| 1 |
- System.register([],(function(e,t){"use strict";return{execute:function(){e({BitMask:ot,CCClass:$t,CacheMode:void 0,DebugMode:void 0,Enum:ct,Eventify:T_,GFXAPI:void 0,GFXAddress:void 0,GFXAttributeName:void 0,GFXBlendFactor:void 0,GFXBlendOp:void 0,GFXBufferAccessBit:void 0,GFXBufferFlagBit:void 0,GFXBufferUsageBit:void 0,GFXClearFlag:void 0,GFXColorMask:void 0,GFXCommandBufferType:void 0,GFXComparisonFunc:void 0,GFXCullMode:void 0,GFXDescriptorType:void 0,GFXDynamicStateFlagBit:void 0,GFXFeature:void 0,GFXFilter:void 0,GFXFormat:void 0,GFXFormatSize:As,GFXFormatSurfaceSize:xs,GFXFormatType:void 0,GFXLoadOp:void 0,GFXMemoryUsageBit:void 0,GFXObjectType:void 0,GFXPipelineBindPoint:void 0,GFXPolygonMode:void 0,GFXPrimitiveMode:void 0,GFXQueueType:void 0,GFXSampleCount:void 0,GFXShadeModel:void 0,GFXShaderStageFlagBit:void 0,GFXStencilFace:void 0,GFXStencilOp:void 0,GFXStoreOp:void 0,GFXSurfaceTransform:void 0,GFXTextureFlagBit:void 0,GFXTextureLayout:void 0,GFXTextureType:void 0,GFXTextureUsageBit:void 0,GFXType:void 0,HorizontalTextAlignment:void 0,InstanceMaterialType:void 0,Overflow:void 0,SystemEventType:void 0,VerticalTextAlignment:void 0,WorldNode3DToLocalNodeUI:gA,WorldNode3DToWorldNodeUI:vA,absMax:xn,absMaxComponent:An,approx:on,assert:d,assertID:R,bezier:gM,bezierByTime:xM,ccenum:ht,clamp:cn,clamp01:ln,color:Rn,computeRatioByType:wM,deserialize:Af,earcut:VY,equals:sn,error:f,errorID:A,find:nw,fragmentText:Ok,getBaselineOffset:function(){return 0},getError:b,getPathFromRoot:function(e,t){for(var n=e,i="";null!==n&&n!==t;)i=n.name+"/"+i,n=n.parent;return i.slice(0,-1)},getWorldTransformUntilRoot:HN,instantiate:IE,inverseLerp:Tn,isCustomTargetModifier:KN,isDisplayStats:w,isElementModifier:YN,isPropertyModifier:XN,isUnicodeCJK:Rk,isUnicodeSpace:bk,isValid:d_,lerp:un,log:h,logID:y,markAsWarning:void 0,mat4:jn,murmurhash2_32_gc:Vs,nextPow2:yn,pingPong:En,pseudoRandom:mn,pseudoRandomRange:gn,pseudoRandomRangeInt:vn,quat:Gn,randomRange:dn,randomRangeInt:pn,rect:ni,removeProperty:void 0,repeat:Sn,replaceProperty:void 0,safeMeasureText:wk,sampleAnimationCurve:bM,setDefaultLogTimes:function(e){e>0&&(he=e)},setDisplayStats:I,size:ei,toDegree:_n,toRadian:hn,v2:Kn,v3:On,v4:Qn,warn:_,warnID:E});var n="undefined"==typeof window?global:window,i=e("cclegacy",{_global:n});i.internal={},n.CC_BUILD=!0,n.CC_TEST=!1,n.CC_EDITOR=!1,n.CC_PREVIEW=!1,n.CC_DEV=!1,n.CC_DEBUG=!1,n.CC_JSB=!1,n.CC_BYTEDANCE=!1,n.CC_WECHAT=!1,n.CC_ALIPAY=!1,n.CC_XIAOMI=!1,n.CC_BAIDU=!1,n.CC_COCOSPLAY=!1,n.CC_HUAWEI=!1,n.CC_OPPO=!1,n.CC_VIVO=!1,n.CC_MINIGAME=!1,n.CC_RUNTIME_BASED=!1,n.CC_SUPPORT_JIT=!0,n.CocosEngine=i.ENGINE_VERSION="3.0.0",n.cc=i;var r="https://github.com/cocos-creator/engine/blob/3d/EngineErrorMap.md",a=null,s=console.log.bind(console),o=s,c=s,l=function(e,t){if(!e){for(var n=arguments.length,i=new Array(n>2?n-2:0),r=2;r<n;r++)i[r-2]=arguments[r];console.log("ASSERT: "+u.apply(void 0,[t].concat(i)))}};function u(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return i.js.formatStr.apply(null,[e].concat(n))}function h(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return s.apply(void 0,[e].concat(n))}function _(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return o.apply(void 0,[e].concat(n))}function f(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return c.apply(void 0,[e].concat(n))}function d(e,t){for(var n=arguments.length,i=new Array(n>2?n-2:0),r=2;r<n;r++)i[r-2]=arguments[r];return l.apply(void 0,[e,t].concat(i))}function p(e){if(s=o=c=l=function(){},e!==x.NONE){if(e>x.ERROR){var t=function(e){if(i.game.canvas){if(!a){var t=document.createElement("Div");t.setAttribute("id","logInfoDiv"),t.setAttribute("width","200"),t.setAttribute("height",i.game.canvas.height);var n=t.style;n.zIndex="99999",n.position="absolute",n.top=n.left="0",(a=document.createElement("textarea")).setAttribute("rows","20"),a.setAttribute("cols","30"),a.setAttribute("disabled","true");var r=a.style;r.backgroundColor="transparent",r.borderBottom="1px solid #cccccc",r.borderTopWidth=r.borderLeftWidth=r.borderRightWidth="0px",r.borderTopStyle=r.borderLeftStyle=r.borderRightStyle="none",r.padding="0px",r.margin="0px",t.appendChild(a),i.game.canvas.parentNode.appendChild(t)}a.value=a.value+e+"\r\n",a.scrollTop=a.scrollHeight}};c=function(e){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];t("ERROR : "+u.apply(void 0,[e].concat(i)))},l=function(e,n){if(!e){for(var i=arguments.length,r=new Array(i>2?i-2:0),a=2;a<i;a++)r[a-2]=arguments[a];t("ASSERT: "+u.apply(void 0,[n].concat(r)))}},e!==x.ERROR_FOR_WEB_PAGE&&(o=function(e){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];t("WARN : "+u.apply(void 0,[e].concat(i)))}),e===x.INFO_FOR_WEB_PAGE&&(s=function(e){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];t(u.apply(void 0,[e].concat(i)))})}else console&&console.log.apply&&(console.error||(console.error=console.log),console.warn||(console.warn=console.log),c=console.error.bind?console.error.bind(console):function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return console.error.apply(console,[e].concat(n))},l=function(e,t){if(!e){for(var n=arguments.length,i=new Array(n>2?n-2:0),r=2;r<n;r++)i[r-2]=arguments[r];var a=u.apply(void 0,[t].concat(i));throw new Error(a)}});e!==x.ERROR&&(o=console.warn.bind?console.warn.bind(console):function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return console.warn.apply(console,[e].concat(n))}),e===x.INFO&&(s=console.log.bind?console.log.bind(console):function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return console.log.apply(console,[e].concat(n))})}}function m(e){f(e.stack||e)}function g(e){return function(t){for(var n=e+" "+t+", please go to "+r+"#"+t+" to see details.",i=arguments.length,a=new Array(i>1?i-1:0),s=1;s<i;s++)a[s-1]=arguments[s];return 0===a.length?n:n+" Arguments: "+a.join(", ")}}var v=g("Log");function y(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];h(v.apply(void 0,[e].concat(n)))}var S=g("Warning");function E(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];_(S.apply(void 0,[e].concat(n)))}var T=g("Error");function A(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];f(T.apply(void 0,[e].concat(n)))}var x,C=g("Assert");function R(e,t){if(!e){for(var n=arguments.length,i=new Array(n>2?n-2:0),r=2;r<n;r++)i[r-2]=arguments[r];d(!1,C.apply(void 0,[t].concat(i)))}}function b(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return T.apply(void 0,[e].concat(n))}function w(){return!!i.profiler&&i.profiler.isShowingStats()}function I(e){i.profiler&&(e?i.profiler.showStats():i.profiler.hideStats(),i.game.config.showFPS=!!e)}!function(e){e[e.NONE=0]="NONE",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e[e.INFO_FOR_WEB_PAGE=4]="INFO_FOR_WEB_PAGE",e[e.WARN_FOR_WEB_PAGE=5]="WARN_FOR_WEB_PAGE",e[e.ERROR_FOR_WEB_PAGE=6]="ERROR_FOR_WEB_PAGE"}(x||(x=e("DebugMode",{})));var O=Object.freeze({__proto__:null,log:h,warn:_,error:f,assert:d,_resetDebugSetting:p,_throw:m,logID:y,warnID:E,errorID:A,assertID:R,get DebugMode(){return x},getError:b,isDisplayStats:w,setDisplayStats:I}),P=/(\.[^\.\/\?\\]*)(\?.*)?$/,M=/((.*)(\/|\\|\\\\))?(.*?\..*$)?/,N=/[^\.\/]+\/\.\.\//;function D(){for(var e="",t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];for(var r=0,a=n;r<a.length;r++){var s=a[r];e=(e+(""===e?"":"/")+s).replace(/(\/|\\\\)$/,"")}return e}function B(e){var t=P.exec(e);return t?t[1]:""}function L(e){if(e){var t=e.lastIndexOf(".");if(-1!==t)return e.substring(0,t)}return e}function F(e,t){var n=e.indexOf("?");n>0&&(e=e.substring(0,n));var i=/(\/|\\)([^\/\\]+)$/g.exec(e.replace(/(\/|\\)$/,""));if(!i)return e;var r=i[2];return t&&e.substring(e.length-t.length).toLowerCase()===t.toLowerCase()?r.substring(0,r.length-t.length):r}function z(e){var t=M.exec(e);return t?t[2]:""}function U(e,t){t=t||"";var n=e.indexOf("?"),i="";return n>0&&(i=e.substring(n),e=e.substring(0,n)),(n=e.lastIndexOf("."))<0?e+t+i:e.substring(0,n)+t+i}function G(e,t,n){if(0===t.indexOf("."))return U(e,t);var i=e.indexOf("?"),r="",a=n?B(e):"";return i>0&&(r=e.substring(i),e=e.substring(0,i)),i=(i=e.lastIndexOf("/"))<=0?0:i+1,e.substring(0,i)+t+a+r}function k(e){var t=e=String(e);do{t=e,e=e.replace(N,"")}while(t.length!==e.length);return e}function H(e){return e.replace(/[\/\\]$/,"")}function V(){return i.sys.os===i.sys.OS_WINDOWS?"\\":"/"}function W(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function j(e,t,n){return t&&W(e.prototype,t),n&&W(e,n),e}function q(){return(q=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e}).apply(this,arguments)}function X(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function Y(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function K(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function Z(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e){if(e){if("string"==typeof e)return K(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?K(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}function Q(e,t,n,i){n&&Object.defineProperty(e,t,{enumerable:n.enumerable,configurable:n.configurable,writable:n.writable,value:n.initializer?n.initializer.call(i):void 0})}function J(e,t,n,i,r){var a={};return Object.keys(i).forEach((function(e){a[e]=i[e]})),a.enumerable=!!a.enumerable,a.configurable=!!a.configurable,("value"in a||a.initializer)&&(a.writable=!0),a=n.slice().reverse().reduce((function(n,i){return i(e,t,n)||n}),a),r&&void 0!==a.initializer&&(a.value=a.initializer?a.initializer.call(r):void 0,a.initializer=void 0),void 0===a.initializer&&(Object.defineProperty(e,t,a),a=null),a}e("path",Object.freeze({__proto__:null,join:D,extname:B,mainFileName:L,basename:F,dirname:z,changeExtname:U,changeBasename:G,_normalize:k,stripSep:H,getSeperator:V})),i.log=h,i.warn=_,i.error=f,i.assert=d,i._throw=m,i.logID=y,i.warnID=E,i.errorID=A,i.assertID=R,i.debug=O,i.path={join:D,extname:B,mainFileName:L,basename:F,dirname:z,changeExtname:U,changeBasename:G,_normalize:k,stripSep:H,get sep(){return V()}};var $=0,ee={};function te(e){var t,n;return t=(e>65535)<<4,t|=n=((e>>>=t)>255)<<3,t|=n=((e>>>=n)>15)<<2,(t|=n=((e>>>=n)>3)<<1)|(e>>>=n)>>1}function ne(e){var t=32;return(e&=-e)&&t--,65535&e&&(t-=16),16711935&e&&(t-=8),252645135&e&&(t-=4),858993459&e&&(t-=2),1431655765&e&&(t-=1),t}function ie(e){return e+=0===e,--e,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,1+(e|=e>>>16)}var re=new Array(256);!function(e){for(var t=0;t<256;++t){var n=t,i=t,r=7;for(n>>>=1;n;n>>>=1)i<<=1,i|=1&n,--r;e[t]=i<<r&255}}(re);var ae=Object.freeze({__proto__:null,INT_BITS:32,INT_MAX:2147483647,INT_MIN:-1<<31,sign:function(e){return(e>0)-(e<0)},abs:function(e){var t=e>>31;return(e^t)-t},min:function(e,t){return t^(e^t)&-(e<t)},max:function(e,t){return e^(e^t)&-(e<t)},isPow2:function(e){return!(e&e-1||!e)},log2:te,log10:function(e){return e>=1e9?9:e>=1e8?8:e>=1e7?7:e>=1e6?6:e>=1e5?5:e>=1e4?4:e>=1e3?3:e>=100?2:e>=10?1:0},popCount:function(e){return 16843009*((e=(858993459&(e-=e>>>1&1431655765))+(e>>>2&858993459))+(e>>>4)&252645135)>>>24},countTrailingZeros:ne,nextPow2:ie,prevPow2:function(e){return e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,(e|=e>>>16)-(e>>>1)},parity:function(e){return e^=e>>>16,e^=e>>>8,e^=e>>>4,27030>>>(e&=15)&1},reverse:function(e){return re[255&e]<<24|re[e>>>8&255]<<16|re[e>>>16&255]<<8|re[e>>>24&255]},interleave2:function(e,t){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e&=65535)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t&=65535)|t<<8))|t<<4))|t<<2))|t<<1))<<1},deinterleave2:function(e,t){return(e=65535&((e=16711935&((e=252645135&((e=858993459&((e=e>>>t&1431655765)|e>>>1))|e>>>2))|e>>>4))|e>>>16))<<16>>16},interleave3:function(e,t,n){return e=1227133513&((e=3272356035&((e=251719695&((e=4278190335&((e&=1023)|e<<16))|e<<8))|e<<4))|e<<2),(e|=(t=1227133513&((t=3272356035&((t=251719695&((t=4278190335&((t&=1023)|t<<16))|t<<8))|t<<4))|t<<2))<<1)|(n=1227133513&((n=3272356035&((n=251719695&((n=4278190335&((n&=1023)|n<<16))|n<<8))|n<<4))|n<<2))<<2},deinterleave3:function(e,t){return(e=1023&((e=4278190335&((e=251719695&((e=3272356035&((e=e>>>t&1227133513)|e>>>2))|e>>>4))|e>>>8))|e>>>16))<<22>>22},nextCombination:function(e){var t=e|e-1;return t+1|(~t&-~t)-1>>>ne(e)+1}});e("bits",ae);var se,oe,ce,le,ue,he=10,_e=0,fe=new Map;ce=function(e,t,n,i,r,a){var s=fe.get(a);s&&s.logTimes>s.count&&(r("'%s' is deprecated, please use '%s' instead.",e+"."+t,n+"."+i),s.count++)},se=e("replaceProperty",(function(e,t,n){null!=e&&n.forEach((function(n){var i=_e++;fe.set(i,{id:i,count:0,logTimes:void 0!==n.logTimes?n.logTimes:he});var r=null!=n.target?n.target:e,a=null!=n.newName?n.newName:n.name,s=null!=n.targetName?n.targetName:t,o=r==e;if(null!=n.customFunction)e[n.name]=function(){var e;return ce(t,n.name,s,a,_,i),(e=n.customFunction).call.apply(e,[this].concat(Array.prototype.slice.call(arguments)))};else if(null!=n.customSetter||null!=n.customGetter){var c=null!=n.customSetter,l=null!=n.customGetter;c&&l?Object.defineProperty(e,n.name,{get:function(){return ce(t,n.name,s,a,_,i),n.customGetter.call(this)},set:function(e){ce(t,n.name,s,a,_,i),n.customSetter.call(this,e)},enumerable:!1}):c?Object.defineProperty(e,n.name,{set:function(e){ce(t,n.name,s,a,_,i),n.customSetter.call(this,e)},enumerable:!1}):l&&Object.defineProperty(e,n.name,{get:function(){return ce(t,n.name,s,a,_,i),n.customGetter.call(this)},enumerable:!1})}else Object.defineProperty(e,n.name,{get:function(){return ce(t,n.name,s,a,_,i),o?this[a]:r[a]},set:function(e){ce(t,n.name,s,a,_,i),o?this[a]=e:r[a]=e},enumerable:!1})}))})),ue=function(e,t,n,i,r){var a=fe.get(i),s=void 0===r?"":"("+r+")";a&&a.logTimes>a.count&&(n("'%s' has been removed. "+s,e+"."+t),a.count++)},oe=e("removeProperty",(function(e,t,n){null!=e&&n.forEach((function(n){var i=_e++;fe.set(i,{id:i,count:0,logTimes:void 0!==n.logTimes?n.logTimes:he}),Object.defineProperty(e,n.name,{get:function(){return ue(t,n.name,f,i,n.suggest)},set:function(){ue(t,n.name,f,i,n.suggest)},enumerable:!1})}))})),le=function(e,t,n,i,r){var a=fe.get(i),s=void 0===r?"":"("+r+")";a&&a.logTimes>a.count&&(n("'%s' is deprecated. "+s,e+"."+t),a.count++)},e("markAsWarning",(function(e,t,n){if(null!=e){var i=function(e,t,n,i,r,a){if(e.get){var s=e.get();e.get=function(){return le(t,n,i,r,a),s.call(this)}}if(e.set){var o=Object.create(e.set);e.set=function(e){le(t,n,i,r,a),o.call(this,e)}}};n.forEach((function(n){var r=n.name,a=Object.getOwnPropertyDescriptor(e,r);if(a){var s=_e++;if(fe.set(s,{id:s,count:0,logTimes:void 0!==n.logTimes?n.logTimes:he}),null!=a.value)if("function"==typeof a.value){var o=a.value;e[r]=function(){return le(t,r,_,s,n.suggest),o.call.apply(o,[this].concat(Array.prototype.slice.call(arguments)))}}else i(a,t,r,_,s,n.suggest);else i(a,t,r,_,s,n.suggest);Object.defineProperty(e,r,{enumerable:!1})}}))}}));var de=function(){function e(e){this.i=0,this.array=e}var t=e.prototype;return t.remove=function(e){var t=this.array.indexOf(e);t>=0&&this.removeAt(t)},t.removeAt=function(e){this.array.splice(e,1),e<=this.i&&--this.i},t.fastRemove=function(e){var t=this.array.indexOf(e);t>=0&&this.fastRemoveAt(t)},t.fastRemoveAt=function(e){var t=this.array;t[e]=t[t.length-1],--t.length,e<=this.i&&--this.i},t.push=function(e){this.array.push(e)},j(e,[{key:"length",get:function(){return this.array.length},set:function(e){this.array.length=e,this.i>=e&&(this.i=e-1)}}]),e}();function pe(e,t){e.splice(t,1)}function me(e,t){var n=e.length;t<0||t>=n||(e[t]=e[n-1],e.length=n-1)}function ge(e,t){var n=e.indexOf(t);return n>=0&&(pe(e,n),!0)}function ve(e,t){return e.indexOf(t)>=0}var ye=Object.freeze({__proto__:null,removeAt:pe,fastRemoveAt:me,remove:ge,fastRemove:function(e,t){var n=e.indexOf(t);n>=0&&(e[n]=e[e.length-1],--e.length)},removeIf:function(e,t){var n=e.findIndex(t);if(n>=0){var i=e[n];return pe(e,n),i}},verifyType:function(e,t){if(e&&e.length>0)for(var n,i=Z(e);!(n=i()).done;)if(!(n.value instanceof t))return y(1300),!1;return!0},removeArray:function(e,t){for(var n=0,i=t.length;n<i;n++)ge(e,t[n])},appendObjectsAt:function(e,t,n){return e.splice.apply(e,[n,0].concat(t)),e},contains:ve,copy:function(e){for(var t=e.length,n=new Array(t),i=0;i<t;i+=1)n[i]=e[i];return n},MutableForwardIterator:de}),Se=function(){function e(e){this.id=void 0,this.prefix=void 0,this.id=0|998*Math.random(),this.prefix=e?e+".":""}return e.prototype.getNewId=function(){return this.prefix+ ++this.id},e}();Se.global=new Se("global");var Ee=new Se("TmpCId."),Te="undefined"==typeof Symbol?"__aliases__":Symbol("[[Aliases]]");function Ae(e){return"number"==typeof e||e instanceof Number}function xe(e){return"string"==typeof e||e instanceof String}function Ce(e){for(var t in e)return!1;return!0}var Re,be=(Re={value:void 0,enumerable:!1,writable:!1,configurable:!0},function(e,t,n,i,r){Re.value=n,Re.writable=i,Re.enumerable=r,Object.defineProperty(e,t,Re),Re.value=void 0}),we=function(){var e={get:void 0,set:void 0,enumerable:!1};return function(t,n,i,r,a,s){void 0===a&&(a=!1),void 0===s&&(s=!1),"boolean"==typeof r&&(a=r,r=void 0),e.get=i,e.set=r,e.enumerable=a,e.configurable=s,Object.defineProperty(t,n,e),e.get=void 0,e.set=void 0}}(),Ie=function(){var e={get:void 0,enumerable:!1,configurable:!1};return function(t,n,i,r,a){e.get=i,e.enumerable=r,e.configurable=a,Object.defineProperty(t,n,e),e.get=void 0}}(),Oe=function(){var e={set:void 0,enumerable:!1,configurable:!1};return function(t,n,i,r,a){e.set=i,e.enumerable=r,e.configurable=a,Object.defineProperty(t,n,e),e.set=void 0}}();function Pe(e){var t=Object.create(null);return e&&(t["."]=1,t["/"]=1,delete t["."],delete t["/"]),t}function Me(e){if("function"==typeof e){var t=e.prototype;if(t&&t.hasOwnProperty("__classname__")&&t.__classname__)return t.__classname__;var n="";if(e.name&&(n=e.name),e.toString){var i,r=e.toString();(i="["===r.charAt(0)?r.match(/\[\w+\s*(\w+)\]/):r.match(/function\s*(\w+)/))&&2===i.length&&(n=i[1])}return"Object"!==n?n:""}return e&&e.constructor?Me(e.constructor):""}function Ne(e,t,n,i){var r=/([^.]+)$/,a=r.exec(t)[0],s=r.exec(n)[0];function o(){return this[s]}i?we(e,a,o,(function(e){this[s]=e})):Ie(e,a,o)}function De(e,t,n,i){for(var r in n)Ne(e,t+"."+r,n[r],i)}var Be=/(%d)|(%s)/,Le=/%s/;function Fe(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];if(0===arguments.length)return"";if(0===n.length)return""+e;var r="string"==typeof e&&Be.test(e);if(r)for(var a,s=Z(n);!(a=s()).done;){var o=a.value,c="number"==typeof o?Be:Le;if(c.test(e)){var l=""+o;e=e.replace(c,l)}else e+=" "+o}else for(var u,h=Z(n);!(u=h()).done;){var _=u.value;e+=" "+_}return e}function ze(){for(var e=arguments.length-1,t=new Array(e),n=0;n<e;++n)t[n]=arguments[n+1];return t}function Ue(e,t){for(;e;){var n=Object.getOwnPropertyDescriptor(e,t);if(n)return n;e=Object.getPrototypeOf(e)}return null}function Ge(e,t,n){var i=Ue(t,e);i&&Object.defineProperty(n,e,i)}function ke(e){e=e||{};for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];for(var r=0,a=n;r<a.length;r++){var s=a[r];if(s){if("object"!=typeof s){A(5402,s);continue}for(var o in s)o in e||Ge(o,s,e)}}return e}function He(e){e=e||{};for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];for(var r=0,a=n;r<a.length;r++){var s=a[r];if(s){if("object"!=typeof s){A(5403,s);continue}for(var o in s)Ge(o,s,e)}}return e}function Ve(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e.prototype=Object.create(t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),e}function We(e){var t=e.prototype,n=t&&Object.getPrototypeOf(t);return n&&n.constructor}function je(e,t){if(e&&t){if("function"!=typeof e)return!1;if("function"!=typeof t)return!1;if(e===t)return!0;for(;;){if(!(e=We(e)))return!1;if(e===t)return!0}}return!1}function qe(e){for(var t=0,n=Object.keys(e);t<n.length;t++)delete e[n[t]]}var Xe=Pe(!0),Ye=Pe(!0);function Ke(e,t){return function(n,i){if(i.prototype.hasOwnProperty(e)&&delete t[i.prototype[e]],be(i.prototype,e,n),n){var r=t[n];r&&r!==i?f("A Class already exists with the same "+e+' : "'+n+'".'):t[n]=i}}}var Ze=Ke("__cid__",Xe),Qe=Ke("__classname__",Ye);function Je(e,t){if(Qe(e,t),!t.prototype.hasOwnProperty("__cid__")){var n=e||Ee.getNewId();n&&Ze(n,t)}}function $e(e,t){var n=Ye[t],i=Xe[t],r=!0;if(n&&n!==e&&(f('"'+t+'" has already been set as name or alias of another class.'),r=!1),i&&i!==e&&(f('"'+t+'" has already been set as id or alias of another class.'),r=!1),r){var a=e[Te];a||(a=[],e[Te]=a),a.push(t),Ye[t]=e,Xe[t]=e}}function et(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];for(var i=0,r=t;i<r.length;i++){var a=r[i],s=a.prototype,o=s.__cid__;o&&delete Xe[o];var c=s.__classname__;c&&delete Ye[c];var l=s[Te];if(l)for(var u=0;u<l.length;++u){var h=l[u];delete Ye[h],delete Xe[h]}}}function tt(e){return Xe[e]}function nt(e){return Ye[e]}function it(e,t){if(t=void 0===t||t,"function"==typeof e&&e.prototype.hasOwnProperty("__cid__"))return e.prototype.__cid__;if(e&&e.constructor){var n=e.constructor.prototype;if(n&&n.hasOwnProperty("__cid__"))return e.__cid__}return""}var rt=function(){var e=t.prototype;function t(e,t){this.count=void 0,this._pool=void 0,this._cleanup=void 0;var n=void 0===t?e:t,i=void 0===t?null:e;this.count=0,this._pool=new Array(n),this._cleanup=i}return e.get=function(){return this._get()},e._get=function(){if(this.count>0){--this.count;var e=this._pool[this.count];return this._pool[this.count]=null,e}return null},e.put=function(e){var t=this._pool;if(this.count<t.length){if(this._cleanup&&!1===this._cleanup(e))return;t[this.count]=e,++this.count}},e.resize=function(e){e>=0&&(this._pool.length=e,this.count>e&&(this.count=e))},t}(),at=ye,st={IDGenerator:Se,Pool:rt,array:ye,isNumber:Ae,isString:xe,isEmptyObject:Ce,getPropertyDescriptor:Ue,addon:ke,mixin:He,extend:Ve,getSuper:We,isChildClassOf:je,clear:qe,value:be,getset:we,get:Ie,set:Oe,unregisterClass:et,getClassName:Me,setClassName:Je,setClassAlias:$e,getClassByName:nt,get _registeredClassNames(){return q({},Ye)},set _registeredClassNames(e){qe(Ye),Object.assign(Ye,e)},get _registeredClassIds(){return q({},Xe)},set _registeredClassIds(e){qe(Xe),Object.assign(Xe,e)},_getClassId:it,_setClassId:Ze,_getClassById:tt,obsolete:Ne,obsoletes:De,formatStr:Fe,shiftArguments:ze,createMap:Pe};function ot(e){if("__bitmask__"in e)return e;be(e,"__bitmask__",null,!0);for(var t=-1,n=Object.keys(e),i=0;i<n.length;i++){var r=n[i],a=e[r];if(-1===a)a=++t,e[r]=a;else if("number"==typeof a)t=a;else if("string"==typeof a&&Number.isInteger(parseFloat(r)))continue;var s=""+a;r!==s&&be(e,s,r)}return e}function ct(e){return"__enums__"in e?e:(be(e,"__enums__",null,!0),ct.update(e))}function lt(e){e.hasOwnProperty("__enums__")}function ut(e){lt(e);var t=e.__enums__||[];for(var n in t.length=0,e){var i=e[n];Number.isInteger(i)&&t.push({name:n,value:i})}return t.sort((function(e,t){return e.value-t.value})),e.__enums__=t,t}function ht(e){"__enums__"in e||be(e,"__enums__",null,!0)}i.js=st,e("js",Object.freeze({__proto__:null,array:at,js:st,IDGenerator:Se,Pool:rt,isNumber:Ae,isString:xe,isEmptyObject:Ce,value:be,getset:we,get:Ie,set:Oe,createMap:Pe,getClassName:Me,obsolete:Ne,obsoletes:De,formatStr:Fe,shiftArguments:ze,getPropertyDescriptor:Ue,addon:ke,mixin:He,extend:Ve,getSuper:We,isChildClassOf:je,clear:qe,_idToClass:Xe,_nameToClass:Ye,_setClassId:Ze,setClassName:Je,setClassAlias:$e,unregisterClass:et,_getClassById:tt,getClassByName:nt,_getClassId:it})),ot.isBitMask=function(e){return e&&e.hasOwnProperty("__bitmask__")},ot.getList=function(e){if(e.__bitmask__)return e.__bitmask__;var t=e.__bitmask__=[];for(var n in e){var i=e[n];Number.isInteger(i)&&t.push({name:n,value:i})}return t.sort((function(e,t){return e.value-t.value})),t},i.BitMask=ot,ct.update=function(e){for(var t=-1,n=Object.keys(e),i=0;i<n.length;i++){var r=n[i],a=e[r];if(-1===a)a=++t,e[r]=a;else if("number"==typeof a)t=a;else if("string"==typeof a&&Number.isInteger(parseFloat(r)))continue;var s=""+a;r!==s&&be(e,s,r)}return Array.isArray(e.__enums__)&&ut(e),e},ct||(ct=e("Enum",{})),ct.isEnum=function(e){return e&&e.hasOwnProperty("__enums__")},ct.getList=function(e){return lt(e),e.__enums__?e.__enums__:ut(e)},i.Enum=ct;var _t=e("ValueType",function(){function e(){}var t=e.prototype;return t.clone=function(){return A(100,Me(this)+".clone"),this},t.equals=function(){return!1},t.set=function(){A(100,Me(this)+".set")},t.toString=function(){return""+{}},e}());Je("cc.ValueType",_t),i.ValueType=_t;var ft=e("macro",{SUPPORT_TEXTURE_FORMATS:[".astc",".pkm",".pvr",".webp",".jpg",".jpeg",".bmp",".png"],KEY:{none:0,back:6,menu:18,backspace:8,tab:9,enter:13,shift:16,ctrl:17,alt:18,pause:19,capslock:20,escape:27,space:32,pageup:33,pagedown:34,end:35,home:36,left:37,up:38,right:39,down:40,select:41,insert:45,Delete:46,0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,a:65,b:66,c:67,d:68,e:69,f:70,g:71,h:72,i:73,j:74,k:75,l:76,m:77,n:78,o:79,p:80,q:81,r:82,s:83,t:84,u:85,v:86,w:87,x:88,y:89,z:90,num0:96,num1:97,num2:98,num3:99,num4:100,num5:101,num6:102,num7:103,num8:104,num9:105,"*":106,"+":107,"-":109,numdel:110,"/":111,f1:112,f2:113,f3:114,f4:115,f5:116,f6:117,f7:118,f8:119,f9:120,f10:121,f11:122,f12:123,numlock:144,scrolllock:145,";":186,semicolon:186,equal:187,"=":187,",":188,comma:188,dash:189,".":190,period:190,forwardslash:191,grave:192,"[":219,openbracket:219,backslash:220,"]":221,closebracket:221,quote:222,dpadLeft:1e3,dpadRight:1001,dpadUp:1003,dpadDown:1004,dpadCenter:1005},RAD:Math.PI/180,DEG:180/Math.PI,REPEAT_FOREVER:Number.MAX_VALUE-1,FLT_EPSILON:1.192092896e-7,ORIENTATION_PORTRAIT:1,ORIENTATION_LANDSCAPE:2,ORIENTATION_AUTO:3,ENABLE_TILEDMAP_CULLING:!0,TOUCH_TIMEOUT:5e3,ENABLE_TRANSPARENT_CANVAS:!1,ENABLE_WEBGL_ANTIALIAS:!0,CLEANUP_IMAGE_CACHE:!1,ENABLE_MULTI_TOUCH:!0,MAX_LABEL_CANVAS_POOL_SIZE:20});i.macro=ft;for(var dt=/^(?:cc|dragonBones|sp|ccsg)\..+/,pt=new Array(123),mt=0;mt<123;++mt)pt[mt]=64;for(var gt=0;gt<64;++gt)pt["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charCodeAt(gt)]=gt;var vt=pt;function yt(e,t,n){function i(e,t,n,i){var r=Object.getOwnPropertyDescriptor(e,t);if(r)r.get&&(e[n]=r.get),r.set&&i&&(e[i]=r.set);else{var a=e[n];we(e,t,a,e[i])}}for(var r,a=e.prototype,s=0;s<t.length;s++){var o=(r=t[s])[0].toUpperCase()+r.slice(1);i(a,r,"get"+o,"set"+o)}for(r in n){var c=n[r];i(a,r,c[0],c[1])}}function St(e,t,n,i){var r=e[t];r?Array.isArray(r)?i?(r.push(r[0]),r[0]=n):r.push(n):e[t]=i?[n,r]:[r,n]:e[t]=n}function Et(e,t){if("function"==typeof e.contains)return e.contains(t);if("function"==typeof e.compareDocumentPosition)return!!(16&e.compareDocumentPosition(t));var n=t.parentNode;if(n)do{if(n===e)return!0;n=n.parentNode}while(null!==n);return!1}function Tt(e){return"object"==typeof window&&"function"==typeof Node?e instanceof Node:e&&"object"==typeof e&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName}function At(e,t,n){e&&setTimeout((function(){e(t,n)}),0)}function xt(e){return!(!e||e.constructor!==Object)&&Ce(e)}function Ct(e,t,n){if(t>n){var i=t;t=n,n=i}return e<t?t:e<n?e:n}function Rt(e){return e*ft.RAD}function bt(e){return e*ft.DEG}function wt(e,t){var n=t?Object.create(t):{};return be(e,"__attrs__",n),n}function It(e){if("function"!=typeof e)return wt(e,Pt(e.constructor));for(var t,n=i.Class.getInheritanceChain(e),r=n.length-1;r>=0;r--){var a=n[r];a.hasOwnProperty("__attrs__")&&a.__attrs__||wt(a,(t=n[r+1])&&t.__attrs__)}return wt(e,(t=n[0])&&t.__attrs__),e.__attrs__}function Ot(e,t){var n=Pt(e),i=t+"$_$",r={};for(var a in n)a.startsWith(i)&&(r[a.slice(i.length)]=n[a]);return r}function Pt(e){return e.hasOwnProperty("__attrs__")&&e.__attrs__||It(e)}function Mt(e,t,n,i){Pt(e)[t+"$_$"+n]=i}i.misc={BUILTIN_CLASSID_RE:dt,BASE64_VALUES:vt,propertyDefine:yt,pushToMap:St,contains:Et,isDomNode:Tt,callInNextTick:At,isPlainEmptyObj_DEV:xt,clampf:Ct,degreesToRadians:Rt,radiansToDegrees:bt},e("misc",Object.freeze({__proto__:null,BUILTIN_CLASSID_RE:dt,BASE64_VALUES:vt,propertyDefine:yt,pushToMap:St,contains:Et,isDomNode:Tt,callInNextTick:At,tryCatchFunctor_EDITOR:function(e){return Function("target","try {\n target."+e+"();\n}\ncatch (e) {\n cc._throw(e);\n}")},isPlainEmptyObj_DEV:xt,clampf:Ct,degreesToRadians:Rt,radiansToDegrees:bt}));var Nt=function(){function e(e,t){this.name=void 0,this.default=void 0,this.name=e,this.default=t}return e.prototype.toString=function(){return this.name},e}(),Dt=e("CCInteger",new Nt("Integer",0));i.Integer=Dt,i.CCInteger=Dt;var Bt=e("CCFloat",new Nt("Float",0));i.Float=Bt,i.CCFloat=Bt;var Lt=e("CCBoolean",new Nt("Boolean",!1));i.Boolean=Lt,i.CCBoolean=Lt;var Ft=e("CCString",new Nt("String",""));function zt(e,t){return function(n,i){var r='"'+Me(n)+"."+i+'"',a=Ot(n,i),s=a.type;if(s===Dt||s===Bt?s="Number":s!==Ft&&s!==Lt||(s=""+s),s===e){if(a.hasOwnProperty("default")){var o=a.default;if(void 0!==o&&!Array.isArray(o)&&!xt(o)){var c=typeof o,l=e.toLowerCase();if(c===l)if("object"===l){if(!o||o instanceof a.ctor)return;E(3605,r,Me(a.ctor))}else"Number"!==e&&E(3606,t,r,e);else{if("function"===c)return;e===Ft.default&&null==o?E(3607,r):E(3611,t,r,c)}delete a.type}}}else E(3604,r)}}i.String=Ft,i.CCString=Ft;var Ut=Object.freeze({__proto__:null,DELIMETER:"$_$",createAttrsSingle:wt,createAttrs:It,attr:Ot,getClassAttrs:Pt,setClassAttr:Mt,PrimitiveType:Nt,CCInteger:Dt,CCFloat:Bt,CCBoolean:Lt,CCString:Ft,getTypeChecker_ET:zt,getObjTypeChecker_ET:function(e){return function(t,n){zt("Object","type")(t,n);var r=Pt(t)[n+"$_$default"],a=i.Class.getDefault(r);if(!Array.isArray(a)&&je(e,i.ValueType)){var s=Me(e),o=Fe('No need to specify the "type" of "%s.%s" because %s is a child class of ValueType.',Me(t),n,s);r?h(o):E(3612,o,s,Me(t),n,s)}}}}),Gt={default:{},serializable:{},editorOnly:{},formerlySerializedAs:{}};function kt(e,t,n,i){if(!e.get&&!e.set&&e.hasOwnProperty("default")){var r="_N$"+t;e.get=function(){return this[r]},e.set=function(e){var t=this[r];this[r]=e,n.call(this,t)};var a={};for(var s in i[r]=a,Gt){var o=Gt[s];e.hasOwnProperty(s)&&(a[s]=e[s],o.canUsedInGet||delete e[s])}}}function Ht(e,t,n,r){if(Array.isArray(t)){if(!(t.length>0))return A(5508,n,r);e.type=t=t[0]}"function"==typeof t&&(t===String?e.type=i.String:t===Boolean?e.type=i.Boolean:t===Number&&(e.type=i.Float))}function Vt(e,t,n){var i=e?{_short:!0}:{_short:!0,default:t};return n&&(i.type=n),i}function Wt(e,t){if(!e||e.constructor!==Object){if(Array.isArray(e)&&e.length>0)return Vt(t,[],e);if("function"==typeof e){var n=e;return Vt(t,je(n,i.ValueType)?new n:null,n)}return Vt(t,e instanceof Nt?e.default:e)}return null}var jt=[];function qt(){return jt[jt.length-1]}i._RF={push:function(e,t,n,i){void 0===n&&(n=t,t=""),jt.push({uuid:t,script:n,module:e,exports:e.exports,beh:null,importMeta:i})},pop:function(){var e=jt.pop(),t=e.module,n=t.exports;if(n===e.exports){for(var i in n)return;t.exports=n=e.cls}},peek:qt};var Xt={datas:null,push:function(e){if(this.datas)this.datas.push(e);else{this.datas=[e];var t=this;setTimeout((function(){t.init()}),0)}},init:function(){var e=this.datas;if(e){for(var t=0;t<e.length;++t){var n=e[t],i=n.cls,r=n.props;"function"==typeof r&&(r=r());var a=Me(i);r?Jt(i,a,r,i.$super,n.mixins):A(3633,a)}this.datas=null}}};function Yt(e,t,n,i){!function(e,t){!function(e,t){e.indexOf(t)<0&&e.push(t)}(e.__props__,t)}(e,n),tn(e,i,t,n)}function Kt(e,t,n,i){var r=i.get;i.set,r&&(tn(e,i,t,n),Mt(e,n,"serializable",!1))}function Zt(e){return"function"==typeof e?e():e}function Qt(e,t,n){for(var i in t)e.hasOwnProperty(i)||n&&!n(i)||Object.defineProperty(e,i,Ue(t,i))}function Jt(e,t,n,i,r){if(e.__props__=[],i&&i.__props__&&(e.__props__=i.__props__.slice()),r)for(var a=0;a<r.length;++a){var s=r[a];s.__props__&&(e.__props__=e.__props__.concat(s.__props__.filter((function(t){return e.__props__.indexOf(t)<0}))))}if(n)for(var o in function(e,t){for(var n in e){var i=e[n],r=Wt(i,!1);if(r&&(i=e[n]=r),i){var a=i.notify;a&&kt(i,n,a,e),"type"in i&&Ht(i,i.type,t,n)}}}(n,t),n){var c=n[o];c.get||c.set?Kt(e,t,o,c):Yt(e,t,o,c)}var l=Pt(e);e.__values__=e.__props__.filter((function(e){return!1!==l[e+"$_$serializable"]}))}function $t(e){var t=e.name,n=e.extends,r=e.mixins,a=function(e,t,n,r){var a=i.Component,s=qt();if(s&&je(t,a)){if(je(s.cls,a))return A(3615),null;e=e||s.script}var o=function(e,t,n,i){var r=i.ctor,a=[r],s=r;be(s,"__ctors__",a.length>0?a:null,!0);var o=s.prototype;if(t&&(s.$super=t),n){for(var c=n.length-1;c>=0;c--){var l=n[c];Qt(o,l.prototype),$t._isCCClass(l)&&Qt(Pt(s),Pt(l))}o.constructor=s}return Je(e,s),s}(e,t,n,r);if(s)if(je(t,a)){var c=s.uuid;c&&Ze(c,o),s.cls=o}else je(s.cls,a)||(s.cls=o);return o}(t,n,r,e);t||(t=i.js.getClassName(a)),a._sealed=!0,n&&(n._sealed=!1);var s=e.properties;"function"==typeof s||n&&null===n.__props__||r&&r.some((function(e){return null===e.__props__}))?(Xt.push({cls:a,props:s,mixins:r}),a.__props__=a.__values__=null):Jt(a,t,s,n,e.mixins);var o=e.editor;return o&&je(n,i.Component)&&i.Component._registerEditorProps(a,o),a}$t._isCCClass=function(e){var t;return null==e||null===(t=e.hasOwnProperty)||void 0===t?void 0:t.call(e,"__ctors__")},$t.fastDefine=function(e,t,n){Je(e,t);for(var i=t.__props__=t.__values__=Object.keys(n),r=Pt(t),a=0;a<i.length;a++){var s=i[a];r[s+"$_$visible"]=!1,r[s+"$_$default"]=n[s]}},$t.Attr=Ut,$t.attr=Ot,$t.getInheritanceChain=function(e){for(var t=[];e=We(e);)e!==Object&&t.push(e);return t};var en={Integer:"Number",Float:"Number",Boolean:"Boolean",String:"String"};function tn(e,t,n,i){var r=null,a="";function s(){return a=i+"$_$",r=Pt(e)}"type"in t&&void 0===t.type&&E(3660,i,n);var o=t.type;o&&(en[o]?(r||s())[a+"type"]=o:"Object"===o||("object"==typeof o?ct.isEnum(o)?((r||s())[a+"type"]="Enum",r[a+"enumList"]=ct.getList(o)):ot.isBitMask(o)&&((r||s())[a+"type"]="BitMask",r[a+"bitmaskList"]=ot.getList(o)):"function"==typeof o&&((r||s())[a+"type"]="Object",r[a+"ctor"]=o))),"default"in t&&((r||s())[a+"default"]=t.default);var c,l=function(e,n){if(e in t){var i=t[e];typeof i===n&&((r||s())[a+e]=i)}};t.editorOnly&&((r||s())[a+"editorOnly"]=!0),t.__noImplicit?(r||s())[a+"serializable"]=null!==(c=t.serializable)&&void 0!==c&&c:!1===t.serializable&&((r||s())[a+"serializable"]=!1),l("formerlySerializedAs","string");var u=t.range;u&&Array.isArray(u)&&u.length>=2&&((r||s())[a+"min"]=u[0],r[a+"max"]=u[1],u.length>2&&(r[a+"step"]=u[2])),l("min","number"),l("max","number"),l("step","number")}$t.isArray=function(e){return e=Zt(e),Array.isArray(e)},$t.getDefault=Zt,$t.escapeForJS=function(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")},$t.IDENTIFIER_RE=/^[A-Za-z_$][0-9A-Za-z_$]*$/,$t.getNewValueTypeCode=function(e){for(var t=Me(e),n=e.constructor,i="new "+t+"(",r=0;r<n.__props__.length;r++)i+=e[n.__props__[r]],r<n.__props__.length-1&&(i+=",");return i+")"},i.Class=$t;var nn=Math.PI/180,rn=180/Math.PI,an=e("EPSILON",1e-6);function sn(e,t){return Math.abs(e-t)<=an*Math.max(1,Math.abs(e),Math.abs(t))}function on(e,t,n){return n=n||an,Math.abs(e-t)<=n}function cn(e,t,n){if(t>n){var i=t;t=n,n=i}return e<t?t:e>n?n:e}function ln(e){return e<0?0:e>1?1:e}function un(e,t,n){return e+(t-e)*n}function hn(e){return e*nn}function _n(e){return e*rn}var fn=e("random",Math.random);function dn(e,t){return Math.random()*(t-e)+e}function pn(e,t){return Math.floor(dn(e,t))}function mn(e){return(e=(9301*e+49297)%233280)/233280}function gn(e,t,n){return mn(e)*(n-t)+t}function vn(e,t,n){return Math.floor(gn(e,t,n))}function yn(e){return--e,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e}function Sn(e,t){return e-Math.floor(e/t)*t}function En(e,t){return e=Sn(e,2*t),t-Math.abs(e-t)}function Tn(e,t,n){return(n-e)/(t-e)}function An(e){return Math.abs(e.x)>Math.abs(e.y)?Math.abs(e.x)>Math.abs(e.z)?e.x:e.z:Math.abs(e.y)>Math.abs(e.z)?e.y:e.z}function xn(e,t){return Math.abs(e)>Math.abs(t)?e:t}var Cn=e("Color",function(e){function t(t,n,i,r){var a;return(a=e.call(this)||this)._val=0,"string"==typeof t?a.fromHEX(t):void 0!==n?a.set(t,n,i,r):a.set(t),a}X(t,e),t.clone=function(e){var n=new t;return e._val?n._val=e._val:n._val=(e.a<<24>>>0)+(e.b<<16)+(e.g<<8)+e.r,n},t.copy=function(e,t){return e.r=t.r,e.g=t.g,e.b=t.b,e.a=t.a,e},t.set=function(e,t,n,i,r){return e.r=t,e.g=n,e.b=i,e.a=r,e},t.fromHEX=function(e,t){return t=0===t.indexOf("#")?t.substring(1):t,e.r=parseInt(t.substr(0,2),16)||0,e.g=parseInt(t.substr(2,2),16)||0,e.b=parseInt(t.substr(4,2),16)||0,e.a=parseInt(t.substr(6,2),16)||255,e._val=(e.a<<24>>>0)+(e.b<<16)+(e.g<<8)+e.r,e},t.add=function(e,t,n){return e.r=t.r+n.r,e.g=t.g+n.g,e.b=t.b+n.b,e.a=t.a+n.a,e},t.subtract=function(e,t,n){return e.r=t.r-n.r,e.g=t.g-n.g,e.b=t.b-n.b,e.a=t.a-n.a,e},t.multiply=function(e,t,n){return e.r=t.r*n.r,e.g=t.g*n.g,e.b=t.b*n.b,e.a=t.a*n.a,e},t.divide=function(e,t,n){return e.r=t.r/n.r,e.g=t.g/n.g,e.b=t.b/n.b,e.a=t.a/n.a,e},t.scale=function(e,t,n){return e.r=t.r*n,e.g=t.g*n,e.b=t.b*n,e.a=t.a*n,e},t.lerp=function(e,t,n,i){var r=t.r,a=t.g,s=t.b,o=t.a;return r+=(n.r-r)*i,a+=(n.g-a)*i,s+=(n.b-s)*i,o+=(n.a-o)*i,e._val=Math.floor((o<<24>>>0)+(s<<16)+(a<<8)+r),e},t.toArray=function(e,n,i){void 0===i&&(i=0);var r=n instanceof t||n.a>1?1/255:1;return e[i+0]=n.r*r,e[i+1]=n.g*r,e[i+2]=n.b*r,e[i+3]=n.a*r,e},t.fromArray=function(e,t,n){return void 0===n&&(n=0),t.r=255*e[n+0],t.g=255*e[n+1],t.b=255*e[n+2],t.a=255*e[n+3],t},t.strictEquals=function(e,t){return e.r===t.r&&e.g===t.g&&e.b===t.b&&e.a===t.a},t.equals=function(e,t,n){return void 0===n&&(n=an),Math.abs(e.r-t.r)<=n*Math.max(1,Math.abs(e.r),Math.abs(t.r))&&Math.abs(e.g-t.g)<=n*Math.max(1,Math.abs(e.g),Math.abs(t.g))&&Math.abs(e.b-t.b)<=n*Math.max(1,Math.abs(e.b),Math.abs(t.b))&&Math.abs(e.a-t.a)<=n*Math.max(1,Math.abs(e.a),Math.abs(t.a))},t.hex=function(e){return(255*e.r<<24|255*e.g<<16|255*e.b<<8|255*e.a)>>>0},j(t,[{key:"r",get:function(){return 255&this._val},set:function(e){e=~~cn(e,0,255),this._val=(4294967040&this._val|e)>>>0}},{key:"g",get:function(){return(65280&this._val)>>8},set:function(e){e=~~cn(e,0,255),this._val=(4294902015&this._val|e<<8)>>>0}},{key:"b",get:function(){return(16711680&this._val)>>16},set:function(e){e=~~cn(e,0,255),this._val=(4278255615&this._val|e<<16)>>>0}},{key:"a",get:function(){return(4278190080&this._val)>>>24},set:function(e){e=~~cn(e,0,255),this._val=(16777215&this._val|e<<24)>>>0}},{key:"x",get:function(){return this.r*(1/255)},set:function(e){this.r=255*e}},{key:"y",get:function(){return this.g*(1/255)},set:function(e){this.g=255*e}},{key:"z",get:function(){return this.b*(1/255)},set:function(e){this.b=255*e}},{key:"w",get:function(){return this.a*(1/255)},set:function(e){this.a=255*e}}]);var n=t.prototype;return n.clone=function(){var e=new t;return e._val=this._val,e},n.equals=function(e){return e&&this._val===e._val},n.lerp=function(e,t){var n=this.r,i=this.g,r=this.b,a=this.a;return n+=(e.r-n)*t,i+=(e.g-i)*t,r+=(e.b-r)*t,a+=(e.a-a)*t,this._val=Math.floor((a<<24>>>0)+(r<<16)+(i<<8)+n),this},n.toString=function(){return"rgba("+this.r.toFixed()+", "+this.g.toFixed()+", "+this.b.toFixed()+", "+this.a.toFixed()+")"},n.toCSS=function(e){return void 0===e&&(e="rgba"),"rgba"===e?"rgba("+this.r+","+this.g+","+this.b+","+(this.a*(1/255)).toFixed(2)+")":"rgb"===e?"rgb("+this.r+","+this.g+","+this.b+")":"#"+this.toHEX(e)},n.fromHEX=function(e){e=0===e.indexOf("#")?e.substring(1):e;var t=parseInt(e.substr(0,2),16)||0,n=parseInt(e.substr(2,2),16)||0,i=parseInt(e.substr(4,2),16)||0,r=parseInt(e.substr(6,2),16)||255;return this._val=(r<<24>>>0)+(i<<16)+(n<<8)+(0|t),this},n.toHEX=function(e){void 0===e&&(e="#rrggbb");var t=[(this.r<16?"0":"")+this.r.toString(16),(this.g<16?"0":"")+this.g.toString(16),(this.b<16?"0":"")+this.b.toString(16)];return"#rgb"===e?(t[0]=t[0][0],t[1]=t[1][0],t[2]=t[2][0]):"#rrggbbaa"===e&&t.push((this.a<16?"0":"")+this.a.toString(16)),t.join("")},n.toRGBValue=function(){return 16777215&this._val},n.fromHSV=function(e,t,n){var i=0,r=0,a=0;if(0===t)i=r=a=n;else if(0===n)i=r=a=0;else{1===e&&(e=0),e*=6;var s=Math.floor(e),o=e-s,c=n*(1-t),l=n*(1-t*o),u=n*(1-t*(1-o));switch(s){case 0:i=n,r=u,a=c;break;case 1:i=l,r=n,a=c;break;case 2:i=c,r=n,a=u;break;case 3:i=c,r=l,a=n;break;case 4:i=u,r=c,a=n;break;case 5:i=n,r=c,a=l}}return i*=255,r*=255,a*=255,this._val=(this.a<<24>>>0)+(a<<16)+(r<<8)+(0|i),this},n.toHSV=function(){var e=this.r*(1/255),t=this.g*(1/255),n=this.b*(1/255),i={h:0,s:0,v:0},r=Math.max(e,t,n),a=Math.min(e,t,n),s=0;return i.v=r,i.s=r?(r-a)/r:0,i.s?(s=r-a,i.h=e===r?(t-n)/s:t===r?2+(n-e)/s:4+(e-t)/s,i.h/=6,i.h<0&&(i.h+=1)):i.h=0,i},n.set=function(e,t,n,i){return"object"==typeof e?null!=e._val?this._val=e._val:(t=e.g||0,n=e.b||0,i="number"==typeof e.a?e.a:255,e=e.r||0,this._val=(i<<24>>>0)+(n<<16)+(t<<8)+(0|e)):(e=e||0,t=t||0,n=n||0,i="number"==typeof i?i:255,this._val=(i<<24>>>0)+(n<<16)+(t<<8)+(0|e)),this},n.multiply=function(e){var t=(255&this._val)*e.r>>8,n=(65280&this._val)*e.g>>8,i=(16711680&this._val)*e.b>>8,r=((4278190080&this._val)>>>8)*e.a;return this._val=4278190080&r|16711680&i|65280&n|255&t,this},n._set_r_unsafe=function(e){return this._val=(4294967040&this._val|e)>>>0,this},n._set_g_unsafe=function(e){return this._val=(4294902015&this._val|e<<8)>>>0,this},n._set_b_unsafe=function(e){return this._val=(4278255615&this._val|e<<16)>>>0,this},n._set_a_unsafe=function(e){return this._val=(16777215&this._val|e<<24)>>>0,this},t}(_t));function Rn(e,t,n,i){return new Cn(e,t,n,i)}Cn.WHITE=Object.freeze(new Cn(255,255,255,255)),Cn.GRAY=Object.freeze(new Cn(127,127,127,255)),Cn.BLACK=Object.freeze(new Cn(0,0,0,255)),Cn.TRANSPARENT=Object.freeze(new Cn(0,0,0,0)),Cn.RED=Object.freeze(new Cn(255,0,0,255)),Cn.GREEN=Object.freeze(new Cn(0,255,0,255)),Cn.BLUE=Object.freeze(new Cn(0,0,255,255)),Cn.CYAN=Object.freeze(new Cn(0,255,255,255)),Cn.MAGENTA=Object.freeze(new Cn(255,0,255,255)),Cn.YELLOW=Object.freeze(new Cn(255,255,0,255)),$t.fastDefine("cc.Color",Cn,{r:0,g:0,b:0,a:255}),i.Color=Cn,i.color=Rn;var bn=e("Vec3",function(e){function t(t,n,i){var r;return r=e.call(this)||this,t&&"object"==typeof t?(r.x=t.x,r.y=t.y,r.z=t.z):(r.x=t||0,r.y=n||0,r.z=i||0),r}X(t,e),t.zero=function(e){return e.x=0,e.y=0,e.z=0,e},t.clone=function(e){return new t(e.x,e.y,e.z)},t.copy=function(e,t){return e.x=t.x,e.y=t.y,e.z=t.z,e},t.set=function(e,t,n,i){return e.x=t,e.y=n,e.z=i,e},t.add=function(e,t,n){return e.x=t.x+n.x,e.y=t.y+n.y,e.z=t.z+n.z,e},t.subtract=function(e,t,n){return e.x=t.x-n.x,e.y=t.y-n.y,e.z=t.z-n.z,e},t.multiply=function(e,t,n){return e.x=t.x*n.x,e.y=t.y*n.y,e.z=t.z*n.z,e},t.divide=function(e,t,n){return e.x=t.x/n.x,e.y=t.y/n.y,e.z=t.z/n.z,e},t.ceil=function(e,t){return e.x=Math.ceil(t.x),e.y=Math.ceil(t.y),e.z=Math.ceil(t.z),e},t.floor=function(e,t){return e.x=Math.floor(t.x),e.y=Math.floor(t.y),e.z=Math.floor(t.z),e},t.min=function(e,t,n){return e.x=Math.min(t.x,n.x),e.y=Math.min(t.y,n.y),e.z=Math.min(t.z,n.z),e},t.max=function(e,t,n){return e.x=Math.max(t.x,n.x),e.y=Math.max(t.y,n.y),e.z=Math.max(t.z,n.z),e},t.round=function(e,t){return e.x=Math.round(t.x),e.y=Math.round(t.y),e.z=Math.round(t.z),e},t.multiplyScalar=function(e,t,n){return e.x=t.x*n,e.y=t.y*n,e.z=t.z*n,e},t.scaleAndAdd=function(e,t,n,i){return e.x=t.x+n.x*i,e.y=t.y+n.y*i,e.z=t.z+n.z*i,e},t.distance=function(e,t){var n=t.x-e.x,i=t.y-e.y,r=t.z-e.z;return Math.sqrt(n*n+i*i+r*r)},t.squaredDistance=function(e,t){var n=t.x-e.x,i=t.y-e.y,r=t.z-e.z;return n*n+i*i+r*r},t.len=function(e){var t=e.x,n=e.y,i=e.z;return Math.sqrt(t*t+n*n+i*i)},t.lengthSqr=function(e){var t=e.x,n=e.y,i=e.z;return t*t+n*n+i*i},t.negate=function(e,t){return e.x=-t.x,e.y=-t.y,e.z=-t.z,e},t.invert=function(e,t){return e.x=1/t.x,e.y=1/t.y,e.z=1/t.z,e},t.invertSafe=function(e,t){var n=t.x,i=t.y,r=t.z;return Math.abs(n)<an?e.x=0:e.x=1/n,Math.abs(i)<an?e.y=0:e.y=1/i,Math.abs(r)<an?e.z=0:e.z=1/r,e},t.normalize=function(e,t){var n=t.x,i=t.y,r=t.z,a=n*n+i*i+r*r;return a>0&&(a=1/Math.sqrt(a),e.x=n*a,e.y=i*a,e.z=r*a),e},t.dot=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z},t.cross=function(e,t,n){var i=t.x,r=t.y,a=t.z,s=n.x,o=n.y,c=n.z;return e.x=r*c-a*o,e.y=a*s-i*c,e.z=i*o-r*s,e},t.lerp=function(e,t,n,i){return e.x=t.x+i*(n.x-t.x),e.y=t.y+i*(n.y-t.y),e.z=t.z+i*(n.z-t.z),e},t.random=function(e,t){t=t||1;var n=2*fn()*Math.PI,i=2*fn()-1,r=Math.sqrt(1-i*i);return e.x=r*Math.cos(n)*t,e.y=r*Math.sin(n)*t,e.z=i*t,e},t.transformMat4=function(e,t,n){var i=t.x,r=t.y,a=t.z,s=n.m03*i+n.m07*r+n.m11*a+n.m15;return s=s?Math.abs(1/s):1,e.x=(n.m00*i+n.m04*r+n.m08*a+n.m12)*s,e.y=(n.m01*i+n.m05*r+n.m09*a+n.m13)*s,e.z=(n.m02*i+n.m06*r+n.m10*a+n.m14)*s,e},t.transformMat4Normal=function(e,t,n){var i=t.x,r=t.y,a=t.z,s=n.m03*i+n.m07*r+n.m11*a;return s=s?Math.abs(1/s):1,e.x=(n.m00*i+n.m04*r+n.m08*a)*s,e.y=(n.m01*i+n.m05*r+n.m09*a)*s,e.z=(n.m02*i+n.m06*r+n.m10*a)*s,e},t.transformMat3=function(e,t,n){var i=t.x,r=t.y,a=t.z;return e.x=i*n.m00+r*n.m03+a*n.m06,e.y=i*n.m01+r*n.m04+a*n.m07,e.z=i*n.m02+r*n.m05+a*n.m08,e},t.transformAffine=function(e,t,n){var i=t.x,r=t.y,a=t.z;return e.x=n.m00*i+n.m04*r+n.m08*a+n.m12,e.y=n.m01*i+n.m05*r+n.m09*a+n.m13,e.x=n.m02*i+n.m06*r+n.m10*a+n.m14,e},t.transformQuat=function(e,t,n){var i=n.w*t.x+n.y*t.z-n.z*t.y,r=n.w*t.y+n.z*t.x-n.x*t.z,a=n.w*t.z+n.x*t.y-n.y*t.x,s=-n.x*t.x-n.y*t.y-n.z*t.z;return e.x=i*n.w+s*-n.x+r*-n.z-a*-n.y,e.y=r*n.w+s*-n.y+a*-n.x-i*-n.z,e.z=a*n.w+s*-n.z+i*-n.y-r*-n.x,e},t.transformRTS=function(e,t,n,i,r){var a=t.x*r.x,s=t.y*r.y,o=t.z*r.z,c=n.w*a+n.y*o-n.z*s,l=n.w*s+n.z*a-n.x*o,u=n.w*o+n.x*s-n.y*a,h=-n.x*a-n.y*s-n.z*o;return e.x=c*n.w+h*-n.x+l*-n.z-u*-n.y+i.x,e.y=l*n.w+h*-n.y+u*-n.x-c*-n.z+i.y,e.z=u*n.w+h*-n.z+c*-n.y-l*-n.x+i.z,e},t.transformInverseRTS=function(e,t,n,i,r){var a=t.x-i.x,s=t.y-i.y,o=t.z-i.z,c=n.w*a-n.y*o+n.z*s,l=n.w*s-n.z*a+n.x*o,u=n.w*o-n.x*s+n.y*a,h=n.x*a+n.y*s+n.z*o;return e.x=(c*n.w+h*n.x+l*n.z-u*n.y)/r.x,e.y=(l*n.w+h*n.y+u*n.x-c*n.z)/r.y,e.z=(u*n.w+h*n.z+c*n.y-l*n.x)/r.z,e},t.rotateX=function(e,t,n,i){var r=t.x-n.x,a=t.y-n.y,s=t.z-n.z,o=Math.cos(i),c=Math.sin(i),l=r,u=a*o-s*c,h=a*c+s*o;return e.x=l+n.x,e.y=u+n.y,e.z=h+n.z,e},t.rotateY=function(e,t,n,i){var r=t.x-n.x,a=t.y-n.y,s=t.z-n.z,o=Math.cos(i),c=Math.sin(i),l=s*c+r*o,u=a,h=s*o-r*c;return e.x=l+n.x,e.y=u+n.y,e.z=h+n.z,e},t.rotateZ=function(e,t,n,i){var r=t.x-n.x,a=t.y-n.y,s=t.z-n.z,o=Math.cos(i),c=Math.sin(i),l=r*o-a*c,u=r*c+a*o,h=s;return e.x=l+n.x,e.y=u+n.y,e.z=h+n.z,e},t.toArray=function(e,t,n){return void 0===n&&(n=0),e[n+0]=t.x,e[n+1]=t.y,e[n+2]=t.z,e},t.fromArray=function(e,t,n){return void 0===n&&(n=0),e.x=t[n+0],e.y=t[n+1],e.z=t[n+2],e},t.strictEquals=function(e,t){return e.x===t.x&&e.y===t.y&&e.z===t.z},t.equals=function(e,t,n){void 0===n&&(n=an);var i=e.x,r=e.y,a=e.z,s=t.x,o=t.y,c=t.z;return Math.abs(i-s)<=n*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(r-o)<=n*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(a-c)<=n*Math.max(1,Math.abs(a),Math.abs(c))},t.angle=function(e,n){t.normalize(wn,e),t.normalize(In,n);var i=t.dot(wn,In);return i>1?0:i<-1?Math.PI:Math.acos(i)},t.projectOnPlane=function(e,n,i){return t.subtract(e,n,t.project(e,n,i))},t.project=function(e,n,i){var r=t.lengthSqr(i);return r<1e-6?t.set(e,0,0,0):t.multiplyScalar(e,i,t.dot(n,i)/r)};var n=t.prototype;return n.clone=function(){return new t(this.x,this.y,this.z)},n.set=function(e,t,n){return e&&"object"==typeof e?(this.x=e.x,this.y=e.y,this.z=e.z):(this.x=e||0,this.y=t||0,this.z=n||0),this},n.equals=function(e,t){return void 0===t&&(t=an),Math.abs(this.x-e.x)<=t*Math.max(1,Math.abs(this.x),Math.abs(e.x))&&Math.abs(this.y-e.y)<=t*Math.max(1,Math.abs(this.y),Math.abs(e.y))&&Math.abs(this.z-e.z)<=t*Math.max(1,Math.abs(this.z),Math.abs(e.z))},n.equals3f=function(e,t,n,i){return void 0===i&&(i=an),Math.abs(this.x-e)<=i*Math.max(1,Math.abs(this.x),Math.abs(e))&&Math.abs(this.y-t)<=i*Math.max(1,Math.abs(this.y),Math.abs(t))&&Math.abs(this.z-n)<=i*Math.max(1,Math.abs(this.z),Math.abs(n))},n.strictEquals=function(e){return this.x===e.x&&this.y===e.y&&this.z===e.z},n.strictEquals3f=function(e,t,n){return this.x===e&&this.y===t&&this.z===n},n.toString=function(){return"("+this.x.toFixed(2)+", "+this.y.toFixed(2)+", "+this.z.toFixed(2)+")"},n.lerp=function(e,t){return this.x+=t*(e.x-this.x),this.y+=t*(e.y-this.y),this.z+=t*(e.z-this.z),this},n.add=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this},n.add3f=function(e,t,n){return this.x+=e,this.y+=t,this.z+=n,this},n.subtract=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this},n.subtract3f=function(e,t,n){return this.x-=e,this.y-=t,this.z-=n,this},n.multiplyScalar=function(e){return"object"==typeof e&&console.warn("should use Vec3.multiply for vector * vector operation"),this.x*=e,this.y*=e,this.z*=e,this},n.multiply=function(e){return"object"!=typeof e&&console.warn("should use Vec3.scale for vector * scalar operation"),this.x*=e.x,this.y*=e.y,this.z*=e.z,this},n.multiply3f=function(e,t,n){return this.x*=e,this.y*=t,this.z*=n,this},n.divide=function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this},n.divide3f=function(e,t,n){return this.x/=e,this.y/=t,this.z/=n,this},n.negative=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},n.clampf=function(e,t){return this.x=cn(this.x,e.x,t.x),this.y=cn(this.y,e.y,t.y),this.z=cn(this.z,e.z,t.z),this},n.dot=function(e){return this.x*e.x+this.y*e.y+this.z*e.z},n.cross=function(e){var t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,s=e.z;return this.x=n*s-i*a,this.y=i*r-t*s,this.z=t*a-n*r,this},n.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},n.lengthSqr=function(){return this.x*this.x+this.y*this.y+this.z*this.z},n.normalize=function(){var e=this.x,t=this.y,n=this.z,i=e*e+t*t+n*n;return i>0&&(i=1/Math.sqrt(i),this.x=e*i,this.y=t*i,this.z=n*i),this},n.transformMat4=function(e){var t=this.x,n=this.y,i=this.z,r=e.m03*t+e.m07*n+e.m11*i+e.m15;return r=r?1/r:1,this.x=(e.m00*t+e.m04*n+e.m08*i+e.m12)*r,this.y=(e.m01*t+e.m05*n+e.m09*i+e.m13)*r,this.z=(e.m02*t+e.m06*n+e.m10*i+e.m14)*r,this},t}(_t));bn.UNIT_X=Object.freeze(new bn(1,0,0)),bn.UNIT_Y=Object.freeze(new bn(0,1,0)),bn.UNIT_Z=Object.freeze(new bn(0,0,1)),bn.RIGHT=Object.freeze(new bn(1,0,0)),bn.UP=Object.freeze(new bn(0,1,0)),bn.FORWARD=Object.freeze(new bn(0,0,-1)),bn.ZERO=Object.freeze(new bn(0,0,0)),bn.ONE=Object.freeze(new bn(1,1,1)),bn.NEG_ONE=Object.freeze(new bn(-1,-1,-1));var wn=new bn,In=new bn;function On(e,t,n){return new bn(e,t,n)}$t.fastDefine("cc.Vec3",bn,{x:0,y:0,z:0}),i.Vec3=bn,i.v3=On;var Pn=e("Mat3",function(e){function t(t,n,i,r,a,s,o,c,l){var u;return void 0===t&&(t=1),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===a&&(a=1),void 0===s&&(s=0),void 0===o&&(o=0),void 0===c&&(c=0),void 0===l&&(l=1),u=e.call(this)||this,"object"==typeof t?(u.m00=t.m00,u.m01=t.m01,u.m02=t.m02,u.m03=t.m03,u.m04=t.m04,u.m05=t.m05,u.m06=t.m06,u.m07=t.m07,u.m08=t.m08):(u.m00=t,u.m01=n,u.m02=i,u.m03=r,u.m04=a,u.m05=s,u.m06=o,u.m07=c,u.m08=l),u}X(t,e),t.clone=function(e){return new t(e.m00,e.m01,e.m02,e.m03,e.m04,e.m05,e.m06,e.m07,e.m08)},t.copy=function(e,t){return e.m00=t.m00,e.m01=t.m01,e.m02=t.m02,e.m03=t.m03,e.m04=t.m04,e.m05=t.m05,e.m06=t.m06,e.m07=t.m07,e.m08=t.m08,e},t.set=function(e,t,n,i,r,a,s,o,c,l){return e.m00=t,e.m01=n,e.m02=i,e.m03=r,e.m04=a,e.m05=s,e.m06=o,e.m07=c,e.m08=l,e},t.identity=function(e){return e.m00=1,e.m01=0,e.m02=0,e.m03=0,e.m04=1,e.m05=0,e.m06=0,e.m07=0,e.m08=1,e},t.transpose=function(e,t){if(e===t){var n=t.m01,i=t.m02,r=t.m05;e.m01=t.m03,e.m02=t.m06,e.m03=n,e.m05=t.m07,e.m06=i,e.m07=r}else e.m00=t.m00,e.m01=t.m03,e.m02=t.m06,e.m03=t.m01,e.m04=t.m04,e.m05=t.m07,e.m06=t.m02,e.m07=t.m05,e.m08=t.m08;return e},t.invert=function(e,t){var n=t.m00,i=t.m01,r=t.m02,a=t.m03,s=t.m04,o=t.m05,c=t.m06,l=t.m07,u=t.m08,h=u*s-o*l,_=-u*a+o*c,f=l*a-s*c,d=n*h+i*_+r*f;return 0===d?(e.m00=0,e.m01=0,e.m02=0,e.m03=0,e.m04=0,e.m05=0,e.m06=0,e.m07=0,e.m08=0,e):(d=1/d,e.m00=h*d,e.m01=(-u*i+r*l)*d,e.m02=(o*i-r*s)*d,e.m03=_*d,e.m04=(u*n-r*c)*d,e.m05=(-o*n+r*a)*d,e.m06=f*d,e.m07=(-l*n+i*c)*d,e.m08=(s*n-i*a)*d,e)},t.determinant=function(e){var t=e.m00,n=e.m01,i=e.m02,r=e.m03,a=e.m04,s=e.m05,o=e.m06,c=e.m07,l=e.m08;return t*(l*a-s*c)+n*(-l*r+s*o)+i*(c*r-a*o)},t.multiply=function(e,t,n){var i=t.m00,r=t.m01,a=t.m02,s=t.m03,o=t.m04,c=t.m05,l=t.m06,u=t.m07,h=t.m08,_=n.m00,f=n.m01,d=n.m02,p=n.m03,m=n.m04,g=n.m05,v=n.m06,y=n.m07,S=n.m08;return e.m00=_*i+f*s+d*l,e.m01=_*r+f*o+d*u,e.m02=_*a+f*c+d*h,e.m03=p*i+m*s+g*l,e.m04=p*r+m*o+g*u,e.m05=p*a+m*c+g*h,e.m06=v*i+y*s+S*l,e.m07=v*r+y*o+S*u,e.m08=v*a+y*c+S*h,e},t.multiplyMat4=function(e,t,n){var i=t.m00,r=t.m01,a=t.m02,s=t.m03,o=t.m04,c=t.m05,l=t.m06,u=t.m07,h=t.m08,_=n.m00,f=n.m01,d=n.m02,p=n.m04,m=n.m05,g=n.m06,v=n.m08,y=n.m09,S=n.m10;return e.m00=_*i+f*s+d*l,e.m01=_*r+f*o+d*u,e.m02=_*a+f*c+d*h,e.m03=p*i+m*s+g*l,e.m04=p*r+m*o+g*u,e.m05=p*a+m*c+g*h,e.m06=v*i+y*s+S*l,e.m07=v*r+y*o+S*u,e.m08=v*a+y*c+S*h,e},t.transform=function(e,t,n){var i=t.m00,r=t.m01,a=t.m02,s=t.m03,o=t.m04,c=t.m05,l=t.m06,u=t.m07,h=t.m08,_=n.x,f=n.y;return e.m00=i,e.m01=r,e.m02=a,e.m03=s,e.m04=o,e.m05=c,e.m06=_*i+f*s+l,e.m07=_*r+f*o+u,e.m08=_*a+f*c+h,e},t.scale=function(e,t,n){var i=n.x,r=n.y;return e.m00=i*t.m00,e.m01=i*t.m01,e.m02=i*t.m02,e.m03=r*t.m03,e.m04=r*t.m04,e.m05=r*t.m05,e.m06=t.m06,e.m07=t.m07,e.m08=t.m08,e},t.rotate=function(e,t,n){var i=t.m00,r=t.m01,a=t.m02,s=t.m03,o=t.m04,c=t.m05,l=t.m06,u=t.m07,h=t.m08,_=Math.sin(n),f=Math.cos(n);return e.m00=f*i+_*s,e.m01=f*r+_*o,e.m02=f*a+_*c,e.m03=f*s-_*i,e.m04=f*o-_*r,e.m05=f*c-_*a,e.m06=l,e.m07=u,e.m08=h,e},t.fromMat4=function(e,t){return e.m00=t.m00,e.m01=t.m01,e.m02=t.m02,e.m03=t.m04,e.m04=t.m05,e.m05=t.m06,e.m06=t.m08,e.m07=t.m09,e.m08=t.m10,e},t.fromViewUp=function(e,n,i){return bn.lengthSqr(n)<an*an?(t.identity(e),e):(i=i||bn.UNIT_Y,bn.normalize(Mn,bn.cross(Mn,i,n)),bn.lengthSqr(Mn)<an*an?(t.identity(e),e):(bn.cross(Nn,n,Mn),t.set(e,Mn.x,Mn.y,Mn.z,Nn.x,Nn.y,Nn.z,n.x,n.y,n.z),e))},t.fromTranslation=function(e,t){return e.m00=1,e.m01=0,e.m02=0,e.m03=0,e.m04=1,e.m05=0,e.m06=t.x,e.m07=t.y,e.m08=1,e},t.fromScaling=function(e,t){return e.m00=t.x,e.m01=0,e.m02=0,e.m03=0,e.m04=t.y,e.m05=0,e.m06=0,e.m07=0,e.m08=1,e},t.fromRotation=function(e,t){var n=Math.sin(t),i=Math.cos(t);return e.m00=i,e.m01=n,e.m02=0,e.m03=-n,e.m04=i,e.m05=0,e.m06=0,e.m07=0,e.m08=1,e},t.fromQuat=function(e,t){var n=t.x,i=t.y,r=t.z,a=t.w,s=n+n,o=i+i,c=r+r,l=n*s,u=i*s,h=i*o,_=r*s,f=r*o,d=r*c,p=a*s,m=a*o,g=a*c;return e.m00=1-h-d,e.m03=u-g,e.m06=_+m,e.m01=u+g,e.m04=1-l-d,e.m07=f-p,e.m02=_-m,e.m05=f+p,e.m08=1-l-h,e},t.inverseTransposeMat4=function(e,t){var n=t.m00,i=t.m01,r=t.m02,a=t.m03,s=t.m04,o=t.m05,c=t.m06,l=t.m07,u=t.m08,h=t.m09,_=t.m10,f=t.m11,d=t.m12,p=t.m13,m=t.m14,g=t.m15,v=n*o-i*s,y=n*c-r*s,S=n*l-a*s,E=i*c-r*o,T=i*l-a*o,A=r*l-a*c,x=u*p-h*d,C=u*m-_*d,R=u*g-f*d,b=h*m-_*p,w=h*g-f*p,I=_*g-f*m,O=v*I-y*w+S*b+E*R-T*C+A*x;return O?(O=1/O,e.m00=(o*I-c*w+l*b)*O,e.m01=(c*R-s*I-l*C)*O,e.m02=(s*w-o*R+l*x)*O,e.m03=(r*w-i*I-a*b)*O,e.m04=(n*I-r*R+a*C)*O,e.m05=(i*R-n*w-a*x)*O,e.m06=(p*A-m*T+g*E)*O,e.m07=(m*S-d*A-g*y)*O,e.m08=(d*T-p*S+g*v)*O,e):null},t.toArray=function(e,t,n){return void 0===n&&(n=0),e[n+0]=t.m00,e[n+1]=t.m01,e[n+2]=t.m02,e[n+3]=t.m03,e[n+4]=t.m04,e[n+5]=t.m05,e[n+6]=t.m06,e[n+7]=t.m07,e[n+8]=t.m08,e},t.fromArray=function(e,t,n){return void 0===n&&(n=0),e.m00=t[n+0],e.m01=t[n+1],e.m02=t[n+2],e.m03=t[n+3],e.m04=t[n+4],e.m05=t[n+5],e.m06=t[n+6],e.m07=t[n+7],e.m08=t[n+8],e},t.add=function(e,t,n){return e.m00=t.m00+n.m00,e.m01=t.m01+n.m01,e.m02=t.m02+n.m02,e.m03=t.m03+n.m03,e.m04=t.m04+n.m04,e.m05=t.m05+n.m05,e.m06=t.m06+n.m06,e.m07=t.m07+n.m07,e.m08=t.m08+n.m08,e},t.subtract=function(e,t,n){return e.m00=t.m00-n.m00,e.m01=t.m01-n.m01,e.m02=t.m02-n.m02,e.m03=t.m03-n.m03,e.m04=t.m04-n.m04,e.m05=t.m05-n.m05,e.m06=t.m06-n.m06,e.m07=t.m07-n.m07,e.m08=t.m08-n.m08,e},t.multiplyScalar=function(e,t,n){return e.m00=t.m00*n,e.m01=t.m01*n,e.m02=t.m02*n,e.m03=t.m03*n,e.m04=t.m04*n,e.m05=t.m05*n,e.m06=t.m06*n,e.m07=t.m07*n,e.m08=t.m08*n,e},t.multiplyScalarAndAdd=function(e,t,n,i){return e.m00=n.m00*i+t.m00,e.m01=n.m01*i+t.m01,e.m02=n.m02*i+t.m02,e.m03=n.m03*i+t.m03,e.m04=n.m04*i+t.m04,e.m05=n.m05*i+t.m05,e.m06=n.m06*i+t.m06,e.m07=n.m07*i+t.m07,e.m08=n.m08*i+t.m08,e},t.strictEquals=function(e,t){return e.m00===t.m00&&e.m01===t.m01&&e.m02===t.m02&&e.m03===t.m03&&e.m04===t.m04&&e.m05===t.m05&&e.m06===t.m06&&e.m07===t.m07&&e.m08===t.m08},t.equals=function(e,t,n){return void 0===n&&(n=an),Math.abs(e.m00-t.m00)<=n*Math.max(1,Math.abs(e.m00),Math.abs(t.m00))&&Math.abs(e.m01-t.m01)<=n*Math.max(1,Math.abs(e.m01),Math.abs(t.m01))&&Math.abs(e.m02-t.m02)<=n*Math.max(1,Math.abs(e.m02),Math.abs(t.m02))&&Math.abs(e.m03-t.m03)<=n*Math.max(1,Math.abs(e.m03),Math.abs(t.m03))&&Math.abs(e.m04-t.m04)<=n*Math.max(1,Math.abs(e.m04),Math.abs(t.m04))&&Math.abs(e.m05-t.m05)<=n*Math.max(1,Math.abs(e.m05),Math.abs(t.m05))&&Math.abs(e.m06-t.m06)<=n*Math.max(1,Math.abs(e.m06),Math.abs(t.m06))&&Math.abs(e.m07-t.m07)<=n*Math.max(1,Math.abs(e.m07),Math.abs(t.m07))&&Math.abs(e.m08-t.m08)<=n*Math.max(1,Math.abs(e.m08),Math.abs(t.m08))};var n=t.prototype;return n.clone=function(){var e=this;return new t(e.m00,e.m01,e.m02,e.m03,e.m04,e.m05,e.m06,e.m07,e.m08)},n.set=function(e,t,n,i,r,a,s,o,c){return void 0===e&&(e=1),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=1),void 0===a&&(a=0),void 0===s&&(s=0),void 0===o&&(o=0),void 0===c&&(c=1),"object"==typeof e?(this.m00=e.m00,this.m01=e.m01,this.m02=e.m02,this.m03=e.m03,this.m04=e.m04,this.m05=e.m05,this.m06=e.m06,this.m07=e.m07,this.m08=e.m08):(this.m00=e,this.m01=t,this.m02=n,this.m03=i,this.m04=r,this.m05=a,this.m06=s,this.m07=o,this.m08=c),this},n.equals=function(e,t){return void 0===t&&(t=an),Math.abs(this.m00-e.m00)<=t*Math.max(1,Math.abs(this.m00),Math.abs(e.m00))&&Math.abs(this.m01-e.m01)<=t*Math.max(1,Math.abs(this.m01),Math.abs(e.m01))&&Math.abs(this.m02-e.m02)<=t*Math.max(1,Math.abs(this.m02),Math.abs(e.m02))&&Math.abs(this.m03-e.m03)<=t*Math.max(1,Math.abs(this.m03),Math.abs(e.m03))&&Math.abs(this.m04-e.m04)<=t*Math.max(1,Math.abs(this.m04),Math.abs(e.m04))&&Math.abs(this.m05-e.m05)<=t*Math.max(1,Math.abs(this.m05),Math.abs(e.m05))&&Math.abs(this.m06-e.m06)<=t*Math.max(1,Math.abs(this.m06),Math.abs(e.m06))&&Math.abs(this.m07-e.m07)<=t*Math.max(1,Math.abs(this.m07),Math.abs(e.m07))&&Math.abs(this.m08-e.m08)<=t*Math.max(1,Math.abs(this.m08),Math.abs(e.m08))},n.strictEquals=function(e){return this.m00===e.m00&&this.m01===e.m01&&this.m02===e.m02&&this.m03===e.m03&&this.m04===e.m04&&this.m05===e.m05&&this.m06===e.m06&&this.m07===e.m07&&this.m08===e.m08},n.toString=function(){var e=this;return"[\n"+e.m00+", "+e.m01+", "+e.m02+",\n"+e.m03+",\n"+e.m04+", "+e.m05+",\n"+e.m06+", "+e.m07+",\n"+e.m08+"\n]"},n.identity=function(){return this.m00=1,this.m01=0,this.m02=0,this.m03=0,this.m04=1,this.m05=0,this.m06=0,this.m07=0,this.m08=1,this},n.transpose=function(){var e=this.m01,t=this.m02,n=this.m05;return this.m01=this.m03,this.m02=this.m06,this.m03=e,this.m05=this.m07,this.m06=t,this.m07=n,this},n.invert=function(){var e=this.m00,t=this.m01,n=this.m02,i=this.m03,r=this.m04,a=this.m05,s=this.m06,o=this.m07,c=this.m08,l=c*r-a*o,u=-c*i+a*s,h=o*i-r*s,_=e*l+t*u+n*h;return 0===_?(this.set(0,0,0,0,0,0,0,0,0),this):(_=1/_,this.m00=l*_,this.m01=(-c*t+n*o)*_,this.m02=(a*t-n*r)*_,this.m03=u*_,this.m04=(c*e-n*s)*_,this.m05=(-a*e+n*i)*_,this.m06=h*_,this.m07=(-o*e+t*s)*_,this.m08=(r*e-t*i)*_,this)},n.determinant=function(){var e=this.m00,t=this.m01,n=this.m02,i=this.m03,r=this.m04,a=this.m05,s=this.m06,o=this.m07,c=this.m08;return e*(c*r-a*o)+t*(-c*i+a*s)+n*(o*i-r*s)},n.add=function(e){return this.m00+=e.m00,this.m01+=e.m01,this.m02+=e.m02,this.m03+=e.m03,this.m04+=e.m04,this.m05+=e.m05,this.m06+=e.m06,this.m07+=e.m07,this.m08+=e.m08,this},n.subtract=function(e){return this.m00-=e.m00,this.m01-=e.m01,this.m02-=e.m02,this.m03-=e.m03,this.m04-=e.m04,this.m05-=e.m05,this.m06-=e.m06,this.m07-=e.m07,this.m08-=e.m08,this},n.multiply=function(e){var t=this.m00,n=this.m01,i=this.m02,r=this.m03,a=this.m04,s=this.m05,o=this.m06,c=this.m07,l=this.m08,u=e.m00,h=e.m01,_=e.m02,f=e.m03,d=e.m04,p=e.m05,m=e.m06,g=e.m07,v=e.m08;return this.m00=u*t+h*r+_*o,this.m01=u*n+h*a+_*c,this.m02=u*i+h*s+_*l,this.m03=f*t+d*r+p*o,this.m04=f*n+d*a+p*c,this.m05=f*i+d*s+p*l,this.m06=m*t+g*r+v*o,this.m07=m*n+g*a+v*c,this.m08=m*i+g*s+v*l,this},n.multiplyScalar=function(e){return this.m00*=e,this.m01*=e,this.m02*=e,this.m03*=e,this.m04*=e,this.m05*=e,this.m06*=e,this.m07*=e,this.m08*=e,this},n.scale=function(e){var t=e.x,n=e.y;return this.m00=t*this.m00,this.m01=t*this.m01,this.m02=t*this.m02,this.m03=n*this.m03,this.m04=n*this.m04,this.m05=n*this.m05,this.m06=this.m06,this.m07=this.m07,this.m08=this.m08,this},n.rotate=function(e){var t=this.m00,n=this.m01,i=this.m02,r=this.m03,a=this.m04,s=this.m05,o=this.m06,c=this.m07,l=this.m08,u=Math.sin(e),h=Math.cos(e);return this.m00=h*t+u*r,this.m01=h*n+u*a,this.m02=h*i+u*s,this.m03=h*r-u*t,this.m04=h*a-u*n,this.m05=h*s-u*i,this.m06=o,this.m07=c,this.m08=l,this},n.fromQuat=function(e){var t=e.x,n=e.y,i=e.z,r=e.w,a=t+t,s=n+n,o=i+i,c=t*a,l=n*a,u=n*s,h=i*a,_=i*s,f=i*o,d=r*a,p=r*s,m=r*o;return this.m00=1-u-f,this.m03=l-m,this.m06=h+p,this.m01=l+m,this.m04=1-c-f,this.m07=_-d,this.m02=h-p,this.m05=_+d,this.m08=1-c-u,this},t}(_t));Pn.IDENTITY=Object.freeze(new Pn);var Mn=new bn,Nn=new bn;$t.fastDefine("cc.Mat3",Pn,{m00:1,m01:0,m02:0,m03:0,m04:1,m05:0,m06:0,m07:0,m08:1}),i.Mat3=Pn;var Dn=e("Quat",function(e){function t(t,n,i,r){var a;return a=e.call(this)||this,t&&"object"==typeof t?(a.x=t.x,a.y=t.y,a.z=t.z,a.w=t.w):(a.x=t||0,a.y=n||0,a.z=i||0,a.w=null!=r?r:1),a}X(t,e),t.clone=function(e){return new t(e.x,e.y,e.z,e.w)},t.copy=function(e,t){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e},t.set=function(e,t,n,i,r){return e.x=t,e.y=n,e.z=i,e.w=r,e},t.identity=function(e){return e.x=0,e.y=0,e.z=0,e.w=1,e},t.rotationTo=function(e,n,i){var r=bn.dot(n,i);return r<-.999999?(bn.cross(Fn,bn.UNIT_X,n),Fn.length()<1e-6&&bn.cross(Fn,bn.UNIT_Y,n),bn.normalize(Fn,Fn),t.fromAxisAngle(e,Fn,Math.PI),e):r>.999999?(e.x=0,e.y=0,e.z=0,e.w=1,e):(bn.cross(Fn,n,i),e.x=Fn.x,e.y=Fn.y,e.z=Fn.z,e.w=1+r,t.normalize(e,e))},t.getAxisAngle=function(e,t){var n=2*Math.acos(t.w),i=Math.sin(n/2);return 0!==i?(e.x=t.x/i,e.y=t.y/i,e.z=t.z/i):(e.x=1,e.y=0,e.z=0),n},t.multiply=function(e,t,n){var i=t.x*n.w+t.w*n.x+t.y*n.z-t.z*n.y,r=t.y*n.w+t.w*n.y+t.z*n.x-t.x*n.z,a=t.z*n.w+t.w*n.z+t.x*n.y-t.y*n.x,s=t.w*n.w-t.x*n.x-t.y*n.y-t.z*n.z;return e.x=i,e.y=r,e.z=a,e.w=s,e},t.multiplyScalar=function(e,t,n){return e.x=t.x*n,e.y=t.y*n,e.z=t.z*n,e.w=t.w*n,e},t.scaleAndAdd=function(e,t,n,i){return e.x=t.x+n.x*i,e.y=t.y+n.y*i,e.z=t.z+n.z*i,e.w=t.w+n.w*i,e},t.rotateX=function(e,t,n){n*=.5;var i=Math.sin(n),r=Math.cos(n),a=t.x,s=t.y,o=t.z,c=t.w;return e.x=a*r+c*i,e.y=s*r+o*i,e.z=o*r-s*i,e.w=c*r-a*i,e},t.rotateY=function(e,t,n){n*=.5;var i=Math.sin(n),r=Math.cos(n),a=t.x,s=t.y,o=t.z,c=t.w;return e.x=a*r-o*i,e.y=s*r+c*i,e.z=o*r+a*i,e.w=c*r-s*i,e},t.rotateZ=function(e,t,n){n*=.5;var i=Math.sin(n),r=Math.cos(n),a=t.x,s=t.y,o=t.z,c=t.w;return e.x=a*r+s*i,e.y=s*r-a*i,e.z=o*r+c*i,e.w=c*r-o*i,e},t.rotateAround=function(e,n,i,r){return t.invert(Bn,n),bn.transformQuat(Fn,i,Bn),t.fromAxisAngle(Bn,Fn,r),t.multiply(e,n,Bn),e},t.rotateAroundLocal=function(e,n,i,r){return t.fromAxisAngle(Bn,i,r),t.multiply(e,n,Bn),e},t.calculateW=function(e,t){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=Math.sqrt(Math.abs(1-t.x*t.x-t.y*t.y-t.z*t.z)),e},t.dot=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w},t.lerp=function(e,t,n,i){return e.x=t.x+i*(n.x-t.x),e.y=t.y+i*(n.y-t.y),e.z=t.z+i*(n.z-t.z),e.w=t.w+i*(n.w-t.w),e},t.slerp=function(e,t,n,i){var r=0,a=0,s=n.x,o=n.y,c=n.z,l=n.w,u=t.x*n.x+t.y*n.y+t.z*n.z+t.w*n.w;if(u<0&&(u=-u,s=-s,o=-o,c=-c,l=-l),1-u>1e-6){var h=Math.acos(u),_=Math.sin(h);r=Math.sin((1-i)*h)/_,a=Math.sin(i*h)/_}else r=1-i,a=i;return e.x=r*t.x+a*s,e.y=r*t.y+a*o,e.z=r*t.z+a*c,e.w=r*t.w+a*l,e},t.sqlerp=function(e,n,i,r,a,s){return t.slerp(Bn,n,a,s),t.slerp(Ln,i,r,s),t.slerp(e,Bn,Ln,2*s*(1-s)),e},t.invert=function(e,t){var n=t.x*t.x+t.y*t.y+t.z*t.z+t.w*t.w,i=n?1/n:0;return e.x=-t.x*i,e.y=-t.y*i,e.z=-t.z*i,e.w=t.w*i,e},t.conjugate=function(e,t){return e.x=-t.x,e.y=-t.y,e.z=-t.z,e.w=t.w,e},t.len=function(e){return Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z+e.w*e.w)},t.lengthSqr=function(e){return e.x*e.x+e.y*e.y+e.z*e.z+e.w*e.w},t.normalize=function(e,t){var n=t.x*t.x+t.y*t.y+t.z*t.z+t.w*t.w;return n>0&&(n=1/Math.sqrt(n),e.x=t.x*n,e.y=t.y*n,e.z=t.z*n,e.w=t.w*n),e},t.fromAxes=function(e,n,i,r){return Pn.set(zn,n.x,n.y,n.z,i.x,i.y,i.z,r.x,r.y,r.z),t.normalize(e,t.fromMat3(e,zn))},t.fromViewUp=function(e,n,i){return Pn.fromViewUp(zn,n,i),t.normalize(e,t.fromMat3(e,zn))},t.fromAxisAngle=function(e,t,n){n*=.5;var i=Math.sin(n);return e.x=i*t.x,e.y=i*t.y,e.z=i*t.z,e.w=Math.cos(n),e},t.fromMat3=function(e,t){var n=t.m00,i=t.m03,r=t.m06,a=t.m01,s=t.m04,o=t.m07,c=t.m02,l=t.m05,u=t.m08,h=n+s+u;if(h>0){var _=.5/Math.sqrt(h+1);e.w=.25/_,e.x=(l-o)*_,e.y=(r-c)*_,e.z=(a-i)*_}else if(n>s&&n>u){var f=2*Math.sqrt(1+n-s-u);e.w=(l-o)/f,e.x=.25*f,e.y=(i+a)/f,e.z=(r+c)/f}else if(s>u){var d=2*Math.sqrt(1+s-n-u);e.w=(r-c)/d,e.x=(i+a)/d,e.y=.25*d,e.z=(o+l)/d}else{var p=2*Math.sqrt(1+u-n-s);e.w=(a-i)/p,e.x=(r+c)/p,e.y=(o+l)/p,e.z=.25*p}return e},t.fromEuler=function(e,t,n,i){t*=Un,n*=Un,i*=Un;var r=Math.sin(t),a=Math.cos(t),s=Math.sin(n),o=Math.cos(n),c=Math.sin(i),l=Math.cos(i);return e.x=r*o*l+a*s*c,e.y=a*s*l+r*o*c,e.z=a*o*c-r*s*l,e.w=a*o*l-r*s*c,e},t.fromAngleZ=function(e,t){return t*=Un,e.x=e.y=0,e.z=Math.sin(t),e.w=Math.cos(t),e},t.toAxisX=function(e,t){var n=2*t.y,i=2*t.z;return e.x=1-n*t.y-i*t.z,e.y=n*t.x+i*t.w,e.z=i*t.x+n*t.w,e},t.toAxisY=function(e,t){var n=2*t.x,i=2*t.y,r=2*t.z;return e.x=i*t.x-r*t.w,e.y=1-n*t.x-r*t.z,e.z=r*t.y+n*t.w,e},t.toAxisZ=function(e,t){var n=2*t.x,i=2*t.y,r=2*t.z;return e.x=r*t.x-i*t.w,e.y=r*t.y-n*t.w,e.z=1-n*t.x-i*t.y,e},t.toEuler=function(e,t,n){var i=t.x,r=t.y,a=t.z,s=t.w,o=0,c=0,l=0,u=i*r+a*s;if(u>.499999)o=0,c=_n(2*Math.atan2(i,s)),l=90;else if(u<-.499999)o=0,c=-_n(2*Math.atan2(i,s)),l=-90;else{var h=i*i,_=r*r,f=a*a;o=_n(Math.atan2(2*i*s-2*r*a,1-2*h-2*f)),c=_n(Math.atan2(2*r*s-2*i*a,1-2*_-2*f)),l=_n(Math.asin(2*u)),n&&(o=-180*Math.sign(o+1e-6)+o,c=-180*Math.sign(c+1e-6)+c,l=180*Math.sign(l+1e-6)-l)}return e.x=o,e.y=c,e.z=l,e},t.toArray=function(e,t,n){return void 0===n&&(n=0),e[n+0]=t.x,e[n+1]=t.y,e[n+2]=t.z,e[n+3]=t.w,e},t.fromArray=function(e,t,n){return void 0===n&&(n=0),e.x=t[n+0],e.y=t[n+1],e.z=t[n+2],e.w=t[n+3],e},t.strictEquals=function(e,t){return e.x===t.x&&e.y===t.y&&e.z===t.z&&e.w===t.w},t.equals=function(e,t,n){return void 0===n&&(n=an),Math.abs(e.x-t.x)<=n*Math.max(1,Math.abs(e.x),Math.abs(t.x))&&Math.abs(e.y-t.y)<=n*Math.max(1,Math.abs(e.y),Math.abs(t.y))&&Math.abs(e.z-t.z)<=n*Math.max(1,Math.abs(e.z),Math.abs(t.z))&&Math.abs(e.w-t.w)<=n*Math.max(1,Math.abs(e.w),Math.abs(t.w))};var n=t.prototype;return n.clone=function(){return new t(this.x,this.y,this.z,this.w)},n.set=function(e,t,n,i){return e&&"object"==typeof e?(this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w):(this.x=e||0,this.y=t||0,this.z=n||0,this.w=null!=i?i:1),this},n.equals=function(e,t){return void 0===t&&(t=an),Math.abs(this.x-e.x)<=t*Math.max(1,Math.abs(this.x),Math.abs(e.x))&&Math.abs(this.y-e.y)<=t*Math.max(1,Math.abs(this.y),Math.abs(e.y))&&Math.abs(this.z-e.z)<=t*Math.max(1,Math.abs(this.z),Math.abs(e.z))&&Math.abs(this.w-e.w)<=t*Math.max(1,Math.abs(this.w),Math.abs(e.w))},n.strictEquals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w},n.getEulerAngles=function(e){return t.toEuler(e,this)},n.lerp=function(e,t){return this.x+=t*(e.x-this.x),this.y+=t*(e.y-this.y),this.z+=t*(e.z-this.z),this.w+=t*(e.w-this.w),this},n.slerp=function(e,n){return t.slerp(this,this,e,n)},n.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},n.lengthSqr=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},t}(_t));Dn.IDENTITY=Object.freeze(new Dn);var Bn=new Dn,Ln=new Dn,Fn=new bn,zn=new Pn,Un=.5*Math.PI/180;function Gn(e,t,n,i){return void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=1),new Dn(e,t,n,i)}$t.fastDefine("cc.Quat",Dn,{x:0,y:0,z:0,w:1}),i.Quat=Dn,i.quat=Gn;var kn=Object.freeze([Object.freeze([1,0,0,1]),Object.freeze([0,1,-1,0]),Object.freeze([-1,0,0,-1]),Object.freeze([0,-1,1,0])]),Hn=e("Mat4",function(e){function t(t,n,i,r,a,s,o,c,l,u,h,_,f,d,p,m){var g;return void 0===t&&(t=1),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===a&&(a=0),void 0===s&&(s=1),void 0===o&&(o=0),void 0===c&&(c=0),void 0===l&&(l=0),void 0===u&&(u=0),void 0===h&&(h=1),void 0===_&&(_=0),void 0===f&&(f=0),void 0===d&&(d=0),void 0===p&&(p=0),void 0===m&&(m=1),(g=e.call(this)||this).m00=void 0,g.m01=void 0,g.m02=void 0,g.m03=void 0,g.m04=void 0,g.m05=void 0,g.m06=void 0,g.m07=void 0,g.m08=void 0,g.m09=void 0,g.m10=void 0,g.m11=void 0,g.m12=void 0,g.m13=void 0,g.m14=void 0,g.m15=void 0,"object"==typeof t?(g.m00=t.m00,g.m01=t.m01,g.m02=t.m02,g.m03=t.m03,g.m04=t.m04,g.m05=t.m05,g.m06=t.m06,g.m07=t.m07,g.m08=t.m08,g.m09=t.m09,g.m10=t.m10,g.m11=t.m11,g.m12=t.m12,g.m13=t.m13,g.m14=t.m14,g.m15=t.m15):(g.m00=t,g.m01=n,g.m02=i,g.m03=r,g.m04=a,g.m05=s,g.m06=o,g.m07=c,g.m08=l,g.m09=u,g.m10=h,g.m11=_,g.m12=f,g.m13=d,g.m14=p,g.m15=m),g}X(t,e),t.clone=function(e){return new t(e.m00,e.m01,e.m02,e.m03,e.m04,e.m05,e.m06,e.m07,e.m08,e.m09,e.m10,e.m11,e.m12,e.m13,e.m14,e.m15)},t.copy=function(e,t){return e.m00=t.m00,e.m01=t.m01,e.m02=t.m02,e.m03=t.m03,e.m04=t.m04,e.m05=t.m05,e.m06=t.m06,e.m07=t.m07,e.m08=t.m08,e.m09=t.m09,e.m10=t.m10,e.m11=t.m11,e.m12=t.m12,e.m13=t.m13,e.m14=t.m14,e.m15=t.m15,e},t.set=function(e,t,n,i,r,a,s,o,c,l,u,h,_,f,d,p,m){return e.m00=t,e.m01=n,e.m02=i,e.m03=r,e.m04=a,e.m05=s,e.m06=o,e.m07=c,e.m08=l,e.m09=u,e.m10=h,e.m11=_,e.m12=f,e.m13=d,e.m14=p,e.m15=m,e},t.identity=function(e){return e.m00=1,e.m01=0,e.m02=0,e.m03=0,e.m04=0,e.m05=1,e.m06=0,e.m07=0,e.m08=0,e.m09=0,e.m10=1,e.m11=0,e.m12=0,e.m13=0,e.m14=0,e.m15=1,e},t.transpose=function(e,t){if(e===t){var n=t.m01,i=t.m02,r=t.m03,a=t.m06,s=t.m07,o=t.m11;e.m01=t.m04,e.m02=t.m08,e.m03=t.m12,e.m04=n,e.m06=t.m09,e.m07=t.m13,e.m08=i,e.m09=a,e.m11=t.m14,e.m12=r,e.m13=s,e.m14=o}else e.m00=t.m00,e.m01=t.m04,e.m02=t.m08,e.m03=t.m12,e.m04=t.m01,e.m05=t.m05,e.m06=t.m09,e.m07=t.m13,e.m08=t.m02,e.m09=t.m06,e.m10=t.m10,e.m11=t.m14,e.m12=t.m03,e.m13=t.m07,e.m14=t.m11,e.m15=t.m15;return e},t.invert=function(e,t){var n=t.m00,i=t.m01,r=t.m02,a=t.m03,s=t.m04,o=t.m05,c=t.m06,l=t.m07,u=t.m08,h=t.m09,_=t.m10,f=t.m11,d=t.m12,p=t.m13,m=t.m14,g=t.m15,v=n*o-i*s,y=n*c-r*s,S=n*l-a*s,E=i*c-r*o,T=i*l-a*o,A=r*l-a*c,x=u*p-h*d,C=u*m-_*d,R=u*g-f*d,b=h*m-_*p,w=h*g-f*p,I=_*g-f*m,O=v*I-y*w+S*b+E*R-T*C+A*x;return 0===O?(e.m00=0,e.m01=0,e.m02=0,e.m03=0,e.m04=0,e.m05=0,e.m06=0,e.m07=0,e.m08=0,e.m09=0,e.m10=0,e.m11=0,e.m12=0,e.m13=0,e.m14=0,e.m15=0,e):(O=1/O,e.m00=(o*I-c*w+l*b)*O,e.m01=(r*w-i*I-a*b)*O,e.m02=(p*A-m*T+g*E)*O,e.m03=(_*T-h*A-f*E)*O,e.m04=(c*R-s*I-l*C)*O,e.m05=(n*I-r*R+a*C)*O,e.m06=(m*S-d*A-g*y)*O,e.m07=(u*A-_*S+f*y)*O,e.m08=(s*w-o*R+l*x)*O,e.m09=(i*R-n*w-a*x)*O,e.m10=(d*T-p*S+g*v)*O,e.m11=(h*S-u*T-f*v)*O,e.m12=(o*C-s*b-c*x)*O,e.m13=(n*b-i*C+r*x)*O,e.m14=(p*y-d*E-m*v)*O,e.m15=(u*E-h*y+_*v)*O,e)},t.determinant=function(e){var t=e.m00,n=e.m01,i=e.m02,r=e.m03,a=e.m04,s=e.m05,o=e.m06,c=e.m07,l=e.m08,u=e.m09,h=e.m10,_=e.m11,f=e.m12,d=e.m13,p=e.m14,m=e.m15;return(t*s-n*a)*(h*m-_*p)-(t*o-i*a)*(u*m-_*d)+(t*c-r*a)*(u*p-h*d)+(n*o-i*s)*(l*m-_*f)-(n*c-r*s)*(l*p-h*f)+(i*c-r*o)*(l*d-u*f)},t.multiply=function(e,t,n){var i=t.m00,r=t.m01,a=t.m02,s=t.m03,o=t.m04,c=t.m05,l=t.m06,u=t.m07,h=t.m08,_=t.m09,f=t.m10,d=t.m11,p=t.m12,m=t.m13,g=t.m14,v=t.m15,y=n.m00,S=n.m01,E=n.m02,T=n.m03;return e.m00=y*i+S*o+E*h+T*p,e.m01=y*r+S*c+E*_+T*m,e.m02=y*a+S*l+E*f+T*g,e.m03=y*s+S*u+E*d+T*v,y=n.m04,S=n.m05,E=n.m06,T=n.m07,e.m04=y*i+S*o+E*h+T*p,e.m05=y*r+S*c+E*_+T*m,e.m06=y*a+S*l+E*f+T*g,e.m07=y*s+S*u+E*d+T*v,y=n.m08,S=n.m09,E=n.m10,T=n.m11,e.m08=y*i+S*o+E*h+T*p,e.m09=y*r+S*c+E*_+T*m,e.m10=y*a+S*l+E*f+T*g,e.m11=y*s+S*u+E*d+T*v,y=n.m12,S=n.m13,E=n.m14,T=n.m15,e.m12=y*i+S*o+E*h+T*p,e.m13=y*r+S*c+E*_+T*m,e.m14=y*a+S*l+E*f+T*g,e.m15=y*s+S*u+E*d+T*v,e},t.transform=function(e,t,n){var i=n.x,r=n.y,a=n.z;if(t===e)e.m12=t.m00*i+t.m04*r+t.m08*a+t.m12,e.m13=t.m01*i+t.m05*r+t.m09*a+t.m13,e.m14=t.m02*i+t.m06*r+t.m10*a+t.m14,e.m15=t.m03*i+t.m07*r+t.m11*a+t.m15;else{var s=t.m00,o=t.m01,c=t.m02,l=t.m03,u=t.m04,h=t.m05,_=t.m06,f=t.m07,d=t.m08,p=t.m09,m=t.m10,g=t.m11;t.m12,t.m13,t.m14,t.m15,e.m00=s,e.m01=o,e.m02=c,e.m03=l,e.m04=u,e.m05=h,e.m06=_,e.m07=f,e.m08=d,e.m09=p,e.m10=m,e.m11=g,e.m12=s*i+u*r+d*a+t.m12,e.m13=o*i+h*r+p*a+t.m13,e.m14=c*i+_*r+m*a+t.m14,e.m15=l*i+f*r+g*a+t.m15}return e},t.translate=function(e,t,n){return console.warn("function changed"),t===e?(e.m12+=n.x,e.m13+=n.y,e.m14+=n.z):(e.m00=t.m00,e.m01=t.m01,e.m02=t.m02,e.m03=t.m03,e.m04=t.m04,e.m05=t.m05,e.m06=t.m06,e.m07=t.m07,e.m08=t.m08,e.m09=t.m09,e.m10=t.m10,e.m11=t.m11,e.m12+=n.x,e.m13+=n.y,e.m14+=n.z,e.m15=t.m15),e},t.scale=function(e,t,n){var i=n.x,r=n.y,a=n.z;return e.m00=t.m00*i,e.m01=t.m01*i,e.m02=t.m02*i,e.m03=t.m03*i,e.m04=t.m04*r,e.m05=t.m05*r,e.m06=t.m06*r,e.m07=t.m07*r,e.m08=t.m08*a,e.m09=t.m09*a,e.m10=t.m10*a,e.m11=t.m11*a,e.m12=t.m12,e.m13=t.m13,e.m14=t.m14,e.m15=t.m15,e},t.rotate=function(e,t,n,i){var r=i.x,a=i.y,s=i.z,o=Math.sqrt(r*r+a*a+s*s);if(Math.abs(o)<an)return null;r*=o=1/o,a*=o,s*=o;var c=Math.sin(n),l=Math.cos(n),u=1-l,h=t.m00,_=t.m01,f=t.m02,d=t.m03,p=t.m04,m=t.m05,g=t.m06,v=t.m07,y=t.m08,S=t.m09,E=t.m10,T=t.m11,A=r*r*u+l,x=a*r*u+s*c,C=s*r*u-a*c,R=r*a*u-s*c,b=a*a*u+l,w=s*a*u+r*c,I=r*s*u+a*c,O=a*s*u-r*c,P=s*s*u+l;return e.m00=h*A+p*x+y*C,e.m01=_*A+m*x+S*C,e.m02=f*A+g*x+E*C,e.m03=d*A+v*x+T*C,e.m04=h*R+p*b+y*w,e.m05=_*R+m*b+S*w,e.m06=f*R+g*b+E*w,e.m07=d*R+v*b+T*w,e.m08=h*I+p*O+y*P,e.m09=_*I+m*O+S*P,e.m10=f*I+g*O+E*P,e.m11=d*I+v*O+T*P,t!==e&&(e.m12=t.m12,e.m13=t.m13,e.m14=t.m14,e.m15=t.m15),e},t.rotateX=function(e,t,n){var i=Math.sin(n),r=Math.cos(n),a=t.m04,s=t.m05,o=t.m06,c=t.m07,l=t.m08,u=t.m09,h=t.m10,_=t.m11;return t!==e&&(e.m00=t.m00,e.m01=t.m01,e.m02=t.m02,e.m03=t.m03,e.m12=t.m12,e.m13=t.m13,e.m14=t.m14,e.m15=t.m15),e.m04=a*r+l*i,e.m05=s*r+u*i,e.m06=o*r+h*i,e.m07=c*r+_*i,e.m08=l*r-a*i,e.m09=u*r-s*i,e.m10=h*r-o*i,e.m11=_*r-c*i,e},t.rotateY=function(e,t,n){var i=Math.sin(n),r=Math.cos(n),a=t.m00,s=t.m01,o=t.m02,c=t.m03,l=t.m08,u=t.m09,h=t.m10,_=t.m11;return t!==e&&(e.m04=t.m04,e.m05=t.m05,e.m06=t.m06,e.m07=t.m07,e.m12=t.m12,e.m13=t.m13,e.m14=t.m14,e.m15=t.m15),e.m00=a*r-l*i,e.m01=s*r-u*i,e.m02=o*r-h*i,e.m03=c*r-_*i,e.m08=a*i+l*r,e.m09=s*i+u*r,e.m10=o*i+h*r,e.m11=c*i+_*r,e},t.rotateZ=function(e,t,n){var i=Math.sin(n),r=Math.cos(n),a=t.m00,s=t.m01,o=t.m02,c=t.m03,l=t.m04,u=t.m05,h=t.m06,_=t.m07;return t!==e&&(e.m08=t.m08,e.m09=t.m09,e.m10=t.m10,e.m11=t.m11,e.m12=t.m12,e.m13=t.m13,e.m14=t.m14,e.m15=t.m15),e.m00=a*r+l*i,e.m01=s*r+u*i,e.m02=o*r+h*i,e.m03=c*r+_*i,e.m04=l*r-a*i,e.m05=u*r-s*i,e.m06=h*r-o*i,e.m07=_*r-c*i,e},t.fromTranslation=function(e,t){return e.m00=1,e.m01=0,e.m02=0,e.m03=0,e.m04=0,e.m05=1,e.m06=0,e.m07=0,e.m08=0,e.m09=0,e.m10=1,e.m11=0,e.m12=t.x,e.m13=t.y,e.m14=t.z,e.m15=1,e},t.fromScaling=function(e,t){return e.m00=t.x,e.m01=0,e.m02=0,e.m03=0,e.m04=0,e.m05=t.y,e.m06=0,e.m07=0,e.m08=0,e.m09=0,e.m10=t.z,e.m11=0,e.m12=0,e.m13=0,e.m14=0,e.m15=1,e},t.fromRotation=function(e,t,n){var i=n.x,r=n.y,a=n.z,s=Math.sqrt(i*i+r*r+a*a);if(Math.abs(s)<an)return null;i*=s=1/s,r*=s,a*=s;var o=Math.sin(t),c=Math.cos(t),l=1-c;return e.m00=i*i*l+c,e.m01=r*i*l+a*o,e.m02=a*i*l-r*o,e.m03=0,e.m04=i*r*l-a*o,e.m05=r*r*l+c,e.m06=a*r*l+i*o,e.m07=0,e.m08=i*a*l+r*o,e.m09=r*a*l-i*o,e.m10=a*a*l+c,e.m11=0,e.m12=0,e.m13=0,e.m14=0,e.m15=1,e},t.fromXRotation=function(e,t){var n=Math.sin(t),i=Math.cos(t);return e.m00=1,e.m01=0,e.m02=0,e.m03=0,e.m04=0,e.m05=i,e.m06=n,e.m07=0,e.m08=0,e.m09=-n,e.m10=i,e.m11=0,e.m12=0,e.m13=0,e.m14=0,e.m15=1,e},t.fromYRotation=function(e,t){var n=Math.sin(t),i=Math.cos(t);return e.m00=i,e.m01=0,e.m02=-n,e.m03=0,e.m04=0,e.m05=1,e.m06=0,e.m07=0,e.m08=n,e.m09=0,e.m10=i,e.m11=0,e.m12=0,e.m13=0,e.m14=0,e.m15=1,e},t.fromZRotation=function(e,t){var n=Math.sin(t),i=Math.cos(t);return e.m00=i,e.m01=n,e.m02=0,e.m03=0,e.m04=-n,e.m05=i,e.m06=0,e.m07=0,e.m08=0,e.m09=0,e.m10=1,e.m11=0,e.m12=0,e.m13=0,e.m14=0,e.m15=1,e},t.fromRT=function(e,t,n){var i=t.x,r=t.y,a=t.z,s=t.w,o=i+i,c=r+r,l=a+a,u=i*o,h=i*c,_=i*l,f=r*c,d=r*l,p=a*l,m=s*o,g=s*c,v=s*l;return e.m00=1-(f+p),e.m01=h+v,e.m02=_-g,e.m03=0,e.m04=h-v,e.m05=1-(u+p),e.m06=d+m,e.m07=0,e.m08=_+g,e.m09=d-m,e.m10=1-(u+f),e.m11=0,e.m12=n.x,e.m13=n.y,e.m14=n.z,e.m15=1,e},t.getTranslation=function(e,t){return e.x=t.m12,e.y=t.m13,e.z=t.m14,e},t.getScaling=function(e,t){var n=Wn.m00=t.m00,i=Wn.m01=t.m01,r=Wn.m02=t.m02,a=Wn.m03=t.m04,s=Wn.m04=t.m05,o=Wn.m05=t.m06,c=Wn.m06=t.m08,l=Wn.m07=t.m09,u=Wn.m08=t.m10;return e.x=Math.sqrt(n*n+i*i+r*r),e.y=Math.sqrt(a*a+s*s+o*o),e.z=Math.sqrt(c*c+l*l+u*u),Pn.determinant(Wn)<0&&(e.x*=-1),e},t.getRotation=function(e,t){var n=t.m00+t.m05+t.m10,i=0;return n>0?(i=2*Math.sqrt(n+1),e.w=.25*i,e.x=(t.m06-t.m09)/i,e.y=(t.m08-t.m02)/i,e.z=(t.m01-t.m04)/i):t.m00>t.m05&&t.m00>t.m10?(i=2*Math.sqrt(1+t.m00-t.m05-t.m10),e.w=(t.m06-t.m09)/i,e.x=.25*i,e.y=(t.m01+t.m04)/i,e.z=(t.m08+t.m02)/i):t.m05>t.m10?(i=2*Math.sqrt(1+t.m05-t.m00-t.m10),e.w=(t.m08-t.m02)/i,e.x=(t.m01+t.m04)/i,e.y=.25*i,e.z=(t.m06+t.m09)/i):(i=2*Math.sqrt(1+t.m10-t.m00-t.m05),e.w=(t.m01-t.m04)/i,e.x=(t.m08+t.m02)/i,e.y=(t.m06+t.m09)/i,e.z=.25*i),e},t.toRTS=function(e,t,n,i){i.x=bn.set(Vn,e.m00,e.m01,e.m02).length(),Wn.m00=e.m00/i.x,Wn.m01=e.m01/i.x,Wn.m02=e.m02/i.x,i.y=bn.set(Vn,e.m04,e.m05,e.m06).length(),Wn.m03=e.m04/i.y,Wn.m04=e.m05/i.y,Wn.m05=e.m06/i.y,i.z=bn.set(Vn,e.m08,e.m09,e.m10).length(),Wn.m06=e.m08/i.z,Wn.m07=e.m09/i.z,Wn.m08=e.m10/i.z,Pn.determinant(Wn)<0&&(i.x*=-1,Wn.m00*=-1,Wn.m01*=-1,Wn.m02*=-1),Dn.fromMat3(t,Wn),bn.set(n,e.m12,e.m13,e.m14)},t.fromRTS=function(e,t,n,i){var r=t.x,a=t.y,s=t.z,o=t.w,c=r+r,l=a+a,u=s+s,h=r*c,_=r*l,f=r*u,d=a*l,p=a*u,m=s*u,g=o*c,v=o*l,y=o*u,S=i.x,E=i.y,T=i.z;return e.m00=(1-(d+m))*S,e.m01=(_+y)*S,e.m02=(f-v)*S,e.m03=0,e.m04=(_-y)*E,e.m05=(1-(h+m))*E,e.m06=(p+g)*E,e.m07=0,e.m08=(f+v)*T,e.m09=(p-g)*T,e.m10=(1-(h+d))*T,e.m11=0,e.m12=n.x,e.m13=n.y,e.m14=n.z,e.m15=1,e},t.fromRTSOrigin=function(e,t,n,i,r){var a=t.x,s=t.y,o=t.z,c=t.w,l=a+a,u=s+s,h=o+o,_=a*l,f=a*u,d=a*h,p=s*u,m=s*h,g=o*h,v=c*l,y=c*u,S=c*h,E=i.x,T=i.y,A=i.z,x=r.x,C=r.y,R=r.z;return e.m00=(1-(p+g))*E,e.m01=(f+S)*E,e.m02=(d-y)*E,e.m03=0,e.m04=(f-S)*T,e.m05=(1-(_+g))*T,e.m06=(m+v)*T,e.m07=0,e.m08=(d+y)*A,e.m09=(m-v)*A,e.m10=(1-(_+p))*A,e.m11=0,e.m12=n.x+x-(e.m00*x+e.m04*C+e.m08*R),e.m13=n.y+C-(e.m01*x+e.m05*C+e.m09*R),e.m14=n.z+R-(e.m02*x+e.m06*C+e.m10*R),e.m15=1,e},t.fromQuat=function(e,t){var n=t.x,i=t.y,r=t.z,a=t.w,s=n+n,o=i+i,c=r+r,l=n*s,u=i*s,h=i*o,_=r*s,f=r*o,d=r*c,p=a*s,m=a*o,g=a*c;return e.m00=1-h-d,e.m01=u+g,e.m02=_-m,e.m03=0,e.m04=u-g,e.m05=1-l-d,e.m06=f+p,e.m07=0,e.m08=_+m,e.m09=f-p,e.m10=1-l-h,e.m11=0,e.m12=0,e.m13=0,e.m14=0,e.m15=1,e},t.frustum=function(e,t,n,i,r,a,s){var o=1/(n-t),c=1/(r-i),l=1/(a-s);return e.m00=2*a*o,e.m01=0,e.m02=0,e.m03=0,e.m04=0,e.m05=2*a*c,e.m06=0,e.m07=0,e.m08=(n+t)*o,e.m09=(r+i)*c,e.m10=(s+a)*l,e.m11=-1,e.m12=0,e.m13=0,e.m14=s*a*2*l,e.m15=0,e},t.perspective=function(e,t,n,i,r,a,s,o,c){void 0===a&&(a=!0),void 0===s&&(s=-1),void 0===o&&(o=1),void 0===c&&(c=0);var l=1/Math.tan(t/2),u=1/(i-r),h=a?l/n:l,_=(a?l:l*n)*o,f=kn[c];return e.m00=h*f[0],e.m01=h*f[1],e.m02=0,e.m03=0,e.m04=_*f[2],e.m05=_*f[3],e.m06=0,e.m07=0,e.m08=0,e.m09=0,e.m10=(r-s*i)*u,e.m11=-1,e.m12=0,e.m13=0,e.m14=r*i*u*(1-s),e.m15=0,e},t.ortho=function(e,t,n,i,r,a,s,o,c,l){void 0===o&&(o=-1),void 0===c&&(c=1),void 0===l&&(l=0);var u=1/(t-n),h=1/(i-r)*c,_=1/(a-s),f=-2*u,d=-2*h,p=(t+n)*u,m=(r+i)*h,g=kn[l];return e.m00=f*g[0],e.m01=f*g[1],e.m02=0,e.m03=0,e.m04=d*g[2],e.m05=d*g[3],e.m06=0,e.m07=0,e.m08=0,e.m09=0,e.m10=_*(1-o),e.m11=0,e.m12=p*g[0]+m*g[2],e.m13=p*g[1]+m*g[3],e.m14=(a-o*s)*_,e.m15=1,e},t.lookAt=function(e,t,n,i){var r=t.x,a=t.y,s=t.z,o=i.x,c=i.y,l=i.z,u=r-n.x,h=a-n.y,_=s-n.z,f=1/Math.sqrt(u*u+h*h+_*_),d=c*(_*=f)-l*(h*=f),p=l*(u*=f)-o*_,m=o*h-c*u,g=h*(m*=f=1/Math.sqrt(d*d+p*p+m*m))-_*(p*=f),v=_*(d*=f)-u*m,y=u*p-h*d;return e.m00=d,e.m01=g,e.m02=u,e.m03=0,e.m04=p,e.m05=v,e.m06=h,e.m07=0,e.m08=m,e.m09=y,e.m10=_,e.m11=0,e.m12=-(d*r+p*a+m*s),e.m13=-(g*r+v*a+y*s),e.m14=-(u*r+h*a+_*s),e.m15=1,e},t.inverseTranspose=function(e,t){var n=t.m00,i=t.m01,r=t.m02,a=t.m03,s=t.m04,o=t.m05,c=t.m06,l=t.m07,u=t.m08,h=t.m09,_=t.m10,f=t.m11,d=t.m12,p=t.m13,m=t.m14,g=t.m15,v=n*o-i*s,y=n*c-r*s,S=n*l-a*s,E=i*c-r*o,T=i*l-a*o,A=r*l-a*c,x=u*p-h*d,C=u*m-_*d,R=u*g-f*d,b=h*m-_*p,w=h*g-f*p,I=_*g-f*m,O=v*I-y*w+S*b+E*R-T*C+A*x;return O?(O=1/O,e.m00=(o*I-c*w+l*b)*O,e.m01=(c*R-s*I-l*C)*O,e.m02=(s*w-o*R+l*x)*O,e.m03=0,e.m04=(r*w-i*I-a*b)*O,e.m05=(n*I-r*R+a*C)*O,e.m06=(i*R-n*w-a*x)*O,e.m07=0,e.m08=(p*A-m*T+g*E)*O,e.m09=(m*S-d*A-g*y)*O,e.m10=(d*T-p*S+g*v)*O,e.m11=0,e.m12=0,e.m13=0,e.m14=0,e.m15=1,e):null},t.toArray=function(e,t,n){return void 0===n&&(n=0),e[n+0]=t.m00,e[n+1]=t.m01,e[n+2]=t.m02,e[n+3]=t.m03,e[n+4]=t.m04,e[n+5]=t.m05,e[n+6]=t.m06,e[n+7]=t.m07,e[n+8]=t.m08,e[n+9]=t.m09,e[n+10]=t.m10,e[n+11]=t.m11,e[n+12]=t.m12,e[n+13]=t.m13,e[n+14]=t.m14,e[n+15]=t.m15,e},t.fromArray=function(e,t,n){return void 0===n&&(n=0),e.m00=t[n+0],e.m01=t[n+1],e.m02=t[n+2],e.m03=t[n+3],e.m04=t[n+4],e.m05=t[n+5],e.m06=t[n+6],e.m07=t[n+7],e.m08=t[n+8],e.m09=t[n+9],e.m10=t[n+10],e.m11=t[n+11],e.m12=t[n+12],e.m13=t[n+13],e.m14=t[n+14],e.m15=t[n+15],e},t.add=function(e,t,n){return e.m00=t.m00+n.m00,e.m01=t.m01+n.m01,e.m02=t.m02+n.m02,e.m03=t.m03+n.m03,e.m04=t.m04+n.m04,e.m05=t.m05+n.m05,e.m06=t.m06+n.m06,e.m07=t.m07+n.m07,e.m08=t.m08+n.m08,e.m09=t.m09+n.m09,e.m10=t.m10+n.m10,e.m11=t.m11+n.m11,e.m12=t.m12+n.m12,e.m13=t.m13+n.m13,e.m14=t.m14+n.m14,e.m15=t.m15+n.m15,e},t.subtract=function(e,t,n){return e.m00=t.m00-n.m00,e.m01=t.m01-n.m01,e.m02=t.m02-n.m02,e.m03=t.m03-n.m03,e.m04=t.m04-n.m04,e.m05=t.m05-n.m05,e.m06=t.m06-n.m06,e.m07=t.m07-n.m07,e.m08=t.m08-n.m08,e.m09=t.m09-n.m09,e.m10=t.m10-n.m10,e.m11=t.m11-n.m11,e.m12=t.m12-n.m12,e.m13=t.m13-n.m13,e.m14=t.m14-n.m14,e.m15=t.m15-n.m15,e},t.multiplyScalar=function(e,t,n){return e.m00=t.m00*n,e.m01=t.m01*n,e.m02=t.m02*n,e.m03=t.m03*n,e.m04=t.m04*n,e.m05=t.m05*n,e.m06=t.m06*n,e.m07=t.m07*n,e.m08=t.m08*n,e.m09=t.m09*n,e.m10=t.m10*n,e.m11=t.m11*n,e.m12=t.m12*n,e.m13=t.m13*n,e.m14=t.m14*n,e.m15=t.m15*n,e},t.multiplyScalarAndAdd=function(e,t,n,i){return e.m00=t.m00+n.m00*i,e.m01=t.m01+n.m01*i,e.m02=t.m02+n.m02*i,e.m03=t.m03+n.m03*i,e.m04=t.m04+n.m04*i,e.m05=t.m05+n.m05*i,e.m06=t.m06+n.m06*i,e.m07=t.m07+n.m07*i,e.m08=t.m08+n.m08*i,e.m09=t.m09+n.m09*i,e.m10=t.m10+n.m10*i,e.m11=t.m11+n.m11*i,e.m12=t.m12+n.m12*i,e.m13=t.m13+n.m13*i,e.m14=t.m14+n.m14*i,e.m15=t.m15+n.m15*i,e},t.strictEquals=function(e,t){return e.m00===t.m00&&e.m01===t.m01&&e.m02===t.m02&&e.m03===t.m03&&e.m04===t.m04&&e.m05===t.m05&&e.m06===t.m06&&e.m07===t.m07&&e.m08===t.m08&&e.m09===t.m09&&e.m10===t.m10&&e.m11===t.m11&&e.m12===t.m12&&e.m13===t.m13&&e.m14===t.m14&&e.m15===t.m15},t.equals=function(e,t,n){return void 0===n&&(n=an),Math.abs(e.m00-t.m00)<=n*Math.max(1,Math.abs(e.m00),Math.abs(t.m00))&&Math.abs(e.m01-t.m01)<=n*Math.max(1,Math.abs(e.m01),Math.abs(t.m01))&&Math.abs(e.m02-t.m02)<=n*Math.max(1,Math.abs(e.m02),Math.abs(t.m02))&&Math.abs(e.m03-t.m03)<=n*Math.max(1,Math.abs(e.m03),Math.abs(t.m03))&&Math.abs(e.m04-t.m04)<=n*Math.max(1,Math.abs(e.m04),Math.abs(t.m04))&&Math.abs(e.m05-t.m05)<=n*Math.max(1,Math.abs(e.m05),Math.abs(t.m05))&&Math.abs(e.m06-t.m06)<=n*Math.max(1,Math.abs(e.m06),Math.abs(t.m06))&&Math.abs(e.m07-t.m07)<=n*Math.max(1,Math.abs(e.m07),Math.abs(t.m07))&&Math.abs(e.m08-t.m08)<=n*Math.max(1,Math.abs(e.m08),Math.abs(t.m08))&&Math.abs(e.m09-t.m09)<=n*Math.max(1,Math.abs(e.m09),Math.abs(t.m09))&&Math.abs(e.m10-t.m10)<=n*Math.max(1,Math.abs(e.m10),Math.abs(t.m10))&&Math.abs(e.m11-t.m11)<=n*Math.max(1,Math.abs(e.m11),Math.abs(t.m11))&&Math.abs(e.m12-t.m12)<=n*Math.max(1,Math.abs(e.m12),Math.abs(t.m12))&&Math.abs(e.m13-t.m13)<=n*Math.max(1,Math.abs(e.m13),Math.abs(t.m13))&&Math.abs(e.m14-t.m14)<=n*Math.max(1,Math.abs(e.m14),Math.abs(t.m14))&&Math.abs(e.m15-t.m15)<=n*Math.max(1,Math.abs(e.m15),Math.abs(t.m15))};var n=t.prototype;return n.clone=function(){return new t(this.m00,this.m01,this.m02,this.m03,this.m04,this.m05,this.m06,this.m07,this.m08,this.m09,this.m10,this.m11,this.m12,this.m13,this.m14,this.m15)},n.set=function(e,t,n,i,r,a,s,o,c,l,u,h,_,f,d,p){return void 0===e&&(e=1),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===a&&(a=1),void 0===s&&(s=0),void 0===o&&(o=0),void 0===c&&(c=0),void 0===l&&(l=0),void 0===u&&(u=1),void 0===h&&(h=0),void 0===_&&(_=0),void 0===f&&(f=0),void 0===d&&(d=0),void 0===p&&(p=1),"object"==typeof e?(this.m01=e.m01,this.m02=e.m02,this.m03=e.m03,this.m04=e.m04,this.m05=e.m05,this.m06=e.m06,this.m07=e.m07,this.m08=e.m08,this.m09=e.m09,this.m10=e.m10,this.m11=e.m11,this.m12=e.m12,this.m13=e.m13,this.m14=e.m14,this.m15=e.m15,this.m00=e.m00):(this.m01=t,this.m02=n,this.m03=i,this.m04=r,this.m05=a,this.m06=s,this.m07=o,this.m08=c,this.m09=l,this.m10=u,this.m11=h,this.m12=_,this.m13=f,this.m14=d,this.m15=p,this.m00=e),this},n.equals=function(e,t){return void 0===t&&(t=an),Math.abs(this.m00-e.m00)<=t*Math.max(1,Math.abs(this.m00),Math.abs(e.m00))&&Math.abs(this.m01-e.m01)<=t*Math.max(1,Math.abs(this.m01),Math.abs(e.m01))&&Math.abs(this.m02-e.m02)<=t*Math.max(1,Math.abs(this.m02),Math.abs(e.m02))&&Math.abs(this.m03-e.m03)<=t*Math.max(1,Math.abs(this.m03),Math.abs(e.m03))&&Math.abs(this.m04-e.m04)<=t*Math.max(1,Math.abs(this.m04),Math.abs(e.m04))&&Math.abs(this.m05-e.m05)<=t*Math.max(1,Math.abs(this.m05),Math.abs(e.m05))&&Math.abs(this.m06-e.m06)<=t*Math.max(1,Math.abs(this.m06),Math.abs(e.m06))&&Math.abs(this.m07-e.m07)<=t*Math.max(1,Math.abs(this.m07),Math.abs(e.m07))&&Math.abs(this.m08-e.m08)<=t*Math.max(1,Math.abs(this.m08),Math.abs(e.m08))&&Math.abs(this.m09-e.m09)<=t*Math.max(1,Math.abs(this.m09),Math.abs(e.m09))&&Math.abs(this.m10-e.m10)<=t*Math.max(1,Math.abs(this.m10),Math.abs(e.m10))&&Math.abs(this.m11-e.m11)<=t*Math.max(1,Math.abs(this.m11),Math.abs(e.m11))&&Math.abs(this.m12-e.m12)<=t*Math.max(1,Math.abs(this.m12),Math.abs(e.m12))&&Math.abs(this.m13-e.m13)<=t*Math.max(1,Math.abs(this.m13),Math.abs(e.m13))&&Math.abs(this.m14-e.m14)<=t*Math.max(1,Math.abs(this.m14),Math.abs(e.m14))&&Math.abs(this.m15-e.m15)<=t*Math.max(1,Math.abs(this.m15),Math.abs(e.m15))},n.strictEquals=function(e){return this.m00===e.m00&&this.m01===e.m01&&this.m02===e.m02&&this.m03===e.m03&&this.m04===e.m04&&this.m05===e.m05&&this.m06===e.m06&&this.m07===e.m07&&this.m08===e.m08&&this.m09===e.m09&&this.m10===e.m10&&this.m11===e.m11&&this.m12===e.m12&&this.m13===e.m13&&this.m14===e.m14&&this.m15===e.m15},n.toString=function(){return"[\n"+this.m00+", "+this.m01+", "+this.m02+", "+this.m03+",\n"+this.m04+", "+this.m05+", "+this.m06+", "+this.m07+",\n"+this.m08+", "+this.m09+", "+this.m10+", "+this.m11+",\n"+this.m12+", "+this.m13+", "+this.m14+", "+this.m15+"\n]"},n.identity=function(){return this.m00=1,this.m01=0,this.m02=0,this.m03=0,this.m04=0,this.m05=1,this.m06=0,this.m07=0,this.m08=0,this.m09=0,this.m10=1,this.m11=0,this.m12=0,this.m13=0,this.m14=0,this.m15=1,this},n.zero=function(){return this.m00=0,this.m01=0,this.m02=0,this.m03=0,this.m04=0,this.m05=0,this.m06=0,this.m07=0,this.m08=0,this.m09=0,this.m10=0,this.m11=0,this.m12=0,this.m13=0,this.m14=0,this.m15=0,this},n.transpose=function(){var e=this.m01,t=this.m02,n=this.m03,i=this.m06,r=this.m07,a=this.m11;return this.m01=this.m04,this.m02=this.m08,this.m03=this.m12,this.m04=e,this.m06=this.m09,this.m07=this.m13,this.m08=t,this.m09=i,this.m11=this.m14,this.m12=n,this.m13=r,this.m14=a,this},n.invert=function(){var e=this.m00,t=this.m01,n=this.m02,i=this.m03,r=this.m04,a=this.m05,s=this.m06,o=this.m07,c=this.m08,l=this.m09,u=this.m10,h=this.m11,_=this.m12,f=this.m13,d=this.m14,p=this.m15,m=e*a-t*r,g=e*s-n*r,v=e*o-i*r,y=t*s-n*a,S=t*o-i*a,E=n*o-i*s,T=c*f-l*_,A=c*d-u*_,x=c*p-h*_,C=l*d-u*f,R=l*p-h*f,b=u*p-h*d,w=m*b-g*R+v*C+y*x-S*A+E*T;return 0===w?(this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),this):(w=1/w,this.m00=(a*b-s*R+o*C)*w,this.m01=(n*R-t*b-i*C)*w,this.m02=(f*E-d*S+p*y)*w,this.m03=(u*S-l*E-h*y)*w,this.m04=(s*x-r*b-o*A)*w,this.m05=(e*b-n*x+i*A)*w,this.m06=(d*v-_*E-p*g)*w,this.m07=(c*E-u*v+h*g)*w,this.m08=(r*R-a*x+o*T)*w,this.m09=(t*x-e*R-i*T)*w,this.m10=(_*S-f*v+p*m)*w,this.m11=(l*v-c*S-h*m)*w,this.m12=(a*A-r*C-s*T)*w,this.m13=(e*C-t*A+n*T)*w,this.m14=(f*g-_*y-d*m)*w,this.m15=(c*y-l*g+u*m)*w,this)},n.determinant=function(){var e=this.m00,t=this.m01,n=this.m02,i=this.m03,r=this.m04,a=this.m05,s=this.m06,o=this.m07,c=this.m08,l=this.m09,u=this.m10,h=this.m11,_=this.m12,f=this.m13,d=this.m14,p=this.m15;return(e*a-t*r)*(u*p-h*d)-(e*s-n*r)*(l*p-h*f)+(e*o-i*r)*(l*d-u*f)+(t*s-n*a)*(c*p-h*_)-(t*o-i*a)*(c*d-u*_)+(n*o-i*s)*(c*f-l*_)},n.add=function(e){return this.m00+=e.m00,this.m01+=e.m01,this.m02+=e.m02,this.m03+=e.m03,this.m04+=e.m04,this.m05+=e.m05,this.m06+=e.m06,this.m07+=e.m07,this.m08+=e.m08,this.m09+=e.m09,this.m10+=e.m10,this.m11+=e.m11,this.m12+=e.m12,this.m13+=e.m13,this.m14+=e.m14,this.m15+=e.m15,this},n.subtract=function(e){return this.m00-=e.m00,this.m01-=e.m01,this.m02-=e.m02,this.m03-=e.m03,this.m04-=e.m04,this.m05-=e.m05,this.m06-=e.m06,this.m07-=e.m07,this.m08-=e.m08,this.m09-=e.m09,this.m10-=e.m10,this.m11-=e.m11,this.m12-=e.m12,this.m13-=e.m13,this.m14-=e.m14,this.m15-=e.m15,this},n.multiply=function(e){var t=this.m00,n=this.m01,i=this.m02,r=this.m03,a=this.m04,s=this.m05,o=this.m06,c=this.m07,l=this.m08,u=this.m09,h=this.m10,_=this.m11,f=this.m12,d=this.m13,p=this.m14,m=this.m15,g=e.m00,v=e.m01,y=e.m02,S=e.m03;return this.m00=g*t+v*a+y*l+S*f,this.m01=g*n+v*s+y*u+S*d,this.m02=g*i+v*o+y*h+S*p,this.m03=g*r+v*c+y*_+S*m,g=e.m04,v=e.m05,y=e.m06,S=e.m07,this.m04=g*t+v*a+y*l+S*f,this.m05=g*n+v*s+y*u+S*d,this.m06=g*i+v*o+y*h+S*p,this.m07=g*r+v*c+y*_+S*m,g=e.m08,v=e.m09,y=e.m10,S=e.m11,this.m08=g*t+v*a+y*l+S*f,this.m09=g*n+v*s+y*u+S*d,this.m10=g*i+v*o+y*h+S*p,this.m11=g*r+v*c+y*_+S*m,g=e.m12,v=e.m13,y=e.m14,S=e.m15,this.m12=g*t+v*a+y*l+S*f,this.m13=g*n+v*s+y*u+S*d,this.m14=g*i+v*o+y*h+S*p,this.m15=g*r+v*c+y*_+S*m,this},n.multiplyScalar=function(e){return this.m00*=e,this.m01*=e,this.m02*=e,this.m03*=e,this.m04*=e,this.m05*=e,this.m06*=e,this.m07*=e,this.m08*=e,this.m09*=e,this.m10*=e,this.m11*=e,this.m12*=e,this.m13*=e,this.m14*=e,this.m15*=e,this},n.translate=function(e){return console.warn("function changed"),this.m12+=e.x,this.m13+=e.y,this.m14+=e.z,this},n.scale=function(e){var t=e.x,n=e.y,i=e.z;return this.m00*=t,this.m01*=t,this.m02*=t,this.m03*=t,this.m04*=n,this.m05*=n,this.m06*=n,this.m07*=n,this.m08*=i,this.m09*=i,this.m10*=i,this.m11*=i,this},n.rotate=function(e,t){var n=t.x,i=t.y,r=t.z,a=Math.sqrt(n*n+i*i+r*r);if(Math.abs(a)<an)return null;n*=a=1/a,i*=a,r*=a;var s=Math.sin(e),o=Math.cos(e),c=1-o,l=this.m00,u=this.m01,h=this.m02,_=this.m03,f=this.m04,d=this.m05,p=this.m06,m=this.m07,g=this.m08,v=this.m09,y=this.m10,S=this.m11,E=n*n*c+o,T=i*n*c+r*s,A=r*n*c-i*s,x=n*i*c-r*s,C=i*i*c+o,R=r*i*c+n*s,b=n*r*c+i*s,w=i*r*c-n*s,I=r*r*c+o;return this.m00=l*E+f*T+g*A,this.m01=u*E+d*T+v*A,this.m02=h*E+p*T+y*A,this.m03=_*E+m*T+S*A,this.m04=l*x+f*C+g*R,this.m05=u*x+d*C+v*R,this.m06=h*x+p*C+y*R,this.m07=_*x+m*C+S*R,this.m08=l*b+f*w+g*I,this.m09=u*b+d*w+v*I,this.m10=h*b+p*w+y*I,this.m11=_*b+m*w+S*I,this},n.getTranslation=function(e){return e.x=this.m12,e.y=this.m13,e.z=this.m14,e},n.getScale=function(e){var t=Wn.m00=this.m00,n=Wn.m01=this.m01,i=Wn.m02=this.m02,r=Wn.m03=this.m04,a=Wn.m04=this.m05,s=Wn.m05=this.m06,o=Wn.m06=this.m08,c=Wn.m07=this.m09,l=Wn.m08=this.m10;return e.x=Math.sqrt(t*t+n*n+i*i),e.y=Math.sqrt(r*r+a*a+s*s),e.z=Math.sqrt(o*o+c*c+l*l),Pn.determinant(Wn)<0&&(e.x*=-1),e},n.getRotation=function(e){var t=this.m00+this.m05+this.m10,n=0;return t>0?(n=2*Math.sqrt(t+1),e.w=.25*n,e.x=(this.m06-this.m09)/n,e.y=(this.m08-this.m02)/n,e.z=(this.m01-this.m04)/n):this.m00>this.m05&&this.m00>this.m10?(n=2*Math.sqrt(1+this.m00-this.m05-this.m10),e.w=(this.m06-this.m09)/n,e.x=.25*n,e.y=(this.m01+this.m04)/n,e.z=(this.m08+this.m02)/n):this.m05>this.m10?(n=2*Math.sqrt(1+this.m05-this.m00-this.m10),e.w=(this.m08-this.m02)/n,e.x=(this.m01+this.m04)/n,e.y=.25*n,e.z=(this.m06+this.m09)/n):(n=2*Math.sqrt(1+this.m10-this.m00-this.m05),e.w=(this.m01-this.m04)/n,e.x=(this.m08+this.m02)/n,e.y=(this.m06+this.m09)/n,e.z=.25*n),e},n.fromRTS=function(e,t,n){var i=e.x,r=e.y,a=e.z,s=e.w,o=i+i,c=r+r,l=a+a,u=i*o,h=i*c,_=i*l,f=r*c,d=r*l,p=a*l,m=s*o,g=s*c,v=s*l,y=n.x,S=n.y,E=n.z;return this.m00=(1-(f+p))*y,this.m01=(h+v)*y,this.m02=(_-g)*y,this.m03=0,this.m04=(h-v)*S,this.m05=(1-(u+p))*S,this.m06=(d+m)*S,this.m07=0,this.m08=(_+g)*E,this.m09=(d-m)*E,this.m10=(1-(u+f))*E,this.m11=0,this.m12=t.x,this.m13=t.y,this.m14=t.z,this.m15=1,this},n.fromQuat=function(e){var t=e.x,n=e.y,i=e.z,r=e.w,a=t+t,s=n+n,o=i+i,c=t*a,l=n*a,u=n*s,h=i*a,_=i*s,f=i*o,d=r*a,p=r*s,m=r*o;return this.m00=1-u-f,this.m01=l+m,this.m02=h-p,this.m03=0,this.m04=l-m,this.m05=1-c-f,this.m06=_+d,this.m07=0,this.m08=h+p,this.m09=_-d,this.m10=1-c-u,this.m11=0,this.m12=0,this.m13=0,this.m14=0,this.m15=1,this},t}(_t));Hn.IDENTITY=Object.freeze(new Hn);var Vn=new bn,Wn=new Pn;function jn(e,t,n,i,r,a,s,o,c,l,u,h,_,f,d,p){return new Hn(e,t,n,i,r,a,s,o,c,l,u,h,_,f,d,p)}$t.fastDefine("cc.Mat4",Hn,{m00:1,m01:0,m02:0,m03:0,m04:0,m05:1,m06:0,m07:0,m08:0,m09:0,m10:1,m11:0,m12:0,m13:0,m14:0,m15:1}),i.Mat4=Hn,i.mat4=jn;var qn=e("Vec2",function(e){function t(t,n){var i;return i=e.call(this)||this,t&&"object"==typeof t?(i.x=t.x,i.y=t.y):(i.x=t||0,i.y=n||0),i}X(t,e),t.clone=function(e){return new t(e.x,e.y)},t.copy=function(e,t){return e.x=t.x,e.y=t.y,e},t.set=function(e,t,n){return e.x=t,e.y=n,e},t.add=function(e,t,n){return e.x=t.x+n.x,e.y=t.y+n.y,e},t.subtract=function(e,t,n){return e.x=t.x-n.x,e.y=t.y-n.y,e},t.multiply=function(e,t,n){return e.x=t.x*n.x,e.y=t.y*n.y,e},t.divide=function(e,t,n){return e.x=t.x/n.x,e.y=t.y/n.y,e},t.ceil=function(e,t){return e.x=Math.ceil(t.x),e.y=Math.ceil(t.y),e},t.floor=function(e,t){return e.x=Math.floor(t.x),e.y=Math.floor(t.y),e},t.min=function(e,t,n){return e.x=Math.min(t.x,n.x),e.y=Math.min(t.y,n.y),e},t.max=function(e,t,n){return e.x=Math.max(t.x,n.x),e.y=Math.max(t.y,n.y),e},t.round=function(e,t){return e.x=Math.round(t.x),e.y=Math.round(t.y),e},t.multiplyScalar=function(e,t,n){return e.x=t.x*n,e.y=t.y*n,e},t.scaleAndAdd=function(e,t,n,i){return e.x=t.x+n.x*i,e.y=t.y+n.y*i,e},t.distance=function(e,t){var n=t.x-e.x,i=t.y-e.y;return Math.sqrt(n*n+i*i)},t.squaredDistance=function(e,t){var n=t.x-e.x,i=t.y-e.y;return n*n+i*i},t.len=function(e){var t=e.x,n=e.y;return Math.sqrt(t*t+n*n)},t.lengthSqr=function(e){var t=e.x,n=e.y;return t*t+n*n},t.negate=function(e,t){return e.x=-t.x,e.y=-t.y,e},t.inverse=function(e,t){return e.x=1/t.x,e.y=1/t.y,e},t.inverseSafe=function(e,t){var n=t.x,i=t.y;return Math.abs(n)<an?e.x=0:e.x=1/n,Math.abs(i)<an?e.y=0:e.y=1/i,e},t.normalize=function(e,t){var n=t.x,i=t.y,r=n*n+i*i;return r>0&&(r=1/Math.sqrt(r),e.x=n*r,e.y=i*r),e},t.dot=function(e,t){return e.x*t.x+e.y*t.y},t.cross=function(e,t,n){return e.x=e.y=0,e.z=t.x*n.y-t.y*n.x,e},t.lerp=function(e,t,n,i){var r=t.x,a=t.y;return e.x=r+i*(n.x-r),e.y=a+i*(n.y-a),e},t.random=function(e,t){t=t||1;var n=2*fn()*Math.PI;return e.x=Math.cos(n)*t,e.y=Math.sin(n)*t,e},t.transformMat3=function(e,t,n){var i=t.x,r=t.y;return e.x=n.m00*i+n.m03*r+n.m06,e.y=n.m01*i+n.m04*r+n.m07,e},t.transformMat4=function(e,t,n){var i=t.x,r=t.y;return e.x=n.m00*i+n.m04*r+n.m12,e.y=n.m01*i+n.m05*r+n.m13,e},t.str=function(e){return"Vec2("+e.x+", "+e.y+")"},t.toArray=function(e,t,n){return void 0===n&&(n=0),e[n+0]=t.x,e[n+1]=t.y,e},t.fromArray=function(e,t,n){return void 0===n&&(n=0),e.x=t[n+0],e.y=t[n+1],e},t.strictEquals=function(e,t){return e.x===t.x&&e.y===t.y},t.equals=function(e,t,n){return void 0===n&&(n=an),Math.abs(e.x-t.x)<=n*Math.max(1,Math.abs(e.x),Math.abs(t.x))&&Math.abs(e.y-t.y)<=n*Math.max(1,Math.abs(e.y),Math.abs(t.y))},t.angle=function(e,n){t.normalize(Xn,e),t.normalize(Yn,n);var i=t.dot(Xn,Yn);return i>1?0:i<-1?Math.PI:Math.acos(i)};var n=t.prototype;return n.clone=function(){return new t(this.x,this.y)},n.set=function(e,t){return e&&"object"==typeof e?(this.x=e.x,this.y=e.y):(this.x=e||0,this.y=t||0),this},n.equals=function(e,t){return void 0===t&&(t=an),Math.abs(this.x-e.x)<=t*Math.max(1,Math.abs(this.x),Math.abs(e.x))&&Math.abs(this.y-e.y)<=t*Math.max(1,Math.abs(this.y),Math.abs(e.y))},n.equals2f=function(e,t,n){return void 0===n&&(n=an),Math.abs(this.x-e)<=n*Math.max(1,Math.abs(this.x),Math.abs(e))&&Math.abs(this.y-t)<=n*Math.max(1,Math.abs(this.y),Math.abs(t))},n.strictEquals=function(e){return e&&this.x===e.x&&this.y===e.y},n.strictEquals2f=function(e,t){return this.x===e&&this.y===t},n.toString=function(){return"("+this.x.toFixed(2)+", "+this.y.toFixed(2)+")"},n.lerp=function(e,t){var n=this.x,i=this.y;return this.x=n+t*(e.x-n),this.y=i+t*(e.y-i),this},n.clampf=function(e,t){return this.x=cn(this.x,e.x,t.x),this.y=cn(this.y,e.y,t.y),this},n.add=function(e){return this.x+=e.x,this.y+=e.y,this},n.add2f=function(e,t){return this.x+=e,this.y+=t,this},n.subtract=function(e){return this.x-=e.x,this.y-=e.y,this},n.subtract2f=function(e,t){return this.x-=e,this.y-=t,this},n.multiplyScalar=function(e){return"object"==typeof e&&console.warn("should use Vec2.multiply for vector * vector operation"),this.x*=e,this.y*=e,this},n.multiply=function(e){return"object"!=typeof e&&console.warn("should use Vec2.scale for vector * scalar operation"),this.x*=e.x,this.y*=e.y,this},n.multiply2f=function(e,t){return this.x*=e,this.y*=t,this},n.divide=function(e){return this.x/=e.x,this.y/=e.y,this},n.divide2f=function(e,t){return this.x/=e,this.y/=t,this},n.negative=function(){return this.x=-this.x,this.y=-this.y,this},n.dot=function(e){return this.x*e.x+this.y*e.y},n.cross=function(e){return this.x*e.y-this.y*e.x},n.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},n.lengthSqr=function(){return this.x*this.x+this.y*this.y},n.normalize=function(){var e=this.x,t=this.y,n=e*e+t*t;return n>0&&(n=1/Math.sqrt(n),this.x*=n,this.y*=n),this},n.angle=function(e){var t=this.lengthSqr(),n=e.lengthSqr();if(0===t||0===n)return console.warn("Can't get angle between zero vector"),0;var i=this.dot(e)/Math.sqrt(t*n);return i=cn(i,-1,1),Math.acos(i)},n.signAngle=function(e){var t=this.angle(e);return this.cross(e)<0?-t:t},n.rotate=function(e){var t=this.x,n=this.y,i=Math.sin(e),r=Math.cos(e);return this.x=r*t-i*n,this.y=i*t+r*n,this},n.project=function(e){var t=this.dot(e)/e.dot(e);return this.x=e.x*t,this.y=e.y*t,this},n.transformMat4=function(e){var t=this.x,n=this.y;return this.x=e.m00*t+e.m04*n+e.m12,this.y=e.m01*t+e.m05*n+e.m13,this},t}(_t));qn.ZERO=Object.freeze(new qn(0,0)),qn.ONE=Object.freeze(new qn(1,1)),qn.NEG_ONE=Object.freeze(new qn(-1,-1)),qn.UNIT_X=Object.freeze(new qn(1,0)),qn.UNIT_Y=Object.freeze(new qn(0,1));var Xn=new qn,Yn=new qn;function Kn(e,t){return new qn(e,t)}$t.fastDefine("cc.Vec2",qn,{x:0,y:0}),i.Vec2=qn,i.v2=Kn;var Zn=e("Vec4",function(e){function t(t,n,i,r){var a;return a=e.call(this)||this,t&&"object"==typeof t?(a.x=t.x,a.y=t.y,a.z=t.z,a.w=t.w):(a.x=t||0,a.y=n||0,a.z=i||0,a.w=r||0),a}X(t,e),t.clone=function(e){return new t(e.x,e.y,e.z,e.w)},t.copy=function(e,t){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e},t.set=function(e,t,n,i,r){return e.x=t,e.y=n,e.z=i,e.w=r,e},t.add=function(e,t,n){return e.x=t.x+n.x,e.y=t.y+n.y,e.z=t.z+n.z,e.w=t.w+n.w,e},t.subtract=function(e,t,n){return e.x=t.x-n.x,e.y=t.y-n.y,e.z=t.z-n.z,e.w=t.w-n.w,e},t.multiply=function(e,t,n){return e.x=t.x*n.x,e.y=t.y*n.y,e.z=t.z*n.z,e.w=t.w*n.w,e},t.divide=function(e,t,n){return e.x=t.x/n.x,e.y=t.y/n.y,e.z=t.z/n.z,e.w=t.w/n.w,e},t.ceil=function(e,t){return e.x=Math.ceil(t.x),e.y=Math.ceil(t.y),e.z=Math.ceil(t.z),e.w=Math.ceil(t.w),e},t.floor=function(e,t){return e.x=Math.floor(t.x),e.y=Math.floor(t.y),e.z=Math.floor(t.z),e.w=Math.floor(t.w),e},t.min=function(e,t,n){return e.x=Math.min(t.x,n.x),e.y=Math.min(t.y,n.y),e.z=Math.min(t.z,n.z),e.w=Math.min(t.w,n.w),e},t.max=function(e,t,n){return e.x=Math.max(t.x,n.x),e.y=Math.max(t.y,n.y),e.z=Math.max(t.z,n.z),e.w=Math.max(t.w,n.w),e},t.round=function(e,t){return e.x=Math.round(t.x),e.y=Math.round(t.y),e.z=Math.round(t.z),e.w=Math.round(t.w),e},t.multiplyScalar=function(e,t,n){return e.x=t.x*n,e.y=t.y*n,e.z=t.z*n,e.w=t.w*n,e},t.scaleAndAdd=function(e,t,n,i){return e.x=t.x+n.x*i,e.y=t.y+n.y*i,e.z=t.z+n.z*i,e.w=t.w+n.w*i,e},t.distance=function(e,t){var n=t.x-e.x,i=t.y-e.y,r=t.z-e.z,a=t.w-e.w;return Math.sqrt(n*n+i*i+r*r+a*a)},t.squaredDistance=function(e,t){var n=t.x-e.x,i=t.y-e.y,r=t.z-e.z,a=t.w-e.w;return n*n+i*i+r*r+a*a},t.len=function(e){var t=e.x,n=e.y,i=e.z,r=e.w;return Math.sqrt(t*t+n*n+i*i+r*r)},t.lengthSqr=function(e){var t=e.x,n=e.y,i=e.z,r=e.w;return t*t+n*n+i*i+r*r},t.negate=function(e,t){return e.x=-t.x,e.y=-t.y,e.z=-t.z,e.w=-t.w,e},t.inverse=function(e,t){return e.x=1/t.x,e.y=1/t.y,e.z=1/t.z,e.w=1/t.w,e},t.inverseSafe=function(e,t){var n=t.x,i=t.y,r=t.z,a=t.w;return Math.abs(n)<an?e.x=0:e.x=1/n,Math.abs(i)<an?e.y=0:e.y=1/i,Math.abs(r)<an?e.z=0:e.z=1/r,Math.abs(a)<an?e.w=0:e.w=1/a,e},t.normalize=function(e,t){var n=t.x,i=t.y,r=t.z,a=t.w,s=n*n+i*i+r*r+a*a;return s>0&&(s=1/Math.sqrt(s),e.x=n*s,e.y=i*s,e.z=r*s,e.w=a*s),e},t.dot=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w},t.lerp=function(e,t,n,i){return e.x=t.x+i*(n.x-t.x),e.y=t.y+i*(n.y-t.y),e.z=t.z+i*(n.z-t.z),e.w=t.w+i*(n.w-t.w),e},t.random=function(e,t){t=t||1;var n=2*fn()*Math.PI,i=2*fn()-1,r=Math.sqrt(1-i*i);return e.x=r*Math.cos(n)*t,e.y=r*Math.sin(n)*t,e.z=i*t,e.w=0,e},t.transformMat4=function(e,t,n){var i=t.x,r=t.y,a=t.z,s=t.w;return e.x=n.m00*i+n.m04*r+n.m08*a+n.m12*s,e.y=n.m01*i+n.m05*r+n.m09*a+n.m13*s,e.z=n.m02*i+n.m06*r+n.m10*a+n.m14*s,e.w=n.m03*i+n.m07*r+n.m11*a+n.m15*s,e},t.transformAffine=function(e,t,n){var i=t.x,r=t.y,a=t.z,s=t.w;return e.x=n.m00*i+n.m01*r+n.m02*a+n.m03*s,e.y=n.m04*i+n.m05*r+n.m06*a+n.m07*s,e.x=n.m08*i+n.m09*r+n.m10*a+n.m11*s,e.w=t.w,e},t.transformQuat=function(e,t,n){var i=t.x,r=t.y,a=t.z,s=n.x,o=n.y,c=n.z,l=n.w,u=l*i+o*a-c*r,h=l*r+c*i-s*a,_=l*a+s*r-o*i,f=-s*i-o*r-c*a;return e.x=u*l+f*-s+h*-c-_*-o,e.y=h*l+f*-o+_*-s-u*-c,e.z=_*l+f*-c+u*-o-h*-s,e.w=t.w,e},t.toArray=function(e,t,n){return void 0===n&&(n=0),e[n+0]=t.x,e[n+1]=t.y,e[n+2]=t.z,e[n+3]=t.w,e},t.fromArray=function(e,t,n){return void 0===n&&(n=0),e.x=t[n+0],e.y=t[n+1],e.z=t[n+2],e.w=t[n+3],e},t.strictEquals=function(e,t){return e.x===t.x&&e.y===t.y&&e.z===t.z&&e.w===t.w},t.equals=function(e,t,n){return void 0===n&&(n=an),Math.abs(e.x-t.x)<=n*Math.max(1,Math.abs(e.x),Math.abs(t.x))&&Math.abs(e.y-t.y)<=n*Math.max(1,Math.abs(e.y),Math.abs(t.y))&&Math.abs(e.z-t.z)<=n*Math.max(1,Math.abs(e.z),Math.abs(t.z))&&Math.abs(e.w-t.w)<=n*Math.max(1,Math.abs(e.w),Math.abs(t.w))};var n=t.prototype;return n.clone=function(){return new t(this.x,this.y,this.z,this.w)},n.set=function(e,t,n,i){return e&&"object"==typeof e?(this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w):(this.x=e||0,this.y=t||0,this.z=n||0,this.w=i||0),this},n.equals=function(e,t){return void 0===t&&(t=an),Math.abs(this.x-e.x)<=t*Math.max(1,Math.abs(this.x),Math.abs(e.x))&&Math.abs(this.y-e.y)<=t*Math.max(1,Math.abs(this.y),Math.abs(e.y))&&Math.abs(this.z-e.z)<=t*Math.max(1,Math.abs(this.z),Math.abs(e.z))&&Math.abs(this.w-e.w)<=t*Math.max(1,Math.abs(this.w),Math.abs(e.w))},n.equals4f=function(e,t,n,i,r){return void 0===r&&(r=an),Math.abs(this.x-e)<=r*Math.max(1,Math.abs(this.x),Math.abs(e))&&Math.abs(this.y-t)<=r*Math.max(1,Math.abs(this.y),Math.abs(t))&&Math.abs(this.z-n)<=r*Math.max(1,Math.abs(this.z),Math.abs(n))&&Math.abs(this.w-i)<=r*Math.max(1,Math.abs(this.w),Math.abs(i))},n.strictEquals=function(e){return this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w},n.strictEquals4f=function(e,t,n,i){return this.x===e&&this.y===t&&this.z===n&&this.w===i},n.lerp=function(e,t){var n=this.x,i=this.y,r=this.z,a=this.w;return this.x=n+t*(e.x-n),this.y=i+t*(e.y-i),this.z=r+t*(e.z-r),this.w=a+t*(e.w-a),this},n.toString=function(){return"("+this.x.toFixed(2)+", "+this.y.toFixed(2)+", "+this.z.toFixed(2)+", "+this.w.toFixed(2)+")"},n.clampf=function(e,t){return this.x=cn(this.x,e.x,t.x),this.y=cn(this.y,e.y,t.y),this.z=cn(this.z,e.z,t.z),this.w=cn(this.w,e.w,t.w),this},n.add=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this},n.add4f=function(e,t,n,i){return this.x+=e,this.y+=t,this.z+=n,this.w+=i,this},n.subtract=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this},n.subtract4f=function(e,t,n,i){return this.x-=e,this.y-=t,this.z-=n,this.w-=i,this},n.multiplyScalar=function(e){return"object"==typeof e&&console.warn("should use Vec4.multiply for vector * vector operation"),this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},n.multiply=function(e){return"object"!=typeof e&&console.warn("should use Vec4.scale for vector * scalar operation"),this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this},n.multiply4f=function(e,t,n,i){return this.x*=e,this.y*=t,this.z*=n,this.w*=i,this},n.divide=function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this},n.divide4f=function(e,t,n,i){return this.x/=e,this.y/=t,this.z/=n,this.w/=i,this},n.negative=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},n.dot=function(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w},n.cross=function(e){var t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,s=e.z;return this.x=n*s-i*a,this.y=i*r-t*s,this.z=t*a-n*r,this},n.length=function(){var e=this.x,t=this.y,n=this.z,i=this.w;return Math.sqrt(e*e+t*t+n*n+i*i)},n.lengthSqr=function(){var e=this.x,t=this.y,n=this.z,i=this.w;return e*e+t*t+n*n+i*i},n.normalize=function(){var e=this.x,t=this.y,n=this.z,i=this.w,r=e*e+t*t+n*n+i*i;return r>0&&(r=1/Math.sqrt(r),this.x=e*r,this.y=t*r,this.z=n*r,this.w=i*r),this},n.transformMat4=function(e){var t=this.x,n=this.y,i=this.z,r=this.w;return this.x=e.m00*t+e.m04*n+e.m08*i+e.m12*r,this.y=e.m01*t+e.m05*n+e.m09*i+e.m13*r,this.z=e.m02*t+e.m06*n+e.m10*i+e.m14*r,this.w=e.m03*t+e.m07*n+e.m11*i+e.m15*r,this},t}(_t));function Qn(e,t,n,i){return new Zn(e,t,n,i)}Zn.ZERO=Object.freeze(new Zn(0,0,0,0)),Zn.ONE=Object.freeze(new Zn(1,1,1,1)),Zn.NEG_ONE=Object.freeze(new Zn(-1,-1,-1,-1)),$t.fastDefine("cc.Vec4",Zn,{x:0,y:0,z:0,w:0}),i.Vec4=Zn,i.v4=Qn,se(qn,"Vec2",[{name:"sub",newName:"subtract",target:qn,targetName:"Vec2"},{name:"mul",newName:"multiply",target:qn,targetName:"Vec2"},{name:"div",newName:"divide",target:qn,targetName:"Vec2"},{name:"dist",newName:"distance",target:qn,targetName:"Vec2"},{name:"sqrDist",newName:"squaredDistance",target:qn,targetName:"Vec2"},{name:"mag",newName:"len",target:qn,targetName:"Vec2"},{name:"sqrMag",newName:"lengthSqr",target:qn,targetName:"Vec2"},{name:"scale",newName:"multiplyScalar",target:qn,targetName:"Vec2"},{name:"exactEquals",newName:"strictEquals",target:qn,targetName:"Vec2"}]),se(qn.prototype,"Vec2",[{name:"mag",newName:"length",target:qn.prototype,targetName:"Vec2"},{name:"magSqr",newName:"lengthSqr",target:qn.prototype,targetName:"Vec2"},{name:"scale",newName:"multiplyScalar",target:qn.prototype,targetName:"Vec2"},{name:"exactEquals",newName:"strictEquals",target:qn.prototype,targetName:"Vec2"}]),se(bn,"Vec3",[{name:"sub",newName:"subtract",target:bn,targetName:"Vec3"},{name:"mul",newName:"multiply",target:bn,targetName:"Vec3"},{name:"div",newName:"divide",target:bn,targetName:"Vec3"},{name:"dist",newName:"distance",target:bn,targetName:"Vec3"},{name:"sqrDist",newName:"squaredDistance",target:bn,targetName:"Vec3"},{name:"mag",newName:"len",target:bn,targetName:"Vec3"},{name:"sqrMag",newName:"lengthSqr",target:bn,targetName:"Vec3"},{name:"scale",newName:"multiplyScalar",target:bn,targetName:"Vec3"},{name:"exactEquals",newName:"strictEquals",target:bn,targetName:"Vec3"}]),se(bn.prototype,"Vec3",[{name:"mag",newName:"length",target:bn.prototype,targetName:"Vec3"},{name:"magSqr",newName:"lengthSqr",target:bn.prototype,targetName:"Vec3"},{name:"scale",newName:"multiplyScalar",target:bn.prototype,targetName:"Vec3"},{name:"exactEquals",newName:"strictEquals",target:bn.prototype,targetName:"Vec3"}]),se(Zn,"Vec4",[{name:"sub",newName:"subtract",target:Zn,targetName:"Vec4"},{name:"mul",newName:"multiply",target:Zn,targetName:"Vec4"},{name:"div",newName:"divide",target:Zn,targetName:"Vec4"},{name:"dist",newName:"distance",target:Zn,targetName:"Vec4"},{name:"sqrDist",newName:"squaredDistance",target:Zn,targetName:"Vec4"},{name:"mag",newName:"len",target:Zn,targetName:"Vec4"},{name:"sqrMag",newName:"lengthSqr",target:Zn,targetName:"Vec4"},{name:"scale",newName:"multiplyScalar",target:Zn,targetName:"Vec4"},{name:"exactEquals",newName:"strictEquals",target:Zn,targetName:"Vec4"}]),se(Zn.prototype,"Vec4",[{name:"mag",newName:"length",target:Zn.prototype,targetName:"Vec4"},{name:"magSqr",newName:"lengthSqr",target:Zn.prototype,targetName:"Vec4"},{name:"scale",newName:"multiplyScalar",target:Zn.prototype,targetName:"Vec4"},{name:"exactEquals",newName:"strictEquals",target:Zn.prototype,targetName:"Vec4"}]),se(Dn,"Quat",[{name:"mag",newName:"len",target:Dn,targetName:"Quat"},{name:"mul",newName:"multiply",target:Dn,targetName:"Quat"},{name:"sqrMag",newName:"lengthSqr",target:Dn,targetName:"Quat"},{name:"scale",newName:"multiplyScalar",target:Dn,targetName:"Quat"},{name:"exactEquals",newName:"strictEquals",target:Dn,targetName:"Quat"}]),se(Dn.prototype,"Quat",[{name:"scale",newName:"multiplyScalar",target:Dn.prototype,targetName:"Quat"},{name:"exactEquals",newName:"strictEquals",target:Dn.prototype,targetName:"Quat"}]),se(Cn,"Color",[{name:"sub",newName:"subtract",target:Cn,targetName:"Color"},{name:"mul",newName:"multiply",target:Cn,targetName:"Color"},{name:"div",newName:"divide",target:Cn,targetName:"Color"},{name:"exactEquals",newName:"strictEquals",target:Cn,targetName:"Color"},{name:"fromHex",newName:"fromHEX",customFunction:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=t[1].toString(16);return i.Color.fromHEX(t[0],r)}}]),se(Pn,"Mat3",[{name:"sub",newName:"subtract",target:Pn,targetName:"Mat3"},{name:"mul",newName:"multiply",target:Pn,targetName:"Mat3"},{name:"exactEquals",newName:"strictEquals",target:Pn,targetName:"Mat3"},{name:"transfrom",newName:"transform",target:Pn,targetName:"Mat3"}]),se(Pn.prototype,"Mat3",[{name:"sub",newName:"subtract",target:Pn.prototype,targetName:"Mat3"},{name:"mul",newName:"multiply",target:Pn.prototype,targetName:"Mat3"},{name:"mulScalar",newName:"multiplyScalar",target:Pn.prototype,targetName:"Mat3"},{name:"exactEquals",newName:"strictEquals",target:Pn.prototype,targetName:"Mat3"}]),se(Hn,"Mat4",[{name:"sub",newName:"subtract",target:Hn,targetName:"Mat4"},{name:"mul",newName:"multiply",target:Hn,targetName:"Mat4"},{name:"exactEquals",newName:"strictEquals",target:Hn,targetName:"Mat4"}]),se(Hn.prototype,"Mat4",[{name:"sub",newName:"subtract",target:Hn.prototype,targetName:"Mat4"},{name:"mul",newName:"multiply",target:Hn.prototype,targetName:"Mat4"},{name:"mulScalar",newName:"multiplyScalar",target:Hn.prototype,targetName:"Mat4"},{name:"exactEquals",newName:"strictEquals",target:Hn.prototype,targetName:"Mat4"}]);var Jn=e("AffineTransform",function(){function e(e,t,n,i,r,a){void 0===e&&(e=1),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=1),void 0===r&&(r=0),void 0===a&&(a=0),this.a=e,this.b=t,this.c=n,this.d=i,this.tx=r,this.ty=a}return e.identity=function(){return new e},e.clone=function(t){return new e(t.a,t.b,t.c,t.d,t.tx,t.ty)},e.concat=function(e,t,n){var i=t.a,r=t.b,a=t.c,s=t.d,o=t.tx,c=t.ty;e.a=i*n.a+r*n.c,e.b=i*n.b+r*n.d,e.c=a*n.a+s*n.c,e.d=a*n.b+s*n.d,e.tx=o*n.a+c*n.c+n.tx,e.ty=o*n.b+c*n.d+n.ty},e.invert=function(e,t){var n=1/(t.a*t.d-t.b*t.c);e.a=n*t.d,e.b=-n*t.b,e.c=-n*t.c,e.d=n*t.a,e.tx=n*(t.c*t.ty-t.d*t.tx),e.ty=n*(t.b*t.tx-t.a*t.ty)},e.fromMat4=function(e,t){e.a=t.m00,e.b=t.m01,e.c=t.m04,e.d=t.m05,e.tx=t.m12,e.ty=t.m13},e.transformVec2=function(e,t,n,i){var r,a;void 0===i?(i=n,r=t.x,a=t.y):(r=t,a=n),e.x=i.a*r+i.c*a+i.tx,e.y=i.b*r+i.d*a+i.ty},e.transformSize=function(e,t,n){e.width=n.a*t.width+n.c*t.height,e.height=n.b*t.width+n.d*t.height},e.transformRect=function(e,t,n){var i=t.x+t.width,r=t.y+t.height,a=n.a*t.x+n.c*t.y+n.tx,s=n.b*t.x+n.d*t.y+n.ty,o=n.a*i+n.c*t.y+n.tx,c=n.b*i+n.d*t.y+n.ty,l=n.a*t.x+n.c*r+n.tx,u=n.b*t.x+n.d*r+n.ty,h=n.a*i+n.c*r+n.tx,_=n.b*i+n.d*r+n.ty,f=Math.min(a,o,l,h),d=Math.max(a,o,l,h),p=Math.min(s,c,u,_),m=Math.max(s,c,u,_);e.x=f,e.y=p,e.width=d-f,e.height=m-p},e.transformObb=function(e,t,n,i,r,a){var s=a.a*r.x+a.c*r.y+a.tx,o=a.b*r.x+a.d*r.y+a.ty,c=a.a*r.width,l=a.b*r.width,u=a.c*r.height,h=a.d*r.height;t.x=s,t.y=o,n.x=c+s,n.y=l+o,e.x=u+s,e.y=h+o,i.x=c+u+s,i.y=l+h+o},e}());i.AffineTransform=Jn;var $n=e("Size",function(e){function t(t,n){var i;return i=e.call(this)||this,t&&"object"==typeof t?(i.width=t.width,i.height=t.height):(i.width=t||0,i.height=n||0),i}X(t,e),t.lerp=function(e,t,n,i){return e.width=t.width+(n.width-t.width)*i,e.height=t.height+(n.height-t.height)*i,e},j(t,[{key:"x",set:function(e){this.width=e},get:function(){return this.width}},{key:"y",set:function(e){this.height=e},get:function(){return this.height}}]);var n=t.prototype;return n.clone=function(){return new t(this.width,this.height)},n.set=function(e,t){return e&&"object"==typeof e?(this.height=e.height,this.width=e.width):(this.width=e||0,this.height=t||0),this},n.equals=function(e){return this.width===e.width&&this.height===e.height},n.lerp=function(e,t){return this.width+=(e.width-this.width)*t,this.height+=(e.height-this.height)*t,this},n.toString=function(){return"("+this.width.toFixed(2)+", "+this.height.toFixed(2)+")"},t}(_t));function ei(e,t){return void 0===e&&(e=0),void 0===t&&(t=0),new $n(e,t)}$n.ZERO=Object.freeze(new $n(0,0)),$n.ONE=Object.freeze(new $n(1,1)),$t.fastDefine("cc.Size",$n,{width:0,height:0}),i.size=ei,i.Size=$n;var ti=e("Rect",function(e){function t(t,n,i,r){var a;return(a=e.call(this)||this).T=void 0,t&&"object"==typeof t?(a.y=t.y,a.width=t.width,a.height=t.height,a.x=t.x):(a.x=t||0,a.y=n||0,a.width=i||0,a.height=r||0),a}X(t,e),t.fromMinMax=function(e,t,n){var i=Math.min(t.x,n.x),r=Math.min(t.y,n.y),a=Math.max(t.x,n.x),s=Math.max(t.y,n.y);return e.x=i,e.y=r,e.width=a-i,e.height=s-r,e},t.lerp=function(e,t,n,i){var r=t.x,a=t.y,s=t.width,o=t.height;return e.x=r+(n.x-r)*i,e.y=a+(n.y-a)*i,e.width=s+(n.width-s)*i,e.height=o+(n.height-o)*i,e},t.intersection=function(e,t,n){var i=t.x,r=t.y,a=t.x+t.width,s=t.y+t.height,o=n.x,c=n.y,l=n.x+n.width,u=n.y+n.height;return e.x=Math.max(i,o),e.y=Math.max(r,c),e.width=Math.min(a,l)-e.x,e.height=Math.min(s,u)-e.y,e},t.union=function(e,t,n){var i=t.x,r=t.y,a=t.width,s=t.height,o=n.x,c=n.y,l=n.width,u=n.height;return e.x=Math.min(i,o),e.y=Math.min(r,c),e.width=Math.max(i+a,o+l)-e.x,e.height=Math.max(r+s,c+u)-e.y,e},j(t,[{key:"xMin",get:function(){return this.x},set:function(e){this.width+=this.x-e,this.x=e}},{key:"yMin",get:function(){return this.y},set:function(e){this.height+=this.y-e,this.y=e}},{key:"xMax",get:function(){return this.x+this.width},set:function(e){this.width=e-this.x}},{key:"yMax",get:function(){return this.y+this.height},set:function(e){this.height=e-this.y}},{key:"center",get:function(){return new qn(this.x+.5*this.width,this.y+.5*this.height)},set:function(e){this.x=e.x-.5*this.width,this.y=e.y-.5*this.height}},{key:"origin",get:function(){return new qn(this.x,this.y)},set:function(e){this.x=e.x,this.y=e.y}},{key:"size",get:function(){return new $n(this.width,this.height)},set:function(e){this.width=e.width,this.height=e.height}},{key:"z",set:function(e){this.width=e},get:function(){return this.width}},{key:"w",set:function(e){this.height=e},get:function(){return this.height}}]);var n=t.prototype;return n.clone=function(){return new t(this.x,this.y,this.width,this.height)},n.set=function(e,t,n,i){return e&&"object"==typeof e?(this.y=e.y,this.width=e.width,this.height=e.height,this.x=e.x):(this.x=e||0,this.y=t||0,this.width=n||0,this.height=i||0),this},n.equals=function(e){return this.x===e.x&&this.y===e.y&&this.width===e.width&&this.height===e.height},n.lerp=function(e,t){var n=this.x,i=this.y,r=this.width,a=this.height;return this.x=n+(e.x-n)*t,this.y=i+(e.y-i)*t,this.width=r+(e.width-r)*t,this.height=a+(e.height-a)*t,this},n.toString=function(){return"("+this.x.toFixed(2)+", "+this.y.toFixed(2)+", "+this.width.toFixed(2)+", "+this.height.toFixed(2)+")"},n.intersects=function(e){var t=this.x+this.width,n=this.y+this.height,i=e.x+e.width,r=e.y+e.height;return!(t<e.x||i<this.x||n<e.y||r<this.y)},n.contains=function(e){return this.x<=e.x&&this.x+this.width>=e.x&&this.y<=e.y&&this.y+this.height>=e.y},n.containsRect=function(e){return this.x<=e.x&&this.x+this.width>=e.x+e.width&&this.y<=e.y&&this.y+this.height>=e.y+e.height},n.transformMat4=function(e){var t=this.x,n=this.y,i=t+this.width,r=n+this.height,a=e.m00*t+e.m04*n+e.m12,s=e.m01*t+e.m05*n+e.m13,o=e.m00*i+e.m04*n+e.m12,c=e.m01*i+e.m05*n+e.m13,l=e.m00*t+e.m04*r+e.m12,u=e.m01*t+e.m05*r+e.m13,h=e.m00*i+e.m04*r+e.m12,_=e.m01*i+e.m05*r+e.m13,f=Math.min(a,o,l,h),d=Math.max(a,o,l,h),p=Math.min(s,c,u,_),m=Math.max(s,c,u,_);return this.x=f,this.y=p,this.width=d-f,this.height=m-p,this},n.transformMat4ToPoints=function(e,t,n,i,r){var a=this.x,s=this.y,o=a+this.width,c=s+this.height;t.x=e.m00*a+e.m04*s+e.m12,t.y=e.m01*a+e.m05*s+e.m13,r.x=e.m00*o+e.m04*s+e.m12,r.y=e.m01*o+e.m05*s+e.m13,n.x=e.m00*a+e.m04*c+e.m12,n.y=e.m01*a+e.m05*c+e.m13,i.x=e.m00*o+e.m04*c+e.m12,i.y=e.m01*o+e.m05*c+e.m13},t}(_t));function ni(e,t,n,i){return void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),new ti(e,t,n,i)}$t.fastDefine("cc.Rect",ti,{x:0,y:0,width:0,height:0}),i.Rect=ti,i.rect=ni;var ii=Object.freeze({__proto__:null,bits:ae,Vec2:qn,v2:Kn,Vec3:bn,v3:On,Vec4:Zn,v4:Qn,Quat:Dn,quat:Gn,Mat3:Pn,Mat4:Hn,mat4:jn,AffineTransform:Jn,Size:$n,size:ei,Rect:ti,rect:ni,Color:Cn,color:Rn,EPSILON:an,equals:sn,approx:on,clamp:cn,clamp01:ln,lerp:un,toRadian:hn,toDegree:_n,random:fn,randomRange:dn,randomRangeInt:pn,pseudoRandom:mn,pseudoRandomRange:gn,pseudoRandomRangeInt:vn,nextPow2:yn,repeat:Sn,pingPong:En,inverseLerp:Tn,absMaxComponent:An,absMax:xn});e("math",ii);var ri,ai,si,oi,ci,li,ui,hi,_i,fi,di,pi,mi,gi,vi,yi,Si,Ei,Ti,Ai,xi,Ci,Ri,bi,wi=function(){function e(e,t,n){this._arrayBuffers=[],this._chunkSize=void 0,this._chunkSize=n*(1<<t)}return e.prototype.allocateNewChunk=function(){return new ArrayBuffer(this._chunkSize)},e}(),Ii=function(){},Oi=function(){function e(){}var t=e.prototype;return t.alloc=function(e,t){return new ArrayBuffer(t)},t.free=function(){},e}();!function(e){e[e.UINT32=0]="UINT32",e[e.FLOAT32=1]="FLOAT32",e[e.NEVER=2]="NEVER"}(bi||(bi={}));var Pi,Mi=function(){function e(e,t,n,i){void 0===i&&(i=8),this._dataType=void 0,this._elementCount=void 0,this._entryBits=void 0,this._stride=void 0,this._entriesPerChunk=void 0,this._entryMask=void 0,this._chunkMask=void 0,this._poolFlag=void 0,this._arrayBuffers=[],this._freelists=[],this._uint32BufferViews=[],this._float32BufferViews=[],this._hasUint32=!1,this._hasFloat32=!1,this._nativePool=void 0,this._elementCount=n.COUNT,this._entryBits=i,this._dataType=t,this._stride=4*this._elementCount,this._entriesPerChunk=1<<i,this._entryMask=this._entriesPerChunk-1,this._poolFlag=1<<30,this._chunkMask=~(this._entryMask|this._poolFlag),this._nativePool=new wi(e,i,this._stride);var r=bi.NEVER,a=!1,s=!1;for(var o in t){if(a=this._hasFloat32,(s=this._hasUint32)&&a)break;r=t[o],a||r!==bi.FLOAT32?s||r!==bi.UINT32||(this._hasUint32=!0):this._hasFloat32=!0}}var t=e.prototype;return t.alloc=function(){for(var e=0;e<this._freelists.length;e++){var t=this._freelists[e];if(t.length){var n=t[t.length-1];return t.length--,(e<<this._entryBits)+n+this._poolFlag}}for(var i=this._nativePool.allocateNewChunk(),r=[],a=[],s=[],o=this._hasFloat32,c=this._hasUint32,l=0;l<this._entriesPerChunk;l++)o&&r.push(new Float32Array(i,this._stride*l,this._elementCount)),c&&a.push(new Uint32Array(i,this._stride*l,this._elementCount)),l&&s.push(l);return this._arrayBuffers.push(i),c&&this._uint32BufferViews.push(a),o&&this._float32BufferViews.push(r),this._freelists.push(s),(e<<this._entryBits)+this._poolFlag},t.get=function(e,t){var n=(this._chunkMask&e)>>this._entryBits,i=this._entryMask&e;return(this._dataType[t]===bi.UINT32?this._uint32BufferViews:this._float32BufferViews)[n][i][t]},t.set=function(e,t,n){var i=(this._chunkMask&e)>>this._entryBits,r=this._entryMask&e;(this._dataType[t]===bi.UINT32?this._uint32BufferViews:this._float32BufferViews)[i][r][t]=n},t.setVec2=function(){},t.setVec3=function(){},t.setVec4=function(){},t.setMat4=function(){},t.free=function(e){var t=(this._chunkMask&e)>>this._entryBits,n=this._entryMask&e;(this._hasUint32?this._uint32BufferViews:this._float32BufferViews)[t][n].fill(0),this._freelists[t].push(n)},e}(),Ni=function(){function e(e,t,n){this._ctor=void 0,this._dtor=void 0,this._indexMask=void 0,this._poolFlag=void 0,this._array=[],this._freelist=[],this._nativePool=void 0,this._ctor=t,n&&(this._dtor=n),this._poolFlag=1<<29,this._indexMask=~this._poolFlag,this._nativePool=new Ii(e,this._array)}var t=e.prototype;return t.alloc=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var i=this._freelist,r=-1;if(i.length)r=i[i.length-1],i.length--,this._array[r]=this._ctor(arguments,this._array[r]);else{r=this._array.length;var a=this._ctor(arguments);if(!a)return 0;this._array.push(a)}return r+this._poolFlag},t.get=function(e){var t=this._indexMask&e;return this._array[t]},t.free=function(e){var t=this._indexMask&e;this._dtor&&(this._array[t]=this._dtor(this._array[t])),this._freelist.push(t)},e}(),Di=function(){function e(e){this._nativeBufferAllocator=void 0,this._buffers=new Map,this._nextBufferIdx=0,this._poolFlag=void 0,this._bufferIdxMask=void 0,this._poolFlag=1<<30,this._bufferIdxMask=~this._poolFlag,this._nativeBufferAllocator=new Oi(e)}var t=e.prototype;return t.alloc=function(e){var t=this._nextBufferIdx++,n=this._nativeBufferAllocator.alloc(t,e);return this._buffers.set(t,n),t|this._poolFlag},t.free=function(e){var t=this._bufferIdxMask&e;this._buffers.get(t)&&(this._nativeBufferAllocator.free(t),this._buffers.delete(t))},t.getBuffer=function(e){var t=this._bufferIdxMask&e;return this._buffers.get(t)||null},e}(),Bi=function(e){function t(t,n,i,r){var a;return(a=e.call(this,t)||this)._viewCtor=void 0,a._size=void 0,a._step=void 0,a._viewCtor=n,a._size=i*n.BYTES_PER_ELEMENT,a._step=r||i,a}X(t,e);var n=t.prototype;return n.alloc=function(){var e=this._nextBufferIdx++,t=this._nativeBufferAllocator.alloc(e,this._size);return this._buffers.set(e,new this._viewCtor(t)),e|this._poolFlag},n.getBuffer=function(){return null},n.assign=function(e,t,n){var i=this._bufferIdxMask&e,r=this._buffers.get(i);if(r){var a=t+1;if(a>=r.length){for(var s=r.length;a>=s;)s+=this._step;s*=this._viewCtor.BYTES_PER_ELEMENT;var o=new this._viewCtor(this._nativeBufferAllocator.alloc(i,s));o.set(r),r=o,this._buffers.set(i,r)}r[a]=n;var c=r[0];r[0]=a>c?a:c}},n.erase=function(e,t){var n=this._bufferIdxMask&e,i=this._buffers.get(n);if(i&&!(t>=i[0])){for(var r=t+1;r<i[0];++r)i[r]=i[r+1];--i[0]}},n.push=function(e,t){var n=this._bufferIdxMask&e,i=this._buffers.get(n);i&&this.assign(e,i[0],t)},n.pop=function(e){var t=this._bufferIdxMask&e,n=this._buffers.get(t);n&&0!==n[0]&&--n[0]},n.clear=function(e){var t=this._bufferIdxMask&e,n=this._buffers.get(t);n&&(n[0]=0)},n.get=function(e,t){var n=this._bufferIdxMask&e,i=this._buffers.get(n);return!i||t>=i[0]?0:i[t+1]},n.length=function(e){var t=this._bufferIdxMask&e,n=this._buffers.get(t);return n?n[0]:0},t}(Di);function Li(e,t,n,i){void 0===i&&(i=!0);for(var r=t.length(e),a=0;a<r;a++){var s=t.get(e,a);s&&n.free(s)}i?t.free(e):t.clear(e)}!function(e){e[e.ATTRIBUTE=0]="ATTRIBUTE",e[e.DESCRIPTOR_SETS=1]="DESCRIPTOR_SETS",e[e.SHADER=2]="SHADER",e[e.INPUT_ASSEMBLER=3]="INPUT_ASSEMBLER",e[e.PIPELINE_LAYOUT=4]="PIPELINE_LAYOUT",e[e.FRAMEBUFFER=5]="FRAMEBUFFER",e[e.PASS=100]="PASS",e[e.SUB_MODEL=101]="SUB_MODEL",e[e.MODEL=102]="MODEL",e[e.SCENE=103]="SCENE",e[e.CAMERA=104]="CAMERA",e[e.NODE=105]="NODE",e[e.ROOT=106]="ROOT",e[e.AABB=107]="AABB",e[e.RENDER_WINDOW=108]="RENDER_WINDOW",e[e.FRUSTUM=109]="FRUSTUM",e[e.AMBIENT=110]="AMBIENT",e[e.FOG=111]="FOG",e[e.SKYBOX=112]="SKYBOX",e[e.SHADOW=113]="SHADOW",e[e.LIGHT=114]="LIGHT",e[e.SPHERE=115]="SPHERE",e[e.INSTANCED_ATTRIBUTE=116]="INSTANCED_ATTRIBUTE",e[e.FLAT_BUFFER=117]="FLAT_BUFFER",e[e.SUB_MESH=118]="SUB_MESH",e[e.RASTERIZER_STATE=119]="RASTERIZER_STATE",e[e.DEPTH_STENCIL_STATE=120]="DEPTH_STENCIL_STATE",e[e.BLEND_TARGET=121]="BLEND_TARGET",e[e.BLEND_STATE=122]="BLEND_STATE",e[e.BATCH_2D=123]="BATCH_2D",e[e.SUB_MODEL_ARRAY=200]="SUB_MODEL_ARRAY",e[e.MODEL_ARRAY=201]="MODEL_ARRAY",e[e.ATTRIBUTE_ARRAY=202]="ATTRIBUTE_ARRAY",e[e.FLAT_BUFFER_ARRAY=203]="FLAT_BUFFER_ARRAY",e[e.INSTANCED_BUFFER_ARRAY=204]="INSTANCED_BUFFER_ARRAY",e[e.LIGHT_ARRAY=205]="LIGHT_ARRAY",e[e.BLEND_TARGET_ARRAY=206]="BLEND_TARGET_ARRAY",e[e.BATCH_ARRAY_2D=207]="BATCH_ARRAY_2D",e[e.RAW_BUFFER=300]="RAW_BUFFER",e[e.RAW_OBJECT=400]="RAW_OBJECT"}(Pi||(Pi={}));var Fi,zi=new Ni(Pi.SHADER,(function(e,t){return t?(t.initialize(e[1]),t):e[0].createShader(e[1])}),(function(e){return e&&e.destroy(),e})),Ui=new Ni(Pi.DESCRIPTOR_SETS,(function(e,t){return t?(t.initialize(e[1]),t):e[0].createDescriptorSet(e[1])}),(function(e){return e&&e.destroy(),e})),Gi=new Ni(Pi.INPUT_ASSEMBLER,(function(e,t){return t?(t.initialize(e[1]),t):e[0].createInputAssembler(e[1])}),(function(e){return e&&e.destroy(),e})),ki=new Ni(Pi.PIPELINE_LAYOUT,(function(e,t){return t?(t.initialize(e[1]),t):e[0].createPipelineLayout(e[1])}),(function(e){return e&&e.destroy(),e})),Hi=new Ni(Pi.FRAMEBUFFER,(function(e,t){return t?(t.initialize(e[1]),t):e[0].createFramebuffer(e[1])}),(function(e){return e&&e.destroy(),e})),Vi=new Bi(Pi.SUB_MODEL_ARRAY,Uint32Array,8,4),Wi=new Bi(Pi.MODEL_ARRAY,Uint32Array,32,16),ji=new Bi(Pi.ATTRIBUTE_ARRAY,Uint32Array,8,4),qi=new Bi(Pi.FLAT_BUFFER_ARRAY,Uint32Array,8,4),Xi=new Bi(Pi.LIGHT_ARRAY,Uint32Array,8,4),Yi=new Bi(Pi.BLEND_TARGET_ARRAY,Uint32Array,8,4),Ki=new Bi(Pi.BATCH_ARRAY_2D,Uint32Array,32,16),Zi=new Di(Pi.RAW_BUFFER),Qi=new Ni(Pi.RAW_OBJECT,(function(e){return e[0]||{}}),(function(){}));!function(e){e[e.PRIORITY=0]="PRIORITY",e[e.STAGE=1]="STAGE",e[e.PHASE=2]="PHASE",e[e.BATCHING_SCHEME=3]="BATCHING_SCHEME",e[e.PRIMITIVE=4]="PRIMITIVE",e[e.DYNAMIC_STATES=5]="DYNAMIC_STATES",e[e.HASH=6]="HASH",e[e.RASTERIZER_STATE=7]="RASTERIZER_STATE",e[e.DEPTH_STENCIL_STATE=8]="DEPTH_STENCIL_STATE",e[e.BLEND_STATE=9]="BLEND_STATE",e[e.DESCRIPTOR_SET=10]="DESCRIPTOR_SET",e[e.PIPELINE_LAYOUT=11]="PIPELINE_LAYOUT",e[e.COUNT=12]="COUNT"}(Fi||(Fi={}));var Ji,$i=((ri={})[Fi.PRIORITY]=bi.UINT32,ri[Fi.STAGE]=bi.UINT32,ri[Fi.PHASE]=bi.UINT32,ri[Fi.BATCHING_SCHEME]=bi.UINT32,ri[Fi.PRIMITIVE]=bi.UINT32,ri[Fi.DYNAMIC_STATES]=bi.UINT32,ri[Fi.HASH]=bi.UINT32,ri[Fi.RASTERIZER_STATE]=bi.UINT32,ri[Fi.DEPTH_STENCIL_STATE]=bi.UINT32,ri[Fi.BLEND_STATE]=bi.UINT32,ri[Fi.DESCRIPTOR_SET]=bi.UINT32,ri[Fi.PIPELINE_LAYOUT]=bi.UINT32,ri[Fi.COUNT]=bi.NEVER,ri),er=new Mi(Pi.PASS,$i,Fi);!function(e){e[e.PRIORITY=0]="PRIORITY",e[e.PASS_COUNT=1]="PASS_COUNT",e[e.PASS_0=2]="PASS_0",e[e.PASS_1=3]="PASS_1",e[e.PASS_2=4]="PASS_2",e[e.PASS_3=5]="PASS_3",e[e.SHADER_0=6]="SHADER_0",e[e.SHADER_1=7]="SHADER_1",e[e.SHADER_2=8]="SHADER_2",e[e.SHADER_3=9]="SHADER_3",e[e.PLANAR_SHADER=10]="PLANAR_SHADER",e[e.DESCRIPTOR_SET=11]="DESCRIPTOR_SET",e[e.INPUT_ASSEMBLER=12]="INPUT_ASSEMBLER",e[e.SUB_MESH=13]="SUB_MESH",e[e.COUNT=14]="COUNT"}(Ji||(Ji={}));var tr,nr=((ai={})[Ji.PRIORITY]=bi.UINT32,ai[Ji.PASS_COUNT]=bi.UINT32,ai[Ji.PASS_0]=bi.UINT32,ai[Ji.PASS_1]=bi.UINT32,ai[Ji.PASS_2]=bi.UINT32,ai[Ji.PASS_3]=bi.UINT32,ai[Ji.SHADER_0]=bi.UINT32,ai[Ji.SHADER_1]=bi.UINT32,ai[Ji.SHADER_2]=bi.UINT32,ai[Ji.SHADER_3]=bi.UINT32,ai[Ji.PLANAR_SHADER]=bi.UINT32,ai[Ji.DESCRIPTOR_SET]=bi.UINT32,ai[Ji.INPUT_ASSEMBLER]=bi.UINT32,ai[Ji.SUB_MESH]=bi.UINT32,ai[Ji.COUNT]=bi.NEVER,ai),ir=new Mi(Pi.SUB_MODEL,nr,Ji);!function(e){e[e.ENABLED=0]="ENABLED",e[e.VIS_FLAGS=1]="VIS_FLAGS",e[e.CAST_SHADOW=2]="CAST_SHADOW",e[e.RECEIVE_SHADOW=3]="RECEIVE_SHADOW",e[e.WORLD_BOUNDS=4]="WORLD_BOUNDS",e[e.NODE=5]="NODE",e[e.TRANSFORM=6]="TRANSFORM",e[e.SUB_MODEL_ARRAY=7]="SUB_MODEL_ARRAY",e[e.INSTANCED_BUFFER=8]="INSTANCED_BUFFER",e[e.INSTANCED_ATTR_ARRAY=9]="INSTANCED_ATTR_ARRAY",e[e.COUNT=10]="COUNT"}(tr||(tr={}));var rr,ar=((si={})[tr.ENABLED]=bi.UINT32,si[tr.VIS_FLAGS]=bi.UINT32,si[tr.CAST_SHADOW]=bi.UINT32,si[tr.RECEIVE_SHADOW]=bi.UINT32,si[tr.WORLD_BOUNDS]=bi.UINT32,si[tr.NODE]=bi.UINT32,si[tr.TRANSFORM]=bi.UINT32,si[tr.SUB_MODEL_ARRAY]=bi.UINT32,si[tr.INSTANCED_BUFFER]=bi.UINT32,si[tr.INSTANCED_ATTR_ARRAY]=bi.UINT32,si[tr.COUNT]=bi.NEVER,si),sr=new Mi(Pi.MODEL,ar,tr);!function(e){e[e.VIS_FLAGS=0]="VIS_FLAGS",e[e.PASS_COUNT=1]="PASS_COUNT",e[e.PASS_0=2]="PASS_0",e[e.PASS_1=3]="PASS_1",e[e.PASS_2=4]="PASS_2",e[e.PASS_3=5]="PASS_3",e[e.SHADER_0=6]="SHADER_0",e[e.SHADER_1=7]="SHADER_1",e[e.SHADER_2=8]="SHADER_2",e[e.SHADER_3=9]="SHADER_3",e[e.DESCRIPTOR_SET=10]="DESCRIPTOR_SET",e[e.INPUT_ASSEMBLER=11]="INPUT_ASSEMBLER",e[e.COUNT=12]="COUNT"}(rr||(rr={}));var or,cr=((oi={})[rr.VIS_FLAGS]=bi.UINT32,oi[rr.PASS_COUNT]=bi.UINT32,oi[rr.PASS_0]=bi.UINT32,oi[rr.PASS_1]=bi.UINT32,oi[rr.PASS_2]=bi.UINT32,oi[rr.PASS_3]=bi.UINT32,oi[rr.SHADER_0]=bi.UINT32,oi[rr.SHADER_1]=bi.UINT32,oi[rr.SHADER_2]=bi.UINT32,oi[rr.SHADER_3]=bi.UINT32,oi[rr.DESCRIPTOR_SET]=bi.UINT32,oi[rr.INPUT_ASSEMBLER]=bi.UINT32,oi[rr.COUNT]=bi.NEVER,oi),lr=new Mi(Pi.BATCH_2D,cr,rr);!function(e){e[e.CENTER=0]="CENTER",e[e.HALF_EXTENSION=3]="HALF_EXTENSION",e[e.COUNT=6]="COUNT"}(or||(or={}));var ur,hr=((ci={})[or.CENTER]=bi.FLOAT32,ci[or.HALF_EXTENSION]=bi.FLOAT32,ci[or.COUNT]=bi.NEVER,ci),_r=new Mi(Pi.AABB,hr,or);!function(e){e[e.MAIN_LIGHT=0]="MAIN_LIGHT",e[e.MODEL_ARRAY=1]="MODEL_ARRAY",e[e.SPHERE_LIGHT_ARRAY=2]="SPHERE_LIGHT_ARRAY",e[e.SPOT_LIGHT_ARRAY=3]="SPOT_LIGHT_ARRAY",e[e.BATCH_ARRAY_2D=4]="BATCH_ARRAY_2D",e[e.COUNT=5]="COUNT"}(ur||(ur={}));var fr,dr=((li={})[ur.MAIN_LIGHT]=bi.UINT32,li[ur.MODEL_ARRAY]=bi.UINT32,li[ur.SPHERE_LIGHT_ARRAY]=bi.UINT32,li[ur.SPOT_LIGHT_ARRAY]=bi.UINT32,li[ur.BATCH_ARRAY_2D]=bi.UINT32,li[ur.COUNT]=bi.NEVER,li),pr=new Mi(Pi.SCENE,dr,ur);!function(e){e[e.WIDTH=0]="WIDTH",e[e.HEIGHT=1]="HEIGHT",e[e.EXPOSURE=2]="EXPOSURE",e[e.CLEAR_FLAG=3]="CLEAR_FLAG",e[e.CLEAR_DEPTH=4]="CLEAR_DEPTH",e[e.CLEAR_STENCIL=5]="CLEAR_STENCIL",e[e.VISIBILITY=6]="VISIBILITY",e[e.NODE=7]="NODE",e[e.SCENE=8]="SCENE",e[e.FRUSTUM=9]="FRUSTUM",e[e.WINDOW=10]="WINDOW",e[e.FORWARD=11]="FORWARD",e[e.POSITION=14]="POSITION",e[e.VIEW_PORT=17]="VIEW_PORT",e[e.CLEAR_COLOR=21]="CLEAR_COLOR",e[e.MAT_VIEW=25]="MAT_VIEW",e[e.MAT_VIEW_PROJ=41]="MAT_VIEW_PROJ",e[e.MAT_VIEW_PROJ_INV=57]="MAT_VIEW_PROJ_INV",e[e.MAT_PROJ=73]="MAT_PROJ",e[e.MAT_PROJ_INV=89]="MAT_PROJ_INV",e[e.COUNT=105]="COUNT"}(fr||(fr={}));var mr,gr=((ui={})[fr.WIDTH]=bi.UINT32,ui[fr.HEIGHT]=bi.UINT32,ui[fr.EXPOSURE]=bi.FLOAT32,ui[fr.CLEAR_FLAG]=bi.UINT32,ui[fr.CLEAR_DEPTH]=bi.FLOAT32,ui[fr.CLEAR_STENCIL]=bi.UINT32,ui[fr.VISIBILITY]=bi.UINT32,ui[fr.NODE]=bi.UINT32,ui[fr.SCENE]=bi.UINT32,ui[fr.FRUSTUM]=bi.UINT32,ui[fr.WINDOW]=bi.UINT32,ui[fr.FORWARD]=bi.FLOAT32,ui[fr.POSITION]=bi.FLOAT32,ui[fr.VIEW_PORT]=bi.FLOAT32,ui[fr.CLEAR_COLOR]=bi.FLOAT32,ui[fr.MAT_VIEW]=bi.FLOAT32,ui[fr.MAT_VIEW_PROJ]=bi.FLOAT32,ui[fr.MAT_VIEW_PROJ_INV]=bi.FLOAT32,ui[fr.MAT_PROJ]=bi.FLOAT32,ui[fr.MAT_PROJ_INV]=bi.FLOAT32,ui[fr.COUNT]=bi.NEVER,ui),vr=new Mi(Pi.CAMERA,gr,fr);!function(e){e[e.FLAGS_CHANGED=0]="FLAGS_CHANGED",e[e.LAYER=1]="LAYER",e[e.WORLD_SCALE=2]="WORLD_SCALE",e[e.WORLD_POSITION=5]="WORLD_POSITION",e[e.WORLD_ROTATION=8]="WORLD_ROTATION",e[e.WORLD_MATRIX=12]="WORLD_MATRIX",e[e.COUNT=28]="COUNT"}(mr||(mr={}));var yr=((hi={})[mr.FLAGS_CHANGED]=bi.UINT32,hi[mr.LAYER]=bi.UINT32,hi[mr.WORLD_SCALE]=bi.FLOAT32,hi[mr.WORLD_POSITION]=bi.FLOAT32,hi[mr.WORLD_ROTATION]=bi.FLOAT32,hi[mr.WORLD_MATRIX]=bi.FLOAT32,hi[mr.COUNT]=bi.NEVER,hi);delete mr[mr.COUNT],mr[mr.COUNT=mr.LAYER+1]="COUNT";var Sr,Er=new Mi(Pi.NODE,yr,mr);!function(e){e[e.CUMULATIVE_TIME=0]="CUMULATIVE_TIME",e[e.FRAME_TIME=1]="FRAME_TIME",e[e.COUNT=2]="COUNT"}(Sr||(Sr={}));var Tr,Ar=((_i={})[Sr.CUMULATIVE_TIME]=bi.FLOAT32,_i[Sr.FRAME_TIME]=bi.FLOAT32,_i[Sr.COUNT]=bi.NEVER,_i),xr=new Mi(Pi.ROOT,Ar,Sr,1);!function(e){e[e.HAS_ON_SCREEN_ATTACHMENTS=0]="HAS_ON_SCREEN_ATTACHMENTS",e[e.HAS_OFF_SCREEN_ATTACHMENTS=1]="HAS_OFF_SCREEN_ATTACHMENTS",e[e.FRAMEBUFFER=2]="FRAMEBUFFER",e[e.COUNT=3]="COUNT"}(Tr||(Tr={}));var Cr,Rr=((fi={})[Tr.HAS_ON_SCREEN_ATTACHMENTS]=bi.UINT32,fi[Tr.HAS_OFF_SCREEN_ATTACHMENTS]=bi.UINT32,fi[Tr.FRAMEBUFFER]=bi.UINT32,fi[Tr.COUNT]=bi.NEVER,fi),br=new Mi(Pi.RENDER_WINDOW,Rr,Tr,2);!function(e){e[e.VERTICES=0]="VERTICES",e[e.PLANES=24]="PLANES",e[e.COUNT=48]="COUNT"}(Cr||(Cr={}));var wr,Ir=((di={})[Cr.VERTICES]=bi.FLOAT32,di[Cr.PLANES]=bi.FLOAT32,di[Cr.COUNT]=bi.NEVER,di),Or=new Mi(Pi.FRUSTUM,Ir,Cr);!function(e){e[e.ENABLE=0]="ENABLE",e[e.ILLUM=1]="ILLUM",e[e.SKY_COLOR=2]="SKY_COLOR",e[e.GROUND_ALBEDO=6]="GROUND_ALBEDO",e[e.COUNT=10]="COUNT"}(wr||(wr={}));var Pr=((pi={})[wr.ENABLE]=bi.UINT32,pi[wr.ILLUM]=bi.FLOAT32,pi[wr.SKY_COLOR]=bi.FLOAT32,pi[wr.GROUND_ALBEDO]=bi.FLOAT32,pi[wr.COUNT]=bi.NEVER,pi);delete wr[wr.COUNT],wr[wr.COUNT=wr.ILLUM+1]="COUNT";var Mr,Nr=new Mi(Pi.AMBIENT,Pr,wr,1);!function(e){e[e.ENABLE=0]="ENABLE",e[e.IS_RGBE=1]="IS_RGBE",e[e.USE_IBL=2]="USE_IBL",e[e.MODEL=3]="MODEL",e[e.COUNT=4]="COUNT"}(Mr||(Mr={}));var Dr,Br=((mi={})[Mr.ENABLE]=bi.UINT32,mi[Mr.IS_RGBE]=bi.UINT32,mi[Mr.USE_IBL]=bi.UINT32,mi[Mr.MODEL]=bi.UINT32,mi[Mr.COUNT]=bi.NEVER,mi),Lr=new Mi(Pi.SKYBOX,Br,Mr,1);!function(e){e[e.ENABLE=0]="ENABLE",e[e.TYPE=1]="TYPE",e[e.DENSITY=2]="DENSITY",e[e.START=3]="START",e[e.END=4]="END",e[e.ATTEN=5]="ATTEN",e[e.TOP=6]="TOP",e[e.RANGE=7]="RANGE",e[e.COLOR=8]="COLOR",e[e.COUNT=12]="COUNT"}(Dr||(Dr={}));var Fr=((gi={})[Dr.ENABLE]=bi.UINT32,gi[Dr.TYPE]=bi.UINT32,gi[Dr.DENSITY]=bi.FLOAT32,gi[Dr.START]=bi.FLOAT32,gi[Dr.END]=bi.FLOAT32,gi[Dr.ATTEN]=bi.FLOAT32,gi[Dr.TOP]=bi.FLOAT32,gi[Dr.RANGE]=bi.FLOAT32,gi[Dr.COLOR]=bi.FLOAT32,gi[Dr.COUNT]=bi.NEVER,gi);delete Dr[Dr.COUNT],Dr[Dr.COUNT=Dr.RANGE+1]="COUNT";var zr,Ur=new Mi(Pi.FOG,Fr,Dr);!function(e){e[e.ENABLE=0]="ENABLE",e[e.DIRTY=1]="DIRTY",e[e.TYPE=2]="TYPE",e[e.DISTANCE=3]="DISTANCE",e[e.INSTANCE_PASS=4]="INSTANCE_PASS",e[e.PLANAR_PASS=5]="PLANAR_PASS",e[e.NEAR=6]="NEAR",e[e.FAR=7]="FAR",e[e.ASPECT=8]="ASPECT",e[e.PCF_TYPE=9]="PCF_TYPE",e[e.SHADOW_MAP_DIRTY=10]="SHADOW_MAP_DIRTY",e[e.BIAS=11]="BIAS",e[e.ORTHO_SIZE=12]="ORTHO_SIZE",e[e.AUTO_ADAPT=13]="AUTO_ADAPT",e[e.COLOR=14]="COLOR",e[e.SIZE=18]="SIZE",e[e.NORMAL=20]="NORMAL",e[e.MAT_LIGHT=23]="MAT_LIGHT",e[e.COUNT=39]="COUNT"}(zr||(zr={}));var Gr=((vi={})[zr.ENABLE]=bi.UINT32,vi[zr.DIRTY]=bi.UINT32,vi[zr.TYPE]=bi.UINT32,vi[zr.DISTANCE]=bi.FLOAT32,vi[zr.INSTANCE_PASS]=bi.UINT32,vi[zr.PLANAR_PASS]=bi.UINT32,vi[zr.NEAR]=bi.FLOAT32,vi[zr.FAR]=bi.FLOAT32,vi[zr.ASPECT]=bi.FLOAT32,vi[zr.PCF_TYPE]=bi.UINT32,vi[zr.SHADOW_MAP_DIRTY]=bi.UINT32,vi[zr.BIAS]=bi.FLOAT32,vi[zr.ORTHO_SIZE]=bi.FLOAT32,vi[zr.AUTO_ADAPT]=bi.UINT32,vi[zr.COLOR]=bi.FLOAT32,vi[zr.SIZE]=bi.FLOAT32,vi[zr.NORMAL]=bi.FLOAT32,vi[zr.MAT_LIGHT]=bi.FLOAT32,vi[zr.COUNT]=bi.NEVER,vi);delete zr[zr.COUNT],zr[zr.COUNT=zr.AUTO_ADAPT+1]="COUNT";var kr,Hr=new Mi(Pi.SHADOW,Gr,zr,1);!function(e){e[e.USE_COLOR_TEMPERATURE=0]="USE_COLOR_TEMPERATURE",e[e.ILLUMINANCE=1]="ILLUMINANCE",e[e.NODE=2]="NODE",e[e.RANGE=3]="RANGE",e[e.TYPE=4]="TYPE",e[e.AABB=5]="AABB",e[e.FRUSTUM=6]="FRUSTUM",e[e.SIZE=7]="SIZE",e[e.SPOT_ANGLE=8]="SPOT_ANGLE",e[e.ASPECT=9]="ASPECT",e[e.DIRECTION=10]="DIRECTION",e[e.COLOR=13]="COLOR",e[e.COLOR_TEMPERATURE_RGB=16]="COLOR_TEMPERATURE_RGB",e[e.POSITION=19]="POSITION",e[e.COUNT=22]="COUNT"}(kr||(kr={}));var Vr,Wr=((yi={})[kr.USE_COLOR_TEMPERATURE]=bi.UINT32,yi[kr.ILLUMINANCE]=bi.FLOAT32,yi[kr.NODE]=bi.UINT32,yi[kr.RANGE]=bi.FLOAT32,yi[kr.TYPE]=bi.UINT32,yi[kr.AABB]=bi.UINT32,yi[kr.FRUSTUM]=bi.UINT32,yi[kr.SIZE]=bi.FLOAT32,yi[kr.SPOT_ANGLE]=bi.FLOAT32,yi[kr.ASPECT]=bi.FLOAT32,yi[kr.DIRECTION]=bi.FLOAT32,yi[kr.COLOR]=bi.FLOAT32,yi[kr.COLOR_TEMPERATURE_RGB]=bi.FLOAT32,yi[kr.POSITION]=bi.FLOAT32,yi[kr.COUNT]=bi.NEVER,yi),jr=new Mi(Pi.LIGHT,Wr,kr,3);!function(e){e[e.RADIUS=0]="RADIUS",e[e.CENTER=1]="CENTER",e[e.COUNT=4]="COUNT"}(Vr||(Vr={}));var qr=((Si={})[Vr.RADIUS]=bi.FLOAT32,Si[Vr.CENTER]=bi.FLOAT32,Si[Vr.COUNT]=bi.NEVER,Si);delete Vr[Vr.COUNT],Vr[Vr.COUNT=Vr.RADIUS+1]="COUNT";var Xr,Yr=new Mi(Pi.SPHERE,qr,Vr,3);!function(e){e[e.STRIDE=0]="STRIDE",e[e.AMOUNT=1]="AMOUNT",e[e.BUFFER=2]="BUFFER",e[e.COUNT=3]="COUNT"}(Xr||(Xr={}));var Kr,Zr=((Ei={})[Xr.STRIDE]=bi.UINT32,Ei[Xr.AMOUNT]=bi.UINT32,Ei[Xr.BUFFER]=bi.UINT32,Ei[Xr.COUNT]=bi.NEVER,Ei),Qr=new Mi(Pi.FLAT_BUFFER,Zr,Xr,3);!function(e){e[e.FLAT_BUFFER_ARRAY=0]="FLAT_BUFFER_ARRAY",e[e.COUNT=1]="COUNT"}(Kr||(Kr={}));var Jr,$r=((Ti={})[Kr.FLAT_BUFFER_ARRAY]=bi.UINT32,Ti[Kr.COUNT]=bi.NEVER,Ti),ea=new Mi(Pi.SUB_MESH,$r,Kr,3);!function(e){e[e.IS_DISCARD=0]="IS_DISCARD",e[e.POLYGO_MODEL=1]="POLYGO_MODEL",e[e.SHADE_MODEL=2]="SHADE_MODEL",e[e.CULL_MODE=3]="CULL_MODE",e[e.IS_FRONT_FACE_CCW=4]="IS_FRONT_FACE_CCW",e[e.DEPTH_BIAS_ENABLED=5]="DEPTH_BIAS_ENABLED",e[e.DEPTH_BIAS=6]="DEPTH_BIAS",e[e.DEPTH_BIAS_CLAMP=7]="DEPTH_BIAS_CLAMP",e[e.DEPTH_BIAS_SLOP=8]="DEPTH_BIAS_SLOP",e[e.IS_DEPTH_CLIP=9]="IS_DEPTH_CLIP",e[e.IS_MULTI_SAMPLE=10]="IS_MULTI_SAMPLE",e[e.LINE_WIDTH=11]="LINE_WIDTH",e[e.COUNT=12]="COUNT"}(Jr||(Jr={}));var ta,na=((Ai={})[Jr.IS_DISCARD]=bi.UINT32,Ai[Jr.POLYGO_MODEL]=bi.UINT32,Ai[Jr.SHADE_MODEL]=bi.UINT32,Ai[Jr.CULL_MODE]=bi.UINT32,Ai[Jr.IS_FRONT_FACE_CCW]=bi.UINT32,Ai[Jr.DEPTH_BIAS_ENABLED]=bi.UINT32,Ai[Jr.DEPTH_BIAS]=bi.FLOAT32,Ai[Jr.DEPTH_BIAS_CLAMP]=bi.FLOAT32,Ai[Jr.DEPTH_BIAS_SLOP]=bi.FLOAT32,Ai[Jr.IS_DEPTH_CLIP]=bi.UINT32,Ai[Jr.IS_MULTI_SAMPLE]=bi.UINT32,Ai[Jr.LINE_WIDTH]=bi.FLOAT32,Ai[Jr.COUNT]=bi.NEVER,Ai),ia=new Mi(Pi.RASTERIZER_STATE,na,Jr,9);!function(e){e[e.DEPTH_TEST=0]="DEPTH_TEST",e[e.DEPTH_WRITE=1]="DEPTH_WRITE",e[e.DEPTH_FUNC=2]="DEPTH_FUNC",e[e.STENCIL_TEST_FRONT=3]="STENCIL_TEST_FRONT",e[e.STENCIL_FUNC_FRONT=4]="STENCIL_FUNC_FRONT",e[e.STENCIL_READ_MASK_FRONT=5]="STENCIL_READ_MASK_FRONT",e[e.STENCIL_WRITE_MASK_FRONT=6]="STENCIL_WRITE_MASK_FRONT",e[e.STENCIL_FAIL_OP_FRONT=7]="STENCIL_FAIL_OP_FRONT",e[e.STENCIL_Z_FAIL_OP_FRONT=8]="STENCIL_Z_FAIL_OP_FRONT",e[e.STENCIL_PASS_OP_FRONT=9]="STENCIL_PASS_OP_FRONT",e[e.STENCIL_REF_FRONT=10]="STENCIL_REF_FRONT",e[e.STENCIL_TEST_BACK=11]="STENCIL_TEST_BACK",e[e.STENCIL_FUNC_BACK=12]="STENCIL_FUNC_BACK",e[e.STENCIL_READ_MADK_BACK=13]="STENCIL_READ_MADK_BACK",e[e.STENCIL_WRITE_MASK_BACK=14]="STENCIL_WRITE_MASK_BACK",e[e.STENCIL_FAIL_OP_BACK=15]="STENCIL_FAIL_OP_BACK",e[e.STENCIL_Z_FAIL_OP_BACK=16]="STENCIL_Z_FAIL_OP_BACK",e[e.STENCIL_PASS_OP_BACK=17]="STENCIL_PASS_OP_BACK",e[e.STENCIL_REF_BACK=18]="STENCIL_REF_BACK",e[e.COUNT=19]="COUNT"}(ta||(ta={}));var ra,aa=((xi={})[ta.DEPTH_TEST]=bi.UINT32,xi[ta.DEPTH_WRITE]=bi.UINT32,xi[ta.DEPTH_FUNC]=bi.UINT32,xi[ta.STENCIL_TEST_FRONT]=bi.UINT32,xi[ta.STENCIL_FUNC_FRONT]=bi.UINT32,xi[ta.STENCIL_READ_MASK_FRONT]=bi.UINT32,xi[ta.STENCIL_WRITE_MASK_FRONT]=bi.UINT32,xi[ta.STENCIL_FAIL_OP_FRONT]=bi.UINT32,xi[ta.STENCIL_Z_FAIL_OP_FRONT]=bi.UINT32,xi[ta.STENCIL_PASS_OP_FRONT]=bi.UINT32,xi[ta.STENCIL_REF_FRONT]=bi.UINT32,xi[ta.STENCIL_TEST_BACK]=bi.UINT32,xi[ta.STENCIL_FUNC_BACK]=bi.UINT32,xi[ta.STENCIL_READ_MADK_BACK]=bi.UINT32,xi[ta.STENCIL_WRITE_MASK_BACK]=bi.UINT32,xi[ta.STENCIL_FAIL_OP_BACK]=bi.UINT32,xi[ta.STENCIL_Z_FAIL_OP_BACK]=bi.UINT32,xi[ta.STENCIL_PASS_OP_BACK]=bi.UINT32,xi[ta.STENCIL_REF_BACK]=bi.UINT32,xi[ta.COUNT]=bi.NEVER,xi),sa=new Mi(Pi.DEPTH_STENCIL_STATE,aa,ta,9);!function(e){e[e.BLEND=0]="BLEND",e[e.BLEND_SRC=1]="BLEND_SRC",e[e.BLEND_DST=2]="BLEND_DST",e[e.BLEND_EQ=3]="BLEND_EQ",e[e.BLEND_SRC_ALPHA=4]="BLEND_SRC_ALPHA",e[e.BLEND_DST_ALPHA=5]="BLEND_DST_ALPHA",e[e.BLEND_ALPHA_EQ=6]="BLEND_ALPHA_EQ",e[e.BLEND_COLOR_MASK=7]="BLEND_COLOR_MASK",e[e.COUNT=8]="COUNT"}(ra||(ra={})),(Ci={})[ra.BLEND]=bi.UINT32,Ci[ra.BLEND_SRC]=bi.UINT32,Ci[ra.BLEND_DST]=bi.UINT32,Ci[ra.BLEND_EQ]=bi.UINT32,Ci[ra.BLEND_SRC_ALPHA]=bi.UINT32,Ci[ra.BLEND_DST_ALPHA]=bi.UINT32,Ci[ra.BLEND_ALPHA_EQ]=bi.UINT32,Ci[ra.BLEND_COLOR_MASK]=bi.UINT32,Ci[ra.COUNT]=bi.NEVER;var oa,ca=new Mi(Pi.BLEND_TARGET,aa,ra,9);!function(e){e[e.IS_A2C=0]="IS_A2C",e[e.IS_INDEPEND=1]="IS_INDEPEND",e[e.BLEND_COLOR=2]="BLEND_COLOR",e[e.BLEND_TARGET=6]="BLEND_TARGET",e[e.COUNT=7]="COUNT"}(oa||(oa={}));var la=((Ri={})[oa.IS_A2C]=bi.UINT32,Ri[oa.IS_INDEPEND]=bi.UINT32,Ri[oa.BLEND_COLOR]=bi.FLOAT32,Ri[oa.BLEND_TARGET]=bi.UINT32,Ri[oa.COUNT]=bi.NEVER,Ri),ua=new Mi(Pi.BLEND_STATE,la,oa,9),ha=function(){function e(){this._skyColor=new Cn(51,128,204,1),this._groundAlbedo=new Cn(51,51,51,255),this._albedoArray=Float32Array.from([.2,.2,.2,1]),this._colorArray=Float32Array.from([.2,.5,.8,1]),this._handle=0,this._handle=Nr.alloc()}j(e,[{key:"colorArray",get:function(){return this._colorArray}},{key:"albedoArray",get:function(){return this._albedoArray}},{key:"enabled",set:function(e){Nr.set(this._handle,wr.ENABLE,e?1:0)},get:function(){return Nr.get(this._handle,wr.ENABLE)}},{key:"skyColor",get:function(){return this._skyColor},set:function(e){this._skyColor.set(e),Cn.toArray(this._colorArray,this._skyColor),Nr.setVec4(this._handle,wr.SKY_COLOR,this._skyColor)}},{key:"skyIllum",get:function(){return Nr.get(this._handle,wr.ILLUM)},set:function(e){Nr.set(this._handle,wr.ILLUM,e)}},{key:"groundAlbedo",get:function(){return this._groundAlbedo},set:function(e){this._groundAlbedo.set(e),bn.toArray(this._albedoArray,this._groundAlbedo),Nr.setVec4(this._handle,wr.GROUND_ALBEDO,this._groundAlbedo)}},{key:"handle",get:function(){return this._handle}}]);var t=e.prototype;return t.initialize=function(e){this._skyColor.set(e.skyColor),this._groundAlbedo.set(e.groundAlbedo),Cn.toArray(this._colorArray,this._skyColor),bn.toArray(this._albedoArray,this._groundAlbedo),Nr.setVec4(this._handle,wr.SKY_COLOR,this._skyColor),Nr.setVec4(this._handle,wr.GROUND_ALBEDO,this._groundAlbedo),Nr.set(this._handle,wr.ILLUM,e.skyIllum)},t.destroy=function(){this._handle&&(Nr.free(this._handle),this._handle=0)},e}();ha.SUN_ILLUM=65e3,ha.SKY_ILLUM=2e4,i.Ambient=ha;var _a=new bn,fa=new bn,da=new bn,pa=new bn,ma=new bn,ga=new bn,va=new Array(3),ya=new Array(3);function Sa(e,t){return bn.dot(t.n,e)-t.d}function Ea(e,t,n){return bn.copy(e,t),bn.subtract(ma,n.center,n.halfExtents),bn.add(ga,n.center,n.halfExtents),e.x=e.x<ma.x?ma.x:e.x,e.y=e.y<ma.y?ma.y:e.y,e.z=e.z<ma.z?ma.z:e.z,e.x=e.x>ga.x?ga.x:e.x,e.y=e.y>ga.y?ga.y:e.y,e.z=e.z>ga.z?ga.z:e.z,e}function Ta(e,t,n){bn.set(_a,n.orientation.m00,n.orientation.m01,n.orientation.m02),bn.set(fa,n.orientation.m03,n.orientation.m04,n.orientation.m05),bn.set(da,n.orientation.m06,n.orientation.m07,n.orientation.m08),va[0]=_a,va[1]=fa,va[2]=da,ya[0]=n.halfExtents.x,ya[1]=n.halfExtents.y,ya[2]=n.halfExtents.z,bn.subtract(pa,t,n.center),bn.set(e,n.center.x,n.center.y,n.center.z);for(var i=0;i<3;i++){var r=bn.dot(pa,va[i]);r>ya[i]&&(r=ya[i]),r<-ya[i]&&(r=-ya[i]),e.x+=r*va[i].x,e.y+=r*va[i].y,e.z+=r*va[i].z}return e}var Aa=Object.freeze({__proto__:null,point_plane:Sa,pt_point_plane:function(e,t,n){var i=Sa(t,n);return bn.subtract(e,t,bn.multiplyScalar(e,n.n,i))},pt_point_aabb:Ea,pt_point_obb:Ta,pt_point_line:function(e,t,n,i){bn.subtract(_a,n,i);var r=_a,a=bn.lengthSqr(r);if(0==a)bn.copy(e,n);else{bn.subtract(_a,t,n);var s=bn.dot(_a,r)/a;s<0?bn.copy(e,n):s>1?bn.copy(e,i):bn.scaleAndAdd(e,n,r,s)}}}),xa={SHAPE_RAY:1,SHAPE_LINE:2,SHAPE_SPHERE:4,SHAPE_AABB:8,SHAPE_OBB:16,SHAPE_PLANE:32,SHAPE_TRIANGLE:64,SHAPE_FRUSTUM:128,SHAPE_FRUSTUM_ACCURATE:256,SHAPE_CAPSULE:512},Ca=function(){function e(e,t,n,i,r,a){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===a&&(a=-1),this.s=void 0,this.e=void 0,this._type=void 0,this._type=xa.SHAPE_LINE,this.s=new bn(e,t,n),this.e=new bn(i,r,a)}return e.create=function(t,n,i,r,a,s){return new e(t,n,i,r,a,s)},e.clone=function(t){return new e(t.s.x,t.s.y,t.s.z,t.e.x,t.e.y,t.e.z)},e.copy=function(e,t){return bn.copy(e.s,t.s),bn.copy(e.e,t.e),e},e.fromPoints=function(e,t,n){return bn.copy(e.s,t),bn.copy(e.e,n),e},e.set=function(e,t,n,i,r,a,s){return e.s.x=t,e.s.y=n,e.s.z=i,e.e.x=r,e.e.y=a,e.e.z=s,e},e.len=function(e){return bn.distance(e.s,e.e)},j(e,[{key:"type",get:function(){return this._type}}]),e.prototype.length=function(){return bn.distance(this.s,this.e)},e}(),Ra=function(){function e(e,t,n,i,r,a){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===a&&(a=-1),this.o=void 0,this.d=void 0,this._type=void 0,this._type=xa.SHAPE_RAY,this.o=new bn(e,t,n),this.d=new bn(i,r,a)}return e.create=function(t,n,i,r,a,s){return void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===a&&(a=0),void 0===s&&(s=1),new e(t,n,i,r,a,s)},e.clone=function(t){return new e(t.o.x,t.o.y,t.o.z,t.d.x,t.d.y,t.d.z)},e.copy=function(e,t){return bn.copy(e.o,t.o),bn.copy(e.d,t.d),e},e.fromPoints=function(e,t,n){return bn.copy(e.o,t),bn.normalize(e.d,bn.subtract(e.d,n,t)),e},e.set=function(e,t,n,i,r,a,s){return e.o.x=t,e.o.y=n,e.o.z=i,e.d.x=r,e.d.y=a,e.d.z=s,e},j(e,[{key:"type",get:function(){return this._type}}]),e.prototype.computeHit=function(e,t){bn.normalize(e,this.d),bn.scaleAndAdd(e,this.o,e,t)},e}(),ba=new bn,wa=new bn,Ia=new bn,Oa=new bn;function Pa(e){return Math.max(Math.max(e.x,e.y),e.z)}var Ma,Na=function(){function e(e,t,n,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=1),this._center=new bn(0,0,0),this._poolHandle=0,this._type=void 0,this._type=xa.SHAPE_SPHERE,this._center=new bn(e,t,n),this._poolHandle=Yr.alloc(),Yr.setVec3(this._poolHandle,Vr.CENTER,this._center),Yr.set(this._poolHandle,Vr.RADIUS,i)}e.create=function(t,n,i,r){return new e(t,n,i,r)},e.clone=function(t){return new e(t.center.x,t.center.y,t.center.z,t.radius)},e.copy=function(e,t){return bn.copy(e.center,t.center),e.radius=t.radius,e},e.fromPoints=function(e,t,n){return bn.multiplyScalar(e.center,bn.add(ba,t,n),.5),e.radius=.5*bn.subtract(ba,n,t).length(),e},e.set=function(e,t,n,i,r){return e.center.x=t,e.center.y=n,e.center.z=i,e.radius=r,e},e.mergePoint=function(e,t,n){if(t.radius<0)return e.center.set(n),e.radius=0,e;bn.subtract(wa,n,t.center);var i=wa.length();if(i>t.radius){var r=.5*(i-t.radius);e.radius+=r,bn.multiplyScalar(wa,wa,r/i),bn.add(e.center,e.center,wa)}return e},e.mergeAABB=function(t,n,i){return i.getBoundary(Ia,Oa),e.mergePoint(t,n,Ia),e.mergePoint(t,n,Oa),t},j(e,[{key:"center",get:function(){return this._center},set:function(e){this._center=e,Yr.setVec3(this._poolHandle,Vr.CENTER,this._center)}},{key:"radius",get:function(){return Yr.get(this._poolHandle,Vr.RADIUS)},set:function(e){Yr.set(this._poolHandle,Vr.RADIUS,e)}},{key:"handle",get:function(){return this._poolHandle}},{key:"type",get:function(){return this._type}}]);var t=e.prototype;return t.destroy=function(){this._poolHandle&&(Yr.free(this._poolHandle),this._poolHandle=0)},t.clone=function(){return e.clone(this)},t.copy=function(t){return e.copy(this,t)},t.getBoundary=function(e,t){bn.set(e,this.center.x-this.radius,this.center.y-this.radius,this.center.z-this.radius),bn.set(t,this.center.x+this.radius,this.center.y+this.radius,this.center.z+this.radius)},t.transform=function(e,t,n,i,r){bn.transformMat4(r.center,this.center,e),r.radius=this.radius*Pa(i)},t.translateAndRotate=function(e,t,n){bn.transformMat4(n.center,this.center,e)},t.setScale=function(e,t){t.radius=this.radius*Pa(e)},e}(),Da=function(){function e(e,t,n,i,r,a,s,o,c){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=1),void 0===r&&(r=0),void 0===a&&(a=0),void 0===s&&(s=0),void 0===o&&(o=1),void 0===c&&(c=0),this.a=void 0,this.b=void 0,this.c=void 0,this._type=void 0,this._type=xa.SHAPE_TRIANGLE,this.a=new bn(e,t,n),this.b=new bn(i,r,a),this.c=new bn(s,o,c)}return e.create=function(t,n,i,r,a,s,o,c,l){return void 0===t&&(t=1),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===a&&(a=0),void 0===s&&(s=0),void 0===o&&(o=0),void 0===c&&(c=0),void 0===l&&(l=1),new e(t,n,i,r,a,s,o,c,l)},e.clone=function(t){return new e(t.a.x,t.a.y,t.a.z,t.b.x,t.b.y,t.b.z,t.c.x,t.c.y,t.c.z)},e.copy=function(e,t){return bn.copy(e.a,t.a),bn.copy(e.b,t.b),bn.copy(e.c,t.c),e},e.fromPoints=function(e,t,n,i){return bn.copy(e.a,t),bn.copy(e.b,n),bn.copy(e.c,i),e},e.set=function(e,t,n,i,r,a,s,o,c,l){return e.a.x=t,e.a.y=n,e.a.z=i,e.b.x=r,e.b.y=a,e.b.z=s,e.c.x=o,e.c.y=c,e.c.z=l,e},j(e,[{key:"type",get:function(){return this._type}}]),e}(),Ba=e("GFX_MAX_ATTACHMENTS",4);!function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.BUFFER=1]="BUFFER",e[e.TEXTURE=2]="TEXTURE",e[e.RENDER_PASS=3]="RENDER_PASS",e[e.FRAMEBUFFER=4]="FRAMEBUFFER",e[e.SAMPLER=5]="SAMPLER",e[e.SHADER=6]="SHADER",e[e.DESCRIPTOR_SET_LAYOUT=7]="DESCRIPTOR_SET_LAYOUT",e[e.PIPELINE_LAYOUT=8]="PIPELINE_LAYOUT",e[e.PIPELINE_STATE=9]="PIPELINE_STATE",e[e.DESCRIPTOR_SET=10]="DESCRIPTOR_SET",e[e.INPUT_ASSEMBLER=11]="INPUT_ASSEMBLER",e[e.COMMAND_BUFFER=12]="COMMAND_BUFFER",e[e.FENCE=13]="FENCE",e[e.QUEUE=14]="QUEUE",e[e.WINDOW=15]="WINDOW"}(Ma||(Ma=e("GFXObjectType",{})));var La,Fa,za,Ua,Ga,ka,Ha,Va,Wa,ja,qa,Xa,Ya,Ka,Za,Qa,Ja,$a,es,ts,ns,is,rs,as,ss,os,cs,ls,us,hs,_s,fs,ds,ps,ms,gs,vs,ys=e("GFXObject",function(){function e(e){this._gfxType=Ma.UNKNOWN,this._gfxType=e}return j(e,[{key:"gfxType",get:function(){return this._gfxType}}]),e}());!function(e){e.ATTR_POSITION="a_position",e.ATTR_NORMAL="a_normal",e.ATTR_TANGENT="a_tangent",e.ATTR_BITANGENT="a_bitangent",e.ATTR_WEIGHTS="a_weights",e.ATTR_JOINTS="a_joints",e.ATTR_COLOR="a_color",e.ATTR_COLOR1="a_color1",e.ATTR_COLOR2="a_color2",e.ATTR_TEX_COORD="a_texCoord",e.ATTR_TEX_COORD1="a_texCoord1",e.ATTR_TEX_COORD2="a_texCoord2",e.ATTR_TEX_COORD3="a_texCoord3",e.ATTR_TEX_COORD4="a_texCoord4",e.ATTR_TEX_COORD5="a_texCoord5",e.ATTR_TEX_COORD6="a_texCoord6",e.ATTR_TEX_COORD7="a_texCoord7",e.ATTR_TEX_COORD8="a_texCoord8",e.ATTR_BATCH_ID="a_batch_id",e.ATTR_BATCH_UV="a_batch_uv"}(La||(La=e("GFXAttributeName",{}))),function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.BOOL=1]="BOOL",e[e.BOOL2=2]="BOOL2",e[e.BOOL3=3]="BOOL3",e[e.BOOL4=4]="BOOL4",e[e.INT=5]="INT",e[e.INT2=6]="INT2",e[e.INT3=7]="INT3",e[e.INT4=8]="INT4",e[e.UINT=9]="UINT",e[e.UINT2=10]="UINT2",e[e.UINT3=11]="UINT3",e[e.UINT4=12]="UINT4",e[e.FLOAT=13]="FLOAT",e[e.FLOAT2=14]="FLOAT2",e[e.FLOAT3=15]="FLOAT3",e[e.FLOAT4=16]="FLOAT4",e[e.MAT2=17]="MAT2",e[e.MAT2X3=18]="MAT2X3",e[e.MAT2X4=19]="MAT2X4",e[e.MAT3X2=20]="MAT3X2",e[e.MAT3=21]="MAT3",e[e.MAT3X4=22]="MAT3X4",e[e.MAT4X2=23]="MAT4X2",e[e.MAT4X3=24]="MAT4X3",e[e.MAT4=25]="MAT4",e[e.SAMPLER1D=26]="SAMPLER1D",e[e.SAMPLER1D_ARRAY=27]="SAMPLER1D_ARRAY",e[e.SAMPLER2D=28]="SAMPLER2D",e[e.SAMPLER2D_ARRAY=29]="SAMPLER2D_ARRAY",e[e.SAMPLER3D=30]="SAMPLER3D",e[e.SAMPLER_CUBE=31]="SAMPLER_CUBE",e[e.COUNT=32]="COUNT"}(Fa||(Fa=e("GFXType",{}))),function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.A8=1]="A8",e[e.L8=2]="L8",e[e.LA8=3]="LA8",e[e.R8=4]="R8",e[e.R8SN=5]="R8SN",e[e.R8UI=6]="R8UI",e[e.R8I=7]="R8I",e[e.R16F=8]="R16F",e[e.R16UI=9]="R16UI",e[e.R16I=10]="R16I",e[e.R32F=11]="R32F",e[e.R32UI=12]="R32UI",e[e.R32I=13]="R32I",e[e.RG8=14]="RG8",e[e.RG8SN=15]="RG8SN",e[e.RG8UI=16]="RG8UI",e[e.RG8I=17]="RG8I",e[e.RG16F=18]="RG16F",e[e.RG16UI=19]="RG16UI",e[e.RG16I=20]="RG16I",e[e.RG32F=21]="RG32F",e[e.RG32UI=22]="RG32UI",e[e.RG32I=23]="RG32I",e[e.RGB8=24]="RGB8",e[e.SRGB8=25]="SRGB8",e[e.RGB8SN=26]="RGB8SN",e[e.RGB8UI=27]="RGB8UI",e[e.RGB8I=28]="RGB8I",e[e.RGB16F=29]="RGB16F",e[e.RGB16UI=30]="RGB16UI",e[e.RGB16I=31]="RGB16I",e[e.RGB32F=32]="RGB32F",e[e.RGB32UI=33]="RGB32UI",e[e.RGB32I=34]="RGB32I",e[e.RGBA8=35]="RGBA8",e[e.BGRA8=36]="BGRA8",e[e.SRGB8_A8=37]="SRGB8_A8",e[e.RGBA8SN=38]="RGBA8SN",e[e.RGBA8UI=39]="RGBA8UI",e[e.RGBA8I=40]="RGBA8I",e[e.RGBA16F=41]="RGBA16F",e[e.RGBA16UI=42]="RGBA16UI",e[e.RGBA16I=43]="RGBA16I",e[e.RGBA32F=44]="RGBA32F",e[e.RGBA32UI=45]="RGBA32UI",e[e.RGBA32I=46]="RGBA32I",e[e.R5G6B5=47]="R5G6B5",e[e.R11G11B10F=48]="R11G11B10F",e[e.RGB5A1=49]="RGB5A1",e[e.RGBA4=50]="RGBA4",e[e.RGB10A2=51]="RGB10A2",e[e.RGB10A2UI=52]="RGB10A2UI",e[e.RGB9E5=53]="RGB9E5",e[e.D16=54]="D16",e[e.D16S8=55]="D16S8",e[e.D24=56]="D24",e[e.D24S8=57]="D24S8",e[e.D32F=58]="D32F",e[e.D32F_S8=59]="D32F_S8",e[e.BC1=60]="BC1",e[e.BC1_ALPHA=61]="BC1_ALPHA",e[e.BC1_SRGB=62]="BC1_SRGB",e[e.BC1_SRGB_ALPHA=63]="BC1_SRGB_ALPHA",e[e.BC2=64]="BC2",e[e.BC2_SRGB=65]="BC2_SRGB",e[e.BC3=66]="BC3",e[e.BC3_SRGB=67]="BC3_SRGB",e[e.BC4=68]="BC4",e[e.BC4_SNORM=69]="BC4_SNORM",e[e.BC5=70]="BC5",e[e.BC5_SNORM=71]="BC5_SNORM",e[e.BC6H_UF16=72]="BC6H_UF16",e[e.BC6H_SF16=73]="BC6H_SF16",e[e.BC7=74]="BC7",e[e.BC7_SRGB=75]="BC7_SRGB",e[e.ETC_RGB8=76]="ETC_RGB8",e[e.ETC2_RGB8=77]="ETC2_RGB8",e[e.ETC2_SRGB8=78]="ETC2_SRGB8",e[e.ETC2_RGB8_A1=79]="ETC2_RGB8_A1",e[e.ETC2_SRGB8_A1=80]="ETC2_SRGB8_A1",e[e.ETC2_RGBA8=81]="ETC2_RGBA8",e[e.ETC2_SRGB8_A8=82]="ETC2_SRGB8_A8",e[e.EAC_R11=83]="EAC_R11",e[e.EAC_R11SN=84]="EAC_R11SN",e[e.EAC_RG11=85]="EAC_RG11",e[e.EAC_RG11SN=86]="EAC_RG11SN",e[e.PVRTC_RGB2=87]="PVRTC_RGB2",e[e.PVRTC_RGBA2=88]="PVRTC_RGBA2",e[e.PVRTC_RGB4=89]="PVRTC_RGB4",e[e.PVRTC_RGBA4=90]="PVRTC_RGBA4",e[e.PVRTC2_2BPP=91]="PVRTC2_2BPP",e[e.PVRTC2_4BPP=92]="PVRTC2_4BPP",e[e.ASTC_RGBA_4x4=93]="ASTC_RGBA_4x4",e[e.ASTC_RGBA_5x4=94]="ASTC_RGBA_5x4",e[e.ASTC_RGBA_5x5=95]="ASTC_RGBA_5x5",e[e.ASTC_RGBA_6x5=96]="ASTC_RGBA_6x5",e[e.ASTC_RGBA_6x6=97]="ASTC_RGBA_6x6",e[e.ASTC_RGBA_8x5=98]="ASTC_RGBA_8x5",e[e.ASTC_RGBA_8x6=99]="ASTC_RGBA_8x6",e[e.ASTC_RGBA_8x8=100]="ASTC_RGBA_8x8",e[e.ASTC_RGBA_10x5=101]="ASTC_RGBA_10x5",e[e.ASTC_RGBA_10x6=102]="ASTC_RGBA_10x6",e[e.ASTC_RGBA_10x8=103]="ASTC_RGBA_10x8",e[e.ASTC_RGBA_10x10=104]="ASTC_RGBA_10x10",e[e.ASTC_RGBA_12x10=105]="ASTC_RGBA_12x10",e[e.ASTC_RGBA_12x12=106]="ASTC_RGBA_12x12",e[e.ASTC_SRGBA_4x4=107]="ASTC_SRGBA_4x4",e[e.ASTC_SRGBA_5x4=108]="ASTC_SRGBA_5x4",e[e.ASTC_SRGBA_5x5=109]="ASTC_SRGBA_5x5",e[e.ASTC_SRGBA_6x5=110]="ASTC_SRGBA_6x5",e[e.ASTC_SRGBA_6x6=111]="ASTC_SRGBA_6x6",e[e.ASTC_SRGBA_8x5=112]="ASTC_SRGBA_8x5",e[e.ASTC_SRGBA_8x6=113]="ASTC_SRGBA_8x6",e[e.ASTC_SRGBA_8x8=114]="ASTC_SRGBA_8x8",e[e.ASTC_SRGBA_10x5=115]="ASTC_SRGBA_10x5",e[e.ASTC_SRGBA_10x6=116]="ASTC_SRGBA_10x6",e[e.ASTC_SRGBA_10x8=117]="ASTC_SRGBA_10x8",e[e.ASTC_SRGBA_10x10=118]="ASTC_SRGBA_10x10",e[e.ASTC_SRGBA_12x10=119]="ASTC_SRGBA_12x10",e[e.ASTC_SRGBA_12x12=120]="ASTC_SRGBA_12x12"}(za||(za=e("GFXFormat",{}))),function(e){e[e.NONE=0]="NONE",e[e.TRANSFER_SRC=1]="TRANSFER_SRC",e[e.TRANSFER_DST=2]="TRANSFER_DST",e[e.INDEX=4]="INDEX",e[e.VERTEX=8]="VERTEX",e[e.UNIFORM=16]="UNIFORM",e[e.STORAGE=32]="STORAGE",e[e.INDIRECT=64]="INDIRECT"}(Ua||(Ua=e("GFXBufferUsageBit",{}))),function(e){e[e.NONE=0]="NONE",e[e.DEVICE=1]="DEVICE",e[e.HOST=2]="HOST"}(Ga||(Ga=e("GFXMemoryUsageBit",{}))),function(e){e[e.NONE=0]="NONE",e[e.BAKUP_BUFFER=4]="BAKUP_BUFFER"}(ka||(ka=e("GFXBufferFlagBit",{}))),function(e){e[e.NONE=0]="NONE",e[e.READ=1]="READ",e[e.WRITE=2]="WRITE"}(Ha||(Ha=e("GFXBufferAccessBit",{}))),function(e){e[e.POINT_LIST=0]="POINT_LIST",e[e.LINE_LIST=1]="LINE_LIST",e[e.LINE_STRIP=2]="LINE_STRIP",e[e.LINE_LOOP=3]="LINE_LOOP",e[e.LINE_LIST_ADJACENCY=4]="LINE_LIST_ADJACENCY",e[e.LINE_STRIP_ADJACENCY=5]="LINE_STRIP_ADJACENCY",e[e.ISO_LINE_LIST=6]="ISO_LINE_LIST",e[e.TRIANGLE_LIST=7]="TRIANGLE_LIST",e[e.TRIANGLE_STRIP=8]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=9]="TRIANGLE_FAN",e[e.TRIANGLE_LIST_ADJACENCY=10]="TRIANGLE_LIST_ADJACENCY",e[e.TRIANGLE_STRIP_ADJACENCY=11]="TRIANGLE_STRIP_ADJACENCY",e[e.TRIANGLE_PATCH_ADJACENCY=12]="TRIANGLE_PATCH_ADJACENCY",e[e.QUAD_PATCH_LIST=13]="QUAD_PATCH_LIST"}(Va||(Va=e("GFXPrimitiveMode",{}))),function(e){e[e.FILL=0]="FILL",e[e.POINT=1]="POINT",e[e.LINE=2]="LINE"}(Wa||(Wa=e("GFXPolygonMode",{}))),function(e){e[e.GOURAND=0]="GOURAND",e[e.FLAT=1]="FLAT"}(ja||(ja=e("GFXShadeModel",{}))),function(e){e[e.NONE=0]="NONE",e[e.FRONT=1]="FRONT",e[e.BACK=2]="BACK"}(qa||(qa=e("GFXCullMode",{}))),function(e){e[e.NEVER=0]="NEVER",e[e.LESS=1]="LESS",e[e.EQUAL=2]="EQUAL",e[e.LESS_EQUAL=3]="LESS_EQUAL",e[e.GREATER=4]="GREATER",e[e.NOT_EQUAL=5]="NOT_EQUAL",e[e.GREATER_EQUAL=6]="GREATER_EQUAL",e[e.ALWAYS=7]="ALWAYS"}(Xa||(Xa=e("GFXComparisonFunc",{}))),function(e){e[e.ZERO=0]="ZERO",e[e.KEEP=1]="KEEP",e[e.REPLACE=2]="REPLACE",e[e.INCR=3]="INCR",e[e.DECR=4]="DECR",e[e.INVERT=5]="INVERT",e[e.INCR_WRAP=6]="INCR_WRAP",e[e.DECR_WRAP=7]="DECR_WRAP"}(Ya||(Ya=e("GFXStencilOp",{}))),function(e){e[e.ADD=0]="ADD",e[e.SUB=1]="SUB",e[e.REV_SUB=2]="REV_SUB",e[e.MIN=3]="MIN",e[e.MAX=4]="MAX"}(Ka||(Ka=e("GFXBlendOp",{}))),function(e){e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_ALPHA=2]="SRC_ALPHA",e[e.DST_ALPHA=3]="DST_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=4]="ONE_MINUS_SRC_ALPHA",e[e.ONE_MINUS_DST_ALPHA=5]="ONE_MINUS_DST_ALPHA",e[e.SRC_COLOR=6]="SRC_COLOR",e[e.DST_COLOR=7]="DST_COLOR",e[e.ONE_MINUS_SRC_COLOR=8]="ONE_MINUS_SRC_COLOR",e[e.ONE_MINUS_DST_COLOR=9]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA_SATURATE=10]="SRC_ALPHA_SATURATE",e[e.CONSTANT_COLOR=11]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=12]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=13]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=14]="ONE_MINUS_CONSTANT_ALPHA"}(Za||(Za=e("GFXBlendFactor",{}))),function(e){e[e.NONE=0]="NONE",e[e.R=1]="R",e[e.G=2]="G",e[e.B=4]="B",e[e.A=8]="A",e[e.ALL=15]="ALL"}(Qa||(Qa=e("GFXColorMask",{}))),function(e){e[e.NONE=0]="NONE",e[e.POINT=1]="POINT",e[e.LINEAR=2]="LINEAR",e[e.ANISOTROPIC=3]="ANISOTROPIC"}(Ja||(Ja=e("GFXFilter",{}))),function(e){e[e.WRAP=0]="WRAP",e[e.MIRROR=1]="MIRROR",e[e.CLAMP=2]="CLAMP",e[e.BORDER=3]="BORDER"}($a||($a=e("GFXAddress",{}))),function(e){e[e.TEX1D=0]="TEX1D",e[e.TEX2D=1]="TEX2D",e[e.TEX3D=2]="TEX3D",e[e.CUBE=3]="CUBE",e[e.TEX1D_ARRAY=4]="TEX1D_ARRAY",e[e.TEX2D_ARRAY=5]="TEX2D_ARRAY"}(es||(es=e("GFXTextureType",{}))),function(e){e[e.NONE=0]="NONE",e[e.TRANSFER_SRC=1]="TRANSFER_SRC",e[e.TRANSFER_DST=2]="TRANSFER_DST",e[e.SAMPLED=4]="SAMPLED",e[e.STORAGE=8]="STORAGE",e[e.COLOR_ATTACHMENT=16]="COLOR_ATTACHMENT",e[e.DEPTH_STENCIL_ATTACHMENT=32]="DEPTH_STENCIL_ATTACHMENT",e[e.TRANSIENT_ATTACHMENT=64]="TRANSIENT_ATTACHMENT",e[e.INPUT_ATTACHMENT=128]="INPUT_ATTACHMENT"}(ts||(ts=e("GFXTextureUsageBit",{}))),function(e){e[e.X1=0]="X1",e[e.X2=1]="X2",e[e.X4=2]="X4",e[e.X8=3]="X8",e[e.X16=4]="X16",e[e.X32=5]="X32",e[e.X64=6]="X64"}(ns||(ns=e("GFXSampleCount",{}))),function(e){e[e.NONE=0]="NONE",e[e.GEN_MIPMAP=1]="GEN_MIPMAP",e[e.CUBEMAP=2]="CUBEMAP",e[e.BAKUP_BUFFER=4]="BAKUP_BUFFER",e[e.IMMUTABLE=8]="IMMUTABLE"}(is||(is=e("GFXTextureFlagBit",{}))),function(e){e[e.NONE=0]="NONE",e[e.VERTEX=1]="VERTEX",e[e.CONTROL=2]="CONTROL",e[e.EVALUATION=4]="EVALUATION",e[e.GEOMETRY=8]="GEOMETRY",e[e.FRAGMENT=16]="FRAGMENT",e[e.COMPUTE=32]="COMPUTE",e[e.ALL=63]="ALL"}(rs||(rs=e("GFXShaderStageFlagBit",{}))),function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.UNIFORM_BUFFER=1]="UNIFORM_BUFFER",e[e.DYNAMIC_UNIFORM_BUFFER=2]="DYNAMIC_UNIFORM_BUFFER",e[e.STORAGE_BUFFER=4]="STORAGE_BUFFER",e[e.DYNAMIC_STORAGE_BUFFER=8]="DYNAMIC_STORAGE_BUFFER",e[e.SAMPLER=16]="SAMPLER"}(as||(as=e("GFXDescriptorType",{}))),function(e){e[e.PRIMARY=0]="PRIMARY",e[e.SECONDARY=1]="SECONDARY"}(ss||(ss=e("GFXCommandBufferType",{}))),function(e){e[e.LOAD=0]="LOAD",e[e.CLEAR=1]="CLEAR",e[e.DISCARD=2]="DISCARD"}(os||(os=e("GFXLoadOp",{}))),function(e){e[e.STORE=0]="STORE",e[e.DISCARD=1]="DISCARD"}(cs||(cs=e("GFXStoreOp",{}))),function(e){e[e.UNDEFINED=0]="UNDEFINED",e[e.GENERAL=1]="GENERAL",e[e.COLOR_ATTACHMENT_OPTIMAL=2]="COLOR_ATTACHMENT_OPTIMAL",e[e.DEPTH_STENCIL_ATTACHMENT_OPTIMAL=3]="DEPTH_STENCIL_ATTACHMENT_OPTIMAL",e[e.DEPTH_STENCIL_READONLY_OPTIMAL=4]="DEPTH_STENCIL_READONLY_OPTIMAL",e[e.SHADER_READONLY_OPTIMAL=5]="SHADER_READONLY_OPTIMAL",e[e.TRANSFER_SRC_OPTIMAL=6]="TRANSFER_SRC_OPTIMAL",e[e.TRANSFER_DST_OPTIMAL=7]="TRANSFER_DST_OPTIMAL",e[e.PREINITIALIZED=8]="PREINITIALIZED",e[e.PRESENT_SRC=9]="PRESENT_SRC"}(ls||(ls=e("GFXTextureLayout",{}))),function(e){e[e.GRAPHICS=0]="GRAPHICS",e[e.COMPUTE=1]="COMPUTE",e[e.RAY_TRACING=2]="RAY_TRACING"}(us||(us=e("GFXPipelineBindPoint",{}))),function(e){e[e.NONE=0]="NONE",e[e.VIEWPORT=1]="VIEWPORT",e[e.SCISSOR=2]="SCISSOR",e[e.LINE_WIDTH=4]="LINE_WIDTH",e[e.DEPTH_BIAS=8]="DEPTH_BIAS",e[e.BLEND_CONSTANTS=16]="BLEND_CONSTANTS",e[e.DEPTH_BOUNDS=32]="DEPTH_BOUNDS",e[e.STENCIL_WRITE_MASK=64]="STENCIL_WRITE_MASK",e[e.STENCIL_COMPARE_MASK=128]="STENCIL_COMPARE_MASK"}(hs||(hs=e("GFXDynamicStateFlagBit",{}))),function(e){e[e.FRONT=0]="FRONT",e[e.BACK=1]="BACK",e[e.ALL=2]="ALL"}(_s||(_s=e("GFXStencilFace",{}))),function(e){e[e.GRAPHICS=0]="GRAPHICS",e[e.COMPUTE=1]="COMPUTE",e[e.TRANSFER=2]="TRANSFER"}(fs||(fs=e("GFXQueueType",{}))),function(e){e[e.NONE=0]="NONE",e[e.COLOR=1]="COLOR",e[e.DEPTH=2]="DEPTH",e[e.STENCIL=4]="STENCIL",e[e.DEPTH_STENCIL=6]="DEPTH_STENCIL",e[e.ALL=7]="ALL"}(ds||(ds=e("GFXClearFlag",{}))),function(e){e[e.NONE=0]="NONE",e[e.UNORM=1]="UNORM",e[e.SNORM=2]="SNORM",e[e.UINT=3]="UINT",e[e.INT=4]="INT",e[e.UFLOAT=5]="UFLOAT",e[e.FLOAT=6]="FLOAT"}(ps||(ps=e("GFXFormatType",{}))),function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.GLES2=1]="GLES2",e[e.GLES3=2]="GLES3",e[e.METAL=3]="METAL",e[e.VULKAN=4]="VULKAN",e[e.WEBGL=5]="WEBGL",e[e.WEBGL2=6]="WEBGL2",e[e.WEBGPU=7]="WEBGPU"}(ms||(ms=e("GFXAPI",{}))),function(e){e[e.IDENTITY=0]="IDENTITY",e[e.ROTATE_90=1]="ROTATE_90",e[e.ROTATE_180=2]="ROTATE_180",e[e.ROTATE_270=3]="ROTATE_270"}(gs||(gs=e("GFXSurfaceTransform",{}))),function(e){e[e.COLOR_FLOAT=0]="COLOR_FLOAT",e[e.COLOR_HALF_FLOAT=1]="COLOR_HALF_FLOAT",e[e.TEXTURE_FLOAT=2]="TEXTURE_FLOAT",e[e.TEXTURE_HALF_FLOAT=3]="TEXTURE_HALF_FLOAT",e[e.TEXTURE_FLOAT_LINEAR=4]="TEXTURE_FLOAT_LINEAR",e[e.TEXTURE_HALF_FLOAT_LINEAR=5]="TEXTURE_HALF_FLOAT_LINEAR",e[e.FORMAT_R11G11B10F=6]="FORMAT_R11G11B10F",e[e.FORMAT_D16=7]="FORMAT_D16",e[e.FORMAT_D16S8=8]="FORMAT_D16S8",e[e.FORMAT_D24=9]="FORMAT_D24",e[e.FORMAT_D24S8=10]="FORMAT_D24S8",e[e.FORMAT_D32F=11]="FORMAT_D32F",e[e.FORMAT_D32FS8=12]="FORMAT_D32FS8",e[e.FORMAT_ETC1=13]="FORMAT_ETC1",e[e.FORMAT_ETC2=14]="FORMAT_ETC2",e[e.FORMAT_DXT=15]="FORMAT_DXT",e[e.FORMAT_PVRTC=16]="FORMAT_PVRTC",e[e.FORMAT_ASTC=17]="FORMAT_ASTC",e[e.FORMAT_RGB8=18]="FORMAT_RGB8",e[e.MSAA=19]="MSAA",e[e.ELEMENT_INDEX_UINT=20]="ELEMENT_INDEX_UINT",e[e.INSTANCED_ARRAYS=21]="INSTANCED_ARRAYS",e[e.MULTIPLE_RENDER_TARGETS=22]="MULTIPLE_RENDER_TARGETS",e[e.BLEND_MINMAX=23]="BLEND_MINMAX",e[e.DEPTH_BOUNDS=24]="DEPTH_BOUNDS",e[e.LINE_WIDTH=25]="LINE_WIDTH",e[e.STENCIL_WRITE_MASK=26]="STENCIL_WRITE_MASK",e[e.STENCIL_COMPARE_MASK=27]="STENCIL_COMPARE_MASK",e[e.COUNT=28]="COUNT"}(vs||(vs=e("GFXFeature",{})));var Ss=e("GFXFormatInfo",(function(e,t,n,i,r,a,s,o){this.name=e,this.size=t,this.count=n,this.type=i,this.hasAlpha=r,this.hasDepth=a,this.hasStencil=s,this.isCompressed=o})),Es=e("GFXMemoryStatus",(function(e,t){void 0===e&&(e=0),void 0===t&&(t=0),this.bufferSize=e,this.textureSize=t})),Ts=e("GFXFormatInfos",Object.freeze([new Ss("UNKNOWN",0,0,ps.NONE,!1,!1,!1,!1),new Ss("A8",1,1,ps.UNORM,!0,!1,!1,!1),new Ss("L8",1,1,ps.UNORM,!1,!1,!1,!1),new Ss("LA8",1,2,ps.UNORM,!0,!1,!1,!1),new Ss("R8",1,1,ps.UNORM,!1,!1,!1,!1),new Ss("R8SN",1,1,ps.SNORM,!1,!1,!1,!1),new Ss("R8UI",1,1,ps.UINT,!1,!1,!1,!1),new Ss("R8I",1,1,ps.INT,!1,!1,!1,!1),new Ss("R16F",2,1,ps.FLOAT,!1,!1,!1,!1),new Ss("R16UI",2,1,ps.UINT,!1,!1,!1,!1),new Ss("R16I",2,1,ps.INT,!1,!1,!1,!1),new Ss("R32F",4,1,ps.FLOAT,!1,!1,!1,!1),new Ss("R32UI",4,1,ps.UINT,!1,!1,!1,!1),new Ss("R32I",4,1,ps.INT,!1,!1,!1,!1),new Ss("RG8",2,2,ps.UNORM,!1,!1,!1,!1),new Ss("RG8SN",2,2,ps.SNORM,!1,!1,!1,!1),new Ss("RG8UI",2,2,ps.UINT,!1,!1,!1,!1),new Ss("RG8I",2,2,ps.INT,!1,!1,!1,!1),new Ss("RG16F",4,2,ps.FLOAT,!1,!1,!1,!1),new Ss("RG16UI",4,2,ps.UINT,!1,!1,!1,!1),new Ss("RG16I",4,2,ps.INT,!1,!1,!1,!1),new Ss("RG32F",8,2,ps.FLOAT,!1,!1,!1,!1),new Ss("RG32UI",8,2,ps.UINT,!1,!1,!1,!1),new Ss("RG32I",8,2,ps.INT,!1,!1,!1,!1),new Ss("RGB8",3,3,ps.UNORM,!1,!1,!1,!1),new Ss("SRGB8",3,3,ps.UNORM,!1,!1,!1,!1),new Ss("RGB8SN",3,3,ps.SNORM,!1,!1,!1,!1),new Ss("RGB8UI",3,3,ps.UINT,!1,!1,!1,!1),new Ss("RGB8I",3,3,ps.INT,!1,!1,!1,!1),new Ss("RGB16F",6,3,ps.FLOAT,!1,!1,!1,!1),new Ss("RGB16UI",6,3,ps.UINT,!1,!1,!1,!1),new Ss("RGB16I",6,3,ps.INT,!1,!1,!1,!1),new Ss("RGB32F",12,3,ps.FLOAT,!1,!1,!1,!1),new Ss("RGB32UI",12,3,ps.UINT,!1,!1,!1,!1),new Ss("RGB32I",12,3,ps.INT,!1,!1,!1,!1),new Ss("RGBA8",4,4,ps.UNORM,!0,!1,!1,!1),new Ss("BGRA8",4,4,ps.UNORM,!0,!1,!1,!1),new Ss("SRGB8_A8",4,4,ps.UNORM,!0,!1,!1,!1),new Ss("RGBA8SN",4,4,ps.SNORM,!0,!1,!1,!1),new Ss("RGBA8UI",4,4,ps.UINT,!0,!1,!1,!1),new Ss("RGBA8I",4,4,ps.INT,!0,!1,!1,!1),new Ss("RGBA16F",8,4,ps.FLOAT,!0,!1,!1,!1),new Ss("RGBA16UI",8,4,ps.UINT,!0,!1,!1,!1),new Ss("RGBA16I",8,4,ps.INT,!0,!1,!1,!1),new Ss("RGBA32F",16,4,ps.FLOAT,!0,!1,!1,!1),new Ss("RGBA32UI",16,4,ps.UINT,!0,!1,!1,!1),new Ss("RGBA32I",16,4,ps.INT,!0,!1,!1,!1),new Ss("R5G6B5",2,3,ps.UNORM,!1,!1,!1,!1),new Ss("R11G11B10F",4,3,ps.FLOAT,!1,!1,!1,!1),new Ss("RGB5A1",2,4,ps.UNORM,!0,!1,!1,!1),new Ss("RGBA4",2,4,ps.UNORM,!0,!1,!1,!1),new Ss("RGB10A2",2,4,ps.UNORM,!0,!1,!1,!1),new Ss("RGB10A2UI",2,4,ps.UINT,!0,!1,!1,!1),new Ss("RGB9E5",2,4,ps.FLOAT,!0,!1,!1,!1),new Ss("D16",2,1,ps.UINT,!1,!0,!1,!1),new Ss("D16S8",3,2,ps.UINT,!1,!0,!0,!1),new Ss("D24",3,1,ps.UINT,!1,!0,!1,!1),new Ss("D24S8",4,2,ps.UINT,!1,!0,!0,!1),new Ss("D32F",4,1,ps.FLOAT,!1,!0,!1,!1),new Ss("D32FS8",5,2,ps.FLOAT,!1,!0,!0,!1),new Ss("BC1",1,3,ps.UNORM,!1,!1,!1,!0),new Ss("BC1_ALPHA",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("BC1_SRGB",1,3,ps.UNORM,!1,!1,!1,!0),new Ss("BC1_SRGB_ALPHA",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("BC2",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("BC2_SRGB",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("BC3",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("BC3_SRGB",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("BC4",1,1,ps.UNORM,!1,!1,!1,!0),new Ss("BC4_SNORM",1,1,ps.SNORM,!1,!1,!1,!0),new Ss("BC5",1,2,ps.UNORM,!1,!1,!1,!0),new Ss("BC5_SNORM",1,2,ps.SNORM,!1,!1,!1,!0),new Ss("BC6H_UF16",1,3,ps.UFLOAT,!1,!1,!1,!0),new Ss("BC6H_SF16",1,3,ps.FLOAT,!1,!1,!1,!0),new Ss("BC7",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("BC7_SRGB",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ETC_RGB8",1,3,ps.UNORM,!1,!1,!1,!0),new Ss("ETC2_RGB8",1,3,ps.UNORM,!1,!1,!1,!0),new Ss("ETC2_SRGB8",1,3,ps.UNORM,!1,!1,!1,!0),new Ss("ETC2_RGB8_A1",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ETC2_SRGB8_A1",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ETC2_RGBA8",2,4,ps.UNORM,!0,!1,!1,!0),new Ss("ETC2_SRGB8_A8",2,4,ps.UNORM,!0,!1,!1,!0),new Ss("EAC_R11",1,1,ps.UNORM,!1,!1,!1,!0),new Ss("EAC_R11SN",1,1,ps.SNORM,!1,!1,!1,!0),new Ss("EAC_RG11",2,2,ps.UNORM,!1,!1,!1,!0),new Ss("EAC_RG11SN",2,2,ps.SNORM,!1,!1,!1,!0),new Ss("PVRTC_RGB2",2,3,ps.UNORM,!1,!1,!1,!0),new Ss("PVRTC_RGBA2",2,4,ps.UNORM,!0,!1,!1,!0),new Ss("PVRTC_RGB4",2,3,ps.UNORM,!1,!1,!1,!0),new Ss("PVRTC_RGBA4",2,4,ps.UNORM,!0,!1,!1,!0),new Ss("PVRTC2_2BPP",2,4,ps.UNORM,!0,!1,!1,!0),new Ss("PVRTC2_4BPP",2,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_RGBA_4x4",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_RGBA_5x4",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_RGBA_5x5",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_RGBA_6x5",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_RGBA_6x6",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_RGBA_8x5",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_RGBA_8x6",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_RGBA_8x8",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_RGBA_10x5",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_RGBA_10x6",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_RGBA_10x8",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_RGBA_10x10",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_RGBA_12x10",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_RGBA_12x12",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_SRGBA_4x4",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_SRGBA_5x4",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_SRGBA_5x5",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_SRGBA_6x5",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_SRGBA_6x6",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_SRGBA_8x5",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_SRGBA_8x6",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_SRGBA_8x8",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_SRGBA_10x5",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_SRGBA_10x6",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_SRGBA_10x8",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_SRGBA_10x10",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_SRGBA_12x10",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_SRGBA_12x12",1,4,ps.UNORM,!0,!1,!1,!0)]));function As(e,t,n,i){if(!Ts[e].isCompressed)return t*n*i*Ts[e].size;switch(e){case za.BC1:case za.BC1_ALPHA:case za.BC1_SRGB:case za.BC1_SRGB_ALPHA:return Math.ceil(t/4)*Math.ceil(n/4)*8*i;case za.BC2:case za.BC2_SRGB:case za.BC3:case za.BC3_SRGB:case za.BC4:case za.BC4_SNORM:case za.BC6H_SF16:case za.BC6H_UF16:case za.BC7:case za.BC7_SRGB:return Math.ceil(t/4)*Math.ceil(n/4)*16*i;case za.BC5:case za.BC5_SNORM:return Math.ceil(t/4)*Math.ceil(n/4)*32*i;case za.ETC_RGB8:case za.ETC2_RGB8:case za.ETC2_SRGB8:case za.ETC2_RGB8_A1:case za.EAC_R11:case za.EAC_R11SN:return Math.ceil(t/4)*Math.ceil(n/4)*8*i;case za.ETC2_RGBA8:case za.ETC2_SRGB8_A1:case za.EAC_RG11:case za.EAC_RG11SN:return Math.ceil(t/4)*Math.ceil(n/4)*16*i;case za.PVRTC_RGB2:case za.PVRTC_RGBA2:case za.PVRTC2_2BPP:return Math.ceil(Math.max(t,16)*Math.max(n,8)/4)*i;case za.PVRTC_RGB4:case za.PVRTC_RGBA4:case za.PVRTC2_4BPP:return Math.ceil(Math.max(t,8)*Math.max(n,8)/2)*i;case za.ASTC_RGBA_4x4:case za.ASTC_SRGBA_4x4:return Math.ceil(t/4)*Math.ceil(n/4)*16*i;case za.ASTC_RGBA_5x4:case za.ASTC_SRGBA_5x4:return Math.ceil(t/5)*Math.ceil(n/4)*16*i;case za.ASTC_RGBA_5x5:case za.ASTC_SRGBA_5x5:return Math.ceil(t/5)*Math.ceil(n/5)*16*i;case za.ASTC_RGBA_6x5:case za.ASTC_SRGBA_6x5:return Math.ceil(t/6)*Math.ceil(n/5)*16*i;case za.ASTC_RGBA_6x6:case za.ASTC_SRGBA_6x6:return Math.ceil(t/6)*Math.ceil(n/6)*16*i;case za.ASTC_RGBA_8x5:case za.ASTC_SRGBA_8x5:return Math.ceil(t/8)*Math.ceil(n/5)*16*i;case za.ASTC_RGBA_8x6:case za.ASTC_SRGBA_8x6:return Math.ceil(t/8)*Math.ceil(n/6)*16*i;case za.ASTC_RGBA_8x8:case za.ASTC_SRGBA_8x8:return Math.ceil(t/8)*Math.ceil(n/8)*16*i;case za.ASTC_RGBA_10x5:case za.ASTC_SRGBA_10x5:return Math.ceil(t/10)*Math.ceil(n/5)*16*i;case za.ASTC_RGBA_10x6:case za.ASTC_SRGBA_10x6:return Math.ceil(t/10)*Math.ceil(n/6)*16*i;case za.ASTC_RGBA_10x8:case za.ASTC_SRGBA_10x8:return Math.ceil(t/10)*Math.ceil(n/8)*16*i;case za.ASTC_RGBA_10x10:case za.ASTC_SRGBA_10x10:return Math.ceil(t/10)*Math.ceil(n/10)*16*i;case za.ASTC_RGBA_12x10:case za.ASTC_SRGBA_12x10:return Math.ceil(t/12)*Math.ceil(n/10)*16*i;case za.ASTC_RGBA_12x12:case za.ASTC_SRGBA_12x12:return Math.ceil(t/12)*Math.ceil(n/12)*16*i;default:return 0}}function xs(e,t,n,i,r){for(var a=0,s=0;s<r;++s)a+=As(e,t,n,i),t=Math.max(t>>1,1),n=Math.max(n>>1,1);return a}var Cs=[0,4,8,12,16,4,8,12,16,4,8,12,16,4,8,12,16,16,24,32,24,36,48,32,48,64,4,4,4,4,4,4];function Rs(e){return Cs[e]||0}function bs(e){var t=e.size/e.count;switch(e.type){case ps.UNORM:case ps.UINT:switch(t){case 1:return Uint8Array;case 2:return Uint16Array;case 4:return Uint32Array}break;case ps.SNORM:case ps.INT:switch(t){case 1:return Int8Array;case 2:return Int16Array;case 4:return Int32Array}break;case ps.FLOAT:return Float32Array}return Float32Array}var ws=e("GFXDrawInfo",(function(e,t,n,i,r,a,s){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===a&&(a=0),void 0===s&&(s=0),this.vertexCount=e,this.firstVertex=t,this.indexCount=n,this.firstIndex=i,this.vertexOffset=r,this.instanceCount=a,this.firstInstance=s})),Is=e("GFX_DRAW_INFO_SIZE",28),Os=e("GFXIndirectBuffer",(function(e){void 0===e&&(e=[]),this.drawInfos=e})),Ps=e("GFXBufferInfo",(function(e,t,n,i,r){void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=ka.NONE),this.usage=e,this.memUsage=t,this.size=n,this.stride=i,this.flags=r})),Ms=e("GFXBufferViewInfo",(function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=0),this.buffer=e,this.offset=t,this.range=n})),Ns=e("GFXBuffer",function(e){function t(t){var n;return(n=e.call(this,Ma.BUFFER)||this)._device=void 0,n._usage=Ua.NONE,n._memUsage=Ga.NONE,n._size=0,n._stride=1,n._count=0,n._flags=ka.NONE,n._bakcupBuffer=null,n._indirectBuffer=null,n._isBufferView=!1,n._device=t,n}return X(t,e),j(t,[{key:"usage",get:function(){return this._usage}},{key:"memUsage",get:function(){return this._memUsage}},{key:"size",get:function(){return this._size}},{key:"stride",get:function(){return this._stride}},{key:"count",get:function(){return this._count}},{key:"flags",get:function(){return this._flags}},{key:"backupBuffer",get:function(){return this._bakcupBuffer}}]),t}(ys)),Ds=e("GFXCommandBufferInfo",(function(e,t){void 0===t&&(t=ss.PRIMARY),this.queue=e,this.type=t})),Bs=e("GFXCommandBuffer",function(e){function t(t){var n;return(n=e.call(this,Ma.COMMAND_BUFFER)||this)._device=void 0,n._queue=null,n._type=ss.PRIMARY,n._numDrawCalls=0,n._numInstances=0,n._numTris=0,n._device=t,n}return X(t,e),j(t,[{key:"type",get:function(){return this._type}},{key:"queue",get:function(){return this._queue}},{key:"numDrawCalls",get:function(){return this._numDrawCalls}},{key:"numInstances",get:function(){return this._numInstances}},{key:"numTris",get:function(){return this._numTris}}]),t}(ys));ht(za);var Ls=e("GFXBindingMappingInfo",(function(e,t,n){void 0===e&&(e=[]),void 0===t&&(t=[]),void 0===n&&(n=0),this.bufferOffsets=e,this.samplerOffsets=t,this.flexibleSet=n})),Fs=e("GFXDeviceInfo",(function(e,t,n,i,r,a,s){void 0===t&&(t=!0),void 0===n&&(n=!0),void 0===i&&(i=1),void 0===r&&(r=1),void 0===a&&(a=1),void 0===s&&(s=new Ls),this.canvasElm=e,this.isAntialias=t,this.isPremultipliedAlpha=n,this.devicePixelRatio=i,this.nativeWidth=r,this.nativeHeight=a,this.bindingMappingInfo=s})),zs=e("GFXDevice",function(){function e(){this._canvas=null,this._canvas2D=null,this._gfxAPI=ms.UNKNOWN,this._transform=gs.IDENTITY,this._deviceName="",this._renderer="",this._vendor="",this._version="",this._features=new Array(vs.COUNT),this._queue=null,this._cmdBuff=null,this._devicePixelRatio=1,this._width=0,this._height=0,this._nativeWidth=0,this._nativeHeight=0,this._maxVertexAttributes=0,this._maxVertexUniformVectors=0,this._maxFragmentUniformVectors=0,this._maxTextureUnits=0,this._maxVertexTextureUnits=0,this._maxUniformBufferBindings=0,this._maxUniformBlockSize=0,this._maxTextureSize=0,this._maxCubeMapTextureSize=0,this._uboOffsetAlignment=1,this._depthBits=0,this._stencilBits=0,this._colorFmt=za.UNKNOWN,this._depthStencilFmt=za.UNKNOWN,this._macros=new Map,this._numDrawCalls=0,this._numInstances=0,this._numTris=0,this._memoryStatus=new Es,this._clipSpaceMinZ=-1,this._screenSpaceSignY=1,this._UVSpaceSignY=-1}return e.prototype.hasFeature=function(e){return this._features[e]},j(e,[{key:"canvas",get:function(){return this._canvas}},{key:"canvas2D",get:function(){return this._canvas2D}},{key:"gfxAPI",get:function(){return this._gfxAPI}},{key:"queue",get:function(){return this._queue}},{key:"commandBuffer",get:function(){return this._cmdBuff}},{key:"devicePixelRatio",get:function(){return this._devicePixelRatio}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"nativeWidth",get:function(){return this._nativeWidth}},{key:"nativeHeight",get:function(){return this._nativeHeight}},{key:"renderer",get:function(){return this._renderer}},{key:"vendor",get:function(){return this._vendor}},{key:"maxVertexAttributes",get:function(){return this._maxVertexAttributes}},{key:"maxVertexUniformVectors",get:function(){return this._maxVertexUniformVectors}},{key:"maxFragmentUniformVectors",get:function(){return this._maxFragmentUniformVectors}},{key:"maxTextureUnits",get:function(){return this._maxTextureUnits}},{key:"maxVertexTextureUnits",get:function(){return this._maxVertexTextureUnits}},{key:"maxUniformBufferBindings",get:function(){return this._maxUniformBufferBindings}},{key:"maxUniformBlockSize",get:function(){return this._maxUniformBlockSize}},{key:"maxTextureSize",get:function(){return this._maxTextureSize}},{key:"maxCubeMapTextureSize",get:function(){return this._maxCubeMapTextureSize}},{key:"uboOffsetAlignment",get:function(){return this._uboOffsetAlignment}},{key:"depthBits",get:function(){return this._depthBits}},{key:"stencilBits",get:function(){return this._stencilBits}},{key:"colorFormat",get:function(){return this._colorFmt}},{key:"depthStencilFormat",get:function(){return this._depthStencilFmt}},{key:"macros",get:function(){return this._macros}},{key:"numDrawCalls",get:function(){return this._numDrawCalls}},{key:"numInstances",get:function(){return this._numInstances}},{key:"numTris",get:function(){return this._numTris}},{key:"memoryStatus",get:function(){return this._memoryStatus}},{key:"clipSpaceMinZ",get:function(){return this._clipSpaceMinZ}},{key:"screenSpaceSignY",get:function(){return this._screenSpaceSignY}},{key:"UVSpaceSignY",get:function(){return this._UVSpaceSignY}},{key:"surfaceTransform",get:function(){return this._transform}}]),e}()),Us=e("GFXFramebufferInfo",(function(e,t,n,i,r){void 0===t&&(t=[]),void 0===n&&(n=null),void 0===i&&(i=[]),void 0===r&&(r=0),this.renderPass=e,this.colorTextures=t,this.depthStencilTexture=n,this.colorMipmapLevels=i,this.depStencilMipmapLevel=r})),Gs=e("GFXFramebuffer",function(e){function t(t){var n;return(n=e.call(this,Ma.FRAMEBUFFER)||this)._device=void 0,n._renderPass=null,n._colorTextures=[],n._depthStencilTexture=null,n._device=t,n}return X(t,e),j(t,[{key:"renderPass",get:function(){return this._renderPass}},{key:"colorTextures",get:function(){return this._colorTextures}},{key:"depthStencilTexture",get:function(){return this._depthStencilTexture}}]),t}(ys)),ks=String.prototype.charCodeAt;function Hs(e){return this[e]}function Vs(e,t){for(var n=e.length,i=t^n,r=0,a="string"==typeof e?ks:Hs;n>=4;){var s=255&a.call(e,r)|(255&a.call(e,++r))<<8|(255&a.call(e,++r))<<16|(255&a.call(e,++r))<<24;s=1540483477*(65535&s)+((1540483477*(s>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(s=1540483477*(65535&(s^=s>>>24))+((1540483477*(s>>>16)&65535)<<16)),n-=4,++r}switch(n){case 3:i^=(255&a.call(e,r+2))<<16;case 2:i^=(255&a.call(e,r+1))<<8;case 1:i=1540483477*(65535&(i^=255&a.call(e,r)))+((1540483477*(i>>>16)&65535)<<16)}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0}var Ws=e("GFXAttribute",(function(e,t,n,i,r,a){void 0===e&&(e=""),void 0===t&&(t=za.UNKNOWN),void 0===n&&(n=!1),void 0===i&&(i=0),void 0===r&&(r=!1),void 0===a&&(a=0),this.name=e,this.format=t,this.isNormalized=n,this.stream=i,this.isInstanced=r,this.location=a})),js=e("GFXInputAssemblerInfo",(function(e,t,n,i){void 0===e&&(e=[]),void 0===t&&(t=[]),void 0===n&&(n=null),void 0===i&&(i=null),this.attributes=e,this.vertexBuffers=t,this.indexBuffer=n,this.indirectBuffer=i})),qs=e("GFXInputAssembler",function(e){function t(t){var n;return(n=e.call(this,Ma.INPUT_ASSEMBLER)||this)._device=void 0,n._attributes=[],n._vertexBuffers=[],n._indexBuffer=null,n._vertexCount=0,n._firstVertex=0,n._indexCount=0,n._firstIndex=0,n._vertexOffset=0,n._instanceCount=0,n._firstInstance=0,n._attributesHash=0,n._indirectBuffer=null,n._device=t,n}X(t,e),j(t,[{key:"vertexBuffers",get:function(){return this._vertexBuffers}},{key:"indexBuffer",get:function(){return this._indexBuffer}},{key:"attributes",get:function(){return this._attributes}},{key:"attributesHash",get:function(){return this._attributesHash}},{key:"vertexCount",get:function(){return this._vertexCount},set:function(e){this._vertexCount=e}},{key:"firstVertex",get:function(){return this._firstVertex},set:function(e){this._firstVertex=e}},{key:"indexCount",get:function(){return this._indexCount},set:function(e){this._indexCount=e}},{key:"firstIndex",get:function(){return this._firstIndex},set:function(e){this._firstIndex=e}},{key:"vertexOffset",get:function(){return this._vertexOffset},set:function(e){this._vertexOffset=e}},{key:"instanceCount",get:function(){return this._instanceCount},set:function(e){this._instanceCount=e}},{key:"firstInstance",get:function(){return this._firstInstance},set:function(e){this._firstInstance=e}},{key:"indirectBuffer",get:function(){return this._indirectBuffer}}]);var n=t.prototype;return n.getVertexBuffer=function(e){return void 0===e&&(e=0),e<this._vertexBuffers.length?this._vertexBuffers[e]:null},n.computeAttributesHash=function(){for(var e="attrs",t=0;t<this.attributes.length;++t){var n=this.attributes[t];e+=","+n.name+","+n.format+","+n.isNormalized+","+n.stream+","+n.isInstanced}return Vs(e,666)},t}(ys)),Xs=e("GFXRect",(function(e,t,n,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=1),void 0===i&&(i=1),this.x=e,this.y=t,this.width=n,this.height=i})),Ys=e("GFXViewport",(function(e,t,n,i,r,a){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===a&&(a=1),this.left=e,this.top=t,this.width=n,this.height=i,this.minDepth=r,this.maxDepth=a})),Ks=e("GFXColor",(function(e,t,n,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),this.x=e,this.y=t,this.z=n,this.w=i})),Zs=e("GFXOffset",(function(e,t,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),this.x=e,this.y=t,this.z=n})),Qs=e("GFXExtent",(function(e,t,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=1),this.width=e,this.height=t,this.depth=n})),Js=e("GFXTextureSubres",(function(e,t,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=1),this.mipLevel=e,this.baseArrayLayer=t,this.layerCount=n})),$s=e("GFXTextureCopy",(function(e,t,n,i,r){void 0===e&&(e=new Js),void 0===t&&(t=new Zs),void 0===n&&(n=new Js),void 0===i&&(i=new Zs),void 0===r&&(r=new Qs),this.srcSubres=e,this.srcOffset=t,this.dstSubres=n,this.dstOffset=i,this.extent=r})),eo=e("GFXBufferTextureCopy",(function(e,t,n,i,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=new Zs),void 0===i&&(i=new Qs),void 0===r&&(r=new Js),this.buffStride=e,this.buffTexHeight=t,this.texOffset=n,this.texExtent=i,this.texSubres=r})),to=e("GFXRasterizerState",function(){function e(e,t,n,i,r,a,s,o,c,l,u,h){void 0===e&&(e=!1),void 0===t&&(t=Wa.FILL),void 0===n&&(n=ja.GOURAND),void 0===i&&(i=qa.BACK),void 0===r&&(r=!0),void 0===a&&(a=!1),void 0===s&&(s=0),void 0===o&&(o=0),void 0===c&&(c=0),void 0===l&&(l=!0),void 0===u&&(u=!1),void 0===h&&(h=1),this.isDiscard=e,this.polygonMode=t,this.shadeModel=n,this.cullMode=i,this.isFrontFaceCCW=r,this.depthBiasEnabled=a,this.depthBias=s,this.depthBiasClamp=o,this.depthBiasSlop=c,this.isDepthClip=l,this.isMultisample=u,this.lineWidth=h}var t=e.prototype;return t.reset=function(){this.isDiscard=!1,this.polygonMode=Wa.FILL,this.shadeModel=ja.GOURAND,this.cullMode=qa.BACK,this.isFrontFaceCCW=!0,this.depthBiasEnabled=!1,this.depthBias=0,this.depthBiasClamp=0,this.depthBiasSlop=0,this.isDepthClip=!0,this.isMultisample=!1,this.lineWidth=1},t.assign=function(e){Object.assign(this,e)},t.destroy=function(){},j(e,[{key:"handle",get:function(){return 0}}]),e}()),no=e("GFXDepthStencilState",function(){function e(e,t,n,i,r,a,s,o,c,l,u,h,_,f,d,p,m,g,v){void 0===e&&(e=!0),void 0===t&&(t=!0),void 0===n&&(n=Xa.LESS),void 0===i&&(i=!1),void 0===r&&(r=Xa.ALWAYS),void 0===a&&(a=65535),void 0===s&&(s=65535),void 0===o&&(o=Ya.KEEP),void 0===c&&(c=Ya.KEEP),void 0===l&&(l=Ya.KEEP),void 0===u&&(u=1),void 0===h&&(h=!1),void 0===_&&(_=Xa.ALWAYS),void 0===f&&(f=65535),void 0===d&&(d=65535),void 0===p&&(p=Ya.KEEP),void 0===m&&(m=Ya.KEEP),void 0===g&&(g=Ya.KEEP),void 0===v&&(v=1),this.depthTest=e,this.depthWrite=t,this.depthFunc=n,this.stencilTestFront=i,this.stencilFuncFront=r,this.stencilReadMaskFront=a,this.stencilWriteMaskFront=s,this.stencilFailOpFront=o,this.stencilZFailOpFront=c,this.stencilPassOpFront=l,this.stencilRefFront=u,this.stencilTestBack=h,this.stencilFuncBack=_,this.stencilReadMaskBack=f,this.stencilWriteMaskBack=d,this.stencilFailOpBack=p,this.stencilZFailOpBack=m,this.stencilPassOpBack=g,this.stencilRefBack=v}var t=e.prototype;return t.reset=function(){this.depthTest=!0,this.depthWrite=!0,this.depthFunc=Xa.LESS,this.stencilTestFront=!1,this.stencilFuncFront=Xa.ALWAYS,this.stencilReadMaskFront=65535,this.stencilWriteMaskFront=65535,this.stencilFailOpFront=Ya.KEEP,this.stencilZFailOpFront=Ya.KEEP,this.stencilPassOpFront=Ya.KEEP,this.stencilRefFront=1,this.stencilTestBack=!1,this.stencilFuncBack=Xa.ALWAYS,this.stencilReadMaskBack=65535,this.stencilWriteMaskBack=65535,this.stencilFailOpBack=Ya.KEEP,this.stencilZFailOpBack=Ya.KEEP,this.stencilPassOpBack=Ya.KEEP,this.stencilRefBack=1},t.assign=function(e){Object.assign(this,e)},t.destroy=function(){},j(e,[{key:"handle",get:function(){return 0}}]),e}()),io=e("GFXBlendTarget",function(){function e(e,t,n,i,r,a,s,o){void 0===e&&(e=!1),void 0===t&&(t=Za.ONE),void 0===n&&(n=Za.ZERO),void 0===i&&(i=Ka.ADD),void 0===r&&(r=Za.ONE),void 0===a&&(a=Za.ZERO),void 0===s&&(s=Ka.ADD),void 0===o&&(o=Qa.ALL),this.blend=e,this.blendSrc=t,this.blendDst=n,this.blendEq=i,this.blendSrcAlpha=r,this.blendDstAlpha=a,this.blendAlphaEq=s,this.blendColorMask=o}var t=e.prototype;return t.reset=function(){this.blend=!1,this.blendSrc=Za.ONE,this.blendDst=Za.ZERO,this.blendEq=Ka.ADD,this.blendSrcAlpha=Za.ONE,this.blendDstAlpha=Za.ZERO,this.blendAlphaEq=Ka.ADD,this.blendColorMask=Qa.ALL},t.assign=function(e){Object.assign(this,e)},t.destroy=function(){},j(e,[{key:"handle",get:function(){return 0}}]),e}()),ro=e("GFXBlendState",function(){function e(e,t,n,i){void 0===e&&(e=!1),void 0===t&&(t=!1),void 0===n&&(n=new Ks),void 0===i&&(i=[new io]),this.isA2C=e,this.isIndepend=t,this.blendColor=n,this.targets=i}var t=e.prototype;return t.setTarget=function(e,t){var n=this.targets[e];n||(n=this.targets[e]=new io),Object.assign(n,t)},t.reset=function(){this.isA2C=!1,this.isIndepend=!1,this.blendColor.x=0,this.blendColor.y=0,this.blendColor.z=0,this.blendColor.w=0,this.targets.length=1,this.targets[0].reset()},t.destroy=function(){},j(e,[{key:"handle",get:function(){return 0}}]),e}()),ao=e("GFXInputState",(function(e){void 0===e&&(e=[]),this.attributes=e})),so=e("GFXPipelineStateInfo",(function(e,t,n,i,r,a,s,o,c){void 0===o&&(o=Va.TRIANGLE_LIST),void 0===c&&(c=hs.NONE),this.shader=e,this.pipelineLayout=t,this.renderPass=n,this.inputState=i,this.rasterizerState=r,this.depthStencilState=a,this.blendState=s,this.primitive=o,this.dynamicStates=c})),oo=e("GFXPipelineState",function(e){function t(t){var n;return(n=e.call(this,Ma.PIPELINE_STATE)||this)._device=void 0,n._shader=null,n._pipelineLayout=null,n._primitive=Va.TRIANGLE_LIST,n._is=null,n._rs=new to,n._dss=new no,n._bs=new ro,n._dynamicStates=hs.NONE,n._renderPass=null,n._device=t,n}return X(t,e),j(t,[{key:"shader",get:function(){return this._shader}},{key:"pipelineLayout",get:function(){return this._pipelineLayout}},{key:"primitive",get:function(){return this._primitive}},{key:"rasterizerState",get:function(){return this._rs}},{key:"depthStencilState",get:function(){return this._dss}},{key:"blendState",get:function(){return this._bs}},{key:"inputState",get:function(){return this._is}},{key:"dynamicStates",get:function(){return this._dynamicStates}},{key:"renderPass",get:function(){return this._renderPass}}]),t}(ys)),co=e("GFXQueueInfo",(function(e){void 0===e&&(e=fs.GRAPHICS),this.type=e})),lo=e("GFXQueue",function(e){function t(t){var n;return(n=e.call(this,Ma.QUEUE)||this)._device=void 0,n._type=fs.GRAPHICS,n._isAsync=!1,n._device=t,n}return X(t,e),j(t,[{key:"type",get:function(){return this._type}}]),t.prototype.isAsync=function(){return this._isAsync},t}(ys)),uo=e("GFXColorAttachment",(function(e,t,n,i,r,a){void 0===e&&(e=za.UNKNOWN),void 0===t&&(t=1),void 0===n&&(n=os.CLEAR),void 0===i&&(i=cs.STORE),void 0===r&&(r=ls.UNDEFINED),void 0===a&&(a=ls.PRESENT_SRC),this.format=e,this.sampleCount=t,this.loadOp=n,this.storeOp=i,this.beginLayout=r,this.endLayout=a})),ho=e("GFXDepthStencilAttachment",(function(e,t,n,i,r,a,s,o){void 0===e&&(e=za.UNKNOWN),void 0===t&&(t=1),void 0===n&&(n=os.CLEAR),void 0===i&&(i=cs.STORE),void 0===r&&(r=os.CLEAR),void 0===a&&(a=cs.STORE),void 0===s&&(s=ls.UNDEFINED),void 0===o&&(o=ls.DEPTH_STENCIL_ATTACHMENT_OPTIMAL),this.format=e,this.sampleCount=t,this.depthLoadOp=n,this.depthStoreOp=i,this.stencilLoadOp=r,this.stencilStoreOp=a,this.beginLayout=s,this.endLayout=o})),_o=e("GFXSubPassInfo",(function(e,t,n,i,r,a){void 0===e&&(e=us.GRAPHICS),void 0===t&&(t=[]),void 0===n&&(n=[]),void 0===i&&(i=[]),void 0===r&&(r=-1),void 0===a&&(a=[]),this.bindPoint=e,this.inputs=t,this.colors=n,this.resolves=i,this.depthStencil=r,this.preserves=a})),fo=e("GFXRenderPassInfo",(function(e,t,n){void 0===e&&(e=[]),void 0===t&&(t=null),void 0===n&&(n=[]),this.colorAttachments=e,this.depthStencilAttachment=t,this.subPasses=n})),po=e("GFXRenderPass",function(e){function t(t){var n;return(n=e.call(this,Ma.RENDER_PASS)||this)._device=void 0,n._colorInfos=[],n._depthStencilInfo=null,n._subPasses=[],n._hash=0,n._device=t,n}return X(t,e),j(t,[{key:"colorAttachments",get:function(){return this._colorInfos}},{key:"depthStencilAttachment",get:function(){return this._depthStencilInfo}},{key:"subPasses",get:function(){return this._subPasses}},{key:"hash",get:function(){return this._hash}}]),t.prototype.computeHash=function(){var e="";if(this._subPasses.length)for(var t=0;t<this._subPasses.length;++t){var n=this._subPasses[t];if(n.inputs.length){e+="ia";for(var i=0;i<n.inputs.length;++i){var r=this._colorInfos[n.inputs[i]];e+=","+r.format+","+r.sampleCount}}if(n.colors.length){e+="ca";for(var a=0;a<n.inputs.length;++a){var s=this._colorInfos[n.inputs[a]];e+=","+s.format+","+s.sampleCount}}if(n.depthStencil>=0){var o=this._colorInfos[n.depthStencil];e+="ds,"+o.format+","+o.sampleCount}}else{e+="ca";for(var c=0;c<this._colorInfos.length;++c){var l=this._colorInfos[c];e+=","+l.format+","+l.sampleCount}var u=this._depthStencilInfo;u&&(e+="ds,"+u.format+","+u.sampleCount)}return Vs(e,666)},t}(ys)),mo=e("GFXSamplerInfo",(function(e,t,n,i,r,a,s,o,c,l,u,h){void 0===e&&(e=Ja.LINEAR),void 0===t&&(t=Ja.LINEAR),void 0===n&&(n=Ja.NONE),void 0===i&&(i=$a.WRAP),void 0===r&&(r=$a.WRAP),void 0===a&&(a=$a.WRAP),void 0===s&&(s=16),void 0===o&&(o=Xa.NEVER),void 0===c&&(c=new Ks),void 0===l&&(l=0),void 0===u&&(u=0),void 0===h&&(h=0),this.minFilter=e,this.magFilter=t,this.mipFilter=n,this.addressU=i,this.addressV=r,this.addressW=a,this.maxAnisotropy=s,this.cmpFunc=o,this.borderColor=c,this.minLOD=l,this.maxLOD=u,this.mipLODBias=h})),go=e("GFXSampler",function(e){function t(t){var n;return(n=e.call(this,Ma.SAMPLER)||this)._device=void 0,n._minFilter=Ja.LINEAR,n._magFilter=Ja.LINEAR,n._mipFilter=Ja.NONE,n._addressU=$a.WRAP,n._addressV=$a.WRAP,n._addressW=$a.WRAP,n._maxAnisotropy=16,n._cmpFunc=Xa.NEVER,n._borderColor=new Ks,n._minLOD=0,n._maxLOD=0,n._mipLODBias=0,n._device=t,n}return X(t,e),j(t,[{key:"minFilter",get:function(){return this._minFilter}},{key:"magFilter",get:function(){return this._magFilter}},{key:"mipFilter",get:function(){return this._mipFilter}},{key:"addressU",get:function(){return this._addressU}},{key:"addressV",get:function(){return this._addressV}},{key:"addressW",get:function(){return this._addressW}},{key:"maxAnisotropy",get:function(){return this._maxAnisotropy}},{key:"cmpFunc",get:function(){return this._cmpFunc}},{key:"borderColor",get:function(){return this._borderColor}},{key:"minLOD",get:function(){return this._minLOD}},{key:"maxLOD",get:function(){return this._maxLOD}},{key:"mipLODBias",get:function(){return this._mipLODBias}}]),t}(ys)),vo=e("GFXShaderStage",(function(e,t){void 0===e&&(e=rs.NONE),void 0===t&&(t=""),this.stage=e,this.source=t})),yo=e("GFXUniform",(function(e,t,n){void 0===e&&(e=""),void 0===t&&(t=Fa.UNKNOWN),void 0===n&&(n=1),this.name=e,this.type=t,this.count=n})),So=e("GFXUniformBlock",(function(e,t,n,i,r){void 0===e&&(e=-1),void 0===t&&(t=-1),void 0===n&&(n=""),void 0===i&&(i=[]),void 0===r&&(r=1),this.set=e,this.binding=t,this.name=n,this.members=i,this.count=r})),Eo=e("GFXUniformSampler",(function(e,t,n,i,r){void 0===e&&(e=-1),void 0===t&&(t=-1),void 0===n&&(n=""),void 0===i&&(i=Fa.UNKNOWN),void 0===r&&(r=1),this.set=e,this.binding=t,this.name=n,this.type=i,this.count=r})),To=e("GFXShaderInfo",(function(e,t,n,i,r){void 0===e&&(e=""),void 0===t&&(t=[]),void 0===n&&(n=[]),void 0===i&&(i=[]),void 0===r&&(r=[]),this.name=e,this.stages=t,this.attributes=n,this.blocks=i,this.samplers=r})),Ao=e("GFXShader",function(e){function t(n){var i;return(i=e.call(this,Ma.SHADER)||this)._device=void 0,i._id=void 0,i._name="",i._stages=[],i._attributes=[],i._blocks=[],i._samplers=[],i._device=n,i._id=t._shaderIdGen++,i}return X(t,e),j(t,[{key:"id",get:function(){return this._id}},{key:"name",get:function(){return this._name}},{key:"attributes",get:function(){return this._attributes}},{key:"blocks",get:function(){return this._blocks}},{key:"samplers",get:function(){return this._samplers}}]),t}(ys));Ao._shaderIdGen=0;var xo=e("GFXTextureInfo",(function(e,t,n,i,r,a,s,o,c,l){void 0===t&&(t=ts.NONE),void 0===n&&(n=za.UNKNOWN),void 0===i&&(i=0),void 0===r&&(r=0),void 0===a&&(a=is.NONE),void 0===s&&(s=1),void 0===o&&(o=1),void 0===c&&(c=ns.X1),void 0===l&&(l=1),this.type=e,this.usage=t,this.format=n,this.width=i,this.height=r,this.flags=a,this.layerCount=s,this.levelCount=o,this.samples=c,this.depth=l})),Co=e("GFXTextureViewInfo",(function(e,t,n,i,r,a,s){void 0===t&&(t=es.TEX2D),void 0===n&&(n=za.UNKNOWN),void 0===i&&(i=0),void 0===r&&(r=1),void 0===a&&(a=0),void 0===s&&(s=1),this.texture=e,this.type=t,this.format=n,this.baseLevel=i,this.levelCount=r,this.baseLayer=a,this.layerCount=s}));function Ro(e){return e>0&&0==(e&e-1)}var bo=e("GFXTexture",function(e){function t(t){var n;return(n=e.call(this,Ma.TEXTURE)||this)._device=void 0,n._type=es.TEX2D,n._usage=ts.NONE,n._format=za.UNKNOWN,n._width=0,n._height=0,n._depth=1,n._layerCount=1,n._levelCount=1,n._samples=ns.X1,n._flags=is.NONE,n._isPowerOf2=!1,n._size=0,n._buffer=null,n._device=t,n}return X(t,e),j(t,[{key:"type",get:function(){return this._type}},{key:"usage",get:function(){return this._usage}},{key:"format",get:function(){return this._format}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"depth",get:function(){return this._depth}},{key:"layerCount",get:function(){return this._layerCount}},{key:"levelCount",get:function(){return this._levelCount}},{key:"samples",get:function(){return this._samples}},{key:"flags",get:function(){return this._flags}},{key:"size",get:function(){return this._size}},{key:"buffer",get:function(){return this._buffer}}]),t}(ys)),wo={Device:zs,Buffer:Ns,Texture:bo,Sampler:go,Shader:Ao,InputAssembler:qs,RenderPass:po,Framebuffer:Gs,PipelineState:oo,CommandBuffer:Bs,Queue:lo,FormatSize:As,FormatSurfaceSize:xs,GetTypeSize:Rs,getTypedArrayConstructor:bs,MAX_ATTACHMENTS:Ba,ObjectType:Ma,Obj:ys,AttributeName:La,Type:Fa,Format:za,BufferUsageBit:Ua,MemoryUsageBit:Ga,BufferFlagBit:ka,BufferAccessBit:Ha,PrimitiveMode:Va,PolygonMode:Wa,ShadeModel:ja,CullMode:qa,ComparisonFunc:Xa,StencilOp:Ya,BlendOp:Ka,BlendFactor:Za,ColorMask:Qa,Filter:Ja,Address:$a,TextureType:es,TextureUsageBit:ts,SampleCount:ns,TextureFlagBit:is,ShaderStageFlagBit:rs,DescriptorType:as,CommandBufferType:ss,LoadOp:os,StoreOp:cs,TextureLayout:ls,PipelineBindPoint:us,DynamicStateFlagBit:hs,StencilFace:_s,QueueType:fs,Rect:Xs,Viewport:Ys,Color:Ks,ClearFlag:ds,Offset:Zs,Extent:Qs,TextureSubres:Js,TextureCopy:$s,BufferTextureCopy:eo,FormatType:ps,FormatInfo:Ss,MemoryStatus:Es,FormatInfos:Ts},Io=e("GFX_DESCRIPTOR_BUFFER_TYPE",as.UNIFORM_BUFFER|as.DYNAMIC_UNIFORM_BUFFER|as.STORAGE_BUFFER|as.DYNAMIC_STORAGE_BUFFER),Oo=e("GFX_DESCRIPTOR_SAMPLER_TYPE",as.SAMPLER),Po=e("GFXDescriptorSetInfo",(function(e){this.layout=e})),Mo=e("GFXDescriptorSet",function(e){function t(t){var n;return(n=e.call(this,Ma.DESCRIPTOR_SET)||this)._device=void 0,n._layout=null,n._buffers=[],n._textures=[],n._samplers=[],n._isDirty=!1,n._device=t,n}X(t,e),j(t,[{key:"layout",get:function(){return this._layout}}]);var n=t.prototype;return n.bindBuffer=function(e,t,n){void 0===n&&(n=0);var i=this._layout.bindingIndices[e],r=this._layout.bindings[i];if(r)if(r.descriptorType&Io){var a=this._layout.descriptorIndices[e];this._buffers[a+n]!==t&&(this._buffers[a+n]=t,this._isDirty=!0)}else console.warn("Setting binding is not DescriptorType.UNIFORM_BUFFER.")},n.bindSampler=function(e,t,n){void 0===n&&(n=0);var i=this._layout.bindingIndices[e],r=this._layout.bindings[i];if(r)if(r.descriptorType&Oo){var a=this._layout.descriptorIndices[e];this._samplers[a+n]!==t&&(this._samplers[a+n]=t,this._isDirty=!0)}else console.warn("Setting binding is not DescriptorType.SAMPLER.")},n.bindTexture=function(e,t,n){void 0===n&&(n=0);var i=this._layout.bindingIndices[e],r=this._layout.bindings[i];if(r)if(r.descriptorType&Oo){var a=this._layout.descriptorIndices[e];this._textures[a+n]!==t&&(this._textures[a+n]=t,this._isDirty=!0)}else console.warn("Setting binding is not DescriptorType.SAMPLER.")},n.getBuffer=function(e,t){void 0===t&&(t=0);var n=this._layout.descriptorIndices[e];return this._buffers[n+t]},n.getSampler=function(e,t){void 0===t&&(t=0);var n=this._layout.descriptorIndices[e];return this._samplers[n+t]},n.getTexture=function(e,t){void 0===t&&(t=0);var n=this._layout.descriptorIndices[e];return this._textures[n+t]},t}(ys)),No=e("GFXDescriptorSetLayoutBinding",(function(e,t,n,i,r){void 0===e&&(e=-1),void 0===t&&(t=as.UNKNOWN),void 0===n&&(n=0),void 0===i&&(i=rs.NONE),void 0===r&&(r=[]),this.binding=e,this.descriptorType=t,this.count=n,this.stageFlags=i,this.immutableSamplers=r})),Do=e("GFXDescriptorSetLayoutInfo",(function(e){void 0===e&&(e=[]),this.bindings=e})),Bo=e("GFX_DESCRIPTOR_DYNAMIC_TYPE",as.DYNAMIC_STORAGE_BUFFER|as.DYNAMIC_UNIFORM_BUFFER),Lo=e("GFXDescriptorSetLayout",function(e){function t(t){var n;return(n=e.call(this,Ma.DESCRIPTOR_SET_LAYOUT)||this)._device=void 0,n._bindings=[],n._bindingIndices=[],n._descriptorIndices=[],n._device=t,n}return X(t,e),j(t,[{key:"bindings",get:function(){return this._bindings}},{key:"bindingIndices",get:function(){return this._bindingIndices}},{key:"descriptorIndices",get:function(){return this._descriptorIndices}}]),t}(ys)),Fo=e("GFXPipelineLayoutInfo",(function(e){void 0===e&&(e=[]),this.setLayouts=e})),zo=e("GFXPipelineLayout",function(e){function t(t){var n;return(n=e.call(this,Ma.PIPELINE_LAYOUT)||this)._device=void 0,n._setLayouts=[],n._device=t,n}return X(t,e),j(t,[{key:"setLayouts",get:function(){return this._setLayouts}}]),t}(ys)),Uo=e("GFXFenceInfo",(function(){})),Go=e("GFXFence",function(e){function t(t){var n;return(n=e.call(this,Ma.FENCE)||this)._device=void 0,n._device=t,n}return X(t,e),t}(ys));se(i,"cc",[{name:"GFXDynamicState",newName:"DynamicStateFlagBit"},{name:"GFXBindingType",newName:"DescriptorType"},{name:"GFXBindingLayout",newName:"DescriptorSet"}]),oe(Bs.prototype,"CommandBuffer.prototype",[{name:"bindBindingLayout",suggest:"Use `bindDescriptorSet` instead"}]);var ko,Ho={MAX_ATTACHMENTS:"GFX_MAX_ATTACHMENTS",Obj:"GFXObject",getTypedArrayConstructor:""};for(var Vo in wo){var Wo=Ho[Vo];""!==Wo&&(void 0===Wo&&(Wo="GFX"+Vo),se(i,"cc",[{name:Wo,newName:Vo,target:i.gfx,targetName:"cc.gfx"}]))}i.gfx=wo,e("gfx",Object.freeze({__proto__:null,DESCRIPTOR_BUFFER_TYPE:Io,DESCRIPTOR_SAMPLER_TYPE:Oo,DescriptorSetInfo:Po,DescriptorSet:Mo,DrawInfo:ws,DRAW_INFO_SIZE:Is,IndirectBuffer:Os,BufferInfo:Ps,BufferViewInfo:Ms,Buffer:Ns,CommandBufferInfo:Ds,CommandBuffer:Bs,MAX_ATTACHMENTS:Ba,get ObjectType(){return Ma},Obj:ys,get AttributeName(){return La},get Type(){return Fa},get Format(){return za},get BufferUsageBit(){return Ua},get MemoryUsageBit(){return Ga},get BufferFlagBit(){return ka},get BufferAccessBit(){return Ha},get PrimitiveMode(){return Va},get PolygonMode(){return Wa},get ShadeModel(){return ja},get CullMode(){return qa},get ComparisonFunc(){return Xa},get StencilOp(){return Ya},get BlendOp(){return Ka},get BlendFactor(){return Za},get ColorMask(){return Qa},get Filter(){return Ja},get Address(){return $a},get TextureType(){return es},get TextureUsageBit(){return ts},get SampleCount(){return ns},get TextureFlagBit(){return is},get ShaderStageFlagBit(){return rs},get DescriptorType(){return as},get CommandBufferType(){return ss},get LoadOp(){return os},get StoreOp(){return cs},get TextureLayout(){return ls},get PipelineBindPoint(){return us},get DynamicStateFlagBit(){return hs},get StencilFace(){return _s},get QueueType(){return fs},get ClearFlag(){return ds},get FormatType(){return ps},get API(){return ms},get SurfaceTransform(){return gs},get Feature(){return vs},FormatInfo:Ss,MemoryStatus:Es,FormatInfos:Ts,FormatSize:As,FormatSurfaceSize:xs,GetTypeSize:Rs,getTypedArrayConstructor:bs,Rect:Xs,Viewport:Ys,Color:Ks,Offset:Zs,Extent:Qs,TextureSubres:Js,TextureCopy:$s,BufferTextureCopy:eo,BindingMappingInfo:Ls,DeviceInfo:Fs,Device:zs,FramebufferInfo:Us,Framebuffer:Gs,Attribute:Ws,InputAssemblerInfo:js,InputAssembler:qs,DescriptorSetLayoutBinding:No,DescriptorSetLayoutInfo:Do,DESCRIPTOR_DYNAMIC_TYPE:Bo,DescriptorSetLayout:Lo,PipelineLayoutInfo:Fo,PipelineLayout:zo,RasterizerState:to,DepthStencilState:no,BlendTarget:io,BlendState:ro,InputState:ao,PipelineStateInfo:so,PipelineState:oo,FenceInfo:Uo,Fence:Go,QueueInfo:co,Queue:lo,ColorAttachment:uo,DepthStencilAttachment:ho,SubPassInfo:_o,RenderPassInfo:fo,RenderPass:po,SamplerInfo:mo,Sampler:go,ShaderStage:vo,Uniform:yo,UniformBlock:So,UniformSampler:Eo,ShaderInfo:To,Shader:Ao,TextureInfo:xo,TextureViewInfo:Co,IsPowerOf2:Ro,Texture:bo})),function(e){e[e.ALL=0]="ALL",e[e.CLOSEST=1]="CLOSEST",e[e.ANY=2]="ANY"}(ko||(ko={}));var jo,qo,Xo,Yo,Ko,Zo,Qo,Jo,$o=(jo=new bn(0,0,0),function(e,t){var n=bn.dot(e.d,t.n);if(Math.abs(n)<Number.EPSILON)return 0;bn.multiplyScalar(jo,t.n,t.d);var i=bn.dot(bn.subtract(jo,jo,e.o),t.n)/n;return i<0?0:i}),ec=(qo=new bn(0,0,0),Xo=new bn(0,0,0),Yo=new bn(0,0,0),Ko=new bn(0,0,0),Zo=new bn(0,0,0),function(e,t,n){bn.subtract(qo,t.b,t.a),bn.subtract(Xo,t.c,t.a),bn.cross(Yo,e.d,Xo);var i=bn.dot(qo,Yo);if(i<Number.EPSILON&&(!n||i>-Number.EPSILON))return 0;var r=1/i;bn.subtract(Ko,e.o,t.a);var a=bn.dot(Ko,Yo)*r;if(a<0||a>1)return 0;bn.cross(Zo,Ko,qo);var s=bn.dot(e.d,Zo)*r;if(s<0||a+s>1)return 0;var o=bn.dot(Xo,Zo)*r;return o<0?0:o}),tc=function(){var e=new bn(0,0,0);return function(t,n){var i=n.radius,r=n.center,a=t.o,s=t.d,o=i*i;bn.subtract(e,r,a);var c=e.lengthSqr(),l=bn.dot(e,s),u=o-(c-l*l);if(u<0)return 0;var h=Math.sqrt(u),_=c<o?l+h:l-h;return _<0?0:_}}(),nc=(Qo=new bn,Jo=new bn,function(e,t){return bn.subtract(Qo,t.center,t.halfExtents),bn.add(Jo,t.center,t.halfExtents),ic(e,Qo,Jo)});function ic(e,t,n){var i=e.o,r=e.d,a=1/r.x,s=1/r.y,o=1/r.z,c=(t.x-i.x)*a,l=(n.x-i.x)*a,u=(t.y-i.y)*s,h=(n.y-i.y)*s,_=(t.z-i.z)*o,f=(n.z-i.z)*o,d=Math.max(Math.max(Math.min(c,l),Math.min(u,h)),Math.min(_,f)),p=Math.min(Math.min(Math.max(c,l),Math.max(u,h)),Math.max(_,f));return p<0||d>p?0:d>0?d:p}var rc,ac,sc,oc,cc=function(){var e=new bn,t=new bn,n=new bn,i=new bn,r=new bn,a=new bn,s=new bn,o=new Array(3),c=new Array(3),l=new Array(3),u=new Array(6);return function(h,_){o[0]=_.halfExtents.x,o[1]=_.halfExtents.y,o[2]=_.halfExtents.z,e=_.center,t=h.o,n=h.d,bn.set(i,_.orientation.m00,_.orientation.m01,_.orientation.m02),bn.set(r,_.orientation.m03,_.orientation.m04,_.orientation.m05),bn.set(a,_.orientation.m06,_.orientation.m07,_.orientation.m08),bn.subtract(s,e,t),c[0]=bn.dot(i,n),c[1]=bn.dot(r,n),c[2]=bn.dot(a,n),l[0]=bn.dot(i,s),l[1]=bn.dot(r,s),l[2]=bn.dot(a,s);for(var f=0;f<3;++f){if(0===c[f]){if(-l[f]-o[f]>0||-l[f]+o[f]<0)return 0;c[f]=1e-7}u[2*f+0]=(l[f]+o[f])/c[f],u[2*f+1]=(l[f]-o[f])/c[f]}var d=Math.max(Math.max(Math.min(u[0],u[1]),Math.min(u[2],u[3])),Math.min(u[4],u[5])),p=Math.min(Math.min(Math.max(u[0],u[1]),Math.max(u[2],u[3])),Math.max(u[4],u[5]));return p<0||d>p?0:d>0?d:p}}(),lc=function(){var e=new bn,t=new bn,n=new bn,i=new bn,r=new bn,a=new bn,s=new bn,o=new Na;return function(c,l){var u=l.radius*l.radius,h=bn.normalize(e,c.d),_=l.ellipseCenter0,f=l.ellipseCenter1,d=bn.subtract(t,f,_);if(d.equals(bn.ZERO))return o.radius=l.radius,o.center.set(l.ellipseCenter0),Xc.raySphere(c,o);var p=c.o,m=bn.subtract(n,p,_),g=bn.cross(i,h,d),v=g.lengthSqr();if(0===v){o.radius=l.radius;var y=bn.subtract(r,f,p);return m.lengthSqr()<y.lengthSqr()?o.center.set(l.ellipseCenter0):o.center.set(l.ellipseCenter1),Xc.raySphere(c,o)}var S=bn.cross(r,m,d),E=d.lengthSqr(),T=2*bn.dot(g,S),A=T*T-4*v*(S.lengthSqr()-u*E);if(A<0)return 0;var x=(-T-Math.sqrt(A))/(2*v);if(x<0){o.radius=l.radius;var C=bn.subtract(a,f,p);return m.lengthSqr()<C.lengthSqr()?o.center.set(l.ellipseCenter0):o.center.set(l.ellipseCenter1),Xc.raySphere(c,o)}var R=bn.scaleAndAdd(a,c.o,h,x),b=bn.subtract(s,R,_),w=bn.dot(b,d)/E;return w>=0&&w<=1?x:w<0?(o.radius=l.radius,o.center.set(l.ellipseCenter0),Xc.raySphere(c,o)):w>1?(o.radius=l.radius,o.center.set(l.ellipseCenter1),Xc.raySphere(c,o)):0}}(),uc=(rc=Da.create(),ac={distance:1/0,doubleSided:!1,mode:ko.ANY},sc=0,oc=function(e,t,n,i,r,a){e===ko.CLOSEST?(sc>t||0===sc)&&(sc=t,a&&(0===a.length?a.push({distance:t,vertexIndex0:n/3,vertexIndex1:i/3,vertexIndex2:r/3}):(a[0].distance=t,a[0].vertexIndex0=n/3,a[0].vertexIndex1=i/3,a[0].vertexIndex2=r/3))):(sc=t,a&&a.push({distance:t,vertexIndex0:n/3,vertexIndex1:i/3,vertexIndex2:r/3}))},function(e,t,n){if(sc=0,0===t.geometricInfo.positions.length)return sc;var i=void 0===n?ac:n;if(ic(e,t.geometricInfo.boundingBox.min,t.geometricInfo.boundingBox.max)){var r=t.primitiveMode,a=t.geometricInfo;!function(e,t,n,i,r){if(n===Va.TRIANGLE_LIST)for(var a=t.length,s=0;s<a;s+=3){var o=3*t[s],c=3*t[s+1],l=3*t[s+2];bn.set(rc.a,e[o],e[o+1],e[o+2]),bn.set(rc.b,e[c],e[c+1],e[c+2]),bn.set(rc.c,e[l],e[l+1],e[l+2]);var u=Xc.rayTriangle(i,rc,r.doubleSided);if(!(0===u||u>r.distance)&&(oc(r.mode,u,o,c,l,r.result),r.mode===ko.ANY))return u}else if(n===Va.TRIANGLE_STRIP)for(var h=t.length-2,_=0,f=0;f<h;f+=1){var d=3*t[f-_],p=3*t[f+_+1],m=3*t[f+2];bn.set(rc.a,e[d],e[d+1],e[d+2]),bn.set(rc.b,e[p],e[p+1],e[p+2]),bn.set(rc.c,e[m],e[m+1],e[m+2]),_=~_;var g=Xc.rayTriangle(i,rc,r.doubleSided);if(!(0===g||g>r.distance)&&(oc(r.mode,g,d,p,m,r.result),r.mode===ko.ANY))return g}else if(n===Va.TRIANGLE_FAN){var v=t.length-1,y=3*t[0];bn.set(rc.a,e[y],e[y+1],e[y+2]);for(var S=1;S<v;S+=1){var E=3*t[S],T=3*t[S+1];bn.set(rc.b,e[E],e[E+1],e[E+2]),bn.set(rc.c,e[T],e[T+1],e[T+2]);var A=Xc.rayTriangle(i,rc,r.doubleSided);if(!(0===A||A>r.distance)&&(oc(r.mode,A,y,E,T,r.result),r.mode===ko.ANY))return A}}}(a.positions,a.indices,r,e,i)}return sc}),hc=function(){var e=0,t={distance:1/0,doubleSided:!1,mode:ko.ANY};return function(n,i,r){e=0;var a=void 0===r?t:r,s=i.renderingSubMeshes.length,o=i.struct.minPosition,c=i.struct.maxPosition;if(o&&c&&!ic(n,o,c))return e;for(var l=0;l<s;l++){var u=i.renderingSubMeshes[l],h=uc(n,u,a);if(h)if(a.mode===ko.CLOSEST)(0===e||e>h)&&(e=h,a.subIndices&&(a.subIndices[0]=l));else if(e=h,a.subIndices&&a.subIndices.push(l),a.mode===ko.ANY)return h}return e&&a.mode===ko.CLOSEST&&(a.result&&(a.result[0].distance=e,a.result.length=1),a.subIndices&&(a.subIndices.length=1)),e}}(),_c=function(){var e=0,t={distance:1/0,doubleSided:!1,mode:ko.ANY},n=new Ra,i=new Hn;return function(r,a,s){e=0;var o=void 0===s?t:s,c=a.worldBounds;if(c&&!nc(r,c))return e;Ra.copy(n,r),a.node&&(Hn.invert(i,a.node.getWorldMatrix(i)),bn.transformMat4(n.o,r.o,i),bn.transformMat4Normal(n.d,r.d,i));for(var l=a.subModels,u=0;u<l.length;u++){var h=l[u].subMesh,_=uc(n,h,o);if(_)if(o.mode===ko.CLOSEST)(0===e||e>_)&&(e=_,o.subIndices&&(o.subIndices[0]=u));else if(e=_,o.subIndices&&o.subIndices.push(u),o.mode===ko.ANY)return _}return e&&o.mode===ko.CLOSEST&&(o.result&&(o.result[0].distance=e,o.result.length=1),o.subIndices&&(o.subIndices.length=1)),e}}(),fc=function(){var e=new bn(0,0,0);return function(t,n){bn.subtract(e,t.e,t.s);var i=(n.d-bn.dot(t.s,n.n))/bn.dot(e,n.n);return i<0||i>1?0:i}}(),dc=function(){var e=new bn(0,0,0),t=new bn(0,0,0),n=new bn(0,0,0),i=new bn(0,0,0),r=new bn(0,0,0),a=new bn(0,0,0);return function(s,o,c){bn.subtract(e,o.b,o.a),bn.subtract(t,o.c,o.a),bn.subtract(n,s.s,s.e),bn.cross(r,e,t);var l=bn.dot(n,r);if(l<=0)return 0;bn.subtract(i,s.s,o.a);var u=bn.dot(i,r);if(u<0||u>l)return 0;bn.cross(a,n,i);var h=bn.dot(t,a);if(h<0||h>l)return 0;var _=-bn.dot(e,a);if(_<0||h+_>l)return 0;if(c){var f=1/l,d=1-(h*=f)-(_*=f);bn.set(c,o.a.x*d+o.b.x*h+o.c.x*_,o.a.y*d+o.b.y*h+o.c.y*_,o.a.z*d+o.b.z*h+o.c.z*_)}return 1}}(),pc=new Ra;function mc(e,t){pc.o.set(e.s),bn.subtract(pc.d,e.e,e.s),pc.d.normalize();var n=nc(pc,t);return n<=e.length()?n:0}function gc(e,t){pc.o.set(e.s),bn.subtract(pc.d,e.e,e.s),pc.d.normalize();var n=cc(pc,t);return n<=e.length()?n:0}function vc(e,t){pc.o.set(e.s),bn.subtract(pc.d,e.e,e.s),pc.d.normalize();var n=tc(pc,t);return n<=e.length()?n:0}var yc,Sc,Ec,Tc,Ac=(yc=new bn,Sc=new bn,Ec=new bn,Tc=new bn,function(e,t){return bn.subtract(yc,e.center,e.halfExtents),bn.add(Sc,e.center,e.halfExtents),bn.subtract(Ec,t.center,t.halfExtents),bn.add(Tc,t.center,t.halfExtents),yc.x<=Tc.x&&Sc.x>=Ec.x&&yc.y<=Tc.y&&Sc.y>=Ec.y&&yc.z<=Tc.z&&Sc.z>=Ec.z});function xc(e,t,n,i,r,a){bn.set(a[0],e.x+n.x*t.x+i.x*t.y+r.x*t.z,e.y+n.y*t.x+i.y*t.y+r.y*t.z,e.z+n.z*t.x+i.z*t.y+r.z*t.z),bn.set(a[1],e.x-n.x*t.x+i.x*t.y+r.x*t.z,e.y-n.y*t.x+i.y*t.y+r.y*t.z,e.z-n.z*t.x+i.z*t.y+r.z*t.z),bn.set(a[2],e.x+n.x*t.x-i.x*t.y+r.x*t.z,e.y+n.y*t.x-i.y*t.y+r.y*t.z,e.z+n.z*t.x-i.z*t.y+r.z*t.z),bn.set(a[3],e.x+n.x*t.x+i.x*t.y-r.x*t.z,e.y+n.y*t.x+i.y*t.y-r.y*t.z,e.z+n.z*t.x+i.z*t.y-r.z*t.z),bn.set(a[4],e.x-n.x*t.x-i.x*t.y-r.x*t.z,e.y-n.y*t.x-i.y*t.y-r.y*t.z,e.z-n.z*t.x-i.z*t.y-r.z*t.z),bn.set(a[5],e.x+n.x*t.x-i.x*t.y-r.x*t.z,e.y+n.y*t.x-i.y*t.y-r.y*t.z,e.z+n.z*t.x-i.z*t.y-r.z*t.z),bn.set(a[6],e.x-n.x*t.x+i.x*t.y-r.x*t.z,e.y-n.y*t.x+i.y*t.y-r.y*t.z,e.z-n.z*t.x+i.z*t.y-r.z*t.z),bn.set(a[7],e.x-n.x*t.x-i.x*t.y+r.x*t.z,e.y-n.y*t.x-i.y*t.y+r.y*t.z,e.z-n.z*t.x-i.z*t.y+r.z*t.z)}function Cc(e,t){for(var n=bn.dot(t,e[0]),i=n,r=1;r<8;++r){var a=bn.dot(t,e[r]);n=a<n?a:n,i=a>i?a:i}return[n,i]}var Rc,bc,wc,Ic=function(){for(var e=new Array(15),t=0;t<15;t++)e[t]=new bn(0,0,0);for(var n=new Array(8),i=new Array(8),r=0;r<8;r++)n[r]=new bn(0,0,0),i[r]=new bn(0,0,0);var a=new bn,s=new bn;return function(t,r){bn.set(e[0],1,0,0),bn.set(e[1],0,1,0),bn.set(e[2],0,0,1),bn.set(e[3],r.orientation.m00,r.orientation.m01,r.orientation.m02),bn.set(e[4],r.orientation.m03,r.orientation.m04,r.orientation.m05),bn.set(e[5],r.orientation.m06,r.orientation.m07,r.orientation.m08);for(var o=0;o<3;++o)bn.cross(e[6+3*o],e[o],e[0]),bn.cross(e[7+3*o],e[o],e[1]),bn.cross(e[7+3*o],e[o],e[2]);bn.subtract(a,t.center,t.halfExtents),bn.add(s,t.center,t.halfExtents),function(e,t,n){bn.set(n[0],e.x,t.y,t.z),bn.set(n[1],e.x,t.y,e.z),bn.set(n[2],e.x,e.y,t.z),bn.set(n[3],e.x,e.y,e.z),bn.set(n[4],t.x,t.y,t.z),bn.set(n[5],t.x,t.y,e.z),bn.set(n[6],t.x,e.y,t.z),bn.set(n[7],t.x,e.y,e.z)}(a,s,n),xc(r.center,r.halfExtents,e[3],e[4],e[5],i);for(var c=0;c<15;++c){var l=Cc(n,e[c]),u=Cc(i,e[c]);if(u[0]>l[1]||l[0]>u[1])return 0}return 1}}(),Oc=function(e,t){var n=e.halfExtents.x*Math.abs(t.n.x)+e.halfExtents.y*Math.abs(t.n.y)+e.halfExtents.z*Math.abs(t.n.z),i=bn.dot(t.n,e.center);return i+n<t.d?-1:i-n>t.d?0:1},Pc=function(e,t){for(var n=0;n<t.planes.length;n++)if(-1===Oc(e,t.planes[n]))return 0;return 1},Mc=function(){for(var e=new Array(8),t=0,n=0,i=0;i<e.length;i++)e[i]=new bn(0,0,0);return function(i,r){for(var a=0,s=!1,o=0;o<r.planes.length;o++){if(-1===(a=Oc(i,r.planes[o])))return 0;1===a&&(s=!0)}if(!s)return 1;for(var c=0;c<r.vertices.length;c++)bn.subtract(e[c],r.vertices[c],i.center);t=0,n=0;for(var l=0;l<r.vertices.length;l++)e[l].x>i.halfExtents.x?t++:e[l].x<-i.halfExtents.x&&n++;if(t===r.vertices.length||n===r.vertices.length)return 0;t=0,n=0;for(var u=0;u<r.vertices.length;u++)e[u].y>i.halfExtents.y?t++:e[u].y<-i.halfExtents.y&&n++;if(t===r.vertices.length||n===r.vertices.length)return 0;t=0,n=0;for(var h=0;h<r.vertices.length;h++)e[h].z>i.halfExtents.z?t++:e[h].z<-i.halfExtents.z&&n++;return t===r.vertices.length||n===r.vertices.length?0:1}}(),Nc=(Rc=new bn(0,0,0),bc=new Pn,function(e,t){return bn.subtract(Rc,t,e.center),bn.transformMat3(Rc,Rc,Pn.transpose(bc,e.orientation)),n=Rc,i=e.halfExtents,Math.abs(n.x)<i.x&&Math.abs(n.y)<i.y&&Math.abs(n.z)<i.z;var n,i}),Dc=(wc=function(e,t,n,i){return Math.abs(e.x*t+e.y*n+e.z*i)},function(e,t){var n=e.halfExtents.x*wc(t.n,e.orientation.m00,e.orientation.m01,e.orientation.m02)+e.halfExtents.y*wc(t.n,e.orientation.m03,e.orientation.m04,e.orientation.m05)+e.halfExtents.z*wc(t.n,e.orientation.m06,e.orientation.m07,e.orientation.m08),i=bn.dot(t.n,e.center);return i+n<t.d?-1:i-n>t.d?0:1}),Bc=function(e,t){for(var n=0;n<t.planes.length;n++)if(-1===Dc(e,t.planes[n]))return 0;return 1},Lc=function(){for(var e=new Array(8),t=0,n=0,i=0,r=0;r<e.length;r++)e[r]=new bn(0,0,0);var a=function(e,t,n,i){return e.x*t+e.y*n+e.z*i};return function(r,s){for(var o=0,c=!1,l=0;l<s.planes.length;l++){if(-1===(o=Dc(r,s.planes[l])))return 0;1===o&&(c=!0)}if(!c)return 1;for(var u=0;u<s.vertices.length;u++)bn.subtract(e[u],s.vertices[u],r.center);n=0,i=0;for(var h=0;h<s.vertices.length;h++)(t=a(e[h],r.orientation.m00,r.orientation.m01,r.orientation.m02))>r.halfExtents.x?n++:t<-r.halfExtents.x&&i++;if(n===s.vertices.length||i===s.vertices.length)return 0;n=0,i=0;for(var _=0;_<s.vertices.length;_++)(t=a(e[_],r.orientation.m03,r.orientation.m04,r.orientation.m05))>r.halfExtents.y?n++:t<-r.halfExtents.y&&i++;if(n===s.vertices.length||i===s.vertices.length)return 0;n=0,i=0;for(var f=0;f<s.vertices.length;f++)(t=a(e[f],r.orientation.m06,r.orientation.m07,r.orientation.m08))>r.halfExtents.z?n++:t<-r.halfExtents.z&&i++;return n===s.vertices.length||i===s.vertices.length?0:1}}(),Fc=function(){for(var e=new Array(15),t=0;t<15;t++)e[t]=new bn(0,0,0);for(var n=new Array(8),i=new Array(8),r=0;r<8;r++)n[r]=new bn(0,0,0),i[r]=new bn(0,0,0);return function(t,r){bn.set(e[0],t.orientation.m00,t.orientation.m01,t.orientation.m02),bn.set(e[1],t.orientation.m03,t.orientation.m04,t.orientation.m05),bn.set(e[2],t.orientation.m06,t.orientation.m07,t.orientation.m08),bn.set(e[3],r.orientation.m00,r.orientation.m01,r.orientation.m02),bn.set(e[4],r.orientation.m03,r.orientation.m04,r.orientation.m05),bn.set(e[5],r.orientation.m06,r.orientation.m07,r.orientation.m08);for(var a=0;a<3;++a)bn.cross(e[6+3*a],e[a],e[0]),bn.cross(e[7+3*a],e[a],e[1]),bn.cross(e[7+3*a],e[a],e[2]);xc(t.center,t.halfExtents,e[0],e[1],e[2],n),xc(r.center,r.halfExtents,e[3],e[4],e[5],i);for(var s=0;s<15;++s){var o=Cc(n,e[s]),c=Cc(i,e[s]);if(c[0]>o[1]||o[0]>c[1])return 0}return 1}}(),zc=function(){for(var e=new Na,t=new bn,n=new bn,i=new bn,r=new Array(8),a=0;a<8;a++)r[a]=new bn;for(var s=new Array(8),o=0;o<8;o++)s[o]=new bn;return function(a,o){if(0===bn.squaredDistance(o.ellipseCenter0,o.ellipseCenter1))return e.radius=o.radius,e.center.set(o.ellipseCenter0),Xc.sphereOBB(e,a);t.x=a.orientation.m00,t.y=a.orientation.m01,t.z=a.orientation.m02,n.x=a.orientation.m03,n.y=a.orientation.m04,n.z=a.orientation.m05,i.x=a.orientation.m06,i.y=a.orientation.m07,i.z=a.orientation.m08,xc(a.center,a.halfExtents,t,n,i,r);var c=s,l=bn.copy(c[0],t),u=bn.copy(c[1],n),h=bn.copy(c[2],i);bn.subtract(c[3],o.center,a.center).normalize();var _=bn.subtract(c[4],o.ellipseCenter0,o.ellipseCenter1);_.normalize(),bn.cross(c[5],l,_),bn.cross(c[6],u,_),bn.cross(c[7],h,_);for(var f=0;f<8;++f){var d=Cc(r,c[f]),p=bn.dot(c[f],o.ellipseCenter0),m=bn.dot(c[f],o.ellipseCenter1),g=Math.max(p,m),v=Math.min(p,m)-o.radius,y=g+o.radius;if(v>d[1]||d[0]>y)return 0}return 1}}(),Uc=function(e,t){var n=bn.dot(t.n,e.center),i=e.radius*t.n.length();return n+i<t.d?-1:n-i>t.d?0:1},Gc=function(e,t){for(var n=0;n<t.planes.length;n++)if(-1===Uc(e,t.planes[n]))return 0;return 1},kc=function(){var e=new bn(0,0,0),t=[1,-1,1,-1,1,-1];return function(n,i){for(var r=0;r<6;r++){var a=i.planes[r],s=n.radius,o=n.center,c=a.n,l=a.d,u=bn.dot(c,o);if(u+s<l)return 0;if(!(u-s>l)){bn.add(e,o,bn.multiplyScalar(e,c,s));for(var h=0;h<6;h++)if(h!==r&&h!==r+t[r]){var _=i.planes[h];if(bn.dot(_.n,e)<_.d)return 0}}}return 1}}(),Hc=function(e,t){var n=e.radius+t.radius;return bn.squaredDistance(e.center,t.center)<n*n},Vc=function(){var e=new bn;return function(t,n){return Ea(e,t.center,n),bn.squaredDistance(t.center,e)<t.radius*t.radius}}(),Wc=function(){var e=new bn;return function(t,n){return Ta(e,t.center,n),bn.squaredDistance(t.center,e)<t.radius*t.radius}}(),jc=function(){var e=new bn,t=new bn;return function(n,i){var r=n.radius+i.radius,a=r*r,s=bn.squaredDistance(i.ellipseCenter0,i.ellipseCenter1);if(0===s)return bn.squaredDistance(n.center,i.center)<a;bn.subtract(e,n.center,i.ellipseCenter0),bn.subtract(t,i.ellipseCenter1,i.ellipseCenter0);var o=bn.dot(e,t)/s;return o<0?bn.squaredDistance(n.center,i.ellipseCenter0)<a:o>1?bn.squaredDistance(n.center,i.ellipseCenter1)<a:(bn.scaleAndAdd(e,i.ellipseCenter0,t,o),bn.squaredDistance(n.center,e)<a)}}(),qc=function(){var e=new bn,t=new bn,n=new bn,i=new bn,r=new bn,a=new bn;return function(s,o){var c,l,u,h,_=bn.subtract(e,s.ellipseCenter1,s.ellipseCenter0),f=bn.subtract(t,o.ellipseCenter1,o.ellipseCenter0),d=bn.subtract(n,s.ellipseCenter0,o.ellipseCenter0),p=bn.dot(_,_),m=bn.dot(_,f),g=bn.dot(f,f),v=bn.dot(_,d),y=bn.dot(f,d),S=p*g-m*m,E=S,T=S;S<an?(l=0,E=1,h=y,T=g):(h=p*y-m*v,(l=m*y-g*v)<0?(l=0,h=y,T=g):l>E&&(l=E,h=y+m,T=g)),h<0?(h=0,-v<0?l=0:-v>p?l=E:(l=-v,E=p)):h>T&&(h=T,-v+m<0?l=0:-v+m>p?l=E:(l=-v+m,E=p)),c=Math.abs(l)<an?0:l/E,u=Math.abs(h)<an?0:h/T;var A=i;A.set(d),A.add(bn.multiplyScalar(r,_,c)),A.subtract(bn.multiplyScalar(a,f,u));var x=s.radius+o.radius;return A.lengthSqr()<x*x}}(),Xc={raySphere:tc,rayAABB:nc,rayOBB:cc,rayPlane:$o,rayTriangle:ec,rayCapsule:lc,raySubMesh:uc,rayMesh:hc,rayModel:_c,lineSphere:vc,lineAABB:mc,lineOBB:gc,linePlane:fc,lineTriangle:dc,sphereWithSphere:Hc,sphereAABB:Vc,sphereOBB:Wc,spherePlane:Uc,sphereFrustum:Gc,sphereFrustumAccurate:kc,sphereCapsule:jc,aabbWithAABB:Ac,aabbWithOBB:Ic,aabbPlane:Oc,aabbFrustum:Pc,aabbFrustumAccurate:Mc,obbWithOBB:Fc,obbPlane:Dc,obbFrustum:Bc,obbFrustumAccurate:Lc,obbPoint:Nc,obbCapsule:zc,capsuleWithCapsule:qc,resolve:function(e,t,n){void 0===n&&(n=null);var i=e._type,r=t._type,a=this[i|r];return i<r?a(e,t,n):a(t,e,n)}};Xc[xa.SHAPE_RAY|xa.SHAPE_SPHERE]=tc,Xc[xa.SHAPE_RAY|xa.SHAPE_AABB]=nc,Xc[xa.SHAPE_RAY|xa.SHAPE_OBB]=cc,Xc[xa.SHAPE_RAY|xa.SHAPE_PLANE]=$o,Xc[xa.SHAPE_RAY|xa.SHAPE_TRIANGLE]=ec,Xc[xa.SHAPE_RAY|xa.SHAPE_CAPSULE]=lc,Xc[xa.SHAPE_LINE|xa.SHAPE_SPHERE]=vc,Xc[xa.SHAPE_LINE|xa.SHAPE_AABB]=mc,Xc[xa.SHAPE_LINE|xa.SHAPE_OBB]=gc,Xc[xa.SHAPE_LINE|xa.SHAPE_PLANE]=fc,Xc[xa.SHAPE_LINE|xa.SHAPE_TRIANGLE]=dc,Xc[xa.SHAPE_SPHERE]=Hc,Xc[xa.SHAPE_SPHERE|xa.SHAPE_AABB]=Vc,Xc[xa.SHAPE_SPHERE|xa.SHAPE_OBB]=Wc,Xc[xa.SHAPE_SPHERE|xa.SHAPE_PLANE]=Uc,Xc[xa.SHAPE_SPHERE|xa.SHAPE_FRUSTUM]=Gc,Xc[xa.SHAPE_SPHERE|xa.SHAPE_FRUSTUM_ACCURATE]=kc,Xc[xa.SHAPE_SPHERE|xa.SHAPE_CAPSULE]=jc,Xc[xa.SHAPE_AABB]=Ac,Xc[xa.SHAPE_AABB|xa.SHAPE_OBB]=Ic,Xc[xa.SHAPE_AABB|xa.SHAPE_PLANE]=Oc,Xc[xa.SHAPE_AABB|xa.SHAPE_FRUSTUM]=Pc,Xc[xa.SHAPE_AABB|xa.SHAPE_FRUSTUM_ACCURATE]=Mc,Xc[xa.SHAPE_OBB]=Fc,Xc[xa.SHAPE_OBB|xa.SHAPE_PLANE]=Dc,Xc[xa.SHAPE_OBB|xa.SHAPE_FRUSTUM]=Bc,Xc[xa.SHAPE_OBB|xa.SHAPE_FRUSTUM_ACCURATE]=Lc,Xc[xa.SHAPE_OBB|xa.SHAPE_CAPSULE]=zc,Xc[xa.SHAPE_CAPSULE]=qc,se(Ca.prototype,"line",[{name:"mag",newName:"len"},{name:"magnitude",newName:"len"}]),oe(Xc,"intersect",[{name:"line_quad"}]);var Yc=new bn(0,0,0),Kc=new bn(0,0,0),Zc=i.mat4(),Qc=i.v4(),Jc=function(){function e(e,t,n,i){void 0===e&&(e=0),void 0===t&&(t=1),void 0===n&&(n=0),void 0===i&&(i=0),this.n=void 0,this.d=void 0,this._type=void 0,this._type=xa.SHAPE_PLANE,this.n=new bn(e,t,n),this.d=i}return e.create=function(t,n,i,r){return new e(t,n,i,r)},e.clone=function(t){return new e(t.n.x,t.n.y,t.n.z,t.d)},e.copy=function(e,t){return bn.copy(e.n,t.n),e.d=t.d,e},e.fromPoints=function(e,t,n,i){return bn.subtract(Yc,n,t),bn.subtract(Kc,i,t),bn.normalize(e.n,bn.cross(e.n,Yc,Kc)),e.d=bn.dot(e.n,t),e},e.set=function(e,t,n,i,r){return e.n.x=t,e.n.y=n,e.n.z=i,e.d=r,e},e.fromNormalAndPoint=function(e,t,n){return bn.copy(e.n,t),e.d=bn.dot(t,n),e},e.normalize=function(e,t){var n=t.n.length();return bn.normalize(e.n,t.n),n>0&&(e.d=t.d/n),e},j(e,[{key:"type",get:function(){return this._type}},{key:"x",set:function(e){this.n.x=e},get:function(){return this.n.x}},{key:"y",set:function(e){this.n.y=e},get:function(){return this.n.y}},{key:"z",set:function(e){this.n.z=e},get:function(){return this.n.z}},{key:"w",set:function(e){this.d=e},get:function(){return this.d}}]),e.prototype.transform=function(e){Hn.invert(Zc,e),Hn.transpose(Zc,Zc),Zn.set(Qc,this.n.x,this.n.y,this.n.z,this.d),Zn.transformMat4(Qc,Qc,Zc),bn.set(this.n,Qc.x,Qc.y,Qc.z),this.d=Qc.w},e}(),$c=new bn,el=new bn,tl=new bn,nl=new bn,il=new Pn,rl=function(e,t,n){il.m00=Math.abs(n.m00),il.m01=Math.abs(n.m01),il.m02=Math.abs(n.m02),il.m03=Math.abs(n.m04),il.m04=Math.abs(n.m05),il.m05=Math.abs(n.m06),il.m06=Math.abs(n.m08),il.m07=Math.abs(n.m09),il.m08=Math.abs(n.m10),bn.transformMat3(e,t,il)},al=function(){function e(e,t,n,i,r,a){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=1),void 0===r&&(r=1),void 0===a&&(a=1),this.center=void 0,this.halfExtents=void 0,this._type=void 0,this._type=xa.SHAPE_AABB,this.center=new bn(e,t,n),this.halfExtents=new bn(i,r,a)}e.create=function(t,n,i,r,a,s){return new e(t,n,i,r,a,s)},e.clone=function(t){return new e(t.center.x,t.center.y,t.center.z,t.halfExtents.x,t.halfExtents.y,t.halfExtents.z)},e.copy=function(e,t){return bn.copy(e.center,t.center),bn.copy(e.halfExtents,t.halfExtents),e},e.fromPoints=function(e,t,n){return bn.add($c,n,t),bn.subtract(el,n,t),bn.multiplyScalar(e.center,$c,.5),bn.multiplyScalar(e.halfExtents,el,.5),e},e.set=function(e,t,n,i,r,a,s){return bn.set(e.center,t,n,i),bn.set(e.halfExtents,r,a,s),e},e.merge=function(t,n,i){return bn.subtract($c,n.center,n.halfExtents),bn.subtract(el,i.center,i.halfExtents),bn.add(tl,n.center,n.halfExtents),bn.add(nl,i.center,i.halfExtents),bn.max(nl,tl,nl),bn.min(tl,$c,el),e.fromPoints(t,tl,nl)},e.toBoundingSphere=function(e,t){t.getBoundary($c,el),e.center.set($c),e.radius=0,bn.subtract(tl,el,e.center);var n=tl.length(),i=.5*n;return e.radius+=i,bn.multiplyScalar(tl,tl,i/n),bn.add(e.center,e.center,tl),e},e.transform=function(e,t,n){return bn.transformMat4(e.center,t.center,n),rl(e.halfExtents,t.halfExtents,n),e},j(e,[{key:"type",get:function(){return this._type}}]);var t=e.prototype;return t.getBoundary=function(e,t){bn.subtract(e,this.center,this.halfExtents),bn.add(t,this.center,this.halfExtents)},t.transform=function(e,t,n,i,r){bn.transformMat4(r.center,this.center,e),rl(r.halfExtents,this.halfExtents,e)},t.clone=function(){return e.clone(this)},t.copy=function(t){return e.copy(this,t)},e}(),sl=new bn,ol=new bn,cl=new Pn,ll=function(){function e(e,t,n,i,r,a,s,o,c,l,u,h,_,f,d){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=1),void 0===r&&(r=1),void 0===a&&(a=1),void 0===s&&(s=1),void 0===o&&(o=0),void 0===c&&(c=0),void 0===l&&(l=0),void 0===u&&(u=1),void 0===h&&(h=0),void 0===_&&(_=0),void 0===f&&(f=0),void 0===d&&(d=1),this.center=void 0,this.halfExtents=void 0,this.orientation=void 0,this._type=void 0,this._type=xa.SHAPE_OBB,this.center=new bn(e,t,n),this.halfExtents=new bn(i,r,a),this.orientation=new Pn(s,o,c,l,u,h,_,f,d)}e.create=function(t,n,i,r,a,s,o,c,l,u,h,_,f,d,p){return new e(t,n,i,r,a,s,o,c,l,u,h,_,f,d,p)},e.clone=function(t){return new e(t.center.x,t.center.y,t.center.z,t.halfExtents.x,t.halfExtents.y,t.halfExtents.z,t.orientation.m00,t.orientation.m01,t.orientation.m02,t.orientation.m03,t.orientation.m04,t.orientation.m05,t.orientation.m06,t.orientation.m07,t.orientation.m08)},e.copy=function(e,t){return bn.copy(e.center,t.center),bn.copy(e.halfExtents,t.halfExtents),Pn.copy(e.orientation,t.orientation),e},e.fromPoints=function(e,t,n){return bn.multiplyScalar(e.center,bn.add(sl,t,n),.5),bn.multiplyScalar(e.halfExtents,bn.subtract(ol,n,t),.5),Pn.identity(e.orientation),e},e.set=function(e,t,n,i,r,a,s,o,c,l,u,h,_,f,d,p){return bn.set(e.center,t,n,i),bn.set(e.halfExtents,r,a,s),Pn.set(e.orientation,o,c,l,u,h,_,f,d,p),e},j(e,[{key:"type",get:function(){return this._type}}]);var t=e.prototype;return t.getBoundary=function(e,t){!function(e,t,n){cl.m00=Math.abs(n.m00),cl.m01=Math.abs(n.m01),cl.m02=Math.abs(n.m02),cl.m03=Math.abs(n.m03),cl.m04=Math.abs(n.m04),cl.m05=Math.abs(n.m05),cl.m06=Math.abs(n.m06),cl.m07=Math.abs(n.m07),cl.m08=Math.abs(n.m08),bn.transformMat3(e,t,cl)}(sl,this.halfExtents,this.orientation),bn.subtract(e,this.center,sl),bn.add(t,this.center,sl)},t.transform=function(e,t,n,i,r){bn.transformMat4(r.center,this.center,e),Pn.fromQuat(r.orientation,n),bn.multiply(r.halfExtents,this.halfExtents,i)},t.translateAndRotate=function(e,t,n){bn.transformMat4(n.center,this.center,e),Pn.fromQuat(n.orientation,t)},t.setScale=function(e,t){bn.multiply(t.halfExtents,this.halfExtents,e)},e}(),ul=function(){function e(e,t,n){void 0===e&&(e=.5),void 0===t&&(t=.5),void 0===n&&(n=1),this._type=void 0,this.radius=void 0,this.halfHeight=void 0,this.axis=void 0,this.center=void 0,this.rotation=void 0,this.ellipseCenter0=void 0,this.ellipseCenter1=void 0,this._type=xa.SHAPE_CAPSULE,this.radius=e,this.halfHeight=t,this.axis=n,this.center=new bn,this.rotation=new Dn,this.ellipseCenter0=new bn(0,t,0),this.ellipseCenter1=new bn(0,-t,0),this.updateCache()}j(e,[{key:"type",get:function(){return this._type}}]);var t=e.prototype;return t.transform=function(e,t,n,i,r){var a=i,s=An(a);r.radius=this.radius*Math.abs(s);var o=(this.halfHeight+this.radius)*Math.abs(a.y)-r.radius;o<0&&(o=0),r.halfHeight=o,bn.transformMat4(r.center,this.center,e),Dn.multiply(r.rotation,this.rotation,n),r.updateCache()},t.updateCache=function(){this.updateLocalCenter(),bn.transformQuat(this.ellipseCenter0,this.ellipseCenter0,this.rotation),bn.transformQuat(this.ellipseCenter1,this.ellipseCenter1,this.rotation),this.ellipseCenter0.add(this.center),this.ellipseCenter1.add(this.center)},t.updateLocalCenter=function(){var e=this.halfHeight;switch(this.axis){case 0:this.ellipseCenter0.set(e,0,0),this.ellipseCenter1.set(-e,0,0);break;case 1:this.ellipseCenter0.set(0,e,0),this.ellipseCenter1.set(0,-e,0);break;case 2:this.ellipseCenter0.set(0,0,e),this.ellipseCenter1.set(0,0,-e)}},e}(),hl=new Array(8);hl[0]=new bn(1,1,1),hl[1]=new bn(-1,1,1),hl[2]=new bn(-1,-1,1),hl[3]=new bn(1,-1,1),hl[4]=new bn(1,1,-1),hl[5]=new bn(-1,1,-1),hl[6]=new bn(-1,-1,-1),hl[7]=new bn(1,-1,-1);var _l,fl,dl,pl=function(){function e(){this._type=void 0,this.planes=void 0,this.vertices=void 0,this._type=xa.SHAPE_FRUSTUM,this.planes=new Array(6);for(var e=0;e<6;++e)this.planes[e]=Jc.create(0,0,0,0);this.vertices=new Array(8);for(var t=0;t<8;++t)this.vertices[t]=new bn}e.create=function(){return new e},e.clone=function(t){return e.copy(new e,t)},e.copy=function(e,t){e._type=t._type;for(var n=0;n<6;++n)Jc.copy(e.planes[n],t.planes[n]);for(var i=0;i<8;++i)bn.copy(e.vertices[i],t.vertices[i]);return e},j(e,[{key:"accurate",set:function(e){this._type=e?xa.SHAPE_FRUSTUM_ACCURATE:xa.SHAPE_FRUSTUM}},{key:"type",get:function(){return this._type}}]);var t=e.prototype;return t.update=function(e,t){if(bn.set(this.planes[0].n,e.m03+e.m00,e.m07+e.m04,e.m11+e.m08),this.planes[0].d=-(e.m15+e.m12),bn.set(this.planes[1].n,e.m03-e.m00,e.m07-e.m04,e.m11-e.m08),this.planes[1].d=-(e.m15-e.m12),bn.set(this.planes[2].n,e.m03+e.m01,e.m07+e.m05,e.m11+e.m09),this.planes[2].d=-(e.m15+e.m13),bn.set(this.planes[3].n,e.m03-e.m01,e.m07-e.m05,e.m11-e.m09),this.planes[3].d=-(e.m15-e.m13),bn.set(this.planes[4].n,e.m03+e.m02,e.m07+e.m06,e.m11+e.m10),this.planes[4].d=-(e.m15+e.m14),bn.set(this.planes[5].n,e.m03-e.m02,e.m07-e.m06,e.m11-e.m10),this.planes[5].d=-(e.m15-e.m14),this._type===xa.SHAPE_FRUSTUM_ACCURATE){for(var n=0;n<6;n++){var i=this.planes[n],r=1/i.n.length();bn.multiplyScalar(i.n,i.n,r),i.d*=r}for(var a=0;a<8;a++)bn.transformMat4(this.vertices[a],hl[a],t)}},t.transform=function(e){if(this._type===xa.SHAPE_FRUSTUM_ACCURATE){for(var t=0;t<8;t++)bn.transformMat4(this.vertices[t],this.vertices[t],e);Jc.fromPoints(this.planes[0],this.vertices[1],this.vertices[5],this.vertices[6]),Jc.fromPoints(this.planes[1],this.vertices[3],this.vertices[7],this.vertices[4]),Jc.fromPoints(this.planes[2],this.vertices[6],this.vertices[7],this.vertices[3]),Jc.fromPoints(this.planes[3],this.vertices[0],this.vertices[4],this.vertices[5]),Jc.fromPoints(this.planes[4],this.vertices[2],this.vertices[3],this.vertices[0]),Jc.fromPoints(this.planes[0],this.vertices[7],this.vertices[6],this.vertices[5])}},e}();function ml(e,t){if(t&&0!==e){for(var n=t.vertices,i=Cr.VERTICES,r=0;r<8;++r)Or.setVec3(e,i,n[r]),i+=3;for(var a=t.planes,s=Cr.PLANES,o=0;o<6;o++,s+=4)Or.setVec4(e,s,a[o])}}pl.createOrtho=(_l=new bn,function(e,t,n,i,r,a){var s=t/2,o=n/2;bn.set(_l,s,o,i),bn.transformMat4(e.vertices[0],_l,a),bn.set(_l,-s,o,i),bn.transformMat4(e.vertices[1],_l,a),bn.set(_l,-s,-o,i),bn.transformMat4(e.vertices[2],_l,a),bn.set(_l,s,-o,i),bn.transformMat4(e.vertices[3],_l,a),bn.set(_l,s,o,r),bn.transformMat4(e.vertices[4],_l,a),bn.set(_l,-s,o,r),bn.transformMat4(e.vertices[5],_l,a),bn.set(_l,-s,-o,r),bn.transformMat4(e.vertices[6],_l,a),bn.set(_l,s,-o,r),bn.transformMat4(e.vertices[7],_l,a),Jc.fromPoints(e.planes[0],e.vertices[1],e.vertices[6],e.vertices[5]),Jc.fromPoints(e.planes[1],e.vertices[3],e.vertices[4],e.vertices[7]),Jc.fromPoints(e.planes[2],e.vertices[6],e.vertices[3],e.vertices[7]),Jc.fromPoints(e.planes[3],e.vertices[0],e.vertices[5],e.vertices[4]),Jc.fromPoints(e.planes[4],e.vertices[2],e.vertices[0],e.vertices[3]),Jc.fromPoints(e.planes[0],e.vertices[7],e.vertices[5],e.vertices[6])}),function(e){e[e.Default=0]="Default",e[e.Normal=1]="Normal",e[e.Loop=2]="Loop",e[e.ShouldWrap=4]="ShouldWrap",e[e.Clamp=8]="Clamp",e[e.PingPong=22]="PingPong",e[e.Reverse=36]="Reverse"}(fl||(fl={})),function(e){e[e.Default=fl.Default]="Default",e[e.Normal=fl.Normal]="Normal",e[e.Reverse=fl.Reverse]="Reverse",e[e.Loop=fl.Loop]="Loop",e[e.LoopReverse=fl.Loop|fl.Reverse]="LoopReverse",e[e.PingPong=fl.PingPong]="PingPong",e[e.PingPongReverse=fl.PingPong|fl.Reverse]="PingPongReverse"}(dl||(dl={})),ht(dl);var gl=function(){function e(e){this.ratio=0,this.time=0,this.direction=1,this.stopped=!0,this.iterations=0,this.frameIndex=void 0,e&&this.set(e)}return e.prototype.set=function(e){this.ratio=e.ratio,this.time=e.time,this.direction=e.direction,this.stopped=e.stopped,this.iterations=e.iterations,this.frameIndex=e.frameIndex},e}(),vl=ct({Default:fl.Default,Normal:fl.Normal,Clamp:fl.Clamp,Loop:fl.Loop,PingPong:fl.PingPong}),yl=function(){this.time=0,this.value=0,this.inTangent=0,this.outTangent=0};$t.fastDefine("cc.Keyframe",yl,{time:0,value:0,inTangent:0,outTangent:0});var Sl=function(){function e(){this.index=void 0,this.time=void 0,this.endTime=void 0,this.coefficient=void 0,this.index=-1,this.time=0,this.endTime=0,this.coefficient=new Float32Array(4)}return e.prototype.evaluate=function(e){return t=e-this.time,n=this.coefficient,t*(t*(t*n[0]+n[1])+n[2])+n[3];var t,n},e}(),El=function(){function e(t){void 0===t&&(t=null),this.keyFrames=void 0,this.preWrapMode=vl.Loop,this.postWrapMode=vl.Clamp,this.cachedKey=void 0,this.keyFrames=t||[].concat(e.defaultKF),this.cachedKey=new Sl}var t=e.prototype;return t.addKey=function(e){null==this.keyFrames&&(this.keyFrames=[]),this.keyFrames.push(e)},t.evaluate_slow=function(e){var t=e,n=e<0?this.preWrapMode:this.postWrapMode,i=this.keyFrames[0].time,r=this.keyFrames[this.keyFrames.length-1].time;switch(n){case vl.Loop:t=Sn(e-i,r-i)+i;break;case vl.PingPong:t=En(e-i,r-i)+i;break;case vl.Default:case vl.Normal:case vl.Clamp:default:t=cn(e,i,r)}var a=0;if(t>this.keyFrames[0].time)if(t>=this.keyFrames[this.keyFrames.length-1].time)a=this.keyFrames.length-2;else for(var s=0;s<this.keyFrames.length-1;s++)if(t>=this.keyFrames[0].time&&t<=this.keyFrames[s+1].time){a=s;break}var o=this.keyFrames[a],c=this.keyFrames[a+1],l=Tn(o.time,c.time,t),u=c.time-o.time,h=o.outTangent*u,_=c.inTangent*u,f=l*l,d=f*l,p=d-2*f+l,m=d-f,g=-2*d+3*f;return(2*d-3*f+1)*o.value+p*h+m*_+g*c.value},t.evaluate=function(e){var t=e,n=e<0?this.preWrapMode:this.postWrapMode,i=this.keyFrames[0].time,r=this.keyFrames[this.keyFrames.length-1].time;switch(n){case vl.Loop:t=Sn(e-i,r-i)+i;break;case vl.PingPong:t=En(e-i,r-i)+i;break;case vl.Default:case vl.Normal:case vl.Clamp:default:t=cn(e,i,r)}if(t>=this.cachedKey.time&&t<this.cachedKey.endTime)return this.cachedKey.evaluate(t);var a=this.findIndex(this.cachedKey,t),s=Math.min(a+1,this.keyFrames.length-1);return this.calcOptimizedKey(this.cachedKey,a,s),this.cachedKey.evaluate(t)},t.calcOptimizedKey=function(e,t,n){var i=this.keyFrames[t],r=this.keyFrames[n];e.index=t,e.time=i.time,e.endTime=r.time;var a=r.time-i.time,s=r.value-i.value,o=1/(a*a),c=i.outTangent*a,l=r.inTangent*a;e.coefficient[0]=(c+l-s-s)*o/a,e.coefficient[1]=(s+s+s-c-c-l)*o,e.coefficient[2]=i.outTangent,e.coefficient[3]=i.value},t.findIndex=function(e,t){var n=e.index;if(-1!==n)if(t>this.keyFrames[n].time)for(var i=0;i<3;i++){var r=n+i;if(r+1<this.keyFrames.length&&this.keyFrames[r+1].time>t)return r}else for(var a=0;a<3;a++){var s=n-a;if(s>=0&&this.keyFrames[s-1].time<=t)return s-1}for(var o,c=0,l=this.keyFrames.length;l-c>1;)o=Math.floor((c+l)/2),this.keyFrames[o].time>=t?l=o:c=o;return c},e}();function Tl(e,t){console.warn(e+" is deprecated, please use "+t+" instead.")}El.defaultKF=[{time:0,value:1,inTangent:0,outTangent:0},{time:1,value:1,inTangent:0,outTangent:0}],$t.fastDefine("cc.AnimationCurve",El,{preWrapMode:vl.Default,postWrapMode:vl.Default,keyFrames:[]}),se(Xc,"intersect",[{name:"ray_aabb",newName:"rayAABB"},{name:"ray_plane",newName:"rayPlane"},{name:"ray_triangle",newName:"rayTriangle"},{name:"ray_sphere",newName:"raySphere"},{name:"ray_obb",newName:"rayOBB"},{name:"ray_capsule",newName:"rayCapsule"},{name:"ray_subMesh",newName:"raySubMesh"},{name:"ray_mesh",newName:"rayMesh"},{name:"ray_model",newName:"rayModel"},{name:"line_plane",newName:"linePlane"},{name:"line_triangle",newName:"lineTriangle"},{name:"line_aabb",newName:"lineAABB"},{name:"line_obb",newName:"lineOBB"},{name:"line_sphere",newName:"lineSphere"},{name:"aabb_aabb",newName:"aabbWithAABB"},{name:"aabb_obb",newName:"aabbWithOBB"},{name:"aabb_plane",newName:"aabbPlane"},{name:"aabb_frustum",newName:"aabbFrustum"},{name:"aabbFrustum_accurate",newName:"aabbFrustumAccurate"},{name:"obb_point",newName:"obbPoint"},{name:"obb_plane",newName:"obbPlane"},{name:"obb_frustum",newName:"obbFrustum"},{name:"obbFrustum_accurate",newName:"obbFrustumAccurate"},{name:"obb_obb",newName:"obbWithOBB"},{name:"obb_capsule",newName:"obbCapsule"},{name:"sphere_plane",newName:"spherePlane"},{name:"sphere_frustum",newName:"sphereFrustum"},{name:"sphereFrustum_accurate",newName:"sphereFrustumAccurate"},{name:"sphere_sphere",newName:"sphereWithSphere"},{name:"sphere_aabb",newName:"sphereAABB"},{name:"sphere_obb",newName:"sphereOBB"},{name:"sphere_capsule",newName:"sphereCapsule"},{name:"capsule_capsule",newName:"capsuleWithCapsule"}]);var Al=function(e){function t(){var t;return t=e.call(this)||this,Tl("line","Line"),t}return X(t,e),t}(Ca),xl=function(e){function t(){var t;return t=e.call(this)||this,Tl("plane","Plane"),t}return X(t,e),t}(Jc),Cl=function(e){function t(){var t;return t=e.call(this)||this,Tl("ray","Ray"),t}return X(t,e),t}(Ra),Rl=function(e){function t(){var t;return t=e.call(this)||this,Tl("triangle","Triangle"),t}return X(t,e),t}(Da),bl=function(e){function t(){var t;return t=e.call(this)||this,Tl("sphere","Sphere"),t}return X(t,e),t}(Na),wl=function(e){function t(){var t;return t=e.call(this)||this,Tl("aabb","AABB"),t}return X(t,e),t}(al),Il=function(e){function t(){var t;return t=e.call(this)||this,Tl("obb","OBB"),t}return X(t,e),t}(ll),Ol=function(e){function t(){var t;return t=e.call(this)||this,Tl("capsule","Capsule"),t}return X(t,e),t}(ul),Pl=function(e){function t(){var t;return t=e.call(this)||this,Tl("frustum","Frustum"),t}return X(t,e),t}(pl),Ml=Object.freeze({__proto__:null,distance:Aa,enums:xa,intersect:Xc,Line:Ca,Plane:Jc,Ray:Ra,Triangle:Da,Sphere:Na,AABB:al,OBB:ll,Capsule:ul,Frustum:pl,Keyframe:yl,AnimationCurve:El,get ERaycastMode(){return ko},line:Al,plane:xl,ray:Cl,triangle:Rl,sphere:bl,aabb:wl,obb:Il,capsule:Ol,frustum:Pl});e("geometry",Ml);var Nl,Dl,Bl={NONE:0,IGNORE_RAYCAST:1<<20,GIZMOS:1<<21,EDITOR:1<<22,UI_3D:1<<23,SCENE_GIZMO:1<<24,UI_2D:1<<25,PROFILER:1<<28,DEFAULT:1<<30,ALL:4294967295},Ll=e("Layers",function(){function e(){}return e.makeMaskInclude=function(e){for(var t,n=0,i=Z(e);!(t=i()).done;)n|=t.value;return n},e.makeMaskExclude=function(t){return~e.makeMaskInclude(t)},e.addLayer=function(t,n){void 0!==n?n>19||n<0?console.warn("maximum layers reached."):(e.Enum[t]=1<<n,e.Enum[n]=t,e.BitMask[t]=1<<n,e.BitMask[n]=t):console.warn("bitNum can't be undefined")},e.deleteLayer=function(t){t>19||t<0?console.warn("do not change buildin layers."):(delete e.Enum[e.Enum[t]],delete e.Enum[t],delete e.BitMask[e.BitMask[t]],delete e.BitMask[t])},e}());Ll.Enum=ct(Bl),Ll.BitMask=ot(q({},Bl)),i.Layers=Ll,function(e){e[e.DEFAULT=100]="DEFAULT",e[e.UI=200]="UI"}(Nl||(Nl={})),i.RenderPassStage=Nl,function(e){e[e.MIN=0]="MIN",e[e.MAX=255]="MAX",e[e.DEFAULT=128]="DEFAULT"}(Dl||(Dl={}));var Fl,zl={bindings:[],layouts:{}},Ul={bindings:[],layouts:{}};!function(e){e[e.UBO_GLOBAL=0]="UBO_GLOBAL",e[e.UBO_CAMERA=1]="UBO_CAMERA",e[e.UBO_SHADOW=2]="UBO_SHADOW",e[e.SAMPLER_SHADOWMAP=3]="SAMPLER_SHADOWMAP",e[e.SAMPLER_ENVIRONMENT=4]="SAMPLER_ENVIRONMENT",e[e.SAMPLER_SPOT_LIGHTING_MAP=5]="SAMPLER_SPOT_LIGHTING_MAP",e[e.COUNT=6]="COUNT"}(Fl||(Fl={}));var Gl,kl=Fl.SAMPLER_SHADOWMAP,Hl=Fl.COUNT-kl;!function(e){e[e.UBO_LOCAL=0]="UBO_LOCAL",e[e.UBO_FORWARD_LIGHTS=1]="UBO_FORWARD_LIGHTS",e[e.UBO_SKINNING_ANIMATION=2]="UBO_SKINNING_ANIMATION",e[e.UBO_SKINNING_TEXTURE=3]="UBO_SKINNING_TEXTURE",e[e.UBO_MORPH=4]="UBO_MORPH",e[e.SAMPLER_JOINTS=5]="SAMPLER_JOINTS",e[e.SAMPLER_MORPH_POSITION=6]="SAMPLER_MORPH_POSITION",e[e.SAMPLER_MORPH_NORMAL=7]="SAMPLER_MORPH_NORMAL",e[e.SAMPLER_MORPH_TANGENT=8]="SAMPLER_MORPH_TANGENT",e[e.SAMPLER_LIGHTMAP=9]="SAMPLER_LIGHTMAP",e[e.SAMPLER_SPRITE=10]="SAMPLER_SPRITE",e[e.COUNT=11]="COUNT"}(Gl||(Gl={}));var Vl,Wl=Gl.SAMPLER_JOINTS,jl=Gl.COUNT-Wl;!function(e){e[e.GLOBAL=0]="GLOBAL",e[e.MATERIAL=1]="MATERIAL",e[e.LOCAL=2]="LOCAL"}(Vl||(Vl={}));var ql=new Ls;ql.bufferOffsets=[0,kl+Wl,kl],ql.samplerOffsets=[-kl,Hl+jl,Hl-Wl],ql.flexibleSet=1;var Xl=function(){};Xl.SIZE=4*(Xl.COUNT=4+(Xl.SCREEN_SIZE_OFFSET=4+(Xl.NATIVE_SIZE_OFFSET=4+(Xl.TIME_OFFSET=0)))),Xl.NAME="CCGlobal",Xl.BINDING=Fl.UBO_GLOBAL,Xl.DESCRIPTOR=new No(Xl.BINDING,as.UNIFORM_BUFFER,1,rs.ALL),Xl.LAYOUT=new So(Vl.GLOBAL,Xl.BINDING,Xl.NAME,[new yo("cc_time",Fa.FLOAT4,1),new yo("cc_screenSize",Fa.FLOAT4,1),new yo("cc_nativeSize",Fa.FLOAT4,1)],1),zl.layouts[Xl.NAME]=Xl.LAYOUT,zl.bindings[Xl.BINDING]=Xl.DESCRIPTOR;var Yl=function(){};Yl.SIZE=4*(Yl.COUNT=4+(Yl.GLOBAL_FOG_ADD_OFFSET=4+(Yl.GLOBAL_FOG_BASE_OFFSET=4+(Yl.GLOBAL_FOG_COLOR_OFFSET=4+(Yl.AMBIENT_GROUND_OFFSET=4+(Yl.AMBIENT_SKY_OFFSET=4+(Yl.MAIN_LIT_COLOR_OFFSET=4+(Yl.MAIN_LIT_DIR_OFFSET=4+(Yl.EXPOSURE_OFFSET=4+(Yl.SCREEN_SCALE_OFFSET=4+(Yl.CAMERA_POS_OFFSET=16+(Yl.MAT_VIEW_PROJ_INV_OFFSET=16+(Yl.MAT_VIEW_PROJ_OFFSET=16+(Yl.MAT_PROJ_INV_OFFSET=16+(Yl.MAT_PROJ_OFFSET=16+(Yl.MAT_VIEW_INV_OFFSET=16+(Yl.MAT_VIEW_OFFSET=0))))))))))))))))),Yl.NAME="CCCamera",Yl.BINDING=Fl.UBO_CAMERA,Yl.DESCRIPTOR=new No(Yl.BINDING,as.UNIFORM_BUFFER,1,rs.ALL),Yl.LAYOUT=new So(Vl.GLOBAL,Yl.BINDING,Yl.NAME,[new yo("cc_matView",Fa.MAT4,1),new yo("cc_matViewInv",Fa.MAT4,1),new yo("cc_matProj",Fa.MAT4,1),new yo("cc_matProjInv",Fa.MAT4,1),new yo("cc_matViewProj",Fa.MAT4,1),new yo("cc_matViewProjInv",Fa.MAT4,1),new yo("cc_cameraPos",Fa.FLOAT4,1),new yo("cc_screenScale",Fa.FLOAT4,1),new yo("cc_exposure",Fa.FLOAT4,1),new yo("cc_mainLitDir",Fa.FLOAT4,1),new yo("cc_mainLitColor",Fa.FLOAT4,1),new yo("cc_ambientSky",Fa.FLOAT4,1),new yo("cc_ambientGround",Fa.FLOAT4,1),new yo("cc_fogColor",Fa.FLOAT4,1),new yo("cc_fogBase",Fa.FLOAT4,1),new yo("cc_fogAdd",Fa.FLOAT4,1)],1),zl.layouts[Yl.NAME]=Yl.LAYOUT,zl.bindings[Yl.BINDING]=Yl.DESCRIPTOR;var Kl=function(){};Kl.SIZE=4*(Kl.COUNT=4+(Kl.SHADOW_INFO_OFFSET=4+(Kl.SHADOW_COLOR_OFFSET=16+(Kl.MAT_LIGHT_VIEW_PROJ_OFFSET=16+(Kl.MAT_LIGHT_PLANE_PROJ_OFFSET=0))))),Kl.NAME="CCShadow",Kl.BINDING=Fl.UBO_SHADOW,Kl.DESCRIPTOR=new No(Kl.BINDING,as.UNIFORM_BUFFER,1,rs.ALL),Kl.LAYOUT=new So(Vl.GLOBAL,Kl.BINDING,Kl.NAME,[new yo("cc_matLightPlaneProj",Fa.MAT4,1),new yo("cc_matLightViewProj",Fa.MAT4,1),new yo("cc_shadowColor",Fa.FLOAT4,1),new yo("cc_shadowInfo",Fa.FLOAT4,1)],1),zl.layouts[Kl.NAME]=Kl.LAYOUT,zl.bindings[Kl.BINDING]=Kl.DESCRIPTOR;var Zl=Fl.SAMPLER_SHADOWMAP,Ql=new No(Zl,as.SAMPLER,1,rs.FRAGMENT),Jl=new Eo(Vl.GLOBAL,Zl,"cc_shadowMap",Fa.SAMPLER2D,1);zl.layouts.cc_shadowMap=Jl,zl.bindings[Zl]=Ql;var $l=Fl.SAMPLER_ENVIRONMENT,eu=new No($l,as.SAMPLER,1,rs.FRAGMENT),tu=new Eo(Vl.GLOBAL,$l,"cc_environment",Fa.SAMPLER_CUBE,1);zl.layouts.cc_environment=tu,zl.bindings[$l]=eu;var nu=Fl.SAMPLER_SPOT_LIGHTING_MAP,iu=new No(nu,as.SAMPLER,1,rs.FRAGMENT),ru=new Eo(Vl.GLOBAL,nu,"cc_spotLightingMap",Fa.SAMPLER2D,1);zl.layouts.cc_spotLightingMap=ru,zl.bindings[nu]=iu;var au=function(){};au.SIZE=4*(au.COUNT=4+(au.LIGHTINGMAP_UVPARAM=16+(au.MAT_WORLD_IT_OFFSET=16+(au.MAT_WORLD_OFFSET=0)))),au.NAME="CCLocal",au.BINDING=Gl.UBO_LOCAL,au.DESCRIPTOR=new No(au.BINDING,as.UNIFORM_BUFFER,1,rs.VERTEX),au.LAYOUT=new So(Vl.LOCAL,au.BINDING,au.NAME,[new yo("cc_matWorld",Fa.MAT4,1),new yo("cc_matWorldIT",Fa.MAT4,1),new yo("cc_lightingMapUVParam",Fa.FLOAT4,1)],1),Ul.layouts[au.NAME]=au.LAYOUT,Ul.bindings[au.BINDING]=au.DESCRIPTOR;var su=function(){};su.BATCHING_COUNT=10,su.MAT_WORLDS_OFFSET=0,su.SIZE=4*(su.COUNT=16*su.BATCHING_COUNT),su.NAME="CCLocalBatched",su.BINDING=Gl.UBO_LOCAL,su.DESCRIPTOR=new No(su.BINDING,as.UNIFORM_BUFFER,1,rs.VERTEX),su.LAYOUT=new So(Vl.LOCAL,su.BINDING,su.NAME,[new yo("cc_matWorlds",Fa.MAT4,su.BATCHING_COUNT)],1),Ul.layouts[su.NAME]=su.LAYOUT,Ul.bindings[su.BINDING]=su.DESCRIPTOR;var ou=function(){};ou.LIGHTS_PER_PASS=1,ou.SIZE=4*(ou.COUNT=(ou.LIGHT_DIR_OFFSET=(ou.LIGHT_SIZE_RANGE_ANGLE_OFFSET=(ou.LIGHT_COLOR_OFFSET=(ou.LIGHT_POS_OFFSET=0)+4*ou.LIGHTS_PER_PASS)+4*ou.LIGHTS_PER_PASS)+4*ou.LIGHTS_PER_PASS)+4*ou.LIGHTS_PER_PASS),ou.NAME="CCForwardLight",ou.BINDING=Gl.UBO_FORWARD_LIGHTS,ou.DESCRIPTOR=new No(ou.BINDING,as.DYNAMIC_UNIFORM_BUFFER,1,rs.FRAGMENT),ou.LAYOUT=new So(Vl.LOCAL,ou.BINDING,ou.NAME,[new yo("cc_lightPos",Fa.FLOAT4,ou.LIGHTS_PER_PASS),new yo("cc_lightColor",Fa.FLOAT4,ou.LIGHTS_PER_PASS),new yo("cc_lightSizeRangeAngle",Fa.FLOAT4,ou.LIGHTS_PER_PASS),new yo("cc_lightDir",Fa.FLOAT4,ou.LIGHTS_PER_PASS)],1),Ul.layouts[ou.NAME]=ou.LAYOUT,Ul.bindings[ou.BINDING]=ou.DESCRIPTOR;var cu=function(){};cu.SIZE=4*(cu.COUNT=4+(cu.JOINTS_TEXTURE_INFO_OFFSET=0)),cu.NAME="CCSkinningTexture",cu.BINDING=Gl.UBO_SKINNING_TEXTURE,cu.DESCRIPTOR=new No(cu.BINDING,as.UNIFORM_BUFFER,1,rs.VERTEX),cu.LAYOUT=new So(Vl.LOCAL,cu.BINDING,cu.NAME,[new yo("cc_jointTextureInfo",Fa.FLOAT4,1)],1),Ul.layouts[cu.NAME]=cu.LAYOUT,Ul.bindings[cu.BINDING]=cu.DESCRIPTOR;var lu=function(){};lu.SIZE=4*(lu.COUNT=4+(lu.JOINTS_ANIM_INFO_OFFSET=0)),lu.NAME="CCSkinningAnimation",lu.BINDING=Gl.UBO_SKINNING_ANIMATION,lu.DESCRIPTOR=new No(lu.BINDING,as.UNIFORM_BUFFER,1,rs.VERTEX),lu.LAYOUT=new So(Vl.LOCAL,lu.BINDING,lu.NAME,[new yo("cc_jointAnimInfo",Fa.FLOAT4,1)],1),Ul.layouts[lu.NAME]=lu.LAYOUT,Ul.bindings[lu.BINDING]=lu.DESCRIPTOR;var uu=function(){};uu.SIZE=4*(uu.COUNT=360+(uu.JOINTS_OFFSET=0)),uu.NAME="CCSkinning",uu.BINDING=Gl.UBO_SKINNING_TEXTURE,uu.DESCRIPTOR=new No(uu.BINDING,as.UNIFORM_BUFFER,1,rs.VERTEX),uu.LAYOUT=new So(Vl.LOCAL,uu.BINDING,uu.NAME,[new yo("cc_joints",Fa.FLOAT4,90)],1),Ul.layouts[uu.NAME]=uu.LAYOUT,Ul.bindings[uu.BINDING]=uu.DESCRIPTOR;var hu=function(){};hu.MAX_MORPH_TARGET_COUNT=60,hu.OFFSET_OF_WEIGHTS=0,hu.OFFSET_OF_VERTICES_COUNT=4+(hu.OFFSET_OF_DISPLACEMENT_TEXTURE_HEIGHT=4+(hu.OFFSET_OF_DISPLACEMENT_TEXTURE_WIDTH=4*hu.MAX_MORPH_TARGET_COUNT)),hu.COUNT_BASE_4_BYTES=4*Math.ceil(hu.MAX_MORPH_TARGET_COUNT/4)+4,hu.SIZE=4*hu.COUNT_BASE_4_BYTES,hu.NAME="CCMorph",hu.BINDING=Gl.UBO_MORPH,hu.DESCRIPTOR=new No(hu.BINDING,as.UNIFORM_BUFFER,1,rs.VERTEX),hu.LAYOUT=new So(Vl.LOCAL,hu.BINDING,hu.NAME,[new yo("cc_displacementWeights",Fa.FLOAT4,hu.MAX_MORPH_TARGET_COUNT/4),new yo("cc_displacementTextureInfo",Fa.FLOAT4,1)],1),Ul.layouts[hu.NAME]=hu.LAYOUT,Ul.bindings[hu.BINDING]=hu.DESCRIPTOR;var _u=Gl.SAMPLER_JOINTS,fu=new No(_u,as.SAMPLER,1,rs.VERTEX),du=new Eo(Vl.LOCAL,_u,"cc_jointTexture",Fa.SAMPLER2D,1);Ul.layouts.cc_jointTexture=du,Ul.bindings[_u]=fu;var pu=Gl.SAMPLER_MORPH_POSITION,mu=new No(pu,as.SAMPLER,1,rs.VERTEX),gu=new Eo(Vl.LOCAL,pu,"cc_PositionDisplacements",Fa.SAMPLER2D,1);Ul.layouts.cc_PositionDisplacements=gu,Ul.bindings[pu]=mu;var vu=Gl.SAMPLER_MORPH_NORMAL,yu=new No(vu,as.SAMPLER,1,rs.VERTEX),Su=new Eo(Vl.LOCAL,vu,"cc_NormalDisplacements",Fa.SAMPLER2D,1);Ul.layouts.cc_NormalDisplacements=Su,Ul.bindings[vu]=yu;var Eu=Gl.SAMPLER_MORPH_TANGENT,Tu=new No(Eu,as.SAMPLER,1,rs.VERTEX),Au=new Eo(Vl.LOCAL,Eu,"cc_TangentDisplacements",Fa.SAMPLER2D,1);Ul.layouts.cc_TangentDisplacements=Au,Ul.bindings[Eu]=Tu;var xu=Gl.SAMPLER_LIGHTMAP,Cu=new No(xu,as.SAMPLER,1,rs.FRAGMENT),Ru=new Eo(Vl.LOCAL,xu,"cc_lightingMap",Fa.SAMPLER2D,1);Ul.layouts.cc_lightingMap=Ru,Ul.bindings[xu]=Cu;var bu=Gl.SAMPLER_SPRITE,wu=new No(bu,as.SAMPLER,1,rs.FRAGMENT),Iu=new Eo(Vl.LOCAL,bu,"cc_spriteTexture",Fa.SAMPLER2D,1);Ul.layouts.cc_spriteTexture=Iu,Ul.bindings[bu]=wu;var Ou,Pu,Mu,Nu,Du,Bu=Ll.makeMaskExclude([Ll.BitMask.UI_2D,Ll.BitMask.GIZMOS,Ll.BitMask.EDITOR,Ll.BitMask.SCENE_GIZMO,Ll.BitMask.PROFILER]),Lu=Ll.makeMaskExclude([Ll.BitMask.UI_2D,Ll.BitMask.PROFILER]),Fu=Ll.Enum.ALL;e("pipeline",Object.freeze({__proto__:null,PIPELINE_FLOW_FORWARD:"ForwardFlow",PIPELINE_FLOW_SHADOW:"ShadowFlow",PIPELINE_FLOW_SMAA:"SMAAFlow",PIPELINE_FLOW_TONEMAP:"ToneMapFlow",get RenderPassStage(){return Nl},get RenderPriority(){return Dl},globalDescriptorSetLayout:zl,localDescriptorSetLayout:Ul,get PipelineGlobalBindings(){return Fl},get ModelLocalBindings(){return Gl},get SetIndex(){return Vl},bindingMappingInfo:ql,UBOGlobal:Xl,UBOCamera:Yl,UBOShadow:Kl,UNIFORM_SHADOWMAP_BINDING:Zl,UNIFORM_ENVIRONMENT_BINDING:$l,UNIFORM_SPOT_LIGHTING_MAP_TEXTURE_BINDING:nu,UBOLocal:au,INST_MAT_WORLD:"a_matWorld0",UBOLocalBatched:su,UBOForwardLight:ou,JOINT_UNIFORM_CAPACITY:30,UBOSkinningTexture:cu,UBOSkinningAnimation:lu,INST_JOINT_ANIM_INFO:"a_jointAnimInfo",UBOSkinning:uu,UBOMorph:hu,UNIFORM_JOINT_TEXTURE_BINDING:_u,UNIFORM_POSITION_MORPH_TEXTURE_BINDING:pu,UNIFORM_NORMAL_MORPH_TEXTURE_BINDING:vu,UNIFORM_TANGENT_MORPH_TEXTURE_BINDING:Eu,UNIFORM_LIGHTMAP_TEXTURE_BINDING:xu,UNIFORM_SPRITE_TEXTURE_BINDING:bu,CAMERA_DEFAULT_MASK:Bu,CAMERA_EDITOR_MASK:Lu,MODEL_ALWAYS_MASK:Fu})),function(e){e[e.VERTICAL=0]="VERTICAL",e[e.HORIZONTAL=1]="HORIZONTAL"}(Ou||(Ou={})),function(e){e[e.ORTHO=0]="ORTHO",e[e.PERSPECTIVE=1]="PERSPECTIVE"}(Pu||(Pu={})),function(e){e[e.F1_8=0]="F1_8",e[e.F2_0=1]="F2_0",e[e.F2_2=2]="F2_2",e[e.F2_5=3]="F2_5",e[e.F2_8=4]="F2_8",e[e.F3_2=5]="F3_2",e[e.F3_5=6]="F3_5",e[e.F4_0=7]="F4_0",e[e.F4_5=8]="F4_5",e[e.F5_0=9]="F5_0",e[e.F5_6=10]="F5_6",e[e.F6_3=11]="F6_3",e[e.F7_1=12]="F7_1",e[e.F8_0=13]="F8_0",e[e.F9_0=14]="F9_0",e[e.F10_0=15]="F10_0",e[e.F11_0=16]="F11_0",e[e.F13_0=17]="F13_0",e[e.F14_0=18]="F14_0",e[e.F16_0=19]="F16_0",e[e.F18_0=20]="F18_0",e[e.F20_0=21]="F20_0",e[e.F22_0=22]="F22_0"}(Mu||(Mu={})),function(e){e[e.ISO100=0]="ISO100",e[e.ISO200=1]="ISO200",e[e.ISO400=2]="ISO400",e[e.ISO800=3]="ISO800"}(Nu||(Nu={})),function(e){e[e.D1=0]="D1",e[e.D2=1]="D2",e[e.D4=2]="D4",e[e.D8=3]="D8",e[e.D15=4]="D15",e[e.D30=5]="D30",e[e.D60=6]="D60",e[e.D125=7]="D125",e[e.D250=8]="D250",e[e.D500=9]="D500",e[e.D1000=10]="D1000",e[e.D2000=11]="D2000",e[e.D4000=12]="D4000"}(Du||(Du={}));var zu,Uu,Gu=[1.8,2,2.2,2.5,2.8,3.2,3.5,4,4.5,5,5.6,6.3,7.1,8,9,10,11,13,14,16,18,20,22],ku=[1,.5,1/4,1/8,1/15,1/30,1/60,.008,.004,.002,.001,5e-4,1/4e3],Hu=[100,200,400,800],Vu=new bn,Wu=new bn,ju=new Hn,qu=ds.STENCIL<<1,Xu=[],Yu=function(){function e(e){if(this.isWindowSize=!0,this.screenScale=void 0,this._device=void 0,this._scene=null,this._node=null,this._name=null,this._enabled=!1,this._proj=-1,this._aspect=void 0,this._orthoHeight=10,this._fovAxis=Ou.VERTICAL,this._fov=hn(45),this._nearClip=1,this._farClip=1e3,this._clearColor=new Ks(.2,.2,.2,1),this._viewport=new ti(0,0,1,1),this._curTransform=gs.IDENTITY,this._isProjDirty=!0,this._matView=new Hn,this._matViewInv=null,this._matProj=new Hn,this._matProjInv=new Hn,this._matViewProj=new Hn,this._matViewProjInv=new Hn,this._frustum=new pl,this._forward=new bn,this._position=new bn,this._priority=0,this._aperture=Mu.F16_0,this._apertureValue=void 0,this._shutter=Du.D125,this._shutterValue=0,this._iso=Nu.ISO100,this._isoValue=0,this._ec=0,this._poolHandle=0,this._frustumHandle=0,this._window=null,this._device=e,this._apertureValue=Gu[this._aperture],this._shutterValue=ku[this._shutter],this._isoValue=Hu[this._iso],this._aspect=this.screenScale=1,!Xu.length){var t=e.screenSpaceSignY;Xu[gs.IDENTITY]=new Hn(1,0,0,0,0,t),Xu[gs.ROTATE_90]=new Hn(0,1,0,0,-t,0),Xu[gs.ROTATE_180]=new Hn(-1,0,0,0,0,-t),Xu[gs.ROTATE_270]=new Hn(0,-1,0,0,t,0)}}var t=e.prototype;return t.initialize=function(e){this._name=e.name,this._node=e.node,this._proj=e.projection,this._priority=e.priority||0,this._aspect=this.screenScale=1;var t=this._poolHandle=vr.alloc();vr.set(t,fr.WIDTH,1),vr.set(t,fr.HEIGHT,1),vr.set(t,fr.CLEAR_FLAG,ds.NONE),vr.set(t,fr.CLEAR_DEPTH,1),vr.set(t,fr.NODE,this._node.handle),vr.set(t,fr.VISIBILITY,Bu),this._scene&&vr.set(t,fr.SCENE,this._scene.handle),this.updateExposure(),this.changeTargetWindow(e.window),console.log("Created Camera: "+this._name+" "+vr.get(t,fr.WIDTH)+"x"+vr.get(t,fr.HEIGHT))},t.destroy=function(){this._window&&this._window.detachCamera(this),this._name=null,this._poolHandle&&(vr.free(this._poolHandle),this._poolHandle=0,this._frustumHandle&&(Or.free(this._frustumHandle),this._frustumHandle=0))},t.attachToScene=function(e){this._scene=e,this._enabled=!0,vr.set(this._poolHandle,fr.SCENE,e.handle)},t.detachFromScene=function(){this._scene=null,this._enabled=!1,vr.set(this._poolHandle,fr.SCENE,0)},t.resize=function(e,t){var n=this._poolHandle;vr.set(n,fr.WIDTH,e),vr.set(n,fr.HEIGHT,t),this._aspect=e*this._viewport.width/(t*this._viewport.height),this._isProjDirty=!0},t.setFixedSize=function(e,t){var n=this._poolHandle;vr.set(n,fr.WIDTH,e),vr.set(n,fr.HEIGHT,t),this._aspect=e*this._viewport.width/(t*this._viewport.height),this.isWindowSize=!1},t.update=function(e){if(void 0===e&&(e=!1),this._node){var t=!1;(this._node.hasChangedFlags||e)&&(Hn.invert(this._matView,this._node.worldMatrix),vr.setMat4(this._poolHandle,fr.MAT_VIEW,this._matView),this._forward.x=-this._matView.m02,this._forward.y=-this._matView.m06,this._forward.z=-this._matView.m10,this._node.getWorldPosition(this._position),vr.setVec3(this._poolHandle,fr.POSITION,this._position),vr.setVec3(this._poolHandle,fr.FORWARD,this._forward),t=!0);var n=this._device.surfaceTransform;if(this._isProjDirty||this._curTransform!==n){this._curTransform=n;var i=this._device.screenSpaceSignY;if(this._window&&this._window.hasOffScreenAttachments&&(i*=this._device.UVSpaceSignY,n=gs.IDENTITY),this._proj===Pu.PERSPECTIVE)Hn.perspective(this._matProj,this._fov,this._aspect,this._nearClip,this._farClip,this._fovAxis===Ou.VERTICAL,this._device.clipSpaceMinZ,i,n);else{var r=this._orthoHeight*this._aspect,a=this._orthoHeight;Hn.ortho(this._matProj,-r,r,-a,a,this._nearClip,this._farClip,this._device.clipSpaceMinZ,i,n)}Hn.invert(this._matProjInv,this._matProj),vr.setMat4(this._poolHandle,fr.MAT_PROJ,this._matProj),vr.setMat4(this._poolHandle,fr.MAT_PROJ_INV,this._matProjInv),t=!0,this._isProjDirty=!1}t&&(Hn.multiply(this._matViewProj,this._matProj,this._matView),Hn.invert(this._matViewProjInv,this._matViewProj),this._frustum.update(this._matViewProj,this._matViewProjInv),vr.setMat4(this._poolHandle,fr.MAT_VIEW_PROJ,this._matViewProj),vr.setMat4(this._poolHandle,fr.MAT_VIEW_PROJ_INV,this._matViewProjInv),ml(this._frustumHandle,this._frustum))}},t.changeTargetWindow=function(e){void 0===e&&(e=null),this._window&&this._window.detachCamera(this);var t=e||i.director.root.mainWindow;t&&(t.attachCamera(this),this.resize(t.width,t.height),this._window=t,vr.set(this._poolHandle,fr.WINDOW,t.handle))},t.detachCamera=function(){this._window&&this._window.detachCamera(this)},t.screenPointToRay=function(e,t,n){if(!this._node)return null;var i=this._poolHandle,r=vr.get(i,fr.WIDTH),a=vr.get(i,fr.HEIGHT),s=this._viewport.x*r,o=this._viewport.y*a,c=this._viewport.width*r,l=this._viewport.height*a,u=this._proj===Pu.PERSPECTIVE,h=this._device.screenSpaceSignY,_=kn[this._curTransform];bn.set(Vu,(t-s)/c*2-1,(n-o)/l*2-1,u?1:-1);var f=Vu.x,d=Vu.y;return Vu.x=f*_[0]+d*_[2]*h,Vu.y=f*_[1]+d*_[3]*h,bn.transformMat4(u?Vu:e.o,Vu,this._matViewProjInv),u?(this._node.getWorldPosition(Wu),Ra.fromPoints(e,Wu,Vu)):bn.transformQuat(e.d,bn.FORWARD,this._node.worldRotation),e},t.screenToWorld=function(e,t){var n=this._poolHandle,i=vr.get(n,fr.WIDTH),r=vr.get(n,fr.HEIGHT),a=this._viewport.x*i,s=this._viewport.y*r,o=this._viewport.width*i,c=this._viewport.height*r,l=this._device.screenSpaceSignY,u=kn[this._curTransform];if(this._proj===Pu.PERSPECTIVE){bn.set(e,(t.x-a)/o*2-1,(t.y-s)/c*2-1,1);var h=e.x,_=e.y;e.x=h*u[0]+_*u[2]*l,e.y=h*u[1]+_*u[3]*l,bn.transformMat4(e,e,this._matViewProjInv),this._node&&this._node.getWorldPosition(Vu),bn.lerp(e,Vu,e,un(this._nearClip/this._farClip,1,t.z))}else{bn.set(e,(t.x-a)/o*2-1,(t.y-s)/c*2-1,2*t.z-1);var f=e.x,d=e.y;e.x=f*u[0]+d*u[2]*l,e.y=f*u[1]+d*u[3]*l,bn.transformMat4(e,e,this._matViewProjInv)}return e},t.worldToScreen=function(e,t){var n=this._poolHandle,i=vr.get(n,fr.WIDTH),r=vr.get(n,fr.HEIGHT),a=this._viewport.x*i,s=this._viewport.y*r,o=this._viewport.width*i,c=this._viewport.height*r,l=this._device.screenSpaceSignY,u=kn[this._curTransform];bn.transformMat4(e,t,this._matViewProj);var h=e.x,_=e.y;return e.x=h*u[0]+_*u[2]*l,e.y=h*u[1]+_*u[3]*l,e.x=a+.5*(e.x+1)*o,e.y=s+.5*(e.y+1)*c,e.z=.5*e.z+.5,e},t.worldMatrixToScreen=function(e,t,n,i){Hn.multiply(e,this._matViewProj,t),Hn.multiply(e,Xu[this._curTransform],e);var r=n/2,a=i/2;return Hn.identity(ju),Hn.transform(ju,ju,bn.set(Vu,r,a,0)),Hn.scale(ju,ju,bn.set(Vu,r,a,1)),Hn.multiply(e,ju,e),e},t.updateExposure=function(){var e=Math.log2(this._apertureValue*this._apertureValue/this._shutterValue*100/this._isoValue);vr.set(this._poolHandle,fr.EXPOSURE,.833333/Math.pow(2,e))},j(e,[{key:"node",set:function(e){this._node=e},get:function(){return this._node}},{key:"enabled",set:function(e){this._enabled=e},get:function(){return this._enabled}},{key:"orthoHeight",set:function(e){this._orthoHeight=e,this._isProjDirty=!0},get:function(){return this._orthoHeight}},{key:"projectionType",set:function(e){this._proj=e,this._isProjDirty=!0},get:function(){return this._proj}},{key:"fovAxis",set:function(e){this._fovAxis=e,this._isProjDirty=!0},get:function(){return this._fovAxis}},{key:"fov",set:function(e){this._fov=e,this._isProjDirty=!0},get:function(){return this._fov}},{key:"nearClip",set:function(e){this._nearClip=e,this._isProjDirty=!0},get:function(){return this._nearClip}},{key:"farClip",set:function(e){this._farClip=e,this._isProjDirty=!0},get:function(){return this._farClip}},{key:"clearColor",set:function(e){this._clearColor.x=e.x,this._clearColor.y=e.y,this._clearColor.z=e.z,this._clearColor.w=e.w,vr.setVec4(this._poolHandle,fr.CLEAR_COLOR,e)},get:function(){return this._clearColor}},{key:"viewport",get:function(){return this._viewport},set:function(e){var t=e.x,n=e.width,i=e.height,r=this._device.screenSpaceSignY<0?1-e.y-i:e.y;switch(this._device.surfaceTransform){case gs.ROTATE_90:this._viewport.x=1-r-i,this._viewport.y=t,this._viewport.width=i,this._viewport.height=n;break;case gs.ROTATE_180:this._viewport.x=1-t-n,this._viewport.y=1-r-i,this._viewport.width=n,this._viewport.height=i;break;case gs.ROTATE_270:this._viewport.x=r,this._viewport.y=1-t-n,this._viewport.width=i,this._viewport.height=n;break;case gs.IDENTITY:this._viewport.x=t,this._viewport.y=r,this._viewport.width=n,this._viewport.height=i}vr.setVec4(this._poolHandle,fr.VIEW_PORT,this._viewport),this.resize(this.width,this.height)}},{key:"scene",get:function(){return this._scene}},{key:"name",get:function(){return this._name}},{key:"width",get:function(){return vr.get(this._poolHandle,fr.WIDTH)}},{key:"height",get:function(){return vr.get(this._poolHandle,fr.HEIGHT)}},{key:"aspect",get:function(){return this._aspect}},{key:"matView",set:function(e){this._matView=e,vr.setMat4(this._poolHandle,fr.MAT_VIEW,this._matView)},get:function(){return this._matView}},{key:"matViewInv",set:function(e){this._matViewInv=e},get:function(){return this._matViewInv||this._node.worldMatrix}},{key:"matProj",set:function(e){this._matProj=e,vr.setMat4(this._poolHandle,fr.MAT_PROJ,this._matProj)},get:function(){return this._matProj}},{key:"matProjInv",set:function(e){this._matProjInv=e,vr.setMat4(this._poolHandle,fr.MAT_PROJ_INV,this._matProjInv)},get:function(){return this._matProjInv}},{key:"matViewProj",set:function(e){this._matViewProj=e,vr.setMat4(this._poolHandle,fr.MAT_VIEW_PROJ,this._matViewProj)},get:function(){return this._matViewProj}},{key:"matViewProjInv",set:function(e){this._matViewProjInv=e,vr.setMat4(this._poolHandle,fr.MAT_VIEW_PROJ_INV,this._matViewProjInv)},get:function(){return this._matViewProjInv}},{key:"frustum",set:function(e){this._frustum=e,ml(this._frustumHandle,e)},get:function(){return this._frustum}},{key:"window",set:function(e){this._window=e,e&&vr.set(this._poolHandle,fr.WINDOW,e.handle)},get:function(){return this._window}},{key:"forward",set:function(e){this._forward=e,vr.setVec3(this._poolHandle,fr.FORWARD,this._forward)},get:function(){return this._forward}},{key:"position",set:function(e){this._position=e,vr.setVec3(this._poolHandle,fr.POSITION,this._position)},get:function(){return this._position}},{key:"visibility",set:function(e){vr.set(this._poolHandle,fr.VISIBILITY,e)},get:function(){return vr.get(this._poolHandle,fr.VISIBILITY)}},{key:"priority",get:function(){return this._priority},set:function(e){this._priority=e}},{key:"aperture",set:function(e){this._aperture=e,this._apertureValue=Gu[this._aperture],this.updateExposure()},get:function(){return this._aperture}},{key:"apertureValue",get:function(){return this._apertureValue}},{key:"shutter",set:function(e){this._shutter=e,this._shutterValue=ku[this._shutter],this.updateExposure()},get:function(){return this._shutter}},{key:"shutterValue",get:function(){return this._shutterValue}},{key:"iso",set:function(e){this._iso=e,this._isoValue=Hu[this._iso],this.updateExposure()},get:function(){return this._iso}},{key:"isoValue",get:function(){return this._isoValue}},{key:"ec",set:function(e){this._ec=e},get:function(){return this._ec}},{key:"exposure",get:function(){return vr.get(this._poolHandle,fr.EXPOSURE)}},{key:"clearFlag",get:function(){return vr.get(this._poolHandle,fr.CLEAR_FLAG)},set:function(e){vr.set(this._poolHandle,fr.CLEAR_FLAG,e)}},{key:"clearDepth",get:function(){return vr.get(this._poolHandle,fr.CLEAR_DEPTH)},set:function(e){vr.set(this._poolHandle,fr.CLEAR_DEPTH,e)}},{key:"clearStencil",get:function(){return vr.get(this._poolHandle,fr.CLEAR_STENCIL)},set:function(e){vr.set(this._poolHandle,fr.CLEAR_STENCIL,e)}},{key:"handle",get:function(){return this._poolHandle}}]),e}();!function(e){e[e.LOCAL=0]="LOCAL",e[e.WORLD=1]="WORLD"}(zu||(zu={})),function(e){e[e.NONE=0]="NONE",e[e.POSITION=1]="POSITION",e[e.ROTATION=2]="ROTATION",e[e.SCALE=4]="SCALE",e[e.RS=e.ROTATION|e.SCALE]="RS",e[e.TRS=e.POSITION|e.ROTATION|e.SCALE]="TRS",e[e.TRS_MASK=~e.TRS]="TRS_MASK"}(Uu||(Uu={})),i.internal.TransformBit=Uu;var Ku=function(){function e(e){this._root=void 0,this._name="",this._cameras=[],this._models=[],this._batches=[],this._directionalLights=[],this._sphereLights=[],this._spotLights=[],this._mainLight=null,this._modelId=0,this._scenePoolHandle=0,this._modelArrayHandle=0,this._batchArrayHandle=0,this._sphereLightsHandle=0,this._spotLightsHandle=0,this._root=e,this._createHandles()}e.registerCreateFunc=function(t){t._createSceneFun=function(t){return new e(t)}},j(e,[{key:"root",get:function(){return this._root}},{key:"name",get:function(){return this._name}},{key:"cameras",get:function(){return this._cameras}},{key:"mainLight",get:function(){return this._mainLight}},{key:"sphereLights",get:function(){return this._sphereLights}},{key:"spotLights",get:function(){return this._spotLights}},{key:"models",get:function(){return this._models}},{key:"handle",get:function(){return this._scenePoolHandle}},{key:"batches",get:function(){return this._batches}}]);var t=e.prototype;return t.initialize=function(e){return this._name=e.name,this._createHandles(),!0},t.update=function(e){var t=this._mainLight;t&&t.update();for(var n=this._sphereLights,i=0;i<n.length;i++)n[i].update();for(var r=this._spotLights,a=0;a<r.length;a++)r[a].update();for(var s=this._models,o=0;o<s.length;o++){var c=s[o];c.enabled&&(c.updateTransform(e),c.updateUBOs(e))}},t.destroy=function(){this.removeCameras(),this.removeSphereLights(),this.removeSpotLights(),this.removeModels(),this._modelArrayHandle&&(Wi.free(this._modelArrayHandle),this._modelArrayHandle=0),this._scenePoolHandle&&(pr.free(this._scenePoolHandle),this._scenePoolHandle=0),this._sphereLightsHandle&&(Xi.free(this._sphereLightsHandle),this._sphereLightsHandle=0),this._spotLightsHandle&&(Xi.free(this._spotLightsHandle),this._spotLightsHandle=0),this._batchArrayHandle&&(Ki.free(this._batchArrayHandle),this._batchArrayHandle=0)},t.addCamera=function(e){e.attachToScene(this),this._cameras.push(e)},t.removeCamera=function(e){for(var t=0;t<this._cameras.length;++t)if(this._cameras[t]===e)return this._cameras.splice(t,1),void e.detachFromScene()},t.removeCameras=function(){for(var e,t=Z(this._cameras);!(e=t()).done;)e.value.detachFromScene();this._cameras.splice(0)},t.setMainLight=function(e){this._mainLight=e,pr.set(this._scenePoolHandle,ur.MAIN_LIGHT,e.handle)},t.unsetMainLight=function(e){if(this._mainLight===e){var t=this._directionalLights;t.length?(this._mainLight=t[t.length-1],this._mainLight.node&&(this._mainLight.node.hasChangedFlags|=Uu.ROTATION)):this._mainLight=null}},t.addDirectionalLight=function(e){e.attachToScene(this),this._directionalLights.push(e)},t.removeDirectionalLight=function(e){for(var t=0;t<this._directionalLights.length;++t)if(this._directionalLights[t]===e)return e.detachFromScene(),void this._directionalLights.splice(t,1)},t.addSphereLight=function(e){e.attachToScene(this),this._sphereLights.push(e),Xi.push(this._sphereLightsHandle,e.handle)},t.removeSphereLight=function(e){for(var t=0;t<this._sphereLights.length;++t)if(this._sphereLights[t]===e)return e.detachFromScene(),this._sphereLights.splice(t,1),void Xi.erase(this._sphereLightsHandle,t)},t.addSpotLight=function(e){e.attachToScene(this),this._spotLights.push(e),Xi.push(this._spotLightsHandle,e.handle)},t.removeSpotLight=function(e){for(var t=0;t<this._spotLights.length;++t)if(this._spotLights[t]===e)return e.detachFromScene(),this._spotLights.splice(t,1),void Xi.erase(this._spotLightsHandle,t)},t.removeSphereLights=function(){for(var e=0;e<this._sphereLights.length;++e)this._sphereLights[e].detachFromScene();this._sphereLights.length=0,Xi.clear(this._sphereLightsHandle)},t.removeSpotLights=function(){for(var e=0;e<this._spotLights.length;++e)this._spotLights[e].detachFromScene();this._spotLights=[],Xi.clear(this._spotLightsHandle)},t.addModel=function(e){e.attachToScene(this),this._models.push(e),Wi.push(this._modelArrayHandle,e.handle)},t.removeModel=function(e){for(var t=0;t<this._models.length;++t)if(this._models[t]===e)return e.detachFromScene(),this._models.splice(t,1),void Wi.erase(this._modelArrayHandle,t)},t.removeModels=function(){for(var e,t=Z(this._models);!(e=t()).done;){var n=e.value;n.detachFromScene(),n.destroy()}this._models.length=0,Wi.clear(this._modelArrayHandle)},t.addBatch=function(e){this._batches.push(e),Ki.push(this._batchArrayHandle,e.handle)},t.removeBatch=function(e){for(var t=0;t<this._batches.length;++t)if(this._batches[t]===e)return this._batches.splice(t,1),void Ki.erase(this._batchArrayHandle,t)},t.removeBatches=function(){this._batches.length=0,Ki.clear(this._batchArrayHandle)},t.onGlobalPipelineStateChanged=function(){for(var e,t=Z(this._models);!(e=t()).done;)e.value.onGlobalPipelineStateChanged()},t.generateModelId=function(){return this._modelId++},t._createHandles=function(){this._modelArrayHandle||(this._modelArrayHandle=Wi.alloc(),this._scenePoolHandle=pr.alloc(),pr.set(this._scenePoolHandle,ur.MODEL_ARRAY,this._modelArrayHandle),this._spotLightsHandle=Xi.alloc(),pr.set(this._scenePoolHandle,ur.SPOT_LIGHT_ARRAY,this._spotLightsHandle),this._sphereLightsHandle=Xi.alloc(),pr.set(this._scenePoolHandle,ur.SPHERE_LIGHT_ARRAY,this._sphereLightsHandle)),this._batchArrayHandle||(this._batchArrayHandle=Ki.alloc(),pr.set(this._scenePoolHandle,ur.BATCH_ARRAY_2D,this._batchArrayHandle))},e}(),Zu=function(){},Qu=function(){return Zu},Ju=$u((function(){}));function $u(e){return function(t){return"function"==typeof t?e(t):function(n){return e(n,t)}}}function eh(e){return function(t){return function(n){!function(e,t,n){var i=th(e);if(i){var r=nh(i,"proto");nh(r,"editor")[t]=n}}(n,e,t)}}}function th(e){return nh(e,"__ccclassCache__")}function nh(e,t){return e[t]||(e[t]={})}var ih=$u((function(e,t){var n=st.getSuper(e);n===Object&&(n=null);var i={name:t,extends:n,ctor:e},r=e.__ccclassCache__;if(r){var a=r.proto;a&&st.mixin(i,a),e.__ccclassCache__=void 0}return $t(i)})),rh=eh("requireComponent"),ah=eh("executionOrder"),sh=Ju;function oh(e,t,n){var i=null;function r(e,t,n){var r=th(e.constructor);if(r){var a=nh(r,"proto"),s=nh(a,"properties");!function(e,t,n,i,r,a){var s,o=r&&(r.get||r.set);i&&(s=Wt(i,o));var c=t[n],l=st.mixin(c||{},s||i||{});if(o)r.get&&(l.get=r.get),r.set&&(l.set=r.set);else if(r)r.initializer&&(l.default=function(e){var t;try{t=e()}catch(t){return e}return"object"!=typeof t||null===t?t:e}(r.initializer));else{var u=a.default||(a.default=function(e){var t;try{t=new e}catch(e){return{}}return t}(e));u.hasOwnProperty(n)&&(l.default=u[n])}t[n]=l}(e.constructor,s,t,i,n,r)}}return void 0===e?oh({type:void 0}):void 0===t?(i=e,r):void r(e,t,n)}var ch=function(e,t,n){return oh(uh({}))(e,t,n)},lh=function(e,t,n){return oh({editorOnly:!0})(e,t,n)};function uh(e){return e.__noImplicit=!0,"serializable"in e||(e.serializable=!0),e}var hh=Ju,_h=Qu,fh=Ju,dh=Qu,ph=Qu,mh=Qu,gh=Zu,vh=Qu,yh=Qu,Sh=Qu,Eh=Qu,Th=Qu,Ah=Qu,xh=Qu,Ch=Zu,Rh=Qu,bh=Qu,wh=Zu,Ih=Zu,Oh=Dh(Dt),Ph=Dh(Bt),Mh=Dh(Lt),Nh=Dh(Ft);function Dh(e){return oh({type:e})}var Bh=function(e,t,n){return oh({__noImplicit:!0,override:!0})(e,t,n)},Lh=function(){function e(e){this._map=null,this._count=0,e?(this._map=e,this._count=Object.keys(e).length):(this._map=st.createMap(!0),this._count=0)}var t=e.prototype;return t.add=function(e,t){return e in this._map||this._count++,this._map[e]=t},t.get=function(e){return this._map[e]},t.has=function(e){return e in this._map},t.remove=function(e){var t=this._map[e];return e in this._map&&(delete this._map[e],this._count--),t},t.clear=function(){0!==this._count&&(this._map=st.createMap(!0),this._count=0)},t.forEach=function(e){for(var t in this._map)e(this._map[t],t)},t.find=function(e){for(var t in this._map)if(e(this._map[t],t))return this._map[t];return null},t.destroy=function(){this._map=null},j(e,[{key:"count",get:function(){return this._count}}]),e}(),Fh=function(){function e(t,n){this.id=e._pipelineId++,this.name="",this.pipes=[],this.name=t;for(var i=0,r=n.length;i<r;i++)this.pipes.push(n[i])}var t=e.prototype;return t.insert=function(e,t){return t>this.pipes.length?(E(4921),this):(this.pipes.splice(t,0,e),this)},t.append=function(e){return this.pipes.push(e),this},t.remove=function(e){return this.pipes.splice(e,1),this},t.sync=function(e){var t=this.pipes;if(0===t.length)return null;e.isFinish=!1;for(var n=0,i=t.length;n<i;){var r=(0,t[n])(e);if(r)return e.isFinish=!0,r;++n!==i&&(e.input=e.output,e.output=null)}return e.isFinish=!0,e.output},t.async=function(e){0!==this.pipes.length&&(e.isFinish=!1,this._flow(0,e))},t._flow=function(e,t){var n=this;(0,this.pipes[e])(t,(function(i){i?(t.isFinish=!0,t.dispatch("complete",i)):++e<n.pipes.length?(t.input=t.output,t.output=null,n._flow(e,t)):(t.isFinish=!0,t.dispatch("complete",i,t.output))}))},e}();Fh._pipelineId=0;var zh,Uh=new Lh,Gh=new Lh,kh=new Lh,Hh=new Lh,Vh=new Fh("normal load",[]),Wh=new Fh("fetch",[]),jh=new Fh("transform url",[]);!function(e){e.UUID="uuid",e.PATH="path",e.DIR="dir",e.URL="url",e.SCENE="scene"}(zh||(zh={}));var qh,Xh={default:{priority:0},preload:{maxConcurrency:6,maxRequestsPerFrame:2,priority:-1},scene:{maxConcurrency:20,maxRequestsPerFrame:20,priority:1},bundle:{maxConcurrency:20,maxRequestsPerFrame:20,priority:2},remote:{maxRetryCount:4}};!function(e){e.RESOURCES="resources",e.MAIN="main",e.START_SCENE="start-scene"}(qh||(qh={}));var Yh=function(){function e(t){this.id=e._taskId++,this.onComplete=null,this.onProgress=null,this.onError=null,this.source=null,this.output=null,this.input=null,this.progress=null,this.options=null,this.isFinish=!0,this.set(t)}e.create=function(t){var n;return 0!==e._deadPool.length?(n=e._deadPool.pop()).set(t):n=new e(t),n};var t=e.prototype;return t.set=function(e){void 0===e&&(e=Object.create(null)),this.onComplete=e.onComplete||null,this.onProgress=e.onProgress||null,this.onError=e.onError||null,this.source=this.input=e.input,this.output=null,this.progress=e.progress,this.options=e.options||Object.create(null)},t.dispatch=function(e,t,n,i,r){switch(e){case"complete":this.onComplete&&this.onComplete(t,n);break;case"progress":this.onProgress&&this.onProgress(t,n,i,r);break;case"error":this.onError&&this.onError(t,n,i,r);break;default:var a="on"+e[0].toUpperCase()+e.substr(1);"function"==typeof this[a]&&this[a](t,n,i,r)}},t.recycle=function(){e._deadPool.length!==e.MAX_DEAD_NUM&&(this.onComplete=null,this.onProgress=null,this.onError=null,this.source=this.output=this.input=null,this.progress=null,this.options=null,e._deadPool.push(this))},e}();Yh.MAX_DEAD_NUM=500,Yh._taskId=0,Yh._deadPool=[];var Kh="0123456789abcdef".split(""),Zh=["","","",""],Qh=Zh.concat(Zh,"-",Zh,"-",Zh,"-",Zh,"-",Zh,Zh,Zh),Jh=Qh.map((function(e,t){return"-"===e?NaN:t})).filter(isFinite);function $h(e){var t=e.split("@")[0];if(22!==t.length)return e;Qh[0]=e[0],Qh[1]=e[1];for(var n=2,i=2;n<22;n+=2){var r=vt[e.charCodeAt(n)],a=vt[e.charCodeAt(n+1)];Qh[Jh[i++]]=Kh[r>>2],Qh[Jh[i++]]=Kh[(3&r)<<2|a>>4],Qh[Jh[i++]]=Kh[15&a]}return e.replace(t,Qh.join(""))}var e_=/.*[/\\][0-9a-fA-F]{2}[/\\]([0-9a-fA-F-@]{8,}).*/;function t_(e){var t=e_.exec(e);return t?t[1]:""}function n_(e,t){(t=t||Object.create(null)).__isNative__=t.isNative,t.ext=t.nativeExt;var n=Hh.find((function(t){return!!t.getAssetInfo(e)}));return n&&(t.bundle=n.name),a_(e,t)}function i_(e){return e&&(e instanceof i.SceneAsset||e instanceof i.Scene)}function r_(e){return e&&(46===e.charCodeAt(0)&&47===e.charCodeAt(1)?e=e.slice(2):47===e.charCodeAt(0)&&(e=e.slice(1))),e}function a_(e,t){var n=Yh.create({input:e,options:t}),i=[];try{for(var r,a=Z(jh.sync(n));!(r=a()).done;){var s=r.value,o=s.url;s.recycle(),i.push(o)}}catch(e){for(var c,l=Z(n.output);!(c=l()).done;)c.value.recycle();f(e.message,e.stack)}return n.recycle(),i.length>1?i:i[0]}var s_=Object.freeze({__proto__:null,getUuidFromURL:t_,getUrlWithUuid:n_,isScene:i_,normalize:r_,transform:a_,decodeUuid:$h}),o_=e("Event",function(){function e(e,t){this.type=void 0,this.bubbles=void 0,this.target=null,this.currentTarget=null,this.eventPhase=0,this.propagationStopped=!1,this.propagationImmediateStopped=!1,this.type=e,this.bubbles=!!t}var t=e.prototype;return t.unuse=function(){this.type=e.NO_TYPE,this.target=null,this.currentTarget=null,this.eventPhase=e.NONE,this.propagationStopped=!1,this.propagationImmediateStopped=!1},t.reuse=function(e,t){this.type=e,this.bubbles=t||!1},t.isStopped=function(){return this.propagationStopped||this.propagationImmediateStopped},t.getCurrentTarget=function(){return this.currentTarget},t.getType=function(){return this.type},e}());o_.NO_TYPE="no_type",o_.TOUCH="touch",o_.MOUSE="mouse",o_.KEYBOARD="keyboard",o_.ACCELERATION="acceleration",o_.NONE=0,o_.CAPTURING_PHASE=1,o_.AT_TARGET=2,o_.BUBBLING_PHASE=3,i.Event=o_;var c_=e("Pool",function(){function e(e,t){this._ctor=void 0,this._elementsPerBatch=void 0,this._nextAvail=void 0,this._freepool=[],this._ctor=e,this._elementsPerBatch=Math.max(t,1),this._nextAvail=this._elementsPerBatch-1;for(var n=0;n<this._elementsPerBatch;++n)this._freepool.push(e())}var t=e.prototype;return t.alloc=function(){if(this._nextAvail<0){for(var e=this._elementsPerBatch,t=0;t<e;t++)this._freepool.push(this._ctor());this._nextAvail=e-1}var n=this._freepool[this._nextAvail--];return this._freepool.length--,n},t.free=function(e){this._freepool.push(e),this._nextAvail++},t.freeArray=function(e){Array.prototype.push.apply(this._freepool,e),this._nextAvail+=e.length},t.destroy=function(e){if(e)for(var t=0;t<=this._nextAvail;t++)e(this._freepool[t]);this._freepool.length=0,this._nextAvail=-1},e}()),l_=e("RecyclePool",function(){function e(e,t){this._fn=void 0,this._count=0,this._data=void 0,this._fn=e,this._data=new Array(t);for(var n=0;n<t;++n)this._data[n]=e()}var t=e.prototype;return t.reset=function(){this._count=0},t.resize=function(e){if(e>this._data.length)for(var t=this._data.length;t<e;++t)this._data[t]=this._fn()},t.add=function(){return this._count>=this._data.length&&this.resize(2*this._data.length),this._data[this._count++]},t.removeAt=function(e){if(!(e>=this._count)){var t=this._count-1,n=this._data[e];this._data[e]=this._data[t],this._data[t]=n,this._count-=1}},j(e,[{key:"length",get:function(){return this._count}},{key:"data",get:function(){return this._data}}]),e}()),u_=e("CachedArray",function(){function e(e,t){this.array=void 0,this.length=0,this._compareFn=void 0,this.array=new Array(e),this.length=0,this._compareFn=void 0!==t?t:function(e,t){return e-t}}var t=e.prototype;return t.push=function(e){this.array[this.length++]=e},t.pop=function(){return this.array[--this.length]},t.get=function(e){return this.array[e]},t.clear=function(){this.length=0},t.destroy=function(){this.length=0,this.array.length=0},t.sort=function(){this.array.length=this.length,this.array.sort(this._compareFn)},t.concat=function(e){for(var t=0;t<e.length;++t)this.array[this.length++]=e[t]},t.fastRemove=function(e){if(!(e>=this.length||e<0)){var t=--this.length;this.array[e]=this.array[t]}},t.indexOf=function(e){return this.array.indexOf(e)},e}());e("memop",Object.freeze({__proto__:null,Pool:c_,RecyclePool:l_,CachedArray:u_}));var h_=[],__=e("CCObject",function(){function e(e){void 0===e&&(e=""),this._objFlags=void 0,this._name=void 0,this._name=e,this._objFlags=0}e._deferredDestroy=function(){for(var e=h_.length,t=0;t<e;++t){var n=h_[t];1&n._objFlags||n._destroyImmediate()}e===h_.length?h_.length=0:h_.splice(0,e)};var t=e.prototype;return t.destroy=function(){return 1&this._objFlags?(E(5e3),!1):!(4&this._objFlags||(this._objFlags|=4,h_.push(this),0))},t._destruct=function(){var e=this.constructor,t=e.__destruct__;t||(t=function(e,t){var n,r=e instanceof i._BaseNode||e instanceof i.Component,a=r?"_id":null,s={};for(n in e)if(e.hasOwnProperty(n)){if(n===a)continue;switch(typeof e[n]){case"string":s[n]="";break;case"object":case"function":s[n]=null}}if($t._isCCClass(t))for(var o=i.Class.Attr.getClassAttrs(t),c=t.__props__,l=0;l<c.length;l++){var u=(n=c[l])+i.Class.Attr.DELIMETER+"default";if(u in o){if(r&&"_id"===n)continue;switch(typeof o[u]){case"string":s[n]="";break;case"object":case"function":s[n]=null;break;case"undefined":s[n]=void 0}}}var h="";for(n in s){var _;_=$t.IDENTIFIER_RE.test(n)?"o."+n+"=":"o["+$t.escapeForJS(n)+"]=";var f=s[n];""===f&&(f='""'),h+=_+f+";\n"}return Function("o",h)}(this,e),be(e,"__destruct__",t,!0)),t(this)},t._destroyImmediate=function(){1&this._objFlags?A(5e3):(this._onPreDestroy&&this._onPreDestroy(),this._destruct(),this._objFlags|=1)},j(e,[{key:"name",get:function(){return this._name},set:function(e){this._name=e}},{key:"isValid",get:function(){return!(1&this._objFlags)}}]),e}()),f_=__.prototype;function d_(e,t){return"object"==typeof e?!(!e||e._objFlags&(t?5:1)):void 0!==e}f_._deserialize=null,f_._onPreDestroy=null,$t.fastDefine("cc.Object",__,{_name:"",_objFlags:0}),be(__,"Flags",{Destroyed:1,DontSave:8,EditorOnly:16,Dirty:32,DontDestroy:64,PersistentMask:-4192741,Destroying:128,Deactivating:256,LockedInEditor:512,HideInHierarchy:1024,IsPreloadStarted:8192,IsOnLoadStarted:32768,IsOnLoadCalled:16384,IsOnEnableCalled:2048,IsStartCalled:65536,IsEditorOnEnableCalled:4096,IsPositionLocked:1<<21,IsRotationLocked:1<<17,IsScaleLocked:1<<18,IsAnchorLocked:1<<19,IsSizeLocked:1<<20}),i.isValid=d_,i.Object=__;var p_=at.fastRemoveAt;function m_(){}var g_=function(){function e(){this.callback=m_,this.target=void 0,this.once=!1}var t=e.prototype;return t.set=function(e,t,n){this.callback=e||m_,this.target=t,this.once=!!n},t.reset=function(){this.target=void 0,this.callback=m_,this.once=!1},t.check=function(){return!(this.target instanceof __&&!d_(this.target,!0))},e}(),v_=new c_((function(){return new g_}),32),y_=function(){function e(){this.callbackInfos=[],this.isInvoking=!1,this.containCanceled=!1}var t=e.prototype;return t.removeByCallback=function(e){for(var t=0;t<this.callbackInfos.length;++t){var n=this.callbackInfos[t];n&&n.callback===e&&(n.reset(),v_.free(n),p_(this.callbackInfos,t),--t)}},t.removeByTarget=function(e){for(var t=0;t<this.callbackInfos.length;++t){var n=this.callbackInfos[t];n&&n.target===e&&(n.reset(),v_.free(n),p_(this.callbackInfos,t),--t)}},t.cancel=function(e){var t=this.callbackInfos[e];t&&(t.reset(),this.isInvoking?this.callbackInfos[e]=null:p_(this.callbackInfos,e),v_.free(t)),this.containCanceled=!0},t.cancelAll=function(){for(var e=0;e<this.callbackInfos.length;e++){var t=this.callbackInfos[e];t&&(t.reset(),v_.free(t),this.callbackInfos[e]=null)}this.containCanceled=!0},t.purgeCanceled=function(){for(var e=this.callbackInfos.length-1;e>=0;--e)this.callbackInfos[e]||p_(this.callbackInfos,e);this.containCanceled=!1},t.clear=function(){this.cancelAll(),this.callbackInfos.length=0,this.isInvoking=!1,this.containCanceled=!1},e}(),S_=new c_((function(){return new y_}),16),E_=function(){function e(){this._callbackTable=Pe(!0)}var t=e.prototype;return t.on=function(e,t,n,i){if(!this.hasEventListener(e,t,n)){var r=this._callbackTable[e];r||(r=this._callbackTable[e]=S_.alloc());var a=v_.alloc();a.set(t,n,i),r.callbackInfos.push(a)}return t},t.hasEventListener=function(e,t,n){var i=this._callbackTable&&this._callbackTable[e];if(!i)return!1;var r=i.callbackInfos;if(!t){if(i.isInvoking){for(var a=0;a<r.length;++a)if(r[a])return!0;return!1}return r.length>0}for(var s=0;s<r.length;++s){var o=r[s];if(o&&o.check()&&o.callback===t&&o.target===n)return!0}return!1},t.removeAll=function(e){if("string"==typeof e){var t=this._callbackTable&&this._callbackTable[e];t&&(t.isInvoking?t.cancelAll():(t.clear(),S_.free(t),delete this._callbackTable[e]))}else if(e)for(var n in this._callbackTable){var i=this._callbackTable[n];if(i.isInvoking)for(var r=i.callbackInfos,a=0;a<r.length;++a){var s=r[a];s&&s.target===e&&i.cancel(a)}else i.removeByTarget(e)}},t.off=function(e,t,n){var i=this._callbackTable&&this._callbackTable[e];if(i){var r=i.callbackInfos;if(t)for(var a=0;a<r.length;++a){var s=r[a];if(s&&s.callback===t&&s.target===n){i.cancel(a);break}}else this.removeAll(e)}},t.emit=function(e,t,n,i,r,a){var s=this._callbackTable&&this._callbackTable[e];if(s){var o=!s.isInvoking;s.isInvoking=!0;for(var c=s.callbackInfos,l=0,u=c.length;l<u;++l){var h=c[l];if(h){var _=h.callback,f=h.target;h.once&&this.off(e,_,f),h.check()?f?_.call(f,t,n,i,r,a):_(t,n,i,r,a):this.off(e,_,f)}}o&&(s.isInvoking=!1,s.containCanceled&&s.purgeCanceled())}},t.clear=function(){for(var e in this._callbackTable){var t=this._callbackTable[e];t&&(t.clear(),S_.free(t),delete this._callbackTable[e])}},e}();function T_(e){for(var t=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._callbackTable=Pe(!0),t}X(t,e);var n=t.prototype;return n.once=function(e,t,n){return this.on(e,t,n,!0)},n.targetOff=function(e){this.removeAll(e)},t}(e),n=E_.prototype,i=Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n)),r=0;r<i.length;++r){var a=i[r];if(!(a in t.prototype)){var s=Object.getOwnPropertyDescriptor(n,a);s&&Object.defineProperty(t.prototype,a,s)}}return t}var A_,x_,C_,R_,b_,w_=e("EventTarget",T_((function(){})));i.EventTarget=w_;var I_=e("Asset",ih("cc.Asset")((b_=R_=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this).loaded=!0,Q(t,"_native",C_,Y(t)),t._nativeUrl="",t.__onLoadedInvoked__=!1,t.__nativeDepend__=null,t.__asyncLoadAssets__=!1,t.__depends__=null,t._file=null,t._ref=0,Object.defineProperty(Y(t),"_uuid",{value:"",writable:!0}),t}X(t,e),t.deserialize=function(e){return i.deserialize(e)},j(t,[{key:"nativeUrl",get:function(){if(!this._nativeUrl){if(!this._native)return"";var e=this._native;if(47===e.charCodeAt(0))return e.slice(1);46===e.charCodeAt(0)?this._nativeUrl=n_(this._uuid,{nativeExt:e,isNative:!0}):this._nativeUrl=n_(this._uuid,{__nativeName__:e,nativeExt:B(e),isNative:!0})}return this._nativeUrl}},{key:"_nativeAsset",get:function(){return this._file},set:function(e){this._file=e}}]);var n=t.prototype;return n.toString=function(){return this.nativeUrl},n.serialize=function(){},n._setRawAsset=function(e,t){void 0===t&&(t=!0),this._native=!1!==t?e||"":"/"+e},n.addRef=function(){return this._ref++,this},n.decRef=function(e){return void 0===e&&(e=!0),this._ref>0&&this._ref--,e&&i.assetManager._releaseManager.tryRelease(this),this},n.onLoaded=function(){},j(t,[{key:"_nativeDep",get:function(){if(this._native)return{__isNative__:!0,uuid:this._uuid,ext:this._native}}},{key:"refCount",get:function(){return this._ref}}]),t}(T_(__)),R_.preventDeferredLoadDependents=!1,R_.preventPreloadNativeObject=!1,C_=J((x_=b_).prototype,"_native",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),J(x_.prototype,"_nativeAsset",[oh],Object.getOwnPropertyDescriptor(x_.prototype,"_nativeAsset"),x_.prototype),A_=x_))||A_);I_.prototype.createNode=null,i.Asset=I_;var O_,P_,M_,N_,D_,B_,L_,F_=1024;function z_(e){return i.sys.capabilities.imageBitmap&&e instanceof ImageBitmap}!function(e){e[e.RGB565=za.R5G6B5]="RGB565",e[e.RGB5A1=za.RGB5A1]="RGB5A1",e[e.RGBA4444=za.RGBA4]="RGBA4444",e[e.RGB888=za.RGB8]="RGB888",e[e.RGB32F=za.RGB32F]="RGB32F",e[e.RGBA8888=za.RGBA8]="RGBA8888",e[e.RGBA32F=za.RGBA32F]="RGBA32F",e[e.A8=za.A8]="A8",e[e.I8=za.L8]="I8",e[e.AI8=za.LA8]="AI8",e[e.RGB_PVRTC_2BPPV1=za.PVRTC_RGB2]="RGB_PVRTC_2BPPV1",e[e.RGBA_PVRTC_2BPPV1=za.PVRTC_RGBA2]="RGBA_PVRTC_2BPPV1",e[e.RGB_A_PVRTC_2BPPV1=F_++]="RGB_A_PVRTC_2BPPV1",e[e.RGB_PVRTC_4BPPV1=za.PVRTC_RGB4]="RGB_PVRTC_4BPPV1",e[e.RGBA_PVRTC_4BPPV1=za.PVRTC_RGBA4]="RGBA_PVRTC_4BPPV1",e[e.RGB_A_PVRTC_4BPPV1=F_++]="RGB_A_PVRTC_4BPPV1",e[e.RGB_ETC1=za.ETC_RGB8]="RGB_ETC1",e[e.RGBA_ETC1=F_++]="RGBA_ETC1",e[e.RGB_ETC2=za.ETC2_RGB8]="RGB_ETC2",e[e.RGBA_ETC2=za.ETC2_RGBA8]="RGBA_ETC2",e[e.RGBA_ASTC_4x4=za.ASTC_RGBA_4x4]="RGBA_ASTC_4x4",e[e.RGBA_ASTC_5x4=za.ASTC_RGBA_5x4]="RGBA_ASTC_5x4",e[e.RGBA_ASTC_5x5=za.ASTC_RGBA_5x5]="RGBA_ASTC_5x5",e[e.RGBA_ASTC_6x5=za.ASTC_RGBA_6x5]="RGBA_ASTC_6x5",e[e.RGBA_ASTC_6x6=za.ASTC_RGBA_6x6]="RGBA_ASTC_6x6",e[e.RGBA_ASTC_8x5=za.ASTC_RGBA_8x5]="RGBA_ASTC_8x5",e[e.RGBA_ASTC_8x6=za.ASTC_RGBA_8x6]="RGBA_ASTC_8x6",e[e.RGBA_ASTC_8x8=za.ASTC_RGBA_8x8]="RGBA_ASTC_8x8",e[e.RGBA_ASTC_10x5=za.ASTC_RGBA_10x5]="RGBA_ASTC_10x5",e[e.RGBA_ASTC_10x6=za.ASTC_RGBA_10x6]="RGBA_ASTC_10x6",e[e.RGBA_ASTC_10x8=za.ASTC_RGBA_10x8]="RGBA_ASTC_10x8",e[e.RGBA_ASTC_10x10=za.ASTC_RGBA_10x10]="RGBA_ASTC_10x10",e[e.RGBA_ASTC_12x10=za.ASTC_RGBA_12x10]="RGBA_ASTC_12x10",e[e.RGBA_ASTC_12x12=za.ASTC_RGBA_12x12]="RGBA_ASTC_12x12"}(O_||(O_={})),function(e){e[e.REPEAT=$a.WRAP]="REPEAT",e[e.CLAMP_TO_EDGE=$a.CLAMP]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=$a.MIRROR]="MIRRORED_REPEAT",e[e.CLAMP_TO_BORDER=$a.BORDER]="CLAMP_TO_BORDER"}(P_||(P_={})),function(e){e[e.NONE=Ja.NONE]="NONE",e[e.LINEAR=Ja.LINEAR]="LINEAR",e[e.NEAREST=Ja.POINT]="NEAREST"}(M_||(M_={}));var U_,G_=e("ImageAsset",ih("cc.ImageAsset")((L_=B_=function(e){function t(t){var n;return(n=e.call(this)||this)._nativeData=void 0,n._tex=void 0,n._exportedExts=void 0,n._format=O_.RGBA8888,n._width=0,n._height=0,n.loaded=!1,n._nativeData={_data:null,width:0,height:0,format:0,_compressed:!1},void 0!==t&&n.reset(t),n}X(t,e),j(t,[{key:"_nativeAsset",get:function(){return this._nativeData},set:function(e){e instanceof HTMLElement||z_(e)||(e.format=e.format||this._format),this.reset(e)}},{key:"data",get:function(){return this._nativeData&&((e=this._nativeData)instanceof HTMLImageElement||e instanceof HTMLCanvasElement||z_(e))?this._nativeData:this._nativeData&&this._nativeData._data;var e}},{key:"width",get:function(){return this._nativeData.width||this._width}},{key:"height",get:function(){return this._nativeData.height||this._height}},{key:"format",get:function(){return this._format}},{key:"isCompressed",get:function(){return this._format>=O_.RGB_ETC1&&this._format<=O_.RGBA_ASTC_12x12||this._format>=O_.RGB_A_PVRTC_2BPPV1&&this._format<=O_.RGBA_ETC1}},{key:"url",get:function(){return this.nativeUrl}},{key:"_texture",set:function(e){this._tex=e},get:function(){if(!this._tex){var e=new i.Texture2D;e.name=this.nativeUrl,e.image=this,this._tex=e}return this._tex}}]);var n=t.prototype;return n.reset=function(e){var t=this;z_(e)?(this._nativeData=e,this._onDataComplete()):e instanceof HTMLElement?(this._nativeData=e,e.complete||e instanceof HTMLCanvasElement?this._onDataComplete():(this.loaded=!1,e.addEventListener("load",(function(){t._onDataComplete()})),e.addEventListener("error",(function(e){E(3119,e.message)})))):(this._nativeData=e,this._format=e.format,this._onDataComplete())},n.destroy=function(){return this.data&&this.data instanceof HTMLImageElement?(this.data.src="",this._setRawAsset("")):z_(this.data)&&this.data.close&&this.data.close(),e.prototype.destroy.call(this)},n._serialize=function(){},n._deserialize=function(e){var n="";"string"==typeof e?n=e:(this._width=e.w,this._height=e.h,n=e.fmt);for(var r,a=i.director.root?i.director.root.device:null,s=n.split("_"),o="",c=Number.MAX_VALUE,l=this._format,u="",h=i.macro.SUPPORT_TEXTURE_FORMATS,_=Z(s);!(r=_()).done;){var f=r.value.split("@"),d=parseInt(f[0],void 0),p=t.extnames[d]||f[0],m=h.indexOf(p);if(-1!==m&&m<c){var g=f[1]?parseInt(f[1]):this._format;if(!(".astc"!==p||a&&a.hasFeature(vs.FORMAT_ASTC)))continue;if(!(".pvr"!==p||a&&a.hasFeature(vs.FORMAT_PVRTC)))continue;if(!(g!==O_.RGB_ETC1&&g!==O_.RGBA_ETC1||a&&a.hasFeature(vs.FORMAT_ETC1)))continue;if(!(g!==O_.RGB_ETC2&&g!==O_.RGBA_ETC2||a&&a.hasFeature(vs.FORMAT_ETC2)))continue;if(".webp"===p&&!i.sys.capabilities.webp)continue;c=m,u=p,l=g}else o||(o=p)}u?(this._setRawAsset(u),this._format=l):o?(this._setRawAsset(o),E(3120,o,o)):E(3121)},n._onDataComplete=function(){this.loaded=!0,this.emit("load")},t}(I_),B_.extnames=[".png",".jpg",".jpeg",".bmp",".webp",".pvr",".pkm",".astc"],J((D_=L_).prototype,"_nativeAsset",[Bh],Object.getOwnPropertyDescriptor(D_.prototype,"_nativeAsset"),D_.prototype),N_=D_))||N_);i.ImageAsset=G_,function(e){e[e.minFilter=0]="minFilter",e[e.magFilter=1]="magFilter",e[e.mipFilter=2]="mipFilter",e[e.addressU=3]="addressU",e[e.addressV=4]="addressV",e[e.addressW=5]="addressW",e[e.maxAnisotropy=6]="maxAnisotropy",e[e.cmpFunc=7]="cmpFunc",e[e.minLOD=8]="minLOD",e[e.maxLOD=9]="maxLOD",e[e.mipLODBias=10]="mipLODBias",e[e.total=11]="total"}(U_||(U_={}));var k_=[Ja.LINEAR,Ja.LINEAR,Ja.NONE,$a.WRAP,$a.WRAP,$a.WRAP,8,Xa.NEVER,0,0,0],H_=j_(k_),V_=new Ks,W_=new mo;function j_(e){for(var t=0,n=0,i=0;i<k_.length;i++)switch(t=e[i]||k_[i],i){case U_.minFilter:n|=t;break;case U_.magFilter:n|=t<<2;break;case U_.mipFilter:n|=t<<4;break;case U_.addressU:n|=t<<6;break;case U_.addressV:n|=t<<8;break;case U_.addressW:n|=t<<10;break;case U_.maxAnisotropy:n|=t<<12;break;case U_.cmpFunc:n|=t<<16;break;case U_.minLOD:n|=t<<20;break;case U_.maxLOD:n|=t<<24;break;case U_.mipLODBias:n|=t<<28}return n}var q_,X_,Y_,K_,Z_,Q_,J_,$_,ef,tf,nf,rf,af=new(function(){function e(){this._cache={}}return e.prototype.getSampler=function(e,t){return t||(t=H_),this._cache[t]||(W_.minFilter=3&t,W_.magFilter=t>>2&3,W_.mipFilter=t>>4&3,W_.addressU=t>>6&3,W_.addressV=t>>8&3,W_.addressW=t>>10&3,W_.maxAnisotropy=t>>12&15,W_.cmpFunc=t>>16&15,W_.minLOD=t>>20&15,W_.maxLOD=t>>24&15,W_.mipLODBias=t>>28&15,W_.borderColor=V_,this._cache[t]=e.createSampler(W_))},e}());i.samplerLib=af;var sf=new Se("Tex"),of=ih("cc.TextureBase")((rf=nf=function(e){function t(){var t;return Q(t=e.call(this)||this,"_format",Y_,Y(t)),Q(t,"_minFilter",K_,Y(t)),Q(t,"_magFilter",Z_,Y(t)),Q(t,"_mipFilter",Q_,Y(t)),Q(t,"_wrapS",J_,Y(t)),Q(t,"_wrapT",$_,Y(t)),Q(t,"_wrapR",ef,Y(t)),Q(t,"_anisotropy",tf,Y(t)),t._width=1,t._height=1,t._id=void 0,t._samplerInfo=[],t._samplerHash=0,t._gfxSampler=null,t._gfxDevice=null,t._textureHash=0,t._id=sf.getNewId(),t.loaded=!1,t._gfxDevice=t._getGFXDevice(),t._textureHash=Vs(t._id,666),t}X(t,e),j(t,[{key:"isCompressed",get:function(){return this._format>=O_.RGB_ETC1&&this._format<=O_.RGBA_ASTC_12x12||this._format>=O_.RGB_A_PVRTC_2BPPV1&&this._format<=O_.RGBA_ETC1}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}}]);var n=t.prototype;return n.getId=function(){return this._id},n.getPixelFormat=function(){return this._format},n.getAnisotropy=function(){return this._anisotropy},n.setWrapMode=function(e,t,n){this._wrapS=e,this._samplerInfo[U_.addressU]=e,this._wrapT=t,this._samplerInfo[U_.addressV]=t,void 0!==n&&(this._wrapR=n,this._samplerInfo[U_.addressW]=n),this._samplerHash=j_(this._samplerInfo),this._gfxDevice&&(this._gfxSampler=af.getSampler(this._gfxDevice,this._samplerHash))},n.setFilters=function(e,t){this._minFilter=e,this._samplerInfo[U_.minFilter]=e,this._magFilter=t,this._samplerInfo[U_.magFilter]=t,this._samplerHash=j_(this._samplerInfo),this._gfxDevice&&(this._gfxSampler=af.getSampler(this._gfxDevice,this._samplerHash))},n.setMipFilter=function(e){this._mipFilter=e,this._samplerInfo[U_.mipFilter]=e,this._samplerInfo[U_.maxLOD]=e===M_.NONE?0:15,this._samplerHash=j_(this._samplerInfo),this._gfxDevice&&(this._gfxSampler=af.getSampler(this._gfxDevice,this._samplerHash))},n.setAnisotropy=function(e){this._anisotropy=e,this._samplerInfo[U_.maxAnisotropy]=e,this._samplerHash=j_(this._samplerInfo),this._gfxDevice&&(this._gfxSampler=af.getSampler(this._gfxDevice,this._samplerHash))},n.destroy=function(){var t=e.prototype.destroy.call(this);return t&&i.director.root&&i.director.root.batcher2D&&i.director.root.batcher2D._releaseDescriptorSetCache(this._textureHash),t},n.getHash=function(){return this._textureHash},n.getGFXTexture=function(){return null},n.getSamplerHash=function(){return this._samplerHash},n.getGFXSampler=function(){return this._gfxSampler||(this._gfxDevice?this._gfxSampler=af.getSampler(this._gfxDevice,this._samplerHash):A(9302)),this._gfxSampler},n._serialize=function(){return""},n._deserialize=function(e){var t=e.split(",");t.unshift(""),t.length>=5&&(this.setFilters(parseInt(t[1]),parseInt(t[2])),this.setWrapMode(parseInt(t[3]),parseInt(t[4]))),t.length>=7&&(this.setMipFilter(parseInt(t[5])),this.setAnisotropy(parseInt(t[6])))},n._getGFXDevice=function(){return i.director.root?i.director.root.device:null},n._getGFXFormat=function(){return this._getGFXPixelFormat(this._format)},n._setGFXFormat=function(e){this._format=void 0===e?O_.RGBA8888:e},n._getGFXPixelFormat=function(e){return e===O_.RGBA_ETC1?e=O_.RGB_ETC1:e===O_.RGB_A_PVRTC_4BPPV1?e=O_.RGB_PVRTC_4BPPV1:e===O_.RGB_A_PVRTC_2BPPV1&&(e=O_.RGB_PVRTC_2BPPV1),e},t}(I_),nf.PixelFormat=O_,nf.WrapMode=P_,nf.Filter=M_,Y_=J((X_=rf).prototype,"_format",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return O_.RGBA8888}}),K_=J(X_.prototype,"_minFilter",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return M_.LINEAR}}),Z_=J(X_.prototype,"_magFilter",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return M_.LINEAR}}),Q_=J(X_.prototype,"_mipFilter",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return M_.NONE}}),J_=J(X_.prototype,"_wrapS",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return P_.REPEAT}}),$_=J(X_.prototype,"_wrapT",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return P_.REPEAT}}),ef=J(X_.prototype,"_wrapR",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return P_.REPEAT}}),tf=J(X_.prototype,"_anisotropy",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 8}}),q_=X_))||q_;i.TextureBase=of;var cf=[qn,bn,Zn,Dn,Cn,$n,ti,Hn];function lf(e,t){e.x=t[1],e.y=t[2],e.z=t[3],e.w=t[4]}var uf=[function(e,t){e.x=t[1],e.y=t[2]},function(e,t){e.x=t[1],e.y=t[2],e.z=t[3]},lf,lf,function(e,t){e._val=t[1]},function(e,t){e.width=t[1],e.height=t[2]},function(e,t){e.x=t[1],e.y=t[2],e.width=t[3],e.height=t[4]},function(e,t){Hn.fromArray(e,t,1)}],hf=e("Details",function(){function e(){this.uuidObjList=null,this.uuidPropList=null,this.uuidList=null}var t=e.prototype;return t.init=function(e){this.uuidObjList=e[8],this.uuidPropList=e[9],this.uuidList=e[10]},t.reset=function(){this.uuidList=null,this.uuidObjList=null,this.uuidPropList=null},t.push=function(e,t,n){this.uuidObjList.push(e),this.uuidPropList.push(t),this.uuidList.push(n)},e}());function _f(e,t){for(var n=e[4][t[0]],i=n[0],r=new(0,i[0]),a=i[1],s=i[2],o=n[n.length-1],c=1;c<o;++c)r[a[n[c]]]=t[c];for(;c<t.length;++c){var l=a[n[c]],u=i[n[c]+s];(0,vf[u])(e,r,l,t[c])}return r}function ff(e,t,n){var i=new t;return i._deserialize?i._deserialize(n,e[0]):A(5303,Me(t)),i}function df(e,t,n,i){i>=0?t[n]=e[5][i]:e[7][3*~i]=t}function pf(e){return function(t,n,i,r){n[i]=r;for(var a=0;a<r.length;++a)e(t,r,a,r[a])}}function mf(e,t,n,i){t[n]=null,e[8][i]=t}function gf(e,t,n,i){t[n]=_f(e,i)}hf.pool=new rt((function(e){e.reset()}),5),hf.pool.get=function(){return this._get()||new hf};var vf=new Array(13);function yf(e,t){return e||Af.reportMissingClass(t),Object}function Sf(e,t,n,i,r,a){var s=e(t);if(!s){if(r)return void(n[i]=function(t,n,i){return function(){var r=e(i)||yf(a,i);return t[n]=r,new r}}(n,i,t));s=yf(a,t)}n[i]=s}function Ef(e,t,n){for(var i=n||tt,r=e[3],a=0;a<r.length;++a){var s=r[a];"string"!=typeof s?Sf(i,s[0],s,0,t,n):Sf(i,s,r,a,t,n)}}function Tf(e){var t=e[4];if(t)for(var n=e[3],i=0;i<t.length;++i){var r=t[i];r[0]=n[r[0]]}}function Af(e,t,n){"string"==typeof e&&(e=JSON.parse(e));var r,a=!t;(t=t||hf.pool.get()).init(e),n=n||{};var s=e[0],o=!1;if("object"==typeof s&&(o=s.preprocessed,s=s.version),s<1)throw new Error(b(5304,s));n._version=s,n.result=t,e[0]=n,o||(Ef(e,!1,n.classFinder),Tf(e)),i.game._isCloning=!0;var c=e[5],l=function(e){var t=e[5],n=e[6],i=0===n?0:n.length,r=t[t.length-1],a=t.length-i;"number"!=typeof r?r=0:(r<0&&(r=~r),--a);for(var s=0;s<a;++s)t[s]=_f(e,t[s]);for(var o=e[3],c=0;c<i;++c,++s){var l=n[c],u=t[s];if(l>=0){var h=o[l];t[s]=ff(e,h,u)}else(0,vf[l=~l])(e,t,s,u)}return r}(e);return i.game._isCloning=!1,e[7]&&function(e,t,n){for(var i=e.length-1,r=0,a=3*e[i];r<a;r+=3){var s=e[r],o=t[e[r+2]],c=e[r+1];c>=0?s[n[c]]=o:s[~c]=o}for(;r<i;r+=3){var l=t[e[r]],u=t[e[r+2]],h=e[r+1];h>=0?l[n[h]]=u:l[~h]=u}}(e[7],c,e[2]),function(e){for(var t=e[5],n=e[2],i=e[1],r=e[8],a=e[9],s=e[10],o=0;o<r.length;++o){var c=r[o];"number"==typeof c&&(r[o]=t[c]);var l=a[o];"number"==typeof l&&(l=l>=0?n[l]:~l,a[o]=l);var u=s[o];"number"==typeof u&&(s[o]=i[u])}}(e),r=c[l],a&&hf.pool.put(t),r}vf[0]=function(e,t,n,i){t[n]=i},vf[1]=df,vf[2]=pf(df),vf[3]=pf(mf),vf[4]=gf,vf[5]=function(e,t,n,i){uf[i[0]](t[n],i)},vf[6]=mf,vf[7]=function(e,t,n,i){t[n].set(i)},vf[8]=function(e,t,n,i){var r=new cf[i[0]];uf[i[0]](r,i),t[n]=r},vf[9]=pf(gf),vf[10]=function(e,t,n,i){var r=e[3][i[0]];t[n]=ff(e,r,i[1])},vf[11]=function(e,t,n,i){var r=i[0];t[n]=r;for(var a=1;a<i.length;a+=3){var s=i[a],o=i[a+1],c=i[a+2];(0,vf[o])(e,r,s,c)}},vf[12]=function(e,t,n,i){var r=i[0];t[n]=r;for(var a=0;a<r.length;++a){var s=r[a],o=i[a+1];0!==o&&(0,vf[o])(e,r,a,s)}},Af.Details=hf,Af.reportMissingClass=function(e){E(5302,e)};var xf,Cf,Rf,bf=function(e){this.preprocessed=!0,this.version=e};function wf(e,t,n){return[1,0,0,[e],0,n?[t,-1]:[t],[0],0,[],[],[]]}i.deserialize=Af;var If=e("Script",ih("cc.Script")(xf=function(e){function t(){return e.apply(this,arguments)||this}return X(t,e),t}(I_))||xf);i._Script=If;var Of=e("JavaScript",ih("cc.JavaScript")(Cf=function(e){function t(){return e.apply(this,arguments)||this}return X(t,e),t}(If))||Cf);i._JavaScript=Of;var Pf,Mf,Nf,Df,Bf,Lf,Ff,zf,Uf,Gf,kf,Hf=e("TypeScript",ih("cc.TypeScript")(Rf=function(e){function t(){return e.apply(this,arguments)||this}return X(t,e),t}(If))||Rf);i._TypeScript=Hf;var Vf,Wf,jf,qf,Xf=new Se("Comp"),Yf=__.Flags.IsOnLoadCalled,Kf=e("Component",(Pf=ih("cc.Component"),Mf=yh(),Nf=Dh(If),Df=Sh(),Pf((kf=Gf=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return Q(t=e.call.apply(e,[this].concat(i))||this,"node",Ff,Y(t)),Q(t,"_enabled",zf,Y(t)),Q(t,"__prefab",Uf,Y(t)),t._sceneGetter=null,t._id=Xf.getNewId(),t}X(t,e);var n=t.prototype;return n._getRenderScene=function(){return this._sceneGetter?this._sceneGetter():this.node.scene._renderScene},n.addComponent=function(e){return this.node.addComponent(e)},n.getComponent=function(e){return this.node.getComponent(e)},n.getComponents=function(e){return this.node.getComponents(e)},n.getComponentInChildren=function(e){return this.node.getComponentInChildren(e)},n.getComponentsInChildren=function(e){return this.node.getComponentsInChildren(e)},n.destroy=function(){return!!e.prototype.destroy.call(this)&&(this._enabled&&this.node.activeInHierarchy&&i.director._compScheduler.disableComp(this),!0)},n._onPreDestroy=function(){this.unscheduleAllCallbacks(),i.director._nodeActivator.destroyComp(this),this.node._removeComponent(this)},n._instantiate=function(e){return e||(e=i.instantiate._clone(this,this)),e.node=null,e},n.schedule=function(e,t,n,r){void 0===t&&(t=0),void 0===n&&(n=i.macro.REPEAT_FOREVER),void 0===r&&(r=0),R(e,1619),R((t=t||0)>=0,1620),n=isNaN(n)?i.macro.REPEAT_FOREVER:n,r=r||0;var a=i.director.getScheduler(),s=a.isTargetPaused(this);a.schedule(e,this,t,n,r,s)},n.scheduleOnce=function(e,t){void 0===t&&(t=0),this.schedule(e,0,0,t)},n.unschedule=function(e){e&&i.director.getScheduler().unschedule(e,this)},n.unscheduleAllCallbacks=function(){i.director.getScheduler().unscheduleAllForTarget(this)},j(t,[{key:"name",get:function(){if(this._name)return this._name;var e=Me(this),t=e.lastIndexOf(".");return t>=0&&(e=e.slice(t+1)),this.node.name+"<"+e+">"},set:function(e){this._name=e}},{key:"uuid",get:function(){return this._id}},{key:"__scriptAsset",get:function(){return null}},{key:"enabled",get:function(){return this._enabled},set:function(e){if(this._enabled!==e&&(this._enabled=e,this.node.activeInHierarchy)){var t=i.director._compScheduler;e?t.enableComp(this):t.disableComp(this)}}},{key:"enabledInHierarchy",get:function(){return this._enabled&&this.node&&this.node.activeInHierarchy}},{key:"_isOnLoadCalled",get:function(){return this._objFlags&Yf}}]),t}(__),Gf.system=null,J((Lf=kf).prototype,"__scriptAsset",[Mf,Nf,Df,Ih],Object.getOwnPropertyDescriptor(Lf.prototype,"__scriptAsset"),Lf.prototype),Ff=J(Lf.prototype,"node",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),zf=J(Lf.prototype,"_enabled",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Uf=J(Lf.prototype,"__prefab",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Bf=Lf))||Bf)),Zf=Kf.prototype;Zf.update=null,Zf.lateUpdate=null,Zf.__preload=null,Zf.onLoad=null,Zf.start=null,Zf.onEnable=null,Zf.onDisable=null,Zf.onDestroy=null,Zf.onFocusInEditor=null,Zf.onLostFocusInEditor=null,Zf.resetInEditor=null,Zf._getLocalBounds=null,Zf.onRestore=null,Kf._requireComponent=null,Kf._executionOrder=0,be(Kf,"_registerEditorProps",(function(e,t){var n=t.requireComponent;n&&(e._requireComponent=n);var i=t.executionOrder;i&&"number"==typeof i&&(e._executionOrder=i)})),i.Component=Kf;var Qf=e("MissingScript",ih("cc.MissingScript")(Vf=dh()((qf=function(e){function t(){var t;return Q(t=e.call(this)||this,"_$erialized",jf,Y(t)),t}return X(t,e),t.safeFindClass=function(e){var t=tt(e);if(t)return t;i.deserialize.reportMissingClass(e)},t.prototype.onLoad=function(){E(4600,this.node.name)},t}(Kf),jf=J((Wf=qf).prototype,"_$erialized",[ch,lh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Vf=Wf))||Vf)||Vf);function Jf(e,t){var n;n=Qf.safeFindClass;var i,r=hf.pool.get();try{i=Af(e,r,{classFinder:n,customEnv:t})}catch(e){throw f(e),hf.pool.put(r),e}i._uuid=t.__uuid__||"";for(var a=r.uuidList,s=r.uuidObjList,o=r.uuidPropList,c=[],l=0;l<a.length;l++){var u=a[l];c[l]={uuid:$h(u),owner:s[l],prop:o[l]}}return i.__depends__=c,i._native&&(i.__nativeDepend__=!0),hf.pool.put(r),i}i._MissingScript=Qf;var $f,ed=new(function(){function e(){this._depends=new Lh}var t=e.prototype;return t.init=function(){this._depends.clear()},t.getNativeDep=function(e){var t=this._depends.get(e);return t&&t.nativeDep?q({},t.nativeDep):null},t.getDeps=function(e){return this._depends.has(e)?this._depends.get(e).deps:[]},t.getDepsRecursively=function(e){var t=Object.create(null),n=[];return this._descend(e,t,n),n},t.remove=function(e){this._depends.remove(e)},t.parse=function(e,t){var n,i,r=null;if(Array.isArray(t)||t.__type__){if(this._depends.has(e))return this._depends.get(e);if(!Array.isArray(t)||"number"==typeof(i=(n=t[5])[n.length-1])&&i<0)try{var a=Jf(t,{__uuid__:e});(r=this._parseDepsFromAsset(a)).nativeDep&&(r.nativeDep.uuid=e),kh.add(e+"@import",a)}catch(t){Gh.remove(e+"@import"),r={deps:[]}}else r={deps:this._parseDepsFromJson(t)}}else{if(this._depends.has(e)&&(r=this._depends.get(e)).parsedFromExistAsset)return r;r=this._parseDepsFromAsset(t)}return this._depends.add(e,r),r},t._parseDepsFromAsset=function(e){for(var t={deps:[],parsedFromExistAsset:!0,preventPreloadNativeObject:e.constructor.preventPreloadNativeObject,preventDeferredLoadDependents:e.constructor.preventDeferredLoadDependents},n=e.__depends__,i=0,r=n.length;i<r;i++)t.deps.push(n[i].uuid);return e.__nativeDepend__&&(t.nativeDep=e._nativeDep),t},t._parseDepsFromJson=function(e){var t=null;return(t=function(e){var t=e[1];return e[10].map((function(e){return t[e]}))}(e)).forEach((function(e,n){return t[n]=$h(e)})),t},t._descend=function(e,t,n){for(var i=this.getDeps(e),r=0;r<i.length;r++){var a=i[r];t[a]||(t[a]=!0,n.push(a),this._descend(a,t,n))}},e}()),td=[new eo];function nd(e){return e&&0==(e&e-1)}var id,rd,ad,sd,od,cd,ld=ih("cc.SimpleTexture")($f=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._gfxTexture=null,t._mipmapLevel=1,t._textureWidth=0,t._textureHeight=0,t}X(t,e);var n=t.prototype;return n.getGFXTexture=function(){return this._gfxTexture},n.destroy=function(){return this._tryDestroyTexture(),e.prototype.destroy.call(this)},n.updateImage=function(){this.updateMipmaps(0)},n.updateMipmaps=function(){},n.uploadData=function(e,t,n){if(void 0===t&&(t=0),void 0===n&&(n=0),this._gfxTexture&&!(this._mipmapLevel<=t)){var i=this._getGFXDevice();if(i){var r=td[0];r.texExtent.width=this._textureWidth>>t,r.texExtent.height=this._textureHeight>>t,r.texSubres.mipLevel=t,r.texSubres.baseArrayLayer=n,ArrayBuffer.isView(e)?i.copyBuffersToTexture([e],this._gfxTexture,td):i.copyTexImagesToTexture([e],this._gfxTexture,td)}}},n._assignImage=function(e,t,n){var r=this,a=function(){var i=e.data;if(i&&(r.uploadData(i,t,n),r._checkTextureLoaded(),ft.CLEANUP_IMAGE_CACHE)){var a=ed.getDeps(r._uuid),s=a.indexOf(e._uuid);-1!==s&&(me(a,s),e.decRef())}};if(e.loaded)a();else{if(e.once("load",(function(){a()})),!this.isCompressed){var s=i.builtinResMgr.get("black-texture").image;this.uploadData(s.data,t,n)}i.assetManager.postLoadNative(e)}},n._checkTextureLoaded=function(){this._textureReady()},n._textureReady=function(){this.loaded=!0,this.emit("load")},n._setMipmapLevel=function(e){this._mipmapLevel=e<1?1:e},n._getGfxTextureCreateInfo=function(){return null},n._tryReset=function(){if(this._tryDestroyTexture(),0!==this._mipmapLevel){var e=this._getGFXDevice();e&&this._createTexture(e)}},n._createTexture=function(e){if(0!==this._width&&0!==this._height){var t=is.NONE;this._mipFilter!==M_.NONE&&function(e,t,n){return!(e.gfxAPI===ms.WEBGL)||nd(t)&&nd(n)}(e,this._width,this._height)&&(this._mipmapLevel=function(e,t){for(var n=Math.max(e,t),i=0;n;)n>>=1,i++;return i}(this._width,this._height),t=is.GEN_MIPMAP);var n=this._getGfxTextureCreateInfo({usage:ts.SAMPLED|ts.TRANSFER_DST,format:this._getGFXFormat(),levelCount:this._mipmapLevel,flags:t|is.IMMUTABLE});if(n){var i=e.createTexture(n);this._textureWidth=n.width,this._textureHeight=n.height,this._gfxTexture=i}}},n._tryDestroyTexture=function(){this._gfxTexture&&(this._gfxTexture.destroy(),this._gfxTexture=null)},j(t,[{key:"mipmapLevel",get:function(){return this._mipmapLevel}}]),t}(of))||$f;i.SimpleTexture=ld;var ud,hd,_d,fd,dd,pd,md=e("Texture2D",(id=ih("cc.Texture2D"),rd=Dh([G_]),id((cd=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return Q(t=e.call.apply(e,[this].concat(i))||this,"_mipmaps",od,Y(t)),t}X(t,e);var n=t.prototype;return n.initialize=function(){this.mipmaps=this._mipmaps},n.onLoaded=function(){this.initialize()},n.reset=function(e){this._width=e.width,this._height=e.height,this._setGFXFormat(e.format),this._setMipmapLevel(e.mipmapLevel||1),this._tryReset()},n.create=function(e,t,n,i){void 0===n&&(n=O_.RGBA8888),void 0===i&&(i=1),this.reset({width:e,height:t,format:n,mipmapLevel:i})},n.toString=function(){return 0!==this._mipmaps.length?this._mipmaps[0].url:""},n.updateMipmaps=function(e,t){if(void 0===e&&(e=0),!(e>=this._mipmaps.length))for(var n=Math.min(void 0===t?this._mipmaps.length:t,this._mipmaps.length-e),i=0;i<n;++i){var r=e+i;this._assignImage(this._mipmaps[r],r)}},n.getHtmlElementObj=function(){return this._mipmaps[0]&&this._mipmaps[0].data instanceof HTMLElement?this._mipmaps[0].data:null},n.destroy=function(){return this._mipmaps=[],e.prototype.destroy.call(this)},n.description=function(){return"<cc.Texture2D | Name = "+(this._mipmaps[0]?this._mipmaps[0].url:"")+" | Dimension = "+this.width+" x "+this.height+">"},n.releaseTexture=function(){this.destroy()},n._serialize=function(){},n._deserialize=function(t,n){var i=t;e.prototype._deserialize.call(this,i.base,n),this._mipmaps=new Array(i.mipmaps.length);for(var r=0;r<i.mipmaps.length;++r)if(this._mipmaps[r]=new G_,i.mipmaps[r]){var a=i.mipmaps[r];n.result.push(this._mipmaps,""+r,a),this._mipmaps[r]._texture=this}},n._getGfxTextureCreateInfo=function(e){var t=new xo(es.TEX2D);return t.width=this._width,t.height=this._height,Object.assign(t,e)},n._checkTextureLoaded=function(){for(var t=!0,n=0;n<this._mipmaps.length;++n)if(!this._mipmaps[n].loaded){t=!1;break}t&&e.prototype._textureReady.call(this)},j(t,[{key:"mipmaps",get:function(){return this._mipmaps},set:function(e){var t=this;if(this._mipmaps=e,this._setMipmapLevel(this._mipmaps.length),this._mipmaps.length>0){var n=this._mipmaps[0];this.reset({width:n.width,height:n.height,format:n.format,mipmapLevel:this._mipmaps.length}),this._mipmaps.forEach((function(e,n){t._assignImage(e,n)}))}else this.reset({width:0,height:0,mipmapLevel:this._mipmaps.length})}},{key:"image",get:function(){return 0===this._mipmaps.length?null:this._mipmaps[0]},set:function(e){this.mipmaps=e?[e]:[]}}]),t}(ld),od=J((sd=cd).prototype,"_mipmaps",[rd],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),ad=sd))||ad));i.Texture2D=md,function(e){e[e.right=0]="right",e[e.left=1]="left",e[e.top=2]="top",e[e.bottom=3]="bottom",e[e.front=4]="front",e[e.back=5]="back"}(pd||(pd={}));var gd=e("TextureCube",ih("cc.TextureCube")((dd=fd=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return Q(t=e.call.apply(e,[this].concat(i))||this,"_mipmaps",_d,Y(t)),t}X(t,e),t.fromTexture2DArray=function(e,n){for(var i=[],r=e.length/6,a=0;a<r;a++){var s=6*a;i.push({front:e[s+pd.front].image,back:e[s+pd.back].image,left:e[s+pd.left].image,right:e[s+pd.right].image,top:e[s+pd.top].image,bottom:e[s+pd.bottom].image})}return(n=n||new t).mipmaps=i,n};var n=t.prototype;return n.onLoaded=function(){this.mipmaps=this._mipmaps,this.loaded=!0,this.emit("load")},n.reset=function(e){this._width=e.width,this._height=e.height,this._setGFXFormat(e.format),this._setMipmapLevel(e.mipmapLevel||1),this._tryReset()},n.updateMipmaps=function(e,t){var n=this;if(void 0===e&&(e=0),!(e>=this._mipmaps.length))for(var i=Math.min(void 0===t?this._mipmaps.length:t,this._mipmaps.length-e),r=function(t){var i=e+t;vd(n._mipmaps[i],(function(e,t){n._assignImage(e,i,t)}))},a=0;a<i;++a)r(a)},n.destroy=function(){return this._mipmaps=[],e.prototype.destroy.call(this)},n.releaseTexture=function(){this.mipmaps=[]},n._serialize=function(){},n._deserialize=function(t,n){var i=t;e.prototype._deserialize.call(this,i.base,n),this._mipmaps=new Array(i.mipmaps.length);for(var r=0;r<i.mipmaps.length;++r){this._mipmaps[r]={front:new G_,back:new G_,left:new G_,right:new G_,top:new G_,bottom:new G_};var a=i.mipmaps[r];n.result.push(this._mipmaps[r],"front",a.front),n.result.push(this._mipmaps[r],"back",a.back),n.result.push(this._mipmaps[r],"left",a.left),n.result.push(this._mipmaps[r],"right",a.right),n.result.push(this._mipmaps[r],"top",a.top),n.result.push(this._mipmaps[r],"bottom",a.bottom)}},n._getGfxTextureCreateInfo=function(e){var t=new xo(es.CUBE);return t.width=this._width,t.height=this._height,t.layerCount=6,Object.assign(t,e),t.flags|=is.CUBEMAP,t},j(t,[{key:"mipmaps",get:function(){return this._mipmaps},set:function(e){var t=this;if(this._mipmaps=e,this._setMipmapLevel(this._mipmaps.length),this._mipmaps.length>0){var n=this._mipmaps[0].front;this.reset({width:n.width,height:n.height,format:n.format,mipmapLevel:this._mipmaps.length}),this._mipmaps.forEach((function(e,n){vd(e,(function(e,i){t._assignImage(e,n,i)}))}))}else this.reset({width:0,height:0,mipmapLevel:this._mipmaps.length})}},{key:"image",get:function(){return 0===this._mipmaps.length?null:this._mipmaps[0]},set:function(e){this.mipmaps=e?[e]:[]}}]),t}(ld),fd.FaceIndex=pd,_d=J((hd=dd).prototype,"_mipmaps",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),ud=hd))||ud);function vd(e,t){t(e.front,pd.front),t(e.back,pd.back),t(e.left,pd.left),t(e.right,pd.right),t(e.top,pd.top),t(e.bottom,pd.bottom)}i.TextureCube=gd;var yd,Sd,Ed,Td=e("effects",[{name:"billboard",techniques:[{name:"add",passes:[{rasterizerState:{cullMode:0},blendState:{targets:[{blend:!0,blendSrc:2,blendDst:1,blendSrcAlpha:2,blendDstAlpha:1}]},program:"billboard|vert:vs_main|tinted-fs:add",depthStencilState:{depthTest:!0,depthWrite:!1},properties:{mainTexture:{value:"grey",type:28},mainTiling_Offset:{value:[1,1,0,0],type:16},tintColor:{value:[.5,.5,.5,.5],type:16}}}]}],shaders:[{name:"billboard|vert:vs_main|tinted-fs:add",hash:2143664850,builtins:{globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplers:[]},locals:{blocks:[{name:"CCLocal",defines:[]}],samplers:[]}},defines:[{name:"CC_USE_HDR",type:"boolean"}],blocks:[{name:"Constants",defines:[],binding:0,stageFlags:1,members:[{name:"mainTiling_Offset",type:16,count:1},{name:"frameTile_velLenScale",type:16,count:1},{name:"scale",type:16,count:1}]},{name:"builtin",defines:[],binding:1,stageFlags:1,members:[{name:"cc_size_rotation",type:16,count:1}]},{name:"FragConstants",defines:[],binding:2,stageFlags:16,members:[{name:"tintColor",type:16,count:1}]}],samplers:[{name:"mainTexture",type:28,count:1,defines:[],stageFlags:16,binding:3}],attributes:[{name:"a_position",type:15,count:1,defines:[],stageFlags:1,format:32,location:0},{name:"a_texCoord",type:14,count:1,defines:[],stageFlags:1,format:21,location:1},{name:"a_color",type:16,count:1,defines:[],stageFlags:1,format:44,location:2}]}]},{name:"clear-stencil",techniques:[{passes:[{blendState:{targets:[{blend:!0}]},rasterizerState:{cullMode:0},program:"clear-stencil|sprite-vs:vert|sprite-fs:frag",depthStencilState:{depthTest:!1,depthWrite:!1}}]}],shaders:[{name:"clear-stencil|sprite-vs:vert|sprite-fs:frag",hash:1062464958,builtins:{globals:{blocks:[],samplers:[]},locals:{blocks:[],samplers:[]}},defines:[],blocks:[],samplers:[],attributes:[{name:"a_position",type:15,count:1,defines:[],stageFlags:1,format:32,location:0}]}]},{name:"graphics",techniques:[{passes:[{blendState:{targets:[{blend:!0,blendSrc:1,blendDst:4,blendSrcAlpha:1,blendDstAlpha:4}]},rasterizerState:{cullMode:0},program:"graphics|vs:vert|fs:frag",depthStencilState:{depthTest:!1,depthWrite:!1}}]}],shaders:[{name:"graphics|vs:vert|fs:frag",hash:3946667351,builtins:{globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplers:[]},locals:{blocks:[{name:"CCLocal",defines:[]}],samplers:[]}},defines:[],blocks:[],samplers:[],attributes:[{name:"a_position",type:15,count:1,defines:[],stageFlags:1,format:32,location:0},{name:"a_color",type:16,count:1,defines:[],stageFlags:1,format:44,location:1},{name:"a_dist",type:13,count:1,defines:[],stageFlags:1,format:11,location:2}]}]},{name:"particle-gpu",techniques:[{name:"add",passes:[{rasterizerState:{cullMode:0},blendState:{targets:[{blend:!0,blendSrc:2,blendDst:1,blendSrcAlpha:2,blendDstAlpha:1}]},program:"particle-gpu|particle-vs-gpu:gpvs_main|tinted-fs:add",depthStencilState:{depthTest:!0,depthWrite:!1},properties:{mainTexture:{value:"grey",type:28},mainTiling_Offset:{value:[1,1,0,0],type:16},tintColor:{value:[.5,.5,.5,.5],type:16}}}]}],shaders:[{name:"particle-gpu|particle-vs-gpu:gpvs_main|tinted-fs:add",hash:3696836305,builtins:{globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplers:[]},locals:{blocks:[{name:"CCLocal",defines:[]}],samplers:[]}},defines:[{name:"CC_RENDER_MODE",type:"number",range:[0,4]},{name:"COLOR_OVER_TIME_MODULE_ENABLE",type:"boolean"},{name:"ROTATION_OVER_TIME_MODULE_ENABLE",type:"boolean"},{name:"SIZE_OVER_TIME_MODULE_ENABLE",type:"boolean"},{name:"FORCE_OVER_TIME_MODULE_ENABLE",type:"boolean"},{name:"VELOCITY_OVER_TIME_MODULE_ENABLE",type:"boolean"},{name:"TEXTURE_ANIMATION_MODULE_ENABLE",type:"boolean"},{name:"CC_USE_WORLD_SPACE",type:"boolean"},{name:"CC_USE_HDR",type:"boolean"}],blocks:[{name:"Constants",defines:[],binding:0,stageFlags:1,members:[{name:"mainTiling_Offset",type:16,count:1},{name:"frameTile_velLenScale",type:16,count:1},{name:"scale",type:16,count:1}]},{name:"SampleConstants",defines:[],binding:1,stageFlags:1,members:[{name:"u_sampleInfo",type:16,count:1}]},{name:"TickConstants",defines:[],binding:2,stageFlags:1,members:[{name:"u_worldRot",type:16,count:1},{name:"u_timeDelta",type:16,count:1}]},{name:"ColorConstant",defines:["COLOR_OVER_TIME_MODULE_ENABLE"],binding:3,stageFlags:1,members:[{name:"u_color_mode",type:5,count:1}]},{name:"RotationConstant",defines:["ROTATION_OVER_TIME_MODULE_ENABLE"],binding:4,stageFlags:1,members:[{name:"u_rotation_mode",type:5,count:1}]},{name:"SizeConstant",defines:["SIZE_OVER_TIME_MODULE_ENABLE"],binding:5,stageFlags:1,members:[{name:"u_size_mode",type:5,count:1}]},{name:"ForceConstant",defines:["FORCE_OVER_TIME_MODULE_ENABLE"],binding:6,stageFlags:1,members:[{name:"u_force_mode",type:5,count:1},{name:"u_force_space",type:5,count:1}]},{name:"VelocityConstant",defines:["VELOCITY_OVER_TIME_MODULE_ENABLE"],binding:7,stageFlags:1,members:[{name:"u_velocity_mode",type:5,count:1},{name:"u_velocity_space",type:5,count:1}]},{name:"AnimationConstant",defines:["TEXTURE_ANIMATION_MODULE_ENABLE"],binding:8,stageFlags:1,members:[{name:"u_anim_info",type:16,count:1}]},{name:"FragConstants",defines:[],binding:9,stageFlags:16,members:[{name:"tintColor",type:16,count:1}]}],samplers:[{name:"color_over_time_tex0",type:28,count:1,defines:["COLOR_OVER_TIME_MODULE_ENABLE"],stageFlags:1,binding:10},{name:"rotation_over_time_tex0",type:28,count:1,defines:["ROTATION_OVER_TIME_MODULE_ENABLE"],stageFlags:1,binding:11},{name:"size_over_time_tex0",type:28,count:1,defines:["SIZE_OVER_TIME_MODULE_ENABLE"],stageFlags:1,binding:12},{name:"force_over_time_tex0",type:28,count:1,defines:["FORCE_OVER_TIME_MODULE_ENABLE"],stageFlags:1,binding:13},{name:"velocity_over_time_tex0",type:28,count:1,defines:["VELOCITY_OVER_TIME_MODULE_ENABLE"],stageFlags:1,binding:14},{name:"texture_animation_tex0",type:28,count:1,defines:["TEXTURE_ANIMATION_MODULE_ENABLE"],stageFlags:1,binding:15},{name:"mainTexture",type:28,count:1,defines:[],stageFlags:16,binding:16}],attributes:[{name:"a_position_starttime",type:16,count:1,defines:[],stageFlags:1,format:44,location:0},{name:"a_size_uv",type:16,count:1,defines:[],stageFlags:1,format:44,location:1},{name:"a_rotation_uv",type:16,count:1,defines:[],stageFlags:1,format:44,location:2},{name:"a_color",type:16,count:1,defines:[],stageFlags:1,format:44,location:3},{name:"a_dir_life",type:16,count:1,defines:[],stageFlags:1,format:44,location:4},{name:"a_rndSeed",type:13,count:1,defines:[],stageFlags:1,format:11,location:5},{name:"a_texCoord",type:15,count:1,defines:["CC_RENDER_MODE"],stageFlags:1,format:32,location:6},{name:"a_texCoord3",type:15,count:1,defines:["CC_RENDER_MODE"],stageFlags:1,format:32,location:7},{name:"a_normal",type:15,count:1,defines:["CC_RENDER_MODE"],stageFlags:1,format:32,location:8},{name:"a_color1",type:16,count:1,defines:["CC_RENDER_MODE"],stageFlags:1,format:44,location:9}]}]},{name:"particle-trail",techniques:[{name:"add",passes:[{rasterizerState:{cullMode:0},blendState:{targets:[{blend:!0,blendSrc:2,blendDst:1,blendSrcAlpha:2,blendDstAlpha:1}]},program:"particle-trail|particle-trail:vs_main|tinted-fs:add",depthStencilState:{depthTest:!0,depthWrite:!1},properties:{mainTexture:{value:"grey",type:28},mainTiling_Offset:{value:[1,1,0,0],type:16},frameTile_velLenScale:{value:[1,1,0,0],type:16},tintColor:{value:[.5,.5,.5,.5],type:16}}}]}],shaders:[{name:"particle-trail|particle-trail:vs_main|tinted-fs:add",hash:4115155772,builtins:{globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplers:[]},locals:{blocks:[{name:"CCLocal",defines:[]}],samplers:[]}},defines:[{name:"CC_RENDER_MODE",type:"number",range:[0,4]},{name:"CC_DRAW_WIRE_FRAME",type:"boolean"},{name:"CC_USE_WORLD_SPACE",type:"boolean"},{name:"CC_USE_HDR",type:"boolean"}],blocks:[{name:"Constants",defines:[],binding:0,stageFlags:1,members:[{name:"mainTiling_Offset",type:16,count:1},{name:"frameTile_velLenScale",type:16,count:1},{name:"scale",type:16,count:1}]},{name:"FragConstants",defines:[],binding:1,stageFlags:16,members:[{name:"tintColor",type:16,count:1}]}],samplers:[{name:"mainTexture",type:28,count:1,defines:[],stageFlags:16,binding:2}],attributes:[{name:"a_position",type:15,count:1,defines:[],stageFlags:1,format:32,location:0},{name:"a_texCoord",type:16,count:1,defines:[],stageFlags:1,format:44,location:1},{name:"a_texCoord1",type:15,count:1,defines:[],stageFlags:1,format:32,location:2},{name:"a_texCoord2",type:15,count:1,defines:[],stageFlags:1,format:32,location:3},{name:"a_color",type:16,count:1,defines:[],stageFlags:1,format:44,location:4}]}]},{name:"particle",techniques:[{name:"add",passes:[{rasterizerState:{cullMode:0},blendState:{targets:[{blend:!0,blendSrc:2,blendDst:1,blendSrcAlpha:2,blendDstAlpha:1}]},program:"particle|particle-vs-legacy:lpvs_main|tinted-fs:add",depthStencilState:{depthTest:!0,depthWrite:!1},properties:{mainTexture:{value:"grey",type:28},mainTiling_Offset:{value:[1,1,0,0],type:16},tintColor:{value:[.5,.5,.5,.5],type:16}}}]}],shaders:[{name:"particle|particle-vs-legacy:lpvs_main|tinted-fs:add",hash:66662317,builtins:{globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplers:[]},locals:{blocks:[{name:"CCLocal",defines:[]}],samplers:[]}},defines:[{name:"CC_RENDER_MODE",type:"number",range:[0,4]},{name:"CC_USE_WORLD_SPACE",type:"boolean"},{name:"CC_USE_HDR",type:"boolean"}],blocks:[{name:"Constants",defines:[],binding:0,stageFlags:1,members:[{name:"mainTiling_Offset",type:16,count:1},{name:"frameTile_velLenScale",type:16,count:1},{name:"scale",type:16,count:1}]},{name:"FragConstants",defines:[],binding:1,stageFlags:16,members:[{name:"tintColor",type:16,count:1}]}],samplers:[{name:"mainTexture",type:28,count:1,defines:[],stageFlags:16,binding:2}],attributes:[{name:"a_position",type:15,count:1,defines:[],stageFlags:1,format:32,location:0},{name:"a_texCoord",type:15,count:1,defines:[],stageFlags:1,format:32,location:1},{name:"a_texCoord1",type:15,count:1,defines:[],stageFlags:1,format:32,location:2},{name:"a_texCoord2",type:15,count:1,defines:[],stageFlags:1,format:32,location:3},{name:"a_color",type:16,count:1,defines:[],stageFlags:1,format:44,location:4},{name:"a_color1",type:15,count:1,defines:["CC_RENDER_MODE"],stageFlags:1,format:32,location:8},{name:"a_texCoord3",type:15,count:1,defines:["CC_RENDER_MODE"],stageFlags:1,format:32,location:6},{name:"a_normal",type:15,count:1,defines:["CC_RENDER_MODE"],stageFlags:1,format:32,location:7}]}]},{name:"spine",techniques:[{passes:[{blendState:{targets:[{blend:!0,blendSrc:2,blendDst:4,blendDstAlpha:4}]},rasterizerState:{cullMode:0},program:"spine|sprite-vs:vert|sprite-fs:frag",depthStencilState:{depthTest:!1,depthWrite:!1},properties:{alphaThreshold:{value:[.5],type:13}}}]}],shaders:[{name:"spine|sprite-vs:vert|sprite-fs:frag",hash:4078504952,builtins:{globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplers:[]},locals:{blocks:[{name:"CCLocal",defines:["USE_LOCAL"]}],samplers:[{name:"cc_spriteTexture",defines:[]}]}},defines:[{name:"USE_LOCAL",type:"boolean"},{name:"TWO_COLORED",type:"boolean"},{name:"USE_ALPHA_TEST",type:"boolean"}],blocks:[{name:"ALPHA_TEST_DATA",defines:["USE_ALPHA_TEST"],binding:0,stageFlags:16,members:[{name:"alphaThreshold",type:13,count:1}]}],samplers:[],attributes:[{name:"a_position",type:15,count:1,defines:[],stageFlags:1,format:32,location:0},{name:"a_texCoord",type:14,count:1,defines:[],stageFlags:1,format:21,location:1},{name:"a_color",type:16,count:1,defines:[],stageFlags:1,format:44,location:2},{name:"a_color2",type:16,count:1,defines:["TWO_COLORED"],stageFlags:1,format:44,location:3}]}]},{name:"sprite",techniques:[{passes:[{blendState:{targets:[{blend:!0,blendSrc:2,blendDst:4,blendDstAlpha:4}]},rasterizerState:{cullMode:0},program:"sprite|sprite-vs:vert|sprite-fs:frag",depthStencilState:{depthTest:!1,depthWrite:!1},properties:{alphaThreshold:{value:[.5],type:13}}}]}],shaders:[{name:"sprite|sprite-vs:vert|sprite-fs:frag",hash:3990469549,builtins:{globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplers:[]},locals:{blocks:[{name:"CCLocal",defines:["USE_LOCAL"]}],samplers:[{name:"cc_spriteTexture",defines:["USE_TEXTURE"]}]}},defines:[{name:"USE_LOCAL",type:"boolean"},{name:"USE_PIXEL_ALIGNMENT",type:"boolean"},{name:"CC_USE_EMBEDDED_ALPHA",type:"boolean"},{name:"USE_ALPHA_TEST",type:"boolean"},{name:"USE_TEXTURE",type:"boolean"},{name:"IS_GRAY",type:"boolean"}],blocks:[{name:"ALPHA_TEST_DATA",defines:["USE_ALPHA_TEST"],binding:0,stageFlags:16,members:[{name:"alphaThreshold",type:13,count:1}]}],samplers:[],attributes:[{name:"a_position",type:15,count:1,defines:[],stageFlags:1,format:32,location:0},{name:"a_texCoord",type:14,count:1,defines:[],stageFlags:1,format:21,location:1},{name:"a_color",type:16,count:1,defines:[],stageFlags:1,format:44,location:2}]}]},{name:"standard",techniques:[{name:"opaque",passes:[{program:"standard|standard-vs:vert|standard-fs:frag",properties:{tilingOffset:{value:[1,1,0,0],type:16},mainColor:{value:[1,1,1,1],type:16,handleInfo:["albedo",0,16]},albedoScale:{value:[1,1,1],type:15,handleInfo:["albedoScaleAndCutoff",0,15]},alphaThreshold:{value:[.5],type:13,handleInfo:["albedoScaleAndCutoff",3,13]},occlusion:{value:[1],type:13,handleInfo:["pbrParams",0,13]},roughness:{value:[.8],type:13,handleInfo:["pbrParams",1,13]},metallic:{value:[.6],type:13,handleInfo:["pbrParams",2,13]},normalStrenth:{value:[1],type:13,handleInfo:["pbrParams",3,13]},emissive:{value:[0,0,0,1],type:16},emissiveScale:{value:[1,1,1],type:15,handleInfo:["emissiveScaleParam",0,15]},mainTexture:{value:"grey",type:28,handleInfo:["albedoMap",0,28]},normalMap:{value:"normal",type:28},pbrMap:{value:"grey",type:28},metallicRoughnessMap:{value:"grey",type:28},occlusionMap:{value:"white",type:28},emissiveMap:{value:"grey",type:28},albedo:{type:16,value:[1,1,1,1]},albedoScaleAndCutoff:{type:16,value:[1,1,1,.5]},pbrParams:{type:16,value:[1,.8,.6,1]},emissiveScaleParam:{type:16,value:[1,1,1,0]},albedoMap:{type:28,value:"grey"}}},{phase:"forward-add",propertyIndex:0,embeddedMacros:{CC_FORWARD_ADD:!0},blendState:{targets:[{blend:!0,blendSrc:1,blendDst:1,blendSrcAlpha:0,blendDstAlpha:1}]},program:"standard|standard-vs:vert|standard-fs:frag",depthStencilState:{depthFunc:2,depthTest:!0,depthWrite:!1},properties:{tilingOffset:{value:[1,1,0,0],type:16},mainColor:{value:[1,1,1,1],type:16,handleInfo:["albedo",0,16]},albedoScale:{value:[1,1,1],type:15,handleInfo:["albedoScaleAndCutoff",0,15]},alphaThreshold:{value:[.5],type:13,handleInfo:["albedoScaleAndCutoff",3,13]},occlusion:{value:[1],type:13,handleInfo:["pbrParams",0,13]},roughness:{value:[.8],type:13,handleInfo:["pbrParams",1,13]},metallic:{value:[.6],type:13,handleInfo:["pbrParams",2,13]},normalStrenth:{value:[1],type:13,handleInfo:["pbrParams",3,13]},emissive:{value:[0,0,0,1],type:16},emissiveScale:{value:[1,1,1],type:15,handleInfo:["emissiveScaleParam",0,15]},mainTexture:{value:"grey",type:28,handleInfo:["albedoMap",0,28]},normalMap:{value:"normal",type:28},pbrMap:{value:"grey",type:28},metallicRoughnessMap:{value:"grey",type:28},occlusionMap:{value:"white",type:28},emissiveMap:{value:"grey",type:28},albedo:{type:16,value:[1,1,1,1]},albedoScaleAndCutoff:{type:16,value:[1,1,1,.5]},pbrParams:{type:16,value:[1,.8,.6,1]},emissiveScaleParam:{type:16,value:[1,1,1,0]},albedoMap:{type:28,value:"grey"}}},{phase:"shadow-caster",propertyIndex:0,rasterizerState:{cullMode:1},program:"standard|shadow-caster-vs:vert|shadow-caster-fs:frag",properties:{tilingOffset:{value:[1,1,0,0],type:16},mainColor:{value:[1,1,1,1],type:16,handleInfo:["albedo",0,16]},albedoScale:{value:[1,1,1],type:15,handleInfo:["albedoScaleAndCutoff",0,15]},alphaThreshold:{value:[.5],type:13,handleInfo:["albedoScaleAndCutoff",3,13]},occlusion:{value:[1],type:13,handleInfo:["pbrParams",0,13]},roughness:{value:[.8],type:13,handleInfo:["pbrParams",1,13]},metallic:{value:[.6],type:13,handleInfo:["pbrParams",2,13]},normalStrenth:{value:[1],type:13,handleInfo:["pbrParams",3,13]},emissive:{value:[0,0,0,1],type:16},emissiveScale:{value:[1,1,1],type:15,handleInfo:["emissiveScaleParam",0,15]},mainTexture:{value:"grey",type:28,handleInfo:["albedoMap",0,28]},albedo:{type:16,value:[1,1,1,1]},albedoScaleAndCutoff:{type:16,value:[1,1,1,.5]},pbrParams:{type:16,value:[1,.8,.6,1]},emissiveScaleParam:{type:16,value:[1,1,1,0]},albedoMap:{type:28,value:"grey"}}}]}],shaders:[{name:"standard|standard-vs:vert|standard-fs:frag",hash:2668109714,builtins:{globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]},{name:"CCShadow",defines:[]}],samplers:[{name:"cc_environment",defines:["CC_USE_IBL"]},{name:"cc_shadowMap",defines:["CC_RECEIVE_SHADOW"]},{name:"cc_spotLightingMap",defines:["CC_RECEIVE_SHADOW"]}]},locals:{blocks:[{name:"CCMorph",defines:["CC_USE_MORPH"]},{name:"CCSkinningTexture",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION"]},{name:"CCSkinningAnimation",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION"]},{name:"CCSkinning",defines:["CC_USE_SKINNING","!CC_USE_BAKED_ANIMATION"]},{name:"CCLocalBatched",defines:["!USE_INSTANCING","USE_BATCHING"]},{name:"CCLocal",defines:["!USE_INSTANCING","!USE_BATCHING"]},{name:"CCForwardLight",defines:["CC_FORWARD_ADD"]}],samplers:[{name:"cc_PositionDisplacements",defines:["CC_USE_MORPH","CC_MORPH_TARGET_HAS_POSITION"]},{name:"cc_NormalDisplacements",defines:["CC_USE_MORPH","CC_MORPH_TARGET_HAS_NORMAL"]},{name:"cc_TangentDisplacements",defines:["CC_USE_MORPH","CC_MORPH_TARGET_HAS_TANGENT"]},{name:"cc_jointTexture",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION"]},{name:"cc_lightingMap",defines:["USE_LIGHTMAP","!USE_BATCHING","!CC_FORWARD_ADD"]}]}},defines:[{name:"CC_USE_MORPH",type:"boolean"},{name:"CC_MORPH_TARGET_COUNT",type:"number",range:[2,8]},{name:"CC_SUPPORT_FLOAT_TEXTURE",type:"boolean"},{name:"CC_MORPH_PRECOMPUTED",type:"boolean"},{name:"CC_MORPH_TARGET_HAS_POSITION",type:"boolean"},{name:"CC_MORPH_TARGET_HAS_NORMAL",type:"boolean"},{name:"CC_MORPH_TARGET_HAS_TANGENT",type:"boolean"},{name:"CC_USE_SKINNING",type:"boolean"},{name:"CC_USE_BAKED_ANIMATION",type:"boolean"},{name:"USE_INSTANCING",type:"boolean"},{name:"USE_BATCHING",type:"boolean"},{name:"USE_LIGHTMAP",type:"boolean"},{name:"CC_USE_FOG",type:"number",range:[0,4]},{name:"CC_FORWARD_ADD",type:"boolean"},{name:"USE_VERTEX_COLOR",type:"boolean"},{name:"USE_NORMAL_MAP",type:"boolean"},{name:"HAS_SECOND_UV",type:"boolean"},{name:"CC_USE_IBL",type:"number",range:[0,2]},{name:"CC_RECEIVE_SHADOW",type:"boolean"},{name:"CC_USE_HDR",type:"boolean"},{name:"USE_ALBEDO_MAP",type:"boolean"},{name:"ALBEDO_UV",type:"string",options:["v_uv","v_uv1"]},{name:"NORMAL_UV",type:"string",options:["v_uv","v_uv1"]},{name:"PBR_UV",type:"string",options:["v_uv","v_uv1"]},{name:"USE_PBR_MAP",type:"boolean"},{name:"USE_METALLIC_ROUGHNESS_MAP",type:"boolean"},{name:"USE_OCCLUSION_MAP",type:"boolean"},{name:"USE_EMISSIVE_MAP",type:"boolean"},{name:"EMISSIVE_UV",type:"string",options:["v_uv","v_uv1"]},{name:"USE_ALPHA_TEST",type:"boolean"},{name:"ALPHA_TEST_CHANNEL",type:"string",options:["a","r"]}],blocks:[{name:"Constants",defines:[],binding:0,stageFlags:17,members:[{name:"tilingOffset",type:16,count:1},{name:"albedo",type:16,count:1},{name:"albedoScaleAndCutoff",type:16,count:1},{name:"pbrParams",type:16,count:1},{name:"emissive",type:16,count:1},{name:"emissiveScaleParam",type:16,count:1}]}],samplers:[{name:"albedoMap",type:28,count:1,defines:["USE_ALBEDO_MAP"],stageFlags:16,binding:1},{name:"normalMap",type:28,count:1,defines:["USE_NORMAL_MAP"],stageFlags:16,binding:2},{name:"pbrMap",type:28,count:1,defines:["USE_PBR_MAP"],stageFlags:16,binding:3},{name:"metallicRoughnessMap",type:28,count:1,defines:["USE_METALLIC_ROUGHNESS_MAP"],stageFlags:16,binding:4},{name:"occlusionMap",type:28,count:1,defines:["USE_OCCLUSION_MAP"],stageFlags:16,binding:5},{name:"emissiveMap",type:28,count:1,defines:["USE_EMISSIVE_MAP"],stageFlags:16,binding:6}],attributes:[{name:"a_position",type:15,count:1,defines:[],stageFlags:1,format:32,location:0},{name:"a_normal",type:15,count:1,defines:[],stageFlags:1,format:32,location:1},{name:"a_texCoord",type:14,count:1,defines:[],stageFlags:1,format:21,location:2},{name:"a_tangent",type:16,count:1,defines:[],stageFlags:1,format:44,location:3},{name:"a_vertexId",type:13,count:1,defines:["CC_USE_MORPH"],stageFlags:1,format:11,location:6},{name:"a_joints",type:12,count:1,defines:["CC_USE_SKINNING"],stageFlags:1,format:42,location:4},{name:"a_weights",type:16,count:1,defines:["CC_USE_SKINNING"],stageFlags:1,format:44,location:5},{name:"a_jointAnimInfo",type:16,count:1,defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION","USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:7},{name:"a_matWorld0",type:16,count:1,defines:["USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:8},{name:"a_matWorld1",type:16,count:1,defines:["USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:9},{name:"a_matWorld2",type:16,count:1,defines:["USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:10},{name:"a_lightingMapUVParam",type:16,count:1,defines:["USE_INSTANCING","USE_LIGHTMAP"],stageFlags:1,format:44,isInstanced:!0,location:11},{name:"a_dyn_batch_id",type:13,count:1,defines:["!USE_INSTANCING","USE_BATCHING"],stageFlags:1,format:11,location:12},{name:"a_color",type:16,count:1,defines:["USE_VERTEX_COLOR"],stageFlags:1,format:44,location:13},{name:"a_texCoord1",type:14,count:1,defines:[],stageFlags:1,format:21,location:14}]},{name:"standard|shadow-caster-vs:vert|shadow-caster-fs:frag",hash:3020491,builtins:{globals:{blocks:[{name:"CCShadow",defines:[]}],samplers:[]},locals:{blocks:[{name:"CCMorph",defines:["CC_USE_MORPH"]},{name:"CCSkinningTexture",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION"]},{name:"CCSkinningAnimation",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION"]},{name:"CCSkinning",defines:["CC_USE_SKINNING","!CC_USE_BAKED_ANIMATION"]},{name:"CCLocalBatched",defines:["!USE_INSTANCING","USE_BATCHING"]},{name:"CCLocal",defines:["!USE_INSTANCING","!USE_BATCHING"]}],samplers:[{name:"cc_PositionDisplacements",defines:["CC_USE_MORPH","CC_MORPH_TARGET_HAS_POSITION"]},{name:"cc_NormalDisplacements",defines:["CC_USE_MORPH","CC_MORPH_TARGET_HAS_NORMAL"]},{name:"cc_TangentDisplacements",defines:["CC_USE_MORPH","CC_MORPH_TARGET_HAS_TANGENT"]},{name:"cc_jointTexture",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION"]}]}},defines:[{name:"CC_USE_MORPH",type:"boolean"},{name:"CC_MORPH_TARGET_COUNT",type:"number",range:[2,8]},{name:"CC_SUPPORT_FLOAT_TEXTURE",type:"boolean"},{name:"CC_MORPH_PRECOMPUTED",type:"boolean"},{name:"CC_MORPH_TARGET_HAS_POSITION",type:"boolean"},{name:"CC_MORPH_TARGET_HAS_NORMAL",type:"boolean"},{name:"CC_MORPH_TARGET_HAS_TANGENT",type:"boolean"},{name:"CC_USE_SKINNING",type:"boolean"},{name:"CC_USE_BAKED_ANIMATION",type:"boolean"},{name:"USE_INSTANCING",type:"boolean"},{name:"USE_BATCHING",type:"boolean"},{name:"USE_LIGHTMAP",type:"boolean"},{name:"HAS_SECOND_UV",type:"boolean"},{name:"USE_ALBEDO_MAP",type:"boolean"},{name:"ALBEDO_UV",type:"string",options:["v_uv","v_uv1"]},{name:"USE_ALPHA_TEST",type:"boolean"},{name:"ALPHA_TEST_CHANNEL",type:"string",options:["a","r"]}],blocks:[{name:"Constants",defines:[],binding:0,stageFlags:17,members:[{name:"tilingOffset",type:16,count:1},{name:"albedo",type:16,count:1},{name:"albedoScaleAndCutoff",type:16,count:1},{name:"pbrParams",type:16,count:1},{name:"emissive",type:16,count:1},{name:"emissiveScaleParam",type:16,count:1}]}],samplers:[{name:"albedoMap",type:28,count:1,defines:["USE_ALBEDO_MAP"],stageFlags:16,binding:1}],attributes:[{name:"a_position",type:15,count:1,defines:[],stageFlags:1,format:32,location:0},{name:"a_normal",type:15,count:1,defines:[],stageFlags:1,format:32,location:1},{name:"a_texCoord",type:14,count:1,defines:[],stageFlags:1,format:21,location:2},{name:"a_tangent",type:16,count:1,defines:[],stageFlags:1,format:44,location:3},{name:"a_vertexId",type:13,count:1,defines:["CC_USE_MORPH"],stageFlags:1,format:11,location:6},{name:"a_joints",type:12,count:1,defines:["CC_USE_SKINNING"],stageFlags:1,format:42,location:4},{name:"a_weights",type:16,count:1,defines:["CC_USE_SKINNING"],stageFlags:1,format:44,location:5},{name:"a_jointAnimInfo",type:16,count:1,defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION","USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:7},{name:"a_matWorld0",type:16,count:1,defines:["USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:8},{name:"a_matWorld1",type:16,count:1,defines:["USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:9},{name:"a_matWorld2",type:16,count:1,defines:["USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:10},{name:"a_lightingMapUVParam",type:16,count:1,defines:["USE_INSTANCING","USE_LIGHTMAP"],stageFlags:1,format:44,isInstanced:!0,location:11},{name:"a_dyn_batch_id",type:13,count:1,defines:["!USE_INSTANCING","USE_BATCHING"],stageFlags:1,format:11,location:12},{name:"a_texCoord1",type:14,count:1,defines:[],stageFlags:1,format:21,location:13}]}]},{name:"terrain",techniques:[{name:"opaque",passes:[{program:"terrain|terrain-vs:vert|terrain-fs:frag",properties:{UVScale:{value:[1,1,1,1],type:16},lightMapUVParam:{value:[0,0,0,0],type:16},metallic:{value:[0,0,0,0],type:16},roughness:{value:[1,1,1,1],type:16},weightMap:{value:"black",type:28},detailMap0:{value:"grey",type:28},detailMap1:{value:"grey",type:28},detailMap2:{value:"grey",type:28},detailMap3:{value:"grey",type:28},normalMap0:{value:"normal-texture",type:28},normalMap1:{value:"normal-texture",type:28},normalMap2:{value:"normal-texture",type:28},normalMap3:{value:"normal-texture",type:28},lightMap:{value:"grey",type:28}}},{phase:"forward-add",propertyIndex:0,embeddedMacros:{CC_FORWARD_ADD:!0},blendState:{targets:[{blend:!0,blendSrc:1,blendDst:1,blendSrcAlpha:0,blendDstAlpha:1}]},program:"terrain|terrain-vs:vert|terrain-fs:frag",depthStencilState:{depthFunc:2,depthTest:!0,depthWrite:!1},properties:{UVScale:{value:[1,1,1,1],type:16},lightMapUVParam:{value:[0,0,0,0],type:16},metallic:{value:[0,0,0,0],type:16},roughness:{value:[1,1,1,1],type:16},weightMap:{value:"black",type:28},detailMap0:{value:"grey",type:28},detailMap1:{value:"grey",type:28},detailMap2:{value:"grey",type:28},detailMap3:{value:"grey",type:28},normalMap0:{value:"normal-texture",type:28},normalMap1:{value:"normal-texture",type:28},normalMap2:{value:"normal-texture",type:28},normalMap3:{value:"normal-texture",type:28},lightMap:{value:"grey",type:28}}},{phase:"shadow-add",propertyIndex:0,rasterizerState:{cullMode:2},program:"terrain|shadow-caster-vs:vert|shadow-caster-fs:frag"}]}],shaders:[{name:"terrain|terrain-vs:vert|terrain-fs:frag",hash:2952542850,builtins:{globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]},{name:"CCShadow",defines:[]}],samplers:[{name:"cc_environment",defines:["CC_USE_IBL"]},{name:"cc_shadowMap",defines:["CC_RECEIVE_SHADOW"]},{name:"cc_spotLightingMap",defines:["CC_RECEIVE_SHADOW"]}]},locals:{blocks:[{name:"CCLocal",defines:[]},{name:"CCForwardLight",defines:["CC_FORWARD_ADD"]}],samplers:[]}},defines:[{name:"CC_USE_FOG",type:"number",range:[0,4]},{name:"CC_FORWARD_ADD",type:"boolean"},{name:"USE_NORMALMAP",type:"boolean"},{name:"USE_LIGHTMAP",type:"boolean"},{name:"CC_USE_IBL",type:"number",range:[0,2]},{name:"CC_RECEIVE_SHADOW",type:"boolean"},{name:"USE_BATCHING",type:"boolean"},{name:"CC_USE_HDR",type:"boolean"},{name:"LAYERS",type:"number",range:[0,4]},{name:"USE_PBR",type:"boolean"}],blocks:[{name:"TexCoords",defines:[],binding:0,stageFlags:1,members:[{name:"UVScale",type:16,count:1},{name:"lightMapUVParam",type:16,count:1}]},{name:"PbrParams",defines:[],binding:1,stageFlags:16,members:[{name:"metallic",type:16,count:1},{name:"roughness",type:16,count:1}]}],samplers:[{name:"weightMap",type:28,count:1,defines:[],stageFlags:16,binding:2},{name:"detailMap0",type:28,count:1,defines:[],stageFlags:16,binding:3},{name:"detailMap1",type:28,count:1,defines:[],stageFlags:16,binding:4},{name:"detailMap2",type:28,count:1,defines:[],stageFlags:16,binding:5},{name:"detailMap3",type:28,count:1,defines:[],stageFlags:16,binding:6},{name:"normalMap0",type:28,count:1,defines:[],stageFlags:16,binding:7},{name:"normalMap1",type:28,count:1,defines:[],stageFlags:16,binding:8},{name:"normalMap2",type:28,count:1,defines:[],stageFlags:16,binding:9},{name:"normalMap3",type:28,count:1,defines:[],stageFlags:16,binding:10},{name:"lightMap",type:28,count:1,defines:[],stageFlags:16,binding:11}],attributes:[{name:"a_position",type:15,count:1,defines:[],stageFlags:1,format:32,location:0},{name:"a_normal",type:15,count:1,defines:[],stageFlags:1,format:32,location:1},{name:"a_texCoord",type:14,count:1,defines:[],stageFlags:1,format:21,location:2}]},{name:"terrain|shadow-caster-vs:vert|shadow-caster-fs:frag",hash:3874167763,builtins:{globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]},{name:"CCShadow",defines:[]}],samplers:[]},locals:{blocks:[{name:"CCLocal",defines:[]}],samplers:[]}},defines:[],blocks:[],samplers:[],attributes:[{name:"a_position",type:15,count:1,defines:[],stageFlags:1,format:32,location:0},{name:"a_normal",type:15,count:1,defines:[],stageFlags:1,format:32,location:1},{name:"a_texCoord",type:14,count:1,defines:[],stageFlags:1,format:21,location:2}]}]},{name:"unlit",techniques:[{name:"opaque",passes:[{program:"unlit|unlit-vs:vert|unlit-fs:frag",properties:{mainTexture:{value:"grey",type:28},tilingOffset:{value:[1,1,0,0],type:16},mainColor:{value:[1,1,1,1],type:16},colorScale:{value:[1,1,1],type:15,handleInfo:["colorScaleAndCutoff",0,15]},alphaThreshold:{value:[.5],type:13,handleInfo:["colorScaleAndCutoff",3,13]},color:{type:16,handleInfo:["mainColor",0,16]},colorScaleAndCutoff:{type:16,value:[1,1,1,.5]}}}]}],shaders:[{name:"unlit|unlit-vs:vert|unlit-fs:frag",hash:3822871803,builtins:{globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplers:[]},locals:{blocks:[{name:"CCMorph",defines:["CC_USE_MORPH"]},{name:"CCSkinningTexture",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION"]},{name:"CCSkinningAnimation",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION"]},{name:"CCSkinning",defines:["CC_USE_SKINNING","!CC_USE_BAKED_ANIMATION"]},{name:"CCLocalBatched",defines:["!USE_INSTANCING","USE_BATCHING"]},{name:"CCLocal",defines:["!USE_INSTANCING","!USE_BATCHING"]}],samplers:[{name:"cc_PositionDisplacements",defines:["CC_USE_MORPH","CC_MORPH_TARGET_HAS_POSITION"]},{name:"cc_NormalDisplacements",defines:["CC_USE_MORPH","CC_MORPH_TARGET_HAS_NORMAL"]},{name:"cc_TangentDisplacements",defines:["CC_USE_MORPH","CC_MORPH_TARGET_HAS_TANGENT"]},{name:"cc_jointTexture",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION"]}]}},defines:[{name:"CC_USE_MORPH",type:"boolean"},{name:"CC_MORPH_TARGET_COUNT",type:"number",range:[2,8]},{name:"CC_SUPPORT_FLOAT_TEXTURE",type:"boolean"},{name:"CC_MORPH_PRECOMPUTED",type:"boolean"},{name:"CC_MORPH_TARGET_HAS_POSITION",type:"boolean"},{name:"CC_MORPH_TARGET_HAS_NORMAL",type:"boolean"},{name:"CC_MORPH_TARGET_HAS_TANGENT",type:"boolean"},{name:"CC_USE_SKINNING",type:"boolean"},{name:"CC_USE_BAKED_ANIMATION",type:"boolean"},{name:"USE_INSTANCING",type:"boolean"},{name:"USE_BATCHING",type:"boolean"},{name:"USE_LIGHTMAP",type:"boolean"},{name:"CC_USE_FOG",type:"number",range:[0,4]},{name:"CC_FORWARD_ADD",type:"boolean"},{name:"USE_VERTEX_COLOR",type:"boolean"},{name:"USE_TEXTURE",type:"boolean"},{name:"CC_USE_HDR",type:"boolean"},{name:"USE_ALPHA_TEST",type:"boolean"},{name:"ALPHA_TEST_CHANNEL",type:"string",options:["a","r","g","b"]}],blocks:[{name:"TexCoords",defines:["USE_TEXTURE"],binding:0,stageFlags:1,members:[{name:"tilingOffset",type:16,count:1}]},{name:"Constant",defines:[],binding:1,stageFlags:16,members:[{name:"mainColor",type:16,count:1},{name:"colorScaleAndCutoff",type:16,count:1}]}],samplers:[{name:"mainTexture",type:28,count:1,defines:["USE_TEXTURE"],stageFlags:16,binding:2}],attributes:[{name:"a_position",type:15,count:1,defines:[],stageFlags:1,format:32,location:0},{name:"a_normal",type:15,count:1,defines:[],stageFlags:1,format:32,location:1},{name:"a_texCoord",type:14,count:1,defines:[],stageFlags:1,format:21,location:2},{name:"a_tangent",type:16,count:1,defines:[],stageFlags:1,format:44,location:3},{name:"a_vertexId",type:13,count:1,defines:["CC_USE_MORPH"],stageFlags:1,format:11,location:6},{name:"a_joints",type:12,count:1,defines:["CC_USE_SKINNING"],stageFlags:1,format:42,location:4},{name:"a_weights",type:16,count:1,defines:["CC_USE_SKINNING"],stageFlags:1,format:44,location:5},{name:"a_jointAnimInfo",type:16,count:1,defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION","USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:7},{name:"a_matWorld0",type:16,count:1,defines:["USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:8},{name:"a_matWorld1",type:16,count:1,defines:["USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:9},{name:"a_matWorld2",type:16,count:1,defines:["USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:10},{name:"a_lightingMapUVParam",type:16,count:1,defines:["USE_INSTANCING","USE_LIGHTMAP"],stageFlags:1,format:44,isInstanced:!0,location:11},{name:"a_dyn_batch_id",type:13,count:1,defines:["!USE_INSTANCING","USE_BATCHING"],stageFlags:1,format:11,location:12},{name:"a_color",type:16,count:1,defines:["USE_VERTEX_COLOR"],stageFlags:1,format:44,location:13}]}]},{name:"planar-shadow",techniques:[{passes:[{phase:"planarShadow",blendState:{targets:[{blend:!0,blendSrc:2,blendDst:4,blendDstAlpha:4}]},program:"planar-shadow|planar-shadow-vs:vert|planar-shadow-fs:frag",depthStencilState:{depthTest:!0,depthWrite:!1,stencilTestFront:!0,stencilFuncFront:5,stencilPassOpFront:2,stencilRefBack:128,stencilRefFront:128,stencilReadMaskBack:128,stencilReadMaskFront:128,stencilWriteMaskBack:128,stencilWriteMaskFront:128}}]}],shaders:[{name:"planar-shadow|planar-shadow-vs:vert|planar-shadow-fs:frag",hash:2901856202,builtins:{globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]},{name:"CCShadow",defines:[]}],samplers:[]},locals:{blocks:[{name:"CCMorph",defines:["CC_USE_MORPH"]},{name:"CCSkinningTexture",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION"]},{name:"CCSkinningAnimation",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION"]},{name:"CCSkinning",defines:["CC_USE_SKINNING","!CC_USE_BAKED_ANIMATION"]},{name:"CCLocalBatched",defines:["!USE_INSTANCING","USE_BATCHING"]},{name:"CCLocal",defines:["!USE_INSTANCING","!USE_BATCHING"]}],samplers:[{name:"cc_PositionDisplacements",defines:["CC_USE_MORPH","CC_MORPH_TARGET_HAS_POSITION"]},{name:"cc_NormalDisplacements",defines:["CC_USE_MORPH","CC_MORPH_TARGET_HAS_NORMAL"]},{name:"cc_TangentDisplacements",defines:["CC_USE_MORPH","CC_MORPH_TARGET_HAS_TANGENT"]},{name:"cc_jointTexture",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION"]}]}},defines:[{name:"CC_USE_MORPH",type:"boolean"},{name:"CC_MORPH_TARGET_COUNT",type:"number",range:[2,8]},{name:"CC_SUPPORT_FLOAT_TEXTURE",type:"boolean"},{name:"CC_MORPH_PRECOMPUTED",type:"boolean"},{name:"CC_MORPH_TARGET_HAS_POSITION",type:"boolean"},{name:"CC_MORPH_TARGET_HAS_NORMAL",type:"boolean"},{name:"CC_MORPH_TARGET_HAS_TANGENT",type:"boolean"},{name:"CC_USE_SKINNING",type:"boolean"},{name:"CC_USE_BAKED_ANIMATION",type:"boolean"},{name:"USE_INSTANCING",type:"boolean"},{name:"USE_BATCHING",type:"boolean"},{name:"USE_LIGHTMAP",type:"boolean"},{name:"CC_USE_HDR",type:"boolean"}],blocks:[],samplers:[],attributes:[{name:"a_position",type:15,count:1,defines:[],stageFlags:1,format:32,location:0},{name:"a_normal",type:15,count:1,defines:[],stageFlags:1,format:32,location:1},{name:"a_texCoord",type:14,count:1,defines:[],stageFlags:1,format:21,location:2},{name:"a_tangent",type:16,count:1,defines:[],stageFlags:1,format:44,location:3},{name:"a_vertexId",type:13,count:1,defines:["CC_USE_MORPH"],stageFlags:1,format:11,location:6},{name:"a_joints",type:12,count:1,defines:["CC_USE_SKINNING"],stageFlags:1,format:42,location:4},{name:"a_weights",type:16,count:1,defines:["CC_USE_SKINNING"],stageFlags:1,format:44,location:5},{name:"a_jointAnimInfo",type:16,count:1,defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION","USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:7},{name:"a_matWorld0",type:16,count:1,defines:["USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:8},{name:"a_matWorld1",type:16,count:1,defines:["USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:9},{name:"a_matWorld2",type:16,count:1,defines:["USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:10},{name:"a_lightingMapUVParam",type:16,count:1,defines:["USE_INSTANCING","USE_LIGHTMAP"],stageFlags:1,format:44,isInstanced:!0,location:11},{name:"a_dyn_batch_id",type:13,count:1,defines:["!USE_INSTANCING","USE_BATCHING"],stageFlags:1,format:11,location:12}]}]},{name:"skybox",techniques:[{passes:[{rasterizerState:{cullMode:0},program:"skybox|sky-vs:vert|sky-fs:frag",priority:245,depthStencilState:{depthTest:!0,depthWrite:!1}}]}],shaders:[{name:"skybox|sky-vs:vert|sky-fs:frag",hash:2319917655,builtins:{globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplers:[{name:"cc_environment",defines:[]}]},locals:{blocks:[],samplers:[]}},defines:[{name:"CC_USE_IBL",type:"number",range:[0,2]},{name:"CC_USE_HDR",type:"boolean"},{name:"USE_RGBE_CUBEMAP",type:"boolean"}],blocks:[],samplers:[],attributes:[{name:"a_position",type:15,count:1,defines:[],stageFlags:1,format:32,location:0},{name:"a_normal",type:15,count:1,defines:[],stageFlags:1,format:32,location:1},{name:"a_texCoord",type:14,count:1,defines:[],stageFlags:1,format:21,location:2},{name:"a_tangent",type:16,count:1,defines:[],stageFlags:1,format:44,location:3}]}]},{name:"profiler",techniques:[{passes:[{blendState:{targets:[{blend:!0,blendSrc:2,blendDst:4,blendDstAlpha:4}]},rasterizerState:{cullMode:0},program:"profiler|profiler-vs:vert|profiler-fs:frag",depthStencilState:{depthTest:!1,depthWrite:!1}}]}],shaders:[{name:"profiler|profiler-vs:vert|profiler-fs:frag",hash:2029303284,builtins:{globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplers:[]},locals:{blocks:[],samplers:[]}},defines:[{name:"CC_USE_HDR",type:"boolean"}],blocks:[{name:"Constants",defines:[],binding:0,stageFlags:1,members:[{name:"offset",type:16,count:1}]},{name:"PerFrameInfo",defines:[],binding:1,stageFlags:1,members:[{name:"digits",type:16,count:20}]}],samplers:[{name:"mainTexture",type:28,count:1,defines:[],stageFlags:16,binding:2}],attributes:[{name:"a_position",type:15,count:1,defines:[],stageFlags:1,format:32,location:0},{name:"a_color",type:16,count:1,defines:[],stageFlags:1,format:44,location:1}]}]},{name:"splash-screen",techniques:[{passes:[{blendState:{targets:[{blend:!0,blendSrc:2,blendDst:4,blendDstAlpha:4}]},rasterizerState:{cullMode:0},program:"splash-screen|splash-screen-vs:vert|splash-screen-fs:frag",depthStencilState:{depthTest:!1,depthWrite:!1}}]}],shaders:[{name:"splash-screen|splash-screen-vs:vert|splash-screen-fs:frag",hash:2106901053,builtins:{globals:{blocks:[],samplers:[]},locals:{blocks:[],samplers:[]}},defines:[],blocks:[{name:"splashFrag",defines:[],binding:0,stageFlags:16,members:[{name:"u_precent",type:13,count:1}]}],samplers:[{name:"mainTexture",type:28,count:1,defines:[],stageFlags:16,binding:1}],attributes:[{name:"a_position",type:14,count:1,defines:[],stageFlags:1,format:21,location:0},{name:"a_texCoord",type:14,count:1,defines:[],stageFlags:1,format:21,location:1}]}]}]);!function(e){e[e.UBO=0]="UBO",e[e.SAMPLER=1]="SAMPLER"}(Ed||(Ed={}));var Ad=function(e,t,n,i,r){return void 0===r&&(r=0),e<<28&4026531840|i<<22&264241152|t<<20&3145728|n<<14&1032192|16383&r},xd=function(e){return(4026531840&e)>>>28},Cd=function(e){return(264241152&e)>>>22},Rd=function(e){return(1032192&e)>>>14},bd=function(e){return 16383&e},wd=function(e,t){return-264241153&e|t<<22&264241152},Id=((yd={})[Fa.UNKNOWN]=function(){return console.warn("illegal uniform handle")},yd[Fa.INT]=function(e,t,n){return void 0===n&&(n=0),e[n]},yd[Fa.INT2]=function(e,t,n){return void 0===n&&(n=0),qn.fromArray(t,e,n)},yd[Fa.INT3]=function(e,t,n){return void 0===n&&(n=0),bn.fromArray(t,e,n)},yd[Fa.INT4]=function(e,t,n){return void 0===n&&(n=0),Zn.fromArray(t,e,n)},yd[Fa.FLOAT]=function(e,t,n){return void 0===n&&(n=0),e[n]},yd[Fa.FLOAT2]=function(e,t,n){return void 0===n&&(n=0),qn.fromArray(t,e,n)},yd[Fa.FLOAT3]=function(e,t,n){return void 0===n&&(n=0),bn.fromArray(t,e,n)},yd[Fa.FLOAT4]=function(e,t,n){return void 0===n&&(n=0),Zn.fromArray(t,e,n)},yd[Fa.MAT3]=function(e,t,n){return void 0===n&&(n=0),Pn.fromArray(t,e,n)},yd[Fa.MAT4]=function(e,t,n){return void 0===n&&(n=0),Hn.fromArray(t,e,n)},yd),Od=((Sd={})[Fa.UNKNOWN]=function(){return console.warn("illegal uniform handle")},Sd[Fa.INT]=function(e,t,n){return void 0===n&&(n=0),e[n]=t},Sd[Fa.INT2]=function(e,t,n){return void 0===n&&(n=0),qn.toArray(e,t,n)},Sd[Fa.INT3]=function(e,t,n){return void 0===n&&(n=0),bn.toArray(e,t,n)},Sd[Fa.INT4]=function(e,t,n){return void 0===n&&(n=0),Zn.toArray(e,t,n)},Sd[Fa.FLOAT]=function(e,t,n){return void 0===n&&(n=0),e[n]=t},Sd[Fa.FLOAT2]=function(e,t,n){return void 0===n&&(n=0),qn.toArray(e,t,n)},Sd[Fa.FLOAT3]=function(e,t,n){return void 0===n&&(n=0),bn.toArray(e,t,n)},Sd[Fa.FLOAT4]=function(e,t,n){return void 0===n&&(n=0),Zn.toArray(e,t,n)},Sd[Fa.MAT3]=function(e,t,n){return void 0===n&&(n=0),Pn.toArray(e,t,n)},Sd[Fa.MAT4]=function(e,t,n){return void 0===n&&(n=0),Hn.toArray(e,t,n)},Sd),Pd=[Object.freeze([0]),Object.freeze([0,0]),Object.freeze([0,0,0,0]),Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])];function Md(e){switch(e){case Fa.BOOL:case Fa.INT:case Fa.UINT:case Fa.FLOAT:return Pd[0];case Fa.BOOL2:case Fa.INT2:case Fa.UINT2:case Fa.FLOAT2:return Pd[1];case Fa.BOOL4:case Fa.INT4:case Fa.UINT4:case Fa.FLOAT4:return Pd[2];case Fa.MAT4:return Pd[3];case Fa.SAMPLER2D:return"default-texture";case Fa.SAMPLER_CUBE:return"default-cube-texture"}return Pd[0]}function Nd(e,t){for(var n=Object.entries(t),i=!1,r=0;r<n.length;r++)e[n[r][0]]!==n[r][1]&&(e[n[r][0]]=n[r][1],i=!0);return i}var Dd=new Do;function Bd(e){return Math.ceil(Math.log2(Math.max(e,2)))}function Ld(e,t){switch(e.type){case"boolean":return"number"==typeof t?t.toString():t?"1":"0";case"string":return void 0!==t?t:e.options[0];case"number":return void 0!==t?t.toString():e.range[0].toString();default:return console.warn("unknown define type '"+e.type+"'"),"-1"}}function Fd(e,t,n,i,r){for(var a=e.builtins[i],s=[],o=function(e){var t=a.blocks[e],i=n.layouts[t.name],o=i&&n.bindings.find((function(e){return e.binding===i.binding}));if(!(i&&o&&o.descriptorType&Io))return console.warn("builtin UBO '"+t.name+"' not available!"),"continue";s.push(i),r&&!r.includes(o)&&r.push(o)},c=0;c<a.blocks.length;c++)o(c);Array.prototype.unshift.apply(t.gfxBlocks,s);for(var l=[],u=function(e){var t=a.samplers[e],i=n.layouts[t.name],s=i&&n.bindings.find((function(e){return e.binding===i.binding}));if(!(i&&s&&s.descriptorType&Oo))return console.warn("builtin sampler '"+t.name+"' not available!"),"continue";l.push(i),r&&!r.includes(s)&&r.push(s)},h=0;h<a.samplers.length;h++)u(h);Array.prototype.unshift.apply(t.gfxSamplers,l),r&&r.sort((function(e,t){return e.binding-t.binding}))}function zd(e){return e.members.reduce((function(e,t){return e+Rs(t.type)*t.count}),0)}function Ud(e,t){for(var n=0;n<e.length;n++){var i=e[n];if("!"===i[0]){if(t[i.slice(1)])return!1}else if(!t[i])return!1}return!0}function Gd(e){switch(e.gfxAPI){case ms.GLES2:case ms.WEBGL:return"glsl1";case ms.GLES3:case ms.WEBGL2:return"glsl3";default:return"glsl4"}}var kd=new(function(){function e(){this._templates={},this._cache={},this._templateInfos={}}var t=e.prototype;return t.register=function(e){for(var t=0;t<e.shaders.length;t++)this.define(e.shaders[t]).effectName=e.name},t.define=function(e){var t=this._templates[e.name];if(t&&t.hash===e.hash)return t;for(var n=q({},e),i=0,r=function(e){var t=n.defines[e],r=1;if("number"===t.type){var a=t.range;r=Bd(a[1]-a[0]+1),t._map=function(e){return e-a[0]}}else"string"===t.type?(r=Bd(t.options.length),t._map=function(e){return Math.max(0,t.options.findIndex((function(t){return t===e})))}):"boolean"===t.type&&(t._map=function(e){return e?1:0});t._offset=i,i+=r},a=0;a<n.defines.length;a++)r(a);if(i>31&&(n.uber=!0),this._templates[e.name]=n,!this._templateInfos[n.hash]){var s={};s.samplerStartBinding=n.blocks.length,s.gfxBlocks=[],s.gfxSamplers=[],s.bindings=[],s.blockSizes=[];for(var o=0;o<n.blocks.length;o++){var c=n.blocks[o];s.blockSizes.push(zd(c)),s.bindings.push(new No(c.binding,c.descriptorType||as.UNIFORM_BUFFER,1,c.stageFlags)),s.gfxBlocks.push(new So(Vl.MATERIAL,c.binding,c.name,c.members.map((function(e){return new yo(e.name,e.type,e.count)})),1))}for(var l=0;l<n.samplers.length;l++){var u=n.samplers[l];s.bindings.push(new No(u.binding,u.descriptorType||as.SAMPLER,u.count,u.stageFlags)),s.gfxSamplers.push(new Eo(Vl.MATERIAL,u.binding,u.name,u.type,u.count))}s.gfxAttributes=[];for(var h=0;h<n.attributes.length;h++){var _=n.attributes[h];s.gfxAttributes.push(new Ws(_.name,_.format,_.isNormalized,0,_.isInstanced,_.location))}Fd(n,s,Ul,"locals"),s.gfxStages=[],s.gfxStages.push(new vo(rs.VERTEX,"")),s.gfxStages.push(new vo(rs.FRAGMENT,"")),s.handleMap=function(e){for(var t={},n=0;n<e.blocks.length;n++)for(var i=e.blocks[n],r=i.members,a=0,s=0;s<r.length;s++){var o=r[s];t[o.name]=Ad(Ed.UBO,Vl.MATERIAL,i.binding,o.type,a),a+=(Rs(o.type)>>2)*o.count}for(var c=0;c<e.samplers.length;c++){var l=e.samplers[c];t[l.name]=Ad(Ed.SAMPLER,Vl.MATERIAL,l.binding,l.type)}return t}(n),s.hPipelineLayout=0,s.setLayouts=[],this._templateInfos[n.hash]=s}return n},t.getTemplate=function(e){return this._templates[e]},t.getTemplateInfo=function(e){var t=this._templates[e].hash;return this._templateInfos[t]},t.getDescriptorSetLayout=function(e,t,n){void 0===n&&(n=!1);var i=this._templates[t],r=this._templateInfos[i.hash];return r.setLayouts.length||(Dd.bindings=r.bindings,r.setLayouts[Vl.MATERIAL]=e.createDescriptorSetLayout(Dd),Dd.bindings=Ul.bindings,r.setLayouts[Vl.LOCAL]=e.createDescriptorSetLayout(Dd)),r.setLayouts[n?Vl.LOCAL:Vl.MATERIAL]},t.hasProgram=function(e){return void 0!==this._templates[e]},t.getKey=function(e,t){var n=this._templates[e],i=n.defines;if(n.uber){for(var r="",a=0;a<i.length;a++){var s=i[a],o=t[s.name];if(o&&s._map){var c=s._map(o);r+=""+s._offset+c+"|"}}return""+r+n.hash}for(var l=0,u=0;u<i.length;u++){var h=i[u],_=t[h.name];_&&h._map&&(l|=h._map(_)<<h._offset)}return l.toString(16)+"|"+n.hash},t.destroyShaderByDefines=function(e){var t=this,n=Object.keys(e);if(n.length)for(var i=n.map((function(t){var n=e[t];return"boolean"==typeof n&&(n=n?"1":"0"),new RegExp(""+t+n)})),r=Object.keys(this._cache).filter((function(e){return i.every((function(n){return n.test(zi.get(t._cache[e]).name)}))})),a=0;a<r.length;a++){var s=r[a],o=zi.get(this._cache[s]);console.log("destroyed shader "+o.name),o.destroy(),delete this._cache[s]}},t.getGFXShader=function(e,t,n,i,r){Object.assign(n,i.macros),r||(r=this.getKey(t,n));var a=this._cache[r];if(a)return a;var s=this._templates[t],o=this._templateInfos[s.hash];o.hPipelineLayout||(this.getDescriptorSetLayout(e,t),Fd(s,o,zl,"globals"),o.setLayouts[Vl.GLOBAL]=i.descriptorSetLayout,o.hPipelineLayout=ki.alloc(e,new Fo(o.setLayouts)));var c=function(e,t){for(var n=[],i=0;i<t.length;i++){var r=t[i],a=r.name,s=e[a],o=Ld(r,s),c=!s||"0"===s;n.push({name:a,value:o,isDefault:c})}return n}(n,s.defines),l=c.reduce((function(e,t){return e+"#define "+t.name+" "+t.value+"\n"}),"")+"\n",u=s.glsl3,h=Gd(e);h?u=s[h]:console.error("Invalid GFX API!"),o.gfxStages[0].source=l+u.vert,o.gfxStages[1].source=l+u.frag;var _=function(e,t,n){for(var i=[],r=e.attributes,a=t.gfxAttributes,s=0;s<r.length;s++)Ud(r[s].defines,n)&&i.push(a[s]);return i}(s,o,n),f=function(e,t){return e+t.reduce((function(e,t){return t.isDefault?e:e+"|"+t.name+t.value}),"")}(t,c),d=new To(f,o.gfxStages,_,o.gfxBlocks,o.gfxSamplers);return this._cache[r]=zi.alloc(e,d)},e}());i.programLib=kd;var Hd,Vd,Wd,jd={glsl1:[[{vert:"\nprecision mediump float;\nuniform highp mat4 cc_matView;\nuniform highp mat4 cc_matViewInv;\nuniform highp mat4 cc_matViewProj;\nuniform highp mat4 cc_matWorld;\nvec4 quaternionFromAxis (vec3 xAxis,vec3 yAxis,vec3 zAxis){\n mat3 m = mat3(xAxis,yAxis,zAxis);\n float trace = m[0][0] + m[1][1] + m[2][2];\n vec4 quat;\n if (trace > 0.) {\n float s = 0.5 / sqrt(trace + 1.0);\n quat.w = 0.25 / s;\n quat.x = (m[2][1] - m[1][2]) * s;\n quat.y = (m[0][2] - m[2][0]) * s;\n quat.z = (m[1][0] - m[0][1]) * s;\n } else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\n float s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\n quat.w = (m[2][1] - m[1][2]) / s;\n quat.x = 0.25 * s;\n quat.y = (m[0][1] + m[1][0]) / s;\n quat.z = (m[0][2] + m[2][0]) / s;\n } else if (m[1][1] > m[2][2]) {\n float s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\n quat.w = (m[0][2] - m[2][0]) / s;\n quat.x = (m[0][1] + m[1][0]) / s;\n quat.y = 0.25 * s;\n quat.z = (m[1][2] + m[2][1]) / s;\n } else {\n float s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\n quat.w = (m[1][0] - m[0][1]) / s;\n quat.x = (m[0][2] + m[2][0]) / s;\n quat.y = (m[1][2] + m[2][1]) / s;\n quat.z = 0.25 * s;\n }\n float len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\n if (len > 0.) {\n len = 1. / sqrt(len);\n quat.x = quat.x * len;\n quat.y = quat.y * len;\n quat.z = quat.z * len;\n quat.w = quat.w * len;\n }\n return quat;\n}\nvec4 quaternionFromEuler (vec3 angle){\n float x = angle.x / 2.;\n float y = angle.y / 2.;\n float z = angle.z / 2.;\n float sx = sin(x);\n float cx = cos(x);\n float sy = sin(y);\n float cy = cos(y);\n float sz = sin(z);\n float cz = cos(z);\n vec4 quat = vec4(0);\n quat.x = sx * cy * cz + cx * sy * sz;\n quat.y = cx * sy * cz + sx * cy * sz;\n quat.z = cx * cy * sz - sx * sy * cz;\n quat.w = cx * cy * cz - sx * sy * sz;\n return quat;\n}\nvec4 quatMultiply (vec4 a, vec4 b){\n vec4 quat;\n quat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\n quat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\n quat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\n quat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\n return quat;\n}\nvoid rotateVecFromQuat (inout vec3 v, vec4 q){\n float ix = q.w * v.x + q.y * v.z - q.z * v.y;\n float iy = q.w * v.y + q.z * v.x - q.x * v.z;\n float iz = q.w * v.z + q.x * v.y - q.y * v.x;\n float iw = -q.x * v.x - q.y * v.y - q.z * v.z;\n v.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\n v.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\n v.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace (vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\n vec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\n vec4 rotQuat = quatMultiply(viewQuat, q);\n rotateVecFromQuat(pos, rotQuat);\n return pos;\n}\nvoid rotateCorner (inout vec2 corner, float angle){\n float xOS = cos(angle) * corner.x - sin(angle) * corner.y;\n float yOS = sin(angle) * corner.x + cos(angle) * corner.y;\n corner.x = xOS;\n corner.y = yOS;\n}\nvarying mediump vec2 uv;\nvarying mediump vec4 color;\nvoid computeVertPos (inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n , mat4 viewInv\n) {\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\n vec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\n vec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n}\nattribute vec3 a_position;\nattribute vec2 a_texCoord;\nattribute vec4 a_color;\nuniform vec4 cc_size_rotation;\nvec4 vs_main() {\n vec4 pos = vec4(a_position, 1);\n pos = cc_matWorld * pos;\n vec2 vertOffset = a_texCoord.xy - 0.5;\n computeVertPos(pos, vertOffset, quaternionFromEuler(vec3(0., 0., cc_size_rotation.z)), vec3(cc_size_rotation.xy, 0.), cc_matViewInv);\n pos = cc_matViewProj * pos;\n uv = a_texCoord.xy;\n color = a_color;\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }",frag:"\nprecision mediump float;\nuniform mediump vec4 cc_exposure;\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n #if CC_USE_HDR\n color.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n #endif\n return color;\n}\nvarying vec2 uv;\nvarying vec4 color;\nuniform sampler2D mainTexture;\nuniform vec4 tintColor;\nvec4 add () {\n vec4 col = 2.0 * color * tintColor * texture2D(mainTexture, uv);\n return CCFragOutput(col);\n}\nvoid main() { gl_FragColor = add(); }"}],[{vert:"\nprecision highp float;\nattribute vec3 a_position;\nvec4 vert () {\n vec4 pos = vec4(a_position, 1);\n return pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nvec4 frag () {\n vec4 o = vec4(1.0);\n return o;\n}\nvoid main() { gl_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nuniform highp mat4 cc_matViewProj;\nuniform highp mat4 cc_matWorld;\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\nattribute float a_dist;\nvarying float v_dist;\nvec4 vert () {\n vec4 pos = vec4(a_position, 1);\n pos = cc_matViewProj * cc_matWorld * pos;\n v_color = a_color;\n v_dist = a_dist;\n return pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\n#ifdef GL_OES_standard_derivatives\n#extension GL_OES_standard_derivatives: enable\n#endif\nprecision highp float;\nvarying vec4 v_color;\nvarying float v_dist;\nvec4 frag () {\n vec4 o = v_color;\n #ifdef GL_OES_standard_derivatives\n float aa = fwidth(v_dist);\n #else\n float aa = 0.05;\n #endif\n float alpha = 1. - smoothstep(-aa, 0., abs(v_dist) - 1.0);\n o.rgb *= o.a;\n o *= alpha;\n return o;\n}\nvoid main() { gl_FragColor = frag(); }"}],[{vert:"\nprecision mediump float;\nvec4 quaternionFromAxis (vec3 xAxis,vec3 yAxis,vec3 zAxis){\n mat3 m = mat3(xAxis,yAxis,zAxis);\n float trace = m[0][0] + m[1][1] + m[2][2];\n vec4 quat;\n if (trace > 0.) {\n float s = 0.5 / sqrt(trace + 1.0);\n quat.w = 0.25 / s;\n quat.x = (m[2][1] - m[1][2]) * s;\n quat.y = (m[0][2] - m[2][0]) * s;\n quat.z = (m[1][0] - m[0][1]) * s;\n } else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\n float s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\n quat.w = (m[2][1] - m[1][2]) / s;\n quat.x = 0.25 * s;\n quat.y = (m[0][1] + m[1][0]) / s;\n quat.z = (m[0][2] + m[2][0]) / s;\n } else if (m[1][1] > m[2][2]) {\n float s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\n quat.w = (m[0][2] - m[2][0]) / s;\n quat.x = (m[0][1] + m[1][0]) / s;\n quat.y = 0.25 * s;\n quat.z = (m[1][2] + m[2][1]) / s;\n } else {\n float s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\n quat.w = (m[1][0] - m[0][1]) / s;\n quat.x = (m[0][2] + m[2][0]) / s;\n quat.y = (m[1][2] + m[2][1]) / s;\n quat.z = 0.25 * s;\n }\n float len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\n if (len > 0.) {\n len = 1. / sqrt(len);\n quat.x = quat.x * len;\n quat.y = quat.y * len;\n quat.z = quat.z * len;\n quat.w = quat.w * len;\n }\n return quat;\n}\nvec4 quaternionFromEuler (vec3 angle){\n float x = angle.x / 2.;\n float y = angle.y / 2.;\n float z = angle.z / 2.;\n float sx = sin(x);\n float cx = cos(x);\n float sy = sin(y);\n float cy = cos(y);\n float sz = sin(z);\n float cz = cos(z);\n vec4 quat = vec4(0);\n quat.x = sx * cy * cz + cx * sy * sz;\n quat.y = cx * sy * cz + sx * cy * sz;\n quat.z = cx * cy * sz - sx * sy * cz;\n quat.w = cx * cy * cz - sx * sy * sz;\n return quat;\n}\nmat4 matrixFromRT (vec4 q, vec3 p){\n float x2 = q.x + q.x;\n float y2 = q.y + q.y;\n float z2 = q.z + q.z;\n float xx = q.x * x2;\n float xy = q.x * y2;\n float xz = q.x * z2;\n float yy = q.y * y2;\n float yz = q.y * z2;\n float zz = q.z * z2;\n float wx = q.w * x2;\n float wy = q.w * y2;\n float wz = q.w * z2;\n return mat4(\n 1. - (yy + zz), xy + wz, xz - wy, 0,\n xy - wz, 1. - (xx + zz), yz + wx, 0,\n xz + wy, yz - wx, 1. - (xx + yy), 0,\n p.x, p.y, p.z, 1\n );\n}\nmat4 matFromRTS (vec4 q, vec3 t, vec3 s){\n float x = q.x, y = q.y, z = q.z, w = q.w;\n float x2 = x + x;\n float y2 = y + y;\n float z2 = z + z;\n float xx = x * x2;\n float xy = x * y2;\n float xz = x * z2;\n float yy = y * y2;\n float yz = y * z2;\n float zz = z * z2;\n float wx = w * x2;\n float wy = w * y2;\n float wz = w * z2;\n float sx = s.x;\n float sy = s.y;\n float sz = s.z;\n return mat4((1. - (yy + zz)) * sx, (xy + wz) * sx, (xz - wy) * sx, 0,\n (xy - wz) * sy, (1. - (xx + zz)) * sy, (yz + wx) * sy, 0,\n (xz + wy) * sz, (yz - wx) * sz, (1. - (xx + yy)) * sz, 0,\n t.x, t.y, t.z, 1);\n}\nvec4 quatMultiply (vec4 a, vec4 b){\n vec4 quat;\n quat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\n quat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\n quat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\n quat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\n return quat;\n}\nvoid rotateVecFromQuat (inout vec3 v, vec4 q){\n float ix = q.w * v.x + q.y * v.z - q.z * v.y;\n float iy = q.w * v.y + q.z * v.x - q.x * v.z;\n float iz = q.w * v.z + q.x * v.y - q.y * v.x;\n float iw = -q.x * v.x - q.y * v.y - q.z * v.z;\n v.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\n v.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\n v.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace (vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\n vec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\n vec4 rotQuat = quatMultiply(viewQuat, q);\n rotateVecFromQuat(pos, rotQuat);\n return pos;\n}\nvoid rotateCorner (inout vec2 corner, float angle){\n float xOS = cos(angle) * corner.x - sin(angle) * corner.y;\n float yOS = sin(angle) * corner.x + cos(angle) * corner.y;\n corner.x = xOS;\n corner.y = yOS;\n}\nuniform vec4 mainTiling_Offset;\nuniform vec4 frameTile_velLenScale;\nuniform vec4 scale;\nuniform highp mat4 cc_matView;\nuniform highp mat4 cc_matViewInv;\nuniform highp mat4 cc_matViewProj;\nuniform highp vec4 cc_cameraPos;\nuniform highp mat4 cc_matWorld;\nvarying mediump vec2 uv;\nvarying mediump vec4 color;\nvoid computeVertPos (inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n#if CC_RENDER_MODE == 0 || CC_RENDER_MODE == 3\n , mat4 viewInv\n#endif\n#if CC_RENDER_MODE == 1\n , vec3 eye\n , vec4 velocity\n , float velocityScale\n , float lengthScale\n , float xIndex\n#endif\n) {\n#if CC_RENDER_MODE == 0\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\n vec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\n vec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_RENDER_MODE == 1\n vec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\n vec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\n pos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_RENDER_MODE == 2\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = vec3(1, 0, 0);\n vec3 camY = vec3(0, 0, -1);\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_RENDER_MODE == 3\n vec2 viewSpaceVert = vec2(vertOffset.x * s.x, vertOffset.y * s.y);\n rotateCorner(viewSpaceVert, q.z);\n vec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\n vec3 camY = vec3(0, 1, 0);\n vec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\n pos.xyz += offset;\n#else\n pos.x += vertOffset.x;\n pos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV (float frameIndex, vec2 vertIndex, vec2 frameTile){\n vec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\n aniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if CC_RENDER_MODE != 4\n vertIndex.y = 1. - vertIndex.y;\n#endif\n return (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nuniform vec4 u_sampleInfo;\nuniform vec4 u_worldRot;\nuniform vec4 u_timeDelta;\nattribute vec4 a_position_starttime;\nattribute vec4 a_size_uv;\nattribute vec4 a_rotation_uv;\nattribute vec4 a_color;\nattribute vec4 a_dir_life;\nattribute float a_rndSeed;\n#if CC_RENDER_MODE == 4\n attribute vec3 a_texCoord;\n attribute vec3 a_texCoord3;\n attribute vec3 a_normal;\n attribute vec4 a_color1;\n#endif\nvec3 unpackCurveData (sampler2D tex, vec2 coord) {\n vec4 a = texture2D(tex, coord);\n vec4 b = texture2D(tex, coord + u_sampleInfo.y);\n float c = fract(coord.x * u_sampleInfo.x);\n return mix(a.xyz, b.xyz, c);\n}\nvec3 unpackCurveData (sampler2D tex, vec2 coord, out float w) {\n vec4 a = texture2D(tex, coord);\n vec4 b = texture2D(tex, coord + u_sampleInfo.y);\n float c = fract(coord.x * u_sampleInfo.x);\n w = mix(a.w, b.w, c);\n return mix(a.xyz, b.xyz, c);\n}\nfloat pseudoRandom (float seed) {\n seed = mod(seed, 233280.);\n float q = (seed * 9301. + 49297.) / 233280.;\n return fract(q);\n}\n#if COLOR_OVER_TIME_MODULE_ENABLE\n uniform sampler2D color_over_time_tex0;\n uniform int u_color_mode;\n#endif\n#if ROTATION_OVER_TIME_MODULE_ENABLE\n uniform sampler2D rotation_over_time_tex0;\n uniform int u_rotation_mode;\n#endif\n#if SIZE_OVER_TIME_MODULE_ENABLE\n uniform sampler2D size_over_time_tex0;\n uniform int u_size_mode;\n#endif\n#if FORCE_OVER_TIME_MODULE_ENABLE\n uniform sampler2D force_over_time_tex0;\n uniform int u_force_mode;\nuniform int u_force_space;\n#endif\n#if VELOCITY_OVER_TIME_MODULE_ENABLE\n uniform sampler2D velocity_over_time_tex0;\n uniform int u_velocity_mode;\nuniform int u_velocity_space;\n#endif\n#if TEXTURE_ANIMATION_MODULE_ENABLE\n uniform sampler2D texture_animation_tex0;\n uniform vec4 u_anim_info;\n#endif\nfloat repeat (float t, float length) {\n return t - floor(t / length) * length;\n}\nvec4 rotateQuat (vec4 p, vec4 q) {\n vec3 iv = cross(q.xyz, p.xyz) + q.w * p.xyz;\n vec3 res = p.xyz + 2.0 * cross(q.xyz, iv);\n return vec4(res.xyz, p.w);\n}\nvec4 gpvs_main () {\n float activeTime = u_timeDelta.x - a_position_starttime.w;\n float normalizedTime = clamp(activeTime / a_dir_life.w, 0.0, 1.0);\n vec2 timeCoord0 = vec2(normalizedTime, 0.);\n vec2 timeCoord1 = vec2(normalizedTime, 1.);\n #if CC_RENDER_MODE == 4\n vec2 vertIdx = vec2(a_texCoord.x, a_texCoord.y);\n #else\n vec2 vertIdx = vec2(a_size_uv.w, a_rotation_uv.w);\n #endif\n vec4 velocity = vec4(a_dir_life.xyz, 0.);\n vec4 pos = vec4(a_position_starttime.xyz, 1.);\n vec3 size = a_size_uv.xyz;\n #if SIZE_OVER_TIME_MODULE_ENABLE\n if (u_size_mode == 1) {\n size *= unpackCurveData(size_over_time_tex0, timeCoord0);\n } else {\n vec3 size_0 = unpackCurveData(size_over_time_tex0, timeCoord0);\n vec3 size_1 = unpackCurveData(size_over_time_tex0, timeCoord1);\n float factor_s = pseudoRandom(a_rndSeed + 39825.);\n size *= mix(size_0, size_1, factor_s);\n }\n #endif\n vec3 compScale = scale.xyz * size;\n #if FORCE_OVER_TIME_MODULE_ENABLE\n vec3 forceAnim = vec3(0.);\n if (u_force_mode == 1) {\n forceAnim = unpackCurveData(force_over_time_tex0, timeCoord0);\n } else {\n vec3 force_0 = unpackCurveData(force_over_time_tex0, timeCoord0);\n vec3 force_1 = unpackCurveData(force_over_time_tex0, timeCoord1);\n float factor_f = pseudoRandom(a_rndSeed + 212165.);\n forceAnim = mix(force_0, force_1, factor_f);\n }\n vec4 forceTrack = vec4(forceAnim, 0.);\n if (u_force_space == 0) {\n forceTrack = rotateQuat(forceTrack, u_worldRot);\n }\n velocity.xyz += forceTrack.xyz;\n #endif\n #if VELOCITY_OVER_TIME_MODULE_ENABLE\n float speedModifier0 = 1.;\n float speedModifier1 = 1.;\n vec3 velocityAnim = vec3(0.);\n if (u_velocity_mode == 1) {\n velocityAnim = unpackCurveData(velocity_over_time_tex0, timeCoord0, speedModifier0);\n } else {\n vec3 vectory_0 = unpackCurveData(velocity_over_time_tex0, timeCoord0, speedModifier0);\n vec3 vectory_1 = unpackCurveData(velocity_over_time_tex0, timeCoord1, speedModifier1);\n float factor_v = pseudoRandom(a_rndSeed + 197866.);\n velocityAnim = mix(vectory_0, vectory_1, factor_v);\n speedModifier0 = mix(speedModifier0, speedModifier1, factor_v);\n }\n vec4 velocityTrack = vec4(velocityAnim, 0.);\n if (u_velocity_space == 0) {\n velocityTrack = rotateQuat(velocityTrack, u_worldRot);\n }\n velocity.xyz += velocityTrack.xyz;\n velocity.xyz *= speedModifier0;\n #endif\n pos.xyz += velocity.xyz * normalizedTime * a_dir_life.w;\n #if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n #if CC_RENDER_MODE == 1\n velocity = rotateQuat(velocity, u_worldRot);\n #endif\n #endif\n vec3 rotation = a_rotation_uv.xyz;\n #if ROTATION_OVER_TIME_MODULE_ENABLE\n if (u_rotation_mode == 1) {\n rotation += unpackCurveData(rotation_over_time_tex0, timeCoord0) * normalizedTime * a_dir_life.w;\n } else {\n vec3 rotation_0 = unpackCurveData(rotation_over_time_tex0, timeCoord0);\n vec3 rotation_1 = unpackCurveData(rotation_over_time_tex0, timeCoord1);\n float factor_r = pseudoRandom(a_rndSeed + 125292.);\n rotation += mix(rotation_0, rotation_1, factor_r) * normalizedTime * a_dir_life.w;\n }\n #endif\n #if COLOR_OVER_TIME_MODULE_ENABLE\n if (u_color_mode == 1) {\n color = a_color * texture2D(color_over_time_tex0, timeCoord0);\n } else {\n vec4 color_0 = texture2D(color_over_time_tex0, timeCoord0);\n vec4 color_1 = texture2D(color_over_time_tex0, timeCoord1);\n float factor_c = pseudoRandom(a_rndSeed + 91041.);\n color = a_color * mix(color_0, color_1, factor_c);\n }\n #else\n color = a_color;\n #endif\n #if CC_RENDER_MODE != 4\n vec2 cornerOffset = vec2((vertIdx - 0.5));\n #if CC_RENDER_MODE == 0\n vec3 rotEuler = rotation.xyz;\n #elif CC_RENDER_MODE == 1\n vec3 rotEuler = vec3(0.);\n #else\n vec3 rotEuler = vec3(0., 0., rotation.z);\n #endif\n computeVertPos(pos, cornerOffset, quaternionFromEuler(rotEuler), compScale\n #if CC_RENDER_MODE == 0 || CC_RENDER_MODE == 3\n , cc_matViewInv\n #endif\n #if CC_RENDER_MODE == 1\n , cc_cameraPos.xyz\n , velocity\n , frameTile_velLenScale.z\n , frameTile_velLenScale.w\n , a_size_uv.w\n #endif\n );\n #else\n mat4 xformNoScale = matrixFromRT(quaternionFromEuler(rotation), pos.xyz);\n mat4 xform = matFromRTS(quaternionFromEuler(rotation), pos.xyz, compScale);\n pos = xform * vec4(a_texCoord3, 1);\n vec4 normal = xformNoScale * vec4(a_normal, 0);\n color *= a_color1;\n #endif\n pos = cc_matViewProj * pos;\n float frameIndex = 0.;\n #if TEXTURE_ANIMATION_MODULE_ENABLE\n float startFrame = 0.;\n vec3 frameInfo = vec3(0.);\n if (int(u_anim_info.x) == 1) {\n frameInfo = unpackCurveData(texture_animation_tex0, timeCoord0);\n } else {\n vec3 frameInfo0 = unpackCurveData(texture_animation_tex0, timeCoord0);\n vec3 frameInfo1 = unpackCurveData(texture_animation_tex0, timeCoord1);\n float factor_t = pseudoRandom(a_rndSeed + 90794.);\n frameInfo = mix(frameInfo0, frameInfo1, factor_t);\n }\n startFrame = frameInfo.x / u_anim_info.y;\n frameIndex = repeat(u_anim_info.z * (frameInfo.y + startFrame), 1.);\n #endif\n uv = computeUV(frameIndex, vertIdx, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\n return pos;\n}\nvoid main() { gl_Position = gpvs_main(); }",frag:"\nprecision mediump float;\nuniform mediump vec4 cc_exposure;\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n #if CC_USE_HDR\n color.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n #endif\n return color;\n}\nvarying vec2 uv;\nvarying vec4 color;\nuniform sampler2D mainTexture;\nuniform vec4 tintColor;\nvec4 add () {\n vec4 col = 2.0 * color * tintColor * texture2D(mainTexture, uv);\n return CCFragOutput(col);\n}\nvoid main() { gl_FragColor = add(); }"}],[{vert:"\nprecision mediump float;\nuniform vec4 mainTiling_Offset;\nuniform highp mat4 cc_matViewProj;\nuniform highp vec4 cc_cameraPos;\nuniform highp mat4 cc_matWorld;\nvarying mediump vec2 uv;\nvarying mediump vec4 color;\nattribute vec3 a_position;\nattribute vec4 a_texCoord;\nattribute vec3 a_texCoord1;\nattribute vec3 a_texCoord2;\nattribute vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\n varying vec3 vBarycentric;\n#endif\nvec4 vs_main() {\n highp vec4 pos = vec4(a_position, 1);\n vec4 velocity = vec4(a_texCoord1.xyz, 0);\n #if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n velocity = cc_matWorld * velocity;\n #endif\n float vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\n vec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\n pos.xyz += camUp * vertOffset;\n pos = cc_matViewProj * pos;\n uv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\n color = a_color;\n #if CC_DRAW_WIRE_FRAME\n vBarycentric = a_texCoord2;\n #endif\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }",frag:"\n precision mediump float;\nuniform mediump vec4 cc_exposure;\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n #if CC_USE_HDR\n color.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n #endif\n return color;\n}\n varying vec2 uv;\n varying vec4 color;\n #if CC_DRAW_WIRE_FRAME\n varying vec3 vBarycentric;\n #endif\n uniform sampler2D mainTexture;\n uniform vec4 tintColor;\n vec4 add () {\n vec4 col = 2.0 * color * tintColor * texture2D(mainTexture, uv);\n#if CC_DRAW_WIRE_FRAME\n if (any(lessThan(vBarycentric, vec3(0.02)))) {\n col = vec4(0., 1., 1., 1.);\n }\n#endif\n return CCFragOutput(col);\n }\nvoid main() { gl_FragColor = add(); }"}],[{vert:"\nprecision highp float;\nvec4 quaternionFromAxis (vec3 xAxis,vec3 yAxis,vec3 zAxis){\n mat3 m = mat3(xAxis,yAxis,zAxis);\n float trace = m[0][0] + m[1][1] + m[2][2];\n vec4 quat;\n if (trace > 0.) {\n float s = 0.5 / sqrt(trace + 1.0);\n quat.w = 0.25 / s;\n quat.x = (m[2][1] - m[1][2]) * s;\n quat.y = (m[0][2] - m[2][0]) * s;\n quat.z = (m[1][0] - m[0][1]) * s;\n } else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\n float s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\n quat.w = (m[2][1] - m[1][2]) / s;\n quat.x = 0.25 * s;\n quat.y = (m[0][1] + m[1][0]) / s;\n quat.z = (m[0][2] + m[2][0]) / s;\n } else if (m[1][1] > m[2][2]) {\n float s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\n quat.w = (m[0][2] - m[2][0]) / s;\n quat.x = (m[0][1] + m[1][0]) / s;\n quat.y = 0.25 * s;\n quat.z = (m[1][2] + m[2][1]) / s;\n } else {\n float s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\n quat.w = (m[1][0] - m[0][1]) / s;\n quat.x = (m[0][2] + m[2][0]) / s;\n quat.y = (m[1][2] + m[2][1]) / s;\n quat.z = 0.25 * s;\n }\n float len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\n if (len > 0.) {\n len = 1. / sqrt(len);\n quat.x = quat.x * len;\n quat.y = quat.y * len;\n quat.z = quat.z * len;\n quat.w = quat.w * len;\n }\n return quat;\n}\nvec4 quaternionFromEuler (vec3 angle){\n float x = angle.x / 2.;\n float y = angle.y / 2.;\n float z = angle.z / 2.;\n float sx = sin(x);\n float cx = cos(x);\n float sy = sin(y);\n float cy = cos(y);\n float sz = sin(z);\n float cz = cos(z);\n vec4 quat = vec4(0);\n quat.x = sx * cy * cz + cx * sy * sz;\n quat.y = cx * sy * cz + sx * cy * sz;\n quat.z = cx * cy * sz - sx * sy * cz;\n quat.w = cx * cy * cz - sx * sy * sz;\n return quat;\n}\nmat4 matrixFromRT (vec4 q, vec3 p){\n float x2 = q.x + q.x;\n float y2 = q.y + q.y;\n float z2 = q.z + q.z;\n float xx = q.x * x2;\n float xy = q.x * y2;\n float xz = q.x * z2;\n float yy = q.y * y2;\n float yz = q.y * z2;\n float zz = q.z * z2;\n float wx = q.w * x2;\n float wy = q.w * y2;\n float wz = q.w * z2;\n return mat4(\n 1. - (yy + zz), xy + wz, xz - wy, 0,\n xy - wz, 1. - (xx + zz), yz + wx, 0,\n xz + wy, yz - wx, 1. - (xx + yy), 0,\n p.x, p.y, p.z, 1\n );\n}\nmat4 matFromRTS (vec4 q, vec3 t, vec3 s){\n float x = q.x, y = q.y, z = q.z, w = q.w;\n float x2 = x + x;\n float y2 = y + y;\n float z2 = z + z;\n float xx = x * x2;\n float xy = x * y2;\n float xz = x * z2;\n float yy = y * y2;\n float yz = y * z2;\n float zz = z * z2;\n float wx = w * x2;\n float wy = w * y2;\n float wz = w * z2;\n float sx = s.x;\n float sy = s.y;\n float sz = s.z;\n return mat4((1. - (yy + zz)) * sx, (xy + wz) * sx, (xz - wy) * sx, 0,\n (xy - wz) * sy, (1. - (xx + zz)) * sy, (yz + wx) * sy, 0,\n (xz + wy) * sz, (yz - wx) * sz, (1. - (xx + yy)) * sz, 0,\n t.x, t.y, t.z, 1);\n}\nvec4 quatMultiply (vec4 a, vec4 b){\n vec4 quat;\n quat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\n quat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\n quat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\n quat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\n return quat;\n}\nvoid rotateVecFromQuat (inout vec3 v, vec4 q){\n float ix = q.w * v.x + q.y * v.z - q.z * v.y;\n float iy = q.w * v.y + q.z * v.x - q.x * v.z;\n float iz = q.w * v.z + q.x * v.y - q.y * v.x;\n float iw = -q.x * v.x - q.y * v.y - q.z * v.z;\n v.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\n v.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\n v.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace (vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\n vec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\n vec4 rotQuat = quatMultiply(viewQuat, q);\n rotateVecFromQuat(pos, rotQuat);\n return pos;\n}\nvoid rotateCorner (inout vec2 corner, float angle){\n float xOS = cos(angle) * corner.x - sin(angle) * corner.y;\n float yOS = sin(angle) * corner.x + cos(angle) * corner.y;\n corner.x = xOS;\n corner.y = yOS;\n}\nuniform vec4 mainTiling_Offset;\nuniform vec4 frameTile_velLenScale;\nuniform vec4 scale;\nuniform highp mat4 cc_matView;\nuniform highp mat4 cc_matViewInv;\nuniform highp mat4 cc_matViewProj;\nuniform highp vec4 cc_cameraPos;\nuniform highp mat4 cc_matWorld;\nvarying mediump vec2 uv;\nvarying mediump vec4 color;\nvoid computeVertPos (inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n#if CC_RENDER_MODE == 0 || CC_RENDER_MODE == 3\n , mat4 viewInv\n#endif\n#if CC_RENDER_MODE == 1\n , vec3 eye\n , vec4 velocity\n , float velocityScale\n , float lengthScale\n , float xIndex\n#endif\n) {\n#if CC_RENDER_MODE == 0\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\n vec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\n vec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_RENDER_MODE == 1\n vec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\n vec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\n pos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_RENDER_MODE == 2\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = vec3(1, 0, 0);\n vec3 camY = vec3(0, 0, -1);\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_RENDER_MODE == 3\n vec2 viewSpaceVert = vec2(vertOffset.x * s.x, vertOffset.y * s.y);\n rotateCorner(viewSpaceVert, q.z);\n vec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\n vec3 camY = vec3(0, 1, 0);\n vec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\n pos.xyz += offset;\n#else\n pos.x += vertOffset.x;\n pos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV (float frameIndex, vec2 vertIndex, vec2 frameTile){\n vec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\n aniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if CC_RENDER_MODE != 4\n vertIndex.y = 1. - vertIndex.y;\n#endif\n return (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nattribute vec3 a_position;\nattribute vec3 a_texCoord;\nattribute vec3 a_texCoord1;\nattribute vec3 a_texCoord2;\nattribute vec4 a_color;\n#if CC_RENDER_MODE == 1\n attribute vec3 a_color1;\n#endif\n#if CC_RENDER_MODE == 4\n attribute vec3 a_texCoord3;\n attribute vec3 a_normal;\n attribute vec4 a_color1;\n#endif\nvec4 lpvs_main () {\n vec3 compScale = scale.xyz * a_texCoord1;\n vec4 pos = vec4(a_position, 1);\n #if CC_RENDER_MODE == 1\n vec4 velocity = vec4(a_color1.xyz, 0);\n #endif\n #if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n #if CC_RENDER_MODE == 1\n velocity = cc_matWorld * velocity;\n #endif\n #endif\n #if CC_RENDER_MODE != 4\n vec2 cornerOffset = vec2((a_texCoord.xy - 0.5));\n #if CC_RENDER_MODE == 0\n vec3 rotEuler = a_texCoord2;\n #elif CC_RENDER_MODE == 1\n vec3 rotEuler = vec3(0.);\n #else\n vec3 rotEuler = vec3(0., 0., a_texCoord2.z);\n #endif\n computeVertPos(pos, cornerOffset, quaternionFromEuler(rotEuler), compScale\n #if CC_RENDER_MODE == 0 || CC_RENDER_MODE == 3\n , cc_matViewInv\n #endif\n #if CC_RENDER_MODE == 1\n , cc_cameraPos.xyz\n , velocity\n , frameTile_velLenScale.z\n , frameTile_velLenScale.w\n , a_texCoord.x\n #endif\n );\n color = a_color;\n #else\n mat4 xformNoScale = matrixFromRT(quaternionFromEuler(a_texCoord2), pos.xyz);\n mat4 xform = matFromRTS(quaternionFromEuler(a_texCoord2), pos.xyz, compScale);\n pos = xform * vec4(a_texCoord3, 1);\n vec4 normal = xformNoScale * vec4(a_normal, 0);\n color = a_color * a_color1;\n #endif\n uv = computeUV(a_texCoord.z, a_texCoord.xy, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\n pos = cc_matViewProj * pos;\n return pos;\n}\nvoid main() { gl_Position = lpvs_main(); }",frag:"\nprecision mediump float;\nuniform mediump vec4 cc_exposure;\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n #if CC_USE_HDR\n color.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n #endif\n return color;\n}\nvarying vec2 uv;\nvarying vec4 color;\nuniform sampler2D mainTexture;\nuniform vec4 tintColor;\nvec4 add () {\n vec4 col = 2.0 * color * tintColor * texture2D(mainTexture, uv);\n return CCFragOutput(col);\n}\nvoid main() { gl_FragColor = add(); }"}],[{vert:"\nprecision highp float;\nuniform highp mat4 cc_matViewProj;\n#if USE_LOCAL\nuniform highp mat4 cc_matWorld;\n#endif\nattribute vec3 a_position;\nattribute vec2 a_texCoord;\nattribute vec4 a_color;\nvarying vec4 v_light;\nvarying vec2 uv0;\n#if TWO_COLORED\n attribute vec4 a_color2;\n varying vec4 v_dark;\n#endif\nvec4 vert () {\n vec4 pos = vec4(a_position, 1);\n #if USE_LOCAL\n pos = cc_matWorld * pos;\n #endif\n pos = cc_matViewProj * pos;\n uv0 = a_texCoord;\n v_light = a_color;\n #if TWO_COLORED\n v_dark = a_color2;\n #endif\n return pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvarying vec4 v_light;\n#if TWO_COLORED\n varying vec4 v_dark;\n#endif\nvarying vec2 uv0;\nuniform sampler2D cc_spriteTexture;\nvec4 frag () {\n vec4 o = vec4(1, 1, 1, 1);\n #if TWO_COLORED\n vec4 texColor = vec4(1, 1, 1, 1);\n texColor *= texture2D(cc_spriteTexture, uv0);\n o.a = texColor.a * v_light.a;\n o.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;\n #else\n o *= texture2D(cc_spriteTexture, uv0);\n o *= v_light;\n #endif\n ALPHA_TEST(o);\n return o;\n}\nvoid main() { gl_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nuniform highp mat4 cc_matView;\nuniform highp mat4 cc_matProj;\nuniform highp mat4 cc_matViewProj;\n#if USE_LOCAL\nuniform highp mat4 cc_matWorld;\n#endif\nattribute vec3 a_position;\nattribute vec2 a_texCoord;\nattribute vec4 a_color;\nvarying vec4 color;\nvarying vec2 uv0;\nvec4 vert () {\n vec4 pos = vec4(a_position, 1);\n #if USE_LOCAL\n pos = cc_matWorld * pos;\n #endif\n #if USE_PIXEL_ALIGNMENT\n pos = cc_matView * pos;\n pos.xyz = floor(pos.xyz);\n pos = cc_matProj * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n uv0 = a_texCoord;\n color = a_color;\n return pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nvec4 CCSampleWithAlphaSeparated(sampler2D tex, vec2 uv) {\n#if CC_USE_EMBEDDED_ALPHA\n return vec4(texture2D(tex, uv).rgb, texture2D(tex, uv + vec2(0.0, 0.5)).r);\n#else\n return texture2D(tex, uv);\n#endif\n}\n#if USE_ALPHA_TEST\n uniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvarying vec4 color;\n#if USE_TEXTURE\n varying vec2 uv0;\n uniform sampler2D cc_spriteTexture;\n#endif\nvec4 frag () {\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n o *= CCSampleWithAlphaSeparated(cc_spriteTexture, uv0);\n #if IS_GRAY\n float gray = 0.2126 * o.r + 0.7152 * o.g + 0.0722 * o.b;\n o.r = o.g = o.b = gray;\n #endif\n #endif\n o *= color;\n ALPHA_TEST(o);\n return o;\n}\nvoid main() { gl_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\n rgba = rgba * 255.0;\n highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\n highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\n highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\n highp vec4 position;\n vec3 normal;\n vec4 tangent;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nattribute vec4 a_tangent;\n#if CC_USE_MORPH\n attribute float a_vertexId;\n int getVertexId() {\n return int(a_vertexId);\n }\nuniform vec4 cc_displacementWeights[15];\nuniform vec4 cc_displacementTextureInfo;\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\n float pixelIndexF = float(pixelIndex);\n float x = mod(pixelIndexF, textureResolution.x);\n float y = floor(pixelIndexF / textureResolution.x);\n return vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\n return (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_SUPPORT_FLOAT_TEXTURE\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 uv = getPixelCoordFromLocation(location, cc_displacementTextureInfo.xy);\n return texture2D(tex, uv);\n }\n#else\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex * 4;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\n return vec4(\n decode32(texture2D(tex, x)),\n decode32(texture2D(tex, y)),\n decode32(texture2D(tex, z)),\n 1.0\n );\n }\n#endif\nfloat getDisplacementWeight(int index) {\n int quot = index / 4;\n int remainder = index - quot * 4;\n if (remainder == 0) {\n return cc_displacementWeights[quot].x;\n } else if (remainder == 1) {\n return cc_displacementWeights[quot].y;\n } else if (remainder == 2) {\n return cc_displacementWeights[quot].z;\n } else {\n return cc_displacementWeights[quot].w;\n }\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\n return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\n vec3 result = vec3(0, 0, 0);\n int nVertices = int(cc_displacementTextureInfo.z);\n for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\n result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n }\n return result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\n uniform sampler2D cc_PositionDisplacements;\n vec3 getPositionDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n uniform sampler2D cc_NormalDisplacements;\n vec3 getNormalDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n uniform sampler2D cc_TangentDisplacements;\n vec3 getTangentDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n }\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\n int vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\n attr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n attr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n attr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\n attribute vec4 a_joints;\nattribute vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n #if USE_INSTANCING\n attribute highp vec4 a_jointAnimInfo;\n #endif\n uniform highp vec4 cc_jointTextureInfo;\n uniform highp vec4 cc_jointAnimInfo;\n uniform highp sampler2D cc_jointTexture;\n #else\n uniform highp vec4 cc_joints[90];\n#endif\n#if CC_USE_BAKED_ANIMATION\n #if CC_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y));\n vec4 v2 = texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y));\n vec4 v3 = texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n );\n vec4 v2 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n );\n vec4 v3 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n#else\n mat4 getJointMatrix (float i) {\n int idx = int(i);\n vec4 v1 = cc_joints[idx * 3];\n vec4 v2 = cc_joints[idx * 3 + 1];\n vec4 v3 = cc_joints[idx * 3 + 2];\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n#endif\nmat4 skinMatrix () {\n vec4 joints = vec4(a_joints);\n return getJointMatrix(joints.x) * a_weights.x\n + getJointMatrix(joints.y) * a_weights.y\n + getJointMatrix(joints.z) * a_weights.z\n + getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\n mat4 m = skinMatrix();\n position = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\n mat4 m = skinMatrix();\n attr.position = m * attr.position;\n attr.normal = (m * vec4(attr.normal, 0.0)).xyz;\n attr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nuniform highp mat4 cc_matView;\nuniform highp mat4 cc_matProj;\nuniform highp vec4 cc_cameraPos;\nuniform mediump vec4 cc_fogBase;\nuniform mediump vec4 cc_fogAdd;\n#if USE_INSTANCING\n attribute vec4 a_matWorld0;\n attribute vec4 a_matWorld1;\n attribute vec4 a_matWorld2;\n #if USE_LIGHTMAP\n attribute vec4 a_lightingMapUVParam;\n #endif\n#elif USE_BATCHING\n attribute float a_dyn_batch_id;\n uniform highp mat4 cc_matWorlds[10];\n#else\nuniform highp mat4 cc_matWorld;\nuniform highp mat4 cc_matWorldIT;\nuniform highp vec4 cc_lightingMapUVParam;\n#endif\nuniform vec4 tilingOffset;\nfloat LinearFog(vec4 pos) {\n vec4 wPos = pos;\n float cam_dis = distance(cc_cameraPos, wPos);\n float fogStart = cc_fogBase.x;\n float fogEnd = cc_fogBase.y;\n return clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float fogDensity = cc_fogBase.z;\n float cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\n float f = exp(-cam_dis * fogDensity);\n return f;\n}\nfloat ExpSquaredFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float fogDensity = cc_fogBase.z;\n float cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\n float f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\n return f;\n}\nfloat LayeredFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float _FogTop = cc_fogAdd.x;\n float _FogRange = cc_fogAdd.y;\n vec3 camWorldProj = cc_cameraPos.xyz;\n camWorldProj.y = 0.;\n vec3 worldPosProj = wPos.xyz;\n worldPosProj.y = 0.;\n float fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\n float fDeltaY, fDensityIntegral;\n if (cc_cameraPos.y > _FogTop) {\n if (wPos.y < _FogTop) {\n fDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\n fDensityIntegral = fDeltaY * fDeltaY * 0.5;\n } else {\n fDeltaY = 0.;\n fDensityIntegral = 0.;\n }\n } else {\n if (wPos.y < _FogTop) {\n float fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\n float fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\n fDeltaY = abs(fDeltaA - fDeltaB);\n fDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n } else {\n fDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\n fDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n }\n }\n float fDensity;\n if (fDeltaY != 0.) {\n fDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n } else {\n fDensity = 0.;\n }\n float f = exp(-fDensity);\n return f;\n}\nfloat CC_TRANSFER_FOG(vec4 pos) {\n #if CC_USE_FOG == 0\n return LinearFog(pos);\n\t#elif CC_USE_FOG == 1\n return ExpFog(pos);\n #elif CC_USE_FOG == 2\n return ExpSquaredFog(pos);\n #elif CC_USE_FOG == 3\n return LayeredFog(pos);\n #endif\n return 1.;\n}\nvarying highp vec4 v_shadowPos;\nuniform highp mat4 cc_matLightViewProj;\n#if USE_VERTEX_COLOR\n attribute vec4 a_color;\n varying vec4 v_color;\n#endif\nvarying vec3 v_position;\nvarying vec3 v_normal;\nvarying vec2 v_uv;\nvarying vec2 v_uv1;\nvarying float v_fog_factor;\n#if USE_NORMAL_MAP\n varying vec3 v_tangent;\n varying vec3 v_bitangent;\n#endif\n#if HAS_SECOND_UV || USE_LIGHTMAP\n attribute vec2 a_texCoord1;\n#endif\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\n varying vec2 v_luv;\nvoid CCLightingMapCaclUV()\n{\n#if !USE_INSTANCING\n v_luv = cc_lightingMapUVParam.xy + a_texCoord1 * cc_lightingMapUVParam.zw;\n#else\n v_luv = a_lightingMapUVParam.xy + a_texCoord1 * a_lightingMapUVParam.zw;\n#endif\n}\n#endif\nvec4 vert () {\n StandardVertInput In;\n In.position = vec4(a_position, 1.0);\n In.normal = a_normal;\n In.tangent = a_tangent;\n #if CC_USE_MORPH\n applyMorph(In);\n #endif\n #if CC_USE_SKINNING\n CCSkin(In);\n #endif\n mat4 matWorld, matWorldIT;\n #if USE_INSTANCING\n matWorld = mat4(\n vec4(a_matWorld0.xyz, 0.0),\n vec4(a_matWorld1.xyz, 0.0),\n vec4(a_matWorld2.xyz, 0.0),\n vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n );\n matWorldIT = matWorld;\n #elif USE_BATCHING\n matWorld = cc_matWorlds[int(a_dyn_batch_id)];\n matWorldIT = matWorld;\n #else\n matWorld = cc_matWorld;\n matWorldIT = cc_matWorldIT;\n #endif\n vec4 pos = matWorld * In.position;\n v_position = pos.xyz;\n v_normal = normalize((matWorldIT * vec4(In.normal, 0.0)).xyz);\n #if USE_NORMAL_MAP\n v_tangent = normalize((matWorld * vec4(In.tangent.xyz, 0.0)).xyz);\n v_bitangent = cross(v_normal, v_tangent) * In.tangent.w;\n #endif\n v_uv = a_texCoord * tilingOffset.xy + tilingOffset.zw;\n #if HAS_SECOND_UV\n v_uv1 = a_texCoord1 * tilingOffset.xy + tilingOffset.zw;\n #endif\n #if USE_VERTEX_COLOR\n v_color = a_color;\n #endif\n v_fog_factor = CC_TRANSFER_FOG(pos);\n #if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\n CCLightingMapCaclUV();\n #endif\n v_shadowPos = cc_matLightViewProj * pos;\n return cc_matProj * (cc_matView * matWorld) * In.position;\n}\nvoid main() { gl_Position = vert(); }",frag:"\n#ifdef GL_EXT_shader_texture_lod\n#extension GL_EXT_shader_texture_lod: enable\n#endif\nprecision highp float;\nuniform highp vec4 cc_cameraPos;\nuniform mediump vec4 cc_exposure;\nuniform mediump vec4 cc_mainLitDir;\nuniform mediump vec4 cc_mainLitColor;\nuniform mediump vec4 cc_ambientSky;\nuniform mediump vec4 cc_ambientGround;\nuniform mediump vec4 cc_fogColor;\nuniform lowp vec4 cc_shadowColor;\nuniform lowp vec4 cc_shadowInfo;\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\nvec3 unpackRGBE (vec4 rgbe) {\n return rgbe.rgb * pow(2.0, rgbe.a * 255.0 - 128.0);\n}\nvec4 fragTextureLod (sampler2D tex, vec2 coord, float lod) {\n #ifdef GL_EXT_shader_texture_lod\n return texture2DLodEXT(tex, coord, lod);\n #else\n return texture2D(tex, coord, lod);\n #endif\n}\nvec4 fragTextureLod (samplerCube tex, vec3 coord, float lod) {\n #ifdef GL_EXT_shader_texture_lod\n return textureCubeLodEXT(tex, coord, lod);\n #else\n return textureCube(tex, coord, lod);\n #endif\n}\n#endif\n#if CC_RECEIVE_SHADOW\nvarying highp vec4 v_shadowPos;\n#if CC_RECEIVE_SHADOW\n uniform sampler2D cc_shadowMap;\n uniform sampler2D cc_spotLightingMap;\n float CCGetShadowFactorX1 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float closestDepth = dot(texture2D(cc_shadowMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n float shadow = step(closestDepth, clipPos.z - cc_shadowInfo.w);\n return shadow;\n }\n float CCGetShadowFactorX5 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n float closestDepth = 0.0;\n closestDepth = dot(texture2D(cc_shadowMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_shadowMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_shadowMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_shadowMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n return shadow / 5.0;\n }\n float CCGetShadowFactorX9 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -1; i <= 1; i++) {\n for (int j = -1; j <= 1; j++) {\n float closestDepth = dot(texture2D(cc_shadowMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 9.0;\n }\n float CCGetShadowFactorX25 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -2; i <= 2; i++) {\n for (int j = -2; j <= 2; j++) {\n float closestDepth = dot(texture2D(cc_shadowMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 25.0;\n }\n float CCGetDirLightShadowFactorX1 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float closestDepth = dot(texture2D(cc_spotLightingMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n float shadow = step(closestDepth, clipPos.z - cc_shadowInfo.w);\n return shadow;\n }\n float CCGetDirLightShadowFactorX5 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n float closestDepth = 0.0;\n closestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n return shadow / 5.0;\n }\n float CCGetDirLightShadowFactorX9 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -1; i <= 1; i++) {\n for (int j = -1; j <= 1; j++) {\n float closestDepth = dot(texture2D(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 9.0;\n }\n float CCGetDirLightShadowFactorX25 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -2; i <= 2; i++) {\n for (int j = -2; j <= 2; j++) {\n float closestDepth = dot(texture2D(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 25.0;\n }\n#endif\n#endif\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nfloat GGXMobile (float roughness, float NoH, vec3 H, vec3 N) {\n vec3 NxH = cross(N, H);\n float OneMinusNoHSqr = dot(NxH, NxH);\n float a = roughness * roughness;\n float n = NoH * a;\n float p = a / (OneMinusNoHSqr + n * n);\n return p * p;\n}\nfloat CalcSpecular (float roughness, float NoH, vec3 H, vec3 N) {\n return (roughness*0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox (vec3 specular, float roughness, float NoV) {\n const vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\n const vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\n vec4 r = roughness * c0 + c1;\n float a004 = min( r.x * r.x, exp2( -9.28 * NoV ) ) * r.x + r.y;\n vec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n AB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\n return specular * AB.x + AB.y;\n}\nstruct StandardSurface {\n vec4 albedo;\n vec3 position;\n vec3 normal;\n vec3 emissive;\n vec4 lightmap;\n float roughness;\n float metallic;\n float occlusion;\n};\n#if CC_FORWARD_ADD\nuniform highp vec4 cc_lightPos[1];\nuniform vec4 cc_lightColor[1];\nuniform vec4 cc_lightSizeRangeAngle[1];\nuniform vec4 cc_lightDir[1];\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\n float factor = distSqr * invSqrAttRadius;\n float smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\n return smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\n float attenuation = 1.0 / max(distSqr, 0.01*0.01);\n attenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\n return attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\n float cd = dot(litDir, L);\n float attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\n return (attenuation * attenuation);\n}\n vec4 CCStandardShading (StandardSurface s) {\n vec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\n vec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\n vec3 diffuseContrib = diffuse / 3.14159265359;\n vec3 N = normalize(s.normal);\n vec3 V = normalize(cc_cameraPos.xyz - s.position);\n float NV = max(abs(dot(N, V)), 0.001);\n specular = BRDFApprox(specular, s.roughness, NV);\n vec3 finalColor = vec3(0.0);\n for (int i = 0; i < 1; i++) {\n vec3 SLU = cc_lightPos[i].xyz - s.position;\n vec3 SL = normalize(SLU);\n vec3 SH = normalize(SL + V);\n float SNL = max(dot(N, SL), 0.001);\n float SNH = max(dot(N, SH), 0.0);\n float distSqr = dot(SLU, SLU);\n float litRadius = cc_lightSizeRangeAngle[i].x;\n float litRadiusSqr = litRadius * litRadius;\n float illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\n float attRadiusSqrInv = 1.0 / max(cc_lightSizeRangeAngle[i].y, 0.01);\n attRadiusSqrInv *= attRadiusSqrInv;\n float att = GetDistAtt(distSqr, attRadiusSqrInv);\n vec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\n if (cc_lightPos[i].w > 0.0) {\n float cosInner = max(dot(-cc_lightDir[i].xyz, SL), 0.01);\n float cosOuter = cc_lightSizeRangeAngle[i].z;\n float litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\n float litAngleOffset = -cosOuter * litAngleScale;\n att *= GetAngleAtt(SL, -cc_lightDir[i].xyz, litAngleScale, litAngleOffset);\n }\n vec3 lightColor = cc_lightColor[i].rgb;\n #if CC_RECEIVE_SHADOW\n if (cc_lightPos[i].w > 0.0) {\n {\n float pcf = cc_shadowInfo.z + 0.001;\n float shadowAttenuation = 0.0;\n if (pcf > 3.0) shadowAttenuation = CCGetDirLightShadowFactorX25();\n else if (3.0 > pcf && pcf > 2.0) shadowAttenuation = CCGetDirLightShadowFactorX9();\n else if (2.0 > pcf && pcf > 1.0) shadowAttenuation = CCGetDirLightShadowFactorX5();\n else shadowAttenuation = CCGetDirLightShadowFactorX1();\n lightColor *= 1.0 - shadowAttenuation;\n }\n }\n #endif\n finalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n }\n finalColor = finalColor * s.occlusion;\n return vec4(finalColor, 0.0);\n }\n#else\n vec4 CCStandardShading (StandardSurface s) {\n vec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\n vec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\n vec3 N = normalize(s.normal);\n vec3 V = normalize(cc_cameraPos.xyz - s.position);\n float NV = max(abs(dot(N, V)), 0.001);\n specular = BRDFApprox(specular, s.roughness, NV);\n vec3 L = normalize(-cc_mainLitDir.xyz);\n vec3 H = normalize(L+V);\n float NH = max(dot(N, H), 0.0);\n float NL = max(dot(N, L), 0.001);\n vec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w;\n #if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\n finalColor = s.lightmap.a * s.lightmap.rgb + (1.0 - s.lightmap.a) * finalColor;\n #endif\n vec3 diffuseContrib = diffuse / 3.14159265359;\n vec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\n finalColor *= (diffuseContrib + specularContrib);\n float fAmb = 0.5 - N.y * 0.5;\n vec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb) * cc_ambientSky.w;\n finalColor += (ambDiff.rgb * diffuse);\n #if CC_USE_IBL\n vec3 R = normalize(reflect(-V, N));\n vec4 envmap = fragTextureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n #if CC_USE_IBL == 2\n vec3 env = unpackRGBE(envmap);\n #else\n vec3 env = SRGBToLinear(envmap.rgb);\n #endif\n finalColor += env * cc_ambientSky.w * specular;\n #endif\n finalColor = finalColor * s.occlusion;\n #if CC_USE_HDR\n s.emissive *= cc_exposure.w;\n #endif\n finalColor += s.emissive;\n #if CC_RECEIVE_SHADOW\n {\n float pcf = cc_shadowInfo.z + 0.001;\n float shadowAttenuation = 0.0;\n if (pcf > 3.0) shadowAttenuation = CCGetShadowFactorX25();\n else if (3.0 > pcf && pcf > 2.0) shadowAttenuation = CCGetShadowFactorX9();\n else if (2.0 > pcf && pcf > 1.0) shadowAttenuation = CCGetShadowFactorX5();\n else shadowAttenuation = CCGetShadowFactorX1();\n vec3 shadowColor = cc_shadowColor.rgb * cc_shadowColor.a + finalColor.rgb * (1.0 - cc_shadowColor.a);\n finalColor.rgb = shadowColor.rgb * shadowAttenuation * NL + finalColor.rgb * (1.0 - shadowAttenuation * NL);\n }\n #endif\n return vec4(finalColor, s.albedo.a);\n }\n#endif\nvec3 ACESToneMap (vec3 color) {\n color = min(color, vec3(8.0));\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n #if !CC_USE_HDR\n color.rgb = sqrt(ACESToneMap(color.rgb));\n #endif\n return color;\n}\nuniform vec4 albedo;\nuniform vec4 albedoScaleAndCutoff;\nuniform vec4 pbrParams;\nuniform vec4 emissive;\nuniform vec4 emissiveScaleParam;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\n varying vec2 v_luv;\nuniform sampler2D cc_lightingMap;\n#endif\nvarying vec3 v_position;\nvarying vec2 v_uv;\nvarying vec2 v_uv1;\nvarying vec3 v_normal;\nvarying float v_fog_factor;\n#if USE_VERTEX_COLOR\n varying vec4 v_color;\n#endif\n#if USE_ALBEDO_MAP\n uniform sampler2D albedoMap;\n#endif\n#if USE_NORMAL_MAP\n varying vec3 v_tangent;\n varying vec3 v_bitangent;\n uniform sampler2D normalMap;\n#endif\n#if USE_PBR_MAP\n uniform sampler2D pbrMap;\n#endif\n#if USE_METALLIC_ROUGHNESS_MAP\n uniform sampler2D metallicRoughnessMap;\n#endif\n#if USE_OCCLUSION_MAP\n uniform sampler2D occlusionMap;\n#endif\n#if USE_EMISSIVE_MAP\n uniform sampler2D emissiveMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\nvoid surf (out StandardSurface s) {\n vec4 baseColor = albedo;\n #if USE_VERTEX_COLOR\n baseColor *= v_color;\n #endif\n #if USE_ALBEDO_MAP\n vec4 texColor = texture2D(albedoMap, ALBEDO_UV);\n texColor.rgb = SRGBToLinear(texColor.rgb);\n baseColor *= texColor;\n #endif\n s.albedo = baseColor;\n s.albedo.rgb *= albedoScaleAndCutoff.xyz;\n #if USE_ALPHA_TEST\n if (s.albedo.ALPHA_TEST_CHANNEL < albedoScaleAndCutoff.w) discard;\n #endif\n #if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\n s.lightmap = texture2D(cc_lightingMap, v_luv);\n #endif\n s.normal = v_normal;\n #if USE_NORMAL_MAP\n vec3 nmmp = texture2D(normalMap, NORMAL_UV).xyz - vec3(0.5);\n s.normal =\n (nmmp.x * pbrParams.w) * normalize(v_tangent) +\n (nmmp.y * pbrParams.w) * normalize(v_bitangent) +\n nmmp.z * normalize(s.normal);\n #endif\n s.position = v_position;\n vec4 pbr = pbrParams;\n #if USE_PBR_MAP\n vec4 res = texture2D(pbrMap, PBR_UV);\n pbr.x *= res.r;\n pbr.y *= res.g;\n pbr.z *= res.b;\n #endif\n #if USE_METALLIC_ROUGHNESS_MAP\n vec4 metallicRoughness = texture2D(metallicRoughnessMap, PBR_UV);\n pbr.z *= metallicRoughness.b;\n pbr.y *= metallicRoughness.g;\n #endif\n #if USE_OCCLUSION_MAP\n pbr.x *= texture2D(occlusionMap, PBR_UV).r;\n #endif\n s.occlusion = clamp(pbr.x, 0.0, 0.96);\n s.roughness = clamp(pbr.y, 0.04, 1.0);\n s.metallic = pbr.z;\n s.emissive = emissive.rgb * emissiveScaleParam.xyz;\n #if USE_EMISSIVE_MAP\n s.emissive *= SRGBToLinear(texture2D(emissiveMap, EMISSIVE_UV).rgb);\n #endif\n}\nvec4 frag () {\n StandardSurface s; surf(s);\n vec4 color = CCStandardShading(s);\n color = vec4(mix(CC_FORWARD_ADD > 0 ? vec3(0.0) : cc_fogColor.rgb, color.rgb, v_fog_factor), color.a);\n return CCFragOutput(color);\n}\nvoid main() { gl_FragColor = frag(); }"},{vert:"\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\n rgba = rgba * 255.0;\n highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\n highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\n highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\n highp vec4 position;\n vec3 normal;\n vec4 tangent;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nattribute vec4 a_tangent;\n#if CC_USE_MORPH\n attribute float a_vertexId;\n int getVertexId() {\n return int(a_vertexId);\n }\nuniform vec4 cc_displacementWeights[15];\nuniform vec4 cc_displacementTextureInfo;\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\n float pixelIndexF = float(pixelIndex);\n float x = mod(pixelIndexF, textureResolution.x);\n float y = floor(pixelIndexF / textureResolution.x);\n return vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\n return (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_SUPPORT_FLOAT_TEXTURE\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 uv = getPixelCoordFromLocation(location, cc_displacementTextureInfo.xy);\n return texture2D(tex, uv);\n }\n#else\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex * 4;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\n return vec4(\n decode32(texture2D(tex, x)),\n decode32(texture2D(tex, y)),\n decode32(texture2D(tex, z)),\n 1.0\n );\n }\n#endif\nfloat getDisplacementWeight(int index) {\n int quot = index / 4;\n int remainder = index - quot * 4;\n if (remainder == 0) {\n return cc_displacementWeights[quot].x;\n } else if (remainder == 1) {\n return cc_displacementWeights[quot].y;\n } else if (remainder == 2) {\n return cc_displacementWeights[quot].z;\n } else {\n return cc_displacementWeights[quot].w;\n }\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\n return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\n vec3 result = vec3(0, 0, 0);\n int nVertices = int(cc_displacementTextureInfo.z);\n for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\n result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n }\n return result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\n uniform sampler2D cc_PositionDisplacements;\n vec3 getPositionDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n uniform sampler2D cc_NormalDisplacements;\n vec3 getNormalDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n uniform sampler2D cc_TangentDisplacements;\n vec3 getTangentDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n }\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\n int vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\n attr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n attr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n attr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\n attribute vec4 a_joints;\nattribute vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n #if USE_INSTANCING\n attribute highp vec4 a_jointAnimInfo;\n #endif\n uniform highp vec4 cc_jointTextureInfo;\n uniform highp vec4 cc_jointAnimInfo;\n uniform highp sampler2D cc_jointTexture;\n #else\n uniform highp vec4 cc_joints[90];\n#endif\n#if CC_USE_BAKED_ANIMATION\n #if CC_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y));\n vec4 v2 = texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y));\n vec4 v3 = texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n );\n vec4 v2 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n );\n vec4 v3 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n#else\n mat4 getJointMatrix (float i) {\n int idx = int(i);\n vec4 v1 = cc_joints[idx * 3];\n vec4 v2 = cc_joints[idx * 3 + 1];\n vec4 v3 = cc_joints[idx * 3 + 2];\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n#endif\nmat4 skinMatrix () {\n vec4 joints = vec4(a_joints);\n return getJointMatrix(joints.x) * a_weights.x\n + getJointMatrix(joints.y) * a_weights.y\n + getJointMatrix(joints.z) * a_weights.z\n + getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\n mat4 m = skinMatrix();\n position = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\n mat4 m = skinMatrix();\n attr.position = m * attr.position;\n attr.normal = (m * vec4(attr.normal, 0.0)).xyz;\n attr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\n#if USE_INSTANCING\n attribute vec4 a_matWorld0;\n attribute vec4 a_matWorld1;\n attribute vec4 a_matWorld2;\n #if USE_LIGHTMAP\n attribute vec4 a_lightingMapUVParam;\n #endif\n#elif USE_BATCHING\n attribute float a_dyn_batch_id;\n uniform highp mat4 cc_matWorlds[10];\n#else\nuniform highp mat4 cc_matWorld;\nuniform highp mat4 cc_matWorldIT;\n#endif\nuniform vec4 tilingOffset;\nuniform highp mat4 cc_matLightViewProj;\n#if HAS_SECOND_UV || USE_LIGHTMAP\n attribute vec2 a_texCoord1;\n#endif\nvarying vec2 v_uv;\nvarying vec2 v_uv1;\nvarying float v_clip_depth;\nvec4 vert () {\n StandardVertInput In;\n In.position = vec4(a_position, 1.0);\n In.normal = a_normal;\n In.tangent = a_tangent;\n #if CC_USE_MORPH\n applyMorph(In);\n #endif\n #if CC_USE_SKINNING\n CCSkin(In);\n #endif\n mat4 matWorld, matWorldIT;\n #if USE_INSTANCING\n matWorld = mat4(\n vec4(a_matWorld0.xyz, 0.0),\n vec4(a_matWorld1.xyz, 0.0),\n vec4(a_matWorld2.xyz, 0.0),\n vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n );\n matWorldIT = matWorld;\n #elif USE_BATCHING\n matWorld = cc_matWorlds[int(a_dyn_batch_id)];\n matWorldIT = matWorld;\n #else\n matWorld = cc_matWorld;\n matWorldIT = cc_matWorldIT;\n #endif\n vec4 worldPos = matWorld * In.position;\n vec4 clipPos = cc_matLightViewProj * worldPos;\n v_uv = a_texCoord * tilingOffset.xy + tilingOffset.zw;\n #if HAS_SECOND_UV\n v_uv1 = a_texCoord1 * tilingOffset.xy + tilingOffset.zw;\n #endif\n v_clip_depth = clipPos.z / clipPos.w * 0.5 + 0.5;\n return clipPos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nuniform vec4 albedo;\nuniform vec4 albedoScaleAndCutoff;\nvec4 packDepthToRGBA (float depth) {\n vec4 ret = vec4(1.0, 255.0, 65025.0, 160581375.0) * depth;\n ret = fract(ret);\n ret -= ret.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n return ret;\n}\nvarying vec2 v_uv;\nvarying vec2 v_uv1;\nvarying float v_clip_depth;\n#if USE_ALBEDO_MAP\n uniform sampler2D albedoMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\nvec4 frag () {\n vec4 baseColor = albedo;\n #if USE_ALBEDO_MAP\n baseColor *= texture2D(albedoMap, ALBEDO_UV);\n #endif\n #if USE_ALPHA_TEST\n if (baseColor.ALPHA_TEST_CHANNEL < albedoScaleAndCutoff.w) discard;\n #endif\n return packDepthToRGBA(v_clip_depth);\n}\nvoid main() { gl_FragColor = frag(); }"}],[{vert:"\nprecision mediump float;\nuniform highp mat4 cc_matViewProj;\nuniform highp vec4 cc_cameraPos;\nuniform mediump vec4 cc_fogBase;\nuniform mediump vec4 cc_fogAdd;\nuniform highp mat4 cc_matWorld;\nfloat LinearFog(vec4 pos) {\n vec4 wPos = pos;\n float cam_dis = distance(cc_cameraPos, wPos);\n float fogStart = cc_fogBase.x;\n float fogEnd = cc_fogBase.y;\n return clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float fogDensity = cc_fogBase.z;\n float cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\n float f = exp(-cam_dis * fogDensity);\n return f;\n}\nfloat ExpSquaredFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float fogDensity = cc_fogBase.z;\n float cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\n float f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\n return f;\n}\nfloat LayeredFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float _FogTop = cc_fogAdd.x;\n float _FogRange = cc_fogAdd.y;\n vec3 camWorldProj = cc_cameraPos.xyz;\n camWorldProj.y = 0.;\n vec3 worldPosProj = wPos.xyz;\n worldPosProj.y = 0.;\n float fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\n float fDeltaY, fDensityIntegral;\n if (cc_cameraPos.y > _FogTop) {\n if (wPos.y < _FogTop) {\n fDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\n fDensityIntegral = fDeltaY * fDeltaY * 0.5;\n } else {\n fDeltaY = 0.;\n fDensityIntegral = 0.;\n }\n } else {\n if (wPos.y < _FogTop) {\n float fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\n float fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\n fDeltaY = abs(fDeltaA - fDeltaB);\n fDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n } else {\n fDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\n fDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n }\n }\n float fDensity;\n if (fDeltaY != 0.) {\n fDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n } else {\n fDensity = 0.;\n }\n float f = exp(-fDensity);\n return f;\n}\nfloat CC_TRANSFER_FOG(vec4 pos) {\n #if CC_USE_FOG == 0\n return LinearFog(pos);\n\t#elif CC_USE_FOG == 1\n return ExpFog(pos);\n #elif CC_USE_FOG == 2\n return ExpSquaredFog(pos);\n #elif CC_USE_FOG == 3\n return LayeredFog(pos);\n #endif\n return 1.;\n}\nvarying highp vec4 v_shadowPos;\nuniform highp mat4 cc_matLightViewProj;\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nvarying highp vec3 v_position;\nvarying mediump vec3 v_normal;\n#if USE_NORMALMAP\n varying mediump vec3 v_tangent;\n varying mediump vec3 v_binormal;\n#endif\nvarying mediump vec2 uvw;\nvarying mediump vec2 uv0;\nvarying mediump vec2 uv1;\nvarying mediump vec2 uv2;\nvarying mediump vec2 uv3;\nvarying mediump vec2 luv;\nvarying mediump vec3 diffuse;\nvarying mediump float v_fog_factor;\nuniform vec4 UVScale;\nuniform vec4 lightMapUVParam;\nvec4 vert () {\n vec3 worldPos;\n worldPos.x = cc_matWorld[3][0] + a_position.x;\n worldPos.y = cc_matWorld[3][1] + a_position.y;\n worldPos.z = cc_matWorld[3][2] + a_position.z;\n vec4 pos = vec4(worldPos, 1.0);\n pos = cc_matViewProj * pos;\n uvw = a_texCoord;\n uv0 = a_position.xz * UVScale.x;\n uv1 = a_position.xz * UVScale.y;\n uv2 = a_position.xz * UVScale.z;\n uv3 = a_position.xz * UVScale.w;\n #if USE_LIGHTMAP\n luv = lightMapUVParam.xy + a_texCoord * lightMapUVParam.zw;\n #endif\n v_position = worldPos;\n v_normal = a_normal;\n v_fog_factor = CC_TRANSFER_FOG(vec4(worldPos, 1.0));\n #if USE_NORMALMAP\n v_tangent = vec3(1.0, 0.0, 0.0);\n v_binormal = vec3(0.0, 0.0, 1.0);\n v_binormal = cross(v_tangent, a_normal);\n v_tangent = cross(a_normal, v_binormal);\n #endif\n v_shadowPos = cc_matLightViewProj * vec4(worldPos, 1.0);\n return pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\n#ifdef GL_EXT_shader_texture_lod\n#extension GL_EXT_shader_texture_lod: enable\n#endif\nprecision highp float;\nuniform highp vec4 cc_cameraPos;\nuniform mediump vec4 cc_exposure;\nuniform mediump vec4 cc_mainLitDir;\nuniform mediump vec4 cc_mainLitColor;\nuniform mediump vec4 cc_ambientSky;\nuniform mediump vec4 cc_ambientGround;\nuniform mediump vec4 cc_fogColor;\nuniform lowp vec4 cc_shadowColor;\nuniform lowp vec4 cc_shadowInfo;\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\nvec3 unpackRGBE (vec4 rgbe) {\n return rgbe.rgb * pow(2.0, rgbe.a * 255.0 - 128.0);\n}\nvec4 fragTextureLod (sampler2D tex, vec2 coord, float lod) {\n #ifdef GL_EXT_shader_texture_lod\n return texture2DLodEXT(tex, coord, lod);\n #else\n return texture2D(tex, coord, lod);\n #endif\n}\nvec4 fragTextureLod (samplerCube tex, vec3 coord, float lod) {\n #ifdef GL_EXT_shader_texture_lod\n return textureCubeLodEXT(tex, coord, lod);\n #else\n return textureCube(tex, coord, lod);\n #endif\n}\n#endif\n#if CC_RECEIVE_SHADOW\nvarying highp vec4 v_shadowPos;\n#if CC_RECEIVE_SHADOW\n uniform sampler2D cc_shadowMap;\n uniform sampler2D cc_spotLightingMap;\n float CCGetShadowFactorX1 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float closestDepth = dot(texture2D(cc_shadowMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n float shadow = step(closestDepth, clipPos.z - cc_shadowInfo.w);\n return shadow;\n }\n float CCGetShadowFactorX5 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n float closestDepth = 0.0;\n closestDepth = dot(texture2D(cc_shadowMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_shadowMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_shadowMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_shadowMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n return shadow / 5.0;\n }\n float CCGetShadowFactorX9 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -1; i <= 1; i++) {\n for (int j = -1; j <= 1; j++) {\n float closestDepth = dot(texture2D(cc_shadowMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 9.0;\n }\n float CCGetShadowFactorX25 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -2; i <= 2; i++) {\n for (int j = -2; j <= 2; j++) {\n float closestDepth = dot(texture2D(cc_shadowMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 25.0;\n }\n float CCGetDirLightShadowFactorX1 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float closestDepth = dot(texture2D(cc_spotLightingMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n float shadow = step(closestDepth, clipPos.z - cc_shadowInfo.w);\n return shadow;\n }\n float CCGetDirLightShadowFactorX5 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n float closestDepth = 0.0;\n closestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n return shadow / 5.0;\n }\n float CCGetDirLightShadowFactorX9 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -1; i <= 1; i++) {\n for (int j = -1; j <= 1; j++) {\n float closestDepth = dot(texture2D(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 9.0;\n }\n float CCGetDirLightShadowFactorX25 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -2; i <= 2; i++) {\n for (int j = -2; j <= 2; j++) {\n float closestDepth = dot(texture2D(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 25.0;\n }\n#endif\n#endif\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nfloat GGXMobile (float roughness, float NoH, vec3 H, vec3 N) {\n vec3 NxH = cross(N, H);\n float OneMinusNoHSqr = dot(NxH, NxH);\n float a = roughness * roughness;\n float n = NoH * a;\n float p = a / (OneMinusNoHSqr + n * n);\n return p * p;\n}\nfloat CalcSpecular (float roughness, float NoH, vec3 H, vec3 N) {\n return (roughness*0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox (vec3 specular, float roughness, float NoV) {\n const vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\n const vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\n vec4 r = roughness * c0 + c1;\n float a004 = min( r.x * r.x, exp2( -9.28 * NoV ) ) * r.x + r.y;\n vec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n AB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\n return specular * AB.x + AB.y;\n}\nstruct StandardSurface {\n vec4 albedo;\n vec3 position;\n vec3 normal;\n vec3 emissive;\n vec4 lightmap;\n float roughness;\n float metallic;\n float occlusion;\n};\n#if CC_FORWARD_ADD\nuniform highp vec4 cc_lightPos[1];\nuniform vec4 cc_lightColor[1];\nuniform vec4 cc_lightSizeRangeAngle[1];\nuniform vec4 cc_lightDir[1];\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\n float factor = distSqr * invSqrAttRadius;\n float smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\n return smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\n float attenuation = 1.0 / max(distSqr, 0.01*0.01);\n attenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\n return attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\n float cd = dot(litDir, L);\n float attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\n return (attenuation * attenuation);\n}\n vec4 CCStandardShading (StandardSurface s) {\n vec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\n vec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\n vec3 diffuseContrib = diffuse / 3.14159265359;\n vec3 N = normalize(s.normal);\n vec3 V = normalize(cc_cameraPos.xyz - s.position);\n float NV = max(abs(dot(N, V)), 0.001);\n specular = BRDFApprox(specular, s.roughness, NV);\n vec3 finalColor = vec3(0.0);\n for (int i = 0; i < 1; i++) {\n vec3 SLU = cc_lightPos[i].xyz - s.position;\n vec3 SL = normalize(SLU);\n vec3 SH = normalize(SL + V);\n float SNL = max(dot(N, SL), 0.001);\n float SNH = max(dot(N, SH), 0.0);\n float distSqr = dot(SLU, SLU);\n float litRadius = cc_lightSizeRangeAngle[i].x;\n float litRadiusSqr = litRadius * litRadius;\n float illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\n float attRadiusSqrInv = 1.0 / max(cc_lightSizeRangeAngle[i].y, 0.01);\n attRadiusSqrInv *= attRadiusSqrInv;\n float att = GetDistAtt(distSqr, attRadiusSqrInv);\n vec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\n if (cc_lightPos[i].w > 0.0) {\n float cosInner = max(dot(-cc_lightDir[i].xyz, SL), 0.01);\n float cosOuter = cc_lightSizeRangeAngle[i].z;\n float litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\n float litAngleOffset = -cosOuter * litAngleScale;\n att *= GetAngleAtt(SL, -cc_lightDir[i].xyz, litAngleScale, litAngleOffset);\n }\n vec3 lightColor = cc_lightColor[i].rgb;\n #if CC_RECEIVE_SHADOW\n if (cc_lightPos[i].w > 0.0) {\n {\n float pcf = cc_shadowInfo.z + 0.001;\n float shadowAttenuation = 0.0;\n if (pcf > 3.0) shadowAttenuation = CCGetDirLightShadowFactorX25();\n else if (3.0 > pcf && pcf > 2.0) shadowAttenuation = CCGetDirLightShadowFactorX9();\n else if (2.0 > pcf && pcf > 1.0) shadowAttenuation = CCGetDirLightShadowFactorX5();\n else shadowAttenuation = CCGetDirLightShadowFactorX1();\n lightColor *= 1.0 - shadowAttenuation;\n }\n }\n #endif\n finalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n }\n finalColor = finalColor * s.occlusion;\n return vec4(finalColor, 0.0);\n }\n#else\n vec4 CCStandardShading (StandardSurface s) {\n vec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\n vec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\n vec3 N = normalize(s.normal);\n vec3 V = normalize(cc_cameraPos.xyz - s.position);\n float NV = max(abs(dot(N, V)), 0.001);\n specular = BRDFApprox(specular, s.roughness, NV);\n vec3 L = normalize(-cc_mainLitDir.xyz);\n vec3 H = normalize(L+V);\n float NH = max(dot(N, H), 0.0);\n float NL = max(dot(N, L), 0.001);\n vec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w;\n #if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\n finalColor = s.lightmap.a * s.lightmap.rgb + (1.0 - s.lightmap.a) * finalColor;\n #endif\n vec3 diffuseContrib = diffuse / 3.14159265359;\n vec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\n finalColor *= (diffuseContrib + specularContrib);\n float fAmb = 0.5 - N.y * 0.5;\n vec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb) * cc_ambientSky.w;\n finalColor += (ambDiff.rgb * diffuse);\n #if CC_USE_IBL\n vec3 R = normalize(reflect(-V, N));\n vec4 envmap = fragTextureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n #if CC_USE_IBL == 2\n vec3 env = unpackRGBE(envmap);\n #else\n vec3 env = SRGBToLinear(envmap.rgb);\n #endif\n finalColor += env * cc_ambientSky.w * specular;\n #endif\n finalColor = finalColor * s.occlusion;\n #if CC_USE_HDR\n s.emissive *= cc_exposure.w;\n #endif\n finalColor += s.emissive;\n #if CC_RECEIVE_SHADOW\n {\n float pcf = cc_shadowInfo.z + 0.001;\n float shadowAttenuation = 0.0;\n if (pcf > 3.0) shadowAttenuation = CCGetShadowFactorX25();\n else if (3.0 > pcf && pcf > 2.0) shadowAttenuation = CCGetShadowFactorX9();\n else if (2.0 > pcf && pcf > 1.0) shadowAttenuation = CCGetShadowFactorX5();\n else shadowAttenuation = CCGetShadowFactorX1();\n vec3 shadowColor = cc_shadowColor.rgb * cc_shadowColor.a + finalColor.rgb * (1.0 - cc_shadowColor.a);\n finalColor.rgb = shadowColor.rgb * shadowAttenuation * NL + finalColor.rgb * (1.0 - shadowAttenuation * NL);\n }\n #endif\n return vec4(finalColor, s.albedo.a);\n }\n#endif\nvec3 ACESToneMap (vec3 color) {\n color = min(color, vec3(8.0));\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n #if !CC_USE_HDR\n color.rgb = sqrt(ACESToneMap(color.rgb));\n #endif\n return color;\n}\nvarying highp vec3 v_position;\nvarying mediump vec3 v_normal;\n#if USE_NORMALMAP\n varying mediump vec3 v_tangent;\n varying mediump vec3 v_binormal;\n#endif\nvarying mediump vec2 uvw;\nvarying mediump vec2 uv0;\nvarying mediump vec2 uv1;\nvarying mediump vec2 uv2;\nvarying mediump vec2 uv3;\nvarying mediump vec3 diffuse;\nvarying mediump vec2 luv;\nvarying mediump float v_fog_factor;\nuniform vec4 metallic;\nuniform vec4 roughness;\nuniform sampler2D weightMap;\nuniform sampler2D detailMap0;\nuniform sampler2D detailMap1;\nuniform sampler2D detailMap2;\nuniform sampler2D detailMap3;\nuniform sampler2D normalMap0;\nuniform sampler2D normalMap1;\nuniform sampler2D normalMap2;\nuniform sampler2D normalMap3;\nuniform sampler2D lightMap;\nvoid surf (out StandardSurface s) {\n #if LAYERS > 1\n vec4 w = texture2D(weightMap, uvw);\n #endif\n vec4 baseColor = vec4(0, 0, 0, 0);\n #if LAYERS == 1\n baseColor = texture2D(detailMap0, uv0);\n #elif LAYERS == 2\n baseColor += texture2D(detailMap0, uv0) * w.r;\n baseColor += texture2D(detailMap1, uv1) * w.g;\n #elif LAYERS == 3\n baseColor += texture2D(detailMap0, uv0) * w.r;\n baseColor += texture2D(detailMap1, uv1) * w.g;\n baseColor += texture2D(detailMap2, uv2) * w.b;\n #elif LAYERS == 4\n baseColor += texture2D(detailMap0, uv0) * w.r;\n baseColor += texture2D(detailMap1, uv1) * w.g;\n baseColor += texture2D(detailMap2, uv2) * w.b;\n baseColor += texture2D(detailMap3, uv3) * w.a;\n #else\n baseColor = texture2D(detailMap0, uv0);\n #endif\n s.position = v_position;\n #if USE_NORMALMAP\n vec4 baseNormal = vec4(0, 0, 0, 0);\n #if LAYERS == 1\n baseNormal = texture2D(normalMap0, uv0);\n #elif LAYERS == 2\n baseNormal += texture2D(normalMap0, uv0) * w.r;\n baseNormal += texture2D(normalMap1, uv1) * w.g;\n #elif LAYERS == 3\n baseNormal += texture2D(normalMap0, uv0) * w.r;\n baseNormal += texture2D(normalMap1, uv1) * w.g;\n baseNormal += texture2D(normalMap2, uv2) * w.b;\n #elif LAYERS == 4\n baseNormal += texture2D(normalMap0, uv0) * w.r;\n baseNormal += texture2D(normalMap1, uv1) * w.g;\n baseNormal += texture2D(normalMap2, uv2) * w.b;\n baseNormal += texture2D(normalMap3, uv3) * w.a;\n #else\n baseNormal = texture2D(normalMap0, uv0);\n #endif\n vec3 nmmp = baseNormal.xyz - vec3(0.5);\n s.normal =\n nmmp.x * normalize(v_tangent) +\n nmmp.y * normalize(v_binormal) +\n nmmp.z * normalize(v_normal);\n #else\n s.normal = v_normal;\n #endif\n s.albedo = vec4(SRGBToLinear(baseColor.rgb), 1.0);\n s.occlusion = 1.0;\n #if USE_PBR\n s.roughness = 0.0;\n #if LAYERS == 1\n s.roughness = roughness.x;\n #elif LAYERS == 2\n s.roughness += roughness.x * w.r;\n s.roughness += roughness.y * w.g;\n #elif LAYERS == 3\n s.roughness += roughness.x * w.r;\n s.roughness += roughness.y * w.g;\n s.roughness += roughness.z * w.b;\n #elif LAYERS == 4\n s.roughness += roughness.x * w.r;\n s.roughness += roughness.y * w.g;\n s.roughness += roughness.z * w.b;\n s.roughness += roughness.w * w.a;\n #else\n s.roughness = 1.0;\n #endif\n s.metallic = 0.0;\n #if LAYERS == 1\n s.metallic = metallic.x;\n #elif LAYERS == 2\n s.metallic += metallic.x * w.r;\n s.metallic += metallic.y * w.g;\n #elif LAYERS == 3\n s.metallic += metallic.x * w.r;\n s.metallic += metallic.y * w.g;\n s.metallic += metallic.z * w.b;\n #elif LAYERS == 4\n s.metallic += metallic.x * w.r;\n s.metallic += metallic.y * w.g;\n s.metallic += metallic.z * w.b;\n s.metallic += metallic.w * w.a;\n #else\n s.metallic = 0.0;\n #endif\n #else\n s.roughness = 1.0;\n s.metallic = 0.0;\n #endif\n s.emissive = vec3(0.0, 0.0, 0.0);\n #if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\n s.lightmap = texture2D(lightMap, luv);\n #else\n s.lightmap = vec4(0.0, 0.0, 0.0, 0.0);\n #endif\n}\nvec4 frag () {\n StandardSurface s; surf(s);\n vec4 color = CCStandardShading(s);\n color = vec4(mix(CC_FORWARD_ADD > 0 ? vec3(0.0) : cc_fogColor.rgb, color.rgb, v_fog_factor), color.a);\n return CCFragOutput(color);\n}\nvoid main() { gl_FragColor = frag(); }"},{vert:"\nprecision highp float;\nuniform highp mat4 cc_matWorld;\nuniform highp mat4 cc_matLightViewProj;\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nvarying vec2 v_clip_depth;\nvec4 vert () {\n vec4 worldPos;\n worldPos.x = cc_matWorld[3][0] + a_position.x;\n worldPos.y = cc_matWorld[3][1] + a_position.y;\n worldPos.z = cc_matWorld[3][2] + a_position.z;\n worldPos.w = 1.0;\n vec4 clipPos = cc_matLightViewProj * worldPos;\n v_clip_depth = clipPos.zw;\n return clipPos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nvec4 packDepthToRGBA (float depth) {\n vec4 ret = vec4(1.0, 255.0, 65025.0, 160581375.0) * depth;\n ret = fract(ret);\n ret -= ret.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n return ret;\n}\nvarying vec2 v_clip_depth;\nvec4 frag () {\n return packDepthToRGBA(v_clip_depth.x / v_clip_depth.y * 0.5 + 0.5);\n}\nvoid main() { gl_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\n rgba = rgba * 255.0;\n highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\n highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\n highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\n highp vec4 position;\n vec3 normal;\n vec4 tangent;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nattribute vec4 a_tangent;\n#if CC_USE_MORPH\n attribute float a_vertexId;\n int getVertexId() {\n return int(a_vertexId);\n }\nuniform vec4 cc_displacementWeights[15];\nuniform vec4 cc_displacementTextureInfo;\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\n float pixelIndexF = float(pixelIndex);\n float x = mod(pixelIndexF, textureResolution.x);\n float y = floor(pixelIndexF / textureResolution.x);\n return vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\n return (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_SUPPORT_FLOAT_TEXTURE\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 uv = getPixelCoordFromLocation(location, cc_displacementTextureInfo.xy);\n return texture2D(tex, uv);\n }\n#else\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex * 4;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\n return vec4(\n decode32(texture2D(tex, x)),\n decode32(texture2D(tex, y)),\n decode32(texture2D(tex, z)),\n 1.0\n );\n }\n#endif\nfloat getDisplacementWeight(int index) {\n int quot = index / 4;\n int remainder = index - quot * 4;\n if (remainder == 0) {\n return cc_displacementWeights[quot].x;\n } else if (remainder == 1) {\n return cc_displacementWeights[quot].y;\n } else if (remainder == 2) {\n return cc_displacementWeights[quot].z;\n } else {\n return cc_displacementWeights[quot].w;\n }\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\n return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\n vec3 result = vec3(0, 0, 0);\n int nVertices = int(cc_displacementTextureInfo.z);\n for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\n result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n }\n return result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\n uniform sampler2D cc_PositionDisplacements;\n vec3 getPositionDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n uniform sampler2D cc_NormalDisplacements;\n vec3 getNormalDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n uniform sampler2D cc_TangentDisplacements;\n vec3 getTangentDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n }\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\n int vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\n attr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n attr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n attr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\n attribute vec4 a_joints;\nattribute vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n #if USE_INSTANCING\n attribute highp vec4 a_jointAnimInfo;\n #endif\n uniform highp vec4 cc_jointTextureInfo;\n uniform highp vec4 cc_jointAnimInfo;\n uniform highp sampler2D cc_jointTexture;\n #else\n uniform highp vec4 cc_joints[90];\n#endif\n#if CC_USE_BAKED_ANIMATION\n #if CC_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y));\n vec4 v2 = texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y));\n vec4 v3 = texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n );\n vec4 v2 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n );\n vec4 v3 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n#else\n mat4 getJointMatrix (float i) {\n int idx = int(i);\n vec4 v1 = cc_joints[idx * 3];\n vec4 v2 = cc_joints[idx * 3 + 1];\n vec4 v3 = cc_joints[idx * 3 + 2];\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n#endif\nmat4 skinMatrix () {\n vec4 joints = vec4(a_joints);\n return getJointMatrix(joints.x) * a_weights.x\n + getJointMatrix(joints.y) * a_weights.y\n + getJointMatrix(joints.z) * a_weights.z\n + getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\n mat4 m = skinMatrix();\n position = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\n mat4 m = skinMatrix();\n attr.position = m * attr.position;\n attr.normal = (m * vec4(attr.normal, 0.0)).xyz;\n attr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nuniform highp mat4 cc_matView;\nuniform highp mat4 cc_matProj;\nuniform highp vec4 cc_cameraPos;\nuniform mediump vec4 cc_fogBase;\nuniform mediump vec4 cc_fogAdd;\n#if USE_INSTANCING\n attribute vec4 a_matWorld0;\n attribute vec4 a_matWorld1;\n attribute vec4 a_matWorld2;\n #if USE_LIGHTMAP\n attribute vec4 a_lightingMapUVParam;\n #endif\n#elif USE_BATCHING\n attribute float a_dyn_batch_id;\n uniform highp mat4 cc_matWorlds[10];\n#else\nuniform highp mat4 cc_matWorld;\n#endif\nfloat LinearFog(vec4 pos) {\n vec4 wPos = pos;\n float cam_dis = distance(cc_cameraPos, wPos);\n float fogStart = cc_fogBase.x;\n float fogEnd = cc_fogBase.y;\n return clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float fogDensity = cc_fogBase.z;\n float cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\n float f = exp(-cam_dis * fogDensity);\n return f;\n}\nfloat ExpSquaredFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float fogDensity = cc_fogBase.z;\n float cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\n float f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\n return f;\n}\nfloat LayeredFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float _FogTop = cc_fogAdd.x;\n float _FogRange = cc_fogAdd.y;\n vec3 camWorldProj = cc_cameraPos.xyz;\n camWorldProj.y = 0.;\n vec3 worldPosProj = wPos.xyz;\n worldPosProj.y = 0.;\n float fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\n float fDeltaY, fDensityIntegral;\n if (cc_cameraPos.y > _FogTop) {\n if (wPos.y < _FogTop) {\n fDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\n fDensityIntegral = fDeltaY * fDeltaY * 0.5;\n } else {\n fDeltaY = 0.;\n fDensityIntegral = 0.;\n }\n } else {\n if (wPos.y < _FogTop) {\n float fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\n float fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\n fDeltaY = abs(fDeltaA - fDeltaB);\n fDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n } else {\n fDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\n fDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n }\n }\n float fDensity;\n if (fDeltaY != 0.) {\n fDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n } else {\n fDensity = 0.;\n }\n float f = exp(-fDensity);\n return f;\n}\nfloat CC_TRANSFER_FOG(vec4 pos) {\n #if CC_USE_FOG == 0\n return LinearFog(pos);\n\t#elif CC_USE_FOG == 1\n return ExpFog(pos);\n #elif CC_USE_FOG == 2\n return ExpSquaredFog(pos);\n #elif CC_USE_FOG == 3\n return LayeredFog(pos);\n #endif\n return 1.;\n}\n#if USE_VERTEX_COLOR\n attribute lowp vec4 a_color;\n varying lowp vec4 v_color;\n#endif\n#if USE_TEXTURE\n varying vec2 v_uv;\n uniform vec4 tilingOffset;\n#endif\nvarying float factor_fog;\nvec4 vert () {\n vec4 position;\n position = vec4(a_position, 1.0);\n #if CC_USE_MORPH\n applyMorph(position);\n #endif\n #if CC_USE_SKINNING\n CCSkin(position);\n #endif\n mat4 matWorld;\n #if USE_INSTANCING\n matWorld = mat4(\n vec4(a_matWorld0.xyz, 0.0),\n vec4(a_matWorld1.xyz, 0.0),\n vec4(a_matWorld2.xyz, 0.0),\n vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n );\n #elif USE_BATCHING\n matWorld = cc_matWorlds[int(a_dyn_batch_id)];\n #else\n matWorld = cc_matWorld;\n #endif\n #if USE_TEXTURE\n v_uv = a_texCoord * tilingOffset.xy + tilingOffset.zw;\n #endif\n #if USE_VERTEX_COLOR\n v_color = a_color;\n #endif\n factor_fog = CC_TRANSFER_FOG(matWorld * position);\n return cc_matProj * (cc_matView * matWorld) * position;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nuniform mediump vec4 cc_exposure;\nuniform mediump vec4 cc_fogColor;\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n #if CC_USE_HDR\n color.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n #endif\n return color;\n}\n#if USE_ALPHA_TEST\n#endif\n#if USE_TEXTURE\n varying vec2 v_uv;\n uniform sampler2D mainTexture;\n#endif\nuniform vec4 mainColor;\nuniform vec4 colorScaleAndCutoff;\n#if USE_VERTEX_COLOR\n varying lowp vec4 v_color;\n#endif\nvarying float factor_fog;\nvec4 frag () {\n vec4 o = mainColor;\n o.rgb *= colorScaleAndCutoff.xyz;\n #if USE_VERTEX_COLOR\n o *= v_color;\n #endif\n #if USE_TEXTURE\n o *= texture2D(mainTexture, v_uv);\n #endif\n #if USE_ALPHA_TEST\n if (o.ALPHA_TEST_CHANNEL < colorScaleAndCutoff.w) discard;\n #endif\n o = vec4(mix(CC_FORWARD_ADD > 0 ? vec3(0.0) : cc_fogColor.rgb, o.rgb, factor_fog), o.a);\n return CCFragOutput(o);\n}\nvoid main() { gl_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\n rgba = rgba * 255.0;\n highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\n highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\n highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\n highp vec4 position;\n vec3 normal;\n vec4 tangent;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nattribute vec4 a_tangent;\n#if CC_USE_MORPH\n attribute float a_vertexId;\n int getVertexId() {\n return int(a_vertexId);\n }\nuniform vec4 cc_displacementWeights[15];\nuniform vec4 cc_displacementTextureInfo;\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\n float pixelIndexF = float(pixelIndex);\n float x = mod(pixelIndexF, textureResolution.x);\n float y = floor(pixelIndexF / textureResolution.x);\n return vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\n return (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_SUPPORT_FLOAT_TEXTURE\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 uv = getPixelCoordFromLocation(location, cc_displacementTextureInfo.xy);\n return texture2D(tex, uv);\n }\n#else\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex * 4;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\n return vec4(\n decode32(texture2D(tex, x)),\n decode32(texture2D(tex, y)),\n decode32(texture2D(tex, z)),\n 1.0\n );\n }\n#endif\nfloat getDisplacementWeight(int index) {\n int quot = index / 4;\n int remainder = index - quot * 4;\n if (remainder == 0) {\n return cc_displacementWeights[quot].x;\n } else if (remainder == 1) {\n return cc_displacementWeights[quot].y;\n } else if (remainder == 2) {\n return cc_displacementWeights[quot].z;\n } else {\n return cc_displacementWeights[quot].w;\n }\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\n return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\n vec3 result = vec3(0, 0, 0);\n int nVertices = int(cc_displacementTextureInfo.z);\n for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\n result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n }\n return result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\n uniform sampler2D cc_PositionDisplacements;\n vec3 getPositionDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n uniform sampler2D cc_NormalDisplacements;\n vec3 getNormalDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n uniform sampler2D cc_TangentDisplacements;\n vec3 getTangentDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n }\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\n int vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\n attr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n attr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n attr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\n attribute vec4 a_joints;\nattribute vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n #if USE_INSTANCING\n attribute highp vec4 a_jointAnimInfo;\n #endif\n uniform highp vec4 cc_jointTextureInfo;\n uniform highp vec4 cc_jointAnimInfo;\n uniform highp sampler2D cc_jointTexture;\n #else\n uniform highp vec4 cc_joints[90];\n#endif\n#if CC_USE_BAKED_ANIMATION\n #if CC_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y));\n vec4 v2 = texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y));\n vec4 v3 = texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n );\n vec4 v2 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n );\n vec4 v3 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n#else\n mat4 getJointMatrix (float i) {\n int idx = int(i);\n vec4 v1 = cc_joints[idx * 3];\n vec4 v2 = cc_joints[idx * 3 + 1];\n vec4 v3 = cc_joints[idx * 3 + 2];\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n#endif\nmat4 skinMatrix () {\n vec4 joints = vec4(a_joints);\n return getJointMatrix(joints.x) * a_weights.x\n + getJointMatrix(joints.y) * a_weights.y\n + getJointMatrix(joints.z) * a_weights.z\n + getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\n mat4 m = skinMatrix();\n position = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\n mat4 m = skinMatrix();\n attr.position = m * attr.position;\n attr.normal = (m * vec4(attr.normal, 0.0)).xyz;\n attr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nuniform highp mat4 cc_matView;\nuniform highp mat4 cc_matProj;\n#if USE_INSTANCING\n attribute vec4 a_matWorld0;\n attribute vec4 a_matWorld1;\n attribute vec4 a_matWorld2;\n #if USE_LIGHTMAP\n attribute vec4 a_lightingMapUVParam;\n #endif\n#elif USE_BATCHING\n attribute float a_dyn_batch_id;\n uniform highp mat4 cc_matWorlds[10];\n#else\nuniform highp mat4 cc_matWorld;\n#endif\nuniform highp mat4 cc_matLightPlaneProj;\nvec4 vert () {\n vec4 position;\n position = vec4(a_position, 1.0);\n #if CC_USE_MORPH\n applyMorph(position);\n #endif\n #if CC_USE_SKINNING\n CCSkin(position);\n #endif\n mat4 matWorld;\n #if USE_INSTANCING\n matWorld = mat4(\n vec4(a_matWorld0.xyz, 0.0),\n vec4(a_matWorld1.xyz, 0.0),\n vec4(a_matWorld2.xyz, 0.0),\n vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n );\n #elif USE_BATCHING\n matWorld = cc_matWorlds[int(a_dyn_batch_id)];\n #else\n matWorld = cc_matWorld;\n #endif\n position = cc_matProj * (cc_matView * cc_matLightPlaneProj * matWorld) * position;\n position.z -= 0.0001;\n return position;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision mediump float;\nuniform lowp vec4 cc_shadowColor;\nuniform mediump vec4 cc_exposure;\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n #if CC_USE_HDR\n color.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n #endif\n return color;\n}\nvec4 frag () {\n return CCFragOutput(cc_shadowColor);\n}\nvoid main() { gl_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nuniform highp mat4 cc_matView;\nuniform highp mat4 cc_matProj;\nstruct StandardVertInput {\n highp vec4 position;\n vec3 normal;\n vec4 tangent;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nattribute vec4 a_tangent;\nvarying mediump vec4 viewDir;\nvec4 vert () {\n viewDir = vec4(a_position, 1.0);\n mat4 matViewRotOnly = mat4(mat3(cc_matView));\n mat4 matProj = cc_matProj;\n if (matProj[3].w > 0.0) {\n vec2 scale = vec2(48.0, 24.0);\n matProj[0].xy *= scale;\n matProj[1].xy *= scale;\n matProj[2].zw = vec2(-1.0);\n matProj[3].zw = vec2(0.0);\n }\n vec4 pos = matProj * matViewRotOnly * viewDir;\n pos.z = 0.99999 * pos.w;\n return pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision mediump float;\nuniform mediump vec4 cc_ambientSky;\nuniform samplerCube cc_environment;\nvec3 unpackRGBE (vec4 rgbe) {\n return rgbe.rgb * pow(2.0, rgbe.a * 255.0 - 128.0);\n}\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec3 ACESToneMap (vec3 color) {\n color = min(color, vec3(8.0));\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n #if !CC_USE_HDR\n color.rgb = sqrt(ACESToneMap(color.rgb));\n #endif\n return color;\n}\nvarying mediump vec4 viewDir;\nvec4 frag () {\n #if USE_RGBE_CUBEMAP\n vec3 c = unpackRGBE(textureCube(cc_environment, viewDir.xyz));\n #else\n vec3 c = SRGBToLinear(textureCube(cc_environment, viewDir.xyz).rgb);\n #endif\n return CCFragOutput(vec4(c * cc_ambientSky.w, 1.0));\n}\nvoid main() { gl_FragColor = frag(); }"}],[{vert:"\nprecision mediump float;\nuniform highp mat4 cc_matViewProj;\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec2 v_uv;\nuniform vec4 offset;\nuniform vec4 digits[20];\nfloat getComponent(vec4 v, float i) {\n if (i < 1.0) { return v.x; }\n else if (i < 2.0) { return v.y; }\n else if (i < 3.0) { return v.z; }\n else { return v.w; }\n}\nvec4 vert () {\n vec4 position = cc_matViewProj * vec4(a_position, 1.0);\n position.xy += offset.xy;\n v_uv = a_color.xy;\n if (a_color.z >= 0.0) {\n float n = getComponent(digits[int(a_color.z)], a_color.w);\n v_uv += vec2(offset.z * n, 0.0);\n }\n return position;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision mediump float;\nuniform mediump vec4 cc_exposure;\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n #if CC_USE_HDR\n color.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n #endif\n return color;\n}\nvarying vec2 v_uv;\nuniform sampler2D mainTexture;\nvec4 frag () {\n return CCFragOutput(texture2D(mainTexture, v_uv));\n}\nvoid main() { gl_FragColor = frag(); }"}],[{vert:"\nprecision mediump float;\nattribute vec2 a_position;\nattribute vec2 a_texCoord;\nvarying vec2 v_uv;\nvec4 vert () {\n vec4 pos = vec4(a_position, 0, 1);\n v_uv = a_texCoord;\n return pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision mediump float;\nvarying vec2 v_uv;\nuniform sampler2D mainTexture;\nuniform float u_precent;\nvec4 frag () {\n vec4 color = texture2D(mainTexture, v_uv);\n float precent = clamp(u_precent, 0.0, 1.0);\n color.xyz *= precent;\n return color;\n}\nvoid main() { gl_FragColor = frag(); }"}]],glsl3:[[{vert:"\nprecision mediump float;\nlayout(std140) uniform Constants {\n vec4 mainTiling_Offset;\n vec4 frameTile_velLenScale;\n vec4 scale;\n};\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nlayout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n};\nvec4 quaternionFromAxis (vec3 xAxis,vec3 yAxis,vec3 zAxis){\n mat3 m = mat3(xAxis,yAxis,zAxis);\n float trace = m[0][0] + m[1][1] + m[2][2];\n vec4 quat;\n if (trace > 0.) {\n float s = 0.5 / sqrt(trace + 1.0);\n quat.w = 0.25 / s;\n quat.x = (m[2][1] - m[1][2]) * s;\n quat.y = (m[0][2] - m[2][0]) * s;\n quat.z = (m[1][0] - m[0][1]) * s;\n } else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\n float s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\n quat.w = (m[2][1] - m[1][2]) / s;\n quat.x = 0.25 * s;\n quat.y = (m[0][1] + m[1][0]) / s;\n quat.z = (m[0][2] + m[2][0]) / s;\n } else if (m[1][1] > m[2][2]) {\n float s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\n quat.w = (m[0][2] - m[2][0]) / s;\n quat.x = (m[0][1] + m[1][0]) / s;\n quat.y = 0.25 * s;\n quat.z = (m[1][2] + m[2][1]) / s;\n } else {\n float s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\n quat.w = (m[1][0] - m[0][1]) / s;\n quat.x = (m[0][2] + m[2][0]) / s;\n quat.y = (m[1][2] + m[2][1]) / s;\n quat.z = 0.25 * s;\n }\n float len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\n if (len > 0.) {\n len = 1. / sqrt(len);\n quat.x = quat.x * len;\n quat.y = quat.y * len;\n quat.z = quat.z * len;\n quat.w = quat.w * len;\n }\n return quat;\n}\nvec4 quaternionFromEuler (vec3 angle){\n float x = angle.x / 2.;\n float y = angle.y / 2.;\n float z = angle.z / 2.;\n float sx = sin(x);\n float cx = cos(x);\n float sy = sin(y);\n float cy = cos(y);\n float sz = sin(z);\n float cz = cos(z);\n vec4 quat = vec4(0);\n quat.x = sx * cy * cz + cx * sy * sz;\n quat.y = cx * sy * cz + sx * cy * sz;\n quat.z = cx * cy * sz - sx * sy * cz;\n quat.w = cx * cy * cz - sx * sy * sz;\n return quat;\n}\nvec4 quatMultiply (vec4 a, vec4 b){\n vec4 quat;\n quat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\n quat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\n quat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\n quat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\n return quat;\n}\nvoid rotateVecFromQuat (inout vec3 v, vec4 q){\n float ix = q.w * v.x + q.y * v.z - q.z * v.y;\n float iy = q.w * v.y + q.z * v.x - q.x * v.z;\n float iz = q.w * v.z + q.x * v.y - q.y * v.x;\n float iw = -q.x * v.x - q.y * v.y - q.z * v.z;\n v.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\n v.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\n v.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace (vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\n vec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\n vec4 rotQuat = quatMultiply(viewQuat, q);\n rotateVecFromQuat(pos, rotQuat);\n return pos;\n}\nvoid rotateCorner (inout vec2 corner, float angle){\n float xOS = cos(angle) * corner.x - sin(angle) * corner.y;\n float yOS = sin(angle) * corner.x + cos(angle) * corner.y;\n corner.x = xOS;\n corner.y = yOS;\n}\nout mediump vec2 uv;\nout mediump vec4 color;\nvoid computeVertPos (inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n , mat4 viewInv\n) {\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\n vec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\n vec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n}\nin vec3 a_position;\nin vec2 a_texCoord;\nin vec4 a_color;\nlayout(std140) uniform builtin {\n vec4 cc_size_rotation;\n};\nvec4 vs_main() {\n vec4 pos = vec4(a_position, 1);\n pos = cc_matWorld * pos;\n vec2 vertOffset = a_texCoord.xy - 0.5;\n computeVertPos(pos, vertOffset, quaternionFromEuler(vec3(0., 0., cc_size_rotation.z)), vec3(cc_size_rotation.xy, 0.), cc_matViewInv);\n pos = cc_matViewProj * pos;\n uv = a_texCoord.xy;\n color = a_color;\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }",frag:"\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n #if CC_USE_HDR\n color.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n #endif\n return color;\n}\nin vec2 uv;\nin vec4 color;\nuniform sampler2D mainTexture;\nlayout(std140) uniform FragConstants {\n vec4 tintColor;\n};\nvec4 add () {\n vec4 col = 2.0 * color * tintColor * texture(mainTexture, uv);\n return CCFragOutput(col);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = add(); }"}],[{vert:"\nprecision highp float;\nin vec3 a_position;\nvec4 vert () {\n vec4 pos = vec4(a_position, 1);\n return pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nvec4 frag () {\n vec4 o = vec4(1.0);\n return o;\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nlayout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n};\nin vec3 a_position;\nin vec4 a_color;\nout vec4 v_color;\nin float a_dist;\nout float v_dist;\nvec4 vert () {\n vec4 pos = vec4(a_position, 1);\n pos = cc_matViewProj * cc_matWorld * pos;\n v_color = a_color;\n v_dist = a_dist;\n return pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nin vec4 v_color;\nin float v_dist;\nvec4 frag () {\n vec4 o = v_color;\n float aa = fwidth(v_dist);\n float alpha = 1. - smoothstep(-aa, 0., abs(v_dist) - 1.0);\n o.rgb *= o.a;\n o *= alpha;\n return o;\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}],[{vert:"\nprecision mediump float;\nvec4 quaternionFromAxis (vec3 xAxis,vec3 yAxis,vec3 zAxis){\n mat3 m = mat3(xAxis,yAxis,zAxis);\n float trace = m[0][0] + m[1][1] + m[2][2];\n vec4 quat;\n if (trace > 0.) {\n float s = 0.5 / sqrt(trace + 1.0);\n quat.w = 0.25 / s;\n quat.x = (m[2][1] - m[1][2]) * s;\n quat.y = (m[0][2] - m[2][0]) * s;\n quat.z = (m[1][0] - m[0][1]) * s;\n } else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\n float s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\n quat.w = (m[2][1] - m[1][2]) / s;\n quat.x = 0.25 * s;\n quat.y = (m[0][1] + m[1][0]) / s;\n quat.z = (m[0][2] + m[2][0]) / s;\n } else if (m[1][1] > m[2][2]) {\n float s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\n quat.w = (m[0][2] - m[2][0]) / s;\n quat.x = (m[0][1] + m[1][0]) / s;\n quat.y = 0.25 * s;\n quat.z = (m[1][2] + m[2][1]) / s;\n } else {\n float s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\n quat.w = (m[1][0] - m[0][1]) / s;\n quat.x = (m[0][2] + m[2][0]) / s;\n quat.y = (m[1][2] + m[2][1]) / s;\n quat.z = 0.25 * s;\n }\n float len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\n if (len > 0.) {\n len = 1. / sqrt(len);\n quat.x = quat.x * len;\n quat.y = quat.y * len;\n quat.z = quat.z * len;\n quat.w = quat.w * len;\n }\n return quat;\n}\nvec4 quaternionFromEuler (vec3 angle){\n float x = angle.x / 2.;\n float y = angle.y / 2.;\n float z = angle.z / 2.;\n float sx = sin(x);\n float cx = cos(x);\n float sy = sin(y);\n float cy = cos(y);\n float sz = sin(z);\n float cz = cos(z);\n vec4 quat = vec4(0);\n quat.x = sx * cy * cz + cx * sy * sz;\n quat.y = cx * sy * cz + sx * cy * sz;\n quat.z = cx * cy * sz - sx * sy * cz;\n quat.w = cx * cy * cz - sx * sy * sz;\n return quat;\n}\nmat4 matrixFromRT (vec4 q, vec3 p){\n float x2 = q.x + q.x;\n float y2 = q.y + q.y;\n float z2 = q.z + q.z;\n float xx = q.x * x2;\n float xy = q.x * y2;\n float xz = q.x * z2;\n float yy = q.y * y2;\n float yz = q.y * z2;\n float zz = q.z * z2;\n float wx = q.w * x2;\n float wy = q.w * y2;\n float wz = q.w * z2;\n return mat4(\n 1. - (yy + zz), xy + wz, xz - wy, 0,\n xy - wz, 1. - (xx + zz), yz + wx, 0,\n xz + wy, yz - wx, 1. - (xx + yy), 0,\n p.x, p.y, p.z, 1\n );\n}\nmat4 matFromRTS (vec4 q, vec3 t, vec3 s){\n float x = q.x, y = q.y, z = q.z, w = q.w;\n float x2 = x + x;\n float y2 = y + y;\n float z2 = z + z;\n float xx = x * x2;\n float xy = x * y2;\n float xz = x * z2;\n float yy = y * y2;\n float yz = y * z2;\n float zz = z * z2;\n float wx = w * x2;\n float wy = w * y2;\n float wz = w * z2;\n float sx = s.x;\n float sy = s.y;\n float sz = s.z;\n return mat4((1. - (yy + zz)) * sx, (xy + wz) * sx, (xz - wy) * sx, 0,\n (xy - wz) * sy, (1. - (xx + zz)) * sy, (yz + wx) * sy, 0,\n (xz + wy) * sz, (yz - wx) * sz, (1. - (xx + yy)) * sz, 0,\n t.x, t.y, t.z, 1);\n}\nvec4 quatMultiply (vec4 a, vec4 b){\n vec4 quat;\n quat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\n quat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\n quat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\n quat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\n return quat;\n}\nvoid rotateVecFromQuat (inout vec3 v, vec4 q){\n float ix = q.w * v.x + q.y * v.z - q.z * v.y;\n float iy = q.w * v.y + q.z * v.x - q.x * v.z;\n float iz = q.w * v.z + q.x * v.y - q.y * v.x;\n float iw = -q.x * v.x - q.y * v.y - q.z * v.z;\n v.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\n v.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\n v.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace (vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\n vec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\n vec4 rotQuat = quatMultiply(viewQuat, q);\n rotateVecFromQuat(pos, rotQuat);\n return pos;\n}\nvoid rotateCorner (inout vec2 corner, float angle){\n float xOS = cos(angle) * corner.x - sin(angle) * corner.y;\n float yOS = sin(angle) * corner.x + cos(angle) * corner.y;\n corner.x = xOS;\n corner.y = yOS;\n}\nlayout(std140) uniform Constants {\n vec4 mainTiling_Offset;\n vec4 frameTile_velLenScale;\n vec4 scale;\n};\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nlayout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n};\nout mediump vec2 uv;\nout mediump vec4 color;\nvoid computeVertPos (inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n#if CC_RENDER_MODE == 0 || CC_RENDER_MODE == 3\n , mat4 viewInv\n#endif\n#if CC_RENDER_MODE == 1\n , vec3 eye\n , vec4 velocity\n , float velocityScale\n , float lengthScale\n , float xIndex\n#endif\n) {\n#if CC_RENDER_MODE == 0\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\n vec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\n vec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_RENDER_MODE == 1\n vec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\n vec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\n pos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_RENDER_MODE == 2\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = vec3(1, 0, 0);\n vec3 camY = vec3(0, 0, -1);\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_RENDER_MODE == 3\n vec2 viewSpaceVert = vec2(vertOffset.x * s.x, vertOffset.y * s.y);\n rotateCorner(viewSpaceVert, q.z);\n vec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\n vec3 camY = vec3(0, 1, 0);\n vec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\n pos.xyz += offset;\n#else\n pos.x += vertOffset.x;\n pos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV (float frameIndex, vec2 vertIndex, vec2 frameTile){\n vec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\n aniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if CC_RENDER_MODE != 4\n vertIndex.y = 1. - vertIndex.y;\n#endif\n return (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nlayout(std140) uniform SampleConstants {\n vec4 u_sampleInfo;\n};\nlayout(std140) uniform TickConstants {\n vec4 u_worldRot;\n vec4 u_timeDelta;\n};\nin vec4 a_position_starttime;\nin vec4 a_size_uv;\nin vec4 a_rotation_uv;\nin vec4 a_color;\nin vec4 a_dir_life;\nin float a_rndSeed;\n#if CC_RENDER_MODE == 4\n in vec3 a_texCoord;\n in vec3 a_texCoord3;\n in vec3 a_normal;\n in vec4 a_color1;\n#endif\nvec3 unpackCurveData (sampler2D tex, vec2 coord) {\n vec4 a = texture(tex, coord);\n vec4 b = texture(tex, coord + u_sampleInfo.y);\n float c = fract(coord.x * u_sampleInfo.x);\n return mix(a.xyz, b.xyz, c);\n}\nvec3 unpackCurveData (sampler2D tex, vec2 coord, out float w) {\n vec4 a = texture(tex, coord);\n vec4 b = texture(tex, coord + u_sampleInfo.y);\n float c = fract(coord.x * u_sampleInfo.x);\n w = mix(a.w, b.w, c);\n return mix(a.xyz, b.xyz, c);\n}\nfloat pseudoRandom (float seed) {\n seed = mod(seed, 233280.);\n float q = (seed * 9301. + 49297.) / 233280.;\n return fract(q);\n}\n#if COLOR_OVER_TIME_MODULE_ENABLE\n uniform sampler2D color_over_time_tex0;\n layout(std140) uniform ColorConstant {\n int u_color_mode;\n };\n#endif\n#if ROTATION_OVER_TIME_MODULE_ENABLE\n uniform sampler2D rotation_over_time_tex0;\n layout(std140) uniform RotationConstant {\n int u_rotation_mode;\n };\n#endif\n#if SIZE_OVER_TIME_MODULE_ENABLE\n uniform sampler2D size_over_time_tex0;\n layout(std140) uniform SizeConstant {\n int u_size_mode;\n };\n#endif\n#if FORCE_OVER_TIME_MODULE_ENABLE\n uniform sampler2D force_over_time_tex0;\n layout(std140) uniform ForceConstant {\n int u_force_mode;\n int u_force_space;\n };\n#endif\n#if VELOCITY_OVER_TIME_MODULE_ENABLE\n uniform sampler2D velocity_over_time_tex0;\n layout(std140) uniform VelocityConstant {\n int u_velocity_mode;\n int u_velocity_space;\n };\n#endif\n#if TEXTURE_ANIMATION_MODULE_ENABLE\n uniform sampler2D texture_animation_tex0;\n layout(std140) uniform AnimationConstant {\n vec4 u_anim_info;\n };\n#endif\nfloat repeat (float t, float length) {\n return t - floor(t / length) * length;\n}\nvec4 rotateQuat (vec4 p, vec4 q) {\n vec3 iv = cross(q.xyz, p.xyz) + q.w * p.xyz;\n vec3 res = p.xyz + 2.0 * cross(q.xyz, iv);\n return vec4(res.xyz, p.w);\n}\nvec4 gpvs_main () {\n float activeTime = u_timeDelta.x - a_position_starttime.w;\n float normalizedTime = clamp(activeTime / a_dir_life.w, 0.0, 1.0);\n vec2 timeCoord0 = vec2(normalizedTime, 0.);\n vec2 timeCoord1 = vec2(normalizedTime, 1.);\n #if CC_RENDER_MODE == 4\n vec2 vertIdx = vec2(a_texCoord.x, a_texCoord.y);\n #else\n vec2 vertIdx = vec2(a_size_uv.w, a_rotation_uv.w);\n #endif\n vec4 velocity = vec4(a_dir_life.xyz, 0.);\n vec4 pos = vec4(a_position_starttime.xyz, 1.);\n vec3 size = a_size_uv.xyz;\n #if SIZE_OVER_TIME_MODULE_ENABLE\n if (u_size_mode == 1) {\n size *= unpackCurveData(size_over_time_tex0, timeCoord0);\n } else {\n vec3 size_0 = unpackCurveData(size_over_time_tex0, timeCoord0);\n vec3 size_1 = unpackCurveData(size_over_time_tex0, timeCoord1);\n float factor_s = pseudoRandom(a_rndSeed + 39825.);\n size *= mix(size_0, size_1, factor_s);\n }\n #endif\n vec3 compScale = scale.xyz * size;\n #if FORCE_OVER_TIME_MODULE_ENABLE\n vec3 forceAnim = vec3(0.);\n if (u_force_mode == 1) {\n forceAnim = unpackCurveData(force_over_time_tex0, timeCoord0);\n } else {\n vec3 force_0 = unpackCurveData(force_over_time_tex0, timeCoord0);\n vec3 force_1 = unpackCurveData(force_over_time_tex0, timeCoord1);\n float factor_f = pseudoRandom(a_rndSeed + 212165.);\n forceAnim = mix(force_0, force_1, factor_f);\n }\n vec4 forceTrack = vec4(forceAnim, 0.);\n if (u_force_space == 0) {\n forceTrack = rotateQuat(forceTrack, u_worldRot);\n }\n velocity.xyz += forceTrack.xyz;\n #endif\n #if VELOCITY_OVER_TIME_MODULE_ENABLE\n float speedModifier0 = 1.;\n float speedModifier1 = 1.;\n vec3 velocityAnim = vec3(0.);\n if (u_velocity_mode == 1) {\n velocityAnim = unpackCurveData(velocity_over_time_tex0, timeCoord0, speedModifier0);\n } else {\n vec3 vectory_0 = unpackCurveData(velocity_over_time_tex0, timeCoord0, speedModifier0);\n vec3 vectory_1 = unpackCurveData(velocity_over_time_tex0, timeCoord1, speedModifier1);\n float factor_v = pseudoRandom(a_rndSeed + 197866.);\n velocityAnim = mix(vectory_0, vectory_1, factor_v);\n speedModifier0 = mix(speedModifier0, speedModifier1, factor_v);\n }\n vec4 velocityTrack = vec4(velocityAnim, 0.);\n if (u_velocity_space == 0) {\n velocityTrack = rotateQuat(velocityTrack, u_worldRot);\n }\n velocity.xyz += velocityTrack.xyz;\n velocity.xyz *= speedModifier0;\n #endif\n pos.xyz += velocity.xyz * normalizedTime * a_dir_life.w;\n #if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n #if CC_RENDER_MODE == 1\n velocity = rotateQuat(velocity, u_worldRot);\n #endif\n #endif\n vec3 rotation = a_rotation_uv.xyz;\n #if ROTATION_OVER_TIME_MODULE_ENABLE\n if (u_rotation_mode == 1) {\n rotation += unpackCurveData(rotation_over_time_tex0, timeCoord0) * normalizedTime * a_dir_life.w;\n } else {\n vec3 rotation_0 = unpackCurveData(rotation_over_time_tex0, timeCoord0);\n vec3 rotation_1 = unpackCurveData(rotation_over_time_tex0, timeCoord1);\n float factor_r = pseudoRandom(a_rndSeed + 125292.);\n rotation += mix(rotation_0, rotation_1, factor_r) * normalizedTime * a_dir_life.w;\n }\n #endif\n #if COLOR_OVER_TIME_MODULE_ENABLE\n if (u_color_mode == 1) {\n color = a_color * texture(color_over_time_tex0, timeCoord0);\n } else {\n vec4 color_0 = texture(color_over_time_tex0, timeCoord0);\n vec4 color_1 = texture(color_over_time_tex0, timeCoord1);\n float factor_c = pseudoRandom(a_rndSeed + 91041.);\n color = a_color * mix(color_0, color_1, factor_c);\n }\n #else\n color = a_color;\n #endif\n #if CC_RENDER_MODE != 4\n vec2 cornerOffset = vec2((vertIdx - 0.5));\n #if CC_RENDER_MODE == 0\n vec3 rotEuler = rotation.xyz;\n #elif CC_RENDER_MODE == 1\n vec3 rotEuler = vec3(0.);\n #else\n vec3 rotEuler = vec3(0., 0., rotation.z);\n #endif\n computeVertPos(pos, cornerOffset, quaternionFromEuler(rotEuler), compScale\n #if CC_RENDER_MODE == 0 || CC_RENDER_MODE == 3\n , cc_matViewInv\n #endif\n #if CC_RENDER_MODE == 1\n , cc_cameraPos.xyz\n , velocity\n , frameTile_velLenScale.z\n , frameTile_velLenScale.w\n , a_size_uv.w\n #endif\n );\n #else\n mat4 xformNoScale = matrixFromRT(quaternionFromEuler(rotation), pos.xyz);\n mat4 xform = matFromRTS(quaternionFromEuler(rotation), pos.xyz, compScale);\n pos = xform * vec4(a_texCoord3, 1);\n vec4 normal = xformNoScale * vec4(a_normal, 0);\n color *= a_color1;\n #endif\n pos = cc_matViewProj * pos;\n float frameIndex = 0.;\n #if TEXTURE_ANIMATION_MODULE_ENABLE\n float startFrame = 0.;\n vec3 frameInfo = vec3(0.);\n if (int(u_anim_info.x) == 1) {\n frameInfo = unpackCurveData(texture_animation_tex0, timeCoord0);\n } else {\n vec3 frameInfo0 = unpackCurveData(texture_animation_tex0, timeCoord0);\n vec3 frameInfo1 = unpackCurveData(texture_animation_tex0, timeCoord1);\n float factor_t = pseudoRandom(a_rndSeed + 90794.);\n frameInfo = mix(frameInfo0, frameInfo1, factor_t);\n }\n startFrame = frameInfo.x / u_anim_info.y;\n frameIndex = repeat(u_anim_info.z * (frameInfo.y + startFrame), 1.);\n #endif\n uv = computeUV(frameIndex, vertIdx, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\n return pos;\n}\nvoid main() { gl_Position = gpvs_main(); }",frag:"\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n #if CC_USE_HDR\n color.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n #endif\n return color;\n}\nin vec2 uv;\nin vec4 color;\nuniform sampler2D mainTexture;\nlayout(std140) uniform FragConstants {\n vec4 tintColor;\n};\nvec4 add () {\n vec4 col = 2.0 * color * tintColor * texture(mainTexture, uv);\n return CCFragOutput(col);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = add(); }"}],[{vert:"\nprecision mediump float;\nlayout(std140) uniform Constants {\n vec4 mainTiling_Offset;\n vec4 frameTile_velLenScale;\n vec4 scale;\n};\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nlayout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n};\nout mediump vec2 uv;\nout mediump vec4 color;\nin vec3 a_position;\nin vec4 a_texCoord;\nin vec3 a_texCoord1;\nin vec3 a_texCoord2;\nin vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\n out vec3 vBarycentric;\n#endif\nvec4 vs_main() {\n highp vec4 pos = vec4(a_position, 1);\n vec4 velocity = vec4(a_texCoord1.xyz, 0);\n #if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n velocity = cc_matWorld * velocity;\n #endif\n float vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\n vec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\n pos.xyz += camUp * vertOffset;\n pos = cc_matViewProj * pos;\n uv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\n color = a_color;\n #if CC_DRAW_WIRE_FRAME\n vBarycentric = a_texCoord2;\n #endif\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }",frag:"\n precision mediump float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n #if CC_USE_HDR\n color.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n #endif\n return color;\n}\n in vec2 uv;\n in vec4 color;\n #if CC_DRAW_WIRE_FRAME\n in vec3 vBarycentric;\n #endif\n uniform sampler2D mainTexture;\n layout(std140) uniform FragConstants {\n vec4 tintColor;\n };\n vec4 add () {\n vec4 col = 2.0 * color * tintColor * texture(mainTexture, uv);\n#if CC_DRAW_WIRE_FRAME\n if (any(lessThan(vBarycentric, vec3(0.02)))) {\n col = vec4(0., 1., 1., 1.);\n }\n#endif\n return CCFragOutput(col);\n }\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = add(); }"}],[{vert:"\nprecision highp float;\nvec4 quaternionFromAxis (vec3 xAxis,vec3 yAxis,vec3 zAxis){\n mat3 m = mat3(xAxis,yAxis,zAxis);\n float trace = m[0][0] + m[1][1] + m[2][2];\n vec4 quat;\n if (trace > 0.) {\n float s = 0.5 / sqrt(trace + 1.0);\n quat.w = 0.25 / s;\n quat.x = (m[2][1] - m[1][2]) * s;\n quat.y = (m[0][2] - m[2][0]) * s;\n quat.z = (m[1][0] - m[0][1]) * s;\n } else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\n float s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\n quat.w = (m[2][1] - m[1][2]) / s;\n quat.x = 0.25 * s;\n quat.y = (m[0][1] + m[1][0]) / s;\n quat.z = (m[0][2] + m[2][0]) / s;\n } else if (m[1][1] > m[2][2]) {\n float s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\n quat.w = (m[0][2] - m[2][0]) / s;\n quat.x = (m[0][1] + m[1][0]) / s;\n quat.y = 0.25 * s;\n quat.z = (m[1][2] + m[2][1]) / s;\n } else {\n float s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\n quat.w = (m[1][0] - m[0][1]) / s;\n quat.x = (m[0][2] + m[2][0]) / s;\n quat.y = (m[1][2] + m[2][1]) / s;\n quat.z = 0.25 * s;\n }\n float len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\n if (len > 0.) {\n len = 1. / sqrt(len);\n quat.x = quat.x * len;\n quat.y = quat.y * len;\n quat.z = quat.z * len;\n quat.w = quat.w * len;\n }\n return quat;\n}\nvec4 quaternionFromEuler (vec3 angle){\n float x = angle.x / 2.;\n float y = angle.y / 2.;\n float z = angle.z / 2.;\n float sx = sin(x);\n float cx = cos(x);\n float sy = sin(y);\n float cy = cos(y);\n float sz = sin(z);\n float cz = cos(z);\n vec4 quat = vec4(0);\n quat.x = sx * cy * cz + cx * sy * sz;\n quat.y = cx * sy * cz + sx * cy * sz;\n quat.z = cx * cy * sz - sx * sy * cz;\n quat.w = cx * cy * cz - sx * sy * sz;\n return quat;\n}\nmat4 matrixFromRT (vec4 q, vec3 p){\n float x2 = q.x + q.x;\n float y2 = q.y + q.y;\n float z2 = q.z + q.z;\n float xx = q.x * x2;\n float xy = q.x * y2;\n float xz = q.x * z2;\n float yy = q.y * y2;\n float yz = q.y * z2;\n float zz = q.z * z2;\n float wx = q.w * x2;\n float wy = q.w * y2;\n float wz = q.w * z2;\n return mat4(\n 1. - (yy + zz), xy + wz, xz - wy, 0,\n xy - wz, 1. - (xx + zz), yz + wx, 0,\n xz + wy, yz - wx, 1. - (xx + yy), 0,\n p.x, p.y, p.z, 1\n );\n}\nmat4 matFromRTS (vec4 q, vec3 t, vec3 s){\n float x = q.x, y = q.y, z = q.z, w = q.w;\n float x2 = x + x;\n float y2 = y + y;\n float z2 = z + z;\n float xx = x * x2;\n float xy = x * y2;\n float xz = x * z2;\n float yy = y * y2;\n float yz = y * z2;\n float zz = z * z2;\n float wx = w * x2;\n float wy = w * y2;\n float wz = w * z2;\n float sx = s.x;\n float sy = s.y;\n float sz = s.z;\n return mat4((1. - (yy + zz)) * sx, (xy + wz) * sx, (xz - wy) * sx, 0,\n (xy - wz) * sy, (1. - (xx + zz)) * sy, (yz + wx) * sy, 0,\n (xz + wy) * sz, (yz - wx) * sz, (1. - (xx + yy)) * sz, 0,\n t.x, t.y, t.z, 1);\n}\nvec4 quatMultiply (vec4 a, vec4 b){\n vec4 quat;\n quat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\n quat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\n quat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\n quat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\n return quat;\n}\nvoid rotateVecFromQuat (inout vec3 v, vec4 q){\n float ix = q.w * v.x + q.y * v.z - q.z * v.y;\n float iy = q.w * v.y + q.z * v.x - q.x * v.z;\n float iz = q.w * v.z + q.x * v.y - q.y * v.x;\n float iw = -q.x * v.x - q.y * v.y - q.z * v.z;\n v.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\n v.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\n v.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace (vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\n vec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\n vec4 rotQuat = quatMultiply(viewQuat, q);\n rotateVecFromQuat(pos, rotQuat);\n return pos;\n}\nvoid rotateCorner (inout vec2 corner, float angle){\n float xOS = cos(angle) * corner.x - sin(angle) * corner.y;\n float yOS = sin(angle) * corner.x + cos(angle) * corner.y;\n corner.x = xOS;\n corner.y = yOS;\n}\nlayout(std140) uniform Constants {\n vec4 mainTiling_Offset;\n vec4 frameTile_velLenScale;\n vec4 scale;\n};\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nlayout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n};\nout mediump vec2 uv;\nout mediump vec4 color;\nvoid computeVertPos (inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n#if CC_RENDER_MODE == 0 || CC_RENDER_MODE == 3\n , mat4 viewInv\n#endif\n#if CC_RENDER_MODE == 1\n , vec3 eye\n , vec4 velocity\n , float velocityScale\n , float lengthScale\n , float xIndex\n#endif\n) {\n#if CC_RENDER_MODE == 0\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\n vec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\n vec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_RENDER_MODE == 1\n vec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\n vec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\n pos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_RENDER_MODE == 2\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = vec3(1, 0, 0);\n vec3 camY = vec3(0, 0, -1);\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_RENDER_MODE == 3\n vec2 viewSpaceVert = vec2(vertOffset.x * s.x, vertOffset.y * s.y);\n rotateCorner(viewSpaceVert, q.z);\n vec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\n vec3 camY = vec3(0, 1, 0);\n vec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\n pos.xyz += offset;\n#else\n pos.x += vertOffset.x;\n pos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV (float frameIndex, vec2 vertIndex, vec2 frameTile){\n vec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\n aniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if CC_RENDER_MODE != 4\n vertIndex.y = 1. - vertIndex.y;\n#endif\n return (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nin vec3 a_position;\nin vec3 a_texCoord;\nin vec3 a_texCoord1;\nin vec3 a_texCoord2;\nin vec4 a_color;\n#if CC_RENDER_MODE == 1\n in vec3 a_color1;\n#endif\n#if CC_RENDER_MODE == 4\n in vec3 a_texCoord3;\n in vec3 a_normal;\n in vec4 a_color1;\n#endif\nvec4 lpvs_main () {\n vec3 compScale = scale.xyz * a_texCoord1;\n vec4 pos = vec4(a_position, 1);\n #if CC_RENDER_MODE == 1\n vec4 velocity = vec4(a_color1.xyz, 0);\n #endif\n #if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n #if CC_RENDER_MODE == 1\n velocity = cc_matWorld * velocity;\n #endif\n #endif\n #if CC_RENDER_MODE != 4\n vec2 cornerOffset = vec2((a_texCoord.xy - 0.5));\n #if CC_RENDER_MODE == 0\n vec3 rotEuler = a_texCoord2;\n #elif CC_RENDER_MODE == 1\n vec3 rotEuler = vec3(0.);\n #else\n vec3 rotEuler = vec3(0., 0., a_texCoord2.z);\n #endif\n computeVertPos(pos, cornerOffset, quaternionFromEuler(rotEuler), compScale\n #if CC_RENDER_MODE == 0 || CC_RENDER_MODE == 3\n , cc_matViewInv\n #endif\n #if CC_RENDER_MODE == 1\n , cc_cameraPos.xyz\n , velocity\n , frameTile_velLenScale.z\n , frameTile_velLenScale.w\n , a_texCoord.x\n #endif\n );\n color = a_color;\n #else\n mat4 xformNoScale = matrixFromRT(quaternionFromEuler(a_texCoord2), pos.xyz);\n mat4 xform = matFromRTS(quaternionFromEuler(a_texCoord2), pos.xyz, compScale);\n pos = xform * vec4(a_texCoord3, 1);\n vec4 normal = xformNoScale * vec4(a_normal, 0);\n color = a_color * a_color1;\n #endif\n uv = computeUV(a_texCoord.z, a_texCoord.xy, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\n pos = cc_matViewProj * pos;\n return pos;\n}\nvoid main() { gl_Position = lpvs_main(); }",frag:"\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n #if CC_USE_HDR\n color.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n #endif\n return color;\n}\nin vec2 uv;\nin vec4 color;\nuniform sampler2D mainTexture;\nlayout(std140) uniform FragConstants {\n vec4 tintColor;\n};\nvec4 add () {\n vec4 col = 2.0 * color * tintColor * texture(mainTexture, uv);\n return CCFragOutput(col);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = add(); }"}],[{vert:"\nprecision highp float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\n#if USE_LOCAL\nlayout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n};\n#endif\nin vec3 a_position;\nin vec2 a_texCoord;\nin vec4 a_color;\nout vec4 v_light;\nout vec2 uv0;\n#if TWO_COLORED\n in vec4 a_color2;\n out vec4 v_dark;\n#endif\nvec4 vert () {\n vec4 pos = vec4(a_position, 1);\n #if USE_LOCAL\n pos = cc_matWorld * pos;\n #endif\n pos = cc_matViewProj * pos;\n uv0 = a_texCoord;\n v_light = a_color;\n #if TWO_COLORED\n v_dark = a_color2;\n #endif\n return pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\n#if USE_ALPHA_TEST\n layout(std140) uniform ALPHA_TEST_DATA {\n float alphaThreshold;\n };\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nin vec4 v_light;\n#if TWO_COLORED\n in vec4 v_dark;\n#endif\nin vec2 uv0;\nuniform sampler2D cc_spriteTexture;\nvec4 frag () {\n vec4 o = vec4(1, 1, 1, 1);\n #if TWO_COLORED\n vec4 texColor = vec4(1, 1, 1, 1);\n texColor *= texture(cc_spriteTexture, uv0);\n o.a = texColor.a * v_light.a;\n o.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;\n #else\n o *= texture(cc_spriteTexture, uv0);\n o *= v_light;\n #endif\n ALPHA_TEST(o);\n return o;\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\n#if USE_LOCAL\nlayout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n};\n#endif\nin vec3 a_position;\nin vec2 a_texCoord;\nin vec4 a_color;\nout vec4 color;\nout vec2 uv0;\nvec4 vert () {\n vec4 pos = vec4(a_position, 1);\n #if USE_LOCAL\n pos = cc_matWorld * pos;\n #endif\n #if USE_PIXEL_ALIGNMENT\n pos = cc_matView * pos;\n pos.xyz = floor(pos.xyz);\n pos = cc_matProj * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n uv0 = a_texCoord;\n color = a_color;\n return pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nvec4 CCSampleWithAlphaSeparated(sampler2D tex, vec2 uv) {\n#if CC_USE_EMBEDDED_ALPHA\n return vec4(texture(tex, uv).rgb, texture(tex, uv + vec2(0.0, 0.5)).r);\n#else\n return texture(tex, uv);\n#endif\n}\n#if USE_ALPHA_TEST\n layout(std140) uniform ALPHA_TEST_DATA {\n float alphaThreshold;\n };\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nin vec4 color;\n#if USE_TEXTURE\n in vec2 uv0;\n uniform sampler2D cc_spriteTexture;\n#endif\nvec4 frag () {\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n o *= CCSampleWithAlphaSeparated(cc_spriteTexture, uv0);\n #if IS_GRAY\n float gray = 0.2126 * o.r + 0.7152 * o.g + 0.0722 * o.b;\n o.r = o.g = o.b = gray;\n #endif\n #endif\n o *= color;\n ALPHA_TEST(o);\n return o;\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\n rgba = rgba * 255.0;\n highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\n highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\n highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\n highp vec4 position;\n vec3 normal;\n vec4 tangent;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nin vec4 a_tangent;\n#if CC_USE_MORPH\n in float a_vertexId;\n int getVertexId() {\n return int(a_vertexId);\n }\nlayout(std140) uniform CCMorph {\n vec4 cc_displacementWeights[15];\n vec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\n float pixelIndexF = float(pixelIndex);\n float x = mod(pixelIndexF, textureResolution.x);\n float y = floor(pixelIndexF / textureResolution.x);\n return vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\n return (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_SUPPORT_FLOAT_TEXTURE\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\n ivec2 texSize = textureSize(tex, 0);\n return texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n }\n#else\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex * 4;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\n return vec4(\n decode32(texture(tex, x)),\n decode32(texture(tex, y)),\n decode32(texture(tex, z)),\n 1.0\n );\n }\n#endif\nfloat getDisplacementWeight(int index) {\n int quot = index / 4;\n int remainder = index - quot * 4;\n if (remainder == 0) {\n return cc_displacementWeights[quot].x;\n } else if (remainder == 1) {\n return cc_displacementWeights[quot].y;\n } else if (remainder == 2) {\n return cc_displacementWeights[quot].z;\n } else {\n return cc_displacementWeights[quot].w;\n }\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\n return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\n vec3 result = vec3(0, 0, 0);\n int nVertices = int(cc_displacementTextureInfo.z);\n for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\n result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n }\n return result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\n uniform sampler2D cc_PositionDisplacements;\n vec3 getPositionDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n uniform sampler2D cc_NormalDisplacements;\n vec3 getNormalDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n uniform sampler2D cc_TangentDisplacements;\n vec3 getTangentDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n }\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\n int vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\n attr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n attr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n attr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\n in vec4 a_joints;\nin vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n #if USE_INSTANCING\n in highp vec4 a_jointAnimInfo;\n #endif\n layout(std140) uniform CCSkinningTexture {\n highp vec4 cc_jointTextureInfo;\n };\n layout(std140) uniform CCSkinningAnimation {\n highp vec4 cc_jointAnimInfo;\n };\n uniform highp sampler2D cc_jointTexture;\n #else\n layout(std140) uniform CCSkinning {\n highp vec4 cc_joints[30 * 3];\n };\n#endif\n#if CC_USE_BAKED_ANIMATION\n #if CC_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\n vec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\n vec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n );\n vec4 v2 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n );\n vec4 v3 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n#else\n mat4 getJointMatrix (float i) {\n int idx = int(i);\n vec4 v1 = cc_joints[idx * 3];\n vec4 v2 = cc_joints[idx * 3 + 1];\n vec4 v3 = cc_joints[idx * 3 + 2];\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n#endif\nmat4 skinMatrix () {\n vec4 joints = vec4(a_joints);\n return getJointMatrix(joints.x) * a_weights.x\n + getJointMatrix(joints.y) * a_weights.y\n + getJointMatrix(joints.z) * a_weights.z\n + getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\n mat4 m = skinMatrix();\n position = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\n mat4 m = skinMatrix();\n attr.position = m * attr.position;\n attr.normal = (m * vec4(attr.normal, 0.0)).xyz;\n attr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\n#if USE_INSTANCING\n in vec4 a_matWorld0;\n in vec4 a_matWorld1;\n in vec4 a_matWorld2;\n #if USE_LIGHTMAP\n in vec4 a_lightingMapUVParam;\n #endif\n#elif USE_BATCHING\n in float a_dyn_batch_id;\n layout(std140) uniform CCLocalBatched {\n highp mat4 cc_matWorlds[10];\n };\n#else\nlayout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n};\n#endif\nlayout(std140) uniform Constants {\n vec4 tilingOffset;\n vec4 albedo;\n vec4 albedoScaleAndCutoff;\n vec4 pbrParams;\n vec4 emissive;\n vec4 emissiveScaleParam;\n};\nfloat LinearFog(vec4 pos) {\n vec4 wPos = pos;\n float cam_dis = distance(cc_cameraPos, wPos);\n float fogStart = cc_fogBase.x;\n float fogEnd = cc_fogBase.y;\n return clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float fogDensity = cc_fogBase.z;\n float cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\n float f = exp(-cam_dis * fogDensity);\n return f;\n}\nfloat ExpSquaredFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float fogDensity = cc_fogBase.z;\n float cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\n float f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\n return f;\n}\nfloat LayeredFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float _FogTop = cc_fogAdd.x;\n float _FogRange = cc_fogAdd.y;\n vec3 camWorldProj = cc_cameraPos.xyz;\n camWorldProj.y = 0.;\n vec3 worldPosProj = wPos.xyz;\n worldPosProj.y = 0.;\n float fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\n float fDeltaY, fDensityIntegral;\n if (cc_cameraPos.y > _FogTop) {\n if (wPos.y < _FogTop) {\n fDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\n fDensityIntegral = fDeltaY * fDeltaY * 0.5;\n } else {\n fDeltaY = 0.;\n fDensityIntegral = 0.;\n }\n } else {\n if (wPos.y < _FogTop) {\n float fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\n float fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\n fDeltaY = abs(fDeltaA - fDeltaB);\n fDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n } else {\n fDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\n fDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n }\n }\n float fDensity;\n if (fDeltaY != 0.) {\n fDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n } else {\n fDensity = 0.;\n }\n float f = exp(-fDensity);\n return f;\n}\nfloat CC_TRANSFER_FOG(vec4 pos) {\n #if CC_USE_FOG == 0\n return LinearFog(pos);\n\t#elif CC_USE_FOG == 1\n return ExpFog(pos);\n #elif CC_USE_FOG == 2\n return ExpSquaredFog(pos);\n #elif CC_USE_FOG == 3\n return LayeredFog(pos);\n #endif\n return 1.;\n}\nout highp vec4 v_shadowPos;\nlayout(std140) uniform CCShadow {\n highp mat4 cc_matLightPlaneProj;\n highp mat4 cc_matLightViewProj;\n lowp vec4 cc_shadowColor;\n lowp vec4 cc_shadowInfo;\n};\n#if USE_VERTEX_COLOR\n in vec4 a_color;\n out vec4 v_color;\n#endif\nout vec3 v_position;\nout vec3 v_normal;\nout vec2 v_uv;\nout vec2 v_uv1;\nout float v_fog_factor;\n#if USE_NORMAL_MAP\n out vec3 v_tangent;\n out vec3 v_bitangent;\n#endif\n#if HAS_SECOND_UV || USE_LIGHTMAP\n in vec2 a_texCoord1;\n#endif\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\n out vec2 v_luv;\nvoid CCLightingMapCaclUV()\n{\n#if !USE_INSTANCING\n v_luv = cc_lightingMapUVParam.xy + a_texCoord1 * cc_lightingMapUVParam.zw;\n#else\n v_luv = a_lightingMapUVParam.xy + a_texCoord1 * a_lightingMapUVParam.zw;\n#endif\n}\n#endif\nvec4 vert () {\n StandardVertInput In;\n In.position = vec4(a_position, 1.0);\n In.normal = a_normal;\n In.tangent = a_tangent;\n #if CC_USE_MORPH\n applyMorph(In);\n #endif\n #if CC_USE_SKINNING\n CCSkin(In);\n #endif\n mat4 matWorld, matWorldIT;\n #if USE_INSTANCING\n matWorld = mat4(\n vec4(a_matWorld0.xyz, 0.0),\n vec4(a_matWorld1.xyz, 0.0),\n vec4(a_matWorld2.xyz, 0.0),\n vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n );\n matWorldIT = matWorld;\n #elif USE_BATCHING\n matWorld = cc_matWorlds[int(a_dyn_batch_id)];\n matWorldIT = matWorld;\n #else\n matWorld = cc_matWorld;\n matWorldIT = cc_matWorldIT;\n #endif\n vec4 pos = matWorld * In.position;\n v_position = pos.xyz;\n v_normal = normalize((matWorldIT * vec4(In.normal, 0.0)).xyz);\n #if USE_NORMAL_MAP\n v_tangent = normalize((matWorld * vec4(In.tangent.xyz, 0.0)).xyz);\n v_bitangent = cross(v_normal, v_tangent) * In.tangent.w;\n #endif\n v_uv = a_texCoord * tilingOffset.xy + tilingOffset.zw;\n #if HAS_SECOND_UV\n v_uv1 = a_texCoord1 * tilingOffset.xy + tilingOffset.zw;\n #endif\n #if USE_VERTEX_COLOR\n v_color = a_color;\n #endif\n v_fog_factor = CC_TRANSFER_FOG(pos);\n #if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\n CCLightingMapCaclUV();\n #endif\n v_shadowPos = cc_matLightViewProj * pos;\n return cc_matProj * (cc_matView * matWorld) * In.position;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nlayout(std140) uniform CCShadow {\n highp mat4 cc_matLightPlaneProj;\n highp mat4 cc_matLightViewProj;\n lowp vec4 cc_shadowColor;\n lowp vec4 cc_shadowInfo;\n};\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\nvec3 unpackRGBE (vec4 rgbe) {\n return rgbe.rgb * pow(2.0, rgbe.a * 255.0 - 128.0);\n}\nvec4 fragTextureLod (sampler2D tex, vec2 coord, float lod) {\n return textureLod(tex, coord, lod);\n}\nvec4 fragTextureLod (samplerCube tex, vec3 coord, float lod) {\n return textureLod(tex, coord, lod);\n}\n#endif\n#if CC_RECEIVE_SHADOW\nin highp vec4 v_shadowPos;\n#if CC_RECEIVE_SHADOW\n uniform sampler2D cc_shadowMap;\n uniform sampler2D cc_spotLightingMap;\n float CCGetShadowFactorX1 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float closestDepth = dot(texture(cc_shadowMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n float shadow = step(closestDepth, clipPos.z - cc_shadowInfo.w);\n return shadow;\n }\n float CCGetShadowFactorX5 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n float closestDepth = 0.0;\n closestDepth = dot(texture(cc_shadowMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_shadowMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_shadowMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_shadowMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n return shadow / 5.0;\n }\n float CCGetShadowFactorX9 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -1; i <= 1; i++) {\n for (int j = -1; j <= 1; j++) {\n float closestDepth = dot(texture(cc_shadowMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 9.0;\n }\n float CCGetShadowFactorX25 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -2; i <= 2; i++) {\n for (int j = -2; j <= 2; j++) {\n float closestDepth = dot(texture(cc_shadowMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 25.0;\n }\n float CCGetDirLightShadowFactorX1 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float closestDepth = dot(texture(cc_spotLightingMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n float shadow = step(closestDepth, clipPos.z - cc_shadowInfo.w);\n return shadow;\n }\n float CCGetDirLightShadowFactorX5 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n float closestDepth = 0.0;\n closestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n return shadow / 5.0;\n }\n float CCGetDirLightShadowFactorX9 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -1; i <= 1; i++) {\n for (int j = -1; j <= 1; j++) {\n float closestDepth = dot(texture(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 9.0;\n }\n float CCGetDirLightShadowFactorX25 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -2; i <= 2; i++) {\n for (int j = -2; j <= 2; j++) {\n float closestDepth = dot(texture(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 25.0;\n }\n#endif\n#endif\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nfloat GGXMobile (float roughness, float NoH, vec3 H, vec3 N) {\n vec3 NxH = cross(N, H);\n float OneMinusNoHSqr = dot(NxH, NxH);\n float a = roughness * roughness;\n float n = NoH * a;\n float p = a / (OneMinusNoHSqr + n * n);\n return p * p;\n}\nfloat CalcSpecular (float roughness, float NoH, vec3 H, vec3 N) {\n return (roughness*0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox (vec3 specular, float roughness, float NoV) {\n const vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\n const vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\n vec4 r = roughness * c0 + c1;\n float a004 = min( r.x * r.x, exp2( -9.28 * NoV ) ) * r.x + r.y;\n vec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n AB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\n return specular * AB.x + AB.y;\n}\nstruct StandardSurface {\n vec4 albedo;\n vec3 position;\n vec3 normal;\n vec3 emissive;\n vec4 lightmap;\n float roughness;\n float metallic;\n float occlusion;\n};\n#if CC_FORWARD_ADD\nlayout(std140) uniform CCForwardLight {\n highp vec4 cc_lightPos[1];\n vec4 cc_lightColor[1];\n vec4 cc_lightSizeRangeAngle[1];\n vec4 cc_lightDir[1];\n};\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\n float factor = distSqr * invSqrAttRadius;\n float smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\n return smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\n float attenuation = 1.0 / max(distSqr, 0.01*0.01);\n attenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\n return attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\n float cd = dot(litDir, L);\n float attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\n return (attenuation * attenuation);\n}\n vec4 CCStandardShading (StandardSurface s) {\n vec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\n vec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\n vec3 diffuseContrib = diffuse / 3.14159265359;\n vec3 N = normalize(s.normal);\n vec3 V = normalize(cc_cameraPos.xyz - s.position);\n float NV = max(abs(dot(N, V)), 0.001);\n specular = BRDFApprox(specular, s.roughness, NV);\n vec3 finalColor = vec3(0.0);\n for (int i = 0; i < 1; i++) {\n vec3 SLU = cc_lightPos[i].xyz - s.position;\n vec3 SL = normalize(SLU);\n vec3 SH = normalize(SL + V);\n float SNL = max(dot(N, SL), 0.001);\n float SNH = max(dot(N, SH), 0.0);\n float distSqr = dot(SLU, SLU);\n float litRadius = cc_lightSizeRangeAngle[i].x;\n float litRadiusSqr = litRadius * litRadius;\n float illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\n float attRadiusSqrInv = 1.0 / max(cc_lightSizeRangeAngle[i].y, 0.01);\n attRadiusSqrInv *= attRadiusSqrInv;\n float att = GetDistAtt(distSqr, attRadiusSqrInv);\n vec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\n if (cc_lightPos[i].w > 0.0) {\n float cosInner = max(dot(-cc_lightDir[i].xyz, SL), 0.01);\n float cosOuter = cc_lightSizeRangeAngle[i].z;\n float litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\n float litAngleOffset = -cosOuter * litAngleScale;\n att *= GetAngleAtt(SL, -cc_lightDir[i].xyz, litAngleScale, litAngleOffset);\n }\n vec3 lightColor = cc_lightColor[i].rgb;\n #if CC_RECEIVE_SHADOW\n if (cc_lightPos[i].w > 0.0) {\n {\n float pcf = cc_shadowInfo.z + 0.001;\n float shadowAttenuation = 0.0;\n if (pcf > 3.0) shadowAttenuation = CCGetDirLightShadowFactorX25();\n else if (3.0 > pcf && pcf > 2.0) shadowAttenuation = CCGetDirLightShadowFactorX9();\n else if (2.0 > pcf && pcf > 1.0) shadowAttenuation = CCGetDirLightShadowFactorX5();\n else shadowAttenuation = CCGetDirLightShadowFactorX1();\n lightColor *= 1.0 - shadowAttenuation;\n }\n }\n #endif\n finalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n }\n finalColor = finalColor * s.occlusion;\n return vec4(finalColor, 0.0);\n }\n#else\n vec4 CCStandardShading (StandardSurface s) {\n vec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\n vec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\n vec3 N = normalize(s.normal);\n vec3 V = normalize(cc_cameraPos.xyz - s.position);\n float NV = max(abs(dot(N, V)), 0.001);\n specular = BRDFApprox(specular, s.roughness, NV);\n vec3 L = normalize(-cc_mainLitDir.xyz);\n vec3 H = normalize(L+V);\n float NH = max(dot(N, H), 0.0);\n float NL = max(dot(N, L), 0.001);\n vec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w;\n #if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\n finalColor = s.lightmap.a * s.lightmap.rgb + (1.0 - s.lightmap.a) * finalColor;\n #endif\n vec3 diffuseContrib = diffuse / 3.14159265359;\n vec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\n finalColor *= (diffuseContrib + specularContrib);\n float fAmb = 0.5 - N.y * 0.5;\n vec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb) * cc_ambientSky.w;\n finalColor += (ambDiff.rgb * diffuse);\n #if CC_USE_IBL\n vec3 R = normalize(reflect(-V, N));\n vec4 envmap = fragTextureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n #if CC_USE_IBL == 2\n vec3 env = unpackRGBE(envmap);\n #else\n vec3 env = SRGBToLinear(envmap.rgb);\n #endif\n finalColor += env * cc_ambientSky.w * specular;\n #endif\n finalColor = finalColor * s.occlusion;\n #if CC_USE_HDR\n s.emissive *= cc_exposure.w;\n #endif\n finalColor += s.emissive;\n #if CC_RECEIVE_SHADOW\n {\n float pcf = cc_shadowInfo.z + 0.001;\n float shadowAttenuation = 0.0;\n if (pcf > 3.0) shadowAttenuation = CCGetShadowFactorX25();\n else if (3.0 > pcf && pcf > 2.0) shadowAttenuation = CCGetShadowFactorX9();\n else if (2.0 > pcf && pcf > 1.0) shadowAttenuation = CCGetShadowFactorX5();\n else shadowAttenuation = CCGetShadowFactorX1();\n vec3 shadowColor = cc_shadowColor.rgb * cc_shadowColor.a + finalColor.rgb * (1.0 - cc_shadowColor.a);\n finalColor.rgb = shadowColor.rgb * shadowAttenuation * NL + finalColor.rgb * (1.0 - shadowAttenuation * NL);\n }\n #endif\n return vec4(finalColor, s.albedo.a);\n }\n#endif\nvec3 ACESToneMap (vec3 color) {\n color = min(color, vec3(8.0));\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n #if !CC_USE_HDR\n color.rgb = sqrt(ACESToneMap(color.rgb));\n #endif\n return color;\n}\nlayout(std140) uniform Constants {\n vec4 tilingOffset;\n vec4 albedo;\n vec4 albedoScaleAndCutoff;\n vec4 pbrParams;\n vec4 emissive;\n vec4 emissiveScaleParam;\n};\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\n in vec2 v_luv;\nuniform sampler2D cc_lightingMap;\n#endif\nin vec3 v_position;\nin vec2 v_uv;\nin vec2 v_uv1;\nin vec3 v_normal;\nin float v_fog_factor;\n#if USE_VERTEX_COLOR\n in vec4 v_color;\n#endif\n#if USE_ALBEDO_MAP\n uniform sampler2D albedoMap;\n#endif\n#if USE_NORMAL_MAP\n in vec3 v_tangent;\n in vec3 v_bitangent;\n uniform sampler2D normalMap;\n#endif\n#if USE_PBR_MAP\n uniform sampler2D pbrMap;\n#endif\n#if USE_METALLIC_ROUGHNESS_MAP\n uniform sampler2D metallicRoughnessMap;\n#endif\n#if USE_OCCLUSION_MAP\n uniform sampler2D occlusionMap;\n#endif\n#if USE_EMISSIVE_MAP\n uniform sampler2D emissiveMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\nvoid surf (out StandardSurface s) {\n vec4 baseColor = albedo;\n #if USE_VERTEX_COLOR\n baseColor *= v_color;\n #endif\n #if USE_ALBEDO_MAP\n vec4 texColor = texture(albedoMap, ALBEDO_UV);\n texColor.rgb = SRGBToLinear(texColor.rgb);\n baseColor *= texColor;\n #endif\n s.albedo = baseColor;\n s.albedo.rgb *= albedoScaleAndCutoff.xyz;\n #if USE_ALPHA_TEST\n if (s.albedo.ALPHA_TEST_CHANNEL < albedoScaleAndCutoff.w) discard;\n #endif\n #if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\n s.lightmap = texture(cc_lightingMap, v_luv);\n #endif\n s.normal = v_normal;\n #if USE_NORMAL_MAP\n vec3 nmmp = texture(normalMap, NORMAL_UV).xyz - vec3(0.5);\n s.normal =\n (nmmp.x * pbrParams.w) * normalize(v_tangent) +\n (nmmp.y * pbrParams.w) * normalize(v_bitangent) +\n nmmp.z * normalize(s.normal);\n #endif\n s.position = v_position;\n vec4 pbr = pbrParams;\n #if USE_PBR_MAP\n vec4 res = texture(pbrMap, PBR_UV);\n pbr.x *= res.r;\n pbr.y *= res.g;\n pbr.z *= res.b;\n #endif\n #if USE_METALLIC_ROUGHNESS_MAP\n vec4 metallicRoughness = texture(metallicRoughnessMap, PBR_UV);\n pbr.z *= metallicRoughness.b;\n pbr.y *= metallicRoughness.g;\n #endif\n #if USE_OCCLUSION_MAP\n pbr.x *= texture(occlusionMap, PBR_UV).r;\n #endif\n s.occlusion = clamp(pbr.x, 0.0, 0.96);\n s.roughness = clamp(pbr.y, 0.04, 1.0);\n s.metallic = pbr.z;\n s.emissive = emissive.rgb * emissiveScaleParam.xyz;\n #if USE_EMISSIVE_MAP\n s.emissive *= SRGBToLinear(texture(emissiveMap, EMISSIVE_UV).rgb);\n #endif\n}\nvec4 frag () {\n StandardSurface s; surf(s);\n vec4 color = CCStandardShading(s);\n color = vec4(mix(CC_FORWARD_ADD > 0 ? vec3(0.0) : cc_fogColor.rgb, color.rgb, v_fog_factor), color.a);\n return CCFragOutput(color);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"},{vert:"\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\n rgba = rgba * 255.0;\n highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\n highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\n highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\n highp vec4 position;\n vec3 normal;\n vec4 tangent;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nin vec4 a_tangent;\n#if CC_USE_MORPH\n in float a_vertexId;\n int getVertexId() {\n return int(a_vertexId);\n }\nlayout(std140) uniform CCMorph {\n vec4 cc_displacementWeights[15];\n vec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\n float pixelIndexF = float(pixelIndex);\n float x = mod(pixelIndexF, textureResolution.x);\n float y = floor(pixelIndexF / textureResolution.x);\n return vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\n return (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_SUPPORT_FLOAT_TEXTURE\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\n ivec2 texSize = textureSize(tex, 0);\n return texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n }\n#else\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex * 4;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\n return vec4(\n decode32(texture(tex, x)),\n decode32(texture(tex, y)),\n decode32(texture(tex, z)),\n 1.0\n );\n }\n#endif\nfloat getDisplacementWeight(int index) {\n int quot = index / 4;\n int remainder = index - quot * 4;\n if (remainder == 0) {\n return cc_displacementWeights[quot].x;\n } else if (remainder == 1) {\n return cc_displacementWeights[quot].y;\n } else if (remainder == 2) {\n return cc_displacementWeights[quot].z;\n } else {\n return cc_displacementWeights[quot].w;\n }\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\n return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\n vec3 result = vec3(0, 0, 0);\n int nVertices = int(cc_displacementTextureInfo.z);\n for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\n result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n }\n return result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\n uniform sampler2D cc_PositionDisplacements;\n vec3 getPositionDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n uniform sampler2D cc_NormalDisplacements;\n vec3 getNormalDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n uniform sampler2D cc_TangentDisplacements;\n vec3 getTangentDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n }\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\n int vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\n attr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n attr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n attr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\n in vec4 a_joints;\nin vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n #if USE_INSTANCING\n in highp vec4 a_jointAnimInfo;\n #endif\n layout(std140) uniform CCSkinningTexture {\n highp vec4 cc_jointTextureInfo;\n };\n layout(std140) uniform CCSkinningAnimation {\n highp vec4 cc_jointAnimInfo;\n };\n uniform highp sampler2D cc_jointTexture;\n #else\n layout(std140) uniform CCSkinning {\n highp vec4 cc_joints[30 * 3];\n };\n#endif\n#if CC_USE_BAKED_ANIMATION\n #if CC_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\n vec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\n vec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n );\n vec4 v2 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n );\n vec4 v3 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n#else\n mat4 getJointMatrix (float i) {\n int idx = int(i);\n vec4 v1 = cc_joints[idx * 3];\n vec4 v2 = cc_joints[idx * 3 + 1];\n vec4 v3 = cc_joints[idx * 3 + 2];\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n#endif\nmat4 skinMatrix () {\n vec4 joints = vec4(a_joints);\n return getJointMatrix(joints.x) * a_weights.x\n + getJointMatrix(joints.y) * a_weights.y\n + getJointMatrix(joints.z) * a_weights.z\n + getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\n mat4 m = skinMatrix();\n position = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\n mat4 m = skinMatrix();\n attr.position = m * attr.position;\n attr.normal = (m * vec4(attr.normal, 0.0)).xyz;\n attr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\n#if USE_INSTANCING\n in vec4 a_matWorld0;\n in vec4 a_matWorld1;\n in vec4 a_matWorld2;\n #if USE_LIGHTMAP\n in vec4 a_lightingMapUVParam;\n #endif\n#elif USE_BATCHING\n in float a_dyn_batch_id;\n layout(std140) uniform CCLocalBatched {\n highp mat4 cc_matWorlds[10];\n };\n#else\nlayout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n};\n#endif\nlayout(std140) uniform Constants {\n vec4 tilingOffset;\n vec4 albedo;\n vec4 albedoScaleAndCutoff;\n vec4 pbrParams;\n vec4 emissive;\n vec4 emissiveScaleParam;\n};\nlayout(std140) uniform CCShadow {\n highp mat4 cc_matLightPlaneProj;\n highp mat4 cc_matLightViewProj;\n lowp vec4 cc_shadowColor;\n lowp vec4 cc_shadowInfo;\n};\n#if HAS_SECOND_UV || USE_LIGHTMAP\n in vec2 a_texCoord1;\n#endif\nout vec2 v_uv;\nout vec2 v_uv1;\nout float v_clip_depth;\nvec4 vert () {\n StandardVertInput In;\n In.position = vec4(a_position, 1.0);\n In.normal = a_normal;\n In.tangent = a_tangent;\n #if CC_USE_MORPH\n applyMorph(In);\n #endif\n #if CC_USE_SKINNING\n CCSkin(In);\n #endif\n mat4 matWorld, matWorldIT;\n #if USE_INSTANCING\n matWorld = mat4(\n vec4(a_matWorld0.xyz, 0.0),\n vec4(a_matWorld1.xyz, 0.0),\n vec4(a_matWorld2.xyz, 0.0),\n vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n );\n matWorldIT = matWorld;\n #elif USE_BATCHING\n matWorld = cc_matWorlds[int(a_dyn_batch_id)];\n matWorldIT = matWorld;\n #else\n matWorld = cc_matWorld;\n matWorldIT = cc_matWorldIT;\n #endif\n vec4 worldPos = matWorld * In.position;\n vec4 clipPos = cc_matLightViewProj * worldPos;\n v_uv = a_texCoord * tilingOffset.xy + tilingOffset.zw;\n #if HAS_SECOND_UV\n v_uv1 = a_texCoord1 * tilingOffset.xy + tilingOffset.zw;\n #endif\n v_clip_depth = clipPos.z / clipPos.w * 0.5 + 0.5;\n return clipPos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nlayout(std140) uniform Constants {\n vec4 tilingOffset;\n vec4 albedo;\n vec4 albedoScaleAndCutoff;\n vec4 pbrParams;\n vec4 emissive;\n vec4 emissiveScaleParam;\n};\nvec4 packDepthToRGBA (float depth) {\n vec4 ret = vec4(1.0, 255.0, 65025.0, 160581375.0) * depth;\n ret = fract(ret);\n ret -= ret.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n return ret;\n}\nin vec2 v_uv;\nin vec2 v_uv1;\nin float v_clip_depth;\n#if USE_ALBEDO_MAP\n uniform sampler2D albedoMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\nvec4 frag () {\n vec4 baseColor = albedo;\n #if USE_ALBEDO_MAP\n baseColor *= texture(albedoMap, ALBEDO_UV);\n #endif\n #if USE_ALPHA_TEST\n if (baseColor.ALPHA_TEST_CHANNEL < albedoScaleAndCutoff.w) discard;\n #endif\n return packDepthToRGBA(v_clip_depth);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}],[{vert:"\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nlayout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n};\nfloat LinearFog(vec4 pos) {\n vec4 wPos = pos;\n float cam_dis = distance(cc_cameraPos, wPos);\n float fogStart = cc_fogBase.x;\n float fogEnd = cc_fogBase.y;\n return clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float fogDensity = cc_fogBase.z;\n float cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\n float f = exp(-cam_dis * fogDensity);\n return f;\n}\nfloat ExpSquaredFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float fogDensity = cc_fogBase.z;\n float cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\n float f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\n return f;\n}\nfloat LayeredFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float _FogTop = cc_fogAdd.x;\n float _FogRange = cc_fogAdd.y;\n vec3 camWorldProj = cc_cameraPos.xyz;\n camWorldProj.y = 0.;\n vec3 worldPosProj = wPos.xyz;\n worldPosProj.y = 0.;\n float fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\n float fDeltaY, fDensityIntegral;\n if (cc_cameraPos.y > _FogTop) {\n if (wPos.y < _FogTop) {\n fDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\n fDensityIntegral = fDeltaY * fDeltaY * 0.5;\n } else {\n fDeltaY = 0.;\n fDensityIntegral = 0.;\n }\n } else {\n if (wPos.y < _FogTop) {\n float fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\n float fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\n fDeltaY = abs(fDeltaA - fDeltaB);\n fDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n } else {\n fDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\n fDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n }\n }\n float fDensity;\n if (fDeltaY != 0.) {\n fDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n } else {\n fDensity = 0.;\n }\n float f = exp(-fDensity);\n return f;\n}\nfloat CC_TRANSFER_FOG(vec4 pos) {\n #if CC_USE_FOG == 0\n return LinearFog(pos);\n\t#elif CC_USE_FOG == 1\n return ExpFog(pos);\n #elif CC_USE_FOG == 2\n return ExpSquaredFog(pos);\n #elif CC_USE_FOG == 3\n return LayeredFog(pos);\n #endif\n return 1.;\n}\nout highp vec4 v_shadowPos;\nlayout(std140) uniform CCShadow {\n highp mat4 cc_matLightPlaneProj;\n highp mat4 cc_matLightViewProj;\n lowp vec4 cc_shadowColor;\n lowp vec4 cc_shadowInfo;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nout highp vec3 v_position;\nout mediump vec3 v_normal;\n#if USE_NORMALMAP\n out mediump vec3 v_tangent;\n out mediump vec3 v_binormal;\n#endif\nout mediump vec2 uvw;\nout mediump vec2 uv0;\nout mediump vec2 uv1;\nout mediump vec2 uv2;\nout mediump vec2 uv3;\nout mediump vec2 luv;\nout mediump vec3 diffuse;\nout mediump float v_fog_factor;\nlayout(std140) uniform TexCoords {\n vec4 UVScale;\n vec4 lightMapUVParam;\n};\nvec4 vert () {\n vec3 worldPos;\n worldPos.x = cc_matWorld[3][0] + a_position.x;\n worldPos.y = cc_matWorld[3][1] + a_position.y;\n worldPos.z = cc_matWorld[3][2] + a_position.z;\n vec4 pos = vec4(worldPos, 1.0);\n pos = cc_matViewProj * pos;\n uvw = a_texCoord;\n uv0 = a_position.xz * UVScale.x;\n uv1 = a_position.xz * UVScale.y;\n uv2 = a_position.xz * UVScale.z;\n uv3 = a_position.xz * UVScale.w;\n #if USE_LIGHTMAP\n luv = lightMapUVParam.xy + a_texCoord * lightMapUVParam.zw;\n #endif\n v_position = worldPos;\n v_normal = a_normal;\n v_fog_factor = CC_TRANSFER_FOG(vec4(worldPos, 1.0));\n #if USE_NORMALMAP\n v_tangent = vec3(1.0, 0.0, 0.0);\n v_binormal = vec3(0.0, 0.0, 1.0);\n v_binormal = cross(v_tangent, a_normal);\n v_tangent = cross(a_normal, v_binormal);\n #endif\n v_shadowPos = cc_matLightViewProj * vec4(worldPos, 1.0);\n return pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nlayout(std140) uniform CCShadow {\n highp mat4 cc_matLightPlaneProj;\n highp mat4 cc_matLightViewProj;\n lowp vec4 cc_shadowColor;\n lowp vec4 cc_shadowInfo;\n};\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\nvec3 unpackRGBE (vec4 rgbe) {\n return rgbe.rgb * pow(2.0, rgbe.a * 255.0 - 128.0);\n}\nvec4 fragTextureLod (sampler2D tex, vec2 coord, float lod) {\n return textureLod(tex, coord, lod);\n}\nvec4 fragTextureLod (samplerCube tex, vec3 coord, float lod) {\n return textureLod(tex, coord, lod);\n}\n#endif\n#if CC_RECEIVE_SHADOW\nin highp vec4 v_shadowPos;\n#if CC_RECEIVE_SHADOW\n uniform sampler2D cc_shadowMap;\n uniform sampler2D cc_spotLightingMap;\n float CCGetShadowFactorX1 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float closestDepth = dot(texture(cc_shadowMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n float shadow = step(closestDepth, clipPos.z - cc_shadowInfo.w);\n return shadow;\n }\n float CCGetShadowFactorX5 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n float closestDepth = 0.0;\n closestDepth = dot(texture(cc_shadowMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_shadowMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_shadowMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_shadowMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n return shadow / 5.0;\n }\n float CCGetShadowFactorX9 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -1; i <= 1; i++) {\n for (int j = -1; j <= 1; j++) {\n float closestDepth = dot(texture(cc_shadowMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 9.0;\n }\n float CCGetShadowFactorX25 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -2; i <= 2; i++) {\n for (int j = -2; j <= 2; j++) {\n float closestDepth = dot(texture(cc_shadowMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 25.0;\n }\n float CCGetDirLightShadowFactorX1 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float closestDepth = dot(texture(cc_spotLightingMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n float shadow = step(closestDepth, clipPos.z - cc_shadowInfo.w);\n return shadow;\n }\n float CCGetDirLightShadowFactorX5 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n float closestDepth = 0.0;\n closestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n return shadow / 5.0;\n }\n float CCGetDirLightShadowFactorX9 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -1; i <= 1; i++) {\n for (int j = -1; j <= 1; j++) {\n float closestDepth = dot(texture(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 9.0;\n }\n float CCGetDirLightShadowFactorX25 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -2; i <= 2; i++) {\n for (int j = -2; j <= 2; j++) {\n float closestDepth = dot(texture(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 25.0;\n }\n#endif\n#endif\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nfloat GGXMobile (float roughness, float NoH, vec3 H, vec3 N) {\n vec3 NxH = cross(N, H);\n float OneMinusNoHSqr = dot(NxH, NxH);\n float a = roughness * roughness;\n float n = NoH * a;\n float p = a / (OneMinusNoHSqr + n * n);\n return p * p;\n}\nfloat CalcSpecular (float roughness, float NoH, vec3 H, vec3 N) {\n return (roughness*0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox (vec3 specular, float roughness, float NoV) {\n const vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\n const vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\n vec4 r = roughness * c0 + c1;\n float a004 = min( r.x * r.x, exp2( -9.28 * NoV ) ) * r.x + r.y;\n vec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n AB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\n return specular * AB.x + AB.y;\n}\nstruct StandardSurface {\n vec4 albedo;\n vec3 position;\n vec3 normal;\n vec3 emissive;\n vec4 lightmap;\n float roughness;\n float metallic;\n float occlusion;\n};\n#if CC_FORWARD_ADD\nlayout(std140) uniform CCForwardLight {\n highp vec4 cc_lightPos[1];\n vec4 cc_lightColor[1];\n vec4 cc_lightSizeRangeAngle[1];\n vec4 cc_lightDir[1];\n};\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\n float factor = distSqr * invSqrAttRadius;\n float smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\n return smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\n float attenuation = 1.0 / max(distSqr, 0.01*0.01);\n attenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\n return attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\n float cd = dot(litDir, L);\n float attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\n return (attenuation * attenuation);\n}\n vec4 CCStandardShading (StandardSurface s) {\n vec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\n vec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\n vec3 diffuseContrib = diffuse / 3.14159265359;\n vec3 N = normalize(s.normal);\n vec3 V = normalize(cc_cameraPos.xyz - s.position);\n float NV = max(abs(dot(N, V)), 0.001);\n specular = BRDFApprox(specular, s.roughness, NV);\n vec3 finalColor = vec3(0.0);\n for (int i = 0; i < 1; i++) {\n vec3 SLU = cc_lightPos[i].xyz - s.position;\n vec3 SL = normalize(SLU);\n vec3 SH = normalize(SL + V);\n float SNL = max(dot(N, SL), 0.001);\n float SNH = max(dot(N, SH), 0.0);\n float distSqr = dot(SLU, SLU);\n float litRadius = cc_lightSizeRangeAngle[i].x;\n float litRadiusSqr = litRadius * litRadius;\n float illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\n float attRadiusSqrInv = 1.0 / max(cc_lightSizeRangeAngle[i].y, 0.01);\n attRadiusSqrInv *= attRadiusSqrInv;\n float att = GetDistAtt(distSqr, attRadiusSqrInv);\n vec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\n if (cc_lightPos[i].w > 0.0) {\n float cosInner = max(dot(-cc_lightDir[i].xyz, SL), 0.01);\n float cosOuter = cc_lightSizeRangeAngle[i].z;\n float litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\n float litAngleOffset = -cosOuter * litAngleScale;\n att *= GetAngleAtt(SL, -cc_lightDir[i].xyz, litAngleScale, litAngleOffset);\n }\n vec3 lightColor = cc_lightColor[i].rgb;\n #if CC_RECEIVE_SHADOW\n if (cc_lightPos[i].w > 0.0) {\n {\n float pcf = cc_shadowInfo.z + 0.001;\n float shadowAttenuation = 0.0;\n if (pcf > 3.0) shadowAttenuation = CCGetDirLightShadowFactorX25();\n else if (3.0 > pcf && pcf > 2.0) shadowAttenuation = CCGetDirLightShadowFactorX9();\n else if (2.0 > pcf && pcf > 1.0) shadowAttenuation = CCGetDirLightShadowFactorX5();\n else shadowAttenuation = CCGetDirLightShadowFactorX1();\n lightColor *= 1.0 - shadowAttenuation;\n }\n }\n #endif\n finalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n }\n finalColor = finalColor * s.occlusion;\n return vec4(finalColor, 0.0);\n }\n#else\n vec4 CCStandardShading (StandardSurface s) {\n vec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\n vec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\n vec3 N = normalize(s.normal);\n vec3 V = normalize(cc_cameraPos.xyz - s.position);\n float NV = max(abs(dot(N, V)), 0.001);\n specular = BRDFApprox(specular, s.roughness, NV);\n vec3 L = normalize(-cc_mainLitDir.xyz);\n vec3 H = normalize(L+V);\n float NH = max(dot(N, H), 0.0);\n float NL = max(dot(N, L), 0.001);\n vec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w;\n #if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\n finalColor = s.lightmap.a * s.lightmap.rgb + (1.0 - s.lightmap.a) * finalColor;\n #endif\n vec3 diffuseContrib = diffuse / 3.14159265359;\n vec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\n finalColor *= (diffuseContrib + specularContrib);\n float fAmb = 0.5 - N.y * 0.5;\n vec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb) * cc_ambientSky.w;\n finalColor += (ambDiff.rgb * diffuse);\n #if CC_USE_IBL\n vec3 R = normalize(reflect(-V, N));\n vec4 envmap = fragTextureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n #if CC_USE_IBL == 2\n vec3 env = unpackRGBE(envmap);\n #else\n vec3 env = SRGBToLinear(envmap.rgb);\n #endif\n finalColor += env * cc_ambientSky.w * specular;\n #endif\n finalColor = finalColor * s.occlusion;\n #if CC_USE_HDR\n s.emissive *= cc_exposure.w;\n #endif\n finalColor += s.emissive;\n #if CC_RECEIVE_SHADOW\n {\n float pcf = cc_shadowInfo.z + 0.001;\n float shadowAttenuation = 0.0;\n if (pcf > 3.0) shadowAttenuation = CCGetShadowFactorX25();\n else if (3.0 > pcf && pcf > 2.0) shadowAttenuation = CCGetShadowFactorX9();\n else if (2.0 > pcf && pcf > 1.0) shadowAttenuation = CCGetShadowFactorX5();\n else shadowAttenuation = CCGetShadowFactorX1();\n vec3 shadowColor = cc_shadowColor.rgb * cc_shadowColor.a + finalColor.rgb * (1.0 - cc_shadowColor.a);\n finalColor.rgb = shadowColor.rgb * shadowAttenuation * NL + finalColor.rgb * (1.0 - shadowAttenuation * NL);\n }\n #endif\n return vec4(finalColor, s.albedo.a);\n }\n#endif\nvec3 ACESToneMap (vec3 color) {\n color = min(color, vec3(8.0));\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n #if !CC_USE_HDR\n color.rgb = sqrt(ACESToneMap(color.rgb));\n #endif\n return color;\n}\nin highp vec3 v_position;\nin mediump vec3 v_normal;\n#if USE_NORMALMAP\n in mediump vec3 v_tangent;\n in mediump vec3 v_binormal;\n#endif\nin mediump vec2 uvw;\nin mediump vec2 uv0;\nin mediump vec2 uv1;\nin mediump vec2 uv2;\nin mediump vec2 uv3;\nin mediump vec3 diffuse;\nin mediump vec2 luv;\nin mediump float v_fog_factor;\nlayout(std140) uniform PbrParams {\n vec4 metallic;\n vec4 roughness;\n};\nuniform sampler2D weightMap;\nuniform sampler2D detailMap0;\nuniform sampler2D detailMap1;\nuniform sampler2D detailMap2;\nuniform sampler2D detailMap3;\nuniform sampler2D normalMap0;\nuniform sampler2D normalMap1;\nuniform sampler2D normalMap2;\nuniform sampler2D normalMap3;\nuniform sampler2D lightMap;\nvoid surf (out StandardSurface s) {\n #if LAYERS > 1\n vec4 w = texture(weightMap, uvw);\n #endif\n vec4 baseColor = vec4(0, 0, 0, 0);\n #if LAYERS == 1\n baseColor = texture(detailMap0, uv0);\n #elif LAYERS == 2\n baseColor += texture(detailMap0, uv0) * w.r;\n baseColor += texture(detailMap1, uv1) * w.g;\n #elif LAYERS == 3\n baseColor += texture(detailMap0, uv0) * w.r;\n baseColor += texture(detailMap1, uv1) * w.g;\n baseColor += texture(detailMap2, uv2) * w.b;\n #elif LAYERS == 4\n baseColor += texture(detailMap0, uv0) * w.r;\n baseColor += texture(detailMap1, uv1) * w.g;\n baseColor += texture(detailMap2, uv2) * w.b;\n baseColor += texture(detailMap3, uv3) * w.a;\n #else\n baseColor = texture(detailMap0, uv0);\n #endif\n s.position = v_position;\n #if USE_NORMALMAP\n vec4 baseNormal = vec4(0, 0, 0, 0);\n #if LAYERS == 1\n baseNormal = texture(normalMap0, uv0);\n #elif LAYERS == 2\n baseNormal += texture(normalMap0, uv0) * w.r;\n baseNormal += texture(normalMap1, uv1) * w.g;\n #elif LAYERS == 3\n baseNormal += texture(normalMap0, uv0) * w.r;\n baseNormal += texture(normalMap1, uv1) * w.g;\n baseNormal += texture(normalMap2, uv2) * w.b;\n #elif LAYERS == 4\n baseNormal += texture(normalMap0, uv0) * w.r;\n baseNormal += texture(normalMap1, uv1) * w.g;\n baseNormal += texture(normalMap2, uv2) * w.b;\n baseNormal += texture(normalMap3, uv3) * w.a;\n #else\n baseNormal = texture(normalMap0, uv0);\n #endif\n vec3 nmmp = baseNormal.xyz - vec3(0.5);\n s.normal =\n nmmp.x * normalize(v_tangent) +\n nmmp.y * normalize(v_binormal) +\n nmmp.z * normalize(v_normal);\n #else\n s.normal = v_normal;\n #endif\n s.albedo = vec4(SRGBToLinear(baseColor.rgb), 1.0);\n s.occlusion = 1.0;\n #if USE_PBR\n s.roughness = 0.0;\n #if LAYERS == 1\n s.roughness = roughness.x;\n #elif LAYERS == 2\n s.roughness += roughness.x * w.r;\n s.roughness += roughness.y * w.g;\n #elif LAYERS == 3\n s.roughness += roughness.x * w.r;\n s.roughness += roughness.y * w.g;\n s.roughness += roughness.z * w.b;\n #elif LAYERS == 4\n s.roughness += roughness.x * w.r;\n s.roughness += roughness.y * w.g;\n s.roughness += roughness.z * w.b;\n s.roughness += roughness.w * w.a;\n #else\n s.roughness = 1.0;\n #endif\n s.metallic = 0.0;\n #if LAYERS == 1\n s.metallic = metallic.x;\n #elif LAYERS == 2\n s.metallic += metallic.x * w.r;\n s.metallic += metallic.y * w.g;\n #elif LAYERS == 3\n s.metallic += metallic.x * w.r;\n s.metallic += metallic.y * w.g;\n s.metallic += metallic.z * w.b;\n #elif LAYERS == 4\n s.metallic += metallic.x * w.r;\n s.metallic += metallic.y * w.g;\n s.metallic += metallic.z * w.b;\n s.metallic += metallic.w * w.a;\n #else\n s.metallic = 0.0;\n #endif\n #else\n s.roughness = 1.0;\n s.metallic = 0.0;\n #endif\n s.emissive = vec3(0.0, 0.0, 0.0);\n #if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\n s.lightmap = texture(lightMap, luv);\n #else\n s.lightmap = vec4(0.0, 0.0, 0.0, 0.0);\n #endif\n}\nvec4 frag () {\n StandardSurface s; surf(s);\n vec4 color = CCStandardShading(s);\n color = vec4(mix(CC_FORWARD_ADD > 0 ? vec3(0.0) : cc_fogColor.rgb, color.rgb, v_fog_factor), color.a);\n return CCFragOutput(color);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"},{vert:"\nprecision highp float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nlayout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n};\nlayout(std140) uniform CCShadow {\n highp mat4 cc_matLightPlaneProj;\n highp mat4 cc_matLightViewProj;\n lowp vec4 cc_shadowColor;\n lowp vec4 cc_shadowInfo;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nout vec2 v_clip_depth;\nvec4 vert () {\n vec4 worldPos;\n worldPos.x = cc_matWorld[3][0] + a_position.x;\n worldPos.y = cc_matWorld[3][1] + a_position.y;\n worldPos.z = cc_matWorld[3][2] + a_position.z;\n worldPos.w = 1.0;\n vec4 clipPos = cc_matLightViewProj * worldPos;\n v_clip_depth = clipPos.zw;\n return clipPos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nvec4 packDepthToRGBA (float depth) {\n vec4 ret = vec4(1.0, 255.0, 65025.0, 160581375.0) * depth;\n ret = fract(ret);\n ret -= ret.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n return ret;\n}\nin vec2 v_clip_depth;\nvec4 frag () {\n return packDepthToRGBA(v_clip_depth.x / v_clip_depth.y * 0.5 + 0.5);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\n rgba = rgba * 255.0;\n highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\n highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\n highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\n highp vec4 position;\n vec3 normal;\n vec4 tangent;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nin vec4 a_tangent;\n#if CC_USE_MORPH\n in float a_vertexId;\n int getVertexId() {\n return int(a_vertexId);\n }\nlayout(std140) uniform CCMorph {\n vec4 cc_displacementWeights[15];\n vec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\n float pixelIndexF = float(pixelIndex);\n float x = mod(pixelIndexF, textureResolution.x);\n float y = floor(pixelIndexF / textureResolution.x);\n return vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\n return (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_SUPPORT_FLOAT_TEXTURE\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\n ivec2 texSize = textureSize(tex, 0);\n return texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n }\n#else\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex * 4;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\n return vec4(\n decode32(texture(tex, x)),\n decode32(texture(tex, y)),\n decode32(texture(tex, z)),\n 1.0\n );\n }\n#endif\nfloat getDisplacementWeight(int index) {\n int quot = index / 4;\n int remainder = index - quot * 4;\n if (remainder == 0) {\n return cc_displacementWeights[quot].x;\n } else if (remainder == 1) {\n return cc_displacementWeights[quot].y;\n } else if (remainder == 2) {\n return cc_displacementWeights[quot].z;\n } else {\n return cc_displacementWeights[quot].w;\n }\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\n return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\n vec3 result = vec3(0, 0, 0);\n int nVertices = int(cc_displacementTextureInfo.z);\n for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\n result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n }\n return result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\n uniform sampler2D cc_PositionDisplacements;\n vec3 getPositionDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n uniform sampler2D cc_NormalDisplacements;\n vec3 getNormalDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n uniform sampler2D cc_TangentDisplacements;\n vec3 getTangentDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n }\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\n int vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\n attr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n attr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n attr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\n in vec4 a_joints;\nin vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n #if USE_INSTANCING\n in highp vec4 a_jointAnimInfo;\n #endif\n layout(std140) uniform CCSkinningTexture {\n highp vec4 cc_jointTextureInfo;\n };\n layout(std140) uniform CCSkinningAnimation {\n highp vec4 cc_jointAnimInfo;\n };\n uniform highp sampler2D cc_jointTexture;\n #else\n layout(std140) uniform CCSkinning {\n highp vec4 cc_joints[30 * 3];\n };\n#endif\n#if CC_USE_BAKED_ANIMATION\n #if CC_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\n vec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\n vec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n );\n vec4 v2 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n );\n vec4 v3 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n#else\n mat4 getJointMatrix (float i) {\n int idx = int(i);\n vec4 v1 = cc_joints[idx * 3];\n vec4 v2 = cc_joints[idx * 3 + 1];\n vec4 v3 = cc_joints[idx * 3 + 2];\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n#endif\nmat4 skinMatrix () {\n vec4 joints = vec4(a_joints);\n return getJointMatrix(joints.x) * a_weights.x\n + getJointMatrix(joints.y) * a_weights.y\n + getJointMatrix(joints.z) * a_weights.z\n + getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\n mat4 m = skinMatrix();\n position = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\n mat4 m = skinMatrix();\n attr.position = m * attr.position;\n attr.normal = (m * vec4(attr.normal, 0.0)).xyz;\n attr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\n#if USE_INSTANCING\n in vec4 a_matWorld0;\n in vec4 a_matWorld1;\n in vec4 a_matWorld2;\n #if USE_LIGHTMAP\n in vec4 a_lightingMapUVParam;\n #endif\n#elif USE_BATCHING\n in float a_dyn_batch_id;\n layout(std140) uniform CCLocalBatched {\n highp mat4 cc_matWorlds[10];\n };\n#else\nlayout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n};\n#endif\nfloat LinearFog(vec4 pos) {\n vec4 wPos = pos;\n float cam_dis = distance(cc_cameraPos, wPos);\n float fogStart = cc_fogBase.x;\n float fogEnd = cc_fogBase.y;\n return clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float fogDensity = cc_fogBase.z;\n float cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\n float f = exp(-cam_dis * fogDensity);\n return f;\n}\nfloat ExpSquaredFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float fogDensity = cc_fogBase.z;\n float cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\n float f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\n return f;\n}\nfloat LayeredFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float _FogTop = cc_fogAdd.x;\n float _FogRange = cc_fogAdd.y;\n vec3 camWorldProj = cc_cameraPos.xyz;\n camWorldProj.y = 0.;\n vec3 worldPosProj = wPos.xyz;\n worldPosProj.y = 0.;\n float fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\n float fDeltaY, fDensityIntegral;\n if (cc_cameraPos.y > _FogTop) {\n if (wPos.y < _FogTop) {\n fDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\n fDensityIntegral = fDeltaY * fDeltaY * 0.5;\n } else {\n fDeltaY = 0.;\n fDensityIntegral = 0.;\n }\n } else {\n if (wPos.y < _FogTop) {\n float fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\n float fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\n fDeltaY = abs(fDeltaA - fDeltaB);\n fDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n } else {\n fDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\n fDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n }\n }\n float fDensity;\n if (fDeltaY != 0.) {\n fDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n } else {\n fDensity = 0.;\n }\n float f = exp(-fDensity);\n return f;\n}\nfloat CC_TRANSFER_FOG(vec4 pos) {\n #if CC_USE_FOG == 0\n return LinearFog(pos);\n\t#elif CC_USE_FOG == 1\n return ExpFog(pos);\n #elif CC_USE_FOG == 2\n return ExpSquaredFog(pos);\n #elif CC_USE_FOG == 3\n return LayeredFog(pos);\n #endif\n return 1.;\n}\n#if USE_VERTEX_COLOR\n in lowp vec4 a_color;\n out lowp vec4 v_color;\n#endif\n#if USE_TEXTURE\n out vec2 v_uv;\n layout(std140) uniform TexCoords {\n vec4 tilingOffset;\n };\n#endif\nout float factor_fog;\nvec4 vert () {\n vec4 position;\n position = vec4(a_position, 1.0);\n #if CC_USE_MORPH\n applyMorph(position);\n #endif\n #if CC_USE_SKINNING\n CCSkin(position);\n #endif\n mat4 matWorld;\n #if USE_INSTANCING\n matWorld = mat4(\n vec4(a_matWorld0.xyz, 0.0),\n vec4(a_matWorld1.xyz, 0.0),\n vec4(a_matWorld2.xyz, 0.0),\n vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n );\n #elif USE_BATCHING\n matWorld = cc_matWorlds[int(a_dyn_batch_id)];\n #else\n matWorld = cc_matWorld;\n #endif\n #if USE_TEXTURE\n v_uv = a_texCoord * tilingOffset.xy + tilingOffset.zw;\n #endif\n #if USE_VERTEX_COLOR\n v_color = a_color;\n #endif\n factor_fog = CC_TRANSFER_FOG(matWorld * position);\n return cc_matProj * (cc_matView * matWorld) * position;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n #if CC_USE_HDR\n color.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n #endif\n return color;\n}\n#if USE_ALPHA_TEST\n#endif\n#if USE_TEXTURE\n in vec2 v_uv;\n uniform sampler2D mainTexture;\n#endif\nlayout(std140) uniform Constant {\n vec4 mainColor;\n vec4 colorScaleAndCutoff;\n};\n#if USE_VERTEX_COLOR\n in lowp vec4 v_color;\n#endif\nin float factor_fog;\nvec4 frag () {\n vec4 o = mainColor;\n o.rgb *= colorScaleAndCutoff.xyz;\n #if USE_VERTEX_COLOR\n o *= v_color;\n #endif\n #if USE_TEXTURE\n o *= texture(mainTexture, v_uv);\n #endif\n #if USE_ALPHA_TEST\n if (o.ALPHA_TEST_CHANNEL < colorScaleAndCutoff.w) discard;\n #endif\n o = vec4(mix(CC_FORWARD_ADD > 0 ? vec3(0.0) : cc_fogColor.rgb, o.rgb, factor_fog), o.a);\n return CCFragOutput(o);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\n rgba = rgba * 255.0;\n highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\n highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\n highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\n highp vec4 position;\n vec3 normal;\n vec4 tangent;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nin vec4 a_tangent;\n#if CC_USE_MORPH\n in float a_vertexId;\n int getVertexId() {\n return int(a_vertexId);\n }\nlayout(std140) uniform CCMorph {\n vec4 cc_displacementWeights[15];\n vec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\n float pixelIndexF = float(pixelIndex);\n float x = mod(pixelIndexF, textureResolution.x);\n float y = floor(pixelIndexF / textureResolution.x);\n return vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\n return (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_SUPPORT_FLOAT_TEXTURE\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\n ivec2 texSize = textureSize(tex, 0);\n return texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n }\n#else\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex * 4;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\n return vec4(\n decode32(texture(tex, x)),\n decode32(texture(tex, y)),\n decode32(texture(tex, z)),\n 1.0\n );\n }\n#endif\nfloat getDisplacementWeight(int index) {\n int quot = index / 4;\n int remainder = index - quot * 4;\n if (remainder == 0) {\n return cc_displacementWeights[quot].x;\n } else if (remainder == 1) {\n return cc_displacementWeights[quot].y;\n } else if (remainder == 2) {\n return cc_displacementWeights[quot].z;\n } else {\n return cc_displacementWeights[quot].w;\n }\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\n return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\n vec3 result = vec3(0, 0, 0);\n int nVertices = int(cc_displacementTextureInfo.z);\n for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\n result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n }\n return result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\n uniform sampler2D cc_PositionDisplacements;\n vec3 getPositionDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n uniform sampler2D cc_NormalDisplacements;\n vec3 getNormalDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n uniform sampler2D cc_TangentDisplacements;\n vec3 getTangentDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n }\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\n int vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\n attr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n attr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n attr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\n in vec4 a_joints;\nin vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n #if USE_INSTANCING\n in highp vec4 a_jointAnimInfo;\n #endif\n layout(std140) uniform CCSkinningTexture {\n highp vec4 cc_jointTextureInfo;\n };\n layout(std140) uniform CCSkinningAnimation {\n highp vec4 cc_jointAnimInfo;\n };\n uniform highp sampler2D cc_jointTexture;\n #else\n layout(std140) uniform CCSkinning {\n highp vec4 cc_joints[30 * 3];\n };\n#endif\n#if CC_USE_BAKED_ANIMATION\n #if CC_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\n vec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\n vec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n );\n vec4 v2 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n );\n vec4 v3 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n#else\n mat4 getJointMatrix (float i) {\n int idx = int(i);\n vec4 v1 = cc_joints[idx * 3];\n vec4 v2 = cc_joints[idx * 3 + 1];\n vec4 v3 = cc_joints[idx * 3 + 2];\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n#endif\nmat4 skinMatrix () {\n vec4 joints = vec4(a_joints);\n return getJointMatrix(joints.x) * a_weights.x\n + getJointMatrix(joints.y) * a_weights.y\n + getJointMatrix(joints.z) * a_weights.z\n + getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\n mat4 m = skinMatrix();\n position = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\n mat4 m = skinMatrix();\n attr.position = m * attr.position;\n attr.normal = (m * vec4(attr.normal, 0.0)).xyz;\n attr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\n#if USE_INSTANCING\n in vec4 a_matWorld0;\n in vec4 a_matWorld1;\n in vec4 a_matWorld2;\n #if USE_LIGHTMAP\n in vec4 a_lightingMapUVParam;\n #endif\n#elif USE_BATCHING\n in float a_dyn_batch_id;\n layout(std140) uniform CCLocalBatched {\n highp mat4 cc_matWorlds[10];\n };\n#else\nlayout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n};\n#endif\nlayout(std140) uniform CCShadow {\n highp mat4 cc_matLightPlaneProj;\n highp mat4 cc_matLightViewProj;\n lowp vec4 cc_shadowColor;\n lowp vec4 cc_shadowInfo;\n};\nvec4 vert () {\n vec4 position;\n position = vec4(a_position, 1.0);\n #if CC_USE_MORPH\n applyMorph(position);\n #endif\n #if CC_USE_SKINNING\n CCSkin(position);\n #endif\n mat4 matWorld;\n #if USE_INSTANCING\n matWorld = mat4(\n vec4(a_matWorld0.xyz, 0.0),\n vec4(a_matWorld1.xyz, 0.0),\n vec4(a_matWorld2.xyz, 0.0),\n vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n );\n #elif USE_BATCHING\n matWorld = cc_matWorlds[int(a_dyn_batch_id)];\n #else\n matWorld = cc_matWorld;\n #endif\n position = cc_matProj * (cc_matView * cc_matLightPlaneProj * matWorld) * position;\n position.z -= 0.0001;\n return position;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision mediump float;\nlayout(std140) uniform CCShadow {\n highp mat4 cc_matLightPlaneProj;\n highp mat4 cc_matLightViewProj;\n lowp vec4 cc_shadowColor;\n lowp vec4 cc_shadowInfo;\n};\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n #if CC_USE_HDR\n color.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n #endif\n return color;\n}\nvec4 frag () {\n return CCFragOutput(cc_shadowColor);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nstruct StandardVertInput {\n highp vec4 position;\n vec3 normal;\n vec4 tangent;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nin vec4 a_tangent;\nout mediump vec4 viewDir;\nvec4 vert () {\n viewDir = vec4(a_position, 1.0);\n mat4 matViewRotOnly = mat4(mat3(cc_matView));\n mat4 matProj = cc_matProj;\n if (matProj[3].w > 0.0) {\n vec2 scale = vec2(48.0, 24.0);\n matProj[0].xy *= scale;\n matProj[1].xy *= scale;\n matProj[2].zw = vec2(-1.0);\n matProj[3].zw = vec2(0.0);\n }\n vec4 pos = matProj * matViewRotOnly * viewDir;\n pos.z = 0.99999 * pos.w;\n return pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nuniform samplerCube cc_environment;\nvec3 unpackRGBE (vec4 rgbe) {\n return rgbe.rgb * pow(2.0, rgbe.a * 255.0 - 128.0);\n}\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec3 ACESToneMap (vec3 color) {\n color = min(color, vec3(8.0));\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n #if !CC_USE_HDR\n color.rgb = sqrt(ACESToneMap(color.rgb));\n #endif\n return color;\n}\nin mediump vec4 viewDir;\nvec4 frag () {\n #if USE_RGBE_CUBEMAP\n vec3 c = unpackRGBE(texture(cc_environment, viewDir.xyz));\n #else\n vec3 c = SRGBToLinear(texture(cc_environment, viewDir.xyz).rgb);\n #endif\n return CCFragOutput(vec4(c * cc_ambientSky.w, 1.0));\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}],[{vert:"\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nin vec3 a_position;\nin vec4 a_color;\nout vec2 v_uv;\nlayout(std140) uniform Constants {\n vec4 offset;\n};\nlayout(std140) uniform PerFrameInfo {\n vec4 digits[8 * 10 / 4];\n};\nfloat getComponent(vec4 v, float i) {\n if (i < 1.0) { return v.x; }\n else if (i < 2.0) { return v.y; }\n else if (i < 3.0) { return v.z; }\n else { return v.w; }\n}\nvec4 vert () {\n vec4 position = cc_matViewProj * vec4(a_position, 1.0);\n position.xy += offset.xy;\n v_uv = a_color.xy;\n if (a_color.z >= 0.0) {\n float n = getComponent(digits[int(a_color.z)], a_color.w);\n v_uv += vec2(offset.z * n, 0.0);\n }\n return position;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n #if CC_USE_HDR\n color.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n #endif\n return color;\n}\nin vec2 v_uv;\nuniform sampler2D mainTexture;\nvec4 frag () {\n return CCFragOutput(texture(mainTexture, v_uv));\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}],[{vert:"\nprecision mediump float;\nin vec2 a_position;\nin vec2 a_texCoord;\nout vec2 v_uv;\nvec4 vert () {\n vec4 pos = vec4(a_position, 0, 1);\n v_uv = a_texCoord;\n return pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision mediump float;\nin vec2 v_uv;\nuniform sampler2D mainTexture;\nlayout(std140) uniform splashFrag {\n float u_precent;\n};\nvec4 frag () {\n vec4 color = texture(mainTexture, v_uv);\n float precent = clamp(u_precent, 0.0, 1.0);\n color.xyz *= precent;\n return color;\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}]]},qd=function(){function e(){this._device=null,this._resources={}}var t=e.prototype;return t.initBuiltinRes=function(e){var t=this;this._device=e;var n=this._resources,r=document.createElement("canvas"),a=r.getContext("2d"),s=new G_(r),o=r.width=r.height=2;a.fillStyle="#000",a.fillRect(0,0,o,o);var c=new md;c._uuid="black-texture",c.image=s,n[c._uuid]=c,a.fillStyle="rgba(0,0,0,0)",a.fillRect(0,0,o,o);for(var l=new Uint8Array(16),u=0;u<l.length;++u)l[u]=0;var h=new md;h._uuid="empty-texture",h.image=s,h.uploadData(l),n[h._uuid]=h;var _=new gd;_._uuid="black-cube-texture",_.setMipFilter(gd.Filter.NEAREST),_.image={front:new G_(r),back:new G_(r),left:new G_(r),right:new G_(r),top:new G_(r),bottom:new G_(r)},n[_._uuid]=_,a.fillStyle="#777",a.fillRect(0,0,o,o);var f=new md;f._uuid="grey-texture",f.image=s,n[f._uuid]=f,a.fillStyle="#fff",a.fillRect(0,0,o,o);var d=new md;d._uuid="white-texture",d.image=s,n[d._uuid]=d;var p=new gd;p._uuid="white-cube-texture",p.setMipFilter(gd.Filter.NEAREST),p.image={front:new G_(r),back:new G_(r),left:new G_(r),right:new G_(r),top:new G_(r),bottom:new G_(r)},n[p._uuid]=p,a.fillStyle="#7f7fff",a.fillRect(0,0,o,o);var m=new md;m._uuid="normal-texture",m.image=s,n[m._uuid]=m,r.width=r.height=16,a.fillStyle="#ddd",a.fillRect(0,0,16,16),a.fillStyle="#555",a.fillRect(0,0,8,8),a.fillStyle="#555",a.fillRect(8,8,8,8);var g=new md;g._uuid="default-texture",g.image=s,n[g._uuid]=g;var v=new gd;if(v.setMipFilter(gd.Filter.NEAREST),v._uuid="default-cube-texture",v.image={front:new G_(r),back:new G_(r),left:new G_(r),right:new G_(r),top:new G_(r),bottom:new G_(r)},n[v._uuid]=v,i.SpriteFrame){var y=new i.SpriteFrame,S=s._texture;y.texture=S,y._uuid="default-spriteframe",n[y._uuid]=y}var E=Gd(e);if(!E)return Promise.reject(Error("Failed to initialize builtin shaders: unknown device."));var T=jd[E];return T?Promise.resolve().then((function(){Td.forEach((function(e,t){var n=Object.assign(new i.EffectAsset,e);n.shaders.forEach((function(e,n){var i=T[t][n];i&&(e[E]=i)})),n.hideInEditor=!0,n.onLoaded()})),t._initMaterials()})):Promise.reject(Error("Current device is requiring builtin shaders of version "+E+" but shaders of that version are not assembled in this build."))},t.get=function(e){return this._resources[e]},t._initMaterials=function(){var e=this._resources,t=[],n=new i.Material;n._uuid="standard-material",n.initialize({effectName:"standard"}),e[n._uuid]=n,t.push(n);var r=new i.Material;r._uuid="missing-effect-material",r.initialize({effectName:"unlit",defines:{USE_COLOR:!0}}),r.setProperty("mainColor",i.color("#ffff00")),e[r._uuid]=r,t.push(r);var a=new i.Material;a._uuid="missing-material",a.initialize({effectName:"unlit",defines:{USE_COLOR:!0}}),a.setProperty("mainColor",i.color("#ff00ff")),e[a._uuid]=a,t.push(a);var s=new i.Material;s._uuid="default-clear-stencil",s.initialize({defines:{USE_TEXTURE:!1},effectName:"clear-stencil"}),e[s._uuid]=s,t.push(s);var o=new i.Material;o._uuid="ui-base-material",o.initialize({defines:{USE_TEXTURE:!1},effectName:"sprite"}),e[o._uuid]=o,t.push(o);var c=new i.Material;c._uuid="ui-sprite-material",c.initialize({defines:{USE_TEXTURE:!0,CC_USE_EMBEDDED_ALPHA:!1,IS_GRAY:!1},effectName:"sprite"}),e[c._uuid]=c,t.push(c);var l=new i.Material;l._uuid="ui-alpha-test-material",l.initialize({defines:{USE_TEXTURE:!0,USE_ALPHA_TEST:!0,CC_USE_EMBEDDED_ALPHA:!1,IS_GRAY:!1},effectName:"sprite"}),e[l._uuid]=l,t.push(l);var u=new i.Material;u._uuid="ui-sprite-gray-material",u.initialize({defines:{USE_TEXTURE:!0,CC_USE_EMBEDDED_ALPHA:!1,IS_GRAY:!0},effectName:"sprite"}),e[u._uuid]=u,t.push(u);var h=new i.Material;h._uuid="ui-sprite-alpha-sep-material",h.initialize({defines:{USE_TEXTURE:!0,CC_USE_EMBEDDED_ALPHA:!0,IS_GRAY:!1},effectName:"sprite"}),e[h._uuid]=h,t.push(h);var _=new i.Material;_._uuid="ui-sprite-gray-alpha-sep-material",_.initialize({defines:{USE_TEXTURE:!0,CC_USE_EMBEDDED_ALPHA:!0,IS_GRAY:!0},effectName:"sprite"}),e[_._uuid]=_,t.push(_);var f=new i.Material;f._uuid="ui-graphics-material",f.initialize({effectName:"graphics"}),e[f._uuid]=f,t.push(f);var d=new i.Material;d._uuid="default-particle-material",d.initialize({effectName:"particle"}),e[d._uuid]=d,t.push(d);var p=new i.Material;p._uuid="default-particle-gpu-material",p.initialize({effectName:"particle-gpu"}),e[p._uuid]=p,t.push(p);var m=new i.Material;m._uuid="default-trail-material",m.initialize({effectName:"particle-trail"}),e[m._uuid]=m,t.push(m);var g=new i.Material;g._uuid="default-billboard-material",g.initialize({effectName:"billboard"}),e[g._uuid]=g,t.push(g);var v=new i.Material;v._uuid="default-spine-material",v.initialize({defines:{USE_TEXTURE:!0,CC_USE_EMBEDDED_ALPHA:!1,IS_GRAY:!1},effectName:"spine"}),e[v._uuid]=v,t.push(v),i.game.on(i.Game.EVENT_RENDERER_INITED,(function(){for(var e=0;e<t.length;++e)for(var n=t[e],i=0;i<n.passes.length;++i)n.passes[i].tryCompile()}))},e}(),Xd=e("builtinResMgr",i.builtinResMgr=new qd),Yd=e("getPhaseID",(Hd=new Map,Vd=0,function(e){return"number"==typeof e?e:(Hd.has(e)||(Hd.set(e,1<<Vd),Vd++),Hd.get(e))})),Kd=new Ps(Ua.UNIFORM|Ua.TRANSFER_DST,Ga.HOST|Ga.DEVICE),Zd=new Ms(null),Qd=new Po(null);!function(e){e[e.INSTANCING=1]="INSTANCING",e[e.VB_MERGING=2]="VB_MERGING"}(Wd||(Wd={}));var Jd=function(){function e(e){this._rootBuffer=null,this._rootBufferDirty=!1,this._buffers=[],this._descriptorSet=null,this._passIndex=0,this._propertyIndex=0,this._programName="",this._dynamics={},this._propertyHandleMap={},this._rootBlock=null,this._blocks=[],this._shaderInfo=null,this._defines={},this._properties={},this._root=void 0,this._device=void 0,this._hShaderDefault=0,this._handle=0,this._bs=new ro,this._dss=new no,this._rs=new to,this._root=e,this._device=e.device}e.fillPipelineInfo=function(e,t){var n=e.handle;void 0!==t.priority&&er.set(n,Fi.PRIORITY,t.priority),void 0!==t.primitive&&er.set(n,Fi.PRIMITIVE,t.primitive),void 0!==t.stage&&er.set(n,Fi.STAGE,t.stage),void 0!==t.dynamicStates&&er.set(n,Fi.DYNAMIC_STATES,t.dynamicStates),void 0!==t.phase&&er.set(n,Fi.PHASE,Yd(t.phase));var i=e._bs;if(t.blendState){var r=t.blendState,a=r.targets;a&&a.forEach((function(e,t){i.setTarget(t,e)})),void 0!==r.isA2C&&(i.isA2C=r.isA2C),void 0!==r.isIndepend&&(i.isIndepend=r.isIndepend),void 0!==r.blendColor&&(i.blendColor=r.blendColor)}e._rs.assign(t.rasterizerState),e._dss.assign(t.depthStencilState)},e.getPassHash=function(e,t){var n,i=e.handle,r=t+","+er.get(i,Fi.PRIMITIVE)+","+er.get(i,Fi.DYNAMIC_STATES);return r+=function(e){for(var t,n=",bs,"+e.isA2C,i=Z(e.targets);!(t=i()).done;){var r=t.value;n+=",bt,"+r.blend+","+r.blendEq+","+r.blendAlphaEq+","+r.blendColorMask,n+=","+r.blendSrc+","+r.blendDst+","+r.blendSrcAlpha+","+r.blendDstAlpha}return n}(e._bs),r+=function(e){var t=",dss,"+e.depthTest+","+e.depthWrite+","+e.depthFunc;return t+=","+e.stencilTestFront+","+e.stencilFuncFront+","+e.stencilRefFront+","+e.stencilReadMaskFront,t+=","+e.stencilFailOpFront+","+e.stencilZFailOpFront+","+e.stencilPassOpFront+","+e.stencilWriteMaskFront,(t+=","+e.stencilTestBack+","+e.stencilFuncBack+","+e.stencilRefBack+","+e.stencilReadMaskBack)+","+e.stencilFailOpBack+","+e.stencilZFailOpBack+","+e.stencilPassOpBack+","+e.stencilWriteMaskBack}(e._dss),Vs(r+=",rs,"+(n=e._rs).cullMode+","+n.depthBias+","+n.isFrontFaceCCW,666)};var t=e.prototype;return t.initialize=function(e){this._doInit(e),this.resetUBOs(),this.resetTextures(),this.tryCompile()},t.getHandle=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=Fa.UNKNOWN);var i=this._propertyHandleMap[e];return i?(n?i=wd(i,n):t&&(i=wd(i,Cd(i)-t)),i+t):0},t.getBinding=function(t){var n=this.getHandle(t);return n?e.getBindingFromHandle(n):-1},t.setUniform=function(t,n){var i=e.getBindingFromHandle(t),r=e.getTypeFromHandle(t),a=e.getOffsetFromHandle(t),s=this._blocks[i];Od[r](s,n,a),this._rootBufferDirty=!0},t.getUniform=function(t,n){var i=e.getBindingFromHandle(t),r=e.getTypeFromHandle(t),a=e.getOffsetFromHandle(t),s=this._blocks[i];return Id[r](s,n,a)},t.setUniformArray=function(t,n){for(var i=e.getBindingFromHandle(t),r=e.getTypeFromHandle(t),a=Rs(r)>>2,s=this._blocks[i],o=e.getOffsetFromHandle(t),c=0;c<n.length;c++,o+=a)null!==n[c]&&Od[r](s,n[c],o);this._rootBufferDirty=!0},t.bindTexture=function(e,t,n){this._descriptorSet.bindTexture(e,t,n||0)},t.bindSampler=function(e,t,n){this._descriptorSet.bindSampler(e,t,n||0)},t.setDynamicState=function(e,t){var n=this._dynamics[e];n&&n.value===t||(n.value=t,n.dirty=!0)},t.overridePipelineStates=function(){console.warn("base pass cannot override states, please use pass instance instead.")},t.update=function(){this._rootBufferDirty&&this._rootBuffer&&(this._rootBuffer.update(this._rootBlock),this._rootBufferDirty=!1),this._descriptorSet.update()},t.destroy=function(){for(var e=0;e<this._shaderInfo.blocks.length;e++){var t=this._shaderInfo.blocks[e];this._buffers[t.binding].destroy()}this._buffers=[],this._rootBuffer&&(this._rootBuffer.destroy(),this._rootBlock=null),this._descriptorSet=null,this._rs.destroy(),this._dss.destroy(),this._bs.destroy(),this._handle&&(Ui.free(er.get(this._handle,Fi.DESCRIPTOR_SET)),er.free(this._handle),this._handle=0)},t.resetUniform=function(t){var n=this.getHandle(t);if(n){var i=e.getTypeFromHandle(n),r=e.getBindingFromHandle(n),a=e.getOffsetFromHandle(n),s=this._blocks[r],o=this._properties[t],c=o&&o.value||Md(i);Od[i](s,c,a),this._rootBufferDirty=!0}},t.resetTexture=function(t,n){var i=this.getHandle(t);if(i){var r=e.getTypeFromHandle(i),a=e.getBindingFromHandle(i),s=this._properties[t],o=s&&s.value,c=o?o+"-texture":Md(r),l=Xd.get(c),u=l&&l.getGFXTexture(),h=s&&void 0!==s.samplerHash?s.samplerHash:l&&l.getSamplerHash(),_=af.getSampler(this._device,h);this._descriptorSet.bindSampler(a,_,n),this._descriptorSet.bindTexture(a,u,n)}},t.resetUBOs=function(){for(var e=0;e<this._shaderInfo.blocks.length;e++)for(var t=this._shaderInfo.blocks[e],n=this._blocks[t.binding],i=0,r=0;r<t.members.length;r++){for(var a=t.members[r],s=this._properties[a.name],o=s&&s.value||Md(a.type),c=(Rs(a.type)>>2)*a.count,l=0;l+o.length<=c;l+=o.length)n.set(o,i+l);i+=c}this._rootBufferDirty=!0},t.resetTextures=function(){for(var e=0;e<this._shaderInfo.samplers.length;e++)for(var t=this._shaderInfo.samplers[e],n=0;n<t.count;n++)this.resetTexture(t.name,n)},t.tryCompile=function(){var t=this._root.pipeline;return!!t&&(this._syncBatchingScheme(),this._hShaderDefault=kd.getGFXShader(this._device,this._programName,this._defines,t),this._hShaderDefault?(er.set(this._handle,Fi.PIPELINE_LAYOUT,kd.getTemplateInfo(this._programName).hPipelineLayout),er.set(this._handle,Fi.HASH,e.getPassHash(this,this._hShaderDefault)),!0):(console.warn("create shader "+this._programName+" failed"),!1))},t.getShaderVariant=function(e){if(void 0===e&&(e=null),!this._hShaderDefault&&!this.tryCompile())return console.warn("pass resources incomplete"),0;if(!e)return this._hShaderDefault;for(var t=this._root.pipeline,n=0;n<e.length;n++){var i=e[n];this._defines[i.name]=i.value}for(var r=kd.getGFXShader(this._device,this._programName,this._defines,t),a=0;a<e.length;a++){var s=e[a];delete this._defines[s.name]}return r},t.beginChangeStatesSilently=function(){},t.endChangeStatesSilently=function(){},t._doInit=function(t,n){void 0===n&&(n=!1);var i=this._handle=er.alloc();er.set(i,Fi.PRIORITY,Dl.DEFAULT),er.set(i,Fi.STAGE,Nl.DEFAULT),er.set(i,Fi.PHASE,Yd("default")),er.set(i,Fi.PRIMITIVE,Va.TRIANGLE_LIST),er.set(i,Fi.RASTERIZER_STATE,this._rs.handle),er.set(i,Fi.DEPTH_STENCIL_STATE,this._dss.handle),er.set(i,Fi.BLEND_STATE,this._bs.handle),this._passIndex=t.passIndex,this._propertyIndex=void 0!==t.propertyIndex?t.propertyIndex:t.passIndex,this._programName=t.program,this._defines=n?q({},t.defines):t.defines,this._shaderInfo=kd.getTemplate(t.program),this._properties=t.properties||this._properties;var r=this._device;e.fillPipelineInfo(this,t),t.stateOverrides&&e.fillPipelineInfo(this,t.stateOverrides),Qd.layout=kd.getDescriptorSetLayout(this._device,t.program);var a=Ui.alloc(this._device,Qd);er.set(this._handle,Fi.DESCRIPTOR_SET,a),this._descriptorSet=Ui.get(a);for(var s=this._shaderInfo.blocks,o=kd.getTemplateInfo(t.program),c=o.blockSizes,l=o.handleMap,u=r.uboOffsetAlignment,h=[],_=0,f=0,d=0;d<s.length;d++){var p=c[d];h.push(f),f+=Math.ceil(p/u)*u,_=p}var m=h[h.length-1]+_;m&&(Kd.size=16*Math.ceil(m/16),this._rootBuffer=r.createBuffer(Kd),this._rootBlock=new ArrayBuffer(m));for(var g=0,v=0;g<s.length;g++){var y=s[g].binding,S=c[g];Zd.buffer=this._rootBuffer,Zd.offset=h[v++],Zd.range=16*Math.ceil(S/16);var E=this._buffers[y]=r.createBuffer(Zd);this._blocks[y]=new Float32Array(this._rootBlock,Zd.offset,S/Float32Array.BYTES_PER_ELEMENT),this._descriptorSet.bindBuffer(y,E)}var T=this._propertyHandleMap=l,A={};for(var x in this._properties){var C=this._properties[x];C.handleInfo&&(A[x]=this.getHandle.apply(this,C.handleInfo))}Object.assign(T,A)},t._syncBatchingScheme=function(){this._defines.USE_INSTANCING?this._device.hasFeature(vs.INSTANCED_ARRAYS)?er.set(this._handle,Fi.BATCHING_SCHEME,Wd.INSTANCING):(this._defines.USE_INSTANCING=!1,er.set(this._handle,Fi.BATCHING_SCHEME,0)):this._defines.USE_BATCHING?er.set(this._handle,Fi.BATCHING_SCHEME,Wd.VB_MERGING):er.set(this._handle,Fi.BATCHING_SCHEME,0)},t._destroyHandle=function(){this._handle&&(er.free(this._handle),this._handle=0)},t._initPassFromTarget=function(e,t,n,i){er.set(this.handle,Fi.PRIORITY,e.priority),er.set(this.handle,Fi.STAGE,e.stage),er.set(this.handle,Fi.PHASE,e.phase),er.set(this.handle,Fi.BATCHING_SCHEME,e.batchingScheme),er.set(this.handle,Fi.PRIMITIVE,e.primitive),er.set(this.handle,Fi.DYNAMIC_STATES,e.dynamicStates),this._descriptorSet=e.descriptorSet,er.set(this.handle,Fi.DESCRIPTOR_SET,er.get(e.handle,Fi.DESCRIPTOR_SET)),this._bs=n,er.set(this.handle,Fi.BLEND_STATE,n.handle),this._rs=e.rasterizerState,er.set(this.handle,Fi.RASTERIZER_STATE,er.get(e.handle,Fi.RASTERIZER_STATE)),this._dss=t,er.set(this.handle,Fi.DEPTH_STENCIL_STATE,t.handle),this._passIndex=e.passIndex,this._propertyIndex=e.propertyIndex,this._programName=e.program,this._defines=e.defines,this._shaderInfo=e._shaderInfo,this._properties=e._properties,this._blocks=e._blocks,this._dynamics=e._dynamics,this._hShaderDefault=e._hShaderDefault,er.set(this._handle,Fi.PIPELINE_LAYOUT,kd.getTemplateInfo(this._programName).hPipelineLayout);var r=er.get(e.handle,Fi.HASH);er.set(this._handle,Fi.HASH,r^i)},j(e,[{key:"root",get:function(){return this._root}},{key:"device",get:function(){return this._device}},{key:"shaderInfo",get:function(){return this._shaderInfo}},{key:"localSetLayout",get:function(){return kd.getDescriptorSetLayout(this._device,this._programName,!0)}},{key:"program",get:function(){return this._programName}},{key:"properties",get:function(){return this._properties}},{key:"defines",get:function(){return this._defines}},{key:"passIndex",get:function(){return this._passIndex}},{key:"propertyIndex",get:function(){return this._propertyIndex}},{key:"dynamics",get:function(){return this._dynamics}},{key:"blocks",get:function(){return this._blocks}},{key:"handle",get:function(){return this._handle}},{key:"priority",get:function(){return er.get(this._handle,Fi.PRIORITY)}},{key:"primitive",get:function(){return er.get(this._handle,Fi.PRIMITIVE)}},{key:"stage",get:function(){return er.get(this._handle,Fi.STAGE)}},{key:"phase",get:function(){return er.get(this._handle,Fi.PHASE)}},{key:"rasterizerState",get:function(){return this._rs}},{key:"depthStencilState",get:function(){return this._dss}},{key:"blendState",get:function(){return this._bs}},{key:"dynamicStates",get:function(){return er.get(this._handle,Fi.DYNAMIC_STATES)}},{key:"batchingScheme",get:function(){return er.get(this._handle,Fi.BATCHING_SCHEME)}},{key:"descriptorSet",get:function(){return this._descriptorSet}},{key:"hash",get:function(){return er.get(this._handle,Fi.HASH)}},{key:"rootBufferDirty",get:function(){return this._rootBufferDirty}}]),e}();Jd.PropertyType=Ed,Jd.getPropertyTypeFromHandle=xd,Jd.getTypeFromHandle=Cd,Jd.getBindingFromHandle=Rd,Jd.getOffsetFromHandle=bd,oe(Ku.prototype,"RenderScene.prototype",[{name:"raycastUI2DNode"},{name:"raycastUINode"}]),oe(Ku.prototype,"RenderScene.prototype",[{name:"raycastAll",suggest:"using intersect.rayModel in geometry"},{name:"raycastAllModels",suggest:"using intersect.rayModel in geometry"},{name:"raycastSingleModel",suggest:"using intersect.rayModel in geometry"},{name:"raycastAllCanvas",suggest:"using intersect.rayAABB in geometry"},{name:"rayResultCanvas"},{name:"rayResultModels"},{name:"rayResultAll"},{name:"rayResultSingleModel"}]);var $d={};oe($d,"CameraVisFlags",[{name:"GENERAL"}]),se($d,"CameraVisFlags",[{name:"PROFILER",newName:"PROFILER",target:Ll.BitMask,targetName:"PROFILER"},{name:"GIZMOS",newName:"GIZMOS",target:Ll.BitMask,targetName:"GIZMOS"},{name:"EDITOR",newName:"EDITOR",target:Ll.BitMask,targetName:"EDITOR"},{name:"UI",newName:"UI",target:Ll.BitMask,targetName:"UI_3D"},{name:"UI2D",newName:"UI2D",target:Ll.BitMask,targetName:"UI_2D"}]),i.CameraVisFlags=$d;var ep,tp={};function np(e,t){t<1e3?t=1e3:t>15e3&&(t=15e3);var n=t*t,i=(.860117757+.000154118254*t+1.28641212e-7*n)/(1+.000842420235*t+7.08145163e-7*n),r=(.317398726+422806245e-13*t+4.20481691e-8*n)/(1-289741816e-13*t+1.61456053e-7*n),a=2*i-8*r+4,s=3*i/a,o=2*r/a,c=1/o*s,l=1/o*(1-s-o);e.x=3.2404542*c-1.5371385+-.4985314*l,e.y=-.969266*c+1.8760108+.041556*l,e.z=.0556434*c-.2040259+1.0572252*l}oe(tp,"VisibilityFlags",[{name:"GENERAL"}]),se(tp,"VisibilityFlags",[{name:"ALWALS",newName:"ALWALS",target:Ll.Enum,targetName:"ALWALS"},{name:"PROFILER",newName:"PROFILER",target:Ll.Enum,targetName:"PROFILER"},{name:"GIZMOS",newName:"GIZMOS",target:Ll.Enum,targetName:"GIZMOS"},{name:"EDITOR",newName:"EDITOR",target:Ll.Enum,targetName:"EDITOR"},{name:"UI",newName:"UI",target:Ll.Enum,targetName:"UI_3D"},{name:"UI2D",newName:"UI2D",target:Ll.Enum,targetName:"UI_2D"}]),i.VisibilityFlags=tp,se(Jd.prototype,"Pass.prototype",[{name:"getBindingTypeFromHandle",newName:"getDescriptorTypeFromHandle"}]),oe(Yu.prototype,"Camera.prototype",[{name:"getSplitFrustum"}]),function(e){e[e.DIRECTIONAL=0]="DIRECTIONAL",e[e.SPHERE=1]="SPHERE",e[e.SPOT=2]="SPOT",e[e.UNKNOWN=3]="UNKNOWN"}(ep||(ep={}));var ip=function(e){return 4*Math.PI*Math.PI*e*e},rp=function(){function e(){this._baked=!1,this._color=new bn(1,1,1),this._colorTemp=6550,this._colorTempRGB=new bn(1,1,1),this._scene=null,this._node=null,this._name=null,this._handle=0}var t=e.prototype;return t.initialize=function(){this._handle=jr.alloc(),jr.setVec3(this._handle,kr.COLOR,this._color),jr.setVec3(this._handle,kr.COLOR_TEMPERATURE_RGB,this._colorTempRGB),jr.set(this._handle,kr.TYPE,ep.UNKNOWN)},t.attachToScene=function(e){this._scene=e},t.detachFromScene=function(){this._scene=null},t.destroy=function(){this._name=null,this._node=null,this._handle&&(jr.free(this._handle),this._handle=0)},t.update=function(){},j(e,[{key:"baked",get:function(){return this._baked},set:function(e){this._baked=e}},{key:"color",set:function(e){this._color.set(e),jr.setVec3(this._handle,kr.COLOR,e)},get:function(){return this._color}},{key:"useColorTemperature",set:function(e){jr.set(this._handle,kr.USE_COLOR_TEMPERATURE,e?1:0)},get:function(){return 1===jr.get(this._handle,kr.USE_COLOR_TEMPERATURE)}},{key:"colorTemperature",set:function(e){this._colorTemp=e,np(this._colorTempRGB,this._colorTemp),jr.setVec3(this._handle,kr.COLOR_TEMPERATURE_RGB,this._colorTempRGB)},get:function(){return this._colorTemp}},{key:"colorTemperatureRGB",get:function(){return this._colorTempRGB}},{key:"node",set:function(e){this._node=e,this._node&&(this._node.hasChangedFlags|=Uu.ROTATION,jr.set(this._handle,kr.NODE,this._node.handle))},get:function(){return this._node}},{key:"type",get:function(){return jr.get(this._handle,kr.TYPE)}},{key:"name",get:function(){return this._name},set:function(e){this._name=e}},{key:"scene",get:function(){return this._scene}},{key:"handle",get:function(){return this._handle}}]),e}(),ap=new bn(0,0,-1),sp=new bn,op=function(e){function t(){var t;return(t=e.call(this)||this)._dir=new bn(1,-1,-1),t._shadowRange=1e3,t._shadowIntensity=0,t._shadowFadeDistance=0,t._shadowDistance=0,t._fadeStart=.8,t._splits=new Zn(1,0,0,0),t._biasAutoAdjust=1,t}X(t,e),j(t,[{key:"shadowRange",set:function(e){this._shadowRange=e},get:function(){return this._shadowRange}},{key:"shadowIntensitywRange",set:function(e){this._shadowIntensity=e}},{key:"shadowIntensity",get:function(){return this._shadowIntensity}},{key:"shadowFadeDistance",set:function(e){this._shadowFadeDistance=e},get:function(){return this._shadowFadeDistance}},{key:"shadowDistance",set:function(e){this._shadowDistance=e},get:function(){return this._shadowDistance}},{key:"fadeStart",set:function(e){this._fadeStart=e},get:function(){return this._fadeStart}},{key:"splits",set:function(e){this._splits=e},get:function(){return this._splits}},{key:"biasAutoAdjust",set:function(e){this._biasAutoAdjust=e},get:function(){return this._biasAutoAdjust}},{key:"direction",set:function(e){bn.normalize(this._dir,e),jr.setVec3(this._handle,kr.DIRECTION,this._dir)},get:function(){return this._dir}},{key:"illuminance",set:function(e){jr.set(this._handle,kr.ILLUMINANCE,e)},get:function(){return jr.get(this._handle,kr.ILLUMINANCE)}}]);var n=t.prototype;return n.initialize=function(){e.prototype.initialize.call(this),jr.set(this._handle,kr.ILLUMINANCE,ha.SUN_ILLUM),jr.setVec3(this._handle,kr.DIRECTION,this._dir),jr.set(this._handle,kr.TYPE,ep.DIRECTIONAL)},n.update=function(){this._node&&this._node.hasChangedFlags&&(this.direction=bn.transformQuat(sp,ap,this._node.worldRotation))},t}(rp),cp=new Po(null),lp=function(){function e(){this._device=null,this._passes=null,this._subMesh=null,this._patches=null,this._handle=0,this._priority=Dl.DEFAULT,this._inputAssembler=null,this._descriptorSet=null}var t=e.prototype;return t.initialize=function(e,t,n){void 0===n&&(n=null),this._device=i.director.root.device,this._subMesh=e,this._patches=n,this._passes=t,this._handle=ir.alloc(),this._flushPassInfo(),t[0].batchingScheme===Wd.VB_MERGING&&this._subMesh.genFlatBuffers(),cp.layout=t[0].localSetLayout;var r=Ui.alloc(this._device,cp),a=Gi.alloc(this._device,e.iaInfo);ir.set(this._handle,Ji.PRIORITY,Dl.DEFAULT),ir.set(this._handle,Ji.INPUT_ASSEMBLER,a),ir.set(this._handle,Ji.DESCRIPTOR_SET,r),ir.set(this._handle,Ji.SUB_MESH,e.handle),this._inputAssembler=Gi.get(a),this._descriptorSet=Ui.get(r)},t.initPlanarShadowShader=function(){var e=i.director.root.pipeline.shadows.getPlanarShader(this._patches);ir.set(this._handle,Ji.PLANAR_SHADER,e)},t.destroy=function(){Ui.free(ir.get(this._handle,Ji.DESCRIPTOR_SET)),Gi.free(ir.get(this._handle,Ji.INPUT_ASSEMBLER)),ir.free(this._handle),this._descriptorSet=null,this._inputAssembler=null,this._priority=Dl.DEFAULT,this._handle=0,this._patches=null,this._subMesh=null,this._passes=null},t.update=function(){for(var e=0;e<this._passes.length;++e)this._passes[e].update();this._descriptorSet.update()},t.onPipelineStateChanged=function(){var e=this._passes;if(e){for(var t=0;t<e.length;t++){var n=e[t];n.beginChangeStatesSilently(),n.tryCompile(),n.endChangeStatesSilently()}this._flushPassInfo()}},t.onMacroPatchesStateChanged=function(e){this._patches=e;var t=this._passes;if(t){for(var n=0;n<t.length;n++){var i=t[n];i.beginChangeStatesSilently(),i.tryCompile(),i.endChangeStatesSilently()}this._flushPassInfo()}},t._flushPassInfo=function(){var e=this._passes;if(e){ir.set(this._handle,Ji.PASS_COUNT,e.length);for(var t=Ji.PASS_0,n=Ji.SHADER_0,i=0;i<e.length;i++,t++,n++)ir.set(this._handle,t,e[i].handle),ir.set(this._handle,n,e[i].getShaderVariant(this._patches))}},j(e,[{key:"passes",set:function(e){if(this._passes=e,this._flushPassInfo(),this._descriptorSet){Ui.free(ir.get(this._handle,Ji.DESCRIPTOR_SET)),cp.layout=e[0].localSetLayout;var t=Ui.alloc(this._device,cp);ir.set(this._handle,Ji.DESCRIPTOR_SET,t),this._descriptorSet=Ui.get(t)}},get:function(){return this._passes}},{key:"subMesh",set:function(e){this._subMesh=e,this._inputAssembler.destroy(),this._inputAssembler.initialize(e.iaInfo),this._passes[0].batchingScheme===Wd.VB_MERGING&&this._subMesh.genFlatBuffers(),ir.set(this._handle,Ji.SUB_MESH,e.handle)},get:function(){return this._subMesh}},{key:"priority",set:function(e){this._priority=e,ir.set(this._handle,Ji.PRIORITY,e)},get:function(){return this._priority}},{key:"handle",get:function(){return this._handle}},{key:"inputAssembler",get:function(){return this._inputAssembler}},{key:"descriptorSet",get:function(){return this._descriptorSet}},{key:"patches",get:function(){return this._patches}},{key:"planarShaderHandel",get:function(){return ir.get(this._handle,Ji.PLANAR_SHADER)}}]),e}(),up=e("InstancedBuffer",function(){function e(e){this.instances=[],this.pass=void 0,this.hasPendingModels=!1,this.dynamicOffsets=[],this._device=void 0,this._device=e.device,this.pass=e}e.get=function(t,n){void 0===n&&(n=0);var i=e._buffers;i.has(t)||i.set(t,{});var r=i.get(t);return r[n]||(r[n]=new e(t))};var t=e.prototype;return t.destroy=function(){for(var e=0;e<this.instances.length;++e){var t=this.instances[e];t.vb.destroy(),t.ia.destroy()}this.instances.length=0},t.merge=function(e,t,n){var i=t.buffer.length;if(i){for(var r=e.inputAssembler,a=e.descriptorSet.getTexture(xu),s=ir.get(e.handle,Ji.SHADER_0+n),o=ir.get(e.handle,Ji.DESCRIPTOR_SET),c=0;c<this.instances.length;++c){var l=this.instances[c];if(!(l.ia.indexBuffer!==r.indexBuffer||l.count>=1024)&&l.lightingMap===a){if(l.stride!==i)return;if(l.count>=l.capacity){l.capacity<<=1;var u=l.stride*l.capacity,h=l.data;l.data=new Uint8Array(u),l.data.set(h),l.vb.resize(u)}return l.hShader!==s&&(l.hShader=s),l.hDescriptorSet!==o&&(l.hDescriptorSet=o),l.data.set(t.buffer,l.stride*l.count++),void(this.hasPendingModels=!0)}}for(var _=this._device.createBuffer(new Ps(Ua.VERTEX|Ua.TRANSFER_DST,Ga.HOST|Ga.DEVICE,32*i,i)),f=new Uint8Array(32*i),d=r.vertexBuffers.slice(),p=r.attributes.slice(),m=r.indexBuffer,g=0;g<t.attributes.length;g++){var v=t.attributes[g],y=new Ws(v.name,v.format,v.isNormalized,d.length,!0);p.push(y)}f.set(t.buffer),d.push(_);var S=new js(p,d,m),E=this._device.createInputAssembler(S);this.instances.push({count:1,capacity:32,vb:_,data:f,ia:E,stride:i,hShader:s,hDescriptorSet:o,lightingMap:a}),this.hasPendingModels=!0}},t.uploadBuffers=function(e){for(var t=0;t<this.instances.length;++t){var n=this.instances[t];n.count&&(n.ia.instanceCount=n.count,e.updateBuffer(n.vb,n.data))}},t.clear=function(){for(var e=0;e<this.instances.length;++e)this.instances[e].count=0;this.hasPendingModels=!1},e}());up._buffers=new Map;var hp,_p=new Ni(Pi.ATTRIBUTE,(function(e,t){return t||new Ws})),fp=new Hn,dp=new c_((function(){return new lp}),32),pp=[{name:"CC_RECEIVE_SHADOW",value:!0}];!function(e){e[e.DEFAULT=0]="DEFAULT",e[e.SKINNING=1]="SKINNING",e[e.BAKED_SKINNING=2]="BAKED_SKINNING",e[e.BATCH_2D=3]="BATCH_2D",e[e.PARTICLE_BATCH=4]="PARTICLE_BATCH",e[e.LINE=5]="LINE"}(hp||(hp={}));var mp,gp,vp,yp,Sp,Ep,Tp,Ap,xp,Cp,Rp,bp,wp,Ip,Op,Pp,Mp,Np,Dp=j_([Ja.LINEAR,Ja.LINEAR,Ja.NONE,$a.CLAMP,$a.CLAMP,$a.CLAMP]),Bp=j_([Ja.LINEAR,Ja.LINEAR,Ja.LINEAR,$a.CLAMP,$a.CLAMP,$a.CLAMP]),Lp=function(){function e(){this.type=hp.DEFAULT,this.scene=null,this.isDynamicBatching=!1,this.instancedAttributes={buffer:null,views:[],attributes:[]},this._worldBounds=null,this._modelBounds=null,this._subModels=[],this._node=null,this._transform=null,this._device=void 0,this._inited=!1,this._descriptorSetCount=1,this._updateStamp=-1,this._transformUpdated=!0,this._handle=0,this._hWorldBounds=0,this._localData=new Float32Array(au.COUNT),this._localBuffer=null,this._instMatWorldIdx=-1,this._lightmap=null,this._lightmapUVParam=new Zn,this._device=i.director.root.device}j(e,[{key:"subModels",get:function(){return this._subModels}},{key:"inited",get:function(){return this._inited}},{key:"worldBounds",get:function(){return this._worldBounds}},{key:"modelBounds",get:function(){return this._modelBounds}},{key:"localBuffer",get:function(){return this._localBuffer}},{key:"updateStamp",get:function(){return this._updateStamp}},{key:"isInstancingEnabled",get:function(){return this._instMatWorldIdx>=0}},{key:"receiveShadow",get:function(){return!!sr.get(this._handle,tr.RECEIVE_SHADOW)},set:function(e){sr.set(this._handle,tr.RECEIVE_SHADOW,e?1:0),this.onMacroPatchesStateChanged()}},{key:"castShadow",get:function(){return!!sr.get(this._handle,tr.CAST_SHADOW)},set:function(e){sr.set(this._handle,tr.CAST_SHADOW,e?1:0)}},{key:"handle",get:function(){return this._handle}},{key:"node",get:function(){return this._node},set:function(e){this._node=e,sr.set(this._handle,tr.NODE,e.handle)}},{key:"transform",get:function(){return this._transform},set:function(e){this._transform=e,sr.set(this._handle,tr.TRANSFORM,e.handle)}},{key:"visFlags",get:function(){return sr.get(this._handle,tr.VIS_FLAGS)},set:function(e){sr.set(this._handle,tr.VIS_FLAGS,e)}},{key:"enabled",get:function(){return!!sr.get(this._handle,tr.ENABLED)},set:function(e){sr.set(this._handle,tr.ENABLED,e?1:0)}}]);var t=e.prototype;return t.initialize=function(){if(!this._inited){this._handle=sr.alloc();var e=Vi.alloc(),t=ji.alloc();sr.set(this._handle,tr.INSTANCED_ATTR_ARRAY,t),sr.set(this._handle,tr.SUB_MODEL_ARRAY,e),sr.set(this._handle,tr.VIS_FLAGS,Ll.Enum.NONE),sr.set(this._handle,tr.ENABLED,1),sr.set(this._handle,tr.RECEIVE_SHADOW,1),sr.set(this._handle,tr.CAST_SHADOW,0),this._inited=!0}},t.destroy=function(){for(var e=this._subModels,t=0;t<e.length;t++){var n=this._subModels[t];n.destroy(),dp.free(n)}if(this._localBuffer&&(this._localBuffer.destroy(),this._localBuffer=null),this._worldBounds=null,this._modelBounds=null,this._subModels.length=0,this._inited=!1,this._transformUpdated=!0,this._transform=null,this._node=null,this.isDynamicBatching=!1,this._handle){var i=sr.get(this._handle,tr.SUB_MODEL_ARRAY);i&&Vi.free(i);var r=sr.get(this._handle,tr.INSTANCED_BUFFER);r&&Zi.free(r);var a=sr.get(this._handle,tr.INSTANCED_ATTR_ARRAY);a&&Li(a,ji,_p),sr.free(this._handle),this._handle=0}this._hWorldBounds&&(_r.free(this._hWorldBounds),this._hWorldBounds=0)},t.attachToScene=function(e){this.scene=e},t.detachFromScene=function(){this.scene=null},t.updateTransform=function(){var e=this.transform;if(e.hasChangedFlags||e._dirtyFlags){e.updateWorldTransform(),this._transformUpdated=!0;var t=this._worldBounds;this._modelBounds&&t&&(this._modelBounds.transform(e._mat,e._pos,e._rot,e._scale,t),_r.setVec3(this._hWorldBounds,or.CENTER,t.center),_r.setVec3(this._hWorldBounds,or.HALF_EXTENSION,t.halfExtents))}},t.updateWorldBound=function(){var e=this.transform;if(null!==e){e.updateWorldTransform(),this._transformUpdated=!0;var t=this._worldBounds;this._modelBounds&&t&&(this._modelBounds.transform(e._mat,e._pos,e._rot,e._scale,t),_r.setVec3(this._hWorldBounds,or.CENTER,t.center),_r.setVec3(this._hWorldBounds,or.HALF_EXTENSION,t.halfExtents))}},t.updateUBOs=function(e){for(var t=this._subModels,n=0;n<t.length;n++)t[n].update();if(this._updateStamp=e,this._transformUpdated){this._transformUpdated=!1;var i=this.transform._mat,r=this._instMatWorldIdx;if(r>=0){var a=this.instancedAttributes.views;!function(e,t,n,i){t[0]=e.m00,t[1]=e.m01,t[2]=e.m02,t[3]=e.m12,n[0]=e.m04,n[1]=e.m05,n[2]=e.m06,n[3]=e.m13,i[0]=e.m08,i[1]=e.m09,i[2]=e.m10,i[3]=e.m14}(i,a[r],a[r+1],a[r+2])}else this._localBuffer&&(Hn.toArray(this._localData,i,au.MAT_WORLD_OFFSET),Hn.inverseTranspose(fp,i),Hn.toArray(this._localData,fp,au.MAT_WORLD_IT_OFFSET),this._localBuffer.update(this._localData))}},t.createBoundingShape=function(e,t){e&&t&&(this._modelBounds=al.fromPoints(al.create(),e,t),this._worldBounds=al.clone(this._modelBounds),0===this._hWorldBounds&&(this._hWorldBounds=_r.alloc(),sr.set(this._handle,tr.WORLD_BOUNDS,this._hWorldBounds)),_r.setVec3(this._hWorldBounds,or.CENTER,this._worldBounds.center),_r.setVec3(this._hWorldBounds,or.HALF_EXTENSION,this._worldBounds.halfExtents))},t.initSubModel=function(e,t,n){this.initialize();var i=!1;if(null==this._subModels[e]?(this._subModels[e]=dp.alloc(),i=!0):this._subModels[e].destroy(),this._subModels[e].initialize(t,n.passes,this.getMacroPatches(e)),this._subModels[e].initPlanarShadowShader(),this._updateAttributesAndBinding(e),i){var r=sr.get(this._handle,tr.SUB_MODEL_ARRAY);Vi.assign(r,e,this._subModels[e].handle)}},t.setSubModelMesh=function(e,t){this._subModels[e]&&(this._subModels[e].subMesh=t)},t.setSubModelMaterial=function(e,t){this._subModels[e]&&(this._subModels[e].passes=t.passes,this._updateAttributesAndBinding(e))},t.onGlobalPipelineStateChanged=function(){for(var e=this._subModels,t=0;t<e.length;t++)e[t].onPipelineStateChanged()},t.onMacroPatchesStateChanged=function(){for(var e=this._subModels,t=0;t<e.length;t++)e[t].onMacroPatchesStateChanged(this.getMacroPatches(t))},t.updateLightingmap=function(e,t){Zn.toArray(this._localData,t,au.LIGHTINGMAP_UVPARAM),this._lightmap=e,this._lightmapUVParam=t,null===e&&(e=Xd.get("empty-texture"));var n=e.getGFXTexture();if(n)for(var i=af.getSampler(this._device,e.mipmaps.length>1?Bp:Dp),r=this._subModels,a=0;a<r.length;a++){var s=r[a].descriptorSet;s.bindTexture(xu,n),s.bindSampler(xu,i),s.update()}},t.getMacroPatches=function(){return this.receiveShadow?pp:null},t._updateAttributesAndBinding=function(e){var t=this._subModels[e];if(t){this._initLocalDescriptors(e),this._updateLocalDescriptors(e,t.descriptorSet);var n=zi.get(ir.get(t.handle,Ji.SHADER_0));this._updateInstancedAttributes(n.attributes,t.passes[0])}},t._getInstancedAttributeIndex=function(e){for(var t=this.instancedAttributes.attributes,n=0;n<t.length;n++)if(t[n].name===e)return n;return-1},t._updateInstancedAttributes=function(e,t){if(t.device.hasFeature(vs.INSTANCED_ARRAYS)){var n=sr.get(this._handle,tr.INSTANCED_BUFFER);n&&Zi.free(n);var i=sr.get(this._handle,tr.INSTANCED_ATTR_ARRAY);i&&Li(i,ji,_p,!1);for(var r=0,a=0;a<e.length;a++){var s=e[a];s.isInstanced&&(r+=Ts[s.format].size)}var o=Zi.alloc(r),c=Zi.getBuffer(o);sr.set(this._handle,tr.INSTANCED_BUFFER,o);var l=this.instancedAttributes;l.buffer=new Uint8Array(c),l.views.length=l.attributes.length=0;for(var u=0,h=0;h<e.length;h++){var _=e[h];if(_.isInstanced){var f=_p.alloc(),d=_p.get(f);d.format=_.format,d.name=_.name,d.isNormalized=_.isNormalized,d.location=_.location,l.attributes.push(d),ji.push(i,f);var p=Ts[_.format];l.views.push(new(bs(p))(c,u,p.count)),u+=p.size}}t.batchingScheme===Wd.INSTANCING&&up.get(t).destroy(),this._instMatWorldIdx=this._getInstancedAttributeIndex("a_matWorld0"),this._transformUpdated=!0}},t._initLocalDescriptors=function(){this._localBuffer||(this._localBuffer=this._device.createBuffer(new Ps(Ua.UNIFORM|Ua.TRANSFER_DST,Ga.HOST|Ga.DEVICE,au.SIZE,au.SIZE)))},t._updateLocalDescriptors=function(e,t){this._localBuffer&&t.bindBuffer(au.BINDING,this._localBuffer)},e}(),Fp=e("EffectAsset",ih("cc.EffectAsset")((Ap=Tp=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return Q(t=e.call.apply(e,[this].concat(i))||this,"techniques",vp,Y(t)),Q(t,"shaders",yp,Y(t)),Q(t,"combinations",Sp,Y(t)),Q(t,"hideInEditor",Ep,Y(t)),t}X(t,e),t.register=function(e){t._effects[e.name]=e},t.remove=function(e){if(t._effects[e])delete t._effects[e];else for(var n in t._effects)if(t._effects[n]._uuid===e)return void delete t._effects[n]},t.get=function(e){if(t._effects[e])return t._effects[e];for(var n in t._effects)if(t._effects[n]._uuid===e)return t._effects[n];return null},t.getAll=function(){return t._effects};var n=t.prototype;return n.onLoaded=function(){kd.register(this),t.register(this),i.game.once(i.Game.EVENT_ENGINE_INITED,this._precompile,this)},n._precompile=function(){for(var e=this,t=i.director.root,n=function(n){var i=e.shaders[n],r=e.combinations[n];if(!r)return"continue";Object.keys(r).reduce((function(e,t){return e.reduce((function(e,n){var i=r[t],a=[n].concat([].concat(Array(i.length-1)).map((function(){return q({},n)})));return a.forEach((function(e,n){return e[t]=i[n]})),e.concat(a)}),[])}),[{}]).forEach((function(e){return kd.getGFXShader(t.device,i.name,e,t.pipeline)}))},r=0;r<this.shaders.length;r++)n(r)},n.destroy=function(){return t.remove(this.name),e.prototype.destroy.call(this)},t}(I_),Tp._effects={},vp=J((gp=Ap).prototype,"techniques",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),yp=J(gp.prototype,"shaders",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Sp=J(gp.prototype,"combinations",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Ep=J(gp.prototype,"hideInEditor",[ch,lh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),mp=gp))||mp);i.EffectAsset=Fp;var zp=new Se("RenderTex"),Up=new uo;Up.endLayout=ls.SHADER_READONLY_OPTIMAL;var Gp,kp,Hp,Vp,Wp,jp,qp,Xp,Yp,Kp,Zp=new ho,Qp=new fo([Up],Zp),Jp={width:1,height:1,renderPassInfo:Qp},$p=e("RenderTexture",(xp=ih("cc.RenderTexture"),Cp=Th(),Rp=Ah(),bp=Th(),wp=Ah(),xp((Np=function(e){function t(){var t;return Q(t=e.call(this)||this,"_width",Pp,Y(t)),Q(t,"_height",Mp,Y(t)),t._textureHash=0,t._id=void 0,t._window=null,t._id=zp.getNewId(),t._textureHash=Vs(t._id,666),t}X(t,e);var n=t.prototype;return n.getHash=function(){return this._textureHash},n.initialize=function(e){this._name=e.name||"",this._width=e.width,this._height=e.height,this._initWindow(e)},n.reset=function(e){this.initialize(e)},n.destroy=function(){return this._window&&(i.director.root.destroyWindow(this._window),this._window=null),e.prototype.destroy.call(this)},n.resize=function(e,t){this._width=e,this._height=t,this._window&&this._window.resize(e,t),this.emit("resize",this._window)},n.getGFXTexture=function(){return this._window&&this._window.framebuffer.colorTextures[0]},n.getGFXSampler=function(){var e=i.director.root;return af.getSampler(e.device,H_)},n.getSamplerHash=function(){return H_},n.onLoaded=function(){this._initWindow(),this.loaded=!0,this.emit("load")},n._initWindow=function(e){var t=i.director.root;Jp.title=this._name,Jp.width=this._width,Jp.height=this._height,Jp.renderPassInfo=e&&e.passInfo?e.passInfo:Qp,this._window?(this._window.destroy(),this._window.initialize(t.device,Jp)):this._window=t.createWindow(Jp)},j(t,[{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"window",get:function(){return this._window}}]),t}(I_),Pp=J((Op=Np).prototype,"_width",[ch,Cp,Rp],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),Mp=J(Op.prototype,"_height",[ch,bp,wp],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),Ip=Op))||Ip));i.RenderTexture=$p;var em=e("Material",(Gp=ih("cc.Material"),kp=Dh(Fp),Gp((Kp=function(e){function t(){var t;return Q(t=e.call(this)||this,"_effectAsset",Wp,Y(t)),Q(t,"_techIdx",jp,Y(t)),Q(t,"_defines",qp,Y(t)),Q(t,"_states",Xp,Y(t)),Q(t,"_props",Yp,Y(t)),t._passes=[],t._hash=0,t.loaded=!1,t}X(t,e),t.getHash=function(e){for(var t,n=0,i=Z(e.passes);!(t=i()).done;)n^=t.value.hash;return n};var n=t.prototype;return n.initialize=function(e){this._defines||(this._defines=[]),this._states||(this._states=[]),this._props||(this._props=[]),void 0!==e.technique&&(this._techIdx=e.technique),e.effectAsset?this._effectAsset=e.effectAsset:e.effectName&&(this._effectAsset=Fp.get(e.effectName)),e.defines&&this._prepareInfo(e.defines,this._defines),e.states&&this._prepareInfo(e.states,this._states),this._update()},n.reset=function(e){this.initialize(e)},n.destroy=function(){return this._doDestroy(),e.prototype.destroy.call(this)},n.recompileShaders=function(){console.warn("Shaders in material asset '"+this.name+"' cannot be modified at runtime, please instantiate the material first.")},n.overridePipelineStates=function(){console.warn("Pipeline states in material asset '"+this.name+"' cannot be modified at runtime, please instantiate the material first.")},n.onLoaded=function(){this._update(),this.loaded=!0,this.emit("load")},n.resetUniforms=function(e){void 0===e&&(e=!0),this._props.length=this._passes.length;for(var t=0;t<this._props.length;t++)this._props[t]={};if(e)for(var n,i=Z(this._passes);!(n=i()).done;){var r=n.value;r.resetUBOs(),r.resetTextures()}},n.setProperty=function(e,t,n){var i=!1;if(void 0===n)for(var r=this._passes,a=r.length,s=0;s<a;s++){var o=r[s];this._uploadProperty(o,e,t)&&(this._props[o.propertyIndex][e]=t,i=!0)}else{if(n>=this._passes.length)return void console.warn("illegal pass index: "+n+".");var c=this._passes[n];this._uploadProperty(c,e,t)&&(this._props[c.propertyIndex][e]=t,i=!0)}i||console.warn("illegal property name: "+e+".")},n.getProperty=function(e,t){if(void 0===t)for(var n=this._props,i=n.length,r=0;r<i;r++){var a=n[r];if(e in a)return a[e]}else{if(t>=this._props.length)return console.warn("illegal pass index: "+t+"."),null;var s=this._props[this._passes[t].propertyIndex];if(e in s)return s[e]}return null},n.copy=function(e){this._techIdx=e._techIdx,this._props.length=e._props.length;for(var t=0;t<e._props.length;t++)this._props[t]=q({},e._props[t]);this._defines.length=e._defines.length;for(var n=0;n<e._defines.length;n++)this._defines[n]=q({},e._defines[n]);this._states.length=e._states.length;for(var i=0;i<e._states.length;i++)this._states[i]=q({},e._states[i]);this._effectAsset=e._effectAsset,this._update()},n._prepareInfo=function(e,t){var n=e;if(!Array.isArray(n)){var i=this._effectAsset?this._effectAsset.techniques[this._techIdx].passes.length:1;n=Array(i).fill(n)}for(var r=0;r<n.length;++r)Object.assign(t[r]||(t[r]={}),n[r])},n._createPasses=function(){var e=this._effectAsset.techniques[this._techIdx||0];if(!e)return[];for(var t=e.passes.length,n=[],r=0;r<t;++r){var a=e.passes[r],s=a.passIndex=r,o=a.defines=this._defines[s]||(this._defines[s]={}),c=a.stateOverrides=this._states[s]||(this._states[s]={});if(void 0!==a.propertyIndex&&(Object.assign(o,this._defines[a.propertyIndex]),Object.assign(c,this._states[a.propertyIndex])),void 0!==a.embeddedMacros&&Object.assign(o,a.embeddedMacros),!a.switch||o[a.switch]){var l=new Jd(i.director.root);l.initialize(a),n.push(l)}}return n},n._update=function(e){var n=this;if(void 0===e&&(e=!0),this._effectAsset){if(this._passes&&this._passes.length)for(var i,r=Z(this._passes);!(i=r()).done;)i.value.destroy();this._passes=this._createPasses();var a=this._effectAsset.techniques[this._techIdx].passes.length;if(this._props.length=a,e)this._passes.forEach((function(e,t){var i=n._props[t];for(var r in i||(i=n._props[t]={}),void 0!==e.propertyIndex&&Object.assign(i,n._props[e.propertyIndex]),i)n._uploadProperty(e,r,i[r])}));else for(var s=0;s<this._props.length;s++)this._props[s]={}}else{var o=Xd.get("missing-effect-material");o&&(this._passes=o._passes.slice())}this._hash=t.getHash(this)},n._uploadProperty=function(e,t,n){var i=e.getHandle(t);if(!i)return!1;var r=Jd.getPropertyTypeFromHandle(i);if(r===Ed.UBO)Array.isArray(n)?e.setUniformArray(i,n):null!==n?e.setUniform(i,n):e.resetUniform(t);else if(r===Ed.SAMPLER)if(Array.isArray(n))for(var a=0;a<n.length;a++)this._bindTexture(e,i,n[a],a);else n?this._bindTexture(e,i,n):e.resetTexture(t);return!0},n._bindTexture=function(e,t,n,i){var r=Jd.getBindingFromHandle(t);if(n instanceof bo)e.bindTexture(r,n,i);else if(n instanceof of||n instanceof $p){var a=n.getGFXTexture();if(!a||!a.width||!a.height)return;e.bindTexture(r,a,i),e.bindSampler(r,n.getGFXSampler(),i)}},n._doDestroy=function(){if(this._passes&&this._passes.length)for(var e,t=Z(this._passes);!(e=t()).done;)e.value.destroy();this._effectAsset=null,this._passes.length=0,this._props.length=0,this._defines.length=0,this._states.length=0},j(t,[{key:"effectAsset",get:function(){return this._effectAsset}},{key:"effectName",get:function(){return this._effectAsset?this._effectAsset.name:""}},{key:"technique",get:function(){return this._techIdx}},{key:"passes",get:function(){return this._passes}},{key:"hash",get:function(){return this._hash}},{key:"parent",get:function(){return null}},{key:"owner",get:function(){return null}}]),t}(I_),Wp=J((Vp=Kp).prototype,"_effectAsset",[kp],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),jp=J(Vp.prototype,"_techIdx",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),qp=J(Vp.prototype,"_defines",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Xp=J(Vp.prototype,"_states",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Yp=J(Vp.prototype,"_props",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Hp=Vp))||Hp));i.Material=em;var tm=ct({Planar:0,ShadowMap:1}),nm=ct({HARD:0,FILTER_X5:1,FILTER_X9:2,FILTER_X25:3}),im=tm.ShadowMap+1,rm=function(){function e(){this.sphere=new Na(0,0,0,.01),this.maxReceived=4,this._normal=new bn(0,1,0),this._shadowColor=new Cn(0,0,0,76),this._matLight=new Hn,this._material=null,this._instancingMaterial=null,this._size=new qn(512,512),this._handle=0,this._handle=Hr.alloc()}j(e,[{key:"enabled",get:function(){return!!Hr.get(this._handle,zr.ENABLE)},set:function(e){Hr.set(this._handle,zr.ENABLE,e?1:0),e||Hr.set(this._handle,zr.TYPE,im),this.activate()}},{key:"normal",get:function(){return this._normal},set:function(e){bn.copy(this._normal,e),Hr.setVec3(this._handle,zr.NORMAL,this._normal)}},{key:"distance",get:function(){return Hr.get(this._handle,zr.DISTANCE)},set:function(e){Hr.set(this._handle,zr.DISTANCE,e)}},{key:"shadowColor",get:function(){return this._shadowColor},set:function(e){this._shadowColor=e,Hr.setVec4(this._handle,zr.COLOR,e)}},{key:"type",get:function(){return Hr.get(this._handle,zr.TYPE)},set:function(e){Hr.set(this._handle,zr.TYPE,this.enabled?e:im),this.activate()}},{key:"near",get:function(){return Hr.get(this._handle,zr.NEAR)},set:function(e){Hr.set(this._handle,zr.NEAR,e)}},{key:"far",get:function(){return Hr.get(this._handle,zr.FAR)},set:function(e){Hr.set(this._handle,zr.FAR,e)}},{key:"aspect",get:function(){return Hr.get(this._handle,zr.ASPECT)},set:function(e){Hr.set(this._handle,zr.ASPECT,e)}},{key:"orthoSize",get:function(){return Hr.get(this._handle,zr.ORTHO_SIZE)},set:function(e){Hr.set(this._handle,zr.ORTHO_SIZE,e)}},{key:"size",get:function(){return this._size},set:function(e){this._size=e,Hr.setVec2(this._handle,zr.SIZE,this._size)}},{key:"pcf",get:function(){return Hr.get(this._handle,zr.PCF_TYPE)},set:function(e){Hr.set(this._handle,zr.PCF_TYPE,e)}},{key:"shadowMapDirty",get:function(){return!!Hr.get(this._handle,zr.SHADOW_MAP_DIRTY)},set:function(e){Hr.set(this._handle,zr.SHADOW_MAP_DIRTY,e?1:0)}},{key:"bias",get:function(){return Hr.get(this._handle,zr.BIAS)},set:function(e){Hr.set(this._handle,zr.BIAS,e)}},{key:"autoAdapt",get:function(){return!!Hr.get(this._handle,zr.AUTO_ADAPT)},set:function(e){Hr.set(this._handle,zr.AUTO_ADAPT,e?1:0)}},{key:"matLight",get:function(){return this._matLight}},{key:"material",get:function(){return this._material}},{key:"instancingMaterial",get:function(){return this._instancingMaterial}},{key:"handle",get:function(){return this._handle}}]);var t=e.prototype;return t.getPlanarShader=function(e){return this._material||(this._material=new em,this._material.initialize({effectName:"planar-shadow"}),Hr.set(this._handle,zr.PLANAR_PASS,this._material.passes[0].handle)),this._material.passes[0].getShaderVariant(e)},t.initialize=function(e){Hr.set(this._handle,zr.TYPE,e.enabled?e.type:im),Hr.set(this._handle,zr.NEAR,e.near),Hr.set(this._handle,zr.FAR,e.far),Hr.set(this._handle,zr.ASPECT,e.aspect),Hr.set(this._handle,zr.ORTHO_SIZE,e.orthoSize),this._size=e.shadowMapSize,Hr.setVec2(this._handle,zr.SIZE,this._size),Hr.set(this._handle,zr.PCF_TYPE,e.pcf),bn.copy(this._normal,e.normal),Hr.setVec3(this._handle,zr.NORMAL,this._normal),Hr.set(this._handle,zr.DISTANCE,e.distance),this._shadowColor.set(e.shadowColor),Hr.setVec4(this._handle,zr.COLOR,this._shadowColor),Hr.set(this._handle,zr.BIAS,e.bias),Hr.set(this._handle,zr.ENABLE,e.enabled?1:0),this.maxReceived=e.maxReceived,Hr.set(this._handle,zr.AUTO_ADAPT,e.autoAdapt?1:0)},t.activate=function(){if(this.enabled)this.type===tm.ShadowMap?this._updatePipeline():this._updatePlanarInfo();else{var e=i.director.root;e.pipeline.macros.CC_RECEIVE_SHADOW=0,e.onGlobalPipelineStateChanged()}},t._updatePlanarInfo=function(){this._material||(this._material=new em,this._material.initialize({effectName:"planar-shadow"}),Hr.set(this._handle,zr.PLANAR_PASS,this._material.passes[0].handle)),this._instancingMaterial||(this._instancingMaterial=new em,this._instancingMaterial.initialize({effectName:"planar-shadow",defines:{USE_INSTANCING:!0}}),Hr.set(this._handle,zr.INSTANCE_PASS,this._instancingMaterial.passes[0].handle));var e=i.director.root;e.pipeline.macros.CC_RECEIVE_SHADOW=0,e.onGlobalPipelineStateChanged()},t._updatePipeline=function(){var e=i.director.root;e.pipeline.macros.CC_RECEIVE_SHADOW=1,e.onGlobalPipelineStateChanged()},t.destroy=function(){this._material&&this._material.destroy(),this._instancingMaterial&&this._instancingMaterial.destroy(),this._handle&&(Hr.free(this._handle),this._handle=0),this.sphere.destroy()},e}();rm.MAX_FAR=2e3,rm.COEFFICIENT_OF_EXPANSION=2*Math.sqrt(3),i.Shadows=rm;var am=function(e){function t(t,n){var i;(i=e.call(this,t.root)||this)._parent=void 0,i._owner=void 0,i._dontNotify=!1,i._parent=t,i._owner=n,i._doInit(i._parent,!0);for(var r=0;r<i._shaderInfo.blocks.length;r++){var a=i._shaderInfo.blocks[r],s=i._blocks[a.binding],o=i._parent.blocks[a.binding];s.set(o)}i._rootBufferDirty=!0;for(var c=i._parent,l=0;l<i._shaderInfo.samplers.length;l++)for(var u=i._shaderInfo.samplers[l],h=0;h<u.count;h++){var _=c._descriptorSet.getSampler(u.binding,h),f=c._descriptorSet.getTexture(u.binding,h);i._descriptorSet.bindSampler(u.binding,_,h),i._descriptorSet.bindTexture(u.binding,f,h)}return e.prototype.tryCompile.call(Y(i)),i}X(t,e),j(t,[{key:"parent",get:function(){return this._parent}}]);var n=t.prototype;return n.overridePipelineStates=function(e,t){this._bs.reset(),this._rs.reset(),this._dss.reset(),Jd.fillPipelineInfo(this,e),Jd.fillPipelineInfo(this,t),this._onStateChange()},n.tryCompile=function(t){if(t&&!Nd(this._defines,t))return!1;var n=e.prototype.tryCompile.call(this);return this._onStateChange(),n},n.beginChangeStatesSilently=function(){this._dontNotify=!0},n.endChangeStatesSilently=function(){this._dontNotify=!1},n._syncBatchingScheme=function(){this._defines.USE_BATCHING=this._defines.USE_INSTANCING=!1,er.set(this._handle,Fi.BATCHING_SCHEME,0)},n._onStateChange=function(){er.set(this._handle,Fi.HASH,Jd.getPassHash(this,this._hShaderDefault)),this._owner.onPassStateChange(this._dontNotify)},t}(Jd),sm=function(e){function t(t){var n;return(n=e.call(this)||this)._passes=[],n._parent=void 0,n._owner=void 0,n._subModelIdx=0,n._parent=t.parent,n._owner=t.owner||null,n._subModelIdx=t.subModelIdx||0,n.copy(n._parent),n}X(t,e),j(t,[{key:"parent",get:function(){return this._parent}},{key:"owner",get:function(){return this._owner}}]);var n=t.prototype;return n.recompileShaders=function(e,t){if(this._passes&&this.effectAsset)if(void 0===t)for(var n,i=Z(this._passes);!(n=i()).done;)n.value.tryCompile(e);else this._passes[t].tryCompile(e)},n.overridePipelineStates=function(e,t){if(this._passes&&this.effectAsset){var n=this.effectAsset.techniques[this.technique].passes;if(void 0===t)for(var i=0;i<this._passes.length;i++){var r=this._passes[i],a=this._states[i]||(this._states[i]={});for(var s in e)a[s]=e[s];r.overridePipelineStates(n[r.passIndex],a)}else{var o=this._states[t]||(this._states[t]={});for(var c in e)o[c]=e[c];this._passes[t].overridePipelineStates(n[t],o)}}},n.destroy=function(){return this._doDestroy(),!0},n.onPassStateChange=function(e){this._hash=em.getHash(this),!e&&this._owner&&this._owner._onRebuildPSO(this._subModelIdx,this)},n._createPasses=function(){var e=[],t=this._parent.passes;if(!t)return e;for(var n=0;n<t.length;++n)e.push(new am(t[n],this));return e},t}(em),om=null,cm=null,lm=function(){function e(){this._envmap=null,this._globalDescriptorSet=null,this._model=null,this._default=null,this._handle=0,this._handle=Lr.alloc()}j(e,[{key:"model",get:function(){return this._model}},{key:"enabled",get:function(){return Lr.get(this._handle,Mr.ENABLE)},set:function(e){e?this.activate():this._updatePipeline(),Lr.set(this._handle,Mr.ENABLE,e?1:0)}},{key:"useIBL",get:function(){return Lr.get(this._handle,Mr.USE_IBL)},set:function(e){Lr.set(this._handle,Mr.USE_IBL,e?1:0),this._updatePipeline()}},{key:"isRGBE",get:function(){return Lr.get(this._handle,Mr.IS_RGBE)},set:function(e){e&&(cm&&cm.recompileShaders({USE_RGBE_CUBEMAP:e}),this._model&&this._model.setSubModelMaterial(0,cm)),Lr.set(this._handle,Mr.IS_RGBE,e?1:0),this._updatePipeline()}},{key:"envmap",get:function(){return this._envmap},set:function(e){this._envmap=e||this._default,this._envmap&&(i.director.root.pipeline.ambient.albedoArray[3]=this._envmap.mipmapLevel,this._updateGlobalBinding())}},{key:"handle",get:function(){return this._handle}}]);var t=e.prototype;return t.initialize=function(e){Lr.set(this._handle,Mr.ENABLE,e.enabled?1:0),Lr.set(this._handle,Mr.USE_IBL,e.useIBL?1:0),Lr.set(this._handle,Mr.IS_RGBE,e.isRGBE?1:0),this._envmap=e.envmap},t.activate=function(){var e=i.director.root.pipeline;if(this._globalDescriptorSet=e.descriptorSet,this._default=Xd.get("default-cube-texture"),this._model||(this._model=i.director.root.createModel(i.renderer.scene.Model),this._model._initLocalDescriptors=function(){}),Lr.set(this._handle,Mr.MODEL,this._model.handle),this._envmap||(this._envmap=this._default),e.ambient.groundAlbedo[3]=this._envmap.mipmapLevel,cm)cm.recompileShaders({USE_RGBE_CUBEMAP:this.isRGBE});else{var t=new em;t.initialize({effectName:"skybox",defines:{USE_RGBE_CUBEMAP:this.isRGBE}}),cm=new sm({parent:t})}this.enabled&&(om||(om=i.utils.createMesh(i.primitives.box({width:2,height:2,length:2}))),this._model.initSubModel(0,om.renderingSubMeshes[0],cm)),this._updateGlobalBinding(),this._updatePipeline()},t._updatePipeline=function(){var e=this.useIBL?this.isRGBE?2:1:0,t=i.director.root,n=t.pipeline;n.macros.CC_USE_IBL!==e&&(n.macros.CC_USE_IBL=e,t.onGlobalPipelineStateChanged())},t._updateGlobalBinding=function(){var e=this.envmap.getGFXTexture(),t=af.getSampler(i.director._device,this.envmap.getSamplerHash());this._globalDescriptorSet.bindSampler($l,t),this._globalDescriptorSet.bindTexture($l,e)},t.destroy=function(){this._handle&&(Lr.free(this._handle),this._handle=0)},e}();i.Skybox=lm;var um,hm,_m=function(e){function t(){var t;return(t=e.call(this)||this)._needUpdate=!1,t._pos=void 0,t._aabb=void 0,t._hAABB=0,t._aabb=al.create(),t._pos=new bn,t}X(t,e),j(t,[{key:"position",get:function(){return this._pos}},{key:"size",set:function(e){jr.set(this._handle,kr.SIZE,e)},get:function(){return jr.get(this._handle,kr.SIZE)}},{key:"range",set:function(e){jr.set(this._handle,kr.RANGE,e),this._needUpdate=!0},get:function(){return jr.get(this._handle,kr.RANGE)}},{key:"luminance",set:function(e){jr.set(this._handle,kr.ILLUMINANCE,e)},get:function(){return jr.get(this._handle,kr.ILLUMINANCE)}},{key:"aabb",get:function(){return this._aabb}}]);var n=t.prototype;return n.initialize=function(){e.prototype.initialize.call(this),this._hAABB=_r.alloc(),jr.set(this._handle,kr.TYPE,ep.SPHERE),jr.set(this._handle,kr.SIZE,.15),jr.set(this._handle,kr.RANGE,1),jr.set(this._handle,kr.AABB,this._hAABB),jr.set(this._handle,kr.ILLUMINANCE,1700/ip(.15))},n.update=function(){if(this._node&&(this._node.hasChangedFlags||this._needUpdate)){this._node.getWorldPosition(this._pos);var e=jr.get(this._handle,kr.RANGE);al.set(this._aabb,this._pos.x,this._pos.y,this._pos.z,e,e,e),this._needUpdate=!1,jr.setVec3(this._handle,kr.POSITION,this._pos),_r.setVec3(this._hAABB,or.CENTER,this._aabb.center),_r.setVec3(this._hAABB,or.HALF_EXTENSION,this._aabb.halfExtents)}},n.destroy=function(){return this._hAABB&&(_r.free(this._hAABB),this._hAABB=0),e.prototype.destroy.call(this)},t}(rp),fm=new bn(0,0,-1),dm=new Dn,pm=new Hn,mm=new Hn,gm=new Hn,vm=new Hn,ym=function(e){function t(){var t;return(t=e.call(this)||this)._dir=new bn(1,-1,-1),t._range=5,t._spotAngle=Math.cos(Math.PI/6),t._pos=void 0,t._aabb=void 0,t._frustum=void 0,t._angle=0,t._needUpdate=!1,t._hAABB=0,t._hFrustum=0,t._aabb=al.create(),t._frustum=pl.create(),t._pos=new bn,t}X(t,e),j(t,[{key:"position",get:function(){return this._pos}},{key:"size",set:function(e){jr.set(this._handle,kr.SIZE,e)},get:function(){return jr.get(this._handle,kr.SIZE)}},{key:"range",set:function(e){this._range=e,jr.set(this._handle,kr.RANGE,e),this._needUpdate=!0},get:function(){return jr.get(this._handle,kr.RANGE)}},{key:"luminance",set:function(e){jr.set(this._handle,kr.ILLUMINANCE,e)},get:function(){return jr.get(this._handle,kr.ILLUMINANCE)}},{key:"direction",get:function(){return this._dir}},{key:"spotAngle",get:function(){return jr.get(this._handle,kr.SPOT_ANGLE)},set:function(e){this._angle=e,jr.set(this._handle,kr.SPOT_ANGLE,Math.cos(.5*e)),this._needUpdate=!0}},{key:"aspect",set:function(e){jr.set(this._handle,kr.ASPECT,e),this._needUpdate=!0},get:function(){return jr.get(this._handle,kr.ASPECT)}},{key:"aabb",get:function(){return this._aabb}},{key:"frustum",get:function(){return this._frustum}}]);var n=t.prototype;return n.initialize=function(){e.prototype.initialize.call(this),this._hAABB=_r.alloc(),this._hFrustum=Or.alloc(),jr.set(this._handle,kr.TYPE,ep.SPOT),jr.set(this._handle,kr.SIZE,.15),jr.set(this._handle,kr.AABB,this._hAABB),jr.set(this._handle,kr.ILLUMINANCE,1700/ip(.15)),jr.set(this._handle,kr.RANGE,Math.cos(Math.PI/6)),jr.set(this._handle,kr.ASPECT,1),jr.setVec3(this._handle,kr.DIRECTION,this._dir)},n.update=function(){this._node&&(this._node.hasChangedFlags||this._needUpdate)&&(this._node.getWorldPosition(this._pos),bn.transformQuat(this._dir,fm,this._node.getWorldRotation(dm)),bn.normalize(this._dir,this._dir),jr.setVec3(this._handle,kr.DIRECTION,this._dir),al.set(this._aabb,this._pos.x,this._pos.y,this._pos.z,this._range,this._range,this._range),this._node.getWorldRT(pm),Hn.invert(pm,pm),Hn.perspective(mm,this._angle,1,.001,this._range),Hn.multiply(gm,mm,pm),this._frustum.update(gm,vm),this._needUpdate=!1,jr.setVec3(this._handle,kr.POSITION,this._pos),_r.setVec3(this._hAABB,or.CENTER,this._aabb.center),_r.setVec3(this._hAABB,or.HALF_EXTENSION,this._aabb.halfExtents),ml(this._hFrustum,this._frustum))},n.destroy=function(){return this._hAABB&&(_r.free(this._hAABB),this._hAABB=0),this._hFrustum&&(Or.free(this._hFrustum),this._hFrustum=0),e.prototype.destroy.call(this)},t}(rp),Sm=Object.freeze({__proto__:null,Ambient:ha,get CameraFOVAxis(){return Ou},get CameraProjection(){return Pu},get CameraAperture(){return Mu},get CameraISO(){return Nu},get CameraShutter(){return Du},SKYBOX_FLAG:qu,Camera:Yu,CameraVisFlags:$d,VisibilityFlags:tp,DirectionalLight:op,ColorTemperatureToRGB:np,get LightType(){return ep},nt2lm:ip,Light:rp,get ModelType(){return hp},Model:Lp,ShadowType:tm,PCFType:nm,Shadows:rm,RenderScene:Ku,Skybox:lm,SphereLight:_m,SpotLight:ym,SubModel:lp});function Em(e){return--e,e|=e>>16,e|=e>>8,e|=e>>4,e|=e>>2,e|=e>>1,++e}function Tm(e,t){return Math.ceil(e/t)*t}!function(e){e[e.OPAQUE=0]="OPAQUE",e[e.TRANSPARENT=1]="TRANSPARENT",e[e.OVERLAY=2]="OVERLAY"}(um||(um={})),function(e){e[e.DEFAULT=1]="DEFAULT",e[e.FORWARD=2]="FORWARD",e[e.SHADOWCAST=4]="SHADOWCAST"}(hm||(hm={}));var Am=function(){function e(e){this._device=void 0,this._format=za.UNKNOWN,this._formatSize=0,this._chunks=[],this._chunkCount=0,this._handles=[],this._region0=new eo,this._region1=new eo,this._region2=new eo,this._roundUpFn=null,this._bufferViewCtor=Uint8Array,this._channels=4,this._alignment=1,this._device=e}var t=e.prototype;return t.initialize=function(e){var t=Ts[e.format];this._format=e.format,this._formatSize=t.size,this._channels=t.count,this._bufferViewCtor=bs(t),this._roundUpFn=e.roundUpFn||null,this._alignment=e.alignment||1,e.inOrderFree&&(this.alloc=this._McDonaldAlloc)},t.destroy=function(){for(var e=0;e<this._chunkCount;++e)this._chunks[e].texture.destroy();this._chunks.length=0,this._handles.length=0},t.alloc=function(e,t){e=Tm(e,this._alignment);var n=-1,i=-1;if(void 0!==t&&(n=t,i=this._findAvailableSpace(e,n)),i<0)for(var r=0;r<this._chunkCount&&(n=r,!((i=this._findAvailableSpace(e,n))>=0));++r);if(i>=0){var a=this._chunks[n];a.start+=e;var s={chunkIdx:n,start:i,end:i+e,texture:a.texture};return this._handles.push(s),s}var o=Math.sqrt(e/this._formatSize),c=this._roundUpFn&&this._roundUpFn(o,this._formatSize)||Math.max(1024,Em(o)),l=this._chunks[this.createChunk(c)];l.start+=e;var u={chunkIdx:this._chunkCount-1,start:0,end:e,texture:l.texture};return this._handles.push(u),u},t.free=function(e){for(var t=0;t<this._handles.length;++t)if(this._handles[t]===e)return this._chunks[e.chunkIdx].end=e.end,void this._handles.splice(t,1)},t.createChunk=function(e){var t=e*e*this._formatSize;console.info("TextureBufferPool: Allocate chunk "+this._chunkCount+", size: "+t+", format: "+this._format);var n={texture:this._device.createTexture(new xo(es.TEX2D,ts.SAMPLED|ts.TRANSFER_DST,this._format,e,e,is.IMMUTABLE)),size:t,start:0,end:t};return this._chunks[this._chunkCount]=n,this._chunkCount++},t.update=function(e,t){var n=[],i=[],r=e.start/this._formatSize,a=t.byteLength/this._formatSize,s=r%e.texture.width,o=Math.floor(r/e.texture.width),c=Math.min(e.texture.width-s,a),l=0;s>0&&(this._region0.texOffset.x=s,this._region0.texOffset.y=o,this._region0.texExtent.width=c,this._region0.texExtent.height=1,n.push(new this._bufferViewCtor(t,l*this._formatSize,c*this._channels)),i.push(this._region0),s=0,o+=1,a-=c,l+=c),a>0&&(this._region1.texOffset.x=s,this._region1.texOffset.y=o,a>e.texture.width?(this._region1.texExtent.width=e.texture.width,this._region1.texExtent.height=Math.floor(a/e.texture.width),c=this._region1.texExtent.width*this._region1.texExtent.height):(c=a,this._region1.texExtent.width=c,this._region1.texExtent.height=1),n.push(new this._bufferViewCtor(t,l*this._formatSize,c*this._channels)),i.push(this._region1),s=0,o+=this._region1.texExtent.height,a-=c,l+=c),a>0&&(this._region2.texOffset.x=s,this._region2.texOffset.y=o,this._region2.texExtent.width=a,this._region2.texExtent.height=1,n.push(new this._bufferViewCtor(t,l*this._formatSize,a*this._channels)),i.push(this._region2)),this._device.copyBuffersToTexture(n,e.texture,i)},t._findAvailableSpace=function(e,t){var n=this._chunks[t],i=!1,r=n.start;if(r+e<=n.size)i=!0;else{r=0;for(var a=this._handles.filter((function(e){return e.chunkIdx===t})).sort((function(e,t){return e.start-t.start})),s=0;s<a.length;s++){var o=a[s];if(r+e<=o.start){i=!0;break}r=o.end}!i&&r+e<=n.size&&(i=!0)}return i?r:-1},t._McDonaldAlloc=function(e){e=Tm(e,this._alignment);for(var t=0;t<this._chunkCount;++t){var n=this._chunks[t],i=!1,r=n.start;if(r+e<=n.end?i=!0:r>n.end?r+e<=n.size?i=!0:e<=n.end&&(n.start=r=0,i=!0):r===n.end&&(n.start=r=0,n.end=n.size,e<=n.end&&(i=!0)),i){n.start+=e;var a={chunkIdx:t,start:r,end:r+e,texture:n.texture};return this._handles.push(a),a}}var s=Math.sqrt(e/this._formatSize),o=this._roundUpFn&&this._roundUpFn(s,this._formatSize)||Math.max(1024,Em(s)),c=this._chunks[this.createChunk(o)];c.start+=e;var l={chunkIdx:this._chunkCount,start:0,end:e,texture:c.texture};return this._handles.push(l),l},e}(),xm=function(e){if(void 0===ee[e]){var t=1<<$;ee[e]=t,$+=1}},Cm=Object.freeze({__proto__:null,addStage:xm,scene:Sm,createIA:function(e,t){if(!t.positions)return console.error("The data must have positions field"),null;for(var n=[],i=t.positions.length/3,r=0;r<i;++r)n.push(t.positions[3*r],t.positions[3*r+1],t.positions[3*r+2]),t.normals&&n.push(t.normals[3*r],t.normals[3*r+1],t.normals[3*r+2]),t.uvs&&n.push(t.uvs[2*r],t.uvs[2*r+1]),t.colors&&n.push(t.colors[3*r],t.colors[3*r+1],t.colors[3*r+2]);var a=[];a.push(new Ws(La.ATTR_POSITION,za.RGB32F)),t.normals&&a.push(new Ws(La.ATTR_NORMAL,za.RGB32F)),t.uvs&&a.push(new Ws(La.ATTR_TEX_COORD,za.RG32F)),t.colors&&a.push(new Ws(La.ATTR_COLOR,za.RGB32F));var s=e.createBuffer(new Ps(Ua.VERTEX|Ua.TRANSFER_DST,Ga.HOST|Ga.DEVICE,4*n.length,4*n.length/i));s.update(new Float32Array(n));var o=null;return t.indices&&(o=e.createBuffer(new Ps(Ua.INDEX|Ua.TRANSFER_DST,Ga.HOST|Ga.DEVICE,2*t.indices.length,2))).update(new Uint16Array(t.indices)),e.createInputAssembler(new js(a,[s],o))},get RenderQueue(){return um},get PassStage(){return hm},get PropertyType(){return Ed},genHandle:Ad,getPropertyTypeFromHandle:xd,getTypeFromHandle:Cd,getSetIndexFromHandle:function(e){return(3145728&e)>>>20},getBindingFromHandle:Rd,getOffsetFromHandle:bd,customizeType:wd,type2reader:Id,type2writer:Od,getDefaultFromType:Md,overrideMacros:Nd,get BatchingSchemes(){return Wd},Pass:Jd,getDeviceShaderVersion:Gd,programLib:kd,get SamplerInfoIndex(){return U_},defaultSamplerHash:H_,genSamplerHash:j_,samplerLib:af,nearestPOT:Em,TextureBufferPool:Am,MaterialInstance:sm,PassInstance:am,ObjectPool:Ni,freeHandleArray:Li,get PoolType(){return Pi},NULL_HANDLE:0,ShaderPool:zi,DSPool:Ui,IAPool:Gi,PipelineLayoutPool:ki,FramebufferPool:Hi,SubModelArrayPool:Vi,ModelArrayPool:Wi,AttributeArrayPool:ji,FlatBufferArrayPool:qi,LightArrayPool:Xi,BlendTargetArrayPool:Yi,UIBatchArrayPool:Ki,RawBufferPool:Zi,RawObjectPool:Qi,get PassView(){return Fi},PassPool:er,get SubModelView(){return Ji},SubModelPool:ir,get ModelView(){return tr},ModelPool:sr,get BatchView2D(){return rr},BatchPool2D:lr,get AABBView(){return or},AABBPool:_r,get SceneView(){return ur},ScenePool:pr,get CameraView(){return fr},CameraPool:vr,get NodeView(){return mr},NodePool:Er,get RootView(){return Sr},RootPool:xr,get RenderWindowView(){return Tr},RenderWindowPool:br,get FrustumView(){return Cr},FrustumPool:Or,get AmbientView(){return wr},AmbientPool:Nr,get SkyboxView(){return Mr},SkyboxPool:Lr,get FogView(){return Dr},FogPool:Ur,get ShadowsView(){return zr},ShadowsPool:Hr,get LightView(){return kr},LightPool:jr,get SphereView(){return Vr},SpherePool:Yr,get FlatBufferView(){return Xr},FlatBufferPool:Qr,get SubMeshView(){return Kr},SubMeshPool:ea,get RasterizerStateView(){return Jr},RasterizerStatePool:ia,get DepthStencilStateView(){return ta},DepthStencilStatePool:sa,get BlendTargetView(){return ra},BlendTargetPool:ca,get BlendStateView(){return oa},BlendStatePool:ua});function Rm(e){return e*e}function bm(e){return e*(2-e)}function wm(e){return e*e*e}function Im(e){return--e*e*e+1}function Om(e){return e*e*e*e}function Pm(e){return 1- --e*e*e*e}function Mm(e){return e*e*e*e*e}function Nm(e){return--e*e*e*e*e+1}function Dm(e){return 1-Math.cos(e*Math.PI/2)}function Bm(e){return Math.sin(e*Math.PI/2)}function Lm(e){return 0===e?0:Math.pow(1024,e-1)}function Fm(e){return 1===e?1:1-Math.pow(2,-10*e)}function zm(e){return 1-Math.sqrt(1-e*e)}function Um(e){return Math.sqrt(1- --e*e)}function Gm(e){var t,n=.1;return 0===e?0:1===e?1:(!n||n<1?(n=1,t=.1):t=.4*Math.asin(1/n)/(2*Math.PI),-n*Math.pow(2,10*(e-=1))*Math.sin(2*(e-t)*Math.PI/.4))}function km(e){var t,n=.1;return 0===e?0:1===e?1:(!n||n<1?(n=1,t=.1):t=.4*Math.asin(1/n)/(2*Math.PI),n*Math.pow(2,-10*e)*Math.sin(2*(e-t)*Math.PI/.4)+1)}function Hm(e){var t=1.70158;return e*e*((t+1)*e-t)}function Vm(e){var t=1.70158;return--e*e*((t+1)*e+t)+1}function Wm(e){return 1-jm(1-e)}function jm(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375}e("renderer",Cm);var qm=ng(Rm,bm),Xm=ng(wm,Im),Ym=ng(Om,Pm),Km=ng(Mm,Nm),Zm=ng(Dm,Bm),Qm=ng(Lm,Fm),Jm=ng(zm,Um),$m=ng(Gm,km),eg=ng(Hm,Vm),tg=ng(Wm,jm);function ng(e,t){return function(n){return n<.5?t(2*n)/2:e(2*n-1)/2+.5}}var ig,rg=Object.freeze({__proto__:null,constant:function(){return 0},linear:function(e){return e},quadIn:Rm,quadOut:bm,quadInOut:function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)},cubicIn:wm,cubicOut:Im,cubicInOut:function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)},quartIn:Om,quartOut:Pm,quartInOut:function(e){return(e*=2)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2)},quintIn:Mm,quintOut:Nm,quintInOut:function(e){return(e*=2)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2)},sineIn:Dm,sineOut:Bm,sineInOut:function(e){return.5*(1-Math.cos(Math.PI*e))},expoIn:Lm,expoOut:Fm,expoInOut:function(e){return 0===e?0:1===e?1:(e*=2)<1?.5*Math.pow(1024,e-1):.5*(2-Math.pow(2,-10*(e-1)))},circIn:zm,circOut:Um,circInOut:function(e){return(e*=2)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1)},elasticIn:Gm,elasticOut:km,elasticInOut:function(e){var t,n=.1;return 0===e?0:1===e?1:(!n||n<1?(n=1,t=.1):t=.4*Math.asin(1/n)/(2*Math.PI),(e*=2)<1?n*Math.pow(2,10*(e-=1))*Math.sin(2*(e-t)*Math.PI/.4)*-.5:n*Math.pow(2,-10*(e-=1))*Math.sin(2*(e-t)*Math.PI/.4)*.5+1)},backIn:Hm,backOut:Vm,backInOut:function(e){var t=2.5949095;return(e*=2)<1?e*e*((t+1)*e-t)*.5:.5*((e-=2)*e*((t+1)*e+t)+2)},bounceIn:Wm,bounceOut:jm,bounceInOut:function(e){return e<.5?.5*Wm(2*e):.5*jm(2*e-1)+.5},smooth:function(e){return e<=0?0:e>=1?1:e*e*(3-2*e)},fade:function(e){return e<=0?0:e>=1?1:e*e*e*(e*(6*e-15)+10)},quadOutIn:qm,cubicOutIn:Xm,quartOutIn:Ym,quintOutIn:Km,sineOutIn:Zm,expoOutIn:Qm,circOutIn:Jm,elasticOutIn:$m,backOutIn:eg,bounceOutIn:tg});e("easing",rg),function(e){e[e.NONE=0]="NONE",e[e.LAN=1]="LAN",e[e.WWAN=2]="WWAN"}(ig||(ig={}));var ag,sg,og,cg,lg,ug,hg,_g,fg,dg,pg,mg=e("sys",{NetworkType:ig,LANGUAGE_ENGLISH:"en",LANGUAGE_CHINESE:"zh",LANGUAGE_FRENCH:"fr",LANGUAGE_ITALIAN:"it",LANGUAGE_GERMAN:"de",LANGUAGE_SPANISH:"es",LANGUAGE_DUTCH:"du",LANGUAGE_RUSSIAN:"ru",LANGUAGE_KOREAN:"ko",LANGUAGE_JAPANESE:"ja",LANGUAGE_HUNGARIAN:"hu",LANGUAGE_PORTUGUESE:"pt",LANGUAGE_ARABIC:"ar",LANGUAGE_NORWEGIAN:"no",LANGUAGE_POLISH:"pl",LANGUAGE_TURKISH:"tr",LANGUAGE_UKRAINIAN:"uk",LANGUAGE_ROMANIAN:"ro",LANGUAGE_BULGARIAN:"bg",LANGUAGE_UNKNOWN:"unknown",OS_IOS:"iOS",OS_ANDROID:"Android",OS_WINDOWS:"Windows",OS_LINUX:"Linux",OS_OSX:"OS X",OS_UNKNOWN:"Unknown",UNKNOWN:-1,WIN32:0,LINUX:1,MACOS:2,ANDROID:3,IPHONE:4,IPAD:5,BLACKBERRY:6,NACL:7,EMSCRIPTEN:8,TIZEN:9,WINRT:10,WP8:11,MOBILE_BROWSER:100,DESKTOP_BROWSER:101,EDITOR_PAGE:102,EDITOR_CORE:103,WECHAT_GAME:104,QQ_PLAY:105,FB_PLAYABLE_ADS:106,BAIDU_MINI_GAME:107,VIVO_MINI_GAME:108,OPPO_MINI_GAME:109,HUAWEI_QUICK_GAME:110,XIAOMI_QUICK_GAME:111,COCOSPLAY:112,ALIPAY_MINI_GAME:113,QTT_MINI_GAME:116,BYTEDANCE_MINI_GAME:117,LINKSURE_MINI_GAME:119,BROWSER_TYPE_WECHAT:"wechat",BROWSER_TYPE_ANDROID:"androidbrowser",BROWSER_TYPE_IE:"ie",BROWSER_TYPE_EDGE:"edge",BROWSER_TYPE_QQ:"qqbrowser",BROWSER_TYPE_MOBILE_QQ:"mqqbrowser",BROWSER_TYPE_UC:"ucbrowser",BROWSER_TYPE_UCBS:"ucbs",BROWSER_TYPE_360:"360browser",BROWSER_TYPE_BAIDU_APP:"baiduboxapp",BROWSER_TYPE_BAIDU:"baidubrowser",BROWSER_TYPE_MAXTHON:"maxthon",BROWSER_TYPE_OPERA:"opera",BROWSER_TYPE_OUPENG:"oupeng",BROWSER_TYPE_MIUI:"miuibrowser",BROWSER_TYPE_FIREFOX:"firefox",BROWSER_TYPE_SAFARI:"safari",BROWSER_TYPE_CHROME:"chrome",BROWSER_TYPE_LIEBAO:"liebao",BROWSER_TYPE_QZONE:"qzone",BROWSER_TYPE_SOUGOU:"sogou",BROWSER_TYPE_HUAWEI:"huawei",BROWSER_TYPE_UNKNOWN:"unknown",isNative:!1,isBrowser:"object"==typeof window&&"object"==typeof document,isMobile:!1,isLittleEndian:(ag=new ArrayBuffer(2),new DataView(ag).setInt16(0,256,!0),256===new Int16Array(ag)[0]),platform:-1,language:"unknown",languageCode:"unknown",os:"Unknown",osVersion:"",osMainVersion:0,browserType:"unknown",browserVersion:"",windowPixelResolution:null,capabilities:null,localStorage:null,__audioSupport:null,__videoSupport:null,getNetworkType:function(){return ig.LAN},getBatteryLevel:function(){return 1},garbageCollect:function(){},isObjectValid:function(e){return null!=e},dump:function(){var e="";e+="isMobile : "+this.isMobile+"\r\n",e+="language : "+this.language+"\r\n",e+="browserType : "+this.browserType+"\r\n",e+="browserVersion : "+this.browserVersion+"\r\n",e+="capabilities : "+JSON.stringify(this.capabilities)+"\r\n",e+="os : "+this.os+"\r\n",e+="osVersion : "+this.osVersion+"\r\n",e+="platform : "+this.platform+"\r\n",h(e+="Using "+(i.game.renderType===i.game.RENDER_TYPE_WEBGL?"WEBGL":"CANVAS")+" renderer.\r\n")},openURL:function(e){window.open(e)},now:function(){return Date.now?Date.now():+new Date},restartVM:function(){},getSafeAreaRect:function(){var e=i.view.getVisibleSize();return i.rect(0,0,e.width,e.height)},__init:function(){var e=window,t=e.navigator,n=document,i=n.documentElement,r=t.userAgent.toLowerCase();mg.isMobile=/mobile|android|iphone|ipad/.test(r),mg.platform=mg.isMobile?mg.MOBILE_BROWSER:mg.DESKTOP_BROWSER;var a=t.language;mg.languageCode=a.toLowerCase(),a=(a=a||t.browserLanguage)?a.split("-")[0]:mg.LANGUAGE_ENGLISH,mg.language=a;var s=!1,o=!1,c="",l=0,u=/android\s*(\d+(?:\.\d+)*)/i.exec(r)||/android\s*(\d+(?:\.\d+)*)/i.exec(t.platform);u&&(s=!0,c=u[1]||"",l=parseInt(c)||0),(u=/(iPad|iPhone|iPod).*OS ((\d+_?){2,3})/i.exec(r))?(o=!0,c=u[2]||"",l=parseInt(c)||0):(/(iPhone|iPad|iPod)/.exec(t.platform)||"MacIntel"===t.platform&&t.maxTouchPoints&&t.maxTouchPoints>1)&&(o=!0,c="",l=0);var h=mg.OS_UNKNOWN;-1!==t.appVersion.indexOf("Win")?h=mg.OS_WINDOWS:o?h=mg.OS_IOS:-1!==t.appVersion.indexOf("Mac")?h=mg.OS_OSX:-1!==t.appVersion.indexOf("X11")&&-1===t.appVersion.indexOf("Linux")?h=mg.OS_UNIX:s?h=mg.OS_ANDROID:-1===t.appVersion.indexOf("Linux")&&-1===r.indexOf("ubuntu")||(h=mg.OS_LINUX),mg.os=h,mg.osVersion=c,mg.osMainVersion=l,mg.browserType=mg.BROWSER_TYPE_UNKNOWN,function(){var e=/mqqbrowser|micromessenger|qqbrowser|sogou|qzone|liebao|maxthon|ucbs|360 aphone|360browser|baiduboxapp|baidubrowser|maxthon|mxbrowser|miuibrowser/i.exec(r)||/qq|qqbrowser|ucbrowser|ubrowser|edge|HuaweiBrowser/i.exec(r)||/chrome|safari|firefox|trident|opera|opr\/|oupeng/i.exec(r),t=e?e[0].toLowerCase():mg.BROWSER_TYPE_UNKNOWN;("safari"===t&&s||"qq"===t&&/android.*applewebkit/i.test(r))&&(t=mg.BROWSER_TYPE_ANDROID);var n={micromessenger:mg.BROWSER_TYPE_WECHAT,trident:mg.BROWSER_TYPE_IE,edge:mg.BROWSER_TYPE_EDGE,"360 aphone":mg.BROWSER_TYPE_360,mxbrowser:mg.BROWSER_TYPE_MAXTHON,"opr/":mg.BROWSER_TYPE_OPERA,ubrowser:mg.BROWSER_TYPE_UC,huaweibrowser:mg.BROWSER_TYPE_HUAWEI};mg.browserType=n[t]||t}(),mg.browserVersion="",function(){var e=/(mqqbrowser|micromessenger|qqbrowser|sogou|qzone|liebao|maxthon|uc|ucbs|360 aphone|360|baiduboxapp|baidu|maxthon|mxbrowser|miui(?:.hybrid)?)(mobile)?(browser)?\/?([\d.]+)/i.exec(r);e||(e=/(qq|chrome|safari|firefox|trident|opera|opr\/|oupeng)(mobile)?(browser)?\/?([\d.]+)/i.exec(r)),mg.browserVersion=e?e[4]:""}();var _=window.innerWidth||document.documentElement.clientWidth,f=window.innerHeight||document.documentElement.clientHeight,d=window.devicePixelRatio||1;mg.windowPixelResolution={width:d*_,height:d*f};var p,m=document.createElement("canvas");try{var g=mg.localStorage=e.localStorage;g.setItem("storage",""),g.removeItem("storage"),g=null}catch(e){var v=function(){E(5200)};mg.localStorage={getItem:v,setItem:v,removeItem:v,clear:v}}try{p=m.toDataURL("image/webp").startsWith("data:image/webp")}catch(e){p=!1}var S=!!m.getContext("2d"),T=!1;e.WebGLRenderingContext&&(T=!0);var A,x=mg.capabilities={canvas:S,opengl:T,webp:p,imageBitmap:!1,touches:!1,mouse:!1,keyboard:!1,accelerometer:!1};"undefined"!=typeof createImageBitmap&&"undefined"!=typeof Blob&&(m.width=m.height=2,createImageBitmap(m,{}).then((function(e){x.imageBitmap=!0,e.close&&e.close()})).catch((function(){}))),(void 0!==i.ontouchstart||void 0!==n.ontouchstart||t.msPointerEnabled)&&(x.touches=!0),void 0!==i.onmouseup&&(x.mouse=!0),void 0!==i.onkeyup&&(x.keyboard=!0),(e.DeviceMotionEvent||e.DeviceOrientationEvent)&&(x.accelerometer=!0),A={ONLY_ONE:!1,WEB_AUDIO:!!(window.AudioContext||window.webkitAudioContext||window.mozAudioContext),DELAY_CREATE_CTX:!1},mg.os===mg.OS_IOS&&(A.USE_LOADER_EVENT="loadedmetadata"),mg.browserType===mg.BROWSER_TYPE_FIREFOX&&(A.DELAY_CREATE_CTX=!0,A.USE_LOADER_EVENT="canplay"),mg.os===mg.OS_ANDROID&&mg.browserType===mg.BROWSER_TYPE_UC&&(A.ONE_SOURCE=!0);try{A.WEB_AUDIO&&(A._context=null,Object.defineProperty(A,"context",{get:function(){return this._context?this._context:this._context=new(window.AudioContext||window.webkitAudioContext||window.mozAudioContext)}}))}catch(e){A.WEB_AUDIO=!1,y(5201)}var C,R=[];(C=document.createElement("audio")).canPlayType&&(C.canPlayType('audio/ogg; codecs="vorbis"')&&R.push(".ogg"),C.canPlayType("audio/mpeg")&&R.push(".mp3"),C.canPlayType('audio/wav; codecs="1"')&&R.push(".wav"),C.canPlayType("audio/mp4")&&R.push(".mp4"),C.canPlayType("audio/x-m4a")&&R.push(".m4a")),A.format=R,mg.__audioSupport=A,mg.__videoSupport={format:[]},function(){var e=document.createElement("video");if(e.canPlayType){var t=mg.__videoSupport.format;["mp4","webm"].forEach((function(n){e.canPlayType("video/"+n)&&t.push("."+n)})),mg.__videoSupport.format=t}}(),mg.__isWebIOS14OrIPadOS14Env=(mg.os===mg.OS_IOS||mg.os===mg.MACOS)&&mg.isBrowser&&/(OS 1[4-9])|(Version\/1[4-9])/.test(window.navigator.userAgent)}});"object"==typeof window&&"object"==typeof document&&mg.__init(),i.sys=mg;var gg,vg,yg,Sg,Eg,Tg,Ag,xg,Cg,Rg,bg,wg,Ig,Og=e("RenderStage",(sg=ih("RenderStage"),og=Rh(),cg=Rh(),lg=Rh(),sg((pg=function(){function e(){Q(this,"_name",_g,this),Q(this,"_priority",fg,this),Q(this,"_tag",dg,this)}var t=e.prototype;return t.initialize=function(e){return this._name=e.name,this._priority=e.priority,e.tag&&(this._tag=e.tag),!0},t.activate=function(e,t){this._pipeline=e,this._flow=t},j(e,[{key:"name",get:function(){return this._name}},{key:"priority",get:function(){return this._priority}},{key:"tag",get:function(){return this._tag}}]),e}(),_g=J((hg=pg).prototype,"_name",[og,ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),fg=J(hg.prototype,"_priority",[cg,ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),dg=J(hg.prototype,"_tag",[lg,ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),ug=hg))||ug));i.RenderStage=Og;var Pg,Mg,Ng,Dg,Bg,Lg,Fg,zg,Ug,Gg=e("RenderFlow",(gg=ih("RenderFlow"),vg=Rh(),yg=Rh(),Sg=Rh(),Eg=Rh(),Tg=Dh([Og]),gg((Ig=function(){function e(){Q(this,"_name",Cg,this),Q(this,"_priority",Rg,this),Q(this,"_tag",bg,this),Q(this,"_stages",wg,this)}var t=e.prototype;return t.initialize=function(e){return this._name=e.name,this._priority=e.priority,this._stages=e.stages,e.tag&&(this._tag=e.tag),!0},t.activate=function(e){this._pipeline=e,this._stages.sort((function(e,t){return e.priority-t.priority}));for(var t=0,n=this._stages.length;t<n;t++)this._stages[t].activate(e,this)},t.render=function(e){for(var t=0,n=this._stages.length;t<n;t++)this._stages[t].render(e)},t.destroy=function(){for(var e=0,t=this._stages.length;e<t;e++)this._stages[e].destroy();this._stages.length=0},j(e,[{key:"name",get:function(){return this._name}},{key:"priority",get:function(){return this._priority}},{key:"tag",get:function(){return this._tag}},{key:"stages",get:function(){return this._stages}}]),e}(),Cg=J((xg=Ig).prototype,"_name",[vg,ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),Rg=J(xg.prototype,"_priority",[yg,ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),bg=J(xg.prototype,"_tag",[Sg,ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),wg=J(xg.prototype,"_stages",[Eg,Tg,ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Ag=xg))||Ag));i.RenderFlow=Gg;var kg,Hg,Vg=e("RenderPipeline",(Pg=ih("cc.RenderPipeline"),Mg=Rh(),Ng=Rh(),Dg=Dh([Gg]),Pg((Ug=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return Q(t=e.call.apply(e,[this].concat(i))||this,"_tag",Fg,Y(t)),Q(t,"_flows",zg,Y(t)),t._macros={},t._commandBuffers=[],t}X(t,e);var n=t.prototype;return n.initialize=function(e){return this._flows=e.flows,e.tag&&(this._tag=e.tag),!0},n.activate=function(){this._device=i.director.root.device;var e=new Do(zl.bindings);this._descriptorSetLayout=this._device.createDescriptorSetLayout(e),this._descriptorSet=this._device.createDescriptorSet(new Po(this._descriptorSetLayout));for(var t=0;t<this._flows.length;t++)this._flows[t].activate(this);return!0},n.render=function(e){for(var t=0;t<this.flows.length;t++)for(var n=0;n<e.length;n++){var i=e[n];this.flows[t].render(i)}},n.destroy=function(){for(var t=0;t<this._flows.length;t++)this._flows[t].destroy();this._flows.length=0,this._descriptorSet&&(this._descriptorSet.destroy(),this._descriptorSet=null);for(var n=0;n<this._commandBuffers.length;n++)this._commandBuffers[n].destroy();return this._commandBuffers.length=0,e.prototype.destroy.call(this)},j(t,[{key:"macros",get:function(){return this._macros}},{key:"tag",get:function(){return this._tag}},{key:"flows",get:function(){return this._flows}},{key:"device",get:function(){return this._device}},{key:"descriptorSetLayout",get:function(){return this._descriptorSetLayout}},{key:"descriptorSet",get:function(){return this._descriptorSet}},{key:"commandBuffers",get:function(){return this._commandBuffers}}]),t}(I_),Fg=J((Lg=Ug).prototype,"_tag",[Mg,ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),zg=J(Lg.prototype,"_flows",[Ng,Dg,ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Bg=Lg))||Bg));i.RenderPipeline=Vg,function(e){e[e.FORWARD=10]="FORWARD",e[e.UI=20]="UI"}(kg||(kg={})),function(e){e[e.SHADOW=0]="SHADOW",e[e.FORWARD=1]="FORWARD",e[e.UI=10]="UI"}(Hg||(Hg={}));var Wg=e("PipelineStateManager",function(){function e(){}return e.getOrCreatePipelineState=function(e,t,n,i,r){var a=t.handle,s=er.get(a,Fi.HASH)^i.hash^r.attributesHash^n.id,o=this._PSOHashMap.get(s);if(!o){var c=ki.get(er.get(a,Fi.PIPELINE_LAYOUT)),l=new ao(r.attributes),u=new so(n,c,i,l,t.rasterizerState,t.depthStencilState,t.blendState,er.get(a,Fi.PRIMITIVE),er.get(a,Fi.DYNAMIC_STATES));o=e.createPipelineState(u),this._PSOHashMap.set(s,o)}return o},e}());function jg(e,t){return e.hash-t.hash||e.depth-t.depth||e.shaderId-t.shaderId}function qg(e,t){return e.hash-t.hash||t.depth-e.depth||e.shaderId-t.shaderId}Wg._PSOHashMap=new Map;var Xg=function(){function e(e){this.queue=void 0,this._passDesc=void 0,this._passPool=void 0,this._passDesc=e,this._passPool=new l_((function(){return{hash:0,depth:0,shaderId:0,subModel:null,passIdx:0}}),64),this.queue=new u_(64,this._passDesc.sortFunc)}var t=e.prototype;return t.clear=function(){this.queue.clear(),this._passPool.reset()},t.insertRenderPass=function(e,t,n){var i=e.model.subModels[t],r=ir.get(i.handle,Ji.PASS_0+n);if(i.passes[n].blendState.targets[0].blend!==this._passDesc.isTransparent||!(er.get(r,Fi.PHASE)&this._passDesc.phases))return!1;var a=0|er.get(r,Fi.PRIORITY)<<16|i.priority<<8|n,s=this._passPool.add();return s.hash=a,s.depth=e.depth||0,s.shaderId=ir.get(i.handle,Ji.SHADER_0+n),s.subModel=i,s.passIdx=n,this.queue.push(s),!0},t.sort=function(){this.queue.sort()},t.recordCommandBuffer=function(e,t,n){for(var i=0;i<this.queue.length;++i){var r=this.queue.array[i],a=r.subModel,s=r.passIdx,o=a.inputAssembler,c=a.handle,l=a.passes[s],u=zi.get(ir.get(c,Ji.SHADER_0+s)),h=Wg.getOrCreatePipelineState(e,l,u,t,o);n.bindPipelineState(h),n.bindDescriptorSet(Vl.MATERIAL,l.descriptorSet),n.bindDescriptorSet(Vl.LOCAL,a.descriptorSet),n.bindInputAssembler(o),n.draw(o)}},e}(),Yg=function(){function e(){this.queue=new Set}var t=e.prototype;return t.clear=function(){for(var e=this.queue.values(),t=e.next();!t.done;)t.value.clear(),t=e.next();this.queue.clear()},t.uploadBuffers=function(e){for(var t=this.queue.values(),n=t.next();!n.done;){for(var i=0;i<n.value.batches.length;++i){var r=n.value.batches[i];if(r.mergeCount){for(var a=0;a<r.vbs.length;++a)r.vbs[a].update(r.vbDatas[a]);e.updateBuffer(r.vbIdx,r.vbIdxData.buffer),e.updateBuffer(r.ubo,r.uboData)}}n=t.next()}},t.recordCommandBuffer=function(e,t,n){for(var i=this.queue.values(),r=i.next();!r.done;){for(var a=!1,s=0;s<r.value.batches.length;++s){var o=r.value.batches[s];if(o.mergeCount){if(!a){var c=zi.get(o.hShader),l=Wg.getOrCreatePipelineState(e,o.pass,c,t,o.ia);n.bindPipelineState(l),n.bindDescriptorSet(Vl.MATERIAL,o.pass.descriptorSet),a=!0}n.bindDescriptorSet(Vl.LOCAL,o.descriptorSet,r.value.dynamicOffsets),n.bindInputAssembler(o.ia),n.draw(o.ia)}}r=i.next()}},e}(),Kg=function(){function e(){this.queue=new Set}var t=e.prototype;return t.clear=function(){for(var e=this.queue.values(),t=e.next();!t.done;)t.value.clear(),t=e.next();this.queue.clear()},t.uploadBuffers=function(e){for(var t=this.queue.values(),n=t.next();!n.done;)n.value.hasPendingModels&&n.value.uploadBuffers(e),n=t.next()},t.recordCommandBuffer=function(e,t,n){for(var i=this.queue.values(),r=i.next();!r.done;){var a=r.value,s=a.instances,o=a.pass;if(a.hasPendingModels){n.bindDescriptorSet(Vl.MATERIAL,o.descriptorSet);for(var c=null,l=0;l<s.length;++l){var u=s[l];if(u.count){var h=zi.get(u.hShader),_=Wg.getOrCreatePipelineState(e,o,h,t,u.ia);c!==_&&(n.bindPipelineState(_),c=_),n.bindDescriptorSet(Vl.LOCAL,Ui.get(u.hDescriptorSet),r.value.dynamicOffsets),n.bindInputAssembler(u.ia),n.draw(u.ia)}}}r=i.next()}},e}(),Zg=function(){function e(e){this.batches=[],this.dynamicOffsets=[],this._device=void 0,this._device=e.device}e.get=function(t,n){void 0===n&&(n=0);var i=e._buffers;i.has(t)||i.set(t,{});var r=i.get(t);return r[n]||(r[n]=new e(t))};var t=e.prototype;return t.destroy=function(){for(var e=0;e<this.batches.length;++e){for(var t=this.batches[e],n=0;n<t.vbs.length;++n)t.vbs[n].destroy();t.vbIdx.destroy(),t.ia.destroy(),t.ubo.destroy()}this.batches.length=0},t.merge=function(e,t,n){var i=e.subMesh.flatBuffers;if(0!==i.length){for(var r=0,a=0,s=i[0].count,o=e.passes[t],c=ir.get(e.handle,Ji.SHADER_0+t),l=e.descriptorSet,u=!1,h=0;h<this.batches.length;++h){var _=this.batches[h];if(_.vbs.length===i.length&&_.mergeCount<su.BATCHING_COUNT){u=!0;for(var f=0;f<_.vbs.length;++f)if(_.vbs[f].stride!==i[f].stride){u=!1;break}if(u){for(var d=0;d<_.vbs.length;++d){var p=i[d],m=_.vbs[d],g=_.vbDatas[d];(r=(s+_.vbCount)*p.stride)>m.size&&(m.resize(r),_.vbDatas[d]=new Uint8Array(r),_.vbDatas[d].set(g)),_.vbDatas[d].set(p.buffer,_.vbCount*p.stride)}var v=_.vbIdxData;(a=4*(s+_.vbCount))>_.vbIdx.size&&(_.vbIdx.resize(a),_.vbIdxData=new Float32Array(a/Float32Array.BYTES_PER_ELEMENT),_.vbIdxData.set(v),v=_.vbIdxData);var y=_.vbCount,S=y+s,E=_.mergeCount;if(v[y]!==E||v[S-1]!==E)for(var T=y;T<S;T++)v[T]=E+.1;return Hn.toArray(_.uboData,n.transform.worldMatrix,su.MAT_WORLDS_OFFSET+16*_.mergeCount),_.mergeCount||(l.bindBuffer(su.BINDING,_.ubo),l.update(),_.pass=o,_.hShader=c,_.descriptorSet=l),++_.mergeCount,_.vbCount+=s,void(_.ia.vertexCount+=s)}}}for(var A=[],x=[],C=[],R=0;R<i.length;++R){var b=i[R],w=this._device.createBuffer(new Ps(Ua.VERTEX|Ua.TRANSFER_DST,Ga.HOST|Ga.DEVICE,b.count*b.stride,b.stride));w.update(b.buffer.buffer),A.push(w),x.push(new Uint8Array(w.size)),C.push(w)}var I=this._device.createBuffer(new Ps(Ua.VERTEX|Ua.TRANSFER_DST,Ga.HOST|Ga.DEVICE,4*s,4)),O=new Float32Array(s);O.fill(0),I.update(O),C.push(I);for(var P=e.inputAssembler.attributes,M=new Array(P.length+1),N=0;N<P.length;++N)M[N]=P[N];M[P.length]=new Ws("a_dyn_batch_id",za.R32F,!1,i.length);var D=new js(M,C),B=this._device.createInputAssembler(D),L=this._device.createBuffer(new Ps(Ua.UNIFORM|Ua.TRANSFER_DST,Ga.HOST|Ga.DEVICE,su.SIZE,su.SIZE));l.bindBuffer(su.BINDING,L),l.update();var F=new Float32Array(su.COUNT);Hn.toArray(F,n.transform.worldMatrix,su.MAT_WORLDS_OFFSET),this.batches.push({mergeCount:1,vbs:A,vbDatas:x,vbIdx:I,vbIdxData:O,vbCount:s,ia:B,ubo:L,uboData:F,pass:o,hShader:c,descriptorSet:l})}},t.clear=function(){for(var e=0;e<this.batches.length;++e){var t=this.batches[e];t.vbCount=0,t.mergeCount=0,t.ia.vertexCount=0}},e}();Zg._buffers=new Map;var Qg=new bn,Jg=new bn,$g=new bn,ev=new Hn,tv=new al,nv=!1,iv=[],rv=Na.create(0,0,0,1),av=new c_((function(){return{model:null,depth:0}}),128),sv=new c_((function(){return{model:null,depth:0}}),128);function ov(e,t){var n=0;e.node&&(bn.subtract(Qg,e.node.worldPosition,t.position),n=bn.dot(Qg,t.forward));var i=av.alloc();return i.model=e,i.depth=n,i}function cv(e,t){var n=0;e.node&&(bn.subtract(Qg,e.node.worldPosition,t.position),n=bn.dot(Qg,t.forward));var i=sv.alloc();return i.model=e,i.depth=n,i}function lv(e,t,n,i){var r=e.shadows;bn.negate(Jg,n);var a=r.sphere.radius*rm.COEFFICIENT_OF_EXPANSION;return bn.multiplyScalar($g,Jg,a),bn.add($g,$g,r.sphere.center),i.set($g),Hn.fromRT(ev,t,$g),ev}function uv(e,t,n){var i=t.direction,r=e.normal,a=e.distance+.001,s=1/bn.dot(r,i),o=i.x*s,c=i.y*s,l=i.z*s,u=r.x,h=r.y,_=r.z,f=e.matLight;f.m00=1-u*o,f.m01=-u*c,f.m02=-u*l,f.m03=0,f.m04=-h*o,f.m05=1-h*c,f.m06=-h*l,f.m07=0,f.m08=-_*o,f.m09=-_*c,f.m10=1-_*l,f.m11=0,f.m12=o*a,f.m13=c*a,f.m14=l*a,f.m15=1,Hn.toArray(n,f,Kl.MAT_LIGHT_PLANE_PROJ_OFFSET)}var hv=[Ja.LINEAR,Ja.LINEAR,Ja.NONE,$a.CLAMP,$a.CLAMP,$a.CLAMP],_v=new c_((function(){return{subModel:null,passIdx:-1,dynamicOffsets:[],lights:[]}}),16),fv=new Float32Array(4),dv=Na.create(0,0,0,1),pv=[],mv=[],gv=new Hn,vv=new Hn;function yv(e,t){return!(!t.worldBounds||Xc.aabbWithAABB(t.worldBounds,e.aabb))}function Sv(e,t){return!(!t.worldBounds||Xc.aabbWithAABB(t.worldBounds,e.aabb)&&Xc.aabbFrustum(t.worldBounds,e.frustum))}var Ev=Yd("forward-add"),Tv=[];function Av(e,t){t.length=0;for(var n=!1,i=0;i<e.length;i++){for(var r=e[i].passes,a=-1,s=0;s<r.length;s++)if(r[s].phase===Ev){a=s,n=!0;break}t.push(a)}return n}var xv,Cv,Rv,bv,wv,Iv,Ov,Pv,Mv,Nv,Dv,Bv,Lv,Fv,zv,Uv,Gv,kv,Hv,Vv,Wv,jv,qv,Xv,Yv,Kv,Zv,Qv,Jv,$v,ey,ty,ny,iy,ry,ay,sy,oy,cy,ly,uy,hy,_y,fy,dy,py,my,gy,vy,yy,Sy,Ey,Ty,Ay,xy,Cy,Ry,by,wy,Iy,Oy,Py,My,Ny,Dy,By,Ly,Fy,zy,Uy,Gy,ky,Hy,Vy,Wy,jy,qy,Xy,Yy,Ky,Zy=function(){function e(e){this._pipeline=void 0,this._device=void 0,this._validLights=[],this._lightPasses=[],this._descriptorSetMap=new Map,this._globalUBO=new Float32Array(Xl.COUNT),this._cameraUBO=new Float32Array(Yl.COUNT),this._shadowUBO=new Float32Array(Kl.COUNT),this._lightBufferCount=16,this._lightBufferStride=void 0,this._lightBufferElementCount=void 0,this._lightBuffer=void 0,this._firstLightBufferView=void 0,this._lightBufferData=void 0,this._isHDR=void 0,this._fpScale=void 0,this._renderObjects=void 0,this._instancedQueue=void 0,this._batchedQueue=void 0,this._lightMeterScale=1e4,this._sampler=null,this._pipeline=e,this._device=e.device,this._isHDR=e.isHDR,this._fpScale=e.fpScale,this._renderObjects=e.renderObjects,this._instancedQueue=new Kg,this._batchedQueue=new Yg,this._lightBufferStride=Math.ceil(ou.SIZE/this._device.uboOffsetAlignment)*this._device.uboOffsetAlignment,this._lightBufferElementCount=this._lightBufferStride/Float32Array.BYTES_PER_ELEMENT,this._lightBuffer=this._device.createBuffer(new Ps(Ua.UNIFORM|Ua.TRANSFER_DST,Ga.HOST|Ga.DEVICE,this._lightBufferStride*this._lightBufferCount,this._lightBufferStride)),this._firstLightBufferView=this._device.createBuffer(new Ms(this._lightBuffer,0,ou.SIZE)),this._lightBufferData=new Float32Array(this._lightBufferElementCount*this._lightBufferCount);var t=j_(hv);this._sampler=af.getSampler(this._device,t)}var t=e.prototype;return t.clear=function(){this._instancedQueue.clear(),this._batchedQueue.clear(),this._validLights.length=0;for(var e=0;e<this._lightPasses.length;e++){var t=this._lightPasses[e];t.dynamicOffsets.length=0,t.lights.length=0}_v.freeArray(this._lightPasses),this._lightPasses.length=0},t.destroy=function(){for(var e=Array.from(this._descriptorSetMap.values()),t=0;t<e.length;++t){var n=e[t];n&&(n.getBuffer(Xl.BINDING).destroy(),n.getBuffer(Kl.BINDING).destroy(),n.getSampler(Zl).destroy(),n.getSampler(nu).destroy(),n.getTexture(Zl).destroy(),n.getTexture(nu).destroy(),n.destroy())}this._descriptorSetMap.clear()},t.gatherLightPasses=function(e,t){var n=this._validLights;if(this.clear(),this._gatherValidLights(e,n),n.length){this._updateUBOs(e,t),this._updateLightDescriptorSet(e,t);for(var i=0;i<this._renderObjects.length;i++){var r=this._renderObjects[i].model,a=r.subModels;if(Av(a,Tv)&&(mv.length=0,this._lightCulling(r,n),mv.length))for(var s=0;s<a.length;s++){var o=Tv[s];if(!(o<0)){var c=a[s],l=c.passes[o];c.descriptorSet.bindBuffer(ou.BINDING,this._firstLightBufferView),c.descriptorSet.update(),this._addRenderQueue(l,c,r,o,n)}}}this._instancedQueue.uploadBuffers(t),this._batchedQueue.uploadBuffers(t)}},t.recordCommandBuffer=function(e,t,n){this._instancedQueue.recordCommandBuffer(e,t,n),this._batchedQueue.recordCommandBuffer(e,t,n);for(var i=0;i<this._lightPasses.length;i++){var r=this._lightPasses[i],a=r.subModel,s=r.passIdx,o=r.dynamicOffsets,c=r.lights,l=zi.get(ir.get(a.handle,Ji.SHADER_0+s)),u=a.passes[s],h=a.inputAssembler,_=Wg.getOrCreatePipelineState(e,u,l,t,h),f=Ui.get(er.get(u.handle,Fi.DESCRIPTOR_SET)),d=a.descriptorSet;n.bindPipelineState(_),n.bindDescriptorSet(Vl.MATERIAL,f),n.bindInputAssembler(h);for(var p=0;p<o.length;++p){var m=c[p],g=this._getOrCreateDescriptorSet(m);pv[0]=o[p],n.bindDescriptorSet(Vl.GLOBAL,g),n.bindDescriptorSet(Vl.LOCAL,d,pv),n.draw(h)}}},t._gatherValidLights=function(e,t){for(var n=e.scene.sphereLights,i=0;i<n.length;i++){var r=n[i];r.baked||(Na.set(dv,r.position.x,r.position.y,r.position.z,r.range),Xc.sphereFrustum(dv,e.frustum)&&(t.push(r),this._getOrCreateDescriptorSet(r)))}for(var a=e.scene.spotLights,s=0;s<a.length;s++){var o=a[s];o.baked||(Na.set(dv,o.position.x,o.position.y,o.position.z,o.range),Xc.sphereFrustum(dv,e.frustum)&&(t.push(o),this._getOrCreateDescriptorSet(o)))}},t._lightCulling=function(e,t){for(var n=0;n<t.length;n++){var i=t[n],r=!1;switch(i.type){case ep.SPHERE:r=yv(i,e);break;case ep.SPOT:r=Sv(i,e)}r||mv.push(n)}},t._addRenderQueue=function(e,t,n,i,r){var a=e.batchingScheme;if(a===Wd.INSTANCING)for(var s=0;s<mv.length;s++){var o=mv[s],c=up.get(e,o);c.merge(t,n.instancedAttributes,i),c.dynamicOffsets[0]=this._lightBufferStride*o,this._instancedQueue.queue.add(c)}else if(a===Wd.VB_MERGING)for(var l=0;l<mv.length;l++){var u=mv[l],h=Zg.get(e,u);h.merge(t,i,n),h.dynamicOffsets[0]=this._lightBufferStride*u,this._batchedQueue.queue.add(h)}else{var _=_v.alloc();_.subModel=t,_.passIdx=i;for(var f=0;f<mv.length;f++){var d=mv[f];_.lights.push(r[d]),_.dynamicOffsets.push(this._lightBufferStride*d)}this._lightPasses.push(_)}},t._updateLightDescriptorSet=function(e,t){for(var n=this._pipeline.shadows,i=e.scene.mainLight,r=0;r<this._validLights.length;r++){var a=this._validLights[r],s=this._getOrCreateDescriptorSet(a);if(s){switch(this._updateGlobalDescriptorSet(e,t),a.type){case ep.SPHERE:i&&uv(n,i,this._shadowUBO),Cn.toArray(this._shadowUBO,n.shadowColor,Kl.SHADOW_COLOR_OFFSET),this._shadowUBO[Kl.SHADOW_INFO_OFFSET+0]=n.size.x,this._shadowUBO[Kl.SHADOW_INFO_OFFSET+1]=n.size.y,this._shadowUBO[Kl.SHADOW_INFO_OFFSET+2]=n.pcf,this._shadowUBO[Kl.SHADOW_INFO_OFFSET+3]=n.bias;break;case ep.SPOT:if(i&&uv(n,i,this._shadowUBO),Hn.invert(gv,a.node.getWorldMatrix()),Hn.perspective(vv,a.spotAngle,a.aspect,.001,a.range),Hn.multiply(vv,vv,gv),Hn.toArray(this._shadowUBO,vv,Kl.MAT_LIGHT_VIEW_PROJ_OFFSET),Cn.toArray(this._shadowUBO,n.shadowColor,Kl.SHADOW_COLOR_OFFSET),this._shadowUBO[Kl.SHADOW_INFO_OFFSET+0]=n.size.x,this._shadowUBO[Kl.SHADOW_INFO_OFFSET+1]=n.size.y,this._shadowUBO[Kl.SHADOW_INFO_OFFSET+2]=n.pcf,this._shadowUBO[Kl.SHADOW_INFO_OFFSET+3]=n.bias,this._pipeline.shadowFrameBufferMap.has(a)&&this._pipeline.shadowFrameBufferMap.has(a)){var o,c=null===(o=this._pipeline.shadowFrameBufferMap.get(a))||void 0===o?void 0:o.colorTextures[0];c&&s.bindTexture(nu,c)}}s.update(),t.updateBuffer(s.getBuffer(Xl.BINDING),this._globalUBO),t.updateBuffer(s.getBuffer(Yl.BINDING),this._cameraUBO),t.updateBuffer(s.getBuffer(Kl.BINDING),this._shadowUBO)}}},t._updateGlobalDescriptorSet=function(e){var t=i.director.root,n=this._pipeline.device,r=this._globalUBO,a=Math.floor(n.width),s=Math.floor(n.height);r[Xl.TIME_OFFSET]=t.cumulativeTime,r[Xl.TIME_OFFSET+1]=t.frameTime,r[Xl.TIME_OFFSET+2]=i.director.getTotalFrames(),r[Xl.SCREEN_SIZE_OFFSET]=n.width,r[Xl.SCREEN_SIZE_OFFSET+1]=n.height,r[Xl.SCREEN_SIZE_OFFSET+2]=1/n.width,r[Xl.SCREEN_SIZE_OFFSET+3]=1/n.height,r[Xl.NATIVE_SIZE_OFFSET]=a,r[Xl.NATIVE_SIZE_OFFSET+1]=s,r[Xl.NATIVE_SIZE_OFFSET+2]=1/r[Xl.NATIVE_SIZE_OFFSET],r[Xl.NATIVE_SIZE_OFFSET+3]=1/r[Xl.NATIVE_SIZE_OFFSET+1],this._updateCameraUBO(e)},t._updateCameraUBO=function(e){var t=this._pipeline,n=e.scene.mainLight,i=t.ambient,r=t.shadingScale,a=this._pipeline.device,s=Math.floor(a.width),o=Math.floor(a.height),c=t.fog,l=this._cameraUBO;l[Yl.SCREEN_SCALE_OFFSET]=e.width/s*r,l[Yl.SCREEN_SCALE_OFFSET+1]=e.height/o*r,l[Yl.SCREEN_SCALE_OFFSET+2]=1/l[Yl.SCREEN_SCALE_OFFSET],l[Yl.SCREEN_SCALE_OFFSET+3]=1/l[Yl.SCREEN_SCALE_OFFSET+1];var u=e.exposure;if(l[Yl.EXPOSURE_OFFSET]=u,l[Yl.EXPOSURE_OFFSET+1]=1/u,l[Yl.EXPOSURE_OFFSET+2]=this._isHDR?1:0,l[Yl.EXPOSURE_OFFSET+3]=this._fpScale/u,n){if(bn.toArray(l,n.direction,Yl.MAIN_LIT_DIR_OFFSET),bn.toArray(l,n.color,Yl.MAIN_LIT_COLOR_OFFSET),n.useColorTemperature){var h=n.colorTemperatureRGB;l[Yl.MAIN_LIT_COLOR_OFFSET]*=h.x,l[Yl.MAIN_LIT_COLOR_OFFSET+1]*=h.y,l[Yl.MAIN_LIT_COLOR_OFFSET+2]*=h.z}this._isHDR?l[Yl.MAIN_LIT_COLOR_OFFSET+3]=n.illuminance*this._fpScale:l[Yl.MAIN_LIT_COLOR_OFFSET+3]=n.illuminance*u}else bn.toArray(l,bn.UNIT_Z,Yl.MAIN_LIT_DIR_OFFSET),Zn.toArray(l,Zn.ZERO,Yl.MAIN_LIT_COLOR_OFFSET);Hn.toArray(l,e.matView,Yl.MAT_VIEW_OFFSET),Hn.toArray(l,e.node.worldMatrix,Yl.MAT_VIEW_INV_OFFSET),Hn.toArray(l,e.matProj,Yl.MAT_PROJ_OFFSET),Hn.toArray(l,e.matProjInv,Yl.MAT_PROJ_INV_OFFSET),Hn.toArray(l,e.matViewProj,Yl.MAT_VIEW_PROJ_OFFSET),Hn.toArray(l,e.matViewProjInv,Yl.MAT_VIEW_PROJ_INV_OFFSET),bn.toArray(l,e.position,Yl.CAMERA_POS_OFFSET);var _=a.screenSpaceSignY;e.window.hasOffScreenAttachments&&(_*=a.UVSpaceSignY),l[Yl.CAMERA_POS_OFFSET+3]=_;var f=i.colorArray;this._isHDR?f[3]=i.skyIllum*this._fpScale:f[3]=i.skyIllum*u,l.set(f,Yl.AMBIENT_SKY_OFFSET),l.set(i.albedoArray,Yl.AMBIENT_GROUND_OFFSET),c.enabled&&(l.set(c.colorArray,Yl.GLOBAL_FOG_COLOR_OFFSET),l[Yl.GLOBAL_FOG_BASE_OFFSET]=c.fogStart,l[Yl.GLOBAL_FOG_BASE_OFFSET+1]=c.fogEnd,l[Yl.GLOBAL_FOG_BASE_OFFSET+2]=c.fogDensity,l[Yl.GLOBAL_FOG_ADD_OFFSET]=c.fogTop,l[Yl.GLOBAL_FOG_ADD_OFFSET+1]=c.fogRange,l[Yl.GLOBAL_FOG_ADD_OFFSET+2]=c.fogAtten)},t._updateUBOs=function(e,t){var n=e.exposure;this._validLights.length>this._lightBufferCount&&(this._firstLightBufferView.destroy(),this._lightBufferCount=yn(this._validLights.length),this._lightBuffer.resize(this._lightBufferStride*this._lightBufferCount),this._lightBufferData=new Float32Array(this._lightBufferElementCount*this._lightBufferCount),this._firstLightBufferView.initialize(new Ms(this._lightBuffer,0,ou.SIZE)));for(var i=0,r=0;i<this._validLights.length;i++,r+=this._lightBufferElementCount){var a=this._validLights[i];switch(a.type){case ep.SPHERE:if(bn.toArray(fv,a.position),fv[3]=0,this._lightBufferData.set(fv,r+ou.LIGHT_POS_OFFSET),fv[0]=a.size,fv[1]=a.range,fv[2]=0,this._lightBufferData.set(fv,r+ou.LIGHT_SIZE_RANGE_ANGLE_OFFSET),bn.toArray(fv,a.color),a.useColorTemperature){var s=a.colorTemperatureRGB;fv[0]*=s.x,fv[1]*=s.y,fv[2]*=s.z}this._isHDR?fv[3]=a.luminance*this._fpScale*this._lightMeterScale:fv[3]=a.luminance*n*this._lightMeterScale,this._lightBufferData.set(fv,r+ou.LIGHT_COLOR_OFFSET);break;case ep.SPOT:if(bn.toArray(fv,a.position),fv[3]=1,this._lightBufferData.set(fv,r+ou.LIGHT_POS_OFFSET),fv[0]=a.size,fv[1]=a.range,fv[2]=a.spotAngle,this._lightBufferData.set(fv,r+ou.LIGHT_SIZE_RANGE_ANGLE_OFFSET),bn.toArray(fv,a.direction),this._lightBufferData.set(fv,r+ou.LIGHT_DIR_OFFSET),bn.toArray(fv,a.color),a.useColorTemperature){var o=a.colorTemperatureRGB;fv[0]*=o.x,fv[1]*=o.y,fv[2]*=o.z}this._isHDR?fv[3]=a.luminance*this._fpScale*this._lightMeterScale:fv[3]=a.luminance*n*this._lightMeterScale,this._lightBufferData.set(fv,r+ou.LIGHT_COLOR_OFFSET)}}t.updateBuffer(this._lightBuffer,this._lightBufferData)},t._getOrCreateDescriptorSet=function(e){if(!this._descriptorSetMap.has(e)){var t=this._device,n=t.createDescriptorSet(new Po(this._pipeline.descriptorSetLayout)),i=t.createBuffer(new Ps(Ua.UNIFORM|Ua.TRANSFER_DST,Ga.HOST|Ga.DEVICE,Xl.SIZE,Xl.SIZE));n.bindBuffer(Xl.BINDING,i);var r=t.createBuffer(new Ps(Ua.UNIFORM|Ua.TRANSFER_DST,Ga.HOST|Ga.DEVICE,Yl.SIZE,Yl.SIZE));n.bindBuffer(Yl.BINDING,r);var a=t.createBuffer(new Ps(Ua.UNIFORM|Ua.TRANSFER_DST,Ga.HOST|Ga.DEVICE,Kl.SIZE,Kl.SIZE));return n.bindBuffer(Kl.BINDING,a),n.bindSampler(Zl,this._sampler),n.bindTexture(Zl,Xd.get("default-texture").getGFXTexture()),n.bindSampler(nu,this._sampler),n.bindTexture(nu,Xd.get("default-texture").getGFXTexture()),n.update(),this._descriptorSetMap.set(e,n),n}return this._descriptorSetMap.get(e)},e}();ht(es),ht(ts),ht(cs),ht(os),ht(ls),function(e){e[e.SCENE=0]="SCENE",e[e.POSTPROCESS=1]="POSTPROCESS",e[e.UI=2]="UI"}(Ky||(Ky={})),ht(Ky),xv=ih("RenderTextureDesc"),Cv=Dh(es),Rv=Dh(ts),bv=Dh(za),xv((Iv=J((wv=function(){Q(this,"name",Iv,this),Q(this,"type",Ov,this),Q(this,"usage",Pv,this),Q(this,"format",Mv,this),Q(this,"width",Nv,this),Q(this,"height",Dv,this)}).prototype,"name",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),Ov=J(wv.prototype,"type",[Cv],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return es.TEX2D}}),Pv=J(wv.prototype,"usage",[Rv],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return ts.COLOR_ATTACHMENT}}),Mv=J(wv.prototype,"format",[bv],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return za.UNKNOWN}}),Nv=J(wv.prototype,"width",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return-1}}),Dv=J(wv.prototype,"height",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return-1}}),wv));var Qy,Jy=(Bv=ih("RenderTextureConfig"),Lv=Dh($p),Bv((Uv=J((zv=function(){Q(this,"name",Uv,this),Q(this,"texture",Gv,this)}).prototype,"name",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),Gv=J(zv.prototype,"texture",[Lv],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Fv=zv))||Fv),$y=(kv=ih("MaterialConfig"),Hv=Dh(em),kv((jv=J((Wv=function(){Q(this,"name",jv,this),Q(this,"material",qv,this)}).prototype,"name",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),qv=J(Wv.prototype,"material",[Hv],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Vv=Wv))||Vv),eS=(Xv=ih("FrameBufferDesc"),Yv=Dh([Ft]),Kv=Dh($p),Xv((Qv=J((Zv=function(){Q(this,"name",Qv,this),Q(this,"renderPass",Jv,this),Q(this,"colorTextures",$v,this),Q(this,"depthStencilTexture",ey,this),Q(this,"texture",ty,this)}).prototype,"name",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),Jv=J(Zv.prototype,"renderPass",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),$v=J(Zv.prototype,"colorTextures",[Yv],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),ey=J(Zv.prototype,"depthStencilTexture",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),ty=J(Zv.prototype,"texture",[Kv],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Zv)),ny=ih("ColorDesc"),iy=Dh(za),ry=Dh(os),ay=Dh(cs),sy=Dh(ls),oy=Dh(ls),ny((uy=J((ly=function(){Q(this,"format",uy,this),Q(this,"loadOp",hy,this),Q(this,"storeOp",_y,this),Q(this,"sampleCount",fy,this),Q(this,"beginLayout",dy,this),Q(this,"endLayout",py,this)}).prototype,"format",[iy],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return za.UNKNOWN}}),hy=J(ly.prototype,"loadOp",[ry],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return os.CLEAR}}),_y=J(ly.prototype,"storeOp",[ay],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return cs.STORE}}),fy=J(ly.prototype,"sampleCount",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),dy=J(ly.prototype,"beginLayout",[sy],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return ls.UNDEFINED}}),py=J(ly.prototype,"endLayout",[oy],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return ls.PRESENT_SRC}}),cy=ly))||cy),tS=(my=ih("DepthStencilDesc"),gy=Dh(za),vy=Dh(os),yy=Dh(cs),Sy=Dh(os),Ey=Dh(cs),Ty=Dh(ls),Ay=Dh(ls),my((Ry=J((Cy=function(){Q(this,"format",Ry,this),Q(this,"depthLoadOp",by,this),Q(this,"depthStoreOp",wy,this),Q(this,"stencilLoadOp",Iy,this),Q(this,"stencilStoreOp",Oy,this),Q(this,"sampleCount",Py,this),Q(this,"beginLayout",My,this),Q(this,"endLayout",Ny,this)}).prototype,"format",[gy],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return za.UNKNOWN}}),by=J(Cy.prototype,"depthLoadOp",[vy],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return os.CLEAR}}),wy=J(Cy.prototype,"depthStoreOp",[yy],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return cs.STORE}}),Iy=J(Cy.prototype,"stencilLoadOp",[Sy],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return os.CLEAR}}),Oy=J(Cy.prototype,"stencilStoreOp",[Ey],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return cs.STORE}}),Py=J(Cy.prototype,"sampleCount",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),My=J(Cy.prototype,"beginLayout",[Ty],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return ls.UNDEFINED}}),Ny=J(Cy.prototype,"endLayout",[Ay],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return ls.DEPTH_STENCIL_ATTACHMENT_OPTIMAL}}),xy=Cy))||xy);Dy=ih("RenderPassDesc"),By=Dh([eS]),Ly=Dh(tS),Dy((zy=J((Fy=function(){Q(this,"index",zy,this),Q(this,"colorAttachments",Uy,this),Q(this,"depthStencilAttachment",Gy,this)}).prototype,"index",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return-1}}),Uy=J(Fy.prototype,"colorAttachments",[By],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Gy=J(Fy.prototype,"depthStencilAttachment",[Ly],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new tS}}),Fy)),function(e){e[e.FRONT_TO_BACK=0]="FRONT_TO_BACK",e[e.BACK_TO_FRONT=1]="BACK_TO_FRONT"}(Qy||(Qy={})),ht(Qy);var nS,iS,rS,aS,sS,oS,cS,lS,uS,hS,_S,fS=(ky=ih("RenderQueueDesc"),Hy=Dh(Qy),Vy=Dh([Ft]),ky((qy=J((jy=function(){Q(this,"isTransparent",qy,this),Q(this,"sortMode",Xy,this),Q(this,"stages",Yy,this)}).prototype,"isTransparent",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Xy=J(jy.prototype,"sortMode",[Hy],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Qy.FRONT_TO_BACK}}),Yy=J(jy.prototype,"stages",[Vy],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Wy=jy))||Wy),dS=new al,pS=function(){function e(e){this._pendingModels=[],this._instancedQueue=new Kg,this._pipeline=void 0,this._pipeline=e}var t=e.prototype;return t.gatherShadowPasses=function(e,t){var n=this._pipeline.shadows;if(this._pendingModels.length=0,n.enabled&&n.type===tm.Planar){this._pipeline.updateShadowUBO(e);var i=e.scene,r=e.frustum,a=0!=(e.visibility&Ll.BitMask.DEFAULT);if(i.mainLight&&a){var s=this._pipeline.renderObjects,o=up.get(n.instancingMaterial.passes[0]);this._instancedQueue.clear(),this._instancedQueue.queue.add(o);for(var c=0;c<s.length;c++){var l=s[c].model;if(l.enabled&&l.node&&l.castShadow&&(!l.worldBounds||(al.transform(dS,l.worldBounds,n.matLight),Xc.aabbFrustum(dS,r))))if(l.isInstancingEnabled)for(var u=0;u<l.subModels.length;u++)o.merge(l.subModels[u],l.instancedAttributes,0);else this._pendingModels.push(l)}this._instancedQueue.uploadBuffers(t)}}},t.recordCommandBuffer=function(e,t,n){var i=this._pipeline.shadows;if(i.enabled&&i.type===tm.Planar&&this._pendingModels.length){this._instancedQueue.recordCommandBuffer(e,t,n);var r=i.material.passes[0],a=Ui.get(er.get(r.handle,Fi.DESCRIPTOR_SET));n.bindDescriptorSet(Vl.MATERIAL,a);for(var s=this._pendingModels.length,o=0;o<s;o++)for(var c=this._pendingModels[o],l=0;l<c.subModels.length;l++){var u=c.subModels[l],h=zi.get(u.planarShaderHandel),_=u.inputAssembler,f=Wg.getOrCreatePipelineState(e,r,h,t,_);n.bindPipelineState(f),n.bindDescriptorSet(Vl.LOCAL,u.descriptorSet),n.bindInputAssembler(_),n.draw(_)}}},e}(),mS=function(){function e(){this._phaseID=Yd("default")}var t=e.prototype;return t.activate=function(e){this._pipeline=e},t.render=function(e,t){for(var n=this._pipeline,i=n.device,r=n.commandBuffers[0],a=e.scene.batches,s=0;s<a.length;s++){var o=a[s],c=!1;if(e.visibility&o.visFlags&&(c=!0),c)for(var l=o.handle,u=lr.get(l,rr.PASS_COUNT),h=0;h<u;h++){var _=o.passes[h];if(_.phase===this._phaseID){var f=lr.get(l,rr.SHADER_0+h),d=zi.get(f),p=Gi.get(o.hInputAssembler),m=Ui.get(o.hDescriptorSet),g=Wg.getOrCreatePipelineState(i,_,d,t,p);r.bindPipelineState(g),r.bindDescriptorSet(Vl.MATERIAL,_.descriptorSet),r.bindDescriptorSet(Vl.LOCAL,m),r.bindInputAssembler(p),r.draw(p)}}}},e}(),gS=[new Ks(0,0,0,1)],vS=e("ForwardStage",(nS=ih("ForwardStage"),iS=Dh([fS]),rS=Rh(),nS((lS=cS=function(e){function t(){var t;return Q(t=e.call(this)||this,"renderQueues",oS,Y(t)),t._renderQueues=[],t._renderArea=new Xs,t._batchedQueue=void 0,t._instancedQueue=void 0,t._phaseID=Yd("default"),t._clearFlag=4294967295,t._batchedQueue=new Yg,t._instancedQueue=new Kg,t._uiPhase=new mS,t}X(t,e);var n=t.prototype;return n.initialize=function(t){return e.prototype.initialize.call(this,t),t.renderQueues&&(this.renderQueues=t.renderQueues),!0},n.activate=function(t,n){e.prototype.activate.call(this,t,n);for(var i=0;i<this.renderQueues.length;i++){for(var r=0,a=0;a<this.renderQueues[i].stages.length;a++)r|=Yd(this.renderQueues[i].stages[a]);var s=jg;switch(this.renderQueues[i].sortMode){case Qy.BACK_TO_FRONT:s=qg;break;case Qy.FRONT_TO_BACK:s=jg}this._renderQueues[i]=new Xg({isTransparent:this.renderQueues[i].isTransparent,phases:r,sortFunc:s})}this._additiveLightQueue=new Zy(this._pipeline),this._planarQueue=new pS(this._pipeline),this._uiPhase.activate(t)},n.destroy=function(){},n.render=function(e){this._instancedQueue.clear(),this._batchedQueue.clear();var t=this._pipeline,n=t.device;this._renderQueues.forEach(this.renderQueueClearFunc);for(var i=t.renderObjects,r=0,a=0,s=0,o=0;o<i.length;++o){var c=i[o],l=c.model.subModels;for(r=0;r<l.length;++r){var u=l[r],h=u.passes;for(a=0;a<h.length;++a){var _=h[a];if(_.phase===this._phaseID){var f=_.batchingScheme;if(f===Wd.INSTANCING){var d=up.get(_);d.merge(u,c.model.instancedAttributes,a),this._instancedQueue.queue.add(d)}else if(f===Wd.VB_MERGING){var p=Zg.get(_);p.merge(u,a,c.model),this._batchedQueue.queue.add(p)}else for(s=0;s<this._renderQueues.length;s++)this._renderQueues[s].insertRenderPass(c,r,a)}}}}this._renderQueues.forEach(this.renderQueueSortFunc);var m=t.commandBuffers[0];this._instancedQueue.uploadBuffers(m),this._batchedQueue.uploadBuffers(m),this._additiveLightQueue.gatherLightPasses(e,m),this._planarQueue.gatherShadowPasses(e,m);var g,v,y=e.viewport,S=e.window.hasOnScreenAttachments&&n.surfaceTransform%2?e.height:e.width,E=e.window.hasOnScreenAttachments&&n.surfaceTransform%2?e.width:e.height;if(this._renderArea.x=y.x*S,this._renderArea.y=y.y*E,this._renderArea.width=y.width*S*t.shadingScale,this._renderArea.height=y.height*E*t.shadingScale,e.clearFlag&ds.COLOR)if(t.isHDR){g=gS[0],v=e.clearColor,g.x=v.x*v.x,g.y=v.y*v.y,g.z=v.z*v.z;var T=t.fpScale/e.exposure;gS[0].x*=T,gS[0].y*=T,gS[0].z*=T}else gS[0].x=e.clearColor.x,gS[0].y=e.clearColor.y,gS[0].z=e.clearColor.z;gS[0].w=e.clearColor.w;var A=e.window.framebuffer,x=A.colorTextures[0]?A.renderPass:t.getRenderPass(e.clearFlag&this._clearFlag);m.beginRenderPass(x,A,this._renderArea,gS,e.clearDepth,e.clearStencil),m.bindDescriptorSet(Vl.GLOBAL,t.descriptorSet),this._renderQueues[0].recordCommandBuffer(n,x,m),this._instancedQueue.recordCommandBuffer(n,x,m),this._batchedQueue.recordCommandBuffer(n,x,m),this._additiveLightQueue.recordCommandBuffer(n,x,m),this._planarQueue.recordCommandBuffer(n,x,m),this._renderQueues[1].recordCommandBuffer(n,x,m),this._uiPhase.render(e,x),m.endRenderPass()},n.renderQueueClearFunc=function(e){e.clear()},n.renderQueueSortFunc=function(e){e.sort()},t}(Og),cS.initInfo={name:"ForwardStage",priority:kg.FORWARD,tag:0,renderQueues:[{isTransparent:!1,sortMode:Qy.FRONT_TO_BACK,stages:["default"]},{isTransparent:!0,sortMode:Qy.BACK_TO_FRONT,stages:["default","planarShadow"]}]},oS=J((sS=lS).prototype,"renderQueues",[iS,ch,rS],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),aS=sS))||aS)),yS=e("ForwardFlow",ih("ForwardFlow")((_S=hS=function(e){function t(){return e.apply(this,arguments)||this}X(t,e);var n=t.prototype;return n.initialize=function(t){if(e.prototype.initialize.call(this,t),0===this._stages.length){var n=new vS;n.initialize(vS.initInfo),this._stages.push(n)}return!0},n.activate=function(t){e.prototype.activate.call(this,t)},n.render=function(t){(function(e,t){var n=t.scene,i=n.mainLight,r=e.shadows,a=e.renderObjects;av.freeArray(a),a.length=0,r.enabled&&Cn.toArray(e.shadowUBO,r.shadowColor,Kl.SHADOW_COLOR_OFFSET),i&&r.type===tm.Planar&&function(e,t){var n=e.shadows,i=t.direction,r=n.normal,a=n.distance+.001,s=1/bn.dot(r,i),o=i.x*s,c=i.y*s,l=i.z*s,u=r.x,h=r.y,_=r.z,f=n.matLight;f.m00=1-u*o,f.m01=-u*c,f.m02=-u*l,f.m03=0,f.m04=-h*o,f.m05=1-h*c,f.m06=-h*l,f.m07=0,f.m08=-_*o,f.m09=-_*c,f.m10=1-_*l,f.m11=0,f.m12=o*a,f.m13=c*a,f.m14=l*a,f.m15=1,Hn.toArray(e.shadowUBO,n.matLight,Kl.MAT_LIGHT_PLANE_PROJ_OFFSET)}(e,i),e.skybox.enabled&&e.skybox.model&&t.clearFlag&qu&&a.push(ov(e.skybox.model,t));for(var s=n.models,o=0;o<s.length;o++){var c=s[o];if(c.enabled&&(c.node&&(t.visibility&c.node.layer)===c.node.layer||t.visibility&c.visFlags)){if(c.worldBounds&&!Xc.aabbFrustum(c.worldBounds,t.frustum))continue;a.push(ov(c,t))}}})(this._pipeline,t),e.prototype.render.call(this,t)},n.destroy=function(){e.prototype.destroy.call(this)},t}(Gg),hS.initInfo={name:"ForwardFlow",priority:Hg.FORWARD,stages:[]},uS=_S))||uS),SS=new Hn,ES=new Hn,TS=new Zn,AS=new bn,xS=new Hn,CS=Yd("shadow-caster"),RS=[];function bS(e,t){t.length=0;for(var n=!1,i=0;i<e.length;i++){for(var r=e[i].passes,a=-1,s=0;s<r.length;s++)if(r[s].phase===CS){a=s,n=!0;break}t.push(a)}return n}var wS,IS,OS,PS,MS,NS,DS,BS,LS,FS,zS,US,GS,kS,HS,VS,WS=function(){function e(e){this._pipeline=void 0,this._subModelsArray=[],this._passArray=[],this._shaderArray=[],this._shadowMapBuffer=void 0,this._device=void 0,this._shadowInfo=void 0,this._descriptorSet=void 0,this._shadowObjects=void 0,this._shadowUBO=void 0,this._instancedQueue=void 0,this._batchedQueue=void 0,this._pipeline=e,this._device=e.device,this._shadowInfo=e.shadows,this._descriptorSet=e.descriptorSet,this._shadowObjects=e.shadowObjects,this._shadowUBO=e.shadowUBO,this._shadowMapBuffer=e.descriptorSet.getBuffer(Kl.BINDING),this._instancedQueue=new Kg,this._batchedQueue=new Yg}var t=e.prototype;return t.gatherLightPasses=function(e,t){if(this.clear(),e&&this._shadowInfo.enabled&&this._shadowInfo.type===tm.ShadowMap){this._updateUBOs(e);for(var n=0;n<this._shadowObjects.length;n++){var i=this._shadowObjects[n].model;if(bS(i.subModels,RS))switch(e.type){case ep.DIRECTIONAL:this.add(i,t,RS);break;case ep.SPOT:if(i.worldBounds&&(!Xc.aabbWithAABB(i.worldBounds,e.aabb)||!Xc.aabbFrustum(i.worldBounds,e.frustum)))continue;this.add(i,t,RS)}}}},t.clear=function(){this._subModelsArray.length=0,this._shaderArray.length=0,this._passArray.length=0,this._instancedQueue.clear(),this._batchedQueue.clear()},t.add=function(e,t,n){for(var i=e.subModels,r=0;r<i.length;r++){var a=i[r],s=n[r],o=a.passes[s],c=o.batchingScheme;if(a.descriptorSet.bindBuffer(Kl.BINDING,this._shadowMapBuffer),a.descriptorSet.update(),c===Wd.INSTANCING){var l=up.get(o);l.merge(a,e.instancedAttributes,s),this._instancedQueue.queue.add(l)}else if(o.batchingScheme===Wd.VB_MERGING){var u=Zg.get(o);u.merge(a,s,e),this._batchedQueue.queue.add(u)}else{var h=zi.get(ir.get(a.handle,Ji.SHADER_0+s));this._subModelsArray.push(a),this._shaderArray.push(h),this._passArray.push(o)}}this._instancedQueue.uploadBuffers(t),this._batchedQueue.uploadBuffers(t)},t.recordCommandBuffer=function(e,t,n){this._instancedQueue.recordCommandBuffer(e,t,n),this._batchedQueue.recordCommandBuffer(e,t,n);for(var i=0;i<this._subModelsArray.length;++i){var r=this._subModelsArray[i],a=this._shaderArray[i],s=this._passArray[i],o=r.inputAssembler,c=Wg.getOrCreatePipelineState(e,s,a,t,o),l=s.descriptorSet;n.bindPipelineState(c),n.bindDescriptorSet(Vl.MATERIAL,l),n.bindDescriptorSet(Vl.LOCAL,r.descriptorSet),n.bindInputAssembler(o),n.draw(o)}},t._updateUBOs=function(e){var t=0,n=0,i=0;switch(e.type){case ep.DIRECTIONAL:if(e.update(),this._shadowInfo.autoAdapt){var r=e.node;r&&(xS=lv(this._pipeline,r.getWorldRotation(),e.direction,AS));var a=this._shadowInfo.sphere.radius;t=a*this._shadowInfo.aspect,n=a;var s=bn.distance(this._shadowInfo.sphere.center,AS);i=Math.min(s*rm.COEFFICIENT_OF_EXPANSION,rm.MAX_FAR)}else xS=e.node.getWorldMatrix(),t=this._shadowInfo.orthoSize*this._shadowInfo.aspect,n=this._shadowInfo.orthoSize,i=this._shadowInfo.far;Hn.invert(SS,xS),Hn.ortho(ES,-t,t,-n,n,this._shadowInfo.near,i,this._device.clipSpaceMinZ,this._device.screenSpaceSignY*this._device.UVSpaceSignY);break;case ep.SPOT:Hn.invert(SS,e.node.getWorldMatrix()),Hn.perspective(ES,e.spotAngle,e.aspect,.001,e.range)}Hn.multiply(ES,ES,SS),Hn.toArray(this._shadowUBO,ES,Kl.MAT_LIGHT_VIEW_PROJ_OFFSET),Cn.toArray(this._shadowUBO,this._shadowInfo.shadowColor,Kl.SHADOW_COLOR_OFFSET),TS.set(this._shadowInfo.size.x,this._shadowInfo.size.y,this._shadowInfo.pcf,this._shadowInfo.bias),Zn.toArray(this._shadowUBO,TS,Kl.SHADOW_INFO_OFFSET),this._descriptorSet.getBuffer(Kl.BINDING).update(this._shadowUBO)},e}(),jS=[new Ks(1,1,1,1)],qS=e("ShadowStage",ih("ShadowStage")((OS=IS=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._shadowFrameBuffer=null,t._renderArea=new Xs,t._light=null,t}X(t,e);var n=t.prototype;return n.setUsage=function(e,t){this._light=e,this._shadowFrameBuffer=t},n.destroy=function(){this._additiveShadowQueue.clear()},n.clearFramebuffer=function(e){if(this._light&&this._shadowFrameBuffer){jS[0].w=e.clearColor.w;var t=this._pipeline.commandBuffers[0],n=this._shadowFrameBuffer.renderPass;t.beginRenderPass(n,this._shadowFrameBuffer,this._renderArea,jS,e.clearDepth,e.clearStencil),t.endRenderPass()}},n.render=function(e){var t=this._pipeline,n=t.shadows,i=t.commandBuffers[0];if(this._light&&this._shadowFrameBuffer){this._additiveShadowQueue.gatherLightPasses(this._light,i);var r=e.viewport,a=n.size;this._renderArea.x=r.x*a.x,this._renderArea.y=r.y*a.y,this._renderArea.width=r.width*a.x*t.shadingScale,this._renderArea.height=r.height*a.y*t.shadingScale;var s=t.device,o=this._shadowFrameBuffer.renderPass;i.beginRenderPass(o,this._shadowFrameBuffer,this._renderArea,jS,e.clearDepth,e.clearStencil),i.bindDescriptorSet(Vl.GLOBAL,t.descriptorSet),this._additiveShadowQueue.recordCommandBuffer(s,o,i),i.endRenderPass()}},n.activate=function(t,n){e.prototype.activate.call(this,t,n),this._additiveShadowQueue=new WS(t)},t}(Og),IS.initInfo={name:"ShadowStage",priority:kg.FORWARD,tag:0},wS=OS))||wS),XS=e("ShadowFlow",ih("ShadowFlow")((NS=MS=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._shadowRenderPass=null,t}X(t,e);var n=t.prototype;return n.initialize=function(t){if(e.prototype.initialize.call(this,t),0===this._stages.length){var n=new qS;n.initialize(qS.initInfo),this._stages.push(n)}return!0},n.render=function(e){var t=this._pipeline,n=t.shadows;if(n.enabled&&n.type===tm.ShadowMap){var i=function(e,t){iv.length=0;var n=e.scene;iv.push(n.mainLight);for(var i=n.spotLights,r=0;r<i.length;r++){var a=i[r];Na.set(rv,a.position.x,a.position.y,a.position.z,a.range),Xc.sphereFrustum(rv,e.frustum)&&t>iv.length&&iv.push(a)}return iv}(e,n.maxReceived);if(function(e,t){var n=t.scene,i=e.shadows,r=e.shadowObjects;sv.freeArray(r),r.length=0,nv=!1;for(var a=n.models,s=0;s<a.length;s++){var o=a[s];(o.node&&(t.visibility&o.node.layer)===o.node.layer||t.visibility&o.visFlags)&&o.castShadow&&o.worldBounds&&(nv||(tv.copy(o.worldBounds),nv=!0),al.merge(tv,tv,o.worldBounds),r.push(cv(o,t)))}tv&&al.toBoundingSphere(i.sphere,tv)}(t,e),0!==t.shadowObjects.length){for(var r=0;r<i.length;r++){var a=i[r];t.shadowFrameBufferMap.has(a)||this._initShadowFrameBuffer(t,a);var s=t.shadowFrameBufferMap.get(a);n.shadowMapDirty&&this.resizeShadowMap(a,n.size);for(var o=0;o<this._stages.length;o++){var c=this._stages[o];c.setUsage(a,s),c.render(e)}}t.updateShadowUBO(e)}else this.clearShadowMap(i,e)}},n.destroy=function(){e.prototype.destroy.call(this);for(var t=Array.from(this._pipeline.shadowFrameBufferMap.values()),n=0;n<t.length;n++){var i=t[n];if(i){for(var r=i.colorTextures,a=0;a<r.length;a++){var s=r[n];s&&s.destroy()}r.length=0;var o=i.depthStencilTexture;o&&o.destroy(),i.destroy()}}this._pipeline.shadowFrameBufferMap.clear(),this._shadowRenderPass&&this._shadowRenderPass.destroy()},n._initShadowFrameBuffer=function(e,t){var n=e.device,i=e.shadows.size;if(!this._shadowRenderPass){var r=new uo;r.format=za.RGBA8,r.loadOp=os.CLEAR,r.storeOp=cs.STORE,r.sampleCount=1,r.beginLayout=ls.UNDEFINED,r.endLayout=ls.PRESENT_SRC;var a=new ho;a.format=n.depthStencilFormat,a.depthLoadOp=os.CLEAR,a.depthStoreOp=cs.DISCARD,a.stencilLoadOp=os.CLEAR,a.stencilStoreOp=cs.DISCARD,a.sampleCount=1,a.beginLayout=ls.UNDEFINED,a.endLayout=ls.DEPTH_STENCIL_ATTACHMENT_OPTIMAL;var s=new fo([r],a);this._shadowRenderPass=n.createRenderPass(s)}var o=[];o.push(n.createTexture(new xo(es.TEX2D,ts.COLOR_ATTACHMENT|ts.SAMPLED,za.RGBA8,i.x,i.y)));var c=n.createTexture(new xo(es.TEX2D,ts.DEPTH_STENCIL_ATTACHMENT,n.depthStencilFormat,i.x,i.y)),l=n.createFramebuffer(new Us(this._shadowRenderPass,o,c));e.shadowFrameBufferMap.set(t,l)},n.clearShadowMap=function(e,t){for(var n=this._pipeline,i=0;i<e.length;i++){var r=e[i],a=n.shadowFrameBufferMap.get(r);if(n.shadowFrameBufferMap.has(r))for(var s=0;s<this._stages.length;s++){var o=this._stages[s];o.setUsage(r,a),o.clearFramebuffer(t)}}},n.resizeShadowMap=function(e,t){var n=t.x,i=t.y,r=this._pipeline;if(r.shadowFrameBufferMap.has(e)){var a=r.shadowFrameBufferMap.get(e);if(!a)return;var s=a.colorTextures;if(s&&s.length>0)for(var o=0;o<s.length;o++){var c=s[o];c&&c.resize(n,i)}var l=a.depthStencilTexture;l&&l.resize(n,i);var u=a.renderPass;a.destroy(),a.initialize(new Us(u,s,l))}},t}(Gg),MS.initInfo={name:"ShadowFlow",priority:Hg.SHADOW,tag:Ky.SCENE,stages:[]},PS=NS))||PS),YS=ct({LINEAR:0,EXP:1,EXP_SQUARED:2,LAYERED:3}),KS=YS.LAYERED+1,ZS=function(){function e(){this._fogColor=new Cn("#C8C8C8"),this._colorArray=new Float32Array([.2,.2,.2,1]),this._handle=0,this._handle=Ur.alloc()}j(e,[{key:"enabled",set:function(e){Ur.set(this._handle,Dr.ENABLE,e?1:0),e||Ur.set(this._handle,Dr.TYPE,KS),e?this.activate():this._updatePipeline()},get:function(){return Ur.get(this._handle,Dr.ENABLE)}},{key:"fogColor",set:function(e){this._fogColor.set(e),Cn.toArray(this._colorArray,this._fogColor),Ur.setVec4(this._handle,Dr.COLOR,this._fogColor)},get:function(){return this._fogColor}},{key:"type",get:function(){return Ur.get(this._handle,Dr.TYPE)},set:function(e){Ur.set(this._handle,Dr.TYPE,this.enabled?e:KS),this.enabled&&this._updatePipeline()}},{key:"fogDensity",get:function(){return Ur.get(this._handle,Dr.DENSITY)},set:function(e){Ur.set(this._handle,Dr.DENSITY,e)}},{key:"fogStart",get:function(){return Ur.get(this._handle,Dr.START)},set:function(e){Ur.set(this._handle,Dr.START,e)}},{key:"fogEnd",get:function(){return Ur.get(this._handle,Dr.END)},set:function(e){Ur.set(this._handle,Dr.END,e)}},{key:"fogAtten",get:function(){return Ur.get(this._handle,Dr.ATTEN)},set:function(e){Ur.set(this._handle,Dr.ATTEN,e)}},{key:"fogTop",get:function(){return Ur.get(this._handle,Dr.TOP)},set:function(e){Ur.set(this._handle,Dr.TOP,e)}},{key:"fogRange",get:function(){return Ur.get(this._handle,Dr.RANGE)},set:function(e){Ur.set(this._handle,Dr.RANGE,e)}},{key:"colorArray",get:function(){return this._colorArray}},{key:"handle",get:function(){return this._handle}}]);var t=e.prototype;return t.initialize=function(e){Ur.set(this._handle,Dr.ENABLE,e.enabled?1:0),Ur.set(this._handle,Dr.TYPE,e.enabled?e.type:KS),this._fogColor.set(e.fogColor),Cn.toArray(this._colorArray,this._fogColor),Ur.setVec4(this._handle,Dr.COLOR,this._fogColor),Ur.set(this._handle,Dr.DENSITY,e.fogDensity),Ur.set(this._handle,Dr.START,e.fogStart),Ur.set(this._handle,Dr.END,e.fogEnd),Ur.set(this._handle,Dr.ATTEN,e.fogAtten),Ur.set(this._handle,Dr.TOP,e.fogTop),Ur.set(this._handle,Dr.RANGE,e.fogRange)},t.activate=function(){this._updatePipeline()},t._updatePipeline=function(){var e=i.director.root,t=this.enabled?this.type:KS,n=e.pipeline;n.macros.CC_USE_FOG!==t&&(n.macros.CC_USE_FOG=t,e.onGlobalPipelineStateChanged())},t.destroy=function(){this._handle&&(Ur.free(this._handle),this._handle=0)},e}();i.Fog=ZS;var QS=new Hn,JS=new Hn,$S=new bn,eE=[Ja.LINEAR,Ja.LINEAR,Ja.NONE,$a.CLAMP,$a.CLAMP,$a.CLAMP],tE=e("ForwardPipeline",(DS=ih("ForwardPipeline"),BS=Dh([Jy]),LS=Rh(),FS=Dh([$y]),zS=Rh(),DS((VS=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return Q(t=e.call.apply(e,[this].concat(i))||this,"renderTextures",kS,Y(t)),Q(t,"materials",HS,Y(t)),t.fog=new ZS,t.ambient=new ha,t.skybox=new lm,t.shadows=new rm,t.renderObjects=[],t.shadowObjects=[],t.shadowFrameBufferMap=new Map,t._isHDR=!1,t._shadingScale=1,t._fpScale=1/1024,t._renderPasses=new Map,t._globalUBO=new Float32Array(Xl.COUNT),t._cameraUBO=new Float32Array(Yl.COUNT),t._shadowUBO=new Float32Array(Kl.COUNT),t}X(t,e);var n=t.prototype;return n.initialize=function(t){if(e.prototype.initialize.call(this,t),0===this._flows.length){var n=new XS;n.initialize(XS.initInfo),this._flows.push(n);var i=new yS;i.initialize(yS.initInfo),this._flows.push(i)}return!0},n.activate=function(){return this._macros={},!(!e.prototype.activate.call(this)||!this._activeRenderer()&&(A(2402),1))},n.render=function(e){this._commandBuffers[0].begin(),this.updateGlobalUBO();for(var t=0;t<e.length;t++){var n=e[t];if(n.scene){this.updateCameraUBO(n);for(var i=0;i<this._flows.length;i++)this._flows[i].render(n)}}this._commandBuffers[0].end(),this._device.queue.submit(this._commandBuffers)},n.getRenderPass=function(e){var t=this._renderPasses.get(e);if(t)return t;var n=this.device,i=new uo,r=new ho;i.format=n.colorFormat,r.format=n.depthStencilFormat,r.stencilStoreOp=cs.DISCARD,r.depthStoreOp=cs.DISCARD,e&ds.COLOR||(e&qu?i.loadOp=os.DISCARD:(i.loadOp=os.LOAD,i.beginLayout=ls.PRESENT_SRC)),(e&ds.DEPTH_STENCIL)!==ds.DEPTH_STENCIL&&(e&ds.DEPTH||(r.depthLoadOp=os.LOAD),e&ds.STENCIL||(r.stencilLoadOp=os.LOAD),r.beginLayout=ls.DEPTH_STENCIL_ATTACHMENT_OPTIMAL);var a=new fo([i],r);return t=n.createRenderPass(a),this._renderPasses.set(e,t),t},n.updateGlobalUBO=function(){this._descriptorSet.update();var e=i.director.root,t=this._globalUBO,n=this.device,r=Math.floor(n.width),a=Math.floor(n.height);t[Xl.TIME_OFFSET]=e.cumulativeTime,t[Xl.TIME_OFFSET+1]=e.frameTime,t[Xl.TIME_OFFSET+2]=i.director.getTotalFrames(),t[Xl.SCREEN_SIZE_OFFSET]=n.width,t[Xl.SCREEN_SIZE_OFFSET+1]=n.height,t[Xl.SCREEN_SIZE_OFFSET+2]=1/n.width,t[Xl.SCREEN_SIZE_OFFSET+3]=1/n.height,t[Xl.NATIVE_SIZE_OFFSET]=r,t[Xl.NATIVE_SIZE_OFFSET+1]=a,t[Xl.NATIVE_SIZE_OFFSET+2]=1/t[Xl.NATIVE_SIZE_OFFSET],t[Xl.NATIVE_SIZE_OFFSET+3]=1/t[Xl.NATIVE_SIZE_OFFSET+1],this._commandBuffers[0].updateBuffer(this._descriptorSet.getBuffer(Xl.BINDING),this._globalUBO)},n._activeRenderer=function(){var e=this.device;this._commandBuffers.push(e.commandBuffer);var t=e.createBuffer(new Ps(Ua.UNIFORM|Ua.TRANSFER_DST,Ga.HOST|Ga.DEVICE,Xl.SIZE,Xl.SIZE));this._descriptorSet.bindBuffer(Xl.BINDING,t);var n=e.createBuffer(new Ps(Ua.UNIFORM|Ua.TRANSFER_DST,Ga.HOST|Ga.DEVICE,Yl.SIZE,Yl.SIZE));this._descriptorSet.bindBuffer(Yl.BINDING,n);var i=e.createBuffer(new Ps(Ua.UNIFORM|Ua.TRANSFER_DST,Ga.HOST|Ga.DEVICE,Kl.SIZE,Kl.SIZE));this._descriptorSet.bindBuffer(Kl.BINDING,i);var r=j_(eE),a=af.getSampler(e,r);return this._descriptorSet.bindSampler(Zl,a),this._descriptorSet.bindTexture(Zl,Xd.get("default-texture").getGFXTexture()),this._descriptorSet.bindSampler(nu,a),this._descriptorSet.bindTexture(nu,Xd.get("default-texture").getGFXTexture()),this._descriptorSet.update(),this.macros.CC_USE_HDR=this._isHDR,this.macros.CC_SUPPORT_FLOAT_TEXTURE=this.device.hasFeature(vs.TEXTURE_FLOAT),!0},n.updateShadowUBO=function(e){this._descriptorSet.update();var t=e.scene.mainLight,n=this.device,i=this.shadows;if(i.enabled){if(t&&i.type===tm.ShadowMap){var r;this.shadowFrameBufferMap.has(t)&&this._descriptorSet.bindTexture(Zl,this.shadowFrameBufferMap.get(t).colorTextures[0]);var a=0,s=0,o=0;if(i.autoAdapt){r=lv(this,t.node.getWorldRotation(),t.direction,$S);var c=i.sphere.radius;a=c*i.aspect,s=c;var l=bn.distance(i.sphere.center,$S);o=Math.min(l*rm.COEFFICIENT_OF_EXPANSION,rm.MAX_FAR)}else r=t.node.getWorldMatrix(),a=i.orthoSize*i.aspect,s=i.orthoSize,o=i.far;Hn.invert(QS,r);var u=n.screenSpaceSignY*n.UVSpaceSignY;Hn.ortho(JS,-a,a,-s,s,i.near,o,n.clipSpaceMinZ,u),Hn.multiply(JS,JS,QS),Hn.toArray(this._shadowUBO,JS,Kl.MAT_LIGHT_VIEW_PROJ_OFFSET),this._shadowUBO[Kl.SHADOW_INFO_OFFSET]=i.size.x,this._shadowUBO[Kl.SHADOW_INFO_OFFSET+1]=i.size.y,this._shadowUBO[Kl.SHADOW_INFO_OFFSET+2]=i.pcf,this._shadowUBO[Kl.SHADOW_INFO_OFFSET+3]=i.bias}else t&&i.type===tm.Planar&&uv(i,t,this._shadowUBO);Cn.toArray(this._shadowUBO,i.shadowColor,Kl.SHADOW_COLOR_OFFSET),this._commandBuffers[0].updateBuffer(this._descriptorSet.getBuffer(Kl.BINDING),this._shadowUBO)}},n.updateCameraUBO=function(e){var t=this.device,n=(e.scene?e.scene:i.director.getScene().renderScene).mainLight,r=this.ambient,a=this.fog,s=Math.floor(t.width),o=Math.floor(t.height),c=this._cameraUBO,l=e.exposure;if(c[Yl.SCREEN_SCALE_OFFSET]=e.width/s*this.shadingScale,c[Yl.SCREEN_SCALE_OFFSET+1]=e.height/o*this.shadingScale,c[Yl.SCREEN_SCALE_OFFSET+2]=1/c[Yl.SCREEN_SCALE_OFFSET],c[Yl.SCREEN_SCALE_OFFSET+3]=1/c[Yl.SCREEN_SCALE_OFFSET+1],c[Yl.EXPOSURE_OFFSET]=l,c[Yl.EXPOSURE_OFFSET+1]=1/l,c[Yl.EXPOSURE_OFFSET+2]=this._isHDR?1:0,c[Yl.EXPOSURE_OFFSET+3]=this._fpScale/l,n){if(bn.toArray(c,n.direction,Yl.MAIN_LIT_DIR_OFFSET),bn.toArray(c,n.color,Yl.MAIN_LIT_COLOR_OFFSET),n.useColorTemperature){var u=n.colorTemperatureRGB;c[Yl.MAIN_LIT_COLOR_OFFSET]*=u.x,c[Yl.MAIN_LIT_COLOR_OFFSET+1]*=u.y,c[Yl.MAIN_LIT_COLOR_OFFSET+2]*=u.z}this._isHDR?c[Yl.MAIN_LIT_COLOR_OFFSET+3]=n.illuminance*this._fpScale:c[Yl.MAIN_LIT_COLOR_OFFSET+3]=n.illuminance*l}else bn.toArray(c,bn.UNIT_Z,Yl.MAIN_LIT_DIR_OFFSET),Zn.toArray(c,Zn.ZERO,Yl.MAIN_LIT_COLOR_OFFSET);var h=r.colorArray;this._isHDR?h[3]=r.skyIllum*this._fpScale:h[3]=r.skyIllum*l,c.set(h,Yl.AMBIENT_SKY_OFFSET),c.set(r.albedoArray,Yl.AMBIENT_GROUND_OFFSET),Hn.toArray(c,e.matView,Yl.MAT_VIEW_OFFSET),Hn.toArray(c,e.node.worldMatrix,Yl.MAT_VIEW_INV_OFFSET),Hn.toArray(c,e.matProj,Yl.MAT_PROJ_OFFSET),Hn.toArray(c,e.matProjInv,Yl.MAT_PROJ_INV_OFFSET),Hn.toArray(c,e.matViewProj,Yl.MAT_VIEW_PROJ_OFFSET),Hn.toArray(c,e.matViewProjInv,Yl.MAT_VIEW_PROJ_INV_OFFSET),bn.toArray(c,e.position,Yl.CAMERA_POS_OFFSET);var _=t.screenSpaceSignY;e.window.hasOffScreenAttachments&&(_*=t.UVSpaceSignY),c[Yl.CAMERA_POS_OFFSET+3]=_,a.enabled&&(c.set(a.colorArray,Yl.GLOBAL_FOG_COLOR_OFFSET),c[Yl.GLOBAL_FOG_BASE_OFFSET]=a.fogStart,c[Yl.GLOBAL_FOG_BASE_OFFSET+1]=a.fogEnd,c[Yl.GLOBAL_FOG_BASE_OFFSET+2]=a.fogDensity,c[Yl.GLOBAL_FOG_ADD_OFFSET]=a.fogTop,c[Yl.GLOBAL_FOG_ADD_OFFSET+1]=a.fogRange,c[Yl.GLOBAL_FOG_ADD_OFFSET+2]=a.fogAtten),this._commandBuffers[0].updateBuffer(this._descriptorSet.getBuffer(Yl.BINDING),this._cameraUBO)},n.destroyUBOs=function(){this._descriptorSet&&(this._descriptorSet.getBuffer(Xl.BINDING).destroy(),this._descriptorSet.getBuffer(Kl.BINDING).destroy(),this._descriptorSet.getBuffer(Yl.BINDING).destroy(),this._descriptorSet.getSampler(Zl).destroy(),this._descriptorSet.getSampler(nu).destroy(),this._descriptorSet.getTexture(Zl).destroy(),this._descriptorSet.getTexture(nu).destroy())},n.destroy=function(){this.destroyUBOs();for(var t=this._renderPasses.values(),n=t.next();!n.done;)n.value.destroy(),n=t.next();return this._commandBuffers.length=0,this.ambient.destroy(),this.skybox.destroy(),this.fog.destroy(),this.shadows.destroy(),e.prototype.destroy.call(this)},j(t,[{key:"isHDR",get:function(){return this._isHDR},set:function(e){this._isHDR!==e&&(this._isHDR=e,this._cameraUBO[Yl.EXPOSURE_OFFSET+2]=this._isHDR?1:0)}},{key:"shadingScale",get:function(){return this._shadingScale}},{key:"fpScale",get:function(){return this._fpScale}},{key:"shadowUBO",get:function(){return this._shadowUBO}}]),t}(Vg),kS=J((GS=VS).prototype,"renderTextures",[BS,ch,LS],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),HS=J(GS.prototype,"materials",[FS,ch,zS],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),US=GS))||US));var nE=__.Flags.Destroyed,iE=__.Flags.PersistentMask,rE=$t.IDENTIFIER_RE,aE={"cc.ClickEvent":!1,"cc.PrefabInfo":!1},sE=$t.escapeForJS,oE=function(){function e(e,t){this.varName=void 0,this.expression=void 0,this.varName=e,this.expression=t}return e.prototype.toString=function(){return"var "+this.varName+"="+this.expression+";"},e}();function cE(e,t){return t instanceof oE?new oE(t.varName,e+t.expression):e+t}function lE(e,t,n){Array.isArray(n)?(n[0]=cE(t,n[0]),e.push(n)):e.push(cE(t,n)+";")}var uE=function(){function e(e){this._exps=void 0,this._targetExp=void 0,this._exps=[],this._targetExp=e}var t=e.prototype;return t.append=function(e,t){this._exps.push([e,t])},t.writeCode=function(e){var t;if(this._exps.length>1)e.push("t="+this._targetExp+";"),t="t";else{if(1!==this._exps.length)return;t=this._targetExp}for(var n=0;n<this._exps.length;n++){var i=this._exps[n];lE(e,t+hE(i[0])+"=",i[1])}},e}();function hE(e){return rE.test(e)?"."+e:"["+sE(e)+"]"}uE.pool=void 0,uE.pool=new rt((function(e){e._exps.length=0,e._targetExp=null}),1),uE.pool.get=function(e){var t=this._get()||new uE;return t._targetExp=e,t};var _E=function(){function e(e,t){var n;this.parent=void 0,this.objsToClear_iN$t=void 0,this.codeArray=void 0,this.objs=void 0,this.funcs=void 0,this.funcModuleCache=void 0,this.globalVariables=void 0,this.globalVariableId=void 0,this.localVariableId=void 0,this.result=void 0,this.parent=t,this.objsToClear_iN$t=[],this.codeArray=[],this.objs=[],this.funcs=[],this.funcModuleCache=Pe(),He(this.funcModuleCache,aE),this.globalVariables=[],this.globalVariableId=0,this.localVariableId=0,this.codeArray.push("var o,t;","if(R){","o=R;","}else{","o=R=new "+this.getFuncModule(e.constructor,!0)+"();","}"),e._iN$t={globalVar:"R"},this.objsToClear_iN$t.push(e),this.enumerateObject(this.codeArray,e),this.globalVariables.length>0&&(n="var "+this.globalVariables.join(",")+";");var i=function(e){var t=[];return function e(t,n){for(var i,r=Z(n);!(i=r()).done;){var a=i.value;Array.isArray(a)?e(t,a):t.push(a)}}(t,e),t.join("")}(["return (function(R){",n||[],this.codeArray,"return o;","})"]);this.result=Function("O","F",i)(this.objs,this.funcs);for(var r=0,a=this.objsToClear_iN$t.length;r<a;++r)this.objsToClear_iN$t[r]._iN$t=null;this.objsToClear_iN$t.length=0}var t=e.prototype;return t.getFuncModule=function(e,t){var n=Me(e);if(n){var i=this.funcModuleCache[n];if(i)return i;if(void 0===i){var r=-1!==n.indexOf(".");if(r)try{if(r=e===Function("return "+n)())return this.funcModuleCache[n]=n,n}catch(e){}}}var a=this.funcs.indexOf(e);a<0&&(a=this.funcs.length,this.funcs.push(e));var s="F["+a+"]";return t&&(s="("+s+")"),this.funcModuleCache[n]=s,s},t.getObjRef=function(e){var t=this.objs.indexOf(e);return t<0&&(t=this.objs.length,this.objs.push(e)),"O["+t+"]"},t.setValueType=function(e,t,n,i){var r=uE.pool.get(i),a=t.constructor.__props__;a||(a=Object.keys(t));for(var s=0;s<a.length;s++){var o=a[s],c=n[o];if(t[o]!==c){var l=this.enumerateField(n,o,c);r.append(o,l)}}r.writeCode(e),uE.pool.put(r)},t.enumerateCCClass=function(e,t,n){for(var r=n.__values__,a=Pt(n),s=0;s<r.length;s++){var o=r[s],c=t[o],l=a[o+"$_$default"];if(!fE(l,c))if("object"==typeof c&&c instanceof i.ValueType&&(l=$t.getDefault(l))&&l.constructor===c.constructor){var u="o"+hE(o);this.setValueType(e,l,c,u)}else this.setObjProp(e,t,o,c)}},t.instantiateArray=function(e){if(0===e.length)return"[]";var t="a"+ ++this.localVariableId,n=[new oE(t,"new Array("+e.length+")")];e._iN$t={globalVar:"",source:n},this.objsToClear_iN$t.push(e);for(var i=0;i<e.length;++i)lE(n,t+"["+i+"]=",this.enumerateField(e,i,e[i]));return n},t.instantiateTypedArray=function(e){var t=e.constructor.name;if(0===e.length)return"new "+t;var n="a"+ ++this.localVariableId,i=[new oE(n,"new "+t+"("+e.length+")")];e._iN$t={globalVar:"",source:i},this.objsToClear_iN$t.push(e);for(var r=0;r<e.length;++r)0!==e[r]&&lE(i,n+"["+r+"]=",e[r]);return i},t.enumerateField=function(e,t,n){if("object"==typeof n&&n){var i=n._iN$t;if(i){var r=i.globalVar;if(!r){r=i.globalVar="v"+ ++this.globalVariableId,this.globalVariables.push(r);var a=i.source[0];i.source[0]=cE(r+"=",a)}return r}return ArrayBuffer.isView(n)?this.instantiateTypedArray(n):Array.isArray(n)?this.instantiateArray(n):this.instantiateObj(n)}return"function"==typeof n?this.getFuncModule(n):"string"==typeof n?sE(n):("_objFlags"===t&&e instanceof __&&(n&=iE),n)},t.setObjProp=function(e,t,n,i){lE(e,"o"+hE(n)+"=",this.enumerateField(t,n,i))},t.enumerateObject=function(e,t){var n=t.constructor;if(i.Class._isCCClass(n))this.enumerateCCClass(e,t,n);else for(var r in t)if(t.hasOwnProperty(r)&&(95!==r.charCodeAt(0)||95!==r.charCodeAt(1)||"__type__"===r)){var a=t[r];"object"==typeof a&&a&&a===t._iN$t||this.setObjProp(e,t,r,a)}},t.instantiateObj=function(e){if(e instanceof i.ValueType)return $t.getNewValueTypeCode(e);if(e instanceof i.Asset)return this.getObjRef(e);if(e._objFlags&nE)return null;var t,n=e.constructor;if(i.Class._isCCClass(n)){if(this.parent)if(this.parent instanceof i.Component){if(e instanceof i._BaseNode||e instanceof i.Component)return this.getObjRef(e)}else if(this.parent instanceof i._BaseNode)if(e instanceof i._BaseNode){if(!e.isChildOf(this.parent))return this.getObjRef(e)}else if(e instanceof i.Component&&!e.node.isChildOf(this.parent))return this.getObjRef(e);t=new oE("o","new "+this.getFuncModule(n,!0)+"()")}else if(n===Object)t=new oE("o","{}");else{if(n)return this.getObjRef(e);t=new oE("o","Object.create(null)")}var r=[t];return e._iN$t={globalVar:"",source:r},this.objsToClear_iN$t.push(e),this.enumerateObject(r,e),["(function(){",r,"return o;})();"]},e}();function fE(e,t){if("function"==typeof e)try{e=e()}catch(e){return!1}if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t&&e.constructor===t.constructor)if(e instanceof i.ValueType){if(e.equals(t))return!0}else{if(Array.isArray(e))return 0===e.length&&0===t.length;if(e.constructor===Object)return Ce(e)&&Ce(t)}return!1}var dE=Object.freeze({__proto__:null,ccclass:ih,property:oh,requireComponent:rh,executionOrder:ah,disallowMultiple:sh,executeInEditMode:hh,menu:_h,playOnFocus:fh,inspector:dh,icon:ph,help:mh,type:Dh,integer:Oh,float:Ph,boolean:Mh,string:Nh});e("_decorator",dE);var pE,mE,gE,vE,yE,SE,EE,TE,AE,xE,CE,RE=__.Flags.Destroyed,bE=__.Flags.PersistentMask,wE=[];function IE(e){var t;if(e instanceof __){if(e._instantiate)return i.game._isCloning=!0,t=e._instantiate(null,!0),i.game._isCloning=!1,t;if(e instanceof i.Asset)throw new TypeError(b(6903))}return i.game._isCloning=!0,t=OE(e),i.game._isCloning=!1,t}function OE(e,t){var n;PE(e,n=e._iN$t?e._iN$t:e.constructor?new(0,e.constructor):Object.create(null),t);for(var i=0,r=wE.length;i<r;++i)wE[i]._iN$t=null;return wE.length=0,n}function PE(e,t,n){st.value(e,"_iN$t",t,!0),wE.push(e);var r=e.constructor;if(i.Class._isCCClass(r))!function(e,t,n,i){for(var r=e.__values__,a=0;a<r.length;a++){var s=r[a],o=t[s];if("object"==typeof o&&o){var c=n[s];c instanceof _t&&c.constructor===o.constructor?c.set(o):n[s]=o._iN$t||ME(o,i)}else n[s]=o}}(r,e,t,n);else for(var a in e)if(e.hasOwnProperty(a)&&(95!==a.charCodeAt(0)||95!==a.charCodeAt(1)||"__type__"===a)){var s=e[a];if("object"==typeof s&&s){if(s===t)continue;t[a]=s._iN$t||ME(s,n)}else t[a]=s}e instanceof __&&(t._objFlags&=bE)}function ME(e,t){if(e instanceof _t)return e.clone();if(e instanceof i.Asset)return e;var n;if(ArrayBuffer.isView(e)){var r=e.length;n=new e.constructor(r),e._iN$t=n,wE.push(e);for(var a=0;a<r;++a)n[a]=e[a];return n}if(Array.isArray(e)){var s=e.length;n=new Array(s),e._iN$t=n,wE.push(e);for(var o=0;o<s;++o){var c=e[o];n[o]="object"==typeof c&&c?c._iN$t||ME(c,t):c}return n}if(e._objFlags&RE)return null;var l=e.constructor;if(i.Class._isCCClass(l)){if(t)if(t instanceof i.Component){if(e instanceof i._BaseNode||e instanceof i.Component)return e}else if(t instanceof i._BaseNode)if(e instanceof i._BaseNode){if(!e.isChildOf(t))return e}else if(e instanceof i.Component&&!e.node.isChildOf(t))return e;n=new l}else if(l===Object)n={};else{if(l)return e;n=Object.create(null)}return PE(e,n,t),n}function NE(e,t){return(t<<3)+e}IE._clone=OE,i.instantiate=IE,function(e){e[e.Uint8=0]="Uint8",e[e.Uint16=1]="Uint16",e[e.Uint32=2]="Uint32",e[e.Int8=3]="Int8",e[e.Int16=4]="Int16",e[e.Int32=5]="Int32",e[e.Float32=6]="Float32",e[e.Float64=7]="Float64"}(xE||(xE={})),function(e){e[e.Scalar=0]="Scalar",e[e.Vec2=1]="Vec2",e[e.Vec3=2]="Vec3",e[e.Vec4=3]="Vec4",e[e.Quat=4]="Quat",e[e.Mat4=5]="Mat4"}(CE||(CE={}));var DE=e("CompactValueTypeArray",ih("cc.CompactValueTypeArray")((TE=EE=function(){function e(){Q(this,"_byteOffset",gE,this),Q(this,"_unitCount",vE,this),Q(this,"_unitElement",yE,this),Q(this,"_length",SE,this)}return e.lengthFor=function(e,t,n){return BE(t).requiredUnits*e.length*LE(n).BYTES_PER_ELEMENT},e.compress=function(t,n,i,r,a,s){for(var o=BE(n),c=LE(i),l=o.requiredUnits*t.length,u=new c(r,a,l),h=0;h<t.length;++h)o.compress(u,h,t[h]);var _=new e;return _._unitElement=NE(i,n),_._byteOffset=s,_._unitCount=l,_._length=t.length,_},e.prototype.decompress=function(e){for(var t,n={storageUnit:7&(t=this._unitElement),elementType:t>>3},i=n.storageUnit,r=BE(n.elementType),a=new(LE(i))(e,this._byteOffset,this._unitCount),s=new Array(this._length),o=0;o<this._length;++o)s[o]=r.decompress(a,o);return s},e}(),EE.StorageUnit=xE,EE.ElementType=CE,gE=J((mE=TE).prototype,"_byteOffset",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),vE=J(mE.prototype,"_unitCount",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),yE=J(mE.prototype,"_unitElement",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return NE(xE.Uint8,CE.Scalar)}}),SE=J(mE.prototype,"_length",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),pE=mE))||pE);function BE(e){return UT[e]}function LE(e){switch(e){case xE.Uint8:return Uint8Array;case xE.Uint16:return Uint16Array;case xE.Uint32:return Uint32Array;case xE.Int8:return Int8Array;case xE.Int16:return Int16Array;case xE.Int32:return Int32Array;case xE.Float32:return Float32Array;case xE.Float64:return Float64Array}}var FE,zE,UE,GE,kE,HE,VE,WE,jE,qE,XE,YE,KE,ZE,QE,JE,$E,eT,tT,nT,iT,rT,aT,sT,oT,cT,lT,uT,hT,_T,fT,dT,pT,mT,gT,vT,yT,ST,ET,TT,AT,xT,CT,RT,bT,wT,IT,OT,PT,MT,NT,DT,BT,LT,FT,zT,UT=((AE={})[CE.Scalar]={requiredUnits:1,compress:function(e,t,n){e[t]=n},decompress:function(e,t){return e[t]}},AE[CE.Vec2]={requiredUnits:2,compress:function(e,t,n){e[2*t]=n.x,e[2*t+1]=n.y},decompress:function(e,t){return new bn(e[2*t],e[2*t+1])}},AE[CE.Vec3]={requiredUnits:3,compress:function(e,t,n){e[3*t]=n.x,e[3*t+1]=n.y,e[3*t+2]=n.z},decompress:function(e,t){return new bn(e[3*t],e[3*t+1],e[3*t+2])}},AE[CE.Vec4]={requiredUnits:4,compress:function(e,t,n){e[4*t]=n.x,e[4*t+1]=n.y,e[4*t+2]=n.z,e[4*t+3]=n.w},decompress:function(e,t){return new Zn(e[4*t],e[4*t+1],e[4*t+2],e[4*t+3])}},AE[CE.Quat]={requiredUnits:4,compress:function(e,t,n){e[4*t]=n.x,e[4*t+1]=n.y,e[4*t+2]=n.z,e[4*t+3]=n.w},decompress:function(e,t){return new Dn(e[4*t],e[4*t+1],e[4*t+2],e[4*t+3])}},AE[CE.Mat4]={requiredUnits:16,compress:function(e,t,n){Hn.toArray(e,n,16*t)},decompress:function(e,t){return Hn.fromArray(new Hn,e,16*t)}},AE);i._decorator=dE;var GT=ih("cc.TargetInfo")((UE=J((zE=function(){Q(this,"localID",UE,this)}).prototype,"localID",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),FE=zE))||FE,kT=(GE=ih("cc.TargetOverrideInfo"),kE=Dh(__),HE=Dh(GT),VE=Dh(i.Node),WE=Dh(GT),GE((XE=J((qE=function(){Q(this,"source",XE,this),Q(this,"sourceInfo",YE,this),Q(this,"propertyPath",KE,this),Q(this,"target",ZE,this),Q(this,"targetInfo",QE,this)}).prototype,"source",[ch,kE],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),YE=J(qE.prototype,"sourceInfo",[ch,HE],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),KE=J(qE.prototype,"propertyPath",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),ZE=J(qE.prototype,"target",[ch,VE],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),QE=J(qE.prototype,"targetInfo",[ch,WE],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),jE=qE))||jE),HT=(JE=ih("cc.PrefabInfo"),$E=Dh([kT]),JE((nT=J((tT=function(){Q(this,"root",nT,this),Q(this,"asset",iT,this),Q(this,"fileId",rT,this),Q(this,"instance",aT,this),Q(this,"targetOverrides",sT,this)}).prototype,"root",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),iT=J(tT.prototype,"asset",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),rT=J(tT.prototype,"fileId",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),aT=J(tT.prototype,"instance",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),sT=J(tT.prototype,"targetOverrides",[ch,$E],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),eT=tT))||eT);i._PrefabInfo=HT;var VT=ih("cc.CompPrefabInfo")((lT=J((cT=function(){Q(this,"fileId",lT,this)}).prototype,"fileId",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),oT=cT))||oT,WT=(uT=ih("CCPropertyOverrideInfo"),hT=Dh(GT),uT((gT=function(){function e(){Q(this,"targetInfo",dT,this),Q(this,"propertyPath",pT,this),Q(this,"value",mT,this)}return e.prototype.isTarget=function(){},e}(),dT=J((fT=gT).prototype,"targetInfo",[ch,hT],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),pT=J(fT.prototype,"propertyPath",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),mT=J(fT.prototype,"value",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),_T=fT))||_T),jT=(vT=ih("cc.MountedChildrenInfo"),yT=Dh(GT),ST=Dh([i.Node]),vT((CT=function(){function e(){Q(this,"targetInfo",AT,this),Q(this,"nodes",xT,this)}return e.prototype.isTarget=function(){},e}(),AT=J((TT=CT).prototype,"targetInfo",[ch,yT],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),xT=J(TT.prototype,"nodes",[ch,ST],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),ET=TT))||ET),qT=(RT=ih("cc.PrefabInstance"),bT=Dh(i.Node),wT=Dh([jT]),IT=Dh([WT]),OT=Dh([GT]),RT((zT=function(){function e(){Q(this,"fileId",NT,this),Q(this,"prefabRootNode",DT,this),Q(this,"mountedChildren",BT,this),Q(this,"propertyOverrides",LT,this),Q(this,"removedComponents",FT,this),this.targetMap={}}var t=e.prototype;return t.findPropertyOverride=function(){},t.removePropertyOverride=function(){},e}(),NT=J((MT=zT).prototype,"fileId",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),DT=J(MT.prototype,"prefabRootNode",[ch,bT],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),BT=J(MT.prototype,"mountedChildren",[ch,wT],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),LT=J(MT.prototype,"propertyOverrides",[ch,IT],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),FT=J(MT.prototype,"removedComponents",[ch,OT],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),PT=MT))||PT);function XT(e){var t=e._prefab;if(t&&t.instance){if(!t.asset)return A(3701,e.name),void(t.instance=null);var n=e._objFlags,r=e._parent,a=e._id,s=e._prefab;i.game._isCloning=!0,t.asset._doInstantiate(e),i.game._isCloning=!1,e._objFlags=n,e._parent=r,e._id=a,e._prefab&&(e._prefab.instance=null==s?void 0:s.instance)}}function YT(e,t,n){var i,r=t,a=null===(i=e._prefab)||void 0===i?void 0:i.instance;!n&&a&&(t[a.fileId]={},r=t[a.fileId]);var s=e._prefab;s&&(r[s.fileId]=e);for(var o=e.components,c=0;c<o.length;c++){var l=o[c];l.__prefab&&(r[l.__prefab.fileId]=l)}for(var u=0;u<e.children.length;u++)YT(e.children[u],r,!1)}function KT(e,t){if(!e)return null;for(var n=t,i=0;i<e.length;i++){if(!n)return null;n=n[e[i]]}return n}function ZT(e,t,n){if(t)for(var i=0;i<t.length;i++){var r=t[i];if(r&&r.targetInfo){var a=KT(r.targetInfo.localID,n);if(!a)continue;if(r.nodes)for(var s=0;s<r.nodes.length;s++){var o=r.nodes[s];a._children.push(o),o._parent=a,o._onBatchCreated(!1)}}}}function QT(e,t,n){if(!(t.length<=0))for(var i=null,r=0;r<t.length;r++){var a=t[r];if(a&&a.targetInfo){if(!(i=KT(a.targetInfo.localID,n)))continue;var s=i,o=a.propertyPath.slice();if(o.length>0){var c=o.pop();if(!c)continue;for(var l=0;l<o.length&&(s=s[o[l]]);l++);if(!s)continue;if(Array.isArray(s))if("length"===c)s[c]=a.value;else{var u=Number.parseInt(c);Number.isInteger(u)&&u<s.length&&(s[c]=a.value)}else s[c]=a.value}}}}function JT(e){var t,n=null===(t=e._prefab)||void 0===t?void 0:t.targetOverrides;if(n)for(var i=0;i<n.length;i++){var r,a,s=n[i],o=s.source,c=s.sourceInfo;if(c){var l,u,h=null===(l=s.source)||void 0===l||null===(u=l._prefab)||void 0===u?void 0:u.instance;if(h&&h.targetMap&&(o=KT(c.localID,h.targetMap)),!o)continue}var _,f=s.targetInfo;if(f){var d=null===(r=s.target)||void 0===r||null===(a=r._prefab)||void 0===a?void 0:a.instance;if(d&&d.targetMap&&(_=KT(f.localID,d.targetMap))){var p=s.propertyPath.slice(),m=o;if(p.length>0){var g=p.pop();if(!g)return;for(var v=0;v<p.length;v++)m=m[p[v]];m[g]=_}}}}}var $T,eA,tA,nA,iA,rA,aA,sA,oA,cA,lA,uA,hA,_A,fA=Object.freeze({__proto__:null,TargetInfo:GT,TargetOverrideInfo:kT,PrefabInfo:HT,CompPrefabInfo:VT,PropertyOverrideInfo:WT,MountedChildrenInfo:jT,PrefabInstance:qT,createNodeWithPrefab:XT,generateTargetMap:YT,getTarget:KT,applyMountedChildren:ZT,applyPropertyOverrides:QT,applyTargetOverrides:JT}),dA=ct({AUTO:0,SINGLE_INSTANCE:1,MULTI_INSTANCE:2}),pA=e("Prefab",ih("cc.Prefab")((aA=rA=function(e){function t(){var t;return Q(t=e.call(this)||this,"data",tA,Y(t)),Q(t,"optimizationPolicy",nA,Y(t)),Q(t,"asyncLoadAssets",iA,Y(t)),t._createFunction=void 0,t._instantiatedTimes=void 0,t._createFunction=null,t._instantiatedTimes=0,t}X(t,e);var n=t.prototype;return n.createNode=function(e){var t=i.instantiate(this);t.name=this.name,e(null,t)},n.compileCreateFunction=function(){var e,t;this._createFunction=(t=(e=this.data)instanceof i._BaseNode&&e,new _E(e,t).result)},n._doInstantiate=function(e){return this.data._prefab||E(3700),this._createFunction||this.compileCreateFunction(),this._createFunction(e)},n._instantiate=function(){var e;return this.optimizationPolicy!==dA.SINGLE_INSTANCE&&(this.optimizationPolicy===dA.MULTI_INSTANCE||this._instantiatedTimes+1>=t.OptimizationPolicyThreshold)?(e=this._doInstantiate(),this.data._instantiate(e)):e=this.data._instantiate(),++this._instantiatedTimes,e},t}(I_),rA.OptimizationPolicy=dA,rA.OptimizationPolicyThreshold=3,tA=J((eA=aA).prototype,"data",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),nA=J(eA.prototype,"optimizationPolicy",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return dA.AUTO}}),iA=J(eA.prototype,"asyncLoadAssets",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),$T=eA))||$T);st.value(pA,"_utils",fA),i.Prefab=pA,Ne(i,"cc._Prefab","Prefab"),e("PrefabLink",(sA=ih("cc.PrefabLink"),oA=Dh(pA),cA=vh(),sA((_A=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return Q(t=e.call.apply(e,[this].concat(i))||this,"prefab",hA,Y(t)),t}return X(t,e),t}(Kf),hA=J((uA=_A).prototype,"prefab",[oA,ch,cA],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),lA=uA))||lA));var mA=new bn;function gA(e,t,n,i){i||(i=new bn),e.convertToUINode(t,n,i);var r=n.position;return i.add(r),i}function vA(e,t,n){return n||(n=new bn),e.worldToScreen(t,n),n.x/=i.view.getScaleX(),n.y/=i.view.getScaleY(),n}var yA=e("convertUtils",{WorldNode3DToLocalNodeUI:gA,WorldNode3DToWorldNodeUI:vA});i.pipelineUtils=yA,se(i.pipelineUtils,"cc.pipelineUtils",[{name:"WorldNode3DToLocalNodeUI",newName:"convertToUINode",targetName:"cc.Camera.prototype",customFunction:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var i=t[0],r=t[3]||mA;return i.convertToUINode(t[1],t[2],r),r.add(t[2].position),t[3]||r.clone()}}]);var SA=new qn,EA=e("EventMouse",function(e){function t(n,i,r){var a;return(a=e.call(this,o_.MOUSE,i)||this).movementX=0,a.movementY=0,a.eventType=void 0,a._button=t.BUTTON_MISSING,a._x=0,a._y=0,a._prevX=0,a._prevY=0,a._scrollX=0,a._scrollY=0,a.eventType=n,r&&(a._prevX=r.x,a._prevY=r.y),a}X(t,e);var n=t.prototype;return n.setScrollData=function(e,t){this._scrollX=e,this._scrollY=t},n.getScrollX=function(){return this._scrollX},n.getScrollY=function(){return this._scrollY},n.setLocation=function(e,t){this._x=e,this._y=t},n.getLocation=function(e){return e||(e=new qn),qn.set(e,this._x,this._y),e},n.getLocationInView=function(e){return e||(e=new qn),qn.set(e,this._x,i.view._designResolutionSize.height-this._y),e},n.getUILocation=function(e){return e||(e=new qn),qn.set(e,this._x,this._y),i.view._convertPointWithScale(e),e},n.getPreviousLocation=function(e){return e||(e=new qn),qn.set(e,this._prevX,this._prevY),e},n.getUIPreviousLocation=function(e){return e||(e=new qn),qn.set(e,this._prevX,this._prevY),i.view._convertPointWithScale(e),e},n.getDelta=function(e){return e||(e=new qn),qn.set(e,this._x-this._prevX,this._y-this._prevY),e},n.getDeltaX=function(){return this._x-this._prevX},n.getDeltaY=function(){return this._y-this._prevY},n.getUIDelta=function(e){return e||(e=new qn),qn.set(e,(this._x-this._prevX)/i.view.getScaleX(),(this._y-this._prevY)/i.view.getScaleY()),e},n.getUIDeltaX=function(){return(this._x-this._prevX)/i.view.getScaleX()},n.getUIDeltaY=function(){return(this._y-this._prevY)/i.view.getScaleY()},n.setButton=function(e){this._button=e},n.getButton=function(){return this._button},n.getLocationX=function(){return this._x},n.getLocationY=function(){return this._y},n.getUILocationX=function(){var e=i.view.getViewportRect();return(this._x-e.x)/i.view.getScaleX()},n.getUILocationY=function(){var e=i.view.getViewportRect();return(this._y-e.y)/i.view.getScaleY()},t}(o_));EA.NONE=0,EA.DOWN=1,EA.UP=2,EA.MOVE=3,EA.SCROLL=4,EA.BUTTON_MISSING=-1,EA.BUTTON_LEFT=0,EA.BUTTON_RIGHT=2,EA.BUTTON_MIDDLE=1,EA.BUTTON_4=3,EA.BUTTON_5=4,EA.BUTTON_6=5,EA.BUTTON_7=6,EA.BUTTON_8=7;var TA=e("EventTouch",function(e){function t(t,n,i,r){var a;return(a=e.call(this,o_.TOUCH,n)||this).touch=null,a.simulate=!1,a._eventCode=void 0,a._touches=void 0,a._allTouches=void 0,a._eventCode=i||0,a._touches=t||[],a._allTouches=r||[],a}X(t,e);var n=t.prototype;return n.getEventCode=function(){return this._eventCode},n.getTouches=function(){return this._touches},n.getAllTouches=function(){return this._allTouches},n.setLocation=function(e,t){this.touch&&this.touch.setTouchInfo(this.touch.getID(),e,t)},n.getLocation=function(e){return this.touch?this.touch.getLocation(e):new qn},n.getUILocation=function(e){return this.touch?this.touch.getUILocation(e):new qn},n.getLocationInView=function(e){return this.touch?this.touch.getLocationInView(e):new qn},n.getPreviousLocation=function(e){return this.touch?this.touch.getPreviousLocation(e):new qn},n.getStartLocation=function(e){return this.touch?this.touch.getStartLocation(e):new qn},n.getUIStartLocation=function(e){return this.touch?this.touch.getUIStartLocation(e):new qn},n.getID=function(){return this.touch?this.touch.getID():null},n.getDelta=function(e){return this.touch?this.touch.getDelta(e):new qn},n.getUIDelta=function(e){return this.touch?this.touch.getUIDelta(e):new qn},n.getDeltaX=function(){return this.touch?this.touch.getDelta(SA).x:0},n.getDeltaY=function(){return this.touch?this.touch.getDelta(SA).y:0},n.getLocationX=function(){return this.touch?this.touch.getLocationX():0},n.getLocationY=function(){return this.touch?this.touch.getLocationY():0},t}(o_));TA.MAX_TOUCHES=5,TA.BEGAN=0,TA.MOVED=1,TA.ENDED=2,TA.CANCELLED=3;var AA=e("EventAcceleration",function(e){function t(t,n){var i;return(i=e.call(this,o_.ACCELERATION,n)||this).acc=void 0,i.acc=t,i}return X(t,e),t}(o_)),xA=e("EventKeyboard",function(e){function t(t,n,i){var r;return(r=e.call(this,o_.KEYBOARD,i)||this).keyCode=void 0,r.rawEvent=void 0,r.isPressed=void 0,"number"==typeof t?r.keyCode=t:(r.keyCode=t.keyCode,r.rawEvent=t),r.isPressed=n,r}return X(t,e),t}(o_));o_.EventMouse=EA,o_.EventTouch=TA,o_.EventAcceleration=AA,o_.EventKeyboard=xA;var CA=function(){function e(e,t,n){this._cameraPriority=0,this.owner=null,this.mask=null,this._previousIn=!1,this._target=null,this._onEvent=void 0,this._type=void 0,this._listenerID=void 0,this._registered=!1,this._fixedPriority=0,this._node=null,this._paused=!0,this._isEnabled=!0,this._onEvent=n,this._type=e||0,this._listenerID=t||""}e.create=function(e){R(e&&e.event,1900);var t=e.event;delete e.event;var n=null;if(t===i.EventListener.TOUCH_ONE_BY_ONE?n=new wA:t===i.EventListener.TOUCH_ALL_AT_ONCE?n=new IA:t===i.EventListener.MOUSE?n=new bA:t===i.EventListener.KEYBOARD?n=new PA:t===i.EventListener.ACCELERATION&&(n=new OA(e.callback),delete e.callback),n)for(var r=0,a=Object.keys(e);r<a.length;r++){var s=a[r];n[s]=e[s]}return n},j(e,[{key:"onEvent",get:function(){return this._onEvent}}]);var t=e.prototype;return t._setPaused=function(e){this._paused=e},t._isPaused=function(){return this._paused},t._setRegistered=function(e){this._registered=e},t._isRegistered=function(){return this._registered},t._getType=function(){return this._type},t._getListenerID=function(){return this._listenerID},t._setFixedPriority=function(e){this._fixedPriority=e},t._getFixedPriority=function(){return this._fixedPriority},t._setSceneGraphPriority=function(e){this._target=e,this._node=e},t._getSceneGraphPriority=function(){return this._node},t.checkAvailable=function(){return null!==this._onEvent},t.clone=function(){return null},t.setEnabled=function(e){this._isEnabled=e},t.isEnabled=function(){return this._isEnabled},e}();CA.UNKNOWN=0,CA.TOUCH_ONE_BY_ONE=1,CA.TOUCH_ALL_AT_ONCE=2,CA.KEYBOARD=3,CA.MOUSE=4,CA.ACCELERATION=6,CA.CUSTOM=8,CA.ListenerID={MOUSE:"__cc_mouse",TOUCH_ONE_BY_ONE:"__cc_touch_one_by_one",TOUCH_ALL_AT_ONCE:"__cc_touch_all_at_once",KEYBOARD:"__cc_keyboard",ACCELERATION:"__cc_acceleration"};var RA=CA.ListenerID,bA=function(e){function t(){var t;return(t=e.call(this,CA.MOUSE,RA.MOUSE,null)||this).onMouseDown=null,t.onMouseUp=null,t.onMouseMove=null,t.onMouseScroll=null,t._onEvent=function(e){return t._callback(e)},t}X(t,e);var n=t.prototype;return n._callback=function(e){var t=i.Event.EventMouse;switch(e.eventType){case t.DOWN:this.onMouseDown&&this.onMouseDown(e);break;case t.UP:this.onMouseUp&&this.onMouseUp(e);break;case t.MOVE:this.onMouseMove&&this.onMouseMove(e);break;case t.SCROLL:this.onMouseScroll&&this.onMouseScroll(e)}},n.clone=function(){var e=new t;return e.onMouseDown=this.onMouseDown,e.onMouseUp=this.onMouseUp,e.onMouseMove=this.onMouseMove,e.onMouseScroll=this.onMouseScroll,e},n.checkAvailable=function(){return!0},t}(CA),wA=function(e){function t(){var t;return(t=e.call(this,CA.TOUCH_ONE_BY_ONE,RA.TOUCH_ONE_BY_ONE,null)||this).swallowTouches=!1,t.onTouchBegan=null,t.onTouchMoved=null,t.onTouchEnded=null,t.onTouchCancelled=null,t._claimedTouches=[],t}X(t,e);var n=t.prototype;return n.setSwallowTouches=function(e){this.swallowTouches=e},n.isSwallowTouches=function(){return this.swallowTouches},n.clone=function(){var e=new t;return e.onTouchBegan=this.onTouchBegan,e.onTouchMoved=this.onTouchMoved,e.onTouchEnded=this.onTouchEnded,e.onTouchCancelled=this.onTouchCancelled,e.swallowTouches=this.swallowTouches,e},n.checkAvailable=function(){return!!this.onTouchBegan||(y(1801),!1)},t}(CA),IA=function(e){function t(){var t;return(t=e.call(this,CA.TOUCH_ALL_AT_ONCE,RA.TOUCH_ALL_AT_ONCE,null)||this).onTouchesBegan=null,t.onTouchesMoved=null,t.onTouchesEnded=null,t.onTouchesCancelled=null,t}X(t,e);var n=t.prototype;return n.clone=function(){var e=new t;return e.onTouchesBegan=this.onTouchesBegan,e.onTouchesMoved=this.onTouchesMoved,e.onTouchesEnded=this.onTouchesEnded,e.onTouchesCancelled=this.onTouchesCancelled,e},n.checkAvailable=function(){return null!==this.onTouchesBegan||null!==this.onTouchesMoved||null!==this.onTouchesEnded||null!==this.onTouchesCancelled||(y(1802),!1)},t}(CA),OA=function(e){function t(t){var n;return(n=e.call(this,CA.ACCELERATION,RA.ACCELERATION,null)||this)._onAccelerationEvent=null,n._onEvent=function(e){return n._callback(e)},n._onAccelerationEvent=t,n}X(t,e);var n=t.prototype;return n._callback=function(e){this._onAccelerationEvent&&this._onAccelerationEvent(e.acc,e)},n.checkAvailable=function(){return R(this._onAccelerationEvent,1803),!0},n.clone=function(){return new t(this._onAccelerationEvent)},t}(CA),PA=function(e){function t(){var t;return(t=e.call(this,CA.KEYBOARD,RA.KEYBOARD,null)||this).onKeyPressed=null,t.onKeyReleased=null,t._onEvent=function(e){return t._callback(e)},t}X(t,e);var n=t.prototype;return n._callback=function(e){e.isPressed?this.onKeyPressed&&this.onKeyPressed(e.keyCode,e):this.onKeyReleased&&this.onKeyReleased(e.keyCode,e)},n.clone=function(){var e=new t;return e.onKeyPressed=this.onKeyPressed,e.onKeyReleased=this.onKeyReleased,e},n.checkAvailable=function(){return null!==this.onKeyPressed||null!==this.onKeyReleased||(y(1800),!1)},t}(CA);i.EventListener=CA;var MA=CA.ListenerID,NA=function(){function e(){this.gt0Index=0,this._fixedListeners=[],this._sceneGraphListeners=[]}var t=e.prototype;return t.size=function(){return this._fixedListeners.length+this._sceneGraphListeners.length},t.empty=function(){return 0===this._fixedListeners.length&&0===this._sceneGraphListeners.length},t.push=function(e){0===e._getFixedPriority()?this._sceneGraphListeners.push(e):this._fixedListeners.push(e)},t.clearSceneGraphListeners=function(){this._sceneGraphListeners.length=0},t.clearFixedListeners=function(){this._fixedListeners.length=0},t.clear=function(){this._sceneGraphListeners.length=0,this._fixedListeners.length=0},t.getFixedPriorityListeners=function(){return this._fixedListeners},t.getSceneGraphPriorityListeners=function(){return this._sceneGraphListeners},e}(),DA=function(){function e(){this._listenersMap={},this._priorityDirtyFlagMap={},this._nodeListenersMap={},this._toAddedListeners=[],this._toRemovedListeners=[],this._dirtyListeners={},this._inDispatch=0,this._isEnabled=!1,this._internalCustomListenerIDs=[],this._currentTouch=null,this._currentTouchListener=null}var t=e.prototype;return t.pauseTarget=function(e,t){if(void 0===t&&(t=!1),e instanceof i._BaseNode){var n=this._nodeListenersMap[e.uuid];if(n)for(var r=0;r<n.length;++r)n[r]._setPaused(!0);if(!0===t){var a=e.children;if(a)for(var s=0;s<a.length;++s){var o=a[s];this.pauseTarget(o,!0)}}}else E(3506)},t.resumeTarget=function(e,t){if(void 0===t&&(t=!1),e instanceof i._BaseNode){var n=this._nodeListenersMap[e.uuid];if(n)for(var r=0;r<n.length;++r)n[r]._setPaused(!1);if(this._setDirtyForNode(e),!0===t&&e.children.length>0){var a=e.children;if(a)for(var s=0;s<a.length;++s){var o=a[s];this.resumeTarget(o,!0)}}}else E(3506)},t.frameUpdateListeners=function(){var e=this._listenersMap,t=this._priorityDirtyFlagMap;for(var n in e)e[n].empty()&&(delete t[n],delete e[n]);var i=this._toAddedListeners;if(0!==i.length){for(var r=0,a=i.length;r<a;r++)this._forceAddEventListener(i[r]);i.length=0}0!==this._toRemovedListeners.length&&this._cleanToRemovedListeners()},t.hasEventListener=function(e){return!!this._getListeners(e)},t.addListener=function(e,t){if(R(e&&t,3503),!(i.js.isNumber(t)||t instanceof i._BaseNode))return E(3506),null;if(e instanceof i.EventListener){if(e._isRegistered())return y(3505),null}else R(!i.js.isNumber(t),3504),e=i.EventListener.create(e);if(!e.checkAvailable())return null;if(i.js.isNumber(t)){if(0===t)return y(3500),null;e._setSceneGraphPriority(null),e._setFixedPriority(t),e._setRegistered(!0),e._setPaused(!1),this._addListener(e)}else{if(!(n=t)||!n.getComponent("cc.UITransform"))return y(3512),null;e._setSceneGraphPriority(t),e._setFixedPriority(0),e._setRegistered(!0),this._addListener(e)}var n;return e},t.addCustomListener=function(e,t){var n=CA.create({event:i.EventListener.CUSTOM,eventName:e,callback:t});return this.addListener(n,1),n},t.removeListener=function(e){if(null!=e){var t=!1,n=this._listenersMap;for(var r in n){var a=n[r],s=a.getFixedPriorityListeners(),o=a.getSceneGraphPriorityListeners();if((t=this._removeListenerInVector(o,e))?this._setDirty(e._getListenerID(),2):(t=this._removeListenerInVector(s,e))&&this._setDirty(e._getListenerID(),1),a.empty()&&(delete this._priorityDirtyFlagMap[e._getListenerID()],delete n[r]),t)break}if(!t)for(var c=this._toAddedListeners,l=c.length-1;l>=0;l--){var u=c[l];if(u===e){i.js.array.removeAt(c,l),u._setRegistered(!1);break}}}},t.removeListeners=function(e,t){if(void 0===t&&(t=!1),i.js.isNumber(e)||e instanceof i._BaseNode)if(void 0!==e._id){var n=this._nodeListenersMap[e._id];if(n){for(var r=i.js.array.copy(n),a=0;a<r.length;++a){var s=r[a];this.removeListener(s)}delete this._nodeListenersMap[e._id]}for(var o=this._toAddedListeners,c=0;c<o.length;){var l=o[c];l._getSceneGraphPriority()===e?(l._setSceneGraphPriority(null),l._setRegistered(!1),o.splice(c,1)):++c}if(!0===t)for(var u=e.getChildren(),h=0;h<u.length;++h){var _=u[h];this.removeListeners(_,!0)}}else e===i.EventListener.TOUCH_ONE_BY_ONE?this._removeListenersForListenerID(MA.TOUCH_ONE_BY_ONE):e===i.EventListener.TOUCH_ALL_AT_ONCE?this._removeListenersForListenerID(MA.TOUCH_ALL_AT_ONCE):e===i.EventListener.MOUSE?this._removeListenersForListenerID(MA.MOUSE):e===i.EventListener.ACCELERATION?this._removeListenersForListenerID(MA.ACCELERATION):e===i.EventListener.KEYBOARD?this._removeListenersForListenerID(MA.KEYBOARD):y(3501);else E(3506)},t.removeCustomListeners=function(e){this._removeListenersForListenerID(e)},t.removeAllListeners=function(){var e=this._listenersMap,t=this._internalCustomListenerIDs;for(var n in e)-1===t.indexOf(n)&&this._removeListenersForListenerID(n)},t.setPriority=function(e,t){if(null!=e){var n=this._listenersMap;for(var i in n){var r=n[i].getFixedPriorityListeners();if(r&&-1!==r.indexOf(e))return null!=e._getSceneGraphPriority()&&y(3502),void(e._getFixedPriority()!==t&&(e._setFixedPriority(t),this._setDirty(e._getListenerID(),1)))}}},t.setEnabled=function(e){this._isEnabled=e},t.isEnabled=function(){return this._isEnabled},t.dispatchEvent=function(e){if(this._isEnabled)if(this._updateDirtyFlagForSceneGraph(),this._inDispatch++,e&&e.getType){if(e.getType().startsWith(i.Event.TOUCH))return this._dispatchTouchEvent(e),void this._inDispatch--;var t=function(e){var t=o_,n=e.type;return n===t.ACCELERATION?MA.ACCELERATION:n===t.KEYBOARD?MA.KEYBOARD:n.startsWith(t.MOUSE)?MA.MOUSE:(n.startsWith(t.TOUCH)&&y(2e3),"")}(e);this._sortEventListeners(t);var n=this._listenersMap[t];null!=n&&(this._dispatchEventToListeners(n,this._onListenerCallback,e),this._onUpdateListeners(n)),this._inDispatch--}else A(3511)},t._onListenerCallback=function(e,t){t.currentTarget=e._target;var n=e.onEvent;return n&&n(t),t.isStopped()},t.dispatchCustomEvent=function(e,t){var n=new i.Event.EventCustom(e);n.setUserData(t),this.dispatchEvent(n)},t._setDirtyForNode=function(e){var t=this._nodeListenersMap[e._id];if(void 0!==t)for(var n=0,i=t.length;n<i;n++){var r=t[n]._getListenerID();this._dirtyListeners[r]||(this._dirtyListeners[r]=!0)}if(e.children.length>0)for(var a=e.children,s=0,o=a?a.length:0;s<o;s++)this._setDirtyForNode(a[s])},t._addListener=function(e){0===this._inDispatch?this._forceAddEventListener(e):this._toAddedListeners.push(e)},t._forceAddEventListener=function(e){var t=e._getListenerID(),n=this._listenersMap[t];if(n||(n=new NA,this._listenersMap[t]=n),n.push(e),0===e._getFixedPriority()){this._setDirty(t,2);var i=e._getSceneGraphPriority();null===i&&y(3507),this._associateNodeAndEventListener(i,e),i.activeInHierarchy&&this.resumeTarget(i)}else this._setDirty(t,1)},t._getListeners=function(e){return this._listenersMap[e]},t._updateDirtyFlagForSceneGraph=function(){var e=this._dirtyListeners;for(var t in e)this._setDirty(t,2),e[t]=!1},t._removeAllListenersInVector=function(e){if(e)for(var t,n=e.length-1;n>=0;n--)(t=e[n])._setRegistered(!1),null!=t._getSceneGraphPriority()&&(this._dissociateNodeAndEventListener(t._getSceneGraphPriority(),t),t._setSceneGraphPriority(null)),0===this._inDispatch&&i.js.array.removeAt(e,n)},t._removeListenersForListenerID=function(e){var t=this._listenersMap[e];if(t){var n=t.getFixedPriorityListeners(),r=t.getSceneGraphPriorityListeners();this._removeAllListenersInVector(r),this._removeAllListenersInVector(n),delete this._priorityDirtyFlagMap[e],this._inDispatch||(t.clear(),delete this._listenersMap[e])}for(var a=this._toAddedListeners,s=a.length-1;s>=0;s--){var o=a[s];o&&o._getListenerID()===e&&i.js.array.removeAt(a,s)}},t._sortEventListeners=function(e){var t=0,n=this._priorityDirtyFlagMap;n[e]&&(t=n[e]),0!==t&&(n[e]=0,1&t&&this._sortListenersOfFixedPriority(e),2&t&&i.director.getScene()&&this._sortListenersOfSceneGraphPriority(e))},t._sortListenersOfSceneGraphPriority=function(e){var t=this._getListeners(e);if(t){var n=t.getSceneGraphPriorityListeners();if(n&&0!==n.length){var i=t.getSceneGraphPriorityListeners();i.forEach((function(e){var t=e._getSceneGraphPriority()._uiProps.uiTransformComp;e._cameraPriority=t.cameraPriority})),i.sort(this._sortEventListenersOfSceneGraphPriorityDes)}}},t._sortEventListenersOfSceneGraphPriorityDes=function(e,t){var n=e._getSceneGraphPriority(),i=t._getSceneGraphPriority();if(!(t&&i&&i._activeInHierarchy&&i._uiProps.uiTransformComp))return-1;if(!(e&&n&&n._activeInHierarchy&&n._uiProps.uiTransformComp))return 1;var r=n,a=i,s=!1;if(e._cameraPriority!==t._cameraPriority)return t._cameraPriority-e._cameraPriority;for(;r.parent._id!==a.parent._id;)r=null===r.parent.parent?(s=!0)&&i:r.parent,a=null===a.parent.parent?(s=!0)&&n:a.parent;if(r._id===a._id){if(r._id===i._id)return-1;if(r._id===n._id)return 1}var o=r.getSiblingIndex(),c=a.getSiblingIndex();return s?o-c:c-o},t._sortListenersOfFixedPriority=function(e){var t=this._listenersMap[e];if(t){var n=t.getFixedPriorityListeners();if(n&&0!==n.length){n.sort(this._sortListenersOfFixedPriorityAsc);for(var i=0,r=n.length;i<r&&!(n[i]._getFixedPriority()>=0);)++i;t.gt0Index=i}}},t._sortListenersOfFixedPriorityAsc=function(e,t){return e._getFixedPriority()-t._getFixedPriority()},t._onUpdateListeners=function(e){var t=e.getFixedPriorityListeners(),n=e.getSceneGraphPriorityListeners(),r=this._toRemovedListeners;if(n)for(var a=n.length-1;a>=0;a--){var s=n[a];if(!s._isRegistered()){i.js.array.removeAt(n,a);var o=r.indexOf(s);-1!==o&&r.splice(o,1)}}if(t)for(var c=t.length-1;c>=0;c--){var l=t[c];if(!l._isRegistered()){i.js.array.removeAt(t,c);var u=r.indexOf(l);-1!==u&&r.splice(u,1)}}n&&0===n.length&&e.clearSceneGraphListeners(),t&&0===t.length&&e.clearFixedListeners()},t._updateTouchListeners=function(){var e=this._inDispatch;if(R(e>0,3508),!(e>1)){var t;(t=this._listenersMap[MA.TOUCH_ONE_BY_ONE])&&this._onUpdateListeners(t),(t=this._listenersMap[MA.TOUCH_ALL_AT_ONCE])&&this._onUpdateListeners(t),R(1===e,3509);var n=this._toAddedListeners;if(0!==n.length){for(var i=0,r=n.length;i<r;i++)this._forceAddEventListener(n[i]);this._toAddedListeners.length=0}0!==this._toRemovedListeners.length&&this._cleanToRemovedListeners()}},t._cleanToRemovedListeners=function(){for(var e=this._toRemovedListeners,t=0;t<e.length;++t){var n=e[t],i=this._listenersMap[n._getListenerID()];if(i){var r=i.getFixedPriorityListeners(),a=i.getSceneGraphPriorityListeners();if(a){var s=a.indexOf(n);-1!==s&&a.splice(s,1)}if(r){var o=r.indexOf(n);-1!==o&&r.splice(o,1)}}}e.length=0},t._onTouchEventCallback=function(e,t){if(!e._isRegistered())return!1;var n=t.event,i=n.touch;n.currentTarget=e._getSceneGraphPriority();var r=!1,a=-1,s=n.getEventCode();if(s===TA.BEGAN){if(!ft.ENABLE_MULTI_TOUCH&&BA._currentTouch){var o=BA._currentTouchListener._node;if(!o||o.activeInHierarchy)return!1}e.onTouchBegan&&(r=e.onTouchBegan(i,n))&&e._isRegistered()&&(e._claimedTouches.push(i),!ft.ENABLE_MULTI_TOUCH&&BA._currentTouch||(BA._currentTouch=i),BA._currentTouchListener=e)}else if(e._claimedTouches.length>0&&-1!==(a=e._claimedTouches.indexOf(i))){if(r=!0,!ft.ENABLE_MULTI_TOUCH&&BA._currentTouch&&BA._currentTouch!==i)return!1;s===TA.MOVED&&e.onTouchMoved?e.onTouchMoved(i,n):s===TA.ENDED?(e.onTouchEnded&&e.onTouchEnded(i,n),e._isRegistered()&&e._claimedTouches.splice(a,1),(ft.ENABLE_MULTI_TOUCH||BA._currentTouch===i)&&(BA._currentTouch=null),BA._currentTouchListener=null):s===TA.CANCELLED&&(e.onTouchCancelled&&e.onTouchCancelled(i,n),e._isRegistered()&&e._claimedTouches.splice(a,1),(ft.ENABLE_MULTI_TOUCH||BA._currentTouch===i)&&(BA._currentTouch=null),BA._currentTouchListener=null)}return n.isStopped()?(BA._updateTouchListeners(n),!0):!!(r&&e._isRegistered()&&e.swallowTouches)&&(t.needsMutableSet&&t.touches.splice(i,1),!0)},t._dispatchTouchEvent=function(e){this._sortEventListeners(MA.TOUCH_ONE_BY_ONE),this._sortEventListeners(MA.TOUCH_ALL_AT_ONCE);var t=this._getListeners(MA.TOUCH_ONE_BY_ONE),n=this._getListeners(MA.TOUCH_ALL_AT_ONCE);if(null!==t||null!==n){var r=e.getTouches(),a=i.js.array.copy(r),s={event:e,needsMutableSet:t&&n,touches:a,selTouch:null};if(t)for(var o=0;o<r.length;++o){var c=r[o];e.touch=c,e.propagationStopped=e.propagationImmediateStopped=!1,this._dispatchEventToListeners(t,this._onTouchEventCallback,s)}n&&a.length>0&&(this._dispatchEventToListeners(n,this._onTouchesEventCallback,{event:e,touches:a}),e.isStopped())||this._updateTouchListeners(e)}},t._onTouchesEventCallback=function(e,t){if(!e._isRegistered())return!1;var n=t.event,i=t.touches,r=n.getEventCode();return n.currentTarget=e._getSceneGraphPriority(),r===TA.BEGAN&&e.onTouchesBegan?e.onTouchesBegan(i,n):r===TA.MOVED&&e.onTouchesMoved?e.onTouchesMoved(i,n):r===TA.ENDED&&e.onTouchesEnded?e.onTouchesEnded(i,n):r===TA.CANCELLED&&e.onTouchesCancelled&&e.onTouchesCancelled(i,n),!!n.isStopped()&&(BA._updateTouchListeners(n),!0)},t._associateNodeAndEventListener=function(e,t){var n=this._nodeListenersMap[e.uuid];n||(n=[],this._nodeListenersMap[e.uuid]=n),n.push(t)},t._dissociateNodeAndEventListener=function(e,t){var n=this._nodeListenersMap[e.uuid];n&&(i.js.array.remove(n,t),0===n.length&&delete this._nodeListenersMap[e.uuid])},t._dispatchEventToListeners=function(e,t,n){var i=!1,r=e.getFixedPriorityListeners(),a=e.getSceneGraphPriorityListeners(),s=0;if(r&&0!==r.length)for(;s<e.gt0Index;++s){var o=r[s];if(o.isEnabled()&&!o._isPaused()&&o._isRegistered()&&t(o,n)){i=!0;break}}if(a&&!i)for(var c=0;c<a.length;++c){var l=a[c];if(l.isEnabled()&&!l._isPaused()&&l._isRegistered()&&t(l,n)){i=!0;break}}if(r&&!i)for(;s<r.length;++s){var u=r[s];if(u.isEnabled()&&!u._isPaused()&&u._isRegistered()&&t(u,n)){i=!0;break}}},t._setDirty=function(e,t){var n=this._priorityDirtyFlagMap;null==n[e]?n[e]=t:n[e]|=t},t._sortNumberAsc=function(e,t){return e-t},t._removeListenerInCallback=function(e,t){if(null==e)return!1;for(var n=e.length-1;n>=0;n--){var r=e[n];if(r._onCustomEvent===t||r.onEvent===t)return r._setRegistered(!1),null!=r._getSceneGraphPriority()&&(this._dissociateNodeAndEventListener(r._getSceneGraphPriority(),r),r._setSceneGraphPriority(null)),0===this._inDispatch?i.js.array.removeAt(e,n):this._toRemovedListeners.push(r),!0}return!1},t._removeListenerInVector=function(e,t){if(null==e)return!1;for(var n=e.length-1;n>=0;n--){var r=e[n];if(r===t)return r._setRegistered(!1),null!=r._getSceneGraphPriority()&&(this._dissociateNodeAndEventListener(r._getSceneGraphPriority(),r),r._setSceneGraphPriority(null)),0===this._inDispatch?i.js.array.removeAt(e,n):this._toRemovedListeners.push(r),!0}return!1},e}(),BA=e("eventManager",new DA);i.eventManager=BA;var LA=new qn,FA=e("Touch",function(){function e(e,t,n){void 0===n&&(n=0),this._point=new qn,this._prevPoint=new qn,this._lastModified=0,this._id=0,this._startPoint=new qn,this._startPointCaptured=!1,this.setTouchInfo(n,e,t)}j(e,[{key:"lastModified",get:function(){return this._lastModified}}]);var t=e.prototype;return t.getLocation=function(e){return e||(e=new qn),e.set(this._point.x,this._point.y),e},t.getLocationX=function(){return this._point.x},t.getLocationY=function(){return this._point.y},t.getUILocation=function(e){return e||(e=new qn),e.set(this._point.x,this._point.y),i.view._convertPointWithScale(e),e},t.getUILocationX=function(){var e=i.view.getViewportRect();return(this._point.x-e.x)/i.view.getScaleX()},t.getUILocationY=function(){var e=i.view.getViewportRect();return(this._point.y-e.y)/i.view.getScaleY()},t.getPreviousLocation=function(e){return e||(e=new qn),e.set(this._prevPoint.x,this._prevPoint.y),e},t.getUIPreviousLocation=function(e){return e||(e=new qn),e.set(this._prevPoint.x,this._prevPoint.y),i.view._convertPointWithScale(e),e},t.getStartLocation=function(e){return e||(e=new qn),e.set(this._startPoint.x,this._startPoint.y),e},t.getUIStartLocation=function(e){return e||(e=new qn),e.set(this._startPoint.x,this._startPoint.y),i.view._convertPointWithScale(e),e},t.getDelta=function(e){return e||(e=new qn),e.set(this._point),e.subtract(this._prevPoint),e},t.getUIDelta=function(e){return e||(e=new qn),LA.set(this._point),LA.subtract(this._prevPoint),e.set(i.view.getScaleX(),i.view.getScaleY()),qn.divide(e,LA,e),e},t.getLocationInView=function(e){return e||(e=new qn),e.set(this._point.x,i.view._designResolutionSize.height-this._point.y),e},t.getPreviousLocationInView=function(e){return e||(e=new qn),e.set(this._prevPoint.x,i.view._designResolutionSize.height-this._prevPoint.y),e},t.getStartLocationInView=function(e){return e||(e=new qn),e.set(this._startPoint.x,i.view._designResolutionSize.height-this._startPoint.y),e},t.getID=function(){return this._id},t.setTouchInfo=function(e,t,n){void 0===e&&(e=0),this._prevPoint=this._point,this._point=new qn(t||0,n||0),this._id=e,this._startPointCaptured||(this._startPoint=new qn(this._point),this._startPointCaptured=!0)},t.setPoint=function(e,t){"object"==typeof e?(this._point.x=e.x,this._point.y=e.y):(this._point.x=e||0,this._point.y=t||0),this._lastModified=i.director.getCurrentTime()},t.setPrevPoint=function(e,t){this._prevPoint="object"==typeof e?new qn(e.x,e.y):new qn(e||0,t||0),this._lastModified=i.director.getCurrentTime()},e}());i.Touch=FA;var zA,UA=ft.TOUCH_TIMEOUT,GA=new qn,kA=new qn,HA=e("Acceleration",(function(e,t,n,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),this.x=void 0,this.y=void 0,this.z=void 0,this.timestamp=void 0,this.x=e,this.y=t,this.z=n,this.timestamp=i}));i.internal.Acceleration=HA;var VA=new(function(){function e(){this._mousePressed=!1,this._isRegisterEvent=!1,this._preTouchPoint=new qn,this._prevMousePoint=new qn,this._preTouchPool=[],this._preTouchPoolPointer=0,this._touches=[],this._touchesIntegerDict={},this._indexBitsUsed=0,this._maxTouches=8,this._accelEnabled=!1,this._accelInterval=.2,this._accelMinus=1,this._accelCurTime=0,this._acceleration=null,this._accelDeviceEvent=null,this._glView=null,this._pointLocked=!1}var t=e.prototype;return t.handleTouchesBegin=function(e){for(var t=[],n=this._touchesIntegerDict,i=0;i<e.length;++i){var r=e[i],a=r.getID();if(null!==a&&void 0===n[a]){var s=this._getUnUsedIndex();if(-1===s){y(2300,s);continue}r.getLocation(GA);var o=new FA(GA.x,GA.y,a);this._touches[s]=o,r.getPreviousLocation(GA),o.setPrevPoint(GA),n[a]=s,t.push(o)}}if(t.length>0){var c=new TA(t,!1,TA.BEGAN,ft.ENABLE_MULTI_TOUCH?this._getUsefulTouches():t);BA.dispatchEvent(c)}},t.handleTouchesMove=function(e){for(var t=[],n=this._touches,i=0;i<e.length;++i){var r=e[i],a=r.getID();if(null!==a){var s=this._touchesIntegerDict[a];void 0!==s&&n[s]&&(r.getLocation(GA),n[s].setPoint(GA),r.getPreviousLocation(GA),n[s].setPrevPoint(GA),t.push(n[s]))}}if(t.length>0){var o=new TA(t,!1,TA.MOVED,ft.ENABLE_MULTI_TOUCH?this._getUsefulTouches():t);BA.dispatchEvent(o)}},t.handleTouchesEnd=function(e){var t=this.getSetOfTouchesEndOrCancel(e);if(t.length>0){var n=new TA(t,!1,TA.ENDED,ft.ENABLE_MULTI_TOUCH?this._getUsefulTouches():t);BA.dispatchEvent(n)}this._preTouchPool.length=0},t.handleTouchesCancel=function(e){var t=this.getSetOfTouchesEndOrCancel(e);if(t.length>0){var n=new TA(t,!1,TA.CANCELLED,ft.ENABLE_MULTI_TOUCH?this._getUsefulTouches():t);BA.dispatchEvent(n)}this._preTouchPool.length=0},t.getSetOfTouchesEndOrCancel=function(e){for(var t=[],n=this._touches,i=this._touchesIntegerDict,r=0;r<e.length;++r){var a=e[r],s=a.getID();if(null!==s){var o=i[s];void 0!==o&&n[o]&&(a.getLocation(GA),n[o].setPoint(GA),a.getPreviousLocation(GA),n[o].setPrevPoint(GA),t.push(n[o]),this._removeUsedIndexBit(o),delete i[s])}}return t},t.getHTMLElementPosition=function(e){var t=document.documentElement,n=mg.os===mg.OS_IOS&&mg.isBrowser?window.screenLeft:window.pageXOffset;n-=t.clientLeft;var i=mg.os===mg.OS_IOS&&mg.isBrowser?window.screenTop:window.pageYOffset;if(i-=t.clientTop,e.getBoundingClientRect){var r=e.getBoundingClientRect();return{left:r.left+n,top:r.top+i,width:r.width,height:r.height}}return e instanceof HTMLCanvasElement?{left:n,top:i,width:e.width,height:e.height}:{left:n,top:i,width:parseInt(e.style.width||"0",void 0),height:parseInt(e.style.height||"0",void 0)}},t.getPreTouch=function(e){for(var t=null,n=this._preTouchPool,i=e.getID(),r=n.length-1;r>=0;r--)if(n[r].getID()===i){t=n[r];break}return t||(t=e),t},t.setPreTouch=function(e){for(var t=!1,n=this._preTouchPool,i=e.getID(),r=n.length-1;r>=0;r--)if(n[r].getID()===i){n[r]=e,t=!0;break}t||(n.length<=50?n.push(e):(n[this._preTouchPoolPointer]=e,this._preTouchPoolPointer=(this._preTouchPoolPointer+1)%50))},t.getTouchByXY=function(e,t,n,i){var r=this._preTouchPoint,a=this._glView.convertToLocationInView(t,n,i);this._pointLocked&&(a.x=r.x+e.movementX,a.y=r.y-e.movementY);var s=new FA(a.x,a.y,0);return s.setPrevPoint(r.x,r.y),r.x=a.x,r.y=a.y,s},t.getMouseEvent=function(e,t,n){var i=this._prevMousePoint,r=new EA(n,!1,i);return i.x=e.x,i.y=e.y,this._glView._convertMouseToLocation(i,t),r.setLocation(i.x,i.y),r},t.getPointByEvent=function(e,t){return null!=e.pageX?{x:e.pageX,y:e.pageY}:(t.left-=document.body.scrollLeft,t.top-=document.body.scrollTop,{x:e.clientX,y:e.clientY})},t.getTouchesByEvent=function(e,t){for(var n=[],i=this._glView,r=this._preTouchPoint,a=e.changedTouches.length,s=0;s<a;s++){var o=e.changedTouches[s];if(o){var c;c=mg.BROWSER_TYPE_FIREFOX===mg.browserType?i.convertToLocationInView(o.pageX,o.pageY,t,GA):i.convertToLocationInView(o.clientX,o.clientY,t,GA);var l=void 0;if(null!=o.identifier?(l=new FA(c.x,c.y,o.identifier),this.getPreTouch(l).getLocation(kA),l.setPrevPoint(kA.x,kA.y),this.setPreTouch(l)):(l=new FA(c.x,c.y)).setPrevPoint(r.x,r.y),r.x=c.x,r.y=c.y,n.push(l),!ft.ENABLE_MULTI_TOUCH)break}}return n},t.registerSystemEvent=function(e){if(!this._isRegisterEvent&&e){this._glView=i.view;var t=mg.isMobile,n=mg.capabilities.mouse,r=mg.capabilities.touches;n&&this._registerMouseEvents(e,t),window.navigator.msPointerEnabled&&this._registerMousePointerEvents(e),r&&this._registerTouchEvents(e),this._registerKeyboardEvent(),this._isRegisterEvent=!0}},t.setAccelerometerEnabled=function(e){if(this._accelEnabled!==e){this._accelEnabled=e;var t=i.director.getScheduler();t.enableForTarget(this),this._accelEnabled?(this._registerAccelerometerEvent(),this._accelCurTime=0,t.scheduleUpdate(this)):(this._unregisterAccelerometerEvent(),this._accelCurTime=0,t.unscheduleUpdate(this))}},t.didAccelerate=function(e){if(this._accelEnabled){var t=this._acceleration,n=0,r=0,a=0;if(this._accelDeviceEvent===window.DeviceMotionEvent){var s=e.accelerationIncludingGravity;s&&(n=this._accelMinus*(s.x||0)*.1,r=this._accelMinus*(s.y||0)*.1,a=.1*(s.z||0))}else{var o=e;n=(o.gamma||0)/90*.981,r=-(o.beta||0)/90*.981,a=(o.alpha||0)/90*.981}if(i.view._isRotated){var c=n;n=-r,r=c}t.x=n,t.y=r,t.z=a,t.timestamp=e.timeStamp||Date.now();var l=t.x;90===window.orientation?(t.x=-t.y,t.y=l):-90===window.orientation?(t.x=t.y,t.y=-l):180===window.orientation&&(t.x=-t.x,t.y=-t.y),i.sys.os===i.sys.OS_ANDROID&&i.sys.browserType!==i.sys.BROWSER_TYPE_MOBILE_QQ&&(t.x=-t.x,t.y=-t.y)}},t.update=function(e){this._accelCurTime>this._accelInterval&&(this._accelCurTime-=this._accelInterval,BA.dispatchEvent(new AA(this._acceleration))),this._accelCurTime+=e},t.setAccelerometerInterval=function(e){this._accelInterval!==e&&(this._accelInterval=e)},t._getUnUsedIndex=function(){for(var e=this._indexBitsUsed,t=i.director.getCurrentTime(),n=0;n<this._maxTouches;n++){if(!(1&e))return this._indexBitsUsed|=1<<n,n;var r=this._touches[n];if(t-r.lastModified>UA){this._removeUsedIndexBit(n);var a=r.getID();return null!==a&&delete this._touchesIntegerDict[a],n}e>>=1}return-1},t._removeUsedIndexBit=function(e){if(!(e<0||e>=this._maxTouches)){var t=1<<e;t=~t,this._indexBitsUsed&=t}},t._registerMouseEvents=function(e,t){this._registerPointerLockEvent(),t||this._registerWindowMouseEvents(e),this._registerElementMouseEvents(e,t)},t._registerPointerLockEvent=function(){var e=this,t=function(){var t=i.game.canvas;document.pointerLockElement===t||document.mozPointerLockElement===t?e._pointLocked=!0:e._pointLocked=!1};"onpointerlockchange"in document?document.addEventListener("pointerlockchange",t,!1):"onmozpointerlockchange"in document&&document.addEventListener("mozpointerlockchange",t,!1)},t._registerWindowMouseEvents=function(e){var t=this;window.addEventListener("mousedown",(function(){t._mousePressed=!0}),!1),window.addEventListener("mouseup",(function(n){if(t._mousePressed){t._mousePressed=!1;var i=t.getHTMLElementPosition(e),r=t.getPointByEvent(n,i);if(!ni(i.left,i.top,i.width,i.height).contains(new qn(r.x,r.y))){t.handleTouchesEnd([t.getTouchByXY(n,r.x,r.y,i)]);var a=t.getMouseEvent(r,i,EA.UP);a.setButton(n.button),BA.dispatchEvent(a)}}}),!1)},t._registerElementMouseEvents=function(e,t){var n=this,i=function(t,i,r){e.addEventListener(t,(function(t){var a=n.getHTMLElementPosition(e),s=n.getPointByEvent(t,a),o=n.getMouseEvent(s,a,i);o.setButton(t.button),r(t,o,s,a),BA.dispatchEvent(o),t.stopPropagation(),t.preventDefault()}))};t||(i("mousedown",EA.DOWN,(function(t,i,r,a){n._mousePressed=!0,n.handleTouchesBegin([n.getTouchByXY(t,r.x,r.y,a)]),e.focus()})),i("mouseup",EA.UP,(function(e,t,i,r){n._mousePressed=!1,n.handleTouchesEnd([n.getTouchByXY(e,i.x,i.y,r)])})),i("mousemove",EA.MOVE,(function(e,t,i,r){n.handleTouchesMove([n.getTouchByXY(e,i.x,i.y,r)]),n._mousePressed||t.setButton(EA.BUTTON_MISSING),void 0!==e.movementX&&void 0!==e.movementY&&(t.movementX=e.movementX,t.movementY=e.movementY)}))),i("mousewheel",EA.SCROLL,(function(e,t){t.setScrollData(0,e.wheelDelta)})),i("DOMMouseScroll",EA.SCROLL,(function(e,t){t.setScrollData(0,-120*e.detail)}))},t._registerMousePointerEvents=function(e){var t=this,n={MSPointerDown:this.handleTouchesBegin,MSPointerMove:this.handleTouchesMove,MSPointerUp:this.handleTouchesEnd,MSPointerCancel:this.handleTouchesCancel},i=function(i){var r=n[i];e.addEventListener(i,(function(n){var i=t.getHTMLElementPosition(e);i.left-=document.documentElement.scrollLeft,i.top-=document.documentElement.scrollTop,r.call(t,[t.getTouchByXY(n,n.clientX,n.clientY,i)]),n.stopPropagation()}),!1)};for(var r in n)i(r)},t._registerTouchEvents=function(e){var t=this,n=function(n){return function(i){if(i.changedTouches){var r=t.getHTMLElementPosition(e),a=document.body;r.left-=a.scrollLeft||0,r.top-=a.scrollTop||0,n(t.getTouchesByEvent(i,r)),i.stopPropagation(),i.preventDefault()}}};e.addEventListener("touchstart",n((function(n){t.handleTouchesBegin(n),e.focus()})),!1),e.addEventListener("touchmove",n((function(e){t.handleTouchesMove(e)})),!1),e.addEventListener("touchend",n((function(e){t.handleTouchesEnd(e)})),!1),e.addEventListener("touchcancel",n((function(e){t.handleTouchesCancel(e)})),!1)},t._registerKeyboardEvent=function(){var e=i.game.canvas;e.addEventListener("keydown",(function(e){BA.dispatchEvent(new xA(e,!0)),e.stopPropagation(),e.preventDefault()}),!1),e.addEventListener("keyup",(function(e){BA.dispatchEvent(new xA(e,!1)),e.stopPropagation(),e.preventDefault()}),!1)},t._registerAccelerometerEvent=function(){var e=this;this._acceleration=new HA,this._accelDeviceEvent=window.DeviceMotionEvent||window.DeviceOrientationEvent,i.sys.browserType===i.sys.BROWSER_TYPE_MOBILE_QQ&&(this._accelDeviceEvent=window.DeviceOrientationEvent);var t=this._accelDeviceEvent===window.DeviceMotionEvent?"devicemotion":"deviceorientation";zA=function(){return e.didAccelerate.apply(e,arguments)},window.addEventListener(t,zA,!1)},t._unregisterAccelerometerEvent=function(){var e=this._accelDeviceEvent===window.DeviceMotionEvent?"devicemotion":"deviceorientation";zA&&window.removeEventListener(e,zA,!1)},t._getUsefulTouches=function(){var e=[],t=this._touchesIntegerDict;for(var n in t){var i=t[parseInt(n)];if(null!=i){var r=this._touches[i];e.push(r)}}return e},e}());i.internal.inputManager=VA;var WA=e("Game",function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this).frame=null,t.container=null,t.canvas=null,t.renderType=-1,t.eventTargetOn=e.prototype.on,t.eventTargetOnce=e.prototype.once,t.config={},t.onStart=null,t.collisionMatrix=[],t.groupList=[],t._persistRootNodes={},t._paused=!0,t._configLoaded=!1,t._isCloning=!1,t._inited=!1,t._engineInited=!1,t._rendererInitialized=!1,t._gfxDevice=null,t._intervalId=null,t}X(t,e);var n=t.prototype;return n.setFrameRate=function(e){var t=this.config;"number"!=typeof e&&(e=parseInt(e,10),Number.isNaN(e)&&(e=60)),t.frameRate=e,this._paused=!0,this._setAnimFrame(),this._runMainLoop()},n.getFrameRate=function(){return this.config.frameRate||0},n.step=function(){i.director.mainLoop()},n.pause=function(){this._paused||(this._paused=!0,this._intervalId&&(window.cAF(this._intervalId),this._intervalId=0))},n.resume=function(){this._paused&&this._runMainLoop()},n.isPaused=function(){return this._paused},n.restart=function(){var e=this;return new Promise((function(e){return i.director.once(i.Director.EVENT_AFTER_DRAW,(function(){return e()}))})).then((function(){for(var n in e._persistRootNodes)e.removePersistRootNode(e._persistRootNodes[n]);return i.director.getScene().destroy(),i.Object._deferredDestroy(),i.director.reset(),e.pause(),e._setRenderPipelineNShowSplash().then((function(){e.resume(),e._safeEmit(t.EVENT_RESTART)}))}))},n.end=function(){this._gfxDevice&&(this._gfxDevice.destroy(),this._gfxDevice=null),window.close()},n.on=function(e,n,i,r){return this._engineInited&&e===t.EVENT_ENGINE_INITED?n.call(i):this.eventTargetOn(e,n,i,r)},n.once=function(e,n,i){return this._engineInited&&e===t.EVENT_ENGINE_INITED?n.call(i):this.eventTargetOnce(e,n,i)},n.init=function(e){var t=this;return this._initConfig(e),this.config.assetOptions&&i.assetManager.init(this.config.assetOptions),this._initEngine().then((function(){return t._initEvents(),i.director.root.dataPoolManager&&i.director.root.dataPoolManager.jointTexturePool.registerCustomTextureLayouts(e.customJointTextureLayouts),t._engineInited}))},n.run=function(e,t){var n,i=this;return"function"!=typeof e&&e?(n=this.init(e),this.onStart=null!=t?t:null):this.onStart=null!=e?e:null,Promise.resolve(n).then((function(){return jA.config.registerSystemEvent&&VA.registerSystemEvent(jA.canvas),i._setRenderPipelineNShowSplash()}))},n.addPersistRootNode=function(e){if(i.Node.isNode(e)&&e.uuid){var t=e.uuid;if(!this._persistRootNodes[t]){var n=i.director._scene;if(i.isValid(n))if(e.parent){if(!(e.parent instanceof i.Scene))return void E(3801);if(e.parent!==n)return void E(3802)}else e.parent=n;this._persistRootNodes[t]=e,e._persistNode=!0,i.assetManager._releaseManager._addPersistNodeRef(e)}}else E(3800)},n.removePersistRootNode=function(e){var t=e.uuid||"";e===this._persistRootNodes[t]&&(delete this._persistRootNodes[t],e._persistNode=!1,i.assetManager._releaseManager._removePersistNodeRef(e))},n.isPersistRootNode=function(e){return!!e._persistNode},n._initEngine=function(){var e=this;return this._initDevice(),Promise.resolve(i.director._init()).then((function(){h("Cocos Creator v3.0.0"),e.emit(t.EVENT_ENGINE_INITED),e._engineInited=!0,i.internal.dynamicAtlasManager.enabled=!ft.CLEANUP_IMAGE_CACHE}))},n._setAnimFrame=function(){this._lastTime=performance.now();var e=this.config.frameRate;this._frameTime=1e3/e,this._intervalId&&(window.cAF(this._intervalId),this._intervalId=0);var t=window.requestAnimationFrame=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame;60!==e&&30!==e?(window.rAF=t?this._stTimeWithRAF:this._stTime,window.cAF=this._ctTime):(window.rAF=t||this._stTime,window.cAF=window.cancelAnimationFrame||window.cancelRequestAnimationFrame||window.msCancelRequestAnimationFrame||window.mozCancelRequestAnimationFrame||window.oCancelRequestAnimationFrame||window.webkitCancelRequestAnimationFrame||window.msCancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.ocancelAnimationFrame||this._ctTime)},n._stTimeWithRAF=function(e){var t=performance.now(),n=Math.max(0,t-jA._lastTime),i=Math.max(0,jA._frameTime-n),r=window.setTimeout((function(){window.requestAnimationFrame(e)}),i);return jA._lastTime=t+i,r},n._stTime=function(e){var t=performance.now(),n=Math.max(0,t-jA._lastTime),i=Math.max(0,jA._frameTime-n),r=window.setTimeout(e,i);return jA._lastTime=t+i,r},n._ctTime=function(e){window.clearTimeout(e)},n._runMainLoop=function(){var e=this;if(this._inited){var t,n=this.config,r=i.director,a=n.frameRate;if(I(!!n.showFPS),r.startAnimation(),30===a){var s=!0;t=function(n){e._intervalId=window.rAF(t),(s=!s)||r.mainLoop(n)}}else t=function(n){e._intervalId=window.rAF(t),r.mainLoop(n)};this._intervalId&&(window.cAF(this._intervalId),this._intervalId=0),this._intervalId=window.rAF(t),this._paused=!1}},n._initConfig=function(e){"number"!=typeof e.debugMode&&(e.debugMode=x.NONE),e.exposeClassName=!!e.exposeClassName,"number"!=typeof e.frameRate&&(e.frameRate=60);var t=e.renderMode;("number"!=typeof t||t>2||t<0)&&(e.renderMode=0),"boolean"!=typeof e.registerSystemEvent&&(e.registerSystemEvent=!0),e.showFPS=!!e.showFPS,this.collisionMatrix=e.collisionMatrix||[],this.groupList=e.groupList||[],p(e.debugMode),this.config=e,this._configLoaded=!0,this._setAnimFrame()},n._determineRenderType=function(){var e=this.config,n=parseInt(e.renderMode,10);this.renderType=t.RENDER_TYPE_CANVAS;var r=!1;if(0===n?i.sys.capabilities.opengl?(this.renderType=t.RENDER_TYPE_WEBGL,r=!0):i.sys.capabilities.canvas&&(this.renderType=t.RENDER_TYPE_CANVAS,r=!0):1===n&&i.sys.capabilities.canvas?(this.renderType=t.RENDER_TYPE_CANVAS,r=!0):2===n&&i.sys.capabilities.opengl&&(this.renderType=t.RENDER_TYPE_WEBGL,r=!0),!r)throw new Error(b(3820,n))},n._initDevice=function(){if(!this._rendererInitialized){if(this.canvas=this.config.adapter.canvas,this.frame=this.config.adapter.frame,this.container=this.config.adapter.container,this._determineRenderType(),this.renderType===t.RENDER_TYPE_WEBGL){var e=[],n=!!window.WebGL2RenderingContext,r=window.navigator.userAgent.toLowerCase();(-1!==r.indexOf("safari")&&-1===r.indexOf("chrome")||mg.browserType===mg.BROWSER_TYPE_UC)&&(n=!1),n&&i.WebGL2Device&&e.push(i.WebGL2Device),i.WebGLDevice&&e.push(i.WebGLDevice);for(var a=new Fs(this.canvas,ft.ENABLE_WEBGL_ANTIALIAS,!1,window.devicePixelRatio,mg.windowPixelResolution.width,mg.windowPixelResolution.height,ql),s=0;s<e.length&&(this._gfxDevice=new e[s],!this._gfxDevice.initialize(a));s++);}if(!this._gfxDevice)return f("can not support canvas rendering in 3D"),void(this.renderType=t.RENDER_TYPE_CANVAS);this.canvas.oncontextmenu=function(){return!1}}},n._initEvents=function(){var e,n=this,i=window;void 0!==document.hidden?e="hidden":void 0!==document.mozHidden?e="mozHidden":void 0!==document.msHidden?e="msHidden":void 0!==document.webkitHidden&&(e="webkitHidden");var r=!1,a=this;function s(){r||(r=!0,a.emit(t.EVENT_HIDE))}function o(e,n,i,s,o){r&&(r=!1,a.emit(t.EVENT_SHOW,e,n,i,s,o))}if(e)for(var c=["visibilitychange","mozvisibilitychange","msvisibilitychange","webkitvisibilitychange","qbrowserVisibilityChange"],l=0;l<c.length;l++)document.addEventListener(c[l],(function(t){var n=document[e];(n=n||t.hidden)?s():o()}));else i.addEventListener("blur",s),i.addEventListener("focus",o);window.navigator.userAgent.indexOf("MicroMessenger")>-1&&(i.onfocus=o),"onpageshow"in window&&"onpagehide"in window&&(i.addEventListener("pagehide",s),i.addEventListener("pageshow",o),document.addEventListener("pagehide",s),document.addEventListener("pageshow",o)),this.on(t.EVENT_HIDE,(function(){n.pause()})),this.on(t.EVENT_SHOW,(function(){n.resume()}))},n._setRenderPipelineNShowSplash=function(){var e=this;return Promise.resolve(this._setupRenderPipeline()).then((function(){return Promise.resolve(e._showSplashScreen()).then((function(){e._inited=!0,e._setAnimFrame(),e._runMainLoop(),e._safeEmit(t.EVENT_GAME_INITED),e.onStart&&e.onStart()}))}))},n._setupRenderPipeline=function(){var e=this,t=this.config.renderPipeline;return t?new Promise((function(e,n){i.assetManager.loadAny(t,(function(t,i){return!t&&i instanceof Vg?e(i):n(t)}))})).then((function(t){e._setRenderPipeline(t)})).catch((function(n){_(n),_("Failed load render pipeline: "+t+", engine failed to initialize, will fallback to default pipeline"),e._setRenderPipeline()})):this._setRenderPipeline()},n._showSplashScreen=function(){if(i.internal.SplashScreen){var e=i.internal.SplashScreen.instance;return e.main(i.director.root),new Promise((function(t){e.setOnFinish((function(){return t()})),e.loadFinish=!0}))}return null},n._setRenderPipeline=function(e){i.director.root.setRenderPipeline(e)||this._setRenderPipeline(),this._rendererInitialized=!0,this._safeEmit(t.EVENT_RENDERER_INITED)},n._safeEmit=function(e){this.emit(e)},j(t,[{key:"inited",get:function(){return this._inited}},{key:"frameTime",get:function(){return this._frameTime}}]),t}(w_));WA.EVENT_HIDE="game_on_hide",WA.EVENT_SHOW="game_on_show",WA.EVENT_LOW_MEMORY="game_on_low_memory",WA.EVENT_GAME_INITED="game_inited",WA.EVENT_ENGINE_INITED="engine_inited",WA.EVENT_RENDERER_INITED="renderer_inited",WA.EVENT_RESTART="game_on_restart",WA.RENDER_TYPE_CANVAS=0,WA.RENDER_TYPE_WEBGL=1,WA.RENDER_TYPE_OPENGL=2,i.Game=WA;var jA=e("game",i.game=new WA),qA={topLeft:i.v2(0,0),topRight:i.v2(0,0),top:i.v2(0,0),bottomLeft:i.v2(0,0),bottomRight:i.v2(0,0),bottom:i.v2(0,0),center:i.v2(0,0),left:i.v2(0,0),right:i.v2(0,0),width:0,height:0,init:function(e){var t=this.width=e.width,n=this.height=e.height,i=e.x,r=e.y,a=r+n,s=i+t;this.topLeft.x=i,this.topLeft.y=a,this.topRight.x=s,this.topRight.y=a,this.top.x=i+t/2,this.top.y=a,this.bottomLeft.x=i,this.bottomLeft.y=r,this.bottomRight.x=s,this.bottomRight.y=r,this.bottom.x=i+t/2,this.bottom.y=r,this.center.x=i+t/2,this.center.y=r+n/2,this.left.x=i,this.left.y=r+n/2,this.right.x=s,this.right.y=r+n/2}};i.visibleRect=qA;var XA=new(function(){function e(){this.html=void 0,this.meta={width:"device-width"},this.adaptationType=i.sys.browserType}var t=e.prototype;return t.init=function(){this.html=document.getElementsByTagName("html")[0]},t.availWidth=function(e){return i.sys.isMobile||!e||e===this.html?window.innerWidth:e.clientWidth},t.availHeight=function(e){return i.sys.isMobile||!e||e===this.html?window.innerHeight:e.clientHeight},e}());switch(i.sys.os===i.sys.OS_IOS&&(XA.adaptationType=i.sys.BROWSER_TYPE_SAFARI),XA.adaptationType){case i.sys.BROWSER_TYPE_SAFARI:XA.meta["minimal-ui"]="true",XA.availWidth=function(e){return e.clientWidth},XA.availHeight=function(e){return e.clientHeight};break;case i.sys.BROWSER_TYPE_SOUGOU:case i.sys.BROWSER_TYPE_UC:XA.availWidth=function(e){return e.clientWidth},XA.availHeight=function(e){return e.clientHeight}}var YA=e("View",function(e){function t(){var t;(t=e.call(this)||this)._resizeWithBrowserSize=void 0,t._designResolutionSize=void 0,t._originalDesignResolutionSize=void 0,t._frameSize=void 0,t._scaleX=void 0,t._scaleY=void 0,t._viewportRect=void 0,t._visibleRect=void 0,t._autoFullScreen=void 0,t._devicePixelRatio=void 0,t._maxPixelRatio=void 0,t._retinaEnabled=void 0,t._resizeCallback=void 0,t._resizing=void 0,t._orientationChanging=void 0,t._isRotated=void 0,t._orientation=void 0,t._isAdjustViewport=void 0,t._resolutionPolicy=void 0,t._rpExactFit=void 0,t._rpShowAll=void 0,t._rpNoBorder=void 0,t._rpFixedHeight=void 0,t._rpFixedWidth=void 0;var n=KA,r=ZA;return t._frameSize=new $n(0,0),t._designResolutionSize=new $n(0,0),t._originalDesignResolutionSize=new $n(0,0),t._scaleX=1,t._scaleY=1,t._viewportRect=new ti(0,0,0,0),t._visibleRect=new ti(0,0,0,0),t._autoFullScreen=!1,t._devicePixelRatio=1,t._maxPixelRatio=2,t._retinaEnabled=!1,t._resizeCallback=null,t._resizing=!1,t._resizeWithBrowserSize=!1,t._orientationChanging=!0,t._isRotated=!1,t._orientation=i.macro.ORIENTATION_AUTO,t._isAdjustViewport=!0,t._rpExactFit=new QA(n.EQUAL_TO_FRAME,r.EXACT_FIT),t._rpShowAll=new QA(n.EQUAL_TO_FRAME,r.SHOW_ALL),t._rpNoBorder=new QA(n.EQUAL_TO_FRAME,r.NO_BORDER),t._rpFixedHeight=new QA(n.EQUAL_TO_FRAME,r.FIXED_HEIGHT),t._rpFixedWidth=new QA(n.EQUAL_TO_FRAME,r.FIXED_WIDTH),t._resolutionPolicy=t._rpShowAll,i.game.once(i.Game.EVENT_ENGINE_INITED,t.init,Y(t)),t}X(t,e);var n=t.prototype;return n.init=function(){XA.init(),this._initFrameSize();var e=i.game.canvas.width,t=i.game.canvas.height;this._designResolutionSize.width=e,this._designResolutionSize.height=t,this._originalDesignResolutionSize.width=e,this._originalDesignResolutionSize.height=t,this._viewportRect.width=e,this._viewportRect.height=t,this._visibleRect.width=e,this._visibleRect.height=t,i.winSize.width=this._visibleRect.width,i.winSize.height=this._visibleRect.height,i.visibleRect&&i.visibleRect.init(this._visibleRect)},n.resizeWithBrowserSize=function(e){e?this._resizeWithBrowserSize||(this._resizeWithBrowserSize=!0,window.addEventListener("resize",this._resizeEvent),window.addEventListener("orientationchange",this._orientationChange)):this._resizeWithBrowserSize&&(this._resizeWithBrowserSize=!1,window.removeEventListener("resize",this._resizeEvent),window.removeEventListener("orientationchange",this._orientationChange))},n.setResizeCallback=function(e){"function"!=typeof e&&null!=e||(this._resizeCallback=e)},n.setOrientation=function(e){(e&=i.macro.ORIENTATION_AUTO)&&this._orientation!==e&&(this._orientation=e)},n.adjustViewportMeta=function(e){this._isAdjustViewport=e},n.enableRetina=function(e){this._retinaEnabled=!!e},n.isRetinaEnabled=function(){return this._retinaEnabled},n.enableAutoFullScreen=function(e){e&&e!==this._autoFullScreen&&i.sys.isMobile&&i.sys.browserType!==i.sys.BROWSER_TYPE_WECHAT?(this._autoFullScreen=!0,i.screen.autoFullScreen(i.game.frame)):this._autoFullScreen=!1},n.isAutoFullScreenEnabled=function(){return this._autoFullScreen},n.setCanvasSize=function(e,t){var n=i.game.canvas,r=i.game.container;this._devicePixelRatio=window.devicePixelRatio,n.width=mg.windowPixelResolution.width,n.height=mg.windowPixelResolution.height,n.style.width=e+"px",n.style.height=t+"px",r.style.width=e+"px",r.style.height=t+"px",this._resizeEvent()},n.getCanvasSize=function(){return new $n(i.game.canvas.width,i.game.canvas.height)},n.getFrameSize=function(){return new $n(this._frameSize.width,this._frameSize.height)},n.setFrameSize=function(e,t){this._frameSize.width=e,this._frameSize.height=t,i.game.frame.style.width=e+"px",i.game.frame.style.height=t+"px",this._resizeEvent()},n.getVisibleSize=function(){return new $n(this._visibleRect.width,this._visibleRect.height)},n.getVisibleSizeInPixel=function(){return new $n(this._visibleRect.width*this._scaleX,this._visibleRect.height*this._scaleY)},n.getVisibleOrigin=function(){return new qn(this._visibleRect.x,this._visibleRect.y)},n.getVisibleOriginInPixel=function(){return new qn(this._visibleRect.x*this._scaleX,this._visibleRect.y*this._scaleY)},n.getResolutionPolicy=function(){return this._resolutionPolicy},n.setResolutionPolicy=function(e){if(e instanceof QA)this._resolutionPolicy=e;else{var t=QA;e===t.EXACT_FIT&&(this._resolutionPolicy=this._rpExactFit),e===t.SHOW_ALL&&(this._resolutionPolicy=this._rpShowAll),e===t.NO_BORDER&&(this._resolutionPolicy=this._rpNoBorder),e===t.FIXED_HEIGHT&&(this._resolutionPolicy=this._rpFixedHeight),e===t.FIXED_WIDTH&&(this._resolutionPolicy=this._rpFixedWidth)}},n.setDesignResolutionSize=function(e,t,n){if(e>0&&t>0){this.setResolutionPolicy(n);var r=this._resolutionPolicy;if(r&&r.preApply(this),i.sys.isMobile&&this._adjustViewportMeta(),this._orientationChanging=!0,this._resizing||this._initFrameSize(),r){this._originalDesignResolutionSize.width=this._designResolutionSize.width=e,this._originalDesignResolutionSize.height=this._designResolutionSize.height=t;var a=r.apply(this,this._designResolutionSize);if(a.scale&&2===a.scale.length&&(this._scaleX=a.scale[0],this._scaleY=a.scale[1]),a.viewport){var s=this._viewportRect,o=this._visibleRect,c=a.viewport;s.x=c.x,s.y=c.y,s.width=c.width,s.height=c.height,o.x=0,o.y=0,o.width=c.width/this._scaleX,o.height=c.height/this._scaleY}r.postApply(this),i.winSize.width=this._visibleRect.width,i.winSize.height=this._visibleRect.height,qA&&qA.init(this._visibleRect),this.emit("design-resolution-changed")}else y(2201)}else A(2200)},n.getDesignResolutionSize=function(){return new $n(this._designResolutionSize.width,this._designResolutionSize.height)},n.setRealPixelResolution=function(e,t,n){this._setViewportMeta({width:e},!0),document.documentElement.style.width=e+"px",document.body.style.width=e+"px",document.body.style.left="0px",document.body.style.top="0px",this.setDesignResolutionSize(e,t,n)},n.getViewportRect=function(){return this._viewportRect},n.getScaleX=function(){return this._scaleX},n.getScaleY=function(){return this._scaleY},n.getDevicePixelRatio=function(){return this._devicePixelRatio},n.convertToLocationInView=function(e,t,n,r){var a=r||new qn,s=this._devicePixelRatio*(e-n.left),o=this._devicePixelRatio*(n.top+n.height-t);return this._isRotated?(a.x=i.game.canvas.width-o,a.y=s):(a.x=s,a.y=o),i.GAME_VIEW&&(a.x/=i.gameView.canvas.width/i.game.canvas.width,a.y/=i.gameView.canvas.height/i.game.canvas.height),a},n._convertPointWithScale=function(e){var t=this._viewportRect;e.x=(e.x-t.x)/this._scaleX,e.y=(e.y-t.y)/this._scaleY},n._resizeEvent=function(){var e=i.view,t=e._frameSize.width,n=e._frameSize.height,r=e._isRotated;if(i.sys.isMobile){var a=i.game.container.style,s=a.margin;a.margin="0",a.display="none",e._initFrameSize(),a.margin=s,a.display="block"}else e._initFrameSize();if(e._orientationChanging||e._isRotated!==r||e._frameSize.width!==t||e._frameSize.height!==n){var o=e._originalDesignResolutionSize.width,c=e._originalDesignResolutionSize.height;e._resizing=!0,o>0&&e.setDesignResolutionSize(o,c,e._resolutionPolicy),e._resizing=!1,e.emit("canvas-resize"),e._resizeCallback&&e._resizeCallback.call()}},n._orientationChange=function(){i.view._orientationChanging=!0,i.view._resizeEvent()},n._initFrameSize=function(){var e=this._frameSize,t=XA.availWidth(i.game.frame),n=XA.availHeight(i.game.frame),r=t>=n;!i.sys.isMobile||r&&this._orientation&i.macro.ORIENTATION_LANDSCAPE||!r&&this._orientation&i.macro.ORIENTATION_PORTRAIT?(e.width=t,e.height=n,i.game.container.style["-webkit-transform"]="rotate(0deg)",i.game.container.style.transform="rotate(0deg)",this._isRotated=!1):(e.width=n,e.height=t,i.game.container.style["-webkit-transform"]="rotate(90deg)",i.game.container.style.transform="rotate(90deg)",i.game.container.style["-webkit-transform-origin"]="0px 0px 0px",i.game.container.style.transformOrigin="0px 0px 0px",this._isRotated=!0,i.game.canvas.style["-webkit-transform"]="translateZ(0px)",i.game.canvas.style.transform="translateZ(0px)"),this._orientationChanging&&setTimeout((function(){i.view._orientationChanging=!1}),1e3)},n._adjustSizeKeepCanvasSize=function(){var e=this._originalDesignResolutionSize.width,t=this._originalDesignResolutionSize.height;e>0&&this.setDesignResolutionSize(e,t,this._resolutionPolicy)},n._setViewportMeta=function(e,t){var n=document.getElementById("cocosMetaElement");n&&t&&document.head.removeChild(n);var i,r,a,s=document.getElementsByName("viewport"),o=s?s[0]:null;for(r in i=o?o.content:"",(n=n||document.createElement("meta")).id="cocosMetaElement",n.name="viewport",n.content="",e)-1===i.indexOf(r)?i+=","+r+"="+e[r]:t&&(a=new RegExp(r+"s*=s*[^,]+"),i=i.replace(a,r+"="+e[r]));/^,/.test(i)&&(i=i.substr(1)),n.content=i,o&&(o.content=i),document.head.appendChild(n)},n._adjustViewportMeta=function(){this._isAdjustViewport&&(this._setViewportMeta(XA.meta,!1),this._isAdjustViewport=!1)},n._convertMouseToLocation=function(e,t){e.x=this._devicePixelRatio*(e.x-t.left),e.y=this._devicePixelRatio*(t.top+t.height-e.y),i.GAME_VIEW&&(e.x/=i.gameView.canvas.width/i.game.canvas.width,e.y/=i.gameView.canvas.height/i.game.canvas.height)},n._convertTouchWidthScale=function(e){var t=this._viewportRect,n=this._scaleX,i=this._scaleY;e._point.x=(e._point.x-t.x)/n,e._point.y=(e._point.y-t.y)/i,e._prevPoint.x=(e._prevPoint.x-t.x)/n,e._prevPoint.y=(e._prevPoint.y-t.y)/i},n._convertTouchesWithScale=function(e){for(var t,n,i=this._viewportRect,r=this._scaleX,a=this._scaleY,s=0;s<e.length;s++){var o=e[s];t=o._point,n=o._prevPoint,t.x=(t.x-i.x)/r,t.y=(t.y-i.y)/a,n.x=(n.x-i.x)/r,n.y=(n.y-i.y)/a}},t}(w_));YA.instance=void 0;var KA=function(){function e(){this.name="ContainerStrategy"}var t=e.prototype;return t.preApply=function(){},t.apply=function(){},t.postApply=function(){},t._setupContainer=function(e,t,n){var r=i.game.canvas,a=i.game.container;i.sys.os===i.sys.OS_ANDROID&&(document.body.style.width=(e._isRotated?n:t)+"px",document.body.style.height=(e._isRotated?t:n)+"px"),a.style.width=r.style.width=t+"px",a.style.height=r.style.height=n+"px",e._devicePixelRatio=1,e.isRetinaEnabled()&&(e._devicePixelRatio=Math.min(e._maxPixelRatio,window.devicePixelRatio||1)),r.width=t*e._devicePixelRatio,r.height=n*e._devicePixelRatio},t._fixContainer=function(){document.body.insertBefore(i.game.container,document.body.firstChild);var e=document.body.style;e.width=window.innerWidth+"px",e.height=window.innerHeight+"px",e.overflow="hidden";var t=i.game.container.style;t.position="fixed",t.left=t.top="0px",document.body.scrollTop=0},e}();KA.EQUAL_TO_FRAME=void 0,KA.PROPORTION_TO_FRAME=void 0;var ZA=function(){function e(){this.name="ContentStrategy",this._result=void 0,this._result={scale:[1,1],viewport:null}}var t=e.prototype;return t.preApply=function(){},t.apply=function(){return{scale:[1,1]}},t.postApply=function(){},t._buildResult=function(e,t,n,i,r,a){Math.abs(e-n)<2&&(n=e),Math.abs(t-i)<2&&(i=t);var s=new ti(Math.round((e-n)/2),Math.round((t-i)/2),n,i);return this._result.scale=[r,a],this._result.viewport=s,this._result},e}();ZA.EXACT_FIT=void 0,ZA.SHOW_ALL=void 0,ZA.NO_BORDER=void 0,ZA.FIXED_HEIGHT=void 0,ZA.FIXED_WIDTH=void 0,function(){var e=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this).name="EqualToFrame",t}return X(t,e),t.prototype.apply=function(e){var t=e._frameSize.height,n=i.game.container.style;this._setupContainer(e,e._frameSize.width,e._frameSize.height),e._isRotated?n.margin="0 0 0 "+t+"px":n.margin="0px",n.padding="0px"},t}(KA),t=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this).name="ProportionalToFrame",t}return X(t,e),t.prototype.apply=function(e,t){var n,r,a=e._frameSize.width,s=e._frameSize.height,o=i.game.container.style,c=t.width,l=t.height,u=a/c,h=s/l;u<h?(n=a,r=l*u):(n=c*h,r=s);var _=Math.round((a-n)/2),f=Math.round((s-r)/2);n=a-2*_,r=s-2*f,this._setupContainer(e,n,r),e._isRotated?o.margin="0 0 0 "+s+"px":o.margin="0px",o.paddingLeft=_+"px",o.paddingRight=_+"px",o.paddingTop=f+"px",o.paddingBottom=f+"px"},t}(KA),n=("undefined"==typeof window?global:window).__globalAdapter;n&&(n.adaptContainerStrategy&&n.adaptContainerStrategy(KA.prototype),n.adaptView&&n.adaptView(YA.prototype)),KA.EQUAL_TO_FRAME=new e,KA.PROPORTION_TO_FRAME=new t;var r=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this).name="ExactFit",t}return X(t,e),t.prototype.apply=function(e,t){var n=i.game.canvas.width,r=i.game.canvas.height,a=n/t.width,s=r/t.height;return this._buildResult(n,r,n,r,a,s)},t}(ZA),a=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this).name="ShowAll",t}return X(t,e),t.prototype.apply=function(e,t){var n,r,a=i.game.canvas.width,s=i.game.canvas.height,o=t.width,c=t.height,l=a/o,u=s/c,h=0;return l<u?(n=a,r=c*(h=l)):(n=o*(h=u),r=s),this._buildResult(a,s,n,r,h,h)},t}(ZA),s=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this).name="NoBorder",t}return X(t,e),t.prototype.apply=function(e,t){var n,r,a,s=i.game.canvas.width,o=i.game.canvas.height,c=t.width,l=t.height,u=s/c,h=o/l;return u<h?(r=c*(n=h),a=o):(r=s,a=l*(n=u)),this._buildResult(s,o,r,a,n,n)},t}(ZA),o=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this).name="FixedHeight",t}return X(t,e),t.prototype.apply=function(e,t){var n=i.game.canvas.width,r=i.game.canvas.height,a=r/t.height,s=n,o=r;return this._buildResult(n,r,s,o,a,a)},t}(ZA),c=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this).name="FixedWidth",t}return X(t,e),t.prototype.apply=function(e,t){var n=i.game.canvas.width,r=i.game.canvas.height,a=n/t.width,s=n,o=r;return this._buildResult(n,r,s,o,a,a)},t}(ZA);ZA.EXACT_FIT=new r,ZA.SHOW_ALL=new a,ZA.NO_BORDER=new s,ZA.FIXED_HEIGHT=new o,ZA.FIXED_WIDTH=new c}();var QA=e("ResolutionPolicy",function(){function e(e,t){this.name="ResolutionPolicy",this._containerStrategy=void 0,this._contentStrategy=void 0,this._containerStrategy=null,this._contentStrategy=null,this.setContainerStrategy(e),this.setContentStrategy(t)}var t=e.prototype;return t.preApply=function(e){this._containerStrategy.preApply(e),this._contentStrategy.preApply(e)},t.apply=function(e,t){return this._containerStrategy.apply(e,t),this._contentStrategy.apply(e,t)},t.postApply=function(e){this._containerStrategy.postApply(e),this._contentStrategy.postApply(e)},t.setContainerStrategy=function(e){e instanceof KA&&(this._containerStrategy=e)},t.setContentStrategy=function(e){e instanceof ZA&&(this._contentStrategy=e)},j(e,[{key:"canvasSize",get:function(){return new qn(i.game.canvas.width,i.game.canvas.height)}}]),e}());QA.EXACT_FIT=0,QA.NO_BORDER=1,QA.SHOW_ALL=2,QA.FIXED_HEIGHT=3,QA.FIXED_WIDTH=4,QA.UNKNOWN=5,QA.ContainerStrategy=KA,QA.ContentStrategy=ZA,i.ResolutionPolicy=QA;var JA,$A=e("view",YA.instance=i.view=new YA);i.winSize=new $n,oe(YA.prototype,"View.prototype",[{name:"isAntiAliasEnabled",suggest:"The API of Texture2d have been largely modified, no alternative"},{name:"enableAntiAlias",suggest:"The API of Texture2d have been largely modified, no alternative"}]),function(e){e.TOUCH_START="touch-start",e.TOUCH_MOVE="touch-move",e.TOUCH_END="touch-end",e.TOUCH_CANCEL="touch-cancel",e.MOUSE_DOWN="mouse-down",e.MOUSE_MOVE="mouse-move",e.MOUSE_UP="mouse-up",e.MOUSE_WHEEL="mouse-wheel",e.MOUSE_ENTER="mouse-enter",e.MOUSE_LEAVE="mouse-leave",e.KEY_DOWN="keydown",e.KEY_UP="keyup",e.DEVICEMOTION="devicemotion",e.TRANSFORM_CHANGED="transform-changed",e.SCENE_CHANGED_FOR_PERSISTS="scene-changed-for-persists",e.SIZE_CHANGED="size-changed",e.ANCHOR_CHANGED="anchor-changed",e.COLOR_CHANGED="color-changed",e.CHILD_ADDED="child-added",e.CHILD_REMOVED="child-removed",e.PARENT_CHANGED="parent-changed",e.NODE_DESTROYED="node-destroyed",e.LAYER_CHANGED="layer-changed",e.SIBLING_ORDER_CHANGED="sibling-order-changed"}(JA||(JA=e("SystemEventType",{}))),ht(JA),i.SystemEventType=JA,se(JA,"Node.EventType",[{name:"POSITION_PART",newName:"TRANSFORM_CHANGED"},{name:"ROTATION_PART",newName:"TRANSFORM_CHANGED"},{name:"SCALE_PART",newName:"TRANSFORM_CHANGED"}]);var ex=null,tx=null,nx=null,ix=null,rx=e("SystemEvent",function(e){function t(){return e.call(this)||this}X(t,e);var n=t.prototype;return n.setAccelerometerEnabled=function(e){e&&window.DeviceMotionEvent&&"function"==typeof DeviceMotionEvent.requestPermission?DeviceMotionEvent.requestPermission().then((function(e){y(3520,e),VA.setAccelerometerEnabled("granted"===e)})).catch((function(e){E(3521,e.message),VA.setAccelerometerEnabled(!1)})):VA.setAccelerometerEnabled(e)},n.setAccelerometerInterval=function(e){VA.setAccelerometerInterval(e)},n.on=function(t,n,r,a){return e.prototype.on.call(this,t,n,r,a),t!==JA.KEY_DOWN&&t!==JA.KEY_UP||ex||(ex=CA.create({event:CA.KEYBOARD,onKeyPressed:function(e,t){t.type=JA.KEY_DOWN,ax.emit(t.type,t)},onKeyReleased:function(e,t){t.type=JA.KEY_UP,ax.emit(t.type,t)}}),BA.addListener(ex,256)),t===JA.DEVICEMOTION&&(tx||(tx=CA.create({event:CA.ACCELERATION,callback:function(e,t){t.type=JA.DEVICEMOTION,i.systemEvent.emit(t.type,t)}}),BA.addListener(tx,256))),t!==JA.TOUCH_START&&t!==JA.TOUCH_MOVE&&t!==JA.TOUCH_END&&t!==JA.TOUCH_CANCEL||nx||(nx=CA.create({event:CA.TOUCH_ONE_BY_ONE,onTouchBegan:function(e,t){return t.type=JA.TOUCH_START,i.systemEvent.emit(t.type,e,t),!0},onTouchMoved:function(e,t){t.type=JA.TOUCH_MOVE,i.systemEvent.emit(t.type,e,t)},onTouchEnded:function(e,t){t.type=JA.TOUCH_END,i.systemEvent.emit(t.type,e,t)},onTouchCancelled:function(e,t){t.type=JA.TOUCH_CANCEL,i.systemEvent.emit(t.type,e,t)}}),BA.addListener(nx,256)),t!==JA.MOUSE_DOWN&&t!==JA.MOUSE_MOVE&&t!==JA.MOUSE_UP&&t!==JA.MOUSE_WHEEL||ix||(ix=CA.create({event:CA.MOUSE,onMouseDown:function(e){e.type=JA.MOUSE_DOWN,i.systemEvent.emit(e.type,e)},onMouseMove:function(e){e.type=JA.MOUSE_MOVE,i.systemEvent.emit(e.type,e)},onMouseUp:function(e){e.type=JA.MOUSE_UP,i.systemEvent.emit(e.type,e)},onMouseScroll:function(e){e.type=JA.MOUSE_WHEEL,i.systemEvent.emit(e.type,e)}}),BA.addListener(ix,256)),n},n.off=function(t,n,i){if(e.prototype.off.call(this,t,n,i),ex&&(t===JA.KEY_DOWN||t===JA.KEY_UP)){var r=this.hasEventListener(JA.KEY_DOWN),a=this.hasEventListener(JA.KEY_UP);r||a||(BA.removeListener(ex),ex=null)}if(tx&&t===JA.DEVICEMOTION&&(BA.removeListener(tx),tx=null),nx&&(t===JA.TOUCH_START||t===JA.TOUCH_MOVE||t===JA.TOUCH_END||t===JA.TOUCH_CANCEL)){var s=this.hasEventListener(JA.TOUCH_START),o=this.hasEventListener(JA.TOUCH_MOVE),c=this.hasEventListener(JA.TOUCH_END),l=this.hasEventListener(JA.TOUCH_CANCEL);s||o||c||l||(BA.removeListener(nx),nx=null)}if(ix&&(t===JA.MOUSE_DOWN||t===JA.MOUSE_MOVE||t===JA.MOUSE_UP||t===JA.MOUSE_WHEEL)){var u=this.hasEventListener(JA.MOUSE_DOWN),h=this.hasEventListener(JA.MOUSE_MOVE),_=this.hasEventListener(JA.MOUSE_UP),f=this.hasEventListener(JA.MOUSE_WHEEL);u||h||_||f||(BA.removeListener(ix),ix=null)}},t}(w_));rx.EventType=JA,i.SystemEvent=rx;var ax=e("systemEvent",new rx);i.systemEvent=ax;var sx=e("screen",{_supportsFullScreen:!1,_onfullscreenchange:null,_onfullscreenerror:null,_preOnFullScreenError:null,_preOnTouch:null,_touchEvent:"",_fn:null,_fnMap:[["requestFullscreen","exitFullscreen","fullscreenchange","fullscreenEnabled","fullscreenElement"],["requestFullScreen","exitFullScreen","fullScreenchange","fullScreenEnabled","fullScreenElement"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitfullscreenchange","webkitIsFullScreen","webkitCurrentFullScreenElement"],["mozRequestFullScreen","mozCancelFullScreen","mozfullscreenchange","mozFullScreen","mozFullScreenElement"],["msRequestFullscreen","msExitFullscreen","MSFullscreenChange","msFullscreenEnabled","msFullscreenElement"]],init:function(){var e,t,n;this._fn={};var i,r=this._fnMap;for(e=0,t=r.length;e<t;e++)if((n=r[e])&&void 0!==document[n[1]]){for(e=0,i=n.length;e<i;e++)this._fn[r[0][e]]=n[e];break}this._supportsFullScreen=void 0!==this._fn.requestFullscreen,this._touchEvent="ontouchstart"in window?"touchstart":"mousedown"},get supportsFullScreen(){return this._supportsFullScreen},fullScreen:function(){return!!this._supportsFullScreen&&void 0!==document[this._fn.fullscreenElement]&&null!==document[this._fn.fullscreenElement]},requestFullScreen:function(e,t,n){if(this._supportsFullScreen){if(e=e||document.documentElement,t){var i=this._fn.fullscreenchange;this._onfullscreenchange&&document.removeEventListener(i,this._onfullscreenchange),this._onfullscreenchange=t,document.addEventListener(i,t,!1)}if(n){var r=this._fn.fullscreenerror;this._onfullscreenerror&&document.removeEventListener(r,this._onfullscreenerror),this._onfullscreenerror=n,document.addEventListener(r,n,{once:!0})}var a=e[this._fn.requestFullscreen]();return window.Promise&&a instanceof Promise&&a.catch((function(){})),a}},exitFullScreen:function(){var e;return this.fullScreen()&&(e=document[this._fn.exitFullscreen]()).catch((function(){})),e},autoFullScreen:function(e,t){e=e||document.body,this._ensureFullScreen(e,t),this.requestFullScreen(e,t)},disableAutoFullScreen:function(e){if(this._preOnTouch){var t=i.game.canvas||e,n=this._touchEvent;t.removeEventListener(n,this._preOnTouch),this._preOnTouch=null}},_ensureFullScreen:function(e,t){var n=this,r=i.game.canvas||e,a=this._fn.fullscreenerror,s=this._touchEvent,o=function(){n._preOnFullScreenError=null,n._preOnTouch&&r.removeEventListener(s,n._preOnTouch),n._preOnTouch=function(){n._preOnTouch=null,n.requestFullScreen(e,t)},r.addEventListener(s,n._preOnTouch,{once:!0})};this._preOnFullScreenError&&e.removeEventListener(a,this._preOnFullScreenError),this._preOnFullScreenError=o,e.addEventListener(a,o,{once:!0})}});sx.init(),i.screen=sx;var ox=function(){var e=t.prototype;function t(){this.handle=0,this.callBack=null,this.cancelAnimate=!1,this.startTime=-1,this._splashFinish=!1,this._loadFinish=!1,this._directCall=!1}return e.main=function(e){if(null!=e){if(window._CCSettings&&window._CCSettings.splashScreen){var t=this.setting=window._CCSettings.splashScreen;t.totalTime=null!=this.setting.totalTime?this.setting.totalTime:3e3,t.base64src=this.setting.base64src||"",t.effect=this.setting.effect||"FADE-INOUT",t.clearColor=this.setting.clearColor||new Ks(.88,.88,.88,1),t.displayRatio=null!=this.setting.displayRatio?this.setting.displayRatio:.4,t.displayWatermark=null==this.setting.displayWatermark||this.setting.displayWatermark}else this.setting={totalTime:3e3,base64src:"",effect:"FADE-INOUT",clearColor:new Ks(.88,.88,.88,1),displayRatio:.4,displayWatermark:!0};if(""===this.setting.base64src||this.setting.totalTime<=0)this.callBack&&this.callBack(),this.callBack=null,this.setting=null,this._directCall=!0;else{i.view.enableRetina(!0);var n=window._CCSettings.designResolution;n?i.view.setDesignResolutionSize(n.width,n.height,n.policy):i.view.setDesignResolutionSize(960,640,4),this.root=e,this.device=e.device,i.game.once(i.Game.EVENT_GAME_INITED,(function(){i.director._lateUpdate=performance.now()}),i.director),this.callBack=null,this.cancelAnimate=!1,this.startTime=-1;var r=this.setting.clearColor;this.clearColors=[new Ks(r.x,r.y,r.z,r.w)];var a=this.device,s=a.width,o=a.height,c=a.surfaceTransform;this.screenWidth=c%2?o:s,this.screenHeight=c%2?s:o,this.image=new Image,this.image.onload=this.init.bind(this),this.image.src=this.setting.base64src}}else f("RENDER ROOT IS NULL.")},e.setOnFinish=function(e){if(this._directCall&&e)return t._ins=void 0,void e();this.callBack=e},e._tryToStart=function(){this._splashFinish&&this._loadFinish&&this.callBack&&(this.callBack(),this.hide(),i.game.resume())},e.init=function(){var e=this;this.initCMD(),this.initIA(),this.initPSO(),this.setting.displayWatermark&&this.initText(),i.game.pause(),this.handle=requestAnimationFrame((function t(n){if(!e.cancelAnimate){e.startTime<0&&(e.startTime=n);var i=n-e.startTime,r=Im(ln(i/e.setting.totalTime));"NONE"===e.setting.effect&&(r=1),e.material.setProperty("u_precent",r),e.material.passes[0].update(),e.setting.displayWatermark&&e.textMaterial&&(e.textMaterial.setProperty("u_precent",r),e.textMaterial.passes[0].update()),e.frame(n),i>e.setting.totalTime&&(e.splashFinish=!0),requestAnimationFrame(t)}}))},e.hide=function(){cancelAnimationFrame(this.handle),this.cancelAnimate=!0,setTimeout(this.destroy.bind(this))},e.frame=function(){if(!this.cancelAnimate){var e=this.device;e.acquire();var t=this.cmdBuff,n=this.framebuffer,i=this.renderArea;i.height=e.height,i.width=e.width,t.begin(),t.beginRenderPass(n.renderPass,n,i,this.clearColors,1,0);var r=this.material.passes[0],a=Wg.getOrCreatePipelineState(e,r,this.shader,n.renderPass,this.assmebler);if(t.bindPipelineState(a),t.bindDescriptorSet(Vl.MATERIAL,r.descriptorSet),t.bindInputAssembler(this.assmebler),t.draw(this.assmebler),this.setting.displayWatermark&&this.textShader&&this.textAssmebler){var s=this.textMaterial.passes[0],o=Wg.getOrCreatePipelineState(e,s,this.textShader,n.renderPass,this.textAssmebler);t.bindPipelineState(o),t.bindDescriptorSet(Vl.MATERIAL,s.descriptorSet),t.bindInputAssembler(this.textAssmebler),t.draw(this.textAssmebler)}t.endRenderPass(),t.end(),e.queue.submit([t]),e.present()}},e.initText=function(){this.textImg=document.createElement("canvas"),this.textImg.width=330,this.textImg.height=30,this.textImg.style.width=""+this.textImg.width,this.textImg.style.height=""+this.textImg.height;var e=this.textImg.getContext("2d");e.font="18px Arial",e.textBaseline="top",e.textAlign="left",e.fillStyle="`#424242`";var t="Powered by Cocos Creator",n=e.measureText(t);e.fillText(t,(330-n.width)/2,6),this.textRegion=new eo,this.textRegion.texExtent.width=this.textImg.width,this.textRegion.texExtent.height=this.textImg.height,this.textRegion.texExtent.depth=1,this.textTexture=this.device.createTexture(new xo(es.TEX2D,ts.SAMPLED|ts.TRANSFER_DST,za.RGBA8,this.textImg.width,this.textImg.height)),this.device.copyTexImagesToTexture([this.textImg],this.textTexture,[this.textRegion]),this.textMaterial=new em,this.textMaterial.initialize({effectName:"splash-screen"});var i=this.textMaterial.passes[0],r=i.getBinding("mainTexture");i.bindTexture(r,this.textTexture),this.textShader=zi.get(i.getShaderVariant()),Ui.get(er.get(i.handle,Fi.DESCRIPTOR_SET)).update();var a=4*Float32Array.BYTES_PER_ELEMENT,s=4*a;this.textVB=this.device.createBuffer(new Ps(Ua.VERTEX|Ua.TRANSFER_DST,Ga.HOST|Ga.DEVICE,s,a));var o=new Float32Array(16),c=-this.textImg.width/2,l=this.textImg.height;l=this.screenWidth<this.screenHeight?(c=-this.screenWidth/2*.5)/(this.textImg.width/this.textImg.height):(c=-this.screenHeight/2*.5)/(this.textImg.width/this.textImg.height);var u=0;o[u++]=c,o[u++]=l,o[u++]=0,o[u++]=1,o[u++]=-c,o[u++]=l,o[u++]=1,o[u++]=1,o[u++]=c,o[u++]=-l,o[u++]=0,o[u++]=0,o[u++]=-c,o[u++]=-l,o[u++]=1,o[u++]=0;for(var h=0;h<o.length;h+=4)o[h]+=this.screenWidth/2,o[h+1]+=.1*this.screenHeight;for(var _=this.device.screenSpaceSignY,f=kn[this.device.surfaceTransform],d=0;d<o.length;d+=4){var p=o[d]/this.screenWidth*2-1,m=(o[d+1]/this.screenHeight*2-1)*_;o[d]=f[0]*p+f[2]*m,o[d+1]=f[1]*p+f[3]*m}this.textVB.update(o);var g=Uint16Array.BYTES_PER_ELEMENT,v=6*g;this.textIB=this.device.createBuffer(new Ps(Ua.INDEX|Ua.TRANSFER_DST,Ga.HOST|Ga.DEVICE,v,g));var y=new Uint16Array(6);y[0]=0,y[1]=1,y[2]=2,y[3]=1,y[4]=3,y[5]=2,this.textIB.update(y);var S=[new Ws("a_position",za.RG32F),new Ws("a_texCoord",za.RG32F)],E=new js(S,[this.textVB],this.textIB);this.textAssmebler=this.device.createInputAssembler(E)},e.initCMD=function(){var e=this.device;this.renderArea=new Xs(0,0,e.width,e.height),this.framebuffer=this.root.mainWindow.framebuffer,this.cmdBuff=e.commandBuffer},e.initIA=function(){var e=this.device,t=4*Float32Array.BYTES_PER_ELEMENT,n=4*t;this.vertexBuffers=e.createBuffer(new Ps(Ua.VERTEX|Ua.TRANSFER_DST,Ga.HOST|Ga.DEVICE,n,t));var i=new Float32Array(16),r=-this.image.width/2,a=this.image.height;a=this.screenWidth<this.screenHeight?(r=-this.screenWidth/2*this.setting.displayRatio)/(this.image.width/this.image.height):(r=-this.screenHeight/2*this.setting.displayRatio)/(this.image.width/this.image.height);var s=0;i[s++]=r,i[s++]=a,i[s++]=0,i[s++]=1,i[s++]=-r,i[s++]=a,i[s++]=1,i[s++]=1,i[s++]=r,i[s++]=-a,i[s++]=0,i[s++]=0,i[s++]=-r,i[s++]=-a,i[s++]=1,i[s++]=0;for(var o=0;o<i.length;o+=4)i[o]+=this.screenWidth/2,i[o+1]+=this.screenHeight/2;for(var c=this.device.screenSpaceSignY,l=kn[this.device.surfaceTransform],u=0;u<i.length;u+=4){var h=i[u]/this.screenWidth*2-1,_=(i[u+1]/this.screenHeight*2-1)*c;i[u]=l[0]*h+l[2]*_,i[u+1]=l[1]*h+l[3]*_}this.vertexBuffers.update(i);var f=Uint16Array.BYTES_PER_ELEMENT,d=6*f;this.indicesBuffers=e.createBuffer(new Ps(Ua.INDEX|Ua.TRANSFER_DST,Ga.HOST|Ga.DEVICE,d,f));var p=new Uint16Array(6);p[0]=0,p[1]=1,p[2]=2,p[3]=1,p[4]=3,p[5]=2,this.indicesBuffers.update(p);var m=[new Ws("a_position",za.RG32F),new Ws("a_texCoord",za.RG32F)],g=new js(m,[this.vertexBuffers],this.indicesBuffers);this.assmebler=e.createInputAssembler(g)},e.initPSO=function(){var e=this.device;this.material=new em,this.material.initialize({effectName:"splash-screen"});var t=new mo;t.addressU=$a.CLAMP,t.addressV=$a.CLAMP,this.sampler=e.createSampler(t),this.texture=e.createTexture(new xo(es.TEX2D,ts.SAMPLED|ts.TRANSFER_DST,za.RGBA8,this.image.width,this.image.height));var n=this.material.passes[0],i=n.getBinding("mainTexture");n.bindTexture(i,this.texture),this.shader=zi.get(n.getShaderVariant());var r=Ui.get(er.get(n.handle,Fi.DESCRIPTOR_SET));r.bindSampler(i,this.sampler),r.update(),this.region=new eo,this.region.texExtent.width=this.image.width,this.region.texExtent.height=this.image.height,this.region.texExtent.depth=1,e.copyTexImagesToTexture([this.image],this.texture,[this.region])},e.destroy=function(){this.callBack=null,this.clearColors=null,this.device=null,this.image=null,this.framebuffer=null,this.renderArea=null,this.region=null,this.cmdBuff=null,this.shader=null,this.material.destroy(),this.material=null,this.texture.destroy(),this.texture=null,this.assmebler.destroy(),this.assmebler=null,this.vertexBuffers.destroy(),this.vertexBuffers=null,this.indicesBuffers.destroy(),this.indicesBuffers=null,this.sampler.destroy(),this.sampler=null,this.textImg&&(this.textImg=null,this.textRegion=null,this.textShader=null,this.textMaterial.destroy(),this.textMaterial=null,this.textTexture.destroy(),this.textTexture=null,this.textAssmebler.destroy(),this.textAssmebler=null,this.textVB.destroy(),this.textVB=null,this.textIB.destroy(),this.textIB=null),this.setting=null,t._ins=void 0},j(t,[{key:"splashFinish",set:function(e){this._splashFinish=e,this._tryToStart()}},{key:"loadFinish",set:function(e){this._loadFinish=e,this._tryToStart()}}],[{key:"instance",get:function(){return t._ins||(t._ins=new t),t._ins}}]),t}();ox._ins=void 0,i.internal.SplashScreen=ox;var cx=e("System",function(){function e(){this._id="",this._priority=0,this._executeInEditMode=!1}e.sortByPriority=function(e,t){return e._priority<t._priority?1:e._priority>t.priority?-1:0};var t=e.prototype;return t.init=function(){},t.update=function(){},t.postUpdate=function(){},j(e,[{key:"priority",set:function(e){this._priority=e},get:function(){return this._priority}},{key:"id",set:function(e){this._id=e},get:function(){return this._id}}]),e}()),lx=new Se("Scheduler"),ux=function(e,t,n,i){this.target=void 0,this.priority=void 0,this.paused=void 0,this.markedForDeletion=void 0,this.target=e,this.priority=t,this.paused=n,this.markedForDeletion=i};ux.get=function(e,t,n,i){var r=ux._listEntries.pop();return r?(r.target=e,r.priority=t,r.paused=n,r.markedForDeletion=i):r=new ux(e,t,n,i),r},ux.put=function(e){ux._listEntries.length<20&&(e.target=null,ux._listEntries.push(e))},ux._listEntries=[];var hx=function(e,t,n,i){this.list=void 0,this.entry=void 0,this.target=void 0,this.callback=void 0,this.list=e,this.entry=t,this.target=n,this.callback=i};hx.get=function(e,t,n,i){var r=hx._hashUpdateEntries.pop();return r?(r.list=e,r.entry=t,r.target=n,r.callback=i):r=new hx(e,t,n,i),r},hx.put=function(e){hx._hashUpdateEntries.length<20&&(e.list=e.entry=e.target=e.callback=null,hx._hashUpdateEntries.push(e))},hx._hashUpdateEntries=[];var _x=function(e,t,n,i,r,a){this.timers=void 0,this.target=void 0,this.timerIndex=void 0,this.currentTimer=void 0,this.currentTimerSalvaged=void 0,this.paused=void 0,this.timers=e,this.target=t,this.timerIndex=n,this.currentTimer=i,this.currentTimerSalvaged=r,this.paused=a};_x.get=function(e,t,n,i,r,a){var s=_x._hashTimerEntries.pop();return s?(s.timers=e,s.target=t,s.timerIndex=n,s.currentTimer=i,s.currentTimerSalvaged=r,s.paused=a):s=new _x(e,t,n,i,r,a),s},_x.put=function(e){_x._hashTimerEntries.length<20&&(e.timers=e.target=e.currentTimer=null,_x._hashTimerEntries.push(e))},_x._hashTimerEntries=[];var fx=function(){function e(){this._lock=void 0,this._scheduler=void 0,this._elapsed=void 0,this._runForever=void 0,this._useDelay=void 0,this._timesExecuted=void 0,this._repeat=void 0,this._delay=void 0,this._interval=void 0,this._target=void 0,this._callback=void 0,this._lock=!1,this._scheduler=null,this._elapsed=-1,this._runForever=!1,this._useDelay=!1,this._timesExecuted=0,this._repeat=0,this._delay=0,this._interval=0,this._target=null,this._callback=null}var t=e.prototype;return t.initWithCallback=function(e,t,n,r,a,s){return this._lock=!1,this._scheduler=e,this._target=n,this._callback=t,this._elapsed=-1,this._interval=r,this._delay=s,this._useDelay=this._delay>0,this._repeat=a,this._runForever=this._repeat===i.macro.REPEAT_FOREVER,!0},t.getInterval=function(){return this._interval},t.setInterval=function(e){this._interval=e},t.update=function(e){-1===this._elapsed?(this._elapsed=0,this._timesExecuted=0):(this._elapsed+=e,this._runForever&&!this._useDelay?this._elapsed>=this._interval&&(this.trigger(),this._elapsed=0):(this._useDelay?this._elapsed>=this._delay&&(this.trigger(),this._elapsed-=this._delay,this._timesExecuted+=1,this._useDelay=!1):this._elapsed>=this._interval&&(this.trigger(),this._elapsed=0,this._timesExecuted+=1),this._callback&&!this._runForever&&this._timesExecuted>this._repeat&&this.cancel()))},t.getCallback=function(){return this._callback},t.trigger=function(){this._target&&this._callback&&(this._lock=!0,this._callback.call(this._target,this._elapsed),this._lock=!1)},t.cancel=function(){this._scheduler.unschedule(this._callback,this._target)},e}();fx._timers=[],fx.get=function(){return fx._timers.pop()||new fx},fx.put=function(e){fx._timers.length<20&&!e._lock&&(e._scheduler=e._target=e._callback=null,fx._timers.push(e))};var dx=e("Scheduler",function(e){function t(){var t;return(t=e.call(this)||this)._timeScale=void 0,t._updatesNegList=void 0,t._updates0List=void 0,t._updatesPosList=void 0,t._hashForUpdates=void 0,t._hashForTimers=void 0,t._currentTarget=void 0,t._currentTargetSalvaged=void 0,t._updateHashLocked=void 0,t._arrayForTimers=void 0,t._timeScale=1,t._updatesNegList=[],t._updates0List=[],t._updatesPosList=[],t._hashForUpdates=Pe(!0),t._hashForTimers=Pe(!0),t._currentTarget=null,t._currentTargetSalvaged=!1,t._updateHashLocked=!1,t._arrayForTimers=[],t}X(t,e),t.enableForTarget=function(e){var t=!1;(e.uuid||e.id)&&(t=!0),t||(e.__instanceId?E(1513):e.id=lx.getNewId())};var n=t.prototype;return n.setTimeScale=function(e){this._timeScale=e},n.getTimeScale=function(){return this._timeScale},n.update=function(e){var t,n,i,r,a;for(this._updateHashLocked=!0,1!==this._timeScale&&(e*=this._timeScale),t=0,i=(n=this._updatesNegList).length;t<i;t++)(r=n[t]).paused||r.markedForDeletion||r.target.update(e);for(t=0,i=(n=this._updates0List).length;t<i;t++)(r=n[t]).paused||r.markedForDeletion||r.target.update(e);for(t=0,i=(n=this._updatesPosList).length;t<i;t++)(r=n[t]).paused||r.markedForDeletion||r.target.update(e);var s=this._arrayForTimers;for(t=0;t<s.length;t++){if(a=s[t],this._currentTarget=a,this._currentTargetSalvaged=!1,!a.paused)for(a.timerIndex=0;a.timerIndex<a.timers.length;++a.timerIndex)a.currentTimer=a.timers[a.timerIndex],a.currentTimerSalvaged=!1,a.currentTimer.update(e),a.currentTimer=null;this._currentTargetSalvaged&&0===this._currentTarget.timers.length&&(this._removeHashElement(this._currentTarget),--t)}for(t=0,n=this._updatesNegList;t<n.length;)(r=n[t]).markedForDeletion?this._removeUpdateFromHash(r):t++;for(t=0,n=this._updates0List;t<n.length;)(r=n[t]).markedForDeletion?this._removeUpdateFromHash(r):t++;for(t=0,n=this._updatesPosList;t<n.length;)(r=n[t]).markedForDeletion?this._removeUpdateFromHash(r):t++;this._updateHashLocked=!1,this._currentTarget=null},n.schedule=function(e,t,n,r,a,s){if("function"!=typeof e){var o=e;e=t,t=o}3!==arguments.length&&4!==arguments.length&&5!==arguments.length||(s=!!r,r=i.macro.REPEAT_FOREVER,a=0),R(t,1502);var c=t.uuid||t.id;if(c){var l,u,h=this._hashForTimers[c];if(h?h.paused!==s&&E(1511):(h=_x.get(null,t,0,null,null,s),this._arrayForTimers.push(h),this._hashForTimers[c]=h),null==h.timers)h.timers=[];else for(u=0;u<h.timers.length;++u)if((l=h.timers[u])&&e===l._callback)return y(1507,l.getInterval(),n),void(l._interval=n);(l=fx.get()).initWithCallback(this,e,t,n,r,a),h.timers.push(l),this._currentTarget===h&&this._currentTargetSalvaged&&(this._currentTargetSalvaged=!1)}else A(1510)},n.scheduleUpdate=function(e,t,n){var i=e.uuid||e.id;if(i){var r=this._hashForUpdates[i];if(r&&r.entry){if(r.entry.priority===t)return r.entry.markedForDeletion=!1,void(r.entry.paused=n);if(this._updateHashLocked)return y(1506),r.entry.markedForDeletion=!1,void(r.entry.paused=n);this.unscheduleUpdate(e)}var a,s=ux.get(e,t,n,!1);0===t?(a=this._updates0List,this._appendIn(a,s)):(a=t<0?this._updatesNegList:this._updatesPosList,this._priorityIn(a,s,t)),this._hashForUpdates[i]=hx.get(a,s,e,null)}else A(1510)},n.unschedule=function(e,t){if(t&&e){var n=t.uuid||t.id;if(n){var i=this._hashForTimers[n];if(i)for(var r=i.timers,a=0,s=r.length;a<s;a++){var o=r[a];if(e===o._callback)return o!==i.currentTimer||i.currentTimerSalvaged||(i.currentTimerSalvaged=!0),r.splice(a,1),fx.put(o),i.timerIndex>=a&&i.timerIndex--,void(0===r.length&&(this._currentTarget===i?this._currentTargetSalvaged=!0:this._removeHashElement(i)))}}else A(1510)}},n.unscheduleUpdate=function(e){if(e){var t=e.uuid||e.id;if(t){var n=this._hashForUpdates[t];n&&(this._updateHashLocked?n.entry.markedForDeletion=!0:this._removeUpdateFromHash(n.entry))}else A(1510)}},n.unscheduleAllForTarget=function(e){if(e){var t=e.uuid||e.id;if(t){var n=this._hashForTimers[t];if(n){var i=n.timers;i.indexOf(n.currentTimer)>-1&&!n.currentTimerSalvaged&&(n.currentTimerSalvaged=!0);for(var r=0,a=i.length;r<a;r++)fx.put(i[r]);i.length=0,this._currentTarget===n?this._currentTargetSalvaged=!0:this._removeHashElement(n)}this.unscheduleUpdate(e)}else A(1510)}},n.unscheduleAll=function(){this.unscheduleAllWithMinPriority(i.Scheduler.PRIORITY_SYSTEM)},n.unscheduleAllWithMinPriority=function(e){var t,n,i,r=this._arrayForTimers;for(t=r.length-1;t>=0;t--)n=r[t],this.unscheduleAllForTarget(n.target);var a=0;if(e<0)for(t=0;t<this._updatesNegList.length;)a=this._updatesNegList.length,(i=this._updatesNegList[t])&&i.priority>=e&&this.unscheduleUpdate(i.target),a===this._updatesNegList.length&&t++;if(e<=0)for(t=0;t<this._updates0List.length;)a=this._updates0List.length,(i=this._updates0List[t])&&this.unscheduleUpdate(i.target),a===this._updates0List.length&&t++;for(t=0;t<this._updatesPosList.length;)a=this._updatesPosList.length,(i=this._updatesPosList[t])&&i.priority>=e&&this.unscheduleUpdate(i.target),a===this._updatesPosList.length&&t++},n.isScheduled=function(e,t){R(e,1508),R(t,1509);var n=t.uuid||t.id;if(n){var i=this._hashForTimers[n];if(!i)return!1;if(null==i.timers)return!1;for(var r=i.timers,a=0;a<r.length;++a)if(e===r[a]._callback)return!0;return!1}A(1510)},n.pauseAllTargets=function(){return this.pauseAllTargetsWithMinPriority(i.Scheduler.PRIORITY_SYSTEM)},n.pauseAllTargetsWithMinPriority=function(e){var t,n,i,r,a=[],s=this._arrayForTimers;for(n=0,i=s.length;n<i;n++)(t=s[n])&&(t.paused=!0,a.push(t.target));if(e<0)for(n=0;n<this._updatesNegList.length;n++)(r=this._updatesNegList[n])&&r.priority>=e&&(r.paused=!0,a.push(r.target));if(e<=0)for(n=0;n<this._updates0List.length;n++)(r=this._updates0List[n])&&(r.paused=!0,a.push(r.target));for(n=0;n<this._updatesPosList.length;n++)(r=this._updatesPosList[n])&&r.priority>=e&&(r.paused=!0,a.push(r.target));return a},n.resumeTargets=function(e){if(e)for(var t=0;t<e.length;t++)this.resumeTarget(e[t])},n.pauseTarget=function(e){R(e,1503);var t=e.uuid||e.id;if(t){var n=this._hashForTimers[t];n&&(n.paused=!0);var i=this._hashForUpdates[t];i&&(i.entry.paused=!0)}else A(1510)},n.resumeTarget=function(e){R(e,1504);var t=e.uuid||e.id;if(t){var n=this._hashForTimers[t];n&&(n.paused=!1);var i=this._hashForUpdates[t];i&&(i.entry.paused=!1)}else A(1510)},n.isTargetPaused=function(e){R(e,1505);var t=e.uuid||e.id;if(!t)return A(1510),!1;var n=this._hashForTimers[t];if(n)return n.paused;var i=this._hashForUpdates[t];return!!i&&i.entry.paused},n._removeHashElement=function(e){var t=e.target.uuid||e.target.id;delete this._hashForTimers[t];for(var n=this._arrayForTimers,i=0,r=n.length;i<r;i++)if(n[i]===e){n.splice(i,1);break}_x.put(e)},n._removeUpdateFromHash=function(e){var t=e.target.uuid||e.target.id,n=this._hashForUpdates[t];if(n){for(var i=n.list,r=n.entry,a=0,s=i.length;a<s;a++)if(i[a]===r){i.splice(a,1);break}delete this._hashForUpdates[t],ux.put(r),hx.put(n)}},n._priorityIn=function(e,t,n){for(var i=0;i<e.length;i++)if(n<e[i].priority)return void e.splice(i,0,t);e.push(t)},n._appendIn=function(e,t){e.push(t)},t}(cx));dx.PRIORITY_SYSTEM=1<<31,dx.PRIORITY_NON_SYSTEM=dx.PRIORITY_SYSTEM+1,dx.ID="scheduler",i.Scheduler=dx;var px=function(){function e(){this._title="",this._width=1,this._height=1,this._nativeWidth=1,this._nativeHeight=1,this._renderPass=null,this._colorTextures=[],this._depthStencilTexture=null,this._swapchainBufferIndices=0,this._shouldSyncSizeWithSwapchain=!1,this._poolHandle=0,this._cameras=[]}e.registerCreateFunc=function(t){t._createWindowFun=function(t){return new e(t)}},j(e,[{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"framebuffer",get:function(){return Hi.get(br.get(this._poolHandle,Tr.FRAMEBUFFER))}},{key:"shouldSyncSizeWithSwapchain",get:function(){return this._shouldSyncSizeWithSwapchain}},{key:"hasOnScreenAttachments",get:function(){return 1===br.get(this._poolHandle,Tr.HAS_ON_SCREEN_ATTACHMENTS)}},{key:"hasOffScreenAttachments",get:function(){return 1===br.get(this._poolHandle,Tr.HAS_OFF_SCREEN_ATTACHMENTS)}},{key:"handle",get:function(){return this._poolHandle}},{key:"cameras",get:function(){return this._cameras}}]);var t=e.prototype;return t.initialize=function(e,t){this._poolHandle=br.alloc(),void 0!==t.title&&(this._title=t.title),void 0!==t.swapchainBufferIndices&&(this._swapchainBufferIndices=t.swapchainBufferIndices),void 0!==t.shouldSyncSizeWithSwapchain&&(this._shouldSyncSizeWithSwapchain=t.shouldSyncSizeWithSwapchain),this._width=t.width,this._height=t.height,this._nativeWidth=this._width,this._nativeHeight=this._height;for(var n=t.renderPassInfo,i=n.colorAttachments,r=n.depthStencilAttachment,a=0;a<i.length;a++)i[a].format===za.UNKNOWN&&(i[a].format=e.colorFormat);r&&r.format===za.UNKNOWN&&(r.format=e.depthStencilFormat),this._renderPass=e.createRenderPass(t.renderPassInfo);for(var s=0;s<i.length;s++){var o=null;this._swapchainBufferIndices&1<<s?br.set(this._poolHandle,Tr.HAS_ON_SCREEN_ATTACHMENTS,1):(o=e.createTexture(new xo(es.TEX2D,ts.COLOR_ATTACHMENT|ts.SAMPLED,i[s].format,this._width,this._height)),br.set(this._poolHandle,Tr.HAS_OFF_SCREEN_ATTACHMENTS,1)),this._colorTextures.push(o)}r&&(this._swapchainBufferIndices>=0?(this._depthStencilTexture=e.createTexture(new xo(es.TEX2D,ts.DEPTH_STENCIL_ATTACHMENT|ts.SAMPLED,r.format,this._width,this._height)),br.set(this._poolHandle,Tr.HAS_OFF_SCREEN_ATTACHMENTS,1)):br.set(this._poolHandle,Tr.HAS_ON_SCREEN_ATTACHMENTS,1));var c=Hi.alloc(e,new Us(this._renderPass,this._colorTextures,this._depthStencilTexture));return br.set(this._poolHandle,Tr.FRAMEBUFFER,c),!0},t.destroy=function(){this.clearCameras(),this._depthStencilTexture&&(this._depthStencilTexture.destroy(),this._depthStencilTexture=null);for(var e=0;e<this._colorTextures.length;e++){var t=this._colorTextures[e];t&&t.destroy()}this._colorTextures.length=0,this._poolHandle&&(Hi.get(br.get(this._poolHandle,Tr.FRAMEBUFFER)).destroy(),this._poolHandle=0)},t.resize=function(e,t){if(this._width=e,this._height=t,e>this._nativeWidth||t>this._nativeHeight){this._nativeWidth=e,this._nativeHeight=t;var n=!1;this._depthStencilTexture&&(this._depthStencilTexture.resize(e,t),n=!0);for(var i=0;i<this._colorTextures.length;i++){var r=this._colorTextures[i];r&&(r.resize(e,t),n=!0)}var a=Hi.get(br.get(this._poolHandle,Tr.FRAMEBUFFER));n&&a&&(a.destroy(),a.initialize(new Us(this._renderPass,this._colorTextures,this._depthStencilTexture)))}for(var s,o=Z(this._cameras);!(s=o()).done;){var c=s.value;c.isWindowSize&&c.resize(e,t)}},t.extractRenderCameras=function(){for(var e=[],t=0;t<this._cameras.length;t++){var n=this._cameras[t];n.enabled&&(n.update(),e.push(n))}return e},t.attachCamera=function(e){for(var t=0;t<this._cameras.length;t++)if(this._cameras[t]===e)return;this._cameras.push(e),this.sortCameras()},t.detachCamera=function(e){for(var t=0;t<this._cameras.length;++t)if(this._cameras[t]===e)return void this._cameras.splice(t,1)},t.clearCameras=function(){this._cameras.length=0},t.sortCameras=function(){this._cameras.sort((function(e,t){return e.priority-t.priority}))},e}(),mx=function(){function e(e){var t=this;this._createSceneFun=null,this._createWindowFun=null,this._device=void 0,this._windows=[],this._mainWindow=null,this._curWindow=null,this._tempWindow=null,this._pipeline=null,this._batcher=null,this._dataPoolMgr=void 0,this._scenes=[],this._modelPools=new Map,this._cameraPool=null,this._lightPools=new Map,this._fpsTime=0,this._frameCount=0,this._fps=0,this._fixedFPS=0,this._fixedFPSFrameTime=0,this._poolHandle=0,this._device=e,this._dataPoolMgr=i.internal.DataPoolManager&&new i.internal.DataPoolManager(e),Ku.registerCreateFunc(this),px.registerCreateFunc(this),this._cameraPool=new c_((function(){return new Yu(t._device)}),4)}j(e,[{key:"device",get:function(){return this._device}},{key:"mainWindow",get:function(){return this._mainWindow}},{key:"curWindow",set:function(e){this._curWindow=e},get:function(){return this._curWindow}},{key:"tempWindow",set:function(e){this._tempWindow=e},get:function(){return this._tempWindow}},{key:"windows",get:function(){return this._windows}},{key:"pipeline",get:function(){return this._pipeline}},{key:"batcher2D",get:function(){return this._batcher}},{key:"scenes",get:function(){return this._scenes}},{key:"cumulativeTime",get:function(){return xr.get(this._poolHandle,Sr.CUMULATIVE_TIME)}},{key:"frameTime",get:function(){return xr.get(this._poolHandle,Sr.FRAME_TIME)}},{key:"frameCount",get:function(){return this._frameCount}},{key:"fps",get:function(){return this._fps}},{key:"fixedFPS",set:function(e){e>0?(this._fixedFPS=e,this._fixedFPSFrameTime=1e3/e):this._fixedFPSFrameTime=0},get:function(){return this._fixedFPS}},{key:"dataPoolManager",get:function(){return this._dataPoolMgr}},{key:"handle",get:function(){return this._poolHandle}}]);var t=e.prototype;return t.initialize=function(){var e=this;this._poolHandle=xr.alloc();var t=new uo,n=new ho;n.depthStoreOp=cs.DISCARD,n.stencilStoreOp=cs.DISCARD;var r=new fo([t],n);return this._mainWindow=this.createWindow({title:"rootMainWindow",width:this._device.width,height:this._device.height,renderPassInfo:r,swapchainBufferIndices:-1}),this._curWindow=this._mainWindow,Promise.resolve(Xd.initBuiltinRes(this._device)).then((function(){i.view.on("design-resolution-changed",(function(){var t=i.game.canvas.width,n=i.game.canvas.height;e.resize(t,n)}),e)}))},t.destroy=function(){this.destroyScenes(),this._pipeline&&(this._pipeline.destroy(),this._pipeline=null),this._batcher&&(this._batcher.destroy(),this._batcher=null),this._curWindow=null,this._mainWindow=null,this.dataPoolManager.clear(),this._poolHandle&&(xr.free(this._poolHandle),this._poolHandle=0)},t.resize=function(e,t){this._device.resize(e,t),this._mainWindow.resize(e,t);for(var n,i=Z(this._windows);!(n=i()).done;){var r=n.value;r.shouldSyncSizeWithSwapchain&&r.resize(e,t)}},t.setRenderPipeline=function(e){if(e||(e=this.createDefaultPipeline()),this._pipeline=e,!this._pipeline.activate())return!1;var t=i.director.getScene();return t&&t.globals.activate(),this.onGlobalPipelineStateChanged(),!(!this._batcher&&i.internal.Batcher2D&&(this._batcher=new i.internal.Batcher2D(this),!this._batcher.initialize())&&(this.destroy(),1))},t.createDefaultPipeline=function(){var e=new tE;return e.initialize({flows:[]}),e},t.onGlobalPipelineStateChanged=function(){for(var e=0;e<this._scenes.length;e++)this._scenes[e].onGlobalPipelineStateChanged()},t.activeWindow=function(e){this._curWindow=e},t.resetCumulativeTime=function(){xr.set(this._poolHandle,Sr.CUMULATIVE_TIME,0)},t.frameMove=function(e){var t=this;xr.set(this._poolHandle,Sr.FRAME_TIME,e),++this._frameCount,xr.set(this._poolHandle,Sr.CUMULATIVE_TIME,xr.get(this._poolHandle,Sr.CUMULATIVE_TIME)+e),this._fpsTime+=e,this._fpsTime>1&&(this._fps=this._frameCount,this._frameCount=0,this._fpsTime=0);for(var n=0;n<this._scenes.length;++n)this._scenes[n].removeBatches();this._batcher&&this._batcher.update(),this._pipeline&&function(){t._device.acquire();var e=t._windows,n=t._scenes,r=i.director.getTotalFrames();t._batcher&&t._batcher.uploadBuffers();for(var a=0;a<n.length;a++)n[a].update(r);i.director.emit(i.Director.EVENT_BEFORE_COMMIT);for(var s=[],o=0;o<e.length;o++)e[o].extractRenderCameras().forEach((function(e){s.push(e)}));s.sort((function(e,t){return e.priority-t.priority})),t._pipeline.render(s),t._device.present()}(),this._batcher&&this._batcher.reset()},t.createWindow=function(e){var t=this._createWindowFun(this);return t.initialize(this.device,e),this._windows.push(t),t},t.destroyWindow=function(e){for(var t=0;t<this._windows.length;++t)if(this._windows[t]===e)return e.destroy(),void this._windows.splice(t,1)},t.destroyWindows=function(){for(var e,t=Z(this._windows);!(e=t()).done;)e.value.destroy();this._windows=[]},t.createScene=function(e){var t=this._createSceneFun(this);return t.initialize(e),this._scenes.push(t),t},t.destroyScene=function(e){for(var t=0;t<this._scenes.length;++t)if(this._scenes[t]===e)return e.destroy(),void this._scenes.splice(t,1)},t.destroyScenes=function(){for(var e,t=Z(this._scenes);!(e=t()).done;)e.value.destroy();this._scenes=[]},t.createModel=function(e){var t=this._modelPools.get(e);t||(this._modelPools.set(e,new c_((function(){return new e}),10)),t=this._modelPools.get(e));var n=t.alloc();return n.initialize(),n},t.destroyModel=function(e){var t=this._modelPools.get(e.constructor);t?(t.free(e),e.destroy(),e.scene&&e.scene.removeModel(e)):E(1300,e.constructor.name)},t.createCamera=function(){return this._cameraPool.alloc()},t.createLight=function(e){var t=this._lightPools.get(e);t||(this._lightPools.set(e,new c_((function(){return new e}),4)),t=this._lightPools.get(e));var n=t.alloc();return n.initialize(),n},t.destroyLight=function(e){var t=this._lightPools.get(e.constructor);if(e.destroy(),t&&(t.free(e),e.scene))switch(e.type){case ep.SPHERE:e.scene.removeSphereLight(e);break;case ep.SPOT:e.scene.removeSpotLight(e)}},e}();i.Root=mx;var gx,vx,yx={};se(yx,"vmath",[{name:"vec2",newName:"Vec2",target:ii,targetName:"math"},{name:"vec3",newName:"Vec3",target:ii,targetName:"math"},{name:"vec4",newName:"Vec4",target:ii,targetName:"math"},{name:"quat",newName:"Quat",target:ii,targetName:"math"},{name:"mat3",newName:"Mat3",target:ii,targetName:"math"},{name:"mat4",newName:"Mat4",target:ii,targetName:"math"},{name:"color4",newName:"Color",target:ii,targetName:"math"},{name:"rect",newName:"Rect",target:ii,targetName:"math"},{name:"approx",newName:"approx",target:ii,targetName:"math"},{name:"EPSILON",newName:"EPSILON",target:ii,targetName:"math"},{name:"equals",newName:"equals",target:ii,targetName:"math"},{name:"clamp",newName:"clamp",target:ii,targetName:"math"},{name:"clamp01",newName:"clamp01",target:ii,targetName:"math"},{name:"lerp",newName:"lerp",target:ii,targetName:"math"},{name:"toRadian",newName:"toRadian",target:ii,targetName:"math"},{name:"toDegree",newName:"toDegree",target:ii,targetName:"math"},{name:"random",newName:"random",target:ii,targetName:"math"},{name:"randomRange",newName:"randomRange",target:ii,targetName:"math"},{name:"randomRangeInt",newName:"randomRangeInt",target:ii,targetName:"math"},{name:"pseudoRandom",newName:"pseudoRandom",target:ii,targetName:"math"},{name:"pseudoRandomRangeInt",newName:"pseudoRandomRangeInt",target:ii,targetName:"math"},{name:"nextPow2",newName:"nextPow2",target:ii,targetName:"math"},{name:"repeat",newName:"repeat",target:ii,targetName:"math"},{name:"pingPong",newName:"pingPong",target:ii,targetName:"math"},{name:"inverseLerp",newName:"inverseLerp",target:ii,targetName:"math"}]),i.vmath=yx,se(dx.prototype,"Scheduler.prototype",[{name:"enableForTarget",newName:"enableForTarget",target:dx,targetName:"Scheduler"}]),se(TA.prototype,"EventTouch.prototype",[{name:"getUILocationInView",newName:"getLocationInView",target:TA,targetName:"EventTouch"}]),se(lp.prototype,"SubModel.prototype",[{name:"subMeshData",newName:"subMesh"}]),oe(lp.prototype,"SubModel.prototype",[{name:"getSubModel",suggest:"Use `subModels[i]` instead"},{name:"subModelNum",suggest:"Use `subModels.length` instead"}]),se(mx.prototype,"Root.prototype",[{name:"ui",newName:"batcher2D"}]),oe(of.prototype,"TextureBase.prototype",[{name:"hasPremultipliedAlpha"},{name:"setPremultiplyAlpha"},{name:"setFlipY"}]),se($p.prototype,"RenderTexture.prototype",[{name:"getGFXWindow",customFunction:function(){return this._window}}]);var Sx,Ex=e("BufferAsset",ih("cc.BufferAsset")((J((vx=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._buffer=null,t}return X(t,e),t.prototype.buffer=function(){return this._buffer},j(t,[{key:"_nativeAsset",get:function(){return this._buffer},set:function(e){e instanceof ArrayBuffer?this._buffer=e:this._buffer=e.buffer}}]),t}(I_)).prototype,"_nativeAsset",[Bh],Object.getOwnPropertyDescriptor(vx.prototype,"_nativeAsset"),vx.prototype),gx=vx))||gx);i.BufferAsset=Ex;var Tx=((Sx={})[ps.UNORM]="Uint",Sx[ps.SNORM]="Int",Sx[ps.UINT]="Uint",Sx[ps.INT]="Int",Sx[ps.UFLOAT]="Float",Sx[ps.FLOAT]="Float",Sx.default="Uint",Sx);function Ax(e){return(Tx[e.type]||Tx.default)+e.size/e.count*8}function xx(e,t,n,i,r){void 0===n&&(n=za.R32F),void 0===i&&(i=0),void 0===r&&(r=0);var a=Ts[n];r||(r=a.size);for(var s="set"+Ax(a),o=a.size/a.count,c=Math.floor(t.length/a.count),l=mg.isLittleEndian,u=0;u<c;++u)for(var h=i+r*u,_=0;_<a.count;++_){var f=h+o*_;e[s](f,t[a.count*u+_],l)}}function Cx(e,t,n,i,r,a){void 0===t&&(t=za.R32F),void 0===n&&(n=0),void 0===i&&(i=e.byteLength-n),void 0===r&&(r=0),void 0===a&&(a=[]);var s=Ts[t];r||(r=s.size);for(var o="get"+Ax(s),c=s.size/s.count,l=Math.floor(i/r),u=mg.isLittleEndian,h=0;h<l;++h)for(var _=n+r*h,f=0;f<s.count;++f){var d=_+c*f;a[s.count*h+f]=e[o](d,u)}return a}function Rx(e,t,n,i,r,a,s){void 0===n&&(n=za.R32F),void 0===i&&(i=0),void 0===r&&(r=e.byteLength-i),void 0===a&&(a=0),s||(s=new DataView(e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)));var o=Ts[n];a||(a=o.size);for(var c="set"+Ax(o),l="get"+Ax(o),u=o.size/o.count,h=Math.floor(r/a),_=mg.isLittleEndian,f=0;f<h;++f)for(var d=i+a*f,p=0;p<o.count;++p){var m=d+u*p,g=e[l](m,_);s[c](m,t(g,p,e),_)}return s}var bx,wx,Ix,Ox,Px,Mx,Nx,Dx,Bx,Lx=e("RenderingSubMesh",function(){function e(e,t,n,i,r){void 0===i&&(i=null),void 0===r&&(r=null),this.mesh=void 0,this.subMeshIdx=void 0,this._flatBuffers=[],this._jointMappedBuffers=void 0,this._jointMappedBufferIndices=void 0,this._vertexIdChannel=void 0,this._geometricInfo=void 0,this._vertexBuffers=void 0,this._attributes=void 0,this._indexBuffer=null,this._indirectBuffer=null,this._primitiveMode=void 0,this._iaInfo=void 0,this._handle=0,this._attributes=t,this._vertexBuffers=e,this._indexBuffer=i,this._indirectBuffer=r,this._primitiveMode=n,this._iaInfo=new js(t,e,i,r),this._handle=ea.alloc();var a=qi.alloc();ea.set(this._handle,Kr.FLAT_BUFFER_ARRAY,a)}var t=e.prototype;return t.genFlatBuffers=function(){if(!this._flatBuffers.length&&this.mesh&&void 0!==this.subMeshIdx){var e=this.mesh,t=0,n=e.struct.primitives[this.subMeshIdx],i=ea.get(this._handle,Kr.FLAT_BUFFER_ARRAY);n.indexView&&(t=n.indexView.count);for(var r=0;r<n.vertexBundelIndices.length;r++){var a=n.vertexBundelIndices[r],s=e.struct.vertexBundles[a],o=n.indexView?n.indexView.count:s.view.count,c=s.view.stride,l=c*o,u=new Uint8Array(e.data.buffer,s.view.offset,s.view.length),h=Zi.alloc(n.indexView?l:s.view.length),_=Qr.alloc();Qr.set(_,Xr.STRIDE,c),Qr.set(_,Xr.AMOUNT,o),Qr.set(_,Xr.BUFFER,h),qi.push(i,_);var f=Zi.getBuffer(h),d=new Uint8Array(f);if(n.indexView){for(var p=e.readIndices(this.subMeshIdx),m=0;m<t;++m)for(var g=m*c,v=p[m]*c,y=0;y<c;++y)d[g+y]=u[v+y];this._flatBuffers.push({stride:c,count:o,buffer:d})}else d.set(e.data.subarray(s.view.offset,s.view.offset+s.view.length)),this._flatBuffers.push({stride:c,count:o,buffer:d})}}},t.destroy=function(){for(var e=0;e<this.vertexBuffers.length;e++)this.vertexBuffers[e].destroy();if(this.vertexBuffers.length=0,this._indexBuffer&&(this._indexBuffer.destroy(),this._indexBuffer=null),this._jointMappedBuffers&&this._jointMappedBufferIndices){for(var t=0;t<this._jointMappedBufferIndices.length;t++)this._jointMappedBuffers[this._jointMappedBufferIndices[t]].destroy();this._jointMappedBuffers=void 0,this._jointMappedBufferIndices=void 0}this._indirectBuffer&&(this._indirectBuffer.destroy(),this._indirectBuffer=null),this._handle&&(Li(ea.get(this._handle,Kr.FLAT_BUFFER_ARRAY),qi,Qr),ea.free(this._handle),this._handle=0)},t.enableVertexIdChannel=function(e){if(!this._vertexIdChannel){var t=this.vertexBuffers.length,n=this.attributes.length,i=this._allocVertexIdBuffer(e);this._vertexBuffers.push(i),this._attributes.push(new Ws("a_vertexId",za.R32F,!1,t)),this._iaInfo.attributes=this._attributes,this._iaInfo.vertexBuffers=this._vertexBuffers,this._vertexIdChannel={stream:t,index:n}}},t._allocVertexIdBuffer=function(e){for(var t=0===this.vertexBuffers.length||0===this.vertexBuffers[0].stride?0:this.vertexBuffers[0].size/this.vertexBuffers[0].stride,n=new Float32Array(t),i=0;i<t;++i)n[i]=i+.5;var r=e.createBuffer(new Ps(Ua.VERTEX|Ua.TRANSFER_DST,Ga.DEVICE,n.byteLength,n.BYTES_PER_ELEMENT));return r.update(n),r},j(e,[{key:"attributes",get:function(){return this._attributes}},{key:"vertexBuffers",get:function(){return this._vertexBuffers}},{key:"indexBuffer",get:function(){return this._indexBuffer}},{key:"indirectBuffer",get:function(){return this._indirectBuffer}},{key:"primitiveMode",get:function(){return this._primitiveMode}},{key:"geometricInfo",get:function(){if(this._geometricInfo)return this._geometricInfo;if(void 0===this.mesh)return{positions:new Float32Array,indices:new Uint8Array,boundingBox:{min:bn.ZERO,max:bn.ZERO}};if(void 0===this.subMeshIdx)return{positions:new Float32Array,indices:new Uint8Array,boundingBox:{min:bn.ZERO,max:bn.ZERO}};var e=this.mesh,t=this.subMeshIdx,n=e.readAttribute(t,La.ATTR_POSITION),i=e.readIndices(t),r=new bn,a=new bn,s=this.attributes.find((function(e){return e.name===La.ATTR_POSITION}));if(s){var o=Ts[s.format].count;2===o?(r.set(n[0],n[1],0),a.set(n[0],n[1],0)):(r.set(n[0],n[1],n[2]),a.set(n[0],n[1],n[2]));for(var c=0;c<n.length;c+=o)2===o?(r.x=n[c]>r.x?n[c]:r.x,r.y=n[c+1]>r.y?n[c+1]:r.y,a.x=n[c]<a.x?n[c]:a.x,a.y=n[c+1]<a.y?n[c+1]:a.y):(r.x=n[c]>r.x?n[c]:r.x,r.y=n[c+1]>r.y?n[c+1]:r.y,r.z=n[c+2]>r.z?n[c+2]:r.z,a.x=n[c]<a.x?n[c]:a.x,a.y=n[c+1]<a.y?n[c+1]:a.y,a.z=n[c+2]<a.z?n[c+2]:a.z)}return this._geometricInfo={positions:n,indices:i,boundingBox:{max:r,min:a}},this._geometricInfo}},{key:"flatBuffers",get:function(){return this._flatBuffers}},{key:"jointMappedBuffers",get:function(){var e=this;if(this._jointMappedBuffers)return this._jointMappedBuffers;var t=this._jointMappedBuffers=[],n=this._jointMappedBufferIndices=[];if(!this.mesh||void 0===this.subMeshIdx)return this._jointMappedBuffers=this.vertexBuffers;var r,a,s=this.mesh.struct,o=s.primitives[this.subMeshIdx];if(!s.jointMaps||void 0===o.jointMapIndex||!s.jointMaps[o.jointMapIndex])return this._jointMappedBuffers=this.vertexBuffers;for(var c=i.director.root.device,l=0;l<o.vertexBundelIndices.length;l++){var u=s.vertexBundles[o.vertexBundelIndices[l]];a=0,r=za.UNKNOWN;for(var h=0;h<u.attributes.length;h++){var _=u.attributes[h];if(_.name===La.ATTR_JOINTS){r=_.format;break}a+=Ts[_.format].size}r?function(){var i=new Uint8Array(e.mesh.data.buffer,u.view.offset,u.view.length),h=new DataView(i.slice().buffer),_=s.jointMaps[o.jointMapIndex];Rx(h,(function(e){return _.indexOf(e)}),r,a,u.view.length,u.view.stride,h);var f=c.createBuffer(new Ps(Ua.VERTEX|Ua.TRANSFER_DST,Ga.DEVICE,u.view.length,u.view.stride));f.update(h.buffer),t.push(f),n.push(l)}():t.push(this.vertexBuffers[o.vertexBundelIndices[l]])}return this._vertexIdChannel&&t.push(this._allocVertexIdBuffer(c)),t}},{key:"iaInfo",get:function(){return this._iaInfo}},{key:"handle",get:function(){return this._handle}}]),e}()),Fx=e("SceneAsset",ih("cc.SceneAsset")((Px=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return Q(t=e.call.apply(e,[this].concat(i))||this,"scene",Ix,Y(t)),Q(t,"asyncLoadAssets",Ox,Y(t)),t}return X(t,e),t}(I_),Ix=J((wx=Px).prototype,"scene",[gh,ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Ox=J(wx.prototype,"asyncLoadAssets",[gh,ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),bx=wx))||bx);i.SceneAsset=Fx;var zx,Ux,Gx,kx,Hx=e("TextAsset",ih("cc.TextAsset")((Bx=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return Q(t=e.call.apply(e,[this].concat(i))||this,"text",Dx,Y(t)),t}return X(t,e),t.prototype.toString=function(){return this.text},t}(I_),Dx=J((Nx=Bx).prototype,"text",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),Mx=Nx))||Mx);i.TextAsset=Hx;var Vx=e("JsonAsset",ih("cc.JsonAsset")((kx=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return Q(t=e.call.apply(e,[this].concat(i))||this,"json",Gx,Y(t)),t}return X(t,e),t}(I_),Gx=J((Ux=kx).prototype,"json",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),zx=Ux))||zx);i.JsonAsset=Vx;var Wx,jx,qx,Xx,Yx,Kx,Zx,Qx,Jx,$x=function(){function e(e){this._uiComp=null,this.opacity=1,this._uiTransformComp=null,this._node=void 0,this._node=e}return j(e,[{key:"uiTransformComp",get:function(){return this._uiTransformComp||(this._uiTransformComp=this._node.getComponent("cc.UITransform")),this._uiTransformComp},set:function(e){this._uiTransformComp=e}},{key:"uiComp",get:function(){return this._uiComp},set:function(e){this._uiComp&&e?E(12002):this._uiComp=e}}]),e}(),eC=(__.Flags.Destroying,__.Flags.Destroying),tC=__.Flags.DontDestroy,nC=__.Flags.Deactivating,iC=new Se("Node");function rC(e){return e?"string"==typeof e?nt(e):e:(A(3804),null)}var aC,sC,oC,cC,lC,uC,hC,_C,fC,dC,pC,mC=e("BaseNode",ih("cc.BaseNode")((Jx=Qx=function(e){X(n,e),n._setScene=function(e){e._updateScene()},n._findComponent=function(e,t){var n=t,i=e._components;if(n._sealed)for(var r=0;r<i.length;++r){var a=i[r];if(a.constructor===t)return a}else for(var s=0;s<i.length;++s){var o=i[s];if(o instanceof t)return o}return null},n._findComponents=function(e,t,n){var i=t,r=e._components;if(i._sealed)for(var a=0;a<r.length;++a){var s=r[a];s.constructor===t&&n.push(s)}else for(var o=0;o<r.length;++o){var c=r[o];c instanceof t&&n.push(c)}},n._findChildComponent=function(e,t){for(var i=0;i<e.length;++i){var r=e[i],a=n._findComponent(r,t);if(a)return a;if(r._children.length>0&&(a=n._findChildComponent(r._children,t)))return a}return null},n._findChildComponents=function(e,t,i){for(var r=0;r<e.length;++r){var a=e[r];n._findComponents(a,t,i),a._children.length>0&&n._findChildComponents(a._children,t,i)}};var t=n.prototype;function n(t){var n;return Q(n=e.call(this,t)||this,"_parent",qx,Y(n)),Q(n,"_children",Xx,Y(n)),Q(n,"_active",Yx,Y(n)),Q(n,"_components",Kx,Y(n)),Q(n,"_prefab",Zx,Y(n)),n._scene=null,n._activeInHierarchy=!1,n._id=iC.getNewId(),n._name=void 0,n._eventProcessor=new i.NodeEventProcessor(Y(n)),n._eventMask=0,n._siblingIndex=0,n._registerIfAttached=void 0,n._name=void 0!==t?t:"New Node",n}return t._updateScene=function(){null==this._parent?f("Node %s(%s) has not attached to a scene.",this.name,this.uuid):this._scene=this._parent._scene},j(n,[{key:"components",get:function(){return this._components}},{key:"_persistNode",get:function(){return(this._objFlags&tC)>0},set:function(e){e?this._objFlags|=tC:this._objFlags&=~tC}},{key:"name",get:function(){return this._name},set:function(e){this._name=e}},{key:"uuid",get:function(){return this._id}},{key:"children",get:function(){return this._children}},{key:"active",get:function(){return this._active},set:function(e){if(this._active!==e){this._active=e;var t=this._parent;t&&t._activeInHierarchy&&i.director._nodeActivator.activateNode(this,e)}}},{key:"activeInHierarchy",get:function(){return this._activeInHierarchy}},{key:"parent",get:function(){return this._parent},set:function(e){this.setParent(e)}},{key:"scene",get:function(){return this._scene}},{key:"eventProcessor",get:function(){return this._eventProcessor}}]),t.attr=function(e){He(this,e)},t.getParent=function(){return this._parent},t.setParent=function(e,t){if(void 0===t&&(t=!1),this._parent!==e){var n=this._parent,i=e;if(this._parent=i,this._siblingIndex=0,this._onSetParent(n,t),this.emit&&this.emit(JA.PARENT_CHANGED,n),n&&!(n._objFlags&eC)){var r=n._children.indexOf(this);n._children.splice(r,1),n._updateSiblingIndex(),n.emit&&n.emit(JA.CHILD_REMOVED,this)}i&&(i._children.push(this),this._siblingIndex=i._children.length-1,i.emit&&i.emit(JA.CHILD_ADDED,this)),this._onHierarchyChanged(n)}},t.getChildByUuid=function(e){if(!e)return h("Invalid uuid"),null;for(var t=this._children,n=0,i=t.length;n<i;n++)if(t[n]._id===e)return t[n];return null},t.getChildByName=function(e){if(!e)return h("Invalid name"),null;for(var t=this._children,n=0,i=t.length;n<i;n++)if(t[n]._name===e)return t[n];return null},t.getChildByPath=function(e){for(var t=e.split("/"),n=this,i=function(e){var i=t[e];if(0===i.length)return"continue";var r=n.children.find((function(e){return e.name===i}));if(!r)return{v:null};n=r},r=0;r<t.length;++r){var a=i(r);switch(a){case"continue":continue;default:if("object"==typeof a)return a.v}}return n},t.addChild=function(e){e.setParent(this)},t.insertChild=function(e,t){e.parent=this,e.setSiblingIndex(t)},t.getSiblingIndex=function(){return this._siblingIndex},t.setSiblingIndex=function(e){if(this._parent)if(this._parent._objFlags&nC)A(3821);else{var t=this._parent._children;e=-1!==e?e:t.length-1;var n=t.indexOf(this);e!==n&&(t.splice(n,1),e<t.length?t.splice(e,0,this):t.push(this),this._parent._updateSiblingIndex(),this._onSiblingIndexChanged&&this._onSiblingIndexChanged(e))}},t.walk=function(e,t){var i=1,r=null,a=null,s=0,o=n._stacks[n._stackId];o||(o=[],n._stacks.push(o)),n._stackId++,o.length=0,o[0]=this;for(var c=null,l=!1;i;)if(a=o[--i])if(!l&&e?e(a):l&&t&&t(a),o[i]=null,l){if(c===this._parent)break;if(l=!1,r)if(r[++s])o[i]=r[s],i++;else if(c&&(o[i]=c,i++,l=!0,c._parent?(s=(r=c._parent._children).indexOf(c),c=c._parent):(c=null,r=null),s<0))break}else a._children.length>0?(c=a,r=a._children,s=0,o[i]=r[s],i++):(o[i]=a,i++,l=!0);o.length=0,n._stackId--},t.removeFromParent=function(){this._parent&&this._parent.removeChild(this)},t.removeChild=function(e){this._children.indexOf(e)>-1&&(e.parent=null)},t.removeAllChildren=function(){for(var e=this._children,t=e.length-1;t>=0;t--){var n=e[t];n&&(n.parent=null)}this._children.length=0},t.isChildOf=function(e){var t=this;do{if(t===e)return!0;t=t._parent}while(t);return!1},t.getComponent=function(e){var t=rC(e);return t?n._findComponent(this,t):null},t.getComponents=function(e){var t=rC(e),i=[];return t&&n._findComponents(this,t,i),i},t.getComponentInChildren=function(e){var t=rC(e);return t?n._findChildComponent(this._children,t):null},t.getComponentsInChildren=function(e){var t=rC(e),i=[];return t&&(n._findComponents(this,t,i),n._findChildComponents(this._children,t,i)),i},t.addComponent=function(e){var t;if("string"==typeof e){if(!(t=nt(e)))throw i._RF.peek()&&A(3808,e),TypeError(b(3807,e))}else{if(!e)throw TypeError(b(3804));t=e}if("function"!=typeof t)throw TypeError(b(3809));if(!je(t,i.Component))throw TypeError(b(3810));var n=t._requireComponent;n&&!this.getComponent(n)&&this.addComponent(n);var r=new t;return r.node=this,this._components.push(r),this._activeInHierarchy&&i.director._nodeActivator.activateComp(r),r},t.removeComponent=function(e){if(e){var t=null;(t=e instanceof Kf?e:this.getComponent(e))&&t.destroy()}else A(3813)},t.on=function(e,t,n,i){switch(void 0===i&&(i=!1),e){case JA.TRANSFORM_CHANGED:this._eventMask|=1}this._eventProcessor.on(e,t,n,i)},t.off=function(e,t,n,i){if(void 0===i&&(i=!1),this._eventProcessor.off(e,t,n,i),!this._eventProcessor.hasEventListener(e))switch(e){case JA.TRANSFORM_CHANGED:this._eventMask&=-2}},t.once=function(e,t,n,i){this._eventProcessor.once(e,t,n,i)},t.emit=function(e,t,n,i,r,a){this._eventProcessor.emit(e,t,n,i,r,a)},t.dispatchEvent=function(e){this._eventProcessor.dispatchEvent(e)},t.hasEventListener=function(e,t,n){return this._eventProcessor.hasEventListener(e,t,n)},t.targetOff=function(e){this._eventProcessor.targetOff(e),1&this._eventMask&&!this._eventProcessor.hasEventListener(JA.TRANSFORM_CHANGED)&&(this._eventMask&=-2)},t.destroy=function(){return!!e.prototype.destroy.call(this)&&(this.active=!1,!0)},t.destroyAllChildren=function(){for(var e=this._children,t=0;t<e.length;++t)e[t].destroy()},t._removeComponent=function(e){if(e){if(!(this._objFlags&eC)){var t=this._components.indexOf(e);-1!==t?this._components.splice(t,1):e.node!==this&&A(3815)}}else A(3814)},t._updateSiblingIndex=function(){for(var e=0;e<this._children.length;++e)this._children[e]._siblingIndex=e;this.emit(JA.SIBLING_ORDER_CHANGED)},t._onSetParent=function(e){this._parent&&(null!=e&&e._scene===this._parent._scene||null==this._parent._scene||this.walk(n._setScene))},t._onPostActivated=function(){},t._onBatchCreated=function(){this._parent&&(this._siblingIndex=this._parent.children.indexOf(this))},t._onPreDestroy=function(){this._onPreDestroyBase()},t._onHierarchyChanged=function(e){return this._onHierarchyChangedBase(e)},t._instantiate=function(e,t){return e||(e=i.instantiate._clone(this,this)),e._prefab,e._parent=null,e._onBatchCreated(t),e},t._onHierarchyChangedBase=function(){var e=this._parent;!this._persistNode||e instanceof i.Scene||i.game.removePersistRootNode(this);var t=this._active&&!(!e||!e._activeInHierarchy);this._activeInHierarchy!==t&&i.director._nodeActivator.activateNode(this,t)},t._onPreDestroyBase=function(){this._objFlags|=eC;var e=this._parent,t=!!e&&0!=(e._objFlags&eC);if(this._persistNode&&i.game.removePersistRootNode(this),!t&&e){this.emit(JA.PARENT_CHANGED,this);var n=e._children.indexOf(this);e._children.splice(n,1),this._siblingIndex=0,e._updateSiblingIndex(),e.emit&&e.emit(JA.CHILD_REMOVED,this)}this.emit(JA.NODE_DESTROYED,this),this._eventProcessor.destroy();for(var r=this._children,a=0;a<r.length;++a)r[a]._destroyImmediate();for(var s=this._components,o=0;o<s.length;++o)s[o]._destroyImmediate();return t},n}(__),Qx.idGenerator=iC,Qx._stacks=[[]],Qx._stackId=0,J((jx=Jx).prototype,"_persistNode",[oh],Object.getOwnPropertyDescriptor(jx.prototype,"_persistNode"),jx.prototype),J(jx.prototype,"name",[gh],Object.getOwnPropertyDescriptor(jx.prototype,"name"),jx.prototype),J(jx.prototype,"children",[gh],Object.getOwnPropertyDescriptor(jx.prototype,"children"),jx.prototype),J(jx.prototype,"active",[gh],Object.getOwnPropertyDescriptor(jx.prototype,"active"),jx.prototype),J(jx.prototype,"activeInHierarchy",[gh],Object.getOwnPropertyDescriptor(jx.prototype,"activeInHierarchy"),jx.prototype),J(jx.prototype,"parent",[gh],Object.getOwnPropertyDescriptor(jx.prototype,"parent"),jx.prototype),qx=J(jx.prototype,"_parent",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Xx=J(jx.prototype,"_children",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Yx=J(jx.prototype,"_active",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Kx=J(jx.prototype,"_components",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Zx=J(jx.prototype,"_prefab",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Wx=jx))||Wx);i._BaseNode=mC;var gC=new bn,vC=new Dn,yC=new Dn,SC=new Array(10),EC=new Dn,TC=new Pn,AC=new Pn,xC=new Hn,CC=new Map,RC=e("Node",(aC=ih("cc.Node"),sC=Dh(bn),aC((pC=dC=function(e){function t(t){var n;return(n=e.call(this,t)||this)._uiProps=new $x(Y(n)),n._static=!1,n._pos=new bn,n._rot=new Dn,n._scale=new bn(1,1,1),n._mat=new Hn,Q(n,"_lpos",lC,Y(n)),Q(n,"_lrot",uC,Y(n)),Q(n,"_lscale",hC,Y(n)),Q(n,"_layer",_C,Y(n)),Q(n,"_euler",fC,Y(n)),n._dirtyFlags=Uu.NONE,n._eulerDirty=!1,n._poolHandle=0,n._poolHandle=Er.alloc(),Er.set(n._poolHandle,mr.LAYER,n._layer),n}X(t,e),t.isNode=function(e){return e instanceof t&&(e.constructor===t||!(e instanceof i.Scene))};var n=t.prototype;return n.destroy=function(){return this._poolHandle&&(Er.free(this._poolHandle),this._poolHandle=0),e.prototype.destroy.call(this)},n.setParent=function(t,n){void 0===n&&(n=!1),n&&this.updateWorldTransform(),e.prototype.setParent.call(this,t,n)},n._onSetParent=function(t,n){if(e.prototype._onSetParent.call(this,t,n),n){var i=this._parent;i?(i.updateWorldTransform(),Hn.multiply(xC,Hn.invert(xC,i._mat),this._mat),Hn.toRTS(xC,this._lrot,this._lpos,this._lscale)):(bn.copy(this._lpos,this._pos),Dn.copy(this._lrot,this._rot),bn.copy(this._lscale,this._scale)),this._eulerDirty=!0}this.invalidateChildren(Uu.TRS)},n._onBatchCreated=function(t){var n;e.prototype._onBatchCreated.call(this,t),Er.set(this._poolHandle,mr.LAYER,this._layer),Er.setVec3(this._poolHandle,mr.WORLD_SCALE,this._scale);var i=null===(n=this._prefab)||void 0===n?void 0:n.instance;!t&&i&&XT(this),this.hasChangedFlags=Uu.TRS,this._dirtyFlags=Uu.TRS;for(var r=this._children.length,a=0;a<r;++a)this._children[a]._onBatchCreated(t);if(!t&&i){var s={};i.targetMap=s,YT(this,s,!0),ZT(0,i.mountedChildren,s),QT(0,i.propertyOverrides,s)}JT(this)},n._onBeforeSerialize=function(){this.eulerAngles},n._onPostActivated=function(e){e?(BA.resumeTarget(this),this.eventProcessor.reattach(),this.invalidateChildren(Uu.TRS)):BA.pauseTarget(this)},n.translate=function(e,t){var n=t||zu.LOCAL;if(n===zu.LOCAL)bn.transformQuat(gC,e,this._lrot),this._lpos.x+=gC.x,this._lpos.y+=gC.y,this._lpos.z+=gC.z;else if(n===zu.WORLD)if(this._parent){Dn.invert(vC,this._parent.worldRotation),bn.transformQuat(gC,e,vC);var i=this.worldScale;this._lpos.x+=gC.x/i.x,this._lpos.y+=gC.y/i.y,this._lpos.z+=gC.z/i.z}else this._lpos.x+=e.x,this._lpos.y+=e.y,this._lpos.z+=e.z;this.invalidateChildren(Uu.POSITION),1&this._eventMask&&this.emit(JA.TRANSFORM_CHANGED,Uu.POSITION)},n.rotate=function(e,t){var n=t||zu.LOCAL;if(Dn.normalize(vC,e),n===zu.LOCAL)Dn.multiply(this._lrot,this._lrot,vC);else if(n===zu.WORLD){var i=this.worldRotation;Dn.multiply(yC,vC,i),Dn.invert(vC,i),Dn.multiply(yC,vC,yC),Dn.multiply(this._lrot,this._lrot,yC)}this._eulerDirty=!0,this.invalidateChildren(Uu.ROTATION),1&this._eventMask&&this.emit(JA.TRANSFORM_CHANGED,Uu.ROTATION)},n.lookAt=function(e,t){this.getWorldPosition(gC),bn.subtract(gC,gC,e),bn.normalize(gC,gC),Dn.fromViewUp(vC,gC,t),this.setWorldRotation(vC)},n.invalidateChildren=function(e){var t=this.hasChangedFlags;if((this._dirtyFlags&t&e)!==e){this._dirtyFlags|=e,this.hasChangedFlags=t|e;for(var n=e|Uu.POSITION,i=this._children.length,r=0;r<i;++r){var a=this._children[r];a.isValid&&a.invalidateChildren(n)}}},n.updateWorldTransform=function(){if(this._dirtyFlags){for(var e,t=this,n=0;t&&t._dirtyFlags;)SC[n++]=t,t=t._parent;for(var i=0;n;)i|=(e=SC[--n])._dirtyFlags,t?(i&Uu.POSITION&&(bn.transformMat4(e._pos,e._lpos,t._mat),e._mat.m12=e._pos.x,e._mat.m13=e._pos.y,e._mat.m14=e._pos.z,Er.setVec3(e._poolHandle,mr.WORLD_POSITION,e._pos)),i&Uu.RS&&(Hn.fromRTS(e._mat,e._lrot,e._lpos,e._lscale),Hn.multiply(e._mat,t._mat,e._mat),i&Uu.ROTATION&&(Dn.multiply(e._rot,t._rot,e._lrot),Er.setVec4(e._poolHandle,mr.WORLD_ROTATION,e._rot)),Pn.fromQuat(TC,Dn.conjugate(EC,e._rot)),Pn.multiplyMat4(TC,TC,e._mat),e._scale.x=TC.m00,e._scale.y=TC.m04,e._scale.z=TC.m08,Er.setVec3(e._poolHandle,mr.WORLD_SCALE,e._scale))):(i&Uu.POSITION&&(bn.copy(e._pos,e._lpos),e._mat.m12=e._pos.x,e._mat.m13=e._pos.y,e._mat.m14=e._pos.z,Er.setVec3(e._poolHandle,mr.WORLD_POSITION,e._pos)),i&Uu.RS&&(i&Uu.ROTATION&&(Dn.copy(e._rot,e._lrot),Er.setVec4(e._poolHandle,mr.WORLD_ROTATION,e._rot)),i&Uu.SCALE&&(bn.copy(e._scale,e._lscale),Er.setVec3(e._poolHandle,mr.WORLD_SCALE,e._scale),Hn.fromRTS(e._mat,e._rot,e._pos,e._scale)))),i!==Uu.NONE&&Er.setMat4(e._poolHandle,mr.WORLD_MATRIX,e._mat),e._dirtyFlags=Uu.NONE,t=e}},n.setPosition=function(e,t,n){void 0===t&&void 0===n?bn.copy(this._lpos,e):void 0===n?bn.set(this._lpos,e,t,this._lpos.z):bn.set(this._lpos,e,t,n),this.invalidateChildren(Uu.POSITION),1&this._eventMask&&this.emit(JA.TRANSFORM_CHANGED,Uu.POSITION)},n.getPosition=function(e){return e?bn.set(e,this._lpos.x,this._lpos.y,this._lpos.z):bn.copy(new bn,this._lpos)},n.setRotation=function(e,t,n,i){void 0===t||void 0===n||void 0===i?Dn.copy(this._lrot,e):Dn.set(this._lrot,e,t,n,i),this._eulerDirty=!0,this.invalidateChildren(Uu.ROTATION),1&this._eventMask&&this.emit(JA.TRANSFORM_CHANGED,Uu.ROTATION)},n.setRotationFromEuler=function(e,t,n){var i=void 0===n?this._euler.z:n;void 0===t?(bn.copy(this._euler,e),Dn.fromEuler(this._lrot,e.x,e.y,e.z)):(bn.set(this._euler,e,t,i),Dn.fromEuler(this._lrot,e,t,i)),this._eulerDirty=!1,this.invalidateChildren(Uu.ROTATION),1&this._eventMask&&this.emit(JA.TRANSFORM_CHANGED,Uu.ROTATION)},n.getRotation=function(e){return e?Dn.set(e,this._lrot.x,this._lrot.y,this._lrot.z,this._lrot.w):Dn.copy(new Dn,this._lrot)},n.setScale=function(e,t,n){void 0===t&&void 0===n?bn.copy(this._lscale,e):void 0===n?bn.set(this._lscale,e,t,this._lscale.z):bn.set(this._lscale,e,t,n),this.invalidateChildren(Uu.SCALE),1&this._eventMask&&this.emit(JA.TRANSFORM_CHANGED,Uu.SCALE)},n.getScale=function(e){return e?bn.set(e,this._lscale.x,this._lscale.y,this._lscale.z):bn.copy(new bn,this._lscale)},n.inverseTransformPoint=function(e,t){bn.copy(e,t);for(var n=this,i=0;n._parent;)SC[i++]=n,n=n._parent;for(;i>=0;)bn.transformInverseRTS(e,e,n._lrot,n._lpos,n._lscale),n=SC[--i];return e},n.setWorldPosition=function(e,t,n){void 0===t||void 0===n?bn.copy(this._pos,e):bn.set(this._pos,e,t,n),Er.setVec3(this._poolHandle,mr.WORLD_POSITION,this._pos);var i=this._parent,r=this._lpos;i?(i.updateWorldTransform(),bn.transformMat4(r,this._pos,Hn.invert(xC,i._mat))):bn.copy(r,this._pos),this.invalidateChildren(Uu.POSITION),1&this._eventMask&&this.emit(JA.TRANSFORM_CHANGED,Uu.POSITION)},n.getWorldPosition=function(e){return this.updateWorldTransform(),e?bn.copy(e,this._pos):bn.copy(new bn,this._pos)},n.setWorldRotation=function(e,t,n,i){void 0===t||void 0===n||void 0===i?Dn.copy(this._rot,e):Dn.set(this._rot,e,t,n,i),Er.setVec4(this._poolHandle,mr.WORLD_ROTATION,this._rot),this._parent?(this._parent.updateWorldTransform(),Dn.multiply(this._lrot,Dn.conjugate(this._lrot,this._parent._rot),this._rot)):Dn.copy(this._lrot,this._rot),this._eulerDirty=!0,this.invalidateChildren(Uu.ROTATION),1&this._eventMask&&this.emit(JA.TRANSFORM_CHANGED,Uu.ROTATION)},n.setWorldRotationFromEuler=function(e,t,n){Dn.fromEuler(this._rot,e,t,n),this._parent?(this._parent.updateWorldTransform(),Dn.multiply(this._lrot,Dn.conjugate(this._lrot,this._parent._rot),this._rot)):Dn.copy(this._lrot,this._rot),this._eulerDirty=!0,this.invalidateChildren(Uu.ROTATION),1&this._eventMask&&this.emit(JA.TRANSFORM_CHANGED,Uu.ROTATION)},n.getWorldRotation=function(e){return this.updateWorldTransform(),e?Dn.copy(e,this._rot):Dn.copy(new Dn,this._rot)},n.setWorldScale=function(e,t,n){void 0===t||void 0===n?bn.copy(this._scale,e):bn.set(this._scale,e,t,n),Er.setVec3(this._poolHandle,mr.WORLD_SCALE,this._scale);var i=this._parent;i?(i.updateWorldTransform(),Pn.fromQuat(TC,Dn.conjugate(EC,i._rot)),Pn.multiplyMat4(TC,TC,i._mat),AC.m00=this._scale.x,AC.m04=this._scale.y,AC.m08=this._scale.z,Pn.multiply(TC,AC,Pn.invert(TC,TC)),this._lscale.x=bn.set(gC,TC.m00,TC.m01,TC.m02).length(),this._lscale.y=bn.set(gC,TC.m03,TC.m04,TC.m05).length(),this._lscale.z=bn.set(gC,TC.m06,TC.m07,TC.m08).length()):bn.copy(this._lscale,this._scale),this.invalidateChildren(Uu.SCALE),1&this._eventMask&&this.emit(JA.TRANSFORM_CHANGED,Uu.SCALE)},n.getWorldScale=function(e){return this.updateWorldTransform(),e?bn.copy(e,this._scale):bn.copy(new bn,this._scale)},n.getWorldMatrix=function(e){this.updateWorldTransform();var t=e||new Hn;return Hn.copy(t,this._mat)},n.getWorldRS=function(e){this.updateWorldTransform();var t=e||new Hn;return Hn.copy(t,this._mat),t.m12=0,t.m13=0,t.m14=0,t},n.getWorldRT=function(e){this.updateWorldTransform();var t=e||new Hn;return Hn.fromRT(t,this._rot,this._pos)},n.setRTS=function(e,t,n){var i=0;e&&(i|=Uu.ROTATION,void 0!==e.w?(Dn.copy(this._lrot,e),this._eulerDirty=!0):(bn.copy(this._euler,e),Dn.fromEuler(this._lrot,e.x,e.y,e.z),this._eulerDirty=!1)),t&&(bn.copy(this._lpos,t),i|=Uu.POSITION),n&&(bn.copy(this._lscale,n),i|=Uu.SCALE),i&&(this.invalidateChildren(i),1&this._eventMask&&this.emit(JA.TRANSFORM_CHANGED,i))},n.pauseSystemEvents=function(e){BA.pauseTarget(this,e)},n.resumeSystemEvents=function(e){BA.resumeTarget(this,e)},j(t,[{key:"handle",get:function(){return this._poolHandle}},{key:"position",get:function(){return this._lpos},set:function(e){this.setPosition(e)}},{key:"worldPosition",get:function(){return this.updateWorldTransform(),this._pos},set:function(e){this.setWorldPosition(e)}},{key:"rotation",get:function(){return this._lrot},set:function(e){this.setRotation(e)}},{key:"eulerAngles",set:function(e){this.setRotationFromEuler(e.x,e.y,e.z)},get:function(){return this._eulerDirty&&(Dn.toEuler(this._euler,this._lrot),this._eulerDirty=!1),this._euler}},{key:"angle",get:function(){return this._euler.z},set:function(e){bn.set(this._euler,0,0,e),Dn.fromAngleZ(this._lrot,e),this._eulerDirty=!1,this.invalidateChildren(Uu.ROTATION),1&this._eventMask&&this.emit(JA.TRANSFORM_CHANGED,Uu.ROTATION)}},{key:"worldRotation",get:function(){return this.updateWorldTransform(),this._rot},set:function(e){this.setWorldRotation(e)}},{key:"scale",get:function(){return this._lscale},set:function(e){this.setScale(e)}},{key:"worldScale",get:function(){return this.updateWorldTransform(),this._scale},set:function(e){this.setWorldScale(e)}},{key:"matrix",set:function(e){Hn.toRTS(e,this._lrot,this._lpos,this._lscale),this.invalidateChildren(Uu.TRS),this._eulerDirty=!0,1&this._eventMask&&this.emit(JA.TRANSFORM_CHANGED,Uu.TRS)}},{key:"worldMatrix",get:function(){return this.updateWorldTransform(),this._mat}},{key:"forward",get:function(){return bn.transformQuat(new bn,bn.FORWARD,this.worldRotation)},set:function(e){var t=e.length();bn.multiplyScalar(gC,e,-1/t),Dn.fromViewUp(vC,gC),this.setWorldRotation(vC)}},{key:"layer",set:function(e){this._layer=e,Er.set(this._poolHandle,mr.LAYER,this._layer),this.emit(JA.LAYER_CHANGED,this._layer)},get:function(){return this._layer}},{key:"hasChangedFlags",get:function(){return CC.get(this)||0},set:function(e){CC.set(this,e),Er.set(this._poolHandle,mr.FLAGS_CHANGED,e)}}]),t}(mC),dC.bookOfChange=CC,dC.EventType=JA,dC.NodeSpace=zu,dC.TransformDirtyBit=Uu,dC.TransformBit=Uu,lC=J((cC=pC).prototype,"_lpos",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new bn}}),uC=J(cC.prototype,"_lrot",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Dn}}),hC=J(cC.prototype,"_lscale",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new bn(1,1,1)}}),_C=J(cC.prototype,"_layer",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Ll.Enum.DEFAULT}}),fC=J(cC.prototype,"_euler",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new bn}}),J(cC.prototype,"eulerAngles",[sC],Object.getOwnPropertyDescriptor(cC.prototype,"eulerAngles"),cC.prototype),J(cC.prototype,"angle",[gh],Object.getOwnPropertyDescriptor(cC.prototype,"angle"),cC.prototype),J(cC.prototype,"layer",[gh],Object.getOwnPropertyDescriptor(cC.prototype,"layer"),cC.prototype),oC=cC))||oC));i.Node=RC;var bC=new Array(16),wC=null,IC=new qn,OC=[JA.TOUCH_START.toString(),JA.TOUCH_MOVE.toString(),JA.TOUCH_END.toString(),JA.TOUCH_CANCEL.toString()],PC=[JA.MOUSE_DOWN.toString(),JA.MOUSE_ENTER.toString(),JA.MOUSE_MOVE.toString(),JA.MOUSE_LEAVE.toString(),JA.MOUSE_UP.toString(),JA.MOUSE_WHEEL.toString()];function MC(e,t){var n=this.owner;return!(!n||!n._uiProps.uiTransformComp||(e.getUILocation(IC),!n._uiProps.uiTransformComp.isHit(IC,this)||(t.type=JA.TOUCH_START.toString(),t.touch=e,t.bubbles=!0,n.dispatchEvent(t),0)))}function NC(e,t){var n=this.owner;return!(!n||!n._uiProps.uiTransformComp||(t.type=JA.TOUCH_MOVE.toString(),t.touch=e,t.bubbles=!0,n.dispatchEvent(t),0))}function DC(e,t){var n=this.owner;n&&n._uiProps.uiTransformComp&&(e.getUILocation(IC),n._uiProps.uiTransformComp.isHit(IC,this)?t.type=JA.TOUCH_END.toString():t.type=JA.TOUCH_CANCEL.toString(),t.touch=e,t.bubbles=!0,n.dispatchEvent(t))}function BC(e,t){var n=this.owner;n&&n._uiProps.uiTransformComp&&(t.type=JA.TOUCH_CANCEL.toString(),t.touch=e,t.bubbles=!0,n.dispatchEvent(t))}function LC(e){var t=this.owner;t&&t._uiProps.uiTransformComp&&(IC=e.getUILocation(),t._uiProps.uiTransformComp.isHit(IC,this)&&(e.type=JA.MOUSE_DOWN.toString(),e.bubbles=!0,t.dispatchEvent(e)))}function FC(e){var t=this.owner;if(t&&t._uiProps.uiTransformComp){if(IC=e.getUILocation(),t._uiProps.uiTransformComp.isHit(IC,this))this._previousIn||(wC&&wC.eventProcessor.mouseListener&&(e.type=JA.MOUSE_LEAVE,wC.dispatchEvent(e),wC.eventProcessor.mouseListener&&(wC.eventProcessor.mouseListener._previousIn=!1)),wC=t,e.type=JA.MOUSE_ENTER.toString(),t.dispatchEvent(e),this._previousIn=!0),e.type=JA.MOUSE_MOVE.toString(),e.bubbles=!0,t.dispatchEvent(e);else{if(!this._previousIn)return;e.type=JA.MOUSE_LEAVE.toString(),t.dispatchEvent(e),this._previousIn=!1,wC=null}e.propagationStopped=!0}}function zC(e){var t=this.owner;t&&t._uiProps.uiTransformComp&&(IC=e.getUILocation(),t._uiProps.uiTransformComp.isHit(IC,this)&&(e.type=JA.MOUSE_UP.toString(),e.bubbles=!0,t.dispatchEvent(e),e.propagationStopped=!0))}function UC(e){var t=this.owner;t&&t._uiProps.uiTransformComp&&(IC=e.getUILocation(),t._uiProps.uiTransformComp.isHit(IC,this)&&(e.type=JA.MOUSE_WHEEL.toString(),e.bubbles=!0,t.dispatchEvent(e),e.propagationStopped=!0))}function GC(e,t){if(t){for(var n=0,i=[],r=e;r&&RC.isNode(r);r=r.parent,++n){var a=r.getComponent(t);if(a){var s={index:n,comp:a};i?i.push(s):i=[s]}}return i.length>0?i:null}return null}function kC(e,t){if(!e._persistNode){if(e.eventProcessor.bubblingTargets)for(var n=0;n<t.length;++n)if(e.eventProcessor.bubblingTargets.hasEventListener(t[n]))return!0;if(e.eventProcessor.capturingTargets)for(var i=0;i<t.length;++i)if(e.eventProcessor.capturingTargets.hasEventListener(t[i]))return!0;return!1}return!0}var HC,VC,WC,jC,qC,XC,YC,KC,ZC,QC,JC,$C,eR,tR,nR,iR,rR,aR,sR,oR,cR,lR,uR,hR,_R,fR,dR,pR,mR,gR,vR,yR,SR,ER,TR,AR,xR,CR,RR,bR,wR,IR,OR,PR,MR,NR,DR,BR,LR,FR,zR,UR,GR,kR,HR,VR,WR,jR,qR,XR,YR,KR,ZR,QR,JR,$R,eb,tb,nb,ib,rb,ab,sb,ob,cb,lb,ub,hb,_b,fb,db,pb,mb,gb,vb,yb,Sb,Eb,Tb,Ab,xb,Cb,Rb,bb,wb,Ib,Ob,Pb,Mb,Nb,Db,Bb,Lb,Fb,zb,Ub,Gb,kb=function(){function e(e){this.bubblingTargets=null,this.capturingTargets=null,this.touchListener=null,this.mouseListener=null,this._node=void 0,this._comp=null,this._node=e}j(e,[{key:"node",get:function(){return this._node}}]);var t=e.prototype;return t.reattach=function(){if(this._comp)if(this.touchListener){var e=this.touchListener.mask=GC(this._node,this._comp);this.mouseListener&&(this.mouseListener.mask=e)}else this.mouseListener&&(this.mouseListener.mask=GC(this._node,this._comp))},t.registerComponentHitList=function(e){this._comp=e},t.destroy=function(){wC===this._node&&(wC=null),(this.touchListener||this.mouseListener)&&(BA.removeListeners(this._node),this.touchListener&&(this.touchListener.owner=null,this.touchListener.mask=null,this.touchListener=null),this.mouseListener&&(this.mouseListener.owner=null,this.mouseListener.mask=null,this.mouseListener=null)),this.capturingTargets&&this.capturingTargets.clear(),this.bubblingTargets&&this.bubblingTargets.clear()},t.on=function(e,t,n,i){return this._checknSetupSysEvent(e)?this._onDispatch(e,t,n,i):(this.bubblingTargets||(this.bubblingTargets=new E_),this.bubblingTargets.on(e,t,n))},t.once=function(e,t,n,i){var r,a=this;(r=this._checknSetupSysEvent(e)&&i?this.capturingTargets=this.capturingTargets||new E_:this.bubblingTargets=this.bubblingTargets||new E_).on(e,t,n,!0),r.on(e,(function(){a.off(e,t,n)}),void 0,!0)},t.off=function(e,t,n,i){var r=-1!==OC.indexOf(e),a=!r&&-1!==PC.indexOf(e);r||a?(this._offDispatch(e,t,n,i),r?this.touchListener&&!kC(this._node,OC)&&(BA.removeListener(this.touchListener),this.touchListener=null):a&&this.mouseListener&&!kC(this._node,PC)&&(BA.removeListener(this.mouseListener),this.mouseListener=null)):this.bubblingTargets&&this.bubblingTargets.off(e,t,n)},t.emit=function(e,t,n,i,r,a){this.bubblingTargets&&this.bubblingTargets.emit(e,t,n,i,r,a)},t.dispatchEvent=function(e){!function(e,t){var n,i=0;for(t.target=e,bC.length=0,e.eventProcessor.getCapturingTargets(t.type,bC),t.eventPhase=1,i=bC.length-1;i>=0;--i)if((n=bC[i]).eventProcessor.capturingTargets&&(t.currentTarget=n,n.eventProcessor.capturingTargets.emit(t.type,t,bC),t.propagationStopped))return void(bC.length=0);if(bC.length=0,t.eventPhase=2,t.currentTarget=e,e.eventProcessor.capturingTargets&&e.eventProcessor.capturingTargets.emit(t.type,t),!t.propagationImmediateStopped&&e.eventProcessor.bubblingTargets&&e.eventProcessor.bubblingTargets.emit(t.type,t),!t.propagationStopped&&t.bubbles)for(e.eventProcessor.getBubblingTargets(t.type,bC),t.eventPhase=3,i=0;i<bC.length;++i)if((n=bC[i]).eventProcessor.bubblingTargets&&(t.currentTarget=n,n.eventProcessor.bubblingTargets.emit(t.type,t),t.propagationStopped))return void(bC.length=0);bC.length=0}(this._node,e),bC.length=0},t.hasEventListener=function(e,t,n){var i=!1;return this.bubblingTargets&&(i=this.bubblingTargets.hasEventListener(e,t,n)),!i&&this.capturingTargets&&(i=this.capturingTargets.hasEventListener(e,t,n)),i},t.targetOff=function(e){this.capturingTargets&&this.capturingTargets.removeAll(e),this.bubblingTargets&&this.bubblingTargets.removeAll(e),this.touchListener&&!kC(this.node,OC)&&(BA.removeListener(this.touchListener),this.touchListener=null),this.mouseListener&&!kC(this.node,PC)&&(BA.removeListener(this.mouseListener),this.mouseListener=null)},t.getCapturingTargets=function(e,t){for(var n=this._node.parent;n;)n.eventProcessor.capturingTargets&&n.eventProcessor.capturingTargets.hasEventListener(e)&&t.push(n),n=n.parent},t.getBubblingTargets=function(e,t){for(var n=this._node.parent;n;)n.eventProcessor.bubblingTargets&&n.eventProcessor.bubblingTargets.hasEventListener(e)&&t.push(n),n=n.parent},t._checknSetupSysEvent=function(e){var t=this,n=!1,r=!1;return-1!==OC.indexOf(e)?(this.touchListener||(this.touchListener=i.EventListener.create({event:i.EventListener.TOUCH_ONE_BY_ONE,swallowTouches:!0,owner:this._node,mask:GC(this._node,this._comp),onTouchBegan:MC,onTouchMoved:NC,onTouchEnded:DC,onTouchCancelled:BC}),BA.addListener(this.touchListener,this._node),n=!0),r=!0):-1!==PC.indexOf(e)&&(this.mouseListener||(this.mouseListener=i.EventListener.create({event:i.EventListener.MOUSE,_previousIn:!1,owner:this._node,mask:GC(this._node,this._comp),onMouseDown:LC,onMouseMove:FC,onMouseUp:zC,onMouseScroll:UC}),BA.addListener(this.mouseListener,this._node),n=!0),r=!0),n&&!this._node.activeInHierarchy&&i.director.getScheduler().schedule((function(){t._node.activeInHierarchy||BA.pauseTarget(t._node)}),this._node,0,0,0,!1),r},t._onDispatch=function(e,t,n,i){if("boolean"==typeof n?(i=n,n=void 0):i=!!i,t){var r=null;return(r=i?this.capturingTargets=this.capturingTargets||new E_:this.bubblingTargets=this.bubblingTargets||new E_).hasEventListener(e,t,n)||r.on(e,t,n),t}A(6800)},t._offDispatch=function(e,t,n,i){if("boolean"==typeof n?(i=n,n=void 0):i=!!i,t){var r=i?this.capturingTargets:this.bubblingTargets;r&&r.off(e,t,n)}else this.capturingTargets&&this.capturingTargets.removeAll(e),this.bubblingTargets&&this.bubblingTargets.removeAll(e)},e}();i.NodeEventProcessor=kb,se(mC.prototype,"BaseNode",[{name:"childrenCount",newName:"children.length",customGetter:function(){return this.children.length}}]),se(RC.prototype,"Node",[{name:"width",targetName:"node.getComponent(UITransform)",customGetter:function(){return this._uiProps.uiTransformComp.width},customSetter:function(e){this._uiProps.uiTransformComp.width=e}},{name:"height",targetName:"node.getComponent(UITransform)",customGetter:function(){return this._uiProps.uiTransformComp.height},customSetter:function(e){this._uiProps.uiTransformComp.height=e}},{name:"anchorX",targetName:"node.getComponent(UITransform)",customGetter:function(){return this._uiProps.uiTransformComp.anchorX},customSetter:function(e){this._uiProps.uiTransformComp.anchorX=e}},{name:"anchorY",targetName:"node.getComponent(UITransform)",customGetter:function(){return this._uiProps.uiTransformComp.anchorY},customSetter:function(e){this._uiProps.uiTransformComp.anchorY=e}},{name:"getAnchorPoint",targetName:"node.getComponent(UITransform)",customFunction:function(e){return e||(e=new qn),e.set(this._uiProps.uiTransformComp.anchorPoint),e}},{name:"setAnchorPoint",targetName:"node.getComponent(UITransform)",customFunction:function(e,t){this._uiProps.uiTransformComp.setAnchorPoint(e,t)}},{name:"getContentSize",targetName:"node.getComponent(UITransform)",customFunction:function(e){return e||(e=new $n),e.set(this._uiProps.uiTransformComp.contentSize),e}},{name:"setContentSize",targetName:"node.getComponent(UITransform)",customFunction:function(e,t){"number"==typeof e?this._uiProps.uiTransformComp.setContentSize(e,t):this._uiProps.uiTransformComp.setContentSize(e)}}]),oe(RC.prototype,"Node.prototype",[{name:"addLayer"},{name:"removeLayer"}]),oe(Ll,"Layers",[{name:"All"},{name:"RaycastMask"},{name:"check"}]),se(Ll,"Layers",[{name:"Default",newName:"DEFAULT",target:Ll.Enum,targetName:"Layers.Enum"},{name:"Always",newName:"ALWAYS",target:Ll.Enum,targetName:"Layers.Enum"},{name:"IgnoreRaycast",newName:"IGNORE_RAYCAST",target:Ll.Enum,targetName:"Layers.Enum"},{name:"Gizmos",newName:"GIZMOS",target:Ll.Enum,targetName:"Layers.Enum"},{name:"Editor",newName:"EDITOR",target:Ll.Enum,targetName:"Layers.Enum"},{name:"UI",newName:"UI_3D",target:Ll.Enum,targetName:"Layers.Enum"},{name:"UI2D",newName:"UI_2D",target:Ll.Enum,targetName:"Layers.Enum"},{name:"SceneGizmo",newName:"SCENE_GIZMO",target:Ll.Enum,targetName:"Layers.Enum"},{name:"makeInclusiveMask",newName:"makeMaskInclude",target:Ll,targetName:"Layers"},{name:"makeExclusiveMask",newName:"makeMaskExclude",target:Ll,targetName:"Layers"}]),oe(Ll.Enum,"Layers.Enum",[{name:"ALWAYS"}]),oe(Ll.BitMask,"Layers.BitMask",[{name:"ALWAYS"}]);var Hb=new bn(0,1,0),Vb=new bn,Wb=new Dn,jb=(HC=ih("cc.AmbientInfo"),VC=Dh(Bt),HC((KC=function(){function e(){Q(this,"_skyColor",qC,this),Q(this,"_skyIllum",XC,this),Q(this,"_groundAlbedo",YC,this),this._resource=null}return e.prototype.activate=function(e){this._resource=e,this._resource.initialize(this)},j(e,[{key:"skyColor",set:function(e){this._skyColor.set(e),this._resource&&(this._resource.skyColor=this._skyColor)},get:function(){return this._skyColor}},{key:"skyIllum",set:function(e){this._skyIllum=e,this._resource&&(this._resource.skyIllum=this.skyIllum)},get:function(){return this._skyIllum}},{key:"groundAlbedo",set:function(e){this._groundAlbedo.set(e),this._resource&&(this._resource.groundAlbedo=this._groundAlbedo)},get:function(){return this._groundAlbedo}}]),e}(),qC=J((jC=KC).prototype,"_skyColor",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Cn(51,128,204,1)}}),XC=J(jC.prototype,"_skyIllum",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return ha.SKY_ILLUM}}),YC=J(jC.prototype,"_groundAlbedo",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Cn(51,51,51,255)}}),J(jC.prototype,"skyColor",[gh],Object.getOwnPropertyDescriptor(jC.prototype,"skyColor"),jC.prototype),J(jC.prototype,"skyIllum",[gh,VC],Object.getOwnPropertyDescriptor(jC.prototype,"skyIllum"),jC.prototype),J(jC.prototype,"groundAlbedo",[gh],Object.getOwnPropertyDescriptor(jC.prototype,"groundAlbedo"),jC.prototype),WC=jC))||WC);i.AmbientInfo=jb;var qb=(ZC=ih("cc.SkyboxInfo"),QC=Dh(gd),JC=Dh(gd),ZC((aR=function(){function e(){Q(this,"_envmap",tR,this),Q(this,"_isRGBE",nR,this),Q(this,"_enabled",iR,this),Q(this,"_useIBL",rR,this),this._resource=null}return e.prototype.activate=function(e){this._resource=e,this._resource.initialize(this),this._resource.activate()},j(e,[{key:"enabled",set:function(e){this._enabled!==e&&(this._enabled=e,this._resource&&(this._resource.enabled=this._enabled))},get:function(){return this._enabled}},{key:"useIBL",set:function(e){this._useIBL=e,this._resource&&(this._resource.useIBL=this._useIBL)},get:function(){return this._useIBL}},{key:"envmap",set:function(e){this._envmap=e,this._resource&&(this._resource.envmap=this._envmap)},get:function(){return this._envmap}},{key:"isRGBE",set:function(e){this._isRGBE=e,this._resource&&(this._resource.isRGBE=this._isRGBE)},get:function(){return this._isRGBE}}]),e}(),tR=J((eR=aR).prototype,"_envmap",[QC],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),nR=J(eR.prototype,"_isRGBE",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),iR=J(eR.prototype,"_enabled",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),rR=J(eR.prototype,"_useIBL",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),J(eR.prototype,"enabled",[gh],Object.getOwnPropertyDescriptor(eR.prototype,"enabled"),eR.prototype),J(eR.prototype,"useIBL",[gh],Object.getOwnPropertyDescriptor(eR.prototype,"useIBL"),eR.prototype),J(eR.prototype,"envmap",[gh,JC],Object.getOwnPropertyDescriptor(eR.prototype,"envmap"),eR.prototype),J(eR.prototype,"isRGBE",[gh],Object.getOwnPropertyDescriptor(eR.prototype,"isRGBE"),eR.prototype),$C=eR))||$C);i.SkyboxInfo=qb;var Xb=(sR=ih("cc.FogInfo"),oR=Dh(YS),cR=vh(),lR=Dh(Bt),uR=Eh(),hR=xh(),_R=Rh(),fR=vh(),dR=Dh(Bt),pR=xh(),mR=Rh(),gR=vh(),vR=Dh(Bt),yR=xh(),SR=Rh(),ER=vh(),TR=Dh(Bt),AR=Th(),xR=xh(),CR=Rh(),RR=vh(),bR=Dh(Bt),wR=xh(),IR=Rh(),OR=vh(),PR=Dh(Bt),MR=xh(),NR=Rh(),sR((qR=jR=function(){function e(){Q(this,"_type",LR,this),Q(this,"_fogColor",FR,this),Q(this,"_enabled",zR,this),Q(this,"_fogDensity",UR,this),Q(this,"_fogStart",GR,this),Q(this,"_fogEnd",kR,this),Q(this,"_fogAtten",HR,this),Q(this,"_fogTop",VR,this),Q(this,"_fogRange",WR,this),this._resource=null}return e.prototype.activate=function(e){this._resource=e,this._resource.initialize(this),this._resource.activate()},j(e,[{key:"enabled",set:function(e){this._enabled!==e&&(this._enabled=e,this._resource&&(this._resource.enabled=e,e&&(this._resource.type=this._type)))},get:function(){return this._enabled}},{key:"fogColor",set:function(e){this._fogColor.set(e),this._resource&&(this._resource.fogColor=this._fogColor)},get:function(){return this._fogColor}},{key:"type",get:function(){return this._type},set:function(e){this._type=e,this._resource&&(this._resource.type=e)}},{key:"fogDensity",get:function(){return this._fogDensity},set:function(e){this._fogDensity=e,this._resource&&(this._resource.fogDensity=e)}},{key:"fogStart",get:function(){return this._fogStart},set:function(e){this._fogStart=e,this._resource&&(this._resource.fogStart=e)}},{key:"fogEnd",get:function(){return this._fogEnd},set:function(e){this._fogEnd=e,this._resource&&(this._resource.fogEnd=e)}},{key:"fogAtten",get:function(){return this._fogAtten},set:function(e){this._fogAtten=e,this._resource&&(this._resource.fogAtten=e)}},{key:"fogTop",get:function(){return this._fogTop},set:function(e){this._fogTop=e,this._resource&&(this._resource.fogTop=e)}},{key:"fogRange",get:function(){return this._fogRange},set:function(e){this._fogRange=e,this._resource&&(this._resource.fogRange=e)}}]),e}(),jR.FogType=YS,LR=J((BR=qR).prototype,"_type",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return YS.LINEAR}}),FR=J(BR.prototype,"_fogColor",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Cn("#C8C8C8")}}),zR=J(BR.prototype,"_enabled",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),UR=J(BR.prototype,"_fogDensity",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.3}}),GR=J(BR.prototype,"_fogStart",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.5}}),kR=J(BR.prototype,"_fogEnd",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 300}}),HR=J(BR.prototype,"_fogAtten",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 5}}),VR=J(BR.prototype,"_fogTop",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1.5}}),WR=J(BR.prototype,"_fogRange",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1.2}}),J(BR.prototype,"enabled",[gh],Object.getOwnPropertyDescriptor(BR.prototype,"enabled"),BR.prototype),J(BR.prototype,"fogColor",[gh],Object.getOwnPropertyDescriptor(BR.prototype,"fogColor"),BR.prototype),J(BR.prototype,"type",[gh,oR],Object.getOwnPropertyDescriptor(BR.prototype,"type"),BR.prototype),J(BR.prototype,"fogDensity",[cR,lR,uR,hR,Ch,_R],Object.getOwnPropertyDescriptor(BR.prototype,"fogDensity"),BR.prototype),J(BR.prototype,"fogStart",[fR,dR,pR,mR],Object.getOwnPropertyDescriptor(BR.prototype,"fogStart"),BR.prototype),J(BR.prototype,"fogEnd",[gR,vR,yR,SR],Object.getOwnPropertyDescriptor(BR.prototype,"fogEnd"),BR.prototype),J(BR.prototype,"fogAtten",[ER,TR,AR,xR,CR],Object.getOwnPropertyDescriptor(BR.prototype,"fogAtten"),BR.prototype),J(BR.prototype,"fogTop",[RR,bR,wR,IR],Object.getOwnPropertyDescriptor(BR.prototype,"fogTop"),BR.prototype),J(BR.prototype,"fogRange",[OR,PR,MR,NR],Object.getOwnPropertyDescriptor(BR.prototype,"fogRange"),BR.prototype),DR=BR))||DR),Yb=(XR=ih("cc.ShadowsInfo"),YR=Dh(tm),KR=vh(),ZR=Dh(Bt),QR=vh(),JR=Dh(nm),$R=vh(),eb=Dh(Lt),tb=vh(),nb=Dh(Bt),ib=vh(),rb=Dh(Bt),ab=vh(),sb=Dh(Bt),ob=vh(),cb=Dh(Dt),lb=vh(),ub=vh(),hb=Dh(Bt),_b=vh(),fb=Dh(Bt),db=vh(),XR((Pb=function(){function e(){Q(this,"_type",gb,this),Q(this,"_enabled",vb,this),Q(this,"_normal",yb,this),Q(this,"_distance",Sb,this),Q(this,"_shadowColor",Eb,this),Q(this,"_autoAdapt",Tb,this),Q(this,"_pcf",Ab,this),Q(this,"_bias",xb,this),Q(this,"_near",Cb,this),Q(this,"_far",Rb,this),Q(this,"_aspect",bb,this),Q(this,"_orthoSize",wb,this),Q(this,"_maxReceived",Ib,this),Q(this,"_size",Ob,this),this._resource=null}var t=e.prototype;return t.setPlaneFromNode=function(e){e.getWorldRotation(Wb),this.normal=bn.transformQuat(Vb,Hb,Wb),e.getWorldPosition(Vb),this.distance=bn.dot(this._normal,Vb)},t.activate=function(e){this._resource=e,this._resource.initialize(this),this._resource.activate()},j(e,[{key:"enabled",set:function(e){this._enabled!==e&&(this._enabled=e,this._resource&&(this._resource.enabled=e,e&&(this._resource.type=this._type)))},get:function(){return this._enabled}},{key:"type",set:function(e){this._type=e,this._resource&&(this._resource.type=e)},get:function(){return this._type}},{key:"shadowColor",set:function(e){this._shadowColor.set(e),this._resource&&(this._resource.shadowColor=e)},get:function(){return this._shadowColor}},{key:"normal",set:function(e){bn.copy(this._normal,e),this._resource&&(this._resource.normal=e)},get:function(){return this._normal}},{key:"distance",set:function(e){this._distance=e,this._resource&&(this._resource.distance=e)},get:function(){return this._distance}},{key:"pcf",set:function(e){this._pcf=e,this._resource&&(this._resource.pcf=e)},get:function(){return this._pcf}},{key:"autoAdapt",set:function(e){this._autoAdapt=e,this._resource&&(this._resource.autoAdapt=e)},get:function(){return this._autoAdapt}},{key:"near",set:function(e){this._near=e,this._resource&&(this._resource.near=e)},get:function(){return this._near}},{key:"far",set:function(e){this._far=e,this._resource&&(this._resource.far=e)},get:function(){return this._far}},{key:"orthoSize",set:function(e){this._orthoSize=e,this._resource&&(this._resource.orthoSize=e)},get:function(){return this._orthoSize}},{key:"maxReceived",set:function(e){this._maxReceived=e,this._resource&&(this._resource.maxReceived=e)},get:function(){return this._maxReceived}},{key:"shadowMapSize",set:function(e){this._size.set(e),this._resource&&(this._resource.size=e,this._resource.shadowMapDirty=!0)},get:function(){return this._size}},{key:"aspect",set:function(e){this._aspect=e,this._resource&&(this._resource.aspect=e)},get:function(){return this._aspect}},{key:"bias",set:function(e){this._bias=e,this._resource&&(this._resource.bias=e)},get:function(){return this._bias}}]),e}(),gb=J((mb=Pb).prototype,"_type",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return tm.Planar}}),vb=J(mb.prototype,"_enabled",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),yb=J(mb.prototype,"_normal",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new bn(0,1,0)}}),Sb=J(mb.prototype,"_distance",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Eb=J(mb.prototype,"_shadowColor",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Cn(0,0,0,76)}}),Tb=J(mb.prototype,"_autoAdapt",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Ab=J(mb.prototype,"_pcf",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return nm.HARD}}),xb=J(mb.prototype,"_bias",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1e-5}}),Cb=J(mb.prototype,"_near",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),Rb=J(mb.prototype,"_far",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 30}}),bb=J(mb.prototype,"_aspect",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),wb=J(mb.prototype,"_orthoSize",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 5}}),Ib=J(mb.prototype,"_maxReceived",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 4}}),Ob=J(mb.prototype,"_size",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new qn(512,512)}}),J(mb.prototype,"enabled",[gh],Object.getOwnPropertyDescriptor(mb.prototype,"enabled"),mb.prototype),J(mb.prototype,"type",[gh,YR],Object.getOwnPropertyDescriptor(mb.prototype,"type"),mb.prototype),J(mb.prototype,"shadowColor",[gh],Object.getOwnPropertyDescriptor(mb.prototype,"shadowColor"),mb.prototype),J(mb.prototype,"normal",[KR],Object.getOwnPropertyDescriptor(mb.prototype,"normal"),mb.prototype),J(mb.prototype,"distance",[ZR,QR],Object.getOwnPropertyDescriptor(mb.prototype,"distance"),mb.prototype),J(mb.prototype,"pcf",[JR,$R],Object.getOwnPropertyDescriptor(mb.prototype,"pcf"),mb.prototype),J(mb.prototype,"autoAdapt",[eb,tb],Object.getOwnPropertyDescriptor(mb.prototype,"autoAdapt"),mb.prototype),J(mb.prototype,"near",[nb,ib],Object.getOwnPropertyDescriptor(mb.prototype,"near"),mb.prototype),J(mb.prototype,"far",[rb,ab],Object.getOwnPropertyDescriptor(mb.prototype,"far"),mb.prototype),J(mb.prototype,"orthoSize",[sb,ob],Object.getOwnPropertyDescriptor(mb.prototype,"orthoSize"),mb.prototype),J(mb.prototype,"maxReceived",[cb,lb],Object.getOwnPropertyDescriptor(mb.prototype,"maxReceived"),mb.prototype),J(mb.prototype,"shadowMapSize",[ub],Object.getOwnPropertyDescriptor(mb.prototype,"shadowMapSize"),mb.prototype),J(mb.prototype,"aspect",[hb,_b],Object.getOwnPropertyDescriptor(mb.prototype,"aspect"),mb.prototype),J(mb.prototype,"bias",[fb,db],Object.getOwnPropertyDescriptor(mb.prototype,"bias"),mb.prototype),pb=mb))||pb);i.ShadowsInfo=Yb;var Kb,Zb,Qb,Jb,$b=(Mb=ih("cc.SceneGlobals"),Nb=Dh(qb),Mb((Gb=function(){function e(){Q(this,"ambient",Lb,this),Q(this,"shadows",Fb,this),Q(this,"_skybox",zb,this),Q(this,"fog",Ub,this)}return e.prototype.activate=function(){var e=i.director.root.pipeline;this.ambient.activate(e.ambient),this.skybox.activate(e.skybox),this.shadows.activate(e.shadows),this.fog.activate(e.fog)},j(e,[{key:"skybox",get:function(){return this._skybox},set:function(e){this._skybox=e}}]),e}(),Lb=J((Bb=Gb).prototype,"ambient",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new jb}}),Fb=J(Bb.prototype,"shadows",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Yb}}),zb=J(Bb.prototype,"_skybox",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new qb}}),Ub=J(Bb.prototype,"fog",[gh,ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Xb}}),J(Bb.prototype,"skybox",[gh,Nb],Object.getOwnPropertyDescriptor(Bb.prototype,"skybox"),Bb.prototype),Db=Bb))||Db);i.SceneGlobals=$b;var ew,tw=e("Scene",ih("cc.Scene")((J((Zb=function(e){X(n,e);var t=n.prototype;function n(t){var n;return Q(n=e.call(this,t)||this,"autoReleaseAssets",Qb,Y(n)),Q(n,"_globals",Jb,Y(n)),n._renderScene=null,n.dependAssets=null,n._inited=void 0,n._prefabSyncedInLiveReload=!1,n._pos=bn.ZERO,n._rot=Dn.IDENTITY,n._scale=bn.ONE,n._mat=Hn.IDENTITY,n._dirtyFlags=0,n._activeInHierarchy=!1,i.director&&i.director.root&&(n._renderScene=i.director.root.createScene({})),n._inited=!i.game||!i.game._isCloning,n}return t._updateScene=function(){this._scene=this},j(n,[{key:"renderScene",get:function(){return this._renderScene}},{key:"globals",get:function(){return this._globals}}]),t.destroy=function(){var e=__.prototype.destroy.call(this);if(e)for(var t=this._children,n=0;n<t.length;++n)t[n].active=!1;return i.director.root.destroyScene(this._renderScene),this._active=!1,this._activeInHierarchy=!1,e},t.addComponent=function(){throw new Error(b(3822))},t._onHierarchyChanged=function(){},t._onBatchCreated=function(t){e.prototype._onBatchCreated.call(this,t);for(var n=this._children.length,i=0;i<n;++i)this._children[i]._onBatchCreated(t);JT(this)},t.getPosition=function(e){return bn.copy(e||new bn,bn.ZERO)},t.getRotation=function(e){return Dn.copy(e||new Dn,Dn.IDENTITY)},t.getScale=function(e){return bn.copy(e||new bn,bn.ONE)},t.getWorldPosition=function(e){return bn.copy(e||new bn,bn.ZERO)},t.getWorldRotation=function(e){return Dn.copy(e||new Dn,Dn.IDENTITY)},t.getWorldScale=function(e){return bn.copy(e||new bn,bn.ONE)},t.getWorldMatrix=function(e){return Hn.copy(e||new Hn,Hn.IDENTITY)},t.getWorldRS=function(e){return Hn.copy(e||new Hn,Hn.IDENTITY)},t.getWorldRT=function(e){return Hn.copy(e||new Hn,Hn.IDENTITY)},t.updateWorldTransform=function(){},t._instantiate=function(){},t._load=function(){this._inited||(this._onBatchCreated(!1),this._inited=!0),this.walk(mC._setScene)},t._activate=function(e){e=!1!==e,i.director._nodeActivator.activateNode(this,e),this._globals.activate()},j(n,[{key:"position",get:function(){return bn.ZERO}},{key:"worldPosition",get:function(){return bn.ZERO}},{key:"rotation",get:function(){return Dn.IDENTITY}},{key:"worldRotation",get:function(){return Dn.IDENTITY}},{key:"scale",get:function(){return bn.ONE}},{key:"worldScale",get:function(){return bn.ONE}},{key:"eulerAngles",get:function(){return bn.ZERO}},{key:"worldMatrix",get:function(){return Hn.IDENTITY}}]),n}(mC)).prototype,"globals",[gh],Object.getOwnPropertyDescriptor(Zb.prototype,"globals"),Zb.prototype),Qb=J(Zb.prototype,"autoReleaseAssets",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Jb=J(Zb.prototype,"_globals",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new $b}}),Kb=Zb))||Kb);function nw(e,t){if(!t){var n=i.director.getScene();if(!n)return null;t=n}return t.getChildByPath(e)}i.Scene=tw,i.find=nw,__.Flags.HideInHierarchy;var iw=e("PrivateNode",ih("cc.PrivateNode")(ew=function(e){function t(t){return e.call(this,t)||this}return X(t,e),t}(RC))||ew);i.PrivateNode=iw;var rw=at.fastRemoveAt,aw=__.Flags.IsStartCalled,sw=__.Flags.IsOnEnableCalled;function ow(e,t){for(var n=t.constructor._executionOrder,i=t._id,r=0,a=e.length-1,s=a>>>1;r<=a;s=r+a>>>1){var o=e[s],c=o.constructor._executionOrder;if(c>n)a=s-1;else if(c<n)r=s+1;else{var l=o._id;if(l>i)a=s-1;else{if(!(l<i))return s;r=s+1}}}return~r}function cw(e,t){for(var n=e.array,i=e.i+1;i<n.length;){var r=n[i];r._enabled&&r.node._activeInHierarchy?++i:(e.removeAt(i),t&&(r._objFlags&=~t))}}__.Flags.IsEditorOnEnableCalled;var lw=function(e){this._zero=void 0,this._neg=void 0,this._pos=void 0,this._invoke=void 0;var t=de;this._zero=new t([]),this._neg=new t([]),this._pos=new t([]),this._invoke=e};function uw(e,t){return e.constructor._executionOrder-t.constructor._executionOrder}lw.stableRemoveInactive=cw;var hw=function(e){function t(){return e.apply(this,arguments)||this}X(t,e);var n=t.prototype;return n.add=function(e){var t=e.constructor._executionOrder;(0===t?this._zero:t<0?this._neg:this._pos).array.push(e)},n.remove=function(e){var t=e.constructor._executionOrder;(0===t?this._zero:t<0?this._neg:this._pos).fastRemove(e)},n.cancelInactive=function(e){cw(this._zero,e),cw(this._neg,e),cw(this._pos,e)},n.invoke=function(){var e=this._neg;e.array.length>0&&(e.array.sort(uw),this._invoke(e),e.array.length=0),this._invoke(this._zero),this._zero.array.length=0;var t=this._pos;t.array.length>0&&(t.array.sort(uw),this._invoke(t),t.array.length=0)},t}(lw),_w=function(e){function t(){return e.apply(this,arguments)||this}X(t,e);var n=t.prototype;return n.add=function(e){var t=e.constructor._executionOrder;if(0===t)this._zero.array.push(e);else{var n=t<0?this._neg.array:this._pos.array,i=ow(n,e);i<0&&n.splice(~i,0,e)}},n.remove=function(e){var t=e.constructor._executionOrder;if(0===t)this._zero.fastRemove(e);else{var n=t<0?this._neg:this._pos,i=ow(n.array,e);i>=0&&n.removeAt(i)}},n.invoke=function(e){this._neg.array.length>0&&this._invoke(this._neg,e),this._invoke(this._zero,e),this._pos.array.length>0&&this._invoke(this._pos,e)},t}(lw);function fw(e,t,n){var r="var a=it.array;for(it.i=0;it.i<a.length;++it.i){var c=a[it.i];"+e+"}",a=t?Function("it","dt",r):Function("it",r);return function(e,t,n){return function(r,a){try{t(r,a)}catch(t){i._throw(t);var s=r.array;for(n&&(s[r.i]._objFlags|=n),++r.i;r.i<s.length;++r.i)try{e(s[r.i],a)}catch(e){i._throw(e),n&&(s[r.i]._objFlags|=n)}}}}(Function("c","dt",e),a,n)}var dw=fw("c.start();c._objFlags|="+aw,!1,aw),pw=fw("c.update(dt)",!0),mw=fw("c.lateUpdate(dt)",!0),gw=function(e){var t=i.director._compScheduler,n=e.array;for(e.i=0;e.i<n.length;++e.i){var r=n[e.i];r._enabled&&(r.onEnable(),!r.node._activeInHierarchy||t._onEnabled(r))}},vw=function(){function e(){this._deferredComps=[],this.unscheduleAll()}var t=e.prototype;return t.unscheduleAll=function(){this.startInvoker=new hw(dw),this.updateInvoker=new _w(pw),this.lateUpdateInvoker=new _w(mw),this._updating=!1},t._onEnabled=function(e){i.director.getScheduler().resumeTarget(e),e._objFlags|=sw,this._updating?this._deferredComps.push(e):this._scheduleImmediate(e)},t._onDisabled=function(e){i.director.getScheduler().pauseTarget(e),e._objFlags&=~sw;var t=this._deferredComps.indexOf(e);t>=0?rw(this._deferredComps,t):(!e.start||e._objFlags&aw||this.startInvoker.remove(e),e.update&&this.updateInvoker.remove(e),e.lateUpdate&&this.lateUpdateInvoker.remove(e))},t.enableComp=function(e,t){if(!(e._objFlags&sw)){if(e.onEnable){if(t)return void t.add(e);if(e.onEnable(),!e.node._activeInHierarchy)return}this._onEnabled(e)}},t.disableComp=function(e){e._objFlags&sw&&(e.onDisable&&e.onDisable(),this._onDisabled(e))},t.startPhase=function(){this._updating=!0,this.startInvoker.invoke(),this._startForNewComps()},t.updatePhase=function(e){this.updateInvoker.invoke(e)},t.lateUpdatePhase=function(e){this.lateUpdateInvoker.invoke(e),this._updating=!1,this._startForNewComps()},t._startForNewComps=function(){this._deferredComps.length>0&&(this._deferredSchedule(),this.startInvoker.invoke())},t._scheduleImmediate=function(e){"function"!=typeof e.start||e._objFlags&aw||this.startInvoker.add(e),"function"==typeof e.update&&this.updateInvoker.add(e),"function"==typeof e.lateUpdate&&this.lateUpdateInvoker.add(e)},t._deferredSchedule=function(){for(var e=this._deferredComps,t=0,n=e.length;t<n;t++)this._scheduleImmediate(e[t]);e.length=0},e}(),yw=__.Flags.IsPreloadStarted,Sw=__.Flags.IsOnLoadStarted,Ew=__.Flags.IsOnLoadCalled,Tw=__.Flags.Deactivating,Aw=function(e){function t(){return e.apply(this,arguments)||this}X(t,e);var n=t.prototype;return n.add=function(e){this._zero.array.push(e)},n.remove=function(e){this._zero.fastRemove(e)},n.cancelInactive=function(e){lw.stableRemoveInactive(this._zero,e)},n.invoke=function(){this._invoke(this._zero),this._zero.array.length=0},t}(lw),xw=fw("c.__preload();"),Cw=fw("c.onLoad();c._objFlags|="+Ew,!1,Ew),Rw=new rt(4);function bw(e,t,n){t?e._removeComponent(t):at.removeAt(e._components,n)}Rw.get=function(){var e=this._get()||{preload:new Aw(xw),onLoad:new hw(Cw),onEnable:new hw(gw)};e.preload._zero.i=-1;var t=e.onLoad;return t._zero.i=-1,t._neg.i=-1,t._pos.i=-1,(t=e.onEnable)._zero.i=-1,t._neg.i=-1,t._pos.i=-1,e};var ww=e("NodeActivator",function(){function e(){this.resetComp=void 0,this.reset()}var t=e.prototype;return t.reset=function(){this._activatingStack=[]},t.activateNode=function(e,t){if(t){var n=Rw.get();this._activatingStack.push(n),this._activateNodeRecursively(e,n.preload,n.onLoad,n.onEnable),n.preload.invoke(),n.onLoad.invoke(),n.onEnable.invoke(),this._activatingStack.pop(),Rw.put(n)}else{this._deactivateNodeRecursively(e);for(var i,r=Z(this._activatingStack);!(i=r()).done;){var a=i.value;a.preload.cancelInactive(yw),a.onLoad.cancelInactive(Sw),a.onEnable.cancelInactive()}}e.emit("active-in-hierarchy-changed",e)},t.activateComp=function(e,t,n,r){if(d_(e,!0)&&(e._objFlags&yw||(e._objFlags|=yw,e.__preload&&(t?t.add(e):e.__preload())),e._objFlags&Sw||(e._objFlags|=Sw,e.onLoad?n?n.add(e):(e.onLoad(),e._objFlags|=Ew):e._objFlags|=Ew),e._enabled)){if(!e.node._activeInHierarchy)return;i.director._compScheduler.enableComp(e,r)}},t.destroyComp=function(e){i.director._compScheduler.disableComp(e),e.onDestroy&&e._objFlags&Ew&&e.onDestroy()},t._activateNodeRecursively=function(e,t,n,r){if(e._objFlags&Tw)A(3816,e.name);else{e._activeInHierarchy=!0;for(var a=e._components.length,s=0;s<a;++s){var o=e._components[s];o instanceof i.Component?this.activateComp(o,t,n,r):(bw(e,o,s),--s,--a)}e._childArrivalOrder=e._children.length;for(var c=0,l=e._children.length;c<l;++c){var u=e._children[c];u._active&&this._activateNodeRecursively(u,t,n,r)}e._onPostActivated(!0)}},t._deactivateNodeRecursively=function(e){e._objFlags|=Tw,e._activeInHierarchy=!1;for(var t=e._components.length,n=0;n<t;++n){var r=e._components[n];if(r._enabled&&(i.director._compScheduler.disableComp(r),e._activeInHierarchy))return void(e._objFlags&=~Tw)}for(var a=0,s=e._children.length;a<s;++a){var o=e._children[a];if(o._activeInHierarchy&&(this._deactivateNodeRecursively(o),e._activeInHierarchy))return void(e._objFlags&=~Tw)}e._onPostActivated(!1),e._objFlags&=~Tw},e}()),Iw=e("Director",function(e){function t(){var t;return(t=e.call(this)||this)._compScheduler=void 0,t._nodeActivator=void 0,t._invalid=void 0,t._paused=void 0,t._purgeDirectorInNextLoop=void 0,t._root=void 0,t._loadingScene=void 0,t._scene=void 0,t._totalFrames=void 0,t._lastUpdate=void 0,t._deltaTime=void 0,t._startTime=void 0,t._scheduler=void 0,t._systems=void 0,t._invalid=!1,t._paused=!1,t._purgeDirectorInNextLoop=!1,t._root=null,t._loadingScene="",t._scene=null,t._totalFrames=0,t._lastUpdate=0,t._deltaTime=0,t._startTime=0,t._scheduler=new dx,t._compScheduler=new vw,t._nodeActivator=new ww,t._systems=[],i.game.once(WA.EVENT_RENDERER_INITED,t._initOnRendererInitialized,Y(t)),t}X(t,e);var n=t.prototype;return n.calculateDeltaTime=function(e){e||(e=performance.now()),this._deltaTime=e>this._lastUpdate?(e-this._lastUpdate)/1e3:0,this._lastUpdate=e},n.convertToGL=function(e){var t=i.game.container,n=i.view,r=t.getBoundingClientRect(),a=r.left+window.pageXOffset-t.clientLeft,s=r.top+window.pageYOffset-t.clientTop,o=n._devicePixelRatio*(e.x-a),c=n._devicePixelRatio*(s+r.height-e.y);return n._isRotated?Kn(n._viewportRect.width-c,o):Kn(o,c)},n.convertToUI=function(e){var t=i.game.container,n=i.view,r=t.getBoundingClientRect(),a=r.left+window.pageXOffset-t.clientLeft,s=r.top+window.pageYOffset-t.clientTop,o=Kn(0,0);return n._isRotated?(o.x=a+e.y/n._devicePixelRatio,o.y=s+r.height-(n._viewportRect.width-e.x)/n._devicePixelRatio):(o.x=a+e.x*n._devicePixelRatio,o.y=s+r.height-e.y*n._devicePixelRatio),o},n.end=function(){this._purgeDirectorInNextLoop=!0},n.getWinSize=function(){return ei(i.winSize)},n.getWinSizeInPixels=function(){return ei(i.winSize)},n.pause=function(){this._paused||(this._paused=!0)},n.purgeCachedData=function(){i.assetManager.releaseAll()},n.purgeDirector=function(){this._scheduler.unscheduleAll(),this._compScheduler.unscheduleAll(),this._nodeActivator.reset(),BA&&BA.setEnabled(!1),i.isValid(this._scene)&&this._scene.destroy(),this._scene=null,this.stopAnimation(),i.assetManager.releaseAll()},n.reset=function(){this.purgeDirector(),this.emit(t.EVENT_RESET),BA&&BA.setEnabled(!0),this.startAnimation()},n.runSceneImmediate=function(e,t,n){e instanceof Fx&&(e=e.scene),R(e instanceof tw,1216),e._load();for(var r=Object.keys(i.game._persistRootNodes).map((function(e){return i.game._persistRootNodes[e]})),a=0;a<r.length;a++){var s=r[a];s.emit(i.Node.SCENE_CHANGED_FOR_PERSISTS,e.renderScene);var o=e.getChildByUuid(s.uuid);if(o){var c=o.getSiblingIndex();o._destroyImmediate(),e.insertChild(s,c)}else s.parent=e}var l=this._scene;i.isValid(l)&&l.destroy(),i.assetManager._releaseManager._autoRelease(l,e,r),this._scene=null,__._deferredDestroy(),t&&t(),this.emit(i.Director.EVENT_BEFORE_SCENE_LAUNCH,e),this._scene=e,e._activate(),this._root&&this._root.resetCumulativeTime(),this.startAnimation(),n&&n(null,e),this.emit(i.Director.EVENT_AFTER_SCENE_LAUNCH,e)},n.runScene=function(e,t,n){var r=this;e instanceof Fx&&(e=e.scene),R(e,1205),R(e instanceof tw,1216),e._load(),this.once(i.Director.EVENT_AFTER_DRAW,(function(){r.runSceneImmediate(e,t,n)}))},n.loadScene=function(e,t,n){var r=this;if(this._loadingScene)return E(1208,e,this._loadingScene),!1;var a=i.assetManager.bundles.find((function(t){return t.getSceneInfo(e)}));return a?(this.emit(i.Director.EVENT_BEFORE_SCENE_LOADING,e),this._loadingScene=e,console.time("LoadScene "+e),a.loadScene(e,(function(i,a){console.timeEnd("LoadScene "+e),r._loadingScene="",i?(f(i),t&&t(i)):r.runSceneImmediate(a,n,t)})),!0):(A(1209,e),!1)},n.preloadScene=function(e,t,n){var r=i.assetManager.bundles.find((function(t){return t.getSceneInfo(e)}));if(r)r.preloadScene(e,null,t,n);else{var a='Can not preload the scene "'+e+'" because it is not in the build settings.';n&&n(new Error(a)),f("preloadScene: "+a)}},n.resume=function(){this._paused&&(this._lastUpdate=performance.now(),this._lastUpdate||y(1200),this._paused=!1,this._deltaTime=0)},n.setDepthTest=function(e){i.Camera.main&&(i.Camera.main.depth=!!e)},n.setClearColor=function(e){i.Camera.main&&(i.Camera.main.backgroundColor=e)},n.getRunningScene=function(){return this._scene},n.getScene=function(){return this._scene},n.getAnimationInterval=function(){return 1e3/i.game.getFrameRate()},n.setAnimationInterval=function(e){i.game.setFrameRate(Math.round(1e3/e))},n.getDeltaTime=function(){return this._deltaTime},n.getTotalTime=function(){return performance.now()-this._startTime},n.getCurrentTime=function(){return this._lastUpdate},n.getTotalFrames=function(){return this._totalFrames},n.isPaused=function(){return this._paused},n.getScheduler=function(){return this._scheduler},n.setScheduler=function(e){this._scheduler!==e&&(this.unregisterSystem(this._scheduler),this._scheduler=e,this.registerSystem(dx.ID,e,200))},n.registerSystem=function(e,t,n){t.id=e,t.priority=n,t.init(),this._systems.push(t),this._systems.sort(cx.sortByPriority)},n.unregisterSystem=function(e){at.fastRemove(this._systems,e),this._systems.sort(cx.sortByPriority)},n.getSystem=function(e){return this._systems.find((function(t){return t.id===e}))},n.getAnimationManager=function(){return this.getSystem(i.AnimationManager.ID)},n.startAnimation=function(){this._invalid=!1,this._lastUpdate=performance.now()},n.stopAnimation=function(){this._invalid=!0},n.mainLoop=function(e){if(this._purgeDirectorInNextLoop)this._purgeDirectorInNextLoop=!1,this.purgeDirector();else if(!this._invalid){this.calculateDeltaTime(e);var n=this._deltaTime;if(!this._paused){this.emit(t.EVENT_BEFORE_UPDATE),this._compScheduler.startPhase(),this._compScheduler.updatePhase(n);for(var i=0;i<this._systems.length;++i)this._systems[i].update(n);this._compScheduler.lateUpdatePhase(n),this.emit(t.EVENT_AFTER_UPDATE),__._deferredDestroy();for(var r=0;r<this._systems.length;++r)this._systems[r].postUpdate(n)}this.emit(t.EVENT_BEFORE_DRAW),this._root.frameMove(this._deltaTime),this.emit(t.EVENT_AFTER_DRAW),BA.frameUpdateListeners(),RC.bookOfChange.clear(),this._totalFrames++}},n._initOnRendererInitialized=function(){this._totalFrames=0,this._lastUpdate=performance.now(),this._startTime=this._lastUpdate,this._paused=!1,this._purgeDirectorInNextLoop=!1,BA&&BA.setEnabled(!0),this.registerSystem(dx.ID,this._scheduler,200),this.emit(t.EVENT_INIT)},n._init=function(){return this._root=new mx(i.game._gfxDevice),this._root.initialize({}).catch((function(e){return A(1217),Promise.reject(e)}))},j(t,[{key:"root",get:function(){return this._root}}]),t}(w_));Iw.EVENT_INIT="director_init",Iw.EVENT_RESET="director_reset",Iw.EVENT_BEFORE_SCENE_LOADING="director_before_scene_loading",Iw.EVENT_BEFORE_SCENE_LAUNCH="director_before_scene_launch",Iw.EVENT_AFTER_SCENE_LAUNCH="director_after_scene_launch",Iw.EVENT_BEFORE_UPDATE="director_before_update",Iw.EVENT_AFTER_UPDATE="director_after_update",Iw.EVENT_BEFORE_DRAW="director_before_draw",Iw.EVENT_AFTER_DRAW="director_after_draw",Iw.EVENT_BEFORE_COMMIT="director_before_commit",Iw.EVENT_BEFORE_PHYSICS="director_before_physics",Iw.EVENT_AFTER_PHYSICS="director_after_physics",Iw.instance=void 0,i.Director=Iw;var Ow=e("director",Iw.instance=i.director=new Iw),Pw=function(){function e(){this.name="",this.base="",this.importBase="",this.nativeBase="",this.deps=null,this.assetInfos=new Lh,this.scenes=new Lh,this.paths=new Lh}var t=e.prototype;return t.init=function(e){!function(e){var t=e.uuids,n=e.paths,i=e.types,r=e.deps,a=e.paths=Object.create(null);if(!1===e.debug){for(var s=0,o=t.length;s<o;s++)t[s]=$h(t[s]);for(var c in n){var l=n[c],u=l[1];l[1]=i[u]}}else{for(var h=Object.create(null),_=0,f=t.length;_<f;_++){var d=t[_];t[_]=h[d]=$h(d)}t=h}for(var p in n){var m=n[p];a[t[p]]=m}var g=e.scenes;for(var v in g){var y=g[v];g[v]=t[y]}var S=e.packs;for(var E in S)for(var T=S[E],A=0;A<T.length;++A)T[A]=t[T[A]];var x=e.versions;if(x)for(var C in x)for(var R=x[C],b=0;b<R.length;b+=2){var w=R[b];R[b]=t[w]||w}var I=e.redirect;if(I)for(var O=0;O<I.length;O+=2)I[O]=t[I[O]],I[O+1]=r[I[O+1]]}(e),this.importBase=e.importBase||"",this.nativeBase=e.nativeBase||"",this.base=e.base||"",this.name=e.name||"",this.deps=e.deps||[],this._initUuid(e.uuids),this._initPath(e.paths),this._initScene(e.scenes),this._initPackage(e.packs),this._initVersion(e.versions),this._initRedirect(e.redirect)},t.getInfoWithPath=function(e,t){if(!e)return null;e=r_(e);var n=this.paths.get(e);if(n){if(!t)return n[0];for(var i=0,r=n.length;i<r;i++){var a=n[i];if(st.isChildClassOf(a.ctor,t))return a}}return null},t.getDirWithPath=function(e,t,n){"/"===(e=r_(e))[e.length-1]&&(e=e.slice(0,-1));var i=n||[];return this.paths.forEach((function(n,r){if(r.startsWith(e)&&function(e,t){return!(e.length>t.length)||47===e.charCodeAt(t.length)}(r,e)||!e)for(var a=0,s=n.length;a<s;a++){var o=n[a];t&&!st.isChildClassOf(o.ctor,t)||i.push(o)}})),i},t.getAssetInfo=function(e){return this.assetInfos.get(e)||null},t.getSceneInfo=function(e){return e.endsWith(".scene")||(e+=".scene"),"/"===e[0]||e.startsWith("db://")||(e="/"+e),this.scenes.find((function(t,n){return n.endsWith(e)}))},t.destroy=function(){this.paths.destroy(),this.scenes.destroy(),this.assetInfos.destroy()},t._initUuid=function(e){if(e){this.assetInfos.clear();for(var t=0,n=e.length;t<n;t++){var i=e[t];this.assetInfos.add(i,{uuid:i})}}},t._initPath=function(e){if(e){var t=this.paths;for(var n in t.clear(),e){var i=e[n],r=i[0],a=i[1],s=3===i.length,o=this.assetInfos.get(n);o.path=r,o.ctor=st._getClassById(a),t.has(r)?s?t.get(r).push(o):t.get(r).splice(0,0,o):t.add(r,[o])}}},t._initScene=function(e){if(e){var t=this.scenes;t.clear();var n=this.assetInfos;for(var i in e){var r=e[i],a=n.get(r);a.url=i,t.add(i,a)}}},t._initPackage=function(e){if(e){var t=this.assetInfos;for(var n in e){var i=e[n],r={uuid:n,packedUuids:i,ext:".json"};t.add(n,r);for(var a=0,s=i.length;a<s;a++){var o=i[a],c=t.get(o),l=c.packs;l?1===s?l.splice(0,0,r):l.push(r):c.packs=[r]}}}},t._initVersion=function(e){if(e){var t=this.assetInfos,n=e.import;if(n)for(var i=0,r=n.length;i<r;i+=2){var a=n[i];t.get(a).ver=n[i+1]}if(n=e.native)for(var s=0,o=n.length;s<o;s+=2){var c=n[s];t.get(c).nativeVer=n[s+1]}}},t._initRedirect=function(e){if(e)for(var t=this.assetInfos,n=0,i=e.length;n<i;n+=2){var r=e[n];t.get(r).redirect=e[n+1]}},e}();function Mw(e,t){e._uuid&&t.push(e._uuid)}function Nw(e,t){for(var n=Object.getOwnPropertyNames(e),i=0;i<n.length;i++){var r=n[i];if("node"!==r&&"__eventTargets"!==r){var a=e[r];if("object"==typeof a&&a)if(Array.isArray(a))for(var s=0;s<a.length;s++){var o=a[s];o instanceof I_&&Mw(o,t)}else if(a.constructor&&a.constructor!==Object)a instanceof I_&&Mw(a,t);else for(var c=Object.getOwnPropertyNames(a),l=0;l<c.length;l++){var u=a[c[l]];u instanceof I_&&Mw(u,t)}}}}function Dw(e,t,n,i){n.push(e._uuid);for(var r=ed.getDeps(e._uuid),a=0,s=r.length;a<s;a++){var o=Uh.get(r[a]);if(o){var c=o._uuid;c in t?t[c]+=i:t[c]=o.refCount+i,n.includes(c)||Dw(o,t,n,i)}}}var Bw=[],Lw=new(function(){function e(){this._persistNodeDeps=new Lh,this._toDelete=new Lh,this._eventListener=!1}var t=e.prototype;return t.init=function(){this._persistNodeDeps.clear(),this._toDelete.clear()},t._addPersistNodeRef=function(e){var t=[];!function e(t,n){for(var i=0;i<t._components.length;i++)Nw(t._components[i],n);for(var r=0;r<t._children.length;r++)e(t._children[r],n)}(e,t);for(var n=0,i=t.length;n<i;n++){var r=Uh.get(t[n]);r&&r.addRef()}this._persistNodeDeps.add(e.uuid,t)},t._removePersistNodeRef=function(e){if(this._persistNodeDeps.has(e.uuid)){for(var t=this._persistNodeDeps.get(e.uuid),n=0,i=t.length;n<i;n++){var r=Uh.get(t[n]);r&&r.decRef()}this._persistNodeDeps.remove(e.uuid)}},t._autoRelease=function(e,t,n){if(e){for(var i=ed.getDeps(e.uuid),r=0,a=i.length;r<a;r++){var s=Uh.get(i[r]);s&&s.decRef(e.autoReleaseAssets)}var o=ed._depends.get(e.uuid);if(o&&o.persistDeps)for(var c=o.persistDeps,l=0,u=c.length;l<u;l++){var h=Uh.get(c[l]);h&&h.decRef(e.autoReleaseAssets)}e.uuid!==t.uuid&&ed.remove(e.uuid)}var _=ed._depends.get(t.uuid);_&&(_.persistDeps=[]);for(var f=0,d=n.length;f<d;f++){for(var p,m,g=n[f],v=this._persistNodeDeps.get(g.uuid),y=Z(v);!(m=y()).done;){var S=m.value,E=Uh.get(S);E&&E.addRef()}_&&(p=_.persistDeps).push.apply(p,v)}},t.tryRelease=function(e,t){void 0===t&&(t=!1),e instanceof I_&&(t?this._free(e,t):(this._toDelete.add(e._uuid,e),this._eventListener||(this._eventListener=!0,At(this._freeAssets.bind(this)))))},t._freeAssets=function(){var e=this;this._eventListener=!1,this._toDelete.forEach((function(t){e._free(t)})),this._toDelete.clear()},t._free=function(e,t){void 0===t&&(t=!1);var n=e._uuid;if(this._toDelete.remove(n),d_(e,!0)&&!(!t&&e.refCount>0&&function(e){var t=Object.create(null);if(t[e._uuid]=e.refCount,Dw(e,t,Bw,-1),Bw.length=0,0!==t[e._uuid])return t[e._uuid];for(var n in t)0!==t[n]&&Dw(Uh.get(n),t,Bw,1);return Bw.length=0,t[e._uuid]}(e)>0)){Uh.remove(n);for(var i=ed.getDeps(n),r=0,a=i.length;r<a;r++){var s=Uh.get(i[r]);s&&(s.decRef(!1),this._free(s,!1))}e.destroy(),ed.remove(n)}},e}()),Fw=null;function zw(e,t){for(var n=0,i=e.input.length;n<i;n++){var r=e.input[n];t&&!r.isNative&&r.content instanceof I_&&r.content.decRef(!1),r.recycle()}e.input=null}function Uw(e,t){return t?/\?/.test(e)?e+"&_t="+Date.now():e+"?_t="+Date.now():e}function Gw(e,t,n,i,r,a,s){try{var o=ed.parse(e,t),c=!0;if(t instanceof I_&&!t.__nativeDepend__&&(c=!1),r){for(var l=0,u=o.deps.length;l<u;l++){var h=o.deps[l];h in n||(n[h]=!0,i.push({uuid:h,bundle:s&&s.name}))}c&&o.nativeDep&&(s&&(o.nativeDep.bundle=s.name),i.push(q({},o.nativeDep)))}else{a=!!t.asyncLoadAssets||a&&!o.preventDeferredLoadDependents;for(var _=0,d=o.deps.length;_<d;_++){var p=o.deps[_];p in n||(n[p]=!0,i.push({uuid:p,__asyncLoadAssets__:a,bundle:s&&s.name}))}c&&!a&&!o.preventPreloadNativeObject&&o.nativeDep&&(s&&(o.nativeDep.bundle=s.name),i.push(q({},o.nativeDep)))}}catch(e){f(e.message,e.stack)}}function kw(e,t,n){t&&(n=void 0!==n?n:i.assetManager.cacheAsset,!i_(t)&&n&&Uh.add(e,t))}function Hw(e,t,n){var i=!1,r=t.__depends__;if(r){for(var a=0,s=r.length;a<s;a++){var o=r[a],c=n[o.uuid+"@import"];c?o.owner[o.prop]=c.addRef():(f("The asset "+o.uuid+" is missing!"),i=!0)}t.__depends__=null}return t.__nativeDepend__&&(n[e+"@native"]?t._nativeAsset=n[e+"@native"]:i=!0,t.__nativeDepend__=!1),i}function Vw(e,t,n){var i=0,r=[],a=e.length;0===a&&n&&n(r);for(var s=function(e){e&&r.push(e),++i===a&&n&&n(r)},o=0;o<a;o++)t(e[o],s)}function Ww(e,t,n){var i=e,r=t,a=n;if(void 0===n){var s="function"==typeof e;t?(a=t,s||(r=null)):void 0===t&&s&&(a=e,i=null,r=null),void 0!==t&&s&&(r=e,i=null)}return{options:i||Object.create(null),onProgress:r,onComplete:a}}function jw(e,t,n){var i=e,r=t,a=n;if(void 0===n){var s=st.isChildClassOf(e,I_);t?(a=t,s&&(r=null)):void 0!==t||s||(a=e,r=null,i=null),void 0===t||s||(r=e,i=null)}return{type:i,onProgress:r||Fw,onComplete:a}}function qw(e){return function(t,n){if(e){var i=[];Array.isArray(n)?n.forEach((function(e){return e instanceof I_&&i.push(e.addRef())})):n instanceof I_&&i.push(n.addRef()),At((function(){i.forEach((function(e){return e.decRef(!1)})),e(t,n)}))}}}var Xw=function(){function e(){this._config=new Pw}var t=e.prototype;return t.getInfoWithPath=function(e,t){return this._config.getInfoWithPath(e,t)},t.getDirWithPath=function(e,t,n){return this._config.getDirWithPath(e,t,n)},t.getAssetInfo=function(e){return this._config.getAssetInfo(e)},t.getSceneInfo=function(e){return this._config.getSceneInfo(e)},t.init=function(e){this._config.init(e),Hh.add(e.name,this)},t.load=function(e,t,n,r){var a=jw(t,n,r),s=a.type,o=a.onProgress,c=a.onComplete,l={__requestType__:zh.PATH,type:s,bundle:this.name,__outputAsArray__:Array.isArray(e)};i.assetManager.loadAny(e,l,o,c)},t.preload=function(e,t,n,r){var a=jw(t,n,r),s=a.type,o=a.onProgress,c=a.onComplete;i.assetManager.preloadAny(e,{__requestType__:zh.PATH,type:s,bundle:this.name},o,c)},t.loadDir=function(e,t,n,r){var a=jw(t,n,r),s=a.type,o=a.onProgress,c=a.onComplete;i.assetManager.loadAny(e,{__requestType__:zh.DIR,type:s,bundle:this.name,__outputAsArray__:!0},o,c)},t.preloadDir=function(e,t,n,r){var a=jw(t,n,r),s=a.type,o=a.onProgress,c=a.onComplete;i.assetManager.preloadAny(e,{__requestType__:zh.DIR,type:s,bundle:this.name},o,c)},t.loadScene=function(e,t,n,r){var a=Ww(t,n,r),s=a.options,o=a.onProgress,c=a.onComplete;s.preset=s.preset||"scene",s.bundle=this.name,i.assetManager.loadAny({scene:e},s,o,(function(e,t){if(e)f(e.message,e.stack);else if(t instanceof Fx&&t.scene){var n=t.scene;n._id=t._uuid,n.name=t.name}else e=new Error("The asset "+t._uuid+" is not a scene");c&&c(e,t)}))},t.preloadScene=function(e,t,n,r){var a=Ww(t,n,r),s=a.options,o=a.onProgress,c=a.onComplete;s.bundle=this.name,i.assetManager.preloadAny({scene:e},s,o,(function(t){t&&A(1210,e,t.message),c&&c(t)}))},t.get=function(e,t){var n=this.getInfoWithPath(e,t);return n&&Uh.get(n.uuid)||null},t.release=function(e,t){var n=this.get(e,t);n&&Lw.tryRelease(n,!0)},t.releaseUnusedAssets=function(){var e=this;Uh.forEach((function(t){var n=e.getAssetInfo(t._uuid);n&&!n.redirect&&Lw.tryRelease(t)}))},t.releaseAll=function(){var e=this;Uh.forEach((function(t){var n=e.getAssetInfo(t._uuid);n&&!n.redirect&&Lw.tryRelease(t,!0)}))},t._destroy=function(){this._config.destroy()},j(e,[{key:"config",get:function(){return this._config}},{key:"name",get:function(){return this._config.name}},{key:"deps",get:function(){return this._config.deps}},{key:"base",get:function(){return this._config.base}}]),e}(),Yw=e("resources",new Xw);function Kw(e,t,n){var i=new Image;function r(){i.removeEventListener("load",r),i.removeEventListener("error",a),n&&n(null,i)}function a(){i.removeEventListener("load",r),i.removeEventListener("error",a),n&&n(new Error(b(4930,e)))}return"file:"!==window.location.protocol&&(i.crossOrigin="anonymous"),i.addEventListener("load",r),i.addEventListener("error",a),i.src=e,i}function Zw(e,t,n,i){var r=new XMLHttpRequest,a="download failed: "+e+", status: ";if(r.open("GET",e,!0),void 0!==t.xhrResponseType&&(r.responseType=t.xhrResponseType),void 0!==t.xhrWithCredentials&&(r.withCredentials=t.xhrWithCredentials),void 0!==t.xhrMimeType&&r.overrideMimeType&&r.overrideMimeType(t.xhrMimeType),void 0!==t.xhrTimeout&&(r.timeout=t.xhrTimeout),t.xhrHeader)for(var s in t.xhrHeader)r.setRequestHeader(s,t.xhrHeader[s]);return r.onload=function(){200===r.status||0===r.status?i&&i(null,r.response):i&&i(new Error(""+a+r.status+"(no response)"))},n&&(r.onprogress=function(e){e.lengthComputable&&n(e.loaded,e.total)}),r.onerror=function(){i&&i(new Error(""+a+r.status+"(error)"))},r.ontimeout=function(){i&&i(new Error(""+a+r.status+"(time out)"))},r.onabort=function(){i&&i(new Error(""+a+r.status+"(abort)"))},r.send(null),r}i.resources=Yw;var Qw={};function Jw(e,t,n){if(Qw[e])return n&&n(null),null;var i=document.createElement("script");function r(){i.parentNode.removeChild(i),i.removeEventListener("load",r,!1),i.removeEventListener("error",a,!1),Qw[e]=!0,n&&n(null)}function a(){i.parentNode.removeChild(i),i.removeEventListener("load",r,!1),i.removeEventListener("error",a,!1),n&&n(new Error(b(4928,e)))}return"file:"!==window.location.protocol&&(i.crossOrigin="anonymous"),i.async=t.scriptAsyncLoading||!1,i.src=e,i.addEventListener("load",r,!1),i.addEventListener("error",a,!1),document.body.appendChild(i),i}var $w=/^(?:\w+:\/\/|\.+\/).+/,eI=function(e,t,n){(mg.capabilities.imageBitmap&&i.assetManager.allowImageBitmap?tI:Kw)(e,t,n)},tI=function(e,t,n){t.xhrResponseType="blob",Zw(e,t,t.onFileProgress,n)},nI=function(e,t,n){t.xhrResponseType="json",Zw(e,t,t.onFileProgress,n)},iI=function(e,t,n){t.xhrResponseType="arraybuffer",Zw(e,t,t.onFileProgress,n)},rI=function(e,t,n){t.xhrResponseType="text",Zw(e,t,t.onFileProgress,n)},aI=function(e,t,n){var i=F(e),r=e;$w.test(r)||(r=-1!==sI.remoteBundles.indexOf(i)?sI.remoteServerAddress+"remote/"+i:"assets/"+i);var a=t.version||sI.bundleVers[i],s=0,o=null,c=null;nI(r+"/config."+(a?a+".":"")+"json",t,(function(e,t){e&&(c=e),(o=t)&&(o.base=r+"/"),2==++s&&n(c,o)})),Jw(r+"/index."+(a?a+".":"")+"js",t,(function(e){e?(c=e,2==++s&&n(e)):sI.importBundleEntry(i).then((function(){2==++s&&n(c,o)})).catch((function(e){c=e,2==++s&&n(c)}))}))},sI=new(function(){function e(){this.maxConcurrency=16,this.maxRequestsPerFrame=16,this.maxRetryCount=3,this.appendTimeStamp=!1,this.limited=!0,this.retryInterval=2e3,this.bundleVers=null,this.remoteBundles=[],this.downloadDomImage=Kw,this.downloadDomAudio=null,this.downloadFile=Zw,this.downloadScript=Jw,this._downloaders={".png":eI,".jpg":eI,".bmp":eI,".jpeg":eI,".gif":eI,".ico":eI,".tiff":eI,".webp":eI,".image":eI,".pvr":iI,".pkm":iI,".astc":iI,".txt":rI,".xml":rI,".vsh":rI,".fsh":rI,".atlas":rI,".tmx":rI,".tsx":rI,".json":nI,".ExportJson":nI,".plist":rI,".fnt":rI,".binary":iI,".bin":iI,".dbbin":iI,".skel":iI,".js":Jw,bundle:aI,default:rI},this._downloading=new Lh,this._queue=[],this._queueDirty=!1,this._totalNum=0,this._totalNumThisPeriod=0,this._lastDate=-1,this._checkNextPeriod=!1,this._remoteServerAddress="",this._maxInterval=1/30}var n=e.prototype;return n.init=function(e,t,n){void 0===e&&(e=""),void 0===t&&(t={}),void 0===n&&(n=[]),this._downloading.clear(),this._queue.length=0,this._remoteServerAddress=e,this.bundleVers=t,this.remoteBundles=n},n.register=function(e,t){"object"==typeof e?He(this._downloaders,e):this._downloaders[e]=t},n.importBundleEntry=function(e){return t.import("virtual:///prerequisite-imports/"+e)},n.download=function(e,t,n,i,r){var a=this,s=Gh.get(e);if(s)r(null,s);else{var o=this._downloading.get(e);if(o){o.push(r);var c=this._queue.find((function(t){return t.id===e}));if(!c)return;var l=i.priority||0;c.priority<l&&(c.priority=l,this._queueDirty=!0)}else{var u=void 0!==i.maxRetryCount?i.maxRetryCount:this.maxRetryCount,h=void 0!==i.maxConcurrency?i.maxConcurrency:this.maxConcurrency,_=void 0!==i.maxRequestsPerFrame?i.maxRequestsPerFrame:this.maxRequestsPerFrame,f=this._downloaders[n]||this._downloaders.default;!function e(t,n,i,r,a){void 0===a&&(a=0),t(a,(function(s,o){a++,!s||a>n?r&&r(s,o):setTimeout((function(){e(t,n,i,r,a)}),i)}))}((function(n,s){if(0===n&&a._downloading.add(e,[r]),a.limited){a._updateTime();var o=function(e,t){a._totalNum--,a._handleQueueInNextFrame(h,_),s(e,t)};a._totalNum<h&&a._totalNumThisPeriod<_?(f(Uw(t,a.appendTimeStamp),i,o),a._totalNum++,a._totalNumThisPeriod++):(a._queue.push({id:e,priority:i.priority||0,url:t,options:i,done:o,handler:f}),a._queueDirty=!0,a._totalNum<h&&a._handleQueueInNextFrame(h,_))}else f(Uw(t,a.appendTimeStamp),i,s)}),u,this.retryInterval,(function(t,n){t||Gh.add(e,n);for(var i=a._downloading.remove(e),r=0,s=i.length;r<s;r++)i[r](t,n)}))}}},n.loadSubpackage=function(e,t){i.assetManager.loadBundle(e,null,t)},n._updateTime=function(){var e=Date.now(),t=i.director.getDeltaTime(),n=t>this._maxInterval?this._maxInterval:t;e-this._lastDate>1e3*n&&(this._totalNumThisPeriod=0,this._lastDate=e)},n._handleQueue=function(e,t){for(this._checkNextPeriod=!1,this._updateTime();this._queue.length>0&&this._totalNum<e&&this._totalNumThisPeriod<t;){this._queueDirty&&(this._queue.sort((function(e,t){return e.priority-t.priority})),this._queueDirty=!1);var n=this._queue.pop();if(!n)break;this._totalNum++,this._totalNumThisPeriod++,n.handler(Uw(n.url,this.appendTimeStamp),n.options,n.done)}this._handleQueueInNextFrame(e,t)},n._handleQueueInNextFrame=function(e,t){!this._checkNextPeriod&&this._queue.length>0&&(At(this._handleQueue.bind(this),e,t),this._checkNextPeriod=!0)},j(e,[{key:"remoteServerAddress",get:function(){return this._remoteServerAddress}}]),e}());function oI(e,t,n,i){var r=null,a=null;try{(r=new G_)._nativeUrl=e,r._nativeAsset=t}catch(e){a=e}i(a,r)}function cI(e,t,n,i){var r=new Vx;r.json=t,i(null,r)}function lI(e,t,n,i){var r=new Hx;r.text=t,i(null,r)}function uI(e,t,n,i){var r=new Ex;r._nativeUrl=e,r._nativeAsset=t,i(null,r)}function hI(e,t,n,i){var r=new I_;r._nativeUrl=e,r._nativeAsset=t,i(null,r)}function _I(e,t,n,i){var r=Hh.get(t.name);r||(r=t.name===qh.RESOURCES?Yw:new Xw,t.base=t.base||e+"/",r.init(t)),i(null,r)}var fI=new(function(){function e(){this._creating=new Lh,this._producers={".png":oI,".jpg":oI,".bmp":oI,".jpeg":oI,".gif":oI,".ico":oI,".tiff":oI,".webp":oI,".image":oI,".pvr":oI,".pkm":oI,".txt":lI,".xml":lI,".vsh":lI,".fsh":lI,".atlas":lI,".tmx":lI,".tsx":lI,".fnt":lI,".json":cI,".ExportJson":cI,".binary":uI,".bin":uI,".dbbin":uI,".skel":uI,bundle:_I,default:hI}}var t=e.prototype;return t.register=function(e,t){"object"==typeof e?st.mixin(this._producers,e):this._producers[e]=t},t.create=function(e,t,n,i,r){var a=this,s=this._producers[n]||this._producers.default,o=Uh.get(e);if(i.reloadAsset||!o){var c=this._creating.get(e);c?c.push(r):(this._creating.add(e,[r]),s(e,t,i,(function(t,n){!t&&n instanceof I_&&(n._uuid=e,kw(e,n,i.cacheAsset));for(var r=a._creating.remove(e),s=0,o=r.length;s<o;s++)r[s](t,n)})))}else r(null,o)},e}()),dI=new(function(){function e(){this._loading=new Lh,this._unpackers={".json":this.unpackJson}}var t=e.prototype;return t.unpackJson=function(e,t,n,i){var r=st.createMap(!0),a=null;if(Array.isArray(t)){(t=function(e){if(e[0]<1)throw new Error(b(5304,e[0]));Ef(e,!0,void 0),Tf(e);for(var t=new bf(e[0]),n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=0;o<s.length;++o)s[o].unshift(t,n,i,r,a);return s}(t)).length!==e.length&&A(4915);for(var s=0;s<e.length;s++)r[e[s]+"@import"]=t[s]}else{var o=st._getClassId(md);if(t.type===o&&t.data){var c=t.data;c.length!==e.length&&A(4915);for(var l=0;l<e.length;l++)r[e[l]+"@import"]=wf(o,{base:c[l][0],mipmaps:c[l][1]})}else a=new Error("unmatched type pack!"),r=null}i(a,r)},t.init=function(){this._loading.clear()},t.register=function(e,t){"object"==typeof e?st.mixin(this._unpackers,e):this._unpackers[e]=t},t.unpack=function(e,t,n,i,r){t?(0,this._unpackers[n])(e,t,i,r):r(new Error("package data is wrong!"))},t.load=function(e,t,n){var i=this;if(!e.isNative&&e.info&&e.info.packs)if(Gh.has(e.id))n(null,Gh.get(e.id));else{var r=e.info.packs,a=r.find((function(e){return i._loading.has(e.uuid)}));if(a)this._loading.get(a.uuid).push({onComplete:n,id:e.id});else{a=r[0],this._loading.add(a.uuid,[{onComplete:n,id:e.id}]);var s=a_(a.uuid,{ext:a.ext,bundle:e.config.name});sI.download(a.uuid,s,a.ext,e.options,(function(t,n){Gh.remove(a.uuid),t&&f(t.message,t.stack),i.unpack(a.packedUuids,n,a.ext,e.options,(function(e,n){if(!e)for(var r in n)Gh.add(r,n[r]);for(var s=i._loading.remove(a.uuid),o=0,c=s.length;o<c;o++){var l=s[o];if(t||e)l.onComplete(t||e);else{var u=n[l.id];u?l.onComplete(null,u):l.onComplete(new Error("can not retrieve data from package"))}}}))}))}}else sI.download(e.id,e.url,e.ext,e.options,n)},e}());function pI(e,t){var n=!1;e.progress||(e.progress={finish:0,total:e.input.length,canInvoke:!0},n=!0);var r=e.options,a=e.progress,s=[],o=a.total;r.__exclude__=r.__exclude__||Object.create(null),e.output=[],Vw(e.input,(function(r,c){if(!r.isNative&&Uh.has(r.uuid)){var l=Uh.get(r.uuid);return l.addRef(),gI(r,e,l,null,l.__asyncLoadAssets__,s,o),void c()}dI.load(r,e.options,(function(l,u){l?e.isFinish||(!i.assetManager.force||n?(f(l.message,l.stack),a.canInvoke=!1,t(l)):gI(r,e,null,null,!1,s,o)):e.isFinish||gI(r,e,null,u,!r.isNative,s,o),c()}))}),(function(){if(e.isFinish)return zw(e,!0),void e.dispatch("error");if(s.length>0){var i=Yh.create({input:s,progress:a,options:r,onProgress:e.onProgress,onError:Yh.prototype.recycle,onComplete:function(r){var a;r||((a=e.output).push.apply(a,i.output),i.recycle()),n&&mI(e),t(r)}});Wh.async(i)}else n&&mI(e),t()}))}function mI(e){for(var t=e.output,n=0,i=t.length;n<i;n++)t[n].content&&t[n].content.decRef(!1)}function gI(e,t,n,i,r,a,s){var o=t.options.__exclude__,c=t.progress;e.content=n,e.file=i,t.output.push(e),r&&(o[e.uuid]=!0,Gw(e.uuid,i||n,o,a,!0,!1,e.config),c.total=s+a.length),c.canInvoke&&t.dispatch("progress",++c.finish,c.total,e)}var vI=new(function(e){function t(){return e.apply(this,arguments)||this}X(t,e);var n=t.prototype;return n.parse=function(e){var t=this._parseXML(e).documentElement;if("plist"!==t.tagName)return E(5100),{};for(var n=null,i=0,r=t.childNodes.length;i<r&&1!==(n=t.childNodes[i]).nodeType;i++);return this._parseNode(n)},n._parseNode=function(e){var t=null,n=e.tagName;if("dict"===n)t=this._parseDict(e);else if("array"===n)t=this._parseArray(e);else if("string"===n)if(1===e.childNodes.length)t=e.firstChild.nodeValue;else{t="";for(var i=0;i<e.childNodes.length;i++)t+=e.childNodes[i].nodeValue}else"false"===n?t=!1:"true"===n?t=!0:"real"===n?t=parseFloat(e.firstChild.nodeValue):"integer"===n&&(t=parseInt(e.firstChild.nodeValue,10));return t},n._parseArray=function(e){for(var t=[],n=0,i=e.childNodes.length;n<i;n++){var r=e.childNodes[n];1===r.nodeType&&t.push(this._parseNode(r))}return t},n._parseDict=function(e){for(var t={},n="",i=0,r=e.childNodes.length;i<r;i++){var a=e.childNodes[i];1===a.nodeType&&("key"===a.tagName?n=a.firstChild.nodeValue:t[n]=this._parseNode(a))}return t},t}(function(){function e(){this._parser=null,window.DOMParser&&(this._parser=new DOMParser)}var t=e.prototype;return t.parse=function(e){return this._parseXML(e)},t._parseXML=function(e){if(this._parser)return this._parser.parseFromString(e,"text/xml");throw new Error("Dom parser is not supported in this platform!")},e}()));function yI(e,t){return e[t]<<8|e[t+1]}var SI=new(function(){function e(){this._parsing=new Lh,this._parsers={".png":this.parseImage,".jpg":this.parseImage,".bmp":this.parseImage,".jpeg":this.parseImage,".gif":this.parseImage,".ico":this.parseImage,".tiff":this.parseImage,".webp":this.parseImage,".image":this.parseImage,".pvr":this.parsePVRTex,".pkm":this.parsePKMTex,".astc":this.parseASTCTex,".mp3":this.parseAudio,".ogg":this.parseAudio,".wav":this.parseAudio,".m4a":this.parseAudio,".plist":this.parsePlist,import:this.parseImport}}var t=e.prototype;return t.parseImage=function(e,t,n){e instanceof HTMLImageElement?n(null,e):createImageBitmap(e,{premultiplyAlpha:"none"}).then((function(e){n(null,e)}),(function(e){n(e,null)}))},t.parseAudio=function(e,t,n){e instanceof ArrayBuffer?mg.__audioSupport.context.decodeAudioData(e,(function(e){n(null,e)}),(function(e){n(new Error("Error with decoding audio data"+e.err),null)})):n(null,e)},t.parsePVRTex=function(e,t,n){var i=null,r=null;try{var a=e instanceof ArrayBuffer?e:e.buffer,s=new Int32Array(a,0,13);if(55727696===s[0]){var o=s[7],c=s[6],l=s[12]+52;r={_data:new Uint8Array(a,l),_compressed:!0,width:o,height:c,format:0}}else{if(559044176!==s[11])throw new Error("Invalid magic number in PVR header");var u=s[0],h=s[1],_=s[2];r={_data:new Uint8Array(a,u),_compressed:!0,width:_,height:h,format:0}}}catch(e){i=e}n(i,r)},t.parsePKMTex=function(e,t,n){var i=null,r=null;try{var a=e instanceof ArrayBuffer?e:e.buffer,s=new Uint8Array(a),o=yI(s,6);if(0!==o&&1!==o&&3!==o)throw new Error("Invalid magic number in ETC header");var c=yI(s,12),l=yI(s,14);yI(s,8),yI(s,10),r={_data:new Uint8Array(a,16),_compressed:!0,width:c,height:l,format:0}}catch(e){i=e}n(i,r)},t.parseASTCTex=function(e,t,n){var i=null,r=null;try{var a=e instanceof ArrayBuffer?e:e.buffer,s=new Uint8Array(a);if(1554098963!==s[0]+(s[1]<<8)+(s[2]<<16)+(s[3]<<24))throw new Error("Invalid magic number in ASTC header");var o=s[4],c=s[5],l=s[6];if((o<3||o>6||c<3||c>6||l<3||l>6)&&(o<4||7===o||9===o||11===o||o>12||c<4||7===c||9===c||11===c||c>12||1!==l))throw new Error("Invalid block number in ASTC header");var u=function(e,t){return 4===e?O_.RGBA_ASTC_4x4:5===e?4===t?O_.RGBA_ASTC_5x4:O_.RGBA_ASTC_5x5:6===e?5===t?O_.RGBA_ASTC_6x5:O_.RGBA_ASTC_6x6:8===e?5===t?O_.RGBA_ASTC_8x5:6===t?O_.RGBA_ASTC_8x6:O_.RGBA_ASTC_8x8:10===e?5===t?O_.RGBA_ASTC_10x5:6===t?O_.RGBA_ASTC_10x6:8===t?O_.RGBA_ASTC_10x8:O_.RGBA_ASTC_10x10:10===t?O_.RGBA_ASTC_12x10:O_.RGBA_ASTC_12x12}(o,c),h=s[7]+(s[8]<<8)+(s[9]<<16),_=s[10]+(s[11]<<8)+(s[12]<<16);s[13],s[14],s[15],r={_data:new Uint8Array(a,16),_compressed:!0,width:h,height:_,format:u}}catch(e){i=e}n(i,r)},t.parsePlist=function(e,t,n){var i=null,r=vI.parse(e);r||(i=new Error("parse failed")),n(i,r)},t.parseImport=function(e,t,n){if(e){var i=null,r=null;try{i=Jf(e,t)}catch(e){r=e}n(r,i)}else n(new Error("The json file of asset "+t.__uuid__+" is empty or missing"))},t.init=function(){this._parsing.clear()},t.register=function(e,t){"object"==typeof e?He(this._parsers,e):this._parsers[e]=t},t.parse=function(e,t,n,i,r){var a=this,s=kh.get(e);if(s)r(null,s);else{var o=this._parsing.get(e);if(o)o.push(r);else{var c=this._parsers[n];c?(this._parsing.add(e,[r]),c(t,i,(function(t,n){t?Gh.remove(e):i_(n)||kh.add(e,n);for(var i=a._parsing.remove(e),r=0,s=i.length;r<s;r++)i[r](t,n)}))):r(null,t)}}},e}());function EI(e,t){var n=!1;e.progress||(e.progress={finish:0,total:e.input.length,canInvoke:!0},n=!0);var r=e.options,a=e.progress;r.__exclude__=r.__exclude__||Object.create(null),e.output=[],Vw(e.input,(function(s,o){var c=Yh.create({input:s,onProgress:e.onProgress,options:r,progress:a,onComplete:function(r,l){r&&!e.isFinish&&(!i.assetManager.force||n?(f(r.message,r.stack),a.canInvoke=!1,t(r)):a.canInvoke&&e.dispatch("progress",++a.finish,a.total,s)),e.output.push(l),c.recycle(),o(null)}});TI.async(c)}),(function(){if(r.__exclude__=null,e.isFinish)return zw(e,!0),void e.dispatch("error");!function(e){var t=e.source;if(e.options.__outputAsArray__||1!==t.length)for(var n=e.output=[],i=0,r=t.length;i<r;i++)n.push(t[i].content);else e.output=t[0].content}(e),zw(e,!0),t()}))}var TI=new Fh("loadOneAsset",[function(e,t){var n=e.output=e.input,i=n.options,r=n.isNative,a=n.uuid,s=n.file,o=i.reloadAsset;s||!o&&!r&&Uh.has(a)?t():dI.load(n,e.options,(function(e,i){n.file=i,t(e)}))},function(e,t){var n=e.output=e.input,i=e.progress,r=e.options.__exclude__,a=n.id,s=n.file,o=n.options;if(n.isNative)SI.parse(a,s,n.ext,o,(function(r,s){r?t(r):(n.content=s,i.canInvoke&&e.dispatch("progress",++i.finish,i.total,n),Gh.remove(a),kh.remove(a),t())}));else{var c=n.uuid;if(c in r){var l=r[c],u=l.finish,h=l.content,_=l.err,f=l.callbacks;i.canInvoke&&e.dispatch("progress",++i.finish,i.total,n),u||function e(t,n,i,r){if(void 0===r&&(r={}),!i[n]||r[n])return!1;r[n]=!0;var a=!1,s=ed.getDeps(n);if(s)for(var o=0,c=s.length;o<c;o++){var l=s[o];if(l===t||e(t,l,i,r)){a=!0;break}}return a}(c,c,r)?(h&&h.addRef(),n.content=h,t(_)):f.push({done:t,item:n})}else if(!o.reloadAsset&&Uh.has(c)){var d=Uh.get(c);o.__asyncLoadAssets__||!d.__asyncLoadAssets__?(n.content=d.addRef(),i.canInvoke&&e.dispatch("progress",++i.finish,i.total,n),t()):AI(e,d,t,!1)}else o.__uuid__=c,SI.parse(a,s,"import",o,(function(n,i){n?t(n):AI(e,i,t,!0)}))}}]);function AI(e,t,n,i){var r=e.input,a=e.progress,s=r,o=s.uuid,c=s.id,l=s.options,u=s.config,h=l.__asyncLoadAssets__,_=l.cacheAsset,d=[];t.addRef&&t.addRef(),Gw(o,t,Object.create(null),d,!1,h,u),a.canInvoke&&e.dispatch("progress",++a.finish,a.total+=d.length,r);var p=e.options.__exclude__[o]={content:t,finish:!1,callbacks:[{done:n,item:r}]},m=Yh.create({input:d,options:e.options,onProgress:e.onProgress,onError:Yh.prototype.recycle,progress:a,onComplete:function(e){if(t.decRef&&t.decRef(!1),t.__asyncLoadAssets__=h,p.finish=!0,p.err=e,!e){for(var n,r=Array.isArray(m.output)?m.output:[m.output],a=Object.create(null),s=Z(r);!(n=s()).done;){var l=n.value;l&&(a[l instanceof I_?l._uuid+"@import":o+"@native"]=l)}if(i){Hw(o,t,a);try{!t.onLoaded||t.__onLoadedInvoked__||t.__nativeDepend__||(t.onLoaded(),t.__onLoadedInvoked__=!0)}catch(e){f(e.message,e.stack)}Gh.remove(c),kh.remove(c),kw(o,t,_)}else if(t.__nativeDepend__){Hw(o,t,a);try{!t.onLoaded||t.__onLoadedInvoked__||t.__nativeDepend__||(t.onLoaded(),t.__onLoadedInvoked__=!0)}catch(e){f(e.message,e.stack)}}m.recycle()}for(var u=p.callbacks,d=0,g=u.length;d<g;d++){var v=u[d];t.addRef&&t.addRef(),v.item.content=t,v.done(e)}u.length=0}});Vh.async(m)}function xI(e,t){var n=e.options,i=Object.create(null),r=Object.create(null);for(var a in n)switch(a){case zh.PATH:case zh.UUID:case zh.DIR:case zh.SCENE:case zh.URL:break;case"__requestType__":case"__isNative__":case"ext":case"type":case"__nativeName__":case"audioLoadMode":case"bundle":i[a]=n[a];break;case"__exclude__":case"__outputAsArray__":r[a]=n[a];break;default:i[a]=n[a],r[a]=n[a]}e.options=r;var s=Yh.create({input:e.input,options:i}),o=null;try{e.output=e.source=jh.sync(s)}catch(e){o=e;for(var c=0,l=s.output.length;c<l;c++)s.output[c].recycle()}s.recycle(),t(o)}var CI=function(){function e(){this.uuid="",this.url="",this.ext=".json",this.content=null,this.file=null,this.info=null,this.config=null,this.isNative=!1,this.options=Object.create(null),this._id=""}return e.create=function(){return 0!==e._deadPool.length?e._deadPool.pop():new e},e.prototype.recycle=function(){e._deadPool.length!==e.MAX_DEAD_NUM&&(this._id="",this.uuid="",this.url="",this.ext=".json",this.content=null,this.file=null,this.info=null,this.config=null,this.isNative=!1,this.options=Object.create(null),e._deadPool.push(this))},j(e,[{key:"id",get:function(){return this._id||(this._id=this.uuid+"@"+(this.isNative?"native":"import")),this._id}}]),e}();CI.MAX_DEAD_NUM=500,CI._deadPool=[];var RI=[];function bI(e){var t=e.options,n=Array.isArray(e.input)?e.input:[e.input];e.output=[];for(var i=function(i){var r=n[i],a=CI.create(),s=null,o=null;if("string"==typeof r&&((r=Object.create(null))[t.__requestType__||zh.UUID]=n[i]),"object"==typeof r)for(var c in ke(r,t),r.preset&&ke(r,Xh[r.preset]),r){switch(c){case zh.UUID:if("break"===function(){var e=a.uuid=$h(r.uuid);if(!r.bundle){var t=Hh.find((function(t){return!!t.getAssetInfo(e)}));r.bundle=t&&t.name}if(Hh.has(r.bundle)){if(s=Hh.get(r.bundle).config,(o=s.getAssetInfo(e))&&o.redirect){if(!Hh.has(o.redirect))throw new Error("Please load bundle "+o.redirect+" first");s=Hh.get(o.redirect).config,o=s.getAssetInfo(e)}a.config=s,a.info=o}return a.ext=r.ext||".json","break"}())break;case"__requestType__":case"ext":case"bundle":case"preset":case"type":break;case zh.DIR:if(Hh.has(r.bundle)){Hh.get(r.bundle).config.getDirWithPath(r.dir,r.type,RI);for(var l,u=Z(RI);!(l=u()).done;){var h=l.value;n.push({uuid:h.uuid,__isNative__:!1,ext:".json",bundle:r.bundle})}RI.length=0}a.recycle(),a=null;break;case zh.PATH:if(Hh.has(r.bundle)){if(s=Hh.get(r.bundle).config,(o=s.getInfoWithPath(r.path,r.type))&&o.redirect){if(!Hh.has(o.redirect))throw new Error("you need to load bundle "+o.redirect+" first");s=Hh.get(o.redirect).config,o=s.getAssetInfo(o.uuid)}if(!o)throw a.recycle(),new Error("Bundle "+r.bundle+" doesn't contain "+r.path);a.config=s,a.uuid=o.uuid,a.info=o}a.ext=r.ext||".json";break;case zh.SCENE:if(!r.bundle){var _=Hh.find((function(e){return!!e.getSceneInfo(r.scene)}));r.bundle=_&&_.name}if(Hh.has(r.bundle)){if(s=Hh.get(r.bundle).config,(o=s.getSceneInfo(r.scene))&&o.redirect){if(!Hh.has(o.redirect))throw new Error("you need to load bundle "+o.redirect+" first");s=Hh.get(o.redirect).config,o=s.getAssetInfo(o.uuid)}if(!o)throw a.recycle(),new Error("Bundle "+s.name+" doesn't contain scene "+r.scene);a.config=s,a.uuid=o.uuid,a.info=o}break;case"__isNative__":a.isNative=r.__isNative__;break;case zh.URL:a.url=r.url,a.uuid=r.uuid||r.url,a.ext=r.ext||B(r.url),a.isNative=void 0===r.__isNative__||r.__isNative__;break;default:a.options[c]=r[c]}if(!a)break}if(!a)return"continue";if(e.output.push(a),!a.uuid&&!a.url)throw new Error("Can not parse this input:"+JSON.stringify(r))},r=0;r<n.length;r++)i(r);return null}function wI(e){for(var t=e.output=e.input,n=0;n<t.length;n++){var r=t[n];if(!r.url){var a,s,o=r.config;s=r.isNative?o&&o.nativeBase?o.base+o.nativeBase:i.assetManager.generalNativeBase:o&&o.importBase?o.base+o.importBase:i.assetManager.generalImportBase;var c=r.uuid,l="";r.info&&(l=r.isNative?r.info.nativeVer?"."+r.info.nativeVer:"":r.info.ver?"."+r.info.ver:""),a=".ttf"===r.ext?s+"/"+c.slice(0,2)+"/"+c+l+"/"+r.options.__nativeName__:s+"/"+c.slice(0,2)+"/"+c+l+r.ext,r.url=a}}return null}var II=e("AssetManager",function(){function e(){this.pipeline=Vh.append(xI).append(EI),this.fetchPipeline=Wh.append(xI).append(pI),this.transformPipeline=jh.append(bI).append(wI),this.bundles=Hh,this.assets=Uh,this.generalImportBase="",this.generalNativeBase="",this.dependUtil=ed,this.force=!1,this.allowImageBitmap=!mg.isMobile,this.utils=s_,this.downloader=sI,this.parser=SI,this.packManager=dI,this.cacheAsset=!0,this.cacheManager=null,this.presets=Xh,this.factory=fI,this.preprocessPipe=xI,this.fetchPipe=pI,this.loadPipe=EI,this.references=null,this._releaseManager=Lw,this._files=Gh,this._parsed=kh,this._parsePipeline=null}var t=e.prototype;return t.init=function(e){void 0===e&&(e={}),this._files.clear(),this._parsed.clear(),this._releaseManager.init(),this.assets.clear(),this.bundles.clear(),this.packManager.init(),this.downloader.init(e.server,e.bundleVers,e.remoteBundles),this.parser.init(),this.dependUtil.init();var t=e.importBase||"";t&&t.endsWith("/")&&(t=t.substr(0,t.length-1));var n=e.nativeBase||"";n&&n.endsWith("/")&&(n=n.substr(0,n.length-1)),this.generalImportBase=t,this.generalNativeBase=n},t.getBundle=function(e){return Hh.get(e)||null},t.removeBundle=function(e){e._destroy(),Hh.remove(e.name)},t.loadAny=function(e,t,n,i){var r=Ww(t,n,i),a=r.options,s=r.onProgress,o=r.onComplete;a.preset=a.preset||"default",e=Array.isArray(e)?e.slice():e;var c=new Yh({input:e,onProgress:s,onComplete:qw(o),options:a});Vh.async(c)},t.preloadAny=function(e,t,n,i){var r=Ww(t,n,i),a=r.options,s=r.onProgress,o=r.onComplete;a.preset=a.preset||"preload",e=Array.isArray(e)?e.slice():e;var c=new Yh({input:e,onProgress:s,onComplete:qw(o),options:a});Wh.async(c)},t.postLoadNative=function(e,t,n){var i=Ww(t,void 0,n),r=i.options,a=i.onComplete;if(e._native&&e.__nativeDepend__){var s=ed.getNativeDep(e._uuid);if(s){if(!Hh.has(s.bundle)){var o=Hh.find((function(t){return!!t.getAssetInfo(e._uuid)}));o&&(s.bundle=o.name)}this.loadAny(s,r,(function(t,n){t?f(t.message,t.stack):e.isValid&&e.__nativeDepend__&&(e._nativeAsset=n,e.__nativeDepend__=!1),a&&a(t)}))}}else qw(a)(null)},t.loadRemote=function(e,t,n){var i=Ww(t,void 0,n),r=i.options,a=i.onComplete;r.reloadAsset||!this.assets.has(e)?(r.__isNative__=!0,r.preset=r.preset||"remote",this.loadAny({url:e},r,null,(function(t,n){t?(f(t.message,t.stack),a&&a(t,n)):fI.create(e,n,r.ext||B(e),r,(function(e,t){a&&a(e,t)}))}))):qw(a)(null,this.assets.get(e))},t.loadBundle=function(e,t,n){var i=Ww(t,void 0,n),r=i.options,a=i.onComplete,s=F(e);this.bundles.has(s)?qw(a)(null,this.getBundle(s)):(r.preset=r.preset||"bundle",r.ext="bundle",r.__isNative__=!0,this.loadAny({url:e},r,null,(function(t,n){t?(f(t.message,t.stack),a&&a(t,n)):fI.create(e,n,"bundle",r,(function(e,t){a&&a(e,t)}))})))},t.releaseAsset=function(e){Lw.tryRelease(e,!0)},t.releaseUnusedAssets=function(){Uh.forEach((function(e){Lw.tryRelease(e)}))},t.releaseAll=function(){Uh.forEach((function(e){Lw.tryRelease(e,!0)}))},t.loadWithJson=function(){throw new Error("Only valid in Editor")},j(e,[{key:"main",get:function(){return Hh.get(qh.MAIN)||null}},{key:"resources",get:function(){return Hh.get(qh.RESOURCES)||null}}]),e}());II.Pipeline=Fh,II.Task=Yh,II.Cache=Lh,II.RequestItem=CI,II.Bundle=Xw,II.BuiltinBundleName=qh;var OI=e("assetManager",i.assetManager=new II);i.AssetManager=II;var PI=[".png",".jpg",".bmp",".jpeg",".gif",".ico",".tiff",".webp",".image",".pvr",".pkm",".astc"],MI=[".mp3",".ogg",".wav",".m4a"];function NI(){return!0}var DI={transformURL:function(e){var t=t_(e);if(!t)return e;var n=Hh.find((function(e){return!!e.getAssetInfo(t)}));if(!n)return e;var i,r=n.getAssetInfo(t);if(!(i=e.startsWith(n.base+n.config.nativeBase)?r.nativeVer||"":r.ver||"")||-1!==e.indexOf(i))return e;var a=!1;if(".ttf"===B(e)&&(a=!0),a){var s=z(e),o=F(e);e=s+"."+i+"/"+o}else e=e.replace(/.*[/\\][0-9a-fA-F]{2}[/\\]([0-9a-fA-F-@]{8,}).*/,(function(e){return e+"."+i}));return e}},BI=e("CCLoader",function(){function e(){this._autoReleaseSetting=Object.create(null),this._parseLoadResArgs=jw}var t=e.prototype;return t.load=function(e,t,n){void 0===n&&void 0!==t&&(n=t,t=null);for(var i=Array.isArray(e)?e:[e],r=0;r<i.length;r++){var a=i[r];"string"==typeof a?i[r]={url:a,__isNative__:!0}:(a.type&&(a.ext="."+a.type,a.type=void 0),a.url&&(a.__isNative__=!0))}var s=[],o=[];OI.loadAny(i,null,(function(e,n,i){i.content&&(PI.includes(i.ext)?s.push(i.content):MI.includes(i.ext)&&o.push(i.content)),t&&t(e,n,i)}),(function(e,t){var r=null;if(!e){t=Array.isArray(t)?t:[t];for(var a=function(e){var n=t[e];if(!(n instanceof I_)){var r=n,a=i[e].url;s.includes(r)?fI.create(a,n,".png",{},(function(n,i){r=t[e]=i})):o.includes(r)&&fI.create(a,n,".mp3",{},(function(n,i){r=t[e]=i})),Uh.add(a,r)}},c=0;c<t.length;c++)a(c);if(t.length>1){var l=Object.create(null);t.forEach((function(e){l[e._uuid]=e})),r={isCompleted:NI,_map:l}}else r=t[0]}n&&n(e,r)}))},t.getXMLHttpRequest=function(){return new XMLHttpRequest},t.getItem=function(e){return OI.assets.has(e)?{content:OI.assets.get(e)}:null},t.loadRes=function(e,t,n,i){var r=this._parseLoadResArgs(t,n,i),a=r.type,s=r.onProgress,o=r.onComplete,c=B(e);c&&!Yw.getInfoWithPath(e,a)&&(e=e.slice(0,-c.length)),Yw.load(e,a,s,o)},t.loadResArray=function(e,t,n,i){var r=this._parseLoadResArgs(t,n,i),a=r.type,s=r.onProgress,o=r.onComplete;e.forEach((function(t,n){var i=B(t);i&&!Yw.getInfoWithPath(t,a)&&(e[n]=t.slice(0,-i.length))})),Yw.load(e,a,s,o)},t.loadResDir=function(e,t,n,i){var r=this._parseLoadResArgs(t,n,i),a=r.type,s=r.onProgress,o=r.onComplete;Yw.loadDir(e,a,s,(function(t,n){var i=[];t||(i=Yw.getDirWithPath(e,a).map((function(e){return e.path}))),o&&o(t,n,i)}))},t.getRes=function(e,t){return Uh.has(e)?Uh.get(e):Yw.get(e,t)},t.getResCount=function(){return Uh.count},t.getDependsRecursively=function(e){if(!e)return[];var t="string"==typeof e?e:e._uuid;return ed.getDepsRecursively(t).concat([t])},t.addDownloadHandlers=function(e){var t=Object.create(null),n=function(n){var i=e[n];t["."+n]=function(e,t,n){i({url:e},n)}};for(var i in e)n(i);sI.register(t)},t.addLoadHandlers=function(e){var t=Object.create(null),n=function(n){var i=e[n];t["."+n]=function(e,t,n){i({content:e},n)}};for(var i in e)n(i);SI.register(t)},t.release=function(e){if(Array.isArray(e))for(var t=0;t<e.length;t++){var n=e[t];"string"==typeof n&&(n=Uh.get(n)),OI.releaseAsset(n)}else e&&("string"==typeof e&&(e=Uh.get(e)),OI.releaseAsset(e))},t.releaseAsset=function(e){OI.releaseAsset(e)},t.releaseRes=function(e,t){Yw.release(e,t)},t.releaseAll=function(){OI.releaseAll(),Uh.clear()},t.removeItem=function(e){return!!Uh.remove(e)},t.setAutoRelease=function(e,t){"object"==typeof e&&(e=e._uuid),this._autoReleaseSetting[e]=!!t},t.setAutoReleaseRecursively=function(e,t){"object"==typeof e&&(e=e._uuid),t=!!t,this._autoReleaseSetting[e]=t;for(var n=ed.getDepsRecursively(e),i=0;i<n.length;i++)this._autoReleaseSetting[n[i]]=t},t.isAutoRelease=function(e){return"object"==typeof e&&(e=e._uuid),!!this._autoReleaseSetting[e]},j(e,[{key:"onProgress",set:function(e){Fw=e}},{key:"_cache",get:function(){return Uh._map}},{key:"md5Pipe",get:function(){return DI}},{key:"downloader",get:function(){return sI}},{key:"loader",get:function(){return OI.parser}}]),e}()),LI=e("loader",new BI),FI=e("AssetLibrary",{init:function(e){e.importBase=e.libraryPath,e.nativeBase=e.rawAssetsBase,OI.init(e),e.rawAssets&&Yw.init({base:"",deps:[],scenes:{},redirect:[],debug:!0,packs:{},types:[],versions:{import:[],native:[]},name:qh.RESOURCES,importBase:e.importBase,nativeBase:e.nativeBase,paths:e.rawAssets.assets,uuids:Object.keys(e.rawAssets.assets)})},loadAsset:function(e,t){OI.loadAny(e,t)}}),zI=e("url",{});se(zI,"url",[{name:"normalize",target:OI.utils,targetName:"assetManager.utils",newName:"normalize"},{name:"raw",targetName:"Asset.prototype",newName:"nativeUrl",customFunction:function(e){return e.startsWith("resources/")?a_({path:U(e.substr(10)),bundle:qh.RESOURCES,__isNative__:!0,ext:B(e)}):""}}]),oe(FI,"AssetLibrary",[{name:"getLibUrlNoExt",suggest:"AssetLibrary.getLibUrlNoExt was removed, if you want to transform url, please use cc.assetManager.utils.getUrlWithUuid instead"},{name:"queryAssetInfo",suggest:"AssetLibrary.queryAssetInfo was removed"}]),oe(LI,"loader",[{name:"releaseResDir",suggest:"loader.releaseResDir was removed, please use assetManager.releaseAsset instead"},{name:"flowInDeps",suggest:"loader.flowInDeps was removed"},{name:"assetLoader",suggest:"cc.loader.assetLoader was removed, assetLoader and md5Pipe were merged into cc.assetManager.transformPipeline"}]),se(i,"cc",[{name:"loader",newName:"assetManager",logTimes:1,customGetter:function(){return LI}},{name:"AssetLibrary",newName:"assetManager",logTimes:1,customGetter:function(){return FI}},{name:"Pipeline",target:II,targetName:"AssetManager",newName:"Pipeline",logTimes:1},{name:"url",targetName:"assetManager",newName:"utils",logTimes:1,customGetter:function(){return zI}}]),oe(i,"cc",[{name:"LoadingItems",suggest:b(1400,"cc.LoadingItems","cc.AssetManager.Task")}]),se(ft,"macro",[{name:"DOWNLOAD_MAX_CONCURRENT",target:sI,targetName:"assetManager.downloader",newName:"maxConcurrency"}]),se(Ow,"director",[{name:"_getSceneUuid",targetName:"assetManager.main",newName:"getSceneInfo",customFunction:function(e){var t;return OI.main?null===(t=OI.main.getSceneInfo(e))||void 0===t?void 0:t.uuid:""}}]),se(jA,"game",[{name:"_sceneInfos",targetName:"assetManager.main",newName:"getSceneInfo",customGetter:function(){var e=[];return OI.main&&OI.main.config.scenes.forEach((function(t){e.push(t)})),e}}]);var UI,GI,kI,HI,VI,WI,jI,qI,XI,YI,KI=Lw._autoRelease;Lw._autoRelease=function(e,t,n){KI.call(Lw,e,t,n);for(var i=LI._autoReleaseSetting,r=Object.keys(i),a=0;a<r.length;a++){var s=r[a];if(!0===i[s]){var o=Uh.get(s);o&&Lw.tryRelease(o)}}};var ZI,QI,JI,$I,eO,tO,nO,iO,rO,aO,sO,oO,cO,lO,uO,hO,_O,fO,dO,pO,mO,gO,vO,yO,SO,EO,TO,AO,xO,CO,RO,bO,wO,IO,OO,PO,MO,NO,DO,BO,LO,FO,zO,UO,GO,kO,HO,VO,WO,jO,qO,XO,YO,KO,ZO,QO,JO,$O,eP,tP,nP,iP,rP,aP,sP,oP,cP,lP=e("EventHandler",(UI=ih("cc.ClickEvent"),GI=Dh(i.Node),UI((YI=function(){function e(){Q(this,"target",VI,this),Q(this,"component",WI,this),Q(this,"_componentId",jI,this),Q(this,"handler",qI,this),Q(this,"customEventData",XI,this)}e.emitEvents=function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];for(var a=0,s=t.length;a<s;a++){var o=t[a];o instanceof e&&o.emit(i)}};var t=e.prototype;return t.emit=function(e){var t=this.target;if(i.isValid(t)){this._genCompIdIfNeeded();var n=i.js._getClassById(this._componentId),r=t.getComponent(n);if(i.isValid(r)){var a=r[this.handler];"function"==typeof a&&(null!=this.customEventData&&""!==this.customEventData&&(e=e.slice()).push(this.customEventData),a.apply(r,e))}}},t._compName2Id=function(e){var t=i.js.getClassByName(e);return i.js._getClassId(t)},t._compId2Name=function(e){var t=i.js._getClassById(e);return i.js.getClassName(t)},t._genCompIdIfNeeded=function(){this._componentId||(this._componentName=this.component,this.component="")},j(e,[{key:"_componentName",get:function(){return this._genCompIdIfNeeded(),this._compId2Name(this._componentId)},set:function(e){this._componentId=this._compName2Id(e)}}]),e}(),VI=J((HI=YI).prototype,"target",[GI],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),WI=J(HI.prototype,"component",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),jI=J(HI.prototype,"_componentId",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),qI=J(HI.prototype,"handler",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),XI=J(HI.prototype,"customEventData",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),kI=HI))||kI));i.Component.EventHandler=lP;var uP,hP,_P,fP,dP,pP,mP,gP,vP,yP,SP,EP=new bn,TP=ct(Pu),AP=ct(Ou),xP=ct(Mu),CP=ct(Du),RP=ct(Nu),bP=ct({SKYBOX:qu|ds.DEPTH_STENCIL,SOLID_COLOR:ds.ALL,DEPTH_ONLY:ds.DEPTH_STENCIL,DONT_CLEAR:ds.NONE}),wP=(ZI=ih("cc.Camera"),QI=mh(),JI=_h(),$I=Rh(),eO=Sh(),tO=Dh(Ll.BitMask),nO=Rh(),iO=Sh(),rO=Dh(bP),aO=Rh(),sO=Sh(),oO=Rh(),cO=Sh(),lO=Rh(),uO=Sh(),hO=Rh(),_O=Sh(),fO=Dh(TP),dO=Rh(),pO=Sh(),mO=Dh(AP),gO=Rh(),vO=Sh(),yO=Rh(),SO=Sh(),EO=Rh(),TO=Sh(),AO=Rh(),xO=Sh(),CO=Rh(),RO=Sh(),bO=Dh(xP),wO=Rh(),IO=Sh(),OO=Dh(CP),PO=Rh(),MO=Sh(),NO=Dh(RP),DO=Rh(),BO=Sh(),LO=Rh(),FO=Sh(),zO=Dh($p),UO=Rh(),GO=Sh(),uP=ZI(kO=QI(kO=JI(kO=hh((cP=oP=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return Q(t=e.call.apply(e,[this].concat(i))||this,"_projection",VO,Y(t)),Q(t,"_priority",WO,Y(t)),Q(t,"_fov",jO,Y(t)),Q(t,"_fovAxis",qO,Y(t)),Q(t,"_orthoHeight",XO,Y(t)),Q(t,"_near",YO,Y(t)),Q(t,"_far",KO,Y(t)),Q(t,"_color",ZO,Y(t)),Q(t,"_depth",QO,Y(t)),Q(t,"_stencil",JO,Y(t)),Q(t,"_clearFlags",$O,Y(t)),Q(t,"_rect",eP,Y(t)),Q(t,"_aperture",tP,Y(t)),Q(t,"_shutter",nP,Y(t)),Q(t,"_iso",iP,Y(t)),Q(t,"_screenScale",rP,Y(t)),Q(t,"_visibility",aP,Y(t)),Q(t,"_targetTexture",sP,Y(t)),t._camera=null,t._inEditorMode=!1,t._flows=void 0,t}X(t,e);var n=t.prototype;return n.onLoad=function(){this._createCamera()},n.onEnable=function(){this.node.hasChangedFlags|=Uu.POSITION,this._camera&&this._attachToScene()},n.onDisable=function(){this._camera&&this._detachFromScene()},n.onDestroy=function(){this._camera&&(this._camera.destroy(),this._camera=null),this._targetTexture&&this._targetTexture.off("resize")},n.screenPointToRay=function(e,t,n){return n||(n=Ra.create()),this._camera&&this._camera.screenPointToRay(n,e,t),n},n.worldToScreen=function(e,t){return t||(t=new bn),this._camera&&this._camera.worldToScreen(t,e),t},n.screenToWorld=function(e,t){return t||(t=this.node.getWorldPosition()),this._camera&&this._camera.screenToWorld(t,e),t},n.convertToUINode=function(e,t,n){if(n||(n=new bn),!this._camera)return n;this.worldToScreen(e,EP);var r=t.getComponent("cc.UITransform"),a=$A.getVisibleSize(),s=EP.x-.5*this._camera.width,o=EP.y-.5*this._camera.height;return EP.x=s/i.view.getScaleX()+.5*a.width,EP.y=o/i.view.getScaleY()+.5*a.height,r&&r.convertToNodeSpaceAR(EP,n),n},n._createCamera=function(){this._camera||(this._camera=i.director.root.createCamera(),this._camera.initialize({name:this.node.name,node:this.node,projection:this._projection,window:this._inEditorMode?i.director.root&&i.director.root.mainWindow:i.director.root&&i.director.root.tempWindow,priority:this._priority}),this._camera.viewport=this._rect,this._camera.fovAxis=this._fovAxis,this._camera.fov=hn(this._fov),this._camera.orthoHeight=this._orthoHeight,this._camera.nearClip=this._near,this._camera.farClip=this._far,this._camera.clearColor=this._color,this._camera.clearDepth=this._depth,this._camera.clearStencil=this._stencil,this._camera.clearFlag=this._clearFlags,this._camera.visibility=this._visibility,this._camera.aperture=this._aperture,this._camera.shutter=this._shutter,this._camera.iso=this._iso),this._updateTargetTexture()},n._attachToScene=function(){this.node.scene&&this._camera&&(this._camera&&this._camera.scene&&this._camera.scene.removeCamera(this._camera),this._getRenderScene().addCamera(this._camera))},n._detachFromScene=function(){this._camera&&this._camera.scene&&this._camera.scene.removeCamera(this._camera)},n._chechTargetTextureEvent=function(e){var t=this;e&&e.off("resize"),this._targetTexture&&this._targetTexture.on("resize",(function(e){t._camera&&t._camera.setFixedSize(e.width,e.height)}),this)},n._updateTargetTexture=function(){if(this._camera&&this._targetTexture){var e=this._targetTexture.window;this._camera.changeTargetWindow(e),this._camera.setFixedSize(e.width,e.height)}},j(t,[{key:"camera",get:function(){return this._camera}},{key:"priority",get:function(){return this._priority},set:function(e){this._priority=e,this._camera&&(this._camera.priority=e)}},{key:"visibility",get:function(){return this._visibility},set:function(e){this._visibility=e,this._camera&&(this._camera.visibility=e)}},{key:"clearFlags",get:function(){return this._clearFlags},set:function(e){this._clearFlags=e,this._camera&&(this._camera.clearFlag=e)}},{key:"clearColor",get:function(){return this._color},set:function(e){this._color.set(e),this._camera&&(this._camera.clearColor=this._color)}},{key:"clearDepth",get:function(){return this._depth},set:function(e){this._depth=e,this._camera&&(this._camera.clearDepth=e)}},{key:"clearStencil",get:function(){return this._stencil},set:function(e){this._stencil=e,this._camera&&(this._camera.clearStencil=e)}},{key:"projection",get:function(){return this._projection},set:function(e){this._projection=e,this._camera&&(this._camera.projectionType=e)}},{key:"fovAxis",get:function(){return this._fovAxis},set:function(e){e!==this._fovAxis&&(this._fovAxis=e,this._camera&&(this._camera.fovAxis=e,e===Ou.VERTICAL?this.fov=this._fov*this._camera.aspect:this.fov=this._fov/this._camera.aspect))}},{key:"fov",get:function(){return this._fov},set:function(e){this._fov=e,this._camera&&(this._camera.fov=hn(e))}},{key:"orthoHeight",get:function(){return this._orthoHeight},set:function(e){this._orthoHeight=e,this._camera&&(this._camera.orthoHeight=e)}},{key:"near",get:function(){return this._near},set:function(e){this._near=e,this._camera&&(this._camera.nearClip=e)}},{key:"far",get:function(){return this._far},set:function(e){this._far=e,this._camera&&(this._camera.farClip=e)}},{key:"aperture",get:function(){return this._aperture},set:function(e){this._aperture=e,this._camera&&(this._camera.aperture=e)}},{key:"shutter",get:function(){return this._shutter},set:function(e){this._shutter=e,this._camera&&(this._camera.shutter=e)}},{key:"iso",get:function(){return this._iso},set:function(e){this._iso=e,this._camera&&(this._camera.iso=e)}},{key:"rect",get:function(){return this._rect},set:function(e){this._rect=e,this._camera&&(this._camera.viewport=e)}},{key:"targetTexture",get:function(){return this._targetTexture},set:function(e){if(this._targetTexture!==e){var t=this._targetTexture;this._targetTexture=e,this._chechTargetTextureEvent(t),this._updateTargetTexture(),!e&&this._camera&&(this._camera.changeTargetWindow(null),this._camera.isWindowSize=!0)}}},{key:"screenScale",get:function(){return this._screenScale},set:function(e){this._screenScale=e,this._camera&&(this._camera.screenScale=e)}},{key:"inEditorMode",get:function(){return this._inEditorMode},set:function(e){this._inEditorMode=e,this._camera&&this._camera.changeTargetWindow(e?i.director.root&&i.director.root.mainWindow:i.director.root&&i.director.root.tempWindow)}}]),t}(Kf),oP.ProjectionType=TP,oP.FOVAxis=AP,oP.ClearFlag=bP,oP.Aperture=xP,oP.Shutter=CP,oP.ISO=RP,VO=J((HO=cP).prototype,"_projection",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return TP.PERSPECTIVE}}),WO=J(HO.prototype,"_priority",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),jO=J(HO.prototype,"_fov",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 45}}),qO=J(HO.prototype,"_fovAxis",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return AP.VERTICAL}}),XO=J(HO.prototype,"_orthoHeight",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 10}}),YO=J(HO.prototype,"_near",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),KO=J(HO.prototype,"_far",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1e3}}),ZO=J(HO.prototype,"_color",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Cn("#333333")}}),QO=J(HO.prototype,"_depth",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),JO=J(HO.prototype,"_stencil",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),$O=J(HO.prototype,"_clearFlags",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return bP.SOLID_COLOR}}),eP=J(HO.prototype,"_rect",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new ti(0,0,1,1)}}),tP=J(HO.prototype,"_aperture",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return xP.F16_0}}),nP=J(HO.prototype,"_shutter",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return CP.D125}}),iP=J(HO.prototype,"_iso",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return RP.ISO100}}),rP=J(HO.prototype,"_screenScale",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),aP=J(HO.prototype,"_visibility",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Bu}}),sP=J(HO.prototype,"_targetTexture",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),J(HO.prototype,"priority",[$I,eO],Object.getOwnPropertyDescriptor(HO.prototype,"priority"),HO.prototype),J(HO.prototype,"visibility",[tO,nO,iO],Object.getOwnPropertyDescriptor(HO.prototype,"visibility"),HO.prototype),J(HO.prototype,"clearFlags",[rO,aO,sO],Object.getOwnPropertyDescriptor(HO.prototype,"clearFlags"),HO.prototype),J(HO.prototype,"clearColor",[oO,cO],Object.getOwnPropertyDescriptor(HO.prototype,"clearColor"),HO.prototype),J(HO.prototype,"clearDepth",[lO,uO],Object.getOwnPropertyDescriptor(HO.prototype,"clearDepth"),HO.prototype),J(HO.prototype,"clearStencil",[hO,_O],Object.getOwnPropertyDescriptor(HO.prototype,"clearStencil"),HO.prototype),J(HO.prototype,"projection",[fO,dO,pO],Object.getOwnPropertyDescriptor(HO.prototype,"projection"),HO.prototype),J(HO.prototype,"fovAxis",[mO,gO,vO],Object.getOwnPropertyDescriptor(HO.prototype,"fovAxis"),HO.prototype),J(HO.prototype,"fov",[yO,SO],Object.getOwnPropertyDescriptor(HO.prototype,"fov"),HO.prototype),J(HO.prototype,"orthoHeight",[EO,TO],Object.getOwnPropertyDescriptor(HO.prototype,"orthoHeight"),HO.prototype),J(HO.prototype,"near",[AO,xO],Object.getOwnPropertyDescriptor(HO.prototype,"near"),HO.prototype),J(HO.prototype,"far",[CO,RO],Object.getOwnPropertyDescriptor(HO.prototype,"far"),HO.prototype),J(HO.prototype,"aperture",[bO,wO,IO],Object.getOwnPropertyDescriptor(HO.prototype,"aperture"),HO.prototype),J(HO.prototype,"shutter",[OO,PO,MO],Object.getOwnPropertyDescriptor(HO.prototype,"shutter"),HO.prototype),J(HO.prototype,"iso",[NO,DO,BO],Object.getOwnPropertyDescriptor(HO.prototype,"iso"),HO.prototype),J(HO.prototype,"rect",[LO,FO],Object.getOwnPropertyDescriptor(HO.prototype,"rect"),HO.prototype),J(HO.prototype,"targetTexture",[zO,UO,GO],Object.getOwnPropertyDescriptor(HO.prototype,"targetTexture"),HO.prototype),kO=HO))||kO)||kO)||kO)||kO,e({Camera:uP,CameraComponent:uP}),uP);i.Camera=wP;var IP,OP,PP,MP,NP,DP,BP,LP,FP={parent:null,owner:null,subModelIdx:0},zP=e("RenderableComponent",(hP=ih("cc.RenderableComponent"),_P=Dh([em]),fP=Dh(em),dP=Rh(),pP=yh(),hP((SP=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return Q(t=e.call.apply(e,[this].concat(i))||this,"_materials",vP,Y(t)),Q(t,"_visFlags",yP,Y(t)),t._materialInstances=[],t._models=[],t}X(t,e);var n=t.prototype;return n.getMaterial=function(e){return e<0||e>=this._materials.length?null:this._materials[e]},n.setMaterial=function(e,t){e&&e instanceof sm&&console.error("Can't set a material instance to a sharedMaterial slot"),this._materials[t]=e;var n=this._materialInstances[t];n?n.parent!==this._materials[t]&&(n.destroy(),this._materialInstances[t]=null,this._onMaterialModified(t,this._materials[t])):this._onMaterialModified(t,this._materials[t])},n.getMaterialInstance=function(e){if(!this._materials[e])return null;if(!this._materialInstances[e]){FP.parent=this._materials[e],FP.owner=this,FP.subModelIdx=e;var t=new sm(FP);this.setMaterialInstance(e,t)}return this._materialInstances[e]},n.setMaterialInstance=function(e,t){t&&t.parent?t!==this._materialInstances[e]&&(this._materialInstances[e]=t,this._onMaterialModified(e,t)):t!==this._materials[e]&&this.setMaterial(t,e)},n.getRenderMaterial=function(e){return this._materialInstances[e]||this._materials[e]},n._collectModels=function(){return this._models},n._attachToScene=function(){},n._detachFromScene=function(){},n._onMaterialModified=function(){},n._onRebuildPSO=function(){},n._clearMaterials=function(){},n._onVisibilityChange=function(){},j(t,[{key:"visibility",get:function(){return this._visFlags},set:function(e){this._visFlags=e,this._onVisibilityChange(e)}},{key:"sharedMaterials",get:function(){return this._materials},set:function(e){for(var t=0;t<e.length;t++)e[t]!==this._materials[t]&&this.setMaterial(e[t],t);if(e.length<this._materials.length){for(var n=e.length;n<this._materials.length;n++)this.setMaterial(null,n);this._materials.splice(e.length)}}},{key:"materials",get:function(){for(var e=0;e<this._materials.length;e++)this._materialInstances[e]=this.getMaterialInstance(e);return this._materialInstances},set:function(e){var t=e.length-this._materials.length;if(t>0)this._materials.length=e.length,this._materialInstances.length=e.length;else if(t<0)for(var n=this._materials.length-t;n<this._materials.length;++n)this.setMaterialInstance(n,null);for(var i=0;i<this._materialInstances.length;i++)this._materialInstances[i]!=e[i]&&this.setMaterialInstance(i,e[i])}},{key:"sharedMaterial",get:function(){return this.getMaterial(0)}},{key:"material",get:function(){return this.getMaterialInstance(0)},set:function(e){1===this._materials.length&&this._materials[0]===e||this.setMaterialInstance(0,e)}}]),t}(Kf),vP=J((gP=SP).prototype,"_materials",[_P],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),yP=J(gP.prototype,"_visFlags",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Ll.Enum.NONE}}),J(gP.prototype,"sharedMaterials",[fP,dP,pP],Object.getOwnPropertyDescriptor(gP.prototype,"sharedMaterials"),gP.prototype),mP=gP))||mP));function UP(e){return"string"==typeof e||"number"==typeof e}function GP(e,t){return e instanceof t}i.RenderableComponent=zP,se(wP,"Camera",[{name:"CameraClearFlag",newName:"ClearFlag"}]),se(wP.prototype,"Camera.prototype",[{name:"color",newName:"clearColor"},{name:"depth",newName:"clearDepth"},{name:"stencil",newName:"clearStencil"}]),i.CameraComponent=wP,st.setClassAlias(wP,"cc.CameraComponent");var kP,HP,VP,WP,jP,qP,XP=ih("cc.animation.HierarchyPath")((MP=function(){function e(e){Q(this,"path",PP,this),this.path=e||""}return e.prototype.get=function(e){return e instanceof RC?e.getChildByPath(this.path)||(_('Node "'+e.name+'" has no path "'+this.path+'"'),null):(_("Target of hierarchy path should be of type Node."),null)},e}(),PP=J((OP=MP).prototype,"path",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),IP=OP))||IP,YP=ih("cc.animation.ComponentPath")((LP=function(){function e(e){Q(this,"component",BP,this),this.component=e||""}return e.prototype.get=function(e){return e instanceof RC?e.getComponent(this.component)||(_('Node "'+e.name+'" has no component "'+this.component+'"'),null):(_("Target of component path should be of type Node."),null)},e}(),BP=J((DP=LP).prototype,"component",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),NP=DP))||NP;function KP(e){for(var t=e,n=0;n<(arguments.length<=1?0:arguments.length-1);++n){var i=n+1<1||arguments.length<=n+1?void 0:arguments[n+1];if(UP(i)){if(!(i in t))return _('Target object has no property "'+i+'"'),null;t=t[i]}else t=i.get(t);if(null===t)break}return t}var ZP,QP,JP,$P,eM,tM,nM,iM,rM,aM,sM,oM=ih("cc.animation.UniformProxyFactory")((qP=function(){function e(e,t){Q(this,"passIndex",VP,this),Q(this,"uniformName",WP,this),Q(this,"channelIndex",jP,this),this.passIndex=t||0,this.uniformName=e||""}return e.prototype.forTarget=function(e){var t=e.passes[this.passIndex],n=t.getHandle(this.uniformName);if(!n)throw new Error('Material "'+e.name+'" has no uniform "'+this.uniformName+'"');var r=Jd.getPropertyTypeFromHandle(n);if(r===Ed.UBO){var a=void 0===this.channelIndex?n:t.getHandle(this.uniformName,this.channelIndex,Fa.FLOAT);if(!a)throw new Error('Uniform "'+this.uniformName+" (in material "+e.name+") has no channel "+this.channelIndex+'"');return function(e,t){for(var n,i=Z(e.shaderInfo.blocks);!(n=i()).done;)for(var r,a=Z(n.value.members);!(r=a()).done;){var s=r.value;if(s.name===t)return s.count>1}return!1}(t,this.uniformName)?{set:function(e){t.setUniformArray(a,e)}}:{set:function(e){t.setUniform(a,e)}}}if(r===Ed.SAMPLER){var s=Jd.getBindingFromHandle(n),o=t.properties[this.uniformName],c=o&&o.value?o.value+"-texture":Md(o.type),l=Xd.get(c);return l||(_("Illegal texture default value: "+c+"."),l=Xd.get("default-texture")),{set:function(e){e||(e=l);var n=e.getGFXTexture();n&&n.width&&n.height&&(t.bindTexture(s,n),e instanceof of&&t.bindSampler(s,af.getSampler(i.game._gfxDevice,e.getSamplerHash())))}}}throw new Error("Animations are not available for uniforms with property type "+r+".")},e}(),VP=J((HP=qP).prototype,"passIndex",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),WP=J(HP.prototype,"uniformName",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),jP=J(HP.prototype,"channelIndex",[Ph],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){}}),kP=HP))||kP,cM=ih("cc.animation.MorphWeightsValueProxy")(($P=function(){function e(){Q(this,"subMeshIndex",JP,this)}return e.prototype.forTarget=function(e){var t=this;return{set:function(n){e.setWeights(n,t.subMeshIndex)}}},e}(),JP=J((QP=$P).prototype,"subMeshIndex",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),ZP=QP))||ZP,lM=ih("cc.animation.MorphWeightsAllValueProxy")(eM=function(){function e(){}return e.prototype.forTarget=function(e){return{set:function(t){for(var n,i,r=null!==(n=null===(i=e.mesh)||void 0===i?void 0:i.struct.primitives.length)&&void 0!==n?n:0,a=0;a<r;++a)e.setWeights(t,a)}}},e}())||eM;function uM(e,t,n,i){var r,a,s,o,c,l,u=new t,h=new t,_=new t,f=ih(e)((l=function(){function e(e,n,i){Q(this,"dataPoint",s,this),Q(this,"inTangent",o,this),Q(this,"outTangent",c,this),this.dataPoint=e||new t,this.inTangent=n||new t,this.outTangent=i||new t}var r=e.prototype;return r.lerp=function(e,t,r){var a=this.dataPoint,s=e.dataPoint;h=n(h,this.inTangent,r),_=n(_,e.outTangent,r);var o=t*t*t,c=t*t,l=o-2*c+t,f=-2*o+3*c,d=o-c;return u=n(u,a,2*o-3*c+1),u=i(u,u,h,l),u=i(u,u,s,f),u=i(u,u,_,d)},r.getNoLerp=function(){return this.dataPoint},e}(),s=J((a=l).prototype,"dataPoint",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new t}}),o=J(a.prototype,"inTangent",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new t}}),c=J(a.prototype,"outTangent",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new t}}),r=a))||r;if(t===Dn){var d=f.prototype.lerp;f.prototype.lerp=function(e,t,n){var i=d.call(this,e,t,n);return Dn.normalize(i,i),i}}return f}var hM=e("CubicSplineVec2Value",uM("cc.CubicSplineVec2Value",qn,qn.multiplyScalar,qn.scaleAndAdd));i.CubicSplineVec2Value=hM;var _M=e("CubicSplineVec3Value",uM("cc.CubicSplineVec3Value",bn,bn.multiplyScalar,bn.scaleAndAdd));i.CubicSplineVec3Value=_M;var fM=e("CubicSplineVec4Value",uM("cc.CubicSplineVec4Value",Zn,Zn.multiplyScalar,Zn.scaleAndAdd));i.CubicSplineVec4Value=fM;var dM=e("CubicSplineQuatValue",uM("cc.CubicSplineQuatValue",Dn,Dn.multiplyScalar,Dn.scaleAndAdd));i.CubicSplineQuatValue=dM;var pM=e("CubicSplineNumberValue",ih("cc.CubicSplineNumberValue")((sM=function(){function e(e,t,n){Q(this,"dataPoint",iM,this),Q(this,"inTangent",rM,this),Q(this,"outTangent",aM,this),this.dataPoint=e,this.inTangent=t,this.outTangent=n}var t=e.prototype;return t.lerp=function(e,t,n){var i=this.dataPoint,r=e.dataPoint,a=t*t*t,s=t*t;return i*(2*a-3*s+1)+this.outTangent*n*(a-2*s+t)+r*(-2*a+3*s)+e.inTangent*n*(a-s)},t.getNoLerp=function(){return this.dataPoint},e}(),iM=J((nM=sM).prototype,"dataPoint",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),rM=J(nM.prototype,"inTangent",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),aM=J(nM.prototype,"outTangent",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),tM=nM))||tM);function mM(e,t,n){void 0===n&&(n=1e-6);for(var i=0,r=e.length-1,a=r>>>1;i<=r;a=i+r>>>1){var s=e[a];if(s>t+n)r=a-1;else{if(!(s<t-n))return a;i=a+1}}return~i}function gM(e,t,n,i,r){var a=1-r;return a*(a*(e+(3*t-e)*r)+3*n*r*r)+i*r*r*r}i.CubicSplineNumberValue=pM,e("animation",Object.freeze({__proto__:null,UniformProxyFactory:oM,MorphWeightsValueProxy:cM,MorphWeightsAllValueProxy:lM,isPropertyPath:UP,isCustomPath:GP,HierarchyPath:XP,ComponentPath:YP,evaluatePath:KP,CubicSplineVec2Value:hM,CubicSplineVec3Value:_M,CubicSplineVec4Value:fM,CubicSplineQuatValue:dM,CubicSplineNumberValue:pM})),i.bezier=gM;var vM=Math.cos,yM=Math.acos,SM=Math.max,EM=2*Math.PI,TM=Math.sqrt;function AM(e){return e<0?-Math.pow(-e,1/3):Math.pow(e,1/3)}function xM(e,t){var n=function(e,t){var n,i,r,a,s=t-0,o=t-e[0],c=3*s,l=3*o,u=3*(t-e[2]),h=1/(-s+l-u+(t-1)),_=(c-6*o+u)*h,f=_*(1/3),d=(-c+l)*h,p=1/3*(3*d-_*_),m=p*(1/3),g=(2*_*_*_-9*_*d+s*h*27)/27,v=g/2,y=v*v+m*m*m;if(y<0){var S=1/3*-p,E=TM(S*S*S),T=-g/(2*E),A=yM(T<-1?-1:T>1?1:T),x=2*AM(E);return i=x*vM(A*(1/3))-f,r=x*vM((A+EM)*(1/3))-f,a=x*vM((A+2*EM)*(1/3))-f,i>=0&&i<=1?r>=0&&r<=1?a>=0&&a<=1?SM(i,r,a):SM(i,r):a>=0&&a<=1?SM(i,a):i:r>=0&&r<=1?a>=0&&a<=1?SM(r,a):r:a}if(0===y)return r=-(n=v<0?AM(-v):-AM(v))-f,(i=2*n-f)>=0&&i<=1?r>=0&&r<=1?SM(i,r):i:r;var C=TM(y);return(n=AM(-v+C))-AM(v+C)-f}(e,t),i=e[1];return((1-n)*(i+(e[3]-i)*n)*3+n*n)*n}i.bezierByTime=xM;var CM=e("RatioSampler",function(){function e(e){var t,n;this.ratios=void 0,this._findRatio=void 0,this.ratios=e;for(var i=!0,r=1,a=e.length;r<a;r++)if(t=e[r]-e[r-1],1===r)n=t;else if(Math.abs(t-n)>1e-6){i=!1;break}this._findRatio=i?IM:mM}return e.prototype.sample=function(e){return this._findRatio(this.ratios,e)},e}());i.RatioSampler=CM;var RM=e("AnimCurve",function(){function e(t,n){this.types=void 0,this.type=null,this._values=[],this._lerp=void 0,this._duration=void 0,this._array=void 0,this._duration=n,this._values=t.values;var i=function(t){return"string"==typeof t?t:Array.isArray(t)?t[0]===t[1]&&t[2]===t[3]?e.Linear:e.Bezier(t):e.Linear};if(void 0!==t.easingMethod)this.type=i(t.easingMethod);else if(Array.isArray(t.easingMethods))this.types=t.easingMethods.map(i);else if(void 0!==t.easingMethods){this.types=new Array(this._values.length).fill(null);for(var r=0,a=Object.keys(t.easingMethods);r<a.length;r++){var s=a[r];this.types[s]=i(t.easingMethods[s])}}else this.type=null;var o=t.values[0];(void 0===t.interpolate||t.interpolate)&&(this._lerp=WM(o)),void 0!==t._arrayLength&&(this._array=new Array(t._arrayLength))}e.Bezier=function(e){return e};var t=e.prototype;return t.hasLerp=function(){return!!this._lerp},t.valueAt=function(e){if(void 0===this._array){var t=this._values[e];return t&&t.getNoLerp?t.getNoLerp():t}for(var n=0;n<this._array.length;++n)this._array[n]=this._values[this._array.length*e+n];return this._array},t.valueBetween=function(e,t,n,i,r){if(this._lerp){var a=this.types?this.types[t]:this.type,s=r-n,o=(e-n)/s;if(a&&(o=wM(o,a)),void 0===this._array){var c=this._values[t],l=this._values[i];return this._lerp(c,l,o,s*this._duration)}for(var u=0;u<this._array.length;++u){var h=this._values[this._array.length*t+u],_=this._values[this._array.length*i+u];this._array[u]=this._lerp(h,_,o,s*this._duration)}return this._array}if(void 0===this._array)return this.valueAt(t);for(var f=0;f<this._array.length;++f)this._array[f]=this._values[this._array.length*t+f];return this._array},t.empty=function(){return 0===this._values.length},t.constant=function(){return 1===this._values.length},e}());function bM(e,t,n){var i=t.sample(n);if(i<0)if((i=~i)<=0)i=0;else{if(!(i>=t.ratios.length))return e.valueBetween(n,i-1,t.ratios[i-1],i,t.ratios[i]);i=t.ratios.length-1}return e.valueAt(i)}function wM(e,t){if("string"==typeof t){var n=rg[t];n?e=n(e):A(3906,t)}else Array.isArray(t)&&(e=xM(t,e));return e}function IM(e,t){var n=e.length-1;if(0===n)return 0;var i=e[0];if(t<i)return 0;var r=e[n];if(t>r)return n;var a=(t=(t-i)/(r-i))/(1/n),s=0|a;return a-s<1e-6?s:s+1-a<1e-6?s+1:~(s+1)}RM.Linear=null,i.AnimCurve=RM,e("EventInfo",function(){function e(){this.events=[]}return e.prototype.add=function(e,t){this.events.push({func:e||"",params:t||[]})},e}()),i.sampleAnimationCurve=bM;var OM,PM,MM,NM,DM,BM,LM,FM,zM,UM,GM,kM,HM,VM,WM=function(){function e(e,t,n,i){return e.lerp(t,n,i)}return function(t){if(null!==t){if("number"==typeof t)return un;if("object"==typeof t&&t.constructor){if(t instanceof Dn)return n=new Dn,function(e,t,i){return Dn.slerp(n,e,t,i)};if(t instanceof _t)return function(e){var t=new e;return function(n,i,r){return e.lerp(t,n,i,r),t}}(t.constructor);if(t.constructor===Number)return un;if("function"==typeof t.lerp)return e}var n}}}(),jM=e("SkelAnimDataHub",function(){function e(){}return e.getOrExtract=function(t){var n=e.pool.get(t);return n&&n.info.sample===t.sample||(n&&i.director.root.dataPoolManager.releaseAnimationClip(t),n=function(e){var t={};e.curves.forEach((function(e){if(!e.valueAdapter&&GP(e.modifiers[0],XP)&&UP(e.modifiers[1])){var n=e.modifiers[0].path,i=t[n];i||(i=t[n]={}),i[e.modifiers[1]]={values:e.data.values,keys:e.data.keys}}}));for(var n=Math.ceil(e.sample*e.duration)+1,i=function(){var i=a[r],s=t[i];if(!s)return"continue";Object.defineProperty(s,"worldMatrix",{get:function(){if(!s._worldMatrix){var r=s.position,a=s.rotation,o=s.scale;qM(e,r,n),qM(e,a,n),qM(e,o,n),function(e,t,n){var i=n.position.values,r=n.rotation.values,a=n.scale.values,s=i.map((function(){return new Hn})),o=t.lastIndexOf("/"),c=null;if(o>0){var l=e[t.substring(0,o)];if(!l)return void console.warn("no data for parent bone?");c=l.worldMatrix.values}for(var u=0;u<i.length;u++){var h=i[u],_=r[u],f=a[u],d=s[u];Hn.fromRTS(d,_,h,f),c&&Hn.multiply(d,c[u],d)}Object.keys(n).forEach((function(e){return delete n[e]})),n._worldMatrix={keys:0,interpolate:!1,values:s}}(t,i,s)}return s._worldMatrix}})},r=0,a=Object.keys(t);r<a.length;r++)i();return{info:{frames:n,sample:e.sample},data:t}}(t),e.pool.set(t,n)),n},e.destroy=function(t){e.pool.delete(t)},e}());function qM(e,t,n){var i=e.keys[t.keys],r=[];if(i&&1!==i.length)for(var a=t.values[0]instanceof Dn,s=0,o=0;s<n;s++){for(var c=s/e.sample;i[o]<=c;)o++;o>i.length-1?c=i[o=i.length-1]:0===o&&(o=1);var l=t.values[o-1].clone(),u=i[o]-i[o-1],h=u?ln((c-i[o-1])/u):1;a?l.slerp(t.values[o],h):l.lerp(t.values[o],h),r[s]=l}else for(var _=0;_<n;_++)r[_]=t.values[0].clone();t.values=r}jM.pool=new Map;var XM=e("AnimationClip",ih("cc.AnimationClip")((VM=HM=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return Q(t=e.call.apply(e,[this].concat(i))||this,"sample",MM,Y(t)),Q(t,"speed",NM,Y(t)),Q(t,"wrapMode",DM,Y(t)),Q(t,"events",BM,Y(t)),Q(t,"_duration",LM,Y(t)),Q(t,"_keys",FM,Y(t)),Q(t,"_stepness",zM,Y(t)),Q(t,"_curves",UM,Y(t)),Q(t,"_commonTargets",GM,Y(t)),Q(t,"_hash",kM,Y(t)),t.frameRate=0,t._ratioSamplers=[],t._runtimeCurves=void 0,t._runtimeEvents=void 0,t._data=null,t}X(t,e),t.createWithSpriteFrames=function(e,n){if(!Array.isArray(e))return A(3905),null;var i=new t;i.sample=n||i.sample,i.duration=e.length/i.sample;for(var r=1/i.sample,a=new Array(e.length),s=new Array(a.length),o=0;o<e.length;o++)a[o]=o*r,s[o]=e[o];return i.keys=[a],i.curves=[{modifiers:[new YP("cc.Sprite"),"spriteFrame"],data:{keys:0,values:s}}],i};var n=t.prototype;return n.onLoaded=function(){this.frameRate=this.sample,this._decodeCVTAs()},n.getPropertyCurves=function(){return this._runtimeCurves||this._createPropertyCurves(),this._runtimeCurves},n.updateEventDatas=function(){delete this._runtimeEvents},n.getEventGroupIndexAtRatio=function(e){return this._runtimeEvents||this._createRuntimeEvents(),mM(this._runtimeEvents.ratios,e)},n.hasEvents=function(){return 0!==this.events.length},n.destroy=function(){return i.director.root.dataPoolManager&&i.director.root.dataPoolManager.releaseAnimationClip(this),jM.destroy(this),e.prototype.destroy.call(this)},n._createPropertyCurves=function(){var e=this;this._ratioSamplers=this._keys.map((function(t){return new CM(t.map((function(t){return t/e._duration})))})),this._runtimeCurves=this._curves.map((function(t){return{curve:new RM(t.data,e._duration),modifiers:t.modifiers,valueAdapter:t.valueAdapter,sampler:e._ratioSamplers[t.data.keys],commonTarget:t.commonTarget}})),this._applyStepness()},n._createRuntimeEvents=function(){for(var e,t=this,n=[],i=[],r=function(){var r=e.value,a=r.frame/t._duration,s=n.findIndex((function(e){return e===a}));s<0&&(s=n.length,n.push(a),i.push({events:[]})),i[s].events.push({functionName:r.func,parameters:r.params})},a=Z(this.events.sort((function(e,t){return e.frame-t.frame})));!(e=a()).done;)r();this._runtimeEvents={ratios:n,eventGroups:i}},n._applyStepness=function(){},n._decodeCVTAs=function(){var e=ArrayBuffer.isView(this._nativeAsset)?this._nativeAsset.buffer:this._nativeAsset;if(e){for(var t=this._keys,n=0;n<t.length;++n){var i=t[n];i instanceof DE&&(t[n]=i.decompress(e))}for(var r=0;r<this._curves.length;++r){var a=this._curves[r];a.data.values instanceof DE&&(a.data.values=a.data.values.decompress(e))}}},j(t,[{key:"duration",get:function(){return this._duration},set:function(e){this._duration=e}},{key:"keys",get:function(){return this._keys},set:function(e){this._keys=e}},{key:"eventGroups",get:function(){return this._runtimeEvents||this._createRuntimeEvents(),this._runtimeEvents.eventGroups}},{key:"stepness",get:function(){return this._stepness},set:function(e){this._stepness=e,this._applyStepness()}},{key:"hash",get:function(){if(this._hash)return this._hash;var e=this._nativeAsset,t=new Uint8Array(ArrayBuffer.isView(e)?e.buffer:e);return this._hash=Vs(t,666)}},{key:"curves",get:function(){return this._curves},set:function(e){this._curves=e,delete this._runtimeCurves}},{key:"data",get:function(){return this._data}},{key:"commonTargets",get:function(){return this._commonTargets},set:function(e){this._commonTargets=e}}]),t}(I_),HM.preventDeferredLoadDependents=!0,HM.WrapMode=dl,MM=J((PM=VM).prototype,"sample",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 60}}),NM=J(PM.prototype,"speed",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),DM=J(PM.prototype,"wrapMode",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return dl.Normal}}),BM=J(PM.prototype,"events",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),LM=J(PM.prototype,"_duration",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),FM=J(PM.prototype,"_keys",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),zM=J(PM.prototype,"_stepness",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),UM=J(PM.prototype,"_curves",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),GM=J(PM.prototype,"_commonTargets",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),kM=J(PM.prototype,"_hash",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),OM=PM))||OM);function YM(e,t,n){var i,r=t[t.length-1];if(0!==t.length&&UP(r)&&!n){var a=KP.apply(void 0,[e].concat(t.slice(0,t.length-1)));if(null===a)return null;i={isProxy:!1,object:a,property:r}}else{if(!n)return f("Empty animation curve."),null;var s=KP.apply(void 0,[e].concat(t));if(null===s)return null;i={isProxy:!0,proxy:n.forTarget(s)}}return{setValue:function(e){i.isProxy?i.proxy.set(e):i.object[i.property]=e},getValue:function(){return i.isProxy?i.proxy.get?i.proxy.get():(f("Target doesn't provide a get method."),null):i.object[i.property]}}}function KM(e,t,n){var i=YM(e,t,n);if(null===i)return null;var r=i.getValue(),a=QM(r);if(!a)return f("Value is not copyable!"),null;var s=a.createBuffer(),o=a.copy;return Object.assign(i,{peek:function(){return s},pull:function(){var e=i.getValue();o(s,e)},push:function(){i.setValue(s)}})}i.AnimationClip=XM;var ZM,QM=((ZM=new Map).set(qn,{createBuffer:function(){return new qn},copy:qn.copy}),ZM.set(bn,{createBuffer:function(){return new bn},copy:bn.copy}),ZM.set(Zn,{createBuffer:function(){return new Zn},copy:Zn.copy}),ZM.set(Cn,{createBuffer:function(){return new Cn},copy:Cn.copy}),ZM.set($n,{createBuffer:function(){return new $n},copy:function(e,t){return e.set(t)}}),function(e){return ZM.get(null==e?void 0:e.constructor)}),JM=function(){function e(){this._isPlaying=!1,this._isPaused=!1,this._stepOnce=!1}var t=e.prototype;return t.play=function(){this._isPlaying?this._isPaused?(this._isPaused=!1,this.onResume()):this.onError(b(3912)):(this._isPlaying=!0,this.onPlay())},t.stop=function(){this._isPlaying&&(this._isPlaying=!1,this.onStop(),this._isPaused=!1)},t.pause=function(){this._isPlaying&&!this._isPaused&&(this._isPaused=!0,this.onPause())},t.resume=function(){this._isPlaying&&this._isPaused&&(this._isPaused=!1,this.onResume())},t.step=function(){this.pause(),this._stepOnce=!0,this._isPlaying||this.play()},t.update=function(){},t.onPlay=function(){},t.onPause=function(){},t.onResume=function(){},t.onStop=function(){},t.onError=function(){},j(e,[{key:"isPlaying",get:function(){return this._isPlaying}},{key:"isPaused",get:function(){return this._isPaused}},{key:"isMotionless",get:function(){return!this.isPlaying||this.isPaused}}]),e}(),$M=function(){function e(){this._nodeBlendStates=new Map,this._states=new Set}var t=e.prototype;return t.ref=function(e,t){var n=this._nodeBlendStates.get(e);n||(n={dirty:!1,properties:{}},this._nodeBlendStates.set(e,n));var i=n.properties[t];return i||(i=n.properties[t]=new nN(n,eN(t)?new bn:new Dn)),++i.refCount,i},t.deRef=function(e,t){var n=this._nodeBlendStates.get(e);if(n){var i=n.properties[t];i&&(--i.refCount,i.refCount>0||(delete n.properties[t],function(e){return!(e.properties.position||e.properties.rotation||e.properties.eulerAngles||e.properties.scale)}(n)&&this._nodeBlendStates.delete(e)))}},t.apply=function(){this._nodeBlendStates.forEach((function(e,t){if(e.dirty){e.dirty=!1;var n,i,r,a=e.properties,s=a.position,o=a.scale,c=a.rotation,l=a.eulerAngles,u=!1;s&&0!==s.weight&&(s.weight=0,n=s.value,u=!0),o&&0!==o.weight&&(o.weight=0,i=o.value,u=!0),c&&0!==c.weight&&(c.weight=0,r=c.value,u=!0),l&&0!==l.weight&&(l.weight=0,r=l.value,u=!0),u&&t.setRTS(r,n,i)}})),this._states.forEach((function(e){e.onBlendFinished()}))},t.bindState=function(e){this._states.add(e)},t.unbindState=function(e){this._states.delete(e)},e}();function eN(e){return!function(e){return"rotation"===e}(e)}var tN,nN=function(){function e(e,t){this.weight=0,this.value=void 0,this.refCount=0,this._node=void 0,this._node=e,this.value=t}return e.prototype.markAsDirty=function(){this._node.dirty=!0},e}();function iN(e,t,n){return 0===n.weight&&bn.zero(n.value),0===t?n.value:1===t?bn.copy(n.value,e):bn.scaleAndAdd(n.value,n.value,e,t)}function rN(e,t,n){if(0===n.weight&&Dn.identity(n.value),0===t)return n.value;if(1===t)return Dn.copy(n.value,e);var i=t/(n.weight+t);return Dn.slerp(n.value,n.value,e,i)}!function(e){e.PLAY="play",e.STOP="stop",e.PAUSE="pause",e.RESUME="resume",e.LASTFRAME="lastframe",e.FINISHED="finished"}(tN||(tN={})),ht(tN);var aN=function(){function e(e,t,n){this.commonTargetIndex=void 0,this._curve=void 0,this._boundTarget=void 0,this._rootTargetProperty=void 0,this._curveDetail=void 0,this._curve=e.curve,this._curveDetail=e,this._boundTarget=n}var t=e.prototype;return t.applySample=function(e,t,n,i,r){var a;this._curve.empty()||(a=this._curve.hasLerp()&&n?this._curve.valueBetween(e,i.from,i.fromRatio,i.to,i.toRatio):this._curve.valueAt(t),this._setValue(a,r))},t._setValue=function(e){this._boundTarget.setValue(e)},j(e,[{key:"propertyName",get:function(){return this._rootTargetProperty||""}},{key:"curveDetail",get:function(){return this._curveDetail}}]),e}(),sN=e("AnimationState",function(e){function t(t,n){var i;return void 0===n&&(n=""),(i=e.call(this)||this).duration=1,i.speed=1,i.time=0,i.weight=0,i.frameRate=0,i._targetNode=null,i._curveLoaded=!1,i._clip=void 0,i._process=i.process,i._samplerSharedGroups=[],i._target=null,i._ignoreIndex=-1,i._commonTargetStatuses=[],i._wrapMode=dl.Normal,i._repeatCount=1,i._delay=0,i._delayTime=0,i._currentFramePlayed=!1,i._name=void 0,i._lastIterations=void 0,i._lastWrapInfo=null,i._lastWrapInfoEvent=null,i._wrappedInfo=new gl,i._blendStateBuffer=null,i._blendStateWriters=[],i._allowLastFrame=!1,i._blendStateWriterHost={weight:0,enabled:!1},i._clip=t,i._name=n||t&&t.name,i}X(t,e),j(t,[{key:"clip",get:function(){return this._clip}},{key:"name",get:function(){return this._name}},{key:"length",get:function(){return this.duration}},{key:"wrapMode",get:function(){return this._wrapMode},set:function(e){this._wrapMode=e,this.time=0,e&fl.Loop?this.repeatCount=1/0:this.repeatCount=1}},{key:"repeatCount",get:function(){return this._repeatCount},set:function(e){this._repeatCount=e;var t=this._wrapMode&fl.ShouldWrap,n=(this.wrapMode&fl.Reverse)===fl.Reverse;this._process=e!==1/0||t||n?this.process:this.simpleProcess}},{key:"delay",get:function(){return this._delay},set:function(e){this._delayTime=this._delay=e}},{key:"current",get:function(){return this.getWrappedInfo(this.time).time}},{key:"ratio",get:function(){return this.current/this.duration}}]);var n=t.prototype;return n.initialize=function(e,t){var n,r,a=this;if(!this._curveLoaded){this._curveLoaded=!0,this._destroyBlendStateWriters(),this._samplerSharedGroups.length=0,this._blendStateBuffer=null!==(n=null===(r=i.director.getAnimationManager())||void 0===r?void 0:r.blendState)&&void 0!==n?n:null,this._blendStateBuffer&&this._blendStateBuffer.bindState(this),this._targetNode=e;var s=this._clip;this.duration=s.duration,this.speed=s.speed,this.wrapMode=s.wrapMode,this.frameRate=s.sample,(this.wrapMode&fl.Loop)===fl.Loop?this.repeatCount=1/0:this.repeatCount=1;var o=function(e,t,n,i,r){if(!function(e){var t;if(1===e.length&&"string"==typeof e[0])t=e[0];else if(e.length>1){for(var n=0;n<e.length-1;++n)if(!(e[n]instanceof XP))return!1;t=e[e.length-1]}switch(t){case"position":case"scale":case"rotation":case"eulerAngles":return!0;default:return!1}}(n)||!a._blendStateBuffer)return e(t,n,i);var s=KP.apply(void 0,[t].concat(n.slice(0,n.length-1)));if(null!==s&&s instanceof RC){var o=n[n.length-1],c=function(e,t,n,i,r){var a=eN(n)?iN:rN,s=e.ref(t,n),o=!1,c=-1;return{destroy:function(){s&&(e.deRef(t,n),s=null)},forTarget:function(){return{get:function(){return t[n]},set:function(e){if(s&&i.enabled){var t=i.weight;if(r)if(1!==t||t!==c)o=!1;else if(o)return;a(e,t,s),s.weight+=t,s.markAsDirty(),o=!0,c=t}}}}}}(a._blendStateBuffer,s,o,a._blendStateWriterHost,r);return a._blendStateWriters.push(c),e(t,[],c)}return null};this._commonTargetStatuses=s.commonTargets.map((function(t){var n=o(KM,e,t.modifiers,t.valueAdapter,!1);return null===n?null:{target:n,changed:!1}})),t||(t=s.getPropertyCurves());for(var c=function(n){var i=t[n],r=a._samplerSharedGroups.find((function(e){return e.sampler===i.sampler}));r||(r={sampler:i.sampler,curves:[],samplerResultCache:{from:0,fromRatio:0,to:0,toRatio:0}},a._samplerSharedGroups.push(r));var s=void 0;if(void 0===i.commonTarget)s=e;else{var c=a._commonTargetStatuses[i.commonTarget];if(!c)return"continue";s=c.target.peek()}var l=o(YM,s,i.modifiers,i.valueAdapter,i.curve.constant());if(null===l);else{var u=new aN(i,s,l);u.commonTargetIndex=i.commonTarget,r.curves.push(u)}},l=0;l<t.length;++l)c(l)}},n.destroy=function(){this._destroyBlendStateWriters()},n.onBlendFinished=function(){this._blendStateWriterHost.enabled=!1},n.emit=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];i.director.getAnimationManager().pushDelayEvent(this._emit,this,t)},n.on=function(e,t,n){return this._target&&this._target.isValid?this._target.on(e,t,n):null},n.once=function(e,t,n){return this._target&&this._target.isValid?this._target.once(e,t,n):null},n.off=function(e,t,n){this._target&&this._target.isValid&&this._target.off(e,t,n)},n.allowLastFrameEvent=function(e){this._allowLastFrame=e},n._setEventTarget=function(e){this._target=e},n.setTime=function(e){this._currentFramePlayed=!1,this.time=e||0,this._lastWrapInfoEvent=null,this._ignoreIndex=-1;var t=this.getWrappedInfo(e,this._wrappedInfo),n=t.direction,i=this._clip.getEventGroupIndexAtRatio(t.ratio);i<0&&(i=~i-1,n<0&&(i+=1),this._ignoreIndex=i)},n.update=function(e){this._delayTime>0&&(this._delayTime-=e,this._delayTime>0)||(this._currentFramePlayed?this.time+=e*this.speed:this._currentFramePlayed=!0,this._process())},n.sample=function(){var e=this.getWrappedInfo(this.time,this._wrappedInfo);return this._sampleCurves(e.ratio),this._sampleEvents(e),e},n.onPlay=function(){this.setTime(0),this._delayTime=this._delay,this._onReplayOrResume(),this.emit(tN.PLAY,this)},n.onStop=function(){this.isPaused||this._onPauseOrStop(),this.emit(tN.STOP,this)},n.onResume=function(){this._onReplayOrResume(),this.emit(tN.RESUME,this)},n.onPause=function(){this._onPauseOrStop(),this.emit(tN.PAUSE,this)},n._sampleCurves=function(e){this._blendStateWriterHost.weight=this.weight,this._blendStateWriterHost.enabled=!0;for(var t=0;t<this._commonTargetStatuses.length;++t){var n=this._commonTargetStatuses[t];n&&(n.target.pull(),n.changed=!1)}for(var i=0,r=this._samplerSharedGroups.length;i<r;++i){var a=this._samplerSharedGroups[i],s=a.sampler,o=a.samplerResultCache,c=0,l=!1;s?(c=s.sample(e))<0&&((c=~c)<=0?c=0:c>=s.ratios.length?c=s.ratios.length-1:(l=!0,o.from=c-1,o.fromRatio=s.ratios[o.from],o.to=c,o.toRatio=s.ratios[o.to],c=o.from)):c=0;for(var u=0,h=a.curves.length;u<h;++u){var _=a.curves[u];if(_.applySample(e,c,l,o,this.weight),void 0!==_.commonTargetIndex){var f=this._commonTargetStatuses[_.commonTargetIndex];f&&(f.changed=!0)}}}for(var d=0;d<this._commonTargetStatuses.length;++d){var p=this._commonTargetStatuses[d];p&&p.changed&&p.target.push()}},n.process=function(){var e,t=this.sample();this._allowLastFrame&&(e=this._lastWrapInfo?this._lastWrapInfo:this._lastWrapInfo=new gl(t),this.repeatCount>1&&(0|t.iterations)>(0|e.iterations)&&this.emit(tN.LASTFRAME,this),e.set(t)),t.stopped&&(this.stop(),this.emit(tN.FINISHED,this))},n.simpleProcess=function(){var e=this.duration,t=this.time%e;t<0&&(t+=e);var n=t/e;this._sampleCurves(n),this._clip.hasEvents()&&this._sampleEvents(this.getWrappedInfo(this.time,this._wrappedInfo)),this._allowLastFrame&&(void 0===this._lastIterations&&(this._lastIterations=n),(this.time>0&&this._lastIterations>n||this.time<0&&this._lastIterations<n)&&this.emit(tN.LASTFRAME,this),this._lastIterations=n)},n.cache=function(){},n._needReverse=function(e){var t=this.wrapMode,n=!1;return(t&fl.PingPong)===fl.PingPong&&(e-(0|e)==0&&e>0&&(e-=1),1&e&&(n=!n)),(t&fl.Reverse)===fl.Reverse&&(n=!n),n},n.getWrappedInfo=function(e,t){t=t||new gl;var n=!1,i=this.duration,r=this.repeatCount,a=e>0?e/i:-e/i;if(a>=r){a=r,n=!0;var s=r-(0|r);0===s&&(s=1),e=s*i*(e>0?1:-1)}if(e>i){var o=e%i;e=0===o?i:o}else e<0&&0!=(e%=i)&&(e+=i);var c=!1,l=this._wrapMode&fl.ShouldWrap;l&&(c=this._needReverse(a));var u=c?-1:1;return this.speed<0&&(u*=-1),l&&c&&(e=i-e),t.ratio=e/i,t.time=e,t.direction=u,t.stopped=n,t.iterations=a,t},n._sampleEvents=function(e){var t=this._clip.eventGroups.length,n=e.direction,r=this._clip.getEventGroupIndexAtRatio(e.ratio);if(r<0&&(r=~r-1,n<0&&(r+=1)),this._ignoreIndex!==r&&(this._ignoreIndex=-1),e.frameIndex=r,!this._lastWrapInfoEvent)return this._fireEvent(r),void(this._lastWrapInfoEvent=new gl(e));var a=this.wrapMode,s=oN(e.iterations),o=this._lastWrapInfoEvent,c=oN(o.iterations),l=o.frameIndex,u=o.direction,h=-1!==c&&s!==c;if(l===r&&h&&1===t)this._fireEvent(0);else if(l!==r||h){n=u;do{if(l!==r){if(-1===n&&0===l&&r>0?((a&fl.PingPong)===fl.PingPong?n*=-1:l=t,c++):1===n&&l===t-1&&r<t-1&&((a&fl.PingPong)===fl.PingPong?n*=-1:l=-1,c++),l===r)break;if(c>s)break}l+=n,i.director.getAnimationManager().pushDelayEvent(this._fireEvent,this,[l])}while(l!==r&&l>-1&&l<t)}this._lastWrapInfoEvent.set(e)},n._emit=function(e,t){this._target&&this._target.isValid&&this._target.emit(e,e,t)},n._fireEvent=function(e){if(this._targetNode&&this._targetNode.isValid){var t=this._clip.eventGroups;if(!(e<0||e>=t.length||this._ignoreIndex===e))for(var n,i=t[e],r=this._targetNode.components,a=Z(i.events);!(n=a()).done;)for(var s,o=n.value,c=o.functionName,l=Z(r);!(s=l()).done;){var u=s.value,h=u[c];"function"==typeof h&&h.apply(u,o.parameters)}}},n._onReplayOrResume=function(){i.director.getAnimationManager().addAnimation(this)},n._onPauseOrStop=function(){i.director.getAnimationManager().removeAnimation(this)},n._destroyBlendStateWriters=function(){for(var e=0;e<this._blendStateWriters.length;++e)this._blendStateWriters[e].destroy();this._blendStateWriters.length=0,this._blendStateBuffer&&(this._blendStateBuffer.unbindState(this),this._blendStateBuffer=null),this._blendStateWriterHost.enabled=!1},j(t,[{key:"curveLoaded",get:function(){return this._curveLoaded}}]),t}(JM));function oN(e){return e-(0|e)==0&&(e-=1),0|e}i.AnimationState=sN;var cN,lN,uN,hN,_N,fN,dN,pN,mN,gN,vN,yN,SN,EN,TN,AN,xN,CN=function(e){function t(){var t;return(t=e.call(this)||this)._managedStates=[],t._fadings=[],t}X(t,e);var n=t.prototype;return n.update=function(e){if(!this.isMotionless){for(var t=0;t<this._managedStates.length;++t){var n=this._managedStates[t].state;n&&(n.weight=0)}for(var i=1,r=this._fadings.length,a=0;a<this._fadings.length;++a){var s=this._fadings[a];s.easeTime+=e;var o=0===s.easeDuration?1:ln(s.easeTime/s.easeDuration),c=o*i;if(i*=1-o,s.target.state&&(s.target.state.weight+=c),s.easeTime>=s.easeDuration){r=a+1,s.easeTime=s.easeDuration;break}}if(r!==this._fadings.length){for(var l=r;l<this._fadings.length;++l){var u=this._fadings[l];--u.target.reference,u.target.reference<=0&&(u.target.state&&u.target.state.stop(),ge(this._managedStates,u.target))}this._fadings.splice(r)}for(var h=0;h<this._managedStates.length;++h){var _=this._managedStates[h].state;_&&_.isMotionless&&_.sample()}}},n.crossFade=function(e,t){var n;0===this._managedStates.length&&(t=0),0===t&&this.clear();var i=this._managedStates.find((function(t){return t.state===e}));i?(null===(n=i.state)||void 0===n?void 0:n.isMotionless)&&i.state.play():(i={state:e,reference:0},e&&e.play(),this._managedStates.push(i)),++i.reference,this._fadings.unshift({easeDuration:t,easeTime:0,target:i})},n.clear=function(){for(var e=0;e<this._managedStates.length;++e){var t=this._managedStates[e].state;t&&t.stop()}this._managedStates.length=0,this._fadings.length=0},n.onPlay=function(){e.prototype.onPlay.call(this),i.director.getAnimationManager().addCrossFade(this)},n.onPause=function(){e.prototype.onPause.call(this),i.director.getAnimationManager().removeCrossFade(this);for(var t=0;t<this._managedStates.length;++t){var n=this._managedStates[t].state;n&&n.pause()}},n.onResume=function(){e.prototype.onResume.call(this),i.director.getAnimationManager().addCrossFade(this);for(var t=0;t<this._managedStates.length;++t){var n=this._managedStates[t].state;n&&n.resume()}},n.onStop=function(){e.prototype.onStop.call(this),i.director.getAnimationManager().removeCrossFade(this),this.clear()},t}(JM),RN=function(t){return e({AnimationComponent:t,Animation:t}),t}((cN=ih("cc.Animation"),lN=mh(),uN=ah(99),hN=_h(),_N=Dh([XM]),fN=Sh(),dN=Dh(XM),pN=Sh(),mN=Sh(),gN=Dh([XM]),cN(vN=lN(vN=uN(vN=hh(vN=hN((xN=AN=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return Q(t=e.call.apply(e,[this].concat(i))||this,"playOnLoad",SN,Y(t)),t._crossFade=new CN,t._nameToState=Pe(!0),Q(t,"_clips",EN,Y(t)),Q(t,"_defaultClip",TN,Y(t)),t._hasBeenPlayed=!1,t}X(t,e);var n=t.prototype;return n.onLoad=function(){for(var e in this.clips=this._clips,this._nameToState)this._nameToState[e].initialize(this.node)},n.start=function(){this.playOnLoad&&!this._hasBeenPlayed&&this._defaultClip&&this.crossFade(this._defaultClip.name,0)},n.onEnable=function(){this._crossFade.resume()},n.onDisable=function(){this._crossFade.pause()},n.onDestroy=function(){for(var e in this._crossFade.stop(),this._nameToState)this._nameToState[e].destroy();this._nameToState=Pe(!0)},n.play=function(e){if(this._hasBeenPlayed=!0,!e){if(!this._defaultClip)return;e=this._defaultClip.name}this.crossFade(e,0)},n.crossFade=function(e,t){void 0===t&&(t=.3),this._hasBeenPlayed=!0;var n=this._nameToState[e];n&&(this._crossFade.play(),this._crossFade.crossFade(n,t))},n.pause=function(){this._crossFade.pause()},n.resume=function(){this._crossFade.resume()},n.stop=function(){this._crossFade.stop()},n.getAnimationState=function(e){return this.getState(e)},n.getState=function(e){var t=this._nameToState[e];return t&&!t.curveLoaded&&t.initialize(this.node),t||null},n.createState=function(e,t){return t=t||e.name,this.removeState(t),this._doCreateState(e,t)},n.removeState=function(e){var t=this._nameToState[e];t&&(t.allowLastFrameEvent(!1),t.stop(),delete this._nameToState[e])},n.addClip=function(e,t){return ve(this._clips,e)||this._clips.push(e),this.createState(e,t)},n.removeClip=function(e,t){var n;for(var i in this._nameToState){var r=this._nameToState[i];if(r.clip===e){n=r;break}}if(e===this._defaultClip){if(!t)return void E(3902);this._defaultClip=null}if(n&&n.isPlaying){if(!t)return void E(3903);n.stop()}this._clips=this._clips.filter((function(t){return t!==e})),n&&delete this._nameToState[n.name]},n.on=function(t,n,i,r){var a=e.prototype.on.call(this,t,n,i,r);return t===tN.LASTFRAME&&this._syncAllowLastFrameEvent(),a},n.once=function(t,n,i){var r=e.prototype.once.call(this,t,n,i);return t===tN.LASTFRAME&&this._syncAllowLastFrameEvent(),r},n.off=function(t,n,i){e.prototype.off.call(this,t,n,i),t===tN.LASTFRAME&&this._syncDisallowLastFrameEvent()},n._createState=function(e,t){return new sN(e,t)},n._doCreateState=function(e,t){var n=this._createState(e,t);return n._setEventTarget(this),n.allowLastFrameEvent(this.hasEventListener(tN.LASTFRAME)),this.node&&n.initialize(this.node),this._nameToState[n.name]=n,n},n._getStateByNameOrDefaultClip=function(e){if(!e){if(!this._defaultClip)return null;e=this._defaultClip.name}return this._nameToState[e]||null},n._removeStateOfAutomaticClip=function(e){for(var t in this._nameToState){var n=this._nameToState[t];bN(e,n.clip)&&(n.stop(),delete this._nameToState[t])}},n._syncAllowLastFrameEvent=function(){if(this.hasEventListener(tN.LASTFRAME))for(var e in this._nameToState)this._nameToState[e].allowLastFrameEvent(!0)},n._syncDisallowLastFrameEvent=function(){if(!this.hasEventListener(tN.LASTFRAME))for(var e in this._nameToState)this._nameToState[e].allowLastFrameEvent(!1)},j(t,[{key:"clips",get:function(){return this._clips},set:function(e){var t=this;this._crossFade&&this._crossFade.clear();for(var n,i=Z(this._clips);!(n=i()).done;){var r=n.value;r&&this._removeStateOfAutomaticClip(r)}for(var a,s=Z(e);!(a=s()).done;){var o=a.value;o&&this.createState(o)}var c=e.find((function(e){return bN(e,t._defaultClip)}));this._defaultClip=c||null,this._clips=e}},{key:"defaultClip",get:function(){return this._defaultClip},set:function(e){this._defaultClip=e,e&&(this._clips.findIndex((function(t){return bN(t,e)}))>=0||(this._clips.push(e),this.createState(e)))}}]),t}(T_(Kf)),AN.EventType=tN,J((yN=xN).prototype,"clips",[_N,fN],Object.getOwnPropertyDescriptor(yN.prototype,"clips"),yN.prototype),J(yN.prototype,"defaultClip",[dN,pN],Object.getOwnPropertyDescriptor(yN.prototype,"defaultClip"),yN.prototype),SN=J(yN.prototype,"playOnLoad",[ch,mN],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),EN=J(yN.prototype,"_clips",[gN],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),TN=J(yN.prototype,"_defaultClip",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),vN=yN))||vN)||vN)||vN)||vN)||vN));function bN(e,t){return e===t||!(!e||!t||e.name!==t.name&&e._uuid!==t._uuid)}se(RN.prototype,"Animation",[{name:"getAnimationState",newName:"getState"},{name:"addClip",newName:"createState"},{name:"removeClip",newName:"removeState",customFunction:function(){var e=arguments.length<=0?void 0:arguments[0];return RN.prototype.removeState.call(this,e.name)}}]),i.AnimationComponent=RN,st.setClassAlias(RN,"cc.AnimationComponent");var wN,IN,ON,PN=[],MN=new Map;function NN(e,t){for(var n=0,i=Hn.IDENTITY;e;){if(e.stamp===t||e.stamp+1===t&&!e.node.hasChangedFlags){i=e.world,e.stamp=t;break}e.stamp=t,PN[n++]=e,e=e.parent}for(;n>0;){var r=(e=PN[--n]).node;Hn.fromRTS(e.local,r.rotation,r.position,r.scale),i=Hn.multiply(e.world,i,e.local)}return i}function DN(e,t){for(var n,i=null,r=0;e!==t;){var a=e.uuid;if(MN.has(a)){i=MN.get(a);break}i={node:e,local:new Hn,world:new Hn,stamp:-1,parent:null},MN.set(a,i),PN[r++]=i,e=e.parent,i=null}for(;r>0;)(n=PN[--r]).parent=i,i=n;return i}function BN(e){for(var t=MN.get(e.uuid)||null;t;)MN.delete(t.node.uuid),t=t.parent}var LN=e("AnimationManager",ih((ON=IN=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._anims=new de([]),t._delayEvents=[],t._blendStateBuffer=new $M,t._crossFades=[],t._sockets=[],t}X(t,e);var n=t.prototype;return n.addCrossFade=function(e){this._crossFades.push(e)},n.removeCrossFade=function(e){ge(this._crossFades,e)},n.update=function(e){for(var t=this._delayEvents,n=this._crossFades,r=this._sockets,a=0,s=n.length;a<s;a++)n[a].update(e);var o=this._anims,c=o.array;for(o.i=0;o.i<c.length;++o.i){var l=c[o.i];l.isMotionless||l.update(e)}this._blendStateBuffer.apply();for(var u=i.director.getTotalFrames(),h=0,_=r.length;h<_;h++){var f=r[h],d=f.target,p=f.transform;d.matrix=NN(p,u)}for(var m=0,g=t.length;m<g;m++){var v=t[m];v.fn.apply(v.thisArg,v.args)}t.length=0},n.destruct=function(){},n.addAnimation=function(e){-1===this._anims.array.indexOf(e)&&this._anims.push(e)},n.removeAnimation=function(e){var t=this._anims.array.indexOf(e);t>=0?this._anims.fastRemoveAt(t):A(3907)},n.pushDelayEvent=function(e,t,n){this._delayEvents.push({fn:e,thisArg:t,args:n})},n.addSockets=function(e,t){for(var n=this,i=function(i){var r=t[i];if(n._sockets.find((function(e){return e.target===r.target})))return"continue";var a=e.getChildByPath(r.path),s=r.target&&a&&DN(a,e);s&&n._sockets.push({target:r.target,transform:s})},r=0;r<t.length;++r)i(r)},n.removeSockets=function(e,t){for(var n=0;n<t.length;++n)for(var i=t[n],r=0;r<this._sockets.length;++r){var a=this._sockets[r];if(a.target===i.target){BN(a.transform.node),this._sockets[r]=this._sockets[this._sockets.length-1],this._sockets.length--;break}}},j(t,[{key:"blendState",get:function(){return this._blendStateBuffer}}]),t}(cx),IN.ID="animation",wN=ON))||wN);Ow.on(Iw.EVENT_INIT,(function(){var e=new LN;Ow.registerSystem(LN.ID,e,dx.PRIORITY_SYSTEM)})),i.AnimationManager=LN;var FN,zN,UN,GN,kN=new Hn;function HN(e,t,n){for(Hn.identity(n);e!==t;)Hn.fromRTS(kN,e.rotation,e.position,e.scale),Hn.multiply(n,kN,n),e=e.parent;return n}i.easing=rg;var VN=e("HierachyModifier",ih("cc.HierachyModifier")(FN=function(e){function t(){return e.apply(this,arguments)||this}return X(t,e),t}(XP))||FN);i.HierachyModifier=VN;var WN=e("ComponentModifier",ih("cc.ComponentModifier")(zN=function(e){function t(){return e.apply(this,arguments)||this}return X(t,e),t}(YP))||zN);i.ComponentModifier=WN;var jN=e("CurveValueAdapter",ih("cc.CurveValueAdapter")(UN=function(){function e(){}return e.prototype.forTarget=function(){return{set:function(){}}},e}())||UN);i.CurveValueAdapter=jN;var qN=e("UniformCurveValueAdapter",ih("cc.UniformCurveValueAdapter")(GN=function(e){function t(){return e.apply(this,arguments)||this}return X(t,e),t}(oM))||GN);function XN(e){return"string"==typeof e}function YN(e){return"number"==typeof e}function KN(e,t){return e instanceof t}i.UniformCurveValueAdapter=qN,i.isPropertyModifier=XN,i.isElementModifier=YN,i.isCustomTargetModifier=KN,i.math=ii,i.geometry=Ml;var ZN=e("NodePool",function(){function e(e){this.poolHandlerComp=void 0,this._pool=void 0,this.poolHandlerComp=e,this._pool=[]}var t=e.prototype;return t.size=function(){return this._pool.length},t.clear=function(){for(var e=this._pool.length,t=0;t<e;++t)this._pool[t].destroy();this._pool.length=0},t.put=function(e){if(e&&-1===this._pool.indexOf(e)){e.removeFromParent();var t=this.poolHandlerComp?e.getComponent(this.poolHandlerComp):null;t&&t.unuse&&t.unuse(),this._pool.push(e)}},t.get=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var i=this._pool.length-1;if(i<0)return null;var r=this._pool[i];this._pool.length=i;var a=this.poolHandlerComp?r.getComponent(this.poolHandlerComp):null;return a&&a.reuse&&a.reuse(arguments),r},e}());i.NodePool=ZN,i.renderer=Cm;var QN,JN=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._gpuDescriptorSet=null,t}X(t,e);var n=t.prototype;return n.initialize=function(e){this._layout=e.layout;var t=e.layout.gpuDescriptorSetLayout,n=t.bindings,i=t.descriptorIndices,r=t.descriptorCount;this._buffers=Array(r).fill(null),this._textures=Array(r).fill(null),this._samplers=Array(r).fill(null);var a=[];this._gpuDescriptorSet={gpuDescriptors:a,descriptorIndices:i};for(var s=0;s<n.length;++s)for(var o=n[s],c=0;c<o.count;c++)a.push({type:o.descriptorType,gpuBuffer:null,gpuTexture:null,gpuSampler:null});return!0},n.destroy=function(){this._layout=null,this._gpuDescriptorSet=null},n.update=function(){if(this._isDirty&&this._gpuDescriptorSet){for(var e=this._gpuDescriptorSet.gpuDescriptors,t=0;t<e.length;++t)if(e[t].type&Io){var n=this._buffers[t];n&&(e[t].gpuBuffer=n.gpuBuffer||n.gpuBufferView)}else e[t].type&Oo&&(this._textures[t]&&(e[t].gpuTexture=this._textures[t].gpuTexture),this._samplers[t]&&(e[t].gpuSampler=this._samplers[t].gpuSampler));this._isDirty=!1}},j(t,[{key:"gpuDescriptorSet",get:function(){return this._gpuDescriptorSet}}]),t}(Mo);function $N(e,t){switch(e){case za.R8:return t.UNSIGNED_BYTE;case za.R8SN:return t.BYTE;case za.R8UI:return t.UNSIGNED_BYTE;case za.R8I:return t.BYTE;case za.R16F:return QN.HALF_FLOAT_OES;case za.R16UI:return t.UNSIGNED_SHORT;case za.R16I:return t.SHORT;case za.R32F:return t.FLOAT;case za.R32UI:return t.UNSIGNED_INT;case za.R32I:return t.INT;case za.RG8:return t.UNSIGNED_BYTE;case za.RG8SN:return t.BYTE;case za.RG8UI:return t.UNSIGNED_BYTE;case za.RG8I:return t.BYTE;case za.RG16F:return QN.HALF_FLOAT_OES;case za.RG16UI:return t.UNSIGNED_SHORT;case za.RG16I:return t.SHORT;case za.RG32F:return t.FLOAT;case za.RG32UI:return t.UNSIGNED_INT;case za.RG32I:return t.INT;case za.RGB8:case za.SRGB8:return t.UNSIGNED_BYTE;case za.RGB8SN:return t.BYTE;case za.RGB8UI:return t.UNSIGNED_BYTE;case za.RGB8I:return t.BYTE;case za.RGB16F:return QN.HALF_FLOAT_OES;case za.RGB16UI:return t.UNSIGNED_SHORT;case za.RGB16I:return t.SHORT;case za.RGB32F:return t.FLOAT;case za.RGB32UI:return t.UNSIGNED_INT;case za.RGB32I:return t.INT;case za.BGRA8:case za.RGBA8:case za.SRGB8_A8:return t.UNSIGNED_BYTE;case za.RGBA8SN:return t.BYTE;case za.RGBA8UI:return t.UNSIGNED_BYTE;case za.RGBA8I:return t.BYTE;case za.RGBA16F:return QN.HALF_FLOAT_OES;case za.RGBA16UI:return t.UNSIGNED_SHORT;case za.RGBA16I:return t.SHORT;case za.RGBA32F:return t.FLOAT;case za.RGBA32UI:return t.UNSIGNED_INT;case za.RGBA32I:return t.INT;case za.R5G6B5:return t.UNSIGNED_SHORT_5_6_5;case za.R11G11B10F:return t.FLOAT;case za.RGB5A1:return t.UNSIGNED_SHORT_5_5_5_1;case za.RGBA4:return t.UNSIGNED_SHORT_4_4_4_4;case za.RGB10A2:return t.UNSIGNED_BYTE;case za.RGB10A2UI:return t.UNSIGNED_INT;case za.RGB9E5:return t.UNSIGNED_BYTE;case za.D16:return t.UNSIGNED_SHORT;case za.D16S8:return QN.UNSIGNED_INT_24_8_WEBGL;case za.D24:return t.UNSIGNED_INT;case za.D24S8:return QN.UNSIGNED_INT_24_8_WEBGL;case za.D32F:return t.UNSIGNED_INT;case za.D32F_S8:return QN.UNSIGNED_INT_24_8_WEBGL;case za.BC1:case za.BC1_SRGB:case za.BC2:case za.BC2_SRGB:case za.BC3:case za.BC3_SRGB:case za.BC4:return t.UNSIGNED_BYTE;case za.BC4_SNORM:return t.BYTE;case za.BC5:return t.UNSIGNED_BYTE;case za.BC5_SNORM:return t.BYTE;case za.BC6H_SF16:case za.BC6H_UF16:return t.FLOAT;case za.BC7:case za.BC7_SRGB:case za.ETC_RGB8:case za.ETC2_RGB8:case za.ETC2_SRGB8:case za.ETC2_RGB8_A1:case za.ETC2_SRGB8_A1:case za.EAC_R11:return t.UNSIGNED_BYTE;case za.EAC_R11SN:return t.BYTE;case za.EAC_RG11:return t.UNSIGNED_BYTE;case za.EAC_RG11SN:return t.BYTE;case za.PVRTC_RGB2:case za.PVRTC_RGBA2:case za.PVRTC_RGB4:case za.PVRTC_RGBA4:case za.PVRTC2_2BPP:case za.PVRTC2_4BPP:return t.UNSIGNED_BYTE;case za.ASTC_RGBA_4x4:case za.ASTC_RGBA_5x4:case za.ASTC_RGBA_5x5:case za.ASTC_RGBA_6x5:case za.ASTC_RGBA_6x6:case za.ASTC_RGBA_8x5:case za.ASTC_RGBA_8x6:case za.ASTC_RGBA_8x8:case za.ASTC_RGBA_10x5:case za.ASTC_RGBA_10x6:case za.ASTC_RGBA_10x8:case za.ASTC_RGBA_10x10:case za.ASTC_RGBA_12x10:case za.ASTC_RGBA_12x12:case za.ASTC_SRGBA_4x4:case za.ASTC_SRGBA_5x4:case za.ASTC_SRGBA_5x5:case za.ASTC_SRGBA_6x5:case za.ASTC_SRGBA_6x6:case za.ASTC_SRGBA_8x5:case za.ASTC_SRGBA_8x6:case za.ASTC_SRGBA_8x8:case za.ASTC_SRGBA_10x5:case za.ASTC_SRGBA_10x6:case za.ASTC_SRGBA_10x8:case za.ASTC_SRGBA_10x10:case za.ASTC_SRGBA_12x10:case za.ASTC_SRGBA_12x12:default:return t.UNSIGNED_BYTE}}function eD(e,t){switch(e){case za.A8:return t.ALPHA;case za.L8:return t.LUMINANCE;case za.LA8:return t.LUMINANCE_ALPHA;case za.RGB8:case za.RGB16F:case za.RGB32F:return t.RGB;case za.BGRA8:case za.RGBA8:case za.RGBA16F:case za.RGBA32F:return t.RGBA;case za.R5G6B5:return t.RGB565;case za.RGB5A1:return t.RGB5_A1;case za.RGBA4:return t.RGBA4;case za.D16:return t.DEPTH_COMPONENT;case za.D16S8:return t.DEPTH_STENCIL;case za.D24:return t.DEPTH_COMPONENT;case za.D24S8:return t.DEPTH_STENCIL;case za.D32F:return t.DEPTH_COMPONENT;case za.D32F_S8:return t.DEPTH_STENCIL;case za.BC1:return QN.COMPRESSED_RGB_S3TC_DXT1_EXT;case za.BC1_ALPHA:return QN.COMPRESSED_RGBA_S3TC_DXT1_EXT;case za.BC1_SRGB:return QN.COMPRESSED_SRGB_S3TC_DXT1_EXT;case za.BC1_SRGB_ALPHA:return QN.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;case za.BC2:return QN.COMPRESSED_RGBA_S3TC_DXT3_EXT;case za.BC2_SRGB:return QN.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;case za.BC3:return QN.COMPRESSED_RGBA_S3TC_DXT5_EXT;case za.BC3_SRGB:return QN.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;case za.ETC_RGB8:return QN.COMPRESSED_RGB_ETC1_WEBGL;case za.ETC2_RGB8:return QN.COMPRESSED_RGB8_ETC2;case za.ETC2_SRGB8:return QN.COMPRESSED_SRGB8_ETC2;case za.ETC2_RGB8_A1:return QN.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;case za.ETC2_SRGB8_A1:return QN.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2;case za.ETC2_RGBA8:return QN.COMPRESSED_RGBA8_ETC2_EAC;case za.ETC2_SRGB8_A8:return QN.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;case za.EAC_R11:return QN.COMPRESSED_R11_EAC;case za.EAC_R11SN:return QN.COMPRESSED_SIGNED_R11_EAC;case za.EAC_RG11:return QN.COMPRESSED_RG11_EAC;case za.EAC_RG11SN:return QN.COMPRESSED_SIGNED_RG11_EAC;case za.PVRTC_RGB2:return QN.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;case za.PVRTC_RGBA2:return QN.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;case za.PVRTC_RGB4:return QN.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;case za.PVRTC_RGBA4:return QN.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;case za.ASTC_RGBA_4x4:return QN.COMPRESSED_RGBA_ASTC_4x4_KHR;case za.ASTC_RGBA_5x4:return QN.COMPRESSED_RGBA_ASTC_5x4_KHR;case za.ASTC_RGBA_5x5:return QN.COMPRESSED_RGBA_ASTC_5x5_KHR;case za.ASTC_RGBA_6x5:return QN.COMPRESSED_RGBA_ASTC_6x5_KHR;case za.ASTC_RGBA_6x6:return QN.COMPRESSED_RGBA_ASTC_6x6_KHR;case za.ASTC_RGBA_8x5:return QN.COMPRESSED_RGBA_ASTC_8x5_KHR;case za.ASTC_RGBA_8x6:return QN.COMPRESSED_RGBA_ASTC_8x6_KHR;case za.ASTC_RGBA_8x8:return QN.COMPRESSED_RGBA_ASTC_8x8_KHR;case za.ASTC_RGBA_10x5:return QN.COMPRESSED_RGBA_ASTC_10x5_KHR;case za.ASTC_RGBA_10x6:return QN.COMPRESSED_RGBA_ASTC_10x6_KHR;case za.ASTC_RGBA_10x8:return QN.COMPRESSED_RGBA_ASTC_10x8_KHR;case za.ASTC_RGBA_10x10:return QN.COMPRESSED_RGBA_ASTC_10x10_KHR;case za.ASTC_RGBA_12x10:return QN.COMPRESSED_RGBA_ASTC_12x10_KHR;case za.ASTC_RGBA_12x12:return QN.COMPRESSED_RGBA_ASTC_12x12_KHR;case za.ASTC_SRGBA_4x4:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;case za.ASTC_SRGBA_5x4:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR;case za.ASTC_SRGBA_5x5:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR;case za.ASTC_SRGBA_6x5:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR;case za.ASTC_SRGBA_6x6:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR;case za.ASTC_SRGBA_8x5:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR;case za.ASTC_SRGBA_8x6:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR;case za.ASTC_SRGBA_8x8:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR;case za.ASTC_SRGBA_10x5:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR;case za.ASTC_SRGBA_10x6:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR;case za.ASTC_SRGBA_10x8:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR;case za.ASTC_SRGBA_10x10:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR;case za.ASTC_SRGBA_12x10:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR;case za.ASTC_SRGBA_12x12:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR;default:return console.error("Unsupported Format, convert to WebGL internal format failed."),t.RGBA}}function tD(e,t){switch(e){case za.A8:return t.ALPHA;case za.L8:return t.LUMINANCE;case za.LA8:return t.LUMINANCE_ALPHA;case za.RGB8:case za.RGB16F:case za.RGB32F:return t.RGB;case za.BGRA8:case za.RGBA8:case za.RGBA16F:case za.RGBA32F:return t.RGBA;case za.R5G6B5:return t.RGB;case za.RGB5A1:case za.RGBA4:return t.RGBA;case za.D16:return t.DEPTH_COMPONENT;case za.D16S8:return t.DEPTH_STENCIL;case za.D24:return t.DEPTH_COMPONENT;case za.D24S8:return t.DEPTH_STENCIL;case za.D32F:return t.DEPTH_COMPONENT;case za.D32F_S8:return t.DEPTH_STENCIL;case za.BC1:return QN.COMPRESSED_RGB_S3TC_DXT1_EXT;case za.BC1_ALPHA:return QN.COMPRESSED_RGBA_S3TC_DXT1_EXT;case za.BC1_SRGB:return QN.COMPRESSED_SRGB_S3TC_DXT1_EXT;case za.BC1_SRGB_ALPHA:return QN.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;case za.BC2:return QN.COMPRESSED_RGBA_S3TC_DXT3_EXT;case za.BC2_SRGB:return QN.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;case za.BC3:return QN.COMPRESSED_RGBA_S3TC_DXT5_EXT;case za.BC3_SRGB:return QN.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;case za.ETC_RGB8:return QN.COMPRESSED_RGB_ETC1_WEBGL;case za.ETC2_RGB8:return QN.COMPRESSED_RGB8_ETC2;case za.ETC2_SRGB8:return QN.COMPRESSED_SRGB8_ETC2;case za.ETC2_RGB8_A1:return QN.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;case za.ETC2_SRGB8_A1:return QN.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2;case za.ETC2_RGBA8:return QN.COMPRESSED_RGBA8_ETC2_EAC;case za.ETC2_SRGB8_A8:return QN.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;case za.EAC_R11:return QN.COMPRESSED_R11_EAC;case za.EAC_R11SN:return QN.COMPRESSED_SIGNED_R11_EAC;case za.EAC_RG11:return QN.COMPRESSED_RG11_EAC;case za.EAC_RG11SN:return QN.COMPRESSED_SIGNED_RG11_EAC;case za.PVRTC_RGB2:return QN.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;case za.PVRTC_RGBA2:return QN.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;case za.PVRTC_RGB4:return QN.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;case za.PVRTC_RGBA4:return QN.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;case za.ASTC_RGBA_4x4:return QN.COMPRESSED_RGBA_ASTC_4x4_KHR;case za.ASTC_RGBA_5x4:return QN.COMPRESSED_RGBA_ASTC_5x4_KHR;case za.ASTC_RGBA_5x5:return QN.COMPRESSED_RGBA_ASTC_5x5_KHR;case za.ASTC_RGBA_6x5:return QN.COMPRESSED_RGBA_ASTC_6x5_KHR;case za.ASTC_RGBA_6x6:return QN.COMPRESSED_RGBA_ASTC_6x6_KHR;case za.ASTC_RGBA_8x5:return QN.COMPRESSED_RGBA_ASTC_8x5_KHR;case za.ASTC_RGBA_8x6:return QN.COMPRESSED_RGBA_ASTC_8x6_KHR;case za.ASTC_RGBA_8x8:return QN.COMPRESSED_RGBA_ASTC_8x8_KHR;case za.ASTC_RGBA_10x5:return QN.COMPRESSED_RGBA_ASTC_10x5_KHR;case za.ASTC_RGBA_10x6:return QN.COMPRESSED_RGBA_ASTC_10x6_KHR;case za.ASTC_RGBA_10x8:return QN.COMPRESSED_RGBA_ASTC_10x8_KHR;case za.ASTC_RGBA_10x10:return QN.COMPRESSED_RGBA_ASTC_10x10_KHR;case za.ASTC_RGBA_12x10:return QN.COMPRESSED_RGBA_ASTC_12x10_KHR;case za.ASTC_RGBA_12x12:return QN.COMPRESSED_RGBA_ASTC_12x12_KHR;case za.ASTC_SRGBA_4x4:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;case za.ASTC_SRGBA_5x4:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR;case za.ASTC_SRGBA_5x5:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR;case za.ASTC_SRGBA_6x5:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR;case za.ASTC_SRGBA_6x6:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR;case za.ASTC_SRGBA_8x5:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR;case za.ASTC_SRGBA_8x6:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR;case za.ASTC_SRGBA_8x8:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR;case za.ASTC_SRGBA_10x5:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR;case za.ASTC_SRGBA_10x6:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR;case za.ASTC_SRGBA_10x8:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR;case za.ASTC_SRGBA_10x10:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR;case za.ASTC_SRGBA_12x10:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR;case za.ASTC_SRGBA_12x12:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR;default:return console.error("Unsupported Format, convert to WebGL format failed."),t.RGBA}}function nD(e,t){switch(e){case Fa.BOOL:return t.BOOL;case Fa.BOOL2:return t.BOOL_VEC2;case Fa.BOOL3:return t.BOOL_VEC3;case Fa.BOOL4:return t.BOOL_VEC4;case Fa.INT:return t.INT;case Fa.INT2:return t.INT_VEC2;case Fa.INT3:return t.INT_VEC3;case Fa.INT4:return t.INT_VEC4;case Fa.UINT:return t.UNSIGNED_INT;case Fa.FLOAT:return t.FLOAT;case Fa.FLOAT2:return t.FLOAT_VEC2;case Fa.FLOAT3:return t.FLOAT_VEC3;case Fa.FLOAT4:return t.FLOAT_VEC4;case Fa.MAT2:return t.FLOAT_MAT2;case Fa.MAT3:return t.FLOAT_MAT3;case Fa.MAT4:return t.FLOAT_MAT4;case Fa.SAMPLER2D:return t.SAMPLER_2D;case Fa.SAMPLER_CUBE:return t.SAMPLER_CUBE;default:return console.error("Unsupported GLType, convert to GL type failed."),Fa.UNKNOWN}}function iD(e){switch(e){case Fa.BOOL:case Fa.BOOL2:case Fa.BOOL3:case Fa.BOOL4:case Fa.INT:case Fa.INT2:case Fa.INT3:case Fa.INT4:case Fa.UINT:return Int32Array;case Fa.FLOAT:case Fa.FLOAT2:case Fa.FLOAT3:case Fa.FLOAT4:case Fa.MAT2:case Fa.MAT3:case Fa.MAT4:return Float32Array;default:return console.error("Unsupported GLType, convert to TypedArrayConstructor failed."),Float32Array}}function rD(e,t){switch(e){case t.BOOL:return Fa.BOOL;case t.BOOL_VEC2:return Fa.BOOL2;case t.BOOL_VEC3:return Fa.BOOL3;case t.BOOL_VEC4:return Fa.BOOL4;case t.INT:return Fa.INT;case t.INT_VEC2:return Fa.INT2;case t.INT_VEC3:return Fa.INT3;case t.INT_VEC4:return Fa.INT4;case t.UNSIGNED_INT:return Fa.UINT;case t.FLOAT:return Fa.FLOAT;case t.FLOAT_VEC2:return Fa.FLOAT2;case t.FLOAT_VEC3:return Fa.FLOAT3;case t.FLOAT_VEC4:return Fa.FLOAT4;case t.FLOAT_MAT2:return Fa.MAT2;case t.FLOAT_MAT3:return Fa.MAT3;case t.FLOAT_MAT4:return Fa.MAT4;case t.SAMPLER_2D:return Fa.SAMPLER2D;case t.SAMPLER_CUBE:return Fa.SAMPLER_CUBE;default:return console.error("Unsupported GLType, convert to Type failed."),Fa.UNKNOWN}}function aD(e,t){switch(e){case t.BOOL:return 4;case t.BOOL_VEC2:return 8;case t.BOOL_VEC3:return 12;case t.BOOL_VEC4:return 16;case t.INT:return 4;case t.INT_VEC2:return 8;case t.INT_VEC3:return 12;case t.INT_VEC4:return 16;case t.UNSIGNED_INT:case t.FLOAT:return 4;case t.FLOAT_VEC2:return 8;case t.FLOAT_VEC3:return 12;case t.FLOAT_VEC4:case t.FLOAT_MAT2:return 16;case t.FLOAT_MAT3:return 36;case t.FLOAT_MAT4:return 64;case t.SAMPLER_2D:case t.SAMPLER_CUBE:return 4;default:return console.error("Unsupported GLType, get type failed."),0}}function sD(e,t){switch(e){case t.FLOAT_MAT2:return 2;case t.FLOAT_MAT3:return 3;case t.FLOAT_MAT4:return 4;default:return 1}}!function(e){e[e.RGBA16F_EXT=34842]="RGBA16F_EXT",e[e.RGB16F_EXT=34843]="RGB16F_EXT",e[e.RGBA32F_EXT=34836]="RGBA32F_EXT",e[e.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT",e[e.UNSIGNED_NORMALIZED_EXT=35863]="UNSIGNED_NORMALIZED_EXT",e[e.UNSIGNED_INT_24_8_WEBGL=34042]="UNSIGNED_INT_24_8_WEBGL",e[e.HALF_FLOAT_OES=36193]="HALF_FLOAT_OES",e[e.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",e[e.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",e[e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",e[e.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",e[e.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",e[e.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",e[e.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",e[e.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",e[e.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",e[e.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",e[e.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",e[e.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",e[e.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",e[e.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",e[e.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",e[e.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",e[e.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",e[e.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",e[e.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",e[e.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",e[e.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",e[e.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",e[e.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",e[e.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",e[e.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR"}(QN||(QN={}));var oD,cD=[512,513,514,515,516,517,518,519],lD=[0,7680,7681,7682,7683,5386,34055,34056],uD=[32774,32778,32779,32775,32776],hD=[0,1,770,772,771,773,768,774,769,775,776,32769,32770,32771,32772];!function(e){e[e.BEGIN_RENDER_PASS=0]="BEGIN_RENDER_PASS",e[e.END_RENDER_PASS=1]="END_RENDER_PASS",e[e.BIND_STATES=2]="BIND_STATES",e[e.DRAW=3]="DRAW",e[e.UPDATE_BUFFER=4]="UPDATE_BUFFER",e[e.COPY_BUFFER_TO_TEXTURE=5]="COPY_BUFFER_TO_TEXTURE",e[e.COUNT=6]="COUNT"}(oD||(oD={}));var _D=function(e){this.cmdType=void 0,this.refCount=0,this.cmdType=e},fD=function(e){function t(){var t;return(t=e.call(this,oD.BEGIN_RENDER_PASS)||this).gpuRenderPass=null,t.gpuFramebuffer=null,t.renderArea=new Xs,t.clearFlag=ds.NONE,t.clearColors=[],t.clearDepth=1,t.clearStencil=0,t}return X(t,e),t.prototype.clear=function(){this.gpuFramebuffer=null,this.clearColors.length=0},t}(_D),dD=function(e){function t(){var t;return(t=e.call(this,oD.BIND_STATES)||this).gpuPipelineState=null,t.gpuInputAssembler=null,t.gpuDescriptorSets=[],t.dynamicOffsets=[],t.viewport=null,t.scissor=null,t.lineWidth=null,t.depthBias=null,t.blendConstants=[],t.depthBounds=null,t.stencilWriteMask=null,t.stencilCompareMask=null,t}return X(t,e),t.prototype.clear=function(){this.gpuPipelineState=null,this.gpuDescriptorSets.length=0,this.gpuInputAssembler=null,this.dynamicOffsets.length=0,this.viewport=null,this.scissor=null,this.lineWidth=null,this.depthBias=null,this.blendConstants.length=0,this.depthBounds=null,this.stencilWriteMask=null,this.stencilCompareMask=null},t}(_D),pD=function(e){function t(){var t;return(t=e.call(this,oD.DRAW)||this).drawInfo=new ws,t}return X(t,e),t.prototype.clear=function(){},t}(_D),mD=function(e){function t(){var t;return(t=e.call(this,oD.UPDATE_BUFFER)||this).gpuBuffer=null,t.buffer=null,t.offset=0,t.size=0,t}return X(t,e),t.prototype.clear=function(){this.gpuBuffer=null,this.buffer=null},t}(_D),gD=function(e){function t(){var t;return(t=e.call(this,oD.COPY_BUFFER_TO_TEXTURE)||this).gpuTexture=null,t.buffers=[],t.regions=[],t}return X(t,e),t.prototype.clear=function(){this.gpuTexture=null,this.buffers.length=0,this.regions.length=0},t}(_D),vD=function(){function e(){this.cmds=new u_(1),this.beginRenderPassCmds=new u_(1),this.bindStatesCmds=new u_(1),this.drawCmds=new u_(1),this.updateBufferCmds=new u_(1),this.copyBufferToTextureCmds=new u_(1)}return e.prototype.clearCmds=function(e){this.beginRenderPassCmds.length&&(e.beginRenderPassCmdPool.freeCmds(this.beginRenderPassCmds),this.beginRenderPassCmds.clear()),this.bindStatesCmds.length&&(e.bindStatesCmdPool.freeCmds(this.bindStatesCmds),this.bindStatesCmds.clear()),this.drawCmds.length&&(e.drawCmdPool.freeCmds(this.drawCmds),this.drawCmds.clear()),this.updateBufferCmds.length&&(e.updateBufferCmdPool.freeCmds(this.updateBufferCmds),this.updateBufferCmds.clear()),this.copyBufferToTextureCmds.length&&(e.copyBufferToTextureCmdPool.freeCmds(this.copyBufferToTextureCmds),this.copyBufferToTextureCmds.clear()),this.cmds.clear()},e}();function yD(e,t,n,i,r){if(t.usage&Ua.UNIFORM)ArrayBuffer.isView(n)?t.vf32.set(n,i/Float32Array.BYTES_PER_ELEMENT):t.vf32.set(new Float32Array(n),i/Float32Array.BYTES_PER_ELEMENT);else if(t.usage&Ua.INDIRECT)t.indirects.length=i,Array.prototype.push.apply(t.indirects,n.drawInfos);else{var a=n,s=e.gl,o=e.stateCache;switch(t.glTarget){case s.ARRAY_BUFFER:e.useVAO&&o.glVAO&&(e.OES_vertex_array_object.bindVertexArrayOES(null),o.glVAO=SD.gpuInputAssembler=null),e.stateCache.glArrayBuffer!==t.glBuffer&&(s.bindBuffer(s.ARRAY_BUFFER,t.glBuffer),e.stateCache.glArrayBuffer=t.glBuffer);break;case s.ELEMENT_ARRAY_BUFFER:e.useVAO&&o.glVAO&&(e.OES_vertex_array_object.bindVertexArrayOES(null),o.glVAO=SD.gpuInputAssembler=null),e.stateCache.glElementArrayBuffer!==t.glBuffer&&(s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,t.glBuffer),e.stateCache.glElementArrayBuffer=t.glBuffer);break;default:return void console.error("Unsupported BufferType, update buffer failed.")}r===a.byteLength?s.bufferSubData(t.glTarget,i,a):s.bufferSubData(t.glTarget,i,a.slice(0,r))}}var SD={gpuPipelineState:null,gpuInputAssembler:null,reverseCW:!1,glPrimitive:0};function ED(e,t,n,i,r,a,s){var o=e.gl,c=e.stateCache,l=0;if(n&&t){if(c.glFramebuffer!==n.glFramebuffer){o.bindFramebuffer(o.FRAMEBUFFER,n.glFramebuffer),c.glFramebuffer=n.glFramebuffer;var u=!!n.glFramebuffer;if(u!==SD.reverseCW){SD.reverseCW=u;var h=!e.stateCache.rs.isFrontFaceCCW;o.frontFace(h?o.CCW:o.CW),e.stateCache.rs.isFrontFaceCCW=h}}c.viewport.left===i.x&&c.viewport.top===i.y&&c.viewport.width===i.width&&c.viewport.height===i.height||(o.viewport(i.x,i.y,i.width,i.height),c.viewport.left=i.x,c.viewport.top=i.y,c.viewport.width=i.width,c.viewport.height=i.height),c.scissorRect.x===i.x&&c.scissorRect.y===i.y&&c.scissorRect.width===i.width&&c.scissorRect.height===i.height||(o.scissor(i.x,i.y,i.width,i.height),c.scissorRect.x=i.x,c.scissorRect.y=i.y,c.scissorRect.width=i.width,c.scissorRect.height=i.height);var _=r.length;e.WEBGL_draw_buffers||(_=1);for(var f=0;f<_;++f){var d=t.colorAttachments[f];if(d.format!==za.UNKNOWN)switch(d.loadOp){case os.LOAD:break;case os.CLEAR:c.bs.targets[0].blendColorMask!==Qa.ALL&&o.colorMask(!0,!0,!0,!0);var p=r[0];o.clearColor(p.x,p.y,p.z,p.w),l|=o.COLOR_BUFFER_BIT;break;case os.DISCARD:}}if(t.depthStencilAttachment&&t.depthStencilAttachment.format!==za.UNKNOWN){switch(t.depthStencilAttachment.depthLoadOp){case os.LOAD:break;case os.CLEAR:c.dss.depthWrite||o.depthMask(!0),o.clearDepth(a),l|=o.DEPTH_BUFFER_BIT;break;case os.DISCARD:}if(Ts[t.depthStencilAttachment.format].hasStencil)switch(t.depthStencilAttachment.stencilLoadOp){case os.LOAD:break;case os.CLEAR:c.dss.stencilWriteMaskFront||o.stencilMaskSeparate(o.FRONT,65535),c.dss.stencilWriteMaskBack||o.stencilMaskSeparate(o.BACK,65535),o.clearStencil(s),l|=o.STENCIL_BUFFER_BIT;break;case os.DISCARD:}}if(l&&o.clear(l),l&o.COLOR_BUFFER_BIT){var m=c.bs.targets[0].blendColorMask;if(m!==Qa.ALL){var g=(m&Qa.R)!==Qa.NONE,v=(m&Qa.G)!==Qa.NONE,y=(m&Qa.B)!==Qa.NONE,S=(m&Qa.A)!==Qa.NONE;o.colorMask(g,v,y,S)}}l&o.DEPTH_BUFFER_BIT&&!c.dss.depthWrite&&o.depthMask(!1),l&o.STENCIL_BUFFER_BIT&&(c.dss.stencilWriteMaskFront||o.stencilMaskSeparate(o.FRONT,0),c.dss.stencilWriteMaskBack||o.stencilMaskSeparate(o.BACK,0))}}function TD(e,t,n,i,r,a,s,o,c,l,u,h,_){var d,p,m,g=e.gl,v=e.stateCache,y=t&&t.gpuShader,S=!1;if(t&&SD.gpuPipelineState!==t){if(SD.gpuPipelineState=t,SD.glPrimitive=t.glPrimitive,t.gpuShader){var E=t.gpuShader.glProgram;v.glProgram!==E&&(g.useProgram(E),v.glProgram=E,S=!0)}var T=t.rs;if(T){if(v.rs.cullMode!==T.cullMode){switch(T.cullMode){case qa.NONE:g.disable(g.CULL_FACE);break;case qa.FRONT:g.enable(g.CULL_FACE),g.cullFace(g.FRONT);break;case qa.BACK:g.enable(g.CULL_FACE),g.cullFace(g.BACK)}v.rs.cullMode=T.cullMode}var A=SD.reverseCW?!T.isFrontFaceCCW:T.isFrontFaceCCW;v.rs.isFrontFaceCCW!==A&&(g.frontFace(A?g.CCW:g.CW),v.rs.isFrontFaceCCW=A),v.rs.depthBias===T.depthBias&&v.rs.depthBiasSlop===T.depthBiasSlop||(g.polygonOffset(T.depthBias,T.depthBiasSlop),v.rs.depthBias=T.depthBias,v.rs.depthBiasSlop=T.depthBiasSlop),v.rs.lineWidth!==T.lineWidth&&(g.lineWidth(T.lineWidth),v.rs.lineWidth=T.lineWidth)}var x=t.dss;x&&(v.dss.depthTest!==x.depthTest&&(x.depthTest?g.enable(g.DEPTH_TEST):g.disable(g.DEPTH_TEST),v.dss.depthTest=x.depthTest),v.dss.depthWrite!==x.depthWrite&&(g.depthMask(x.depthWrite),v.dss.depthWrite=x.depthWrite),v.dss.depthFunc!==x.depthFunc&&(g.depthFunc(cD[x.depthFunc]),v.dss.depthFunc=x.depthFunc),v.dss.stencilTestFront===x.stencilTestFront&&v.dss.stencilTestBack===x.stencilTestBack||(x.stencilTestFront||x.stencilTestBack?g.enable(g.STENCIL_TEST):g.disable(g.STENCIL_TEST),v.dss.stencilTestFront=x.stencilTestFront,v.dss.stencilTestBack=x.stencilTestBack),v.dss.stencilFuncFront===x.stencilFuncFront&&v.dss.stencilRefFront===x.stencilRefFront&&v.dss.stencilReadMaskFront===x.stencilReadMaskFront||(g.stencilFuncSeparate(g.FRONT,cD[x.stencilFuncFront],x.stencilRefFront,x.stencilReadMaskFront),v.dss.stencilFuncFront=x.stencilFuncFront,v.dss.stencilRefFront=x.stencilRefFront,v.dss.stencilReadMaskFront=x.stencilReadMaskFront),v.dss.stencilFailOpFront===x.stencilFailOpFront&&v.dss.stencilZFailOpFront===x.stencilZFailOpFront&&v.dss.stencilPassOpFront===x.stencilPassOpFront||(g.stencilOpSeparate(g.FRONT,lD[x.stencilFailOpFront],lD[x.stencilZFailOpFront],lD[x.stencilPassOpFront]),v.dss.stencilFailOpFront=x.stencilFailOpFront,v.dss.stencilZFailOpFront=x.stencilZFailOpFront,v.dss.stencilPassOpFront=x.stencilPassOpFront),v.dss.stencilWriteMaskFront!==x.stencilWriteMaskFront&&(g.stencilMaskSeparate(g.FRONT,x.stencilWriteMaskFront),v.dss.stencilWriteMaskFront=x.stencilWriteMaskFront),v.dss.stencilFuncBack===x.stencilFuncBack&&v.dss.stencilRefBack===x.stencilRefBack&&v.dss.stencilReadMaskBack===x.stencilReadMaskBack||(g.stencilFuncSeparate(g.BACK,cD[x.stencilFuncBack],x.stencilRefBack,x.stencilReadMaskBack),v.dss.stencilFuncBack=x.stencilFuncBack,v.dss.stencilRefBack=x.stencilRefBack,v.dss.stencilReadMaskBack=x.stencilReadMaskBack),v.dss.stencilFailOpBack===x.stencilFailOpBack&&v.dss.stencilZFailOpBack===x.stencilZFailOpBack&&v.dss.stencilPassOpBack===x.stencilPassOpBack||(g.stencilOpSeparate(g.BACK,lD[x.stencilFailOpBack],lD[x.stencilZFailOpBack],lD[x.stencilPassOpBack]),v.dss.stencilFailOpBack=x.stencilFailOpBack,v.dss.stencilZFailOpBack=x.stencilZFailOpBack,v.dss.stencilPassOpBack=x.stencilPassOpBack),v.dss.stencilWriteMaskBack!==x.stencilWriteMaskBack&&(g.stencilMaskSeparate(g.BACK,x.stencilWriteMaskBack),v.dss.stencilWriteMaskBack=x.stencilWriteMaskBack));var C=t.bs;if(C){v.bs.isA2C!==C.isA2C&&(C.isA2C?g.enable(g.SAMPLE_ALPHA_TO_COVERAGE):g.disable(g.SAMPLE_ALPHA_TO_COVERAGE),v.bs.isA2C=C.isA2C),v.bs.blendColor.x===C.blendColor.x&&v.bs.blendColor.y===C.blendColor.y&&v.bs.blendColor.z===C.blendColor.z&&v.bs.blendColor.w===C.blendColor.w||(g.blendColor(C.blendColor.x,C.blendColor.y,C.blendColor.z,C.blendColor.w),v.bs.blendColor.x=C.blendColor.x,v.bs.blendColor.y=C.blendColor.y,v.bs.blendColor.z=C.blendColor.z,v.bs.blendColor.w=C.blendColor.w);var R=C.targets[0],b=v.bs.targets[0];b.blend!==R.blend&&(R.blend?g.enable(g.BLEND):g.disable(g.BLEND),b.blend=R.blend),b.blendEq===R.blendEq&&b.blendAlphaEq===R.blendAlphaEq||(g.blendEquationSeparate(uD[R.blendEq],uD[R.blendAlphaEq]),b.blendEq=R.blendEq,b.blendAlphaEq=R.blendAlphaEq),b.blendSrc===R.blendSrc&&b.blendDst===R.blendDst&&b.blendSrcAlpha===R.blendSrcAlpha&&b.blendDstAlpha===R.blendDstAlpha||(g.blendFuncSeparate(hD[R.blendSrc],hD[R.blendDst],hD[R.blendSrcAlpha],hD[R.blendDstAlpha]),b.blendSrc=R.blendSrc,b.blendDst=R.blendDst,b.blendSrcAlpha=R.blendSrcAlpha,b.blendDstAlpha=R.blendDstAlpha),b.blendColorMask!==R.blendColorMask&&(g.colorMask((R.blendColorMask&Qa.R)!==Qa.NONE,(R.blendColorMask&Qa.G)!==Qa.NONE,(R.blendColorMask&Qa.B)!==Qa.NONE,(R.blendColorMask&Qa.A)!==Qa.NONE),b.blendColorMask=R.blendColorMask)}}if(t&&t.gpuPipelineLayout&&y){for(var w=y.glBlocks.length,I=t.gpuPipelineLayout.dynamicOffsetIndices,O=0;O<w;O++){var P=y.glBlocks[O],M=i[P.set],N=M&&M.descriptorIndices[P.binding],D=N>=0&&M.gpuDescriptors[N],B=null,L=0;if(D&&D.gpuBuffer){var F=D.gpuBuffer,z=I[P.set],U=z&&z[P.binding];U>=0&&(L=r[U]),"vf32"in F?B=F.vf32:(L+=F.offset,B=F.gpuBuffer.vf32),L>>=2}if(B)for(var G=P.glActiveUniforms.length,k=0;k<G;k++){var H=P.glActiveUniforms[k];switch(H.glType){case g.BOOL:case g.INT:for(var V=0;V<H.array.length;++V){var W=H.begin+L+V;if(B[W]!==H.array[V]){for(var j=V,q=W;j<H.array.length;++j,++q)H.array[j]=B[q];g.uniform1iv(H.glLoc,H.array);break}}break;case g.BOOL_VEC2:case g.INT_VEC2:for(var X=0;X<H.array.length;++X){var Y=H.begin+L+X;if(B[Y]!==H.array[X]){for(var K=X,Z=Y;K<H.array.length;++K,++Z)H.array[K]=B[Z];g.uniform2iv(H.glLoc,H.array);break}}break;case g.BOOL_VEC3:case g.INT_VEC3:for(var Q=0;Q<H.array.length;++Q){var J=H.begin+L+Q;if(B[J]!==H.array[Q]){for(var $=Q,ee=J;$<H.array.length;++$,++ee)H.array[$]=B[ee];g.uniform3iv(H.glLoc,H.array);break}}break;case g.BOOL_VEC4:case g.INT_VEC4:for(var te=0;te<H.array.length;++te){var ne=H.begin+L+te;if(B[ne]!==H.array[te]){for(var ie=te,re=ne;ie<H.array.length;++ie,++re)H.array[ie]=B[re];g.uniform4iv(H.glLoc,H.array);break}}break;case g.FLOAT:for(var ae=0;ae<H.array.length;++ae){var se=H.begin+L+ae;if(B[se]!==H.array[ae]){for(var oe=ae,ce=se;oe<H.array.length;++oe,++ce)H.array[oe]=B[ce];g.uniform1fv(H.glLoc,H.array);break}}break;case g.FLOAT_VEC2:for(var le=0;le<H.array.length;++le){var ue=H.begin+L+le;if(B[ue]!==H.array[le]){for(var he=le,_e=ue;he<H.array.length;++he,++_e)H.array[he]=B[_e];g.uniform2fv(H.glLoc,H.array);break}}break;case g.FLOAT_VEC3:for(var fe=0;fe<H.array.length;++fe){var de=H.begin+L+fe;if(B[de]!==H.array[fe]){for(var pe=fe,me=de;pe<H.array.length;++pe,++me)H.array[pe]=B[me];g.uniform3fv(H.glLoc,H.array);break}}break;case g.FLOAT_VEC4:for(var ge=0;ge<H.array.length;++ge){var ve=H.begin+L+ge;if(B[ve]!==H.array[ge]){for(var ye=ge,Se=ve;ye<H.array.length;++ye,++Se)H.array[ye]=B[Se];g.uniform4fv(H.glLoc,H.array);break}}break;case g.FLOAT_MAT2:for(var Ee=0;Ee<H.array.length;++Ee){var Te=H.begin+L+Ee;if(B[Te]!==H.array[Ee]){for(var Ae=Ee,xe=Te;Ae<H.array.length;++Ae,++xe)H.array[Ae]=B[xe];g.uniformMatrix2fv(H.glLoc,!1,H.array);break}}break;case g.FLOAT_MAT3:for(var Ce=0;Ce<H.array.length;++Ce){var Re=H.begin+L+Ce;if(B[Re]!==H.array[Ce]){for(var be=Ce,we=Re;be<H.array.length;++be,++we)H.array[be]=B[we];g.uniformMatrix3fv(H.glLoc,!1,H.array);break}}break;case g.FLOAT_MAT4:for(var Ie=0;Ie<H.array.length;++Ie){var Oe=H.begin+L+Ie;if(B[Oe]!==H.array[Ie]){for(var Pe=Ie,Me=Oe;Pe<H.array.length;++Pe,++Me)H.array[Pe]=B[Me];g.uniformMatrix4fv(H.glLoc,!1,H.array);break}}}}else f("Buffer binding '"+P.name+"' at set "+P.set+" binding "+P.binding+" is not bounded")}for(var Ne=y.glSamplers.length,De=0;De<Ne;De++)for(var Be=y.glSamplers[De],Le=i[Be.set],Fe=Le&&Le.descriptorIndices[Be.binding],ze=Fe>=0&&Le.gpuDescriptors[Fe],Ue=Be.units.length,Ge=0;Ge<Ue;Ge++){var ke=Be.units[Ge];if(ze&&ze.gpuSampler){if(ze.gpuTexture&&ze.gpuTexture.size>0){var He=ze.gpuTexture,Ve=v.glTexUnits[ke];Ve.glTexture!==He.glTexture&&(v.texUnit!==ke&&(g.activeTexture(g.TEXTURE0+ke),v.texUnit=ke),He.glTexture?g.bindTexture(He.glTarget,He.glTexture):g.bindTexture(He.glTarget,e.nullTex2D.gpuTexture.glTexture),Ve.glTexture=He.glTexture);var We=ze.gpuSampler;He.isPowerOf2?(d=We.glWrapS,p=We.glWrapT):(d=g.CLAMP_TO_EDGE,p=g.CLAMP_TO_EDGE),m=He.isPowerOf2?He.mipLevel<=1&&(We.glMinFilter===g.LINEAR_MIPMAP_NEAREST||We.glMinFilter===g.LINEAR_MIPMAP_LINEAR)?g.LINEAR:We.glMinFilter:We.glMinFilter===g.LINEAR||We.glMinFilter===g.LINEAR_MIPMAP_NEAREST||We.glMinFilter===g.LINEAR_MIPMAP_LINEAR?g.LINEAR:g.NEAREST,He.glWrapS!==d&&(v.texUnit!==ke&&(g.activeTexture(g.TEXTURE0+ke),v.texUnit=ke),g.texParameteri(He.glTarget,g.TEXTURE_WRAP_S,d),He.glWrapS=d),He.glWrapT!==p&&(v.texUnit!==ke&&(g.activeTexture(g.TEXTURE0+ke),v.texUnit=ke),g.texParameteri(He.glTarget,g.TEXTURE_WRAP_T,p),He.glWrapT=p),He.glMinFilter!==m&&(v.texUnit!==ke&&(g.activeTexture(g.TEXTURE0+ke),v.texUnit=ke),g.texParameteri(He.glTarget,g.TEXTURE_MIN_FILTER,m),He.glMinFilter=m),He.glMagFilter!==We.glMagFilter&&(v.texUnit!==ke&&(g.activeTexture(g.TEXTURE0+ke),v.texUnit=ke),g.texParameteri(He.glTarget,g.TEXTURE_MAG_FILTER,We.glMagFilter),He.glMagFilter=We.glMagFilter)}ze=Le.gpuDescriptors[++Fe]}else f("Sampler binding '"+Be.name+"' at set "+Be.set+" binding "+Be.binding+" index "+Ge+" is not bounded")}}if(n&&y&&(S||SD.gpuInputAssembler!==n)){SD.gpuInputAssembler=n;var je=e.ANGLE_instanced_arrays;if(e.useVAO){var qe=e.OES_vertex_array_object,Xe=n.glVAOs.get(y.glProgram);if(!Xe){var Ye;Xe=qe.createVertexArrayOES(),n.glVAOs.set(y.glProgram,Xe),qe.bindVertexArrayOES(Xe),g.bindBuffer(g.ARRAY_BUFFER,null),g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,null),v.glArrayBuffer=null,v.glElementArrayBuffer=null;for(var Ke=y.glInputs.length,Ze=0;Ze<Ke;Ze++){var Qe=y.glInputs[Ze];Ye=null;for(var Je=n.glAttribs.length,$e=0;$e<Je;$e++){var et=n.glAttribs[$e];if(et.name===Qe.name){Ye=et;break}}if(Ye){v.glArrayBuffer!==Ye.glBuffer&&(g.bindBuffer(g.ARRAY_BUFFER,Ye.glBuffer),v.glArrayBuffer=Ye.glBuffer);for(var tt=0;tt<Ye.componentCount;++tt){var nt=Qe.glLoc+tt,it=Ye.offset+Ye.size*tt;g.enableVertexAttribArray(nt),v.glCurrentAttribLocs[nt]=!0,g.vertexAttribPointer(nt,Ye.count,Ye.glType,Ye.isNormalized,Ye.stride,it),je&&je.vertexAttribDivisorANGLE(nt,Ye.isInstanced?1:0)}}}var rt=n.gpuIndexBuffer;rt&&g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,rt.glBuffer),qe.bindVertexArrayOES(null),g.bindBuffer(g.ARRAY_BUFFER,null),g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,null),v.glArrayBuffer=null,v.glElementArrayBuffer=null}v.glVAO!==Xe&&(qe.bindVertexArrayOES(Xe),v.glVAO=Xe)}else{for(var at=0;at<e.maxVertexAttributes;++at)v.glCurrentAttribLocs[at]=!1;for(var st=y.glInputs.length,ot=0;ot<st;ot++){for(var ct=y.glInputs[ot],lt=null,ut=n.glAttribs.length,ht=0;ht<ut;ht++){var _t=n.glAttribs[ht];if(_t.name===ct.name){lt=_t;break}}if(lt){v.glArrayBuffer!==lt.glBuffer&&(g.bindBuffer(g.ARRAY_BUFFER,lt.glBuffer),v.glArrayBuffer=lt.glBuffer);for(var ft=0;ft<lt.componentCount;++ft){var dt=ct.glLoc+ft,pt=lt.offset+lt.size*ft;!v.glEnabledAttribLocs[dt]&&dt>=0&&(g.enableVertexAttribArray(dt),v.glEnabledAttribLocs[dt]=!0),v.glCurrentAttribLocs[dt]=!0,g.vertexAttribPointer(dt,lt.count,lt.glType,lt.isNormalized,lt.stride,pt),je&&je.vertexAttribDivisorANGLE(dt,lt.isInstanced?1:0)}}}var mt=n.gpuIndexBuffer;mt&&v.glElementArrayBuffer!==mt.glBuffer&&(g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,mt.glBuffer),v.glElementArrayBuffer=mt.glBuffer);for(var gt=0;gt<e.maxVertexAttributes;++gt)v.glEnabledAttribLocs[gt]!==v.glCurrentAttribLocs[gt]&&(g.disableVertexAttribArray(gt),v.glEnabledAttribLocs[gt]=!1)}}if(t&&t.dynamicStates.length)for(var vt=t.dynamicStates.length,yt=0;yt<vt;yt++)switch(t.dynamicStates[yt]){case hs.VIEWPORT:a&&(v.viewport.left===a.left&&v.viewport.top===a.top&&v.viewport.width===a.width&&v.viewport.height===a.height||(g.viewport(a.left,a.top,a.width,a.height),v.viewport.left=a.left,v.viewport.top=a.top,v.viewport.width=a.width,v.viewport.height=a.height));break;case hs.SCISSOR:s&&(v.scissorRect.x===s.x&&v.scissorRect.y===s.y&&v.scissorRect.width===s.width&&v.scissorRect.height===s.height||(g.scissor(s.x,s.y,s.width,s.height),v.scissorRect.x=s.x,v.scissorRect.y=s.y,v.scissorRect.width=s.width,v.scissorRect.height=s.height));break;case hs.LINE_WIDTH:o&&v.rs.lineWidth!==o&&(g.lineWidth(o),v.rs.lineWidth=o);break;case hs.DEPTH_BIAS:c&&(v.rs.depthBias===c.constantFactor&&v.rs.depthBiasSlop===c.slopeFactor||(g.polygonOffset(c.constantFactor,c.slopeFactor),v.rs.depthBias=c.constantFactor,v.rs.depthBiasSlop=c.slopeFactor));break;case hs.BLEND_CONSTANTS:v.bs.blendColor.x===l[0]&&v.bs.blendColor.y===l[1]&&v.bs.blendColor.z===l[2]&&v.bs.blendColor.w===l[3]||(g.blendColor(l[0],l[1],l[2],l[3]),v.bs.blendColor.x=l[0],v.bs.blendColor.y=l[1],v.bs.blendColor.z=l[2],v.bs.blendColor.w=l[3]);break;case hs.STENCIL_WRITE_MASK:if(h)switch(h.face){case _s.FRONT:v.dss.stencilWriteMaskFront!==h.writeMask&&(g.stencilMaskSeparate(g.FRONT,h.writeMask),v.dss.stencilWriteMaskFront=h.writeMask);break;case _s.BACK:v.dss.stencilWriteMaskBack!==h.writeMask&&(g.stencilMaskSeparate(g.BACK,h.writeMask),v.dss.stencilWriteMaskBack=h.writeMask);break;case _s.ALL:v.dss.stencilWriteMaskFront===h.writeMask&&v.dss.stencilWriteMaskBack===h.writeMask||(g.stencilMask(h.writeMask),v.dss.stencilWriteMaskFront=h.writeMask,v.dss.stencilWriteMaskBack=h.writeMask)}break;case hs.STENCIL_COMPARE_MASK:if(_)switch(_.face){case _s.FRONT:v.dss.stencilRefFront===_.reference&&v.dss.stencilReadMaskFront===_.compareMask||(g.stencilFuncSeparate(g.FRONT,cD[v.dss.stencilFuncFront],_.reference,_.compareMask),v.dss.stencilRefFront=_.reference,v.dss.stencilReadMaskFront=_.compareMask);break;case _s.BACK:v.dss.stencilRefBack===_.reference&&v.dss.stencilReadMaskBack===_.compareMask||(g.stencilFuncSeparate(g.BACK,cD[v.dss.stencilFuncBack],_.reference,_.compareMask),v.dss.stencilRefBack=_.reference,v.dss.stencilReadMaskBack=_.compareMask);break;case _s.ALL:v.dss.stencilRefFront===_.reference&&v.dss.stencilReadMaskFront===_.compareMask&&v.dss.stencilRefBack===_.reference&&v.dss.stencilReadMaskBack===_.compareMask||(g.stencilFunc(cD[v.dss.stencilFuncBack],_.reference,_.compareMask),v.dss.stencilRefFront=_.reference,v.dss.stencilReadMaskFront=_.compareMask,v.dss.stencilRefBack=_.reference,v.dss.stencilReadMaskBack=_.compareMask)}}}function AD(e,t){var n=e.gl,i=e.ANGLE_instanced_arrays,r=SD.gpuInputAssembler,a=SD.glPrimitive;if(r)if(r.gpuIndirectBuffer)for(var s=r.gpuIndirectBuffer.indirects.length,o=0;o<s;o++){var c=r.gpuIndirectBuffer.indirects[o],l=r.gpuIndexBuffer;if(c.instanceCount&&i)if(l){if(c.indexCount>0){var u=c.firstIndex*l.stride;i.drawElementsInstancedANGLE(a,c.indexCount,r.glIndexType,u,c.instanceCount)}}else c.vertexCount>0&&i.drawArraysInstancedANGLE(a,c.firstVertex,c.vertexCount,c.instanceCount);else if(l){if(c.indexCount>0){var h=c.firstIndex*l.stride;n.drawElements(a,c.indexCount,r.glIndexType,h)}}else c.vertexCount>0&&n.drawArrays(a,c.firstVertex,c.vertexCount)}else{var _=r.gpuIndexBuffer;if(t.instanceCount&&i)if(_){if(t.indexCount>0){var f=t.firstIndex*_.stride;i.drawElementsInstancedANGLE(a,t.indexCount,r.glIndexType,f,t.instanceCount)}}else t.vertexCount>0&&i.drawArraysInstancedANGLE(a,t.firstVertex,t.vertexCount,t.instanceCount);else if(_){if(t.indexCount>0){var d=t.firstIndex*_.stride;n.drawElements(a,t.indexCount,r.glIndexType,d)}}else t.vertexCount>0&&n.drawArrays(a,t.firstVertex,t.vertexCount)}}var xD=new Array(oD.COUNT);function CD(e,t){xD.fill(0);for(var n=0;n<t.cmds.length;++n){var i=t.cmds.array[n],r=xD[i]++;switch(i){case oD.BEGIN_RENDER_PASS:var a=t.beginRenderPassCmds.array[r];ED(e,a.gpuRenderPass,a.gpuFramebuffer,a.renderArea,a.clearColors,a.clearDepth,a.clearStencil);break;case oD.BIND_STATES:var s=t.bindStatesCmds.array[r];TD(e,s.gpuPipelineState,s.gpuInputAssembler,s.gpuDescriptorSets,s.dynamicOffsets,s.viewport,s.scissor,s.lineWidth,s.depthBias,s.blendConstants,s.depthBounds,s.stencilWriteMask,s.stencilCompareMask);break;case oD.DRAW:AD(e,t.drawCmds.array[r].drawInfo);break;case oD.UPDATE_BUFFER:var o=t.updateBufferCmds.array[r];yD(e,o.gpuBuffer,o.buffer,o.offset,o.size);break;case oD.COPY_BUFFER_TO_TEXTURE:var c=t.copyBufferToTextureCmds.array[r];RD(e,c.buffers,c.gpuTexture,c.regions)}}}function RD(e,t,n,i){var r=e.gl,a=e.stateCache.glTexUnits[e.stateCache.texUnit];a.glTexture!==n.glTexture&&(r.bindTexture(n.glTarget,n.glTexture),a.glTexture=n.glTexture);var s=0,o=1,c=1,l=0,u=Ts[n.format].isCompressed;switch(n.glTarget){case r.TEXTURE_2D:for(var h=0;h<i.length;h++){var _=i[h];o=_.texExtent.width,c=_.texExtent.height;var f=t[s++];u?n.glInternalFmt===QN.COMPRESSED_RGB_ETC1_WEBGL||e.noCompressedTexSubImage2D?r.compressedTexImage2D(r.TEXTURE_2D,_.texSubres.mipLevel,n.glInternalFmt,o,c,0,f):r.compressedTexSubImage2D(r.TEXTURE_2D,_.texSubres.mipLevel,_.texOffset.x,_.texOffset.y,o,c,n.glFormat,f):r.texSubImage2D(r.TEXTURE_2D,_.texSubres.mipLevel,_.texOffset.x,_.texOffset.y,o,c,n.glFormat,n.glType,f)}break;case r.TEXTURE_CUBE_MAP:for(var d=0;d<i.length;d++){var p=i[d],m=p.texSubres.baseArrayLayer+p.texSubres.layerCount;for(l=p.texSubres.baseArrayLayer;l<m;++l){o=p.texExtent.width,c=p.texExtent.height;var g=t[s++];u?n.glInternalFmt===QN.COMPRESSED_RGB_ETC1_WEBGL||e.noCompressedTexSubImage2D?r.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+l,p.texSubres.mipLevel,n.glInternalFmt,o,c,0,g):r.compressedTexSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+l,p.texSubres.mipLevel,p.texOffset.x,p.texOffset.y,o,c,n.glFormat,g):r.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+l,p.texSubres.mipLevel,p.texOffset.x,p.texOffset.y,o,c,n.glFormat,n.glType,g)}}break;default:console.error("Unsupported GL texture type, copy buffer to texture failed.")}n.flags&is.GEN_MIPMAP&&r.generateMipmap(n.glTarget)}var bD=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._gpuBuffer=null,t._gpuBufferView=null,t._uniformBuffer=null,t}X(t,e);var n=t.prototype;return n.initialize=function(e){if("buffer"in e){this._isBufferView=!0;var t=e.buffer;this._usage=t.usage,this._memUsage=t.memUsage,this._size=this._stride=e.range,this._count=1,this._flags=t.flags,this._gpuBufferView={gpuBuffer:t.gpuBuffer,offset:e.offset,range:e.range}}else this._usage=e.usage,this._memUsage=e.memUsage,this._size=e.size,this._stride=Math.max(e.stride||this._size,1),this._count=this._size/this._stride,this._flags=e.flags,this._usage&Ua.INDIRECT&&(this._indirectBuffer=new Os),this._flags&ka.BAKUP_BUFFER&&(this._bakcupBuffer=new Uint8Array(this._size),this._device.memoryStatus.bufferSize+=this._size),this._usage&Ua.UNIFORM&&this._size>0&&(this._uniformBuffer=new Uint8Array(this._size)),this._gpuBuffer={usage:this._usage,memUsage:this._memUsage,size:this._size,stride:this._stride,buffer:this._bakcupBuffer,vf32:null,indirects:[],glTarget:0,glBuffer:null},e.usage&Ua.INDIRECT&&(this._gpuBuffer.indirects=this._indirectBuffer.drawInfos),this._usage&Ua.UNIFORM&&(this._gpuBuffer.buffer=this._uniformBuffer),function(e,t){var n=e.gl,i=e.stateCache,r=t.memUsage&Ga.HOST?n.DYNAMIC_DRAW:n.STATIC_DRAW;if(t.usage&Ua.VERTEX){t.glTarget=n.ARRAY_BUFFER;var a=n.createBuffer();a&&(t.glBuffer=a,t.size>0&&(e.useVAO&&i.glVAO&&(e.OES_vertex_array_object.bindVertexArrayOES(null),i.glVAO=SD.gpuInputAssembler=null),e.stateCache.glArrayBuffer!==t.glBuffer&&(n.bindBuffer(n.ARRAY_BUFFER,t.glBuffer),e.stateCache.glArrayBuffer=t.glBuffer),n.bufferData(n.ARRAY_BUFFER,t.size,r),n.bindBuffer(n.ARRAY_BUFFER,null),e.stateCache.glArrayBuffer=null))}else if(t.usage&Ua.INDEX){t.glTarget=n.ELEMENT_ARRAY_BUFFER;var s=n.createBuffer();s&&(t.glBuffer=s,t.size>0&&(e.useVAO&&i.glVAO&&(e.OES_vertex_array_object.bindVertexArrayOES(null),i.glVAO=SD.gpuInputAssembler=null),e.stateCache.glElementArrayBuffer!==t.glBuffer&&(n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t.glBuffer),e.stateCache.glElementArrayBuffer=t.glBuffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.size,r),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null),e.stateCache.glElementArrayBuffer=null))}else t.usage&Ua.UNIFORM?(t.glTarget=n.NONE,t.buffer&&(t.vf32=new Float32Array(t.buffer.buffer))):(t.usage&Ua.INDIRECT||t.usage&Ua.TRANSFER_DST||t.usage&Ua.TRANSFER_SRC||console.error("Unsupported BufferType, create buffer failed."),t.glTarget=n.NONE)}(this._device,this._gpuBuffer),this._device.memoryStatus.bufferSize+=this._size;return!0},n.destroy=function(){var e,t;this._gpuBuffer&&(e=this._device,(t=this._gpuBuffer).glBuffer&&(e.gl.deleteBuffer(t.glBuffer),t.glBuffer=null),this._device.memoryStatus.bufferSize-=this._size,this._gpuBuffer=null),this._gpuBufferView&&(this._gpuBufferView=null),this._bakcupBuffer=null},n.resize=function(e){if(this._isBufferView)console.warn("cannot resize buffer views!");else{var t=this._size;if(t!==e){if(this._size=e,this._count=this._size/this._stride,this._bakcupBuffer){var n=this._bakcupBuffer;this._bakcupBuffer=new Uint8Array(this._size),this._bakcupBuffer.set(n),this._device.memoryStatus.bufferSize-=t,this._device.memoryStatus.bufferSize+=e}this._uniformBuffer&&(this._uniformBuffer=new Uint8Array(e)),this._gpuBuffer&&(this._uniformBuffer?this._gpuBuffer.buffer=this._uniformBuffer:this._bakcupBuffer&&(this._gpuBuffer.buffer=this._bakcupBuffer),this._gpuBuffer.size=e,e>0&&(function(e,t){var n=e.gl,i=e.stateCache,r=t.memUsage&Ga.HOST?n.DYNAMIC_DRAW:n.STATIC_DRAW;t.usage&Ua.VERTEX?(e.useVAO&&i.glVAO&&(e.OES_vertex_array_object.bindVertexArrayOES(null),i.glVAO=SD.gpuInputAssembler=null),e.stateCache.glArrayBuffer!==t.glBuffer&&n.bindBuffer(n.ARRAY_BUFFER,t.glBuffer),t.buffer?n.bufferData(n.ARRAY_BUFFER,t.buffer,r):n.bufferData(n.ARRAY_BUFFER,t.size,r),n.bindBuffer(n.ARRAY_BUFFER,null),e.stateCache.glArrayBuffer=null):t.usage&Ua.INDEX?(e.useVAO&&i.glVAO&&(e.OES_vertex_array_object.bindVertexArrayOES(null),i.glVAO=SD.gpuInputAssembler=null),e.stateCache.glElementArrayBuffer!==t.glBuffer&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t.glBuffer),t.buffer?n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.buffer,r):n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.size,r),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null),e.stateCache.glElementArrayBuffer=null):t.usage&Ua.UNIFORM?t.buffer&&(t.vf32=new Float32Array(t.buffer.buffer)):(t.usage&Ua.INDIRECT||t.usage&Ua.TRANSFER_DST||t.usage&Ua.TRANSFER_SRC||console.error("Unsupported BufferType, create buffer failed."),t.glTarget=n.NONE)}(this._device,this._gpuBuffer),this._device.memoryStatus.bufferSize-=t,this._device.memoryStatus.bufferSize+=e))}}},n.update=function(e,t){if(this._isBufferView)console.warn("cannot update through buffer views!");else{var n;if(n=void 0!==t?t:this._usage&Ua.INDIRECT?0:e.byteLength,this._bakcupBuffer&&e!==this._bakcupBuffer.buffer){var i=new Uint8Array(e,0,t);this._bakcupBuffer.set(i)}yD(this._device,this._gpuBuffer,e,0,n)}},j(t,[{key:"gpuBuffer",get:function(){return this._gpuBuffer}},{key:"gpuBufferView",get:function(){return this._gpuBufferView}}]),t}(Ns),wD=function(){function e(e,t){this._frees=void 0,this._freeIdx=0,this._freeCmds=void 0,this._frees=new Array(t),this._freeCmds=new u_(t);for(var n=0;n<t;++n)this._frees[n]=new e;this._freeIdx=t-1}var t=e.prototype;return t.alloc=function(e){if(this._freeIdx<0){var t=2*this._frees.length,n=this._frees;this._frees=new Array(t);for(var i=t-n.length,r=0;r<i;++r)this._frees[r]=new e;for(var a=i,s=0;a<t;++a,++s)this._frees[a]=n[s];this._freeIdx+=i}var o=this._frees[this._freeIdx];return this._frees[this._freeIdx--]=null,++o.refCount,o},t.free=function(e){0==--e.refCount&&this._freeCmds.push(e)},t.freeCmds=function(e){for(var t=0;t<e.length;++t)0==--e.array[t].refCount&&this._freeCmds.push(e.array[t])},t.release=function(){for(var e=0;e<this._freeCmds.length;++e){var t=this._freeCmds.array[e];t.clear(),this._frees[++this._freeIdx]=t}this._freeCmds.clear()},e}(),ID=function(){function e(){this.beginRenderPassCmdPool=void 0,this.bindStatesCmdPool=void 0,this.drawCmdPool=void 0,this.updateBufferCmdPool=void 0,this.copyBufferToTextureCmdPool=void 0,this.beginRenderPassCmdPool=new wD(fD,1),this.bindStatesCmdPool=new wD(dD,1),this.drawCmdPool=new wD(pD,1),this.updateBufferCmdPool=new wD(mD,1),this.copyBufferToTextureCmdPool=new wD(gD,1)}var t=e.prototype;return t.clearCmds=function(e){e.beginRenderPassCmds.length&&(this.beginRenderPassCmdPool.freeCmds(e.beginRenderPassCmds),e.beginRenderPassCmds.clear()),e.bindStatesCmds.length&&(this.bindStatesCmdPool.freeCmds(e.bindStatesCmds),e.bindStatesCmds.clear()),e.drawCmds.length&&(this.drawCmdPool.freeCmds(e.drawCmds),e.drawCmds.clear()),e.updateBufferCmds.length&&(this.updateBufferCmdPool.freeCmds(e.updateBufferCmds),e.updateBufferCmds.clear()),e.copyBufferToTextureCmds.length&&(this.copyBufferToTextureCmdPool.freeCmds(e.copyBufferToTextureCmds),e.copyBufferToTextureCmds.clear()),e.cmds.clear()},t.releaseCmds=function(){this.beginRenderPassCmdPool.release(),this.bindStatesCmdPool.release(),this.drawCmdPool.release(),this.updateBufferCmdPool.release(),this.copyBufferToTextureCmdPool.release()},e}(),OD=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this).cmdPackage=new vD,t._webGLAllocator=null,t._isInRenderPass=!1,t._curGPUPipelineState=null,t._curGPUInputAssembler=null,t._curGPUDescriptorSets=[],t._curDynamicOffsets=[],t._curViewport=null,t._curScissor=null,t._curLineWidth=null,t._curDepthBias=null,t._curBlendConstants=[],t._curDepthBounds=null,t._curStencilWriteMask=null,t._curStencilCompareMask=null,t._isStateInvalied=!1,t}X(t,e);var n=t.prototype;return n.initialize=function(e){this._type=e.type,this._queue=e.queue,this._webGLAllocator=this._device.cmdAllocator;for(var t=this._device.bindingMappingInfo.bufferOffsets.length,n=0;n<t;n++)this._curGPUDescriptorSets.push(null),this._curDynamicOffsets.push([]);return!0},n.destroy=function(){this._webGLAllocator&&(this._webGLAllocator.clearCmds(this.cmdPackage),this._webGLAllocator=null)},n.begin=function(){this._webGLAllocator.clearCmds(this.cmdPackage),this._curGPUPipelineState=null,this._curGPUInputAssembler=null,this._curGPUDescriptorSets.length=0;for(var e=0;e<this._curDynamicOffsets.length;e++)this._curDynamicOffsets[e].length=0;this._curViewport=null,this._curScissor=null,this._curLineWidth=null,this._curDepthBias=null,this._curBlendConstants.length=0,this._curDepthBounds=null,this._curStencilWriteMask=null,this._curStencilCompareMask=null,this._numDrawCalls=0,this._numInstances=0,this._numTris=0},n.end=function(){this._isStateInvalied&&this.bindStates(),this._isInRenderPass=!1},n.beginRenderPass=function(e,t,n,i,r,a){var s=this._webGLAllocator.beginRenderPassCmdPool.alloc(fD);s.gpuRenderPass=e.gpuRenderPass,s.gpuFramebuffer=t.gpuFramebuffer,s.renderArea=n,s.clearColors.length=i.length;for(var o=0;o<i.length;++o)s.clearColors[o]=i[o];s.clearDepth=r,s.clearStencil=a,this.cmdPackage.beginRenderPassCmds.push(s),this.cmdPackage.cmds.push(oD.BEGIN_RENDER_PASS),this._isInRenderPass=!0},n.endRenderPass=function(){this._isInRenderPass=!1},n.bindPipelineState=function(e){var t=e.gpuPipelineState;t!==this._curGPUPipelineState&&(this._curGPUPipelineState=t,this._isStateInvalied=!0)},n.bindDescriptorSet=function(e,t,n){var i=t.gpuDescriptorSet;if(i!==this._curGPUDescriptorSets[e]&&(this._curGPUDescriptorSets[e]=i,this._isStateInvalied=!0),n){for(var r=this._curDynamicOffsets[e],a=0;a<n.length;a++)r[a]=n[a];r.length=n.length,this._isStateInvalied=!0}},n.bindInputAssembler=function(e){var t=e.gpuInputAssembler;this._curGPUInputAssembler=t,this._isStateInvalied=!0},n.setViewport=function(e){this._curViewport?this._curViewport.left===e.left&&this._curViewport.top===e.top&&this._curViewport.width===e.width&&this._curViewport.height===e.height&&this._curViewport.minDepth===e.minDepth&&this._curViewport.maxDepth===e.maxDepth||(this._curViewport.left=e.left,this._curViewport.top=e.top,this._curViewport.width=e.width,this._curViewport.height=e.height,this._curViewport.minDepth=e.minDepth,this._curViewport.maxDepth=e.maxDepth,this._isStateInvalied=!0):this._curViewport=new Ys(e.left,e.top,e.width,e.height,e.minDepth,e.maxDepth)},n.setScissor=function(e){this._curScissor?this._curScissor.x===e.x&&this._curScissor.y===e.y&&this._curScissor.width===e.width&&this._curScissor.height===e.height||(this._curScissor.x=e.x,this._curScissor.y=e.y,this._curScissor.width=e.width,this._curScissor.height=e.height,this._isStateInvalied=!0):this._curScissor=new Xs(e.x,e.y,e.width,e.height)},n.setLineWidth=function(e){this._curLineWidth!==e&&(this._curLineWidth=e,this._isStateInvalied=!0)},n.setDepthBias=function(e,t,n){this._curDepthBias?this._curDepthBias.constantFactor===e&&this._curDepthBias.clamp===t&&this._curDepthBias.slopeFactor===n||(this._curDepthBias.constantFactor=e,this._curDepthBias.clamp=t,this._curDepthBias.slopeFactor=n,this._isStateInvalied=!0):(this._curDepthBias={constantFactor:e,clamp:t,slopeFactor:n},this._isStateInvalied=!0)},n.setBlendConstants=function(e){4!==e.length||this._curBlendConstants[0]===e[0]&&this._curBlendConstants[1]===e[1]&&this._curBlendConstants[2]===e[2]&&this._curBlendConstants[3]===e[3]||(this._curBlendConstants.length=0,Array.prototype.push.apply(this._curBlendConstants,e),this._isStateInvalied=!0)},n.setDepthBound=function(e,t){this._curDepthBounds&&this._curDepthBounds.minBounds===e&&this._curDepthBounds.maxBounds===t||(this._curDepthBounds={minBounds:e,maxBounds:t},this._isStateInvalied=!0)},n.setStencilWriteMask=function(e,t){this._curStencilWriteMask?this._curStencilWriteMask.face===e&&this._curStencilWriteMask.writeMask===t||(this._curStencilWriteMask.face=e,this._curStencilWriteMask.writeMask=t,this._isStateInvalied=!0):(this._curStencilWriteMask={face:e,writeMask:t},this._isStateInvalied=!0)},n.setStencilCompareMask=function(e,t,n){this._curStencilCompareMask?this._curStencilCompareMask.face===e&&this._curStencilCompareMask.reference===t&&this._curStencilCompareMask.compareMask===n||(this._curStencilCompareMask.face=e,this._curStencilCompareMask.reference=t,this._curStencilCompareMask.compareMask=n,this._isStateInvalied=!0):(this._curStencilCompareMask={face:e,reference:t,compareMask:n},this._isStateInvalied=!0)},n.draw=function(e){if(this._type===ss.PRIMARY&&this._isInRenderPass||this._type===ss.SECONDARY){this._isStateInvalied&&this.bindStates();var t=this._webGLAllocator.drawCmdPool.alloc(pD);t.drawInfo.vertexCount=e.vertexCount,t.drawInfo.firstVertex=e.firstVertex,t.drawInfo.indexCount=e.indexCount,t.drawInfo.firstIndex=e.firstIndex,t.drawInfo.vertexOffset=e.vertexOffset,t.drawInfo.instanceCount=e.instanceCount,t.drawInfo.firstInstance=e.firstInstance,this.cmdPackage.drawCmds.push(t),this.cmdPackage.cmds.push(oD.DRAW),++this._numDrawCalls,this._numInstances+=e.instanceCount;var n=e.indexCount||e.vertexCount;if(this._curGPUPipelineState)switch(this._curGPUPipelineState.glPrimitive){case 4:this._numTris+=n/3*Math.max(e.instanceCount,1);break;case 5:case 6:this._numTris+=(n-2)*Math.max(e.instanceCount,1)}}else console.error("Command 'draw' must be recorded inside a render pass.")},n.updateBuffer=function(e,t,n){if(this._type===ss.PRIMARY&&!this._isInRenderPass||this._type===ss.SECONDARY){var i=e.gpuBuffer;if(i){var r,a=this._webGLAllocator.updateBufferCmdPool.alloc(mD),s=0;e.usage&Ua.INDIRECT||(s=void 0!==n?n:t.byteLength),r=t,a.gpuBuffer=i,a.buffer=r,a.offset=0,a.size=s,this.cmdPackage.updateBufferCmds.push(a),this.cmdPackage.cmds.push(oD.UPDATE_BUFFER)}}else console.error("Command 'updateBuffer' must be recorded outside a render pass.")},n.copyBuffersToTexture=function(e,t,n){if(this._type===ss.PRIMARY&&!this._isInRenderPass||this._type===ss.SECONDARY){var i=t.gpuTexture;if(i){var r=this._webGLAllocator.copyBufferToTextureCmdPool.alloc(gD);r&&(r.gpuTexture=i,r.regions=n,r.buffers=e,this.cmdPackage.copyBufferToTextureCmds.push(r),this.cmdPackage.cmds.push(oD.COPY_BUFFER_TO_TEXTURE))}}else console.error("Command 'copyBufferToTexture' must be recorded outside a render pass.")},n.execute=function(e,t){for(var n=0;n<t;++n){for(var i=e[n],r=0;r<i.cmdPackage.beginRenderPassCmds.length;++r){var a=i.cmdPackage.beginRenderPassCmds.array[r];++a.refCount,this.cmdPackage.beginRenderPassCmds.push(a)}for(var s=0;s<i.cmdPackage.bindStatesCmds.length;++s){var o=i.cmdPackage.bindStatesCmds.array[s];++o.refCount,this.cmdPackage.bindStatesCmds.push(o)}for(var c=0;c<i.cmdPackage.drawCmds.length;++c){var l=i.cmdPackage.drawCmds.array[c];++l.refCount,this.cmdPackage.drawCmds.push(l)}for(var u=0;u<i.cmdPackage.updateBufferCmds.length;++u){var h=i.cmdPackage.updateBufferCmds.array[u];++h.refCount,this.cmdPackage.updateBufferCmds.push(h)}for(var _=0;_<i.cmdPackage.copyBufferToTextureCmds.length;++_){var f=i.cmdPackage.copyBufferToTextureCmds.array[_];++f.refCount,this.cmdPackage.copyBufferToTextureCmds.push(f)}this.cmdPackage.cmds.concat(i.cmdPackage.cmds.array),this._numDrawCalls+=i._numDrawCalls,this._numInstances+=i._numInstances,this._numTris+=i._numTris}},n.bindStates=function(){var e=this._webGLAllocator.bindStatesCmdPool.alloc(dD);if(e){e.gpuPipelineState=this._curGPUPipelineState,Array.prototype.push.apply(e.gpuDescriptorSets,this._curGPUDescriptorSets);for(var t=0;t<this._curDynamicOffsets.length;t++)Array.prototype.push.apply(e.dynamicOffsets,this._curDynamicOffsets[t]);e.gpuInputAssembler=this._curGPUInputAssembler,e.viewport=this._curViewport,e.scissor=this._curScissor,e.lineWidth=this._curLineWidth,e.depthBias=this._curDepthBias,Array.prototype.push.apply(e.blendConstants,this._curBlendConstants),e.depthBounds=this._curDepthBounds,e.stencilWriteMask=this._curStencilWriteMask,e.stencilCompareMask=this._curStencilCompareMask,this.cmdPackage.bindStatesCmds.push(e),this.cmdPackage.cmds.push(oD.BIND_STATES),this._isStateInvalied=!1}},j(t,[{key:"webGLDevice",get:function(){return this._device}}]),t}(Bs),PD=function(e){function t(){return e.apply(this,arguments)||this}X(t,e);var n=t.prototype;return n.initialize=function(){return!0},n.destroy=function(){},n.wait=function(){},n.reset=function(){},t}(Go),MD=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._gpuFramebuffer=null,t}X(t,e);var n=t.prototype;return n.initialize=function(e){this._renderPass=e.renderPass,this._colorTextures=e.colorTextures||[],this._depthStencilTexture=e.depthStencilTexture||null,0!==e.depStencilMipmapLevel&&console.warn("The mipmap level of th texture image to be attached of depth stencil attachment should be 0. Convert to 0.");for(var t=0;t<e.colorMipmapLevels.length;++t)0!==e.colorMipmapLevels[t]&&console.warn("The mipmap level of th texture image to be attached of color attachment "+t+" should be 0. Convert to 0.");for(var n=[],i=0;i<e.colorTextures.length;++i){var r=e.colorTextures[i];r&&n.push(r.gpuTexture)}var a=null;return e.depthStencilTexture&&(a=e.depthStencilTexture.gpuTexture),this._gpuFramebuffer={gpuRenderPass:e.renderPass.gpuRenderPass,gpuColorTextures:n,gpuDepthStencilTexture:a,glFramebuffer:null},function(e,t){if(t.gpuColorTextures.length||t.gpuDepthStencilTexture){var n=e.gl,i=[],r=n.createFramebuffer();if(r){t.glFramebuffer=r,e.stateCache.glFramebuffer!==t.glFramebuffer&&n.bindFramebuffer(n.FRAMEBUFFER,t.glFramebuffer);for(var a=0;a<t.gpuColorTextures.length;++a){var s=t.gpuColorTextures[a];s&&(s.glTexture?n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+a,s.glTarget,s.glTexture,0):n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+a,n.RENDERBUFFER,s.glRenderbuffer),i.push(n.COLOR_ATTACHMENT0+a))}var o=t.gpuDepthStencilTexture;if(o){var c=Ts[o.format].hasStencil?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;o.glTexture?n.framebufferTexture2D(n.FRAMEBUFFER,c,o.glTarget,o.glTexture,0):n.framebufferRenderbuffer(n.FRAMEBUFFER,c,n.RENDERBUFFER,o.glRenderbuffer)}e.WEBGL_draw_buffers&&e.WEBGL_draw_buffers.drawBuffersWEBGL(i);var l=n.checkFramebufferStatus(n.FRAMEBUFFER);if(l!==n.FRAMEBUFFER_COMPLETE)switch(l){case n.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:console.error("glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_ATTACHMENT");break;case n.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:console.error("glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT");break;case n.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:console.error("glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_DIMENSIONS");break;case n.FRAMEBUFFER_UNSUPPORTED:console.error("glCheckFramebufferStatus() - FRAMEBUFFER_UNSUPPORTED")}e.stateCache.glFramebuffer!==t.glFramebuffer&&n.bindFramebuffer(n.FRAMEBUFFER,e.stateCache.glFramebuffer)}}}(this._device,this._gpuFramebuffer),!0},n.destroy=function(){var e,t;this._gpuFramebuffer&&(e=this._device,(t=this._gpuFramebuffer).glFramebuffer&&(e.gl.deleteFramebuffer(t.glFramebuffer),t.glFramebuffer=null),this._gpuFramebuffer=null)},j(t,[{key:"gpuFramebuffer",get:function(){return this._gpuFramebuffer}}]),t}(Gs),ND=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._gpuInputAssembler=null,t}X(t,e);var n=t.prototype;return n.initialize=function(e){if(0===e.vertexBuffers.length)return console.error("InputAssemblerInfo.vertexBuffers is null."),!1;if(this._attributes=e.attributes,this._attributesHash=this.computeAttributesHash(),this._vertexBuffers=e.vertexBuffers,e.indexBuffer)this._indexBuffer=e.indexBuffer,this._indexCount=this._indexBuffer.size/this._indexBuffer.stride,this._firstIndex=0;else{var t=this._vertexBuffers[0];this._vertexCount=t.size/t.stride,this._firstVertex=0,this._vertexOffset=0}this._instanceCount=0,this._firstInstance=0,this._indirectBuffer=e.indirectBuffer||null;for(var n=new Array(e.vertexBuffers.length),i=0;i<e.vertexBuffers.length;++i){var r=e.vertexBuffers[i];r.gpuBuffer&&(n[i]=r.gpuBuffer)}var a=null,s=0;if(e.indexBuffer&&(a=e.indexBuffer.gpuBuffer))switch(a.stride){case 1:s=5121;break;case 2:s=5123;break;case 4:s=5125;break;default:console.error("Error index buffer stride.")}var o=null;return e.indirectBuffer&&(o=e.indirectBuffer.gpuBuffer),this._gpuInputAssembler={attributes:e.attributes,gpuVertexBuffers:n,gpuIndexBuffer:a,gpuIndirectBuffer:o,glAttribs:[],glIndexType:s,glVAOs:new Map},function(e,t){var n=e.gl;t.glAttribs=new Array(t.attributes.length);for(var i=[0,0,0,0,0,0,0,0],r=0;r<t.attributes.length;++r){var a=t.attributes[r],s=void 0!==a.stream?a.stream:0,o=t.gpuVertexBuffers[s],c=$N(a.format,n),l=Ts[a.format].size;t.glAttribs[r]={name:a.name,glBuffer:o.glBuffer,glType:c,size:l,count:Ts[a.format].count,stride:o.stride,componentCount:sD(c,n),isNormalized:void 0!==a.isNormalized&&a.isNormalized,isInstanced:void 0!==a.isInstanced&&a.isInstanced,offset:i[s]},i[s]+=l}}(this._device,this._gpuInputAssembler),!0},n.destroy=function(){var e=this._device;this._gpuInputAssembler&&e.useVAO&&function(e,t){for(var n=t.glVAOs.values(),i=n.next();!i.done;)e.OES_vertex_array_object.deleteVertexArrayOES(i.value),i=n.next();t.glVAOs.clear()}(e,this._gpuInputAssembler),this._gpuInputAssembler=null},j(t,[{key:"gpuInputAssembler",get:function(){return this._gpuInputAssembler}}]),t}(qs),DD=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._gpuDescriptorSetLayout=null,t}X(t,e);var n=t.prototype;return n.initialize=function(e){Array.prototype.push.apply(this._bindings,e.bindings);for(var t=0,n=-1,i=[],r=0;r<this._bindings.length;r++){var a=this._bindings[r];i.push(t),t+=a.count,a.binding>n&&(n=a.binding)}this._bindingIndices=Array(n+1).fill(-1);for(var s=this._descriptorIndices=Array(n+1).fill(-1),o=0;o<this._bindings.length;o++){var c=this._bindings[o];this._bindingIndices[c.binding]=o,s[c.binding]=i[o]}for(var l=[],u=0;u<this._bindings.length;u++){var h=this._bindings[u];if(h.descriptorType&Bo)for(var _=0;_<h.count;_++)l.push(h.binding)}return this._gpuDescriptorSetLayout={bindings:this._bindings,dynamicBindings:l,descriptorIndices:s,descriptorCount:t},!0},n.destroy=function(){this._bindings.length=0},j(t,[{key:"gpuDescriptorSetLayout",get:function(){return this._gpuDescriptorSetLayout}}]),t}(Lo),BD=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._gpuPipelineLayout=null,t}X(t,e);var n=t.prototype;return n.initialize=function(e){Array.prototype.push.apply(this._setLayouts,e.setLayouts);for(var t=[],n=[],i=0,r=0;r<this._setLayouts.length;r++){for(var a=this._setLayouts[r],s=a.gpuDescriptorSetLayout.dynamicBindings,o=Array(a.bindingIndices.length).fill(-1),c=0;c<s.length;c++){var l=s[c];o[l]<0&&(o[l]=i+c)}n.push(a.gpuDescriptorSetLayout),t.push(o),i+=s.length}return this._gpuPipelineLayout={gpuSetLayouts:n,dynamicOffsetIndices:t,dynamicOffsetCount:i},!0},n.destroy=function(){this._setLayouts.length=0},j(t,[{key:"gpuPipelineLayout",get:function(){return this._gpuPipelineLayout}}]),t}(zo),LD=[0,1,3,2,0,0,0,4,5,6,0,0,0,0],FD=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._gpuPipelineState=null,t}X(t,e);var n=t.prototype;return n.initialize=function(e){this._primitive=e.primitive,this._shader=e.shader,this._pipelineLayout=e.pipelineLayout;var t=this._bs;if(e.blendState){var n=e.blendState,i=n.targets;i&&i.forEach((function(e,n){t.setTarget(n,e)})),void 0!==n.isA2C&&(t.isA2C=n.isA2C),void 0!==n.isIndepend&&(t.isIndepend=n.isIndepend),void 0!==n.blendColor&&(t.blendColor=n.blendColor)}Object.assign(this._rs,e.rasterizerState),Object.assign(this._dss,e.depthStencilState),this._is=e.inputState,this._renderPass=e.renderPass,this._dynamicStates=e.dynamicStates;for(var r=[],a=0;a<31;a++)this._dynamicStates&1<<a&&r.push(1<<a);return this._gpuPipelineState={glPrimitive:LD[e.primitive],gpuShader:e.shader.gpuShader,gpuPipelineLayout:e.pipelineLayout.gpuPipelineLayout,rs:e.rasterizerState,dss:e.depthStencilState,bs:e.blendState,gpuRenderPass:e.renderPass.gpuRenderPass,dynamicStates:r},!0},n.destroy=function(){this._gpuPipelineState=null},j(t,[{key:"gpuPipelineState",get:function(){return this._gpuPipelineState}}]),t}(oo),zD=[],UD=function(e){function t(){return e.apply(this,arguments)||this}X(t,e);var n=t.prototype;return n.beginRenderPass=function(e,t,n,i,r,a){ED(this._device,e.gpuRenderPass,t.gpuFramebuffer,n,i,r,a),this._isInRenderPass=!0},n.draw=function(e){if(this._isInRenderPass){this._isStateInvalied&&this.bindStates(),AD(this._device,e),++this._numDrawCalls,this._numInstances+=e.instanceCount;var t=e.indexCount||e.vertexCount;if(this._curGPUPipelineState)switch(this._curGPUPipelineState.glPrimitive){case 4:this._numTris+=t/3*Math.max(e.instanceCount,1);break;case 5:case 6:this._numTris+=(t-2)*Math.max(e.instanceCount,1)}}else console.error("Command 'draw' must be recorded inside a render pass.")},n.updateBuffer=function(e,t,n){if(this._isInRenderPass)console.error("Command 'updateBuffer' must be recorded outside a render pass.");else{var i,r=e.gpuBuffer;r&&(i=void 0!==n?n:e.usage&Ua.INDIRECT?0:t.byteLength,yD(this._device,r,t,0,i))}},n.copyBuffersToTexture=function(e,t,n){if(this._isInRenderPass)console.error("Command 'copyBufferToTexture' must be recorded outside a render pass.");else{var i=t.gpuTexture;i&&RD(this._device,e,i,n)}},n.execute=function(e,t){for(var n=0;n<t;++n){var i=e[n];CD(this._device,i.cmdPackage),this._numDrawCalls+=i._numDrawCalls,this._numInstances+=i._numInstances,this._numTris+=i._numTris}},n.bindStates=function(){zD.length=0;for(var e=0;e<this._curDynamicOffsets.length;e++)Array.prototype.push.apply(zD,this._curDynamicOffsets[e]);TD(this._device,this._curGPUPipelineState,this._curGPUInputAssembler,this._curGPUDescriptorSets,zD,this._curViewport,this._curScissor,this._curLineWidth,this._curDepthBias,this._curBlendConstants,this._curDepthBounds,this._curStencilWriteMask,this._curStencilCompareMask),this._isStateInvalied=!1},t}(OD),GD=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this).numDrawCalls=0,t.numInstances=0,t.numTris=0,t}X(t,e);var n=t.prototype;return n.initialize=function(e){return this._type=e.type,!0},n.destroy=function(){},n.submit=function(e){if(!this._isAsync)for(var t=e.length,n=0;n<t;n++){var i=e[n];this.numDrawCalls+=i.numDrawCalls,this.numInstances+=i.numInstances,this.numTris+=i.numTris}},n.clear=function(){this.numDrawCalls=0,this.numInstances=0,this.numTris=0},t}(lo),kD=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._gpuRenderPass=null,t}X(t,e);var n=t.prototype;return n.initialize=function(e){return this._colorInfos=e.colorAttachments,this._depthStencilInfo=e.depthStencilAttachment,e.subPasses&&(this._subPasses=e.subPasses),this._gpuRenderPass={colorAttachments:this._colorInfos,depthStencilAttachment:this._depthStencilInfo},this._hash=this.computeHash(),!0},n.destroy=function(){this._gpuRenderPass=null},j(t,[{key:"gpuRenderPass",get:function(){return this._gpuRenderPass}}]),t}(po),HD=[10497,33648,33071,33071],VD=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._gpuSampler=null,t}X(t,e);var n=t.prototype;return n.initialize=function(e){this._minFilter=e.minFilter,this._magFilter=e.magFilter,this._mipFilter=e.mipFilter,this._addressU=e.addressU,this._addressV=e.addressV,this._addressW=e.addressW,this._maxAnisotropy=e.maxAnisotropy,this._cmpFunc=e.cmpFunc,this._borderColor=e.borderColor,this._minLOD=e.minLOD,this._maxLOD=e.maxLOD,this._mipLODBias=e.mipLODBias;var t,n,i=this._minFilter,r=this._magFilter,a=this._mipFilter;t=i===Ja.LINEAR||i===Ja.ANISOTROPIC?a===Ja.LINEAR||a===Ja.ANISOTROPIC?9987:a===Ja.POINT?9985:9729:a===Ja.LINEAR||a===Ja.ANISOTROPIC?9986:a===Ja.POINT?9984:9728,n=r===Ja.LINEAR||r===Ja.ANISOTROPIC?9729:9728;var s=HD[this._addressU],o=HD[this._addressV],c=HD[this._addressW];return this._gpuSampler={glMinFilter:t,glMagFilter:n,glWrapS:s,glWrapT:o,glWrapR:c},!0},n.destroy=function(){this._gpuSampler=null},j(t,[{key:"gpuSampler",get:function(){return this._gpuSampler}}]),t}(go),WD=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._gpuShader=null,t}X(t,e);var n=t.prototype;return n.initialize=function(e){this._name=e.name,this._stages=e.stages,this._attributes=e.attributes,this._blocks=e.blocks,this._samplers=e.samplers,this._gpuShader={name:e.name,blocks:e.blocks,samplers:e.samplers,gpuStages:new Array(e.stages.length),glProgram:null,glInputs:[],glUniforms:[],glBlocks:[],glSamplers:[]};for(var t=0;t<e.stages.length;++t){var n=e.stages[t];this._gpuShader.gpuStages[t]={type:n.stage,source:n.source,glShader:null}}return function(e,t){for(var n=e.gl,i=function(e){var i=t.gpuStages[e],r=0,a="",s=1;switch(i.type){case rs.VERTEX:a="VertexShader",r=n.VERTEX_SHADER;break;case rs.FRAGMENT:a="FragmentShader",r=n.FRAGMENT_SHADER;break;default:return console.error("Unsupported ShaderType."),{v:void 0}}var o=n.createShader(r);if(o&&(i.glShader=o,n.shaderSource(i.glShader,i.source),n.compileShader(i.glShader),!n.getShaderParameter(i.glShader,n.COMPILE_STATUS))){console.error(a+" in '"+t.name+"' compilation failed."),console.error("Shader source dump:",i.source.replace(/^|\n/g,(function(){return"\n"+s+++" "}))),console.error(n.getShaderInfoLog(i.glShader));for(var c=0;c<t.gpuStages.length;c++){var l=t.gpuStages[e];l.glShader&&(n.deleteShader(l.glShader),l.glShader=null)}return{v:void 0}}},r=0;r<t.gpuStages.length;r++){var a=i(r);if("object"==typeof a)return a.v}var s=n.createProgram();if(s){t.glProgram=s;for(var o=0;o<t.gpuStages.length;o++){var c=t.gpuStages[o];n.attachShader(t.glProgram,c.glShader)}if(n.linkProgram(t.glProgram),e.destroyShadersImmediately)for(var l=0;l<t.gpuStages.length;l++){var u=t.gpuStages[l];u.glShader&&(n.detachShader(t.glProgram,u.glShader),n.deleteShader(u.glShader),u.glShader=null)}if(!n.getProgramParameter(t.glProgram,n.LINK_STATUS))return console.error("Failed to link shader '"+t.name+"'."),void console.error(n.getProgramInfoLog(t.glProgram));console.info("Shader '"+t.name+"' compilation succeeded.");var h=n.getProgramParameter(t.glProgram,n.ACTIVE_ATTRIBUTES);t.glInputs=new Array(h);for(var _=0;_<h;++_){var f=n.getActiveAttrib(t.glProgram,_);if(f){var d,p=f.name.indexOf("[");d=-1!==p?f.name.substr(0,p):f.name;var m=n.getAttribLocation(t.glProgram,d),g=rD(f.type,n),v=aD(f.type,n);t.glInputs[_]={binding:m,name:d,type:g,stride:v,count:f.size,size:v*f.size,glType:f.type,glLoc:m}}}if(t.blocks.length>0){t.glBlocks=new Array(t.blocks.length);for(var y=0;y<t.blocks.length;++y){var S=t.blocks[y],E={set:S.set,binding:S.binding,name:S.name,size:0,glUniforms:new Array(S.members.length),glActiveUniforms:[]};t.glBlocks[y]=E;for(var T=0;T<S.members.length;++T){var A=S.members[T],x=nD(A.type,n),C=iD(A.type),R=aD(x,n),b=R*A.count,w=E.size/4,I=new C(b/4);E.glUniforms[T]={binding:-1,name:A.name,type:A.type,stride:R,count:A.count,size:b,offset:E.size,glType:x,glLoc:-1,array:I,begin:w},E.size+=b}}}if(t.samplers.length>0){t.glSamplers=new Array(t.samplers.length);for(var O=0;O<t.samplers.length;++O){var P=t.samplers[O];t.glSamplers[O]={set:P.set,binding:P.binding,name:P.name,type:P.type,count:P.count,units:[],glUnits:null,glType:nD(P.type,n),glLoc:null}}}for(var M=n.getProgramParameter(t.glProgram,n.ACTIVE_UNIFORMS),N=0;N<M;++N){var D=n.getActiveUniform(t.glProgram,N);if(D&&D.type!==n.SAMPLER_2D&&D.type!==n.SAMPLER_CUBE){var B=n.getUniformLocation(t.glProgram,D.name);if(null!==B&&("number"==typeof B||-1!==B.id)){var L,F=D.name.indexOf("[");L=-1!==F?D.name.substr(0,F):D.name;for(var z=0;z<t.glBlocks.length;z++)for(var U=t.glBlocks[z],G=0;G<U.glUniforms.length;G++){var k=U.glUniforms[G];if(k.name===L){k.glLoc=B,U.glActiveUniforms.push(k);break}}}}}for(var H=[],V=[],W=e.bindingMappingInfo,j=e.stateCache.texUnitCacheMap,q=0,X=0;X<t.blocks.length;++X)t.blocks[X].set===W.flexibleSet&&q++;for(var Y=0,K=0;K<t.samplers.length;++K){var Z=t.samplers[K],Q=n.getUniformLocation(t.glProgram,Z.name);if(null===Q||"number"!=typeof Q&&-1===Q.id||(H.push(t.glSamplers[K]),V.push(Q)),void 0===j[Z.name]){var J=Z.binding+W.samplerOffsets[Z.set]+Y;Z.set===W.flexibleSet&&(J-=q),j[Z.name]=J%e.maxTextureUnits,Y+=Z.count-1}}if(H.length){for(var $=[],ee=0;ee<H.length;++ee){var te=H[ee],ne=j[te.name];if(void 0!==ne){te.glLoc=V[ee];for(var ie=0;ie<te.count;++ie){for(;$[ne];)ne=(ne+1)%e.maxTextureUnits;te.units.push(ne),$[ne]=!0}}}for(var re=0,ae=0;ae<H.length;++ae){var se=H[ae];if(!se.glLoc){se.glLoc=V[ae];for(var oe=0;oe<se.count;++oe){for(;$[re];)re=(re+1)%e.maxTextureUnits;void 0===j[se.name]&&(j[se.name]=re),se.units.push(re),$[re]=!0}}}e.stateCache.glProgram!==t.glProgram&&n.useProgram(t.glProgram);for(var ce=0;ce<H.length;ce++){var le=H[ce];le.glUnits=new Int32Array(le.units),n.uniform1iv(le.glLoc,le.glUnits)}e.stateCache.glProgram!==t.glProgram&&n.useProgram(e.stateCache.glProgram)}for(var ue=0;ue<t.glBlocks.length;)t.glBlocks[ue].glActiveUniforms.length?ue++:(t.glBlocks[ue]=t.glBlocks[t.glBlocks.length-1],t.glBlocks.length--);t.glSamplers=H}}(this._device,this._gpuShader),!0},n.destroy=function(){this._gpuShader&&(function(e,t){if(t.glProgram){var n=e.gl;if(!e.destroyShadersImmediately)for(var i=0;i<t.gpuStages.length;i++){var r=t.gpuStages[i];r.glShader&&(n.detachShader(t.glProgram,r.glShader),n.deleteShader(r.glShader),r.glShader=null)}n.deleteProgram(t.glProgram),t.glProgram=null}}(this._device,this._gpuShader),this._gpuShader=null)},j(t,[{key:"gpuShader",get:function(){return this._gpuShader}}]),t}(Ao),jD=function(){function e(){this.glArrayBuffer=null,this.glElementArrayBuffer=null,this.glVAO=null,this.texUnit=0,this.glTexUnits=[],this.glRenderbuffer=null,this.glFramebuffer=null,this.viewport=new Ys,this.scissorRect=new Xs(0,0,0,0),this.rs=new to,this.dss=new no,this.bs=new ro,this.glProgram=null,this.glEnabledAttribLocs=[],this.glCurrentAttribLocs=[],this.texUnitCacheMap={}}return e.prototype.initialize=function(e,t){for(var n=0;n<e;++n)this.glTexUnits.push({glTexture:null});this.glEnabledAttribLocs.length=t,this.glEnabledAttribLocs.fill(!1),this.glCurrentAttribLocs.length=t,this.glCurrentAttribLocs.fill(!1)},e}(),qD=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._gpuTexture=null,t}X(t,e);var n=t.prototype;return n.initialize=function(e){return"texture"in e?(console.log("WebGL does not support texture view."),!1):(this._type=e.type,this._usage=e.usage,this._format=e.format,this._width=e.width,this._height=e.height,this._depth=e.depth,this._layerCount=e.layerCount,this._levelCount=e.levelCount,this._samples=e.samples,this._flags=e.flags,this._isPowerOf2=Ro(this._width)&&Ro(this._height),this._size=xs(this._format,this.width,this.height,this.depth,this._levelCount)*this._layerCount,this._flags&is.BAKUP_BUFFER&&(this._buffer=new ArrayBuffer(this._size)),this._gpuTexture={type:this._type,format:this._format,usage:this._usage,width:this._width,height:this._height,depth:this._depth,size:this._size,arrayLayer:this._layerCount,mipLevel:this._levelCount,samples:this._samples,flags:this._flags,isPowerOf2:this._isPowerOf2,glTarget:0,glInternalFmt:0,glFormat:0,glType:0,glUsage:0,glTexture:null,glRenderbuffer:null,glWrapS:0,glWrapT:0,glMinFilter:0,glMagFilter:0},function(e,t){var n=e.gl;t.glInternalFmt=eD(t.format,n),t.glFormat=tD(t.format,n),t.glType=$N(t.format,n);var i=t.width,r=t.height;switch(t.type){case es.TEX2D:t.glTarget=n.TEXTURE_2D;var a=Math.max(i,r);if(a>e.maxTextureSize&&A(9100,a,e.maxTextureSize),!e.WEBGL_depth_texture&&Ts[t.format].hasDepth){var s=n.createRenderbuffer();s&&t.size>0&&(t.glRenderbuffer=s,e.stateCache.glRenderbuffer!==t.glRenderbuffer&&(n.bindRenderbuffer(n.RENDERBUFFER,t.glRenderbuffer),e.stateCache.glRenderbuffer=t.glRenderbuffer),t.glInternalFmt===n.DEPTH_COMPONENT&&(t.glInternalFmt=n.DEPTH_COMPONENT16),n.renderbufferStorage(n.RENDERBUFFER,t.glInternalFmt,i,r))}else if(t.samples===ns.X1){var o=n.createTexture();if(o&&t.size>0){t.glTexture=o;var c=e.stateCache.glTexUnits[e.stateCache.texUnit];if(c.glTexture!==t.glTexture&&(n.bindTexture(n.TEXTURE_2D,t.glTexture),c.glTexture=t.glTexture),Ts[t.format].isCompressed)if(t.glInternalFmt!==QN.COMPRESSED_RGB_ETC1_WEBGL)for(var l=0;l<t.mipLevel;++l){var u=As(t.format,i,r,1),h=new Uint8Array(u);n.compressedTexImage2D(n.TEXTURE_2D,l,t.glInternalFmt,i,r,0,h),i=Math.max(1,i>>1),r=Math.max(1,r>>1)}else{var _=As(t.format,2,2,1),f=new Uint8Array(_);n.compressedTexImage2D(n.TEXTURE_2D,0,t.glInternalFmt,2,2,0,f)}else for(var d=0;d<t.mipLevel;++d)n.texImage2D(n.TEXTURE_2D,d,t.glInternalFmt,i,r,0,t.glFormat,t.glType,null),i=Math.max(1,i>>1),r=Math.max(1,r>>1);t.isPowerOf2?(t.glWrapS=n.REPEAT,t.glWrapT=n.REPEAT):(t.glWrapS=n.CLAMP_TO_EDGE,t.glWrapT=n.CLAMP_TO_EDGE),t.glMinFilter=n.LINEAR,t.glMagFilter=n.LINEAR,n.texParameteri(t.glTarget,n.TEXTURE_WRAP_S,t.glWrapS),n.texParameteri(t.glTarget,n.TEXTURE_WRAP_T,t.glWrapT),n.texParameteri(t.glTarget,n.TEXTURE_MIN_FILTER,t.glMinFilter),n.texParameteri(t.glTarget,n.TEXTURE_MAG_FILTER,t.glMagFilter)}else n.deleteTexture(o)}break;case es.CUBE:t.glTarget=n.TEXTURE_CUBE_MAP;var p=Math.max(i,r);p>e.maxCubeMapTextureSize&&A(9100,p,e.maxTextureSize);var m=n.createTexture();if(m&&t.size>0){t.glTexture=m;var g=e.stateCache.glTexUnits[e.stateCache.texUnit];if(g.glTexture!==t.glTexture&&(n.bindTexture(n.TEXTURE_CUBE_MAP,t.glTexture),g.glTexture=t.glTexture),Ts[t.format].isCompressed)if(t.glInternalFmt!==QN.COMPRESSED_RGB_ETC1_WEBGL)for(var v=0;v<6;++v){i=t.width,r=t.height;for(var y=0;y<t.mipLevel;++y){var S=As(t.format,i,r,1),E=new Uint8Array(S);n.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+v,y,t.glInternalFmt,i,r,0,E),i=Math.max(1,i>>1),r=Math.max(1,r>>1)}}else for(var T=0;T<6;++T){var x=As(t.format,2,2,1),C=new Uint8Array(x);n.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+T,0,t.glInternalFmt,2,2,0,C)}else for(var R=0;R<6;++R){i=t.width,r=t.height;for(var b=0;b<t.mipLevel;++b)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+R,b,t.glInternalFmt,i,r,0,t.glFormat,t.glType,null),i=Math.max(1,i>>1),r=Math.max(1,r>>1)}t.isPowerOf2?(t.glWrapS=n.REPEAT,t.glWrapT=n.REPEAT):(t.glWrapS=n.CLAMP_TO_EDGE,t.glWrapT=n.CLAMP_TO_EDGE),t.glMinFilter=n.LINEAR,t.glMagFilter=n.LINEAR,n.texParameteri(t.glTarget,n.TEXTURE_WRAP_S,t.glWrapS),n.texParameteri(t.glTarget,n.TEXTURE_WRAP_T,t.glWrapT),n.texParameteri(t.glTarget,n.TEXTURE_MIN_FILTER,t.glMinFilter),n.texParameteri(t.glTarget,n.TEXTURE_MAG_FILTER,t.glMagFilter)}break;default:console.error("Unsupported TextureType, create texture failed."),t.type=es.TEX2D,t.glTarget=n.TEXTURE_2D}}(this._device,this._gpuTexture),this._device.memoryStatus.textureSize+=this._size,!0)},n.destroy=function(){var e,t;this._gpuTexture&&(e=this._device,(t=this._gpuTexture).glTexture&&(e.gl.deleteTexture(t.glTexture),t.glTexture=null),t.glRenderbuffer&&(e.gl.deleteRenderbuffer(t.glRenderbuffer),t.glRenderbuffer=null),this._device.memoryStatus.textureSize-=this._size,this._gpuTexture=null),this._buffer=null},n.resize=function(e,t){var n=this._size;this._width=e,this._height=t,this._size=xs(this._format,this.width,this.height,this.depth,this._levelCount)*this._layerCount,this._gpuTexture&&(this._gpuTexture.width=e,this._gpuTexture.height=t,this._gpuTexture.size=this._size,function(e,t){var n=e.gl;t.glInternalFmt=eD(t.format,n),t.glFormat=tD(t.format,n),t.glType=$N(t.format,n);var i=t.width,r=t.height;switch(t.type){case es.TEX2D:t.glTarget=n.TEXTURE_2D;var a=Math.max(i,r);if(a>e.maxTextureSize&&A(9100,a,e.maxTextureSize),t.glRenderbuffer)e.stateCache.glRenderbuffer!==t.glRenderbuffer&&(n.bindRenderbuffer(n.RENDERBUFFER,t.glRenderbuffer),e.stateCache.glRenderbuffer=t.glRenderbuffer),n.renderbufferStorage(n.RENDERBUFFER,t.glInternalFmt,i,r);else if(t.glTexture){var s=e.stateCache.glTexUnits[e.stateCache.texUnit];if(s.glTexture!==t.glTexture&&(n.bindTexture(n.TEXTURE_2D,t.glTexture),s.glTexture=t.glTexture),Ts[t.format].isCompressed){if(t.glInternalFmt!==QN.COMPRESSED_RGB_ETC1_WEBGL)for(var o=0;o<t.mipLevel;++o){var c=As(t.format,i,r,1),l=new Uint8Array(c);n.compressedTexImage2D(n.TEXTURE_2D,o,t.glInternalFmt,i,r,0,l),i=Math.max(1,i>>1),r=Math.max(1,r>>1)}}else for(var u=0;u<t.mipLevel;++u)n.texImage2D(n.TEXTURE_2D,u,t.glInternalFmt,i,r,0,t.glFormat,t.glType,null),i=Math.max(1,i>>1),r=Math.max(1,r>>1)}break;case es.CUBE:t.glTarget=n.TEXTURE_CUBE_MAP;var h=Math.max(i,r);h>e.maxCubeMapTextureSize&&A(9100,h,e.maxTextureSize);var _=e.stateCache.glTexUnits[e.stateCache.texUnit];if(_.glTexture!==t.glTexture&&(n.bindTexture(n.TEXTURE_CUBE_MAP,t.glTexture),_.glTexture=t.glTexture),Ts[t.format].isCompressed){if(t.glInternalFmt!==QN.COMPRESSED_RGB_ETC1_WEBGL)for(var f=0;f<6;++f){i=t.width,r=t.height;for(var d=0;d<t.mipLevel;++d){var p=As(t.format,i,r,1),m=new Uint8Array(p);n.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+f,d,t.glInternalFmt,i,r,0,m),i=Math.max(1,i>>1),r=Math.max(1,r>>1)}}}else for(var g=0;g<6;++g){i=t.width,r=t.height;for(var v=0;v<t.mipLevel;++v)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+g,v,t.glInternalFmt,i,r,0,t.glFormat,t.glType,null),i=Math.max(1,i>>1),r=Math.max(1,r>>1)}break;default:console.error("Unsupported TextureType, create texture failed."),t.type=es.TEX2D,t.glTarget=n.TEXTURE_2D}}(this._device,this._gpuTexture),this._device.memoryStatus.textureSize-=n,this._device.memoryStatus.textureSize+=this._size)},j(t,[{key:"gpuTexture",get:function(){return this._gpuTexture}}]),t}(bo),XD=e("WebGLDevice",function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this).stateCache=new jD,t.cmdAllocator=new ID,t.nullTex2D=null,t.nullTexCube=null,t._webGLRC=null,t._isAntialias=!0,t._isPremultipliedAlpha=!0,t._useVAO=!1,t._destroyShadersImmediately=!0,t._noCompressedTexSubImage2D=!1,t._bindingMappingInfo=new Ls,t._webGLContextLostHandler=null,t._extensions=null,t._EXT_texture_filter_anisotropic=null,t._EXT_blend_minmax=null,t._EXT_frag_depth=null,t._EXT_shader_texture_lod=null,t._EXT_sRGB=null,t._OES_vertex_array_object=null,t._EXT_color_buffer_half_float=null,t._WEBGL_color_buffer_float=null,t._WEBGL_compressed_texture_etc1=null,t._WEBGL_compressed_texture_etc=null,t._WEBGL_compressed_texture_pvrtc=null,t._WEBGL_compressed_texture_astc=null,t._WEBGL_compressed_texture_s3tc=null,t._WEBGL_compressed_texture_s3tc_srgb=null,t._WEBGL_debug_shaders=null,t._WEBGL_draw_buffers=null,t._WEBGL_lose_context=null,t._WEBGL_depth_texture=null,t._WEBGL_debug_renderer_info=null,t._OES_texture_half_float=null,t._OES_texture_half_float_linear=null,t._OES_texture_float=null,t._OES_texture_float_linear=null,t._OES_standard_derivatives=null,t._OES_element_index_uint=null,t._ANGLE_instanced_arrays=null,t}X(t,e);var n=t.prototype;return n.initialize=function(e){this._canvas=e.canvasElm,this._isAntialias=e.isAntialias,this._isPremultipliedAlpha=e.isPremultipliedAlpha,this._bindingMappingInfo=e.bindingMappingInfo,this._bindingMappingInfo.bufferOffsets.length||this._bindingMappingInfo.bufferOffsets.push(0),this._bindingMappingInfo.samplerOffsets.length||this._bindingMappingInfo.samplerOffsets.push(0);try{var t={alpha:ft.ENABLE_TRANSPARENT_CANVAS,antialias:this._isAntialias,depth:!0,stencil:!0,premultipliedAlpha:this._isPremultipliedAlpha,preserveDrawingBuffer:!1,powerPreference:"default",failIfMajorPerformanceCaveat:!1};this._webGLRC=this._canvas.getContext("webgl",t)}catch(e){return console.error(e),!1}if(!this._webGLRC)return console.error("This device does not support WebGL."),!1;this._webGLContextLostHandler=this._onWebGLContextLost.bind(this),this._canvas.addEventListener("webglcontextlost",this._onWebGLContextLost),this._canvas2D=document.createElement("canvas"),console.info("WebGL device initialized."),this._gfxAPI=ms.WEBGL,this._deviceName="WebGL";var n=this._webGLRC;this._WEBGL_debug_renderer_info=this.getExtension("WEBGL_debug_renderer_info"),this._WEBGL_debug_renderer_info?(this._renderer=n.getParameter(this._WEBGL_debug_renderer_info.UNMASKED_RENDERER_WEBGL),this._vendor=n.getParameter(this._WEBGL_debug_renderer_info.UNMASKED_VENDOR_WEBGL)):(this._renderer=n.getParameter(n.RENDERER),this._vendor=n.getParameter(n.VENDOR)),this._version=n.getParameter(n.VERSION),this._maxVertexAttributes=n.getParameter(n.MAX_VERTEX_ATTRIBS),this._maxVertexUniformVectors=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),this._maxFragmentUniformVectors=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),this._maxTextureUnits=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),this._maxVertexTextureUnits=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),this._maxTextureSize=n.getParameter(n.MAX_TEXTURE_SIZE),this._maxCubeMapTextureSize=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),this._depthBits=n.getParameter(n.DEPTH_BITS),this._stencilBits=n.getParameter(n.STENCIL_BITS),this.stateCache.initialize(this._maxTextureUnits,this._maxVertexAttributes),this._devicePixelRatio=e.devicePixelRatio||1,this._width=this._canvas.width,this._height=this._canvas.height,this._nativeWidth=Math.max(e.nativeWidth||this._width,0),this._nativeHeight=Math.max(e.nativeHeight||this._height,0),this._colorFmt=za.RGBA8,24===this._depthBits?8===this._stencilBits?this._depthStencilFmt=za.D24S8:this._depthStencilFmt=za.D24:8===this._stencilBits?this._depthStencilFmt=za.D16S8:this._depthStencilFmt=za.D16,this._extensions=n.getSupportedExtensions();var i="";if(this._extensions){for(var r,a=Z(this._extensions);!(r=a()).done;)i+=r.value+" ";console.debug("EXTENSIONS: "+i)}this._EXT_texture_filter_anisotropic=this.getExtension("EXT_texture_filter_anisotropic"),this._EXT_blend_minmax=this.getExtension("EXT_blend_minmax"),this._EXT_frag_depth=this.getExtension("EXT_frag_depth"),this._EXT_shader_texture_lod=this.getExtension("EXT_shader_texture_lod"),this._EXT_sRGB=this.getExtension("EXT_sRGB"),this._OES_vertex_array_object=this.getExtension("OES_vertex_array_object"),this._EXT_color_buffer_half_float=this.getExtension("EXT_color_buffer_half_float"),this._WEBGL_color_buffer_float=this.getExtension("WEBGL_color_buffer_float"),this._WEBGL_compressed_texture_etc1=this.getExtension("WEBGL_compressed_texture_etc1"),this._WEBGL_compressed_texture_etc=this.getExtension("WEBGL_compressed_texture_etc"),this._WEBGL_compressed_texture_pvrtc=this.getExtension("WEBGL_compressed_texture_pvrtc"),this._WEBGL_compressed_texture_s3tc=this.getExtension("WEBGL_compressed_texture_s3tc"),this._WEBGL_compressed_texture_s3tc_srgb=this.getExtension("WEBGL_compressed_texture_s3tc_srgb"),this._WEBGL_debug_shaders=this.getExtension("WEBGL_debug_shaders"),this._WEBGL_draw_buffers=this.getExtension("WEBGL_draw_buffers"),this._WEBGL_lose_context=this.getExtension("WEBGL_lose_context"),this._WEBGL_depth_texture=this.getExtension("WEBGL_depth_texture"),this._OES_texture_half_float=this.getExtension("OES_texture_half_float"),this._OES_texture_half_float_linear=this.getExtension("OES_texture_half_float_linear"),this._OES_texture_float=this.getExtension("OES_texture_float"),this._OES_texture_float_linear=this.getExtension("OES_texture_float_linear"),this._OES_standard_derivatives=this.getExtension("OES_standard_derivatives"),this._OES_element_index_uint=this.getExtension("OES_element_index_uint"),this._ANGLE_instanced_arrays=this.getExtension("ANGLE_instanced_arrays"),mg.os===mg.OS_IOS&&14===mg.osMainVersion&&mg.isBrowser||(this._WEBGL_compressed_texture_astc=this.getExtension("WEBGL_compressed_texture_astc")),mg.browserType===mg.BROWSER_TYPE_UC&&(this._ANGLE_instanced_arrays=null),mg.os===mg.OS_IOS&&mg.osMainVersion<=10&&(this._destroyShadersImmediately=!1),this._features.fill(!1),this._EXT_blend_minmax&&(this._features[vs.BLEND_MINMAX]=!0),this._WEBGL_color_buffer_float&&(this._features[vs.COLOR_FLOAT]=!0),this._EXT_color_buffer_half_float&&(this._features[vs.COLOR_HALF_FLOAT]=!0),this._OES_texture_float&&(this._features[vs.TEXTURE_FLOAT]=!0),this._OES_texture_half_float&&(this._features[vs.TEXTURE_HALF_FLOAT]=!0),this._OES_texture_float_linear&&(this._features[vs.TEXTURE_FLOAT_LINEAR]=!0),this._OES_texture_half_float_linear&&(this._features[vs.TEXTURE_HALF_FLOAT_LINEAR]=!0),this._features[vs.FORMAT_RGB8]=!0,this._WEBGL_depth_texture&&(this._features[vs.FORMAT_D16]=!0,this._features[vs.FORMAT_D24]=!0,this._features[vs.FORMAT_D24S8]=!0),this._OES_element_index_uint&&(this._features[vs.ELEMENT_INDEX_UINT]=!0),this._ANGLE_instanced_arrays&&(this._features[vs.INSTANCED_ARRAYS]=!0),this._WEBGL_draw_buffers&&(this._features[vs.MULTIPLE_RENDER_TARGETS]=!0);var s="";this._WEBGL_compressed_texture_etc1&&(this._features[vs.FORMAT_ETC1]=!0,s+="etc1 "),this._WEBGL_compressed_texture_etc&&(this._features[vs.FORMAT_ETC2]=!0,s+="etc2 "),this._WEBGL_compressed_texture_s3tc&&(this._features[vs.FORMAT_DXT]=!0,s+="dxt "),this._WEBGL_compressed_texture_pvrtc&&(this._features[vs.FORMAT_PVRTC]=!0,s+="pvrtc "),this._WEBGL_compressed_texture_astc&&(this._features[vs.FORMAT_ASTC]=!0,s+="astc "),this._OES_vertex_array_object&&(this._useVAO=!0),console.info("RENDERER: "+this._renderer),console.info("VENDOR: "+this._vendor),console.info("VERSION: "+this._version),console.info("DPR: "+this._devicePixelRatio),console.info("SCREEN_SIZE: "+this._width+" x "+this._height),console.info("NATIVE_SIZE: "+this._nativeWidth+" x "+this._nativeHeight),console.info("MAX_VERTEX_UNIFORM_VECTORS: "+this._maxVertexUniformVectors),console.info("DEPTH_BITS: "+this._depthBits),console.info("STENCIL_BITS: "+this._stencilBits),this._EXT_texture_filter_anisotropic&&console.info("MAX_TEXTURE_MAX_ANISOTROPY_EXT: "+this._EXT_texture_filter_anisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT),console.info("USE_VAO: "+this._useVAO),console.info("COMPRESSED_FORMAT: "+s),this.initStates(n),this._queue=this.createQueue(new co(fs.GRAPHICS)),this._cmdBuff=this.createCommandBuffer(new Ds(this._queue)),this.nullTex2D=this.createTexture(new xo(es.TEX2D,ts.SAMPLED,za.RGBA8,2,2,is.GEN_MIPMAP)),this.nullTexCube=this.createTexture(new xo(es.TEX2D,ts.SAMPLED,za.RGBA8,2,2,is.CUBEMAP|is.GEN_MIPMAP,6));var o=new eo;o.texExtent.width=2,o.texExtent.height=2;var c=new Uint8Array(this.nullTex2D.size);return c.fill(0),this.copyBuffersToTexture([c],this.nullTex2D,[o]),o.texSubres.layerCount=6,this.copyBuffersToTexture([c,c,c,c,c,c],this.nullTexCube,[o]),!0},n.destroy=function(){this._canvas&&this._webGLContextLostHandler&&(this._canvas.removeEventListener("webglcontextlost",this._webGLContextLostHandler),this._webGLContextLostHandler=null),this.nullTex2D&&(this.nullTex2D.destroy(),this.nullTex2D=null),this.nullTexCube&&(this.nullTexCube.destroy(),this.nullTexCube=null),this._queue&&(this._queue.destroy(),this._queue=null),this._cmdBuff&&(this._cmdBuff.destroy(),this._cmdBuff=null),this._extensions=null,this._webGLRC=null},n.resize=function(e,t){this._width===e&&this._height===t||(console.info("Resizing device: "+e+"x"+t),this._canvas.width=e,this._canvas.height=t,this._width=e,this._height=t)},n.acquire=function(){this.cmdAllocator.releaseCmds()},n.present=function(){var e=this._queue;this._numDrawCalls=e.numDrawCalls,this._numInstances=e.numInstances,this._numTris=e.numTris,e.clear()},n.createCommandBuffer=function(e){var t=new(e.type===ss.PRIMARY?UD:OD)(this);return t.initialize(e),t},n.createBuffer=function(e){var t=new bD(this);return t.initialize(e)?t:null},n.createTexture=function(e){var t=new qD(this);return t.initialize(e)?t:null},n.createSampler=function(e){var t=new VD(this);return t.initialize(e)?t:null},n.createDescriptorSet=function(e){var t=new JN(this);return t.initialize(e)?t:null},n.createShader=function(e){var t=new WD(this);return t.initialize(e)?t:null},n.createInputAssembler=function(e){var t=new ND(this);return t.initialize(e)?t:null},n.createRenderPass=function(e){var t=new kD(this);return t.initialize(e)?t:null},n.createFramebuffer=function(e){var t=new MD(this);return t.initialize(e)?t:null},n.createDescriptorSetLayout=function(e){var t=new DD(this);return t.initialize(e)?t:null},n.createPipelineLayout=function(e){var t=new BD(this);return t.initialize(e)?t:null},n.createPipelineState=function(e){var t=new FD(this);return t.initialize(e)?t:null},n.createFence=function(e){var t=new PD(this);return t.initialize(e)?t:null},n.createQueue=function(e){var t=new GD(this);return t.initialize(e)?t:null},n.copyBuffersToTexture=function(e,t,n){RD(this,e,t.gpuTexture,n)},n.copyTexImagesToTexture=function(e,t,n){!function(e,t,n,i){var r=e.gl,a=e.stateCache.glTexUnits[e.stateCache.texUnit];a.glTexture!==n.glTexture&&(r.bindTexture(n.glTarget,n.glTexture),a.glTexture=n.glTexture);var s=0,o=0;switch(n.glTarget){case r.TEXTURE_2D:for(var c=0;c<i.length;c++){var l=i[c];r.texSubImage2D(r.TEXTURE_2D,l.texSubres.mipLevel,l.texOffset.x,l.texOffset.y,n.glFormat,n.glType,t[s++])}break;case r.TEXTURE_CUBE_MAP:for(var u=0;u<i.length;u++){var h=i[u],_=h.texSubres.baseArrayLayer+h.texSubres.layerCount;for(o=h.texSubres.baseArrayLayer;o<_;++o)r.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+o,h.texSubres.mipLevel,h.texOffset.x,h.texOffset.y,n.glFormat,n.glType,t[s++])}break;default:console.error("Unsupported GL texture type, copy buffer to texture failed.")}n.flags&is.GEN_MIPMAP&&n.isPowerOf2&&r.generateMipmap(n.glTarget)}(this,e,t.gpuTexture,n)},n.copyFramebufferToBuffer=function(e,t,n){var i=this._webGLRC,r=e.gpuFramebuffer,a=r.gpuColorTextures[0].format,s=tD(a,i),o=$N(a,i),c=bs(Ts[a]),l=this.stateCache.glFramebuffer;this.stateCache.glFramebuffer!==r.glFramebuffer&&(i.bindFramebuffer(i.FRAMEBUFFER,r.glFramebuffer),this.stateCache.glFramebuffer=r.glFramebuffer);for(var u,h=new c(t),_=Z(n);!(u=_()).done;){var f=u.value,d=f.texExtent.width,p=f.texExtent.height;i.readPixels(f.texOffset.x,f.texOffset.y,d,p,s,o,h)}this.stateCache.glFramebuffer!==l&&(i.bindFramebuffer(i.FRAMEBUFFER,l),this.stateCache.glFramebuffer=l)},n.blitFramebuffer=function(){},n.getExtension=function(e){for(var t=["","WEBKIT_","MOZ_"],n=0;n<t.length;++n){var i=this.gl.getExtension(t[n]+e);if(i)return i}return null},n.initStates=function(e){e.activeTexture(e.TEXTURE0),e.pixelStorei(e.PACK_ALIGNMENT,1),e.pixelStorei(e.UNPACK_ALIGNMENT,1),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.bindFramebuffer(e.FRAMEBUFFER,null),e.enable(e.SCISSOR_TEST),e.enable(e.CULL_FACE),e.cullFace(e.BACK),e.frontFace(e.CCW),e.disable(e.POLYGON_OFFSET_FILL),e.polygonOffset(0,0),e.enable(e.DEPTH_TEST),e.depthMask(!0),e.depthFunc(e.LESS),e.depthRange(0,1),e.stencilFuncSeparate(e.FRONT,e.ALWAYS,1,65535),e.stencilOpSeparate(e.FRONT,e.KEEP,e.KEEP,e.KEEP),e.stencilMaskSeparate(e.FRONT,65535),e.stencilFuncSeparate(e.BACK,e.ALWAYS,1,65535),e.stencilOpSeparate(e.BACK,e.KEEP,e.KEEP,e.KEEP),e.stencilMaskSeparate(e.BACK,65535),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.disable(e.BLEND),e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.colorMask(!0,!0,!0,!0),e.blendColor(0,0,0,0)},n._onWebGLContextLost=function(e){E(11e3),_(e)},j(t,[{key:"gl",get:function(){return this._webGLRC}},{key:"webGLQueue",get:function(){return this._queue}},{key:"isAntialias",get:function(){return this._isAntialias}},{key:"isPremultipliedAlpha",get:function(){return this._isPremultipliedAlpha}},{key:"useVAO",get:function(){return this._useVAO}},{key:"destroyShadersImmediately",get:function(){return this._destroyShadersImmediately}},{key:"noCompressedTexSubImage2D",get:function(){return this._noCompressedTexSubImage2D}},{key:"bindingMappingInfo",get:function(){return this._bindingMappingInfo}},{key:"EXT_texture_filter_anisotropic",get:function(){return this._EXT_texture_filter_anisotropic}},{key:"EXT_blend_minmax",get:function(){return this._EXT_blend_minmax}},{key:"EXT_frag_depth",get:function(){return this._EXT_frag_depth}},{key:"EXT_shader_texture_lod",get:function(){return this._EXT_shader_texture_lod}},{key:"EXT_sRGB",get:function(){return this._EXT_sRGB}},{key:"OES_vertex_array_object",get:function(){return this._OES_vertex_array_object}},{key:"WEBGL_color_buffer_float",get:function(){return this._WEBGL_color_buffer_float}},{key:"WEBGL_compressed_texture_etc1",get:function(){return this._WEBGL_compressed_texture_etc1}},{key:"WEBGL_compressed_texture_pvrtc",get:function(){return this._WEBGL_compressed_texture_pvrtc}},{key:"WEBGL_compressed_texture_astc",get:function(){return this._WEBGL_compressed_texture_astc}},{key:"WEBGL_compressed_texture_s3tc",get:function(){return this._WEBGL_compressed_texture_s3tc}},{key:"WEBGL_compressed_texture_s3tc_srgb",get:function(){return this._WEBGL_compressed_texture_s3tc_srgb}},{key:"WEBGL_debug_shaders",get:function(){return this._WEBGL_debug_shaders}},{key:"WEBGL_draw_buffers",get:function(){return this._WEBGL_draw_buffers}},{key:"WEBGL_lose_context",get:function(){return this._WEBGL_lose_context}},{key:"WEBGL_depth_texture",get:function(){return this._WEBGL_depth_texture}},{key:"WEBGL_debug_renderer_info",get:function(){return this._WEBGL_debug_renderer_info}},{key:"OES_texture_half_float",get:function(){return this._OES_texture_half_float}},{key:"OES_texture_half_float_linear",get:function(){return this._OES_texture_half_float_linear}},{key:"OES_texture_float",get:function(){return this._OES_texture_float}},{key:"OES_standard_derivatives",get:function(){return this._OES_standard_derivatives}},{key:"OES_element_index_uint",get:function(){return this._OES_element_index_uint}},{key:"ANGLE_instanced_arrays",get:function(){return this._ANGLE_instanced_arrays}}]),t}(zs));i.WebGLDevice=XD;var YD=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._gpuDescriptorSet=null,t}X(t,e);var n=t.prototype;return n.initialize=function(e){this._layout=e.layout;var t=e.layout.gpuDescriptorSetLayout,n=t.bindings,i=t.descriptorIndices,r=t.descriptorCount;this._buffers=Array(r).fill(null),this._textures=Array(r).fill(null),this._samplers=Array(r).fill(null);var a=[];this._gpuDescriptorSet={gpuDescriptors:a,descriptorIndices:i};for(var s=0;s<n.length;++s)for(var o=n[s],c=0;c<o.count;c++)a.push({type:o.descriptorType,gpuBuffer:null,gpuTexture:null,gpuSampler:null});return!0},n.destroy=function(){this._layout=null,this._gpuDescriptorSet=null},n.update=function(){if(this._isDirty&&this._gpuDescriptorSet){for(var e=this._gpuDescriptorSet.gpuDescriptors,t=0;t<e.length;++t)e[t].type&Io?this._buffers[t]&&(e[t].gpuBuffer=this._buffers[t].gpuBuffer):e[t].type&Oo&&(this._textures[t]&&(e[t].gpuTexture=this._textures[t].gpuTexture),this._samplers[t]&&(e[t].gpuSampler=this._samplers[t].gpuSampler));this._isDirty=!1}},j(t,[{key:"gpuDescriptorSet",get:function(){return this._gpuDescriptorSet}}]),t}(Mo),KD=[10497,33648,33071,33071],ZD=[1,2,4,8,16,32,64],QD=new Float32Array(4);function JD(e,t){switch(e){case za.R8:return t.UNSIGNED_BYTE;case za.R8SN:return t.BYTE;case za.R8UI:return t.UNSIGNED_BYTE;case za.R8I:return t.BYTE;case za.R16F:return t.HALF_FLOAT;case za.R16UI:return t.UNSIGNED_SHORT;case za.R16I:return t.SHORT;case za.R32F:return t.FLOAT;case za.R32UI:return t.UNSIGNED_INT;case za.R32I:return t.INT;case za.RG8:return t.UNSIGNED_BYTE;case za.RG8SN:return t.BYTE;case za.RG8UI:return t.UNSIGNED_BYTE;case za.RG8I:return t.BYTE;case za.RG16F:return t.HALF_FLOAT;case za.RG16UI:return t.UNSIGNED_SHORT;case za.RG16I:return t.SHORT;case za.RG32F:return t.FLOAT;case za.RG32UI:return t.UNSIGNED_INT;case za.RG32I:return t.INT;case za.RGB8:case za.SRGB8:return t.UNSIGNED_BYTE;case za.RGB8SN:return t.BYTE;case za.RGB8UI:return t.UNSIGNED_BYTE;case za.RGB8I:return t.BYTE;case za.RGB16F:return t.HALF_FLOAT;case za.RGB16UI:return t.UNSIGNED_SHORT;case za.RGB16I:return t.SHORT;case za.RGB32F:return t.FLOAT;case za.RGB32UI:return t.UNSIGNED_INT;case za.RGB32I:return t.INT;case za.BGRA8:case za.RGBA8:case za.SRGB8_A8:return t.UNSIGNED_BYTE;case za.RGBA8SN:return t.BYTE;case za.RGBA8UI:return t.UNSIGNED_BYTE;case za.RGBA8I:return t.BYTE;case za.RGBA16F:return t.HALF_FLOAT;case za.RGBA16UI:return t.UNSIGNED_SHORT;case za.RGBA16I:return t.SHORT;case za.RGBA32F:return t.FLOAT;case za.RGBA32UI:return t.UNSIGNED_INT;case za.RGBA32I:return t.INT;case za.R5G6B5:return t.UNSIGNED_SHORT_5_6_5;case za.R11G11B10F:return t.UNSIGNED_INT_10F_11F_11F_REV;case za.RGB5A1:return t.UNSIGNED_SHORT_5_5_5_1;case za.RGBA4:return t.UNSIGNED_SHORT_4_4_4_4;case za.RGB10A2:case za.RGB10A2UI:return t.UNSIGNED_INT_2_10_10_10_REV;case za.RGB9E5:return t.FLOAT;case za.D16:return t.UNSIGNED_SHORT;case za.D16S8:return t.UNSIGNED_INT_24_8;case za.D24:return t.UNSIGNED_INT;case za.D24S8:return t.UNSIGNED_INT_24_8;case za.D32F:return t.FLOAT;case za.D32F_S8:return t.FLOAT_32_UNSIGNED_INT_24_8_REV;case za.BC1:case za.BC1_SRGB:case za.BC2:case za.BC2_SRGB:case za.BC3:case za.BC3_SRGB:case za.BC4:return t.UNSIGNED_BYTE;case za.BC4_SNORM:return t.BYTE;case za.BC5:return t.UNSIGNED_BYTE;case za.BC5_SNORM:return t.BYTE;case za.BC6H_SF16:case za.BC6H_UF16:return t.FLOAT;case za.BC7:case za.BC7_SRGB:case za.ETC_RGB8:case za.ETC2_RGB8:case za.ETC2_SRGB8:case za.ETC2_RGB8_A1:case za.ETC2_SRGB8_A1:case za.EAC_R11:return t.UNSIGNED_BYTE;case za.EAC_R11SN:return t.BYTE;case za.EAC_RG11:return t.UNSIGNED_BYTE;case za.EAC_RG11SN:return t.BYTE;case za.PVRTC_RGB2:case za.PVRTC_RGBA2:case za.PVRTC_RGB4:case za.PVRTC_RGBA4:case za.PVRTC2_2BPP:case za.PVRTC2_4BPP:return t.UNSIGNED_BYTE;case za.ASTC_RGBA_4x4:case za.ASTC_RGBA_5x4:case za.ASTC_RGBA_5x5:case za.ASTC_RGBA_6x5:case za.ASTC_RGBA_6x6:case za.ASTC_RGBA_8x5:case za.ASTC_RGBA_8x6:case za.ASTC_RGBA_8x8:case za.ASTC_RGBA_10x5:case za.ASTC_RGBA_10x6:case za.ASTC_RGBA_10x8:case za.ASTC_RGBA_10x10:case za.ASTC_RGBA_12x10:case za.ASTC_RGBA_12x12:case za.ASTC_SRGBA_4x4:case za.ASTC_SRGBA_5x4:case za.ASTC_SRGBA_5x5:case za.ASTC_SRGBA_6x5:case za.ASTC_SRGBA_6x6:case za.ASTC_SRGBA_8x5:case za.ASTC_SRGBA_8x6:case za.ASTC_SRGBA_8x8:case za.ASTC_SRGBA_10x5:case za.ASTC_SRGBA_10x6:case za.ASTC_SRGBA_10x8:case za.ASTC_SRGBA_10x10:case za.ASTC_SRGBA_12x10:case za.ASTC_SRGBA_12x12:default:return t.UNSIGNED_BYTE}}function $D(e,t){switch(e){case za.A8:return t.ALPHA;case za.L8:return t.LUMINANCE;case za.LA8:return t.LUMINANCE_ALPHA;case za.R8:return t.R8;case za.R8SN:return t.R8_SNORM;case za.R8UI:return t.R8UI;case za.R8I:return t.R8I;case za.RG8:return t.RG8;case za.RG8SN:return t.RG8_SNORM;case za.RG8UI:return t.RG8UI;case za.RG8I:return t.RG8I;case za.RGB8:return t.RGB8;case za.RGB8SN:return t.RGB8_SNORM;case za.RGB8UI:return t.RGB8UI;case za.RGB8I:return t.RGB8I;case za.BGRA8:case za.RGBA8:return t.RGBA8;case za.RGBA8SN:return t.RGBA8_SNORM;case za.RGBA8UI:return t.RGBA8UI;case za.RGBA8I:return t.RGBA8I;case za.R16I:return t.R16I;case za.R16UI:return t.R16UI;case za.R16F:return t.R16F;case za.RG16I:return t.RG16I;case za.RG16UI:return t.RG16UI;case za.RG16F:return t.RG16F;case za.RGB16I:return t.RGB16I;case za.RGB16UI:return t.RGB16UI;case za.RGB16F:return t.RGB16F;case za.RGBA16I:return t.RGBA16I;case za.RGBA16UI:return t.RGBA16UI;case za.RGBA16F:return t.RGBA16F;case za.R32I:return t.R32I;case za.R32UI:return t.R32UI;case za.R32F:return t.R32F;case za.RG32I:return t.RG32I;case za.RG32UI:return t.RG32UI;case za.RG32F:return t.RG32F;case za.RGB32I:return t.RGB32I;case za.RGB32UI:return t.RGB32UI;case za.RGB32F:return t.RGB32F;case za.RGBA32I:return t.RGBA32I;case za.RGBA32UI:return t.RGBA32UI;case za.RGBA32F:return t.RGBA32F;case za.R5G6B5:return t.RGB565;case za.RGB5A1:return t.RGB5_A1;case za.RGBA4:return t.RGBA4;case za.RGB10A2:return t.RGB10_A2;case za.RGB10A2UI:return t.RGB10_A2UI;case za.R11G11B10F:return t.R11F_G11F_B10F;case za.D16:return t.DEPTH_COMPONENT16;case za.D16S8:return t.DEPTH24_STENCIL8;case za.D24:return t.DEPTH_COMPONENT24;case za.D24S8:return t.DEPTH24_STENCIL8;case za.D32F:return t.DEPTH_COMPONENT32F;case za.D32F_S8:return t.DEPTH32F_STENCIL8;case za.BC1:return QN.COMPRESSED_RGB_S3TC_DXT1_EXT;case za.BC1_ALPHA:return QN.COMPRESSED_RGBA_S3TC_DXT1_EXT;case za.BC1_SRGB:return QN.COMPRESSED_SRGB_S3TC_DXT1_EXT;case za.BC1_SRGB_ALPHA:return QN.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;case za.BC2:return QN.COMPRESSED_RGBA_S3TC_DXT3_EXT;case za.BC2_SRGB:return QN.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;case za.BC3:return QN.COMPRESSED_RGBA_S3TC_DXT5_EXT;case za.BC3_SRGB:return QN.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;case za.ETC_RGB8:return QN.COMPRESSED_RGB_ETC1_WEBGL;case za.ETC2_RGB8:return QN.COMPRESSED_RGB8_ETC2;case za.ETC2_SRGB8:return QN.COMPRESSED_SRGB8_ETC2;case za.ETC2_RGB8_A1:return QN.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;case za.ETC2_SRGB8_A1:return QN.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2;case za.ETC2_RGBA8:return QN.COMPRESSED_RGBA8_ETC2_EAC;case za.ETC2_SRGB8_A8:return QN.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;case za.EAC_R11:return QN.COMPRESSED_R11_EAC;case za.EAC_R11SN:return QN.COMPRESSED_SIGNED_R11_EAC;case za.EAC_RG11:return QN.COMPRESSED_RG11_EAC;case za.EAC_RG11SN:return QN.COMPRESSED_SIGNED_RG11_EAC;case za.PVRTC_RGB2:return QN.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;case za.PVRTC_RGBA2:return QN.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;case za.PVRTC_RGB4:return QN.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;case za.PVRTC_RGBA4:return QN.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;case za.ASTC_RGBA_4x4:return QN.COMPRESSED_RGBA_ASTC_4x4_KHR;case za.ASTC_RGBA_5x4:return QN.COMPRESSED_RGBA_ASTC_5x4_KHR;case za.ASTC_RGBA_5x5:return QN.COMPRESSED_RGBA_ASTC_5x5_KHR;case za.ASTC_RGBA_6x5:return QN.COMPRESSED_RGBA_ASTC_6x5_KHR;case za.ASTC_RGBA_6x6:return QN.COMPRESSED_RGBA_ASTC_6x6_KHR;case za.ASTC_RGBA_8x5:return QN.COMPRESSED_RGBA_ASTC_8x5_KHR;case za.ASTC_RGBA_8x6:return QN.COMPRESSED_RGBA_ASTC_8x6_KHR;case za.ASTC_RGBA_8x8:return QN.COMPRESSED_RGBA_ASTC_8x8_KHR;case za.ASTC_RGBA_10x5:return QN.COMPRESSED_RGBA_ASTC_10x5_KHR;case za.ASTC_RGBA_10x6:return QN.COMPRESSED_RGBA_ASTC_10x6_KHR;case za.ASTC_RGBA_10x8:return QN.COMPRESSED_RGBA_ASTC_10x8_KHR;case za.ASTC_RGBA_10x10:return QN.COMPRESSED_RGBA_ASTC_10x10_KHR;case za.ASTC_RGBA_12x10:return QN.COMPRESSED_RGBA_ASTC_12x10_KHR;case za.ASTC_RGBA_12x12:return QN.COMPRESSED_RGBA_ASTC_12x12_KHR;case za.ASTC_SRGBA_4x4:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;case za.ASTC_SRGBA_5x4:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR;case za.ASTC_SRGBA_5x5:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR;case za.ASTC_SRGBA_6x5:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR;case za.ASTC_SRGBA_6x6:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR;case za.ASTC_SRGBA_8x5:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR;case za.ASTC_SRGBA_8x6:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR;case za.ASTC_SRGBA_8x8:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR;case za.ASTC_SRGBA_10x5:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR;case za.ASTC_SRGBA_10x6:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR;case za.ASTC_SRGBA_10x8:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR;case za.ASTC_SRGBA_10x10:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR;case za.ASTC_SRGBA_12x10:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR;case za.ASTC_SRGBA_12x12:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR;default:return console.error("Unsupported Format, convert to WebGL internal format failed."),t.RGBA}}function eB(e,t){switch(e){case za.A8:return t.ALPHA;case za.L8:return t.LUMINANCE;case za.LA8:return t.LUMINANCE_ALPHA;case za.R8:case za.R8SN:return t.RED;case za.R8UI:case za.R8I:return t.RED;case za.RG8:case za.RG8SN:case za.RG8UI:case za.RG8I:return t.RG;case za.RGB8:case za.RGB8SN:case za.RGB8UI:case za.RGB8I:return t.RGB;case za.BGRA8:case za.RGBA8:case za.RGBA8SN:case za.RGBA8UI:case za.RGBA8I:return t.RGBA;case za.R16UI:case za.R16I:case za.R16F:return t.RED;case za.RG16UI:case za.RG16I:case za.RG16F:return t.RG;case za.RGB16UI:case za.RGB16I:case za.RGB16F:return t.RGB;case za.RGBA16UI:case za.RGBA16I:case za.RGBA16F:return t.RGBA;case za.R32UI:case za.R32I:case za.R32F:return t.RED;case za.RG32UI:case za.RG32I:case za.RG32F:return t.RG;case za.RGB32UI:case za.RGB32I:case za.RGB32F:return t.RGB;case za.RGBA32UI:case za.RGBA32I:case za.RGBA32F:case za.RGB10A2:return t.RGBA;case za.R11G11B10F:case za.R5G6B5:return t.RGB;case za.RGB5A1:case za.RGBA4:return t.RGBA;case za.D16:return t.DEPTH_COMPONENT;case za.D16S8:return t.DEPTH_STENCIL;case za.D24:return t.DEPTH_COMPONENT;case za.D24S8:return t.DEPTH_STENCIL;case za.D32F:return t.DEPTH_COMPONENT;case za.D32F_S8:return t.DEPTH_STENCIL;case za.BC1:return QN.COMPRESSED_RGB_S3TC_DXT1_EXT;case za.BC1_ALPHA:return QN.COMPRESSED_RGBA_S3TC_DXT1_EXT;case za.BC1_SRGB:return QN.COMPRESSED_SRGB_S3TC_DXT1_EXT;case za.BC1_SRGB_ALPHA:return QN.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;case za.BC2:return QN.COMPRESSED_RGBA_S3TC_DXT3_EXT;case za.BC2_SRGB:return QN.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;case za.BC3:return QN.COMPRESSED_RGBA_S3TC_DXT5_EXT;case za.BC3_SRGB:return QN.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;case za.ETC_RGB8:return QN.COMPRESSED_RGB_ETC1_WEBGL;case za.ETC2_RGB8:return QN.COMPRESSED_RGB8_ETC2;case za.ETC2_SRGB8:return QN.COMPRESSED_SRGB8_ETC2;case za.ETC2_RGB8_A1:return QN.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;case za.ETC2_SRGB8_A1:return QN.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2;case za.ETC2_RGBA8:return QN.COMPRESSED_RGBA8_ETC2_EAC;case za.ETC2_SRGB8_A8:return QN.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;case za.EAC_R11:return QN.COMPRESSED_R11_EAC;case za.EAC_R11SN:return QN.COMPRESSED_SIGNED_R11_EAC;case za.EAC_RG11:return QN.COMPRESSED_RG11_EAC;case za.EAC_RG11SN:return QN.COMPRESSED_SIGNED_RG11_EAC;case za.PVRTC_RGB2:return QN.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;case za.PVRTC_RGBA2:return QN.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;case za.PVRTC_RGB4:return QN.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;case za.PVRTC_RGBA4:return QN.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;case za.ASTC_RGBA_4x4:return QN.COMPRESSED_RGBA_ASTC_4x4_KHR;case za.ASTC_RGBA_5x4:return QN.COMPRESSED_RGBA_ASTC_5x4_KHR;case za.ASTC_RGBA_5x5:return QN.COMPRESSED_RGBA_ASTC_5x5_KHR;case za.ASTC_RGBA_6x5:return QN.COMPRESSED_RGBA_ASTC_6x5_KHR;case za.ASTC_RGBA_6x6:return QN.COMPRESSED_RGBA_ASTC_6x6_KHR;case za.ASTC_RGBA_8x5:return QN.COMPRESSED_RGBA_ASTC_8x5_KHR;case za.ASTC_RGBA_8x6:return QN.COMPRESSED_RGBA_ASTC_8x6_KHR;case za.ASTC_RGBA_8x8:return QN.COMPRESSED_RGBA_ASTC_8x8_KHR;case za.ASTC_RGBA_10x5:return QN.COMPRESSED_RGBA_ASTC_10x5_KHR;case za.ASTC_RGBA_10x6:return QN.COMPRESSED_RGBA_ASTC_10x6_KHR;case za.ASTC_RGBA_10x8:return QN.COMPRESSED_RGBA_ASTC_10x8_KHR;case za.ASTC_RGBA_10x10:return QN.COMPRESSED_RGBA_ASTC_10x10_KHR;case za.ASTC_RGBA_12x10:return QN.COMPRESSED_RGBA_ASTC_12x10_KHR;case za.ASTC_RGBA_12x12:return QN.COMPRESSED_RGBA_ASTC_12x12_KHR;case za.ASTC_SRGBA_4x4:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;case za.ASTC_SRGBA_5x4:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR;case za.ASTC_SRGBA_5x5:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR;case za.ASTC_SRGBA_6x5:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR;case za.ASTC_SRGBA_6x6:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR;case za.ASTC_SRGBA_8x5:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR;case za.ASTC_SRGBA_8x6:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR;case za.ASTC_SRGBA_8x8:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR;case za.ASTC_SRGBA_10x5:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR;case za.ASTC_SRGBA_10x6:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR;case za.ASTC_SRGBA_10x8:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR;case za.ASTC_SRGBA_10x10:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR;case za.ASTC_SRGBA_12x10:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR;case za.ASTC_SRGBA_12x12:return QN.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR;default:return console.error("Unsupported Format, convert to WebGL format failed."),t.RGBA}}function tB(e,t){switch(e){case Fa.BOOL:return t.BOOL;case Fa.BOOL2:return t.BOOL_VEC2;case Fa.BOOL3:return t.BOOL_VEC3;case Fa.BOOL4:return t.BOOL_VEC4;case Fa.INT:return t.INT;case Fa.INT2:return t.INT_VEC2;case Fa.INT3:return t.INT_VEC3;case Fa.INT4:return t.INT_VEC4;case Fa.UINT:return t.UNSIGNED_INT;case Fa.FLOAT:return t.FLOAT;case Fa.FLOAT2:return t.FLOAT_VEC2;case Fa.FLOAT3:return t.FLOAT_VEC3;case Fa.FLOAT4:return t.FLOAT_VEC4;case Fa.MAT2:return t.FLOAT_MAT2;case Fa.MAT2X3:return t.FLOAT_MAT2x3;case Fa.MAT2X4:return t.FLOAT_MAT2x4;case Fa.MAT3X2:return t.FLOAT_MAT3x2;case Fa.MAT3:return t.FLOAT_MAT3;case Fa.MAT3X4:return t.FLOAT_MAT3x4;case Fa.MAT4X2:return t.FLOAT_MAT4x2;case Fa.MAT4X3:return t.FLOAT_MAT4x3;case Fa.MAT4:return t.FLOAT_MAT4;case Fa.SAMPLER2D:return t.SAMPLER_2D;case Fa.SAMPLER2D_ARRAY:return t.SAMPLER_2D_ARRAY;case Fa.SAMPLER3D:return t.SAMPLER_3D;case Fa.SAMPLER_CUBE:return t.SAMPLER_CUBE;default:return console.error("Unsupported GLType, convert to GL type failed."),Fa.UNKNOWN}}function nB(e,t){switch(e){case t.BOOL:return Fa.BOOL;case t.BOOL_VEC2:return Fa.BOOL2;case t.BOOL_VEC3:return Fa.BOOL3;case t.BOOL_VEC4:return Fa.BOOL4;case t.INT:return Fa.INT;case t.INT_VEC2:return Fa.INT2;case t.INT_VEC3:return Fa.INT3;case t.INT_VEC4:return Fa.INT4;case t.UNSIGNED_INT:return Fa.UINT;case t.UNSIGNED_INT_VEC2:return Fa.UINT2;case t.UNSIGNED_INT_VEC3:return Fa.UINT3;case t.UNSIGNED_INT_VEC4:return Fa.UINT4;case t.FLOAT:return Fa.FLOAT;case t.FLOAT_VEC2:return Fa.FLOAT2;case t.FLOAT_VEC3:return Fa.FLOAT3;case t.FLOAT_VEC4:return Fa.FLOAT4;case t.FLOAT_MAT2:return Fa.MAT2;case t.FLOAT_MAT2x3:return Fa.MAT2X3;case t.FLOAT_MAT2x4:return Fa.MAT2X4;case t.FLOAT_MAT3x2:return Fa.MAT3X2;case t.FLOAT_MAT3:return Fa.MAT3;case t.FLOAT_MAT3x4:return Fa.MAT3X4;case t.FLOAT_MAT4x2:return Fa.MAT4X2;case t.FLOAT_MAT4x3:return Fa.MAT4X3;case t.FLOAT_MAT4:return Fa.MAT4;case t.SAMPLER_2D:return Fa.SAMPLER2D;case t.SAMPLER_2D_ARRAY:return Fa.SAMPLER2D_ARRAY;case t.SAMPLER_3D:return Fa.SAMPLER3D;case t.SAMPLER_CUBE:return Fa.SAMPLER_CUBE;default:return console.error("Unsupported GLType, convert to Type failed."),Fa.UNKNOWN}}function iB(e,t){switch(e){case t.BOOL:return 4;case t.BOOL_VEC2:return 8;case t.BOOL_VEC3:return 12;case t.BOOL_VEC4:return 16;case t.INT:return 4;case t.INT_VEC2:return 8;case t.INT_VEC3:return 12;case t.INT_VEC4:return 16;case t.UNSIGNED_INT:return 4;case t.UNSIGNED_INT_VEC2:return 8;case t.UNSIGNED_INT_VEC3:return 12;case t.UNSIGNED_INT_VEC4:return 16;case t.FLOAT:return 4;case t.FLOAT_VEC2:return 8;case t.FLOAT_VEC3:return 12;case t.FLOAT_VEC4:case t.FLOAT_MAT2:return 16;case t.FLOAT_MAT2x3:return 24;case t.FLOAT_MAT2x4:return 32;case t.FLOAT_MAT3x2:return 24;case t.FLOAT_MAT3:return 36;case t.FLOAT_MAT3x4:return 48;case t.FLOAT_MAT4x2:return 32;case t.FLOAT_MAT4x3:return 48;case t.FLOAT_MAT4:return 64;case t.SAMPLER_2D:case t.SAMPLER_2D_ARRAY:case t.SAMPLER_2D_ARRAY_SHADOW:case t.SAMPLER_3D:case t.SAMPLER_CUBE:case t.INT_SAMPLER_2D:case t.INT_SAMPLER_2D_ARRAY:case t.INT_SAMPLER_3D:case t.INT_SAMPLER_CUBE:case t.UNSIGNED_INT_SAMPLER_2D:case t.UNSIGNED_INT_SAMPLER_2D_ARRAY:case t.UNSIGNED_INT_SAMPLER_3D:case t.UNSIGNED_INT_SAMPLER_CUBE:return 4;default:return console.error("Unsupported GLType, get type failed."),0}}function rB(e,t){switch(e){case t.FLOAT_MAT2:case t.FLOAT_MAT2x3:case t.FLOAT_MAT2x4:return 2;case t.FLOAT_MAT3x2:case t.FLOAT_MAT3:case t.FLOAT_MAT3x4:return 3;case t.FLOAT_MAT4x2:case t.FLOAT_MAT4x3:case t.FLOAT_MAT4:return 4;default:return 1}}var aB,sB=[512,513,514,515,516,517,518,519],oB=[0,7680,7681,7682,7683,5386,34055,34056],cB=[32774,32778,32779,32775,32776],lB=[0,1,770,772,771,773,768,774,769,775,776,32769,32770,32771,32772];!function(e){e[e.BEGIN_RENDER_PASS=0]="BEGIN_RENDER_PASS",e[e.END_RENDER_PASS=1]="END_RENDER_PASS",e[e.BIND_STATES=2]="BIND_STATES",e[e.DRAW=3]="DRAW",e[e.UPDATE_BUFFER=4]="UPDATE_BUFFER",e[e.COPY_BUFFER_TO_TEXTURE=5]="COPY_BUFFER_TO_TEXTURE",e[e.COUNT=6]="COUNT"}(aB||(aB={}));var uB=function(e){this.cmdType=void 0,this.refCount=0,this.cmdType=e},hB=function(e){function t(){var t;return(t=e.call(this,aB.BEGIN_RENDER_PASS)||this).gpuRenderPass=null,t.gpuFramebuffer=null,t.renderArea=new Xs,t.clearColors=[],t.clearDepth=1,t.clearStencil=0,t}return X(t,e),t.prototype.clear=function(){this.gpuFramebuffer=null,this.clearColors.length=0},t}(uB),_B=function(e){function t(){var t;return(t=e.call(this,aB.BIND_STATES)||this).gpuPipelineState=null,t.gpuInputAssembler=null,t.gpuDescriptorSets=[],t.dynamicOffsets=[],t.viewport=null,t.scissor=null,t.lineWidth=null,t.depthBias=null,t.blendConstants=[],t.depthBounds=null,t.stencilWriteMask=null,t.stencilCompareMask=null,t}return X(t,e),t.prototype.clear=function(){this.gpuPipelineState=null,this.gpuInputAssembler=null,this.gpuDescriptorSets.length=0,this.dynamicOffsets.length=0,this.viewport=null,this.scissor=null,this.lineWidth=null,this.depthBias=null,this.blendConstants.length=0,this.depthBounds=null,this.stencilWriteMask=null,this.stencilCompareMask=null},t}(uB),fB=function(e){function t(){var t;return(t=e.call(this,aB.DRAW)||this).drawInfo=new ws,t}return X(t,e),t.prototype.clear=function(){},t}(uB),dB=function(e){function t(){var t;return(t=e.call(this,aB.UPDATE_BUFFER)||this).gpuBuffer=null,t.buffer=null,t.offset=0,t.size=0,t}return X(t,e),t.prototype.clear=function(){this.gpuBuffer=null,this.buffer=null},t}(uB),pB=function(e){function t(){var t;return(t=e.call(this,aB.COPY_BUFFER_TO_TEXTURE)||this).gpuTexture=null,t.buffers=[],t.regions=[],t}return X(t,e),t.prototype.clear=function(){this.gpuTexture=null,this.buffers.length=0,this.regions.length=0},t}(uB),mB=function(){function e(){this.cmds=new u_(1),this.beginRenderPassCmds=new u_(1),this.bindStatesCmds=new u_(1),this.drawCmds=new u_(1),this.updateBufferCmds=new u_(1),this.copyBufferToTextureCmds=new u_(1)}return e.prototype.clearCmds=function(e){this.beginRenderPassCmds.length&&(e.beginRenderPassCmdPool.freeCmds(this.beginRenderPassCmds),this.beginRenderPassCmds.clear()),this.bindStatesCmds.length&&(e.bindStatesCmdPool.freeCmds(this.bindStatesCmds),this.bindStatesCmds.clear()),this.drawCmds.length&&(e.drawCmdPool.freeCmds(this.drawCmds),this.drawCmds.clear()),this.updateBufferCmds.length&&(e.updateBufferCmdPool.freeCmds(this.updateBufferCmds),this.updateBufferCmds.clear()),this.copyBufferToTextureCmds.length&&(e.copyBufferToTextureCmdPool.freeCmds(this.copyBufferToTextureCmds),this.copyBufferToTextureCmds.clear()),this.cmds.clear()},e}();function gB(e,t,n,i,r){if(t.usage&Ua.INDIRECT)t.indirects.length=i,Array.prototype.push.apply(t.indirects,n.drawInfos);else{var a=n,s=e.gl,o=e.stateCache;switch(t.glTarget){case s.ARRAY_BUFFER:o.glVAO&&(s.bindVertexArray(null),o.glVAO=vB.gpuInputAssembler=null),o.glArrayBuffer!==t.glBuffer&&(s.bindBuffer(s.ARRAY_BUFFER,t.glBuffer),o.glArrayBuffer=t.glBuffer),r===a.byteLength?s.bufferSubData(t.glTarget,i,a):s.bufferSubData(t.glTarget,i,a.slice(0,r));break;case s.ELEMENT_ARRAY_BUFFER:o.glVAO&&(s.bindVertexArray(null),o.glVAO=vB.gpuInputAssembler=null),o.glElementArrayBuffer!==t.glBuffer&&(s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,t.glBuffer),o.glElementArrayBuffer=t.glBuffer),r===a.byteLength?s.bufferSubData(t.glTarget,i,a):s.bufferSubData(t.glTarget,i,a.slice(0,r));break;case s.UNIFORM_BUFFER:o.glUniformBuffer!==t.glBuffer&&(s.bindBuffer(s.UNIFORM_BUFFER,t.glBuffer),o.glUniformBuffer=t.glBuffer),r===a.byteLength?s.bufferSubData(t.glTarget,i,a):s.bufferSubData(t.glTarget,i,new Float32Array(a,0,r/4));break;default:console.error("Unsupported BufferType, update buffer failed.")}}}var vB={gpuPipelineState:null,gpuInputAssembler:null,reverseCW:!1,glPrimitive:0,invalidateAttachments:[]};function yB(e,t,n,i,r,a,s){var o=e.gl,c=e.stateCache,l=0;if(n&&t){if(c.glFramebuffer!==n.glFramebuffer){o.bindFramebuffer(o.FRAMEBUFFER,n.glFramebuffer),c.glFramebuffer=n.glFramebuffer;var u=!!n.glFramebuffer;if(u!==vB.reverseCW){vB.reverseCW=u;var h=!e.stateCache.rs.isFrontFaceCCW;o.frontFace(h?o.CCW:o.CW),e.stateCache.rs.isFrontFaceCCW=h}}c.viewport.left===i.x&&c.viewport.top===i.y&&c.viewport.width===i.width&&c.viewport.height===i.height||(o.viewport(i.x,i.y,i.width,i.height),c.viewport.left=i.x,c.viewport.top=i.y,c.viewport.width=i.width,c.viewport.height=i.height),c.scissorRect.x===i.x&&c.scissorRect.y===i.y&&c.scissorRect.width===i.width&&c.scissorRect.height===i.height||(o.scissor(i.x,i.y,i.width,i.height),c.scissorRect.x=i.x,c.scissorRect.y=i.y,c.scissorRect.width=i.width,c.scissorRect.height=i.height),vB.invalidateAttachments.length=0;for(var _=0;_<r.length;++_){var f=t.colorAttachments[_];if(f.format!==za.UNKNOWN)switch(f.loadOp){case os.LOAD:break;case os.CLEAR:if(c.bs.targets[0].blendColorMask!==Qa.ALL&&o.colorMask(!0,!0,!0,!0),n.isOffscreen)QD[0]=r[_].x,QD[1]=r[_].y,QD[2]=r[_].z,QD[3]=r[_].w,o.clearBufferfv(o.COLOR,_,QD);else{var d=r[0];o.clearColor(d.x,d.y,d.z,d.w),l|=o.COLOR_BUFFER_BIT}break;case os.DISCARD:vB.invalidateAttachments.push(o.COLOR_ATTACHMENT0+_)}}if(t.depthStencilAttachment&&t.depthStencilAttachment.format!==za.UNKNOWN){switch(t.depthStencilAttachment.depthLoadOp){case os.LOAD:break;case os.CLEAR:c.dss.depthWrite||o.depthMask(!0),o.clearDepth(a),l|=o.DEPTH_BUFFER_BIT;break;case os.DISCARD:vB.invalidateAttachments.push(o.DEPTH_ATTACHMENT)}if(Ts[t.depthStencilAttachment.format].hasStencil)switch(t.depthStencilAttachment.stencilLoadOp){case os.LOAD:break;case os.CLEAR:c.dss.stencilWriteMaskFront||o.stencilMaskSeparate(o.FRONT,65535),c.dss.stencilWriteMaskBack||o.stencilMaskSeparate(o.BACK,65535),o.clearStencil(s),l|=o.STENCIL_BUFFER_BIT;break;case os.DISCARD:vB.invalidateAttachments.push(o.STENCIL_ATTACHMENT)}}if(n.glFramebuffer&&vB.invalidateAttachments.length&&o.invalidateFramebuffer(o.FRAMEBUFFER,vB.invalidateAttachments),l&&o.clear(l),l&o.COLOR_BUFFER_BIT){var p=c.bs.targets[0].blendColorMask;if(p!==Qa.ALL){var m=(p&Qa.R)!==Qa.NONE,g=(p&Qa.G)!==Qa.NONE,v=(p&Qa.B)!==Qa.NONE,y=(p&Qa.A)!==Qa.NONE;o.colorMask(m,g,v,y)}}l&o.DEPTH_BUFFER_BIT&&!c.dss.depthWrite&&o.depthMask(!1),l&o.STENCIL_BUFFER_BIT&&(c.dss.stencilWriteMaskFront||o.stencilMaskSeparate(o.FRONT,0),c.dss.stencilWriteMaskBack||o.stencilMaskSeparate(o.BACK,0))}}function SB(e,t,n,i,r,a,s,o,c,l,u,h,_){var d=e.gl,p=e.stateCache,m=t&&t.gpuShader,g=!1;if(t&&vB.gpuPipelineState!==t){if(vB.gpuPipelineState=t,vB.glPrimitive=t.glPrimitive,m){var v=m.glProgram;p.glProgram!==v&&(d.useProgram(v),p.glProgram=v,g=!0)}var y=t.rs;if(y){if(p.rs.cullMode!==y.cullMode){switch(y.cullMode){case qa.NONE:d.disable(d.CULL_FACE);break;case qa.FRONT:d.enable(d.CULL_FACE),d.cullFace(d.FRONT);break;case qa.BACK:d.enable(d.CULL_FACE),d.cullFace(d.BACK)}e.stateCache.rs.cullMode=y.cullMode}var S=y.isFrontFaceCCW!==vB.reverseCW;e.stateCache.rs.isFrontFaceCCW!==S&&(d.frontFace(S?d.CCW:d.CW),e.stateCache.rs.isFrontFaceCCW=S),e.stateCache.rs.depthBias===y.depthBias&&e.stateCache.rs.depthBiasSlop===y.depthBiasSlop||(d.polygonOffset(y.depthBias,y.depthBiasSlop),e.stateCache.rs.depthBias=y.depthBias,e.stateCache.rs.depthBiasSlop=y.depthBiasSlop),e.stateCache.rs.lineWidth!==y.lineWidth&&(d.lineWidth(y.lineWidth),e.stateCache.rs.lineWidth=y.lineWidth)}var E=t.dss;E&&(p.dss.depthTest!==E.depthTest&&(E.depthTest?d.enable(d.DEPTH_TEST):d.disable(d.DEPTH_TEST),p.dss.depthTest=E.depthTest),p.dss.depthWrite!==E.depthWrite&&(d.depthMask(E.depthWrite),p.dss.depthWrite=E.depthWrite),p.dss.depthFunc!==E.depthFunc&&(d.depthFunc(sB[E.depthFunc]),p.dss.depthFunc=E.depthFunc),p.dss.stencilTestFront===E.stencilTestFront&&p.dss.stencilTestBack===E.stencilTestBack||(E.stencilTestFront||E.stencilTestBack?d.enable(d.STENCIL_TEST):d.disable(d.STENCIL_TEST),p.dss.stencilTestFront=E.stencilTestFront,p.dss.stencilTestBack=E.stencilTestBack),p.dss.stencilFuncFront===E.stencilFuncFront&&p.dss.stencilRefFront===E.stencilRefFront&&p.dss.stencilReadMaskFront===E.stencilReadMaskFront||(d.stencilFuncSeparate(d.FRONT,sB[E.stencilFuncFront],E.stencilRefFront,E.stencilReadMaskFront),p.dss.stencilFuncFront=E.stencilFuncFront,p.dss.stencilRefFront=E.stencilRefFront,p.dss.stencilReadMaskFront=E.stencilReadMaskFront),p.dss.stencilFailOpFront===E.stencilFailOpFront&&p.dss.stencilZFailOpFront===E.stencilZFailOpFront&&p.dss.stencilPassOpFront===E.stencilPassOpFront||(d.stencilOpSeparate(d.FRONT,oB[E.stencilFailOpFront],oB[E.stencilZFailOpFront],oB[E.stencilPassOpFront]),p.dss.stencilFailOpFront=E.stencilFailOpFront,p.dss.stencilZFailOpFront=E.stencilZFailOpFront,p.dss.stencilPassOpFront=E.stencilPassOpFront),p.dss.stencilWriteMaskFront!==E.stencilWriteMaskFront&&(d.stencilMaskSeparate(d.FRONT,E.stencilWriteMaskFront),p.dss.stencilWriteMaskFront=E.stencilWriteMaskFront),p.dss.stencilFuncBack===E.stencilFuncBack&&p.dss.stencilRefBack===E.stencilRefBack&&p.dss.stencilReadMaskBack===E.stencilReadMaskBack||(d.stencilFuncSeparate(d.BACK,sB[E.stencilFuncBack],E.stencilRefBack,E.stencilReadMaskBack),p.dss.stencilFuncBack=E.stencilFuncBack,p.dss.stencilRefBack=E.stencilRefBack,p.dss.stencilReadMaskBack=E.stencilReadMaskBack),p.dss.stencilFailOpBack===E.stencilFailOpBack&&p.dss.stencilZFailOpBack===E.stencilZFailOpBack&&p.dss.stencilPassOpBack===E.stencilPassOpBack||(d.stencilOpSeparate(d.BACK,oB[E.stencilFailOpBack],oB[E.stencilZFailOpBack],oB[E.stencilPassOpBack]),p.dss.stencilFailOpBack=E.stencilFailOpBack,p.dss.stencilZFailOpBack=E.stencilZFailOpBack,p.dss.stencilPassOpBack=E.stencilPassOpBack),p.dss.stencilWriteMaskBack!==E.stencilWriteMaskBack&&(d.stencilMaskSeparate(d.BACK,E.stencilWriteMaskBack),p.dss.stencilWriteMaskBack=E.stencilWriteMaskBack));var T=t.bs;if(T){p.bs.isA2C!==T.isA2C&&(T.isA2C?d.enable(d.SAMPLE_ALPHA_TO_COVERAGE):d.disable(d.SAMPLE_ALPHA_TO_COVERAGE),p.bs.isA2C=T.isA2C),p.bs.blendColor.x===T.blendColor.x&&p.bs.blendColor.y===T.blendColor.y&&p.bs.blendColor.z===T.blendColor.z&&p.bs.blendColor.w===T.blendColor.w||(d.blendColor(T.blendColor.x,T.blendColor.y,T.blendColor.z,T.blendColor.w),p.bs.blendColor.x=T.blendColor.x,p.bs.blendColor.y=T.blendColor.y,p.bs.blendColor.z=T.blendColor.z,p.bs.blendColor.w=T.blendColor.w);var A=T.targets[0],x=p.bs.targets[0];x.blend!==A.blend&&(A.blend?d.enable(d.BLEND):d.disable(d.BLEND),x.blend=A.blend),x.blendEq===A.blendEq&&x.blendAlphaEq===A.blendAlphaEq||(d.blendEquationSeparate(cB[A.blendEq],cB[A.blendAlphaEq]),x.blendEq=A.blendEq,x.blendAlphaEq=A.blendAlphaEq),x.blendSrc===A.blendSrc&&x.blendDst===A.blendDst&&x.blendSrcAlpha===A.blendSrcAlpha&&x.blendDstAlpha===A.blendDstAlpha||(d.blendFuncSeparate(lB[A.blendSrc],lB[A.blendDst],lB[A.blendSrcAlpha],lB[A.blendDstAlpha]),x.blendSrc=A.blendSrc,x.blendDst=A.blendDst,x.blendSrcAlpha=A.blendSrcAlpha,x.blendDstAlpha=A.blendDstAlpha),x.blendColorMask!==A.blendColorMask&&(d.colorMask((A.blendColorMask&Qa.R)!==Qa.NONE,(A.blendColorMask&Qa.G)!==Qa.NONE,(A.blendColorMask&Qa.B)!==Qa.NONE,(A.blendColorMask&Qa.A)!==Qa.NONE),x.blendColorMask=A.blendColorMask)}}if(t&&t.gpuPipelineLayout&&m){for(var C=m.glBlocks.length,R=t.gpuPipelineLayout.dynamicOffsetIndices,b=0;b<C;b++){var w=m.glBlocks[b],I=i[w.set],O=I&&I.descriptorIndices[w.binding],P=O>=0&&I.gpuDescriptors[O];if(P&&P.gpuBuffer){var M=R[w.set],N=M&&M[w.binding],D=P.gpuBuffer.glOffset;N>=0&&(D+=r[N]),p.glBindUBOs[w.glBinding]===P.gpuBuffer.glBuffer&&p.glBindUBOOffsets[w.glBinding]===D||(D?d.bindBufferRange(d.UNIFORM_BUFFER,w.glBinding,P.gpuBuffer.glBuffer,D,P.gpuBuffer.size):d.bindBufferBase(d.UNIFORM_BUFFER,w.glBinding,P.gpuBuffer.glBuffer),p.glUniformBuffer=p.glBindUBOs[w.glBinding]=P.gpuBuffer.glBuffer,p.glBindUBOOffsets[w.glBinding]=D)}else f("Buffer binding '"+w.name+"' at set "+w.set+" binding "+w.binding+" is not bounded")}for(var B=m.glSamplers.length,L=0;L<B;L++)for(var F=m.glSamplers[L],z=i[F.set],U=z&&z.descriptorIndices[F.binding],G=U>=0&&z.gpuDescriptors[U],k=0;k<F.units.length;k++){var H=F.units[k],V=p.glTexUnits[H];if(G&&G.gpuTexture&&G.gpuSampler){if(G.gpuTexture&&G.gpuTexture.size>0){var W=G.gpuTexture;V.glTexture!==W.glTexture&&(p.texUnit!==H&&(d.activeTexture(d.TEXTURE0+H),p.texUnit=H),W.glTexture?d.bindTexture(W.glTarget,W.glTexture):d.bindTexture(W.glTarget,e.nullTex2D.gpuTexture.glTexture),V.glTexture=W.glTexture);var j=G.gpuSampler;p.glSamplerUnits[H]!==j.glSampler&&(d.bindSampler(H,j.glSampler),p.glSamplerUnits[H]=j.glSampler)}G=z.gpuDescriptors[++U]}else f("Sampler binding '"+F.name+"' at set "+F.set+" binding "+F.binding+" index "+k+" is not bounded")}}if(n&&m&&(g||vB.gpuInputAssembler!==n))if(vB.gpuInputAssembler=n,e.useVAO){var q=n.glVAOs.get(m.glProgram);if(!q){var X;q=d.createVertexArray(),n.glVAOs.set(m.glProgram,q),d.bindVertexArray(q),d.bindBuffer(d.ARRAY_BUFFER,null),d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,null),p.glArrayBuffer=null,p.glElementArrayBuffer=null;for(var Y=0;Y<m.glInputs.length;Y++){var K=m.glInputs[Y];X=null;for(var Z=0;Z<n.glAttribs.length;Z++){var Q=n.glAttribs[Z];if(Q.name===K.name){X=Q;break}}if(X){p.glArrayBuffer!==X.glBuffer&&(d.bindBuffer(d.ARRAY_BUFFER,X.glBuffer),p.glArrayBuffer=X.glBuffer);for(var J=0;J<X.componentCount;++J){var $=K.glLoc+J,ee=X.offset+X.size*J;d.enableVertexAttribArray($),p.glCurrentAttribLocs[$]=!0,d.vertexAttribPointer($,X.count,X.glType,X.isNormalized,X.stride,ee),d.vertexAttribDivisor($,X.isInstanced?1:0)}}}var te=n.gpuIndexBuffer;te&&d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,te.glBuffer),d.bindVertexArray(null),d.bindBuffer(d.ARRAY_BUFFER,null),d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,null),p.glArrayBuffer=null,p.glElementArrayBuffer=null}p.glVAO!==q&&(d.bindVertexArray(q),p.glVAO=q)}else{for(var ne=0;ne<e.maxVertexAttributes;++ne)p.glCurrentAttribLocs[ne]=!1;for(var ie=0;ie<m.glInputs.length;ie++){for(var re=m.glInputs[ie],ae=null,se=0;se<n.glAttribs.length;se++){var oe=n.glAttribs[se];if(oe.name===re.name){ae=oe;break}}if(ae){p.glArrayBuffer!==ae.glBuffer&&(d.bindBuffer(d.ARRAY_BUFFER,ae.glBuffer),p.glArrayBuffer=ae.glBuffer);for(var ce=0;ce<ae.componentCount;++ce){var le=re.glLoc+ce,ue=ae.offset+ae.size*ce;!p.glEnabledAttribLocs[le]&&le>=0&&(d.enableVertexAttribArray(le),p.glEnabledAttribLocs[le]=!0),p.glCurrentAttribLocs[le]=!0,d.vertexAttribPointer(le,ae.count,ae.glType,ae.isNormalized,ae.stride,ue),d.vertexAttribDivisor(le,ae.isInstanced?1:0)}}}var he=n.gpuIndexBuffer;he&&p.glElementArrayBuffer!==he.glBuffer&&(d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,he.glBuffer),p.glElementArrayBuffer=he.glBuffer);for(var _e=0;_e<e.maxVertexAttributes;++_e)p.glEnabledAttribLocs[_e]!==p.glCurrentAttribLocs[_e]&&(d.disableVertexAttribArray(_e),p.glEnabledAttribLocs[_e]=!1)}if(t&&t.dynamicStates.length)for(var fe=t.dynamicStates.length,de=0;de<fe;de++)switch(t.dynamicStates[de]){case hs.VIEWPORT:a&&(p.viewport.left===a.left&&p.viewport.top===a.top&&p.viewport.width===a.width&&p.viewport.height===a.height||(d.viewport(a.left,a.top,a.width,a.height),p.viewport.left=a.left,p.viewport.top=a.top,p.viewport.width=a.width,p.viewport.height=a.height));break;case hs.SCISSOR:s&&(p.scissorRect.x===s.x&&p.scissorRect.y===s.y&&p.scissorRect.width===s.width&&p.scissorRect.height===s.height||(d.scissor(s.x,s.y,s.width,s.height),p.scissorRect.x=s.x,p.scissorRect.y=s.y,p.scissorRect.width=s.width,p.scissorRect.height=s.height));break;case hs.LINE_WIDTH:o&&p.rs.lineWidth!==o&&(d.lineWidth(o),p.rs.lineWidth=o);break;case hs.DEPTH_BIAS:c&&(p.rs.depthBias===c.constantFactor&&p.rs.depthBiasSlop===c.slopeFactor||(d.polygonOffset(c.constantFactor,c.slopeFactor),p.rs.depthBias=c.constantFactor,p.rs.depthBiasSlop=c.slopeFactor));break;case hs.BLEND_CONSTANTS:p.bs.blendColor.x===l[0]&&p.bs.blendColor.y===l[1]&&p.bs.blendColor.z===l[2]&&p.bs.blendColor.w===l[3]||(d.blendColor(l[0],l[1],l[2],l[3]),p.bs.blendColor.x=l[0],p.bs.blendColor.y=l[1],p.bs.blendColor.z=l[2],p.bs.blendColor.w=l[3]);break;case hs.STENCIL_WRITE_MASK:if(h)switch(h.face){case _s.FRONT:p.dss.stencilWriteMaskFront!==h.writeMask&&(d.stencilMaskSeparate(d.FRONT,h.writeMask),p.dss.stencilWriteMaskFront=h.writeMask);break;case _s.BACK:p.dss.stencilWriteMaskBack!==h.writeMask&&(d.stencilMaskSeparate(d.BACK,h.writeMask),p.dss.stencilWriteMaskBack=h.writeMask);break;case _s.ALL:p.dss.stencilWriteMaskFront===h.writeMask&&p.dss.stencilWriteMaskBack===h.writeMask||(d.stencilMask(h.writeMask),p.dss.stencilWriteMaskFront=h.writeMask,p.dss.stencilWriteMaskBack=h.writeMask)}break;case hs.STENCIL_COMPARE_MASK:if(_)switch(_.face){case _s.FRONT:p.dss.stencilRefFront===_.reference&&p.dss.stencilReadMaskFront===_.compareMask||(d.stencilFuncSeparate(d.FRONT,sB[p.dss.stencilFuncFront],_.reference,_.compareMask),p.dss.stencilRefFront=_.reference,p.dss.stencilReadMaskFront=_.compareMask);break;case _s.BACK:p.dss.stencilRefBack===_.reference&&p.dss.stencilReadMaskBack===_.compareMask||(d.stencilFuncSeparate(d.BACK,sB[p.dss.stencilFuncBack],_.reference,_.compareMask),p.dss.stencilRefBack=_.reference,p.dss.stencilReadMaskBack=_.compareMask);break;case _s.ALL:p.dss.stencilRefFront===_.reference&&p.dss.stencilReadMaskFront===_.compareMask&&p.dss.stencilRefBack===_.reference&&p.dss.stencilReadMaskBack===_.compareMask||(d.stencilFunc(sB[p.dss.stencilFuncBack],_.reference,_.compareMask),p.dss.stencilRefFront=_.reference,p.dss.stencilReadMaskFront=_.compareMask,p.dss.stencilRefBack=_.reference,p.dss.stencilReadMaskBack=_.compareMask)}}}function EB(e,t){var n=e.gl,i=vB.gpuInputAssembler,r=vB.glPrimitive;if(i)if(i.gpuIndirectBuffer)for(var a=i.gpuIndirectBuffer.indirects,s=0;s<a.length;s++){var o=a[s],c=i.gpuIndexBuffer;if(o.instanceCount)if(c){if(o.indexCount>0){var l=o.firstIndex*c.stride;n.drawElementsInstanced(r,o.indexCount,i.glIndexType,l,o.instanceCount)}}else o.vertexCount>0&&n.drawArraysInstanced(r,o.firstVertex,o.vertexCount,o.instanceCount);else if(c){if(o.indexCount>0){var u=o.firstIndex*c.stride;n.drawElements(r,o.indexCount,i.glIndexType,u)}}else o.vertexCount>0&&n.drawArrays(r,o.firstVertex,o.vertexCount)}else if(t.instanceCount)if(i.gpuIndexBuffer){if(t.indexCount>0){var h=t.firstIndex*i.gpuIndexBuffer.stride;n.drawElementsInstanced(r,t.indexCount,i.glIndexType,h,t.instanceCount)}}else t.vertexCount>0&&n.drawArraysInstanced(r,t.firstVertex,t.vertexCount,t.instanceCount);else if(i.gpuIndexBuffer){if(t.indexCount>0){var _=t.firstIndex*i.gpuIndexBuffer.stride;n.drawElements(r,t.indexCount,i.glIndexType,_)}}else t.vertexCount>0&&n.drawArrays(r,t.firstVertex,t.vertexCount)}var TB=new Array(aB.COUNT);function AB(e,t){TB.fill(0);for(var n=0;n<t.cmds.length;++n){var i=t.cmds.array[n],r=TB[i]++;switch(i){case aB.BEGIN_RENDER_PASS:var a=t.beginRenderPassCmds.array[r];yB(e,a.gpuRenderPass,a.gpuFramebuffer,a.renderArea,a.clearColors,a.clearDepth,a.clearStencil);break;case aB.BIND_STATES:var s=t.bindStatesCmds.array[r];SB(e,s.gpuPipelineState,s.gpuInputAssembler,s.gpuDescriptorSets,s.dynamicOffsets,s.viewport,s.scissor,s.lineWidth,s.depthBias,s.blendConstants,s.depthBounds,s.stencilWriteMask,s.stencilCompareMask);break;case aB.DRAW:EB(e,t.drawCmds.array[r].drawInfo);break;case aB.UPDATE_BUFFER:var o=t.updateBufferCmds.array[r];gB(e,o.gpuBuffer,o.buffer,o.offset,o.size);break;case aB.COPY_BUFFER_TO_TEXTURE:var c=t.copyBufferToTextureCmds.array[r];xB(e,c.buffers,c.gpuTexture,c.regions)}}}function xB(e,t,n,i){var r=e.gl,a=e.stateCache.glTexUnits[e.stateCache.texUnit];a.glTexture!==n.glTexture&&(r.bindTexture(n.glTarget,n.glTexture),a.glTexture=n.glTexture);var s=0,o=1,c=1,l=0,u=Ts[n.format].isCompressed;switch(n.glTarget){case r.TEXTURE_2D:for(var h=0;h<i.length;h++){var _=i[h];o=_.texExtent.width,c=_.texExtent.height;var f=t[s++];u?n.glInternalFmt!==QN.COMPRESSED_RGB_ETC1_WEBGL?r.compressedTexSubImage2D(r.TEXTURE_2D,_.texSubres.mipLevel,_.texOffset.x,_.texOffset.y,o,c,n.glFormat,f):r.compressedTexImage2D(r.TEXTURE_2D,_.texSubres.mipLevel,n.glInternalFmt,o,c,0,f):r.texSubImage2D(r.TEXTURE_2D,_.texSubres.mipLevel,_.texOffset.x,_.texOffset.y,o,c,n.glFormat,n.glType,f)}break;case r.TEXTURE_CUBE_MAP:for(var d=0;d<i.length;d++){var p=i[d],m=p.texSubres.baseArrayLayer+p.texSubres.layerCount;for(l=p.texSubres.baseArrayLayer;l<m;++l){o=p.texExtent.width,c=p.texExtent.height;var g=t[s++];u?n.glInternalFmt!==QN.COMPRESSED_RGB_ETC1_WEBGL?r.compressedTexSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+l,p.texSubres.mipLevel,p.texOffset.x,p.texOffset.y,o,c,n.glFormat,g):r.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+l,p.texSubres.mipLevel,n.glInternalFmt,o,c,0,g):r.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+l,p.texSubres.mipLevel,p.texOffset.x,p.texOffset.y,o,c,n.glFormat,n.glType,g)}}break;default:console.error("Unsupported GL texture type, copy buffer to texture failed.")}n.flags&is.GEN_MIPMAP&&r.generateMipmap(n.glTarget)}var CB,RB=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._gpuBuffer=null,t}X(t,e);var n=t.prototype;return n.initialize=function(e){if("buffer"in e){this._isBufferView=!0;var t=e.buffer;this._usage=t.usage,this._memUsage=t.memUsage,this._size=this._stride=e.range,this._count=1,this._flags=t.flags,this._gpuBuffer={usage:this._usage,memUsage:this._memUsage,size:this._size,stride:this._stride,buffer:this._bakcupBuffer,indirects:t.gpuBuffer.indirects,glTarget:t.gpuBuffer.glTarget,glBuffer:t.gpuBuffer.glBuffer,glOffset:e.offset}}else this._usage=e.usage,this._memUsage=e.memUsage,this._size=e.size,this._stride=Math.max(e.stride||this._size,1),this._count=this._size/this._stride,this._flags=e.flags,this._usage&Ua.INDIRECT&&(this._indirectBuffer=new Os),this._flags&ka.BAKUP_BUFFER&&(this._bakcupBuffer=new Uint8Array(this._size),this._device.memoryStatus.bufferSize+=this._size),this._gpuBuffer={usage:this._usage,memUsage:this._memUsage,size:this._size,stride:this._stride,buffer:this._bakcupBuffer,indirects:[],glTarget:0,glBuffer:null,glOffset:0},e.usage&Ua.INDIRECT&&(this._gpuBuffer.indirects=this._indirectBuffer.drawInfos),function(e,t){var n=e.gl,i=e.stateCache,r=t.memUsage&Ga.HOST?n.DYNAMIC_DRAW:n.STATIC_DRAW;if(t.usage&Ua.VERTEX){t.glTarget=n.ARRAY_BUFFER;var a=n.createBuffer();a&&(t.glBuffer=a,t.size>0&&(e.useVAO&&i.glVAO&&(n.bindVertexArray(null),i.glVAO=vB.gpuInputAssembler=null),e.stateCache.glArrayBuffer!==t.glBuffer&&(n.bindBuffer(n.ARRAY_BUFFER,t.glBuffer),e.stateCache.glArrayBuffer=t.glBuffer),n.bufferData(n.ARRAY_BUFFER,t.size,r),n.bindBuffer(n.ARRAY_BUFFER,null),e.stateCache.glArrayBuffer=null))}else if(t.usage&Ua.INDEX){t.glTarget=n.ELEMENT_ARRAY_BUFFER;var s=n.createBuffer();s&&(t.glBuffer=s,t.size>0&&(e.useVAO&&i.glVAO&&(n.bindVertexArray(null),i.glVAO=vB.gpuInputAssembler=null),e.stateCache.glElementArrayBuffer!==t.glBuffer&&(n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t.glBuffer),e.stateCache.glElementArrayBuffer=t.glBuffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.size,r),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null),e.stateCache.glElementArrayBuffer=null))}else if(t.usage&Ua.UNIFORM){t.glTarget=n.UNIFORM_BUFFER;var o=n.createBuffer();o&&t.size>0&&(t.glBuffer=o,e.stateCache.glUniformBuffer!==t.glBuffer&&(n.bindBuffer(n.UNIFORM_BUFFER,t.glBuffer),e.stateCache.glUniformBuffer=t.glBuffer),n.bufferData(n.UNIFORM_BUFFER,t.size,r),n.bindBuffer(n.UNIFORM_BUFFER,null),e.stateCache.glUniformBuffer=null)}else t.usage&Ua.INDIRECT||t.usage&Ua.TRANSFER_DST||t.usage&Ua.TRANSFER_SRC||console.error("Unsupported BufferType, create buffer failed."),t.glTarget=n.NONE}(this._device,this._gpuBuffer),this._device.memoryStatus.bufferSize+=this._size;return!0},n.destroy=function(){this._gpuBuffer&&(this._isBufferView||(function(e,t){var n=e.gl;if(t.glBuffer){switch(t.glTarget){case n.ARRAY_BUFFER:e.useVAO&&e.stateCache.glVAO&&(n.bindVertexArray(null),e.stateCache.glVAO=vB.gpuInputAssembler=null),n.bindBuffer(n.ARRAY_BUFFER,null),e.stateCache.glArrayBuffer=null;break;case n.ELEMENT_ARRAY_BUFFER:e.useVAO&&e.stateCache.glVAO&&(n.bindVertexArray(null),e.stateCache.glVAO=vB.gpuInputAssembler=null),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null),e.stateCache.glElementArrayBuffer=null;break;case n.UNIFORM_BUFFER:n.bindBuffer(n.UNIFORM_BUFFER,null),e.stateCache.glUniformBuffer=null}n.deleteBuffer(t.glBuffer),t.glBuffer=null}}(this._device,this._gpuBuffer),this._device.memoryStatus.bufferSize-=this._size),this._gpuBuffer=null),this._bakcupBuffer=null},n.resize=function(e){if(this._isBufferView)console.warn("cannot resize buffer views!");else{var t=this._size;if(t!==e){if(this._size=e,this._count=this._size/this._stride,this._bakcupBuffer){var n=this._bakcupBuffer;this._bakcupBuffer=new Uint8Array(this._size),this._bakcupBuffer.set(n),this._device.memoryStatus.bufferSize-=t,this._device.memoryStatus.bufferSize+=e}this._gpuBuffer&&(this._bakcupBuffer&&(this._gpuBuffer.buffer=this._bakcupBuffer),this._gpuBuffer.size=e,e>0&&(function(e,t){var n=e.gl,i=e.stateCache,r=t.memUsage&Ga.HOST?n.DYNAMIC_DRAW:n.STATIC_DRAW;t.usage&Ua.VERTEX?(e.useVAO&&i.glVAO&&(n.bindVertexArray(null),i.glVAO=vB.gpuInputAssembler=null),i.glArrayBuffer!==t.glBuffer&&n.bindBuffer(n.ARRAY_BUFFER,t.glBuffer),t.buffer?n.bufferData(n.ARRAY_BUFFER,t.buffer,r):n.bufferData(n.ARRAY_BUFFER,t.size,r),n.bindBuffer(n.ARRAY_BUFFER,null),i.glArrayBuffer=null):t.usage&Ua.INDEX?(e.useVAO&&i.glVAO&&(n.bindVertexArray(null),i.glVAO=vB.gpuInputAssembler=null),e.stateCache.glElementArrayBuffer!==t.glBuffer&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t.glBuffer),t.buffer?n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.buffer,r):n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.size,r),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null),e.stateCache.glElementArrayBuffer=null):t.usage&Ua.UNIFORM?(e.stateCache.glUniformBuffer!==t.glBuffer&&n.bindBuffer(n.UNIFORM_BUFFER,t.glBuffer),n.bufferData(n.UNIFORM_BUFFER,t.size,r),n.bindBuffer(n.UNIFORM_BUFFER,null),e.stateCache.glUniformBuffer=null):(t.usage&Ua.INDIRECT||t.usage&Ua.TRANSFER_DST||t.usage&Ua.TRANSFER_SRC||console.error("Unsupported BufferType, create buffer failed."),t.glTarget=n.NONE)}(this._device,this._gpuBuffer),this._device.memoryStatus.bufferSize-=t,this._device.memoryStatus.bufferSize+=e))}}},n.update=function(e,t){if(this._isBufferView)console.warn("cannot update through buffer views!");else{var n;if(n=void 0!==t?t:this._usage&Ua.INDIRECT?0:e.byteLength,this._bakcupBuffer&&e!==this._bakcupBuffer.buffer){var i=new Uint8Array(e,0,t);this._bakcupBuffer.set(i)}gB(this._device,this._gpuBuffer,e,0,n)}},j(t,[{key:"gpuBuffer",get:function(){return this._gpuBuffer}}]),t}(Ns),bB=function(){function e(e,t){this._frees=void 0,this._freeIdx=0,this._freeCmds=void 0,this._frees=new Array(t),this._freeCmds=new u_(t);for(var n=0;n<t;++n)this._frees[n]=new e;this._freeIdx=t-1}var t=e.prototype;return t.alloc=function(e){if(this._freeIdx<0){var t=2*this._frees.length,n=this._frees;this._frees=new Array(t);for(var i=t-n.length,r=0;r<i;++r)this._frees[r]=new e;for(var a=i,s=0;a<t;++a,++s)this._frees[a]=n[s];this._freeIdx+=i}var o=this._frees[this._freeIdx];return this._frees[this._freeIdx--]=null,++o.refCount,o},t.free=function(e){0==--e.refCount&&this._freeCmds.push(e)},t.freeCmds=function(e){for(var t=0;t<e.length;++t)0==--e.array[t].refCount&&this._freeCmds.push(e.array[t])},t.release=function(){for(var e=0;e<this._freeCmds.length;++e){var t=this._freeCmds.array[e];t.clear(),this._frees[++this._freeIdx]=t}this._freeCmds.clear()},e}(),wB=function(){function e(){this.beginRenderPassCmdPool=void 0,this.bindStatesCmdPool=void 0,this.drawCmdPool=void 0,this.updateBufferCmdPool=void 0,this.copyBufferToTextureCmdPool=void 0,this.beginRenderPassCmdPool=new bB(hB,1),this.bindStatesCmdPool=new bB(_B,1),this.drawCmdPool=new bB(fB,1),this.updateBufferCmdPool=new bB(dB,1),this.copyBufferToTextureCmdPool=new bB(pB,1)}var t=e.prototype;return t.clearCmds=function(e){e.beginRenderPassCmds.length&&(this.beginRenderPassCmdPool.freeCmds(e.beginRenderPassCmds),e.beginRenderPassCmds.clear()),e.bindStatesCmds.length&&(this.bindStatesCmdPool.freeCmds(e.bindStatesCmds),e.bindStatesCmds.clear()),e.drawCmds.length&&(this.drawCmdPool.freeCmds(e.drawCmds),e.drawCmds.clear()),e.updateBufferCmds.length&&(this.updateBufferCmdPool.freeCmds(e.updateBufferCmds),e.updateBufferCmds.clear()),e.copyBufferToTextureCmds.length&&(this.copyBufferToTextureCmdPool.freeCmds(e.copyBufferToTextureCmds),e.copyBufferToTextureCmds.clear()),e.cmds.clear()},t.releaseCmds=function(){this.beginRenderPassCmdPool.release(),this.bindStatesCmdPool.release(),this.drawCmdPool.release(),this.updateBufferCmdPool.release(),this.copyBufferToTextureCmdPool.release()},e}(),IB=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this).cmdPackage=new mB,t._webGLAllocator=null,t._isInRenderPass=!1,t._curGPUPipelineState=null,t._curGPUDescriptorSets=[],t._curGPUInputAssembler=null,t._curDynamicOffsets=[],t._curViewport=null,t._curScissor=null,t._curLineWidth=null,t._curDepthBias=null,t._curBlendConstants=[],t._curDepthBounds=null,t._curStencilWriteMask=null,t._curStencilCompareMask=null,t._isStateInvalied=!1,t}X(t,e);var n=t.prototype;return n.initialize=function(e){this._type=e.type,this._queue=e.queue,this._webGLAllocator=this._device.cmdAllocator;for(var t=this._device.bindingMappingInfo.bufferOffsets.length,n=0;n<t;n++)this._curGPUDescriptorSets.push(null),this._curDynamicOffsets.push([]);return!0},n.destroy=function(){this._webGLAllocator&&(this._webGLAllocator.clearCmds(this.cmdPackage),this._webGLAllocator=null)},n.begin=function(){this._webGLAllocator.clearCmds(this.cmdPackage),this._curGPUPipelineState=null,this._curGPUInputAssembler=null,this._curGPUDescriptorSets.length=0;for(var e=0;e<this._curDynamicOffsets.length;e++)this._curDynamicOffsets[e].length=0;this._curViewport=null,this._curScissor=null,this._curLineWidth=null,this._curDepthBias=null,this._curBlendConstants.length=0,this._curDepthBounds=null,this._curStencilWriteMask=null,this._curStencilCompareMask=null,this._numDrawCalls=0,this._numInstances=0,this._numTris=0},n.end=function(){this._isStateInvalied&&this.bindStates(),this._isInRenderPass=!1},n.beginRenderPass=function(e,t,n,i,r,a){var s=this._webGLAllocator.beginRenderPassCmdPool.alloc(hB);s.gpuRenderPass=e.gpuRenderPass,s.gpuFramebuffer=t.gpuFramebuffer,s.renderArea=n;for(var o=0;o<i.length;++o)s.clearColors[o]=i[o];s.clearDepth=r,s.clearStencil=a,this.cmdPackage.beginRenderPassCmds.push(s),this.cmdPackage.cmds.push(aB.BEGIN_RENDER_PASS),this._isInRenderPass=!0},n.endRenderPass=function(){this._isInRenderPass=!1},n.bindPipelineState=function(e){var t=e.gpuPipelineState;t!==this._curGPUPipelineState&&(this._curGPUPipelineState=t,this._isStateInvalied=!0)},n.bindDescriptorSet=function(e,t,n){var i=t.gpuDescriptorSet;if(i!==this._curGPUDescriptorSets[e]&&(this._curGPUDescriptorSets[e]=i,this._isStateInvalied=!0),n){for(var r=this._curDynamicOffsets[e],a=0;a<n.length;a++)r[a]=n[a];r.length=n.length,this._isStateInvalied=!0}},n.bindInputAssembler=function(e){var t=e.gpuInputAssembler;this._curGPUInputAssembler=t,this._isStateInvalied=!0},n.setViewport=function(e){this._curViewport?this._curViewport.left===e.left&&this._curViewport.top===e.top&&this._curViewport.width===e.width&&this._curViewport.height===e.height&&this._curViewport.minDepth===e.minDepth&&this._curViewport.maxDepth===e.maxDepth||(this._curViewport.left=e.left,this._curViewport.top=e.top,this._curViewport.width=e.width,this._curViewport.height=e.height,this._curViewport.minDepth=e.minDepth,this._curViewport.maxDepth=e.maxDepth,this._isStateInvalied=!0):this._curViewport=new Ys(e.left,e.top,e.width,e.height,e.minDepth,e.maxDepth)},n.setScissor=function(e){this._curScissor?this._curScissor.x===e.x&&this._curScissor.y===e.y&&this._curScissor.width===e.width&&this._curScissor.height===e.height||(this._curScissor.x=e.x,this._curScissor.y=e.y,this._curScissor.width=e.width,this._curScissor.height=e.height,this._isStateInvalied=!0):this._curScissor=new Xs(e.x,e.y,e.width,e.height)},n.setLineWidth=function(e){this._curLineWidth!==e&&(this._curLineWidth=e,this._isStateInvalied=!0)},n.setDepthBias=function(e,t,n){this._curDepthBias?this._curDepthBias.constantFactor===e&&this._curDepthBias.clamp===t&&this._curDepthBias.slopeFactor===n||(this._curDepthBias.constantFactor=e,this._curDepthBias.clamp=t,this._curDepthBias.slopeFactor=n,this._isStateInvalied=!0):(this._curDepthBias={constantFactor:e,clamp:t,slopeFactor:n},this._isStateInvalied=!0)},n.setBlendConstants=function(e){4!==e.length||this._curBlendConstants[0]===e[0]&&this._curBlendConstants[1]===e[1]&&this._curBlendConstants[2]===e[2]&&this._curBlendConstants[3]===e[3]||(this._curBlendConstants.length=0,Array.prototype.push.apply(this._curBlendConstants,e),this._isStateInvalied=!0)},n.setDepthBound=function(e,t){this._curDepthBounds&&this._curDepthBounds.minBounds===e&&this._curDepthBounds.maxBounds===t||(this._curDepthBounds={minBounds:e,maxBounds:t},this._isStateInvalied=!0)},n.setStencilWriteMask=function(e,t){this._curStencilWriteMask?this._curStencilWriteMask.face===e&&this._curStencilWriteMask.writeMask===t||(this._curStencilWriteMask.face=e,this._curStencilWriteMask.writeMask=t,this._isStateInvalied=!0):(this._curStencilWriteMask={face:e,writeMask:t},this._isStateInvalied=!0)},n.setStencilCompareMask=function(e,t,n){this._curStencilCompareMask?this._curStencilCompareMask.face===e&&this._curStencilCompareMask.reference===t&&this._curStencilCompareMask.compareMask===n||(this._curStencilCompareMask.face=e,this._curStencilCompareMask.reference=t,this._curStencilCompareMask.compareMask=n,this._isStateInvalied=!0):(this._curStencilCompareMask={face:e,reference:t,compareMask:n},this._isStateInvalied=!0)},n.draw=function(e){if(this._type===ss.PRIMARY&&this._isInRenderPass||this._type===ss.SECONDARY){this._isStateInvalied&&this.bindStates();var t=this._webGLAllocator.drawCmdPool.alloc(fB);t.drawInfo.vertexCount=e.vertexCount,t.drawInfo.firstVertex=e.firstVertex,t.drawInfo.indexCount=e.indexCount,t.drawInfo.firstIndex=e.firstIndex,t.drawInfo.vertexOffset=e.vertexOffset,t.drawInfo.instanceCount=e.instanceCount,t.drawInfo.firstInstance=e.firstInstance,this.cmdPackage.drawCmds.push(t),this.cmdPackage.cmds.push(aB.DRAW),++this._numDrawCalls,this._numInstances+=e.instanceCount;var n=e.indexCount||e.vertexCount;if(this._curGPUPipelineState)switch(this._curGPUPipelineState.glPrimitive){case 4:this._numTris+=n/3*Math.max(e.instanceCount,1);break;case 5:case 6:this._numTris+=(n-2)*Math.max(e.instanceCount,1)}}else console.error("Command 'draw' must be recorded inside a render pass.")},n.updateBuffer=function(e,t,n){if(this._type===ss.PRIMARY&&!this._isInRenderPass||this._type===ss.SECONDARY){var i=e.gpuBuffer;if(i){var r,a=this._webGLAllocator.updateBufferCmdPool.alloc(dB),s=0;e.usage&Ua.INDIRECT||(s=void 0!==n?n:t.byteLength),r=t,a.gpuBuffer=i,a.buffer=r,a.offset=0,a.size=s,this.cmdPackage.updateBufferCmds.push(a),this.cmdPackage.cmds.push(aB.UPDATE_BUFFER)}}else console.error("Command 'updateBuffer' must be recorded outside a render pass.")},n.copyBuffersToTexture=function(e,t,n){if(this._type===ss.PRIMARY&&!this._isInRenderPass||this._type===ss.SECONDARY){var i=t.gpuTexture;if(i){var r=this._webGLAllocator.copyBufferToTextureCmdPool.alloc(pB);r.gpuTexture=i,r.regions=n,r.buffers=e,this.cmdPackage.copyBufferToTextureCmds.push(r),this.cmdPackage.cmds.push(aB.COPY_BUFFER_TO_TEXTURE)}}else console.error("Command 'copyBufferToTexture' must be recorded outside a render pass.")},n.execute=function(e,t){for(var n=0;n<t;++n){for(var i=e[n],r=0;r<i.cmdPackage.beginRenderPassCmds.length;++r){var a=i.cmdPackage.beginRenderPassCmds.array[r];++a.refCount,this.cmdPackage.beginRenderPassCmds.push(a)}for(var s=0;s<i.cmdPackage.bindStatesCmds.length;++s){var o=i.cmdPackage.bindStatesCmds.array[s];++o.refCount,this.cmdPackage.bindStatesCmds.push(o)}for(var c=0;c<i.cmdPackage.drawCmds.length;++c){var l=i.cmdPackage.drawCmds.array[c];++l.refCount,this.cmdPackage.drawCmds.push(l)}for(var u=0;u<i.cmdPackage.updateBufferCmds.length;++u){var h=i.cmdPackage.updateBufferCmds.array[u];++h.refCount,this.cmdPackage.updateBufferCmds.push(h)}for(var _=0;_<i.cmdPackage.copyBufferToTextureCmds.length;++_){var f=i.cmdPackage.copyBufferToTextureCmds.array[_];++f.refCount,this.cmdPackage.copyBufferToTextureCmds.push(f)}this.cmdPackage.cmds.concat(i.cmdPackage.cmds.array),this._numDrawCalls+=i._numDrawCalls,this._numInstances+=i._numInstances,this._numTris+=i._numTris}},n.bindStates=function(){var e=this._webGLAllocator.bindStatesCmdPool.alloc(_B);e.gpuPipelineState=this._curGPUPipelineState,Array.prototype.push.apply(e.gpuDescriptorSets,this._curGPUDescriptorSets);for(var t=0;t<this._curDynamicOffsets.length;t++)Array.prototype.push.apply(e.dynamicOffsets,this._curDynamicOffsets[t]);e.gpuInputAssembler=this._curGPUInputAssembler,e.viewport=this._curViewport,e.scissor=this._curScissor,e.lineWidth=this._curLineWidth,e.depthBias=this._curDepthBias,Array.prototype.push.apply(e.blendConstants,this._curBlendConstants),e.depthBounds=this._curDepthBounds,e.stencilWriteMask=this._curStencilWriteMask,e.stencilCompareMask=this._curStencilCompareMask,this.cmdPackage.bindStatesCmds.push(e),this.cmdPackage.cmds.push(aB.BIND_STATES),this._isStateInvalied=!1},j(t,[{key:"webGLDevice",get:function(){return this._device}}]),t}(Bs),OB=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._sync=null,t}X(t,e);var n=t.prototype;return n.initialize=function(){return!0},n.destroy=function(){},n.wait=function(){if(this._sync){var e=this._device.gl;e.clientWaitSync(this._sync,0,e.TIMEOUT_IGNORED)}},n.reset=function(){this._sync&&(this._device.gl.deleteSync(this._sync),this._sync=null)},n.insert=function(){var e=this._device.gl;this._sync&&e.deleteSync(this._sync),this._sync=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0)},t}(Go),PB=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._gpuFramebuffer=null,t}X(t,e);var n=t.prototype;return n.initialize=function(e){this._renderPass=e.renderPass,this._colorTextures=e.colorTextures||[],this._depthStencilTexture=e.depthStencilTexture||null,0!==e.depStencilMipmapLevel&&console.warn("The mipmap level of th texture image to be attached of depth stencil attachment should be 0. Convert to 0.");for(var t=0;t<e.colorMipmapLevels.length;++t)0!==e.colorMipmapLevels[t]&&console.warn("The mipmap level of th texture image to be attached of color attachment "+t+" should be 0. Convert to 0.");for(var n=[],i=0;i<e.colorTextures.length;i++){var r=e.colorTextures[i];r&&n.push(r.gpuTexture)}var a=null;return e.depthStencilTexture&&(a=e.depthStencilTexture.gpuTexture),this._gpuFramebuffer={gpuRenderPass:e.renderPass.gpuRenderPass,gpuColorTextures:n,gpuDepthStencilTexture:a,glFramebuffer:null},function(e,t){if(t.gpuColorTextures.length||t.gpuDepthStencilTexture){var n=e.gl,i=[],r=n.createFramebuffer();if(r){t.glFramebuffer=r,e.stateCache.glFramebuffer!==t.glFramebuffer&&n.bindFramebuffer(n.FRAMEBUFFER,t.glFramebuffer);for(var a=0;a<t.gpuColorTextures.length;++a){var s=t.gpuColorTextures[a];s&&(s.glTexture?n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+a,s.glTarget,s.glTexture,0):n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+a,n.RENDERBUFFER,s.glRenderbuffer),i.push(n.COLOR_ATTACHMENT0+a))}var o=t.gpuDepthStencilTexture;if(o){var c=Ts[o.format].hasStencil?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;o.glTexture?n.framebufferTexture2D(n.FRAMEBUFFER,c,o.glTarget,o.glTexture,0):n.framebufferRenderbuffer(n.FRAMEBUFFER,c,n.RENDERBUFFER,o.glRenderbuffer)}n.drawBuffers(i);var l=n.checkFramebufferStatus(n.FRAMEBUFFER);if(l!==n.FRAMEBUFFER_COMPLETE)switch(l){case n.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:console.error("glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_ATTACHMENT");break;case n.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:console.error("glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT");break;case n.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:console.error("glCheckFramebufferStatus() - FRAMEBUFFER_INCOMPLETE_DIMENSIONS");break;case n.FRAMEBUFFER_UNSUPPORTED:console.error("glCheckFramebufferStatus() - FRAMEBUFFER_UNSUPPORTED")}e.stateCache.glFramebuffer!==t.glFramebuffer&&n.bindFramebuffer(n.FRAMEBUFFER,e.stateCache.glFramebuffer)}}}(this._device,this._gpuFramebuffer),!0},n.destroy=function(){var e,t;this._gpuFramebuffer&&(e=this._device,(t=this._gpuFramebuffer).glFramebuffer&&(e.gl.deleteFramebuffer(t.glFramebuffer),t.glFramebuffer=null),this._gpuFramebuffer=null)},j(t,[{key:"gpuFramebuffer",get:function(){return this._gpuFramebuffer}}]),t}(Gs),MB=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._gpuInputAssembler=null,t}X(t,e);var n=t.prototype;return n.initialize=function(e){if(0===e.vertexBuffers.length)return console.error("InputAssemblerInfo.vertexBuffers is null."),!1;if(this._attributes=e.attributes,this._attributesHash=this.computeAttributesHash(),this._vertexBuffers=e.vertexBuffers,e.indexBuffer)this._indexBuffer=e.indexBuffer,this._indexCount=this._indexBuffer.size/this._indexBuffer.stride,this._firstIndex=0;else{var t=this._vertexBuffers[0];this._vertexCount=t.size/t.stride,this._firstVertex=0,this._vertexOffset=0}this._instanceCount=0,this._firstInstance=0,this._indirectBuffer=e.indirectBuffer||null;for(var n=new Array(e.vertexBuffers.length),i=0;i<e.vertexBuffers.length;++i){var r=e.vertexBuffers[i];r.gpuBuffer&&(n[i]=r.gpuBuffer)}var a=null,s=0;if(e.indexBuffer&&(a=e.indexBuffer.gpuBuffer))switch(a.stride){case 1:s=5121;break;case 2:s=5123;break;case 4:s=5125;break;default:console.error("Illegal index buffer stride.")}var o=null;return e.indirectBuffer&&(o=e.indirectBuffer.gpuBuffer),this._gpuInputAssembler={attributes:e.attributes,gpuVertexBuffers:n,gpuIndexBuffer:a,gpuIndirectBuffer:o,glAttribs:[],glIndexType:s,glVAOs:new Map},function(e,t){var n=e.gl;t.glAttribs=new Array(t.attributes.length);for(var i=[0,0,0,0,0,0,0,0],r=0;r<t.attributes.length;++r){var a=t.attributes[r],s=void 0!==a.stream?a.stream:0,o=t.gpuVertexBuffers[s],c=JD(a.format,n),l=Ts[a.format].size;t.glAttribs[r]={name:a.name,glBuffer:o.glBuffer,glType:c,size:l,count:Ts[a.format].count,stride:o.stride,componentCount:rB(c,n),isNormalized:void 0!==a.isNormalized&&a.isNormalized,isInstanced:void 0!==a.isInstanced&&a.isInstanced,offset:i[s]},i[s]+=l}}(this._device,this._gpuInputAssembler),!0},n.destroy=function(){var e=this._device;this._gpuInputAssembler&&e.useVAO&&function(e,t){for(var n=t.glVAOs.values(),i=n.next();!i.done;)e.gl.deleteVertexArray(i.value),i=n.next();t.glVAOs.clear()}(e,this._gpuInputAssembler),this._gpuInputAssembler=null},j(t,[{key:"gpuInputAssembler",get:function(){return this._gpuInputAssembler}}]),t}(qs),NB=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._gpuDescriptorSetLayout=null,t}X(t,e);var n=t.prototype;return n.initialize=function(e){Array.prototype.push.apply(this._bindings,e.bindings);for(var t=0,n=-1,i=[],r=0;r<this._bindings.length;r++){var a=this._bindings[r];i.push(t),t+=a.count,a.binding>n&&(n=a.binding)}this._bindingIndices=Array(n+1).fill(-1);for(var s=this._descriptorIndices=Array(n+1).fill(-1),o=0;o<this._bindings.length;o++){var c=this._bindings[o];this._bindingIndices[c.binding]=o,s[c.binding]=i[o]}for(var l=[],u=0;u<this._bindings.length;u++){var h=this._bindings[u];if(h.descriptorType&Bo)for(var _=0;_<h.count;_++)l.push(h.binding)}return this._gpuDescriptorSetLayout={bindings:this._bindings,dynamicBindings:l,descriptorIndices:s,descriptorCount:t},!0},n.destroy=function(){this._bindings.length=0},j(t,[{key:"gpuDescriptorSetLayout",get:function(){return this._gpuDescriptorSetLayout}}]),t}(Lo),DB=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._gpuPipelineLayout=null,t}X(t,e);var n=t.prototype;return n.initialize=function(e){Array.prototype.push.apply(this._setLayouts,e.setLayouts);for(var t=[],n=[],i=0,r=0;r<this._setLayouts.length;r++){for(var a=this._setLayouts[r],s=a.gpuDescriptorSetLayout.dynamicBindings,o=Array(a.bindingIndices.length).fill(-1),c=0;c<s.length;c++){var l=s[c];o[l]<0&&(o[l]=i+c)}n.push(a.gpuDescriptorSetLayout),t.push(o),i+=s.length}return this._gpuPipelineLayout={gpuSetLayouts:n,dynamicOffsetIndices:t,dynamicOffsetCount:i},!0},n.destroy=function(){this._setLayouts.length=0},j(t,[{key:"gpuPipelineLayout",get:function(){return this._gpuPipelineLayout}}]),t}(zo),BB=[0,1,3,2,0,0,0,4,5,6,0,0,0,0],LB=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._gpuPipelineState=null,t}X(t,e);var n=t.prototype;return n.initialize=function(e){this._primitive=e.primitive,this._shader=e.shader,this._pipelineLayout=e.pipelineLayout;var t=this._bs;if(e.blendState){var n=e.blendState,i=n.targets;i&&i.forEach((function(e,n){t.setTarget(n,e)})),void 0!==n.isA2C&&(t.isA2C=n.isA2C),void 0!==n.isIndepend&&(t.isIndepend=n.isIndepend),void 0!==n.blendColor&&(t.blendColor=n.blendColor)}Object.assign(this._rs,e.rasterizerState),Object.assign(this._dss,e.depthStencilState),this._is=e.inputState,this._renderPass=e.renderPass,this._dynamicStates=e.dynamicStates;for(var r=[],a=0;a<31;a++)this._dynamicStates&1<<a&&r.push(1<<a);return this._gpuPipelineState={glPrimitive:BB[e.primitive],gpuShader:e.shader.gpuShader,gpuPipelineLayout:e.pipelineLayout.gpuPipelineLayout,rs:e.rasterizerState,dss:e.depthStencilState,bs:e.blendState,gpuRenderPass:e.renderPass.gpuRenderPass,dynamicStates:r},!0},n.destroy=function(){this._gpuPipelineState=null},j(t,[{key:"gpuPipelineState",get:function(){return this._gpuPipelineState}}]),t}(oo),FB=[],zB=function(e){function t(){return e.apply(this,arguments)||this}X(t,e);var n=t.prototype;return n.beginRenderPass=function(e,t,n,i,r,a){yB(this._device,e.gpuRenderPass,t.gpuFramebuffer,n,i,r,a),this._isInRenderPass=!0},n.draw=function(e){if(this._isInRenderPass){this._isStateInvalied&&this.bindStates(),EB(this._device,e),++this._numDrawCalls,this._numInstances+=e.instanceCount;var t=e.indexCount||e.vertexCount;if(this._curGPUPipelineState)switch(this._curGPUPipelineState.glPrimitive){case 4:this._numTris+=t/3*Math.max(e.instanceCount,1);break;case 5:case 6:this._numTris+=(t-2)*Math.max(e.instanceCount,1)}}else console.error("Command 'draw' must be recorded inside a render pass.")},n.updateBuffer=function(e,t,n){if(this._isInRenderPass)console.error("Command 'updateBuffer' must be recorded outside a render pass.");else{var i,r=e.gpuBuffer;r&&(i=void 0!==n?n:e.usage&Ua.INDIRECT?0:t.byteLength,gB(this._device,r,t,0,i))}},n.copyBuffersToTexture=function(e,t,n){if(this._isInRenderPass)console.error("Command 'copyBufferToTexture' must be recorded outside a render pass.");else{var i=t.gpuTexture;i&&xB(this._device,e,i,n)}},n.execute=function(e,t){for(var n=0;n<t;++n){var i=e[n];AB(this._device,i.cmdPackage),this._numDrawCalls+=i._numDrawCalls,this._numInstances+=i._numInstances,this._numTris+=i._numTris}},n.bindStates=function(){FB.length=0;for(var e=0;e<this._curDynamicOffsets.length;e++)Array.prototype.push.apply(FB,this._curDynamicOffsets[e]);SB(this._device,this._curGPUPipelineState,this._curGPUInputAssembler,this._curGPUDescriptorSets,FB,this._curViewport,this._curScissor,this._curLineWidth,this._curDepthBias,this._curBlendConstants,this._curDepthBounds,this._curStencilWriteMask,this._curStencilCompareMask),this._isStateInvalied=!1},t}(IB),UB=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this).numDrawCalls=0,t.numInstances=0,t.numTris=0,t}X(t,e);var n=t.prototype;return n.initialize=function(e){return this._type=e.type,!0},n.destroy=function(){},n.submit=function(e,t){if(!this._isAsync)for(var n=0;n<e.length;n++){var i=e[n];this.numDrawCalls+=i.numDrawCalls,this.numInstances+=i.numInstances,this.numTris+=i.numTris}t&&t.insert()},n.clear=function(){this.numDrawCalls=0,this.numInstances=0,this.numTris=0},t}(lo),GB=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._gpuRenderPass=null,t}X(t,e);var n=t.prototype;return n.initialize=function(e){return this._colorInfos=e.colorAttachments,this._depthStencilInfo=e.depthStencilAttachment,e.subPasses&&(this._subPasses=e.subPasses),this._gpuRenderPass={colorAttachments:this._colorInfos,depthStencilAttachment:this._depthStencilInfo},this._hash=this.computeHash(),!0},n.destroy=function(){this._gpuRenderPass=null},j(t,[{key:"gpuRenderPass",get:function(){return this._gpuRenderPass}}]),t}(po),kB=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._gpuSampler=null,t}X(t,e);var n=t.prototype;return n.initialize=function(e){var t,n,i,r;return this._minFilter=e.minFilter,this._magFilter=e.magFilter,this._mipFilter=e.mipFilter,this._addressU=e.addressU,this._addressV=e.addressV,this._addressW=e.addressW,this._maxAnisotropy=e.maxAnisotropy,this._cmpFunc=e.cmpFunc,this._borderColor=e.borderColor,this._minLOD=e.minLOD,this._maxLOD=e.maxLOD,this._mipLODBias=e.mipLODBias,this._gpuSampler={glSampler:null,minFilter:this._minFilter,magFilter:this._magFilter,mipFilter:this._mipFilter,addressU:this._addressU,addressV:this._addressV,addressW:this._addressW,minLOD:this._minLOD,maxLOD:this._maxLOD,glMinFilter:0,glMagFilter:0,glWrapS:0,glWrapT:0,glWrapR:0},t=this._device,n=this._gpuSampler,(r=(i=t.gl).createSampler())&&(n.minFilter===Ja.LINEAR||n.minFilter===Ja.ANISOTROPIC?n.mipFilter===Ja.LINEAR||n.mipFilter===Ja.ANISOTROPIC?n.glMinFilter=i.LINEAR_MIPMAP_LINEAR:n.mipFilter===Ja.POINT?n.glMinFilter=i.LINEAR_MIPMAP_NEAREST:n.glMinFilter=i.LINEAR:n.mipFilter===Ja.LINEAR||n.mipFilter===Ja.ANISOTROPIC?n.glMinFilter=i.NEAREST_MIPMAP_LINEAR:n.mipFilter===Ja.POINT?n.glMinFilter=i.NEAREST_MIPMAP_NEAREST:n.glMinFilter=i.NEAREST,n.magFilter===Ja.LINEAR||n.magFilter===Ja.ANISOTROPIC?n.glMagFilter=i.LINEAR:n.glMagFilter=i.NEAREST,n.glWrapS=KD[n.addressU],n.glWrapT=KD[n.addressV],n.glWrapR=KD[n.addressW],n.glSampler=r,i.samplerParameteri(r,i.TEXTURE_MIN_FILTER,n.glMinFilter),i.samplerParameteri(r,i.TEXTURE_MAG_FILTER,n.glMagFilter),i.samplerParameteri(r,i.TEXTURE_WRAP_S,n.glWrapS),i.samplerParameteri(r,i.TEXTURE_WRAP_T,n.glWrapT),i.samplerParameteri(r,i.TEXTURE_WRAP_R,n.glWrapR),i.samplerParameterf(r,i.TEXTURE_MIN_LOD,n.minLOD),i.samplerParameterf(r,i.TEXTURE_MAX_LOD,n.maxLOD)),!0},n.destroy=function(){var e,t;this._gpuSampler&&(e=this._device,(t=this._gpuSampler).glSampler&&(e.gl.deleteSampler(t.glSampler),t.glSampler=null),this._gpuSampler=null)},j(t,[{key:"gpuSampler",get:function(){return this._gpuSampler}}]),t}(go),HB=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._gpuShader=null,t}X(t,e);var n=t.prototype;return n.initialize=function(e){this._name=e.name,this._stages=e.stages,this._attributes=e.attributes,this._blocks=e.blocks,this._samplers=e.samplers,this._gpuShader={name:e.name,blocks:e.blocks,samplers:e.samplers,gpuStages:new Array(e.stages.length),glProgram:null,glInputs:[],glUniforms:[],glBlocks:[],glSamplers:[]};for(var t=0;t<e.stages.length;++t){var n=e.stages[t];this._gpuShader.gpuStages[t]={type:n.stage,source:n.source,glShader:null}}return function(e,t){for(var n=e.gl,i=function(e){var i=t.gpuStages[e],r=0,a="",s=1;switch(i.type){case rs.VERTEX:a="VertexShader",r=n.VERTEX_SHADER;break;case rs.FRAGMENT:a="FragmentShader",r=n.FRAGMENT_SHADER;break;default:return console.error("Unsupported ShaderType."),{v:void 0}}var o=n.createShader(r);if(o&&(i.glShader=o,n.shaderSource(i.glShader,"#version 300 es\n"+i.source),n.compileShader(i.glShader),!n.getShaderParameter(i.glShader,n.COMPILE_STATUS))){console.error(a+" in '"+t.name+"' compilation failed."),console.error("Shader source dump:",i.source.replace(/^|\n/g,(function(){return"\n"+s+++" "}))),console.error(n.getShaderInfoLog(i.glShader));for(var c=0;c<t.gpuStages.length;c++){var l=t.gpuStages[e];l.glShader&&(n.deleteShader(l.glShader),l.glShader=null)}return{v:void 0}}},r=0;r<t.gpuStages.length;r++){var a=i(r);if("object"==typeof a)return a.v}var s=n.createProgram();if(s){t.glProgram=s;for(var o=0;o<t.gpuStages.length;o++){var c=t.gpuStages[o];n.attachShader(t.glProgram,c.glShader)}n.linkProgram(t.glProgram);for(var l=0;l<t.gpuStages.length;l++){var u=t.gpuStages[l];u.glShader&&(n.detachShader(t.glProgram,u.glShader),n.deleteShader(u.glShader),u.glShader=null)}if(!n.getProgramParameter(t.glProgram,n.LINK_STATUS))return console.error("Failed to link shader '"+t.name+"'."),void console.error(n.getProgramInfoLog(t.glProgram));console.info("Shader '"+t.name+"' compilation succeeded.");var h=n.getProgramParameter(t.glProgram,n.ACTIVE_ATTRIBUTES);t.glInputs=new Array(h);for(var _=0;_<h;++_){var d=n.getActiveAttrib(t.glProgram,_);if(d){var p,m=d.name.indexOf("[");p=-1!==m?d.name.substr(0,m):d.name;var g=n.getAttribLocation(t.glProgram,p),v=nB(d.type,n),y=iB(d.type,n);t.glInputs[_]={name:p,type:v,stride:y,count:d.size,size:y*d.size,glType:d.type,glLoc:g}}}var S,E,T,A,x=n.getProgramParameter(t.glProgram,n.ACTIVE_UNIFORM_BLOCKS);if(x){t.glBlocks=new Array(x);for(var C=0;C<x;++C){var R=(S=n.getActiveUniformBlockName(t.glProgram,C)).indexOf("[");-1!==R&&(S=S.substr(0,R)),A=null;for(var b=0;b<t.blocks.length;b++)if(t.blocks[b].name===S){A=t.blocks[b];break}if(A){E=C,T=n.getActiveUniformBlockParameter(t.glProgram,E,n.UNIFORM_BLOCK_DATA_SIZE);var w=A.binding+(e.bindingMappingInfo.bufferOffsets[A.set]||0);n.uniformBlockBinding(t.glProgram,E,w),t.glBlocks[C]={set:A.set,binding:A.binding,idx:E,name:S,size:T,glBinding:w}}else f("Block '"+S+"' does not bound")}}if(t.samplers.length>0){t.glSamplers=new Array(t.samplers.length);for(var I=0;I<t.samplers.length;++I){var O=t.samplers[I];t.glSamplers[I]={set:O.set,binding:O.binding,name:O.name,type:O.type,count:O.count,units:[],glUnits:null,glType:tB(O.type,n),glLoc:null}}}for(var P=[],M=[],N=e.bindingMappingInfo,D=e.stateCache.texUnitCacheMap,B=0,L=0;L<t.blocks.length;++L)t.blocks[L].set===N.flexibleSet&&B++;for(var F=0,z=0;z<t.samplers.length;++z){var U=t.samplers[z],G=n.getUniformLocation(t.glProgram,U.name);if(null===G||"number"!=typeof G&&-1===G.id||(P.push(t.glSamplers[z]),M.push(G)),void 0===D[U.name]){var k=U.binding+N.samplerOffsets[U.set]+F;U.set===N.flexibleSet&&(k-=B),D[U.name]=k%e.maxTextureUnits,F+=U.count-1}}if(P.length){for(var H=[],V=0;V<P.length;++V){var W=P[V],j=D[W.name];if(void 0!==j){W.glLoc=M[V];for(var q=0;q<W.count;++q){for(;H[j];)j=(j+1)%e.maxTextureUnits;W.units.push(j),H[j]=!0}}}for(var X=0,Y=0;Y<P.length;++Y){var K=P[Y];if(!K.glLoc){for(K.glLoc=M[Y];H[X];)X++;for(var Z=0;Z<K.count;++Z){for(;H[X];)X=(X+1)%e.maxTextureUnits;void 0===D[K.name]&&(D[K.name]=X),K.units.push(X),H[X]=!0}}}e.stateCache.glProgram!==t.glProgram&&n.useProgram(t.glProgram);for(var Q=0;Q<P.length;Q++){var J=P[Q];J.glUnits=new Int32Array(J.units),n.uniform1iv(J.glLoc,J.glUnits)}e.stateCache.glProgram!==t.glProgram&&n.useProgram(e.stateCache.glProgram)}t.glSamplers=P}}(this._device,this._gpuShader),!0},n.destroy=function(){var e,t;this._gpuShader&&(e=this._device,(t=this._gpuShader).glProgram&&(e.gl.deleteProgram(t.glProgram),t.glProgram=null),this._gpuShader=null)},j(t,[{key:"gpuShader",get:function(){return this._gpuShader}}]),t}(Ao),VB=function(){function e(){this.glArrayBuffer=null,this.glElementArrayBuffer=null,this.glUniformBuffer=null,this.glBindUBOs=[],this.glBindUBOOffsets=[],this.glVAO=null,this.texUnit=0,this.glTexUnits=[],this.glSamplerUnits=[],this.glRenderbuffer=null,this.glFramebuffer=null,this.glReadFramebuffer=null,this.viewport=new Ys,this.scissorRect=new Xs(0,0,0,0),this.rs=new to,this.dss=new no,this.bs=new ro,this.glProgram=null,this.glEnabledAttribLocs=[],this.glCurrentAttribLocs=[],this.texUnitCacheMap={}}return e.prototype.initialize=function(e,t,n){for(var i=0;i<e;++i)this.glTexUnits.push({glTexture:null});this.glSamplerUnits.length=e,this.glSamplerUnits.fill(null),this.glBindUBOs.length=t,this.glBindUBOs.fill(null),this.glBindUBOOffsets.length=t,this.glBindUBOOffsets.fill(0),this.glEnabledAttribLocs.length=n,this.glEnabledAttribLocs.fill(!1),this.glCurrentAttribLocs.length=n,this.glCurrentAttribLocs.fill(!1)},e}(),WB=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._gpuTexture=null,t}X(t,e);var n=t.prototype;return n.initialize=function(e){return"texture"in e?(console.log("WebGL2 does not support texture view."),!1):(this._type=e.type,this._usage=e.usage,this._format=e.format,this._width=e.width,this._height=e.height,this._depth=e.depth,this._layerCount=e.layerCount,this._levelCount=e.levelCount,this._samples=e.samples,this._flags=e.flags,this._isPowerOf2=Ro(this._width)&&Ro(this._height),this._size=xs(this._format,this.width,this.height,this.depth,this._levelCount)*this._layerCount,this._flags&is.BAKUP_BUFFER&&(this._buffer=new ArrayBuffer(this._size)),this._gpuTexture={type:this._type,format:this._format,usage:this._usage,width:this._width,height:this._height,depth:this._depth,size:this._size,arrayLayer:this._layerCount,mipLevel:this._levelCount,samples:this._samples,flags:this._flags,isPowerOf2:this._isPowerOf2,glTarget:0,glInternalFmt:0,glFormat:0,glType:0,glUsage:0,glTexture:null,glRenderbuffer:null,glWrapS:0,glWrapT:0,glMinFilter:0,glMagFilter:0},function(e,t){var n=e.gl;t.glInternalFmt=$D(t.format,n),t.glFormat=eB(t.format,n),t.glType=JD(t.format,n);var i=t.width,r=t.height;switch(t.type){case es.TEX2D:t.glTarget=n.TEXTURE_2D;var a=Math.max(i,r);if(a>e.maxTextureSize&&A(9100,a,e.maxTextureSize),t.samples===ns.X1){var s=n.createTexture();if(s&&t.size>0){t.glTexture=s;var o=e.stateCache.glTexUnits[e.stateCache.texUnit];if(o.glTexture!==t.glTexture&&(n.bindTexture(n.TEXTURE_2D,t.glTexture),o.glTexture=t.glTexture),t.flags&is.IMMUTABLE)n.texStorage2D(n.TEXTURE_2D,t.mipLevel,t.glInternalFmt,i,r);else if(Ts[t.format].isCompressed)if(t.glInternalFmt!==QN.COMPRESSED_RGB_ETC1_WEBGL)for(var c=0;c<t.mipLevel;++c){var l=As(t.format,i,r,1),u=new Uint8Array(l);n.compressedTexImage2D(n.TEXTURE_2D,c,t.glInternalFmt,i,r,0,u),i=Math.max(1,i>>1),r=Math.max(1,r>>1)}else{var h=As(t.format,2,2,1),_=new Uint8Array(h);n.compressedTexImage2D(n.TEXTURE_2D,0,t.glInternalFmt,2,2,0,_)}else for(var f=0;f<t.mipLevel;++f)n.texImage2D(n.TEXTURE_2D,f,t.glInternalFmt,i,r,0,t.glFormat,t.glType,null),i=Math.max(1,i>>1),r=Math.max(1,r>>1)}else n.deleteTexture(s)}else{var d=n.createRenderbuffer();d&&t.size>0&&(t.glRenderbuffer=d,e.stateCache.glRenderbuffer!==t.glRenderbuffer&&(n.bindRenderbuffer(n.RENDERBUFFER,t.glRenderbuffer),e.stateCache.glRenderbuffer=t.glRenderbuffer),n.renderbufferStorageMultisample(n.RENDERBUFFER,ZD[t.samples],t.glInternalFmt,t.width,t.height))}break;case es.CUBE:t.glTarget=n.TEXTURE_CUBE_MAP;var p=Math.max(i,r);p>e.maxCubeMapTextureSize&&A(9100,p,e.maxTextureSize);var m=n.createTexture();if(m&&t.size>0){t.glTexture=m;var g=e.stateCache.glTexUnits[e.stateCache.texUnit];if(g.glTexture!==t.glTexture&&(n.bindTexture(n.TEXTURE_CUBE_MAP,t.glTexture),g.glTexture=t.glTexture),t.flags&is.IMMUTABLE)n.texStorage2D(n.TEXTURE_CUBE_MAP,t.mipLevel,t.glInternalFmt,i,r);else if(Ts[t.format].isCompressed)if(t.glInternalFmt!==QN.COMPRESSED_RGB_ETC1_WEBGL)for(var v=0;v<t.mipLevel;++v){for(var y=As(t.format,i,r,1),S=new Uint8Array(y),E=0;E<6;++E)n.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+E,v,t.glInternalFmt,i,r,0,S);i=Math.max(1,i>>1),r=Math.max(1,r>>1)}else for(var T=0;T<6;++T){var x=As(t.format,2,2,1),C=new Uint8Array(x);n.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+T,0,t.glInternalFmt,2,2,0,C)}else for(var R=0;R<t.mipLevel;++R){for(var b=0;b<6;++b)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+b,R,t.glInternalFmt,i,r,0,t.glFormat,t.glType,null);i=Math.max(1,i>>1),r=Math.max(1,r>>1)}}break;default:console.error("Unsupported TextureType, create texture failed."),t.type=es.TEX2D,t.glTarget=n.TEXTURE_2D}}(this._device,this._gpuTexture),this._device.memoryStatus.textureSize+=this._size,!0)},n.destroy=function(){var e,t;this._gpuTexture&&(e=this._device,(t=this._gpuTexture).glTexture&&(e.gl.deleteTexture(t.glTexture),t.glTexture=null),t.glRenderbuffer&&(e.gl.deleteRenderbuffer(t.glRenderbuffer),t.glRenderbuffer=null),this._device.memoryStatus.textureSize-=this._size,this._gpuTexture=null),this._buffer=null},n.resize=function(e,t){var n=this._size;this._width=e,this._height=t,this._size=xs(this._format,this.width,this.height,this.depth,this._levelCount)*this._layerCount,this._gpuTexture&&(this._gpuTexture.width=e,this._gpuTexture.height=t,this._gpuTexture.size=this._size,function(e,t){var n=e.gl;t.glInternalFmt=$D(t.format,n),t.glFormat=eB(t.format,n),t.glType=JD(t.format,n);var i=t.width,r=t.height;switch(t.type){case es.TEX2D:t.glTarget=n.TEXTURE_2D;var a=Math.max(i,r);if(a>e.maxTextureSize&&A(9100,a,e.maxTextureSize),t.samples===ns.X1){var s=e.stateCache.glTexUnits[e.stateCache.texUnit];if(s.glTexture!==t.glTexture&&(n.bindTexture(n.TEXTURE_2D,t.glTexture),s.glTexture=t.glTexture),Ts[t.format].isCompressed){if(t.glInternalFmt!==QN.COMPRESSED_RGB_ETC1_WEBGL)for(var o=0;o<t.mipLevel;++o){var c=As(t.format,i,r,1),l=new Uint8Array(c);n.compressedTexImage2D(n.TEXTURE_2D,o,t.glInternalFmt,i,r,0,l),i=Math.max(1,i>>1),r=Math.max(1,r>>1)}}else for(var u=0;u<t.mipLevel;++u)n.texImage2D(n.TEXTURE_2D,u,t.glInternalFmt,i,r,0,t.glFormat,t.glType,null),i=Math.max(1,i>>1),r=Math.max(1,r>>1)}else{var h=n.createRenderbuffer();h&&t.size>0&&(t.glRenderbuffer=h,e.stateCache.glRenderbuffer!==t.glRenderbuffer&&(n.bindRenderbuffer(n.RENDERBUFFER,t.glRenderbuffer),e.stateCache.glRenderbuffer=t.glRenderbuffer),n.renderbufferStorageMultisample(n.RENDERBUFFER,ZD[t.samples],t.glInternalFmt,t.width,t.height))}break;case es.CUBE:t.type=es.CUBE,t.glTarget=n.TEXTURE_CUBE_MAP;var _=Math.max(i,r);_>e.maxCubeMapTextureSize&&A(9100,_,e.maxTextureSize);var f=e.stateCache.glTexUnits[e.stateCache.texUnit];if(f.glTexture!==t.glTexture&&(n.bindTexture(n.TEXTURE_CUBE_MAP,t.glTexture),f.glTexture=t.glTexture),Ts[t.format].isCompressed){if(t.glInternalFmt!==QN.COMPRESSED_RGB_ETC1_WEBGL)for(var d=0;d<6;++d){i=t.width,r=t.height;for(var p=0;p<t.mipLevel;++p){var m=As(t.format,i,r,1),g=new Uint8Array(m);n.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+d,p,t.glInternalFmt,i,r,0,g),i=Math.max(1,i>>1),r=Math.max(1,r>>1)}}}else for(var v=0;v<6;++v){i=t.width,r=t.height;for(var y=0;y<t.mipLevel;++y)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+v,y,t.glInternalFmt,i,r,0,t.glFormat,t.glType,null),i=Math.max(1,i>>1),r=Math.max(1,r>>1)}break;default:console.error("Unsupported TextureType, create texture failed."),t.type=es.TEX2D,t.glTarget=n.TEXTURE_2D}}(this._device,this._gpuTexture),this._device.memoryStatus.textureSize-=n,this._device.memoryStatus.textureSize+=this._size)},j(t,[{key:"gpuTexture",get:function(){return this._gpuTexture}}]),t}(bo),jB=e("WebGL2Device",function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this).stateCache=new VB,t.cmdAllocator=new wB,t.nullTex2D=null,t.nullTexCube=null,t._webGL2RC=null,t._isAntialias=!0,t._isPremultipliedAlpha=!0,t._useVAO=!0,t._bindingMappingInfo=new Ls,t._webGLContextLostHandler=null,t._extensions=null,t._EXT_texture_filter_anisotropic=null,t._OES_texture_float_linear=null,t._OES_texture_half_float_linear=null,t._EXT_color_buffer_float=null,t._EXT_disjoint_timer_query_webgl2=null,t._WEBGL_compressed_texture_etc1=null,t._WEBGL_compressed_texture_etc=null,t._WEBGL_compressed_texture_pvrtc=null,t._WEBGL_compressed_texture_astc=null,t._WEBGL_compressed_texture_s3tc=null,t._WEBGL_compressed_texture_s3tc_srgb=null,t._WEBGL_debug_renderer_info=null,t._WEBGL_texture_storage_multisample=null,t._WEBGL_debug_shaders=null,t._WEBGL_lose_context=null,t}X(t,e);var n=t.prototype;return n.initialize=function(e){this._canvas=e.canvasElm,this._isAntialias=e.isAntialias,this._isPremultipliedAlpha=e.isPremultipliedAlpha,this._bindingMappingInfo=e.bindingMappingInfo,this._bindingMappingInfo.bufferOffsets.length||this._bindingMappingInfo.bufferOffsets.push(0),this._bindingMappingInfo.samplerOffsets.length||this._bindingMappingInfo.samplerOffsets.push(0);try{var t={alpha:ft.ENABLE_TRANSPARENT_CANVAS,antialias:this._isAntialias,depth:!0,stencil:!0,premultipliedAlpha:this._isPremultipliedAlpha,preserveDrawingBuffer:!1,powerPreference:"default",failIfMajorPerformanceCaveat:!1};this._webGL2RC=this._canvas.getContext("webgl2",t)}catch(e){return console.warn(e),!1}if(!this._webGL2RC)return console.warn("This device does not support WebGL2."),!1;this._webGLContextLostHandler=this._onWebGLContextLost.bind(this),this._canvas.addEventListener("webglcontextlost",this._onWebGLContextLost),this._canvas2D=document.createElement("canvas"),console.info("WebGL2 device initialized."),this._gfxAPI=ms.WEBGL2,this._deviceName="WebGL2";var n=this._webGL2RC;this._WEBGL_debug_renderer_info=this.getExtension("WEBGL_debug_renderer_info"),this._WEBGL_debug_renderer_info?(this._renderer=n.getParameter(this._WEBGL_debug_renderer_info.UNMASKED_RENDERER_WEBGL),this._vendor=n.getParameter(this._WEBGL_debug_renderer_info.UNMASKED_VENDOR_WEBGL)):(this._renderer=n.getParameter(n.RENDERER),this._vendor=n.getParameter(n.VENDOR)),this._version=n.getParameter(n.VERSION),this._maxVertexAttributes=n.getParameter(n.MAX_VERTEX_ATTRIBS),this._maxVertexUniformVectors=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),this._maxFragmentUniformVectors=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),this._maxTextureUnits=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),this._maxVertexTextureUnits=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),this._maxUniformBufferBindings=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS),this._maxUniformBlockSize=n.getParameter(n.MAX_UNIFORM_BLOCK_SIZE),this._maxTextureSize=n.getParameter(n.MAX_TEXTURE_SIZE),this._maxCubeMapTextureSize=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),this._uboOffsetAlignment=n.getParameter(n.UNIFORM_BUFFER_OFFSET_ALIGNMENT),this._depthBits=n.getParameter(n.DEPTH_BITS),this._stencilBits=n.getParameter(n.STENCIL_BITS),this.stateCache.initialize(this._maxTextureUnits,this._maxUniformBufferBindings,this._maxVertexAttributes),this._devicePixelRatio=e.devicePixelRatio||1,this._width=this._canvas.width,this._height=this._canvas.height,this._nativeWidth=Math.max(e.nativeWidth||this._width,0),this._nativeHeight=Math.max(e.nativeHeight||this._height,0),this._colorFmt=za.RGBA8,32===this._depthBits?8===this._stencilBits?this._depthStencilFmt=za.D32F_S8:this._depthStencilFmt=za.D32F:24===this._depthBits?8===this._stencilBits?this._depthStencilFmt=za.D24S8:this._depthStencilFmt=za.D24:8===this._stencilBits?this._depthStencilFmt=za.D16S8:this._depthStencilFmt=za.D16,this._extensions=n.getSupportedExtensions();var i="";if(this._extensions){for(var r,a=Z(this._extensions);!(r=a()).done;)i+=r.value+" ";console.debug("EXTENSIONS: "+i)}this._EXT_texture_filter_anisotropic=this.getExtension("EXT_texture_filter_anisotropic"),this._EXT_color_buffer_float=this.getExtension("EXT_color_buffer_float"),this._EXT_disjoint_timer_query_webgl2=this.getExtension("EXT_disjoint_timer_query_webgl2"),this._OES_texture_float_linear=this.getExtension("OES_texture_float_linear"),this._OES_texture_half_float_linear=this.getExtension("OES_texture_half_float_linear"),this._WEBGL_compressed_texture_etc1=this.getExtension("WEBGL_compressed_texture_etc1"),this._WEBGL_compressed_texture_etc=this.getExtension("WEBGL_compressed_texture_etc"),this._WEBGL_compressed_texture_pvrtc=this.getExtension("WEBGL_compressed_texture_pvrtc"),this._WEBGL_compressed_texture_astc=this.getExtension("WEBGL_compressed_texture_astc"),this._WEBGL_compressed_texture_s3tc=this.getExtension("WEBGL_compressed_texture_s3tc"),this._WEBGL_compressed_texture_s3tc_srgb=this.getExtension("WEBGL_compressed_texture_s3tc_srgb"),this._WEBGL_texture_storage_multisample=this.getExtension("WEBGL_texture_storage_multisample"),this._WEBGL_debug_shaders=this.getExtension("WEBGL_debug_shaders"),this._WEBGL_lose_context=this.getExtension("WEBGL_lose_context"),this._features.fill(!1),this._features[vs.TEXTURE_FLOAT]=!0,this._features[vs.TEXTURE_HALF_FLOAT]=!0,this._features[vs.FORMAT_R11G11B10F]=!0,this._features[vs.FORMAT_RGB8]=!0,this._features[vs.FORMAT_D16]=!0,this._features[vs.FORMAT_D24]=!0,this._features[vs.FORMAT_D32F]=!0,this._features[vs.FORMAT_D24S8]=!0,this._features[vs.FORMAT_D32FS8]=!0,this._features[vs.MSAA]=!0,this._features[vs.ELEMENT_INDEX_UINT]=!0,this._features[vs.INSTANCED_ARRAYS]=!0,this._features[vs.MULTIPLE_RENDER_TARGETS]=!0,this._features[vs.BLEND_MINMAX]=!0,this._EXT_color_buffer_float&&(this._features[vs.COLOR_FLOAT]=!0,this._features[vs.COLOR_HALF_FLOAT]=!0),this._OES_texture_float_linear&&(this._features[vs.TEXTURE_FLOAT_LINEAR]=!0),this._OES_texture_half_float_linear&&(this._features[vs.TEXTURE_HALF_FLOAT_LINEAR]=!0);var s="";this._WEBGL_compressed_texture_etc1&&(this._features[vs.FORMAT_ETC1]=!0,s+="etc1 "),this._WEBGL_compressed_texture_etc&&(this._features[vs.FORMAT_ETC2]=!0,s+="etc2 "),this._WEBGL_compressed_texture_s3tc&&(this._features[vs.FORMAT_DXT]=!0,s+="dxt "),this._WEBGL_compressed_texture_pvrtc&&(this._features[vs.FORMAT_PVRTC]=!0,s+="pvrtc "),this._WEBGL_compressed_texture_astc&&(this._features[vs.FORMAT_ASTC]=!0,s+="astc "),console.info("RENDERER: "+this._renderer),console.info("VENDOR: "+this._vendor),console.info("VERSION: "+this._version),console.info("DPR: "+this._devicePixelRatio),console.info("SCREEN_SIZE: "+this._width+" x "+this._height),console.info("NATIVE_SIZE: "+this._nativeWidth+" x "+this._nativeHeight),console.info("MAX_VERTEX_ATTRIBS: "+this._maxVertexAttributes),console.info("MAX_VERTEX_UNIFORM_VECTORS: "+this._maxVertexUniformVectors),console.info("MAX_FRAGMENT_UNIFORM_VECTORS: "+this._maxFragmentUniformVectors),console.info("MAX_TEXTURE_IMAGE_UNITS: "+this._maxTextureUnits),console.info("MAX_VERTEX_TEXTURE_IMAGE_UNITS: "+this._maxVertexTextureUnits),console.info("MAX_UNIFORM_BUFFER_BINDINGS: "+this._maxUniformBufferBindings),console.info("MAX_UNIFORM_BLOCK_SIZE: "+this._maxUniformBlockSize),console.info("DEPTH_BITS: "+this._depthBits),console.info("STENCIL_BITS: "+this._stencilBits),console.info("UNIFORM_BUFFER_OFFSET_ALIGNMENT: "+this._uboOffsetAlignment),this._EXT_texture_filter_anisotropic&&console.info("MAX_TEXTURE_MAX_ANISOTROPY_EXT: "+this._EXT_texture_filter_anisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT),console.info("USE_VAO: "+this._useVAO),console.info("COMPRESSED_FORMAT: "+s),this.initStates(n),this._queue=this.createQueue(new co(fs.GRAPHICS)),this._cmdBuff=this.createCommandBuffer(new Ds(this._queue)),this.nullTex2D=this.createTexture(new xo(es.TEX2D,ts.SAMPLED,za.RGBA8,2,2,is.GEN_MIPMAP)),this.nullTexCube=new WB(this),this.nullTexCube.initialize(new xo(es.TEX2D,ts.SAMPLED,za.RGBA8,2,2,is.CUBEMAP|is.GEN_MIPMAP,6));var o=new eo;o.texExtent.width=2,o.texExtent.height=2;var c=new Uint8Array(this.nullTex2D.size);return c.fill(0),this.copyBuffersToTexture([c],this.nullTex2D,[o]),o.texSubres.layerCount=6,this.copyBuffersToTexture([c,c,c,c,c,c],this.nullTexCube,[o]),!0},n.destroy=function(){this._canvas&&this._webGLContextLostHandler&&(this._canvas.removeEventListener("webglcontextlost",this._webGLContextLostHandler),this._webGLContextLostHandler=null),this.nullTex2D&&(this.nullTex2D.destroy(),this.nullTex2D=null),this.nullTexCube&&(this.nullTexCube.destroy(),this.nullTexCube=null),this._queue&&(this._queue.destroy(),this._queue=null),this._cmdBuff&&(this._cmdBuff.destroy(),this._cmdBuff=null),this._extensions=null,this._webGL2RC=null},n.resize=function(e,t){this._width===e&&this._height===t||(console.info("Resizing device: "+e+"x"+t),this._canvas.width=e,this._canvas.height=t,this._width=e,this._height=t)},n.acquire=function(){this.cmdAllocator.releaseCmds()},n.present=function(){var e=this._queue;this._numDrawCalls=e.numDrawCalls,this._numInstances=e.numInstances,this._numTris=e.numTris,e.clear()},n.createCommandBuffer=function(e){var t=new(e.type===ss.PRIMARY?zB:IB)(this);return t.initialize(e)?t:null},n.createBuffer=function(e){var t=new RB(this);return t.initialize(e)?t:null},n.createTexture=function(e){var t=new WB(this);return t.initialize(e)?t:null},n.createSampler=function(e){var t=new kB(this);return t.initialize(e)?t:null},n.createDescriptorSet=function(e){var t=new YD(this);return t.initialize(e)?t:null},n.createShader=function(e){var t=new HB(this);return t.initialize(e)?t:null},n.createInputAssembler=function(e){var t=new MB(this);return t.initialize(e)?t:null},n.createRenderPass=function(e){var t=new GB(this);return t.initialize(e)?t:null},n.createFramebuffer=function(e){var t=new PB(this);return t.initialize(e)?t:null},n.createDescriptorSetLayout=function(e){var t=new NB(this);return t.initialize(e)?t:null},n.createPipelineLayout=function(e){var t=new DB(this);return t.initialize(e)?t:null},n.createPipelineState=function(e){var t=new LB(this);return t.initialize(e)?t:null},n.createFence=function(e){var t=new OB(this);return t.initialize(e)?t:null},n.createQueue=function(e){var t=new UB(this);return t.initialize(e)?t:null},n.copyBuffersToTexture=function(e,t,n){xB(this,e,t.gpuTexture,n)},n.copyTexImagesToTexture=function(e,t,n){!function(e,t,n,i){var r=e.gl,a=e.stateCache.glTexUnits[e.stateCache.texUnit];a.glTexture!==n.glTexture&&(r.bindTexture(n.glTarget,n.glTexture),a.glTexture=n.glTexture);var s=0,o=0;switch(n.glTarget){case r.TEXTURE_2D:for(var c=0;c<i.length;c++){var l=i[c];r.texSubImage2D(r.TEXTURE_2D,l.texSubres.mipLevel,l.texOffset.x,l.texOffset.y,n.glFormat,n.glType,t[s++])}break;case r.TEXTURE_CUBE_MAP:for(var u=0;u<i.length;u++){var h=i[u],_=h.texSubres.baseArrayLayer+h.texSubres.layerCount;for(o=h.texSubres.baseArrayLayer;o<_;++o)r.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+o,h.texSubres.mipLevel,h.texOffset.x,h.texOffset.y,n.glFormat,n.glType,t[s++])}break;default:console.error("Unsupported GL texture type, copy buffer to texture failed.")}n.flags&is.GEN_MIPMAP&&r.generateMipmap(n.glTarget)}(this,e,t.gpuTexture,n)},n.copyFramebufferToBuffer=function(e,t,n){var i=this._webGL2RC,r=e.gpuFramebuffer,a=r.gpuColorTextures[0].format,s=eB(a,i),o=JD(a,i),c=bs(Ts[a]),l=this.stateCache.glFramebuffer;this.stateCache.glFramebuffer!==r.glFramebuffer&&(i.bindFramebuffer(i.FRAMEBUFFER,r.glFramebuffer),this.stateCache.glFramebuffer=r.glFramebuffer);for(var u,h=new c(t),_=Z(n);!(u=_()).done;){var f=u.value,d=f.texExtent.width,p=f.texExtent.height;i.readPixels(f.texOffset.x,f.texOffset.y,d,p,s,o,h)}this.stateCache.glFramebuffer!==l&&(i.bindFramebuffer(i.FRAMEBUFFER,l),this.stateCache.glFramebuffer=l)},n.blitFramebuffer=function(e,t,n,i,r){!function(e,t,n,i,r,a){var s=e.gl;e.stateCache.glReadFramebuffer!==t.glFramebuffer&&(s.bindFramebuffer(s.READ_FRAMEBUFFER,t.glFramebuffer),e.stateCache.glReadFramebuffer=t.glFramebuffer);var o=n.glFramebuffer!==e.stateCache.glFramebuffer;o&&s.bindFramebuffer(s.DRAW_FRAMEBUFFER,n.glFramebuffer);var c=0;t.gpuColorTextures.length>0&&(c|=s.COLOR_BUFFER_BIT),t.gpuDepthStencilTexture&&(c|=s.DEPTH_BUFFER_BIT,Ts[t.gpuDepthStencilTexture.format].hasStencil&&(c|=s.STENCIL_BUFFER_BIT));var l=a===Ja.LINEAR||a===Ja.ANISOTROPIC?s.LINEAR:s.NEAREST;s.blitFramebuffer(i.x,i.y,i.x+i.width,i.y+i.height,r.x,r.y,r.x+r.width,r.y+r.height,c,l),o&&s.bindFramebuffer(s.FRAMEBUFFER,e.stateCache.glFramebuffer)}(this,e.gpuFramebuffer,t.gpuFramebuffer,n,i,r)},n.getExtension=function(e){for(var t=["","WEBKIT_","MOZ_"],n=0;n<t.length;++n){var i=this.gl.getExtension(t[n]+e);if(i)return i}return null},n.initStates=function(e){e.activeTexture(e.TEXTURE0),e.pixelStorei(e.PACK_ALIGNMENT,1),e.pixelStorei(e.UNPACK_ALIGNMENT,1),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.bindFramebuffer(e.FRAMEBUFFER,null),e.enable(e.SCISSOR_TEST),e.enable(e.CULL_FACE),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.enable(e.DEPTH_TEST),e.depthMask(!0),e.depthFunc(e.LESS),e.stencilFuncSeparate(e.FRONT,e.ALWAYS,1,65535),e.stencilOpSeparate(e.FRONT,e.KEEP,e.KEEP,e.KEEP),e.stencilMaskSeparate(e.FRONT,65535),e.stencilFuncSeparate(e.BACK,e.ALWAYS,1,65535),e.stencilOpSeparate(e.BACK,e.KEEP,e.KEEP,e.KEEP),e.stencilMaskSeparate(e.BACK,65535),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.disable(e.BLEND),e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.colorMask(!0,!0,!0,!0),e.blendColor(0,0,0,0)},n._onWebGLContextLost=function(e){E(11e3),_(e)},j(t,[{key:"gl",get:function(){return this._webGL2RC}},{key:"isAntialias",get:function(){return this._isAntialias}},{key:"isPremultipliedAlpha",get:function(){return this._isPremultipliedAlpha}},{key:"useVAO",get:function(){return this._useVAO}},{key:"bindingMappingInfo",get:function(){return this._bindingMappingInfo}},{key:"EXT_texture_filter_anisotropic",get:function(){return this._EXT_texture_filter_anisotropic}},{key:"OES_texture_float_linear",get:function(){return this._OES_texture_float_linear}},{key:"EXT_color_buffer_float",get:function(){return this._EXT_color_buffer_float}},{key:"EXT_disjoint_timer_query_webgl2",get:function(){return this._EXT_disjoint_timer_query_webgl2}},{key:"WEBGL_compressed_texture_etc1",get:function(){return this._WEBGL_compressed_texture_etc1}},{key:"WEBGL_compressed_texture_etc",get:function(){return this._WEBGL_compressed_texture_etc}},{key:"WEBGL_compressed_texture_pvrtc",get:function(){return this._WEBGL_compressed_texture_pvrtc}},{key:"WEBGL_compressed_texture_s3tc",get:function(){return this._WEBGL_compressed_texture_s3tc}},{key:"WEBGL_compressed_texture_s3tc_srgb",get:function(){return this._WEBGL_compressed_texture_s3tc_srgb}},{key:"WEBGL_texture_storage_multisample",get:function(){return this._WEBGL_texture_storage_multisample}},{key:"WEBGL_debug_shaders",get:function(){return this._WEBGL_debug_shaders}},{key:"WEBGL_lose_context",get:function(){return this._WEBGL_lose_context}}]),t}(zs));i.WebGL2Device=jB,function(e){e[e.positions=La.ATTR_POSITION]="positions",e[e.normals=La.ATTR_NORMAL]="normals",e[e.uvs=La.ATTR_TEX_COORD]="uvs",e[e.colors=La.ATTR_COLOR]="colors"}(CB||(CB={}));var qB,XB,YB,KB,ZB,QB,JB=function(){function e(){this._arrayBufferOrPaddings=[],this._length=0}var t=e.prototype;return t.setNextAlignment=function(e){if(0!==e){var t=this._length%e;if(0!==t){var n=e-t;this._arrayBufferOrPaddings.push(n),this._length+=n}}},t.addBuffer=function(e){var t=this._length;return this._arrayBufferOrPaddings.push(e),this._length+=e.byteLength,t},t.getLength=function(){return this._length},t.getCombined=function(){var e=new Uint8Array(this._length),t=0;return this._arrayBufferOrPaddings.forEach((function(n){"number"==typeof n?t+=n:(e.set(new Uint8Array(n),t),t+=n.byteLength)})),e.buffer},e}(),$B=function(){function e(e,t){if(this._mesh=void 0,this._subMeshRenderings=[],this._mesh=e,this._mesh.struct.morph){var n=this._mesh.struct.primitives.length;this._subMeshRenderings=new Array(n).fill(null);for(var i=0;i<n;++i){var r=this._mesh.struct.morph.subMeshMorphs[i];r&&(r.targets.length>hu.MAX_MORPH_TARGET_COUNT?this._subMeshRenderings[i]=new tL(this._mesh,i,this._mesh.struct.morph,t):this._subMeshRenderings[i]=new eL(this._mesh,i,this._mesh.struct.morph,t))}}}return e.prototype.createInstance=function(){for(var e=this,t=this._mesh.struct.primitives.length,n=new Array(t),i=0;i<t;++i){var r,a;n[i]=null!==(r=null===(a=this._subMeshRenderings[i])||void 0===a?void 0:a.createInstance())&&void 0!==r?r:null}return{setWeights:function(e,t){var i;null===(i=n[e])||void 0===i||i.setWeights(t)},requiredPatches:function(t){e._mesh.struct.morph;var i=e._mesh.struct.morph.subMeshMorphs[t],r=n[t];if(null!==r){var a=[{name:"CC_USE_MORPH",value:!0},{name:"CC_MORPH_TARGET_COUNT",value:i.targets.length}];return i.attributes.includes(La.ATTR_POSITION)&&a.push({name:"CC_MORPH_TARGET_HAS_POSITION",value:!0}),i.attributes.includes(La.ATTR_NORMAL)&&a.push({name:"CC_MORPH_TARGET_HAS_NORMAL",value:!0}),i.attributes.includes(La.ATTR_TANGENT)&&a.push({name:"CC_MORPH_TARGET_HAS_TANGENT",value:!0}),a.push.apply(a,r.requiredPatches()),a}},adaptPipelineState:function(e,t){var i;null===(i=n[e])||void 0===i||i.adaptPipelineState(t)},destroy:function(){for(var e,t=Z(n);!(e=t()).done;){var i=e.value;null==i||i.destroy()}}}},e}(),eL=function(){function e(e,t,n,i){this._gfxDevice=void 0,this._subMeshMorph=void 0,this._textureInfo=void 0,this._attributes=void 0,this._verticesCount=void 0,this._gfxDevice=i;var r=n.subMeshMorphs[t];this._subMeshMorph=r,aL(e,t,i);var a=e.struct.vertexBundles[e.struct.primitives[t].vertexBundelIndices[0]].view.count;this._verticesCount=a;var s=r.targets.length,o=rL(i,a*s);this._textureInfo={width:o.width,height:o.height},this._attributes=r.attributes.map((function(t,n){var i=o.create(),s=i.valueView;return r.targets.forEach((function(t,i){for(var r=t.displacements[n],o=new Float32Array(e.data.buffer,e.data.byteOffset+r.offset,r.count),c=a*i*4,l=0;l<a;++l)s[c+4*l+0]=o[3*l+0],s[c+4*l+1]=o[3*l+1],s[c+4*l+2]=o[3*l+2]})),i.updatePixels(),{name:t,morphTexture:i}}))}var t=e.prototype;return t.destroy=function(){for(var e,t=Z(this._attributes);!(e=t()).done;)e.value.morphTexture.destroy()},t.createInstance=function(){var e=this,t=new iL(this._gfxDevice,this._subMeshMorph.targets.length);return t.setMorphTextureInfo(this._textureInfo.width,this._textureInfo.height),t.setVerticesCount(this._verticesCount),t.commit(),{setWeights:function(e){t.setWeights(e),t.commit()},requiredPatches:function(){return[{name:"CC_MORPH_TARGET_USE_TEXTURE",value:!0}]},adaptPipelineState:function(n){for(var i,r=Z(e._attributes);!(i=r()).done;){var a=i.value,s=void 0;switch(a.name){case La.ATTR_POSITION:s=pu;break;case La.ATTR_NORMAL:s=vu;break;case La.ATTR_TANGENT:s=Eu;break;default:_("Unexpected attribute!")}void 0!==s&&(n.bindSampler(s,a.morphTexture.sampler),n.bindTexture(s,a.morphTexture.texture))}n.bindBuffer(hu.BINDING,t.buffer),n.update()},destroy:function(){}}},e}(),tL=function(){function e(e,t,n,i){this._gfxDevice=void 0,this._attributes=[],this._gfxDevice=i;var r=n.subMeshMorphs[t];aL(e,t,i),this._attributes=r.attributes.map((function(t,n){return{name:t,targets:r.targets.map((function(t){return{displacements:new Float32Array(e.data.buffer,e.data.byteOffset+t.displacements[n].offset,t.displacements[n].count)}}))}}))}return e.prototype.createInstance=function(){return new nL(this,this._attributes[0].targets[0].displacements.length/3,this._gfxDevice)},j(e,[{key:"data",get:function(){return this._attributes}}]),e}(),nL=function(){function e(e,t,n){this._attributes=void 0,this._owner=void 0,this._morphUniforms=void 0,this._owner=e,this._morphUniforms=new iL(n,0);var i=rL(n,t);this._morphUniforms.setMorphTextureInfo(i.width,i.height),this._morphUniforms.commit(),this._attributes=this._owner.data.map((function(e){var t=i.create();return{attributeName:e.name,morphTexture:t}}))}var t=e.prototype;return t.setWeights=function(e){for(var t=0;t<this._attributes.length;++t){var n=this._attributes[t],i=n.morphTexture.valueView,r=this._owner.data[t];e.length,r.targets.length;for(var a=0;a<r.targets.length;++a){var s=r.targets[a].displacements,o=e[a],c=s.length/3;if(0===a)for(var l=0;l<c;++l)i[4*l+0]=s[3*l+0]*o,i[4*l+1]=s[3*l+1]*o,i[4*l+2]=s[3*l+2]*o;else for(var u=0;u<c;++u)i[4*u+0]+=s[3*u+0]*o,i[4*u+1]+=s[3*u+1]*o,i[4*u+2]+=s[3*u+2]*o}n.morphTexture.updatePixels()}},t.requiredPatches=function(){return[{name:"CC_MORPH_TARGET_USE_TEXTURE",value:!0},{name:"CC_MORPH_PRECOMPUTED",value:!0}]},t.adaptPipelineState=function(e){for(var t,n=Z(this._attributes);!(t=n()).done;){var i=t.value,r=void 0;switch(i.attributeName){case La.ATTR_POSITION:r=pu;break;case La.ATTR_NORMAL:r=vu;break;case La.ATTR_TANGENT:r=Eu;break;default:_("Unexpected attribute!")}void 0!==r&&(e.bindSampler(r,i.morphTexture.sampler),e.bindTexture(r,i.morphTexture.texture))}e.bindBuffer(hu.BINDING,this._morphUniforms.buffer),e.update()},t.destroy=function(){this._morphUniforms.destroy();for(var e=0;e<this._attributes.length;++e)this._attributes[e].morphTexture.destroy()},e}(),iL=function(){function e(e,t){this._targetCount=void 0,this._localBuffer=void 0,this._remoteBuffer=void 0,this._targetCount=t,this._localBuffer=new DataView(new ArrayBuffer(hu.SIZE)),this._remoteBuffer=e.createBuffer(new Ps(Ua.UNIFORM|Ua.TRANSFER_DST,Ga.HOST|Ga.DEVICE,hu.SIZE,hu.SIZE))}var t=e.prototype;return t.destroy=function(){this._remoteBuffer.destroy()},t.setWeights=function(e){e.length,this._targetCount;for(var t=0;t<e.length;++t)this._localBuffer.setFloat32(hu.OFFSET_OF_WEIGHTS+4*t,e[t],i.sys.isLittleEndian)},t.setMorphTextureInfo=function(e,t){this._localBuffer.setFloat32(hu.OFFSET_OF_DISPLACEMENT_TEXTURE_WIDTH,e,i.sys.isLittleEndian),this._localBuffer.setFloat32(hu.OFFSET_OF_DISPLACEMENT_TEXTURE_HEIGHT,t,i.sys.isLittleEndian)},t.setVerticesCount=function(e){this._localBuffer.setFloat32(hu.OFFSET_OF_VERTICES_COUNT,e,i.sys.isLittleEndian)},t.commit=function(){this._remoteBuffer.update(this._localBuffer.buffer)},j(e,[{key:"buffer",get:function(){return this._remoteBuffer}}]),e}();function rL(e,t){var n,i,r,a;e.hasFeature(vs.TEXTURE_FLOAT)?(n=t,r=16,i=md.PixelFormat.RGBA32F,a=Float32Array):(n=4*t,r=4,i=md.PixelFormat.RGBA8888,a=Uint8Array);var s=function(e){e<5&&(e=5);var t=te(ie(e)),n=t>>1;return{width:1<<(1&t?n+1:n),height:1<<n}}(n),o=s.width,c=s.height;return{width:o,height:c,create:function(){var t=new ArrayBuffer(o*c*r),n=new Float32Array(t),s=a===Float32Array?n:new a(t),l=new G_({width:o,height:c,_data:s,_compressed:!1,format:i}),u=new md;u.setFilters(md.Filter.NEAREST,md.Filter.NEAREST),u.setMipFilter(md.Filter.NONE),u.setWrapMode(md.WrapMode.CLAMP_TO_EDGE,md.WrapMode.CLAMP_TO_EDGE,md.WrapMode.CLAMP_TO_EDGE),u.image=l,u.getGFXTexture()||_("Unexpected: failed to create morph texture?");var h=af.getSampler(e,u.getSamplerHash());return{get texture(){return u.getGFXTexture()},get sampler(){return h},get valueView(){return n},destroy:function(){u.destroy()},updatePixels:function(){u.uploadData(s)}}}}}function aL(e,t,n){e.renderingSubMeshes[t].enableVertexIdChannel(n)}function sL(e){switch(e){case 1:return Uint8Array;case 2:return Uint16Array;case 4:return Uint32Array;default:return Uint8Array}}var oL=new bn,cL=new bn,lL=new Uint8Array,uL=e("Mesh",ih("cc.Mesh")((QB=function(e){function t(){var t;return(t=e.call(this)||this).morphRendering=null,Q(t,"_struct",YB,Y(t)),Q(t,"_dataLength",KB,Y(t)),Q(t,"_hash",ZB,Y(t)),t._data=lL,t._initialized=!1,t._renderingSubMeshes=null,t._boneSpaceBounds=new Map,t._jointBufferIndices=null,t.loaded=!1,t}X(t,e),j(t,[{key:"_nativeAsset",get:function(){return this._data.buffer},set:function(e){this._data.byteLength===e.byteLength?this._data.set(new Uint8Array(e)):this._data=new Uint8Array(e),this.loaded=!0,this.emit("load")}},{key:"subMeshCount",get:function(){var e=this.renderingSubMeshes;return e?e.length:0}},{key:"minPosition",get:function(){return this.struct.minPosition}},{key:"maxPosition",get:function(){return this.struct.maxPosition}},{key:"struct",get:function(){return this._struct}},{key:"data",get:function(){return this._data}},{key:"hash",get:function(){return this._hash||(this._hash=Vs(this._data,666)),this._hash}},{key:"jointBufferIndices",get:function(){return this._jointBufferIndices?this._jointBufferIndices:this._jointBufferIndices=this._struct.primitives.map((function(e){return e.jointMapIndex||0}))}},{key:"renderingSubMeshes",get:function(){return this.initialize(),this._renderingSubMeshes}}]);var n=t.prototype;return n.initialize=function(){var e=this;if(!this._initialized){this._initialized=!0,this._data.byteLength!==this._dataLength&&(this._data=new Uint8Array(this._dataLength),i.assetManager.postLoadNative(this));for(var t=this._data.buffer,n=i.director.root.device,r=this._createVertexBuffers(n,t),a=[],s=function(i){var s=e._struct.primitives[i];if(0===s.vertexBundelIndices.length)return"continue";var o=null,c=null;if(s.indexView){var l=s.indexView,u=l.stride,h=l.length;if(4===u&&!n.hasFeature(vs.ELEMENT_INDEX_UINT)){var _=e._struct.vertexBundles[s.vertexBundelIndices[0]].view.count;if(_>=65536)return E(10001,_,65536),"continue";u>>=1,h>>=1}o=n.createBuffer(new Ps(Ua.INDEX,Ga.DEVICE,h,u)),c=new(sL(l.stride))(t,l.offset,l.count),l.stride!==u&&(c=sL(u).from(c)),e.loaded?o.update(c):e.once("load",(function(){o.update(c)}))}var f=s.vertexBundelIndices.map((function(e){return r[e]})),d=[];if(s.vertexBundelIndices.length>0)for(var p=s.vertexBundelIndices[0],m=e._struct.vertexBundles[p].attributes,g=0;g<m.length;++g){var v=m[g];d[g]=new Ws(v.name,v.format,v.isInstanced,v.stream,v.isInstanced,v.location)}var y=new Lx(f,d,s.primitiveMode,o);y.mesh=e,y.subMeshIdx=i,a.push(y)},o=0;o<this._struct.primitives.length;o++)s(o);this._renderingSubMeshes=a,this._struct.morph&&(this.morphRendering=function(e,t){return new $B(e,t)}(this,n))}},n.destroy=function(){return this.destroyRenderingMesh(),e.prototype.destroy.call(this)},n.destroyRenderingMesh=function(){if(this._renderingSubMeshes){for(var e=0;e<this._renderingSubMeshes.length;e++)this._renderingSubMeshes[e].destroy();this._renderingSubMeshes=null,this._initialized=!1}},n.assign=function(e,t){this.reset({struct:e,data:t})},n.reset=function(e){this.destroyRenderingMesh(),this._struct=e.struct,this._data=e.data,this._dataLength=this.data.byteLength,this._hash=0,this.loaded=!0,this.emit("load")},n.getBoneSpaceBounds=function(e){if(this._boneSpaceBounds.has(e.hash))return this._boneSpaceBounds.get(e.hash);var t=[];this._boneSpaceBounds.set(e.hash,t);for(var n=[],i=e.bindposes,r=0;r<i.length;r++)t.push(new al(1/0,1/0,1/0,-1/0,-1/0,-1/0)),n.push(!1);for(var a=this._struct.primitives,s=0;s<a.length;s++){var o=this.readAttribute(s,La.ATTR_JOINTS),c=this.readAttribute(s,La.ATTR_WEIGHTS),l=this.readAttribute(s,La.ATTR_POSITION);if(o&&c&&l)for(var u=Math.min(o.length/4,c.length/4,l.length/3),h=0;h<u;h++){bn.set(oL,l[3*h+0],l[3*h+1],l[3*h+2]);for(var _=0;_<4;++_){var f=4*h+_,d=o[f];if(!(0===c[f]||d>=i.length)){bn.transformMat4(cL,oL,i[d]),n[d]=!0;var p=t[d];bn.min(p.center,p.center,cL),bn.max(p.halfExtents,p.halfExtents,cL)}}}}for(var m=0;m<i.length;m++){var g=t[m];n[m]?al.fromPoints(g,g.center,g.halfExtents):t[m]=null}return t},n.merge=function(e,t,n){if(n&&(!this.loaded||!e.loaded||!this.validateMergingMesh(e)))return!1;var i=new bn,r=t&&new Dn,a=t&&new al;if(r&&t.getRotation(r),!this._initialized){var s=JSON.parse(JSON.stringify(e._struct)),o=e._data.slice();if(t){s.maxPosition&&s.minPosition&&(bn.add(a.center,s.maxPosition,s.minPosition),bn.multiplyScalar(a.center,a.center,.5),bn.subtract(a.halfExtents,s.maxPosition,s.minPosition),bn.multiplyScalar(a.halfExtents,a.halfExtents,.5),al.transform(a,a,t),bn.add(s.maxPosition,a.center,a.halfExtents),bn.subtract(s.minPosition,a.center,a.halfExtents));for(var c=0;c<s.vertexBundles.length;c++)for(var l=s.vertexBundles[c],u=0;u<l.attributes.length;u++)if(l.attributes[u].name===La.ATTR_POSITION||l.attributes[u].name===La.ATTR_NORMAL){var h=l.attributes[u].format,_=new DataView(o.buffer,l.view.offset+hL(l.attributes,u)),f=dL(_,h),d=pL(_,h);if(!f||!d)continue;for(var p=l.view.count,m=l.view.stride,g=fL(h),v=0;v<p;v++){var y=v*m,S=y+g,E=S+g;switch(i.set(f(y),f(S),f(E)),l.attributes[u].name){case La.ATTR_POSITION:i.transformMat4(t);break;case La.ATTR_NORMAL:bn.transformQuat(i,i,r)}d(y,i.x),d(S,i.y),d(E,i.z)}}}return this.reset({struct:s,data:o}),this.initialize(),!0}for(var T,A,x,C,R,b=new JB,w=0,I=0,O=0,P=0,M=0,N=0,D=0,B=0,L=!1,F=new Array(this._struct.vertexBundles.length),z=0;z<this._struct.vertexBundles.length;++z){var U=this._struct.vertexBundles[z],G=e._struct.vertexBundles[z];O=U.view.offset,P=G.view.offset,I=U.view.stride,w=U.view.count+G.view.count,T=new ArrayBuffer(w*I),A=new Uint8Array(T),O+=(x=this._data.subarray(O,O+U.view.length)).length,P+=(C=e._data.subarray(P,P+G.view.length)).length,A.set(x),M=0;for(var k,H=Z(U.attributes);!(k=H()).done;){var V=k.value;D=0,L=!1;for(var W,j=Z(G.attributes);!(W=j()).done;){var q=W.value;if(V.name===q.name&&V.format===q.format){L=!0;break}D+=Ts[q.format].size}if(L){B=Ts[V.format].size,N=U.view.length+M;for(var X=0;X<G.view.count;++X){if(R=C.subarray(D,D+B),A.set(R,N),(V.name===La.ATTR_POSITION||V.name===La.ATTR_NORMAL)&&t){var Y=new Float32Array(A.buffer,N,3);switch(i.set(Y[0],Y[1],Y[2]),V.name){case La.ATTR_POSITION:i.transformMat4(t);break;case La.ATTR_NORMAL:bn.transformQuat(i,i,r)}Y[0]=i.x,Y[1]=i.y,Y[2]=i.z}N+=U.view.stride,D+=G.view.stride}}M+=Ts[V.format].size}F[z]={attributes:U.attributes,view:{offset:b.getLength(),length:T.byteLength,count:w,stride:I}},b.addBuffer(T)}for(var K,Q,J,$=0,ee=2,te=0,ne=new Array(this._struct.primitives.length),ie=0;ie<this._struct.primitives.length;++ie){var re=this._struct.primitives[ie],ae=e._struct.primitives[ie];ne[ie]={primitiveMode:re.primitiveMode,vertexBundelIndices:re.vertexBundelIndices};for(var se,oe=Z(re.vertexBundelIndices);!(se=oe()).done;){var ce=se.value;te=Math.max(te,this._struct.vertexBundles[ce].view.count)}if(re.indexView&&ae.indexView){$=re.indexView.count,$+=ae.indexView.count,O=re.indexView.offset,P=ae.indexView.offset,ee=$<256?1:$<65536?2:4;var le=new ArrayBuffer($*ee);if(K=2===ee?new Uint16Array(le):1===ee?new Uint8Array(le):new Uint32Array(le),Q=2===re.indexView.stride?new Uint16Array(this._data.buffer,O,re.indexView.count):1===re.indexView.stride?new Uint8Array(this._data.buffer,O,re.indexView.count):new Uint32Array(this._data.buffer,O,re.indexView.count),ee===re.indexView.stride)K.set(Q);else for(var ue=0;ue<re.indexView.count;++ue)K[ue]=Q[ue];O+=re.indexView.length,J=2===ae.indexView.stride?new Uint16Array(e._data.buffer,P,ae.indexView.count):1===ae.indexView.stride?new Uint8Array(e._data.buffer,P,ae.indexView.count):new Uint32Array(e._data.buffer,P,ae.indexView.count);for(var he=0;he<ae.indexView.count;++he)K[re.indexView.count+he]=te+J[he];P+=ae.indexView.length,ne[ie].indexView={offset:b.getLength(),length:le.byteLength,count:$,stride:ee},b.setNextAlignment(ee),b.addBuffer(le)}}var _e={vertexBundles:F,primitives:ne,minPosition:this._struct.minPosition,maxPosition:this._struct.maxPosition};return _e.minPosition&&e._struct.minPosition&&_e.maxPosition&&e._struct.maxPosition&&(t?(bn.add(a.center,e._struct.maxPosition,e._struct.minPosition),bn.multiplyScalar(a.center,a.center,.5),bn.subtract(a.halfExtents,e._struct.maxPosition,e._struct.minPosition),bn.multiplyScalar(a.halfExtents,a.halfExtents,.5),al.transform(a,a,t),bn.add(i,a.center,a.halfExtents),bn.max(_e.maxPosition,_e.maxPosition,i),bn.subtract(i,a.center,a.halfExtents),bn.min(_e.minPosition,_e.minPosition,i)):(bn.min(_e.minPosition,_e.minPosition,e._struct.minPosition),bn.max(_e.maxPosition,_e.maxPosition,e._struct.maxPosition))),this.reset({struct:_e,data:new Uint8Array(b.getCombined())}),this.initialize(),!0},n.validateMergingMesh=function(e){if(this._struct.vertexBundles.length!==e._struct.vertexBundles.length)return!1;for(var t=0;t<this._struct.vertexBundles.length;++t){var n=this._struct.vertexBundles[t],i=e._struct.vertexBundles[t];if(n.attributes.length!==i.attributes.length)return!1;for(var r=0;r<n.attributes.length;++r)if(n.attributes[r].format!==i.attributes[r].format)return!1}if(this._struct.primitives.length!==e._struct.primitives.length)return!1;for(var a=0;a<this._struct.primitives.length;++a){var s=this._struct.primitives[a],o=e._struct.primitives[a];if(s.vertexBundelIndices.length!==o.vertexBundelIndices.length)return!1;for(var c=0;c<s.vertexBundelIndices.length;++c)if(s.vertexBundelIndices[c]!==o.vertexBundelIndices[c])return!1;if(s.primitiveMode!==o.primitiveMode)return!1;if(s.indexView){if(void 0===o.indexView)return!1}else if(o.indexView)return!1}return!0},n.readAttribute=function(e,t){var n=this,i=null;return this._accessAttribute(e,t,(function(e,t){var r=e.view.count,a=e.attributes[t].format,s=bs(Ts[a]);if(0!==r){var o=new DataView(n._data.buffer,e.view.offset+hL(e.attributes,t)),c=Ts[a],l=dL(o,a);if(s&&l){for(var u=c.count,h=new s(r*u),_=e.view.stride,f=0;f<r;++f)for(var d=0;d<u;++d)h[u*f+d]=l(_*f+h.BYTES_PER_ELEMENT*d);i=h}}})),i},n.copyAttribute=function(e,t,n,i,r){var a=this,s=!1;return this._accessAttribute(e,t,(function(e,t){var o=e.view.count;if(0!==o){var c=e.attributes[t].format,l=new DataView(a._data.buffer,e.view.offset+hL(e.attributes,t)),u=new DataView(n,r),h=Ts[c],_=dL(l,c),f=pL(u,c);if(_&&f){for(var d=h.count,p=e.view.stride,m=fL(c),g=i,v=m,y=0;y<o;++y)for(var S=0;S<d;++S)f(g*y+v*S,_(p*y+m*S));s=!0}}else s=!0})),s},n.readIndices=function(e){if(e>=this._struct.primitives.length)return null;var t=this._struct.primitives[e];if(!t.indexView)return null;var n=t.indexView.stride;return new(1===n?Uint8Array:2===n?Uint16Array:Uint32Array)(this._data.buffer,t.indexView.offset,t.indexView.count)},n.copyIndices=function(e,t){if(e>=this._struct.primitives.length)return!1;var n=this._struct.primitives[e];if(!n.indexView)return!1;for(var i=n.indexView.count,r=1===n.indexView.stride?za.R8UI:2===n.indexView.stride?za.R16UI:za.R32UI,a=dL(new DataView(this._data.buffer),r),s=0;s<i;++s)t[s]=a(n.indexView.offset+Ts[r].size*s);return!0},n._accessAttribute=function(e,t,n){if(!(e>=this._struct.primitives.length))for(var i,r=Z(this._struct.primitives[e].vertexBundelIndices);!(i=r()).done;){var a=i.value,s=this._struct.vertexBundles[a],o=s.attributes.findIndex((function(e){return e.name===t}));if(!(o<0)){n(s,o);break}}},n._createVertexBuffers=function(e,t){var n=this;return this._struct.vertexBundles.map((function(i){var r=e.createBuffer(new Ps(Ua.VERTEX,Ga.DEVICE,i.view.length,i.view.stride)),a=new Uint8Array(t,i.view.offset,i.view.length);return n.loaded?r.update(a):n.once("load",(function(){r.update(a)})),r}))},t}(I_),YB=J((XB=QB).prototype,"_struct",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return{vertexBundles:[],primitives:[]}}}),KB=J(XB.prototype,"_dataLength",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),ZB=J(XB.prototype,"_hash",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),qB=XB))||qB);function hL(e,t){for(var n=0,i=0;i<t;++i){var r=e[i];n+=Ts[r.format].size}return n}i.Mesh=uL;var _L=mg.isLittleEndian;function fL(e){var t=Ts[e];return t.size/t.count}function dL(e,t){var n=Ts[t],i=n.size/n.count;switch(n.type){case ps.UNORM:switch(i){case 1:return function(t){return e.getUint8(t)};case 2:return function(t){return e.getUint16(t,_L)};case 4:return function(t){return e.getUint32(t,_L)}}break;case ps.SNORM:case ps.INT:switch(i){case 1:return function(t){return e.getInt8(t)};case 2:return function(t){return e.getInt16(t,_L)};case 4:return function(t){return e.getInt32(t,_L)}}break;case ps.UINT:switch(i){case 1:return function(t){return e.getUint8(t)};case 2:return function(t){return e.getUint16(t,_L)};case 4:return function(t){return e.getUint32(t,_L)}}break;case ps.FLOAT:return function(t){return e.getFloat32(t,_L)}}return null}function pL(e,t){var n=Ts[t],i=n.size/n.count;switch(n.type){case ps.UNORM:switch(i){case 1:return function(t,n){return e.setUint8(t,n)};case 2:return function(t,n){return e.setUint16(t,n,_L)};case 4:return function(t,n){return e.setUint32(t,n,_L)}}break;case ps.SNORM:case ps.INT:switch(i){case 1:return function(t,n){return e.setInt8(t,n)};case 2:return function(t,n){return e.setInt16(t,n,_L)};case 4:return function(t,n){return e.setInt32(t,n,_L)}}break;case ps.UINT:switch(i){case 1:return function(t,n){return e.setUint8(t,n)};case 2:return function(t,n){return e.setUint16(t,n,_L)};case 4:return function(t,n){return e.setUint32(t,n,_L)}}break;case ps.FLOAT:return function(t,n){return e.setFloat32(t,n,_L)}}return null}var mL=[new Ws(La.ATTR_POSITION,za.RGB32F),new Ws(La.ATTR_NORMAL,za.RGB32F),new Ws(La.ATTR_TEX_COORD,za.RG32F),new Ws(La.ATTR_TANGENT,za.RGBA32F),new Ws(La.ATTR_COLOR,za.RGBA32F)],gL=new bn;function vL(e,t,n){n=n||{};var i,r=[],a=0,s=[],o=0,c=e.positions.slice();if(c.length>0){if(i=null,e.attributes)for(var l,u=Z(e.attributes);!(l=u()).done;){var h=l.value;if(h.name===La.ATTR_POSITION){i=h;break}}i||(i=mL[0]),r.push(i);var _=Ts[i.format];o=Math.max(o,Math.floor(c.length/_.count)),s.push({offset:a,data:c,attribute:i}),a+=_.size}if(e.normals&&e.normals.length>0){if(i=null,e.attributes)for(var f,d=Z(e.attributes);!(f=d()).done;){var p=f.value;if(p.name===La.ATTR_NORMAL){i=p;break}}i||(i=mL[1]);var m=Ts[i.format];r.push(i),o=Math.max(o,Math.floor(e.normals.length/m.count)),s.push({offset:a,data:e.normals,attribute:i}),a+=m.size}if(e.uvs&&e.uvs.length>0){if(i=null,e.attributes)for(var g,v=Z(e.attributes);!(g=v()).done;){var y=g.value;if(y.name===La.ATTR_TEX_COORD){i=y;break}}i||(i=mL[2]);var S=Ts[i.format];r.push(i),o=Math.max(o,Math.floor(e.uvs.length/S.count)),s.push({offset:a,data:e.uvs,attribute:i}),a+=S.size}if(e.tangents&&e.tangents.length>0){if(i=null,e.attributes)for(var E,T=Z(e.attributes);!(E=T()).done;){var A=E.value;if(A.name===La.ATTR_TANGENT){i=A;break}}i||(i=mL[3]);var x=Ts[i.format];r.push(i),o=Math.max(o,Math.floor(e.tangents.length/x.count)),s.push({offset:a,data:e.tangents,attribute:i}),a+=x.size}if(e.colors&&e.colors.length>0){if(i=null,e.attributes)for(var C,R=Z(e.attributes);!(C=R()).done;){var b=C.value;if(b.name===La.ATTR_COLOR){i=b;break}}i||(i=mL[4]);var w=Ts[i.format];r.push(i),o=Math.max(o,Math.floor(e.colors.length/w.count)),s.push({offset:a,data:e.colors,attribute:i}),a+=w.size}if(e.customAttributes)for(var I,O=Z(e.customAttributes);!(I=O()).done;){var P=I.value,M=Ts[P.attr.format];r.push(P.attr),o=Math.max(o,Math.floor(P.values.length/M.count)),s.push({offset:a,data:P.values,attribute:P.attr}),a+=M.size}for(var N=new JB,D=new ArrayBuffer(o*a),B=new DataView(D),L=0,F=s;L<F.length;L++){var z=F[L];xx(B,z.data,z.attribute.format,z.offset,a)}N.setNextAlignment(0);var U={attributes:r,view:{offset:N.getLength(),length:D.byteLength,count:o,stride:a}};N.addBuffer(D);var G=null,k=0;if(e.indices){var H=e.indices;k=H.length,G=new ArrayBuffer(2*k),xx(new DataView(G),H,za.R16UI)}var V={primitiveMode:e.primitiveMode||Va.TRIANGLE_LIST,vertexBundelIndices:[0]};G&&(N.setNextAlignment(2),V.indexView={offset:N.getLength(),length:G.byteLength,count:k,stride:2},N.addBuffer(G));var W=e.minPos;if(!W&&n.calculateBounds){W=bn.set(new bn,1/0,1/0,1/0);for(var j=0;j<o;++j)bn.set(gL,c[3*j+0],c[3*j+1],c[3*j+2]),bn.min(W,W,gL)}var q=e.maxPos;if(!q&&n.calculateBounds){q=bn.set(new bn,-1/0,-1/0,-1/0);for(var X=0;X<o;++X)bn.set(gL,c[3*X+0],c[3*X+1],c[3*X+2]),bn.max(q,q,gL)}var Y={vertexBundles:[U],primitives:[V]};return W&&(Y.minPosition=new bn(W.x,W.y,W.z)),q&&(Y.maxPosition=new bn(q.x,q.y,q.z)),t||(t=new uL),t.reset({struct:Y,data:new Uint8Array(N.getCombined())}),t}var yL=Object.freeze({__proto__:null,find:nw,toPPM:function(e,t,n){return"P3 "+t+" "+n+" 255\n"+e.filter((function(e,t){return t%4<3})).toString()+"\n"},readMesh:function(e,t){void 0===t&&(t=0);for(var n,i={positions:[]},r=new DataView(e.data.buffer,e.data.byteOffset,e.data.byteLength),a=e.struct,s=a.primitives[t],o=Z(s.vertexBundelIndices);!(n=o()).done;)for(var c,l=n.value,u=a.vertexBundles[l],h=u.view.offset,_=u.view,f=_.length,d=_.stride,p=Z(u.attributes);!(c=p()).done;){var m=c.value,g=CB[m.name];g&&(i[g]=(i[g]||[]).concat(Cx(r,m.format,h,f,d))),h+=Ts[m.format].size}var v=s.indexView;return i.indices=Cx(r,za["R"+8*v.stride+"UI"],v.offset,v.length),i},createMesh:vL,readBuffer:Cx,writeBuffer:xx,mapBuffer:Rx});e("utils",yL);var SL,EL,TL,AL,xL,CL,RL,bL,wL,IL,OL,PL,ML,NL,DL,BL,LL,FL,zL,UL,GL,kL,HL,VL,WL,jL,qL,XL,YL,KL,ZL,QL,JL,$L,eF,tF,nF,iF,rF,aF,sF=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._morphRenderingInstance=null,t._usedMaterials=new Set,t}X(t,e);var n=t.prototype;return n.getMacroPatches=function(e){return this._morphRenderingInstance?this._morphRenderingInstance.requiredPatches(e):void 0},n.initSubModel=function(t,n,i){return e.prototype.initSubModel.call(this,t,n,this._launderMaterial(i))},n.setSubModelMaterial=function(t,n){return e.prototype.setSubModelMaterial.call(this,t,this._launderMaterial(n))},n._updateLocalDescriptors=function(t,n){e.prototype._updateLocalDescriptors.call(this,t,n),this._morphRenderingInstance&&this._morphRenderingInstance.adaptPipelineState(t,n)},n._launderMaterial=function(e){return e},n.setMorphRendering=function(e){this._morphRenderingInstance=e},t}(Lp),oF=ct({OFF:0,ON:1}),cF=ct({OFF:0,ON:1}),lF=(SL=ih("cc.ModelLightmapSettings"),EL=oh(uh({formerlySerializedAs:"_recieveShadow"})),SL((OL=function(){function e(){Q(this,"texture",xL,this),Q(this,"uvParam",CL,this),Q(this,"_bakeable",RL,this),Q(this,"_castShadow",bL,this),Q(this,"_receiveShadow",wL,this),Q(this,"_lightmapSize",IL,this)}return j(e,[{key:"bakeable",get:function(){return this._bakeable},set:function(e){this._bakeable=e}},{key:"castShadow",get:function(){return this._castShadow},set:function(e){this._castShadow=e}},{key:"receiveShadow",get:function(){return this._receiveShadow},set:function(e){this._receiveShadow=e}},{key:"lightmapSize",get:function(){return this._lightmapSize},set:function(e){this._lightmapSize=e}}]),e}(),xL=J((AL=OL).prototype,"texture",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),CL=J(AL.prototype,"uvParam",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Zn}}),RL=J(AL.prototype,"_bakeable",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),bL=J(AL.prototype,"_castShadow",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),wL=J(AL.prototype,"_receiveShadow",[EL],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),IL=J(AL.prototype,"_lightmapSize",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 64}}),J(AL.prototype,"bakeable",[gh],Object.getOwnPropertyDescriptor(AL.prototype,"bakeable"),AL.prototype),J(AL.prototype,"castShadow",[gh],Object.getOwnPropertyDescriptor(AL.prototype,"castShadow"),AL.prototype),J(AL.prototype,"receiveShadow",[gh],Object.getOwnPropertyDescriptor(AL.prototype,"receiveShadow"),AL.prototype),J(AL.prototype,"lightmapSize",[gh],Object.getOwnPropertyDescriptor(AL.prototype,"lightmapSize"),AL.prototype),TL=AL))||TL),uF=function(t){return e({MeshRenderer:t,ModelComponent:t}),t}((PL=ih("cc.MeshRenderer"),ML=mh(),NL=ah(100),DL=_h(),BL=Dh(oF),LL=Sh(),FL=Dh(cF),zL=Sh(),UL=Dh(uL),GL=Sh(),kL=vh(),PL(HL=ML(HL=NL(HL=DL(HL=hh((ZL=KL=function(e){function t(){var t;return Q(t=e.call(this)||this,"lightmapSettings",WL,Y(t)),Q(t,"_mesh",jL,Y(t)),Q(t,"_shadowCastingMode",qL,Y(t)),Q(t,"_shadowReceivingMode",XL,Y(t)),t._modelType=void 0,t._model=null,t._morphInstance=null,Q(t,"_enableMorph",YL,Y(t)),t._modelType=Lp,t}X(t,e),j(t,[{key:"shadowCastingMode",get:function(){return this._shadowCastingMode},set:function(e){this._shadowCastingMode=e,this._updateCastShadow()}},{key:"receiveShadow",get:function(){return this._shadowReceivingMode},set:function(e){this._shadowReceivingMode=e,this._updateReceiveShadow()}},{key:"mesh",get:function(){return this._mesh},set:function(e){var t=this._mesh;this._mesh=e,this._mesh&&this._mesh.initialize(),this._watchMorphInMesh(),this._onMeshChanged(t),this._updateModels(),this.enabledInHierarchy&&this._attachToScene(),this._updateCastShadow(),this._updateReceiveShadow()}},{key:"model",get:function(){return this._model}},{key:"enableMorph",get:function(){return this._enableMorph},set:function(e){this._enableMorph=e}}]);var n=t.prototype;return n.onLoad=function(){this._mesh&&this._mesh.initialize(),this._watchMorphInMesh(),this._updateModels(),this._updateCastShadow(),this._updateReceiveShadow()},n.onRestore=function(){this._updateModels(),this._updateCastShadow(),this._updateReceiveShadow()},n.onEnable=function(){this._model||this._updateModels(),this._attachToScene()},n.onDisable=function(){this._model&&this._detachFromScene()},n.onDestroy=function(){this._model&&(i.director.root.destroyModel(this._model),this._model=null,this._models.length=0),this._morphInstance&&this._morphInstance.destroy()},n.setWeights=function(e,t){this._morphInstance&&this._morphInstance.setWeights(t,e)},n.setInstancedAttribute=function(e,t){if(this.model)for(var n=this.model.instancedAttributes,i=n.attributes,r=n.views,a=0;a<i.length;a++)if(i[a].name===e){r[a].set(t);break}},n._updateLightmap=function(e,t,n,i,r){this.lightmapSettings.texture=e,this.lightmapSettings.uvParam.x=t,this.lightmapSettings.uvParam.y=n,this.lightmapSettings.uvParam.z=i,this.lightmapSettings.uvParam.w=r,this._onUpdateLightingmap()},n._updateModels=function(){if(this.enabledInHierarchy&&this._mesh){var e=this._model;e?(e.destroy(),e.initialize(),e.node=e.transform=this.node):this._createModel(),this._model&&(this._model.createBoundingShape(this._mesh.struct.minPosition,this._mesh.struct.maxPosition),this._updateModelParams(),this._onUpdateLightingmap())}},n._createModel=function(){var e=this._morphInstance&&this._modelType===Lp?sF:this._modelType,t=this._model=i.director.root.createModel(e);t.visFlags=this.visibility,t.node=t.transform=this.node,this._models.length=0,this._models.push(this._model),this._morphInstance&&t instanceof sF&&t.setMorphRendering(this._morphInstance)},n._attachToScene=function(){if(this.node.scene&&this._model){var e=this._getRenderScene();null!==this._model.scene&&this._detachFromScene(),e.addModel(this._model)}},n._detachFromScene=function(){this._model&&this._model.scene&&this._model.scene.removeModel(this._model)},n._updateModelParams=function(){if(this._mesh&&this._model){this.node.hasChangedFlags|=Uu.POSITION,this._model.transform.hasChangedFlags|=Uu.POSITION,this._model.isDynamicBatching=this._isBatchingEnabled();var e=this._mesh?this._mesh.renderingSubMeshes.length:0,t=this._mesh.renderingSubMeshes;if(t)for(var n=0;n<e;++n){var i=this.getRenderMaterial(n);i&&!i.isValid&&(i=null);var r=t[n];r&&this._model.initSubModel(n,r,i||this._getBuiltinMaterial())}this._model.enabled=!0}},n._onUpdateLightingmap=function(){null!==this.model&&this.model.updateLightingmap(this.lightmapSettings.texture,this.lightmapSettings.uvParam),this.setInstancedAttribute("a_lightingMapUVParam",[this.lightmapSettings.uvParam.x,this.lightmapSettings.uvParam.y,this.lightmapSettings.uvParam.z,this.lightmapSettings.uvParam.w])},n._onMaterialModified=function(e,t){this._model&&this._model.inited&&this._onRebuildPSO(e,t||this._getBuiltinMaterial())},n._onRebuildPSO=function(e,t){this._model&&this._model.inited&&(this._model.isDynamicBatching=this._isBatchingEnabled(),this._model.setSubModelMaterial(e,t),this._onUpdateLightingmap())},n._onMeshChanged=function(){},n._clearMaterials=function(){if(this._model)for(var e=this._model.subModels,t=0;t<e.length;++t)this._onMaterialModified(t,null)},n._getBuiltinMaterial=function(){return Xd.get("missing-material")},n._onVisibilityChange=function(e){this._model&&(this._model.visFlags=e)},n._updateCastShadow=function(){this._model&&(this._shadowCastingMode===oF.OFF?this._model.castShadow=!1:(this._shadowCastingMode,oF.ON,this._shadowCastingMode,this._model.castShadow=!0))},n._updateReceiveShadow=function(){this._model&&(this._shadowReceivingMode===cF.OFF?this._model.receiveShadow=!1:this._model.receiveShadow=!0)},n._isBatchingEnabled=function(){for(var e=0;e<this._materials.length;++e){var t=this._materials[e];if(t)for(var n=0;n<t.passes.length;++n)if(t.passes[n].batchingScheme)return!0}return!1},n._watchMorphInMesh=function(){if(this._morphInstance&&(this._morphInstance.destroy(),this._morphInstance=null),this._enableMorph&&this._mesh&&this._mesh.struct.morph&&this._mesh.morphRendering){var e=this._mesh.struct.morph;this._morphInstance=this._mesh.morphRendering.createInstance();for(var t=this._mesh.struct.primitives.length,n=0;n<t;++n){var i=e.subMeshMorphs[n];if(i){var r=i.weights||e.weights,a=r?r.slice():new Array(i.targets.length).fill(0);this._morphInstance.setWeights(n,a)}}this._model&&this._model instanceof sF&&this._model.setMorphRendering(this._morphInstance)}},n._syncMorphWeights=function(e){if(this._morphInstance){var t=this._morphInstance[e];t&&t.renderResources&&t.renderResources.setWeights(t.weights)}},t}(zP),KL.ShadowCastingMode=oF,KL.ShadowReceivingMode=cF,WL=J((VL=ZL).prototype,"lightmapSettings",[ch,gh,Ih],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new lF}}),jL=J(VL.prototype,"_mesh",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),qL=J(VL.prototype,"_shadowCastingMode",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return oF.OFF}}),XL=J(VL.prototype,"_shadowReceivingMode",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return cF.ON}}),J(VL.prototype,"shadowCastingMode",[BL,LL,Ih],Object.getOwnPropertyDescriptor(VL.prototype,"shadowCastingMode"),VL.prototype),J(VL.prototype,"receiveShadow",[FL,zL,Ih],Object.getOwnPropertyDescriptor(VL.prototype,"receiveShadow"),VL.prototype),J(VL.prototype,"mesh",[UL,GL],Object.getOwnPropertyDescriptor(VL.prototype,"mesh"),VL.prototype),J(VL.prototype,"enableMorph",[kL,Ih],Object.getOwnPropertyDescriptor(VL.prototype,"enableMorph"),VL.prototype),YL=J(VL.prototype,"_enableMorph",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),HL=VL))||HL)||HL)||HL)||HL)||HL));function hF(e,t){var n=e.sharedMaterials.length;if(n!==t.sharedMaterials.length)return!1;for(var i=0;i<n;i++)if(e.getRenderMaterial(i)!==t.getRenderMaterial(i))return!1;return!0}e("BatchingUtility",function(){function e(){}return e.batchStaticModel=function(e,t){var n=e.getComponentsInChildren(uF);if(n.length<2)return console.error("the number of static models to batch is less than 2,it needn't batch."),!1;for(var i=1;i<n.length;i++){if(!n[0].mesh.validateMergingMesh(n[i].mesh))return console.error("the meshes of "+n[0].node.name+" and "+n[i].node.name+" can't be merged"),!1;if(!hF(n[0],n[i]))return console.error("the materials of "+n[0].node.name+" and "+n[i].node.name+" can't be merged"),!1}var r=new uL,a=new Hn,s=new Hn;e.getWorldMatrix(s),Hn.invert(s,s);for(var o=0;o<n.length;o++){var c=n[o];c.node.getWorldMatrix(a),Hn.multiply(a,s,a),r.merge(n[o].mesh,a),c.enabled=!1}var l=t.addComponent(uF);return l.mesh=r,l.sharedMaterials=n[0].sharedMaterials,!0},e.unbatchStaticModel=function(e,t){for(var n=e.getComponentsInChildren("cc.MeshRenderer"),i=0;i<n.length;i++)n[i].enabled=!0;var r=t.getComponent("cc.MeshRenderer");return r&&r.destroy(),!0},e}()),se(uL.prototype,"Mesh.prototype",[{name:"renderingMesh",newName:"renderingSubMeshes"}]),oe(uL.prototype,"Mesh.prototype",[{name:"hasFlatBuffers"},{name:"destroyFlatBuffers"}]);var _F,fF,dF,pF,mF,gF,vF,yF,SF,EF,TF,AF,xF,CF,RF,bF,wF,IF,OF,PF,MF,NF=e("Skeleton",(QL=ih("cc.Skeleton"),JL=Dh([Ft]),$L=Dh([Hn]),QL((aF=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return Q(t=e.call.apply(e,[this].concat(i))||this,"_joints",nF,Y(t)),Q(t,"_bindposes",iF,Y(t)),Q(t,"_hash",rF,Y(t)),t._invBindposes=null,t}return X(t,e),t.prototype.destroy=function(){return i.director.root.dataPoolManager.releaseSkeleton(this),e.prototype.destroy.call(this)},j(t,[{key:"joints",get:function(){return this._joints},set:function(e){this._joints=e}},{key:"bindposes",get:function(){return this._bindposes},set:function(e){this._bindposes=e}},{key:"inverseBindposes",get:function(){if(!this._invBindposes){this._invBindposes=[];for(var e=0;e<this._bindposes.length;e++){var t=new Hn;Hn.invert(t,this._bindposes[e]),this._invBindposes.push(t)}}return this._invBindposes}},{key:"hash",get:function(){if(!this._hash){for(var e="",t=0;t<this._bindposes.length;t++){var n=this._bindposes[t];e+=n.m00.toPrecision(2)+" "+n.m01.toPrecision(2)+" "+n.m02.toPrecision(2)+" "+n.m03.toPrecision(2)+" "+n.m04.toPrecision(2)+" "+n.m05.toPrecision(2)+" "+n.m06.toPrecision(2)+" "+n.m07.toPrecision(2)+" "+n.m08.toPrecision(2)+" "+n.m09.toPrecision(2)+" "+n.m10.toPrecision(2)+" "+n.m11.toPrecision(2)+" "+n.m12.toPrecision(2)+" "+n.m13.toPrecision(2)+" "+n.m14.toPrecision(2)+" "+n.m15.toPrecision(2)+"\n"}this._hash=Vs(e,666)}return this._hash}}]),t}(I_),nF=J((tF=aF).prototype,"_joints",[JL],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),iF=J(tF.prototype,"_bindposes",[$L],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),rF=J(tF.prototype,"_hash",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),eF=tF))||eF));i.Skeleton=NF,oe(uF.prototype,"MeshRenderer.prototype",[{name:"enableDynamicBatching"},{name:"recieveShadows"}]),i.ModelComponent=uF,st.setClassAlias(uF,"cc.ModelComponent");var DF,BF,LF,FF,zF,UF,GF,kF,HF,VF,WF,jF,qF,XF,YF,KF,ZF,QF,JF,$F,ez,tz,nz,iz,rz,az,sz,oz,cz,lz,uz,hz,_z,fz,dz,pz,mz,gz,vz,yz,Sz,Ez,Tz,Az,xz,Cz,Rz,bz,wz=ct({LUMINOUS_POWER:0,LUMINANCE:1}),Iz=new bn,Oz=ih("cc.StaticLightSettings")((vF=function(){function e(){Q(this,"_baked",dF,this),Q(this,"_editorOnly",pF,this),Q(this,"_bakeable",mF,this),Q(this,"_castShadow",gF,this)}return j(e,[{key:"editorOnly",get:function(){return this._editorOnly},set:function(e){this._editorOnly=e}},{key:"baked",get:function(){return this._baked},set:function(e){this._baked=e}},{key:"bakeable",get:function(){return this._bakeable},set:function(e){this._bakeable=e}},{key:"castShadow",get:function(){return this._castShadow},set:function(e){this._castShadow=e}}]),e}(),dF=J((fF=vF).prototype,"_baked",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),pF=J(fF.prototype,"_editorOnly",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),mF=J(fF.prototype,"_bakeable",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),gF=J(fF.prototype,"_castShadow",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),J(fF.prototype,"editorOnly",[gh],Object.getOwnPropertyDescriptor(fF.prototype,"editorOnly"),fF.prototype),J(fF.prototype,"bakeable",[gh],Object.getOwnPropertyDescriptor(fF.prototype,"bakeable"),fF.prototype),J(fF.prototype,"castShadow",[gh],Object.getOwnPropertyDescriptor(fF.prototype,"castShadow"),fF.prototype),_F=fF))||_F,Pz=function(t){return e({Light:t,LightComponent:t}),t}((yF=ih("cc.Light"),SF=Sh(),EF=Sh(),TF=Eh(),AF=Sh(),xF=Dh(Oz),yF((MF=PF=function(e){function t(){var t;return Q(t=e.call(this)||this,"_color",bF,Y(t)),Q(t,"_useColorTemperature",wF,Y(t)),Q(t,"_colorTemperature",IF,Y(t)),Q(t,"_staticSettings",OF,Y(t)),t._type=ep.UNKNOWN,t._lightType=void 0,t._light=null,t._lightType=rp,t}X(t,e),j(t,[{key:"color",get:function(){return this._color},set:function(e){this._color=e,this._light&&(Iz.x=e.r/255,Iz.y=e.g/255,Iz.z=e.b/255,this._light.color=Iz)}},{key:"useColorTemperature",get:function(){return this._useColorTemperature},set:function(e){this._useColorTemperature=e,this._light&&(this._light.useColorTemperature=e)}},{key:"colorTemperature",get:function(){return this._colorTemperature},set:function(e){this._colorTemperature=e,this._light&&(this._light.colorTemperature=e)}},{key:"staticSettings",get:function(){return this._staticSettings},set:function(e){this._staticSettings=e}},{key:"type",get:function(){return this._type}},{key:"baked",get:function(){return this.staticSettings.baked},set:function(e){this.staticSettings.baked=e,null!==this._light&&(this._light.baked=e)}}]);var n=t.prototype;return n.onLoad=function(){this._createLight()},n.onEnable=function(){this._attachToScene()},n.onDisable=function(){this._detachFromScene()},n.onDestroy=function(){this._destroyLight()},n._createLight=function(){this._light||(this._light=i.director.root.createLight(this._lightType)),this.color=this._color,this.useColorTemperature=this._useColorTemperature,this.colorTemperature=this._colorTemperature,this._light.node=this.node,this._light.baked=this.baked},n._destroyLight=function(){this._light&&(i.director.root.destroyLight(this),this._light=null)},n._attachToScene=function(){if(this._detachFromScene(),this._light&&!this._light.scene&&this.node.scene){var e=this._getRenderScene();switch(this._type){case ep.DIRECTIONAL:e.addDirectionalLight(this._light),e.setMainLight(this._light);break;case ep.SPHERE:e.addSphereLight(this._light);break;case ep.SPOT:e.addSpotLight(this._light)}}},n._detachFromScene=function(){if(this._light&&this._light.scene){var e=this._light.scene;switch(this._type){case ep.DIRECTIONAL:e.removeDirectionalLight(this._light),e.unsetMainLight(this._light);break;case ep.SPHERE:e.removeSphereLight(this._light);break;case ep.SPOT:e.removeSpotLight(this._light)}}},t}(Kf),PF.Type=ep,PF.PhotometricTerm=wz,bF=J((RF=MF).prototype,"_color",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Cn.WHITE.clone()}}),wF=J(RF.prototype,"_useColorTemperature",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),IF=J(RF.prototype,"_colorTemperature",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 6550}}),OF=J(RF.prototype,"_staticSettings",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Oz}}),J(RF.prototype,"color",[SF],Object.getOwnPropertyDescriptor(RF.prototype,"color"),RF.prototype),J(RF.prototype,"useColorTemperature",[EF],Object.getOwnPropertyDescriptor(RF.prototype,"useColorTemperature"),RF.prototype),J(RF.prototype,"colorTemperature",[Ch,TF,AF],Object.getOwnPropertyDescriptor(RF.prototype,"colorTemperature"),RF.prototype),J(RF.prototype,"staticSettings",[xF],Object.getOwnPropertyDescriptor(RF.prototype,"staticSettings"),RF.prototype),CF=RF))||CF)),Mz=function(t){return e({DirectionalLight:t,DirectionalLightComponent:t}),t}((DF=ih("cc.DirectionalLight"),BF=mh(),LF=_h(),FF=bh(),zF=Sh(),DF(UF=BF(UF=LF(UF=hh((HF=function(e){function t(){var t;return Q(t=e.call(this)||this,"_illuminance",kF,Y(t)),t._type=ep.DIRECTIONAL,t._light=null,t._lightType=op,t}return X(t,e),j(t,[{key:"illuminance",get:function(){return this._illuminance},set:function(e){this._illuminance=e,this._light&&(this._light.illuminance=this._illuminance)}}]),t.prototype._createLight=function(){e.prototype._createLight.call(this),this._light&&(this.illuminance=this._illuminance)},t}(Pz),kF=J((GF=HF).prototype,"_illuminance",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 65e3}}),J(GF.prototype,"illuminance",[FF,zF],Object.getOwnPropertyDescriptor(GF.prototype,"illuminance"),GF.prototype),UF=GF))||UF)||UF)||UF)||UF)),Nz=function(t){return e({SphereLight:t,SphereLightComponent:t}),t}((VF=ih("cc.SphereLight"),WF=mh(),jF=_h(),qF=bh(),XF=Sh(),YF=bh(),KF=Sh(),ZF=Dh(wz),QF=Sh(),JF=Sh(),$F=Sh(),VF(ez=WF(ez=jF(ez=hh((sz=function(e){function t(){var t;return Q(t=e.call(this)||this,"_size",nz,Y(t)),Q(t,"_luminance",iz,Y(t)),Q(t,"_term",rz,Y(t)),Q(t,"_range",az,Y(t)),t._type=ep.SPHERE,t._light=null,t._lightType=_m,t}return X(t,e),j(t,[{key:"luminousPower",get:function(){return this._luminance*ip(this._size)},set:function(e){this._luminance=e/ip(this._size),this._light&&(this._light.luminance=this._luminance)}},{key:"luminance",get:function(){return this._luminance},set:function(e){this._luminance=e,this._light&&(this._light.luminance=e)}},{key:"term",get:function(){return this._term},set:function(e){this._term=e}},{key:"size",get:function(){return this._size},set:function(e){this._size=e,this._light&&(this._light.size=e)}},{key:"range",get:function(){return this._range},set:function(e){this._range=e,this._light&&(this._light.range=e)}}]),t.prototype._createLight=function(){e.prototype._createLight.call(this),this._light&&(this.luminance=this._luminance,this.size=this._size,this.range=this._range)},t}(Pz),nz=J((tz=sz).prototype,"_size",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.15}}),iz=J(tz.prototype,"_luminance",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1700/ip(.15)}}),rz=J(tz.prototype,"_term",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return wz.LUMINOUS_POWER}}),az=J(tz.prototype,"_range",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),J(tz.prototype,"luminousPower",[qF,XF],Object.getOwnPropertyDescriptor(tz.prototype,"luminousPower"),tz.prototype),J(tz.prototype,"luminance",[YF,KF],Object.getOwnPropertyDescriptor(tz.prototype,"luminance"),tz.prototype),J(tz.prototype,"term",[ZF,QF],Object.getOwnPropertyDescriptor(tz.prototype,"term"),tz.prototype),J(tz.prototype,"size",[JF],Object.getOwnPropertyDescriptor(tz.prototype,"size"),tz.prototype),J(tz.prototype,"range",[$F],Object.getOwnPropertyDescriptor(tz.prototype,"range"),tz.prototype),ez=tz))||ez)||ez)||ez)||ez)),Dz=function(t){return e({SpotLight:t,SpotLightComponent:t}),t}((oz=ih("cc.SpotLight"),cz=mh(),lz=_h(),uz=bh(),hz=Sh(),_z=bh(),fz=Sh(),dz=Dh(wz),pz=Sh(),mz=Sh(),gz=Sh(),vz=Eh(),yz=Sh(),oz(Sz=cz(Sz=lz(Sz=hh((bz=function(e){function t(){var t;return Q(t=e.call(this)||this,"_size",Tz,Y(t)),Q(t,"_luminance",Az,Y(t)),Q(t,"_term",xz,Y(t)),Q(t,"_range",Cz,Y(t)),Q(t,"_spotAngle",Rz,Y(t)),t._type=ep.SPOT,t._light=null,t._lightType=ym,t}return X(t,e),j(t,[{key:"luminousPower",get:function(){return this._luminance*ip(this._size)},set:function(e){this._luminance=e/ip(this._size),this._light&&(this._light.luminance=this._luminance)}},{key:"luminance",get:function(){return this._luminance},set:function(e){this._luminance=e,this._light&&(this._light.luminance=e)}},{key:"term",get:function(){return this._term},set:function(e){this._term=e}},{key:"size",get:function(){return this._size},set:function(e){this._size=e,this._light&&(this._light.size=e)}},{key:"range",get:function(){return this._range},set:function(e){this._range=e,this._light&&(this._light.range=e)}},{key:"spotAngle",get:function(){return this._spotAngle},set:function(e){this._spotAngle=e,this._light&&(this._light.spotAngle=hn(e))}}]),t.prototype._createLight=function(){e.prototype._createLight.call(this),this._light&&(this.luminance=this._luminance,this.size=this._size,this.range=this._range,this.spotAngle=this._spotAngle)},t}(Pz),Tz=J((Ez=bz).prototype,"_size",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.15}}),Az=J(Ez.prototype,"_luminance",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1700/ip(.15)}}),xz=J(Ez.prototype,"_term",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return wz.LUMINOUS_POWER}}),Cz=J(Ez.prototype,"_range",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),Rz=J(Ez.prototype,"_spotAngle",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 60}}),J(Ez.prototype,"luminousPower",[uz,hz],Object.getOwnPropertyDescriptor(Ez.prototype,"luminousPower"),Ez.prototype),J(Ez.prototype,"luminance",[_z,fz],Object.getOwnPropertyDescriptor(Ez.prototype,"luminance"),Ez.prototype),J(Ez.prototype,"term",[dz,pz],Object.getOwnPropertyDescriptor(Ez.prototype,"term"),Ez.prototype),J(Ez.prototype,"size",[mz],Object.getOwnPropertyDescriptor(Ez.prototype,"size"),Ez.prototype),J(Ez.prototype,"range",[gz],Object.getOwnPropertyDescriptor(Ez.prototype,"range"),Ez.prototype),J(Ez.prototype,"spotAngle",[Ch,vz,yz],Object.getOwnPropertyDescriptor(Ez.prototype,"spotAngle"),Ez.prototype),Sz=Ez))||Sz)||Sz)||Sz)||Sz));i.LightComponent=Pz,st.setClassAlias(Pz,"cc.LightComponent"),i.DirectionalLightComponent=Mz,st.setClassAlias(Mz,"cc.DirectionalLightComponent"),i.SphereLightComponent=Nz,st.setClassAlias(Nz,"cc.SphereLightComponent"),i.SpotLightComponent=Dz,st.setClassAlias(Dz,"cc.SpotLightComponent");var Bz=function(e,t,n){e[t+0]=n.m00,e[t+1]=n.m01,e[t+2]=n.m02,e[t+3]=n.m12,e[t+4]=n.m04,e[t+5]=n.m05,e[t+6]=n.m06,e[t+7]=n.m13,e[t+8]=n.m08,e[t+9]=n.m09,e[t+10]=n.m10,e[t+11]=n.m14};function Lz(e,t){var n=4/Math.sqrt(t);return 12*Math.ceil(Math.max(480*n,e)/12)}new Dn,new Dn,new bn,new Dn,new bn;var Fz=j_([Ja.POINT,Ja.POINT,Ja.NONE,$a.CLAMP,$a.CLAMP,$a.CLAMP]),zz=new bn,Uz=new bn,Gz=new bn,kz=new bn,Hz=new Hn,Vz=new Hn,Wz=new al,jz=Number.MAX_SAFE_INTEGER,qz=function(){function e(e){this._device=void 0,this._pool=void 0,this._textureBuffers=new Map,this._formatSize=void 0,this._pixelsPerJoint=void 0,this._customPool=void 0,this._chunkIdxMap=new Map,this._device=e;var t=function(e){return e.hasFeature(vs.TEXTURE_FLOAT)?za.RGBA32F:za.RGBA8}(this._device);this._formatSize=Ts[t].size,this._pixelsPerJoint=48/this._formatSize,this._pool=new Am(e),this._pool.initialize({format:t,roundUpFn:Lz}),this._customPool=new Am(e),this._customPool.initialize({format:t,roundUpFn:Lz})}j(e,[{key:"pixelsPerJoint",get:function(){return this._pixelsPerJoint}}]);var t=e.prototype;return t.clear=function(){this._pool.destroy(),this._textureBuffers.clear()},t.registerCustomTextureLayouts=function(e){for(var t=0;t<e.length;t++)for(var n=e[t],i=this._customPool.createChunk(n.textureLength),r=0;r<n.contents.length;r++){var a=n.contents[r],s=a.skeleton;this._chunkIdxMap.set(s,i);for(var o=0;o<a.clips.length;o++){var c=a.clips[o];this._chunkIdxMap.set(s^c,i)}}},t.getDefaultPoseTexture=function(e,t,n){var i=0^e.hash,r=this._textureBuffers.get(i)||null;if(r&&r.bounds.has(t.hash))return r.refCount++,r;var a=e.joints,s=e.bindposes,o=null,c=!1,l=a.length;if(r)r.refCount++;else{var u=12*l,h=this._chunkIdxMap.get(i),_=void 0!==h?this._customPool.alloc(u*Float32Array.BYTES_PER_ELEMENT,h):this._pool.alloc(u*Float32Array.BYTES_PER_ELEMENT);if(!_)return r;r={pixelOffset:_.start/this._formatSize,refCount:1,bounds:new Map,skeletonHash:e.hash,clipHash:0,readyToBeDeleted:!1,handle:_},o=new Float32Array(u),c=!0}bn.set(Gz,jz,jz,jz),bn.set(kz,-jz,-jz,-jz);for(var f=t.getBoneSpaceBounds(e),d=0,p=0;d<l;d++,p+=12){var m=n.getChildByPath(a[d]),g=m?HN(m,n,Hz):e.inverseBindposes[d],v=f[d];v&&(al.transform(Wz,v,g),Wz.getBoundary(zz,Uz),bn.min(Gz,Gz,zz),bn.max(kz,kz,Uz)),c&&(m&&Hn.multiply(g,g,s[d]),Bz(o,p,m?g:Hn.IDENTITY))}var y=[new al];return r.bounds.set(t.hash,y),al.fromPoints(y[0],Gz,kz),c&&(this._pool.update(r.handle,o.buffer),this._textureBuffers.set(i,r)),r},t.getSequencePoseTexture=function(e,t,n,i){var r=e.hash^t.hash,a=this._textureBuffers.get(r)||null;if(a&&a.bounds.has(n.hash))return a.refCount++,a;var s=e.joints,o=e.bindposes,c=jM.getOrExtract(t).info.frames,l=null,u=!1,h=s.length;if(a)a.refCount++;else{var _=12*h*c,f=this._chunkIdxMap.get(r),d=void 0!==f?this._customPool.alloc(_*Float32Array.BYTES_PER_ELEMENT,f):this._pool.alloc(_*Float32Array.BYTES_PER_ELEMENT);if(!d)return null;var p=this._createAnimInfos(e,t,i);a={pixelOffset:d.start/this._formatSize,refCount:1,bounds:new Map,skeletonHash:e.hash,clipHash:t.hash,readyToBeDeleted:!1,handle:d,animInfos:p},l=new Float32Array(_),u=!0}var m=n.getBoneSpaceBounds(e),g=[];a.bounds.set(n.hash,g);for(var v=0;v<c;v++)g.push(new al(jz,jz,jz,-jz,-jz,-jz));for(var y=0,S=0;y<c;y++){for(var E=g[y],T=0;T<h;T++,S+=12){var A=a.animInfos[T],x=A.curveData,C=A.downstream,R=A.bindposeIdx,b=A.bindposeCorrection,w=void 0,I=!0;x&&C?w=Hn.multiply(Hz,x[y],C):x?w=x[y]:C?w=C:(w=e.inverseBindposes[R],I=!1);var O=m[T];if(O){var P=b?Hn.multiply(Vz,w,b):w;al.transform(Wz,O,P),Wz.getBoundary(zz,Uz),bn.min(E.center,E.center,zz),bn.max(E.halfExtents,E.halfExtents,Uz)}u&&(I&&Hn.multiply(Hz,w,o[R]),Bz(l,S,I?Hz:Hn.IDENTITY))}al.fromPoints(E,E.center,E.halfExtents)}return u&&(this._pool.update(a.handle,l.buffer),this._textureBuffers.set(r,a)),a},t.releaseHandle=function(e){if(e.refCount>0&&e.refCount--,!e.refCount&&e.readyToBeDeleted){var t=e.skeletonHash^e.clipHash;(void 0!==this._chunkIdxMap.get(t)?this._customPool:this._pool).free(e.handle),this._textureBuffers.get(t)===e&&this._textureBuffers.delete(t)}},t.releaseSkeleton=function(e){for(var t=this._textureBuffers.values(),n=t.next();!n.done;){var i=n.value;i.skeletonHash===e.hash&&(i.readyToBeDeleted=!0,i.refCount?this._textureBuffers.delete(i.skeletonHash^i.clipHash):this.releaseHandle(i)),n=t.next()}},t.releaseAnimationClip=function(e){for(var t=this._textureBuffers.values(),n=t.next();!n.done;){var i=n.value;i.clipHash===e.hash&&(i.readyToBeDeleted=!0,i.refCount?this._textureBuffers.delete(i.skeletonHash^i.clipHash):this.releaseHandle(i)),n=t.next()}},t._createAnimInfos=function(e,t,n){for(var i=[],r=e.joints,a=e.bindposes,s=r.length,o=jM.getOrExtract(t),c=0;c<s;c++){for(var l=r[c],u=o.data[l],h=n.getChildByPath(l),_=void 0,f=void 0;!u;){var d=l.lastIndexOf("/");if(l=l.substring(0,d),u=o.data[l],h?(_||(_=new Hn),Hn.fromRTS(Hz,h.rotation,h.position,h.scale),Hn.multiply(_,Hz,_),h=h.parent):f=l,d<0)break}var p=c,m=void 0;if(void 0!==f&&u){p=c-1;for(var g=0;g<s;g++)if(r[g]===f){p=g,m=new Hn,Hn.multiply(m,a[g],e.inverseBindposes[c]);break}}i.push({curveData:u&&u.worldMatrix.values,downstream:_,bindposeIdx:p,bindposeCorrection:m})}return i},e}(),Xz=function(){function e(e){this._pool=new Map,this._device=void 0,this._device=e}var t=e.prototype;return t.getData=function(e){void 0===e&&(e="-1");var t=this._pool.get(e);if(t)return t;var n=this._device.createBuffer(new Ps(Ua.UNIFORM|Ua.TRANSFER_DST,Ga.HOST|Ga.DEVICE,lu.SIZE,lu.SIZE)),i=new Float32Array([0,0,0,0]);n.update(i);var r={buffer:n,data:i,dirty:!1};return this._pool.set(e,r),r},t.destroy=function(e){var t=this._pool.get(e);t&&(t.buffer.destroy(),this._pool.delete(e))},t.switchClip=function(e){return e.data[0]=0,e.buffer.update(e.data),e.dirty=!1,e},t.clear=function(){for(var e,t=Z(this._pool.values());!(e=t()).done;)e.value.buffer.destroy();this._pool.clear()},e}(),Yz=function(){function e(e){this.jointTexturePool=void 0,this.jointAnimationInfo=void 0,this.jointTexturePool=new qz(e),this.jointAnimationInfo=new Xz(e)}var t=e.prototype;return t.releaseSkeleton=function(e){this.jointTexturePool.releaseSkeleton(e)},t.releaseAnimationClip=function(e){this.jointTexturePool.releaseAnimationClip(e)},t.clear=function(){this.jointTexturePool.clear(),this.jointAnimationInfo.clear()},e}();i.internal.DataPoolManager=Yz;var Kz=[{name:"CC_USE_SKINNING",value:!0}];function Zz(e,t,n,i){for(var r=0;r<n.length;r++){for(var a=n[r],s=-1,o=0;o<a.length;o++)if(a[o]===i){s=o;break}s>=0&&(t.push(r),e.push(s))}}var Qz,Jz,$z,eU,tU,nU,iU,rU,aU,sU,oU,cU,lU,uU,hU,_U,fU,dU,pU,mU,gU,vU,yU,SU,EU,TU,AU,xU,CU,RU,bU,wU,IU,OU,PU,MU,NU,DU,BU,LU,FU,zU,UU,GU,kU,HU=new bn,VU=new bn,WU=new bn,jU=new bn,qU=new Hn,XU=new al,YU=function(e){function t(){var t;return(t=e.call(this)||this).uploadAnimation=null,t._buffers=[],t._dataArray=[],t._joints=[],t._bufferIndices=null,t.type=hp.SKINNING,t}X(t,e);var n=t.prototype;return n.destroy=function(){if(this.bindSkeleton(),this._buffers.length){for(var t=0;t<this._buffers.length;t++)this._buffers[t].destroy();this._buffers.length=0}e.prototype.destroy.call(this)},n.bindSkeleton=function(e,t,n){void 0===e&&(e=null),void 0===t&&(t=null),void 0===n&&(n=null);for(var i=0;i<this._joints.length;i++)BN(this._joints[i].target);if(this._bufferIndices=null,this._joints.length=0,e&&t&&n){this.transform=t;var r=n.getBoneSpaceBounds(e),a=n.struct.jointMaps;this._ensureEnoughBuffers(a&&a.length||1),this._bufferIndices=n.jointBufferIndices;for(var s=0;s<e.joints.length;s++){var o=r[s],c=t.getChildByPath(e.joints[s]);if(o&&c){var l=DN(c,t),u=e.bindposes[s],h=[],_=[];a?Zz(h,_,a,s):(h.push(s),_.push(0)),this._joints.push({indices:h,buffers:_,bound:o,target:c,bindpose:u,transform:l})}}}},n.updateTransform=function(e){var t=this.transform;(t.hasChangedFlags||t._dirtyFlags)&&(t.updateWorldTransform(),this._transformUpdated=!0),bn.set(HU,1/0,1/0,1/0),bn.set(VU,-1/0,-1/0,-1/0);for(var n=0;n<this._joints.length;n++){var i=this._joints[n],r=i.bound,a=NN(i.transform,e);al.transform(XU,r,a),XU.getBoundary(WU,jU),bn.min(HU,HU,WU),bn.max(VU,VU,jU)}var s=this._worldBounds;this._modelBounds&&s&&(al.fromPoints(this._modelBounds,HU,VU),this._modelBounds.transform(t._mat,t._pos,t._rot,t._scale,this._worldBounds),_r.setVec3(this._hWorldBounds,or.CENTER,s.center),_r.setVec3(this._hWorldBounds,or.HALF_EXTENSION,s.halfExtents))},n.updateUBOs=function(t){e.prototype.updateUBOs.call(this,t);for(var n=0;n<this._joints.length;n++){var i=this._joints[n],r=i.indices,a=i.buffers,s=i.transform,o=i.bindpose;Hn.multiply(qU,s.world,o);for(var c=0;c<a.length;c++)Bz(this._dataArray[a[c]],12*r[c],qU)}for(var l=0;l<this._buffers.length;l++)this._buffers[l].update(this._dataArray[l]);return!0},n.initSubModel=function(t,n,i){var r=n.vertexBuffers,a=n.iaInfo;a.vertexBuffers=n.jointMappedBuffers,e.prototype.initSubModel.call(this,t,n,i),a.vertexBuffers=r},n.getMacroPatches=function(t){var n=e.prototype.getMacroPatches.call(this,t);return n?Kz.concat(n):Kz},n._updateLocalDescriptors=function(t,n){e.prototype._updateLocalDescriptors.call(this,t,n);var i=this._buffers[this._bufferIndices[t]];i&&n.bindBuffer(uu.BINDING,i)},n._ensureEnoughBuffers=function(e){for(var t=0;t<e;t++)this._buffers[t]||(this._buffers[t]=this._device.createBuffer(new Ps(Ua.UNIFORM|Ua.TRANSFER_DST,Ga.HOST|Ga.DEVICE,uu.SIZE,uu.SIZE))),this._dataArray[t]||(this._dataArray[t]=new Float32Array(uu.COUNT))},t}(sF),KU=[{name:"CC_USE_SKINNING",value:!0},{name:"CC_USE_BAKED_ANIMATION",value:!0}],ZU=function(e){function t(){var t;(t=e.call(this)||this).uploadedAnim=void 0,t._jointsMedium=void 0,t._skeleton=null,t._mesh=null,t._dataPoolManager=void 0,t._instAnimInfoIdx=-1,t.type=hp.BAKED_SKINNING,t._dataPoolManager=i.director.root.dataPoolManager;var n=new Float32Array(4),r=t._dataPoolManager.jointAnimationInfo.getData();return t._jointsMedium={buffer:null,jointTextureInfo:n,animInfo:r,texture:null,boundsInfo:null},t}X(t,e);var n=t.prototype;return n.destroy=function(){this.uploadedAnim=void 0,this._jointsMedium.boundsInfo=null,this._jointsMedium.buffer&&(this._jointsMedium.buffer.destroy(),this._jointsMedium.buffer=null),this._applyJointTexture(),e.prototype.destroy.call(this)},n.bindSkeleton=function(e,t,n){if(void 0===e&&(e=null),void 0===t&&(t=null),void 0===n&&(n=null),this._skeleton=e,this._mesh=n,e&&t&&n){this.transform=t;var i=this._dataPoolManager;this._jointsMedium.animInfo=i.jointAnimationInfo.getData(t.uuid),this._jointsMedium.buffer||(this._jointsMedium.buffer=this._device.createBuffer(new Ps(Ua.UNIFORM|Ua.TRANSFER_DST,Ga.HOST|Ga.DEVICE,cu.SIZE,cu.SIZE)))}},n.updateTransform=function(t){if(e.prototype.updateTransform.call(this,t),this.uploadedAnim){var n=this._jointsMedium,i=n.animInfo,r=n.boundsInfo[i.data[0]],a=this._worldBounds;if(a&&r){var s=this.transform;r.transform(s._mat,s._pos,s._rot,s._scale,a),_r.setVec3(this._hWorldBounds,or.CENTER,a.center),_r.setVec3(this._hWorldBounds,or.HALF_EXTENSION,a.halfExtents)}}},n.updateUBOs=function(t){e.prototype.updateUBOs.call(this,t);var n=this._jointsMedium.animInfo,i=this._instAnimInfoIdx;return i>=0?this.instancedAttributes.views[i][0]=n.data[0]:n.dirty&&(n.buffer.update(n.data),n.dirty=!1),!0},n.uploadAnimation=function(e){if(this._skeleton&&this._mesh&&this.uploadedAnim!==e){this.uploadedAnim=e;var t=this._dataPoolManager,n=null;e?(n=t.jointTexturePool.getSequencePoseTexture(this._skeleton,e,this._mesh,this.transform),this._jointsMedium.boundsInfo=n&&n.bounds.get(this._mesh.hash),this._modelBounds=null):(n=t.jointTexturePool.getDefaultPoseTexture(this._skeleton,this._mesh,this.transform),this._jointsMedium.boundsInfo=null,this._modelBounds=n&&n.bounds.get(this._mesh.hash)[0]),this._applyJointTexture(n)}},n._applyJointTexture=function(e){void 0===e&&(e=null);var t=this._jointsMedium.texture;if(t&&t!==e&&this._dataPoolManager.jointTexturePool.releaseHandle(t),this._jointsMedium.texture=e,e){var n=this._jointsMedium,i=n.buffer,r=n.jointTextureInfo;r[0]=e.handle.texture.width,r[1]=this._skeleton.joints.length,r[2]=e.pixelOffset+.1,r[3]=1/r[0],this.updateInstancedJointTextureInfo(),i&&i.update(r);for(var a=e.handle.texture,s=0;s<this._subModels.length;++s)this._subModels[s].descriptorSet.bindTexture(_u,a)}},n.getMacroPatches=function(t){var n=e.prototype.getMacroPatches.call(this,t);return n?n.concat(KU):KU},n._updateLocalDescriptors=function(t,n){e.prototype._updateLocalDescriptors.call(this,t,n);var i=this._jointsMedium,r=i.buffer,a=i.texture,s=i.animInfo;if(n.bindBuffer(cu.BINDING,r),n.bindBuffer(lu.BINDING,s.buffer),a){var o=af.getSampler(this._device,Fz);n.bindTexture(_u,a.handle.texture),n.bindSampler(_u,o)}},n._updateInstancedAttributes=function(t,n){e.prototype._updateInstancedAttributes.call(this,t,n),this._instAnimInfoIdx=this._getInstancedAttributeIndex("a_jointAnimInfo"),this.updateInstancedJointTextureInfo()},n.updateInstancedJointTextureInfo=function(){var e=this._jointsMedium,t=e.jointTextureInfo,n=e.animInfo,i=this._instAnimInfoIdx;if(i>=0){var r=this.instancedAttributes.views[i];r[0]=n.data[0],r[1]=t[1],r[2]=t[2]}},t}(sF),QU=function(t){return e({SkinnedMeshRenderer:t,SkinningModelComponent:t}),t}((Qz=ih("cc.SkinnedMeshRenderer"),Jz=mh(),$z=ah(100),eU=_h(),tU=Dh(NF),nU=Dh(RC),iU=Dh(NF),rU=Dh(RC),aU=Sh(),Qz(sU=Jz(sU=$z(sU=hh(sU=eU((uU=function(e){function t(){var t;return Q(t=e.call(this)||this,"_skeleton",cU,Y(t)),Q(t,"_skinningRoot",lU,Y(t)),t._clip=null,t._modelType=ZU,t}X(t,e),j(t,[{key:"skeleton",get:function(){return this._skeleton},set:function(e){e!==this._skeleton&&(this._skeleton=e,this._update())}},{key:"skinningRoot",get:function(){return this._skinningRoot},set:function(e){e!==this._skinningRoot&&(this._skinningRoot=e,this._updateModelType(),this._update())}},{key:"model",get:function(){return this._model}}]);var n=t.prototype;return n.__preload=function(){this._updateModelType()},n.uploadAnimation=function(e){this._clip=e,this.model&&this.model.uploadAnimation&&this.model.uploadAnimation(e)},n.setUseBakedAnimation=function(e){void 0===e&&(e=!0);var t=e?ZU:YU;this._modelType!==t&&(this._modelType=t,this._model&&(i.director.root.destroyModel(this._model),this._model=null,this._models.length=0,this._updateModels(),this._updateCastShadow(),this.enabledInHierarchy&&this._attachToScene()))},n.setMaterial=function(t,n){e.prototype.setMaterial.call(this,t,n),this._modelType===YU&&this.getMaterialInstance(n)},n._updateModelParams=function(){this._update(),e.prototype._updateModelParams.call(this)},n._updateModelType=function(){if(this._skinningRoot){var e=this._skinningRoot.getComponent("cc.SkeletalAnimation");e&&this.setUseBakedAnimation(e.useBakedAnimation)}},n._update=function(){this.model&&(this.model.bindSkeleton(this._skeleton,this._skinningRoot,this._mesh),this.model.uploadAnimation&&this.model.uploadAnimation(this._clip))},t}(uF),cU=J((oU=uU).prototype,"_skeleton",[tU],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),lU=J(oU.prototype,"_skinningRoot",[nU],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),J(oU.prototype,"skeleton",[iU],Object.getOwnPropertyDescriptor(oU.prototype,"skeleton"),oU.prototype),J(oU.prototype,"skinningRoot",[rU,aU],Object.getOwnPropertyDescriptor(oU.prototype,"skinningRoot"),oU.prototype),sU=oU))||sU)||sU)||sU)||sU)||sU)),JU=new Ws(La.ATTR_BATCH_ID,za.R32F),$U=new Ws(La.ATTR_BATCH_UV,za.RG32F),eG=Ts[JU.format].size+Ts[$U.format].size,tG=function(t){return e({SkinnedMeshUnit:t,SkinningModelUnit:t}),t}((hU=ih("cc.SkinnedMeshUnit"),_U=Dh(uL),fU=Dh(NF),dU=Dh(em),pU=Dh(QU),hU((xU=function(){function e(){Q(this,"mesh",vU,this),Q(this,"skeleton",yU,this),Q(this,"material",SU,this),Q(this,"_localTransform",EU,this),Q(this,"_offset",TU,this),Q(this,"_size",AU,this)}return j(e,[{key:"offset",set:function(e){qn.copy(this._offset,e)},get:function(){return this._offset}},{key:"size",set:function(e){qn.copy(this._size,e)},get:function(){return this._size}},{key:"copyFrom",set:function(e){e&&(this.mesh=e.mesh,this.skeleton=e.skeleton,this.material=e.getMaterial(0),e.skinningRoot&&HN(e.node,e.skinningRoot,this._localTransform))},get:function(){return null}}]),e}(),vU=J((gU=xU).prototype,"mesh",[_U],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),yU=J(gU.prototype,"skeleton",[fU],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),SU=J(gU.prototype,"material",[dU],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),EU=J(gU.prototype,"_localTransform",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Hn}}),TU=J(gU.prototype,"_offset",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new qn(0,0)}}),AU=J(gU.prototype,"_size",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new qn(1,1)}}),J(gU.prototype,"offset",[gh],Object.getOwnPropertyDescriptor(gU.prototype,"offset"),gU.prototype),J(gU.prototype,"size",[gh],Object.getOwnPropertyDescriptor(gU.prototype,"size"),gU.prototype),J(gU.prototype,"copyFrom",[pU],Object.getOwnPropertyDescriptor(gU.prototype,"copyFrom"),gU.prototype),mU=gU))||mU)),nG=new Hn,iG=(new Hn,new bn),rG=function(t){return e({SkinnedMeshBatchRenderer:t,BatchedSkinningModelComponent:t}),t}((CU=ih("cc.SkinnedMeshBatchRenderer"),RU=mh(),bU=ah(100),wU=_h(),IU=Sh(),OU=Dh([Ft]),PU=Sh(),MU=Dh([tG]),NU=Sh(),DU=vh(),BU=vh(),CU(LU=RU(LU=bU(LU=hh(LU=wU((kU=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return Q(t=e.call.apply(e,[this].concat(i))||this,"atlasSize",zU,Y(t)),Q(t,"batchableTextureNames",UU,Y(t)),Q(t,"units",GU,Y(t)),t._textures={},t._batchMaterial=null,t}X(t,e);var n=t.prototype;return n.onLoad=function(){e.prototype.onLoad.call(this),this.cook()},n.onDestroy=function(){for(var t in this._textures)this._textures[t].destroy();this._textures={},this._mesh&&(this._mesh.destroy(),this._mesh=null),e.prototype.onDestroy.call(this)},n._onMaterialModified=function(t){this.cookMaterials(),e.prototype._onMaterialModified.call(this,t,this.getMaterialInstance(t))},n.cook=function(){this.cookMaterials(),this.cookSkeletons(),this.cookMeshes()},n.cookMaterials=function(){var e=this;this._batchMaterial||(this._batchMaterial=this.getMaterial(0));var t=this.getMaterialInstance(0);if(t&&this._batchMaterial&&this._batchMaterial.effectAsset){t.copy(this._batchMaterial),this.resizeAtlases();for(var n=t.effectAsset.techniques[t.technique],i=function(i){var r=n.passes[i];if(!r.properties)return"continue";var a=function(n){if(r.properties[n].type>=Fa.SAMPLER1D){var a=null;e.batchableTextureNames.find((function(e){return e===n}))?((a=e._textures[n])||(a=e.createTexture(n)),e.cookTextures(a,n,i)):e.units.some((function(e){return a=e.material&&e.material.getProperty(n,i)})),a&&t.setProperty(n,a,i)}else{for(var s=[],o=0;o<e.units.length;o++){var c=e.units[o];c.material&&s.push(c.material.getProperty(n.slice(0,-3),i))}t.setProperty(n,s,i)}};for(var s in r.properties)a(s)},r=0;r<n.passes.length;r++)i(r)}else console.warn("incomplete batch material!")},n.cookSkeletons=function(){if(this._skinningRoot){for(var e=[],t=[],n=0;n<this.units.length;n++){var i=this.units[n];if(i&&i.skeleton){var r=i.skeleton;Hn.invert(nG,i._localTransform);for(var a=function(n){var i=r.joints[n];if(e.findIndex((function(e){return e===i}))>=0)return"continue";e.push(i),t.push(Hn.multiply(new Hn,r.bindposes[n]||Hn.IDENTITY,nG))},s=0;s<r.joints.length;s++)a(s)}}var o=Array.from(Array(e.length).keys()).sort((function(t,n){return e[t]>e[n]?1:e[t]<e[n]?-1:0})),c=new NF;c.joints=e.map((function(e,t,n){return n[o[t]]})),c.bindposes=t.map((function(e,t,n){return n[o[t]]})),this._skeleton&&this._skeleton.destroy(),this.skeleton=c}else console.warn("no skinning root specified!")},n.cookMeshes=function(){for(var e=this,t=!1,n=0;n<this.units.length;n++)if(this.units[n].mesh){t=!0;break}if(t&&this._skinningRoot){this._mesh?this._mesh.destroyRenderingMesh():this._mesh=new uL;for(var i=0,r=za.UNKNOWN,a=0,s=za.UNKNOWN,o=0,c=za.UNKNOWN,l=0,u=za.UNKNOWN,h=0,_=za.UNKNOWN,f=new Array(this.units.length),d=this.units.length,p=0;p<d;p++){var m=this.units[p];m&&m.skeleton&&(f[p]=m.skeleton.joints.map((function(t){return e._skeleton.joints.findIndex((function(e){return t===e}))})))}for(var g=function(t){var n=e.units[t];if(!n||!n.mesh||!n.mesh.data)return"continue";var d=e._createUnitMesh(t,n.mesh),p=new DataView(d.data.buffer);Hn.inverseTranspose(nG,n._localTransform);for(var m=n.offset,g=n.size,v=function(e){var v=d.struct.vertexBundles[e];i=v.view.offset,r=za.UNKNOWN;for(var y=0;y<v.attributes.length;y++){var S=v.attributes[y];if(S.name===La.ATTR_POSITION){r=S.format;break}i+=Ts[S.format].size}if(r){for(var E=Cx(p,r,i,v.view.length,v.view.stride),T=0;T<E.length;T+=3)bn.fromArray(iG,E,T),bn.transformMat4(iG,iG,n._localTransform),bn.toArray(E,iG,T);xx(p,E,r,i,v.view.stride)}a=v.view.offset,s=za.UNKNOWN;for(var A=0;A<v.attributes.length;A++){var x=v.attributes[A];if(x.name===La.ATTR_NORMAL){s=x.format;break}a+=Ts[x.format].size}if(s){for(var C=Cx(p,s,a,v.view.length,v.view.stride),R=0;R<C.length;R+=3)bn.fromArray(iG,C,R),bn.transformMat4Normal(iG,iG,nG),bn.toArray(C,iG,R);xx(p,C,s,a,v.view.stride)}o=v.view.offset,c=za.UNKNOWN;for(var b=0;b<v.attributes.length;b++){var w=v.attributes[b];if(w.name===La.ATTR_TANGENT){c=w.format;break}o+=Ts[w.format].size}if(c){for(var I=Cx(p,c,o,v.view.length,v.view.stride),O=0;O<I.length;O+=3)bn.fromArray(iG,I,O),bn.transformMat4Normal(iG,iG,nG),bn.toArray(I,iG,O);xx(p,I,c,o,v.view.stride)}l=v.view.offset,u=za.UNKNOWN;for(var P=0;P<v.attributes.length;P++){var M=v.attributes[P];if(M.name===La.ATTR_BATCH_UV){u=M.format;break}l+=Ts[M.format].size}u&&Rx(p,(function(e,t){var n,i=0===t?"x":"y";return(e=(n=e)-Math.floor(n))*g[i]+m[i]}),u,l,v.view.length,v.view.stride,p);var N=f[t];if(!N)return"continue";h=v.view.offset,_=za.UNKNOWN;for(var D=0;D<v.attributes.length;D++){var B=v.attributes[D];if(B.name===La.ATTR_JOINTS){_=B.format;break}h+=Ts[B.format].size}_&&Rx(p,(function(e){return N[e]}),_,h,v.view.length,v.view.stride,p)},y=0;y<d.struct.vertexBundles.length;y++)v(y);e._mesh.merge(d)},v=0;v<d;v++)g(v);this._onMeshChanged(this._mesh),this._updateModels()}},n.cookTextures=function(e,t,n){for(var r=[],a=[],s=[],o=[],c=0;c<this.units.length;c++){var l=this.units[c];if(l.material){var u=l.material.getProperty(t,n);if(u&&u.image&&u.image.data){var h=new eo;h.texOffset.x=l.offset.x*this.atlasSize,h.texOffset.y=l.offset.y*this.atlasSize,h.texExtent.width=l.size.x*this.atlasSize,h.texExtent.height=l.size.y*this.atlasSize;var _=u.image.data;ArrayBuffer.isView(_)?(s.push(_),o.push(h)):(r.push(_),a.push(h))}}}var f=e.getGFXTexture(),d=i.director.root.device;s.length>0&&d.copyBuffersToTexture(s,f,o),r.length>0&&d.copyTexImagesToTexture(r,f,a)},n.createTexture=function(e){var t=new md;return t.setFilters(M_.LINEAR,M_.LINEAR),t.setMipFilter(M_.NEAREST),t.reset({width:this.atlasSize,height:this.atlasSize,format:O_.RGBA8888}),t.loaded=!0,this._textures[e]=t,t},n.resizeAtlases=function(){for(var e in this._textures)this._textures[e].reset({width:this.atlasSize,height:this.atlasSize,format:O_.RGBA8888})},n._createUnitMesh=function(e,t){for(var n=JSON.parse(JSON.stringify(t.struct)),r={},a=0;a<t.struct.primitives.length;a++){for(var s=t.struct.primitives[a],o=0,c=za.UNKNOWN,l=0;l<s.vertexBundelIndices.length;l++){var u=t.struct.vertexBundles[s.vertexBundelIndices[l]];o=u.view.offset,c=za.UNKNOWN;for(var h=0;h<u.attributes.length;h++){var _=u.attributes[h];if(_.name===La.ATTR_TEX_COORD){c=_.format;break}o+=Ts[_.format].size}if(c)break}if(void 0===r[l]){r[l]=[c,o];var f=n.vertexBundles[l];f.attributes.push(JU),f.attributes.push($U),f.view.offset=0,f.view.length+=f.view.count*eG,f.view.stride+=eG}}for(var d=0,p=0;p<n.vertexBundles.length;p++)d+=n.vertexBundles[p].view.length;for(var m=0;m<n.primitives.length;m++){var g=n.primitives[m];g.indexView&&(g.indexView.offset=d,d+=g.indexView.length)}var v=new Uint8Array(d),y=t.data,S=new DataView(v.buffer),E=new DataView(y.buffer),T=i.sys.isLittleEndian;for(var A in r)for(var x=n.vertexBundles[A],C=t.struct.vertexBundles[A],R=r[A],b=Cx(E,R[0],R[1],C.view.length,C.view.stride),w=C.view,I=x.view,O=w.stride,P=I.stride,M=w.offset,N=I.offset,D=0;D<I.count;D++){var B=y.subarray(M,M+O);v.set(B,N),S.setFloat32(N+O,e),S.setFloat32(N+O+4,b[2*D],T),S.setFloat32(N+O+8,b[2*D+1],T),N+=P,M+=O}for(var L=0;L<n.primitives.length;L++){var F=t.struct.primitives[L],z=n.primitives[L];if(F.indexView&&z.indexView)for(var U=F.indexView.stride,G=z.indexView.stride,k=F.indexView.offset,H=z.indexView.offset,V=0;V<z.indexView.count;V++){var W=y.subarray(k,k+U);v.set(W,H),H+=G,k+=U}}var j=new uL;return j.reset({struct:n,data:v}),j},j(t,[{key:"mesh",get:function(){return e.prototype.mesh},set:function(e){this.mesh=e}},{key:"skeleton",get:function(){return e.prototype.skeleton},set:function(e){this.skeleton=e}}]),t}(QU),zU=J((FU=kU).prototype,"atlasSize",[ch,IU],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1024}}),UU=J(FU.prototype,"batchableTextureNames",[OU,ch,PU],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),GU=J(FU.prototype,"units",[MU,ch,NU],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),J(FU.prototype,"mesh",[Bh,DU],Object.getOwnPropertyDescriptor(FU.prototype,"mesh"),FU.prototype),J(FU.prototype,"skeleton",[Bh,BU],Object.getOwnPropertyDescriptor(FU.prototype,"skeleton"),FU.prototype),LU=FU))||LU)||LU)||LU)||LU)||LU));i.SkinningModelComponent=QU,st.setClassAlias(QU,"cc.SkinningModelComponent"),i.SkinningModelUnit=tG,st.setClassAlias(tG,"cc.SkinningModelUnit"),i.BatchedSkinningModelComponent=rG,st.setClassAlias(rG,"cc.BatchedSkinningModelComponent");var aG,sG,oG,cG,lG,uG,hG,_G,fG,dG,pG,mG,gG,vG,yG,SG,EG,TG,AG,xG,CG=new Hn,RG=new Hn,bG=[],wG=e("SkeletalAnimationState",function(e){function t(t,n){var r;return void 0===n&&(n=""),(r=e.call(this,t,n)||this)._frames=1,r._bakedDuration=0,r._animInfo=null,r._sockets=[],r._animInfoMgr=void 0,r._comps=[],r._parent=null,r._curvesInited=!1,r._animInfoMgr=i.director.root.dataPoolManager.jointAnimationInfo,r}X(t,e);var n=t.prototype;return n.initialize=function(t){if(!this._curveLoaded){this._comps.length=0;for(var n=t.getComponentsInChildren(QU),i=0;i<n.length;++i){var r=n[i];r.skinningRoot===t&&this._comps.push(r)}this._parent=t.getComponent("cc.SkeletalAnimation");var a=this._parent.useBakedAnimation;e.prototype.initialize.call(this,t,a?bG:void 0),this._curvesInited=!a;var s=jM.getOrExtract(this.clip).info;this._frames=s.frames-1,this._animInfo=this._animInfoMgr.getData(t.uuid),this._bakedDuration=this._frames/s.sample}},n.onPlay=function(){if(e.prototype.onPlay.call(this),this._parent.useBakedAnimation){this._sampleCurves=this._sampleCurvesBaked,this.duration=this._bakedDuration,this._animInfoMgr.switchClip(this._animInfo,this.clip);for(var t=0;t<this._comps.length;++t)this._comps[t].uploadAnimation(this.clip)}else this._sampleCurves=e.prototype._sampleCurves,this.duration=this.clip.duration,this._curvesInited||(this._curveLoaded=!1,e.prototype.initialize.call(this,this._targetNode),this._curvesInited=!0)},n.rebuildSocketCurves=function(e){if(this._sockets.length=0,this._targetNode)for(var t=this._targetNode,n=0;n<e.length;++n){var i=e[n],r=t.getChildByPath(i.path);if(i.target){for(var a=jM.getOrExtract(this.clip),s=i.path,o=a.data[s],c=r,l=void 0;!o;){var u=s.lastIndexOf("/");if(s=s.substring(0,u),o=a.data[s],c&&(l||(l=Hn.identity(RG)),Hn.fromRTS(CG,c.rotation,c.position,c.scale),Hn.multiply(l,CG,l),c=c.parent),u<0)break}for(var h=o&&o.worldMatrix.values,_=a.info.frames,f=[],d=0;d<_;d++){var p;p=h&&l?Hn.multiply(CG,h[d],l):h?h[d]:l||Hn.IDENTITY;var m={pos:new bn,rot:new Dn,scale:new bn};Hn.toRTS(p,m.rot,m.pos,m.scale),f.push(m)}this._sockets.push({target:i.target,frames:f})}}},n._sampleCurvesBaked=function(e){var t=this._animInfo,n=e*this._frames+.5|0;if(n!==t.data[0]){t.data[0]=n,t.dirty=!0;for(var i=0;i<this._sockets.length;++i){var r=this._sockets[i],a=r.target,s=r.frames[n],o=s.pos,c=s.rot,l=s.scale;a.setRTS(c,o,l)}}},t}(sN)),IG=e("Socket",(aG=ih("cc.SkeletalAnimation.Socket"),sG=Dh(RC),aG((lG=J((cG=function(e,t){void 0===e&&(e=""),void 0===t&&(t=null),Q(this,"path",lG,this),Q(this,"target",uG,this),this.path=e,this.target=t}).prototype,"path",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),uG=J(cG.prototype,"target",[sG],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),oG=cG))||oG));st.setClassAlias(IG,"cc.SkeletalAnimationComponent.Socket");var OG=new Hn,PG=new Hn;function MG(e,t,n){void 0===t&&(t=""),void 0===n&&(n=[]);for(var i=0;i<e.children.length;i++){var r=e.children[i];if(r){var a=t?t+"/"+r.name:r.name;n.push(a),MG(r,a,n)}}return n}var NG=function(t){return e({SkeletalAnimation:t,SkeletalAnimationComponent:t}),t}((hG=ih("cc.SkeletalAnimation"),_G=mh(),fG=ah(99),dG=_h(),pG=Dh([IG]),mG=Sh(),gG=Sh(),vG=Dh([IG]),hG(yG=_G(yG=fG(yG=hh(yG=dG((xG=AG=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return Q(t=e.call.apply(e,[this].concat(i))||this,"_useBakedAnimation",EG,Y(t)),Q(t,"_sockets",TG,Y(t)),t}X(t,e);var n=t.prototype;return n.onDestroy=function(){e.prototype.onDestroy.call(this),i.director.root.dataPoolManager.jointAnimationInfo.destroy(this.node.uuid),i.director.getAnimationManager().removeSockets(this.node,this._sockets)},n.start=function(){this.sockets=this._sockets,this.useBakedAnimation=this._useBakedAnimation,e.prototype.start.call(this)},n.querySockets=function(){var e=this._defaultClip&&Object.keys(jM.getOrExtract(this._defaultClip).data).sort().reduce((function(e,t){return t.startsWith(e[e.length-1])||e.push(t),e}),[])||[];if(!e.length)return["please specify a valid default animation clip first"];for(var t=[],n=0;n<e.length;n++){var i=e[n],r=this.node.getChildByPath(i);r&&(t.push(i),MG(r,i,t))}return t},n.rebuildSocketAnimations=function(){for(var e,t=Z(this._sockets);!(e=t()).done;){var n=e.value,i=this.node.getChildByPath(n.path),r=n.target;i&&r&&(r.name=n.path.substring(n.path.lastIndexOf("/")+1)+" Socket",r.parent=this.node,HN(i,this.node,OG),Hn.fromRTS(PG,r.rotation,r.position,r.scale),Hn.equals(PG,OG)||(r.matrix=OG))}for(var a=0,s=Object.keys(this._nameToState);a<s.length;a++){var o=s[a];this._nameToState[o].rebuildSocketCurves(this._sockets)}},n.createSocket=function(e){var t=this._sockets.find((function(t){return t.path===e}));if(t)return t.target;if(!this.node.getChildByPath(e))return console.warn("illegal socket path"),null;var n=new RC;return n.parent=this.node,this._sockets.push(new IG(e,n)),this.rebuildSocketAnimations(),n},n._createState=function(e,t){return new wG(e,t)},n._doCreateState=function(t,n){var i=e.prototype._doCreateState.call(this,t,n);return i.rebuildSocketCurves(this._sockets),i},j(t,[{key:"sockets",get:function(){return this._sockets},set:function(e){if(!this._useBakedAnimation){var t=i.director.getAnimationManager();t.removeSockets(this.node,this._sockets),t.addSockets(this.node,e)}this._sockets=e,this.rebuildSocketAnimations()}},{key:"useBakedAnimation",get:function(){return this._useBakedAnimation},set:function(e){this._useBakedAnimation=e;for(var t=this.node.getComponentsInChildren(QU),n=0;n<t.length;++n){var r=t[n];r.skinningRoot===this.node&&r.setUseBakedAnimation(this._useBakedAnimation)}this._useBakedAnimation?i.director.getAnimationManager().removeSockets(this.node,this._sockets):i.director.getAnimationManager().addSockets(this.node,this._sockets)}}]),t}(RN),AG.Socket=IG,J((SG=xG).prototype,"sockets",[pG,mG],Object.getOwnPropertyDescriptor(SG.prototype,"sockets"),SG.prototype),J(SG.prototype,"useBakedAnimation",[gG],Object.getOwnPropertyDescriptor(SG.prototype,"useBakedAnimation"),SG.prototype),EG=J(SG.prototype,"_useBakedAnimation",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),TG=J(SG.prototype,"_sockets",[vG],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),yG=SG))||yG)||yG)||yG)||yG)||yG));i.SkeletalAnimationComponent=NG,st.setClassAlias(NG,"cc.SkeletalAnimationComponent"),i.utils=yL;var DG=new bn,BG=new Hn;function LG(e,t,n,i){var r=n.data,a=t.acquireBufferBatch(),s=a.byteOffset>>2,o=n.vertexCount,c=a.indicesOffset,l=a.vertexOffset;a.request(o,n.indicesCount)||(a=t.currBufferBatch,o=0,c=0,l=0);var u=a.vData,h=a.iData;e.getWorldMatrix(BG);for(var _=0;_<o;_++){var f=r[_];bn.set(DG,f.x,f.y,0),bn.transformMat4(DG,DG,BG),u[s++]=DG.x,u[s++]=DG.y,u[s++]=DG.z,u[s++]=f.u,u[s++]=f.v,Cn.toArray(u,i,s),s+=4}for(var d=0,p=o/4;d<p;d++){var m=l+4*d;h[c++]=m,h[c++]=m+1,h[c++]=m+2,h[c++]=m+1,h[c++]=m+3,h[c++]=m+2}}var FG=function(){function e(e,t){this._texture=void 0,this._width=void 0,this._height=void 0,this._x=void 0,this._y=void 0,this._nexty=void 0,this._innerTextureInfos={},this._innerSpriteFrames=void 0,this._count=void 0;var n=new zG;n.initWithSize(e,t),this._texture=n,this._width=e,this._height=t,this._x=2,this._y=2,this._nexty=2,this._innerTextureInfos={},this._innerSpriteFrames=[],this._count=0}var t=e.prototype;return t.insertSpriteFrame=function(e){var t=e.rect,n=e.texture,r=this._innerTextureInfos[n.getId()],a=t.x,s=t.y;if(r)a+=r.x,s+=r.y;else{var o=n.width,c=n.height;if(this._x+o+2>this._width&&(this._x=2,this._y=this._nexty),this._y+c+2>this._nexty&&(this._nexty=this._y+c+2),this._nexty>this._height)return null;i.internal.dynamicAtlasManager.textureBleeding&&((o<=8||c<=8)&&(this._texture.drawTextureAt(n.image,this._x-1,this._y-1),this._texture.drawTextureAt(n.image,this._x-1,this._y+1),this._texture.drawTextureAt(n.image,this._x+1,this._y-1),this._texture.drawTextureAt(n.image,this._x+1,this._y+1)),this._texture.drawTextureAt(n.image,this._x-1,this._y),this._texture.drawTextureAt(n.image,this._x+1,this._y),this._texture.drawTextureAt(n.image,this._x,this._y-1),this._texture.drawTextureAt(n.image,this._x,this._y+1)),this._texture.drawTextureAt(n.image,this._x,this._y),this._innerTextureInfos[n.getId()]={x:this._x,y:this._y,texture:n},this._count++,a+=this._x,s+=this._y,this._x+=o+2}var l={x:a,y:s,texture:this._texture};return this._innerSpriteFrames.push(e),l},t.deleteInnerTexture=function(e){e&&this._innerTextureInfos[e.getId()]&&(delete this._innerTextureInfos[e.getId()],this._count--)},t.isEmpty=function(){return this._count<=0},t.reset=function(){this._x=2,this._y=2,this._nexty=2;for(var e=this._innerSpriteFrames,t=0,n=e.length;t<n;t++){var i=e[t];i.isValid&&i._resetDynamicAtlasFrame()}this._innerSpriteFrames.length=0,this._innerTextureInfos={}},t.destroy=function(){this.reset(),this._texture.destroy()},e}(),zG=function(e){function t(){return e.apply(this,arguments)||this}X(t,e);var n=t.prototype;return n.initWithSize=function(e,t,n){void 0===n&&(n=O_.RGBA8888),this.reset({width:e,height:t,format:n}),this.loaded=!0,this.emit("load")},n.drawTextureAt=function(e,t,n){var i=this.getGFXTexture();if(e&&i){var r=this._getGFXDevice();if(r){var a=new eo;a.texOffset.x=t,a.texOffset.y=n,a.texExtent.width=e.width,a.texExtent.height=e.height,r.copyTexImagesToTexture([e.data],i,[a])}else console.warn("Unable to get device")}},t}(md),UG=function(){function e(){this._atlases=[],this._atlasIndex=-1,this._maxAtlasCount=5,this._textureSize=2048,this._maxFrameSize=512,this._textureBleeding=!0,this._enabled=!1}var t=e.prototype;return t.newAtlas=function(){var e=this._atlases[++this._atlasIndex];return e||(e=new FG(this._textureSize,this._textureSize),this._atlases.push(e)),e},t.beforeSceneLoad=function(){this.reset()},t.insertSpriteFrame=function(e){if(!this._enabled||this._atlasIndex===this._maxAtlasCount||!e||e._original)return null;if(!e.packable)return null;var t=this._atlases[this._atlasIndex];t||(t=this.newAtlas());var n=t.insertSpriteFrame(e);return n||this._atlasIndex===this._maxAtlasCount?n:(t=this.newAtlas()).insertSpriteFrame(e)},t.reset=function(){for(var e=0,t=this._atlases.length;e<t;e++)this._atlases[e].destroy();this._atlases.length=0,this._atlasIndex=-1},t.deleteAtlasSpriteFrame=function(e){if(e._original){var t=e._original._texture;this.deleteAtlasTexture(t)}},t.deleteAtlasTexture=function(e){if(e)for(var t=this._atlases.length-1;t>=0;t--)this._atlases[t].deleteInnerTexture(e),this._atlases[t].isEmpty()&&(this._atlases[t].destroy(),this._atlases.splice(t,1),this._atlasIndex--)},t.packToDynamicAtlas=function(e,t){if(!t._original&&t.packable){var n=this.insertSpriteFrame(t);n&&t._setDynamicAtlasFrame(n)}},j(e,[{key:"enabled",get:function(){return this._enabled},set:function(e){this._enabled!==e&&(e?(this.reset(),i.director.on(i.Director.EVENT_BEFORE_SCENE_LAUNCH,this.beforeSceneLoad,this)):i.director.off(i.Director.EVENT_BEFORE_SCENE_LAUNCH,this.beforeSceneLoad,this),this._enabled=e)}},{key:"maxAtlasCount",get:function(){return this._maxAtlasCount},set:function(e){this._maxAtlasCount=e}},{key:"atlasCount",get:function(){return this._atlases.length}},{key:"textureBleeding",get:function(){return this._textureBleeding},set:function(e){this._textureBleeding=e}},{key:"textureSize",get:function(){return this._textureSize},set:function(e){this._textureSize=e}},{key:"maxFrameSize",get:function(){return this._maxFrameSize},set:function(e){this._maxFrameSize=e}}]),e}();UG.instance=void 0;var GG,kG=e("dynamicAtlasManager",UG.instance=new UG);i.internal.dynamicAtlasManager=kG;var HG,VG,WG,jG,qG=[{u:0,v:0},{u:0,v:0},{u:0,v:0},{u:0,v:0}],XG=e("SpriteFrame",ih("cc.SpriteFrame")(GG=function(e){function t(){var t;return(t=e.call(this)||this).vertices=null,t.uv=[],t.uvHash=0,t.unbiasUV=[],t.uvSliced=[],t._rect=new ti,t._offset=new qn,t._originalSize=new $n,t._rotated=!1,t._capInsets=[0,0,0,0],t._atlasUuid="",t._texture=void 0,t._isFlipUVY=!1,t._isFlipUVX=!1,t._original=null,t._packable=!0,t}X(t,e),t.createWithImage=function(e){var n=e instanceof G_?e:new G_(e),i=new md;i.image=n;var r=new t;return r.texture=i,r},j(t,[{key:"insetTop",get:function(){return this._capInsets[1]},set:function(e){this._capInsets[1]!==e&&(this._capInsets[1]=e,this._texture&&this._calculateSlicedUV())}},{key:"insetBottom",get:function(){return this._capInsets[3]},set:function(e){this._capInsets[3]!==e&&(this._capInsets[3]=e,this._texture&&this._calculateSlicedUV())}},{key:"insetLeft",get:function(){return this._capInsets[0]},set:function(e){this._capInsets[0]!==e&&(this._capInsets[0]=e,this._texture&&this._calculateSlicedUV())}},{key:"insetRight",get:function(){return this._capInsets[2]},set:function(e){this._capInsets[2]!==e&&(this._capInsets[2]=e,this._texture&&this._calculateSlicedUV())}},{key:"rect",get:function(){return this._rect},set:function(e){this._rect.equals(e)||(this._rect.set(e),this._texture&&this._calculateUV())}},{key:"originalSize",get:function(){return this._originalSize},set:function(e){this._originalSize.equals(e)||(this._originalSize.set(e),this._texture&&this._calculateUV())}},{key:"offset",get:function(){return this._offset},set:function(e){this._offset.set(e)}},{key:"rotated",get:function(){return this._rotated},set:function(e){this._rotated!==e&&(this._rotated=e,this._texture&&this._calculateUV())}},{key:"texture",get:function(){return this._texture},set:function(e){e?this.reset({texture:e},!0):console.warn("Error Texture in "+this.name)}},{key:"atlasUuid",get:function(){return this._atlasUuid},set:function(e){this._atlasUuid=e}},{key:"width",get:function(){return this._texture.width}},{key:"height",get:function(){return this._texture.height}},{key:"_textureSource",set:function(e){window.Build?this._texture=e:e&&(this._refreshTexture(e),this._calculateUV())}},{key:"flipUVX",get:function(){return this._isFlipUVX},set:function(e){this._isFlipUVX=e,this._calculateUV()}},{key:"flipUVY",get:function(){return this._isFlipUVY},set:function(e){this._isFlipUVY=e,this._calculateUV()}},{key:"packable",get:function(){return this._packable},set:function(e){this._packable=e}},{key:"original",get:function(){return this._original}}]);var n=t.prototype;return n.textureLoaded=function(){return this.texture&&this.texture.loaded},n.isRotated=function(){return this._rotated},n.setRotated=function(e){this.rotated=e},n.getRect=function(e){return e?(e.set(this._rect),e):this._rect.clone()},n.setRect=function(e){this.rect=e},n.getOriginalSize=function(e){return e?(e.set(this._originalSize),e):this._originalSize.clone()},n.setOriginalSize=function(e){this.originalSize=e},n.getOffset=function(e){return e?(e.set(this._offset),e):this._offset.clone()},n.setOffset=function(e){this.offset=e},n.getGFXTexture=function(){return this._texture.getGFXTexture()},n.getGFXSampler=function(){return this._texture.getGFXSampler()},n.getHash=function(){return this._texture.getHash()},n.getSamplerHash=function(){return this._texture.getSamplerHash()},n.reset=function(e,t){void 0===t&&(t=!1);var n=!1;t&&(this._originalSize.set(0,0),this._rect.set(0,0,0,0),this._offset.set(0,0),this._capInsets=[0,0,0,0],this._rotated=!1,n=!0),e&&(e.texture&&(this.loaded=!1,this._rect.x=this._rect.y=0,this._rect.width=e.texture.width,this._rect.height=e.texture.height,this._refreshTexture(e.texture),this.checkRect(this._texture)),e.originalSize&&this._originalSize.set(e.originalSize),e.rect&&this._rect.set(e.rect),e.offset&&this._offset.set(e.offset),void 0!==e.borderTop&&(this._capInsets[1]=e.borderTop),void 0!==e.borderBottom&&(this._capInsets[3]=e.borderBottom),void 0!==e.borderLeft&&(this._capInsets[0]=e.borderLeft),void 0!==e.borderRight&&(this._capInsets[2]=e.borderRight),void 0!==e.isRotate&&(this._rotated=!!e.isRotate),void 0!==e.isFlipUv&&(this._isFlipUVY=!!e.isFlipUv),n=!0),n&&this.texture&&this._calculateUV()},n.checkRect=function(e){var t=this._rect,n=t.x,i=t.y;return this._rotated?(n+=t.height,i+=t.width):(n+=t.width,i+=t.height),n>e.width?(A(3300,this.name+"/"+e.name,n,e.width),!1):!(i>e.height&&(A(3301,this.name+"/"+e.name,i,e.height),1))},n.onLoaded=function(){this.loaded=!0,this.emit("load")},n.destroy=function(){return this._packable&&kG&&kG.deleteAtlasSpriteFrame(this),e.prototype.destroy.call(this)},n._calculateSlicedUV=function(){var e=this._rect,t=this.texture,n=t.width,i=t.height,r=this._capInsets[0],a=this._capInsets[2],s=e.width-r-a,o=this._capInsets[1],c=this._capInsets[3],l=e.height-o-c,u=this.uvSliced;if(u.length=0,this._rotated){qG[0].u=(e.x+.5)/n,qG[1].u=(e.x+c)/n,qG[2].u=(e.x+c+l)/n,qG[3].u=(e.x+e.height-.5)/n,qG[3].v=(e.y+.5)/i,qG[2].v=(e.y+r)/i,qG[1].v=(e.y+r+s)/i,qG[0].v=(e.y+e.width-.5)/i;for(var h=0;h<4;++h)for(var _=qG[h],f=0;f<4;++f){var d=qG[3-f];u.push({u:_.u,v:d.v})}}else{qG[0].u=(e.x+.5)/n,qG[1].u=(e.x+r)/n,qG[2].u=(e.x+r+s)/n,qG[3].u=(e.x+e.width-.5)/n,qG[3].v=(e.y+.5)/i,qG[2].v=(e.y+o)/i,qG[1].v=(e.y+o+l)/i,qG[0].v=(e.y+e.height-.5)/i;for(var p=0;p<4;++p)for(var m=qG[p],g=0;g<4;++g){var v=qG[g];u.push({u:v.u,v:m.v})}}},n._calculateUV=function(){var e=this._rect,t=this.uv,n=this.unbiasUV,i=this.texture,r=i.width,a=i.height;if(this._rotated){var s=0===r?0:(e.x+.5)/r,o=0===r?0:(e.x+e.height-.5)/r,c=0===a?0:(e.y+.5)/a,l=0===a?0:(e.y+e.width-.5)/a;this._isFlipUVX&&this._isFlipUVY?(t[0]=o,t[1]=l,t[2]=o,t[3]=c,t[4]=s,t[5]=l,t[6]=s,t[7]=c):this._isFlipUVX?(t[0]=o,t[1]=c,t[2]=o,t[3]=l,t[4]=s,t[5]=c,t[6]=s,t[7]=l):this._isFlipUVY?(t[0]=s,t[1]=l,t[2]=s,t[3]=c,t[4]=o,t[5]=l,t[6]=o,t[7]=c):(t[0]=s,t[1]=c,t[2]=s,t[3]=l,t[4]=o,t[5]=c,t[6]=o,t[7]=l);var u=0===r?0:e.x/r,h=0===r?0:(e.x+e.height)/r,_=0===a?0:e.y/a,f=0===a?0:(e.y+e.width)/a;this._isFlipUVX&&this._isFlipUVY?(n[0]=h,n[1]=f,n[2]=h,n[3]=_,n[4]=u,n[5]=f,n[6]=u,n[7]=_):this._isFlipUVX?(n[0]=h,n[1]=_,n[2]=h,n[3]=f,n[4]=u,n[5]=_,n[6]=u,n[7]=f):this._isFlipUVY?(n[0]=u,n[1]=f,n[2]=u,n[3]=_,n[4]=h,n[5]=f,n[6]=h,n[7]=_):(n[0]=u,n[1]=_,n[2]=u,n[3]=f,n[4]=h,n[5]=_,n[6]=h,n[7]=f)}else{var d=0===r?0:(e.x+.5)/r,p=0===r?0:(e.x+e.width-.5)/r,m=0===a?0:(e.y+e.height-.5)/a,g=0===a?0:(e.y+.5)/a;this._isFlipUVX&&this._isFlipUVY?(t[0]=p,t[1]=g,t[2]=d,t[3]=g,t[4]=p,t[5]=m,t[6]=d,t[7]=m):this._isFlipUVX?(t[0]=p,t[1]=m,t[2]=d,t[3]=m,t[4]=p,t[5]=g,t[6]=d,t[7]=g):this._isFlipUVY?(t[0]=d,t[1]=g,t[2]=p,t[3]=g,t[4]=d,t[5]=m,t[6]=p,t[7]=m):(t[0]=d,t[1]=m,t[2]=p,t[3]=m,t[4]=d,t[5]=g,t[6]=p,t[7]=g);var v=0===r?0:e.x/r,y=0===r?0:(e.x+e.width)/r,S=0===a?0:(e.y+e.height)/a,E=0===a?0:e.y/a;this._isFlipUVX&&this._isFlipUVY?(n[0]=y,n[1]=E,n[2]=v,n[3]=E,n[4]=y,n[5]=S,n[6]=v,n[7]=S):this._isFlipUVX?(n[0]=y,n[1]=S,n[2]=v,n[3]=S,n[4]=y,n[5]=E,n[6]=v,n[7]=E):this._isFlipUVY?(n[0]=v,n[1]=E,n[2]=y,n[3]=E,n[4]=v,n[5]=S,n[6]=y,n[7]=S):(n[0]=v,n[1]=S,n[2]=y,n[3]=S,n[4]=v,n[5]=E,n[6]=y,n[7]=E)}for(var T="",A=0;A<t.length;A++)T+=t[A];this.uvHash=Vs(T,666);var x=this.vertices;if(x){x.nu.length=0,x.nv.length=0;for(var C=0;C<x.u.length;C++)x.nu[C]=x.u[C]/r,x.nv[C]=x.v[C]/a}this._calculateSlicedUV()},n._setDynamicAtlasFrame=function(e){e&&(this._original={_texture:this._texture,_x:this._rect.x,_y:this._rect.y},this._texture=e.texture,this._rect.x=e.x,this._rect.y=e.y,this._calculateUV())},n._resetDynamicAtlasFrame=function(){this._original&&(this._rect.x=this._original._x,this._rect.y=this._original._y,this._texture=this._original._texture,this._original=null,this._calculateUV())},n._checkPackable=function(){var e=kG;if(e){var t=this._texture;if(t instanceof md&&!t.isCompressed){var n=this.width,i=this.height;!t.image||n>e.maxFrameSize||i>e.maxFrameSize?this._packable=!1:t.image&&t.image instanceof HTMLCanvasElement&&(this._packable=!0)}else this._packable=!1}},n._serialize=function(){},n._deserialize=function(e){var t=e,n=t.rect;n&&(this._rect=new ti(n.x,n.y,n.width,n.height));var i=t.offset;t.offset&&(this._offset=new qn(i.x,i.y));var r=t.originalSize;t.originalSize&&(this._originalSize=new $n(r.width,r.height)),this._rotated=!!t.rotated,this._name=t.name,this._packable=!!t.packable;var a=t.capInsets;a&&(this._capInsets[0]=a[0],this._capInsets[1]=a[1],this._capInsets[2]=a[2],this._capInsets[3]=a[3]),this.vertices=t.vertices,this.vertices&&(this.vertices.nu=[],this.vertices.nv=[])},n.clone=function(){var e,n,i,r,a,s,o,c,l=new t,u=this.vertices;return l.vertices=u?{x:u.x,y:u.y,triangles:u.triangles,nu:null===(e=u.nu)||void 0===e?void 0:e.slice(0),u:null===(n=u.u)||void 0===n?void 0:n.slice(0),nv:null===(i=u.nv)||void 0===i?void 0:i.slice(0),v:null===(r=u.v)||void 0===r?void 0:r.slice(0)}:null,(a=l.uv).splice.apply(a,[0,l.uv.length].concat(this.uv)),l.uvHash=this.uvHash,(s=l.unbiasUV).splice.apply(s,[0,l.unbiasUV.length].concat(this.unbiasUV)),(o=l.uvSliced).splice.apply(o,[0,l.uvSliced.length].concat(this.uvSliced)),l._rect.set(this._rect),l._offset.set(this._offset),l._originalSize.set(this._originalSize),l._rotated=this._rotated,(c=l._capInsets).splice.apply(c,[0,l._capInsets.length].concat(this._capInsets)),l._atlasUuid=this._atlasUuid,l._texture=this._texture,l._isFlipUVX=this._isFlipUVX,l._isFlipUVY=this._isFlipUVY,l},n._textureLoaded=function(){var e=this._texture,t={},n=!1;0!==this._rect.width&&0!==this._rect.height&&this.checkRect(e)||(t.rect=new ti(0,0,e.width,e.height),n=!0),(0===this._originalSize.width||0===this._originalSize.height||n)&&(t.originalSize=new $n(e.width,e.height),n=!0),n&&(this.reset(t),this.onLoaded()),this._checkPackable()},n._refreshTexture=function(e){this._texture=e,e.loaded?this._textureLoaded():e.once("load",this._textureLoaded,this)},t}(I_))||GG);i.SpriteFrame=XG;var YG,KG=e("SpriteAtlas",ih("cc.SpriteAtlas")((jG=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return Q(t=e.call.apply(e,[this].concat(i))||this,"spriteFrames",WG,Y(t)),t}X(t,e);var n=t.prototype;return n.getTexture=function(){var e=Object.keys(this.spriteFrames);if(e.length>0){var t=this.spriteFrames[e[0]];return t&&t.texture}return null},n.getSpriteFrame=function(e){var t=this.spriteFrames[e];return t?(t.name||(t.name=e),t):null},n.getSpriteFrames=function(){for(var e=[],t=this.spriteFrames,n=0,i=Object.keys(t);n<i.length;n++){var r=i[n];e.push(t[r])}return e},n._serialize=function(){},n._deserialize=function(e,t){var n=e;this._name=n.name;var i=n.spriteFrames;this.spriteFrames=Pe();for(var r=0;r<i.length;r+=2)t.result.push(this.spriteFrames,i[r],i[r+1])},t}(I_),WG=J((VG=jG).prototype,"spriteFrames",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Pe()}}),HG=VG))||HG);i.SpriteAtlas=KG;var ZG,QG,JG,$G,ek=e("Font",ih("cc.Font")(YG=function(e){function t(){return e.apply(this,arguments)||this}return X(t,e),t}(I_))||YG);i.Font=ek;var tk,nk,ik,rk,ak,sk,ok,ck,lk,uk=e("TTFFont",ih("cc.TTFFont")(($G=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return Q(t=e.call.apply(e,[this].concat(i))||this,"_fontFamily",JG,Y(t)),t}return X(t,e),j(t,[{key:"_nativeAsset",get:function(){return this._fontFamily},set:function(e){this._fontFamily=e||"Arial"}},{key:"_nativeDep",get:function(){return{uuid:this._uuid,__nativeName__:this._native,ext:B(this._native),__isNative__:!0}}}]),t}(ek),JG=J((QG=$G).prototype,"_fontFamily",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),J(QG.prototype,"_nativeAsset",[Bh,Nh],Object.getOwnPropertyDescriptor(QG.prototype,"_nativeAsset"),QG.prototype),J(QG.prototype,"_nativeDep",[Bh],Object.getOwnPropertyDescriptor(QG.prototype,"_nativeDep"),QG.prototype),ZG=QG))||ZG);i.TTFFont=uk;var hk,_k=function(){this.u=0,this.v=0,this.w=0,this.h=0,this.offsetX=0,this.offsetY=0,this.textureID=0,this.valid=!1,this.xAdvance=0},fk=function(){function e(e){this.letterDefinitions={},this.texture=e}var t=e.prototype;return t.addLetterDefinitions=function(e,t){this.letterDefinitions[e]=t},t.cloneLetterDefinition=function(){for(var e={},t=0,n=Object.keys(this.letterDefinitions);t<n.length;t++){var i=n[t],r=new _k;He(r,this.letterDefinitions[i]),e[i]=r}return e},t.getTexture=function(){return this.texture},t.getLetter=function(e){return this.letterDefinitions[e]},t.getLetterDefinitionForChar=function(e){var t=e.charCodeAt(0);return this.letterDefinitions.hasOwnProperty(t)?this.letterDefinitions[t]:null},t.clear=function(){this.letterDefinitions={}},e}(),dk=e("BitmapFont",(tk=ih("cc.BitmapFont"),nk=Dh(XG),tk((lk=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return Q(t=e.call.apply(e,[this].concat(i))||this,"fntDataStr",ak,Y(t)),Q(t,"spriteFrame",sk,Y(t)),Q(t,"fontSize",ok,Y(t)),Q(t,"fntConfig",ck,Y(t)),t}return X(t,e),t.prototype.onLoaded=function(){var e=this.spriteFrame;!this.fontDefDictionary&&e&&(this.fontDefDictionary=new fk(e.texture));var t=this.fntConfig;if(t){var n=t.fontDefDictionary;for(var i in n){var r=new _k,a=n[i].rect;r.offsetX=n[i].xOffset,r.offsetY=n[i].yOffset,r.w=a.width,r.h=a.height,r.u=a.x,r.v=a.y,r.textureID=0,r.valid=!0,r.xAdvance=n[i].xAdvance,this.fontDefDictionary.addLetterDefinitions(i,r)}}else _("The fnt config is not exists!")},t}(ek),ak=J((rk=lk).prototype,"fntDataStr",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),sk=J(rk.prototype,"spriteFrame",[nk],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),ok=J(rk.prototype,"fontSize",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return-1}}),ck=J(rk.prototype,"fntConfig",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),ik=rk))||ik));i.BitmapFont=dk;var pk=e("LabelAtlas",ih("cc.LabelAtlas")(hk=function(e){function t(){return e.apply(this,arguments)||this}return X(t,e),t}(dk))||hk);i.LabelAtlas=pk;var mk=e("BASELINE_RATIO",.26),gk=e("MIDDLE_RATIO",(mk+1)/2-mk);var vk=new rt(2);vk.get=function(){return this._get()||{key:"",value:0,prev:null,next:null}};var yk,Sk=new(function(){function e(e){this.count=0,this.limit=0,this.datas={},this.limit=e}var t=e.prototype;return t.moveToHead=function(e){e.next=this.head,e.prev=null,this.head&&(this.head.prev=e),this.head=e,this.tail||(this.tail=e),this.count++,this.datas[e.key]=e},t.put=function(e,t){var n=vk.get();if(n.key=e,n.value=t,this.count>=this.limit){var i=this.tail;delete this.datas[i.key],this.count--,this.tail=i.prev,this.tail.next=null,i.prev=null,i.next=null,vk.put(i)}this.moveToHead(n)},t.remove=function(e){e.prev?e.prev.next=e.next:this.head=e.next,e.next?e.next.prev=e.prev:this.tail=e.prev,delete this.datas[e.key],this.count--},t.get=function(e){var t=this.datas[e];return t?(this.remove(t),this.moveToHead(t),t.value):null},t.clear=function(){this.count=0,this.datas={},this.head=null,this.tail=null},t.has=function(e){return!!this.datas[e]},t.delete=function(e){var t=this.datas[e];this.remove(t)},e}())(100),Ek=/([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûа-яА-ЯЁё]+|\S)/,Tk=/^[!,.:;'}\]%\?>、‘“》?。,!]/,Ak=/([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁё]+|\S)$/,xk=/[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁё]+$/,Ck=/^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁё]/;function Rk(e){return/^[\u4E00-\u9FFF\u3400-\u4DFF]+$/.test(e)||/[\u3000-\u303F]|[\u3040-\u309F]|[\u30A0-\u30FF]|[\uFF00-\uFFEF]|[\u4E00-\u9FAF]|[\u2605-\u2606]|[\u2190-\u2195]|\u203B/g.test(e)||/^[\u1100-\u11FF]|[\u3130-\u318F]|[\uA960-\uA97F]|[\uAC00-\uD7AF]|[\uD7B0-\uD7FF]+$/.test(e)}function bk(e){var t=e.charCodeAt(0);return t>=9&&t<=13||32===t||133===t||160===t||5760===t||t>=8192&&t<=8202||8232===t||8233===t||8239===t||8287===t||12288===t}function wk(e,t,n){var i=(n||e.font)+"🎮"+t,r=Sk.get(i);if(null!==r)return r;var a=e.measureText(t),s=a&&a.width||0;return Sk.put(i,s),s}function Ik(e,t,n){var i=t,r=n,a=e[t];if(a>="\udc00"&&a<="\udfff"&&i--,void 0!==n)if(n-1!==t){var s=e[n-1];s>="\ud800"&&s<="\udbff"&&r--}else a>="\ud800"&&a<="\udbff"&&r++;return e.substring(i,r)}function Ok(e,t,n,i){var r=[];if(0===e.length||n<0)return r.push(""),r;for(var a=e;t>n&&a.length>1;){for(var s=a.length*(n/t)|0,o=Ik(a,s),c=t-i(o),l=o,u=0,h=0;c>n&&h++<10;)s*=n/c,c=t-i(o=Ik(a,s|=0));for(h=0;c<=n&&h++<10;){if(o){var _=Ek.exec(o);u=_?_[0].length:1,l=o}c=t-i(o=Ik(a,s+=u))}0==(s-=u)?(s=1,l=Ik(a,1)):1===s&&a[0]>="\ud800"&&a[0]<="\udbff"&&(s=2,l=Ik(a,2));var f=Ik(a,0,s),d=void 0;Tk.test(l||o)&&(0==(s-=(d=Ak.exec(f))?d[0].length:0)&&(s=1),l=Ik(a,s),f=Ik(a,0,s)),Ck.test(l)&&(d=xk.exec(f))&&f!==d[0]&&(l=Ik(a,s-=d[0].length),f=Ik(a,0,s)),(0===r.length||(f=f.trim()).length>0)&&r.push(f),t=i(a=l||o)}return(0===r.length||(a=a.trim()).length>0)&&r.push(a),r}var Pk,Mk,Nk,Dk,Bk,Lk,Fk,zk,Uk,Gk,kk,Hk,Vk,Wk,jk,qk,Xk,Yk=e("CanvasPool",function(){function e(){this.pool=[]}e.getInstance=function(){return yk||(yk=new e),yk};var t=e.prototype;return t.get=function(){var e=this.pool.pop();if(!e){var t=document.createElement("canvas"),n=t.getContext("2d");e={canvas:t,context:n}}return e},t.put=function(e){this.pool.length>=ft.MAX_LABEL_CANVAS_POOL_SIZE||this.pool.push(e)},e}()),Kk=Cn.WHITE.clone(),Zk=function(){this.u=0,this.v=0,this.w=0,this.h=0,this.texture=null,this.offsetX=0,this.offsetY=0,this.valid=!1,this.xAdvance=0},Qk="rgba(255, 255, 255, "+(1/255).toFixed(3)+")",Jk=function(){function e(e,t){this.image=null,this.labelInfo=void 0,this.char=void 0,this.data=null,this.canvas=null,this.context=null,this.width=0,this.height=0,this.offsetY=0,this.hash=void 0,this.char=e,this.labelInfo=t,this.hash=e.charCodeAt(0)+t.hash}var t=e.prototype;return t.updateRenderData=function(){this._updateProperties(),this._updateTexture()},t.destroy=function(){this.image=null},t._updateProperties=function(){if(this.data=Yk.getInstance().get(),this.canvas=this.data.canvas,this.context=this.data.context,this.context){this.context.font=this.labelInfo.fontDesc;var e=wk(this.context,this.char,this.labelInfo.fontDesc),t=2*this.labelInfo.margin+2;this.width=parseFloat(e.toFixed(2))+t,this.height=(1+mk)*this.labelInfo.fontSize+t,this.offsetY=-this.labelInfo.fontSize*mk/2}this.canvas.width!==this.width&&(this.canvas.width=this.width),this.canvas.height!==this.height&&(this.canvas.height=this.height),this.image||(this.image=new G_),this.image.reset(this.canvas)},t._updateTexture=function(){if(this.context&&this.canvas){var e=this.context,t=this.labelInfo,n=this.canvas.width,i=this.canvas.height;e.textAlign="center",e.textBaseline="alphabetic",e.clearRect(0,0,n,i),e.fillStyle=Qk,e.fillRect(0,0,n,i),e.font=t.fontDesc;var r=t.fontSize,a=n/2,s=i/2+r*gk+0*r,o=t.color;if(e.lineJoin="round",e.fillStyle="rgba("+o.r+", "+o.g+", "+o.b+", 1)",t.isOutlined){var c=t.out||Kk;e.strokeStyle="rgba("+c.r+", "+c.g+", "+c.b+", "+c.a/255+")",e.lineWidth=2*t.margin,e.strokeText(this.char,a,s)}e.fillText(this.char,a,s)}},e}(),$k=function(e){function t(){return e.apply(this,arguments)||this}X(t,e);var n=t.prototype;return n.initWithSize=function(e,t,n){void 0===n&&(n=O_.RGBA8888),this.reset({width:e,height:t,format:n}),this.loaded=!0,this.emit("load")},n.drawTextureAt=function(e,t,n){var i=this.getGFXTexture();if(e&&i){var r=this._getGFXDevice();if(r){var a=new eo;a.texOffset.x=t,a.texOffset.y=n,a.texExtent.width=e.width,a.texExtent.height=e.height,r.copyTexImagesToTexture([e.data],i,[a])}else console.warn("Unable to get device")}},t}(md),eH=function(){function e(e,t){this._x=0,this._y=0,this._nextY=0,this._width=0,this._height=0,this._halfBleed=0,this._dirty=!1;var n=new $k;n.initWithSize(e,t),this.fontDefDictionary=new fk(n),this._halfBleed=1,this._width=e,this._height=t,Ow.on(Iw.EVENT_BEFORE_SCENE_LAUNCH,this.beforeSceneLoad,this)}j(e,[{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}}]);var t=e.prototype;return t.insertLetterTexture=function(e){var t=e.image,n=Ow.root.device;if(!t||!this.fontDefDictionary||!n)return null;var i=t.width,r=t.height;if(this._x+i+0>this._width&&(this._x=0,this._y=this._nextY),this._y+r>this._nextY&&(this._nextY=this._y+r+0),this._nextY>this._height)return null;this.fontDefDictionary.texture.drawTextureAt(t,this._x,this._y),this._dirty=!0;var a=new Zk;return a.u=this._x+this._halfBleed,a.v=this._y+this._halfBleed,a.texture=this.fontDefDictionary.texture,a.valid=!0,a.w=e.width-2,a.h=e.height-2,a.xAdvance=a.w,a.offsetY=e.offsetY,this._x+=i+0,this.fontDefDictionary.addLetterDefinitions(e.hash,a),a},t.update=function(){this._dirty&&(this._dirty=!1)},t.reset=function(){this._x=0,this._y=0,this._nextY=0,this.fontDefDictionary.clear()},t.destroy=function(){this.reset(),this.fontDefDictionary&&(this.fontDefDictionary.texture.destroy(),this.fontDefDictionary.texture=null)},t.getTexture=function(){return this.fontDefDictionary.getTexture()},t.beforeSceneLoad=function(){this.clearAllCache()},t.clearAllCache=function(){this.destroy();var e=new $k;e.initWithSize(this._width,this._height),this.fontDefDictionary.texture=e},t.getLetter=function(e){return this.fontDefDictionary.letterDefinitions[e]},t.getLetterDefinitionForChar=function(e,t){var n=e.charCodeAt(0)+t.hash,i=this.fontDefDictionary.letterDefinitions[n];if(!i){var r=new Jk(e,t);r.updateRenderData(),i=this.insertLetterTexture(r),r.destroy()}return i},e}(),tH={fontAtlas:null,fontSize:0,lineHeight:0,hAlign:0,vAlign:0,hash:"",fontFamily:"",fontDesc:"Arial",color:Cn.WHITE.clone(),isOutlined:!1,out:Cn.WHITE.clone(),margin:0},nH=function(){this.material=null,this.vertexCount=0,this.indicesCount=0},iH=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this).vData=null,t.uvDirty=!0,t.vertDirty=!0,t._data=[],t._indices=[],t._pivotX=0,t._pivotY=0,t._width=0,t._height=0,t}X(t,e),t.add=function(){return sH.add()},t.remove=function(e){var t=sH.data.indexOf(e);-1!==t&&(sH.data[t].clear(),sH.removeAt(t))};var n=t.prototype;return n.updateSizeNPivot=function(e,t,n,i){e===this._width&&t===this._height&&n===this._pivotX&&i===this._pivotY||(this._width=e,this._height=t,this._pivotX=n,this._pivotY=i,this.vertDirty=!0)},n.clear=function(){this._data.length=0,this._indices.length=0,this._pivotX=0,this._pivotY=0,this._width=0,this._height=0,this.uvDirty=!0,this.vertDirty=!0,this.material=null,this.vertexCount=0,this.indicesCount=0},j(t,[{key:"dataLength",get:function(){return this._data.length},set:function(e){var t=this._data;if(t.length!==e){var n=t.length,i=0;for(i=e;i<n;i++)aH.free(t[i]);for(i=n;i<e;i++)t[i]=aH.alloc();t.length=e}}},{key:"data",get:function(){return this._data}}]),t}(nH),rH=function(e){function t(t){var n;return void 0===t&&(t=9),(n=e.call(this)||this).vData=void 0,n.iData=void 0,n.vertexStart=0,n.indicesStart=0,n.byteStart=0,n.byteCount=0,n.lastFilledIndices=0,n.lastFilledVertex=0,n._formatByte=void 0,n._formatByte=t*Float32Array.BYTES_PER_ELEMENT,n.vData=new Float32Array(256*t*Float32Array.BYTES_PER_ELEMENT),n.iData=new Uint16Array(1536),n}X(t,e),t.add=function(){return oH.add()},t.remove=function(e){var t=oH.data.indexOf(e);-1!==t&&(oH.data[t].reset(),oH.removeAt(t))};var n=t.prototype;return n.request=function(e,t){var n=this.byteCount+e*this._formatByte;return this.reserve(e,t),this.vertexCount+=e,this.indicesCount+=t,this.byteCount=n,!0},n.reserve=function(e,t){var n=this.byteCount+e*this._formatByte,i=this.indicesCount+t;if(e+this.vertexCount>65535)return!1;var r=this.vData.byteLength,a=this.iData.length,s=this.vData.length,o=this.iData.length;if(n>r||i>a){for(;r<n||a<i;)r=4*(s*=2),a=o*=2;this._reallocBuffer(s,o)}return!0},n.advance=function(e,t){this.vertexCount+=e,this.indicesCount+=t,this.byteCount+=e*this._formatByte},n.reset=function(){this.vertexCount=0,this.indicesCount=0,this.byteCount=0,this.vertexStart=0,this.indicesStart=0,this.byteStart=0,this.lastFilledIndices=0,this.lastFilledVertex=0},n._reallocBuffer=function(e,t){var n=this.vData;this.vData=new Float32Array(e),this.vData.set(n,0);var i=this.iData;this.iData=new Uint16Array(t),this.iData.set(i,0)},j(t,[{key:"formatByte",set:function(e){this._formatByte=e},get:function(){return this._formatByte}},{key:"floatStride",get:function(){return this._formatByte>>2}},{key:"vDataOffset",get:function(){return this.byteCount>>>2}}]),t}(nH),aH=(function(e){function t(){return e.apply(this,arguments)||this}X(t,e);var n=t.prototype;n._fillQuadBuffer=function(){for(var e=this.iData.length/6,t=this.iData,n=0,i=0;n<e;n++){var r=4*n;t[i++]=r,t[i++]=r+1,t[i++]=r+2,t[i++]=r+1,t[i++]=r+3,t[i++]=r+2}},n._reallocBuffer=function(t,n){e.prototype._reallocBuffer.call(this,t,n),this._fillQuadBuffer()}}(rH),new c_((function(){return{x:0,y:0,z:0,u:0,v:0,color:Cn.WHITE.clone()}}),128)),sH=new l_((function(){return new iH}),32),oH=new l_((function(){return new rH}),32),cH=new qn,lH=new qn,uH=new Hn,hH=new Hn,_H=new Hn,fH=new Hn(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),dH=new ti,pH=function(t){return e({UITransform:t,UITransformComponent:t}),t}((Pk=ih("cc.UITransform"),Mk=mh(),Nk=ah(110),Dk=_h(),Bk=Rh(),Lk=Sh(),Fk=Rh(),zk=Sh(),Uk=Sh(),Pk(Gk=Mk(Gk=Nk(Gk=Dk(Gk=sh(Gk=hh((qk=jk=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return Q(t=e.call.apply(e,[this].concat(i))||this,"_priority",Hk,Y(t)),Q(t,"_contentSize",Vk,Y(t)),Q(t,"_anchorPoint",Wk,Y(t)),t}X(t,e);var n=t.prototype;return n.__preload=function(){this.node._uiProps.uiTransformComp=this},n.onEnable=function(){this.node.on(JA.PARENT_CHANGED,this._parentChanged,this),this._checkAndSortSiblings()&&this.node.parent._updateSiblingIndex()},n.onDisable=function(){this.node.off(JA.PARENT_CHANGED,this._parentChanged,this)},n.onDestroy=function(){this.node._uiProps.uiTransformComp=null},n.setContentSize=function(e,t){var n=this._contentSize;if(void 0===t){if((e=e).width===n.width&&e.height===n.height)return;n.width=e.width,n.height=e.height}else{if(e===n.width&&t===n.height)return;n.width=e,n.height=t}this.node.emit(JA.SIZE_CHANGED)},n.setAnchorPoint=function(e,t){var n=this._anchorPoint;if(void 0===t){if((e=e).x===n.x&&e.y===n.y)return;n.x=e.x,n.y=e.y}else{if(e===n.x&&t===n.y)return;n.x=e,n.y=t}this.node.emit(JA.ANCHOR_CHANGED,this._anchorPoint)},n.isHit=function(e,t){for(var n=this._contentSize.width,r=this._contentSize.height,a=cH,s=lH,o=this._getRenderScene().cameras,c=0;c<o.length;c++){var l=o[c];if(l.visibility&this.node.layer){l.node.getWorldRT(uH);var u=uH.m12,h=uH.m13,_=i.visibleRect.center;if(uH.m12=_.x-(uH.m00*u+uH.m04*h),uH.m13=_.y-(uH.m01*u+uH.m05*h),Hn.invert(uH,uH),qn.transformMat4(a,e,uH),this.node.getWorldMatrix(_H),Hn.invert(uH,_H),!Hn.strictEquals(uH,fH)){qn.transformMat4(s,a,uH),s.x+=this._anchorPoint.x*n,s.y+=this._anchorPoint.y*r;var f=!1;if(s.x>=0&&s.y>=0&&s.x<=n&&s.y<=r&&(f=!0,t&&t.mask))for(var d=t.mask,p=this.node,m=d?d.length:0,g=0,v=0;p&&v<m;++g,p=p.parent){var y=d[v];if(g===y.index){if(p!==y.comp.node){d.length=v;break}var S=y.comp;if(S&&S._enabled&&!S.isHit(a)){f=!1;break}v++}else if(g>y.index){d.length=v;break}}if(f)return!0}}}return!1},n.convertToNodeSpaceAR=function(e,t){return this.node.getWorldMatrix(_H),Hn.invert(uH,_H),t||(t=new bn),bn.transformMat4(t,e,uH)},n.convertToWorldSpaceAR=function(e,t){return this.node.getWorldMatrix(_H),t||(t=new bn),bn.transformMat4(t,e,_H)},n.getBoundingBox=function(){Hn.fromRTS(hH,this.node.getRotation(),this.node.getPosition(),this.node.getScale());var e=this._contentSize.width,t=this._contentSize.height,n=new ti(-this._anchorPoint.x*e,-this._anchorPoint.y*t,e,t);return n.transformMat4(hH),n},n.getBoundingBoxToWorld=function(){return this.node.parent?(this.node.parent.getWorldMatrix(_H),this.getBoundingBoxTo(_H)):this.getBoundingBox()},n.getBoundingBoxTo=function(e){Hn.fromRTS(hH,this.node.getRotation(),this.node.getPosition(),this.node.getScale());var n=this._contentSize.width,i=this._contentSize.height,r=new ti(-this._anchorPoint.x*n,-this._anchorPoint.y*i,n,i);if(Hn.multiply(_H,e,hH),r.transformMat4(_H),!this.node.children)return r;for(var a,s=Z(this.node.children);!(a=s()).done;){var o=a.value;if(o&&o.active){var c=o.getComponent(t);if(c){var l=c.getBoundingBoxTo(e);l&&ti.union(r,r,l)}}}return r},n.getComputeAABB=function(e){var t=this._contentSize.width,n=this._contentSize.height;dH.set(-this._anchorPoint.x*t,-this._anchorPoint.y*n,t,n),dH.transformMat4(this.node.worldMatrix);var i=dH.x+.5*dH.width,r=dH.y+.5*dH.height,a=this.node.worldPosition.z,s=dH.width/2,o=dH.height/2;return null!=e?(al.set(e,i,r,a,s,o,.001),e):new al(i,r,a,s,o,.001)},n._parentChanged=function(){this.node.getComponent("cc.RenderRoot2D")||this._checkAndSortSiblings()},n._checkAndSortSiblings=function(){var e=this.node.parent&&this.node.parent.children,t=!1;return e&&e.sort((function(e,n){var i=e._uiProps.uiTransformComp,r=n._uiProps.uiTransformComp,a=(i?i.priority:0)-(r?r.priority:0);return 0===a&&(a=e.getSiblingIndex()-n.getSiblingIndex()),t=a>0,a})),t},j(t,[{key:"contentSize",get:function(){return this._contentSize},set:function(e){this._contentSize.equals(e)||(this._contentSize.set(e),this.node.emit(JA.SIZE_CHANGED))}},{key:"width",get:function(){return this._contentSize.width},set:function(e){this._contentSize.width!==e&&(this._contentSize.width=e,this.node.emit(JA.SIZE_CHANGED))}},{key:"height",get:function(){return this._contentSize.height},set:function(e){this.contentSize.height!==e&&(this._contentSize.height=e,this.node.emit(JA.SIZE_CHANGED))}},{key:"anchorPoint",get:function(){return this._anchorPoint},set:function(e){this._anchorPoint.equals(e)||(this._anchorPoint.set(e),this.node.emit(JA.ANCHOR_CHANGED,this._anchorPoint))}},{key:"anchorX",get:function(){return this._anchorPoint.x},set:function(e){this._anchorPoint.x!==e&&(this._anchorPoint.x=e,this.node.emit(JA.ANCHOR_CHANGED,this._anchorPoint))}},{key:"anchorY",get:function(){return this._anchorPoint.y},set:function(e){this._anchorPoint.y!==e&&(this._anchorPoint.y=e,this.node.emit(JA.ANCHOR_CHANGED,this._anchorPoint))}},{key:"priority",get:function(){return this._priority},set:function(e){this._priority!==e&&(this.node.getComponent("cc.RenderRoot2D")?E(6706):(this._priority=e,this._checkAndSortSiblings(),this.node.parent._updateSiblingIndex()))}},{key:"visibility",get:function(){var e=Ow.root.batcher2D.getFirstRenderCamera(this.node);return e?e.visibility:0}},{key:"cameraPriority",get:function(){var e=Ow.root.batcher2D.getFirstRenderCamera(this.node);return e?e.priority:0}}]),t}(Kf),jk.EventType=JA,J((kk=qk).prototype,"contentSize",[Bk,Lk],Object.getOwnPropertyDescriptor(kk.prototype,"contentSize"),kk.prototype),J(kk.prototype,"anchorPoint",[Fk,zk],Object.getOwnPropertyDescriptor(kk.prototype,"anchorPoint"),kk.prototype),J(kk.prototype,"priority",[Uk],Object.getOwnPropertyDescriptor(kk.prototype,"priority"),kk.prototype),Hk=J(kk.prototype,"_priority",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Vk=J(kk.prototype,"_contentSize",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new $n(100,100)}}),Wk=J(kk.prototype,"_anchorPoint",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new qn(.5,.5)}}),Gk=kk))||Gk)||Gk)||Gk)||Gk)||Gk)||Gk));!function(e){e[e.DISABLED=0]="DISABLED",e[e.CLEAR=1]="CLEAR",e[e.ENTER_LEVEL=2]="ENTER_LEVEL",e[e.ENABLED=3]="ENABLED",e[e.EXIT_LEVEL=4]="EXIT_LEVEL",e[e.CLEAR_INVERTED=5]="CLEAR_INVERTED",e[e.ENTER_LEVEL_INVERTED=6]="ENTER_LEVEL_INVERTED"}(Xk||(Xk={}));var mH,gH,vH,yH,SH,EH,TH,AH,xH,CH,RH,bH,wH,IH,OH,PH,MH,NH,DH,BH,LH,FH,zH,UH,GH,kH,HH,VH=e("StencilManager",function(){function e(){this.stage=Xk.DISABLED,this._maskStack=[],this._stencilPattern={stencilTest:!0,func:Xa.ALWAYS,stencilMask:65535,writeMask:65535,failOp:Ya.KEEP,zFailOp:Ya.KEEP,passOp:Ya.KEEP,ref:1},this.stencilStateMap=new Map,this.stencilStateMapWithDepth=new Map}var t=e.prototype;return t.pushMask=function(e){this._maskStack.push(e)},t.clear=function(e){e.stencilStage=e.inverted?Xk.CLEAR_INVERTED:Xk.CLEAR},t.enterLevel=function(e){e.graphics.stencilStage=e.inverted?Xk.ENTER_LEVEL_INVERTED:Xk.ENTER_LEVEL},t.enableMask=function(){this.stage=Xk.ENABLED},t.exitMask=function(){0!==this._maskStack.length&&(this._maskStack.pop(),0===this._maskStack.length?this.stage=Xk.DISABLED:this.stage=Xk.ENABLED)},t.getWriteMask=function(){return 1<<this._maskStack.length-1},t.getExitWriteMask=function(){return 1<<this._maskStack.length},t.getStencilRef=function(){for(var e=0,t=0;t<this._maskStack.length;++t)e+=1<<t;return e},t.reset=function(){this._maskStack.length=0,this.stage=Xk.DISABLED},t.destroy=function(){this.stencilStateMap.forEach((function(e){e.destroy()})),this.stencilStateMap.clear()},t.getStencilStage=function(e,t){var n=0,i=!1,r=!1,a=Xa.LESS,s=this.stencilStateMap;if(t&&t.passes[0]){var o=t.passes[0].depthStencilState,c=0,l=0;o.depthTest&&(c=1),o.depthWrite&&(l=1),n=c|l<<1|o.depthFunc<<2|e<<6|this._maskStack.length<<9,i=o.depthTest,r=o.depthWrite,a=o.depthFunc,s=this.stencilStateMapWithDepth}else n=e<<16|this._maskStack.length;if(s&&s.has(n))return s.get(n);this.setStateFromStage(e);var u=new no(i,r,a,this._stencilPattern.stencilTest,this._stencilPattern.func,this._stencilPattern.stencilMask,this._stencilPattern.writeMask,this._stencilPattern.failOp,this._stencilPattern.zFailOp,this._stencilPattern.passOp,this._stencilPattern.ref,this._stencilPattern.stencilTest,this._stencilPattern.func,this._stencilPattern.stencilMask,this._stencilPattern.writeMask,this._stencilPattern.failOp,this._stencilPattern.zFailOp,this._stencilPattern.passOp,this._stencilPattern.ref);return s.set(n,u),u},t.getStencilHash=function(e){return e<<8|this._maskStack.length},t.setStateFromStage=function(e){var t=this._stencilPattern;e===Xk.DISABLED?(t.stencilTest=!1,t.func=Xa.ALWAYS,t.failOp=Ya.KEEP,t.stencilMask=t.writeMask=65535,t.ref=1):(t.stencilTest=!0,e===Xk.ENABLED?(t.func=Xa.EQUAL,t.failOp=Ya.KEEP,t.stencilMask=t.ref=this.getStencilRef(),t.writeMask=this.getWriteMask()):e===Xk.CLEAR?(t.func=Xa.NEVER,t.failOp=Ya.ZERO,t.writeMask=t.stencilMask=t.ref=this.getWriteMask()):e===Xk.CLEAR_INVERTED||e===Xk.ENTER_LEVEL?(t.func=Xa.NEVER,t.failOp=Ya.REPLACE,t.writeMask=t.stencilMask=t.ref=this.getWriteMask()):e===Xk.ENTER_LEVEL_INVERTED&&(t.func=Xa.NEVER,t.failOp=Ya.ZERO,t.writeMask=t.stencilMask=t.ref=this.getWriteMask()))},j(e,[{key:"pattern",get:function(){return this._stencilPattern}}]),e}());VH.sharedManager=null,VH.sharedManager=new VH,ht(Za),function(e){e[e.ADD_COLOR=0]="ADD_COLOR",e[e.ADD_COLOR_AND_TEXTURE=1]="ADD_COLOR_AND_TEXTURE",e[e.GRAYSCALE=2]="GRAYSCALE",e[e.USE_ALPHA_SEPARATED=3]="USE_ALPHA_SEPARATED",e[e.USE_ALPHA_SEPARATED_AND_GRAY=4]="USE_ALPHA_SEPARATED_AND_GRAY"}(HH||(HH=e("InstanceMaterialType",{})));var WH,jH,qH,XH,YH,KH,ZH,QH,JH,$H,eV,tV,nV,iV,rV,aV,sV,oV,cV,lV,uV,hV,_V,fV,dV,pV,mV,gV,vV,yV,SV,EV,TV,AV,xV,CV,RV,bV,wV,IV,OV,PV,MV,NV,DV,BV,LV,FV,zV,UV,GV,kV,HV,VV,WV,jV,qV,XV,YV,KV,ZV,QV,JV,$V,eW=function(t){return e({Renderable2D:t,RenderComponent:t,UIRenderable:t}),t}((mH=ih("cc.Renderable2D"),gH=rh(pH),vH=vh(),yH=Dh(em),SH=Dh(em),EH=Rh(),TH=yh(),AH=vh(),xH=Dh(Za),CH=Rh(),RH=Sh(),bH=vh(),wH=Dh(Za),IH=Rh(),OH=Sh(),PH=Rh(),MH=Sh(),mH(NH=gH(NH=sh(NH=hh((kH=GH=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return Q(t=e.call.apply(e,[this].concat(i))||this,"_materials",BH,Y(t)),Q(t,"_customMaterial",LH,Y(t)),t.stencilStage=Xk.DISABLED,Q(t,"_srcBlendFactor",FH,Y(t)),Q(t,"_dstBlendFactor",zH,Y(t)),Q(t,"_color",UH,Y(t)),t._assembler=null,t._postAssembler=null,t._renderData=null,t._renderDataFlag=!0,t._renderFlag=!0,t._delegateSrc=null,t._instanceMaterialType=HH.ADD_COLOR_AND_TEXTURE,t._blendState=new ro,t._blendHash=0,t._lastParent=null,t}X(t,e);var n=t.prototype;return n.updateMaterial=function(){if(this._customMaterial)return this.setMaterial(this._customMaterial,0),void(this._blendHash=-1);var e=this._updateBuiltinMaterial();this.setMaterial(e,0),this._updateBlendFunc()},n.updateBlendHash=function(){var e=this._blendState.targets[0].blendDst<<4;this._blendHash=e|this._blendState.targets[0].blendSrc},n.__preload=function(){this.node._uiProps.uiComp=this,this._flushAssembler&&this._flushAssembler()},n.onEnable=function(){this.node.on(JA.ANCHOR_CHANGED,this._nodeStateChange,this),this.node.on(JA.SIZE_CHANGED,this._nodeStateChange,this),this.updateMaterial(),this._renderFlag=this._canRender()},n.onRestore=function(){this.updateMaterial(),this._renderFlag=this._canRender()},n.onDisable=function(){this.node.off(JA.ANCHOR_CHANGED,this._nodeStateChange,this),this.node.off(JA.SIZE_CHANGED,this._nodeStateChange,this),this._renderFlag=!1},n.onDestroy=function(){if(this.node._uiProps.uiComp===this&&(this.node._uiProps.uiComp=null),this.destroyRenderData(),this._materialInstances)for(var e=0;e<this._materialInstances.length;e++)this._materialInstances[e].destroy();this._renderData=null,this._blendState&&this._blendState.destroy()},n.markForUpdateRenderData=function(e){if(void 0===e&&(e=!0),this._renderFlag=this._canRender(),e&&this._renderFlag){var t=this._renderData;t&&(t.vertDirty=!0),this._renderDataFlag=e}else e||(this._renderDataFlag=e)},n.requestRenderData=function(){var e=iH.add();return this._renderData=e,e},n.destroyRenderData=function(){this._renderData&&(iH.remove(this._renderData),this._renderData=null)},n.updateAssembler=function(e){this._renderFlag&&(this._checkAndUpdateRenderData(),this._render(e))},n.postUpdateAssembler=function(e){this._renderFlag&&this._postRender(e)},n._render=function(){},n._postRender=function(){},n._checkAndUpdateRenderData=function(){this._renderDataFlag&&(this._assembler.updateRenderData(this),this._renderDataFlag=!1)},n._canRender=function(){return this.isValid&&null!==this.getMaterial(0)&&this.enabled&&(this._delegateSrc?this._delegateSrc.activeInHierarchy:this.enabledInHierarchy)&&this._color.a>0},n._postCanRender=function(){},n._updateColor=function(){this._assembler&&this._assembler.updateColor&&this._assembler.updateColor(this)},n._updateBlendFunc=function(){var e=this._blendState.targets[0];e||(e=new io,this._blendState.setTarget(0,e)),e.blendDst===this._dstBlendFactor&&e.blendSrc===this._srcBlendFactor||(e.blend=!0,e.blendDstAlpha=Za.ONE_MINUS_SRC_ALPHA,e.blendDst=this._dstBlendFactor,e.blendSrc=this._srcBlendFactor),this.updateBlendHash()},n.getBlendState=function(){return this._blendState},n._nodeStateChange=function(){this._renderData&&this.markForUpdateRenderData();for(var e=0;e<this.node.children.length;++e){var n=this.node.children[e].getComponent(t);n&&n.markForUpdateRenderData()}},n._updateBuiltinMaterial=function(){var e;switch(this._instanceMaterialType){case HH.ADD_COLOR:e=Xd.get("ui-base-material");break;case HH.GRAYSCALE:e=Xd.get("ui-sprite-gray-material");break;case HH.USE_ALPHA_SEPARATED:e=Xd.get("ui-sprite-alpha-sep-material");break;case HH.USE_ALPHA_SEPARATED_AND_GRAY:e=Xd.get("ui-sprite-gray-alpha-sep-material");break;default:e=Xd.get("ui-sprite-material")}return e},j(t,[{key:"sharedMaterials",get:function(){return this._materials},set:function(e){for(var t=0;t<e.length;t++)e[t]!==this._materials[t]&&this.setMaterial(e[t],t);if(e.length<this._materials.length){for(var n=e.length;n<this._materials.length;n++)this.setMaterial(null,n);this._materials.splice(e.length)}}},{key:"customMaterial",get:function(){return this._customMaterial},set:function(e){this._customMaterial=e,this.updateMaterial()}},{key:"srcBlendFactor",get:function(){return this._customMaterial&&E(12001),this._srcBlendFactor},set:function(e){this._customMaterial?E(12001):this._srcBlendFactor!==e&&(this._srcBlendFactor=e,this._updateBlendFunc())}},{key:"dstBlendFactor",get:function(){return this._customMaterial&&E(12001),this._dstBlendFactor},set:function(e){this._customMaterial?E(12001):this._dstBlendFactor!==e&&(this._dstBlendFactor=e,this._updateBlendFunc())}},{key:"color",get:function(){return this._color},set:function(e){this._color.equals(e)||(this._color.set(e),this._updateColor(),this.markForUpdateRenderData())}},{key:"renderData",get:function(){return this._renderData}},{key:"delegateSrc",set:function(e){this._delegateSrc=e}},{key:"blendHash",get:function(){return this._blendHash}}]),t}(zP),GH.BlendState=Za,GH.Assembler=null,GH.PostAssembler=null,BH=J((DH=kH).prototype,"_materials",[Bh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),J(DH.prototype,"sharedMaterials",[Bh,vH],Object.getOwnPropertyDescriptor(DH.prototype,"sharedMaterials"),DH.prototype),LH=J(DH.prototype,"_customMaterial",[yH],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),J(DH.prototype,"customMaterial",[SH,EH,TH],Object.getOwnPropertyDescriptor(DH.prototype,"customMaterial"),DH.prototype),J(DH.prototype,"srcBlendFactor",[AH,xH,CH,RH],Object.getOwnPropertyDescriptor(DH.prototype,"srcBlendFactor"),DH.prototype),J(DH.prototype,"dstBlendFactor",[bH,wH,IH,OH],Object.getOwnPropertyDescriptor(DH.prototype,"dstBlendFactor"),DH.prototype),J(DH.prototype,"color",[PH,MH],Object.getOwnPropertyDescriptor(DH.prototype,"color"),DH.prototype),FH=J(DH.prototype,"_srcBlendFactor",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Za.SRC_ALPHA}}),zH=J(DH.prototype,"_dstBlendFactor",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Za.ONE_MINUS_SRC_ALPHA}}),UH=J(DH.prototype,"_color",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Cn.WHITE.clone()}}),NH=DH))||NH)||NH)||NH)||NH));i.internal.Renderable2D=eW,function(e){e[e.LEFT=0]="LEFT",e[e.CENTER=1]="CENTER",e[e.RIGHT=2]="RIGHT"}(ZV||(ZV=e("HorizontalTextAlignment",{}))),ht(ZV),function(e){e[e.TOP=0]="TOP",e[e.CENTER=1]="CENTER",e[e.BOTTOM=2]="BOTTOM"}(QV||(QV=e("VerticalTextAlignment",{}))),ht(QV),function(e){e[e.NONE=0]="NONE",e[e.CLAMP=1]="CLAMP",e[e.SHRINK=2]="SHRINK",e[e.RESIZE_HEIGHT=3]="RESIZE_HEIGHT"}(JV||(JV=e("Overflow",{}))),ht(JV),function(e){e[e.NONE=0]="NONE",e[e.BITMAP=1]="BITMAP",e[e.CHAR=2]="CHAR"}($V||($V=e("CacheMode",{}))),ht($V);var tW,nW,iW,rW=function(t){return e({Label:t,LabelComponent:t}),t}((WH=ih("cc.Label"),jH=mh(),qH=ah(110),XH=_h(),YH=Rh(),KH=Sh(),ZH=Dh(ZV),QH=Rh(),JH=Sh(),$H=Dh(QV),eV=Rh(),tV=Sh(),nV=Rh(),iV=Sh(),rV=Rh(),aV=vh(),sV=Sh(),oV=Rh(),cV=Sh(),lV=Dh(JV),uV=Rh(),hV=Sh(),_V=Rh(),fV=Sh(),dV=Dh(ek),pV=Rh(),mV=vh(),gV=Sh(),vV=Rh(),yV=Sh(),SV=Dh($V),EV=Rh(),TV=Sh(),AV=Rh(),xV=Sh(),CV=Rh(),RV=Sh(),bV=Rh(),wV=Sh(),IV=vh(),WH(OV=jH(OV=qH(OV=XH((KV=YV=function(e){function t(){var t;return Q(t=e.call(this)||this,"_string",MV,Y(t)),Q(t,"_horizontalAlign",NV,Y(t)),Q(t,"_verticalAlign",DV,Y(t)),Q(t,"_actualFontSize",BV,Y(t)),Q(t,"_fontSize",LV,Y(t)),Q(t,"_fontFamily",FV,Y(t)),Q(t,"_lineHeight",zV,Y(t)),Q(t,"_overflow",UV,Y(t)),Q(t,"_enableWrapText",GV,Y(t)),Q(t,"_font",kV,Y(t)),Q(t,"_isSystemFontUsed",HV,Y(t)),t._spacingX=0,Q(t,"_isItalic",VV,Y(t)),Q(t,"_isBold",WV,Y(t)),Q(t,"_isUnderline",jV,Y(t)),Q(t,"_underlineHeight",qV,Y(t)),Q(t,"_cacheMode",XV,Y(t)),t._N$file=null,t._texture=null,t._ttfSpriteFrame=null,t._userDefinedFont=null,t._assemblerData=null,t._fontAtlas=null,t._letterTexture=null,t._ttfSpriteFrame=null,t}X(t,e),j(t,[{key:"string",get:function(){return this._string},set:function(e){e+="",this._string!==e&&(this._string=e,this.updateRenderData())}},{key:"horizontalAlign",get:function(){return this._horizontalAlign},set:function(e){this._horizontalAlign!==e&&(this._horizontalAlign=e,this.updateRenderData())}},{key:"verticalAlign",get:function(){return this._verticalAlign},set:function(e){this._verticalAlign!==e&&(this._verticalAlign=e,this.updateRenderData())}},{key:"actualFontSize",get:function(){return this._actualFontSize},set:function(e){this._actualFontSize=e}},{key:"fontSize",get:function(){return this._fontSize},set:function(e){this._fontSize!==e&&(this._fontSize=e,this.updateRenderData())}},{key:"fontFamily",get:function(){return this._fontFamily},set:function(e){this._fontFamily!==e&&(this._fontFamily=e,this.updateRenderData())}},{key:"lineHeight",get:function(){return this._lineHeight},set:function(e){this._lineHeight!==e&&(this._lineHeight=e,this.updateRenderData())}},{key:"overflow",get:function(){return this._overflow},set:function(e){this._overflow!==e&&(this._overflow=e,this.updateRenderData())}},{key:"enableWrapText",get:function(){return this._enableWrapText},set:function(e){this._enableWrapText!==e&&(this._enableWrapText=e,this.updateRenderData())}},{key:"font",get:function(){return this._font},set:function(e){this._font!==e&&(this._isSystemFontUsed=!e,this._font=e,this._renderData&&(this.destroyRenderData(),this._renderData=null),this._fontAtlas=null,this.updateRenderData(!0))}},{key:"useSystemFont",get:function(){return this._isSystemFontUsed},set:function(e){this._isSystemFontUsed!==e&&(this.destroyRenderData(),this._renderData=null,this._isSystemFontUsed=!!e,e&&(this.font=null),this._flushAssembler(),this.updateRenderData())}},{key:"cacheMode",get:function(){return this._cacheMode},set:function(e){this._cacheMode!==e&&(this._cacheMode!==$V.BITMAP||this._font instanceof dk||!this._ttfSpriteFrame||this._ttfSpriteFrame._resetDynamicAtlasFrame(),this._cacheMode===$V.CHAR&&(this._ttfSpriteFrame=null),this._cacheMode=e,this.updateRenderData(!0))}},{key:"spriteFrame",get:function(){return this._texture}},{key:"ttfSpriteFrame",get:function(){return this._ttfSpriteFrame}},{key:"isBold",get:function(){return this._isBold},set:function(e){this._isBold!==e&&(this._isBold=e,this.updateRenderData())}},{key:"isItalic",get:function(){return this._isItalic},set:function(e){this._isItalic!==e&&(this._isItalic=e,this.updateRenderData())}},{key:"isUnderline",get:function(){return this._isUnderline},set:function(e){this._isUnderline!==e&&(this._isUnderline=e,this.updateRenderData())}},{key:"underlineHeight",get:function(){return this._underlineHeight},set:function(e){this._underlineHeight!==e&&(this._underlineHeight=e,this.updateRenderData())}},{key:"assemblerData",get:function(){return this._assemblerData}},{key:"fontAtlas",get:function(){return this._fontAtlas},set:function(e){this._fontAtlas=e}},{key:"spacingX",get:function(){return this._spacingX},set:function(e){this._spacingX!==e&&(this._spacingX=e,this.updateRenderData())}},{key:"_bmFontOriginalSize",get:function(){return this._font instanceof dk?this._font.fontSize:-1}}]);var n=t.prototype;return n.onEnable=function(){e.prototype.onEnable.call(this),this._font||this._isSystemFontUsed||(this.useSystemFont=!0),this._isSystemFontUsed&&!this._fontFamily&&(this.fontFamily="Arial"),this.updateRenderData(!0)},n.onDisable=function(){e.prototype.onDisable.call(this)},n.onDestroy=function(){if(this._assembler&&this._assembler.resetAssemblerData&&this._assembler.resetAssemblerData(this._assemblerData),this._assemblerData=null,this._ttfSpriteFrame){var t=this._ttfSpriteFrame.texture;if(t&&null===this._ttfSpriteFrame.original){var n=t;n.image&&n.image.destroy(),t.destroy()}this._ttfSpriteFrame=null}this._letterTexture=null,e.prototype.onDestroy.call(this)},n.updateRenderData=function(e){void 0===e&&(e=!1),this.markForUpdateRenderData(),e&&(this._flushAssembler(),this._applyFontTexture())},n._render=function(e){e.commitComp(this,this._texture,this._assembler,null)},n._updateColor=function(){this._font instanceof dk?e.prototype._updateColor.call(this):this.updateRenderData(!1)},n._canRender=function(){if(!e.prototype._canRender.call(this)||!this._string)return!1;var t=this._font;if(t&&t instanceof dk){var n=t.spriteFrame;if(!n||!n.textureLoaded())return!1}return!0},n._flushAssembler=function(){var e=t.Assembler.getAssembler(this);this._assembler!==e&&(this.destroyRenderData(),this._assembler=e),this._renderData||this._assembler&&this._assembler.createData&&(this._renderData=this._assembler.createData(this),this._renderData.material=this.material)},n._applyFontTexture=function(){var e=this,t=this._font;if(t instanceof dk){var n=t.spriteFrame,i=function(){e._texture=n,e._assembler&&e._assembler.updateRenderData(e)};n&&(n.loaded||n.textureLoaded?i():n.once("load",i,this))}else{if(this.cacheMode===$V.CHAR)this._letterTexture=this._assembler.getAssemblerData(),this._texture=this._letterTexture;else if(!this._ttfSpriteFrame){this._ttfSpriteFrame=new XG,this._assemblerData=this._assembler.getAssemblerData();var r=new G_(this._assemblerData.canvas)._texture;this._ttfSpriteFrame.texture=r}this.cacheMode!==$V.CHAR&&(this._texture=this._ttfSpriteFrame)}},t}(eW),YV.HorizontalAlign=ZV,YV.VerticalAlign=QV,YV.Overflow=JV,YV.CacheMode=$V,YV._canvasPool=Yk.getInstance(),J((PV=KV).prototype,"string",[YH,KH,wh],Object.getOwnPropertyDescriptor(PV.prototype,"string"),PV.prototype),J(PV.prototype,"horizontalAlign",[ZH,QH,JH],Object.getOwnPropertyDescriptor(PV.prototype,"horizontalAlign"),PV.prototype),J(PV.prototype,"verticalAlign",[$H,eV,tV],Object.getOwnPropertyDescriptor(PV.prototype,"verticalAlign"),PV.prototype),J(PV.prototype,"fontSize",[nV,iV],Object.getOwnPropertyDescriptor(PV.prototype,"fontSize"),PV.prototype),J(PV.prototype,"fontFamily",[rV,aV,sV],Object.getOwnPropertyDescriptor(PV.prototype,"fontFamily"),PV.prototype),J(PV.prototype,"lineHeight",[oV,cV],Object.getOwnPropertyDescriptor(PV.prototype,"lineHeight"),PV.prototype),J(PV.prototype,"overflow",[lV,uV,hV],Object.getOwnPropertyDescriptor(PV.prototype,"overflow"),PV.prototype),J(PV.prototype,"enableWrapText",[_V,fV],Object.getOwnPropertyDescriptor(PV.prototype,"enableWrapText"),PV.prototype),J(PV.prototype,"font",[dV,pV,mV,gV],Object.getOwnPropertyDescriptor(PV.prototype,"font"),PV.prototype),J(PV.prototype,"useSystemFont",[vV,yV],Object.getOwnPropertyDescriptor(PV.prototype,"useSystemFont"),PV.prototype),J(PV.prototype,"cacheMode",[SV,EV,TV],Object.getOwnPropertyDescriptor(PV.prototype,"cacheMode"),PV.prototype),J(PV.prototype,"isBold",[AV,xV],Object.getOwnPropertyDescriptor(PV.prototype,"isBold"),PV.prototype),J(PV.prototype,"isItalic",[CV,RV],Object.getOwnPropertyDescriptor(PV.prototype,"isItalic"),PV.prototype),J(PV.prototype,"isUnderline",[bV,wV],Object.getOwnPropertyDescriptor(PV.prototype,"isUnderline"),PV.prototype),J(PV.prototype,"underlineHeight",[IV,gh],Object.getOwnPropertyDescriptor(PV.prototype,"underlineHeight"),PV.prototype),MV=J(PV.prototype,"_string",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"label"}}),NV=J(PV.prototype,"_horizontalAlign",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return ZV.CENTER}}),DV=J(PV.prototype,"_verticalAlign",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return QV.CENTER}}),BV=J(PV.prototype,"_actualFontSize",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),LV=J(PV.prototype,"_fontSize",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 40}}),FV=J(PV.prototype,"_fontFamily",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"Arial"}}),zV=J(PV.prototype,"_lineHeight",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 40}}),UV=J(PV.prototype,"_overflow",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return JV.NONE}}),GV=J(PV.prototype,"_enableWrapText",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),kV=J(PV.prototype,"_font",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),HV=J(PV.prototype,"_isSystemFontUsed",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),VV=J(PV.prototype,"_isItalic",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),WV=J(PV.prototype,"_isBold",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),jV=J(PV.prototype,"_isUnderline",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),qV=J(PV.prototype,"_underlineHeight",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 2}}),XV=J(PV.prototype,"_cacheMode",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return $V.NONE}}),OV=PV))||OV)||OV)||OV)||OV));!function(e){e[e.BUTT=0]="BUTT",e[e.ROUND=1]="ROUND",e[e.SQUARE=2]="SQUARE"}(tW||(tW={})),ht(tW),function(e){e[e.BEVEL=0]="BEVEL",e[e.ROUND=1]="ROUND",e[e.MITER=2]="MITER"}(nW||(nW={})),ht(nW),function(e){e[e.PT_CORNER=1]="PT_CORNER",e[e.PT_LEFT=2]="PT_LEFT",e[e.PT_BEVEL=4]="PT_BEVEL",e[e.PT_INNERBEVEL=8]="PT_INNERBEVEL"}(iW||(iW={})),ht(iW);var aW=Math.PI,sW=Math.min,oW=Math.max,cW=Math.cos,lW=Math.sin,uW=Math.abs,hW=Math.sign,_W=.5522847493;function fW(e,t,n,i,r){e.moveTo(t-i,n),e.bezierCurveTo(t-i,n+r*_W,t-i*_W,n+r,t,n+r),e.bezierCurveTo(t+i*_W,n+r,t+i,n+r*_W,t+i,n),e.bezierCurveTo(t+i,n-r*_W,t+i*_W,n-r,t,n-r),e.bezierCurveTo(t-i*_W,n-r,t-i,n-r*_W,t-i,n),e.close()}var dW,pW,mW,gW,vW,yW,SW,EW,TW,AW,xW,CW,RW,bW,wW,IW,OW,PW,MW,NW,DW,BW,LW,FW,zW=function(e){function t(t,n){var i;return(i=e.call(this,t,n)||this).dx=0,i.dy=0,i.dmx=0,i.dmy=0,i.flags=0,i.len=0,i.reset(),i}return X(t,e),t.prototype.reset=function(){this.dx=0,this.dy=0,this.dmx=0,this.dmy=0,this.flags=0,this.len=0},t}(qn),UW=function(){function e(){this.closed=!1,this.bevel=0,this.complex=!0,this.points=[],this.reset()}return e.prototype.reset=function(){this.closed=!1,this.bevel=0,this.complex=!0,this.points?this.points.length=0:this.points=[]},e}(),GW=function(){function e(){this.dataOffset=0,this.updatePathOffset=!1,this.pathLength=0,this.pathOffset=0,this.paths=[],this.tessTol=.25,this.distTol=.01,this.fillColor=Cn.WHITE.clone(),this.lineCap=tW.BUTT,this.strokeColor=Cn.BLACK.clone(),this.lineJoin=nW.MITER,this.lineWidth=0,this.pointsOffset=0,this._commandX=0,this._commandY=0,this._points=[],this._renderDataList=[],this._curPath=null}var t=e.prototype;return t.moveTo=function(e,t){this.updatePathOffset&&(this.pathOffset=this.pathLength,this.updatePathOffset=!1),this._addPath(),this.addPoint(e,t,iW.PT_CORNER),this._commandX=e,this._commandY=t},t.lineTo=function(e,t){this.addPoint(e,t,iW.PT_CORNER),this._commandX=e,this._commandY=t},t.bezierCurveTo=function(e,t,n,i,r,a){var s=this._curPath,o=s.points[s.points.length-1];o&&(o.x!==e||o.y!==t||n!==r||i!==a?(function e(t,n,i,r,a,s,o,c,l,u,h){var _,f,d,p,m,g,v,y,S,E,T,A,x,C,R,b;u>10||(m=.5*(s+c),g=.5*(o+l),v=.5*((_=.5*(n+r))+(d=.5*(r+s))),y=.5*((f=.5*(i+a))+(p=.5*(a+o))),((R=uW((r-c)*(C=l-i)-(a-l)*(x=c-n)))+(b=uW((s-c)*C-(o-l)*x)))*(R+b)<t.tessTol*(x*x+C*C)?t.addPoint(c,l,0===h?h|iW.PT_BEVEL:h):(e(t,n,i,_,f,v,y,T=.5*(v+(S=.5*(d+m))),A=.5*(y+(E=.5*(p+g))),u+1,0),e(t,T,A,S,E,m,g,c,l,u+1,h)))}(this,o.x,o.y,e,t,n,i,r,a,0,iW.PT_CORNER),this._commandX=r,this._commandY=a):this.lineTo(r,a))},t.quadraticCurveTo=function(e,t,n,i){var r=this._commandX,a=this._commandY;this.bezierCurveTo(r+2/3*(e-r),a+2/3*(t-a),n+2/3*(e-n),i+2/3*(t-i),n,i)},t.arc=function(e,t,n,i,r,a){!function(e,t,n,i,r,a,s){var o,c,l=0,u=0,h=0,_=0,f=0,d=0,p=0,m=0,g=0,v=0,y=0,S=0,E=0,T=0;if(u=a-r,s=s||!1)if(uW(u)>=2*aW)u=2*aW;else for(;u<0;)u+=2*aW;else if(uW(u)>=2*aW)u=2*-aW;else for(;u>0;)u-=2*aW;for(c=0|oW(1,sW(uW(u)/(.5*aW)+.5,5)),h=uW(4/3*(1-cW(o=u/c/2))/lW(o)),s||(h=-h),T=0;T<=c;T++)d=t+(_=cW(l=r+u*(T/c)))*i,p=n+(f=lW(l))*i,m=-f*i*h,g=_*i*h,0===T?e.moveTo(d,p):e.bezierCurveTo(v+S,y+E,d-m,p-g,d,p),v=d,y=p,S=m,E=g}(this,e,t,n,i,r,a)},t.ellipse=function(e,t,n,i){fW(this,e,t,n,i),this._curPath.complex=!1},t.circle=function(e,t,n){fW(this,e,t,n,n),this._curPath.complex=!1},t.rect=function(e,t,n,i){this.moveTo(e,t),this.lineTo(e+n,t),this.lineTo(e+n,t+i),this.lineTo(e,t+i),this.close(),this._curPath.complex=!1},t.roundRect=function(e,t,n,i,r){!function(e,t,n,i,r,a){if(a<.1)e.rect(t,n,i,r);else{var s=sW(a,.5*uW(i))*hW(i),o=sW(a,.5*uW(r))*hW(r);e.moveTo(t,n+o),e.lineTo(t,n+r-o),e.bezierCurveTo(t,n+r-o*(1-_W),t+s*(1-_W),n+r,t+s,n+r),e.lineTo(t+i-s,n+r),e.bezierCurveTo(t+i-s*(1-_W),n+r,t+i,n+r-o*(1-_W),t+i,n+r-o),e.lineTo(t+i,n+o),e.bezierCurveTo(t+i,n+o*(1-_W),t+i-s*(1-_W),n,t+i-s,n),e.lineTo(t+s,n),e.bezierCurveTo(t+s*(1-_W),n,t,n+o*(1-_W),t,n+o),e.close()}}(this,e,t,n,i,r),this._curPath.complex=!1},t.clear=function(){this.pathLength=0,this.pathOffset=0,this.pointsOffset=0,this.dataOffset=0,this._curPath=null,this.paths.length=0,this._points.length=0;for(var e=this._renderDataList,t=0,n=e.length;t<n;t++){var i=e[t];i&&rH.remove(i)}this._renderDataList.length=0},t.close=function(){this._curPath.closed=!0},t.requestRenderData=function(){var e=rH.add();return this._renderDataList.push(e),e},t.getRenderDataList=function(){return 0===this._renderDataList.length&&this.requestRenderData(),this._renderDataList},t.addPoint=function(e,t,n){var i=this._curPath;if(i){var r=this._points,a=i.points,s=r[this.pointsOffset++];s?(s.x=e,s.y=t):(s=new zW(e,t),r.push(s)),s.flags=n,a.push(s)}},t._addPath=function(){var e=this.pathLength,t=this.paths[e];return t?t.reset():(t=new UW,this.paths.push(t)),this.pathLength++,this._curPath=t,t},e}(),kW=[new Ws(La.ATTR_POSITION,za.RGB32F)],HW=[new Ws(La.ATTR_POSITION,za.RGB32F),new Ws(La.ATTR_COLOR,za.RGBA32F)],VW=[new Ws(La.ATTR_POSITION,za.RGB32F),new Ws(La.ATTR_TEX_COORD,za.RG32F),new Ws(La.ATTR_COLOR,za.RGBA32F)],WW=[new Ws(La.ATTR_POSITION,za.RGB32F),new Ws(La.ATTR_TEX_COORD,za.RG32F),new Ws(La.ATTR_COLOR,za.RGBA32F),new Ws(La.ATTR_COLOR2,za.RGBA32F)];function jW(e){for(var t=0,n=0;n<e.length;n++){var i=e[n];t+=Ts[i.format].count}return t}function qW(e){for(var t=0,n=0;n<e.length;n++){var i=e[n];t+=Ts[i.format].size}return t}i.internal.vfmtPosUvColor=VW,i.internal.vfmtPosUvTwoColor=WW,e("UIVertexFormat",Object.freeze({__proto__:null,vfmt:kW,vfmtPosColor:HW,vfmtPosUvColor:VW,vfmtPosUvTwoColor:WW,getComponentPerVertex:jW,getAttributeStride:qW}));var XW,YW,KW,ZW,QW,JW,$W,ej,tj,nj,ij,rj,aj,sj,oj,cj,lj,uj,hj,_j,fj,dj,pj,mj,gj,vj,yj,Sj,Ej=HW.concat([new Ws("a_dist",za.R32F)]),Tj=jW(Ej),Aj=qW(Ej),xj=function(t){return e({Graphics:t,GraphicsComponent:t}),t}((dW=ih("cc.Graphics"),pW=mh(),mW=ah(110),gW=_h(),vW=Dh(nW),yW=Sh(),SW=Dh(tW),EW=Sh(),TW=Sh(),AW=Sh(),xW=Sh(),CW=vh(),RW=vh(),bW=vh(),dW(wW=pW(wW=mW(wW=gW((FW=LW=function(e){function t(){var t;return(t=e.call(this)||this).impl=null,t.model=null,Q(t,"_lineWidth",OW,Y(t)),Q(t,"_strokeColor",PW,Y(t)),Q(t,"_lineJoin",MW,Y(t)),Q(t,"_lineCap",NW,Y(t)),Q(t,"_fillColor",DW,Y(t)),Q(t,"_miterLimit",BW,Y(t)),t._isDrawing=!1,t._isNeedUploadData=!0,t._instanceMaterialType=HH.ADD_COLOR,t.impl=new GW,t}X(t,e),j(t,[{key:"lineWidth",get:function(){return this._lineWidth},set:function(e){this._lineWidth=e,this.impl&&(this.impl.lineWidth=e)}},{key:"lineJoin",get:function(){return this._lineJoin},set:function(e){this._lineJoin=e,this.impl&&(this.impl.lineJoin=e)}},{key:"lineCap",get:function(){return this._lineCap},set:function(e){this._lineCap=e,this.impl&&(this.impl.lineCap=e)}},{key:"strokeColor",get:function(){return this._strokeColor},set:function(e){this.impl&&(this._strokeColor.set(e),this.impl.strokeColor=this._strokeColor)}},{key:"fillColor",get:function(){return this._fillColor},set:function(e){this.impl&&(this._fillColor.set(e),this.impl.fillColor=this._fillColor)}},{key:"miterLimit",get:function(){return this._miterLimit},set:function(e){this._miterLimit=e}},{key:"color",get:function(){return this._color},set:function(e){this._color!==e&&(this._color.set(e),this._updateColor(),this.markForUpdateRenderData())}},{key:"srcBlendFactor",get:function(){return this._srcBlendFactor},set:function(){}},{key:"dstBlendFactor",get:function(){return this._dstBlendFactor},set:function(){}}]);var n=t.prototype;return n.onRestore=function(){this.impl||this._flushAssembler()},n.onLoad=function(){this.model=Ow.root.createModel(Lp),this.model.node=this.model.transform=this.node,this._flushAssembler()},n.onEnable=function(){e.prototype.onEnable.call(this),this._updateMtlForGraphics()},n.onDisable=function(){e.prototype.onDisable.call(this)},n.onDestroy=function(){e.prototype.onDestroy.call(this),this._sceneGetter=null,this.model&&(Ow.root.destroyModel(this.model),this.model=null),this.impl&&(this._isDrawing=!1,this.impl.clear(),this.impl=null)},n.moveTo=function(e,t){this.impl&&this.impl.moveTo(e,t)},n.lineTo=function(e,t){this.impl&&this.impl.lineTo(e,t)},n.bezierCurveTo=function(e,t,n,i,r,a){this.impl&&this.impl.bezierCurveTo(e,t,n,i,r,a)},n.quadraticCurveTo=function(e,t,n,i){this.impl&&this.impl.quadraticCurveTo(e,t,n,i)},n.arc=function(e,t,n,i,r,a){this.impl&&this.impl.arc(e,t,n,i,r,a)},n.ellipse=function(e,t,n,i){this.impl&&this.impl.ellipse(e,t,n,i)},n.circle=function(e,t,n){this.impl&&this.impl.circle(e,t,n)},n.rect=function(e,t,n,i){this.impl&&this.impl.rect(e,t,n,i)},n.roundRect=function(e,t,n,i,r){this.impl&&this.impl.roundRect(e,t,n,i,r)},n.fillRect=function(e,t,n,i){this.rect(e,t,n,i),this.fill()},n.clear=function(){if(this.impl){if(this.impl.clear(),this._isDrawing=!1,this.model)for(var e=0;e<this.model.subModels.length;e++)this.model.subModels[e].inputAssembler.indexCount=0;this.markForUpdateRenderData()}},n.close=function(){this.impl&&this.impl.close()},n.stroke=function(){this._assembler||this._flushAssembler(),this._isDrawing=!0,this._isNeedUploadData=!0,this._assembler.stroke(this)},n.fill=function(){this._assembler||this._flushAssembler(),this._isDrawing=!0,this._isNeedUploadData=!0,this._assembler.fill(this)},n._updateMtlForGraphics=function(){var e;this._customMaterial?e=this.getMaterialInstance(0):(e=Xd.get("ui-graphics-material"),this.setMaterial(e,0),(e=this.getMaterialInstance(0)).recompileShaders({USE_LOCAL:!0}))},n.activeSubModel=function(e){if(this.model){if(this.model.subModels.length<=e){var t=i.director.root.device,n=t.createBuffer(new Ps(Ua.VERTEX|Ua.TRANSFER_DST,Ga.DEVICE,65535*Aj,Aj)),r=t.createBuffer(new Ps(Ua.INDEX|Ua.TRANSFER_DST,Ga.DEVICE,131070*Uint16Array.BYTES_PER_ELEMENT,Uint16Array.BYTES_PER_ELEMENT)),a=new Lx([n],Ej,Va.TRIANGLE_LIST,r);a.subMeshIdx=0,this.model.initSubModel(e,a,this.getMaterialInstance(0))}}else E(4500,this.node.name)},n._uploadData=function(e){var t=this.impl;if(t){var n=t&&t.getRenderDataList();if(!(n.length<=0)&&this.model){for(var i=this.model.subModels,r=0;r<n.length;r++){var a=n[r],s=i[r].inputAssembler;if(a.lastFilledVertex!==a.vertexStart){var o=new Float32Array(a.vData.buffer,0,a.vertexStart*Tj);s.vertexBuffers[0].update(o),s.vertexCount=a.vertexStart;var c=new Uint16Array(a.iData.buffer,0,a.indicesStart);s.indexBuffer.update(c),s.indexCount=a.indicesStart,a.lastFilledVertex=a.vertexStart,a.lastFilledIndices=a.indicesStart}}e.removeUploadBuffersFunc(this),this._isNeedUploadData=!1}}},n._render=function(e){if(this._isNeedUploadData){if(this.impl){var t=this.impl.getRenderDataList(),n=this.model.subModels.length;if(t.length>n)for(var i=n;i<t.length;i++)this.activeSubModel(i)}e.addUploadBuffersFunc(this,this._uploadData)}e.commitModel(this,this.model,this.getMaterialInstance(0))},n._flushAssembler=function(){var e=t.Assembler.getAssembler(this);this._assembler!==e&&(this._assembler=e)},n._canRender=function(){return!!e.prototype._canRender.call(this)&&!!this.model&&this._isDrawing},t}(eW),LW.LineJoin=nW,LW.LineCap=tW,J((IW=FW).prototype,"lineWidth",[gh],Object.getOwnPropertyDescriptor(IW.prototype,"lineWidth"),IW.prototype),J(IW.prototype,"lineJoin",[vW,yW],Object.getOwnPropertyDescriptor(IW.prototype,"lineJoin"),IW.prototype),J(IW.prototype,"lineCap",[SW,EW],Object.getOwnPropertyDescriptor(IW.prototype,"lineCap"),IW.prototype),J(IW.prototype,"strokeColor",[TW],Object.getOwnPropertyDescriptor(IW.prototype,"strokeColor"),IW.prototype),J(IW.prototype,"fillColor",[AW],Object.getOwnPropertyDescriptor(IW.prototype,"fillColor"),IW.prototype),J(IW.prototype,"miterLimit",[xW],Object.getOwnPropertyDescriptor(IW.prototype,"miterLimit"),IW.prototype),J(IW.prototype,"color",[Bh,CW],Object.getOwnPropertyDescriptor(IW.prototype,"color"),IW.prototype),J(IW.prototype,"srcBlendFactor",[Bh,RW],Object.getOwnPropertyDescriptor(IW.prototype,"srcBlendFactor"),IW.prototype),J(IW.prototype,"dstBlendFactor",[Bh,bW],Object.getOwnPropertyDescriptor(IW.prototype,"dstBlendFactor"),IW.prototype),OW=J(IW.prototype,"_lineWidth",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),PW=J(IW.prototype,"_strokeColor",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Cn.BLACK.clone()}}),MW=J(IW.prototype,"_lineJoin",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return nW.MITER}}),NW=J(IW.prototype,"_lineCap",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return tW.BUTT}}),DW=J(IW.prototype,"_fillColor",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Cn.WHITE.clone()}}),BW=J(IW.prototype,"_miterLimit",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 10}}),wW=IW))||wW)||wW)||wW)||wW)),Cj=new Hn,Rj=new qn,bj=new Hn,wj=[];!function(e){e[e.RECT=0]="RECT",e[e.ELLIPSE=1]="ELLIPSE",e[e.GRAPHICS_STENCIL=2]="GRAPHICS_STENCIL",e[e.IMAGE_STENCIL=3]="IMAGE_STENCIL"}(Sj||(Sj={})),ht(Sj);var Ij=function(t){return e({Mask:t,MaskComponent:t}),t}((XW=ih("cc.Mask"),YW=mh(),KW=ah(110),ZW=_h(),QW=Dh(Sj),JW=Rh(),$W=Sh(),ej=Rh(),tj=Sh(),nj=vh(),ij=Dh(XG),rj=vh(),aj=vh(),sj=Eh(),oj=vh(),cj=vh(),lj=vh(),uj=vh(),XW(hj=YW(hj=KW(hj=ZW((yj=vj=function(e){function t(){var t;return(t=e.call(this)||this)._clearStencilMtl=null,t._clearModel=null,Q(t,"_type",fj,Y(t)),Q(t,"_inverted",dj,Y(t)),Q(t,"_segments",pj,Y(t)),Q(t,"_spriteFrame",mj,Y(t)),Q(t,"_alphaThreshold",gj,Y(t)),t._graphics=null,t._instanceMaterialType=HH.ADD_COLOR,t}X(t,e),j(t,[{key:"type",get:function(){return this._type},set:function(e){this._type!==e&&(this._type=e,this.markForUpdateRenderData(!1),this._updateMaterial(),this._type!==Sj.IMAGE_STENCIL?(this._spriteFrame=null,this._updateGraphics(),this._renderData&&(this.destroyRenderData(),this._renderData=null)):(this._useRenderData(),this._graphics&&this._graphics.clear()))}},{key:"inverted",get:function(){return this._inverted},set:function(e){i.game.renderType!==WA.RENDER_TYPE_CANVAS?(this._inverted=e,this.stencilStage=Xk.DISABLED,this._graphics&&(this._graphics.stencilStage=Xk.DISABLED)):E(4202)}},{key:"segments",get:function(){return this._segments},set:function(e){this._segments!==e&&(this._segments=cn(e,3,1e4),this._updateGraphics())}},{key:"spriteFrame",get:function(){return this._spriteFrame},set:function(e){if(this._spriteFrame!==e){var t=this._spriteFrame;this._spriteFrame=e,this._type===Sj.IMAGE_STENCIL&&!t&&e&&this.markForUpdateRenderData()}}},{key:"alphaThreshold",get:function(){return this._alphaThreshold},set:function(e){this._alphaThreshold!==e&&(this._alphaThreshold=e,this.type===Sj.IMAGE_STENCIL&&this._graphics&&this._graphics.getMaterialInstance(0).setProperty("alphaThreshold",this._alphaThreshold))}},{key:"graphics",get:function(){return this._graphics}},{key:"dstBlendFactor",get:function(){return this._dstBlendFactor},set:function(e){this._dstBlendFactor!==e&&(this._dstBlendFactor=e,this._updateBlendFunc())}},{key:"srcBlendFactor",get:function(){return this._srcBlendFactor},set:function(e){this._srcBlendFactor!==e&&(this._srcBlendFactor=e,this._updateBlendFunc())}},{key:"color",get:function(){return this._color},set:function(e){this._color!==e&&(this._color.set(e),this.markForUpdateRenderData())}},{key:"customMaterial",get:function(){return this._customMaterial},set:function(){}}]);var n=t.prototype;return n.onLoad=function(){this._createClearModel(),this._createGraphics(),this._graphics&&this._graphics.onLoad()},n.onEnable=function(){e.prototype.onEnable.call(this),this._updateGraphics(),this._broadcastToNode(this.node)},n.onRestore=function(){this._createGraphics(),this._updateGraphics()},n.onDisable=function(){e.prototype.onDisable.call(this),this._disableGraphics()},n.onDestroy=function(){e.prototype.onDestroy.call(this),this._clearModel&&Ow.root.destroyModel(this._clearModel),this._clearStencilMtl&&this._clearStencilMtl.destroy(),this._removeGraphics()},n.isHit=function(e){var t=this.node._uiProps.uiTransformComp,n=t.contentSize,i=n.width,r=n.height,a=Rj;this.node.getWorldMatrix(Cj),Hn.invert(bj,Cj),qn.transformMat4(a,e,bj);var s=t.anchorPoint;a.x+=s.x*i,a.y+=s.y*r;var o=!1;if(this.type===Sj.RECT||this.type===Sj.GRAPHICS_STENCIL)o=a.x>=0&&a.y>=0&&a.x<=i&&a.y<=r;else if(this.type===Sj.ELLIPSE){var c=i/2,l=r/2,u=a.x-.5*i,h=a.y-.5*r;o=u*u/(c*c)+h*h/(l*l)<1}return this._inverted&&(o=!o),o},n._render=function(e){e.commitComp(this,null,this._assembler,null)},n._postRender=function(e){this._postAssembler&&e.commitComp(this,null,this._postAssembler,null)},n._nodeStateChange=function(t){e.prototype._nodeStateChange.call(this,t),this._updateGraphics()},n._canRender=function(){return!!e.prototype._canRender.call(this)&&null!==this._graphics&&(this._type!==Sj.IMAGE_STENCIL||null!==this._spriteFrame)},n._flushAssembler=function(){var e=t.Assembler.getAssembler(this),n=t.PostAssembler.getAssembler(this);this._assembler!==e&&(this.destroyRenderData(),this._assembler=e),this._postAssembler!==n&&(this._postAssembler=n),this._useRenderData()},n._createGraphics=function(){if(!this._graphics){var e=this._graphics=new xj;e.node=this.node,e.node.getWorldMatrix(),e.lineWidth=0;var t=Cn.WHITE.clone();t.a=0,e.fillColor=t}this._updateMaterial()},n._updateGraphics=function(){if(this._graphics&&(this._type===Sj.RECT||this._type===Sj.ELLIPSE)){var e=this.node._uiProps.uiTransformComp,t=this._graphics;t.clear();var n=e.contentSize,i=n.width,r=n.height,a=e.anchorPoint,s=-i*a.x,o=-r*a.y;if(this._type===Sj.RECT)t.rect(s,o,i,r);else if(this._type===Sj.ELLIPSE){for(var c=function(e,t,n){wj.length=0;for(var i=2*Math.PI/n,r=0;r<n;++r)wj.push(new bn(t.x*Math.cos(i*r)+e.x,t.y*Math.sin(i*r)+e.y,0));return wj}(new bn(s+i/2,o+r/2,0),new bn(i/2,r/2,0),this._segments),l=0;l<c.length;++l){var u=c[l];0===l?t.moveTo(u.x,u.y):t.lineTo(u.x,u.y)}t.close()}t.fill()}},n._createClearModel=function(){if(!this._clearModel){var e=Xd.get("default-clear-stencil");this._clearStencilMtl=new sm({parent:e,owner:this,subModelIdx:0}),this._clearModel=Ow.root.createModel(Lp),this._clearModel.node=this._clearModel.transform=this.node;var t=qW(kW),n=i.director.root.device,r=n.createBuffer(new Ps(Ua.VERTEX|Ua.TRANSFER_DST,Ga.DEVICE,4*t,t)),a=new Float32Array([-1,-1,0,1,-1,0,-1,1,0,1,1,0]);r.update(a);var s=n.createBuffer(new Ps(Ua.INDEX|Ua.TRANSFER_DST,Ga.DEVICE,6*Uint16Array.BYTES_PER_ELEMENT,Uint16Array.BYTES_PER_ELEMENT)),o=new Uint16Array([0,1,2,2,1,3]);s.update(o);var c=new Lx([r],kW,Va.TRIANGLE_LIST,s);c.subMeshIdx=0,this._clearModel.initSubModel(0,c,this._clearStencilMtl)}},n._updateMaterial=function(){if(this._graphics){var e,t=this._graphics;t.stencilStage=Xk.DISABLED,this._type===Sj.IMAGE_STENCIL?(e=Xd.get("ui-alpha-test-material"),t.setMaterial(e,0),(e=t.getMaterialInstance(0)).setProperty("alphaThreshold",this._alphaThreshold)):(e=Xd.get("ui-graphics-material"),t.setMaterial(e,0),t.getMaterialInstance(0))}},n._disableGraphics=function(){this._graphics&&this._graphics.onDisable()},n._removeGraphics=function(){this._graphics&&(this._graphics.destroy(),this._graphics._destroyImmediate(),this._graphics=null)},n._useRenderData=function(){this._type!==Sj.IMAGE_STENCIL||this._renderData||this._assembler&&this._assembler.createData&&(this._renderData=this._assembler.createData(this),this.markForUpdateRenderData())},n._broadcastToNode=function(e){var n=e.children;e.eventProcessor.registerComponentHitList(t);for(var i=0,r=n.length;i<r;i++)this._broadcastToNode(n[i])},t}(eW),vj.Type=Sj,J((_j=yj).prototype,"type",[QW,JW,$W],Object.getOwnPropertyDescriptor(_j.prototype,"type"),_j.prototype),J(_j.prototype,"inverted",[ej,tj],Object.getOwnPropertyDescriptor(_j.prototype,"inverted"),_j.prototype),J(_j.prototype,"segments",[nj],Object.getOwnPropertyDescriptor(_j.prototype,"segments"),_j.prototype),J(_j.prototype,"spriteFrame",[ij,rj],Object.getOwnPropertyDescriptor(_j.prototype,"spriteFrame"),_j.prototype),J(_j.prototype,"alphaThreshold",[aj,sj,Ch],Object.getOwnPropertyDescriptor(_j.prototype,"alphaThreshold"),_j.prototype),J(_j.prototype,"dstBlendFactor",[Bh,oj],Object.getOwnPropertyDescriptor(_j.prototype,"dstBlendFactor"),_j.prototype),J(_j.prototype,"srcBlendFactor",[Bh,cj],Object.getOwnPropertyDescriptor(_j.prototype,"srcBlendFactor"),_j.prototype),J(_j.prototype,"color",[Bh,lj],Object.getOwnPropertyDescriptor(_j.prototype,"color"),_j.prototype),J(_j.prototype,"customMaterial",[Bh,uj],Object.getOwnPropertyDescriptor(_j.prototype,"customMaterial"),_j.prototype),fj=J(_j.prototype,"_type",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Sj.RECT}}),dj=J(_j.prototype,"_inverted",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),pj=J(_j.prototype,"_segments",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 64}}),mj=J(_j.prototype,"_spriteFrame",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),gj=J(_j.prototype,"_alphaThreshold",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.1}}),hj=_j))||hj)||hj)||hj)||hj));i.Mask=Ij;var Oj,Pj,Mj,Nj,Dj,Bj,Lj,Fj,zj,Uj,Gj,kj,Hj,Vj,Wj,jj,qj,Xj,Yj,Kj,Zj,Qj,Jj,$j,eq,tq,nq,iq,rq,aq,sq,oq,cq,lq,uq,hq,_q,fq,dq,pq,mq,gq,vq,yq,Sq,Eq,Tq,Aq,xq,Cq,Rq,bq,wq,Iq,Oq,Pq=/^(click)(\s)*=|(param)(\s)*=/,Mq=/(\s)*src(\s)*=|(\s)*height(\s)*=|(\s)*width(\s)*=|(\s)*align(\s)*=|(\s)*offset(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/,Nq=e("HtmlTextParser",function(){function e(){this._specialSymbolArray=[],this._stack=[],this._resultObjectArray=[],this._specialSymbolArray.push([/</g,"<"]),this._specialSymbolArray.push([/>/g,">"]),this._specialSymbolArray.push([/&/g,"&"]),this._specialSymbolArray.push([/"/g,'"']),this._specialSymbolArray.push([/'/g,"'"])}var t=e.prototype;return t.parse=function(e){this._resultObjectArray.length=0,this._stack.length=0;for(var t=0,n=e.length;t<n;){var i=e.indexOf(">",t),r=-1;if(i>=0&&(r=e.lastIndexOf("<",i))<t-1&&(r=e.indexOf("<",i+1),i=e.indexOf(">",r+1)),r<0)this._stack.pop(),this._processResult(e.substring(t)),t=n;else{var a=e.substring(t,r),s=e.substring(r+1,i);""===s&&(a=e.substring(t,i+1)),this._processResult(a),-1===i?i=r:"/"===e.charAt(r+1)?this._stack.pop():this._addToStack(s),t=i+1}}return this._resultObjectArray},t._attributeToObject=function(e){e=e.trim();var t={},n=/^(color|size)(\s)*=/.exec(e),i="",r=0,a="";if(n){if(i=n[0],""===(e=e.substring(i.length).trim()))return t;switch(r=e.indexOf(" "),i[0]){case"c":t.color=r>-1?e.substring(0,r).trim():e;break;case"s":t.size=parseInt(e)}return r>-1&&(a=e.substring(r+1).trim(),t.event=this._processEventHandler(a)),t}if((n=/^(br(\s)*\/)/.exec(e))&&n[0].length>0&&(i=n[0].trim()).startsWith("br")&&"/"===i[i.length-1])return t.isNewLine=!0,this._resultObjectArray.push({text:"",style:{isNewLine:!0}}),t;var s="";if((n=/^(img(\s)*src(\s)*=[^>]+\/)/.exec(e))&&n[0].length>0&&(i=n[0].trim()).startsWith("img")&&"/"===i[i.length-1]){var o;n=Mq.exec(e);for(var c=!1;n;){if(i=(e=e.substring(e.indexOf(n[0]))).substr(0,n[0].length),o=(r=(s=e.substring(i.length).trim()).indexOf(" "))>-1?s.substr(0,r):s,i=(i=i.replace(/[^a-zA-Z]/g,"").trim()).toLowerCase(),e=s.substring(r).trim(),o.endsWith("/")&&(o=o.slice(0,-1)),"src"===i){switch(o.charCodeAt(0)){case 34:case 39:c=!0,o=o.slice(1,-1)}t.isImage=!0,t.src=o}else if("height"===i)t.imageHeight=parseInt(o);else if("width"===i)t.imageWidth=parseInt(o);else if("align"===i){switch(o.charCodeAt(0)){case 34:case 39:o=o.slice(1,-1)}t.imageAlign=o.toLowerCase()}else"offset"===i?t.imageOffset=o:"click"===i&&(t.event=this._processEventHandler(i+"="+o));t.event&&"param"===i&&(t.event[i]=o.replace(/^"|"$/g,"")),n=Mq.exec(e)}return c&&t.isImage&&this._resultObjectArray.push({text:"",style:t}),{}}if(n=/^(outline(\s)*[^>]*)/.exec(e)){var l={color:"#ffffff",width:1};if(e=n[0].substring("outline".length).trim()){var u,h=/(\s)*color(\s)*=|(\s)*width(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/;for(n=h.exec(e);n;)i=(e=e.substring(e.indexOf(n[0]))).substr(0,n[0].length),u=(r=(s=e.substring(i.length).trim()).indexOf(" "))>-1?s.substr(0,r):s,i=(i=i.replace(/[^a-zA-Z]/g,"").trim()).toLowerCase(),e=s.substring(r).trim(),"click"===i?t.event=this._processEventHandler(i+"="+u):"color"===i?l.color=u:"width"===i&&(l.width=parseInt(u)),t.event&&"param"===i&&(t.event[i]=u.replace(/^"|"$/g,"")),n=h.exec(e)}t.outline=l}if((n=/^(on|u|b|i)(\s)*/.exec(e))&&n[0].length>0){switch(i=n[0],e=e.substring(i.length).trim(),i[0]){case"u":t.underline=!0;break;case"i":t.italic=!0;break;case"b":t.bold=!0}if(""===e)return t;t.event=this._processEventHandler(e)}return t},t._processEventHandler=function(e){for(var t={},n=0,i=!1,r=Pq.exec(e);r;){var a=r[0],s="";if(i=!1,'"'===(e=e.substring(a.length).trim()).charAt(0))(n=e.indexOf('"',1))>-1&&(s=e.substring(1,n).trim(),i=!0),n++;else if("'"===e.charAt(0))(n=e.indexOf("'",1))>-1&&(s=e.substring(1,n).trim(),i=!0),n++;else{var o=/(\S)+/.exec(e);n=(s=o?o[0]:"").length}i&&(t[a=a.substring(0,a.length-1).trim()]=s),e=e.substring(n).trim(),r=Pq.exec(e)}return t},t._addToStack=function(e){var t=this._attributeToObject(e);if(0===this._stack.length)this._stack.push(t);else{if(t.isNewLine||t.isImage)return;var n=this._stack[this._stack.length-1];for(var i in n)t[i]||(t[i]=n[i]);this._stack.push(t)}},t._processResult=function(e){0!==e.length&&(e=this._escapeSpecialSymbol(e),this._stack.length>0?this._resultObjectArray.push({text:e,style:this._stack[this._stack.length-1]}):this._resultObjectArray.push({text:e}))},t._escapeSpecialSymbol=function(e){for(var t,n=Z(this._specialSymbolArray);!(t=n()).done;){var i=t.value,r=i[0],a=i[1];e=e.replace(r,a)}return e},e}()),Dq=function(t){return e({LabelOutline:t,LabelOutlineComponent:t}),t}((Oj=ih("cc.LabelOutline"),Pj=mh(),Mj=ah(110),Nj=_h(),Dj=rh(rW),Bj=Sh(),Lj=Sh(),Oj(Fj=Pj(Fj=Mj(Fj=Nj(Fj=Dj(Fj=hh((kj=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return Q(t=e.call.apply(e,[this].concat(i))||this,"_color",Uj,Y(t)),Q(t,"_width",Gj,Y(t)),t}X(t,e);var n=t.prototype;return n.onEnable=function(){this._updateRenderData()},n.onDisable=function(){this._updateRenderData()},n._updateRenderData=function(){var e=this.node.getComponent(rW);e&&e.updateRenderData(!0)},j(t,[{key:"color",get:function(){return this._color},set:function(e){this._color!==e&&(this._color.set(e),this._updateRenderData())}},{key:"width",get:function(){return this._width},set:function(e){this._width!==e&&(this._width=e,this._updateRenderData())}}]),t}(Kf),Uj=J((zj=kj).prototype,"_color",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Cn(0,0,0,255)}}),Gj=J(zj.prototype,"_width",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 2}}),J(zj.prototype,"color",[Bj],Object.getOwnPropertyDescriptor(zj.prototype,"color"),zj.prototype),J(zj.prototype,"width",[Lj],Object.getOwnPropertyDescriptor(zj.prototype,"width"),zj.prototype),Fj=zj))||Fj)||Fj)||Fj)||Fj)||Fj)||Fj));!function(e){e[e.SIMPLE=0]="SIMPLE",e[e.SLICED=1]="SLICED",e[e.TILED=2]="TILED",e[e.FILLED=3]="FILLED"}(bq||(bq={})),ht(bq),function(e){e[e.HORIZONTAL=0]="HORIZONTAL",e[e.VERTICAL=1]="VERTICAL",e[e.RADIAL=2]="RADIAL"}(wq||(wq={})),ht(wq),function(e){e[e.CUSTOM=0]="CUSTOM",e[e.TRIMMED=1]="TRIMMED",e[e.RAW=2]="RAW"}(Iq||(Iq={})),ht(Iq),function(e){e.SPRITE_FRAME_CHANGED="spriteframe-changed"}(Oq||(Oq={}));var Bq,Lq,Fq,zq,Uq,Gq,kq,Hq,Vq,Wq,jq,qq,Xq,Yq,Kq=function(t){return e({Sprite:t,SpriteComponent:t}),t}((Hj=ih("cc.Sprite"),Vj=mh(),Wj=ah(110),jj=_h(),qj=Dh(KG),Xj=Rh(),Yj=Sh(),Kj=Dh(XG),Zj=Rh(),Qj=Sh(),Jj=Dh(bq),$j=Rh(),eq=Sh(),tq=Dh(wq),nq=Sh(),iq=Sh(),rq=Eh(),aq=Sh(),sq=Eh(),oq=Sh(),cq=Rh(),lq=Sh(),uq=Dh(Iq),hq=Rh(),_q=Sh(),Hj(fq=Vj(fq=Wj(fq=jj((Rq=Cq=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return Q(t=e.call.apply(e,[this].concat(i))||this,"_spriteFrame",pq,Y(t)),Q(t,"_type",mq,Y(t)),Q(t,"_fillType",gq,Y(t)),Q(t,"_sizeMode",vq,Y(t)),Q(t,"_fillCenter",yq,Y(t)),Q(t,"_fillStart",Sq,Y(t)),Q(t,"_fillRange",Eq,Y(t)),Q(t,"_isTrimmedMode",Tq,Y(t)),Q(t,"_useGrayscale",Aq,Y(t)),Q(t,"_atlas",xq,Y(t)),t}X(t,e);var n=t.prototype;return n.__preload=function(){this.changeMaterialForDefine(),e.prototype.__preload.call(this),this._spriteFrame&&(this._spriteFrame.on("load",this._markForUpdateUvDirty,this),this._markForUpdateUvDirty())},n.onEnable=function(){e.prototype.onEnable.call(this),this._activateMaterial()},n.onDestroy=function(){this.destroyRenderData(),this._spriteFrame&&this._spriteFrame.off("load"),e.prototype.onDestroy.call(this)},n.changeSpriteFrameFromAtlas=function(e){if(this._atlas){var t=this._atlas.getSpriteFrame(e);this.spriteFrame=t}else console.warn("SpriteAtlas is null.")},n.changeMaterialForDefine=function(){var e;this._spriteFrame&&(e=this._spriteFrame.texture);var t=!1;if(e instanceof of){var n=e.getPixelFormat();t=n===O_.RGBA_ETC1||n===O_.RGB_A_PVRTC_4BPPV1||n===O_.RGB_A_PVRTC_2BPPV1}t&&this.grayscale?this._instanceMaterialType=HH.USE_ALPHA_SEPARATED_AND_GRAY:t?this._instanceMaterialType=HH.USE_ALPHA_SEPARATED:this.grayscale?this._instanceMaterialType=HH.GRAYSCALE:this._instanceMaterialType=HH.ADD_COLOR_AND_TEXTURE,this.updateMaterial()},n._render=function(e){e.commitComp(this,this._spriteFrame,this._assembler,null)},n._canRender=function(){if(!e.prototype._canRender.call(this))return!1;var t=this._spriteFrame;return!(!t||!t.textureLoaded())},n._flushAssembler=function(){var e=t.Assembler.getAssembler(this);this._assembler!==e&&(this.destroyRenderData(),this._assembler=e),this._renderData||this._assembler&&this._assembler.createData&&(this._renderData=this._assembler.createData(this),this._renderData.material=this.getRenderMaterial(0),this.markForUpdateRenderData(),this._updateColor())},n._applySpriteSize=function(){if(this._spriteFrame){if(Iq.RAW===this._sizeMode){var e=this._spriteFrame.originalSize;this.node._uiProps.uiTransformComp.setContentSize(e)}else if(Iq.TRIMMED===this._sizeMode){var t=this._spriteFrame.getRect();this.node._uiProps.uiTransformComp.setContentSize(t.width,t.height)}this._activateMaterial()}},n._resized=function(){},n._activateMaterial=function(){var e=this._spriteFrame,t=this.getRenderMaterial(0);i.game.renderType!==i.game.RENDER_TYPE_CANVAS?(e&&t&&this.markForUpdateRenderData(),this._renderData&&(this._renderData.material=t)):this.markForUpdateRenderData()},n._onTextureLoaded=function(){this.isValid&&(this.changeMaterialForDefine(),this._applySpriteSize())},n._applySpriteFrame=function(e){var t=this._spriteFrame;this._renderData&&(e&&e.off("load",this._markForUpdateUvDirty),t&&t.on("load",this._markForUpdateUvDirty,this),this._renderData.uvDirty||(this._renderData.uvDirty=!e||!t||e.uvHash!==t.uvHash),this._renderDataFlag=this._renderData.uvDirty),t&&(e&&t===e||(t.loaded?this._onTextureLoaded():t.once("load",this._onTextureLoaded,this)))},n._markForUpdateUvDirty=function(){this._renderData&&(this._renderData.uvDirty=!0,this._renderDataFlag=!0)},j(t,[{key:"spriteAtlas",get:function(){return this._atlas},set:function(e){this._atlas!==e&&(this._atlas=e)}},{key:"spriteFrame",get:function(){return this._spriteFrame},set:function(e){if(this._spriteFrame!==e){var t=this._spriteFrame;this._spriteFrame=e,this.markForUpdateRenderData(!1),this._applySpriteFrame(t)}}},{key:"type",get:function(){return this._type},set:function(e){this._type!==e&&(this._type=e,this._flushAssembler())}},{key:"fillType",get:function(){return this._fillType},set:function(e){this._fillType!==e&&(e===wq.RADIAL||this._fillType===wq.RADIAL?(this.destroyRenderData(),this._renderData=null):this._renderData&&this.markForUpdateRenderData(!0)),this._fillType=e,this._flushAssembler()}},{key:"fillCenter",get:function(){return this._fillCenter},set:function(e){this._fillCenter.x=e.x,this._fillCenter.y=e.y,this._type===bq.FILLED&&this._renderData&&this.markForUpdateRenderData()}},{key:"fillStart",get:function(){return this._fillStart},set:function(e){this._fillStart=cn(e,-1,1),this._type===bq.FILLED&&this._renderData&&(this.markForUpdateRenderData(),this._renderData.uvDirty=!0)}},{key:"fillRange",get:function(){return this._fillRange},set:function(e){this._fillRange=cn(e,-1,1),this._type===bq.FILLED&&this._renderData&&(this.markForUpdateRenderData(),this._renderData.uvDirty=!0)}},{key:"trim",get:function(){return this._isTrimmedMode},set:function(e){this._isTrimmedMode!==e&&(this._isTrimmedMode=e,this._type===bq.SIMPLE&&this._renderData&&this.markForUpdateRenderData(!0))}},{key:"grayscale",get:function(){return this._useGrayscale},set:function(e){this._useGrayscale!==e&&(this._useGrayscale=e,this._instanceMaterialType=!0===e?HH.GRAYSCALE:HH.ADD_COLOR_AND_TEXTURE,this.updateMaterial())}},{key:"sizeMode",get:function(){return this._sizeMode},set:function(e){this._sizeMode!==e&&(this._sizeMode=e,e!==Iq.CUSTOM&&this._applySpriteSize())}}]),t}(eW),Cq.FillType=wq,Cq.Type=bq,Cq.SizeMode=Iq,Cq.EventType=Oq,J((dq=Rq).prototype,"spriteAtlas",[qj,Xj,Yj],Object.getOwnPropertyDescriptor(dq.prototype,"spriteAtlas"),dq.prototype),J(dq.prototype,"spriteFrame",[Kj,Zj,Qj],Object.getOwnPropertyDescriptor(dq.prototype,"spriteFrame"),dq.prototype),J(dq.prototype,"type",[Jj,$j,eq],Object.getOwnPropertyDescriptor(dq.prototype,"type"),dq.prototype),J(dq.prototype,"fillType",[tq,nq],Object.getOwnPropertyDescriptor(dq.prototype,"fillType"),dq.prototype),J(dq.prototype,"fillCenter",[iq],Object.getOwnPropertyDescriptor(dq.prototype,"fillCenter"),dq.prototype),J(dq.prototype,"fillStart",[rq,aq],Object.getOwnPropertyDescriptor(dq.prototype,"fillStart"),dq.prototype),J(dq.prototype,"fillRange",[sq,oq],Object.getOwnPropertyDescriptor(dq.prototype,"fillRange"),dq.prototype),J(dq.prototype,"trim",[cq,lq],Object.getOwnPropertyDescriptor(dq.prototype,"trim"),dq.prototype),J(dq.prototype,"grayscale",[gh],Object.getOwnPropertyDescriptor(dq.prototype,"grayscale"),dq.prototype),J(dq.prototype,"sizeMode",[uq,hq,_q],Object.getOwnPropertyDescriptor(dq.prototype,"sizeMode"),dq.prototype),pq=J(dq.prototype,"_spriteFrame",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),mq=J(dq.prototype,"_type",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return bq.SIMPLE}}),gq=J(dq.prototype,"_fillType",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return wq.HORIZONTAL}}),vq=J(dq.prototype,"_sizeMode",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Iq.TRIMMED}}),yq=J(dq.prototype,"_fillCenter",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new qn(0,0)}}),Sq=J(dq.prototype,"_fillStart",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Eq=J(dq.prototype,"_fillRange",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Tq=J(dq.prototype,"_isTrimmedMode",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Aq=J(dq.prototype,"_useGrayscale",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),xq=J(dq.prototype,"_atlas",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),fq=dq))||fq)||fq)||fq)||fq)),Zq=e("RenderRoot2D",ih("cc.RenderRoot2D")(Bq=ah(100)(Bq=_h()(Bq=rh(pH)(Bq=sh(Bq=hh(Bq=function(e){function t(){return e.apply(this,arguments)||this}X(t,e);var n=t.prototype;return n.onEnable=function(){i.director.root.batcher2D.addScreen(this)},n.onDisable=function(){i.director.root.batcher2D.removeScreen(this)},n.onDestroy=function(){i.director.root.batcher2D.removeScreen(this)},t}(Kf))||Bq)||Bq)||Bq)||Bq)||Bq)||Bq),Qq=new bn,Jq=ct({OVERLAY:0,INTERSPERSE:1}),$q=function(t){return e({Canvas:t,CanvasComponent:t}),t}((Lq=ih("cc.Canvas"),Fq=mh(),zq=ah(100),Uq=_h(),Gq=Dh(wP),kq=Sh(),Hq=Sh(),Vq=Dh(wP),Lq(Wq=Fq(Wq=zq(Wq=Uq(Wq=hh(Wq=sh((J((jq=function(e){function t(){var t;return Q(t=e.call(this)||this,"_cameraComponent",qq,Y(t)),Q(t,"_alignCanvasWithScreen",Xq,Y(t)),t._thisOnCameraResized=void 0,t._fitDesignResolution=void 0,t._pos=new bn,t._renderMode=Jq.OVERLAY,t._thisOnCameraResized=t._onResizeCamera.bind(Y(t)),t}X(t,e),j(t,[{key:"renderMode",get:function(){return this._renderMode},set:function(e){this._renderMode=e,this._cameraComponent&&(this._cameraComponent.priority=this._getViewPriority())}},{key:"cameraComponent",get:function(){return this._cameraComponent},set:function(e){this._cameraComponent!==e&&(this._cameraComponent=e,this._onResizeCamera())}},{key:"alignCanvasWithScreen",get:function(){return this._alignCanvasWithScreen},set:function(e){this._alignCanvasWithScreen=e,this._onResizeCamera()}}]);var n=t.prototype;return n.__preload=function(){var e=this.getComponent("cc.Widget");e&&e.updateAlignment(),this._cameraComponent&&this._cameraComponent._createCamera(),this._onResizeCamera(),this.node.on(JA.TRANSFORM_CHANGED,this._thisOnCameraResized)},n.onDestroy=function(){e.prototype.onDestroy.call(this),this.node.off(JA.TRANSFORM_CHANGED,this._thisOnCameraResized)},n._onResizeCamera=function(){if(this._cameraComponent&&this._alignCanvasWithScreen){if(this._cameraComponent.targetTexture){var e=this._cameraComponent.targetTexture.window;this._cameraComponent.camera&&this._cameraComponent.camera.setFixedSize(e.width,e.height),this._cameraComponent.orthoHeight=qA.height/2}else if(jA.canvas){var t=jA.canvas;this._cameraComponent.camera&&this._cameraComponent.camera.resize(t.width,t.height),this._cameraComponent.orthoHeight=jA.canvas.height/$A.getScaleY()/2}this.node.getWorldPosition(Qq),this._cameraComponent.node.setWorldPosition(Qq.x,Qq.y,1e3)}},n._getViewPriority=function(){if(this._cameraComponent){var e,t=null===(e=this.cameraComponent)||void 0===e?void 0:e.priority;return this._renderMode===Jq.OVERLAY?t|1<<30:t&~(1<<30)}return 0},t}(Zq)).prototype,"cameraComponent",[Gq,kq],Object.getOwnPropertyDescriptor(jq.prototype,"cameraComponent"),jq.prototype),J(jq.prototype,"alignCanvasWithScreen",[Hq],Object.getOwnPropertyDescriptor(jq.prototype,"alignCanvasWithScreen"),jq.prototype),qq=J(jq.prototype,"_cameraComponent",[Vq],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Xq=J(jq.prototype,"_alignCanvasWithScreen",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Wq=jq))||Wq)||Wq)||Wq)||Wq)||Wq)||Wq));i.Canvas=$q;var eX,tX,nX,iX,rX,aX,sX,oX,cX,lX,uX,hX,_X,fX,dX,pX,mX,gX,vX,yX,SX,EX,TX,AX,xX,CX,RX,bX,wX,IX,OX,PX,MX,NX,DX,BX=e("UIComponent",ih("cc.UIComponent")(Yq=rh(pH)(Yq=ah(110)(Yq=sh(Yq=hh(Yq=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._lastParent=null,t.stencilStage=Xk.DISABLED,t}X(t,e);var n=t.prototype;return n.__preload=function(){this.node._uiProps.uiComp=this},n.onEnable=function(){},n.onDisable=function(){},n.onDestroy=function(){this.node._uiProps.uiComp===this&&(this.node._uiProps.uiComp=null)},n.updateAssembler=function(){},n.postUpdateAssembler=function(){},t}(Kf))||Yq)||Yq)||Yq)||Yq)||Yq);oe(BX.prototype,"UIComponent",[{name:"_visibility"},{name:"setVisibility"}]),se($q.prototype,"Canvas.prototype",[{name:"camera",newName:"cameraComponent.camera",customGetter:function(){return this._cameraComponent.camera}},{name:"clearFlag",newName:"cameraComponent.clearFlags",customGetter:function(){return this._cameraComponent?this._cameraComponent.clearFlags:0},customSetter:function(e){this._cameraComponent&&(this._cameraComponent.clearFlags=e)}},{name:"color",newName:"cameraComponent.clearColor",customGetter:function(){return this._cameraComponent?this._cameraComponent.clearColor:Cn.BLACK},customSetter:function(e){this._cameraComponent&&(this._cameraComponent.clearColor=e)}},{name:"priority",newName:"cameraComponent.priority",customGetter:function(){return this._cameraComponent?this._cameraComponent.priority:0},customSetter:function(e){this._cameraComponent&&(this._cameraComponent.priority=e)}},{name:"targetTexture",newName:"cameraComponent.targetTexture",customGetter:function(){return this._cameraComponent?this._cameraComponent.targetTexture:null},customSetter:function(e){this._cameraComponent&&(this._cameraComponent.targetTexture=e)}},{name:"visibility",newName:"cameraComponent.visibility",customGetter:function(){return this._cameraComponent?this._cameraComponent.visibility:0}}]),i.UITransformComponent=pH,st.setClassAlias(pH,"cc.UITransformComponent"),st.setClassAlias(eW,"cc.RenderComponent"),i.CanvasComponent=$q,st.setClassAlias($q,"cc.CanvasComponent");var LX=new Nq,FX=new rt((function(e){if(!i.isValid(e.node))return!1;var t=e.node.getComponent(Dq);return t&&(t.width=0),!0}),20),zX=new rt((function(e){return i.isValid(e.node)}),10);function UX(e){return{node:new iw(e),comp:null,lineCount:0,styleIndex:0,imageOffset:"",clickParam:"",clickHandler:"",type:e}}function GX(e,t){var n;"RICHTEXT_CHILD"===e?n=FX._get():"RICHTEXT_Image_CHILD"===e&&(n=zX._get());var i=(n=n||UX(e)).node;return i||(i=new iw(e)),"RICHTEXT_Image_CHILD"===e?(n.comp=i.getComponent(Kq)||i.addComponent(Kq),n.comp.spriteFrame=t,n.comp.type=Kq.Type.SLICED,n.comp.sizeMode=Kq.SizeMode.CUSTOM):(n.comp=i.getComponent(rW)||i.addComponent(rW),n.comp.string=t,n.comp.horizontalAlign=ZV.LEFT,n.comp.verticalAlign=QV.TOP),i.setPosition(0,0,0),i._uiProps.uiTransformComp.setAnchorPoint(.5,.5),n.node=i,n.lineCount=0,n.styleIndex=0,n.imageOffset="",n.clickParam="",n.clickHandler="",n}var kX,HX=function(t){return e({RichText:t,RichTextComponent:t}),t}((eX=ih("cc.RichText"),tX=mh(),nX=ah(110),iX=_h(),rX=Sh(),aX=Dh(ZV),sX=Sh(),oX=Sh(),cX=Sh(),lX=Dh(ek),uX=Sh(),hX=Sh(),_X=Dh($V),fX=Sh(),dX=Sh(),pX=Sh(),mX=Dh(KG),gX=Sh(),vX=Sh(),eX(yX=tX(yX=nX(yX=iX(yX=hh((DX=NX=function(e){function t(){var t;return Q(t=e.call(this)||this,"_lineHeight",EX,Y(t)),Q(t,"_string",TX,Y(t)),Q(t,"_horizontalAlign",AX,Y(t)),Q(t,"_fontSize",xX,Y(t)),Q(t,"_maxWidth",CX,Y(t)),Q(t,"_fontFamily",RX,Y(t)),Q(t,"_font",bX,Y(t)),Q(t,"_isSystemFontUsed",wX,Y(t)),Q(t,"_userDefinedFont",IX,Y(t)),Q(t,"_cacheMode",OX,Y(t)),Q(t,"_imageAtlas",PX,Y(t)),Q(t,"_handleTouchEvent",MX,Y(t)),t._textArray=[],t._segments=[],t._labelSegmentsCache=[],t._linesWidth=[],t._lineCount=1,t._labelWidth=0,t._labelHeight=0,t._layoutDirty=!0,t._lineOffsetX=0,t._updateRichTextStatus=void 0,t._updateRichTextStatus=t._updateRichText,t}X(t,e),j(t,[{key:"string",get:function(){return this._string},set:function(e){this._string!==e&&(this._string=e,this._updateRichTextStatus())}},{key:"horizontalAlign",get:function(){return this._horizontalAlign},set:function(e){this.horizontalAlign!==e&&(this._horizontalAlign=e,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"fontSize",get:function(){return this._fontSize},set:function(e){this._fontSize!==e&&(this._fontSize=e,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"fontFamily",get:function(){return this._fontFamily},set:function(e){this._fontFamily!==e&&(this._fontFamily=e,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"font",get:function(){return this._font},set:function(e){this._font!==e&&(this._font=e,this._layoutDirty=!0,this._font?(this.useSystemFont=!1,this._onTTFLoaded()):this.useSystemFont=!0,this._updateRichTextStatus())}},{key:"useSystemFont",get:function(){return this._isSystemFontUsed},set:function(e){this._isSystemFontUsed!==e&&(this._isSystemFontUsed=e,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"cacheMode",get:function(){return this._cacheMode},set:function(e){this._cacheMode!==e&&(this._cacheMode=e,this._updateRichTextStatus())}},{key:"maxWidth",get:function(){return this._maxWidth},set:function(e){this._maxWidth!==e&&(this._maxWidth=e,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"lineHeight",get:function(){return this._lineHeight},set:function(e){this._lineHeight!==e&&(this._lineHeight=e,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"imageAtlas",get:function(){return this._imageAtlas},set:function(e){this._imageAtlas!==e&&(this._imageAtlas=e,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"handleTouchEvent",get:function(){return this._handleTouchEvent},set:function(e){this._handleTouchEvent!==e&&(this._handleTouchEvent=e,this.enabledInHierarchy&&(this.handleTouchEvent?this._addEventListeners():this._removeEventListeners()))}}]);var n=t.prototype;return n.onLoad=function(){this.node.on(JA.LAYER_CHANGED,this._applyLayer,this)},n.onEnable=function(){this.handleTouchEvent&&this._addEventListeners(),this._updateRichText(),this._activateChildren(!0)},n.onDisable=function(){this.handleTouchEvent&&this._removeEventListeners(),this._activateChildren(!1)},n.start=function(){this._onTTFLoaded(),this.node.on(RC.EventType.ANCHOR_CHANGED,this._updateRichTextPosition,this)},n.onRestore=function(){},n.onDestroy=function(){for(var e,t=Z(this._segments);!(e=t()).done;){var n=e.value;n.node.removeFromParent(),"RICHTEXT_CHILD"===n.type?FX.put(n):"RICHTEXT_Image_CHILD"===n.type&&zX.put(n)}this.node.off(RC.EventType.ANCHOR_CHANGED,this._updateRichTextPosition,this),this.node.off(JA.LAYER_CHANGED,this._applyLayer,this)},n._addEventListeners=function(){this.node.on(RC.EventType.TOUCH_END,this._onTouchEnded,this)},n._removeEventListeners=function(){this.node.off(RC.EventType.TOUCH_END,this._onTouchEnded,this)},n._updateLabelSegmentTextAttributes=function(){var e=this;this._segments.forEach((function(t){e._applyTextAttribute(t)}))},n._createFontLabel=function(e){return GX("RICHTEXT_CHILD",e)},n._createImage=function(e){return GX("RICHTEXT_Image_CHILD",e)},n._onTTFLoaded=function(){var e=this;this._font instanceof uk?this._font._nativeAsset?(this._layoutDirty=!0,this._updateRichText()):OI.postLoadNative(this._font,(function(){e.isValid&&(e._layoutDirty=!0,e._updateRichText())})):(this._layoutDirty=!0,this._updateRichText())},n._measureText=function(e,t){var n=this,i=function(t){var i;return 0===n._labelSegmentsCache.length?(i=n._createFontLabel(t),n._labelSegmentsCache.push(i)):(i=n._labelSegmentsCache[0]).node.getComponent(rW).string=t,i.styleIndex=e,n._applyTextAttribute(i),i.node._uiProps.uiTransformComp.contentSize.width};return t?i(t):i},n._onTouchEnded=function(e){for(var t,n=this,i=this.node.getComponents(Kf),r=function(){var r=t.value,a=r.clickHandler,s=r.clickParam;a&&n._containsTouchLocation(r,e.touch.getUILocation())&&(i.forEach((function(t){var n=t[a];t.enabledInHierarchy&&n&&n.call(t,e,s)})),e.propagationStopped=!0)},a=Z(this._segments);!(t=a()).done;)r()},n._containsTouchLocation=function(e,t){var n=e.node.getComponent(pH);return!!n&&n.getBoundingBoxToWorld().contains(t)},n._resetState=function(){for(var e=this.node.children,t=e.length-1;t>=0;t--){var n=e[t];if("RICHTEXT_CHILD"===n.name||"RICHTEXT_Image_CHILD"===n.name){n.parent===this.node?n.parent=null:e.splice(t,1);var i=UX(n.name);i.node=n,"RICHTEXT_CHILD"===n.name?(i.comp=n.getComponent(rW),FX.put(i)):(i.comp=n.getComponent(Kq),zX.put(i))}}e.length=0,this._segments.length=0,this._labelSegmentsCache.length=0,this._linesWidth.length=0,this._lineOffsetX=0,this._lineCount=1,this._labelWidth=0,this._labelHeight=0,this._layoutDirty=!0},n._activateChildren=function(e){for(var t=this.node.children.length-1;t>=0;t--){var n=this.node.children[t];"RICHTEXT_CHILD"!==n.name&&"RICHTEXT_Image_CHILD"!==n.name||(n.active=e)}},n._addLabelSegment=function(e,t){var n;if(0===this._labelSegmentsCache.length)n=this._createFontLabel(e);else{var i=(n=this._labelSegmentsCache.pop()).node.getComponent(rW);i&&(i.string=e)}return n.styleIndex=t,n.lineCount=this._lineCount,n.node._uiProps.uiTransformComp.setAnchorPoint(0,0),n.node.layer=this.node.layer,this._applyTextAttribute(n),this.node.addChild(n.node),this._segments.push(n),n},n._updateRichTextWithMaxWidth=function(e,t,n){var i=t;if(this._lineOffsetX>0&&i+this._lineOffsetX>this._maxWidth)for(var r=0;this._lineOffsetX<=this._maxWidth;){var a=this._getFirstWordLen(e,r,e.length),s=e.substr(r,a),o=this._measureText(n,s);if(!(this._lineOffsetX+o<=this._maxWidth)){if(r>0){var c=e.substr(0,r);this._addLabelSegment(c,n),e=e.substr(r,e.length),i=this._measureText(n,e)}this._updateLineInfo();break}this._lineOffsetX+=o,r+=a}if(i>this._maxWidth)for(var l=Ok(e,i,this._maxWidth,this._measureText(n)),u=0;u<l.length;++u){var h=l[u],_=this._addLabelSegment(h,n).node._uiProps.uiTransformComp.contentSize;this._lineOffsetX+=_.width,l.length>1&&u<l.length-1&&this._updateLineInfo()}else this._lineOffsetX+=i,this._addLabelSegment(e,n)},n._isLastComponentCR=function(e){return e.length-1===e.lastIndexOf("\n")},n._updateLineInfo=function(){this._linesWidth.push(this._lineOffsetX),this._lineOffsetX=0,this._lineCount++},n._needsUpdateTextLayout=function(e){if(this._layoutDirty||!this._textArray||!e)return!0;if(this._textArray.length!==e.length)return!0;for(var t=0;t<this._textArray.length;t++){var n=this._textArray[t],i=e[t];if(n.text!==i.text)return!0;var r=n.style,a=i.style;if(r){if(a){if(!!a.outline!=!!r.outline)return!0;if(r.size!==a.size||r.italic!==a.italic||r.isImage!==a.isImage)return!0;if(r.src!==a.src||r.imageAlign!==a.imageAlign||r.imageHeight!==a.imageHeight||r.imageWidth!==a.imageWidth||r.imageOffset!==a.imageOffset)return!0}else if(r.size||r.italic||r.isImage||r.outline)return!0}else if(a&&(a.size||a.italic||a.isImage||a.outline))return!0}return!1},n._addRichTextImageElement=function(e){if(e.style){var t=e.style,n=t.src,i=this._imageAtlas&&n&&this._imageAtlas.getSpriteFrame(n);if(i){var r=this._createImage(i);switch(r.comp,t.imageAlign){case"top":r.node._uiProps.uiTransformComp.setAnchorPoint(0,1);break;case"center":r.node._uiProps.uiTransformComp.setAnchorPoint(0,.5);break;default:r.node._uiProps.uiTransformComp.setAnchorPoint(0,0)}r.node.layer=this.node.layer,this.node.addChild(r.node),this._segments.push(r);var a=i.rect.clone(),s=1,o=a.width,c=a.height,l=t.imageWidth||0,u=t.imageHeight||0;u>0?(o*=s=u/c,c*=s):(o*=s=this._lineHeight/c,c*=s),l>0&&(o=l),this._maxWidth>0?(this._lineOffsetX+o>this._maxWidth&&this._updateLineInfo(),this._lineOffsetX+=o):(this._lineOffsetX+=o,this._lineOffsetX>this._labelWidth&&(this._labelWidth=this._lineOffsetX)),r.node._uiProps.uiTransformComp.setContentSize(o,c),r.lineCount=this._lineCount,r.clickHandler="",r.clickParam="";var h=t.event;h&&(r.clickHandler=h.click,r.clickParam=h.param)}else E(4400)}},n._updateRichText=function(){if(this.enabledInHierarchy){var e=LX.parse(this._string);if(!this._needsUpdateTextLayout(e))return this._textArray=e.slice(),void this._updateLabelSegmentTextAttributes();this._textArray=e.slice(),this._resetState();for(var t,n=!1,i=0;i<this._textArray.length;++i){var r=this._textArray[i],a=r.text;if(void 0!==a){if(""===a){if(r.style&&r.style.isNewLine){this._updateLineInfo();continue}if(r.style&&r.style.isImage&&this._imageAtlas){this._addRichTextImageElement(r);continue}}for(var s=a.split("\n"),o=0;o<s.length;++o){var c=s[o];if(""!==c)if(n=!1,this._maxWidth>0){var l=this._measureText(i,c);this._updateRichTextWithMaxWidth(c,l,i),s.length>1&&o<s.length-1&&this._updateLineInfo()}else t=this._addLabelSegment(c,i),this._lineOffsetX+=t.node._uiProps.uiTransformComp.width,this._lineOffsetX>this._labelWidth&&(this._labelWidth=this._lineOffsetX),s.length>1&&o<s.length-1&&this._updateLineInfo();else{if(this._isLastComponentCR(a)&&o===s.length-1)continue;this._updateLineInfo(),n=!0}}}}n||this._linesWidth.push(this._lineOffsetX),this._maxWidth>0&&(this._labelWidth=this._maxWidth),this._labelHeight=(this._lineCount+mk)*this._lineHeight,this.node._uiProps.uiTransformComp.setContentSize(this._labelWidth,this._labelHeight),this._updateRichTextPosition(),this._layoutDirty=!1}},n._getFirstWordLen=function(e,t,n){var i=e.charAt(t);if(Rk(i)||bk(i))return 1;for(var r=1,a=t+1;a<n&&!bk(i=e.charAt(a))&&!Rk(i);++a)r++;return r},n._updateRichTextPosition=function(){for(var e=0,t=1,n=this._lineCount,i=this.node._uiProps.uiTransformComp,r=i.anchorX,a=i.anchorY,s=0;s<this._segments.length;++s){var o=this._segments[s],c=o.lineCount;c>t&&(e=0,t=c);var l=this._labelWidth*(.5*this._horizontalAlign-r);switch(this._horizontalAlign){case ZV.LEFT:break;case ZV.CENTER:l-=this._linesWidth[c-1]/2;break;case ZV.RIGHT:l-=this._linesWidth[c-1]}var u=o.node.position;if(o.node.setPosition(e+l,this._lineHeight*(n-c)-this._labelHeight*a,u.z),c===t&&(e+=o.node._uiProps.uiTransformComp.width),o.node.getComponent(Kq)){var h=o.node.position.clone(),_=this._lineHeight,f=this._lineHeight*(1+mk);switch(o.node._uiProps.uiTransformComp.anchorY){case 1:h.y+=_+(f-_)/2;break;case.5:h.y+=f/2;break;default:h.y+=(f-_)/2}if(o.imageOffset){var d=o.imageOffset.split(",");if(1===d.length&&d[0]){var p=parseFloat(d[0]);Number.isInteger(p)&&(h.y+=p)}else if(2===d.length){var m=parseFloat(d[0]),g=parseFloat(d[1]);Number.isInteger(m)&&(h.x+=m),Number.isInteger(g)&&(h.y+=g)}}o.node.position=h}var v=o.node.getComponent(Dq);if(v){var y=o.node.position.clone();y.y-=v.width,o.node.position=y}}},n._convertLiteralColorValue=function(e){var t=e.toUpperCase();return Cn[t]?Cn[t]:(new Cn).fromHEX(e)},n._applyTextAttribute=function(e){var t=e.node.getComponent(rW);if(t){var n,i=e.styleIndex;if(this._textArray[i]&&(n=this._textArray[i].style),n){if(t.color=this._convertLiteralColorValue(n.color||"white"),t.isBold=!!n.bold,t.isItalic=!!n.italic,t.isUnderline=!!n.underline,n.outline){var r=e.node.getComponent(Dq);r||(r=e.node.addComponent(Dq)),r.color=this._convertLiteralColorValue(n.outline.color),r.width=n.outline.width}t.fontSize=n.size||this._fontSize,e.clickHandler="",e.clickParam="";var a=n.event;a&&(e.clickHandler=a.click||"",e.clickParam=a.param||"")}else t.fontSize=this._fontSize;t.cacheMode=this._cacheMode,this._font instanceof ek&&!this._isSystemFontUsed?t.font=this._font:t.fontFamily=this._fontFamily,t.useSystemFont=this._isSystemFontUsed,t.lineHeight=this._lineHeight,t.updateRenderData(!0);var s=t._assembler;s&&s.updateRenderData(t)}},n._applyLayer=function(){for(var e,t=Z(this._segments);!(e=t()).done;)e.value.node.layer=this.node.layer},t}(BX),NX.HorizontalAlign=ZV,NX.VerticalAlign=QV,J((SX=DX).prototype,"string",[wh,rX],Object.getOwnPropertyDescriptor(SX.prototype,"string"),SX.prototype),J(SX.prototype,"horizontalAlign",[aX,sX],Object.getOwnPropertyDescriptor(SX.prototype,"horizontalAlign"),SX.prototype),J(SX.prototype,"fontSize",[oX],Object.getOwnPropertyDescriptor(SX.prototype,"fontSize"),SX.prototype),J(SX.prototype,"fontFamily",[cX],Object.getOwnPropertyDescriptor(SX.prototype,"fontFamily"),SX.prototype),J(SX.prototype,"font",[lX,uX],Object.getOwnPropertyDescriptor(SX.prototype,"font"),SX.prototype),J(SX.prototype,"useSystemFont",[hX],Object.getOwnPropertyDescriptor(SX.prototype,"useSystemFont"),SX.prototype),J(SX.prototype,"cacheMode",[_X,fX],Object.getOwnPropertyDescriptor(SX.prototype,"cacheMode"),SX.prototype),J(SX.prototype,"maxWidth",[dX],Object.getOwnPropertyDescriptor(SX.prototype,"maxWidth"),SX.prototype),J(SX.prototype,"lineHeight",[pX],Object.getOwnPropertyDescriptor(SX.prototype,"lineHeight"),SX.prototype),J(SX.prototype,"imageAtlas",[mX,gX],Object.getOwnPropertyDescriptor(SX.prototype,"imageAtlas"),SX.prototype),J(SX.prototype,"handleTouchEvent",[vX],Object.getOwnPropertyDescriptor(SX.prototype,"handleTouchEvent"),SX.prototype),EX=J(SX.prototype,"_lineHeight",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 40}}),TX=J(SX.prototype,"_string",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"<color=#00ff00>Rich</color><color=#0fffff>Text</color>"}}),AX=J(SX.prototype,"_horizontalAlign",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return ZV.LEFT}}),xX=J(SX.prototype,"_fontSize",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 40}}),CX=J(SX.prototype,"_maxWidth",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),RX=J(SX.prototype,"_fontFamily",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"Arial"}}),bX=J(SX.prototype,"_font",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),wX=J(SX.prototype,"_isSystemFontUsed",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),IX=J(SX.prototype,"_userDefinedFont",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),OX=J(SX.prototype,"_cacheMode",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return $V.NONE}}),PX=J(SX.prototype,"_imageAtlas",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),MX=J(SX.prototype,"_handleTouchEvent",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),yX=SX))||yX)||yX)||yX)||yX)||yX)),VX=function(t){return e({UIMeshRenderer:t,UIModelComponent:t}),t}(ih("cc.UIMeshRenderer")(kX=mh()(kX=ah(110)(kX=_h()(kX=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._models=null,t._modelComponent=null,t}X(t,e);var n=t.prototype;return n.onLoad=function(){this.node._uiProps.uiTransformComp||this.node.addComponent("cc.UITransform"),this._modelComponent=this.getComponent("cc.RenderableComponent"),this._modelComponent?this._models=this._modelComponent._collectModels():console.warn("node '"+(this.node&&this.node.name)+"' doesn't have any renderable component")},n.onEnable=function(){e.prototype.onEnable.call(this)},n.onDisable=function(){e.prototype.onDisable.call(this)},n.onDestroy=function(){e.prototype.onDestroy.call(this),this._modelComponent=this.getComponent("cc.RenderableComponent"),this._modelComponent&&(this._modelComponent._sceneGetter=null,this._models=null)},n.updateAssembler=function(e){if(this._models){this._modelComponent._detachFromScene();for(var t,n=Z(this._models);!(t=n()).done;){var i=t.value;e.commitModel.call(e,this,i,this._modelComponent.material)}return!0}return!1},n.update=function(){this._fitUIRenderQueue()},n._fitUIRenderQueue=function(){if(this._modelComponent)for(var e=this._modelComponent.sharedMaterials.length,t=0;t<e;t++){var n=this._modelComponent.getMaterialInstance(t);if(null!=n)for(var i=n.passes,r=i.length,a=0;a<r;a++){var s=i[a];s._priority=Dl.MAX-11,s.blendState.targets[0].blend||n.overridePipelineStates({blendState:{targets:[{blend:!0}]}},a)}}},j(t,[{key:"modelComponent",get:function(){return this._modelComponent}}]),t}(BX))||kX)||kX)||kX)||kX),WX=e("MeshBuffer",function(){function e(e){this.vData=null,this.iData=null,this.byteStart=0,this.byteOffset=0,this.indicesStart=0,this.indicesOffset=0,this.vertexStart=0,this.vertexOffset=0,this.lastByteOffset=1,this._attributes=null,this._vertexBuffers=[],this._indexBuffer=null,this._iaInfo=null,this._batcher=void 0,this._dirty=!1,this._vertexFormatBytes=0,this._initVDataCount=0,this._initIDataCount=1536,this._outOfCallback=null,this._hInputAssemblers=[],this._nextFreeIAHandle=0,this._batcher=e}j(e,[{key:"attributes",get:function(){return this._attributes}},{key:"vertexBuffers",get:function(){return this._vertexBuffers}},{key:"indexBuffer",get:function(){return this._indexBuffer}}]);var t=e.prototype;return t.initialize=function(e,t){this._outOfCallback=t;var n=jW(e);this._vertexFormatBytes=n*Float32Array.BYTES_PER_ELEMENT,this._initVDataCount=256*this._vertexFormatBytes;var i=Float32Array.BYTES_PER_ELEMENT*n;this.vertexBuffers.length||this.vertexBuffers.push(this._batcher.device.createBuffer(new Ps(Ua.VERTEX|Ua.TRANSFER_DST,Ga.HOST|Ga.DEVICE,i,i)));var r=Uint16Array.BYTES_PER_ELEMENT;this.indexBuffer||(this._indexBuffer=this._batcher.device.createBuffer(new Ps(Ua.INDEX|Ua.TRANSFER_DST,Ga.HOST|Ga.DEVICE,r,r))),this._attributes=e,this._iaInfo=new js(this.attributes,this.vertexBuffers,this.indexBuffer),this._reallocBuffer()},t.request=function(e,t){void 0===e&&(e=4),void 0===t&&(t=6),this.lastByteOffset=this.byteOffset;var n=this.byteOffset+e*this._vertexFormatBytes,i=this.indicesOffset+t;if(e+this.vertexOffset>65535)return this._outOfCallback&&this._outOfCallback.call(this._batcher,e,t),!1;var r=this.vData.byteLength,a=this.iData.length;if(n>r||i>a){for(;r<n||a<i;)this._initVDataCount*=2,this._initIDataCount*=2,r=4*this._initVDataCount,a=this._initIDataCount;this._reallocBuffer()}return this.vertexOffset+=e,this.indicesOffset+=t,this.byteOffset=n,this._dirty=!0,!0},t.reset=function(){this.byteStart=0,this.byteOffset=0,this.indicesStart=0,this.indicesOffset=0,this.vertexStart=0,this.vertexOffset=0,this.lastByteOffset=0,this._nextFreeIAHandle=0,this._dirty=!1},t.destroy=function(){this._attributes=null,this.vertexBuffers[0].destroy(),this.vertexBuffers.length=0,this.indexBuffer.destroy(),this._indexBuffer=null;for(var e=0;e<this._hInputAssemblers.length;e++)Gi.free(this._hInputAssemblers[e]);this._hInputAssemblers.length=0},t.recordBatch=function(){var e=this.indicesOffset-this.indicesStart;if(!e)return 0;this._hInputAssemblers.length<=this._nextFreeIAHandle&&this._hInputAssemblers.push(Gi.alloc(this._batcher.device,this._iaInfo));var t=this._hInputAssemblers[this._nextFreeIAHandle++],n=Gi.get(t);return n.firstIndex=this.indicesStart,n.indexCount=e,t},t.uploadBuffers=function(){if(0!==this.byteOffset&&this._dirty){var e=new Float32Array(this.vData.buffer,0,this.byteOffset>>2),t=new Uint16Array(this.iData.buffer,0,this.indicesOffset);this.byteOffset>this.vertexBuffers[0].size&&this.vertexBuffers[0].resize(this.byteOffset),this.vertexBuffers[0].update(e),2*this.indicesOffset>this.indexBuffer.size&&this.indexBuffer.resize(2*this.indicesOffset),this.indexBuffer.update(t),this._dirty=!1}},t._reallocBuffer=function(){this._reallocVData(!0),this._reallocIData(!0)},t._reallocVData=function(e){var t;if(this.vData&&(t=new Uint8Array(this.vData.buffer)),this.vData=new Float32Array(this._initVDataCount),t&&e)for(var n=new Uint8Array(this.vData.buffer),i=0,r=t.length;i<r;i++)n[i]=t[i]},t._reallocIData=function(e){var t=this.iData;if(this.iData=new Uint16Array(this._initIDataCount),t&&e)for(var n=this.iData,i=0,r=t.length;i<r;i++)n[i]=t[i]},j(e,[{key:"vertexFormatBytes",get:function(){return this._vertexFormatBytes}}]),e}());WX.OPACITY_OFFSET=8;var jX,qX,XX,YX,KX,ZX,QX,JX,$X,eY,tY,nY,iY,rY,aY,sY,oY,cY,lY,uY,hY,_Y,fY,dY,pY,mY,gY=Ll.Enum.NONE|Ll.Enum.UI_3D,vY=e("UIDrawBatch",function(){function e(){this.bufferBatch=null,this.camera=null,this.renderScene=null,this.model=null,this.texture=null,this.sampler=null,this.useLocalData=null,this.isStatic=!1,this.textureHash=0,this.samplerHash=0,this._handle=0,this._passes=[],this._handle=lr.alloc(),lr.set(this._handle,rr.VIS_FLAGS,gY),lr.set(this._handle,rr.INPUT_ASSEMBLER,0),lr.set(this._handle,rr.DESCRIPTOR_SET,0)}j(e,[{key:"handle",get:function(){return this._handle}},{key:"hInputAssembler",get:function(){return lr.get(this._handle,rr.INPUT_ASSEMBLER)},set:function(e){lr.set(this._handle,rr.INPUT_ASSEMBLER,e)}},{key:"hDescriptorSet",get:function(){return lr.get(this._handle,rr.DESCRIPTOR_SET)},set:function(e){lr.set(this._handle,rr.DESCRIPTOR_SET,e)}},{key:"visFlags",get:function(){return lr.get(this._handle,rr.VIS_FLAGS)},set:function(e){lr.set(this._handle,rr.VIS_FLAGS,e)}},{key:"passes",get:function(){return this._passes}}]);var t=e.prototype;return t.destroy=function(){if(this._handle){for(var e=this.passes.length,t=0;t<e;t++)this.passes[t]._destroyHandle();this._passes=[],lr.free(this._handle),this._handle=0}},t.clear=function(){this.bufferBatch=null,this.hInputAssembler=0,this.hDescriptorSet=0,this.camera=null,this.texture=null,this.sampler=null,this.model=null,this.isStatic=!1,this.useLocalData=null,this.visFlags=gY},t.fillPasses=function(e,t,n,r,a,s){if(e){var o=e.passes;if(!o)return;lr.set(this._handle,rr.PASS_COUNT,o.length);for(var c=rr.PASS_0,l=rr.SHADER_0,u=0,h=0;h<o.length;h++,c++,l++){this._passes[h]||(this._passes[h]=new Jd(i.director.root),this._passes[h]._handle=er.alloc());var _=o[h],f=this._passes[h];t||(t=_.depthStencilState,n=0),r||(r=_.blendState,a=0),-1===a&&(a=0),u=n<<16|a,_.update(),f._initPassFromTarget(_,t,r,u),lr.set(this._handle,c,f.handle),lr.set(this._handle,l,f.getShaderVariant(s))}}},e}()),yY=function(t){return e({UIStaticBatch:t,UIStaticBatchComponent:t}),t}((jX=ih("cc.UIStaticBatch"),qX=mh(),XX=_h(),YX=ah(110),KX=vh(),ZX=vh(),QX=vh(),jX(JX=qX(JX=XX(JX=YX((J(($X=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return(t=e.call.apply(e,[this].concat(i))||this)._init=!1,t._meshBuffer=null,t._dirty=!0,t._lastMeshBuffer=null,t._uiDrawBatchList=[],t}X(t,e);var n=t.prototype;return n.onLoad=function(){var e=this._getBatcher();if(e){var t=VW,n=new WX(e);n.initialize(t,this._arrivalMaxBuffer.bind(this)),this._meshBuffer=n}},n.onDestroy=function(){e.prototype.onDestroy.call(this),this._clearData(),this._meshBuffer&&(this._meshBuffer.destroy(),this._meshBuffer=null)},n.updateAssembler=function(e){this._dirty&&(e.finishMergeBatches(),this._lastMeshBuffer=e.currBufferBatch,e.currBufferBatch=this._meshBuffer,e.currStaticRoot=this),this._init&&(e.finishMergeBatches(),e.commitStaticBatch(this))},n.postUpdateAssembler=function(e){this._dirty&&(e.finishMergeBatches(),e.currBufferBatch=this._lastMeshBuffer,e.currStaticRoot=null,this._dirty=!1,this._init=!0,this.node._static=!0,this._meshBuffer.uploadBuffers())},n.markAsDirty=function(){this._getBatcher()&&(this.node._static=!1,this._dirty=!0,this._init=!1,this._clearData())},n._requireDrawBatch=function(){var e=new vY;return e.isStatic=!0,this._uiDrawBatchList.push(e),e},n._clearData=function(){if(this._meshBuffer){this._meshBuffer.reset();for(var e=this._getBatcher(),t=0;t<this._uiDrawBatchList.length;t++)this._uiDrawBatchList[t].destroy(e)}this._uiDrawBatchList.length=0,this._init=!1},n._getBatcher=function(){return Ow.root&&Ow.root.batcher2D?Ow.root.batcher2D:(E(9301),null)},n._arrivalMaxBuffer=function(){var e=this._getBatcher();e&&e.autoMergeBatches(),E(9300)},j(t,[{key:"dstBlendFactor",get:function(){return this._dstBlendFactor},set:function(e){this._dstBlendFactor!==e&&(this._dstBlendFactor=e,this._updateBlendFunc())}},{key:"srcBlendFactor",get:function(){return this._srcBlendFactor},set:function(e){this._srcBlendFactor!==e&&(this._srcBlendFactor=e,this._updateBlendFunc())}},{key:"color",get:function(){return this._color},set:function(e){this._color!==e&&(this._color.set(e),this._updateColor(),this.markForUpdateRenderData())}},{key:"drawBatchList",get:function(){return this._uiDrawBatchList}}]),t}(eW)).prototype,"dstBlendFactor",[Bh,KX],Object.getOwnPropertyDescriptor($X.prototype,"dstBlendFactor"),$X.prototype),J($X.prototype,"srcBlendFactor",[Bh,ZX],Object.getOwnPropertyDescriptor($X.prototype,"srcBlendFactor"),$X.prototype),J($X.prototype,"color",[Bh,QX],Object.getOwnPropertyDescriptor($X.prototype,"color"),$X.prototype),JX=$X))||JX)||JX)||JX)||JX)),SY=e("LabelShadow",(eY=ih("cc.LabelShadow"),tY=mh(),nY=ah(110),iY=_h(),rY=rh(rW),aY=Sh(),sY=Sh(),oY=Sh(),eY(cY=tY(cY=nY(cY=iY(cY=rY(cY=hh((fY=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return Q(t=e.call.apply(e,[this].concat(i))||this,"_color",uY,Y(t)),Q(t,"_offset",hY,Y(t)),Q(t,"_blur",_Y,Y(t)),t}X(t,e);var n=t.prototype;return n.onEnable=function(){this._updateRenderData()},n.onDisable=function(){this._updateRenderData()},n._updateRenderData=function(){var e=this.node.getComponent(rW);e&&e.updateRenderData(!0)},j(t,[{key:"color",get:function(){return this._color},set:function(e){this._color!==e&&(this._color.set(e),this._updateRenderData())}},{key:"offset",get:function(){return this._offset},set:function(e){this._offset=e,this._updateRenderData()}},{key:"blur",get:function(){return this._blur},set:function(e){this._blur=e,this._updateRenderData()}}]),t}(Kf),uY=J((lY=fY).prototype,"_color",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Cn(0,0,0,255)}}),hY=J(lY.prototype,"_offset",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new qn(2,2)}}),_Y=J(lY.prototype,"_blur",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 2}}),J(lY.prototype,"color",[aY],Object.getOwnPropertyDescriptor(lY.prototype,"color"),lY.prototype),J(lY.prototype,"offset",[sY],Object.getOwnPropertyDescriptor(lY.prototype,"offset"),lY.prototype),J(lY.prototype,"blur",[oY],Object.getOwnPropertyDescriptor(lY.prototype,"blur"),lY.prototype),cY=lY))||cY)||cY)||cY)||cY)||cY)||cY)),EY=function(t){return e({UIOpacity:t,UIOpacityComponent:t}),t}(ih("cc.UIOpacity")(dY=mh()(dY=ah(110)(dY=_h()(dY=hh((J((pY=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];return Q(t=e.call.apply(e,[this].concat(i))||this,"_opacity",mY,Y(t)),t}X(t,e);var n=t.prototype;return n.onEnable=function(){this.node._uiProps.opacity=this._opacity/255},n.onDisable=function(){this.node._uiProps.opacity=1},j(t,[{key:"opacity",get:function(){return this._opacity},set:function(e){this._opacity!==e&&(e=Ct(e,0,255),this._opacity=e,this.node._uiProps.opacity=e/255)}}]),t}(Kf)).prototype,"opacity",[gh],Object.getOwnPropertyDescriptor(pY.prototype,"opacity"),pY.prototype),mY=J(pY.prototype,"_opacity",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 255}}),dY=pY))||dY)||dY)||dY)||dY)||dY);i.MaskComponent=Ij,st.setClassAlias(Ij,"cc.MaskComponent"),i.LabelComponent=rW,st.setClassAlias(rW,"cc.LabelComponent"),i.LabelOutlineComponent=Dq,st.setClassAlias(Dq,"cc.LabelOutlineComponent"),i.RichTextComponent=HX,st.setClassAlias(HX,"cc.RichTextComponent"),i.SpriteComponent=Kq,st.setClassAlias(Kq,"cc.SpriteComponent"),i.UIModelComponent=VX,st.setClassAlias(VX,"cc.UIModelComponent"),i.GraphicsComponent=xj,st.setClassAlias(xj,"cc.GraphicsComponent"),st.setClassAlias(yY,"cc.UIStaticBatchComponent"),st.setClassAlias(EY,"cc.UIOpacityComponent");var TY=function(e,t,n){this.i=void 0,this.x=void 0,this.y=void 0,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1,this.i=e,this.x=t,this.y=n};function AY(e,t,n,i,r){var a=0,s=null;if(r===function(e,t,n,i){for(var r=0,a=t,s=n-i;a<n;a+=i)r+=(e[s]-e[a])*(e[a+1]+e[s+1]),s=a;return r}(e,t,n,i)>0)for(a=t;a<n;a+=i)s=kY(a,e[a],e[a+1],s);else for(a=n-i;a>=t;a-=i)s=kY(a,e[a],e[a+1],s);return s&&FY(s,s.next)&&(HY(s),s=s.next),s}function xY(e,t){if(void 0===t&&(t=null),!e)return e;t||(t=e);var n=e,i=!1;do{if(i=!1,n.steiner||!FY(n,n.next)&&0!==LY(n.prev,n,n.next))n=n.next;else{if(HY(n),(n=t=n.prev)===n.next)return null;i=!0}}while(i||n!==t);return t}function CY(e,t,n,i,r,a,s){if(void 0===s&&(s=0),e){!s&&a&&function(e,t,n,i){var r=e;do{null===r.z&&(r.z=MY(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){var t=0,n=null,i=null,r=null,a=null,s=0,o=0,c=0,l=1;do{for(n=e,e=null,a=null,s=0;n;){for(s++,i=n,o=0,t=0;t<l&&(o++,i=i.nextZ);t++);for(c=l;o>0||c>0&&i;)0===o?(r=i,i=i.nextZ,c--):0!==c&&i?n.z<=i.z?(r=n,n=n.nextZ,o--):(r=i,i=i.nextZ,c--):(r=n,n=n.nextZ,o--),a?a.nextZ=r:e=r,r.prevZ=a,a=r;n=i}a.nextZ=null,l*=2}while(s>1)}(r)}(e,i,r,a);for(var o=e,c=null,l=null;e.prev!==e.next;)if(c=e.prev,l=e.next,a?bY(e,i,r,a):RY(e))t.push(c.i/n),t.push(e.i/n),t.push(l.i/n),HY(e),e=l.next,o=l.next;else if((e=l)===o){s?1===s?CY(e=wY(e,t,n),t,n,i,r,a,2):2===s&&IY(e,t,n,i,r,a):CY(xY(e),t,n,i,r,a,1);break}}}function RY(e){var t=e.prev,n=e,i=e.next;if(LY(t,n,i)>=0)return!1;for(var r=e.next.next;r!==e.prev;){if(DY(t.x,t.y,n.x,n.y,i.x,i.y,r.x,r.y)&&LY(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function bY(e,t,n,i){var r=e.prev,a=e,s=e.next;if(LY(r,a,s)>=0)return!1;for(var o=r.x<a.x?r.x<s.x?r.x:s.x:a.x<s.x?a.x:s.x,c=r.y<a.y?r.y<s.y?r.y:s.y:a.y<s.y?a.y:s.y,l=r.x>a.x?r.x>s.x?r.x:s.x:a.x>s.x?a.x:s.x,u=r.y>a.y?r.y>s.y?r.y:s.y:a.y>s.y?a.y:s.y,h=MY(o,c,t,n,i),_=MY(l,u,t,n,i),f=e.nextZ;f&&f.z<=_;){if(f!==e.prev&&f!==e.next&&DY(r.x,r.y,a.x,a.y,s.x,s.y,f.x,f.y)&&LY(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(f=e.prevZ;f&&f.z>=h;){if(f!==e.prev&&f!==e.next&&DY(r.x,r.y,a.x,a.y,s.x,s.y,f.x,f.y)&&LY(f.prev,f,f.next)>=0)return!1;f=f.prevZ}return!0}function wY(e,t,n){var i=e;do{var r=i.prev,a=i.next.next;!FY(r,a)&&zY(r,i,i.next,a)&&UY(r,a)&&UY(a,r)&&(t.push(r.i/n),t.push(i.i/n),t.push(a.i/n),HY(i),HY(i.next),i=e=a),i=i.next}while(i!==e);return i}function IY(e,t,n,i,r,a){var s=e;do{for(var o=s.next.next;o!==s.prev;){if(s.i!==o.i&&BY(s,o)){var c=GY(s,o);return s=xY(s,s.next),c=xY(c,c.next),CY(s,t,n,i,r,a),void CY(c,t,n,i,r,a)}o=o.next}s=s.next}while(s!==e)}function OY(e,t){return e.x-t.x}function PY(e,t){if(t=function(e,t){var n=t,i=e.x,r=e.y,a=-1/0,s=null;do{if(r<=n.y&&r>=n.next.y){var o=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(o<=i&&o>a){if(a=o,o===i){if(r===n.y)return n;if(r===n.next.y)return n.next}s=n.x<n.next.x?n:n.next}}n=n.next}while(n!==t);if(!s)return null;if(i===a)return s.prev;var c,l=s,u=s.x,h=s.y,_=1/0;for(n=s.next;n!==l;)i>=n.x&&n.x>=u&&DY(r<h?i:a,r,u,h,r<h?a:i,r,n.x,n.y)&&((c=Math.abs(r-n.y)/(i-n.x))<_||c===_&&n.x>s.x)&&UY(n,e)&&(s=n,_=c),n=n.next;return s}(e,t)){var n=GY(t,e);xY(n,n.next)}}function MY(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)/r)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)/r)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function NY(e){var t=e,n=e;do{t.x<n.x&&(n=t),t=t.next}while(t!==e);return n}function DY(e,t,n,i,r,a,s,o){return(r-s)*(t-o)-(e-s)*(a-o)>=0&&(e-s)*(i-o)-(n-s)*(t-o)>=0&&(n-s)*(a-o)-(r-s)*(i-o)>=0}function BY(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&zY(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&UY(e,t)&&UY(t,e)&&function(e,t){var n=e,i=!1,r=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!=n.next.y>a&&r<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}(e,t)}function LY(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function FY(e,t){return e.x===t.x&&e.y===t.y}function zY(e,t,n,i){return!!(FY(e,t)&&FY(n,i)||FY(e,i)&&FY(n,t))||LY(e,t,n)>0!=LY(e,t,i)>0&&LY(n,i,e)>0!=LY(n,i,t)>0}function UY(e,t){return LY(e.prev,e,e.next)<0?LY(e,t,e.next)>=0&&LY(e,e.prev,t)>=0:LY(e,t,e.prev)<0||LY(e,e.next,t)<0}function GY(e,t){var n=new TY(e.i,e.x,e.y),i=new TY(t.i,t.x,t.y),r=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,a.next=i,i.prev=a,i}function kY(e,t,n,i){var r=new TY(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function HY(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function VY(e,t,n){n=n||3;var i=t?t.length:0,r=i?t[0]*n:e.length,a=AY(e,0,r,n,!0),s=[];if(!a)return s;var o=0,c=0,l=0,u=0,h=0,_=0,f=0;if(i&&(a=function(e,t,n,i){var r,a=[],s=0,o=null;for(s=0,r=t.length;s<r;s++)(o=AY(e,t[s]*i,s<r-1?t[s+1]*i:e.length,i,!1))&&(o===o.next&&(o.steiner=!0),a.push(NY(o)));if(a.sort(OY),!n)return n;for(s=0;s<a.length;s++)PY(a[s],n),n=xY(n,n.next);return n}(e,t,a,n)),e.length>80*n){o=l=e[0],c=u=e[1];for(var d=n;d<r;d+=n)(h=e[d])<o&&(o=h),(_=e[d+1])<c&&(c=_),h>l&&(l=h),_>u&&(u=_);f=Math.max(l-o,u-c)}return CY(a,s,n,o,c,f),s}for(var WY=Math.PI,jY=Math.min,qY=Math.max,XY=Math.ceil,YY=Math.acos,KY=Math.cos,ZY=Math.sin,QY=Math.atan2,JY=null,$Y=null,eK=new Cn,tK=[],nK=0;nK<4;nK++)tK.push(new bn);function iK(e,t,n){return e<t?t:e>n?n:e}var rK={useModel:!0,updateRenderData:function(){},fillBuffers:function(){},renderIA:function(){},getRenderData:function(e,t){if(!$Y)return null;var n=$Y.getRenderDataList(),i=n[$Y.dataOffset];if(!i)return null;var r=i,a=r?r.vertexStart+t:0;return(a>65535||3*a>131070)&&(++$Y.dataOffset,$Y.dataOffset<n.length?i=n[$Y.dataOffset]:(i=$Y.requestRenderData(),n[$Y.dataOffset]=i),r=i),r&&r.vertexCount<a&&r.request(t,3*t),i},stroke:function(e){Cn.copy(eK,e.strokeColor),e.impl&&(this._flattenPaths(e.impl),this._expandStroke(e),e.impl.updatePathOffset=!0,this.end(e))},fill:function(e){Cn.copy(eK,e.fillColor),this._expandFill(e),e.impl&&(e.impl.updatePathOffset=!0),this.end(e)},end:function(e){e.markForUpdateRenderData()},_expandStroke:function(e){var t=.5*e.lineWidth,n=e.lineCap,i=e.lineJoin,r=e.miterLimit;if($Y=e.impl){var a=function(e,t,n){var i=2*YY(e/(e+n));return qY(2,XY(t/i))}(t,WY,$Y.tessTol);this._calculateJoins($Y,t,i,r);for(var s=$Y.paths,o=0,c=$Y.pathOffset,l=$Y.pathLength;c<l;c++){var u=s[c],h=u.points.length;i===nW.ROUND?o+=2*(h+u.bevel*(a+2)+1):o+=2*(h+5*u.bevel+1),u.closed||(n===tW.ROUND?o+=2*(2*a+2):o+=12)}var _=JY=this.getRenderData(e,o);if(_){for(var f=_.vData,d=_.iData,p=$Y.pathOffset,m=$Y.pathLength;p<m;p++){var g=s[p],v=g.points,y=v.length,S=_.vertexStart,E=void 0,T=void 0,A=0,x=0,C=g.closed;if(C?(E=v[y-1],T=v[0],A=0,x=y):(E=v[0],T=v[1],A=1,x=y-1),T=T||E,!C){var R=new zW(T.x,T.y);R.subtract(E),R.normalize();var b=R.x,w=R.y;n===tW.BUTT?this._buttCapStart(E,b,w,t,0):n===tW.SQUARE?this._buttCapStart(E,b,w,t,t):n===tW.ROUND&&this._roundCapStart(E,b,w,t,a)}for(var I=A;I<x;++I)i===nW.ROUND?this._roundJoin(E,T,t,t,a):0!=(T.flags&(iW.PT_BEVEL|iW.PT_INNERBEVEL))?this._bevelJoin(E,T,t,t):(this._vSet(T.x+T.dmx*t,T.y+T.dmy*t,1),this._vSet(T.x-T.dmx*t,T.y-T.dmy*t,-1)),E=T,T=v[I+1];if(C){var O=8*S;this._vSet(f[O],f[O+1],1),this._vSet(f[O+8],f[O+8+1],-1)}else{var P=new zW(T.x,T.y);P.subtract(E),P.normalize();var M=P.x,N=P.y;n===tW.BUTT?this._buttCapEnd(T,M,N,t,0):n===tW.SQUARE?this._buttCapEnd(T,M,N,t,t):n===tW.ROUND&&this._roundCapEnd(T,M,N,t,a)}for(var D=_.indicesStart,B=S+2,L=_.vertexStart;B<L;B++)d[D++]=B-2,d[D++]=B-1,d[D++]=B;_.indicesStart=D}JY=null,$Y=null}}},_expandFill:function(e){if($Y=e.impl){for(var t=$Y.paths,n=0,i=$Y.pathOffset,r=$Y.pathLength;i<r;i++)n+=t[i].points.length;var a=JY=this.getRenderData(e,n);if(a){for(var s=a,o=s.vData,c=s.iData,l=$Y.pathOffset,u=$Y.pathLength;l<u;l++){var h=t[l],_=h.points,f=_.length;if(0!==f){for(var d=a.vertexStart,p=0;p<f;++p)this._vSet(_[p].x,_[p].y);var m=a.indicesStart;if(h.complex){for(var g=[],v=d,y=a.vertexStart;v<y;v++){var S=8*v;g.push(o[S++]),g.push(o[S++]),g.push(o[S++])}var E=VY(g,null,3);if(!E||0===E.length)continue;for(var T=0,A=E.length;T<A;T++)c[m++]=E[T]+d}else for(var x=d,C=d+2,R=s.vertexStart;C<R;C++)c[m++]=x,c[m++]=C-1,c[m++]=C;s.indicesStart=m}}JY=null,$Y=null}}},_calculateJoins:function(e,t,n,i){var r=0;t>0&&(r=1/t);for(var a=e.paths,s=e.pathOffset,o=e.pathLength;s<o;s++){var c=a[s],l=c.points,u=l.length,h=l[u-1],_=l[0];c.bevel=0;for(var f=0;f<u;f++){var d,p,m=h.dy,g=-h.dx,v=_.dy,y=-_.dx;if(_.dmx=.5*(m+v),_.dmy=.5*(g+y),(d=_.dmx*_.dmx+_.dmy*_.dmy)>1e-6){var S=1/d;S>600&&(S=600),_.dmx*=S,_.dmy*=S}_.dx*h.dy-h.dx*_.dy>0&&(_.flags|=iW.PT_LEFT),d*(p=qY(11,jY(h.len,_.len)*r))*p<1&&(_.flags|=iW.PT_INNERBEVEL),_.flags&iW.PT_CORNER&&(d*i*i<1||n===nW.BEVEL||n===nW.ROUND)&&(_.flags|=iW.PT_BEVEL),0!=(_.flags&(iW.PT_BEVEL|iW.PT_INNERBEVEL))&&c.bevel++,h=_,_=l[f+1]}}},_flattenPaths:function(e){for(var t=e.paths,n=e.pathOffset,i=e.pathLength;n<i;n++){var r=t[n],a=r.points,s=a[a.length-1],o=a[0];a.length>2&&s.equals(o)&&(r.closed=!0,a.pop(),s=a[a.length-1]);for(var c=0,l=a.length;c<l;c++){var u=new zW(o.x,o.y);u.subtract(s),s.len=u.length(),(u.x||u.y)&&u.normalize(),s.dx=u.x,s.dy=u.y,s=o,o=a[c+1]}}},_chooseBevel:function(e,t,n,i){var r=n.x,a=n.y,s=0,o=0,c=0,l=0;return 0!==e?(s=r+t.dy*i,o=a-t.dx*i,c=r+n.dy*i,l=a-n.dx*i):(s=c=r+n.dmx*i,o=l=a+n.dmy*i),[s,o,c,l]},_buttCapStart:function(e,t,n,i,r){var a=e.x-t*r,s=e.y-n*r,o=n,c=-t;this._vSet(a+o*i,s+c*i,1),this._vSet(a-o*i,s-c*i,-1)},_buttCapEnd:function(e,t,n,i,r){var a=e.x+t*r,s=e.y+n*r,o=n,c=-t;this._vSet(a+o*i,s+c*i,1),this._vSet(a-o*i,s-c*i,-1)},_roundCapStart:function(e,t,n,i,r){for(var a=e.x,s=e.y,o=n,c=-t,l=0;l<r;l++){var u=l/(r-1)*WY,h=KY(u)*i,_=ZY(u)*i;this._vSet(a-o*h-t*_,s-c*h-n*_,1),this._vSet(a,s,0)}this._vSet(a+o*i,s+c*i,1),this._vSet(a-o*i,s-c*i,-1)},_roundCapEnd:function(e,t,n,i,r){var a=e.x,s=e.y,o=n,c=-t;this._vSet(a+o*i,s+c*i,1),this._vSet(a-o*i,s-c*i,-1);for(var l=0;l<r;l++){var u=l/(r-1)*WY,h=KY(u)*i,_=ZY(u)*i;this._vSet(a,s,0),this._vSet(a-o*h+t*_,s-c*h+n*_,1)}},_roundJoin:function(e,t,n,i,r){var a=e.dy,s=-e.dx,o=t.dy,c=-t.dx,l=t.x,u=t.y;if(0!=(t.flags&iW.PT_LEFT)){var h=this._chooseBevel(t.flags&iW.PT_INNERBEVEL,e,t,n),_=h[0],f=h[1],d=h[2],p=h[3],m=QY(-s,-a),g=QY(-c,-o);g>m&&(g-=2*WY),this._vSet(_,f,1),this._vSet(l-a*i,t.y-s*i,-1);for(var v=iK(XY((m-g)/WY)*r,2,r),y=0;y<v;y++){var S=m+y/(v-1)*(g-m),E=l+KY(S)*i,T=u+ZY(S)*i;this._vSet(l,u,0),this._vSet(E,T,-1)}this._vSet(d,p,1),this._vSet(l-o*i,u-c*i,-1)}else{var A=this._chooseBevel(t.flags&iW.PT_INNERBEVEL,e,t,-i),x=A[0],C=A[1],R=A[2],b=A[3],w=QY(s,a),I=QY(c,o);I<w&&(I+=2*WY),this._vSet(l+a*i,u+s*i,1),this._vSet(x,C,-1);for(var O=iK(XY((I-w)/WY)*r,2,r),P=0;P<O;P++){var M=w+P/(O-1)*(I-w),N=l+KY(M)*n,D=u+ZY(M)*n;this._vSet(N,D,1),this._vSet(l,u,0)}this._vSet(l+o*i,u+c*i,1),this._vSet(R,b,-1)}},_bevelJoin:function(e,t,n,i){var r=0,a=0,s=0,o=0,c=0,l=0,u=0,h=0,_=e.dy,f=-e.dx,d=t.dy,p=-t.dx;if(t.flags&iW.PT_LEFT){var m=this._chooseBevel(t.flags&iW.PT_INNERBEVEL,e,t,n);c=m[0],l=m[1],u=m[2],h=m[3],this._vSet(c,l,1),this._vSet(t.x-_*i,t.y-f*i,-1),this._vSet(u,h,1),this._vSet(t.x-d*i,t.y-p*i,-1)}else{var g=this._chooseBevel(t.flags&iW.PT_INNERBEVEL,e,t,-i);r=g[0],a=g[1],s=g[2],o=g[3],this._vSet(t.x+_*n,t.y+f*n,1),this._vSet(r,a,-1),this._vSet(t.x+d*n,t.y+p*n,1),this._vSet(s,o,-1)}},_vSet:function(e,t,n){if(void 0===n&&(n=0),JY){var i=JY,r=8*i.vertexStart,a=i.vData;a[r++]=e,a[r++]=t,a[r++]=0,Cn.toArray(a,eK,r),r+=4,a[r++]=n,i.vertexStart++}}},aK=e("graphicsAssembler",{getAssembler:function(){return rK}});xj.Assembler=aK;var sK=function(){this.char="",this.valid=!0,this.x=0,this.y=0,this.line=0,this.hash=""},oK=new ti,cK=null,lK=null,uK=[],hK=[],_K=[],fK=[],dK=new $n,pK=new $n,mK=new qn,gK=null,vK=0,yK=0,SK=0,EK=0,TK=0,AK=1,xK=null,CK="",RK=0,bK=0,wK=0,IK=0,OK=0,PK=0,MK=0,NK=!1,DK=0,BK=0,LK=0,FK={updateRenderData:function(e){e.renderData&&e.renderData.vertDirty&&cK!==e&&(lK=(cK=e).node._uiProps.uiTransformComp,this._updateFontFamily(e),this._updateProperties(e),this._updateLabelInfo(e),this._updateContent(),cK.actualFontSize=RK,lK.setContentSize(pK),cK.renderData.vertDirty=cK.renderData.uvDirty=!1,cK=null,this._resetProperties())},_updateFontScale:function(){AK=RK/bK},_updateFontFamily:function(e){var t=e.font;xK=t.spriteFrame,gK=t.fntConfig,tH.fontAtlas=t.fontDefDictionary,kG.packToDynamicAtlas(e,xK)},_updateLabelInfo:function(){tH.hash="",tH.margin=0},_updateProperties:function(e){CK=e.string.toString(),RK=e.fontSize,bK=gK?gK.fontSize:e.fontSize,wK=e.horizontalAlign,IK=e.verticalAlign,OK=e.spacingX,MK=e.overflow,PK=e._lineHeight;var t=lK.contentSize;pK.width=t.width,pK.height=t.height,MK===JV.NONE?(NK=!1,pK.width+=2*tH.margin,pK.height+=2*tH.margin):MK===JV.RESIZE_HEIGHT?(NK=!0,pK.height+=2*tH.margin):NK=e.enableWrapText,tH.lineHeight=PK,tH.fontSize=RK,this._setupBMFontOverflowMetrics()},_resetProperties:function(){gK=null,xK=null,tH.hash="",tH.margin=0},_updateContent:function(){this._updateFontScale(),this._computeHorizontalKerningForText(),this._alignText()},_computeHorizontalKerningForText:function(){for(var e=CK,t=e.length,n=gK.kerningDict,i=uK,r=-1,a=0;a<t;++a){var s=e.charCodeAt(a),o=n[r<<16|65535&s]||0;i[a]=a<t-1?o:0,r=s}},_multilineTextWrap:function(e){for(var t=CK.length,n=0,i=0,r=0,a=0,s=0,o=0,c=0,l=null,u=0;u<t;){var h=CK.charAt(u);if("\n"!==h){for(var _=e(CK,u,t),f=o,d=c,p=s,m=i,g=!1,v=0;v<_;++v){var y=u+v;if("\r"!==(h=CK.charAt(y)))if(l=tH.fontAtlas.getLetterDefinitionForChar(h,tH)){var S=m+l.offsetX*AK-tH.margin;if(NK&&LK>0&&i>0&&S+l.w*AK>LK&&!bk(h)){_K.push(s),s=0,n++,i=0,r-=PK*this._getFontScale()+0,g=!0;break}mK.x=S,mK.y=r-l.offsetY*AK,this._recordLetterInfo(mK,h,y,n),y+1<uK.length&&y<t-1&&(m+=uK[y+1]),m+=l.xAdvance*AK+OK,p=mK.x+l.w*AK,f<mK.y&&(f=mK.y),d>mK.y-l.h*AK&&(d=mK.y-l.h*AK)}else this._recordPlaceholderInfo(y,h),console.log("Can't find letter definition in texture atlas "+gK.atlasName+" for letter:"+h);else this._recordPlaceholderInfo(y,h)}g||(i=m,o<f&&(o=f),c>d&&(c=d),a<(s=p)&&(a=s),u+=_)}else _K.push(s),s=0,n++,i=0,r-=PK*this._getFontScale()+0,this._recordPlaceholderInfo(u,h),u++}return _K.push(s),yK=(vK=n+1)*PK*this._getFontScale(),vK>1&&(yK+=0*(vK-1)),pK.width=DK,pK.height=BK,DK<=0&&(pK.width=parseFloat(a.toFixed(2))+2*tH.margin),BK<=0&&(pK.height=parseFloat(yK.toFixed(2))+2*tH.margin),EK=pK.height,TK=0,o>0&&(EK=pK.height+o),c<-yK&&(TK=yK+c),!0},_getFirstCharLen:function(){return 1},_getFontScale:function(){return MK===JV.SHRINK?AK:1},_getFirstWordLen:function(e,t,n){var i=e.charAt(t);if(Rk(i)||"\n"===i||bk(i))return 1;var r=1,a=tH.fontAtlas.getLetterDefinitionForChar(i,tH);if(!a)return r;for(var s=a.xAdvance*AK+OK,o=t+1;o<n&&(i=e.charAt(o),a=tH.fontAtlas.getLetterDefinitionForChar(i,tH));++o){if(s+a.offsetX*AK+a.w*AK>LK&&!bk(i)&&LK>0)return r;if(s+=a.xAdvance*AK+OK,"\n"===i||bk(i)||Rk(i))break;r++}return r},_multilineTextWrapByWord:function(){return this._multilineTextWrap(this._getFirstWordLen)},_multilineTextWrapByChar:function(){return this._multilineTextWrap(this._getFirstCharLen)},_recordPlaceholderInfo:function(e,t){if(e>=hK.length){var n=new sK;hK.push(n)}hK[e].char=t,hK[e].hash=t.charCodeAt(0)+tH.hash,hK[e].valid=!1},_recordLetterInfo:function(e,t,n,i){if(n>=hK.length){var r=new sK;hK.push(r)}var a=t.charCodeAt(0)+tH.hash;hK[n].line=i,hK[n].char=t,hK[n].hash=a,hK[n].valid=tH.fontAtlas.getLetter(a).valid,hK[n].x=e.x,hK[n].y=e.y},_alignText:function(){yK=0,_K.length=0,this._multilineTextWrapByWord(),this._computeAlignmentOffset(),MK===JV.SHRINK&&RK>0&&this._isVerticalClamp()&&this._shrinkLabelToContentSize(this._isVerticalClamp),this._updateQuads()||MK===JV.SHRINK&&this._shrinkLabelToContentSize(this._isHorizontalClamp)},_scaleFontSizeDown:function(e){var t=!0;e||(e=.1,t=!1),RK=e,t&&this._updateContent()},_shrinkLabelToContentSize:function(e){for(var t=0,n=0|RK,i=0;t<n;){var r=i=t+n+1>>1;if(r<=0)break;AK=r/bK,this._multilineTextWrapByWord(),this._computeAlignmentOffset(),e()?n=i-1:t=i}t>=0&&this._scaleFontSizeDown(t)},_isVerticalClamp:function(){return yK>pK.height},_isHorizontalClamp:function(){for(var e=!1,t=0,n=CK.length;t<n;++t){var i=hK[t];if(i.valid){var r=tH.fontAtlas.getLetterDefinitionForChar(i.char,tH);if(!r)continue;var a=i.x+r.w/2*AK,s=i.line;if(DK>0)if(NK){if(_K[s]>pK.width&&(a>pK.width||a<0)){e=!0;break}}else if(a>pK.width){e=!0;break}}}return e},_isHorizontalClamped:function(e,t){var n=_K[t],i=e>pK.width||e<0;return NK?n>pK.width&&i:i},_updateQuads:function(){if(!cK)return!1;var e=xK?xK.texture:tH.fontAtlas.getTexture(),t=cK.renderData;t.dataLength=t.vertexCount=t.indicesCount=0;for(var n=lK.anchorPoint,i=pK,r=n.x*i.width,a=n.y*i.height,s=!0,o=0,c=CK.length;o<c;++o){var l=hK[o];if(l.valid){var u=tH.fontAtlas.getLetter(l.hash);if(u){oK.height=u.h,oK.width=u.w,oK.x=u.u,oK.y=u.v;var h=l.y+SK;if(BK>0){if(h>EK){var _=h-EK;oK.y+=_,oK.height-=_,h-=_}h-u.h*AK<TK&&MK===JV.CLAMP&&(oK.height=h<TK?0:(h-TK)/AK)}var f=l.line,d=l.x+u.w/2*AK+fK[f];if(DK>0&&this._isHorizontalClamped(d,f))if(MK===JV.CLAMP)oK.width=0;else if(MK===JV.SHRINK){if(pK.width>u.w){s=!1;break}oK.width=0}if(oK.height>0&&oK.width>0){var p=this._determineRect(),m=l.x+fK[l.line];this.appendQuad(cK,e,oK,p,m-r,h-a,AK)}}else console.warn("Can't find letter in this bitmap-font")}}return s},appendQuad:function(){},_determineRect:function(){var e=xK.isRotated(),t=xK.getOriginalSize(),n=xK.getRect(),i=xK.getOffset(),r=i.x+(t.width-n.width)/2,a=i.y-(t.height-n.height)/2;if(e){var s=oK.x;oK.x=n.x+n.height-oK.y-oK.height-a,oK.y=s+n.y-r,oK.y<0&&(oK.height+=a)}else oK.x+=n.x-r,oK.y+=n.y+a;return e},_computeAlignmentOffset:function(){switch(fK.length=0,wK){case ZV.LEFT:for(var e=0;e<vK;++e)fK.push(0);break;case ZV.CENTER:for(var t=0,n=_K.length;t<n;t++)fK.push((pK.width-_K[t])/2);break;case ZV.RIGHT:for(var i=0,r=_K.length;i<r;i++)fK.push(pK.width-_K[i])}if(SK=pK.height,IK!==QV.TOP){var a=pK.height-yK+PK*this._getFontScale()-bK*AK;IK===QV.BOTTOM?SK-=a:SK-=a/2}},_setupBMFontOverflowMetrics:function(){var e=pK.width,t=pK.height;MK===JV.RESIZE_HEIGHT&&(t=0),MK===JV.NONE&&(e=0,t=0),DK=e,BK=t,dK.width=e,dK.height=t,LK=e}},zK={createData:function(e){return e.requestRenderData()},fillBuffers:function(e,t){LG(e.node,t,e.renderData,e.color)},appendQuad:function(e,t,n,i,r,a,s){var o=e.renderData;if(o){var c=o.dataLength;o.dataLength+=4,o.vertexCount=o.dataLength,o.indicesCount=o.dataLength/2*3;var l=o.data,u=t.width,h=t.height,_=n.width,f=n.height,d=0,p=0,m=0,g=0;i?(d=n.x/u,g=(n.x+f)/u,p=(n.y+_)/h,m=n.y/h,l[c].u=d,l[c].v=m,l[c+1].u=d,l[c+1].v=p,l[c+2].u=g,l[c+2].v=m,l[c+3].u=g,l[c+3].v=p):(d=n.x/u,g=(n.x+_)/u,p=(n.y+f)/h,m=n.y/h,l[c].u=d,l[c].v=p,l[c+1].u=g,l[c+1].v=p,l[c+2].u=d,l[c+2].v=m,l[c+3].u=g,l[c+3].v=m),l[c].x=r,l[c].y=a-f*s,l[c+1].x=r+_*s,l[c+1].y=a-f*s,l[c+2].x=r,l[c+2].y=a,l[c+3].x=r+_*s,l[c+3].y=a}}};ke(zK,FK);var UK=null,GK=He(FK,{getAssemblerData:function(){return UK||(UK=new eH(1024,1024)),UK.getTexture()},_updateFontFamily:function(e){tH.fontAtlas=UK,tH.fontFamily=this._getFontFamily(e);var t=e.getComponent(Dq);t&&t.enabled?(tH.isOutlined=!0,tH.margin=t.width,tH.out=t.color.clone(),tH.out.a=t.color.a*e.color.a/255):(tH.isOutlined=!1,tH.margin=0)},_getFontFamily:function(e){var t="Arial";return e.useSystemFont?t=e.fontFamily||"Arial":e.font&&(e.font._nativeAsset?t=e.font._nativeAsset:OI.postLoadNative(e.font,(function(){e.isValid&&(t=e.font._nativeAsset||"Arial",e.updateRenderData(!0))}))),t},_updateLabelInfo:function(e){tH.fontDesc=this._getFontDesc(),tH.color=e.color,tH.hash=function(e){var t=e.color.toHEX(),n="";return e.isOutlined&&e.margin>0&&(n=n+e.margin+e.out.toHEX()),""+e.fontSize+e.fontFamily+t+n}(tH)},_getFontDesc:function(){return tH.fontSize.toString()+"px "+tH.fontFamily},_computeHorizontalKerningForText:function(){},_determineRect:function(){return!1}}),kK=new Cn(255,255,255,255),HK={createData:function(e){return e.requestRenderData()},fillBuffers:function(e,t){if(e.renderData){var n=e.node;kK.a=e.color.a,LG(n,t,e.renderData,kK)}},appendQuad:zK.appendQuad};ke(HK,GK);var VK=rW.Overflow,WK=null,jK=null,qK=null,XK="",YK="",KK=0,ZK=0,QK=[],JK=new $n,$K=0,eZ=0,tZ=0,nZ=new Cn,iZ="",rZ=VK.NONE,aZ=!1,sZ=null,oZ=Cn.BLACK.clone(),cZ=null,lZ=Cn.BLACK.clone(),uZ=new ti,hZ=$n.ZERO.clone(),_Z=$n.ZERO.clone(),fZ=qn.ZERO.clone(),dZ=qn.ZERO.clone(),pZ=0,mZ=0,gZ=!1,vZ=!1,yZ=!1,SZ=["left","center","right"],EZ={getAssemblerData:function(){return rW._canvasPool.get()},resetAssemblerData:function(e){e&&rW._canvasPool.put(e)},updateRenderData:function(e){if(e.renderData&&e.renderData.vertDirty){var t=e.node._uiProps.uiTransformComp;this._updateFontFamily(e),this._updateProperties(e,t),this._calculateLabelFont(),this._updateLabelDimensions(),this._resetDynamicAtlas(e),this._updateTexture(),this._calDynamicAtlas(e),e.actualFontSize=KK,t.setContentSize(JK),this.updateVertexData(e),this.updateUvs(e),e.markForUpdateRenderData(!1),WK=null,jK=null,qK=null}},updateVertexData:function(){},updateUvs:function(){},_updateFontFamily:function(e){e.useSystemFont?iZ=e.fontFamily||"Arial":e.font?e.font._nativeAsset?iZ=e.font._nativeAsset:(OI.postLoadNative(e.font,(function(){e.isValid&&(iZ=e.font._nativeAsset||"Arial",e.updateRenderData(!0))})),iZ="Arial"):iZ="Arial"},_updateProperties:function(e,t){var n=e.assemblerData;n&&(WK=n.context,jK=n.canvas,qK=e.spriteFrame,YK=e.string.toString(),KK=e.fontSize,ZK=KK,rZ=e.overflow,_Z.width=JK.width=t.width,_Z.height=JK.height=t.height,mZ=e.underlineHeight,$K=e.lineHeight,eZ=e.horizontalAlign,tZ=e.verticalAlign,nZ=e.color,gZ=e.isBold,vZ=e.isItalic,yZ=e.isUnderline,aZ=rZ!==VK.NONE&&(rZ===VK.RESIZE_HEIGHT||e.enableWrapText),(sZ=(sZ=Dq&&e.getComponent(Dq))&&sZ.enabled&&sZ.width>0?sZ:null)&&oZ.set(sZ.color),(cZ=(cZ=SY&&e.getComponent(SY))&&cZ.enabled?cZ:null)&&lZ.set(cZ.color),this._updatePaddingRect())},_updatePaddingRect:function(){var e=0,t=0,n=0,i=0,r=0;if(hZ.width=hZ.height=0,sZ&&(e=t=n=i=r=sZ.width,hZ.width=hZ.height=2*r),cZ){var a=cZ.blur+r,s=cZ.offset.x,o=cZ.offset.y;n=Math.max(n,-s+a),i=Math.max(i,s+a),e=Math.max(e,o+a),t=Math.max(t,-o+a)}if(vZ){var c=ZK*Math.tan(.20943951);i+=c,hZ.width+=c}uZ.x=n,uZ.y=e,uZ.width=n+i,uZ.height=e+t},_calculateFillTextStartPosition:function(){var e=0;eZ===ZV.RIGHT?e=JK.width-uZ.width:eZ===ZV.CENTER&&(e=(JK.width-uZ.width)/2);var t=this._getLineHeight()*(QK.length-1),n=KK*(1-mk/2);if(tZ!==QV.TOP){var i=t+uZ.height+KK-JK.height;tZ===QV.BOTTOM?n-=i+=mk/2*KK:n-=i/2}n+=0*KK,fZ.set(e+uZ.x,n+uZ.y)},_updateTexture:function(){if(WK&&jK){WK.clearRect(0,0,jK.width,jK.height),WK.font=XK,this._calculateFillTextStartPosition();var e=this._getLineHeight();WK.lineJoin="round",WK.fillStyle="rgba("+nZ.r+", "+nZ.g+", "+nZ.b+", 1)";var t,n=fZ.x,r=0;this._drawTextEffect(fZ,e);for(var a=0;a<QK.length;++a)r=fZ.y+a*e,sZ&&WK.strokeText(QK[a],n,r),WK.fillText(QK[a],n,r);cZ&&(WK.shadowColor="transparent"),qK&&(t=qK instanceof XG?qK.texture:qK,0!==jK.width&&0!==jK.height&&(t.reset({width:jK.width,height:jK.height,mipmapLevel:1}),t.uploadData(jK),qK instanceof XG&&(qK.rect=new ti(0,0,jK.width,jK.height),qK._calculateUV()),i.director.root&&i.director.root.batcher2D&&i.director.root.batcher2D._releaseDescriptorSetCache(t.getHash())))}},_resetDynamicAtlas:function(e){if(e.cacheMode===rW.CacheMode.BITMAP){var t=e.ttfSpriteFrame;kG.deleteAtlasSpriteFrame(t),t._resetDynamicAtlasFrame()}},_calDynamicAtlas:function(e){if(e.cacheMode===rW.CacheMode.BITMAP){var t=e.ttfSpriteFrame;kG.packToDynamicAtlas(e,t),e.renderData.uvDirty=!0}},_setupOutline:function(){WK.strokeStyle="rgba("+oZ.r+", "+oZ.g+", "+oZ.b+", "+oZ.a/255+")",WK.lineWidth=2*sZ.width},_setupShadow:function(){WK.shadowColor="rgba("+lZ.r+", "+lZ.g+", "+lZ.b+", "+lZ.a/255+")",WK.shadowBlur=cZ.blur,WK.shadowOffsetX=cZ.offset.x,WK.shadowOffsetY=-cZ.offset.y},_drawTextEffect:function(e,t){if(cZ||sZ||yZ){var n=QK.length>1&&cZ,i=this._measureText(WK,XK),r=0,a=0;cZ&&this._setupShadow(),sZ&&this._setupOutline();for(var s=0;s<QK.length;++s)r=e.x,a=e.y+s*t,n&&(sZ&&WK.strokeText(QK[s],r,a),WK.fillText(QK[s],r,a)),yZ&&(pZ=i(QK[s]),eZ===ZV.RIGHT?dZ.x=e.x-pZ:eZ===ZV.CENTER?dZ.x=e.x-pZ/2:dZ.x=e.x,dZ.y=a+ZK/8,WK.fillRect(dZ.x,dZ.y,pZ,mZ));n&&(WK.shadowColor="transparent")}},_updateLabelDimensions:function(){JK.width=Math.min(JK.width,2048),JK.height=Math.min(JK.height,2048);var e=!1;jK.width!==JK.width&&(jK.width=JK.width,e=!0),jK.height!==JK.height&&(jK.height=JK.height,e=!0),e&&(WK.font=XK),WK.textAlign=SZ[eZ],WK.textBaseline="alphabetic"},_getFontDesc:function(){var e=KK.toString()+"px ";return e+=iZ,gZ&&(e="bold "+e),vZ&&(e="italic "+e),e},_getLineHeight:function(){return 0|(0===$K?KK:$K*KK/ZK)},_calculateParagraphLength:function(e,t){for(var n,i=[],r=Z(e);!(n=r()).done;){var a=wk(t,n.value,XK);i.push(a)}return i},_measureText:function(e,t){return function(n){return wk(e,n,t)}},_calculateShrinkFont:function(e){if(WK){var t=this._calculateParagraphLength(e,WK),n=0,i=0,r=0;if(aZ){var a=_Z.width,s=_Z.height;if(a<0||s<0)return;i=s+1;for(var o=0,c=0|KK+1,l=0;o<c;){if((l=o+c+1>>1)<=0){y(4003);break}KK=l,XK=this._getFontDesc(),WK.font=XK;var u=this._getLineHeight();for(i=0,n=0;n<e.length;++n){var h=wk(WK,e[n],XK);i+=Ok(e[n],h,a,this._measureText(WK,XK)).length*u}i>s?c=l-1:o=l}0===o?y(4003):(KK=o,XK=this._getFontDesc(),WK.font=XK)}else{for(i=e.length*this._getLineHeight(),n=0;n<e.length;++n)r<t[n]&&(r=t[n]);var _=(JK.width-uZ.width)/r,f=JK.height/i;KK=ZK*Math.min(1,_,f)|0,XK=this._getFontDesc(),WK.font=XK}}},_calculateWrapText:function(e){if(aZ&&WK){QK=[];for(var t=_Z.width,n=0;n<e.length;++n){var i=wk(WK,e[n],XK),r=Ok(e[n],i,t,this._measureText(WK,XK));QK=QK.concat(r)}}},_calculateLabelFont:function(){if(WK){var e=YK.split("\n");switch(QK=e,XK=this._getFontDesc(),WK.font=XK,rZ){case VK.NONE:for(var t=0,n=0,i=0;i<e.length;++i){var r=wk(WK,e[i],XK);t=t>r?t:r}n=(QK.length+mk)*this._getLineHeight();var a=parseFloat(t.toFixed(2)),s=parseFloat(n.toFixed(2));JK.width=a+uZ.width,JK.height=s+uZ.height,_Z.width=a+hZ.width,_Z.height=s+hZ.height;break;case VK.SHRINK:this._calculateShrinkFont(e),this._calculateWrapText(e);break;case VK.CLAMP:this._calculateWrapText(e);break;case VK.RESIZE_HEIGHT:this._calculateWrapText(e);var o=(QK.length+mk)*this._getLineHeight();JK.height=o+uZ.height,_Z.height=o+hZ.height}}}},TZ=Cn.WHITE.clone(),AZ={createData:function(e){var t=e.requestRenderData();t.dataLength=4,t.vertexCount=4,t.indicesCount=6;var n=t.vData=new Float32Array(36);n[3]=n[21]=n[22]=n[31]=0,n[4]=n[12]=n[13]=n[30]=1;for(var i=5,r=0;r<4;r++)Cn.toArray(n,TZ,i),i+=9;return t},fillBuffers:function(e,t){var n=e.renderData,i=n.data,r=e.node,a=t.acquireBufferBatch(),s=a.byteOffset>>2,o=a.indicesOffset,c=a.vertexOffset;a.request()||(a=t.currBufferBatch,o=0,c=0,s=0);var l=a.vData,u=a.iData,h=n.vData,_=i[0],f=i[3];r.updateWorldTransform();var d=r._pos,p=r._rot,m=r._scale,g=_.x*m.x,v=f.x*m.x,y=_.y*m.y,S=f.y*m.y,E=p.x,T=p.y,A=p.z,x=p.w,C=E*T,R=A*x,b=E*E-T*T,w=x*x-A*A,I=w+b,O=2*(C-R),P=w-b,M=2*(C+R),N=d.x,D=d.y;h[0]=I*g+O*y+N,h[1]=P*y+M*g+D,h[9]=I*v+O*y+N,h[10]=P*y+M*v+D,h[18]=I*g+O*S+N,h[19]=P*S+M*g+D,h[27]=I*v+O*S+N,h[28]=P*S+M*v+D,l.set(h,s),u[o++]=c,u[o++]=c+1,u[o++]=c+2,u[o++]=c+2,u[o++]=c+1,u[o++]=c+3},updateVertexData:function(e){var t=e.renderData;if(t){var n=e.node._uiProps.uiTransformComp,i=n.width,r=n.height,a=n.anchorX*i,s=n.anchorY*r,o=t.data;o[0].x=-a,o[0].y=-s,o[3].x=i-a,o[3].y=r-s}},updateUvs:function(e){var t=e.renderData;if(t){var n=t.vData;if(n&&t.uvDirty){var i=e.ttfSpriteFrame.uv;n[3]=i[0],n[4]=i[1],n[12]=i[2],n[13]=i[3],n[21]=i[4],n[22]=i[5],n[30]=i[6],n[31]=i[7],t.uvDirty=!1}}}};ke(AZ,EZ);var xZ=e("labelAssembler",{getAssembler:function(e){var t=AZ;return e.font instanceof dk?t=zK:e.cacheMode===rW.CacheMode.CHAR&&(t=HK),t}});rW.Assembler=xZ;var CZ=Kq.FillType,RZ=new Hn,bZ={useModel:!1,updateRenderData:function(e){var t=e.spriteFrame;kG.packToDynamicAtlas(e,t);var n=e.renderData;if(n&&t){var i=n.uvDirty,r=n.vertDirty;if(!i&&!r)return;var a=e.fillStart,s=e.fillRange;s<0&&(a+=s,s=-s),s=(s=(s=a+s)>1?1:s)<0?0:s;var o=(a=(a=a>1?1:a)<0?0:a)+(s=(s-=a)<0?0:s);o=o>1?1:o,i&&this.updateUVs(e,a,o),r&&(this.updateVertexData&&this.updateVertexData(e,a,o),this.updateWorldVertexData(e))}},updateUVs:function(e,t,n){var i=e.spriteFrame,r=e.renderData,a=r.data,s=i.width,o=i.height,c=i.getRect(),l=0,u=0,h=0,_=0,f=0,d=0,p=0,m=0,g=0,v=0;switch(i.isRotated()?(l=c.x/s,u=(c.y+c.width)/o,h=f=l,p=g=(c.x+c.height)/s,d=v=u,_=m=c.y/o):(l=c.x/s,u=(c.y+c.height)/o,h=p=l,f=g=(c.x+c.width)/s,_=d=u,m=v=c.y/o),e.fillType){case CZ.HORIZONTAL:a[0].u=h+(f-h)*t,a[0].v=_+(d-_)*t,a[1].u=h+(f-h)*n,a[1].v=_+(d-_)*n,a[2].u=p+(g-p)*t,a[2].v=m+(v-m)*t,a[3].u=p+(g-p)*n,a[3].v=m+(v-m)*n;break;case CZ.VERTICAL:a[0].u=h+(p-h)*t,a[0].v=_+(m-_)*t,a[1].u=f+(g-f)*t,a[1].v=d+(v-d)*t,a[2].u=h+(p-h)*n,a[2].v=_+(m-_)*n,a[3].u=f+(g-f)*n,a[3].v=d+(v-d)*n;break;default:A(2626)}r.uvDirty=!1},updateVertexData:function(e,t,n){var i=e.renderData,r=i.data,a=e.node._uiProps.uiTransformComp,s=a.width,o=a.height,c=a.anchorX*s,l=a.anchorY*o,u=-c,h=-l,_=s-c,f=o-l,d=0;switch(e.fillType){case CZ.HORIZONTAL:d=u+(_-u)*n,u+=(_-u)*t,_=d;break;case CZ.VERTICAL:d=h+(f-h)*n,h+=(f-h)*t,f=d;break;default:A(2626)}r[4].x=u,r[4].y=h,r[5].x=_,r[5].y=h,r[6].x=u,r[6].y=f,r[7].x=_,r[7].y=f,i.vertDirty=!1},createData:function(e){var t=e.requestRenderData();t.dataLength=8,t.vertexCount=4,t.indicesCount=6;for(var n,i=Z(t.data);!(n=i()).done;)n.value.z=0;return t},updateWorldVertexData:function(e){var t=e.node,n=e.renderData.data;t.getWorldMatrix(RZ);for(var i=0;i<4;i++){var r=n[i+4],a=n[i];bn.transformMat4(a,r,RZ)}},fillBuffers:function(e,t){e.node.hasChangedFlags&&this.updateWorldVertexData(e),e.node,function(e,t,n,i){var r=n.data,a=t.acquireBufferBatch(),s=a.byteOffset>>2,o=n.vertexCount,c=a.indicesOffset,l=a.vertexOffset;a.request(o,n.indicesCount)||(a=t.currBufferBatch,o=0,c=0,l=0);for(var u=a.vData,h=0;h<o;h++){var _=r[h];u[s++]=_.x,u[s++]=_.y,u[s++]=_.z,u[s++]=_.u,u[s++]=_.v,Cn.toArray(u,i,s),s+=4}var f=a.iData;f[c++]=l,f[c++]=l+1,f[c++]=l+2,f[c++]=l+1,f[c++]=l+3,f[c++]=l+2}(0,t,e.renderData,e.color)}},wZ=2*Math.PI,IZ=[new qn,new qn,new qn,new qn],OZ=new Array(4),PZ=new Array(8),MZ=[new qn,new qn,new qn,new qn],NZ=[new qn,new qn,new qn,new qn],DZ=new qn,BZ=[new qn,new qn,new qn,new qn];function LZ(e,t,n,i,r,a,s){var o=Math.sin(a);o=Math.abs(o)>1e-6?o:0;var c=Math.cos(a),l=0,u=0;if(0!==(c=Math.abs(c)>1e-6?c:0)){if(l=o/c,(e-r.x)*c>0){var h=r.y+l*(e-r.x);s[0].x=e,s[0].y=h}if((t-r.x)*c>0){var _=r.y+l*(t-r.x);s[2].x=t,s[2].y=_}}if(0!==o){if(u=c/o,(i-r.y)*o>0){var f=r.x+u*(i-r.y);s[3].x=f,s[3].y=i}if((n-r.y)*o>0){var d=r.x+u*(n-r.y);s[1].x=d,s[1].y=n}}}function FZ(e,t){var n=t.x-e.x,i=t.y-e.y;if(0===n&&0===i)return 0;if(0===n)return i>0?.5*Math.PI:1.5*Math.PI;var r=Math.atan(i/n);return n<0&&(r+=Math.PI),r}function zZ(e,t,n,i,r){var a=OZ,s=a[0],o=a[1],c=a[2],l=a[3];e[t].x=n.x,e[t].y=n.y,e[t+1].x=i.x,e[t+1].y=i.y,e[t+2].x=r.x,e[t+2].y=r.y,UZ((n.x-s)/(c-s),(n.y-o)/(l-o),e,t),UZ((i.x-s)/(c-s),(i.y-o)/(l-o),e,t+1),UZ((r.x-s)/(c-s),(r.y-o)/(l-o),e,t+2)}function UZ(e,t,n,i){var r=PZ,a=r[0]+(r[2]-r[0])*e,s=r[4]+(r[6]-r[4])*e,o=r[1]+(r[3]-r[1])*e,c=r[5]+(r[7]-r[5])*e,l=n[i];l.u=a+(s-a)*t,l.v=o+(c-o)*t}for(var GZ={useModel:!1,createData:function(e){return e.requestRenderData()},updateRenderData:function(e){var t=e.spriteFrame;kG.packToDynamicAtlas(e,t);var n=e.renderData;if(n&&t&&(n.vertDirty||n.uvDirty)){var i=n.data,r=e.fillStart,a=e.fillRange;for(a<0&&(r+=a,a=-a);r>=1;)r-=1;for(;r<0;)r+=1;var s=(r*=wZ)+(a*=wZ);!function(e){var t=e.node._uiProps.uiTransformComp,n=t.width,i=t.height,r=t.anchorX*n,a=t.anchorY*i,s=-r,o=-a,c=n-r,l=i-a,u=OZ;u[0]=s,u[1]=o,u[2]=c,u[3]=l;var h=e.fillCenter,_=DZ.x=Math.min(Math.max(0,h.x),1)*(c-s)+s,f=DZ.y=Math.min(Math.max(0,h.y),1)*(l-o)+o;IZ[0].x=IZ[3].x=s,IZ[1].x=IZ[2].x=c,IZ[0].y=IZ[1].y=o,IZ[2].y=IZ[3].y=l;for(var d,p=Z(BZ);!(d=p()).done;){var m=d.value;qn.set(m,0,0)}_!==u[0]&&qn.set(BZ[0],3,0),_!==u[2]&&qn.set(BZ[2],1,2),f!==u[1]&&qn.set(BZ[1],0,1),f!==u[3]&&qn.set(BZ[3],2,3)}(e),function(e){var t=e.width,n=e.height,i=e.getRect(),r=0,a=0,s=0,o=0,c=PZ;e.isRotated()?(r=i.x/t,a=(i.x+i.height)/t,s=i.y/n,o=(i.y+i.width)/n,c[0]=c[2]=r,c[4]=c[6]=a,c[3]=c[7]=o,c[1]=c[5]=s):(r=i.x/t,a=(i.x+i.width)/t,s=i.y/n,o=(i.y+i.height)/n,c[0]=c[4]=r,c[2]=c[6]=a,c[1]=c[3]=o,c[5]=c[7]=s)}(t),LZ(OZ[0],OZ[2],OZ[1],OZ[3],DZ,r,MZ),LZ(OZ[0],OZ[2],OZ[1],OZ[3],DZ,r+a,NZ);for(var o=0,c=0;c<4;++c){var l=BZ[c];if(l)if(a>=wZ)n.dataLength=o+3,zZ(i,o,DZ,IZ[l.x],IZ[l.y]),o+=3;else{var u=FZ(DZ,IZ[l.x]),h=FZ(DZ,IZ[l.y]);h<u&&(h+=wZ),u-=wZ,h-=wZ;for(var _=0;_<3;++_)u>=s||(u>=r?(n.dataLength=o+3,zZ(i,o,DZ,IZ[l.x],h>=s?NZ[c]:IZ[l.y]),o+=3):h>r&&(h<=s?(n.dataLength=o+3,zZ(i,o,DZ,MZ[c],IZ[l.y]),o+=3):(n.dataLength=o+3,zZ(i,o,DZ,MZ[c],NZ[c]),o+=3))),u+=wZ,h+=wZ}}n.indicesCount=n.vertexCount=o,n.vertDirty=n.uvDirty=!1}},fillBuffers:function(e,t){!function(e,t,n,i){var r=n.data,a=t.acquireBufferBatch(),s=a.byteOffset>>2,o=n.vertexCount,c=a.indicesOffset,l=a.vertexOffset;a.request(o,n.indicesCount)||(a=t.currBufferBatch,o=0,c=0,l=0);var u=a.vData;e.getWorldMatrix(BG);for(var h=0;h<o;h++){var _=r[h];bn.set(DG,_.x,_.y,0),bn.transformMat4(DG,DG,BG),u[s++]=DG.x,u[s++]=DG.y,u[s++]=DG.z,u[s++]=_.u,u[s++]=_.v,Cn.toArray(u,i,s),s+=4}for(var f=a.iData,d=0;d<n.dataLength;d++)f[c+d]=l+d}(e.node,t,e.renderData,e.color)}},kZ=[],HZ=0;HZ<4;HZ++)kZ.push(new bn);for(var VZ={createData:function(e){var t=e.requestRenderData();return t.dataLength=4,t.vertexCount=4,t.indicesCount=6,t.vData=new Float32Array(36),t},updateRenderData:function(e){var t=e.spriteFrame;kG.packToDynamicAtlas(e,t);var n=e.renderData;n&&t&&(n.vertDirty&&this.updateVertexData(e),n.uvDirty&&this.updateUvs(e))},fillBuffers:function(e,t){if(null!==e){var n=e.renderData.data,i=e.node,r=t.acquireBufferBatch(),a=r.byteOffset>>2,s=r.indicesOffset,o=r.vertexOffset;r.request()||(r=t.currBufferBatch,a=0,s=0,o=0);var c=r.vData,l=r.iData,u=e.renderData.vData,h=n[0],_=n[3],f=i.worldMatrix,d=f.m00,p=f.m01,m=f.m04,g=f.m05,v=f.m12,y=f.m13,S=h.x,E=_.x,T=h.y,A=_.y,x=d*S,C=d*E,R=p*S,b=p*E,w=m*T,I=m*A,O=g*T,P=g*A;u[0]=x+w+v,u[1]=R+O+y,u[9]=C+w+v,u[10]=b+O+y,u[18]=x+I+v,u[19]=R+P+y,u[27]=C+I+v,u[28]=b+P+y,c.set(u,a),l[s++]=o,l[s++]=o+1,l[s++]=o+2,l[s++]=o+2,l[s++]=o+1,l[s++]=o+3}},updateVertexData:function(e){var t=e.renderData;if(t){var n=e.node._uiProps.uiTransformComp,i=t.data,r=n.width,a=n.height,s=n.anchorX*r,o=n.anchorY*a,c=0,l=0,u=0,h=0;if(e.trim)c=-s,l=-o,u=r-s,h=a-o;else{var _=e.spriteFrame,f=_.getOriginalSize(),d=_.getRect(),p=f.width,m=f.height,g=d.width,v=d.height,y=_.getOffset(),S=r/p,E=a/m,T=y.x+(p-g)/2,A=y.x-(p-g)/2;c=T*S-s,l=(y.y+(m-v)/2)*E-o,u=r+A*S-s,h=a+(y.y-(m-v)/2)*E-o}i[0].x=c,i[0].y=l,i[0].z=0,i[3].x=u,i[3].y=h,i[3].z=0,t.vertDirty=!1}},updateUvs:function(e){var t=e.renderData,n=t.vData,i=e.spriteFrame.uv;n[3]=i[0],n[4]=i[1],n[12]=i[2],n[13]=i[3],n[21]=i[4],n[22]=i[5],n[30]=i[6],n[31]=i[7],t.uvDirty=!1},updateColor:function(e){for(var t=e.renderData.vData,n=5,i=e.color,r=i.r/255,a=i.g/255,s=i.b/255,o=i.a/255,c=0;c<4;c++)t[n]=r,t[n+1]=a,t[n+2]=s,t[n+3]=o,n+=9}},WZ=new bn,jZ=new Hn,qZ={useModel:!1,createData:function(e){var t=e.requestRenderData();return t.dataLength=20,t.vertexCount=16,t.indicesCount=54,t},updateRenderData:function(e){var t=e.spriteFrame;kG.packToDynamicAtlas(e,t);var n=e.renderData;n&&t&&n.vertDirty&&(this.updateVertexData(e),this.updateWorldVertexData(e))},updateVertexData:function(e){var t=e.renderData,n=t.data,i=e.node._uiProps.uiTransformComp,r=i.width,a=i.height,s=i.anchorX*r,o=i.anchorY*a,c=e.spriteFrame,l=c.insetLeft,u=c.insetRight,h=c.insetTop,_=c.insetBottom,f=r-l-u,d=a-h-_,p=r/(l+u),m=a/(h+_);p=Number.isNaN(p)||p>1?1:p,m=Number.isNaN(m)||m>1?1:m,f=f<0?0:f,d=d<0?0:d,n[0].x=-s,n[0].y=-o,n[1].x=l*p-s,n[1].y=_*m-o,n[2].x=n[1].x+f,n[2].y=n[1].y+d,n[3].x=r-s,n[3].y=a-o,t.vertDirty=!1},fillBuffers:function(e,t){e.node.hasChangedFlags&&this.updateWorldVertexData(e);var n=t.acquireBufferBatch(),i=e.renderData,r=i.data,a=n.byteOffset>>2,s=i.vertexCount,o=n.indicesOffset,c=n.vertexOffset,l=e.spriteFrame.uvSliced;n.request(s,i.indicesCount)||(n=t.currBufferBatch,a=0,o=0,c=0);for(var u=n.vData,h=n.iData,_=4;_<20;++_){var f=r[_],d=l[_-4];u[a++]=f.x,u[a++]=f.y,u[a++]=f.z,u[a++]=d.u,u[a++]=d.v,Cn.toArray(u,e.color,a),a+=4}for(var p=0;p<3;++p)for(var m=0;m<3;++m){var g=c+4*p+m;h[o++]=g,h[o++]=g+1,h[o++]=g+4,h[o++]=g+1,h[o++]=g+5,h[o++]=g+4}},updateWorldVertexData:function(e){var t=e.node,n=e.renderData.data;t.getWorldMatrix(jZ);for(var i=0;i<4;++i)for(var r=n[i],a=0;a<4;++a){var s=n[a],o=n[4+4*i+a];bn.set(WZ,s.x,r.y,0),bn.transformMat4(o,WZ,jZ)}}},XZ=[],YZ=0;YZ<4;YZ++)XZ.push(new bn);var KZ={useModel:!1,sizableWidth:0,sizableHeight:0,vRepeat:0,hRepeat:0,row:0,col:0,createData:function(e){return e.requestRenderData()},updateRenderData:function(e){var t=e.renderData,n=e.spriteFrame;if(n&&t&&(t.uvDirty||t.vertDirty)){var i=e.node._uiProps.uiTransformComp,r=Math.abs(i.width),a=Math.abs(i.height),s=n.getRect(),o=n.insetLeft,c=n.insetRight,l=s.width-o-c,u=n.insetTop,h=n.insetBottom,_=s.height-u-h;this.sizableWidth=r-o-c,this.sizableHeight=a-u-h,this.sizableWidth=this.sizableWidth>0?this.sizableWidth:0,this.sizableHeight=this.sizableHeight>0?this.sizableHeight:0,this.hRepeat=0===l?this.sizableWidth:this.sizableWidth/l,this.vRepeat=0===_?this.sizableHeight:this.sizableHeight/_,this.row=Math.ceil(this.vRepeat+2),this.col=Math.ceil(this.hRepeat+2),t.dataLength=Math.max(8,this.row+1,this.col+1),this.updateVerts(e),t.vertexCount=this.row*this.col*4,t.indicesCount=this.row*this.col*6,t.uvDirty=!1,t.vertDirty=!1}},fillBuffers:function(e,t){var n=e.node,i=e.renderData,r=t.acquireBufferBatch(),a=r.indicesOffset,s=r.byteOffset>>2,o=r.vertexOffset,c=i.vertexCount,l=i.indicesCount,u=r.vData,h=r.iData;r.request(c,l)||(r=t.currBufferBatch,s=0,a=0,o=0);var _=e.spriteFrame,f=_.isRotated(),d=_.uv,p=_.uvSliced,m=_.getRect(),g=_.insetLeft,v=_.insetRight,y=m.width-g-v,S=_.insetTop,E=_.insetBottom,T=m.height-S-E,A=n.worldMatrix;this.fillVertices(u,s,A,this.row,this.col,i.data);for(var x=0,C=0,R=0,b=this.row;R<b;++R){C=this.sizableHeight>T?this.sizableHeight>=R*T?1:this.vRepeat%1:this.vRepeat;for(var w=0,I=this.col;w<I;++w){x=this.sizableWidth>y?this.sizableWidth>=w*y?1:this.hRepeat%1:this.hRepeat;var O=s+3,P=O+1;f?(u[O]=d[0],u[P]=d[1],u[O+9]=d[0],u[P+9]=d[1]+(d[7]-d[1])*x,u[O+18]=d[0]+(d[6]-d[0])*C,u[P+18]=d[1],u[O+27]=u[O+18],u[P+27]=u[P+9]):(0===w?u[O]=d[0]:w>0&&w<this.col-1?u[O]=p[1].u:w===this.col-1&&(u[O]=p[2].u),0===R?u[P]=p[0].v:R>0&&R<this.row-1?u[P]=p[4].v:R===this.row-1&&(u[P]=p[8].v),0===w||w>0&&w<this.col-1?u[O+9]=p[1].u+(p[2].u-p[1].u)*x:w===this.col-1&&(u[O+9]=p[3].u),0===R?u[P+9]=p[0].v:R>0&&R<this.row-1?u[P+9]=p[4].v:R===this.row-1&&(u[P+9]=p[8].v),0===w?u[O+18]=d[0]:w>0&&w<this.col-1?u[O+18]=p[1].u:w===this.col-1&&(u[O+18]=p[2].u),0===R||R>0&&R<this.row-1?u[P+18]=p[4].v+(p[8].v-p[4].v)*C:R===this.row-1&&(u[P+18]=p[12].v),u[O+27]=u[O+9],u[P+27]=u[P+18]),Cn.toArray(u,e.color,P+1),Cn.toArray(u,e.color,P+9+1),Cn.toArray(u,e.color,P+18+1),Cn.toArray(u,e.color,P+27+1),s+=36}}for(var M=0;M<l;M+=6)h[a++]=o,h[a++]=o+1,h[a++]=o+2,h[a++]=o+1,h[a++]=o+3,h[a++]=o+2,o+=4},fillVertices:function(e,t,n,i,r,a){for(var s=0,o=0,c=0,l=0,u=0,h=i;u<h;++u){c=a[u].y,l=a[u+1].y;for(var _=0,f=r;_<f;++_){s=a[_].x,o=a[_+1].x,bn.set(XZ[0],s,c,0),bn.set(XZ[1],o,c,0),bn.set(XZ[2],s,l,0),bn.set(XZ[3],o,l,0);for(var d=0;d<4;d++){var p=XZ[d];bn.transformMat4(p,p,n);var m=9*d;e[t+m]=p.x,e[t+m+1]=p.y,e[t+m+2]=p.z}t+=36}}},updateVerts:function(e){var t,n,i=e.node._uiProps.uiTransformComp,r=e.renderData.data,a=e.spriteFrame,s=a.getRect(),o=Math.abs(i.width),c=Math.abs(i.height),l=i.anchorX*o,u=i.anchorY*c,h=a.insetLeft,_=a.insetRight,f=s.width-h-_,d=a.insetTop,p=a.insetBottom,m=s.height-d-p,g=i.width/(h+_)>1?1:i.width/(h+_),v=i.height/(d+p)>1?1:i.height/(d+p);t=f>0?Math.floor(1e3*this.sizableWidth)/1e3%f==0?f:this.sizableWidth%f:this.sizableWidth,n=m>0?Math.floor(1e3*this.sizableHeight)/1e3%m==0?m:this.sizableHeight%m:this.sizableHeight;for(var y=0;y<=this.col;y++)0===y?r[y].x=-l:y>0&&y<this.col?1===y?r[y].x=h*g+Math.min(f,this.sizableWidth)-l:f>0?y===this.col-1?r[y].x=h+t+f*(y-2)-l:r[y].x=h+Math.min(f,this.sizableWidth)+f*(y-2)-l:r[y].x=h+this.sizableWidth-l:y===this.col&&(r[y].x=Math.min(h+this.sizableWidth+_,o)-l);for(var S=0;S<=this.row;S++)0===S?r[S].y=-u:S>0&&S<this.row?1===S?r[S].y=p*v+Math.min(m,this.sizableHeight)-u:m>0?S===this.row-1?r[S].y=p+n+(S-2)*m-u:r[S].y=p+Math.min(m,this.sizableHeight)+(S-2)*m-u:r[S].y=p+this.sizableHeight-u:S===this.row&&(r[S].y=Math.min(p+this.sizableHeight+d,c)-u)}},ZZ=Kq.Type,QZ=Kq.FillType,JZ=e("spriteAssembler",{getAssembler:function(e){var t=VZ,n=e;switch(n.type){case ZZ.SLICED:t=qZ;break;case ZZ.TILED:t=KZ;break;case ZZ.FILLED:t=n.fillType===QZ.RADIAL?GZ:bZ}return t}});Kq.Assembler=JZ;var $Z=VH.sharedManager,eQ={createData:function(e){var t=e.requestRenderData();return t.dataLength=4,t.vertexCount=4,t.indicesCount=6,t.vData=new Float32Array(36),t},updateRenderData:function(e){e.type===Sj.IMAGE_STENCIL&&(VZ.updateRenderData(e),VZ.updateColor(e))},fillBuffers:function(e,t){(e.type!==Sj.IMAGE_STENCIL||e.spriteFrame)&&($Z.pushMask(e),t.finishMergeBatches(),function(e,t){$Z.clear(e),t.commitModel(e,e._clearModel,e._clearStencilMtl)}(e,t),function(e,t){if($Z.enterLevel(e),e.type===Sj.IMAGE_STENCIL){VZ.fillBuffers(e,t);var n=e.graphics.getMaterialInstance(0);t.forceMergeBatches(n,e.spriteFrame,e.graphics)}else e.graphics.updateAssembler(t)}(e,t),$Z.enableMask())}},tQ={fillBuffers:function(){$Z.exitMask()}},nQ={getAssembler:function(){return eQ}},iQ={getAssembler:function(){return tQ}};Ij.Assembler=nQ,Ij.PostAssembler=iQ;var rQ=new Po(null),aQ=new Hn,sQ=e("UI",function(){var e=t.prototype;function t(e){var t=this;this.device=void 0,this._screens=[],this._bufferBatchPool=new l_((function(){return new WX(t)}),128),this._drawBatchPool=void 0,this._meshBuffers=new Map,this._customMeshBuffers=new Map,this._meshBufferUseCount=new Map,this._batches=void 0,this._doUploadBuffersCall=new Map,this._emptyMaterial=new em,this._currScene=null,this._currMaterial=this._emptyMaterial,this._currTexture=null,this._currSampler=null,this._currMeshBuffer=null,this._currStaticRoot=null,this._currComponent=null,this._currTransform=null,this._currTextureHash=0,this._currSamplerHash=0,this._currBlendTargetHash=0,this._currLayer=0,this._currDepthStencilStateStage=null,this._parentOpacity=1,this._descriptorSetCache=new cQ,this._root=e,this.device=e.device,this._batches=new u_(64),this._drawBatchPool=new c_((function(){return new vY}),128)}return e.acquireBufferBatch=function(e){void 0===e&&(e=VW);var t=e===VW?36:qW(e);return this._currMeshBuffer&&this._currMeshBuffer.vertexFormatBytes===t||this._requireBufferBatch(e),this._currMeshBuffer},e.registerCustomBuffer=function(e,t){var n;e instanceof WX?n=e:(n=this._bufferBatchPool.add()).initialize(e,t||this._recreateMeshBuffer.bind(this,e));var i=n.vertexFormatBytes,r=this._customMeshBuffers.get(i);return r||(r=[],this._customMeshBuffers.set(i,r)),r.push(n),n},e.unRegisterCustomBuffer=function(e){var t=this._customMeshBuffers.get(e.vertexFormatBytes);if(t)for(var n=0;n<t.length;n++)if(t[n]===e){t.splice(n,1);break}},j(t,[{key:"currBufferBatch",get:function(){return this._currMeshBuffer||(this._currMeshBuffer=this.acquireBufferBatch()),this._currMeshBuffer},set:function(e){e&&(this._currMeshBuffer=e)}},{key:"batches",get:function(){return this._batches}},{key:"currStaticRoot",set:function(e){this._currStaticRoot=e}}]),e.initialize=function(){return!0},e.destroy=function(){for(var e=this,t=0;t<this._batches.length;t++)this._batches.array[t]&&this._batches.array[t].destroy(this);this._batches.destroy();for(var n,i=Z(this._meshBuffers.keys());!(n=i()).done;){var r=n.value,a=this._meshBuffers.get(r);a&&a.forEach((function(e){return e.destroy()}))}this._drawBatchPool&&this._drawBatchPool.destroy((function(t){t.destroy(e)})),this._descriptorSetCache.destroy(),this._meshBuffers.clear(),VH.sharedManager.destroy()},e.addScreen=function(e){this._screens.push(e),this._screens.sort(this._screenSort)},e.getFirstRenderCamera=function(e){if(e.scene&&e.scene.renderScene)for(var t=e.scene.renderScene.cameras,n=0;n<t.length;n++){var i=t[n];if(i.visibility&e.layer)return i}return null},e.removeScreen=function(e){var t=this._screens.indexOf(e);-1!==t&&this._screens.splice(t,1)},e.sortScreens=function(){this._screens.sort(this._screenSort)},e.addUploadBuffersFunc=function(e,t){this._doUploadBuffersCall.set(e,t)},e.removeUploadBuffersFunc=function(e){this._doUploadBuffersCall.delete(e)},e.update=function(){for(var e=this._screens,t=0;t<e.length;++t){var n=e[t];n.enabledInHierarchy&&this._recursiveScreenNode(n.node)}var i=0;if(this._batches.length)for(var r=0;r<this._batches.length;++r){var a=this._batches.array[r];if(a.renderScene){if(a.model)for(var s=a.model.subModels,o=0;o<s.length;o++)s[o].priority=i++;else a.hDescriptorSet=this._descriptorSetCache.getDescriptorSet(a);a.renderScene.addBatch(a)}}},e.uploadBuffers=function(){if(this._batches.length>0){for(var e,t=this._doUploadBuffersCall,n=Z(t.keys());!(e=n()).done;){var i=e.value;t.get(i).call(i,this)}for(var r,a=this._meshBuffers,s=Z(a.keys());!(r=s()).done;){var o=r.value,c=a.get(o);c&&c.forEach((function(e){e.uploadBuffers(),e.reset()}))}for(var l,u=this._customMeshBuffers,h=Z(u.keys());!(l=h()).done;){var _=l.value,f=u.get(_);f&&f.forEach((function(e){e.uploadBuffers(),e.reset()}))}this._descriptorSetCache.update()}},e.reset=function(){for(var e=0;e<this._batches.length;++e){var t=this._batches.array[e];t.isStatic||(t.clear(),this._drawBatchPool.free(t))}this._parentOpacity=1,this._currLayer=0,this._currMaterial=this._emptyMaterial,this._currTexture=null,this._currSampler=null,this._currComponent=null,this._currTransform=null,this._currScene=null,this._currMeshBuffer=null,this._meshBufferUseCount.clear(),this._batches.clear(),VH.sharedManager.reset(),this._descriptorSetCache.reset()},e.commitComp=function(e,t,n,i){var r,a,s=e,o=0,c=0;t?(r=t.getGFXTexture(),a=t.getGFXSampler(),o=t.getHash(),c=t.getSamplerHash()):(r=null,a=null);var l=s._getRenderScene(),u=s.getRenderMaterial(0);s.stencilStage=VH.sharedManager.stage;var h=s.blendHash,_=s.stencilStage;this._currScene===l&&this._currLayer===e.node.layer&&this._currMaterial===u&&this._currBlendTargetHash===h&&this._currDepthStencilStateStage===_&&this._currTextureHash===o&&this._currSamplerHash===c&&this._currTransform===i||(this.autoMergeBatches(this._currComponent),this._currScene=l,this._currComponent=s,this._currTransform=i,this._currMaterial=u,this._currTexture=r,this._currSampler=a,this._currTextureHash=o,this._currSamplerHash=c,this._currBlendTargetHash=h,this._currDepthStencilStateStage=_,this._currLayer=e.node.layer),n&&(n.fillBuffers(s,this),this._applyOpacity(s))},e.commitModel=function(e,t,n){var r;this._currMaterial!==this._emptyMaterial&&this.autoMergeBatches(this._currComponent);var a=0;n&&(e.stencilStage!==Xk.ENABLED&&e.stencilStage!==Xk.DISABLED||(e.stencilStage=VH.sharedManager.stage),r=VH.sharedManager.getStencilStage(e.stencilStage,n),a=VH.sharedManager.getStencilHash(e.stencilStage));var s=i.director.getTotalFrames();t&&(t.updateTransform(s),t.updateUBOs(s));for(var o=0;o<t.subModels.length;o++){var c=this._drawBatchPool.alloc(),l=t.subModels[o];c.renderScene=e._getRenderScene(),c.visFlags=e.node.layer,c.model=t,c.bufferBatch=null,c.texture=null,c.sampler=null,c.useLocalData=null,r||(r=null),c.fillPasses(n,r,a,null,0,l.patches),c.hDescriptorSet=ir.get(l.handle,Ji.DESCRIPTOR_SET),c.hInputAssembler=ir.get(l.handle,Ji.INPUT_ASSEMBLER),c.model.visFlags=c.visFlags,this._batches.push(c)}this._currMaterial=this._emptyMaterial,this._currScene=null,this._currComponent=null,this._currTransform=null,this._currTexture=null,this._currSampler=null,this._currTextureHash=0,this._currSamplerHash=0,this._currLayer=0},e.commitStaticBatch=function(e){this._batches.concat(e.drawBatchList),this.finishMergeBatches()},e.autoMergeBatches=function(e){var t=this.currBufferBatch,n=null==t?void 0:t.recordBatch(),i=this._currMaterial;if(n&&i&&t){var r,a,s=0,o=0;e&&(r=-1===e.blendHash?null:e.getBlendState(),o=e.blendHash,a=null!==e.customMaterial?VH.sharedManager.getStencilStage(e.stencilStage,i):VH.sharedManager.getStencilStage(e.stencilStage),s=VH.sharedManager.getStencilHash(e.stencilStage));var c=this._currStaticRoot?this._currStaticRoot._requireDrawBatch():this._drawBatchPool.alloc();c.renderScene=this._currScene,c.visFlags=this._currLayer,c.bufferBatch=t,c.texture=this._currTexture,c.sampler=this._currSampler,c.hInputAssembler=n,c.useLocalData=this._currTransform,c.textureHash=this._currTextureHash,c.samplerHash=this._currSamplerHash,c.fillPasses(i,a,s,r,o,null),this._batches.push(c),t.vertexStart=t.vertexOffset,t.indicesStart=t.indicesOffset,t.byteStart=t.byteOffset,mg.__isWebIOS14OrIPadOS14Env&&(this._currMeshBuffer=null)}},e.forceMergeBatches=function(e,t,n){this._currMaterial=e,t?(this._currTexture=t.getGFXTexture(),this._currSampler=t.getGFXSampler(),this._currTextureHash=t.getHash(),this._currSamplerHash=t.getSamplerHash()):(this._currTexture=this._currSampler=null,this._currTextureHash=this._currSamplerHash=0),this._currLayer=n.node.layer,this._currScene=n._getRenderScene(),this.autoMergeBatches(n)},e.finishMergeBatches=function(){this.autoMergeBatches(),this._currMaterial=this._emptyMaterial,this._currTexture=null,this._currComponent=null,this._currTransform=null,this._currTextureHash=0,this._currSamplerHash=0,this._currLayer=0},e.flushMaterial=function(e){this._currMaterial=e},e.walk=function(e,t){void 0===t&&(t=0);var n=e.children.length,i=this._parentOpacity;if(this._parentOpacity*=e._uiProps.opacity,this._preProcess(e),n>0&&!e._static)for(var r=e.children,a=0;a<r.length;++a){var s=r[a];this.walk(s,t)}this._postProcess(e),this._parentOpacity=i,t+=1},e._preProcess=function(e){if(e._uiProps.uiTransformComp){var t=e._uiProps.uiComp;t&&t.enabledInHierarchy&&t.updateAssembler(this)}},e._postProcess=function(e){var t=e._uiProps.uiComp;t&&t.enabledInHierarchy&&t.postUpdateAssembler(this)},e._recursiveScreenNode=function(e){this.walk(e),this.autoMergeBatches(this._currComponent)},e._createMeshBuffer=function(e){var t=this._bufferBatchPool.add();t.initialize(e,this._recreateMeshBuffer.bind(this,e));var n=qW(e),i=this._meshBuffers.get(n);return i||(i=[],this._meshBuffers.set(n,i)),i.push(t),t},e._recreateMeshBuffer=function(e,t,n){this.autoMergeBatches(),this._requireBufferBatch(e,t,n)},e._requireBufferBatch=function(e,t,n){var i=qW(e),r=this._meshBuffers.get(i);r||(r=[],this._meshBuffers.set(i,r));var a=this._meshBufferUseCount.get(i)||0;a>=r.length?this._currMeshBuffer=this._createMeshBuffer(e):this._currMeshBuffer=r[a],this._meshBufferUseCount.set(i,a+1),t&&n&&this._currMeshBuffer.request(t,n)},e._screenSort=function(e,t){return e.node.getSiblingIndex()-t.node.getSiblingIndex()},e._applyOpacity=function(e){for(var t=e.color.a/255,n=this._parentOpacity*=t,i=this.currBufferBatch,r=i.byteOffset>>2,a=i.vData,s=i.lastByteOffset>>2,o=i.vertexFormatBytes/4,c=s;c<r;c+=o)a[c+WX.OPACITY_OFFSET]*=n;i.lastByteOffset=i.byteOffset},e._releaseDescriptorSetCache=function(e){this._descriptorSetCache.releaseDescriptorSetCache(e)},t}()),oQ=function(){function e(){this._handle=null,this._transform=null,this._textureHash=0,this._samplerHash=0,this._localBuffer=null,this._transformUpdate=!0;var e=i.director.root.device;this._localData=new Float32Array(au.COUNT),this._localBuffer=e.createBuffer(new Ps(Ua.UNIFORM|Ua.TRANSFER_DST,Ga.HOST|Ga.DEVICE,au.SIZE,au.SIZE))}j(e,[{key:"handle",get:function(){return this._handle}}]);var t=e.prototype;return t.initialize=function(e){var t=i.director.root.device;this._transform=e.useLocalData,this._textureHash=e.textureHash,this._samplerHash=e.samplerHash,rQ.layout=e.passes[0].localSetLayout,this._handle&&(Ui.free(this._handle),this._handle=null),this._handle=Ui.alloc(t,rQ),this._descriptorSet=Ui.get(this._handle),this._descriptorSet.bindBuffer(au.BINDING,this._localBuffer);var n=Gl.SAMPLER_SPRITE;this._descriptorSet.bindTexture(n,e.texture),this._descriptorSet.bindSampler(n,e.sampler),this._descriptorSet.update(),this._transformUpdate=!0},t.updateTransform=function(e){e!==this._transform&&(this._transform=e,this._transformUpdate=!0,this.uploadLocalData())},t.updateLocal=function(){this._transform&&this.uploadLocalData()},t.equals=function(e,t,n){return this._transform===e&&this._textureHash===t&&this._samplerHash===n},t.reset=function(){this._transform=null,this._textureHash=0,this._samplerHash=0},t.destroy=function(){this._localBuffer&&(this._localBuffer.destroy(),this._localBuffer=null),this._handle&&(Ui.free(this._handle),this._handle=null),this._localData=null},t.uploadLocalData=function(){var e=this._transform;if((e.hasChangedFlags||e._dirtyFlags)&&e.updateWorldTransform(),this._transformUpdate){var t=e._mat;Hn.toArray(this._localData,t,au.MAT_WORLD_OFFSET),Hn.inverseTranspose(aQ,t),Hn.toArray(this._localData,aQ,au.MAT_WORLD_IT_OFFSET),this._localBuffer.update(this._localData),this._transformUpdate=!1}},e}(),cQ=function(){function e(){this._descriptorSetCache=new Map,this._localDescriptorSetCache=[],this._localCachePool=void 0,this._localCachePool=new c_((function(){return new oQ}),16)}var t=e.prototype;return t.getDescriptorSet=function(e){var t=i.director.root;if(e.useLocalData){for(var n=this._localDescriptorSetCache,r=0,a=n.length;r<a;r++){var s=n[r];if(s.equals(e.useLocalData,e.textureHash,e.samplerHash))return s.handle}var o=this._localCachePool.alloc();return o.initialize(e),this._localDescriptorSetCache.push(o),o.handle}var c=this._descriptorSetCache.get(e.textureHash);if(c&&c.has(e.samplerHash))return c.get(e.samplerHash);rQ.layout=e.passes[0].localSetLayout;var l=Ui.alloc(t.device,rQ),u=Ui.get(l),h=Gl.SAMPLER_SPRITE;return u.bindTexture(h,e.texture),u.bindSampler(h,e.sampler),u.update(),c?this._descriptorSetCache.get(e.textureHash).set(e.samplerHash,l):this._descriptorSetCache.set(e.textureHash,new Map([[e.samplerHash,l]])),l},t.update=function(){this._localDescriptorSetCache.forEach((function(e){e.updateLocal()}))},t.reset=function(){var e=this;this._localDescriptorSetCache.forEach((function(t){e._localCachePool.free(t)})),this._localDescriptorSetCache.length=0},t.releaseDescriptorSetCache=function(e){this._descriptorSetCache.has(e)&&(this._descriptorSetCache.get(e).forEach((function(e){Ui.free(e)})),this._descriptorSetCache.delete(e))},t.destroy=function(){this._descriptorSetCache.forEach((function(e){e.forEach((function(e){Ui.free(e)}))})),this._descriptorSetCache.clear(),this._localDescriptorSetCache.length=0,this._localCachePool.destroy((function(e){e.destroy()}))},e}();i.internal.Batcher2D=sQ;var lQ,uQ=null,hQ=-1,_Q=Object.create(null),fQ=[];function dQ(){for(var e=!0,t=Date.now(),n=fQ.length-1;n>=0;n--){var i=fQ[n],r=i.fontFamilyName;if(t-i.startTime>3e3)E(4933,r),i.onComplete(null,r),fQ.splice(n,1);else{var a=i.refWidth,s="40px "+r;uQ.font=s,a!==wk(uQ,"BES bswy:->@123丁ぁᄁ",s)?(fQ.splice(n,1),i.onComplete(null,r)):e=!1}}e&&(clearInterval(hQ),hQ=-1)}function pQ(e,t,n){var i=function(e){var t=e.lastIndexOf(".ttf");if(-1===t)return e;var n,i=e.lastIndexOf("/");return-1!==(n=-1===i?e.substring(0,t)+"_LABEL":e.substring(i+1,t)+"_LABEL").indexOf(" ")&&(n='"'+n+'"'),n}(e);if(_Q[i])n(null,i);else{if(!uQ){var r=document.createElement("canvas");r.width=100,r.height=100,uQ=r.getContext("2d")}var a=wk(uQ,"BES bswy:->@123丁ぁᄁ","40px "+i),s=document.createElement("style");s.type="text/css";var o="";Number.isNaN(i)?o+="@font-face { font-family:"+i+"; src:":o+='@font-face { font-family:"'+i+'"; src:',o+='url("'+e+'");',s.textContent=o+"}",document.body.appendChild(s);var c=document.createElement("div"),l=c.style;if(l.fontFamily=i,c.innerHTML=".",l.position="absolute",l.left="-100px",l.top="-100px",document.body.appendChild(c),function(){if(void 0===lQ)if("FontFace"in window){var e=/Gecko.*Firefox\/(\d+)/.exec(window.navigator.userAgent),t=/OS X.*Version\/10\..*Safari/.exec(window.navigator.userAgent)&&/Apple/.exec(window.navigator.vendor);lQ=e?parseInt(e[1],10)>42:!t}else lQ=!1;return lQ}())!function(e,t,n){var i=new Promise((function(n,i){!function r(){Date.now()-e>=3e3?i():document.fonts.load("40px "+t).then((function(e){e.length>=1?n():setTimeout(r,100)}),(function(){i()}))}()})),r=null,a=new Promise((function(e,t){r=setTimeout(t,3e3)}));Promise.race([a,i]).then((function(){r&&(clearTimeout(r),r=null),n(null,t)}),(function(){E(4933,t),n(null,t)}))}(Date.now(),i,n);else{var u={fontFamilyName:i,refWidth:a,onComplete:n,startTime:Date.now()};fQ.push(u),-1===hQ&&(hQ=setInterval(dQ,100))}_Q[i]=s}}function mQ(e,t,n,i){var r=new uk;r._nativeUrl=e,r._nativeAsset=t,i(null,r)}function gQ(e){return void 0===(e=e||{}).includeNormal&&(e.includeNormal=!0),void 0===e.includeUV&&(e.includeUV=!0),e}sI.register({".font":pQ,".eot":pQ,".ttf":pQ,".woff":pQ,".svg":pQ,".ttc":pQ}),fI.register({".font":mQ,".eot":mQ,".ttf":mQ,".woff":mQ,".svg":mQ,".ttc":mQ}),i.UI={MeshBuffer:WX,spriteAssembler:JZ,graphicsAssembler:aK,labelAssembler:xZ};var vQ=new bn,yQ=new bn,SQ=new bn,EQ=new bn,TQ=new bn,AQ=new bn,xQ=new bn,CQ=new bn,RQ=new bn,bQ=new bn,wQ=new bn,IQ=new bn,OQ=new bn(0,0,0),PQ=new bn(0,0,0);function MQ(e,t,n,i){void 0===e&&(e=.5),void 0===t&&(t=.5),void 0===n&&(n=2),void 0===i&&(i={});var r=.5*n,a=i.radialSegments||32,s=i.heightSegments||1,o=void 0===i.capped||i.capped,c=i.arc||2*Math.PI,l=0;o||(e>0&&l++,t>0&&l++);var u=(a+1)*(s+1);o&&(u+=(a+1)*l+a*l);var h=a*s*6;o&&(h+=a*l*3);var _=new Array(h),f=new Array(3*u),d=new Array(3*u),p=new Array(2*u),m=Math.max(e,t),g=new bn(-m,-r,-m),v=new bn(m,r,m),y=Math.sqrt(m*m+r*r),S=0,E=0;return function(){for(var i=[],o=e-t,l=o*o/n*Math.sign(o),u=0;u<=s;u++){for(var h=[],m=u/s,g=m*o+t,v=0;v<=a;++v){var y=v/a,T=y*c,A=Math.sin(T),x=Math.cos(T);f[3*S]=g*A,f[3*S+1]=m*n-r,f[3*S+2]=g*x,bn.normalize(OQ,bn.set(PQ,A,-l,x)),d[3*S]=OQ.x,d[3*S+1]=OQ.y,d[3*S+2]=OQ.z,p[2*S]=2*(1-y)%1,p[2*S+1]=m,h.push(S),++S}i.push(h)}for(var C=0;C<s;++C)for(var R=0;R<a;++R){var b=i[C][R],w=i[C+1][R],I=i[C+1][R+1],O=i[C][R+1];_[E]=b,++E,_[E]=O,++E,_[E]=w,++E,_[E]=O,++E,_[E]=I,++E,_[E]=w,++E}}(),o&&(t>0&&T(!1),e>0&&T(!0)),{positions:f,normals:d,uvs:p,indices:_,minPos:g,maxPos:v,boundingRadius:y};function T(n){for(var i=n?e:t,s=n?1:-1,o=S,l=1;l<=a;++l)f[3*S]=0,f[3*S+1]=r*s,f[3*S+2]=0,d[3*S]=0,d[3*S+1]=s,d[3*S+2]=0,p[2*S]=.5,p[2*S+1]=.5,++S;for(var u=S,h=0;h<=a;++h){var m=h/a*c,g=Math.cos(m),v=Math.sin(m);f[3*S]=i*v,f[3*S+1]=r*s,f[3*S+2]=i*g,d[3*S]=0,d[3*S+1]=s,d[3*S+2]=0,p[2*S]=.5-.5*v*s,p[2*S+1]=.5+.5*g,++S}for(var y=0;y<a;++y){var T=o+y,A=u+y;n?(_[E]=A+1,++E,_[E]=T,++E,_[E]=A,++E):(_[E]=T,++E,_[E]=A+1,++E,_[E]=A,++E)}}}var NQ,DQ,BQ,LQ,FQ,zQ,UQ,GQ,kQ,HQ=new bn(0,0,0),VQ=new bn(0,0,0),WQ=new bn(0,0,0),jQ=new bn(0,0,0),qQ=new bn(0,0,0),XQ=new bn(0,0,0),YQ=new bn(0,0,0),KQ=new bn(0,0,0),ZQ=new bn(0,0,0),QQ=Object.freeze({__proto__:null,box:function(e){var t=(e=e||{}).widthSegments||1,n=e.heightSegments||1,i=e.lengthSegments||1,r=(e.width||1)/2,a=(e.height||1)/2,s=(e.length||1)/2,o=[bn.set(TQ,-r,-a,s),bn.set(AQ,r,-a,s),bn.set(xQ,r,a,s),bn.set(CQ,-r,a,s),bn.set(RQ,r,-a,-s),bn.set(bQ,-r,-a,-s),bn.set(wQ,-r,a,-s),bn.set(IQ,r,a,-s)],c=[[2,3,1],[4,5,7],[7,6,2],[1,0,4],[1,4,2],[5,0,6]],l=[[0,0,1],[0,0,-1],[0,1,0],[0,-1,0],[1,0,0],[-1,0,0]],u=[[-1,0,0,1],[-1,0,0,1],[-1,0,0,1],[-1,0,0,1],[0,0,-1,1],[0,0,1,1]],h=[],_=[],f=[],d=[],p=[],m=new bn(-r,-a,-s),g=new bn(r,a,s),v=Math.sqrt(r*r+a*a+s*s);function y(e,t,n){var i,r,a,s,m=h.length/3,g=c[e],v=l[e],y=u[e];for(s=0;s<=n;s++)for(a=0;a<=t;a++)if(i=a/t,r=s/n,bn.lerp(vQ,o[g[0]],o[g[1]],i),bn.lerp(yQ,o[g[0]],o[g[2]],r),bn.subtract(SQ,yQ,o[g[0]]),bn.add(EQ,vQ,SQ),h.push(EQ.x,EQ.y,EQ.z),_.push(v[0],v[1],v[2]),f.push(i,r),d.push(y[0],y[1],y[2],y[3]),a<t&&s<n){var S=t+1,E=a+s*S,T=a+(s+1)*S,A=a+1+(s+1)*S,x=a+1+s*S;p.push(m+E,m+x,m+T),p.push(m+T,m+x,m+A)}}return y(0,t,n),y(4,i,n),y(1,t,n),y(5,i,n),y(3,t,i),y(2,t,i),{positions:h,normals:_,uvs:f,tangents:d,indices:p,minPos:m,maxPos:g,boundingRadius:v}},cone:function(e,t,n){return void 0===e&&(e=.5),void 0===t&&(t=1),void 0===n&&(n={}),MQ(0,e,t,n)},cylinder:MQ,plane:function(e){var t=function(e){return(e=gQ(e)).width=e.width||10,e.length=e.length||10,e.widthSegments=e.widthSegments||10,e.lengthSegments=e.lengthSegments||10,e}(e),n=t.width,i=t.length,r=t.widthSegments,a=t.lengthSegments,s=.5*n,o=.5*i,c=[],l=[],u=[],h=new bn(-s,0,-o),_=new bn(s,0,o),f=Math.sqrt(n*n+i*i);bn.set(qQ,-s,0,o),bn.set(XQ,s,0,o),bn.set(YQ,-s,0,-o);for(var d=0;d<=a;d++)for(var p=0;p<=r;p++){var m=p/r,g=d/a;if(bn.lerp(HQ,qQ,XQ,m),bn.lerp(VQ,qQ,YQ,g),bn.subtract(WQ,VQ,qQ),bn.add(jQ,HQ,WQ),c.push(jQ.x,jQ.y,jQ.z),t.includeUV&&l.push(m,g),p<r&&d<a){var v=r+1,y=p+d*v,S=p+(d+1)*v,E=p+1+(d+1)*v,T=p+1+d*v;u.push(y,T,S),u.push(T,E,S)}}var A={positions:c,indices:u,minPos:h,maxPos:_,boundingRadius:f};if(t.includeNormal){var x=(a+1)*(r+1),C=new Array(3*x);A.normals=C;for(var R=0;R<x;++R)C[3*R+0]=0,C[3*R+1]=1,C[3*R+2]=0}return t.includeUV&&(A.uvs=l),A},quad:function(e){var t=gQ(e),n={positions:[-.5,-.5,0,-.5,.5,0,.5,.5,0,.5,-.5,0],indices:[0,3,1,3,2,1],minPos:{x:-.5,y:-.5,z:0},maxPos:{x:.5,y:.5,z:0},boundingRadius:Math.sqrt(.5)};return!1!==t.includeNormal&&(n.normals=[0,0,1,0,0,1,0,0,1,0,0,1]),!1!==t.includeUV&&(n.uvs=[0,0,0,1,1,1,1,0]),n},sphere:function(e,t){void 0===e&&(e=.5),void 0===t&&(t={});for(var n=void 0!==t.segments?t.segments:32,i=[],r=[],a=[],s=[],o=new bn(-e,-e,-e),c=new bn(e,e,e),l=e,u=0;u<=n;++u)for(var h=u*Math.PI/n,_=Math.sin(h),f=-Math.cos(h),d=0;d<=n;++d){var p=2*d*Math.PI/n-Math.PI/2,m=Math.sin(p)*_,g=f,v=Math.cos(p)*_,y=d/n,S=u/n;if(i.push(m*e,g*e,v*e),r.push(m,g,v),a.push(y,S),u<n&&d<n){var E=n+1,T=E*u+d,A=E*(u+1)+d,x=E*(u+1)+d+1,C=E*u+d+1;s.push(T,C,A),s.push(C,x,A)}}return{positions:i,indices:s,normals:r,uvs:a,minPos:o,maxPos:c,boundingRadius:l}},torus:function(e,t,n){void 0===e&&(e=.4),void 0===t&&(t=.1),void 0===n&&(n={});for(var i=n.radialSegments||32,r=n.tubularSegments||32,a=n.arc||2*Math.PI,s=[],o=[],c=[],l=[],u=new bn(-e-t,-t,-e-t),h=new bn(e+t,t,e+t),_=e+t,f=0;f<=i;f++)for(var d=0;d<=r;d++){var p=d/r,m=f/i,g=p*a,v=m*Math.PI*2,y=(e+t*Math.cos(v))*Math.sin(g),S=t*Math.sin(v),E=(e+t*Math.cos(v))*Math.cos(g),T=Math.sin(g)*Math.cos(v),A=Math.sin(v),x=Math.cos(g)*Math.cos(v);if(s.push(y,S,E),o.push(T,A,x),c.push(p,m),d<r&&f<i){var C=r+1,R=C*f+d,b=C*(f+1)+d,w=C*(f+1)+d+1,I=C*f+d+1;l.push(R,I,b),l.push(I,w,b)}}return{positions:s,normals:o,uvs:c,indices:l,minPos:u,maxPos:h,boundingRadius:_}},capsule:function(e,t,n,i){void 0===e&&(e=.5),void 0===t&&(t=.5),void 0===n&&(n=2),void 0===i&&(i={});var r=n-e-t,a=i.sides||32,s=i.heightSegments||32,o=t/n,c=r/n,l=e/n,u=Math.floor(s*o),h=Math.floor(s*l),_=Math.floor(s*c),f=r+t-n/2,d=t-n/2,p=t-n/2,m=i.arc||2*Math.PI,g=[],v=[],y=[],S=[],E=Math.max(e,t),T=new bn(-E,-n/2,-E),A=new bn(E,n/2,E),x=n/2,C=0,R=[];return function(){for(var e=0;e<=u;++e)for(var n=e*Math.PI/u/2,i=Math.sin(n),r=-Math.cos(n),o=0;o<=a;++o){var c=2*o*Math.PI/a-Math.PI/2,l=Math.sin(c)*i,h=r,_=Math.cos(c)*i,f=o/a,d=e/s;if(g.push(l*t,h*t+p,_*t),v.push(l,h,_),y.push(f,d),e<u&&o<a){var m=a+1,E=m*e+o,T=m*(e+1)+o,A=m*(e+1)+o+1,x=m*e+o+1;S.push(E,x,T),S.push(x,A,T)}++C}}(),function(){for(var n=(e-t)/r,i=0;i<=_;i++){for(var s=[],l=i/_,u=l*(e-t)+t,h=0;h<=a;++h){var f=h/a,p=l*c+o,E=f*m-m/4,T=Math.sin(E),A=Math.cos(E);g.push(u*T),g.push(l*r+d),g.push(u*A),bn.normalize(KQ,bn.set(ZQ,T,-n,A)),v.push(KQ.x),v.push(KQ.y),v.push(KQ.z),y.push(f,p),s.push(C),++C}R.push(s)}for(var x=0;x<_;++x)for(var b=0;b<a;++b){var w=R[x][b],I=R[x+1][b],O=R[x+1][b+1],P=R[x][b+1];S.push(w),S.push(P),S.push(I),S.push(P),S.push(O),S.push(I)}}(),function(){for(var t=0;t<=h;++t)for(var n=t*Math.PI/h/2+Math.PI/2,i=Math.sin(n),r=-Math.cos(n),o=0;o<=a;++o){var c=2*o*Math.PI/a-Math.PI/2,u=Math.sin(c)*i,d=r,p=Math.cos(c)*i,m=o/a,E=t/s+(1-l);if(g.push(u*e,d*e+f,p*e),v.push(u,d,p),y.push(m,E),t<h&&o<a){var T=a+1,A=T*t+o+R[_][a]+1,x=T*(t+1)+o+R[_][a]+1,C=T*(t+1)+o+1+R[_][a]+1,b=T*t+o+1+R[_][a]+1;S.push(A,b,x),S.push(b,C,x)}}}(),{positions:g,normals:v,uvs:y,indices:S,minPos:T,maxPos:A,boundingRadius:x}},circle:function(e){var t=function(e){return(e=gQ(e)).segments=64,e}(e).segments,n=new Array(3*(t+1));n[0]=0,n[1]=0,n[2]=0;var i=new Array(1+2*t);i[0]=0;for(var r=2*Math.PI/t,a=0;a<t;++a){var s=r*a,o=Math.cos(s),c=Math.sin(s),l=3*(a+1);n[l+0]=o,n[l+1]=c,n[l+2]=0;var u=2*a;i[1+u]=a+1,i[1+(u+1)]=a+2}return t>0&&(i[i.length-1]=1),{positions:n,indices:i,minPos:{x:1,y:1,z:0},maxPos:{x:-1,y:-1,z:0},boundingRadius:1,primitiveMode:Va.TRIANGLE_FAN}},translate:function(e,t){for(var n=t.x||0,i=t.y||0,r=t.z||0,a=Math.floor(e.positions.length/3),s=0;s<a;++s){var o=3*s,c=3*s+1,l=3*s+2;e.positions[o]=e.positions[o]+n,e.positions[c]=e.positions[c]+i,e.positions[l]=e.positions[l]+r}return e.minPos&&(e.minPos.x+=n,e.minPos.y+=i,e.minPos.z+=r),e.maxPos&&(e.maxPos.x+=n,e.maxPos.y+=i,e.maxPos.z+=r),e},scale:function(e,t){for(var n=t.x||0,i=t.y||0,r=t.z||0,a=Math.floor(e.positions.length/3),s=0;s<a;++s){var o=3*s,c=3*s+1,l=3*s+2;e.positions[o]*=n,e.positions[c]*=i,e.positions[l]*=r}return e.minPos&&(e.minPos.x*=n,e.minPos.y*=i,e.minPos.z*=r),e.maxPos&&(e.maxPos.x*=n,e.maxPos.y*=i,e.maxPos.z*=r),e.boundingRadius=Math.max(Math.max(n,i),r),e},wireframed:function(e){var t=e.indices;if(!t)return e;if(e.primitiveMode&&e.primitiveMode!==Va.TRIANGLE_LIST)return e;for(var n=[[0,1],[1,2],[2,0]],i=[],r={},a=0;a<t.length;a+=3)for(var s=0;s<3;++s){var o=t[a+n[s][0]],c=t[a+n[s][1]],l=o>c?c<<16|o:o<<16|c;void 0===r[l]&&(r[l]=0,i.push(o,c))}return e.indices=i,e.primitiveMode=Va.LINE_LIST,e},wireframe:function(e){for(var t=[[0,1],[1,2],[2,0]],n=[],i={},r=0;r<e.length;r+=3)for(var a=0;a<3;++a){var s=e[r+t[a][0]],o=e[r+t[a][1]],c=s>o?o<<16|s:s<<16|o;void 0===i[c]&&(i[c]=0,n.push(s,o))}return n},invWinding:function(e){for(var t=[],n=0;n<e.length;n+=3)t.push(e[n],e[n+2],e[n+1]);return t},toWavefrontOBJ:function(e,t){if(void 0===t&&(t=1),!e.indices||!e.uvs||!e.normals||void 0!==e.primitiveMode&&e.primitiveMode!==Va.TRIANGLE_LIST)return"";for(var n=e.positions,i=e.uvs,r=e.normals,a=e.indices,s=function(e){return a[e]+1+"/"+(a[e]+1)+"/"+(a[e]+1)},o="",c=0;c<n.length;c+=3)o+="v "+n[c]*t+" "+n[c+1]*t+" "+n[c+2]*t+"\n";for(var l=0;l<i.length;l+=2)o+="vt "+i[l]+" "+i[l+1]+"\n";for(var u=0;u<r.length;u+=3)o+="vn "+r[u]+" "+r[u+1]+" "+r[u+2]+"\n";for(var h=0;h<a.length;h+=3)o+="f "+s(h)+" "+s(h+1)+" "+s(h+2)+"\n";return o},normals:function(e,t,n){void 0===n&&(n=1);for(var i=new Array(2*e.length),r=0;r<e.length/3;++r){var a=3*r,s=6*r;i[s+0]=e[a+0],i[s+1]=e[a+1],i[s+2]=e[a+2],i[s+3]=e[a+0]+t[a+0]*n,i[s+4]=e[a+1]+t[a+1]*n,i[s+5]=e[a+2]+t[a+2]*n}return i},applyDefaultGeometryOptions:gQ});e("primitives",QQ),function(e){e[e.BOX=0]="BOX",e[e.SPHERE=1]="SPHERE",e[e.CYLINDER=2]="CYLINDER",e[e.CONE=3]="CONE",e[e.CAPSULE=4]="CAPSULE",e[e.TORUS=5]="TORUS",e[e.PLANE=6]="PLANE",e[e.QUAD=7]="QUAD"}(kQ||(kQ={})),ht(kQ);var JQ=e("Primitive",(NQ=ih("cc.Primitive"),DQ=Dh(kQ),NQ((GQ=UQ=function(e){function t(t){var n;return void 0===t&&(t=kQ.BOX),Q(n=e.call(this)||this,"type",FQ,Y(n)),Q(n,"info",zQ,Y(n)),n.type=t,n}return X(t,e),t.prototype.onLoaded=function(){vL(QQ[kQ[this.type].toLowerCase()](this.info),this)},t}(uL),UQ.PrimitiveType=kQ,FQ=J((LQ=GQ).prototype,"type",[DQ],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return kQ.BOX}}),zQ=J(LQ.prototype,"info",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return{}}}),BQ=LQ))||BQ));i.Primitive=JQ,i.primitives=QQ}}}));
|