1 |
- System.register([],(function(e,t){"use strict";return{execute:async function(){e({A:void 0,E:void 0,F:void 0,G:void 0,H:void 0,I:void 0,J:void 0,L:void 0,M:void 0,O:void 0,Q:void 0,S:void 0,T:void 0,aF:void 0,aL:vc,aM:gc,aN:yc,aO:Ec,aP:Sc,b:void 0,b$:hf,b9:KM,bD:k,bE:G,bF:function(){},bO:he,bP:ue,bQ:se,bS:Rc,bU:function(e,t,n,i,o){void 0===n&&(n=Oa.R32F),void 0===i&&(i=0),void 0===o&&(o=0);var r=_c[n];o||(o=r.size);for(var a="set"+tP(r),s=r.size/r.count,c=Math.floor(t.length/r.count),l=mx.isLittleEndian,u=0;u<c;++u)for(var h=i+o*u,_=0;_<r.count;++_){var f=h+s*_;e[a](f,t[r.count*u+_],l)}},bV:YR,bW:nP,bY:ct,bZ:function(e){return U_(V_({formerlySerializedAs:e}))},ba:QM,bd:rL,bj:ie,bk:te,bl:N,bm:x,bo:le,bq:void 0,bs:void 0,bu:b,bv:y,bx:function(e,t,n,i,o,r){void 0===t&&(t=Oa.R32F),void 0===n&&(n=0),void 0===i&&(i=e.byteLength-n),void 0===o&&(o=0),void 0===r&&(r=[]);var a=_c[t];o||(o=a.size);for(var s="get"+tP(a),c=a.size/a.count,l=Math.floor(i/o),u=mx.isLittleEndian,h=0;h<l;++h)for(var _=n+o*h,f=0;f<a.count;++f){var d=_+c*f;r[a.count*h+f]=e[s](d,u)}return r},by:function(){},c:void 0,c1:void 0,cB:void 0,cD:void 0,cJ:void 0,cK:void 0,cR:Re,cS:it,cU:Fi,cV:Ge,c_:void 0,cc:void 0,cd:void 0,cg:void 0,cr:fn,cs:rd,ct:function(e,t,n){for(jn.identity(n);e!==t;)jn.fromRTS(QF,e.rotation,e.position,e.scale),jn.multiply(n,QF,n),e=e.parent;return n},cx:WF,cy:kF,cz:VF,d:void 0,d0:ht,d9:un,dC:_n,dF:Et,dK:hn,dR:dn,dU:void 0,dV:Sn,dW:gn,dY:mn,dZ:vn,d_:H,db:ne,dg:void 0,di:void 0,dn:void 0,dr:wt,ds:He,dt:I,dv:void 0,dy:void 0,e:void 0,e0:Tn,e2:GI,e4:cn,e6:Ei,e9:Cn,eC:Jn,eD:Dn,eE:ei,eF:kn,eI:ii,eJ:ri,eK:bn,eM:ln,eN:yn,eO:xn,eP:En,eQ:An,eR:wn,eS:st,eY:function(e){e>0&&(Z=e)},eZ:Ny,e_:Oy,ea:de,eb:ae,ec:pe,ed:U_,ef:Ct,eg:It,eh:L,ej:Gi,el:g,em:Xn,er:fi,ev:tn,ex:$e,f:void 0,f$:wL,f1:zd,fY:tz,fZ:nz,f_:iz,fd:E,fe:M,ff:F,fg:z,fh:void 0,fr:$w,g:void 0,g0:OL,g4:LL,g5:FL,g8:function(e,t){for(var n=e,i="";null!==n&&n!==t;)i=n.name+"/"+i,n=n.parent;return i.slice(0,-1)},ga:hz,h:void 0,i:void 0,j:void 0,k:void 0,l:void 0,m:void 0,n:void 0,o:void 0,p:void 0,q:void 0,r:void 0,s:void 0,t:void 0,u:void 0,v:void 0,w:void 0,x:void 0,y:void 0,z:void 0});const n=e("bt",!1),i=e("dT",!1),o=e("dJ",!1),r=e("dH",!1),a=e("dI",!1);var s="undefined"==typeof window?global:window,c=e("bw",{_global:s});c.internal={},s.CC_BUILD=!0,s.CC_TEST=!1,s.CC_EDITOR=i,s.CC_PREVIEW=!1,s.CC_DEV=!1,s.CC_DEBUG=!1,s.CC_JSB=a,s.CC_BYTEDANCE=!1,s.CC_WECHAT=n,s.CC_ALIPAY=!1,s.CC_XIAOMI=!1,s.CC_BAIDU=!1,s.CC_COCOSPLAY=!1,s.CC_HUAWEI=!1,s.CC_OPPO=!1,s.CC_VIVO=!1,s.CC_MINIGAME=r,s.CC_RUNTIME_BASED=o,s.CC_SUPPORT_JIT=!0;var l=e("eo","3.2.0");s.CocosEngine=c.ENGINE_VERSION=l,s.cc=c;var u="https://github.com/cocos-creator/engine/blob/3d/EngineErrorMap.md",h=null,_=console.log.bind(console),f=_,d=_,p=function(e,t){if(!e){for(var n=arguments.length,i=new Array(n>2?n-2:0),o=2;o<n;o++)i[o-2]=arguments[o];console.log("ASSERT: "+v.apply(void 0,[t].concat(i)))}},m=_;function v(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.js.formatStr.apply(null,[e].concat(n))}function g(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 _.apply(void 0,[e].concat(n))}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];return f.apply(void 0,[e].concat(n))}function x(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 d.apply(void 0,[e].concat(n))}function E(e,t){for(var n=arguments.length,i=new Array(n>2?n-2:0),o=2;o<n;o++)i[o-2]=arguments[o];return p.apply(void 0,[e,t].concat(i))}function S(){return m.apply(void 0,arguments)}function T(e){if(_=f=d=p=m=function(){},e!==O.NONE){if(e>O.ERROR){var t=function(e){if(c.game.canvas){if(!h){var t=document.createElement("Div");t.setAttribute("id","logInfoDiv"),t.setAttribute("width","200"),t.setAttribute("height",c.game.canvas.height);var n=t.style;n.zIndex="99999",n.position="absolute",n.top=n.left="0",(h=document.createElement("textarea")).setAttribute("rows","20"),h.setAttribute("cols","30"),h.setAttribute("disabled","true");var i=h.style;i.backgroundColor="transparent",i.borderBottom="1px solid #cccccc",i.borderTopWidth=i.borderLeftWidth=i.borderRightWidth="0px",i.borderTopStyle=i.borderLeftStyle=i.borderRightStyle="none",i.padding="0px",i.margin="0px",t.appendChild(h),c.game.canvas.parentNode.appendChild(t)}h.value=h.value+e+"\r\n",h.scrollTop=h.scrollHeight}};d=function(e){for(var n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];t("ERROR : "+v.apply(void 0,[e].concat(i)))},p=function(e,n){if(!e){for(var i=arguments.length,o=new Array(i>2?i-2:0),r=2;r<i;r++)o[r-2]=arguments[r];t("ASSERT: "+v.apply(void 0,[n].concat(o)))}},e!==O.ERROR_FOR_WEB_PAGE&&(f=function(e){for(var n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];t("WARN : "+v.apply(void 0,[e].concat(i)))}),e===O.INFO_FOR_WEB_PAGE&&(_=function(e){for(var n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];t(v.apply(void 0,[e].concat(i)))})}else console&&(console.error||(console.error=console.log),console.warn||(console.warn=console.log),d=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))},p=function(e,t){if(!e){for(var n=arguments.length,i=new Array(n>2?n-2:0),o=2;o<n;o++)i[o-2]=arguments[o];var r=v.apply(void 0,[t].concat(i));throw new Error(r)}});if(e!==O.ERROR&&(f=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===O.INFO&&(_=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))}),e<=O.VERBOSE&&"function"==typeof console.debug){var n=console.debug;m=function(){return n.apply(void 0,arguments)}}}}function A(e){x(e.stack||e)}function w(e){return function(t){for(var n=e+" "+t+", please go to "+u+"#"+t+" to see details.",i=arguments.length,o=new Array(i>1?i-1:0),r=1;r<i;r++)o[r-1]=arguments[r];return 0===o.length?n:n+" Arguments: "+o.join(", ")}}var C=w("Log");function I(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];g(C.apply(void 0,[e].concat(n)))}var P=w("Warning");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];y(P.apply(void 0,[e].concat(n)))}var R=w("Error");function N(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];x(R.apply(void 0,[e].concat(n)))}var O,D=w("Assert");function M(e,t){if(!e){for(var n=arguments.length,i=new Array(n>2?n-2:0),o=2;o<n;o++)i[o-2]=arguments[o];E(!1,D.apply(void 0,[t].concat(i)))}}function L(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 R.apply(void 0,[e].concat(n))}function F(){return!!c.profiler&&c.profiler.isShowingStats()}function z(e){c.profiler&&(e?c.profiler.showStats():c.profiler.hideStats(),c.game.config.showFPS=!!e)}!function(e){e[e.NONE=0]="NONE",e[e.VERBOSE=1]="VERBOSE",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.INFO_FOR_WEB_PAGE=5]="INFO_FOR_WEB_PAGE",e[e.WARN_FOR_WEB_PAGE=6]="WARN_FOR_WEB_PAGE",e[e.ERROR_FOR_WEB_PAGE=7]="ERROR_FOR_WEB_PAGE"}(O||(O=e("fh",{})));var B=Object.freeze({__proto__:null,log:g,warn:y,error:x,assert:E,debug:S,_resetDebugSetting:T,_throw:A,logID:I,warnID:b,errorID:N,assertID:M,get DebugMode(){return O},getError:L,isDisplayStats:F,setDisplayStats:z}),U=e("e1",2147483647);function H(e){return(e>0)-(e<0)}function G(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 V(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 k(e){return e+=0===e,--e,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,1+(e|=e>>>16)}var W=new Array(256);!function(e){for(var t=0;t<256;++t){var n=t,i=t,o=7;for(n>>>=1;n;n>>>=1)i<<=1,i|=1&n,--o;e[t]=i<<o&255}}(W);var j=Object.freeze({__proto__:null,INT_BITS:32,INT_MAX:U,INT_MIN:-2147483648,sign:H,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:G,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:V,nextPow2:k,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 W[255&e]<<24|W[e>>>8&255]<<16|W[e>>>16&255]<<8|W[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>>>V(e)+1}});e("eB",j);var q,Y,X,K,Q,Z=10,J=0,$=new Map;function ee(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 te(e,t,n){return t&&ee(e.prototype,t),n&&ee(e,n),e}function ne(){return(ne=e("db",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 ie(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,oe(e,t)}function oe(e,t){return(oe=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function re(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function ae(t,n,i){return(ae=re()?e("eb",Reflect.construct):e("eb",(function(e,t,n){var i=[null];i.push.apply(i,t);var o=new(Function.bind.apply(e,i));return n&&oe(o,n.prototype),o}))).apply(null,arguments)}function se(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ce(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 le(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return ce(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ce(e,t):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 ue(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 he(e,t,n,i,o){var r={};return Object.keys(i).forEach((function(e){r[e]=i[e]})),r.enumerable=!!r.enumerable,r.configurable=!!r.configurable,("value"in r||r.initializer)&&(r.writable=!0),r=n.slice().reverse().reduce((function(n,i){return i(e,t,n)||n}),r),o&&void 0!==r.initializer&&(r.value=r.initializer?r.initializer.call(o):void 0,r.initializer=void 0),void 0===r.initializer&&(Object.defineProperty(e,t,r),r=null),r}X=function(e,t,n,i,o,r,a){var s=$.get(r);s&&s.logTimes>s.count&&(o("'%s' is deprecated, please use '%s' instead. "+a,e+"."+t,n+"."+i),s.count++)},q=e("cc",(function(e,t,n){null!=e&&n.forEach((function(n){var i=J++;$.set(i,{id:i,count:0,logTimes:void 0!==n.logTimes?n.logTimes:Z});var o=null!=n.target?n.target:e,r=null!=n.newName?n.newName:n.name,a=null!=n.targetName?n.targetName:t,s=o===e,c=n.suggest?"("+n.suggest+")":"";if(null!=n.customFunction)e[n.name]=function(){var e;return X(t,n.name,a,r,y,i,c),(e=n.customFunction).call.apply(e,[this].concat(Array.prototype.slice.call(arguments)))};else if(null!=n.customSetter||null!=n.customGetter){var l=null!=n.customSetter,u=null!=n.customGetter;l&&u?Object.defineProperty(e,n.name,{get:function(){return X(t,n.name,a,r,y,i,c),n.customGetter.call(this)},set:function(e){X(t,n.name,a,r,y,i,c),n.customSetter.call(this,e)},enumerable:!1}):l?Object.defineProperty(e,n.name,{set:function(e){X(t,n.name,a,r,y,i,c),n.customSetter.call(this,e)},enumerable:!1}):u&&Object.defineProperty(e,n.name,{get:function(){return X(t,n.name,a,r,y,i,c),n.customGetter.call(this)},enumerable:!1})}else Object.defineProperty(e,n.name,{get:function(){return X(t,n.name,a,r,y,i,c),s?this[r]:o[r]},set:function(e){X(t,n.name,a,r,y,i,c),s?this[r]=e:o[r]=e},enumerable:!1})}))})),Q=function(e,t,n,i,o){var r=$.get(i);r&&r.logTimes>r.count&&(n("'%s' has been removed. "+o,e+"."+t),r.count++)},Y=e("cd",(function(e,t,n){null!=e&&n.forEach((function(n){var i=J++;$.set(i,{id:i,count:0,logTimes:void 0!==n.logTimes?n.logTimes:Z});var o=n.suggest?"("+n.suggest+")":"";Object.defineProperty(e,n.name,{get:function(){return Q(t,n.name,x,i,o)},set:function(){Q(t,n.name,x,i,o)},enumerable:!1})}))})),K=function(e,t,n,i,o){var r=$.get(i);r&&r.logTimes>r.count&&(n("'%s' is deprecated. "+o,e+"."+t),r.count++)},e("dg",(function(e,t,n){if(null!=e){var i=function(t,n,i,o,r,a){if(t.get){var s=t.get;t.get=function(){return K(n,i,o,r,a),s.call(this)}}if(t.set){var c=t.set;t.set=function(e){K(n,i,o,r,a),c.call(this,e)}}Object.defineProperty(e,i,t)};n.forEach((function(n){var o=n.name,r=Object.getOwnPropertyDescriptor(e,o);if(r&&r.configurable){var a=J++;$.set(a,{id:a,count:0,logTimes:void 0!==n.logTimes?n.logTimes:Z});var s=n.suggest?"("+n.suggest+")":"";if(null!=r.value)if("function"==typeof r.value){var c=r.value;e[o]=function(){return K(t,o,y,a,s),c.call.apply(c,[this].concat(Array.prototype.slice.call(arguments)))}}else i(r,t,o,y,a,s);else i(r,t,o,y,a,s);Object.defineProperty(e,o,{enumerable:!1})}}))}}));var _e=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)},te(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 fe(e,t){e.splice(t,1)}function de(e,t){var n=e.length;t<0||t>=n||(e[t]=e[n-1],e.length=n-1)}function pe(e,t){var n=e.indexOf(t);return n>=0&&(fe(e,n),!0)}function me(e,t){return e.indexOf(t)>=0}var ve=Object.freeze({__proto__:null,removeAt:fe,fastRemoveAt:de,remove:pe,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 fe(e,n),i}},verifyType:function(e,t){if(e&&e.length>0)for(var n,i=le(e);!(n=i()).done;)if(!(n.value instanceof t))return I(1300),!1;return!0},removeArray:function(e,t){for(var n=0,i=t.length;n<i;n++)pe(e,t[n])},appendObjectsAt:function(e,t,n){return e.splice.apply(e,[n,0].concat(t)),e},contains:me,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:_e}),ge=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}();ge.global=new ge("global");var ye=new ge("TmpCId."),xe="undefined"==typeof Symbol?"__aliases__":Symbol("[[Aliases]]"),Ee="__cid__";function Se(e){return"number"==typeof e||e instanceof Number}function Te(e){return"string"==typeof e||e instanceof String}function Ae(e){for(var t in e)return!1;return!0}var we,Ce=(we={value:void 0,enumerable:!1,writable:!1,configurable:!0},function(e,t,n,i,o){we.value=n,we.writable=i,we.enumerable=o,Object.defineProperty(e,t,we),we.value=void 0}),Ie=function(){var e={get:void 0,set:void 0,enumerable:!1};return function(t,n,i,o,r,a){void 0===r&&(r=!1),void 0===a&&(a=!1),"boolean"==typeof o&&(r=o,o=void 0),e.get=i,e.set=o,e.enumerable=r,e.configurable=a,Object.defineProperty(t,n,e),e.get=void 0,e.set=void 0}}(),Pe=function(){var e={get:void 0,enumerable:!1,configurable:!1};return function(t,n,i,o,r){e.get=i,e.enumerable=o,e.configurable=r,Object.defineProperty(t,n,e),e.get=void 0}}(),be=function(){var e={set:void 0,enumerable:!1,configurable:!1};return function(t,n,i,o,r){e.set=i,e.enumerable=o,e.configurable=r,Object.defineProperty(t,n,e),e.set=void 0}}();function Re(e){var t=Object.create(null);return e&&(t["."]=1,t["/"]=1,delete t["."],delete t["/"]),t}function Ne(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,o=e.toString();(i="["===o.charAt(0)?o.match(/\[\w+\s*(\w+)\]/):o.match(/function\s*(\w+)/))&&2===i.length&&(n=i[1])}return"Object"!==n?n:""}return e&&e.constructor?Ne(e.constructor):""}function Oe(e,t,n,i){var o=/([^.]+)$/,r=o.exec(t)[0],a=o.exec(n)[0];function s(){return this[a]}i?Ie(e,r,s,(function(e){this[a]=e})):Pe(e,r,s)}function De(e,t,n,i){for(var o in n)Oe(e,t+"."+o,n[o],i)}var Me=/(%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 o="string"==typeof e&&Me.test(e);if(o)for(var r,a=le(n);!(r=a()).done;){var s=r.value,c="number"==typeof s?Me:Le;if(c.test(e)){var l=""+s;e=e.replace(c,l)}else e+=" "+s}else for(var u,h=le(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 Be(e,t){for(;e;){var n=Object.getOwnPropertyDescriptor(e,t);if(n)return n;e=Object.getPrototypeOf(e)}return null}function Ue(e,t,n){var i=Be(t,e);i&&Object.defineProperty(n,e,i)}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 o=0,r=n;o<r.length;o++){var a=r[o];if(a){if("object"!=typeof a){N(5402,a);continue}for(var s in a)s in e||Ue(s,a,e)}}return e}function Ge(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 o=0,r=n;o<r.length;o++){var a=r[o];if(a){if("object"!=typeof a){N(5403,a);continue}for(var s in a)Ue(s,a,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 ke(e){var t=e.prototype,n=t&&Object.getPrototypeOf(t);return n&&n.constructor}function We(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=ke(e)))return!1;if(e===t)return!0}}return!1}function je(e){for(var t=0,n=Object.keys(e);t<n.length;t++)delete e[n[t]]}function qe(e){return"string"!=typeof e||e.startsWith(ye.prefix)}var Ye=Re(!0),Xe=Re(!0);function Ke(e,t){return function(n,i){if(i.prototype.hasOwnProperty(e)&&delete t[i.prototype[e]],Ce(i.prototype,e,n),n){var o=t[n];o&&o!==i?x("A Class already exists with the same "+e+' : "'+n+'".'):t[n]=i}}}var Qe=Ke("__cid__",Ye),Ze=Ke("__classname__",Xe);function Je(e,t){if(Ze(e,t),!t.prototype.hasOwnProperty(Ee)){var n=e||ye.getNewId();n&&Qe(n,t)}}function $e(e,t){var n=Xe[t],i=Ye[t],o=!0;if(n&&n!==e&&(x('"'+t+'" has already been set as name or alias of another class.'),o=!1),i&&i!==e&&(x('"'+t+'" has already been set as id or alias of another class.'),o=!1),o){var r=e[xe];r||(r=[],e[xe]=r),r.push(t),Xe[t]=e,Ye[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,o=t;i<o.length;i++){var r=o[i],a=r.prototype,s=a.__cid__;s&&delete Ye[s];var c=a.__classname__;c&&delete Xe[c];var l=a[xe];if(l)for(var u=0;u<l.length;++u){var h=l[u];delete Xe[h],delete Ye[h]}}}function tt(e){return Ye[e]}function nt(e){return Xe[e]}function it(e,t){var n;if(t=void 0===t||t,"function"==typeof e&&e.prototype.hasOwnProperty(Ee))return n=e.prototype.__cid__,!t&&i&&qe(n)?"":n;if(e&&e.constructor){var o=e.constructor.prototype;if(o&&o.hasOwnProperty(Ee))return n=e.__cid__,!t&&i&&qe(n)?"":n}return""}var ot=e("cW",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}()),rt=e("dP",ve),at=e("cf",{IDGenerator:ge,Pool:ot,array:ve,isNumber:Se,isString:Te,isEmptyObject:Ae,getPropertyDescriptor:Be,addon:He,mixin:Ge,extend:Ve,getSuper:ke,isChildClassOf:We,clear:je,value:Ce,getset:Ie,get:Pe,set:be,unregisterClass:et,getClassName:Ne,setClassName:Je,setClassAlias:$e,getClassByName:nt,get _registeredClassNames(){return ne({},Xe)},set _registeredClassNames(e){je(Xe),Object.assign(Xe,e)},get _registeredClassIds(){return ne({},Ye)},set _registeredClassIds(e){je(Ye),Object.assign(Ye,e)},_getClassId:it,_setClassId:Qe,_getClassById:tt,obsolete:Oe,obsoletes:De,formatStr:Fe,shiftArguments:ze,createMap:Re});function st(e){if("__bitmask__"in e)return e;Ce(e,"__bitmask__",null,!0);for(var t=-1,n=Object.keys(e),i=0;i<n.length;i++){var o=n[i],r=e[o];if(-1===r)r=++t,e[o]=r;else if("number"==typeof r)t=r;else if("string"==typeof r&&Number.isInteger(parseFloat(o)))continue;var a=""+r;o!==a&&Ce(e,a,o)}return e}function ct(e){return"__enums__"in e?e:(Ce(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||Ce(e,"__enums__",null,!0)}c.js=at,e("eU",Object.freeze({__proto__:null,array:rt,js:at,IDGenerator:ge,Pool:ot,isNumber:Se,isString:Te,isEmptyObject:Ae,value:Ce,getset:Ie,get:Pe,set:be,createMap:Re,getClassName:Ne,obsolete:Oe,obsoletes:De,formatStr:Fe,shiftArguments:ze,getPropertyDescriptor:Be,addon:He,mixin:Ge,extend:Ve,getSuper:ke,isChildClassOf:We,clear:je,_idToClass:Ye,_nameToClass:Xe,_setClassId:Qe,setClassName:Je,setClassAlias:$e,unregisterClass:et,_getClassById:tt,getClassByName:nt,_getClassId:it})),st.isBitMask=function(e){return e&&e.hasOwnProperty("__bitmask__")},st.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},c.BitMask=st,ct.update=function(e){for(var t=-1,n=Object.keys(e),i=0;i<n.length;i++){var o=n[i],r=e[o];if(-1===r)r=++t,e[o]=r;else if("number"==typeof r)t=r;else if("string"==typeof r&&Number.isInteger(parseFloat(o)))continue;var a=""+r;o!==a&&Ce(e,a,o)}return Array.isArray(e.__enums__)&&ut(e),e},ct||(ct=e("bY",{})),ct.isEnum=function(e){return e&&e.hasOwnProperty("__enums__")},ct.getList=function(e){return lt(e),e.__enums__?e.__enums__:ut(e)},c.Enum=ct;var _t=e("eT",function(){function e(){}var t=e.prototype;return t.clone=function(){return N(100,Ne(this)+".clone"),this},t.equals=function(){return!1},t.set=function(){N(100,Ne(this)+".set")},t.toString=function(){return""+{}},e}());Je("cc.ValueType",_t),c.ValueType=_t;var ft=e("bn",{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});c.macro=ft;for(var dt=/^(?:cc|dragonBones|sp|ccsg)\..+/,pt=new Array(123),mt=0;mt<123;++mt)pt[mt]=64;for(var vt=0;vt<64;++vt)pt["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charCodeAt(vt)]=vt;var gt=pt;function yt(e,t,n){function i(e,t,n,i){var o=Object.getOwnPropertyDescriptor(e,t);if(o)o.get&&(e[n]=o.get),o.set&&i&&(e[i]=o.set);else{var r=e[n];Ie(e,t,r,e[i])}}for(var o,r=e.prototype,a=0;a<t.length;a++){var s=(o=t[a])[0].toUpperCase()+o.slice(1);i(r,o,"get"+s,"set"+s)}for(o in n){var c=n[o];i(r,o,c[0],c[1])}}function xt(e,t,n,i){var o=e[t];o?Array.isArray(o)?i?(o.push(o[0]),o[0]=n):o.push(n):e[t]=i?[n,o]:[o,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 St(e){return"object"==typeof window&&"function"==typeof Node?e instanceof Node:e&&"object"==typeof e&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName}function Tt(e,t,n){e&&setTimeout((function(){e(t,n)}),0)}function At(e){return!(!e||e.constructor!==Object)&&Ae(e)}function wt(e,t,n){if(t>n){var i=t;t=n,n=i}return e<t?t:e<n?e:n}function Ct(e){return e*ft.RAD}function It(e){return e*ft.DEG}c.misc={BUILTIN_CLASSID_RE:dt,BASE64_VALUES:gt,propertyDefine:yt,pushToMap:xt,contains:Et,isDomNode:St,callInNextTick:Tt,isPlainEmptyObj_DEV:At,clampf:wt,degreesToRadians:Ct,radiansToDegrees:It},e("eV",Object.freeze({__proto__:null,BUILTIN_CLASSID_RE:dt,BASE64_VALUES:gt,propertyDefine:yt,pushToMap:xt,contains:Et,isDomNode:St,callInNextTick:Tt,tryCatchFunctor_EDITOR:function(e){return Function("target","try {\n target."+e+"();\n}\ncatch (e) {\n cc._throw(e);\n}")},isPlainEmptyObj_DEV:At,clampf:wt,degreesToRadians:Ct,radiansToDegrees:It}));var Pt="$_$";function bt(e,t){var n=t?Object.create(t):{};return Ce(e,"__attrs__",n),n}function Rt(e){if("function"!=typeof e)return bt(e,Ot(e.constructor));for(var t,n=c.Class.getInheritanceChain(e),i=n.length-1;i>=0;i--){var o=n[i];o.hasOwnProperty("__attrs__")&&o.__attrs__||bt(o,(t=n[i+1])&&t.__attrs__)}return bt(e,(t=n[0])&&t.__attrs__),e.__attrs__}function Nt(e,t){var n=Ot(e),i=t+Pt,o={};for(var r in n)r.startsWith(i)&&(o[r.slice(i.length)]=n[r]);return o}function Ot(e){return e.hasOwnProperty("__attrs__")&&e.__attrs__||Rt(e)}function Dt(e,t,n,i){Ot(e)[t+Pt+n]=i}var Mt=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}(),Lt=e("et",new Mt("Integer",0));c.Integer=Lt,c.CCInteger=Lt;var Ft=e("f3",new Mt("Float",0));c.Float=Ft,c.CCFloat=Ft;var zt=e("eq",new Mt("Boolean",!1));c.Boolean=zt,c.CCBoolean=zt;var Bt=e("ce",new Mt("String",""));function Ut(e,t){return function(n,i){var o='"'+Ne(n)+"."+i+'"',r=Nt(n,i),a=r.type;if(a===Lt||a===Ft?a="Number":a!==Bt&&a!==zt||(a=""+a),a===e){if(r.hasOwnProperty("default")){var s=r.default;if(void 0!==s&&!Array.isArray(s)&&!At(s)){var c=typeof s,l=e.toLowerCase();if(c===l)if("object"===l){if(!s||s instanceof r.ctor)return;b(3605,o,Ne(r.ctor))}else"Number"!==e&&b(3606,t,o,e);else{if("function"===c)return;e===Bt.default&&null==s?b(3607,o):b(3611,t,o,c)}delete r.type}}}else b(3604,o)}}c.String=Bt,c.CCString=Bt;var Ht=Object.freeze({__proto__:null,DELIMETER:Pt,createAttrsSingle:bt,createAttrs:Rt,attr:Nt,getClassAttrs:Ot,setClassAttr:Dt,PrimitiveType:Mt,CCInteger:Lt,CCFloat:Ft,CCBoolean:zt,CCString:Bt,getTypeChecker_ET:Ut,getObjTypeChecker_ET:function(e){return function(t,n){Ut("Object","type")(t,n);var i=Ot(t)[n+Pt+"default"],o=c.Class.getDefault(i);if(!Array.isArray(o)&&We(e,c.ValueType)){var r=Ne(e),a=Fe('No need to specify the "type" of "%s.%s" because %s is a child class of ValueType.',Ne(t),n,r);i?g(a):b(3612,a,r,Ne(t),n,r)}}}}),Gt={default:{},serializable:{},editorOnly:{},formerlySerializedAs:{}};function Vt(e,t,n,i){if(!e.get&&!e.set&&e.hasOwnProperty("default")){var o="_N$"+t;e.get=function(){return this[o]},e.set=function(e){var t=this[o];this[o]=e,n.call(this,t)};var r={};for(var a in i[o]=r,Gt){var s=Gt[a];e.hasOwnProperty(a)&&(r[a]=e[a],s.canUsedInGet||delete e[a])}}}function kt(e,t,n,i){if(Array.isArray(t)){if(!(t.length>0))return N(5508,n,i);e.type=t=t[0]}"function"==typeof t&&(t===String?e.type=c.String:t===Boolean?e.type=c.Boolean:t===Number&&(e.type=c.Float))}function Wt(e,t,n){var i=e?{_short:!0}:{_short:!0,default:t};return n&&(i.type=n),i}function jt(e,t){if(!e||e.constructor!==Object){if(Array.isArray(e)&&e.length>0)return Wt(t,[],e);if("function"==typeof e){var n=e;return Wt(t,We(n,c.ValueType)?new n:null,n)}return Wt(t,e instanceof Mt?e.default:e)}return null}var qt=[];function Yt(){return qt[qt.length-1]}c._RF={push:function(e,t,n,i){void 0===n&&(n=t,t=""),qt.push({uuid:t,script:n,module:e,exports:e.exports,beh:null,importMeta:i})},pop:function(){var e=qt.pop(),t=e.module,n=t.exports;if(n===e.exports){for(var i in n)return;t.exports=n=e.cls}},peek:Yt};var Xt=Pt,Kt={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,o=n.props;"function"==typeof o&&(o=o());var r=Ne(i);o?en(i,r,o,i.$super,n.mixins):N(3633,r)}this.datas=null}}};function Qt(e,t,n,i){!function(e,t){!function(e,t){e.indexOf(t)<0&&e.push(t)}(e.__props__,t)}(e,n),on(e,i,t,n)}function Zt(e,t,n,i){var o=i.get;i.set,o&&(on(e,i,t,n),Dt(e,n,"serializable",!1))}function Jt(e){return"function"==typeof e?e():e}function $t(e,t,n){for(var i in t)e.hasOwnProperty(i)||n&&!n(i)||Object.defineProperty(e,i,Be(t,i))}function en(e,t,n,i,o){if(e.__props__=[],i&&i.__props__&&(e.__props__=i.__props__.slice()),o)for(var r=0;r<o.length;++r){var a=o[r];a.__props__&&(e.__props__=e.__props__.concat(a.__props__.filter((function(t){return e.__props__.indexOf(t)<0}))))}if(n)for(var s in function(e,t){for(var n in e){var i=e[n],o=jt(i,!1);if(o&&(i=e[n]=o),i){var r=i.notify;r&&Vt(i,n,r,e),"type"in i&&kt(i,i.type,t,n)}}}(n,t),n){var c=n[s];c.get||c.set?Zt(e,t,s,c):Qt(e,t,s,c)}var l=Ot(e);e.__values__=e.__props__.filter((function(e){return!1!==l[e+Xt+"serializable"]}))}function tn(e){var t=e.name,n=e.extends,i=e.mixins,o=function(e,t,n,i){var o=c.Component,r=Yt();if(r&&We(t,o)){if(We(r.cls,o))return N(3615),null;e=e||r.script}var a=function(e,t,n,i){var o=i.ctor,r=[o],a=o;Ce(a,"__ctors__",r.length>0?r:null,!0);var s=a.prototype;if(t&&(a.$super=t),n){for(var c=n.length-1;c>=0;c--){var l=n[c];$t(s,l.prototype),tn._isCCClass(l)&&$t(Ot(a),Ot(l))}s.constructor=a}return Je(e,a),a}(e,t,n,i);if(r)if(We(t,o)){var s=r.uuid;s&&Qe(s,a),r.cls=a}else We(r.cls,o)||(r.cls=a);return a}(t,n,i,e);t||(t=c.js.getClassName(o)),o._sealed=!0,n&&(n._sealed=!1);var r=e.properties;"function"==typeof r||n&&null===n.__props__||i&&i.some((function(e){return null===e.__props__}))?(Kt.push({cls:o,props:r,mixins:i}),o.__props__=o.__values__=null):en(o,t,r,n,e.mixins);var a=e.editor;return a&&We(n,c.Component)&&c.Component._registerEditorProps(o,a),o}tn._isCCClass=function(e){var t;return null==e||null===(t=e.hasOwnProperty)||void 0===t?void 0:t.call(e,"__ctors__")},tn.fastDefine=function(e,t,n){Je(e,t);for(var i=t.__props__=t.__values__=Object.keys(n),o=Ot(t),r=0;r<i.length;r++){var a=i[r];o[a+Xt+"visible"]=!1,o[a+Xt+"default"]=n[a]}},tn.Attr=Ht,tn.attr=Nt,tn.getInheritanceChain=function(e){for(var t=[];e=ke(e);)e!==Object&&t.push(e);return t};var nn={Integer:"Number",Float:"Number",Boolean:"Boolean",String:"String"};function on(e,t,n,i){var o=null,r="";function a(){return r=i+Xt,o=Ot(e)}"type"in t&&void 0===t.type&&b(3660,i,n);var s=t.type;s&&(nn[s]?(o||a())[r+"type"]=s:"Object"===s||("object"==typeof s?ct.isEnum(s)?((o||a())[r+"type"]="Enum",o[r+"enumList"]=ct.getList(s)):st.isBitMask(s)&&((o||a())[r+"type"]="BitMask",o[r+"bitmaskList"]=st.getList(s)):"function"==typeof s&&((o||a())[r+"type"]="Object",o[r+"ctor"]=s))),"default"in t&&((o||a())[r+"default"]=t.default);var c,l=function(e,n){if(e in t){var i=t[e];typeof i===n&&((o||a())[r+e]=i)}};t.editorOnly&&((o||a())[r+"editorOnly"]=!0),t.__noImplicit?(o||a())[r+"serializable"]=null!==(c=t.serializable)&&void 0!==c&&c:!1===t.serializable&&((o||a())[r+"serializable"]=!1),l("formerlySerializedAs","string");var u=t.range;u&&Array.isArray(u)&&u.length>=2&&((o||a())[r+"min"]=u[0],o[r+"max"]=u[1],u.length>2&&(o[r+"step"]=u[2])),l("min","number"),l("max","number"),l("step","number")}tn.isArray=function(e){return e=Jt(e),Array.isArray(e)},tn.getDefault=Jt,tn.escapeForJS=function(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")},tn.IDENTIFIER_RE=/^[A-Za-z_$][0-9A-Za-z_$]*$/,tn.getNewValueTypeCode=function(e){for(var t=Ne(e),n=e.constructor,i="new "+t+"(",o=0;o<n.__props__.length;o++)i+=e[n.__props__[o]],o<n.__props__.length-1&&(i+=",");return i+")"},c.Class=tn;var rn=Math.PI/180,an=180/Math.PI,sn=e("eL",1e-6);function cn(e,t){return Math.abs(e-t)<=sn*Math.max(1,Math.abs(e),Math.abs(t))}function ln(e,t,n){return n=n||sn,Math.abs(e-t)<=n}function un(e,t,n){if(t>n){var i=t;t=n,n=i}return e<t?t:e>n?n:e}function hn(e){return e<0?0:e>1?1:e}function _n(e,t,n){return e+(t-e)*n}function fn(e){return e*rn}function dn(e){return e*an}var pn=e("dX",Math.random);function mn(e,t){return Math.random()*(t-e)+e}function vn(e,t){return Math.floor(mn(e,t))}function gn(e){return(e=(9301*e+49297)%233280)/233280}function yn(e,t,n){return gn(e)*(n-t)+t}function xn(e,t,n){return Math.floor(yn(e,t,n))}function En(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 Tn(e,t){return e=Sn(e,2*t),t-Math.abs(e-t)}function An(e,t,n){return(n-e)/(t-e)}function wn(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 Cn(e,t){return Math.abs(e)>Math.abs(t)?e:t}var In=1/255,Pn=e("cl",function(e){function t(t,n,i,o){var r;return(r=e.call(this)||this)._val=0,"string"==typeof t?r.fromHEX(t):void 0!==n?r.set(t,n,i,o):r.set(t),r}ie(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,o){return e.r=t,e.g=n,e.b=i,e.a=o,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 o=t.r,r=t.g,a=t.b,s=t.a;return o+=(n.r-o)*i,r+=(n.g-r)*i,a+=(n.b-a)*i,s+=(n.a-s)*i,e._val=Math.floor((s<<24>>>0)+(a<<16)+(r<<8)+o),e},t.toArray=function(e,n,i){void 0===i&&(i=0);var o=n instanceof t||n.a>1?1/255:1;return e[i+0]=n.r*o,e[i+1]=n.g*o,e[i+2]=n.b*o,e[i+3]=n.a*o,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=sn),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};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,o=this.b,r=this.a;return n+=(e.r-n)*t,i+=(e.g-i)*t,o+=(e.b-o)*t,r+=(e.a-r)*t,this._val=Math.floor((r<<24>>>0)+(o<<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*In).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,o=parseInt(e.substr(6,2),16)||255;return this._val=(o<<24>>>0)+(i<<16)+(n<<8)+(0|t),this},n.toHEX=function(e){void 0===e&&(e="#rrggbb");var t="0",n=[(this.r<16?t:"")+this.r.toString(16),(this.g<16?t:"")+this.g.toString(16),(this.b<16?t:"")+this.b.toString(16)];return"#rgb"===e?(n[0]=n[0][0],n[1]=n[1][0],n[2]=n[2][0]):"#rrggbbaa"===e&&n.push((this.a<16?t:"")+this.a.toString(16)),n.join("")},n.toRGBValue=function(){return 16777215&this._val},n.fromHSV=function(e,t,n){var i=0,o=0,r=0;if(0===t)i=o=r=n;else if(0===n)i=o=r=0;else{1===e&&(e=0),e*=6;var a=Math.floor(e),s=e-a,c=n*(1-t),l=n*(1-t*s),u=n*(1-t*(1-s));switch(a){case 0:i=n,o=u,r=c;break;case 1:i=l,o=n,r=c;break;case 2:i=c,o=n,r=u;break;case 3:i=c,o=l,r=n;break;case 4:i=u,o=c,r=n;break;case 5:i=n,o=c,r=l}}return i*=255,o*=255,r*=255,this._val=(this.a<<24>>>0)+(r<<16)+(o<<8)+(0|i),this},n.toHSV=function(){var e=this.r*In,t=this.g*In,n=this.b*In,i={h:0,s:0,v:0},o=Math.max(e,t,n),r=Math.min(e,t,n),a=0;return i.v=o,i.s=o?(o-r)/o:0,i.s?(a=o-r,i.h=e===o?(t-n)/a:t===o?2+(n-e)/a:4+(e-t)/a,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,o=((4278190080&this._val)>>>8)*e.a;return this._val=4278190080&o|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},te(t,[{key:"r",get:function(){return 255&this._val},set:function(e){e=~~un(e,0,255),this._val=(4294967040&this._val|e)>>>0}},{key:"g",get:function(){return(65280&this._val)>>8},set:function(e){e=~~un(e,0,255),this._val=(4294902015&this._val|e<<8)>>>0}},{key:"b",get:function(){return(16711680&this._val)>>16},set:function(e){e=~~un(e,0,255),this._val=(4278255615&this._val|e<<16)>>>0}},{key:"a",get:function(){return(4278190080&this._val)>>>24},set:function(e){e=~~un(e,0,255),this._val=(16777215&this._val|e<<24)>>>0}},{key:"x",get:function(){return this.r*In},set:function(e){this.r=255*e}},{key:"y",get:function(){return this.g*In},set:function(e){this.g=255*e}},{key:"z",get:function(){return this.b*In},set:function(e){this.b=255*e}},{key:"w",get:function(){return this.a*In},set:function(e){this.a=255*e}}]),t}(_t));function bn(e,t,n,i){return new Pn(e,t,n,i)}Pn.WHITE=Object.freeze(new Pn(255,255,255,255)),Pn.GRAY=Object.freeze(new Pn(127,127,127,255)),Pn.BLACK=Object.freeze(new Pn(0,0,0,255)),Pn.TRANSPARENT=Object.freeze(new Pn(0,0,0,0)),Pn.RED=Object.freeze(new Pn(255,0,0,255)),Pn.GREEN=Object.freeze(new Pn(0,255,0,255)),Pn.BLUE=Object.freeze(new Pn(0,0,255,255)),Pn.CYAN=Object.freeze(new Pn(0,255,255,255)),Pn.MAGENTA=Object.freeze(new Pn(255,0,255,255)),Pn.YELLOW=Object.freeze(new Pn(255,255,0,255)),tn.fastDefine("cc.Color",Pn,{r:0,g:0,b:0,a:255}),c.Color=Pn,c.color=bn;var Rn=e("bJ",function(e){function t(t,n,i){var o;return o=e.call(this)||this,t&&"object"==typeof t?(o.x=t.x,o.y=t.y,o.z=t.z):(o.x=t||0,o.y=n||0,o.z=i||0),o}ie(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,o=t.z-e.z;return Math.sqrt(n*n+i*i+o*o)},t.squaredDistance=function(e,t){var n=t.x-e.x,i=t.y-e.y,o=t.z-e.z;return n*n+i*i+o*o},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,o=t.z;return Math.abs(n)<sn?e.x=0:e.x=1/n,Math.abs(i)<sn?e.y=0:e.y=1/i,Math.abs(o)<sn?e.z=0:e.z=1/o,e},t.normalize=function(e,t){var n=t.x,i=t.y,o=t.z,r=n*n+i*i+o*o;return r>0&&(r=1/Math.sqrt(r),e.x=n*r,e.y=i*r,e.z=o*r),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,o=t.y,r=t.z,a=n.x,s=n.y,c=n.z;return e.x=o*c-r*s,e.y=r*a-i*c,e.z=i*s-o*a,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*pn()*Math.PI,i=2*pn()-1,o=Math.sqrt(1-i*i);return e.x=o*Math.cos(n)*t,e.y=o*Math.sin(n)*t,e.z=i*t,e},t.transformMat4=function(e,t,n){var i=t.x,o=t.y,r=t.z,a=n.m03*i+n.m07*o+n.m11*r+n.m15;return a=a?Math.abs(1/a):1,e.x=(n.m00*i+n.m04*o+n.m08*r+n.m12)*a,e.y=(n.m01*i+n.m05*o+n.m09*r+n.m13)*a,e.z=(n.m02*i+n.m06*o+n.m10*r+n.m14)*a,e},t.transformMat4Normal=function(e,t,n){var i=t.x,o=t.y,r=t.z,a=n.m03*i+n.m07*o+n.m11*r;return a=a?Math.abs(1/a):1,e.x=(n.m00*i+n.m04*o+n.m08*r)*a,e.y=(n.m01*i+n.m05*o+n.m09*r)*a,e.z=(n.m02*i+n.m06*o+n.m10*r)*a,e},t.transformMat3=function(e,t,n){var i=t.x,o=t.y,r=t.z;return e.x=i*n.m00+o*n.m03+r*n.m06,e.y=i*n.m01+o*n.m04+r*n.m07,e.z=i*n.m02+o*n.m05+r*n.m08,e},t.transformAffine=function(e,t,n){var i=t.x,o=t.y,r=t.z;return e.x=n.m00*i+n.m04*o+n.m08*r+n.m12,e.y=n.m01*i+n.m05*o+n.m09*r+n.m13,e.x=n.m02*i+n.m06*o+n.m10*r+n.m14,e},t.transformQuat=function(e,t,n){var i=n.w*t.x+n.y*t.z-n.z*t.y,o=n.w*t.y+n.z*t.x-n.x*t.z,r=n.w*t.z+n.x*t.y-n.y*t.x,a=-n.x*t.x-n.y*t.y-n.z*t.z;return e.x=i*n.w+a*-n.x+o*-n.z-r*-n.y,e.y=o*n.w+a*-n.y+r*-n.x-i*-n.z,e.z=r*n.w+a*-n.z+i*-n.y-o*-n.x,e},t.transformRTS=function(e,t,n,i,o){var r=t.x*o.x,a=t.y*o.y,s=t.z*o.z,c=n.w*r+n.y*s-n.z*a,l=n.w*a+n.z*r-n.x*s,u=n.w*s+n.x*a-n.y*r,h=-n.x*r-n.y*a-n.z*s;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,o){var r=t.x-i.x,a=t.y-i.y,s=t.z-i.z,c=n.w*r-n.y*s+n.z*a,l=n.w*a-n.z*r+n.x*s,u=n.w*s-n.x*a+n.y*r,h=n.x*r+n.y*a+n.z*s;return e.x=(c*n.w+h*n.x+l*n.z-u*n.y)/o.x,e.y=(l*n.w+h*n.y+u*n.x-c*n.z)/o.y,e.z=(u*n.w+h*n.z+c*n.y-l*n.x)/o.z,e},t.rotateX=function(e,t,n,i){var o=t.x-n.x,r=t.y-n.y,a=t.z-n.z,s=Math.cos(i),c=Math.sin(i),l=o,u=r*s-a*c,h=r*c+a*s;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 o=t.x-n.x,r=t.y-n.y,a=t.z-n.z,s=Math.cos(i),c=Math.sin(i),l=a*c+o*s,u=r,h=a*s-o*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 o=t.x-n.x,r=t.y-n.y,a=t.z-n.z,s=Math.cos(i),c=Math.sin(i),l=o*s-r*c,u=o*c+r*s,h=a;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=sn);var i=e.x,o=e.y,r=e.z,a=t.x,s=t.y,c=t.z;return Math.abs(i-a)<=n*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(o-s)<=n*Math.max(1,Math.abs(o),Math.abs(s))&&Math.abs(r-c)<=n*Math.max(1,Math.abs(r),Math.abs(c))},t.angle=function(e,n){t.normalize(Nn,e),t.normalize(On,n);var i=t.dot(Nn,On);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 o=t.lengthSqr(i);return o<1e-6?t.set(e,0,0,0):t.multiplyScalar(e,i,t.dot(n,i)/o)};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=sn),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=sn),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=un(this.x,e.x,t.x),this.y=un(this.y,e.y,t.y),this.z=un(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,o=e.x,r=e.y,a=e.z;return this.x=n*a-i*r,this.y=i*o-t*a,this.z=t*r-n*o,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,o=e.m03*t+e.m07*n+e.m11*i+e.m15;return o=o?1/o:1,this.x=(e.m00*t+e.m04*n+e.m08*i+e.m12)*o,this.y=(e.m01*t+e.m05*n+e.m09*i+e.m13)*o,this.z=(e.m02*t+e.m06*n+e.m10*i+e.m14)*o,this},t}(_t));Rn.UNIT_X=Object.freeze(new Rn(1,0,0)),Rn.UNIT_Y=Object.freeze(new Rn(0,1,0)),Rn.UNIT_Z=Object.freeze(new Rn(0,0,1)),Rn.RIGHT=Object.freeze(new Rn(1,0,0)),Rn.UP=Object.freeze(new Rn(0,1,0)),Rn.FORWARD=Object.freeze(new Rn(0,0,-1)),Rn.ZERO=Object.freeze(new Rn(0,0,0)),Rn.ONE=Object.freeze(new Rn(1,1,1)),Rn.NEG_ONE=Object.freeze(new Rn(-1,-1,-1));var Nn=new Rn,On=new Rn;function Dn(e,t,n){return new Rn(e,t,n)}tn.fastDefine("cc.Vec3",Rn,{x:0,y:0,z:0}),c.Vec3=Rn,c.v3=Dn;var Mn=e("eG",function(e){function t(t,n,i,o,r,a,s,c,l){var u;return void 0===t&&(t=1),void 0===n&&(n=0),void 0===i&&(i=0),void 0===o&&(o=0),void 0===r&&(r=1),void 0===a&&(a=0),void 0===s&&(s=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=o,u.m04=r,u.m05=a,u.m06=s,u.m07=c,u.m08=l),u}ie(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,o,r,a,s,c,l){return e.m00=t,e.m01=n,e.m02=i,e.m03=o,e.m04=r,e.m05=a,e.m06=s,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,o=t.m05;e.m01=t.m03,e.m02=t.m06,e.m03=n,e.m05=t.m07,e.m06=i,e.m07=o}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,o=t.m02,r=t.m03,a=t.m04,s=t.m05,c=t.m06,l=t.m07,u=t.m08,h=u*a-s*l,_=-u*r+s*c,f=l*r-a*c,d=n*h+i*_+o*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+o*l)*d,e.m02=(s*i-o*a)*d,e.m03=_*d,e.m04=(u*n-o*c)*d,e.m05=(-s*n+o*r)*d,e.m06=f*d,e.m07=(-l*n+i*c)*d,e.m08=(a*n-i*r)*d,e)},t.determinant=function(e){var t=e.m00,n=e.m01,i=e.m02,o=e.m03,r=e.m04,a=e.m05,s=e.m06,c=e.m07,l=e.m08;return t*(l*r-a*c)+n*(-l*o+a*s)+i*(c*o-r*s)},t.multiply=function(e,t,n){var i=t.m00,o=t.m01,r=t.m02,a=t.m03,s=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,v=n.m05,g=n.m06,y=n.m07,x=n.m08;return e.m00=_*i+f*a+d*l,e.m01=_*o+f*s+d*u,e.m02=_*r+f*c+d*h,e.m03=p*i+m*a+v*l,e.m04=p*o+m*s+v*u,e.m05=p*r+m*c+v*h,e.m06=g*i+y*a+x*l,e.m07=g*o+y*s+x*u,e.m08=g*r+y*c+x*h,e},t.multiplyMat4=function(e,t,n){var i=t.m00,o=t.m01,r=t.m02,a=t.m03,s=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,v=n.m06,g=n.m08,y=n.m09,x=n.m10;return e.m00=_*i+f*a+d*l,e.m01=_*o+f*s+d*u,e.m02=_*r+f*c+d*h,e.m03=p*i+m*a+v*l,e.m04=p*o+m*s+v*u,e.m05=p*r+m*c+v*h,e.m06=g*i+y*a+x*l,e.m07=g*o+y*s+x*u,e.m08=g*r+y*c+x*h,e},t.transform=function(e,t,n){var i=t.m00,o=t.m01,r=t.m02,a=t.m03,s=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=o,e.m02=r,e.m03=a,e.m04=s,e.m05=c,e.m06=_*i+f*a+l,e.m07=_*o+f*s+u,e.m08=_*r+f*c+h,e},t.scale=function(e,t,n){var i=n.x,o=n.y;return e.m00=i*t.m00,e.m01=i*t.m01,e.m02=i*t.m02,e.m03=o*t.m03,e.m04=o*t.m04,e.m05=o*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,o=t.m01,r=t.m02,a=t.m03,s=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+_*a,e.m01=f*o+_*s,e.m02=f*r+_*c,e.m03=f*a-_*i,e.m04=f*s-_*o,e.m05=f*c-_*r,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 Rn.lengthSqr(n)<sn*sn?(t.identity(e),e):(i=i||Rn.UNIT_Y,Rn.normalize(Ln,Rn.cross(Ln,i,n)),Rn.lengthSqr(Ln)<sn*sn?(t.identity(e),e):(Rn.cross(Fn,n,Ln),t.set(e,Ln.x,Ln.y,Ln.z,Fn.x,Fn.y,Fn.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,o=t.z,r=t.w,a=n+n,s=i+i,c=o+o,l=n*a,u=i*a,h=i*s,_=o*a,f=o*s,d=o*c,p=r*a,m=r*s,v=r*c;return e.m00=1-h-d,e.m03=u-v,e.m06=_+m,e.m01=u+v,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,o=t.m02,r=t.m03,a=t.m04,s=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,v=t.m15,g=n*s-i*a,y=n*c-o*a,x=n*l-r*a,E=i*c-o*s,S=i*l-r*s,T=o*l-r*c,A=u*p-h*d,w=u*m-_*d,C=u*v-f*d,I=h*m-_*p,P=h*v-f*p,b=_*v-f*m,R=g*b-y*P+x*I+E*C-S*w+T*A;return R?(R=1/R,e.m00=(s*b-c*P+l*I)*R,e.m01=(c*C-a*b-l*w)*R,e.m02=(a*P-s*C+l*A)*R,e.m03=(o*P-i*b-r*I)*R,e.m04=(n*b-o*C+r*w)*R,e.m05=(i*C-n*P-r*A)*R,e.m06=(p*T-m*S+v*E)*R,e.m07=(m*x-d*T-v*y)*R,e.m08=(d*S-p*x+v*g)*R,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=sn),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,o,r,a,s,c){return void 0===e&&(e=1),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===o&&(o=1),void 0===r&&(r=0),void 0===a&&(a=0),void 0===s&&(s=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=o,this.m05=r,this.m06=a,this.m07=s,this.m08=c),this},n.equals=function(e,t){return void 0===t&&(t=sn),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,o=this.m04,r=this.m05,a=this.m06,s=this.m07,c=this.m08,l=c*o-r*s,u=-c*i+r*a,h=s*i-o*a,_=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*s)*_,this.m02=(r*t-n*o)*_,this.m03=u*_,this.m04=(c*e-n*a)*_,this.m05=(-r*e+n*i)*_,this.m06=h*_,this.m07=(-s*e+t*a)*_,this.m08=(o*e-t*i)*_,this)},n.determinant=function(){var e=this.m00,t=this.m01,n=this.m02,i=this.m03,o=this.m04,r=this.m05,a=this.m06,s=this.m07,c=this.m08;return e*(c*o-r*s)+t*(-c*i+r*a)+n*(s*i-o*a)},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,o=this.m03,r=this.m04,a=this.m05,s=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,v=e.m07,g=e.m08;return this.m00=u*t+h*o+_*s,this.m01=u*n+h*r+_*c,this.m02=u*i+h*a+_*l,this.m03=f*t+d*o+p*s,this.m04=f*n+d*r+p*c,this.m05=f*i+d*a+p*l,this.m06=m*t+v*o+g*s,this.m07=m*n+v*r+g*c,this.m08=m*i+v*a+g*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,o=this.m03,r=this.m04,a=this.m05,s=this.m06,c=this.m07,l=this.m08,u=Math.sin(e),h=Math.cos(e);return this.m00=h*t+u*o,this.m01=h*n+u*r,this.m02=h*i+u*a,this.m03=h*o-u*t,this.m04=h*r-u*n,this.m05=h*a-u*i,this.m06=s,this.m07=c,this.m08=l,this},n.fromQuat=function(e){var t=e.x,n=e.y,i=e.z,o=e.w,r=t+t,a=n+n,s=i+i,c=t*r,l=n*r,u=n*a,h=i*r,_=i*a,f=i*s,d=o*r,p=o*a,m=o*s;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));Mn.IDENTITY=Object.freeze(new Mn);var Ln=new Rn,Fn=new Rn;tn.fastDefine("cc.Mat3",Mn,{m00:1,m01:0,m02:0,m03:0,m04:1,m05:0,m06:0,m07:0,m08:1}),c.Mat3=Mn;var zn=e("bM",function(e){function t(t,n,i,o){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.w=t.w):(r.x=t||0,r.y=n||0,r.z=i||0,r.w=null!=o?o:1),r}ie(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,o){return e.x=t,e.y=n,e.z=i,e.w=o,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 o=Rn.dot(n,i);return o<-.999999?(Rn.cross(Hn,Rn.UNIT_X,n),Hn.length()<1e-6&&Rn.cross(Hn,Rn.UNIT_Y,n),Rn.normalize(Hn,Hn),t.fromAxisAngle(e,Hn,Math.PI),e):o>.999999?(e.x=0,e.y=0,e.z=0,e.w=1,e):(Rn.cross(Hn,n,i),e.x=Hn.x,e.y=Hn.y,e.z=Hn.z,e.w=1+o,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,o=t.y*n.w+t.w*n.y+t.z*n.x-t.x*n.z,r=t.z*n.w+t.w*n.z+t.x*n.y-t.y*n.x,a=t.w*n.w-t.x*n.x-t.y*n.y-t.z*n.z;return e.x=i,e.y=o,e.z=r,e.w=a,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),o=Math.cos(n),r=t.x,a=t.y,s=t.z,c=t.w;return e.x=r*o+c*i,e.y=a*o+s*i,e.z=s*o-a*i,e.w=c*o-r*i,e},t.rotateY=function(e,t,n){n*=.5;var i=Math.sin(n),o=Math.cos(n),r=t.x,a=t.y,s=t.z,c=t.w;return e.x=r*o-s*i,e.y=a*o+c*i,e.z=s*o+r*i,e.w=c*o-a*i,e},t.rotateZ=function(e,t,n){n*=.5;var i=Math.sin(n),o=Math.cos(n),r=t.x,a=t.y,s=t.z,c=t.w;return e.x=r*o+a*i,e.y=a*o-r*i,e.z=s*o+c*i,e.w=c*o-s*i,e},t.rotateAround=function(e,n,i,o){return t.invert(Bn,n),Rn.transformQuat(Hn,i,Bn),t.fromAxisAngle(Bn,Hn,o),t.multiply(e,n,Bn),e},t.rotateAroundLocal=function(e,n,i,o){return t.fromAxisAngle(Bn,i,o),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 o=0,r=0,a=n.x,s=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,a=-a,s=-s,c=-c,l=-l),1-u>1e-6){var h=Math.acos(u),_=Math.sin(h);o=Math.sin((1-i)*h)/_,r=Math.sin(i*h)/_}else o=1-i,r=i;return e.x=o*t.x+r*a,e.y=o*t.y+r*s,e.z=o*t.z+r*c,e.w=o*t.w+r*l,e},t.sqlerp=function(e,n,i,o,r,a){return t.slerp(Bn,n,r,a),t.slerp(Un,i,o,a),t.slerp(e,Bn,Un,2*a*(1-a)),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,o){return Mn.set(Gn,n.x,n.y,n.z,i.x,i.y,i.z,o.x,o.y,o.z),t.normalize(e,t.fromMat3(e,Gn))},t.fromViewUp=function(e,n,i){return Mn.fromViewUp(Gn,n,i),t.normalize(e,t.fromMat3(e,Gn))},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,o=t.m06,r=t.m01,a=t.m04,s=t.m07,c=t.m02,l=t.m05,u=t.m08,h=n+a+u;if(h>0){var _=.5/Math.sqrt(h+1);e.w=.25/_,e.x=(l-s)*_,e.y=(o-c)*_,e.z=(r-i)*_}else if(n>a&&n>u){var f=2*Math.sqrt(1+n-a-u);e.w=(l-s)/f,e.x=.25*f,e.y=(i+r)/f,e.z=(o+c)/f}else if(a>u){var d=2*Math.sqrt(1+a-n-u);e.w=(o-c)/d,e.x=(i+r)/d,e.y=.25*d,e.z=(s+l)/d}else{var p=2*Math.sqrt(1+u-n-a);e.w=(r-i)/p,e.x=(o+c)/p,e.y=(s+l)/p,e.z=.25*p}return e},t.fromEuler=function(e,t,n,i){t*=Vn,n*=Vn,i*=Vn;var o=Math.sin(t),r=Math.cos(t),a=Math.sin(n),s=Math.cos(n),c=Math.sin(i),l=Math.cos(i);return e.x=o*s*l+r*a*c,e.y=r*a*l+o*s*c,e.z=r*s*c-o*a*l,e.w=r*s*l-o*a*c,e},t.fromAngleZ=function(e,t){return t*=Vn,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,o=2*t.z;return e.x=i*t.x-o*t.w,e.y=1-n*t.x-o*t.z,e.z=o*t.y+n*t.w,e},t.toAxisZ=function(e,t){var n=2*t.x,i=2*t.y,o=2*t.z;return e.x=o*t.x-i*t.w,e.y=o*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,o=t.y,r=t.z,a=t.w,s=0,c=0,l=0,u=i*o+r*a;if(u>.499999)s=0,c=dn(2*Math.atan2(i,a)),l=90;else if(u<-.499999)s=0,c=-dn(2*Math.atan2(i,a)),l=-90;else{var h=i*i,_=o*o,f=r*r;s=dn(Math.atan2(2*i*a-2*o*r,1-2*h-2*f)),c=dn(Math.atan2(2*o*a-2*i*r,1-2*_-2*f)),l=dn(Math.asin(2*u)),n&&(s=-180*Math.sign(s+1e-6)+s,c=-180*Math.sign(c+1e-6)+c,l=180*Math.sign(l+1e-6)-l)}return e.x=s,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=sn),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=sn),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));zn.IDENTITY=Object.freeze(new zn);var Bn=new zn,Un=new zn,Hn=new Rn,Gn=new Mn,Vn=.5*Math.PI/180;function kn(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 zn(e,t,n,i)}tn.fastDefine("cc.Quat",zn,{x:0,y:0,z:0,w:1}),c.Quat=zn,c.quat=kn;var Wn=e("ee",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])])),jn=e("cb",function(e){function t(t,n,i,o,r,a,s,c,l,u,h,_,f,d,p,m){var v;return void 0===t&&(t=1),void 0===n&&(n=0),void 0===i&&(i=0),void 0===o&&(o=0),void 0===r&&(r=0),void 0===a&&(a=1),void 0===s&&(s=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),(v=e.call(this)||this).m00=void 0,v.m01=void 0,v.m02=void 0,v.m03=void 0,v.m04=void 0,v.m05=void 0,v.m06=void 0,v.m07=void 0,v.m08=void 0,v.m09=void 0,v.m10=void 0,v.m11=void 0,v.m12=void 0,v.m13=void 0,v.m14=void 0,v.m15=void 0,"object"==typeof t?(v.m00=t.m00,v.m01=t.m01,v.m02=t.m02,v.m03=t.m03,v.m04=t.m04,v.m05=t.m05,v.m06=t.m06,v.m07=t.m07,v.m08=t.m08,v.m09=t.m09,v.m10=t.m10,v.m11=t.m11,v.m12=t.m12,v.m13=t.m13,v.m14=t.m14,v.m15=t.m15):(v.m00=t,v.m01=n,v.m02=i,v.m03=o,v.m04=r,v.m05=a,v.m06=s,v.m07=c,v.m08=l,v.m09=u,v.m10=h,v.m11=_,v.m12=f,v.m13=d,v.m14=p,v.m15=m),v}ie(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,o,r,a,s,c,l,u,h,_,f,d,p,m){return e.m00=t,e.m01=n,e.m02=i,e.m03=o,e.m04=r,e.m05=a,e.m06=s,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,o=t.m03,r=t.m06,a=t.m07,s=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=r,e.m11=t.m14,e.m12=o,e.m13=a,e.m14=s}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,o=t.m02,r=t.m03,a=t.m04,s=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,v=t.m15,g=n*s-i*a,y=n*c-o*a,x=n*l-r*a,E=i*c-o*s,S=i*l-r*s,T=o*l-r*c,A=u*p-h*d,w=u*m-_*d,C=u*v-f*d,I=h*m-_*p,P=h*v-f*p,b=_*v-f*m,R=g*b-y*P+x*I+E*C-S*w+T*A;return 0===R?(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):(R=1/R,e.m00=(s*b-c*P+l*I)*R,e.m01=(o*P-i*b-r*I)*R,e.m02=(p*T-m*S+v*E)*R,e.m03=(_*S-h*T-f*E)*R,e.m04=(c*C-a*b-l*w)*R,e.m05=(n*b-o*C+r*w)*R,e.m06=(m*x-d*T-v*y)*R,e.m07=(u*T-_*x+f*y)*R,e.m08=(a*P-s*C+l*A)*R,e.m09=(i*C-n*P-r*A)*R,e.m10=(d*S-p*x+v*g)*R,e.m11=(h*x-u*S-f*g)*R,e.m12=(s*w-a*I-c*A)*R,e.m13=(n*I-i*w+o*A)*R,e.m14=(p*y-d*E-m*g)*R,e.m15=(u*E-h*y+_*g)*R,e)},t.determinant=function(e){var t=e.m00,n=e.m01,i=e.m02,o=e.m03,r=e.m04,a=e.m05,s=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*a-n*r)*(h*m-_*p)-(t*s-i*r)*(u*m-_*d)+(t*c-o*r)*(u*p-h*d)+(n*s-i*a)*(l*m-_*f)-(n*c-o*a)*(l*p-h*f)+(i*c-o*s)*(l*d-u*f)},t.multiply=function(e,t,n){var i=t.m00,o=t.m01,r=t.m02,a=t.m03,s=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,v=t.m14,g=t.m15,y=n.m00,x=n.m01,E=n.m02,S=n.m03;return e.m00=y*i+x*s+E*h+S*p,e.m01=y*o+x*c+E*_+S*m,e.m02=y*r+x*l+E*f+S*v,e.m03=y*a+x*u+E*d+S*g,y=n.m04,x=n.m05,E=n.m06,S=n.m07,e.m04=y*i+x*s+E*h+S*p,e.m05=y*o+x*c+E*_+S*m,e.m06=y*r+x*l+E*f+S*v,e.m07=y*a+x*u+E*d+S*g,y=n.m08,x=n.m09,E=n.m10,S=n.m11,e.m08=y*i+x*s+E*h+S*p,e.m09=y*o+x*c+E*_+S*m,e.m10=y*r+x*l+E*f+S*v,e.m11=y*a+x*u+E*d+S*g,y=n.m12,x=n.m13,E=n.m14,S=n.m15,e.m12=y*i+x*s+E*h+S*p,e.m13=y*o+x*c+E*_+S*m,e.m14=y*r+x*l+E*f+S*v,e.m15=y*a+x*u+E*d+S*g,e},t.transform=function(e,t,n){var i=n.x,o=n.y,r=n.z;if(t===e)e.m12=t.m00*i+t.m04*o+t.m08*r+t.m12,e.m13=t.m01*i+t.m05*o+t.m09*r+t.m13,e.m14=t.m02*i+t.m06*o+t.m10*r+t.m14,e.m15=t.m03*i+t.m07*o+t.m11*r+t.m15;else{var a=t.m00,s=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,v=t.m11;t.m12,t.m13,t.m14,t.m15,e.m00=a,e.m01=s,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=v,e.m12=a*i+u*o+d*r+t.m12,e.m13=s*i+h*o+p*r+t.m13,e.m14=c*i+_*o+m*r+t.m14,e.m15=l*i+f*o+v*r+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,o=n.y,r=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*o,e.m05=t.m05*o,e.m06=t.m06*o,e.m07=t.m07*o,e.m08=t.m08*r,e.m09=t.m09*r,e.m10=t.m10*r,e.m11=t.m11*r,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 o=i.x,r=i.y,a=i.z,s=Math.sqrt(o*o+r*r+a*a);if(Math.abs(s)<sn)return null;o*=s=1/s,r*=s,a*=s;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,v=t.m06,g=t.m07,y=t.m08,x=t.m09,E=t.m10,S=t.m11,T=o*o*u+l,A=r*o*u+a*c,w=a*o*u-r*c,C=o*r*u-a*c,I=r*r*u+l,P=a*r*u+o*c,b=o*a*u+r*c,R=r*a*u-o*c,N=a*a*u+l;return e.m00=h*T+p*A+y*w,e.m01=_*T+m*A+x*w,e.m02=f*T+v*A+E*w,e.m03=d*T+g*A+S*w,e.m04=h*C+p*I+y*P,e.m05=_*C+m*I+x*P,e.m06=f*C+v*I+E*P,e.m07=d*C+g*I+S*P,e.m08=h*b+p*R+y*N,e.m09=_*b+m*R+x*N,e.m10=f*b+v*R+E*N,e.m11=d*b+g*R+S*N,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),o=Math.cos(n),r=t.m04,a=t.m05,s=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=r*o+l*i,e.m05=a*o+u*i,e.m06=s*o+h*i,e.m07=c*o+_*i,e.m08=l*o-r*i,e.m09=u*o-a*i,e.m10=h*o-s*i,e.m11=_*o-c*i,e},t.rotateY=function(e,t,n){var i=Math.sin(n),o=Math.cos(n),r=t.m00,a=t.m01,s=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=r*o-l*i,e.m01=a*o-u*i,e.m02=s*o-h*i,e.m03=c*o-_*i,e.m08=r*i+l*o,e.m09=a*i+u*o,e.m10=s*i+h*o,e.m11=c*i+_*o,e},t.rotateZ=function(e,t,n){var i=Math.sin(n),o=Math.cos(n),r=t.m00,a=t.m01,s=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=r*o+l*i,e.m01=a*o+u*i,e.m02=s*o+h*i,e.m03=c*o+_*i,e.m04=l*o-r*i,e.m05=u*o-a*i,e.m06=h*o-s*i,e.m07=_*o-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,o=n.y,r=n.z,a=Math.sqrt(i*i+o*o+r*r);if(Math.abs(a)<sn)return null;i*=a=1/a,o*=a,r*=a;var s=Math.sin(t),c=Math.cos(t),l=1-c;return e.m00=i*i*l+c,e.m01=o*i*l+r*s,e.m02=r*i*l-o*s,e.m03=0,e.m04=i*o*l-r*s,e.m05=o*o*l+c,e.m06=r*o*l+i*s,e.m07=0,e.m08=i*r*l+o*s,e.m09=o*r*l-i*s,e.m10=r*r*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,o=t.y,r=t.z,a=t.w,s=i+i,c=o+o,l=r+r,u=i*s,h=i*c,_=i*l,f=o*c,d=o*l,p=r*l,m=a*s,v=a*c,g=a*l;return e.m00=1-(f+p),e.m01=h+g,e.m02=_-v,e.m03=0,e.m04=h-g,e.m05=1-(u+p),e.m06=d+m,e.m07=0,e.m08=_+v,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=Yn.m00=t.m00,i=Yn.m01=t.m01,o=Yn.m02=t.m02,r=Yn.m03=t.m04,a=Yn.m04=t.m05,s=Yn.m05=t.m06,c=Yn.m06=t.m08,l=Yn.m07=t.m09,u=Yn.m08=t.m10;return e.x=Math.sqrt(n*n+i*i+o*o),e.y=Math.sqrt(r*r+a*a+s*s),e.z=Math.sqrt(c*c+l*l+u*u),Mn.determinant(Yn)<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=Rn.set(qn,e.m00,e.m01,e.m02).length(),Yn.m00=e.m00/i.x,Yn.m01=e.m01/i.x,Yn.m02=e.m02/i.x,i.y=Rn.set(qn,e.m04,e.m05,e.m06).length(),Yn.m03=e.m04/i.y,Yn.m04=e.m05/i.y,Yn.m05=e.m06/i.y,i.z=Rn.set(qn,e.m08,e.m09,e.m10).length(),Yn.m06=e.m08/i.z,Yn.m07=e.m09/i.z,Yn.m08=e.m10/i.z,Mn.determinant(Yn)<0&&(i.x*=-1,Yn.m00*=-1,Yn.m01*=-1,Yn.m02*=-1),zn.fromMat3(t,Yn),Rn.set(n,e.m12,e.m13,e.m14)},t.fromRTS=function(e,t,n,i){var o=t.x,r=t.y,a=t.z,s=t.w,c=o+o,l=r+r,u=a+a,h=o*c,_=o*l,f=o*u,d=r*l,p=r*u,m=a*u,v=s*c,g=s*l,y=s*u,x=i.x,E=i.y,S=i.z;return e.m00=(1-(d+m))*x,e.m01=(_+y)*x,e.m02=(f-g)*x,e.m03=0,e.m04=(_-y)*E,e.m05=(1-(h+m))*E,e.m06=(p+v)*E,e.m07=0,e.m08=(f+g)*S,e.m09=(p-v)*S,e.m10=(1-(h+d))*S,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,o){var r=t.x,a=t.y,s=t.z,c=t.w,l=r+r,u=a+a,h=s+s,_=r*l,f=r*u,d=r*h,p=a*u,m=a*h,v=s*h,g=c*l,y=c*u,x=c*h,E=i.x,S=i.y,T=i.z,A=o.x,w=o.y,C=o.z;return e.m00=(1-(p+v))*E,e.m01=(f+x)*E,e.m02=(d-y)*E,e.m03=0,e.m04=(f-x)*S,e.m05=(1-(_+v))*S,e.m06=(m+g)*S,e.m07=0,e.m08=(d+y)*T,e.m09=(m-g)*T,e.m10=(1-(_+p))*T,e.m11=0,e.m12=n.x+A-(e.m00*A+e.m04*w+e.m08*C),e.m13=n.y+w-(e.m01*A+e.m05*w+e.m09*C),e.m14=n.z+C-(e.m02*A+e.m06*w+e.m10*C),e.m15=1,e},t.fromQuat=function(e,t){var n=t.x,i=t.y,o=t.z,r=t.w,a=n+n,s=i+i,c=o+o,l=n*a,u=i*a,h=i*s,_=o*a,f=o*s,d=o*c,p=r*a,m=r*s,v=r*c;return e.m00=1-h-d,e.m01=u+v,e.m02=_-m,e.m03=0,e.m04=u-v,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,o,r,a){var s=1/(n-t),c=1/(o-i),l=1/(r-a);return e.m00=2*r*s,e.m01=0,e.m02=0,e.m03=0,e.m04=0,e.m05=2*r*c,e.m06=0,e.m07=0,e.m08=(n+t)*s,e.m09=(o+i)*c,e.m10=(a+r)*l,e.m11=-1,e.m12=0,e.m13=0,e.m14=a*r*2*l,e.m15=0,e},t.perspective=function(e,t,n,i,o,r,a,s,c){void 0===r&&(r=!0),void 0===a&&(a=-1),void 0===s&&(s=1),void 0===c&&(c=0);var l=1/Math.tan(t/2),u=1/(i-o),h=r?l/n:l,_=(r?l:l*n)*s,f=Wn[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=(o-a*i)*u,e.m11=-1,e.m12=0,e.m13=0,e.m14=o*i*u*(1-a),e.m15=0,e},t.ortho=function(e,t,n,i,o,r,a,s,c,l){void 0===s&&(s=-1),void 0===c&&(c=1),void 0===l&&(l=0);var u=1/(t-n),h=1/(i-o)*c,_=1/(r-a),f=-2*u,d=-2*h,p=(t+n)*u,m=(o+i)*h,v=Wn[l];return e.m00=f*v[0],e.m01=f*v[1],e.m02=0,e.m03=0,e.m04=d*v[2],e.m05=d*v[3],e.m06=0,e.m07=0,e.m08=0,e.m09=0,e.m10=_*(1-s),e.m11=0,e.m12=p*v[0]+m*v[2],e.m13=p*v[1]+m*v[3],e.m14=(r-s*a)*_,e.m15=1,e},t.lookAt=function(e,t,n,i){var o=t.x,r=t.y,a=t.z,s=i.x,c=i.y,l=i.z,u=o-n.x,h=r-n.y,_=a-n.z,f=1/Math.sqrt(u*u+h*h+_*_),d=c*(_*=f)-l*(h*=f),p=l*(u*=f)-s*_,m=s*h-c*u,v=h*(m*=f=1/Math.sqrt(d*d+p*p+m*m))-_*(p*=f),g=_*(d*=f)-u*m,y=u*p-h*d;return e.m00=d,e.m01=v,e.m02=u,e.m03=0,e.m04=p,e.m05=g,e.m06=h,e.m07=0,e.m08=m,e.m09=y,e.m10=_,e.m11=0,e.m12=-(d*o+p*r+m*a),e.m13=-(v*o+g*r+y*a),e.m14=-(u*o+h*r+_*a),e.m15=1,e},t.inverseTranspose=function(e,t){var n=t.m00,i=t.m01,o=t.m02,r=t.m03,a=t.m04,s=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,v=t.m15,g=n*s-i*a,y=n*c-o*a,x=n*l-r*a,E=i*c-o*s,S=i*l-r*s,T=o*l-r*c,A=u*p-h*d,w=u*m-_*d,C=u*v-f*d,I=h*m-_*p,P=h*v-f*p,b=_*v-f*m,R=g*b-y*P+x*I+E*C-S*w+T*A;return R?(R=1/R,e.m00=(s*b-c*P+l*I)*R,e.m01=(c*C-a*b-l*w)*R,e.m02=(a*P-s*C+l*A)*R,e.m03=0,e.m04=(o*P-i*b-r*I)*R,e.m05=(n*b-o*C+r*w)*R,e.m06=(i*C-n*P-r*A)*R,e.m07=0,e.m08=(p*T-m*S+v*E)*R,e.m09=(m*x-d*T-v*y)*R,e.m10=(d*S-p*x+v*g)*R,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=sn),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,o,r,a,s,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===o&&(o=0),void 0===r&&(r=1),void 0===a&&(a=0),void 0===s&&(s=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=o,this.m05=r,this.m06=a,this.m07=s,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=sn),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,o=this.m07,r=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=o,this.m14=r,this},n.invert=function(){var e=this.m00,t=this.m01,n=this.m02,i=this.m03,o=this.m04,r=this.m05,a=this.m06,s=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*r-t*o,v=e*a-n*o,g=e*s-i*o,y=t*a-n*r,x=t*s-i*r,E=n*s-i*a,S=c*f-l*_,T=c*d-u*_,A=c*p-h*_,w=l*d-u*f,C=l*p-h*f,I=u*p-h*d,P=m*I-v*C+g*w+y*A-x*T+E*S;return 0===P?(this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),this):(P=1/P,this.m00=(r*I-a*C+s*w)*P,this.m01=(n*C-t*I-i*w)*P,this.m02=(f*E-d*x+p*y)*P,this.m03=(u*x-l*E-h*y)*P,this.m04=(a*A-o*I-s*T)*P,this.m05=(e*I-n*A+i*T)*P,this.m06=(d*g-_*E-p*v)*P,this.m07=(c*E-u*g+h*v)*P,this.m08=(o*C-r*A+s*S)*P,this.m09=(t*A-e*C-i*S)*P,this.m10=(_*x-f*g+p*m)*P,this.m11=(l*g-c*x-h*m)*P,this.m12=(r*T-o*w-a*S)*P,this.m13=(e*w-t*T+n*S)*P,this.m14=(f*v-_*y-d*m)*P,this.m15=(c*y-l*v+u*m)*P,this)},n.determinant=function(){var e=this.m00,t=this.m01,n=this.m02,i=this.m03,o=this.m04,r=this.m05,a=this.m06,s=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*r-t*o)*(u*p-h*d)-(e*a-n*o)*(l*p-h*f)+(e*s-i*o)*(l*d-u*f)+(t*a-n*r)*(c*p-h*_)-(t*s-i*r)*(c*d-u*_)+(n*s-i*a)*(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,o=this.m03,r=this.m04,a=this.m05,s=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,v=e.m00,g=e.m01,y=e.m02,x=e.m03;return this.m00=v*t+g*r+y*l+x*f,this.m01=v*n+g*a+y*u+x*d,this.m02=v*i+g*s+y*h+x*p,this.m03=v*o+g*c+y*_+x*m,v=e.m04,g=e.m05,y=e.m06,x=e.m07,this.m04=v*t+g*r+y*l+x*f,this.m05=v*n+g*a+y*u+x*d,this.m06=v*i+g*s+y*h+x*p,this.m07=v*o+g*c+y*_+x*m,v=e.m08,g=e.m09,y=e.m10,x=e.m11,this.m08=v*t+g*r+y*l+x*f,this.m09=v*n+g*a+y*u+x*d,this.m10=v*i+g*s+y*h+x*p,this.m11=v*o+g*c+y*_+x*m,v=e.m12,g=e.m13,y=e.m14,x=e.m15,this.m12=v*t+g*r+y*l+x*f,this.m13=v*n+g*a+y*u+x*d,this.m14=v*i+g*s+y*h+x*p,this.m15=v*o+g*c+y*_+x*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,o=t.z,r=Math.sqrt(n*n+i*i+o*o);if(Math.abs(r)<sn)return null;n*=r=1/r,i*=r,o*=r;var a=Math.sin(e),s=Math.cos(e),c=1-s,l=this.m00,u=this.m01,h=this.m02,_=this.m03,f=this.m04,d=this.m05,p=this.m06,m=this.m07,v=this.m08,g=this.m09,y=this.m10,x=this.m11,E=n*n*c+s,S=i*n*c+o*a,T=o*n*c-i*a,A=n*i*c-o*a,w=i*i*c+s,C=o*i*c+n*a,I=n*o*c+i*a,P=i*o*c-n*a,b=o*o*c+s;return this.m00=l*E+f*S+v*T,this.m01=u*E+d*S+g*T,this.m02=h*E+p*S+y*T,this.m03=_*E+m*S+x*T,this.m04=l*A+f*w+v*C,this.m05=u*A+d*w+g*C,this.m06=h*A+p*w+y*C,this.m07=_*A+m*w+x*C,this.m08=l*I+f*P+v*b,this.m09=u*I+d*P+g*b,this.m10=h*I+p*P+y*b,this.m11=_*I+m*P+x*b,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=Yn.m00=this.m00,n=Yn.m01=this.m01,i=Yn.m02=this.m02,o=Yn.m03=this.m04,r=Yn.m04=this.m05,a=Yn.m05=this.m06,s=Yn.m06=this.m08,c=Yn.m07=this.m09,l=Yn.m08=this.m10;return e.x=Math.sqrt(t*t+n*n+i*i),e.y=Math.sqrt(o*o+r*r+a*a),e.z=Math.sqrt(s*s+c*c+l*l),Mn.determinant(Yn)<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,o=e.y,r=e.z,a=e.w,s=i+i,c=o+o,l=r+r,u=i*s,h=i*c,_=i*l,f=o*c,d=o*l,p=r*l,m=a*s,v=a*c,g=a*l,y=n.x,x=n.y,E=n.z;return this.m00=(1-(f+p))*y,this.m01=(h+g)*y,this.m02=(_-v)*y,this.m03=0,this.m04=(h-g)*x,this.m05=(1-(u+p))*x,this.m06=(d+m)*x,this.m07=0,this.m08=(_+v)*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,o=e.w,r=t+t,a=n+n,s=i+i,c=t*r,l=n*r,u=n*a,h=i*r,_=i*a,f=i*s,d=o*r,p=o*a,m=o*s;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));jn.IDENTITY=Object.freeze(new jn);var qn=new Rn,Yn=new Mn;function Xn(e,t,n,i,o,r,a,s,c,l,u,h,_,f,d,p){return new jn(e,t,n,i,o,r,a,s,c,l,u,h,_,f,d,p)}tn.fastDefine("cc.Mat4",jn,{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}),c.Mat4=jn,c.mat4=Xn;var Kn=e("cM",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}ie(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)<sn?e.x=0:e.x=1/n,Math.abs(i)<sn?e.y=0:e.y=1/i,e},t.normalize=function(e,t){var n=t.x,i=t.y,o=n*n+i*i;return o>0&&(o=1/Math.sqrt(o),e.x=n*o,e.y=i*o),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 o=t.x,r=t.y;return e.x=o+i*(n.x-o),e.y=r+i*(n.y-r),e},t.random=function(e,t){t=t||1;var n=2*pn()*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,o=t.y;return e.x=n.m00*i+n.m03*o+n.m06,e.y=n.m01*i+n.m04*o+n.m07,e},t.transformMat4=function(e,t,n){var i=t.x,o=t.y;return e.x=n.m00*i+n.m04*o+n.m12,e.y=n.m01*i+n.m05*o+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=sn),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(Qn,e),t.normalize(Zn,n);var i=t.dot(Qn,Zn);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=sn),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=sn),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=un(this.x,e.x,t.x),this.y=un(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=un(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),o=Math.cos(e);return this.x=o*t-i*n,this.y=i*t+o*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));Kn.ZERO=Object.freeze(new Kn(0,0)),Kn.ONE=Object.freeze(new Kn(1,1)),Kn.NEG_ONE=Object.freeze(new Kn(-1,-1)),Kn.UNIT_X=Object.freeze(new Kn(1,0)),Kn.UNIT_Y=Object.freeze(new Kn(0,1));var Qn=new Kn,Zn=new Kn;function Jn(e,t){return new Kn(e,t)}tn.fastDefine("cc.Vec2",Kn,{x:0,y:0}),c.Vec2=Kn,c.v2=Jn;var $n=e("c4",function(e){function t(t,n,i,o){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.w=t.w):(r.x=t||0,r.y=n||0,r.z=i||0,r.w=o||0),r}ie(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,o){return e.x=t,e.y=n,e.z=i,e.w=o,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,o=t.z-e.z,r=t.w-e.w;return Math.sqrt(n*n+i*i+o*o+r*r)},t.squaredDistance=function(e,t){var n=t.x-e.x,i=t.y-e.y,o=t.z-e.z,r=t.w-e.w;return n*n+i*i+o*o+r*r},t.len=function(e){var t=e.x,n=e.y,i=e.z,o=e.w;return Math.sqrt(t*t+n*n+i*i+o*o)},t.lengthSqr=function(e){var t=e.x,n=e.y,i=e.z,o=e.w;return t*t+n*n+i*i+o*o},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,o=t.z,r=t.w;return Math.abs(n)<sn?e.x=0:e.x=1/n,Math.abs(i)<sn?e.y=0:e.y=1/i,Math.abs(o)<sn?e.z=0:e.z=1/o,Math.abs(r)<sn?e.w=0:e.w=1/r,e},t.normalize=function(e,t){var n=t.x,i=t.y,o=t.z,r=t.w,a=n*n+i*i+o*o+r*r;return a>0&&(a=1/Math.sqrt(a),e.x=n*a,e.y=i*a,e.z=o*a,e.w=r*a),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*pn()*Math.PI,i=2*pn()-1,o=Math.sqrt(1-i*i);return e.x=o*Math.cos(n)*t,e.y=o*Math.sin(n)*t,e.z=i*t,e.w=0,e},t.transformMat4=function(e,t,n){var i=t.x,o=t.y,r=t.z,a=t.w;return e.x=n.m00*i+n.m04*o+n.m08*r+n.m12*a,e.y=n.m01*i+n.m05*o+n.m09*r+n.m13*a,e.z=n.m02*i+n.m06*o+n.m10*r+n.m14*a,e.w=n.m03*i+n.m07*o+n.m11*r+n.m15*a,e},t.transformAffine=function(e,t,n){var i=t.x,o=t.y,r=t.z,a=t.w;return e.x=n.m00*i+n.m01*o+n.m02*r+n.m03*a,e.y=n.m04*i+n.m05*o+n.m06*r+n.m07*a,e.x=n.m08*i+n.m09*o+n.m10*r+n.m11*a,e.w=t.w,e},t.transformQuat=function(e,t,n){var i=t.x,o=t.y,r=t.z,a=n.x,s=n.y,c=n.z,l=n.w,u=l*i+s*r-c*o,h=l*o+c*i-a*r,_=l*r+a*o-s*i,f=-a*i-s*o-c*r;return e.x=u*l+f*-a+h*-c-_*-s,e.y=h*l+f*-s+_*-a-u*-c,e.z=_*l+f*-c+u*-s-h*-a,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=sn),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=sn),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,o){return void 0===o&&(o=sn),Math.abs(this.x-e)<=o*Math.max(1,Math.abs(this.x),Math.abs(e))&&Math.abs(this.y-t)<=o*Math.max(1,Math.abs(this.y),Math.abs(t))&&Math.abs(this.z-n)<=o*Math.max(1,Math.abs(this.z),Math.abs(n))&&Math.abs(this.w-i)<=o*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,o=this.z,r=this.w;return this.x=n+t*(e.x-n),this.y=i+t*(e.y-i),this.z=o+t*(e.z-o),this.w=r+t*(e.w-r),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=un(this.x,e.x,t.x),this.y=un(this.y,e.y,t.y),this.z=un(this.z,e.z,t.z),this.w=un(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,o=e.x,r=e.y,a=e.z;return this.x=n*a-i*r,this.y=i*o-t*a,this.z=t*r-n*o,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,o=e*e+t*t+n*n+i*i;return o>0&&(o=1/Math.sqrt(o),this.x=e*o,this.y=t*o,this.z=n*o,this.w=i*o),this},n.transformMat4=function(e){var t=this.x,n=this.y,i=this.z,o=this.w;return this.x=e.m00*t+e.m04*n+e.m08*i+e.m12*o,this.y=e.m01*t+e.m05*n+e.m09*i+e.m13*o,this.z=e.m02*t+e.m06*n+e.m10*i+e.m14*o,this.w=e.m03*t+e.m07*n+e.m11*i+e.m15*o,this},t}(_t));function ei(e,t,n,i){return new $n(e,t,n,i)}$n.ZERO=Object.freeze(new $n(0,0,0,0)),$n.ONE=Object.freeze(new $n(1,1,1,1)),$n.NEG_ONE=Object.freeze(new $n(-1,-1,-1,-1)),tn.fastDefine("cc.Vec4",$n,{x:0,y:0,z:0,w:0}),c.Vec4=$n,c.v4=ei,q(Kn,"Vec2",[{name:"sub",newName:"subtract",target:Kn,targetName:"Vec2"},{name:"mul",newName:"multiply",target:Kn,targetName:"Vec2"},{name:"div",newName:"divide",target:Kn,targetName:"Vec2"},{name:"dist",newName:"distance",target:Kn,targetName:"Vec2"},{name:"sqrDist",newName:"squaredDistance",target:Kn,targetName:"Vec2"},{name:"mag",newName:"len",target:Kn,targetName:"Vec2"},{name:"sqrMag",newName:"lengthSqr",target:Kn,targetName:"Vec2"},{name:"scale",newName:"multiplyScalar",target:Kn,targetName:"Vec2"},{name:"exactEquals",newName:"strictEquals",target:Kn,targetName:"Vec2"}]),q(Kn.prototype,"Vec2",[{name:"mag",newName:"length",target:Kn.prototype,targetName:"Vec2"},{name:"magSqr",newName:"lengthSqr",target:Kn.prototype,targetName:"Vec2"},{name:"scale",newName:"multiplyScalar",target:Kn.prototype,targetName:"Vec2"},{name:"exactEquals",newName:"strictEquals",target:Kn.prototype,targetName:"Vec2"}]),q(Rn,"Vec3",[{name:"sub",newName:"subtract",target:Rn,targetName:"Vec3"},{name:"mul",newName:"multiply",target:Rn,targetName:"Vec3"},{name:"div",newName:"divide",target:Rn,targetName:"Vec3"},{name:"dist",newName:"distance",target:Rn,targetName:"Vec3"},{name:"sqrDist",newName:"squaredDistance",target:Rn,targetName:"Vec3"},{name:"mag",newName:"len",target:Rn,targetName:"Vec3"},{name:"sqrMag",newName:"lengthSqr",target:Rn,targetName:"Vec3"},{name:"scale",newName:"multiplyScalar",target:Rn,targetName:"Vec3"},{name:"exactEquals",newName:"strictEquals",target:Rn,targetName:"Vec3"}]),q(Rn.prototype,"Vec3",[{name:"mag",newName:"length",target:Rn.prototype,targetName:"Vec3"},{name:"magSqr",newName:"lengthSqr",target:Rn.prototype,targetName:"Vec3"},{name:"scale",newName:"multiplyScalar",target:Rn.prototype,targetName:"Vec3"},{name:"exactEquals",newName:"strictEquals",target:Rn.prototype,targetName:"Vec3"}]),q($n,"Vec4",[{name:"sub",newName:"subtract",target:$n,targetName:"Vec4"},{name:"mul",newName:"multiply",target:$n,targetName:"Vec4"},{name:"div",newName:"divide",target:$n,targetName:"Vec4"},{name:"dist",newName:"distance",target:$n,targetName:"Vec4"},{name:"sqrDist",newName:"squaredDistance",target:$n,targetName:"Vec4"},{name:"mag",newName:"len",target:$n,targetName:"Vec4"},{name:"sqrMag",newName:"lengthSqr",target:$n,targetName:"Vec4"},{name:"scale",newName:"multiplyScalar",target:$n,targetName:"Vec4"},{name:"exactEquals",newName:"strictEquals",target:$n,targetName:"Vec4"}]),q($n.prototype,"Vec4",[{name:"mag",newName:"length",target:$n.prototype,targetName:"Vec4"},{name:"magSqr",newName:"lengthSqr",target:$n.prototype,targetName:"Vec4"},{name:"scale",newName:"multiplyScalar",target:$n.prototype,targetName:"Vec4"},{name:"exactEquals",newName:"strictEquals",target:$n.prototype,targetName:"Vec4"}]),q(zn,"Quat",[{name:"mag",newName:"len",target:zn,targetName:"Quat"},{name:"mul",newName:"multiply",target:zn,targetName:"Quat"},{name:"sqrMag",newName:"lengthSqr",target:zn,targetName:"Quat"},{name:"scale",newName:"multiplyScalar",target:zn,targetName:"Quat"},{name:"exactEquals",newName:"strictEquals",target:zn,targetName:"Quat"}]),q(zn.prototype,"Quat",[{name:"scale",newName:"multiplyScalar",target:zn.prototype,targetName:"Quat"},{name:"exactEquals",newName:"strictEquals",target:zn.prototype,targetName:"Quat"}]),q(Pn,"Color",[{name:"sub",newName:"subtract",target:Pn,targetName:"Color"},{name:"mul",newName:"multiply",target:Pn,targetName:"Color"},{name:"div",newName:"divide",target:Pn,targetName:"Color"},{name:"exactEquals",newName:"strictEquals",target:Pn,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 i=t[1].toString(16);return c.Color.fromHEX(t[0],i)}}]),q(Mn,"Mat3",[{name:"sub",newName:"subtract",target:Mn,targetName:"Mat3"},{name:"mul",newName:"multiply",target:Mn,targetName:"Mat3"},{name:"exactEquals",newName:"strictEquals",target:Mn,targetName:"Mat3"},{name:"transfrom",newName:"transform",target:Mn,targetName:"Mat3"}]),q(Mn.prototype,"Mat3",[{name:"sub",newName:"subtract",target:Mn.prototype,targetName:"Mat3"},{name:"mul",newName:"multiply",target:Mn.prototype,targetName:"Mat3"},{name:"mulScalar",newName:"multiplyScalar",target:Mn.prototype,targetName:"Mat3"},{name:"exactEquals",newName:"strictEquals",target:Mn.prototype,targetName:"Mat3"}]),q(jn,"Mat4",[{name:"sub",newName:"subtract",target:jn,targetName:"Mat4"},{name:"mul",newName:"multiply",target:jn,targetName:"Mat4"},{name:"exactEquals",newName:"strictEquals",target:jn,targetName:"Mat4"}]),q(jn.prototype,"Mat4",[{name:"sub",newName:"subtract",target:jn.prototype,targetName:"Mat4"},{name:"mul",newName:"multiply",target:jn.prototype,targetName:"Mat4"},{name:"mulScalar",newName:"multiplyScalar",target:jn.prototype,targetName:"Mat4"},{name:"exactEquals",newName:"strictEquals",target:jn.prototype,targetName:"Mat4"}]);var ti=e("eH",function(){function e(e,t,n,i,o,r){void 0===e&&(e=1),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=1),void 0===o&&(o=0),void 0===r&&(r=0),this.a=e,this.b=t,this.c=n,this.d=i,this.tx=o,this.ty=r}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,o=t.b,r=t.c,a=t.d,s=t.tx,c=t.ty;e.a=i*n.a+o*n.c,e.b=i*n.b+o*n.d,e.c=r*n.a+a*n.c,e.d=r*n.b+a*n.d,e.tx=s*n.a+c*n.c+n.tx,e.ty=s*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 o,r;void 0===i?(i=n,o=t.x,r=t.y):(o=t,r=n),e.x=i.a*o+i.c*r+i.tx,e.y=i.b*o+i.d*r+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,o=t.y+t.height,r=n.a*t.x+n.c*t.y+n.tx,a=n.b*t.x+n.d*t.y+n.ty,s=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*o+n.tx,u=n.b*t.x+n.d*o+n.ty,h=n.a*i+n.c*o+n.tx,_=n.b*i+n.d*o+n.ty,f=Math.min(r,s,l,h),d=Math.max(r,s,l,h),p=Math.min(a,c,u,_),m=Math.max(a,c,u,_);e.x=f,e.y=p,e.width=d-f,e.height=m-p},e.transformObb=function(e,t,n,i,o,r){var a=r.a*o.x+r.c*o.y+r.tx,s=r.b*o.x+r.d*o.y+r.ty,c=r.a*o.width,l=r.b*o.width,u=r.c*o.height,h=r.d*o.height;t.x=a,t.y=s,n.x=c+a,n.y=l+s,e.x=u+a,e.y=h+s,i.x=c+u+a,i.y=l+h+s},e}());c.AffineTransform=ti;var ni=e("cQ",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}ie(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};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)+")"},te(t,[{key:"x",get:function(){return this.width},set:function(e){this.width=e}},{key:"y",get:function(){return this.height},set:function(e){this.height=e}}]),t}(_t));function ii(e,t){return void 0===e&&(e=0),void 0===t&&(t=0),new ni(e,t)}ni.ZERO=Object.freeze(new ni(0,0)),ni.ONE=Object.freeze(new ni(1,1)),tn.fastDefine("cc.Size",ni,{width:0,height:0}),c.size=ii,c.Size=ni;var oi=e("cP",function(e){function t(t,n,i,o){var r;return r=e.call(this)||this,t&&"object"==typeof t?(r.y=t.y,r.width=t.width,r.height=t.height,r.x=t.x):(r.x=t||0,r.y=n||0,r.width=i||0,r.height=o||0),r}ie(t,e),t.fromMinMax=function(e,t,n){var i=Math.min(t.x,n.x),o=Math.min(t.y,n.y),r=Math.max(t.x,n.x),a=Math.max(t.y,n.y);return e.x=i,e.y=o,e.width=r-i,e.height=a-o,e},t.lerp=function(e,t,n,i){var o=t.x,r=t.y,a=t.width,s=t.height;return e.x=o+(n.x-o)*i,e.y=r+(n.y-r)*i,e.width=a+(n.width-a)*i,e.height=s+(n.height-s)*i,e},t.intersection=function(e,t,n){var i=t.x,o=t.y,r=t.x+t.width,a=t.y+t.height,s=n.x,c=n.y,l=n.x+n.width,u=n.y+n.height;return e.x=Math.max(i,s),e.y=Math.max(o,c),e.width=Math.min(r,l)-e.x,e.height=Math.min(a,u)-e.y,e},t.union=function(e,t,n){var i=t.x,o=t.y,r=t.width,a=t.height,s=n.x,c=n.y,l=n.width,u=n.height;return e.x=Math.min(i,s),e.y=Math.min(o,c),e.width=Math.max(i+r,s+l)-e.x,e.height=Math.max(o+a,c+u)-e.y,e};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,o=this.width,r=this.height;return this.x=n+(e.x-n)*t,this.y=i+(e.y-i)*t,this.width=o+(e.width-o)*t,this.height=r+(e.height-r)*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,o=e.y+e.height;return!(t<e.x||i<this.x||n<e.y||o<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,o=n+this.height,r=e.m00*t+e.m04*n+e.m12,a=e.m01*t+e.m05*n+e.m13,s=e.m00*i+e.m04*n+e.m12,c=e.m01*i+e.m05*n+e.m13,l=e.m00*t+e.m04*o+e.m12,u=e.m01*t+e.m05*o+e.m13,h=e.m00*i+e.m04*o+e.m12,_=e.m01*i+e.m05*o+e.m13,f=Math.min(r,s,l,h),d=Math.max(r,s,l,h),p=Math.min(a,c,u,_),m=Math.max(a,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,o){var r=this.x,a=this.y,s=r+this.width,c=a+this.height;t.x=e.m00*r+e.m04*a+e.m12,t.y=e.m01*r+e.m05*a+e.m13,o.x=e.m00*s+e.m04*a+e.m12,o.y=e.m01*s+e.m05*a+e.m13,n.x=e.m00*r+e.m04*c+e.m12,n.y=e.m01*r+e.m05*c+e.m13,i.x=e.m00*s+e.m04*c+e.m12,i.y=e.m01*s+e.m05*c+e.m13},te(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 Kn(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 Kn(this.x,this.y)},set:function(e){this.x=e.x,this.y=e.y}},{key:"size",get:function(){return new ni(this.width,this.height)},set:function(e){this.width=e.width,this.height=e.height}},{key:"z",get:function(){return this.width},set:function(e){this.width=e}},{key:"w",get:function(){return this.height},set:function(e){this.height=e}}]),t}(_t));function ri(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 oi(e,t,n,i)}tn.fastDefine("cc.Rect",oi,{x:0,y:0,width:0,height:0}),c.Rect=oi,c.rect=ri;var ai=Object.freeze({__proto__:null,bits:j,Vec2:Kn,v2:Jn,Vec3:Rn,v3:Dn,Vec4:$n,v4:ei,Quat:zn,quat:kn,Mat3:Mn,Mat4:jn,mat4:Xn,AffineTransform:ti,Size:ni,size:ii,Rect:oi,rect:ri,Color:Pn,color:bn,EPSILON:sn,equals:cn,approx:ln,clamp:un,clamp01:hn,lerp:_n,toRadian:fn,toDegree:dn,random:pn,randomRange:mn,randomRangeInt:vn,pseudoRandom:gn,pseudoRandomRange:yn,pseudoRandomRangeInt:xn,nextPow2:En,repeat:Sn,pingPong:Tn,inverseLerp:An,absMaxComponent:wn,absMax:Cn});e("ez",ai);var si=e("P",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}()),ci=e("R",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}},te(e,[{key:"length",get:function(){return this._count}},{key:"data",get:function(){return this._data}}]),e}()),li=e("C",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}()),ui=[],hi=e("d5",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=ui.length,t=0;t<e;++t){var n=ui[t];1&n._objFlags||n._destroyImmediate()}e===ui.length?ui.length=0:ui.splice(0,e)};var t=e.prototype;return t.destroy=function(){return 1&this._objFlags?(b(5e3),!1):!(4&this._objFlags||(this._objFlags|=4,ui.push(this),0))},t._destruct=function(){var e=this.constructor,t=e.__destruct__;t||(t=function(e,t){var n,i=e instanceof c._BaseNode||e instanceof c.Component,o=i?"_id":null,r={};for(n in e)if(e.hasOwnProperty(n)){if(n===o)continue;switch(typeof e[n]){case"string":r[n]="";break;case"object":case"function":r[n]=null}}if(tn._isCCClass(t))for(var a=c.Class.Attr.getClassAttrs(t),s=t.__props__,l=0;l<s.length;l++){var u=(n=s[l])+c.Class.Attr.DELIMETER+"default";if(u in a){if(i&&"_id"===n)continue;switch(typeof a[u]){case"string":r[n]="";break;case"object":case"function":r[n]=null;break;case"undefined":r[n]=void 0}}}var h="";for(n in r){var _;_=tn.IDENTIFIER_RE.test(n)?"o."+n+"=":"o["+tn.escapeForJS(n)+"]=";var f=r[n];""===f&&(f='""'),h+=_+f+";\n"}return Function("o",h)}(this,e),Ce(e,"__destruct__",t,!0)),t(this)},t._destroyImmediate=function(){1&this._objFlags?N(5e3):(this._onPreDestroy&&this._onPreDestroy(),this._destruct(),this._objFlags|=1)},te(e,[{key:"name",get:function(){return this._name},set:function(e){this._name=e}},{key:"hideFlags",get:function(){return this._objFlags&e.Flags.AllHideMasks},set:function(t){var n=t&e.Flags.AllHideMasks;this._objFlags=this._objFlags&~e.Flags.AllHideMasks|n}},{key:"isValid",get:function(){return!(1&this._objFlags)}}]),e}()),_i=hi.prototype;function fi(e,t){return"object"==typeof e?!(!e||e._objFlags&(t?5:1)):void 0!==e}_i._deserialize=null,_i._onPreDestroy=null,tn.fastDefine("cc.Object",hi,{_name:"",_objFlags:0}),Ce(hi,"Flags",{Destroyed:1,DontSave:8,EditorOnly:16,Dirty:32,DontDestroy:64,PersistentMask:-4192741,Destroying:128,Deactivating:256,LockedInEditor:512,HideInHierarchy:1024,AllHideMasks:1560,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}),c.isValid=fi,c.Object=hi;var di=rt.fastRemoveAt;function pi(){}var mi=function(){function e(){this.callback=pi,this.target=void 0,this.once=!1}var t=e.prototype;return t.set=function(e,t,n){this.callback=e||pi,this.target=t,this.once=!!n},t.reset=function(){this.target=void 0,this.callback=pi,this.once=!1},t.check=function(){return!(this.target instanceof hi&&!fi(this.target,!0))},e}(),vi=new si((function(){return new mi}),32),gi=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(),vi.free(n),di(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(),vi.free(n),di(this.callbackInfos,t),--t)}},t.cancel=function(e){var t=this.callbackInfos[e];t&&(t.reset(),this.isInvoking?this.callbackInfos[e]=null:di(this.callbackInfos,e),vi.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(),vi.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]||di(this.callbackInfos,e);this.containCanceled=!1},t.clear=function(){this.cancelAll(),this.callbackInfos.length=0,this.isInvoking=!1,this.containCanceled=!1},e}(),yi=new si((function(){return new gi}),16),xi=function(){function e(){this._callbackTable=Re(!0)}var t=e.prototype;return t.on=function(e,t,n,i){if(!this.hasEventListener(e,t,n)){var o=this._callbackTable[e];o||(o=this._callbackTable[e]=yi.alloc());var r=vi.alloc();r.set(t,n,i),o.callbackInfos.push(r)}return t},t.hasEventListener=function(e,t,n){var i=this._callbackTable&&this._callbackTable[e];if(!i)return!1;var o=i.callbackInfos;if(!t){if(i.isInvoking){for(var r=0;r<o.length;++r)if(o[r])return!0;return!1}return o.length>0}for(var a=0;a<o.length;++a){var s=o[a];if(s&&s.check()&&s.callback===t&&s.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(),yi.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 o=i.callbackInfos,r=0;r<o.length;++r){var a=o[r];a&&a.target===e&&i.cancel(r)}else i.removeByTarget(e)}},t.off=function(e,t,n){var i=this._callbackTable&&this._callbackTable[e];if(i){var o=i.callbackInfos;if(t)for(var r=0;r<o.length;++r){var a=o[r];if(a&&a.callback===t&&a.target===n){i.cancel(r);break}}else this.removeAll(e)}},t.emit=function(e,t,n,i,o,r){var a=this._callbackTable&&this._callbackTable[e];if(a){var s=!a.isInvoking;a.isInvoking=!0;for(var c=a.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,o,r):_(t,n,i,o,r):this.off(e,_,f)}}s&&(a.isInvoking=!1,a.containCanceled&&a.purgeCanceled())}},t.clear=function(){for(var e in this._callbackTable){var t=this._callbackTable[e];t&&(t.clear(),yi.free(t),delete this._callbackTable[e])}},e}();function Ei(e){for(var t=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return(t=e.call.apply(e,[this].concat(i))||this)._callbackTable=Re(!0),t}ie(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=xi.prototype,i=Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n)),o=0;o<i.length;++o){var r=i[o];if(!(r in t.prototype)){var a=Object.getOwnPropertyDescriptor(n,r);a&&Object.defineProperty(t.prototype,r,a)}}return t}var Si,Ti,Ai,wi,Ci,Ii,Pi,bi=e("ek",Ei((function(){})));c.EventTarget=bi,function(e){e.UNKNOWN="unknown",e.WECHAT="wechat",e.ANDROID="androidbrowser",e.IE="ie",e.EDGE="edge",e.QQ="qqbrowser",e.MOBILE_QQ="mqqbrowser",e.UC="ucbrowser",e.UCBS="ucbs",e.BROWSER_360="360browser",e.BAIDU_APP="baiduboxapp",e.BAIDU="baidubrowser",e.MAXTHON="maxthon",e.OPERA="opera",e.OUPENG="oupeng",e.MIUI="miuibrowser",e.FIREFOX="firefox",e.SAFARI="safari",e.CHROME="chrome",e.LIEBAO="liebao",e.QZONE="qzone",e.SOUGOU="sogou",e.HUAWEI="huawei"}(Si||(Si=e("bs",{}))),function(e){e.HIDE="hide",e.SHOW="show",e.RESIZE="resize",e.ORIENTATION_CHANGE="orientation_change"}(Ti||(Ti={})),function(e){e.UNKNOWN="unknown",e.ENGLISH="en",e.CHINESE="zh",e.FRENCH="fr",e.ITALIAN="it",e.GERMAN="de",e.SPANISH="es",e.DUTCH="du",e.RUSSIAN="ru",e.KOREAN="ko",e.JAPANESE="ja",e.HUNGARIAN="hu",e.PORTUGUESE="pt",e.ARABIC="ar",e.NORWEGIAN="no",e.POLISH="pl",e.TURKISH="tr",e.UKRAINIAN="uk",e.ROMANIAN="ro",e.BULGARIAN="bg"}(Ai||(Ai={})),function(e){e[e.NONE=0]="NONE",e[e.LAN=1]="LAN",e[e.WWAN=2]="WWAN"}(wi||(wi={})),function(e){e.UNKNOWN="Unknown",e.IOS="iOS",e.ANDROID="Android",e.WINDOWS="Windows",e.LINUX="Linux",e.OSX="OS X",e.OHOS="OHOS"}(Ci||(Ci=e("bq",{}))),function(e){e[e.PORTRAIT=1]="PORTRAIT",e[e.PORTRAIT_UPSIDE_DOWN=2]="PORTRAIT_UPSIDE_DOWN",e[e.LANDSCAPE_LEFT=4]="LANDSCAPE_LEFT",e[e.LANDSCAPE_RIGHT=8]="LANDSCAPE_RIGHT",e[e.LANDSCAPE=12]="LANDSCAPE"}(Ii||(Ii={})),function(e){e.UNKNOWN="UNKNOWN",e.EDITOR_PAGE="EDITOR_PAGE",e.EDITOR_CORE="EDITOR_CORE",e.MOBILE_BROWSER="MOBILE_BROWSER",e.DESKTOP_BROWSER="DESKTOP_BROWSER",e.WIN32="WIN32",e.ANDROID="ANDROID",e.IOS="IOS",e.MACOS="MACOS",e.OHOS="OHOS",e.WECHAT_GAME="WECHAT_GAME",e.BAIDU_MINI_GAME="BAIDU_MINI_GAME",e.XIAOMI_QUICK_GAME="XIAOMI_QUICK_GAME",e.ALIPAY_MINI_GAME="ALIPAY_MINI_GAME",e.BYTEDANCE_MINI_GAME="BYTEDANCE_MINI_GAME",e.OPPO_MINI_GAME="OPPO_MINI_GAME",e.VIVO_MINI_GAME="VIVO_MINI_GAME",e.HUAWEI_QUICK_GAME="HUAWEI_QUICK_GAME",e.COCOSPLAY="COCOSPLAY",e.LINKSURE_MINI_GAME="LINKSURE_MINI_GAME",e.QTT_MINI_GAME="QTT_MINI_GAME"}(Pi||(Pi={}));var Ri=function(){function e(){var e,t=this;this.networkType=void 0,this.isNative=void 0,this.isBrowser=void 0,this.isMobile=void 0,this.isLittleEndian=void 0,this.platform=void 0,this.language=void 0,this.nativeLanguage=void 0,this.os=void 0,this.osVersion=void 0,this.osMainVersion=void 0,this.browserType=void 0,this.browserVersion=void 0,this.pixelRatio=void 0,this.supportCapability=void 0,this._eventTarget=new bi,this._html=void 0,this._battery=void 0;var n,i=window.navigator,o=i.userAgent.toLowerCase();this._html=document.getElementsByTagName("html")[0],null===(e=i.getBattery)||void 0===e||e.call(i).then((function(e){t._battery=e})),this.networkType=wi.LAN,this.isNative=!1,this.isBrowser=!0,this.isMobile=/mobile|android|iphone|ipad/.test(o),this.platform=this.isMobile?Pi.MOBILE_BROWSER:Pi.DESKTOP_BROWSER,this.isLittleEndian=(n=new ArrayBuffer(2),new DataView(n).setInt16(0,256,!0),256===new Int16Array(n)[0]);var r=i.language;this.nativeLanguage=r.toLowerCase(),r=(r=r||i.browserLanguage)?r.split("-")[0]:Ai.ENGLISH,this.language=r;var a=!1,s=!1,c="",l=0,u=/android\s*(\d+(?:\.\d+)*)/i.exec(o)||/android\s*(\d+(?:\.\d+)*)/i.exec(i.platform);u&&(a=!0,c=u[1]||"",l=parseInt(c)||0),(u=/(iPad|iPhone|iPod).*OS ((\d+_?){2,3})/i.exec(o))?(s=!0,c=u[2]||"",l=parseInt(c)||0):(/(iPhone|iPad|iPod)/.exec(i.platform)||"MacIntel"===i.platform&&i.maxTouchPoints&&i.maxTouchPoints>1)&&(s=!0,c="",l=0);var h=Ci.UNKNOWN;-1!==i.appVersion.indexOf("Win")?h=Ci.WINDOWS:s?h=Ci.IOS:-1!==i.appVersion.indexOf("Mac")?h=Ci.OSX:-1!==i.appVersion.indexOf("X11")&&-1===i.appVersion.indexOf("Linux")?h=Ci.LINUX:a?h=Ci.ANDROID:-1===i.appVersion.indexOf("Linux")&&-1===o.indexOf("ubuntu")||(h=Ci.LINUX),this.os=h,this.osVersion=c,this.osMainVersion=l,this.browserType=Si.UNKNOWN;var _=/wechat|weixin|micromessenger/i.exec(o)||/mqqbrowser|micromessenger|qqbrowser|sogou|qzone|liebao|maxthon|ucbs|360 aphone|360browser|baiduboxapp|baidubrowser|maxthon|mxbrowser|miuibrowser/i.exec(o)||/qq|qqbrowser|ucbrowser|ubrowser|edge|HuaweiBrowser/i.exec(o)||/chrome|safari|firefox|trident|opera|opr\/|oupeng/i.exec(o),f=_?_[0].toLowerCase():Ci.UNKNOWN;("safari"===f&&a||"qq"===f&&/android.*applewebkit/i.test(o))&&(f=Si.ANDROID);var d={micromessenger:Si.WECHAT,wechat:Si.WECHAT,weixin:Si.WECHAT,trident:Si.IE,edge:Si.EDGE,"360 aphone":Si.BROWSER_360,mxbrowser:Si.MAXTHON,"opr/":Si.OPERA,ubrowser:Si.UC,huaweibrowser:Si.HUAWEI};this.browserType=d[f]||f,this.browserVersion="";var p=/(mqqbrowser|micromessenger|qqbrowser|sogou|qzone|liebao|maxthon|uc|ucbs|360 aphone|360|baiduboxapp|baidu|maxthon|mxbrowser|miui(?:.hybrid)?)(mobile)?(browser)?\/?([\d.]+)/i.exec(o);p||(p=/(qq|chrome|safari|firefox|trident|opera|opr\/|oupeng)(mobile)?(browser)?\/?([\d.]+)/i.exec(o)),this.browserVersion=p?p[4]:"",this.pixelRatio=window.devicePixelRatio||1;var m,v=document.createElement("canvas"),g=!!v.getContext("2d"),y=!1;window.WebGLRenderingContext&&(y=!0);try{m=v.toDataURL("image/webp").startsWith("data:image/webp")}catch(e){m=!1}var x=!1;"undefined"!=typeof createImageBitmap&&"undefined"!=typeof Blob&&(v.width=v.height=2,createImageBitmap(v,{}).then((function(e){x=!0,null==e||e.close()})).catch((function(){}))),this.supportCapability={webp:m,gl:y,canvas:g,imageBitmap:x},this._registerEvent()}var t=e.prototype;return t._registerEvent=function(){var e=this;window.addEventListener("resize",(function(){e._eventTarget.emit(Ti.RESIZE)})),window.addEventListener("orientationchange",(function(){e._eventTarget.emit(Ti.ORIENTATION_CHANGE)})),this._registerVisibilityEvent()},t._registerVisibilityEvent=function(){var e,t=this;e=void 0!==document.hidden?"hidden":void 0!==document.mozHidden?"mozHidden":void 0!==document.msHidden?"msHidden":void 0!==document.webkitHidden?"webkitHidden":"hidden";var n=!1,i=function(){n||(n=!0,t._eventTarget.emit(Ti.HIDE))},o=function(e,i,o,r,a){n&&(n=!1,t._eventTarget.emit(Ti.SHOW,e,i,o,r,a))};if(e)for(var r=["visibilitychange","mozvisibilitychange","msvisibilitychange","webkitvisibilitychange","qbrowserVisibilityChange"],a=0;a<r.length;a++)document.addEventListener(r[a],(function(t){var n=document[e];(n=n||t.hidden)?i():o()}));else window.addEventListener("blur",i),window.addEventListener("focus",o);window.navigator.userAgent.indexOf("MicroMessenger")>-1&&(window.onfocus=o),"onpageshow"in window&&"onpagehide"in window&&(window.addEventListener("pagehide",i),window.addEventListener("pageshow",o),document.addEventListener("pagehide",i),document.addEventListener("pageshow",o))},t.getViewSize=function(){var e=document.getElementById("GameDiv");return this.isMobile||!e||e===this._html?new ni(window.innerWidth,window.innerHeight):new ni(e.clientWidth,e.clientHeight)},t.getOrientation=function(){throw new Error("TODO")},t.getSafeAreaEdge=function(){return{top:0,bottom:0,left:0,right:0}},t.getBatteryLevel=function(){return this._battery?this._battery.level:1},t.triggerGC=function(){},t.openURL=function(e){window.open(e)},t.now=function(){return Date.now?Date.now():+new Date},t.restartJSVM=function(){},t.onHide=function(e){this._eventTarget.on(Ti.HIDE,e)},t.onShow=function(e){this._eventTarget.on(Ti.SHOW,e)},t.onViewResize=function(e){this._eventTarget.on(Ti.RESIZE,e)},t.onOrientationChange=function(e){this._eventTarget.on(Ti.ORIENTATION_CHANGE,e)},t.offHide=function(e){this._eventTarget.off(Ti.HIDE,e)},t.offShow=function(e){this._eventTarget.off(Ti.SHOW,e)},t.offViewResize=function(e){this._eventTarget.off(Ti.RESIZE,e)},t.offOrientationChange=function(e){this._eventTarget.off(Ti.ORIENTATION_CHANGE,e)},e}(),Ni=e("bp",new Ri),Oi=/(\.[^\.\/\?\\]*)(\?.*)?$/,Di=/((.*)(\/|\\|\\\\))?(.*?\..*$)?/,Mi=/[^\.\/]+\/\.\.\//;function Li(){for(var e="",t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];for(var o=0,r=n;o<r.length;o++){var a=r[o];e=(e+(""===e?"":"/")+a).replace(/(\/|\\\\)$/,"")}return e}function Fi(e){var t=Oi.exec(e);return t?t[1]:""}function zi(e){if(e){var t=e.lastIndexOf(".");if(-1!==t)return e.substring(0,t)}return e}function Bi(e,t){var n=e.indexOf("?");n>0&&(e=e.substring(0,n));var i=/(\/|\\)([^\/\\]+)$/g.exec(e.replace(/(\/|\\)$/,""));if(!i)return e;var o=i[2];return t&&e.substring(e.length-t.length).toLowerCase()===t.toLowerCase()?o.substring(0,o.length-t.length):o}function Ui(e){var t=Di.exec(e);return t?t[2]:""}function Hi(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 Gi(e,t,n){if(0===t.indexOf("."))return Hi(e,t);var i=e.indexOf("?"),o="",r=n?Fi(e):"";return i>0&&(o=e.substring(i),e=e.substring(0,i)),i=(i=e.lastIndexOf("/"))<=0?0:i+1,e.substring(0,i)+t+r+o}function Vi(e){var t=e=String(e);do{t=e,e=e.replace(Mi,"")}while(t.length!==e.length);return e}function ki(e){return e.replace(/[\/\\]$/,"")}function Wi(){return Ni.os===Ci.WINDOWS?"\\":"/"}e("eW",Object.freeze({__proto__:null,join:Li,extname:Fi,mainFileName:zi,basename:Bi,dirname:Ui,changeExtname:Hi,changeBasename:Gi,_normalize:Vi,stripSep:ki,getSeperator:Wi})),c.log=g,c.warn=y,c.error=x,c.assert=E,c._throw=A,c.logID=I,c.warnID=b,c.errorID=N,c.assertID=M,c.debug=B,c.path={join:Li,extname:Fi,mainFileName:zi,basename:Bi,dirname:Ui,changeExtname:Hi,changeBasename:Gi,_normalize:Vi,stripSep:ki,get sep(){return Wi()}};var ji,qi,Yi,Xi,Ki,Qi,Zi,Ji,$i,eo,to,no,io,oo,ro,ao,so,co,lo,uo,ho,_o,fo,po,mo,vo=0,go={},yo=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}(),xo=function(){function e(){}return e.prototype.bind=function(){},e}(),Eo=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"}(mo||(mo={}));var So,To=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 yo(e,i,this._stride);var o=mo.NEVER,r=!1,a=!1;for(var s in t){if(r=this._hasFloat32,(a=this._hasUint32)&&r)break;o=t[s],r||o!==mo.FLOAT32?a||o!==mo.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(),o=[],r=[],a=[],s=this._hasFloat32,c=this._hasUint32,l=0;l<this._entriesPerChunk;l++)s&&o.push(new Float32Array(i,this._stride*l,this._elementCount)),c&&r.push(new Uint32Array(i,this._stride*l,this._elementCount)),l&&a.push(l);return this._arrayBuffers.push(i),c&&this._uint32BufferViews.push(r),s&&this._float32BufferViews.push(o),this._freelists.push(a),(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]===mo.UINT32?this._uint32BufferViews:this._float32BufferViews)[n][i][t]},t.set=function(e,t,n){var i=(this._chunkMask&e)>>this._entryBits,o=this._entryMask&e;(this._dataType[t]===mo.UINT32?this._uint32BufferViews:this._float32BufferViews)[i][o][t]=n},t.setVec2=function(){},t.setVec3=function(){},t.getVec3=function(){},t.setVec4=function(){},t.getVec4=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}(),Ao=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 xo(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,o=-1;if(i.length)o=i[i.length-1],i.length--,this._array[o]=this._ctor(arguments,this._array[o]);else{o=this._array.length;var r=this._ctor(arguments);if(!r)return 0;this._array.push(r)}return o+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}(),wo=function(){function e(e){this._nativeBufferAllocator=void 0,this._buffers=new Map,this._nextBufferIdx=0,this._poolFlag=void 0,this._bufferIdxMask=void 0,this._freelist=[],this._poolFlag=1<<30,this._bufferIdxMask=~this._poolFlag,this._nativeBufferAllocator=new Eo(e)}var t=e.prototype;return t.alloc=function(e){var t=this._freelist,n=-1;t.length?(n=t[t.length-1],t.length--):n=this._nextBufferIdx++;var i=this._nativeBufferAllocator.alloc(n,e);return this._buffers.set(n,i),n|this._poolFlag},t.free=function(e){var t=this._bufferIdxMask&e;this._buffers.get(t)&&(this._nativeBufferAllocator.free(t),this._buffers.delete(t),this._freelist.push(t))},t.getBuffer=function(e){var t=this._bufferIdxMask&e;return this._buffers.get(t)||null},e}(),Co=function(e){function t(t,n,i,o){var r;return(r=e.call(this,t)||this)._viewCtor=void 0,r._size=void 0,r._step=void 0,r._viewCtor=n,r._size=i*n.BYTES_PER_ELEMENT,r._step=o||i,r}ie(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,o=this._buffers.get(i);if(o){var r=t+1;if(r>=o.length){for(var a=o.length;r>=a;)a+=this._step;a*=this._viewCtor.BYTES_PER_ELEMENT;var s=new this._viewCtor(this._nativeBufferAllocator.alloc(i,a));s.set(o),o=s,this._buffers.set(i,o)}o[r]=n;var c=o[0];o[0]=r>c?r:c}},n.erase=function(e,t){var n=this._bufferIdxMask&e,i=this._buffers.get(n);if(i&&!(t>=i[0])){for(var o=t+1;o<i[0];++o)i[o]=i[o+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}(wo);function Io(e,t,n,i){void 0===i&&(i=!0);for(var o=t.length(e),r=0;r<o;r++){var a=t.get(e,r);a&&n.free(a)}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.PIPELINE_SCENE_DATA=124]="PIPELINE_SCENE_DATA",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"}(So||(So={}));var Po,bo=e("dk",0),Ro=new Ao(So.SHADER,(function(e,t){return t?(t.initialize(e[1]),t):e[0].createShader(e[1])}),(function(e){return e&&e.destroy(),e})),No=e("dw",new Ao(So.DESCRIPTOR_SETS,(function(e,t){return t?(t.initialize(e[1]),t):e[0].createDescriptorSet(e[1])}),(function(e){return e&&e.destroy(),e}))),Oo=e("dj",new Ao(So.INPUT_ASSEMBLER,(function(e,t){return t?(t.initialize(e[1]),t):e[0].createInputAssembler(e[1])}),(function(e){return e&&e.destroy(),e}))),Do=new Ao(So.PIPELINE_LAYOUT,(function(e,t){return t?(t.initialize(e[1]),t):e[0].createPipelineLayout(e[1])}),(function(e){return e&&e.destroy(),e})),Mo=new Ao(So.FRAMEBUFFER,(function(e,t){return t?(t.initialize(e[1]),t):e[0].createFramebuffer(e[1])}),(function(e){return e&&e.destroy(),e})),Lo=new Co(So.SUB_MODEL_ARRAY,Uint32Array,8,4),Fo=new Co(So.MODEL_ARRAY,Uint32Array,32,16),zo=new Co(So.ATTRIBUTE_ARRAY,Uint32Array,8,4),Bo=new Co(So.FLAT_BUFFER_ARRAY,Uint32Array,8,4),Uo=new Co(So.LIGHT_ARRAY,Uint32Array,8,4),Ho=new Co(So.BLEND_TARGET_ARRAY,Uint32Array,8,4),Go=new Co(So.BATCH_ARRAY_2D,Uint32Array,32,16),Vo=new wo(So.RAW_BUFFER),ko=new Ao(So.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"}(Po||(Po={}));var Wo,jo=((ji={})[Po.PRIORITY]=mo.UINT32,ji[Po.STAGE]=mo.UINT32,ji[Po.PHASE]=mo.UINT32,ji[Po.BATCHING_SCHEME]=mo.UINT32,ji[Po.PRIMITIVE]=mo.UINT32,ji[Po.DYNAMIC_STATES]=mo.UINT32,ji[Po.HASH]=mo.UINT32,ji[Po.RASTERIZER_STATE]=mo.UINT32,ji[Po.DEPTH_STENCIL_STATE]=mo.UINT32,ji[Po.BLEND_STATE]=mo.UINT32,ji[Po.DESCRIPTOR_SET]=mo.UINT32,ji[Po.PIPELINE_LAYOUT]=mo.UINT32,ji[Po.COUNT]=mo.NEVER,ji),qo=e("dq",new To(So.PASS,jo,Po));!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.PASS_4=6]="PASS_4",e[e.PASS_5=7]="PASS_5",e[e.PASS_6=8]="PASS_6",e[e.PASS_7=9]="PASS_7",e[e.SHADER_0=10]="SHADER_0",e[e.SHADER_1=11]="SHADER_1",e[e.SHADER_2=12]="SHADER_2",e[e.SHADER_3=13]="SHADER_3",e[e.SHADER_4=14]="SHADER_4",e[e.SHADER_5=15]="SHADER_5",e[e.SHADER_6=16]="SHADER_6",e[e.SHADER_7=17]="SHADER_7",e[e.PLANAR_SHADER=18]="PLANAR_SHADER",e[e.PLANAR_INSTANCE_SHADER=19]="PLANAR_INSTANCE_SHADER",e[e.DESCRIPTOR_SET=20]="DESCRIPTOR_SET",e[e.INPUT_ASSEMBLER=21]="INPUT_ASSEMBLER",e[e.SUB_MESH=22]="SUB_MESH",e[e.COUNT=23]="COUNT"}(Wo||(Wo=e("dv",{})));var Yo,Xo=((qi={})[Wo.PRIORITY]=mo.UINT32,qi[Wo.PASS_COUNT]=mo.UINT32,qi[Wo.PASS_0]=mo.UINT32,qi[Wo.PASS_1]=mo.UINT32,qi[Wo.PASS_2]=mo.UINT32,qi[Wo.PASS_3]=mo.UINT32,qi[Wo.PASS_4]=mo.UINT32,qi[Wo.PASS_5]=mo.UINT32,qi[Wo.PASS_6]=mo.UINT32,qi[Wo.PASS_7]=mo.UINT32,qi[Wo.SHADER_0]=mo.UINT32,qi[Wo.SHADER_1]=mo.UINT32,qi[Wo.SHADER_2]=mo.UINT32,qi[Wo.SHADER_3]=mo.UINT32,qi[Wo.SHADER_4]=mo.UINT32,qi[Wo.SHADER_5]=mo.UINT32,qi[Wo.SHADER_6]=mo.UINT32,qi[Wo.SHADER_7]=mo.UINT32,qi[Wo.PLANAR_SHADER]=mo.UINT32,qi[Wo.PLANAR_INSTANCE_SHADER]=mo.UINT32,qi[Wo.DESCRIPTOR_SET]=mo.UINT32,qi[Wo.INPUT_ASSEMBLER]=mo.UINT32,qi[Wo.SUB_MESH]=mo.UINT32,qi[Wo.COUNT]=mo.NEVER,qi),Ko=e("du",new To(So.SUB_MODEL,Xo,Wo));!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"}(Yo||(Yo={}));var Qo,Zo=((Yi={})[Yo.ENABLED]=mo.UINT32,Yi[Yo.VIS_FLAGS]=mo.UINT32,Yi[Yo.CAST_SHADOW]=mo.UINT32,Yi[Yo.RECEIVE_SHADOW]=mo.UINT32,Yi[Yo.WORLD_BOUNDS]=mo.UINT32,Yi[Yo.NODE]=mo.UINT32,Yi[Yo.TRANSFORM]=mo.UINT32,Yi[Yo.SUB_MODEL_ARRAY]=mo.UINT32,Yi[Yo.INSTANCED_BUFFER]=mo.UINT32,Yi[Yo.INSTANCED_ATTR_ARRAY]=mo.UINT32,Yi[Yo.COUNT]=mo.NEVER,Yi),Jo=new To(So.MODEL,Zo,Yo);!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"}(Qo||(Qo=e("dn",{})));var $o,er=((Xi={})[Qo.VIS_FLAGS]=mo.UINT32,Xi[Qo.PASS_COUNT]=mo.UINT32,Xi[Qo.PASS_0]=mo.UINT32,Xi[Qo.PASS_1]=mo.UINT32,Xi[Qo.PASS_2]=mo.UINT32,Xi[Qo.PASS_3]=mo.UINT32,Xi[Qo.SHADER_0]=mo.UINT32,Xi[Qo.SHADER_1]=mo.UINT32,Xi[Qo.SHADER_2]=mo.UINT32,Xi[Qo.SHADER_3]=mo.UINT32,Xi[Qo.DESCRIPTOR_SET]=mo.UINT32,Xi[Qo.INPUT_ASSEMBLER]=mo.UINT32,Xi[Qo.COUNT]=mo.NEVER,Xi),tr=e("dm",new To(So.BATCH_2D,er,Qo));!function(e){e[e.CENTER=0]="CENTER",e[e.HALF_EXTENSION=3]="HALF_EXTENSION",e[e.COUNT=6]="COUNT"}($o||($o=e("cB",{})));var nr,ir=((Ki={})[$o.CENTER]=mo.FLOAT32,Ki[$o.HALF_EXTENSION]=mo.FLOAT32,Ki[$o.COUNT]=mo.NEVER,Ki),or=e("cA",new To(So.AABB,ir,$o));!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"}(nr||(nr={}));var rr,ar=((Qi={})[nr.MAIN_LIGHT]=mo.UINT32,Qi[nr.MODEL_ARRAY]=mo.UINT32,Qi[nr.SPHERE_LIGHT_ARRAY]=mo.UINT32,Qi[nr.SPOT_LIGHT_ARRAY]=mo.UINT32,Qi[nr.BATCH_ARRAY_2D]=mo.UINT32,Qi[nr.COUNT]=mo.NEVER,Qi),sr=new To(So.SCENE,ar,nr);!function(e){e[e.WIDTH=0]="WIDTH",e[e.HEIGHT=1]="HEIGHT",e[e.EXPOSURE=2]="EXPOSURE",e[e.CLEAR_FLAGS=3]="CLEAR_FLAGS",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.MAT_VIEW_PROJ_OFFSCREEN=105]="MAT_VIEW_PROJ_OFFSCREEN",e[e.MAT_VIEW_PROJ_INV_OFFSCREEN=121]="MAT_VIEW_PROJ_INV_OFFSCREEN",e[e.MAT_PROJ_OFFSCREEN=137]="MAT_PROJ_OFFSCREEN",e[e.MAT_PROJ_INV_OFFSCREEN=153]="MAT_PROJ_INV_OFFSCREEN",e[e.COUNT=169]="COUNT"}(rr||(rr={}));var cr,lr=((Zi={})[rr.WIDTH]=mo.UINT32,Zi[rr.HEIGHT]=mo.UINT32,Zi[rr.EXPOSURE]=mo.FLOAT32,Zi[rr.CLEAR_FLAGS]=mo.UINT32,Zi[rr.CLEAR_DEPTH]=mo.FLOAT32,Zi[rr.CLEAR_STENCIL]=mo.UINT32,Zi[rr.VISIBILITY]=mo.UINT32,Zi[rr.NODE]=mo.UINT32,Zi[rr.SCENE]=mo.UINT32,Zi[rr.FRUSTUM]=mo.UINT32,Zi[rr.WINDOW]=mo.UINT32,Zi[rr.FORWARD]=mo.FLOAT32,Zi[rr.POSITION]=mo.FLOAT32,Zi[rr.VIEW_PORT]=mo.FLOAT32,Zi[rr.CLEAR_COLOR]=mo.FLOAT32,Zi[rr.MAT_VIEW]=mo.FLOAT32,Zi[rr.MAT_VIEW_PROJ]=mo.FLOAT32,Zi[rr.MAT_VIEW_PROJ_INV]=mo.FLOAT32,Zi[rr.MAT_PROJ]=mo.FLOAT32,Zi[rr.MAT_PROJ_INV]=mo.FLOAT32,Zi[rr.MAT_VIEW_PROJ_OFFSCREEN]=mo.FLOAT32,Zi[rr.MAT_VIEW_PROJ_INV_OFFSCREEN]=mo.FLOAT32,Zi[rr.MAT_PROJ_OFFSCREEN]=mo.FLOAT32,Zi[rr.MAT_PROJ_INV_OFFSCREEN]=mo.FLOAT32,Zi[rr.COUNT]=mo.NEVER,Zi),ur=new To(So.CAMERA,lr,rr);!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"}(cr||(cr={}));var hr=((Ji={})[cr.FLAGS_CHANGED]=mo.UINT32,Ji[cr.LAYER]=mo.UINT32,Ji[cr.WORLD_SCALE]=mo.FLOAT32,Ji[cr.WORLD_POSITION]=mo.FLOAT32,Ji[cr.WORLD_ROTATION]=mo.FLOAT32,Ji[cr.WORLD_MATRIX]=mo.FLOAT32,Ji[cr.COUNT]=mo.NEVER,Ji);delete cr[cr.COUNT],cr[cr.COUNT=cr.LAYER+1]="COUNT";var _r,fr=new To(So.NODE,hr,cr);!function(e){e[e.CUMULATIVE_TIME=0]="CUMULATIVE_TIME",e[e.FRAME_TIME=1]="FRAME_TIME",e[e.COUNT=2]="COUNT"}(_r||(_r={}));var dr,pr=(($i={})[_r.CUMULATIVE_TIME]=mo.FLOAT32,$i[_r.FRAME_TIME]=mo.FLOAT32,$i[_r.COUNT]=mo.NEVER,$i),mr=new To(So.ROOT,pr,_r,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"}(dr||(dr={}));var vr,gr=((eo={})[dr.HAS_ON_SCREEN_ATTACHMENTS]=mo.UINT32,eo[dr.HAS_OFF_SCREEN_ATTACHMENTS]=mo.UINT32,eo[dr.FRAMEBUFFER]=mo.UINT32,eo[dr.COUNT]=mo.NEVER,eo),yr=new To(So.RENDER_WINDOW,gr,dr,2);!function(e){e[e.VERTICES=0]="VERTICES",e[e.PLANES=24]="PLANES",e[e.COUNT=48]="COUNT"}(vr||(vr={}));var xr,Er=((to={})[vr.VERTICES]=mo.FLOAT32,to[vr.PLANES]=mo.FLOAT32,to[vr.COUNT]=mo.NEVER,to),Sr=new To(So.FRUSTUM,Er,vr);!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"}(xr||(xr={}));var Tr=((no={})[xr.ENABLE]=mo.UINT32,no[xr.ILLUM]=mo.FLOAT32,no[xr.SKY_COLOR]=mo.FLOAT32,no[xr.GROUND_ALBEDO]=mo.FLOAT32,no[xr.COUNT]=mo.NEVER,no);delete xr[xr.COUNT],xr[xr.COUNT=xr.ILLUM+1]="COUNT";var Ar,wr=new To(So.AMBIENT,Tr,xr,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"}(Ar||(Ar={}));var Cr,Ir=((io={})[Ar.ENABLE]=mo.UINT32,io[Ar.IS_RGBE]=mo.UINT32,io[Ar.USE_IBL]=mo.UINT32,io[Ar.MODEL]=mo.UINT32,io[Ar.COUNT]=mo.NEVER,io),Pr=new To(So.SKYBOX,Ir,Ar,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"}(Cr||(Cr={}));var br=((oo={})[Cr.ENABLE]=mo.UINT32,oo[Cr.TYPE]=mo.UINT32,oo[Cr.DENSITY]=mo.FLOAT32,oo[Cr.START]=mo.FLOAT32,oo[Cr.END]=mo.FLOAT32,oo[Cr.ATTEN]=mo.FLOAT32,oo[Cr.TOP]=mo.FLOAT32,oo[Cr.RANGE]=mo.FLOAT32,oo[Cr.COLOR]=mo.FLOAT32,oo[Cr.COUNT]=mo.NEVER,oo);delete Cr[Cr.COUNT],Cr[Cr.COUNT=Cr.RANGE+1]="COUNT";var Rr,Nr=new To(So.FOG,br,Cr);!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.PACKING=12]="PACKING",e[e.LINEAR=13]="LINEAR",e[e.SELF_SHADOW=14]="SELF_SHADOW",e[e.NORMAL_BIAS=15]="NORMAL_BIAS",e[e.ORTHO_SIZE=16]="ORTHO_SIZE",e[e.AUTO_ADAPT=17]="AUTO_ADAPT",e[e.COLOR=18]="COLOR",e[e.SIZE=22]="SIZE",e[e.NORMAL=24]="NORMAL",e[e.MAT_LIGHT=27]="MAT_LIGHT",e[e.COUNT=43]="COUNT"}(Rr||(Rr={}));var Or=((ro={})[Rr.ENABLE]=mo.UINT32,ro[Rr.DIRTY]=mo.UINT32,ro[Rr.TYPE]=mo.UINT32,ro[Rr.DISTANCE]=mo.FLOAT32,ro[Rr.INSTANCE_PASS]=mo.UINT32,ro[Rr.PLANAR_PASS]=mo.UINT32,ro[Rr.NEAR]=mo.FLOAT32,ro[Rr.FAR]=mo.FLOAT32,ro[Rr.ASPECT]=mo.FLOAT32,ro[Rr.PCF_TYPE]=mo.UINT32,ro[Rr.SHADOW_MAP_DIRTY]=mo.UINT32,ro[Rr.BIAS]=mo.FLOAT32,ro[Rr.PACKING]=mo.UINT32,ro[Rr.LINEAR]=mo.UINT32,ro[Rr.SELF_SHADOW]=mo.UINT32,ro[Rr.NORMAL_BIAS]=mo.FLOAT32,ro[Rr.ORTHO_SIZE]=mo.FLOAT32,ro[Rr.AUTO_ADAPT]=mo.UINT32,ro[Rr.COLOR]=mo.FLOAT32,ro[Rr.SIZE]=mo.FLOAT32,ro[Rr.NORMAL]=mo.FLOAT32,ro[Rr.MAT_LIGHT]=mo.FLOAT32,ro[Rr.COUNT]=mo.NEVER,ro);delete Rr[Rr.COUNT],Rr[Rr.COUNT=Rr.AUTO_ADAPT+1]="COUNT";var Dr,Mr=new To(So.SHADOW,Or,Rr,1);!function(e){e[e.SHADOW=0]="SHADOW",e[e.SKYBOX=1]="SKYBOX",e[e.AMBIENT=2]="AMBIENT",e[e.FOG=3]="FOG",e[e.IS_HDR=4]="IS_HDR",e[e.SHADING_SCALE=5]="SHADING_SCALE",e[e.FP_SCALE=6]="FP_SCALE",e[e.DEFERRED_LIGHT_PASS=7]="DEFERRED_LIGHT_PASS",e[e.DEFERRED_LIGHT_PASS_SHADER=8]="DEFERRED_LIGHT_PASS_SHADER",e[e.DEFERRED_POST_PASS=9]="DEFERRED_POST_PASS",e[e.DEFERRED_POST_PASS_SHADER=10]="DEFERRED_POST_PASS_SHADER",e[e.COUNT=11]="COUNT"}(Dr||(Dr={}));var Lr,Fr=((ao={})[Dr.SHADOW]=mo.UINT32,ao[Dr.SKYBOX]=mo.UINT32,ao[Dr.AMBIENT]=mo.UINT32,ao[Dr.FOG]=mo.UINT32,ao[Dr.IS_HDR]=mo.UINT32,ao[Dr.SHADING_SCALE]=mo.UINT32,ao[Dr.FP_SCALE]=mo.UINT32,ao[Dr.DEFERRED_LIGHT_PASS]=mo.UINT32,ao[Dr.DEFERRED_LIGHT_PASS_SHADER]=mo.UINT32,ao[Dr.DEFERRED_POST_PASS]=mo.UINT32,ao[Dr.DEFERRED_POST_PASS_SHADER]=mo.UINT32,ao[Dr.COUNT]=mo.NEVER,ao),zr=new To(So.PIPELINE_SCENE_DATA,Fr,Dr,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"}(Lr||(Lr={}));var Br,Ur=((so={})[Lr.USE_COLOR_TEMPERATURE]=mo.UINT32,so[Lr.ILLUMINANCE]=mo.FLOAT32,so[Lr.NODE]=mo.UINT32,so[Lr.RANGE]=mo.FLOAT32,so[Lr.TYPE]=mo.UINT32,so[Lr.AABB]=mo.UINT32,so[Lr.FRUSTUM]=mo.UINT32,so[Lr.SIZE]=mo.FLOAT32,so[Lr.SPOT_ANGLE]=mo.FLOAT32,so[Lr.ASPECT]=mo.FLOAT32,so[Lr.DIRECTION]=mo.FLOAT32,so[Lr.COLOR]=mo.FLOAT32,so[Lr.COLOR_TEMPERATURE_RGB]=mo.FLOAT32,so[Lr.POSITION]=mo.FLOAT32,so[Lr.COUNT]=mo.NEVER,so),Hr=new To(So.LIGHT,Ur,Lr,3);!function(e){e[e.RADIUS=0]="RADIUS",e[e.CENTER=1]="CENTER",e[e.COUNT=4]="COUNT"}(Br||(Br={}));var Gr=((co={})[Br.RADIUS]=mo.FLOAT32,co[Br.CENTER]=mo.FLOAT32,co[Br.COUNT]=mo.NEVER,co);delete Br[Br.COUNT],Br[Br.COUNT=Br.RADIUS+1]="COUNT";var Vr,kr=new To(So.SPHERE,Gr,Br,3);!function(e){e[e.STRIDE=0]="STRIDE",e[e.AMOUNT=1]="AMOUNT",e[e.BUFFER=2]="BUFFER",e[e.COUNT=3]="COUNT"}(Vr||(Vr={}));var Wr,jr=((lo={})[Vr.STRIDE]=mo.UINT32,lo[Vr.AMOUNT]=mo.UINT32,lo[Vr.BUFFER]=mo.UINT32,lo[Vr.COUNT]=mo.NEVER,lo),qr=new To(So.FLAT_BUFFER,jr,Vr,3);!function(e){e[e.FLAT_BUFFER_ARRAY=0]="FLAT_BUFFER_ARRAY",e[e.COUNT=1]="COUNT"}(Wr||(Wr={}));var Yr,Xr=((uo={})[Wr.FLAT_BUFFER_ARRAY]=mo.UINT32,uo[Wr.COUNT]=mo.NEVER,uo),Kr=new To(So.SUB_MESH,Xr,Wr,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"}(Yr||(Yr={}));var Qr,Zr=((ho={})[Yr.IS_DISCARD]=mo.UINT32,ho[Yr.POLYGO_MODEL]=mo.UINT32,ho[Yr.SHADE_MODEL]=mo.UINT32,ho[Yr.CULL_MODE]=mo.UINT32,ho[Yr.IS_FRONT_FACE_CCW]=mo.UINT32,ho[Yr.DEPTH_BIAS_ENABLED]=mo.UINT32,ho[Yr.DEPTH_BIAS]=mo.FLOAT32,ho[Yr.DEPTH_BIAS_CLAMP]=mo.FLOAT32,ho[Yr.DEPTH_BIAS_SLOP]=mo.FLOAT32,ho[Yr.IS_DEPTH_CLIP]=mo.UINT32,ho[Yr.IS_MULTI_SAMPLE]=mo.UINT32,ho[Yr.LINE_WIDTH]=mo.FLOAT32,ho[Yr.COUNT]=mo.NEVER,ho),Jr=new To(So.RASTERIZER_STATE,Zr,Yr,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"}(Qr||(Qr={}));var $r,ea=((_o={})[Qr.DEPTH_TEST]=mo.UINT32,_o[Qr.DEPTH_WRITE]=mo.UINT32,_o[Qr.DEPTH_FUNC]=mo.UINT32,_o[Qr.STENCIL_TEST_FRONT]=mo.UINT32,_o[Qr.STENCIL_FUNC_FRONT]=mo.UINT32,_o[Qr.STENCIL_READ_MASK_FRONT]=mo.UINT32,_o[Qr.STENCIL_WRITE_MASK_FRONT]=mo.UINT32,_o[Qr.STENCIL_FAIL_OP_FRONT]=mo.UINT32,_o[Qr.STENCIL_Z_FAIL_OP_FRONT]=mo.UINT32,_o[Qr.STENCIL_PASS_OP_FRONT]=mo.UINT32,_o[Qr.STENCIL_REF_FRONT]=mo.UINT32,_o[Qr.STENCIL_TEST_BACK]=mo.UINT32,_o[Qr.STENCIL_FUNC_BACK]=mo.UINT32,_o[Qr.STENCIL_READ_MADK_BACK]=mo.UINT32,_o[Qr.STENCIL_WRITE_MASK_BACK]=mo.UINT32,_o[Qr.STENCIL_FAIL_OP_BACK]=mo.UINT32,_o[Qr.STENCIL_Z_FAIL_OP_BACK]=mo.UINT32,_o[Qr.STENCIL_PASS_OP_BACK]=mo.UINT32,_o[Qr.STENCIL_REF_BACK]=mo.UINT32,_o[Qr.COUNT]=mo.NEVER,_o),ta=new To(So.DEPTH_STENCIL_STATE,ea,Qr,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"}($r||($r={})),(fo={})[$r.BLEND]=mo.UINT32,fo[$r.BLEND_SRC]=mo.UINT32,fo[$r.BLEND_DST]=mo.UINT32,fo[$r.BLEND_EQ]=mo.UINT32,fo[$r.BLEND_SRC_ALPHA]=mo.UINT32,fo[$r.BLEND_DST_ALPHA]=mo.UINT32,fo[$r.BLEND_ALPHA_EQ]=mo.UINT32,fo[$r.BLEND_COLOR_MASK]=mo.UINT32,fo[$r.COUNT]=mo.NEVER;var na,ia=new To(So.BLEND_TARGET,ea,$r,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"}(na||(na={}));var oa=((po={})[na.IS_A2C]=mo.UINT32,po[na.IS_INDEPEND]=mo.UINT32,po[na.BLEND_COLOR]=mo.FLOAT32,po[na.BLEND_TARGET]=mo.UINT32,po[na.COUNT]=mo.NEVER,po),ra=new To(So.BLEND_STATE,oa,na,9),aa=function(){function e(){this._skyColor=new Pn(51,128,204,1),this._groundAlbedo=new Pn(51,51,51,255),this._albedoArray=Float32Array.from([.2,.2,.2,1]),this._colorArray=Float32Array.from([.2,.5,.8,1]),this._handle=bo,this._handle=wr.alloc()}var t=e.prototype;return t.initialize=function(e){this._skyColor.set(e.skyColor),this._groundAlbedo.set(e.groundAlbedo),Pn.toArray(this._colorArray,this._skyColor),Rn.toArray(this._albedoArray,this._groundAlbedo),wr.setVec4(this._handle,xr.SKY_COLOR,this._skyColor),wr.setVec4(this._handle,xr.GROUND_ALBEDO,this._groundAlbedo),wr.set(this._handle,xr.ILLUM,e.skyIllum)},t.destroy=function(){this._handle&&(wr.free(this._handle),this._handle=bo)},te(e,[{key:"colorArray",get:function(){return this._colorArray}},{key:"albedoArray",get:function(){return this._albedoArray}},{key:"enabled",get:function(){return wr.get(this._handle,xr.ENABLE)},set:function(e){wr.set(this._handle,xr.ENABLE,e?1:0)}},{key:"skyColor",get:function(){return this._skyColor},set:function(e){this._skyColor.set(e),Pn.toArray(this._colorArray,this._skyColor),wr.setVec4(this._handle,xr.SKY_COLOR,this._skyColor)}},{key:"skyIllum",get:function(){return wr.get(this._handle,xr.ILLUM)},set:function(e){wr.set(this._handle,xr.ILLUM,e)}},{key:"groundAlbedo",get:function(){return this._groundAlbedo},set:function(e){this._groundAlbedo.set(e),Rn.toArray(this._albedoArray,this._groundAlbedo),wr.setVec4(this._handle,xr.GROUND_ALBEDO,this._groundAlbedo)}},{key:"handle",get:function(){return this._handle}}]),e}();aa.SUN_ILLUM=65e3,aa.SKY_ILLUM=2e4,c.Ambient=aa;var sa=new Rn,ca=new Rn,la=new Rn,ua=new Rn,ha=new Rn,_a=new Rn,fa=new Array(3),da=new Array(3);function pa(e,t){return Rn.dot(t.n,e)-t.d}function ma(e,t,n){return Rn.copy(e,t),Rn.subtract(ha,n.center,n.halfExtents),Rn.add(_a,n.center,n.halfExtents),e.x=e.x<ha.x?ha.x:e.x,e.y=e.y<ha.y?ha.y:e.y,e.z=e.z<ha.z?ha.z:e.z,e.x=e.x>_a.x?_a.x:e.x,e.y=e.y>_a.y?_a.y:e.y,e.z=e.z>_a.z?_a.z:e.z,e}function va(e,t,n){Rn.set(sa,n.orientation.m00,n.orientation.m01,n.orientation.m02),Rn.set(ca,n.orientation.m03,n.orientation.m04,n.orientation.m05),Rn.set(la,n.orientation.m06,n.orientation.m07,n.orientation.m08),fa[0]=sa,fa[1]=ca,fa[2]=la,da[0]=n.halfExtents.x,da[1]=n.halfExtents.y,da[2]=n.halfExtents.z,Rn.subtract(ua,t,n.center),Rn.set(e,n.center.x,n.center.y,n.center.z);for(var i=0;i<3;i++){var o=Rn.dot(ua,fa[i]);o>da[i]&&(o=da[i]),o<-da[i]&&(o=-da[i]),e.x+=o*fa[i].x,e.y+=o*fa[i].y,e.z+=o*fa[i].z}return e}var ga=Object.freeze({__proto__:null,point_plane:pa,pt_point_plane:function(e,t,n){var i=pa(t,n);return Rn.subtract(e,t,Rn.multiplyScalar(e,n.n,i))},pt_point_aabb:ma,pt_point_obb:va,pt_point_line:function(e,t,n,i){Rn.subtract(sa,n,i);var o=sa,r=Rn.lengthSqr(o);if(0==r)Rn.copy(e,n);else{Rn.subtract(sa,t,n);var a=Rn.dot(sa,o)/r;a<0?Rn.copy(e,n):a>1?Rn.copy(e,i):Rn.scaleAndAdd(e,n,o,a)}}}),ya={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},xa=function(){function e(e,t,n,i,o,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===o&&(o=0),void 0===r&&(r=-1),this.s=void 0,this.e=void 0,this._type=void 0,this._type=ya.SHAPE_LINE,this.s=new Rn(e,t,n),this.e=new Rn(i,o,r)}return e.create=function(t,n,i,o,r,a){return new e(t,n,i,o,r,a)},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 Rn.copy(e.s,t.s),Rn.copy(e.e,t.e),e},e.fromPoints=function(e,t,n){return Rn.copy(e.s,t),Rn.copy(e.e,n),e},e.set=function(e,t,n,i,o,r,a){return e.s.x=t,e.s.y=n,e.s.z=i,e.e.x=o,e.e.y=r,e.e.z=a,e},e.len=function(e){return Rn.distance(e.s,e.e)},e.prototype.length=function(){return Rn.distance(this.s,this.e)},te(e,[{key:"type",get:function(){return this._type}}]),e}(),Ea=function(){function e(e,t,n,i,o,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===o&&(o=0),void 0===r&&(r=-1),this.o=void 0,this.d=void 0,this._type=void 0,this._type=ya.SHAPE_RAY,this.o=new Rn(e,t,n),this.d=new Rn(i,o,r)}return e.create=function(t,n,i,o,r,a){return void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===o&&(o=0),void 0===r&&(r=0),void 0===a&&(a=1),new e(t,n,i,o,r,a)},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 Rn.copy(e.o,t.o),Rn.copy(e.d,t.d),e},e.fromPoints=function(e,t,n){return Rn.copy(e.o,t),Rn.normalize(e.d,Rn.subtract(e.d,n,t)),e},e.set=function(e,t,n,i,o,r,a){return e.o.x=t,e.o.y=n,e.o.z=i,e.d.x=o,e.d.y=r,e.d.z=a,e},e.prototype.computeHit=function(e,t){Rn.normalize(e,this.d),Rn.scaleAndAdd(e,this.o,e,t)},te(e,[{key:"type",get:function(){return this._type}}]),e}(),Sa=new Rn,Ta=new Rn,Aa=new Rn,wa=new Rn;function Ca(e){return Math.max(Math.max(e.x,e.y),e.z)}var Ia,Pa,ba,Ra,Na,Oa,Da,Ma,La,Fa,za,Ba,Ua,Ha,Ga,Va,ka,Wa,ja,qa,Ya,Xa,Ka,Qa,Za,Ja,$a,es,ts,ns,is,os,rs,as,ss,cs,ls,us,hs=e("e8",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 Rn(0,0,0),this._poolHandle=bo,this._type=void 0,this._type=ya.SHAPE_SPHERE,this._center=new Rn(e,t,n),this._poolHandle=kr.alloc(),kr.setVec3(this._poolHandle,Br.CENTER,this._center),kr.set(this._poolHandle,Br.RADIUS,i)}e.create=function(t,n,i,o){return new e(t,n,i,o)},e.clone=function(t){return new e(t.center.x,t.center.y,t.center.z,t.radius)},e.copy=function(e,t){return Rn.copy(e.center,t.center),e.radius=t.radius,e},e.fromPoints=function(e,t,n){return Rn.multiplyScalar(e.center,Rn.add(Sa,t,n),.5),e.radius=.5*Rn.subtract(Sa,n,t).length(),e},e.set=function(e,t,n,i,o){return e.center.x=t,e.center.y=n,e.center.z=i,e.radius=o,e},e.mergePoint=function(e,t,n){if(t.radius<0)return e.center.set(n),e.radius=0,e;Rn.subtract(Ta,n,t.center);var i=Ta.length();if(i>t.radius){var o=.5*(i-t.radius);e.radius+=o,Rn.multiplyScalar(Ta,Ta,o/i),Rn.add(e.center,e.center,Ta)}return e},e.mergeAABB=function(t,n,i){return i.getBoundary(Aa,wa),e.mergePoint(t,n,Aa),e.mergePoint(t,n,wa),t};var t=e.prototype;return t.destroy=function(){this._poolHandle&&(kr.free(this._poolHandle),this._poolHandle=bo)},t.clone=function(){return e.clone(this)},t.copy=function(t){return e.copy(this,t)},t.getBoundary=function(e,t){Rn.set(e,this.center.x-this.radius,this.center.y-this.radius,this.center.z-this.radius),Rn.set(t,this.center.x+this.radius,this.center.y+this.radius,this.center.z+this.radius)},t.transform=function(e,t,n,i,o){Rn.transformMat4(o.center,this.center,e),o.radius=this.radius*Ca(i)},t.translateAndRotate=function(e,t,n){Rn.transformMat4(n.center,this.center,e)},t.setScale=function(e,t){t.radius=this.radius*Ca(e)},te(e,[{key:"center",get:function(){return this._center},set:function(e){this._center=e,kr.setVec3(this._poolHandle,Br.CENTER,this._center)}},{key:"radius",get:function(){return kr.get(this._poolHandle,Br.RADIUS)},set:function(e){kr.set(this._poolHandle,Br.RADIUS,e)}},{key:"handle",get:function(){return this._poolHandle}},{key:"type",get:function(){return this._type}}]),e}()),_s=function(){function e(e,t,n,i,o,r,a,s,c){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=1),void 0===o&&(o=0),void 0===r&&(r=0),void 0===a&&(a=0),void 0===s&&(s=1),void 0===c&&(c=0),this.a=void 0,this.b=void 0,this.c=void 0,this._type=void 0,this._type=ya.SHAPE_TRIANGLE,this.a=new Rn(e,t,n),this.b=new Rn(i,o,r),this.c=new Rn(a,s,c)}return e.create=function(t,n,i,o,r,a,s,c,l){return void 0===t&&(t=1),void 0===n&&(n=0),void 0===i&&(i=0),void 0===o&&(o=0),void 0===r&&(r=0),void 0===a&&(a=0),void 0===s&&(s=0),void 0===c&&(c=0),void 0===l&&(l=1),new e(t,n,i,o,r,a,s,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 Rn.copy(e.a,t.a),Rn.copy(e.b,t.b),Rn.copy(e.c,t.c),e},e.fromPoints=function(e,t,n,i){return Rn.copy(e.a,t),Rn.copy(e.b,n),Rn.copy(e.c,i),e},e.set=function(e,t,n,i,o,r,a,s,c,l){return e.a.x=t,e.a.y=n,e.a.z=i,e.b.x=o,e.b.y=r,e.b.z=a,e.c.x=s,e.c.y=c,e.c.z=l,e},te(e,[{key:"type",get:function(){return this._type}}]),e}(),fs=function(e,t,n){for(var i=0;i<t.length;++i)e.length<=i&&e.push(new n),e[i].copy(t[i]);e.length=t.length};!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.QUEUE=13]="QUEUE",e[e.GLOBAL_BARRIER=14]="GLOBAL_BARRIER",e[e.TEXTURE_BARRIER=15]="TEXTURE_BARRIER",e[e.BUFFER_BARRIER=16]="BUFFER_BARRIER"}(Ia||(Ia=e("O",{}))),function(e){e[e.UNREADY=0]="UNREADY",e[e.FAILED=1]="FAILED",e[e.SUCCESS=2]="SUCCESS"}(Pa||(Pa=e("S",{}))),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"}(ba||(ba=e("A",{}))),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"}(Ra||(Ra=e("b",{}))),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.MULTITHREADED_SUBMISSION=28]="MULTITHREADED_SUBMISSION",e[e.COMPUTE_SHADER=29]="COMPUTE_SHADER",e[e.COUNT=30]="COUNT"}(Na||(Na=e("F",{}))),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",e[e.COUNT=121]="COUNT"}(Oa||(Oa=e("c",{}))),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"}(Da||(Da=e("d",{}))),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.SAMPLER=32]="SAMPLER",e[e.TEXTURE1D=33]="TEXTURE1D",e[e.TEXTURE1D_ARRAY=34]="TEXTURE1D_ARRAY",e[e.TEXTURE2D=35]="TEXTURE2D",e[e.TEXTURE2D_ARRAY=36]="TEXTURE2D_ARRAY",e[e.TEXTURE3D=37]="TEXTURE3D",e[e.TEXTURE_CUBE=38]="TEXTURE_CUBE",e[e.IMAGE1D=39]="IMAGE1D",e[e.IMAGE1D_ARRAY=40]="IMAGE1D_ARRAY",e[e.IMAGE2D=41]="IMAGE2D",e[e.IMAGE2D_ARRAY=42]="IMAGE2D_ARRAY",e[e.IMAGE3D=43]="IMAGE3D",e[e.IMAGE_CUBE=44]="IMAGE_CUBE",e[e.SUBPASS_INPUT=45]="SUBPASS_INPUT",e[e.COUNT=46]="COUNT"}(Ma||(Ma=e("T",{}))),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"}(La||(La=e("e",{}))),function(e){e[e.NONE=0]="NONE"}(Fa||(Fa=e("f",{}))),function(e){e[e.NONE=0]="NONE",e[e.READ_ONLY=1]="READ_ONLY",e[e.WRITE_ONLY=2]="WRITE_ONLY",e[e.READ_WRITE=3]="READ_WRITE"}(za||(za=e("M",{}))),function(e){e[e.NONE=0]="NONE",e[e.DEVICE=1]="DEVICE",e[e.HOST=2]="HOST"}(Ba||(Ba=e("g",{}))),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"}(Ua||(Ua=e("h",{}))),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"}(Ha||(Ha=e("i",{}))),function(e){e[e.NONE=0]="NONE",e[e.GEN_MIPMAP=1]="GEN_MIPMAP",e[e.IMMUTABLE=2]="IMMUTABLE"}(Ga||(Ga=e("j",{}))),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"}(Va||(Va=e("k",{}))),function(e){e[e.NONE=0]="NONE",e[e.POINT=1]="POINT",e[e.LINEAR=2]="LINEAR",e[e.ANISOTROPIC=3]="ANISOTROPIC"}(ka||(ka=e("l",{}))),function(e){e[e.WRAP=0]="WRAP",e[e.MIRROR=1]="MIRROR",e[e.CLAMP=2]="CLAMP",e[e.BORDER=3]="BORDER"}(Wa||(Wa=e("m",{}))),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"}(ja||(ja=e("n",{}))),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"}(qa||(qa=e("o",{}))),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"}(Ya||(Ya=e("p",{}))),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"}(Xa||(Xa=e("q",{}))),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"}(Ka||(Ka=e("r",{}))),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"}(Qa||(Qa=e("s",{}))),function(e){e[e.LOAD=0]="LOAD",e[e.CLEAR=1]="CLEAR",e[e.DISCARD=2]="DISCARD"}(Za||(Za=e("L",{}))),function(e){e[e.STORE=0]="STORE",e[e.DISCARD=1]="DISCARD"}(Ja||(Ja=e("t",{}))),function(e){e[e.NONE=0]="NONE",e[e.INDIRECT_BUFFER=1]="INDIRECT_BUFFER",e[e.INDEX_BUFFER=2]="INDEX_BUFFER",e[e.VERTEX_BUFFER=3]="VERTEX_BUFFER",e[e.VERTEX_SHADER_READ_UNIFORM_BUFFER=4]="VERTEX_SHADER_READ_UNIFORM_BUFFER",e[e.VERTEX_SHADER_READ_TEXTURE=5]="VERTEX_SHADER_READ_TEXTURE",e[e.VERTEX_SHADER_READ_OTHER=6]="VERTEX_SHADER_READ_OTHER",e[e.FRAGMENT_SHADER_READ_UNIFORM_BUFFER=7]="FRAGMENT_SHADER_READ_UNIFORM_BUFFER",e[e.FRAGMENT_SHADER_READ_TEXTURE=8]="FRAGMENT_SHADER_READ_TEXTURE",e[e.FRAGMENT_SHADER_READ_COLOR_INPUT_ATTACHMENT=9]="FRAGMENT_SHADER_READ_COLOR_INPUT_ATTACHMENT",e[e.FRAGMENT_SHADER_READ_DEPTH_STENCIL_INPUT_ATTACHMENT=10]="FRAGMENT_SHADER_READ_DEPTH_STENCIL_INPUT_ATTACHMENT",e[e.FRAGMENT_SHADER_READ_OTHER=11]="FRAGMENT_SHADER_READ_OTHER",e[e.COLOR_ATTACHMENT_READ=12]="COLOR_ATTACHMENT_READ",e[e.DEPTH_STENCIL_ATTACHMENT_READ=13]="DEPTH_STENCIL_ATTACHMENT_READ",e[e.COMPUTE_SHADER_READ_UNIFORM_BUFFER=14]="COMPUTE_SHADER_READ_UNIFORM_BUFFER",e[e.COMPUTE_SHADER_READ_TEXTURE=15]="COMPUTE_SHADER_READ_TEXTURE",e[e.COMPUTE_SHADER_READ_OTHER=16]="COMPUTE_SHADER_READ_OTHER",e[e.TRANSFER_READ=17]="TRANSFER_READ",e[e.HOST_READ=18]="HOST_READ",e[e.PRESENT=19]="PRESENT",e[e.VERTEX_SHADER_WRITE=20]="VERTEX_SHADER_WRITE",e[e.FRAGMENT_SHADER_WRITE=21]="FRAGMENT_SHADER_WRITE",e[e.COLOR_ATTACHMENT_WRITE=22]="COLOR_ATTACHMENT_WRITE",e[e.DEPTH_STENCIL_ATTACHMENT_WRITE=23]="DEPTH_STENCIL_ATTACHMENT_WRITE",e[e.COMPUTE_SHADER_WRITE=24]="COMPUTE_SHADER_WRITE",e[e.TRANSFER_WRITE=25]="TRANSFER_WRITE",e[e.HOST_PREINITIALIZED=26]="HOST_PREINITIALIZED",e[e.HOST_WRITE=27]="HOST_WRITE"}($a||($a=e("u",{}))),function(e){e[e.GRAPHICS=0]="GRAPHICS",e[e.COMPUTE=1]="COMPUTE",e[e.RAY_TRACING=2]="RAY_TRACING"}(es||(es=e("v",{}))),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"}(ts||(ts=e("w",{}))),function(e){e[e.FILL=0]="FILL",e[e.POINT=1]="POINT",e[e.LINE=2]="LINE"}(ns||(ns=e("x",{}))),function(e){e[e.GOURAND=0]="GOURAND",e[e.FLAT=1]="FLAT"}(is||(is=e("y",{}))),function(e){e[e.NONE=0]="NONE",e[e.FRONT=1]="FRONT",e[e.BACK=2]="BACK"}(os||(os=e("z",{}))),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"}(rs||(rs=e("E",{}))),function(e){e[e.FRONT=0]="FRONT",e[e.BACK=1]="BACK",e[e.ALL=2]="ALL"}(as||(as=e("G",{}))),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_TEXTURE=16]="SAMPLER_TEXTURE",e[e.SAMPLER=32]="SAMPLER",e[e.TEXTURE=64]="TEXTURE",e[e.STORAGE_IMAGE=128]="STORAGE_IMAGE",e[e.INPUT_ATTACHMENT=256]="INPUT_ATTACHMENT"}(ss||(ss=e("H",{}))),function(e){e[e.GRAPHICS=0]="GRAPHICS",e[e.COMPUTE=1]="COMPUTE",e[e.TRANSFER=2]="TRANSFER"}(cs||(cs=e("Q",{}))),function(e){e[e.PRIMARY=0]="PRIMARY",e[e.SECONDARY=1]="SECONDARY"}(ls||(ls=e("I",{}))),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"}(us||(us=e("J",{})));var ds,ps=e("K",function(){function e(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}return e.prototype.copy=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},e}()),ms=e("N",function(){function e(e,t,n,i,o,r,a,s,c,l,u,h,_,f,d,p,m,v,g,y,x,E,S){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===o&&(o=0),void 0===r&&(r=0),void 0===a&&(a=0),void 0===s&&(s=0),void 0===c&&(c=0),void 0===l&&(l=0),void 0===u&&(u=0),void 0===h&&(h=0),void 0===_&&(_=0),void 0===f&&(f=0),void 0===d&&(d=0),void 0===p&&(p=1),void 0===m&&(m=0),void 0===v&&(v=0),void 0===g&&(g=new ps),void 0===y&&(y=new ps),void 0===x&&(x=-1),void 0===E&&(E=1),void 0===S&&(S=1),this.maxVertexAttributes=e,this.maxVertexUniformVectors=t,this.maxFragmentUniformVectors=n,this.maxTextureUnits=i,this.maxImageUnits=o,this.maxVertexTextureUnits=r,this.maxColorRenderTargets=a,this.maxShaderStorageBufferBindings=s,this.maxShaderStorageBlockSize=c,this.maxUniformBufferBindings=l,this.maxUniformBlockSize=u,this.maxTextureSize=h,this.maxCubeMapTextureSize=_,this.depthBits=f,this.stencilBits=d,this.uboOffsetAlignment=p,this.maxComputeSharedMemorySize=m,this.maxComputeWorkGroupInvocations=v,this.maxComputeWorkGroupSize=g,this.maxComputeWorkGroupCount=y,this.clipSpaceMinZ=x,this.screenSpaceSignY=E,this.clipSpaceSignY=S}return e.prototype.copy=function(e){return this.maxVertexAttributes=e.maxVertexAttributes,this.maxVertexUniformVectors=e.maxVertexUniformVectors,this.maxFragmentUniformVectors=e.maxFragmentUniformVectors,this.maxTextureUnits=e.maxTextureUnits,this.maxImageUnits=e.maxImageUnits,this.maxVertexTextureUnits=e.maxVertexTextureUnits,this.maxColorRenderTargets=e.maxColorRenderTargets,this.maxShaderStorageBufferBindings=e.maxShaderStorageBufferBindings,this.maxShaderStorageBlockSize=e.maxShaderStorageBlockSize,this.maxUniformBufferBindings=e.maxUniformBufferBindings,this.maxUniformBlockSize=e.maxUniformBlockSize,this.maxTextureSize=e.maxTextureSize,this.maxCubeMapTextureSize=e.maxCubeMapTextureSize,this.depthBits=e.depthBits,this.stencilBits=e.stencilBits,this.uboOffsetAlignment=e.uboOffsetAlignment,this.maxComputeSharedMemorySize=e.maxComputeSharedMemorySize,this.maxComputeWorkGroupInvocations=e.maxComputeWorkGroupInvocations,this.maxComputeWorkGroupSize.copy(e.maxComputeWorkGroupSize),this.maxComputeWorkGroupCount.copy(e.maxComputeWorkGroupCount),this.clipSpaceMinZ=e.clipSpaceMinZ,this.screenSpaceSignY=e.screenSpaceSignY,this.clipSpaceSignY=e.clipSpaceSignY,this},e}()),vs=e("U",function(){function e(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}return e.prototype.copy=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},e}()),gs=e("V",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=0),this.x=e,this.y=t,this.width=n,this.height=i}return e.prototype.copy=function(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this},e}()),ys=e("W",function(){function e(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}return e.prototype.copy=function(e){return this.width=e.width,this.height=e.height,this.depth=e.depth,this},e}()),xs=e("X",function(){function e(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}return e.prototype.copy=function(e){return this.mipLevel=e.mipLevel,this.baseArrayLayer=e.baseArrayLayer,this.layerCount=e.layerCount,this},e}()),Es=e("Y",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=1),this.baseMipLevel=e,this.levelCount=t,this.baseArrayLayer=n,this.layerCount=i}return e.prototype.copy=function(e){return this.baseMipLevel=e.baseMipLevel,this.levelCount=e.levelCount,this.baseArrayLayer=e.baseArrayLayer,this.layerCount=e.layerCount,this},e}()),Ss=e("Z",function(){function e(e,t,n,i,o){void 0===e&&(e=new xs),void 0===t&&(t=new vs),void 0===n&&(n=new xs),void 0===i&&(i=new vs),void 0===o&&(o=new ys),this.srcSubres=e,this.srcOffset=t,this.dstSubres=n,this.dstOffset=i,this.extent=o}return e.prototype.copy=function(e){return this.srcSubres.copy(e.srcSubres),this.srcOffset.copy(e.srcOffset),this.dstSubres.copy(e.dstSubres),this.dstOffset.copy(e.dstOffset),this.extent.copy(e.extent),this},e}()),Ts=e("_",function(){function e(e,t,n,i,o,r){void 0===e&&(e=new xs),void 0===t&&(t=new vs),void 0===n&&(n=new ys),void 0===i&&(i=new xs),void 0===o&&(o=new vs),void 0===r&&(r=new ys),this.srcSubres=e,this.srcOffset=t,this.srcExtent=n,this.dstSubres=i,this.dstOffset=o,this.dstExtent=r}return e.prototype.copy=function(e){return this.srcSubres.copy(e.srcSubres),this.srcOffset.copy(e.srcOffset),this.srcExtent.copy(e.srcExtent),this.dstSubres.copy(e.dstSubres),this.dstOffset.copy(e.dstOffset),this.dstExtent.copy(e.dstExtent),this},e}()),As=e("$",function(){function e(e,t,n,i,o){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=new vs),void 0===i&&(i=new ys),void 0===o&&(o=new xs),this.buffStride=e,this.buffTexHeight=t,this.texOffset=n,this.texExtent=i,this.texSubres=o}return e.prototype.copy=function(e){return this.buffStride=e.buffStride,this.buffTexHeight=e.buffTexHeight,this.texOffset.copy(e.texOffset),this.texExtent.copy(e.texExtent),this.texSubres.copy(e.texSubres),this},e}()),ws=e("a0",function(){function e(e,t,n,i,o,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===o&&(o=0),void 0===r&&(r=1),this.left=e,this.top=t,this.width=n,this.height=i,this.minDepth=o,this.maxDepth=r}return e.prototype.copy=function(e){return this.left=e.left,this.top=e.top,this.width=e.width,this.height=e.height,this.minDepth=e.minDepth,this.maxDepth=e.maxDepth,this},e}()),Cs=e("a1",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=0),this.x=e,this.y=t,this.z=n,this.w=i}return e.prototype.copy=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},e}()),Is=e("a2",function(){function e(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}return e.prototype.copy=function(e){return this.bufferOffsets=e.bufferOffsets.slice(),this.samplerOffsets=e.samplerOffsets.slice(),this.flexibleSet=e.flexibleSet,this},e}()),Ps=e("a3",function(){function e(e,t,n,i,o){void 0===e&&(e=La.NONE),void 0===t&&(t=Ba.NONE),void 0===n&&(n=0),void 0===i&&(i=0),void 0===o&&(o=Fa.NONE),this.usage=e,this.memUsage=t,this.size=n,this.stride=i,this.flags=o}return e.prototype.copy=function(e){return this.usage=e.usage,this.memUsage=e.memUsage,this.size=e.size,this.stride=e.stride,this.flags=e.flags,this},e}()),bs=e("a4",function(){function e(e,t,n){void 0===e&&(e=null),void 0===t&&(t=0),void 0===n&&(n=0),this.buffer=e,this.offset=t,this.range=n}return e.prototype.copy=function(e){return this.buffer=e.buffer,this.offset=e.offset,this.range=e.range,this},e}()),Rs=e("a5",function(){function e(e,t,n,i,o,r,a){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===o&&(o=0),void 0===r&&(r=0),void 0===a&&(a=0),this.vertexCount=e,this.firstVertex=t,this.indexCount=n,this.firstIndex=i,this.vertexOffset=o,this.instanceCount=r,this.firstInstance=a}return e.prototype.copy=function(e){return this.vertexCount=e.vertexCount,this.firstVertex=e.firstVertex,this.indexCount=e.indexCount,this.firstIndex=e.firstIndex,this.vertexOffset=e.vertexOffset,this.instanceCount=e.instanceCount,this.firstInstance=e.firstInstance,this},e}()),Ns=e("a6",function(){function e(e,t,n,i,o){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=null),void 0===o&&(o=0),this.groupCountX=e,this.groupCountY=t,this.groupCountZ=n,this.indirectBuffer=i,this.indirectOffset=o}return e.prototype.copy=function(e){return this.groupCountX=e.groupCountX,this.groupCountY=e.groupCountY,this.groupCountZ=e.groupCountZ,this.indirectBuffer=e.indirectBuffer,this.indirectOffset=e.indirectOffset,this},e}()),Os=e("a7",function(){function e(e){void 0===e&&(e=[]),this.drawInfos=e}return e.prototype.copy=function(e){return fs(this.drawInfos,e.drawInfos,Rs),this},e}()),Ds=e("a8",function(){function e(e,t,n,i,o,r,a,s,c,l){void 0===e&&(e=Ua.TEX2D),void 0===t&&(t=Ha.NONE),void 0===n&&(n=Oa.UNKNOWN),void 0===i&&(i=0),void 0===o&&(o=0),void 0===r&&(r=Ga.NONE),void 0===a&&(a=1),void 0===s&&(s=1),void 0===c&&(c=Va.X1),void 0===l&&(l=1),this.type=e,this.usage=t,this.format=n,this.width=i,this.height=o,this.flags=r,this.layerCount=a,this.levelCount=s,this.samples=c,this.depth=l}return e.prototype.copy=function(e){return this.type=e.type,this.usage=e.usage,this.format=e.format,this.width=e.width,this.height=e.height,this.flags=e.flags,this.layerCount=e.layerCount,this.levelCount=e.levelCount,this.samples=e.samples,this.depth=e.depth,this},e}()),Ms=e("a9",function(){function e(e,t,n,i,o,r,a){void 0===e&&(e=null),void 0===t&&(t=Ua.TEX2D),void 0===n&&(n=Oa.UNKNOWN),void 0===i&&(i=0),void 0===o&&(o=1),void 0===r&&(r=0),void 0===a&&(a=1),this.texture=e,this.type=t,this.format=n,this.baseLevel=i,this.levelCount=o,this.baseLayer=r,this.layerCount=a}return e.prototype.copy=function(e){return this.texture=e.texture,this.type=e.type,this.format=e.format,this.baseLevel=e.baseLevel,this.levelCount=e.levelCount,this.baseLayer=e.baseLayer,this.layerCount=e.layerCount,this},e}()),Ls=e("aa",function(){function e(e,t,n,i,o,r,a,s,c,l){void 0===e&&(e=ka.LINEAR),void 0===t&&(t=ka.LINEAR),void 0===n&&(n=ka.NONE),void 0===i&&(i=Wa.WRAP),void 0===o&&(o=Wa.WRAP),void 0===r&&(r=Wa.WRAP),void 0===a&&(a=0),void 0===s&&(s=ja.ALWAYS),void 0===c&&(c=new Cs),void 0===l&&(l=0),this.minFilter=e,this.magFilter=t,this.mipFilter=n,this.addressU=i,this.addressV=o,this.addressW=r,this.maxAnisotropy=a,this.cmpFunc=s,this.borderColor=c,this.mipLODBias=l}return e.prototype.copy=function(e){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.copy(e.borderColor),this.mipLODBias=e.mipLODBias,this},e}()),Fs=e("ab",function(){function e(e,t,n){void 0===e&&(e=""),void 0===t&&(t=Ma.UNKNOWN),void 0===n&&(n=0),this.name=e,this.type=t,this.count=n}return e.prototype.copy=function(e){return this.name=e.name,this.type=e.type,this.count=e.count,this},e}()),zs=e("ac",function(){function e(e,t,n,i,o){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=""),void 0===i&&(i=[]),void 0===o&&(o=0),this.set=e,this.binding=t,this.name=n,this.members=i,this.count=o}return e.prototype.copy=function(e){return this.set=e.set,this.binding=e.binding,this.name=e.name,fs(this.members,e.members,Fs),this.count=e.count,this},e}()),Bs=e("ad",function(){function e(e,t,n,i,o){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=""),void 0===i&&(i=Ma.UNKNOWN),void 0===o&&(o=0),this.set=e,this.binding=t,this.name=n,this.type=i,this.count=o}return e.prototype.copy=function(e){return this.set=e.set,this.binding=e.binding,this.name=e.name,this.type=e.type,this.count=e.count,this},e}()),Us=e("ae",function(){function e(e,t,n,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=""),void 0===i&&(i=0),this.set=e,this.binding=t,this.name=n,this.count=i}return e.prototype.copy=function(e){return this.set=e.set,this.binding=e.binding,this.name=e.name,this.count=e.count,this},e}()),Hs=e("af",function(){function e(e,t,n,i,o){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=""),void 0===i&&(i=Ma.UNKNOWN),void 0===o&&(o=0),this.set=e,this.binding=t,this.name=n,this.type=i,this.count=o}return e.prototype.copy=function(e){return this.set=e.set,this.binding=e.binding,this.name=e.name,this.type=e.type,this.count=e.count,this},e}()),Gs=e("ag",function(){function e(e,t,n,i,o,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=""),void 0===i&&(i=Ma.UNKNOWN),void 0===o&&(o=0),void 0===r&&(r=za.READ_WRITE),this.set=e,this.binding=t,this.name=n,this.type=i,this.count=o,this.memoryAccess=r}return e.prototype.copy=function(e){return this.set=e.set,this.binding=e.binding,this.name=e.name,this.type=e.type,this.count=e.count,this.memoryAccess=e.memoryAccess,this},e}()),Vs=e("ah",function(){function e(e,t,n,i,o){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=""),void 0===i&&(i=0),void 0===o&&(o=za.READ_WRITE),this.set=e,this.binding=t,this.name=n,this.count=i,this.memoryAccess=o}return e.prototype.copy=function(e){return this.set=e.set,this.binding=e.binding,this.name=e.name,this.count=e.count,this.memoryAccess=e.memoryAccess,this},e}()),ks=e("ai",function(){function e(e,t,n,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=""),void 0===i&&(i=0),this.set=e,this.binding=t,this.name=n,this.count=i}return e.prototype.copy=function(e){return this.set=e.set,this.binding=e.binding,this.name=e.name,this.count=e.count,this},e}()),Ws=e("aj",function(){function e(e,t){void 0===e&&(e=Qa.NONE),void 0===t&&(t=""),this.stage=e,this.source=t}return e.prototype.copy=function(e){return this.stage=e.stage,this.source=e.source,this},e}()),js=e("ak",function(){function e(e,t,n,i,o,r){void 0===e&&(e=""),void 0===t&&(t=Oa.UNKNOWN),void 0===n&&(n=!1),void 0===i&&(i=0),void 0===o&&(o=!1),void 0===r&&(r=0),this.name=e,this.format=t,this.isNormalized=n,this.stream=i,this.isInstanced=o,this.location=r}return e.prototype.copy=function(e){return this.name=e.name,this.format=e.format,this.isNormalized=e.isNormalized,this.stream=e.stream,this.isInstanced=e.isInstanced,this.location=e.location,this},e}()),qs=e("al",function(){function e(e,t,n,i,o,r,a,s,c,l){void 0===e&&(e=""),void 0===t&&(t=[]),void 0===n&&(n=[]),void 0===i&&(i=[]),void 0===o&&(o=[]),void 0===r&&(r=[]),void 0===a&&(a=[]),void 0===s&&(s=[]),void 0===c&&(c=[]),void 0===l&&(l=[]),this.name=e,this.stages=t,this.attributes=n,this.blocks=i,this.buffers=o,this.samplerTextures=r,this.samplers=a,this.textures=s,this.images=c,this.subpassInputs=l}return e.prototype.copy=function(e){return this.name=e.name,fs(this.stages,e.stages,Ws),fs(this.attributes,e.attributes,js),fs(this.blocks,e.blocks,zs),fs(this.buffers,e.buffers,Vs),fs(this.samplerTextures,e.samplerTextures,Bs),fs(this.samplers,e.samplers,Us),fs(this.textures,e.textures,Hs),fs(this.images,e.images,Gs),fs(this.subpassInputs,e.subpassInputs,ks),this},e}()),Ys=e("am",function(){function e(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}return e.prototype.copy=function(e){return fs(this.attributes,e.attributes,js),this.vertexBuffers=e.vertexBuffers.slice(),this.indexBuffer=e.indexBuffer,this.indirectBuffer=e.indirectBuffer,this},e}()),Xs=e("an",function(){function e(e,t,n,i,o,r){void 0===e&&(e=Oa.UNKNOWN),void 0===t&&(t=Va.X1),void 0===n&&(n=Za.CLEAR),void 0===i&&(i=Ja.STORE),void 0===o&&(o=[]),void 0===r&&(r=[$a.PRESENT]),this.format=e,this.sampleCount=t,this.loadOp=n,this.storeOp=i,this.beginAccesses=o,this.endAccesses=r}return e.prototype.copy=function(e){return this.format=e.format,this.sampleCount=e.sampleCount,this.loadOp=e.loadOp,this.storeOp=e.storeOp,this.beginAccesses=e.beginAccesses.slice(),this.endAccesses=e.endAccesses.slice(),this},e}()),Ks=e("ao",function(){function e(e,t,n,i,o,r,a,s){void 0===e&&(e=Oa.UNKNOWN),void 0===t&&(t=Va.X1),void 0===n&&(n=Za.CLEAR),void 0===i&&(i=Ja.STORE),void 0===o&&(o=Za.CLEAR),void 0===r&&(r=Ja.STORE),void 0===a&&(a=[]),void 0===s&&(s=[$a.DEPTH_STENCIL_ATTACHMENT_WRITE]),this.format=e,this.sampleCount=t,this.depthLoadOp=n,this.depthStoreOp=i,this.stencilLoadOp=o,this.stencilStoreOp=r,this.beginAccesses=a,this.endAccesses=s}return e.prototype.copy=function(e){return this.format=e.format,this.sampleCount=e.sampleCount,this.depthLoadOp=e.depthLoadOp,this.depthStoreOp=e.depthStoreOp,this.stencilLoadOp=e.stencilLoadOp,this.stencilStoreOp=e.stencilStoreOp,this.beginAccesses=e.beginAccesses.slice(),this.endAccesses=e.endAccesses.slice(),this},e}()),Qs=e("ap",function(){function e(e,t,n,i,o){void 0===e&&(e=[]),void 0===t&&(t=[]),void 0===n&&(n=[]),void 0===i&&(i=[]),void 0===o&&(o=-1),this.inputs=e,this.colors=t,this.resolves=n,this.preserves=i,this.depthStencil=o}return e.prototype.copy=function(e){return this.inputs=e.inputs.slice(),this.colors=e.colors.slice(),this.resolves=e.resolves.slice(),this.preserves=e.preserves.slice(),this.depthStencil=e.depthStencil,this},e}()),Zs=e("aq",function(){function e(e,t,n){void 0===e&&(e=[]),void 0===t&&(t=new Ks),void 0===n&&(n=[]),this.colorAttachments=e,this.depthStencilAttachment=t,this.subpasses=n}return e.prototype.copy=function(e){return fs(this.colorAttachments,e.colorAttachments,Xs),this.depthStencilAttachment.copy(e.depthStencilAttachment),fs(this.subpasses,e.subpasses,Qs),this},e}()),Js=e("ar",function(){function e(e,t){void 0===e&&(e=[]),void 0===t&&(t=[]),this.prevAccesses=e,this.nextAccesses=t}return e.prototype.copy=function(e){return this.prevAccesses=e.prevAccesses.slice(),this.nextAccesses=e.nextAccesses.slice(),this},e}()),$s=e("as",function(){function e(e,t,n,i,o){void 0===e&&(e=[]),void 0===t&&(t=[]),void 0===n&&(n=!1),void 0===i&&(i=null),void 0===o&&(o=null),this.prevAccesses=e,this.nextAccesses=t,this.discardContents=n,this.srcQueue=i,this.dstQueue=o}return e.prototype.copy=function(e){return this.prevAccesses=e.prevAccesses.slice(),this.nextAccesses=e.nextAccesses.slice(),this.discardContents=e.discardContents,this.srcQueue=e.srcQueue,this.dstQueue=e.dstQueue,this},e}()),ec=e("at",function(){function e(e,t,n,i,o){void 0===e&&(e=null),void 0===t&&(t=[]),void 0===n&&(n=null),void 0===i&&(i=[]),void 0===o&&(o=0),this.renderPass=e,this.colorTextures=t,this.depthStencilTexture=n,this.colorMipmapLevels=i,this.depthStencilMipmapLevel=o}return e.prototype.copy=function(e){return this.renderPass=e.renderPass,this.colorTextures=e.colorTextures.slice(),this.depthStencilTexture=e.depthStencilTexture,this.colorMipmapLevels=e.colorMipmapLevels.slice(),this.depthStencilMipmapLevel=e.depthStencilMipmapLevel,this},e}()),tc=e("au",function(){function e(e,t,n,i,o){void 0===e&&(e=-1),void 0===t&&(t=ss.UNKNOWN),void 0===n&&(n=0),void 0===i&&(i=Qa.NONE),void 0===o&&(o=[]),this.binding=e,this.descriptorType=t,this.count=n,this.stageFlags=i,this.immutableSamplers=o}return e.prototype.copy=function(e){return this.binding=e.binding,this.descriptorType=e.descriptorType,this.count=e.count,this.stageFlags=e.stageFlags,this.immutableSamplers=e.immutableSamplers.slice(),this},e}()),nc=e("av",function(){function e(e){void 0===e&&(e=[]),this.bindings=e}return e.prototype.copy=function(e){return fs(this.bindings,e.bindings,tc),this},e}()),ic=e("aw",function(){function e(e){void 0===e&&(e=null),this.layout=e}return e.prototype.copy=function(e){return this.layout=e.layout,this},e}()),oc=e("ax",function(){function e(e){void 0===e&&(e=[]),this.setLayouts=e}return e.prototype.copy=function(e){return this.setLayouts=e.setLayouts.slice(),this},e}()),rc=e("ay",function(){function e(e){void 0===e&&(e=[]),this.attributes=e}return e.prototype.copy=function(e){return fs(this.attributes,e.attributes,js),this},e}()),ac=e("az",function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t=ls.PRIMARY),this.queue=e,this.type=t}return e.prototype.copy=function(e){return this.queue=e.queue,this.type=e.type,this},e}()),sc=e("aA",function(){function e(e){void 0===e&&(e=cs.GRAPHICS),this.type=e}return e.prototype.copy=function(e){return this.type=e.type,this},e}()),cc=e("aB",(function(e,t,n,i,o,r,a,s){void 0===e&&(e=""),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=Da.NONE),void 0===o&&(o=!1),void 0===r&&(r=!1),void 0===a&&(a=!1),void 0===s&&(s=!1),this.name=e,this.size=t,this.count=n,this.type=i,this.hasAlpha=o,this.hasDepth=r,this.hasStencil=a,this.isCompressed=s})),lc=e("aC",function(){function e(e,t){void 0===e&&(e=0),void 0===t&&(t=0),this.bufferSize=e,this.textureSize=t}return e.prototype.copy=function(e){return this.bufferSize=e.bufferSize,this.textureSize=e.textureSize,this},e}()),uc=e("aD",function(){function e(e){this._gfxType=Ia.UNKNOWN,this._gfxType=e}return te(e,[{key:"gfxType",get:function(){return this._gfxType}}]),e}()),hc=e("aE",(function(e,t,n,i,o,r,a){void 0===t&&(t=!0),void 0===n&&(n=!0),void 0===i&&(i=1),void 0===o&&(o=1),void 0===r&&(r=1),void 0===a&&(a=new Is),this.canvasElm=e,this.isAntialias=t,this.isPremultipliedAlpha=n,this.devicePixelRatio=i,this.nativeWidth=o,this.nativeHeight=r,this.bindingMappingInfo=a}));!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"}(ds||(ds=e("aF",{})));var _c=e("aG",Object.freeze([new cc("UNKNOWN",0,0,Da.NONE,!1,!1,!1,!1),new cc("A8",1,1,Da.UNORM,!0,!1,!1,!1),new cc("L8",1,1,Da.UNORM,!1,!1,!1,!1),new cc("LA8",1,2,Da.UNORM,!0,!1,!1,!1),new cc("R8",1,1,Da.UNORM,!1,!1,!1,!1),new cc("R8SN",1,1,Da.SNORM,!1,!1,!1,!1),new cc("R8UI",1,1,Da.UINT,!1,!1,!1,!1),new cc("R8I",1,1,Da.INT,!1,!1,!1,!1),new cc("R16F",2,1,Da.FLOAT,!1,!1,!1,!1),new cc("R16UI",2,1,Da.UINT,!1,!1,!1,!1),new cc("R16I",2,1,Da.INT,!1,!1,!1,!1),new cc("R32F",4,1,Da.FLOAT,!1,!1,!1,!1),new cc("R32UI",4,1,Da.UINT,!1,!1,!1,!1),new cc("R32I",4,1,Da.INT,!1,!1,!1,!1),new cc("RG8",2,2,Da.UNORM,!1,!1,!1,!1),new cc("RG8SN",2,2,Da.SNORM,!1,!1,!1,!1),new cc("RG8UI",2,2,Da.UINT,!1,!1,!1,!1),new cc("RG8I",2,2,Da.INT,!1,!1,!1,!1),new cc("RG16F",4,2,Da.FLOAT,!1,!1,!1,!1),new cc("RG16UI",4,2,Da.UINT,!1,!1,!1,!1),new cc("RG16I",4,2,Da.INT,!1,!1,!1,!1),new cc("RG32F",8,2,Da.FLOAT,!1,!1,!1,!1),new cc("RG32UI",8,2,Da.UINT,!1,!1,!1,!1),new cc("RG32I",8,2,Da.INT,!1,!1,!1,!1),new cc("RGB8",3,3,Da.UNORM,!1,!1,!1,!1),new cc("SRGB8",3,3,Da.UNORM,!1,!1,!1,!1),new cc("RGB8SN",3,3,Da.SNORM,!1,!1,!1,!1),new cc("RGB8UI",3,3,Da.UINT,!1,!1,!1,!1),new cc("RGB8I",3,3,Da.INT,!1,!1,!1,!1),new cc("RGB16F",6,3,Da.FLOAT,!1,!1,!1,!1),new cc("RGB16UI",6,3,Da.UINT,!1,!1,!1,!1),new cc("RGB16I",6,3,Da.INT,!1,!1,!1,!1),new cc("RGB32F",12,3,Da.FLOAT,!1,!1,!1,!1),new cc("RGB32UI",12,3,Da.UINT,!1,!1,!1,!1),new cc("RGB32I",12,3,Da.INT,!1,!1,!1,!1),new cc("RGBA8",4,4,Da.UNORM,!0,!1,!1,!1),new cc("BGRA8",4,4,Da.UNORM,!0,!1,!1,!1),new cc("SRGB8_A8",4,4,Da.UNORM,!0,!1,!1,!1),new cc("RGBA8SN",4,4,Da.SNORM,!0,!1,!1,!1),new cc("RGBA8UI",4,4,Da.UINT,!0,!1,!1,!1),new cc("RGBA8I",4,4,Da.INT,!0,!1,!1,!1),new cc("RGBA16F",8,4,Da.FLOAT,!0,!1,!1,!1),new cc("RGBA16UI",8,4,Da.UINT,!0,!1,!1,!1),new cc("RGBA16I",8,4,Da.INT,!0,!1,!1,!1),new cc("RGBA32F",16,4,Da.FLOAT,!0,!1,!1,!1),new cc("RGBA32UI",16,4,Da.UINT,!0,!1,!1,!1),new cc("RGBA32I",16,4,Da.INT,!0,!1,!1,!1),new cc("R5G6B5",2,3,Da.UNORM,!1,!1,!1,!1),new cc("R11G11B10F",4,3,Da.FLOAT,!1,!1,!1,!1),new cc("RGB5A1",2,4,Da.UNORM,!0,!1,!1,!1),new cc("RGBA4",2,4,Da.UNORM,!0,!1,!1,!1),new cc("RGB10A2",2,4,Da.UNORM,!0,!1,!1,!1),new cc("RGB10A2UI",2,4,Da.UINT,!0,!1,!1,!1),new cc("RGB9E5",2,4,Da.FLOAT,!0,!1,!1,!1),new cc("D16",2,1,Da.UINT,!1,!0,!1,!1),new cc("D16S8",3,2,Da.UINT,!1,!0,!0,!1),new cc("D24",3,1,Da.UINT,!1,!0,!1,!1),new cc("D24S8",4,2,Da.UINT,!1,!0,!0,!1),new cc("D32F",4,1,Da.FLOAT,!1,!0,!1,!1),new cc("D32FS8",5,2,Da.FLOAT,!1,!0,!0,!1),new cc("BC1",1,3,Da.UNORM,!1,!1,!1,!0),new cc("BC1_ALPHA",1,4,Da.UNORM,!0,!1,!1,!0),new cc("BC1_SRGB",1,3,Da.UNORM,!1,!1,!1,!0),new cc("BC1_SRGB_ALPHA",1,4,Da.UNORM,!0,!1,!1,!0),new cc("BC2",1,4,Da.UNORM,!0,!1,!1,!0),new cc("BC2_SRGB",1,4,Da.UNORM,!0,!1,!1,!0),new cc("BC3",1,4,Da.UNORM,!0,!1,!1,!0),new cc("BC3_SRGB",1,4,Da.UNORM,!0,!1,!1,!0),new cc("BC4",1,1,Da.UNORM,!1,!1,!1,!0),new cc("BC4_SNORM",1,1,Da.SNORM,!1,!1,!1,!0),new cc("BC5",1,2,Da.UNORM,!1,!1,!1,!0),new cc("BC5_SNORM",1,2,Da.SNORM,!1,!1,!1,!0),new cc("BC6H_UF16",1,3,Da.UFLOAT,!1,!1,!1,!0),new cc("BC6H_SF16",1,3,Da.FLOAT,!1,!1,!1,!0),new cc("BC7",1,4,Da.UNORM,!0,!1,!1,!0),new cc("BC7_SRGB",1,4,Da.UNORM,!0,!1,!1,!0),new cc("ETC_RGB8",1,3,Da.UNORM,!1,!1,!1,!0),new cc("ETC2_RGB8",1,3,Da.UNORM,!1,!1,!1,!0),new cc("ETC2_SRGB8",1,3,Da.UNORM,!1,!1,!1,!0),new cc("ETC2_RGB8_A1",1,4,Da.UNORM,!0,!1,!1,!0),new cc("ETC2_SRGB8_A1",1,4,Da.UNORM,!0,!1,!1,!0),new cc("ETC2_RGBA8",2,4,Da.UNORM,!0,!1,!1,!0),new cc("ETC2_SRGB8_A8",2,4,Da.UNORM,!0,!1,!1,!0),new cc("EAC_R11",1,1,Da.UNORM,!1,!1,!1,!0),new cc("EAC_R11SN",1,1,Da.SNORM,!1,!1,!1,!0),new cc("EAC_RG11",2,2,Da.UNORM,!1,!1,!1,!0),new cc("EAC_RG11SN",2,2,Da.SNORM,!1,!1,!1,!0),new cc("PVRTC_RGB2",2,3,Da.UNORM,!1,!1,!1,!0),new cc("PVRTC_RGBA2",2,4,Da.UNORM,!0,!1,!1,!0),new cc("PVRTC_RGB4",2,3,Da.UNORM,!1,!1,!1,!0),new cc("PVRTC_RGBA4",2,4,Da.UNORM,!0,!1,!1,!0),new cc("PVRTC2_2BPP",2,4,Da.UNORM,!0,!1,!1,!0),new cc("PVRTC2_4BPP",2,4,Da.UNORM,!0,!1,!1,!0),new cc("ASTC_RGBA_4x4",1,4,Da.UNORM,!0,!1,!1,!0),new cc("ASTC_RGBA_5x4",1,4,Da.UNORM,!0,!1,!1,!0),new cc("ASTC_RGBA_5x5",1,4,Da.UNORM,!0,!1,!1,!0),new cc("ASTC_RGBA_6x5",1,4,Da.UNORM,!0,!1,!1,!0),new cc("ASTC_RGBA_6x6",1,4,Da.UNORM,!0,!1,!1,!0),new cc("ASTC_RGBA_8x5",1,4,Da.UNORM,!0,!1,!1,!0),new cc("ASTC_RGBA_8x6",1,4,Da.UNORM,!0,!1,!1,!0),new cc("ASTC_RGBA_8x8",1,4,Da.UNORM,!0,!1,!1,!0),new cc("ASTC_RGBA_10x5",1,4,Da.UNORM,!0,!1,!1,!0),new cc("ASTC_RGBA_10x6",1,4,Da.UNORM,!0,!1,!1,!0),new cc("ASTC_RGBA_10x8",1,4,Da.UNORM,!0,!1,!1,!0),new cc("ASTC_RGBA_10x10",1,4,Da.UNORM,!0,!1,!1,!0),new cc("ASTC_RGBA_12x10",1,4,Da.UNORM,!0,!1,!1,!0),new cc("ASTC_RGBA_12x12",1,4,Da.UNORM,!0,!1,!1,!0),new cc("ASTC_SRGBA_4x4",1,4,Da.UNORM,!0,!1,!1,!0),new cc("ASTC_SRGBA_5x4",1,4,Da.UNORM,!0,!1,!1,!0),new cc("ASTC_SRGBA_5x5",1,4,Da.UNORM,!0,!1,!1,!0),new cc("ASTC_SRGBA_6x5",1,4,Da.UNORM,!0,!1,!1,!0),new cc("ASTC_SRGBA_6x6",1,4,Da.UNORM,!0,!1,!1,!0),new cc("ASTC_SRGBA_8x5",1,4,Da.UNORM,!0,!1,!1,!0),new cc("ASTC_SRGBA_8x6",1,4,Da.UNORM,!0,!1,!1,!0),new cc("ASTC_SRGBA_8x8",1,4,Da.UNORM,!0,!1,!1,!0),new cc("ASTC_SRGBA_10x5",1,4,Da.UNORM,!0,!1,!1,!0),new cc("ASTC_SRGBA_10x6",1,4,Da.UNORM,!0,!1,!1,!0),new cc("ASTC_SRGBA_10x8",1,4,Da.UNORM,!0,!1,!1,!0),new cc("ASTC_SRGBA_10x10",1,4,Da.UNORM,!0,!1,!1,!0),new cc("ASTC_SRGBA_12x10",1,4,Da.UNORM,!0,!1,!1,!0),new cc("ASTC_SRGBA_12x12",1,4,Da.UNORM,!0,!1,!1,!0)])),fc=e("aH",ss.UNIFORM_BUFFER|ss.DYNAMIC_UNIFORM_BUFFER|ss.STORAGE_BUFFER|ss.DYNAMIC_STORAGE_BUFFER),dc=e("aI",ss.SAMPLER_TEXTURE|ss.SAMPLER|ss.TEXTURE|ss.STORAGE_IMAGE|ss.INPUT_ATTACHMENT),pc=e("aJ",ss.DYNAMIC_STORAGE_BUFFER|ss.DYNAMIC_UNIFORM_BUFFER),mc=e("aK",28);function vc(e){return e>0&&0==(e&e-1)}function gc(e,t,n,i){if(!_c[e].isCompressed)return t*n*i*_c[e].size;switch(e){case Oa.BC1:case Oa.BC1_ALPHA:case Oa.BC1_SRGB:case Oa.BC1_SRGB_ALPHA:return Math.ceil(t/4)*Math.ceil(n/4)*8*i;case Oa.BC2:case Oa.BC2_SRGB:case Oa.BC3:case Oa.BC3_SRGB:case Oa.BC4:case Oa.BC4_SNORM:case Oa.BC6H_SF16:case Oa.BC6H_UF16:case Oa.BC7:case Oa.BC7_SRGB:return Math.ceil(t/4)*Math.ceil(n/4)*16*i;case Oa.BC5:case Oa.BC5_SNORM:return Math.ceil(t/4)*Math.ceil(n/4)*32*i;case Oa.ETC_RGB8:case Oa.ETC2_RGB8:case Oa.ETC2_SRGB8:case Oa.ETC2_RGB8_A1:case Oa.EAC_R11:case Oa.EAC_R11SN:return Math.ceil(t/4)*Math.ceil(n/4)*8*i;case Oa.ETC2_RGBA8:case Oa.ETC2_SRGB8_A1:case Oa.EAC_RG11:case Oa.EAC_RG11SN:return Math.ceil(t/4)*Math.ceil(n/4)*16*i;case Oa.PVRTC_RGB2:case Oa.PVRTC_RGBA2:case Oa.PVRTC2_2BPP:return Math.ceil(Math.max(t,16)*Math.max(n,8)/4)*i;case Oa.PVRTC_RGB4:case Oa.PVRTC_RGBA4:case Oa.PVRTC2_4BPP:return Math.ceil(Math.max(t,8)*Math.max(n,8)/2)*i;case Oa.ASTC_RGBA_4x4:case Oa.ASTC_SRGBA_4x4:return Math.ceil(t/4)*Math.ceil(n/4)*16*i;case Oa.ASTC_RGBA_5x4:case Oa.ASTC_SRGBA_5x4:return Math.ceil(t/5)*Math.ceil(n/4)*16*i;case Oa.ASTC_RGBA_5x5:case Oa.ASTC_SRGBA_5x5:return Math.ceil(t/5)*Math.ceil(n/5)*16*i;case Oa.ASTC_RGBA_6x5:case Oa.ASTC_SRGBA_6x5:return Math.ceil(t/6)*Math.ceil(n/5)*16*i;case Oa.ASTC_RGBA_6x6:case Oa.ASTC_SRGBA_6x6:return Math.ceil(t/6)*Math.ceil(n/6)*16*i;case Oa.ASTC_RGBA_8x5:case Oa.ASTC_SRGBA_8x5:return Math.ceil(t/8)*Math.ceil(n/5)*16*i;case Oa.ASTC_RGBA_8x6:case Oa.ASTC_SRGBA_8x6:return Math.ceil(t/8)*Math.ceil(n/6)*16*i;case Oa.ASTC_RGBA_8x8:case Oa.ASTC_SRGBA_8x8:return Math.ceil(t/8)*Math.ceil(n/8)*16*i;case Oa.ASTC_RGBA_10x5:case Oa.ASTC_SRGBA_10x5:return Math.ceil(t/10)*Math.ceil(n/5)*16*i;case Oa.ASTC_RGBA_10x6:case Oa.ASTC_SRGBA_10x6:return Math.ceil(t/10)*Math.ceil(n/6)*16*i;case Oa.ASTC_RGBA_10x8:case Oa.ASTC_SRGBA_10x8:return Math.ceil(t/10)*Math.ceil(n/8)*16*i;case Oa.ASTC_RGBA_10x10:case Oa.ASTC_SRGBA_10x10:return Math.ceil(t/10)*Math.ceil(n/10)*16*i;case Oa.ASTC_RGBA_12x10:case Oa.ASTC_SRGBA_12x10:return Math.ceil(t/12)*Math.ceil(n/10)*16*i;case Oa.ASTC_RGBA_12x12:case Oa.ASTC_SRGBA_12x12:return Math.ceil(t/12)*Math.ceil(n/12)*16*i;default:return 0}}function yc(e,t,n,i,o){for(var r=0,a=0;a<o;++a)r+=gc(e,t,n,i),t=Math.max(t>>1,1),n=Math.max(n>>1,1);return r}var xc=[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 Ec(e){return xc[e]||0}function Sc(e){var t=e.size/e.count;switch(e.type){case Da.UNORM:case Da.UINT:switch(t){case 1:return Uint8Array;case 2:return Uint16Array;case 4:return Uint32Array}break;case Da.SNORM:case Da.INT:switch(t){case 1:return Int8Array;case 2:return Int16Array;case 4:return Int32Array}break;case Da.FLOAT:return Float32Array}return Float32Array}var Tc=Object.freeze({__proto__:null,get ObjectType(){return Ia},get Status(){return Pa},get API(){return ba},get SurfaceTransform(){return Ra},get Feature(){return Na},get Format(){return Oa},get FormatType(){return Da},get Type(){return Ma},get BufferUsageBit(){return La},get BufferFlagBit(){return Fa},get MemoryAccessBit(){return za},get MemoryUsageBit(){return Ba},get TextureType(){return Ua},get TextureUsageBit(){return Ha},get TextureFlagBit(){return Ga},get SampleCount(){return Va},get Filter(){return ka},get Address(){return Wa},get ComparisonFunc(){return ja},get StencilOp(){return qa},get BlendFactor(){return Ya},get BlendOp(){return Xa},get ColorMask(){return Ka},get ShaderStageFlagBit(){return Qa},get LoadOp(){return Za},get StoreOp(){return Ja},get AccessType(){return $a},get PipelineBindPoint(){return es},get PrimitiveMode(){return ts},get PolygonMode(){return ns},get ShadeModel(){return is},get CullMode(){return os},get DynamicStateFlagBit(){return rs},get StencilFace(){return as},get DescriptorType(){return ss},get QueueType(){return cs},get CommandBufferType(){return ls},get ClearFlagBit(){return us},Size:ps,DeviceCaps:ms,Offset:vs,Rect:gs,Extent:ys,TextureSubresLayers:xs,TextureSubresRange:Es,TextureCopy:Ss,TextureBlit:Ts,BufferTextureCopy:As,Viewport:ws,Color:Cs,BindingMappingInfo:Is,BufferInfo:Ps,BufferViewInfo:bs,DrawInfo:Rs,DispatchInfo:Ns,IndirectBuffer:Os,TextureInfo:Ds,TextureViewInfo:Ms,SamplerInfo:Ls,Uniform:Fs,UniformBlock:zs,UniformSamplerTexture:Bs,UniformSampler:Us,UniformTexture:Hs,UniformStorageImage:Gs,UniformStorageBuffer:Vs,UniformInputAttachment:ks,ShaderStage:Ws,Attribute:js,ShaderInfo:qs,InputAssemblerInfo:Ys,ColorAttachment:Xs,DepthStencilAttachment:Ks,SubpassInfo:Qs,RenderPassInfo:Zs,GlobalBarrierInfo:Js,TextureBarrierInfo:$s,FramebufferInfo:ec,DescriptorSetLayoutBinding:tc,DescriptorSetLayoutInfo:nc,DescriptorSetInfo:ic,PipelineLayoutInfo:oc,InputState:rc,CommandBufferInfo:ac,QueueInfo:sc,FormatInfo:cc,MemoryStatus:lc,Obj:uc,DeviceInfo:hc,get AttributeName(){return ds},FormatInfos:_c,DESCRIPTOR_BUFFER_TYPE:fc,DESCRIPTOR_SAMPLER_TYPE:dc,DESCRIPTOR_DYNAMIC_TYPE:pc,DRAW_INFO_SIZE:mc,IsPowerOf2:vc,FormatSize:gc,FormatSurfaceSize:yc,GetTypeSize:Ec,getTypedArrayConstructor:Sc}),Ac=e("B",function(e){function t(t){var n;return(n=e.call(this,Ia.BUFFER)||this)._device=void 0,n._usage=La.NONE,n._memUsage=Ba.NONE,n._size=0,n._stride=1,n._count=0,n._flags=Fa.NONE,n._indirectBuffer=null,n._isBufferView=!1,n._device=t,n}return ie(t,e),te(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}}]),t}(uc)),wc=e("a",function(e){function t(t){var n;return(n=e.call(this,Ia.COMMAND_BUFFER)||this)._device=void 0,n._queue=null,n._type=ls.PRIMARY,n._numDrawCalls=0,n._numInstances=0,n._numTris=0,n._device=t,n}return ie(t,e),te(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}(uc));ht(Oa);var Cc=e("aQ",function(){function e(){this._canvas=null,this._canvas2D=null,this._gfxAPI=ba.UNKNOWN,this._transform=Ra.IDENTITY,this._deviceName="",this._renderer="",this._vendor="",this._version="",this._features=new Array(Na.COUNT),this._queue=null,this._cmdBuff=null,this._devicePixelRatio=1,this._width=0,this._height=0,this._nativeWidth=0,this._nativeHeight=0,this._colorFmt=Oa.UNKNOWN,this._depthStencilFmt=Oa.UNKNOWN,this._numDrawCalls=0,this._numInstances=0,this._numTris=0,this._memoryStatus=new lc,this._caps=new ms}return e.prototype.hasFeature=function(e){return this._features[e]},te(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:"colorFormat",get:function(){return this._colorFmt}},{key:"depthStencilFormat",get:function(){return this._depthStencilFmt}},{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:"capabilities",get:function(){return this._caps}},{key:"surfaceTransform",get:function(){return this._transform}}]),e}()),Ic=e("aR",function(e){function t(t){var n;return(n=e.call(this,Ia.FRAMEBUFFER)||this)._device=void 0,n._renderPass=null,n._colorTextures=[],n._depthStencilTexture=null,n._device=t,n}return ie(t,e),te(t,[{key:"renderPass",get:function(){return this._renderPass}},{key:"colorTextures",get:function(){return this._colorTextures}},{key:"depthStencilTexture",get:function(){return this._depthStencilTexture}}]),t}(uc)),Pc=String.prototype.charCodeAt;function bc(e){return this[e]}function Rc(e,t){for(var n=e.length,i=t^n,o=0,r="string"==typeof e?Pc:bc;n>=4;){var a=255&r.call(e,o)|(255&r.call(e,++o))<<8|(255&r.call(e,++o))<<16|(255&r.call(e,++o))<<24;a=1540483477*(65535&a)+((1540483477*(a>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(a=1540483477*(65535&(a^=a>>>24))+((1540483477*(a>>>16)&65535)<<16)),n-=4,++o}switch(n){case 3:i^=(255&r.call(e,o+2))<<16;case 2:i^=(255&r.call(e,o+1))<<8;case 1:i=1540483477*(65535&(i^=255&r.call(e,o)))+((1540483477*(i>>>16)&65535)<<16)}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0}var Nc=e("aS",function(e){function t(t){var n;return(n=e.call(this,Ia.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}ie(t,e);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 Rc(e,666)},te(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}}]),t}(uc)),Oc=e("D",function(e){function t(t){var n;return(n=e.call(this,Ia.DESCRIPTOR_SET)||this)._device=void 0,n._layout=null,n._buffers=[],n._textures=[],n._samplers=[],n._isDirty=!1,n._device=t,n}ie(t,e);var n=t.prototype;return n.bindBuffer=function(e,t,n){void 0===n&&(n=0);var i=this._layout.bindingIndices[e],o=this._layout.bindings[i];if(o)if(o.descriptorType&fc){var r=this._layout.descriptorIndices[e];this._buffers[r+n]!==t&&(this._buffers[r+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],o=this._layout.bindings[i];if(o)if(o.descriptorType&dc){var r=this._layout.descriptorIndices[e];this._samplers[r+n]!==t&&(this._samplers[r+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],o=this._layout.bindings[i];if(o)if(o.descriptorType&dc){var r=this._layout.descriptorIndices[e];this._textures[r+n]!==t&&(this._textures[r+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]},te(t,[{key:"layout",get:function(){return this._layout}}]),t}(uc)),Dc=e("aT",function(e){function t(t){var n;return(n=e.call(this,Ia.DESCRIPTOR_SET_LAYOUT)||this)._device=void 0,n._bindings=[],n._bindingIndices=[],n._descriptorIndices=[],n._device=t,n}return ie(t,e),te(t,[{key:"bindings",get:function(){return this._bindings}},{key:"bindingIndices",get:function(){return this._bindingIndices}},{key:"descriptorIndices",get:function(){return this._descriptorIndices}}]),t}(uc)),Mc=e("aU",function(e){function t(t){var n;return(n=e.call(this,Ia.PIPELINE_LAYOUT)||this)._device=void 0,n._setLayouts=[],n._device=t,n}return ie(t,e),te(t,[{key:"setLayouts",get:function(){return this._setLayouts}}]),t}(uc)),Lc=e("aV",function(){function e(e,t,n,i,o,r,a,s,c,l,u,h){void 0===e&&(e=!1),void 0===t&&(t=ns.FILL),void 0===n&&(n=is.GOURAND),void 0===i&&(i=os.BACK),void 0===o&&(o=!0),void 0===r&&(r=!1),void 0===a&&(a=0),void 0===s&&(s=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=o,this.depthBiasEnabled=r,this.depthBias=a,this.depthBiasClamp=s,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=ns.FILL,this.shadeModel=is.GOURAND,this.cullMode=os.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(){},te(e,[{key:"handle",get:function(){return bo}}]),e}()),Fc=e("aW",function(){function e(e,t,n,i,o,r,a,s,c,l,u,h,_,f,d,p,m,v,g){void 0===e&&(e=!0),void 0===t&&(t=!0),void 0===n&&(n=ja.LESS),void 0===i&&(i=!1),void 0===o&&(o=ja.ALWAYS),void 0===r&&(r=65535),void 0===a&&(a=65535),void 0===s&&(s=qa.KEEP),void 0===c&&(c=qa.KEEP),void 0===l&&(l=qa.KEEP),void 0===u&&(u=1),void 0===h&&(h=!1),void 0===_&&(_=ja.ALWAYS),void 0===f&&(f=65535),void 0===d&&(d=65535),void 0===p&&(p=qa.KEEP),void 0===m&&(m=qa.KEEP),void 0===v&&(v=qa.KEEP),void 0===g&&(g=1),this.depthTest=e,this.depthWrite=t,this.depthFunc=n,this.stencilTestFront=i,this.stencilFuncFront=o,this.stencilReadMaskFront=r,this.stencilWriteMaskFront=a,this.stencilFailOpFront=s,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=v,this.stencilRefBack=g}var t=e.prototype;return t.reset=function(){this.depthTest=!0,this.depthWrite=!0,this.depthFunc=ja.LESS,this.stencilTestFront=!1,this.stencilFuncFront=ja.ALWAYS,this.stencilReadMaskFront=65535,this.stencilWriteMaskFront=65535,this.stencilFailOpFront=qa.KEEP,this.stencilZFailOpFront=qa.KEEP,this.stencilPassOpFront=qa.KEEP,this.stencilRefFront=1,this.stencilTestBack=!1,this.stencilFuncBack=ja.ALWAYS,this.stencilReadMaskBack=65535,this.stencilWriteMaskBack=65535,this.stencilFailOpBack=qa.KEEP,this.stencilZFailOpBack=qa.KEEP,this.stencilPassOpBack=qa.KEEP,this.stencilRefBack=1},t.assign=function(e){Object.assign(this,e)},t.destroy=function(){},te(e,[{key:"handle",get:function(){return bo}}]),e}()),zc=e("aX",function(){function e(e,t,n,i,o,r,a,s){void 0===e&&(e=!1),void 0===t&&(t=Ya.ONE),void 0===n&&(n=Ya.ZERO),void 0===i&&(i=Xa.ADD),void 0===o&&(o=Ya.ONE),void 0===r&&(r=Ya.ZERO),void 0===a&&(a=Xa.ADD),void 0===s&&(s=Ka.ALL),this.blend=e,this.blendSrc=t,this.blendDst=n,this.blendEq=i,this.blendSrcAlpha=o,this.blendDstAlpha=r,this.blendAlphaEq=a,this.blendColorMask=s}var t=e.prototype;return t.reset=function(){this.blend=!1,this.blendSrc=Ya.ONE,this.blendDst=Ya.ZERO,this.blendEq=Xa.ADD,this.blendSrcAlpha=Ya.ONE,this.blendDstAlpha=Ya.ZERO,this.blendAlphaEq=Xa.ADD,this.blendColorMask=Ka.ALL},t.assign=function(e){Object.assign(this,e)},t.destroy=function(){},te(e,[{key:"handle",get:function(){return bo}}]),e}()),Bc=e("aY",function(){function e(e,t,n,i){void 0===e&&(e=!1),void 0===t&&(t=!1),void 0===n&&(n=new Cs),void 0===i&&(i=[new zc]),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 zc),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(){},te(e,[{key:"handle",get:function(){return bo}}]),e}()),Uc=e("aZ",(function(e,t,n,i,o,r,a,s,c,l){void 0===e&&(e=null),void 0===t&&(t=null),void 0===n&&(n=null),void 0===i&&(i=new rc),void 0===o&&(o=new Lc),void 0===r&&(r=new Fc),void 0===a&&(a=new Bc),void 0===s&&(s=ts.TRIANGLE_LIST),void 0===c&&(c=rs.NONE),void 0===l&&(l=es.GRAPHICS),this.shader=e,this.pipelineLayout=t,this.renderPass=n,this.inputState=i,this.rasterizerState=o,this.depthStencilState=r,this.blendState=a,this.primitive=s,this.dynamicStates=c,this.bindPoint=l})),Hc=e("a_",function(e){function t(t){var n;return(n=e.call(this,Ia.PIPELINE_STATE)||this)._device=void 0,n._shader=null,n._pipelineLayout=null,n._primitive=ts.TRIANGLE_LIST,n._is=null,n._rs=new Lc,n._dss=new Fc,n._bs=new Bc,n._dynamicStates=rs.NONE,n._renderPass=null,n._device=t,n}return ie(t,e),te(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}(uc)),Gc=e("a$",function(e){function t(t){var n;return(n=e.call(this,Ia.QUEUE)||this)._device=void 0,n._type=cs.GRAPHICS,n._isAsync=!1,n._device=t,n}return ie(t,e),t.prototype.isAsync=function(){return this._isAsync},te(t,[{key:"type",get:function(){return this._type}}]),t}(uc)),Vc=e("b0",function(e){function t(t){var n;return(n=e.call(this,Ia.RENDER_PASS)||this)._device=void 0,n._colorInfos=[],n._depthStencilInfo=null,n._subpasses=[],n._hash=0,n._device=t,n}return ie(t,e),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 o=this._colorInfos[n.inputs[i]];e+=","+o.format+","+o.sampleCount}}if(n.colors.length){e+="ca";for(var r=0;r<n.inputs.length;++r){var a=this._colorInfos[n.inputs[r]];e+=","+a.format+","+a.sampleCount}}if(n.depthStencil>=0){var s=this._colorInfos[n.depthStencil];e+="ds,"+s.format+","+s.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 Rc(e,666)},te(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}(uc)),kc=e("b1",function(e){function t(t){var n;return(n=e.call(this,Ia.SAMPLER)||this)._device=void 0,n._minFilter=ka.LINEAR,n._magFilter=ka.LINEAR,n._mipFilter=ka.NONE,n._addressU=Wa.WRAP,n._addressV=Wa.WRAP,n._addressW=Wa.WRAP,n._maxAnisotropy=16,n._cmpFunc=ja.NEVER,n._borderColor=new Cs,n._mipLODBias=0,n._device=t,n}return ie(t,e),te(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:"mipLODBias",get:function(){return this._mipLODBias}}]),t}(uc)),Wc=e("b2",function(e){function t(n){var i;return(i=e.call(this,Ia.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 ie(t,e),te(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}(uc));Wc._shaderIdGen=0;var jc=e("b3",function(e){function t(t){var n;return(n=e.call(this,Ia.TEXTURE)||this)._device=void 0,n._type=Ua.TEX2D,n._usage=Ha.NONE,n._format=Oa.UNKNOWN,n._width=0,n._height=0,n._depth=1,n._layerCount=1,n._levelCount=1,n._samples=Va.X1,n._flags=Ga.NONE,n._isPowerOf2=!1,n._size=0,n._device=t,n}return ie(t,e),te(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}}]),t}(uc)),qc=e("b4",function(e){function t(t){var n;return(n=e.call(this,Ia.GLOBAL_BARRIER)||this)._device=void 0,n._info=new Js,n._device=t,n}return ie(t,e),t.prototype.initialize=function(e){return this._info.copy(e),!0},t}(uc)),Yc=e("b5",function(e){function t(t){var n;return(n=e.call(this,Ia.TEXTURE_BARRIER)||this)._device=void 0,n._info=new $s,n._device=t,n}return ie(t,e),t.prototype.initialize=function(e){return this._info.copy(e),!0},t}(uc)),Xc={Device:Cc,Buffer:Ac,Texture:jc,Sampler:kc,Shader:Wc,InputAssembler:Nc,RenderPass:Vc,Framebuffer:Ic,DescriptorSet:Oc,DescriptorSetLayout:Dc,PipelineLayout:Mc,PipelineState:Hc,CommandBuffer:wc,Queue:Gc,GlobalBarrier:qc,TextureBarrier:Yc,RasterizerState:Lc,BlendState:Bc,BlendTarget:zc,DepthStencilState:Fc,PipelineStateInfo:Uc};Object.assign(Xc,Tc),c.gfx=Xc;var Kc,Qc={Obj:"GFXObject",DRAW_INFO_SIZE:"GFX_DRAW_INFO_SIZE",DESCRIPTOR_BUFFER_TYPE:"",DESCRIPTOR_SAMPLER_TYPE:"",DESCRIPTOR_DYNAMIC_TYPE:"",getTypedArrayConstructor:""};for(var Zc in c.gfx)if("__esModule"!==Zc){var Jc=Qc[Zc];""===Jc?Jc=Zc:void 0===Jc&&(Jc="GFX"+Zc),q(c,"cc",[{name:Jc,newName:Zc,target:c.gfx,targetName:"cc.gfx"}])}!function(e){e[e.ALL=0]="ALL",e[e.CLOSEST=1]="CLOSEST",e[e.ANY=2]="ANY"}(Kc||(Kc={}));var $c,el,tl,nl,il,ol,rl,al,sl=($c=new Rn(0,0,0),function(e,t){var n=Rn.dot(e.d,t.n);if(Math.abs(n)<Number.EPSILON)return 0;Rn.multiplyScalar($c,t.n,t.d);var i=Rn.dot(Rn.subtract($c,$c,e.o),t.n)/n;return i<0?0:i}),cl=(el=new Rn(0,0,0),tl=new Rn(0,0,0),nl=new Rn(0,0,0),il=new Rn(0,0,0),ol=new Rn(0,0,0),function(e,t,n){Rn.subtract(el,t.b,t.a),Rn.subtract(tl,t.c,t.a),Rn.cross(nl,e.d,tl);var i=Rn.dot(el,nl);if(i<Number.EPSILON&&(!n||i>-Number.EPSILON))return 0;var o=1/i;Rn.subtract(il,e.o,t.a);var r=Rn.dot(il,nl)*o;if(r<0||r>1)return 0;Rn.cross(ol,il,el);var a=Rn.dot(e.d,ol)*o;if(a<0||r+a>1)return 0;var s=Rn.dot(tl,ol)*o;return s<0?0:s}),ll=function(){var e=new Rn(0,0,0);return function(t,n){var i=n.radius,o=n.center,r=t.o,a=t.d,s=i*i;Rn.subtract(e,o,r);var c=e.lengthSqr(),l=Rn.dot(e,a),u=s-(c-l*l);if(u<0)return 0;var h=Math.sqrt(u),_=c<s?l+h:l-h;return _<0?0:_}}(),ul=(rl=new Rn,al=new Rn,function(e,t){return Rn.subtract(rl,t.center,t.halfExtents),Rn.add(al,t.center,t.halfExtents),hl(e,rl,al)});function hl(e,t,n){var i=e.o,o=e.d,r=1/o.x,a=1/o.y,s=1/o.z,c=(t.x-i.x)*r,l=(n.x-i.x)*r,u=(t.y-i.y)*a,h=(n.y-i.y)*a,_=(t.z-i.z)*s,f=(n.z-i.z)*s,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 _l,fl,dl,pl,ml=function(){var e=new Rn,t=new Rn,n=new Rn,i=new Rn,o=new Rn,r=new Rn,a=new Rn,s=new Array(3),c=new Array(3),l=new Array(3),u=new Array(6);return function(h,_){s[0]=_.halfExtents.x,s[1]=_.halfExtents.y,s[2]=_.halfExtents.z,e=_.center,t=h.o,n=h.d,Rn.set(i,_.orientation.m00,_.orientation.m01,_.orientation.m02),Rn.set(o,_.orientation.m03,_.orientation.m04,_.orientation.m05),Rn.set(r,_.orientation.m06,_.orientation.m07,_.orientation.m08),Rn.subtract(a,e,t),c[0]=Rn.dot(i,n),c[1]=Rn.dot(o,n),c[2]=Rn.dot(r,n),l[0]=Rn.dot(i,a),l[1]=Rn.dot(o,a),l[2]=Rn.dot(r,a);for(var f=0;f<3;++f){if(0===c[f]){if(-l[f]-s[f]>0||-l[f]+s[f]<0)return 0;c[f]=1e-7}u[2*f+0]=(l[f]+s[f])/c[f],u[2*f+1]=(l[f]-s[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}}(),vl=function(){var e=new Rn,t=new Rn,n=new Rn,i=new Rn,o=new Rn,r=new Rn,a=new Rn,s=new hs;return function(c,l){var u=l.radius*l.radius,h=Rn.normalize(e,c.d),_=l.ellipseCenter0,f=l.ellipseCenter1,d=Rn.subtract(t,f,_);if(d.equals(Rn.ZERO))return s.radius=l.radius,s.center.set(l.ellipseCenter0),tu.raySphere(c,s);var p=c.o,m=Rn.subtract(n,p,_),v=Rn.cross(i,h,d),g=v.lengthSqr();if(0===g){s.radius=l.radius;var y=Rn.subtract(o,f,p);return m.lengthSqr()<y.lengthSqr()?s.center.set(l.ellipseCenter0):s.center.set(l.ellipseCenter1),tu.raySphere(c,s)}var x=Rn.cross(o,m,d),E=d.lengthSqr(),S=2*Rn.dot(v,x),T=S*S-4*g*(x.lengthSqr()-u*E);if(T<0)return 0;var A=(-S-Math.sqrt(T))/(2*g);if(A<0){s.radius=l.radius;var w=Rn.subtract(r,f,p);return m.lengthSqr()<w.lengthSqr()?s.center.set(l.ellipseCenter0):s.center.set(l.ellipseCenter1),tu.raySphere(c,s)}var C=Rn.scaleAndAdd(r,c.o,h,A),I=Rn.subtract(a,C,_),P=Rn.dot(I,d)/E;return P>=0&&P<=1?A:P<0?(s.radius=l.radius,s.center.set(l.ellipseCenter0),tu.raySphere(c,s)):P>1?(s.radius=l.radius,s.center.set(l.ellipseCenter1),tu.raySphere(c,s)):0}}(),gl=(_l=_s.create(),fl={distance:1/0,doubleSided:!1,mode:Kc.ANY},dl=0,pl=function(e,t,n,i,o,r){e===Kc.CLOSEST?(dl>t||0===dl)&&(dl=t,r&&(0===r.length?r.push({distance:t,vertexIndex0:n/3,vertexIndex1:i/3,vertexIndex2:o/3}):(r[0].distance=t,r[0].vertexIndex0=n/3,r[0].vertexIndex1=i/3,r[0].vertexIndex2=o/3))):(dl=t,r&&r.push({distance:t,vertexIndex0:n/3,vertexIndex1:i/3,vertexIndex2:o/3}))},function(e,t,n){if(dl=0,0===t.geometricInfo.positions.length)return dl;var i=void 0===n?fl:n;if(hl(e,t.geometricInfo.boundingBox.min,t.geometricInfo.boundingBox.max)){var o=t.primitiveMode,r=t.geometricInfo;!function(e,t,n,i,o){if(n===ts.TRIANGLE_LIST)for(var r=t.length,a=0;a<r;a+=3){var s=3*t[a],c=3*t[a+1],l=3*t[a+2];Rn.set(_l.a,e[s],e[s+1],e[s+2]),Rn.set(_l.b,e[c],e[c+1],e[c+2]),Rn.set(_l.c,e[l],e[l+1],e[l+2]);var u=tu.rayTriangle(i,_l,o.doubleSided);if(!(0===u||u>o.distance)&&(pl(o.mode,u,s,c,l,o.result),o.mode===Kc.ANY))return u}else if(n===ts.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];Rn.set(_l.a,e[d],e[d+1],e[d+2]),Rn.set(_l.b,e[p],e[p+1],e[p+2]),Rn.set(_l.c,e[m],e[m+1],e[m+2]),_=~_;var v=tu.rayTriangle(i,_l,o.doubleSided);if(!(0===v||v>o.distance)&&(pl(o.mode,v,d,p,m,o.result),o.mode===Kc.ANY))return v}else if(n===ts.TRIANGLE_FAN){var g=t.length-1,y=3*t[0];Rn.set(_l.a,e[y],e[y+1],e[y+2]);for(var x=1;x<g;x+=1){var E=3*t[x],S=3*t[x+1];Rn.set(_l.b,e[E],e[E+1],e[E+2]),Rn.set(_l.c,e[S],e[S+1],e[S+2]);var T=tu.rayTriangle(i,_l,o.doubleSided);if(!(0===T||T>o.distance)&&(pl(o.mode,T,y,E,S,o.result),o.mode===Kc.ANY))return T}}}(r.positions,r.indices,o,e,i)}return dl}),yl=function(){var e=0,t={distance:1/0,doubleSided:!1,mode:Kc.ANY};return function(n,i,o){e=0;var r=void 0===o?t:o,a=i.renderingSubMeshes.length,s=i.struct.minPosition,c=i.struct.maxPosition;if(s&&c&&!hl(n,s,c))return e;for(var l=0;l<a;l++){var u=i.renderingSubMeshes[l],h=gl(n,u,r);if(h)if(r.mode===Kc.CLOSEST)(0===e||e>h)&&(e=h,r.subIndices&&(r.subIndices[0]=l));else if(e=h,r.subIndices&&r.subIndices.push(l),r.mode===Kc.ANY)return h}return e&&r.mode===Kc.CLOSEST&&(r.result&&(r.result[0].distance=e,r.result.length=1),r.subIndices&&(r.subIndices.length=1)),e}}(),xl=function(){var e=0,t={distance:1/0,doubleSided:!1,mode:Kc.ANY},n=new Ea,i=new jn;return function(o,r,a){e=0;var s=void 0===a?t:a,c=r.worldBounds;if(c&&!ul(o,c))return e;Ea.copy(n,o),r.node&&(jn.invert(i,r.node.getWorldMatrix(i)),Rn.transformMat4(n.o,o.o,i),Rn.transformMat4Normal(n.d,o.d,i));for(var l=r.subModels,u=0;u<l.length;u++){var h=l[u].subMesh,_=gl(n,h,s);if(_)if(s.mode===Kc.CLOSEST)(0===e||e>_)&&(e=_,s.subIndices&&(s.subIndices[0]=u));else if(e=_,s.subIndices&&s.subIndices.push(u),s.mode===Kc.ANY)return _}return e&&s.mode===Kc.CLOSEST&&(s.result&&(s.result[0].distance=e,s.result.length=1),s.subIndices&&(s.subIndices.length=1)),e}}(),El=function(){var e=new Rn(0,0,0);return function(t,n){Rn.subtract(e,t.e,t.s);var i=(n.d-Rn.dot(t.s,n.n))/Rn.dot(e,n.n);return i<0||i>1?0:i}}(),Sl=function(){var e=new Rn(0,0,0),t=new Rn(0,0,0),n=new Rn(0,0,0),i=new Rn(0,0,0),o=new Rn(0,0,0),r=new Rn(0,0,0);return function(a,s,c){Rn.subtract(e,s.b,s.a),Rn.subtract(t,s.c,s.a),Rn.subtract(n,a.s,a.e),Rn.cross(o,e,t);var l=Rn.dot(n,o);if(l<=0)return 0;Rn.subtract(i,a.s,s.a);var u=Rn.dot(i,o);if(u<0||u>l)return 0;Rn.cross(r,n,i);var h=Rn.dot(t,r);if(h<0||h>l)return 0;var _=-Rn.dot(e,r);if(_<0||h+_>l)return 0;if(c){var f=1/l,d=1-(h*=f)-(_*=f);Rn.set(c,s.a.x*d+s.b.x*h+s.c.x*_,s.a.y*d+s.b.y*h+s.c.y*_,s.a.z*d+s.b.z*h+s.c.z*_)}return 1}}(),Tl=new Ea;function Al(e,t){Tl.o.set(e.s),Rn.subtract(Tl.d,e.e,e.s),Tl.d.normalize();var n=ul(Tl,t);return n<=e.length()?n:0}function wl(e,t){Tl.o.set(e.s),Rn.subtract(Tl.d,e.e,e.s),Tl.d.normalize();var n=ml(Tl,t);return n<=e.length()?n:0}function Cl(e,t){Tl.o.set(e.s),Rn.subtract(Tl.d,e.e,e.s),Tl.d.normalize();var n=ll(Tl,t);return n<=e.length()?n:0}var Il,Pl,bl,Rl,Nl=(Il=new Rn,Pl=new Rn,bl=new Rn,Rl=new Rn,function(e,t){return Rn.subtract(Il,e.center,e.halfExtents),Rn.add(Pl,e.center,e.halfExtents),Rn.subtract(bl,t.center,t.halfExtents),Rn.add(Rl,t.center,t.halfExtents),Il.x<=Rl.x&&Pl.x>=bl.x&&Il.y<=Rl.y&&Pl.y>=bl.y&&Il.z<=Rl.z&&Pl.z>=bl.z});function Ol(e,t,n,i,o,r){Rn.set(r[0],e.x+n.x*t.x+i.x*t.y+o.x*t.z,e.y+n.y*t.x+i.y*t.y+o.y*t.z,e.z+n.z*t.x+i.z*t.y+o.z*t.z),Rn.set(r[1],e.x-n.x*t.x+i.x*t.y+o.x*t.z,e.y-n.y*t.x+i.y*t.y+o.y*t.z,e.z-n.z*t.x+i.z*t.y+o.z*t.z),Rn.set(r[2],e.x+n.x*t.x-i.x*t.y+o.x*t.z,e.y+n.y*t.x-i.y*t.y+o.y*t.z,e.z+n.z*t.x-i.z*t.y+o.z*t.z),Rn.set(r[3],e.x+n.x*t.x+i.x*t.y-o.x*t.z,e.y+n.y*t.x+i.y*t.y-o.y*t.z,e.z+n.z*t.x+i.z*t.y-o.z*t.z),Rn.set(r[4],e.x-n.x*t.x-i.x*t.y-o.x*t.z,e.y-n.y*t.x-i.y*t.y-o.y*t.z,e.z-n.z*t.x-i.z*t.y-o.z*t.z),Rn.set(r[5],e.x+n.x*t.x-i.x*t.y-o.x*t.z,e.y+n.y*t.x-i.y*t.y-o.y*t.z,e.z+n.z*t.x-i.z*t.y-o.z*t.z),Rn.set(r[6],e.x-n.x*t.x+i.x*t.y-o.x*t.z,e.y-n.y*t.x+i.y*t.y-o.y*t.z,e.z-n.z*t.x+i.z*t.y-o.z*t.z),Rn.set(r[7],e.x-n.x*t.x-i.x*t.y+o.x*t.z,e.y-n.y*t.x-i.y*t.y+o.y*t.z,e.z-n.z*t.x-i.z*t.y+o.z*t.z)}function Dl(e,t){for(var n=Rn.dot(t,e[0]),i=n,o=1;o<8;++o){var r=Rn.dot(t,e[o]);n=r<n?r:n,i=r>i?r:i}return[n,i]}var Ml,Ll,Fl,zl=function(){for(var e=new Array(15),t=0;t<15;t++)e[t]=new Rn(0,0,0);for(var n=new Array(8),i=new Array(8),o=0;o<8;o++)n[o]=new Rn(0,0,0),i[o]=new Rn(0,0,0);var r=new Rn,a=new Rn;return function(t,o){Rn.set(e[0],1,0,0),Rn.set(e[1],0,1,0),Rn.set(e[2],0,0,1),Rn.set(e[3],o.orientation.m00,o.orientation.m01,o.orientation.m02),Rn.set(e[4],o.orientation.m03,o.orientation.m04,o.orientation.m05),Rn.set(e[5],o.orientation.m06,o.orientation.m07,o.orientation.m08);for(var s=0;s<3;++s)Rn.cross(e[6+3*s],e[s],e[0]),Rn.cross(e[7+3*s],e[s],e[1]),Rn.cross(e[7+3*s],e[s],e[2]);Rn.subtract(r,t.center,t.halfExtents),Rn.add(a,t.center,t.halfExtents),function(e,t,n){Rn.set(n[0],e.x,t.y,t.z),Rn.set(n[1],e.x,t.y,e.z),Rn.set(n[2],e.x,e.y,t.z),Rn.set(n[3],e.x,e.y,e.z),Rn.set(n[4],t.x,t.y,t.z),Rn.set(n[5],t.x,t.y,e.z),Rn.set(n[6],t.x,e.y,t.z),Rn.set(n[7],t.x,e.y,e.z)}(r,a,n),Ol(o.center,o.halfExtents,e[3],e[4],e[5],i);for(var c=0;c<15;++c){var l=Dl(n,e[c]),u=Dl(i,e[c]);if(u[0]>l[1]||l[0]>u[1])return 0}return 1}}(),Bl=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=Rn.dot(t.n,e.center);return i+n<t.d?-1:i-n>t.d?0:1},Ul=function(e,t){for(var n=0;n<t.planes.length;n++)if(-1===Bl(e,t.planes[n]))return 0;return 1},Hl=function(){for(var e=new Array(8),t=0,n=0,i=0;i<e.length;i++)e[i]=new Rn(0,0,0);return function(i,o){for(var r=0,a=!1,s=0;s<o.planes.length;s++){if(-1===(r=Bl(i,o.planes[s])))return 0;1===r&&(a=!0)}if(!a)return 1;for(var c=0;c<o.vertices.length;c++)Rn.subtract(e[c],o.vertices[c],i.center);t=0,n=0;for(var l=0;l<o.vertices.length;l++)e[l].x>i.halfExtents.x?t++:e[l].x<-i.halfExtents.x&&n++;if(t===o.vertices.length||n===o.vertices.length)return 0;t=0,n=0;for(var u=0;u<o.vertices.length;u++)e[u].y>i.halfExtents.y?t++:e[u].y<-i.halfExtents.y&&n++;if(t===o.vertices.length||n===o.vertices.length)return 0;t=0,n=0;for(var h=0;h<o.vertices.length;h++)e[h].z>i.halfExtents.z?t++:e[h].z<-i.halfExtents.z&&n++;return t===o.vertices.length||n===o.vertices.length?0:1}}(),Gl=(Ml=new Rn(0,0,0),Ll=new Mn,function(e,t){return Rn.subtract(Ml,t,e.center),Rn.transformMat3(Ml,Ml,Mn.transpose(Ll,e.orientation)),n=Ml,i=e.halfExtents,Math.abs(n.x)<i.x&&Math.abs(n.y)<i.y&&Math.abs(n.z)<i.z;var n,i}),Vl=(Fl=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*Fl(t.n,e.orientation.m00,e.orientation.m01,e.orientation.m02)+e.halfExtents.y*Fl(t.n,e.orientation.m03,e.orientation.m04,e.orientation.m05)+e.halfExtents.z*Fl(t.n,e.orientation.m06,e.orientation.m07,e.orientation.m08),i=Rn.dot(t.n,e.center);return i+n<t.d?-1:i-n>t.d?0:1}),kl=function(e,t){for(var n=0;n<t.planes.length;n++)if(-1===Vl(e,t.planes[n]))return 0;return 1},Wl=function(){for(var e=new Array(8),t=0,n=0,i=0,o=0;o<e.length;o++)e[o]=new Rn(0,0,0);var r=function(e,t,n,i){return e.x*t+e.y*n+e.z*i};return function(o,a){for(var s=0,c=!1,l=0;l<a.planes.length;l++){if(-1===(s=Vl(o,a.planes[l])))return 0;1===s&&(c=!0)}if(!c)return 1;for(var u=0;u<a.vertices.length;u++)Rn.subtract(e[u],a.vertices[u],o.center);n=0,i=0;for(var h=0;h<a.vertices.length;h++)(t=r(e[h],o.orientation.m00,o.orientation.m01,o.orientation.m02))>o.halfExtents.x?n++:t<-o.halfExtents.x&&i++;if(n===a.vertices.length||i===a.vertices.length)return 0;n=0,i=0;for(var _=0;_<a.vertices.length;_++)(t=r(e[_],o.orientation.m03,o.orientation.m04,o.orientation.m05))>o.halfExtents.y?n++:t<-o.halfExtents.y&&i++;if(n===a.vertices.length||i===a.vertices.length)return 0;n=0,i=0;for(var f=0;f<a.vertices.length;f++)(t=r(e[f],o.orientation.m06,o.orientation.m07,o.orientation.m08))>o.halfExtents.z?n++:t<-o.halfExtents.z&&i++;return n===a.vertices.length||i===a.vertices.length?0:1}}(),jl=function(){for(var e=new Array(15),t=0;t<15;t++)e[t]=new Rn(0,0,0);for(var n=new Array(8),i=new Array(8),o=0;o<8;o++)n[o]=new Rn(0,0,0),i[o]=new Rn(0,0,0);return function(t,o){Rn.set(e[0],t.orientation.m00,t.orientation.m01,t.orientation.m02),Rn.set(e[1],t.orientation.m03,t.orientation.m04,t.orientation.m05),Rn.set(e[2],t.orientation.m06,t.orientation.m07,t.orientation.m08),Rn.set(e[3],o.orientation.m00,o.orientation.m01,o.orientation.m02),Rn.set(e[4],o.orientation.m03,o.orientation.m04,o.orientation.m05),Rn.set(e[5],o.orientation.m06,o.orientation.m07,o.orientation.m08);for(var r=0;r<3;++r)Rn.cross(e[6+3*r],e[r],e[0]),Rn.cross(e[7+3*r],e[r],e[1]),Rn.cross(e[7+3*r],e[r],e[2]);Ol(t.center,t.halfExtents,e[0],e[1],e[2],n),Ol(o.center,o.halfExtents,e[3],e[4],e[5],i);for(var a=0;a<15;++a){var s=Dl(n,e[a]),c=Dl(i,e[a]);if(c[0]>s[1]||s[0]>c[1])return 0}return 1}}(),ql=function(){for(var e=new hs,t=new Rn,n=new Rn,i=new Rn,o=new Array(8),r=0;r<8;r++)o[r]=new Rn;for(var a=new Array(8),s=0;s<8;s++)a[s]=new Rn;return function(r,s){if(0===Rn.squaredDistance(s.ellipseCenter0,s.ellipseCenter1))return e.radius=s.radius,e.center.set(s.ellipseCenter0),tu.sphereOBB(e,r);t.x=r.orientation.m00,t.y=r.orientation.m01,t.z=r.orientation.m02,n.x=r.orientation.m03,n.y=r.orientation.m04,n.z=r.orientation.m05,i.x=r.orientation.m06,i.y=r.orientation.m07,i.z=r.orientation.m08,Ol(r.center,r.halfExtents,t,n,i,o);var c=a,l=Rn.copy(c[0],t),u=Rn.copy(c[1],n),h=Rn.copy(c[2],i);Rn.subtract(c[3],s.center,r.center).normalize();var _=Rn.subtract(c[4],s.ellipseCenter0,s.ellipseCenter1);_.normalize(),Rn.cross(c[5],l,_),Rn.cross(c[6],u,_),Rn.cross(c[7],h,_);for(var f=0;f<8;++f){var d=Dl(o,c[f]),p=Rn.dot(c[f],s.ellipseCenter0),m=Rn.dot(c[f],s.ellipseCenter1),v=Math.max(p,m),g=Math.min(p,m)-s.radius,y=v+s.radius;if(g>d[1]||d[0]>y)return 0}return 1}}(),Yl=function(e,t){var n=Rn.dot(t.n,e.center),i=e.radius*t.n.length();return n+i<t.d?-1:n-i>t.d?0:1},Xl=function(e,t){for(var n=0;n<t.planes.length;n++)if(-1===Yl(e,t.planes[n]))return 0;return 1},Kl=function(){var e=new Rn(0,0,0),t=[1,-1,1,-1,1,-1];return function(n,i){for(var o=0;o<6;o++){var r=i.planes[o],a=n.radius,s=n.center,c=r.n,l=r.d,u=Rn.dot(c,s);if(u+a<l)return 0;if(!(u-a>l)){Rn.add(e,s,Rn.multiplyScalar(e,c,a));for(var h=0;h<6;h++)if(h!==o&&h!==o+t[o]){var _=i.planes[h];if(Rn.dot(_.n,e)<_.d)return 0}}}return 1}}(),Ql=function(e,t){var n=e.radius+t.radius;return Rn.squaredDistance(e.center,t.center)<n*n},Zl=function(){var e=new Rn;return function(t,n){return ma(e,t.center,n),Rn.squaredDistance(t.center,e)<t.radius*t.radius}}(),Jl=function(){var e=new Rn;return function(t,n){return va(e,t.center,n),Rn.squaredDistance(t.center,e)<t.radius*t.radius}}(),$l=function(){var e=new Rn,t=new Rn;return function(n,i){var o=n.radius+i.radius,r=o*o,a=Rn.squaredDistance(i.ellipseCenter0,i.ellipseCenter1);if(0===a)return Rn.squaredDistance(n.center,i.center)<r;Rn.subtract(e,n.center,i.ellipseCenter0),Rn.subtract(t,i.ellipseCenter1,i.ellipseCenter0);var s=Rn.dot(e,t)/a;return s<0?Rn.squaredDistance(n.center,i.ellipseCenter0)<r:s>1?Rn.squaredDistance(n.center,i.ellipseCenter1)<r:(Rn.scaleAndAdd(e,i.ellipseCenter0,t,s),Rn.squaredDistance(n.center,e)<r)}}(),eu=function(){var e=new Rn,t=new Rn,n=new Rn,i=new Rn,o=new Rn,r=new Rn;return function(a,s){var c,l,u,h,_=Rn.subtract(e,a.ellipseCenter1,a.ellipseCenter0),f=Rn.subtract(t,s.ellipseCenter1,s.ellipseCenter0),d=Rn.subtract(n,a.ellipseCenter0,s.ellipseCenter0),p=Rn.dot(_,_),m=Rn.dot(_,f),v=Rn.dot(f,f),g=Rn.dot(_,d),y=Rn.dot(f,d),x=p*v-m*m,E=x,S=x;x<sn?(l=0,E=1,h=y,S=v):(h=p*y-m*g,(l=m*y-v*g)<0?(l=0,h=y,S=v):l>E&&(l=E,h=y+m,S=v)),h<0?(h=0,-g<0?l=0:-g>p?l=E:(l=-g,E=p)):h>S&&(h=S,-g+m<0?l=0:-g+m>p?l=E:(l=-g+m,E=p)),c=Math.abs(l)<sn?0:l/E,u=Math.abs(h)<sn?0:h/S;var T=i;T.set(d),T.add(Rn.multiplyScalar(o,_,c)),T.subtract(Rn.multiplyScalar(r,f,u));var A=a.radius+s.radius;return T.lengthSqr()<A*A}}(),tu={raySphere:ll,rayAABB:ul,rayOBB:ml,rayPlane:sl,rayTriangle:cl,rayCapsule:vl,raySubMesh:gl,rayMesh:yl,rayModel:xl,lineSphere:Cl,lineAABB:Al,lineOBB:wl,linePlane:El,lineTriangle:Sl,sphereWithSphere:Ql,sphereAABB:Zl,sphereOBB:Jl,spherePlane:Yl,sphereFrustum:Xl,sphereFrustumAccurate:Kl,sphereCapsule:$l,aabbWithAABB:Nl,aabbWithOBB:zl,aabbPlane:Bl,aabbFrustum:Ul,aabbFrustumAccurate:Hl,obbWithOBB:jl,obbPlane:Vl,obbFrustum:kl,obbFrustumAccurate:Wl,obbPoint:Gl,obbCapsule:ql,capsuleWithCapsule:eu,resolve:function(e,t,n){void 0===n&&(n=null);var i=e._type,o=t._type,r=this[i|o];return i<o?r(e,t,n):r(t,e,n)}};tu[ya.SHAPE_RAY|ya.SHAPE_SPHERE]=ll,tu[ya.SHAPE_RAY|ya.SHAPE_AABB]=ul,tu[ya.SHAPE_RAY|ya.SHAPE_OBB]=ml,tu[ya.SHAPE_RAY|ya.SHAPE_PLANE]=sl,tu[ya.SHAPE_RAY|ya.SHAPE_TRIANGLE]=cl,tu[ya.SHAPE_RAY|ya.SHAPE_CAPSULE]=vl,tu[ya.SHAPE_LINE|ya.SHAPE_SPHERE]=Cl,tu[ya.SHAPE_LINE|ya.SHAPE_AABB]=Al,tu[ya.SHAPE_LINE|ya.SHAPE_OBB]=wl,tu[ya.SHAPE_LINE|ya.SHAPE_PLANE]=El,tu[ya.SHAPE_LINE|ya.SHAPE_TRIANGLE]=Sl,tu[ya.SHAPE_SPHERE]=Ql,tu[ya.SHAPE_SPHERE|ya.SHAPE_AABB]=Zl,tu[ya.SHAPE_SPHERE|ya.SHAPE_OBB]=Jl,tu[ya.SHAPE_SPHERE|ya.SHAPE_PLANE]=Yl,tu[ya.SHAPE_SPHERE|ya.SHAPE_FRUSTUM]=Xl,tu[ya.SHAPE_SPHERE|ya.SHAPE_FRUSTUM_ACCURATE]=Kl,tu[ya.SHAPE_SPHERE|ya.SHAPE_CAPSULE]=$l,tu[ya.SHAPE_AABB]=Nl,tu[ya.SHAPE_AABB|ya.SHAPE_OBB]=zl,tu[ya.SHAPE_AABB|ya.SHAPE_PLANE]=Bl,tu[ya.SHAPE_AABB|ya.SHAPE_FRUSTUM]=Ul,tu[ya.SHAPE_AABB|ya.SHAPE_FRUSTUM_ACCURATE]=Hl,tu[ya.SHAPE_OBB]=jl,tu[ya.SHAPE_OBB|ya.SHAPE_PLANE]=Vl,tu[ya.SHAPE_OBB|ya.SHAPE_FRUSTUM]=kl,tu[ya.SHAPE_OBB|ya.SHAPE_FRUSTUM_ACCURATE]=Wl,tu[ya.SHAPE_OBB|ya.SHAPE_CAPSULE]=ql,tu[ya.SHAPE_CAPSULE]=eu,q(xa.prototype,"line",[{name:"mag",newName:"len"},{name:"magnitude",newName:"len"}]),Y(tu,"intersect",[{name:"line_quad"}]);var nu=new Rn(0,0,0),iu=new Rn(0,0,0),ou=c.mat4(),ru=c.v4(),au=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=ya.SHAPE_PLANE,this.n=new Rn(e,t,n),this.d=i}return e.create=function(t,n,i,o){return new e(t,n,i,o)},e.clone=function(t){return new e(t.n.x,t.n.y,t.n.z,t.d)},e.copy=function(e,t){return Rn.copy(e.n,t.n),e.d=t.d,e},e.fromPoints=function(e,t,n,i){return Rn.subtract(nu,n,t),Rn.subtract(iu,i,t),Rn.normalize(e.n,Rn.cross(e.n,nu,iu)),e.d=Rn.dot(e.n,t),e},e.set=function(e,t,n,i,o){return e.n.x=t,e.n.y=n,e.n.z=i,e.d=o,e},e.fromNormalAndPoint=function(e,t,n){return Rn.copy(e.n,t),e.d=Rn.dot(t,n),e},e.normalize=function(e,t){var n=t.n.length();return Rn.normalize(e.n,t.n),n>0&&(e.d=t.d/n),e},e.prototype.transform=function(e){jn.invert(ou,e),jn.transpose(ou,ou),$n.set(ru,this.n.x,this.n.y,this.n.z,this.d),$n.transformMat4(ru,ru,ou),Rn.set(this.n,ru.x,ru.y,ru.z),this.d=ru.w},te(e,[{key:"type",get:function(){return this._type}},{key:"x",get:function(){return this.n.x},set:function(e){this.n.x=e}},{key:"y",get:function(){return this.n.y},set:function(e){this.n.y=e}},{key:"z",get:function(){return this.n.z},set:function(e){this.n.z=e}},{key:"w",get:function(){return this.d},set:function(e){this.d=e}}]),e}(),su=new Rn,cu=new Rn,lu=new Rn,uu=new Rn,hu=new Mn,_u=function(e,t,n){hu.m00=Math.abs(n.m00),hu.m01=Math.abs(n.m01),hu.m02=Math.abs(n.m02),hu.m03=Math.abs(n.m04),hu.m04=Math.abs(n.m05),hu.m05=Math.abs(n.m06),hu.m06=Math.abs(n.m08),hu.m07=Math.abs(n.m09),hu.m08=Math.abs(n.m10),Rn.transformMat3(e,t,hu)},fu=e("bL",function(){function e(e,t,n,i,o,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=1),void 0===o&&(o=1),void 0===r&&(r=1),this.center=void 0,this.halfExtents=void 0,this._type=void 0,this._type=ya.SHAPE_AABB,this.center=new Rn(e,t,n),this.halfExtents=new Rn(i,o,r)}e.create=function(t,n,i,o,r,a){return new e(t,n,i,o,r,a)},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 Rn.copy(e.center,t.center),Rn.copy(e.halfExtents,t.halfExtents),e},e.fromPoints=function(e,t,n){return Rn.add(su,n,t),Rn.subtract(cu,n,t),Rn.multiplyScalar(e.center,su,.5),Rn.multiplyScalar(e.halfExtents,cu,.5),e},e.set=function(e,t,n,i,o,r,a){return Rn.set(e.center,t,n,i),Rn.set(e.halfExtents,o,r,a),e},e.merge=function(t,n,i){return Rn.subtract(su,n.center,n.halfExtents),Rn.subtract(cu,i.center,i.halfExtents),Rn.add(lu,n.center,n.halfExtents),Rn.add(uu,i.center,i.halfExtents),Rn.max(uu,lu,uu),Rn.min(lu,su,cu),e.fromPoints(t,lu,uu)},e.toBoundingSphere=function(e,t){t.getBoundary(su,cu),e.center.set(su),e.radius=0,Rn.subtract(lu,cu,e.center);var n=lu.length(),i=.5*n;return e.radius+=i,Rn.multiplyScalar(lu,lu,i/n),Rn.add(e.center,e.center,lu),e},e.transform=function(e,t,n){return Rn.transformMat4(e.center,t.center,n),_u(e.halfExtents,t.halfExtents,n),e};var t=e.prototype;return t.getBoundary=function(e,t){Rn.subtract(e,this.center,this.halfExtents),Rn.add(t,this.center,this.halfExtents)},t.transform=function(e,t,n,i,o){Rn.transformMat4(o.center,this.center,e),_u(o.halfExtents,this.halfExtents,e)},t.clone=function(){return e.clone(this)},t.copy=function(t){return e.copy(this,t)},te(e,[{key:"type",get:function(){return this._type}}]),e}()),du=new Rn,pu=new Rn,mu=new Mn,vu=function(){function e(e,t,n,i,o,r,a,s,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===o&&(o=1),void 0===r&&(r=1),void 0===a&&(a=1),void 0===s&&(s=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=ya.SHAPE_OBB,this.center=new Rn(e,t,n),this.halfExtents=new Rn(i,o,r),this.orientation=new Mn(a,s,c,l,u,h,_,f,d)}e.create=function(t,n,i,o,r,a,s,c,l,u,h,_,f,d,p){return new e(t,n,i,o,r,a,s,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 Rn.copy(e.center,t.center),Rn.copy(e.halfExtents,t.halfExtents),Mn.copy(e.orientation,t.orientation),e},e.fromPoints=function(e,t,n){return Rn.multiplyScalar(e.center,Rn.add(du,t,n),.5),Rn.multiplyScalar(e.halfExtents,Rn.subtract(pu,n,t),.5),Mn.identity(e.orientation),e},e.set=function(e,t,n,i,o,r,a,s,c,l,u,h,_,f,d,p){return Rn.set(e.center,t,n,i),Rn.set(e.halfExtents,o,r,a),Mn.set(e.orientation,s,c,l,u,h,_,f,d,p),e};var t=e.prototype;return t.getBoundary=function(e,t){!function(e,t,n){mu.m00=Math.abs(n.m00),mu.m01=Math.abs(n.m01),mu.m02=Math.abs(n.m02),mu.m03=Math.abs(n.m03),mu.m04=Math.abs(n.m04),mu.m05=Math.abs(n.m05),mu.m06=Math.abs(n.m06),mu.m07=Math.abs(n.m07),mu.m08=Math.abs(n.m08),Rn.transformMat3(e,t,mu)}(du,this.halfExtents,this.orientation),Rn.subtract(e,this.center,du),Rn.add(t,this.center,du)},t.transform=function(e,t,n,i,o){Rn.transformMat4(o.center,this.center,e),Mn.fromQuat(o.orientation,n),Rn.multiply(o.halfExtents,this.halfExtents,i)},t.translateAndRotate=function(e,t,n){Rn.transformMat4(n.center,this.center,e),Mn.fromQuat(n.orientation,t)},t.setScale=function(e,t){Rn.multiply(t.halfExtents,this.halfExtents,e)},te(e,[{key:"type",get:function(){return this._type}}]),e}(),gu=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=ya.SHAPE_CAPSULE,this.radius=e,this.halfHeight=t,this.axis=n,this.center=new Rn,this.rotation=new zn,this.ellipseCenter0=new Rn(0,t,0),this.ellipseCenter1=new Rn(0,-t,0),this.updateCache()}var t=e.prototype;return t.transform=function(e,t,n,i,o){var r=i,a=wn(r);o.radius=this.radius*Math.abs(a);var s=(this.halfHeight+this.radius)*Math.abs(r.y)-o.radius;s<0&&(s=0),o.halfHeight=s,Rn.transformMat4(o.center,this.center,e),zn.multiply(o.rotation,this.rotation,n),o.updateCache()},t.updateCache=function(){this.updateLocalCenter(),Rn.transformQuat(this.ellipseCenter0,this.ellipseCenter0,this.rotation),Rn.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)}},te(e,[{key:"type",get:function(){return this._type}}]),e}(),yu=new Array(8);yu[0]=new Rn(1,1,1),yu[1]=new Rn(-1,1,1),yu[2]=new Rn(-1,-1,1),yu[3]=new Rn(1,-1,1),yu[4]=new Rn(1,1,-1),yu[5]=new Rn(-1,1,-1),yu[6]=new Rn(-1,-1,-1),yu[7]=new Rn(1,-1,-1);var xu,Eu,Su,Tu=function(){function e(){this._type=void 0,this.planes=void 0,this.vertices=void 0,this._type=ya.SHAPE_FRUSTUM,this.planes=new Array(6);for(var e=0;e<6;++e)this.planes[e]=au.create(0,0,0,0);this.vertices=new Array(8);for(var t=0;t<8;++t)this.vertices[t]=new Rn}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)au.copy(e.planes[n],t.planes[n]);for(var i=0;i<8;++i)Rn.copy(e.vertices[i],t.vertices[i]);return e};var t=e.prototype;return t.update=function(e,t){if(Rn.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),Rn.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),Rn.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),Rn.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),Rn.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),Rn.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===ya.SHAPE_FRUSTUM_ACCURATE){for(var n=0;n<6;n++){var i=this.planes[n],o=1/i.n.length();Rn.multiplyScalar(i.n,i.n,o),i.d*=o}for(var r=0;r<8;r++)Rn.transformMat4(this.vertices[r],yu[r],t)}},t.transform=function(e){if(this._type===ya.SHAPE_FRUSTUM_ACCURATE){for(var t=0;t<8;t++)Rn.transformMat4(this.vertices[t],this.vertices[t],e);au.fromPoints(this.planes[0],this.vertices[1],this.vertices[5],this.vertices[6]),au.fromPoints(this.planes[1],this.vertices[3],this.vertices[7],this.vertices[4]),au.fromPoints(this.planes[2],this.vertices[6],this.vertices[7],this.vertices[3]),au.fromPoints(this.planes[3],this.vertices[0],this.vertices[4],this.vertices[5]),au.fromPoints(this.planes[4],this.vertices[2],this.vertices[3],this.vertices[0]),au.fromPoints(this.planes[0],this.vertices[7],this.vertices[6],this.vertices[5])}},te(e,[{key:"accurate",set:function(e){this._type=e?ya.SHAPE_FRUSTUM_ACCURATE:ya.SHAPE_FRUSTUM}},{key:"type",get:function(){return this._type}}]),e}();function Au(e,t){if(t&&e!==bo){for(var n=t.vertices,i=vr.VERTICES,o=0;o<8;++o)Sr.setVec3(e,i,n[o]),i+=3;for(var r=t.planes,a=vr.PLANES,s=0;s<6;s++,a+=4)Sr.setVec4(e,a,r[s])}}Tu.createOrtho=(xu=new Rn,function(e,t,n,i,o,r){var a=t/2,s=n/2;Rn.set(xu,a,s,i),Rn.transformMat4(e.vertices[0],xu,r),Rn.set(xu,-a,s,i),Rn.transformMat4(e.vertices[1],xu,r),Rn.set(xu,-a,-s,i),Rn.transformMat4(e.vertices[2],xu,r),Rn.set(xu,a,-s,i),Rn.transformMat4(e.vertices[3],xu,r),Rn.set(xu,a,s,o),Rn.transformMat4(e.vertices[4],xu,r),Rn.set(xu,-a,s,o),Rn.transformMat4(e.vertices[5],xu,r),Rn.set(xu,-a,-s,o),Rn.transformMat4(e.vertices[6],xu,r),Rn.set(xu,a,-s,o),Rn.transformMat4(e.vertices[7],xu,r),au.fromPoints(e.planes[0],e.vertices[1],e.vertices[6],e.vertices[5]),au.fromPoints(e.planes[1],e.vertices[3],e.vertices[4],e.vertices[7]),au.fromPoints(e.planes[2],e.vertices[6],e.vertices[3],e.vertices[7]),au.fromPoints(e.planes[3],e.vertices[0],e.vertices[5],e.vertices[4]),au.fromPoints(e.planes[4],e.vertices[2],e.vertices[0],e.vertices[3]),au.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"}(Eu||(Eu={})),function(e){e[e.Default=Eu.Default]="Default",e[e.Normal=Eu.Normal]="Normal",e[e.Reverse=Eu.Reverse]="Reverse",e[e.Loop=Eu.Loop]="Loop",e[e.LoopReverse=Eu.Loop|Eu.Reverse]="LoopReverse",e[e.PingPong=Eu.PingPong]="PingPong",e[e.PingPongReverse=Eu.PingPong|Eu.Reverse]="PingPongReverse"}(Su||(Su={})),ht(Su);var wu=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}(),Cu=ct({Default:Eu.Default,Normal:Eu.Normal,Clamp:Eu.Clamp,Loop:Eu.Loop,PingPong:Eu.PingPong}),Iu=function(){this.time=0,this.value=0,this.inTangent=0,this.outTangent=0};tn.fastDefine("cc.Keyframe",Iu,{time:0,value:0,inTangent:0,outTangent:0});var Pu=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}(),bu=e("dS",function(){function e(t){void 0===t&&(t=null),this.keyFrames=void 0,this.preWrapMode=Cu.Loop,this.postWrapMode=Cu.Clamp,this.cachedKey=void 0,this.keyFrames=t||[].concat(e.defaultKF),this.cachedKey=new Pu}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,o=this.keyFrames[this.keyFrames.length-1].time;switch(n){case Cu.Loop:t=Sn(e-i,o-i)+i;break;case Cu.PingPong:t=Tn(e-i,o-i)+i;break;case Cu.Default:case Cu.Normal:case Cu.Clamp:default:t=un(e,i,o)}var r=0;if(t>this.keyFrames[0].time)if(t>=this.keyFrames[this.keyFrames.length-1].time)r=this.keyFrames.length-2;else for(var a=0;a<this.keyFrames.length-1;a++)if(t>=this.keyFrames[0].time&&t<=this.keyFrames[a+1].time){r=a;break}var s=this.keyFrames[r],c=this.keyFrames[r+1],l=An(s.time,c.time,t),u=c.time-s.time,h=s.outTangent*u,_=c.inTangent*u,f=l*l,d=f*l,p=d-2*f+l,m=d-f,v=-2*d+3*f;return(2*d-3*f+1)*s.value+p*h+m*_+v*c.value},t.evaluate=function(e){var t=e,n=e<0?this.preWrapMode:this.postWrapMode,i=this.keyFrames[0].time,o=this.keyFrames[this.keyFrames.length-1].time;switch(n){case Cu.Loop:t=Sn(e-i,o-i)+i;break;case Cu.PingPong:t=Tn(e-i,o-i)+i;break;case Cu.Default:case Cu.Normal:case Cu.Clamp:default:t=un(e,i,o)}if(t>=this.cachedKey.time&&t<this.cachedKey.endTime)return this.cachedKey.evaluate(t);var r=this.findIndex(this.cachedKey,t),a=Math.min(r+1,this.keyFrames.length-1);return this.calcOptimizedKey(this.cachedKey,r,a),this.cachedKey.evaluate(t)},t.calcOptimizedKey=function(e,t,n){var i=this.keyFrames[t],o=this.keyFrames[n];e.index=t,e.time=i.time,e.endTime=o.time;var r=o.time-i.time,a=o.value-i.value,s=1/(r*r),c=i.outTangent*r,l=o.inTangent*r;e.coefficient[0]=(c+l-a-a)*s/r,e.coefficient[1]=(a+a+a-c-c-l)*s,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 o=n+i;if(o+1<this.keyFrames.length&&this.keyFrames[o+1].time>t)return o}else for(var r=0;r<3;r++){var a=n-r;if(a>=0&&this.keyFrames[a-1].time<=t)return a-1}for(var s,c=0,l=this.keyFrames.length;l-c>1;)s=Math.floor((c+l)/2),this.keyFrames[s].time>=t?l=s:c=s;return c},e}());function Ru(e,t){console.warn(e+" is deprecated, please use "+t+" instead.")}bu.defaultKF=[{time:0,value:1,inTangent:0,outTangent:0},{time:1,value:1,inTangent:0,outTangent:0}],tn.fastDefine("cc.AnimationCurve",bu,{preWrapMode:Cu.Default,postWrapMode:Cu.Default,keyFrames:[]}),q(tu,"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 Nu=function(e){function t(){var t;return t=e.call(this)||this,Ru("line","Line"),t}return ie(t,e),t}(xa),Ou=function(e){function t(){var t;return t=e.call(this)||this,Ru("plane","Plane"),t}return ie(t,e),t}(au),Du=function(e){function t(){var t;return t=e.call(this)||this,Ru("ray","Ray"),t}return ie(t,e),t}(Ea),Mu=function(e){function t(){var t;return t=e.call(this)||this,Ru("triangle","Triangle"),t}return ie(t,e),t}(_s),Lu=function(e){function t(){var t;return t=e.call(this)||this,Ru("sphere","Sphere"),t}return ie(t,e),t}(hs),Fu=function(e){function t(){var t;return t=e.call(this)||this,Ru("aabb","AABB"),t}return ie(t,e),t}(fu),zu=function(e){function t(){var t;return t=e.call(this)||this,Ru("obb","OBB"),t}return ie(t,e),t}(vu),Bu=function(e){function t(){var t;return t=e.call(this)||this,Ru("capsule","Capsule"),t}return ie(t,e),t}(gu),Uu=function(e){function t(){var t;return t=e.call(this)||this,Ru("frustum","Frustum"),t}return ie(t,e),t}(Tu),Hu=Object.freeze({__proto__:null,distance:ga,enums:ya,intersect:tu,Line:xa,Plane:au,Ray:Ea,Triangle:_s,Sphere:hs,AABB:fu,OBB:vu,Capsule:gu,Frustum:Tu,Keyframe:Iu,AnimationCurve:bu,get ERaycastMode(){return Kc},line:Nu,plane:Ou,ray:Du,triangle:Mu,sphere:Lu,aabb:Fu,obb:zu,capsule:Bu,frustum:Uu});e("eA",Hu);var Gu={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},Vu=e("dl",function(){function e(){}return e.makeMaskInclude=function(e){for(var t,n=0,i=le(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}());Vu.Enum=ct(Gu),Vu.BitMask=st(ne({},Gu)),c.Layers=Vu;var ku,Wu,ju="GbufferFlow",qu="LightingFlow",Yu="ForwardFlow",Xu="ShadowFlow";!function(e){e[e.DEFAULT=100]="DEFAULT",e[e.UI=200]="UI"}(ku||(ku={})),c.RenderPassStage=ku,function(e){e[e.MIN=0]="MIN",e[e.MAX=255]="MAX",e[e.DEFAULT=128]="DEFAULT"}(Wu||(Wu=e("di",{})));var Ku,Qu={bindings:[],layouts:{}},Zu={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.SAMPLER_GBUFFER_ALBEDOMAP=6]="SAMPLER_GBUFFER_ALBEDOMAP",e[e.SAMPLER_GBUFFER_POSITIONMAP=7]="SAMPLER_GBUFFER_POSITIONMAP",e[e.SAMPLER_GBUFFER_NORMALMAP=8]="SAMPLER_GBUFFER_NORMALMAP",e[e.SAMPLER_GBUFFER_EMISSIVEMAP=9]="SAMPLER_GBUFFER_EMISSIVEMAP",e[e.SAMPLER_LIGHTING_RESULTMAP=10]="SAMPLER_LIGHTING_RESULTMAP",e[e.COUNT=11]="COUNT"}(Ku||(Ku={}));var Ju,$u=Ku.SAMPLER_SHADOWMAP,eh=Ku.COUNT-$u;!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"}(Ju||(Ju=e("dy",{})));var th,nh=Ju.SAMPLER_JOINTS,ih=Ju.COUNT-nh;!function(e){e[e.GLOBAL=0]="GLOBAL",e[e.MATERIAL=1]="MATERIAL",e[e.LOCAL=2]="LOCAL"}(th||(th={}));var oh=new Is;oh.bufferOffsets=[0,$u+nh,$u],oh.samplerOffsets=[-$u,eh+ih,eh-nh],oh.flexibleSet=1;var rh=function(){};rh.SIZE=4*(rh.COUNT=4+(rh.SCREEN_SIZE_OFFSET=4+(rh.NATIVE_SIZE_OFFSET=4+(rh.TIME_OFFSET=0)))),rh.NAME="CCGlobal",rh.BINDING=Ku.UBO_GLOBAL,rh.DESCRIPTOR=new tc(rh.BINDING,ss.UNIFORM_BUFFER,1,Qa.ALL),rh.LAYOUT=new zs(th.GLOBAL,rh.BINDING,rh.NAME,[new Fs("cc_time",Ma.FLOAT4,1),new Fs("cc_screenSize",Ma.FLOAT4,1),new Fs("cc_nativeSize",Ma.FLOAT4,1)],1),Qu.layouts[rh.NAME]=rh.LAYOUT,Qu.bindings[rh.BINDING]=rh.DESCRIPTOR;var ah=function(){};ah.SIZE=4*(ah.COUNT=4+(ah.GLOBAL_FOG_ADD_OFFSET=4+(ah.GLOBAL_FOG_BASE_OFFSET=4+(ah.GLOBAL_FOG_COLOR_OFFSET=4+(ah.AMBIENT_GROUND_OFFSET=4+(ah.AMBIENT_SKY_OFFSET=4+(ah.MAIN_LIT_COLOR_OFFSET=4+(ah.MAIN_LIT_DIR_OFFSET=4+(ah.EXPOSURE_OFFSET=4+(ah.SCREEN_SCALE_OFFSET=4+(ah.CAMERA_POS_OFFSET=16+(ah.MAT_VIEW_PROJ_INV_OFFSET=16+(ah.MAT_VIEW_PROJ_OFFSET=16+(ah.MAT_PROJ_INV_OFFSET=16+(ah.MAT_PROJ_OFFSET=16+(ah.MAT_VIEW_INV_OFFSET=16+(ah.MAT_VIEW_OFFSET=0))))))))))))))))),ah.NAME="CCCamera",ah.BINDING=Ku.UBO_CAMERA,ah.DESCRIPTOR=new tc(ah.BINDING,ss.UNIFORM_BUFFER,1,Qa.ALL),ah.LAYOUT=new zs(th.GLOBAL,ah.BINDING,ah.NAME,[new Fs("cc_matView",Ma.MAT4,1),new Fs("cc_matViewInv",Ma.MAT4,1),new Fs("cc_matProj",Ma.MAT4,1),new Fs("cc_matProjInv",Ma.MAT4,1),new Fs("cc_matViewProj",Ma.MAT4,1),new Fs("cc_matViewProjInv",Ma.MAT4,1),new Fs("cc_cameraPos",Ma.FLOAT4,1),new Fs("cc_screenScale",Ma.FLOAT4,1),new Fs("cc_exposure",Ma.FLOAT4,1),new Fs("cc_mainLitDir",Ma.FLOAT4,1),new Fs("cc_mainLitColor",Ma.FLOAT4,1),new Fs("cc_ambientSky",Ma.FLOAT4,1),new Fs("cc_ambientGround",Ma.FLOAT4,1),new Fs("cc_fogColor",Ma.FLOAT4,1),new Fs("cc_fogBase",Ma.FLOAT4,1),new Fs("cc_fogAdd",Ma.FLOAT4,1)],1),Qu.layouts[ah.NAME]=ah.LAYOUT,Qu.bindings[ah.BINDING]=ah.DESCRIPTOR;var sh=function(){};sh.SIZE=4*(sh.COUNT=4+(sh.SHADOW_COLOR_OFFSET=4+(sh.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET=4+(sh.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET=4+(sh.SHADOW_NEAR_FAR_LINEAR_SELF_INFO_OFFSET=16+(sh.MAT_LIGHT_VIEW_PROJ_OFFSET=16+(sh.MAT_LIGHT_VIEW_OFFSET=16+(sh.MAT_LIGHT_PLANE_PROJ_OFFSET=0)))))))),sh.NAME="CCShadow",sh.BINDING=Ku.UBO_SHADOW,sh.DESCRIPTOR=new tc(sh.BINDING,ss.UNIFORM_BUFFER,1,Qa.ALL),sh.LAYOUT=new zs(th.GLOBAL,sh.BINDING,sh.NAME,[new Fs("cc_matLightPlaneProj",Ma.MAT4,1),new Fs("cc_matLightView",Ma.MAT4,1),new Fs("cc_matLightViewProj",Ma.MAT4,1),new Fs("cc_shadowNFLSInfo",Ma.FLOAT4,1),new Fs("cc_shadowWHPBInfo",Ma.FLOAT4,1),new Fs("cc_shadowLPNNInfo",Ma.FLOAT4,1),new Fs("cc_shadowColor",Ma.FLOAT4,1)],1),Qu.layouts[sh.NAME]=sh.LAYOUT,Qu.bindings[sh.BINDING]=sh.DESCRIPTOR;var ch=Ku.SAMPLER_SHADOWMAP,lh=new tc(ch,ss.SAMPLER_TEXTURE,1,Qa.FRAGMENT),uh=new Bs(th.GLOBAL,ch,"cc_shadowMap",Ma.SAMPLER2D,1);Qu.layouts.cc_shadowMap=uh,Qu.bindings[ch]=lh;var hh=Ku.SAMPLER_GBUFFER_ALBEDOMAP,_h=new tc(hh,ss.SAMPLER_TEXTURE,1,Qa.FRAGMENT),fh=new Bs(th.GLOBAL,hh,"cc_gbuffer_albedoMap",Ma.SAMPLER2D,1);Qu.layouts.cc_gbuffer_albedoMap=fh,Qu.bindings[hh]=_h;var dh=Ku.SAMPLER_GBUFFER_POSITIONMAP,ph=new tc(dh,ss.SAMPLER_TEXTURE,1,Qa.FRAGMENT),mh=new Bs(th.GLOBAL,dh,"cc_gbuffer_positionMap",Ma.SAMPLER2D,1);Qu.layouts.cc_gbuffer_positionMap=mh,Qu.bindings[dh]=ph;var vh=Ku.SAMPLER_GBUFFER_NORMALMAP,gh=new tc(vh,ss.SAMPLER_TEXTURE,1,Qa.FRAGMENT),yh=new Bs(th.GLOBAL,vh,"cc_gbuffer_normalMap",Ma.SAMPLER2D,1);Qu.layouts.cc_gbuffer_normalMap=yh,Qu.bindings[vh]=gh;var xh=Ku.SAMPLER_LIGHTING_RESULTMAP,Eh=new tc(xh,ss.SAMPLER_TEXTURE,1,Qa.FRAGMENT),Sh=new Bs(th.GLOBAL,xh,"cc_lighting_resultMap",Ma.SAMPLER2D,1);Qu.layouts.cc_lighting_resultMap=Sh,Qu.bindings[xh]=Eh;var Th=Ku.SAMPLER_GBUFFER_EMISSIVEMAP,Ah=new tc(Th,ss.SAMPLER_TEXTURE,1,Qa.FRAGMENT),wh=new Bs(th.GLOBAL,Th,"cc_gbuffer_emissiveMap",Ma.SAMPLER2D,1);Qu.layouts.cc_gbuffer_emissiveMap=wh,Qu.bindings[Th]=Ah;var Ch=Ku.SAMPLER_ENVIRONMENT,Ih=new tc(Ch,ss.SAMPLER_TEXTURE,1,Qa.FRAGMENT),Ph=new Bs(th.GLOBAL,Ch,"cc_environment",Ma.SAMPLER_CUBE,1);Qu.layouts.cc_environment=Ph,Qu.bindings[Ch]=Ih;var bh=Ku.SAMPLER_SPOT_LIGHTING_MAP,Rh=new tc(bh,ss.SAMPLER_TEXTURE,1,Qa.FRAGMENT),Nh=new Bs(th.GLOBAL,bh,"cc_spotLightingMap",Ma.SAMPLER2D,1);Qu.layouts.cc_spotLightingMap=Nh,Qu.bindings[bh]=Rh;var Oh=e("dx",(function(){}));Oh.MAT_WORLD_OFFSET=0,Oh.MAT_WORLD_IT_OFFSET=Oh.MAT_WORLD_OFFSET+16,Oh.LIGHTINGMAP_UVPARAM=Oh.MAT_WORLD_IT_OFFSET+16,Oh.COUNT=Oh.LIGHTINGMAP_UVPARAM+4,Oh.SIZE=4*Oh.COUNT,Oh.NAME="CCLocal",Oh.BINDING=Ju.UBO_LOCAL,Oh.DESCRIPTOR=new tc(Oh.BINDING,ss.UNIFORM_BUFFER,1,Qa.VERTEX),Oh.LAYOUT=new zs(th.LOCAL,Oh.BINDING,Oh.NAME,[new Fs("cc_matWorld",Ma.MAT4,1),new Fs("cc_matWorldIT",Ma.MAT4,1),new Fs("cc_lightingMapUVParam",Ma.FLOAT4,1)],1),Zu.layouts[Oh.NAME]=Oh.LAYOUT,Zu.bindings[Oh.BINDING]=Oh.DESCRIPTOR;var Dh="a_matWorld0",Mh=function(){};Mh.BATCHING_COUNT=10,Mh.MAT_WORLDS_OFFSET=0,Mh.SIZE=4*(Mh.COUNT=16*Mh.BATCHING_COUNT),Mh.NAME="CCLocalBatched",Mh.BINDING=Ju.UBO_LOCAL,Mh.DESCRIPTOR=new tc(Mh.BINDING,ss.UNIFORM_BUFFER,1,Qa.VERTEX),Mh.LAYOUT=new zs(th.LOCAL,Mh.BINDING,Mh.NAME,[new Fs("cc_matWorlds",Ma.MAT4,Mh.BATCHING_COUNT)],1),Zu.layouts[Mh.NAME]=Mh.LAYOUT,Zu.bindings[Mh.BINDING]=Mh.DESCRIPTOR;var Lh=function(){};Lh.LIGHTS_PER_PASS=1,Lh.SIZE=4*(Lh.COUNT=(Lh.LIGHT_DIR_OFFSET=(Lh.LIGHT_SIZE_RANGE_ANGLE_OFFSET=(Lh.LIGHT_COLOR_OFFSET=(Lh.LIGHT_POS_OFFSET=0)+4*Lh.LIGHTS_PER_PASS)+4*Lh.LIGHTS_PER_PASS)+4*Lh.LIGHTS_PER_PASS)+4*Lh.LIGHTS_PER_PASS),Lh.NAME="CCForwardLight",Lh.BINDING=Ju.UBO_FORWARD_LIGHTS,Lh.DESCRIPTOR=new tc(Lh.BINDING,ss.DYNAMIC_UNIFORM_BUFFER,1,Qa.FRAGMENT),Lh.LAYOUT=new zs(th.LOCAL,Lh.BINDING,Lh.NAME,[new Fs("cc_lightPos",Ma.FLOAT4,Lh.LIGHTS_PER_PASS),new Fs("cc_lightColor",Ma.FLOAT4,Lh.LIGHTS_PER_PASS),new Fs("cc_lightSizeRangeAngle",Ma.FLOAT4,Lh.LIGHTS_PER_PASS),new Fs("cc_lightDir",Ma.FLOAT4,Lh.LIGHTS_PER_PASS)],1),Zu.layouts[Lh.NAME]=Lh.LAYOUT,Zu.bindings[Lh.BINDING]=Lh.DESCRIPTOR;var Fh=function(){};Fh.LIGHTS_PER_PASS=10;var zh=e("cE",(function(){}));zh.JOINTS_TEXTURE_INFO_OFFSET=0,zh.COUNT=zh.JOINTS_TEXTURE_INFO_OFFSET+4,zh.SIZE=4*zh.COUNT,zh.NAME="CCSkinningTexture",zh.BINDING=Ju.UBO_SKINNING_TEXTURE,zh.DESCRIPTOR=new tc(zh.BINDING,ss.UNIFORM_BUFFER,1,Qa.VERTEX),zh.LAYOUT=new zs(th.LOCAL,zh.BINDING,zh.NAME,[new Fs("cc_jointTextureInfo",Ma.FLOAT4,1)],1),Zu.layouts[zh.NAME]=zh.LAYOUT,Zu.bindings[zh.BINDING]=zh.DESCRIPTOR;var Bh=e("cw",(function(){}));Bh.JOINTS_ANIM_INFO_OFFSET=0,Bh.COUNT=Bh.JOINTS_ANIM_INFO_OFFSET+4,Bh.SIZE=4*Bh.COUNT,Bh.NAME="CCSkinningAnimation",Bh.BINDING=Ju.UBO_SKINNING_ANIMATION,Bh.DESCRIPTOR=new tc(Bh.BINDING,ss.UNIFORM_BUFFER,1,Qa.VERTEX),Bh.LAYOUT=new zs(th.LOCAL,Bh.BINDING,Bh.NAME,[new Fs("cc_jointAnimInfo",Ma.FLOAT4,1)],1),Zu.layouts[Bh.NAME]=Bh.LAYOUT,Zu.bindings[Bh.BINDING]=Bh.DESCRIPTOR;var Uh=e("cG","a_jointAnimInfo"),Hh=e("cC",(function(){}));Hh.JOINTS_OFFSET=0,Hh.COUNT=Hh.JOINTS_OFFSET+360,Hh.SIZE=4*Hh.COUNT,Hh.NAME="CCSkinning",Hh.BINDING=Ju.UBO_SKINNING_TEXTURE,Hh.DESCRIPTOR=new tc(Hh.BINDING,ss.UNIFORM_BUFFER,1,Qa.VERTEX),Hh.LAYOUT=new zs(th.LOCAL,Hh.BINDING,Hh.NAME,[new Fs("cc_joints",Ma.FLOAT4,90)],1),Zu.layouts[Hh.NAME]=Hh.LAYOUT,Zu.bindings[Hh.BINDING]=Hh.DESCRIPTOR;var Gh=e("bz",(function(){}));Gh.MAX_MORPH_TARGET_COUNT=60,Gh.OFFSET_OF_WEIGHTS=0,Gh.OFFSET_OF_DISPLACEMENT_TEXTURE_WIDTH=4*Gh.MAX_MORPH_TARGET_COUNT,Gh.OFFSET_OF_DISPLACEMENT_TEXTURE_HEIGHT=Gh.OFFSET_OF_DISPLACEMENT_TEXTURE_WIDTH+4,Gh.OFFSET_OF_VERTICES_COUNT=Gh.OFFSET_OF_DISPLACEMENT_TEXTURE_HEIGHT+4,Gh.COUNT_BASE_4_BYTES=4*Math.ceil(Gh.MAX_MORPH_TARGET_COUNT/4)+4,Gh.SIZE=4*Gh.COUNT_BASE_4_BYTES,Gh.NAME="CCMorph",Gh.BINDING=Ju.UBO_MORPH,Gh.DESCRIPTOR=new tc(Gh.BINDING,ss.UNIFORM_BUFFER,1,Qa.VERTEX),Gh.LAYOUT=new zs(th.LOCAL,Gh.BINDING,Gh.NAME,[new Fs("cc_displacementWeights",Ma.FLOAT4,Gh.MAX_MORPH_TARGET_COUNT/4),new Fs("cc_displacementTextureInfo",Ma.FLOAT4,1)],1),Zu.layouts[Gh.NAME]=Gh.LAYOUT,Zu.bindings[Gh.BINDING]=Gh.DESCRIPTOR;var Vh=e("cF",Ju.SAMPLER_JOINTS),kh=new tc(Vh,ss.SAMPLER_TEXTURE,1,Qa.VERTEX),Wh=new Bs(th.LOCAL,Vh,"cc_jointTexture",Ma.SAMPLER2D,1);Zu.layouts.cc_jointTexture=Wh,Zu.bindings[Vh]=kh;var jh=e("bI",Ju.SAMPLER_MORPH_POSITION),qh=new tc(jh,ss.SAMPLER_TEXTURE,1,Qa.VERTEX),Yh=new Bs(th.LOCAL,jh,"cc_PositionDisplacements",Ma.SAMPLER2D,1);Zu.layouts.cc_PositionDisplacements=Yh,Zu.bindings[jh]=qh;var Xh=e("bH",Ju.SAMPLER_MORPH_NORMAL),Kh=new tc(Xh,ss.SAMPLER_TEXTURE,1,Qa.VERTEX),Qh=new Bs(th.LOCAL,Xh,"cc_NormalDisplacements",Ma.SAMPLER2D,1);Zu.layouts.cc_NormalDisplacements=Qh,Zu.bindings[Xh]=Kh;var Zh=e("bG",Ju.SAMPLER_MORPH_TANGENT),Jh=new tc(Zh,ss.SAMPLER_TEXTURE,1,Qa.VERTEX),$h=new Bs(th.LOCAL,Zh,"cc_TangentDisplacements",Ma.SAMPLER2D,1);Zu.layouts.cc_TangentDisplacements=$h,Zu.bindings[Zh]=Jh;var e_=Ju.SAMPLER_LIGHTMAP,t_=new tc(e_,ss.SAMPLER_TEXTURE,1,Qa.FRAGMENT),n_=new Bs(th.LOCAL,e_,"cc_lightingMap",Ma.SAMPLER2D,1);Zu.layouts.cc_lightingMap=n_,Zu.bindings[e_]=t_;var i_=Ju.SAMPLER_SPRITE,o_=new tc(i_,ss.SAMPLER_TEXTURE,1,Qa.FRAGMENT),r_=new Bs(th.LOCAL,i_,"cc_spriteTexture",Ma.SAMPLER2D,1);Zu.layouts.cc_spriteTexture=r_,Zu.bindings[i_]=o_;var a_,s_,c_,l_,u_,h_=Vu.makeMaskExclude([Vu.BitMask.UI_2D,Vu.BitMask.GIZMOS,Vu.BitMask.EDITOR,Vu.BitMask.SCENE_GIZMO,Vu.BitMask.PROFILER]),__=Vu.makeMaskExclude([Vu.BitMask.UI_2D,Vu.BitMask.PROFILER]),f_=Vu.Enum.ALL;function d_(e){return e.hasFeature(Na.COLOR_HALF_FLOAT)&&e.hasFeature(Na.TEXTURE_HALF_FLOAT)}e("fq",Object.freeze({__proto__:null,PIPELINE_FLOW_GBUFFER:ju,PIPELINE_FLOW_LIGHTING:qu,PIPELINE_FLOW_FORWARD:Yu,PIPELINE_FLOW_SHADOW:Xu,PIPELINE_FLOW_SMAA:"SMAAFlow",PIPELINE_FLOW_TONEMAP:"ToneMapFlow",get RenderPassStage(){return ku},get RenderPriority(){return Wu},globalDescriptorSetLayout:Qu,localDescriptorSetLayout:Zu,get PipelineGlobalBindings(){return Ku},get ModelLocalBindings(){return Ju},get SetIndex(){return th},bindingMappingInfo:oh,UBOGlobal:rh,UBOCamera:ah,UBOShadow:sh,UNIFORM_SHADOWMAP_BINDING:ch,UNIFORM_GBUFFER_ALBEDOMAP_BINDING:hh,UNIFORM_GBUFFER_POSITIONMAP_BINDING:dh,UNIFORM_GBUFFER_NORMALMAP_BINDING:vh,UNIFORM_LIGHTING_RESULTMAP_BINDING:xh,UNIFORM_GBUFFER_EMISSIVEMAP_BINDING:Th,UNIFORM_ENVIRONMENT_BINDING:Ch,UNIFORM_SPOT_LIGHTING_MAP_TEXTURE_BINDING:bh,UBOLocal:Oh,INST_MAT_WORLD:Dh,UBOLocalBatched:Mh,UBOForwardLight:Lh,UBODeferredLight:Fh,JOINT_UNIFORM_CAPACITY:30,UBOSkinningTexture:zh,UBOSkinningAnimation:Bh,INST_JOINT_ANIM_INFO:Uh,UBOSkinning:Hh,UBOMorph:Gh,UNIFORM_JOINT_TEXTURE_BINDING:Vh,UNIFORM_POSITION_MORPH_TEXTURE_BINDING:jh,UNIFORM_NORMAL_MORPH_TEXTURE_BINDING:Xh,UNIFORM_TANGENT_MORPH_TEXTURE_BINDING:Zh,UNIFORM_LIGHTMAP_TEXTURE_BINDING:e_,UNIFORM_SPRITE_TEXTURE_BINDING:i_,CAMERA_DEFAULT_MASK:h_,CAMERA_EDITOR_MASK:__,MODEL_ALWAYS_MASK:f_,supportsHalfFloatTexture:d_})),function(e){e[e.VERTICAL=0]="VERTICAL",e[e.HORIZONTAL=1]="HORIZONTAL"}(a_||(a_={})),function(e){e[e.ORTHO=0]="ORTHO",e[e.PERSPECTIVE=1]="PERSPECTIVE"}(s_||(s_={})),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"}(c_||(c_={})),function(e){e[e.ISO100=0]="ISO100",e[e.ISO200=1]="ISO200",e[e.ISO400=2]="ISO400",e[e.ISO800=3]="ISO800"}(l_||(l_={})),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"}(u_||(u_={}));var p_,m_,v_=[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],g_=[1,.5,1/4,1/8,1/15,1/30,1/60,.008,.004,.002,.001,5e-4,1/4e3],y_=[100,200,400,800],x_=new Rn,E_=new Rn,S_=new jn,T_=us.STENCIL<<1,A_=[],w_=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=a_.VERTICAL,this._fov=fn(45),this._nearClip=1,this._farClip=1e3,this._clearColor=new Cs(.2,.2,.2,1),this._viewport=new oi(0,0,1,1),this._curTransform=Ra.IDENTITY,this._isProjDirty=!0,this._matView=new jn,this._matViewInv=null,this._matProj=new jn,this._matProjInv=new jn,this._matViewProj=new jn,this._matViewProjInv=new jn,this._frustum=new Tu,this._forward=new Rn,this._position=new Rn,this._priority=0,this._aperture=c_.F16_0,this._apertureValue=void 0,this._shutter=u_.D125,this._shutterValue=0,this._iso=l_.ISO100,this._isoValue=0,this._ec=0,this._poolHandle=bo,this._frustumHandle=bo,this._window=null,this._device=e,this._apertureValue=v_[this._aperture],this._shutterValue=g_[this._shutter],this._isoValue=y_[this._iso],this._aspect=this.screenScale=1,!A_.length){var t=e.capabilities.clipSpaceSignY;A_[Ra.IDENTITY]=new jn(1,0,0,0,0,t),A_[Ra.ROTATE_90]=new jn(0,1,0,0,-t,0),A_[Ra.ROTATE_180]=new jn(-1,0,0,0,0,-t),A_[Ra.ROTATE_270]=new jn(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=ur.alloc();ur.set(t,rr.WIDTH,1),ur.set(t,rr.HEIGHT,1),ur.set(t,rr.CLEAR_FLAGS,us.NONE),ur.set(t,rr.CLEAR_DEPTH,1),ur.set(t,rr.NODE,this._node.handle),ur.set(t,rr.VISIBILITY,h_),this._scene&&ur.set(t,rr.SCENE,this._scene.handle),this.updateExposure(),this.changeTargetWindow(e.window),console.log("Created Camera: "+this._name+" "+ur.get(t,rr.WIDTH)+"x"+ur.get(t,rr.HEIGHT))},t.destroy=function(){this._window&&this._window.detachCamera(this),this._name=null,this._poolHandle&&(ur.free(this._poolHandle),this._poolHandle=bo,this._frustumHandle&&(Sr.free(this._frustumHandle),this._frustumHandle=bo))},t.attachToScene=function(e){this._scene=e,this._enabled=!0,ur.set(this._poolHandle,rr.SCENE,e.handle)},t.detachFromScene=function(){this._scene=null,this._enabled=!1,ur.set(this._poolHandle,rr.SCENE,0)},t.resize=function(e,t){var n=this._poolHandle;ur.set(n,rr.WIDTH,e),ur.set(n,rr.HEIGHT,t),this._aspect=e*this._viewport.width/(t*this._viewport.height),this._isProjDirty=!0},t.setFixedSize=function(e,t){var n=this._poolHandle;ur.set(n,rr.WIDTH,e),ur.set(n,rr.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)&&(jn.invert(this._matView,this._node.worldMatrix),ur.setMat4(this._poolHandle,rr.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),ur.setVec3(this._poolHandle,rr.POSITION,this._position),ur.setVec3(this._poolHandle,rr.FORWARD,this._forward),t=!0);var n=this._device.surfaceTransform;if(this._isProjDirty||this._curTransform!==n){var i;this._curTransform=n;var o=this._device.capabilities.clipSpaceSignY;if((null===(i=this.window)||void 0===i?void 0:i.hasOffScreenAttachments)&&(n=Ra.IDENTITY),this._proj===s_.PERSPECTIVE)jn.perspective(this._matProj,this._fov,this._aspect,this._nearClip,this._farClip,this._fovAxis===a_.VERTICAL,this._device.capabilities.clipSpaceMinZ,o,n);else{var r=this._orthoHeight*this._aspect,a=this._orthoHeight;jn.ortho(this._matProj,-r,r,-a,a,this._nearClip,this._farClip,this._device.capabilities.clipSpaceMinZ,o,n)}jn.invert(this._matProjInv,this._matProj),ur.setMat4(this._poolHandle,rr.MAT_PROJ,this._matProj),ur.setMat4(this._poolHandle,rr.MAT_PROJ_INV,this._matProjInv),t=!0,this._isProjDirty=!1}t&&(jn.multiply(this._matViewProj,this._matProj,this._matView),jn.invert(this._matViewProjInv,this._matViewProj),this._frustum.update(this._matViewProj,this._matViewProjInv),ur.setMat4(this._poolHandle,rr.MAT_VIEW_PROJ,this._matViewProj),ur.setMat4(this._poolHandle,rr.MAT_VIEW_PROJ_INV,this._matViewProjInv),Au(this._frustumHandle,this._frustum))}},t.changeTargetWindow=function(e){void 0===e&&(e=null),this._window&&this._window.detachCamera(this);var t=e||c.director.root.mainWindow;t&&(t.attachCamera(this),this.resize(t.width,t.height),this._window=t,ur.set(this._poolHandle,rr.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,o=ur.get(i,rr.WIDTH),r=ur.get(i,rr.HEIGHT),a=this._viewport.x*o,s=this._viewport.y*r,c=this._viewport.width*o,l=this._viewport.height*r,u=this._proj===s_.PERSPECTIVE,h=this._device.capabilities.clipSpaceSignY,_=Wn[this._curTransform];Rn.set(x_,(t-a)/c*2-1,(n-s)/l*2-1,u?1:-1);var f=x_.x,d=x_.y;return x_.x=f*_[0]+d*_[2]*h,x_.y=f*_[1]+d*_[3]*h,Rn.transformMat4(u?x_:e.o,x_,this._matViewProjInv),u?(this._node.getWorldPosition(E_),Ea.fromPoints(e,E_,x_)):Rn.transformQuat(e.d,Rn.FORWARD,this._node.worldRotation),e},t.screenToWorld=function(e,t){var n=this._poolHandle,i=ur.get(n,rr.WIDTH),o=ur.get(n,rr.HEIGHT),r=this._viewport.x*i,a=this._viewport.y*o,s=this._viewport.width*i,c=this._viewport.height*o,l=this._device.capabilities.clipSpaceSignY,u=Wn[this._curTransform];if(this._proj===s_.PERSPECTIVE){Rn.set(e,(t.x-r)/s*2-1,(t.y-a)/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,Rn.transformMat4(e,e,this._matViewProjInv),this._node&&this._node.getWorldPosition(x_),Rn.lerp(e,x_,e,_n(this._nearClip/this._farClip,1,t.z))}else{Rn.set(e,(t.x-r)/s*2-1,(t.y-a)/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,Rn.transformMat4(e,e,this._matViewProjInv)}return e},t.worldToScreen=function(e,t){var n=this._poolHandle,i=ur.get(n,rr.WIDTH),o=ur.get(n,rr.HEIGHT),r=this._viewport.x*i,a=this._viewport.y*o,s=this._viewport.width*i,c=this._viewport.height*o,l=this._device.capabilities.clipSpaceSignY,u=Wn[this._curTransform];Rn.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=r+.5*(e.x+1)*s,e.y=a+.5*(e.y+1)*c,e.z=.5*e.z+.5,e},t.worldMatrixToScreen=function(e,t,n,i){jn.multiply(e,this._matViewProj,t),jn.multiply(e,A_[this._curTransform],e);var o=n/2,r=i/2;return jn.identity(S_),jn.transform(S_,S_,Rn.set(x_,o,r,0)),jn.scale(S_,S_,Rn.set(x_,o,r,1)),jn.multiply(e,S_,e),e},t.updateExposure=function(){var e=Math.log2(this._apertureValue*this._apertureValue/this._shutterValue*100/this._isoValue);ur.set(this._poolHandle,rr.EXPOSURE,.833333/Math.pow(2,e))},te(e,[{key:"node",get:function(){return this._node},set:function(e){this._node=e}},{key:"enabled",get:function(){return this._enabled},set:function(e){this._enabled=e}},{key:"orthoHeight",get:function(){return this._orthoHeight},set:function(e){this._orthoHeight=e,this._isProjDirty=!0}},{key:"projectionType",get:function(){return this._proj},set:function(e){this._proj=e,this._isProjDirty=!0}},{key:"fovAxis",get:function(){return this._fovAxis},set:function(e){this._fovAxis=e,this._isProjDirty=!0}},{key:"fov",get:function(){return this._fov},set:function(e){this._fov=e,this._isProjDirty=!0}},{key:"nearClip",get:function(){return this._nearClip},set:function(e){this._nearClip=e,this._isProjDirty=!0}},{key:"farClip",get:function(){return this._farClip},set:function(e){this._farClip=e,this._isProjDirty=!0}},{key:"clearColor",get:function(){return this._clearColor},set:function(e){this._clearColor.x=e.x,this._clearColor.y=e.y,this._clearColor.z=e.z,this._clearColor.w=e.w,ur.setVec4(this._poolHandle,rr.CLEAR_COLOR,e)}},{key:"viewport",get:function(){return this._viewport},set:function(e){var t=e.x,n=e.width,i=e.height,o=this._device.capabilities.clipSpaceSignY<0?1-e.y-i:e.y;switch(this._device.surfaceTransform){case Ra.ROTATE_90:this._viewport.x=1-o-i,this._viewport.y=t,this._viewport.width=i,this._viewport.height=n;break;case Ra.ROTATE_180:this._viewport.x=1-t-n,this._viewport.y=1-o-i,this._viewport.width=n,this._viewport.height=i;break;case Ra.ROTATE_270:this._viewport.x=o,this._viewport.y=1-t-n,this._viewport.width=i,this._viewport.height=n;break;case Ra.IDENTITY:this._viewport.x=t,this._viewport.y=o,this._viewport.width=n,this._viewport.height=i}ur.setVec4(this._poolHandle,rr.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 ur.get(this._poolHandle,rr.WIDTH)}},{key:"height",get:function(){return ur.get(this._poolHandle,rr.HEIGHT)}},{key:"aspect",get:function(){return this._aspect}},{key:"matView",get:function(){return this._matView},set:function(e){this._matView=e,ur.setMat4(this._poolHandle,rr.MAT_VIEW,this._matView)}},{key:"matViewInv",get:function(){return this._matViewInv||this._node.worldMatrix},set:function(e){this._matViewInv=e}},{key:"matProj",get:function(){return this._matProj},set:function(e){this._matProj=e,ur.setMat4(this._poolHandle,rr.MAT_PROJ,this._matProj)}},{key:"matProjInv",get:function(){return this._matProjInv},set:function(e){this._matProjInv=e,ur.setMat4(this._poolHandle,rr.MAT_PROJ_INV,this._matProjInv)}},{key:"matViewProj",get:function(){return this._matViewProj},set:function(e){this._matViewProj=e,ur.setMat4(this._poolHandle,rr.MAT_VIEW_PROJ,this._matViewProj)}},{key:"matViewProjInv",get:function(){return this._matViewProjInv},set:function(e){this._matViewProjInv=e,ur.setMat4(this._poolHandle,rr.MAT_VIEW_PROJ_INV,this._matViewProjInv)}},{key:"frustum",get:function(){return this._frustum},set:function(e){this._frustum=e,Au(this._frustumHandle,e)}},{key:"window",get:function(){return this._window},set:function(e){this._window=e,e&&ur.set(this._poolHandle,rr.WINDOW,e.handle)}},{key:"forward",get:function(){return this._forward},set:function(e){this._forward=e,ur.setVec3(this._poolHandle,rr.FORWARD,this._forward)}},{key:"position",get:function(){return this._position},set:function(e){this._position=e,ur.setVec3(this._poolHandle,rr.POSITION,this._position)}},{key:"visibility",get:function(){return ur.get(this._poolHandle,rr.VISIBILITY)},set:function(e){ur.set(this._poolHandle,rr.VISIBILITY,e)}},{key:"priority",get:function(){return this._priority},set:function(e){this._priority=e}},{key:"aperture",get:function(){return this._aperture},set:function(e){this._aperture=e,this._apertureValue=v_[this._aperture],this.updateExposure()}},{key:"apertureValue",get:function(){return this._apertureValue}},{key:"shutter",get:function(){return this._shutter},set:function(e){this._shutter=e,this._shutterValue=g_[this._shutter],this.updateExposure()}},{key:"shutterValue",get:function(){return this._shutterValue}},{key:"iso",get:function(){return this._iso},set:function(e){this._iso=e,this._isoValue=y_[this._iso],this.updateExposure()}},{key:"isoValue",get:function(){return this._isoValue}},{key:"ec",get:function(){return this._ec},set:function(e){this._ec=e}},{key:"exposure",get:function(){return ur.get(this._poolHandle,rr.EXPOSURE)}},{key:"clearFlag",get:function(){return ur.get(this._poolHandle,rr.CLEAR_FLAGS)},set:function(e){ur.set(this._poolHandle,rr.CLEAR_FLAGS,e)}},{key:"clearDepth",get:function(){return ur.get(this._poolHandle,rr.CLEAR_DEPTH)},set:function(e){ur.set(this._poolHandle,rr.CLEAR_DEPTH,e)}},{key:"clearStencil",get:function(){return ur.get(this._poolHandle,rr.CLEAR_STENCIL)},set:function(e){ur.set(this._poolHandle,rr.CLEAR_STENCIL,e)}},{key:"handle",get:function(){return this._poolHandle}}]),e}();!function(e){e[e.LOCAL=0]="LOCAL",e[e.WORLD=1]="WORLD"}(p_||(p_={})),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"}(m_||(m_=e("c1",{}))),c.internal.TransformBit=m_;var C_=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=bo,this._modelArrayHandle=bo,this._batchArrayHandle=bo,this._sphereLightsHandle=bo,this._spotLightsHandle=bo,this._root=e,this._createHandles()}e.registerCreateFunc=function(t){t._createSceneFun=function(t){return new e(t)}};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 o=this._spotLights,r=0;r<o.length;r++)o[r].update();for(var a=this._models,s=0;s<a.length;s++){var c=a[s];c.enabled&&(c.updateTransform(e),c.updateUBOs(e))}},t.destroy=function(){this.removeCameras(),this.removeSphereLights(),this.removeSpotLights(),this.removeModels(),this._modelArrayHandle&&(Fo.free(this._modelArrayHandle),this._modelArrayHandle=bo),this._scenePoolHandle&&(sr.free(this._scenePoolHandle),this._scenePoolHandle=bo),this._sphereLightsHandle&&(Uo.free(this._sphereLightsHandle),this._sphereLightsHandle=bo),this._spotLightsHandle&&(Uo.free(this._spotLightsHandle),this._spotLightsHandle=bo),this._batchArrayHandle&&(Go.free(this._batchArrayHandle),this._batchArrayHandle=bo)},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=le(this._cameras);!(e=t()).done;)e.value.detachFromScene();this._cameras.splice(0)},t.setMainLight=function(e){this._mainLight=e,sr.set(this._scenePoolHandle,nr.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|=m_.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),Uo.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 Uo.erase(this._sphereLightsHandle,t)},t.addSpotLight=function(e){e.attachToScene(this),this._spotLights.push(e),Uo.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 Uo.erase(this._spotLightsHandle,t)},t.removeSphereLights=function(){for(var e=0;e<this._sphereLights.length;++e)this._sphereLights[e].detachFromScene();this._sphereLights.length=0,Uo.clear(this._sphereLightsHandle)},t.removeSpotLights=function(){for(var e=0;e<this._spotLights.length;++e)this._spotLights[e].detachFromScene();this._spotLights=[],Uo.clear(this._spotLightsHandle)},t.addModel=function(e){e.attachToScene(this),this._models.push(e),Fo.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 Fo.erase(this._modelArrayHandle,t)},t.removeModels=function(){for(var e,t=le(this._models);!(e=t()).done;){var n=e.value;n.detachFromScene(),n.destroy()}this._models.length=0,Fo.clear(this._modelArrayHandle)},t.addBatch=function(e){this._batches.push(e),Go.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 Go.erase(this._batchArrayHandle,t)},t.removeBatches=function(){this._batches.length=0,Go.clear(this._batchArrayHandle)},t.onGlobalPipelineStateChanged=function(){for(var e,t=le(this._models);!(e=t()).done;)e.value.onGlobalPipelineStateChanged()},t.generateModelId=function(){return this._modelId++},t._createHandles=function(){this._modelArrayHandle||(this._modelArrayHandle=Fo.alloc(),this._scenePoolHandle=sr.alloc(),sr.set(this._scenePoolHandle,nr.MODEL_ARRAY,this._modelArrayHandle),this._spotLightsHandle=Uo.alloc(),sr.set(this._scenePoolHandle,nr.SPOT_LIGHT_ARRAY,this._spotLightsHandle),this._sphereLightsHandle=Uo.alloc(),sr.set(this._scenePoolHandle,nr.SPHERE_LIGHT_ARRAY,this._sphereLightsHandle)),this._batchArrayHandle||(this._batchArrayHandle=Go.alloc(),sr.set(this._scenePoolHandle,nr.BATCH_ARRAY_2D,this._batchArrayHandle))},te(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}}]),e}(),I_=function(){},P_=function(){return I_},b_=R_((function(){}));function R_(e){return function(t){return"function"==typeof t?e(t):function(n){return e(n,t)}}}function N_(e){return function(t){return function(n){!function(e,t,n){var i=D_(e);if(i){var o=M_(i,"proto");M_(o,"editor")[t]=n}}(n,e,t)}}}var O_="__ccclassCache__";function D_(e){return M_(e,O_)}function M_(e,t){return e[t]||(e[t]={})}var L_=e("bK",R_((function(e,t){var n=at.getSuper(e);n===Object&&(n=null);var i={name:t,extends:n,ctor:e},o=e[O_];if(o){var r=o.proto;r&&at.mixin(i,r),e[O_]=void 0}return tn(i)}))),F_=e("d1",N_("requireComponent")),z_=e("c6",N_("executionOrder")),B_=e("cZ",b_);function U_(e,t,n){var i=null;function o(e,t,n){var o=D_(e.constructor);if(o){var r=M_(o,"proto"),a=M_(r,"properties");!function(e,t,n,i,o,r){var a,s=o&&(o.get||o.set);i&&(a=jt(i,s));var c=t[n],l=at.mixin(c||{},a||i||{});if(s)o.get&&(l.get=o.get),o.set&&(l.set=o.set);else if(o)o.initializer&&(l.default=function(e){var t;try{t=e()}catch(t){return e}return"object"!=typeof t||null===t?t:e}(o.initializer));else{var u=r.default||(r.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,a,t,i,n,o)}}return void 0===e?U_({type:void 0}):void 0===t?(i=e,o):void o(e,t,n)}var H_=e("bT",(function(e,t,n){return U_(V_({}))(e,t,n)})),G_=e("dO",(function(e,t,n){return U_({editorOnly:!0})(e,t,n)}));function V_(e){return e.__noImplicit=!0,"serializable"in e||(e.serializable=!0),e}var k_=e("c0",b_),W_=e("c7",P_),j_=e("ei",b_),q_=P_,Y_=P_,X_=e("c5",P_),K_=e("b_",I_),Q_=e("c9",P_),Z_=(e("e7",I_),e("d2",P_)),J_=e("c8",P_),$_=e("ci",P_),ef=e("dD",P_),tf=e("dE",P_),nf=P_,of=e("ch",I_),rf=e("c$",P_),af=(e("cm",P_),e("d$",I_),e("d4",I_),e("c3",I_)),sf=hf(Lt),cf=hf(Ft),lf=hf(zt),uf=e("cT",hf(Bt));function hf(e){return U_({type:e})}var _f=e("cL",(function(e,t,n){return U_({__noImplicit:!0,override:!0})(e,t,n)})),ff=function(){function e(e){this._map=null,this._count=0,e?(this._map=e,this._count=Object.keys(e).length):(this._map=at.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=at.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},te(e,[{key:"count",get:function(){return this._count}}]),e}(),df=function(){function e(t,n){this.id=e._pipelineId++,this.name="",this.pipes=[],this.name=t;for(var i=0,o=n.length;i<o;i++)this.pipes.push(n[i])}var t=e.prototype;return t.insert=function(e,t){return t>this.pipes.length?(b(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 o=(0,t[n])(e);if(o)return e.isFinish=!0,o;++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}();df._pipelineId=0;var pf,mf=new ff,vf=new ff,gf=new ff,yf=new ff,xf=new df("normal load",[]),Ef=new df("fetch",[]),Sf=new df("transform url",[]);!function(e){e.UUID="uuid",e.PATH="path",e.DIR="dir",e.URL="url",e.SCENE="scene"}(pf||(pf={}));var Tf,Af={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"}(Tf||(Tf={}));var wf=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,o){switch(e){case"complete":this.onComplete&&this.onComplete(t,n);break;case"progress":this.onProgress&&this.onProgress(t,n,i,o);break;case"error":this.onError&&this.onError(t,n,i,o);break;default:var r="on"+e[0].toUpperCase()+e.substr(1);"function"==typeof this[r]&&this[r](t,n,i,o)}},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}();wf.MAX_DEAD_NUM=500,wf._taskId=0,wf._deadPool=[];var Cf="0123456789abcdef".split(""),If=["","","",""],Pf=If.concat(If,"-",If,"-",If,"-",If,"-",If,If,If),bf=Pf.map((function(e,t){return"-"===e?NaN:t})).filter(isFinite);function Rf(e){var t=e.split("@")[0];if(22!==t.length)return e;Pf[0]=e[0],Pf[1]=e[1];for(var n=2,i=2;n<22;n+=2){var o=gt[e.charCodeAt(n)],r=gt[e.charCodeAt(n+1)];Pf[bf[i++]]=Cf[o>>2],Pf[bf[i++]]=Cf[(3&o)<<2|r>>4],Pf[bf[i++]]=Cf[15&r]}return e.replace(t,Pf.join(""))}var Nf=/.*[/\\][0-9a-fA-F]{2}[/\\]([0-9a-fA-F-@]{8,}).*/;function Of(e){var t=Nf.exec(e);return t?t[1]:""}function Df(e,t){(t=t||Object.create(null)).__isNative__=t.isNative,t.ext=t.nativeExt;var n=yf.find((function(t){return!!t.getAssetInfo(e)}));return n&&(t.bundle=n.name),Ff(e,t)}function Mf(e){return e&&(e instanceof c.SceneAsset||e instanceof c.Scene)}function Lf(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 Ff(e,t){var n=wf.create({input:e,options:t}),i=[];try{for(var o,r=le(Sf.sync(n));!(o=r()).done;){var a=o.value,s=a.url;a.recycle(),i.push(s)}}catch(e){for(var c,l=le(n.output);!(c=l()).done;)c.value.recycle();x(e.message,e.stack)}return n.recycle(),i.length>1?i:i[0]}var zf,Bf,Uf,Hf,Gf=Object.freeze({__proto__:null,getUuidFromURL:Of,getUrlWithUuid:Df,isScene:Mf,normalize:Lf,transform:Ff,decodeUuid:Rf}),Vf=e("dM",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}());Vf.NO_TYPE="no_type",Vf.TOUCH="touch",Vf.MOUSE="mouse",Vf.KEYBOARD="keyboard",Vf.ACCELERATION="acceleration",Vf.NONE=0,Vf.CAPTURING_PHASE=1,Vf.AT_TARGET=2,Vf.BUBBLING_PHASE=3,c.Event=Vf;var kf=e("bN",L_("cc.Asset")((Hf=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return(t=e.call.apply(e,[this].concat(i))||this).loaded=!0,ue(t,"_native",Uf,se(t)),t._nativeUrl="",t.__onLoadedInvoked__=!1,t.__nativeDepend__=null,t.__depends__=null,t._file=null,t._ref=0,Object.defineProperty(se(t),"_uuid",{value:"",writable:!0}),t}ie(t,e),t.deserialize=function(e){return c.deserialize(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&&c.assetManager._releaseManager.tryRelease(this),this},n.onLoaded=function(){},n.initDefault=function(e){e&&(this._uuid=e),this.isDefault=!0},n.validate=function(){return!0},te(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=Df(this._uuid,{nativeExt:e,isNative:!0}):this._nativeUrl=Df(this._uuid,{__nativeName__:e,nativeExt:Fi(e),isNative:!0})}return this._nativeUrl}},{key:"_nativeAsset",get:function(){return this._file},set:function(e){this._file=e}},{key:"_nativeDep",get:function(){if(this._native)return{__isNative__:!0,uuid:this._uuid,ext:this._native}}},{key:"refCount",get:function(){return this._ref}}]),t}(Ei(hi)),Uf=he((Bf=Hf).prototype,"_native",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),he(Bf.prototype,"_nativeAsset",[U_],Object.getOwnPropertyDescriptor(Bf.prototype,"_nativeAsset"),Bf.prototype),zf=Bf))||zf);kf.prototype.createNode=null,c.Asset=kf;var Wf,jf,qf,Yf,Xf,Kf,Qf,Zf=1024;function Jf(e){return c.sys.capabilities.imageBitmap&&e instanceof ImageBitmap}!function(e){e[e.RGB565=Oa.R5G6B5]="RGB565",e[e.RGB5A1=Oa.RGB5A1]="RGB5A1",e[e.RGBA4444=Oa.RGBA4]="RGBA4444",e[e.RGB888=Oa.RGB8]="RGB888",e[e.RGB32F=Oa.RGB32F]="RGB32F",e[e.RGBA8888=Oa.RGBA8]="RGBA8888",e[e.RGBA32F=Oa.RGBA32F]="RGBA32F",e[e.A8=Oa.A8]="A8",e[e.I8=Oa.L8]="I8",e[e.AI8=Oa.LA8]="AI8",e[e.RGB_PVRTC_2BPPV1=Oa.PVRTC_RGB2]="RGB_PVRTC_2BPPV1",e[e.RGBA_PVRTC_2BPPV1=Oa.PVRTC_RGBA2]="RGBA_PVRTC_2BPPV1",e[e.RGB_A_PVRTC_2BPPV1=Zf++]="RGB_A_PVRTC_2BPPV1",e[e.RGB_PVRTC_4BPPV1=Oa.PVRTC_RGB4]="RGB_PVRTC_4BPPV1",e[e.RGBA_PVRTC_4BPPV1=Oa.PVRTC_RGBA4]="RGBA_PVRTC_4BPPV1",e[e.RGB_A_PVRTC_4BPPV1=Zf++]="RGB_A_PVRTC_4BPPV1",e[e.RGB_ETC1=Oa.ETC_RGB8]="RGB_ETC1",e[e.RGBA_ETC1=Zf++]="RGBA_ETC1",e[e.RGB_ETC2=Oa.ETC2_RGB8]="RGB_ETC2",e[e.RGBA_ETC2=Oa.ETC2_RGBA8]="RGBA_ETC2",e[e.RGBA_ASTC_4x4=Oa.ASTC_RGBA_4x4]="RGBA_ASTC_4x4",e[e.RGBA_ASTC_5x4=Oa.ASTC_RGBA_5x4]="RGBA_ASTC_5x4",e[e.RGBA_ASTC_5x5=Oa.ASTC_RGBA_5x5]="RGBA_ASTC_5x5",e[e.RGBA_ASTC_6x5=Oa.ASTC_RGBA_6x5]="RGBA_ASTC_6x5",e[e.RGBA_ASTC_6x6=Oa.ASTC_RGBA_6x6]="RGBA_ASTC_6x6",e[e.RGBA_ASTC_8x5=Oa.ASTC_RGBA_8x5]="RGBA_ASTC_8x5",e[e.RGBA_ASTC_8x6=Oa.ASTC_RGBA_8x6]="RGBA_ASTC_8x6",e[e.RGBA_ASTC_8x8=Oa.ASTC_RGBA_8x8]="RGBA_ASTC_8x8",e[e.RGBA_ASTC_10x5=Oa.ASTC_RGBA_10x5]="RGBA_ASTC_10x5",e[e.RGBA_ASTC_10x6=Oa.ASTC_RGBA_10x6]="RGBA_ASTC_10x6",e[e.RGBA_ASTC_10x8=Oa.ASTC_RGBA_10x8]="RGBA_ASTC_10x8",e[e.RGBA_ASTC_10x10=Oa.ASTC_RGBA_10x10]="RGBA_ASTC_10x10",e[e.RGBA_ASTC_12x10=Oa.ASTC_RGBA_12x10]="RGBA_ASTC_12x10",e[e.RGBA_ASTC_12x12=Oa.ASTC_RGBA_12x12]="RGBA_ASTC_12x12"}(Wf||(Wf=e("cK",{}))),function(e){e[e.REPEAT=Wa.WRAP]="REPEAT",e[e.CLAMP_TO_EDGE=Wa.CLAMP]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=Wa.MIRROR]="MIRRORED_REPEAT",e[e.CLAMP_TO_BORDER=Wa.BORDER]="CLAMP_TO_BORDER"}(jf||(jf=e("dU",{}))),function(e){e[e.NONE=ka.NONE]="NONE",e[e.LINEAR=ka.LINEAR]="LINEAR",e[e.NEAREST=ka.POINT]="NEAREST"}(qf||(qf=e("cJ",{})));var $f,ed=e("bA",L_("cc.ImageAsset")((Qf=Kf=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=Wf.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}ie(t,e);var n=t.prototype;return n.reset=function(e){var t=this;Jf(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){b(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("")):Jf(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 i,o=c.director.root?c.director.root.device:null,r=n.split("_"),a="",s=Number.MAX_VALUE,l=this._format,u="",h=c.macro.SUPPORT_TEXTURE_FORMATS,_=le(r);!(i=_()).done;){var f=i.value.split("@"),d=parseInt(f[0],void 0),p=t.extnames[d]||f[0],m=h.indexOf(p);if(-1!==m&&m<s){var v=f[1]?parseInt(f[1]):this._format;if(!(".astc"!==p||o&&o.hasFeature(Na.FORMAT_ASTC)))continue;if(!(".pvr"!==p||o&&o.hasFeature(Na.FORMAT_PVRTC)))continue;if(!(v!==Wf.RGB_ETC1&&v!==Wf.RGBA_ETC1||o&&o.hasFeature(Na.FORMAT_ETC1)))continue;if(!(v!==Wf.RGB_ETC2&&v!==Wf.RGBA_ETC2||o&&o.hasFeature(Na.FORMAT_ETC2)))continue;if(".webp"===p&&!c.sys.capabilities.webp)continue;s=m,u=p,l=v}else a||(a=p)}u?(this._setRawAsset(u),this._format=l):a?(this._setRawAsset(a),b(3120,a,a)):b(3121)},n._onDataComplete=function(){this.loaded=!0,this.emit("load")},n.initDefault=function(n){if(e.prototype.initDefault.call(this,n),t._sharedPlaceHolderCanvas)this.reset(t._sharedPlaceHolderCanvas);else{var i=document.createElement("canvas"),o=i.getContext("2d"),r=i.width=i.height=2;o.fillStyle="#ff00ff",o.fillRect(0,0,r,r),this.reset(i),t._sharedPlaceHolderCanvas=i}},n.validate=function(){return!!this.data},te(t,[{key:"_nativeAsset",get:function(){return this._nativeData},set:function(e){e instanceof HTMLElement||Jf(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||Jf(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>=Wf.RGB_ETC1&&this._format<=Wf.RGBA_ASTC_12x12||this._format>=Wf.RGB_A_PVRTC_2BPPV1&&this._format<=Wf.RGBA_ETC1}},{key:"url",get:function(){return this.nativeUrl}},{key:"_texture",get:function(){if(!this._tex){var e=new c.Texture2D;e.name=this.nativeUrl,e.image=this,this._tex=e}return this._tex},set:function(e){this._tex=e}}]),t}(kf),Kf.extnames=[".png",".jpg",".jpeg",".bmp",".webp",".pvr",".pkm",".astc"],Kf._sharedPlaceHolderCanvas=null,he((Xf=Qf).prototype,"_nativeAsset",[_f],Object.getOwnPropertyDescriptor(Xf.prototype,"_nativeAsset"),Xf.prototype),Yf=Xf))||Yf);c.ImageAsset=ed,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.mipLODBias=8]="mipLODBias",e[e.total=9]="total"}($f||($f={}));var td=[ka.LINEAR,ka.LINEAR,ka.NONE,Wa.WRAP,Wa.WRAP,Wa.WRAP,0,ja.NEVER,0],nd=rd(td),id=new Cs,od=new Ls;function rd(e){for(var t=0,n=0,i=0;i<td.length;i++)switch(t=e[i]||td[i],i){case $f.minFilter:n|=t;break;case $f.magFilter:n|=t<<2;break;case $f.mipFilter:n|=t<<4;break;case $f.addressU:n|=t<<6;break;case $f.addressV:n|=t<<8;break;case $f.addressW:n|=t<<10;break;case $f.maxAnisotropy:n|=t<<12;break;case $f.cmpFunc:n|=t<<16;break;case $f.mipLODBias:n|=t<<28}return n}var ad,sd,cd,ld,ud,hd,_d,fd,dd,pd,md,vd,gd=function(){function e(){this._cache={}}return e.prototype.getSampler=function(e,t){return t||(t=nd),this._cache[t]||(od.minFilter=3&t,od.magFilter=t>>2&3,od.mipFilter=t>>4&3,od.addressU=t>>6&3,od.addressV=t>>8&3,od.addressW=t>>10&3,od.maxAnisotropy=t>>12&15,od.cmpFunc=t>>16&15,od.mipLODBias=t>>28&15,od.borderColor=id,this._cache[t]=e.createSampler(od))},e}(),yd=e("bC",new gd);c.samplerLib=yd;var xd=new ge("Tex"),Ed=e("d3",L_("cc.TextureBase")((vd=md=function(e){function t(){var t;return ue(t=e.call(this)||this,"_format",cd,se(t)),ue(t,"_minFilter",ld,se(t)),ue(t,"_magFilter",ud,se(t)),ue(t,"_mipFilter",hd,se(t)),ue(t,"_wrapS",_d,se(t)),ue(t,"_wrapT",fd,se(t)),ue(t,"_wrapR",dd,se(t)),ue(t,"_anisotropy",pd,se(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=xd.getNewId(),t.loaded=!1,t._gfxDevice=t._getGFXDevice(),t._textureHash=Rc(t._id,666),t}ie(t,e);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[$f.addressU]=e,this._wrapT=t,this._samplerInfo[$f.addressV]=t,void 0!==n&&(this._wrapR=n,this._samplerInfo[$f.addressW]=n),this._samplerHash=rd(this._samplerInfo),this._gfxDevice&&(this._gfxSampler=yd.getSampler(this._gfxDevice,this._samplerHash))},n.setFilters=function(e,t){this._minFilter=e,this._samplerInfo[$f.minFilter]=e,this._magFilter=t,this._samplerInfo[$f.magFilter]=t,this._samplerHash=rd(this._samplerInfo),this._gfxDevice&&(this._gfxSampler=yd.getSampler(this._gfxDevice,this._samplerHash))},n.setMipFilter=function(e){this._mipFilter=e,this._samplerInfo[$f.mipFilter]=e,this._samplerHash=rd(this._samplerInfo),this._gfxDevice&&(this._gfxSampler=yd.getSampler(this._gfxDevice,this._samplerHash))},n.setAnisotropy=function(e){this._anisotropy=e,this._samplerInfo[$f.maxAnisotropy]=e,this._samplerHash=rd(this._samplerInfo),this._gfxDevice&&(this._gfxSampler=yd.getSampler(this._gfxDevice,this._samplerHash))},n.destroy=function(){var t=e.prototype.destroy.call(this);return t&&c.director.root&&c.director.root.batcher2D&&c.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=yd.getSampler(this._gfxDevice,this._samplerHash):N(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 c.director.root?c.director.root.device:null},n._getGFXFormat=function(){return this._getGFXPixelFormat(this._format)},n._setGFXFormat=function(e){this._format=void 0===e?Wf.RGBA8888:e},n._getGFXPixelFormat=function(e){return e===Wf.RGBA_ETC1?e=Wf.RGB_ETC1:e===Wf.RGB_A_PVRTC_4BPPV1?e=Wf.RGB_PVRTC_4BPPV1:e===Wf.RGB_A_PVRTC_2BPPV1&&(e=Wf.RGB_PVRTC_2BPPV1),e},te(t,[{key:"isCompressed",get:function(){return this._format>=Wf.RGB_ETC1&&this._format<=Wf.RGBA_ASTC_12x12||this._format>=Wf.RGB_A_PVRTC_2BPPV1&&this._format<=Wf.RGBA_ETC1}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}}]),t}(kf),md.PixelFormat=Wf,md.WrapMode=jf,md.Filter=qf,cd=he((sd=vd).prototype,"_format",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Wf.RGBA8888}}),ld=he(sd.prototype,"_minFilter",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return qf.LINEAR}}),ud=he(sd.prototype,"_magFilter",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return qf.LINEAR}}),hd=he(sd.prototype,"_mipFilter",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return qf.NONE}}),_d=he(sd.prototype,"_wrapS",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return jf.REPEAT}}),fd=he(sd.prototype,"_wrapT",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return jf.REPEAT}}),dd=he(sd.prototype,"_wrapR",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return jf.REPEAT}}),pd=he(sd.prototype,"_anisotropy",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),ad=sd))||ad);c.TextureBase=Ed;var Sd=[Kn,Rn,$n,zn,Pn,ni,oi,jn];function Td(e,t){e.x=t[1],e.y=t[2],e.z=t[3],e.w=t[4]}var Ad=[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]},Td,Td,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){jn.fromArray(e,t,1)}],wd=e("f2",function(){function e(){this.uuidObjList=null,this.uuidPropList=null,this.uuidList=null,this.uuidTypeList=[]}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,i){this.uuidObjList.push(e),this.uuidPropList.push(t),this.uuidList.push(n),this.uuidTypeList.push(i||"")},e}());function Cd(e,t){for(var n=e[4][t[0]],i=n[0],o=new(0,i[0]),r=i[1],a=i[2],s=n[n.length-1],c=1;c<s;++c)o[r[n[c]]]=t[c];for(;c<t.length;++c){var l=r[n[c]],u=i[n[c]+a];(0,Od[u])(e,o,l,t[c])}return o}function Id(e,t,n){var i=new t;return i._deserialize?i._deserialize(n,e[0]):N(5303,Ne(t)),i}function Pd(e,t,n,i){i>=0?t[n]=e[5][i]:e[7][3*~i]=t}function bd(e){return function(t,n,i,o){n[i]=o;for(var r=0;r<o.length;++r)e(t,o,r,o[r])}}function Rd(e,t,n,i){t[n]=null,e[8][i]=t}function Nd(e,t,n,i){t[n]=Cd(e,i)}wd.pool=new ot((function(e){e.reset()}),5),wd.pool.get=function(){return this._get()||new wd};var Od=new Array(13);function Dd(e,t){return e||zd.reportMissingClass(t),Object}function Md(e,t,n,i,o,r){var a=e(t);if(!a){if(o)return void(n[i]=function(t,n,i){return function(){var o=e(i)||Dd(r,i);return t[n]=o,new o}}(n,i,t));a=Dd(r,t)}n[i]=a}function Ld(e,t,n){for(var i=n||tt,o=e[3],r=0;r<o.length;++r){var a=o[r];"string"!=typeof a?Md(i,a[0],a,0,t,n):Md(i,a,o,r,t,n)}}function Fd(e){var t=e[4];if(t)for(var n=e[3],i=0;i<t.length;++i){var o=t[i];o[0]=n[o[0]]}}function zd(e,t,n){"string"==typeof e&&(e=JSON.parse(e));var i,o=!t;(t=t||wd.pool.get()).init(e),n=n||{};var r=e[0],a=!1;if("object"==typeof r&&(a=r.preprocessed,r=r.version),r<1)throw new Error(L(5304,r));n._version=r,n.result=t,e[0]=n,a||(Ld(e,!1,n.classFinder),Fd(e)),c.game._isCloning=!0;var s=e[5],l=function(e){var t=e[5],n=e[6],i=0===n?0:n.length,o=t[t.length-1],r=t.length-i;"number"!=typeof o?o=0:(o<0&&(o=~o),--r);for(var a=0;a<r;++a)t[a]=Cd(e,t[a]);for(var s=e[3],c=0;c<i;++c,++a){var l=n[c],u=t[a];if(l>=0){var h=s[l];t[a]=Id(e,h,u)}else(0,Od[l=~l])(e,t,a,u)}return o}(e);return c.game._isCloning=!1,e[7]&&function(e,t,n){for(var i=e.length-1,o=0,r=3*e[i];o<r;o+=3){var a=e[o],s=t[e[o+2]],c=e[o+1];c>=0?a[n[c]]=s:a[~c]=s}for(;o<i;o+=3){var l=t[e[o]],u=t[e[o+2]],h=e[o+1];h>=0?l[n[h]]=u:l[~h]=u}}(e[7],s,e[2]),function(e){for(var t=e[5],n=e[2],i=e[1],o=e[8],r=e[9],a=e[10],s=0;s<o.length;++s){var c=o[s];"number"==typeof c&&(o[s]=t[c]);var l=r[s];"number"==typeof l&&(l=l>=0?n[l]:~l,r[s]=l);var u=a[s];"number"==typeof u&&(a[s]=i[u])}}(e),i=s[l],o&&wd.pool.put(t),i}Od[0]=function(e,t,n,i){t[n]=i},Od[1]=Pd,Od[2]=bd(Pd),Od[3]=bd(Rd),Od[4]=Nd,Od[5]=function(e,t,n,i){Ad[i[0]](t[n],i)},Od[6]=Rd,Od[7]=function(e,t,n,i){t[n].set(i)},Od[8]=function(e,t,n,i){var o=new Sd[i[0]];Ad[i[0]](o,i),t[n]=o},Od[9]=bd(Nd),Od[10]=function(e,t,n,i){var o=e[3][i[0]];t[n]=Id(e,o,i[1])},Od[11]=function(e,t,n,i){var o=i[0];t[n]=o;for(var r=1;r<i.length;r+=3){var a=i[r],s=i[r+1],c=i[r+2];(0,Od[s])(e,o,a,c)}},Od[12]=function(e,t,n,i){var o=i[0];t[n]=o;for(var r=0;r<o.length;++r){var a=o[r],s=i[r+1];0!==s&&(0,Od[s])(e,o,r,a)}},zd.Details=wd,zd.reportMissingClass=function(e){b(5302,e)};var Bd,Ud,Hd,Gd=function(e){this.preprocessed=!0,this.version=e};function Vd(e,t,n){return[1,0,0,[e],0,n?[t,-1]:[t],[0],0,[],[],[]]}c.deserialize=zd;var kd=e("fa",L_("cc.Script")(Bd=function(e){function t(){return e.apply(this,arguments)||this}return ie(t,e),t}(kf))||Bd);c._Script=kd;var Wd=e("fb",L_("cc.JavaScript")(Ud=function(e){function t(){return e.apply(this,arguments)||this}return ie(t,e),t}(kd))||Ud);c._JavaScript=Wd;var jd,qd,Yd,Xd,Kd,Qd,Zd,Jd,$d,ep,tp,np=e("fc",L_("cc.TypeScript")(Hd=function(e){function t(){return e.apply(this,arguments)||this}return ie(t,e),t}(kd))||Hd);c._TypeScript=np;var ip,op,rp,ap,sp=new ge("Comp"),cp=hi.Flags.IsOnLoadCalled,lp=e("ck",(jd=L_("cc.Component"),qd=Z_(),Yd=hf(kd),Xd=J_(),jd((tp=ep=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return ue(t=e.call.apply(e,[this].concat(i))||this,"node",Zd,se(t)),ue(t,"_enabled",Jd,se(t)),ue(t,"__prefab",$d,se(t)),t._sceneGetter=null,t._id=sp.getNewId(),t}ie(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&&c.director._compScheduler.disableComp(this),!0)},n._onPreDestroy=function(){this.unscheduleAllCallbacks(),c.director._nodeActivator.destroyComp(this),this.node._removeComponent(this)},n._instantiate=function(e){return e||(e=c.instantiate._clone(this,this)),e&&(e.node=null),e},n.schedule=function(e,t,n,i){void 0===t&&(t=0),void 0===n&&(n=c.macro.REPEAT_FOREVER),void 0===i&&(i=0),M(e,1619),M((t=t||0)>=0,1620),n=Number.isNaN(n)?c.macro.REPEAT_FOREVER:n,i=i||0;var o=c.director.getScheduler(),r=o.isTargetPaused(this);o.schedule(e,this,t,n,i,r)},n.scheduleOnce=function(e,t){void 0===t&&(t=0),this.schedule(e,0,0,t)},n.unschedule=function(e){e&&c.director.getScheduler().unschedule(e,this)},n.unscheduleAllCallbacks=function(){c.director.getScheduler().unscheduleAllForTarget(this)},te(t,[{key:"name",get:function(){if(this._name)return this._name;var e=Ne(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=c.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&cp}}]),t}(hi),ep.system=null,he((Qd=tp).prototype,"__scriptAsset",[qd,Yd,Xd,af],Object.getOwnPropertyDescriptor(Qd.prototype,"__scriptAsset"),Qd.prototype),Zd=he(Qd.prototype,"node",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Jd=he(Qd.prototype,"_enabled",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),$d=he(Qd.prototype,"__prefab",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Kd=Qd))||Kd)),up=lp.prototype;up.update=null,up.lateUpdate=null,up.__preload=null,up.onLoad=null,up.start=null,up.onEnable=null,up.onDisable=null,up.onDestroy=null,up.onFocusInEditor=null,up.onLostFocusInEditor=null,up.resetInEditor=null,up._getLocalBounds=null,up.onRestore=null,lp._requireComponent=null,lp._executionOrder=0,Ce(lp,"_registerEditorProps",(function(e,t){var n=t.requireComponent;n&&(e._requireComponent=n);var i=t.executionOrder;i&&"number"==typeof i&&(e._executionOrder=i)})),c.Component=lp;var hp=e("fS",L_("cc.MissingScript")(ip=q_()((ap=function(e){function t(){var t;return ue(t=e.call(this)||this,"_$erialized",rp,se(t)),t}return ie(t,e),t.safeFindClass=function(e){var t=tt(e);if(t)return t;c.deserialize.reportMissingClass(e)},t.prototype.onLoad=function(){b(4600,this.node.name)},t}(lp),rp=he((op=ap).prototype,"_$erialized",[H_,G_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),ip=op))||ip)||ip);function _p(e,t){var n;n=hp.safeFindClass;var i,o=wd.pool.get();try{i=zd(e,o,{classFinder:n,customEnv:t})}catch(e){throw x(e),wd.pool.put(o),e}i._uuid=t.__uuid__||"";for(var r=o.uuidList,a=o.uuidObjList,s=o.uuidPropList,c=o.uuidTypeList||[],l=[],u=0;u<r.length;u++){var h=r[u];l[u]={uuid:Rf(h),owner:a[u],prop:s[u],type:at._getClassById(c[u])}}return i.__depends__=l,i._native&&(i.__nativeDepend__=!0),wd.pool.put(o),i}c._MissingScript=hp;var fp,dp=new(function(){function e(){this._depends=new ff}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?ne({},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,o=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 r=_p(t,{__uuid__:e});(o=this._parseDepsFromAsset(r)).nativeDep&&(o.nativeDep.uuid=e),gf.add(e+"@import",r)}catch(t){vf.remove(e+"@import"),o={deps:[]}}else o={deps:this._parseDepsFromJson(t)}}else{if(this._depends.has(e)&&(o=this._depends.get(e)).parsedFromExistAsset)return o;o=this._parseDepsFromAsset(t)}return this._depends.add(e,o),o},t._parseDepsFromAsset=function(e){for(var t={deps:[],parsedFromExistAsset:!0},n=e.__depends__,i=0,o=n.length;i<o;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]=Rf(e)})),t},t._descend=function(e,t,n){for(var i=this.getDeps(e),o=0;o<i.length;o++){var r=i[o];t[r]||(t[r]=!0,n.push(r),this._descend(r,t,n))}},e}()),pp=[new As];function mp(e){return e&&0==(e&e-1)}var vp,gp,yp,xp,Ep,Sp,Tp=L_("cc.SimpleTexture")(fp=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return(t=e.call.apply(e,[this].concat(i))||this)._gfxTexture=null,t._mipmapLevel=1,t._textureWidth=0,t._textureHeight=0,t}ie(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 o=pp[0];o.texExtent.width=this._textureWidth>>t,o.texExtent.height=this._textureHeight>>t,o.texSubres.mipLevel=t,o.texSubres.baseArrayLayer=n,ArrayBuffer.isView(e)?i.copyBuffersToTexture([e],this._gfxTexture,pp):i.copyTexImagesToTexture([e],this._gfxTexture,pp)}}},n._assignImage=function(e,t,n){var i=this,o=function(){var o=e.data;if(o&&(i.uploadData(o,t,n),i._checkTextureLoaded(),ft.CLEANUP_IMAGE_CACHE)){var r=dp.getDeps(i._uuid),a=r.indexOf(e._uuid);-1!==a&&(de(r,a),e.decRef())}};if(e.loaded)o();else{if(e.once("load",(function(){o()})),!this.isCompressed){var r=c.builtinResMgr.get("black-texture").image;this.uploadData(r.data,t,n)}c.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=Ga.NONE;this._mipFilter!==qf.NONE&&function(e,t,n){return!(e.gfxAPI===ba.WEBGL)||mp(t)&&mp(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=Ga.GEN_MIPMAP);var n=this._getGfxTextureCreateInfo({usage:Ha.SAMPLED|Ha.TRANSFER_DST,format:this._getGFXFormat(),levelCount:this._mipmapLevel,flags:t|Ga.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)},te(t,[{key:"mipmapLevel",get:function(){return this._mipmapLevel}}]),t}(Ed))||fp;c.SimpleTexture=Tp;var Ap,wp,Cp,Ip,Pp,bp,Rp=e("bB",(vp=L_("cc.Texture2D"),gp=hf([ed]),vp((Sp=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return ue(t=e.call.apply(e,[this].concat(i))||this,"_mipmaps",Ep,se(t)),t}ie(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=Wf.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 o=e+i;this._assignImage(this._mipmaps[o],o)}},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(){return null},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 o=0;o<i.mipmaps.length;++o)if(this._mipmaps[o]=new ed,i.mipmaps[o]){var r=i.mipmaps[o];n.result.push(this._mipmaps,""+o,r,at._getClassId(ed)),this._mipmaps[o]._texture=this}},n._getGfxTextureCreateInfo=function(e){var t=new Ds(Ua.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)},n.initDefault=function(t){e.prototype.initDefault.call(this,t);var n=new ed;n.initDefault(),this.image=n},n.validate=function(){return this.mipmaps&&0!==this.mipmaps.length},te(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}(Tp),Ep=he((xp=Sp).prototype,"_mipmaps",[gp],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),yp=xp))||yp));c.Texture2D=Rp,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"}(bp||(bp={}));var Np=e("f9",L_("cc.TextureCube")((Pp=Ip=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return ue(t=e.call.apply(e,[this].concat(i))||this,"_mipmaps",Cp,se(t)),t}ie(t,e),t.fromTexture2DArray=function(e,n){for(var i=[],o=e.length/6,r=0;r<o;r++){var a=6*r;i.push({front:e[a+bp.front].image,back:e[a+bp.back].image,left:e[a+bp.left].image,right:e[a+bp.right].image,top:e[a+bp.top].image,bottom:e[a+bp.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),o=function(t){var i=e+t;Op(n._mipmaps[i],(function(e,t){n._assignImage(e,i,t)}))},r=0;r<i;++r)o(r)},n.destroy=function(){return this._mipmaps=[],e.prototype.destroy.call(this)},n.releaseTexture=function(){this.mipmaps=[]},n._serialize=function(){return null},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 o=0;o<i.mipmaps.length;++o){this._mipmaps[o]={front:new ed,back:new ed,left:new ed,right:new ed,top:new ed,bottom:new ed};var r=i.mipmaps[o],a=at._getClassId(ed);n.result.push(this._mipmaps[o],"front",r.front,a),n.result.push(this._mipmaps[o],"back",r.back,a),n.result.push(this._mipmaps[o],"left",r.left,a),n.result.push(this._mipmaps[o],"right",r.right,a),n.result.push(this._mipmaps[o],"top",r.top,a),n.result.push(this._mipmaps[o],"bottom",r.bottom,a)}},n._getGfxTextureCreateInfo=function(e){var t=new Ds(Ua.CUBE);return t.width=this._width,t.height=this._height,t.layerCount=6,Object.assign(t,e),t},n.initDefault=function(t){e.prototype.initDefault.call(this,t);var n=new ed;n.initDefault(),this.mipmaps=[{front:n,back:n,top:n,bottom:n,left:n,right:n}]},n.validate=function(){return 0!==this._mipmaps.length&&!this._mipmaps.find((function(e){return!(e.top&&e.bottom&&e.front&&e.back&&e.left&&e.right)}))},te(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){Op(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}(Tp),Ip.FaceIndex=bp,Cp=he((wp=Pp).prototype,"_mipmaps",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Ap=wp))||Ap);function Op(e,t){t(e.front,bp.front),t(e.back,bp.back),t(e.left,bp.left),t(e.right,bp.right),t(e.top,bp.top),t(e.bottom,bp.bottom)}c.TextureCube=Np;var Dp,Mp,Lp,Fp=e("fT",[{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:456146524,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:50,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:38},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplerTextures:[]},locals:{blocks:[{name:"CCLocal",defines:[]}],samplerTextures:[]}},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}]}],samplerTextures:[{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:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:0,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:0},globals:{blocks:[],samplerTextures:[]},locals:{blocks:[],samplerTextures:[]}},defines:[],blocks:[],samplerTextures:[],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:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:46,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:0},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplerTextures:[]},locals:{blocks:[{name:"CCLocal",defines:[]}],samplerTextures:[]}},defines:[],blocks:[],samplerTextures:[],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:932177378,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:60,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:38},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplerTextures:[]},locals:{blocks:[{name:"CCLocal",defines:[]}],samplerTextures:[]}},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}]}],samplerTextures:[{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:293909391,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:49,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:38},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplerTextures:[]},locals:{blocks:[{name:"CCLocal",defines:[]}],samplerTextures:[]}},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}]}],samplerTextures:[{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:3802928649,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:49,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:38},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplerTextures:[]},locals:{blocks:[{name:"CCLocal",defines:[]}],samplerTextures:[]}},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}]}],samplerTextures:[{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:2041444135,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:46,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:1},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplerTextures:[]},locals:{blocks:[{name:"CCLocal",defines:["USE_LOCAL"]}],samplerTextures:[{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}]}],samplerTextures:[],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:1142786345,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:46,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:1},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplerTextures:[]},locals:{blocks:[{name:"CCLocal",defines:["USE_LOCAL"]}],samplerTextures:[{name:"cc_spriteTexture",defines:["USE_TEXTURE"]}]}},defines:[{name:"USE_LOCAL",type:"boolean"},{name:"SAMPLE_FROM_RT",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}]}],samplerTextures:[],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|standard-fs",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:"deferred",propertyIndex:0,blendState:{targets:[{blend:!1},{blend:!1},{blend:!1},{blend:!1}]},program:"standard|standard-vs|standard-fs",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|standard-fs",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|standard-fs",hash:632993342,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:216,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:59},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]},{name:"CCShadow",defines:[]}],samplerTextures:[{name:"cc_shadowMap",defines:["CC_RECEIVE_SHADOW"]},{name:"cc_spotLightingMap",defines:["CC_RECEIVE_SHADOW"]},{name:"cc_environment",defines:["CC_USE_IBL"]}]},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"]}],samplerTextures:[{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_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:"CC_RECEIVE_SHADOW",type:"boolean"},{name:"USE_VERTEX_COLOR",type:"boolean"},{name:"USE_NORMAL_MAP",type:"boolean"},{name:"HAS_SECOND_UV",type:"boolean"},{name:"SAMPLE_FROM_RT",type:"boolean"},{name:"CC_USE_IBL",type:"number",range:[0,2]},{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"]},{name:"CC_PIPELINE_TYPE",type:"number",range:[0,1]}],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}]}],samplerTextures:[{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:"u32vec4",count:1,defines:["CC_USE_SKINNING"],stageFlags:1,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:1518991842,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:179,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:22},globals:{blocks:[{name:"CCShadow",defines:[]}],samplerTextures:[]},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"]}],samplerTextures:[{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_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}]}],samplerTextures:[{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:"u32vec4",count:1,defines:["CC_USE_SKINNING"],stageFlags:1,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|terrain-fs",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",type:28},normalMap1:{value:"normal",type:28},normalMap2:{value:"normal",type:28},normalMap3:{value:"normal",type:28},lightMap:{value:"grey",type:28}}},{phase:"deferred",propertyIndex:0,blendState:{targets:[{blend:!1},{blend:!1},{blend:!1},{blend:!1}]},program:"terrain|terrain-vs|terrain-fs",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",type:28},normalMap1:{value:"normal",type:28},normalMap2:{value:"normal",type:28},normalMap3:{value:"normal",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|terrain-fs",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",type:28},normalMap1:{value:"normal",type:28},normalMap2:{value:"normal",type:28},normalMap3:{value:"normal",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|terrain-fs",hash:2532494361,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:64,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:55},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]},{name:"CCShadow",defines:[]}],samplerTextures:[{name:"cc_shadowMap",defines:["CC_RECEIVE_SHADOW"]},{name:"cc_spotLightingMap",defines:["CC_RECEIVE_SHADOW"]},{name:"cc_environment",defines:["CC_USE_IBL"]}]},locals:{blocks:[{name:"CCLocal",defines:[]},{name:"CCForwardLight",defines:["CC_FORWARD_ADD"]}],samplerTextures:[{name:"cc_lightingMap",defines:["USE_LIGHTMAP","!USE_BATCHING","!CC_FORWARD_ADD"]}]}},defines:[{name:"CC_USE_FOG",type:"number",range:[0,4]},{name:"CC_FORWARD_ADD",type:"boolean"},{name:"CC_RECEIVE_SHADOW",type:"boolean"},{name:"USE_NORMALMAP",type:"boolean"},{name:"USE_LIGHTMAP",type:"boolean"},{name:"CC_USE_IBL",type:"number",range:[0,2]},{name:"USE_BATCHING",type:"boolean"},{name:"CC_USE_HDR",type:"boolean"},{name:"LAYERS",type:"number",range:[0,4]},{name:"USE_PBR",type:"boolean"},{name:"CC_PIPELINE_TYPE",type:"number",range:[0,1]}],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}]}],samplerTextures:[{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:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:62,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:0},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]},{name:"CCShadow",defines:[]}],samplerTextures:[]},locals:{blocks:[{name:"CCLocal",defines:[]}],samplerTextures:[]}},defines:[],blocks:[],samplerTextures:[],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:3579616855,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:195,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:39},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplerTextures:[]},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"]}],samplerTextures:[{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_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:"SAMPLE_FROM_RT",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}]}],samplerTextures:[{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:"u32vec4",count:1,defines:["CC_USE_SKINNING"],stageFlags:1,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:"deferred-lighting",techniques:[{passes:[{phase:"deferred-lighting",program:"deferred-lighting|lighting-vs|lighting-fs",depthStencilState:{depthFunc:4,depthTest:!0,depthWrite:!1}}]}],shaders:[{name:"deferred-lighting|lighting-vs|lighting-fs",hash:4181944545,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:37,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:53},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]},{name:"CCShadow",defines:[]}],samplerTextures:[{name:"cc_shadowMap",defines:["CC_RECEIVE_SHADOW"]},{name:"cc_spotLightingMap",defines:["CC_RECEIVE_SHADOW"]},{name:"cc_environment",defines:["CC_USE_IBL"]},{name:"cc_gbuffer_albedoMap",defines:[]},{name:"cc_gbuffer_positionMap",defines:[]},{name:"cc_gbuffer_normalMap",defines:[]},{name:"cc_gbuffer_emissiveMap",defines:[]}]},locals:{blocks:[{name:"CCForwardLight",defines:[]}],samplerTextures:[]}},defines:[{name:"CC_RECEIVE_SHADOW",type:"boolean"},{name:"CC_USE_IBL",type:"number",range:[0,2]},{name:"USE_LIGHTMAP",type:"boolean"},{name:"USE_BATCHING",type:"boolean"},{name:"CC_FORWARD_ADD",type:"boolean"},{name:"CC_USE_HDR",type:"boolean"},{name:"CC_PIPELINE_TYPE",type:"number",range:[0,1]},{name:"CC_USE_FOG",type:"number",range:[0,4]}],blocks:[],samplerTextures:[],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:"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:3940098901,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:210,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:53},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]},{name:"CCShadow",defines:[]}],samplerTextures:[]},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"]}],samplerTextures:[{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_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:[],samplerTextures:[],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:"u32vec4",count:1,defines:["CC_USE_SKINNING"],stageFlags:1,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:"post-process",techniques:[{passes:[{phase:"post-process",blendState:{targets:[{blend:!0,blendSrc:2,blendDst:4,blendSrcAlpha:2,blendDstAlpha:4}]},program:"post-process|post-process-vs|post-process-fs",depthStencilState:{depthTest:!1,depthWrite:!1}}]}],shaders:[{name:"post-process|post-process-vs|post-process-fs",hash:2054814724,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:145,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:37},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplerTextures:[{name:"cc_lighting_resultMap",defines:[]}]},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"]}],samplerTextures:[{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_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"}],blocks:[],samplerTextures:[],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:"u32vec4",count:1,defines:["CC_USE_SKINNING"],stageFlags:1,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:"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:553035852,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:37,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:37},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplerTextures:[{name:"cc_environment",defines:[]}]},locals:{blocks:[],samplerTextures:[]}},defines:[{name:"CC_USE_IBL",type:"number",range:[0,2]},{name:"CC_USE_HDR",type:"boolean"},{name:"USE_RGBE_CUBEMAP",type:"boolean"}],blocks:[],samplerTextures:[],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:3108604430,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:58,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:37},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplerTextures:[]},locals:{blocks:[],samplerTextures:[]}},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}]}],samplerTextures:[{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:[{name:"default",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},properties:{mainTexture:{value:"grey",type:28},resolution:{value:[640,960],type:14,handleInfo:["u_buffer0",0,14]},precent:{value:[.5],type:13,handleInfo:["u_buffer0",2,13]},scale:{value:[200,500],type:14,handleInfo:["u_buffer1",0,14]},translate:{value:[320,480],type:14,handleInfo:["u_buffer1",2,14]},u_buffer0:{type:16,value:[640,960,.5,0]},u_buffer1:{type:16,value:[200,500,320,480]}}}]}],shaders:[{name:"splash-screen|splash-screen-vs:vert|splash-screen-fs:frag",hash:624029864,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:6,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:0},globals:{blocks:[],samplerTextures:[]},locals:{blocks:[],samplerTextures:[]}},defines:[],blocks:[{name:"Constant",defines:[],binding:0,stageFlags:1,members:[{name:"u_buffer0",type:16,count:1},{name:"u_buffer1",type:16,count:1},{name:"u_projection",type:25,count:1}]}],samplerTextures:[{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}]}]}]),zp=4026531840,Bp=264241152,Up=3145728,Hp=1032192;!function(e){e[e.BUFFER=0]="BUFFER",e[e.TEXTURE=1]="TEXTURE"}(Lp||(Lp={}));var Gp=function(e,t,n,i,o){return void 0===o&&(o=0),e<<28&zp|i<<22&Bp|t<<20&Up|n<<14&Hp|16383&o},Vp=function(e){return(e&zp)>>>28},kp=function(e){return(e&Bp)>>>22},Wp=function(e){return(e&Hp)>>>14},jp=function(e){return 16383&e},qp=function(e,t){return e&~Bp|t<<22&Bp},Yp=((Dp={})[Ma.UNKNOWN]=function(){return console.warn("illegal uniform handle")},Dp[Ma.INT]=function(e,t,n){return void 0===n&&(n=0),e[n]},Dp[Ma.INT2]=function(e,t,n){return void 0===n&&(n=0),Kn.fromArray(t,e,n)},Dp[Ma.INT3]=function(e,t,n){return void 0===n&&(n=0),Rn.fromArray(t,e,n)},Dp[Ma.INT4]=function(e,t,n){return void 0===n&&(n=0),$n.fromArray(t,e,n)},Dp[Ma.FLOAT]=function(e,t,n){return void 0===n&&(n=0),e[n]},Dp[Ma.FLOAT2]=function(e,t,n){return void 0===n&&(n=0),Kn.fromArray(t,e,n)},Dp[Ma.FLOAT3]=function(e,t,n){return void 0===n&&(n=0),Rn.fromArray(t,e,n)},Dp[Ma.FLOAT4]=function(e,t,n){return void 0===n&&(n=0),$n.fromArray(t,e,n)},Dp[Ma.MAT3]=function(e,t,n){return void 0===n&&(n=0),Mn.fromArray(t,e,n)},Dp[Ma.MAT4]=function(e,t,n){return void 0===n&&(n=0),jn.fromArray(t,e,n)},Dp),Xp=((Mp={})[Ma.UNKNOWN]=function(){return console.warn("illegal uniform handle")},Mp[Ma.INT]=function(e,t,n){return void 0===n&&(n=0),e[n]=t},Mp[Ma.INT2]=function(e,t,n){return void 0===n&&(n=0),Kn.toArray(e,t,n)},Mp[Ma.INT3]=function(e,t,n){return void 0===n&&(n=0),Rn.toArray(e,t,n)},Mp[Ma.INT4]=function(e,t,n){return void 0===n&&(n=0),$n.toArray(e,t,n)},Mp[Ma.FLOAT]=function(e,t,n){return void 0===n&&(n=0),e[n]=t},Mp[Ma.FLOAT2]=function(e,t,n){return void 0===n&&(n=0),Kn.toArray(e,t,n)},Mp[Ma.FLOAT3]=function(e,t,n){return void 0===n&&(n=0),Rn.toArray(e,t,n)},Mp[Ma.FLOAT4]=function(e,t,n){return void 0===n&&(n=0),$n.toArray(e,t,n)},Mp[Ma.MAT3]=function(e,t,n){return void 0===n&&(n=0),Mn.toArray(e,t,n)},Mp[Ma.MAT4]=function(e,t,n){return void 0===n&&(n=0),jn.toArray(e,t,n)},Mp),Kp=[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 Qp(e){switch(e){case Ma.BOOL:case Ma.INT:case Ma.UINT:case Ma.FLOAT:return Kp[0];case Ma.BOOL2:case Ma.INT2:case Ma.UINT2:case Ma.FLOAT2:return Kp[1];case Ma.BOOL4:case Ma.INT4:case Ma.UINT4:case Ma.FLOAT4:return Kp[2];case Ma.MAT4:return Kp[3];case Ma.SAMPLER2D:return"default-texture";case Ma.SAMPLER_CUBE:return"default-cube-texture"}return Kp[0]}function Zp(e,t){for(var n=Object.entries(t),i=!1,o=0;o<n.length;o++)e[n[o][0]]!==n[o][1]&&(e[n[o][0]]=n[o][1],i=!0);return i}var Jp=new nc;function $p(e){return Math.ceil(Math.log2(Math.max(e,2)))}function em(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 tm(e,t,n,i,o){for(var r=e.builtins[i],a=[],s=function(e){var t=r.blocks[e],i=n.layouts[t.name],s=i&&n.bindings.find((function(e){return e.binding===i.binding}));if(!(i&&s&&s.descriptorType&fc))return console.warn("builtin UBO '"+t.name+"' not available!"),"continue";a.push(i),o&&!o.includes(s)&&o.push(s)},c=0;c<r.blocks.length;c++)s(c);Array.prototype.unshift.apply(t.gfxBlocks,a);for(var l=[],u=function(e){var t=r.samplerTextures[e],i=n.layouts[t.name],a=i&&n.bindings.find((function(e){return e.binding===i.binding}));if(!(i&&a&&a.descriptorType&dc))return console.warn("builtin samplerTexture '"+t.name+"' not available!"),"continue";l.push(i),o&&!o.includes(a)&&o.push(a)},h=0;h<r.samplerTextures.length;h++)u(h);Array.prototype.unshift.apply(t.gfxSamplerTextures,l),o&&o.sort((function(e,t){return e.binding-t.binding}))}function nm(e){return e.members.reduce((function(e,t){return e+Ec(t.type)*t.count}),0)}function im(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 om(e){switch(e.gfxAPI){case ba.GLES2:case ba.WEBGL:return"glsl1";case ba.GLES3:case ba.WEBGL2:return"glsl3";default:return"glsl4"}}var rm=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=ne({},e),i=0,o=function(e){var t=n.defines[e],o=1;if("number"===t.type){var r=t.range;o=$p(r[1]-r[0]+1),t._map=function(e){return e-r[0]}}else"string"===t.type?(o=$p(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+=o},r=0;r<n.defines.length;r++)o(r);for(var a in i>31&&(n.uber=!0),n.constantMacros="",n.builtins.statistics)n.constantMacros+="#define "+a+" "+n.builtins.statistics[a]+"\n";if(this._templates[e.name]=n,!this._templateInfos[n.hash]){var s={};s.samplerStartBinding=n.blocks.length,s.gfxBlocks=[],s.gfxSamplerTextures=[],s.bindings=[],s.blockSizes=[];for(var c=0;c<n.blocks.length;c++){var l=n.blocks[c];s.blockSizes.push(nm(l)),s.bindings.push(new tc(l.binding,l.descriptorType||ss.UNIFORM_BUFFER,1,l.stageFlags)),s.gfxBlocks.push(new zs(th.MATERIAL,l.binding,l.name,l.members.map((function(e){return new Fs(e.name,e.type,e.count)})),1))}for(var u=0;u<n.samplerTextures.length;u++){var h=n.samplerTextures[u];s.bindings.push(new tc(h.binding,h.descriptorType||ss.SAMPLER_TEXTURE,h.count,h.stageFlags)),s.gfxSamplerTextures.push(new Bs(th.MATERIAL,h.binding,h.name,h.type,h.count))}s.gfxAttributes=[];for(var _=0;_<n.attributes.length;_++){var f=n.attributes[_];s.gfxAttributes.push(new js(f.name,f.format,f.isNormalized,0,f.isInstanced,f.location))}tm(n,s,Zu,"locals"),s.gfxStages=[],s.gfxStages.push(new Ws(Qa.VERTEX,"")),s.gfxStages.push(new Ws(Qa.FRAGMENT,"")),s.handleMap=function(e){for(var t={},n=0;n<e.blocks.length;n++)for(var i=e.blocks[n],o=i.members,r=0,a=0;a<o.length;a++){var s=o[a];t[s.name]=Gp(Lp.BUFFER,th.MATERIAL,i.binding,s.type,r),r+=(Ec(s.type)>>2)*s.count}for(var c=0;c<e.samplerTextures.length;c++){var l=e.samplerTextures[c];t[l.name]=Gp(Lp.TEXTURE,th.MATERIAL,l.binding,l.type)}return t}(n),s.hPipelineLayout=bo,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],o=this._templateInfos[i.hash];return o.setLayouts.length||(Jp.bindings=o.bindings,o.setLayouts[th.MATERIAL]=e.createDescriptorSetLayout(Jp),Jp.bindings=Zu.bindings,o.setLayouts[th.LOCAL]=e.createDescriptorSetLayout(Jp)),o.setLayouts[n?th.LOCAL:th.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 o="",r=0;r<i.length;r++){var a=i[r],s=t[a.name];if(s&&a._map){var c=a._map(s);o+=""+a._offset+c+"|"}}return""+o+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)})),o=Object.keys(this._cache).filter((function(e){return i.every((function(n){return n.test(Ro.get(t._cache[e]).name)}))})),r=0;r<o.length;r++){var a=o[r],s=Ro.get(this._cache[a]);console.log("destroyed shader "+s.name),s.destroy(),delete this._cache[a]}},t.getGFXShader=function(e,t,n,i,o){Object.assign(n,i.macros),o||(o=this.getKey(t,n));var r=this._cache[o];if(r)return r;var a=this._templates[t],s=this._templateInfos[a.hash];s.hPipelineLayout||(this.getDescriptorSetLayout(e,t),tm(a,s,Qu,"globals"),s.setLayouts[th.GLOBAL]=i.descriptorSetLayout,s.hPipelineLayout=Do.alloc(e,new oc(s.setLayouts)));var c=function(e,t){for(var n=[],i=0;i<t.length;i++){var o=t[i],r=o.name,a=e[r],s=em(o,a),c=!a||"0"===a;n.push({name:r,value:s,isDefault:c})}return n}(n,a.defines),l=i.constantMacros+a.constantMacros+c.reduce((function(e,t){return e+"#define "+t.name+" "+t.value+"\n"}),""),u=a.glsl3,h=om(e);h?u=a[h]:console.error("Invalid GFX API!"),s.gfxStages[0].source=l+u.vert,s.gfxStages[1].source=l+u.frag;var _=function(e,t,n){for(var i=[],o=e.attributes,r=t.gfxAttributes,a=0;a<o.length;a++)im(o[a].defines,n)&&i.push(r[a]);return i}(a,s,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 qs(f,s.gfxStages,_,s.gfxBlocks);return d.samplerTextures=s.gfxSamplerTextures,this._cache[o]=Ro.alloc(e,d)},e}());c.programLib=rm;var am,sm,cm,lm={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){\nmat3 m = mat3(xAxis,yAxis,zAxis);\nfloat trace = m[0][0] + m[1][1] + m[2][2];\nvec4 quat;\nif (trace > 0.) {\nfloat s = 0.5 / sqrt(trace + 1.0);\nquat.w = 0.25 / s;\nquat.x = (m[2][1] - m[1][2]) * s;\nquat.y = (m[0][2] - m[2][0]) * s;\nquat.z = (m[1][0] - m[0][1]) * s;\n} else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\nfloat s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\nquat.w = (m[2][1] - m[1][2]) / s;\nquat.x = 0.25 * s;\nquat.y = (m[0][1] + m[1][0]) / s;\nquat.z = (m[0][2] + m[2][0]) / s;\n} else if (m[1][1] > m[2][2]) {\nfloat s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\nquat.w = (m[0][2] - m[2][0]) / s;\nquat.x = (m[0][1] + m[1][0]) / s;\nquat.y = 0.25 * s;\nquat.z = (m[1][2] + m[2][1]) / s;\n} else {\nfloat s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\nquat.w = (m[1][0] - m[0][1]) / s;\nquat.x = (m[0][2] + m[2][0]) / s;\nquat.y = (m[1][2] + m[2][1]) / s;\nquat.z = 0.25 * s;\n}\nfloat len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\nif (len > 0.) {\nlen = 1. / sqrt(len);\nquat.x = quat.x * len;\nquat.y = quat.y * len;\nquat.z = quat.z * len;\nquat.w = quat.w * len;\n}\nreturn quat;\n}\nvec4 quaternionFromEuler (vec3 angle){\nfloat x = angle.x / 2.;\nfloat y = angle.y / 2.;\nfloat z = angle.z / 2.;\nfloat sx = sin(x);\nfloat cx = cos(x);\nfloat sy = sin(y);\nfloat cy = cos(y);\nfloat sz = sin(z);\nfloat cz = cos(z);\nvec4 quat = vec4(0);\nquat.x = sx * cy * cz + cx * sy * sz;\nquat.y = cx * sy * cz + sx * cy * sz;\nquat.z = cx * cy * sz - sx * sy * cz;\nquat.w = cx * cy * cz - sx * sy * sz;\nreturn quat;\n}\nvec4 quatMultiply (vec4 a, vec4 b){\nvec4 quat;\nquat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\nquat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\nquat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\nquat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\nreturn quat;\n}\nvoid rotateVecFromQuat (inout vec3 v, vec4 q){\nfloat ix = q.w * v.x + q.y * v.z - q.z * v.y;\nfloat iy = q.w * v.y + q.z * v.x - q.x * v.z;\nfloat iz = q.w * v.z + q.x * v.y - q.y * v.x;\nfloat iw = -q.x * v.x - q.y * v.y - q.z * v.z;\nv.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\nv.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\nv.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){\nvec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\nvec4 rotQuat = quatMultiply(viewQuat, q);\nrotateVecFromQuat(pos, rotQuat);\nreturn pos;\n}\nvoid rotateCorner (inout vec2 corner, float angle){\nfloat xOS = cos(angle) * corner.x - sin(angle) * corner.y;\nfloat yOS = sin(angle) * corner.x + cos(angle) * corner.y;\ncorner.x = xOS;\ncorner.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) {\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nvec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\nvec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\nvec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\npos.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() {\nvec4 pos = vec4(a_position, 1);\npos = cc_matWorld * pos;\nvec2 vertOffset = a_texCoord.xy - 0.5;\ncomputeVertPos(pos, vertOffset, quaternionFromEuler(vec3(0., 0., cc_size_rotation.z)), vec3(cc_size_rotation.xy, 0.), cc_matViewInv);\npos = cc_matViewProj * pos;\nuv = a_texCoord.xy;\ncolor = a_color;\nreturn pos;\n}\nvoid main() { gl_Position = vs_main(); }",frag:"\nprecision mediump float;\nuniform mediump vec4 cc_exposure;\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n#endif\nreturn color;\n}\nvarying vec2 uv;\nvarying vec4 color;\nuniform sampler2D mainTexture;\nuniform vec4 tintColor;\nvec4 add () {\nvec4 col = 2.0 * color * tintColor * texture2D(mainTexture, uv);\nreturn CCFragOutput(col);\n}\nvoid main() { gl_FragColor = add(); }"}],[{vert:"\nprecision highp float;\nattribute vec3 a_position;\nvec4 vert () {\nvec4 pos = vec4(a_position, 1);\nreturn pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nvec4 frag () {\nvec4 o = vec4(1.0);\nreturn 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 () {\nvec4 pos = vec4(a_position, 1);\npos = cc_matViewProj * cc_matWorld * pos;\nv_color = a_color;\nv_dist = a_dist;\nreturn 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 () {\nvec4 o = v_color;\n#ifdef GL_OES_standard_derivatives\nfloat aa = fwidth(v_dist);\n#else\nfloat aa = 0.05;\n#endif\nfloat alpha = 1. - smoothstep(-aa, 0., abs(v_dist) - 1.0);\no.rgb *= o.a;\no *= alpha;\nreturn o;\n}\nvoid main() { gl_FragColor = frag(); }"}],[{vert:"\nprecision mediump float;\nvec4 quaternionFromAxis (vec3 xAxis,vec3 yAxis,vec3 zAxis){\nmat3 m = mat3(xAxis,yAxis,zAxis);\nfloat trace = m[0][0] + m[1][1] + m[2][2];\nvec4 quat;\nif (trace > 0.) {\nfloat s = 0.5 / sqrt(trace + 1.0);\nquat.w = 0.25 / s;\nquat.x = (m[2][1] - m[1][2]) * s;\nquat.y = (m[0][2] - m[2][0]) * s;\nquat.z = (m[1][0] - m[0][1]) * s;\n} else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\nfloat s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\nquat.w = (m[2][1] - m[1][2]) / s;\nquat.x = 0.25 * s;\nquat.y = (m[0][1] + m[1][0]) / s;\nquat.z = (m[0][2] + m[2][0]) / s;\n} else if (m[1][1] > m[2][2]) {\nfloat s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\nquat.w = (m[0][2] - m[2][0]) / s;\nquat.x = (m[0][1] + m[1][0]) / s;\nquat.y = 0.25 * s;\nquat.z = (m[1][2] + m[2][1]) / s;\n} else {\nfloat s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\nquat.w = (m[1][0] - m[0][1]) / s;\nquat.x = (m[0][2] + m[2][0]) / s;\nquat.y = (m[1][2] + m[2][1]) / s;\nquat.z = 0.25 * s;\n}\nfloat len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\nif (len > 0.) {\nlen = 1. / sqrt(len);\nquat.x = quat.x * len;\nquat.y = quat.y * len;\nquat.z = quat.z * len;\nquat.w = quat.w * len;\n}\nreturn quat;\n}\nvec4 quaternionFromEuler (vec3 angle){\nfloat x = angle.x / 2.;\nfloat y = angle.y / 2.;\nfloat z = angle.z / 2.;\nfloat sx = sin(x);\nfloat cx = cos(x);\nfloat sy = sin(y);\nfloat cy = cos(y);\nfloat sz = sin(z);\nfloat cz = cos(z);\nvec4 quat = vec4(0);\nquat.x = sx * cy * cz + cx * sy * sz;\nquat.y = cx * sy * cz + sx * cy * sz;\nquat.z = cx * cy * sz - sx * sy * cz;\nquat.w = cx * cy * cz - sx * sy * sz;\nreturn quat;\n}\nmat4 matrixFromRT (vec4 q, vec3 p){\nfloat x2 = q.x + q.x;\nfloat y2 = q.y + q.y;\nfloat z2 = q.z + q.z;\nfloat xx = q.x * x2;\nfloat xy = q.x * y2;\nfloat xz = q.x * z2;\nfloat yy = q.y * y2;\nfloat yz = q.y * z2;\nfloat zz = q.z * z2;\nfloat wx = q.w * x2;\nfloat wy = q.w * y2;\nfloat wz = q.w * z2;\nreturn mat4(\n1. - (yy + zz), xy + wz, xz - wy, 0,\nxy - wz, 1. - (xx + zz), yz + wx, 0,\nxz + wy, yz - wx, 1. - (xx + yy), 0,\np.x, p.y, p.z, 1\n);\n}\nmat4 matFromRTS (vec4 q, vec3 t, vec3 s){\nfloat x = q.x, y = q.y, z = q.z, w = q.w;\nfloat x2 = x + x;\nfloat y2 = y + y;\nfloat z2 = z + z;\nfloat xx = x * x2;\nfloat xy = x * y2;\nfloat xz = x * z2;\nfloat yy = y * y2;\nfloat yz = y * z2;\nfloat zz = z * z2;\nfloat wx = w * x2;\nfloat wy = w * y2;\nfloat wz = w * z2;\nfloat sx = s.x;\nfloat sy = s.y;\nfloat sz = s.z;\nreturn 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,\nt.x, t.y, t.z, 1);\n}\nvec4 quatMultiply (vec4 a, vec4 b){\nvec4 quat;\nquat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\nquat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\nquat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\nquat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\nreturn quat;\n}\nvoid rotateVecFromQuat (inout vec3 v, vec4 q){\nfloat ix = q.w * v.x + q.y * v.z - q.z * v.y;\nfloat iy = q.w * v.y + q.z * v.x - q.x * v.z;\nfloat iz = q.w * v.z + q.x * v.y - q.y * v.x;\nfloat iw = -q.x * v.x - q.y * v.y - q.z * v.z;\nv.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\nv.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\nv.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){\nvec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\nvec4 rotQuat = quatMultiply(viewQuat, q);\nrotateVecFromQuat(pos, rotQuat);\nreturn pos;\n}\nvoid rotateCorner (inout vec2 corner, float angle){\nfloat xOS = cos(angle) * corner.x - sin(angle) * corner.y;\nfloat yOS = sin(angle) * corner.x + cos(angle) * corner.y;\ncorner.x = xOS;\ncorner.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\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nvec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\nvec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\nvec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\npos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_RENDER_MODE == 1\nvec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\nvec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\npos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_RENDER_MODE == 2\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nvec3 camX = vec3(1, 0, 0);\nvec3 camY = vec3(0, 0, -1);\npos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_RENDER_MODE == 3\nvec2 viewSpaceVert = vec2(vertOffset.x * s.x, vertOffset.y * s.y);\nrotateCorner(viewSpaceVert, q.z);\nvec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\nvec3 camY = vec3(0, 1, 0);\nvec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\npos.xyz += offset;\n#else\npos.x += vertOffset.x;\npos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV (float frameIndex, vec2 vertIndex, vec2 frameTile){\nvec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\naniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if CC_RENDER_MODE != 4\nvertIndex.y = 1. - vertIndex.y;\n#endif\nreturn (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\nattribute vec3 a_texCoord;\nattribute vec3 a_texCoord3;\nattribute vec3 a_normal;\nattribute vec4 a_color1;\n#endif\nvec3 unpackCurveData (sampler2D tex, vec2 coord) {\nvec4 a = texture2D(tex, coord);\nvec4 b = texture2D(tex, coord + u_sampleInfo.y);\nfloat c = fract(coord.x * u_sampleInfo.x);\nreturn mix(a.xyz, b.xyz, c);\n}\nvec3 unpackCurveData (sampler2D tex, vec2 coord, out float w) {\nvec4 a = texture2D(tex, coord);\nvec4 b = texture2D(tex, coord + u_sampleInfo.y);\nfloat c = fract(coord.x * u_sampleInfo.x);\nw = mix(a.w, b.w, c);\nreturn mix(a.xyz, b.xyz, c);\n}\nfloat pseudoRandom (float seed) {\nseed = mod(seed, 233280.);\nfloat q = (seed * 9301. + 49297.) / 233280.;\nreturn fract(q);\n}\n#if COLOR_OVER_TIME_MODULE_ENABLE\nuniform sampler2D color_over_time_tex0;\nuniform int u_color_mode;\n#endif\n#if ROTATION_OVER_TIME_MODULE_ENABLE\nuniform sampler2D rotation_over_time_tex0;\nuniform int u_rotation_mode;\n#endif\n#if SIZE_OVER_TIME_MODULE_ENABLE\nuniform sampler2D size_over_time_tex0;\nuniform int u_size_mode;\n#endif\n#if FORCE_OVER_TIME_MODULE_ENABLE\nuniform sampler2D force_over_time_tex0;\nuniform int u_force_mode;\nuniform int u_force_space;\n#endif\n#if VELOCITY_OVER_TIME_MODULE_ENABLE\nuniform sampler2D velocity_over_time_tex0;\nuniform int u_velocity_mode;\nuniform int u_velocity_space;\n#endif\n#if TEXTURE_ANIMATION_MODULE_ENABLE\nuniform sampler2D texture_animation_tex0;\nuniform vec4 u_anim_info;\n#endif\nfloat repeat (float t, float length) {\nreturn t - floor(t / length) * length;\n}\nvec4 rotateQuat (vec4 p, vec4 q) {\nvec3 iv = cross(q.xyz, p.xyz) + q.w * p.xyz;\nvec3 res = p.xyz + 2.0 * cross(q.xyz, iv);\nreturn vec4(res.xyz, p.w);\n}\nvec4 gpvs_main () {\nfloat activeTime = u_timeDelta.x - a_position_starttime.w;\nfloat normalizedTime = clamp(activeTime / a_dir_life.w, 0.0, 1.0);\nvec2 timeCoord0 = vec2(normalizedTime, 0.);\nvec2 timeCoord1 = vec2(normalizedTime, 1.);\n#if CC_RENDER_MODE == 4\nvec2 vertIdx = vec2(a_texCoord.x, a_texCoord.y);\n#else\nvec2 vertIdx = vec2(a_size_uv.w, a_rotation_uv.w);\n#endif\nvec4 velocity = vec4(a_dir_life.xyz, 0.);\nvec4 pos = vec4(a_position_starttime.xyz, 1.);\nvec3 size = a_size_uv.xyz;\n#if SIZE_OVER_TIME_MODULE_ENABLE\nif (u_size_mode == 1) {\nsize *= unpackCurveData(size_over_time_tex0, timeCoord0);\n} else {\nvec3 size_0 = unpackCurveData(size_over_time_tex0, timeCoord0);\nvec3 size_1 = unpackCurveData(size_over_time_tex0, timeCoord1);\nfloat factor_s = pseudoRandom(a_rndSeed + 39825.);\nsize *= mix(size_0, size_1, factor_s);\n}\n#endif\nvec3 compScale = scale.xyz * size;\n#if FORCE_OVER_TIME_MODULE_ENABLE\nvec3 forceAnim = vec3(0.);\nif (u_force_mode == 1) {\nforceAnim = unpackCurveData(force_over_time_tex0, timeCoord0);\n} else {\nvec3 force_0 = unpackCurveData(force_over_time_tex0, timeCoord0);\nvec3 force_1 = unpackCurveData(force_over_time_tex0, timeCoord1);\nfloat factor_f = pseudoRandom(a_rndSeed + 212165.);\nforceAnim = mix(force_0, force_1, factor_f);\n}\nvec4 forceTrack = vec4(forceAnim, 0.);\nif (u_force_space == 0) {\nforceTrack = rotateQuat(forceTrack, u_worldRot);\n}\nvelocity.xyz += forceTrack.xyz;\n#endif\n#if VELOCITY_OVER_TIME_MODULE_ENABLE\nfloat speedModifier0 = 1.;\nfloat speedModifier1 = 1.;\nvec3 velocityAnim = vec3(0.);\nif (u_velocity_mode == 1) {\nvelocityAnim = unpackCurveData(velocity_over_time_tex0, timeCoord0, speedModifier0);\n} else {\nvec3 vectory_0 = unpackCurveData(velocity_over_time_tex0, timeCoord0, speedModifier0);\nvec3 vectory_1 = unpackCurveData(velocity_over_time_tex0, timeCoord1, speedModifier1);\nfloat factor_v = pseudoRandom(a_rndSeed + 197866.);\nvelocityAnim = mix(vectory_0, vectory_1, factor_v);\nspeedModifier0 = mix(speedModifier0, speedModifier1, factor_v);\n}\nvec4 velocityTrack = vec4(velocityAnim, 0.);\nif (u_velocity_space == 0) {\nvelocityTrack = rotateQuat(velocityTrack, u_worldRot);\n}\nvelocity.xyz += velocityTrack.xyz;\nvelocity.xyz *= speedModifier0;\n#endif\npos.xyz += velocity.xyz * normalizedTime * a_dir_life.w;\n#if !CC_USE_WORLD_SPACE\npos = cc_matWorld * pos;\n#if CC_RENDER_MODE == 1\nvelocity = rotateQuat(velocity, u_worldRot);\n#endif\n#endif\nvec3 rotation = a_rotation_uv.xyz;\n#if ROTATION_OVER_TIME_MODULE_ENABLE\nif (u_rotation_mode == 1) {\nrotation += unpackCurveData(rotation_over_time_tex0, timeCoord0) * normalizedTime * a_dir_life.w;\n} else {\nvec3 rotation_0 = unpackCurveData(rotation_over_time_tex0, timeCoord0);\nvec3 rotation_1 = unpackCurveData(rotation_over_time_tex0, timeCoord1);\nfloat factor_r = pseudoRandom(a_rndSeed + 125292.);\nrotation += mix(rotation_0, rotation_1, factor_r) * normalizedTime * a_dir_life.w;\n}\n#endif\n#if COLOR_OVER_TIME_MODULE_ENABLE\nif (u_color_mode == 1) {\ncolor = a_color * texture2D(color_over_time_tex0, timeCoord0);\n} else {\nvec4 color_0 = texture2D(color_over_time_tex0, timeCoord0);\nvec4 color_1 = texture2D(color_over_time_tex0, timeCoord1);\nfloat factor_c = pseudoRandom(a_rndSeed + 91041.);\ncolor = a_color * mix(color_0, color_1, factor_c);\n}\n#else\ncolor = a_color;\n#endif\n#if CC_RENDER_MODE != 4\nvec2 cornerOffset = vec2((vertIdx - 0.5));\n#if CC_RENDER_MODE == 0\nvec3 rotEuler = rotation.xyz;\n#elif CC_RENDER_MODE == 1\nvec3 rotEuler = vec3(0.);\n#else\nvec3 rotEuler = vec3(0., 0., rotation.z);\n#endif\ncomputeVertPos(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\nmat4 xformNoScale = matrixFromRT(quaternionFromEuler(rotation), pos.xyz);\nmat4 xform = matFromRTS(quaternionFromEuler(rotation), pos.xyz, compScale);\npos = xform * vec4(a_texCoord3, 1);\nvec4 normal = xformNoScale * vec4(a_normal, 0);\ncolor *= a_color1;\n#endif\npos = cc_matViewProj * pos;\nfloat frameIndex = 0.;\n#if TEXTURE_ANIMATION_MODULE_ENABLE\nfloat startFrame = 0.;\nvec3 frameInfo = vec3(0.);\nif (int(u_anim_info.x) == 1) {\nframeInfo = unpackCurveData(texture_animation_tex0, timeCoord0);\n} else {\nvec3 frameInfo0 = unpackCurveData(texture_animation_tex0, timeCoord0);\nvec3 frameInfo1 = unpackCurveData(texture_animation_tex0, timeCoord1);\nfloat factor_t = pseudoRandom(a_rndSeed + 90794.);\nframeInfo = mix(frameInfo0, frameInfo1, factor_t);\n}\nstartFrame = frameInfo.x / u_anim_info.y;\nframeIndex = repeat(u_anim_info.z * (frameInfo.y + startFrame), 1.);\n#endif\nuv = computeUV(frameIndex, vertIdx, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\nreturn pos;\n}\nvoid main() { gl_Position = gpvs_main(); }",frag:"\nprecision mediump float;\nuniform mediump vec4 cc_exposure;\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n#endif\nreturn color;\n}\nvarying vec2 uv;\nvarying vec4 color;\nuniform sampler2D mainTexture;\nuniform vec4 tintColor;\nvec4 add () {\nvec4 col = 2.0 * color * tintColor * texture2D(mainTexture, uv);\nreturn 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\nvarying vec3 vBarycentric;\n#endif\nvec4 vs_main() {\nhighp vec4 pos = vec4(a_position, 1);\nvec4 velocity = vec4(a_texCoord1.xyz, 0);\n#if !CC_USE_WORLD_SPACE\npos = cc_matWorld * pos;\nvelocity = cc_matWorld * velocity;\n#endif\nfloat vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\nvec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\npos.xyz += camUp * vertOffset;\npos = cc_matViewProj * pos;\nuv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\ncolor = a_color;\n#if CC_DRAW_WIRE_FRAME\nvBarycentric = a_texCoord2;\n#endif\nreturn pos;\n}\nvoid main() { gl_Position = vs_main(); }",frag:"\nprecision mediump float;\nuniform mediump vec4 cc_exposure;\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n#endif\nreturn color;\n}\nvarying vec2 uv;\nvarying vec4 color;\n#if CC_DRAW_WIRE_FRAME\nvarying vec3 vBarycentric;\n#endif\nuniform sampler2D mainTexture;\nuniform vec4 tintColor;\nvec4 add () {\nvec4 col = 2.0 * color * tintColor * texture2D(mainTexture, uv);\n#if CC_DRAW_WIRE_FRAME\nif (any(lessThan(vBarycentric, vec3(0.02)))) {\ncol = vec4(0., 1., 1., 1.);\n}\n#endif\nreturn CCFragOutput(col);\n}\nvoid main() { gl_FragColor = add(); }"}],[{vert:"\nprecision highp float;\nvec4 quaternionFromAxis (vec3 xAxis,vec3 yAxis,vec3 zAxis){\nmat3 m = mat3(xAxis,yAxis,zAxis);\nfloat trace = m[0][0] + m[1][1] + m[2][2];\nvec4 quat;\nif (trace > 0.) {\nfloat s = 0.5 / sqrt(trace + 1.0);\nquat.w = 0.25 / s;\nquat.x = (m[2][1] - m[1][2]) * s;\nquat.y = (m[0][2] - m[2][0]) * s;\nquat.z = (m[1][0] - m[0][1]) * s;\n} else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\nfloat s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\nquat.w = (m[2][1] - m[1][2]) / s;\nquat.x = 0.25 * s;\nquat.y = (m[0][1] + m[1][0]) / s;\nquat.z = (m[0][2] + m[2][0]) / s;\n} else if (m[1][1] > m[2][2]) {\nfloat s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\nquat.w = (m[0][2] - m[2][0]) / s;\nquat.x = (m[0][1] + m[1][0]) / s;\nquat.y = 0.25 * s;\nquat.z = (m[1][2] + m[2][1]) / s;\n} else {\nfloat s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\nquat.w = (m[1][0] - m[0][1]) / s;\nquat.x = (m[0][2] + m[2][0]) / s;\nquat.y = (m[1][2] + m[2][1]) / s;\nquat.z = 0.25 * s;\n}\nfloat len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\nif (len > 0.) {\nlen = 1. / sqrt(len);\nquat.x = quat.x * len;\nquat.y = quat.y * len;\nquat.z = quat.z * len;\nquat.w = quat.w * len;\n}\nreturn quat;\n}\nvec4 quaternionFromEuler (vec3 angle){\nfloat x = angle.x / 2.;\nfloat y = angle.y / 2.;\nfloat z = angle.z / 2.;\nfloat sx = sin(x);\nfloat cx = cos(x);\nfloat sy = sin(y);\nfloat cy = cos(y);\nfloat sz = sin(z);\nfloat cz = cos(z);\nvec4 quat = vec4(0);\nquat.x = sx * cy * cz + cx * sy * sz;\nquat.y = cx * sy * cz + sx * cy * sz;\nquat.z = cx * cy * sz - sx * sy * cz;\nquat.w = cx * cy * cz - sx * sy * sz;\nreturn quat;\n}\nmat4 matrixFromRT (vec4 q, vec3 p){\nfloat x2 = q.x + q.x;\nfloat y2 = q.y + q.y;\nfloat z2 = q.z + q.z;\nfloat xx = q.x * x2;\nfloat xy = q.x * y2;\nfloat xz = q.x * z2;\nfloat yy = q.y * y2;\nfloat yz = q.y * z2;\nfloat zz = q.z * z2;\nfloat wx = q.w * x2;\nfloat wy = q.w * y2;\nfloat wz = q.w * z2;\nreturn mat4(\n1. - (yy + zz), xy + wz, xz - wy, 0,\nxy - wz, 1. - (xx + zz), yz + wx, 0,\nxz + wy, yz - wx, 1. - (xx + yy), 0,\np.x, p.y, p.z, 1\n);\n}\nmat4 matFromRTS (vec4 q, vec3 t, vec3 s){\nfloat x = q.x, y = q.y, z = q.z, w = q.w;\nfloat x2 = x + x;\nfloat y2 = y + y;\nfloat z2 = z + z;\nfloat xx = x * x2;\nfloat xy = x * y2;\nfloat xz = x * z2;\nfloat yy = y * y2;\nfloat yz = y * z2;\nfloat zz = z * z2;\nfloat wx = w * x2;\nfloat wy = w * y2;\nfloat wz = w * z2;\nfloat sx = s.x;\nfloat sy = s.y;\nfloat sz = s.z;\nreturn 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,\nt.x, t.y, t.z, 1);\n}\nvec4 quatMultiply (vec4 a, vec4 b){\nvec4 quat;\nquat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\nquat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\nquat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\nquat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\nreturn quat;\n}\nvoid rotateVecFromQuat (inout vec3 v, vec4 q){\nfloat ix = q.w * v.x + q.y * v.z - q.z * v.y;\nfloat iy = q.w * v.y + q.z * v.x - q.x * v.z;\nfloat iz = q.w * v.z + q.x * v.y - q.y * v.x;\nfloat iw = -q.x * v.x - q.y * v.y - q.z * v.z;\nv.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\nv.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\nv.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){\nvec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\nvec4 rotQuat = quatMultiply(viewQuat, q);\nrotateVecFromQuat(pos, rotQuat);\nreturn pos;\n}\nvoid rotateCorner (inout vec2 corner, float angle){\nfloat xOS = cos(angle) * corner.x - sin(angle) * corner.y;\nfloat yOS = sin(angle) * corner.x + cos(angle) * corner.y;\ncorner.x = xOS;\ncorner.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\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nvec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\nvec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\nvec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\npos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_RENDER_MODE == 1\nvec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\nvec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\npos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_RENDER_MODE == 2\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nvec3 camX = vec3(1, 0, 0);\nvec3 camY = vec3(0, 0, -1);\npos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_RENDER_MODE == 3\nvec2 viewSpaceVert = vec2(vertOffset.x * s.x, vertOffset.y * s.y);\nrotateCorner(viewSpaceVert, q.z);\nvec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\nvec3 camY = vec3(0, 1, 0);\nvec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\npos.xyz += offset;\n#else\npos.x += vertOffset.x;\npos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV (float frameIndex, vec2 vertIndex, vec2 frameTile){\nvec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\naniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if CC_RENDER_MODE != 4\nvertIndex.y = 1. - vertIndex.y;\n#endif\nreturn (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\nattribute vec3 a_color1;\n#endif\n#if CC_RENDER_MODE == 4\nattribute vec3 a_texCoord3;\nattribute vec3 a_normal;\nattribute vec4 a_color1;\n#endif\nvec4 lpvs_main () {\nvec3 compScale = scale.xyz * a_texCoord1;\nvec4 pos = vec4(a_position, 1);\n#if CC_RENDER_MODE == 1\nvec4 velocity = vec4(a_color1.xyz, 0);\n#endif\n#if !CC_USE_WORLD_SPACE\npos = cc_matWorld * pos;\n#if CC_RENDER_MODE == 1\nvelocity = cc_matWorld * velocity;\n#endif\n#endif\n#if CC_RENDER_MODE != 4\nvec2 cornerOffset = vec2((a_texCoord.xy - 0.5));\n#if CC_RENDER_MODE == 0\nvec3 rotEuler = a_texCoord2;\n#elif CC_RENDER_MODE == 1\nvec3 rotEuler = vec3(0.);\n#else\nvec3 rotEuler = vec3(0., 0., a_texCoord2.z);\n#endif\ncomputeVertPos(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);\ncolor = a_color;\n#else\nmat4 xformNoScale = matrixFromRT(quaternionFromEuler(a_texCoord2), pos.xyz);\nmat4 xform = matFromRTS(quaternionFromEuler(a_texCoord2), pos.xyz, compScale);\npos = xform * vec4(a_texCoord3, 1);\nvec4 normal = xformNoScale * vec4(a_normal, 0);\ncolor = a_color * a_color1;\n#endif\nuv = computeUV(a_texCoord.z, a_texCoord.xy, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\npos = cc_matViewProj * pos;\nreturn pos;\n}\nvoid main() { gl_Position = lpvs_main(); }",frag:"\nprecision mediump float;\nuniform mediump vec4 cc_exposure;\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n#endif\nreturn color;\n}\nvarying vec2 uv;\nvarying vec4 color;\nuniform sampler2D mainTexture;\nuniform vec4 tintColor;\nvec4 add () {\nvec4 col = 2.0 * color * tintColor * texture2D(mainTexture, uv);\nreturn 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\nattribute vec4 a_color2;\nvarying vec4 v_dark;\n#endif\nvec4 vert () {\nvec4 pos = vec4(a_position, 1);\n#if USE_LOCAL\npos = cc_matWorld * pos;\n#endif\npos = cc_matViewProj * pos;\nuv0 = a_texCoord;\nv_light = a_color;\n#if TWO_COLORED\nv_dark = a_color2;\n#endif\nreturn pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\n#if USE_ALPHA_TEST\nuniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n#if USE_ALPHA_TEST\nif (color.a < alphaThreshold) discard;\n#endif\n}\nvoid ALPHA_TEST (in float alpha) {\n#if USE_ALPHA_TEST\nif (alpha < alphaThreshold) discard;\n#endif\n}\nvarying vec4 v_light;\n#if TWO_COLORED\nvarying vec4 v_dark;\n#endif\nvarying vec2 uv0;\nuniform sampler2D cc_spriteTexture;\nvec4 frag () {\nvec4 o = vec4(1, 1, 1, 1);\n#if TWO_COLORED\nvec4 texColor = vec4(1, 1, 1, 1);\ntexColor *= texture2D(cc_spriteTexture, uv0);\no.a = texColor.a * v_light.a;\no.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;\n#else\no *= texture2D(cc_spriteTexture, uv0);\no *= v_light;\n#endif\nALPHA_TEST(o);\nreturn 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;\nuniform highp vec4 cc_cameraPos;\n#if USE_LOCAL\nuniform highp mat4 cc_matWorld;\n#endif\n#if SAMPLE_FROM_RT\n#endif\nattribute vec3 a_position;\nattribute vec2 a_texCoord;\nattribute vec4 a_color;\nvarying vec4 color;\nvarying vec2 uv0;\nvec4 vert () {\nvec4 pos = vec4(a_position, 1);\n#if USE_LOCAL\npos = cc_matWorld * pos;\n#endif\n#if USE_PIXEL_ALIGNMENT\npos = cc_matView * pos;\npos.xyz = floor(pos.xyz);\npos = cc_matProj * pos;\n#else\npos = cc_matViewProj * pos;\n#endif\nuv0 = a_texCoord;\n#if SAMPLE_FROM_RT\nuv0 = cc_cameraPos.w > 1.0 ? vec2(uv0.x, 1.0 - uv0.y) : uv0;\n#endif\ncolor = a_color;\nreturn pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nvec4 CCSampleWithAlphaSeparated(sampler2D tex, vec2 uv) {\n#if CC_USE_EMBEDDED_ALPHA\nreturn vec4(texture2D(tex, uv).rgb, texture2D(tex, uv + vec2(0.0, 0.5)).r);\n#else\nreturn texture2D(tex, uv);\n#endif\n}\n#if USE_ALPHA_TEST\nuniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n#if USE_ALPHA_TEST\nif (color.a < alphaThreshold) discard;\n#endif\n}\nvoid ALPHA_TEST (in float alpha) {\n#if USE_ALPHA_TEST\nif (alpha < alphaThreshold) discard;\n#endif\n}\nvarying vec4 color;\n#if USE_TEXTURE\nvarying vec2 uv0;\nuniform sampler2D cc_spriteTexture;\n#endif\nvec4 frag () {\nvec4 o = vec4(1, 1, 1, 1);\n#if USE_TEXTURE\no *= CCSampleWithAlphaSeparated(cc_spriteTexture, uv0);\n#if IS_GRAY\nfloat gray = 0.2126 * o.r + 0.7152 * o.g + 0.0722 * o.b;\no.r = o.g = o.b = gray;\n#endif\n#endif\no *= color;\nALPHA_TEST(o);\nreturn o;\n}\nvoid main() { gl_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nattribute vec4 a_tangent;\n#if CC_USE_MORPH\nattribute float a_vertexId;\nint getVertexId() {\nreturn int(a_vertexId);\n}\nuniform vec4 cc_displacementWeights[15];\nuniform vec4 cc_displacementTextureInfo;\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 uv = getPixelCoordFromLocation(location, cc_displacementTextureInfo.xy);\nreturn texture2D(tex, uv);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture2D(tex, x)),\ndecode32(texture2D(tex, y)),\ndecode32(texture2D(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nuniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nuniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nuniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nattribute vec4 a_joints;\nattribute vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nattribute highp vec4 a_jointAnimInfo;\n#endif\nuniform highp vec4 cc_jointTextureInfo;\nuniform highp vec4 cc_jointAnimInfo;\nuniform highp sampler2D cc_jointTexture;\n#else\nuniform highp vec4 cc_joints[90];\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn 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\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn 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\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn 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 () {\nvec4 joints = vec4(a_joints);\nreturn 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) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.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\nattribute vec4 a_matWorld0;\nattribute vec4 a_matWorld1;\nattribute vec4 a_matWorld2;\n#if USE_LIGHTMAP\nattribute vec4 a_lightingMapUVParam;\n#endif\n#elif USE_BATCHING\nattribute float a_dyn_batch_id;\nuniform 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) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nvarying float v_fog_factor;\nvarying highp vec4 v_shadowPos;\nuniform highp mat4 cc_matLightViewProj;\n#if CC_RECEIVE_SHADOW\nuniform sampler2D cc_shadowMap;\nuniform sampler2D cc_spotLightingMap;\n#endif\n#if USE_VERTEX_COLOR\nattribute vec4 a_color;\nvarying vec4 v_color;\n#endif\nvarying vec3 v_position;\nvarying vec3 v_normal;\nvarying vec2 v_uv;\nvarying vec2 v_uv1;\n#if USE_NORMAL_MAP\nvarying vec3 v_tangent;\nvarying vec3 v_bitangent;\n#endif\n#if HAS_SECOND_UV || USE_LIGHTMAP\nattribute vec2 a_texCoord1;\n#endif\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nvarying vec3 v_luv;\nvoid CCLightingMapCaclUV()\n{\n#if !USE_INSTANCING\nv_luv.xy = cc_lightingMapUVParam.xy + a_texCoord1 * cc_lightingMapUVParam.zw;\nv_luv.z = cc_lightingMapUVParam.z;\n#else\nv_luv.xy = a_lightingMapUVParam.xy + a_texCoord1 * a_lightingMapUVParam.zw;\nv_luv.z = a_lightingMapUVParam.z;\n#endif\n}\n#endif\nvoid main () {\nStandardVertInput In;\nIn.position = vec4(a_position, 1.0);\nIn.normal = a_normal;\nIn.tangent = a_tangent;\n#if CC_USE_MORPH\napplyMorph(In);\n#endif\n#if CC_USE_SKINNING\nCCSkin(In);\n#endif\nmat4 matWorld, matWorldIT;\n#if USE_INSTANCING\nmatWorld = mat4(\nvec4(a_matWorld0.xyz, 0.0),\nvec4(a_matWorld1.xyz, 0.0),\nvec4(a_matWorld2.xyz, 0.0),\nvec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n);\nmatWorldIT = matWorld;\n#elif USE_BATCHING\nmatWorld = cc_matWorlds[int(a_dyn_batch_id)];\nmatWorldIT = matWorld;\n#else\nmatWorld = cc_matWorld;\nmatWorldIT = cc_matWorldIT;\n#endif\nvec4 pos = matWorld * In.position;\nv_position = pos.xyz;\nv_normal = normalize((matWorldIT * vec4(In.normal, 0.0)).xyz);\n#if USE_NORMAL_MAP\nv_tangent = normalize((matWorld * vec4(In.tangent.xyz, 0.0)).xyz);\nv_bitangent = cross(v_normal, v_tangent) * In.tangent.w;\n#endif\nv_uv = a_texCoord * tilingOffset.xy + tilingOffset.zw;\n#if SAMPLE_FROM_RT\nv_uv = cc_cameraPos.w > 1.0 ? vec2(v_uv.x, 1.0 - v_uv.y) : v_uv;\n#endif\n#if HAS_SECOND_UV\nv_uv1 = a_texCoord1 * tilingOffset.xy + tilingOffset.zw;\n#if SAMPLE_FROM_RT\nv_uv1 = cc_cameraPos.w > 1.0 ? vec2(v_uv1.x, 1.0 - v_uv1.y) : v_uv1;\n#endif\n#endif\n#if USE_VERTEX_COLOR\nv_color = a_color;\n#endif\n#if CC_USE_FOG == 0\nv_fog_factor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nv_fog_factor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nv_fog_factor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nv_fog_factor = LayeredFog(pos);\n#else\nv_fog_factor = 1.0;\n#endif\nv_shadowPos = cc_matLightViewProj * pos;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nCCLightingMapCaclUV();\n#endif\ngl_Position = cc_matProj * (cc_matView * matWorld) * In.position;\n}",frag:"\n#ifdef GL_EXT_draw_buffers\n#extension GL_EXT_draw_buffers: enable\n#endif\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 vec4 albedo;\nuniform vec4 albedoScaleAndCutoff;\nuniform vec4 pbrParams;\nuniform vec4 emissive;\nuniform vec4 emissiveScaleParam;\nvarying float v_fog_factor;\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nuniform highp mat4 cc_matLightView;\nuniform lowp vec4 cc_shadowNFLSInfo;\nuniform lowp vec4 cc_shadowWHPBInfo;\nuniform lowp vec4 cc_shadowLPNNInfo;\nuniform lowp vec4 cc_shadowColor;\n#if CC_RECEIVE_SHADOW\nuniform sampler2D cc_shadowMap;\nuniform sampler2D cc_spotLightingMap;\nfloat CCGetLinearDepth (vec3 worldPos) {\nvec4 viewStartPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\nfloat dist = length(viewStartPos.xyz);\nreturn cc_shadowNFLSInfo.x + (-dist / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x));\n}\nfloat CCGetShadowFactorX1 (vec4 shadowPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture2D(cc_shadowMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n} else {\nclosestDepth = texture2D(cc_shadowMap, clipPos.xy).x;\n}\nshadow = step(closestDepth, clipPos.z- cc_shadowWHPBInfo.w);\nreturn shadow;\n}\nfloat CCGetShadowFactorX5 (vec4 shadowPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfloat 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n} else {\nfloat closestDepth = texture2D(cc_shadowMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = texture2D(cc_shadowMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = texture2D(cc_shadowMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = texture2D(cc_shadowMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\nreturn shadow / 5.0;\n}\nfloat CCGetShadowFactorX9 (vec4 shadowPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n} else {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat closestDepth = texture2D(cc_shadowMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n}\nreturn shadow / 9.0;\n}\nfloat CCGetShadowFactorX25 (vec4 shadowPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfor (int i = -2; i <= 2; i++) {\nfor (int j = -2; j <= 2; j++) {\nfloat 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n} else {\nfor (int i = -2; i <= 2; i++) {\nfor (int j = -2; j <= 2; j++) {\nfloat closestDepth = texture2D(cc_shadowMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n}\nreturn shadow / 25.0;\n}\nfloat CCGetDirLightShadowFactorX1 (vec4 shadowPos, vec3 worldPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nfloat depth = 0.0;\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture2D(cc_spotLightingMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n} else {\nclosestDepth = texture2D(cc_spotLightingMap, clipPos.xy).x;\n}\nshadow = step(closestDepth, depth - cc_shadowWHPBInfo.w);\nreturn shadow;\n}\nfloat CCGetDirLightShadowFactorX5 (vec4 shadowPos, vec3 worldPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfloat 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));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\n} else {\nfloat closestDepth = texture2D(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = texture2D(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = texture2D(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = texture2D(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\n}\nreturn shadow / 5.0;\n}\nfloat CCGetDirLightShadowFactorX9 (vec4 shadowPos, vec3 worldPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat 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));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\n}\n}\n} else {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat closestDepth = texture2D(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\n}\n}\n}\nreturn shadow / 9.0;\n}\nfloat CCGetDirLightShadowFactorX25 (vec4 shadowPos, vec3 worldPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat depth = 0.0;\nfloat shadow = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfor (int i = -2; i <= 2; i++) {\nfor (int j = -2; j <= 2; j++) {\nfloat 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n} else {\nfor (int i = -2; i <= 2; i++) {\nfor (int j = -2; j <= 2; j++) {\nfloat closestDepth = texture2D(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n}\nreturn shadow / 25.0;\n}\n#endif\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\nvec3 unpackRGBE (vec4 rgbe) {\nreturn 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\nreturn texture2DLodEXT(tex, coord, lod);\n#else\nreturn texture2D(tex, coord, lod);\n#endif\n}\nvec4 fragTextureLod (samplerCube tex, vec3 coord, float lod) {\n#ifdef GL_EXT_shader_texture_lod\nreturn textureCubeLodEXT(tex, coord, lod);\n#else\nreturn textureCube(tex, coord, lod);\n#endif\n}\n#endif\nfloat GGXMobile (float roughness, float NoH, vec3 H, vec3 N) {\nvec3 NxH = cross(N, H);\nfloat OneMinusNoHSqr = dot(NxH, NxH);\nfloat a = roughness * roughness;\nfloat n = NoH * a;\nfloat p = a / (OneMinusNoHSqr + n * n);\nreturn p * p;\n}\nfloat CalcSpecular (float roughness, float NoH, vec3 H, vec3 N) {\nreturn (roughness * 0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox (vec3 specular, float roughness, float NoV) {\nconst vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\nconst vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\nvec4 r = roughness * c0 + c1;\nfloat a004 = min(r.x * r.x, exp2(-9.28 * NoV)) * r.x + r.y;\nvec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;\nAB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\nreturn specular * AB.x + AB.y;\n}\nstruct StandardSurface {\nvec4 albedo;\nvec3 position;\nvec3 normal;\nvec3 emissive;\nvec3 lightmap;\nfloat lightmap_test;\nfloat roughness;\nfloat metallic;\nfloat occlusion;\n};\nvec4 CCStandardShadingBase (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.001);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 L = normalize(-cc_mainLitDir.xyz);\nvec3 H = normalize(L + V);\nfloat NH = max(dot(N, H), 0.0);\nfloat NL = max(dot(N, L), 0.001);\nvec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w;\nvec3 diffuseContrib = diffuse;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nif (s.lightmap_test > 0.0001) {\nfinalColor = s.lightmap.rgb;\n}\n#else\ndiffuseContrib /= 3.14159265359;\n#endif\nvec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\nfinalColor *= (diffuseContrib + specularContrib);\nfloat fAmb = 0.5 - N.y * 0.5;\nvec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb) * cc_ambientSky.w;\nfinalColor += (ambDiff.rgb * diffuse);\n#if CC_USE_IBL\nvec3 R = normalize(reflect(-V, N));\nvec4 envmap = fragTextureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n#if CC_USE_IBL == 2\nvec3 env = unpackRGBE(envmap);\n#else\nvec3 env = SRGBToLinear(envmap.rgb);\n#endif\nfinalColor += env * cc_ambientSky.w * specular;\n#endif\nfinalColor = finalColor * s.occlusion;\n#if CC_USE_HDR\ns.emissive *= cc_exposure.w;\n#endif\nfinalColor += s.emissive;\n#if CC_RECEIVE_SHADOW\n{\nfloat pcf = cc_shadowWHPBInfo.z + 0.001;\nfloat shadowAttenuation = 0.0;\nfloat cosAngle = clamp(1.0 - dot(N, L.xyz), 0.0, 1.0);\nvec3 projWorldPos = shadowPos.xyz + cosAngle * cc_shadowLPNNInfo.z * N;\nvec4 pos = vec4(projWorldPos.xyz, shadowPos.w);\nif (pcf > 3.0) shadowAttenuation = CCGetShadowFactorX25(pos);\nelse if (pcf > 2.0) shadowAttenuation = CCGetShadowFactorX9(pos);\nelse if (pcf > 1.0) shadowAttenuation = CCGetShadowFactorX5(pos);\nelse shadowAttenuation = CCGetShadowFactorX1(pos);\nvec3 shadowColor = cc_shadowColor.rgb * cc_shadowColor.a + finalColor.rgb * (1.0 - cc_shadowColor.a);\nif (cc_shadowNFLSInfo.w > 0.000001) {\nfinalColor.rgb = shadowColor.rgb * shadowAttenuation + finalColor.rgb * (1.0 - shadowAttenuation);\n} else {\nfinalColor.rgb = shadowColor.rgb * shadowAttenuation * NL + finalColor.rgb * (1.0 - shadowAttenuation * NL);\n}\n}\n#endif\nreturn vec4(finalColor, s.albedo.a);\n}\nvec3 ACESToneMap (vec3 color) {\ncolor = min(color, vec3(8.0));\nconst float A = 2.51;\nconst float B = 0.03;\nconst float C = 2.43;\nconst float D = 0.59;\nconst float E = 0.14;\nreturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n#if !CC_USE_HDR\ncolor.rgb = sqrt(ACESToneMap(color.rgb));\n#endif\nreturn color;\n}\nvarying highp vec4 v_shadowPos;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nvarying vec3 v_luv;\nuniform sampler2D cc_lightingMap;\nvec3 UnpackLightingmap(vec4 color) {\nvec3 c;\nfloat e = 1.0 + color.a * (8.0 - 1.0);\nc.r = color.r * e;\nc.g = color.g * e;\nc.b = color.b * e;\nreturn c;\n}\n#endif\nvarying vec3 v_position;\nvarying vec2 v_uv;\nvarying vec2 v_uv1;\nvarying vec3 v_normal;\n#if USE_VERTEX_COLOR\nvarying vec4 v_color;\n#endif\n#if USE_ALBEDO_MAP\nuniform sampler2D albedoMap;\n#endif\n#if USE_NORMAL_MAP\nvarying vec3 v_tangent;\nvarying vec3 v_bitangent;\nuniform sampler2D normalMap;\n#endif\n#if USE_PBR_MAP\nuniform sampler2D pbrMap;\n#endif\n#if USE_METALLIC_ROUGHNESS_MAP\nuniform sampler2D metallicRoughnessMap;\n#endif\n#if USE_OCCLUSION_MAP\nuniform sampler2D occlusionMap;\n#endif\n#if USE_EMISSIVE_MAP\nuniform sampler2D emissiveMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\nvoid surf (out StandardSurface s) {\nvec4 baseColor = albedo;\n#if USE_VERTEX_COLOR\nbaseColor *= v_color;\n#endif\n#if USE_ALBEDO_MAP\nvec4 texColor = texture2D(albedoMap, ALBEDO_UV);\ntexColor.rgb = SRGBToLinear(texColor.rgb);\nbaseColor *= texColor;\n#endif\ns.albedo = baseColor;\ns.albedo.rgb *= albedoScaleAndCutoff.xyz;\n#if USE_ALPHA_TEST\nif (s.albedo.ALPHA_TEST_CHANNEL < albedoScaleAndCutoff.w) discard;\n#endif\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nvec4 lightColor = texture2D(cc_lightingMap, v_luv.xy);\ns.lightmap = UnpackLightingmap(lightColor);\ns.lightmap_test = v_luv.z;\n#endif\ns.normal = v_normal;\n#if USE_NORMAL_MAP\nvec3 nmmp = texture2D(normalMap, NORMAL_UV).xyz - vec3(0.5);\ns.normal =\n(nmmp.x * pbrParams.w) * normalize(v_tangent) +\n(nmmp.y * pbrParams.w) * normalize(v_bitangent) +\nnmmp.z * normalize(s.normal);\n#endif\ns.position = v_position;\nvec4 pbr = pbrParams;\n#if USE_PBR_MAP\nvec4 res = texture2D(pbrMap, PBR_UV);\npbr.x *= res.r;\npbr.y *= res.g;\npbr.z *= res.b;\n#endif\n#if USE_METALLIC_ROUGHNESS_MAP\nvec4 metallicRoughness = texture2D(metallicRoughnessMap, PBR_UV);\npbr.z *= metallicRoughness.b;\npbr.y *= metallicRoughness.g;\n#endif\n#if USE_OCCLUSION_MAP\npbr.x *= texture2D(occlusionMap, PBR_UV).r;\n#endif\ns.occlusion = clamp(pbr.x, 0.0, 0.96);\ns.roughness = clamp(pbr.y, 0.04, 1.0);\ns.metallic = pbr.z;\ns.emissive = emissive.rgb * emissiveScaleParam.xyz;\n#if USE_EMISSIVE_MAP\ns.emissive *= SRGBToLinear(texture2D(emissiveMap, EMISSIVE_UV).rgb);\n#endif\n}\n#if CC_FORWARD_ADD\n#if CC_PIPELINE_TYPE == 0\n# define LIGHTS_PER_PASS 1\n#else\n# define LIGHTS_PER_PASS 10\n#endif\nuniform highp vec4 cc_lightPos[LIGHTS_PER_PASS];\nuniform vec4 cc_lightColor[LIGHTS_PER_PASS];\nuniform vec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS];\nuniform vec4 cc_lightDir[LIGHTS_PER_PASS];\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\nfloat factor = distSqr * invSqrAttRadius;\nfloat smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\nreturn smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\nfloat attenuation = 1.0 / max(distSqr, 0.01*0.01);\nattenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\nreturn attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\nfloat cd = dot(litDir, L);\nfloat attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\nreturn (attenuation * attenuation);\n}\nvec4 CCStandardShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 diffuseContrib = diffuse / 3.14159265359;\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.001);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nint numLights = CC_PIPELINE_TYPE == 0 ? LIGHTS_PER_PASS : int(cc_lightDir[0].w);\nfor (int i = 0; i < LIGHTS_PER_PASS; i++) {\nif (i >= numLights) break;\nvec3 SLU = cc_lightPos[i].xyz - s.position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.001);\nfloat SNH = max(dot(N, SH), 0.0);\nfloat distSqr = dot(SLU, SLU);\nfloat litRadius = cc_lightSizeRangeAngle[i].x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(cc_lightSizeRangeAngle[i].y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (cc_lightPos[i].w > 0.0) {\nfloat cosInner = max(dot(-cc_lightDir[i].xyz, SL), 0.01);\nfloat cosOuter = cc_lightSizeRangeAngle[i].z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -cc_lightDir[i].xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = cc_lightColor[i].rgb;\n#if CC_RECEIVE_SHADOW\nif (cc_lightPos[i].w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z + 0.001;\nfloat shadowAttenuation = 0.0;\nfloat cosAngle = clamp(1.0 - dot(N, normalize(cc_lightPos[i].xyz - s.position.xyz)), 0.0, 1.0);\nvec3 projWorldPos = shadowPos.xyz + cosAngle * cc_shadowLPNNInfo.z * N;\nvec4 pos = vec4(projWorldPos.xyz, shadowPos.w);\nif (pcf > 3.0) shadowAttenuation = CCGetDirLightShadowFactorX25(pos, s.position);\nelse if (pcf > 2.0) shadowAttenuation = CCGetDirLightShadowFactorX9(pos, s.position);\nelse if (pcf > 1.0) shadowAttenuation = CCGetDirLightShadowFactorX5(pos, s.position);\nelse shadowAttenuation = CCGetDirLightShadowFactorX1(pos, s.position);\nlightColor *= 1.0 - shadowAttenuation;\n}\n}\n#endif\nfinalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n}\nfinalColor = finalColor * s.occlusion;\nreturn vec4(finalColor, 0.0);\n}\nvoid main () {\nStandardSurface s; surf(s);\nvec4 color = CCStandardShadingAdditive(s, v_shadowPos);\ncolor = vec4(mix(CC_FORWARD_ADD > 0 ? vec3(0.0) : cc_fogColor.rgb, color.rgb, v_fog_factor), color.a);\ngl_FragData[0] = CCFragOutput(color);\n}\n#elif CC_PIPELINE_TYPE == 0\nvoid main () {\nStandardSurface s; surf(s);\nvec4 color = CCStandardShadingBase(s, v_shadowPos);\ncolor = vec4(mix(CC_FORWARD_ADD > 0 ? vec3(0.0) : cc_fogColor.rgb, color.rgb, v_fog_factor), color.a);\ngl_FragData[0] = CCFragOutput(color);\n}\n#elif CC_PIPELINE_TYPE == 1\nvoid main () {\nStandardSurface s; surf(s);\ngl_FragData[0] = s.albedo;\ngl_FragData[1] = vec4(s.position, s.roughness);\ngl_FragData[2] = vec4(s.normal, s.metallic);\ngl_FragData[3] = vec4(s.emissive, s.occlusion);\n}\n#endif"},{vert:"\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nattribute vec4 a_tangent;\n#if CC_USE_MORPH\nattribute float a_vertexId;\nint getVertexId() {\nreturn int(a_vertexId);\n}\nuniform vec4 cc_displacementWeights[15];\nuniform vec4 cc_displacementTextureInfo;\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 uv = getPixelCoordFromLocation(location, cc_displacementTextureInfo.xy);\nreturn texture2D(tex, uv);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture2D(tex, x)),\ndecode32(texture2D(tex, y)),\ndecode32(texture2D(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nuniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nuniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nuniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nattribute vec4 a_joints;\nattribute vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nattribute highp vec4 a_jointAnimInfo;\n#endif\nuniform highp vec4 cc_jointTextureInfo;\nuniform highp vec4 cc_jointAnimInfo;\nuniform highp sampler2D cc_jointTexture;\n#else\nuniform highp vec4 cc_joints[90];\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn 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\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn 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\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn 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 () {\nvec4 joints = vec4(a_joints);\nreturn 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) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\n#if USE_INSTANCING\nattribute vec4 a_matWorld0;\nattribute vec4 a_matWorld1;\nattribute vec4 a_matWorld2;\n#if USE_LIGHTMAP\nattribute vec4 a_lightingMapUVParam;\n#endif\n#elif USE_BATCHING\nattribute float a_dyn_batch_id;\nuniform 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\nattribute vec2 a_texCoord1;\n#endif\nvarying vec2 v_uv;\nvarying vec2 v_uv1;\nvarying vec4 v_worldPos;\nvarying float v_clip_depth;\nvec4 vert () {\nStandardVertInput In;\nIn.position = vec4(a_position, 1.0);\nIn.normal = a_normal;\nIn.tangent = a_tangent;\n#if CC_USE_MORPH\napplyMorph(In);\n#endif\n#if CC_USE_SKINNING\nCCSkin(In);\n#endif\nmat4 matWorld, matWorldIT;\n#if USE_INSTANCING\nmatWorld = mat4(\nvec4(a_matWorld0.xyz, 0.0),\nvec4(a_matWorld1.xyz, 0.0),\nvec4(a_matWorld2.xyz, 0.0),\nvec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n);\nmatWorldIT = matWorld;\n#elif USE_BATCHING\nmatWorld = cc_matWorlds[int(a_dyn_batch_id)];\nmatWorldIT = matWorld;\n#else\nmatWorld = cc_matWorld;\nmatWorldIT = cc_matWorldIT;\n#endif\nv_worldPos = matWorld * In.position;\nvec4 clipPos = cc_matLightViewProj * v_worldPos;\nv_uv = a_texCoord * tilingOffset.xy + tilingOffset.zw;\n#if HAS_SECOND_UV\nv_uv1 = a_texCoord1 * tilingOffset.xy + tilingOffset.zw;\n#endif\nv_clip_depth = clipPos.z / clipPos.w * 0.5 + 0.5;\nreturn clipPos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nuniform vec4 albedo;\nuniform vec4 albedoScaleAndCutoff;\nvec4 packDepthToRGBA (float depth) {\nvec4 ret = vec4(1.0, 255.0, 65025.0, 160581375.0) * depth;\nret = fract(ret);\nret -= ret.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\nreturn ret;\n}\nuniform highp mat4 cc_matLightView;\nuniform lowp vec4 cc_shadowNFLSInfo;\nuniform lowp vec4 cc_shadowLPNNInfo;\nvarying vec2 v_uv;\nvarying vec2 v_uv1;\nvarying vec4 v_worldPos;\nvarying float v_clip_depth;\n#if USE_ALBEDO_MAP\nuniform sampler2D albedoMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\nvec4 frag () {\nvec4 baseColor = albedo;\n#if USE_ALBEDO_MAP\nbaseColor *= texture2D(albedoMap, ALBEDO_UV);\n#endif\n#if USE_ALPHA_TEST\nif (baseColor.ALPHA_TEST_CHANNEL < albedoScaleAndCutoff.w) discard;\n#endif\nif(cc_shadowLPNNInfo.x > 0.000001 && cc_shadowLPNNInfo.x < 1.999999) {\nif (cc_shadowNFLSInfo.z > 0.000001) {\nvec4 viewStartPos = cc_matLightView * v_worldPos;\nfloat dist = length(viewStartPos.xyz);\nfloat linearDepth = cc_shadowNFLSInfo.x + (-dist / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x));\nreturn vec4(linearDepth, 1.0, 1.0, 1.0);\n}\n}\nif (cc_shadowLPNNInfo.y > 0.000001) {\nreturn packDepthToRGBA(v_clip_depth);\n}\nreturn vec4(v_clip_depth, 1.0, 1.0, 1.0);\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) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nvarying float v_fog_factor;\nvarying highp vec4 v_shadowPos;\nuniform highp mat4 cc_matLightViewProj;\n#if CC_RECEIVE_SHADOW\nuniform sampler2D cc_shadowMap;\nuniform sampler2D cc_spotLightingMap;\n#endif\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\nvarying mediump vec3 v_tangent;\nvarying 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 luv;\nvarying mediump vec3 diffuse;\nuniform vec4 UVScale;\nuniform vec4 lightMapUVParam;\nvoid main () {\nvec3 worldPos;\nworldPos.x = cc_matWorld[3][0] + a_position.x;\nworldPos.y = cc_matWorld[3][1] + a_position.y;\nworldPos.z = cc_matWorld[3][2] + a_position.z;\nvec4 pos = vec4(worldPos, 1.0);\npos = cc_matViewProj * pos;\nuvw = a_texCoord;\nuv0 = a_position.xz * UVScale.x;\nuv1 = a_position.xz * UVScale.y;\nuv2 = a_position.xz * UVScale.z;\nuv3 = a_position.xz * UVScale.w;\n#if USE_LIGHTMAP\nluv.xy = lightMapUVParam.xy + a_texCoord * lightMapUVParam.zw;\nluv.z = lightMapUVParam.z;\n#endif\nv_position = worldPos;\nv_normal = a_normal;\n#if CC_USE_FOG == 0\nv_fog_factor = LinearFog(vec4(worldPos, 1.0));\n#elif CC_USE_FOG == 1\nv_fog_factor = ExpFog(vec4(worldPos, 1.0));\n#elif CC_USE_FOG == 2\nv_fog_factor = ExpSquaredFog(vec4(worldPos, 1.0));\n#elif CC_USE_FOG == 3\nv_fog_factor = LayeredFog(vec4(worldPos, 1.0));\n#else\nv_fog_factor = 1.0;\n#endif\n#if USE_NORMALMAP\nv_tangent = vec3(1.0, 0.0, 0.0);\nv_binormal = vec3(0.0, 0.0, 1.0);\nv_binormal = cross(v_tangent, a_normal);\nv_tangent = cross(a_normal, v_binormal);\n#endif\nv_shadowPos = cc_matLightViewProj * vec4(worldPos, 1.0);\ngl_Position = pos;\n}",frag:"\n#ifdef GL_EXT_draw_buffers\n#extension GL_EXT_draw_buffers: enable\n#endif\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;\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nuniform highp mat4 cc_matLightView;\nuniform lowp vec4 cc_shadowNFLSInfo;\nuniform lowp vec4 cc_shadowWHPBInfo;\nuniform lowp vec4 cc_shadowLPNNInfo;\nuniform lowp vec4 cc_shadowColor;\n#if CC_RECEIVE_SHADOW\nuniform sampler2D cc_shadowMap;\nuniform sampler2D cc_spotLightingMap;\nfloat CCGetLinearDepth (vec3 worldPos) {\nvec4 viewStartPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\nfloat dist = length(viewStartPos.xyz);\nreturn cc_shadowNFLSInfo.x + (-dist / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x));\n}\nfloat CCGetShadowFactorX1 (vec4 shadowPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture2D(cc_shadowMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n} else {\nclosestDepth = texture2D(cc_shadowMap, clipPos.xy).x;\n}\nshadow = step(closestDepth, clipPos.z- cc_shadowWHPBInfo.w);\nreturn shadow;\n}\nfloat CCGetShadowFactorX5 (vec4 shadowPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfloat 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n} else {\nfloat closestDepth = texture2D(cc_shadowMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = texture2D(cc_shadowMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = texture2D(cc_shadowMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = texture2D(cc_shadowMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\nreturn shadow / 5.0;\n}\nfloat CCGetShadowFactorX9 (vec4 shadowPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n} else {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat closestDepth = texture2D(cc_shadowMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n}\nreturn shadow / 9.0;\n}\nfloat CCGetShadowFactorX25 (vec4 shadowPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfor (int i = -2; i <= 2; i++) {\nfor (int j = -2; j <= 2; j++) {\nfloat 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n} else {\nfor (int i = -2; i <= 2; i++) {\nfor (int j = -2; j <= 2; j++) {\nfloat closestDepth = texture2D(cc_shadowMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n}\nreturn shadow / 25.0;\n}\nfloat CCGetDirLightShadowFactorX1 (vec4 shadowPos, vec3 worldPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nfloat depth = 0.0;\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture2D(cc_spotLightingMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n} else {\nclosestDepth = texture2D(cc_spotLightingMap, clipPos.xy).x;\n}\nshadow = step(closestDepth, depth - cc_shadowWHPBInfo.w);\nreturn shadow;\n}\nfloat CCGetDirLightShadowFactorX5 (vec4 shadowPos, vec3 worldPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfloat 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));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\n} else {\nfloat closestDepth = texture2D(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = texture2D(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = texture2D(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = texture2D(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\n}\nreturn shadow / 5.0;\n}\nfloat CCGetDirLightShadowFactorX9 (vec4 shadowPos, vec3 worldPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat 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));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\n}\n}\n} else {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat closestDepth = texture2D(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\n}\n}\n}\nreturn shadow / 9.0;\n}\nfloat CCGetDirLightShadowFactorX25 (vec4 shadowPos, vec3 worldPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat depth = 0.0;\nfloat shadow = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfor (int i = -2; i <= 2; i++) {\nfor (int j = -2; j <= 2; j++) {\nfloat 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n} else {\nfor (int i = -2; i <= 2; i++) {\nfor (int j = -2; j <= 2; j++) {\nfloat closestDepth = texture2D(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n}\nreturn shadow / 25.0;\n}\n#endif\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\nvec3 unpackRGBE (vec4 rgbe) {\nreturn 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\nreturn texture2DLodEXT(tex, coord, lod);\n#else\nreturn texture2D(tex, coord, lod);\n#endif\n}\nvec4 fragTextureLod (samplerCube tex, vec3 coord, float lod) {\n#ifdef GL_EXT_shader_texture_lod\nreturn textureCubeLodEXT(tex, coord, lod);\n#else\nreturn textureCube(tex, coord, lod);\n#endif\n}\n#endif\nfloat GGXMobile (float roughness, float NoH, vec3 H, vec3 N) {\nvec3 NxH = cross(N, H);\nfloat OneMinusNoHSqr = dot(NxH, NxH);\nfloat a = roughness * roughness;\nfloat n = NoH * a;\nfloat p = a / (OneMinusNoHSqr + n * n);\nreturn p * p;\n}\nfloat CalcSpecular (float roughness, float NoH, vec3 H, vec3 N) {\nreturn (roughness * 0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox (vec3 specular, float roughness, float NoV) {\nconst vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\nconst vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\nvec4 r = roughness * c0 + c1;\nfloat a004 = min(r.x * r.x, exp2(-9.28 * NoV)) * r.x + r.y;\nvec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;\nAB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\nreturn specular * AB.x + AB.y;\n}\nstruct StandardSurface {\nvec4 albedo;\nvec3 position;\nvec3 normal;\nvec3 emissive;\nvec3 lightmap;\nfloat lightmap_test;\nfloat roughness;\nfloat metallic;\nfloat occlusion;\n};\nvec4 CCStandardShadingBase (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.001);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 L = normalize(-cc_mainLitDir.xyz);\nvec3 H = normalize(L + V);\nfloat NH = max(dot(N, H), 0.0);\nfloat NL = max(dot(N, L), 0.001);\nvec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w;\nvec3 diffuseContrib = diffuse;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nif (s.lightmap_test > 0.0001) {\nfinalColor = s.lightmap.rgb;\n}\n#else\ndiffuseContrib /= 3.14159265359;\n#endif\nvec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\nfinalColor *= (diffuseContrib + specularContrib);\nfloat fAmb = 0.5 - N.y * 0.5;\nvec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb) * cc_ambientSky.w;\nfinalColor += (ambDiff.rgb * diffuse);\n#if CC_USE_IBL\nvec3 R = normalize(reflect(-V, N));\nvec4 envmap = fragTextureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n#if CC_USE_IBL == 2\nvec3 env = unpackRGBE(envmap);\n#else\nvec3 env = SRGBToLinear(envmap.rgb);\n#endif\nfinalColor += env * cc_ambientSky.w * specular;\n#endif\nfinalColor = finalColor * s.occlusion;\n#if CC_USE_HDR\ns.emissive *= cc_exposure.w;\n#endif\nfinalColor += s.emissive;\n#if CC_RECEIVE_SHADOW\n{\nfloat pcf = cc_shadowWHPBInfo.z + 0.001;\nfloat shadowAttenuation = 0.0;\nfloat cosAngle = clamp(1.0 - dot(N, L.xyz), 0.0, 1.0);\nvec3 projWorldPos = shadowPos.xyz + cosAngle * cc_shadowLPNNInfo.z * N;\nvec4 pos = vec4(projWorldPos.xyz, shadowPos.w);\nif (pcf > 3.0) shadowAttenuation = CCGetShadowFactorX25(pos);\nelse if (pcf > 2.0) shadowAttenuation = CCGetShadowFactorX9(pos);\nelse if (pcf > 1.0) shadowAttenuation = CCGetShadowFactorX5(pos);\nelse shadowAttenuation = CCGetShadowFactorX1(pos);\nvec3 shadowColor = cc_shadowColor.rgb * cc_shadowColor.a + finalColor.rgb * (1.0 - cc_shadowColor.a);\nif (cc_shadowNFLSInfo.w > 0.000001) {\nfinalColor.rgb = shadowColor.rgb * shadowAttenuation + finalColor.rgb * (1.0 - shadowAttenuation);\n} else {\nfinalColor.rgb = shadowColor.rgb * shadowAttenuation * NL + finalColor.rgb * (1.0 - shadowAttenuation * NL);\n}\n}\n#endif\nreturn vec4(finalColor, s.albedo.a);\n}\nvec3 ACESToneMap (vec3 color) {\ncolor = min(color, vec3(8.0));\nconst float A = 2.51;\nconst float B = 0.03;\nconst float C = 2.43;\nconst float D = 0.59;\nconst float E = 0.14;\nreturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n#if !CC_USE_HDR\ncolor.rgb = sqrt(ACESToneMap(color.rgb));\n#endif\nreturn color;\n}\nvarying float v_fog_factor;\nvarying highp vec4 v_shadowPos;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nvarying vec3 v_luv;\nuniform sampler2D cc_lightingMap;\nvec3 UnpackLightingmap(vec4 color) {\nvec3 c;\nfloat e = 1.0 + color.a * (8.0 - 1.0);\nc.r = color.r * e;\nc.g = color.g * e;\nc.b = color.b * e;\nreturn c;\n}\n#endif\nvarying highp vec3 v_position;\nvarying mediump vec3 v_normal;\n#if USE_NORMALMAP\nvarying mediump vec3 v_tangent;\nvarying 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 vec3 luv;\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\nvec4 w = texture2D(weightMap, uvw);\n#endif\nvec4 baseColor = vec4(0, 0, 0, 0);\n#if LAYERS == 1\nbaseColor = texture2D(detailMap0, uv0);\n#elif LAYERS == 2\nbaseColor += texture2D(detailMap0, uv0) * w.r;\nbaseColor += texture2D(detailMap1, uv1) * w.g;\n#elif LAYERS == 3\nbaseColor += texture2D(detailMap0, uv0) * w.r;\nbaseColor += texture2D(detailMap1, uv1) * w.g;\nbaseColor += texture2D(detailMap2, uv2) * w.b;\n#elif LAYERS == 4\nbaseColor += texture2D(detailMap0, uv0) * w.r;\nbaseColor += texture2D(detailMap1, uv1) * w.g;\nbaseColor += texture2D(detailMap2, uv2) * w.b;\nbaseColor += texture2D(detailMap3, uv3) * w.a;\n#else\nbaseColor = texture2D(detailMap0, uv0);\n#endif\ns.position = v_position;\n#if USE_NORMALMAP\nvec4 baseNormal = vec4(0, 0, 0, 0);\n#if LAYERS == 1\nbaseNormal = texture2D(normalMap0, uv0);\n#elif LAYERS == 2\nbaseNormal += texture2D(normalMap0, uv0) * w.r;\nbaseNormal += texture2D(normalMap1, uv1) * w.g;\n#elif LAYERS == 3\nbaseNormal += texture2D(normalMap0, uv0) * w.r;\nbaseNormal += texture2D(normalMap1, uv1) * w.g;\nbaseNormal += texture2D(normalMap2, uv2) * w.b;\n#elif LAYERS == 4\nbaseNormal += texture2D(normalMap0, uv0) * w.r;\nbaseNormal += texture2D(normalMap1, uv1) * w.g;\nbaseNormal += texture2D(normalMap2, uv2) * w.b;\nbaseNormal += texture2D(normalMap3, uv3) * w.a;\n#else\nbaseNormal = texture2D(normalMap0, uv0);\n#endif\nvec3 nmmp = baseNormal.xyz - vec3(0.5);\ns.normal =\nnmmp.x * normalize(v_tangent) +\nnmmp.y * normalize(v_binormal) +\nnmmp.z * normalize(v_normal);\n#else\ns.normal = v_normal;\n#endif\ns.albedo = vec4(SRGBToLinear(baseColor.rgb), 1.0);\ns.occlusion = 1.0;\n#if USE_PBR\ns.roughness = 0.0;\n#if LAYERS == 1\ns.roughness = roughness.x;\n#elif LAYERS == 2\ns.roughness += roughness.x * w.r;\ns.roughness += roughness.y * w.g;\n#elif LAYERS == 3\ns.roughness += roughness.x * w.r;\ns.roughness += roughness.y * w.g;\ns.roughness += roughness.z * w.b;\n#elif LAYERS == 4\ns.roughness += roughness.x * w.r;\ns.roughness += roughness.y * w.g;\ns.roughness += roughness.z * w.b;\ns.roughness += roughness.w * w.a;\n#else\ns.roughness = 1.0;\n#endif\ns.metallic = 0.0;\n#if LAYERS == 1\ns.metallic = metallic.x;\n#elif LAYERS == 2\ns.metallic += metallic.x * w.r;\ns.metallic += metallic.y * w.g;\n#elif LAYERS == 3\ns.metallic += metallic.x * w.r;\ns.metallic += metallic.y * w.g;\ns.metallic += metallic.z * w.b;\n#elif LAYERS == 4\ns.metallic += metallic.x * w.r;\ns.metallic += metallic.y * w.g;\ns.metallic += metallic.z * w.b;\ns.metallic += metallic.w * w.a;\n#else\ns.metallic = 0.0;\n#endif\n#else\ns.roughness = 1.0;\ns.metallic = 0.0;\n#endif\ns.emissive = vec3(0.0, 0.0, 0.0);\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nvec4 lightColor = texture2D(lightMap, luv.xy);\ns.lightmap = UnpackLightingmap(lightColor);\ns.lightmap_test = luv.z;\n#endif\n}\n#if CC_FORWARD_ADD\n#if CC_PIPELINE_TYPE == 0\n# define LIGHTS_PER_PASS 1\n#else\n# define LIGHTS_PER_PASS 10\n#endif\nuniform highp vec4 cc_lightPos[LIGHTS_PER_PASS];\nuniform vec4 cc_lightColor[LIGHTS_PER_PASS];\nuniform vec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS];\nuniform vec4 cc_lightDir[LIGHTS_PER_PASS];\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\nfloat factor = distSqr * invSqrAttRadius;\nfloat smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\nreturn smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\nfloat attenuation = 1.0 / max(distSqr, 0.01*0.01);\nattenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\nreturn attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\nfloat cd = dot(litDir, L);\nfloat attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\nreturn (attenuation * attenuation);\n}\nvec4 CCStandardShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 diffuseContrib = diffuse / 3.14159265359;\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.001);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nint numLights = CC_PIPELINE_TYPE == 0 ? LIGHTS_PER_PASS : int(cc_lightDir[0].w);\nfor (int i = 0; i < LIGHTS_PER_PASS; i++) {\nif (i >= numLights) break;\nvec3 SLU = cc_lightPos[i].xyz - s.position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.001);\nfloat SNH = max(dot(N, SH), 0.0);\nfloat distSqr = dot(SLU, SLU);\nfloat litRadius = cc_lightSizeRangeAngle[i].x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(cc_lightSizeRangeAngle[i].y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (cc_lightPos[i].w > 0.0) {\nfloat cosInner = max(dot(-cc_lightDir[i].xyz, SL), 0.01);\nfloat cosOuter = cc_lightSizeRangeAngle[i].z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -cc_lightDir[i].xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = cc_lightColor[i].rgb;\n#if CC_RECEIVE_SHADOW\nif (cc_lightPos[i].w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z + 0.001;\nfloat shadowAttenuation = 0.0;\nfloat cosAngle = clamp(1.0 - dot(N, normalize(cc_lightPos[i].xyz - s.position.xyz)), 0.0, 1.0);\nvec3 projWorldPos = shadowPos.xyz + cosAngle * cc_shadowLPNNInfo.z * N;\nvec4 pos = vec4(projWorldPos.xyz, shadowPos.w);\nif (pcf > 3.0) shadowAttenuation = CCGetDirLightShadowFactorX25(pos, s.position);\nelse if (pcf > 2.0) shadowAttenuation = CCGetDirLightShadowFactorX9(pos, s.position);\nelse if (pcf > 1.0) shadowAttenuation = CCGetDirLightShadowFactorX5(pos, s.position);\nelse shadowAttenuation = CCGetDirLightShadowFactorX1(pos, s.position);\nlightColor *= 1.0 - shadowAttenuation;\n}\n}\n#endif\nfinalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n}\nfinalColor = finalColor * s.occlusion;\nreturn vec4(finalColor, 0.0);\n}\nvoid main () {\nStandardSurface s; surf(s);\nvec4 color = CCStandardShadingAdditive(s, v_shadowPos);\ncolor = vec4(mix(CC_FORWARD_ADD > 0 ? vec3(0.0) : cc_fogColor.rgb, color.rgb, v_fog_factor), color.a);\ngl_FragData[0] = CCFragOutput(color);\n}\n#elif CC_PIPELINE_TYPE == 0\nvoid main () {\nStandardSurface s; surf(s);\nvec4 color = CCStandardShadingBase(s, v_shadowPos);\ncolor = vec4(mix(CC_FORWARD_ADD > 0 ? vec3(0.0) : cc_fogColor.rgb, color.rgb, v_fog_factor), color.a);\ngl_FragData[0] = CCFragOutput(color);\n}\n#elif CC_PIPELINE_TYPE == 1\nvoid main () {\nStandardSurface s; surf(s);\ngl_FragData[0] = s.albedo;\ngl_FragData[1] = vec4(s.position, s.roughness);\ngl_FragData[2] = vec4(s.normal, s.metallic);\ngl_FragData[3] = vec4(s.emissive, s.occlusion);\n}\n#endif"},{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 () {\nvec4 worldPos;\nworldPos.x = cc_matWorld[3][0] + a_position.x;\nworldPos.y = cc_matWorld[3][1] + a_position.y;\nworldPos.z = cc_matWorld[3][2] + a_position.z;\nworldPos.w = 1.0;\nvec4 clipPos = cc_matLightViewProj * worldPos;\nv_clip_depth = clipPos.zw;\nreturn clipPos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nvec4 packDepthToRGBA (float depth) {\nvec4 ret = vec4(1.0, 255.0, 65025.0, 160581375.0) * depth;\nret = fract(ret);\nret -= ret.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\nreturn ret;\n}\nvarying vec2 v_clip_depth;\nvec4 frag () {\nreturn 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) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nattribute vec4 a_tangent;\n#if CC_USE_MORPH\nattribute float a_vertexId;\nint getVertexId() {\nreturn int(a_vertexId);\n}\nuniform vec4 cc_displacementWeights[15];\nuniform vec4 cc_displacementTextureInfo;\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 uv = getPixelCoordFromLocation(location, cc_displacementTextureInfo.xy);\nreturn texture2D(tex, uv);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture2D(tex, x)),\ndecode32(texture2D(tex, y)),\ndecode32(texture2D(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nuniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nuniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nuniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nattribute vec4 a_joints;\nattribute vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nattribute highp vec4 a_jointAnimInfo;\n#endif\nuniform highp vec4 cc_jointTextureInfo;\nuniform highp vec4 cc_jointAnimInfo;\nuniform highp sampler2D cc_jointTexture;\n#else\nuniform highp vec4 cc_joints[90];\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn 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\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn 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\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn 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 () {\nvec4 joints = vec4(a_joints);\nreturn 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) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.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\nattribute vec4 a_matWorld0;\nattribute vec4 a_matWorld1;\nattribute vec4 a_matWorld2;\n#if USE_LIGHTMAP\nattribute vec4 a_lightingMapUVParam;\n#endif\n#elif USE_BATCHING\nattribute float a_dyn_batch_id;\nuniform highp mat4 cc_matWorlds[10];\n#else\nuniform highp mat4 cc_matWorld;\n#endif\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nvarying float v_fog_factor;\n#if USE_VERTEX_COLOR\nattribute lowp vec4 a_color;\nvarying lowp vec4 v_color;\n#endif\n#if USE_TEXTURE\nvarying vec2 v_uv;\nuniform vec4 tilingOffset;\n#endif\nvec4 vert () {\nvec4 position;\nposition = vec4(a_position, 1.0);\n#if CC_USE_MORPH\napplyMorph(position);\n#endif\n#if CC_USE_SKINNING\nCCSkin(position);\n#endif\nmat4 matWorld;\n#if USE_INSTANCING\nmatWorld = mat4(\nvec4(a_matWorld0.xyz, 0.0),\nvec4(a_matWorld1.xyz, 0.0),\nvec4(a_matWorld2.xyz, 0.0),\nvec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n);\n#elif USE_BATCHING\nmatWorld = cc_matWorlds[int(a_dyn_batch_id)];\n#else\nmatWorld = cc_matWorld;\n#endif\n#if USE_TEXTURE\nv_uv = a_texCoord * tilingOffset.xy + tilingOffset.zw;\n#if SAMPLE_FROM_RT\nv_uv = cc_cameraPos.w > 1.0 ? vec2(v_uv.x, 1.0 - v_uv.y) : v_uv;\n#endif\n#endif\n#if USE_VERTEX_COLOR\nv_color = a_color;\n#endif\n#if CC_USE_FOG == 0\nv_fog_factor = LinearFog(matWorld * position);\n#elif CC_USE_FOG == 1\nv_fog_factor = ExpFog(matWorld * position);\n#elif CC_USE_FOG == 2\nv_fog_factor = ExpSquaredFog(matWorld * position);\n#elif CC_USE_FOG == 3\nv_fog_factor = LayeredFog(matWorld * position);\n#else\nv_fog_factor = 1.0;\n#endif\nreturn 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) {\nreturn gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n#endif\nreturn color;\n}\nvarying float v_fog_factor;\n#if USE_ALPHA_TEST\n#endif\n#if USE_TEXTURE\nvarying vec2 v_uv;\nuniform sampler2D mainTexture;\n#endif\nuniform vec4 mainColor;\nuniform vec4 colorScaleAndCutoff;\n#if USE_VERTEX_COLOR\nvarying lowp vec4 v_color;\n#endif\nvec4 frag () {\nvec4 o = mainColor;\no.rgb *= colorScaleAndCutoff.xyz;\n#if USE_VERTEX_COLOR\no *= v_color;\n#endif\n#if USE_TEXTURE\no *= texture2D(mainTexture, v_uv);\n#endif\n#if USE_ALPHA_TEST\nif (o.ALPHA_TEST_CHANNEL < colorScaleAndCutoff.w) discard;\n#endif\no = vec4(mix(CC_FORWARD_ADD > 0 ? vec3(0.0) : cc_fogColor.rgb, o.rgb, v_fog_factor), o.a);\nreturn CCFragOutput(o);\n}\nvoid main() { gl_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nattribute vec4 a_tangent;\nuniform highp vec4 cc_cameraPos;\nvarying vec2 v_uv;\nvoid main () {\nvec4 position;\nposition = vec4(a_position, 1.0);\nposition.xy = cc_cameraPos.w == 0.0 ? vec2(position.xy.x, -position.xy.y) : position.xy;\ngl_Position = vec4(position.x, position.y, 1.0, 1.0);\nv_uv = a_texCoord;\n}",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 mediump vec4 cc_fogBase;\nuniform mediump vec4 cc_fogAdd;\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nuniform highp mat4 cc_matLightView;\nuniform highp mat4 cc_matLightViewProj;\nuniform lowp vec4 cc_shadowNFLSInfo;\nuniform lowp vec4 cc_shadowWHPBInfo;\nuniform lowp vec4 cc_shadowLPNNInfo;\nuniform lowp vec4 cc_shadowColor;\n#if CC_RECEIVE_SHADOW\nuniform sampler2D cc_shadowMap;\nuniform sampler2D cc_spotLightingMap;\nfloat CCGetLinearDepth (vec3 worldPos) {\nvec4 viewStartPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\nfloat dist = length(viewStartPos.xyz);\nreturn cc_shadowNFLSInfo.x + (-dist / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x));\n}\nfloat CCGetShadowFactorX1 (vec4 shadowPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture2D(cc_shadowMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n} else {\nclosestDepth = texture2D(cc_shadowMap, clipPos.xy).x;\n}\nshadow = step(closestDepth, clipPos.z- cc_shadowWHPBInfo.w);\nreturn shadow;\n}\nfloat CCGetShadowFactorX5 (vec4 shadowPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfloat 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n} else {\nfloat closestDepth = texture2D(cc_shadowMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = texture2D(cc_shadowMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = texture2D(cc_shadowMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = texture2D(cc_shadowMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\nreturn shadow / 5.0;\n}\nfloat CCGetShadowFactorX9 (vec4 shadowPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n} else {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat closestDepth = texture2D(cc_shadowMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n}\nreturn shadow / 9.0;\n}\nfloat CCGetShadowFactorX25 (vec4 shadowPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfor (int i = -2; i <= 2; i++) {\nfor (int j = -2; j <= 2; j++) {\nfloat 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n} else {\nfor (int i = -2; i <= 2; i++) {\nfor (int j = -2; j <= 2; j++) {\nfloat closestDepth = texture2D(cc_shadowMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n}\nreturn shadow / 25.0;\n}\nfloat CCGetDirLightShadowFactorX1 (vec4 shadowPos, vec3 worldPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nfloat depth = 0.0;\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture2D(cc_spotLightingMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n} else {\nclosestDepth = texture2D(cc_spotLightingMap, clipPos.xy).x;\n}\nshadow = step(closestDepth, depth - cc_shadowWHPBInfo.w);\nreturn shadow;\n}\nfloat CCGetDirLightShadowFactorX5 (vec4 shadowPos, vec3 worldPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfloat 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));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\n} else {\nfloat closestDepth = texture2D(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = texture2D(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = texture2D(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = texture2D(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\n}\nreturn shadow / 5.0;\n}\nfloat CCGetDirLightShadowFactorX9 (vec4 shadowPos, vec3 worldPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat 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));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\n}\n}\n} else {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat closestDepth = texture2D(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\n}\n}\n}\nreturn shadow / 9.0;\n}\nfloat CCGetDirLightShadowFactorX25 (vec4 shadowPos, vec3 worldPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat depth = 0.0;\nfloat shadow = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfor (int i = -2; i <= 2; i++) {\nfor (int j = -2; j <= 2; j++) {\nfloat 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n} else {\nfor (int i = -2; i <= 2; i++) {\nfor (int j = -2; j <= 2; j++) {\nfloat closestDepth = texture2D(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n}\nreturn shadow / 25.0;\n}\n#endif\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\nvec3 unpackRGBE (vec4 rgbe) {\nreturn 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\nreturn texture2DLodEXT(tex, coord, lod);\n#else\nreturn texture2D(tex, coord, lod);\n#endif\n}\nvec4 fragTextureLod (samplerCube tex, vec3 coord, float lod) {\n#ifdef GL_EXT_shader_texture_lod\nreturn textureCubeLodEXT(tex, coord, lod);\n#else\nreturn textureCube(tex, coord, lod);\n#endif\n}\n#endif\nfloat GGXMobile (float roughness, float NoH, vec3 H, vec3 N) {\nvec3 NxH = cross(N, H);\nfloat OneMinusNoHSqr = dot(NxH, NxH);\nfloat a = roughness * roughness;\nfloat n = NoH * a;\nfloat p = a / (OneMinusNoHSqr + n * n);\nreturn p * p;\n}\nfloat CalcSpecular (float roughness, float NoH, vec3 H, vec3 N) {\nreturn (roughness * 0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox (vec3 specular, float roughness, float NoV) {\nconst vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\nconst vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\nvec4 r = roughness * c0 + c1;\nfloat a004 = min(r.x * r.x, exp2(-9.28 * NoV)) * r.x + r.y;\nvec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;\nAB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\nreturn specular * AB.x + AB.y;\n}\nstruct StandardSurface {\nvec4 albedo;\nvec3 position;\nvec3 normal;\nvec3 emissive;\nvec3 lightmap;\nfloat lightmap_test;\nfloat roughness;\nfloat metallic;\nfloat occlusion;\n};\nvec4 CCStandardShadingBase (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.001);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 L = normalize(-cc_mainLitDir.xyz);\nvec3 H = normalize(L + V);\nfloat NH = max(dot(N, H), 0.0);\nfloat NL = max(dot(N, L), 0.001);\nvec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w;\nvec3 diffuseContrib = diffuse;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nif (s.lightmap_test > 0.0001) {\nfinalColor = s.lightmap.rgb;\n}\n#else\ndiffuseContrib /= 3.14159265359;\n#endif\nvec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\nfinalColor *= (diffuseContrib + specularContrib);\nfloat fAmb = 0.5 - N.y * 0.5;\nvec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb) * cc_ambientSky.w;\nfinalColor += (ambDiff.rgb * diffuse);\n#if CC_USE_IBL\nvec3 R = normalize(reflect(-V, N));\nvec4 envmap = fragTextureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n#if CC_USE_IBL == 2\nvec3 env = unpackRGBE(envmap);\n#else\nvec3 env = SRGBToLinear(envmap.rgb);\n#endif\nfinalColor += env * cc_ambientSky.w * specular;\n#endif\nfinalColor = finalColor * s.occlusion;\n#if CC_USE_HDR\ns.emissive *= cc_exposure.w;\n#endif\nfinalColor += s.emissive;\n#if CC_RECEIVE_SHADOW\n{\nfloat pcf = cc_shadowWHPBInfo.z + 0.001;\nfloat shadowAttenuation = 0.0;\nfloat cosAngle = clamp(1.0 - dot(N, L.xyz), 0.0, 1.0);\nvec3 projWorldPos = shadowPos.xyz + cosAngle * cc_shadowLPNNInfo.z * N;\nvec4 pos = vec4(projWorldPos.xyz, shadowPos.w);\nif (pcf > 3.0) shadowAttenuation = CCGetShadowFactorX25(pos);\nelse if (pcf > 2.0) shadowAttenuation = CCGetShadowFactorX9(pos);\nelse if (pcf > 1.0) shadowAttenuation = CCGetShadowFactorX5(pos);\nelse shadowAttenuation = CCGetShadowFactorX1(pos);\nvec3 shadowColor = cc_shadowColor.rgb * cc_shadowColor.a + finalColor.rgb * (1.0 - cc_shadowColor.a);\nif (cc_shadowNFLSInfo.w > 0.000001) {\nfinalColor.rgb = shadowColor.rgb * shadowAttenuation + finalColor.rgb * (1.0 - shadowAttenuation);\n} else {\nfinalColor.rgb = shadowColor.rgb * shadowAttenuation * NL + finalColor.rgb * (1.0 - shadowAttenuation * NL);\n}\n}\n#endif\nreturn vec4(finalColor, s.albedo.a);\n}\n#if CC_PIPELINE_TYPE == 0\n# define LIGHTS_PER_PASS 1\n#else\n# define LIGHTS_PER_PASS 10\n#endif\nuniform highp vec4 cc_lightPos[LIGHTS_PER_PASS];\nuniform vec4 cc_lightColor[LIGHTS_PER_PASS];\nuniform vec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS];\nuniform vec4 cc_lightDir[LIGHTS_PER_PASS];\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\nfloat factor = distSqr * invSqrAttRadius;\nfloat smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\nreturn smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\nfloat attenuation = 1.0 / max(distSqr, 0.01*0.01);\nattenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\nreturn attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\nfloat cd = dot(litDir, L);\nfloat attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\nreturn (attenuation * attenuation);\n}\nvec4 CCStandardShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 diffuseContrib = diffuse / 3.14159265359;\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.001);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nint numLights = CC_PIPELINE_TYPE == 0 ? LIGHTS_PER_PASS : int(cc_lightDir[0].w);\nfor (int i = 0; i < LIGHTS_PER_PASS; i++) {\nif (i >= numLights) break;\nvec3 SLU = cc_lightPos[i].xyz - s.position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.001);\nfloat SNH = max(dot(N, SH), 0.0);\nfloat distSqr = dot(SLU, SLU);\nfloat litRadius = cc_lightSizeRangeAngle[i].x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(cc_lightSizeRangeAngle[i].y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (cc_lightPos[i].w > 0.0) {\nfloat cosInner = max(dot(-cc_lightDir[i].xyz, SL), 0.01);\nfloat cosOuter = cc_lightSizeRangeAngle[i].z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -cc_lightDir[i].xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = cc_lightColor[i].rgb;\n#if CC_RECEIVE_SHADOW\nif (cc_lightPos[i].w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z + 0.001;\nfloat shadowAttenuation = 0.0;\nfloat cosAngle = clamp(1.0 - dot(N, normalize(cc_lightPos[i].xyz - s.position.xyz)), 0.0, 1.0);\nvec3 projWorldPos = shadowPos.xyz + cosAngle * cc_shadowLPNNInfo.z * N;\nvec4 pos = vec4(projWorldPos.xyz, shadowPos.w);\nif (pcf > 3.0) shadowAttenuation = CCGetDirLightShadowFactorX25(pos, s.position);\nelse if (pcf > 2.0) shadowAttenuation = CCGetDirLightShadowFactorX9(pos, s.position);\nelse if (pcf > 1.0) shadowAttenuation = CCGetDirLightShadowFactorX5(pos, s.position);\nelse shadowAttenuation = CCGetDirLightShadowFactorX1(pos, s.position);\nlightColor *= 1.0 - shadowAttenuation;\n}\n}\n#endif\nfinalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n}\nfinalColor = finalColor * s.occlusion;\nreturn vec4(finalColor, 0.0);\n}\nvec3 ACESToneMap (vec3 color) {\ncolor = min(color, vec3(8.0));\nconst float A = 2.51;\nconst float B = 0.03;\nconst float C = 2.43;\nconst float D = 0.59;\nconst float E = 0.14;\nreturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n#if !CC_USE_HDR\ncolor.rgb = sqrt(ACESToneMap(color.rgb));\n#endif\nreturn color;\n}\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nvarying vec2 v_uv;\nuniform sampler2D cc_gbuffer_albedoMap;\nuniform sampler2D cc_gbuffer_positionMap;\nuniform sampler2D cc_gbuffer_normalMap;\nuniform sampler2D cc_gbuffer_emissiveMap;\nvoid main () {\nStandardSurface s;\nvec4 albedoMap = texture2D(cc_gbuffer_albedoMap,v_uv);\nvec4 positionMap = texture2D(cc_gbuffer_positionMap,v_uv);\nvec4 normalMap = texture2D(cc_gbuffer_normalMap,v_uv);\nvec4 emissiveMap = texture2D(cc_gbuffer_emissiveMap,v_uv);\ns.albedo = albedoMap;\ns.position = positionMap.xyz;\ns.roughness = positionMap.w;\ns.normal = normalMap.xyz;\ns.metallic = normalMap.w;\ns.emissive = emissiveMap.xyz;\ns.occlusion = emissiveMap.w;\nfloat fogFactor;\n#if CC_USE_FOG == 0\nfogFactor = LinearFog(vec4(s.position, 1));\n#elif CC_USE_FOG == 1\nfogFactor = ExpFog(vec4(s.position, 1));\n#elif CC_USE_FOG == 2\nfogFactor = ExpSquaredFog(vec4(s.position, 1));\n#elif CC_USE_FOG == 3\nfogFactor = LayeredFog(vec4(s.position, 1));\n#else\nfogFactor = 1.0;\n#endif\nvec4 shadowPos;\nshadowPos = cc_matLightViewProj * vec4(s.position, 1);\nvec4 color = CCStandardShadingBase(s, shadowPos) +\nCCStandardShadingAdditive(s, shadowPos);\ncolor = vec4(mix(CC_FORWARD_ADD > 0 ? vec3(0.0) : cc_fogColor.rgb, color.rgb, fogFactor), color.a);\ngl_FragColor = CCFragOutput(color);\n}"}],[{vert:"\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nattribute vec4 a_tangent;\n#if CC_USE_MORPH\nattribute float a_vertexId;\nint getVertexId() {\nreturn int(a_vertexId);\n}\nuniform vec4 cc_displacementWeights[15];\nuniform vec4 cc_displacementTextureInfo;\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 uv = getPixelCoordFromLocation(location, cc_displacementTextureInfo.xy);\nreturn texture2D(tex, uv);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture2D(tex, x)),\ndecode32(texture2D(tex, y)),\ndecode32(texture2D(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nuniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nuniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nuniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nattribute vec4 a_joints;\nattribute vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nattribute highp vec4 a_jointAnimInfo;\n#endif\nuniform highp vec4 cc_jointTextureInfo;\nuniform highp vec4 cc_jointAnimInfo;\nuniform highp sampler2D cc_jointTexture;\n#else\nuniform highp vec4 cc_joints[90];\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn 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\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn 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\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn 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 () {\nvec4 joints = vec4(a_joints);\nreturn 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) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.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\nattribute vec4 a_matWorld0;\nattribute vec4 a_matWorld1;\nattribute vec4 a_matWorld2;\n#if USE_LIGHTMAP\nattribute vec4 a_lightingMapUVParam;\n#endif\n#elif USE_BATCHING\nattribute float a_dyn_batch_id;\nuniform highp mat4 cc_matWorlds[10];\n#else\nuniform highp mat4 cc_matWorld;\n#endif\nuniform highp mat4 cc_matLightPlaneProj;\nvec4 vert () {\nvec4 position;\nposition = vec4(a_position, 1.0);\n#if CC_USE_MORPH\napplyMorph(position);\n#endif\n#if CC_USE_SKINNING\nCCSkin(position);\n#endif\nmat4 matWorld;\n#if USE_INSTANCING\nmatWorld = mat4(\nvec4(a_matWorld0.xyz, 0.0),\nvec4(a_matWorld1.xyz, 0.0),\nvec4(a_matWorld2.xyz, 0.0),\nvec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n);\n#elif USE_BATCHING\nmatWorld = cc_matWorlds[int(a_dyn_batch_id)];\n#else\nmatWorld = cc_matWorld;\n#endif\nposition = cc_matProj * (cc_matView * cc_matLightPlaneProj * matWorld) * position;\nposition.z -= 0.0001;\nreturn 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) {\nreturn gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n#endif\nreturn color;\n}\nvec4 frag () {\nreturn CCFragOutput(cc_shadowColor);\n}\nvoid main() { gl_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nattribute vec4 a_tangent;\n#if CC_USE_MORPH\nattribute float a_vertexId;\nint getVertexId() {\nreturn int(a_vertexId);\n}\nuniform vec4 cc_displacementWeights[15];\nuniform vec4 cc_displacementTextureInfo;\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 uv = getPixelCoordFromLocation(location, cc_displacementTextureInfo.xy);\nreturn texture2D(tex, uv);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture2D(tex, x)),\ndecode32(texture2D(tex, y)),\ndecode32(texture2D(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nuniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nuniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nuniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nattribute vec4 a_joints;\nattribute vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nattribute highp vec4 a_jointAnimInfo;\n#endif\nuniform highp vec4 cc_jointTextureInfo;\nuniform highp vec4 cc_jointAnimInfo;\nuniform highp sampler2D cc_jointTexture;\n#else\nuniform highp vec4 cc_joints[90];\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn 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\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture2D(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture2D(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn 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\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn 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 () {\nvec4 joints = vec4(a_joints);\nreturn 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) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nuniform highp vec4 cc_cameraPos;\nvarying vec2 v_uv;\nvoid main () {\nStandardVertInput In;\nIn.position = vec4(a_position, 1.0);\nIn.normal = a_normal;\nIn.tangent = a_tangent;\n#if CC_USE_MORPH\napplyMorph(In);\n#endif\n#if CC_USE_SKINNING\nCCSkin(In);\n#endif\nIn.position.xy = cc_cameraPos.w == 0.0 ? vec2(In.position.xy.x, -In.position.xy.y) : In.position.xy;\ngl_Position = In.position;\ngl_Position.y = gl_Position.y;\nv_uv = a_texCoord;\n}",frag:"\nprecision highp float;\nuniform mediump vec4 cc_screenSize;\nvarying vec2 v_uv;\nuniform sampler2D cc_lighting_resultMap;\nvoid texcoords(vec2 fragCoord, vec2 resolution,\nout vec2 v_rgbNW, out vec2 v_rgbNE,\nout vec2 v_rgbSW, out vec2 v_rgbSE,\nout vec2 v_rgbM) {\nvec2 inverseVP = 1.0 / resolution.xy;\nv_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;\nv_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;\nv_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;\nv_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;\nv_rgbM = vec2(fragCoord * inverseVP);\n}\nvec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 resolution,\nvec2 v_rgbNW, vec2 v_rgbNE,\nvec2 v_rgbSW, vec2 v_rgbSE,\nvec2 v_rgbM) {\nvec4 color;\nmediump vec2 inverseVP = vec2(1.0 / resolution.x, 1.0 / resolution.y);\nvec3 rgbNW = texture2D(tex, v_rgbNW).xyz;\nvec3 rgbNE = texture2D(tex, v_rgbNE).xyz;\nvec3 rgbSW = texture2D(tex, v_rgbSW).xyz;\nvec3 rgbSE = texture2D(tex, v_rgbSE).xyz;\nvec4 texColor = texture2D(tex, v_rgbM);\nvec3 rgbM = texColor.xyz;\nvec3 luma = vec3(0.299, 0.587, 0.114);\nfloat lumaNW = dot(rgbNW, luma);\nfloat lumaNE = dot(rgbNE, luma);\nfloat lumaSW = dot(rgbSW, luma);\nfloat lumaSE = dot(rgbSE, luma);\nfloat lumaM = dot(rgbM, luma);\nfloat lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\nfloat lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\nmediump vec2 dir;\ndir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\ndir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\nfloat dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *\n(0.25 * (1.0 / 8.0)), (1.0/ 128.0));\nfloat rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\ndir = min(vec2(8.0, 8.0),\nmax(vec2(-8.0, -8.0),\ndir * rcpDirMin)) * inverseVP;\nvec3 rgbA = 0.5 * (\ntexture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +\ntexture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);\nvec3 rgbB = rgbA * 0.5 + 0.25 * (\ntexture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz +\ntexture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz);\nfloat lumaB = dot(rgbB, luma);\nif ((lumaB < lumaMin) || (lumaB > lumaMax))\ncolor = vec4(rgbA, texColor.a);\nelse\ncolor = vec4(rgbB, texColor.a);\nreturn color;\n}\nvoid main () {\nmediump vec2 v_rgbNW;\nmediump vec2 v_rgbNE;\nmediump vec2 v_rgbSW;\nmediump vec2 v_rgbSE;\nmediump vec2 v_rgbM;\nvec2 resolution = cc_screenSize.xy;\nvec2 fragCoord = v_uv * resolution;\ntexcoords(fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\ngl_FragColor = fxaa(cc_lighting_resultMap, fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n}"}],[{vert:"\nprecision highp float;\nuniform highp mat4 cc_matView;\nuniform highp mat4 cc_matProj;\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nattribute vec4 a_tangent;\nvarying mediump vec4 viewDir;\nvec4 vert () {\nviewDir = vec4(a_position, 1.0);\nmat4 matViewRotOnly = mat4(mat3(cc_matView));\nmat4 matProj = cc_matProj;\nif (matProj[3].w > 0.0) {\nvec2 scale = vec2(48.0, 24.0);\nmatProj[0].xy *= scale;\nmatProj[1].xy *= scale;\nmatProj[2].zw = vec2(-1.0);\nmatProj[3].zw = vec2(0.0);\n}\nvec4 pos = matProj * matViewRotOnly * viewDir;\npos.z = 0.99999 * pos.w;\nreturn pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision mediump float;\nuniform mediump vec4 cc_ambientSky;\nuniform samplerCube cc_environment;\nvec3 unpackRGBE (vec4 rgbe) {\nreturn rgbe.rgb * pow(2.0, rgbe.a * 255.0 - 128.0);\n}\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nvec3 ACESToneMap (vec3 color) {\ncolor = min(color, vec3(8.0));\nconst float A = 2.51;\nconst float B = 0.03;\nconst float C = 2.43;\nconst float D = 0.59;\nconst float E = 0.14;\nreturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n#if !CC_USE_HDR\ncolor.rgb = sqrt(ACESToneMap(color.rgb));\n#endif\nreturn color;\n}\nvarying mediump vec4 viewDir;\nvec4 frag () {\n#if USE_RGBE_CUBEMAP\nvec3 c = unpackRGBE(textureCube(cc_environment, viewDir.xyz));\n#else\nvec3 c = SRGBToLinear(textureCube(cc_environment, viewDir.xyz).rgb);\n#endif\nreturn 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) {\nif (i < 1.0) { return v.x; }\nelse if (i < 2.0) { return v.y; }\nelse if (i < 3.0) { return v.z; }\nelse { return v.w; }\n}\nvec4 vert () {\nvec4 position = cc_matViewProj * vec4(a_position, 1.0);\nposition.xy += offset.xy;\nv_uv = a_color.xy;\nif (a_color.z >= 0.0) {\nfloat n = getComponent(digits[int(a_color.z)], a_color.w);\nv_uv += vec2(offset.z * n, 0.0);\n}\nreturn position;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision mediump float;\nuniform mediump vec4 cc_exposure;\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n#endif\nreturn color;\n}\nvarying vec2 v_uv;\nuniform sampler2D mainTexture;\nvec4 frag () {\nreturn 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;\nvarying float v_percent;\nuniform vec4 u_buffer0;\nuniform vec4 u_buffer1;\nuniform mat4 u_projection;\nvec4 vert () {\nvec2 worldPos = a_position * u_buffer1.xy + u_buffer1.zw;\nvec2 clipSpace = worldPos / u_buffer0.xy * 2.0 - 1.0;\nvec4 screenPos = u_projection * vec4(clipSpace, 0.0, 1.0);\nv_uv = a_texCoord;\nv_percent = u_buffer0.z;\nreturn screenPos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision mediump float;\nvarying vec2 v_uv;\nvarying float v_percent;\nuniform sampler2D mainTexture;\nvec4 frag () {\nvec4 color = texture2D(mainTexture, v_uv);\nfloat precent = clamp(v_percent, 0.0, 1.0);\ncolor.xyz *= precent;\nreturn color;\n}\nvoid main() { gl_FragColor = frag(); }"}]],glsl3:[[{vert:"\nprecision mediump float;\nlayout(std140) uniform Constants {\nvec4 mainTiling_Offset;\nvec4 frameTile_velLenScale;\nvec4 scale;\n};\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nlayout(std140) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\nvec4 quaternionFromAxis (vec3 xAxis,vec3 yAxis,vec3 zAxis){\nmat3 m = mat3(xAxis,yAxis,zAxis);\nfloat trace = m[0][0] + m[1][1] + m[2][2];\nvec4 quat;\nif (trace > 0.) {\nfloat s = 0.5 / sqrt(trace + 1.0);\nquat.w = 0.25 / s;\nquat.x = (m[2][1] - m[1][2]) * s;\nquat.y = (m[0][2] - m[2][0]) * s;\nquat.z = (m[1][0] - m[0][1]) * s;\n} else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\nfloat s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\nquat.w = (m[2][1] - m[1][2]) / s;\nquat.x = 0.25 * s;\nquat.y = (m[0][1] + m[1][0]) / s;\nquat.z = (m[0][2] + m[2][0]) / s;\n} else if (m[1][1] > m[2][2]) {\nfloat s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\nquat.w = (m[0][2] - m[2][0]) / s;\nquat.x = (m[0][1] + m[1][0]) / s;\nquat.y = 0.25 * s;\nquat.z = (m[1][2] + m[2][1]) / s;\n} else {\nfloat s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\nquat.w = (m[1][0] - m[0][1]) / s;\nquat.x = (m[0][2] + m[2][0]) / s;\nquat.y = (m[1][2] + m[2][1]) / s;\nquat.z = 0.25 * s;\n}\nfloat len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\nif (len > 0.) {\nlen = 1. / sqrt(len);\nquat.x = quat.x * len;\nquat.y = quat.y * len;\nquat.z = quat.z * len;\nquat.w = quat.w * len;\n}\nreturn quat;\n}\nvec4 quaternionFromEuler (vec3 angle){\nfloat x = angle.x / 2.;\nfloat y = angle.y / 2.;\nfloat z = angle.z / 2.;\nfloat sx = sin(x);\nfloat cx = cos(x);\nfloat sy = sin(y);\nfloat cy = cos(y);\nfloat sz = sin(z);\nfloat cz = cos(z);\nvec4 quat = vec4(0);\nquat.x = sx * cy * cz + cx * sy * sz;\nquat.y = cx * sy * cz + sx * cy * sz;\nquat.z = cx * cy * sz - sx * sy * cz;\nquat.w = cx * cy * cz - sx * sy * sz;\nreturn quat;\n}\nvec4 quatMultiply (vec4 a, vec4 b){\nvec4 quat;\nquat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\nquat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\nquat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\nquat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\nreturn quat;\n}\nvoid rotateVecFromQuat (inout vec3 v, vec4 q){\nfloat ix = q.w * v.x + q.y * v.z - q.z * v.y;\nfloat iy = q.w * v.y + q.z * v.x - q.x * v.z;\nfloat iz = q.w * v.z + q.x * v.y - q.y * v.x;\nfloat iw = -q.x * v.x - q.y * v.y - q.z * v.z;\nv.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\nv.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\nv.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){\nvec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\nvec4 rotQuat = quatMultiply(viewQuat, q);\nrotateVecFromQuat(pos, rotQuat);\nreturn pos;\n}\nvoid rotateCorner (inout vec2 corner, float angle){\nfloat xOS = cos(angle) * corner.x - sin(angle) * corner.y;\nfloat yOS = sin(angle) * corner.x + cos(angle) * corner.y;\ncorner.x = xOS;\ncorner.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) {\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nvec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\nvec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\nvec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\npos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n}\nin vec3 a_position;\nin vec2 a_texCoord;\nin vec4 a_color;\nlayout(std140) uniform builtin {\nvec4 cc_size_rotation;\n};\nvec4 vs_main() {\nvec4 pos = vec4(a_position, 1);\npos = cc_matWorld * pos;\nvec2 vertOffset = a_texCoord.xy - 0.5;\ncomputeVertPos(pos, vertOffset, quaternionFromEuler(vec3(0., 0., cc_size_rotation.z)), vec3(cc_size_rotation.xy, 0.), cc_matViewInv);\npos = cc_matViewProj * pos;\nuv = a_texCoord.xy;\ncolor = a_color;\nreturn pos;\n}\nvoid main() { gl_Position = vs_main(); }",frag:"\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n#endif\nreturn color;\n}\nin vec2 uv;\nin vec4 color;\nuniform sampler2D mainTexture;\nlayout(std140) uniform FragConstants {\nvec4 tintColor;\n};\nvec4 add () {\nvec4 col = 2.0 * color * tintColor * texture(mainTexture, uv);\nreturn 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 () {\nvec4 pos = vec4(a_position, 1);\nreturn pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nvec4 frag () {\nvec4 o = vec4(1.0);\nreturn o;\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nlayout(std140) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp 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 () {\nvec4 pos = vec4(a_position, 1);\npos = cc_matViewProj * cc_matWorld * pos;\nv_color = a_color;\nv_dist = a_dist;\nreturn pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nin vec4 v_color;\nin float v_dist;\nvec4 frag () {\nvec4 o = v_color;\nfloat aa = fwidth(v_dist);\nfloat alpha = 1. - smoothstep(-aa, 0., abs(v_dist) - 1.0);\no.rgb *= o.a;\no *= alpha;\nreturn 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){\nmat3 m = mat3(xAxis,yAxis,zAxis);\nfloat trace = m[0][0] + m[1][1] + m[2][2];\nvec4 quat;\nif (trace > 0.) {\nfloat s = 0.5 / sqrt(trace + 1.0);\nquat.w = 0.25 / s;\nquat.x = (m[2][1] - m[1][2]) * s;\nquat.y = (m[0][2] - m[2][0]) * s;\nquat.z = (m[1][0] - m[0][1]) * s;\n} else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\nfloat s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\nquat.w = (m[2][1] - m[1][2]) / s;\nquat.x = 0.25 * s;\nquat.y = (m[0][1] + m[1][0]) / s;\nquat.z = (m[0][2] + m[2][0]) / s;\n} else if (m[1][1] > m[2][2]) {\nfloat s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\nquat.w = (m[0][2] - m[2][0]) / s;\nquat.x = (m[0][1] + m[1][0]) / s;\nquat.y = 0.25 * s;\nquat.z = (m[1][2] + m[2][1]) / s;\n} else {\nfloat s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\nquat.w = (m[1][0] - m[0][1]) / s;\nquat.x = (m[0][2] + m[2][0]) / s;\nquat.y = (m[1][2] + m[2][1]) / s;\nquat.z = 0.25 * s;\n}\nfloat len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\nif (len > 0.) {\nlen = 1. / sqrt(len);\nquat.x = quat.x * len;\nquat.y = quat.y * len;\nquat.z = quat.z * len;\nquat.w = quat.w * len;\n}\nreturn quat;\n}\nvec4 quaternionFromEuler (vec3 angle){\nfloat x = angle.x / 2.;\nfloat y = angle.y / 2.;\nfloat z = angle.z / 2.;\nfloat sx = sin(x);\nfloat cx = cos(x);\nfloat sy = sin(y);\nfloat cy = cos(y);\nfloat sz = sin(z);\nfloat cz = cos(z);\nvec4 quat = vec4(0);\nquat.x = sx * cy * cz + cx * sy * sz;\nquat.y = cx * sy * cz + sx * cy * sz;\nquat.z = cx * cy * sz - sx * sy * cz;\nquat.w = cx * cy * cz - sx * sy * sz;\nreturn quat;\n}\nmat4 matrixFromRT (vec4 q, vec3 p){\nfloat x2 = q.x + q.x;\nfloat y2 = q.y + q.y;\nfloat z2 = q.z + q.z;\nfloat xx = q.x * x2;\nfloat xy = q.x * y2;\nfloat xz = q.x * z2;\nfloat yy = q.y * y2;\nfloat yz = q.y * z2;\nfloat zz = q.z * z2;\nfloat wx = q.w * x2;\nfloat wy = q.w * y2;\nfloat wz = q.w * z2;\nreturn mat4(\n1. - (yy + zz), xy + wz, xz - wy, 0,\nxy - wz, 1. - (xx + zz), yz + wx, 0,\nxz + wy, yz - wx, 1. - (xx + yy), 0,\np.x, p.y, p.z, 1\n);\n}\nmat4 matFromRTS (vec4 q, vec3 t, vec3 s){\nfloat x = q.x, y = q.y, z = q.z, w = q.w;\nfloat x2 = x + x;\nfloat y2 = y + y;\nfloat z2 = z + z;\nfloat xx = x * x2;\nfloat xy = x * y2;\nfloat xz = x * z2;\nfloat yy = y * y2;\nfloat yz = y * z2;\nfloat zz = z * z2;\nfloat wx = w * x2;\nfloat wy = w * y2;\nfloat wz = w * z2;\nfloat sx = s.x;\nfloat sy = s.y;\nfloat sz = s.z;\nreturn 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,\nt.x, t.y, t.z, 1);\n}\nvec4 quatMultiply (vec4 a, vec4 b){\nvec4 quat;\nquat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\nquat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\nquat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\nquat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\nreturn quat;\n}\nvoid rotateVecFromQuat (inout vec3 v, vec4 q){\nfloat ix = q.w * v.x + q.y * v.z - q.z * v.y;\nfloat iy = q.w * v.y + q.z * v.x - q.x * v.z;\nfloat iz = q.w * v.z + q.x * v.y - q.y * v.x;\nfloat iw = -q.x * v.x - q.y * v.y - q.z * v.z;\nv.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\nv.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\nv.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){\nvec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\nvec4 rotQuat = quatMultiply(viewQuat, q);\nrotateVecFromQuat(pos, rotQuat);\nreturn pos;\n}\nvoid rotateCorner (inout vec2 corner, float angle){\nfloat xOS = cos(angle) * corner.x - sin(angle) * corner.y;\nfloat yOS = sin(angle) * corner.x + cos(angle) * corner.y;\ncorner.x = xOS;\ncorner.y = yOS;\n}\nlayout(std140) uniform Constants {\nvec4 mainTiling_Offset;\nvec4 frameTile_velLenScale;\nvec4 scale;\n};\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nlayout(std140) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp 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\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nvec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\nvec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\nvec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\npos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_RENDER_MODE == 1\nvec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\nvec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\npos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_RENDER_MODE == 2\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nvec3 camX = vec3(1, 0, 0);\nvec3 camY = vec3(0, 0, -1);\npos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_RENDER_MODE == 3\nvec2 viewSpaceVert = vec2(vertOffset.x * s.x, vertOffset.y * s.y);\nrotateCorner(viewSpaceVert, q.z);\nvec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\nvec3 camY = vec3(0, 1, 0);\nvec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\npos.xyz += offset;\n#else\npos.x += vertOffset.x;\npos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV (float frameIndex, vec2 vertIndex, vec2 frameTile){\nvec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\naniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if CC_RENDER_MODE != 4\nvertIndex.y = 1. - vertIndex.y;\n#endif\nreturn (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nlayout(std140) uniform SampleConstants {\nvec4 u_sampleInfo;\n};\nlayout(std140) uniform TickConstants {\nvec4 u_worldRot;\nvec4 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\nin vec3 a_texCoord;\nin vec3 a_texCoord3;\nin vec3 a_normal;\nin vec4 a_color1;\n#endif\nvec3 unpackCurveData (sampler2D tex, vec2 coord) {\nvec4 a = texture(tex, coord);\nvec4 b = texture(tex, coord + u_sampleInfo.y);\nfloat c = fract(coord.x * u_sampleInfo.x);\nreturn mix(a.xyz, b.xyz, c);\n}\nvec3 unpackCurveData (sampler2D tex, vec2 coord, out float w) {\nvec4 a = texture(tex, coord);\nvec4 b = texture(tex, coord + u_sampleInfo.y);\nfloat c = fract(coord.x * u_sampleInfo.x);\nw = mix(a.w, b.w, c);\nreturn mix(a.xyz, b.xyz, c);\n}\nfloat pseudoRandom (float seed) {\nseed = mod(seed, 233280.);\nfloat q = (seed * 9301. + 49297.) / 233280.;\nreturn fract(q);\n}\n#if COLOR_OVER_TIME_MODULE_ENABLE\nuniform sampler2D color_over_time_tex0;\nlayout(std140) uniform ColorConstant {\nint u_color_mode;\n};\n#endif\n#if ROTATION_OVER_TIME_MODULE_ENABLE\nuniform sampler2D rotation_over_time_tex0;\nlayout(std140) uniform RotationConstant {\nint u_rotation_mode;\n};\n#endif\n#if SIZE_OVER_TIME_MODULE_ENABLE\nuniform sampler2D size_over_time_tex0;\nlayout(std140) uniform SizeConstant {\nint u_size_mode;\n};\n#endif\n#if FORCE_OVER_TIME_MODULE_ENABLE\nuniform sampler2D force_over_time_tex0;\nlayout(std140) uniform ForceConstant {\nint u_force_mode;\nint u_force_space;\n};\n#endif\n#if VELOCITY_OVER_TIME_MODULE_ENABLE\nuniform sampler2D velocity_over_time_tex0;\nlayout(std140) uniform VelocityConstant {\nint u_velocity_mode;\nint u_velocity_space;\n};\n#endif\n#if TEXTURE_ANIMATION_MODULE_ENABLE\nuniform sampler2D texture_animation_tex0;\nlayout(std140) uniform AnimationConstant {\nvec4 u_anim_info;\n};\n#endif\nfloat repeat (float t, float length) {\nreturn t - floor(t / length) * length;\n}\nvec4 rotateQuat (vec4 p, vec4 q) {\nvec3 iv = cross(q.xyz, p.xyz) + q.w * p.xyz;\nvec3 res = p.xyz + 2.0 * cross(q.xyz, iv);\nreturn vec4(res.xyz, p.w);\n}\nvec4 gpvs_main () {\nfloat activeTime = u_timeDelta.x - a_position_starttime.w;\nfloat normalizedTime = clamp(activeTime / a_dir_life.w, 0.0, 1.0);\nvec2 timeCoord0 = vec2(normalizedTime, 0.);\nvec2 timeCoord1 = vec2(normalizedTime, 1.);\n#if CC_RENDER_MODE == 4\nvec2 vertIdx = vec2(a_texCoord.x, a_texCoord.y);\n#else\nvec2 vertIdx = vec2(a_size_uv.w, a_rotation_uv.w);\n#endif\nvec4 velocity = vec4(a_dir_life.xyz, 0.);\nvec4 pos = vec4(a_position_starttime.xyz, 1.);\nvec3 size = a_size_uv.xyz;\n#if SIZE_OVER_TIME_MODULE_ENABLE\nif (u_size_mode == 1) {\nsize *= unpackCurveData(size_over_time_tex0, timeCoord0);\n} else {\nvec3 size_0 = unpackCurveData(size_over_time_tex0, timeCoord0);\nvec3 size_1 = unpackCurveData(size_over_time_tex0, timeCoord1);\nfloat factor_s = pseudoRandom(a_rndSeed + 39825.);\nsize *= mix(size_0, size_1, factor_s);\n}\n#endif\nvec3 compScale = scale.xyz * size;\n#if FORCE_OVER_TIME_MODULE_ENABLE\nvec3 forceAnim = vec3(0.);\nif (u_force_mode == 1) {\nforceAnim = unpackCurveData(force_over_time_tex0, timeCoord0);\n} else {\nvec3 force_0 = unpackCurveData(force_over_time_tex0, timeCoord0);\nvec3 force_1 = unpackCurveData(force_over_time_tex0, timeCoord1);\nfloat factor_f = pseudoRandom(a_rndSeed + 212165.);\nforceAnim = mix(force_0, force_1, factor_f);\n}\nvec4 forceTrack = vec4(forceAnim, 0.);\nif (u_force_space == 0) {\nforceTrack = rotateQuat(forceTrack, u_worldRot);\n}\nvelocity.xyz += forceTrack.xyz;\n#endif\n#if VELOCITY_OVER_TIME_MODULE_ENABLE\nfloat speedModifier0 = 1.;\nfloat speedModifier1 = 1.;\nvec3 velocityAnim = vec3(0.);\nif (u_velocity_mode == 1) {\nvelocityAnim = unpackCurveData(velocity_over_time_tex0, timeCoord0, speedModifier0);\n} else {\nvec3 vectory_0 = unpackCurveData(velocity_over_time_tex0, timeCoord0, speedModifier0);\nvec3 vectory_1 = unpackCurveData(velocity_over_time_tex0, timeCoord1, speedModifier1);\nfloat factor_v = pseudoRandom(a_rndSeed + 197866.);\nvelocityAnim = mix(vectory_0, vectory_1, factor_v);\nspeedModifier0 = mix(speedModifier0, speedModifier1, factor_v);\n}\nvec4 velocityTrack = vec4(velocityAnim, 0.);\nif (u_velocity_space == 0) {\nvelocityTrack = rotateQuat(velocityTrack, u_worldRot);\n}\nvelocity.xyz += velocityTrack.xyz;\nvelocity.xyz *= speedModifier0;\n#endif\npos.xyz += velocity.xyz * normalizedTime * a_dir_life.w;\n#if !CC_USE_WORLD_SPACE\npos = cc_matWorld * pos;\n#if CC_RENDER_MODE == 1\nvelocity = rotateQuat(velocity, u_worldRot);\n#endif\n#endif\nvec3 rotation = a_rotation_uv.xyz;\n#if ROTATION_OVER_TIME_MODULE_ENABLE\nif (u_rotation_mode == 1) {\nrotation += unpackCurveData(rotation_over_time_tex0, timeCoord0) * normalizedTime * a_dir_life.w;\n} else {\nvec3 rotation_0 = unpackCurveData(rotation_over_time_tex0, timeCoord0);\nvec3 rotation_1 = unpackCurveData(rotation_over_time_tex0, timeCoord1);\nfloat factor_r = pseudoRandom(a_rndSeed + 125292.);\nrotation += mix(rotation_0, rotation_1, factor_r) * normalizedTime * a_dir_life.w;\n}\n#endif\n#if COLOR_OVER_TIME_MODULE_ENABLE\nif (u_color_mode == 1) {\ncolor = a_color * texture(color_over_time_tex0, timeCoord0);\n} else {\nvec4 color_0 = texture(color_over_time_tex0, timeCoord0);\nvec4 color_1 = texture(color_over_time_tex0, timeCoord1);\nfloat factor_c = pseudoRandom(a_rndSeed + 91041.);\ncolor = a_color * mix(color_0, color_1, factor_c);\n}\n#else\ncolor = a_color;\n#endif\n#if CC_RENDER_MODE != 4\nvec2 cornerOffset = vec2((vertIdx - 0.5));\n#if CC_RENDER_MODE == 0\nvec3 rotEuler = rotation.xyz;\n#elif CC_RENDER_MODE == 1\nvec3 rotEuler = vec3(0.);\n#else\nvec3 rotEuler = vec3(0., 0., rotation.z);\n#endif\ncomputeVertPos(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\nmat4 xformNoScale = matrixFromRT(quaternionFromEuler(rotation), pos.xyz);\nmat4 xform = matFromRTS(quaternionFromEuler(rotation), pos.xyz, compScale);\npos = xform * vec4(a_texCoord3, 1);\nvec4 normal = xformNoScale * vec4(a_normal, 0);\ncolor *= a_color1;\n#endif\npos = cc_matViewProj * pos;\nfloat frameIndex = 0.;\n#if TEXTURE_ANIMATION_MODULE_ENABLE\nfloat startFrame = 0.;\nvec3 frameInfo = vec3(0.);\nif (int(u_anim_info.x) == 1) {\nframeInfo = unpackCurveData(texture_animation_tex0, timeCoord0);\n} else {\nvec3 frameInfo0 = unpackCurveData(texture_animation_tex0, timeCoord0);\nvec3 frameInfo1 = unpackCurveData(texture_animation_tex0, timeCoord1);\nfloat factor_t = pseudoRandom(a_rndSeed + 90794.);\nframeInfo = mix(frameInfo0, frameInfo1, factor_t);\n}\nstartFrame = frameInfo.x / u_anim_info.y;\nframeIndex = repeat(u_anim_info.z * (frameInfo.y + startFrame), 1.);\n#endif\nuv = computeUV(frameIndex, vertIdx, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\nreturn pos;\n}\nvoid main() { gl_Position = gpvs_main(); }",frag:"\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n#endif\nreturn color;\n}\nin vec2 uv;\nin vec4 color;\nuniform sampler2D mainTexture;\nlayout(std140) uniform FragConstants {\nvec4 tintColor;\n};\nvec4 add () {\nvec4 col = 2.0 * color * tintColor * texture(mainTexture, uv);\nreturn CCFragOutput(col);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = add(); }"}],[{vert:"\nprecision mediump float;\nlayout(std140) uniform Constants {\nvec4 mainTiling_Offset;\nvec4 frameTile_velLenScale;\nvec4 scale;\n};\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nlayout(std140) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp 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\nout vec3 vBarycentric;\n#endif\nvec4 vs_main() {\nhighp vec4 pos = vec4(a_position, 1);\nvec4 velocity = vec4(a_texCoord1.xyz, 0);\n#if !CC_USE_WORLD_SPACE\npos = cc_matWorld * pos;\nvelocity = cc_matWorld * velocity;\n#endif\nfloat vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\nvec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\npos.xyz += camUp * vertOffset;\npos = cc_matViewProj * pos;\nuv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\ncolor = a_color;\n#if CC_DRAW_WIRE_FRAME\nvBarycentric = a_texCoord2;\n#endif\nreturn pos;\n}\nvoid main() { gl_Position = vs_main(); }",frag:"\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n#endif\nreturn color;\n}\nin vec2 uv;\nin vec4 color;\n#if CC_DRAW_WIRE_FRAME\nin vec3 vBarycentric;\n#endif\nuniform sampler2D mainTexture;\nlayout(std140) uniform FragConstants {\nvec4 tintColor;\n};\nvec4 add () {\nvec4 col = 2.0 * color * tintColor * texture(mainTexture, uv);\n#if CC_DRAW_WIRE_FRAME\nif (any(lessThan(vBarycentric, vec3(0.02)))) {\ncol = vec4(0., 1., 1., 1.);\n}\n#endif\nreturn 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){\nmat3 m = mat3(xAxis,yAxis,zAxis);\nfloat trace = m[0][0] + m[1][1] + m[2][2];\nvec4 quat;\nif (trace > 0.) {\nfloat s = 0.5 / sqrt(trace + 1.0);\nquat.w = 0.25 / s;\nquat.x = (m[2][1] - m[1][2]) * s;\nquat.y = (m[0][2] - m[2][0]) * s;\nquat.z = (m[1][0] - m[0][1]) * s;\n} else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\nfloat s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\nquat.w = (m[2][1] - m[1][2]) / s;\nquat.x = 0.25 * s;\nquat.y = (m[0][1] + m[1][0]) / s;\nquat.z = (m[0][2] + m[2][0]) / s;\n} else if (m[1][1] > m[2][2]) {\nfloat s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\nquat.w = (m[0][2] - m[2][0]) / s;\nquat.x = (m[0][1] + m[1][0]) / s;\nquat.y = 0.25 * s;\nquat.z = (m[1][2] + m[2][1]) / s;\n} else {\nfloat s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\nquat.w = (m[1][0] - m[0][1]) / s;\nquat.x = (m[0][2] + m[2][0]) / s;\nquat.y = (m[1][2] + m[2][1]) / s;\nquat.z = 0.25 * s;\n}\nfloat len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\nif (len > 0.) {\nlen = 1. / sqrt(len);\nquat.x = quat.x * len;\nquat.y = quat.y * len;\nquat.z = quat.z * len;\nquat.w = quat.w * len;\n}\nreturn quat;\n}\nvec4 quaternionFromEuler (vec3 angle){\nfloat x = angle.x / 2.;\nfloat y = angle.y / 2.;\nfloat z = angle.z / 2.;\nfloat sx = sin(x);\nfloat cx = cos(x);\nfloat sy = sin(y);\nfloat cy = cos(y);\nfloat sz = sin(z);\nfloat cz = cos(z);\nvec4 quat = vec4(0);\nquat.x = sx * cy * cz + cx * sy * sz;\nquat.y = cx * sy * cz + sx * cy * sz;\nquat.z = cx * cy * sz - sx * sy * cz;\nquat.w = cx * cy * cz - sx * sy * sz;\nreturn quat;\n}\nmat4 matrixFromRT (vec4 q, vec3 p){\nfloat x2 = q.x + q.x;\nfloat y2 = q.y + q.y;\nfloat z2 = q.z + q.z;\nfloat xx = q.x * x2;\nfloat xy = q.x * y2;\nfloat xz = q.x * z2;\nfloat yy = q.y * y2;\nfloat yz = q.y * z2;\nfloat zz = q.z * z2;\nfloat wx = q.w * x2;\nfloat wy = q.w * y2;\nfloat wz = q.w * z2;\nreturn mat4(\n1. - (yy + zz), xy + wz, xz - wy, 0,\nxy - wz, 1. - (xx + zz), yz + wx, 0,\nxz + wy, yz - wx, 1. - (xx + yy), 0,\np.x, p.y, p.z, 1\n);\n}\nmat4 matFromRTS (vec4 q, vec3 t, vec3 s){\nfloat x = q.x, y = q.y, z = q.z, w = q.w;\nfloat x2 = x + x;\nfloat y2 = y + y;\nfloat z2 = z + z;\nfloat xx = x * x2;\nfloat xy = x * y2;\nfloat xz = x * z2;\nfloat yy = y * y2;\nfloat yz = y * z2;\nfloat zz = z * z2;\nfloat wx = w * x2;\nfloat wy = w * y2;\nfloat wz = w * z2;\nfloat sx = s.x;\nfloat sy = s.y;\nfloat sz = s.z;\nreturn 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,\nt.x, t.y, t.z, 1);\n}\nvec4 quatMultiply (vec4 a, vec4 b){\nvec4 quat;\nquat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\nquat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\nquat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\nquat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\nreturn quat;\n}\nvoid rotateVecFromQuat (inout vec3 v, vec4 q){\nfloat ix = q.w * v.x + q.y * v.z - q.z * v.y;\nfloat iy = q.w * v.y + q.z * v.x - q.x * v.z;\nfloat iz = q.w * v.z + q.x * v.y - q.y * v.x;\nfloat iw = -q.x * v.x - q.y * v.y - q.z * v.z;\nv.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\nv.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\nv.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){\nvec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\nvec4 rotQuat = quatMultiply(viewQuat, q);\nrotateVecFromQuat(pos, rotQuat);\nreturn pos;\n}\nvoid rotateCorner (inout vec2 corner, float angle){\nfloat xOS = cos(angle) * corner.x - sin(angle) * corner.y;\nfloat yOS = sin(angle) * corner.x + cos(angle) * corner.y;\ncorner.x = xOS;\ncorner.y = yOS;\n}\nlayout(std140) uniform Constants {\nvec4 mainTiling_Offset;\nvec4 frameTile_velLenScale;\nvec4 scale;\n};\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nlayout(std140) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp 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\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nvec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\nvec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\nvec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\npos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_RENDER_MODE == 1\nvec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\nvec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\npos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_RENDER_MODE == 2\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nvec3 camX = vec3(1, 0, 0);\nvec3 camY = vec3(0, 0, -1);\npos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_RENDER_MODE == 3\nvec2 viewSpaceVert = vec2(vertOffset.x * s.x, vertOffset.y * s.y);\nrotateCorner(viewSpaceVert, q.z);\nvec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\nvec3 camY = vec3(0, 1, 0);\nvec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\npos.xyz += offset;\n#else\npos.x += vertOffset.x;\npos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV (float frameIndex, vec2 vertIndex, vec2 frameTile){\nvec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\naniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if CC_RENDER_MODE != 4\nvertIndex.y = 1. - vertIndex.y;\n#endif\nreturn (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\nin vec3 a_color1;\n#endif\n#if CC_RENDER_MODE == 4\nin vec3 a_texCoord3;\nin vec3 a_normal;\nin vec4 a_color1;\n#endif\nvec4 lpvs_main () {\nvec3 compScale = scale.xyz * a_texCoord1;\nvec4 pos = vec4(a_position, 1);\n#if CC_RENDER_MODE == 1\nvec4 velocity = vec4(a_color1.xyz, 0);\n#endif\n#if !CC_USE_WORLD_SPACE\npos = cc_matWorld * pos;\n#if CC_RENDER_MODE == 1\nvelocity = cc_matWorld * velocity;\n#endif\n#endif\n#if CC_RENDER_MODE != 4\nvec2 cornerOffset = vec2((a_texCoord.xy - 0.5));\n#if CC_RENDER_MODE == 0\nvec3 rotEuler = a_texCoord2;\n#elif CC_RENDER_MODE == 1\nvec3 rotEuler = vec3(0.);\n#else\nvec3 rotEuler = vec3(0., 0., a_texCoord2.z);\n#endif\ncomputeVertPos(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);\ncolor = a_color;\n#else\nmat4 xformNoScale = matrixFromRT(quaternionFromEuler(a_texCoord2), pos.xyz);\nmat4 xform = matFromRTS(quaternionFromEuler(a_texCoord2), pos.xyz, compScale);\npos = xform * vec4(a_texCoord3, 1);\nvec4 normal = xformNoScale * vec4(a_normal, 0);\ncolor = a_color * a_color1;\n#endif\nuv = computeUV(a_texCoord.z, a_texCoord.xy, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\npos = cc_matViewProj * pos;\nreturn pos;\n}\nvoid main() { gl_Position = lpvs_main(); }",frag:"\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n#endif\nreturn color;\n}\nin vec2 uv;\nin vec4 color;\nuniform sampler2D mainTexture;\nlayout(std140) uniform FragConstants {\nvec4 tintColor;\n};\nvec4 add () {\nvec4 col = 2.0 * color * tintColor * texture(mainTexture, uv);\nreturn CCFragOutput(col);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = add(); }"}],[{vert:"\nprecision highp float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\n#if USE_LOCAL\nlayout(std140) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp 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\nin vec4 a_color2;\nout vec4 v_dark;\n#endif\nvec4 vert () {\nvec4 pos = vec4(a_position, 1);\n#if USE_LOCAL\npos = cc_matWorld * pos;\n#endif\npos = cc_matViewProj * pos;\nuv0 = a_texCoord;\nv_light = a_color;\n#if TWO_COLORED\nv_dark = a_color2;\n#endif\nreturn pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\n#if USE_ALPHA_TEST\nlayout(std140) uniform ALPHA_TEST_DATA {\nfloat alphaThreshold;\n};\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n#if USE_ALPHA_TEST\nif (color.a < alphaThreshold) discard;\n#endif\n}\nvoid ALPHA_TEST (in float alpha) {\n#if USE_ALPHA_TEST\nif (alpha < alphaThreshold) discard;\n#endif\n}\nin vec4 v_light;\n#if TWO_COLORED\nin vec4 v_dark;\n#endif\nin vec2 uv0;\nuniform sampler2D cc_spriteTexture;\nvec4 frag () {\nvec4 o = vec4(1, 1, 1, 1);\n#if TWO_COLORED\nvec4 texColor = vec4(1, 1, 1, 1);\ntexColor *= texture(cc_spriteTexture, uv0);\no.a = texColor.a * v_light.a;\no.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;\n#else\no *= texture(cc_spriteTexture, uv0);\no *= v_light;\n#endif\nALPHA_TEST(o);\nreturn o;\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\n#if USE_LOCAL\nlayout(std140) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\n#endif\n#if SAMPLE_FROM_RT\n#endif\nin vec3 a_position;\nin vec2 a_texCoord;\nin vec4 a_color;\nout vec4 color;\nout vec2 uv0;\nvec4 vert () {\nvec4 pos = vec4(a_position, 1);\n#if USE_LOCAL\npos = cc_matWorld * pos;\n#endif\n#if USE_PIXEL_ALIGNMENT\npos = cc_matView * pos;\npos.xyz = floor(pos.xyz);\npos = cc_matProj * pos;\n#else\npos = cc_matViewProj * pos;\n#endif\nuv0 = a_texCoord;\n#if SAMPLE_FROM_RT\nuv0 = cc_cameraPos.w > 1.0 ? vec2(uv0.x, 1.0 - uv0.y) : uv0;\n#endif\ncolor = a_color;\nreturn pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nvec4 CCSampleWithAlphaSeparated(sampler2D tex, vec2 uv) {\n#if CC_USE_EMBEDDED_ALPHA\nreturn vec4(texture(tex, uv).rgb, texture(tex, uv + vec2(0.0, 0.5)).r);\n#else\nreturn texture(tex, uv);\n#endif\n}\n#if USE_ALPHA_TEST\nlayout(std140) uniform ALPHA_TEST_DATA {\nfloat alphaThreshold;\n};\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n#if USE_ALPHA_TEST\nif (color.a < alphaThreshold) discard;\n#endif\n}\nvoid ALPHA_TEST (in float alpha) {\n#if USE_ALPHA_TEST\nif (alpha < alphaThreshold) discard;\n#endif\n}\nin vec4 color;\n#if USE_TEXTURE\nin vec2 uv0;\nuniform sampler2D cc_spriteTexture;\n#endif\nvec4 frag () {\nvec4 o = vec4(1, 1, 1, 1);\n#if USE_TEXTURE\no *= CCSampleWithAlphaSeparated(cc_spriteTexture, uv0);\n#if IS_GRAY\nfloat gray = 0.2126 * o.r + 0.7152 * o.g + 0.0722 * o.b;\no.r = o.g = o.b = gray;\n#endif\n#endif\no *= color;\nALPHA_TEST(o);\nreturn o;\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nin vec4 a_tangent;\n#if CC_USE_MORPH\nin float a_vertexId;\nint getVertexId() {\nreturn int(a_vertexId);\n}\nlayout(std140) uniform CCMorph {\nvec4 cc_displacementWeights[15];\nvec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\nivec2 texSize = textureSize(tex, 0);\nreturn texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture(tex, x)),\ndecode32(texture(tex, y)),\ndecode32(texture(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nuniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nuniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nuniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nin vec4 a_joints;\nin vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nin highp vec4 a_jointAnimInfo;\n#endif\nlayout(std140) uniform CCSkinningTexture {\nhighp vec4 cc_jointTextureInfo;\n};\nlayout(std140) uniform CCSkinningAnimation {\nhighp vec4 cc_jointAnimInfo;\n};\nuniform highp sampler2D cc_jointTexture;\n#else\nlayout(std140) uniform CCSkinning {\nhighp vec4 cc_joints[30 * 3];\n};\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn 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\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn 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\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn 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 () {\nvec4 joints = vec4(a_joints);\nreturn 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) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\n#if USE_INSTANCING\nin vec4 a_matWorld0;\nin vec4 a_matWorld1;\nin vec4 a_matWorld2;\n#if USE_LIGHTMAP\nin vec4 a_lightingMapUVParam;\n#endif\n#elif USE_BATCHING\nin float a_dyn_batch_id;\nlayout(std140) uniform CCLocalBatched {\nhighp mat4 cc_matWorlds[10];\n};\n#else\nlayout(std140) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\n#endif\nlayout(std140) uniform Constants {\nvec4 tilingOffset;\nvec4 albedo;\nvec4 albedoScaleAndCutoff;\nvec4 pbrParams;\nvec4 emissive;\nvec4 emissiveScaleParam;\n};\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nout float v_fog_factor;\nout highp vec4 v_shadowPos;\nlayout(std140) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\n#if CC_RECEIVE_SHADOW\nuniform sampler2D cc_shadowMap;\nuniform sampler2D cc_spotLightingMap;\n#endif\n#if USE_VERTEX_COLOR\nin vec4 a_color;\nout vec4 v_color;\n#endif\nout vec3 v_position;\nout vec3 v_normal;\nout vec2 v_uv;\nout vec2 v_uv1;\n#if USE_NORMAL_MAP\nout vec3 v_tangent;\nout vec3 v_bitangent;\n#endif\n#if HAS_SECOND_UV || USE_LIGHTMAP\nin vec2 a_texCoord1;\n#endif\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nout vec3 v_luv;\nvoid CCLightingMapCaclUV()\n{\n#if !USE_INSTANCING\nv_luv.xy = cc_lightingMapUVParam.xy + a_texCoord1 * cc_lightingMapUVParam.zw;\nv_luv.z = cc_lightingMapUVParam.z;\n#else\nv_luv.xy = a_lightingMapUVParam.xy + a_texCoord1 * a_lightingMapUVParam.zw;\nv_luv.z = a_lightingMapUVParam.z;\n#endif\n}\n#endif\nvoid main () {\nStandardVertInput In;\nIn.position = vec4(a_position, 1.0);\nIn.normal = a_normal;\nIn.tangent = a_tangent;\n#if CC_USE_MORPH\napplyMorph(In);\n#endif\n#if CC_USE_SKINNING\nCCSkin(In);\n#endif\nmat4 matWorld, matWorldIT;\n#if USE_INSTANCING\nmatWorld = mat4(\nvec4(a_matWorld0.xyz, 0.0),\nvec4(a_matWorld1.xyz, 0.0),\nvec4(a_matWorld2.xyz, 0.0),\nvec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n);\nmatWorldIT = matWorld;\n#elif USE_BATCHING\nmatWorld = cc_matWorlds[int(a_dyn_batch_id)];\nmatWorldIT = matWorld;\n#else\nmatWorld = cc_matWorld;\nmatWorldIT = cc_matWorldIT;\n#endif\nvec4 pos = matWorld * In.position;\nv_position = pos.xyz;\nv_normal = normalize((matWorldIT * vec4(In.normal, 0.0)).xyz);\n#if USE_NORMAL_MAP\nv_tangent = normalize((matWorld * vec4(In.tangent.xyz, 0.0)).xyz);\nv_bitangent = cross(v_normal, v_tangent) * In.tangent.w;\n#endif\nv_uv = a_texCoord * tilingOffset.xy + tilingOffset.zw;\n#if SAMPLE_FROM_RT\nv_uv = cc_cameraPos.w > 1.0 ? vec2(v_uv.x, 1.0 - v_uv.y) : v_uv;\n#endif\n#if HAS_SECOND_UV\nv_uv1 = a_texCoord1 * tilingOffset.xy + tilingOffset.zw;\n#if SAMPLE_FROM_RT\nv_uv1 = cc_cameraPos.w > 1.0 ? vec2(v_uv1.x, 1.0 - v_uv1.y) : v_uv1;\n#endif\n#endif\n#if USE_VERTEX_COLOR\nv_color = a_color;\n#endif\n#if CC_USE_FOG == 0\nv_fog_factor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nv_fog_factor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nv_fog_factor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nv_fog_factor = LayeredFog(pos);\n#else\nv_fog_factor = 1.0;\n#endif\nv_shadowPos = cc_matLightViewProj * pos;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nCCLightingMapCaclUV();\n#endif\ngl_Position = cc_matProj * (cc_matView * matWorld) * In.position;\n}",frag:"\nprecision highp float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nlayout(std140) uniform Constants {\nvec4 tilingOffset;\nvec4 albedo;\nvec4 albedoScaleAndCutoff;\nvec4 pbrParams;\nvec4 emissive;\nvec4 emissiveScaleParam;\n};\nin float v_fog_factor;\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nlayout(std140) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\n#if CC_RECEIVE_SHADOW\nuniform sampler2D cc_shadowMap;\nuniform sampler2D cc_spotLightingMap;\nfloat CCGetLinearDepth (vec3 worldPos) {\nvec4 viewStartPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\nfloat dist = length(viewStartPos.xyz);\nreturn cc_shadowNFLSInfo.x + (-dist / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x));\n}\nfloat CCGetShadowFactorX1 (vec4 shadowPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture(cc_shadowMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n} else {\nclosestDepth = texture(cc_shadowMap, clipPos.xy).x;\n}\nshadow = step(closestDepth, clipPos.z- cc_shadowWHPBInfo.w);\nreturn shadow;\n}\nfloat CCGetShadowFactorX5 (vec4 shadowPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfloat 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n} else {\nfloat closestDepth = texture(cc_shadowMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = texture(cc_shadowMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = texture(cc_shadowMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = texture(cc_shadowMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\nreturn shadow / 5.0;\n}\nfloat CCGetShadowFactorX9 (vec4 shadowPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n} else {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat closestDepth = texture(cc_shadowMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n}\nreturn shadow / 9.0;\n}\nfloat CCGetShadowFactorX25 (vec4 shadowPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfor (int i = -2; i <= 2; i++) {\nfor (int j = -2; j <= 2; j++) {\nfloat 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n} else {\nfor (int i = -2; i <= 2; i++) {\nfor (int j = -2; j <= 2; j++) {\nfloat closestDepth = texture(cc_shadowMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n}\nreturn shadow / 25.0;\n}\nfloat CCGetDirLightShadowFactorX1 (vec4 shadowPos, vec3 worldPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nfloat depth = 0.0;\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture(cc_spotLightingMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n} else {\nclosestDepth = texture(cc_spotLightingMap, clipPos.xy).x;\n}\nshadow = step(closestDepth, depth - cc_shadowWHPBInfo.w);\nreturn shadow;\n}\nfloat CCGetDirLightShadowFactorX5 (vec4 shadowPos, vec3 worldPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfloat 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));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\n} else {\nfloat closestDepth = texture(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = texture(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = texture(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = texture(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\n}\nreturn shadow / 5.0;\n}\nfloat CCGetDirLightShadowFactorX9 (vec4 shadowPos, vec3 worldPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat 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));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\n}\n}\n} else {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat closestDepth = texture(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\n}\n}\n}\nreturn shadow / 9.0;\n}\nfloat CCGetDirLightShadowFactorX25 (vec4 shadowPos, vec3 worldPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat depth = 0.0;\nfloat shadow = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfor (int i = -2; i <= 2; i++) {\nfor (int j = -2; j <= 2; j++) {\nfloat 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n} else {\nfor (int i = -2; i <= 2; i++) {\nfor (int j = -2; j <= 2; j++) {\nfloat closestDepth = texture(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n}\nreturn shadow / 25.0;\n}\n#endif\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\nvec3 unpackRGBE (vec4 rgbe) {\nreturn rgbe.rgb * pow(2.0, rgbe.a * 255.0 - 128.0);\n}\nvec4 fragTextureLod (sampler2D tex, vec2 coord, float lod) {\nreturn textureLod(tex, coord, lod);\n}\nvec4 fragTextureLod (samplerCube tex, vec3 coord, float lod) {\nreturn textureLod(tex, coord, lod);\n}\n#endif\nfloat GGXMobile (float roughness, float NoH, vec3 H, vec3 N) {\nvec3 NxH = cross(N, H);\nfloat OneMinusNoHSqr = dot(NxH, NxH);\nfloat a = roughness * roughness;\nfloat n = NoH * a;\nfloat p = a / (OneMinusNoHSqr + n * n);\nreturn p * p;\n}\nfloat CalcSpecular (float roughness, float NoH, vec3 H, vec3 N) {\nreturn (roughness * 0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox (vec3 specular, float roughness, float NoV) {\nconst vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\nconst vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\nvec4 r = roughness * c0 + c1;\nfloat a004 = min(r.x * r.x, exp2(-9.28 * NoV)) * r.x + r.y;\nvec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;\nAB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\nreturn specular * AB.x + AB.y;\n}\nstruct StandardSurface {\nvec4 albedo;\nvec3 position;\nvec3 normal;\nvec3 emissive;\nvec3 lightmap;\nfloat lightmap_test;\nfloat roughness;\nfloat metallic;\nfloat occlusion;\n};\nvec4 CCStandardShadingBase (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.001);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 L = normalize(-cc_mainLitDir.xyz);\nvec3 H = normalize(L + V);\nfloat NH = max(dot(N, H), 0.0);\nfloat NL = max(dot(N, L), 0.001);\nvec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w;\nvec3 diffuseContrib = diffuse;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nif (s.lightmap_test > 0.0001) {\nfinalColor = s.lightmap.rgb;\n}\n#else\ndiffuseContrib /= 3.14159265359;\n#endif\nvec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\nfinalColor *= (diffuseContrib + specularContrib);\nfloat fAmb = 0.5 - N.y * 0.5;\nvec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb) * cc_ambientSky.w;\nfinalColor += (ambDiff.rgb * diffuse);\n#if CC_USE_IBL\nvec3 R = normalize(reflect(-V, N));\nvec4 envmap = fragTextureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n#if CC_USE_IBL == 2\nvec3 env = unpackRGBE(envmap);\n#else\nvec3 env = SRGBToLinear(envmap.rgb);\n#endif\nfinalColor += env * cc_ambientSky.w * specular;\n#endif\nfinalColor = finalColor * s.occlusion;\n#if CC_USE_HDR\ns.emissive *= cc_exposure.w;\n#endif\nfinalColor += s.emissive;\n#if CC_RECEIVE_SHADOW\n{\nfloat pcf = cc_shadowWHPBInfo.z + 0.001;\nfloat shadowAttenuation = 0.0;\nfloat cosAngle = clamp(1.0 - dot(N, L.xyz), 0.0, 1.0);\nvec3 projWorldPos = shadowPos.xyz + cosAngle * cc_shadowLPNNInfo.z * N;\nvec4 pos = vec4(projWorldPos.xyz, shadowPos.w);\nif (pcf > 3.0) shadowAttenuation = CCGetShadowFactorX25(pos);\nelse if (pcf > 2.0) shadowAttenuation = CCGetShadowFactorX9(pos);\nelse if (pcf > 1.0) shadowAttenuation = CCGetShadowFactorX5(pos);\nelse shadowAttenuation = CCGetShadowFactorX1(pos);\nvec3 shadowColor = cc_shadowColor.rgb * cc_shadowColor.a + finalColor.rgb * (1.0 - cc_shadowColor.a);\nif (cc_shadowNFLSInfo.w > 0.000001) {\nfinalColor.rgb = shadowColor.rgb * shadowAttenuation + finalColor.rgb * (1.0 - shadowAttenuation);\n} else {\nfinalColor.rgb = shadowColor.rgb * shadowAttenuation * NL + finalColor.rgb * (1.0 - shadowAttenuation * NL);\n}\n}\n#endif\nreturn vec4(finalColor, s.albedo.a);\n}\nvec3 ACESToneMap (vec3 color) {\ncolor = min(color, vec3(8.0));\nconst float A = 2.51;\nconst float B = 0.03;\nconst float C = 2.43;\nconst float D = 0.59;\nconst float E = 0.14;\nreturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n#if !CC_USE_HDR\ncolor.rgb = sqrt(ACESToneMap(color.rgb));\n#endif\nreturn color;\n}\nin highp vec4 v_shadowPos;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nin vec3 v_luv;\nuniform sampler2D cc_lightingMap;\nvec3 UnpackLightingmap(vec4 color) {\nvec3 c;\nfloat e = 1.0 + color.a * (8.0 - 1.0);\nc.r = color.r * e;\nc.g = color.g * e;\nc.b = color.b * e;\nreturn c;\n}\n#endif\nin vec3 v_position;\nin vec2 v_uv;\nin vec2 v_uv1;\nin vec3 v_normal;\n#if USE_VERTEX_COLOR\nin vec4 v_color;\n#endif\n#if USE_ALBEDO_MAP\nuniform sampler2D albedoMap;\n#endif\n#if USE_NORMAL_MAP\nin vec3 v_tangent;\nin vec3 v_bitangent;\nuniform sampler2D normalMap;\n#endif\n#if USE_PBR_MAP\nuniform sampler2D pbrMap;\n#endif\n#if USE_METALLIC_ROUGHNESS_MAP\nuniform sampler2D metallicRoughnessMap;\n#endif\n#if USE_OCCLUSION_MAP\nuniform sampler2D occlusionMap;\n#endif\n#if USE_EMISSIVE_MAP\nuniform sampler2D emissiveMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\nvoid surf (out StandardSurface s) {\nvec4 baseColor = albedo;\n#if USE_VERTEX_COLOR\nbaseColor *= v_color;\n#endif\n#if USE_ALBEDO_MAP\nvec4 texColor = texture(albedoMap, ALBEDO_UV);\ntexColor.rgb = SRGBToLinear(texColor.rgb);\nbaseColor *= texColor;\n#endif\ns.albedo = baseColor;\ns.albedo.rgb *= albedoScaleAndCutoff.xyz;\n#if USE_ALPHA_TEST\nif (s.albedo.ALPHA_TEST_CHANNEL < albedoScaleAndCutoff.w) discard;\n#endif\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nvec4 lightColor = texture(cc_lightingMap, v_luv.xy);\ns.lightmap = UnpackLightingmap(lightColor);\ns.lightmap_test = v_luv.z;\n#endif\ns.normal = v_normal;\n#if USE_NORMAL_MAP\nvec3 nmmp = texture(normalMap, NORMAL_UV).xyz - vec3(0.5);\ns.normal =\n(nmmp.x * pbrParams.w) * normalize(v_tangent) +\n(nmmp.y * pbrParams.w) * normalize(v_bitangent) +\nnmmp.z * normalize(s.normal);\n#endif\ns.position = v_position;\nvec4 pbr = pbrParams;\n#if USE_PBR_MAP\nvec4 res = texture(pbrMap, PBR_UV);\npbr.x *= res.r;\npbr.y *= res.g;\npbr.z *= res.b;\n#endif\n#if USE_METALLIC_ROUGHNESS_MAP\nvec4 metallicRoughness = texture(metallicRoughnessMap, PBR_UV);\npbr.z *= metallicRoughness.b;\npbr.y *= metallicRoughness.g;\n#endif\n#if USE_OCCLUSION_MAP\npbr.x *= texture(occlusionMap, PBR_UV).r;\n#endif\ns.occlusion = clamp(pbr.x, 0.0, 0.96);\ns.roughness = clamp(pbr.y, 0.04, 1.0);\ns.metallic = pbr.z;\ns.emissive = emissive.rgb * emissiveScaleParam.xyz;\n#if USE_EMISSIVE_MAP\ns.emissive *= SRGBToLinear(texture(emissiveMap, EMISSIVE_UV).rgb);\n#endif\n}\n#if CC_FORWARD_ADD\n#if CC_PIPELINE_TYPE == 0\n# define LIGHTS_PER_PASS 1\n#else\n# define LIGHTS_PER_PASS 10\n#endif\nlayout(std140) uniform CCForwardLight {\nhighp vec4 cc_lightPos[LIGHTS_PER_PASS];\nvec4 cc_lightColor[LIGHTS_PER_PASS];\nvec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS];\nvec4 cc_lightDir[LIGHTS_PER_PASS];\n};\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\nfloat factor = distSqr * invSqrAttRadius;\nfloat smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\nreturn smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\nfloat attenuation = 1.0 / max(distSqr, 0.01*0.01);\nattenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\nreturn attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\nfloat cd = dot(litDir, L);\nfloat attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\nreturn (attenuation * attenuation);\n}\nvec4 CCStandardShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 diffuseContrib = diffuse / 3.14159265359;\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.001);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nint numLights = CC_PIPELINE_TYPE == 0 ? LIGHTS_PER_PASS : int(cc_lightDir[0].w);\nfor (int i = 0; i < LIGHTS_PER_PASS; i++) {\nif (i >= numLights) break;\nvec3 SLU = cc_lightPos[i].xyz - s.position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.001);\nfloat SNH = max(dot(N, SH), 0.0);\nfloat distSqr = dot(SLU, SLU);\nfloat litRadius = cc_lightSizeRangeAngle[i].x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(cc_lightSizeRangeAngle[i].y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (cc_lightPos[i].w > 0.0) {\nfloat cosInner = max(dot(-cc_lightDir[i].xyz, SL), 0.01);\nfloat cosOuter = cc_lightSizeRangeAngle[i].z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -cc_lightDir[i].xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = cc_lightColor[i].rgb;\n#if CC_RECEIVE_SHADOW\nif (cc_lightPos[i].w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z + 0.001;\nfloat shadowAttenuation = 0.0;\nfloat cosAngle = clamp(1.0 - dot(N, normalize(cc_lightPos[i].xyz - s.position.xyz)), 0.0, 1.0);\nvec3 projWorldPos = shadowPos.xyz + cosAngle * cc_shadowLPNNInfo.z * N;\nvec4 pos = vec4(projWorldPos.xyz, shadowPos.w);\nif (pcf > 3.0) shadowAttenuation = CCGetDirLightShadowFactorX25(pos, s.position);\nelse if (pcf > 2.0) shadowAttenuation = CCGetDirLightShadowFactorX9(pos, s.position);\nelse if (pcf > 1.0) shadowAttenuation = CCGetDirLightShadowFactorX5(pos, s.position);\nelse shadowAttenuation = CCGetDirLightShadowFactorX1(pos, s.position);\nlightColor *= 1.0 - shadowAttenuation;\n}\n}\n#endif\nfinalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n}\nfinalColor = finalColor * s.occlusion;\nreturn vec4(finalColor, 0.0);\n}\nlayout(location = 0) out vec4 fragColorX;\nvoid main () {\nStandardSurface s; surf(s);\nvec4 color = CCStandardShadingAdditive(s, v_shadowPos);\ncolor = vec4(mix(CC_FORWARD_ADD > 0 ? vec3(0.0) : cc_fogColor.rgb, color.rgb, v_fog_factor), color.a);\nfragColorX = CCFragOutput(color);\n}\n#elif CC_PIPELINE_TYPE == 0\nlayout(location = 0) out vec4 fragColorX;\nvoid main () {\nStandardSurface s; surf(s);\nvec4 color = CCStandardShadingBase(s, v_shadowPos);\ncolor = vec4(mix(CC_FORWARD_ADD > 0 ? vec3(0.0) : cc_fogColor.rgb, color.rgb, v_fog_factor), color.a);\nfragColorX = CCFragOutput(color);\n}\n#elif CC_PIPELINE_TYPE == 1\nlayout(location = 0) out vec4 fragColor0;\nlayout(location = 1) out vec4 fragColor1;\nlayout(location = 2) out vec4 fragColor2;\nlayout(location = 3) out vec4 fragColor3;\nvoid main () {\nStandardSurface s; surf(s);\nfragColor0 = s.albedo;\nfragColor1 = vec4(s.position, s.roughness);\nfragColor2 = vec4(s.normal, s.metallic);\nfragColor3 = vec4(s.emissive, s.occlusion);\n}\n#endif"},{vert:"\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nin vec4 a_tangent;\n#if CC_USE_MORPH\nin float a_vertexId;\nint getVertexId() {\nreturn int(a_vertexId);\n}\nlayout(std140) uniform CCMorph {\nvec4 cc_displacementWeights[15];\nvec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\nivec2 texSize = textureSize(tex, 0);\nreturn texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture(tex, x)),\ndecode32(texture(tex, y)),\ndecode32(texture(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nuniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nuniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nuniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nin vec4 a_joints;\nin vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nin highp vec4 a_jointAnimInfo;\n#endif\nlayout(std140) uniform CCSkinningTexture {\nhighp vec4 cc_jointTextureInfo;\n};\nlayout(std140) uniform CCSkinningAnimation {\nhighp vec4 cc_jointAnimInfo;\n};\nuniform highp sampler2D cc_jointTexture;\n#else\nlayout(std140) uniform CCSkinning {\nhighp vec4 cc_joints[30 * 3];\n};\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn 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\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn 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\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn 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 () {\nvec4 joints = vec4(a_joints);\nreturn 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) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\n#if USE_INSTANCING\nin vec4 a_matWorld0;\nin vec4 a_matWorld1;\nin vec4 a_matWorld2;\n#if USE_LIGHTMAP\nin vec4 a_lightingMapUVParam;\n#endif\n#elif USE_BATCHING\nin float a_dyn_batch_id;\nlayout(std140) uniform CCLocalBatched {\nhighp mat4 cc_matWorlds[10];\n};\n#else\nlayout(std140) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\n#endif\nlayout(std140) uniform Constants {\nvec4 tilingOffset;\nvec4 albedo;\nvec4 albedoScaleAndCutoff;\nvec4 pbrParams;\nvec4 emissive;\nvec4 emissiveScaleParam;\n};\nlayout(std140) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\n#if HAS_SECOND_UV || USE_LIGHTMAP\nin vec2 a_texCoord1;\n#endif\nout vec2 v_uv;\nout vec2 v_uv1;\nout vec4 v_worldPos;\nout float v_clip_depth;\nvec4 vert () {\nStandardVertInput In;\nIn.position = vec4(a_position, 1.0);\nIn.normal = a_normal;\nIn.tangent = a_tangent;\n#if CC_USE_MORPH\napplyMorph(In);\n#endif\n#if CC_USE_SKINNING\nCCSkin(In);\n#endif\nmat4 matWorld, matWorldIT;\n#if USE_INSTANCING\nmatWorld = mat4(\nvec4(a_matWorld0.xyz, 0.0),\nvec4(a_matWorld1.xyz, 0.0),\nvec4(a_matWorld2.xyz, 0.0),\nvec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n);\nmatWorldIT = matWorld;\n#elif USE_BATCHING\nmatWorld = cc_matWorlds[int(a_dyn_batch_id)];\nmatWorldIT = matWorld;\n#else\nmatWorld = cc_matWorld;\nmatWorldIT = cc_matWorldIT;\n#endif\nv_worldPos = matWorld * In.position;\nvec4 clipPos = cc_matLightViewProj * v_worldPos;\nv_uv = a_texCoord * tilingOffset.xy + tilingOffset.zw;\n#if HAS_SECOND_UV\nv_uv1 = a_texCoord1 * tilingOffset.xy + tilingOffset.zw;\n#endif\nv_clip_depth = clipPos.z / clipPos.w * 0.5 + 0.5;\nreturn clipPos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nlayout(std140) uniform Constants {\nvec4 tilingOffset;\nvec4 albedo;\nvec4 albedoScaleAndCutoff;\nvec4 pbrParams;\nvec4 emissive;\nvec4 emissiveScaleParam;\n};\nvec4 packDepthToRGBA (float depth) {\nvec4 ret = vec4(1.0, 255.0, 65025.0, 160581375.0) * depth;\nret = fract(ret);\nret -= ret.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\nreturn ret;\n}\nlayout(std140) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\nin vec2 v_uv;\nin vec2 v_uv1;\nin vec4 v_worldPos;\nin float v_clip_depth;\n#if USE_ALBEDO_MAP\nuniform sampler2D albedoMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\nvec4 frag () {\nvec4 baseColor = albedo;\n#if USE_ALBEDO_MAP\nbaseColor *= texture(albedoMap, ALBEDO_UV);\n#endif\n#if USE_ALPHA_TEST\nif (baseColor.ALPHA_TEST_CHANNEL < albedoScaleAndCutoff.w) discard;\n#endif\nif(cc_shadowLPNNInfo.x > 0.000001 && cc_shadowLPNNInfo.x < 1.999999) {\nif (cc_shadowNFLSInfo.z > 0.000001) {\nvec4 viewStartPos = cc_matLightView * v_worldPos;\nfloat dist = length(viewStartPos.xyz);\nfloat linearDepth = cc_shadowNFLSInfo.x + (-dist / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x));\nreturn vec4(linearDepth, 1.0, 1.0, 1.0);\n}\n}\nif (cc_shadowLPNNInfo.y > 0.000001) {\nreturn packDepthToRGBA(v_clip_depth);\n}\nreturn vec4(v_clip_depth, 1.0, 1.0, 1.0);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}],[{vert:"\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nlayout(std140) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nout float v_fog_factor;\nout highp vec4 v_shadowPos;\nlayout(std140) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\n#if CC_RECEIVE_SHADOW\nuniform sampler2D cc_shadowMap;\nuniform sampler2D cc_spotLightingMap;\n#endif\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\nout mediump vec3 v_tangent;\nout 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 vec3 luv;\nout mediump vec3 diffuse;\nlayout(std140) uniform TexCoords {\nvec4 UVScale;\nvec4 lightMapUVParam;\n};\nvoid main () {\nvec3 worldPos;\nworldPos.x = cc_matWorld[3][0] + a_position.x;\nworldPos.y = cc_matWorld[3][1] + a_position.y;\nworldPos.z = cc_matWorld[3][2] + a_position.z;\nvec4 pos = vec4(worldPos, 1.0);\npos = cc_matViewProj * pos;\nuvw = a_texCoord;\nuv0 = a_position.xz * UVScale.x;\nuv1 = a_position.xz * UVScale.y;\nuv2 = a_position.xz * UVScale.z;\nuv3 = a_position.xz * UVScale.w;\n#if USE_LIGHTMAP\nluv.xy = lightMapUVParam.xy + a_texCoord * lightMapUVParam.zw;\nluv.z = lightMapUVParam.z;\n#endif\nv_position = worldPos;\nv_normal = a_normal;\n#if CC_USE_FOG == 0\nv_fog_factor = LinearFog(vec4(worldPos, 1.0));\n#elif CC_USE_FOG == 1\nv_fog_factor = ExpFog(vec4(worldPos, 1.0));\n#elif CC_USE_FOG == 2\nv_fog_factor = ExpSquaredFog(vec4(worldPos, 1.0));\n#elif CC_USE_FOG == 3\nv_fog_factor = LayeredFog(vec4(worldPos, 1.0));\n#else\nv_fog_factor = 1.0;\n#endif\n#if USE_NORMALMAP\nv_tangent = vec3(1.0, 0.0, 0.0);\nv_binormal = vec3(0.0, 0.0, 1.0);\nv_binormal = cross(v_tangent, a_normal);\nv_tangent = cross(a_normal, v_binormal);\n#endif\nv_shadowPos = cc_matLightViewProj * vec4(worldPos, 1.0);\ngl_Position = pos;\n}",frag:"\nprecision highp float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nlayout(std140) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\n#if CC_RECEIVE_SHADOW\nuniform sampler2D cc_shadowMap;\nuniform sampler2D cc_spotLightingMap;\nfloat CCGetLinearDepth (vec3 worldPos) {\nvec4 viewStartPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\nfloat dist = length(viewStartPos.xyz);\nreturn cc_shadowNFLSInfo.x + (-dist / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x));\n}\nfloat CCGetShadowFactorX1 (vec4 shadowPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture(cc_shadowMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n} else {\nclosestDepth = texture(cc_shadowMap, clipPos.xy).x;\n}\nshadow = step(closestDepth, clipPos.z- cc_shadowWHPBInfo.w);\nreturn shadow;\n}\nfloat CCGetShadowFactorX5 (vec4 shadowPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfloat 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n} else {\nfloat closestDepth = texture(cc_shadowMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = texture(cc_shadowMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = texture(cc_shadowMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = texture(cc_shadowMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\nreturn shadow / 5.0;\n}\nfloat CCGetShadowFactorX9 (vec4 shadowPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n} else {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat closestDepth = texture(cc_shadowMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n}\nreturn shadow / 9.0;\n}\nfloat CCGetShadowFactorX25 (vec4 shadowPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfor (int i = -2; i <= 2; i++) {\nfor (int j = -2; j <= 2; j++) {\nfloat 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n} else {\nfor (int i = -2; i <= 2; i++) {\nfor (int j = -2; j <= 2; j++) {\nfloat closestDepth = texture(cc_shadowMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n}\nreturn shadow / 25.0;\n}\nfloat CCGetDirLightShadowFactorX1 (vec4 shadowPos, vec3 worldPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nfloat depth = 0.0;\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture(cc_spotLightingMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n} else {\nclosestDepth = texture(cc_spotLightingMap, clipPos.xy).x;\n}\nshadow = step(closestDepth, depth - cc_shadowWHPBInfo.w);\nreturn shadow;\n}\nfloat CCGetDirLightShadowFactorX5 (vec4 shadowPos, vec3 worldPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfloat 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));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\n} else {\nfloat closestDepth = texture(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = texture(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = texture(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = texture(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\n}\nreturn shadow / 5.0;\n}\nfloat CCGetDirLightShadowFactorX9 (vec4 shadowPos, vec3 worldPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat 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));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\n}\n}\n} else {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat closestDepth = texture(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\n}\n}\n}\nreturn shadow / 9.0;\n}\nfloat CCGetDirLightShadowFactorX25 (vec4 shadowPos, vec3 worldPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat depth = 0.0;\nfloat shadow = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfor (int i = -2; i <= 2; i++) {\nfor (int j = -2; j <= 2; j++) {\nfloat 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n} else {\nfor (int i = -2; i <= 2; i++) {\nfor (int j = -2; j <= 2; j++) {\nfloat closestDepth = texture(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n}\nreturn shadow / 25.0;\n}\n#endif\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\nvec3 unpackRGBE (vec4 rgbe) {\nreturn rgbe.rgb * pow(2.0, rgbe.a * 255.0 - 128.0);\n}\nvec4 fragTextureLod (sampler2D tex, vec2 coord, float lod) {\nreturn textureLod(tex, coord, lod);\n}\nvec4 fragTextureLod (samplerCube tex, vec3 coord, float lod) {\nreturn textureLod(tex, coord, lod);\n}\n#endif\nfloat GGXMobile (float roughness, float NoH, vec3 H, vec3 N) {\nvec3 NxH = cross(N, H);\nfloat OneMinusNoHSqr = dot(NxH, NxH);\nfloat a = roughness * roughness;\nfloat n = NoH * a;\nfloat p = a / (OneMinusNoHSqr + n * n);\nreturn p * p;\n}\nfloat CalcSpecular (float roughness, float NoH, vec3 H, vec3 N) {\nreturn (roughness * 0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox (vec3 specular, float roughness, float NoV) {\nconst vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\nconst vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\nvec4 r = roughness * c0 + c1;\nfloat a004 = min(r.x * r.x, exp2(-9.28 * NoV)) * r.x + r.y;\nvec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;\nAB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\nreturn specular * AB.x + AB.y;\n}\nstruct StandardSurface {\nvec4 albedo;\nvec3 position;\nvec3 normal;\nvec3 emissive;\nvec3 lightmap;\nfloat lightmap_test;\nfloat roughness;\nfloat metallic;\nfloat occlusion;\n};\nvec4 CCStandardShadingBase (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.001);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 L = normalize(-cc_mainLitDir.xyz);\nvec3 H = normalize(L + V);\nfloat NH = max(dot(N, H), 0.0);\nfloat NL = max(dot(N, L), 0.001);\nvec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w;\nvec3 diffuseContrib = diffuse;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nif (s.lightmap_test > 0.0001) {\nfinalColor = s.lightmap.rgb;\n}\n#else\ndiffuseContrib /= 3.14159265359;\n#endif\nvec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\nfinalColor *= (diffuseContrib + specularContrib);\nfloat fAmb = 0.5 - N.y * 0.5;\nvec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb) * cc_ambientSky.w;\nfinalColor += (ambDiff.rgb * diffuse);\n#if CC_USE_IBL\nvec3 R = normalize(reflect(-V, N));\nvec4 envmap = fragTextureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n#if CC_USE_IBL == 2\nvec3 env = unpackRGBE(envmap);\n#else\nvec3 env = SRGBToLinear(envmap.rgb);\n#endif\nfinalColor += env * cc_ambientSky.w * specular;\n#endif\nfinalColor = finalColor * s.occlusion;\n#if CC_USE_HDR\ns.emissive *= cc_exposure.w;\n#endif\nfinalColor += s.emissive;\n#if CC_RECEIVE_SHADOW\n{\nfloat pcf = cc_shadowWHPBInfo.z + 0.001;\nfloat shadowAttenuation = 0.0;\nfloat cosAngle = clamp(1.0 - dot(N, L.xyz), 0.0, 1.0);\nvec3 projWorldPos = shadowPos.xyz + cosAngle * cc_shadowLPNNInfo.z * N;\nvec4 pos = vec4(projWorldPos.xyz, shadowPos.w);\nif (pcf > 3.0) shadowAttenuation = CCGetShadowFactorX25(pos);\nelse if (pcf > 2.0) shadowAttenuation = CCGetShadowFactorX9(pos);\nelse if (pcf > 1.0) shadowAttenuation = CCGetShadowFactorX5(pos);\nelse shadowAttenuation = CCGetShadowFactorX1(pos);\nvec3 shadowColor = cc_shadowColor.rgb * cc_shadowColor.a + finalColor.rgb * (1.0 - cc_shadowColor.a);\nif (cc_shadowNFLSInfo.w > 0.000001) {\nfinalColor.rgb = shadowColor.rgb * shadowAttenuation + finalColor.rgb * (1.0 - shadowAttenuation);\n} else {\nfinalColor.rgb = shadowColor.rgb * shadowAttenuation * NL + finalColor.rgb * (1.0 - shadowAttenuation * NL);\n}\n}\n#endif\nreturn vec4(finalColor, s.albedo.a);\n}\nvec3 ACESToneMap (vec3 color) {\ncolor = min(color, vec3(8.0));\nconst float A = 2.51;\nconst float B = 0.03;\nconst float C = 2.43;\nconst float D = 0.59;\nconst float E = 0.14;\nreturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n#if !CC_USE_HDR\ncolor.rgb = sqrt(ACESToneMap(color.rgb));\n#endif\nreturn color;\n}\nin float v_fog_factor;\nin highp vec4 v_shadowPos;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nin vec3 v_luv;\nuniform sampler2D cc_lightingMap;\nvec3 UnpackLightingmap(vec4 color) {\nvec3 c;\nfloat e = 1.0 + color.a * (8.0 - 1.0);\nc.r = color.r * e;\nc.g = color.g * e;\nc.b = color.b * e;\nreturn c;\n}\n#endif\nin highp vec3 v_position;\nin mediump vec3 v_normal;\n#if USE_NORMALMAP\nin mediump vec3 v_tangent;\nin 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 vec3 luv;\nlayout(std140) uniform PbrParams {\nvec4 metallic;\nvec4 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\nvec4 w = texture(weightMap, uvw);\n#endif\nvec4 baseColor = vec4(0, 0, 0, 0);\n#if LAYERS == 1\nbaseColor = texture(detailMap0, uv0);\n#elif LAYERS == 2\nbaseColor += texture(detailMap0, uv0) * w.r;\nbaseColor += texture(detailMap1, uv1) * w.g;\n#elif LAYERS == 3\nbaseColor += texture(detailMap0, uv0) * w.r;\nbaseColor += texture(detailMap1, uv1) * w.g;\nbaseColor += texture(detailMap2, uv2) * w.b;\n#elif LAYERS == 4\nbaseColor += texture(detailMap0, uv0) * w.r;\nbaseColor += texture(detailMap1, uv1) * w.g;\nbaseColor += texture(detailMap2, uv2) * w.b;\nbaseColor += texture(detailMap3, uv3) * w.a;\n#else\nbaseColor = texture(detailMap0, uv0);\n#endif\ns.position = v_position;\n#if USE_NORMALMAP\nvec4 baseNormal = vec4(0, 0, 0, 0);\n#if LAYERS == 1\nbaseNormal = texture(normalMap0, uv0);\n#elif LAYERS == 2\nbaseNormal += texture(normalMap0, uv0) * w.r;\nbaseNormal += texture(normalMap1, uv1) * w.g;\n#elif LAYERS == 3\nbaseNormal += texture(normalMap0, uv0) * w.r;\nbaseNormal += texture(normalMap1, uv1) * w.g;\nbaseNormal += texture(normalMap2, uv2) * w.b;\n#elif LAYERS == 4\nbaseNormal += texture(normalMap0, uv0) * w.r;\nbaseNormal += texture(normalMap1, uv1) * w.g;\nbaseNormal += texture(normalMap2, uv2) * w.b;\nbaseNormal += texture(normalMap3, uv3) * w.a;\n#else\nbaseNormal = texture(normalMap0, uv0);\n#endif\nvec3 nmmp = baseNormal.xyz - vec3(0.5);\ns.normal =\nnmmp.x * normalize(v_tangent) +\nnmmp.y * normalize(v_binormal) +\nnmmp.z * normalize(v_normal);\n#else\ns.normal = v_normal;\n#endif\ns.albedo = vec4(SRGBToLinear(baseColor.rgb), 1.0);\ns.occlusion = 1.0;\n#if USE_PBR\ns.roughness = 0.0;\n#if LAYERS == 1\ns.roughness = roughness.x;\n#elif LAYERS == 2\ns.roughness += roughness.x * w.r;\ns.roughness += roughness.y * w.g;\n#elif LAYERS == 3\ns.roughness += roughness.x * w.r;\ns.roughness += roughness.y * w.g;\ns.roughness += roughness.z * w.b;\n#elif LAYERS == 4\ns.roughness += roughness.x * w.r;\ns.roughness += roughness.y * w.g;\ns.roughness += roughness.z * w.b;\ns.roughness += roughness.w * w.a;\n#else\ns.roughness = 1.0;\n#endif\ns.metallic = 0.0;\n#if LAYERS == 1\ns.metallic = metallic.x;\n#elif LAYERS == 2\ns.metallic += metallic.x * w.r;\ns.metallic += metallic.y * w.g;\n#elif LAYERS == 3\ns.metallic += metallic.x * w.r;\ns.metallic += metallic.y * w.g;\ns.metallic += metallic.z * w.b;\n#elif LAYERS == 4\ns.metallic += metallic.x * w.r;\ns.metallic += metallic.y * w.g;\ns.metallic += metallic.z * w.b;\ns.metallic += metallic.w * w.a;\n#else\ns.metallic = 0.0;\n#endif\n#else\ns.roughness = 1.0;\ns.metallic = 0.0;\n#endif\ns.emissive = vec3(0.0, 0.0, 0.0);\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nvec4 lightColor = texture(lightMap, luv.xy);\ns.lightmap = UnpackLightingmap(lightColor);\ns.lightmap_test = luv.z;\n#endif\n}\n#if CC_FORWARD_ADD\n#if CC_PIPELINE_TYPE == 0\n# define LIGHTS_PER_PASS 1\n#else\n# define LIGHTS_PER_PASS 10\n#endif\nlayout(std140) uniform CCForwardLight {\nhighp vec4 cc_lightPos[LIGHTS_PER_PASS];\nvec4 cc_lightColor[LIGHTS_PER_PASS];\nvec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS];\nvec4 cc_lightDir[LIGHTS_PER_PASS];\n};\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\nfloat factor = distSqr * invSqrAttRadius;\nfloat smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\nreturn smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\nfloat attenuation = 1.0 / max(distSqr, 0.01*0.01);\nattenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\nreturn attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\nfloat cd = dot(litDir, L);\nfloat attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\nreturn (attenuation * attenuation);\n}\nvec4 CCStandardShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 diffuseContrib = diffuse / 3.14159265359;\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.001);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nint numLights = CC_PIPELINE_TYPE == 0 ? LIGHTS_PER_PASS : int(cc_lightDir[0].w);\nfor (int i = 0; i < LIGHTS_PER_PASS; i++) {\nif (i >= numLights) break;\nvec3 SLU = cc_lightPos[i].xyz - s.position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.001);\nfloat SNH = max(dot(N, SH), 0.0);\nfloat distSqr = dot(SLU, SLU);\nfloat litRadius = cc_lightSizeRangeAngle[i].x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(cc_lightSizeRangeAngle[i].y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (cc_lightPos[i].w > 0.0) {\nfloat cosInner = max(dot(-cc_lightDir[i].xyz, SL), 0.01);\nfloat cosOuter = cc_lightSizeRangeAngle[i].z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -cc_lightDir[i].xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = cc_lightColor[i].rgb;\n#if CC_RECEIVE_SHADOW\nif (cc_lightPos[i].w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z + 0.001;\nfloat shadowAttenuation = 0.0;\nfloat cosAngle = clamp(1.0 - dot(N, normalize(cc_lightPos[i].xyz - s.position.xyz)), 0.0, 1.0);\nvec3 projWorldPos = shadowPos.xyz + cosAngle * cc_shadowLPNNInfo.z * N;\nvec4 pos = vec4(projWorldPos.xyz, shadowPos.w);\nif (pcf > 3.0) shadowAttenuation = CCGetDirLightShadowFactorX25(pos, s.position);\nelse if (pcf > 2.0) shadowAttenuation = CCGetDirLightShadowFactorX9(pos, s.position);\nelse if (pcf > 1.0) shadowAttenuation = CCGetDirLightShadowFactorX5(pos, s.position);\nelse shadowAttenuation = CCGetDirLightShadowFactorX1(pos, s.position);\nlightColor *= 1.0 - shadowAttenuation;\n}\n}\n#endif\nfinalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n}\nfinalColor = finalColor * s.occlusion;\nreturn vec4(finalColor, 0.0);\n}\nlayout(location = 0) out vec4 fragColorX;\nvoid main () {\nStandardSurface s; surf(s);\nvec4 color = CCStandardShadingAdditive(s, v_shadowPos);\ncolor = vec4(mix(CC_FORWARD_ADD > 0 ? vec3(0.0) : cc_fogColor.rgb, color.rgb, v_fog_factor), color.a);\nfragColorX = CCFragOutput(color);\n}\n#elif CC_PIPELINE_TYPE == 0\nlayout(location = 0) out vec4 fragColorX;\nvoid main () {\nStandardSurface s; surf(s);\nvec4 color = CCStandardShadingBase(s, v_shadowPos);\ncolor = vec4(mix(CC_FORWARD_ADD > 0 ? vec3(0.0) : cc_fogColor.rgb, color.rgb, v_fog_factor), color.a);\nfragColorX = CCFragOutput(color);\n}\n#elif CC_PIPELINE_TYPE == 1\nlayout(location = 0) out vec4 fragColor0;\nlayout(location = 1) out vec4 fragColor1;\nlayout(location = 2) out vec4 fragColor2;\nlayout(location = 3) out vec4 fragColor3;\nvoid main () {\nStandardSurface s; surf(s);\nfragColor0 = s.albedo;\nfragColor1 = vec4(s.position, s.roughness);\nfragColor2 = vec4(s.normal, s.metallic);\nfragColor3 = vec4(s.emissive, s.occlusion);\n}\n#endif"},{vert:"\nprecision highp float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nlayout(std140) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\nlayout(std140) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nout vec2 v_clip_depth;\nvec4 vert () {\nvec4 worldPos;\nworldPos.x = cc_matWorld[3][0] + a_position.x;\nworldPos.y = cc_matWorld[3][1] + a_position.y;\nworldPos.z = cc_matWorld[3][2] + a_position.z;\nworldPos.w = 1.0;\nvec4 clipPos = cc_matLightViewProj * worldPos;\nv_clip_depth = clipPos.zw;\nreturn clipPos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nvec4 packDepthToRGBA (float depth) {\nvec4 ret = vec4(1.0, 255.0, 65025.0, 160581375.0) * depth;\nret = fract(ret);\nret -= ret.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\nreturn ret;\n}\nin vec2 v_clip_depth;\nvec4 frag () {\nreturn 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) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nin vec4 a_tangent;\n#if CC_USE_MORPH\nin float a_vertexId;\nint getVertexId() {\nreturn int(a_vertexId);\n}\nlayout(std140) uniform CCMorph {\nvec4 cc_displacementWeights[15];\nvec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\nivec2 texSize = textureSize(tex, 0);\nreturn texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture(tex, x)),\ndecode32(texture(tex, y)),\ndecode32(texture(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nuniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nuniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nuniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nin vec4 a_joints;\nin vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nin highp vec4 a_jointAnimInfo;\n#endif\nlayout(std140) uniform CCSkinningTexture {\nhighp vec4 cc_jointTextureInfo;\n};\nlayout(std140) uniform CCSkinningAnimation {\nhighp vec4 cc_jointAnimInfo;\n};\nuniform highp sampler2D cc_jointTexture;\n#else\nlayout(std140) uniform CCSkinning {\nhighp vec4 cc_joints[30 * 3];\n};\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn 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\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn 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\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn 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 () {\nvec4 joints = vec4(a_joints);\nreturn 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) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\n#if USE_INSTANCING\nin vec4 a_matWorld0;\nin vec4 a_matWorld1;\nin vec4 a_matWorld2;\n#if USE_LIGHTMAP\nin vec4 a_lightingMapUVParam;\n#endif\n#elif USE_BATCHING\nin float a_dyn_batch_id;\nlayout(std140) uniform CCLocalBatched {\nhighp mat4 cc_matWorlds[10];\n};\n#else\nlayout(std140) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\n#endif\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nout float v_fog_factor;\n#if USE_VERTEX_COLOR\nin lowp vec4 a_color;\nout lowp vec4 v_color;\n#endif\n#if USE_TEXTURE\nout vec2 v_uv;\nlayout(std140) uniform TexCoords {\nvec4 tilingOffset;\n};\n#endif\nvec4 vert () {\nvec4 position;\nposition = vec4(a_position, 1.0);\n#if CC_USE_MORPH\napplyMorph(position);\n#endif\n#if CC_USE_SKINNING\nCCSkin(position);\n#endif\nmat4 matWorld;\n#if USE_INSTANCING\nmatWorld = mat4(\nvec4(a_matWorld0.xyz, 0.0),\nvec4(a_matWorld1.xyz, 0.0),\nvec4(a_matWorld2.xyz, 0.0),\nvec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n);\n#elif USE_BATCHING\nmatWorld = cc_matWorlds[int(a_dyn_batch_id)];\n#else\nmatWorld = cc_matWorld;\n#endif\n#if USE_TEXTURE\nv_uv = a_texCoord * tilingOffset.xy + tilingOffset.zw;\n#if SAMPLE_FROM_RT\nv_uv = cc_cameraPos.w > 1.0 ? vec2(v_uv.x, 1.0 - v_uv.y) : v_uv;\n#endif\n#endif\n#if USE_VERTEX_COLOR\nv_color = a_color;\n#endif\n#if CC_USE_FOG == 0\nv_fog_factor = LinearFog(matWorld * position);\n#elif CC_USE_FOG == 1\nv_fog_factor = ExpFog(matWorld * position);\n#elif CC_USE_FOG == 2\nv_fog_factor = ExpSquaredFog(matWorld * position);\n#elif CC_USE_FOG == 3\nv_fog_factor = LayeredFog(matWorld * position);\n#else\nv_fog_factor = 1.0;\n#endif\nreturn cc_matProj * (cc_matView * matWorld) * position;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n#endif\nreturn color;\n}\nin float v_fog_factor;\n#if USE_ALPHA_TEST\n#endif\n#if USE_TEXTURE\nin vec2 v_uv;\nuniform sampler2D mainTexture;\n#endif\nlayout(std140) uniform Constant {\nvec4 mainColor;\nvec4 colorScaleAndCutoff;\n};\n#if USE_VERTEX_COLOR\nin lowp vec4 v_color;\n#endif\nvec4 frag () {\nvec4 o = mainColor;\no.rgb *= colorScaleAndCutoff.xyz;\n#if USE_VERTEX_COLOR\no *= v_color;\n#endif\n#if USE_TEXTURE\no *= texture(mainTexture, v_uv);\n#endif\n#if USE_ALPHA_TEST\nif (o.ALPHA_TEST_CHANNEL < colorScaleAndCutoff.w) discard;\n#endif\no = vec4(mix(CC_FORWARD_ADD > 0 ? vec3(0.0) : cc_fogColor.rgb, o.rgb, v_fog_factor), o.a);\nreturn CCFragOutput(o);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nin vec4 a_tangent;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nout vec2 v_uv;\nvoid main () {\nvec4 position;\nposition = vec4(a_position, 1.0);\nposition.xy = cc_cameraPos.w == 0.0 ? vec2(position.xy.x, -position.xy.y) : position.xy;\ngl_Position = vec4(position.x, position.y, 1.0, 1.0);\nv_uv = a_texCoord;\n}",frag:"\nprecision highp float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nlayout(std140) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\n#if CC_RECEIVE_SHADOW\nuniform sampler2D cc_shadowMap;\nuniform sampler2D cc_spotLightingMap;\nfloat CCGetLinearDepth (vec3 worldPos) {\nvec4 viewStartPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\nfloat dist = length(viewStartPos.xyz);\nreturn cc_shadowNFLSInfo.x + (-dist / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x));\n}\nfloat CCGetShadowFactorX1 (vec4 shadowPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture(cc_shadowMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n} else {\nclosestDepth = texture(cc_shadowMap, clipPos.xy).x;\n}\nshadow = step(closestDepth, clipPos.z- cc_shadowWHPBInfo.w);\nreturn shadow;\n}\nfloat CCGetShadowFactorX5 (vec4 shadowPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfloat 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n} else {\nfloat closestDepth = texture(cc_shadowMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = texture(cc_shadowMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = texture(cc_shadowMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\nclosestDepth = texture(cc_shadowMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\nreturn shadow / 5.0;\n}\nfloat CCGetShadowFactorX9 (vec4 shadowPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n} else {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat closestDepth = texture(cc_shadowMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n}\nreturn shadow / 9.0;\n}\nfloat CCGetShadowFactorX25 (vec4 shadowPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfor (int i = -2; i <= 2; i++) {\nfor (int j = -2; j <= 2; j++) {\nfloat 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n} else {\nfor (int i = -2; i <= 2; i++) {\nfor (int j = -2; j <= 2; j++) {\nfloat closestDepth = texture(cc_shadowMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n}\nreturn shadow / 25.0;\n}\nfloat CCGetDirLightShadowFactorX1 (vec4 shadowPos, vec3 worldPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nfloat depth = 0.0;\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nif (cc_shadowLPNNInfo.y > 0.000001) {\nclosestDepth = dot(texture(cc_spotLightingMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n} else {\nclosestDepth = texture(cc_spotLightingMap, clipPos.xy).x;\n}\nshadow = step(closestDepth, depth - cc_shadowWHPBInfo.w);\nreturn shadow;\n}\nfloat CCGetDirLightShadowFactorX5 (vec4 shadowPos, vec3 worldPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfloat 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));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = 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));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\n} else {\nfloat closestDepth = texture(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = texture(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = texture(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\nclosestDepth = texture(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\n}\nreturn shadow / 5.0;\n}\nfloat CCGetDirLightShadowFactorX9 (vec4 shadowPos, vec3 worldPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat shadow = 0.0;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat 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));\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\n}\n}\n} else {\nfor (int i = -1; i <= 1; i++) {\nfor (int j = -1; j <= 1; j++) {\nfloat closestDepth = texture(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)).x;\nshadow += step(closestDepth, depth - cc_shadowWHPBInfo.w);\n}\n}\n}\nreturn shadow / 9.0;\n}\nfloat CCGetDirLightShadowFactorX25 (vec4 shadowPos, vec3 worldPos) {\nvec3 clipPos = shadowPos.xyz / shadowPos.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\nfloat offsetx = 1.0 / cc_shadowWHPBInfo.x;\nfloat offsety = 1.0 / cc_shadowWHPBInfo.y;\nfloat depth = 0.0;\nfloat shadow = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nfor (int i = -2; i <= 2; i++) {\nfor (int j = -2; j <= 2; j++) {\nfloat 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));\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n} else {\nfor (int i = -2; i <= 2; i++) {\nfor (int j = -2; j <= 2; j++) {\nfloat closestDepth = texture(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)).x;\nshadow += step(closestDepth, clipPos.z - cc_shadowWHPBInfo.w);\n}\n}\n}\nreturn shadow / 25.0;\n}\n#endif\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\nvec3 unpackRGBE (vec4 rgbe) {\nreturn rgbe.rgb * pow(2.0, rgbe.a * 255.0 - 128.0);\n}\nvec4 fragTextureLod (sampler2D tex, vec2 coord, float lod) {\nreturn textureLod(tex, coord, lod);\n}\nvec4 fragTextureLod (samplerCube tex, vec3 coord, float lod) {\nreturn textureLod(tex, coord, lod);\n}\n#endif\nfloat GGXMobile (float roughness, float NoH, vec3 H, vec3 N) {\nvec3 NxH = cross(N, H);\nfloat OneMinusNoHSqr = dot(NxH, NxH);\nfloat a = roughness * roughness;\nfloat n = NoH * a;\nfloat p = a / (OneMinusNoHSqr + n * n);\nreturn p * p;\n}\nfloat CalcSpecular (float roughness, float NoH, vec3 H, vec3 N) {\nreturn (roughness * 0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox (vec3 specular, float roughness, float NoV) {\nconst vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\nconst vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\nvec4 r = roughness * c0 + c1;\nfloat a004 = min(r.x * r.x, exp2(-9.28 * NoV)) * r.x + r.y;\nvec2 AB = vec2(-1.04, 1.04) * a004 + r.zw;\nAB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\nreturn specular * AB.x + AB.y;\n}\nstruct StandardSurface {\nvec4 albedo;\nvec3 position;\nvec3 normal;\nvec3 emissive;\nvec3 lightmap;\nfloat lightmap_test;\nfloat roughness;\nfloat metallic;\nfloat occlusion;\n};\nvec4 CCStandardShadingBase (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.001);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 L = normalize(-cc_mainLitDir.xyz);\nvec3 H = normalize(L + V);\nfloat NH = max(dot(N, H), 0.0);\nfloat NL = max(dot(N, L), 0.001);\nvec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w;\nvec3 diffuseContrib = diffuse;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\nif (s.lightmap_test > 0.0001) {\nfinalColor = s.lightmap.rgb;\n}\n#else\ndiffuseContrib /= 3.14159265359;\n#endif\nvec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\nfinalColor *= (diffuseContrib + specularContrib);\nfloat fAmb = 0.5 - N.y * 0.5;\nvec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb) * cc_ambientSky.w;\nfinalColor += (ambDiff.rgb * diffuse);\n#if CC_USE_IBL\nvec3 R = normalize(reflect(-V, N));\nvec4 envmap = fragTextureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n#if CC_USE_IBL == 2\nvec3 env = unpackRGBE(envmap);\n#else\nvec3 env = SRGBToLinear(envmap.rgb);\n#endif\nfinalColor += env * cc_ambientSky.w * specular;\n#endif\nfinalColor = finalColor * s.occlusion;\n#if CC_USE_HDR\ns.emissive *= cc_exposure.w;\n#endif\nfinalColor += s.emissive;\n#if CC_RECEIVE_SHADOW\n{\nfloat pcf = cc_shadowWHPBInfo.z + 0.001;\nfloat shadowAttenuation = 0.0;\nfloat cosAngle = clamp(1.0 - dot(N, L.xyz), 0.0, 1.0);\nvec3 projWorldPos = shadowPos.xyz + cosAngle * cc_shadowLPNNInfo.z * N;\nvec4 pos = vec4(projWorldPos.xyz, shadowPos.w);\nif (pcf > 3.0) shadowAttenuation = CCGetShadowFactorX25(pos);\nelse if (pcf > 2.0) shadowAttenuation = CCGetShadowFactorX9(pos);\nelse if (pcf > 1.0) shadowAttenuation = CCGetShadowFactorX5(pos);\nelse shadowAttenuation = CCGetShadowFactorX1(pos);\nvec3 shadowColor = cc_shadowColor.rgb * cc_shadowColor.a + finalColor.rgb * (1.0 - cc_shadowColor.a);\nif (cc_shadowNFLSInfo.w > 0.000001) {\nfinalColor.rgb = shadowColor.rgb * shadowAttenuation + finalColor.rgb * (1.0 - shadowAttenuation);\n} else {\nfinalColor.rgb = shadowColor.rgb * shadowAttenuation * NL + finalColor.rgb * (1.0 - shadowAttenuation * NL);\n}\n}\n#endif\nreturn vec4(finalColor, s.albedo.a);\n}\n#if CC_PIPELINE_TYPE == 0\n# define LIGHTS_PER_PASS 1\n#else\n# define LIGHTS_PER_PASS 10\n#endif\nlayout(std140) uniform CCForwardLight {\nhighp vec4 cc_lightPos[LIGHTS_PER_PASS];\nvec4 cc_lightColor[LIGHTS_PER_PASS];\nvec4 cc_lightSizeRangeAngle[LIGHTS_PER_PASS];\nvec4 cc_lightDir[LIGHTS_PER_PASS];\n};\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\nfloat factor = distSqr * invSqrAttRadius;\nfloat smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\nreturn smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\nfloat attenuation = 1.0 / max(distSqr, 0.01*0.01);\nattenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\nreturn attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\nfloat cd = dot(litDir, L);\nfloat attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\nreturn (attenuation * attenuation);\n}\nvec4 CCStandardShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\nvec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\nvec3 diffuseContrib = diffuse / 3.14159265359;\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - s.position);\nfloat NV = max(abs(dot(N, V)), 0.001);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nint numLights = CC_PIPELINE_TYPE == 0 ? LIGHTS_PER_PASS : int(cc_lightDir[0].w);\nfor (int i = 0; i < LIGHTS_PER_PASS; i++) {\nif (i >= numLights) break;\nvec3 SLU = cc_lightPos[i].xyz - s.position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.001);\nfloat SNH = max(dot(N, SH), 0.0);\nfloat distSqr = dot(SLU, SLU);\nfloat litRadius = cc_lightSizeRangeAngle[i].x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(cc_lightSizeRangeAngle[i].y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (cc_lightPos[i].w > 0.0) {\nfloat cosInner = max(dot(-cc_lightDir[i].xyz, SL), 0.01);\nfloat cosOuter = cc_lightSizeRangeAngle[i].z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -cc_lightDir[i].xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = cc_lightColor[i].rgb;\n#if CC_RECEIVE_SHADOW\nif (cc_lightPos[i].w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z + 0.001;\nfloat shadowAttenuation = 0.0;\nfloat cosAngle = clamp(1.0 - dot(N, normalize(cc_lightPos[i].xyz - s.position.xyz)), 0.0, 1.0);\nvec3 projWorldPos = shadowPos.xyz + cosAngle * cc_shadowLPNNInfo.z * N;\nvec4 pos = vec4(projWorldPos.xyz, shadowPos.w);\nif (pcf > 3.0) shadowAttenuation = CCGetDirLightShadowFactorX25(pos, s.position);\nelse if (pcf > 2.0) shadowAttenuation = CCGetDirLightShadowFactorX9(pos, s.position);\nelse if (pcf > 1.0) shadowAttenuation = CCGetDirLightShadowFactorX5(pos, s.position);\nelse shadowAttenuation = CCGetDirLightShadowFactorX1(pos, s.position);\nlightColor *= 1.0 - shadowAttenuation;\n}\n}\n#endif\nfinalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n}\nfinalColor = finalColor * s.occlusion;\nreturn vec4(finalColor, 0.0);\n}\nvec3 ACESToneMap (vec3 color) {\ncolor = min(color, vec3(8.0));\nconst float A = 2.51;\nconst float B = 0.03;\nconst float C = 2.43;\nconst float D = 0.59;\nconst float E = 0.14;\nreturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n#if !CC_USE_HDR\ncolor.rgb = sqrt(ACESToneMap(color.rgb));\n#endif\nreturn color;\n}\nfloat LinearFog(vec4 pos) {\nvec4 wPos = pos;\nfloat cam_dis = distance(cc_cameraPos, wPos);\nfloat fogStart = cc_fogBase.x;\nfloat fogEnd = cc_fogBase.y;\nreturn clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\nfloat f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\nreturn f;\n}\nfloat LayeredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat _FogTop = cc_fogAdd.x;\nfloat _FogRange = cc_fogAdd.y;\nvec3 camWorldProj = cc_cameraPos.xyz;\ncamWorldProj.y = 0.;\nvec3 worldPosProj = wPos.xyz;\nworldPosProj.y = 0.;\nfloat fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\nfloat fDeltaY, fDensityIntegral;\nif (cc_cameraPos.y > _FogTop) {\nif (wPos.y < _FogTop) {\nfDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\nfDensityIntegral = fDeltaY * fDeltaY * 0.5;\n} else {\nfDeltaY = 0.;\nfDensityIntegral = 0.;\n}\n} else {\nif (wPos.y < _FogTop) {\nfloat fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfloat fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\nfDeltaY = abs(fDeltaA - fDeltaB);\nfDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n} else {\nfDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\nfDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n}\n}\nfloat fDensity;\nif (fDeltaY != 0.) {\nfDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n} else {\nfDensity = 0.;\n}\nfloat f = exp(-fDensity);\nreturn f;\n}\nin vec2 v_uv;\nuniform sampler2D cc_gbuffer_albedoMap;\nuniform sampler2D cc_gbuffer_positionMap;\nuniform sampler2D cc_gbuffer_normalMap;\nuniform sampler2D cc_gbuffer_emissiveMap;\nlayout(location = 0) out vec4 fragColor;\nvoid main () {\nStandardSurface s;\nvec4 albedoMap = texture(cc_gbuffer_albedoMap,v_uv);\nvec4 positionMap = texture(cc_gbuffer_positionMap,v_uv);\nvec4 normalMap = texture(cc_gbuffer_normalMap,v_uv);\nvec4 emissiveMap = texture(cc_gbuffer_emissiveMap,v_uv);\ns.albedo = albedoMap;\ns.position = positionMap.xyz;\ns.roughness = positionMap.w;\ns.normal = normalMap.xyz;\ns.metallic = normalMap.w;\ns.emissive = emissiveMap.xyz;\ns.occlusion = emissiveMap.w;\nfloat fogFactor;\n#if CC_USE_FOG == 0\nfogFactor = LinearFog(vec4(s.position, 1));\n#elif CC_USE_FOG == 1\nfogFactor = ExpFog(vec4(s.position, 1));\n#elif CC_USE_FOG == 2\nfogFactor = ExpSquaredFog(vec4(s.position, 1));\n#elif CC_USE_FOG == 3\nfogFactor = LayeredFog(vec4(s.position, 1));\n#else\nfogFactor = 1.0;\n#endif\nvec4 shadowPos;\nshadowPos = cc_matLightViewProj * vec4(s.position, 1);\nvec4 color = CCStandardShadingBase(s, shadowPos) +\nCCStandardShadingAdditive(s, shadowPos);\ncolor = vec4(mix(CC_FORWARD_ADD > 0 ? vec3(0.0) : cc_fogColor.rgb, color.rgb, fogFactor), color.a);\nfragColor = CCFragOutput(color);\n}"}],[{vert:"\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nin vec4 a_tangent;\n#if CC_USE_MORPH\nin float a_vertexId;\nint getVertexId() {\nreturn int(a_vertexId);\n}\nlayout(std140) uniform CCMorph {\nvec4 cc_displacementWeights[15];\nvec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\nivec2 texSize = textureSize(tex, 0);\nreturn texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture(tex, x)),\ndecode32(texture(tex, y)),\ndecode32(texture(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nuniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nuniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nuniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nin vec4 a_joints;\nin vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nin highp vec4 a_jointAnimInfo;\n#endif\nlayout(std140) uniform CCSkinningTexture {\nhighp vec4 cc_jointTextureInfo;\n};\nlayout(std140) uniform CCSkinningAnimation {\nhighp vec4 cc_jointAnimInfo;\n};\nuniform highp sampler2D cc_jointTexture;\n#else\nlayout(std140) uniform CCSkinning {\nhighp vec4 cc_joints[30 * 3];\n};\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn 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\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn 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\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn 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 () {\nvec4 joints = vec4(a_joints);\nreturn 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) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\n#if USE_INSTANCING\nin vec4 a_matWorld0;\nin vec4 a_matWorld1;\nin vec4 a_matWorld2;\n#if USE_LIGHTMAP\nin vec4 a_lightingMapUVParam;\n#endif\n#elif USE_BATCHING\nin float a_dyn_batch_id;\nlayout(std140) uniform CCLocalBatched {\nhighp mat4 cc_matWorlds[10];\n};\n#else\nlayout(std140) uniform CCLocal {\nhighp mat4 cc_matWorld;\nhighp mat4 cc_matWorldIT;\nhighp vec4 cc_lightingMapUVParam;\n};\n#endif\nlayout(std140) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\nvec4 vert () {\nvec4 position;\nposition = vec4(a_position, 1.0);\n#if CC_USE_MORPH\napplyMorph(position);\n#endif\n#if CC_USE_SKINNING\nCCSkin(position);\n#endif\nmat4 matWorld;\n#if USE_INSTANCING\nmatWorld = mat4(\nvec4(a_matWorld0.xyz, 0.0),\nvec4(a_matWorld1.xyz, 0.0),\nvec4(a_matWorld2.xyz, 0.0),\nvec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n);\n#elif USE_BATCHING\nmatWorld = cc_matWorlds[int(a_dyn_batch_id)];\n#else\nmatWorld = cc_matWorld;\n#endif\nposition = cc_matProj * (cc_matView * cc_matLightPlaneProj * matWorld) * position;\nposition.z -= 0.0001;\nreturn position;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision mediump float;\nlayout(std140) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nlowp vec4 cc_shadowNFLSInfo;\nlowp vec4 cc_shadowWHPBInfo;\nlowp vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\n};\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n#endif\nreturn color;\n}\nvec4 frag () {\nreturn CCFragOutput(cc_shadowColor);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\nrgba = rgba * 255.0;\nhighp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\nhighp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\nhighp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\nreturn Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nin vec4 a_tangent;\n#if CC_USE_MORPH\nin float a_vertexId;\nint getVertexId() {\nreturn int(a_vertexId);\n}\nlayout(std140) uniform CCMorph {\nvec4 cc_displacementWeights[15];\nvec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\nfloat pixelIndexF = float(pixelIndex);\nfloat x = mod(pixelIndexF, textureResolution.x);\nfloat y = floor(pixelIndexF / textureResolution.x);\nreturn vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\nreturn (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\nivec2 texSize = textureSize(tex, 0);\nreturn texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n}\n#else\nvec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\nint pixelIndex = elementIndex * 4;\nvec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\nvec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\nvec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\nreturn vec4(\ndecode32(texture(tex, x)),\ndecode32(texture(tex, y)),\ndecode32(texture(tex, z)),\n1.0\n);\n}\n#endif\nfloat getDisplacementWeight(int index) {\nint quot = index / 4;\nint remainder = index - quot * 4;\nif (remainder == 0) {\nreturn cc_displacementWeights[quot].x;\n} else if (remainder == 1) {\nreturn cc_displacementWeights[quot].y;\n} else if (remainder == 2) {\nreturn cc_displacementWeights[quot].z;\n} else {\nreturn cc_displacementWeights[quot].w;\n}\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\nreturn fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\nvec3 result = vec3(0, 0, 0);\nint nVertices = int(cc_displacementTextureInfo.z);\nfor (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\nresult += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n}\nreturn result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\nuniform sampler2D cc_PositionDisplacements;\nvec3 getPositionDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nuniform sampler2D cc_NormalDisplacements;\nvec3 getNormalDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n}\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nuniform sampler2D cc_TangentDisplacements;\nvec3 getTangentDisplacement(int vertexId) {\nreturn getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n}\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\nint vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\nattr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\nattr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\nattr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\nposition.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\nin vec4 a_joints;\nin vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n#if USE_INSTANCING\nin highp vec4 a_jointAnimInfo;\n#endif\nlayout(std140) uniform CCSkinningTexture {\nhighp vec4 cc_jointTextureInfo;\n};\nlayout(std140) uniform CCSkinningAnimation {\nhighp vec4 cc_jointAnimInfo;\n};\nuniform highp sampler2D cc_jointTexture;\n#else\nlayout(std140) uniform CCSkinning {\nhighp vec4 cc_joints[30 * 3];\n};\n#endif\n#if CC_USE_BAKED_ANIMATION\n#if CC_DEVICE_SUPPORT_FLOAT_TEXTURE\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\nvec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\nvec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\nreturn 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\nmat4 getJointMatrix (float i) {\n#if USE_INSTANCING\nhighp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n#else\nhighp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n#endif\nhighp float invSize = cc_jointTextureInfo.w;\nhighp float y = floor(j * invSize);\nhighp float x = floor(j - y * cc_jointTextureInfo.x);\ny = (y + 0.5) * invSize;\nvec4 v1 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n);\nvec4 v2 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n);\nvec4 v3 = vec4(\ndecode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\ndecode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n);\nreturn 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\nmat4 getJointMatrix (float i) {\nint idx = int(i);\nvec4 v1 = cc_joints[idx * 3];\nvec4 v2 = cc_joints[idx * 3 + 1];\nvec4 v3 = cc_joints[idx * 3 + 2];\nreturn 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 () {\nvec4 joints = vec4(a_joints);\nreturn 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) {\nmat4 m = skinMatrix();\nposition = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\nmat4 m = skinMatrix();\nattr.position = m * attr.position;\nattr.normal = (m * vec4(attr.normal, 0.0)).xyz;\nattr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nout vec2 v_uv;\nvoid main () {\nStandardVertInput In;\nIn.position = vec4(a_position, 1.0);\nIn.normal = a_normal;\nIn.tangent = a_tangent;\n#if CC_USE_MORPH\napplyMorph(In);\n#endif\n#if CC_USE_SKINNING\nCCSkin(In);\n#endif\nIn.position.xy = cc_cameraPos.w == 0.0 ? vec2(In.position.xy.x, -In.position.xy.y) : In.position.xy;\ngl_Position = In.position;\ngl_Position.y = gl_Position.y;\nv_uv = a_texCoord;\n}",frag:"\nprecision highp float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nin vec2 v_uv;\nuniform sampler2D cc_lighting_resultMap;\nlayout(location = 0) out vec4 fragColor;\nvoid texcoords(vec2 fragCoord, vec2 resolution,\nout vec2 v_rgbNW, out vec2 v_rgbNE,\nout vec2 v_rgbSW, out vec2 v_rgbSE,\nout vec2 v_rgbM) {\nvec2 inverseVP = 1.0 / resolution.xy;\nv_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;\nv_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;\nv_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;\nv_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;\nv_rgbM = vec2(fragCoord * inverseVP);\n}\nvec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 resolution,\nvec2 v_rgbNW, vec2 v_rgbNE,\nvec2 v_rgbSW, vec2 v_rgbSE,\nvec2 v_rgbM) {\nvec4 color;\nmediump vec2 inverseVP = vec2(1.0 / resolution.x, 1.0 / resolution.y);\nvec3 rgbNW = texture(tex, v_rgbNW).xyz;\nvec3 rgbNE = texture(tex, v_rgbNE).xyz;\nvec3 rgbSW = texture(tex, v_rgbSW).xyz;\nvec3 rgbSE = texture(tex, v_rgbSE).xyz;\nvec4 texColor = texture(tex, v_rgbM);\nvec3 rgbM = texColor.xyz;\nvec3 luma = vec3(0.299, 0.587, 0.114);\nfloat lumaNW = dot(rgbNW, luma);\nfloat lumaNE = dot(rgbNE, luma);\nfloat lumaSW = dot(rgbSW, luma);\nfloat lumaSE = dot(rgbSE, luma);\nfloat lumaM = dot(rgbM, luma);\nfloat lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\nfloat lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\nmediump vec2 dir;\ndir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\ndir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\nfloat dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *\n(0.25 * (1.0 / 8.0)), (1.0/ 128.0));\nfloat rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\ndir = min(vec2(8.0, 8.0),\nmax(vec2(-8.0, -8.0),\ndir * rcpDirMin)) * inverseVP;\nvec3 rgbA = 0.5 * (\ntexture(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +\ntexture(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);\nvec3 rgbB = rgbA * 0.5 + 0.25 * (\ntexture(tex, fragCoord * inverseVP + dir * -0.5).xyz +\ntexture(tex, fragCoord * inverseVP + dir * 0.5).xyz);\nfloat lumaB = dot(rgbB, luma);\nif ((lumaB < lumaMin) || (lumaB > lumaMax))\ncolor = vec4(rgbA, texColor.a);\nelse\ncolor = vec4(rgbB, texColor.a);\nreturn color;\n}\nvoid main () {\nmediump vec2 v_rgbNW;\nmediump vec2 v_rgbNE;\nmediump vec2 v_rgbSW;\nmediump vec2 v_rgbSE;\nmediump vec2 v_rgbM;\nvec2 resolution = cc_screenSize.xy;\nvec2 fragCoord = v_uv * resolution;\ntexcoords(fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\nfragColor = fxaa(cc_lighting_resultMap, fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n}"}],[{vert:"\nprecision highp float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nstruct StandardVertInput {\nhighp vec4 position;\nvec3 normal;\nvec4 tangent;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nin vec4 a_tangent;\nout mediump vec4 viewDir;\nvec4 vert () {\nviewDir = vec4(a_position, 1.0);\nmat4 matViewRotOnly = mat4(mat3(cc_matView));\nmat4 matProj = cc_matProj;\nif (matProj[3].w > 0.0) {\nvec2 scale = vec2(48.0, 24.0);\nmatProj[0].xy *= scale;\nmatProj[1].xy *= scale;\nmatProj[2].zw = vec2(-1.0);\nmatProj[3].zw = vec2(0.0);\n}\nvec4 pos = matProj * matViewRotOnly * viewDir;\npos.z = 0.99999 * pos.w;\nreturn pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nuniform samplerCube cc_environment;\nvec3 unpackRGBE (vec4 rgbe) {\nreturn rgbe.rgb * pow(2.0, rgbe.a * 255.0 - 128.0);\n}\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nvec3 ACESToneMap (vec3 color) {\ncolor = min(color, vec3(8.0));\nconst float A = 2.51;\nconst float B = 0.03;\nconst float C = 2.43;\nconst float D = 0.59;\nconst float E = 0.14;\nreturn (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n#if !CC_USE_HDR\ncolor.rgb = sqrt(ACESToneMap(color.rgb));\n#endif\nreturn color;\n}\nin mediump vec4 viewDir;\nvec4 frag () {\n#if USE_RGBE_CUBEMAP\nvec3 c = unpackRGBE(texture(cc_environment, viewDir.xyz));\n#else\nvec3 c = SRGBToLinear(texture(cc_environment, viewDir.xyz).rgb);\n#endif\nreturn 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 {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nin vec3 a_position;\nin vec4 a_color;\nout vec2 v_uv;\nlayout(std140) uniform Constants {\nvec4 offset;\n};\nlayout(std140) uniform PerFrameInfo {\nvec4 digits[8 * 10 / 4];\n};\nfloat getComponent(vec4 v, float i) {\nif (i < 1.0) { return v.x; }\nelse if (i < 2.0) { return v.y; }\nelse if (i < 3.0) { return v.z; }\nelse { return v.w; }\n}\nvec4 vert () {\nvec4 position = cc_matViewProj * vec4(a_position, 1.0);\nposition.xy += offset.xy;\nv_uv = a_color.xy;\nif (a_color.z >= 0.0) {\nfloat n = getComponent(digits[int(a_color.z)], a_color.w);\nv_uv += vec2(offset.z * n, 0.0);\n}\nreturn position;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\nhighp vec4 cc_time;\nmediump vec4 cc_screenSize;\nmediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\nhighp mat4 cc_matView;\nhighp mat4 cc_matViewInv;\nhighp mat4 cc_matProj;\nhighp mat4 cc_matProjInv;\nhighp mat4 cc_matViewProj;\nhighp mat4 cc_matViewProjInv;\nhighp vec4 cc_cameraPos;\nmediump vec4 cc_screenScale;\nmediump vec4 cc_exposure;\nmediump vec4 cc_mainLitDir;\nmediump vec4 cc_mainLitColor;\nmediump vec4 cc_ambientSky;\nmediump vec4 cc_ambientGround;\nmediump vec4 cc_fogColor;\nmediump vec4 cc_fogBase;\nmediump vec4 cc_fogAdd;\n};\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n#endif\nreturn color;\n}\nin vec2 v_uv;\nuniform sampler2D mainTexture;\nvec4 frag () {\nreturn 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;\nout float v_percent;\nlayout(std140) uniform Constant {\nvec4 u_buffer0;\nvec4 u_buffer1;\nmat4 u_projection;\n};\nvec4 vert () {\nvec2 worldPos = a_position * u_buffer1.xy + u_buffer1.zw;\nvec2 clipSpace = worldPos / u_buffer0.xy * 2.0 - 1.0;\nvec4 screenPos = u_projection * vec4(clipSpace, 0.0, 1.0);\nv_uv = a_texCoord;\nv_percent = u_buffer0.z;\nreturn screenPos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision mediump float;\nin vec2 v_uv;\nin float v_percent;\nuniform sampler2D mainTexture;\nvec4 frag () {\nvec4 color = texture(mainTexture, v_uv);\nfloat precent = clamp(v_percent, 0.0, 1.0);\ncolor.xyz *= precent;\nreturn color;\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}]]},um=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,i=document.createElement("canvas"),o=i.getContext("2d"),r=new ed(i),a=i.width=i.height=2;o.fillStyle="#000",o.fillRect(0,0,a,a);var s=new Rp;s._uuid="black-texture",s.image=r,n[s._uuid]=s,o.fillStyle="rgba(0,0,0,0)",o.fillRect(0,0,a,a);var l=new Rp;l._uuid="empty-texture",l.image=r,n[l._uuid]=l;var u=new Np;u._uuid="black-cube-texture",u.setMipFilter(Np.Filter.NEAREST),u.image={front:new ed(i),back:new ed(i),left:new ed(i),right:new ed(i),top:new ed(i),bottom:new ed(i)},n[u._uuid]=u,o.fillStyle="#777",o.fillRect(0,0,a,a);var h=new Rp;h._uuid="grey-texture",h.image=r,n[h._uuid]=h,o.fillStyle="#fff",o.fillRect(0,0,a,a);var _=new Rp;_._uuid="white-texture",_.image=r,n[_._uuid]=_;var f=new Np;f._uuid="white-cube-texture",f.setMipFilter(Np.Filter.NEAREST),f.image={front:new ed(i),back:new ed(i),left:new ed(i),right:new ed(i),top:new ed(i),bottom:new ed(i)},n[f._uuid]=f,o.fillStyle="#7f7fff",o.fillRect(0,0,a,a);var d=new Rp;d._uuid="normal-texture",d.image=r,n[d._uuid]=d,i.width=i.height=16,o.fillStyle="#ddd",o.fillRect(0,0,16,16),o.fillStyle="#555",o.fillRect(0,0,8,8),o.fillStyle="#555",o.fillRect(8,8,8,8);var p=new Rp;p._uuid="default-texture",p.image=r,n[p._uuid]=p;var m=new Np;if(m.setMipFilter(Np.Filter.NEAREST),m._uuid="default-cube-texture",m.image={front:new ed(i),back:new ed(i),left:new ed(i),right:new ed(i),top:new ed(i),bottom:new ed(i)},n[m._uuid]=m,c.SpriteFrame){var v=new c.SpriteFrame,g=r._texture;v.texture=g,v._uuid="default-spriteframe",n[v._uuid]=v}var y=om(e);if(!y)return Promise.reject(Error("Failed to initialize builtin shaders: unknown device."));var x=lm[y];return x?Promise.resolve().then((function(){Fp.forEach((function(e,t){var n=Object.assign(new c.EffectAsset,e);n.shaders.forEach((function(e,n){var i=x[t][n];i&&(e[y]=i)})),n.hideInEditor=!0,n.onLoaded()})),t._initMaterials()})):Promise.reject(Error("Current device is requiring builtin shaders of version "+y+" 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 c.Material;n._uuid="standard-material",n.initialize({effectName:"standard"}),e[n._uuid]=n,t.push(n);var i=new c.Material;i._uuid="missing-effect-material",i.initialize({effectName:"unlit",defines:{USE_COLOR:!0}}),i.setProperty("mainColor",c.color("#ffff00")),e[i._uuid]=i,t.push(i);var o=new c.Material;o._uuid="missing-material",o.initialize({effectName:"unlit",defines:{USE_COLOR:!0}}),o.setProperty("mainColor",c.color("#ff00ff")),e[o._uuid]=o,t.push(o);var r=new c.Material;r._uuid="default-clear-stencil",r.initialize({defines:{USE_TEXTURE:!1},effectName:"clear-stencil"}),e[r._uuid]=r,t.push(r);var a=new c.Material;a._uuid="ui-base-material",a.initialize({defines:{USE_TEXTURE:!1},effectName:"sprite"}),e[a._uuid]=a,t.push(a);var s=new c.Material;s._uuid="ui-sprite-material",s.initialize({defines:{USE_TEXTURE:!0,CC_USE_EMBEDDED_ALPHA:!1,IS_GRAY:!1},effectName:"sprite"}),e[s._uuid]=s,t.push(s);var l=new c.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 c.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 c.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 c.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 c.Material;f._uuid="ui-graphics-material",f.initialize({effectName:"graphics"}),e[f._uuid]=f,t.push(f);var d=new c.Material;d._uuid="default-particle-material",d.initialize({effectName:"particle"}),e[d._uuid]=d,t.push(d);var p=new c.Material;p._uuid="default-particle-gpu-material",p.initialize({effectName:"particle-gpu"}),e[p._uuid]=p,t.push(p);var m=new c.Material;m._uuid="default-trail-material",m.initialize({effectName:"particle-trail"}),e[m._uuid]=m,t.push(m);var v=new c.Material;v._uuid="default-billboard-material",v.initialize({effectName:"billboard"}),e[v._uuid]=v,t.push(v);var g=new c.Material;g._uuid="default-spine-material",g.initialize({defines:{USE_TEXTURE:!0,CC_USE_EMBEDDED_ALPHA:!1,IS_GRAY:!1},effectName:"spine"}),e[g._uuid]=g,t.push(g);var y=new c.Material;y._uuid="builtin-deferred-material",y.initialize({effectName:"deferred-lighting"}),e[y._uuid]=y,t.push(y);var x=new c.Material;x._uuid="builtin-post-process-material",x.initialize({effectName:"post-process"}),e[x._uuid]=x,t.push(x),c.game.on(c.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}(),hm=e("c2",c.builtinResMgr=new um),_m=e("fI",(am=new Map,sm=0,function(e){return"number"==typeof e?e:(am.has(e)||(am.set(e,1<<sm),sm++),am.get(e))})),fm=new Ps(La.UNIFORM|La.TRANSFER_DST,Ba.HOST|Ba.DEVICE),dm=new bs(null),pm=new ic(null);!function(e){e[e.INSTANCING=1]="INSTANCING",e[e.VB_MERGING=2]="VB_MERGING"}(cm||(cm={}));var mm=e("dp",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=bo,this._handle=bo,this._bs=new Bc,this._dss=new Fc,this._rs=new Lc,this._root=e,this._device=e.device}e.fillPipelineInfo=function(e,t){var n=e.handle;void 0!==t.priority&&qo.set(n,Po.PRIORITY,t.priority),void 0!==t.primitive&&qo.set(n,Po.PRIMITIVE,t.primitive),void 0!==t.stage&&qo.set(n,Po.STAGE,t.stage),void 0!==t.dynamicStates&&qo.set(n,Po.DYNAMIC_STATES,t.dynamicStates),void 0!==t.phase&&qo.set(n,Po.PHASE,_m(t.phase));var i=e._bs;if(t.blendState){var o=t.blendState,r=o.targets;r&&r.forEach((function(e,t){i.setTarget(t,e)})),void 0!==o.isA2C&&(i.isA2C=o.isA2C),void 0!==o.isIndepend&&(i.isIndepend=o.isIndepend),void 0!==o.blendColor&&(i.blendColor=o.blendColor)}e._rs.assign(t.rasterizerState),e._dss.assign(t.depthStencilState)},e.getPassHash=function(e,t){var n,i=e.handle,o=t+","+qo.get(i,Po.PRIMITIVE)+","+qo.get(i,Po.DYNAMIC_STATES);return o+=function(e){for(var t,n=",bs,"+e.isA2C,i=le(e.targets);!(t=i()).done;){var o=t.value;n+=",bt,"+o.blend+","+o.blendEq+","+o.blendAlphaEq+","+o.blendColorMask,n+=","+o.blendSrc+","+o.blendDst+","+o.blendSrcAlpha+","+o.blendDstAlpha}return n}(e._bs),o+=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),Rc(o+=",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=Ma.UNKNOWN);var i=this._propertyHandleMap[e];return i?(n?i=qp(i,n):t&&(i=qp(i,kp(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),o=e.getTypeFromHandle(t),r=e.getOffsetFromHandle(t),a=this._blocks[i];Xp[o](a,n,r),this._rootBufferDirty=!0},t.getUniform=function(t,n){var i=e.getBindingFromHandle(t),o=e.getTypeFromHandle(t),r=e.getOffsetFromHandle(t),a=this._blocks[i];return Yp[o](a,n,r)},t.setUniformArray=function(t,n){for(var i=e.getBindingFromHandle(t),o=e.getTypeFromHandle(t),r=Ec(o)>>2,a=this._blocks[i],s=e.getOffsetFromHandle(t),c=0;c<n.length;c++,s+=r)null!==n[c]&&Xp[o](a,n[c],s);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&&(No.free(qo.get(this._handle,Po.DESCRIPTOR_SET)),qo.free(this._handle),this._handle=bo)},t.resetUniform=function(t){var n=this.getHandle(t);if(n){var i=e.getTypeFromHandle(n),o=e.getBindingFromHandle(n),r=e.getOffsetFromHandle(n),a=this._blocks[o],s=this._properties[t],c=s&&s.value||Qp(i);Xp[i](a,c,r),this._rootBufferDirty=!0}},t.resetTexture=function(t,n){var i=this.getHandle(t);if(i){var o=e.getTypeFromHandle(i),r=e.getBindingFromHandle(i),a=this._properties[t],s=a&&a.value,c=s?s+"-texture":Qp(o),l=hm.get(c),u=l&&l.getGFXTexture(),h=a&&void 0!==a.samplerHash?a.samplerHash:l&&l.getSamplerHash(),_=yd.getSampler(this._device,h);this._descriptorSet.bindSampler(r,_,n),this._descriptorSet.bindTexture(r,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,o=0;o<t.members.length;o++){for(var r=t.members[o],a=this._properties[r.name],s=a&&a.value||Qp(r.type),c=(Ec(r.type)>>2)*r.count,l=0;l+s.length<=c;l+=s.length)n.set(s,i+l);i+=c}this._rootBufferDirty=!0},t.resetTextures=function(){for(var e=0;e<this._shaderInfo.samplerTextures.length;e++)for(var t=this._shaderInfo.samplerTextures[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=rm.getGFXShader(this._device,this._programName,this._defines,t),this._hShaderDefault?(qo.set(this._handle,Po.PIPELINE_LAYOUT,rm.getTemplateInfo(this._programName).hPipelineLayout),qo.set(this._handle,Po.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"),bo;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 o=rm.getGFXShader(this._device,this._programName,this._defines,t),r=0;r<e.length;r++){var a=e[r];delete this._defines[a.name]}return o},t.beginChangeStatesSilently=function(){},t.endChangeStatesSilently=function(){},t._doInit=function(t,n){void 0===n&&(n=!1);var i=this._handle=qo.alloc();qo.set(i,Po.PRIORITY,Wu.DEFAULT),qo.set(i,Po.STAGE,ku.DEFAULT),qo.set(i,Po.PHASE,_m("default")),qo.set(i,Po.PRIMITIVE,ts.TRIANGLE_LIST),qo.set(i,Po.RASTERIZER_STATE,this._rs.handle),qo.set(i,Po.DEPTH_STENCIL_STATE,this._dss.handle),qo.set(i,Po.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?ne({},t.defines):t.defines,this._shaderInfo=rm.getTemplate(t.program),this._properties=t.properties||this._properties;var o=this._device;e.fillPipelineInfo(this,t),t.stateOverrides&&e.fillPipelineInfo(this,t.stateOverrides),pm.layout=rm.getDescriptorSetLayout(this._device,t.program);var r=No.alloc(this._device,pm);qo.set(this._handle,Po.DESCRIPTOR_SET,r),this._descriptorSet=No.get(r);for(var a=this._shaderInfo.blocks,s=rm.getTemplateInfo(t.program),c=s.blockSizes,l=s.handleMap,u=o.capabilities.uboOffsetAlignment,h=[],_=0,f=0,d=0;d<a.length;d++){var p=c[d];h.push(f),f+=Math.ceil(p/u)*u,_=p}var m=h[h.length-1]+_;m&&(fm.size=16*Math.ceil(m/16),this._rootBuffer=o.createBuffer(fm),this._rootBlock=new ArrayBuffer(m));for(var v=0,g=0;v<a.length;v++){var y=a[v].binding,x=c[v];dm.buffer=this._rootBuffer,dm.offset=h[g++],dm.range=16*Math.ceil(x/16);var E=this._buffers[y]=o.createBuffer(dm);this._blocks[y]=new Float32Array(this._rootBlock,dm.offset,x/Float32Array.BYTES_PER_ELEMENT),this._descriptorSet.bindBuffer(y,E)}var S=this._propertyHandleMap=l,T={};for(var A in this._properties){var w=this._properties[A];w.handleInfo&&(T[A]=this.getHandle.apply(this,w.handleInfo))}Object.assign(S,T)},t._syncBatchingScheme=function(){this._defines.USE_INSTANCING?this._device.hasFeature(Na.INSTANCED_ARRAYS)?qo.set(this._handle,Po.BATCHING_SCHEME,cm.INSTANCING):(this._defines.USE_INSTANCING=!1,qo.set(this._handle,Po.BATCHING_SCHEME,0)):this._defines.USE_BATCHING?qo.set(this._handle,Po.BATCHING_SCHEME,cm.VB_MERGING):qo.set(this._handle,Po.BATCHING_SCHEME,0)},t._destroyHandle=function(){this._handle&&(qo.free(this._handle),this._handle=bo)},t._initPassFromTarget=function(e,t,n,i){qo.set(this.handle,Po.PRIORITY,e.priority),qo.set(this.handle,Po.STAGE,e.stage),qo.set(this.handle,Po.PHASE,e.phase),qo.set(this.handle,Po.BATCHING_SCHEME,e.batchingScheme),qo.set(this.handle,Po.PRIMITIVE,e.primitive),qo.set(this.handle,Po.DYNAMIC_STATES,e.dynamicStates),this._descriptorSet=e.descriptorSet,qo.set(this.handle,Po.DESCRIPTOR_SET,qo.get(e.handle,Po.DESCRIPTOR_SET)),this._bs=n,qo.set(this.handle,Po.BLEND_STATE,n.handle),this._rs=e.rasterizerState,qo.set(this.handle,Po.RASTERIZER_STATE,qo.get(e.handle,Po.RASTERIZER_STATE)),this._dss=t,qo.set(this.handle,Po.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,qo.set(this._handle,Po.PIPELINE_LAYOUT,rm.getTemplateInfo(this._programName).hPipelineLayout);var o=qo.get(e.handle,Po.HASH);qo.set(this._handle,Po.HASH,o^i)},te(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 rm.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 qo.get(this._handle,Po.PRIORITY)}},{key:"primitive",get:function(){return qo.get(this._handle,Po.PRIMITIVE)}},{key:"stage",get:function(){return qo.get(this._handle,Po.STAGE)}},{key:"phase",get:function(){return qo.get(this._handle,Po.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 qo.get(this._handle,Po.DYNAMIC_STATES)}},{key:"batchingScheme",get:function(){return qo.get(this._handle,Po.BATCHING_SCHEME)}},{key:"descriptorSet",get:function(){return this._descriptorSet}},{key:"hash",get:function(){return qo.get(this._handle,Po.HASH)}},{key:"rootBufferDirty",get:function(){return this._rootBufferDirty}}]),e}());mm.PropertyType=Lp,mm.getPropertyTypeFromHandle=Vp,mm.getTypeFromHandle=kp,mm.getBindingFromHandle=Wp,mm.getOffsetFromHandle=jp,Y(C_.prototype,"RenderScene.prototype",[{name:"raycastUI2DNode"},{name:"raycastUINode"}]),Y(C_.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 vm={};Y(vm,"CameraVisFlags",[{name:"GENERAL"}]),q(vm,"CameraVisFlags",[{name:"PROFILER",newName:"PROFILER",target:Vu.BitMask,targetName:"PROFILER"},{name:"GIZMOS",newName:"GIZMOS",target:Vu.BitMask,targetName:"GIZMOS"},{name:"EDITOR",newName:"EDITOR",target:Vu.BitMask,targetName:"EDITOR"},{name:"UI",newName:"UI",target:Vu.BitMask,targetName:"UI_3D"},{name:"UI2D",newName:"UI2D",target:Vu.BitMask,targetName:"UI_2D"}]),c.CameraVisFlags=vm;var gm,ym={};function xm(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),o=(.317398726+422806245e-13*t+4.20481691e-8*n)/(1-289741816e-13*t+1.61456053e-7*n),r=2*i-8*o+4,a=3*i/r,s=2*o/r,c=1/s*a,l=1/s*(1-a-s);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}Y(ym,"VisibilityFlags",[{name:"GENERAL"}]),q(ym,"VisibilityFlags",[{name:"ALWALS",newName:"ALWALS",target:Vu.Enum,targetName:"ALWALS"},{name:"PROFILER",newName:"PROFILER",target:Vu.Enum,targetName:"PROFILER"},{name:"GIZMOS",newName:"GIZMOS",target:Vu.Enum,targetName:"GIZMOS"},{name:"EDITOR",newName:"EDITOR",target:Vu.Enum,targetName:"EDITOR"},{name:"UI",newName:"UI",target:Vu.Enum,targetName:"UI_3D"},{name:"UI2D",newName:"UI2D",target:Vu.Enum,targetName:"UI_2D"}]),c.VisibilityFlags=ym,q(mm.prototype,"Pass.prototype",[{name:"getBindingTypeFromHandle",newName:"getDescriptorTypeFromHandle"}]),Y(w_.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"}(gm||(gm=e("cg",{})));var Em=e("cp",(function(e){return 4*Math.PI*Math.PI*e*e})),Sm=e("cj",function(){function e(){this._baked=!1,this._color=new Rn(1,1,1),this._colorTemp=6550,this._colorTempRGB=new Rn(1,1,1),this._scene=null,this._node=null,this._name=null,this._handle=bo}var t=e.prototype;return t.initialize=function(){this._handle=Hr.alloc(),Hr.setVec3(this._handle,Lr.COLOR,this._color),Hr.setVec3(this._handle,Lr.COLOR_TEMPERATURE_RGB,this._colorTempRGB),Hr.set(this._handle,Lr.TYPE,gm.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&&(Hr.free(this._handle),this._handle=bo)},t.update=function(){},te(e,[{key:"baked",get:function(){return this._baked},set:function(e){this._baked=e}},{key:"color",get:function(){return this._color},set:function(e){this._color.set(e),Hr.setVec3(this._handle,Lr.COLOR,e)}},{key:"useColorTemperature",get:function(){return 1===Hr.get(this._handle,Lr.USE_COLOR_TEMPERATURE)},set:function(e){Hr.set(this._handle,Lr.USE_COLOR_TEMPERATURE,e?1:0)}},{key:"colorTemperature",get:function(){return this._colorTemp},set:function(e){this._colorTemp=e,xm(this._colorTempRGB,this._colorTemp),Hr.setVec3(this._handle,Lr.COLOR_TEMPERATURE_RGB,this._colorTempRGB)}},{key:"colorTemperatureRGB",get:function(){return this._colorTempRGB}},{key:"node",get:function(){return this._node},set:function(e){this._node=e,this._node&&(this._node.hasChangedFlags|=m_.ROTATION,Hr.set(this._handle,Lr.NODE,this._node.handle))}},{key:"type",get:function(){return Hr.get(this._handle,Lr.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}()),Tm=new Rn(0,0,-1),Am=new Rn,wm=e("cn",function(e){function t(){var t;return(t=e.call(this)||this)._dir=new Rn(1,-1,-1),t}ie(t,e);var n=t.prototype;return n.initialize=function(){e.prototype.initialize.call(this),Hr.set(this._handle,Lr.ILLUMINANCE,aa.SUN_ILLUM),Hr.setVec3(this._handle,Lr.DIRECTION,this._dir),Hr.set(this._handle,Lr.TYPE,gm.DIRECTIONAL)},n.update=function(){this._node&&this._node.hasChangedFlags&&(this.direction=Rn.transformQuat(Am,Tm,this._node.worldRotation))},te(t,[{key:"direction",get:function(){return this._dir},set:function(e){Rn.normalize(this._dir,e),Hr.setVec3(this._handle,Lr.DIRECTION,this._dir)}},{key:"illuminance",get:function(){return Hr.get(this._handle,Lr.ILLUMINANCE)},set:function(e){Hr.set(this._handle,Lr.ILLUMINANCE,e)}}]),t}(Sm));function Cm(e,t){for(var n,i=le(t);!(n=i()).done;){var o=n.value;Array.isArray(o)?Cm(e,o):e.push(o)}}function Im(e){var t=[];return Cm(t,e),t.join("")}var Pm=hi.Flags.Destroyed,bm=hi.Flags.PersistentMask,Rm=tn.IDENTIFIER_RE,Nm="var ",Om="o",Dm={"cc.ClickEvent":!1,"cc.PrefabInfo":!1},Mm=tn.escapeForJS,Lm=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 Nm+this.varName+"="+this.expression+";"},e}();function Fm(e,t){return t instanceof Lm?new Lm(t.varName,e+t.expression):e+t}function zm(e,t,n){Array.isArray(n)?(n[0]=Fm(t,n[0]),e.push(n)):e.push(Fm(t,n)+";")}var Bm=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];zm(e,t+Um(i[0])+"=",i[1])}},e}();function Um(e){return Rm.test(e)?"."+e:"["+Mm(e)+"]"}Bm.pool=void 0,Bm.pool=new ot((function(e){e._exps.length=0,e._targetExp=null}),1),Bm.pool.get=function(e){var t=this._get()||new Bm;return t._targetExp=e,t};var Hm=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=Re(),Ge(this.funcModuleCache,Dm),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=Nm+this.globalVariables.join(",")+";");var i=Im(["return (function(R){",n||[],this.codeArray,"return o;","})"]);this.result=Function("O","F",i)(this.objs,this.funcs);for(var o=0,r=this.objsToClear_iN$t.length;o<r;++o)this.objsToClear_iN$t[o]._iN$t=null;this.objsToClear_iN$t.length=0}var t=e.prototype;return t.getFuncModule=function(e,t){var n=Ne(e);if(n){var i=this.funcModuleCache[n];if(i)return i;if(void 0===i){var o=-1!==n.indexOf(".");if(o)try{if(o=e===Function("return "+n)())return this.funcModuleCache[n]=n,n}catch(e){}}}var r=this.funcs.indexOf(e);r<0&&(r=this.funcs.length,this.funcs.push(e));var a="F["+r+"]";return t&&(a="("+a+")"),this.funcModuleCache[n]=a,a},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 o=Bm.pool.get(i),r=t.constructor.__props__;r||(r=Object.keys(t));for(var a=0;a<r.length;a++){var s=r[a],c=n[s];if(t[s]!==c){var l=this.enumerateField(n,s,c);o.append(s,l)}}o.writeCode(e),Bm.pool.put(o)},t.enumerateCCClass=function(e,t,n){for(var i=n.__values__,o=Ot(n),r=0;r<i.length;r++){var a=i[r],s=t[a],l=o[a+"$_$default"];if(!Gm(l,s))if("object"==typeof s&&s instanceof c.ValueType&&(l=tn.getDefault(l))&&l.constructor===s.constructor){var u=Om+Um(a);this.setValueType(e,l,s,u)}else this.setObjProp(e,t,a,s)}},t.instantiateArray=function(e){if(0===e.length)return"[]";var t="a"+ ++this.localVariableId,n=[new Lm(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)zm(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 Lm(n,"new "+t+"("+e.length+")")];e._iN$t={globalVar:"",source:i},this.objsToClear_iN$t.push(e);for(var o=0;o<e.length;++o)0!==e[o]&&zm(i,n+"["+o+"]=",e[o]);return i},t.enumerateField=function(e,t,n){if("object"==typeof n&&n){var i=n._iN$t;if(i){var o=i.globalVar;if(!o){o=i.globalVar="v"+ ++this.globalVariableId,this.globalVariables.push(o);var r=i.source[0];i.source[0]=Fm(o+"=",r)}return o}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?Mm(n):("_objFlags"===t&&e instanceof hi&&(n&=bm),n)},t.setObjProp=function(e,t,n,i){zm(e,Om+Um(n)+"=",this.enumerateField(t,n,i))},t.enumerateObject=function(e,t){var n=t.constructor;if(c.Class._isCCClass(n))this.enumerateCCClass(e,t,n);else for(var i in t)if(t.hasOwnProperty(i)&&(95!==i.charCodeAt(0)||95!==i.charCodeAt(1)||"__type__"===i)){var o=t[i];"object"==typeof o&&o&&o===t._iN$t||this.setObjProp(e,t,i,o)}},t.instantiateObj=function(e){if(e instanceof c.ValueType)return tn.getNewValueTypeCode(e);if(e instanceof c.Asset)return this.getObjRef(e);if(e._objFlags&Pm)return null;var t,n=e.constructor;if(c.Class._isCCClass(n)){if(this.parent)if(this.parent instanceof c.Component){if(e instanceof c._BaseNode||e instanceof c.Component)return this.getObjRef(e)}else if(this.parent instanceof c._BaseNode)if(e instanceof c._BaseNode){if(!e.isChildOf(this.parent))return this.getObjRef(e)}else if(e instanceof c.Component&&!e.node.isChildOf(this.parent))return this.getObjRef(e);t=new Lm(Om,"new "+this.getFuncModule(n,!0)+"()")}else if(n===Object)t=new Lm(Om,"{}");else{if(n)return this.getObjRef(e);t=new Lm(Om,"Object.create(null)")}var i=[t];return e._iN$t={globalVar:"",source:i},this.objsToClear_iN$t.push(e),this.enumerateObject(i,e),["(function(){",i,"return o;})();"]},e}();function Gm(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 c.ValueType){if(e.equals(t))return!0}else{if(Array.isArray(e))return 0===e.length&&0===t.length;if(e.constructor===Object)return Ae(e)&&Ae(t)}return!1}var Vm,km=function(){function e(e){this._uiComp=null,this.opacity=1,this.localOpacity=1,this._uiTransformComp=null,this._node=void 0,this._node=e}return te(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?b(12002):this._uiComp=e}}]),e}();!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"}(Vm||(Vm=e("c_",{}))),ht(Vm),c.SystemEventType=Vm;var Wm=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){M(e&&e.event,1900);var t=e.event;delete e.event;var n=null;if(t===c.EventListener.TOUCH_ONE_BY_ONE?n=new Ym:t===c.EventListener.TOUCH_ALL_AT_ONCE?n=new Xm:t===c.EventListener.MOUSE?n=new qm:t===c.EventListener.KEYBOARD?n=new Qm:t===c.EventListener.ACCELERATION&&(n=new Km(e.callback),delete e.callback),n)for(var i=0,o=Object.keys(e);i<o.length;i++){var r=o[i];n[r]=e[r]}return n};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},te(e,[{key:"onEvent",get:function(){return this._onEvent}}]),e}();Wm.UNKNOWN=0,Wm.TOUCH_ONE_BY_ONE=1,Wm.TOUCH_ALL_AT_ONCE=2,Wm.KEYBOARD=3,Wm.MOUSE=4,Wm.ACCELERATION=6,Wm.CUSTOM=8,Wm.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 jm=Wm.ListenerID,qm=function(e){function t(){var t;return(t=e.call(this,Wm.MOUSE,jm.MOUSE,null)||this).onMouseDown=null,t.onMouseUp=null,t.onMouseMove=null,t.onMouseScroll=null,t._onEvent=function(e){return t._callback(e)},t}ie(t,e);var n=t.prototype;return n._callback=function(e){switch(e.eventType){case Vm.MOUSE_DOWN:this.onMouseDown&&this.onMouseDown(e);break;case Vm.MOUSE_UP:this.onMouseUp&&this.onMouseUp(e);break;case Vm.MOUSE_MOVE:this.onMouseMove&&this.onMouseMove(e);break;case Vm.MOUSE_WHEEL: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}(Wm),Ym=function(e){function t(){var t;return(t=e.call(this,Wm.TOUCH_ONE_BY_ONE,jm.TOUCH_ONE_BY_ONE,null)||this).swallowTouches=!1,t.onTouchBegan=null,t.onTouchMoved=null,t.onTouchEnded=null,t.onTouchCancelled=null,t._claimedTouches=[],t}ie(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||(I(1801),!1)},t}(Wm),Xm=function(e){function t(){var t;return(t=e.call(this,Wm.TOUCH_ALL_AT_ONCE,jm.TOUCH_ALL_AT_ONCE,null)||this).onTouchesBegan=null,t.onTouchesMoved=null,t.onTouchesEnded=null,t.onTouchesCancelled=null,t}ie(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||(I(1802),!1)},t}(Wm),Km=function(e){function t(t){var n;return(n=e.call(this,Wm.ACCELERATION,jm.ACCELERATION,null)||this)._onAccelerationEvent=null,n._onEvent=function(e){return n._callback(e)},n._onAccelerationEvent=t,n}ie(t,e);var n=t.prototype;return n._callback=function(e){this._onAccelerationEvent&&this._onAccelerationEvent(e.acc,e)},n.checkAvailable=function(){return M(this._onAccelerationEvent,1803),!0},n.clone=function(){return new t(this._onAccelerationEvent)},t}(Wm),Qm=function(e){function t(){var t;return(t=e.call(this,Wm.KEYBOARD,jm.KEYBOARD,null)||this).onKeyPressed=null,t.onKeyReleased=null,t._onEvent=function(e){return t._callback(e)},t}ie(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||(I(1800),!1)},t}(Wm);c.EventListener=Wm;var Zm=Wm.ListenerID,Jm=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}(),$m=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 c._BaseNode){var n=this._nodeListenersMap[e.uuid];if(n)for(var i=0;i<n.length;++i)n[i]._setPaused(!0);if(!0===t){var o=e.children;if(o)for(var r=0;r<o.length;++r){var a=o[r];this.pauseTarget(a,!0)}}}else b(3506)},t.resumeTarget=function(e,t){if(void 0===t&&(t=!1),e instanceof c._BaseNode){var n=this._nodeListenersMap[e.uuid];if(n)for(var i=0;i<n.length;++i)n[i]._setPaused(!1);if(this._setDirtyForNode(e),!0===t&&e.children.length>0){var o=e.children;if(o)for(var r=0;r<o.length;++r){var a=o[r];this.resumeTarget(a,!0)}}}else b(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 o=0,r=i.length;o<r;o++)this._forceAddEventListener(i[o]);i.length=0}0!==this._toRemovedListeners.length&&this._cleanToRemovedListeners()},t.hasEventListener=function(e){return!!this._getListeners(e)},t.addListener=function(e,t){if(M(e&&t,3503),!(c.js.isNumber(t)||t instanceof c._BaseNode))return b(3506),null;if(e instanceof c.EventListener){if(e._isRegistered())return I(3505),null}else M(!c.js.isNumber(t),3504),e=c.EventListener.create(e);if(!e.checkAvailable())return null;if(c.js.isNumber(t)){if(0===t)return I(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 I(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=Wm.create({event:c.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 i in e===this._currentTouchListener&&(this._currentTouchListener=this._currentTouch=null),n){var o=n[i],r=o.getFixedPriorityListeners(),a=o.getSceneGraphPriorityListeners();if((t=this._removeListenerInVector(a,e))?this._setDirty(e._getListenerID(),2):(t=this._removeListenerInVector(r,e))&&this._setDirty(e._getListenerID(),1),o.empty()&&(delete this._priorityDirtyFlagMap[e._getListenerID()],delete n[i]),t)break}if(!t)for(var s=this._toAddedListeners,l=s.length-1;l>=0;l--){var u=s[l];if(u===e){c.js.array.removeAt(s,l),u._setRegistered(!1);break}}}},t.removeListeners=function(e,t){if(void 0===t&&(t=!1),c.js.isNumber(e)||e instanceof c._BaseNode)if(void 0!==e._id){var n=this._nodeListenersMap[e._id];if(n){for(var i=c.js.array.copy(n),o=0;o<i.length;++o){var r=i[o];this.removeListener(r)}delete this._nodeListenersMap[e._id]}for(var a=this._toAddedListeners,s=0;s<a.length;){var l=a[s];l._getSceneGraphPriority()===e?(l._setSceneGraphPriority(null),l._setRegistered(!1),a.splice(s,1)):++s}if(!0===t)for(var u=e.getChildren(),h=0;h<u.length;++h){var _=u[h];this.removeListeners(_,!0)}}else e===c.EventListener.TOUCH_ONE_BY_ONE?this._removeListenersForListenerID(Zm.TOUCH_ONE_BY_ONE):e===c.EventListener.TOUCH_ALL_AT_ONCE?this._removeListenersForListenerID(Zm.TOUCH_ALL_AT_ONCE):e===c.EventListener.MOUSE?this._removeListenersForListenerID(Zm.MOUSE):e===c.EventListener.ACCELERATION?this._removeListenersForListenerID(Zm.ACCELERATION):e===c.EventListener.KEYBOARD?this._removeListenersForListenerID(Zm.KEYBOARD):I(3501);else b(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 o=n[i].getFixedPriorityListeners();if(o&&-1!==o.indexOf(e))return null!=e._getSceneGraphPriority()&&I(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(c.Event.TOUCH))return this._dispatchTouchEvent(e),void this._inDispatch--;var t=function(e){var t=Vf,n=e.type;return n===t.ACCELERATION?Zm.ACCELERATION:n===t.KEYBOARD?Zm.KEYBOARD:n.startsWith(t.MOUSE)?Zm.MOUSE:(n.startsWith(t.TOUCH)&&I(2e3),"")}(e);this._sortEventListeners(t);var n=this._listenersMap[t];null!=n&&(this._dispatchEventToListeners(n,this._onListenerCallback,e),this._onUpdateListeners(n)),this._inDispatch--}else N(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 c.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 o=t[n]._getListenerID();this._dirtyListeners[o]||(this._dirtyListeners[o]=!0)}if(e.children.length>0)for(var r=e.children,a=0,s=r?r.length:0;a<s;a++)this._setDirtyForNode(r[a])},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 Jm,this._listenersMap[t]=n),n.push(e),0===e._getFixedPriority()){this._setDirty(t,2);var i=e._getSceneGraphPriority();null===i&&I(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&&c.js.array.removeAt(e,n)},t._removeListenersForListenerID=function(e){var t=this._listenersMap[e];if(t){var n=t.getFixedPriorityListeners(),i=t.getSceneGraphPriorityListeners();this._removeAllListenersInVector(i),this._removeAllListenersInVector(n),delete this._priorityDirtyFlagMap[e],this._inDispatch||(t.clear(),delete this._listenersMap[e])}for(var o=this._toAddedListeners,r=o.length-1;r>=0;r--){var a=o[r];a&&a._getListenerID()===e&&c.js.array.removeAt(o,r)}},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&&c.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 o=n,r=i,a=!1;if(e._cameraPriority!==t._cameraPriority)return t._cameraPriority-e._cameraPriority;for(;o.parent._id!==r.parent._id;)o=null===o.parent.parent?(a=!0)&&i:o.parent,r=null===r.parent.parent?(a=!0)&&n:r.parent;if(o._id===r._id){if(o._id===i._id)return-1;if(o._id===n._id)return 1}var s=o.getSiblingIndex(),c=r.getSiblingIndex();return a?s-c:c-s},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,o=n.length;i<o&&!(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(),i=this._toRemovedListeners;if(n)for(var o=n.length-1;o>=0;o--){var r=n[o];if(!r._isRegistered()){c.js.array.removeAt(n,o);var a=i.indexOf(r);-1!==a&&i.splice(a,1)}}if(t)for(var s=t.length-1;s>=0;s--){var l=t[s];if(!l._isRegistered()){c.js.array.removeAt(t,s);var u=i.indexOf(l);-1!==u&&i.splice(u,1)}}n&&0===n.length&&e.clearSceneGraphListeners(),t&&0===t.length&&e.clearFixedListeners()},t._updateTouchListeners=function(){var e=this._inDispatch;if(M(e>0,3508),!(e>1)){var t;(t=this._listenersMap[Zm.TOUCH_ONE_BY_ONE])&&this._onUpdateListeners(t),(t=this._listenersMap[Zm.TOUCH_ALL_AT_ONCE])&&this._onUpdateListeners(t),M(1===e,3509);var n=this._toAddedListeners;if(0!==n.length){for(var i=0,o=n.length;i<o;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 o=i.getFixedPriorityListeners(),r=i.getSceneGraphPriorityListeners();if(r){var a=r.indexOf(n);-1!==a&&r.splice(a,1)}if(o){var s=o.indexOf(n);-1!==s&&o.splice(s,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 o=!1,r=-1,a=n.getEventCode();if(a===Vm.TOUCH_START){if(!ft.ENABLE_MULTI_TOUCH&&ev._currentTouch){var s=ev._currentTouchListener._node;if(!s||s.activeInHierarchy)return!1}e.onTouchBegan&&(o=e.onTouchBegan(i,n))&&e._isRegistered()&&!e._isPaused()&&(e._claimedTouches.push(i),!ft.ENABLE_MULTI_TOUCH&&ev._currentTouch||(ev._currentTouch=i),ev._currentTouchListener=e)}else if(e._claimedTouches.length>0&&-1!==(r=e._claimedTouches.indexOf(i))){if(o=!0,!ft.ENABLE_MULTI_TOUCH&&ev._currentTouch&&ev._currentTouch!==i)return!1;a===Vm.TOUCH_MOVE&&e.onTouchMoved?e.onTouchMoved(i,n):a===Vm.TOUCH_END?(e.onTouchEnded&&e.onTouchEnded(i,n),e._isRegistered()&&e._claimedTouches.splice(r,1),(ft.ENABLE_MULTI_TOUCH||ev._currentTouch===i)&&(ev._currentTouch=null),ev._currentTouchListener=null):a===Vm.TOUCH_CANCEL&&(e.onTouchCancelled&&e.onTouchCancelled(i,n),e._isRegistered()&&e._claimedTouches.splice(r,1),(ft.ENABLE_MULTI_TOUCH||ev._currentTouch===i)&&(ev._currentTouch=null),ev._currentTouchListener=null)}return n.isStopped()?(ev._updateTouchListeners(n),!0):!!(o&&e._isRegistered()&&e.swallowTouches)&&(t.needsMutableSet&&t.touches.splice(i,1),!0)},t._dispatchTouchEvent=function(e){this._sortEventListeners(Zm.TOUCH_ONE_BY_ONE),this._sortEventListeners(Zm.TOUCH_ALL_AT_ONCE);var t=this._getListeners(Zm.TOUCH_ONE_BY_ONE),n=this._getListeners(Zm.TOUCH_ALL_AT_ONCE);if(null!==t||null!==n){var i=e.getTouches(),o=c.js.array.copy(i),r={event:e,needsMutableSet:t&&n,touches:o,selTouch:null};if(t)for(var a=0;a<i.length;++a){var s=i[a];e.touch=s,e.propagationStopped=e.propagationImmediateStopped=!1,this._dispatchEventToListeners(t,this._onTouchEventCallback,r)}n&&o.length>0&&(this._dispatchEventToListeners(n,this._onTouchesEventCallback,{event:e,touches:o}),e.isStopped())||this._updateTouchListeners(e)}},t._onTouchesEventCallback=function(e,t){if(!e._isRegistered())return!1;var n=t.event,i=t.touches,o=n.getEventCode();return n.currentTarget=e._getSceneGraphPriority(),o===Vm.TOUCH_START&&e.onTouchesBegan?e.onTouchesBegan(i,n):o===Vm.TOUCH_MOVE&&e.onTouchesMoved?e.onTouchesMoved(i,n):o===Vm.TOUCH_END&&e.onTouchesEnded?e.onTouchesEnded(i,n):o===Vm.TOUCH_CANCEL&&e.onTouchesCancelled&&e.onTouchesCancelled(i,n),!!n.isStopped()&&(ev._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&&(c.js.array.remove(n,t),0===n.length&&delete this._nodeListenersMap[e.uuid])},t._dispatchEventToListeners=function(e,t,n){var i=!1,o=e.getFixedPriorityListeners(),r=e.getSceneGraphPriorityListeners(),a=0;if(o&&0!==o.length)for(;a<e.gt0Index;++a){var s=o[a];if(s.isEnabled()&&!s._isPaused()&&s._isRegistered()&&t(s,n)){i=!0;break}}if(r&&!i)for(var c=0;c<r.length;++c){var l=r[c];if(l.isEnabled()&&!l._isPaused()&&l._isRegistered()&&t(l,n)){i=!0;break}}if(o&&!i)for(;a<o.length;++a){var u=o[a];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 i=e[n];if(i._onCustomEvent===t||i.onEvent===t)return i._setRegistered(!1),null!=i._getSceneGraphPriority()&&(this._dissociateNodeAndEventListener(i._getSceneGraphPriority(),i),i._setSceneGraphPriority(null)),0===this._inDispatch?c.js.array.removeAt(e,n):this._toRemovedListeners.push(i),!0}return!1},t._removeListenerInVector=function(e,t){if(null==e)return!1;for(var n=e.length-1;n>=0;n--){var i=e[n];if(i===t)return i._setRegistered(!1),null!=i._getSceneGraphPriority()&&(this._dissociateNodeAndEventListener(i._getSceneGraphPriority(),i),i._setSceneGraphPriority(null)),0===this._inDispatch?c.js.array.removeAt(e,n):this._toRemovedListeners.push(i),!0}return!1},e}(),ev=e("fj",new $m);c.eventManager=ev,hi.Flags.Destroying;var tv,nv,iv,ov,rv,av,sv,cv,lv,uv=hi.Flags.Destroying,hv=hi.Flags.DontDestroy,_v=hi.Flags.Deactivating,fv=new ge("Node");function dv(e){return e?"string"==typeof e?nt(e):e:(N(3804),null)}var pv,mv,vv,gv,yv,xv,Ev,Sv,Tv,Av,wv,Cv=e("fP",L_("cc.BaseNode")((lv=cv=function(e){ie(n,e),n._setScene=function(e){e._updateScene()},n._findComponent=function(e,t){var n=t,i=e._components;if(n._sealed)for(var o=0;o<i.length;++o){var r=i[o];if(r.constructor===t)return r}else for(var a=0;a<i.length;++a){var s=i[a];if(s instanceof t)return s}return null},n._findComponents=function(e,t,n){var i=t,o=e._components;if(i._sealed)for(var r=0;r<o.length;++r){var a=o[r];a.constructor===t&&n.push(a)}else for(var s=0;s<o.length;++s){var c=o[s];c instanceof t&&n.push(c)}},n._findChildComponent=function(e,t){for(var i=0;i<e.length;++i){var o=e[i],r=n._findComponent(o,t);if(r)return r;if(o._children.length>0&&(r=n._findChildComponent(o._children,t)))return r}return null},n._findChildComponents=function(e,t,i){for(var o=0;o<e.length;++o){var r=e[o];n._findComponents(r,t,i),r._children.length>0&&n._findChildComponents(r._children,t,i)}};var t=n.prototype;function n(t){var n;return ue(n=e.call(this,t)||this,"_parent",iv,se(n)),ue(n,"_children",ov,se(n)),ue(n,"_active",rv,se(n)),ue(n,"_components",av,se(n)),ue(n,"_prefab",sv,se(n)),n._scene=null,n._activeInHierarchy=!1,n._id=fv.getNewId(),n._name=void 0,n._eventProcessor=new c.NodeEventProcessor(se(n)),n._eventMask=0,n._siblingIndex=0,n._originalSceneId="",n._registerIfAttached=void 0,n._name=void 0!==t?t:"New Node",n}return t._updateScene=function(){null==this._parent?x("Node %s(%s) has not attached to a scene.",this.name,this.uuid):this._scene=this._parent._scene},t.attr=function(e){Ge(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(Vm.PARENT_CHANGED,n),n&&!(n._objFlags&uv)){var o=n._children.indexOf(this);n._children.splice(o,1),n._updateSiblingIndex(),n.emit&&n.emit(Vm.CHILD_REMOVED,this)}i&&(i._children.push(this),this._siblingIndex=i._children.length-1,i.emit&&i.emit(Vm.CHILD_ADDED,this)),this._onHierarchyChanged(n)}},t.getChildByUuid=function(e){if(!e)return g("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 g("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 o=n.children.find((function(e){return e.name===i}));if(!o)return{v:null};n=o},o=0;o<t.length;++o){var r=i(o);if("continue"!==r&&"object"==typeof r)return r.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&_v)N(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,o=null,r=null,a=0,s=n._stacks[n._stackId];s||(s=[],n._stacks.push(s)),n._stackId++,s.length=0,s[0]=this;for(var c=null,l=!1;i;)if(r=s[--i])if(!l&&e?e(r):l&&t&&t(r),s[i]=null,l){if(c===this._parent)break;if(l=!1,o)if(o[++a])s[i]=o[a],i++;else if(c&&(s[i]=c,i++,l=!0,c._parent?(a=(o=c._parent._children).indexOf(c),c=c._parent):(c=null,o=null),a<0))break}else r._children.length>0?(c=r,o=r._children,a=0,s[i]=o[a],i++):(s[i]=r,i++,l=!0);s.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=dv(e);return t?n._findComponent(this,t):null},t.getComponents=function(e){var t=dv(e),i=[];return t&&n._findComponents(this,t,i),i},t.getComponentInChildren=function(e){var t=dv(e);return t?n._findChildComponent(this._children,t):null},t.getComponentsInChildren=function(e){var t=dv(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 c._RF.peek()&&N(3808,e),TypeError(L(3807,e))}else{if(!e)throw TypeError(L(3804));t=e}if("function"!=typeof t)throw TypeError(L(3809));if(!We(t,c.Component))throw TypeError(L(3810));var n=t._requireComponent;n&&!this.getComponent(n)&&this.addComponent(n);var i=new t;return i.node=this,this._components.push(i),this._activeInHierarchy&&c.director._nodeActivator.activateComp(i),i},t.removeComponent=function(e){if(e){var t=null;(t=e instanceof lp?e:this.getComponent(e))&&t.destroy()}else N(3813)},t.on=function(e,t,n,i){switch(void 0===i&&(i=!1),e){case Vm.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 Vm.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,o,r){this._eventProcessor.emit(e,t,n,i,o,r)},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(Vm.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&uv)){var t=this._components.indexOf(e);-1!==t?this._components.splice(t,1):e.node!==this&&N(3815)}}else N(3814)},t._updateSiblingIndex=function(){for(var e=0;e<this._children.length;++e)this._children[e]._siblingIndex=e;this.emit(Vm.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=c.instantiate._clone(this,this)),e._prefab,e._parent=null,e._onBatchCreated(t),e},t._onHierarchyChangedBase=function(){var e=this._parent;!this._persistNode||e instanceof c.Scene||c.game.removePersistRootNode(this);var t=this._active&&!(!e||!e._activeInHierarchy);this._activeInHierarchy!==t&&c.director._nodeActivator.activateNode(this,t)},t._onPreDestroyBase=function(){this._objFlags|=uv;var e=this._parent,t=!!e&&0!=(e._objFlags&uv);if(!t&&i&&this._registerIfAttached(!1),this._persistNode&&c.game.removePersistRootNode(this),!t&&e){this.emit(Vm.PARENT_CHANGED,this);var n=e._children.indexOf(this);e._children.splice(n,1),this._siblingIndex=0,e._updateSiblingIndex(),e.emit&&e.emit(Vm.CHILD_REMOVED,this)}this.emit(Vm.NODE_DESTROYED,this),this._eventProcessor.destroy();for(var o=this._children,r=0;r<o.length;++r)o[r]._destroyImmediate();for(var a=this._components,s=0;s<a.length;++s)a[s]._destroyImmediate();return t},te(n,[{key:"components",get:function(){return this._components}},{key:"_persistNode",get:function(){return(this._objFlags&hv)>0},set:function(e){e?this._objFlags|=hv:this._objFlags&=~hv}},{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&&c.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}}]),n}(hi),cv.idGenerator=fv,cv._stacks=[[]],cv._stackId=0,he((nv=lv).prototype,"_persistNode",[U_],Object.getOwnPropertyDescriptor(nv.prototype,"_persistNode"),nv.prototype),he(nv.prototype,"name",[K_],Object.getOwnPropertyDescriptor(nv.prototype,"name"),nv.prototype),he(nv.prototype,"children",[K_],Object.getOwnPropertyDescriptor(nv.prototype,"children"),nv.prototype),he(nv.prototype,"active",[K_],Object.getOwnPropertyDescriptor(nv.prototype,"active"),nv.prototype),he(nv.prototype,"activeInHierarchy",[K_],Object.getOwnPropertyDescriptor(nv.prototype,"activeInHierarchy"),nv.prototype),he(nv.prototype,"parent",[K_],Object.getOwnPropertyDescriptor(nv.prototype,"parent"),nv.prototype),iv=he(nv.prototype,"_parent",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),ov=he(nv.prototype,"_children",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),rv=he(nv.prototype,"_active",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),av=he(nv.prototype,"_components",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),sv=he(nv.prototype,"_prefab",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),tv=nv))||tv);function Iv(e){var t=e._prefab;if(t&&t.instance){if(!t.asset)return N(3701,e.name),void(t.instance=void 0);var n=e._objFlags,i=e._parent,o=e._id,r=e._prefab;c.game._isCloning=!0,t.asset._doInstantiate(e),c.game._isCloning=!1,e._objFlags=n,e._parent=i,e._id=o,e._prefab&&(e._prefab.instance=null==r?void 0:r.instance)}}function Pv(e,t,n){var i;if(t){var o=t,r=null===(i=e._prefab)||void 0===i?void 0:i.instance;!n&&r&&(t[r.fileId]={},o=t[r.fileId]);var a=e._prefab;a&&(o[a.fileId]=e);for(var s=e.components,c=0;c<s.length;c++){var l=s[c];l.__prefab&&(o[l.__prefab.fileId]=l)}for(var u=0;u<e.children.length;u++)Pv(e.children[u],o,!1)}}function bv(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 Rv(e,t,n){if(t)for(var i=0;i<t.length;i++){var o=t[i];if(o&&o.targetInfo){var r=bv(o.targetInfo.localID,n);if(!r)continue;var a=n,s=o.targetInfo.localID;if(s.length>0)for(var c=0;c<s.length-1;c++)a=a[s[c]];if(o.nodes)for(var l=0;l<o.nodes.length;l++){var u=o.nodes[l];u&&(r._children.push(u),u._parent=r,Pv(u,a,!1),u._siblingIndex=r._children.length-1,u._onBatchCreated(!1))}}}}function Nv(e,t,n){if(t)for(var i=0;i<t.length;i++){var o=t[i];if(o&&o.targetInfo){var r=bv(o.targetInfo.localID,n);if(!r)continue;if(o.components)for(var a=0;a<o.components.length;a++){var s=o.components[a];s&&(s.node=r,r._components.push(s))}}}}function Ov(e,t,n){if(t)for(var i=0;i<t.length;i++){var o=t[i];if(o){var r=bv(o.localID,n);if(!r||!r.node)continue;var a=r.node.components.indexOf(r);a>=0&&r.node._components.splice(a,1)}}}function Dv(e,t,n){if(!(t.length<=0))for(var i=null,o=0;o<t.length;o++){var r=t[o];if(r&&r.targetInfo){if(!(i=bv(r.targetInfo.localID,n)))continue;var a=i,s=r.propertyPath.slice();if(s.length>0){var c=s.pop();if(!c)continue;for(var l=0;l<s.length&&(a=a[s[l]]);l++);if(!a)continue;if(Array.isArray(a))if("length"===c)a[c]=r.value;else{var u=Number.parseInt(c);Number.isInteger(u)&&u<a.length&&(a[c]=r.value)}else a[c]=r.value}}}}function Mv(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 o,r,a=n[i],s=a.source,c=a.sourceInfo;if(c){var l,u,h=null===(l=a.source)||void 0===l||null===(u=l._prefab)||void 0===u?void 0:u.instance;h&&h.targetMap&&(s=bv(c.localID,h.targetMap))}if(s){var _,f=a.targetInfo;if(f){var d=null===(o=a.target)||void 0===o||null===(r=o._prefab)||void 0===r?void 0:r.instance;if(d&&d.targetMap&&(_=bv(f.localID,d.targetMap))){var p=a.propertyPath.slice(),m=s;if(p.length>0){var v=p.pop();if(!v)return;for(var g=0;g<p.length&&(m=m[p[g]]);g++);if(!m)continue;m[v]=_}}}}}}c._BaseNode=Cv;var Lv,Fv,zv,Bv,Uv,Hv,Gv,Vv,kv,Wv,jv,qv,Yv,Xv,Kv,Qv,Zv,Jv,$v,eg,tg,ng,ig,og,rg,ag,sg,cg,lg,ug,hg,_g,fg,dg,pg,mg,vg,gg,yg,xg,Eg,Sg,Tg,Ag,wg,Cg,Ig,Pg,bg,Rg,Ng,Og,Dg,Mg,Lg,Fg,zg,Bg,Ug,Hg,Gg,Vg,kg,Wg,jg,qg,Yg,Xg,Kg,Qg=new Rn,Zg=new zn,Jg=new zn,$g=new Array(10),ey=new zn,ty=new Mn,ny=new Mn,iy=new jn,oy=new Map,ry=e("cH",(pv=L_("cc.Node"),mv=hf(Rn),pv((wv=Av=function(e){function t(t){var n;return(n=e.call(this,t)||this)._uiProps=new km(se(n)),n._static=!1,n._pos=new Rn,n._rot=new zn,n._scale=new Rn(1,1,1),n._mat=new jn,ue(n,"_lpos",yv,se(n)),ue(n,"_lrot",xv,se(n)),ue(n,"_lscale",Ev,se(n)),ue(n,"_layer",Sv,se(n)),ue(n,"_euler",Tv,se(n)),n._dirtyFlags=m_.NONE,n._eulerDirty=!1,n._poolHandle=bo,n._poolHandle=fr.alloc(),fr.set(n._poolHandle,cr.LAYER,n._layer),n}ie(t,e),t.isNode=function(e){return e instanceof t&&(e.constructor===t||!(e instanceof c.Scene))};var n=t.prototype;return n.destroy=function(){return this._poolHandle&&(fr.free(this._poolHandle),this._poolHandle=bo),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(),jn.multiply(iy,jn.invert(iy,i._mat),this._mat),jn.toRTS(iy,this._lrot,this._lpos,this._lscale)):(Rn.copy(this._lpos,this._pos),zn.copy(this._lrot,this._rot),Rn.copy(this._lscale,this._scale)),this._eulerDirty=!0}this.invalidateChildren(m_.TRS)},n._onHierarchyChanged=function(t){this.eventProcessor.reattach(),e.prototype._onHierarchyChangedBase.call(this,t)},n._onBatchCreated=function(e){var t;fr.set(this._poolHandle,cr.LAYER,this._layer),fr.setVec3(this._poolHandle,cr.WORLD_SCALE,this._scale);var n=null===(t=this._prefab)||void 0===t?void 0:t.instance;!e&&n&&Iv(this),this.hasChangedFlags=m_.TRS,this._dirtyFlags=m_.TRS;for(var i=this._children.length,o=0;o<i;++o)this._children[o]._siblingIndex=o,this._children[o]._onBatchCreated(e);if(!e&&n){var r={};n.targetMap=r,Pv(this,r,!0),Rv(0,n.mountedChildren,r),Ov(0,n.removedComponents,r),Nv(0,n.mountedComponents,r),Dv(0,n.propertyOverrides,r)}Mv(this)},n._onBeforeSerialize=function(){this.eulerAngles},n._onPostActivated=function(e){e?(ev.resumeTarget(this),this.invalidateChildren(m_.TRS)):ev.pauseTarget(this)},n.translate=function(e,t){var n=t||p_.LOCAL;if(n===p_.LOCAL)Rn.transformQuat(Qg,e,this._lrot),this._lpos.x+=Qg.x,this._lpos.y+=Qg.y,this._lpos.z+=Qg.z;else if(n===p_.WORLD)if(this._parent){zn.invert(Zg,this._parent.worldRotation),Rn.transformQuat(Qg,e,Zg);var i=this.worldScale;this._lpos.x+=Qg.x/i.x,this._lpos.y+=Qg.y/i.y,this._lpos.z+=Qg.z/i.z}else this._lpos.x+=e.x,this._lpos.y+=e.y,this._lpos.z+=e.z;this.invalidateChildren(m_.POSITION),1&this._eventMask&&this.emit(Vm.TRANSFORM_CHANGED,m_.POSITION),fr.setVec3(this._poolHandle,cr.WORLD_POSITION,this.worldPosition)},n.rotate=function(e,t){var n=t||p_.LOCAL;if(zn.normalize(Zg,e),n===p_.LOCAL)zn.multiply(this._lrot,this._lrot,Zg);else if(n===p_.WORLD){var i=this.worldRotation;zn.multiply(Jg,Zg,i),zn.invert(Zg,i),zn.multiply(Jg,Zg,Jg),zn.multiply(this._lrot,this._lrot,Jg)}this._eulerDirty=!0,this.invalidateChildren(m_.ROTATION),1&this._eventMask&&this.emit(Vm.TRANSFORM_CHANGED,m_.ROTATION),fr.setVec4(this._poolHandle,cr.WORLD_ROTATION,this.worldRotation)},n.lookAt=function(e,t){this.getWorldPosition(Qg),Rn.subtract(Qg,Qg,e),Rn.normalize(Qg,Qg),zn.fromViewUp(Zg,Qg,t),this.setWorldRotation(Zg)},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|m_.POSITION,i=this._children.length,o=0;o<i;++o){var r=this._children[o];r.isValid&&r.invalidateChildren(n)}}},n.updateWorldTransform=function(){if(this._dirtyFlags){for(var e,t=this,n=0;t&&t._dirtyFlags;)$g[n++]=t,t=t._parent;for(var i=0;n;)i|=(e=$g[--n])._dirtyFlags,t?(i&m_.POSITION&&(Rn.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,fr.setVec3(e._poolHandle,cr.WORLD_POSITION,e._pos)),i&m_.RS&&(jn.fromRTS(e._mat,e._lrot,e._lpos,e._lscale),jn.multiply(e._mat,t._mat,e._mat),i&m_.ROTATION&&(zn.multiply(e._rot,t._rot,e._lrot),fr.setVec4(e._poolHandle,cr.WORLD_ROTATION,e._rot)),Mn.fromQuat(ty,zn.conjugate(ey,e._rot)),Mn.multiplyMat4(ty,ty,e._mat),e._scale.x=ty.m00,e._scale.y=ty.m04,e._scale.z=ty.m08,fr.setVec3(e._poolHandle,cr.WORLD_SCALE,e._scale))):(i&m_.POSITION&&(Rn.copy(e._pos,e._lpos),e._mat.m12=e._pos.x,e._mat.m13=e._pos.y,e._mat.m14=e._pos.z,fr.setVec3(e._poolHandle,cr.WORLD_POSITION,e._pos)),i&m_.RS&&(i&m_.ROTATION&&(zn.copy(e._rot,e._lrot),fr.setVec4(e._poolHandle,cr.WORLD_ROTATION,e._rot)),i&m_.SCALE&&(Rn.copy(e._scale,e._lscale),fr.setVec3(e._poolHandle,cr.WORLD_SCALE,e._scale),jn.fromRTS(e._mat,e._rot,e._pos,e._scale)))),i!==m_.NONE&&fr.setMat4(e._poolHandle,cr.WORLD_MATRIX,e._mat),e._dirtyFlags=m_.NONE,t=e}},n.setPosition=function(e,t,n){void 0===t&&void 0===n?Rn.copy(this._lpos,e):void 0===n?Rn.set(this._lpos,e,t,this._lpos.z):Rn.set(this._lpos,e,t,n),this.invalidateChildren(m_.POSITION),1&this._eventMask&&this.emit(Vm.TRANSFORM_CHANGED,m_.POSITION)},n.getPosition=function(e){return e?Rn.set(e,this._lpos.x,this._lpos.y,this._lpos.z):Rn.copy(new Rn,this._lpos)},n.setRotation=function(e,t,n,i){void 0===t||void 0===n||void 0===i?zn.copy(this._lrot,e):zn.set(this._lrot,e,t,n,i),this._eulerDirty=!0,this.invalidateChildren(m_.ROTATION),1&this._eventMask&&this.emit(Vm.TRANSFORM_CHANGED,m_.ROTATION)},n.setRotationFromEuler=function(e,t,n){var i=void 0===n?this._euler.z:n;void 0===t?(Rn.copy(this._euler,e),zn.fromEuler(this._lrot,e.x,e.y,e.z)):(Rn.set(this._euler,e,t,i),zn.fromEuler(this._lrot,e,t,i)),this._eulerDirty=!1,this.invalidateChildren(m_.ROTATION),1&this._eventMask&&this.emit(Vm.TRANSFORM_CHANGED,m_.ROTATION)},n.getRotation=function(e){return e?zn.set(e,this._lrot.x,this._lrot.y,this._lrot.z,this._lrot.w):zn.copy(new zn,this._lrot)},n.setScale=function(e,t,n){void 0===t&&void 0===n?Rn.copy(this._lscale,e):void 0===n?Rn.set(this._lscale,e,t,this._lscale.z):Rn.set(this._lscale,e,t,n),this.invalidateChildren(m_.SCALE),1&this._eventMask&&this.emit(Vm.TRANSFORM_CHANGED,m_.SCALE)},n.getScale=function(e){return e?Rn.set(e,this._lscale.x,this._lscale.y,this._lscale.z):Rn.copy(new Rn,this._lscale)},n.inverseTransformPoint=function(e,t){Rn.copy(e,t);for(var n=this,i=0;n._parent;)$g[i++]=n,n=n._parent;for(;i>=0;)Rn.transformInverseRTS(e,e,n._lrot,n._lpos,n._lscale),n=$g[--i];return e},n.setWorldPosition=function(e,t,n){void 0===t||void 0===n?Rn.copy(this._pos,e):Rn.set(this._pos,e,t,n),fr.setVec3(this._poolHandle,cr.WORLD_POSITION,this._pos);var i=this._parent,o=this._lpos;i?(i.updateWorldTransform(),Rn.transformMat4(o,this._pos,jn.invert(iy,i._mat))):Rn.copy(o,this._pos),this.invalidateChildren(m_.POSITION),1&this._eventMask&&this.emit(Vm.TRANSFORM_CHANGED,m_.POSITION)},n.getWorldPosition=function(e){return this.updateWorldTransform(),e?Rn.copy(e,this._pos):Rn.copy(new Rn,this._pos)},n.setWorldRotation=function(e,t,n,i){void 0===t||void 0===n||void 0===i?zn.copy(this._rot,e):zn.set(this._rot,e,t,n,i),fr.setVec4(this._poolHandle,cr.WORLD_ROTATION,this._rot),this._parent?(this._parent.updateWorldTransform(),zn.multiply(this._lrot,zn.conjugate(this._lrot,this._parent._rot),this._rot)):zn.copy(this._lrot,this._rot),this._eulerDirty=!0,this.invalidateChildren(m_.ROTATION),1&this._eventMask&&this.emit(Vm.TRANSFORM_CHANGED,m_.ROTATION)},n.setWorldRotationFromEuler=function(e,t,n){zn.fromEuler(this._rot,e,t,n),this._parent?(this._parent.updateWorldTransform(),zn.multiply(this._lrot,zn.conjugate(this._lrot,this._parent._rot),this._rot)):zn.copy(this._lrot,this._rot),this._eulerDirty=!0,this.invalidateChildren(m_.ROTATION),1&this._eventMask&&this.emit(Vm.TRANSFORM_CHANGED,m_.ROTATION)},n.getWorldRotation=function(e){return this.updateWorldTransform(),e?zn.copy(e,this._rot):zn.copy(new zn,this._rot)},n.setWorldScale=function(e,t,n){void 0===t||void 0===n?Rn.copy(this._scale,e):Rn.set(this._scale,e,t,n),fr.setVec3(this._poolHandle,cr.WORLD_SCALE,this._scale);var i=this._parent;i?(i.updateWorldTransform(),Mn.fromQuat(ty,zn.conjugate(ey,i._rot)),Mn.multiplyMat4(ty,ty,i._mat),ny.m00=this._scale.x,ny.m04=this._scale.y,ny.m08=this._scale.z,Mn.multiply(ty,ny,Mn.invert(ty,ty)),this._lscale.x=Rn.set(Qg,ty.m00,ty.m01,ty.m02).length(),this._lscale.y=Rn.set(Qg,ty.m03,ty.m04,ty.m05).length(),this._lscale.z=Rn.set(Qg,ty.m06,ty.m07,ty.m08).length()):Rn.copy(this._lscale,this._scale),this.invalidateChildren(m_.SCALE),1&this._eventMask&&this.emit(Vm.TRANSFORM_CHANGED,m_.SCALE)},n.getWorldScale=function(e){return this.updateWorldTransform(),e?Rn.copy(e,this._scale):Rn.copy(new Rn,this._scale)},n.getWorldMatrix=function(e){this.updateWorldTransform();var t=e||new jn;return jn.copy(t,this._mat)},n.getWorldRS=function(e){this.updateWorldTransform();var t=e||new jn;return jn.copy(t,this._mat),t.m12=0,t.m13=0,t.m14=0,t},n.getWorldRT=function(e){this.updateWorldTransform();var t=e||new jn;return jn.fromRT(t,this._rot,this._pos)},n.setRTS=function(e,t,n){var i=0;e&&(i|=m_.ROTATION,void 0!==e.w?(zn.copy(this._lrot,e),this._eulerDirty=!0):(Rn.copy(this._euler,e),zn.fromEuler(this._lrot,e.x,e.y,e.z),this._eulerDirty=!1)),t&&(Rn.copy(this._lpos,t),i|=m_.POSITION),n&&(Rn.copy(this._lscale,n),i|=m_.SCALE),i&&(this.invalidateChildren(i),1&this._eventMask&&this.emit(Vm.TRANSFORM_CHANGED,i))},n.pauseSystemEvents=function(e){ev.pauseTarget(this,e)},n.resumeSystemEvents=function(e){ev.resumeTarget(this,e)},t.clearBooks=function(){oy.clear()},n.syncToNativeTransform=function(){var e=this.hasChangedFlags;e&&(e&m_.POSITION&&fr.setVec3(this._poolHandle,cr.WORLD_POSITION,this.worldPosition),e&m_.ROTATION&&fr.setVec3(this._poolHandle,cr.WORLD_ROTATION,this.worldRotation),e&m_.SCALE&&fr.setVec3(this._poolHandle,cr.WORLD_SCALE,this.worldScale))},n.syncFromNativeTransform=function(){var e=fr.get(this._poolHandle,cr.FLAGS_CHANGED);e&&(e&m_.POSITION&&(fr.getVec3(this._poolHandle,cr.WORLD_POSITION,Qg),this.setWorldPosition(Qg)),e&m_.ROTATION&&(fr.getVec4(this._poolHandle,cr.WORLD_ROTATION,Zg),this.setWorldRotation(Zg)),e&m_.SCALE&&(fr.getVec3(this._poolHandle,cr.WORLD_SCALE,Qg),this.setWorldScale(Qg)))},te(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",get:function(){return this._eulerDirty&&(zn.toEuler(this._euler,this._lrot),this._eulerDirty=!1),this._euler},set:function(e){this.setRotationFromEuler(e.x,e.y,e.z)}},{key:"angle",get:function(){return this._euler.z},set:function(e){Rn.set(this._euler,0,0,e),zn.fromAngleZ(this._lrot,e),this._eulerDirty=!1,this.invalidateChildren(m_.ROTATION),1&this._eventMask&&this.emit(Vm.TRANSFORM_CHANGED,m_.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){jn.toRTS(e,this._lrot,this._lpos,this._lscale),this.invalidateChildren(m_.TRS),this._eulerDirty=!0,1&this._eventMask&&this.emit(Vm.TRANSFORM_CHANGED,m_.TRS)}},{key:"worldMatrix",get:function(){return this.updateWorldTransform(),this._mat}},{key:"forward",get:function(){return Rn.transformQuat(new Rn,Rn.FORWARD,this.worldRotation)},set:function(e){var t=e.length();Rn.multiplyScalar(Qg,e,-1/t),zn.fromViewUp(Zg,Qg),this.setWorldRotation(Zg)}},{key:"layer",get:function(){return this._layer},set:function(e){this._layer=e,fr.set(this._poolHandle,cr.LAYER,this._layer),this.emit(Vm.LAYER_CHANGED,this._layer)}},{key:"hasChangedFlags",get:function(){return oy.get(this)||0},set:function(e){oy.set(this,e),fr.set(this._poolHandle,cr.FLAGS_CHANGED,e)}}]),t}(Cv),Av.bookOfChange=oy,Av.EventType=Vm,Av.NodeSpace=p_,Av.TransformDirtyBit=m_,Av.TransformBit=m_,yv=he((gv=wv).prototype,"_lpos",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Rn}}),xv=he(gv.prototype,"_lrot",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new zn}}),Ev=he(gv.prototype,"_lscale",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Rn(1,1,1)}}),Sv=he(gv.prototype,"_layer",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Vu.Enum.DEFAULT}}),Tv=he(gv.prototype,"_euler",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Rn}}),he(gv.prototype,"eulerAngles",[mv],Object.getOwnPropertyDescriptor(gv.prototype,"eulerAngles"),gv.prototype),he(gv.prototype,"angle",[K_],Object.getOwnPropertyDescriptor(gv.prototype,"angle"),gv.prototype),he(gv.prototype,"layer",[K_],Object.getOwnPropertyDescriptor(gv.prototype,"layer"),gv.prototype),vv=gv))||vv));c.Node=ry;var ay=L_("cc.TargetInfo")((zv=he((Fv=function(){ue(this,"localID",zv,this)}).prototype,"localID",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Lv=Fv))||Lv,sy=(Bv=L_("cc.TargetOverrideInfo"),Uv=hf(hi),Hv=hf(ay),Gv=hf(ry),Vv=hf(ay),Bv((jv=he((Wv=function(){ue(this,"source",jv,this),ue(this,"sourceInfo",qv,this),ue(this,"propertyPath",Yv,this),ue(this,"target",Xv,this),ue(this,"targetInfo",Kv,this)}).prototype,"source",[H_,Uv],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),qv=he(Wv.prototype,"sourceInfo",[H_,Hv],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Yv=he(Wv.prototype,"propertyPath",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Xv=he(Wv.prototype,"target",[H_,Gv],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Kv=he(Wv.prototype,"targetInfo",[H_,Vv],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),kv=Wv))||kv),cy=L_("cc.CompPrefabInfo")((Jv=he((Zv=function(){ue(this,"fileId",Jv,this)}).prototype,"fileId",[H_,K_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),Qv=Zv))||Qv,ly=($v=L_("CCPropertyOverrideInfo"),eg=hf(ay),$v((ag=function(){function e(){ue(this,"targetInfo",ig,this),ue(this,"propertyPath",og,this),ue(this,"value",rg,this)}return e.prototype.isTarget=function(){},e}(),ig=he((ng=ag).prototype,"targetInfo",[H_,eg],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),og=he(ng.prototype,"propertyPath",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),rg=he(ng.prototype,"value",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),tg=ng))||tg),uy=(sg=L_("cc.MountedChildrenInfo"),cg=hf(ay),lg=hf([ry]),sg((dg=function(){function e(){ue(this,"targetInfo",_g,this),ue(this,"nodes",fg,this)}return e.prototype.isTarget=function(){},e}(),_g=he((hg=dg).prototype,"targetInfo",[H_,cg],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),fg=he(hg.prototype,"nodes",[H_,lg],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),ug=hg))||ug),hy=(pg=L_("cc.MountedComponentsInfo"),mg=hf(ay),vg=hf([lp]),pg((Sg=function(){function e(){ue(this,"targetInfo",xg,this),ue(this,"components",Eg,this)}return e.prototype.isTarget=function(){},e}(),xg=he((yg=Sg).prototype,"targetInfo",[H_,mg],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Eg=he(yg.prototype,"components",[H_,vg],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),gg=yg))||gg),_y=(Tg=L_("cc.PrefabInstance"),Ag=hf(ry),wg=hf([uy]),Cg=hf([hy]),Ig=hf([ly]),Pg=hf([ay]),Tg((zg=function(){function e(){ue(this,"fileId",Ng,this),ue(this,"prefabRootNode",Og,this),ue(this,"mountedChildren",Dg,this),ue(this,"mountedComponents",Mg,this),ue(this,"propertyOverrides",Lg,this),ue(this,"removedComponents",Fg,this),this.targetMap={}}var t=e.prototype;return t.findPropertyOverride=function(){},t.removePropertyOverride=function(){},e}(),Ng=he((Rg=zg).prototype,"fileId",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),Og=he(Rg.prototype,"prefabRootNode",[H_,Ag],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),Dg=he(Rg.prototype,"mountedChildren",[H_,wg],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Mg=he(Rg.prototype,"mountedComponents",[H_,Cg],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Lg=he(Rg.prototype,"propertyOverrides",[H_,Ig],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Fg=he(Rg.prototype,"removedComponents",[H_,Pg],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),bg=Rg))||bg),fy=(Bg=L_("cc.PrefabInfo"),Ug=hf(ry),Hg=hf(c.Prefab),Gg=hf(_y),Vg=hf([sy]),Bg((jg=he((Wg=function(){ue(this,"root",jg,this),ue(this,"asset",qg,this),ue(this,"fileId",Yg,this),ue(this,"instance",Xg,this),ue(this,"targetOverrides",Kg,this)}).prototype,"root",[H_,Ug],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),qg=he(Wg.prototype,"asset",[H_,Hg],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),Yg=he(Wg.prototype,"fileId",[H_,K_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),Xg=he(Wg.prototype,"instance",[H_,Gg],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),Kg=he(Wg.prototype,"targetOverrides",[H_,Vg],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),kg=Wg))||kg);c._PrefabInfo=fy;var dy,py,my,vy,gy,yy,xy,Ey,Sy,Ty,Ay,wy,Cy,Iy=Object.freeze({__proto__:null,TargetInfo:ay,TargetOverrideInfo:sy,CompPrefabInfo:cy,PropertyOverrideInfo:ly,MountedChildrenInfo:uy,MountedComponentsInfo:hy,PrefabInstance:_y,PrefabInfo:fy,createNodeWithPrefab:Iv,generateTargetMap:Pv,getTarget:bv,applyMountedChildren:Rv,applyMountedComponents:Nv,applyRemovedComponents:Ov,applyPropertyOverrides:Dv,applyTargetOverrides:Mv}),Py=ct({AUTO:0,SINGLE_INSTANCE:1,MULTI_INSTANCE:2}),by=e("f6",L_("cc.Prefab")((yy=gy=function(e){function t(){var t;return ue(t=e.call(this)||this,"data",my,se(t)),ue(t,"optimizationPolicy",vy,se(t)),t._createFunction=void 0,t._instantiatedTimes=void 0,t._createFunction=null,t._instantiatedTimes=0,t}ie(t,e);var n=t.prototype;return n.createNode=function(e){var t=c.instantiate(this);t.name=this.name,e(null,t)},n.compileCreateFunction=function(){var e,t;this._createFunction=(t=(e=this.data)instanceof c._BaseNode&&e,new Hm(e,t).result)},n._doInstantiate=function(e){return this.data._prefab||b(3700),this._createFunction||this.compileCreateFunction(),this._createFunction(e)},n._instantiate=function(){var e;return this.optimizationPolicy!==Py.SINGLE_INSTANCE&&(this.optimizationPolicy===Py.MULTI_INSTANCE||this._instantiatedTimes+1>=t.OptimizationPolicyThreshold)?(e=this._doInstantiate(),this.data._instantiate(e)):e=this.data._instantiate(),++this._instantiatedTimes,e},n.initDefault=function(t){e.prototype.initDefault.call(this,t),this.data=new ry,this.data.name="(Missing Node)";var n=new fy;n.asset=this,n.root=this.data,this.data._prefab=n},n.validate=function(){return!!this.data},t}(kf),gy.OptimizationPolicy=Py,gy.OptimizationPolicyThreshold=3,my=he((py=yy).prototype,"data",[H_,K_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),vy=he(py.prototype,"optimizationPolicy",[H_,K_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Py.AUTO}}),dy=py))||dy);at.value(by,"_utils",Iy),c.Prefab=by,Oe(c,"cc._Prefab","Prefab"),e("eX",(xy=L_("cc.PrefabLink"),Ey=hf(by),Sy=Q_(),xy((Cy=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return ue(t=e.call.apply(e,[this].concat(i))||this,"prefab",wy,se(t)),t}return ie(t,e),t}(lp),wy=he((Ay=Cy).prototype,"prefab",[Ey,H_,Sy],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Ty=Ay))||Ty));var Ry=new Rn;function Ny(e,t,n,i){i||(i=new Rn),e.convertToUINode(t,n,i);var o=n.position;return i.add(o),i}function Oy(e,t,n){return n||(n=new Rn),e.worldToScreen(t,n),n.x/=c.view.getScaleX(),n.y/=c.view.getScaleY(),n}var Dy=e("e$",{WorldNode3DToLocalNodeUI:Ny,WorldNode3DToWorldNodeUI:Oy});c.pipelineUtils=Dy,q(c.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],o=t[3]||Ry;return i.convertToUINode(t[1],t[2],o),o.add(t[2].position),t[3]||o.clone()}}]),q(Vm,"Node.EventType",[{name:"POSITION_PART",newName:"TRANSFORM_CHANGED"},{name:"ROTATION_PART",newName:"TRANSFORM_CHANGED"},{name:"SCALE_PART",newName:"TRANSFORM_CHANGED"}]);var My=function(){function e(){this.support=void 0,this._intervalInMileseconds=200,this._accelTimer=0,this._eventTarget=new bi,this._deviceEventName=void 0,this._globalEventClass=void 0,this._didAccelerateFunc=void 0,this.support=void 0!==window.DeviceMotionEvent||void 0!==window.DeviceOrientationEvent,this._globalEventClass=window.DeviceMotionEvent||window.DeviceOrientationEvent,Ni.browserType===Si.MOBILE_QQ&&(this._globalEventClass=window.DeviceOrientationEvent),this._deviceEventName=this._globalEventClass===window.DeviceMotionEvent?"devicemotion":"deviceorientation",this._didAccelerateFunc=this._didAccelerate.bind(this)}var t=e.prototype;return t._registerEvent=function(){this._accelTimer=performance.now(),window.addEventListener(this._deviceEventName,this._didAccelerateFunc,!1)},t._unregisterEvent=function(){this._accelTimer=0,window.removeEventListener(this._deviceEventName,this._didAccelerateFunc,!1)},t._didAccelerate=function(e){var t=performance.now();if(!(t-this._accelTimer<this._intervalInMileseconds)){this._accelTimer=t;var n=0,i=0,o=0;if(this._globalEventClass===window.DeviceMotionEvent){var r=e.accelerationIncludingGravity;n=.1*((null==r?void 0:r.x)||0),i=.1*((null==r?void 0:r.y)||0),o=.1*((null==r?void 0:r.z)||0)}else{var a=e;n=(a.gamma||0)/90*.981,i=-(a.beta||0)/90*.981,o=(a.alpha||0)/90*.981}if(c.view._isRotated){var s=n;n=-i,i=s}var l=n;90===window.orientation?(n=-i,i=l):-90===window.orientation?(n=i,i=-l):180===window.orientation&&(n=-n,i=-i),Ni.os===Ci.ANDROID&&Ni.browserType!==Si.MOBILE_QQ&&(n=-n,i=-i);var u={type:Vm.DEVICEMOTION,x:n,y:i,z:o,timestamp:performance.now()};this._eventTarget.emit(Vm.DEVICEMOTION,u)}},t.start=function(){this._registerEvent()},t.stop=function(){this._unregisterEvent()},t.setInterval=function(e){this._intervalInMileseconds=e},t.onChange=function(e){this._eventTarget.on(Vm.DEVICEMOTION,e)},e}(),Ly=function(){function e(){this.support=void 0,this.support=!0}var t=e.prototype;return t.show=function(){throw new Error("Method not implemented.")},t.hide=function(){throw new Error("Method not implemented.")},t.onChange=function(){throw new Error("Method not implemented.")},t.onComplete=function(){throw new Error("Method not implemented.")},t.offChange=function(){throw new Error("Method not implemented.")},t.offComplete=function(){throw new Error("Method not implemented.")},e}(),Fy=function(){function e(){this.support=void 0,this._eventTarget=new bi,this.support=void 0!==document.documentElement.onkeyup,this._registerEvent()}var t=e.prototype;return t._registerEvent=function(){var e=document.getElementById("GameCanvas");null==e||e.addEventListener("keydown",this._createCallback(Vm.KEY_DOWN)),null==e||e.addEventListener("keyup",this._createCallback(Vm.KEY_UP))},t._createCallback=function(e){var t=this;return function(n){var i={type:e,code:n.keyCode,timestamp:performance.now()};n.stopPropagation(),n.preventDefault(),t._eventTarget.emit(e,i)}},t.onDown=function(e){this._eventTarget.on(Vm.KEY_DOWN,e)},t.onUp=function(e){this._eventTarget.on(Vm.KEY_UP,e)},e}(),zy=function(){function e(){this.support=void 0,this._canvas=void 0,this._eventTarget=new bi,this._pointLocked=!1,this._isPressed=!1,this._preMousePos=new Kn,this.support=void 0!==document.documentElement.onmouseup,this.support&&(this._canvas=document.getElementById("GameCanvas"),this._canvas||console.warn("failed to access canvas"),this._registerEvent())}var t=e.prototype;return t._getCanvasRect=function(){var e=this._canvas,t=null==e?void 0:e.getBoundingClientRect();return t?new oi(t.x,t.y,t.width,t.height):new oi(0,0,0,0)},t._getLocation=function(e){return new Kn(e.clientX,e.clientY)},t._registerEvent=function(){var e,t,n,i,o=this;window.addEventListener("mousedown",(function(){o._isPressed=!0})),null===(e=this._canvas)||void 0===e||e.addEventListener("mousedown",this._createCallback(Vm.MOUSE_DOWN)),null===(t=this._canvas)||void 0===t||t.addEventListener("mousemove",this._createCallback(Vm.MOUSE_MOVE)),window.addEventListener("mouseup",this._createCallback(Vm.MOUSE_UP)),null===(n=this._canvas)||void 0===n||n.addEventListener("mouseup",this._createCallback(Vm.MOUSE_UP)),null===(i=this._canvas)||void 0===i||i.addEventListener("wheel",(function(e){var t=o._getCanvasRect(),n=o._getLocation(e),i={type:Vm.MOUSE_WHEEL,x:n.x-t.x,y:t.y+t.height-n.y,button:e.button,deltaX:5*e.deltaX,deltaY:5*-e.deltaY,timestamp:performance.now(),movementX:e.movementX,movementY:e.movementY};e.stopPropagation(),e.preventDefault(),o._eventTarget.emit(Vm.MOUSE_WHEEL,i)})),this._registerPointerLockEvent()},t._registerPointerLockEvent=function(){var e=this,t=function(){var t=e._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._createCallback=function(e){var t=this;return function(n){var i,o=t._getCanvasRect(),r=t._getLocation(n),a=n.button;switch(n.type){case"mousedown":null===(i=t._canvas)||void 0===i||i.focus(),t._isPressed=!0;break;case"mouseup":t._isPressed=!1;break;case"mousemove":t._isPressed||(a=-1)}var s={type:e,x:t._pointLocked?t._preMousePos.x+n.movementX:r.x-o.x,y:t._pointLocked?t._preMousePos.y-n.movementY:o.y+o.height-r.y,button:a,timestamp:performance.now(),movementX:n.movementX,movementY:n.movementY};t._preMousePos.set(s.x,s.y),n.stopPropagation(),n.target===t._canvas&&n.preventDefault(),t._eventTarget.emit(e,s)}},t.onDown=function(e){this._eventTarget.on(Vm.MOUSE_DOWN,e)},t.onMove=function(e){this._eventTarget.on(Vm.MOUSE_MOVE,e)},t.onUp=function(e){this._eventTarget.on(Vm.MOUSE_UP,e)},t.onWheel=function(e){this._eventTarget.on(Vm.MOUSE_WHEEL,e)},e}(),By=function(){function e(){this.support=void 0,this._canvas=void 0,this._eventTarget=new bi,this.support=void 0!==document.documentElement.ontouchstart||void 0!==document.ontouchstart||navigator.msPointerEnabled,this.support&&(this._canvas=document.getElementById("GameCanvas"),this._canvas||console.warn("failed to access canvas"),this._registerEvent())}var t=e.prototype;return t._registerEvent=function(){var e,t,n,i;null===(e=this._canvas)||void 0===e||e.addEventListener("touchstart",this._createCallback(Vm.TOUCH_START)),null===(t=this._canvas)||void 0===t||t.addEventListener("touchmove",this._createCallback(Vm.TOUCH_MOVE)),null===(n=this._canvas)||void 0===n||n.addEventListener("touchend",this._createCallback(Vm.TOUCH_END)),null===(i=this._canvas)||void 0===i||i.addEventListener("touchcancel",this._createCallback(Vm.TOUCH_CANCEL))},t._createCallback=function(e){var t=this;return function(n){for(var i=t._getCanvasRect(),o=[],r=n.changedTouches.length,a=0;a<r;++a){var s=n.changedTouches[a],l=t._getLocation(s),u=l.x-i.x,h=i.y+i.height-l.y;if(c.view._isRotated){var _=u;u=i.height-h,h=_}var f={identifier:s.identifier,x:u,y:h,force:s.force};o.push(f)}var d,p={type:e,changedTouches:o,timestamp:performance.now()};n.stopPropagation(),n.target===t._canvas&&n.preventDefault(),"touchstart"===n.type&&(null===(d=t._canvas)||void 0===d||d.focus()),t._eventTarget.emit(e,p)}},t._getCanvasRect=function(){var e=this._canvas,t=null==e?void 0:e.getBoundingClientRect();return t?new oi(t.x,t.y,t.width,t.height):new oi(0,0,0,0)},t._getLocation=function(e){return new Kn(e.clientX,e.clientY)},t.onStart=function(e){this._eventTarget.on(Vm.TOUCH_START,e)},t.onMove=function(e){this._eventTarget.on(Vm.TOUCH_MOVE,e)},t.onEnd=function(e){this._eventTarget.on(Vm.TOUCH_END,e)},t.onCancel=function(e){this._eventTarget.on(Vm.TOUCH_CANCEL,e)},e}(),Uy=new(function(){function e(){this._touch=new By,this._mouse=new zy,this._keyboard=new Fy,this._accelerometer=new My,this._inputBox=new Ly,this._inputEventList=[],this._registerEvent()}var t=e.prototype;return t._registerEvent=function(){},t._pushEvent=function(e){this._inputEventList.push(e)},t.pollEvent=function(){return this._inputEventList.shift()},e}()),Hy=new Kn,Gy=e("fm",function(e){function t(n,i,o){var r;return(r=e.call(this,Vf.MOUSE,i)||this).movementX=0,r.movementY=0,r.eventType=void 0,r._button=t.BUTTON_MISSING,r._x=0,r._y=0,r._prevX=0,r._prevY=0,r._scrollX=0,r._scrollY=0,r.eventType=n,o&&(r._prevX=o.x,r._prevY=o.y),r}ie(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 Kn),Kn.set(e,this._x,this._y),e},n.getLocationInView=function(e){return e||(e=new Kn),Kn.set(e,this._x,c.view._designResolutionSize.height-this._y),e},n.getUILocation=function(e){return e||(e=new Kn),Kn.set(e,this._x,this._y),c.view._convertPointWithScale(e),e},n.getPreviousLocation=function(e){return e||(e=new Kn),Kn.set(e,this._prevX,this._prevY),e},n.getUIPreviousLocation=function(e){return e||(e=new Kn),Kn.set(e,this._prevX,this._prevY),c.view._convertPointWithScale(e),e},n.getDelta=function(e){return e||(e=new Kn),Kn.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 Kn),Kn.set(e,(this._x-this._prevX)/c.view.getScaleX(),(this._y-this._prevY)/c.view.getScaleY()),e},n.getUIDeltaX=function(){return(this._x-this._prevX)/c.view.getScaleX()},n.getUIDeltaY=function(){return(this._y-this._prevY)/c.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=c.view.getViewportRect();return(this._x-e.x)/c.view.getScaleX()},n.getUILocationY=function(){var e=c.view.getViewportRect();return(this._y-e.y)/c.view.getScaleY()},t}(Vf));Gy.BUTTON_MISSING=-1,Gy.BUTTON_LEFT=0,Gy.BUTTON_RIGHT=2,Gy.BUTTON_MIDDLE=1,Gy.BUTTON_4=3,Gy.BUTTON_5=4,Gy.BUTTON_6=5,Gy.BUTTON_7=6,Gy.BUTTON_8=7;var Vy=e("dL",function(e){function t(t,n,i,o){var r;return(r=e.call(this,Vf.TOUCH,n)||this).touch=null,r.simulate=!1,r._eventCode=void 0,r._touches=void 0,r._allTouches=void 0,r._eventCode=i||"",r._touches=t||[],r._allTouches=o||[],r}ie(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 Kn},n.getUILocation=function(e){return this.touch?this.touch.getUILocation(e):new Kn},n.getLocationInView=function(e){return this.touch?this.touch.getLocationInView(e):new Kn},n.getPreviousLocation=function(e){return this.touch?this.touch.getPreviousLocation(e):new Kn},n.getStartLocation=function(e){return this.touch?this.touch.getStartLocation(e):new Kn},n.getUIStartLocation=function(e){return this.touch?this.touch.getUIStartLocation(e):new Kn},n.getID=function(){return this.touch?this.touch.getID():null},n.getDelta=function(e){return this.touch?this.touch.getDelta(e):new Kn},n.getUIDelta=function(e){return this.touch?this.touch.getUIDelta(e):new Kn},n.getDeltaX=function(){return this.touch?this.touch.getDelta(Hy).x:0},n.getDeltaY=function(){return this.touch?this.touch.getDelta(Hy).y:0},n.getLocationX=function(){return this.touch?this.touch.getLocationX():0},n.getLocationY=function(){return this.touch?this.touch.getLocationY():0},t}(Vf));Vy.MAX_TOUCHES=5;var ky=e("fn",function(e){function t(t,n){var i;return(i=e.call(this,Vf.ACCELERATION,n)||this).acc=void 0,i.acc=t,i}return ie(t,e),t}(Vf)),Wy=e("fo",function(e){function t(t,n,i){var o;return(o=e.call(this,Vf.KEYBOARD,i)||this).keyCode=void 0,o.rawEvent=void 0,o.isPressed=void 0,"number"==typeof t?o.keyCode=t:(o.keyCode=t.keyCode,o.rawEvent=t),o.isPressed=n,o}return ie(t,e),t}(Vf));Vf.EventMouse=Gy,Vf.EventTouch=Vy,Vf.EventAcceleration=ky,Vf.EventKeyboard=Wy;var jy=new Kn,qy=e("fp",function(){function e(e,t,n){void 0===n&&(n=0),this._point=new Kn,this._prevPoint=new Kn,this._lastModified=0,this._id=0,this._startPoint=new Kn,this._startPointCaptured=!1,this.setTouchInfo(n,e,t)}var t=e.prototype;return t.getLocation=function(e){return e||(e=new Kn),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 Kn),e.set(this._point.x,this._point.y),c.view._convertPointWithScale(e),e},t.getUILocationX=function(){var e=c.view.getViewportRect();return(this._point.x-e.x)/c.view.getScaleX()},t.getUILocationY=function(){var e=c.view.getViewportRect();return(this._point.y-e.y)/c.view.getScaleY()},t.getPreviousLocation=function(e){return e||(e=new Kn),e.set(this._prevPoint.x,this._prevPoint.y),e},t.getUIPreviousLocation=function(e){return e||(e=new Kn),e.set(this._prevPoint.x,this._prevPoint.y),c.view._convertPointWithScale(e),e},t.getStartLocation=function(e){return e||(e=new Kn),e.set(this._startPoint.x,this._startPoint.y),e},t.getUIStartLocation=function(e){return e||(e=new Kn),e.set(this._startPoint.x,this._startPoint.y),c.view._convertPointWithScale(e),e},t.getDelta=function(e){return e||(e=new Kn),e.set(this._point),e.subtract(this._prevPoint),e},t.getUIDelta=function(e){return e||(e=new Kn),jy.set(this._point),jy.subtract(this._prevPoint),e.set(c.view.getScaleX(),c.view.getScaleY()),Kn.divide(e,jy,e),e},t.getLocationInView=function(e){return e||(e=new Kn),e.set(this._point.x,c.view._designResolutionSize.height-this._point.y),e},t.getPreviousLocationInView=function(e){return e||(e=new Kn),e.set(this._prevPoint.x,c.view._designResolutionSize.height-this._prevPoint.y),e},t.getStartLocationInView=function(e){return e||(e=new Kn),e.set(this._startPoint.x,c.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 Kn(t||0,n||0),this._id=e,this._startPointCaptured||(this._startPoint=new Kn(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=c.director.getCurrentTime()},t.setPrevPoint=function(e,t){this._prevPoint="object"==typeof e?new Kn(e.x,e.y):new Kn(e||0,t||0),this._lastModified=c.director.getCurrentTime()},te(e,[{key:"lastModified",get:function(){return this._lastModified}}]),e}());c.Touch=qy;var Yy=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},Xy=ft.TOUCH_TIMEOUT,Ky=new Kn,Qy=new Kn,Zy=new(function(){function e(){this._isRegisterEvent=!1,this._preTouchPoint=new Kn,this._prevMousePoint=new Kn,this._preTouchPool=[],this._preTouchPoolPointer=0,this._touches=[],this._touchesIntegerDict={},this._indexBitsUsed=0,this._maxTouches=8,this._glView=null}var t=e.prototype;return t.handleTouchesBegin=function(e){for(var t=[],n=this._touchesIntegerDict,i=0;i<e.length;++i){var o=e[i],r=o.getID();if(null!==r&&void 0===n[r]){var a=this._getUnUsedIndex();if(-1===a){I(2300,a);continue}o.getLocation(Ky);var s=new qy(Ky.x,Ky.y,r);this._touches[a]=s,o.getPreviousLocation(Ky),s.setPrevPoint(Ky),n[r]=a,t.push(s)}}if(t.length>0){var c=new Vy(t,!1,Vm.TOUCH_START,ft.ENABLE_MULTI_TOUCH?this._getUsefulTouches():t);ev.dispatchEvent(c)}},t.handleTouchesMove=function(e){for(var t=[],n=this._touches,i=0;i<e.length;++i){var o=e[i],r=o.getID();if(null!==r){var a=this._touchesIntegerDict[r];void 0!==a&&n[a]&&(o.getLocation(Ky),n[a].setPoint(Ky),o.getPreviousLocation(Ky),n[a].setPrevPoint(Ky),t.push(n[a]))}}if(t.length>0){var s=new Vy(t,!1,Vm.TOUCH_MOVE,ft.ENABLE_MULTI_TOUCH?this._getUsefulTouches():t);ev.dispatchEvent(s)}},t.handleTouchesEnd=function(e){var t=this.getSetOfTouchesEndOrCancel(e);if(t.length>0){var n=new Vy(t,!1,Vm.TOUCH_END,ft.ENABLE_MULTI_TOUCH?this._getUsefulTouches():t);ev.dispatchEvent(n)}this._preTouchPool.length=0},t.handleTouchesCancel=function(e){var t=this.getSetOfTouchesEndOrCancel(e);if(t.length>0){var n=new Vy(t,!1,Vm.TOUCH_CANCEL,ft.ENABLE_MULTI_TOUCH?this._getUsefulTouches():t);ev.dispatchEvent(n)}this._preTouchPool.length=0},t.getSetOfTouchesEndOrCancel=function(e){for(var t=[],n=this._touches,i=this._touchesIntegerDict,o=0;o<e.length;++o){var r=e[o],a=r.getID();if(null!==a){var s=i[a];void 0!==s&&n[s]&&(r.getLocation(Ky),n[s].setPoint(Ky),r.getPreviousLocation(Ky),n[s].setPrevPoint(Ky),t.push(n[s]),this._removeUsedIndexBit(s),delete i[a])}}return t},t._getPreTouch=function(e){for(var t=null,n=this._preTouchPool,i=e.getID(),o=n.length-1;o>=0;o--)if(n[o].getID()===i){t=n[o];break}return t||(t=e),t},t._setPreTouch=function(e){for(var t=!1,n=this._preTouchPool,i=e.getID(),o=n.length-1;o>=0;o--)if(n[o].getID()===i){n[o]=e,t=!0;break}t||(n.length<=50?n.push(e):(n[this._preTouchPoolPointer]=e,this._preTouchPoolPointer=(this._preTouchPoolPointer+1)%50))},t._getViewPixelRatio=function(){return this._glView?this._glView._devicePixelRatio:1},t._getTouch=function(e){var t=this._preTouchPoint,n=this._getViewPixelRatio(),i=e.x*n,o=e.y*n,r=new qy(i,o,0);return r.setPrevPoint(t.x,t.y),t.x=i,t.y=o,r},t._getMouseEvent=function(e){var t=this._prevMousePoint,n=new Gy(e.type,!1,t),i=this._getViewPixelRatio();return t.x=e.x*i,t.y=e.y*i,c.GAME_VIEW&&(t.x/=c.gameView.canvas.width/c.game.canvas.width,t.y/=c.gameView.canvas.height/c.game.canvas.height),n.setLocation(t.x,t.y),n.setButton(e.button),e.movementX&&(n.movementX=e.movementX),e.movementY&&(n.movementY=e.movementY),n},t._getTouchList=function(e){for(var t=[],n=this._preTouchPoint,i=e.changedTouches.length,o=this._getViewPixelRatio(),r=0;r<i;r++){var a=e.changedTouches[r],s=a.x*o,c=a.y*o,l=new qy(s,c,a.identifier);if(this._getPreTouch(l).getLocation(Qy),l.setPrevPoint(Qy.x,Qy.y),this._setPreTouch(l),n.x=s,n.y=c,t.push(l),!ft.ENABLE_MULTI_TOUCH)break}return t},t._getUnUsedIndex=function(){for(var e=this._indexBitsUsed,t=c.director.getCurrentTime(),n=0;n<this._maxTouches;n++){if(!(1&e))return this._indexBitsUsed|=1<<n,n;var i=this._touches[n];if(t-i.lastModified>Xy){this._removeUsedIndexBit(n);var o=i.getID();return null!==o&&delete this._touchesIntegerDict[o],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._getUsefulTouches=function(){var e=[],t=this._touchesIntegerDict;for(var n in t){var i=t[parseInt(n)];if(null!=i){var o=this._touches[i];e.push(o)}}return e},t.setAccelerometerEnabled=function(e){e?Uy._accelerometer.start():Uy._accelerometer.stop()},t.setAccelerometerInterval=function(e){Uy._accelerometer.setInterval(e)},t.registerSystemEvent=function(){this._isRegisterEvent||(this._glView=c.view,Uy._mouse.support&&this._registerMouseEvents(),Uy._touch.support&&this._registerTouchEvents(),Uy._keyboard.support&&this._registerKeyboardEvent(),Uy._accelerometer.support&&this._registerAccelerometerEvent(),this._isRegisterEvent=!0)},t._registerMouseEvents=function(){var e=this;Uy._mouse.onDown((function(t){var n=e._getMouseEvent(t),i=e._getTouch(t);e.handleTouchesBegin([i]),ev.dispatchEvent(n)})),Uy._mouse.onMove((function(t){var n=e._getMouseEvent(t),i=e._getTouch(t);e.handleTouchesMove([i]),ev.dispatchEvent(n)})),Uy._mouse.onUp((function(t){var n=e._getMouseEvent(t),i=e._getTouch(t);e.handleTouchesEnd([i]),ev.dispatchEvent(n)})),Uy._mouse.onWheel((function(t){var n=e._getMouseEvent(t);n.setScrollData(t.deltaX,t.deltaY),ev.dispatchEvent(n)}))},t._registerTouchEvents=function(){var e=this;Uy._touch.onStart((function(t){var n=e._getTouchList(t);e.handleTouchesBegin(n)})),Uy._touch.onMove((function(t){var n=e._getTouchList(t);e.handleTouchesMove(n)})),Uy._touch.onEnd((function(t){var n=e._getTouchList(t);e.handleTouchesEnd(n)})),Uy._touch.onCancel((function(t){var n=e._getTouchList(t);e.handleTouchesCancel(n)}))},t._registerKeyboardEvent=function(){Uy._keyboard.onDown((function(e){ev.dispatchEvent(new Wy(e.code,!0))})),Uy._keyboard.onUp((function(e){ev.dispatchEvent(new Wy(e.code,!1))}))},t._registerAccelerometerEvent=function(){Uy._accelerometer.onChange((function(e){var t=e.x,n=e.y,i=e.z,o=e.timestamp;ev.dispatchEvent(new ky(new Yy(t,n,i,o)))}))},e}());c.internal.inputManager=Zy;var Jy=null,$y=null,ex=null,tx=null,nx=e("fk",function(e){function t(){return e.call(this)||this}ie(t,e);var n=t.prototype;return n.setAccelerometerEnabled=function(e){e&&window.DeviceMotionEvent&&"function"==typeof DeviceMotionEvent.requestPermission?DeviceMotionEvent.requestPermission().then((function(e){I(3520,e),Zy.setAccelerometerEnabled("granted"===e)})).catch((function(e){b(3521,e.message),Zy.setAccelerometerEnabled(!1)})):Zy.setAccelerometerEnabled(e)},n.setAccelerometerInterval=function(e){Zy.setAccelerometerInterval(e)},n.on=function(t,n,i,o){return e.prototype.on.call(this,t,n,i,o),t!==Vm.KEY_DOWN&&t!==Vm.KEY_UP||Jy||(Jy=Wm.create({event:Wm.KEYBOARD,onKeyPressed:function(e,t){t.type=Vm.KEY_DOWN,ix.emit(t.type,t)},onKeyReleased:function(e,t){t.type=Vm.KEY_UP,ix.emit(t.type,t)}}),ev.addListener(Jy,256)),t===Vm.DEVICEMOTION&&($y||($y=Wm.create({event:Wm.ACCELERATION,callback:function(e,t){t.type=Vm.DEVICEMOTION,c.systemEvent.emit(t.type,t)}}),ev.addListener($y,256))),t!==Vm.TOUCH_START&&t!==Vm.TOUCH_MOVE&&t!==Vm.TOUCH_END&&t!==Vm.TOUCH_CANCEL||ex||(ex=Wm.create({event:Wm.TOUCH_ONE_BY_ONE,onTouchBegan:function(e,t){return t.type=Vm.TOUCH_START,c.systemEvent.emit(t.type,e,t),!0},onTouchMoved:function(e,t){t.type=Vm.TOUCH_MOVE,c.systemEvent.emit(t.type,e,t)},onTouchEnded:function(e,t){t.type=Vm.TOUCH_END,c.systemEvent.emit(t.type,e,t)},onTouchCancelled:function(e,t){t.type=Vm.TOUCH_CANCEL,c.systemEvent.emit(t.type,e,t)}}),ev.addListener(ex,256)),t!==Vm.MOUSE_DOWN&&t!==Vm.MOUSE_MOVE&&t!==Vm.MOUSE_UP&&t!==Vm.MOUSE_WHEEL||tx||(tx=Wm.create({event:Wm.MOUSE,onMouseDown:function(e){e.type=Vm.MOUSE_DOWN,c.systemEvent.emit(e.type,e)},onMouseMove:function(e){e.type=Vm.MOUSE_MOVE,c.systemEvent.emit(e.type,e)},onMouseUp:function(e){e.type=Vm.MOUSE_UP,c.systemEvent.emit(e.type,e)},onMouseScroll:function(e){e.type=Vm.MOUSE_WHEEL,c.systemEvent.emit(e.type,e)}}),ev.addListener(tx,256)),n},n.off=function(t,n,i){if(e.prototype.off.call(this,t,n,i),Jy&&(t===Vm.KEY_DOWN||t===Vm.KEY_UP)){var o=this.hasEventListener(Vm.KEY_DOWN),r=this.hasEventListener(Vm.KEY_UP);o||r||(ev.removeListener(Jy),Jy=null)}if($y&&t===Vm.DEVICEMOTION&&(ev.removeListener($y),$y=null),ex&&(t===Vm.TOUCH_START||t===Vm.TOUCH_MOVE||t===Vm.TOUCH_END||t===Vm.TOUCH_CANCEL)){var a=this.hasEventListener(Vm.TOUCH_START),s=this.hasEventListener(Vm.TOUCH_MOVE),c=this.hasEventListener(Vm.TOUCH_END),l=this.hasEventListener(Vm.TOUCH_CANCEL);a||s||c||l||(ev.removeListener(ex),ex=null)}if(tx&&(t===Vm.MOUSE_DOWN||t===Vm.MOUSE_MOVE||t===Vm.MOUSE_UP||t===Vm.MOUSE_WHEEL)){var u=this.hasEventListener(Vm.MOUSE_DOWN),h=this.hasEventListener(Vm.MOUSE_MOVE),_=this.hasEventListener(Vm.MOUSE_UP),f=this.hasEventListener(Vm.MOUSE_WHEEL);u||h||_||f||(ev.removeListener(tx),tx=null)}},t}(bi));nx.EventType=Vm,c.SystemEvent=nx;var ix=e("fl",new nx);c.systemEvent=ix;var ox,rx,ax,sx,cx,lx,ux,hx,_x,fx,dx=Ni.getViewSize(),px=Ni.pixelRatio,mx=e("br",{NetworkType:wi,Language:Ai,OS:Ci,Platform:Pi,BrowserType:Si,isNative:Ni.isNative,isBrowser:Ni.isBrowser,isMobile:Ni.isMobile,isLittleEndian:Ni.isLittleEndian,platform:Ni.platform,language:Ni.language,languageCode:Ni.nativeLanguage,os:Ni.os,osVersion:Ni.osVersion,osMainVersion:Ni.osMainVersion,browserType:Ni.browserType,browserVersion:Ni.browserVersion,windowPixelResolution:{width:dx.width*px,height:dx.height*px},capabilities:{canvas:Ni.supportCapability.canvas,opengl:Ni.supportCapability.gl,webp:Ni.supportCapability.webp,imageBitmap:Ni.supportCapability.imageBitmap,touches:!1,mouse:!1,keyboard:!1,accelerometer:!1},localStorage:null,getNetworkType:function(){return Ni.networkType},getBatteryLevel:function(){return Ni.getBatteryLevel()},garbageCollect:function(){Ni.triggerGC()},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",g(e+="Using "+(c.game.renderType===c.game.RENDER_TYPE_WEBGL?"WEBGL":"CANVAS")+" renderer.\r\n")},openURL:function(e){Ni.openURL(e)},now:function(){return Ni.now()},restartVM:function(){Ni.restartJSVM()},getSafeAreaRect:function(){var e=c.view,t=Ni.getSafeAreaEdge(),n=Ni.getViewSize(),i=new Kn(t.left,n.height-t.bottom),o=new Kn(n.width-t.right,t.top),r={left:0,top:0,width:n.width,height:n.height};e.convertToLocationInView(i.x,i.y,r,i),e.convertToLocationInView(o.x,o.y,r,o),e._convertPointWithScale(i),e._convertPointWithScale(o);var a=i.x,s=i.y,l=o.x-i.x,u=o.y-i.y;return new oi(a,s,l,u)},__init:function(){try{var e=mx.localStorage=window.localStorage;e.setItem("storage",""),e.removeItem("storage"),e=null}catch(e){var t=function(){b(5200)};mx.localStorage={getItem:t,setItem:t,removeItem:t,clear:t}}var n=window,i=n.navigator,o=document,r=o.documentElement,a=mx.capabilities;(void 0!==r.ontouchstart||void 0!==o.ontouchstart||i.msPointerEnabled)&&(a.touches=!0),void 0!==r.onmouseup&&(a.mouse=!0),void 0!==r.onkeyup&&(a.keyboard=!0),(n.DeviceMotionEvent||n.DeviceOrientationEvent)&&(a.accelerometer=!0),mx.__isWebIOS14OrIPadOS14Env=(mx.os===Ci.IOS||mx.os===Ci.OSX)&&Ni.isBrowser&&/(OS 1[4-9])|(Version\/1[4-9])/.test(window.navigator.userAgent),Ni.onViewResize((function(){var e=Ni.getViewSize();mx.windowPixelResolution={width:Math.round(e.width*px),height:Math.round(e.height*px)}}))}});mx.__init(),c.sys=mx;var vx,gx,yx,xx,Ex,Sx,Tx,Ax,wx,Cx,Ix,Px,bx,Rx=e("fu",(ox=L_("RenderStage"),rx=rf(),ax=rf(),sx=rf(),ox((fx=function(){function e(){ue(this,"_name",ux,this),ue(this,"_priority",hx,this),ue(this,"_tag",_x,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},te(e,[{key:"name",get:function(){return this._name}},{key:"priority",get:function(){return this._priority}},{key:"tag",get:function(){return this._tag}}]),e}(),ux=he((lx=fx).prototype,"_name",[rx,H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),hx=he(lx.prototype,"_priority",[ax,H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),_x=he(lx.prototype,"_tag",[sx,H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),cx=lx))||cx));c.RenderStage=Rx;var Nx,Ox,Dx,Mx,Lx,Fx,zx,Bx,Ux=e("ft",(vx=L_("RenderFlow"),gx=rf(),yx=rf(),xx=rf(),Ex=rf(),Sx=hf([Rx]),vx((bx=function(){function e(){ue(this,"_name",wx,this),ue(this,"_priority",Cx,this),ue(this,"_tag",Ix,this),ue(this,"_stages",Px,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},te(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}},{key:"pipeline",get:function(){return this._pipeline}}]),e}(),wx=he((Ax=bx).prototype,"_name",[gx,H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),Cx=he(Ax.prototype,"_priority",[yx,H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Ix=he(Ax.prototype,"_tag",[xx,H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Px=he(Ax.prototype,"_stages",[Ex,Sx,H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Tx=Ax))||Tx));c.RenderFlow=Ux;var Hx,Gx,Vx,kx,Wx,jx,qx,Yx,Xx,Kx,Qx=e("ep",L_("cc.EffectAsset")((Bx=zx=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return ue(t=e.call.apply(e,[this].concat(i))||this,"techniques",Dx,se(t)),ue(t,"shaders",Mx,se(t)),ue(t,"combinations",Lx,se(t)),ue(t,"hideInEditor",Fx,se(t)),t}ie(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(){rm.register(this),t.register(this),c.game.once(c.Game.EVENT_ENGINE_INITED,this._precompile,this)},n._precompile=function(){for(var e=this,t=c.director.root,n=function(n){var i=e.shaders[n],o=e.combinations[n];if(!o)return"continue";Object.keys(o).reduce((function(e,t){return e.reduce((function(e,n){for(var i=o[t],r=0;r<i.length;++r){var a=ne({},n);a[t]=i[r],e.push(a)}return e}),[])}),[{}]).forEach((function(e){return rm.getGFXShader(t.device,i.name,e,t.pipeline)}))},i=0;i<this.shaders.length;i++)n(i)},n.destroy=function(){return t.remove(this.name),e.prototype.destroy.call(this)},n.initDefault=function(n){e.prototype.initDefault.call(this,n);var i=t.get("unlit");this.name="unlit",this.shaders=i.shaders,this.combinations=i.combinations,this.techniques=i.techniques},n.validate=function(){return this.techniques.length>0&&this.shaders.length>0},t}(kf),zx._effects={},Dx=he((Ox=Bx).prototype,"techniques",[H_,K_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Mx=he(Ox.prototype,"shaders",[H_,K_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Lx=he(Ox.prototype,"combinations",[H_,K_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Fx=he(Ox.prototype,"hideInEditor",[H_,G_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),Nx=Ox))||Nx);c.EffectAsset=Qx;var Zx=new ge("RenderTex"),Jx=new Xs;Jx.endAccesses=[$a.FRAGMENT_SHADER_READ_TEXTURE];var $x,eE,tE,nE,iE,oE,rE,aE,sE,cE,lE=new Ks,uE=new Zs([Jx],lE),hE={width:1,height:1,renderPassInfo:uE},_E=e("da",(Hx=L_("cc.RenderTexture"),Gx=ef(),Vx=tf(),kx=ef(),Wx=tf(),Hx((Kx=function(e){function t(){var t;return ue(t=e.call(this)||this,"_width",Yx,se(t)),ue(t,"_height",Xx,se(t)),t._textureHash=0,t._id=void 0,t._window=null,t._id=Zx.getNewId(),t._textureHash=Rc(t._id,666),t}ie(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&&(c.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=c.director.root;return yd.getSampler(e.device,nd)},n.getSamplerHash=function(){return nd},n.onLoaded=function(){this._initWindow(),this.loaded=!0,this.emit("load")},n._initWindow=function(e){var t=c.director.root;hE.title=this._name,hE.width=this._width,hE.height=this._height,hE.renderPassInfo=e&&e.passInfo?e.passInfo:uE,this._window?(this._window.destroy(),this._window.initialize(t.device,hE)):this._window=t.createWindow(hE)},n.initDefault=function(t){e.prototype.initDefault.call(this,t),this._width=this._height=1,this._initWindow()},n.validate=function(){return this.width>=1&&this.width<=2048&&this.height>=1&&this.height<=2048},te(t,[{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"window",get:function(){return this._window}}]),t}(kf),Yx=he((qx=Kx).prototype,"_width",[H_,Gx,Vx],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),Xx=he(qx.prototype,"_height",[H_,kx,Wx],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),jx=qx))||jx));c.RenderTexture=_E;var fE=e("cI",($x=L_("cc.Material"),eE=hf(Qx),$x((cE=function(e){function t(){var t;return ue(t=e.call(this)||this,"_effectAsset",iE,se(t)),ue(t,"_techIdx",oE,se(t)),ue(t,"_defines",rE,se(t)),ue(t,"_states",aE,se(t)),ue(t,"_props",sE,se(t)),t._passes=[],t._hash=0,t.loaded=!1,t}ie(t,e),t.getHash=function(e){for(var t,n=0,i=le(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=Qx.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=le(this._passes);!(n=i()).done;){var o=n.value;o.resetUBOs(),o.resetTextures()}},n.setProperty=function(e,t,n){var i=!1;if(void 0===n)for(var o=this._passes,r=o.length,a=0;a<r;a++){var s=o[a];this._uploadProperty(s,e,t)&&(this._props[s.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,o=0;o<i;o++){var r=n[o];if(e in r)return r[e]}else{if(t>=this._props.length)return console.warn("illegal pass index: "+t+"."),null;var a=this._props[this._passes[t].propertyIndex];if(e in a)return a[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]=ne({},e._props[t]);this._defines.length=e._defines.length;for(var n=0;n<e._defines.length;n++)this._defines[n]=ne({},e._defines[n]);this._states.length=e._states.length;for(var i=0;i<e._states.length;i++)this._states[i]=ne({},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 o=0;o<n.length;++o)Object.assign(t[o]||(t[o]={}),n[o])},n._createPasses=function(){var e=this._effectAsset.techniques[this._techIdx||0];if(!e)return[];for(var t=e.passes.length,n=[],i=0;i<t;++i){var o=e.passes[i],r=o.passIndex=i,a=o.defines=this._defines[r]||(this._defines[r]={}),s=o.stateOverrides=this._states[r]||(this._states[r]={});if(void 0!==o.propertyIndex&&(Object.assign(a,this._defines[o.propertyIndex]),Object.assign(s,this._states[o.propertyIndex])),void 0!==o.embeddedMacros&&Object.assign(a,o.embeddedMacros),!o.switch||a[o.switch]){var l=new mm(c.director.root);l.initialize(o),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,o=le(this._passes);!(i=o()).done;)i.value.destroy();this._passes=this._createPasses();var r=this._effectAsset.techniques[this._techIdx].passes.length;if(this._props.length=r,e)this._passes.forEach((function(e,t){var i=n._props[t];for(var o in i||(i=n._props[t]={}),void 0!==e.propertyIndex&&Object.assign(i,n._props[e.propertyIndex]),i)n._uploadProperty(e,o,i[o])}));else for(var a=0;a<this._props.length;a++)this._props[a]={}}this._hash=t.getHash(this)},n._uploadProperty=function(e,t,n){var i=e.getHandle(t);if(!i)return!1;var o=mm.getPropertyTypeFromHandle(i);if(o===Lp.BUFFER)Array.isArray(n)?e.setUniformArray(i,n):null!==n?e.setUniform(i,n):e.resetUniform(t);else if(o===Lp.TEXTURE)if(Array.isArray(n))for(var r=0;r<n.length;r++)this._bindTexture(e,i,n[r],r);else n?this._bindTexture(e,i,n):e.resetTexture(t);return!0},n._bindTexture=function(e,t,n,i){var o=mm.getBindingFromHandle(t);if(n instanceof jc)e.bindTexture(o,n,i);else if(n instanceof Ed||n instanceof _E){var r=n.getGFXTexture();if(!r||!r.width||!r.height)return;e.bindTexture(o,r,i),e.bindSampler(o,n.getGFXSampler(),i)}},n._doDestroy=function(){if(this._passes&&this._passes.length)for(var e,t=le(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},n.initDefault=function(t){e.prototype.initDefault.call(this,t),this.initialize({effectName:"unlit",defines:{USE_COLOR:!0}}),this.setProperty("mainColor",new Pn("#ff00ff"))},n.validate=function(){return!!this._effectAsset&&!this._effectAsset.isDefault&&this.passes.length>0},te(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}(kf),iE=he((nE=cE).prototype,"_effectAsset",[eE],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),oE=he(nE.prototype,"_techIdx",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),rE=he(nE.prototype,"_defines",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),aE=he(nE.prototype,"_states",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),sE=he(nE.prototype,"_props",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),tE=nE))||tE));c.Material=fE;var dE=ct({Planar:0,ShadowMap:1}),pE=ct({HARD:0,FILTER_X5:1,FILTER_X9:2,FILTER_X25:3}),mE=dE.ShadowMap+1,vE=function(){function e(){this.sphere=new hs(0,0,0,.01),this.maxReceived=4,this._normal=new Rn(0,1,0),this._shadowColor=new Pn(0,0,0,76),this._matLight=new jn,this._material=null,this._instancingMaterial=null,this._size=new Kn(512,512),this._handle=bo,this._handle=Mr.alloc()}var t=e.prototype;return t.getPlanarShader=function(e){return this._material||(this._material=new fE,this._material.initialize({effectName:"planar-shadow"}),Mr.set(this._handle,Rr.PLANAR_PASS,this._material.passes[0].handle)),this._material.passes[0].getShaderVariant(e)},t.getPlanarInstanceShader=function(e){return this._instancingMaterial||(this._instancingMaterial=new fE,this._instancingMaterial.initialize({effectName:"planar-shadow",defines:{USE_INSTANCING:!0}}),Mr.set(this._handle,Rr.INSTANCE_PASS,this._instancingMaterial.passes[0].handle)),this._instancingMaterial.passes[0].getShaderVariant(e)},t.initialize=function(e){Mr.set(this._handle,Rr.TYPE,e.enabled?e.type:mE),Mr.set(this._handle,Rr.NEAR,e.near),Mr.set(this._handle,Rr.FAR,e.far),Mr.set(this._handle,Rr.ASPECT,e.aspect),Mr.set(this._handle,Rr.ORTHO_SIZE,e.orthoSize),this._size=e.shadowMapSize,Mr.setVec2(this._handle,Rr.SIZE,this._size),Mr.set(this._handle,Rr.PCF_TYPE,e.pcf),Rn.copy(this._normal,e.normal),Mr.setVec3(this._handle,Rr.NORMAL,this._normal),Mr.set(this._handle,Rr.DISTANCE,e.distance),this._shadowColor.set(e.shadowColor),Mr.setVec4(this._handle,Rr.COLOR,this._shadowColor),Mr.set(this._handle,Rr.BIAS,e.bias),Mr.set(this._handle,Rr.PACKING,e.packing?1:0),Mr.set(this._handle,Rr.LINEAR,e.linear?1:0),Mr.set(this._handle,Rr.SELF_SHADOW,e.selfShadow?1:0),Mr.set(this._handle,Rr.NORMAL_BIAS,e.normalBias),Mr.set(this._handle,Rr.ENABLE,e.enabled?1:0),this.maxReceived=e.maxReceived,Mr.set(this._handle,Rr.AUTO_ADAPT,e.autoAdapt?1:0)},t.activate=function(){if(this.enabled)this.type===dE.ShadowMap?this._updatePipeline():this._updatePlanarInfo();else{var e=c.director.root;e.pipeline.macros.CC_RECEIVE_SHADOW=0,e.onGlobalPipelineStateChanged()}},t._updatePlanarInfo=function(){this._material||(this._material=new fE,this._material.initialize({effectName:"planar-shadow"}),Mr.set(this._handle,Rr.PLANAR_PASS,this._material.passes[0].handle)),this._instancingMaterial||(this._instancingMaterial=new fE,this._instancingMaterial.initialize({effectName:"planar-shadow",defines:{USE_INSTANCING:!0}}),Mr.set(this._handle,Rr.INSTANCE_PASS,this._instancingMaterial.passes[0].handle));var e=c.director.root;e.pipeline.macros.CC_RECEIVE_SHADOW=0,e.onGlobalPipelineStateChanged()},t._updatePipeline=function(){var e=c.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&&(Mr.free(this._handle),this._handle=bo),this.sphere.destroy()},te(e,[{key:"enabled",get:function(){return!!Mr.get(this._handle,Rr.ENABLE)},set:function(e){Mr.set(this._handle,Rr.ENABLE,e?1:0),e||Mr.set(this._handle,Rr.TYPE,mE),this.activate()}},{key:"normal",get:function(){return this._normal},set:function(e){Rn.copy(this._normal,e),Mr.setVec3(this._handle,Rr.NORMAL,this._normal)}},{key:"distance",get:function(){return Mr.get(this._handle,Rr.DISTANCE)},set:function(e){Mr.set(this._handle,Rr.DISTANCE,e)}},{key:"shadowColor",get:function(){return this._shadowColor},set:function(e){this._shadowColor=e,Mr.setVec4(this._handle,Rr.COLOR,e)}},{key:"type",get:function(){return Mr.get(this._handle,Rr.TYPE)},set:function(e){Mr.set(this._handle,Rr.TYPE,this.enabled?e:mE),this.activate()}},{key:"near",get:function(){return Mr.get(this._handle,Rr.NEAR)},set:function(e){Mr.set(this._handle,Rr.NEAR,e)}},{key:"far",get:function(){return Mr.get(this._handle,Rr.FAR)},set:function(e){Mr.set(this._handle,Rr.FAR,e)}},{key:"aspect",get:function(){return Mr.get(this._handle,Rr.ASPECT)},set:function(e){Mr.set(this._handle,Rr.ASPECT,e)}},{key:"orthoSize",get:function(){return Mr.get(this._handle,Rr.ORTHO_SIZE)},set:function(e){Mr.set(this._handle,Rr.ORTHO_SIZE,e)}},{key:"size",get:function(){return this._size},set:function(e){this._size=e,Mr.setVec2(this._handle,Rr.SIZE,this._size)}},{key:"pcf",get:function(){return Mr.get(this._handle,Rr.PCF_TYPE)},set:function(e){Mr.set(this._handle,Rr.PCF_TYPE,e)}},{key:"shadowMapDirty",get:function(){return!!Mr.get(this._handle,Rr.SHADOW_MAP_DIRTY)},set:function(e){Mr.set(this._handle,Rr.SHADOW_MAP_DIRTY,e?1:0)}},{key:"bias",get:function(){return Mr.get(this._handle,Rr.BIAS)},set:function(e){Mr.set(this._handle,Rr.BIAS,e)}},{key:"packing",get:function(){return!!Mr.get(this._handle,Rr.PACKING)},set:function(e){Mr.set(this._handle,Rr.PACKING,e?1:0)}},{key:"linear",get:function(){return!!Mr.get(this._handle,Rr.LINEAR)},set:function(e){Mr.set(this._handle,Rr.LINEAR,e?1:0)}},{key:"selfShadow",get:function(){return!!Mr.get(this._handle,Rr.SELF_SHADOW)},set:function(e){Mr.set(this._handle,Rr.SELF_SHADOW,e?1:0)}},{key:"normalBias",get:function(){return Mr.get(this._handle,Rr.NORMAL_BIAS)},set:function(e){Mr.set(this._handle,Rr.NORMAL_BIAS,e)}},{key:"autoAdapt",get:function(){return!!Mr.get(this._handle,Rr.AUTO_ADAPT)},set:function(e){Mr.set(this._handle,Rr.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}}]),e}();vE.MAX_FAR=2e3,vE.COEFFICIENT_OF_EXPANSION=2*Math.sqrt(3),c.Shadows=vE;var gE=new Rn,yE=new Rn,xE=new Rn,EE=new jn,SE=new fu,TE=!1,AE=[],wE=hs.create(0,0,0,1),CE=new si((function(){return{model:null,depth:0}}),128),IE=new si((function(){return{model:null,depth:0}}),128);function PE(e,t){var n=0;e.node&&(Rn.subtract(gE,e.node.worldPosition,t.position),n=Rn.dot(gE,t.forward));var i=CE.alloc();return i.model=e,i.depth=n,i}function bE(e,t){var n=0;e.node&&(Rn.subtract(gE,e.node.worldPosition,t.position),n=Rn.dot(gE,t.forward));var i=IE.alloc();return i.model=e,i.depth=n,i}function RE(e,t,n,i){var o=e.pipelineSceneData.shadows;Rn.negate(yE,n);var r=o.sphere.radius*vE.COEFFICIENT_OF_EXPANSION;return Rn.multiplyScalar(xE,yE,r),Rn.add(xE,xE,o.sphere.center),i.set(xE),jn.fromRT(EE,t,xE),EE}function NE(e,t,n){var i=t.direction,o=e.normal,r=e.distance+.001,a=1/Rn.dot(o,i),s=i.x*a,c=i.y*a,l=i.z*a,u=o.x,h=o.y,_=o.z,f=e.matLight;f.m00=1-u*s,f.m01=-u*c,f.m02=-u*l,f.m03=0,f.m04=-h*s,f.m05=1-h*c,f.m06=-h*l,f.m07=0,f.m08=-_*s,f.m09=-_*c,f.m10=1-_*l,f.m11=0,f.m12=s*r,f.m13=c*r,f.m14=l*r,f.m15=1,jn.toArray(n,f,sh.MAT_LIGHT_PLANE_PROJ_OFFSET)}function OE(e,t){var n=t.scene,i=n.mainLight,o=e.pipelineSceneData,r=o.shadows,a=o.skybox,s=o.renderObjects;CE.freeArray(s),s.length=0;var c=null;TE=!1,r.enabled&&(e.pipelineUBO.updateShadowUBORange(sh.SHADOW_COLOR_OFFSET,r.shadowColor),r.type===dE.ShadowMap&&(c=e.pipelineSceneData.shadowObjects,IE.freeArray(c),c.length=0)),i&&r.type===dE.Planar&&function(e,t){var n=e.pipelineSceneData.shadows,i=t.direction,o=n.normal,r=n.distance+.001,a=1/Rn.dot(o,i),s=i.x*a,c=i.y*a,l=i.z*a,u=o.x,h=o.y,_=o.z,f=n.matLight;f.m00=1-u*s,f.m01=-u*c,f.m02=-u*l,f.m03=0,f.m04=-h*s,f.m05=1-h*c,f.m06=-h*l,f.m07=0,f.m08=-_*s,f.m09=-_*c,f.m10=1-_*l,f.m11=0,f.m12=s*r,f.m13=c*r,f.m14=l*r,f.m15=1,e.pipelineUBO.updateShadowUBORange(sh.MAT_LIGHT_PLANE_PROJ_OFFSET,n.matLight)}(e,i),a.enabled&&a.model&&t.clearFlag&T_&&s.push(PE(a.model,t));for(var l=n.models,u=0;u<l.length;u++){var h=l[u];if(h.enabled&&(h.node&&(t.visibility&h.node.layer)===h.node.layer||t.visibility&h.visFlags)){if(null!=c&&h.castShadow&&h.worldBounds&&(TE||(SE.copy(h.worldBounds),TE=!0),fu.merge(SE,SE,h.worldBounds),c.push(bE(h,t))),h.worldBounds&&!tu.aabbFrustum(h.worldBounds,t.frustum))continue;s.push(PE(h,t))}}SE&&fu.toBoundingSphere(r.sphere,SE)}var DE=new jn,ME=new jn,LE=new Rn,FE=new $n,zE=function(){function e(){this._globalUBO=new Float32Array(rh.COUNT),this._cameraUBO=new Float32Array(ah.COUNT),this._shadowUBO=new Float32Array(sh.COUNT)}e.updateGlobalUBOView=function(e,t){var n=e.device,i=c.director.root,o=t,r=Math.floor(n.width),a=Math.floor(n.height);o[rh.TIME_OFFSET]=i.cumulativeTime,o[rh.TIME_OFFSET+1]=i.frameTime,o[rh.TIME_OFFSET+2]=c.director.getTotalFrames(),o[rh.SCREEN_SIZE_OFFSET]=n.width,o[rh.SCREEN_SIZE_OFFSET+1]=n.height,o[rh.SCREEN_SIZE_OFFSET+2]=1/n.width,o[rh.SCREEN_SIZE_OFFSET+3]=1/n.height,o[rh.NATIVE_SIZE_OFFSET]=r,o[rh.NATIVE_SIZE_OFFSET+1]=a,o[rh.NATIVE_SIZE_OFFSET+2]=1/o[rh.NATIVE_SIZE_OFFSET],o[rh.NATIVE_SIZE_OFFSET+3]=1/o[rh.NATIVE_SIZE_OFFSET+1]},e.updateCameraUBOView=function(e,t,n){var i=e.device,o=(n.scene?n.scene:c.director.getScene().renderScene).mainLight,r=e.pipelineSceneData,a=r.ambient,s=r.fog,l=Math.floor(i.width),u=Math.floor(i.height),h=t,_=n.exposure,f=r.isHDR,d=r.shadingScale,p=r.fpScale;if(h[ah.SCREEN_SCALE_OFFSET]=n.width/l*d,h[ah.SCREEN_SCALE_OFFSET+1]=n.height/u*d,h[ah.SCREEN_SCALE_OFFSET+2]=1/h[ah.SCREEN_SCALE_OFFSET],h[ah.SCREEN_SCALE_OFFSET+3]=1/h[ah.SCREEN_SCALE_OFFSET+1],h[ah.EXPOSURE_OFFSET]=_,h[ah.EXPOSURE_OFFSET+1]=1/_,h[ah.EXPOSURE_OFFSET+2]=f?1:0,h[ah.EXPOSURE_OFFSET+3]=p/_,o){if(Rn.toArray(h,o.direction,ah.MAIN_LIT_DIR_OFFSET),Rn.toArray(h,o.color,ah.MAIN_LIT_COLOR_OFFSET),o.useColorTemperature){var m=o.colorTemperatureRGB;h[ah.MAIN_LIT_COLOR_OFFSET]*=m.x,h[ah.MAIN_LIT_COLOR_OFFSET+1]*=m.y,h[ah.MAIN_LIT_COLOR_OFFSET+2]*=m.z}h[ah.MAIN_LIT_COLOR_OFFSET+3]=f?o.illuminance*p:o.illuminance*_}else Rn.toArray(h,Rn.UNIT_Z,ah.MAIN_LIT_DIR_OFFSET),$n.toArray(h,$n.ZERO,ah.MAIN_LIT_COLOR_OFFSET);var v=a.colorArray;v[3]=f?a.skyIllum*p:a.skyIllum*_,h.set(v,ah.AMBIENT_SKY_OFFSET),h.set(a.albedoArray,ah.AMBIENT_GROUND_OFFSET),jn.toArray(h,n.matView,ah.MAT_VIEW_OFFSET),jn.toArray(h,n.node.worldMatrix,ah.MAT_VIEW_INV_OFFSET),Rn.toArray(h,n.position,ah.CAMERA_POS_OFFSET),jn.toArray(h,n.matProj,ah.MAT_PROJ_OFFSET),jn.toArray(h,n.matProjInv,ah.MAT_PROJ_INV_OFFSET),jn.toArray(h,n.matViewProj,ah.MAT_VIEW_PROJ_OFFSET),jn.toArray(h,n.matViewProjInv,ah.MAT_VIEW_PROJ_INV_OFFSET),h[ah.CAMERA_POS_OFFSET+3]=this.getCombineSignY(),h.set(s.colorArray,ah.GLOBAL_FOG_COLOR_OFFSET),h[ah.GLOBAL_FOG_BASE_OFFSET]=s.fogStart,h[ah.GLOBAL_FOG_BASE_OFFSET+1]=s.fogEnd,h[ah.GLOBAL_FOG_BASE_OFFSET+2]=s.fogDensity,h[ah.GLOBAL_FOG_ADD_OFFSET]=s.fogTop,h[ah.GLOBAL_FOG_ADD_OFFSET+1]=s.fogRange,h[ah.GLOBAL_FOG_ADD_OFFSET+2]=s.fogAtten},e.updateShadowUBOView=function(e,t,n){var i=e.device,o=n.scene.mainLight,r=e.pipelineSceneData.shadows,a=t;if(r.enabled){if(o&&r.type===dE.ShadowMap){var s,c=0,l=0,u=0;if(r.autoAdapt){s=RE(e,o.node.getWorldRotation(),o.direction,LE);var h=r.sphere.radius;c=h*r.aspect,l=h;var _=Rn.distance(r.sphere.center,LE);u=Math.min(_*vE.COEFFICIENT_OF_EXPANSION,vE.MAX_FAR)}else s=o.node.getWorldMatrix(),c=r.orthoSize*r.aspect,l=r.orthoSize,u=r.far;jn.toArray(a,s,sh.MAT_LIGHT_VIEW_OFFSET),jn.invert(DE,s),jn.ortho(ME,-c,c,-l,l,r.near,u,i.capabilities.clipSpaceMinZ,i.capabilities.clipSpaceSignY),jn.multiply(ME,ME,DE),jn.toArray(a,ME,sh.MAT_LIGHT_VIEW_PROJ_OFFSET);var f=d_(i),d=r.linear&&f?1:0;a[sh.SHADOW_NEAR_FAR_LINEAR_SELF_INFO_OFFSET+0]=r.near,a[sh.SHADOW_NEAR_FAR_LINEAR_SELF_INFO_OFFSET+1]=u,a[sh.SHADOW_NEAR_FAR_LINEAR_SELF_INFO_OFFSET+2]=d,a[sh.SHADOW_NEAR_FAR_LINEAR_SELF_INFO_OFFSET+3]=r.selfShadow?1:0,a[sh.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET+0]=r.size.x,a[sh.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET+1]=r.size.y,a[sh.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET+2]=r.pcf,a[sh.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET+3]=r.bias;var p=r.packing?1:f?0:1;a[sh.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET+0]=0,a[sh.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET+1]=p,a[sh.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET+2]=r.normalBias,a[sh.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET+3]=0}else o&&r.type===dE.Planar&&NE(r,o,a);Pn.toArray(a,r.shadowColor,sh.SHADOW_COLOR_OFFSET)}},e.updateShadowUBOLightView=function(e,t,n){var i,o=e.device,r=e.pipelineSceneData.shadows,a=t,s=d_(o),c=r.linear&&s?1:0,l=r.packing?1:s?0:1,u=0,h=0,_=0;switch(n.type){case gm.DIRECTIONAL:if(n.update(),r.autoAdapt){var f=n.node;f&&(i=RE(e,f.getWorldRotation(),n.direction,LE));var d=r.sphere.radius;u=d*r.aspect,h=d;var p=Rn.distance(r.sphere.center,LE);_=Math.min(p*vE.COEFFICIENT_OF_EXPANSION,vE.MAX_FAR)}else i=n.node.getWorldMatrix(),u=r.orthoSize*r.aspect,h=r.orthoSize,_=r.far;jn.toArray(a,i,sh.MAT_LIGHT_VIEW_OFFSET),jn.invert(DE,i),FE.set(r.near,_,c,r.selfShadow?1:0),$n.toArray(a,FE,sh.SHADOW_NEAR_FAR_LINEAR_SELF_INFO_OFFSET),FE.set(0,l,r.normalBias,0),$n.toArray(a,FE,sh.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET),jn.ortho(ME,-u,u,-h,h,r.near,_,o.capabilities.clipSpaceMinZ,o.capabilities.clipSpaceSignY);break;case gm.SPOT:jn.toArray(a,n.node.getWorldMatrix(),sh.MAT_LIGHT_VIEW_OFFSET),jn.invert(DE,n.node.getWorldMatrix()),FE.set(.01,n.range,c,r.selfShadow?1:0),$n.toArray(a,FE,sh.SHADOW_NEAR_FAR_LINEAR_SELF_INFO_OFFSET),FE.set(1,l,r.normalBias,0),$n.toArray(a,FE,sh.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET),jn.perspective(ME,n.spotAngle,n.aspect,.001,n.range)}jn.multiply(ME,ME,DE),jn.toArray(a,ME,sh.MAT_LIGHT_VIEW_PROJ_OFFSET),FE.set(r.size.x,r.size.y,r.pcf,r.bias),$n.toArray(a,FE,sh.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET),Pn.toArray(a,r.shadowColor,sh.SHADOW_COLOR_OFFSET)},e.getCombineSignY=function(){return e._combineSignY};var t=e.prototype;return t._initCombineSignY=function(){var t=this._device;e._combineSignY=.5*t.capabilities.screenSpaceSignY+.5<<1|.5*t.capabilities.clipSpaceSignY+.5},t.activate=function(e,t){this._device=e,this._pipeline=t;var n=this._pipeline.descriptorSet;this._initCombineSignY();var i=e.createBuffer(new Ps(La.UNIFORM|La.TRANSFER_DST,Ba.HOST|Ba.DEVICE,rh.SIZE,rh.SIZE));n.bindBuffer(rh.BINDING,i);var o=e.createBuffer(new Ps(La.UNIFORM|La.TRANSFER_DST,Ba.HOST|Ba.DEVICE,ah.SIZE,ah.SIZE));n.bindBuffer(ah.BINDING,o);var r=e.createBuffer(new Ps(La.UNIFORM|La.TRANSFER_DST,Ba.HOST|Ba.DEVICE,sh.SIZE,sh.SIZE));n.bindBuffer(sh.BINDING,r)},t.updateGlobalUBO=function(){var t=this._pipeline.descriptorSet,n=this._pipeline.commandBuffers;t.update(),e.updateGlobalUBOView(this._pipeline,this._globalUBO),n[0].updateBuffer(t.getBuffer(rh.BINDING),this._globalUBO)},t.updateCameraUBO=function(t){var n=this._pipeline.descriptorSet,i=this._pipeline.commandBuffers;e.updateCameraUBOView(this._pipeline,this._cameraUBO,t),i[0].updateBuffer(n.getBuffer(ah.BINDING),this._cameraUBO)},t.updateShadowUBO=function(t){var n=this._pipeline.pipelineSceneData;if(n.shadows.enabled){var i=this._pipeline.descriptorSet,o=this._pipeline.commandBuffers,r=n.shadowFrameBufferMap,a=t.scene.mainLight;i.update(),a&&r.has(a)&&i.bindTexture(ch,r.get(a).colorTextures[0]),e.updateShadowUBOView(this._pipeline,this._shadowUBO,t),o[0].updateBuffer(i.getBuffer(sh.BINDING),this._shadowUBO)}},t.updateShadowUBOLight=function(t){var n=this._pipeline.descriptorSet;e.updateShadowUBOLightView(this._pipeline,this._shadowUBO,t),n.getBuffer(sh.BINDING).update(this._shadowUBO)},t.updateShadowUBORange=function(e,t){t instanceof jn?jn.toArray(this._shadowUBO,t,e):t instanceof Pn&&Pn.toArray(this._shadowUBO,t,e)},t.destroy=function(){},e}();zE._combineSignY=0;var BE=ct({LINEAR:0,EXP:1,EXP_SQUARED:2,LAYERED:3}),UE=BE.LAYERED+1,HE=function(){function e(){this._fogColor=new Pn("#C8C8C8"),this._colorArray=new Float32Array([.2,.2,.2,1]),this._handle=bo,this._handle=Nr.alloc()}var t=e.prototype;return t.initialize=function(e){Nr.set(this._handle,Cr.ENABLE,e.enabled?1:0),Nr.set(this._handle,Cr.TYPE,e.enabled?e.type:UE),this._fogColor.set(e.fogColor),Pn.toArray(this._colorArray,this._fogColor),Nr.setVec4(this._handle,Cr.COLOR,this._fogColor),Nr.set(this._handle,Cr.DENSITY,e.fogDensity),Nr.set(this._handle,Cr.START,e.fogStart),Nr.set(this._handle,Cr.END,e.fogEnd),Nr.set(this._handle,Cr.ATTEN,e.fogAtten),Nr.set(this._handle,Cr.TOP,e.fogTop),Nr.set(this._handle,Cr.RANGE,e.fogRange)},t.activate=function(){this._updatePipeline()},t._updatePipeline=function(){var e=c.director.root,t=this.enabled?this.type:UE,n=e.pipeline;n.macros.CC_USE_FOG!==t&&(n.macros.CC_USE_FOG=t,e.onGlobalPipelineStateChanged())},t.destroy=function(){this._handle&&(Nr.free(this._handle),this._handle=bo)},te(e,[{key:"enabled",get:function(){return Nr.get(this._handle,Cr.ENABLE)},set:function(e){Nr.set(this._handle,Cr.ENABLE,e?1:0),e||Nr.set(this._handle,Cr.TYPE,UE),e?this.activate():this._updatePipeline()}},{key:"fogColor",get:function(){return this._fogColor},set:function(e){this._fogColor.set(e),Pn.toArray(this._colorArray,this._fogColor),Nr.setVec4(this._handle,Cr.COLOR,this._fogColor)}},{key:"type",get:function(){return Nr.get(this._handle,Cr.TYPE)},set:function(e){Nr.set(this._handle,Cr.TYPE,this.enabled?e:UE),this.enabled&&this._updatePipeline()}},{key:"fogDensity",get:function(){return Nr.get(this._handle,Cr.DENSITY)},set:function(e){Nr.set(this._handle,Cr.DENSITY,e)}},{key:"fogStart",get:function(){return Nr.get(this._handle,Cr.START)},set:function(e){Nr.set(this._handle,Cr.START,e)}},{key:"fogEnd",get:function(){return Nr.get(this._handle,Cr.END)},set:function(e){Nr.set(this._handle,Cr.END,e)}},{key:"fogAtten",get:function(){return Nr.get(this._handle,Cr.ATTEN)},set:function(e){Nr.set(this._handle,Cr.ATTEN,e)}},{key:"fogTop",get:function(){return Nr.get(this._handle,Cr.TOP)},set:function(e){Nr.set(this._handle,Cr.TOP,e)}},{key:"fogRange",get:function(){return Nr.get(this._handle,Cr.RANGE)},set:function(e){Nr.set(this._handle,Cr.RANGE,e)}},{key:"colorArray",get:function(){return this._colorArray}},{key:"handle",get:function(){return this._handle}}]),e}();c.Fog=HE;var GE=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 o=0;o<i._shaderInfo.blocks.length;o++){var r=i._shaderInfo.blocks[o],a=i._blocks[r.binding],s=i._parent.blocks[r.binding];a.set(s)}i._rootBufferDirty=!0;for(var c=i._parent,l=0;l<i._shaderInfo.samplerTextures.length;l++)for(var u=i._shaderInfo.samplerTextures[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(se(i)),i}ie(t,e);var n=t.prototype;return n.overridePipelineStates=function(e,t){this._bs.reset(),this._rs.reset(),this._dss.reset(),mm.fillPipelineInfo(this,e),mm.fillPipelineInfo(this,t),this._onStateChange()},n.tryCompile=function(t){if(t&&!Zp(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,qo.set(this._handle,Po.BATCHING_SCHEME,0)},n._onStateChange=function(){qo.set(this._handle,Po.HASH,mm.getPassHash(this,this._hShaderDefault)),this._owner.onPassStateChange(this._dontNotify)},te(t,[{key:"parent",get:function(){return this._parent}}]),t}(mm),VE=e("d6",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}ie(t,e);var n=t.prototype;return n.recompileShaders=function(e,t){if(this._passes&&this.effectAsset)if(void 0===t)for(var n,i=le(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 o=this._passes[i],r=this._states[i]||(this._states[i]={});for(var a in e)r[a]=e[a];o.overridePipelineStates(n[o.passIndex],r)}else{var s=this._states[t]||(this._states[t]={});for(var c in e)s[c]=e[c];this._passes[t].overridePipelineStates(n[t],s)}}},n.destroy=function(){return this._doDestroy(),!0},n.onPassStateChange=function(e){this._hash=fE.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 GE(t[n],this));return e},te(t,[{key:"parent",get:function(){return this._parent}},{key:"owner",get:function(){return this._owner}}]),t}(fE)),kE=null,WE=null,jE=function(){function e(){this._envmap=null,this._globalDescriptorSet=null,this._model=null,this._default=null,this._handle=bo,this._handle=Pr.alloc()}var t=e.prototype;return t.initialize=function(e){Pr.set(this._handle,Ar.ENABLE,e.enabled?1:0),Pr.set(this._handle,Ar.USE_IBL,e.useIBL?1:0),Pr.set(this._handle,Ar.IS_RGBE,e.isRGBE?1:0),this._envmap=e.envmap},t.activate=function(){var e=c.director.root.pipeline,t=e.pipelineSceneData.ambient;if(this._globalDescriptorSet=e.descriptorSet,this._default=hm.get("default-cube-texture"),this._model||(this._model=c.director.root.createModel(c.renderer.scene.Model),this._model._initLocalDescriptors=function(){}),Pr.set(this._handle,Ar.MODEL,this._model.handle),this._envmap||(this._envmap=this._default),t.albedoArray[3]=this._envmap.mipmapLevel,WE)WE.recompileShaders({USE_RGBE_CUBEMAP:this.isRGBE});else{var n=new fE;n.initialize({effectName:"skybox",defines:{USE_RGBE_CUBEMAP:this.isRGBE}}),WE=new VE({parent:n})}this.enabled&&(kE||(kE=c.utils.createMesh(c.primitives.box({width:2,height:2,length:2}))),this._model.initSubModel(0,kE.renderingSubMeshes[0],WE)),this._updateGlobalBinding(),this._updatePipeline()},t._updatePipeline=function(){var e=this.useIBL?this.isRGBE?2:1:0,t=c.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=yd.getSampler(c.director._device,this.envmap.getSamplerHash());this._globalDescriptorSet.bindSampler(Ch,t),this._globalDescriptorSet.bindTexture(Ch,e)},t.destroy=function(){this._handle&&(Pr.free(this._handle),this._handle=bo)},te(e,[{key:"model",get:function(){return this._model}},{key:"enabled",get:function(){return Pr.get(this._handle,Ar.ENABLE)},set:function(e){e?this.activate():this._updatePipeline(),Pr.set(this._handle,Ar.ENABLE,e?1:0)}},{key:"useIBL",get:function(){return Pr.get(this._handle,Ar.USE_IBL)},set:function(e){Pr.set(this._handle,Ar.USE_IBL,e?1:0),this._updatePipeline()}},{key:"isRGBE",get:function(){return Pr.get(this._handle,Ar.IS_RGBE)},set:function(e){e&&(WE&&WE.recompileShaders({USE_RGBE_CUBEMAP:e}),this._model&&this._model.setSubModelMaterial(0,WE)),Pr.set(this._handle,Ar.IS_RGBE,e?1:0),this._updatePipeline()}},{key:"envmap",get:function(){return this._envmap},set:function(e){this._envmap=e||this._default,this._envmap&&(c.director.root.pipeline.pipelineSceneData.ambient.albedoArray[3]=this._envmap.mipmapLevel,this._updateGlobalBinding())}},{key:"handle",get:function(){return this._handle}}]),e}();c.Skybox=jE;var qE,YE,XE,KE,QE,ZE,JE,$E,eS,tS,nS,iS=function(){function e(){this.fog=new HE,this.ambient=new aa,this.skybox=new jE,this.shadows=new vE,this.renderObjects=[],this.shadowObjects=[],this.shadowFrameBufferMap=new Map,this._handle=zr.alloc(),zr.set(this._handle,Dr.AMBIENT,this.ambient.handle),zr.set(this._handle,Dr.SKYBOX,this.skybox.handle),zr.set(this._handle,Dr.FOG,this.fog.handle),zr.set(this._handle,Dr.SHADOW,this.shadows.handle),zr.set(this._handle,Dr.IS_HDR,0),zr.set(this._handle,Dr.SHADING_SCALE,1),zr.set(this._handle,Dr.FP_SCALE,1/1024)}var t=e.prototype;return t.initDeferredPassInfo=function(){var e=hm.get("builtin-deferred-material");if(e){var t=e.passes[0];t.beginChangeStatesSilently(),t.tryCompile(),t.endChangeStatesSilently()}var n=hm.get("builtin-post-process-material");if(n){var i=n.passes[0];i.beginChangeStatesSilently(),i.tryCompile(),i.endChangeStatesSilently()}if(e){var o=e.passes[0];zr.set(this._handle,Dr.DEFERRED_LIGHT_PASS,o.handle),zr.set(this._handle,Dr.DEFERRED_LIGHT_PASS_SHADER,o.getShaderVariant())}if(n){var r=n.passes[0];zr.set(this._handle,Dr.DEFERRED_POST_PASS,r.handle),zr.set(this._handle,Dr.DEFERRED_POST_PASS_SHADER,r.getShaderVariant())}},t.activate=function(e,t){return this._device=e,this._pipeline=t,this.initDeferredPassInfo(),!0},t.destroy=function(){this.ambient.destroy(),this.skybox.destroy(),this.fog.destroy(),this.shadows.destroy(),this._handle&&zr.free(this._handle)},te(e,[{key:"handle",get:function(){return this._handle}},{key:"isHDR",get:function(){return zr.get(this._handle,Dr.IS_HDR)},set:function(e){zr.set(this._handle,Dr.IS_HDR,e?1:0)}},{key:"shadingScale",get:function(){return zr.get(this._handle,Dr.SHADING_SCALE)},set:function(e){zr.set(this._handle,Dr.SHADING_SCALE,e)}},{key:"fpScale",get:function(){return zr.get(this._handle,Dr.FP_SCALE)},set:function(e){zr.set(this._handle,Dr.FP_SCALE,e)}},{key:"deferredLightPassHandle",get:function(){return zr.get(this._handle,Dr.DEFERRED_LIGHT_PASS)}},{key:"deferredLightPassShaderHandle",get:function(){return zr.get(this._handle,Dr.DEFERRED_LIGHT_PASS_SHADER)}},{key:"deferredPostPassHandle",get:function(){return zr.get(this._handle,Dr.DEFERRED_POST_PASS)}},{key:"deferredPostPassShaderHandle",get:function(){return zr.get(this._handle,Dr.DEFERRED_POST_PASS_SHADER)}}]),e}(),oS=e("fs",(qE=L_("cc.RenderPipeline"),YE=rf(),XE=rf(),KE=hf([Ux]),qE((eS=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return ue(t=e.call.apply(e,[this].concat(i))||this,"_tag",JE,se(t)),ue(t,"_flows",$E,se(t)),t._commandBuffers=[],t._pipelineUBO=new zE,t._pipelineSceneData=new iS,t._macros={},t._constantMacros="",t}ie(t,e);var n=t.prototype;return n.initialize=function(e){return this._flows=e.flows,e.tag&&(this._tag=e.tag),!0},n.generateRenderArea=function(e){var t=new gs,n=e.viewport,i=this.pipelineSceneData,o=e.window.hasOnScreenAttachments&&this.device.surfaceTransform%2?e.height:e.width,r=e.window.hasOnScreenAttachments&&this.device.surfaceTransform%2?e.width:e.height;return t.x=n.x*o,t.y=n.y*r,t.width=n.width*o*i.shadingScale,t.height=n.height*r*i.shadingScale,t},n.activate=function(){this._device=c.director.root.device;var e=new nc(Qu.bindings);this._descriptorSetLayout=this._device.createDescriptorSetLayout(e),this._descriptorSet=this._device.createDescriptorSet(new ic(this._descriptorSetLayout)),this._pipelineUBO.activate(this._device,this),this._pipelineSceneData.activate(this._device,this);for(var t=0;t<this._flows.length;t++)this._flows[t].activate(this);return this._macros.CC_USE_HDR=this._pipelineSceneData.isHDR,this._generateConstantMacros(),!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,this._pipelineUBO.destroy(),this._pipelineSceneData.destroy(),e.prototype.destroy.call(this)},n.resize=function(){},n._generateConstantMacros=function(){var e="";e+="#define CC_DEVICE_SUPPORT_FLOAT_TEXTURE "+(this.device.hasFeature(Na.TEXTURE_FLOAT)?1:0)+"\n",e+="#define CC_DEVICE_MAX_VERTEX_UNIFORM_VECTORS "+this.device.capabilities.maxVertexUniformVectors+"\n",e+="#define CC_DEVICE_MAX_FRAGMENT_UNIFORM_VECTORS "+this.device.capabilities.maxFragmentUniformVectors+"\n",this._constantMacros=e},te(t,[{key:"tag",get:function(){return this._tag}},{key:"flows",get:function(){return this._flows}},{key:"constantMacros",get:function(){return this._constantMacros}},{key:"macros",get:function(){return this._macros}},{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}},{key:"pipelineUBO",get:function(){return this._pipelineUBO}},{key:"pipelineSceneData",get:function(){return this._pipelineSceneData}}]),t}(kf),JE=he((ZE=eS).prototype,"_tag",[YE,H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),$E=he(ZE.prototype,"_flows",[XE,KE,H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),QE=ZE))||QE));c.RenderPipeline=oS,function(e){e[e.FORWARD=10]="FORWARD",e[e.UI=20]="UI"}(tS||(tS={})),function(e){e[e.SHADOW=0]="SHADOW",e[e.FORWARD=1]="FORWARD",e[e.UI=10]="UI"}(nS||(nS={}));var rS,aS,sS,cS,lS,uS,hS,_S,fS,dS,pS,mS,vS,gS,yS,xS,ES,SS,TS,AS,wS,CS,IS,PS,bS,RS,NS,OS,DS,MS,LS,FS,zS,BS,US,HS,GS,VS,kS,WS,jS,qS,YS,XS,KS,QS,ZS,JS,$S,eT,tT,nT,iT,oT,rT,aT,sT,cT,lT,uT,hT,_T,fT,dT,pT,mT,vT,gT,yT,xT,ET,ST,TT,AT,wT,CT,IT,PT,bT,RT,NT=e("fH",function(){function e(){}return e.getOrCreatePipelineState=function(e,t,n,i,o){var r=t.handle,a=qo.get(r,Po.HASH)^i.hash^o.attributesHash^n.id,s=this._PSOHashMap.get(a);if(!s){var c=Do.get(qo.get(r,Po.PIPELINE_LAYOUT)),l=new rc(o.attributes),u=new Uc(n,c,i,l,t.rasterizerState,t.depthStencilState,t.blendState,qo.get(r,Po.PRIMITIVE),qo.get(r,Po.DYNAMIC_STATES));s=e.createPipelineState(u),this._PSOHashMap.set(a,s)}return s},e}());NT._PSOHashMap=new Map,ht(Ua),ht(Ha),ht(Ja),ht(Za),ht($a),function(e){e[e.SCENE=0]="SCENE",e[e.POSTPROCESS=1]="POSTPROCESS",e[e.UI=2]="UI"}(RT||(RT={})),ht(RT),rS=L_("RenderTextureDesc"),aS=hf(Ua),sS=hf(Ha),cS=hf(Oa),rS((uS=he((lS=function(){ue(this,"name",uS,this),ue(this,"type",hS,this),ue(this,"usage",_S,this),ue(this,"format",fS,this),ue(this,"width",dS,this),ue(this,"height",pS,this)}).prototype,"name",[H_,K_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),hS=he(lS.prototype,"type",[aS],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Ua.TEX2D}}),_S=he(lS.prototype,"usage",[sS],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Ha.COLOR_ATTACHMENT}}),fS=he(lS.prototype,"format",[cS],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Oa.UNKNOWN}}),dS=he(lS.prototype,"width",[H_,K_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return-1}}),pS=he(lS.prototype,"height",[H_,K_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return-1}}),lS));var OT,DT=(mS=L_("RenderTextureConfig"),vS=hf(_E),mS((xS=he((yS=function(){ue(this,"name",xS,this),ue(this,"texture",ES,this)}).prototype,"name",[H_,K_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),ES=he(yS.prototype,"texture",[vS],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),gS=yS))||gS),MT=(SS=L_("MaterialConfig"),TS=hf(fE),SS((CS=he((wS=function(){ue(this,"name",CS,this),ue(this,"material",IS,this)}).prototype,"name",[H_,K_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),IS=he(wS.prototype,"material",[TS],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),AS=wS))||AS),LT=(PS=L_("FrameBufferDesc"),bS=hf([Bt]),RS=hf(_E),PS((OS=he((NS=function(){ue(this,"name",OS,this),ue(this,"renderPass",DS,this),ue(this,"colorTextures",MS,this),ue(this,"depthStencilTexture",LS,this),ue(this,"texture",FS,this)}).prototype,"name",[H_,K_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),DS=he(NS.prototype,"renderPass",[H_,K_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),MS=he(NS.prototype,"colorTextures",[bS],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),LS=he(NS.prototype,"depthStencilTexture",[H_,K_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),FS=he(NS.prototype,"texture",[RS],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),NS)),zS=L_("ColorDesc"),BS=hf(Oa),US=hf(Za),HS=hf(Ja),GS=hf([$a]),VS=hf([$a]),zS((jS=he((WS=function(){ue(this,"format",jS,this),ue(this,"loadOp",qS,this),ue(this,"storeOp",YS,this),ue(this,"sampleCount",XS,this),ue(this,"beginAccesses",KS,this),ue(this,"endAccesses",QS,this)}).prototype,"format",[BS],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Oa.UNKNOWN}}),qS=he(WS.prototype,"loadOp",[US],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Za.CLEAR}}),YS=he(WS.prototype,"storeOp",[HS],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Ja.STORE}}),XS=he(WS.prototype,"sampleCount",[H_,K_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),KS=he(WS.prototype,"beginAccesses",[GS],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),QS=he(WS.prototype,"endAccesses",[VS],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[$a.PRESENT]}}),kS=WS))||kS),FT=(ZS=L_("DepthStencilDesc"),JS=hf(Oa),$S=hf(Za),eT=hf(Ja),tT=hf(Za),nT=hf(Ja),iT=hf([$a]),oT=hf([$a]),ZS((sT=he((aT=function(){ue(this,"format",sT,this),ue(this,"depthLoadOp",cT,this),ue(this,"depthStoreOp",lT,this),ue(this,"stencilLoadOp",uT,this),ue(this,"stencilStoreOp",hT,this),ue(this,"sampleCount",_T,this),ue(this,"beginAccesses",fT,this),ue(this,"endAccesses",dT,this)}).prototype,"format",[JS],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Oa.UNKNOWN}}),cT=he(aT.prototype,"depthLoadOp",[$S],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Za.CLEAR}}),lT=he(aT.prototype,"depthStoreOp",[eT],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Ja.STORE}}),uT=he(aT.prototype,"stencilLoadOp",[tT],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Za.CLEAR}}),hT=he(aT.prototype,"stencilStoreOp",[nT],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Ja.STORE}}),_T=he(aT.prototype,"sampleCount",[H_,K_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),fT=he(aT.prototype,"beginAccesses",[iT],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),dT=he(aT.prototype,"endAccesses",[oT],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[$a.DEPTH_STENCIL_ATTACHMENT_WRITE]}}),rT=aT))||rT);pT=L_("RenderPassDesc"),mT=hf([LT]),vT=hf(FT),pT((yT=he((gT=function(){ue(this,"index",yT,this),ue(this,"colorAttachments",xT,this),ue(this,"depthStencilAttachment",ET,this)}).prototype,"index",[H_,K_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return-1}}),xT=he(gT.prototype,"colorAttachments",[mT],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),ET=he(gT.prototype,"depthStencilAttachment",[vT],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new FT}}),gT)),function(e){e[e.FRONT_TO_BACK=0]="FRONT_TO_BACK",e[e.BACK_TO_FRONT=1]="BACK_TO_FRONT"}(OT||(OT={})),ht(OT);var zT=(ST=L_("RenderQueueDesc"),TT=hf(OT),AT=hf([Bt]),ST((IT=he((CT=function(){ue(this,"isTransparent",IT,this),ue(this,"sortMode",PT,this),ue(this,"stages",bT,this)}).prototype,"isTransparent",[H_,K_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),PT=he(CT.prototype,"sortMode",[TT],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return OT.FRONT_TO_BACK}}),bT=he(CT.prototype,"stages",[AT],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),wT=CT))||wT);function BT(e,t){return e.hash-t.hash||e.depth-t.depth||e.shaderId-t.shaderId}function UT(e,t){return e.hash-t.hash||t.depth-e.depth||e.shaderId-t.shaderId}var HT=function(){function e(e){this.queue=void 0,this._passDesc=void 0,this._passPool=void 0,this._passDesc=e,this._passPool=new ci((function(){return{hash:0,depth:0,shaderId:0,subModel:null,passIdx:0}}),64),this.queue=new li(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],o=Ko.get(i.handle,Wo.PASS_0+n);if(i.passes[n].blendState.targets[0].blend!==this._passDesc.isTransparent||!(qo.get(o,Po.PHASE)&this._passDesc.phases))return!1;var r=0|qo.get(o,Po.PRIORITY)<<16|i.priority<<8|n,a=this._passPool.add();return a.hash=r,a.depth=e.depth||0,a.shaderId=Ko.get(i.handle,Wo.SHADER_0+n),a.subModel=i,a.passIdx=n,this.queue.push(a),!0},t.sort=function(){this.queue.sort()},t.recordCommandBuffer=function(e,t,n){for(var i=0;i<this.queue.length;++i){var o=this.queue.array[i],r=o.subModel,a=o.passIdx,s=r.inputAssembler,c=r.handle,l=r.passes[a],u=Ro.get(Ko.get(c,Wo.SHADER_0+a)),h=NT.getOrCreatePipelineState(e,l,u,t,s);n.bindPipelineState(h),n.bindDescriptorSet(th.MATERIAL,l.descriptorSet),n.bindDescriptorSet(th.LOCAL,r.descriptorSet),n.bindInputAssembler(s),n.draw(s)}},e}();function GT(e){for(var t=0,n=0;n<e.stages.length;n++)t|=_m(e.stages[n]);var i=BT;switch(e.sortMode){case OT.BACK_TO_FRONT:i=UT;break;case OT.FRONT_TO_BACK:i=BT}return new HT({isTransparent:e.isTransparent,phases:t,sortFunc:i})}function VT(e){e.clear()}function kT(e){e.sort()}function WT(e,t){e.x=t.x*t.x,e.y=t.y*t.y,e.z=t.z*t.z}var jT=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 o=n.value.batches[i];if(o.mergeCount){for(var r=0;r<o.vbs.length;++r)o.vbs[r].update(o.vbDatas[r]);e.updateBuffer(o.vbIdx,o.vbIdxData.buffer),e.updateBuffer(o.ubo,o.uboData)}}n=t.next()}},t.recordCommandBuffer=function(e,t,n){for(var i=this.queue.values(),o=i.next();!o.done;){for(var r=!1,a=0;a<o.value.batches.length;++a){var s=o.value.batches[a];if(s.mergeCount){if(!r){var c=Ro.get(s.hShader),l=NT.getOrCreatePipelineState(e,s.pass,c,t,s.ia);n.bindPipelineState(l),n.bindDescriptorSet(th.MATERIAL,s.pass.descriptorSet),r=!0}n.bindDescriptorSet(th.LOCAL,s.descriptorSet,o.value.dynamicOffsets),n.bindInputAssembler(s.ia),n.draw(s.ia)}}o=i.next()}},e}(),qT=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(),o=i.next();!o.done;){var r=o.value,a=r.instances,s=r.pass;if(r.hasPendingModels){n.bindDescriptorSet(th.MATERIAL,s.descriptorSet);for(var c=null,l=0;l<a.length;++l){var u=a[l];if(u.count){var h=Ro.get(u.hShader),_=NT.getOrCreatePipelineState(e,s,h,t,u.ia);c!==_&&(n.bindPipelineState(_),c=_),n.bindDescriptorSet(th.LOCAL,No.get(u.hDescriptorSet),o.value.dynamicOffsets),n.bindInputAssembler(u.ia),n.draw(u.ia)}}}o=i.next()}},e}(),YT=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 o=i.get(t);return o[n]||(o[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 o=0,r=0,a=i[0].count,s=e.passes[t],c=Ko.get(e.handle,Wo.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<Mh.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],v=_.vbDatas[d];(o=(a+_.vbCount)*p.stride)>m.size&&(m.resize(o),_.vbDatas[d]=new Uint8Array(o),_.vbDatas[d].set(v)),_.vbDatas[d].set(p.buffer,_.vbCount*p.stride)}var g=_.vbIdxData;(r=4*(a+_.vbCount))>_.vbIdx.size&&(_.vbIdx.resize(r),_.vbIdxData=new Float32Array(r/Float32Array.BYTES_PER_ELEMENT),_.vbIdxData.set(g),g=_.vbIdxData);var y=_.vbCount,x=y+a,E=_.mergeCount;if(g[y]!==E||g[x-1]!==E)for(var S=y;S<x;S++)g[S]=E+.1;return jn.toArray(_.uboData,n.transform.worldMatrix,Mh.MAT_WORLDS_OFFSET+16*_.mergeCount),_.mergeCount||(l.bindBuffer(Mh.BINDING,_.ubo),l.update(),_.pass=s,_.hShader=c,_.descriptorSet=l),++_.mergeCount,_.vbCount+=a,void(_.ia.vertexCount+=a)}}}for(var T=[],A=[],w=[],C=0;C<i.length;++C){var I=i[C],P=this._device.createBuffer(new Ps(La.VERTEX|La.TRANSFER_DST,Ba.HOST|Ba.DEVICE,I.count*I.stride,I.stride));P.update(I.buffer.buffer),T.push(P),A.push(new Uint8Array(P.size)),w.push(P)}var b=this._device.createBuffer(new Ps(La.VERTEX|La.TRANSFER_DST,Ba.HOST|Ba.DEVICE,4*a,4)),R=new Float32Array(a);R.fill(0),b.update(R),w.push(b);for(var N=e.inputAssembler.attributes,O=new Array(N.length+1),D=0;D<N.length;++D)O[D]=N[D];O[N.length]=new js("a_dyn_batch_id",Oa.R32F,!1,i.length);var M=new Ys(O,w),L=this._device.createInputAssembler(M),F=this._device.createBuffer(new Ps(La.UNIFORM|La.TRANSFER_DST,Ba.HOST|Ba.DEVICE,Mh.SIZE,Mh.SIZE));l.bindBuffer(Mh.BINDING,F),l.update();var z=new Float32Array(Mh.COUNT);jn.toArray(z,n.transform.worldMatrix,Mh.MAT_WORLDS_OFFSET),this.batches.push({mergeCount:1,vbs:T,vbDatas:A,vbIdx:b,vbIdxData:R,vbCount:a,ia:L,ubo:F,uboData:z,pass:s,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}();YT._buffers=new Map;var XT=e("fG",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 o=i.get(t);return o[n]||(o[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,i){void 0===i&&(i=null);var o=t.buffer.length;if(o){var r=e.inputAssembler,a=e.descriptorSet.getTexture(e_),s=i;s||(s=Ko.get(e.handle,Wo.SHADER_0+n));for(var c=Ko.get(e.handle,Wo.DESCRIPTOR_SET),l=0;l<this.instances.length;++l){var u=this.instances[l];if(!(u.ia.indexBuffer!==r.indexBuffer||u.count>=1024)&&u.lightingMap===a){if(u.stride!==o)return;if(u.count>=u.capacity){u.capacity<<=1;var h=u.stride*u.capacity,_=u.data;u.data=new Uint8Array(h),u.data.set(_),u.vb.resize(h)}return u.hShader!==s&&(u.hShader=s),u.hDescriptorSet!==c&&(u.hDescriptorSet=c),u.data.set(t.buffer,u.stride*u.count++),void(this.hasPendingModels=!0)}}for(var f=this._device.createBuffer(new Ps(La.VERTEX|La.TRANSFER_DST,Ba.HOST|Ba.DEVICE,32*o,o)),d=new Uint8Array(32*o),p=r.vertexBuffers.slice(),m=r.attributes.slice(),v=r.indexBuffer,g=0;g<t.attributes.length;g++){var y=t.attributes[g],x=new js(y.name,y.format,y.isNormalized,p.length,!0);m.push(x)}d.set(t.buffer),p.push(f);var E=new Ys(m,p,v),S=this._device.createInputAssembler(E);this.instances.push({count:1,capacity:32,vb:f,data:d,ia:S,stride:o,hShader:s,hDescriptorSet:c,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}());XT._buffers=new Map;var KT=[ka.LINEAR,ka.LINEAR,ka.NONE,Wa.CLAMP,Wa.CLAMP,Wa.CLAMP],QT=new si((function(){return{subModel:null,passIdx:-1,dynamicOffsets:[],lights:[]}}),16),ZT=new Float32Array(4),JT=hs.create(0,0,0,1),$T=[],eA=[],tA=new jn,nA=new jn;function iA(e,t){return!(!t.worldBounds||tu.aabbWithAABB(t.worldBounds,e.aabb))}function oA(e,t){return!(!t.worldBounds||tu.aabbWithAABB(t.worldBounds,e.aabb)&&tu.aabbFrustum(t.worldBounds,e.frustum))}var rA=_m("forward-add"),aA=[];function sA(e,t){t.length=0;for(var n=!1,i=0;i<e.length;i++){for(var o=e[i].passes,r=-1,a=0;a<o.length;a++)if(o[a].phase===rA){r=a,n=!0;break}t.push(r)}return n}var cA,lA,uA,hA,_A,fA,dA,pA,mA,vA,gA,yA=function(){function e(e){this._pipeline=void 0,this._device=void 0,this._validLights=[],this._lightPasses=[],this._descriptorSetMap=new Map,this._shadowUBO=new Float32Array(sh.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._instancedQueue=void 0,this._batchedQueue=void 0,this._lightMeterScale=1e4,this._sampler=null,this._pipeline=e,this._device=e.device,this._instancedQueue=new qT,this._batchedQueue=new jT;var t=this._device.capabilities.uboOffsetAlignment;this._lightBufferStride=Math.ceil(Lh.SIZE/t)*t,this._lightBufferElementCount=this._lightBufferStride/Float32Array.BYTES_PER_ELEMENT,this._lightBuffer=this._device.createBuffer(new Ps(La.UNIFORM|La.TRANSFER_DST,Ba.HOST|Ba.DEVICE,this._lightBufferStride*this._lightBufferCount,this._lightBufferStride)),this._firstLightBufferView=this._device.createBuffer(new bs(this._lightBuffer,0,Lh.SIZE)),this._lightBufferData=new Float32Array(this._lightBufferElementCount*this._lightBufferCount);var n=rd(KT);this._sampler=yd.getSampler(this._device,n)}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}QT.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(rh.BINDING).destroy(),n.getBuffer(sh.BINDING).destroy(),n.getSampler(ch).destroy(),n.getSampler(bh).destroy(),n.getTexture(ch).destroy(),n.getTexture(bh).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=this._pipeline.pipelineSceneData.renderObjects,o=0;o<i.length;o++){var r=i[o].model,a=r.subModels;if(sA(a,aA)&&(eA.length=0,this._lightCulling(r,n),eA.length))for(var s=0;s<a.length;s++){var c=aA[s];if(!(c<0)){var l=a[s],u=l.passes[c];l.descriptorSet.bindBuffer(Lh.BINDING,this._firstLightBufferView),l.descriptorSet.update(),this._addRenderQueue(u,l,r,c,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 o=this._lightPasses[i],r=o.subModel,a=o.passIdx,s=o.dynamicOffsets,c=o.lights,l=Ro.get(Ko.get(r.handle,Wo.SHADER_0+a)),u=r.passes[a],h=r.inputAssembler,_=NT.getOrCreatePipelineState(e,u,l,t,h),f=No.get(qo.get(u.handle,Po.DESCRIPTOR_SET)),d=r.descriptorSet;n.bindPipelineState(_),n.bindDescriptorSet(th.MATERIAL,f),n.bindInputAssembler(h);for(var p=0;p<s.length;++p){var m=c[p],v=this._getOrCreateDescriptorSet(m);$T[0]=s[p],n.bindDescriptorSet(th.GLOBAL,v),n.bindDescriptorSet(th.LOCAL,d,$T),n.draw(h)}}},t._gatherValidLights=function(e,t){for(var n=e.scene.sphereLights,i=0;i<n.length;i++){var o=n[i];o.baked||(hs.set(JT,o.position.x,o.position.y,o.position.z,o.range),tu.sphereFrustum(JT,e.frustum)&&(t.push(o),this._getOrCreateDescriptorSet(o)))}for(var r=e.scene.spotLights,a=0;a<r.length;a++){var s=r[a];s.baked||(hs.set(JT,s.position.x,s.position.y,s.position.z,s.range),tu.sphereFrustum(JT,e.frustum)&&(t.push(s),this._getOrCreateDescriptorSet(s)))}},t._lightCulling=function(e,t){for(var n=0;n<t.length;n++){var i=t[n],o=!1;switch(i.type){case gm.SPHERE:o=iA(i,e);break;case gm.SPOT:o=oA(i,e)}o||eA.push(n)}},t._addRenderQueue=function(e,t,n,i,o){var r=e.batchingScheme;if(r===cm.INSTANCING)for(var a=0;a<eA.length;a++){var s=eA[a],c=XT.get(e,s);c.merge(t,n.instancedAttributes,i),c.dynamicOffsets[0]=this._lightBufferStride*s,this._instancedQueue.queue.add(c)}else if(r===cm.VB_MERGING)for(var l=0;l<eA.length;l++){var u=eA[l],h=YT.get(e,u);h.merge(t,i,n),h.dynamicOffsets[0]=this._lightBufferStride*u,this._batchedQueue.queue.add(h)}else{var _=QT.alloc();_.subModel=t,_.passIdx=i;for(var f=0;f<eA.length;f++){var d=eA[f];_.lights.push(o[d]),_.dynamicOffsets.push(this._lightBufferStride*d)}this._lightPasses.push(_)}},t._updateLightDescriptorSet=function(e,t){for(var n=this._pipeline.device,i=this._pipeline.pipelineSceneData,o=i.shadows,r=i.shadowFrameBufferMap,a=e.scene.mainLight,s=d_(n),c=o.linear&&s?1:0,l=o.packing?1:s?0:1,u=0;u<this._validLights.length;u++){var h=this._validLights[u],_=this._getOrCreateDescriptorSet(h);if(_){switch(h.type){case gm.SPHERE:a&&NE(o,a,this._shadowUBO),this._shadowUBO[sh.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET+0]=o.size.x,this._shadowUBO[sh.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET+1]=o.size.y,this._shadowUBO[sh.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET+2]=o.pcf,this._shadowUBO[sh.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET+3]=o.bias,this._shadowUBO[sh.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET+0]=2,this._shadowUBO[sh.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET+1]=l,this._shadowUBO[sh.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET+2]=o.normalBias,this._shadowUBO[sh.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET+3]=0,Pn.toArray(this._shadowUBO,o.shadowColor,sh.SHADOW_COLOR_OFFSET);break;case gm.SPOT:if(a&&NE(o,a,this._shadowUBO),jn.toArray(this._shadowUBO,h.node.getWorldMatrix(),sh.MAT_LIGHT_VIEW_OFFSET),jn.invert(tA,h.node.getWorldMatrix()),jn.perspective(nA,h.spotAngle,h.aspect,.001,h.range),jn.multiply(nA,nA,tA),jn.toArray(this._shadowUBO,nA,sh.MAT_LIGHT_VIEW_PROJ_OFFSET),this._shadowUBO[sh.SHADOW_NEAR_FAR_LINEAR_SELF_INFO_OFFSET+0]=.01,this._shadowUBO[sh.SHADOW_NEAR_FAR_LINEAR_SELF_INFO_OFFSET+1]=h.range,this._shadowUBO[sh.SHADOW_NEAR_FAR_LINEAR_SELF_INFO_OFFSET+2]=c,this._shadowUBO[sh.SHADOW_NEAR_FAR_LINEAR_SELF_INFO_OFFSET+3]=o.selfShadow?1:0,this._shadowUBO[sh.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET+0]=o.size.x,this._shadowUBO[sh.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET+1]=o.size.y,this._shadowUBO[sh.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET+2]=o.pcf,this._shadowUBO[sh.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET+3]=o.bias,this._shadowUBO[sh.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET+0]=1,this._shadowUBO[sh.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET+1]=l,this._shadowUBO[sh.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET+2]=o.normalBias,this._shadowUBO[sh.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET+3]=0,Pn.toArray(this._shadowUBO,o.shadowColor,sh.SHADOW_COLOR_OFFSET),r.has(h)&&r.has(h)){var f,d=null===(f=r.get(h))||void 0===f?void 0:f.colorTextures[0];d&&_.bindTexture(bh,d)}}_.update(),t.updateBuffer(_.getBuffer(sh.BINDING),this._shadowUBO)}}},t._updateUBOs=function(e,t){var n=e.exposure,i=this._pipeline.pipelineSceneData,o=i.isHDR,r=i.fpScale;this._validLights.length>this._lightBufferCount&&(this._firstLightBufferView.destroy(),this._lightBufferCount=En(this._validLights.length),this._lightBuffer.resize(this._lightBufferStride*this._lightBufferCount),this._lightBufferData=new Float32Array(this._lightBufferElementCount*this._lightBufferCount),this._firstLightBufferView.initialize(new bs(this._lightBuffer,0,Lh.SIZE)));for(var a=0,s=0;a<this._validLights.length;a++,s+=this._lightBufferElementCount){var c=this._validLights[a];switch(c.type){case gm.SPHERE:if(Rn.toArray(ZT,c.position),ZT[3]=0,this._lightBufferData.set(ZT,s+Lh.LIGHT_POS_OFFSET),ZT[0]=c.size,ZT[1]=c.range,ZT[2]=0,this._lightBufferData.set(ZT,s+Lh.LIGHT_SIZE_RANGE_ANGLE_OFFSET),Rn.toArray(ZT,c.color),c.useColorTemperature){var l=c.colorTemperatureRGB;ZT[0]*=l.x,ZT[1]*=l.y,ZT[2]*=l.z}ZT[3]=o?c.luminance*r*this._lightMeterScale:c.luminance*n*this._lightMeterScale,this._lightBufferData.set(ZT,s+Lh.LIGHT_COLOR_OFFSET);break;case gm.SPOT:if(Rn.toArray(ZT,c.position),ZT[3]=1,this._lightBufferData.set(ZT,s+Lh.LIGHT_POS_OFFSET),ZT[0]=c.size,ZT[1]=c.range,ZT[2]=c.spotAngle,this._lightBufferData.set(ZT,s+Lh.LIGHT_SIZE_RANGE_ANGLE_OFFSET),Rn.toArray(ZT,c.direction),this._lightBufferData.set(ZT,s+Lh.LIGHT_DIR_OFFSET),Rn.toArray(ZT,c.color),c.useColorTemperature){var u=c.colorTemperatureRGB;ZT[0]*=u.x,ZT[1]*=u.y,ZT[2]*=u.z}ZT[3]=o?c.luminance*r*this._lightMeterScale:c.luminance*n*this._lightMeterScale,this._lightBufferData.set(ZT,s+Lh.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 ic(this._pipeline.descriptorSetLayout));n.bindBuffer(rh.BINDING,this._pipeline.descriptorSet.getBuffer(rh.BINDING)),n.bindBuffer(ah.BINDING,this._pipeline.descriptorSet.getBuffer(ah.BINDING));var i=t.createBuffer(new Ps(La.UNIFORM|La.TRANSFER_DST,Ba.HOST|Ba.DEVICE,sh.SIZE,sh.SIZE));return n.bindBuffer(sh.BINDING,i),n.bindSampler(ch,this._sampler),n.bindTexture(ch,hm.get("default-texture").getGFXTexture()),n.bindSampler(bh,this._sampler),n.bindTexture(bh,hm.get("default-texture").getGFXTexture()),n.update(),this._descriptorSetMap.set(e,n),n}return this._descriptorSetMap.get(e)},e}(),xA=new fu,EA=function(){function e(e){this._pendingModels=[],this._instancedQueue=new qT,this._pipeline=void 0,this._pipeline=e}var t=e.prototype;return t.gatherShadowPasses=function(e,t){var n=this._pipeline.pipelineSceneData,i=this._pipeline.pipelineUBO,o=n.shadows;if(this._instancedQueue.clear(),this._pendingModels.length=0,o.enabled&&o.type===dE.Planar){i.updateShadowUBO(e);var r=e.scene,a=e.frustum,s=0!=(e.visibility&Vu.BitMask.DEFAULT);if(r.mainLight&&s){var c=n.renderObjects,l=XT.get(o.instancingMaterial.passes[0]);this._instancedQueue.queue.add(l);for(var u=0;u<c.length;u++){var h=c[u].model;if(h.enabled&&h.node&&h.castShadow&&(!h.worldBounds||(fu.transform(xA,h.worldBounds,o.matLight),tu.aabbFrustum(xA,a))))if(h.isInstancingEnabled)for(var _=h.subModels,f=0;f<_.length;f++){var d=_[f];l.merge(d,h.instancedAttributes,0,d.planarInstanceShaderHandle)}else this._pendingModels.push(h)}this._instancedQueue.uploadBuffers(t)}}},t.recordCommandBuffer=function(e,t,n){var i=this._pipeline.pipelineSceneData.shadows;if(i.enabled&&i.type===dE.Planar&&(this._instancedQueue.recordCommandBuffer(e,t,n),this._pendingModels.length)){var o=i.material.passes[0],r=No.get(qo.get(o.handle,Po.DESCRIPTOR_SET));n.bindDescriptorSet(th.MATERIAL,r);for(var a=this._pendingModels.length,s=0;s<a;s++)for(var c=this._pendingModels[s],l=0;l<c.subModels.length;l++){var u=c.subModels[l],h=Ro.get(u.planarShaderHandle),_=u.inputAssembler,f=NT.getOrCreatePipelineState(e,o,h,t,_);n.bindPipelineState(f),n.bindDescriptorSet(th.LOCAL,u.descriptorSet),n.bindInputAssembler(_),n.draw(_)}}},e}(),SA=function(){function e(){this._phaseID=_m("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,o=n.commandBuffers[0],r=e.scene.batches,a=0;a<r.length;a++){var s=r[a],c=!1;if(e.visibility&s.visFlags&&(c=!0),c)for(var l=s.handle,u=tr.get(l,Qo.PASS_COUNT),h=0;h<u;h++){var _=s.passes[h];if(_.phase===this._phaseID){var f=tr.get(l,Qo.SHADER_0+h),d=Ro.get(f),p=Oo.get(s.hInputAssembler),m=No.get(s.hDescriptorSet),v=NT.getOrCreatePipelineState(i,_,d,t,p);o.bindPipelineState(v),o.bindDescriptorSet(th.MATERIAL,_.descriptorSet),o.bindDescriptorSet(th.LOCAL,m),o.bindInputAssembler(p),o.draw(p)}}}},e}(),TA=[new Cs(0,0,0,1)],AA=e("fx",(cA=L_("ForwardStage"),lA=hf([zT]),uA=rf(),cA((pA=dA=function(e){function t(){var t;return ue(t=e.call(this)||this,"renderQueues",fA,se(t)),t._renderQueues=[],t._renderArea=new gs,t._batchedQueue=void 0,t._instancedQueue=void 0,t._phaseID=_m("default"),t._clearFlag=4294967295,t._batchedQueue=new jT,t._instancedQueue=new qT,t._uiPhase=new SA,t}ie(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++)this._renderQueues[i]=GT(this.renderQueues[i]);this._additiveLightQueue=new yA(this._pipeline),this._planarQueue=new EA(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(VT);for(var i=t.pipelineSceneData.renderObjects,o=0,r=0,a=0,s=0;s<i.length;++s){var c=i[s],l=c.model.subModels;for(o=0;o<l.length;++o){var u=l[o],h=u.passes;for(r=0;r<h.length;++r){var _=h[r];if(_.phase===this._phaseID){var f=_.batchingScheme;if(f===cm.INSTANCING){var d=XT.get(_);d.merge(u,c.model.instancedAttributes,r),this._instancedQueue.queue.add(d)}else if(f===cm.VB_MERGING){var p=YT.get(_);p.merge(u,r,c.model),this._batchedQueue.queue.add(p)}else for(a=0;a<this._renderQueues.length;a++)this._renderQueues[a].insertRenderPass(c,o,r)}}}}this._renderQueues.forEach(kT);var m=t.commandBuffers[0];this._instancedQueue.uploadBuffers(m),this._batchedQueue.uploadBuffers(m),this._additiveLightQueue.gatherLightPasses(e,m),this._planarQueue.gatherShadowPasses(e,m);var v=t.pipelineSceneData;if(this._renderArea=t.generateRenderArea(e),e.clearFlag&us.COLOR)if(v.isHDR){WT(TA[0],e.clearColor);var g=v.fpScale/e.exposure;TA[0].x*=g,TA[0].y*=g,TA[0].z*=g}else TA[0].x=e.clearColor.x,TA[0].y=e.clearColor.y,TA[0].z=e.clearColor.z;TA[0].w=e.clearColor.w;var y=e.window.framebuffer,x=y.colorTextures[0]?y.renderPass:t.getRenderPass(e.clearFlag&this._clearFlag);m.beginRenderPass(x,y,this._renderArea,TA,e.clearDepth,e.clearStencil),m.bindDescriptorSet(th.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()},t}(Rx),dA.initInfo={name:"ForwardStage",priority:tS.FORWARD,tag:0,renderQueues:[{isTransparent:!1,sortMode:OT.FRONT_TO_BACK,stages:["default"]},{isTransparent:!0,sortMode:OT.BACK_TO_FRONT,stages:["default","planarShadow"]}]},fA=he((_A=pA).prototype,"renderQueues",[lA,H_,uA],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),hA=_A))||hA)),wA=e("fw",L_("ForwardFlow")((gA=vA=function(e){function t(){return e.apply(this,arguments)||this}ie(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 AA;n.initialize(AA.initInfo),this._stages.push(n)}return!0},n.activate=function(t){e.prototype.activate.call(this,t)},n.render=function(t){e.prototype.render.call(this,t)},n.destroy=function(){e.prototype.destroy.call(this)},t}(Ux),vA.initInfo={name:Yu,priority:nS.FORWARD,stages:[]},mA=gA))||mA),CA=_m("shadow-caster"),IA=[];function PA(e,t){t.length=0;for(var n=!1,i=0;i<e.length;i++){for(var o=e[i].passes,r=-1,a=0;a<o.length;a++)if(o[a].phase===CA){r=a,n=!0;break}t.push(r)}return n}var bA,RA,NA,OA,DA,MA,LA,FA,zA,BA,UA,HA,GA,VA,kA,WA,jA,qA,YA,XA,KA,QA,ZA,JA,$A,ew,tw=function(){function e(e){this._pipeline=void 0,this._subModelsArray=[],this._passArray=[],this._shaderArray=[],this._instancedQueue=void 0,this._batchedQueue=void 0,this._pipeline=e,this._instancedQueue=new qT,this._batchedQueue=new jT}var t=e.prototype;return t.gatherLightPasses=function(e,t){this.clear();var n=this._pipeline.pipelineSceneData.shadows,i=this._pipeline.pipelineSceneData.shadowObjects;if(e&&n.enabled&&n.type===dE.ShadowMap){this._pipeline.pipelineUBO.updateShadowUBOLight(e);for(var o=0;o<i.length;o++){var r=i[o].model;if(PA(r.subModels,IA))switch(e.type){case gm.DIRECTIONAL:this.add(r,t,IA);break;case gm.SPOT:if(r.worldBounds&&(!tu.aabbWithAABB(r.worldBounds,e.aabb)||!tu.aabbFrustum(r.worldBounds,e.frustum)))continue;this.add(r,t,IA)}}}},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,o=0;o<i.length;o++){var r=i[o],a=n[o],s=r.passes[a];if(s.batchingScheme===cm.INSTANCING){var c=XT.get(s);c.merge(r,e.instancedAttributes,a),this._instancedQueue.queue.add(c)}else if(s.batchingScheme===cm.VB_MERGING){var l=YT.get(s);l.merge(r,a,e),this._batchedQueue.queue.add(l)}else{var u=Ro.get(Ko.get(r.handle,Wo.SHADER_0+a));this._subModelsArray.push(r),this._shaderArray.push(u),this._passArray.push(s)}}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 o=this._subModelsArray[i],r=this._shaderArray[i],a=this._passArray[i],s=o.inputAssembler,c=NT.getOrCreatePipelineState(e,a,r,t,s),l=a.descriptorSet;n.bindPipelineState(c),n.bindDescriptorSet(th.MATERIAL,l),n.bindDescriptorSet(th.LOCAL,o.descriptorSet),n.bindInputAssembler(s),n.draw(s)}},e}(),nw=[new Cs(1,1,1,1)],iw=e("fF",L_("ShadowStage")((NA=RA=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return(t=e.call.apply(e,[this].concat(i))||this)._shadowFrameBuffer=null,t._renderArea=new gs,t._light=null,t}ie(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){nw[0].w=e.clearColor.w;var t=this._pipeline.commandBuffers[0],n=this._shadowFrameBuffer.renderPass;t.beginRenderPass(n,this._shadowFrameBuffer,this._renderArea,nw,e.clearDepth,e.clearStencil),t.endRenderPass()}},n.render=function(e){var t=this._pipeline,n=t.pipelineSceneData,i=n.shadows,o=n.shadingScale,r=t.commandBuffers[0];if(this._light&&this._shadowFrameBuffer){this._additiveShadowQueue.gatherLightPasses(this._light,r);var a=e.viewport,s=i.size;this._renderArea.x=a.x*s.x,this._renderArea.y=a.y*s.y,this._renderArea.width=a.width*s.x*o,this._renderArea.height=a.height*s.y*o;var c=t.device,l=this._shadowFrameBuffer.renderPass;r.beginRenderPass(l,this._shadowFrameBuffer,this._renderArea,nw,e.clearDepth,e.clearStencil),r.bindDescriptorSet(th.GLOBAL,t.descriptorSet),this._additiveShadowQueue.recordCommandBuffer(c,l,r),r.endRenderPass()}},n.activate=function(t,n){e.prototype.activate.call(this,t,n),this._additiveShadowQueue=new tw(t)},t}(Rx),RA.initInfo={name:"ShadowStage",priority:tS.FORWARD,tag:0},bA=NA))||bA),ow=e("fE",L_("ShadowFlow")((MA=DA=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return(t=e.call.apply(e,[this].concat(i))||this)._shadowRenderPass=null,t}ie(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 iw;n.initialize(iw.initInfo),this._stages.push(n)}return!0},n.render=function(e){var t=this._pipeline,n=t.pipelineSceneData.shadows,i=t.pipelineSceneData.shadowFrameBufferMap,o=t.pipelineSceneData.shadowObjects;if(n.enabled&&n.type===dE.ShadowMap){var r=function(e,t){AE.length=0;var n=e.scene;AE.push(n.mainLight);for(var i=n.spotLights,o=0;o<i.length;o++){var r=i[o];hs.set(wE,r.position.x,r.position.y,r.position.z,r.range),tu.sphereFrustum(wE,e.frustum)&&t>AE.length&&AE.push(r)}return AE}(e,n.maxReceived);if(0!==o.length){for(var a=0;a<r.length;a++){var s=r[a];i.has(s)||this._initShadowFrameBuffer(t,s);var c=i.get(s);n.shadowMapDirty&&this.resizeShadowMap(s,n);for(var l=0;l<this._stages.length;l++){var u=this._stages[l];u.setUsage(s,c),u.render(e)}}t.pipelineUBO.updateShadowUBO(e)}else this.clearShadowMap(r,e)}},n.destroy=function(){e.prototype.destroy.call(this);for(var t=this._pipeline.pipelineSceneData.shadowFrameBufferMap,n=Array.from(t.values()),i=0;i<n.length;i++){var o=n[i];if(o){for(var r=o.colorTextures,a=0;a<r.length;a++){var s=r[i];s&&s.destroy()}r.length=0;var c=o.depthStencilTexture;c&&c.destroy(),o.destroy()}}t.clear(),this._shadowRenderPass&&this._shadowRenderPass.destroy()},n._initShadowFrameBuffer=function(e,t){var n=e.device,i=e.pipelineSceneData.shadows,o=i.size,r=e.pipelineSceneData.shadowFrameBufferMap,a=d_(n)?i.packing?Oa.RGBA8:Oa.RGBA16F:Oa.RGBA8;if(!this._shadowRenderPass){var s=new Xs;s.format=a,s.loadOp=Za.CLEAR,s.storeOp=Ja.STORE,s.sampleCount=1;var c=new Ks;c.format=n.depthStencilFormat,c.depthLoadOp=Za.CLEAR,c.depthStoreOp=Ja.DISCARD,c.stencilLoadOp=Za.CLEAR,c.stencilStoreOp=Ja.DISCARD,c.sampleCount=1;var l=new Zs([s],c);this._shadowRenderPass=n.createRenderPass(l)}var u=[];u.push(n.createTexture(new Ds(Ua.TEX2D,Ha.COLOR_ATTACHMENT|Ha.SAMPLED,a,o.x,o.y)));var h=n.createTexture(new Ds(Ua.TEX2D,Ha.DEPTH_STENCIL_ATTACHMENT,n.depthStencilFormat,o.x,o.y)),_=n.createFramebuffer(new ec(this._shadowRenderPass,u,h));r.set(t,_)},n.clearShadowMap=function(e,t){for(var n=this._pipeline.pipelineSceneData,i=0;i<e.length;i++){var o=e[i],r=n.shadowFrameBufferMap.get(o);if(n.shadowFrameBufferMap.has(o))for(var a=0;a<this._stages.length;a++){var s=this._stages[a];s.setUsage(o,r),s.clearFramebuffer(t)}}},n.resizeShadowMap=function(e,t){var n=t.size.x,i=t.size.y,o=this._pipeline,r=o.device,a=o.pipelineSceneData.shadowFrameBufferMap,s=d_(r)?t.packing?Oa.RGBA8:Oa.RGBA16F:Oa.RGBA8;if(a.has(e)){var c=a.get(e);if(!c)return;var l=[];l.push(o.device.createTexture(new Ds(Ua.TEX2D,Ha.COLOR_ATTACHMENT|Ha.SAMPLED,s,n,i)));var u=c.depthStencilTexture;u&&u.resize(n,i);var h=c.renderPass;c.destroy(),c.initialize(new ec(h,l,u))}t.shadowMapDirty=!1},t}(Ux),DA.initInfo={name:Xu,priority:nS.SHADOW,tag:RT.SCENE,stages:[]},OA=MA))||OA),rw=[ka.LINEAR,ka.LINEAR,ka.NONE,Wa.CLAMP,Wa.CLAMP,Wa.CLAMP],aw=e("fv",(LA=L_("ForwardPipeline"),FA=hf([DT]),zA=rf(),BA=hf([MT]),UA=rf(),LA((WA=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return ue(t=e.call.apply(e,[this].concat(i))||this,"renderTextures",VA,se(t)),ue(t,"materials",kA,se(t)),t._renderPasses=new Map,t}ie(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 ow;n.initialize(ow.initInfo),this._flows.push(n);var i=new wA;i.initialize(wA.initInfo),this._flows.push(i)}return!0},n.activate=function(){return!(!e.prototype.activate.call(this)||!this._activeRenderer()&&(N(2402),1))},n.render=function(e){this._commandBuffers[0].begin(),this._pipelineUBO.updateGlobalUBO();for(var t=0;t<e.length;t++){var n=e[t];if(n.scene){OE(this,n),this._pipelineUBO.updateCameraUBO(n);for(var i=0;i<this._flows.length;i++)this._flows[i].render(n)}}this._commandBuffers[0].end(),this._device.flushCommands(this._commandBuffers),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 Xs,o=new Ks;i.format=n.colorFormat,o.format=n.depthStencilFormat,o.stencilStoreOp=Ja.DISCARD,o.depthStoreOp=Ja.DISCARD,e&us.COLOR||(e&T_?i.loadOp=Za.DISCARD:(i.loadOp=Za.LOAD,i.beginAccesses=[$a.PRESENT])),(e&us.DEPTH_STENCIL)!==us.DEPTH_STENCIL&&(e&us.DEPTH||(o.depthLoadOp=Za.LOAD),e&us.STENCIL||(o.stencilLoadOp=Za.LOAD),o.beginAccesses=[$a.DEPTH_STENCIL_ATTACHMENT_WRITE]);var r=new Zs([i],o);return t=n.createRenderPass(r),this._renderPasses.set(e,t),t},n._activeRenderer=function(){var e=this.device;this._commandBuffers.push(e.commandBuffer);var t=rd(rw),n=yd.getSampler(e,t);return this._descriptorSet.bindSampler(ch,n),this._descriptorSet.bindTexture(ch,hm.get("default-texture").getGFXTexture()),this._descriptorSet.bindSampler(bh,n),this._descriptorSet.bindTexture(bh,hm.get("default-texture").getGFXTexture()),this._descriptorSet.update(),!0},n.destroyUBOs=function(){this._descriptorSet&&(this._descriptorSet.getBuffer(rh.BINDING).destroy(),this._descriptorSet.getBuffer(sh.BINDING).destroy(),this._descriptorSet.getBuffer(ah.BINDING).destroy(),this._descriptorSet.getSampler(ch).destroy(),this._descriptorSet.getSampler(bh).destroy(),this._descriptorSet.getTexture(ch).destroy(),this._descriptorSet.getTexture(bh).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,e.prototype.destroy.call(this)},t}(oS),VA=he((GA=WA).prototype,"renderTextures",[FA,H_,zA],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),kA=he(GA.prototype,"materials",[BA,H_,UA],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),HA=GA))||HA));!function(e){e[e.GBUFFER=10]="GBUFFER",e[e.LIGHTING=15]="LIGHTING",e[e.TRANSPARENT=18]="TRANSPARENT",e[e.POSTPROCESS=19]="POSTPROCESS",e[e.UI=20]="UI"}(jA||(jA={})),function(e){e[e.SHADOW=0]="SHADOW",e[e.GBUFFER=1]="GBUFFER",e[e.LIGHTING=5]="LIGHTING",e[e.UI=10]="UI"}(qA||(qA={}));var sw,cw,lw,uw,hw,_w,fw,dw,pw,mw,vw,gw,yw,xw,Ew,Sw,Tw,Aw,ww,Cw,Iw,Pw,bw,Rw,Nw,Ow,Dw,Mw,Lw,Fw,zw,Bw,Uw,Hw,Gw,Vw=[new Cs(0,0,0,0),new Cs(0,0,0,0),new Cs(0,0,0,0),new Cs(0,0,0,0)],kw=e("fA",(YA=L_("GbufferStage"),XA=hf([zT]),KA=rf(),YA((ew=$A=function(e){function t(){var t;return ue(t=e.call(this)||this,"renderQueues",JA,se(t)),t._renderQueues=[],t._renderArea=new gs,t._batchedQueue=void 0,t._instancedQueue=void 0,t._phaseID=_m("deferred"),t._batchedQueue=new jT,t._instancedQueue=new qT,t}ie(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++)this._renderQueues[i]=GT(this.renderQueues[i])},n.destroy=function(){},n.render=function(e){this._instancedQueue.clear(),this._batchedQueue.clear();var t=this._pipeline,n=t.device;this._renderQueues.forEach(VT);var i=t.pipelineSceneData.renderObjects;if(0!==i.length){for(var o=0,r=0,a=0,s=0;s<i.length;++s){var c=i[s],l=c.model.subModels;for(o=0;o<l.length;++o){var u=l[o],h=u.passes;for(r=0;r<h.length;++r){var _=h[r];if(_.phase===this._phaseID){var f=_.batchingScheme;if(f===cm.INSTANCING){var d=XT.get(_);d.merge(u,c.model.instancedAttributes,r),this._instancedQueue.queue.add(d)}else if(f===cm.VB_MERGING){var p=YT.get(_);p.merge(u,r,c.model),this._batchedQueue.queue.add(p)}else for(a=0;a<this._renderQueues.length;a++)this._renderQueues[a].insertRenderPass(c,o,r)}}}}this._renderQueues.forEach(kT);var m=t.commandBuffers[0];if(this._instancedQueue.uploadBuffers(m),this._batchedQueue.uploadBuffers(m),this._renderArea=t.generateRenderArea(e),t.updateQuadVertexData(this._renderArea),e.clearFlag&us.COLOR)if(t.pipelineSceneData.isHDR){WT(Vw[0],e.clearColor);var v=t.pipelineSceneData.fpScale/e.exposure;Vw[0].x*=v,Vw[0].y*=v,Vw[0].z*=v}else Vw[0].x=e.clearColor.x,Vw[0].y=e.clearColor.y,Vw[0].z=e.clearColor.z;Vw[0].w=e.clearColor.w;var g=t.getDeferredRenderData(e).gbufferFrameBuffer,y=g.renderPass;m.beginRenderPass(y,g,this._renderArea,Vw,e.clearDepth,e.clearStencil),m.bindDescriptorSet(th.GLOBAL,t.descriptorSet);for(var x=0;x<this.renderQueues.length;x++)this._renderQueues[x].recordCommandBuffer(n,y,m);this._instancedQueue.recordCommandBuffer(n,y,m),this._batchedQueue.recordCommandBuffer(n,y,m),m.endRenderPass()}},t}(Rx),$A.initInfo={name:"GbufferStage",priority:jA.GBUFFER,tag:0,renderQueues:[{isTransparent:!1,sortMode:OT.FRONT_TO_BACK,stages:["default"]},{isTransparent:!0,sortMode:OT.BACK_TO_FRONT,stages:["default"]}]},JA=he((ZA=ew).prototype,"renderQueues",[XA,H_,KA],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),QA=ZA))||QA)),Ww=e("fz",L_("GbufferFlow")((lw=cw=function(e){function t(){return e.apply(this,arguments)||this}ie(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 kw;n.initialize(kw.initInfo),this._stages.push(n)}return!0},n.activate=function(t){e.prototype.activate.call(this,t)},n.render=function(t){e.prototype.render.call(this,t)},n.destroy=function(){e.prototype.destroy.call(this)},t}(Ux),cw.initInfo={name:ju,priority:qA.GBUFFER,stages:[]},sw=lw))||sw),jw=[new Cs(0,0,0,1)],qw=e("fC",(uw=L_("LightingStage"),hw=hf(fE),_w=rf(),fw=hf([zT]),dw=rf(),uw((xw=yw=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return(t=e.call.apply(e,[this].concat(i))||this)._deferredLitsBufs=null,t._maxDeferredLights=Fh.LIGHTS_PER_PASS,t._lightMeterScale=1e4,t._descriptorSet=null,t._renderArea=new gs,ue(t,"_deferredMaterial",vw,se(t)),ue(t,"renderQueues",gw,se(t)),t._phaseID=_m("default"),t._defPhaseID=_m("deferred"),t._renderQueues=[],t}ie(t,e);var n=t.prototype;return n.initialize=function(t){return e.prototype.initialize.call(this,t),!0},n.gatherLights=function(e){for(var t=this._pipeline,n=t.commandBuffers[0],i=e.scene.sphereLights,o=e.scene.spotLights,r=hs.create(0,0,0,1),a=new Float32Array(4),s=e.exposure,c=0,l=$n.length,u=l*this._maxDeferredLights,h=0;h<i.length&&c<this._maxDeferredLights;h++,++c){var _=i[h];if(hs.set(r,_.position.x,_.position.y,_.position.z,_.range),tu.sphereFrustum(r,e.frustum)){if(Rn.toArray(a,_.position),a[3]=0,this._lightBufferData.set(a,c*l),Rn.toArray(a,_.color),_.useColorTemperature){var f=_.colorTemperatureRGB;a[0]*=f.x,a[1]*=f.y,a[2]*=f.z}t.pipelineSceneData.isHDR?a[3]=_.luminance*t.pipelineSceneData.fpScale*this._lightMeterScale:a[3]=_.luminance*s*this._lightMeterScale,this._lightBufferData.set(a,c*l+1*u),a[0]=_.size,a[1]=_.range,a[2]=0,this._lightBufferData.set(a,c*l+2*u)}}for(var d=0;d<o.length&&c<this._maxDeferredLights;d++,++c){var p=o[d];if(hs.set(r,p.position.x,p.position.y,p.position.z,p.range),tu.sphereFrustum(r,e.frustum)){if(Rn.toArray(a,p.position),a[3]=1,this._lightBufferData.set(a,c*l+0*u),Rn.toArray(a,p.color),p.useColorTemperature){var m=p.colorTemperatureRGB;a[0]*=m.x,a[1]*=m.y,a[2]*=m.z}t.pipelineSceneData.isHDR?a[3]=p.luminance*t.pipelineSceneData.fpScale*this._lightMeterScale:a[3]=p.luminance*s*this._lightMeterScale,this._lightBufferData.set(a,c*l+1*u),a[0]=p.size,a[1]=p.range,a[2]=p.spotAngle,this._lightBufferData.set(a,c*l+2*u),Rn.toArray(a,p.direction),this._lightBufferData.set(a,c*l+3*u)}}var v=3*u+3;this._lightBufferData.set([c],v),n.updateBuffer(this._deferredLitsBufs,this._lightBufferData)},n.activate=function(t,n){e.prototype.activate.call(this,t,n);for(var i=t.device,o=0;o<this.renderQueues.length;o++)this._renderQueues[o]=GT(this.renderQueues[o]);var r=16*Float32Array.BYTES_PER_ELEMENT*this._maxDeferredLights;r=Math.ceil(r/i.capabilities.uboOffsetAlignment)*i.capabilities.uboOffsetAlignment,this._deferredLitsBufs=i.createBuffer(new Ps(La.UNIFORM|La.TRANSFER_DST,Ba.HOST|Ba.DEVICE,r,i.capabilities.uboOffsetAlignment));var a=i.createBuffer(new bs(this._deferredLitsBufs,0,r));this._lightBufferData=new Float32Array(r/Float32Array.BYTES_PER_ELEMENT);var s=new nc(Zu.bindings);this._descriptorSetLayout=i.createDescriptorSetLayout(s),this._descriptorSet=i.createDescriptorSet(new ic(this._descriptorSetLayout)),this._descriptorSet.bindBuffer(Lh.BINDING,a),this._planarQueue=new EA(this._pipeline)},n.destroy=function(){this._deferredLitsBufs.destroy(),this._deferredLitsBufs=null,this._descriptorSet=null},n.render=function(e){var t=this._pipeline,n=t.device,i=t.commandBuffers[0],o=t.pipelineSceneData.renderObjects;if(0!==o.length){if(this.gatherLights(e),this._descriptorSet.update(),this._planarQueue.gatherShadowPasses(e,i),i.bindDescriptorSet(th.LOCAL,this._descriptorSet,[0]),this._renderArea=t.generateRenderArea(e),e.clearFlag&us.COLOR)if(t.pipelineSceneData.isHDR){WT(jw[0],e.clearColor);var r=t.pipelineSceneData.fpScale/e.exposure;jw[0].x*=r,jw[0].y*=r,jw[0].z*=r}else jw[0].x=e.clearColor.x,jw[0].y=e.clearColor.y,jw[0].z=e.clearColor.z;jw[0].w=0;var a,s,c=t.getDeferredRenderData(e).lightingFrameBuffer,l=c.renderPass;i.beginRenderPass(l,c,this._renderArea,jw,e.clearDepth,e.clearStencil),i.bindDescriptorSet(th.GLOBAL,t.descriptorSet);var u=hm.get("builtin-deferred-material");u?(a=u.passes[0],s=Ro.get(a.getShaderVariant())):(a=this._deferredMaterial.passes[1],s=Ro.get(this._deferredMaterial.passes[1].getShaderVariant()));var h=t.quadIAOffscreen,_=null;null!=a&&null!=s&&null!=h&&(_=NT.getOrCreatePipelineState(n,a,s,l,h)),null!=_&&(i.bindPipelineState(_),i.bindInputAssembler(h),i.draw(h)),this._renderQueues.forEach(VT);for(var f=0,d=0,p=0,m=0;m<o.length;++m){var v=o[m],g=v.model.subModels;for(f=0;f<g.length;++f){var y=g[f].passes;for(d=0;d<y.length;++d){var x=y[d];if(x.phase===this._phaseID||x.phase===this._defPhaseID)for(p=0;p<this._renderQueues.length;p++)this._renderQueues[p].insertRenderPass(v,f,d)}}}this._renderQueues.forEach(kT);for(var E=0;E<this._renderQueues.length;E++)this._renderQueues[E].recordCommandBuffer(n,l,i);this._planarQueue.recordCommandBuffer(n,l,i),i.endRenderPass()}},te(t,[{key:"material",set:function(e){this._deferredMaterial!==e&&(this._deferredMaterial=e)}}]),t}(Rx),yw.initInfo={name:"LightingStage",priority:jA.LIGHTING,tag:0},vw=he((mw=xw).prototype,"_deferredMaterial",[hw,H_,_w],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),gw=he(mw.prototype,"renderQueues",[fw,H_,dw],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),pw=mw))||pw)),Yw=e("fB",L_("LightingFlow")((Tw=Sw=function(e){function t(){return e.apply(this,arguments)||this}ie(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 qw;n.initialize(qw.initInfo),this._stages.push(n)}return!0},n.activate=function(t){e.prototype.activate.call(this,t)},n.render=function(t){e.prototype.render.call(this,t)},n.destroy=function(){e.prototype.destroy.call(this)},t}(Ux),Sw.initInfo={name:qu,priority:qA.LIGHTING,stages:[]},Ew=Tw))||Ew),Xw=rd([ka.LINEAR,ka.LINEAR,ka.NONE,Wa.CLAMP,Wa.CLAMP,Wa.CLAMP]),Kw=function(){this.quadIB=null,this.quadVB=null,this.quadIA=null},Qw=function(){this.gbufferFrameBuffer=null,this.gbufferRenderTargets=[],this.lightingFrameBuffer=null,this.lightingRenderTargets=[],this.depthTex=null},Zw=e("fy",(Aw=L_("DeferredPipeline"),ww=hf([DT]),Cw=rf(),Iw=hf([MT]),Pw=rf(),Aw((Dw=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return(t=e.call.apply(e,[this].concat(i))||this)._quadIB=null,t._quadVBOnscreen=null,t._quadVBOffscreen=null,t._quadIAOnscreen=null,t._quadIAOffscreen=null,t._deferredRenderData=null,t._gbufferRenderPass=null,t._lightingRenderPass=null,t._width=0,t._height=0,t._lastUsedRenderArea=new gs,ue(t,"renderTextures",Nw,se(t)),ue(t,"materials",Ow,se(t)),t._renderPasses=new Map,t}ie(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 ow;n.initialize(ow.initInfo),this._flows.push(n);var i=new Ww;i.initialize(Ww.initInfo),this._flows.push(i);var o=new Yw;o.initialize(Yw.initInfo),this._flows.push(o)}return!0},n.activate=function(){return this._macros.CC_PIPELINE_TYPE=1,!(!e.prototype.activate.call(this)||!this._activeRenderer()&&(N(2402),1))},n.render=function(e){if(0!==e.length){this._commandBuffers[0].begin(),this._pipelineUBO.updateGlobalUBO();for(var t=0;t<e.length;t++){var n=e[t];if(n.scene){OE(this,n),this._pipelineUBO.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 Xs,o=new Ks;i.format=n.colorFormat,o.format=n.depthStencilFormat,o.stencilStoreOp=Ja.DISCARD,o.depthStoreOp=Ja.DISCARD,e&us.COLOR||(e&T_?i.loadOp=Za.DISCARD:(i.loadOp=Za.LOAD,i.beginAccesses=[$a.PRESENT])),(e&us.DEPTH_STENCIL)!==us.DEPTH_STENCIL&&(e&us.DEPTH||(o.depthLoadOp=Za.LOAD),e&us.STENCIL||(o.stencilLoadOp=Za.LOAD),o.beginAccesses=[$a.DEPTH_STENCIL_ATTACHMENT_WRITE]);var r=new Zs([i],o);return t=n.createRenderPass(r),this._renderPasses.set(e,t),t},n.getDeferredRenderData=function(){return this._deferredRenderData||this._generateDeferredRenderData(),this._deferredRenderData},n._activeRenderer=function(){var e=this.device;this._commandBuffers.push(e.commandBuffer);var t=yd.getSampler(e,Xw);this._descriptorSet.bindSampler(ch,t),this._descriptorSet.bindTexture(ch,hm.get("default-texture").getGFXTexture()),this._descriptorSet.bindSampler(bh,t),this._descriptorSet.bindTexture(bh,hm.get("default-texture").getGFXTexture()),this._descriptorSet.update();var n=new Kw;if(!(n=this.createQuadInputAssembler(Ra.IDENTITY)).quadIB||!n.quadVB||!n.quadIA)return!1;this._quadIB=n.quadIB,this._quadVBOffscreen=n.quadVB,this._quadIAOffscreen=n.quadIA;var i=this.createQuadInputAssembler(e.surfaceTransform);if(!i.quadIB||!i.quadVB||!i.quadIA)return!1;if(this._quadVBOnscreen=i.quadVB,this._quadIAOnscreen=i.quadIA,!this._gbufferRenderPass){var o=new Xs;o.format=Oa.RGBA16F,o.loadOp=Za.CLEAR,o.storeOp=Ja.STORE;var r=new Xs;r.format=Oa.RGBA16F,r.loadOp=Za.CLEAR,r.storeOp=Ja.STORE;var a=new Xs;a.format=Oa.RGBA16F,a.loadOp=Za.CLEAR,a.storeOp=Ja.STORE;var s=new Xs;s.format=Oa.RGBA16F,s.loadOp=Za.CLEAR,s.storeOp=Ja.STORE;var c=new Ks;c.format=e.depthStencilFormat,c.depthLoadOp=Za.CLEAR,c.depthStoreOp=Ja.STORE,c.stencilLoadOp=Za.CLEAR,c.stencilStoreOp=Ja.STORE;var l=new Zs([o,r,a,s],c);this._gbufferRenderPass=e.createRenderPass(l)}if(!this._lightingRenderPass){var u=new Xs;u.format=Oa.RGBA16F,u.loadOp=Za.CLEAR,u.storeOp=Ja.STORE,u.endAccesses=[$a.COLOR_ATTACHMENT_WRITE];var h=new Ks;h.format=e.depthStencilFormat,h.depthLoadOp=Za.LOAD,h.depthStoreOp=Ja.DISCARD,h.stencilLoadOp=Za.LOAD,h.stencilStoreOp=Ja.DISCARD,h.beginAccesses=[$a.DEPTH_STENCIL_ATTACHMENT_WRITE],h.endAccesses=[$a.DEPTH_STENCIL_ATTACHMENT_WRITE];var _=new Zs([u],h);this._lightingRenderPass=e.createRenderPass(_)}return this._width=e.width,this._height=e.height,this._generateDeferredRenderData(),e.surfaceTransform===Ra.IDENTITY||e.surfaceTransform===Ra.ROTATE_180?(this._width=e.width,this._height=e.height):(this._width=e.height,this._height=e.width),!0},n.destroyUBOs=function(){this._descriptorSet&&(this._descriptorSet.getBuffer(rh.BINDING).destroy(),this._descriptorSet.getBuffer(sh.BINDING).destroy(),this._descriptorSet.getBuffer(ah.BINDING).destroy(),this._descriptorSet.getSampler(ch).destroy(),this._descriptorSet.getSampler(bh).destroy(),this._descriptorSet.getTexture(ch).destroy(),this._descriptorSet.getTexture(bh).destroy())},n.destroyDeferredData=function(){var e=this._deferredRenderData;if(e){e.gbufferFrameBuffer&&e.gbufferFrameBuffer.destroy(),e.lightingFrameBuffer&&e.lightingFrameBuffer.destroy(),e.depthTex&&e.depthTex.destroy();for(var t=0;t<e.gbufferRenderTargets.length;t++)e.gbufferRenderTargets[t].destroy();e.gbufferRenderTargets.length=0;for(var n=0;n<e.lightingRenderTargets.length;n++)e.lightingRenderTargets[n].destroy();e.lightingRenderTargets.length=0}this._deferredRenderData=null},n.destroy=function(){this.destroyUBOs(),this.destroyQuadInputAssembler(),this.destroyDeferredData();for(var t=this._renderPasses.values(),n=t.next();!n.done;)n.value.destroy(),n=t.next();return this._commandBuffers.length=0,e.prototype.destroy.call(this)},n.resize=function(e,t){this._width===e&&this._height===t||(this._width=e,this._height=t,this.destroyDeferredData(),this._generateDeferredRenderData())},n.createQuadInputAssembler=function(){var e=new Kw,t=4*Float32Array.BYTES_PER_ELEMENT,n=4*t,i=this._device.createBuffer(new Ps(La.VERTEX|La.TRANSFER_DST,Ba.HOST|Ba.DEVICE,n,t));if(!i)return e;var o=Uint8Array.BYTES_PER_ELEMENT,r=6*o,a=this._device.createBuffer(new Ps(La.INDEX|La.TRANSFER_DST,Ba.HOST|Ba.DEVICE,r,o));if(!a)return e;var s=new Uint8Array(6);s[0]=0,s[1]=1,s[2]=2,s[3]=1,s[4]=3,s[5]=2,a.update(s);var c=new Array(2);c[0]=new js("a_position",Oa.RG32F),c[1]=new js("a_texCoord",Oa.RG32F);var l=this._device.createInputAssembler(new Ys(c,[i],a));return e.quadIB=a,e.quadVB=i,e.quadIA=l,e},n.updateQuadVertexData=function(e){if(this._lastUsedRenderArea!==e){this._lastUsedRenderArea=e;var t=this.genQuadVertexData(Ra.IDENTITY,e);this._quadVBOffscreen.update(t);var n=this.genQuadVertexData(this.device.surfaceTransform,e);this._quadVBOnscreen.update(n)}},n.genQuadVertexData=function(e,t){var n=new Float32Array(16),i=t.x/this.device.width,o=(t.x+t.width)/this.device.width,r=t.y/this.device.height,a=(t.y+t.height)/this.device.height;if(this.device.capabilities.screenSpaceSignY>0){var s=a;a=r,r=s}var c=0;switch(e){case Ra.IDENTITY:c=0,n[c++]=-1,n[c++]=-1,n[c++]=i,n[c++]=a,n[c++]=1,n[c++]=-1,n[c++]=o,n[c++]=a,n[c++]=-1,n[c++]=1,n[c++]=i,n[c++]=r,n[c++]=1,n[c++]=1,n[c++]=o,n[c++]=r;break;case Ra.ROTATE_90:c=0,n[c++]=-1,n[c++]=-1,n[c++]=o,n[c++]=a,n[c++]=1,n[c++]=-1,n[c++]=o,n[c++]=r,n[c++]=-1,n[c++]=1,n[c++]=i,n[c++]=a,n[c++]=1,n[c++]=1,n[c++]=i,n[c++]=r;break;case Ra.ROTATE_180:c=0,n[c++]=-1,n[c++]=-1,n[c++]=i,n[c++]=r,n[c++]=1,n[c++]=-1,n[c++]=o,n[c++]=r,n[c++]=-1,n[c++]=1,n[c++]=i,n[c++]=a,n[c++]=1,n[c++]=1,n[c++]=o,n[c++]=a;break;case Ra.ROTATE_270:c=0,n[c++]=-1,n[c++]=-1,n[c++]=i,n[c++]=r,n[c++]=1,n[c++]=-1,n[c++]=i,n[c++]=a,n[c++]=-1,n[c++]=1,n[c++]=o,n[c++]=r,n[c++]=1,n[c++]=1,n[c++]=o,n[c++]=a}return n},n.destroyQuadInputAssembler=function(){this._quadIB&&(this._quadIB.destroy(),this._quadIB=null),this._quadVBOnscreen&&(this._quadVBOnscreen.destroy(),this._quadVBOnscreen=null),this._quadVBOffscreen&&(this._quadVBOffscreen.destroy(),this._quadVBOffscreen=null),this._quadIAOnscreen&&(this._quadIAOnscreen.destroy(),this._quadIAOnscreen=null),this._quadIAOffscreen&&(this._quadIAOffscreen.destroy(),this._quadIAOffscreen=null)},n._generateDeferredRenderData=function(){var e=this.device,t=this._deferredRenderData=new Qw;t.gbufferRenderTargets.push(e.createTexture(new Ds(Ua.TEX2D,Ha.COLOR_ATTACHMENT|Ha.SAMPLED,Oa.RGBA16F,this._width,this._height))),t.gbufferRenderTargets.push(e.createTexture(new Ds(Ua.TEX2D,Ha.COLOR_ATTACHMENT|Ha.SAMPLED,Oa.RGBA16F,this._width,this._height))),t.gbufferRenderTargets.push(e.createTexture(new Ds(Ua.TEX2D,Ha.COLOR_ATTACHMENT|Ha.SAMPLED,Oa.RGBA16F,this._width,this._height))),t.gbufferRenderTargets.push(e.createTexture(new Ds(Ua.TEX2D,Ha.COLOR_ATTACHMENT|Ha.SAMPLED,Oa.RGBA16F,this._width,this._height))),t.depthTex=e.createTexture(new Ds(Ua.TEX2D,Ha.DEPTH_STENCIL_ATTACHMENT,e.depthStencilFormat,this._width,this._height)),t.gbufferFrameBuffer=e.createFramebuffer(new ec(this._gbufferRenderPass,t.gbufferRenderTargets,t.depthTex)),t.lightingRenderTargets.push(e.createTexture(new Ds(Ua.TEX2D,Ha.COLOR_ATTACHMENT|Ha.SAMPLED,Oa.RGBA16F,this._width,this._height))),t.lightingFrameBuffer=e.createFramebuffer(new ec(this._lightingRenderPass,t.lightingRenderTargets,t.depthTex)),this._descriptorSet.bindTexture(hh,t.gbufferFrameBuffer.colorTextures[0]),this._descriptorSet.bindTexture(dh,t.gbufferFrameBuffer.colorTextures[1]),this._descriptorSet.bindTexture(vh,t.gbufferFrameBuffer.colorTextures[2]),this._descriptorSet.bindTexture(Th,t.gbufferFrameBuffer.colorTextures[3]),this._descriptorSet.bindTexture(xh,t.lightingFrameBuffer.colorTextures[0]);var n=yd.getSampler(e,Xw);this._descriptorSet.bindSampler(hh,n),this._descriptorSet.bindSampler(dh,n),this._descriptorSet.bindSampler(vh,n),this._descriptorSet.bindSampler(Th,n),this._descriptorSet.bindSampler(xh,n)},te(t,[{key:"quadIAOnscreen",get:function(){return this._quadIAOnscreen}},{key:"quadIAOffscreen",get:function(){return this._quadIAOffscreen}}]),t}(oS),Nw=he((Rw=Dw).prototype,"renderTextures",[ww,H_,Cw],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Ow=he(Rw.prototype,"materials",[Iw,H_,Pw],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),bw=Rw))||bw)),Jw=[new Cs(0,0,0,1)];function $w(){var e=new aw;return e.initialize({flows:[]}),e}e("fD",(Mw=L_("PostprocessStage"),Lw=hf(fE),Fw=rf(),Mw((Gw=Hw=function(e){function t(){var t;return ue(t=e.call(this)||this,"_postprocessMaterial",Uw,se(t)),t._renderArea=new gs,t._uiPhase=void 0,t._uiPhase=new SA,t}ie(t,e);var n=t.prototype;return n.initialize=function(t){return e.prototype.initialize.call(this,t),!0},n.activate=function(t,n){e.prototype.activate.call(this,t,n),this._uiPhase.activate(t)},n.destroy=function(){},n.render=function(e){var t=this._pipeline,n=t.device,i=t.commandBuffers[0];t.pipelineUBO.updateCameraUBO(e);var o=e.viewport;this._renderArea.x=o.x*e.width,this._renderArea.y=o.y*e.height,this._renderArea.width=o.width*e.width*t.pipelineSceneData.shadingScale,this._renderArea.height=o.height*e.height*t.pipelineSceneData.shadingScale;var r,a,s=e.window.framebuffer,c=s.colorTextures[0]?s.renderPass:t.getRenderPass(e.clearFlag);e.clearFlag&us.COLOR&&(Jw[0].x=e.clearColor.x,Jw[0].y=e.clearColor.y,Jw[0].z=e.clearColor.z),Jw[0].w=e.clearColor.w,i.beginRenderPass(c,s,this._renderArea,Jw,e.clearDepth,e.clearStencil),i.bindDescriptorSet(th.GLOBAL,t.descriptorSet);var l=hm.get("builtin-post-process-material");l?(r=l.passes[0],a=Ro.get(r.getShaderVariant())):(r=this._postprocessMaterial.passes[0],a=Ro.get(this._postprocessMaterial.passes[0].getShaderVariant()));var u=e.window.hasOffScreenAttachments?t.quadIAOffscreen:t.quadIAOnscreen,h=null;null!=r&&null!=a&&null!=u&&(h=NT.getOrCreatePipelineState(n,r,a,c,u));var _=t.pipelineSceneData.renderObjects;null!=h&&_.length>0&&(i.bindPipelineState(h),i.bindInputAssembler(u),i.draw(u)),this._uiPhase.render(e,c),i.endRenderPass()},te(t,[{key:"material",set:function(e){this._postprocessMaterial!==e&&(this._postprocessMaterial=e)}}]),t}(Rx),Hw.initInfo={name:"PostprocessStage",priority:jA.POSTPROCESS,tag:0},Uw=he((Bw=Gw).prototype,"_postprocessMaterial",[Lw,H_,Fw],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),zw=Bw))||zw));var eC=e("d8",function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];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}ie(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(){c.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 c.director.once(c.Director.EVENT_AFTER_DRAW,(function(){return e()}))})).then((function(){for(var n in e._persistRootNodes)e.removePersistRootNode(e._persistRootNodes[n]);return c.director.getScene().destroy(),c.Object._deferredDestroy(),c.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,o){return this._engineInited&&e===t.EVENT_ENGINE_INITED?n.call(i):this.eventTargetOn(e,n,i,o)},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&&c.assetManager.init(this.config.assetOptions),this._initEngine().then((function(){return t._initEvents(),c.director.root.dataPoolManager&&c.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 tC.config.registerSystemEvent&&Zy.registerSystemEvent(),i._setRenderPipelineNShowSplash()}))},n.addPersistRootNode=function(e){if(c.Node.isNode(e)&&e.uuid){var t=e.uuid;if(!this._persistRootNodes[t]){var n=c.director._scene;if(c.isValid(n))if(e.parent){if(!(e.parent instanceof c.Scene))return void b(3801);if(e.parent!==n)return void b(3802);e._originalSceneId=n.uuid}else e.parent=n;this._persistRootNodes[t]=e,e._persistNode=!0,c.assetManager._releaseManager._addPersistNodeRef(e)}}else b(3800)},n.removePersistRootNode=function(e){var t=e.uuid||"";e===this._persistRootNodes[t]&&(delete this._persistRootNodes[t],e._persistNode=!1,e._originalSceneId="",c.assetManager._releaseManager._removePersistNodeRef(e))},n.isPersistRootNode=function(e){return!!e._persistNode},n._initEngine=function(){var e=this;return this._initDevice(),Promise.resolve(c.director._init()).then((function(){g("Cocos Creator v"+l),e.emit(t.EVENT_ENGINE_INITED),e._engineInited=!0,c.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-tC._lastTime),i=Math.max(0,tC._frameTime-n),o=window.setTimeout((function(){window.requestAnimationFrame(e)}),i);return tC._lastTime=t+i,o},n._stTime=function(e){var t=performance.now(),n=Math.max(0,t-tC._lastTime),i=Math.max(0,tC._frameTime-n),o=window.setTimeout(e,i);return tC._lastTime=t+i,o},n._ctTime=function(e){window.clearTimeout(e)},n._runMainLoop=function(){var e=this;if(this._inited&&!i){var t,n=this.config,o=c.director,r=n.frameRate;if(z(!!n.showFPS),o.startAnimation(),30===r){var a=!0;t=function(n){e._intervalId=window.rAF(t),(a=!a)||o.mainLoop(n)}}else t=function(n){e._intervalId=window.rAF(t),o.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=O.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||[],T(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 i=!1;if(0===n?c.sys.capabilities.opengl?(this.renderType=t.RENDER_TYPE_WEBGL,i=!0):c.sys.capabilities.canvas&&(this.renderType=t.RENDER_TYPE_CANVAS,i=!0):1===n&&c.sys.capabilities.canvas?(this.renderType=t.RENDER_TYPE_CANVAS,i=!0):2===n&&c.sys.capabilities.opengl&&(this.renderType=t.RENDER_TYPE_WEBGL,i=!0),!i)throw new Error(L(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,i=window.navigator.userAgent.toLowerCase();(-1!==i.indexOf("safari")&&-1===i.indexOf("chrome")||Ni.browserType===Si.UC)&&(n=!1),n&&c.WebGL2Device&&e.push(c.WebGL2Device),c.WebGLDevice&&e.push(c.WebGLDevice);for(var o=new hc(this.canvas,ft.ENABLE_WEBGL_ANTIALIAS,!1,window.devicePixelRatio,mx.windowPixelResolution.width,mx.windowPixelResolution.height,oh),r=0;r<e.length&&(this._gfxDevice=new e[r],!this._gfxDevice.initialize(o));r++);}if(!this._gfxDevice)return x("can not support canvas rendering in 3D"),void(this.renderType=t.RENDER_TYPE_CANVAS);this.canvas.oncontextmenu=function(){return!1}}},n._initEvents=function(){Ni.onShow(this._onShow.bind(this)),Ni.onHide(this._onHide.bind(this))},n._onHide=function(){this.emit(t.EVENT_HIDE),this.pause()},n._onShow=function(){this.emit(t.EVENT_SHOW),this.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){c.assetManager.loadAny(t,(function(t,i){return!t&&i instanceof oS?e(i):n(t)}))})).then((function(t){e._setRenderPipeline(t)})).catch((function(n){y(n),y("Failed load render pipeline: "+t+", engine failed to initialize, will fallback to default pipeline"),e._setRenderPipeline()})):this._setRenderPipeline()},n._showSplashScreen=function(){if(c.internal.SplashScreen){var e=c.internal.SplashScreen.instance;return e.main(c.director.root),new Promise((function(t){e.setOnFinish((function(){return t()})),e.loadFinish=!0}))}return null},n._setRenderPipeline=function(e){c.director.root.setRenderPipeline(e)||this._setRenderPipeline(),this._rendererInitialized=!0,this._safeEmit(t.EVENT_RENDERER_INITED)},n._safeEmit=function(e){this.emit(e)},te(t,[{key:"inited",get:function(){return this._inited}},{key:"frameTime",get:function(){return this._frameTime}}]),t}(bi));eC.EVENT_HIDE="game_on_hide",eC.EVENT_SHOW="game_on_show",eC.EVENT_LOW_MEMORY="game_on_low_memory",eC.EVENT_GAME_INITED="game_inited",eC.EVENT_ENGINE_INITED="engine_inited",eC.EVENT_RENDERER_INITED="renderer_inited",eC.EVENT_RESTART="game_on_restart",eC.RENDER_TYPE_CANVAS=0,eC.RENDER_TYPE_WEBGL=1,eC.RENDER_TYPE_OPENGL=2,c.Game=eC;var tC=e("de",c.game=new eC),nC=e("dd",{topLeft:c.v2(0,0),topRight:c.v2(0,0),top:c.v2(0,0),bottomLeft:c.v2(0,0),bottomRight:c.v2(0,0),bottom:c.v2(0,0),center:c.v2(0,0),left:c.v2(0,0),right:c.v2(0,0),width:0,height:0,init:function(e){var t=this.width=e.width,n=this.height=e.height,i=e.x,o=e.y,r=o+n,a=i+t;this.topLeft.x=i,this.topLeft.y=r,this.topRight.x=a,this.topRight.y=r,this.top.x=i+t/2,this.top.y=r,this.bottomLeft.x=i,this.bottomLeft.y=o,this.bottomRight.x=a,this.bottomRight.y=o,this.bottom.x=i+t/2,this.bottom.y=o,this.center.x=i+t/2,this.center.y=o+n/2,this.left.x=i,this.left.y=o+n/2,this.right.x=a,this.right.y=o+n/2}});c.visibleRect=nC;var iC=new(function(){function e(){this.html=void 0,this.meta={width:"device-width"},this.adaptationType=c.sys.browserType}var t=e.prototype;return t.init=function(){this.html=document.getElementsByTagName("html")[0]},t.availWidth=function(e){return c.sys.isMobile||!e||e===this.html?window.innerWidth:e.clientWidth},t.availHeight=function(e){return c.sys.isMobile||!e||e===this.html?window.innerHeight:e.clientHeight},e}());switch(Ni.os===Ci.IOS&&(iC.adaptationType=Si.SAFARI),iC.adaptationType){case Si.SAFARI:iC.meta["minimal-ui"]="true",iC.availWidth=function(e){return e.clientWidth},iC.availHeight=function(e){return e.clientHeight};break;case Si.SOUGOU:case Si.UC:iC.availWidth=function(e){return e.clientWidth},iC.availHeight=function(e){return e.clientHeight}}var oC=e("dQ",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=rC,i=aC;return t._frameSize=new ni(0,0),t._designResolutionSize=new ni(0,0),t._originalDesignResolutionSize=new ni(0,0),t._scaleX=1,t._scaleY=1,t._viewportRect=new oi(0,0,0,0),t._visibleRect=new oi(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=c.macro.ORIENTATION_AUTO,t._isAdjustViewport=!0,t._rpExactFit=new sC(n.EQUAL_TO_FRAME,i.EXACT_FIT),t._rpShowAll=new sC(n.EQUAL_TO_FRAME,i.SHOW_ALL),t._rpNoBorder=new sC(n.EQUAL_TO_FRAME,i.NO_BORDER),t._rpFixedHeight=new sC(n.EQUAL_TO_FRAME,i.FIXED_HEIGHT),t._rpFixedWidth=new sC(n.EQUAL_TO_FRAME,i.FIXED_WIDTH),t._resolutionPolicy=t._rpShowAll,c.game.once(c.Game.EVENT_ENGINE_INITED,t.init,se(t)),t}ie(t,e);var n=t.prototype;return n.init=function(){iC.init(),this._initFrameSize();var e=c.game.canvas.width,t=c.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,c.winSize.width=this._visibleRect.width,c.winSize.height=this._visibleRect.height,c.visibleRect&&c.visibleRect.init(this._visibleRect)},n.resizeWithBrowserSize=function(e){e?this._resizeWithBrowserSize||(this._resizeWithBrowserSize=!0,Ni.onViewResize(this._resizeEvent),Ni.onOrientationChange(this._orientationChange)):this._resizeWithBrowserSize&&(this._resizeWithBrowserSize=!1,Ni.offViewResize(this._resizeEvent),Ni.offOrientationChange(this._orientationChange))},n.setResizeCallback=function(e){"function"!=typeof e&&null!=e||(this._resizeCallback=e)},n.setOrientation=function(e){(e&=c.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&&c.sys.isMobile&&Ni.browserType!==Si.WECHAT?(this._autoFullScreen=!0,c.screen.autoFullScreen(c.game.frame)):this._autoFullScreen=!1},n.isAutoFullScreenEnabled=function(){return this._autoFullScreen},n.setCanvasSize=function(e,t){var n=c.game.canvas,i=c.game.container;this._devicePixelRatio=window.devicePixelRatio,n.width=mx.windowPixelResolution.width,n.height=mx.windowPixelResolution.height,n.style.width=e+"px",n.style.height=t+"px",i.style.width=e+"px",i.style.height=t+"px",this._resizeEvent()},n.getCanvasSize=function(){return new ni(c.game.canvas.width,c.game.canvas.height)},n.getFrameSize=function(){return new ni(this._frameSize.width,this._frameSize.height)},n.setFrameSize=function(e,t){this._frameSize.width=e,this._frameSize.height=t,c.game.frame.style.width=e+"px",c.game.frame.style.height=t+"px",this._resizeEvent()},n.getVisibleSize=function(){return new ni(this._visibleRect.width,this._visibleRect.height)},n.getVisibleSizeInPixel=function(){return new ni(this._visibleRect.width*this._scaleX,this._visibleRect.height*this._scaleY)},n.getVisibleOrigin=function(){return new Kn(this._visibleRect.x,this._visibleRect.y)},n.getVisibleOriginInPixel=function(){return new Kn(this._visibleRect.x*this._scaleX,this._visibleRect.y*this._scaleY)},n.getResolutionPolicy=function(){return this._resolutionPolicy},n.setResolutionPolicy=function(e){if(e instanceof sC)this._resolutionPolicy=e;else{var t=sC;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 i=this._resolutionPolicy;if(i&&i.preApply(this),c.sys.isMobile&&this._adjustViewportMeta(),this._orientationChanging=!0,this._resizing||this._initFrameSize(),i){this._originalDesignResolutionSize.width=this._designResolutionSize.width=e,this._originalDesignResolutionSize.height=this._designResolutionSize.height=t;var o=i.apply(this,this._designResolutionSize);if(o.scale&&2===o.scale.length&&(this._scaleX=o.scale[0],this._scaleY=o.scale[1]),o.viewport){var r=this._viewportRect,a=this._visibleRect,s=o.viewport;r.x=s.x,r.y=s.y,r.width=s.width,r.height=s.height,a.x=0,a.y=0,a.width=s.width/this._scaleX,a.height=s.height/this._scaleY}i.postApply(this),c.winSize.width=this._visibleRect.width,c.winSize.height=this._visibleRect.height,nC&&nC.init(this._visibleRect),this.emit("design-resolution-changed")}else I(2201)}else N(2200)},n.getDesignResolutionSize=function(){return new ni(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,i){var o=i||new Kn,r=this._devicePixelRatio*(e-n.left),a=this._devicePixelRatio*(n.top+n.height-t);return this._isRotated?(o.x=c.game.canvas.width-a,o.y=r):(o.x=r,o.y=a),c.GAME_VIEW&&(o.x/=c.gameView.canvas.width/c.game.canvas.width,o.y/=c.gameView.canvas.height/c.game.canvas.height),o},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=c.view,t=e._frameSize.width,n=e._frameSize.height,i=e._isRotated;if(c.sys.isMobile){var o=c.game.container.style,r=o.margin;o.margin="0",o.display="none",e._initFrameSize(),o.margin=r,o.display="block"}else e._initFrameSize();if(e._orientationChanging||e._isRotated!==i||e._frameSize.width!==t||e._frameSize.height!==n){var a=e._originalDesignResolutionSize.width,s=e._originalDesignResolutionSize.height;e._resizing=!0,a>0&&e.setDesignResolutionSize(a,s,e._resolutionPolicy),e._resizing=!1,e.emit("canvas-resize"),e._resizeCallback&&e._resizeCallback.call()}},n._orientationChange=function(){c.view._orientationChanging=!0,c.view._resizeEvent()},n._initFrameSize=function(){var e=this._frameSize,t=iC.availWidth(c.game.frame),n=iC.availHeight(c.game.frame),i=t>=n;!c.sys.isMobile||i&&this._orientation&c.macro.ORIENTATION_LANDSCAPE||!i&&this._orientation&c.macro.ORIENTATION_PORTRAIT?(e.width=t,e.height=n,c.game.container.style["-webkit-transform"]="rotate(0deg)",c.game.container.style.transform="rotate(0deg)",this._isRotated=!1):(e.width=n,e.height=t,c.game.container.style["-webkit-transform"]="rotate(90deg)",c.game.container.style.transform="rotate(90deg)",c.game.container.style["-webkit-transform-origin"]="0px 0px 0px",c.game.container.style.transformOrigin="0px 0px 0px",this._isRotated=!0,c.game.canvas.style["-webkit-transform"]="translateZ(0px)",c.game.canvas.style.transform="translateZ(0px)"),this._orientationChanging&&setTimeout((function(){c.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,o,r,a=document.getElementsByName("viewport"),s=a?a[0]:null;for(o in i=s?s.content:"",(n=n||document.createElement("meta")).id="cocosMetaElement",n.name="viewport",n.content="",e)-1===i.indexOf(o)?i+=","+o+"="+e[o]:t&&(r=new RegExp(o+"s*=s*[^,]+"),i=i.replace(r,o+"="+e[o]));/^,/.test(i)&&(i=i.substr(1)),n.content=i,s&&(s.content=i),document.head.appendChild(n)},n._adjustViewportMeta=function(){!this._isAdjustViewport||a||o||r||(this._setViewportMeta(iC.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),c.GAME_VIEW&&(e.x/=c.gameView.canvas.width/c.game.canvas.width,e.y/=c.gameView.canvas.height/c.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,o=this._scaleX,r=this._scaleY,a=0;a<e.length;a++){var s=e[a];t=s._point,n=s._prevPoint,t.x=(t.x-i.x)/o,t.y=(t.y-i.y)/r,n.x=(n.x-i.x)/o,n.y=(n.y-i.y)/r}},t}(bi));oC.instance=void 0;var rC=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 i=c.game.canvas,o=c.game.container;Ni.os!==Ci.ANDROID&&Ni.os!==Ci.OHOS||(document.body.style.width=(e._isRotated?n:t)+"px",document.body.style.height=(e._isRotated?t:n)+"px"),o.style.width=i.style.width=t+"px",o.style.height=i.style.height=n+"px",e._devicePixelRatio=1,e.isRetinaEnabled()&&(e._devicePixelRatio=Math.min(e._maxPixelRatio,window.devicePixelRatio||1)),i.width=t*e._devicePixelRatio,i.height=n*e._devicePixelRatio},t._fixContainer=function(){document.body.insertBefore(c.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=c.game.container.style;t.position="fixed",t.left=t.top="0px",document.body.scrollTop=0},e}();rC.EQUAL_TO_FRAME=void 0,rC.PROPORTION_TO_FRAME=void 0;var aC=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,o,r){Math.abs(e-n)<2&&(n=e),Math.abs(t-i)<2&&(i=t);var a=new oi(Math.round((e-n)/2),Math.round((t-i)/2),n,i);return this._result.scale=[o,r],this._result.viewport=a,this._result},e}();aC.EXACT_FIT=void 0,aC.SHOW_ALL=void 0,aC.NO_BORDER=void 0,aC.FIXED_HEIGHT=void 0,aC.FIXED_WIDTH=void 0,function(){var e=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return(t=e.call.apply(e,[this].concat(i))||this).name="EqualToFrame",t}return ie(t,e),t.prototype.apply=function(e){var t=e._frameSize.height,n=c.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}(rC),t=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return(t=e.call.apply(e,[this].concat(i))||this).name="ProportionalToFrame",t}return ie(t,e),t.prototype.apply=function(e,t){var n,i,o=e._frameSize.width,r=e._frameSize.height,a=c.game.container.style,s=t.width,l=t.height,u=o/s,h=r/l;u<h?(n=o,i=l*u):(n=s*h,i=r);var _=Math.round((o-n)/2),f=Math.round((r-i)/2);n=o-2*_,i=r-2*f,this._setupContainer(e,n,i),e._isRotated?a.margin="0 0 0 "+r+"px":a.margin="0px",a.paddingLeft=_+"px",a.paddingRight=_+"px",a.paddingTop=f+"px",a.paddingBottom=f+"px"},t}(rC),n=("undefined"==typeof window?global:window).__globalAdapter;n&&(n.adaptContainerStrategy&&n.adaptContainerStrategy(rC.prototype),n.adaptView&&n.adaptView(oC.prototype)),rC.EQUAL_TO_FRAME=new e,rC.PROPORTION_TO_FRAME=new t;var i=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return(t=e.call.apply(e,[this].concat(i))||this).name="ExactFit",t}return ie(t,e),t.prototype.apply=function(e,t){var n=c.game.canvas.width,i=c.game.canvas.height,o=n/t.width,r=i/t.height;return this._buildResult(n,i,n,i,o,r)},t}(aC),o=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return(t=e.call.apply(e,[this].concat(i))||this).name="ShowAll",t}return ie(t,e),t.prototype.apply=function(e,t){var n,i,o=c.game.canvas.width,r=c.game.canvas.height,a=t.width,s=t.height,l=o/a,u=r/s,h=0;return l<u?(n=o,i=s*(h=l)):(n=a*(h=u),i=r),this._buildResult(o,r,n,i,h,h)},t}(aC),r=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return(t=e.call.apply(e,[this].concat(i))||this).name="NoBorder",t}return ie(t,e),t.prototype.apply=function(e,t){var n,i,o,r=c.game.canvas.width,a=c.game.canvas.height,s=t.width,l=t.height,u=r/s,h=a/l;return u<h?(i=s*(n=h),o=a):(i=r,o=l*(n=u)),this._buildResult(r,a,i,o,n,n)},t}(aC),a=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return(t=e.call.apply(e,[this].concat(i))||this).name="FixedHeight",t}return ie(t,e),t.prototype.apply=function(e,t){var n=c.game.canvas.width,i=c.game.canvas.height,o=i/t.height,r=n,a=i;return this._buildResult(n,i,r,a,o,o)},t}(aC),s=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return(t=e.call.apply(e,[this].concat(i))||this).name="FixedWidth",t}return ie(t,e),t.prototype.apply=function(e,t){var n=c.game.canvas.width,i=c.game.canvas.height,o=n/t.width,r=n,a=i;return this._buildResult(n,i,r,a,o,o)},t}(aC);aC.EXACT_FIT=new i,aC.SHOW_ALL=new o,aC.NO_BORDER=new r,aC.FIXED_HEIGHT=new a,aC.FIXED_WIDTH=new s}();var sC=e("fi",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 rC&&(this._containerStrategy=e)},t.setContentStrategy=function(e){e instanceof aC&&(this._contentStrategy=e)},te(e,[{key:"canvasSize",get:function(){return new Kn(c.game.canvas.width,c.game.canvas.height)}}]),e}());sC.EXACT_FIT=0,sC.NO_BORDER=1,sC.SHOW_ALL=2,sC.FIXED_HEIGHT=3,sC.FIXED_WIDTH=4,sC.UNKNOWN=5,sC.ContainerStrategy=rC,sC.ContentStrategy=aC,c.ResolutionPolicy=sC;var cC=e("df",oC.instance=c.view=new oC);c.winSize=new ni,Y(oC.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"}]),q(Gy,"EventMouse",["DOWN","UP","MOVE"].map((function(e){return{name:e,newName:"MOUSE_"+e,target:nx.EventType,targetName:"SystemEvent.EventType"}}))),q(Gy,"EventMouse",[{name:"SCROLL",newName:"MOUSE_WHEEL",target:nx.EventType,targetName:"SystemEvent.EventType"}]),q(Vy,"EventTouch",[{name:"BEGAN",newName:"TOUCH_START",target:nx.EventType,targetName:"SystemEvent.EventType"}]),q(Vy,"EventTouch",[{name:"MOVED",newName:"TOUCH_MOVE",target:nx.EventType,targetName:"SystemEvent.EventType"}]),q(Vy,"EventTouch",[{name:"ENDED",newName:"TOUCH_END",target:nx.EventType,targetName:"SystemEvent.EventType"}]),q(Vy,"EventTouch",[{name:"CANCELLED",newName:"TOUCH_CANCEL",target:nx.EventType,targetName:"SystemEvent.EventType"}]),q(mx,"sys",["UNKNOWN","ENGLISH","CHINESE","FRENCH","ITALIAN","GERMAN","SPANISH","DUTCH","RUSSIAN","KOREAN","JAPANESE","HUNGARIAN","PORTUGUESE","ARABIC","NORWEGIAN","POLISH","TURKISH","UKRAINIAN","ROMANIAN","BULGARIAN"].map((function(e){return{name:"LANGUAGE_"+e,newName:e,target:mx.Language,targetName:"sys.Language"}}))),q(mx,"sys",["UNKNOWN","IOS","ANDROID","WINDOWS","LINUX","OSX"].map((function(e){return{name:"OS_"+e,newName:e,target:mx.OS,targetName:"sys.OS"}}))),q(mx,"sys",["UNKNOWN","WECHAT","ANDROID","IE","EDGE","QQ","MOBILE_QQ","UC","UCBS","BAIDU_APP","BAIDU","MAXTHON","OPERA","OUPENG","MIUI","FIREFOX","SAFARI","CHROME","LIEBAO","QZONE","SOUGOU","HUAWEI"].map((function(e){return{name:"BROWSER_TYPE_"+e,newName:e,target:mx.BrowserType,targetName:"sys.BrowserType"}}))),q(mx,"sys",[{name:"BROWSER_TYPE_360",newName:"BROWSER_360",target:mx.BrowserType,targetName:"sys.BrowserType"}]),q(mx,"sys",["UNKNOWN","EDITOR_PAGE","EDITOR_CORE","MOBILE_BROWSER","DESKTOP_BROWSER","WIN32","MACOS","IOS","ANDROID","OHOS","WECHAT_GAME","BAIDU_MINI_GAME","XIAOMI_QUICK_GAME","ALIPAY_MINI_GAME","BYTEDANCE_MINI_GAME","OPPO_MINI_GAME","VIVO_MINI_GAME","HUAWEI_QUICK_GAME","COCOSPLAY","LINKSURE_MINI_GAME","QTT_MINI_GAME"].map((function(e){return{name:e,target:mx.Platform,targetName:"sys.Platform"}}))),q(mx,"sys",[{name:"IPHONE",newName:"IOS",target:mx.Platform,targetName:"sys.Platform"},{name:"IPAD",newName:"IOS",target:mx.Platform,targetName:"sys.Platform"}]),Y(mx,"sys",["LINUX","BLACKBERRY","NACL","EMSCRIPTEN","TIZEN","WINRT","WP8","QQ_PLAY","FB_PLAYABLE_ADS"].map((function(e){return{name:e}})));var lC=e("dG",{_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,o=this._fnMap;for(e=0,t=o.length;e<t;e++)if((n=o[e])&&void 0!==document[n[1]]){for(e=0,i=n.length;e<i;e++)this._fn[o[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 o=this._fn.fullscreenerror;this._onfullscreenerror&&document.removeEventListener(o,this._onfullscreenerror),this._onfullscreenerror=n,document.addEventListener(o,n,{once:!0})}var r=e[this._fn.requestFullscreen]();return window.Promise&&r instanceof Promise&&r.catch((function(){})),r}},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=c.game.canvas||e,n=this._touchEvent;t.removeEventListener(n,this._preOnTouch),this._preOnTouch=null}},_ensureFullScreen:function(e,t){var n=this,i=c.game.canvas||e,o=this._fn.fullscreenerror,r=this._touchEvent,a=function(){n._preOnFullScreenError=null,n._preOnTouch&&i.removeEventListener(r,n._preOnTouch),n._preOnTouch=function(){n._preOnTouch=null,n.requestFullScreen(e,t)},i.addEventListener(r,n._preOnTouch,{once:!0})};this._preOnFullScreenError&&e.removeEventListener(o,this._preOnFullScreenError),this._preOnFullScreenError=a,e.addEventListener(o,a,{once:!0})}});lC.init(),c.screen=lC;var uC,hC=new ic(null),_C=function(){function e(){this._device=null,this._passes=null,this._subMesh=null,this._patches=null,this._handle=bo,this._priority=Wu.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=c.director.root.device,this._subMesh=e,this._patches=n,this._passes=t,this._handle=Ko.alloc(),this._flushPassInfo(),t[0].batchingScheme===cm.VB_MERGING&&this._subMesh.genFlatBuffers(),hC.layout=t[0].localSetLayout;var i=No.alloc(this._device,hC),o=Oo.alloc(this._device,e.iaInfo);Ko.set(this._handle,Wo.PRIORITY,Wu.DEFAULT),Ko.set(this._handle,Wo.INPUT_ASSEMBLER,o),Ko.set(this._handle,Wo.DESCRIPTOR_SET,i),Ko.set(this._handle,Wo.SUB_MESH,e.handle),this._inputAssembler=Oo.get(o),this._descriptorSet=No.get(i)},t.initPlanarShadowShader=function(){var e=c.director.root.pipeline.pipelineSceneData.shadows.getPlanarShader(this._patches);Ko.set(this._handle,Wo.PLANAR_SHADER,e)},t.initPlanarShadowInstanceShader=function(){var e=c.director.root.pipeline.pipelineSceneData.shadows.getPlanarInstanceShader(this._patches);Ko.set(this._handle,Wo.PLANAR_INSTANCE_SHADER,e)},t.destroy=function(){No.free(Ko.get(this._handle,Wo.DESCRIPTOR_SET)),Oo.free(Ko.get(this._handle,Wo.INPUT_ASSEMBLER)),Ko.free(this._handle),this._descriptorSet=null,this._inputAssembler=null,this._priority=Wu.DEFAULT,this._handle=bo,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){Ko.set(this._handle,Wo.PASS_COUNT,e.length);for(var t=Wo.PASS_0,n=Wo.SHADER_0,i=0;i<e.length;i++,t++,n++)Ko.set(this._handle,t,e[i].handle),Ko.set(this._handle,n,e[i].getShaderVariant(this._patches))}},te(e,[{key:"passes",get:function(){return this._passes},set:function(e){if(e.length>8)N(12004,8);else if(this._passes=e,this._flushPassInfo(),this._descriptorSet){No.free(Ko.get(this._handle,Wo.DESCRIPTOR_SET)),hC.layout=e[0].localSetLayout;var t=No.alloc(this._device,hC);Ko.set(this._handle,Wo.DESCRIPTOR_SET,t),this._descriptorSet=No.get(t)}}},{key:"subMesh",get:function(){return this._subMesh},set:function(e){this._subMesh=e,this._inputAssembler.destroy(),this._inputAssembler.initialize(e.iaInfo),this._passes[0].batchingScheme===cm.VB_MERGING&&this._subMesh.genFlatBuffers(),Ko.set(this._handle,Wo.SUB_MESH,e.handle)}},{key:"priority",get:function(){return this._priority},set:function(e){this._priority=e,Ko.set(this._handle,Wo.PRIORITY,e)}},{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:"planarShaderHandle",get:function(){return Ko.get(this._handle,Wo.PLANAR_SHADER)}},{key:"planarInstanceShaderHandle",get:function(){return Ko.get(this._handle,Wo.PLANAR_INSTANCE_SHADER)}}]),e}(),fC=new Ao(So.ATTRIBUTE,(function(e,t){return t||new js})),dC=new jn,pC=new si((function(){return new _C}),32),mC=[{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"}(uC||(uC=e("cD",{})));var vC,gC,yC=rd([ka.LINEAR,ka.LINEAR,ka.NONE,Wa.CLAMP,Wa.CLAMP,Wa.CLAMP]),xC=rd([ka.LINEAR,ka.LINEAR,ka.LINEAR,Wa.CLAMP,Wa.CLAMP,Wa.CLAMP]),EC=e("bX",function(){function e(){this.type=uC.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=bo,this._hWorldBounds=bo,this._localData=new Float32Array(Oh.COUNT),this._localBuffer=null,this._instMatWorldIdx=-1,this._lightmap=null,this._lightmapUVParam=new $n,this._device=c.director.root.device}var t=e.prototype;return t.initialize=function(){if(!this._inited){this._handle=Jo.alloc();var e=Lo.alloc(),t=zo.alloc();Jo.set(this._handle,Yo.INSTANCED_ATTR_ARRAY,t),Jo.set(this._handle,Yo.SUB_MODEL_ARRAY,e),Jo.set(this._handle,Yo.VIS_FLAGS,Vu.Enum.NONE),Jo.set(this._handle,Yo.ENABLED,1),Jo.set(this._handle,Yo.RECEIVE_SHADOW,1),Jo.set(this._handle,Yo.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(),pC.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=Jo.get(this._handle,Yo.SUB_MODEL_ARRAY);i&&Lo.free(i);var o=Jo.get(this._handle,Yo.INSTANCED_BUFFER);o&&Vo.free(o);var r=Jo.get(this._handle,Yo.INSTANCED_ATTR_ARRAY);r&&Io(r,zo,fC),Jo.free(this._handle),this._handle=bo}this._hWorldBounds&&(or.free(this._hWorldBounds),this._hWorldBounds=bo)},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),or.setVec3(this._hWorldBounds,$o.CENTER,t.center),or.setVec3(this._hWorldBounds,$o.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),or.setVec3(this._hWorldBounds,$o.CENTER,t.center),or.setVec3(this._hWorldBounds,$o.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,o=this._instMatWorldIdx;if(o>=0){var r=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,r[o],r[o+1],r[o+2])}else this._localBuffer&&(jn.toArray(this._localData,i,Oh.MAT_WORLD_OFFSET),jn.inverseTranspose(dC,i),jn.toArray(this._localData,dC,Oh.MAT_WORLD_IT_OFFSET),this._localBuffer.update(this._localData))}},t.createBoundingShape=function(e,t){e&&t&&(this._modelBounds=fu.fromPoints(fu.create(),e,t),this._worldBounds=fu.clone(this._modelBounds),this._hWorldBounds===bo&&(this._hWorldBounds=or.alloc(),Jo.set(this._handle,Yo.WORLD_BOUNDS,this._hWorldBounds)),or.setVec3(this._hWorldBounds,$o.CENTER,this._worldBounds.center),or.setVec3(this._hWorldBounds,$o.HALF_EXTENSION,this._worldBounds.halfExtents))},t.initSubModel=function(e,t,n){this.initialize();var i=!1;if(null==this._subModels[e]?(this._subModels[e]=pC.alloc(),i=!0):this._subModels[e].destroy(),this._subModels[e].initialize(t,n.passes,this.getMacroPatches(e)),this._subModels[e].initPlanarShadowShader(),this._subModels[e].initPlanarShadowInstanceShader(),this._updateAttributesAndBinding(e),i){var o=Jo.get(this._handle,Yo.SUB_MODEL_ARRAY);Lo.assign(o,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){$n.toArray(this._localData,t,Oh.LIGHTINGMAP_UVPARAM),this._lightmap=e,this._lightmapUVParam=t,null===e&&(e=hm.get("empty-texture"));var n=e.getGFXTexture();if(n)for(var i=yd.getSampler(this._device,e.mipmaps.length>1?xC:yC),o=this._subModels,r=0;r<o.length;r++){var a=o[r].descriptorSet;a.bindTexture(e_,n),a.bindSampler(e_,i),a.update()}},t.getMacroPatches=function(){return this.receiveShadow?mC:null},t._updateAttributesAndBinding=function(e){var t=this._subModels[e];if(t){this._initLocalDescriptors(e),this._updateLocalDescriptors(e,t.descriptorSet);var n=Ro.get(Ko.get(t.handle,Wo.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(Na.INSTANCED_ARRAYS)){var n=Jo.get(this._handle,Yo.INSTANCED_BUFFER);n&&Vo.free(n);var i=Jo.get(this._handle,Yo.INSTANCED_ATTR_ARRAY);i&&Io(i,zo,fC,!1);for(var o=0,r=0;r<e.length;r++){var a=e[r];a.isInstanced&&(o+=_c[a.format].size)}var s=Vo.alloc(o),c=Vo.getBuffer(s);Jo.set(this._handle,Yo.INSTANCED_BUFFER,s);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=fC.alloc(),d=fC.get(f);d.format=_.format,d.name=_.name,d.isNormalized=_.isNormalized,d.location=_.location,l.attributes.push(d),zo.push(i,f);var p=_c[_.format];l.views.push(new(Sc(p))(c,u,p.count)),u+=p.size}}t.batchingScheme===cm.INSTANCING&&XT.get(t).destroy(),this._instMatWorldIdx=this._getInstancedAttributeIndex(Dh),this._transformUpdated=!0}},t._initLocalDescriptors=function(){this._localBuffer||(this._localBuffer=this._device.createBuffer(new Ps(La.UNIFORM|La.TRANSFER_DST,Ba.HOST|Ba.DEVICE,Oh.SIZE,Oh.SIZE)))},t._updateLocalDescriptors=function(e,t){this._localBuffer&&t.bindBuffer(Oh.BINDING,this._localBuffer)},te(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!!Jo.get(this._handle,Yo.RECEIVE_SHADOW)},set:function(e){Jo.set(this._handle,Yo.RECEIVE_SHADOW,e?1:0),this.onMacroPatchesStateChanged()}},{key:"castShadow",get:function(){return!!Jo.get(this._handle,Yo.CAST_SHADOW)},set:function(e){Jo.set(this._handle,Yo.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,Jo.set(this._handle,Yo.NODE,e.handle)}},{key:"transform",get:function(){return this._transform},set:function(e){this._transform=e,Jo.set(this._handle,Yo.TRANSFORM,e.handle)}},{key:"visFlags",get:function(){return Jo.get(this._handle,Yo.VIS_FLAGS)},set:function(e){Jo.set(this._handle,Yo.VIS_FLAGS,e)}},{key:"enabled",get:function(){return!!Jo.get(this._handle,Yo.ENABLED)},set:function(e){Jo.set(this._handle,Yo.ENABLED,e?1:0)}}]),e}()),SC=e("co",function(e){function t(){var t;return(t=e.call(this)||this)._needUpdate=!1,t._pos=void 0,t._aabb=void 0,t._hAABB=bo,t._aabb=fu.create(),t._pos=new Rn,t}ie(t,e);var n=t.prototype;return n.initialize=function(){e.prototype.initialize.call(this),this._hAABB=or.alloc(),Hr.set(this._handle,Lr.TYPE,gm.SPHERE),Hr.set(this._handle,Lr.SIZE,.15),Hr.set(this._handle,Lr.RANGE,1),Hr.set(this._handle,Lr.AABB,this._hAABB),Hr.set(this._handle,Lr.ILLUMINANCE,1700/Em(.15))},n.update=function(){if(this._node&&(this._node.hasChangedFlags||this._needUpdate)){this._node.getWorldPosition(this._pos);var e=Hr.get(this._handle,Lr.RANGE);fu.set(this._aabb,this._pos.x,this._pos.y,this._pos.z,e,e,e),this._needUpdate=!1,Hr.setVec3(this._handle,Lr.POSITION,this._pos),or.setVec3(this._hAABB,$o.CENTER,this._aabb.center),or.setVec3(this._hAABB,$o.HALF_EXTENSION,this._aabb.halfExtents)}},n.destroy=function(){return this._hAABB&&(or.free(this._hAABB),this._hAABB=bo),e.prototype.destroy.call(this)},te(t,[{key:"position",get:function(){return this._pos}},{key:"size",get:function(){return Hr.get(this._handle,Lr.SIZE)},set:function(e){Hr.set(this._handle,Lr.SIZE,e)}},{key:"range",get:function(){return Hr.get(this._handle,Lr.RANGE)},set:function(e){Hr.set(this._handle,Lr.RANGE,e),this._needUpdate=!0}},{key:"luminance",get:function(){return Hr.get(this._handle,Lr.ILLUMINANCE)},set:function(e){Hr.set(this._handle,Lr.ILLUMINANCE,e)}},{key:"aabb",get:function(){return this._aabb}}]),t}(Sm)),TC=new Rn(0,0,-1),AC=new zn,wC=new jn,CC=new jn,IC=new jn,PC=new jn,bC=e("cq",function(e){function t(){var t;return(t=e.call(this)||this)._dir=new Rn(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=bo,t._hFrustum=bo,t._aabb=fu.create(),t._frustum=Tu.create(),t._pos=new Rn,t}ie(t,e);var n=t.prototype;return n.initialize=function(){e.prototype.initialize.call(this),this._hAABB=or.alloc(),this._hFrustum=Sr.alloc(),Hr.set(this._handle,Lr.TYPE,gm.SPOT),Hr.set(this._handle,Lr.SIZE,.15),Hr.set(this._handle,Lr.AABB,this._hAABB),Hr.set(this._handle,Lr.ILLUMINANCE,1700/Em(.15)),Hr.set(this._handle,Lr.RANGE,Math.cos(Math.PI/6)),Hr.set(this._handle,Lr.ASPECT,1),Hr.setVec3(this._handle,Lr.DIRECTION,this._dir),Hr.set(this._handle,Lr.FRUSTUM,this._hFrustum)},n.update=function(){this._node&&(this._node.hasChangedFlags||this._needUpdate)&&(this._node.getWorldPosition(this._pos),Rn.transformQuat(this._dir,TC,this._node.getWorldRotation(AC)),Rn.normalize(this._dir,this._dir),Hr.setVec3(this._handle,Lr.DIRECTION,this._dir),fu.set(this._aabb,this._pos.x,this._pos.y,this._pos.z,this._range,this._range,this._range),this._node.getWorldRT(wC),jn.invert(wC,wC),jn.perspective(CC,this._angle,1,.001,this._range),jn.multiply(IC,CC,wC),this._frustum.update(IC,PC),this._needUpdate=!1,Hr.setVec3(this._handle,Lr.POSITION,this._pos),or.setVec3(this._hAABB,$o.CENTER,this._aabb.center),or.setVec3(this._hAABB,$o.HALF_EXTENSION,this._aabb.halfExtents),Au(this._hFrustum,this._frustum))},n.destroy=function(){return this._hAABB&&(or.free(this._hAABB),this._hAABB=bo),this._hFrustum&&(Sr.free(this._hFrustum),this._hFrustum=bo),e.prototype.destroy.call(this)},te(t,[{key:"position",get:function(){return this._pos}},{key:"size",get:function(){return Hr.get(this._handle,Lr.SIZE)},set:function(e){Hr.set(this._handle,Lr.SIZE,e)}},{key:"range",get:function(){return Hr.get(this._handle,Lr.RANGE)},set:function(e){this._range=e,Hr.set(this._handle,Lr.RANGE,e),this._needUpdate=!0}},{key:"luminance",get:function(){return Hr.get(this._handle,Lr.ILLUMINANCE)},set:function(e){Hr.set(this._handle,Lr.ILLUMINANCE,e)}},{key:"direction",get:function(){return this._dir}},{key:"spotAngle",get:function(){return Hr.get(this._handle,Lr.SPOT_ANGLE)},set:function(e){this._angle=e,Hr.set(this._handle,Lr.SPOT_ANGLE,Math.cos(.5*e)),this._needUpdate=!0}},{key:"aspect",get:function(){return Hr.get(this._handle,Lr.ASPECT)},set:function(e){Hr.set(this._handle,Lr.ASPECT,e),this._needUpdate=!0}},{key:"aabb",get:function(){return this._aabb}},{key:"frustum",get:function(){return this._frustum}}]),t}(Sm)),RC=Object.freeze({__proto__:null,Ambient:aa,get CameraFOVAxis(){return a_},get CameraProjection(){return s_},get CameraAperture(){return c_},get CameraISO(){return l_},get CameraShutter(){return u_},SKYBOX_FLAG:T_,Camera:w_,CameraVisFlags:vm,VisibilityFlags:ym,DirectionalLight:wm,ColorTemperatureToRGB:xm,get LightType(){return gm},nt2lm:Em,Light:Sm,get ModelType(){return uC},Model:EC,ShadowType:dE,PCFType:pE,Shadows:vE,RenderScene:C_,Skybox:jE,SphereLight:SC,SpotLight:bC,SubModel:_C});function NC(e){return--e,e|=e>>16,e|=e>>8,e|=e>>4,e|=e>>2,e|=e>>1,++e}function OC(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"}(vC||(vC={})),function(e){e[e.DEFAULT=1]="DEFAULT",e[e.FORWARD=2]="FORWARD",e[e.SHADOWCAST=4]="SHADOWCAST"}(gC||(gC={}));var DC=e("cv",function(){function e(e){this._device=void 0,this._format=Oa.UNKNOWN,this._formatSize=0,this._chunks=[],this._chunkCount=0,this._handles=[],this._region0=new As,this._region1=new As,this._region2=new As,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=_c[e.format];this._format=e.format,this._formatSize=t.size,this._channels=t.count,this._bufferViewCtor=Sc(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=OC(e,this._alignment);var n=-1,i=-1;if(void 0!==t&&(n=t,i=this._findAvailableSpace(e,n)),i<0)for(var o=0;o<this._chunkCount&&(n=o,!((i=this._findAvailableSpace(e,n))>=0));++o);if(i>=0){var r=this._chunks[n];r.start+=e;var a={chunkIdx:n,start:i,end:i+e,texture:r.texture};return this._handles.push(a),a}var s=Math.sqrt(e/this._formatSize),c=this._roundUpFn&&this._roundUpFn(s,this._formatSize)||Math.max(1024,NC(s)),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 Ds(Ua.TEX2D,Ha.SAMPLED|Ha.TRANSFER_DST,this._format,e,e,Ga.IMMUTABLE)),size:t,start:0,end:t};return this._chunks[this._chunkCount]=n,this._chunkCount++},t.update=function(e,t){var n=[],i=[],o=e.start/this._formatSize,r=t.byteLength/this._formatSize,a=o%e.texture.width,s=Math.floor(o/e.texture.width),c=Math.min(e.texture.width-a,r),l=0;a>0&&(this._region0.texOffset.x=a,this._region0.texOffset.y=s,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),a=0,s+=1,r-=c,l+=c),r>0&&(this._region1.texOffset.x=a,this._region1.texOffset.y=s,r>e.texture.width?(this._region1.texExtent.width=e.texture.width,this._region1.texExtent.height=Math.floor(r/e.texture.width),c=this._region1.texExtent.width*this._region1.texExtent.height):(c=r,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),a=0,s+=this._region1.texExtent.height,r-=c,l+=c),r>0&&(this._region2.texOffset.x=a,this._region2.texOffset.y=s,this._region2.texExtent.width=r,this._region2.texExtent.height=1,n.push(new this._bufferViewCtor(t,l*this._formatSize,r*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,o=n.start;if(o+e<=n.size)i=!0;else{o=0;for(var r=this._handles.filter((function(e){return e.chunkIdx===t})).sort((function(e,t){return e.start-t.start})),a=0;a<r.length;a++){var s=r[a];if(o+e<=s.start){i=!0;break}o=s.end}!i&&o+e<=n.size&&(i=!0)}return i?o:-1},t._McDonaldAlloc=function(e){e=OC(e,this._alignment);for(var t=0;t<this._chunkCount;++t){var n=this._chunks[t],i=!1,o=n.start;if(o+e<=n.end?i=!0:o>n.end?o+e<=n.size?i=!0:e<=n.end&&(n.start=o=0,i=!0):o===n.end&&(n.start=o=0,n.end=n.size,e<=n.end&&(i=!0)),i){n.start+=e;var r={chunkIdx:t,start:o,end:o+e,texture:n.texture};return this._handles.push(r),r}}var a=Math.sqrt(e/this._formatSize),s=this._roundUpFn&&this._roundUpFn(a,this._formatSize)||Math.max(1024,NC(a)),c=this._chunks[this.createChunk(s)];c.start+=e;var l={chunkIdx:this._chunkCount,start:0,end:e,texture:c.texture};return this._handles.push(l),l},e}()),MC=function(e){if(void 0===go[e]){var t=1<<vo;go[e]=t,vo+=1}},LC=Object.freeze({__proto__:null,addStage:MC,scene:RC,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,o=0;o<i;++o)n.push(t.positions[3*o],t.positions[3*o+1],t.positions[3*o+2]),t.normals&&n.push(t.normals[3*o],t.normals[3*o+1],t.normals[3*o+2]),t.uvs&&n.push(t.uvs[2*o],t.uvs[2*o+1]),t.colors&&n.push(t.colors[3*o],t.colors[3*o+1],t.colors[3*o+2]);var r=[];r.push(new js(ds.ATTR_POSITION,Oa.RGB32F)),t.normals&&r.push(new js(ds.ATTR_NORMAL,Oa.RGB32F)),t.uvs&&r.push(new js(ds.ATTR_TEX_COORD,Oa.RG32F)),t.colors&&r.push(new js(ds.ATTR_COLOR,Oa.RGB32F));var a=e.createBuffer(new Ps(La.VERTEX|La.TRANSFER_DST,Ba.HOST|Ba.DEVICE,4*n.length,4*n.length/i));a.update(new Float32Array(n));var s=null;return t.indices&&(s=e.createBuffer(new Ps(La.INDEX|La.TRANSFER_DST,Ba.HOST|Ba.DEVICE,2*t.indices.length,2))).update(new Uint16Array(t.indices)),e.createInputAssembler(new Ys(r,[a],s))},get RenderQueue(){return vC},get PassStage(){return gC},get PropertyType(){return Lp},genHandle:Gp,getPropertyTypeFromHandle:Vp,getTypeFromHandle:kp,getSetIndexFromHandle:function(e){return(e&Up)>>>20},getBindingFromHandle:Wp,getOffsetFromHandle:jp,customizeType:qp,type2reader:Yp,type2writer:Xp,getDefaultFromType:Qp,overrideMacros:Zp,get BatchingSchemes(){return cm},Pass:mm,getDeviceShaderVersion:om,programLib:rm,get SamplerInfoIndex(){return $f},defaultSamplerHash:nd,genSamplerHash:rd,samplerLib:yd,nearestPOT:NC,TextureBufferPool:DC,MaterialInstance:VE,PassInstance:GE,ObjectPool:Ao,freeHandleArray:Io,get PoolType(){return So},NULL_HANDLE:bo,ShaderPool:Ro,DSPool:No,IAPool:Oo,PipelineLayoutPool:Do,FramebufferPool:Mo,SubModelArrayPool:Lo,ModelArrayPool:Fo,AttributeArrayPool:zo,FlatBufferArrayPool:Bo,LightArrayPool:Uo,BlendTargetArrayPool:Ho,UIBatchArrayPool:Go,RawBufferPool:Vo,RawObjectPool:ko,get PassView(){return Po},PassPool:qo,get SubModelView(){return Wo},SubModelPool:Ko,get ModelView(){return Yo},ModelPool:Jo,get BatchView2D(){return Qo},BatchPool2D:tr,get AABBView(){return $o},AABBPool:or,get SceneView(){return nr},ScenePool:sr,get CameraView(){return rr},CameraPool:ur,get NodeView(){return cr},NodePool:fr,get RootView(){return _r},RootPool:mr,get RenderWindowView(){return dr},RenderWindowPool:yr,get FrustumView(){return vr},FrustumPool:Sr,get AmbientView(){return xr},AmbientPool:wr,get SkyboxView(){return Ar},SkyboxPool:Pr,get FogView(){return Cr},FogPool:Nr,get ShadowsView(){return Rr},ShadowsPool:Mr,get PipelineSceneDataView(){return Dr},PipelineSceneDataPool:zr,get LightView(){return Lr},LightPool:Hr,get SphereView(){return Br},SpherePool:kr,get FlatBufferView(){return Vr},FlatBufferPool:qr,get SubMeshView(){return Wr},SubMeshPool:Kr,get RasterizerStateView(){return Yr},RasterizerStatePool:Jr,get DepthStencilStateView(){return Qr},DepthStencilStatePool:ta,get BlendTargetView(){return $r},BlendTargetPool:ia,get BlendStateView(){return na},BlendStatePool:ra});function FC(e){return e*e}function zC(e){return e*(2-e)}function BC(e){return e*e*e}function UC(e){return--e*e*e+1}function HC(e){return e*e*e*e}function GC(e){return 1- --e*e*e*e}function VC(e){return e*e*e*e*e}function kC(e){return--e*e*e*e*e+1}function WC(e){return 1===e?1:1-Math.cos(e*Math.PI/2)}function jC(e){return Math.sin(e*Math.PI/2)}function qC(e){return 0===e?0:Math.pow(1024,e-1)}function YC(e){return 1===e?1:1-Math.pow(2,-10*e)}function XC(e){return 1-Math.sqrt(1-e*e)}function KC(e){return Math.sqrt(1- --e*e)}function QC(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 ZC(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 JC(e){if(1===e)return 1;var t=1.70158;return e*e*((t+1)*e-t)}function $C(e){if(0===e)return 0;var t=1.70158;return--e*e*((t+1)*e+t)+1}function eI(e){return 1-tI(1-e)}function tI(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("ey",LC);var nI=_I(FC,zC),iI=_I(BC,UC),oI=_I(HC,GC),rI=_I(VC,kC),aI=_I(WC,jC),sI=_I(qC,YC),cI=_I(XC,KC),lI=_I(QC,ZC),uI=_I(JC,$C),hI=_I(eI,tI);function _I(e,t){return function(n){return n<.5?t(2*n)/2:e(2*n-1)/2+.5}}var fI=Object.freeze({__proto__:null,constant:function(){return 0},linear:function(e){return e},quadIn:FC,quadOut:zC,quadInOut:function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)},cubicIn:BC,cubicOut:UC,cubicInOut:function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)},quartIn:HC,quartOut:GC,quartInOut:function(e){return(e*=2)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2)},quintIn:VC,quintOut:kC,quintInOut:function(e){return(e*=2)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2)},sineIn:WC,sineOut:jC,sineInOut:function(e){return.5*(1-Math.cos(Math.PI*e))},expoIn:qC,expoOut:YC,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:XC,circOut:KC,circInOut:function(e){return(e*=2)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1)},elasticIn:QC,elasticOut:ZC,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:JC,backOut:$C,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:eI,bounceOut:tI,bounceInOut:function(e){return e<.5?.5*eI(2*e):.5*tI(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:nI,cubicOutIn:iI,quartOutIn:oI,quintOutIn:rI,sineOutIn:aI,expoOutIn:sI,circOutIn:cI,elasticOutIn:lI,backOutIn:uI,bounceOutIn:hI});e("en",fI);var dI=new Kn,pI=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.settings=window._CCSettings.splashScreen;t.totalTime=null!=this.settings.totalTime?this.settings.totalTime:3e3,t.base64src=this.settings.base64src||"",t.effect=this.settings.effect||"FADE-INOUT",t.clearColor=this.settings.clearColor||new Cs(.88,.88,.88,1),t.displayRatio=null!=this.settings.displayRatio?this.settings.displayRatio:.4,t.displayWatermark=null==this.settings.displayWatermark||this.settings.displayWatermark}else this.settings={totalTime:3e3,base64src:"",effect:"FADE-INOUT",clearColor:new Cs(.88,.88,.88,1),displayRatio:.4,displayWatermark:!0};if(""===this.settings.base64src||this.settings.totalTime<=0)this.callBack&&this.callBack(),this.callBack=null,this.settings=null,this._directCall=!0;else{c.view.enableRetina(!0),c.view.resizeWithBrowserSize(!0);var n=window._CCSettings.designResolution;n?c.view.setDesignResolutionSize(n.width,n.height,n.policy):c.view.setDesignResolutionSize(960,640,4),this.root=e,this.device=e.device,c.game.once(c.Game.EVENT_GAME_INITED,(function(){c.director._lateUpdate=performance.now()}),c.director),this.callBack=null,this.cancelAnimate=!1,this.startTime=-1,this.preInit(),this.logoImage=new Image,this.logoImage.onload=this.init.bind(this),this.logoImage.src=this.settings.base64src}}else x("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(),c.game.resume())},e.preInit=function(){var e=this.settings.clearColor;this.clearColors=[new Cs(e.x,e.y,e.z,e.w)];var t=this.device;this.renderArea=new gs(0,0,t.width,t.height),this.framebuffer=this.root.mainWindow.framebuffer,this.cmdBuff=t.commandBuffer;var n=new Float32Array([.5,.5,1,0,-.5,.5,0,0,.5,-.5,1,1,-.5,-.5,0,1]),i=4*Float32Array.BYTES_PER_ELEMENT,o=4*i;this.vertexBuffers=t.createBuffer(new Ps(La.VERTEX|La.TRANSFER_DST,Ba.HOST|Ba.DEVICE,o,i)),this.vertexBuffers.update(n);var r=new Uint16Array([0,1,2,1,3,2]),a=Uint16Array.BYTES_PER_ELEMENT,s=6*a;this.indicesBuffers=t.createBuffer(new Ps(La.INDEX|La.TRANSFER_DST,Ba.HOST|Ba.DEVICE,s,a)),this.indicesBuffers.update(r);var c=[new js("a_position",Oa.RG32F),new js("a_texCoord",Oa.RG32F)],l=new Ys(c,[this.vertexBuffers],this.indicesBuffers);this.quadAssmebler=t.createInputAssembler(l),this.projection=new jn,jn.ortho(this.projection,-1,1,-1,1,-1,1,t.capabilities.clipSpaceMinZ,t.capabilities.clipSpaceSignY,t.surfaceTransform)},e.init=function(){var e=this;this.initLogo(),this.settings.displayWatermark&&this.initWarterMark(),c.game.pause(),this.handle=requestAnimationFrame((function t(n){if(!e.cancelAnimate){var i=e.settings,o=e.device;jn.ortho(e.projection,-1,1,-1,1,-1,1,o.capabilities.clipSpaceMinZ,o.capabilities.clipSpaceSignY,o.surfaceTransform);var r=o.width,a=o.height,s=r<a?r:a;e.startTime<0&&(e.startTime=n);var c=n-e.startTime,l=UC(hn(c/i.totalTime));"NONE"===i.effect&&(l=1);var u=e.logoTexture.width,h=e.logoTexture.height,_=s*i.displayRatio,f=_*u/h,d=_;if(o.surfaceTransform!==Ra.ROTATE_90&&o.surfaceTransform!==Ra.ROTATE_270||(f=_*r/a,d=_*h/u*a/r),e.logoMat.setProperty("resolution",dI.set(r,a),0),e.logoMat.setProperty("scale",dI.set(f,d),0),e.logoMat.setProperty("translate",dI.set(.5*r,.5*a),0),e.logoMat.setProperty("precent",l),e.logoMat.setProperty("u_projection",e.projection),e.logoMat.passes[0].update(),i.displayWatermark&&e.watermarkMat){var p=.5*s,m=e.watermarkTexture.width,v=p,g=p*e.watermarkTexture.height/m;o.surfaceTransform!==Ra.ROTATE_90&&o.surfaceTransform!==Ra.ROTATE_270||(v=.5*p,g=p*r/a*.5),e.watermarkMat.setProperty("resolution",dI.set(r,a),0),e.watermarkMat.setProperty("scale",dI.set(v,g),0),e.watermarkMat.setProperty("translate",dI.set(.5*r,.1*a),0),e.watermarkMat.setProperty("precent",l),e.watermarkMat.setProperty("u_projection",e.projection),e.watermarkMat.passes[0].update()}e.frame(),c>i.totalTime&&(e.splashFinish=!0),requestAnimationFrame(t)}}))},e.hide=function(){cancelAnimationFrame(this.handle),this.cancelAnimate=!0,setTimeout(this.destroy.bind(this))},e.initLogo=function(){var e=this.device;this.logoMat=new fE,this.logoMat.initialize({effectName:"splash-screen"});var t=new Ls;t.addressU=Wa.CLAMP,t.addressV=Wa.CLAMP,t.addressW=Wa.CLAMP,this.sampler=e.createSampler(t),this.logoTexture=e.createTexture(new Ds(Ua.TEX2D,Ha.SAMPLED|Ha.TRANSFER_DST,Oa.RGBA8,this.logoImage.width,this.logoImage.height));var n=this.logoMat.passes[0],i=n.getBinding("mainTexture");n.bindTexture(i,this.logoTexture),this.shader=Ro.get(n.getShaderVariant());var o=No.get(qo.get(n.handle,Po.DESCRIPTOR_SET));o.bindSampler(i,this.sampler),o.update();var r=new As;r.texExtent.width=this.logoImage.width,r.texExtent.height=this.logoImage.height,r.texExtent.depth=1,e.copyTexImagesToTexture([this.logoImage],this.logoTexture,[r])},e.initWarterMark=function(){var e=document.createElement("canvas");e.width=330,e.height=30,e.style.width=""+e.width,e.style.height=""+e.height;var t=e.getContext("2d");t.font="18px Arial",t.textBaseline="top",t.textAlign="left",t.fillStyle="`#424242`";var n="Powered by Cocos Creator",i=t.measureText(n);t.fillText(n,(330-i.width)/2,6);var o=new As;o.texExtent.width=e.width,o.texExtent.height=e.height,o.texExtent.depth=1,this.watermarkTexture=this.device.createTexture(new Ds(Ua.TEX2D,Ha.SAMPLED|Ha.TRANSFER_DST,Oa.RGBA8,e.width,e.height)),this.device.copyTexImagesToTexture([e],this.watermarkTexture,[o]),this.watermarkMat=new fE,this.watermarkMat.initialize({effectName:"splash-screen"});var r=this.watermarkMat.passes[0],a=r.getBinding("mainTexture");r.bindTexture(a,this.watermarkTexture),No.get(qo.get(r.handle,Po.DESCRIPTOR_SET)).update()},e.frame=function(){var e=this.device;e.acquire();var t=this.cmdBuff,n=this.framebuffer,i=this.renderArea;i.width=e.width,i.height=e.height,t.begin(),t.beginRenderPass(n.renderPass,n,i,this.clearColors,1,0);var o=this.logoMat.passes[0],r=NT.getOrCreatePipelineState(e,o,this.shader,n.renderPass,this.quadAssmebler);if(t.bindPipelineState(r),t.bindDescriptorSet(th.MATERIAL,o.descriptorSet),t.bindInputAssembler(this.quadAssmebler),t.draw(this.quadAssmebler),this.settings.displayWatermark&&this.watermarkMat){var a=this.watermarkMat.passes[0],s=NT.getOrCreatePipelineState(e,a,this.shader,n.renderPass,this.quadAssmebler);t.bindPipelineState(s),t.bindDescriptorSet(th.MATERIAL,a.descriptorSet),t.bindInputAssembler(this.quadAssmebler),t.draw(this.quadAssmebler)}t.endRenderPass(),t.end(),e.flushCommands([t]),e.queue.submit([t]),e.present()},e.destroy=function(){this.callBack=null,this.root=null,this.device=null,this.clearColors=null,this.logoImage.destroy&&this.logoImage.destroy(),this.logoImage=null,this.framebuffer=null,this.renderArea=null,this.cmdBuff=null,this.shader=null,this.logoMat.destroy(),this.logoMat=null,this.logoTexture.destroy(),this.logoTexture=null,this.quadAssmebler.destroy(),this.quadAssmebler=null,this.vertexBuffers.destroy(),this.vertexBuffers=null,this.indicesBuffers.destroy(),this.indicesBuffers=null,this.sampler.destroy(),this.sampler=null,this.watermarkTexture&&(this.watermarkMat.destroy(),this.watermarkMat=null,this.watermarkTexture.destroy(),this.watermarkTexture=null),this.settings=null,t._ins=void 0},te(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}();pI._ins=void 0,c.internal.SplashScreen=pI;var mI=e("e5",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(){},te(e,[{key:"priority",get:function(){return this._priority},set:function(e){this._priority=e}},{key:"id",get:function(){return this._id},set:function(e){this._id=e}}]),e}()),vI=new ge("Scheduler"),gI=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};gI.get=function(e,t,n,i){var o=gI._listEntries.pop();return o?(o.target=e,o.priority=t,o.paused=n,o.markedForDeletion=i):o=new gI(e,t,n,i),o},gI.put=function(e){gI._listEntries.length<20&&(e.target=null,gI._listEntries.push(e))},gI._listEntries=[];var yI=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};yI.get=function(e,t,n,i){var o=yI._hashUpdateEntries.pop();return o?(o.list=e,o.entry=t,o.target=n,o.callback=i):o=new yI(e,t,n,i),o},yI.put=function(e){yI._hashUpdateEntries.length<20&&(e.list=e.entry=e.target=e.callback=null,yI._hashUpdateEntries.push(e))},yI._hashUpdateEntries=[];var xI=function(e,t,n,i,o,r){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=o,this.paused=r};xI.get=function(e,t,n,i,o,r){var a=xI._hashTimerEntries.pop();return a?(a.timers=e,a.target=t,a.timerIndex=n,a.currentTimer=i,a.currentTimerSalvaged=o,a.paused=r):a=new xI(e,t,n,i,o,r),a},xI.put=function(e){xI._hashTimerEntries.length<20&&(e.timers=e.target=e.currentTimer=null,xI._hashTimerEntries.push(e))},xI._hashTimerEntries=[];var EI=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,i,o,r){return this._lock=!1,this._scheduler=e,this._target=n,this._callback=t,this._elapsed=-1,this._interval=i,this._delay=r,this._useDelay=this._delay>0,this._repeat=o,this._runForever=this._repeat===c.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}();EI._timers=[],EI.get=function(){return EI._timers.pop()||new EI},EI.put=function(e){EI._timers.length<20&&!e._lock&&(e._scheduler=e._target=e._callback=null,EI._timers.push(e))};var SI=e("ew",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=Re(!0),t._hashForTimers=Re(!0),t._currentTarget=null,t._currentTargetSalvaged=!1,t._updateHashLocked=!1,t._arrayForTimers=[],t}ie(t,e),t.enableForTarget=function(e){var t=!1;(e.uuid||e.id)&&(t=!0),t||(e.__instanceId?b(1513):e.id=vI.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,o,r;for(this._updateHashLocked=!0,1!==this._timeScale&&(e*=this._timeScale),t=0,i=(n=this._updatesNegList).length;t<i;t++)(o=n[t]).paused||o.markedForDeletion||o.target.update(e);for(t=0,i=(n=this._updates0List).length;t<i;t++)(o=n[t]).paused||o.markedForDeletion||o.target.update(e);for(t=0,i=(n=this._updatesPosList).length;t<i;t++)(o=n[t]).paused||o.markedForDeletion||o.target.update(e);var a=this._arrayForTimers;for(t=0;t<a.length;t++){if(r=a[t],this._currentTarget=r,this._currentTargetSalvaged=!1,!r.paused)for(r.timerIndex=0;r.timerIndex<r.timers.length;++r.timerIndex)r.currentTimer=r.timers[r.timerIndex],r.currentTimerSalvaged=!1,r.currentTimer.update(e),r.currentTimer=null;this._currentTargetSalvaged&&0===this._currentTarget.timers.length&&(this._removeHashElement(this._currentTarget),--t)}for(t=0,n=this._updatesNegList;t<n.length;)(o=n[t]).markedForDeletion?this._removeUpdateFromHash(o):t++;for(t=0,n=this._updates0List;t<n.length;)(o=n[t]).markedForDeletion?this._removeUpdateFromHash(o):t++;for(t=0,n=this._updatesPosList;t<n.length;)(o=n[t]).markedForDeletion?this._removeUpdateFromHash(o):t++;this._updateHashLocked=!1,this._currentTarget=null},n.schedule=function(e,t,n,i,o,r){if("function"!=typeof e){var a=e;e=t,t=a}3!==arguments.length&&4!==arguments.length&&5!==arguments.length||(r=!!i,i=c.macro.REPEAT_FOREVER,o=0),M(t,1502);var s=t.uuid||t.id;if(s){var l,u,h=this._hashForTimers[s];if(h?h.paused!==r&&b(1511):(h=xI.get(null,t,0,null,null,r),this._arrayForTimers.push(h),this._hashForTimers[s]=h),null==h.timers)h.timers=[];else for(u=0;u<h.timers.length;++u)if((l=h.timers[u])&&e===l._callback)return I(1507,l.getInterval(),n),void(l._interval=n);(l=EI.get()).initWithCallback(this,e,t,n,i,o),h.timers.push(l),this._currentTarget===h&&this._currentTargetSalvaged&&(this._currentTargetSalvaged=!1)}else N(1510)},n.scheduleUpdate=function(e,t,n){var i=e.uuid||e.id;if(i){var o=this._hashForUpdates[i];if(o&&o.entry){if(o.entry.priority===t)return o.entry.markedForDeletion=!1,void(o.entry.paused=n);if(this._updateHashLocked)return I(1506),o.entry.markedForDeletion=!1,void(o.entry.paused=n);this.unscheduleUpdate(e)}var r,a=gI.get(e,t,n,!1);0===t?(r=this._updates0List,this._appendIn(r,a)):(r=t<0?this._updatesNegList:this._updatesPosList,this._priorityIn(r,a,t)),this._hashForUpdates[i]=yI.get(r,a,e,null)}else N(1510)},n.unschedule=function(e,t){if(t&&e){var n=t.uuid||t.id;if(n){var i=this,o=i._hashForTimers[n];if(o)for(var r=o.timers,a=0,s=r.length;a<s;a++){var c=r[a];if(e===c._callback)return c!==o.currentTimer||o.currentTimerSalvaged||(o.currentTimerSalvaged=!0),r.splice(a,1),EI.put(c),o.timerIndex>=a&&o.timerIndex--,void(0===r.length&&(i._currentTarget===o?i._currentTargetSalvaged=!0:i._removeHashElement(o)))}}else N(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 N(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 o=0,r=i.length;o<r;o++)EI.put(i[o]);i.length=0,this._currentTarget===n?this._currentTargetSalvaged=!0:this._removeHashElement(n)}this.unscheduleUpdate(e)}else N(1510)}},n.unscheduleAll=function(){this.unscheduleAllWithMinPriority(c.Scheduler.PRIORITY_SYSTEM)},n.unscheduleAllWithMinPriority=function(e){var t,n,i,o=this._arrayForTimers;for(t=o.length-1;t>=0;t--)n=o[t],this.unscheduleAllForTarget(n.target);var r=0;if(e<0)for(t=0;t<this._updatesNegList.length;)r=this._updatesNegList.length,(i=this._updatesNegList[t])&&i.priority>=e&&this.unscheduleUpdate(i.target),r===this._updatesNegList.length&&t++;if(e<=0)for(t=0;t<this._updates0List.length;)r=this._updates0List.length,(i=this._updates0List[t])&&this.unscheduleUpdate(i.target),r===this._updates0List.length&&t++;for(t=0;t<this._updatesPosList.length;)r=this._updatesPosList.length,(i=this._updatesPosList[t])&&i.priority>=e&&this.unscheduleUpdate(i.target),r===this._updatesPosList.length&&t++},n.isScheduled=function(e,t){M(e,1508),M(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 o=i.timers,r=0;r<o.length;++r)if(e===o[r]._callback)return!0;return!1}N(1510)},n.pauseAllTargets=function(){return this.pauseAllTargetsWithMinPriority(c.Scheduler.PRIORITY_SYSTEM)},n.pauseAllTargetsWithMinPriority=function(e){var t,n,i,o,r=[],a=this._arrayForTimers;for(n=0,i=a.length;n<i;n++)(t=a[n])&&(t.paused=!0,r.push(t.target));if(e<0)for(n=0;n<this._updatesNegList.length;n++)(o=this._updatesNegList[n])&&o.priority>=e&&(o.paused=!0,r.push(o.target));if(e<=0)for(n=0;n<this._updates0List.length;n++)(o=this._updates0List[n])&&(o.paused=!0,r.push(o.target));for(n=0;n<this._updatesPosList.length;n++)(o=this._updatesPosList[n])&&o.priority>=e&&(o.paused=!0,r.push(o.target));return r},n.resumeTargets=function(e){if(e)for(var t=0;t<e.length;t++)this.resumeTarget(e[t])},n.pauseTarget=function(e){M(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 N(1510)},n.resumeTarget=function(e){M(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 N(1510)},n.isTargetPaused=function(e){M(e,1505);var t=e.uuid||e.id;if(!t)return N(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,o=n.length;i<o;i++)if(n[i]===e){n.splice(i,1);break}xI.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,o=n.entry,r=0,a=i.length;r<a;r++)if(i[r]===o){i.splice(r,1);break}delete this._hashForUpdates[t],gI.put(o),yI.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}(mI));SI.PRIORITY_SYSTEM=1<<31,SI.PRIORITY_NON_SYSTEM=SI.PRIORITY_SYSTEM+1,SI.ID="scheduler",c.Scheduler=SI;var TI=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=bo,this._cameras=[]}e.registerCreateFunc=function(t){t._createWindowFun=function(t){return new e(t)}};var t=e.prototype;return t.initialize=function(e,t){this._poolHandle=yr.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,o=n.depthStencilAttachment,r=0;r<i.length;r++)i[r].format===Oa.UNKNOWN&&(i[r].format=e.colorFormat);o&&o.format===Oa.UNKNOWN&&(o.format=e.depthStencilFormat),this._renderPass=e.createRenderPass(t.renderPassInfo);for(var a=0;a<i.length;a++){var s=null;this._swapchainBufferIndices&1<<a?yr.set(this._poolHandle,dr.HAS_ON_SCREEN_ATTACHMENTS,1):(s=e.createTexture(new Ds(Ua.TEX2D,Ha.COLOR_ATTACHMENT|Ha.SAMPLED,i[a].format,this._width,this._height)),yr.set(this._poolHandle,dr.HAS_OFF_SCREEN_ATTACHMENTS,1)),this._colorTextures.push(s)}o&&(this._swapchainBufferIndices>=0?(this._depthStencilTexture=e.createTexture(new Ds(Ua.TEX2D,Ha.DEPTH_STENCIL_ATTACHMENT|Ha.SAMPLED,o.format,this._width,this._height)),yr.set(this._poolHandle,dr.HAS_OFF_SCREEN_ATTACHMENTS,1)):yr.set(this._poolHandle,dr.HAS_ON_SCREEN_ATTACHMENTS,1));var c=Mo.alloc(e,new ec(this._renderPass,this._colorTextures,this._depthStencilTexture));return yr.set(this._poolHandle,dr.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&&(Mo.get(yr.get(this._poolHandle,dr.FRAMEBUFFER)).destroy(),this._poolHandle=bo)},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 o=this._colorTextures[i];o&&(o.resize(e,t),n=!0)}var r=Mo.get(yr.get(this._poolHandle,dr.FRAMEBUFFER));n&&r&&(r.destroy(),r.initialize(new ec(this._renderPass,this._colorTextures,this._depthStencilTexture)))}for(var a,s=le(this._cameras);!(a=s()).done;){var c=a.value;c.isWindowSize&&c.resize(e,t)}},t.extractRenderCameras=function(e){for(var t=0;t<this._cameras.length;t++){var n=this._cameras[t];n.enabled&&(n.update(),e.push(n))}},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}))},te(e,[{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"framebuffer",get:function(){return Mo.get(yr.get(this._poolHandle,dr.FRAMEBUFFER))}},{key:"shouldSyncSizeWithSwapchain",get:function(){return this._shouldSyncSizeWithSwapchain}},{key:"hasOnScreenAttachments",get:function(){return 1===yr.get(this._poolHandle,dr.HAS_ON_SCREEN_ATTACHMENTS)}},{key:"hasOffScreenAttachments",get:function(){return 1===yr.get(this._poolHandle,dr.HAS_OFF_SCREEN_ATTACHMENTS)}},{key:"handle",get:function(){return this._poolHandle}},{key:"cameras",get:function(){return this._cameras}}]),e}(),AI=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=bo,this._useDeferredPipeline=!1,this._device=e,this._dataPoolMgr=c.internal.DataPoolManager&&new c.internal.DataPoolManager(e),C_.registerCreateFunc(this),TI.registerCreateFunc(this),this._cameraPool=new si((function(){return new w_(t._device)}),4)}var t=e.prototype;return t.initialize=function(){var e=this;this._poolHandle=mr.alloc();var t=new Xs,n=new Ks;n.depthStoreOp=Ja.DISCARD,n.stencilStoreOp=Ja.DISCARD;var i=new Zs([t],n);return this._mainWindow=this.createWindow({title:"rootMainWindow",width:this._device.width,height:this._device.height,renderPassInfo:i,swapchainBufferIndices:-1}),this._curWindow=this._mainWindow,Promise.resolve(hm.initBuiltinRes(this._device)).then((function(){c.view.on("design-resolution-changed",(function(){var t=c.game.canvas.width,n=c.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&&(mr.free(this._poolHandle),this._poolHandle=bo)},t.resize=function(e,t){this._device.resize(e,t),this._mainWindow.resize(e,t);for(var n,i=le(this._windows);!(n=i()).done;){var o=n.value;o.shouldSyncSizeWithSwapchain&&o.resize(e,t)}this._pipeline&&this._pipeline.resize(e,t)},t.setRenderPipeline=function(e){if(e instanceof Zw&&(this._useDeferredPipeline=!0),e||(e=$w()),this._pipeline=e,!this._pipeline.activate())return!1;var t=c.director.getScene();return t&&t.globals.activate(),this.onGlobalPipelineStateChanged(),!(!this._batcher&&c.internal.Batcher2D&&(this._batcher=new c.internal.Batcher2D(this),!this._batcher.initialize())&&(this.destroy(),1))},t.onGlobalPipelineStateChanged=function(){for(var e=0;e<this._scenes.length;e++)this._scenes[e].onGlobalPipelineStateChanged();this._pipeline.pipelineSceneData.initDeferredPassInfo()},t.activeWindow=function(e){this._curWindow=e},t.resetCumulativeTime=function(){mr.set(this._poolHandle,_r.CUMULATIVE_TIME,0)},t.frameMove=function(e){mr.set(this._poolHandle,_r.FRAME_TIME,e),++this._frameCount,mr.set(this._poolHandle,_r.CUMULATIVE_TIME,mr.get(this._poolHandle,_r.CUMULATIVE_TIME)+e),this._fpsTime+=e,this._fpsTime>1&&(this._fps=this._frameCount,this._frameCount=0,this._fpsTime=0);for(var t=0;t<this._scenes.length;++t)this._scenes[t].removeBatches();this._batcher&&this._batcher.update();for(var n=this._windows,i=[],o=0;o<n.length;o++)n[o].extractRenderCameras(i);if(this._pipeline&&i.length>0){this._device.acquire();var r=this._scenes,a=c.director.getTotalFrames();this._batcher&&this._batcher.uploadBuffers();for(var s=0;s<r.length;s++)r[s].update(a);c.director.emit(c.Director.EVENT_BEFORE_COMMIT),i.sort((function(e,t){return e.priority-t.priority})),this._pipeline.render(i),this._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=le(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=le(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 si((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)):b(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 si((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 gm.SPHERE:e.scene.removeSphereLight(e);break;case gm.SPOT:e.scene.removeSpotLight(e)}},te(e,[{key:"device",get:function(){return this._device}},{key:"mainWindow",get:function(){return this._mainWindow}},{key:"curWindow",get:function(){return this._curWindow},set:function(e){this._curWindow=e}},{key:"tempWindow",get:function(){return this._tempWindow},set:function(e){this._tempWindow=e}},{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 mr.get(this._poolHandle,_r.CUMULATIVE_TIME)}},{key:"frameTime",get:function(){return mr.get(this._poolHandle,_r.FRAME_TIME)}},{key:"frameCount",get:function(){return this._frameCount}},{key:"fps",get:function(){return this._fps}},{key:"fixedFPS",get:function(){return this._fixedFPS},set:function(e){e>0?(this._fixedFPS=e,this._fixedFPSFrameTime=1e3/e):this._fixedFPSFrameTime=0}},{key:"dataPoolManager",get:function(){return this._dataPoolMgr}},{key:"handle",get:function(){return this._poolHandle}},{key:"useDeferredPipeline",get:function(){return this._useDeferredPipeline}}]),e}();c.Root=AI;var wI={};q(wI,"vmath",[{name:"vec2",newName:"Vec2",target:ai,targetName:"math"},{name:"vec3",newName:"Vec3",target:ai,targetName:"math"},{name:"vec4",newName:"Vec4",target:ai,targetName:"math"},{name:"quat",newName:"Quat",target:ai,targetName:"math"},{name:"mat3",newName:"Mat3",target:ai,targetName:"math"},{name:"mat4",newName:"Mat4",target:ai,targetName:"math"},{name:"color4",newName:"Color",target:ai,targetName:"math"},{name:"rect",newName:"Rect",target:ai,targetName:"math"},{name:"approx",newName:"approx",target:ai,targetName:"math"},{name:"EPSILON",newName:"EPSILON",target:ai,targetName:"math"},{name:"equals",newName:"equals",target:ai,targetName:"math"},{name:"clamp",newName:"clamp",target:ai,targetName:"math"},{name:"clamp01",newName:"clamp01",target:ai,targetName:"math"},{name:"lerp",newName:"lerp",target:ai,targetName:"math"},{name:"toRadian",newName:"toRadian",target:ai,targetName:"math"},{name:"toDegree",newName:"toDegree",target:ai,targetName:"math"},{name:"random",newName:"random",target:ai,targetName:"math"},{name:"randomRange",newName:"randomRange",target:ai,targetName:"math"},{name:"randomRangeInt",newName:"randomRangeInt",target:ai,targetName:"math"},{name:"pseudoRandom",newName:"pseudoRandom",target:ai,targetName:"math"},{name:"pseudoRandomRangeInt",newName:"pseudoRandomRangeInt",target:ai,targetName:"math"},{name:"nextPow2",newName:"nextPow2",target:ai,targetName:"math"},{name:"repeat",newName:"repeat",target:ai,targetName:"math"},{name:"pingPong",newName:"pingPong",target:ai,targetName:"math"},{name:"inverseLerp",newName:"inverseLerp",target:ai,targetName:"math"}]),c.vmath=wI,q(SI.prototype,"Scheduler.prototype",[{name:"enableForTarget",newName:"enableForTarget",target:SI,targetName:"Scheduler"}]),q(Vy.prototype,"EventTouch.prototype",[{name:"getUILocationInView",newName:"getLocationInView",target:Vy,targetName:"EventTouch"}]),q(_C.prototype,"SubModel.prototype",[{name:"subMeshData",newName:"subMesh"}]),Y(_C.prototype,"SubModel.prototype",[{name:"getSubModel",suggest:"Use `subModels[i]` instead"},{name:"subModelNum",suggest:"Use `subModels.length` instead"}]),q(AI.prototype,"Root.prototype",[{name:"ui",newName:"batcher2D"}]);var CI=Object.freeze({__proto__:null,ccclass:L_,property:U_,requireComponent:F_,executionOrder:z_,disallowMultiple:B_,executeInEditMode:k_,menu:W_,playOnFocus:j_,inspector:q_,icon:Y_,help:X_,type:hf,integer:sf,float:cf,boolean:lf,string:uf});e("f0",CI);var II,PI,bI,RI,NI,OI,DI,MI,LI,FI,zI,BI=hi.Flags.Destroyed,UI=hi.Flags.PersistentMask,HI=[];function GI(e){var t;if(e instanceof hi){if(e._instantiate)return c.game._isCloning=!0,t=e._instantiate(null,!0),c.game._isCloning=!1,t;if(e instanceof c.Asset)throw new TypeError(L(6903))}return c.game._isCloning=!0,t=VI(e),c.game._isCloning=!1,t}function VI(e,t){var n;kI(e,n=e._iN$t?e._iN$t:e.constructor?new(0,e.constructor):Object.create(null),t);for(var i=0,o=HI.length;i<o;++i)HI[i]._iN$t=null;return HI.length=0,n}function kI(e,t,n){at.value(e,"_iN$t",t,!0),HI.push(e);var i=e.constructor;if(c.Class._isCCClass(i))!function(e,t,n,i){for(var o=e.__values__,r=0;r<o.length;r++){var a=o[r],s=t[a];if("object"==typeof s&&s){var c=n[a];c instanceof _t&&c.constructor===s.constructor?c.set(s):n[a]=s._iN$t||WI(s,i)}else n[a]=s}}(i,e,t,n);else for(var o in e)if(e.hasOwnProperty(o)&&(95!==o.charCodeAt(0)||95!==o.charCodeAt(1)||"__type__"===o)){var r=e[o];if("object"==typeof r&&r){if(r===t)continue;t[o]=r._iN$t||WI(r,n)}else t[o]=r}e instanceof hi&&(t._objFlags&=UI)}function WI(e,t){if(e instanceof _t)return e.clone();if(e instanceof c.Asset)return e;var n;if(ArrayBuffer.isView(e)){var i=e.length;n=new e.constructor(i),e._iN$t=n,HI.push(e);for(var o=0;o<i;++o)n[o]=e[o];return n}if(Array.isArray(e)){var r=e.length;n=new Array(r),e._iN$t=n,HI.push(e);for(var a=0;a<r;++a){var s=e[a];n[a]="object"==typeof s&&s?s._iN$t||WI(s,t):s}return n}if(e._objFlags&BI)return null;var l=e.constructor;if(c.Class._isCCClass(l)){if(t)if(t instanceof c.Component){if(e instanceof c._BaseNode||e instanceof c.Component)return e}else if(t instanceof c._BaseNode)if(e instanceof c._BaseNode){if(!e.isChildOf(t))return e}else if(e instanceof c.Component&&e.node&&!e.node.isChildOf(t))return e;n=new l}else if(l===Object)n={};else{if(l)return e;n=Object.create(null)}return kI(e,n,t),n}function jI(e,t){return(t<<3)+e}GI._clone=VI,c.instantiate=GI,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"}(FI||(FI={})),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"}(zI||(zI={}));var qI=e("f4",L_("cc.CompactValueTypeArray")((MI=DI=function(){function e(){ue(this,"_byteOffset",bI,this),ue(this,"_unitCount",RI,this),ue(this,"_unitElement",NI,this),ue(this,"_length",OI,this)}return e.lengthFor=function(e,t,n){return YI(t).requiredUnits*e.length*XI(n).BYTES_PER_ELEMENT},e.compress=function(t,n,i,o,r,a){for(var s=YI(n),c=XI(i),l=s.requiredUnits*t.length,u=new c(o,r,l),h=0;h<t.length;++h)s.compress(u,h,t[h]);var _=new e;return _._unitElement=jI(i,n),_._byteOffset=a,_._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,o=YI(n.elementType),r=new(XI(i))(e,this._byteOffset,this._unitCount),a=new Array(this._length),s=0;s<this._length;++s)a[s]=o.decompress(r,s);return a},e}(),DI.StorageUnit=FI,DI.ElementType=zI,bI=he((PI=MI).prototype,"_byteOffset",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),RI=he(PI.prototype,"_unitCount",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),NI=he(PI.prototype,"_unitElement",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return jI(FI.Uint8,zI.Scalar)}}),OI=he(PI.prototype,"_length",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),II=PI))||II);function YI(e){return ZI[e]}function XI(e){switch(e){case FI.Uint8:return Uint8Array;case FI.Uint16:return Uint16Array;case FI.Uint32:return Uint32Array;case FI.Int8:return Int8Array;case FI.Int16:return Int16Array;case FI.Int32:return Int32Array;case FI.Float32:return Float32Array;case FI.Float64:return Float64Array}}var KI,QI,ZI=((LI={})[zI.Scalar]={requiredUnits:1,compress:function(e,t,n){e[t]=n},decompress:function(e,t){return e[t]}},LI[zI.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 Rn(e[2*t],e[2*t+1])}},LI[zI.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 Rn(e[3*t],e[3*t+1],e[3*t+2])}},LI[zI.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 $n(e[4*t],e[4*t+1],e[4*t+2],e[4*t+3])}},LI[zI.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 zn(e[4*t],e[4*t+1],e[4*t+2],e[4*t+3])}},LI[zI.Mat4]={requiredUnits:16,compress:function(e,t,n){jn.toArray(e,n,16*t)},decompress:function(e,t){return jn.fromArray(new jn,e,16*t)}},LI);c._decorator=CI,Y(Ed.prototype,"TextureBase.prototype",[{name:"hasPremultipliedAlpha"},{name:"setPremultiplyAlpha"},{name:"setFlipY"}]),q(_E.prototype,"RenderTexture.prototype",[{name:"getGFXWindow",customFunction:function(){return this._window}}]);var JI,$I=e("f5",L_("cc.BufferAsset")((he((QI=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return(t=e.call.apply(e,[this].concat(i))||this)._buffer=null,t}ie(t,e);var n=t.prototype;return n.buffer=function(){return this._buffer},n.validate=function(){return!!this.buffer},te(t,[{key:"_nativeAsset",get:function(){return this._buffer},set:function(e){e instanceof ArrayBuffer?this._buffer=e:this._buffer=e.buffer}}]),t}(kf)).prototype,"_nativeAsset",[_f],Object.getOwnPropertyDescriptor(QI.prototype,"_nativeAsset"),QI.prototype),KI=QI))||KI);c.BufferAsset=$I;var eP=((JI={})[Da.UNORM]="Uint",JI[Da.SNORM]="Int",JI[Da.UINT]="Uint",JI[Da.INT]="Int",JI[Da.UFLOAT]="Float",JI[Da.FLOAT]="Float",JI.default="Uint",JI);function tP(e){return""+(eP[e.type]||eP.default)+e.size/e.count*8}function nP(e,t,n,i,o,r,a){void 0===n&&(n=Oa.R32F),void 0===i&&(i=0),void 0===o&&(o=e.byteLength-i),void 0===r&&(r=0),a||(a=new DataView(e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)));var s=_c[n];r||(r=s.size);for(var c="set"+tP(s),l="get"+tP(s),u=s.size/s.count,h=Math.floor(o/r),_=mx.isLittleEndian,f=0;f<h;++f)for(var d=i+r*f,p=0;p<s.count;++p){var m=d+u*p,v=e[l](m,_);a[c](m,t(v,p,e),_)}return a}e("bR",function(){function e(e,t,n,i,o){void 0===i&&(i=null),void 0===o&&(o=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=bo,this._attributes=t,this._vertexBuffers=e,this._indexBuffer=i,this._indirectBuffer=o,this._primitiveMode=n,this._iaInfo=new Ys(t,e,i,o),this._handle=Kr.alloc();var r=Bo.alloc();Kr.set(this._handle,Wr.FLAT_BUFFER_ARRAY,r)}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=Kr.get(this._handle,Wr.FLAT_BUFFER_ARRAY);n.indexView&&(t=n.indexView.count);for(var o=0;o<n.vertexBundelIndices.length;o++){var r=n.vertexBundelIndices[o],a=e.struct.vertexBundles[r],s=n.indexView?n.indexView.count:a.view.count,c=a.view.stride,l=c*s,u=new Uint8Array(e.data.buffer,a.view.offset,a.view.length),h=Vo.alloc(n.indexView?l:a.view.length),_=qr.alloc();qr.set(_,Vr.STRIDE,c),qr.set(_,Vr.AMOUNT,s),qr.set(_,Vr.BUFFER,h),Bo.push(i,_);var f=Vo.getBuffer(h),d=new Uint8Array(f);if(n.indexView){for(var p=e.readIndices(this.subMeshIdx),m=0;m<t;++m)for(var v=m*c,g=p[m]*c,y=0;y<c;++y)d[v+y]=u[g+y];this._flatBuffers.push({stride:c,count:s,buffer:d})}else d.set(e.data.subarray(a.view.offset,a.view.offset+a.view.length)),this._flatBuffers.push({stride:c,count:s,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&&(Io(Kr.get(this._handle,Wr.FLAT_BUFFER_ARRAY),Bo,qr),Kr.free(this._handle),this._handle=bo)},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 js("a_vertexId",Oa.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 o=e.createBuffer(new Ps(La.VERTEX|La.TRANSFER_DST,Ba.DEVICE,n.byteLength,n.BYTES_PER_ELEMENT));return o.update(n),o},te(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:Rn.ZERO,max:Rn.ZERO}};if(void 0===this.subMeshIdx)return{positions:new Float32Array,indices:new Uint8Array,boundingBox:{min:Rn.ZERO,max:Rn.ZERO}};var e=this.mesh,t=this.subMeshIdx,n=e.readAttribute(t,ds.ATTR_POSITION),i=e.readIndices(t),o=new Rn,r=new Rn,a=this.attributes.find((function(e){return e.name===ds.ATTR_POSITION}));if(a){var s=_c[a.format].count;2===s?(o.set(n[0],n[1],0),r.set(n[0],n[1],0)):(o.set(n[0],n[1],n[2]),r.set(n[0],n[1],n[2]));for(var c=0;c<n.length;c+=s)2===s?(o.x=n[c]>o.x?n[c]:o.x,o.y=n[c+1]>o.y?n[c+1]:o.y,r.x=n[c]<r.x?n[c]:r.x,r.y=n[c+1]<r.y?n[c+1]:r.y):(o.x=n[c]>o.x?n[c]:o.x,o.y=n[c+1]>o.y?n[c+1]:o.y,o.z=n[c+2]>o.z?n[c+2]:o.z,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)}return this._geometricInfo={positions:n,indices:i,boundingBox:{max:o,min:r}},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 i,o,r=this.mesh.struct,a=r.primitives[this.subMeshIdx];if(!r.jointMaps||void 0===a.jointMapIndex||!r.jointMaps[a.jointMapIndex])return this._jointMappedBuffers=this.vertexBuffers;for(var s=c.director.root.device,l=0;l<a.vertexBundelIndices.length;l++){var u=r.vertexBundles[a.vertexBundelIndices[l]];o=0,i=Oa.UNKNOWN;for(var h=0;h<u.attributes.length;h++){var _=u.attributes[h];if(_.name===ds.ATTR_JOINTS){i=_.format;break}o+=_c[_.format].size}i?function(){var c=new Uint8Array(e.mesh.data.buffer,u.view.offset,u.view.length),h=new DataView(c.slice().buffer),_=r.jointMaps[a.jointMapIndex];nP(h,(function(e){return _.indexOf(e)}),i,o,u.view.length,u.view.stride,h);var f=s.createBuffer(new Ps(La.VERTEX|La.TRANSFER_DST,Ba.DEVICE,u.view.length,u.view.stride));f.update(h.buffer),t.push(f),n.push(l)}():t.push(this.vertexBuffers[a.vertexBundelIndices[l]])}return this._vertexIdChannel&&t.push(this._allocVertexIdBuffer(s)),t}},{key:"iaInfo",get:function(){return this._iaInfo}},{key:"handle",get:function(){return this._handle}}]),e}());var iP=new Array(16),oP=null,rP=new Kn,aP=[Vm.TOUCH_START.toString(),Vm.TOUCH_MOVE.toString(),Vm.TOUCH_END.toString(),Vm.TOUCH_CANCEL.toString()],sP=[Vm.MOUSE_DOWN.toString(),Vm.MOUSE_ENTER.toString(),Vm.MOUSE_MOVE.toString(),Vm.MOUSE_LEAVE.toString(),Vm.MOUSE_UP.toString(),Vm.MOUSE_WHEEL.toString()];function cP(e,t){var n=this.owner;return!(!n||!n._uiProps.uiTransformComp||(e.getUILocation(rP),!n._uiProps.uiTransformComp.isHit(rP,this)||(t.type=Vm.TOUCH_START.toString(),t.touch=e,t.bubbles=!0,n.dispatchEvent(t),0)))}function lP(e,t){var n=this.owner;return!(!n||!n._uiProps.uiTransformComp||(t.type=Vm.TOUCH_MOVE.toString(),t.touch=e,t.bubbles=!0,n.dispatchEvent(t),0))}function uP(e,t){var n=this.owner;n&&n._uiProps.uiTransformComp&&(e.getUILocation(rP),n._uiProps.uiTransformComp.isHit(rP,this)?t.type=Vm.TOUCH_END.toString():t.type=Vm.TOUCH_CANCEL.toString(),t.touch=e,t.bubbles=!0,n.dispatchEvent(t))}function hP(e,t){var n=this.owner;n&&n._uiProps.uiTransformComp&&(t.type=Vm.TOUCH_CANCEL.toString(),t.touch=e,t.bubbles=!0,n.dispatchEvent(t))}function _P(e){var t=this.owner;t&&t._uiProps.uiTransformComp&&(rP=e.getUILocation(),t._uiProps.uiTransformComp.isHit(rP,this)&&(e.type=Vm.MOUSE_DOWN.toString(),e.bubbles=!0,t.dispatchEvent(e)))}function fP(e){var t=this.owner;if(t&&t._uiProps.uiTransformComp){if(rP=e.getUILocation(),t._uiProps.uiTransformComp.isHit(rP,this))this._previousIn||(oP&&oP.eventProcessor.mouseListener&&(e.type=Vm.MOUSE_LEAVE,oP.dispatchEvent(e),oP.eventProcessor.mouseListener&&(oP.eventProcessor.mouseListener._previousIn=!1)),oP=t,e.type=Vm.MOUSE_ENTER.toString(),t.dispatchEvent(e),this._previousIn=!0),e.type=Vm.MOUSE_MOVE.toString(),e.bubbles=!0,t.dispatchEvent(e);else{if(!this._previousIn)return;e.type=Vm.MOUSE_LEAVE.toString(),t.dispatchEvent(e),this._previousIn=!1,oP=null}e.propagationStopped=!0}}function dP(e){var t=this.owner;t&&t._uiProps.uiTransformComp&&(rP=e.getUILocation(),t._uiProps.uiTransformComp.isHit(rP,this)&&(e.type=Vm.MOUSE_UP.toString(),e.bubbles=!0,t.dispatchEvent(e),e.propagationStopped=!0))}function pP(e){var t=this.owner;t&&t._uiProps.uiTransformComp&&(rP=e.getUILocation(),t._uiProps.uiTransformComp.isHit(rP,this)&&(e.type=Vm.MOUSE_WHEEL.toString(),e.bubbles=!0,t.dispatchEvent(e),e.propagationStopped=!0))}function mP(e,t){if(t){for(var n=0,i=[],o=e;o&&ry.isNode(o);o=o.parent,++n){var r=o.getComponent(t);if(r){var a={index:n,comp:r};i?i.push(a):i=[a]}}return i.length>0?i:null}return null}function vP(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 gP,yP=e("d7",function(){function e(e){this.bubblingTargets=null,this.capturingTargets=null,this.touchListener=null,this.mouseListener=null,this._node=void 0,this._node=e}var t=e.prototype;return t.reattach=function(){var t;this.node.walk((function(n){t||(t=mP(n,e._comp)),n.eventProcessor.touchListener&&(n.eventProcessor.touchListener.mask=t),n.eventProcessor.mouseListener&&(n.eventProcessor.mouseListener.mask=t)}))},t.destroy=function(){oP===this._node&&(oP=null),(this.touchListener||this.mouseListener)&&(ev.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 xi),this.bubblingTargets.on(e,t,n))},t.once=function(e,t,n,i){var o,r=this;(o=this._checknSetupSysEvent(e)&&i?this.capturingTargets=this.capturingTargets||new xi:this.bubblingTargets=this.bubblingTargets||new xi).on(e,t,n,!0),o.on(e,(function(){r.off(e,t,n)}),void 0,!0)},t.off=function(e,t,n,i){var o=-1!==aP.indexOf(e),r=!o&&-1!==sP.indexOf(e);o||r?(this._offDispatch(e,t,n,i),o?this.touchListener&&!vP(this._node,aP)&&(ev.removeListener(this.touchListener),this.touchListener=null):r&&this.mouseListener&&!vP(this._node,sP)&&(ev.removeListener(this.mouseListener),this.mouseListener=null)):this.bubblingTargets&&this.bubblingTargets.off(e,t,n)},t.emit=function(e,t,n,i,o,r){this.bubblingTargets&&this.bubblingTargets.emit(e,t,n,i,o,r)},t.dispatchEvent=function(e){!function(e,t){var n,i=0;for(t.target=e,iP.length=0,e.eventProcessor.getCapturingTargets(t.type,iP),t.eventPhase=1,i=iP.length-1;i>=0;--i)if((n=iP[i]).eventProcessor.capturingTargets&&(t.currentTarget=n,n.eventProcessor.capturingTargets.emit(t.type,t,iP),t.propagationStopped))return void(iP.length=0);if(iP.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,iP),t.eventPhase=3,i=0;i<iP.length;++i)if((n=iP[i]).eventProcessor.bubblingTargets&&(t.currentTarget=n,n.eventProcessor.bubblingTargets.emit(t.type,t),t.propagationStopped))return void(iP.length=0);iP.length=0}(this._node,e),iP.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&&!vP(this.node,aP)&&(ev.removeListener(this.touchListener),this.touchListener=null),this.mouseListener&&!vP(this.node,sP)&&(ev.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(t){var n=this,i=!1,o=!1;return-1!==aP.indexOf(t)?(this.touchListener||(this.touchListener=c.EventListener.create({event:c.EventListener.TOUCH_ONE_BY_ONE,swallowTouches:!0,owner:this._node,mask:mP(this._node,e._comp),onTouchBegan:cP,onTouchMoved:lP,onTouchEnded:uP,onTouchCancelled:hP}),ev.addListener(this.touchListener,this._node),i=!0),o=!0):-1!==sP.indexOf(t)&&(this.mouseListener||(this.mouseListener=c.EventListener.create({event:c.EventListener.MOUSE,_previousIn:!1,owner:this._node,mask:mP(this._node,e._comp),onMouseDown:_P,onMouseMove:fP,onMouseUp:dP,onMouseScroll:pP}),ev.addListener(this.mouseListener,this._node),i=!0),o=!0),i&&!this._node.activeInHierarchy&&c.director.getScheduler().schedule((function(){n._node.activeInHierarchy||ev.pauseTarget(n._node)}),this._node,0,0,0,!1),o},t._onDispatch=function(e,t,n,i){if("boolean"==typeof n?(i=n,n=void 0):i=!!i,t){var o=null;return(o=i?this.capturingTargets=this.capturingTargets||new xi:this.bubblingTargets=this.bubblingTargets||new xi).hasEventListener(e,t,n)||o.on(e,t,n),t}N(6800)},t._offDispatch=function(e,t,n,i){if("boolean"==typeof n?(i=n,n=void 0):i=!!i,t){var o=i?this.capturingTargets:this.bubblingTargets;o&&o.off(e,t,n)}else this.capturingTargets&&this.capturingTargets.removeAll(e),this.bubblingTargets&&this.bubblingTargets.removeAll(e)},te(e,[{key:"node",get:function(){return this._node}}]),e}());yP._comp=null,c.NodeEventProcessor=yP,q(Cv.prototype,"BaseNode",[{name:"childrenCount",newName:"children.length",customGetter:function(){return this.children.length}}]),q(ry.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 Kn),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 ni),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)}}]),Y(ry.prototype,"Node.prototype",[{name:"addLayer"},{name:"removeLayer"}]),Y(Vu,"Layers",[{name:"All"},{name:"RaycastMask"},{name:"check"}]),q(Vu,"Layers",[{name:"Default",newName:"DEFAULT",target:Vu.Enum,targetName:"Layers.Enum"},{name:"Always",newName:"ALWAYS",target:Vu.Enum,targetName:"Layers.Enum"},{name:"IgnoreRaycast",newName:"IGNORE_RAYCAST",target:Vu.Enum,targetName:"Layers.Enum"},{name:"Gizmos",newName:"GIZMOS",target:Vu.Enum,targetName:"Layers.Enum"},{name:"Editor",newName:"EDITOR",target:Vu.Enum,targetName:"Layers.Enum"},{name:"UI",newName:"UI_3D",target:Vu.Enum,targetName:"Layers.Enum"},{name:"UI2D",newName:"UI_2D",target:Vu.Enum,targetName:"Layers.Enum"},{name:"SceneGizmo",newName:"SCENE_GIZMO",target:Vu.Enum,targetName:"Layers.Enum"},{name:"makeInclusiveMask",newName:"makeMaskInclude",target:Vu,targetName:"Layers"},{name:"makeExclusiveMask",newName:"makeMaskExclude",target:Vu,targetName:"Layers"}]),Y(Vu.Enum,"Layers.Enum",[{name:"ALWAYS"}]),Y(Vu.BitMask,"Layers.BitMask",[{name:"ALWAYS"}]);var xP,EP,SP,TP,AP,wP,CP,IP,PP,bP,RP,NP,OP,DP,MP,LP,FP,zP,BP,UP,HP,GP,VP,kP,WP,jP,qP,YP,XP,KP,QP,ZP,JP,$P,eb,tb,nb,ib,ob,rb,ab,sb,cb,lb,ub,hb,_b,fb,db,pb,mb,vb,gb,yb,xb,Eb,Sb,Tb,Ab,wb,Cb,Ib,Pb,bb,Rb,Nb,Ob,Db,Mb,Lb,Fb,zb,Bb,Ub,Hb,Gb,Vb,kb,Wb,jb,qb,Yb,Xb,Kb,Qb,Zb,Jb,$b,eR,tR,nR,iR,oR,rR,aR,sR,cR,lR,uR,hR,_R,fR,dR,pR,mR,vR,gR,yR,xR,ER,SR,TR,AR,wR,CR,IR,PR,bR,RR,NR=hi.Flags.HideInHierarchy,OR=hi.Flags.DontSave,DR=e("fR",L_("cc.PrivateNode")(gP=function(e){function t(t){var n;return b(12003,(n=e.call(this,t)||this).name),n.hideFlags|=OR|NR,n}return ie(t,e),t}(ry))||gP);c.PrivateNode=DR;var MR=new Rn(0,1,0),LR=new Rn,FR=new zn,zR=(xP=L_("cc.AmbientInfo"),EP=hf(Ft),xP((IP=function(){function e(){ue(this,"_skyColor",AP,this),ue(this,"_skyIllum",wP,this),ue(this,"_groundAlbedo",CP,this),this._resource=null}return e.prototype.activate=function(e){this._resource=e,this._resource.initialize(this)},te(e,[{key:"skyColor",get:function(){return this._skyColor},set:function(e){this._skyColor.set(e),this._resource&&(this._resource.skyColor=this._skyColor)}},{key:"skyIllum",get:function(){return this._skyIllum},set:function(e){this._skyIllum=e,this._resource&&(this._resource.skyIllum=this.skyIllum)}},{key:"groundAlbedo",get:function(){return this._groundAlbedo},set:function(e){this._groundAlbedo.set(e),this._resource&&(this._resource.groundAlbedo=this._groundAlbedo)}}]),e}(),AP=he((TP=IP).prototype,"_skyColor",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Pn(51,128,204,1)}}),wP=he(TP.prototype,"_skyIllum",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return aa.SKY_ILLUM}}),CP=he(TP.prototype,"_groundAlbedo",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Pn(51,51,51,255)}}),he(TP.prototype,"skyColor",[K_],Object.getOwnPropertyDescriptor(TP.prototype,"skyColor"),TP.prototype),he(TP.prototype,"skyIllum",[K_,EP],Object.getOwnPropertyDescriptor(TP.prototype,"skyIllum"),TP.prototype),he(TP.prototype,"groundAlbedo",[K_],Object.getOwnPropertyDescriptor(TP.prototype,"groundAlbedo"),TP.prototype),SP=TP))||SP);c.AmbientInfo=zR;var BR=(PP=L_("cc.SkyboxInfo"),bP=hf(Np),RP=hf(Np),PP((zP=function(){function e(){ue(this,"_envmap",DP,this),ue(this,"_isRGBE",MP,this),ue(this,"_enabled",LP,this),ue(this,"_useIBL",FP,this),this._resource=null}return e.prototype.activate=function(e){this._resource=e,this._resource.initialize(this),this._resource.activate()},te(e,[{key:"enabled",get:function(){return this._enabled},set:function(e){this._enabled!==e&&(this._enabled=e,this._resource&&(this._resource.enabled=this._enabled))}},{key:"useIBL",get:function(){return this._useIBL},set:function(e){this._useIBL=e,this._resource&&(this._resource.useIBL=this._useIBL)}},{key:"envmap",get:function(){return this._envmap},set:function(e){this._envmap=e,this._resource&&(this._resource.envmap=this._envmap)}},{key:"isRGBE",get:function(){return this._isRGBE},set:function(e){this._isRGBE=e,this._resource&&(this._resource.isRGBE=this._isRGBE)}}]),e}(),DP=he((OP=zP).prototype,"_envmap",[bP],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),MP=he(OP.prototype,"_isRGBE",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),LP=he(OP.prototype,"_enabled",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),FP=he(OP.prototype,"_useIBL",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),he(OP.prototype,"enabled",[K_],Object.getOwnPropertyDescriptor(OP.prototype,"enabled"),OP.prototype),he(OP.prototype,"useIBL",[K_],Object.getOwnPropertyDescriptor(OP.prototype,"useIBL"),OP.prototype),he(OP.prototype,"envmap",[K_,RP],Object.getOwnPropertyDescriptor(OP.prototype,"envmap"),OP.prototype),he(OP.prototype,"isRGBE",[K_],Object.getOwnPropertyDescriptor(OP.prototype,"isRGBE"),OP.prototype),NP=OP))||NP);c.SkyboxInfo=BR;var UR=(BP=L_("cc.FogInfo"),UP=hf(BE),HP=Q_(),GP=hf(Ft),VP=$_(),kP=nf(),WP=rf(),jP=Q_(),qP=hf(Ft),YP=nf(),XP=rf(),KP=Q_(),QP=hf(Ft),ZP=nf(),JP=rf(),$P=Q_(),eb=hf(Ft),tb=ef(),nb=nf(),ib=rf(),ob=Q_(),rb=hf(Ft),ab=nf(),sb=rf(),cb=Q_(),lb=hf(Ft),ub=nf(),hb=rf(),BP((Ab=Tb=function(){function e(){ue(this,"_type",db,this),ue(this,"_fogColor",pb,this),ue(this,"_enabled",mb,this),ue(this,"_fogDensity",vb,this),ue(this,"_fogStart",gb,this),ue(this,"_fogEnd",yb,this),ue(this,"_fogAtten",xb,this),ue(this,"_fogTop",Eb,this),ue(this,"_fogRange",Sb,this),this._resource=null}return e.prototype.activate=function(e){this._resource=e,this._resource.initialize(this),this._resource.activate()},te(e,[{key:"enabled",get:function(){return this._enabled},set:function(e){this._enabled!==e&&(this._enabled=e,this._resource&&(this._resource.enabled=e,e&&(this._resource.type=this._type)))}},{key:"fogColor",get:function(){return this._fogColor},set:function(e){this._fogColor.set(e),this._resource&&(this._resource.fogColor=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}(),Tb.FogType=BE,db=he((fb=Ab).prototype,"_type",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return BE.LINEAR}}),pb=he(fb.prototype,"_fogColor",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Pn("#C8C8C8")}}),mb=he(fb.prototype,"_enabled",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),vb=he(fb.prototype,"_fogDensity",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.3}}),gb=he(fb.prototype,"_fogStart",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.5}}),yb=he(fb.prototype,"_fogEnd",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 300}}),xb=he(fb.prototype,"_fogAtten",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 5}}),Eb=he(fb.prototype,"_fogTop",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1.5}}),Sb=he(fb.prototype,"_fogRange",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1.2}}),he(fb.prototype,"enabled",[K_],Object.getOwnPropertyDescriptor(fb.prototype,"enabled"),fb.prototype),he(fb.prototype,"fogColor",[K_],Object.getOwnPropertyDescriptor(fb.prototype,"fogColor"),fb.prototype),he(fb.prototype,"type",[K_,UP],Object.getOwnPropertyDescriptor(fb.prototype,"type"),fb.prototype),he(fb.prototype,"fogDensity",[HP,GP,VP,kP,of,WP],Object.getOwnPropertyDescriptor(fb.prototype,"fogDensity"),fb.prototype),he(fb.prototype,"fogStart",[jP,qP,YP,XP],Object.getOwnPropertyDescriptor(fb.prototype,"fogStart"),fb.prototype),he(fb.prototype,"fogEnd",[KP,QP,ZP,JP],Object.getOwnPropertyDescriptor(fb.prototype,"fogEnd"),fb.prototype),he(fb.prototype,"fogAtten",[$P,eb,tb,nb,ib],Object.getOwnPropertyDescriptor(fb.prototype,"fogAtten"),fb.prototype),he(fb.prototype,"fogTop",[ob,rb,ab,sb],Object.getOwnPropertyDescriptor(fb.prototype,"fogTop"),fb.prototype),he(fb.prototype,"fogRange",[cb,lb,ub,hb],Object.getOwnPropertyDescriptor(fb.prototype,"fogRange"),fb.prototype),_b=fb))||_b),HR=(wb=L_("cc.ShadowsInfo"),Cb=hf(dE),Ib=Q_(),Pb=hf(Ft),bb=Q_(),Rb=hf(pE),Nb=Q_(),Ob=hf(Lt),Db=Q_(),Mb=hf(Ft),Lb=Q_(),Fb=hf(zt),zb=Q_(),Bb=hf(zt),Ub=Q_(),Hb=hf(zt),Gb=Q_(),Vb=hf(Ft),kb=Q_(),Wb=hf(zt),jb=Q_(),qb=hf(Ft),Yb=Q_(),Xb=hf(Ft),Kb=Q_(),Qb=hf(Ft),Zb=Q_(),Jb=Q_(),$b=hf(Ft),eR=Q_(),wb((ER=function(){function e(){ue(this,"_type",iR,this),ue(this,"_enabled",oR,this),ue(this,"_normal",rR,this),ue(this,"_distance",aR,this),ue(this,"_shadowColor",sR,this),ue(this,"_autoAdapt",cR,this),ue(this,"_pcf",lR,this),ue(this,"_bias",uR,this),ue(this,"_packing",hR,this),ue(this,"_linear",_R,this),ue(this,"_selfShadow",fR,this),ue(this,"_normalBias",dR,this),ue(this,"_near",pR,this),ue(this,"_far",mR,this),ue(this,"_aspect",vR,this),ue(this,"_orthoSize",gR,this),ue(this,"_maxReceived",yR,this),ue(this,"_size",xR,this),this._resource=null}var t=e.prototype;return t.setPlaneFromNode=function(e){e.getWorldRotation(FR),this.normal=Rn.transformQuat(LR,MR,FR),e.getWorldPosition(LR),this.distance=Rn.dot(this._normal,LR)},t.activate=function(e){this._resource=e,this._resource.initialize(this),this._resource.activate()},te(e,[{key:"enabled",get:function(){return this._enabled},set:function(e){this._enabled!==e&&(this._enabled=e,this._resource&&(this._resource.enabled=e,e&&(this._resource.type=this._type)))}},{key:"type",get:function(){return this._type},set:function(e){this._type=e,this._resource&&(this._resource.type=e)}},{key:"shadowColor",get:function(){return this._shadowColor},set:function(e){this._shadowColor.set(e),this._resource&&(this._resource.shadowColor=e)}},{key:"normal",get:function(){return this._normal},set:function(e){Rn.copy(this._normal,e),this._resource&&(this._resource.normal=e)}},{key:"distance",get:function(){return this._distance},set:function(e){this._distance=e,this._resource&&(this._resource.distance=e)}},{key:"pcf",get:function(){return this._pcf},set:function(e){this._pcf=e,this._resource&&(this._resource.pcf=e)}},{key:"maxReceived",get:function(){return this._maxReceived},set:function(e){this._maxReceived=e,this._resource&&(this._resource.maxReceived=e)}},{key:"bias",get:function(){return this._bias},set:function(e){this._bias=e,this._resource&&(this._resource.bias=e)}},{key:"packing",get:function(){return this._packing},set:function(e){this._packing=e,e&&(this._linear=!this._linear&&this._linear,this._resource&&(this._resource.linear=this._linear)),this._resource&&(this._resource.packing=e,this._resource.shadowMapDirty=!0)}},{key:"linear",get:function(){return this._linear},set:function(e){this._linear=e,e&&(this._packing=!this._packing&&this._packing,this._resource&&(this._resource.packing=this._packing)),this._resource&&(this._resource.linear=e)}},{key:"selfShadow",get:function(){return this._selfShadow},set:function(e){this._selfShadow=e,this._resource&&(this._resource.selfShadow=e)}},{key:"normalBias",get:function(){return this._normalBias},set:function(e){this._normalBias=e,this._resource&&(this._resource.normalBias=e)}},{key:"autoAdapt",get:function(){return this._autoAdapt},set:function(e){this._autoAdapt=e,this._resource&&(this._resource.autoAdapt=e)}},{key:"near",get:function(){return this._near},set:function(e){this._near=e,this._resource&&(this._resource.near=e)}},{key:"far",get:function(){return this._far},set:function(e){this._far=e,this._resource&&(this._resource.far=e)}},{key:"orthoSize",get:function(){return this._orthoSize},set:function(e){this._orthoSize=e,this._resource&&(this._resource.orthoSize=e)}},{key:"shadowMapSize",get:function(){return this._size},set:function(e){this._size.set(e),this._resource&&(this._resource.size=e,this._resource.shadowMapDirty=!0)}},{key:"aspect",get:function(){return this._aspect},set:function(e){this._aspect=e,this._resource&&(this._resource.aspect=e)}}]),e}(),iR=he((nR=ER).prototype,"_type",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return dE.Planar}}),oR=he(nR.prototype,"_enabled",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),rR=he(nR.prototype,"_normal",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Rn(0,1,0)}}),aR=he(nR.prototype,"_distance",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),sR=he(nR.prototype,"_shadowColor",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Pn(0,0,0,76)}}),cR=he(nR.prototype,"_autoAdapt",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),lR=he(nR.prototype,"_pcf",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return pE.HARD}}),uR=he(nR.prototype,"_bias",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1e-5}}),hR=he(nR.prototype,"_packing",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),_R=he(nR.prototype,"_linear",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),fR=he(nR.prototype,"_selfShadow",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),dR=he(nR.prototype,"_normalBias",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),pR=he(nR.prototype,"_near",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),mR=he(nR.prototype,"_far",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 30}}),vR=he(nR.prototype,"_aspect",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),gR=he(nR.prototype,"_orthoSize",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 5}}),yR=he(nR.prototype,"_maxReceived",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 4}}),xR=he(nR.prototype,"_size",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Kn(512,512)}}),he(nR.prototype,"enabled",[K_],Object.getOwnPropertyDescriptor(nR.prototype,"enabled"),nR.prototype),he(nR.prototype,"type",[K_,Cb],Object.getOwnPropertyDescriptor(nR.prototype,"type"),nR.prototype),he(nR.prototype,"shadowColor",[K_],Object.getOwnPropertyDescriptor(nR.prototype,"shadowColor"),nR.prototype),he(nR.prototype,"normal",[Ib],Object.getOwnPropertyDescriptor(nR.prototype,"normal"),nR.prototype),he(nR.prototype,"distance",[Pb,bb],Object.getOwnPropertyDescriptor(nR.prototype,"distance"),nR.prototype),he(nR.prototype,"pcf",[Rb,Nb],Object.getOwnPropertyDescriptor(nR.prototype,"pcf"),nR.prototype),he(nR.prototype,"maxReceived",[Ob,Db],Object.getOwnPropertyDescriptor(nR.prototype,"maxReceived"),nR.prototype),he(nR.prototype,"bias",[Mb,Lb],Object.getOwnPropertyDescriptor(nR.prototype,"bias"),nR.prototype),he(nR.prototype,"packing",[Fb,zb],Object.getOwnPropertyDescriptor(nR.prototype,"packing"),nR.prototype),he(nR.prototype,"linear",[Bb,Ub],Object.getOwnPropertyDescriptor(nR.prototype,"linear"),nR.prototype),he(nR.prototype,"selfShadow",[Hb,Gb],Object.getOwnPropertyDescriptor(nR.prototype,"selfShadow"),nR.prototype),he(nR.prototype,"normalBias",[Vb,kb],Object.getOwnPropertyDescriptor(nR.prototype,"normalBias"),nR.prototype),he(nR.prototype,"autoAdapt",[Wb,jb],Object.getOwnPropertyDescriptor(nR.prototype,"autoAdapt"),nR.prototype),he(nR.prototype,"near",[qb,Yb],Object.getOwnPropertyDescriptor(nR.prototype,"near"),nR.prototype),he(nR.prototype,"far",[Xb,Kb],Object.getOwnPropertyDescriptor(nR.prototype,"far"),nR.prototype),he(nR.prototype,"orthoSize",[Qb,Zb],Object.getOwnPropertyDescriptor(nR.prototype,"orthoSize"),nR.prototype),he(nR.prototype,"shadowMapSize",[Jb],Object.getOwnPropertyDescriptor(nR.prototype,"shadowMapSize"),nR.prototype),he(nR.prototype,"aspect",[$b,eR],Object.getOwnPropertyDescriptor(nR.prototype,"aspect"),nR.prototype),tR=nR))||tR);c.ShadowsInfo=HR;var GR,VR,kR,WR,jR=(SR=L_("cc.SceneGlobals"),TR=hf(BR),SR((RR=function(){function e(){ue(this,"ambient",CR,this),ue(this,"shadows",IR,this),ue(this,"_skybox",PR,this),ue(this,"fog",bR,this)}return e.prototype.activate=function(){var e=c.director.root.pipeline.pipelineSceneData;this.ambient.activate(e.ambient),this.skybox.activate(e.skybox),this.shadows.activate(e.shadows),this.fog.activate(e.fog)},te(e,[{key:"skybox",get:function(){return this._skybox},set:function(e){this._skybox=e}}]),e}(),CR=he((wR=RR).prototype,"ambient",[H_,K_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new zR}}),IR=he(wR.prototype,"shadows",[H_,K_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new HR}}),PR=he(wR.prototype,"_skybox",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new BR}}),bR=he(wR.prototype,"fog",[K_,H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new UR}}),he(wR.prototype,"skybox",[K_,TR],Object.getOwnPropertyDescriptor(wR.prototype,"skybox"),wR.prototype),AR=wR))||AR);c.SceneGlobals=jR;var qR=e("dN",L_("cc.Scene")((he((VR=function(e){ie(n,e);var t=n.prototype;function n(t){var n;return ue(n=e.call(this,t)||this,"autoReleaseAssets",kR,se(n)),ue(n,"_globals",WR,se(n)),n._renderScene=null,n.dependAssets=null,n._inited=void 0,n._prefabSyncedInLiveReload=!1,n._pos=Rn.ZERO,n._rot=zn.IDENTITY,n._scale=Rn.ONE,n._mat=jn.IDENTITY,n._dirtyFlags=0,n._activeInHierarchy=!1,c.director&&c.director.root&&(n._renderScene=c.director.root.createScene({})),n._inited=!c.game||!c.game._isCloning,n}return t._updateScene=function(){this._scene=this},t.destroy=function(){var e=hi.prototype.destroy.call(this);if(e)for(var t=this._children,n=0;n<t.length;++n)t[n].active=!1;return c.director.root.destroyScene(this._renderScene),this._active=!1,this._activeInHierarchy=!1,e},t.addComponent=function(){throw new Error(L(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]._siblingIndex=i,this._children[i]._onBatchCreated(t);Mv(this)},t.getPosition=function(e){return Rn.copy(e||new Rn,Rn.ZERO)},t.getRotation=function(e){return zn.copy(e||new zn,zn.IDENTITY)},t.getScale=function(e){return Rn.copy(e||new Rn,Rn.ONE)},t.getWorldPosition=function(e){return Rn.copy(e||new Rn,Rn.ZERO)},t.getWorldRotation=function(e){return zn.copy(e||new zn,zn.IDENTITY)},t.getWorldScale=function(e){return Rn.copy(e||new Rn,Rn.ONE)},t.getWorldMatrix=function(e){return jn.copy(e||new jn,jn.IDENTITY)},t.getWorldRS=function(e){return jn.copy(e||new jn,jn.IDENTITY)},t.getWorldRT=function(e){return jn.copy(e||new jn,jn.IDENTITY)},t.updateWorldTransform=function(){},t._instantiate=function(){},t._load=function(){this._inited||(this._onBatchCreated(i),this._inited=!0),this.walk(Cv._setScene)},t._activate=function(e){e=!1!==e,c.director._nodeActivator.activateNode(this,e),this._globals.activate()},te(n,[{key:"renderScene",get:function(){return this._renderScene}},{key:"globals",get:function(){return this._globals}},{key:"position",get:function(){return Rn.ZERO}},{key:"worldPosition",get:function(){return Rn.ZERO}},{key:"rotation",get:function(){return zn.IDENTITY}},{key:"worldRotation",get:function(){return zn.IDENTITY}},{key:"scale",get:function(){return Rn.ONE}},{key:"worldScale",get:function(){return Rn.ONE}},{key:"eulerAngles",get:function(){return Rn.ZERO}},{key:"worldMatrix",get:function(){return jn.IDENTITY}}]),n}(Cv)).prototype,"globals",[K_],Object.getOwnPropertyDescriptor(VR.prototype,"globals"),VR.prototype),kR=he(VR.prototype,"autoReleaseAssets",[H_,K_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),WR=he(VR.prototype,"_globals",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new jR}}),GR=VR))||GR);function YR(e,t){if(!t){var n=c.director.getScene();if(!n)return null;t=n}return t.getChildByPath(e)}c.Scene=qR,c.find=YR;var XR=rt.fastRemoveAt,KR=hi.Flags.IsStartCalled,QR=hi.Flags.IsOnEnableCalled;function ZR(e,t){for(var n=t.constructor._executionOrder,i=t._id,o=0,r=e.length-1,a=r>>>1;o<=r;a=o+r>>>1){var s=e[a],c=s.constructor._executionOrder;if(c>n)r=a-1;else if(c<n)o=a+1;else{var l=s._id;if(l>i)r=a-1;else{if(!(l<i))return a;o=a+1}}}return~o}function JR(e,t){for(var n=e.array,i=e.i+1;i<n.length;){var o=n[i];o.node._activeInHierarchy?++i:(e.removeAt(i),t&&(o._objFlags&=~t))}}hi.Flags.IsEditorOnEnableCalled;var $R=function(e){this._zero=void 0,this._neg=void 0,this._pos=void 0,this._invoke=void 0;var t=_e;this._zero=new t([]),this._neg=new t([]),this._pos=new t([]),this._invoke=e};function eN(e,t){return e.constructor._executionOrder-t.constructor._executionOrder}$R.stableRemoveInactive=JR;var tN=function(e){function t(){return e.apply(this,arguments)||this}ie(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){JR(this._zero,e),JR(this._neg,e),JR(this._pos,e)},n.invoke=function(){var e=this._neg;e.array.length>0&&(e.array.sort(eN),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(eN),this._invoke(t),t.array.length=0)},t}($R),nN=function(e){function t(){return e.apply(this,arguments)||this}ie(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=ZR(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=ZR(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}($R);function iN(e,t,n){var i="var a=it.array;for(it.i=0;it.i<a.length;++it.i){var c=a[it.i];"+e+"}",o=t?Function("it","dt",i):Function("it",i);return function(e,t,n){return function(i,o){try{t(i,o)}catch(t){c._throw(t);var r=i.array;for(n&&(r[i.i]._objFlags|=n),++i.i;i.i<r.length;++i.i)try{e(r[i.i],o)}catch(e){c._throw(e),n&&(r[i.i]._objFlags|=n)}}}}(Function("c","dt",e),o,n)}var oN=iN("c.start();c._objFlags|="+KR,!1,KR),rN=iN("c.update(dt)",!0),aN=iN("c.lateUpdate(dt)",!0),sN=function(e){var t=c.director._compScheduler,n=e.array;for(e.i=0;e.i<n.length;++e.i){var i=n[e.i];i._enabled&&(i.onEnable(),!i.node._activeInHierarchy||t._onEnabled(i))}},cN=function(){function e(){this._deferredComps=[],this.unscheduleAll()}var t=e.prototype;return t.unscheduleAll=function(){this.startInvoker=new tN(oN),this.updateInvoker=new nN(rN),this.lateUpdateInvoker=new nN(aN),this._updating=!1},t._onEnabled=function(e){c.director.getScheduler().resumeTarget(e),e._objFlags|=QR,this._updating?this._deferredComps.push(e):this._scheduleImmediate(e)},t._onDisabled=function(e){c.director.getScheduler().pauseTarget(e),e._objFlags&=~QR;var t=this._deferredComps.indexOf(e);t>=0?XR(this._deferredComps,t):(!e.start||e._objFlags&KR||this.startInvoker.remove(e),e.update&&this.updateInvoker.remove(e),e.lateUpdate&&this.lateUpdateInvoker.remove(e))},t.enableComp=function(e,t){if(!(e._objFlags&QR)){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&QR&&(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&KR||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}(),lN=hi.Flags.IsPreloadStarted,uN=hi.Flags.IsOnLoadStarted,hN=hi.Flags.IsOnLoadCalled,_N=hi.Flags.Deactivating,fN=function(e){function t(){return e.apply(this,arguments)||this}ie(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){$R.stableRemoveInactive(this._zero,e)},n.invoke=function(){this._invoke(this._zero),this._zero.array.length=0},t}($R),dN=iN("c.__preload();"),pN=iN("c.onLoad();c._objFlags|="+hN,!1,hN),mN=new ot(4);function vN(e,t,n){t?e._removeComponent(t):rt.removeAt(e._components,n)}mN.get=function(){var e=this._get()||{preload:new fN(dN),onLoad:new tN(pN),onEnable:new tN(sN)};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 gN,yN,xN,EN,SN,TN,AN,wN,CN=e("fQ",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=mN.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(),mN.put(n)}else{this._deactivateNodeRecursively(e);for(var i,o=le(this._activatingStack);!(i=o()).done;){var r=i.value;r.preload.cancelInactive(lN),r.onLoad.cancelInactive(uN),r.onEnable.cancelInactive()}}e.emit("active-in-hierarchy-changed",e)},t.activateComp=function(e,t,n,i){if(fi(e,!0)&&(e._objFlags&lN||(e._objFlags|=lN,e.__preload&&(t?t.add(e):e.__preload())),e._objFlags&uN||(e._objFlags|=uN,e.onLoad?n?n.add(e):(e.onLoad(),e._objFlags|=hN):e._objFlags|=hN),e._enabled)){if(!e.node._activeInHierarchy)return;c.director._compScheduler.enableComp(e,i)}},t.destroyComp=function(e){c.director._compScheduler.disableComp(e),e.onDestroy&&e._objFlags&hN&&e.onDestroy()},t._activateNodeRecursively=function(e,t,n,i){if(e._objFlags&_N)N(3816,e.name);else{e._activeInHierarchy=!0;for(var o=e._components.length,r=0;r<o;++r){var a=e._components[r];a instanceof c.Component?this.activateComp(a,t,n,i):(vN(e,a,r),--r,--o)}e._childArrivalOrder=e._children.length;for(var s=0,l=e._children.length;s<l;++s){var u=e._children[s];u._active&&this._activateNodeRecursively(u,t,n,i)}e._onPostActivated(!0)}},t._deactivateNodeRecursively=function(e){e._objFlags|=_N,e._activeInHierarchy=!1;for(var t=e._components.length,n=0;n<t;++n){var i=e._components[n];if(i._enabled&&(c.director._compScheduler.disableComp(i),e._activeInHierarchy))return void(e._objFlags&=~_N)}for(var o=0,r=e._children.length;o<r;++o){var a=e._children[o];if(a._activeInHierarchy&&(this._deactivateNodeRecursively(a),e._activeInHierarchy))return void(e._objFlags&=~_N)}e._onPostActivated(!1),e._objFlags&=~_N},e}()),IN=e("f7",L_("cc.SceneAsset")((EN=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return ue(t=e.call.apply(e,[this].concat(i))||this,"scene",xN,se(t)),t}ie(t,e);var n=t.prototype;return n.initDefault=function(t){e.prototype.initDefault.call(this,t),this.scene=new qR("New Scene")},n.validate=function(){return!!this.scene},t}(kf),xN=he((yN=EN).prototype,"scene",[K_,H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),gN=yN))||gN);c.SceneAsset=IN;var PN,bN,RN,NN,ON=e("eu",L_("cc.TextAsset")((wN=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return ue(t=e.call.apply(e,[this].concat(i))||this,"text",AN,se(t)),t}return ie(t,e),t.prototype.toString=function(){return this.text},t}(kf),AN=he((TN=wN).prototype,"text",[H_,K_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),SN=TN))||SN);c.TextAsset=ON;var DN=e("f8",L_("cc.JsonAsset")((NN=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return ue(t=e.call.apply(e,[this].concat(i))||this,"json",RN,se(t)),t}return ie(t,e),t}(kf),RN=he((bN=NN).prototype,"json",[H_,K_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),PN=bN))||PN);c.JsonAsset=DN;var MN=e("cY",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 SI,t._compScheduler=new cN,t._nodeActivator=new CN,t._systems=[],c.game.once(eC.EVENT_RENDERER_INITED,t._initOnRendererInitialized,se(t)),t}ie(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=c.game.container,n=c.view,i=t.getBoundingClientRect(),o=i.left+window.pageXOffset-t.clientLeft,r=i.top+window.pageYOffset-t.clientTop,a=n._devicePixelRatio*(e.x-o),s=n._devicePixelRatio*(r+i.height-e.y);return n._isRotated?Jn(n._viewportRect.width-s,a):Jn(a,s)},n.convertToUI=function(e){var t=c.game.container,n=c.view,i=t.getBoundingClientRect(),o=i.left+window.pageXOffset-t.clientLeft,r=i.top+window.pageYOffset-t.clientTop,a=Jn(0,0);return n._isRotated?(a.x=o+e.y/n._devicePixelRatio,a.y=r+i.height-(n._viewportRect.width-e.x)/n._devicePixelRatio):(a.x=o+e.x*n._devicePixelRatio,a.y=r+i.height-e.y*n._devicePixelRatio),a},n.end=function(){this._purgeDirectorInNextLoop=!0},n.getWinSize=function(){return ii(c.winSize)},n.getWinSizeInPixels=function(){return ii(c.winSize)},n.pause=function(){this._paused||(this._paused=!0)},n.purgeCachedData=function(){c.assetManager.releaseAll()},n.purgeDirector=function(){this._scheduler.unscheduleAll(),this._compScheduler.unscheduleAll(),this._nodeActivator.reset(),ev&&ev.setEnabled(!1),c.isValid(this._scene)&&this._scene.destroy(),this._scene=null,this.stopAnimation(),c.assetManager.releaseAll()},n.reset=function(){this.purgeDirector(),this.emit(t.EVENT_RESET),ev&&ev.setEnabled(!0),this.startAnimation()},n.runSceneImmediate=function(e,t,n){e instanceof IN&&(e=e.scene),M(e instanceof qR,1216),e._load();for(var i=Object.keys(c.game._persistRootNodes).map((function(e){return c.game._persistRootNodes[e]})),o=0;o<i.length;o++){var r=i[o];r.emit(c.Node.SCENE_CHANGED_FOR_PERSISTS,e.renderScene);var a=e.uuid===r._originalSceneId&&e.getChildByUuid(r.uuid);if(a){var s=a.getSiblingIndex();a._destroyImmediate(),e.insertChild(r,s)}else r.parent=e}var l=this._scene;c.isValid(l)&&l.destroy(),c.assetManager._releaseManager._autoRelease(l,e,c.game._persistRootNodes),this._scene=null,hi._deferredDestroy(),t&&t(),this.emit(c.Director.EVENT_BEFORE_SCENE_LAUNCH,e),this._scene=e,e._activate(),this._root&&this._root.resetCumulativeTime(),this.startAnimation(),n&&n(null,e),this.emit(c.Director.EVENT_AFTER_SCENE_LAUNCH,e)},n.runScene=function(e,t,n){var i=this;e instanceof IN&&(e=e.scene),M(e,1205),M(e instanceof qR,1216),e._load(),this.once(c.Director.EVENT_AFTER_DRAW,(function(){i.runSceneImmediate(e,t,n)}))},n.loadScene=function(e,t,n){var i=this;if(this._loadingScene)return b(1208,e,this._loadingScene),!1;var o=c.assetManager.bundles.find((function(t){return!!t.getSceneInfo(e)}));return o?(this.emit(c.Director.EVENT_BEFORE_SCENE_LOADING,e),this._loadingScene=e,console.time("LoadScene "+e),o.loadScene(e,(function(o,r){console.timeEnd("LoadScene "+e),i._loadingScene="",o?(x(o),t&&t(o)):i.runSceneImmediate(r,n,t)})),!0):(N(1209,e),!1)},n.preloadScene=function(e,t,n){var i=c.assetManager.bundles.find((function(t){return!!t.getSceneInfo(e)}));if(i)i.preloadScene(e,null,t,n);else{var o='Can not preload the scene "'+e+'" because it is not in the build settings.';n&&n(new Error(o)),x("preloadScene: "+o)}},n.resume=function(){this._paused&&(this._lastUpdate=performance.now(),this._lastUpdate||I(1200),this._paused=!1,this._deltaTime=0)},n.setDepthTest=function(e){c.Camera.main&&(c.Camera.main.depth=!!e)},n.setClearColor=function(e){c.Camera.main&&(c.Camera.main.backgroundColor=e)},n.getRunningScene=function(){return this._scene},n.getScene=function(){return this._scene},n.getAnimationInterval=function(){return 1e3/c.game.getFrameRate()},n.setAnimationInterval=function(e){c.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(SI.ID,e,200))},n.registerSystem=function(e,t,n){t.id=e,t.priority=n,t.init(),this._systems.push(t),this._systems.sort(mI.sortByPriority)},n.unregisterSystem=function(e){rt.fastRemove(this._systems,e),this._systems.sort(mI.sortByPriority)},n.getSystem=function(e){return this._systems.find((function(t){return t.id===e}))},n.getAnimationManager=function(){return this.getSystem(c.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),this.emit(t.EVENT_BEGIN_FRAME);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),hi._deferredDestroy();for(var o=0;o<this._systems.length;++o)this._systems[o].postUpdate(n)}this.emit(t.EVENT_BEFORE_DRAW),this._root.frameMove(this._deltaTime),this.emit(t.EVENT_AFTER_DRAW),ev.frameUpdateListeners(),ry.clearBooks(),this.emit(t.EVENT_END_FRAME),this._totalFrames++}},n._initOnRendererInitialized=function(){this._totalFrames=0,this._lastUpdate=performance.now(),this._startTime=this._lastUpdate,this._paused=!1,this._purgeDirectorInNextLoop=!1,ev&&ev.setEnabled(!0),this.registerSystem(SI.ID,this._scheduler,200),this.emit(t.EVENT_INIT)},n._init=function(){return this._root=new AI(c.game._gfxDevice),this._root.initialize({}).catch((function(e){return N(1217),Promise.reject(e)}))},te(t,[{key:"root",get:function(){return this._root}}]),t}(bi));MN.EVENT_INIT="director_init",MN.EVENT_RESET="director_reset",MN.EVENT_BEFORE_SCENE_LOADING="director_before_scene_loading",MN.EVENT_BEFORE_SCENE_LAUNCH="director_before_scene_launch",MN.EVENT_AFTER_SCENE_LAUNCH="director_after_scene_launch",MN.EVENT_BEFORE_UPDATE="director_before_update",MN.EVENT_AFTER_UPDATE="director_after_update",MN.EVENT_BEFORE_DRAW="director_before_draw",MN.EVENT_AFTER_DRAW="director_after_draw",MN.EVENT_BEFORE_COMMIT="director_before_commit",MN.EVENT_BEFORE_PHYSICS="director_before_physics",MN.EVENT_AFTER_PHYSICS="director_after_physics",MN.EVENT_BEGIN_FRAME="director_begin_frame",MN.EVENT_END_FRAME="director_end_frame",MN.instance=void 0,c.Director=MN;var LN=e("cX",MN.instance=c.director=new MN),FN=function(){function e(){this.name="",this.base="",this.importBase="",this.nativeBase="",this.deps=null,this.assetInfos=new ff,this.scenes=new ff,this.paths=new ff}var t=e.prototype;return t.init=function(e){!function(e){var t=e.uuids,n=e.paths,i=e.types,o=e.deps,r=e.paths=Object.create(null);if(!1===e.debug){for(var a=0,s=t.length;a<s;a++)t[a]=Rf(t[a]);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]=Rf(d)}t=h}for(var p in n){var m=n[p];r[t[p]]=m}var v=e.scenes;for(var g in v){var y=v[g];v[g]=t[y]}var x=e.packs;for(var E in x)for(var S=x[E],T=0;T<S.length;++T)S[T]=t[S[T]];var A=e.versions;if(A)for(var w in A)for(var C=A[w],I=0;I<C.length;I+=2){var P=C[I];C[I]=t[P]||P}var b=e.redirect;if(b)for(var R=0;R<b.length;R+=2)b[R]=t[b[R]],b[R+1]=o[b[R+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=Lf(e);var n=this.paths.get(e);if(n){if(!t)return n[0];for(var i=0,o=n.length;i<o;i++){var r=n[i];if(at.isChildClassOf(r.ctor,t))return r}}return null},t.getDirWithPath=function(e,t,n){"/"===(e=Lf(e))[e.length-1]&&(e=e.slice(0,-1));var i=n||[];return this.paths.forEach((function(n,o){if(o.startsWith(e)&&function(e,t){return!(e.length>t.length)||47===e.charCodeAt(t.length)}(o,e)||!e)for(var r=0,a=n.length;r<a;r++){var s=n[r];t&&!at.isChildClassOf(s.ctor,t)||i.push(s)}})),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],o=i[0],r=i[1],a=3===i.length,s=this.assetInfos.get(n);s.path=o,s.ctor=at._getClassById(r),t.has(o)?a?t.get(o).push(s):t.get(o).splice(0,0,s):t.add(o,[s])}}},t._initScene=function(e){if(e){var t=this.scenes;t.clear();var n=this.assetInfos;for(var i in e){var o=e[i],r=n.get(o);r.url=i,t.add(i,r)}}},t._initPackage=function(e){if(e){var t=this.assetInfos;for(var n in e){var i=e[n],o={uuid:n,packedUuids:i,ext:".json"};t.add(n,o);for(var r=0,a=i.length;r<a;r++){var s=i[r],c=t.get(s),l=c.packs;l?1===a?l.splice(0,0,o):l.push(o):c.packs=[o]}}}},t._initVersion=function(e){if(e){var t=this.assetInfos,n=e.import;if(n)for(var i=0,o=n.length;i<o;i+=2){var r=n[i];t.get(r).ver=n[i+1]}if(n=e.native)for(var a=0,s=n.length;a<s;a+=2){var c=n[a];t.get(c).nativeVer=n[a+1]}}},t._initRedirect=function(e){if(e)for(var t=this.assetInfos,n=0,i=e.length;n<i;n+=2){var o=e[n];t.get(o).redirect=e[n+1]}},e}();function zN(e,t){e._uuid&&t.push(e._uuid)}function BN(e,t){for(var n=Object.getOwnPropertyNames(e),i=0;i<n.length;i++){var o=n[i];if("node"!==o&&"__eventTargets"!==o){var r=e[o];if("object"==typeof r&&r)if(Array.isArray(r))for(var a=0;a<r.length;a++){var s=r[a];s instanceof kf&&zN(s,t)}else if(r.constructor&&r.constructor!==Object)r instanceof kf&&zN(r,t);else for(var c=Object.getOwnPropertyNames(r),l=0;l<c.length;l++){var u=r[c[l]];u instanceof kf&&zN(u,t)}}}}function UN(e,t){for(var n=0;n<e._components.length;n++)BN(e._components[n],t);for(var i=0;i<e._children.length;i++)UN(e._children[i],t)}function HN(e,t,n,i){n.push(e._uuid);for(var o=dp.getDeps(e._uuid),r=0,a=o.length;r<a;r++){var s=mf.get(o[r]);if(s){var c=s._uuid;c in t?t[c]+=i:t[c]=s.refCount+i,n.includes(c)||HN(s,t,n,i)}}}var GN=[],VN=new(function(){function e(){this._persistNodeDeps=new ff,this._toDelete=new ff,this._eventListener=!1}var t=e.prototype;return t.init=function(){this._persistNodeDeps.clear(),this._toDelete.clear()},t._addPersistNodeRef=function(e){var t=[];UN(e,t);for(var n=0,i=t.length;n<i;n++){var o=mf.get(t[n]);o&&o.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 o=mf.get(t[n]);o&&o.decRef()}this._persistNodeDeps.remove(e.uuid)}},t._autoRelease=function(e,t,n){if(e){for(var i=dp.getDeps(e.uuid),o=0,r=i.length;o<r;o++){var a=mf.get(i[o]);a&&a.decRef(e.autoReleaseAssets)}var s=dp._depends.get(e.uuid);if(s&&s.persistDeps)for(var c=s.persistDeps,l=0,u=c.length;l<u;l++){var h=mf.get(c[l]);h&&h.decRef(e.autoReleaseAssets)}e.uuid!==t.uuid&&dp.remove(e.uuid)}var _=dp._depends.get(t.uuid);for(var f in _&&(_.persistDeps=[]),n){for(var d,p,m=n[f],v=this._persistNodeDeps.get(m.uuid),g=le(v);!(p=g()).done;){var y=p.value,x=mf.get(y);x&&x.addRef()}_&&(d=_.persistDeps).push.apply(d,v)}},t.tryRelease=function(e,t){void 0===t&&(t=!1),e instanceof kf&&(t?this._free(e,t):(this._toDelete.add(e._uuid,e),this._eventListener||(this._eventListener=!0,Tt(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),fi(e,!0)&&!(!t&&e.refCount>0&&function(e){var t=Object.create(null);if(t[e._uuid]=e.refCount,HN(e,t,GN,-1),GN.length=0,0!==t[e._uuid])return t[e._uuid];for(var n in t)0!==t[n]&&HN(mf.get(n),t,GN,1);return GN.length=0,t[e._uuid]}(e)>0)){mf.remove(n);for(var i=dp.getDeps(n),o=0,r=i.length;o<r;o++){var a=mf.get(i[o]);a&&(a.decRef(!1),this._free(a,!1))}e.destroy(),dp.remove(n)}},e}()),kN=null;function WN(e,t){for(var n=0,i=e.input.length;n<i;n++){var o=e.input[n];t&&!o.isNative&&o.content instanceof kf&&o.content.decRef(!1),o.recycle()}e.input=null}function jN(e,t){return t?/\?/.test(e)?e+"&_t="+Date.now():e+"?_t="+Date.now():e}function qN(e,t,n,i,o){void 0===o&&(o=0),e(o,(function(r,a){o++,!r||o>t?i&&i(r,a):setTimeout((function(){qN(e,t,n,i,o)}),n)}))}function YN(e,t,n,i,o){try{for(var r=dp.parse(e,t),a=0,s=r.deps.length;a<s;a++){var c=r.deps[a];c in n||(n[c]=!0,i.push({uuid:c,bundle:o&&o.name}))}r.nativeDep&&(o&&(r.nativeDep.bundle=o.name),i.push(ne({},r.nativeDep)))}catch(e){x(e.message,e.stack)}}function XN(e,t,n){t&&(n=void 0!==n?n:c.assetManager.cacheAsset,Mf(t)||!n||t.isDefault||mf.add(e,t))}function KN(e,t,n){var i=0,o=[],r=e.length;0===r&&n&&n(o);for(var a=function(e){e&&o.push(e),++i===r&&n&&n(o)},s=0;s<r;s++)t(e[s],a)}function QN(e,t,n){var i=e,o=t,r=n;if(void 0===n){var a="function"==typeof e;t?(r=t,a||(o=null)):void 0===t&&a&&(r=e,i=null,o=null),void 0!==t&&a&&(o=e,i=null)}return{options:i||Object.create(null),onProgress:o,onComplete:r}}function ZN(e,t,n){var i=e,o=t,r=n;if(void 0===n){var a=at.isChildClassOf(e,kf);t?(r=t,a&&(o=null)):void 0!==t||a||(r=e,o=null,i=null),void 0===t||a||(o=e,i=null)}return{type:i,onProgress:o||kN,onComplete:r}}function JN(e,t,n,i){if(void 0===i&&(i={}),!n[t]||i[t])return!1;i[t]=!0;var o=!1,r=dp.getDeps(t);if(r)for(var a=0,s=r.length;a<s;a++){var c=r[a];if(c===e||JN(e,c,n,i)){o=!0;break}}return o}function $N(e){return function(t,n){if(e){var i=[];Array.isArray(n)?n.forEach((function(e){return e instanceof kf&&i.push(e.addRef())})):n instanceof kf&&i.push(n.addRef()),Tt((function(){i.forEach((function(e){return e.decRef(!1)})),e(t,n)}))}}}var eO=function(){function e(){this._config=new FN}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),yf.add(e.name,this)},t.load=function(e,t,n,i){var o=ZN(t,n,i),r=o.type,a=o.onProgress,s=o.onComplete,l={__requestType__:pf.PATH,type:r,bundle:this.name,__outputAsArray__:Array.isArray(e)};c.assetManager.loadAny(e,l,a,s)},t.preload=function(e,t,n,i){var o=ZN(t,n,i),r=o.type,a=o.onProgress,s=o.onComplete;c.assetManager.preloadAny(e,{__requestType__:pf.PATH,type:r,bundle:this.name},a,s)},t.loadDir=function(e,t,n,i){var o=ZN(t,n,i),r=o.type,a=o.onProgress,s=o.onComplete;c.assetManager.loadAny(e,{__requestType__:pf.DIR,type:r,bundle:this.name,__outputAsArray__:!0},a,s)},t.preloadDir=function(e,t,n,i){var o=ZN(t,n,i),r=o.type,a=o.onProgress,s=o.onComplete;c.assetManager.preloadAny(e,{__requestType__:pf.DIR,type:r,bundle:this.name},a,s)},t.loadScene=function(e,t,n,i){var o=QN(t,n,i),r=o.options,a=o.onProgress,s=o.onComplete;r.preset=r.preset||"scene",r.bundle=this.name,c.assetManager.loadAny({scene:e},r,a,(function(e,t){if(e)x(e.message,e.stack);else if(t instanceof IN&&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");s&&s(e,t)}))},t.preloadScene=function(e,t,n,i){var o=QN(t,n,i),r=o.options,a=o.onProgress,s=o.onComplete;r.bundle=this.name,c.assetManager.preloadAny({scene:e},r,a,(function(t){t&&N(1210,e,t.message),s&&s(t)}))},t.get=function(e,t){var n=this.getInfoWithPath(e,t);return n&&mf.get(n.uuid)||null},t.release=function(e,t){var n=this.get(e,t);n&&VN.tryRelease(n,!0)},t.releaseUnusedAssets=function(){var e=this;mf.forEach((function(t){var n=e.getAssetInfo(t._uuid);n&&!n.redirect&&VN.tryRelease(t)}))},t.releaseAll=function(){var e=this;mf.forEach((function(t){var n=e.getAssetInfo(t._uuid);n&&!n.redirect&&VN.tryRelease(t,!0)}))},t._destroy=function(){this._config.destroy()},te(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}(),tO=e("fK",new eO);function nO(e,t,n){var i=new Image;function o(){i.removeEventListener("load",o),i.removeEventListener("error",r),n&&n(null,i)}function r(){i.removeEventListener("load",o),i.removeEventListener("error",r),n&&n(new Error(L(4930,e)))}return"file:"!==window.location.protocol&&(i.crossOrigin="anonymous"),i.addEventListener("load",o),i.addEventListener("error",r),i.src=e,i}function iO(e,t,n,i){var o=new XMLHttpRequest,r="download failed: "+e+", status: ";if(o.open("GET",e,!0),void 0!==t.xhrResponseType&&(o.responseType=t.xhrResponseType),void 0!==t.xhrWithCredentials&&(o.withCredentials=t.xhrWithCredentials),void 0!==t.xhrMimeType&&o.overrideMimeType&&o.overrideMimeType(t.xhrMimeType),void 0!==t.xhrTimeout&&(o.timeout=t.xhrTimeout),t.xhrHeader)for(var a in t.xhrHeader)o.setRequestHeader(a,t.xhrHeader[a]);return o.onload=function(){200===o.status||0===o.status?i&&i(null,o.response):i&&i(new Error(""+r+o.status+"(no response)"))},n&&(o.onprogress=function(e){e.lengthComputable&&n(e.loaded,e.total)}),o.onerror=function(){i&&i(new Error(""+r+o.status+"(error)"))},o.ontimeout=function(){i&&i(new Error(""+r+o.status+"(time out)"))},o.onabort=function(){i&&i(new Error(""+r+o.status+"(abort)"))},o.send(null),o}c.resources=tO;var oO={};function rO(e,t,n){if(oO[e])return n&&n(null),null;var i=document.createElement("script");function o(){i.parentNode.removeChild(i),i.removeEventListener("load",o,!1),i.removeEventListener("error",r,!1),oO[e]=!0,n&&n(null)}function r(){i.parentNode.removeChild(i),i.removeEventListener("load",o,!1),i.removeEventListener("error",r,!1),n&&n(new Error(L(4928,e)))}return"file:"!==window.location.protocol&&(i.crossOrigin="anonymous"),i.async=t.scriptAsyncLoading||!1,i.src=e,i.addEventListener("load",o,!1),i.addEventListener("error",r,!1),document.body.appendChild(i),i}var aO=/^(?:\w+:\/\/|\.+\/).+/,sO=function(e,t,n){(mx.capabilities.imageBitmap&&c.assetManager.allowImageBitmap?cO:nO)(e,t,n)},cO=function(e,t,n){t.xhrResponseType="blob",iO(e,t,t.onFileProgress,n)},lO=function(e,t,n){t.xhrResponseType="json",iO(e,t,t.onFileProgress,n)},uO=function(e,t,n){t.xhrResponseType="arraybuffer",iO(e,t,t.onFileProgress,n)},hO=function(e,t,n){t.xhrResponseType="text",iO(e,t,t.onFileProgress,n)},_O=function(e,t,n){var i=Bi(e),o=e;aO.test(o)||(o=-1!==dO.remoteBundles.indexOf(i)?dO.remoteServerAddress+"remote/"+i:"assets/"+i);var r=t.version||dO.bundleVers[i],a=0,s=null,c=null;lO(o+"/config."+(r?r+".":"")+"json",t,(function(e,t){c=e,(s=t)&&(s.base=o+"/"),2==++a&&n(c,s)})),rO(o+"/index."+(r?r+".":"")+"js",t,(function(e){c=e,2==++a&&n(e,s)}))},fO=function(){function e(){this.maxConcurrency=6,this.maxRequestsPerFrame=6,this.maxRetryCount=3,this.appendTimeStamp=!!i,this.limited=!i,this.retryInterval=2e3,this.bundleVers=null,this.remoteBundles=[],this.downloadDomImage=nO,this.downloadDomAudio=null,this.downloadFile=iO,this.downloadScript=rO,this._downloaders={".png":sO,".jpg":sO,".bmp":sO,".jpeg":sO,".gif":sO,".ico":sO,".tiff":sO,".webp":sO,".image":sO,".pvr":uO,".pkm":uO,".astc":uO,".txt":hO,".xml":hO,".vsh":hO,".fsh":hO,".atlas":hO,".tmx":hO,".tsx":hO,".json":lO,".ExportJson":lO,".plist":hO,".fnt":hO,".binary":uO,".bin":uO,".dbbin":uO,".skel":uO,".js":rO,bundle:_O,default:hO},this._downloading=new ff,this._queue=[],this._queueDirty=!1,this._totalNum=0,this._totalNumThisPeriod=0,this._lastDate=-1,this._checkNextPeriod=!1,this._remoteServerAddress="",this._maxInterval=1/30}var t=e.prototype;return t.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},t.register=function(e,t){"object"==typeof e?Ge(this._downloaders,e):this._downloaders[e]=t},t.download=function(e,t,n,i,o){var r=this,a=vf.get(e);if(a)o(null,a);else{var s=this._downloading.get(e);if(s){s.push(o);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;qN((function(n,a){if(0===n&&r._downloading.add(e,[o]),r.limited){r._updateTime();var s=function(e,t){r._totalNum--,r._handleQueueInNextFrame(h,_),a(e,t)};r._totalNum<h&&r._totalNumThisPeriod<_?(f(jN(t,r.appendTimeStamp),i,s),r._totalNum++,r._totalNumThisPeriod++):(r._queue.push({id:e,priority:i.priority||0,url:t,options:i,done:s,handler:f}),r._queueDirty=!0,r._totalNum<h&&r._handleQueueInNextFrame(h,_))}else f(jN(t,r.appendTimeStamp),i,a)}),u,this.retryInterval,(function(t,n){t||vf.add(e,n);for(var i=r._downloading.remove(e),o=0,a=i.length;o<a;o++)i[o](t,n)}))}}},t.loadSubpackage=function(e,t){c.assetManager.loadBundle(e,null,t)},t._updateTime=function(){var e=Date.now(),t=c.director.getDeltaTime(),n=t>this._maxInterval?this._maxInterval:t;e-this._lastDate>1e3*n&&(this._totalNumThisPeriod=0,this._lastDate=e)},t._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(jN(n.url,this.appendTimeStamp),n.options,n.done)}this._handleQueueInNextFrame(e,t)},t._handleQueueInNextFrame=function(e,t){!this._checkNextPeriod&&this._queue.length>0&&(Tt(this._handleQueue.bind(this),e,t),this._checkNextPeriod=!0)},te(e,[{key:"remoteServerAddress",get:function(){return this._remoteServerAddress}}]),e}(),dO=e("dz",new fO);function pO(e,t,n,i){var o=null,r=null;try{(o=new ed)._nativeUrl=e,o._nativeAsset=t}catch(e){r=e}i(r,o)}function mO(e,t,n,i){var o=new DN;o.json=t,i(null,o)}function vO(e,t,n,i){var o=new ON;o.text=t,i(null,o)}function gO(e,t,n,i){var o=new $I;o._nativeUrl=e,o._nativeAsset=t,i(null,o)}function yO(e,t,n,i){var o=new kf;o._nativeUrl=e,o._nativeAsset=t,i(null,o)}function xO(e,n,i,o){var r=yf.get(n.name);r||(r=n.name===Tf.RESOURCES?tO:new eO,n.base=n.base||e+"/",r.init(n)),t.import("virtual:///prerequisite-imports/"+r.name).then((function(){o(null,r)})).catch(o)}var EO=function(){function e(){this._creating=new ff,this._producers={".png":pO,".jpg":pO,".bmp":pO,".jpeg":pO,".gif":pO,".ico":pO,".tiff":pO,".webp":pO,".image":pO,".pvr":pO,".pkm":pO,".txt":vO,".xml":vO,".vsh":vO,".fsh":vO,".atlas":vO,".tmx":vO,".tsx":vO,".fnt":vO,".json":mO,".ExportJson":mO,".binary":gO,".bin":gO,".dbbin":gO,".skel":gO,bundle:xO,default:yO}}var t=e.prototype;return t.register=function(e,t){"object"==typeof e?at.mixin(this._producers,e):this._producers[e]=t},t.create=function(e,t,n,i,o){var r=this,a=this._producers[n]||this._producers.default,s=mf.get(e);if(i.reloadAsset||!s){var c=this._creating.get(e);c?c.push(o):(this._creating.add(e,[o]),a(e,t,i,(function(t,n){!t&&n instanceof kf&&(n._uuid=e,XN(e,n,i.cacheAsset));for(var o=r._creating.remove(e),a=0,s=o.length;a<s;a++)o[a](t,n)})))}else o(null,s)},e}(),SO=e("dA",new EO),TO=new(function(){function e(){this._loading=new ff,this._unpackers={".json":this.unpackJson}}var t=e.prototype;return t.unpackJson=function(e,t,n,i){var o=at.createMap(!0),r=null;if(Array.isArray(t)){(t=function(e){if(e[0]<1)throw new Error(L(5304,e[0]));Ld(e,!0,void 0),Fd(e);for(var t=new Gd(e[0]),n=e[1],i=e[2],o=e[3],r=e[4],a=e[5],s=0;s<a.length;++s)a[s].unshift(t,n,i,o,r);return a}(t)).length!==e.length&&N(4915);for(var a=0;a<e.length;a++)o[e[a]+"@import"]=t[a]}else{var s=at._getClassId(Rp),c=at._getClassId(ed);if(t.type===s&&t.data){var l=t.data;l.length!==e.length&&N(4915);for(var u=0;u<e.length;u++)o[e[u]+"@import"]=Vd(s,{base:l[u][0],mipmaps:l[u][1]})}else if(t.type===c&&t.data){var h=t.data;h.length!==e.length&&N(4915);for(var _=0;_<e.length;_++)o[e[_]+"@import"]=h[_]}else r=new Error("unmatched type pack!"),o=null}i(r,o)},t.init=function(){this._loading.clear()},t.register=function(e,t){"object"==typeof e?at.mixin(this._unpackers,e):this._unpackers[e]=t},t.unpack=function(e,t,n,i,o){t?(0,this._unpackers[n])(e,t,i,o):o(new Error("package data is wrong!"))},t.load=function(e,t,n){var i=this;if(!e.isNative&&e.info&&e.info.packs)if(vf.has(e.id))n(null,vf.get(e.id));else{var o=e.info.packs,r=o.find((function(e){return i._loading.has(e.uuid)}));if(r)this._loading.get(r.uuid).push({onComplete:n,id:e.id});else{r=o[0],this._loading.add(r.uuid,[{onComplete:n,id:e.id}]);var a=Ff(r.uuid,{ext:r.ext,bundle:e.config.name});dO.download(r.uuid,a,r.ext,e.options,(function(t,n){vf.remove(r.uuid),t&&x(t.message,t.stack),i.unpack(r.packedUuids,n,r.ext,e.options,(function(e,n){if(!e)for(var o in n)vf.add(o,n[o]);for(var a=i._loading.remove(r.uuid),s=0,c=a.length;s<c;s++){var l=a[s];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 dO.download(e.id,e.url,e.ext,e.options,n)},e}());function AO(e,t){var n=!1;e.progress||(e.progress={finish:0,total:e.input.length,canInvoke:!0},n=!0);var i=e.options,o=e.progress,r=[],a=o.total,s=i.__exclude__=i.__exclude__||Object.create(null);e.output=[],KN(e.input,(function(i,l){if(!i.isNative&&mf.has(i.uuid)){var u=mf.get(i.uuid);return i.content=u.addRef(),e.output.push(i),o.canInvoke&&e.dispatch("progress",++o.finish,o.total,i),void l()}TO.load(i,e.options,(function(u,h){u?e.isFinish||(!c.assetManager.force||n?(x(u.message,u.stack),o.canInvoke=!1,t(u)):(e.output.push(i),o.canInvoke&&e.dispatch("progress",++o.finish,o.total,i))):e.isFinish||(i.file=h,e.output.push(i),i.isNative||(s[i.uuid]=!0,YN(i.uuid,h,s,r,i.config),o.total=a+r.length),o.canInvoke&&e.dispatch("progress",++o.finish,o.total,i)),l()}))}),(function(){if(e.isFinish)return WN(e,!0),void e.dispatch("error");if(r.length>0){var a=wf.create({input:r,progress:o,options:i,onProgress:e.onProgress,onError:wf.prototype.recycle,onComplete:function(i){var o;i||((o=e.output).push.apply(o,a.output),a.recycle()),n&&wO(e),t(i)}});Ef.async(a)}else n&&wO(e),t()}))}function wO(e){for(var t=e.output,n=0,i=t.length;n<i;n++)t[n].content&&t[n].content.decRef(!1)}var CO=new(function(e){function t(){return e.apply(this,arguments)||this}ie(t,e);var n=t.prototype;return n.parse=function(e){var t=this._parseXML(e).documentElement;if("plist"!==t.tagName)return b(5100),{};for(var n=null,i=0,o=t.childNodes.length;i<o&&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 o=e.childNodes[n];1===o.nodeType&&t.push(this._parseNode(o))}return t},n._parseDict=function(e){for(var t={},n="",i=0,o=e.childNodes.length;i<o;i++){var r=e.childNodes[i];1===r.nodeType&&("key"===r.tagName?n=r.firstChild.nodeValue:t[n]=this._parseNode(r))}return t},t}(e("es",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 IO(e,t){return e[t]<<8|e[t+1]}var PO=new(function(){function e(){this._parsing=new ff,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?mx.__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,o=null;try{var r=e instanceof ArrayBuffer?e:e.buffer,a=new Int32Array(r,0,13);if(55727696===a[0]){var s=a[7],c=a[6],l=a[12]+52;o={_data:new Uint8Array(r,l),_compressed:!0,width:s,height:c,format:0}}else{if(559044176!==a[11])throw new Error("Invalid magic number in PVR header");var u=a[0],h=a[1],_=a[2];o={_data:new Uint8Array(r,u),_compressed:!0,width:_,height:h,format:0}}}catch(e){i=e}n(i,o)},t.parsePKMTex=function(e,t,n){var i=null,o=null;try{var r=e instanceof ArrayBuffer?e:e.buffer,a=new Uint8Array(r),s=IO(a,6);if(0!==s&&1!==s&&3!==s)throw new Error("Invalid magic number in ETC header");var c=IO(a,12),l=IO(a,14);IO(a,8),IO(a,10),o={_data:new Uint8Array(r,16),_compressed:!0,width:c,height:l,format:0}}catch(e){i=e}n(i,o)},t.parseASTCTex=function(e,t,n){var i=null,o=null;try{var r=e instanceof ArrayBuffer?e:e.buffer,a=new Uint8Array(r);if(1554098963!==a[0]+(a[1]<<8)+(a[2]<<16)+(a[3]<<24))throw new Error("Invalid magic number in ASTC header");var s=a[4],c=a[5],l=a[6];if((s<3||s>6||c<3||c>6||l<3||l>6)&&(s<4||7===s||9===s||11===s||s>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?Wf.RGBA_ASTC_4x4:5===e?4===t?Wf.RGBA_ASTC_5x4:Wf.RGBA_ASTC_5x5:6===e?5===t?Wf.RGBA_ASTC_6x5:Wf.RGBA_ASTC_6x6:8===e?5===t?Wf.RGBA_ASTC_8x5:6===t?Wf.RGBA_ASTC_8x6:Wf.RGBA_ASTC_8x8:10===e?5===t?Wf.RGBA_ASTC_10x5:6===t?Wf.RGBA_ASTC_10x6:8===t?Wf.RGBA_ASTC_10x8:Wf.RGBA_ASTC_10x10:10===t?Wf.RGBA_ASTC_12x10:Wf.RGBA_ASTC_12x12}(s,c),h=a[7]+(a[8]<<8)+(a[9]<<16),_=a[10]+(a[11]<<8)+(a[12]<<16);a[13],a[14],a[15],o={_data:new Uint8Array(r,16),_compressed:!0,width:h,height:_,format:u}}catch(e){i=e}n(i,o)},t.parsePlist=function(e,t,n){var i=null,o=CO.parse(e);o||(i=new Error("parse failed")),n(i,o)},t.parseImport=function(e,t,n){if(e){var i=null,o=null;try{i=_p(e,t)}catch(e){o=e}n(o,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?Ge(this._parsers,e):this._parsers[e]=t},t.parse=function(e,t,n,i,o){var r=this,a=gf.get(e);if(a)o(null,a);else{var s=this._parsing.get(e);if(s)s.push(o);else{var c=this._parsers[n];c?(this._parsing.add(e,[o]),c(t,i,(function(t,n){t?vf.remove(e):Mf(n)||gf.add(e,n);for(var i=r._parsing.remove(e),o=0,a=i.length;o<a;o++)i[o](t,n)}))):o(null,t)}}},e}());function bO(e,t){var n=!1;e.progress||(e.progress={finish:0,total:e.input.length,canInvoke:!0},n=!0);var i=e.options,o=e.progress;i.__exclude__=i.__exclude__||Object.create(null),e.output=[],KN(e.input,(function(r,a){var s=wf.create({input:r,onProgress:e.onProgress,options:i,progress:o,onComplete:function(i,l){i&&!e.isFinish&&(!c.assetManager.force||n?(x(i.message,i.stack),o.canInvoke=!1,t(i)):o.canInvoke&&e.dispatch("progress",++o.finish,o.total,r)),e.output.push(l),s.recycle(),a(null)}});RO.async(s)}),(function(){if(i.__exclude__=null,e.isFinish)return WN(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,o=t.length;i<o;i++)n.push(t[i].content);else e.output=t[0].content}(e),WN(e,!0),t()}))}var RO=new df("loadOneAsset",[function(e,t){var n=e.output=e.input,i=n.options,o=n.isNative,r=n.uuid,a=n.file,s=i.reloadAsset;a||!s&&!o&&mf.has(r)?t():TO.load(n,e.options,(function(e,i){n.file=i,t(e)}))},function(e,t){var n=e.output=e.input,i=e.progress,o=e.options.__exclude__,r=n.id,a=n.file,s=n.options;if(n.isNative)PO.parse(r,a,n.ext,s,(function(o,a){o?t(o):(n.content=a,i.canInvoke&&e.dispatch("progress",++i.finish,i.total,n),vf.remove(r),gf.remove(r),t())}));else{var c=n.uuid;if(c in o){var l=o[c],u=l.finish,h=l.content,_=l.err,f=l.callbacks;i.canInvoke&&e.dispatch("progress",++i.finish,i.total,n),u||JN(c,c,o)?(h&&h.addRef(),n.content=h,t(_)):f.push({done:t,item:n})}else if(!s.reloadAsset&&mf.has(c)){var d=mf.get(c);n.content=d.addRef(),i.canInvoke&&e.dispatch("progress",++i.finish,i.total,n),t()}else s.__uuid__=c,PO.parse(r,a,"import",s,(function(n,i){n?t(n):function(e,t,n){var i=e.input,o=e.progress,r=i,a=r.uuid,s=r.id,c=r.options,l=r.config,u=c.cacheAsset,h=[];t.addRef&&t.addRef(),YN(a,t,Object.create(null),h,l),o.canInvoke&&e.dispatch("progress",++o.finish,o.total+=h.length,i);var _=e.options.__exclude__[a]={content:t,finish:!1,callbacks:[{done:n,item:i}]},f=wf.create({input:h,options:e.options,onProgress:e.onProgress,onError:wf.prototype.recycle,progress:o,onComplete:function(e){if(t.decRef&&t.decRef(!1),_.finish=!0,_.err=e,!e){for(var n,i=Array.isArray(f.output)?f.output:[f.output],o=Object.create(null),r=le(i);!(n=r()).done;){var c=n.value;c&&(o[c instanceof kf?c._uuid+"@import":a+"@native"]=c)}!function(e,t,n){var i=t.__depends__;if(i){for(var o=0,r=i.length;o<r;o++){var a=i[o],s=n[a.uuid+"@import"];if(s)a.owner[a.prop]=s.addRef();else{if(x("The asset "+a.uuid+" is missing!"),a.type&&a.type!==kf){var c=new a.type;c.initDefault(a.uuid),a.owner[a.prop]=c}!0}}t.__depends__=null}t.__nativeDepend__&&(n[e+"@native"]?t._nativeAsset=n[e+"@native"]:(!0,console.error("the native asset of "+e+" is missing!")),t.__nativeDepend__=!1)}(a,t,o);try{"function"!=typeof t.onLoaded||t.__onLoadedInvoked__||t.__nativeDepend__||(t.onLoaded(),t.__onLoadedInvoked__=!0)}catch(e){x("The asset "+a+" is invalid for some reason, detail message: "+e.message+", stack: "+e.stack)}vf.remove(s),gf.remove(s),XN(a,t,u),f.recycle()}for(var l=_.callbacks,h=0,d=l.length;h<d;h++){var p=l[h];t.addRef&&t.addRef(),p.item.content=t,p.done(e)}l.length=0}});xf.async(f)}(e,i,t)}))}}]);function NO(e,t){var n=e.options,i=Object.create(null),o=Object.create(null);for(var r in n)switch(r){case pf.PATH:case pf.UUID:case pf.DIR:case pf.SCENE:case pf.URL:break;case"__requestType__":case"__isNative__":case"ext":case"type":case"__nativeName__":case"audioLoadMode":case"bundle":i[r]=n[r];break;case"__exclude__":case"__outputAsArray__":o[r]=n[r];break;default:i[r]=n[r],o[r]=n[r]}e.options=o;var a=wf.create({input:e.input,options:i}),s=null;try{e.output=e.source=Sf.sync(a)}catch(e){s=e;for(var c=0,l=a.output.length;c<l;c++)a.output[c].recycle()}a.recycle(),t(s)}var OO=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))},te(e,[{key:"id",get:function(){return this._id||(this._id=this.uuid+"@"+(this.isNative?"native":"import")),this._id}}]),e}();OO.MAX_DEAD_NUM=500,OO._deadPool=[];var DO=[];function MO(e){var t=e.options,n=Array.isArray(e.input)?e.input:[e.input];e.output=[];for(var i=function(i){var o=n[i],r=OO.create(),a=null,s=null;if("string"==typeof o&&((o=Object.create(null))[t.__requestType__||pf.UUID]=n[i]),"object"==typeof o)for(var c in He(o,t),o.preset&&He(o,Af[o.preset]),o){switch(c){case pf.UUID:if("break"===function(){var e=r.uuid=Rf(o.uuid);if(!o.bundle){var t=yf.find((function(t){return!!t.getAssetInfo(e)}));o.bundle=t&&t.name}if(yf.has(o.bundle)){if(a=yf.get(o.bundle).config,(s=a.getAssetInfo(e))&&s.redirect){if(!yf.has(s.redirect))throw new Error("Please load bundle "+s.redirect+" first");a=yf.get(s.redirect).config,s=a.getAssetInfo(e)}r.config=a,r.info=s}return r.ext=o.ext||".json","break"}())break;case"__requestType__":case"ext":case"bundle":case"preset":case"type":break;case pf.DIR:if(yf.has(o.bundle)){yf.get(o.bundle).config.getDirWithPath(o.dir,o.type,DO);for(var l,u=le(DO);!(l=u()).done;){var h=l.value;n.push({uuid:h.uuid,__isNative__:!1,ext:".json",bundle:o.bundle})}DO.length=0}r.recycle(),r=null;break;case pf.PATH:if(yf.has(o.bundle)){if(a=yf.get(o.bundle).config,(s=a.getInfoWithPath(o.path,o.type))&&s.redirect){if(!yf.has(s.redirect))throw new Error("you need to load bundle "+s.redirect+" first");a=yf.get(s.redirect).config,s=a.getAssetInfo(s.uuid)}if(!s)throw r.recycle(),new Error("Bundle "+o.bundle+" doesn't contain "+o.path);r.config=a,r.uuid=s.uuid,r.info=s}r.ext=o.ext||".json";break;case pf.SCENE:if(!o.bundle){var _=yf.find((function(e){return!!e.getSceneInfo(o.scene)}));o.bundle=_&&_.name}if(yf.has(o.bundle)){if(a=yf.get(o.bundle).config,(s=a.getSceneInfo(o.scene))&&s.redirect){if(!yf.has(s.redirect))throw new Error("you need to load bundle "+s.redirect+" first");a=yf.get(s.redirect).config,s=a.getAssetInfo(s.uuid)}if(!s)throw r.recycle(),new Error("Bundle "+a.name+" doesn't contain scene "+o.scene);r.config=a,r.uuid=s.uuid,r.info=s}break;case"__isNative__":r.isNative=o.__isNative__;break;case pf.URL:r.url=o.url,r.uuid=o.uuid||o.url,r.ext=o.ext||Fi(o.url),r.isNative=void 0===o.__isNative__||o.__isNative__;break;default:r.options[c]=o[c]}if(!r)break}if(!r)return"continue";if(e.output.push(r),!r.uuid&&!r.url)throw new Error("Can not parse this input:"+JSON.stringify(o))},o=0;o<n.length;o++)i(o);return null}function LO(e){for(var t=e.output=e.input,n=0;n<t.length;n++){var i=t[n];if(!i.url){var o,r,a=i.config;r=i.isNative?a&&a.nativeBase?a.base+a.nativeBase:c.assetManager.generalNativeBase:a&&a.importBase?a.base+a.importBase:c.assetManager.generalImportBase;var s=i.uuid,l="";i.info&&(l=i.isNative?i.info.nativeVer?"."+i.info.nativeVer:"":i.info.ver?"."+i.info.ver:""),o=".ttf"===i.ext?r+"/"+s.slice(0,2)+"/"+s+l+"/"+i.options.__nativeName__:r+"/"+s.slice(0,2)+"/"+s+l+i.ext,i.url=o}}return null}var FO=e("fJ",function(){function e(){this.pipeline=xf.append(NO).append(bO),this.fetchPipeline=Ef.append(NO).append(AO),this.transformPipeline=Sf.append(MO).append(LO),this.bundles=yf,this.assets=mf,this.generalImportBase="",this.generalNativeBase="",this.dependUtil=dp,this.force=!1,this.allowImageBitmap=!mx.isMobile,this.utils=Gf,this.downloader=dO,this.parser=PO,this.packManager=TO,this.cacheAsset=!0,this.cacheManager=null,this.presets=Af,this.factory=SO,this.preprocessPipe=NO,this.fetchPipe=AO,this.loadPipe=bO,this.references=null,this._releaseManager=VN,this._files=vf,this._parsed=gf,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 yf.get(e)||null},t.removeBundle=function(e){e._destroy(),yf.remove(e.name)},t.loadAny=function(e,t,n,i){var o=QN(t,n,i),r=o.options,a=o.onProgress,s=o.onComplete;r.preset=r.preset||"default",e=Array.isArray(e)?e.slice():e;var c=wf.create({input:e,onProgress:a,onComplete:$N(s),options:r});xf.async(c)},t.preloadAny=function(e,t,n,i){var o=QN(t,n,i),r=o.options,a=o.onProgress,s=o.onComplete;r.preset=r.preset||"preload",e=Array.isArray(e)?e.slice():e;var c=wf.create({input:e,onProgress:a,onComplete:$N(s),options:r});Ef.async(c)},t.postLoadNative=function(e,t,n){var i=QN(t,void 0,n),o=i.options,r=i.onComplete;if(e._native&&e.__nativeDepend__){var a=dp.getNativeDep(e._uuid);if(a){if(!yf.has(a.bundle)){var s=yf.find((function(t){return!!t.getAssetInfo(e._uuid)}));s&&(a.bundle=s.name)}this.loadAny(a,o,(function(t,n){t?x(t.message,t.stack):e.isValid&&e.__nativeDepend__&&(e._nativeAsset=n,e.__nativeDepend__=!1),r&&r(t)}))}}else $N(r)(null)},t.loadRemote=function(e,t,n){var i=QN(t,void 0,n),o=i.options,r=i.onComplete;o.reloadAsset||!this.assets.has(e)?(o.__isNative__=!0,o.preset=o.preset||"remote",this.loadAny({url:e},o,null,(function(t,n){t?(x(t.message,t.stack),r&&r(t,n)):SO.create(e,n,o.ext||Fi(e),o,(function(e,t){r&&r(e,t)}))}))):$N(r)(null,this.assets.get(e))},t.loadBundle=function(e,t,n){var i=QN(t,void 0,n),o=i.options,r=i.onComplete,a=Bi(e);this.bundles.has(a)?$N(r)(null,this.getBundle(a)):(o.preset=o.preset||"bundle",o.ext="bundle",o.__isNative__=!0,this.loadAny({url:e},o,null,(function(t,n){t?(x(t.message,t.stack),r&&r(t,n)):SO.create(e,n,"bundle",o,(function(e,t){r&&r(e,t)}))})))},t.releaseAsset=function(e){VN.tryRelease(e,!0)},t.releaseUnusedAssets=function(){mf.forEach((function(e){VN.tryRelease(e)}))},t.releaseAll=function(){mf.forEach((function(e){VN.tryRelease(e,!0)}))},t.loadWithJson=function(){throw new Error("Only valid in Editor")},te(e,[{key:"main",get:function(){return yf.get(Tf.MAIN)||null}},{key:"resources",get:function(){return yf.get(Tf.RESOURCES)||null}}]),e}());FO.Pipeline=df,FO.Task=wf,FO.Cache=ff,FO.RequestItem=OO,FO.Bundle=eO,FO.BuiltinBundleName=Tf;var zO=e("dh",c.assetManager=new FO);c.AssetManager=FO;var BO=[".png",".jpg",".bmp",".jpeg",".gif",".ico",".tiff",".webp",".image",".pvr",".pkm",".astc"],UO=[".mp3",".ogg",".wav",".m4a"];function HO(){return!0}var GO={transformURL:function(e){var t=Of(e);if(!t)return e;var n=yf.find((function(e){return!!e.getAssetInfo(t)}));if(!n)return e;var i,o=n.getAssetInfo(t);if(!(i=e.startsWith(n.base+n.config.nativeBase)?o.nativeVer||"":o.ver||"")||-1!==e.indexOf(i))return e;var r=!1;if(".ttf"===Fi(e)&&(r=!0),r){var a=Ui(e),s=Bi(e);e=a+"."+i+"/"+s}else e=e.replace(/.*[/\\][0-9a-fA-F]{2}[/\\]([0-9a-fA-F-@]{8,}).*/,(function(e){return e+"."+i}));return e}},VO=e("fL",function(){function e(){this._autoReleaseSetting=Object.create(null),this._parseLoadResArgs=ZN}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],o=0;o<i.length;o++){var r=i[o];"string"==typeof r?i[o]={url:r,__isNative__:!0}:(r.type&&(r.ext="."+r.type,r.type=void 0),r.url&&(r.__isNative__=!0))}var a=[],s=[];zO.loadAny(i,null,(function(e,n,i){i.content&&(BO.includes(i.ext)?a.push(i.content):UO.includes(i.ext)&&s.push(i.content)),t&&t(e,n,i)}),(function(e,t){var o=null;if(!e){t=Array.isArray(t)?t:[t];for(var r=function(e){var n=t[e];if(!(n instanceof kf)){var o=n,r=i[e].url;a.includes(o)?SO.create(r,n,".png",{},(function(n,i){o=t[e]=i})):s.includes(o)&&SO.create(r,n,".mp3",{},(function(n,i){o=t[e]=i})),mf.add(r,o)}},c=0;c<t.length;c++)r(c);if(t.length>1){var l=Object.create(null);t.forEach((function(e){l[e._uuid]=e})),o={isCompleted:HO,_map:l}}else o=t[0]}n&&n(e,o)}))},t.getXMLHttpRequest=function(){return new XMLHttpRequest},t.getItem=function(e){return zO.assets.has(e)?{content:zO.assets.get(e)}:null},t.loadRes=function(e,t,n,i){var o=this._parseLoadResArgs(t,n,i),r=o.type,a=o.onProgress,s=o.onComplete,c=Fi(e);c&&!tO.getInfoWithPath(e,r)&&(e=e.slice(0,-c.length)),tO.load(e,r,a,s)},t.loadResArray=function(e,t,n,i){var o=this._parseLoadResArgs(t,n,i),r=o.type,a=o.onProgress,s=o.onComplete;e.forEach((function(t,n){var i=Fi(t);i&&!tO.getInfoWithPath(t,r)&&(e[n]=t.slice(0,-i.length))})),tO.load(e,r,a,s)},t.loadResDir=function(e,t,n,i){var o=this._parseLoadResArgs(t,n,i),r=o.type,a=o.onProgress,s=o.onComplete;tO.loadDir(e,r,a,(function(t,n){var i=[];t||(i=tO.getDirWithPath(e,r).map((function(e){return e.path}))),s&&s(t,n,i)}))},t.getRes=function(e,t){return mf.has(e)?mf.get(e):tO.get(e,t)},t.getResCount=function(){return mf.count},t.getDependsRecursively=function(e){if(!e)return[];var t="string"==typeof e?e:e._uuid;return dp.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);dO.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);PO.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=mf.get(n)),zO.releaseAsset(n)}else e&&("string"==typeof e&&(e=mf.get(e)),zO.releaseAsset(e))},t.releaseAsset=function(e){zO.releaseAsset(e)},t.releaseRes=function(e,t){tO.release(e,t)},t.releaseAll=function(){zO.releaseAll(),mf.clear()},t.removeItem=function(e){return!!mf.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=dp.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]},te(e,[{key:"onProgress",set:function(e){kN=e}},{key:"_cache",get:function(){return mf._map}},{key:"md5Pipe",get:function(){return GO}},{key:"downloader",get:function(){return dO}},{key:"loader",get:function(){return zO.parser}}]),e}()),kO=e("fM",new VO),WO=e("fN",{init:function(e){e.importBase=e.libraryPath,e.nativeBase=e.rawAssetsBase,zO.init(e),e.rawAssets&&tO.init({base:"",deps:[],scenes:{},redirect:[],debug:!0,packs:{},types:[],versions:{import:[],native:[]},name:Tf.RESOURCES,importBase:e.importBase,nativeBase:e.nativeBase,paths:e.rawAssets.assets,uuids:Object.keys(e.rawAssets.assets)})},loadAsset:function(e,t){zO.loadAny(e,t)}}),jO=e("fO",{});q(jO,"url",[{name:"normalize",target:zO.utils,targetName:"assetManager.utils",newName:"normalize"},{name:"raw",targetName:"Asset.prototype",newName:"nativeUrl",customFunction:function(e){return e.startsWith("resources/")?Ff({path:Hi(e.substr(10)),bundle:Tf.RESOURCES,__isNative__:!0,ext:Fi(e)}):""}}]),Y(WO,"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"}]),Y(kO,"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"}]),q(c,"cc",[{name:"loader",newName:"assetManager",logTimes:1,customGetter:function(){return kO}},{name:"AssetLibrary",newName:"assetManager",logTimes:1,customGetter:function(){return WO}},{name:"Pipeline",target:FO,targetName:"AssetManager",newName:"Pipeline",logTimes:1},{name:"url",targetName:"assetManager",newName:"utils",logTimes:1,customGetter:function(){return jO}}]),Y(c,"cc",[{name:"LoadingItems",suggest:L(1400,"cc.LoadingItems","cc.AssetManager.Task")}]),q(ft,"macro",[{name:"DOWNLOAD_MAX_CONCURRENT",target:dO,targetName:"assetManager.downloader",newName:"maxConcurrency"}]),q(LN,"director",[{name:"_getSceneUuid",targetName:"assetManager.main",newName:"getSceneInfo",customFunction:function(e){var t;return zO.main?null===(t=zO.main.getSceneInfo(e))||void 0===t?void 0:t.uuid:""}}]),q(tC,"game",[{name:"_sceneInfos",targetName:"assetManager.main",newName:"getSceneInfo",customGetter:function(){var e=[];return zO.main&&zO.main.config.scenes.forEach((function(t){e.push(t)})),e}}]);var qO,YO,XO,KO,QO,ZO,JO,$O,eD,tD,nD,iD,oD,rD,aD=VN._autoRelease;VN._autoRelease=function(e,t,n){aD.call(VN,e,t,n);for(var i=kO._autoReleaseSetting,o=Object.keys(i),r=0;r<o.length;r++){var a=o[r];if(!0===i[a]){var s=mf.get(a);s&&VN.tryRelease(s)}}};var sD,cD,lD,uD,hD,_D,fD,dD,pD,mD,vD,gD,yD,xD,ED,SD,TD,AD,wD,CD,ID,PD,bD,RD,ND,OD,DD,MD,LD,FD,zD,BD,UD,HD,GD,VD,kD,WD,jD,qD,YD,XD,KD,QD,ZD,JD,$D,eM,tM,nM,iM,oM,rM,aM,sM,cM,lM,uM,hM,_M,fM,dM,pM,mM,vM,gM,yM,xM=e("dB",(qO=L_("cc.ClickEvent"),YO=hf(c.Node),XO=J_(),KO=J_(),QO=J_(),ZO=J_(),qO((rD=function(){function e(){ue(this,"target",eD,this),ue(this,"component",tD,this),ue(this,"_componentId",nD,this),ue(this,"handler",iD,this),ue(this,"customEventData",oD,this)}e.emitEvents=function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];for(var r=0,a=t.length;r<a;r++){var s=t[r];s instanceof e&&s.emit(i)}};var t=e.prototype;return t.emit=function(e){var t=this.target;if(c.isValid(t)){this._genCompIdIfNeeded();var n=c.js._getClassById(this._componentId),i=t.getComponent(n);if(c.isValid(i)){var o=i[this.handler];"function"==typeof o&&(null!=this.customEventData&&""!==this.customEventData&&(e=e.slice()).push(this.customEventData),o.apply(i,e))}}},t._compName2Id=function(e){var t=c.js.getClassByName(e);return c.js._getClassId(t)},t._compId2Name=function(e){var t=c.js._getClassById(e);return c.js.getClassName(t)},t._genCompIdIfNeeded=function(){this._componentId||(this._componentName=this.component,this.component="")},te(e,[{key:"_componentName",get:function(){return this._genCompIdIfNeeded(),this._compId2Name(this._componentId)},set:function(e){this._componentId=this._compName2Id(e)}}]),e}(),eD=he(($O=rD).prototype,"target",[H_,YO,XO],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),tD=he($O.prototype,"component",[H_,K_,KO],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),nD=he($O.prototype,"_componentId",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),iD=he($O.prototype,"handler",[H_,K_,QO],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),oD=he($O.prototype,"customEventData",[H_,K_,ZO],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),JO=$O))||JO));c.Component.EventHandler=xM;var EM,SM,TM,AM,wM,CM,IM,PM,bM,RM,NM=new Rn,OM=ct(s_),DM=ct(a_),MM=ct(c_),LM=ct(u_),FM=ct(l_),zM=ct({SKYBOX:T_|us.DEPTH_STENCIL,SOLID_COLOR:us.ALL,DEPTH_ONLY:us.DEPTH_STENCIL,DONT_CLEAR:us.NONE}),BM=e("dc",(sD=L_("cc.Camera"),cD=X_(),lD=W_(),uD=rf(),hD=J_(),_D=hf(Vu.BitMask),fD=rf(),dD=J_(),pD=hf(zM),mD=rf(),vD=J_(),gD=rf(),yD=J_(),xD=rf(),ED=J_(),SD=rf(),TD=J_(),AD=hf(OM),wD=rf(),CD=J_(),ID=hf(DM),PD=rf(),bD=J_(),RD=rf(),ND=J_(),OD=rf(),DD=J_(),MD=rf(),LD=J_(),FD=rf(),zD=J_(),BD=hf(MM),UD=rf(),HD=J_(),GD=hf(LM),VD=rf(),kD=J_(),WD=hf(FM),jD=rf(),qD=J_(),YD=rf(),XD=J_(),KD=hf(_E),QD=rf(),ZD=J_(),sD(JD=cD(JD=lD(JD=k_((yM=gM=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return ue(t=e.call.apply(e,[this].concat(i))||this,"_projection",eM,se(t)),ue(t,"_priority",tM,se(t)),ue(t,"_fov",nM,se(t)),ue(t,"_fovAxis",iM,se(t)),ue(t,"_orthoHeight",oM,se(t)),ue(t,"_near",rM,se(t)),ue(t,"_far",aM,se(t)),ue(t,"_color",sM,se(t)),ue(t,"_depth",cM,se(t)),ue(t,"_stencil",lM,se(t)),ue(t,"_clearFlags",uM,se(t)),ue(t,"_rect",hM,se(t)),ue(t,"_aperture",_M,se(t)),ue(t,"_shutter",fM,se(t)),ue(t,"_iso",dM,se(t)),ue(t,"_screenScale",pM,se(t)),ue(t,"_visibility",mM,se(t)),ue(t,"_targetTexture",vM,se(t)),t._camera=null,t._inEditorMode=!1,t._flows=void 0,t}ie(t,e);var n=t.prototype;return n.onLoad=function(){this._createCamera()},n.onEnable=function(){this.node.hasChangedFlags|=m_.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=Ea.create()),this._camera&&this._camera.screenPointToRay(n,e,t),n},n.worldToScreen=function(e,t){return t||(t=new Rn),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 Rn),!this._camera)return n;this.worldToScreen(e,NM);var i=t.getComponent("cc.UITransform"),o=cC.getVisibleSize(),r=NM.x-.5*this._camera.width,a=NM.y-.5*this._camera.height;return NM.x=r/c.view.getScaleX()+.5*o.width,NM.y=a/c.view.getScaleY()+.5*o.height,i&&i.convertToNodeSpaceAR(NM,n),n},n._createCamera=function(){this._camera||(this._camera=c.director.root.createCamera(),this._camera.initialize({name:this.node.name,node:this.node,projection:this._projection,window:this._inEditorMode?c.director.root&&c.director.root.mainWindow:c.director.root&&c.director.root.tempWindow,priority:this._priority}),this._camera.viewport=this._rect,this._camera.fovAxis=this._fovAxis,this._camera.fov=fn(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)}},te(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===a_.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=fn(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?c.director.root&&c.director.root.mainWindow:c.director.root&&c.director.root.tempWindow)}}]),t}(lp),gM.ProjectionType=OM,gM.FOVAxis=DM,gM.ClearFlag=zM,gM.Aperture=MM,gM.Shutter=LM,gM.ISO=FM,eM=he(($D=yM).prototype,"_projection",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return OM.PERSPECTIVE}}),tM=he($D.prototype,"_priority",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),nM=he($D.prototype,"_fov",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 45}}),iM=he($D.prototype,"_fovAxis",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return DM.VERTICAL}}),oM=he($D.prototype,"_orthoHeight",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 10}}),rM=he($D.prototype,"_near",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),aM=he($D.prototype,"_far",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1e3}}),sM=he($D.prototype,"_color",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Pn("#333333")}}),cM=he($D.prototype,"_depth",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),lM=he($D.prototype,"_stencil",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),uM=he($D.prototype,"_clearFlags",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return zM.SOLID_COLOR}}),hM=he($D.prototype,"_rect",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new oi(0,0,1,1)}}),_M=he($D.prototype,"_aperture",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return MM.F16_0}}),fM=he($D.prototype,"_shutter",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return LM.D125}}),dM=he($D.prototype,"_iso",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return FM.ISO100}}),pM=he($D.prototype,"_screenScale",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),mM=he($D.prototype,"_visibility",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return h_}}),vM=he($D.prototype,"_targetTexture",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),he($D.prototype,"priority",[uD,hD],Object.getOwnPropertyDescriptor($D.prototype,"priority"),$D.prototype),he($D.prototype,"visibility",[_D,fD,dD],Object.getOwnPropertyDescriptor($D.prototype,"visibility"),$D.prototype),he($D.prototype,"clearFlags",[pD,mD,vD],Object.getOwnPropertyDescriptor($D.prototype,"clearFlags"),$D.prototype),he($D.prototype,"clearColor",[gD,yD],Object.getOwnPropertyDescriptor($D.prototype,"clearColor"),$D.prototype),he($D.prototype,"clearDepth",[xD,ED],Object.getOwnPropertyDescriptor($D.prototype,"clearDepth"),$D.prototype),he($D.prototype,"clearStencil",[SD,TD],Object.getOwnPropertyDescriptor($D.prototype,"clearStencil"),$D.prototype),he($D.prototype,"projection",[AD,wD,CD],Object.getOwnPropertyDescriptor($D.prototype,"projection"),$D.prototype),he($D.prototype,"fovAxis",[ID,PD,bD],Object.getOwnPropertyDescriptor($D.prototype,"fovAxis"),$D.prototype),he($D.prototype,"fov",[RD,ND],Object.getOwnPropertyDescriptor($D.prototype,"fov"),$D.prototype),he($D.prototype,"orthoHeight",[OD,DD],Object.getOwnPropertyDescriptor($D.prototype,"orthoHeight"),$D.prototype),he($D.prototype,"near",[MD,LD],Object.getOwnPropertyDescriptor($D.prototype,"near"),$D.prototype),he($D.prototype,"far",[FD,zD],Object.getOwnPropertyDescriptor($D.prototype,"far"),$D.prototype),he($D.prototype,"aperture",[BD,UD,HD],Object.getOwnPropertyDescriptor($D.prototype,"aperture"),$D.prototype),he($D.prototype,"shutter",[GD,VD,kD],Object.getOwnPropertyDescriptor($D.prototype,"shutter"),$D.prototype),he($D.prototype,"iso",[WD,jD,qD],Object.getOwnPropertyDescriptor($D.prototype,"iso"),$D.prototype),he($D.prototype,"rect",[YD,XD],Object.getOwnPropertyDescriptor($D.prototype,"rect"),$D.prototype),he($D.prototype,"targetTexture",[KD,QD,ZD],Object.getOwnPropertyDescriptor($D.prototype,"targetTexture"),$D.prototype),JD=$D))||JD)||JD)||JD)||JD));c.Camera=BM;var UM,HM,GM,VM,kM,WM,jM,qM,YM={parent:null,owner:null,subModelIdx:0},XM=e("ca",(EM=L_("cc.RenderableComponent"),SM=hf([fE]),TM=hf(fE),AM=rf(),wM=Z_(),EM((RM=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return ue(t=e.call.apply(e,[this].concat(i))||this,"_materials",PM,se(t)),ue(t,"_visFlags",bM,se(t)),t._materialInstances=[],t._models=[],t}ie(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 VE&&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]){YM.parent=this._materials[e],YM.owner=this,YM.subModelIdx=e;var t=new VE(YM);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(){},te(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}(lp),PM=he((IM=RM).prototype,"_materials",[SM],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),bM=he(IM.prototype,"_visFlags",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Vu.Enum.NONE}}),he(IM.prototype,"sharedMaterials",[TM,AM,wM],Object.getOwnPropertyDescriptor(IM.prototype,"sharedMaterials"),IM.prototype),CM=IM))||CM));function KM(e){return"string"==typeof e||"number"==typeof e}function QM(e,t){return e instanceof t}c.RenderableComponent=XM,q(BM,"Camera",[{name:"CameraClearFlag",newName:"ClearFlag"}]),q(BM.prototype,"Camera.prototype",[{name:"color",newName:"clearColor"},{name:"depth",newName:"clearDepth"},{name:"stencil",newName:"clearStencil"}]),c.CameraComponent=BM,at.setClassAlias(BM,"cc.CameraComponent");var ZM,JM,$M,eL,tL,nL,iL=e("bb",L_("cc.animation.HierarchyPath")((VM=function(){function e(e){ue(this,"path",GM,this),this.path=e||""}return e.prototype.get=function(e){return e instanceof ry?e.getChildByPath(this.path)||(y('Node "'+e.name+'" has no path "'+this.path+'"'),null):(y("Target of hierarchy path should be of type Node."),null)},e}(),GM=he((HM=VM).prototype,"path",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),UM=HM))||UM),oL=e("bc",L_("cc.animation.ComponentPath")((qM=function(){function e(e){ue(this,"component",jM,this),this.component=e||""}return e.prototype.get=function(e){return e instanceof ry?e.getComponent(this.component)||(y('Node "'+e.name+'" has no component "'+this.component+'"'),null):(y("Target of component path should be of type Node."),null)},e}(),jM=he((WM=qM).prototype,"component",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),kM=WM))||kM);function rL(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(KM(i)){if(!(i in t))return y('Target object has no property "'+i+'"'),null;t=t[i]}else t=i.get(t);if(null===t)break}return t}var aL,sL,cL,lL,uL,hL,_L,fL,dL,pL,mL,vL=e("b6",L_("cc.animation.UniformProxyFactory")((nL=function(){function e(e,t){ue(this,"passIndex",$M,this),ue(this,"uniformName",eL,this),ue(this,"channelIndex",tL,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 i=mm.getPropertyTypeFromHandle(n);if(i===Lp.BUFFER){var o=void 0===this.channelIndex?n:t.getHandle(this.uniformName,this.channelIndex,Ma.FLOAT);if(!o)throw new Error('Uniform "'+this.uniformName+" (in material "+e.name+") has no channel "+this.channelIndex+'"');return function(e,t){for(var n,i=le(e.shaderInfo.blocks);!(n=i()).done;)for(var o,r=le(n.value.members);!(o=r()).done;){var a=o.value;if(a.name===t)return a.count>1}return!1}(t,this.uniformName)?{set:function(e){t.setUniformArray(o,e)}}:{set:function(e){t.setUniform(o,e)}}}if(i===Lp.TEXTURE){var r=mm.getBindingFromHandle(n),a=t.properties[this.uniformName],s=a&&a.value?a.value+"-texture":Qp(a.type),l=hm.get(s);return l||(y("Illegal texture default value: "+s+"."),l=hm.get("default-texture")),{set:function(e){e||(e=l);var n=e.getGFXTexture();n&&n.width&&n.height&&(t.bindTexture(r,n),e instanceof Ed&&t.bindSampler(r,yd.getSampler(c.game._gfxDevice,e.getSamplerHash())))}}}throw new Error("Animations are not available for uniforms with property type "+i+".")},e}(),$M=he((JM=nL).prototype,"passIndex",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),eL=he(JM.prototype,"uniformName",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),tL=he(JM.prototype,"channelIndex",[cf],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){}}),ZM=JM))||ZM);function gL(e,t,n,i){var o,r,a,s,c,l,u=new t,h=new t,_=new t,f=L_(e)((l=function(){function e(e,n,i){ue(this,"dataPoint",a,this),ue(this,"inTangent",s,this),ue(this,"outTangent",c,this),this.dataPoint=e||new t,this.inTangent=n||new t,this.outTangent=i||new t}var o=e.prototype;return o.lerp=function(e,t,o){var r=this.dataPoint,a=e.dataPoint;h=n(h,this.inTangent,o),_=n(_,e.outTangent,o);var s=t*t*t,c=t*t,l=s-2*c+t,f=-2*s+3*c,d=s-c;return u=n(u,r,2*s-3*c+1),u=i(u,u,h,l),u=i(u,u,a,f),u=i(u,u,_,d)},o.getNoLerp=function(){return this.dataPoint},e}(),a=he((r=l).prototype,"dataPoint",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new t}}),s=he(r.prototype,"inTangent",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new t}}),c=he(r.prototype,"outTangent",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new t}}),o=r))||o;if(t===zn){var d=f.prototype.lerp;f.prototype.lerp=function(e,t,n){var i=d.call(this,e,t,n);return zn.normalize(i,i),i}}return f}e("b7",L_("cc.animation.MorphWeightsValueProxy")((lL=function(){function e(){ue(this,"subMeshIndex",cL,this)}return e.prototype.forTarget=function(e){var t=this;return{set:function(n){e.setWeights(n,t.subMeshIndex)}}},e}(),cL=he((sL=lL).prototype,"subMeshIndex",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),aL=sL))||aL),e("b8",L_("cc.animation.MorphWeightsAllValueProxy")(uL=function(){function e(){}return e.prototype.forTarget=function(e){return{set:function(t){for(var n,i,o=null!==(n=null===(i=e.mesh)||void 0===i?void 0:i.struct.primitives.length)&&void 0!==n?n:0,r=0;r<o;++r)e.setWeights(t,r)}}},e}())||uL);var yL=e("be",gL("cc.CubicSplineVec2Value",Kn,Kn.multiplyScalar,Kn.scaleAndAdd));c.CubicSplineVec2Value=yL;var xL=e("bf",gL("cc.CubicSplineVec3Value",Rn,Rn.multiplyScalar,Rn.scaleAndAdd));c.CubicSplineVec3Value=xL;var EL=e("bg",gL("cc.CubicSplineVec4Value",$n,$n.multiplyScalar,$n.scaleAndAdd));c.CubicSplineVec4Value=EL;var SL=e("bh",gL("cc.CubicSplineQuatValue",zn,zn.multiplyScalar,zn.scaleAndAdd));c.CubicSplineQuatValue=SL;var TL=e("bi",L_("cc.CubicSplineNumberValue")((mL=function(){function e(e,t,n){ue(this,"dataPoint",fL,this),ue(this,"inTangent",dL,this),ue(this,"outTangent",pL,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,o=e.dataPoint,r=t*t*t,a=t*t;return i*(2*r-3*a+1)+this.outTangent*n*(r-2*a+t)+o*(-2*r+3*a)+e.inTangent*n*(r-a)},t.getNoLerp=function(){return this.dataPoint},e}(),fL=he((_L=mL).prototype,"dataPoint",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),dL=he(_L.prototype,"inTangent",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),pL=he(_L.prototype,"outTangent",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),hL=_L))||hL);function AL(e,t,n){void 0===n&&(n=1e-6);for(var i=0,o=e.length-1,r=o>>>1;i<=o;r=i+o>>>1){var a=e[r];if(a>t+n)o=r-1;else{if(!(a<t-n))return r;i=r+1}}return~i}function wL(e,t,n,i,o){var r=1-o;return r*(r*(e+(3*t-e)*o)+3*n*o*o)+i*o*o*o}c.CubicSplineNumberValue=TL,c.bezier=wL;var CL=Math.cos,IL=Math.acos,PL=Math.max,bL=2*Math.PI,RL=Math.sqrt;function NL(e){return e<0?-Math.pow(-e,1/3):Math.pow(e,1/3)}function OL(e,t){var n=function(e,t){var n,i,o,r,a=t-0,s=t-e[0],c=3*a,l=3*s,u=3*(t-e[2]),h=1/(-a+l-u+(t-1)),_=1/3,f=(c-6*s+u)*h,d=f*_,p=(-c+l)*h,m=(3*p-f*f)*_,v=m*_,g=(2*f*f*f-9*f*p+a*h*27)/27,y=g/2,x=y*y+v*v*v;if(x<0){var E=-m*_,S=RL(E*E*E),T=-g/(2*S),A=IL(T<-1?-1:T>1?1:T),w=2*NL(S);return i=w*CL(A*_)-d,o=w*CL((A+bL)*_)-d,r=w*CL((A+2*bL)*_)-d,i>=0&&i<=1?o>=0&&o<=1?r>=0&&r<=1?PL(i,o,r):PL(i,o):r>=0&&r<=1?PL(i,r):i:o>=0&&o<=1?r>=0&&r<=1?PL(o,r):o:r}if(0===x)return o=-(n=y<0?NL(-y):-NL(y))-d,(i=2*n-d)>=0&&i<=1?o>=0&&o<=1?PL(i,o):i:o;var C=RL(x);return(n=NL(-y+C))-NL(y+C)-d}(e,t),i=e[1];return((1-n)*(i+(e[3]-i)*n)*3+n*n)*n}c.bezierByTime=OL;var DL=e("g1",function(){function e(e){var t,n;this.ratios=void 0,this._findRatio=void 0,this.ratios=e;for(var i=!0,o=1,r=e.length;o<r;o++)if(t=e[o]-e[o-1],1===o)n=t;else if(Math.abs(t-n)>1e-6){i=!1;break}this._findRatio=i?zL:AL}return e.prototype.sample=function(e){return this._findRatio(this.ratios,e)},e}());c.RatioSampler=DL;var ML=e("g2",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 o=0,r=Object.keys(t.easingMethods);o<r.length;o++){var a=r[o];this.types[a]=i(t.easingMethods[a])}}else this.type=null;var s=t.values[0];(void 0===t.interpolate||t.interpolate)&&(this._lerp=$L(s)),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,o){if(this._lerp){var r=this.types?this.types[t]:this.type,a=o-n,s=(e-n)/a;if(r&&(s=FL(s,r)),void 0===this._array){var c=this._values[t],l=this._values[i];return this._lerp(c,l,s,a*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,_,s,a*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 LL(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 FL(e,t){if("string"==typeof t){var n=fI[t];n?e=n(e):N(3906,t)}else Array.isArray(t)&&(e=OL(t,e));return e}function zL(e,t){var n=e.length-1;if(0===n)return 0;var i=e[0];if(t<i)return 0;var o=e[n];if(t>o)return n;var r=(t=(t-i)/(o-i))/(1/n),a=0|r,s=1e-6;return r-a<s?a:a+1-r<s?a+1:~(a+1)}ML.Linear=null,c.AnimCurve=ML,e("g3",function(){function e(){this.events=[]}return e.prototype.add=function(e,t){this.events.push({func:e||"",params:t||[]})},e}()),c.sampleAnimationCurve=LL;var BL,UL,HL,GL,VL,kL,WL,jL,qL,YL,XL,KL,QL,ZL,JL,$L=function(){function e(e,t,n,i){return e.lerp(t,n,i)}return function(t){if(null!==t){if("number"==typeof t)return _n;if("object"==typeof t&&t.constructor){if(t instanceof zn)return n=new zn,function(e,t,i){return zn.slerp(n,e,t,i)};if(t instanceof _t)return function(e){var t=new e;return function(n,i,o){return e.lerp(t,n,i,o),t}}(t.constructor);if(t.constructor===Number)return _n;if("function"==typeof t.lerp)return e}var n}}}(),eF=e("cu",function(){function e(){}return e.getOrExtract=function(t){var n=e.pool.get(t);return n&&n.info.sample===t.sample||(n&&c.director.root.dataPoolManager.releaseAnimationClip(t),n=function(e){var t={};e.curves.forEach((function(e){if(!e.valueAdapter&&QM(e.modifiers[0],iL)&&KM(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=r[o],a=t[i];if(!a)return"continue";Object.defineProperty(a,"worldMatrix",{get:function(){if(!a._worldMatrix){var o=a.position,r=a.rotation,s=a.scale;tF(e,o,n),tF(e,r,n),tF(e,s,n),function(e,t,n){var i=n.position.values,o=n.rotation.values,r=n.scale.values,a=i.map((function(){return new jn})),s=t.lastIndexOf("/"),c=null;if(s>0){var l=e[t.substring(0,s)];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],_=o[u],f=r[u],d=a[u];jn.fromRTS(d,_,h,f),c&&jn.multiply(d,c[u],d)}Object.keys(n).forEach((function(e){return delete n[e]})),n._worldMatrix={keys:0,interpolate:!1,values:a}}(t,i,a)}return a._worldMatrix}})},o=0,r=Object.keys(t);o<r.length;o++)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 tF(e,t,n){var i=e.keys[t.keys],o=[];if(i&&1!==i.length)for(var r=t.values[0]instanceof zn,a=0,s=0;a<n;a++){for(var c=a/e.sample;i[s]<=c;)s++;s>i.length-1?c=i[s=i.length-1]:0===s&&(s=1);var l=t.values[s-1].clone(),u=i[s]-i[s-1],h=u?hn((c-i[s-1])/u):1;r?l.slerp(t.values[s],h):l.lerp(t.values[s],h),o[a]=l}else for(var _=0;_<n;_++)o[_]=t.values[0].clone();t.values=o}eF.pool=new Map;var nF=e("g6",L_("cc.AnimationClip")((JL=ZL=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return ue(t=e.call.apply(e,[this].concat(i))||this,"sample",HL,se(t)),ue(t,"speed",GL,se(t)),ue(t,"wrapMode",VL,se(t)),ue(t,"events",kL,se(t)),ue(t,"enableTrsBlending",WL,se(t)),ue(t,"_duration",jL,se(t)),ue(t,"_keys",qL,se(t)),ue(t,"_stepness",YL,se(t)),ue(t,"_curves",XL,se(t)),ue(t,"_commonTargets",KL,se(t)),ue(t,"_hash",QL,se(t)),t.frameRate=0,t._ratioSamplers=[],t._runtimeCurves=void 0,t._runtimeEvents=void 0,t._data=null,t}ie(t,e),t.createWithSpriteFrames=function(e,n){if(!Array.isArray(e))return N(3905),null;var i=new t;i.sample=n||i.sample,i.duration=e.length/i.sample;for(var o=1/i.sample,r=new Array(e.length),a=new Array(r.length),s=0;s<e.length;s++)r[s]=s*o,a[s]=e[s];return i.keys=[r],i.curves=[{modifiers:[new oL("cc.Sprite"),"spriteFrame"],data:{keys:0,values:a}}],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(),AL(this._runtimeEvents.ratios,e)},n.hasEvents=function(){return 0!==this.events.length},n.destroy=function(){return c.director.root.dataPoolManager&&c.director.root.dataPoolManager.releaseAnimationClip(this),eF.destroy(this),e.prototype.destroy.call(this)},n._createPropertyCurves=function(){var e=this;this._ratioSamplers=this._keys.map((function(t){return new DL(t.map((function(t){return t/e._duration})))})),this._runtimeCurves=this._curves.map((function(t){return{curve:new ML(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=[],o=function(){var o=e.value,r=o.frame/t._duration,a=n.findIndex((function(e){return e===r}));a<0&&(a=n.length,n.push(r),i.push({events:[]})),i[a].events.push({functionName:o.func,parameters:o.params})},r=le(this.events.sort((function(e,t){return e.frame-t.frame})));!(e=r()).done;)o();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 qI&&(t[n]=i.decompress(e))}for(var o=0;o<this._curves.length;++o){var r=this._curves[o];r.data.values instanceof qI&&(r.data.values=r.data.values.decompress(e))}}},n.validate=function(){return this.keys.length>0&&this.curves.length>0},te(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=Rc(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}(kf),ZL.WrapMode=Su,HL=he((UL=JL).prototype,"sample",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 60}}),GL=he(UL.prototype,"speed",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),VL=he(UL.prototype,"wrapMode",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Su.Normal}}),kL=he(UL.prototype,"events",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),WL=he(UL.prototype,"enableTrsBlending",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),jL=he(UL.prototype,"_duration",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),qL=he(UL.prototype,"_keys",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),YL=he(UL.prototype,"_stepness",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),XL=he(UL.prototype,"_curves",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),KL=he(UL.prototype,"_commonTargets",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),QL=he(UL.prototype,"_hash",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),BL=UL))||BL);function iF(e,t,n){var i=t[t.length-1];if(0!==t.length&&KM(i)&&!n){var o=rL.apply(void 0,[e].concat(t.slice(0,t.length-1)));return null===o?null:{setValue:function(e){o[i]=e},getValue:function(){return o[i]}}}if(n){var r=rL.apply(void 0,[e].concat(t));if(null===r)return null;var a=n.forTarget(r);return{setValue:function(e){a.set(e)},getValue:function(){return a.get?a.get():(x("Target doesn't provide a get method."),null)}}}return x("Empty animation curve."),null}function oF(e,t,n){var i=iF(e,t,n);if(null===i)return null;var o=i.getValue(),r=aF(o);if(!r)return x("Value is not copyable!"),null;var a=r.createBuffer(),s=r.copy;return Object.assign(i,{peek:function(){return a},pull:function(){var e=i.getValue();s(a,e)},push:function(){i.setValue(a)}})}c.AnimationClip=nF;var rF,aF=((rF=new Map).set(Kn,{createBuffer:function(){return new Kn},copy:Kn.copy}),rF.set(Rn,{createBuffer:function(){return new Rn},copy:Rn.copy}),rF.set($n,{createBuffer:function(){return new $n},copy:$n.copy}),rF.set(Pn,{createBuffer:function(){return new Pn},copy:Pn.copy}),rF.set(ni,{createBuffer:function(){return new ni},copy:function(e,t){return e.set(t)}}),function(e){return rF.get(null==e?void 0:e.constructor)}),sF=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(L(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(){},te(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}(),cF=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 hF(n,lF(t)?new Rn:new zn)),++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,o,r=e.properties,a=r.position,s=r.scale,c=r.rotation,l=r.eulerAngles,u=!1;a&&0!==a.weight&&(a.weight=0,n=a.value,u=!0),s&&0!==s.weight&&(s.weight=0,i=s.value,u=!0),c&&0!==c.weight&&(c.weight=0,o=c.value,u=!0),l&&0!==l.weight&&(l.weight=0,o=l.value,u=!0),u&&t.setRTS(o,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 lF(e){return!function(e){return"rotation"===e}(e)}var uF,hF=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 _F(e,t,n){return 0===n.weight&&Rn.zero(n.value),0===t?n.value:1===t?Rn.copy(n.value,e):Rn.scaleAndAdd(n.value,n.value,e,t)}function fF(e,t,n){if(0===n.weight&&zn.identity(n.value),0===t)return n.value;if(1===t)return zn.copy(n.value,e);var i=t/(n.weight+t);return zn.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"}(uF||(uF={})),ht(uF);var dF=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,this._shouldLerp=e.curve.hasLerp()}var t=e.prototype;return t.applySample=function(e,t,n,i,o){var r;r=this._shouldLerp&&n?this._curve.valueBetween(e,i.from,i.fromRatio,i.to,i.toRatio):this._curve.valueAt(t),this._setValue(r,o)},t._setValue=function(e){this._boundTarget.setValue(e)},te(e,[{key:"propertyName",get:function(){return this._rootTargetProperty||""}},{key:"curveDetail",get:function(){return this._curveDetail}}]),e}(),pF=e("cN",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=Su.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 wu,i._blendStateBuffer=null,i._blendStateWriters=[],i._allowLastFrame=!1,i._blendStateWriterHost={weight:0,enabled:!1},i._playbackRange=void 0,i._playbackDuration=0,i._invDuration=1,i._clip=t,i._name=n||t&&t.name,i._playbackRange={min:0,max:i._clip.duration},i._playbackDuration=t.duration,t.duration||S("Clip "+t.name+" has zero duration."),i}ie(t,e);var n=t.prototype;return n.initialize=function(e,t){var n,i,o=this;if(!this._curveLoaded){this._curveLoaded=!0,this._destroyBlendStateWriters(),this._samplerSharedGroups.length=0,this._blendStateBuffer=null!==(n=null===(i=c.director.getAnimationManager())||void 0===i?void 0:i.blendState)&&void 0!==n?n:null,this._blendStateBuffer&&this._blendStateBuffer.bindState(this),this._targetNode=e;var r=this._clip;this.duration=r.duration,this._invDuration=1/this.duration,this.speed=r.speed,this.wrapMode=r.wrapMode,this.frameRate=r.sample,this._playbackRange={min:0,max:r.duration},this._playbackDuration=r.duration,(this.wrapMode&Eu.Loop)===Eu.Loop?this.repeatCount=1/0:this.repeatCount=1;var a=function(e,t,n,i,a){if(!(r.enableTrsBlending&&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 iL))return!1;t=e[e.length-1]}switch(t){case"position":case"scale":case"rotation":case"eulerAngles":return!0;default:return!1}}(n)&&o._blendStateBuffer))return e(t,n,i);var s=rL.apply(void 0,[t].concat(n.slice(0,n.length-1)));if(null!==s&&s instanceof ry){var c=n[n.length-1],l=function(e,t,n,i,o){var r=lF(n)?_F:fF,a=e.ref(t,n),s=!1,c=-1;return{destroy:function(){a&&(e.deRef(t,n),a=null)},forTarget:function(){return{get:function(){return t[n]},set:function(e){if(a&&i.enabled){var t=i.weight;if(o)if(1!==t||t!==c)s=!1;else if(s)return;r(e,t,a),a.weight+=t,a.markAsDirty(),s=!0,c=t}}}}}}(o._blendStateBuffer,s,c,o._blendStateWriterHost,a);return o._blendStateWriters.push(l),e(t,[],l)}return null};this._commonTargetStatuses=r.commonTargets.map((function(t){var n=a(oF,e,t.modifiers,t.valueAdapter,!1);return null===n?null:{target:n,changed:!1}})),t||(t=r.getPropertyCurves());for(var s=function(n){var i=t[n];if(i.curve.empty())return"continue";var r=o._samplerSharedGroups.find((function(e){return e.sampler===i.sampler}));r||(r={sampler:i.sampler,curves:[],samplerResultCache:{from:0,fromRatio:0,to:0,toRatio:0}},o._samplerSharedGroups.push(r));var s=void 0;if(void 0===i.commonTarget)s=e;else{var c=o._commonTargetStatuses[i.commonTarget];if(!c)return"continue";s=c.target.peek()}var l=a(iF,s,i.modifiers,i.valueAdapter,i.curve.constant());if(null===l);else{var u=new dF(i,s,l);u.commonTargetIndex=i.commonTarget,r.curves.push(u)}},l=0;l<t.length;++l)s(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];c.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(uF.PLAY,this)},n.onStop=function(){this.isPaused||this._onPauseOrStop(),this.emit(uF.STOP,this)},n.onResume=function(){this._onReplayOrResume(),this.emit(uF.RESUME,this)},n.onPause=function(){this._onPauseOrStop(),this.emit(uF.PAUSE,this)},n._sampleCurves=function(e){this._blendStateWriterHost.weight=this.weight,this._blendStateWriterHost.enabled=!0;for(var t=this._commonTargetStatuses,n=0,i=t.length;n<i;++n){var o=t[n];o&&(o.target.pull(),o.changed=!1)}for(var r=0,a=!1,s=this._samplerSharedGroups,c=0,l=s.length;c<l;++c){var u=s[c],h=u.sampler,_=u.samplerResultCache;a=!1,h?(r=h.sample(e))<0&&((r=~r)<=0?r=0:r>=h.ratios.length?r=h.ratios.length-1:(a=!0,_.from=r-1,_.fromRatio=h.ratios[_.from],_.to=r,_.toRatio=h.ratios[_.to],r=_.from)):r=0;for(var f=u.curves,d=0,p=f.length;d<p;++d){var m=f[d];if(m.applySample(e,r,a,_,this.weight),void 0!==m.commonTargetIndex){var v=t[m.commonTargetIndex];v&&(v.changed=!0)}}}for(var g=0,y=t.length;g<y;++g){var x=t[g];x&&x.changed&&x.target.push()}},n.process=function(){var e,t=this.sample();this._allowLastFrame&&(e=this._lastWrapInfo?this._lastWrapInfo:this._lastWrapInfo=new wu(t),this.repeatCount>1&&(0|t.iterations)>(0|e.iterations)&&this.emit(uF.LASTFRAME,this),e.set(t)),t.stopped&&(this.stop(),this.emit(uF.FINISHED,this))},n.simpleProcess=function(){var e=this._playbackRange.min,t=this._playbackDuration,n=this.time%t;n<0&&(n+=t);var i=(e+n)*this._invDuration;this._sampleCurves(i),this._clip.hasEvents()&&this._sampleEvents(this.getWrappedInfo(this.time,this._wrappedInfo)),this._allowLastFrame&&(void 0===this._lastIterations&&(this._lastIterations=i),(this.time>0&&this._lastIterations>i||this.time<0&&this._lastIterations<i)&&this.emit(uF.LASTFRAME,this),this._lastIterations=i)},n.cache=function(){},n._needReverse=function(e){var t=this.wrapMode,n=!1;return(t&Eu.PingPong)===Eu.PingPong&&(e-(0|e)==0&&e>0&&(e-=1),1&e&&(n=!n)),(t&Eu.Reverse)===Eu.Reverse&&(n=!n),n},n.getWrappedInfo=function(e,t){t=t||new wu;var n=this._getPlaybackStart(),i=this._getPlaybackEnd()-n,o=!1,r=this.repeatCount,a=e>0?e/i:-e/i;if(a>=r){a=r,o=!0;var s=r-(0|r);0===s&&(s=1),e=s*i*(e>0?1:-1)}if(e>i){var c=e%i;e=0===c?i:c}else e<0&&0!=(e%=i)&&(e+=i);var l=!1,u=this._wrapMode&Eu.ShouldWrap;u&&(l=this._needReverse(a));var h=l?-1:1;return this.speed<0&&(h*=-1),u&&l&&(e=i-e),t.time=n+e,t.ratio=t.time/this.duration,t.direction=h,t.stopped=o,t.iterations=a,t},n._getPlaybackStart=function(){return this._playbackRange.min},n._getPlaybackEnd=function(){return this._playbackRange.max},n._sampleEvents=function(e){var t=this._clip.eventGroups.length,n=e.direction,i=this._clip.getEventGroupIndexAtRatio(e.ratio);if(i<0&&(i=~i-1,n<0&&(i+=1)),this._ignoreIndex!==i&&(this._ignoreIndex=-1),e.frameIndex=i,!this._lastWrapInfoEvent)return this._fireEvent(i),void(this._lastWrapInfoEvent=new wu(e));var o=this.wrapMode,r=mF(e.iterations),a=this._lastWrapInfoEvent,s=mF(a.iterations),l=a.frameIndex,u=a.direction,h=-1!==s&&r!==s;if(l===i&&h&&1===t)this._fireEvent(0);else if(l!==i||h){n=u;do{if(l!==i){if(-1===n&&0===l&&i>0?((o&Eu.PingPong)===Eu.PingPong?n*=-1:l=t,s++):1===n&&l===t-1&&i<t-1&&((o&Eu.PingPong)===Eu.PingPong?n*=-1:l=-1,s++),l===i)break;if(s>r)break}l+=n,c.director.getAnimationManager().pushDelayEvent(this._fireEvent,this,[l])}while(l!==i&&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],o=this._targetNode.components,r=le(i.events);!(n=r()).done;)for(var a,s=n.value,c=s.functionName,l=le(o);!(a=l()).done;){var u=a.value,h=u[c];"function"==typeof h&&h.apply(u,s.parameters)}}},n._onReplayOrResume=function(){c.director.getAnimationManager().addAnimation(this)},n._onPauseOrStop=function(){c.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},te(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&Eu.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&Eu.ShouldWrap,n=(this.wrapMode&Eu.Reverse)===Eu.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:"playbackRange",get:function(){return this._playbackRange},set:function(e){e.max,e.min,this._playbackRange.min=Math.max(e.min,0),this._playbackRange.max=Math.min(e.max,this.duration),this._playbackDuration=this._playbackRange.max-this._playbackRange.min,this.setTime(0)}},{key:"current",get:function(){return this.getWrappedInfo(this.time).time}},{key:"ratio",get:function(){return this.current/this.duration}},{key:"curveLoaded",get:function(){return this._curveLoaded}}]),t}(sF));function mF(e){return e-(0|e)==0&&(e-=1),0|e}c.AnimationState=pF;var vF,gF,yF,xF,EF,SF,TF,AF,wF,CF,IF,PF,bF,RF,NF,OF,DF,MF=function(e){function t(){var t;return(t=e.call(this)||this)._managedStates=[],t._fadings=[],t}ie(t,e);var n=t.prototype;return n.update=function(e){if(!this.isMotionless){var t=this._managedStates,n=this._fadings;if(1===t.length&&1===n.length){var i=t[0].state;i&&(i.weight=1)}else this._calculateWeights(e);for(var o=0;o<t.length;++o){var r=t[o].state;r&&r.isMotionless&&r.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),c.director.getAnimationManager().addCrossFade(this)},n.onPause=function(){e.prototype.onPause.call(this),c.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),c.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),c.director.getAnimationManager().removeCrossFade(this),this.clear()},n._calculateWeights=function(e){for(var t=this._managedStates,n=(this._fadings,0);n<t.length;++n){var i=t[n].state;i&&(i.weight=0)}for(var o=1,r=this._fadings.length,a=0;a<this._fadings.length;++a){var s=this._fadings[a];s.easeTime+=e;var c=0===s.easeDuration?1:hn(s.easeTime/s.easeDuration),l=c*o;if(o*=1-c,s.target.state&&(s.target.state.weight+=l),s.easeTime>=s.easeDuration){r=a+1,s.easeTime=s.easeDuration;break}}if(r!==this._fadings.length){for(var u=r;u<this._fadings.length;++u){var h=this._fadings[u];--h.target.reference,h.target.reference<=0&&(h.target.state&&h.target.state.stop(),pe(this._managedStates,h.target))}this._fadings.splice(r)}},t}(sF),LF=e("cO",(vF=L_("cc.Animation"),gF=X_(),yF=z_(99),xF=W_(),EF=hf([nF]),SF=J_(),TF=hf(nF),AF=J_(),wF=J_(),CF=hf([nF]),vF(IF=gF(IF=yF(IF=k_(IF=xF((DF=OF=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return ue(t=e.call.apply(e,[this].concat(i))||this,"playOnLoad",bF,se(t)),t._crossFade=new MF,t._nameToState=Re(!0),ue(t,"_clips",RF,se(t)),ue(t,"_defaultClip",NF,se(t)),t._hasBeenPlayed=!1,t}ie(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=Re(!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 me(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 o=this._nameToState[i];if(o.clip===e){n=o;break}}if(e===this._defaultClip){if(!t)return void b(3902);this._defaultClip=null}if(n&&n.isPlaying){if(!t)return void b(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,o){var r=e.prototype.on.call(this,t,n,i,o);return t===uF.LASTFRAME&&this._syncAllowLastFrameEvent(),r},n.once=function(t,n,i){var o=e.prototype.once.call(this,t,n,i);return t===uF.LASTFRAME&&this._syncAllowLastFrameEvent(),o},n.off=function(t,n,i){e.prototype.off.call(this,t,n,i),t===uF.LASTFRAME&&this._syncDisallowLastFrameEvent()},n._createState=function(e,t){return new pF(e,t)},n._doCreateState=function(e,t){var n=this._createState(e,t);return n._setEventTarget(this),n.allowLastFrameEvent(this.hasEventListener(uF.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];FF(e,n.clip)&&(n.stop(),delete this._nameToState[t])}},n._syncAllowLastFrameEvent=function(){if(this.hasEventListener(uF.LASTFRAME))for(var e in this._nameToState)this._nameToState[e].allowLastFrameEvent(!0)},n._syncDisallowLastFrameEvent=function(){if(!this.hasEventListener(uF.LASTFRAME))for(var e in this._nameToState)this._nameToState[e].allowLastFrameEvent(!1)},te(t,[{key:"clips",get:function(){return this._clips},set:function(e){var t=this;this._crossFade&&this._crossFade.clear();for(var n,i=le(this._clips);!(n=i()).done;){var o=n.value;o&&this._removeStateOfAutomaticClip(o)}for(var r,a=le(e);!(r=a()).done;){var s=r.value;s&&this.createState(s)}var c=e.find((function(e){return FF(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 FF(t,e)}))>=0||(this._clips.push(e),this.createState(e)))}}]),t}(Ei(lp)),OF.EventType=uF,he((PF=DF).prototype,"clips",[EF,SF],Object.getOwnPropertyDescriptor(PF.prototype,"clips"),PF.prototype),he(PF.prototype,"defaultClip",[TF,AF],Object.getOwnPropertyDescriptor(PF.prototype,"defaultClip"),PF.prototype),bF=he(PF.prototype,"playOnLoad",[H_,wF],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),RF=he(PF.prototype,"_clips",[CF],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),NF=he(PF.prototype,"_defaultClip",[H_],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),IF=PF))||IF)||IF)||IF)||IF)||IF));function FF(e,t){return e===t||!!e&&!!t&&e._uuid===t._uuid&&e._uuid}q(LF.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 LF.prototype.removeState.call(this,e.name)}}]),c.AnimationComponent=LF,at.setClassAlias(LF,"cc.AnimationComponent");var zF,BF,UF,HF=[],GF=new Map;function VF(e,t){for(var n=0,i=jn.IDENTITY;e;){if(e.stamp===t||e.stamp+1===t&&!e.node.hasChangedFlags){i=e.world,e.stamp=t;break}e.stamp=t,HF[n++]=e,e=e.parent}for(;n>0;){var o=(e=HF[--n]).node;jn.fromRTS(e.local,o.rotation,o.position,o.scale),i=jn.multiply(e.world,i,e.local)}return i}function kF(e,t){for(var n,i=null,o=0;e!==t;){var r=e.uuid;if(GF.has(r)){i=GF.get(r);break}i={node:e,local:new jn,world:new jn,stamp:-1,parent:null},GF.set(r,i),HF[o++]=i,e=e.parent,i=null}for(;o>0;)(n=HF[--o]).parent=i,i=n;return i}function WF(e){for(var t=GF.get(e.uuid)||null;t;)GF.delete(t.node.uuid),t=t.parent}var jF=e("g7",L_((UF=BF=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return(t=e.call.apply(e,[this].concat(i))||this)._anims=new _e([]),t._delayEvents=[],t._blendStateBuffer=new cF,t._crossFades=[],t._sockets=[],t}ie(t,e);var n=t.prototype;return n.addCrossFade=function(e){this._crossFades.push(e)},n.removeCrossFade=function(e){pe(this._crossFades,e)},n.update=function(e){for(var t=this._delayEvents,n=this._crossFades,i=this._sockets,o=0,r=n.length;o<r;o++)n[o].update(e);var a=this._anims,s=a.array;for(a.i=0;a.i<s.length;++a.i){var l=s[a.i];l.isMotionless||l.update(e)}this._blendStateBuffer.apply();for(var u=c.director.getTotalFrames(),h=0,_=i.length;h<_;h++){var f=i[h],d=f.target,p=f.transform;d.matrix=VF(p,u)}for(var m=0,v=t.length;m<v;m++){var g=t[m];g.fn.apply(g.thisArg,g.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):N(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 o=t[i];if(n._sockets.find((function(e){return e.target===o.target})))return"continue";var r=e.getChildByPath(o.path),a=o.target&&r&&kF(r,e);a&&n._sockets.push({target:o.target,transform:a})},o=0;o<t.length;++o)i(o)},n.removeSockets=function(e,t){for(var n=0;n<t.length;++n)for(var i=t[n],o=0;o<this._sockets.length;++o){var r=this._sockets[o];if(r.target===i.target){WF(r.transform.node),this._sockets[o]=this._sockets[this._sockets.length-1],this._sockets.length--;break}}},te(t,[{key:"blendState",get:function(){return this._blendStateBuffer}}]),t}(mI),BF.ID="animation",zF=UF))||zF);LN.on(MN.EVENT_INIT,(function(){var e=new jF;LN.registerSystem(jF.ID,e,SI.PRIORITY_SYSTEM)})),c.AnimationManager=jF;var qF,YF,XF,KF,QF=new jn;c.easing=fI;var ZF=e("fU",L_("cc.HierachyModifier")(qF=function(e){function t(){return e.apply(this,arguments)||this}return ie(t,e),t}(iL))||qF);c.HierachyModifier=ZF;var JF=e("fV",L_("cc.ComponentModifier")(YF=function(e){function t(){return e.apply(this,arguments)||this}return ie(t,e),t}(oL))||YF);c.ComponentModifier=JF;var $F=e("fW",L_("cc.CurveValueAdapter")(XF=function(){function e(){}return e.prototype.forTarget=function(){return{set:function(){}}},e}())||XF);c.CurveValueAdapter=$F;var ez=e("fX",L_("cc.UniformCurveValueAdapter")(KF=function(e){function t(){return e.apply(this,arguments)||this}return ie(t,e),t}(vL))||KF);function tz(e){return"string"==typeof e}function nz(e){return"number"==typeof e}function iz(e,t){return e instanceof t}c.UniformCurveValueAdapter=ez,c.isPropertyModifier=tz,c.isElementModifier=nz,c.isCustomTargetModifier=iz,c.math=ai,c.geometry=Hu;var oz=e("g9",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 o=this._pool[i];this._pool.length=i;var r=this.poolHandlerComp?o.getComponent(this.poolHandlerComp):null;return r&&r.reuse&&r.reuse(arguments),o},e}());c.NodePool=oz,c.renderer=LC;var rz=new URL("assets/ammo.wasm-2f572f72.wasm",t.meta.url).href;let az,sz=!1;"undefined"==typeof WebAssembly?az=await t.import("./ammo-823cde4b.js"):(az=await t.import("./ammo.wasm-0444094c.js"),sz=!0);var cz,lz=az.default,uz=e("e3",{});function hz(e){var t={};return void 0!==e&&(uz.wasmBinary=e),new Promise((function(e){lz.call(t,uz).then((function(){e()}))}))}(cz=hz||(hz=e("ga",{}))).isWasm=sz,cz.wasmBinaryURL=rz}}}));
|