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,b9:KM,bC:k,bD:G,bE:function(){},bN:he,bO:ue,bP:se,bR:Rc,bU:ct,bV:function(e){return U_(V_({formerlySerializedAs:e}))},bX:hf,bZ:void 0,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(){},c:void 0,c7: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;h0&&(Z=e)},eZ:Ny,e_:Oy,ek:ae,el:pe,em:U_,en:Ct,eo:It,ep:L,er:Gi,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("dn",!1),o=e("ed",!1),r=e("eb",!1),a=e("ec",!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("cT","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;o1?t-1:0),i=1;i1?t-1:0),i=1;i1?t-1:0),i=1;i1?t-1:0),i=1;i2?n-2:0),o=2;oO.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;o2?i-2:0),r=2;r1?n-1:0),o=1;o1?n-1:0),o=1;o1?t-1:0),i=1;i2?n-2:0),o=2;o1?t-1:0),i=1;i1?t-1:0),i=1;i1?i-1:0),r=1;r1?t-1:0),i=1;i1?t-1:0),i=1;i1?t-1:0),i=1;i2?n-2:0),o=2;o1?t-1:0),i=1;i0)-(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<>31;return(e^t)-t},min:function(e,t){return t^(e^t)&-(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;ne.length)&&(t=e.length);for(var n=0,i=new Array(t);n=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("cp",(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("cI",(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("cJ",(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;n1?t-1:0),i=1;i1?t-1:0),i=1;i1?t-1:0),i=1;i0){--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=0&&(this._pool.length=e,this.count>e&&(this.count=e))},t}()),rt=e("ei",ve),at=e("cq",{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;in){var i=t;t=n,n=i}return e=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("dJ",new Mt("Boolean",!1));c.Boolean=zt,c.CCBoolean=zt;var Bt=e("cU",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;t0?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=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;on){var i=t;t=n,n=i}return en?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("dt",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("cF",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("bI",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)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).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("cf",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("ct",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)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)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("cs",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)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("c0",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)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.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;nthis._data.length)for(var t=this._data.length;t=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=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("cQ",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=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;r0}for(var a=0;a1)&&(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-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;i0&&(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<>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=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]?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_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("dG",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;i0&&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>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=0){var s=this._colorInfos[n.depthStencil];e+="ds,"+s.format+","+s.sampleCount}}else{e+="ca";for(var c=0;c-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),_=cp?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()=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;ao.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;fo.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;xo.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;lh)&&(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_)&&(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=ri?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+nt.d?0:1},Ul=function(e,t){for(var n=0;ni.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;ui.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;hi.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)t.d?0:1}),kl=function(e,t){for(var n=0;no.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;_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;fo.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+it.d?0:1},Xl=function(e,t){for(var n=0;nl)){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)1?Rn.squaredDistance(n.center,i.ellipseCenter1)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)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("bK",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("dl",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[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&&tthis.keyFrames[n].time)for(var i=0;i<3;i++){var o=n+i;if(o+1t)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("cd",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<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("dY",{})));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("e8",{})));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("e7",(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("dd",(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("d5",(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("df","a_jointAnimInfo"),Hh=e("db",(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("by",(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("de",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("bH",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("bG",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("bF",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("bZ",{}))),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;ithis.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>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("ef",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("bM",L_("cc.Asset")((Hf=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o0&&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("dh",{}))),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("dp",{}))),function(e){e[e.NONE=ka.NONE]="NONE",e[e.LINEAR=ka.LINEAR]="LINEAR",e[e.NEAREST=ka.POINT]="NEAREST"}(qf||(qf=e("dg",{})));var $f,ed=e("bz",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=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>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("bB",new gd);c.samplerLib=yd;var xd=new ge("Tex"),Ed=e("dR",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=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=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=0?a[n[c]]=s:a[~c]=s}for(;o=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=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=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>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("bA",(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=this._mipmaps.length))for(var n=Math.min(void 0===t?this._mipmaps.length:t,this._mipmaps.length-e),i=0;i"},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;o0){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=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;r0){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;o31&&(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>2)*s.count}for(var c=0;c 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>2,a=this._blocks[i],s=e.getOffsetFromHandle(t),c=0;c>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;e15e3&&(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("cV",{})));var Em=e("c_",(function(e){return 4*Math.PI*Math.PI*e*e})),Sm=e("cW",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("cY",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;n0&&(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;o0){var o=e.children;if(o)for(var r=0;r=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;o0)for(var r=e.children,a=0,s=r?r.length:0;a=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=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;i0&&-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;a0&&(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=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;o0&&(r=n._findChildComponent(o._children,t)))return r}return null},n._findChildComponents=function(e,t,i){for(var o=0;o0&&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;n0?(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;t0},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;c0)for(var c=0;c=0&&r.node._components.splice(a,1)}}}function Dv(e,t,n){if(!(t.length<=0))for(var i=null,o=0;o0){var c=s.pop();if(!c)continue;for(var l=0;l0){var v=p.pop();if(!v)return;for(var g=0;g=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;o0){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;i0){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=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;rXy){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<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("dV",(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("ce",($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._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=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;t0},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;um.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=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;gthis._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;aAE.length&&AE.push(r)}return AE}(e,n.maxReceived);if(0!==o.length){for(var a=0;a0){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("dU",function(e){function t(){for(var t,n=arguments.length,i=new Array(n),o=0;o2||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;r0&&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;a8)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("dc",{})));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("bT",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=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;t1?xC:yC),o=this._subModels,r=0;r=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("cZ",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("c$",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("d4",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=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;t0&&(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;an.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<>>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("cS",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=ri.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("cR",function(){function e(){this._id="",this._priority=0,this._executeInEditMode=!1}e.sortByPriority=function(e,t){return e._priorityt.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=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=0;t--)n=o[t],this.unscheduleAllForTarget(n.target);var r=0;if(e<0)for(t=0;t=e&&this.unscheduleUpdate(i.target),r===this._updatesNegList.length&&t++;if(e<=0)for(t=0;t=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=e&&(o.paused=!0,r.push(o.target));if(e<=0)for(n=0;n=e&&(o.paused=!0,r.push(o.target));return r},n.resumeTargets=function(e){if(e)for(var t=0;t=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;ethis._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;i1&&(this._fps=this._frameCount,this._frameCount=0,this._fpsTime=0);for(var t=0;t0){this._device.acquire();var r=this._scenes,a=c.director.getTotalFrames();this._batcher&&this._batcher.uploadBuffers();for(var s=0;s0?(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>3},i=n.storageUnit,o=YI(n.elementType),r=new(XI(i))(e,this._byteOffset,this._unitCount),a=new Array(this._length),s=0;so.x?n[c]:o.x,o.y=n[c+1]>o.y?n[c+1]:o.y,r.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]0?i:null}return null}function vP(e,t){if(!e._persistNode){if(e.eventProcessor.bubblingTargets)for(var n=0;n=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>>1;o<=r;a=o+r>>>1){var s=e[a],c=s.constructor._executionOrder;if(c>n)r=a-1;else if(ci)r=a-1;else{if(!(l0&&(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=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;tthis._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;ot.length)||47===e.charCodeAt(t.length)}(o,e)||!e)for(var r=0,a=n.length;r0&&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;othis._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._totalNum0&&(Tt(this._handleQueue.bind(this),e,t),this._checkNextPeriod=!0)},te(e,[{key:"remoteServerAddress",get:function(){return this._remoteServerAddress}}]),e}(),dO=e("ck",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;a0){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;n6||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;o1){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;t1?n-1:0),o=1;o=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;t0)this._materials.length=e.length,this._materialInstances.length=e.length;else if(t<0)for(var n=this._materials.length-t;n1}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>>1;i<=o;r=i+o>>>1){var a=e[r];if(a>t+n)o=r-1;else{if(!(a1?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;o1e-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=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(to)return n;var r=(t=(t-i)/(o-i))/(1/n),a=0|r,s=1e-6;return r-a0){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;ui.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;_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("di",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;n0&&(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=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;d1&&(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._lastIterations0&&(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&&ir)break}l+=n,c.director.getAnimationManager().pushDelayEvent(this._fireEvent,this,[l])}while(l!==i&&l>-1&&l=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=s.easeDuration){r=a+1,s.easeTime=s.easeDuration;break}}if(r!==this._fadings.length){for(var u=r;u=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=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