System.register([],(function(e,t){"use strict";return{execute:function(){function n(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 i(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 r(e){return--e,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,1+(e|=e>>>16)}e({BitMask:nt,CCClass:Qt,CacheMode:void 0,DebugMode:void 0,ECollider2DType:void 0,EJoint2DType:void 0,EPhysics2DDrawFlags:void 0,ERaycast2DType:void 0,ERigidBody2DType:void 0,Enum:it,Eventify:Ql,ExtrapolationMode:void 0,HorizontalTextAlignment:void 0,InstanceMaterialType:void 0,KeyCode:void 0,Overflow:void 0,Physics2DManifoldType:void 0,PhysicsGroup:void 0,PipelineEventType:void 0,QuatInterpolationMode:void 0,RealInterpolationMode:void 0,SystemEventType:void 0,TangentWeightMode:void 0,VerticalTextAlignment:void 0,WorldNode3DToLocalNodeUI:Tb,WorldNode3DToWorldNodeUI:Eb,absMax:Sn,absMaxComponent:xn,approx:rn,assert:S,assertID:N,bezier:P_,bezierByTime:X_,ccenum:at,clamp:on,clamp01:an,color:Cn,computeRatioByType:ok,createDefaultPipeline:SM,debug:T,deserialize:Oh,earcut:dQ,enumerableProps:Tn,equals:nn,error:x,errorID:D,find:gD,fragmentText:GH,getBaselineOffset:function(){return 0},getError:L,getPathFromRoot:function(e,t){for(var n=e,i="";null!==n&&n!==t;)i=n.name+"/"+i,n=n.parent;return i.slice(0,-1)},getSerializationMetadata:function(e){return e[mc]},getWorldTransformUntilRoot:LG,instantiate:Kh,inverseLerp:yn,isCustomTargetModifier:HG,isDisplayStats:F,isElementModifier:GG,isPropertyModifier:UG,isUnicodeCJK:BH,isUnicodeSpace:zH,isValid:fl,lerp:sn,log:v,logID:w,markAsWarning:void 0,mat4:jn,murmurhash2_32_gc:po,nextPow2:mn,pingPong:vn,pseudoRandom:_n,pseudoRandomRange:pn,pseudoRandomRangeInt:dn,quat:kn,randomRange:hn,randomRangeInt:fn,rect:ti,removeProperty:void 0,repeat:gn,replaceProperty:void 0,safeMeasureText:kH,sampleAnimationCurve:rk,setDefaultLogTimes:function(e){e>0&&(W=e)},setDisplayStats:B,size:$n,toDegree:ln,toRadian:cn,tween:_ue,tweenUtil:pue,v2:Yn,v3:Pn,v4:Qn,warn:y,warnID:P});var o=new Array(256);!function(e){for(var t=0;t<256;++t){var n=t,i=t,r=7;for(n>>>=1;n;n>>>=1)i<<=1,i|=1&n,--r;e[t]=i<0)-(e<0)},abs:function(e){var t=e>>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:i,nextPow2:r,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 o[255&e]<<24|o[e>>>8&255]<<16|o[e>>>16&255]<<8|o[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>>>i(e)+1}});e("bits",a);var s="undefined"==typeof window?global:window,c=e("cclegacy",{_global:s});c.internal={},s.CC_BUILD=!0,s.CC_TEST=!1,s.CC_EDITOR=false,s.CC_PREVIEW=!1,s.CC_DEV=!1,s.CC_DEBUG=!1,s.CC_JSB=!1,s.CC_BYTEDANCE=!1,s.CC_WECHAT=!1,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=!1,s.CC_RUNTIME_BASED=!1,s.CC_SUPPORT_JIT=!0;var l=e("VERSION","3.4.2");s.CocosEngine=c.ENGINE_VERSION=l,s.cc=c;var u="https://github.com/cocos-creator/engine/blob/develop/EngineErrorMap.md",h=null,f=console.log.bind(console),_=f,p=f,d=function(e,t){if(!e){for(var n=arguments.length,i=new Array(n>2?n-2:0),r=2;r1?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),r=2;rO.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}};p=function(e){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r2?i-2:0),o=2;o1?n-1:0),r=1;r1?n-1:0),r=1;r1?t-1:0),i=1;i2?n-2:0),r=2;r1?t-1:0),i=1;i1?t-1:0),i=1;i1?i-1:0),o=1;o1?t-1:0),i=1;i1?t-1:0),i=1;i1?t-1:0),i=1;i2?n-2:0),r=2;r1?t-1:0),i=1;ie.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 ae(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 se(e,t,n,i,r){var o={};return Object.keys(i).forEach((function(e){o[e]=i[e]})),o.enumerable=!!o.enumerable,o.configurable=!!o.configurable,("value"in o||o.initializer)&&(o.writable=!0),o=n.slice().reverse().reduce((function(n,i){return i(e,t,n)||n}),o),r&&void 0!==o.initializer&&(o.value=o.initializer?o.initializer.call(r):void 0,o.initializer=void 0),void 0===o.initializer&&(Object.defineProperty(e,t,o),o=null),o}G=function(e,t,n,i,r,o,a){var s=X.get(o);s&&s.logTimes>s.count&&(r("'%s' is deprecated, please use '%s' instead. "+a,e+"."+t,n+"."+i),s.count++)},z=e("replaceProperty",(function(e,t,n){null!=e&&n.forEach((function(n){var i=q++;X.set(i,{id:i,count:0,logTimes:void 0!==n.logTimes?n.logTimes:W});var r=null!=n.target?n.target:e,o=null!=n.newName?n.newName:n.name,a=null!=n.targetName?n.targetName:t,s=r===e,c=n.suggest?"("+n.suggest+")":"";if(null!=n.customFunction)e[n.name]=function(){var e;return G(t,n.name,a,o,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 G(t,n.name,a,o,y,i,c),n.customGetter.call(this)},set:function(e){G(t,n.name,a,o,y,i,c),n.customSetter.call(this,e)},enumerable:!1}):l?Object.defineProperty(e,n.name,{set:function(e){G(t,n.name,a,o,y,i,c),n.customSetter.call(this,e)},enumerable:!1}):u&&Object.defineProperty(e,n.name,{get:function(){return G(t,n.name,a,o,y,i,c),n.customGetter.call(this)},enumerable:!1})}else Object.defineProperty(e,n.name,{get:function(){return G(t,n.name,a,o,y,i,c),s?this[o]:r[o]},set:function(e){G(t,n.name,a,o,y,i,c),s?this[o]=e:r[o]=e},enumerable:!1})}))})),V=function(e,t,n,i,r){var o=X.get(i);o&&o.logTimes>o.count&&(n("'%s' has been removed. "+r,e+"."+t),o.count++)},k=e("removeProperty",(function(e,t,n){null!=e&&n.forEach((function(n){var i=q++;X.set(i,{id:i,count:0,logTimes:void 0!==n.logTimes?n.logTimes:W});var r=n.suggest?"("+n.suggest+")":"";Object.defineProperty(e,n.name,{get:function(){return V(t,n.name,x,i,r)},set:function(){V(t,n.name,x,i,r)},enumerable:!1})}))})),H=function(e,t,n,i,r){var o=X.get(i);o&&o.logTimes>o.count&&(n("'%s' is deprecated. "+r,e+"."+t),o.count++)},U=e("markAsWarning",(function(e,t,n){null!=e&&n.forEach((function(n){var i=n.name,r=Object.getOwnPropertyDescriptor(e,i);if(r&&r.configurable){var o=q++;X.set(o,{id:o,count:0,logTimes:void 0!==n.logTimes?n.logTimes:W});var a=n.suggest?"("+n.suggest+")":"";if(void 0!==r.value)if("function"==typeof r.value){var s=r.value;e[i]=function(){return H(t,i,y,o,a),s.call.apply(s,[this].concat(Array.prototype.slice.call(arguments)))}}else{var c=r.value;Object.defineProperty(e,i,{configurable:!0,get:function(){return H(t,i,y,o,a),c}}),r.writable&&Object.defineProperty(e,i,{set:function(e){H(t,i,y,o,a),c=e}})}else!function(t,n,i,r,o,a){if(t.get){var s=t.get;t.get=function(){return H(n,i,r,o,a),s.call(this)}}if(t.set){var c=t.set;t.set=function(e){H(n,i,r,o,a),c.call(this,e)}}Object.defineProperty(e,i,t)}(r,t,i,y,o,a);Object.defineProperty(e,i,{enumerable:!1})}}))}));var ce=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)},K(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 le(e,t){e.splice(t,1)}function ue(e,t){var n=e.length;t<0||t>=n||(e[t]=e[n-1],e.length=n-1)}function he(e,t){var n=e.indexOf(t);return n>=0&&(le(e,n),!0)}function fe(e,t){return e.indexOf(t)>=0}var _e=Object.freeze({__proto__:null,removeAt:le,fastRemoveAt:ue,remove:he,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 le(e,n),i}},verifyType:function(e,t){if(e&&e.length>0)for(var n,i=oe(e);!(n=i()).done;)if(!(n.value instanceof t))return w(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}(),et=_e,tt={IDGenerator:pe,Pool:$e,array:_e,isNumber:ve,isString:ye,isEmptyObject:xe,getPropertyDescriptor:Ne,addon:Fe,mixin:Be,extend:ze,getSuper:ke,isChildClassOf:Ue,clear:Ge,value:Te,getset:Ee,get:Ae,set:Ce,unregisterClass:Ke,getClassName:we,setClassName:Xe,setClassAlias:Ye,getClassByName:Ze,get _registeredClassNames(){return Q({},Ve)},set _registeredClassNames(e){Ge(Ve),Object.assign(Ve,e)},get _registeredClassIds(){return Q({},He)},set _registeredClassIds(e){Ge(He),Object.assign(He,e)},_getClassId:Je,_setClassId:We,_getClassById:Qe,obsolete:Re,obsoletes:Pe,formatStr:Oe,shiftArguments:Me,createMap:be};function nt(e){if("__bitmask__"in e)return e;Te(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 r=n[i];r.hasOwnProperty("__attrs__")&&r.__attrs__||At(r,(t=n[i+1])&&t.__attrs__)}return At(e,(t=n[0])&&t.__attrs__),e.__attrs__}function bt(e,t){var n=wt(e),i=t+Et,r={};for(var o in n)o.startsWith(i)&&(r[o.slice(i.length)]=n[o]);return r}function wt(e){return e.hasOwnProperty("__attrs__")&&e.__attrs__||Ct(e)}function Rt(e,t,n,i){wt(e)[t+Et+n]=i}var Pt=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}(),It=e("CCInteger",new Pt("Integer",0));c.Integer=It,c.CCInteger=It;var Dt=e("CCFloat",new Pt("Float",0));c.Float=Dt,c.CCFloat=Dt;var Ot=e("CCBoolean",new Pt("Boolean",!1));c.Boolean=Ot,c.CCBoolean=Ot;var Mt=e("CCString",new Pt("String",""));function Nt(e,t){return function(n,i){var r='"'+we(n)+"."+i+'"',o=bt(n,i),a=o.type;if(a===It||a===Dt?a="Number":a!==Mt&&a!==Ot||(a=""+a),a===e){if(o.hasOwnProperty("default")){var s=o.default;if(void 0!==s&&!Array.isArray(s)&&!yt(s)){var c=typeof s,l=e.toLowerCase();if(c===l)if("object"===l){if(!s||s instanceof o.ctor)return;P(3605,r,we(o.ctor))}else"Number"!==e&&P(3606,t,r,e);else{if("function"===c)return;e===Mt.default&&null==s?P(3607,r):P(3611,t,r,c)}delete o.type}}}else P(3604,r)}}c.String=Mt,c.CCString=Mt;var Lt=Object.freeze({__proto__:null,DELIMETER:Et,createAttrsSingle:At,createAttrs:Ct,attr:bt,getClassAttrs:wt,setClassAttr:Rt,PrimitiveType:Pt,CCInteger:It,CCFloat:Dt,CCBoolean:Ot,CCString:Mt,getTypeChecker_ET:Nt,getObjTypeChecker_ET:function(e){return function(t,n){Nt("Object","type")(t,n);var i=wt(t)[n+Et+"default"],r=c.Class.getDefault(i);if(!Array.isArray(r)&&Ue(e,c.ValueType)){var o=we(e),a=Oe('No need to specify the "type" of "%s.%s" because %s is a child class of ValueType.',we(t),n,o);i?v(a):P(3612,a,o,we(t),n,o)}}}}),Ft={default:{},serializable:{},editorOnly:{},formerlySerializedAs:{}};function Bt(e,t,n,i){if(!e.get&&!e.set&&e.hasOwnProperty("default")){var r="_N$"+t;e.get=function(){return this[r]},e.set=function(e){var t=this[r];this[r]=e,n.call(this,t)};var o={};for(var a in i[r]=o,Ft){var s=Ft[a];e.hasOwnProperty(a)&&(o[a]=e[a],s.canUsedInGet||delete e[a])}}}function zt(e,t,n,i){if(Array.isArray(t)){if(!(t.length>0))return D(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 kt(e,t,n){var i=e?{_short:!0}:{_short:!0,default:t};return n&&(i.type=n),i}function Ut(e,t){if(!e||e.constructor!==Object){if(Array.isArray(e)&&e.length>0)return kt(t,[],e);if("function"==typeof e){var n=e;return kt(t,Ue(n,c.ValueType)?new n:null,n)}return kt(t,e instanceof Pt?e.default:e)}return null}var Gt=[];function Ht(){return Gt[Gt.length-1]}c._RF={push:function(e,t,n,i){void 0===n&&(n=t,t=""),Gt.push({uuid:t,script:n,module:e,exports:e.exports,beh:null,importMeta:i})},pop:function(){var e=Gt.pop(),t=e.module,n=t.exports;if(n===e.exports){for(var i in n)return;t.exports=n=e.cls}},peek:Ht};var Vt=Et,jt={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?o: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];Yt(s,l.prototype),Qt._isCCClass(l)&&Yt(wt(a),wt(l))}s.constructor=a}return Xe(e,a),a}(e,t,n,i);if(o)if(Ue(t,r)){var s=o.uuid;s&&We(s,a),o.cls=a}else Ue(o.cls,r)||(o.cls=a);return a}(t,n,i,e);t||(t=c.js.getClassName(r)),r._sealed=!0,n&&(n._sealed=!1);var o=e.properties;"function"==typeof o||n&&null===n.__props__||i&&i.some((function(e){return null===e.__props__}))?(jt.push({cls:r,props:o,mixins:i}),r.__props__=r.__values__=null):Kt(r,t,o,n,e.mixins);var a=e.editor;return a&&Ue(n,c.Component)&&c.Component._registerEditorProps(r,a),r}Qt._isCCClass=function(e){var t;return null==e||null===(t=e.hasOwnProperty)||void 0===t?void 0:t.call(e,"__ctors__")},Qt.fastDefine=function(e,t,n){Xe(e,t);for(var i=t.__props__=t.__values__=Object.keys(n),r=wt(t),o=0;o=2&&((r||a())[o+"min"]=u[0],r[o+"max"]=u[1],u.length>2&&(r[o+"step"]=u[2])),l("min","number"),l("max","number"),l("step","number")}Qt.isArray=function(e){return e=Xt(e),Array.isArray(e)},Qt.getDefault=Xt,Qt.escapeForJS=function(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")},Qt.IDENTIFIER_RE=/^[A-Za-z_$][0-9A-Za-z_$]*$/,Qt.getNewValueTypeCode=function(e){for(var t=we(e),n=e.constructor,i="new "+t+"(",r=0;rn){var i=t;t=n,n=i}return en?n:e}function an(e){return e<0?0:e>1?1:e}function sn(e,t,n){return e+(t-e)*n}function cn(e){return e*$t}function ln(e){return e*en}var un=e("random",Math.random);function hn(e,t){return Math.random()*(t-e)+e}function fn(e,t){return Math.floor(hn(e,t))}function _n(e){return(e=(9301*e+49297)%233280)/233280}function pn(e,t,n){return _n(e)*(n-t)+t}function dn(e,t,n){return Math.floor(pn(e,t,n))}function mn(e){return--e,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e}function gn(e,t){return e-Math.floor(e/t)*t}function vn(e,t){return e=gn(e,2*t),t-Math.abs(e-t)}function yn(e,t,n){return(n-e)/(t-e)}function xn(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 Sn(e,t){return Math.abs(e)>Math.abs(t)?e:t}function Tn(e,t){t.forEach((function(t){Object.defineProperty(e,t,{enumerable:!0})}))}var En=1/255,An=e("Color",function(e){function t(t,n,i,r){var o;return(o=e.call(this)||this)._val=0,"string"==typeof t?o.fromHEX(t):void 0!==n?o.set(t,n,i,r):o.set(t),o}Z(t,e),t.clone=function(e){var n=new t;return e._val?n._val=e._val:n._val=(e.a<<24>>>0)+(e.b<<16)+(e.g<<8)+e.r,n},t.copy=function(e,t){return e.r=t.r,e.g=t.g,e.b=t.b,e.a=t.a,e},t.set=function(e,t,n,i,r){return e.r=t,e.g=n,e.b=i,e.a=r,e},t.fromHEX=function(e,t){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;var n=parseInt(t.substr(6,2),16);return e.a=Number.isNaN(n)?255:n,e._val=(e.a<<24>>>0)+(e.b<<16)+(e.g<<8)+e.r,e},t.add=function(e,t,n){return e.r=t.r+n.r,e.g=t.g+n.g,e.b=t.b+n.b,e.a=t.a+n.a,e},t.subtract=function(e,t,n){return e.r=t.r-n.r,e.g=t.g-n.g,e.b=t.b-n.b,e.a=t.a-n.a,e},t.multiply=function(e,t,n){return e.r=t.r*n.r,e.g=t.g*n.g,e.b=t.b*n.b,e.a=t.a*n.a,e},t.divide=function(e,t,n){return e.r=t.r/n.r,e.g=t.g/n.g,e.b=t.b/n.b,e.a=t.a/n.a,e},t.scale=function(e,t,n){return e.r=t.r*n,e.g=t.g*n,e.b=t.b*n,e.a=t.a*n,e},t.lerp=function(e,t,n,i){var r=t.r,o=t.g,a=t.b,s=t.a;return r+=(n.r-r)*i,o+=(n.g-o)*i,a+=(n.b-a)*i,s+=(n.a-s)*i,e._val=Math.floor((s<<24>>>0)+(a<<16)+(o<<8)+r),e},t.toArray=function(e,n,i){void 0===i&&(i=0);var r=n instanceof t||n.a>1?1/255:1;return e[i+0]=n.r*r,e[i+1]=n.g*r,e[i+2]=n.b*r,e[i+3]=n.a*r,e},t.fromArray=function(e,t,n){return void 0===n&&(n=0),t.r=255*e[n+0],t.g=255*e[n+1],t.b=255*e[n+2],t.a=255*e[n+3],t},t.strictEquals=function(e,t){return e.r===t.r&&e.g===t.g&&e.b===t.b&&e.a===t.a},t.equals=function(e,t,n){return void 0===n&&(n=tn),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,r=this.b,o=this.a;return n+=(e.r-n)*t,i+=(e.g-i)*t,r+=(e.b-r)*t,o+=(e.a-o)*t,this._val=Math.floor((o<<24>>>0)+(r<<16)+(i<<8)+n),this},n.toString=function(){return"rgba("+this.r.toFixed()+", "+this.g.toFixed()+", "+this.b.toFixed()+", "+this.a.toFixed()+")"},n.toCSS=function(e){return void 0===e&&(e="rgba"),"rgba"===e?"rgba("+this.r+","+this.g+","+this.b+","+(this.a*En).toFixed(2)+")":"rgb"===e?"rgb("+this.r+","+this.g+","+this.b+")":"#"+this.toHEX(e)},n.fromHEX=function(e){e=0===e.indexOf("#")?e.substring(1):e;var t=parseInt(e.substr(0,2),16)||0,n=parseInt(e.substr(2,2),16)||0,i=parseInt(e.substr(4,2),16)||0,r=parseInt(e.substr(6,2),16);return r=Number.isNaN(r)?255:r,this._val=(r<<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,r=0,o=0;if(0===t)i=r=o=n;else if(0===n)i=r=o=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,r=u,o=c;break;case 1:i=l,r=n,o=c;break;case 2:i=c,r=n,o=u;break;case 3:i=c,r=l,o=n;break;case 4:i=u,r=c,o=n;break;case 5:i=n,r=c,o=l}}return i*=255,r*=255,o*=255,this._val=(this.a<<24>>>0)+(o<<16)+(r<<8)+(0|i),this},n.toHSV=function(){var e=this.r*En,t=this.g*En,n=this.b*En,i={h:0,s:0,v:0},r=Math.max(e,t,n),o=Math.min(e,t,n),a=0;return i.v=r,i.s=r?(r-o)/r:0,i.s?(a=r-o,i.h=e===r?(t-n)/a:t===r?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,r=((4278190080&this._val)>>>8)*e.a;return this._val=4278190080&r|16711680&i|65280&n|255&t,this},n._set_r_unsafe=function(e){return this._val=(4294967040&this._val|e)>>>0,this},n._set_g_unsafe=function(e){return this._val=(4294902015&this._val|e<<8)>>>0,this},n._set_b_unsafe=function(e){return this._val=(4278255615&this._val|e<<16)>>>0,this},n._set_a_unsafe=function(e){return this._val=(16777215&this._val|e<<24)>>>0,this},K(t,[{key:"r",get:function(){return 255&this._val},set:function(e){e=~~on(e,0,255),this._val=(4294967040&this._val|e)>>>0}},{key:"g",get:function(){return(65280&this._val)>>8},set:function(e){e=~~on(e,0,255),this._val=(4294902015&this._val|e<<8)>>>0}},{key:"b",get:function(){return(16711680&this._val)>>16},set:function(e){e=~~on(e,0,255),this._val=(4278255615&this._val|e<<16)>>>0}},{key:"a",get:function(){return(4278190080&this._val)>>>24},set:function(e){e=~~on(e,0,255),this._val=(16777215&this._val|e<<24)>>>0}},{key:"x",get:function(){return this.r*En},set:function(e){this.r=255*e}},{key:"y",get:function(){return this.g*En},set:function(e){this.g=255*e}},{key:"z",get:function(){return this.b*En},set:function(e){this.b=255*e}},{key:"w",get:function(){return this.a*En},set:function(e){this.a=255*e}}]),t}(st));function Cn(e,t,n,i){return new An(e,t,n,i)}An.WHITE=Object.freeze(new An(255,255,255,255)),An.GRAY=Object.freeze(new An(127,127,127,255)),An.BLACK=Object.freeze(new An(0,0,0,255)),An.TRANSPARENT=Object.freeze(new An(0,0,0,0)),An.RED=Object.freeze(new An(255,0,0,255)),An.GREEN=Object.freeze(new An(0,255,0,255)),An.BLUE=Object.freeze(new An(0,0,255,255)),An.CYAN=Object.freeze(new An(0,255,255,255)),An.MAGENTA=Object.freeze(new An(255,0,255,255)),An.YELLOW=Object.freeze(new An(255,255,0,255)),Qt.fastDefine("cc.Color",An,{r:0,g:0,b:0,a:255}),c.Color=An,c.color=Cn;var bn=e("Vec3",function(e){function t(t,n,i){var r;return r=e.call(this)||this,t&&"object"==typeof t?(r.x=t.x,r.y=t.y,r.z=t.z):(r.x=t||0,r.y=n||0,r.z=i||0),r}Z(t,e),t.zero=function(e){return e.x=0,e.y=0,e.z=0,e},t.clone=function(e){return new t(e.x,e.y,e.z)},t.copy=function(e,t){return e.x=t.x,e.y=t.y,e.z=t.z,e},t.set=function(e,t,n,i){return e.x=t,e.y=n,e.z=i,e},t.add=function(e,t,n){return e.x=t.x+n.x,e.y=t.y+n.y,e.z=t.z+n.z,e},t.subtract=function(e,t,n){return e.x=t.x-n.x,e.y=t.y-n.y,e.z=t.z-n.z,e},t.multiply=function(e,t,n){return e.x=t.x*n.x,e.y=t.y*n.y,e.z=t.z*n.z,e},t.divide=function(e,t,n){return e.x=t.x/n.x,e.y=t.y/n.y,e.z=t.z/n.z,e},t.ceil=function(e,t){return e.x=Math.ceil(t.x),e.y=Math.ceil(t.y),e.z=Math.ceil(t.z),e},t.floor=function(e,t){return e.x=Math.floor(t.x),e.y=Math.floor(t.y),e.z=Math.floor(t.z),e},t.min=function(e,t,n){return e.x=Math.min(t.x,n.x),e.y=Math.min(t.y,n.y),e.z=Math.min(t.z,n.z),e},t.max=function(e,t,n){return e.x=Math.max(t.x,n.x),e.y=Math.max(t.y,n.y),e.z=Math.max(t.z,n.z),e},t.round=function(e,t){return e.x=Math.round(t.x),e.y=Math.round(t.y),e.z=Math.round(t.z),e},t.multiplyScalar=function(e,t,n){return e.x=t.x*n,e.y=t.y*n,e.z=t.z*n,e},t.scaleAndAdd=function(e,t,n,i){return e.x=t.x+n.x*i,e.y=t.y+n.y*i,e.z=t.z+n.z*i,e},t.distance=function(e,t){var n=t.x-e.x,i=t.y-e.y,r=t.z-e.z;return Math.sqrt(n*n+i*i+r*r)},t.squaredDistance=function(e,t){var n=t.x-e.x,i=t.y-e.y,r=t.z-e.z;return n*n+i*i+r*r},t.len=function(e){var t=e.x,n=e.y,i=e.z;return Math.sqrt(t*t+n*n+i*i)},t.lengthSqr=function(e){var t=e.x,n=e.y,i=e.z;return t*t+n*n+i*i},t.negate=function(e,t){return e.x=-t.x,e.y=-t.y,e.z=-t.z,e},t.invert=function(e,t){return e.x=1/t.x,e.y=1/t.y,e.z=1/t.z,e},t.invertSafe=function(e,t){var n=t.x,i=t.y,r=t.z;return Math.abs(n)0&&(o=1/Math.sqrt(o),e.x=n*o,e.y=i*o,e.z=r*o),e},t.dot=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z},t.cross=function(e,t,n){var i=t.x,r=t.y,o=t.z,a=n.x,s=n.y,c=n.z;return e.x=r*c-o*s,e.y=o*a-i*c,e.z=i*s-r*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*un()*Math.PI,i=2*un()-1,r=Math.sqrt(1-i*i);return e.x=r*Math.cos(n)*t,e.y=r*Math.sin(n)*t,e.z=i*t,e},t.transformMat4=function(e,t,n){var i=t.x,r=t.y,o=t.z,a=n.m03*i+n.m07*r+n.m11*o+n.m15;return a=a?Math.abs(1/a):1,e.x=(n.m00*i+n.m04*r+n.m08*o+n.m12)*a,e.y=(n.m01*i+n.m05*r+n.m09*o+n.m13)*a,e.z=(n.m02*i+n.m06*r+n.m10*o+n.m14)*a,e},t.transformMat4Normal=function(e,t,n){var i=t.x,r=t.y,o=t.z,a=n.m03*i+n.m07*r+n.m11*o;return a=a?Math.abs(1/a):1,e.x=(n.m00*i+n.m04*r+n.m08*o)*a,e.y=(n.m01*i+n.m05*r+n.m09*o)*a,e.z=(n.m02*i+n.m06*r+n.m10*o)*a,e},t.transformMat3=function(e,t,n){var i=t.x,r=t.y,o=t.z;return e.x=i*n.m00+r*n.m03+o*n.m06,e.y=i*n.m01+r*n.m04+o*n.m07,e.z=i*n.m02+r*n.m05+o*n.m08,e},t.transformAffine=function(e,t,n){var i=t.x,r=t.y,o=t.z;return e.x=n.m00*i+n.m04*r+n.m08*o+n.m12,e.y=n.m01*i+n.m05*r+n.m09*o+n.m13,e.x=n.m02*i+n.m06*r+n.m10*o+n.m14,e},t.transformQuat=function(e,t,n){var i=n.w*t.x+n.y*t.z-n.z*t.y,r=n.w*t.y+n.z*t.x-n.x*t.z,o=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+r*-n.z-o*-n.y,e.y=r*n.w+a*-n.y+o*-n.x-i*-n.z,e.z=o*n.w+a*-n.z+i*-n.y-r*-n.x,e},t.transformRTS=function(e,t,n,i,r){var o=t.x*r.x,a=t.y*r.y,s=t.z*r.z,c=n.w*o+n.y*s-n.z*a,l=n.w*a+n.z*o-n.x*s,u=n.w*s+n.x*a-n.y*o,h=-n.x*o-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,r){var o=t.x-i.x,a=t.y-i.y,s=t.z-i.z,c=n.w*o-n.y*s+n.z*a,l=n.w*a-n.z*o+n.x*s,u=n.w*s-n.x*a+n.y*o,h=n.x*o+n.y*a+n.z*s;return e.x=(c*n.w+h*n.x+l*n.z-u*n.y)/r.x,e.y=(l*n.w+h*n.y+u*n.x-c*n.z)/r.y,e.z=(u*n.w+h*n.z+c*n.y-l*n.x)/r.z,e},t.rotateX=function(e,t,n,i){var r=t.x-n.x,o=t.y-n.y,a=t.z-n.z,s=Math.cos(i),c=Math.sin(i),l=r,u=o*s-a*c,h=o*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 r=t.x-n.x,o=t.y-n.y,a=t.z-n.z,s=Math.cos(i),c=Math.sin(i),l=a*c+r*s,u=o,h=a*s-r*c;return e.x=l+n.x,e.y=u+n.y,e.z=h+n.z,e},t.rotateZ=function(e,t,n,i){var r=t.x-n.x,o=t.y-n.y,a=t.z-n.z,s=Math.cos(i),c=Math.sin(i),l=r*s-o*c,u=r*c+o*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=tn);var i=e.x,r=e.y,o=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(r-s)<=n*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(o-c)<=n*Math.max(1,Math.abs(o),Math.abs(c))},t.angle=function(e,n){t.normalize(wn,e),t.normalize(Rn,n);var i=t.dot(wn,Rn);return i>1?0:i<-1?Math.PI:Math.acos(i)},t.projectOnPlane=function(e,n,i){return t.subtract(e,n,t.project(e,n,i))},t.project=function(e,n,i){var r=t.lengthSqr(i);return r<1e-6?t.set(e,0,0,0):t.multiplyScalar(e,i,t.dot(n,i)/r)};var n=t.prototype;return n.clone=function(){return new t(this.x,this.y,this.z)},n.set=function(e,t,n){return e&&"object"==typeof e?(this.x=e.x,this.y=e.y,this.z=e.z):(this.x=e||0,this.y=t||0,this.z=n||0),this},n.equals=function(e,t){return void 0===t&&(t=tn),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=tn),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=on(this.x,e.x,t.x),this.y=on(this.y,e.y,t.y),this.z=on(this.z,e.z,t.z),this},n.dot=function(e){return this.x*e.x+this.y*e.y+this.z*e.z},n.cross=function(e){var t=this.x,n=this.y,i=this.z,r=e.x,o=e.y,a=e.z;return this.x=n*a-i*o,this.y=i*r-t*a,this.z=t*o-n*r,this},n.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},n.lengthSqr=function(){return this.x*this.x+this.y*this.y+this.z*this.z},n.normalize=function(){var e=this.x,t=this.y,n=this.z,i=e*e+t*t+n*n;return i>0&&(i=1/Math.sqrt(i),this.x=e*i,this.y=t*i,this.z=n*i),this},n.transformMat4=function(e){var t=this.x,n=this.y,i=this.z,r=e.m03*t+e.m07*n+e.m11*i+e.m15;return r=r?1/r:1,this.x=(e.m00*t+e.m04*n+e.m08*i+e.m12)*r,this.y=(e.m01*t+e.m05*n+e.m09*i+e.m13)*r,this.z=(e.m02*t+e.m06*n+e.m10*i+e.m14)*r,this},t}(st));bn.UNIT_X=Object.freeze(new bn(1,0,0)),bn.UNIT_Y=Object.freeze(new bn(0,1,0)),bn.UNIT_Z=Object.freeze(new bn(0,0,1)),bn.RIGHT=Object.freeze(new bn(1,0,0)),bn.UP=Object.freeze(new bn(0,1,0)),bn.FORWARD=Object.freeze(new bn(0,0,-1)),bn.ZERO=Object.freeze(new bn(0,0,0)),bn.ONE=Object.freeze(new bn(1,1,1)),bn.NEG_ONE=Object.freeze(new bn(-1,-1,-1));var wn=new bn,Rn=new bn;function Pn(e,t,n){return new bn(e,t,n)}Qt.fastDefine("cc.Vec3",bn,{x:0,y:0,z:0}),c.Vec3=bn,c.v3=Pn;var In=e("Mat3",function(e){function t(t,n,i,r,o,a,s,c,l){var u;return void 0===t&&(t=1),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===o&&(o=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=r,u.m04=o,u.m05=a,u.m06=s,u.m07=c,u.m08=l),u}Z(t,e),t.clone=function(e){return new t(e.m00,e.m01,e.m02,e.m03,e.m04,e.m05,e.m06,e.m07,e.m08)},t.copy=function(e,t){return e.m00=t.m00,e.m01=t.m01,e.m02=t.m02,e.m03=t.m03,e.m04=t.m04,e.m05=t.m05,e.m06=t.m06,e.m07=t.m07,e.m08=t.m08,e},t.set=function(e,t,n,i,r,o,a,s,c,l){return e.m00=t,e.m01=n,e.m02=i,e.m03=r,e.m04=o,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,r=t.m05;e.m01=t.m03,e.m02=t.m06,e.m03=n,e.m05=t.m07,e.m06=i,e.m07=r}else e.m00=t.m00,e.m01=t.m03,e.m02=t.m06,e.m03=t.m01,e.m04=t.m04,e.m05=t.m07,e.m06=t.m02,e.m07=t.m05,e.m08=t.m08;return e},t.invert=function(e,t){var n=t.m00,i=t.m01,r=t.m02,o=t.m03,a=t.m04,s=t.m05,c=t.m06,l=t.m07,u=t.m08,h=u*a-s*l,f=-u*o+s*c,_=l*o-a*c,p=n*h+i*f+r*_;return 0===p?(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):(p=1/p,e.m00=h*p,e.m01=(-u*i+r*l)*p,e.m02=(s*i-r*a)*p,e.m03=f*p,e.m04=(u*n-r*c)*p,e.m05=(-s*n+r*o)*p,e.m06=_*p,e.m07=(-l*n+i*c)*p,e.m08=(a*n-i*o)*p,e)},t.determinant=function(e){var t=e.m00,n=e.m01,i=e.m02,r=e.m03,o=e.m04,a=e.m05,s=e.m06,c=e.m07,l=e.m08;return t*(l*o-a*c)+n*(-l*r+a*s)+i*(c*r-o*s)},t.multiply=function(e,t,n){var i=t.m00,r=t.m01,o=t.m02,a=t.m03,s=t.m04,c=t.m05,l=t.m06,u=t.m07,h=t.m08,f=n.m00,_=n.m01,p=n.m02,d=n.m03,m=n.m04,g=n.m05,v=n.m06,y=n.m07,x=n.m08;return e.m00=f*i+_*a+p*l,e.m01=f*r+_*s+p*u,e.m02=f*o+_*c+p*h,e.m03=d*i+m*a+g*l,e.m04=d*r+m*s+g*u,e.m05=d*o+m*c+g*h,e.m06=v*i+y*a+x*l,e.m07=v*r+y*s+x*u,e.m08=v*o+y*c+x*h,e},t.multiplyMat4=function(e,t,n){var i=t.m00,r=t.m01,o=t.m02,a=t.m03,s=t.m04,c=t.m05,l=t.m06,u=t.m07,h=t.m08,f=n.m00,_=n.m01,p=n.m02,d=n.m04,m=n.m05,g=n.m06,v=n.m08,y=n.m09,x=n.m10;return e.m00=f*i+_*a+p*l,e.m01=f*r+_*s+p*u,e.m02=f*o+_*c+p*h,e.m03=d*i+m*a+g*l,e.m04=d*r+m*s+g*u,e.m05=d*o+m*c+g*h,e.m06=v*i+y*a+x*l,e.m07=v*r+y*s+x*u,e.m08=v*o+y*c+x*h,e},t.transform=function(e,t,n){var i=t.m00,r=t.m01,o=t.m02,a=t.m03,s=t.m04,c=t.m05,l=t.m06,u=t.m07,h=t.m08,f=n.x,_=n.y;return e.m00=i,e.m01=r,e.m02=o,e.m03=a,e.m04=s,e.m05=c,e.m06=f*i+_*a+l,e.m07=f*r+_*s+u,e.m08=f*o+_*c+h,e},t.scale=function(e,t,n){var i=n.x,r=n.y;return e.m00=i*t.m00,e.m01=i*t.m01,e.m02=i*t.m02,e.m03=r*t.m03,e.m04=r*t.m04,e.m05=r*t.m05,e.m06=t.m06,e.m07=t.m07,e.m08=t.m08,e},t.rotate=function(e,t,n){var i=t.m00,r=t.m01,o=t.m02,a=t.m03,s=t.m04,c=t.m05,l=t.m06,u=t.m07,h=t.m08,f=Math.sin(n),_=Math.cos(n);return e.m00=_*i+f*a,e.m01=_*r+f*s,e.m02=_*o+f*c,e.m03=_*a-f*i,e.m04=_*s-f*r,e.m05=_*c-f*o,e.m06=l,e.m07=u,e.m08=h,e},t.fromMat4=function(e,t){return e.m00=t.m00,e.m01=t.m01,e.m02=t.m02,e.m03=t.m04,e.m04=t.m05,e.m05=t.m06,e.m06=t.m08,e.m07=t.m09,e.m08=t.m10,e},t.fromViewUp=function(e,n,i){return bn.lengthSqr(n).999999?(e.x=0,e.y=0,e.z=0,e.w=1,e):(bn.cross(Fn,n,i),e.x=Fn.x,e.y=Fn.y,e.z=Fn.z,e.w=1+r,t.normalize(e,e))},t.getAxisAngle=function(e,t){var n=2*Math.acos(t.w),i=Math.sin(n/2);return 0!==i?(e.x=t.x/i,e.y=t.y/i,e.z=t.z/i):(e.x=1,e.y=0,e.z=0),n},t.multiply=function(e,t,n){var i=t.x*n.w+t.w*n.x+t.y*n.z-t.z*n.y,r=t.y*n.w+t.w*n.y+t.z*n.x-t.x*n.z,o=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=r,e.z=o,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),r=Math.cos(n),o=t.x,a=t.y,s=t.z,c=t.w;return e.x=o*r+c*i,e.y=a*r+s*i,e.z=s*r-a*i,e.w=c*r-o*i,e},t.rotateY=function(e,t,n){n*=.5;var i=Math.sin(n),r=Math.cos(n),o=t.x,a=t.y,s=t.z,c=t.w;return e.x=o*r-s*i,e.y=a*r+c*i,e.z=s*r+o*i,e.w=c*r-a*i,e},t.rotateZ=function(e,t,n){n*=.5;var i=Math.sin(n),r=Math.cos(n),o=t.x,a=t.y,s=t.z,c=t.w;return e.x=o*r+a*i,e.y=a*r-o*i,e.z=s*r+c*i,e.w=c*r-s*i,e},t.rotateAround=function(e,n,i,r){return t.invert(Nn,n),bn.transformQuat(Fn,i,Nn),t.fromAxisAngle(Nn,Fn,r),t.multiply(e,n,Nn),e},t.rotateAroundLocal=function(e,n,i,r){return t.fromAxisAngle(Nn,i,r),t.multiply(e,n,Nn),e},t.calculateW=function(e,t){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=Math.sqrt(Math.abs(1-t.x*t.x-t.y*t.y-t.z*t.z)),e},t.dot=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w},t.lerp=function(e,t,n,i){return e.x=t.x+i*(n.x-t.x),e.y=t.y+i*(n.y-t.y),e.z=t.z+i*(n.z-t.z),e.w=t.w+i*(n.w-t.w),e},t.slerp=function(e,t,n,i){var r=0,o=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),f=Math.sin(h);r=Math.sin((1-i)*h)/f,o=Math.sin(i*h)/f}else r=1-i,o=i;return e.x=r*t.x+o*a,e.y=r*t.y+o*s,e.z=r*t.z+o*c,e.w=r*t.w+o*l,e},t.sqlerp=function(e,n,i,r,o,a){return t.slerp(Nn,n,o,a),t.slerp(Ln,i,r,a),t.slerp(e,Nn,Ln,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,r){return In.set(Bn,n.x,n.y,n.z,i.x,i.y,i.z,r.x,r.y,r.z),t.normalize(e,t.fromMat3(e,Bn))},t.fromViewUp=function(e,n,i){return In.fromViewUp(Bn,n,i),t.normalize(e,t.fromMat3(e,Bn))},t.fromAxisAngle=function(e,t,n){n*=.5;var i=Math.sin(n);return e.x=i*t.x,e.y=i*t.y,e.z=i*t.z,e.w=Math.cos(n),e},t.fromMat3=function(e,t){var n=t.m00,i=t.m03,r=t.m06,o=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 f=.5/Math.sqrt(h+1);e.w=.25/f,e.x=(l-s)*f,e.y=(r-c)*f,e.z=(o-i)*f}else if(n>a&&n>u){var _=2*Math.sqrt(1+n-a-u);e.w=(l-s)/_,e.x=.25*_,e.y=(i+o)/_,e.z=(r+c)/_}else if(a>u){var p=2*Math.sqrt(1+a-n-u);e.w=(r-c)/p,e.x=(i+o)/p,e.y=.25*p,e.z=(s+l)/p}else{var d=2*Math.sqrt(1+u-n-a);e.w=(o-i)/d,e.x=(r+c)/d,e.y=(s+l)/d,e.z=.25*d}return e},t.fromEuler=function(e,t,n,i){t*=zn,n*=zn,i*=zn;var r=Math.sin(t),o=Math.cos(t),a=Math.sin(n),s=Math.cos(n),c=Math.sin(i),l=Math.cos(i);return e.x=r*s*l+o*a*c,e.y=o*a*l+r*s*c,e.z=o*s*c-r*a*l,e.w=o*s*l-r*a*c,e},t.fromAngleZ=function(e,t){return t*=zn,e.x=e.y=0,e.z=Math.sin(t),e.w=Math.cos(t),e},t.toAxisX=function(e,t){var n=2*t.y,i=2*t.z;return e.x=1-n*t.y-i*t.z,e.y=n*t.x+i*t.w,e.z=i*t.x+n*t.w,e},t.toAxisY=function(e,t){var n=2*t.x,i=2*t.y,r=2*t.z;return e.x=i*t.x-r*t.w,e.y=1-n*t.x-r*t.z,e.z=r*t.y+n*t.w,e},t.toAxisZ=function(e,t){var n=2*t.x,i=2*t.y,r=2*t.z;return e.x=r*t.x-i*t.w,e.y=r*t.y-n*t.w,e.z=1-n*t.x-i*t.y,e},t.toEuler=function(e,t,n){var i=t.x,r=t.y,o=t.z,a=t.w,s=0,c=0,l=0,u=i*r+o*a;if(u>.499999)s=0,c=ln(2*Math.atan2(i,a)),l=90;else if(u<-.499999)s=0,c=-ln(2*Math.atan2(i,a)),l=-90;else{var h=i*i,f=r*r,_=o*o;s=ln(Math.atan2(2*i*a-2*r*o,1-2*h-2*_)),c=ln(Math.atan2(2*r*a-2*i*o,1-2*f-2*_)),l=ln(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=tn),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=tn),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}(st));Mn.IDENTITY=Object.freeze(new Mn);var Nn=new Mn,Ln=new Mn,Fn=new bn,Bn=new In,zn=.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 Mn(e,t,n,i)}Qt.fastDefine("cc.Quat",Mn,{x:0,y:0,z:0,w:1}),c.Quat=Mn,c.quat=kn;var Un=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])]),Gn=e("Mat4",function(e){function t(t,n,i,r,o,a,s,c,l,u,h,f,_,p,d,m){var g;return void 0===t&&(t=1),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===o&&(o=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===f&&(f=0),void 0===_&&(_=0),void 0===p&&(p=0),void 0===d&&(d=0),void 0===m&&(m=1),(g=e.call(this)||this).m00=void 0,g.m01=void 0,g.m02=void 0,g.m03=void 0,g.m04=void 0,g.m05=void 0,g.m06=void 0,g.m07=void 0,g.m08=void 0,g.m09=void 0,g.m10=void 0,g.m11=void 0,g.m12=void 0,g.m13=void 0,g.m14=void 0,g.m15=void 0,"object"==typeof t?(g.m00=t.m00,g.m01=t.m01,g.m02=t.m02,g.m03=t.m03,g.m04=t.m04,g.m05=t.m05,g.m06=t.m06,g.m07=t.m07,g.m08=t.m08,g.m09=t.m09,g.m10=t.m10,g.m11=t.m11,g.m12=t.m12,g.m13=t.m13,g.m14=t.m14,g.m15=t.m15):(g.m00=t,g.m01=n,g.m02=i,g.m03=r,g.m04=o,g.m05=a,g.m06=s,g.m07=c,g.m08=l,g.m09=u,g.m10=h,g.m11=f,g.m12=_,g.m13=p,g.m14=d,g.m15=m),g}Z(t,e),t.clone=function(e){return new t(e.m00,e.m01,e.m02,e.m03,e.m04,e.m05,e.m06,e.m07,e.m08,e.m09,e.m10,e.m11,e.m12,e.m13,e.m14,e.m15)},t.copy=function(e,t){return e.m00=t.m00,e.m01=t.m01,e.m02=t.m02,e.m03=t.m03,e.m04=t.m04,e.m05=t.m05,e.m06=t.m06,e.m07=t.m07,e.m08=t.m08,e.m09=t.m09,e.m10=t.m10,e.m11=t.m11,e.m12=t.m12,e.m13=t.m13,e.m14=t.m14,e.m15=t.m15,e},t.set=function(e,t,n,i,r,o,a,s,c,l,u,h,f,_,p,d,m){return e.m00=t,e.m01=n,e.m02=i,e.m03=r,e.m04=o,e.m05=a,e.m06=s,e.m07=c,e.m08=l,e.m09=u,e.m10=h,e.m11=f,e.m12=_,e.m13=p,e.m14=d,e.m15=m,e},t.identity=function(e){return e.m00=1,e.m01=0,e.m02=0,e.m03=0,e.m04=0,e.m05=1,e.m06=0,e.m07=0,e.m08=0,e.m09=0,e.m10=1,e.m11=0,e.m12=0,e.m13=0,e.m14=0,e.m15=1,e},t.transpose=function(e,t){if(e===t){var n=t.m01,i=t.m02,r=t.m03,o=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=o,e.m11=t.m14,e.m12=r,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,r=t.m02,o=t.m03,a=t.m04,s=t.m05,c=t.m06,l=t.m07,u=t.m08,h=t.m09,f=t.m10,_=t.m11,p=t.m12,d=t.m13,m=t.m14,g=t.m15,v=n*s-i*a,y=n*c-r*a,x=n*l-o*a,S=i*c-r*s,T=i*l-o*s,E=r*l-o*c,A=u*d-h*p,C=u*m-f*p,b=u*g-_*p,w=h*m-f*d,R=h*g-_*d,P=f*g-_*m,I=v*P-y*R+x*w+S*b-T*C+E*A;return 0===I?(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):(I=1/I,e.m00=(s*P-c*R+l*w)*I,e.m01=(r*R-i*P-o*w)*I,e.m02=(d*E-m*T+g*S)*I,e.m03=(f*T-h*E-_*S)*I,e.m04=(c*b-a*P-l*C)*I,e.m05=(n*P-r*b+o*C)*I,e.m06=(m*x-p*E-g*y)*I,e.m07=(u*E-f*x+_*y)*I,e.m08=(a*R-s*b+l*A)*I,e.m09=(i*b-n*R-o*A)*I,e.m10=(p*T-d*x+g*v)*I,e.m11=(h*x-u*T-_*v)*I,e.m12=(s*C-a*w-c*A)*I,e.m13=(n*w-i*C+r*A)*I,e.m14=(d*y-p*S-m*v)*I,e.m15=(u*S-h*y+f*v)*I,e)},t.determinant=function(e){var t=e.m00,n=e.m01,i=e.m02,r=e.m03,o=e.m04,a=e.m05,s=e.m06,c=e.m07,l=e.m08,u=e.m09,h=e.m10,f=e.m11,_=e.m12,p=e.m13,d=e.m14,m=e.m15;return(t*a-n*o)*(h*m-f*d)-(t*s-i*o)*(u*m-f*p)+(t*c-r*o)*(u*d-h*p)+(n*s-i*a)*(l*m-f*_)-(n*c-r*a)*(l*d-h*_)+(i*c-r*s)*(l*p-u*_)},t.multiply=function(e,t,n){var i=t.m00,r=t.m01,o=t.m02,a=t.m03,s=t.m04,c=t.m05,l=t.m06,u=t.m07,h=t.m08,f=t.m09,_=t.m10,p=t.m11,d=t.m12,m=t.m13,g=t.m14,v=t.m15,y=n.m00,x=n.m01,S=n.m02,T=n.m03;return e.m00=y*i+x*s+S*h+T*d,e.m01=y*r+x*c+S*f+T*m,e.m02=y*o+x*l+S*_+T*g,e.m03=y*a+x*u+S*p+T*v,y=n.m04,x=n.m05,S=n.m06,T=n.m07,e.m04=y*i+x*s+S*h+T*d,e.m05=y*r+x*c+S*f+T*m,e.m06=y*o+x*l+S*_+T*g,e.m07=y*a+x*u+S*p+T*v,y=n.m08,x=n.m09,S=n.m10,T=n.m11,e.m08=y*i+x*s+S*h+T*d,e.m09=y*r+x*c+S*f+T*m,e.m10=y*o+x*l+S*_+T*g,e.m11=y*a+x*u+S*p+T*v,y=n.m12,x=n.m13,S=n.m14,T=n.m15,e.m12=y*i+x*s+S*h+T*d,e.m13=y*r+x*c+S*f+T*m,e.m14=y*o+x*l+S*_+T*g,e.m15=y*a+x*u+S*p+T*v,e},t.transform=function(e,t,n){var i=n.x,r=n.y,o=n.z;if(t===e)e.m12=t.m00*i+t.m04*r+t.m08*o+t.m12,e.m13=t.m01*i+t.m05*r+t.m09*o+t.m13,e.m14=t.m02*i+t.m06*r+t.m10*o+t.m14,e.m15=t.m03*i+t.m07*r+t.m11*o+t.m15;else{var a=t.m00,s=t.m01,c=t.m02,l=t.m03,u=t.m04,h=t.m05,f=t.m06,_=t.m07,p=t.m08,d=t.m09,m=t.m10,g=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=f,e.m07=_,e.m08=p,e.m09=d,e.m10=m,e.m11=g,e.m12=a*i+u*r+p*o+t.m12,e.m13=s*i+h*r+d*o+t.m13,e.m14=c*i+f*r+m*o+t.m14,e.m15=l*i+_*r+g*o+t.m15}return e},t.translate=function(e,t,n){return console.warn("function changed"),t===e?(e.m12+=n.x,e.m13+=n.y,e.m14+=n.z):(e.m00=t.m00,e.m01=t.m01,e.m02=t.m02,e.m03=t.m03,e.m04=t.m04,e.m05=t.m05,e.m06=t.m06,e.m07=t.m07,e.m08=t.m08,e.m09=t.m09,e.m10=t.m10,e.m11=t.m11,e.m12+=n.x,e.m13+=n.y,e.m14+=n.z,e.m15=t.m15),e},t.scale=function(e,t,n){var i=n.x,r=n.y,o=n.z;return e.m00=t.m00*i,e.m01=t.m01*i,e.m02=t.m02*i,e.m03=t.m03*i,e.m04=t.m04*r,e.m05=t.m05*r,e.m06=t.m06*r,e.m07=t.m07*r,e.m08=t.m08*o,e.m09=t.m09*o,e.m10=t.m10*o,e.m11=t.m11*o,e.m12=t.m12,e.m13=t.m13,e.m14=t.m14,e.m15=t.m15,e},t.rotate=function(e,t,n,i){var r=i.x,o=i.y,a=i.z,s=Math.sqrt(r*r+o*o+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=bn.set(Hn,e.m00,e.m01,e.m02).length(),Vn.m00=e.m00/i.x,Vn.m01=e.m01/i.x,Vn.m02=e.m02/i.x,i.y=bn.set(Hn,e.m04,e.m05,e.m06).length(),Vn.m03=e.m04/i.y,Vn.m04=e.m05/i.y,Vn.m05=e.m06/i.y,i.z=bn.set(Hn,e.m08,e.m09,e.m10).length(),Vn.m06=e.m08/i.z,Vn.m07=e.m09/i.z,Vn.m08=e.m10/i.z,In.determinant(Vn)<0&&(i.x*=-1,Vn.m00*=-1,Vn.m01*=-1,Vn.m02*=-1),Mn.fromMat3(t,Vn),bn.set(n,e.m12,e.m13,e.m14)},t.fromRTS=function(e,t,n,i){var r=t.x,o=t.y,a=t.z,s=t.w,c=r+r,l=o+o,u=a+a,h=r*c,f=r*l,_=r*u,p=o*l,d=o*u,m=a*u,g=s*c,v=s*l,y=s*u,x=i.x,S=i.y,T=i.z;return e.m00=(1-(p+m))*x,e.m01=(f+y)*x,e.m02=(_-v)*x,e.m03=0,e.m04=(f-y)*S,e.m05=(1-(h+m))*S,e.m06=(d+g)*S,e.m07=0,e.m08=(_+v)*T,e.m09=(d-g)*T,e.m10=(1-(h+p))*T,e.m11=0,e.m12=n.x,e.m13=n.y,e.m14=n.z,e.m15=1,e},t.fromRTSOrigin=function(e,t,n,i,r){var o=t.x,a=t.y,s=t.z,c=t.w,l=o+o,u=a+a,h=s+s,f=o*l,_=o*u,p=o*h,d=a*u,m=a*h,g=s*h,v=c*l,y=c*u,x=c*h,S=i.x,T=i.y,E=i.z,A=r.x,C=r.y,b=r.z;return e.m00=(1-(d+g))*S,e.m01=(_+x)*S,e.m02=(p-y)*S,e.m03=0,e.m04=(_-x)*T,e.m05=(1-(f+g))*T,e.m06=(m+v)*T,e.m07=0,e.m08=(p+y)*E,e.m09=(m-v)*E,e.m10=(1-(f+d))*E,e.m11=0,e.m12=n.x+A-(e.m00*A+e.m04*C+e.m08*b),e.m13=n.y+C-(e.m01*A+e.m05*C+e.m09*b),e.m14=n.z+b-(e.m02*A+e.m06*C+e.m10*b),e.m15=1,e},t.fromQuat=function(e,t){var n=t.x,i=t.y,r=t.z,o=t.w,a=n+n,s=i+i,c=r+r,l=n*a,u=i*a,h=i*s,f=r*a,_=r*s,p=r*c,d=o*a,m=o*s,g=o*c;return e.m00=1-h-p,e.m01=u+g,e.m02=f-m,e.m03=0,e.m04=u-g,e.m05=1-l-p,e.m06=_+d,e.m07=0,e.m08=f+m,e.m09=_-d,e.m10=1-l-h,e.m11=0,e.m12=0,e.m13=0,e.m14=0,e.m15=1,e},t.frustum=function(e,t,n,i,r,o,a){var s=1/(n-t),c=1/(r-i),l=1/(o-a);return e.m00=2*o*s,e.m01=0,e.m02=0,e.m03=0,e.m04=0,e.m05=2*o*c,e.m06=0,e.m07=0,e.m08=(n+t)*s,e.m09=(r+i)*c,e.m10=(a+o)*l,e.m11=-1,e.m12=0,e.m13=0,e.m14=a*o*2*l,e.m15=0,e},t.perspective=function(e,t,n,i,r,o,a,s,c){void 0===o&&(o=!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-r),h=o?l/n:l,f=(o?l:l*n)*s,_=Un[c];return e.m00=h*_[0],e.m01=h*_[1],e.m02=0,e.m03=0,e.m04=f*_[2],e.m05=f*_[3],e.m06=0,e.m07=0,e.m08=0,e.m09=0,e.m10=(r-a*i)*u,e.m11=-1,e.m12=0,e.m13=0,e.m14=r*i*u*(1-a),e.m15=0,e},t.ortho=function(e,t,n,i,r,o,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-r)*c,f=1/(o-a),_=-2*u,p=-2*h,d=(t+n)*u,m=(r+i)*h,g=Un[l];return e.m00=_*g[0],e.m01=_*g[1],e.m02=0,e.m03=0,e.m04=p*g[2],e.m05=p*g[3],e.m06=0,e.m07=0,e.m08=0,e.m09=0,e.m10=f*(1-s),e.m11=0,e.m12=d*g[0]+m*g[2],e.m13=d*g[1]+m*g[3],e.m14=(o-s*a)*f,e.m15=1,e},t.lookAt=function(e,t,n,i){var r=t.x,o=t.y,a=t.z,s=i.x,c=i.y,l=i.z,u=r-n.x,h=o-n.y,f=a-n.z,_=1/Math.sqrt(u*u+h*h+f*f),p=c*(f*=_)-l*(h*=_),d=l*(u*=_)-s*f,m=s*h-c*u,g=h*(m*=_=1/Math.sqrt(p*p+d*d+m*m))-f*(d*=_),v=f*(p*=_)-u*m,y=u*d-h*p;return e.m00=p,e.m01=g,e.m02=u,e.m03=0,e.m04=d,e.m05=v,e.m06=h,e.m07=0,e.m08=m,e.m09=y,e.m10=f,e.m11=0,e.m12=-(p*r+d*o+m*a),e.m13=-(g*r+v*o+y*a),e.m14=-(u*r+h*o+f*a),e.m15=1,e},t.inverseTranspose=function(e,t){var n=t.m00,i=t.m01,r=t.m02,o=t.m03,a=t.m04,s=t.m05,c=t.m06,l=t.m07,u=t.m08,h=t.m09,f=t.m10,_=t.m11,p=t.m12,d=t.m13,m=t.m14,g=t.m15,v=n*s-i*a,y=n*c-r*a,x=n*l-o*a,S=i*c-r*s,T=i*l-o*s,E=r*l-o*c,A=u*d-h*p,C=u*m-f*p,b=u*g-_*p,w=h*m-f*d,R=h*g-_*d,P=f*g-_*m,I=v*P-y*R+x*w+S*b-T*C+E*A;return I?(I=1/I,e.m00=(s*P-c*R+l*w)*I,e.m01=(c*b-a*P-l*C)*I,e.m02=(a*R-s*b+l*A)*I,e.m03=0,e.m04=(r*R-i*P-o*w)*I,e.m05=(n*P-r*b+o*C)*I,e.m06=(i*b-n*R-o*A)*I,e.m07=0,e.m08=(d*E-m*T+g*S)*I,e.m09=(m*x-p*E-g*y)*I,e.m10=(p*T-d*x+g*v)*I,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=tn),Math.abs(e.m00-t.m00)<=n*Math.max(1,Math.abs(e.m00),Math.abs(t.m00))&&Math.abs(e.m01-t.m01)<=n*Math.max(1,Math.abs(e.m01),Math.abs(t.m01))&&Math.abs(e.m02-t.m02)<=n*Math.max(1,Math.abs(e.m02),Math.abs(t.m02))&&Math.abs(e.m03-t.m03)<=n*Math.max(1,Math.abs(e.m03),Math.abs(t.m03))&&Math.abs(e.m04-t.m04)<=n*Math.max(1,Math.abs(e.m04),Math.abs(t.m04))&&Math.abs(e.m05-t.m05)<=n*Math.max(1,Math.abs(e.m05),Math.abs(t.m05))&&Math.abs(e.m06-t.m06)<=n*Math.max(1,Math.abs(e.m06),Math.abs(t.m06))&&Math.abs(e.m07-t.m07)<=n*Math.max(1,Math.abs(e.m07),Math.abs(t.m07))&&Math.abs(e.m08-t.m08)<=n*Math.max(1,Math.abs(e.m08),Math.abs(t.m08))&&Math.abs(e.m09-t.m09)<=n*Math.max(1,Math.abs(e.m09),Math.abs(t.m09))&&Math.abs(e.m10-t.m10)<=n*Math.max(1,Math.abs(e.m10),Math.abs(t.m10))&&Math.abs(e.m11-t.m11)<=n*Math.max(1,Math.abs(e.m11),Math.abs(t.m11))&&Math.abs(e.m12-t.m12)<=n*Math.max(1,Math.abs(e.m12),Math.abs(t.m12))&&Math.abs(e.m13-t.m13)<=n*Math.max(1,Math.abs(e.m13),Math.abs(t.m13))&&Math.abs(e.m14-t.m14)<=n*Math.max(1,Math.abs(e.m14),Math.abs(t.m14))&&Math.abs(e.m15-t.m15)<=n*Math.max(1,Math.abs(e.m15),Math.abs(t.m15))};var n=t.prototype;return n.clone=function(){return new t(this.m00,this.m01,this.m02,this.m03,this.m04,this.m05,this.m06,this.m07,this.m08,this.m09,this.m10,this.m11,this.m12,this.m13,this.m14,this.m15)},n.set=function(e,t,n,i,r,o,a,s,c,l,u,h,f,_,p,d){return void 0===e&&(e=1),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===o&&(o=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===f&&(f=0),void 0===_&&(_=0),void 0===p&&(p=0),void 0===d&&(d=1),"object"==typeof e?(this.m01=e.m01,this.m02=e.m02,this.m03=e.m03,this.m04=e.m04,this.m05=e.m05,this.m06=e.m06,this.m07=e.m07,this.m08=e.m08,this.m09=e.m09,this.m10=e.m10,this.m11=e.m11,this.m12=e.m12,this.m13=e.m13,this.m14=e.m14,this.m15=e.m15,this.m00=e.m00):(this.m01=t,this.m02=n,this.m03=i,this.m04=r,this.m05=o,this.m06=a,this.m07=s,this.m08=c,this.m09=l,this.m10=u,this.m11=h,this.m12=f,this.m13=_,this.m14=p,this.m15=d,this.m00=e),this},n.equals=function(e,t){return void 0===t&&(t=tn),Math.abs(this.m00-e.m00)<=t*Math.max(1,Math.abs(this.m00),Math.abs(e.m00))&&Math.abs(this.m01-e.m01)<=t*Math.max(1,Math.abs(this.m01),Math.abs(e.m01))&&Math.abs(this.m02-e.m02)<=t*Math.max(1,Math.abs(this.m02),Math.abs(e.m02))&&Math.abs(this.m03-e.m03)<=t*Math.max(1,Math.abs(this.m03),Math.abs(e.m03))&&Math.abs(this.m04-e.m04)<=t*Math.max(1,Math.abs(this.m04),Math.abs(e.m04))&&Math.abs(this.m05-e.m05)<=t*Math.max(1,Math.abs(this.m05),Math.abs(e.m05))&&Math.abs(this.m06-e.m06)<=t*Math.max(1,Math.abs(this.m06),Math.abs(e.m06))&&Math.abs(this.m07-e.m07)<=t*Math.max(1,Math.abs(this.m07),Math.abs(e.m07))&&Math.abs(this.m08-e.m08)<=t*Math.max(1,Math.abs(this.m08),Math.abs(e.m08))&&Math.abs(this.m09-e.m09)<=t*Math.max(1,Math.abs(this.m09),Math.abs(e.m09))&&Math.abs(this.m10-e.m10)<=t*Math.max(1,Math.abs(this.m10),Math.abs(e.m10))&&Math.abs(this.m11-e.m11)<=t*Math.max(1,Math.abs(this.m11),Math.abs(e.m11))&&Math.abs(this.m12-e.m12)<=t*Math.max(1,Math.abs(this.m12),Math.abs(e.m12))&&Math.abs(this.m13-e.m13)<=t*Math.max(1,Math.abs(this.m13),Math.abs(e.m13))&&Math.abs(this.m14-e.m14)<=t*Math.max(1,Math.abs(this.m14),Math.abs(e.m14))&&Math.abs(this.m15-e.m15)<=t*Math.max(1,Math.abs(this.m15),Math.abs(e.m15))},n.strictEquals=function(e){return this.m00===e.m00&&this.m01===e.m01&&this.m02===e.m02&&this.m03===e.m03&&this.m04===e.m04&&this.m05===e.m05&&this.m06===e.m06&&this.m07===e.m07&&this.m08===e.m08&&this.m09===e.m09&&this.m10===e.m10&&this.m11===e.m11&&this.m12===e.m12&&this.m13===e.m13&&this.m14===e.m14&&this.m15===e.m15},n.toString=function(){return"[\n"+this.m00+", "+this.m01+", "+this.m02+", "+this.m03+",\n"+this.m04+", "+this.m05+", "+this.m06+", "+this.m07+",\n"+this.m08+", "+this.m09+", "+this.m10+", "+this.m11+",\n"+this.m12+", "+this.m13+", "+this.m14+", "+this.m15+"\n]"},n.identity=function(){return this.m00=1,this.m01=0,this.m02=0,this.m03=0,this.m04=0,this.m05=1,this.m06=0,this.m07=0,this.m08=0,this.m09=0,this.m10=1,this.m11=0,this.m12=0,this.m13=0,this.m14=0,this.m15=1,this},n.zero=function(){return this.m00=0,this.m01=0,this.m02=0,this.m03=0,this.m04=0,this.m05=0,this.m06=0,this.m07=0,this.m08=0,this.m09=0,this.m10=0,this.m11=0,this.m12=0,this.m13=0,this.m14=0,this.m15=0,this},n.transpose=function(){var e=this.m01,t=this.m02,n=this.m03,i=this.m06,r=this.m07,o=this.m11;return this.m01=this.m04,this.m02=this.m08,this.m03=this.m12,this.m04=e,this.m06=this.m09,this.m07=this.m13,this.m08=t,this.m09=i,this.m11=this.m14,this.m12=n,this.m13=r,this.m14=o,this},n.invert=function(){var e=this.m00,t=this.m01,n=this.m02,i=this.m03,r=this.m04,o=this.m05,a=this.m06,s=this.m07,c=this.m08,l=this.m09,u=this.m10,h=this.m11,f=this.m12,_=this.m13,p=this.m14,d=this.m15,m=e*o-t*r,g=e*a-n*r,v=e*s-i*r,y=t*a-n*o,x=t*s-i*o,S=n*s-i*a,T=c*_-l*f,E=c*p-u*f,A=c*d-h*f,C=l*p-u*_,b=l*d-h*_,w=u*d-h*p,R=m*w-g*b+v*C+y*A-x*E+S*T;return 0===R?(this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),this):(R=1/R,this.m00=(o*w-a*b+s*C)*R,this.m01=(n*b-t*w-i*C)*R,this.m02=(_*S-p*x+d*y)*R,this.m03=(u*x-l*S-h*y)*R,this.m04=(a*A-r*w-s*E)*R,this.m05=(e*w-n*A+i*E)*R,this.m06=(p*v-f*S-d*g)*R,this.m07=(c*S-u*v+h*g)*R,this.m08=(r*b-o*A+s*T)*R,this.m09=(t*A-e*b-i*T)*R,this.m10=(f*x-_*v+d*m)*R,this.m11=(l*v-c*x-h*m)*R,this.m12=(o*E-r*C-a*T)*R,this.m13=(e*C-t*E+n*T)*R,this.m14=(_*g-f*y-p*m)*R,this.m15=(c*y-l*g+u*m)*R,this)},n.determinant=function(){var e=this.m00,t=this.m01,n=this.m02,i=this.m03,r=this.m04,o=this.m05,a=this.m06,s=this.m07,c=this.m08,l=this.m09,u=this.m10,h=this.m11,f=this.m12,_=this.m13,p=this.m14,d=this.m15;return(e*o-t*r)*(u*d-h*p)-(e*a-n*r)*(l*d-h*_)+(e*s-i*r)*(l*p-u*_)+(t*a-n*o)*(c*d-h*f)-(t*s-i*o)*(c*p-u*f)+(n*s-i*a)*(c*_-l*f)},n.add=function(e){return this.m00+=e.m00,this.m01+=e.m01,this.m02+=e.m02,this.m03+=e.m03,this.m04+=e.m04,this.m05+=e.m05,this.m06+=e.m06,this.m07+=e.m07,this.m08+=e.m08,this.m09+=e.m09,this.m10+=e.m10,this.m11+=e.m11,this.m12+=e.m12,this.m13+=e.m13,this.m14+=e.m14,this.m15+=e.m15,this},n.subtract=function(e){return this.m00-=e.m00,this.m01-=e.m01,this.m02-=e.m02,this.m03-=e.m03,this.m04-=e.m04,this.m05-=e.m05,this.m06-=e.m06,this.m07-=e.m07,this.m08-=e.m08,this.m09-=e.m09,this.m10-=e.m10,this.m11-=e.m11,this.m12-=e.m12,this.m13-=e.m13,this.m14-=e.m14,this.m15-=e.m15,this},n.multiply=function(e){var t=this.m00,n=this.m01,i=this.m02,r=this.m03,o=this.m04,a=this.m05,s=this.m06,c=this.m07,l=this.m08,u=this.m09,h=this.m10,f=this.m11,_=this.m12,p=this.m13,d=this.m14,m=this.m15,g=e.m00,v=e.m01,y=e.m02,x=e.m03;return this.m00=g*t+v*o+y*l+x*_,this.m01=g*n+v*a+y*u+x*p,this.m02=g*i+v*s+y*h+x*d,this.m03=g*r+v*c+y*f+x*m,g=e.m04,v=e.m05,y=e.m06,x=e.m07,this.m04=g*t+v*o+y*l+x*_,this.m05=g*n+v*a+y*u+x*p,this.m06=g*i+v*s+y*h+x*d,this.m07=g*r+v*c+y*f+x*m,g=e.m08,v=e.m09,y=e.m10,x=e.m11,this.m08=g*t+v*o+y*l+x*_,this.m09=g*n+v*a+y*u+x*p,this.m10=g*i+v*s+y*h+x*d,this.m11=g*r+v*c+y*f+x*m,g=e.m12,v=e.m13,y=e.m14,x=e.m15,this.m12=g*t+v*o+y*l+x*_,this.m13=g*n+v*a+y*u+x*p,this.m14=g*i+v*s+y*h+x*d,this.m15=g*r+v*c+y*f+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,r=t.z,o=Math.sqrt(n*n+i*i+r*r);if(Math.abs(o)0?(n=2*Math.sqrt(t+1),e.w=.25*n,e.x=(this.m06-this.m09)/n,e.y=(this.m08-this.m02)/n,e.z=(this.m01-this.m04)/n):this.m00>this.m05&&this.m00>this.m10?(n=2*Math.sqrt(1+this.m00-this.m05-this.m10),e.w=(this.m06-this.m09)/n,e.x=.25*n,e.y=(this.m01+this.m04)/n,e.z=(this.m08+this.m02)/n):this.m05>this.m10?(n=2*Math.sqrt(1+this.m05-this.m00-this.m10),e.w=(this.m08-this.m02)/n,e.x=(this.m01+this.m04)/n,e.y=.25*n,e.z=(this.m06+this.m09)/n):(n=2*Math.sqrt(1+this.m10-this.m00-this.m05),e.w=(this.m01-this.m04)/n,e.x=(this.m08+this.m02)/n,e.y=(this.m06+this.m09)/n,e.z=.25*n),e},n.fromRTS=function(e,t,n){var i=e.x,r=e.y,o=e.z,a=e.w,s=i+i,c=r+r,l=o+o,u=i*s,h=i*c,f=i*l,_=r*c,p=r*l,d=o*l,m=a*s,g=a*c,v=a*l,y=n.x,x=n.y,S=n.z;return this.m00=(1-(_+d))*y,this.m01=(h+v)*y,this.m02=(f-g)*y,this.m03=0,this.m04=(h-v)*x,this.m05=(1-(u+d))*x,this.m06=(p+m)*x,this.m07=0,this.m08=(f+g)*S,this.m09=(p-m)*S,this.m10=(1-(u+_))*S,this.m11=0,this.m12=t.x,this.m13=t.y,this.m14=t.z,this.m15=1,this},n.fromQuat=function(e){var t=e.x,n=e.y,i=e.z,r=e.w,o=t+t,a=n+n,s=i+i,c=t*o,l=n*o,u=n*a,h=i*o,f=i*a,_=i*s,p=r*o,d=r*a,m=r*s;return this.m00=1-u-_,this.m01=l+m,this.m02=h-d,this.m03=0,this.m04=l-m,this.m05=1-c-_,this.m06=f+p,this.m07=0,this.m08=h+d,this.m09=f-p,this.m10=1-c-u,this.m11=0,this.m12=0,this.m13=0,this.m14=0,this.m15=1,this},t}(st));Gn.IDENTITY=Object.freeze(new Gn);var Hn=new bn,Vn=new In;function jn(e,t,n,i,r,o,a,s,c,l,u,h,f,_,p,d){return new Gn(e,t,n,i,r,o,a,s,c,l,u,h,f,_,p,d)}Qt.fastDefine("cc.Mat4",Gn,{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=Gn,c.mat4=jn;var Wn=e("Vec2",function(e){function t(t,n){var i;return i=e.call(this)||this,t&&"object"==typeof t?(i.x=t.x,i.y=t.y):(i.x=t||0,i.y=n||0),i}Z(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&&(r=1/Math.sqrt(r),e.x=n*r,e.y=i*r),e},t.dot=function(e,t){return e.x*t.x+e.y*t.y},t.cross=function(e,t,n){return e instanceof bn?(e.x=e.y=0,e.z=t.x*n.y-t.y*n.x,e):e.x*t.y-e.y*t.x},t.lerp=function(e,t,n,i){var r=t.x,o=t.y;return e.x=r+i*(n.x-r),e.y=o+i*(n.y-o),e},t.random=function(e,t){t=t||1;var n=2*un()*Math.PI;return e.x=Math.cos(n)*t,e.y=Math.sin(n)*t,e},t.transformMat3=function(e,t,n){var i=t.x,r=t.y;return e.x=n.m00*i+n.m03*r+n.m06,e.y=n.m01*i+n.m04*r+n.m07,e},t.transformMat4=function(e,t,n){var i=t.x,r=t.y;return e.x=n.m00*i+n.m04*r+n.m12,e.y=n.m01*i+n.m05*r+n.m13,e},t.str=function(e){return"Vec2("+e.x+", "+e.y+")"},t.toArray=function(e,t,n){return void 0===n&&(n=0),e[n+0]=t.x,e[n+1]=t.y,e},t.fromArray=function(e,t,n){return void 0===n&&(n=0),e.x=t[n+0],e.y=t[n+1],e},t.strictEquals=function(e,t){return e.x===t.x&&e.y===t.y},t.equals=function(e,t,n){return void 0===n&&(n=tn),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(Xn,n);var i=t.dot(qn,Xn);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=tn),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=tn),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=on(this.x,e.x,t.x),this.y=on(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=on(i,-1,1),Math.acos(i)},n.signAngle=function(e){var t=this.angle(e);return this.cross(e)<0?-t:t},n.rotate=function(e){var t=this.x,n=this.y,i=Math.sin(e),r=Math.cos(e);return this.x=r*t-i*n,this.y=i*t+r*n,this},n.project=function(e){var t=this.dot(e)/e.dot(e);return this.x=e.x*t,this.y=e.y*t,this},n.transformMat4=function(e){var t=this.x,n=this.y;return this.x=e.m00*t+e.m04*n+e.m12,this.y=e.m01*t+e.m05*n+e.m13,this},t}(st));Wn.ZERO=Object.freeze(new Wn(0,0)),Wn.ONE=Object.freeze(new Wn(1,1)),Wn.NEG_ONE=Object.freeze(new Wn(-1,-1)),Wn.UNIT_X=Object.freeze(new Wn(1,0)),Wn.UNIT_Y=Object.freeze(new Wn(0,1));var qn=new Wn,Xn=new Wn;function Yn(e,t){return new Wn(e,t)}Qt.fastDefine("cc.Vec2",Wn,{x:0,y:0}),c.Vec2=Wn,c.v2=Yn;var Kn=e("Vec4",function(e){function t(t,n,i,r){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.w=t.w):(o.x=t||0,o.y=n||0,o.z=i||0,o.w=r||0),o}Z(t,e),t.clone=function(e){return new t(e.x,e.y,e.z,e.w)},t.copy=function(e,t){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e},t.set=function(e,t,n,i,r){return e.x=t,e.y=n,e.z=i,e.w=r,e},t.add=function(e,t,n){return e.x=t.x+n.x,e.y=t.y+n.y,e.z=t.z+n.z,e.w=t.w+n.w,e},t.subtract=function(e,t,n){return e.x=t.x-n.x,e.y=t.y-n.y,e.z=t.z-n.z,e.w=t.w-n.w,e},t.multiply=function(e,t,n){return e.x=t.x*n.x,e.y=t.y*n.y,e.z=t.z*n.z,e.w=t.w*n.w,e},t.divide=function(e,t,n){return e.x=t.x/n.x,e.y=t.y/n.y,e.z=t.z/n.z,e.w=t.w/n.w,e},t.ceil=function(e,t){return e.x=Math.ceil(t.x),e.y=Math.ceil(t.y),e.z=Math.ceil(t.z),e.w=Math.ceil(t.w),e},t.floor=function(e,t){return e.x=Math.floor(t.x),e.y=Math.floor(t.y),e.z=Math.floor(t.z),e.w=Math.floor(t.w),e},t.min=function(e,t,n){return e.x=Math.min(t.x,n.x),e.y=Math.min(t.y,n.y),e.z=Math.min(t.z,n.z),e.w=Math.min(t.w,n.w),e},t.max=function(e,t,n){return e.x=Math.max(t.x,n.x),e.y=Math.max(t.y,n.y),e.z=Math.max(t.z,n.z),e.w=Math.max(t.w,n.w),e},t.round=function(e,t){return e.x=Math.round(t.x),e.y=Math.round(t.y),e.z=Math.round(t.z),e.w=Math.round(t.w),e},t.multiplyScalar=function(e,t,n){return e.x=t.x*n,e.y=t.y*n,e.z=t.z*n,e.w=t.w*n,e},t.scaleAndAdd=function(e,t,n,i){return e.x=t.x+n.x*i,e.y=t.y+n.y*i,e.z=t.z+n.z*i,e.w=t.w+n.w*i,e},t.distance=function(e,t){var n=t.x-e.x,i=t.y-e.y,r=t.z-e.z,o=t.w-e.w;return Math.sqrt(n*n+i*i+r*r+o*o)},t.squaredDistance=function(e,t){var n=t.x-e.x,i=t.y-e.y,r=t.z-e.z,o=t.w-e.w;return n*n+i*i+r*r+o*o},t.len=function(e){var t=e.x,n=e.y,i=e.z,r=e.w;return Math.sqrt(t*t+n*n+i*i+r*r)},t.lengthSqr=function(e){var t=e.x,n=e.y,i=e.z,r=e.w;return t*t+n*n+i*i+r*r},t.negate=function(e,t){return e.x=-t.x,e.y=-t.y,e.z=-t.z,e.w=-t.w,e},t.inverse=function(e,t){return e.x=1/t.x,e.y=1/t.y,e.z=1/t.z,e.w=1/t.w,e},t.inverseSafe=function(e,t){var n=t.x,i=t.y,r=t.z,o=t.w;return Math.abs(n)0&&(a=1/Math.sqrt(a),e.x=n*a,e.y=i*a,e.z=r*a,e.w=o*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*un()*Math.PI,i=2*un()-1,r=Math.sqrt(1-i*i);return e.x=r*Math.cos(n)*t,e.y=r*Math.sin(n)*t,e.z=i*t,e.w=0,e},t.transformMat4=function(e,t,n){var i=t.x,r=t.y,o=t.z,a=t.w;return e.x=n.m00*i+n.m04*r+n.m08*o+n.m12*a,e.y=n.m01*i+n.m05*r+n.m09*o+n.m13*a,e.z=n.m02*i+n.m06*r+n.m10*o+n.m14*a,e.w=n.m03*i+n.m07*r+n.m11*o+n.m15*a,e},t.transformAffine=function(e,t,n){var i=t.x,r=t.y,o=t.z,a=t.w;return e.x=n.m00*i+n.m01*r+n.m02*o+n.m03*a,e.y=n.m04*i+n.m05*r+n.m06*o+n.m07*a,e.x=n.m08*i+n.m09*r+n.m10*o+n.m11*a,e.w=t.w,e},t.transformQuat=function(e,t,n){var i=t.x,r=t.y,o=t.z,a=n.x,s=n.y,c=n.z,l=n.w,u=l*i+s*o-c*r,h=l*r+c*i-a*o,f=l*o+a*r-s*i,_=-a*i-s*r-c*o;return e.x=u*l+_*-a+h*-c-f*-s,e.y=h*l+_*-s+f*-a-u*-c,e.z=f*l+_*-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=tn),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=tn),Math.abs(this.x-e.x)<=t*Math.max(1,Math.abs(this.x),Math.abs(e.x))&&Math.abs(this.y-e.y)<=t*Math.max(1,Math.abs(this.y),Math.abs(e.y))&&Math.abs(this.z-e.z)<=t*Math.max(1,Math.abs(this.z),Math.abs(e.z))&&Math.abs(this.w-e.w)<=t*Math.max(1,Math.abs(this.w),Math.abs(e.w))},n.equals4f=function(e,t,n,i,r){return void 0===r&&(r=tn),Math.abs(this.x-e)<=r*Math.max(1,Math.abs(this.x),Math.abs(e))&&Math.abs(this.y-t)<=r*Math.max(1,Math.abs(this.y),Math.abs(t))&&Math.abs(this.z-n)<=r*Math.max(1,Math.abs(this.z),Math.abs(n))&&Math.abs(this.w-i)<=r*Math.max(1,Math.abs(this.w),Math.abs(i))},n.strictEquals=function(e){return this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w},n.strictEquals4f=function(e,t,n,i){return this.x===e&&this.y===t&&this.z===n&&this.w===i},n.lerp=function(e,t){var n=this.x,i=this.y,r=this.z,o=this.w;return this.x=n+t*(e.x-n),this.y=i+t*(e.y-i),this.z=r+t*(e.z-r),this.w=o+t*(e.w-o),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=on(this.x,e.x,t.x),this.y=on(this.y,e.y,t.y),this.z=on(this.z,e.z,t.z),this.w=on(this.w,e.w,t.w),this},n.add=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this},n.add4f=function(e,t,n,i){return this.x+=e,this.y+=t,this.z+=n,this.w+=i,this},n.subtract=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this},n.subtract4f=function(e,t,n,i){return this.x-=e,this.y-=t,this.z-=n,this.w-=i,this},n.multiplyScalar=function(e){return"object"==typeof e&&console.warn("should use Vec4.multiply for vector * vector operation"),this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},n.multiply=function(e){return"object"!=typeof e&&console.warn("should use Vec4.scale for vector * scalar operation"),this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this},n.multiply4f=function(e,t,n,i){return this.x*=e,this.y*=t,this.z*=n,this.w*=i,this},n.divide=function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this},n.divide4f=function(e,t,n,i){return this.x/=e,this.y/=t,this.z/=n,this.w/=i,this},n.negative=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},n.dot=function(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w},n.cross=function(e){var t=this.x,n=this.y,i=this.z,r=e.x,o=e.y,a=e.z;return this.x=n*a-i*o,this.y=i*r-t*a,this.z=t*o-n*r,this},n.length=function(){var e=this.x,t=this.y,n=this.z,i=this.w;return Math.sqrt(e*e+t*t+n*n+i*i)},n.lengthSqr=function(){var e=this.x,t=this.y,n=this.z,i=this.w;return e*e+t*t+n*n+i*i},n.normalize=function(){var e=this.x,t=this.y,n=this.z,i=this.w,r=e*e+t*t+n*n+i*i;return r>0&&(r=1/Math.sqrt(r),this.x=e*r,this.y=t*r,this.z=n*r,this.w=i*r),this},n.transformMat4=function(e){var t=this.x,n=this.y,i=this.z,r=this.w;return this.x=e.m00*t+e.m04*n+e.m08*i+e.m12*r,this.y=e.m01*t+e.m05*n+e.m09*i+e.m13*r,this.z=e.m02*t+e.m06*n+e.m10*i+e.m14*r,this.w=e.m03*t+e.m07*n+e.m11*i+e.m15*r,this},t}(st));function Qn(e,t,n,i){return new Kn(e,t,n,i)}Kn.ZERO=Object.freeze(new Kn(0,0,0,0)),Kn.ONE=Object.freeze(new Kn(1,1,1,1)),Kn.NEG_ONE=Object.freeze(new Kn(-1,-1,-1,-1)),Qt.fastDefine("cc.Vec4",Kn,{x:0,y:0,z:0,w:0}),c.Vec4=Kn,c.v4=Qn,z(Wn,"Vec2",[{name:"sub",newName:"subtract",target:Wn,targetName:"Vec2"},{name:"mul",newName:"multiply",target:Wn,targetName:"Vec2"},{name:"div",newName:"divide",target:Wn,targetName:"Vec2"},{name:"dist",newName:"distance",target:Wn,targetName:"Vec2"},{name:"sqrDist",newName:"squaredDistance",target:Wn,targetName:"Vec2"},{name:"mag",newName:"len",target:Wn,targetName:"Vec2"},{name:"sqrMag",newName:"lengthSqr",target:Wn,targetName:"Vec2"},{name:"scale",newName:"multiplyScalar",target:Wn,targetName:"Vec2"},{name:"exactEquals",newName:"strictEquals",target:Wn,targetName:"Vec2"}]),z(Wn.prototype,"Vec2",[{name:"mag",newName:"length",target:Wn.prototype,targetName:"Vec2"},{name:"magSqr",newName:"lengthSqr",target:Wn.prototype,targetName:"Vec2"},{name:"scale",newName:"multiplyScalar",target:Wn.prototype,targetName:"Vec2"},{name:"exactEquals",newName:"strictEquals",target:Wn.prototype,targetName:"Vec2"}]),z(bn,"Vec3",[{name:"sub",newName:"subtract",target:bn,targetName:"Vec3"},{name:"mul",newName:"multiply",target:bn,targetName:"Vec3"},{name:"div",newName:"divide",target:bn,targetName:"Vec3"},{name:"dist",newName:"distance",target:bn,targetName:"Vec3"},{name:"sqrDist",newName:"squaredDistance",target:bn,targetName:"Vec3"},{name:"mag",newName:"len",target:bn,targetName:"Vec3"},{name:"sqrMag",newName:"lengthSqr",target:bn,targetName:"Vec3"},{name:"scale",newName:"multiplyScalar",target:bn,targetName:"Vec3"},{name:"exactEquals",newName:"strictEquals",target:bn,targetName:"Vec3"}]),z(bn.prototype,"Vec3",[{name:"mag",newName:"length",target:bn.prototype,targetName:"Vec3"},{name:"magSqr",newName:"lengthSqr",target:bn.prototype,targetName:"Vec3"},{name:"scale",newName:"multiplyScalar",target:bn.prototype,targetName:"Vec3"},{name:"exactEquals",newName:"strictEquals",target:bn.prototype,targetName:"Vec3"}]),z(Kn,"Vec4",[{name:"sub",newName:"subtract",target:Kn,targetName:"Vec4"},{name:"mul",newName:"multiply",target:Kn,targetName:"Vec4"},{name:"div",newName:"divide",target:Kn,targetName:"Vec4"},{name:"dist",newName:"distance",target:Kn,targetName:"Vec4"},{name:"sqrDist",newName:"squaredDistance",target:Kn,targetName:"Vec4"},{name:"mag",newName:"len",target:Kn,targetName:"Vec4"},{name:"sqrMag",newName:"lengthSqr",target:Kn,targetName:"Vec4"},{name:"scale",newName:"multiplyScalar",target:Kn,targetName:"Vec4"},{name:"exactEquals",newName:"strictEquals",target:Kn,targetName:"Vec4"}]),z(Kn.prototype,"Vec4",[{name:"mag",newName:"length",target:Kn.prototype,targetName:"Vec4"},{name:"magSqr",newName:"lengthSqr",target:Kn.prototype,targetName:"Vec4"},{name:"scale",newName:"multiplyScalar",target:Kn.prototype,targetName:"Vec4"},{name:"exactEquals",newName:"strictEquals",target:Kn.prototype,targetName:"Vec4"}]),z(Mn,"Quat",[{name:"mag",newName:"len",target:Mn,targetName:"Quat"},{name:"mul",newName:"multiply",target:Mn,targetName:"Quat"},{name:"sqrMag",newName:"lengthSqr",target:Mn,targetName:"Quat"},{name:"scale",newName:"multiplyScalar",target:Mn,targetName:"Quat"},{name:"exactEquals",newName:"strictEquals",target:Mn,targetName:"Quat"}]),z(Mn.prototype,"Quat",[{name:"scale",newName:"multiplyScalar",target:Mn.prototype,targetName:"Quat"},{name:"exactEquals",newName:"strictEquals",target:Mn.prototype,targetName:"Quat"}]),z(An,"Color",[{name:"sub",newName:"subtract",target:An,targetName:"Color"},{name:"mul",newName:"multiply",target:An,targetName:"Color"},{name:"div",newName:"divide",target:An,targetName:"Color"},{name:"exactEquals",newName:"strictEquals",target:An,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,r=n+this.height,o=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*r+e.m12,u=e.m01*t+e.m05*r+e.m13,h=e.m00*i+e.m04*r+e.m12,f=e.m01*i+e.m05*r+e.m13,_=Math.min(o,s,l,h),p=Math.max(o,s,l,h),d=Math.min(a,c,u,f),m=Math.max(a,c,u,f);return this.x=_,this.y=d,this.width=p-_,this.height=m-d,this},n.transformMat4ToPoints=function(e,t,n,i,r){var o=this.x,a=this.y,s=o+this.width,c=a+this.height;t.x=e.m00*o+e.m04*a+e.m12,t.y=e.m01*o+e.m05*a+e.m13,r.x=e.m00*s+e.m04*a+e.m12,r.y=e.m01*s+e.m05*a+e.m13,n.x=e.m00*o+e.m04*c+e.m12,n.y=e.m01*o+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},K(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 Wn(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 Wn(this.x,this.y)},set:function(e){this.x=e.x,this.y=e.y}},{key:"size",get:function(){return new Jn(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}(st));function ti(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 ei(e,t,n,i)}Qt.fastDefine("cc.Rect",ei,{x:0,y:0,width:0,height:0}),c.Rect=ei,c.rect=ti;var ni=e("MATH_FLOAT_ARRAY",Float64Array),ii=e("MathBase",function(e){function t(){return e.apply(this,arguments)||this}return Z(t,e),t.createFloatArray=function(e){return new ni(e)},K(t,[{key:"array",get:function(){return this._array}}]),t}(st)),ri=Object.freeze({__proto__:null,bits:a,Vec2:Wn,v2:Yn,Vec3:bn,v3:Pn,Vec4:Kn,v4:Qn,Quat:Mn,quat:kn,Mat3:In,Mat4:Gn,mat4:jn,AffineTransform:Zn,Size:Jn,size:$n,Rect:ei,rect:ti,Color:An,color:Cn,EPSILON:tn,equals:nn,approx:rn,clamp:on,clamp01:an,lerp:sn,toRadian:cn,toDegree:ln,random:un,randomRange:hn,randomRangeInt:fn,pseudoRandom:_n,pseudoRandomRange:pn,pseudoRandomRangeInt:dn,nextPow2:mn,repeat:gn,pingPong:vn,inverseLerp:yn,absMaxComponent:xn,absMax:Sn,enumerableProps:Tn,MATH_FLOAT_ARRAY:ni,MathBase:ii});e("math",ri);var oi,ai,si,ci,li,ui,hi,fi,_i,pi,di,mi,gi,vi,yi,xi,Si,Ti,Ei,Ai,Ci,bi,wi,Ri,Pi,Ii,Di,Oi,Mi,Ni,Li,Fi,Bi,zi,ki,Ui,Gi,Hi,Vi,ji,Wi,qi=function(e,t,n){for(var i=0;i0&&0==(e&e-1)}function to(e,t,n,i){if(!Qr[e].isCompressed)return t*n*i*Qr[e].size;switch(e){case ui.BC1:case ui.BC1_ALPHA:case ui.BC1_SRGB:case ui.BC1_SRGB_ALPHA:return Math.ceil(t/4)*Math.ceil(n/4)*8*i;case ui.BC2:case ui.BC2_SRGB:case ui.BC3:case ui.BC3_SRGB:case ui.BC4:case ui.BC4_SNORM:case ui.BC6H_SF16:case ui.BC6H_UF16:case ui.BC7:case ui.BC7_SRGB:return Math.ceil(t/4)*Math.ceil(n/4)*16*i;case ui.BC5:case ui.BC5_SNORM:return Math.ceil(t/4)*Math.ceil(n/4)*32*i;case ui.ETC_RGB8:case ui.ETC2_RGB8:case ui.ETC2_SRGB8:case ui.ETC2_RGB8_A1:case ui.EAC_R11:case ui.EAC_R11SN:return Math.ceil(t/4)*Math.ceil(n/4)*8*i;case ui.ETC2_RGBA8:case ui.ETC2_SRGB8_A1:case ui.EAC_RG11:case ui.EAC_RG11SN:return Math.ceil(t/4)*Math.ceil(n/4)*16*i;case ui.PVRTC_RGB2:case ui.PVRTC_RGBA2:case ui.PVRTC2_2BPP:return Math.ceil(Math.max(t,16)*Math.max(n,8)/4)*i;case ui.PVRTC_RGB4:case ui.PVRTC_RGBA4:case ui.PVRTC2_4BPP:return Math.ceil(Math.max(t,8)*Math.max(n,8)/2)*i;case ui.ASTC_RGBA_4X4:case ui.ASTC_SRGBA_4X4:return Math.ceil(t/4)*Math.ceil(n/4)*16*i;case ui.ASTC_RGBA_5X4:case ui.ASTC_SRGBA_5X4:return Math.ceil(t/5)*Math.ceil(n/4)*16*i;case ui.ASTC_RGBA_5X5:case ui.ASTC_SRGBA_5X5:return Math.ceil(t/5)*Math.ceil(n/5)*16*i;case ui.ASTC_RGBA_6X5:case ui.ASTC_SRGBA_6X5:return Math.ceil(t/6)*Math.ceil(n/5)*16*i;case ui.ASTC_RGBA_6X6:case ui.ASTC_SRGBA_6X6:return Math.ceil(t/6)*Math.ceil(n/6)*16*i;case ui.ASTC_RGBA_8X5:case ui.ASTC_SRGBA_8X5:return Math.ceil(t/8)*Math.ceil(n/5)*16*i;case ui.ASTC_RGBA_8X6:case ui.ASTC_SRGBA_8X6:return Math.ceil(t/8)*Math.ceil(n/6)*16*i;case ui.ASTC_RGBA_8X8:case ui.ASTC_SRGBA_8X8:return Math.ceil(t/8)*Math.ceil(n/8)*16*i;case ui.ASTC_RGBA_10X5:case ui.ASTC_SRGBA_10X5:return Math.ceil(t/10)*Math.ceil(n/5)*16*i;case ui.ASTC_RGBA_10X6:case ui.ASTC_SRGBA_10X6:return Math.ceil(t/10)*Math.ceil(n/6)*16*i;case ui.ASTC_RGBA_10X8:case ui.ASTC_SRGBA_10X8:return Math.ceil(t/10)*Math.ceil(n/8)*16*i;case ui.ASTC_RGBA_10X10:case ui.ASTC_SRGBA_10X10:return Math.ceil(t/10)*Math.ceil(n/10)*16*i;case ui.ASTC_RGBA_12X10:case ui.ASTC_SRGBA_12X10:return Math.ceil(t/12)*Math.ceil(n/10)*16*i;case ui.ASTC_RGBA_12X12:case ui.ASTC_SRGBA_12X12:return Math.ceil(t/12)*Math.ceil(n/12)*16*i;default:return 0}}function no(e,t,n,i,r){for(var o=0,a=0;a>1,1),n=Math.max(n>>1,1);return o}var io=[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 ro(e){return io[e]||0}function oo(e){var t=e.size/e.count;switch(e.type){case hi.UNORM:case hi.UINT:switch(t){case 1:return Uint8Array;case 2:return Uint16Array;case 4:return Uint32Array}break;case hi.SNORM:case hi.INT:switch(t){case 1:return Int8Array;case 2:return Int16Array;case 4:return Int32Array}break;case hi.FLOAT:return Float32Array}return Float32Array}var ao=Object.freeze({__proto__:null,get ObjectType(){return oi},get Status(){return ai},get API(){return si},get SurfaceTransform(){return ci},get Feature(){return li},get Format(){return ui},get FormatType(){return hi},get Type(){return fi},get BufferUsageBit(){return _i},get BufferFlagBit(){return pi},get MemoryAccessBit(){return di},get MemoryUsageBit(){return mi},get TextureType(){return gi},get TextureUsageBit(){return vi},get TextureFlagBit(){return yi},get SampleCount(){return xi},get VsyncMode(){return Si},get Filter(){return Ti},get Address(){return Ei},get ComparisonFunc(){return Ai},get StencilOp(){return Ci},get BlendFactor(){return bi},get BlendOp(){return wi},get ColorMask(){return Ri},get ShaderStageFlagBit(){return Pi},get LoadOp(){return Ii},get StoreOp(){return Di},get AccessType(){return Oi},get ResolveMode(){return Mi},get PipelineBindPoint(){return Ni},get PrimitiveMode(){return Li},get PolygonMode(){return Fi},get ShadeModel(){return Bi},get CullMode(){return zi},get DynamicStateFlagBit(){return ki},get StencilFace(){return Ui},get DescriptorType(){return Gi},get QueueType(){return Hi},get QueryType(){return Vi},get CommandBufferType(){return ji},get ClearFlagBit(){return Wi},Size:Yi,DeviceCaps:Ki,Offset:Qi,Rect:Zi,Extent:Ji,TextureSubresLayers:$i,TextureSubresRange:er,TextureCopy:tr,TextureBlit:nr,BufferTextureCopy:ir,Viewport:rr,Color:or,BindingMappingInfo:ar,SwapchainInfo:sr,DeviceInfo:cr,BufferInfo:lr,BufferViewInfo:ur,DrawInfo:hr,DispatchInfo:fr,IndirectBuffer:_r,TextureInfo:pr,TextureViewInfo:dr,SamplerInfo:mr,Uniform:gr,UniformBlock:vr,UniformSamplerTexture:yr,UniformSampler:xr,UniformTexture:Sr,UniformStorageImage:Tr,UniformStorageBuffer:Er,UniformInputAttachment:Ar,ShaderStage:Cr,Attribute:br,ShaderInfo:wr,InputAssemblerInfo:Rr,ColorAttachment:Pr,DepthStencilAttachment:Ir,SubpassInfo:Dr,SubpassDependency:Or,RenderPassInfo:Mr,GlobalBarrierInfo:Nr,TextureBarrierInfo:Lr,FramebufferInfo:Fr,DescriptorSetLayoutBinding:Br,DescriptorSetLayoutInfo:zr,DescriptorSetInfo:kr,PipelineLayoutInfo:Ur,InputState:Gr,CommandBufferInfo:Hr,QueueInfo:Vr,QueryPoolInfo:jr,FormatInfo:Wr,MemoryStatus:qr,DynamicStencilStates:Xr,DynamicStates:Yr,GFXObject:Kr,get AttributeName(){return Xi},FormatInfos:Qr,DESCRIPTOR_BUFFER_TYPE:Zr,DESCRIPTOR_SAMPLER_TYPE:Jr,DESCRIPTOR_DYNAMIC_TYPE:$r,DRAW_INFO_SIZE:28,IsPowerOf2:eo,FormatSize:to,FormatSurfaceSize:no,GetTypeSize:ro,getTypedArrayConstructor:oo}),so=function(e){function t(){var t;return(t=e.call(this,oi.BUFFER)||this)._usage=_i.NONE,t._memUsage=mi.NONE,t._size=0,t._stride=1,t._count=0,t._flags=pi.NONE,t._isBufferView=!1,t}return Z(t,e),K(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}(Kr),co=function(e){function t(){var t;return(t=e.call(this,oi.COMMAND_BUFFER)||this)._queue=null,t._type=ji.PRIMARY,t._numDrawCalls=0,t._numInstances=0,t._numTris=0,t}return Z(t,e),K(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}(Kr),lo=function(){function e(){this._gfxAPI=si.UNKNOWN,this._renderer="",this._vendor="",this._features=new Array(li.COUNT),this._queue=null,this._cmdBuff=null,this._numDrawCalls=0,this._numInstances=0,this._numTris=0,this._memoryStatus=new qr,this._caps=new Ki,this._bindingMappingInfo=new ar,this._samplers=new Map,this._globalBarriers=new Map,this._textureBarriers=new Map}return e.prototype.hasFeature=function(e){return this._features[e]},K(e,[{key:"gfxAPI",get:function(){return this._gfxAPI}},{key:"queue",get:function(){return this._queue}},{key:"commandBuffer",get:function(){return this._cmdBuff}},{key:"renderer",get:function(){return this._renderer}},{key:"vendor",get:function(){return this._vendor}},{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:"bindingMappingInfo",get:function(){return this._bindingMappingInfo}}]),e}();lo.canvas=void 0;var uo=function(e){function t(){var t;return(t=e.call(this,oi.SWAPCHAIN)||this)._transform=ci.IDENTITY,t._colorTexture=null,t._depthStencilTexture=null,t}return Z(t,e),K(t,[{key:"colorTexture",get:function(){return this._colorTexture}},{key:"depthStencilTexture",get:function(){return this._depthStencilTexture}},{key:"surfaceTransform",get:function(){return this._transform}},{key:"width",get:function(){return this._colorTexture.width}},{key:"height",get:function(){return this._colorTexture.height}}]),t}(Kr),ho=function(e){function t(){var t;return(t=e.call(this,oi.FRAMEBUFFER)||this)._renderPass=null,t._colorTextures=[],t._depthStencilTexture=null,t}return Z(t,e),K(t,[{key:"renderPass",get:function(){return this._renderPass}},{key:"colorTextures",get:function(){return this._colorTextures}},{key:"depthStencilTexture",get:function(){return this._depthStencilTexture}}]),t}(Kr),fo=String.prototype.charCodeAt;function _o(e){return this[e]}function po(e,t){for(var n=e.length,i=t^n,r=0,o="string"==typeof e?fo:_o;n>=4;){var a=255&o.call(e,r)|(255&o.call(e,++r))<<8|(255&o.call(e,++r))<<16|(255&o.call(e,++r))<<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,++r}switch(n){case 3:i^=(255&o.call(e,r+2))<<16;case 2:i^=(255&o.call(e,r+1))<<8;case 1:i=1540483477*(65535&(i^=255&o.call(e,r)))+((1540483477*(i>>>16)&65535)<<16)}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0}var mo=function(e){function t(){var t;return(t=e.call(this,oi.INPUT_ASSEMBLER)||this)._attributes=[],t._attributesHash=0,t._vertexBuffers=[],t._indexBuffer=null,t._indirectBuffer=null,t._drawInfo=new hr,t}Z(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>0,t.magFilter=(3&e)>>2,t.mipFilter=(3&e)>>4,t.addressU=(3&e)>>6,t.addressV=(3&e)>>8,t.addressW=(3&e)>>10,t.maxAnisotropy=(15&e)>>12,t.cmpFunc=(7&e)>>16,t},K(t,[{key:"info",get:function(){return this._info}},{key:"hash",get:function(){return this._hash}}]),t}(Kr),Po=function(e){function t(){var t;return(t=e.call(this,oi.SHADER)||this)._name="",t._stages=[],t._attributes=[],t._blocks=[],t._samplers=[],t}return Z(t,e),K(t,[{key:"name",get:function(){return this._name}},{key:"attributes",get:function(){return this._attributes}},{key:"blocks",get:function(){return this._blocks}},{key:"samplers",get:function(){return this._samplers}}]),t}(Kr),Io=function(e){function t(){var t;return(t=e.call(this,oi.TEXTURE)||this)._type=gi.TEX2D,t._usage=vi.NONE,t._format=ui.UNKNOWN,t._width=0,t._height=0,t._depth=1,t._layerCount=1,t._levelCount=1,t._samples=xi.ONE,t._flags=yi.NONE,t._isPowerOf2=!1,t._size=0,t}return Z(t,e),K(t,[{key:"type",get:function(){return this._type}},{key:"usage",get:function(){return this._usage}},{key:"format",get:function(){return this._format}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"depth",get:function(){return this._depth}},{key:"layerCount",get:function(){return this._layerCount}},{key:"levelCount",get:function(){return this._levelCount}},{key:"samples",get:function(){return this._samples}},{key:"flags",get:function(){return this._flags}},{key:"size",get:function(){return this._size}}]),t}(Kr),Do=function(e){function t(t,n){var i;return(i=e.call(this,oi.GLOBAL_BARRIER)||this)._info=new Nr,i._hash=0,i._info.copy(t),i._hash=n,i}return Z(t,e),t.computeHash=function(e){for(var t="prev:",n=0;nHo.x?Ho.x:e.x,e.y=e.y>Ho.y?Ho.y:e.y,e.z=e.z>Ho.z?Ho.z:e.z,e}function Xo(e,t,n){bn.set(Bo,n.orientation.m00,n.orientation.m01,n.orientation.m02),bn.set(zo,n.orientation.m03,n.orientation.m04,n.orientation.m05),bn.set(ko,n.orientation.m06,n.orientation.m07,n.orientation.m08),Vo[0]=Bo,Vo[1]=zo,Vo[2]=ko,jo[0]=n.halfExtents.x,jo[1]=n.halfExtents.y,jo[2]=n.halfExtents.z,bn.subtract(Uo,t,n.center),bn.set(e,n.center.x,n.center.y,n.center.z);for(var i=0;i<3;i++){var r=bn.dot(Uo,Vo[i]);r>jo[i]&&(r=jo[i]),r<-jo[i]&&(r=-jo[i]),e.x+=r*Vo[i].x,e.y+=r*Vo[i].y,e.z+=r*Vo[i].z}return e}var Yo=Object.freeze({__proto__:null,point_plane:Wo,pt_point_plane:function(e,t,n){var i=Wo(t,n);return bn.subtract(e,t,bn.multiplyScalar(e,n.n,i))},pt_point_aabb:qo,pt_point_obb:Xo,pt_point_line:function(e,t,n,i){bn.subtract(Bo,n,i);var r=Bo,o=bn.lengthSqr(r);if(0==o)bn.copy(e,n);else{bn.subtract(Bo,t,n);var a=bn.dot(Bo,r)/o;a<0?bn.copy(e,n):a>1?bn.copy(e,i):bn.scaleAndAdd(e,n,r,a)}}}),Ko={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},Qo=function(){function e(e,t,n,i,r,o){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===o&&(o=-1),this.s=void 0,this.e=void 0,this._type=void 0,this._type=Ko.SHAPE_LINE,this.s=new bn(e,t,n),this.e=new bn(i,r,o)}return e.create=function(t,n,i,r,o,a){return new e(t,n,i,r,o,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 bn.copy(e.s,t.s),bn.copy(e.e,t.e),e},e.fromPoints=function(e,t,n){return bn.copy(e.s,t),bn.copy(e.e,n),e},e.set=function(e,t,n,i,r,o,a){return e.s.x=t,e.s.y=n,e.s.z=i,e.e.x=r,e.e.y=o,e.e.z=a,e},e.len=function(e){return bn.distance(e.s,e.e)},e.prototype.length=function(){return bn.distance(this.s,this.e)},K(e,[{key:"type",get:function(){return this._type}}]),e}(),Zo=function(){function e(e,t,n,i,r,o){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===o&&(o=-1),this.o=void 0,this.d=void 0,this._type=void 0,this._type=Ko.SHAPE_RAY,this.o=new bn(e,t,n),this.d=new bn(i,r,o)}return e.create=function(t,n,i,r,o,a){return void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===o&&(o=0),void 0===a&&(a=1),new e(t,n,i,r,o,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 bn.copy(e.o,t.o),bn.copy(e.d,t.d),e},e.fromPoints=function(e,t,n){return bn.copy(e.o,t),bn.normalize(e.d,bn.subtract(e.d,n,t)),e},e.set=function(e,t,n,i,r,o,a){return e.o.x=t,e.o.y=n,e.o.z=i,e.d.x=r,e.d.y=o,e.d.z=a,e},e.prototype.computeHit=function(e,t){bn.normalize(e,this.d),bn.scaleAndAdd(e,this.o,e,t)},K(e,[{key:"type",get:function(){return this._type}}]),e}(),Jo=new bn,$o=new bn,ea=new bn,ta=new bn;function na(e){return Math.max(Math.max(e.x,e.y),e.z)}var ia,ra=function(){function e(e,t,n,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=1),this._center=new bn(0,0,0),this._radius=0,this._type=void 0,this._type=Ko.SHAPE_SPHERE,this._center=new bn(e,t,n),this._radius=i}e.create=function(t,n,i,r){return new e(t,n,i,r)},e.clone=function(t){return new e(t.center.x,t.center.y,t.center.z,t.radius)},e.copy=function(e,t){return bn.copy(e.center,t.center),e.radius=t.radius,e},e.fromPoints=function(e,t,n){return bn.multiplyScalar(e.center,bn.add(Jo,t,n),.5),e.radius=.5*bn.subtract(Jo,n,t).length(),e},e.set=function(e,t,n,i,r){return e.center.x=t,e.center.y=n,e.center.z=i,e.radius=r,e};var t=e.prototype;return t.destroy=function(){},t.clone=function(){return e.clone(this)},t.copy=function(t){return e.copy(this,t)},t.getBoundary=function(e,t){bn.set(e,this.center.x-this.radius,this.center.y-this.radius,this.center.z-this.radius),bn.set(t,this.center.x+this.radius,this.center.y+this.radius,this.center.z+this.radius)},t.transform=function(e,t,n,i,r){bn.transformMat4(r.center,this.center,e),r.radius=this.radius*na(i)},t.translateAndRotate=function(e,t,n){bn.transformMat4(n.center,this.center,e)},t.setScale=function(e,t){t.radius=this.radius*na(e)},t.mergePoint=function(e){this.radius<0&&(this.center.set(e),this.radius=0),bn.subtract($o,e,this.center);var t=$o.length();if(t>this.radius){var n=.5*(t-this.radius);this.radius+=n,bn.multiplyScalar($o,$o,n/t),bn.add(this.center,this.center,$o)}},t.mergePoints=function(e){var t=e.length;if(!(t<1)){this.radius=-1;for(var n=0;n-Number.EPSILON))return 0;var r=1/i;bn.subtract(ua,e.o,t.a);var o=bn.dot(ua,la)*r;if(o<0||o>1)return 0;bn.cross(ha,ua,sa);var a=bn.dot(e.d,ha)*r;if(a<0||o+a>1)return 0;var s=bn.dot(ca,ha)*r;return s<0?0:s}),ma=function(){var e=new bn(0,0,0);return function(t,n){var i=n.radius,r=n.center,o=t.o,a=t.d,s=i*i;bn.subtract(e,r,o);var c=e.lengthSqr(),l=bn.dot(e,a),u=s-(c-l*l);if(u<0)return 0;var h=Math.sqrt(u),f=cd?0:p>0?p:d}var ya,xa,Sa,Ta,Ea=function(){var e=new bn,t=new bn,n=new bn,i=new bn,r=new bn,o=new bn,a=new bn,s=new Array(3),c=new Array(3),l=new Array(3),u=new Array(6);return function(h,f){s[0]=f.halfExtents.x,s[1]=f.halfExtents.y,s[2]=f.halfExtents.z,e=f.center,t=h.o,n=h.d,bn.set(i,f.orientation.m00,f.orientation.m01,f.orientation.m02),bn.set(r,f.orientation.m03,f.orientation.m04,f.orientation.m05),bn.set(o,f.orientation.m06,f.orientation.m07,f.orientation.m08),bn.subtract(a,e,t),c[0]=bn.dot(i,n),c[1]=bn.dot(r,n),c[2]=bn.dot(o,n),l[0]=bn.dot(i,a),l[1]=bn.dot(r,a),l[2]=bn.dot(o,a);for(var _=0;_<3;++_){if(0===c[_]){if(-l[_]-s[_]>0||-l[_]+s[_]<0)return 0;c[_]=1e-7}u[2*_+0]=(l[_]+s[_])/c[_],u[2*_+1]=(l[_]-s[_])/c[_]}var p=Math.max(Math.max(Math.min(u[0],u[1]),Math.min(u[2],u[3])),Math.min(u[4],u[5])),d=Math.min(Math.min(Math.max(u[0],u[1]),Math.max(u[2],u[3])),Math.max(u[4],u[5]));return d<0||p>d?0:p>0?p:d}}(),Aa=function(){var e=new bn,t=new bn,n=new bn,i=new bn,r=new bn,o=new bn,a=new bn,s=new ra;return function(c,l){var u=l.radius*l.radius,h=bn.normalize(e,c.d),f=l.ellipseCenter0,_=l.ellipseCenter1,p=bn.subtract(t,_,f);if(p.equals(bn.ZERO))return s.radius=l.radius,s.center.set(l.ellipseCenter0),cs.raySphere(c,s);var d=c.o,m=bn.subtract(n,d,f),g=bn.cross(i,h,p),v=g.lengthSqr();if(0===v){s.radius=l.radius;var y=bn.subtract(r,_,d);return m.lengthSqr()=0&&R<=1?A:R<0?(s.radius=l.radius,s.center.set(l.ellipseCenter0),cs.raySphere(c,s)):R>1?(s.radius=l.radius,s.center.set(l.ellipseCenter1),cs.raySphere(c,s)):0}}(),Ca=(ya=oa.create(),xa={distance:1/0,doubleSided:!1,mode:ia.ANY},Sa=0,Ta=function(e,t,n,i,r,o){e===ia.CLOSEST?(Sa>t||0===Sa)&&(Sa=t,o&&(0===o.length?o.push({distance:t,vertexIndex0:n/3,vertexIndex1:i/3,vertexIndex2:r/3}):(o[0].distance=t,o[0].vertexIndex0=n/3,o[0].vertexIndex1=i/3,o[0].vertexIndex2=r/3))):(Sa=t,o&&o.push({distance:t,vertexIndex0:n/3,vertexIndex1:i/3,vertexIndex2:r/3}))},function(e,t,n){if(Sa=0,0===t.geometricInfo.positions.length)return Sa;var i=void 0===n?xa:n;if(va(e,t.geometricInfo.boundingBox.min,t.geometricInfo.boundingBox.max)){var r=t.primitiveMode,o=t.geometricInfo;!function(e,t,n,i,r){if(n===Li.TRIANGLE_LIST)for(var o=t.length,a=0;ar.distance)&&(Ta(r.mode,u,s,c,l,r.result),r.mode===ia.ANY))return u}else if(n===Li.TRIANGLE_STRIP)for(var h=t.length-2,f=0,_=0;_r.distance)&&(Ta(r.mode,g,p,d,m,r.result),r.mode===ia.ANY))return g}else if(n===Li.TRIANGLE_FAN){var v=t.length-1,y=3*t[0];bn.set(ya.a,e[y],e[y+1],e[y+2]);for(var x=1;xr.distance)&&(Ta(r.mode,E,y,S,T,r.result),r.mode===ia.ANY))return E}}}(o.positions,o.indices,r,e,i)}return Sa}),ba=function(){var e=0,t={distance:1/0,doubleSided:!1,mode:ia.ANY};return function(n,i,r){e=0;var o=void 0===r?t:r,a=i.renderingSubMeshes.length,s=i.struct.minPosition,c=i.struct.maxPosition;if(s&&c&&!va(n,s,c))return e;for(var l=0;lh)&&(e=h,o.subIndices&&(o.subIndices[0]=l));else if(e=h,o.subIndices&&o.subIndices.push(l),o.mode===ia.ANY)return h}return e&&o.mode===ia.CLOSEST&&(o.result&&(o.result[0].distance=e,o.result.length=1),o.subIndices&&(o.subIndices.length=1)),e}}(),wa=function(){var e=0,t={distance:1/0,doubleSided:!1,mode:ia.ANY},n=new Zo,i=new Gn;return function(r,o,a){e=0;var s=void 0===a?t:a,c=o.worldBounds;if(c&&!ga(r,c))return e;Zo.copy(n,r),o.node&&(Gn.invert(i,o.node.getWorldMatrix(i)),bn.transformMat4(n.o,r.o,i),bn.transformMat4Normal(n.d,r.d,i));for(var l=o.subModels,u=0;uf)&&(e=f,s.subIndices&&(s.subIndices[0]=u));else if(e=f,s.subIndices&&s.subIndices.push(u),s.mode===ia.ANY)return f}return e&&s.mode===ia.CLOSEST&&(s.result&&(s.result[0].distance=e,s.result.length=1),s.subIndices&&(s.subIndices.length=1)),e}}(),Ra=function(){var e=new bn(0,0,0);return function(t,n){bn.subtract(e,t.e,t.s);var i=(n.d-bn.dot(t.s,n.n))/bn.dot(e,n.n);return i<0||i>1?0:i}}(),Pa=function(){var e=new bn(0,0,0),t=new bn(0,0,0),n=new bn(0,0,0),i=new bn(0,0,0),r=new bn(0,0,0),o=new bn(0,0,0);return function(a,s,c){bn.subtract(e,s.b,s.a),bn.subtract(t,s.c,s.a),bn.subtract(n,a.s,a.e),bn.cross(r,e,t);var l=bn.dot(n,r);if(l<=0)return 0;bn.subtract(i,a.s,s.a);var u=bn.dot(i,r);if(u<0||u>l)return 0;bn.cross(o,n,i);var h=bn.dot(t,o);if(h<0||h>l)return 0;var f=-bn.dot(e,o);if(f<0||h+f>l)return 0;if(c){var _=1/l,p=1-(h*=_)-(f*=_);bn.set(c,s.a.x*p+s.b.x*h+s.c.x*f,s.a.y*p+s.b.y*h+s.c.y*f,s.a.z*p+s.b.z*h+s.c.z*f)}return 1}}(),Ia=new Zo;function Da(e,t){Ia.o.set(e.s),bn.subtract(Ia.d,e.e,e.s),Ia.d.normalize();var n=ga(Ia,t);return n<=e.length()?n:0}function Oa(e,t){Ia.o.set(e.s),bn.subtract(Ia.d,e.e,e.s),Ia.d.normalize();var n=Ea(Ia,t);return n<=e.length()?n:0}function Ma(e,t){Ia.o.set(e.s),bn.subtract(Ia.d,e.e,e.s),Ia.d.normalize();var n=ma(Ia,t);return n<=e.length()?n:0}var Na,La,Fa,Ba,za=(Na=new bn,La=new bn,Fa=new bn,Ba=new bn,function(e,t){return bn.subtract(Na,e.center,e.halfExtents),bn.add(La,e.center,e.halfExtents),bn.subtract(Fa,t.center,t.halfExtents),bn.add(Ba,t.center,t.halfExtents),Na.x<=Ba.x&&La.x>=Fa.x&&Na.y<=Ba.y&&La.y>=Fa.y&&Na.z<=Ba.z&&La.z>=Fa.z});function ka(e,t,n,i,r,o){bn.set(o[0],e.x+n.x*t.x+i.x*t.y+r.x*t.z,e.y+n.y*t.x+i.y*t.y+r.y*t.z,e.z+n.z*t.x+i.z*t.y+r.z*t.z),bn.set(o[1],e.x-n.x*t.x+i.x*t.y+r.x*t.z,e.y-n.y*t.x+i.y*t.y+r.y*t.z,e.z-n.z*t.x+i.z*t.y+r.z*t.z),bn.set(o[2],e.x+n.x*t.x-i.x*t.y+r.x*t.z,e.y+n.y*t.x-i.y*t.y+r.y*t.z,e.z+n.z*t.x-i.z*t.y+r.z*t.z),bn.set(o[3],e.x+n.x*t.x+i.x*t.y-r.x*t.z,e.y+n.y*t.x+i.y*t.y-r.y*t.z,e.z+n.z*t.x+i.z*t.y-r.z*t.z),bn.set(o[4],e.x-n.x*t.x-i.x*t.y-r.x*t.z,e.y-n.y*t.x-i.y*t.y-r.y*t.z,e.z-n.z*t.x-i.z*t.y-r.z*t.z),bn.set(o[5],e.x+n.x*t.x-i.x*t.y-r.x*t.z,e.y+n.y*t.x-i.y*t.y-r.y*t.z,e.z+n.z*t.x-i.z*t.y-r.z*t.z),bn.set(o[6],e.x-n.x*t.x+i.x*t.y-r.x*t.z,e.y-n.y*t.x+i.y*t.y-r.y*t.z,e.z-n.z*t.x+i.z*t.y-r.z*t.z),bn.set(o[7],e.x-n.x*t.x-i.x*t.y+r.x*t.z,e.y-n.y*t.x-i.y*t.y+r.y*t.z,e.z-n.z*t.x-i.z*t.y+r.z*t.z)}function Ua(e,t){for(var n=bn.dot(t,e[0]),i=n,r=1;r<8;++r){var o=bn.dot(t,e[r]);n=oi?o:i}return[n,i]}var Ga,Ha,Va,ja=function(){for(var e=new Array(15),t=0;t<15;t++)e[t]=new bn(0,0,0);for(var n=new Array(8),i=new Array(8),r=0;r<8;r++)n[r]=new bn(0,0,0),i[r]=new bn(0,0,0);var o=new bn,a=new bn;return function(t,r){bn.set(e[0],1,0,0),bn.set(e[1],0,1,0),bn.set(e[2],0,0,1),bn.set(e[3],r.orientation.m00,r.orientation.m01,r.orientation.m02),bn.set(e[4],r.orientation.m03,r.orientation.m04,r.orientation.m05),bn.set(e[5],r.orientation.m06,r.orientation.m07,r.orientation.m08);for(var s=0;s<3;++s)bn.cross(e[6+3*s],e[s],e[3]),bn.cross(e[7+3*s],e[s],e[4]),bn.cross(e[7+3*s],e[s],e[5]);bn.subtract(o,t.center,t.halfExtents),bn.add(a,t.center,t.halfExtents),function(e,t,n){bn.set(n[0],e.x,t.y,t.z),bn.set(n[1],e.x,t.y,e.z),bn.set(n[2],e.x,e.y,t.z),bn.set(n[3],e.x,e.y,e.z),bn.set(n[4],t.x,t.y,t.z),bn.set(n[5],t.x,t.y,e.z),bn.set(n[6],t.x,e.y,t.z),bn.set(n[7],t.x,e.y,e.z)}(o,a,n),ka(r.center,r.halfExtents,e[3],e[4],e[5],i);for(var c=0;c<15;++c){var l=Ua(n,e[c]),u=Ua(i,e[c]);if(u[0]>l[1]||l[0]>u[1])return 0}return 1}}(),Wa=function(e,t){var n=e.halfExtents.x*Math.abs(t.n.x)+e.halfExtents.y*Math.abs(t.n.y)+e.halfExtents.z*Math.abs(t.n.z),i=bn.dot(t.n,e.center);return i+nt.d?0:1},qa=function(e,t){for(var n=0;ni.halfExtents.x?t++:e[l].x<-i.halfExtents.x&&n++;if(t===r.vertices.length||n===r.vertices.length)return 0;t=0,n=0;for(var u=0;ui.halfExtents.y?t++:e[u].y<-i.halfExtents.y&&n++;if(t===r.vertices.length||n===r.vertices.length)return 0;t=0,n=0;for(var h=0;hi.halfExtents.z?t++:e[h].z<-i.halfExtents.z&&n++;return t===r.vertices.length||n===r.vertices.length?0:1}}(),Ya=(Ga=new bn(0,0,0),Ha=new In,function(e,t){return bn.subtract(Ga,t,e.center),bn.transformMat3(Ga,Ga,In.transpose(Ha,e.orientation)),n=Ga,i=e.halfExtents,Math.abs(n.x)t.d?0:1}),Qa=function(e,t){for(var n=0;nr.halfExtents.x?n++:t<-r.halfExtents.x&&i++;if(n===a.vertices.length||i===a.vertices.length)return 0;n=0,i=0;for(var f=0;fr.halfExtents.y?n++:t<-r.halfExtents.y&&i++;if(n===a.vertices.length||i===a.vertices.length)return 0;n=0,i=0;for(var _=0;_r.halfExtents.z?n++:t<-r.halfExtents.z&&i++;return n===a.vertices.length||i===a.vertices.length?0:1}}(),Ja=function(){for(var e=new Array(15),t=0;t<15;t++)e[t]=new bn(0,0,0);for(var n=new Array(8),i=new Array(8),r=0;r<8;r++)n[r]=new bn(0,0,0),i[r]=new bn(0,0,0);return function(t,r){bn.set(e[0],t.orientation.m00,t.orientation.m01,t.orientation.m02),bn.set(e[1],t.orientation.m03,t.orientation.m04,t.orientation.m05),bn.set(e[2],t.orientation.m06,t.orientation.m07,t.orientation.m08),bn.set(e[3],r.orientation.m00,r.orientation.m01,r.orientation.m02),bn.set(e[4],r.orientation.m03,r.orientation.m04,r.orientation.m05),bn.set(e[5],r.orientation.m06,r.orientation.m07,r.orientation.m08);for(var o=0;o<3;++o)bn.cross(e[6+3*o],e[o],e[3]),bn.cross(e[7+3*o],e[o],e[4]),bn.cross(e[8+3*o],e[o],e[5]);ka(t.center,t.halfExtents,e[0],e[1],e[2],n),ka(r.center,r.halfExtents,e[3],e[4],e[5],i);for(var a=0;a<15;++a){var s=Ua(n,e[a]),c=Ua(i,e[a]);if(c[0]>s[1]||s[0]>c[1])return 0}return 1}}(),$a=function(){for(var e=new ra,t=new bn,n=new bn,i=new bn,r=new Array(8),o=0;o<8;o++)r[o]=new bn;for(var a=new Array(8),s=0;s<8;s++)a[s]=new bn;return function(o,s){if(0===bn.squaredDistance(s.ellipseCenter0,s.ellipseCenter1))return e.radius=s.radius,e.center.set(s.ellipseCenter0),cs.sphereOBB(e,o);t.x=o.orientation.m00,t.y=o.orientation.m01,t.z=o.orientation.m02,n.x=o.orientation.m03,n.y=o.orientation.m04,n.z=o.orientation.m05,i.x=o.orientation.m06,i.y=o.orientation.m07,i.z=o.orientation.m08,ka(o.center,o.halfExtents,t,n,i,r);var c=a,l=bn.copy(c[0],t),u=bn.copy(c[1],n),h=bn.copy(c[2],i);bn.subtract(c[3],s.center,o.center).normalize();var f=bn.subtract(c[4],s.ellipseCenter0,s.ellipseCenter1);f.normalize(),bn.cross(c[5],l,f),bn.cross(c[6],u,f),bn.cross(c[7],h,f);for(var _=0;_<8;++_){var p=Ua(r,c[_]),d=bn.dot(c[_],s.ellipseCenter0),m=bn.dot(c[_],s.ellipseCenter1),g=Math.max(d,m),v=Math.min(d,m)-s.radius,y=g+s.radius;if(v>p[1]||p[0]>y)return 0}return 1}}(),es=function(e,t){var n=bn.dot(t.n,e.center),i=e.radius*t.n.length();return n+it.d?0:1},ts=function(e,t){for(var n=0;nl)){bn.add(e,s,bn.multiplyScalar(e,c,a));for(var h=0;h<6;h++)if(h!==r&&h!==r+t[r]){var f=i.planes[h];if(bn.dot(f.n,e)1?bn.squaredDistance(n.center,i.ellipseCenter1)y&&(c=y,l=g+p,x=d)),l<0?(l=0,-m<0?c=0:-m>_?c=y:(c=-m,y=_)):l>x&&(l=x,-m+p<0?c=0:-m+p>_?c=y:(c=-m+p,y=_));var S=Math.abs(c)0&&(e.d=t.d/n),e},e.prototype.transform=function(e){Gn.invert(vs,e),Gn.transpose(vs,vs),Kn.set(ys,this.n.x,this.n.y,this.n.z,this.d),Kn.transformMat4(ys,ys,vs),bn.set(this.n,ys.x,ys.y,ys.z),this.d=ys.w},K(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}(),Ss=function(){function e(e,t,n){this._arrayBuffers=[],this._chunkSize=void 0,this._chunkSize=n*(1<>this._entryBits,n=this._entryMask&e;return(this._hasFloat32?this._float32BufferViews:this._uint32BufferViews)[t][n]},t.getTypedArray=function(e,t){var n=(this._chunkMask&e)>>this._entryBits,i=this._entryMask&e,r=t,o=(this._dataType[t]===ds.UINT32?this._uint32BufferViews:this._float32BufferViews)[n][i],a=this._dataMembers[t];return o.subarray(r,r+a)},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}();!function(e){e[e.NODE=0]="NODE",e[e.PASS=1]="PASS",e[e.AABB=2]="AABB"}(Ts||(Ts={})),function(e){e[e.DIRTY_FLAG=0]="DIRTY_FLAG",e[e.LAYER=1]="LAYER",e[e.WORLD_SCALE=2]="WORLD_SCALE",e[e.WORLD_POSITION=5]="WORLD_POSITION",e[e.WORLD_ROTATION=8]="WORLD_ROTATION",e[e.WORLD_MATRIX=12]="WORLD_MATRIX",e[e.LOCAL_SCALE=28]="LOCAL_SCALE",e[e.LOCAL_POSITION=31]="LOCAL_POSITION",e[e.LOCAL_ROTATION=34]="LOCAL_ROTATION",e[e.COUNT=38]="COUNT"}(Es||(Es={}));var Cs,bs=((ls={})[Es.DIRTY_FLAG]=ds.UINT32,ls[Es.LAYER]=ds.UINT32,ls[Es.WORLD_SCALE]=ds.FLOAT32,ls[Es.WORLD_POSITION]=ds.FLOAT32,ls[Es.WORLD_ROTATION]=ds.FLOAT32,ls[Es.WORLD_MATRIX]=ds.FLOAT32,ls[Es.LOCAL_SCALE]=ds.FLOAT32,ls[Es.LOCAL_POSITION]=ds.FLOAT32,ls[Es.LOCAL_ROTATION]=ds.FLOAT32,ls[Es.COUNT]=ds.NEVER,ls),ws=((us={})[Es.DIRTY_FLAG]=Es.LAYER-Es.DIRTY_FLAG,us[Es.LAYER]=Es.WORLD_SCALE-Es.LAYER,us[Es.WORLD_SCALE]=Es.WORLD_POSITION-Es.WORLD_SCALE,us[Es.WORLD_POSITION]=Es.WORLD_ROTATION-Es.WORLD_POSITION,us[Es.WORLD_ROTATION]=Es.WORLD_MATRIX-Es.WORLD_ROTATION,us[Es.WORLD_MATRIX]=Es.LOCAL_SCALE-Es.WORLD_MATRIX,us[Es.LOCAL_SCALE]=Es.LOCAL_POSITION-Es.LOCAL_SCALE,us[Es.LOCAL_POSITION]=Es.LOCAL_ROTATION-Es.LOCAL_POSITION,us[Es.LOCAL_ROTATION]=Es.COUNT-Es.LOCAL_ROTATION,us[Es.COUNT]=1,us),Rs=new As(Ts.NODE,bs,ws,Es);!function(e){e[e.PRIORITY=0]="PRIORITY",e[e.STAGE=1]="STAGE",e[e.PHASE=2]="PHASE",e[e.PRIMITIVE=3]="PRIMITIVE",e[e.BATCHING_SCHEME=4]="BATCHING_SCHEME",e[e.DYNAMIC_STATE=5]="DYNAMIC_STATE",e[e.HASH=6]="HASH",e[e.COUNT=7]="COUNT"}(Cs||(Cs={}));var Ps,Is=((hs={})[Cs.PRIORITY]=ds.UINT32,hs[Cs.STAGE]=ds.UINT32,hs[Cs.PHASE]=ds.UINT32,hs[Cs.PRIMITIVE]=ds.UINT32,hs[Cs.BATCHING_SCHEME]=ds.UINT32,hs[Cs.DYNAMIC_STATE]=ds.UINT32,hs[Cs.HASH]=ds.UINT32,hs[Cs.COUNT]=ds.NEVER,hs),Ds=((fs={})[Cs.PRIORITY]=Cs.STAGE-Cs.PRIORITY,fs[Cs.STAGE]=Cs.PHASE-Cs.STAGE,fs[Cs.PHASE]=Cs.PRIMITIVE-Cs.PHASE,fs[Cs.PRIMITIVE]=Cs.BATCHING_SCHEME-Cs.PRIMITIVE,fs[Cs.BATCHING_SCHEME]=Cs.DYNAMIC_STATE-Cs.BATCHING_SCHEME,fs[Cs.DYNAMIC_STATE]=Cs.HASH-Cs.DYNAMIC_STATE,fs[Cs.HASH]=Cs.COUNT-Cs.HASH,fs[Cs.COUNT]=1,fs),Os=new As(Ts.PASS,Is,Ds,Cs);!function(e){e[e.CENTER=0]="CENTER",e[e.HALFEXTENTS=3]="HALFEXTENTS",e[e.COUNT=6]="COUNT"}(Ps||(Ps={}));var Ms=((_s={})[Ps.CENTER]=ds.FLOAT32,_s[Ps.HALFEXTENTS]=ds.FLOAT32,_s[Ps.COUNT]=ds.NEVER,_s),Ns=((ps={})[Ps.CENTER]=Ps.HALFEXTENTS-Ps.CENTER,ps[Ps.HALFEXTENTS]=Ps.COUNT-Ps.HALFEXTENTS,ps[Ps.COUNT]=1,ps),Ls=new As(Ts.AABB,Ms,Ns,Ps),Fs=new bn,Bs=new bn,zs=new bn,ks=new bn,Us=new In,Gs=function(e,t,n){Us.m00=Math.abs(n.m00),Us.m01=Math.abs(n.m01),Us.m02=Math.abs(n.m02),Us.m03=Math.abs(n.m04),Us.m04=Math.abs(n.m05),Us.m05=Math.abs(n.m06),Us.m06=Math.abs(n.m08),Us.m07=Math.abs(n.m09),Us.m08=Math.abs(n.m10),bn.transformMat3(e,t,Us)},Hs=function(){function e(e,t,n,i,r,o){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=1),void 0===r&&(r=1),void 0===o&&(o=1),this.center=void 0,this.halfExtents=void 0,this._type=void 0,this._aabbHandle=0,this._type=Ko.SHAPE_AABB,this.center=new bn(e,t,n),this.halfExtents=new bn(i,r,o)}e.create=function(t,n,i,r,o,a){return new e(t,n,i,r,o,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 bn.copy(e.center,t.center),bn.copy(e.halfExtents,t.halfExtents),e},e.fromPoints=function(e,t,n){return bn.add(Fs,n,t),bn.subtract(Bs,n,t),bn.multiplyScalar(e.center,Fs,.5),bn.multiplyScalar(e.halfExtents,Bs,.5),e},e.set=function(e,t,n,i,r,o,a){return e.center.set(t,n,i),e.halfExtents.set(r,o,a),e},e.merge=function(t,n,i){return bn.subtract(Fs,n.center,n.halfExtents),bn.subtract(Bs,i.center,i.halfExtents),bn.add(zs,n.center,n.halfExtents),bn.add(ks,i.center,i.halfExtents),bn.max(ks,zs,ks),bn.min(zs,Fs,Bs),e.fromPoints(t,zs,ks)},e.toBoundingSphere=function(e,t){return e.center.set(t.center),e.radius=t.halfExtents.length(),e},e.transform=function(e,t,n){return bn.transformMat4(e.center,t.center,n),Gs(e.halfExtents,t.halfExtents,n),e};var t=e.prototype;return t.getBoundary=function(e,t){bn.subtract(e,this.center,this.halfExtents),bn.add(t,this.center,this.halfExtents)},t.transform=function(e,t,n,i,r){bn.transformMat4(r.center,this.center,e),Gs(r.halfExtents,this.halfExtents,e)},t.clone=function(){return e.clone(this)},t.copy=function(t){return e.copy(this,t)},t.mergePoint=function(e){this.getBoundary(Fs,Bs),e.xBs.x&&(Bs.x=e.x),e.y>Bs.y&&(Bs.y=e.y),e.z>Bs.z&&(Bs.z=e.z),bn.add(zs,Fs,Bs),this.center.set(bn.multiplyScalar(zs,zs,.5)),this.halfExtents.set(Bs.x-zs.x,Bs.y-zs.y,Bs.z-zs.z)},t.mergePoints=function(e){if(!(e.length<1))for(var t=0;t>>1;i<=r;o=i+r>>>1){var a=e[o];if(a>t+n)r=o-1;else{if(!(a=e._times.length)return{done:!0,value:void 0};var n=[e._times[t],e._values[t]];return++t,{done:!1,value:n}}}},t.keyframes=function(){return this},t.times=function(){return this._times},t.values=function(){return this._values},t.getKeyframeTime=function(e){return this._times[e]},t.getKeyframeValue=function(e){return this._values[e]},t.addKeyFrame=function(e,t){return this._insertNewKeyframe(e,t)},t.removeKeyframe=function(e){this._times.splice(e,1),this._values.splice(e,1)},t.indexOfKeyframe=function(e){return nc(this._times,e)},t.updateTime=function(e,t){var n=this._values[e];this.removeKeyframe(e),this._insertNewKeyframe(t,n)},t.assignSorted=function(e,t){if(void 0!==t)this.setKeyframes(e.slice(),t.slice());else{var n=Array.from(e);this.setKeyframes(n.map((function(e){return e[0]})),n.map((function(e){return e[1]})))}},t.clear=function(){this._times.length=0,this._values.length=0},t.searchKeyframe=function(e){return nc(this._times,e)},t.setKeyframes=function(e,t){e.length,t.length,function(e){e.every((function(e,t,n){return 0===t||e>n[t-1]||rn(e,n[t-1],1e-6)}))}(e),this._times=e,this._values=t},t._insertNewKeyframe=function(e,t){var n=this._times,i=this._values,r=n.length,o=nc(n,e);if(o>=0)return o;var a=~o;return 0===a?(n.unshift(e),i.unshift(t)):a===r?(n.push(e),i.push(t)):(n.splice(a-1,0,e),i.splice(a-1,0,t)),a},K(e,[{key:"keyFramesCount",get:function(){return this._times.length}},{key:"rangeMin",get:function(){return this._times[0]}},{key:"rangeMax",get:function(){return this._times[this._values.length-1]}}]),e}(),Kc=se((Yc=Zc).prototype,"_times",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Qc=se(Yc.prototype,"_values",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Xc=Yc))||Xc;function il(e){return e>-1e-9&&e<1e-9}!function(e){e[e.LINEAR=0]="LINEAR",e[e.CONSTANT=1]="CONSTANT",e[e.CUBIC=2]="CUBIC"}(Jc||(Jc=e("RealInterpolationMode",{}))),function(e){e[e.LINEAR=0]="LINEAR",e[e.CLAMP=1]="CLAMP",e[e.LOOP=2]="LOOP",e[e.PING_PONG=3]="PING_PONG"}($c||($c=e("ExtrapolationMode",{}))),function(e){e[e.NONE=0]="NONE",e[e.LEFT=1]="LEFT",e[e.RIGHT=2]="RIGHT",e[e.BOTH=3]="BOTH"}(el||(el=e("TangentWeightMode",{})));var rl,ol=e("editorExtrasTag","__editorExtras__"),al=function(){},sl=Object.freeze({__proto__:null,uniquelyReferenced:Sc,ccclass:hc,property:dc,requireComponent:fc,executionOrder:_c,disallowMultiple:pc,allowReplicated:function(e){Qt.Attr.setClassAttr(e,"replicated","visible",!0)},executeInEditMode:Tc,menu:Ec,playOnFocus:Ac,inspector:Cc,icon:bc,help:wc,type:Wc,integer:Gc,float:Hc,boolean:Vc,string:jc});e("_decorator",sl);var cl=1<<22,ll=[],ul=e("CCObject",function(){function e(e){void 0===e&&(e=""),this._objFlags=void 0,this._name=void 0,this._name=e,this._objFlags=0}e._deferredDestroy=function(){for(var e=ll.length,t=0;tthis.pipes.length?(P(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],Rl[Pl[i++]]=bl[(3&r)<<2|o>>4],Rl[Pl[i++]]=bl[15&o]}return e.replace(t,Rl.join(""))}var Dl=/.*[/\\][0-9a-fA-F]{2}[/\\]([0-9a-fA-F-@]{8,}).*/;function Ol(e){var t=Dl.exec(e);return t?t[1]:""}function Ml(e,t){(t=t||Object.create(null)).__isNative__=t.isNative,t.ext=t.nativeExt;var n=yl.find((function(t){return!!t.getAssetInfo(e)}));return n&&(t.bundle=n.name),Fl(e,t)}function Nl(e){return!!e&&(e instanceof c.SceneAsset||e instanceof c.Scene)}function Ll(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 Fl(e,t){var n=Cl.create({input:e,options:t}),i=[];try{for(var r,o=oe(Tl.sync(n));!(r=o()).done;){var a=r.value,s=a.url;a.recycle(),i.push(s)}}catch(e){for(var c,l=oe(n.output);!(c=l()).done;)c.value.recycle();x(e.message,e.stack)}return n.recycle(),i.length>1?i:i[0]}var Bl=Object.freeze({__proto__:null,getUuidFromURL:Ol,getUrlWithUuid:Ml,isScene:Nl,normalize:Ll,transform:Fl,decodeUuid:Il}),zl=new(function(){function e(){this._pools=[],this._lastShrinkPassed=0,this.shrinkTimeSpan=5}var t=e.prototype;return t.addContainer=function(e){-1===e._poolHandle&&(e._poolHandle=this._pools.length,this._pools.push(e))},t.removeContainer=function(e){-1!==e._poolHandle&&(this._pools[this._pools.length-1]._poolHandle=e._poolHandle,tt.array.fastRemoveAt(this._pools,e._poolHandle),e._poolHandle=-1)},t.tryShrink=function(){for(var e=0;ethis.shrinkTimeSpan&&(this.tryShrink(),this._lastShrinkPassed-=this.shrinkTimeSpan)},e}()),kl=function(){function e(){this._poolHandle=-1,zl.addContainer(this)}return e.prototype.destroy=function(){zl.removeContainer(this)},e}(),Ul=e("Pool",function(e){function t(t,n,i){var r;(r=e.call(this)||this)._ctor=void 0,r._elementsPerBatch=void 0,r._nextAvail=void 0,r._freepool=[],r._dtor=void 0,r._ctor=t,r._dtor=i||null,r._elementsPerBatch=Math.max(n,1),r._nextAvail=r._elementsPerBatch-1;for(var o=0;o>1>this._elementsPerBatch){if(this._dtor)for(var e=this._nextAvail>>1;e<=this._nextAvail;e++)this._dtor(this._freepool[e]);this._freepool.length=this._nextAvail>>1,this._nextAvail=this._freepool.length-1}},n.destroy=function(){var t=arguments.length>0?arguments[0]:null;t&&P(14100);var n=t||this._dtor;if(n)for(var i=0;i<=this._nextAvail;i++)n(this._freepool[i]);this._freepool.length=0,this._nextAvail=-1,e.prototype.destroy.call(this)},t}(kl)),Gl=e("RecyclePool",function(e){function t(t,n,i){var r;(r=e.call(this)||this)._fn=void 0,r._dtor=null,r._count=0,r._data=void 0,r._initSize=0,r._fn=t,r._dtor=i||null,r._data=new Array(n),r._initSize=n;for(var o=0;othis._data.length)for(var t=this._data.length;t=this._data.length&&this.resize(this._data.length<<1),this._data[this._count++]},n.destroy=function(){if(this._dtor)for(var t=0;t>2>this._count){var e=Math.max(this._initSize,this._data.length>>1);if(this._dtor)for(var t=e;t=this._count)){var t=this._count-1,n=this._data[e];this._data[e]=this._data[t],this._data[t]=n,this._count-=1}},K(t,[{key:"length",get:function(){return this._count}},{key:"data",get:function(){return this._data}}]),t}(kl)),Hl=e("CachedArray",function(e){function t(t,n){var i;return(i=e.call(this)||this).array=void 0,i.length=0,i._compareFn=void 0,i._initSize=0,i.array=new Array(t),i._initSize=t,i.length=0,i._compareFn=void 0!==n?n:function(e,t){return e-t},i}Z(t,e);var n=t.prototype;return n.push=function(e){this.array[this.length++]=e},n.pop=function(){return this.array[--this.length]},n.get=function(e){return this.array[e]},n.clear=function(){this.length=0},n.destroy=function(){this.length=0,this.array.length=0,e.prototype.destroy.call(this)},n.tryShrink=function(){this.array.length>>2>this.length&&(this.array.length=Math.max(this._initSize,this.array.length>>1))},n.sort=function(){this.array.length=this.length,this.array.sort(this._compareFn)},n.concat=function(e){for(var t=0;t=this.length||e<0)){var t=--this.length;this.array[e]=this.array[t]}},n.indexOf=function(e){for(var t=0,n=this.length;t=0;--e)this.callbackInfos[e]||Vl(this.callbackInfos,e);this.containCanceled=!1},t.clear=function(){this.cancelAll(),this.callbackInfos.length=0,this.isInvoking=!1,this.containCanceled=!1},e}(),Yl=new Ul((function(){return new Xl}),16),Kl=function(){function e(){this._callbackTable=be(!0),this._offCallback=void 0}var t=e.prototype;return t.on=function(e,t,n,i){if(!this.hasEventListener(e,t,n)){var r=this._callbackTable[e];r||(r=this._callbackTable[e]=Yl.alloc());var o=ql.alloc();o.set(t,n,i),r.callbackInfos.push(o)}return t},t.hasEventListener=function(e,t,n){var i=this._callbackTable&&this._callbackTable[e];if(!i)return!1;var r=i.callbackInfos;if(!t){if(i.isInvoking){for(var o=0;o0}for(var a=0;a1)&&(l=!0,u="",h=0);var _=nu.UNKNOWN;-1!==o.appVersion.indexOf("Win")?_=nu.WINDOWS:l?_=nu.IOS:-1!==o.appVersion.indexOf("Mac")?_=nu.OSX:-1!==o.appVersion.indexOf("X11")&&-1===o.appVersion.indexOf("Linux")?_=nu.LINUX:c?_=nu.ANDROID:-1===o.appVersion.indexOf("Linux")&&-1===a.indexOf("ubuntu")||(_=nu.LINUX),i.os=_,i.osVersion=u,i.osMainVersion=h,i.browserType=$l.UNKNOWN;var p=/wechat|weixin|micromessenger/i.exec(a)||/mqqbrowser|micromessenger|qqbrowser|sogou|qzone|liebao|maxthon|ucbs|360 aphone|360browser|baiduboxapp|baidubrowser|maxthon|mxbrowser|miuibrowser/i.exec(a)||/qq|qqbrowser|ucbrowser|ubrowser|edge|HuaweiBrowser/i.exec(a)||/chrome|safari|firefox|trident|opera|opr\/|oupeng/i.exec(a),d=p?p[0].toLowerCase():nu.UNKNOWN;("safari"===d&&c||"qq"===d&&/android.*applewebkit/i.test(a))&&(d=$l.ANDROID);var m={micromessenger:$l.WECHAT,wechat:$l.WECHAT,weixin:$l.WECHAT,trident:$l.IE,edge:$l.EDGE,"360 aphone":$l.BROWSER_360,mxbrowser:$l.MAXTHON,"opr/":$l.OPERA,ubrowser:$l.UC,huaweibrowser:$l.HUAWEI};i.browserType=m[d]||d,i.browserVersion="";var g=/(mqqbrowser|micromessenger|qqbrowser|sogou|qzone|liebao|maxthon|uc|ucbs|360 aphone|360|baiduboxapp|baidu|maxthon|mxbrowser|miui(?:.hybrid)?)(mobile)?(browser)?\/?([\d.]+)/i.exec(a);g||(g=/(qq|chrome|safari|firefox|trident|opera|opr\/|oupeng)(mobile)?(browser)?\/?([\d.]+)/i.exec(a)),i.browserVersion=g?g[4]:"";var v,y=document.createElement("canvas");y.getContext("2d");try{v=y.toDataURL("image/webp").startsWith("data:image/webp")}catch(e){v=!1}var x=!1;"undefined"!=typeof createImageBitmap&&"undefined"!=typeof Blob&&(y.width=y.height=2,createImageBitmap(y,{}).then((function(e){x=!0,null==e||e.close()})).catch((function(){})));var S=void 0!==document.documentElement.ontouchstart||void 0!==document.ontouchstart,T=void 0!==document.documentElement.onmouseup;return i._featureMap=((n={})[ru.WEBP]=v,n[ru.IMAGE_BITMAP]=x,n[ru.WEB_VIEW]=!0,n[ru.VIDEO_PLAYER]=!0,n[ru.SAFE_AREA]=!1,n[ru.INPUT_TOUCH]=S,n[ru.EVENT_KEYBOARD]=void 0!==document.documentElement.onkeyup,n[ru.EVENT_MOUSE]=T,n[ru.EVENT_TOUCH]=S||T,n[ru.EVENT_ACCELEROMETER]=void 0!==window.DeviceMotionEvent||void 0!==window.DeviceOrientationEvent,n),i._registerEvent(),i}Z(t,e);var n=t.prototype;return n._registerEvent=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.emit("hide"))},r=function(e,i,r,o,a){n&&(n=!1,t.emit("show",e,i,r,o,a))};if(e)for(var o=["visibilitychange","mozvisibilitychange","msvisibilitychange","webkitvisibilitychange","qbrowserVisibilityChange"],a=0;a-1&&(window.onfocus=r),"onpageshow"in window&&"onpagehide"in window&&(window.addEventListener("pagehide",i),window.addEventListener("pageshow",r),document.addEventListener("pagehide",i),document.addEventListener("pageshow",r))},n.hasFeature=function(e){return this._featureMap[e]},n.getBatteryLevel=function(){return this._battery?this._battery.level:1},n.triggerGC=function(){},n.openURL=function(e){window.open(e)},n.now=function(){return Date.now?Date.now():+new Date},n.restartJSVM=function(){},n.close=function(){this.emit("close"),window.close()},t}(Zl)),fu=/(\.[^\.\/\?\\]*)(\?.*)?$/,_u=/((.*)(\/|\\|\\\\))?(.*?\..*$)?/,pu=/[^\.\/]+\/\.\.\//;function du(){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 r=i[2];return t&&e.substring(e.length-t.length).toLowerCase()===t.toLowerCase()?r.substring(0,r.length-t.length):r}function yu(e){var t=_u.exec(e);return t?t[2]:""}function xu(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 Su(e,t,n){if(0===t.indexOf("."))return xu(e,t);var i=e.indexOf("?"),r="",o=n?mu(e):"";return i>0&&(r=e.substring(i),e=e.substring(0,i)),i=(i=e.lastIndexOf("/"))<=0?0:i+1,e.substring(0,i)+t+o+r}function Tu(e){var t=e=String(e);do{t=e,e=e.replace(pu,"")}while(t.length!==e.length);return e}function Eu(e){return e.replace(/[\/\\]$/,"")}function Au(){return hu.os===nu.WINDOWS?"\\":"/"}e("path",Object.freeze({__proto__:null,join:du,extname:mu,mainFileName:gu,basename:vu,dirname:yu,changeExtname:xu,changeBasename:Su,_normalize:Tu,stripSep:Eu,getSeperator:Au}));var Cu,bu,wu,Ru=e("Asset",hc("cc.Asset")((uu=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r0&&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},n.destroy=function(){return T(L(12101,this._uuid)),e.prototype.destroy.call(this)},K(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=Ml(this._uuid,{nativeExt:e,isNative:!0}):this._nativeUrl=Ml(this._uuid,{__nativeName__:e,nativeExt:mu(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}(Ql(au)),lu=se((cu=uu).prototype,"_native",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),se(cu.prototype,"_nativeAsset",[dc],Object.getOwnPropertyDescriptor(cu.prototype,"_nativeAsset"),cu.prototype),su=cu))||su);Ru.prototype.createNode=null,c.Asset=Ru;var Pu=e("Script",hc("cc.Script")(Cu=function(e){function t(){return e.apply(this,arguments)||this}return Z(t,e),t}(Ru))||Cu);c._Script=Pu;var Iu=e("JavaScript",hc("cc.JavaScript")(bu=function(e){function t(){return e.apply(this,arguments)||this}return Z(t,e),t}(Pu))||bu);c._JavaScript=Iu;var Du,Ou,Mu,Nu,Lu,Fu,Bu,zu,ku,Uu,Gu,Hu=e("TypeScript",hc("cc.TypeScript")(wu=function(e){function t(){return e.apply(this,arguments)||this}return Z(t,e),t}(Pu))||wu);c._TypeScript=Hu;var Vu,ju,Wu,qu,Xu=new pe("Comp"),Yu=ul.Flags.IsOnLoadCalled,Ku=e("Component",(Du=hc("cc.Component"),Ou=Dc(),Mu=Wc(Pu),Nu=Oc(),Du((Gu=Uu=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r=0,1620),n=Number.isNaN(n)?c.macro.REPEAT_FOREVER:n,i=i||0;var r=c.director.getScheduler(),o=r.isTargetPaused(this);r.schedule(e,this,t,n,i,o)},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)},K(t,[{key:"name",get:function(){if(this._name)return this._name;var e=we(this),t=e.lastIndexOf(".");return t>=0&&(e=e.slice(t+1)),this.node?this.node.name+"<"+e+">":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&Yu}}]),t}(ul),Uu.system=null,se((Fu=Gu).prototype,"__scriptAsset",[Ou,Mu,Nu,Uc],Object.getOwnPropertyDescriptor(Fu.prototype,"__scriptAsset"),Fu.prototype),Bu=se(Fu.prototype,"node",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),zu=se(Fu.prototype,"_enabled",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),ku=se(Fu.prototype,"__prefab",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Lu=Fu))||Lu)),Qu=Ku.prototype;Qu.update=null,Qu.lateUpdate=null,Qu.__preload=null,Qu.onLoad=null,Qu.start=null,Qu.onEnable=null,Qu.onDisable=null,Qu.onDestroy=null,Qu.onFocusInEditor=null,Qu.onLostFocusInEditor=null,Qu.resetInEditor=null,Qu._getLocalBounds=null,Qu.onRestore=null,Ku._requireComponent=null,Ku._executionOrder=0,Te(Ku,"_registerEditorProps",(function(e,t){var n=t.requireComponent;n&&(Array.isArray(n)&&(n=n.filter(Boolean)),e._requireComponent=n);var i=t.executionOrder;i&&"number"==typeof i&&(e._executionOrder=i)})),c.Component=Ku;var Zu,Ju=e("MissingScript",hc("cc.MissingScript")(Vu=Cc()((qu=function(e){function t(){var t;return ae(t=e.call(this)||this,"_$erialized",Wu,ie(t)),t}return Z(t,e),t.safeFindClass=function(e){var t=Qe(e);if(t)return t;c.deserialize.reportMissingClass(e)},t.prototype.onLoad=function(){P(4600,this.node.name)},t}(Ku),Wu=se((ju=qu).prototype,"_$erialized",[gc,yc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Vu=ju))||Vu)||Vu);c._MissingScript=Ju;try{var $u=Ju.__values__;0!==$u.length&&"_$erialized"===$u[$u.length-1]||(x("The '_$erialized' prop in MissingScript is missing. Please contact jare."),x(" Error props: ['"+$u+"']"))}catch(jo){x("Error when checking MissingScript 5, "+jo)}!function(e){e[e.PORTRAIT=1]="PORTRAIT",e[e.PORTRAIT_UPSIDE_DOWN=2]="PORTRAIT_UPSIDE_DOWN",e[e.LANDSCAPE_LEFT=4]="LANDSCAPE_LEFT",e[e.LANDSCAPE_RIGHT=8]="LANDSCAPE_RIGHT",e[e.LANDSCAPE=12]="LANDSCAPE",e[e.AUTO=13]="AUTO"}(Zu||(Zu={}));var eh,th={auto:Zu.AUTO,landscape:Zu.LANDSCAPE,portrait:Zu.PORTRAIT};!function(e){e[e.Unknown=0]="Unknown",e[e.SubFrame=1]="SubFrame",e[e.BrowserWindow=2]="BrowserWindow",e[e.Fullscreen=3]="Fullscreen"}(eh||(eh={}));var nh=new(function(e){function t(){var t,n,i,r,o,a;(t=e.call(this)||this).isFrameRotated=!1,t.handleResizeEvent=!0,t._gameFrame=void 0,t._gameContainer=void 0,t._gameCanvas=void 0,t._isProportionalToFrame=!1,t._cachedFrameStyle={width:"0px",height:"0px"},t._cachedContainerStyle={width:"0px",height:"0px"},t._cbToUpdateFrameBuffer=void 0,t._supportFullScreen=!1,t._touchEventName=void 0,t._onFullscreenChange=void 0,t._onFullscreenError=void 0,t._orientationChangeTimeoutId=-1,t._cachedFrameSize=new Jn(0,0),t._exactFitScreen=!1,t._fn={},t._fnGroup=[["requestFullscreen","exitFullscreen","fullscreenchange","fullscreenEnabled","fullscreenElement","fullscreenerror"],["requestFullScreen","exitFullScreen","fullScreenchange","fullScreenEnabled","fullScreenElement","fullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitfullscreenchange","webkitIsFullScreen","webkitCurrentFullScreenElement","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozfullscreenchange","mozFullScreen","mozFullScreenElement","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","MSFullscreenChange","msFullscreenEnabled","msFullscreenElement","msfullscreenerror"]],t._resolutionScale=1,t._orientation=Zu.AUTO,t._gameFrame=document.getElementById("GameDiv"),t._gameContainer=document.getElementById("Cocos3dGameContainer"),t._gameCanvas=document.getElementById("GameCanvas"),t._gameFrame||(t._gameFrame=document.createElement("div"),t._gameFrame.setAttribute("id","GameDiv"),null===(n=t._gameCanvas)||void 0===n||null===(i=n.parentNode)||void 0===i||i.insertBefore(t._gameFrame,t._gameCanvas),t._gameFrame.appendChild(t._gameCanvas)),t._gameContainer||(t._gameContainer=document.createElement("div"),t._gameContainer.setAttribute("id","Cocos3dGameContainer"),null===(r=t._gameCanvas)||void 0===r||null===(o=r.parentNode)||void 0===o||o.insertBefore(t._gameContainer,t._gameCanvas),t._gameContainer.appendChild(t._gameCanvas));for(var s=t._fnGroup,c=0;cwindow.innerHeight;this.isFrameRotated=hu.isMobile&&(t&&e===Zu.PORTRAIT||!t&&e===Zu.LANDSCAPE)},n._updateContainer=function(){if(this._gameContainer){if(this.isProportionalToFrame){if(!this._gameFrame)return void P(9201);var e,t,n=c.view.getDesignResolutionSize(),i=this._gameFrame,r=i.clientWidth,o=i.clientHeight,a=n.width,s=n.height,l=r/a,u=o/s,h=this._gameContainer.style;l0&&P(1400,"screen.requestFullScreen(element, onFullScreenChange?, onFullScreenError?)","screen.requestFullScreen(): Promise"),nh.requestFullScreen().then((function(){null==t||t()})).catch((function(e){console.error(e),null==n||n()}))},t.exitFullScreen=function(){return nh.exitFullScreen()},t.autoFullScreen=function(e,t){var n;null===(n=this.requestFullScreen(e,t))||void 0===n||n.catch((function(){}))},t.disableAutoFullScreen=function(){},K(e,[{key:"devicePixelRatio",get:function(){return nh.devicePixelRatio}},{key:"windowSize",get:function(){return nh.windowSize},set:function(e){nh.windowSize=e}},{key:"resolution",get:function(){return nh.resolution}},{key:"supportsFullScreen",get:function(){return nh.supportFullScreen}}]),e}(),rh=e("screen",new ih);c.screen=rh;var oh=e("sys",{Feature:ru,hasFeature:function(e){return hu.hasFeature(e)},NetworkType:tu,Language:eu,OS:nu,Platform:iu,BrowserType:$l,isNative:hu.isNative,isBrowser:hu.isBrowser,isMobile:hu.isMobile,isLittleEndian:hu.isLittleEndian,platform:hu.platform,language:hu.language,languageCode:hu.nativeLanguage,os:hu.os,osVersion:hu.osVersion,osMainVersion:hu.osMainVersion,browserType:hu.browserType,browserVersion:hu.browserVersion,windowPixelResolution:rh.windowSize,capabilities:{canvas:!0,opengl:!0,webp:hu.hasFeature(ru.WEBP),imageBitmap:hu.hasFeature(ru.IMAGE_BITMAP),touches:hu.hasFeature(ru.INPUT_TOUCH),mouse:hu.hasFeature(ru.EVENT_MOUSE),keyboard:hu.hasFeature(ru.EVENT_KEYBOARD),accelerometer:hu.hasFeature(ru.EVENT_ACCELEROMETER)},localStorage:{},getNetworkType:function(){return hu.networkType},getBatteryLevel:function(){return hu.getBatteryLevel()},garbageCollect:function(){hu.triggerGC()},isObjectValid:function(e){return null!=e},dump:function(){var e="";e+="isMobile : "+this.isMobile+"\r\n",e+="language : "+this.language+"\r\n",e+="browserType : "+this.browserType+"\r\n",e+="browserVersion : "+this.browserVersion+"\r\n",e+="capabilities : "+JSON.stringify(this.capabilities)+"\r\n",e+="os : "+this.os+"\r\n",e+="osVersion : "+this.osVersion+"\r\n",e+="platform : "+this.platform+"\r\n",v(e+="Using "+(c.game.renderType===c.game.RENDER_TYPE_WEBGL?"WEBGL":"CANVAS")+" renderer.\r\n")},openURL:function(e){hu.openURL(e)},now:function(){return hu.now()},restartVM:function(){hu.restartJSVM()},getSafeAreaRect:function(){var e=c.view,t=nh.safeAreaEdge,n=nh.windowSize,i=new Wn(t.left,t.bottom),r=new Wn(n.width-t.right,n.height-t.top);e._convertToUISpace(i),e._convertToUISpace(r);var o=i.x,a=i.y,s=r.x-i.x,l=r.y-i.y;return new ei(o,a,s,l)}});!function(){try{var e=oh.localStorage=window.localStorage;e.setItem("storage",""),e.removeItem("storage"),e=null}catch(e){var t=function(){P(5200)};oh.localStorage={getItem:t,setItem:t,clear:t,removeItem:t}}oh.__isWebIOS14OrIPadOS14Env=(oh.os===nu.IOS||oh.os===nu.OSX)&&hu.isBrowser&&/(OS 14)|(Version\/14)/.test(window.navigator.userAgent)}(),c.sys=oh;var ah=e("serializeTag",Symbol("[[Serialize]]")),sh=e("deserializeTag",Symbol("[[Deserialize]]")),ch=function(){function e(e,t){this._document=void 0,this._chunks=void 0,this._document=e,this._chunks=t}return K(e,[{key:"document",get:function(){return this._document}},{key:"chunks",get:function(){return this._chunks}}]),e}();function lh(e){var t=e;return{chunks:t.chunks,document:t.document}}function uh(e){if(e.length<16)throw new hh(L(13102));var t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(1313817411!==t.getUint32(0,!0))throw new hh(L(13100));var n=t.getUint32(4,!0);if(1!==n)throw new hh(L(13101,n));if(t.getUint32(8,!0)!==t.byteLength)throw new hh(L(13102));var i=12,r=t.getUint32(i,!0);i+=4;var o=new Uint8Array(t.buffer,i+t.byteOffset,r);i+=r;var a,s=function(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);if("Buffer"in globalThis)return globalThis.Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString();throw new Error(L(13104))}(o);try{a=JSON.parse(s)}catch(e){throw new hh(e)}for(var c=[];i0&&(e.chunks.length,this._mainBinChunk=e.chunks[0])):t=e,this._serializedData=t,this._context={fromCCON:n};var i=Array.isArray(t)?t[0]:t;return this.deserializedData=this._deserializeObject(i,0),this._serializedData=void 0,this._mainBinChunk=void 0,this._context=void 0,this.deserializedData},t._deserializeObject=function(e,t,n,i){switch(e.__type__){case"TypedArray":return this._deserializeTypedArrayView(e);case"TypedArrayRef":return this._deserializeTypedArrayViewRef(e);default:return e.__type__?this._deserializeTypeTaggedObject(e,t,n,i):Array.isArray(e)?this._deserializeArray(e):this._deserializePlainObject(e)}},t._deserializeTypedArrayView=function(e){return globalThis[e.ctor].from(e.array)},t._deserializeTypedArrayViewRef=function(e){var t=e.offset,n=e.length,i=e.ctor;return new globalThis[i](this._mainBinChunk.buffer,this._mainBinChunk.byteOffset+t,n)},t._deserializeArray=function(e){for(var t,n=new Array(e.length),i=0;i=0&&(r.deserializedList[t]=n),n}(a);return this._deserializeInto(e,s,a),s},t._deserializeInto=function(e,t,n,i){void 0===i&&(i=!1),i||!t[sh]?t._deserialize?t._deserialize(e.content,this):c.Class._isCCClass(n)?this._deserializeFireClass(t,e,n):this._deserializeFastDefinedObject(t,e,n):this._runCustomizedDeserialize(e,t,n)},t._runCustomizedDeserialize=function(e,t,n){var i=this,r={readProperty:function(t){var n=e[t];return"object"==typeof n&&n?i._deserializeObjectField(n):n},readThis:function(){i._deserializeInto(e,t,n,!0)},readSuper:function(){var r=ke(n);r&&i._deserializeInto(e,t,r)}};t[sh](r,this._context)},t._deserializeFireClass=function(e,t,n){var i;if(n.hasOwnProperty("__deserialize__"))i=n.__deserialize__;else{i=function(e,t){for(var n=wt(t),i=t.__values__,r=["var prop;"],o=lt.test(Je(t)),a=0;a=0?t[n]=e[5][i]:e[7][3*~i]=t}function Ah(e){return function(t,n,i,r){n[i]=r;for(var o=0;o=0){var h=s[l];t[a]=Th(e,h,u)}else(0,wh[l=~l])(e,t,a,u)}return r}(e);c.game._isCloning=!1,e[7]&&function(e,t,n){for(var i=e.length-1,r=0,o=3*e[i];r=0?a[n[c]]=s:a[~c]=s}for(;r=0?l[n[h]]=u:l[~h]=u}}(e[7],l,e[2]),function(e){for(var t=e[5],n=e[2],i=e[1],r=e[8],o=e[9],a=e[10],s=0;s=0?n[l]:~l,o[s]=l);var u=a[s];"number"==typeof u&&(a[s]=i[u])}}(e),i=l[u]}else i=function(e,t,n){var i,r=(n=n||{}).classFinder||Qe,o=n.createAssetRefs||oh.platform===iu.EDITOR_CORE,a=n.customEnv,s=n.ignoreEditorOnly,l=null!==(i=n.reportMissingClass)&&void 0!==i?i:c.deserialize.reportMissingClass;t.init();var u=mh.pool.get(t,r,l,a,s);c.game._isCloning=!0;var h=u.deserialize(e);return c.game._isCloning=!1,mh.pool.put(u),o&&t.assignAssetsBy(EditorExtends.serialize.asAsset),h}(e,t,n);return r&&xh.pool.put(t),i}wh[0]=function(e,t,n,i){t[n]=i},wh[1]=Eh,wh[2]=Ah(Eh),wh[3]=Ah(Ch),wh[4]=bh,wh[5]=function(e,t,n,i){yh[i[0]](t[n],i)},wh[6]=Ch,wh[7]=function(e,t,n,i){t[n].set(i)},wh[8]=function(e,t,n,i){var r=new gh[i[0]];yh[i[0]](r,i),t[n]=r},wh[9]=Ah(bh),wh[10]=function(e,t,n,i){var r=e[3][i[0]];t[n]=Th(e,r,i[1])},wh[11]=function(e,t,n,i){var r=i[0];t[n]=r;for(var o=1;o>3},i=n.storageUnit,r=ef(n.elementType),o=new(tf(i))(e,this._byteOffset,this._unitCount),a=new Array(this._length),s=0;s=1?1:e*e*(3-2*e)}function Bf(e){return e<=0?0:e>=1?1:e*e*e*(e*(6*e-15)+10)}c._decorator=sl;var zf=Yf(af,sf),kf=Yf(lf,uf),Uf=Yf(ff,_f),Gf=Yf(df,mf),Hf=Yf(vf,yf),Vf=Yf(Sf,Tf),jf=Yf(Af,Cf),Wf=Yf(wf,Rf),qf=Yf(If,Df),Xf=Yf(Mf,Nf);function Yf(e,t){return function(n){return n<.5?t(2*n)/2:e(2*n-1)/2+.5}}var Kf,Qf,Zf=Object.freeze({__proto__:null,constant:rf,linear:of,quadIn:af,quadOut:sf,quadInOut:cf,cubicIn:lf,cubicOut:uf,cubicInOut:hf,quartIn:ff,quartOut:_f,quartInOut:pf,quintIn:df,quintOut:mf,quintInOut:gf,sineIn:vf,sineOut:yf,sineInOut:xf,expoIn:Sf,expoOut:Tf,expoInOut:Ef,circIn:Af,circOut:Cf,circInOut:bf,elasticIn:wf,elasticOut:Rf,elasticInOut:Pf,backIn:If,backOut:Df,backInOut:Of,bounceIn:Mf,bounceOut:Nf,bounceInOut:Lf,smooth:Ff,fade:Bf,quadOutIn:zf,cubicOutIn:kf,quartOutIn:Uf,quintOutIn:Gf,sineOutIn:Hf,expoOutIn:Vf,circOutIn:jf,elasticOutIn:Wf,backOutIn:qf,bounceOutIn:Xf});e("easing",Zf),function(e){e[e.LINEAR=0]="LINEAR",e[e.CONSTANT=1]="CONSTANT",e[e.QUAD_IN=2]="QUAD_IN",e[e.QUAD_OUT=3]="QUAD_OUT",e[e.QUAD_IN_OUT=4]="QUAD_IN_OUT",e[e.QUAD_OUT_IN=5]="QUAD_OUT_IN",e[e.CUBIC_IN=6]="CUBIC_IN",e[e.CUBIC_OUT=7]="CUBIC_OUT",e[e.CUBIC_IN_OUT=8]="CUBIC_IN_OUT",e[e.CUBIC_OUT_IN=9]="CUBIC_OUT_IN",e[e.QUART_IN=10]="QUART_IN",e[e.QUART_OUT=11]="QUART_OUT",e[e.QUART_IN_OUT=12]="QUART_IN_OUT",e[e.QUART_OUT_IN=13]="QUART_OUT_IN",e[e.QUINT_IN=14]="QUINT_IN",e[e.QUINT_OUT=15]="QUINT_OUT",e[e.QUINT_IN_OUT=16]="QUINT_IN_OUT",e[e.QUINT_OUT_IN=17]="QUINT_OUT_IN",e[e.SINE_IN=18]="SINE_IN",e[e.SINE_OUT=19]="SINE_OUT",e[e.SINE_IN_OUT=20]="SINE_IN_OUT",e[e.SINE_OUT_IN=21]="SINE_OUT_IN",e[e.EXPO_IN=22]="EXPO_IN",e[e.EXPO_OUT=23]="EXPO_OUT",e[e.EXPO_IN_OUT=24]="EXPO_IN_OUT",e[e.EXPO_OUT_IN=25]="EXPO_OUT_IN",e[e.CIRC_IN=26]="CIRC_IN",e[e.CIRC_OUT=27]="CIRC_OUT",e[e.CIRC_IN_OUT=28]="CIRC_IN_OUT",e[e.CIRC_OUT_IN=29]="CIRC_OUT_IN",e[e.ELASTIC_IN=30]="ELASTIC_IN",e[e.ELASTIC_OUT=31]="ELASTIC_OUT",e[e.ELASTIC_IN_OUT=32]="ELASTIC_IN_OUT",e[e.ELASTIC_OUT_IN=33]="ELASTIC_OUT_IN",e[e.BACK_IN=34]="BACK_IN",e[e.BACK_OUT=35]="BACK_OUT",e[e.BACK_IN_OUT=36]="BACK_IN_OUT",e[e.BACK_OUT_IN=37]="BACK_OUT_IN",e[e.BOUNCE_IN=38]="BOUNCE_IN",e[e.BOUNCE_OUT=39]="BOUNCE_OUT",e[e.BOUNCE_IN_OUT=40]="BOUNCE_IN_OUT",e[e.BOUNCE_OUT_IN=41]="BOUNCE_OUT_IN",e[e.SMOOTH=42]="SMOOTH",e[e.FADE=43]="FADE"}(Qf||(Qf={}));var Jf,$f,e_,t_,n_,i_=((Kf={})[Qf.CONSTANT]=rf,Kf[Qf.LINEAR]=of,Kf[Qf.QUAD_IN]=af,Kf[Qf.QUAD_OUT]=sf,Kf[Qf.QUAD_IN_OUT]=cf,Kf[Qf.QUAD_OUT_IN]=zf,Kf[Qf.CUBIC_IN]=lf,Kf[Qf.CUBIC_OUT]=uf,Kf[Qf.CUBIC_IN_OUT]=hf,Kf[Qf.CUBIC_OUT_IN]=kf,Kf[Qf.QUART_IN]=ff,Kf[Qf.QUART_OUT]=_f,Kf[Qf.QUART_IN_OUT]=pf,Kf[Qf.QUART_OUT_IN]=Uf,Kf[Qf.QUINT_IN]=df,Kf[Qf.QUINT_OUT]=mf,Kf[Qf.QUINT_IN_OUT]=gf,Kf[Qf.QUINT_OUT_IN]=Gf,Kf[Qf.SINE_IN]=vf,Kf[Qf.SINE_OUT]=yf,Kf[Qf.SINE_IN_OUT]=xf,Kf[Qf.SINE_OUT_IN]=Hf,Kf[Qf.EXPO_IN]=Sf,Kf[Qf.EXPO_OUT]=Tf,Kf[Qf.EXPO_IN_OUT]=Ef,Kf[Qf.EXPO_OUT_IN]=Vf,Kf[Qf.CIRC_IN]=Af,Kf[Qf.CIRC_OUT]=Cf,Kf[Qf.CIRC_IN_OUT]=bf,Kf[Qf.CIRC_OUT_IN]=jf,Kf[Qf.ELASTIC_IN]=wf,Kf[Qf.ELASTIC_OUT]=Rf,Kf[Qf.ELASTIC_IN_OUT]=Pf,Kf[Qf.ELASTIC_OUT_IN]=Wf,Kf[Qf.BACK_IN]=If,Kf[Qf.BACK_OUT]=Df,Kf[Qf.BACK_IN_OUT]=Of,Kf[Qf.BACK_OUT_IN]=qf,Kf[Qf.BOUNCE_IN]=Mf,Kf[Qf.BOUNCE_OUT]=Nf,Kf[Qf.BOUNCE_IN_OUT]=Lf,Kf[Qf.BOUNCE_OUT_IN]=Xf,Kf[Qf.SMOOTH]=Ff,Kf[Qf.FADE]=Bf,Kf);function r_(e){return i_[e]}var o_,a_,s_,c_=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;ro){var c=this.postExtrapolation,l=n[i-1];if(c===$c.CLAMP||i<2)return l.value;switch(c){case $c.LINEAR:return w_(o,l.value,t[i-2],n[i-2].value,e);case $c.LOOP:e=C_(e,r,o);break;case $c.PING_PONG:e=b_(e,r,o);break;default:return l.value}}var u=nc(t,e);if(u>=0)return n[u].value;var h=~u,f=h-1,_=t[f],p=n[f],d=t[h];return function(e,t,n,i,r){var o=n-e;switch(t.interpolationMode){default:case Jc.CONSTANT:return t.value;case Jc.LINEAR:var a=t.easingMethod===Qf.LINEAR?r:r_(t.easingMethod)(r);return sn(t.value,i.value,a);case Jc.CUBIC:var s=1/3,c=t.rightTangent,l=t.rightTangentWeight,u=0!=(t.tangentWeightMode&el.RIGHT),h=i.leftTangent,f=i.leftTangentWeight,_=0!=(i.tangentWeightMode&el.LEFT);if(u||_){var p=0;if(u)p=l;else{var d=o,m=o*c;p=Math.sqrt(d*d+m*m)*s}var g=Math.atan(c),v=Math.cos(g)*p+e,y=Math.sin(g)*p+t.value,x=0;if(_)x=f;else{var S=o,T=o*h;x=Math.sqrt(S*S+T*T)*s}var E=Math.atan(h),A=(v-e)/o,C=(-Math.cos(E)*x+n-e)/o,b=y,w=-Math.sin(E)*x+i.value,R=[0,0,0],P=function(e,t,n,i,r){var o=n/i,a=t/i,s=o*o,c=1/3*(-1/3*s+a),l=.5*(2/27*o*s-1/3*o*a+e/i),u=c*c*c,h=l*l+u,f=0;if(il(h)){if(il(l))return r[0]=0,1;var _=Math.cbrt(-l);return r[0]=2*_,r[1]=-_,2}if(h<0){var p=1/3*Math.acos(-l/Math.sqrt(-u)),d=2*Math.sqrt(-c);r[0]=d*Math.cos(p),r[1]=-d*Math.cos(p+Math.PI/3),r[2]=-d*Math.cos(p-Math.PI/3),f=3}else{var m=Math.sqrt(h),g=Math.cbrt(m-l),v=-Math.cbrt(m+l);r[0]=g+v,f=1}for(var y=1/3*o,x=0;x=0&&o<=1&&o>i&&(i=o)}i===-1/0&&(i=0)}return i}(R,P,r);return R_(t.value,b,w,i.value,I)}var D=t.value+s*c*o,O=i.value-s*h*o;return R_(t.value,D,O,i.value,r)}}(_,p,d,n[h],(e-_)/(d-_))},n.addKeyFrame=function(t,n){return e.prototype.addKeyFrame.call(this,t,l_(n))},n.assignSorted=function(e,t){if(void 0!==t)this.setKeyframes(e.slice(),t.map((function(e){return l_(e)})));else{var n=Array.from(e);this.setKeyframes(n.map((function(e){return e[0]})),n.map((function(e){return l_(e[1])})))}},n.isConstant=function(e){if(this._values.length<=1)return!0;var t=this._values[0].value;return this._values.every((function(n){return rn(n.value,t,e)}))},n[ah]=function(e,t){if(t.toCCON){var n=this._times,i=this._values,r=n.length,o=new DataView(new ArrayBuffer(0+f_+f_+__+p_*r+T_*r)),a=0;o.setUint8(a,this.preExtrapolation),a+=f_,o.setUint8(a,this.postExtrapolation),a+=f_,o.setUint32(a,r,!0),a+=__,n.forEach((function(e,t){return o.setFloat32(a+p_*t,e,!0)})),a+=p_*r;for(var s,c=oe(i);!(s=c()).done;){var l=s.value;a=E_(o,l,a)}var u=new Uint8Array(o.buffer,0,a);e.writeProperty("bytes",u);var h=i.map((function(e){return e[ol]}));h.some((function(e){return void 0!==e}))&&e.writeProperty("keyframeValueEditorExtras",h)}else e.writeThis()},n[sh]=function(e,t){if(t.fromCCON){var n=e.readProperty("bytes"),i=new DataView(n.buffer,n.byteOffset,n.byteLength),r=0;this.preExtrapolation=i.getUint8(r),r+=f_,this.postExtrapolation=i.getUint8(r),r+=f_;var o=i.getUint32(r,!0);r+=__;var a=Array.from({length:o},(function(e,t){return i.getFloat32(r+p_*t,!0)}));r+=p_*o;for(var s=new Array(o),c=0;c>8;return t.easingMethod=o,i}function C_(e,t,n){return t+gn(e-t,n-t)}function b_(e,t,n){return t+vn(e-t,n-t)}function w_(e,t,n,i,r){return t+(i-t)/(n-e)*(r-e)}function R_(e,t,n,i,r){var o=1-r;return o*o*o*e+3*o*o*r*t+3*o*r*r*n+r*r*r*i}function P_(e,t,n,i,r){var o=1-r;return o*(o*(e+(3*t-e)*r)+3*n*r*r)+i*r*r*r}c.bezier=P_;var I_,D_,O_,M_,N_,L_,F_,B_,z_,k_,U_,G_=Math.cos,H_=Math.acos,V_=Math.max,j_=2*Math.PI,W_=Math.sqrt;function q_(e){return e<0?-Math.pow(-e,1/3):Math.pow(e,1/3)}function X_(e,t){var n=function(e,t){var n,i,r,o,a=t-0,s=t-e[0],c=3*a,l=3*s,u=3*(t-e[2]),h=1/(-a+l-u+(t-1)),f=1/3,_=(c-6*s+u)*h,p=_*f,d=(-c+l)*h,m=(3*d-_*_)*f,g=m*f,v=(2*_*_*_-9*_*d+a*h*27)/27,y=v/2,x=y*y+g*g*g;if(x<0){var S=-m*f,T=W_(S*S*S),E=-v/(2*T),A=H_(E<-1?-1:E>1?1:E),C=2*q_(T);return i=C*G_(A*f)-p,r=C*G_((A+j_)*f)-p,o=C*G_((A+2*j_)*f)-p,i>=0&&i<=1?r>=0&&r<=1?o>=0&&o<=1?V_(i,r,o):V_(i,r):o>=0&&o<=1?V_(i,o):i:r>=0&&r<=1?o>=0&&o<=1?V_(r,o):r:o}if(0===x)return r=-(n=y<0?q_(-y):-q_(y))-p,(i=2*n-p)>=0&&i<=1?r>=0&&r<=1?V_(i,r):i:r;var b=W_(x);return(n=q_(-y+b))-q_(y+b)-p}(e,t),i=e[1];return((1-n)*(i+(e[3]-i)*n)*3+n*n)*n}c.bezierByTime=X_,function(e){e[e.SLERP=0]="SLERP",e[e.CONSTANT=1]="CONSTANT"}(U_||(U_=e("QuatInterpolationMode",{})));var Y_=hc("cc.QuatKeyframeValue")(I_=Sc((O_=se((D_=function(e){var t=void 0===e?{}:e,n=t.value,i=t.interpolationMode,r=t.easingMethod;ae(this,"interpolationMode",O_,this),ae(this,"value",M_,this),ae(this,"easingMethod",N_,this),this.value=n?Mn.clone(n):this.value,this.interpolationMode=null!=i?i:this.interpolationMode,this.easingMethod=null!=r?r:this.easingMethod}).prototype,"interpolationMode",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return U_.SLERP}}),M_=se(D_.prototype,"value",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Mn.clone(Mn.IDENTITY)}}),N_=se(D_.prototype,"easingMethod",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Qf.LINEAR}}),I_=D_))||I_)||I_;function K_(e){return new Y_(e)}var Q_,Z_=e("QuatCurve",hc("cc.QuatCurve")((k_=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;rl){var h=r[s-1];switch(o){case $c.LOOP:e=c+gn(e-c,l-c);break;case $c.PING_PONG:e=c+vn(e-c,l-c);break;case $c.CLAMP:default:return Mn.copy(t,h.value)}}var f=nc(i,e);if(f>=0)return Mn.copy(t,r[f].value);var _=~f,p=_-1,d=i[p],m=r[p],g=i[_],v=r[_],y=(e-d)/(g-d);switch(m.interpolationMode){default:case U_.CONSTANT:return Mn.copy(t,m.value);case U_.SLERP:var x=m.easingMethod,S=x===Qf.LINEAR?y:Array.isArray(x)?X_(x,y):r_(x)(y);return Mn.slerp(t,m.value,v.value,S)}},n.addKeyFrame=function(t,n){var i=new Y_(n);return e.prototype.addKeyFrame.call(this,t,i)},n.assignSorted=function(e,t){if(void 0!==t)this.setKeyframes(e.slice(),t.map((function(e){return K_(e)})));else{var n=Array.from(e);this.setKeyframes(n.map((function(e){return e[0]})),n.map((function(e){return K_(e[1])})))}},n[ah]=function(e,t){if(t.toCCON){var n=this._times,i=this._values,r=!0;i.forEach((function(e,t,n){var i=n[0];r&&e.interpolationMode!==i.interpolationMode&&(r=!1)}));var o=n.length,a=cp*(r?1:o),s=i.reduce((function(e,t){var n=t.easingMethod;return e+(Array.isArray(n)?lp+4*hp:lp)}),0),c=0,l=new DataView(new ArrayBuffer(c+=rp+op+ap*o+4*sp*o+s+a+0)),u=0,h=0;r&&(h|=Q_.INTERPOLATION_MODE),l.setUint32(u,h,!0),u+=rp,l.setUint32(u,o,!0),u+=op,n.forEach((function(e,t){return l.setFloat32(u+ap*t,e,!0)})),u+=ap*o,i.forEach((function(e,t){var n=e.value,i=n.x,r=n.y,o=n.z,a=n.w,s=u+4*sp*t;l.setFloat32(s+0*sp,i,!0),l.setFloat32(s+1*sp,r,!0),l.setFloat32(s+2*sp,o,!0),l.setFloat32(s+3*sp,a,!0)})),u+=4*sp*o,i.forEach((function(e){var t=e.easingMethod;Array.isArray(t)?(l.setUint8(u,up),++u,l.setFloat32(u+0*hp,t[0],!0),l.setFloat32(u+1*hp,t[1],!0),l.setFloat32(u+2*hp,t[2],!0),l.setFloat32(u+3*hp,t[3],!0),u+=4*hp):(l.setUint8(u,t),++u)}));var f=u;u+=a;var _=f;i.forEach((function(e){var t=e.interpolationMode;l.setUint8(_,t),r||(_+=cp)}));var p=new Uint8Array(l.buffer);e.writeProperty("bytes",p)}else e.writeThis()},n[sh]=function(e,t){if(t.fromCCON){var n=e.readProperty("bytes"),i=new DataView(n.buffer,n.byteOffset,n.byteLength),r=0,o=i.getUint32(r,!0);r+=rp;var a=o&Q_.INTERPOLATION_MODE,s=i.getUint32(r,!0);r+=op;var c=Array.from({length:s},(function(e,t){return i.getFloat32(r+ap*t,!0)})),l=r+=ap*s;r+=4*sp*s;var u=Array.from({length:s},(function(e,t){var n=l+4*sp*t,o=i.getFloat32(n+0*sp,!0),a=i.getFloat32(n+1*sp,!0),s=i.getFloat32(n+2*sp,!0),c=i.getFloat32(n+3*sp,!0),u=i.getUint8(r);++r;var h=K_({value:{x:o,y:a,z:s,w:c}});return u!==up?h.easingMethod=u:(h.easingMethod=[i.getFloat32(r+0*hp,!0),i.getFloat32(r+1*hp,!0),i.getFloat32(r+2*hp,!0),i.getFloat32(r+3*hp,!0)],r+=4*hp),h}));if(a){var h=i.getUint8(r);++r;for(var f=0;f=0)return this._values[t];var n=on(~t-1,0,this._values.length-1);return this._values[n]},t}(nl))||J_),_p=function(){this.time=0,this.value=0,this.inTangent=0,this.outTangent=0};Qt.fastDefine("cc.Keyframe",_p,{time:0,value:0,inTangent:0,outTangent:0});var pp=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}(),dp=hc("cc.AnimationCurve")((ip=np=function(){function e(e){if(void 0===e&&(e=null),ae(this,"_curve",tp,this),this.cachedKey=void 0,e instanceof h_)this._curve=e;else{var t=new h_;this._curve=t,t.preExtrapolation=$c.LOOP,t.postExtrapolation=$c.CLAMP,e?t.assignSorted(e.map((function(e){return[e.time,{interpolationMode:Jc.CUBIC,value:e.value,leftTangent:e.inTangent,rightTangent:e.outTangent}]}))):t.assignSorted([[0,{interpolationMode:Jc.CUBIC,value:1}],[1,{interpolationMode:Jc.CUBIC,value:1}]])}this.cachedKey=new pp}var t=e.prototype;return t.addKey=function(e){e?this._curve.addKeyFrame(e.time,{interpolationMode:Jc.CUBIC,value:e.value,leftTangent:e.inTangent,rightTangent:e.outTangent}):this._curve.clear()},t.evaluate_slow=function(e){return this._curve.evaluate(e)},t.evaluate=function(e){var t=this.cachedKey,n=this._curve,i=n.keyFramesCount-1,r=e,o=e<0?n.preExtrapolation:n.postExtrapolation,a=n.getKeyframeTime(0),s=n.getKeyframeTime(i);switch(o){case $c.LOOP:r=gn(e-a,s-a)+a;break;case $c.PING_PONG:r=vn(e-a,s-a)+a;break;case $c.CLAMP:default:r=on(e,a,s)}if(r>=t.time&&rn.getKeyframeTime(r))for(var o=0;o<3;o++){var a=r+o;if(a+1t)return a}else for(var s=0;s<3;s++){var c=r-s;if(c>=0&&n.getKeyframeTime(c-1)<=t)return c-1}for(var l,u=0,h=i;h-u>1;)l=Math.floor((u+h)/2),n.getKeyframeTime(l)>=t?h=l:u=l;return u},K(e,[{key:"_internalCurve",get:function(){return this._curve}},{key:"keyFrames",get:function(){return Array.from(this._curve.keyframes()).map((function(e){var t=e[0],n=e[1],i=new _p;return i.time=t,i.value=n.value,i.inTangent=n.leftTangent,i.outTangent=n.rightTangent,i}))},set:function(e){this._curve.assignSorted(e.map((function(e){return[e.time,{interpolationMode:Jc.CUBIC,value:e.value,leftTangent:e.inTangent,rightTangent:e.outTangent}]})))}},{key:"preWrapMode",get:function(){return gp(this._curve.preExtrapolation)},set:function(e){this._curve.preExtrapolation=mp(e)}},{key:"postWrapMode",get:function(){return gp(this._curve.postExtrapolation)},set:function(e){this._curve.postExtrapolation=mp(e)}}]),e}(),np.defaultKF=[{time:0,value:1,inTangent:0,outTangent:0},{time:1,value:1,inTangent:0,outTangent:0}],tp=se((ep=ip).prototype,"_curve",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),$_=ep))||$_;function mp(e){switch(e){default:case Ks.Default:case Ks.Normal:case Ks.Clamp:return $c.CLAMP;case Ks.PingPong:return $c.PING_PONG;case Ks.Loop:return $c.LOOP}}function gp(e){switch(e){default:case $c.LINEAR:case $c.CLAMP:return Ks.Clamp;case $c.PING_PONG:return Ks.PingPong;case $c.LOOP:return Ks.Loop}}function vp(e,t){console.warn(e+" is deprecated, please use "+t+" instead.")}z(cs,"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 yp=function(e){function t(){var t;return t=e.call(this)||this,vp("line","Line"),t}return Z(t,e),t}(Qo),xp=function(e){function t(){var t;return t=e.call(this)||this,vp("plane","Plane"),t}return Z(t,e),t}(xs),Sp=function(e){function t(){var t;return t=e.call(this)||this,vp("ray","Ray"),t}return Z(t,e),t}(Zo),Tp=function(e){function t(){var t;return t=e.call(this)||this,vp("triangle","Triangle"),t}return Z(t,e),t}(oa),Ep=function(e){function t(){var t;return t=e.call(this)||this,vp("sphere","Sphere"),t}return Z(t,e),t}(ra),Ap=function(e){function t(){var t;return t=e.call(this)||this,vp("aabb","AABB"),t}return Z(t,e),t}(Hs),Cp=function(e){function t(){var t;return t=e.call(this)||this,vp("obb","OBB"),t}return Z(t,e),t}(qs),bp=function(e){function t(){var t;return t=e.call(this)||this,vp("capsule","Capsule"),t}return Z(t,e),t}(Xs),wp=function(e){function t(){var t;return t=e.call(this)||this,vp("frustum","Frustum"),t}return Z(t,e),t}(ec),Rp=Object.freeze({__proto__:null,distance:Yo,enums:Ko,intersect:cs,Line:Qo,Plane:xs,Ray:Zo,Triangle:oa,Sphere:ra,AABB:Hs,OBB:qs,Capsule:Xs,Frustum:ec,Keyframe:_p,AnimationCurve:dp,get ERaycastMode(){return ia},line:yp,plane:xp,ray:Sp,triangle:Tp,sphere:Ep,aabb:Ap,obb:Cp,capsule:bp,frustum:wp});e("geometry",Rp);var Pp={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},Ip=e("Layers",function(){function e(){}return e.makeMaskInclude=function(e){for(var t,n=0,i=oe(e);!(t=i()).done;)n|=t.value;return n},e.makeMaskExclude=function(t){return~e.makeMaskInclude(t)},e.addLayer=function(t,n){if(void 0!==n)if(n>19||n<0)console.warn("maximum layers reached.");else{var i=1<19||t<0)console.warn("do not change buildin layers.");else{var n=1<31||t<0?(console.warn("Unable to access unknown layer."),""):e.Enum[1<>>26},em=function(e){return(e&Qd)>>>20},tm=function(e){return(e&Zd)>>>12},nm=function(e){return 4095&e},im=function(e,t){return 67108863&e|t<<26&Kd},rm=((Vd={})[fi.UNKNOWN]=function(){return console.warn("illegal uniform handle")},Vd[fi.INT]=function(e,t,n){return void 0===n&&(n=0),e[n]},Vd[fi.INT2]=function(e,t,n){return void 0===n&&(n=0),Wn.fromArray(t,e,n)},Vd[fi.INT3]=function(e,t,n){return void 0===n&&(n=0),bn.fromArray(t,e,n)},Vd[fi.INT4]=function(e,t,n){return void 0===n&&(n=0),Kn.fromArray(t,e,n)},Vd[fi.FLOAT]=function(e,t,n){return void 0===n&&(n=0),e[n]},Vd[fi.FLOAT2]=function(e,t,n){return void 0===n&&(n=0),Wn.fromArray(t,e,n)},Vd[fi.FLOAT3]=function(e,t,n){return void 0===n&&(n=0),bn.fromArray(t,e,n)},Vd[fi.FLOAT4]=function(e,t,n){return void 0===n&&(n=0),Kn.fromArray(t,e,n)},Vd[fi.MAT3]=function(e,t,n){return void 0===n&&(n=0),In.fromArray(t,e,n)},Vd[fi.MAT4]=function(e,t,n){return void 0===n&&(n=0),Gn.fromArray(t,e,n)},Vd),om=((jd={})[fi.UNKNOWN]=function(){return console.warn("illegal uniform handle")},jd[fi.INT]=function(e,t,n){return void 0===n&&(n=0),e[n]=t},jd[fi.INT2]=function(e,t,n){return void 0===n&&(n=0),Wn.toArray(e,t,n)},jd[fi.INT3]=function(e,t,n){return void 0===n&&(n=0),bn.toArray(e,t,n)},jd[fi.INT4]=function(e,t,n){return void 0===n&&(n=0),Kn.toArray(e,t,n)},jd[fi.FLOAT]=function(e,t,n){return void 0===n&&(n=0),e[n]=t},jd[fi.FLOAT2]=function(e,t,n){return void 0===n&&(n=0),Wn.toArray(e,t,n)},jd[fi.FLOAT3]=function(e,t,n){return void 0===n&&(n=0),bn.toArray(e,t,n)},jd[fi.FLOAT4]=function(e,t,n){return void 0===n&&(n=0),Kn.toArray(e,t,n)},jd[fi.MAT3]=function(e,t,n){return void 0===n&&(n=0),In.toArray(e,t,n)},jd[fi.MAT4]=function(e,t,n){return void 0===n&&(n=0),Gn.toArray(e,t,n)},jd),am=[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 sm(e){switch(e){case fi.BOOL:case fi.INT:case fi.UINT:case fi.FLOAT:return am[0];case fi.BOOL2:case fi.INT2:case fi.UINT2:case fi.FLOAT2:return am[1];case fi.BOOL4:case fi.INT4:case fi.UINT4:case fi.FLOAT4:return am[2];case fi.MAT4:return am[3];case fi.SAMPLER2D:return"default-texture";case fi.SAMPLER_CUBE:return"default-cube-texture"}return am[0]}function cm(e,t){for(var n=Object.entries(t),i=!1,r=0;r31&&(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.shaderInfo=new wr,s.blockSizes=[],s.bindings=[];for(var c=0;c>2)*s.count}for(var c=0;c0&&this.shaders.length>0},t}(Ru),Tm._effects={},vm=se((gm=Em).prototype,"techniques",[gc,Rc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),ym=se(gm.prototype,"shaders",[gc,Rc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),xm=se(gm.prototype,"combinations",[gc,Rc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Sm=se(gm.prototype,"hideInEditor",[gc,yc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),mm=gm))||mm);c.EffectAsset=Cm;var bm,wm,Rm,Pm,Im,Dm,Om,Mm,Nm,Lm,Fm,Bm,zm,km,Um,Gm=1024;!function(e){e[e.RGB565=ui.R5G6B5]="RGB565",e[e.RGB5A1=ui.RGB5A1]="RGB5A1",e[e.RGBA4444=ui.RGBA4]="RGBA4444",e[e.RGB888=ui.RGB8]="RGB888",e[e.RGB32F=ui.RGB32F]="RGB32F",e[e.RGBA8888=ui.RGBA8]="RGBA8888",e[e.RGBA32F=ui.RGBA32F]="RGBA32F",e[e.A8=ui.A8]="A8",e[e.I8=ui.L8]="I8",e[e.AI8=ui.LA8]="AI8",e[e.RGB_PVRTC_2BPPV1=ui.PVRTC_RGB2]="RGB_PVRTC_2BPPV1",e[e.RGBA_PVRTC_2BPPV1=ui.PVRTC_RGBA2]="RGBA_PVRTC_2BPPV1",e[e.RGB_A_PVRTC_2BPPV1=Gm++]="RGB_A_PVRTC_2BPPV1",e[e.RGB_PVRTC_4BPPV1=ui.PVRTC_RGB4]="RGB_PVRTC_4BPPV1",e[e.RGBA_PVRTC_4BPPV1=ui.PVRTC_RGBA4]="RGBA_PVRTC_4BPPV1",e[e.RGB_A_PVRTC_4BPPV1=Gm++]="RGB_A_PVRTC_4BPPV1",e[e.RGB_ETC1=ui.ETC_RGB8]="RGB_ETC1",e[e.RGBA_ETC1=Gm++]="RGBA_ETC1",e[e.RGB_ETC2=ui.ETC2_RGB8]="RGB_ETC2",e[e.RGBA_ETC2=ui.ETC2_RGBA8]="RGBA_ETC2",e[e.RGBA_ASTC_4x4=ui.ASTC_RGBA_4X4]="RGBA_ASTC_4x4",e[e.RGBA_ASTC_5x4=ui.ASTC_RGBA_5X4]="RGBA_ASTC_5x4",e[e.RGBA_ASTC_5x5=ui.ASTC_RGBA_5X5]="RGBA_ASTC_5x5",e[e.RGBA_ASTC_6x5=ui.ASTC_RGBA_6X5]="RGBA_ASTC_6x5",e[e.RGBA_ASTC_6x6=ui.ASTC_RGBA_6X6]="RGBA_ASTC_6x6",e[e.RGBA_ASTC_8x5=ui.ASTC_RGBA_8X5]="RGBA_ASTC_8x5",e[e.RGBA_ASTC_8x6=ui.ASTC_RGBA_8X6]="RGBA_ASTC_8x6",e[e.RGBA_ASTC_8x8=ui.ASTC_RGBA_8X8]="RGBA_ASTC_8x8",e[e.RGBA_ASTC_10x5=ui.ASTC_RGBA_10X5]="RGBA_ASTC_10x5",e[e.RGBA_ASTC_10x6=ui.ASTC_RGBA_10X6]="RGBA_ASTC_10x6",e[e.RGBA_ASTC_10x8=ui.ASTC_RGBA_10X8]="RGBA_ASTC_10x8",e[e.RGBA_ASTC_10x10=ui.ASTC_RGBA_10X10]="RGBA_ASTC_10x10",e[e.RGBA_ASTC_12x10=ui.ASTC_RGBA_12X10]="RGBA_ASTC_12x10",e[e.RGBA_ASTC_12x12=ui.ASTC_RGBA_12X12]="RGBA_ASTC_12x12"}(bm||(bm={})),function(e){e[e.REPEAT=Ei.WRAP]="REPEAT",e[e.CLAMP_TO_EDGE=Ei.CLAMP]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=Ei.MIRROR]="MIRRORED_REPEAT",e[e.CLAMP_TO_BORDER=Ei.BORDER]="CLAMP_TO_BORDER"}(wm||(wm={})),function(e){e[e.NONE=Ti.NONE]="NONE",e[e.LINEAR=Ti.LINEAR]="LINEAR",e[e.NEAREST=Ti.POINT]="NEAREST"}(Rm||(Rm={})),at(ui);var Hm,Vm,jm,Wm,qm=new pe("Tex"),Xm=hc("cc.TextureBase")((Um=km=function(e){function t(){var t;return ae(t=e.call(this)||this,"_format",Dm,ie(t)),ae(t,"_minFilter",Om,ie(t)),ae(t,"_magFilter",Mm,ie(t)),ae(t,"_mipFilter",Nm,ie(t)),ae(t,"_wrapS",Lm,ie(t)),ae(t,"_wrapT",Fm,ie(t)),ae(t,"_wrapR",Bm,ie(t)),ae(t,"_anisotropy",zm,ie(t)),t._width=1,t._height=1,t._id=void 0,t._samplerInfo=new mr,t._gfxSampler=null,t._gfxDevice=null,t._textureHash=0,t._id=qm.getNewId(),t._gfxDevice=t._getGFXDevice(),t._textureHash=po(t._id,666),t}Z(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){void 0===n&&(n=e),this._wrapS=e,this._samplerInfo.addressU=e,this._wrapT=t,this._samplerInfo.addressV=t,this._wrapR=n,this._samplerInfo.addressW=n,this._gfxDevice&&(this._gfxSampler=this._gfxDevice.getSampler(this._samplerInfo))},n.setFilters=function(e,t){this._minFilter=e,this._samplerInfo.minFilter=e,this._magFilter=t,this._samplerInfo.magFilter=t,this._gfxDevice&&(this._gfxSampler=this._gfxDevice.getSampler(this._samplerInfo))},n.setMipFilter=function(e){this._mipFilter=e,this._samplerInfo.mipFilter=e,this._gfxDevice&&(this._gfxSampler=this._gfxDevice.getSampler(this._samplerInfo))},n.setAnisotropy=function(e){this._anisotropy=e,this._samplerInfo.maxAnisotropy=e,this._gfxDevice&&(this._gfxSampler=this._gfxDevice.getSampler(this._samplerInfo))},n.destroy=function(){var t,n=e.prototype.destroy.call(this);return n&&(null===(t=c.director.root)||void 0===t?void 0:t.batcher2D)&&c.director.root.batcher2D._releaseDescriptorSetCache(this._textureHash),n},n.getHash=function(){return this._textureHash},n.getGFXTexture=function(){return null},n.getSamplerInfo=function(){return this._samplerInfo},n.getGFXSampler=function(){return this._gfxSampler||(this._gfxDevice?this._gfxSampler=this._gfxDevice.getSampler(this._samplerInfo):D(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?bm.RGBA8888:e},n._getGFXPixelFormat=function(e){return e===bm.RGBA_ETC1?e=bm.RGB_ETC1:e===bm.RGB_A_PVRTC_4BPPV1?e=bm.RGB_PVRTC_4BPPV1:e===bm.RGB_A_PVRTC_2BPPV1&&(e=bm.RGB_PVRTC_2BPPV1),e},K(t,[{key:"isCompressed",get:function(){return this._format>=bm.RGB_ETC1&&this._format<=bm.RGBA_ASTC_12x12||this._format>=bm.RGB_A_PVRTC_2BPPV1&&this._format<=bm.RGBA_ETC1}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}}]),t}(Ru),km.PixelFormat=bm,km.WrapMode=wm,km.Filter=Rm,Dm=se((Im=Um).prototype,"_format",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return bm.RGBA8888}}),Om=se(Im.prototype,"_minFilter",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Rm.LINEAR}}),Mm=se(Im.prototype,"_magFilter",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Rm.LINEAR}}),Nm=se(Im.prototype,"_mipFilter",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Rm.NONE}}),Lm=se(Im.prototype,"_wrapS",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return wm.REPEAT}}),Fm=se(Im.prototype,"_wrapT",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return wm.REPEAT}}),Bm=se(Im.prototype,"_wrapR",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return wm.REPEAT}}),zm=se(Im.prototype,"_anisotropy",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Pm=Im))||Pm;function Ym(e){return!!(c.sys.hasFeature(c.sys.Feature.IMAGE_BITMAP)&&e instanceof ImageBitmap)}c.TextureBase=Xm;var Km=e("ImageAsset",hc("cc.ImageAsset")((Wm=jm=function(e){function t(t){var n;return(n=e.call(this)||this)._nativeData=void 0,n._exportedExts=void 0,n._format=bm.RGBA8888,n._width=0,n._height=0,n._nativeData={_data:null,width:0,height:0,format:0,_compressed:!1},void 0!==t&&n.reset(t),n}Z(t,e);var n=t.prototype;return n.reset=function(e){Ym(e)||e instanceof HTMLElement?this._nativeData=e:(this._nativeData=e,this._format=e.format)},n.destroy=function(){return this.data&&this.data instanceof HTMLImageElement?(this.data.src="",this._setRawAsset("")):Ym(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,r=c.director.root?c.director.root.device:null,o=n.split("_"),a=Number.MAX_VALUE,s=this._format,l="",u=c.macro.SUPPORT_TEXTURE_FORMATS,h=oe(o);!(i=h()).done;){var f=i.value.split("@"),_=parseInt(f[0],void 0),p=t.extnames[_]||f[0],d=u.indexOf(p);if(-1!==d&&d=bm.RGB_ETC1&&this._format<=bm.RGBA_ASTC_12x12||this._format>=bm.RGB_A_PVRTC_2BPPV1&&this._format<=bm.RGBA_ETC1}},{key:"url",get:function(){return this.nativeUrl}}]),t}(Ru),jm.extnames=[".png",".jpg",".jpeg",".bmp",".webp",".pvr",".pkm",".astc"],jm._sharedPlaceHolderCanvas=null,se((Vm=Wm).prototype,"_nativeAsset",[tl],Object.getOwnPropertyDescriptor(Vm.prototype,"_nativeAsset"),Vm.prototype),Hm=Vm))||Hm);c.ImageAsset=Km;var Qm=new WeakMap,Zm=new WeakSet,Jm=new WeakSet;function $m(e,t){var n;n=Ju.safeFindClass;var i,r=xh.pool.get();try{i=Oh(e,r,{classFinder:n,customEnv:t})}catch(e){throw x(e),xh.pool.put(r),e}i._uuid=t.__uuid__||"";for(var o=r.uuidList,a=r.uuidObjList,s=r.uuidPropList,c=r.uuidTypeList||[],l=[],u=0;u>t,r.texExtent.height=this._textureHeight>>t,r.texSubres.mipLevel=t,r.texSubres.baseArrayLayer=n,ArrayBuffer.isView(e)?i.copyBuffersToTexture([e],this._gfxTexture,ng):i.copyTexImagesToTexture([e],this._gfxTexture,ng)}}},n._assignImage=function(e,t,n){var i=e.data;if(i&&(this.uploadData(i,t,n),this._checkTextureLoaded(),ct.CLEANUP_IMAGE_CACHE)){var r=tg.getDeps(this._uuid),o=r.indexOf(e._uuid);-1!==o&&(ue(r,o),e.decRef())}},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=yi.NONE;this._mipFilter!==Rm.NONE&&function(e,t,n){return!(e.gfxAPI===si.WEBGL)||ig(t)&&ig(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=yi.GEN_MIPMAP);var n=this._getGfxTextureCreateInfo({usage:vi.SAMPLED|vi.TRANSFER_DST,format:this._getGFXFormat(),levelCount:this._mipmapLevel,flags:t});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)},K(t,[{key:"mipmapLevel",get:function(){return this._mipmapLevel}}]),t}(Xm))||eg;c.SimpleTexture=ug;var hg,fg,_g,pg,dg,mg,gg,vg=e("Texture2D",(rg=hc("cc.Texture2D"),og=Wc([Km]),rg((lg=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r=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 r=0;r0){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}(ug),cg=se((sg=lg).prototype,"_mipmaps",[og],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),ag=sg))||ag));c.Texture2D=vg,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"}(gg||(gg={}));var yg=e("TextureCube",hc("cc.TextureCube")((mg=dg=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r=this._mipmaps.length))for(var i=Math.min(void 0===t?this._mipmaps.length:t,this._mipmaps.length-e),r=function(t){var i=e+t;xg(n._mipmaps[i],(function(e,t){n._assignImage(e,i,t)}))},o=0;o0){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){xg(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}(ug),dg.FaceIndex=gg,_g=se((fg=mg).prototype,"isRGBE",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),pg=se(fg.prototype,"_mipmaps",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),hg=fg))||hg);function xg(e,t){t(e.front,gg.front),t(e.back,gg.back),t(e.left,gg.left),t(e.right,gg.right),t(e.top,gg.top),t(e.bottom,gg.bottom)}c.TextureCube=yg;var Sg,Tg,Eg,Ag=e("effects",[{name:"billboard",techniques:[{name:"add",passes:[{rasterizerState:{cullMode:0},blendState:{targets:[{blend:!0,blendSrc:2,blendDst:1,blendSrcAlpha:2,blendDstAlpha:1}]},program:"billboard|vert:vs_main|tinted-fs:add",depthStencilState:{depthTest:!0,depthWrite:!1},properties:{mainTexture:{value:"grey",type:28},mainTiling_Offset:{value:[1,1,0,0],type:16},tintColor:{value:[.5,.5,.5,.5],type:16}}}]}],shaders:[{name:"billboard|vert:vs_main|tinted-fs:add",hash:2909832090,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:53,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:40},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplerTextures:[],buffers:[],images:[]},locals:{blocks:[{name:"CCLocal",defines:[]}],samplerTextures:[],buffers:[],images:[]}},defines:[],attributes:[{name:"a_position",defines:[],format:32,location:0},{name:"a_texCoord",defines:[],format:21,location:1},{name:"a_color",defines:[],format:44,location:2}],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:"nodeRotation",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}],buffers:[],images:[],textures:[],samplers:[],subpassInputs:[]}]},{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:3507038093,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:0,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:0},globals:{blocks:[],samplerTextures:[],buffers:[],images:[]},locals:{blocks:[],samplerTextures:[],buffers:[],images:[]}},defines:[],attributes:[{name:"a_position",defines:[],format:32,location:0}],blocks:[],samplerTextures:[],buffers:[],images:[],textures:[],samplers:[],subpassInputs:[]}]},{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:2610213142,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:48,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:0},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplerTextures:[],buffers:[],images:[]},locals:{blocks:[{name:"CCLocal",defines:[]}],samplerTextures:[],buffers:[],images:[]}},defines:[],attributes:[{name:"a_position",defines:[],format:32,location:0},{name:"a_color",defines:[],format:44,location:1},{name:"a_dist",defines:[],format:11,location:2}],blocks:[],samplerTextures:[],buffers:[],images:[],textures:[],samplers:[],subpassInputs:[]}]},{name:"occlusion-query",techniques:[{passes:[{rasterizerState:{cullMode:2},blendState:{targets:[{blendColorMask:0}]},program:"occlusion-query|occlusion-query-vs:vert|occlusion-query-fs:frag",depthStencilState:{depthTest:!0,depthWrite:!1}}]}],shaders:[{name:"occlusion-query|occlusion-query-vs:vert|occlusion-query-fs:frag",hash:1571978323,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:41,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:0},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplerTextures:[],buffers:[],images:[]},locals:{blocks:[{name:"CCWorldBound",defines:[]}],samplerTextures:[],buffers:[],images:[]}},defines:[],attributes:[{name:"a_position",defines:[],format:32,location:0}],blocks:[],samplerTextures:[],buffers:[],images:[],textures:[],samplers:[],subpassInputs:[]}]},{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:1250077034,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:63,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:40},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplerTextures:[],buffers:[],images:[]},locals:{blocks:[{name:"CCLocal",defines:[]}],samplerTextures:[],buffers:[],images:[]}},defines:[{name:"CC_RENDER_MODE",type:"number",range:[0,4]},{name:"USE_VK_SHADER",type:"boolean"},{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"}],attributes:[{name:"a_position_starttime",defines:[],format:44,location:0},{name:"a_size_uv",defines:[],format:44,location:1},{name:"a_rotation_uv",defines:[],format:44,location:2},{name:"a_color",defines:[],format:44,location:3},{name:"a_dir_life",defines:[],format:44,location:4},{name:"a_rndSeed",defines:[],format:11,location:5},{name:"a_texCoord",defines:["CC_RENDER_MODE"],format:32,location:6},{name:"a_texCoord3",defines:["CC_RENDER_MODE"],format:32,location:7},{name:"a_normal",defines:["CC_RENDER_MODE"],format:32,location:8},{name:"a_color1",defines:["CC_RENDER_MODE"],format:44,location:9}],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:"nodeRotation",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}],buffers:[],images:[],textures:[],samplers:[],subpassInputs:[]}]},{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:1437790364,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:52,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:40},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplerTextures:[],buffers:[],images:[]},locals:{blocks:[{name:"CCLocal",defines:[]}],samplerTextures:[],buffers:[],images:[]}},defines:[{name:"CC_RENDER_MODE",type:"number",range:[0,4]},{name:"CC_DRAW_WIRE_FRAME",type:"boolean"},{name:"CC_USE_WORLD_SPACE",type:"boolean"}],attributes:[{name:"a_position",defines:[],format:32,location:0},{name:"a_texCoord",defines:[],format:44,location:1},{name:"a_texCoord1",defines:[],format:32,location:2},{name:"a_texCoord2",defines:[],format:32,location:3},{name:"a_color",defines:[],format:44,location:4}],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:"nodeRotation",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}],buffers:[],images:[],textures:[],samplers:[],subpassInputs:[]}]},{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:2554907268,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:52,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:40},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplerTextures:[],buffers:[],images:[]},locals:{blocks:[{name:"CCLocal",defines:[]}],samplerTextures:[],buffers:[],images:[]}},defines:[{name:"CC_RENDER_MODE",type:"number",range:[0,4]},{name:"CC_USE_WORLD_SPACE",type:"boolean"},{name:"ROTATION_OVER_TIME_MODULE_ENABLE",type:"boolean"}],attributes:[{name:"a_position",defines:[],format:32,location:0},{name:"a_texCoord",defines:[],format:32,location:1},{name:"a_texCoord1",defines:[],format:32,location:2},{name:"a_texCoord2",defines:[],format:32,location:3},{name:"a_color",defines:[],format:44,location:4},{name:"a_color1",defines:["CC_RENDER_MODE"],format:32,location:8},{name:"a_texCoord3",defines:["CC_RENDER_MODE"],format:32,location:6},{name:"a_normal",defines:["CC_RENDER_MODE"],format:32,location:7}],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:"nodeRotation",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}],buffers:[],images:[],textures:[],samplers:[],subpassInputs:[]}]},{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:3192452405,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:48,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:1},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplerTextures:[],buffers:[],images:[]},locals:{blocks:[{name:"CCLocal",defines:["USE_LOCAL"]}],samplerTextures:[{name:"cc_spriteTexture",defines:[]}],buffers:[],images:[]}},defines:[{name:"USE_LOCAL",type:"boolean"},{name:"TWO_COLORED",type:"boolean"},{name:"USE_ALPHA_TEST",type:"boolean"}],attributes:[{name:"a_position",defines:[],format:32,location:0},{name:"a_texCoord",defines:[],format:21,location:1},{name:"a_color",defines:[],format:44,location:2},{name:"a_color2",defines:["TWO_COLORED"],format:44,location:3}],blocks:[{name:"ALPHA_TEST_DATA",defines:["USE_ALPHA_TEST"],binding:0,stageFlags:16,members:[{name:"alphaThreshold",type:13,count:1}]}],samplerTextures:[],buffers:[],images:[],textures:[],samplers:[],subpassInputs:[]}]},{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:1770338543,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:48,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:1},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplerTextures:[],buffers:[],images:[]},locals:{blocks:[{name:"CCLocal",defines:["USE_LOCAL"]}],samplerTextures:[{name:"cc_spriteTexture",defines:["USE_TEXTURE"]}],buffers:[],images:[]}},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"}],attributes:[{name:"a_position",defines:[],format:32,location:0},{name:"a_texCoord",defines:[],format:21,location:1},{name:"a_color",defines:[],format:44,location:2}],blocks:[{name:"ALPHA_TEST_DATA",defines:["USE_ALPHA_TEST"],binding:0,stageFlags:16,members:[{name:"alphaThreshold",type:13,count:1}]}],samplerTextures:[],buffers:[],images:[],textures:[],samplers:[],subpassInputs:[]}]},{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],linear:!0,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]},SpecularIntensity:{value:[.5],type:13,handleInfo:["pbrParams",3,13]},emissive:{value:[0,0,0,1],linear:!0,type:16},emissiveScale:{value:[1,1,1],type:15,handleInfo:["emissiveScaleParam",0,15]},normalStrenth:{value:[1],type:13,handleInfo:["emissiveScaleParam",3,13]},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,.5]},emissiveScaleParam:{type:16,value:[1,1,1,1]},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}},{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]},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]},albedoMap:{type:28,value:"grey"}}}]}],shaders:[{name:"standard|standard-vs|standard-fs",hash:4038009253,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:222,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:65},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_diffuseMap",defines:["CC_USE_IBL","CC_USE_DIFFUSEMAP"]}],buffers:[],images:[]},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","CC_ENABLE_CLUSTERED_LIGHT_CULLING"]}],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"]}],buffers:[],images:[]}},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_USE_ACCURATE_FOG",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:"CC_FORWARD_ADD",type:"boolean"},{name:"USE_TWOSIDE",type:"boolean"},{name:"SAMPLE_FROM_RT",type:"boolean"},{name:"CC_USE_IBL",type:"number",range:[0,2]},{name:"CC_USE_DIFFUSEMAP",type:"number",range:[0,2]},{name:"USE_REFLECTION_DENOISE",type:"boolean"},{name:"CC_USE_HDR",type:"boolean"},{name:"USE_ALBEDO_MAP",type:"boolean"},{name:"ALBEDO_UV",type:"string",options:["v_uv","v_uv1"]},{name:"NORMAL_UV",type:"string",options:["v_uv","v_uv1"]},{name:"PBR_UV",type:"string",options:["v_uv","v_uv1"]},{name:"USE_PBR_MAP",type:"boolean"},{name:"USE_METALLIC_ROUGHNESS_MAP",type:"boolean"},{name:"USE_OCCLUSION_MAP",type:"boolean"},{name:"USE_EMISSIVE_MAP",type:"boolean"},{name:"EMISSIVE_UV",type:"string",options:["v_uv","v_uv1"]},{name:"USE_ALPHA_TEST",type:"boolean"},{name:"ALPHA_TEST_CHANNEL",type:"string",options:["a","r"]},{name:"CC_PIPELINE_TYPE",type:"number",range:[0,1]},{name:"CC_FORCE_FORWARD_SHADING",type:"boolean"}],attributes:[{name:"a_position",defines:[],format:32,location:0},{name:"a_normal",defines:[],format:32,location:1},{name:"a_texCoord",defines:[],format:21,location:2},{name:"a_tangent",defines:[],format:44,location:3},{name:"a_vertexId",defines:["CC_USE_MORPH"],format:11,location:6},{name:"a_joints",defines:["CC_USE_SKINNING"],location:4},{name:"a_weights",defines:["CC_USE_SKINNING"],format:44,location:5},{name:"a_jointAnimInfo",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION","USE_INSTANCING"],format:44,isInstanced:!0,location:7},{name:"a_matWorld0",defines:["USE_INSTANCING"],format:44,isInstanced:!0,location:8},{name:"a_matWorld1",defines:["USE_INSTANCING"],format:44,isInstanced:!0,location:9},{name:"a_matWorld2",defines:["USE_INSTANCING"],format:44,isInstanced:!0,location:10},{name:"a_lightingMapUVParam",defines:["USE_INSTANCING","USE_LIGHTMAP"],format:44,isInstanced:!0,location:11},{name:"a_dyn_batch_id",defines:["!USE_INSTANCING","USE_BATCHING"],format:11,location:12},{name:"a_color",defines:["USE_VERTEX_COLOR"],format:44,location:13},{name:"a_texCoord1",defines:[],format:21,location:14}],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}],buffers:[{name:"b_ccLightsBuffer",memoryAccess:1,defines:["CC_FORWARD_ADD","CC_ENABLE_CLUSTERED_LIGHT_CULLING"],stageFlags:16,binding:7},{name:"b_clusterLightIndicesBuffer",memoryAccess:1,defines:["CC_FORWARD_ADD","CC_ENABLE_CLUSTERED_LIGHT_CULLING"],stageFlags:16,binding:8},{name:"b_clusterLightGridBuffer",memoryAccess:1,defines:["CC_FORWARD_ADD","CC_ENABLE_CLUSTERED_LIGHT_CULLING"],stageFlags:16,binding:9}],images:[],textures:[],samplers:[],subpassInputs:[]},{name:"standard|shadow-caster-vs:vert|shadow-caster-fs:frag",hash:210600745,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:183,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:65},globals:{blocks:[{name:"CCShadow",defines:[]},{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplerTextures:[{name:"cc_shadowMap",defines:["CC_RECEIVE_SHADOW"]},{name:"cc_spotLightingMap",defines:["CC_RECEIVE_SHADOW"]}],buffers:[],images:[]},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"]}],buffers:[],images:[]}},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:"CC_RECEIVE_SHADOW",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"]}],attributes:[{name:"a_position",defines:[],format:32,location:0},{name:"a_normal",defines:[],format:32,location:1},{name:"a_texCoord",defines:[],format:21,location:2},{name:"a_tangent",defines:[],format:44,location:3},{name:"a_vertexId",defines:["CC_USE_MORPH"],format:11,location:6},{name:"a_joints",defines:["CC_USE_SKINNING"],location:4},{name:"a_weights",defines:["CC_USE_SKINNING"],format:44,location:5},{name:"a_jointAnimInfo",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION","USE_INSTANCING"],format:44,isInstanced:!0,location:7},{name:"a_matWorld0",defines:["USE_INSTANCING"],format:44,isInstanced:!0,location:8},{name:"a_matWorld1",defines:["USE_INSTANCING"],format:44,isInstanced:!0,location:9},{name:"a_matWorld2",defines:["USE_INSTANCING"],format:44,isInstanced:!0,location:10},{name:"a_lightingMapUVParam",defines:["USE_INSTANCING","USE_LIGHTMAP"],format:44,isInstanced:!0,location:11},{name:"a_dyn_batch_id",defines:["!USE_INSTANCING","USE_BATCHING"],format:11,location:12},{name:"a_texCoord1",defines:[],format:21,location:13}],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}],buffers:[],images:[],textures:[],samplers:[],subpassInputs:[]}]},{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:"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:3916952624,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:70,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:61},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_diffuseMap",defines:["CC_USE_IBL","CC_USE_DIFFUSEMAP"]}],buffers:[],images:[]},locals:{blocks:[{name:"CCLocal",defines:[]},{name:"CCForwardLight",defines:["CC_FORWARD_ADD","CC_ENABLE_CLUSTERED_LIGHT_CULLING"]}],samplerTextures:[{name:"cc_lightingMap",defines:["USE_LIGHTMAP","!USE_BATCHING","!CC_FORWARD_ADD"]}],buffers:[],images:[]}},defines:[{name:"CC_USE_FOG",type:"number",range:[0,4]},{name:"CC_USE_ACCURATE_FOG",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:"CC_USE_DIFFUSEMAP",type:"number",range:[0,2]},{name:"USE_REFLECTION_DENOISE",type:"boolean"},{name:"USE_BATCHING",type:"boolean"},{name:"CC_FORWARD_ADD",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]},{name:"CC_FORCE_FORWARD_SHADING",type:"boolean"}],attributes:[{name:"a_position",defines:[],format:32,location:0},{name:"a_normal",defines:[],format:32,location:1},{name:"a_texCoord",defines:[],format:21,location:2}],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}],buffers:[{name:"b_ccLightsBuffer",memoryAccess:1,defines:["CC_FORWARD_ADD","CC_ENABLE_CLUSTERED_LIGHT_CULLING"],stageFlags:16,binding:12},{name:"b_clusterLightIndicesBuffer",memoryAccess:1,defines:["CC_FORWARD_ADD","CC_ENABLE_CLUSTERED_LIGHT_CULLING"],stageFlags:16,binding:13},{name:"b_clusterLightGridBuffer",memoryAccess:1,defines:["CC_FORWARD_ADD","CC_ENABLE_CLUSTERED_LIGHT_CULLING"],stageFlags:16,binding:14}],images:[],textures:[],samplers:[],subpassInputs:[]},{name:"terrain|shadow-caster-vs:vert|shadow-caster-fs:frag",hash:4270039829,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:68,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:0},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]},{name:"CCShadow",defines:[]}],samplerTextures:[],buffers:[],images:[]},locals:{blocks:[{name:"CCLocal",defines:[]}],samplerTextures:[],buffers:[],images:[]}},defines:[],attributes:[{name:"a_position",defines:[],format:32,location:0},{name:"a_normal",defines:[],format:32,location:1},{name:"a_texCoord",defines:[],format:21,location:2}],blocks:[],samplerTextures:[],buffers:[],images:[],textures:[],samplers:[],subpassInputs:[]}]},{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],linear:!0,type:16},colorScale:{value:[1,1,1],type:15,handleInfo:["colorScaleAndCutoff",0,15]},alphaThreshold:{value:[.5],type:13,handleInfo:["colorScaleAndCutoff",3,13]},color:{linear:!0,type:16,handleInfo:["mainColor",0,16]},colorScaleAndCutoff:{type:16,value:[1,1,1,.5]}}}]}],shaders:[{name:"unlit|unlit-vs:vert|unlit-fs:frag",hash:3319190198,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:197,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:41},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplerTextures:[],buffers:[],images:[]},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"]}],buffers:[],images:[]}},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_USE_ACCURATE_FOG",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"]}],attributes:[{name:"a_position",defines:[],format:32,location:0},{name:"a_normal",defines:[],format:32,location:1},{name:"a_texCoord",defines:[],format:21,location:2},{name:"a_tangent",defines:[],format:44,location:3},{name:"a_vertexId",defines:["CC_USE_MORPH"],format:11,location:6},{name:"a_joints",defines:["CC_USE_SKINNING"],location:4},{name:"a_weights",defines:["CC_USE_SKINNING"],format:44,location:5},{name:"a_jointAnimInfo",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION","USE_INSTANCING"],format:44,isInstanced:!0,location:7},{name:"a_matWorld0",defines:["USE_INSTANCING"],format:44,isInstanced:!0,location:8},{name:"a_matWorld1",defines:["USE_INSTANCING"],format:44,isInstanced:!0,location:9},{name:"a_matWorld2",defines:["USE_INSTANCING"],format:44,isInstanced:!0,location:10},{name:"a_lightingMapUVParam",defines:["USE_INSTANCING","USE_LIGHTMAP"],format:44,isInstanced:!0,location:11},{name:"a_dyn_batch_id",defines:["!USE_INSTANCING","USE_BATCHING"],format:11,location:12},{name:"a_color",defines:["USE_VERTEX_COLOR"],format:44,location:13}],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}],buffers:[],images:[],textures:[],samplers:[],subpassInputs:[]}]},{name:"bloom",techniques:[{passes:[{phase:"bloom-prefilter",program:"bloom|bloom-vs|prefilter-fs",depthStencilState:{depthTest:!1,depthWrite:!1}},{phase:"bloom-downsample",program:"bloom|bloom-vs|downsample-fs",depthStencilState:{depthTest:!1,depthWrite:!1}},{phase:"bloom-downsample",program:"bloom|bloom-vs|downsample-fs",depthStencilState:{depthTest:!1,depthWrite:!1}},{phase:"bloom-downsample",program:"bloom|bloom-vs|downsample-fs",depthStencilState:{depthTest:!1,depthWrite:!1}},{phase:"bloom-downsample",program:"bloom|bloom-vs|downsample-fs",depthStencilState:{depthTest:!1,depthWrite:!1}},{phase:"bloom-downsample",program:"bloom|bloom-vs|downsample-fs",depthStencilState:{depthTest:!1,depthWrite:!1}},{phase:"bloom-downsample",program:"bloom|bloom-vs|downsample-fs",depthStencilState:{depthTest:!1,depthWrite:!1}},{phase:"bloom-upsample",program:"bloom|bloom-vs|upsample-fs",depthStencilState:{depthTest:!1,depthWrite:!1}},{phase:"bloom-upsample",program:"bloom|bloom-vs|upsample-fs",depthStencilState:{depthTest:!1,depthWrite:!1}},{phase:"bloom-upsample",program:"bloom|bloom-vs|upsample-fs",depthStencilState:{depthTest:!1,depthWrite:!1}},{phase:"bloom-upsample",program:"bloom|bloom-vs|upsample-fs",depthStencilState:{depthTest:!1,depthWrite:!1}},{phase:"bloom-upsample",program:"bloom|bloom-vs|upsample-fs",depthStencilState:{depthTest:!1,depthWrite:!1}},{phase:"bloom-upsample",program:"bloom|bloom-vs|upsample-fs",depthStencilState:{depthTest:!1,depthWrite:!1}},{phase:"bloom-combine",program:"bloom|bloom-vs|combine-fs",depthStencilState:{depthTest:!1,depthWrite:!1}}]}],shaders:[{name:"bloom|bloom-vs|prefilter-fs",hash:2185821616,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:147,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:40},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplerTextures:[],buffers:[],images:[]},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"]}],buffers:[],images:[]}},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"}],attributes:[{name:"a_position",defines:[],format:32,location:0},{name:"a_normal",defines:[],format:32,location:1},{name:"a_texCoord",defines:[],format:21,location:2},{name:"a_tangent",defines:[],format:44,location:3},{name:"a_vertexId",defines:["CC_USE_MORPH"],format:11,location:6},{name:"a_joints",defines:["CC_USE_SKINNING"],location:4},{name:"a_weights",defines:["CC_USE_SKINNING"],format:44,location:5},{name:"a_jointAnimInfo",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION","USE_INSTANCING"],format:44,isInstanced:!0,location:7}],blocks:[{name:"BloomUBO",defines:[],binding:0,stageFlags:16,members:[{name:"texSize",type:16,count:1}]}],samplerTextures:[{name:"outputResultMap",type:28,count:1,defines:[],stageFlags:16,binding:1}],buffers:[],images:[],textures:[],samplers:[],subpassInputs:[]},{name:"bloom|bloom-vs|downsample-fs",hash:1780231359,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:147,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:40},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplerTextures:[],buffers:[],images:[]},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"]}],buffers:[],images:[]}},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"}],attributes:[{name:"a_position",defines:[],format:32,location:0},{name:"a_normal",defines:[],format:32,location:1},{name:"a_texCoord",defines:[],format:21,location:2},{name:"a_tangent",defines:[],format:44,location:3},{name:"a_vertexId",defines:["CC_USE_MORPH"],format:11,location:6},{name:"a_joints",defines:["CC_USE_SKINNING"],location:4},{name:"a_weights",defines:["CC_USE_SKINNING"],format:44,location:5},{name:"a_jointAnimInfo",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION","USE_INSTANCING"],format:44,isInstanced:!0,location:7}],blocks:[{name:"BloomUBO",defines:[],binding:0,stageFlags:16,members:[{name:"texSize",type:16,count:1}]}],samplerTextures:[{name:"bloomTexture",type:28,count:1,defines:[],stageFlags:16,binding:1}],buffers:[],images:[],textures:[],samplers:[],subpassInputs:[]},{name:"bloom|bloom-vs|upsample-fs",hash:3580425335,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:147,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:40},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplerTextures:[],buffers:[],images:[]},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"]}],buffers:[],images:[]}},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"}],attributes:[{name:"a_position",defines:[],format:32,location:0},{name:"a_normal",defines:[],format:32,location:1},{name:"a_texCoord",defines:[],format:21,location:2},{name:"a_tangent",defines:[],format:44,location:3},{name:"a_vertexId",defines:["CC_USE_MORPH"],format:11,location:6},{name:"a_joints",defines:["CC_USE_SKINNING"],location:4},{name:"a_weights",defines:["CC_USE_SKINNING"],format:44,location:5},{name:"a_jointAnimInfo",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION","USE_INSTANCING"],format:44,isInstanced:!0,location:7}],blocks:[{name:"BloomUBO",defines:[],binding:0,stageFlags:16,members:[{name:"texSize",type:16,count:1}]}],samplerTextures:[{name:"bloomTexture",type:28,count:1,defines:[],stageFlags:16,binding:1}],buffers:[],images:[],textures:[],samplers:[],subpassInputs:[]},{name:"bloom|bloom-vs|combine-fs",hash:3457196798,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:147,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:40},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplerTextures:[],buffers:[],images:[]},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"]}],buffers:[],images:[]}},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"}],attributes:[{name:"a_position",defines:[],format:32,location:0},{name:"a_normal",defines:[],format:32,location:1},{name:"a_texCoord",defines:[],format:21,location:2},{name:"a_tangent",defines:[],format:44,location:3},{name:"a_vertexId",defines:["CC_USE_MORPH"],format:11,location:6},{name:"a_joints",defines:["CC_USE_SKINNING"],location:4},{name:"a_weights",defines:["CC_USE_SKINNING"],format:44,location:5},{name:"a_jointAnimInfo",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION","USE_INSTANCING"],format:44,isInstanced:!0,location:7}],blocks:[{name:"BloomUBO",defines:[],binding:0,stageFlags:16,members:[{name:"texSize",type:16,count:1}]}],samplerTextures:[{name:"outputResultMap",type:28,count:1,defines:[],stageFlags:16,binding:1},{name:"bloomTexture",type:28,count:1,defines:[],stageFlags:16,binding:2}],buffers:[],images:[],textures:[],samplers:[],subpassInputs:[]}]},{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:3788484086,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:39,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"]},{name:"cc_diffuseMap",defines:["CC_USE_IBL","CC_USE_DIFFUSEMAP"]}],buffers:[],images:[]},locals:{blocks:[{name:"CCForwardLight",defines:["CC_ENABLE_CLUSTERED_LIGHT_CULLING"]}],samplerTextures:[],buffers:[],images:[]}},defines:[{name:"CC_RECEIVE_SHADOW",type:"boolean"},{name:"CC_USE_IBL",type:"number",range:[0,2]},{name:"CC_USE_DIFFUSEMAP",type:"number",range:[0,2]},{name:"USE_REFLECTION_DENOISE",type:"boolean"},{name:"USE_LIGHTMAP",type:"boolean"},{name:"USE_BATCHING",type:"boolean"},{name:"CC_FORWARD_ADD",type:"boolean"},{name:"CC_PIPELINE_TYPE",type:"number",range:[0,1]},{name:"CC_FORCE_FORWARD_SHADING",type:"boolean"},{name:"CC_USE_HDR",type:"boolean"},{name:"CC_USE_FOG",type:"number",range:[0,4]}],attributes:[{name:"a_position",defines:[],format:32,location:0},{name:"a_normal",defines:[],format:32,location:1},{name:"a_texCoord",defines:[],format:21,location:2},{name:"a_tangent",defines:[],format:44,location:3}],blocks:[],samplerTextures:[{name:"depth_stencil",type:28,count:1,defines:[],stageFlags:16,binding:3}],buffers:[{name:"b_ccLightsBuffer",memoryAccess:1,defines:["CC_ENABLE_CLUSTERED_LIGHT_CULLING"],stageFlags:16,binding:4},{name:"b_clusterLightIndicesBuffer",memoryAccess:1,defines:["CC_ENABLE_CLUSTERED_LIGHT_CULLING"],stageFlags:16,binding:5},{name:"b_clusterLightGridBuffer",memoryAccess:1,defines:["CC_ENABLE_CLUSTERED_LIGHT_CULLING"],stageFlags:16,binding:6}],images:[],textures:[],samplers:[],subpassInputs:[{name:"gbuffer_albedoMap",count:1,defines:["CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT"],stageFlags:16,binding:0},{name:"gbuffer_normalMap",count:1,defines:["CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT"],stageFlags:16,binding:1},{name:"gbuffer_emissiveMap",count:1,defines:["CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT"],stageFlags:16,binding:2}]}]},{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:730673320,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:[],buffers:[],images:[]},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"]}],buffers:[],images:[]}},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"}],attributes:[{name:"a_position",defines:[],format:32,location:0},{name:"a_normal",defines:[],format:32,location:1},{name:"a_texCoord",defines:[],format:21,location:2},{name:"a_tangent",defines:[],format:44,location:3},{name:"a_vertexId",defines:["CC_USE_MORPH"],format:11,location:6},{name:"a_joints",defines:["CC_USE_SKINNING"],location:4},{name:"a_weights",defines:["CC_USE_SKINNING"],format:44,location:5},{name:"a_jointAnimInfo",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION","USE_INSTANCING"],format:44,isInstanced:!0,location:7},{name:"a_matWorld0",defines:["USE_INSTANCING"],format:44,isInstanced:!0,location:8},{name:"a_matWorld1",defines:["USE_INSTANCING"],format:44,isInstanced:!0,location:9},{name:"a_matWorld2",defines:["USE_INSTANCING"],format:44,isInstanced:!0,location:10},{name:"a_lightingMapUVParam",defines:["USE_INSTANCING","USE_LIGHTMAP"],format:44,isInstanced:!0,location:11},{name:"a_dyn_batch_id",defines:["!USE_INSTANCING","USE_BATCHING"],format:11,location:12}],blocks:[],samplerTextures:[],buffers:[],images:[],textures:[],samplers:[],subpassInputs:[]}]},{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:3237848814,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:147,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:39},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplerTextures:[],buffers:[],images:[]},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"]}],buffers:[],images:[]}},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:"ANTIALIAS_TYPE",type:"number",range:[0,3]}],attributes:[{name:"a_position",defines:[],format:32,location:0},{name:"a_normal",defines:[],format:32,location:1},{name:"a_texCoord",defines:[],format:21,location:2},{name:"a_tangent",defines:[],format:44,location:3},{name:"a_vertexId",defines:["CC_USE_MORPH"],format:11,location:6},{name:"a_joints",defines:["CC_USE_SKINNING"],location:4},{name:"a_weights",defines:["CC_USE_SKINNING"],format:44,location:5},{name:"a_jointAnimInfo",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION","USE_INSTANCING"],format:44,isInstanced:!0,location:7}],blocks:[],samplerTextures:[{name:"outputResultMap",type:28,count:1,defines:[],stageFlags:16,binding:0}],buffers:[],images:[],textures:[],samplers:[],subpassInputs:[]}]},{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:4277052359,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:39,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:39},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplerTextures:[{name:"cc_environment",defines:[]}],buffers:[],images:[]},locals:{blocks:[],samplerTextures:[],buffers:[],images:[]}},defines:[{name:"CC_USE_IBL",type:"number",range:[0,2]},{name:"CC_USE_HDR",type:"boolean"},{name:"USE_RGBE_CUBEMAP",type:"boolean"}],attributes:[{name:"a_position",defines:[],format:32,location:0},{name:"a_normal",defines:[],format:32,location:1},{name:"a_texCoord",defines:[],format:21,location:2},{name:"a_tangent",defines:[],format:44,location:3}],blocks:[],samplerTextures:[],buffers:[],images:[],textures:[],samplers:[],subpassInputs:[]}]},{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",priority:255,depthStencilState:{depthTest:!1,depthWrite:!1}}]}],shaders:[{name:"profiler|profiler-vs:vert|profiler-fs:frag",hash:179162168,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:60,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:39},globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplerTextures:[],buffers:[],images:[]},locals:{blocks:[],samplerTextures:[],buffers:[],images:[]}},defines:[],attributes:[{name:"a_position",defines:[],format:32,location:0},{name:"a_color",defines:[],format:44,location:1}],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}],buffers:[],images:[],textures:[],samplers:[],subpassInputs:[]}]},{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]},percent:{value:[.5],type:13,handleInfo:["u_percent",0,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,0,0]},u_percent:{type:13,value:[.5]},u_buffer1:{type:16,value:[200,500,320,480]}}}]}],shaders:[{name:"splash-screen|splash-screen-vs:vert|splash-screen-fs:frag",hash:3189094080,builtins:{statistics:{CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS:6,CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS:1},globals:{blocks:[],samplerTextures:[],buffers:[],images:[]},locals:{blocks:[],samplerTextures:[],buffers:[],images:[]}},defines:[],attributes:[{name:"a_position",defines:[],format:21,location:0},{name:"a_texCoord",defines:[],format:21,location:1}],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}]},{name:"Factor",defines:[],binding:1,stageFlags:16,members:[{name:"u_percent",type:13,count:1}]}],samplerTextures:[{name:"mainTexture",type:28,count:1,defines:[],stageFlags:16,binding:2}],buffers:[],images:[],textures:[],samplers:[],subpassInputs:[]}]}]),Cg={glsl1:[[{vert:"\nprecision mediump float;\nuniform highp mat4 cc_matView;\nuniform highp mat4 cc_matViewInv;\nuniform highp mat4 cc_matViewProj;\nuniform highp mat4 cc_matWorld;\nvec4 quaternionFromAxis (vec3 xAxis,vec3 yAxis,vec3 zAxis){\nmat3 m = mat3(xAxis,yAxis,zAxis);\nfloat trace = m[0][0] + m[1][1] + m[2][2];\nvec4 quat;\nif (trace > 0.) {\nfloat s = 0.5 / sqrt(trace + 1.0);\nquat.w = 0.25 / s;\nquat.x = (m[2][1] - m[1][2]) * s;\nquat.y = (m[0][2] - m[2][0]) * s;\nquat.z = (m[1][0] - m[0][1]) * s;\n} else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\nfloat s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\nquat.w = (m[2][1] - m[1][2]) / s;\nquat.x = 0.25 * s;\nquat.y = (m[0][1] + m[1][0]) / s;\nquat.z = (m[0][2] + m[2][0]) / s;\n} else if (m[1][1] > m[2][2]) {\nfloat s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\nquat.w = (m[0][2] - m[2][0]) / s;\nquat.x = (m[0][1] + m[1][0]) / s;\nquat.y = 0.25 * s;\nquat.z = (m[1][2] + m[2][1]) / s;\n} else {\nfloat s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\nquat.w = (m[1][0] - m[0][1]) / s;\nquat.x = (m[0][2] + m[2][0]) / s;\nquat.y = (m[1][2] + m[2][1]) / s;\nquat.z = 0.25 * s;\n}\nfloat len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\nif (len > 0.) {\nlen = 1. / sqrt(len);\nquat.x = quat.x * len;\nquat.y = quat.y * len;\nquat.z = quat.z * len;\nquat.w = quat.w * len;\n}\nreturn quat;\n}\nvec4 quaternionFromEuler (vec3 angle){\nfloat x = angle.x / 2.;\nfloat y = angle.y / 2.;\nfloat z = angle.z / 2.;\nfloat sx = sin(x);\nfloat cx = cos(x);\nfloat sy = sin(y);\nfloat cy = cos(y);\nfloat sz = sin(z);\nfloat cz = cos(z);\nvec4 quat = vec4(0);\nquat.x = sx * cy * cz + cx * sy * sz;\nquat.y = cx * sy * cz + sx * cy * sz;\nquat.z = cx * cy * sz - sx * sy * cz;\nquat.w = cx * cy * cz - sx * sy * sz;\nreturn quat;\n}\nvec4 quatMultiply (vec4 a, vec4 b){\nvec4 quat;\nquat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\nquat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\nquat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\nquat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\nreturn quat;\n}\nvoid rotateVecFromQuat (inout vec3 v, vec4 q){\nfloat ix = q.w * v.x + q.y * v.z - q.z * v.y;\nfloat iy = q.w * v.y + q.z * v.x - q.x * v.z;\nfloat iz = q.w * v.z + q.x * v.y - q.y * v.x;\nfloat iw = -q.x * v.x - q.y * v.y - q.z * v.z;\nv.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\nv.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\nv.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace (vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\nvec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\nvec4 rotQuat = quatMultiply(viewQuat, q);\nrotateVecFromQuat(pos, rotQuat);\nreturn pos;\n}\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;\nvec4 CCFragOutput (vec4 color) {\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 highp float;\nuniform highp mat4 cc_matViewProj;\nuniform highp vec4 cc_worldBoundCenter;\nuniform highp vec4 cc_worldBoundHalfExtents;\nattribute vec3 a_position;\nvec4 vert () {\nvec4 position;\nposition = vec4(a_position, 1.0);\nposition *= cc_worldBoundHalfExtents;\nposition += cc_worldBoundCenter;\nposition = cc_matViewProj * position;\nreturn position;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision mediump float;\nvec4 frag () {\nreturn vec4(1, 0, 0, 1);\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}\nmat3 quatToMat3(vec4 q) {\nvec3 m0 = vec3(\n1.0 - 2.0 * q.y * q.y - 2.0 * q.z * q.z,\n2.0 * q.x * q.y + 2.0 * q.w * q.z,\n2.0 * q.x * q.z - 2.0 * q.w * q.y);\nvec3 m1 = vec3(\n2.0 * q.x * q.y - 2.0 * q.w * q.z,\n1.0 - 2.0 * q.x * q.x - 2.0 * q.z * q.z,\n2.0 * q.y * q.z + 2.0 * q.w * q.x);\nvec3 m2 = vec3(\n2.0 * q.x * q.z + 2.0 * q.w * q.y,\n2.0 * q.y * q.z - 2.0 * q.w * q.x,\n1.0 - 2.0 * q.x * q.x - 2.0 * q.y * q.y);\nreturn mat3(m0, m1, m2);\n}\nvec4 mat3ToQuat(mat3 mat) {\nfloat tr = mat[0][0] + mat[1][1] + mat[2][2];\nfloat qw, qx, qy, qz;\nif (tr > 0.0) {\nfloat S = sqrt(tr + 1.0) * 2.0;\nfloat invS = 1.0 / S;\nqw = 0.25 * S;\nqx = (mat[1][2] - mat[2][1]) * invS;\nqy = (mat[2][0] - mat[0][2]) * invS;\nqz = (mat[0][1] - mat[1][0]) * invS;\n} else if ((mat[0][0] > mat[1][1])&&(mat[0][0] > mat[2][2])) {\nfloat S = sqrt(1.0 + mat[0][0] - mat[1][1] - mat[2][2]) * 2.0;\nfloat invS = 1.0 / S;\nqw = (mat[1][2] - mat[2][1]) * invS;\nqx = 0.25 * S;\nqy = (mat[1][0] + mat[0][1]) * invS;\nqz = (mat[2][0] + mat[0][2]) * invS;\n} else if (mat[1][1] > mat[2][2]) {\nfloat S = sqrt(1.0 + mat[1][1] - mat[0][0] - mat[2][2]) * 2.0;\nfloat invS = 1.0 / S;\nqw = (mat[2][0] - mat[0][2]) * invS;\nqx = (mat[1][0] + mat[0][1]) * invS;\nqy = 0.25 * S;\nqz = (mat[2][1] + mat[1][2]) * invS;\n} else {\nfloat S = sqrt(1.0 + mat[2][2] - mat[0][0] - mat[1][1]) * 2.0;\nfloat invS = 1.0 / S;\nqw = (mat[0][1] - mat[1][0]) * invS;\nqx = (mat[2][0] + mat[0][2]) * invS;\nqy = (mat[2][1] + mat[1][2]) * invS;\nqz = 0.25 * S;\n}\nreturn vec4(qx, qy, qz, qw);\n}\nvec4 eulerToQuat(vec3 euler) {\nvec3 er = euler * 0.5;\nfloat x = er.x, y = er.y, z = er.z;\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;\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}\nuniform vec4 mainTiling_Offset;\nuniform vec4 frameTile_velLenScale;\nuniform vec4 scale;\nuniform vec4 nodeRotation;\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\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nrotateVecFromQuat(viewSpaceVert, q);\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 x) {\n#if USE_VK_SHADER\nfloat o = x;\nx = mod(x - 1.0, 2.0) - 1.0;\nfloat freqVar = 10.16640753482;\nfloat y = sin(freqVar * floor(o * 0.5 - 0.5));\nfloat v = max(0.0, 1.0-abs(x));\nv *= 0.7071067812;\nv = y < 0.0 ? -v : v;\nreturn v;\n#else\nfloat seed = mod(x, 233280.);\nfloat q = (seed * 9301. + 49297.) / 233280.;\nreturn fract(q);\n#endif\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 startRotation = a_rotation_uv.xyz;\n#if CC_RENDER_MODE != 4\n#if CC_RENDER_MODE == 0\nvec3 rotEuler = startRotation.xyz;\n#elif CC_RENDER_MODE == 1\nvec3 rotEuler = vec3(0.);\n#else\nvec3 rotEuler = vec3(0., 0., startRotation.z);\n#endif\nvec4 rot = quaternionFromEuler(rotEuler);\n#else\nvec4 rot = quaternionFromEuler(startRotation);\n#endif\n#if ROTATION_OVER_TIME_MODULE_ENABLE\nif (u_rotation_mode == 1) {\nvec3 euler = unpackCurveData(rotation_over_time_tex0, timeCoord0) * normalizedTime * a_dir_life.w;\nvec4 quat = eulerToQuat(euler);\nmat3 mLocal = quatToMat3(quat);\nmat3 mStart = quatToMat3(rot);\nrot = mat3ToQuat(mStart * mLocal);\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.);\nvec3 euler = mix(rotation_0, rotation_1, factor_r) * normalizedTime * a_dir_life.w;\n#if CC_RENDER_MODE == 3 || CC_RENDER_MODE == 2\neuler = vec3(0.0, 0.0, euler.z);\n#endif\nvec4 quat = eulerToQuat(euler);\nmat3 mLocal = quatToMat3(quat);\nmat3 mStart = quatToMat3(rot);\nrot = mat3ToQuat(mStart * mLocal);\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 == 1\nrot = vec4(0.0, 0.0, 0.0, 1.0);\n#endif\ncomputeVertPos(pos, cornerOffset, rot, 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\nmat3 rotMat = quatToMat3(rot);\nmat3 nodeMat = quatToMat3(nodeRotation);\nrotMat = nodeMat * rotMat;\nrot = mat3ToQuat(rotMat);\nmat4 xformNoScale = matrixFromRT(rot, pos.xyz);\nmat4 xform = matFromRTS(rot, 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;\nvec4 CCFragOutput (vec4 color) {\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;\nvec4 CCFragOutput (vec4 color) {\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}\nmat3 quatToMat3(vec4 q) {\nvec3 m0 = vec3(\n1.0 - 2.0 * q.y * q.y - 2.0 * q.z * q.z,\n2.0 * q.x * q.y + 2.0 * q.w * q.z,\n2.0 * q.x * q.z - 2.0 * q.w * q.y);\nvec3 m1 = vec3(\n2.0 * q.x * q.y - 2.0 * q.w * q.z,\n1.0 - 2.0 * q.x * q.x - 2.0 * q.z * q.z,\n2.0 * q.y * q.z + 2.0 * q.w * q.x);\nvec3 m2 = vec3(\n2.0 * q.x * q.z + 2.0 * q.w * q.y,\n2.0 * q.y * q.z - 2.0 * q.w * q.x,\n1.0 - 2.0 * q.x * q.x - 2.0 * q.y * q.y);\nreturn mat3(m0, m1, m2);\n}\nvec4 mat3ToQuat(mat3 mat) {\nfloat tr = mat[0][0] + mat[1][1] + mat[2][2];\nfloat qw, qx, qy, qz;\nif (tr > 0.0) {\nfloat S = sqrt(tr + 1.0) * 2.0;\nfloat invS = 1.0 / S;\nqw = 0.25 * S;\nqx = (mat[1][2] - mat[2][1]) * invS;\nqy = (mat[2][0] - mat[0][2]) * invS;\nqz = (mat[0][1] - mat[1][0]) * invS;\n} else if ((mat[0][0] > mat[1][1])&&(mat[0][0] > mat[2][2])) {\nfloat S = sqrt(1.0 + mat[0][0] - mat[1][1] - mat[2][2]) * 2.0;\nfloat invS = 1.0 / S;\nqw = (mat[1][2] - mat[2][1]) * invS;\nqx = 0.25 * S;\nqy = (mat[1][0] + mat[0][1]) * invS;\nqz = (mat[2][0] + mat[0][2]) * invS;\n} else if (mat[1][1] > mat[2][2]) {\nfloat S = sqrt(1.0 + mat[1][1] - mat[0][0] - mat[2][2]) * 2.0;\nfloat invS = 1.0 / S;\nqw = (mat[2][0] - mat[0][2]) * invS;\nqx = (mat[1][0] + mat[0][1]) * invS;\nqy = 0.25 * S;\nqz = (mat[2][1] + mat[1][2]) * invS;\n} else {\nfloat S = sqrt(1.0 + mat[2][2] - mat[0][0] - mat[1][1]) * 2.0;\nfloat invS = 1.0 / S;\nqw = (mat[0][1] - mat[1][0]) * invS;\nqx = (mat[2][0] + mat[0][2]) * invS;\nqy = (mat[2][1] + mat[1][2]) * invS;\nqz = 0.25 * S;\n}\nreturn vec4(qx, qy, qz, qw);\n}\nuniform vec4 mainTiling_Offset;\nuniform vec4 frameTile_velLenScale;\nuniform vec4 scale;\nuniform vec4 nodeRotation;\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\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nrotateVecFromQuat(viewSpaceVert, q);\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 ROTATION_OVER_TIME_MODULE_ENABLE\nvec3 rotTmp = a_texCoord2;\nfloat mulFactor = 1.0;\nif (rotTmp.x > 10.0 * 0.5) {\nrotTmp.x -= 10.0;\nmulFactor = -1.0;\n}\nvec4 rot = vec4(rotTmp, 0.0);\nrot.w = mulFactor * sqrt(abs(1.0 - rot.x * rot.x - rot.y * rot.y - rot.z * rot.z));\n#else\n#if CC_RENDER_MODE != 4\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\nvec4 rot = quaternionFromEuler(rotEuler);\n#else\nvec4 rot = quaternionFromEuler(a_texCoord2);\n#endif\n#endif\n#if CC_RENDER_MODE != 4\nvec2 cornerOffset = vec2((a_texCoord.xy - 0.5));\n#if CC_RENDER_MODE == 0 || CC_RENDER_MODE == 3\ncomputeVertPos(pos, cornerOffset, rot, compScale, cc_matViewInv);\n#elif CC_RENDER_MODE == 1\ncomputeVertPos(pos, cornerOffset, rot, compScale, cc_cameraPos.xyz, velocity, frameTile_velLenScale.z, frameTile_velLenScale.w, a_texCoord.x);\n#elif 2\ncomputeVertPos(pos, cornerOffset, rot, compScale);\n#endif\ncolor = a_color;\n#else\nmat3 rotMat = quatToMat3(rot);\nmat3 nodeMat = quatToMat3(nodeRotation);\nrotMat = nodeMat * rotMat;\nrot = mat3ToQuat(rotMat);\nmat4 xformNoScale = matrixFromRT(rot, pos.xyz);\nmat4 xform = matFromRTS(rot, 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;\nvec4 CCFragOutput (vec4 color) {\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 fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / 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}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\n#if !CC_USE_ACCURATE_FOG\nvarying float v_fog_factor;\n#endif\nvoid CC_TRANSFER_FOG(vec4 pos) {\n#if !CC_USE_ACCURATE_FOG\nCC_TRANSFER_FOG_BASE(pos, v_fog_factor);\n#endif\n}\nvarying highp vec4 v_shadowPos;\nuniform highp mat4 cc_matLightViewProj;\n#if CC_RECEIVE_SHADOW\nuniform highp sampler2D cc_shadowMap;\nuniform highp 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_TWOSIDE\nvec3 viewDirect = normalize(cc_cameraPos.xyz - v_position);\nv_normal *= dot(v_normal, viewDirect) < 0.0 ? -1.0 : 1.0;\n#endif\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\nCC_TRANSFER_FOG(pos);\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_OES_standard_derivatives\n#extension GL_OES_standard_derivatives: 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 mat4 cc_matView;\nuniform highp vec4 cc_cameraPos;\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;\nuniform mediump vec4 cc_nearFar;\nuniform mediump vec4 cc_viewPort;\nuniform vec4 albedo;\nuniform vec4 albedoScaleAndCutoff;\nuniform vec4 pbrParams;\nuniform vec4 emissive;\nuniform vec4 emissiveScaleParam;\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 fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / 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}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\nvoid CC_APPLY_FOG_BASE(inout vec4 color, float factor) {\ncolor = vec4(mix(cc_fogColor.rgb, color.rgb, factor), color.a);\n}\n#if !CC_USE_ACCURATE_FOG\nvarying float v_fog_factor;\n#endif\nvoid CC_APPLY_FOG(inout vec4 color) {\n#if !CC_USE_ACCURATE_FOG\nCC_APPLY_FOG_BASE(color, v_fog_factor);\n#endif\n}\nvoid CC_APPLY_FOG(inout vec4 color, vec3 worldPos) {\n#if CC_USE_ACCURATE_FOG\nfloat factor;\nCC_TRANSFER_FOG_BASE(vec4(worldPos, 1.0), factor);\n#else\nfloat factor = v_fog_factor;\n#endif\nCC_APPLY_FOG_BASE(color, factor);\n}\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nuniform highp mat4 cc_matLightView;\nuniform highp vec4 cc_shadowInvProjDepthInfo;\nuniform highp vec4 cc_shadowProjDepthInfo;\nuniform highp vec4 cc_shadowProjInfo;\nuniform mediump vec4 cc_shadowNFLSInfo;\nuniform mediump vec4 cc_shadowWHPBInfo;\nuniform mediump vec4 cc_shadowLPNNInfo;\nhighp float unpackHighpData (float mainPart, float modPart) {\nhighp float data = mainPart;\nreturn data + modPart;\n}\nvoid packHighpData (out float mainPart, out float modPart, highp float data) {\nmainPart = fract(data);\nmodPart = data - mainPart;\n}\nhighp float unpackHighpData (float mainPart, float modPart, const float modValue) {\nhighp float data = mainPart * modValue;\nreturn data + modPart * modValue;\n}\nvoid packHighpData (out float mainPart, out float modPart, highp float data, const float modValue) {\nhighp float divide = data / modValue;\nmainPart = floor(divide);\nmodPart = (data - mainPart * modValue) / modValue;\n}\nhighp vec2 unpackHighpData (vec2 mainPart, vec2 modPart) {\nhighp vec2 data = mainPart;\nreturn data + modPart;\n}\nvoid packHighpData (out vec2 mainPart, out vec2 modPart, highp vec2 data) {\nmainPart = fract(data);\nmodPart = data - mainPart;\n}\nhighp vec2 unpackHighpData (vec2 mainPart, vec2 modPart, const float modValue) {\nhighp vec2 data = mainPart * modValue;\nreturn data + modPart * modValue;\n}\nvoid packHighpData (out vec2 mainPart, out vec2 modPart, highp vec2 data, const float modValue) {\nhighp vec2 divide = data / modValue;\nmainPart = floor(divide);\nmodPart = (data - mainPart * modValue) / modValue;\n}\nhighp vec3 unpackHighpData (vec3 mainPart, vec3 modPart) {\nhighp vec3 data = mainPart;\nreturn data + modPart;\n}\nvoid packHighpData (out vec3 mainPart, out vec3 modPart, highp vec3 data) {\nmainPart = fract(data);\nmodPart = data - mainPart;\n}\nhighp vec3 unpackHighpData (vec3 mainPart, vec3 modPart, const float modValue) {\nhighp vec3 data = mainPart * modValue;\nreturn data + modPart * modValue;\n}\nvoid packHighpData (out vec3 mainPart, out vec3 modPart, highp vec3 data, const float modValue) {\nhighp vec3 divide = data / modValue;\nmainPart = floor(divide);\nmodPart = (data - mainPart * modValue) / modValue;\n}\nhighp vec4 unpackHighpData (vec4 mainPart, vec4 modPart) {\nhighp vec4 data = mainPart;\nreturn data + modPart;\n}\nvoid packHighpData (out vec4 mainPart, out vec4 modPart, highp vec4 data) {\nmainPart = fract(data);\nmodPart = data - mainPart;\n}\nhighp vec4 unpackHighpData (vec4 mainPart, vec4 modPart, const float modValue) {\nhighp vec4 data = mainPart * modValue;\nreturn data + modPart * modValue;\n}\nvoid packHighpData (out vec4 mainPart, out vec4 modPart, highp vec4 data, const float modValue) {\nhighp vec4 divide = data / modValue;\nmainPart = floor(divide);\nmodPart = (data - mainPart * modValue) / modValue;\n}\nfloat CCGetLinearDepthFromViewSpace(vec3 viewPos) {\nfloat dist = length(viewPos);\nreturn (dist - cc_shadowNFLSInfo.x) / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x);\n}\nfloat CCGetLinearDepth(vec3 worldPos) {\nvec4 viewStartPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\nreturn CCGetLinearDepthFromViewSpace(viewStartPos.xyz);\n}\n#if CC_RECEIVE_SHADOW\nuniform highp sampler2D cc_shadowMap;\nuniform highp sampler2D cc_spotLightingMap;\nvec4 ApplyShadowDepthBias_FaceNormal(vec4 shadowPos, vec3 worldNormal)\n{\nvec4 newShadowPos = shadowPos;\nif(cc_shadowLPNNInfo.z > 0.0001)\n{\nvec4 viewNormal = cc_matLightView * vec4(worldNormal, 0.0);\nif(viewNormal.z < 0.1)\nnewShadowPos.xy += viewNormal.xy * cc_shadowProjInfo.xy * cc_shadowLPNNInfo.z * clamp(viewNormal.z, 0.001, 0.1);\n}\nreturn newShadowPos;\n}\nvec4 ApplyShadowDepthBias_Perspective(vec4 shadowPos, float viewspaceDepthBias)\n{\nvec3 viewSpacePos;\nviewSpacePos.xy = shadowPos.xy * cc_shadowProjInfo.zw;\nviewSpacePos.z = shadowPos.z * cc_shadowInvProjDepthInfo.x + shadowPos.w * cc_shadowInvProjDepthInfo.y;\nviewSpacePos.xyz += cc_shadowProjDepthInfo.z * normalize(viewSpacePos.xyz) * viewspaceDepthBias;\nvec4 clipSpacePos;\nclipSpacePos.xy = viewSpacePos.xy * cc_shadowProjInfo.xy;\nclipSpacePos.zw = viewSpacePos.z * cc_shadowProjDepthInfo.xz + vec2(cc_shadowProjDepthInfo.y, 0.0);\nif (cc_shadowNFLSInfo.z > 0.000001) {\nclipSpacePos.z = CCGetLinearDepthFromViewSpace(viewSpacePos.xyz);\nclipSpacePos.z = (clipSpacePos.z * 2.0 - 1.0) * clipSpacePos.w;\n}\nreturn clipSpacePos;\n}\nvec4 ApplyShadowDepthBias_Orthographic(vec4 shadowPos, float viewspaceDepthBias)\n{\nfloat coeffA = cc_shadowProjDepthInfo.x;\nfloat coeffB = cc_shadowProjDepthInfo.y;\nfloat viewSpacePos_z = (shadowPos.z - coeffB) / coeffA;\nviewSpacePos_z += viewspaceDepthBias;\nvec4 result = shadowPos;\nresult.z = viewSpacePos_z * coeffA + coeffB;\nreturn result;\n}\nfloat CCGetShadowFactorHard (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\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 / 16581375.0));\n} else {\nclosestDepth = texture2D(cc_shadowMap, clipPos.xy).x;\n}\nshadow = step(clipPos.z, closestDepth);\nreturn shadow;\n}\nfloat CCGetShadowFactorSoft (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetShadowFactorSoft2X (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\nfloat CCGetSpotLightShadowFactorHard (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nfloat depth = clipPos.z;\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 / 16581375.0));\n} else {\nclosestDepth = texture2D(cc_spotLightingMap, clipPos.xy).x;\n}\nshadow = step(depth, closestDepth);\nreturn shadow;\n}\nfloat CCGetSpotLightShadowFactorSoft (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nfloat bias = cc_shadowWHPBInfo.w;\nvec2 oneTap = 1.0 / cc_shadowWHPBInfo.xy;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * cc_shadowWHPBInfo.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * cc_shadowWHPBInfo.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetSpotLightShadowFactorSoft2X (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nfloat bias = cc_shadowWHPBInfo.w;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\n#endif\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\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}\nvec3 unpackRGBE (vec4 rgbe) {\nreturn rgbe.rgb * pow(1.1, rgbe.a * 255.0 - 128.0);\n}\n#if CC_USE_DIFFUSEMAP\nuniform samplerCube cc_diffuseMap;\n#endif\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}\n#if USE_REFLECTION_DENOISE\nvec3 GetEnvReflectionWithMipFiltering(vec3 R, float roughness, float mipCount, float denoiseIntensity) {\n#if CC_USE_IBL\nfloat mip = roughness * mipCount;\nfloat delta = (dot(dFdx(R), dFdy(R))) * 1000.0;\nfloat mipBias = mix(0.0, 5.0, clamp(delta, 0.0, 1.0));\nvec4 biased = fragTextureLod(cc_environment, R, mip + mipBias);\nvec4 filtered = textureCube(cc_environment, R);\n#if CC_USE_IBL == 2\nbiased.rgb = unpackRGBE(biased);\nfiltered.rgb = unpackRGBE(filtered);\n#else\nbiased.rgb = SRGBToLinear(biased.rgb);\nfiltered.rgb = SRGBToLinear(filtered.rgb);\n#endif\nreturn mix(biased.rgb, filtered.rgb, denoiseIntensity);\n#else\nreturn vec3(0.0, 0.0, 0.0);\n#endif\n}\n#endif\nstruct StandardSurface {\nvec4 albedo;\n#if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\nvec3 position, position_fract_part;\n#else\nvec3 position;\n#endif\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 position;\n#if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\nposition = unpackHighpData(s.position, s.position_fract_part);\n#else\nposition = s.position;\n#endif\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - position);\nfloat NV = max(abs(dot(N, V)), 0.0);\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.0);\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);\nvec3 dirlightContrib = (diffuseContrib + specularContrib);\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (NL > 0.0 && cc_mainLitDir.w > 0.0) {\n{\nvec4 pos = ApplyShadowDepthBias_FaceNormal(shadowPos, N);\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetShadowFactorSoft2X(pos);\nelse if (pcf > 0.9) shadow = CCGetShadowFactorSoft(pos);\nelse shadow = CCGetShadowFactorHard(pos);\nshadow = mix(shadow, 1.0, cc_shadowNFLSInfo.w);\n}\n}\n#endif\ndirlightContrib *= shadow;\nfinalColor *= dirlightContrib;\nfloat fAmb = 0.5 - N.y * 0.5;\nvec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb);\n#if CC_USE_IBL\n#if CC_USE_DIFFUSEMAP\nvec4 diffuseMap = textureCube(cc_diffuseMap, N);\n#if CC_USE_DIFFUSEMAP == 2\nambDiff = unpackRGBE(diffuseMap);\n#else\nambDiff = SRGBToLinear(diffuseMap.rgb);\n#endif\n#endif\nvec3 R = normalize(reflect(-V, N));\n#if USE_REFLECTION_DENOISE\nvec3 env = GetEnvReflectionWithMipFiltering(R, s.roughness, cc_ambientGround.w, 0.6);\n#else\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\n#endif\nfinalColor += env * cc_ambientSky.w * specular * s.occlusion;\n#endif\nfinalColor += ambDiff.rgb * cc_ambientSky.w * diffuse * s.occlusion;\nfinalColor += s.emissive;\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 = ACESToneMap(color.rgb);\n#endif\ncolor.rgb = sqrt(color.rgb);\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.rgb *= SRGBToLinear(v_color.rgb);\nbaseColor.a *= v_color.a;\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 * emissiveScaleParam.w) * normalize(v_tangent) +\n(nmmp.y * emissiveScaleParam.w) * normalize(v_bitangent) +\nnmmp.z * normalize(s.normal);\n#endif\n#if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\npackHighpData(s.position, s.position_fract_part, v_position);\n#else\ns.position = v_position;\n#endif\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;\npbr.w *= res.a;\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 = pbr.x;\ns.roughness = pbr.y;\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\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\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];\n#endif\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}\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\nvec4 CCStandardShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 position;\n#if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\nposition = unpackHighpData(s.position, s.position_fract_part);\n#else\nposition = s.position;\n#endif\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 - position);\nfloat NV = max(abs(dot(N, V)), 0.0);\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 - position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.0);\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;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (cc_lightPos[i].w > 0.0 && cc_lightSizeRangeAngle[i].w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\n#endif\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1\nreadonly buffer b_ccLightsBuffer { vec4 b_ccLights[]; };\nreadonly buffer b_clusterLightIndicesBuffer { uint b_clusterLightIndices[]; };\nreadonly buffer b_clusterLightGridBuffer { uvec4 b_clusterLightGrid[]; };\nstruct CCLight\n{\nvec4 cc_lightPos;\nvec4 cc_lightColor;\nvec4 cc_lightSizeRangeAngle;\nvec4 cc_lightDir;\n};\nstruct Cluster\n{\nvec3 minBounds;\nvec3 maxBounds;\n};\nstruct LightGrid\n{\nuint offset;\nuint ccLights;\n};\nCCLight getCCLight(uint i)\n{\nCCLight light;\nlight.cc_lightPos = b_ccLights[4u * i + 0u];\nlight.cc_lightColor = b_ccLights[4u * i + 1u];\nlight.cc_lightSizeRangeAngle = b_ccLights[4u * i + 2u];\nlight.cc_lightDir = b_ccLights[4u * i + 3u];\nreturn light;\n}\nLightGrid getLightGrid(uint cluster)\n{\nuvec4 gridvec = b_clusterLightGrid[cluster];\nLightGrid grid;\ngrid.offset = gridvec.x;\ngrid.ccLights = gridvec.y;\nreturn grid;\n}\nuint getGridLightIndex(uint start, uint offset)\n{\nreturn b_clusterLightIndices[start + offset];\n}\nuint getClusterZIndex(vec4 worldPos)\n{\nfloat scale = float(24) / log(cc_nearFar.y / cc_nearFar.x);\nfloat bias = -(float(24) * log(cc_nearFar.x) / log(cc_nearFar.y / cc_nearFar.x));\nfloat eyeDepth = -(cc_matView * worldPos).z;\nuint zIndex = uint(max(log(eyeDepth) * scale + bias, 0.0));\nreturn zIndex;\n}\nuint getClusterIndex(vec4 fragCoord, vec4 worldPos)\n{\nuint zIndex = getClusterZIndex(worldPos);\nfloat clusterSizeX = ceil(cc_viewPort.z / float(16));\nfloat clusterSizeY = ceil(cc_viewPort.w / float(8));\nuvec3 indices = uvec3(uvec2(fragCoord.xy / vec2(clusterSizeX, clusterSizeY)), zIndex);\nuint cluster = (16u * 8u) * indices.z + 16u * indices.y + indices.x;\nreturn cluster;\n}\nvec4 CCClusterShadingAdditive (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 position;\n#if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\nposition = unpackHighpData(s.position, s.position_fract_part);\n#else\nposition = s.position;\n#endif\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - position);\nfloat NV = max(abs(dot(N, V)), 0.001);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nuint cluster = getClusterIndex(gl_FragCoord, vec4(position, 1.0));\nLightGrid grid = getLightGrid(cluster);\nuint numLights = grid.ccLights;\nfor (uint i = 0u; i < 100u; i++) {\nif (i >= numLights) break;\nuint lightIndex = getGridLightIndex(grid.offset, i);\nCCLight light = getCCLight(lightIndex);\nvec3 SLU = light.cc_lightPos.xyz - 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 = light.cc_lightSizeRangeAngle.x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(light.cc_lightSizeRangeAngle.y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (light.cc_lightPos.w > 0.0) {\nfloat cosInner = max(dot(-light.cc_lightDir.xyz, SL), 0.01);\nfloat cosOuter = light.cc_lightSizeRangeAngle.z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -light.cc_lightDir.xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = light.cc_lightColor.rgb;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (light.cc_lightPos.w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * light.cc_lightColor.w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\n#endif\nvoid main () {\nStandardSurface s; surf(s);\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1\nvec4 color = CCClusterShadingAdditive(s, v_shadowPos);\n#else\nvec4 color = CCStandardShadingAdditive(s, v_shadowPos);\n#endif\nCC_APPLY_FOG(color, s.position.xyz);\ngl_FragData[0] = CCFragOutput(color);\n}\n#elif (CC_PIPELINE_TYPE == 0 || CC_FORCE_FORWARD_SHADING)\nvoid main () {\nStandardSurface s; surf(s);\nvec4 color = CCStandardShadingBase(s, v_shadowPos);\nCC_APPLY_FOG(color, s.position.xyz);\ngl_FragData[0] = CCFragOutput(color);\n}\n#elif CC_PIPELINE_TYPE == 1\nvec2 signNotZero(vec2 v) {\nreturn vec2((v.x >= 0.0) ? +1.0 : -1.0, (v.y >= 0.0) ? +1.0 : -1.0);\n}\nvec2 float32x3_to_oct(in vec3 v) {\nvec2 p = v.xy * (1.0 / (abs(v.x) + abs(v.y) + abs(v.z)));\nreturn (v.z <= 0.0) ? ((1.0 - abs(p.yx)) * signNotZero(p)) : p;\n}\nvoid main () {\nStandardSurface s; surf(s);\ngl_FragData[0] = s.albedo;\ngl_FragData[1] = vec4(float32x3_to_oct(s.normal), s.roughness, s.metallic);\ngl_FragData[2] = 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, 16581375.0) * depth;\nret = fract(ret);\nret -= vec4(ret.yzw, 0.0) / 255.0;\nreturn ret;\n}\nuniform highp mat4 cc_matLightView;\nuniform mediump vec4 cc_shadowNFLSInfo;\nuniform mediump vec4 cc_shadowLPNNInfo;\nfloat CCGetLinearDepthFromViewSpace(vec3 viewPos) {\nfloat dist = length(viewPos);\nreturn (dist - cc_shadowNFLSInfo.x) / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x);\n}\nfloat CCGetLinearDepth(vec3 worldPos) {\nvec4 viewStartPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\nreturn CCGetLinearDepthFromViewSpace(viewStartPos.xyz);\n}\n#if CC_RECEIVE_SHADOW\nuniform highp sampler2D cc_shadowMap;\nuniform highp sampler2D cc_spotLightingMap;\n#endif\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) {\nreturn vec4(CCGetLinearDepth(v_worldPos.xyz), 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 fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / 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}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\n#if !CC_USE_ACCURATE_FOG\nvarying float v_fog_factor;\n#endif\nvoid CC_TRANSFER_FOG(vec4 pos) {\n#if !CC_USE_ACCURATE_FOG\nCC_TRANSFER_FOG_BASE(pos, v_fog_factor);\n#endif\n}\nvarying highp vec4 v_shadowPos;\nuniform highp mat4 cc_matLightViewProj;\n#if CC_RECEIVE_SHADOW\nuniform highp sampler2D cc_shadowMap;\nuniform highp 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;\nCC_TRANSFER_FOG(vec4(worldPos, 1.0));\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_OES_standard_derivatives\n#extension GL_OES_standard_derivatives: 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 mat4 cc_matView;\nuniform highp vec4 cc_cameraPos;\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;\nuniform mediump vec4 cc_nearFar;\nuniform mediump vec4 cc_viewPort;\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nuniform highp mat4 cc_matLightView;\nuniform highp vec4 cc_shadowInvProjDepthInfo;\nuniform highp vec4 cc_shadowProjDepthInfo;\nuniform highp vec4 cc_shadowProjInfo;\nuniform mediump vec4 cc_shadowNFLSInfo;\nuniform mediump vec4 cc_shadowWHPBInfo;\nuniform mediump vec4 cc_shadowLPNNInfo;\nhighp float unpackHighpData (float mainPart, float modPart) {\nhighp float data = mainPart;\nreturn data + modPart;\n}\nvoid packHighpData (out float mainPart, out float modPart, highp float data) {\nmainPart = fract(data);\nmodPart = data - mainPart;\n}\nhighp float unpackHighpData (float mainPart, float modPart, const float modValue) {\nhighp float data = mainPart * modValue;\nreturn data + modPart * modValue;\n}\nvoid packHighpData (out float mainPart, out float modPart, highp float data, const float modValue) {\nhighp float divide = data / modValue;\nmainPart = floor(divide);\nmodPart = (data - mainPart * modValue) / modValue;\n}\nhighp vec2 unpackHighpData (vec2 mainPart, vec2 modPart) {\nhighp vec2 data = mainPart;\nreturn data + modPart;\n}\nvoid packHighpData (out vec2 mainPart, out vec2 modPart, highp vec2 data) {\nmainPart = fract(data);\nmodPart = data - mainPart;\n}\nhighp vec2 unpackHighpData (vec2 mainPart, vec2 modPart, const float modValue) {\nhighp vec2 data = mainPart * modValue;\nreturn data + modPart * modValue;\n}\nvoid packHighpData (out vec2 mainPart, out vec2 modPart, highp vec2 data, const float modValue) {\nhighp vec2 divide = data / modValue;\nmainPart = floor(divide);\nmodPart = (data - mainPart * modValue) / modValue;\n}\nhighp vec3 unpackHighpData (vec3 mainPart, vec3 modPart) {\nhighp vec3 data = mainPart;\nreturn data + modPart;\n}\nvoid packHighpData (out vec3 mainPart, out vec3 modPart, highp vec3 data) {\nmainPart = fract(data);\nmodPart = data - mainPart;\n}\nhighp vec3 unpackHighpData (vec3 mainPart, vec3 modPart, const float modValue) {\nhighp vec3 data = mainPart * modValue;\nreturn data + modPart * modValue;\n}\nvoid packHighpData (out vec3 mainPart, out vec3 modPart, highp vec3 data, const float modValue) {\nhighp vec3 divide = data / modValue;\nmainPart = floor(divide);\nmodPart = (data - mainPart * modValue) / modValue;\n}\nhighp vec4 unpackHighpData (vec4 mainPart, vec4 modPart) {\nhighp vec4 data = mainPart;\nreturn data + modPart;\n}\nvoid packHighpData (out vec4 mainPart, out vec4 modPart, highp vec4 data) {\nmainPart = fract(data);\nmodPart = data - mainPart;\n}\nhighp vec4 unpackHighpData (vec4 mainPart, vec4 modPart, const float modValue) {\nhighp vec4 data = mainPart * modValue;\nreturn data + modPart * modValue;\n}\nvoid packHighpData (out vec4 mainPart, out vec4 modPart, highp vec4 data, const float modValue) {\nhighp vec4 divide = data / modValue;\nmainPart = floor(divide);\nmodPart = (data - mainPart * modValue) / modValue;\n}\nfloat CCGetLinearDepthFromViewSpace(vec3 viewPos) {\nfloat dist = length(viewPos);\nreturn (dist - cc_shadowNFLSInfo.x) / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x);\n}\nfloat CCGetLinearDepth(vec3 worldPos) {\nvec4 viewStartPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\nreturn CCGetLinearDepthFromViewSpace(viewStartPos.xyz);\n}\n#if CC_RECEIVE_SHADOW\nuniform highp sampler2D cc_shadowMap;\nuniform highp sampler2D cc_spotLightingMap;\nvec4 ApplyShadowDepthBias_FaceNormal(vec4 shadowPos, vec3 worldNormal)\n{\nvec4 newShadowPos = shadowPos;\nif(cc_shadowLPNNInfo.z > 0.0001)\n{\nvec4 viewNormal = cc_matLightView * vec4(worldNormal, 0.0);\nif(viewNormal.z < 0.1)\nnewShadowPos.xy += viewNormal.xy * cc_shadowProjInfo.xy * cc_shadowLPNNInfo.z * clamp(viewNormal.z, 0.001, 0.1);\n}\nreturn newShadowPos;\n}\nvec4 ApplyShadowDepthBias_Perspective(vec4 shadowPos, float viewspaceDepthBias)\n{\nvec3 viewSpacePos;\nviewSpacePos.xy = shadowPos.xy * cc_shadowProjInfo.zw;\nviewSpacePos.z = shadowPos.z * cc_shadowInvProjDepthInfo.x + shadowPos.w * cc_shadowInvProjDepthInfo.y;\nviewSpacePos.xyz += cc_shadowProjDepthInfo.z * normalize(viewSpacePos.xyz) * viewspaceDepthBias;\nvec4 clipSpacePos;\nclipSpacePos.xy = viewSpacePos.xy * cc_shadowProjInfo.xy;\nclipSpacePos.zw = viewSpacePos.z * cc_shadowProjDepthInfo.xz + vec2(cc_shadowProjDepthInfo.y, 0.0);\nif (cc_shadowNFLSInfo.z > 0.000001) {\nclipSpacePos.z = CCGetLinearDepthFromViewSpace(viewSpacePos.xyz);\nclipSpacePos.z = (clipSpacePos.z * 2.0 - 1.0) * clipSpacePos.w;\n}\nreturn clipSpacePos;\n}\nvec4 ApplyShadowDepthBias_Orthographic(vec4 shadowPos, float viewspaceDepthBias)\n{\nfloat coeffA = cc_shadowProjDepthInfo.x;\nfloat coeffB = cc_shadowProjDepthInfo.y;\nfloat viewSpacePos_z = (shadowPos.z - coeffB) / coeffA;\nviewSpacePos_z += viewspaceDepthBias;\nvec4 result = shadowPos;\nresult.z = viewSpacePos_z * coeffA + coeffB;\nreturn result;\n}\nfloat CCGetShadowFactorHard (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\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 / 16581375.0));\n} else {\nclosestDepth = texture2D(cc_shadowMap, clipPos.xy).x;\n}\nshadow = step(clipPos.z, closestDepth);\nreturn shadow;\n}\nfloat CCGetShadowFactorSoft (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetShadowFactorSoft2X (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\nfloat CCGetSpotLightShadowFactorHard (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nfloat depth = clipPos.z;\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 / 16581375.0));\n} else {\nclosestDepth = texture2D(cc_spotLightingMap, clipPos.xy).x;\n}\nshadow = step(depth, closestDepth);\nreturn shadow;\n}\nfloat CCGetSpotLightShadowFactorSoft (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nfloat bias = cc_shadowWHPBInfo.w;\nvec2 oneTap = 1.0 / cc_shadowWHPBInfo.xy;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * cc_shadowWHPBInfo.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * cc_shadowWHPBInfo.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetSpotLightShadowFactorSoft2X (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nfloat bias = cc_shadowWHPBInfo.w;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\n#endif\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\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}\nvec3 unpackRGBE (vec4 rgbe) {\nreturn rgbe.rgb * pow(1.1, rgbe.a * 255.0 - 128.0);\n}\n#if CC_USE_DIFFUSEMAP\nuniform samplerCube cc_diffuseMap;\n#endif\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}\n#if USE_REFLECTION_DENOISE\nvec3 GetEnvReflectionWithMipFiltering(vec3 R, float roughness, float mipCount, float denoiseIntensity) {\n#if CC_USE_IBL\nfloat mip = roughness * mipCount;\nfloat delta = (dot(dFdx(R), dFdy(R))) * 1000.0;\nfloat mipBias = mix(0.0, 5.0, clamp(delta, 0.0, 1.0));\nvec4 biased = fragTextureLod(cc_environment, R, mip + mipBias);\nvec4 filtered = textureCube(cc_environment, R);\n#if CC_USE_IBL == 2\nbiased.rgb = unpackRGBE(biased);\nfiltered.rgb = unpackRGBE(filtered);\n#else\nbiased.rgb = SRGBToLinear(biased.rgb);\nfiltered.rgb = SRGBToLinear(filtered.rgb);\n#endif\nreturn mix(biased.rgb, filtered.rgb, denoiseIntensity);\n#else\nreturn vec3(0.0, 0.0, 0.0);\n#endif\n}\n#endif\nstruct StandardSurface {\nvec4 albedo;\n#if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\nvec3 position, position_fract_part;\n#else\nvec3 position;\n#endif\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 position;\n#if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\nposition = unpackHighpData(s.position, s.position_fract_part);\n#else\nposition = s.position;\n#endif\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - position);\nfloat NV = max(abs(dot(N, V)), 0.0);\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.0);\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);\nvec3 dirlightContrib = (diffuseContrib + specularContrib);\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (NL > 0.0 && cc_mainLitDir.w > 0.0) {\n{\nvec4 pos = ApplyShadowDepthBias_FaceNormal(shadowPos, N);\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetShadowFactorSoft2X(pos);\nelse if (pcf > 0.9) shadow = CCGetShadowFactorSoft(pos);\nelse shadow = CCGetShadowFactorHard(pos);\nshadow = mix(shadow, 1.0, cc_shadowNFLSInfo.w);\n}\n}\n#endif\ndirlightContrib *= shadow;\nfinalColor *= dirlightContrib;\nfloat fAmb = 0.5 - N.y * 0.5;\nvec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb);\n#if CC_USE_IBL\n#if CC_USE_DIFFUSEMAP\nvec4 diffuseMap = textureCube(cc_diffuseMap, N);\n#if CC_USE_DIFFUSEMAP == 2\nambDiff = unpackRGBE(diffuseMap);\n#else\nambDiff = SRGBToLinear(diffuseMap.rgb);\n#endif\n#endif\nvec3 R = normalize(reflect(-V, N));\n#if USE_REFLECTION_DENOISE\nvec3 env = GetEnvReflectionWithMipFiltering(R, s.roughness, cc_ambientGround.w, 0.6);\n#else\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\n#endif\nfinalColor += env * cc_ambientSky.w * specular * s.occlusion;\n#endif\nfinalColor += ambDiff.rgb * cc_ambientSky.w * diffuse * s.occlusion;\nfinalColor += s.emissive;\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 = ACESToneMap(color.rgb);\n#endif\ncolor.rgb = sqrt(color.rgb);\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 fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / 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}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\nvoid CC_APPLY_FOG_BASE(inout vec4 color, float factor) {\ncolor = vec4(mix(cc_fogColor.rgb, color.rgb, factor), color.a);\n}\n#if !CC_USE_ACCURATE_FOG\nvarying float v_fog_factor;\n#endif\nvoid CC_APPLY_FOG(inout vec4 color) {\n#if !CC_USE_ACCURATE_FOG\nCC_APPLY_FOG_BASE(color, v_fog_factor);\n#endif\n}\nvoid CC_APPLY_FOG(inout vec4 color, vec3 worldPos) {\n#if CC_USE_ACCURATE_FOG\nfloat factor;\nCC_TRANSFER_FOG_BASE(vec4(worldPos, 1.0), factor);\n#else\nfloat factor = v_fog_factor;\n#endif\nCC_APPLY_FOG_BASE(color, factor);\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 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\n#if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\npackHighpData(s.position, s.position_fract_part, v_position);\n#else\ns.position = v_position;\n#endif\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\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\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];\n#endif\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}\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\nvec4 CCStandardShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 position;\n#if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\nposition = unpackHighpData(s.position, s.position_fract_part);\n#else\nposition = s.position;\n#endif\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 - position);\nfloat NV = max(abs(dot(N, V)), 0.0);\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 - position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.0);\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;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (cc_lightPos[i].w > 0.0 && cc_lightSizeRangeAngle[i].w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\n#endif\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1\nreadonly buffer b_ccLightsBuffer { vec4 b_ccLights[]; };\nreadonly buffer b_clusterLightIndicesBuffer { uint b_clusterLightIndices[]; };\nreadonly buffer b_clusterLightGridBuffer { uvec4 b_clusterLightGrid[]; };\nstruct CCLight\n{\nvec4 cc_lightPos;\nvec4 cc_lightColor;\nvec4 cc_lightSizeRangeAngle;\nvec4 cc_lightDir;\n};\nstruct Cluster\n{\nvec3 minBounds;\nvec3 maxBounds;\n};\nstruct LightGrid\n{\nuint offset;\nuint ccLights;\n};\nCCLight getCCLight(uint i)\n{\nCCLight light;\nlight.cc_lightPos = b_ccLights[4u * i + 0u];\nlight.cc_lightColor = b_ccLights[4u * i + 1u];\nlight.cc_lightSizeRangeAngle = b_ccLights[4u * i + 2u];\nlight.cc_lightDir = b_ccLights[4u * i + 3u];\nreturn light;\n}\nLightGrid getLightGrid(uint cluster)\n{\nuvec4 gridvec = b_clusterLightGrid[cluster];\nLightGrid grid;\ngrid.offset = gridvec.x;\ngrid.ccLights = gridvec.y;\nreturn grid;\n}\nuint getGridLightIndex(uint start, uint offset)\n{\nreturn b_clusterLightIndices[start + offset];\n}\nuint getClusterZIndex(vec4 worldPos)\n{\nfloat scale = float(24) / log(cc_nearFar.y / cc_nearFar.x);\nfloat bias = -(float(24) * log(cc_nearFar.x) / log(cc_nearFar.y / cc_nearFar.x));\nfloat eyeDepth = -(cc_matView * worldPos).z;\nuint zIndex = uint(max(log(eyeDepth) * scale + bias, 0.0));\nreturn zIndex;\n}\nuint getClusterIndex(vec4 fragCoord, vec4 worldPos)\n{\nuint zIndex = getClusterZIndex(worldPos);\nfloat clusterSizeX = ceil(cc_viewPort.z / float(16));\nfloat clusterSizeY = ceil(cc_viewPort.w / float(8));\nuvec3 indices = uvec3(uvec2(fragCoord.xy / vec2(clusterSizeX, clusterSizeY)), zIndex);\nuint cluster = (16u * 8u) * indices.z + 16u * indices.y + indices.x;\nreturn cluster;\n}\nvec4 CCClusterShadingAdditive (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 position;\n#if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\nposition = unpackHighpData(s.position, s.position_fract_part);\n#else\nposition = s.position;\n#endif\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - position);\nfloat NV = max(abs(dot(N, V)), 0.001);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nuint cluster = getClusterIndex(gl_FragCoord, vec4(position, 1.0));\nLightGrid grid = getLightGrid(cluster);\nuint numLights = grid.ccLights;\nfor (uint i = 0u; i < 100u; i++) {\nif (i >= numLights) break;\nuint lightIndex = getGridLightIndex(grid.offset, i);\nCCLight light = getCCLight(lightIndex);\nvec3 SLU = light.cc_lightPos.xyz - 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 = light.cc_lightSizeRangeAngle.x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(light.cc_lightSizeRangeAngle.y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (light.cc_lightPos.w > 0.0) {\nfloat cosInner = max(dot(-light.cc_lightDir.xyz, SL), 0.01);\nfloat cosOuter = light.cc_lightSizeRangeAngle.z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -light.cc_lightDir.xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = light.cc_lightColor.rgb;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (light.cc_lightPos.w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * light.cc_lightColor.w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\n#endif\nvoid main () {\nStandardSurface s; surf(s);\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1\nvec4 color = CCClusterShadingAdditive(s, v_shadowPos);\n#else\nvec4 color = CCStandardShadingAdditive(s, v_shadowPos);\n#endif\nCC_APPLY_FOG(color, s.position.xyz);\ngl_FragData[0] = CCFragOutput(color);\n}\n#elif (CC_PIPELINE_TYPE == 0 || CC_FORCE_FORWARD_SHADING)\nvoid main () {\nStandardSurface s; surf(s);\nvec4 color = CCStandardShadingBase(s, v_shadowPos);\nCC_APPLY_FOG(color, s.position.xyz);\ngl_FragData[0] = CCFragOutput(color);\n}\n#elif CC_PIPELINE_TYPE == 1\nvec2 signNotZero(vec2 v) {\nreturn vec2((v.x >= 0.0) ? +1.0 : -1.0, (v.y >= 0.0) ? +1.0 : -1.0);\n}\nvec2 float32x3_to_oct(in vec3 v) {\nvec2 p = v.xy * (1.0 / (abs(v.x) + abs(v.y) + abs(v.z)));\nreturn (v.z <= 0.0) ? ((1.0 - abs(p.yx)) * signNotZero(p)) : p;\n}\nvoid main () {\nStandardSurface s; surf(s);\ngl_FragData[0] = s.albedo;\ngl_FragData[1] = vec4(float32x3_to_oct(s.normal), s.roughness, s.metallic);\ngl_FragData[2] = 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, 16581375.0) * depth;\nret = fract(ret);\nret -= vec4(ret.yzw, 0.0) / 255.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 fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / 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}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\n#if !CC_USE_ACCURATE_FOG\nvarying float v_fog_factor;\n#endif\nvoid CC_TRANSFER_FOG(vec4 pos) {\n#if !CC_USE_ACCURATE_FOG\nCC_TRANSFER_FOG_BASE(pos, v_fog_factor);\n#endif\n}\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\nCC_TRANSFER_FOG(matWorld * position);\nreturn cc_matProj * (cc_matView * matWorld) * position;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\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}\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = ACESToneMap(color.rgb);\n#endif\ncolor.rgb = sqrt(color.rgb);\nreturn color;\n}\nuniform highp vec4 cc_cameraPos;\nuniform mediump vec4 cc_fogColor;\nuniform mediump vec4 cc_fogBase;\nuniform mediump vec4 cc_fogAdd;\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 fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / 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}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\nvoid CC_APPLY_FOG_BASE(inout vec4 color, float factor) {\ncolor = vec4(mix(cc_fogColor.rgb, color.rgb, factor), color.a);\n}\n#if !CC_USE_ACCURATE_FOG\nvarying float v_fog_factor;\n#endif\nvoid CC_APPLY_FOG(inout vec4 color) {\n#if !CC_USE_ACCURATE_FOG\nCC_APPLY_FOG_BASE(color, v_fog_factor);\n#endif\n}\nvoid CC_APPLY_FOG(inout vec4 color, vec3 worldPos) {\n#if CC_USE_ACCURATE_FOG\nfloat factor;\nCC_TRANSFER_FOG_BASE(vec4(worldPos, 1.0), factor);\n#else\nfloat factor = v_fog_factor;\n#endif\nCC_APPLY_FOG_BASE(color, factor);\n}\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.rgb *= SRGBToLinear(v_color.rgb);\no.a *= v_color.a;\n#endif\n#if USE_TEXTURE\nvec4 texColor = texture2D(mainTexture, v_uv);\ntexColor.rgb = SRGBToLinear(texColor.rgb);\no *= texColor;\n#endif\n#if USE_ALPHA_TEST\nif (o.ALPHA_TEST_CHANNEL < colorScaleAndCutoff.w) discard;\n#endif\nCC_APPLY_FOG(o);\nreturn CCFragOutput(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 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;\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nvarying vec2 v_uv;\nuniform mediump vec4 texSize;\nuniform sampler2D outputResultMap;\nfloat luminance(vec3 color) {\nreturn dot(color, vec3(0.2126, 0.7152, 0.0722));\n}\nvoid main() {\nvec3 color = texture2D(outputResultMap, v_uv).xyz;\nif (luminance(SRGBToLinear(color)) > texSize.z) {\ngl_FragColor = vec4(color, 1.0);\n} else {\ngl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n}\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 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;\nvarying vec2 v_uv;\nuniform mediump vec4 texSize;\nuniform sampler2D bloomTexture;\nvec3 downsample4taps(vec2 uv, vec2 halfpixel) {\nvec3 sum = texture2D(bloomTexture, uv + vec2(-halfpixel.x, halfpixel.y)).xyz;\nsum += texture2D(bloomTexture, uv + vec2(halfpixel.x, halfpixel.y)).xyz;\nsum += texture2D(bloomTexture, uv + vec2(halfpixel.x, -halfpixel.y)).xyz;\nsum += texture2D(bloomTexture, uv + vec2(-halfpixel.x, -halfpixel.y)).xyz;\nreturn sum / 4.0;\n}\nvoid main()\n{\nvec3 result = downsample4taps(v_uv, 1.0 / texSize.xy).rgb;\ngl_FragColor = vec4(result, 1.0);\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 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;\nvarying vec2 v_uv;\nuniform mediump vec4 texSize;\nuniform sampler2D bloomTexture;\nvec3 upsample4taps(vec2 uv, vec2 halfpixel) {\nvec3 sum = texture2D(bloomTexture, uv + vec2(-halfpixel.x, halfpixel.y)).xyz;\nsum += texture2D(bloomTexture, uv + vec2(halfpixel.x, halfpixel.y)).xyz;\nsum += texture2D(bloomTexture, uv + vec2(halfpixel.x, -halfpixel.y)).xyz;\nsum += texture2D(bloomTexture, uv + vec2(-halfpixel.x, -halfpixel.y)).xyz;\nreturn sum / 4.0;\n}\nvoid main() {\nvec3 result = upsample4taps(v_uv, 0.5 / texSize.xy).rgb;\ngl_FragColor = vec4(result, 1.0);\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 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;\nvarying vec2 v_uv;\nuniform mediump vec4 texSize;\nuniform sampler2D outputResultMap;\nuniform sampler2D bloomTexture;\nvoid main() {\nvec4 hdrColor = texture2D(outputResultMap, v_uv);\nvec3 bloomColor = texture2D(bloomTexture, v_uv).rgb;\nvec3 result = hdrColor.rgb + bloomColor * texSize.w * hdrColor.a;\ngl_FragColor = vec4(result, hdrColor.a);\n}"}],[{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_framebuffer_fetch\n#extension GL_EXT_shader_framebuffer_fetch: enable\n#endif\n#ifdef GL_OES_standard_derivatives\n#extension GL_OES_standard_derivatives: 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 mat4 cc_matView;\nuniform highp mat4 cc_matViewProjInv;\nuniform highp vec4 cc_cameraPos;\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;\nuniform mediump vec4 cc_nearFar;\nuniform mediump vec4 cc_viewPort;\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nuniform highp mat4 cc_matLightView;\nuniform highp mat4 cc_matLightViewProj;\nuniform highp vec4 cc_shadowInvProjDepthInfo;\nuniform highp vec4 cc_shadowProjDepthInfo;\nuniform highp vec4 cc_shadowProjInfo;\nuniform mediump vec4 cc_shadowNFLSInfo;\nuniform mediump vec4 cc_shadowWHPBInfo;\nuniform mediump vec4 cc_shadowLPNNInfo;\nhighp float unpackHighpData (float mainPart, float modPart) {\nhighp float data = mainPart;\nreturn data + modPart;\n}\nhighp float unpackHighpData (float mainPart, float modPart, const float modValue) {\nhighp float data = mainPart * modValue;\nreturn data + modPart * modValue;\n}\nhighp vec2 unpackHighpData (vec2 mainPart, vec2 modPart) {\nhighp vec2 data = mainPart;\nreturn data + modPart;\n}\nhighp vec2 unpackHighpData (vec2 mainPart, vec2 modPart, const float modValue) {\nhighp vec2 data = mainPart * modValue;\nreturn data + modPart * modValue;\n}\nhighp vec3 unpackHighpData (vec3 mainPart, vec3 modPart) {\nhighp vec3 data = mainPart;\nreturn data + modPart;\n}\nhighp vec3 unpackHighpData (vec3 mainPart, vec3 modPart, const float modValue) {\nhighp vec3 data = mainPart * modValue;\nreturn data + modPart * modValue;\n}\nhighp vec4 unpackHighpData (vec4 mainPart, vec4 modPart) {\nhighp vec4 data = mainPart;\nreturn data + modPart;\n}\nhighp vec4 unpackHighpData (vec4 mainPart, vec4 modPart, const float modValue) {\nhighp vec4 data = mainPart * modValue;\nreturn data + modPart * modValue;\n}\nfloat CCGetLinearDepthFromViewSpace(vec3 viewPos) {\nfloat dist = length(viewPos);\nreturn (dist - cc_shadowNFLSInfo.x) / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x);\n}\nfloat CCGetLinearDepth(vec3 worldPos) {\nvec4 viewStartPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\nreturn CCGetLinearDepthFromViewSpace(viewStartPos.xyz);\n}\n#if CC_RECEIVE_SHADOW\nuniform highp sampler2D cc_shadowMap;\nuniform highp sampler2D cc_spotLightingMap;\nvec4 ApplyShadowDepthBias_FaceNormal(vec4 shadowPos, vec3 worldNormal)\n{\nvec4 newShadowPos = shadowPos;\nif(cc_shadowLPNNInfo.z > 0.0001)\n{\nvec4 viewNormal = cc_matLightView * vec4(worldNormal, 0.0);\nif(viewNormal.z < 0.1)\nnewShadowPos.xy += viewNormal.xy * cc_shadowProjInfo.xy * cc_shadowLPNNInfo.z * clamp(viewNormal.z, 0.001, 0.1);\n}\nreturn newShadowPos;\n}\nvec4 ApplyShadowDepthBias_Perspective(vec4 shadowPos, float viewspaceDepthBias)\n{\nvec3 viewSpacePos;\nviewSpacePos.xy = shadowPos.xy * cc_shadowProjInfo.zw;\nviewSpacePos.z = shadowPos.z * cc_shadowInvProjDepthInfo.x + shadowPos.w * cc_shadowInvProjDepthInfo.y;\nviewSpacePos.xyz += cc_shadowProjDepthInfo.z * normalize(viewSpacePos.xyz) * viewspaceDepthBias;\nvec4 clipSpacePos;\nclipSpacePos.xy = viewSpacePos.xy * cc_shadowProjInfo.xy;\nclipSpacePos.zw = viewSpacePos.z * cc_shadowProjDepthInfo.xz + vec2(cc_shadowProjDepthInfo.y, 0.0);\nif (cc_shadowNFLSInfo.z > 0.000001) {\nclipSpacePos.z = CCGetLinearDepthFromViewSpace(viewSpacePos.xyz);\nclipSpacePos.z = (clipSpacePos.z * 2.0 - 1.0) * clipSpacePos.w;\n}\nreturn clipSpacePos;\n}\nvec4 ApplyShadowDepthBias_Orthographic(vec4 shadowPos, float viewspaceDepthBias)\n{\nfloat coeffA = cc_shadowProjDepthInfo.x;\nfloat coeffB = cc_shadowProjDepthInfo.y;\nfloat viewSpacePos_z = (shadowPos.z - coeffB) / coeffA;\nviewSpacePos_z += viewspaceDepthBias;\nvec4 result = shadowPos;\nresult.z = viewSpacePos_z * coeffA + coeffB;\nreturn result;\n}\nfloat CCGetShadowFactorHard (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\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 / 16581375.0));\n} else {\nclosestDepth = texture2D(cc_shadowMap, clipPos.xy).x;\n}\nshadow = step(clipPos.z, closestDepth);\nreturn shadow;\n}\nfloat CCGetShadowFactorSoft (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetShadowFactorSoft2X (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(offsetDepth, dot(texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(offsetDepth, texture2D(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\nfloat CCGetSpotLightShadowFactorHard (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nfloat depth = clipPos.z;\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 / 16581375.0));\n} else {\nclosestDepth = texture2D(cc_spotLightingMap, clipPos.xy).x;\n}\nshadow = step(depth, closestDepth);\nreturn shadow;\n}\nfloat CCGetSpotLightShadowFactorSoft (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nfloat bias = cc_shadowWHPBInfo.w;\nvec2 oneTap = 1.0 / cc_shadowWHPBInfo.xy;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * cc_shadowWHPBInfo.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * cc_shadowWHPBInfo.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetSpotLightShadowFactorSoft2X (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nfloat bias = cc_shadowWHPBInfo.w;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(depth, dot(texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(depth, texture2D(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\n#endif\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\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}\nvec3 unpackRGBE (vec4 rgbe) {\nreturn rgbe.rgb * pow(1.1, rgbe.a * 255.0 - 128.0);\n}\n#if CC_USE_DIFFUSEMAP\nuniform samplerCube cc_diffuseMap;\n#endif\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}\n#if USE_REFLECTION_DENOISE\nvec3 GetEnvReflectionWithMipFiltering(vec3 R, float roughness, float mipCount, float denoiseIntensity) {\n#if CC_USE_IBL\nfloat mip = roughness * mipCount;\nfloat delta = (dot(dFdx(R), dFdy(R))) * 1000.0;\nfloat mipBias = mix(0.0, 5.0, clamp(delta, 0.0, 1.0));\nvec4 biased = fragTextureLod(cc_environment, R, mip + mipBias);\nvec4 filtered = textureCube(cc_environment, R);\n#if CC_USE_IBL == 2\nbiased.rgb = unpackRGBE(biased);\nfiltered.rgb = unpackRGBE(filtered);\n#else\nbiased.rgb = SRGBToLinear(biased.rgb);\nfiltered.rgb = SRGBToLinear(filtered.rgb);\n#endif\nreturn mix(biased.rgb, filtered.rgb, denoiseIntensity);\n#else\nreturn vec3(0.0, 0.0, 0.0);\n#endif\n}\n#endif\nstruct StandardSurface {\nvec4 albedo;\n#if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\nvec3 position, position_fract_part;\n#else\nvec3 position;\n#endif\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 position;\n#if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\nposition = unpackHighpData(s.position, s.position_fract_part);\n#else\nposition = s.position;\n#endif\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - position);\nfloat NV = max(abs(dot(N, V)), 0.0);\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.0);\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);\nvec3 dirlightContrib = (diffuseContrib + specularContrib);\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (NL > 0.0 && cc_mainLitDir.w > 0.0) {\n{\nvec4 pos = ApplyShadowDepthBias_FaceNormal(shadowPos, N);\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetShadowFactorSoft2X(pos);\nelse if (pcf > 0.9) shadow = CCGetShadowFactorSoft(pos);\nelse shadow = CCGetShadowFactorHard(pos);\nshadow = mix(shadow, 1.0, cc_shadowNFLSInfo.w);\n}\n}\n#endif\ndirlightContrib *= shadow;\nfinalColor *= dirlightContrib;\nfloat fAmb = 0.5 - N.y * 0.5;\nvec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb);\n#if CC_USE_IBL\n#if CC_USE_DIFFUSEMAP\nvec4 diffuseMap = textureCube(cc_diffuseMap, N);\n#if CC_USE_DIFFUSEMAP == 2\nambDiff = unpackRGBE(diffuseMap);\n#else\nambDiff = SRGBToLinear(diffuseMap.rgb);\n#endif\n#endif\nvec3 R = normalize(reflect(-V, N));\n#if USE_REFLECTION_DENOISE\nvec3 env = GetEnvReflectionWithMipFiltering(R, s.roughness, cc_ambientGround.w, 0.6);\n#else\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\n#endif\nfinalColor += env * cc_ambientSky.w * specular * s.occlusion;\n#endif\nfinalColor += ambDiff.rgb * cc_ambientSky.w * diffuse * s.occlusion;\nfinalColor += s.emissive;\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\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\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];\n#endif\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}\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\nvec4 CCStandardShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 position;\n#if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\nposition = unpackHighpData(s.position, s.position_fract_part);\n#else\nposition = s.position;\n#endif\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 - position);\nfloat NV = max(abs(dot(N, V)), 0.0);\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 - position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.0);\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;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (cc_lightPos[i].w > 0.0 && cc_lightSizeRangeAngle[i].w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\n#endif\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1\nreadonly buffer b_ccLightsBuffer { vec4 b_ccLights[]; };\nreadonly buffer b_clusterLightIndicesBuffer { uint b_clusterLightIndices[]; };\nreadonly buffer b_clusterLightGridBuffer { uvec4 b_clusterLightGrid[]; };\nstruct CCLight\n{\nvec4 cc_lightPos;\nvec4 cc_lightColor;\nvec4 cc_lightSizeRangeAngle;\nvec4 cc_lightDir;\n};\nstruct Cluster\n{\nvec3 minBounds;\nvec3 maxBounds;\n};\nstruct LightGrid\n{\nuint offset;\nuint ccLights;\n};\nCCLight getCCLight(uint i)\n{\nCCLight light;\nlight.cc_lightPos = b_ccLights[4u * i + 0u];\nlight.cc_lightColor = b_ccLights[4u * i + 1u];\nlight.cc_lightSizeRangeAngle = b_ccLights[4u * i + 2u];\nlight.cc_lightDir = b_ccLights[4u * i + 3u];\nreturn light;\n}\nLightGrid getLightGrid(uint cluster)\n{\nuvec4 gridvec = b_clusterLightGrid[cluster];\nLightGrid grid;\ngrid.offset = gridvec.x;\ngrid.ccLights = gridvec.y;\nreturn grid;\n}\nuint getGridLightIndex(uint start, uint offset)\n{\nreturn b_clusterLightIndices[start + offset];\n}\nuint getClusterZIndex(vec4 worldPos)\n{\nfloat scale = float(24) / log(cc_nearFar.y / cc_nearFar.x);\nfloat bias = -(float(24) * log(cc_nearFar.x) / log(cc_nearFar.y / cc_nearFar.x));\nfloat eyeDepth = -(cc_matView * worldPos).z;\nuint zIndex = uint(max(log(eyeDepth) * scale + bias, 0.0));\nreturn zIndex;\n}\nuint getClusterIndex(vec4 fragCoord, vec4 worldPos)\n{\nuint zIndex = getClusterZIndex(worldPos);\nfloat clusterSizeX = ceil(cc_viewPort.z / float(16));\nfloat clusterSizeY = ceil(cc_viewPort.w / float(8));\nuvec3 indices = uvec3(uvec2(fragCoord.xy / vec2(clusterSizeX, clusterSizeY)), zIndex);\nuint cluster = (16u * 8u) * indices.z + 16u * indices.y + indices.x;\nreturn cluster;\n}\nvec4 CCClusterShadingAdditive (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 position;\n#if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\nposition = unpackHighpData(s.position, s.position_fract_part);\n#else\nposition = s.position;\n#endif\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - position);\nfloat NV = max(abs(dot(N, V)), 0.001);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nuint cluster = getClusterIndex(gl_FragCoord, vec4(position, 1.0));\nLightGrid grid = getLightGrid(cluster);\nuint numLights = grid.ccLights;\nfor (uint i = 0u; i < 100u; i++) {\nif (i >= numLights) break;\nuint lightIndex = getGridLightIndex(grid.offset, i);\nCCLight light = getCCLight(lightIndex);\nvec3 SLU = light.cc_lightPos.xyz - 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 = light.cc_lightSizeRangeAngle.x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(light.cc_lightSizeRangeAngle.y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (light.cc_lightPos.w > 0.0) {\nfloat cosInner = max(dot(-light.cc_lightDir.xyz, SL), 0.01);\nfloat cosOuter = light.cc_lightSizeRangeAngle.z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -light.cc_lightDir.xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = light.cc_lightColor.rgb;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (light.cc_lightPos.w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * light.cc_lightColor.w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\n#endif\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 = ACESToneMap(color.rgb);\n#endif\ncolor.rgb = sqrt(color.rgb);\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 fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / 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}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\nvoid CC_APPLY_FOG_BASE(inout vec4 color, float factor) {\ncolor = vec4(mix(cc_fogColor.rgb, color.rgb, factor), color.a);\n}\nvec2 signNotZero(vec2 v) {\nreturn vec2((v.x >= 0.0) ? +1.0 : -1.0, (v.y >= 0.0) ? +1.0 : -1.0);\n}\nvec3 oct_to_float32x3(vec2 e) {\nvec3 v = vec3(e.xy, 1.0 - abs(e.x) - abs(e.y));\nif (v.z < 0.0) v.xy = (1.0 - abs(v.yx)) * signNotZero(v.xy);\nreturn normalize(v);\n}\nvec4 screen2WS(vec3 coord) {\nvec3 ndc = vec3(\n2.0 * (coord.x - cc_viewPort.x) / cc_viewPort.z - 1.0,\n2.0 * (coord.y - cc_viewPort.y) / cc_viewPort.w - 1.0,\n2.0 * coord.z - 1.0);\nvec4 world = ((cc_matViewProjInv) * (vec4(ndc, 1.0)));\nworld = world / world.w;\nreturn world;\n}\nvarying vec2 v_uv;\n#if CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT\n#else\nuniform sampler2D gbuffer_albedoMap;\nuniform sampler2D gbuffer_normalMap;\nuniform sampler2D gbuffer_emissiveMap;\n#endif\nuniform sampler2D depth_stencil;\n#if !CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT || __VERSION__ >= 450\n#endif\nvoid main () {\nStandardSurface s;\n#if CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT\nvec4 albedoMap = gl_LastFragData[0];\nvec4 normalMap = gl_LastFragData[1];\nvec4 emissiveMap = gl_LastFragDat[2];\n#else\nvec4 albedoMap = texture2D(gbuffer_albedoMap,v_uv);\nvec4 normalMap = texture2D(gbuffer_normalMap,v_uv);\nvec4 emissiveMap = texture2D(gbuffer_emissiveMap,v_uv);\n#endif\nfloat depth = texture2D(depth_stencil, v_uv).x;\ns.albedo = albedoMap;\nvec3 position = screen2WS(vec3(gl_FragCoord.xy, depth)).xyz;\ns.position = position;\ns.roughness = normalMap.z;\ns.normal = oct_to_float32x3(normalMap.xy);\ns.metallic = normalMap.w;\ns.emissive = emissiveMap.xyz;\ns.occlusion = emissiveMap.w;\nfloat fogFactor;\nCC_TRANSFER_FOG_BASE(vec4(position, 1), fogFactor);\nvec4 shadowPos;\nshadowPos = cc_matLightViewProj * vec4(position, 1);\nvec4 color = CCStandardShadingBase(s, shadowPos) +\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1\nCCClusterShadingAdditive(s, shadowPos);\n#else\nCCStandardShadingAdditive(s, shadowPos);\n#endif\nCC_APPLY_FOG_BASE(color, fogFactor);\ncolor = CCFragOutput(color);\n#if CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT\ngl_FragData[2] = color;\n#else\ngl_FragColor = color;\n#endif\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;\nuniform highp vec4 cc_cameraPos;\nuniform mediump vec4 cc_mainLitDir;\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 mediump vec4 cc_planarNDInfo;\nvarying float v_dist;\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\nvec3 P = (matWorld * position).xyz;\nvec3 L = cc_mainLitDir.xyz;\nvec3 N = cc_planarNDInfo.xyz;\nfloat d = cc_planarNDInfo.w + 0.001;\nfloat dist = (-d - dot(P, N)) / (dot(L, N) + 0.0001);\nvec3 shadowPos = P + L * dist;\nvec3 view = normalize(cc_cameraPos.xyz - shadowPos);\nfloat viewLength = length(cc_cameraPos.xyz - shadowPos);\nshadowPos += view * min(1.0, 0.005 * viewLength);\nposition = cc_matProj * cc_matView * vec4(shadowPos, 1.0);\nv_dist = dist;\nreturn position;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision mediump float;\nuniform lowp vec4 cc_shadowColor;\nvec4 CCFragOutput (vec4 color) {\nreturn color;\n}\nvarying float v_dist;\nvec4 frag () {\nif(v_dist < 0.0)\ndiscard;\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;\n#if ANTIALIAS_TYPE == 1\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}\n#endif\nvarying vec2 v_uv;\nuniform sampler2D outputResultMap;\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}\nvoid main () {\nmediump vec2 v_rgbNW;\nmediump vec2 v_rgbNE;\nmediump vec2 v_rgbSW;\nmediump vec2 v_rgbSE;\nmediump vec2 v_rgbM;\n#if ANTIALIAS_TYPE == 1\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(outputResultMap, fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n#else\ngl_FragColor = texture2D(outputResultMap, v_uv);\n#endif\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));\nvec4 pos = matViewRotOnly * viewDir;\nif (cc_matProj[3].w > 0.0) {\nmat4 matProj = cc_matProj;\nmatProj[0].x = 5.2;\nmatProj[1].y = 2.6;\nmatProj[2].zw = vec2(-1.0);\nmatProj[3].zw = vec2(0.0);\npos = matProj * pos;\n} else {\npos = cc_matProj * pos;\n}\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(1.1, 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 = ACESToneMap(color.rgb);\n#endif\ncolor.rgb = sqrt(color.rgb);\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_matProj;\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 () {\nmat2 proj = mat2(cc_matProj[0].xy, cc_matProj[1].xy);\nproj /= abs(proj[1].x + proj[1].y);\nvec2 position = proj * a_position.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 vec4(position, 0.0, 1.0);\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision mediump float;\nvec4 CCFragOutput (vec4 color) {\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;\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;\nreturn screenPos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision mediump float;\nvarying vec2 v_uv;\nuniform float u_percent;\nuniform sampler2D mainTexture;\nvec4 frag () {\nvec4 color = texture2D(mainTexture, v_uv);\nfloat percent = clamp(u_percent, 0.0, 1.0);\ncolor.xyz *= percent;\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;\nvec4 nodeRotation;\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\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}\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nvec4 CCFragOutput (vec4 color) {\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\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 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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(std140) uniform CCWorldBound {\nhighp vec4 cc_worldBoundCenter;\nhighp vec4 cc_worldBoundHalfExtents;\n};\nin vec3 a_position;\nvec4 vert () {\nvec4 position;\nposition = vec4(a_position, 1.0);\nposition *= cc_worldBoundHalfExtents;\nposition += cc_worldBoundCenter;\nposition = cc_matViewProj * position;\nreturn position;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision mediump float;\nvec4 frag () {\nreturn vec4(1, 0, 0, 1);\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}\nmat3 quatToMat3(vec4 q) {\nvec3 m0 = vec3(\n1.0 - 2.0 * q.y * q.y - 2.0 * q.z * q.z,\n2.0 * q.x * q.y + 2.0 * q.w * q.z,\n2.0 * q.x * q.z - 2.0 * q.w * q.y);\nvec3 m1 = vec3(\n2.0 * q.x * q.y - 2.0 * q.w * q.z,\n1.0 - 2.0 * q.x * q.x - 2.0 * q.z * q.z,\n2.0 * q.y * q.z + 2.0 * q.w * q.x);\nvec3 m2 = vec3(\n2.0 * q.x * q.z + 2.0 * q.w * q.y,\n2.0 * q.y * q.z - 2.0 * q.w * q.x,\n1.0 - 2.0 * q.x * q.x - 2.0 * q.y * q.y);\nreturn mat3(m0, m1, m2);\n}\nvec4 mat3ToQuat(mat3 mat) {\nfloat tr = mat[0][0] + mat[1][1] + mat[2][2];\nfloat qw, qx, qy, qz;\nif (tr > 0.0) {\nfloat S = sqrt(tr + 1.0) * 2.0;\nfloat invS = 1.0 / S;\nqw = 0.25 * S;\nqx = (mat[1][2] - mat[2][1]) * invS;\nqy = (mat[2][0] - mat[0][2]) * invS;\nqz = (mat[0][1] - mat[1][0]) * invS;\n} else if ((mat[0][0] > mat[1][1])&&(mat[0][0] > mat[2][2])) {\nfloat S = sqrt(1.0 + mat[0][0] - mat[1][1] - mat[2][2]) * 2.0;\nfloat invS = 1.0 / S;\nqw = (mat[1][2] - mat[2][1]) * invS;\nqx = 0.25 * S;\nqy = (mat[1][0] + mat[0][1]) * invS;\nqz = (mat[2][0] + mat[0][2]) * invS;\n} else if (mat[1][1] > mat[2][2]) {\nfloat S = sqrt(1.0 + mat[1][1] - mat[0][0] - mat[2][2]) * 2.0;\nfloat invS = 1.0 / S;\nqw = (mat[2][0] - mat[0][2]) * invS;\nqx = (mat[1][0] + mat[0][1]) * invS;\nqy = 0.25 * S;\nqz = (mat[2][1] + mat[1][2]) * invS;\n} else {\nfloat S = sqrt(1.0 + mat[2][2] - mat[0][0] - mat[1][1]) * 2.0;\nfloat invS = 1.0 / S;\nqw = (mat[0][1] - mat[1][0]) * invS;\nqx = (mat[2][0] + mat[0][2]) * invS;\nqy = (mat[2][1] + mat[1][2]) * invS;\nqz = 0.25 * S;\n}\nreturn vec4(qx, qy, qz, qw);\n}\nvec4 eulerToQuat(vec3 euler) {\nvec3 er = euler * 0.5;\nfloat x = er.x, y = er.y, z = er.z;\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;\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}\nlayout(std140) uniform Constants {\nvec4 mainTiling_Offset;\nvec4 frameTile_velLenScale;\nvec4 scale;\nvec4 nodeRotation;\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\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\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nrotateVecFromQuat(viewSpaceVert, q);\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 x) {\n#if USE_VK_SHADER\nfloat o = x;\nx = mod(x - 1.0, 2.0) - 1.0;\nfloat freqVar = 10.16640753482;\nfloat y = sin(freqVar * floor(o * 0.5 - 0.5));\nfloat v = max(0.0, 1.0-abs(x));\nv *= 0.7071067812;\nv = y < 0.0 ? -v : v;\nreturn v;\n#else\nfloat seed = mod(x, 233280.);\nfloat q = (seed * 9301. + 49297.) / 233280.;\nreturn fract(q);\n#endif\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 startRotation = a_rotation_uv.xyz;\n#if CC_RENDER_MODE != 4\n#if CC_RENDER_MODE == 0\nvec3 rotEuler = startRotation.xyz;\n#elif CC_RENDER_MODE == 1\nvec3 rotEuler = vec3(0.);\n#else\nvec3 rotEuler = vec3(0., 0., startRotation.z);\n#endif\nvec4 rot = quaternionFromEuler(rotEuler);\n#else\nvec4 rot = quaternionFromEuler(startRotation);\n#endif\n#if ROTATION_OVER_TIME_MODULE_ENABLE\nif (u_rotation_mode == 1) {\nvec3 euler = unpackCurveData(rotation_over_time_tex0, timeCoord0) * normalizedTime * a_dir_life.w;\nvec4 quat = eulerToQuat(euler);\nmat3 mLocal = quatToMat3(quat);\nmat3 mStart = quatToMat3(rot);\nrot = mat3ToQuat(mStart * mLocal);\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.);\nvec3 euler = mix(rotation_0, rotation_1, factor_r) * normalizedTime * a_dir_life.w;\n#if CC_RENDER_MODE == 3 || CC_RENDER_MODE == 2\neuler = vec3(0.0, 0.0, euler.z);\n#endif\nvec4 quat = eulerToQuat(euler);\nmat3 mLocal = quatToMat3(quat);\nmat3 mStart = quatToMat3(rot);\nrot = mat3ToQuat(mStart * mLocal);\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 == 1\nrot = vec4(0.0, 0.0, 0.0, 1.0);\n#endif\ncomputeVertPos(pos, cornerOffset, rot, 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\nmat3 rotMat = quatToMat3(rot);\nmat3 nodeMat = quatToMat3(nodeRotation);\nrotMat = nodeMat * rotMat;\nrot = mat3ToQuat(rotMat);\nmat4 xformNoScale = matrixFromRT(rot, pos.xyz);\nmat4 xform = matFromRTS(rot, 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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nvec4 CCFragOutput (vec4 color) {\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;\nvec4 nodeRotation;\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nvec4 CCFragOutput (vec4 color) {\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}\nmat3 quatToMat3(vec4 q) {\nvec3 m0 = vec3(\n1.0 - 2.0 * q.y * q.y - 2.0 * q.z * q.z,\n2.0 * q.x * q.y + 2.0 * q.w * q.z,\n2.0 * q.x * q.z - 2.0 * q.w * q.y);\nvec3 m1 = vec3(\n2.0 * q.x * q.y - 2.0 * q.w * q.z,\n1.0 - 2.0 * q.x * q.x - 2.0 * q.z * q.z,\n2.0 * q.y * q.z + 2.0 * q.w * q.x);\nvec3 m2 = vec3(\n2.0 * q.x * q.z + 2.0 * q.w * q.y,\n2.0 * q.y * q.z - 2.0 * q.w * q.x,\n1.0 - 2.0 * q.x * q.x - 2.0 * q.y * q.y);\nreturn mat3(m0, m1, m2);\n}\nvec4 mat3ToQuat(mat3 mat) {\nfloat tr = mat[0][0] + mat[1][1] + mat[2][2];\nfloat qw, qx, qy, qz;\nif (tr > 0.0) {\nfloat S = sqrt(tr + 1.0) * 2.0;\nfloat invS = 1.0 / S;\nqw = 0.25 * S;\nqx = (mat[1][2] - mat[2][1]) * invS;\nqy = (mat[2][0] - mat[0][2]) * invS;\nqz = (mat[0][1] - mat[1][0]) * invS;\n} else if ((mat[0][0] > mat[1][1])&&(mat[0][0] > mat[2][2])) {\nfloat S = sqrt(1.0 + mat[0][0] - mat[1][1] - mat[2][2]) * 2.0;\nfloat invS = 1.0 / S;\nqw = (mat[1][2] - mat[2][1]) * invS;\nqx = 0.25 * S;\nqy = (mat[1][0] + mat[0][1]) * invS;\nqz = (mat[2][0] + mat[0][2]) * invS;\n} else if (mat[1][1] > mat[2][2]) {\nfloat S = sqrt(1.0 + mat[1][1] - mat[0][0] - mat[2][2]) * 2.0;\nfloat invS = 1.0 / S;\nqw = (mat[2][0] - mat[0][2]) * invS;\nqx = (mat[1][0] + mat[0][1]) * invS;\nqy = 0.25 * S;\nqz = (mat[2][1] + mat[1][2]) * invS;\n} else {\nfloat S = sqrt(1.0 + mat[2][2] - mat[0][0] - mat[1][1]) * 2.0;\nfloat invS = 1.0 / S;\nqw = (mat[0][1] - mat[1][0]) * invS;\nqx = (mat[2][0] + mat[0][2]) * invS;\nqy = (mat[2][1] + mat[1][2]) * invS;\nqz = 0.25 * S;\n}\nreturn vec4(qx, qy, qz, qw);\n}\nlayout(std140) uniform Constants {\nvec4 mainTiling_Offset;\nvec4 frameTile_velLenScale;\nvec4 scale;\nvec4 nodeRotation;\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\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\nvec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\nrotateVecFromQuat(viewSpaceVert, q);\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 ROTATION_OVER_TIME_MODULE_ENABLE\nvec3 rotTmp = a_texCoord2;\nfloat mulFactor = 1.0;\nif (rotTmp.x > 10.0 * 0.5) {\nrotTmp.x -= 10.0;\nmulFactor = -1.0;\n}\nvec4 rot = vec4(rotTmp, 0.0);\nrot.w = mulFactor * sqrt(abs(1.0 - rot.x * rot.x - rot.y * rot.y - rot.z * rot.z));\n#else\n#if CC_RENDER_MODE != 4\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\nvec4 rot = quaternionFromEuler(rotEuler);\n#else\nvec4 rot = quaternionFromEuler(a_texCoord2);\n#endif\n#endif\n#if CC_RENDER_MODE != 4\nvec2 cornerOffset = vec2((a_texCoord.xy - 0.5));\n#if CC_RENDER_MODE == 0 || CC_RENDER_MODE == 3\ncomputeVertPos(pos, cornerOffset, rot, compScale, cc_matViewInv);\n#elif CC_RENDER_MODE == 1\ncomputeVertPos(pos, cornerOffset, rot, compScale, cc_cameraPos.xyz, velocity, frameTile_velLenScale.z, frameTile_velLenScale.w, a_texCoord.x);\n#elif 2\ncomputeVertPos(pos, cornerOffset, rot, compScale);\n#endif\ncolor = a_color;\n#else\nmat3 rotMat = quatToMat3(rot);\nmat3 nodeMat = quatToMat3(nodeRotation);\nrotMat = nodeMat * rotMat;\nrot = mat3ToQuat(rotMat);\nmat4 xformNoScale = matrixFromRT(rot, pos.xyz);\nmat4 xform = matFromRTS(rot, 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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nvec4 CCFragOutput (vec4 color) {\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\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 fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / 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}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\n#if !CC_USE_ACCURATE_FOG\nout float v_fog_factor;\n#endif\nvoid CC_TRANSFER_FOG(vec4 pos) {\n#if !CC_USE_ACCURATE_FOG\nCC_TRANSFER_FOG_BASE(pos, v_fog_factor);\n#endif\n}\nout highp vec4 v_shadowPos;\nlayout(std140) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nmediump vec4 cc_shadowNFLSInfo;\nmediump vec4 cc_shadowWHPBInfo;\nmediump vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\nmediump vec4 cc_planarNDInfo;\n};\n#if CC_RECEIVE_SHADOW\nuniform highp sampler2D cc_shadowMap;\nuniform highp 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_TWOSIDE\nvec3 viewDirect = normalize(cc_cameraPos.xyz - v_position);\nv_normal *= dot(v_normal, viewDirect) < 0.0 ? -1.0 : 1.0;\n#endif\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\nCC_TRANSFER_FOG(pos);\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\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 fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / 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}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\nvoid CC_APPLY_FOG_BASE(inout vec4 color, float factor) {\ncolor = vec4(mix(cc_fogColor.rgb, color.rgb, factor), color.a);\n}\n#if !CC_USE_ACCURATE_FOG\nin float v_fog_factor;\n#endif\nvoid CC_APPLY_FOG(inout vec4 color) {\n#if !CC_USE_ACCURATE_FOG\nCC_APPLY_FOG_BASE(color, v_fog_factor);\n#endif\n}\nvoid CC_APPLY_FOG(inout vec4 color, vec3 worldPos) {\n#if CC_USE_ACCURATE_FOG\nfloat factor;\nCC_TRANSFER_FOG_BASE(vec4(worldPos, 1.0), factor);\n#else\nfloat factor = v_fog_factor;\n#endif\nCC_APPLY_FOG_BASE(color, factor);\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;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nmediump vec4 cc_shadowNFLSInfo;\nmediump vec4 cc_shadowWHPBInfo;\nmediump vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\nmediump vec4 cc_planarNDInfo;\n};\nhighp float unpackHighpData (float mainPart, float modPart) {\nhighp float data = mainPart;\nreturn data + modPart;\n}\nvoid packHighpData (out float mainPart, out float modPart, highp float data) {\nmainPart = fract(data);\nmodPart = data - mainPart;\n}\nhighp float unpackHighpData (float mainPart, float modPart, const float modValue) {\nhighp float data = mainPart * modValue;\nreturn data + modPart * modValue;\n}\nvoid packHighpData (out float mainPart, out float modPart, highp float data, const float modValue) {\nhighp float divide = data / modValue;\nmainPart = floor(divide);\nmodPart = (data - mainPart * modValue) / modValue;\n}\nhighp vec2 unpackHighpData (vec2 mainPart, vec2 modPart) {\nhighp vec2 data = mainPart;\nreturn data + modPart;\n}\nvoid packHighpData (out vec2 mainPart, out vec2 modPart, highp vec2 data) {\nmainPart = fract(data);\nmodPart = data - mainPart;\n}\nhighp vec2 unpackHighpData (vec2 mainPart, vec2 modPart, const float modValue) {\nhighp vec2 data = mainPart * modValue;\nreturn data + modPart * modValue;\n}\nvoid packHighpData (out vec2 mainPart, out vec2 modPart, highp vec2 data, const float modValue) {\nhighp vec2 divide = data / modValue;\nmainPart = floor(divide);\nmodPart = (data - mainPart * modValue) / modValue;\n}\nhighp vec3 unpackHighpData (vec3 mainPart, vec3 modPart) {\nhighp vec3 data = mainPart;\nreturn data + modPart;\n}\nvoid packHighpData (out vec3 mainPart, out vec3 modPart, highp vec3 data) {\nmainPart = fract(data);\nmodPart = data - mainPart;\n}\nhighp vec3 unpackHighpData (vec3 mainPart, vec3 modPart, const float modValue) {\nhighp vec3 data = mainPart * modValue;\nreturn data + modPart * modValue;\n}\nvoid packHighpData (out vec3 mainPart, out vec3 modPart, highp vec3 data, const float modValue) {\nhighp vec3 divide = data / modValue;\nmainPart = floor(divide);\nmodPart = (data - mainPart * modValue) / modValue;\n}\nhighp vec4 unpackHighpData (vec4 mainPart, vec4 modPart) {\nhighp vec4 data = mainPart;\nreturn data + modPart;\n}\nvoid packHighpData (out vec4 mainPart, out vec4 modPart, highp vec4 data) {\nmainPart = fract(data);\nmodPart = data - mainPart;\n}\nhighp vec4 unpackHighpData (vec4 mainPart, vec4 modPart, const float modValue) {\nhighp vec4 data = mainPart * modValue;\nreturn data + modPart * modValue;\n}\nvoid packHighpData (out vec4 mainPart, out vec4 modPart, highp vec4 data, const float modValue) {\nhighp vec4 divide = data / modValue;\nmainPart = floor(divide);\nmodPart = (data - mainPart * modValue) / modValue;\n}\nfloat CCGetLinearDepthFromViewSpace(vec3 viewPos) {\nfloat dist = length(viewPos);\nreturn (dist - cc_shadowNFLSInfo.x) / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x);\n}\nfloat CCGetLinearDepth(vec3 worldPos) {\nvec4 viewStartPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\nreturn CCGetLinearDepthFromViewSpace(viewStartPos.xyz);\n}\n#if CC_RECEIVE_SHADOW\nuniform highp sampler2D cc_shadowMap;\nuniform highp sampler2D cc_spotLightingMap;\nvec4 ApplyShadowDepthBias_FaceNormal(vec4 shadowPos, vec3 worldNormal)\n{\nvec4 newShadowPos = shadowPos;\nif(cc_shadowLPNNInfo.z > 0.0001)\n{\nvec4 viewNormal = cc_matLightView * vec4(worldNormal, 0.0);\nif(viewNormal.z < 0.1)\nnewShadowPos.xy += viewNormal.xy * cc_shadowProjInfo.xy * cc_shadowLPNNInfo.z * clamp(viewNormal.z, 0.001, 0.1);\n}\nreturn newShadowPos;\n}\nvec4 ApplyShadowDepthBias_Perspective(vec4 shadowPos, float viewspaceDepthBias)\n{\nvec3 viewSpacePos;\nviewSpacePos.xy = shadowPos.xy * cc_shadowProjInfo.zw;\nviewSpacePos.z = shadowPos.z * cc_shadowInvProjDepthInfo.x + shadowPos.w * cc_shadowInvProjDepthInfo.y;\nviewSpacePos.xyz += cc_shadowProjDepthInfo.z * normalize(viewSpacePos.xyz) * viewspaceDepthBias;\nvec4 clipSpacePos;\nclipSpacePos.xy = viewSpacePos.xy * cc_shadowProjInfo.xy;\nclipSpacePos.zw = viewSpacePos.z * cc_shadowProjDepthInfo.xz + vec2(cc_shadowProjDepthInfo.y, 0.0);\nif (cc_shadowNFLSInfo.z > 0.000001) {\nclipSpacePos.z = CCGetLinearDepthFromViewSpace(viewSpacePos.xyz);\nclipSpacePos.z = (clipSpacePos.z * 2.0 - 1.0) * clipSpacePos.w;\n}\nreturn clipSpacePos;\n}\nvec4 ApplyShadowDepthBias_Orthographic(vec4 shadowPos, float viewspaceDepthBias)\n{\nfloat coeffA = cc_shadowProjDepthInfo.x;\nfloat coeffB = cc_shadowProjDepthInfo.y;\nfloat viewSpacePos_z = (shadowPos.z - coeffB) / coeffA;\nviewSpacePos_z += viewspaceDepthBias;\nvec4 result = shadowPos;\nresult.z = viewSpacePos_z * coeffA + coeffB;\nreturn result;\n}\nfloat CCGetShadowFactorHard (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\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 / 16581375.0));\n} else {\nclosestDepth = texture(cc_shadowMap, clipPos.xy).x;\n}\nshadow = step(clipPos.z, closestDepth);\nreturn shadow;\n}\nfloat CCGetShadowFactorSoft (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetShadowFactorSoft2X (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\nfloat CCGetSpotLightShadowFactorHard (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nfloat depth = clipPos.z;\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 / 16581375.0));\n} else {\nclosestDepth = texture(cc_spotLightingMap, clipPos.xy).x;\n}\nshadow = step(depth, closestDepth);\nreturn shadow;\n}\nfloat CCGetSpotLightShadowFactorSoft (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nfloat bias = cc_shadowWHPBInfo.w;\nvec2 oneTap = 1.0 / cc_shadowWHPBInfo.xy;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * cc_shadowWHPBInfo.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * cc_shadowWHPBInfo.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetSpotLightShadowFactorSoft2X (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nfloat bias = cc_shadowWHPBInfo.w;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\n#endif\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\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}\nvec3 unpackRGBE (vec4 rgbe) {\nreturn rgbe.rgb * pow(1.1, rgbe.a * 255.0 - 128.0);\n}\n#if CC_USE_DIFFUSEMAP\nuniform samplerCube cc_diffuseMap;\n#endif\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}\n#if USE_REFLECTION_DENOISE\nvec3 GetEnvReflectionWithMipFiltering(vec3 R, float roughness, float mipCount, float denoiseIntensity) {\n#if CC_USE_IBL\nfloat mip = roughness * mipCount;\nfloat delta = (dot(dFdx(R), dFdy(R))) * 1000.0;\nfloat mipBias = mix(0.0, 5.0, clamp(delta, 0.0, 1.0));\nvec4 biased = fragTextureLod(cc_environment, R, mip + mipBias);\nvec4 filtered = texture(cc_environment, R);\n#if CC_USE_IBL == 2\nbiased.rgb = unpackRGBE(biased);\nfiltered.rgb = unpackRGBE(filtered);\n#else\nbiased.rgb = SRGBToLinear(biased.rgb);\nfiltered.rgb = SRGBToLinear(filtered.rgb);\n#endif\nreturn mix(biased.rgb, filtered.rgb, denoiseIntensity);\n#else\nreturn vec3(0.0, 0.0, 0.0);\n#endif\n}\n#endif\nstruct StandardSurface {\nvec4 albedo;\n#if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\nvec3 position, position_fract_part;\n#else\nvec3 position;\n#endif\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 position;\n#if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\nposition = unpackHighpData(s.position, s.position_fract_part);\n#else\nposition = s.position;\n#endif\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - position);\nfloat NV = max(abs(dot(N, V)), 0.0);\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.0);\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);\nvec3 dirlightContrib = (diffuseContrib + specularContrib);\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (NL > 0.0 && cc_mainLitDir.w > 0.0) {\n{\nvec4 pos = ApplyShadowDepthBias_FaceNormal(shadowPos, N);\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetShadowFactorSoft2X(pos);\nelse if (pcf > 0.9) shadow = CCGetShadowFactorSoft(pos);\nelse shadow = CCGetShadowFactorHard(pos);\nshadow = mix(shadow, 1.0, cc_shadowNFLSInfo.w);\n}\n}\n#endif\ndirlightContrib *= shadow;\nfinalColor *= dirlightContrib;\nfloat fAmb = 0.5 - N.y * 0.5;\nvec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb);\n#if CC_USE_IBL\n#if CC_USE_DIFFUSEMAP\nvec4 diffuseMap = texture(cc_diffuseMap, N);\n#if CC_USE_DIFFUSEMAP == 2\nambDiff = unpackRGBE(diffuseMap);\n#else\nambDiff = SRGBToLinear(diffuseMap.rgb);\n#endif\n#endif\nvec3 R = normalize(reflect(-V, N));\n#if USE_REFLECTION_DENOISE\nvec3 env = GetEnvReflectionWithMipFiltering(R, s.roughness, cc_ambientGround.w, 0.6);\n#else\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\n#endif\nfinalColor += env * cc_ambientSky.w * specular * s.occlusion;\n#endif\nfinalColor += ambDiff.rgb * cc_ambientSky.w * diffuse * s.occlusion;\nfinalColor += s.emissive;\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 = ACESToneMap(color.rgb);\n#endif\ncolor.rgb = sqrt(color.rgb);\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.rgb *= SRGBToLinear(v_color.rgb);\nbaseColor.a *= v_color.a;\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 * emissiveScaleParam.w) * normalize(v_tangent) +\n(nmmp.y * emissiveScaleParam.w) * normalize(v_bitangent) +\nnmmp.z * normalize(s.normal);\n#endif\n#if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\npackHighpData(s.position, s.position_fract_part, v_position);\n#else\ns.position = v_position;\n#endif\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;\npbr.w *= res.a;\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 = pbr.x;\ns.roughness = pbr.y;\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\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\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};\n#endif\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}\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\nvec4 CCStandardShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 position;\n#if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\nposition = unpackHighpData(s.position, s.position_fract_part);\n#else\nposition = s.position;\n#endif\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 - position);\nfloat NV = max(abs(dot(N, V)), 0.0);\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 - position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.0);\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;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (cc_lightPos[i].w > 0.0 && cc_lightSizeRangeAngle[i].w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\n#endif\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1\nlayout(std430, binding = 4) readonly buffer b_ccLightsBuffer { vec4 b_ccLights[]; };\nlayout(std430, binding = 5) readonly buffer b_clusterLightIndicesBuffer { uint b_clusterLightIndices[]; };\nlayout(std430, binding = 6) readonly buffer b_clusterLightGridBuffer { uvec4 b_clusterLightGrid[]; };\nstruct CCLight\n{\nvec4 cc_lightPos;\nvec4 cc_lightColor;\nvec4 cc_lightSizeRangeAngle;\nvec4 cc_lightDir;\n};\nstruct Cluster\n{\nvec3 minBounds;\nvec3 maxBounds;\n};\nstruct LightGrid\n{\nuint offset;\nuint ccLights;\n};\nCCLight getCCLight(uint i)\n{\nCCLight light;\nlight.cc_lightPos = b_ccLights[4u * i + 0u];\nlight.cc_lightColor = b_ccLights[4u * i + 1u];\nlight.cc_lightSizeRangeAngle = b_ccLights[4u * i + 2u];\nlight.cc_lightDir = b_ccLights[4u * i + 3u];\nreturn light;\n}\nLightGrid getLightGrid(uint cluster)\n{\nuvec4 gridvec = b_clusterLightGrid[cluster];\nLightGrid grid;\ngrid.offset = gridvec.x;\ngrid.ccLights = gridvec.y;\nreturn grid;\n}\nuint getGridLightIndex(uint start, uint offset)\n{\nreturn b_clusterLightIndices[start + offset];\n}\nuint getClusterZIndex(vec4 worldPos)\n{\nfloat scale = float(24) / log(cc_nearFar.y / cc_nearFar.x);\nfloat bias = -(float(24) * log(cc_nearFar.x) / log(cc_nearFar.y / cc_nearFar.x));\nfloat eyeDepth = -(cc_matView * worldPos).z;\nuint zIndex = uint(max(log(eyeDepth) * scale + bias, 0.0));\nreturn zIndex;\n}\nuint getClusterIndex(vec4 fragCoord, vec4 worldPos)\n{\nuint zIndex = getClusterZIndex(worldPos);\nfloat clusterSizeX = ceil(cc_viewPort.z / float(16));\nfloat clusterSizeY = ceil(cc_viewPort.w / float(8));\nuvec3 indices = uvec3(uvec2(fragCoord.xy / vec2(clusterSizeX, clusterSizeY)), zIndex);\nuint cluster = (16u * 8u) * indices.z + 16u * indices.y + indices.x;\nreturn cluster;\n}\nvec4 CCClusterShadingAdditive (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 position;\n#if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\nposition = unpackHighpData(s.position, s.position_fract_part);\n#else\nposition = s.position;\n#endif\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - position);\nfloat NV = max(abs(dot(N, V)), 0.001);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nuint cluster = getClusterIndex(gl_FragCoord, vec4(position, 1.0));\nLightGrid grid = getLightGrid(cluster);\nuint numLights = grid.ccLights;\nfor (uint i = 0u; i < 100u; i++) {\nif (i >= numLights) break;\nuint lightIndex = getGridLightIndex(grid.offset, i);\nCCLight light = getCCLight(lightIndex);\nvec3 SLU = light.cc_lightPos.xyz - 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 = light.cc_lightSizeRangeAngle.x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(light.cc_lightSizeRangeAngle.y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (light.cc_lightPos.w > 0.0) {\nfloat cosInner = max(dot(-light.cc_lightDir.xyz, SL), 0.01);\nfloat cosOuter = light.cc_lightSizeRangeAngle.z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -light.cc_lightDir.xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = light.cc_lightColor.rgb;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (light.cc_lightPos.w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * light.cc_lightColor.w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\n#endif\nlayout(location = 0) out vec4 fragColorX;\nvoid main () {\nStandardSurface s; surf(s);\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1\nvec4 color = CCClusterShadingAdditive(s, v_shadowPos);\n#else\nvec4 color = CCStandardShadingAdditive(s, v_shadowPos);\n#endif\nCC_APPLY_FOG(color, s.position.xyz);\nfragColorX = CCFragOutput(color);\n}\n#elif (CC_PIPELINE_TYPE == 0 || CC_FORCE_FORWARD_SHADING)\nlayout(location = 0) out vec4 fragColorX;\nvoid main () {\nStandardSurface s; surf(s);\nvec4 color = CCStandardShadingBase(s, v_shadowPos);\nCC_APPLY_FOG(color, s.position.xyz);\nfragColorX = CCFragOutput(color);\n}\n#elif CC_PIPELINE_TYPE == 1\nvec2 signNotZero(vec2 v) {\nreturn vec2((v.x >= 0.0) ? +1.0 : -1.0, (v.y >= 0.0) ? +1.0 : -1.0);\n}\nvec2 float32x3_to_oct(in vec3 v) {\nvec2 p = v.xy * (1.0 / (abs(v.x) + abs(v.y) + abs(v.z)));\nreturn (v.z <= 0.0) ? ((1.0 - abs(p.yx)) * signNotZero(p)) : p;\n}\nlayout(location = 0) out vec4 fragColor0;\nlayout(location = 1) out vec4 fragColor1;\nlayout(location = 2) out vec4 fragColor2;\nvoid main () {\nStandardSurface s; surf(s);\nfragColor0 = s.albedo;\nfragColor1 = vec4(float32x3_to_oct(s.normal), s.roughness, s.metallic);\nfragColor2 = 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;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nmediump vec4 cc_shadowNFLSInfo;\nmediump vec4 cc_shadowWHPBInfo;\nmediump vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\nmediump vec4 cc_planarNDInfo;\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, 16581375.0) * depth;\nret = fract(ret);\nret -= vec4(ret.yzw, 0.0) / 255.0;\nreturn ret;\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nlayout(std140) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nmediump vec4 cc_shadowNFLSInfo;\nmediump vec4 cc_shadowWHPBInfo;\nmediump vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\nmediump vec4 cc_planarNDInfo;\n};\nfloat CCGetLinearDepthFromViewSpace(vec3 viewPos) {\nfloat dist = length(viewPos);\nreturn (dist - cc_shadowNFLSInfo.x) / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x);\n}\nfloat CCGetLinearDepth(vec3 worldPos) {\nvec4 viewStartPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\nreturn CCGetLinearDepthFromViewSpace(viewStartPos.xyz);\n}\n#if CC_RECEIVE_SHADOW\nuniform highp sampler2D cc_shadowMap;\nuniform highp sampler2D cc_spotLightingMap;\n#endif\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) {\nreturn vec4(CCGetLinearDepth(v_worldPos.xyz), 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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\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 fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / 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}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\n#if !CC_USE_ACCURATE_FOG\nout float v_fog_factor;\n#endif\nvoid CC_TRANSFER_FOG(vec4 pos) {\n#if !CC_USE_ACCURATE_FOG\nCC_TRANSFER_FOG_BASE(pos, v_fog_factor);\n#endif\n}\nout highp vec4 v_shadowPos;\nlayout(std140) uniform CCShadow {\nhighp mat4 cc_matLightPlaneProj;\nhighp mat4 cc_matLightView;\nhighp mat4 cc_matLightViewProj;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nmediump vec4 cc_shadowNFLSInfo;\nmediump vec4 cc_shadowWHPBInfo;\nmediump vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\nmediump vec4 cc_planarNDInfo;\n};\n#if CC_RECEIVE_SHADOW\nuniform highp sampler2D cc_shadowMap;\nuniform highp 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;\nCC_TRANSFER_FOG(vec4(worldPos, 1.0));\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\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;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nmediump vec4 cc_shadowNFLSInfo;\nmediump vec4 cc_shadowWHPBInfo;\nmediump vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\nmediump vec4 cc_planarNDInfo;\n};\nhighp float unpackHighpData (float mainPart, float modPart) {\nhighp float data = mainPart;\nreturn data + modPart;\n}\nvoid packHighpData (out float mainPart, out float modPart, highp float data) {\nmainPart = fract(data);\nmodPart = data - mainPart;\n}\nhighp float unpackHighpData (float mainPart, float modPart, const float modValue) {\nhighp float data = mainPart * modValue;\nreturn data + modPart * modValue;\n}\nvoid packHighpData (out float mainPart, out float modPart, highp float data, const float modValue) {\nhighp float divide = data / modValue;\nmainPart = floor(divide);\nmodPart = (data - mainPart * modValue) / modValue;\n}\nhighp vec2 unpackHighpData (vec2 mainPart, vec2 modPart) {\nhighp vec2 data = mainPart;\nreturn data + modPart;\n}\nvoid packHighpData (out vec2 mainPart, out vec2 modPart, highp vec2 data) {\nmainPart = fract(data);\nmodPart = data - mainPart;\n}\nhighp vec2 unpackHighpData (vec2 mainPart, vec2 modPart, const float modValue) {\nhighp vec2 data = mainPart * modValue;\nreturn data + modPart * modValue;\n}\nvoid packHighpData (out vec2 mainPart, out vec2 modPart, highp vec2 data, const float modValue) {\nhighp vec2 divide = data / modValue;\nmainPart = floor(divide);\nmodPart = (data - mainPart * modValue) / modValue;\n}\nhighp vec3 unpackHighpData (vec3 mainPart, vec3 modPart) {\nhighp vec3 data = mainPart;\nreturn data + modPart;\n}\nvoid packHighpData (out vec3 mainPart, out vec3 modPart, highp vec3 data) {\nmainPart = fract(data);\nmodPart = data - mainPart;\n}\nhighp vec3 unpackHighpData (vec3 mainPart, vec3 modPart, const float modValue) {\nhighp vec3 data = mainPart * modValue;\nreturn data + modPart * modValue;\n}\nvoid packHighpData (out vec3 mainPart, out vec3 modPart, highp vec3 data, const float modValue) {\nhighp vec3 divide = data / modValue;\nmainPart = floor(divide);\nmodPart = (data - mainPart * modValue) / modValue;\n}\nhighp vec4 unpackHighpData (vec4 mainPart, vec4 modPart) {\nhighp vec4 data = mainPart;\nreturn data + modPart;\n}\nvoid packHighpData (out vec4 mainPart, out vec4 modPart, highp vec4 data) {\nmainPart = fract(data);\nmodPart = data - mainPart;\n}\nhighp vec4 unpackHighpData (vec4 mainPart, vec4 modPart, const float modValue) {\nhighp vec4 data = mainPart * modValue;\nreturn data + modPart * modValue;\n}\nvoid packHighpData (out vec4 mainPart, out vec4 modPart, highp vec4 data, const float modValue) {\nhighp vec4 divide = data / modValue;\nmainPart = floor(divide);\nmodPart = (data - mainPart * modValue) / modValue;\n}\nfloat CCGetLinearDepthFromViewSpace(vec3 viewPos) {\nfloat dist = length(viewPos);\nreturn (dist - cc_shadowNFLSInfo.x) / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x);\n}\nfloat CCGetLinearDepth(vec3 worldPos) {\nvec4 viewStartPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\nreturn CCGetLinearDepthFromViewSpace(viewStartPos.xyz);\n}\n#if CC_RECEIVE_SHADOW\nuniform highp sampler2D cc_shadowMap;\nuniform highp sampler2D cc_spotLightingMap;\nvec4 ApplyShadowDepthBias_FaceNormal(vec4 shadowPos, vec3 worldNormal)\n{\nvec4 newShadowPos = shadowPos;\nif(cc_shadowLPNNInfo.z > 0.0001)\n{\nvec4 viewNormal = cc_matLightView * vec4(worldNormal, 0.0);\nif(viewNormal.z < 0.1)\nnewShadowPos.xy += viewNormal.xy * cc_shadowProjInfo.xy * cc_shadowLPNNInfo.z * clamp(viewNormal.z, 0.001, 0.1);\n}\nreturn newShadowPos;\n}\nvec4 ApplyShadowDepthBias_Perspective(vec4 shadowPos, float viewspaceDepthBias)\n{\nvec3 viewSpacePos;\nviewSpacePos.xy = shadowPos.xy * cc_shadowProjInfo.zw;\nviewSpacePos.z = shadowPos.z * cc_shadowInvProjDepthInfo.x + shadowPos.w * cc_shadowInvProjDepthInfo.y;\nviewSpacePos.xyz += cc_shadowProjDepthInfo.z * normalize(viewSpacePos.xyz) * viewspaceDepthBias;\nvec4 clipSpacePos;\nclipSpacePos.xy = viewSpacePos.xy * cc_shadowProjInfo.xy;\nclipSpacePos.zw = viewSpacePos.z * cc_shadowProjDepthInfo.xz + vec2(cc_shadowProjDepthInfo.y, 0.0);\nif (cc_shadowNFLSInfo.z > 0.000001) {\nclipSpacePos.z = CCGetLinearDepthFromViewSpace(viewSpacePos.xyz);\nclipSpacePos.z = (clipSpacePos.z * 2.0 - 1.0) * clipSpacePos.w;\n}\nreturn clipSpacePos;\n}\nvec4 ApplyShadowDepthBias_Orthographic(vec4 shadowPos, float viewspaceDepthBias)\n{\nfloat coeffA = cc_shadowProjDepthInfo.x;\nfloat coeffB = cc_shadowProjDepthInfo.y;\nfloat viewSpacePos_z = (shadowPos.z - coeffB) / coeffA;\nviewSpacePos_z += viewspaceDepthBias;\nvec4 result = shadowPos;\nresult.z = viewSpacePos_z * coeffA + coeffB;\nreturn result;\n}\nfloat CCGetShadowFactorHard (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\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 / 16581375.0));\n} else {\nclosestDepth = texture(cc_shadowMap, clipPos.xy).x;\n}\nshadow = step(clipPos.z, closestDepth);\nreturn shadow;\n}\nfloat CCGetShadowFactorSoft (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetShadowFactorSoft2X (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\nfloat CCGetSpotLightShadowFactorHard (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nfloat depth = clipPos.z;\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 / 16581375.0));\n} else {\nclosestDepth = texture(cc_spotLightingMap, clipPos.xy).x;\n}\nshadow = step(depth, closestDepth);\nreturn shadow;\n}\nfloat CCGetSpotLightShadowFactorSoft (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nfloat bias = cc_shadowWHPBInfo.w;\nvec2 oneTap = 1.0 / cc_shadowWHPBInfo.xy;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * cc_shadowWHPBInfo.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * cc_shadowWHPBInfo.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetSpotLightShadowFactorSoft2X (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nfloat bias = cc_shadowWHPBInfo.w;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\n#endif\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\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}\nvec3 unpackRGBE (vec4 rgbe) {\nreturn rgbe.rgb * pow(1.1, rgbe.a * 255.0 - 128.0);\n}\n#if CC_USE_DIFFUSEMAP\nuniform samplerCube cc_diffuseMap;\n#endif\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}\n#if USE_REFLECTION_DENOISE\nvec3 GetEnvReflectionWithMipFiltering(vec3 R, float roughness, float mipCount, float denoiseIntensity) {\n#if CC_USE_IBL\nfloat mip = roughness * mipCount;\nfloat delta = (dot(dFdx(R), dFdy(R))) * 1000.0;\nfloat mipBias = mix(0.0, 5.0, clamp(delta, 0.0, 1.0));\nvec4 biased = fragTextureLod(cc_environment, R, mip + mipBias);\nvec4 filtered = texture(cc_environment, R);\n#if CC_USE_IBL == 2\nbiased.rgb = unpackRGBE(biased);\nfiltered.rgb = unpackRGBE(filtered);\n#else\nbiased.rgb = SRGBToLinear(biased.rgb);\nfiltered.rgb = SRGBToLinear(filtered.rgb);\n#endif\nreturn mix(biased.rgb, filtered.rgb, denoiseIntensity);\n#else\nreturn vec3(0.0, 0.0, 0.0);\n#endif\n}\n#endif\nstruct StandardSurface {\nvec4 albedo;\n#if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\nvec3 position, position_fract_part;\n#else\nvec3 position;\n#endif\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 position;\n#if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\nposition = unpackHighpData(s.position, s.position_fract_part);\n#else\nposition = s.position;\n#endif\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - position);\nfloat NV = max(abs(dot(N, V)), 0.0);\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.0);\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);\nvec3 dirlightContrib = (diffuseContrib + specularContrib);\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (NL > 0.0 && cc_mainLitDir.w > 0.0) {\n{\nvec4 pos = ApplyShadowDepthBias_FaceNormal(shadowPos, N);\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetShadowFactorSoft2X(pos);\nelse if (pcf > 0.9) shadow = CCGetShadowFactorSoft(pos);\nelse shadow = CCGetShadowFactorHard(pos);\nshadow = mix(shadow, 1.0, cc_shadowNFLSInfo.w);\n}\n}\n#endif\ndirlightContrib *= shadow;\nfinalColor *= dirlightContrib;\nfloat fAmb = 0.5 - N.y * 0.5;\nvec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb);\n#if CC_USE_IBL\n#if CC_USE_DIFFUSEMAP\nvec4 diffuseMap = texture(cc_diffuseMap, N);\n#if CC_USE_DIFFUSEMAP == 2\nambDiff = unpackRGBE(diffuseMap);\n#else\nambDiff = SRGBToLinear(diffuseMap.rgb);\n#endif\n#endif\nvec3 R = normalize(reflect(-V, N));\n#if USE_REFLECTION_DENOISE\nvec3 env = GetEnvReflectionWithMipFiltering(R, s.roughness, cc_ambientGround.w, 0.6);\n#else\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\n#endif\nfinalColor += env * cc_ambientSky.w * specular * s.occlusion;\n#endif\nfinalColor += ambDiff.rgb * cc_ambientSky.w * diffuse * s.occlusion;\nfinalColor += s.emissive;\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 = ACESToneMap(color.rgb);\n#endif\ncolor.rgb = sqrt(color.rgb);\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 fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / 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}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\nvoid CC_APPLY_FOG_BASE(inout vec4 color, float factor) {\ncolor = vec4(mix(cc_fogColor.rgb, color.rgb, factor), color.a);\n}\n#if !CC_USE_ACCURATE_FOG\nin float v_fog_factor;\n#endif\nvoid CC_APPLY_FOG(inout vec4 color) {\n#if !CC_USE_ACCURATE_FOG\nCC_APPLY_FOG_BASE(color, v_fog_factor);\n#endif\n}\nvoid CC_APPLY_FOG(inout vec4 color, vec3 worldPos) {\n#if CC_USE_ACCURATE_FOG\nfloat factor;\nCC_TRANSFER_FOG_BASE(vec4(worldPos, 1.0), factor);\n#else\nfloat factor = v_fog_factor;\n#endif\nCC_APPLY_FOG_BASE(color, factor);\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 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\n#if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\npackHighpData(s.position, s.position_fract_part, v_position);\n#else\ns.position = v_position;\n#endif\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\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\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};\n#endif\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}\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\nvec4 CCStandardShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 position;\n#if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\nposition = unpackHighpData(s.position, s.position_fract_part);\n#else\nposition = s.position;\n#endif\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 - position);\nfloat NV = max(abs(dot(N, V)), 0.0);\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 - position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.0);\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;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (cc_lightPos[i].w > 0.0 && cc_lightSizeRangeAngle[i].w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\n#endif\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1\nlayout(std430, binding = 4) readonly buffer b_ccLightsBuffer { vec4 b_ccLights[]; };\nlayout(std430, binding = 5) readonly buffer b_clusterLightIndicesBuffer { uint b_clusterLightIndices[]; };\nlayout(std430, binding = 6) readonly buffer b_clusterLightGridBuffer { uvec4 b_clusterLightGrid[]; };\nstruct CCLight\n{\nvec4 cc_lightPos;\nvec4 cc_lightColor;\nvec4 cc_lightSizeRangeAngle;\nvec4 cc_lightDir;\n};\nstruct Cluster\n{\nvec3 minBounds;\nvec3 maxBounds;\n};\nstruct LightGrid\n{\nuint offset;\nuint ccLights;\n};\nCCLight getCCLight(uint i)\n{\nCCLight light;\nlight.cc_lightPos = b_ccLights[4u * i + 0u];\nlight.cc_lightColor = b_ccLights[4u * i + 1u];\nlight.cc_lightSizeRangeAngle = b_ccLights[4u * i + 2u];\nlight.cc_lightDir = b_ccLights[4u * i + 3u];\nreturn light;\n}\nLightGrid getLightGrid(uint cluster)\n{\nuvec4 gridvec = b_clusterLightGrid[cluster];\nLightGrid grid;\ngrid.offset = gridvec.x;\ngrid.ccLights = gridvec.y;\nreturn grid;\n}\nuint getGridLightIndex(uint start, uint offset)\n{\nreturn b_clusterLightIndices[start + offset];\n}\nuint getClusterZIndex(vec4 worldPos)\n{\nfloat scale = float(24) / log(cc_nearFar.y / cc_nearFar.x);\nfloat bias = -(float(24) * log(cc_nearFar.x) / log(cc_nearFar.y / cc_nearFar.x));\nfloat eyeDepth = -(cc_matView * worldPos).z;\nuint zIndex = uint(max(log(eyeDepth) * scale + bias, 0.0));\nreturn zIndex;\n}\nuint getClusterIndex(vec4 fragCoord, vec4 worldPos)\n{\nuint zIndex = getClusterZIndex(worldPos);\nfloat clusterSizeX = ceil(cc_viewPort.z / float(16));\nfloat clusterSizeY = ceil(cc_viewPort.w / float(8));\nuvec3 indices = uvec3(uvec2(fragCoord.xy / vec2(clusterSizeX, clusterSizeY)), zIndex);\nuint cluster = (16u * 8u) * indices.z + 16u * indices.y + indices.x;\nreturn cluster;\n}\nvec4 CCClusterShadingAdditive (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 position;\n#if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\nposition = unpackHighpData(s.position, s.position_fract_part);\n#else\nposition = s.position;\n#endif\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - position);\nfloat NV = max(abs(dot(N, V)), 0.001);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nuint cluster = getClusterIndex(gl_FragCoord, vec4(position, 1.0));\nLightGrid grid = getLightGrid(cluster);\nuint numLights = grid.ccLights;\nfor (uint i = 0u; i < 100u; i++) {\nif (i >= numLights) break;\nuint lightIndex = getGridLightIndex(grid.offset, i);\nCCLight light = getCCLight(lightIndex);\nvec3 SLU = light.cc_lightPos.xyz - 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 = light.cc_lightSizeRangeAngle.x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(light.cc_lightSizeRangeAngle.y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (light.cc_lightPos.w > 0.0) {\nfloat cosInner = max(dot(-light.cc_lightDir.xyz, SL), 0.01);\nfloat cosOuter = light.cc_lightSizeRangeAngle.z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -light.cc_lightDir.xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = light.cc_lightColor.rgb;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (light.cc_lightPos.w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * light.cc_lightColor.w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\n#endif\nlayout(location = 0) out vec4 fragColorX;\nvoid main () {\nStandardSurface s; surf(s);\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1\nvec4 color = CCClusterShadingAdditive(s, v_shadowPos);\n#else\nvec4 color = CCStandardShadingAdditive(s, v_shadowPos);\n#endif\nCC_APPLY_FOG(color, s.position.xyz);\nfragColorX = CCFragOutput(color);\n}\n#elif (CC_PIPELINE_TYPE == 0 || CC_FORCE_FORWARD_SHADING)\nlayout(location = 0) out vec4 fragColorX;\nvoid main () {\nStandardSurface s; surf(s);\nvec4 color = CCStandardShadingBase(s, v_shadowPos);\nCC_APPLY_FOG(color, s.position.xyz);\nfragColorX = CCFragOutput(color);\n}\n#elif CC_PIPELINE_TYPE == 1\nvec2 signNotZero(vec2 v) {\nreturn vec2((v.x >= 0.0) ? +1.0 : -1.0, (v.y >= 0.0) ? +1.0 : -1.0);\n}\nvec2 float32x3_to_oct(in vec3 v) {\nvec2 p = v.xy * (1.0 / (abs(v.x) + abs(v.y) + abs(v.z)));\nreturn (v.z <= 0.0) ? ((1.0 - abs(p.yx)) * signNotZero(p)) : p;\n}\nlayout(location = 0) out vec4 fragColor0;\nlayout(location = 1) out vec4 fragColor1;\nlayout(location = 2) out vec4 fragColor2;\nvoid main () {\nStandardSurface s; surf(s);\nfragColor0 = s.albedo;\nfragColor1 = vec4(float32x3_to_oct(s.normal), s.roughness, s.metallic);\nfragColor2 = 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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\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;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nmediump vec4 cc_shadowNFLSInfo;\nmediump vec4 cc_shadowWHPBInfo;\nmediump vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\nmediump vec4 cc_planarNDInfo;\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, 16581375.0) * depth;\nret = fract(ret);\nret -= vec4(ret.yzw, 0.0) / 255.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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\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 fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / 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}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\n#if !CC_USE_ACCURATE_FOG\nout float v_fog_factor;\n#endif\nvoid CC_TRANSFER_FOG(vec4 pos) {\n#if !CC_USE_ACCURATE_FOG\nCC_TRANSFER_FOG_BASE(pos, v_fog_factor);\n#endif\n}\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\nCC_TRANSFER_FOG(matWorld * position);\nreturn cc_matProj * (cc_matView * matWorld) * position;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\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}\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n#if CC_USE_HDR\ncolor.rgb = ACESToneMap(color.rgb);\n#endif\ncolor.rgb = sqrt(color.rgb);\nreturn color;\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\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 fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / 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}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\nvoid CC_APPLY_FOG_BASE(inout vec4 color, float factor) {\ncolor = vec4(mix(cc_fogColor.rgb, color.rgb, factor), color.a);\n}\n#if !CC_USE_ACCURATE_FOG\nin float v_fog_factor;\n#endif\nvoid CC_APPLY_FOG(inout vec4 color) {\n#if !CC_USE_ACCURATE_FOG\nCC_APPLY_FOG_BASE(color, v_fog_factor);\n#endif\n}\nvoid CC_APPLY_FOG(inout vec4 color, vec3 worldPos) {\n#if CC_USE_ACCURATE_FOG\nfloat factor;\nCC_TRANSFER_FOG_BASE(vec4(worldPos, 1.0), factor);\n#else\nfloat factor = v_fog_factor;\n#endif\nCC_APPLY_FOG_BASE(color, factor);\n}\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.rgb *= SRGBToLinear(v_color.rgb);\no.a *= v_color.a;\n#endif\n#if USE_TEXTURE\nvec4 texColor = texture(mainTexture, v_uv);\ntexColor.rgb = SRGBToLinear(texColor.rgb);\no *= texColor;\n#endif\n#if USE_ALPHA_TEST\nif (o.ALPHA_TEST_CHANNEL < colorScaleAndCutoff.w) discard;\n#endif\nCC_APPLY_FOG(o);\nreturn CCFragOutput(o);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nvec3 SRGBToLinear (vec3 gamma) {\nreturn gamma * gamma;\n}\nin vec2 v_uv;\nlayout(std140) uniform BloomUBO {\nmediump vec4 texSize;\n};\nuniform sampler2D outputResultMap;\nlayout(location = 0) out vec4 fragColor;\nfloat luminance(vec3 color) {\nreturn dot(color, vec3(0.2126, 0.7152, 0.0722));\n}\nvoid main() {\nvec3 color = texture(outputResultMap, v_uv).xyz;\nif (luminance(SRGBToLinear(color)) > texSize.z) {\nfragColor = vec4(color, 1.0);\n} else {\nfragColor = vec4(0.0, 0.0, 0.0, 1.0);\n}\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nin vec2 v_uv;\nlayout(std140) uniform BloomUBO {\nmediump vec4 texSize;\n};\nuniform sampler2D bloomTexture;\nlayout(location = 0) out vec4 fragColor;\nvec3 downsample4taps(vec2 uv, vec2 halfpixel) {\nvec3 sum = texture(bloomTexture, uv + vec2(-halfpixel.x, halfpixel.y)).xyz;\nsum += texture(bloomTexture, uv + vec2(halfpixel.x, halfpixel.y)).xyz;\nsum += texture(bloomTexture, uv + vec2(halfpixel.x, -halfpixel.y)).xyz;\nsum += texture(bloomTexture, uv + vec2(-halfpixel.x, -halfpixel.y)).xyz;\nreturn sum / 4.0;\n}\nvoid main()\n{\nvec3 result = downsample4taps(v_uv, 1.0 / texSize.xy).rgb;\nfragColor = vec4(result, 1.0);\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nin vec2 v_uv;\nlayout(std140) uniform BloomUBO {\nmediump vec4 texSize;\n};\nuniform sampler2D bloomTexture;\nlayout(location = 0) out vec4 fragColor;\nvec3 upsample4taps(vec2 uv, vec2 halfpixel) {\nvec3 sum = texture(bloomTexture, uv + vec2(-halfpixel.x, halfpixel.y)).xyz;\nsum += texture(bloomTexture, uv + vec2(halfpixel.x, halfpixel.y)).xyz;\nsum += texture(bloomTexture, uv + vec2(halfpixel.x, -halfpixel.y)).xyz;\nsum += texture(bloomTexture, uv + vec2(-halfpixel.x, -halfpixel.y)).xyz;\nreturn sum / 4.0;\n}\nvoid main() {\nvec3 result = upsample4taps(v_uv, 0.5 / texSize.xy).rgb;\nfragColor = vec4(result, 1.0);\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nin vec2 v_uv;\nlayout(std140) uniform BloomUBO {\nmediump vec4 texSize;\n};\nuniform sampler2D outputResultMap;\nuniform sampler2D bloomTexture;\nlayout(location = 0) out vec4 fragColor;\nvoid main() {\nvec4 hdrColor = texture(outputResultMap, v_uv);\nvec3 bloomColor = texture(bloomTexture, v_uv).rgb;\nvec3 result = hdrColor.rgb + bloomColor * texSize.w * hdrColor.a;\nfragColor = vec4(result, hdrColor.a);\n}"}],[{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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\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:"\n#ifdef GL_EXT_shader_framebuffer_fetch\n#extension GL_EXT_shader_framebuffer_fetch: enable\n#endif\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\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;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nmediump vec4 cc_shadowNFLSInfo;\nmediump vec4 cc_shadowWHPBInfo;\nmediump vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\nmediump vec4 cc_planarNDInfo;\n};\nhighp float unpackHighpData (float mainPart, float modPart) {\nhighp float data = mainPart;\nreturn data + modPart;\n}\nhighp float unpackHighpData (float mainPart, float modPart, const float modValue) {\nhighp float data = mainPart * modValue;\nreturn data + modPart * modValue;\n}\nhighp vec2 unpackHighpData (vec2 mainPart, vec2 modPart) {\nhighp vec2 data = mainPart;\nreturn data + modPart;\n}\nhighp vec2 unpackHighpData (vec2 mainPart, vec2 modPart, const float modValue) {\nhighp vec2 data = mainPart * modValue;\nreturn data + modPart * modValue;\n}\nhighp vec3 unpackHighpData (vec3 mainPart, vec3 modPart) {\nhighp vec3 data = mainPart;\nreturn data + modPart;\n}\nhighp vec3 unpackHighpData (vec3 mainPart, vec3 modPart, const float modValue) {\nhighp vec3 data = mainPart * modValue;\nreturn data + modPart * modValue;\n}\nhighp vec4 unpackHighpData (vec4 mainPart, vec4 modPart) {\nhighp vec4 data = mainPart;\nreturn data + modPart;\n}\nhighp vec4 unpackHighpData (vec4 mainPart, vec4 modPart, const float modValue) {\nhighp vec4 data = mainPart * modValue;\nreturn data + modPart * modValue;\n}\nfloat CCGetLinearDepthFromViewSpace(vec3 viewPos) {\nfloat dist = length(viewPos);\nreturn (dist - cc_shadowNFLSInfo.x) / (cc_shadowNFLSInfo.y - cc_shadowNFLSInfo.x);\n}\nfloat CCGetLinearDepth(vec3 worldPos) {\nvec4 viewStartPos = cc_matLightView * vec4(worldPos.xyz, 1.0);\nreturn CCGetLinearDepthFromViewSpace(viewStartPos.xyz);\n}\n#if CC_RECEIVE_SHADOW\nuniform highp sampler2D cc_shadowMap;\nuniform highp sampler2D cc_spotLightingMap;\nvec4 ApplyShadowDepthBias_FaceNormal(vec4 shadowPos, vec3 worldNormal)\n{\nvec4 newShadowPos = shadowPos;\nif(cc_shadowLPNNInfo.z > 0.0001)\n{\nvec4 viewNormal = cc_matLightView * vec4(worldNormal, 0.0);\nif(viewNormal.z < 0.1)\nnewShadowPos.xy += viewNormal.xy * cc_shadowProjInfo.xy * cc_shadowLPNNInfo.z * clamp(viewNormal.z, 0.001, 0.1);\n}\nreturn newShadowPos;\n}\nvec4 ApplyShadowDepthBias_Perspective(vec4 shadowPos, float viewspaceDepthBias)\n{\nvec3 viewSpacePos;\nviewSpacePos.xy = shadowPos.xy * cc_shadowProjInfo.zw;\nviewSpacePos.z = shadowPos.z * cc_shadowInvProjDepthInfo.x + shadowPos.w * cc_shadowInvProjDepthInfo.y;\nviewSpacePos.xyz += cc_shadowProjDepthInfo.z * normalize(viewSpacePos.xyz) * viewspaceDepthBias;\nvec4 clipSpacePos;\nclipSpacePos.xy = viewSpacePos.xy * cc_shadowProjInfo.xy;\nclipSpacePos.zw = viewSpacePos.z * cc_shadowProjDepthInfo.xz + vec2(cc_shadowProjDepthInfo.y, 0.0);\nif (cc_shadowNFLSInfo.z > 0.000001) {\nclipSpacePos.z = CCGetLinearDepthFromViewSpace(viewSpacePos.xyz);\nclipSpacePos.z = (clipSpacePos.z * 2.0 - 1.0) * clipSpacePos.w;\n}\nreturn clipSpacePos;\n}\nvec4 ApplyShadowDepthBias_Orthographic(vec4 shadowPos, float viewspaceDepthBias)\n{\nfloat coeffA = cc_shadowProjDepthInfo.x;\nfloat coeffB = cc_shadowProjDepthInfo.y;\nfloat viewSpacePos_z = (shadowPos.z - coeffB) / coeffA;\nviewSpacePos_z += viewspaceDepthBias;\nvec4 result = shadowPos;\nresult.z = viewSpacePos_z * coeffA + coeffB;\nreturn result;\n}\nfloat CCGetShadowFactorHard (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\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 / 16581375.0));\n} else {\nclosestDepth = texture(cc_shadowMap, clipPos.xy).x;\n}\nshadow = step(clipPos.z, closestDepth);\nreturn shadow;\n}\nfloat CCGetShadowFactorSoft (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetShadowFactorSoft2X (vec4 shadowPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Orthographic(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat offsetDepth = clipPos.z;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(offsetDepth, dot(texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(offsetDepth, texture(cc_shadowMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\nfloat CCGetSpotLightShadowFactorHard (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat shadow = 0.0;\nfloat closestDepth = 0.0;\nfloat depth = clipPos.z;\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 / 16581375.0));\n} else {\nclosestDepth = texture(cc_spotLightingMap, clipPos.xy).x;\n}\nshadow = step(depth, closestDepth);\nreturn shadow;\n}\nfloat CCGetSpotLightShadowFactorSoft (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nfloat bias = cc_shadowWHPBInfo.w;\nvec2 oneTap = 1.0 / cc_shadowWHPBInfo.xy;\nvec2 clipPos_offset = clipPos.xy + oneTap;\nfloat block0, block1, block2, block3;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos_offset.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x);\nblock1 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos.y)).x);\nblock2 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset.y)).x);\nblock3 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset.x, clipPos_offset.y)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * cc_shadowWHPBInfo.x;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block2, block3, coefX);\nfloat coefY = mod(clipPos.y, oneTap.y) * cc_shadowWHPBInfo.y;\nreturn mix(resultX, resultY, coefY);\n}\nfloat CCGetSpotLightShadowFactorSoft2X (vec4 shadowPos, vec3 worldPos) {\nvec4 clipPosNew = ApplyShadowDepthBias_Perspective(shadowPos, cc_shadowWHPBInfo.w);\nvec3 clipPos = clipPosNew.xyz / clipPosNew.w * 0.5 + 0.5;\nif (clipPos.x < 0.0 || clipPos.x > 1.0 ||\nclipPos.y < 0.0 || clipPos.y > 1.0 ||\nclipPos.z < 0.0 || clipPos.z > 1.0) { return 1.0; }\nclipPos.xy = cc_cameraPos.w == 1.0 ? vec2(clipPos.xy.x, 1.0 - clipPos.xy.y) : clipPos.xy;\nfloat depth = 0.0;\nif (cc_shadowNFLSInfo.z > 0.000001) {\ndepth = CCGetLinearDepth(worldPos);\n} else {\ndepth = clipPos.z;\n}\nfloat bias = cc_shadowWHPBInfo.w;\nvec2 mapSize = cc_shadowWHPBInfo.xy;\nvec2 oneTap = 1.0 / mapSize;\nfloat clipPos_offset_L = clipPos.x - oneTap.x;\nfloat clipPos_offset_R = clipPos.x + oneTap.x;\nfloat clipPos_offset_U = clipPos.y - oneTap.y;\nfloat clipPos_offset_D = clipPos.y + oneTap.y;\nfloat block0, block1, block2, block3, block4, block5, block6, block7, block8;\nif (cc_shadowLPNNInfo.y > 0.000001) {\nblock0 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock1 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock2 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_U)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock3 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock4 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock5 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock6 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock7 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\nblock8 = step(depth, dot(texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_D)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0)));\n} else {\nblock0 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_U)).x);\nblock1 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_U)).x);\nblock2 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_U)).x);\nblock3 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos.y)).x);\nblock4 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)).x);\nblock5 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos.y)).x);\nblock6 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_L, clipPos_offset_D)).x);\nblock7 = step(depth, texture(cc_spotLightingMap, vec2(clipPos.x, clipPos_offset_D)).x);\nblock8 = step(depth, texture(cc_spotLightingMap, vec2(clipPos_offset_R, clipPos_offset_D)).x);\n}\nfloat coefX = mod(clipPos.x, oneTap.x) * mapSize.x;\nfloat coefY = mod(clipPos.y, oneTap.y) * mapSize.y;\nfloat shadow = 0.0;\nfloat resultX = mix(block0, block1, coefX);\nfloat resultY = mix(block3, block4, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block1, block2, coefX);\nresultY = mix(block4, block5, coefX);\nshadow += mix(resultX , resultY, coefY);\nresultX = mix(block3, block4, coefX);\nresultY = mix(block6, block7, coefX);\nshadow += mix(resultX, resultY, coefY);\nresultX = mix(block4, block5, coefX);\nresultY = mix(block7, block8, coefX);\nshadow += mix(resultX, resultY, coefY);\nreturn shadow * 0.25;\n}\n#endif\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\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}\nvec3 unpackRGBE (vec4 rgbe) {\nreturn rgbe.rgb * pow(1.1, rgbe.a * 255.0 - 128.0);\n}\n#if CC_USE_DIFFUSEMAP\nuniform samplerCube cc_diffuseMap;\n#endif\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}\n#if USE_REFLECTION_DENOISE\nvec3 GetEnvReflectionWithMipFiltering(vec3 R, float roughness, float mipCount, float denoiseIntensity) {\n#if CC_USE_IBL\nfloat mip = roughness * mipCount;\nfloat delta = (dot(dFdx(R), dFdy(R))) * 1000.0;\nfloat mipBias = mix(0.0, 5.0, clamp(delta, 0.0, 1.0));\nvec4 biased = fragTextureLod(cc_environment, R, mip + mipBias);\nvec4 filtered = texture(cc_environment, R);\n#if CC_USE_IBL == 2\nbiased.rgb = unpackRGBE(biased);\nfiltered.rgb = unpackRGBE(filtered);\n#else\nbiased.rgb = SRGBToLinear(biased.rgb);\nfiltered.rgb = SRGBToLinear(filtered.rgb);\n#endif\nreturn mix(biased.rgb, filtered.rgb, denoiseIntensity);\n#else\nreturn vec3(0.0, 0.0, 0.0);\n#endif\n}\n#endif\nstruct StandardSurface {\nvec4 albedo;\n#if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\nvec3 position, position_fract_part;\n#else\nvec3 position;\n#endif\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 position;\n#if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\nposition = unpackHighpData(s.position, s.position_fract_part);\n#else\nposition = s.position;\n#endif\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - position);\nfloat NV = max(abs(dot(N, V)), 0.0);\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.0);\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);\nvec3 dirlightContrib = (diffuseContrib + specularContrib);\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (NL > 0.0 && cc_mainLitDir.w > 0.0) {\n{\nvec4 pos = ApplyShadowDepthBias_FaceNormal(shadowPos, N);\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetShadowFactorSoft2X(pos);\nelse if (pcf > 0.9) shadow = CCGetShadowFactorSoft(pos);\nelse shadow = CCGetShadowFactorHard(pos);\nshadow = mix(shadow, 1.0, cc_shadowNFLSInfo.w);\n}\n}\n#endif\ndirlightContrib *= shadow;\nfinalColor *= dirlightContrib;\nfloat fAmb = 0.5 - N.y * 0.5;\nvec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb);\n#if CC_USE_IBL\n#if CC_USE_DIFFUSEMAP\nvec4 diffuseMap = texture(cc_diffuseMap, N);\n#if CC_USE_DIFFUSEMAP == 2\nambDiff = unpackRGBE(diffuseMap);\n#else\nambDiff = SRGBToLinear(diffuseMap.rgb);\n#endif\n#endif\nvec3 R = normalize(reflect(-V, N));\n#if USE_REFLECTION_DENOISE\nvec3 env = GetEnvReflectionWithMipFiltering(R, s.roughness, cc_ambientGround.w, 0.6);\n#else\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\n#endif\nfinalColor += env * cc_ambientSky.w * specular * s.occlusion;\n#endif\nfinalColor += ambDiff.rgb * cc_ambientSky.w * diffuse * s.occlusion;\nfinalColor += s.emissive;\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\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\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};\n#endif\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}\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 0\nvec4 CCStandardShadingAdditive (StandardSurface s, vec4 shadowPos) {\nvec3 position;\n#if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\nposition = unpackHighpData(s.position, s.position_fract_part);\n#else\nposition = s.position;\n#endif\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 - position);\nfloat NV = max(abs(dot(N, V)), 0.0);\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 - position;\nvec3 SL = normalize(SLU);\nvec3 SH = normalize(SL + V);\nfloat SNL = max(dot(N, SL), 0.0);\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;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (cc_lightPos[i].w > 0.0 && cc_lightSizeRangeAngle[i].w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\n#endif\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1\nlayout(std430, binding = 4) readonly buffer b_ccLightsBuffer { vec4 b_ccLights[]; };\nlayout(std430, binding = 5) readonly buffer b_clusterLightIndicesBuffer { uint b_clusterLightIndices[]; };\nlayout(std430, binding = 6) readonly buffer b_clusterLightGridBuffer { uvec4 b_clusterLightGrid[]; };\nstruct CCLight\n{\nvec4 cc_lightPos;\nvec4 cc_lightColor;\nvec4 cc_lightSizeRangeAngle;\nvec4 cc_lightDir;\n};\nstruct Cluster\n{\nvec3 minBounds;\nvec3 maxBounds;\n};\nstruct LightGrid\n{\nuint offset;\nuint ccLights;\n};\nCCLight getCCLight(uint i)\n{\nCCLight light;\nlight.cc_lightPos = b_ccLights[4u * i + 0u];\nlight.cc_lightColor = b_ccLights[4u * i + 1u];\nlight.cc_lightSizeRangeAngle = b_ccLights[4u * i + 2u];\nlight.cc_lightDir = b_ccLights[4u * i + 3u];\nreturn light;\n}\nLightGrid getLightGrid(uint cluster)\n{\nuvec4 gridvec = b_clusterLightGrid[cluster];\nLightGrid grid;\ngrid.offset = gridvec.x;\ngrid.ccLights = gridvec.y;\nreturn grid;\n}\nuint getGridLightIndex(uint start, uint offset)\n{\nreturn b_clusterLightIndices[start + offset];\n}\nuint getClusterZIndex(vec4 worldPos)\n{\nfloat scale = float(24) / log(cc_nearFar.y / cc_nearFar.x);\nfloat bias = -(float(24) * log(cc_nearFar.x) / log(cc_nearFar.y / cc_nearFar.x));\nfloat eyeDepth = -(cc_matView * worldPos).z;\nuint zIndex = uint(max(log(eyeDepth) * scale + bias, 0.0));\nreturn zIndex;\n}\nuint getClusterIndex(vec4 fragCoord, vec4 worldPos)\n{\nuint zIndex = getClusterZIndex(worldPos);\nfloat clusterSizeX = ceil(cc_viewPort.z / float(16));\nfloat clusterSizeY = ceil(cc_viewPort.w / float(8));\nuvec3 indices = uvec3(uvec2(fragCoord.xy / vec2(clusterSizeX, clusterSizeY)), zIndex);\nuint cluster = (16u * 8u) * indices.z + 16u * indices.y + indices.x;\nreturn cluster;\n}\nvec4 CCClusterShadingAdditive (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 position;\n#if CC_PLATFORM_ANDROID_AND_WEBGL && CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES\nposition = unpackHighpData(s.position, s.position_fract_part);\n#else\nposition = s.position;\n#endif\nvec3 N = normalize(s.normal);\nvec3 V = normalize(cc_cameraPos.xyz - position);\nfloat NV = max(abs(dot(N, V)), 0.001);\nspecular = BRDFApprox(specular, s.roughness, NV);\nvec3 finalColor = vec3(0.0);\nuint cluster = getClusterIndex(gl_FragCoord, vec4(position, 1.0));\nLightGrid grid = getLightGrid(cluster);\nuint numLights = grid.ccLights;\nfor (uint i = 0u; i < 100u; i++) {\nif (i >= numLights) break;\nuint lightIndex = getGridLightIndex(grid.offset, i);\nCCLight light = getCCLight(lightIndex);\nvec3 SLU = light.cc_lightPos.xyz - 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 = light.cc_lightSizeRangeAngle.x;\nfloat litRadiusSqr = litRadius * litRadius;\nfloat illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\nfloat attRadiusSqrInv = 1.0 / max(light.cc_lightSizeRangeAngle.y, 0.01);\nattRadiusSqrInv *= attRadiusSqrInv;\nfloat att = GetDistAtt(distSqr, attRadiusSqrInv);\nvec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\nif (light.cc_lightPos.w > 0.0) {\nfloat cosInner = max(dot(-light.cc_lightDir.xyz, SL), 0.01);\nfloat cosOuter = light.cc_lightSizeRangeAngle.z;\nfloat litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\nfloat litAngleOffset = -cosOuter * litAngleScale;\natt *= GetAngleAtt(SL, -light.cc_lightDir.xyz, litAngleScale, litAngleOffset);\n}\nvec3 lightColor = light.cc_lightColor.rgb;\nfloat shadow = 1.0;\n#if CC_RECEIVE_SHADOW\nif (light.cc_lightPos.w > 0.0) {\n{\nfloat pcf = cc_shadowWHPBInfo.z;\nif (pcf > 1.9) shadow = CCGetSpotLightShadowFactorSoft2X(shadowPos, position);\nelse if (pcf > 0.9) shadow = CCGetSpotLightShadowFactorSoft(shadowPos, position);\nelse shadow = CCGetSpotLightShadowFactorHard(shadowPos, position);\n}\n}\n#endif\nlightColor *= shadow;\nfinalColor += SNL * lightColor * light.cc_lightColor.w * illum * att * (diffuseContrib + lspec);\n}\nreturn vec4(finalColor, 0.0);\n}\n#endif\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 = ACESToneMap(color.rgb);\n#endif\ncolor.rgb = sqrt(color.rgb);\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 fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / fogAtten * 4.;\nfloat f = exp(-cam_dis * fogDensity);\nreturn f;\n}\nfloat ExpSquaredFog(vec4 pos) {\nvec4 wPos = pos;\nfloat fogAtten = cc_fogAdd.z;\nfloat fogStart = cc_fogBase.x;\nfloat fogDensity = cc_fogBase.z;\nfloat cam_dis = max(distance(cc_cameraPos, wPos) - fogStart, 0.0) / 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}\nvoid CC_TRANSFER_FOG_BASE(vec4 pos, out float factor)\n{\n#if CC_USE_FOG == 0\nfactor = LinearFog(pos);\n#elif CC_USE_FOG == 1\nfactor = ExpFog(pos);\n#elif CC_USE_FOG == 2\nfactor = ExpSquaredFog(pos);\n#elif CC_USE_FOG == 3\nfactor = LayeredFog(pos);\n#else\nfactor = 1.0;\n#endif\n}\nvoid CC_APPLY_FOG_BASE(inout vec4 color, float factor) {\ncolor = vec4(mix(cc_fogColor.rgb, color.rgb, factor), color.a);\n}\nvec2 signNotZero(vec2 v) {\nreturn vec2((v.x >= 0.0) ? +1.0 : -1.0, (v.y >= 0.0) ? +1.0 : -1.0);\n}\nvec3 oct_to_float32x3(vec2 e) {\nvec3 v = vec3(e.xy, 1.0 - abs(e.x) - abs(e.y));\nif (v.z < 0.0) v.xy = (1.0 - abs(v.yx)) * signNotZero(v.xy);\nreturn normalize(v);\n}\nvec4 screen2WS(vec3 coord) {\nvec3 ndc = vec3(\n2.0 * (coord.x - cc_viewPort.x) / cc_viewPort.z - 1.0,\n2.0 * (coord.y - cc_viewPort.y) / cc_viewPort.w - 1.0,\n2.0 * coord.z - 1.0);\nvec4 world = ((cc_matViewProjInv) * (vec4(ndc, 1.0)));\nworld = world / world.w;\nreturn world;\n}\nin vec2 v_uv;\n#if CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT\nlayout(location = 0) inout vec4 gbuffer_albedoMap;\nlayout(location = 1) inout vec4 gbuffer_normalMap;\nlayout(location = 2) inout vec4 gbuffer_emissiveMap;\n#else\nuniform sampler2D gbuffer_albedoMap;\nuniform sampler2D gbuffer_normalMap;\nuniform sampler2D gbuffer_emissiveMap;\n#endif\nuniform sampler2D depth_stencil;\n#if !CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT || __VERSION__ >= 450\nlayout(location = 0) out vec4 fragColor;\n#endif\nvoid main () {\nStandardSurface s;\n#if CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT\nvec4 albedoMap = gbuffer_albedoMap;\nvec4 normalMap = gbuffer_normalMap;\nvec4 emissiveMap = gbuffer_emissiveMap;\n#else\nvec4 albedoMap = texture(gbuffer_albedoMap,v_uv);\nvec4 normalMap = texture(gbuffer_normalMap,v_uv);\nvec4 emissiveMap = texture(gbuffer_emissiveMap,v_uv);\n#endif\nfloat depth = texture(depth_stencil, v_uv).x;\ns.albedo = albedoMap;\nvec3 position = screen2WS(vec3(gl_FragCoord.xy, depth)).xyz;\ns.position = position;\ns.roughness = normalMap.z;\ns.normal = oct_to_float32x3(normalMap.xy);\ns.metallic = normalMap.w;\ns.emissive = emissiveMap.xyz;\ns.occlusion = emissiveMap.w;\nfloat fogFactor;\nCC_TRANSFER_FOG_BASE(vec4(position, 1), fogFactor);\nvec4 shadowPos;\nshadowPos = cc_matLightViewProj * vec4(position, 1);\nvec4 color = CCStandardShadingBase(s, shadowPos) +\n#if CC_ENABLE_CLUSTERED_LIGHT_CULLING == 1\nCCClusterShadingAdditive(s, shadowPos);\n#else\nCCStandardShadingAdditive(s, shadowPos);\n#endif\nCC_APPLY_FOG_BASE(color, fogFactor);\ncolor = CCFragOutput(color);\n#if CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT\ngbuffer_emissiveMap = color;\n#else\nfragColor = color;\n#endif\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\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;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nmediump vec4 cc_shadowNFLSInfo;\nmediump vec4 cc_shadowWHPBInfo;\nmediump vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\nmediump vec4 cc_planarNDInfo;\n};\nout float v_dist;\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\nvec3 P = (matWorld * position).xyz;\nvec3 L = cc_mainLitDir.xyz;\nvec3 N = cc_planarNDInfo.xyz;\nfloat d = cc_planarNDInfo.w + 0.001;\nfloat dist = (-d - dot(P, N)) / (dot(L, N) + 0.0001);\nvec3 shadowPos = P + L * dist;\nvec3 view = normalize(cc_cameraPos.xyz - shadowPos);\nfloat viewLength = length(cc_cameraPos.xyz - shadowPos);\nshadowPos += view * min(1.0, 0.005 * viewLength);\nposition = cc_matProj * cc_matView * vec4(shadowPos, 1.0);\nv_dist = dist;\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;\nhighp vec4 cc_shadowInvProjDepthInfo;\nhighp vec4 cc_shadowProjDepthInfo;\nhighp vec4 cc_shadowProjInfo;\nmediump vec4 cc_shadowNFLSInfo;\nmediump vec4 cc_shadowWHPBInfo;\nmediump vec4 cc_shadowLPNNInfo;\nlowp vec4 cc_shadowColor;\nmediump vec4 cc_planarNDInfo;\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nvec4 CCFragOutput (vec4 color) {\nreturn color;\n}\nin float v_dist;\nvec4 frag () {\nif(v_dist < 0.0)\ndiscard;\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\n#if ANTIALIAS_TYPE == 1\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}\n#endif\nin vec2 v_uv;\nuniform sampler2D outputResultMap;\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}\nvoid main () {\nmediump vec2 v_rgbNW;\nmediump vec2 v_rgbNE;\nmediump vec2 v_rgbSW;\nmediump vec2 v_rgbSE;\nmediump vec2 v_rgbM;\n#if ANTIALIAS_TYPE == 1\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(outputResultMap, fragCoord, resolution, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n#else\nfragColor = texture(outputResultMap, v_uv);\n#endif\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\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));\nvec4 pos = matViewRotOnly * viewDir;\nif (cc_matProj[3].w > 0.0) {\nmat4 matProj = cc_matProj;\nmatProj[0].x = 5.2;\nmatProj[1].y = 2.6;\nmatProj[2].zw = vec2(-1.0);\nmatProj[3].zw = vec2(0.0);\npos = matProj * pos;\n} else {\npos = cc_matProj * pos;\n}\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nuniform samplerCube cc_environment;\nvec3 unpackRGBE (vec4 rgbe) {\nreturn rgbe.rgb * pow(1.1, 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 = ACESToneMap(color.rgb);\n#endif\ncolor.rgb = sqrt(color.rgb);\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\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 () {\nmat2 proj = mat2(cc_matProj[0].xy, cc_matProj[1].xy);\nproj /= abs(proj[1].x + proj[1].y);\nvec2 position = proj * a_position.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 vec4(position, 0.0, 1.0);\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;\nmediump vec4 cc_nearFar;\nmediump vec4 cc_viewPort;\n};\nvec4 CCFragOutput (vec4 color) {\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;\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;\nreturn screenPos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision mediump float;\nin vec2 v_uv;\nlayout(std140) uniform Factor {\nfloat u_percent;\n};\nuniform sampler2D mainTexture;\nvec4 frag () {\nvec4 color = texture(mainTexture, v_uv);\nfloat percent = clamp(u_percent, 0.0, 1.0);\ncolor.xyz *= percent;\nreturn color;\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}]]},bg=function(){function e(){this._device=null,this._resources={}}var t=e.prototype;return t.initBuiltinRes=function(e){var t=this;this._device=e;for(var n=this._resources,i=new Uint8Array(16),r=new Uint8Array(16),o=new Uint8Array(16),a=new Uint8Array(16),s=new Uint8Array(16),l=0,u=0;u<4;u++)i[l]=0,i[l+1]=0,i[l+2]=0,i[l+3]=255,r[l]=0,r[l+1]=0,r[l+2]=0,r[l+3]=0,o[l]=119,o[l+1]=119,o[l+2]=119,o[l+3]=255,a[l]=255,a[l+1]=255,a[l+2]=255,a[l+3]=255,s[l]=127,s[l+1]=127,s[l+2]=255,s[l+3]=255,l+=4;var h=new Uint8Array(1024);l=0;for(var f=0;f<256;f++)h[l]=221,h[l+1]=221,h[l+2]=221,h[l+3]=255,l+=4;l=0;for(var _=0;_<8;_++){for(var p=0;p<8;p++)h[l]=85,h[l+1]=85,h[l+2]=85,h[l+3]=255,l+=4;l+=32}l+=32;for(var d=0;d<8;d++){for(var m=0;m<8;m++)h[l]=85,h[l+1]=85,h[l+2]=85,h[l+3]=255,l+=4;l+=32}var g={width:2,height:2,_data:i,_compressed:!1,format:vg.PixelFormat.RGBA8888},v={width:2,height:2,_data:r,_compressed:!1,format:vg.PixelFormat.RGBA8888},y={width:2,height:2,_data:o,_compressed:!1,format:vg.PixelFormat.RGBA8888},x={width:2,height:2,_data:a,_compressed:!1,format:vg.PixelFormat.RGBA8888},S={width:2,height:2,_data:s,_compressed:!1,format:vg.PixelFormat.RGBA8888},T={width:16,height:16,_data:h,_compressed:!1,format:vg.PixelFormat.RGBA8888},E=new Km(g),A=new vg;A._uuid="black-texture",A.image=E,n[A._uuid]=A;var C=new Km(v),b=new vg;b._uuid="empty-texture",b.image=C,n[b._uuid]=b;var w=new yg;w._uuid="black-cube-texture",w.setMipFilter(yg.Filter.NEAREST),w.image={front:new Km(g),back:new Km(g),left:new Km(g),right:new Km(g),top:new Km(g),bottom:new Km(g)},n[w._uuid]=w;var R=new Km(y),P=new vg;P._uuid="grey-texture",P.image=R,n[P._uuid]=P;var I=new Km(x),D=new vg;D._uuid="white-texture",D.image=I,n[D._uuid]=D;var O=new yg;O._uuid="white-cube-texture",O.setMipFilter(yg.Filter.NEAREST),O.image={front:new Km(x),back:new Km(x),left:new Km(x),right:new Km(x),top:new Km(x),bottom:new Km(x)},n[O._uuid]=O;var M=new Km(S),N=new vg;N._uuid="normal-texture",N.image=M,n[N._uuid]=N;var L=new Km(T),F=new vg;F._uuid="default-texture",F.image=L,n[F._uuid]=F;var B=new yg;if(B.setMipFilter(yg.Filter.NEAREST),B._uuid="default-cube-texture",B.image={front:new Km(T),back:new Km(T),left:new Km(T),right:new Km(T),top:new Km(T),bottom:new Km(T)},n[B._uuid]=B,c.SpriteFrame){var z=new c.SpriteFrame,k=E,U=new vg;U.image=k,z.texture=U,z._uuid="default-spriteframe",n[z._uuid]=z}var G=dm(e);if(!G)return Promise.reject(Error("Failed to initialize builtin shaders: unknown device."));var H=Cg[G];return H?Promise.resolve().then((function(){Ag.forEach((function(e,t){var n=Object.assign(new c.EffectAsset,e);n.shaders.forEach((function(e,n){var i=H[t][n];i&&(e[G]=i)})),n.hideInEditor=!0,n.onLoaded()})),t._initMaterials()})):Promise.reject(Error("Current device is requiring builtin shaders of version "+G+" 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 r=new c.Material;r._uuid="missing-material",r.initialize({effectName:"unlit",defines:{USE_COLOR:!0}}),r.setProperty("mainColor",c.color("#ff00ff")),e[r._uuid]=r,t.push(r);var o=new c.Material;o._uuid="default-clear-stencil",o.initialize({defines:{USE_TEXTURE:!1},effectName:"clear-stencil"}),e[o._uuid]=o,t.push(o);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 f=new c.Material;f._uuid="ui-sprite-gray-alpha-sep-material",f.initialize({defines:{USE_TEXTURE:!0,CC_USE_EMBEDDED_ALPHA:!0,IS_GRAY:!0},effectName:"sprite"}),e[f._uuid]=f,t.push(f);var _=new c.Material;_._uuid="ui-graphics-material",_.initialize({effectName:"graphics"}),e[_._uuid]=_,t.push(_);var p=new c.Material;p._uuid="default-particle-material",p.initialize({effectName:"particle"}),e[p._uuid]=p,t.push(p);var d=new c.Material;d._uuid="default-particle-gpu-material",d.initialize({effectName:"particle-gpu"}),e[d._uuid]=d,t.push(d);var m=new c.Material;m._uuid="default-trail-material",m.initialize({effectName:"particle-trail"}),e[m._uuid]=m,t.push(m);var g=new c.Material;g._uuid="default-billboard-material",g.initialize({effectName:"billboard"}),e[g._uuid]=g,t.push(g);var v=new c.Material;v._uuid="default-spine-material",v.initialize({defines:{USE_TEXTURE:!0,CC_USE_EMBEDDED_ALPHA:!1,IS_GRAY:!1},effectName:"spine"}),e[v._uuid]=v,t.push(v),c.game.on(c.Game.EVENT_GAME_INITED,(function(){for(var e=0;e=1024)&&u.lightingMap===a&&u.stride===r){if(u.count>=u.capacity){u.capacity<<=1;var h=u.stride*u.capacity,f=u.data;u.data=new Uint8Array(h),u.data.set(f),u.vb.resize(h)}return u.shader!==s&&(u.shader=s),u.descriptorSet!==c&&(u.descriptorSet=c),u.data.set(t.buffer,u.stride*u.count++),void(this.hasPendingModels=!0)}}for(var _=this._device.createBuffer(new lr(_i.VERTEX|_i.TRANSFER_DST,mi.HOST|mi.DEVICE,32*r,r)),p=new Uint8Array(32*r),d=o.vertexBuffers.slice(),m=o.attributes.slice(),g=o.indexBuffer,v=0;vm.size&&(m.resize(r),f.vbDatas[p]=new Uint8Array(r),f.vbDatas[p].set(g)),f.vbDatas[p].set(d.buffer,f.vbCount*d.stride)}var v=f.vbIdxData;(o=4*(a+f.vbCount))>f.vbIdx.size&&(f.vbIdx.resize(o),f.vbIdxData=new Float32Array(o/Float32Array.BYTES_PER_ELEMENT),f.vbIdxData.set(v),v=f.vbIdxData);var y=f.vbCount,x=y+a,S=f.mergeCount;if(v[y]!==S||v[x-1]!==S)for(var T=y;T>2,a=this._getBlockView(r,i),s=e.getOffsetFromHandle(t),c=0;c>2)*a,h=0;h+l.length<=u;h+=l.length)s.set(l,o+h);this._setRootBufferDirty(!0)}},t.resetTexture=function(t,n){var i=this.getHandle(t);if(i){var r=e.getTypeFromHandle(i),o=e.getBindingFromHandle(i),a=this._properties[t],s=a&&a.value,c=s?s+"-texture":sm(r),l=wg.get(c),u=l&&l.getGFXTexture(),h=a&&void 0!==a.samplerHash?Ro.unpackFromHash(a.samplerHash):l&&l.getSamplerInfo(),f=this._device.getSampler(h);this._descriptorSet.bindSampler(o,f,n),this._descriptorSet.bindTexture(o,u,n)}},t.resetUBOs=function(){for(var e=0;e>2)*r.count,l=0;l+s.length<=c;l+=s.length)o.set(s,n+l);n+=c}this._setRootBufferDirty(!0)},t.resetTextures=function(){for(var e=0;e=this._passes.length)return void console.warn("illegal pass index: "+n+".");var c=this._passes[n];this._uploadProperty(c,e,t)&&(this._props[c.propertyIndex][e]=t,i=!0)}i||console.warn("illegal property name: "+e+".")},n.getProperty=function(e,t){if(void 0===t)for(var n=this._props,i=n.length,r=0;r=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,t){this._techIdx=e._techIdx,this._props.length=e._props.length;for(var n=0;n0},K(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}(Ru),Vg=se((Hg=Yg).prototype,"_effectAsset",[Ug],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),jg=se(Hg.prototype,"_techIdx",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Wg=se(Hg.prototype,"_defines",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),qg=se(Hg.prototype,"_states",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Xg=se(Hg.prototype,"_props",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Gg=Hg))||Gg));c.Material=iv,function(e){e[e.VERTICAL=0]="VERTICAL",e[e.HORIZONTAL=1]="HORIZONTAL"}(Zg||(Zg={})),function(e){e[e.ORTHO=0]="ORTHO",e[e.PERSPECTIVE=1]="PERSPECTIVE"}(Jg||(Jg={})),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"}($g||($g={})),function(e){e[e.ISO100=0]="ISO100",e[e.ISO200=1]="ISO200",e[e.ISO400=2]="ISO400",e[e.ISO800=3]="ISO800"}(ev||(ev={})),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"}(tv||(tv={}));var rv=[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],ov=[1,.5,1/4,1/8,1/15,1/30,1/60,.008,.004,.002,.001,5e-4,1/4e3],av=[100,200,400,800],sv=new bn,cv=new bn,lv=new Gn,uv=Wi.STENCIL<<1,hv=[],fv=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=Zg.VERTICAL,this._fov=cn(45),this._nearClip=1,this._farClip=1e3,this._clearColor=new or(.2,.2,.2,1),this._viewport=new ei(0,0,1,1),this._orientedViewport=new ei(0,0,1,1),this._curTransform=ci.IDENTITY,this._isProjDirty=!0,this._matView=new Gn,this._matProj=new Gn,this._matProjInv=new Gn,this._matViewProj=new Gn,this._matViewProjInv=new Gn,this._frustum=new ec,this._forward=new bn,this._position=new bn,this._priority=0,this._aperture=$g.F16_0,this._apertureValue=void 0,this._shutter=tv.D125,this._shutterValue=0,this._iso=ev.ISO100,this._isoValue=0,this._ec=0,this._window=null,this._width=1,this._height=1,this._clearFlag=Wi.NONE,this._clearDepth=1,this._visibility=Wd,this._exposure=0,this._clearStencil=0,this._device=e,this._apertureValue=rv[this._aperture],this._shutterValue=ov[this._shutter],this._isoValue=av[this._iso],this._aspect=this.screenScale=1,this._frustum.accurate=!0,!hv.length){var t=e.capabilities.clipSpaceSignY;hv[ci.IDENTITY]=new Gn(1,0,0,0,0,t),hv[ci.ROTATE_90]=new Gn(0,1,0,0,-t,0),hv[ci.ROTATE_180]=new Gn(-1,0,0,0,0,-t),hv[ci.ROTATE_270]=new Gn(0,-1,0,0,t,0)}}var t=e.prototype;return t._setWidth=function(e){this._width=e},t._setHeight=function(e){this._height=e},t._setScene=function(e){this._scene=e},t._updateAspect=function(e){if(void 0===e&&(e=!0),this._aspect=this.window.width*this._viewport.width/(this.window.height*this._viewport.height),e){var t=this.window.swapchain;(t&&t.surfaceTransform||ci.IDENTITY)%2&&(this._aspect=1/this._aspect)}this._isProjDirty=!0},t._init=function(){},t.initialize=function(e){this._init(e),this.node=e.node,this._setWidth(1),this._setHeight(1),this.clearFlag=Wi.NONE,this.clearDepth=1,this.visibility=Wd,this._name=e.name,this._proj=e.projection,this._priority=e.priority||0,this._aspect=this.screenScale=1,this.updateExposure(),this.changeTargetWindow(e.window)},t._destroy=function(){},t.destroy=function(){this._window&&(this._window.detachCamera(this),this.window=null),this._name=null,this._destroy()},t.attachToScene=function(e){this._enabled=!0,this._setScene(e)},t.detachFromScene=function(){this._enabled=!1,this._setScene(null)},t.resize=function(e,t){this._window&&(this._setWidth(e),this._setHeight(t),this._updateAspect())},t.setFixedSize=function(e,t){this._setWidth(e),this._setHeight(t),this._updateAspect(!1),this.isWindowSize=!1},t.syncCameraEditor=function(){},t.update=function(e){var t;if(void 0===e&&(e=!1),this._node){var n=!1;(this._node.hasChangedFlags||e)&&(Gn.invert(this._matView,this._node.worldMatrix),this._forward.x=-this._matView.m02,this._forward.y=-this._matView.m06,this._forward.z=-this._matView.m10,this._node.getWorldPosition(this._position),n=!0);var i=null===(t=this.window)||void 0===t?void 0:t.swapchain,r=i&&i.surfaceTransform||ci.IDENTITY;if(this._isProjDirty||this._curTransform!==r){this._curTransform=r;var o=this._device.capabilities.clipSpaceSignY;if(this._proj===Jg.PERSPECTIVE)Gn.perspective(this._matProj,this._fov,this._aspect,this._nearClip,this._farClip,this._fovAxis===Zg.VERTICAL,this._device.capabilities.clipSpaceMinZ,o,r);else{var a=this._orthoHeight*this._aspect,s=this._orthoHeight;Gn.ortho(this._matProj,-a,a,-s,s,this._nearClip,this._farClip,this._device.capabilities.clipSpaceMinZ,o,r)}Gn.invert(this._matProjInv,this._matProj),n=!0,this._isProjDirty=!1}n&&(Gn.multiply(this._matViewProj,this._matProj,this._matView),Gn.invert(this._matViewProjInv,this._matViewProj),this._frustum.update(this._matViewProj,this._matViewProjInv))}},t.setViewportInOrientedSpace=function(e){var t,n=e.x,i=e.width,r=e.height,o=this._device.capabilities.screenSpaceSignY<0?1-e.y-r:e.y,a=null===(t=this.window)||void 0===t?void 0:t.swapchain;switch(a&&a.surfaceTransform||ci.IDENTITY){case ci.ROTATE_90:this._viewport.x=1-o-r,this._viewport.y=n,this._viewport.width=r,this._viewport.height=i;break;case ci.ROTATE_180:this._viewport.x=1-n-i,this._viewport.y=1-o-r,this._viewport.width=i,this._viewport.height=r;break;case ci.ROTATE_270:this._viewport.x=o,this._viewport.y=1-n-i,this._viewport.width=r,this._viewport.height=i;break;case ci.IDENTITY:this._viewport.x=n,this._viewport.y=o,this._viewport.width=i,this._viewport.height=r}this._orientedViewport.x=n,this._orientedViewport.y=o,this._orientedViewport.width=i,this._orientedViewport.height=r,this.resize(this.width,this.height)},t.changeTargetWindow=function(e){void 0===e&&(e=null),this._window&&this._window.detachCamera(this);var t=e||c.director.root.mainWindow;if(t){t.attachCamera(this),this.window=t;var n=t.swapchain;(n&&n.surfaceTransform||ci.IDENTITY)%2?this.resize(t.height,t.width):this.resize(t.width,t.height)}},t.detachCamera=function(){this._window&&this._window.detachCamera(this)},t.screenPointToRay=function(e,t,n){if(!this._node)return null;var i=this.width,r=this.height,o=this._orientedViewport.x*i,a=this._orientedViewport.y*r,s=this._orientedViewport.width*i,c=this._orientedViewport.height*r,l=this._proj===Jg.PERSPECTIVE,u=this._device.capabilities.clipSpaceSignY,h=Un[this._curTransform];bn.set(sv,(t-o)/s*2-1,(n-a)/c*2-1,l?1:-1);var f=sv.x,_=sv.y;return sv.x=f*h[0]+_*h[2]*u,sv.y=f*h[1]+_*h[3]*u,bn.transformMat4(l?sv:e.o,sv,this._matViewProjInv),l?(this._node.getWorldPosition(cv),Zo.fromPoints(e,cv,sv)):bn.transformQuat(e.d,bn.FORWARD,this._node.worldRotation),e},t.screenToWorld=function(e,t){var n=this.width,i=this.height,r=this._orientedViewport.x*n,o=this._orientedViewport.y*i,a=this._orientedViewport.width*n,s=this._orientedViewport.height*i,c=this._device.capabilities.clipSpaceSignY,l=Un[this._curTransform];if(this._proj===Jg.PERSPECTIVE){bn.set(e,(t.x-r)/a*2-1,(t.y-o)/s*2-1,1);var u=e.x,h=e.y;e.x=u*l[0]+h*l[2]*c,e.y=u*l[1]+h*l[3]*c,bn.transformMat4(e,e,this._matViewProjInv),this._node&&this._node.getWorldPosition(sv),bn.lerp(e,sv,e,sn(this._nearClip/this._farClip,1,t.z))}else{bn.set(e,(t.x-r)/a*2-1,(t.y-o)/s*2-1,2*t.z-1);var f=e.x,_=e.y;e.x=f*l[0]+_*l[2]*c,e.y=f*l[1]+_*l[3]*c,bn.transformMat4(e,e,this._matViewProjInv)}return e},t.worldToScreen=function(e,t){var n=this._device.capabilities.clipSpaceSignY,i=Un[this._curTransform];bn.transformMat4(e,t,this._matViewProj);var r=e.x,o=e.y;e.x=r*i[0]+o*i[2]*n,e.y=r*i[1]+o*i[3]*n;var a=this.width,s=this.height,c=this._orientedViewport.x*a,l=this._orientedViewport.y*s,u=this._orientedViewport.width*a,h=this._orientedViewport.height*s;return e.x=c+.5*(e.x+1)*u,e.y=l+.5*(e.y+1)*h,e.z=.5*e.z+.5,e},t.worldMatrixToScreen=function(e,t,n,i){Gn.multiply(e,this._matViewProj,t),Gn.multiply(e,hv[this._curTransform],e);var r=n/2,o=i/2;return Gn.identity(lv),Gn.transform(lv,lv,bn.set(sv,r,o,0)),Gn.scale(lv,lv,bn.set(sv,r,o,1)),Gn.multiply(e,lv,e),e},t.setExposure=function(e){this._exposure=.833333/Math.pow(2,e)},t.updateExposure=function(){var e=Math.log2(this._apertureValue*this._apertureValue/this._shutterValue*100/this._isoValue);this.setExposure(e)},K(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}},{key:"viewport",get:function(){return this._viewport},set:function(e){P(8302),this.setViewportInOrientedSpace(e)}},{key:"scene",get:function(){return this._scene}},{key:"name",get:function(){return this._name}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"aspect",get:function(){return this._aspect}},{key:"matView",get:function(){return this._matView}},{key:"matProj",get:function(){return this._matProj}},{key:"matProjInv",get:function(){return this._matProjInv}},{key:"matViewProj",get:function(){return this._matViewProj}},{key:"matViewProjInv",get:function(){return this._matViewProjInv}},{key:"frustum",get:function(){return this._frustum},set:function(e){this._frustum=e}},{key:"window",get:function(){return this._window},set:function(e){this._window=e}},{key:"forward",get:function(){return this._forward},set:function(e){this._forward=e}},{key:"position",get:function(){return this._position},set:function(e){this._position=e}},{key:"visibility",get:function(){return this._visibility},set:function(e){this._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=rv[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=ov[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=av[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 this._exposure}},{key:"clearFlag",get:function(){return this._clearFlag},set:function(e){this._clearFlag=e}},{key:"clearDepth",get:function(){return this._clearDepth},set:function(e){this._clearDepth=e}},{key:"clearStencil",get:function(){return this._clearStencil},set:function(e){this._clearStencil=e}},{key:"native",get:function(){return this._nativeObj}}],[{key:"standardExposureValue",get:function(){return 1/38400}},{key:"standardLightMeterScale",get:function(){return 1e4}}]),e}(),_v=it({Low_256x256:256,Medium_512x512:512,High_1024x1024:1024,Ultra_2048x2048:2048}),pv=it({Planar:0,ShadowMap:1}),dv=it({HARD:0,SOFT:1,SOFT_2X:2}),mv=pv.ShadowMap+1,gv=function(){function e(){this.fixedSphere=new ra(0,0,0,.01),this.maxReceived=4,this.firstSetCSM=!1,this.shadowCameraFar=0,this.matShadowView=new Gn,this.matShadowProj=new Gn,this.matShadowViewProj=new Gn,this._normal=new bn(0,1,0),this._shadowColor=new An(0,0,0,76),this._matLight=new Gn,this._material=null,this._instancingMaterial=null,this._size=new Wn(512,512),this._enabled=!1,this._distance=0,this._type=mv,this._near=.1,this._far=10,this._invisibleOcclusionRange=200,this._shadowDistance=100,this._orthoSize=1,this._pcf=0,this._shadowMapDirty=!1,this._bias=0,this._normalBias=0,this._fixedArea=!1,this._saturation=.75}var t=e.prototype;return t.getPlanarShader=function(e){return this._material||(this._material=new iv,this._material.initialize({effectName:"planar-shadow"})),this._material.passes[0].getShaderVariant(e)},t.getPlanarInstanceShader=function(e){return this._instancingMaterial||(this._instancingMaterial=new iv,this._instancingMaterial.initialize({effectName:"planar-shadow",defines:{USE_INSTANCING:!0}})),this._instancingMaterial.passes[0].getShaderVariant(e)},t._setEnable=function(e){this._enabled=e},t._setType=function(e){this._type=this.enabled?e:mv},t.initialize=function(e){this.near=e.near,this.far=e.far,this.invisibleOcclusionRange=e.invisibleOcclusionRange,this.shadowDistance=e.shadowDistance,this.orthoSize=e.orthoSize,this.size=e.size,this.pcf=e.pcf,this.normal=e.normal,this.distance=e.distance,this.shadowColor=e.shadowColor,this.bias=e.bias,this.normalBias=e.normalBias,this.maxReceived=e.maxReceived,this.fixedArea=e.fixedArea,this._setEnable(e.enabled),this._setType(e.type),this.saturation=e.saturation},t.activate=function(){this.enabled&&this.type===pv.Planar&&this._updatePlanarInfo()},t._updatePlanarInfo=function(){this._material||(this._material=new iv,this._material.initialize({effectName:"planar-shadow"})),this._instancingMaterial||(this._instancingMaterial=new iv,this._instancingMaterial.initialize({effectName:"planar-shadow",defines:{USE_INSTANCING:!0}}))},t._destroy=function(){},t.destroy=function(){this._destroy(),this._material&&this._material.destroy(),this._instancingMaterial&&this._instancingMaterial.destroy(),this.fixedSphere.destroy()},K(e,[{key:"enabled",get:function(){return this._enabled},set:function(e){this._setEnable(e),this.activate()}},{key:"normal",get:function(){return this._normal},set:function(e){bn.copy(this._normal,e)}},{key:"distance",get:function(){return this._distance},set:function(e){this._distance=e}},{key:"shadowColor",get:function(){return this._shadowColor},set:function(e){this._shadowColor=e}},{key:"invisibleOcclusionRange",get:function(){return this._invisibleOcclusionRange},set:function(e){this._invisibleOcclusionRange=e}},{key:"shadowDistance",get:function(){return this._shadowDistance},set:function(e){this._shadowDistance=e}},{key:"type",get:function(){return this._type},set:function(e){this._setType(e),this.activate()}},{key:"near",get:function(){return this._near},set:function(e){this._near=e}},{key:"far",get:function(){return this._far},set:function(e){this._far=e}},{key:"orthoSize",get:function(){return this._orthoSize},set:function(e){this._orthoSize=e}},{key:"size",get:function(){return this._size},set:function(e){this._size.set(e)}},{key:"pcf",get:function(){return this._pcf},set:function(e){this._pcf=e}},{key:"shadowMapDirty",get:function(){return this._shadowMapDirty},set:function(e){this._shadowMapDirty=e}},{key:"bias",get:function(){return this._bias},set:function(e){this._bias=e}},{key:"normalBias",get:function(){return this._normalBias},set:function(e){this._normalBias=e}},{key:"saturation",get:function(){return this._saturation},set:function(e){this._saturation=e}},{key:"fixedArea",get:function(){return this._fixedArea},set:function(e){this._fixedArea=e}},{key:"matLight",get:function(){return this._matLight}},{key:"material",get:function(){return this._material}},{key:"instancingMaterial",get:function(){return this._instancingMaterial}},{key:"native",get:function(){return this._nativeObj}}]),e}();gv.MAX_FAR=2e3,gv.COEFFICIENT_OF_EXPANSION=2*Math.sqrt(3),c.Shadows=gv;var vv=new bn,yv=(new bn,new bn,new bn),xv=new Gn,Sv=new Hs,Tv=new Hs,Ev=!1,Av=ra.create(0,0,0,1),Cv=new ra,bv=new ec;bv.accurate=!0;var wv=new ec;wv.accurate=!0;var Rv=new ec,Pv=new Gn,Iv=new Gn,Dv=new Gn,Ov=new Gn,Mv=new Gn,Nv=new Gn,Lv=new Gn,Fv=new bn,Bv=new Wn,zv=new bn,kv=new bn,Uv=new bn(0,0,0),Gv=(new Hs,new Ul((function(){return{model:null,depth:0}}),128)),Hv=new Ul((function(){return{model:null,depth:0}}),128),Vv=new Ul((function(){return{model:null,depth:0}}),128);function jv(e,t){var n=0;e.node&&(bn.subtract(vv,e.node.worldPosition,t.position),n=bn.dot(vv,t.forward));var i=Gv.alloc();return i.model=e,i.depth=n,i}function Wv(e,t){var n=0;e.node&&(bn.subtract(vv,e.node.worldPosition,t.position),n=bn.dot(vv,t.forward));var i=Hv.alloc();return i.model=e,i.depth=n,i}function qv(e,t){var n=0;e.node&&(bn.subtract(vv,e.node.worldPosition,t.position),n=bn.dot(vv,t.forward));var i=Vv.alloc();return i.model=e,i.depth=n,i}function Xv(e,t,n){var i=t.direction,r=e.normal,o=e.distance+.001,a=1/bn.dot(r,i),s=i.x*a,c=i.y*a,l=i.z*a,u=r.x,h=r.y,f=r.z,_=e.matLight;_.m00=1-u*s,_.m01=-u*c,_.m02=-u*l,_.m03=0,_.m04=-h*s,_.m05=1-h*c,_.m06=-h*l,_.m07=0,_.m08=-f*s,_.m09=-f*c,_.m10=1-f*l,_.m11=0,_.m12=s*o,_.m13=c*o,_.m14=l*o,_.m15=1,Gn.toArray(n,_,Yp.MAT_LIGHT_PLANE_PROJ_OFFSET)}function Yv(e,t){bn.normalize(vv,e.normal),t[Yp.PLANAR_NORMAL_DISTANCE_INFO_OFFSET+0]=vv.x,t[Yp.PLANAR_NORMAL_DISTANCE_INFO_OFFSET+1]=vv.y,t[Yp.PLANAR_NORMAL_DISTANCE_INFO_OFFSET+2]=vv.z,t[Yp.PLANAR_NORMAL_DISTANCE_INFO_OFFSET+3]=e.distance}function Kv(e,t){var n=e.pipelineSceneData.validPunctualLights;n.length=0;for(var i=t.scene.spotLights,r=0;r0){Gn.multiply(Nv,Ov,f),bn.transformMat4(Fv,yv,Nv);var g=2/h;Bv.set(g,g);var v=Fv.x%Bv.x,y=Fv.y%Bv.y;zv.set(Fv.x-v,Fv.y-y,Fv.z),Gn.invert(Lv,Nv),bn.transformMat4(kv,zv,Lv),Gn.fromRT(Pv,n.node.rotation,kv),Gn.invert(Iv,Pv),Gn.invert(Dv,Iv),ec.createOrtho(e,d,d,.1,r.shadowCameraFar,Dv)}else{for(var x=0;x<8;x++)e.vertices[x].set(0,0,0);e.updatePlanes()}Gn.multiply(Mv,Ov,Iv),r.matShadowView=Iv,r.matShadowProj=Ov,r.matShadowViewProj=Mv}}(Rv,e,i,t,o);else{for(var u=0;u<8;u++)Rv.vertices[u].set(0,0,0);Rv.updatePlanes()}i&&o.type===pv.Planar&&function(e,t){var n=e.pipelineSceneData.shadows,i=t.direction,r=n.normal,o=n.distance+.001,a=1/bn.dot(r,i),s=i.x*a,c=i.y*a,l=i.z*a,u=r.x,h=r.y,f=r.z,_=n.matLight;_.m00=1-u*s,_.m01=-u*c,_.m02=-u*l,_.m03=0,_.m04=-h*s,_.m05=1-h*c,_.m06=-h*l,_.m07=0,_.m08=-f*s,_.m09=-f*c,_.m10=1-f*l,_.m11=0,_.m12=s*o,_.m13=c*o,_.m14=l*o,_.m15=1,e.pipelineUBO.updateShadowUBORange(Yp.MAT_LIGHT_PLANE_PROJ_OFFSET,n.matLight)}(e,i),a.enabled&&a.model&&t.clearFlag&uv&&s.push(jv(a.model,t));for(var h=n.models,f=t.visibility,_=0;_15e3&&(t=15e3);var n=t*t,i=(.860117757+.000154118254*t+1.28641212e-7*n)/(1+.000842420235*t+7.08145163e-7*n),r=(.317398726+422806245e-13*t+4.20481691e-8*n)/(1-289741816e-13*t+1.61456053e-7*n),o=2*i-8*r+4,a=3*i/o,s=2*r/o,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}!function(e){e[e.LOCAL=0]="LOCAL",e[e.WORLD=1]="WORLD"}(Zv||(Zv={})),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"}(Jv||(Jv={})),c.internal.TransformBit=Jv,function(e){e[e.DIRECTIONAL=0]="DIRECTIONAL",e[e.SPHERE=1]="SPHERE",e[e.SPOT=2]="SPOT",e[e.UNKNOWN=3]="UNKNOWN"}($v||($v={}));var ry,oy,ay,sy,cy,ly,uy,hy,fy,_y,py=function(e){return 4*Math.PI*Math.PI*e*e},dy=function(){function e(){this._baked=!1,this._color=new bn(1,1,1),this._colorTemp=6550,this._colorTempRGB=new bn(1,1,1),this._scene=null,this._node=null,this._name=null,this._useColorTemperature=!1,this._type=$v.UNKNOWN}var t=e.prototype;return t._init=function(){},t._destroy=function(){},t.initialize=function(){this._init(),this.color=new bn(1,1,1),this.colorTemperature=6550},t.attachToScene=function(e){this._scene=e},t.detachFromScene=function(){this._scene=null},t.destroy=function(){this._name=null,this._node=null,this._destroy()},t.update=function(){},K(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)}},{key:"useColorTemperature",get:function(){return this._useColorTemperature},set:function(e){this._useColorTemperature=e}},{key:"colorTemperature",get:function(){return this._colorTemp},set:function(e){this._colorTemp=e,iy(this._colorTempRGB,this._colorTemp)}},{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|=Jv.ROTATION)}},{key:"type",get:function(){return this._type}},{key:"name",get:function(){return this._name},set:function(e){this._name=e}},{key:"scene",get:function(){return this._scene}},{key:"native",get:function(){return this._nativeObj}}]),e}(),my=new Gn,gy=new Gn,vy=new Gn,yy=new Kn,xy=new Kn(0,0,1,0),Sy=function(){function e(){this._globalUBO=new Float32Array(qp.COUNT),this._cameraUBO=new Float32Array(Xp.COUNT),this._shadowUBO=new Float32Array(Yp.COUNT)}e.updateGlobalUBOView=function(e,t){var n=c.director.root,i=t,r=Math.floor(e.width),o=Math.floor(e.height);i[qp.TIME_OFFSET]=n.cumulativeTime,i[qp.TIME_OFFSET+1]=n.frameTime,i[qp.TIME_OFFSET+2]=c.director.getTotalFrames(),i[qp.SCREEN_SIZE_OFFSET]=r,i[qp.SCREEN_SIZE_OFFSET+1]=o,i[qp.SCREEN_SIZE_OFFSET+2]=1/r,i[qp.SCREEN_SIZE_OFFSET+3]=1/o,i[qp.NATIVE_SIZE_OFFSET]=r,i[qp.NATIVE_SIZE_OFFSET+1]=o,i[qp.NATIVE_SIZE_OFFSET+2]=1/i[qp.NATIVE_SIZE_OFFSET],i[qp.NATIVE_SIZE_OFFSET+3]=1/i[qp.NATIVE_SIZE_OFFSET+1]},e.updateCameraUBOView=function(e,t,n){var i=(n.scene?n.scene:c.director.getScene().renderScene).mainLight,r=e.pipelineSceneData,o=r.ambient,a=r.fog,s=r.shadows,l=t,u=n.exposure,h=r.isHDR;if(l[Xp.SCREEN_SCALE_OFFSET]=r.shadingScale,l[Xp.SCREEN_SCALE_OFFSET+1]=r.shadingScale,l[Xp.SCREEN_SCALE_OFFSET+2]=1/l[Xp.SCREEN_SCALE_OFFSET],l[Xp.SCREEN_SCALE_OFFSET+3]=1/l[Xp.SCREEN_SCALE_OFFSET+1],l[Xp.EXPOSURE_OFFSET]=u,l[Xp.EXPOSURE_OFFSET+1]=1/u,l[Xp.EXPOSURE_OFFSET+2]=h?1:0,l[Xp.EXPOSURE_OFFSET+3]=0,i){var f=s.enabled&&s.type===pv.ShadowMap?1:0,_=i.direction;if(xy.set(_.x,_.y,_.z,f),Kn.toArray(l,xy,Xp.MAIN_LIT_DIR_OFFSET),bn.toArray(l,i.color,Xp.MAIN_LIT_COLOR_OFFSET),i.useColorTemperature){var p=i.colorTemperatureRGB;l[Xp.MAIN_LIT_COLOR_OFFSET]*=p.x,l[Xp.MAIN_LIT_COLOR_OFFSET+1]*=p.y,l[Xp.MAIN_LIT_COLOR_OFFSET+2]*=p.z}l[Xp.MAIN_LIT_COLOR_OFFSET+3]=h?i.illuminance*u:i.illuminance}else xy.set(0,0,1,0),Kn.toArray(l,xy,Xp.MAIN_LIT_DIR_OFFSET),Kn.toArray(l,Kn.ZERO,Xp.MAIN_LIT_COLOR_OFFSET);var d=o.skyColor;d.w=h?o.skyIllum*u:o.skyIllum,l[Xp.AMBIENT_SKY_OFFSET+0]=d.x,l[Xp.AMBIENT_SKY_OFFSET+1]=d.y,l[Xp.AMBIENT_SKY_OFFSET+2]=d.z,l[Xp.AMBIENT_SKY_OFFSET+3]=d.w,l[Xp.AMBIENT_GROUND_OFFSET+0]=o.groundAlbedo.x,l[Xp.AMBIENT_GROUND_OFFSET+1]=o.groundAlbedo.y,l[Xp.AMBIENT_GROUND_OFFSET+2]=o.groundAlbedo.z,l[Xp.AMBIENT_GROUND_OFFSET+3]=o.mipmapCount,Gn.toArray(l,n.matView,Xp.MAT_VIEW_OFFSET),Gn.toArray(l,n.node.worldMatrix,Xp.MAT_VIEW_INV_OFFSET),bn.toArray(l,n.position,Xp.CAMERA_POS_OFFSET),Gn.toArray(l,n.matProj,Xp.MAT_PROJ_OFFSET),Gn.toArray(l,n.matProjInv,Xp.MAT_PROJ_INV_OFFSET),Gn.toArray(l,n.matViewProj,Xp.MAT_VIEW_PROJ_OFFSET),Gn.toArray(l,n.matViewProjInv,Xp.MAT_VIEW_PROJ_INV_OFFSET),l[Xp.CAMERA_POS_OFFSET+3]=this.getCombineSignY();var m=a.colorArray;l[Xp.GLOBAL_FOG_COLOR_OFFSET]=m.x,l[Xp.GLOBAL_FOG_COLOR_OFFSET+1]=m.y,l[Xp.GLOBAL_FOG_COLOR_OFFSET+2]=m.z,l[Xp.GLOBAL_FOG_COLOR_OFFSET+3]=m.z,l[Xp.GLOBAL_FOG_BASE_OFFSET]=a.fogStart,l[Xp.GLOBAL_FOG_BASE_OFFSET+1]=a.fogEnd,l[Xp.GLOBAL_FOG_BASE_OFFSET+2]=a.fogDensity,l[Xp.GLOBAL_FOG_ADD_OFFSET]=a.fogTop,l[Xp.GLOBAL_FOG_ADD_OFFSET+1]=a.fogRange,l[Xp.GLOBAL_FOG_ADD_OFFSET+2]=a.fogAtten,l[Xp.NEAR_FAR_OFFSET]=n.nearClip,l[Xp.NEAR_FAR_OFFSET+1]=n.farClip,l[Xp.VIEW_PORT_OFFSET]=r.shadingScale*n.window.width*n.viewport.x,l[Xp.VIEW_PORT_OFFSET+1]=r.shadingScale*n.window.height*n.viewport.y,l[Xp.VIEW_PORT_OFFSET+2]=r.shadingScale*n.window.width*n.viewport.z,l[Xp.VIEW_PORT_OFFSET+3]=r.shadingScale*n.window.height*n.viewport.w},e.updateShadowUBOView=function(e,t,n){var i=e.device,r=n.scene.mainLight,o=e.pipelineSceneData.shadows,a=t;if(o.enabled){if(r&&o.type===pv.ShadowMap){var s=.1,c=0,l=o.matShadowView,u=o.matShadowProj,h=o.matShadowViewProj;o.fixedArea?(s=o.near,c=o.far):(s=.1,c=o.shadowCameraFar),Gn.toArray(t,l,Yp.MAT_LIGHT_VIEW_OFFSET),a[Yp.SHADOW_PROJ_DEPTH_INFO_OFFSET+0]=u.m10,a[Yp.SHADOW_PROJ_DEPTH_INFO_OFFSET+1]=u.m14,a[Yp.SHADOW_PROJ_DEPTH_INFO_OFFSET+2]=u.m11,a[Yp.SHADOW_PROJ_DEPTH_INFO_OFFSET+3]=u.m15,a[Yp.SHADOW_PROJ_INFO_OFFSET+0]=u.m00,a[Yp.SHADOW_PROJ_INFO_OFFSET+1]=u.m05,a[Yp.SHADOW_PROJ_INFO_OFFSET+2]=1/u.m00,a[Yp.SHADOW_PROJ_INFO_OFFSET+3]=1/u.m05,Gn.toArray(t,h,Yp.MAT_LIGHT_VIEW_PROJ_OFFSET);var f=Yd(i)?0:1;a[Yp.SHADOW_NEAR_FAR_LINEAR_SATURATION_INFO_OFFSET+0]=s,a[Yp.SHADOW_NEAR_FAR_LINEAR_SATURATION_INFO_OFFSET+1]=c,a[Yp.SHADOW_NEAR_FAR_LINEAR_SATURATION_INFO_OFFSET+2]=0,a[Yp.SHADOW_NEAR_FAR_LINEAR_SATURATION_INFO_OFFSET+3]=1-o.saturation,a[Yp.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET+0]=o.size.x,a[Yp.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET+1]=o.size.y,a[Yp.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET+2]=o.pcf,a[Yp.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET+3]=o.bias,a[Yp.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET+0]=0,a[Yp.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET+1]=f,a[Yp.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET+2]=o.normalBias,a[Yp.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET+3]=0}else r&&o.type===pv.Planar&&(Xv(o,r,a),Yv(o,a));An.toArray(a,o.shadowColor,Yp.SHADOW_COLOR_OFFSET)}},e.updateShadowUBOLightView=function(e,t,n){var i=e.device,r=e.pipelineSceneData.shadows,o=t,a=Yd(i)?0:1,s=.1,c=0,l=r.matShadowView,u=r.matShadowProj,h=r.matShadowViewProj;switch(n.type){case $v.DIRECTIONAL:r.fixedArea?(s=r.near,c=r.far):(s=.1,c=r.shadowCameraFar),Gn.toArray(t,l,Yp.MAT_LIGHT_VIEW_OFFSET),o[Yp.SHADOW_PROJ_DEPTH_INFO_OFFSET+0]=u.m10,o[Yp.SHADOW_PROJ_DEPTH_INFO_OFFSET+1]=u.m14,o[Yp.SHADOW_PROJ_DEPTH_INFO_OFFSET+2]=u.m11,o[Yp.SHADOW_PROJ_DEPTH_INFO_OFFSET+3]=u.m15,o[Yp.SHADOW_PROJ_INFO_OFFSET+0]=u.m00,o[Yp.SHADOW_PROJ_INFO_OFFSET+1]=u.m05,o[Yp.SHADOW_PROJ_INFO_OFFSET+2]=1/u.m00,o[Yp.SHADOW_PROJ_INFO_OFFSET+3]=1/u.m05,Gn.toArray(t,h,Yp.MAT_LIGHT_VIEW_PROJ_OFFSET),yy.set(s,c,0,1-r.saturation),Kn.toArray(o,yy,Yp.SHADOW_NEAR_FAR_LINEAR_SATURATION_INFO_OFFSET),yy.set(0,a,r.normalBias,0),Kn.toArray(o,yy,Yp.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET);break;case $v.SPOT:Gn.invert(my,n.node.getWorldMatrix()),Gn.toArray(o,my,Yp.MAT_LIGHT_VIEW_OFFSET),Gn.perspective(gy,n.angle,n.aspect,.001,n.range),Gn.multiply(vy,gy,my),Gn.toArray(o,vy,Yp.MAT_LIGHT_VIEW_PROJ_OFFSET),yy.set(.01,n.range,0,1-r.saturation),Kn.toArray(o,yy,Yp.SHADOW_NEAR_FAR_LINEAR_SATURATION_INFO_OFFSET),yy.set(1,a,r.normalBias,0),Kn.toArray(o,yy,Yp.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET)}yy.set(r.size.x,r.size.y,r.pcf,r.bias),Kn.toArray(o,yy,Yp.SHADOW_WIDTH_HEIGHT_PCF_BIAS_INFO_OFFSET),An.toArray(o,r.shadowColor,Yp.SHADOW_COLOR_OFFSET)},e.getCombineSignY=function(){return e._combineSignY};var t=e.prototype;return t._initCombineSignY=function(){var t=this._device;e._combineSignY=.5*t.capabilities.screenSpaceSignY+.5<<1|.5*t.capabilities.clipSpaceSignY+.5},t.activate=function(e,t){this._device=e,this._pipeline=t;var n=this._pipeline.descriptorSet;this._initCombineSignY();var i=e.createBuffer(new lr(_i.UNIFORM|_i.TRANSFER_DST,mi.HOST|mi.DEVICE,qp.SIZE,qp.SIZE));n.bindBuffer(qp.BINDING,i);var r=e.createBuffer(new lr(_i.UNIFORM|_i.TRANSFER_DST,mi.HOST|mi.DEVICE,Xp.SIZE,Xp.SIZE));n.bindBuffer(Xp.BINDING,r);var o=e.createBuffer(new lr(_i.UNIFORM|_i.TRANSFER_DST,mi.HOST|mi.DEVICE,Yp.SIZE,Yp.SIZE));n.bindBuffer(Yp.BINDING,o)},t.updateGlobalUBO=function(t){var n=this._pipeline.globalDSManager,i=this._pipeline.descriptorSet,r=this._pipeline.commandBuffers;i.update(),e.updateGlobalUBOView(t,this._globalUBO),r[0].updateBuffer(i.getBuffer(qp.BINDING),this._globalUBO),n.bindBuffer(qp.BINDING,i.getBuffer(qp.BINDING)),n.update()},t.updateCameraUBO=function(t){var n=this._pipeline.globalDSManager,i=this._pipeline.descriptorSet,r=this._pipeline.commandBuffers;e.updateCameraUBOView(this._pipeline,this._cameraUBO,t),r[0].updateBuffer(i.getBuffer(Xp.BINDING),this._cameraUBO),n.bindBuffer(Xp.BINDING,i.getBuffer(Xp.BINDING)),n.update()},t.updateShadowUBO=function(t){var n=this._pipeline.pipelineSceneData;if(n.shadows.enabled){var i=this._pipeline.descriptorSet,r=this._pipeline.commandBuffers,o=n.shadowFrameBufferMap,a=t.scene.mainLight;a&&o.has(a)&&i.bindTexture(Kp,o.get(a).colorTextures[0]),e.updateShadowUBOView(this._pipeline,this._shadowUBO,t),i.update(),r[0].updateBuffer(i.getBuffer(Yp.BINDING),this._shadowUBO)}},t.updateShadowUBOLight=function(t,n){e.updateShadowUBOLightView(this._pipeline,this._shadowUBO,n),t.bindTexture(Kp,wg.get("default-texture").getGFXTexture()),t.bindTexture(rd,wg.get("default-texture").getGFXTexture()),t.update(),t.getBuffer(Yp.BINDING).update(this._shadowUBO)},t.updateShadowUBORange=function(e,t){t instanceof Gn?Gn.toArray(this._shadowUBO,t,e):t instanceof An&&An.toArray(this._shadowUBO,t,e)},t.destroy=function(){},e}();Sy._combineSignY=0;var Ty,Ey,Ay,Cy,by,wy,Ry,Py,Iy,Dy,Oy,My,Ny,Ly=e("RenderStage",(ry=hc("RenderStage"),oy=zc(),ay=zc(),sy=zc(),ry((_y=function(){function e(){ae(this,"_name",uy,this),ae(this,"_priority",hy,this),this._enabled=!0,ae(this,"_tag",fy,this)}var t=e.prototype;return t.initialize=function(e){return this._name=e.name,this._priority=e.priority,e.tag&&(this._tag=e.tag),!0},t.activate=function(e,t){this._pipeline=e,this._flow=t},K(e,[{key:"name",get:function(){return this._name}},{key:"priority",get:function(){return this._priority}},{key:"tag",get:function(){return this._tag}},{key:"enabled",get:function(){return this._enabled},set:function(e){this._enabled=e}}]),e}(),uy=se((ly=_y).prototype,"_name",[oy,gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),hy=se(ly.prototype,"_priority",[ay,gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),fy=se(ly.prototype,"_tag",[sy,gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),cy=ly))||cy));c.RenderStage=Ly;var Fy,By=e("RenderFlow",(Ty=hc("RenderFlow"),Ey=zc(),Ay=zc(),Cy=zc(),by=zc(),wy=Wc([Ly]),Ty((Ny=function(){function e(){ae(this,"_name",Iy,this),ae(this,"_priority",Dy,this),ae(this,"_tag",Oy,this),ae(this,"_stages",My,this)}var t=e.prototype;return t.initialize=function(e){return this._name=e.name,this._priority=e.priority,this._stages=e.stages,e.tag&&(this._tag=e.tag),!0},t.activate=function(e){this._pipeline=e,this._stages.sort((function(e,t){return e.priority-t.priority}));for(var t=0,n=this._stages.length;t=0;--t){var n=e[t];if(n.window.swapchain)return void(Kg=n)}Kg=null}(e);for(var t=0;t0){var s=a;a=o,o=s}var c=0;switch(e){case ci.IDENTITY:c=0,n[c++]=-1,n[c++]=-1,n[c++]=i,n[c++]=a,n[c++]=1,n[c++]=-1,n[c++]=r,n[c++]=a,n[c++]=-1,n[c++]=1,n[c++]=i,n[c++]=o,n[c++]=1,n[c++]=1,n[c++]=r,n[c++]=o;break;case ci.ROTATE_90:c=0,n[c++]=-1,n[c++]=-1,n[c++]=r,n[c++]=a,n[c++]=1,n[c++]=-1,n[c++]=r,n[c++]=o,n[c++]=-1,n[c++]=1,n[c++]=i,n[c++]=a,n[c++]=1,n[c++]=1,n[c++]=i,n[c++]=o;break;case ci.ROTATE_180:c=0,n[c++]=-1,n[c++]=-1,n[c++]=i,n[c++]=o,n[c++]=1,n[c++]=-1,n[c++]=r,n[c++]=o,n[c++]=-1,n[c++]=1,n[c++]=i,n[c++]=a,n[c++]=1,n[c++]=1,n[c++]=r,n[c++]=a;break;case ci.ROTATE_270:c=0,n[c++]=-1,n[c++]=-1,n[c++]=i,n[c++]=o,n[c++]=1,n[c++]=-1,n[c++]=i,n[c++]=a,n[c++]=-1,n[c++]=1,n[c++]=r,n[c++]=o,n[c++]=1,n[c++]=1,n[c++]=r,n[c++]=a}return n},n._createQuadInputAssembler=function(){var e=new ix,t=4*Float32Array.BYTES_PER_ELEMENT,n=4*t,i=this._device.createBuffer(new lr(_i.VERTEX|_i.TRANSFER_DST,mi.DEVICE|mi.HOST,n,t));if(!i)return e;var r=Uint8Array.BYTES_PER_ELEMENT,o=6*r,a=this._device.createBuffer(new lr(_i.INDEX|_i.TRANSFER_DST,mi.DEVICE,o,r));if(!a)return e;var s=new Uint8Array(6);s[0]=0,s[1]=1,s[2]=2,s[3]=1,s[4]=3,s[5]=2,a.update(s);var c=new Array(2);c[0]=new br("a_position",ui.RG32F),c[1]=new br("a_texCoord",ui.RG32F);var l=this._device.createInputAssembler(new Rr(c,[i],a));return e.quadIB=a,e.quadVB=i,e.quadIA=l,e},n.updateQuadVertexData=function(e,t){var n=this._lastUsedRenderArea;if(n.x!==e.x||n.y!==e.y||n.width!==e.width||n.height!==e.height){var i=this._genQuadVertexData(ci.IDENTITY,e);this._quadVBOffscreen.update(i);var r=this._genQuadVertexData(t.swapchain&&t.swapchain.surfaceTransform||ci.IDENTITY,e);this._quadVBOnscreen.update(r),n.copy(e)}},n.destroy=function(){for(var t,n,i=0;i>1,r>>1)),e.prefilterFramebuffer=t.createFramebuffer(new Fr(e.renderPass,[e.prefiterTex])),i>>=1,r>>=1;for(var o=0;o<6;++o)e.downsampleTexs.push(t.createTexture(new pr(gi.TEX2D,vi.COLOR_ATTACHMENT|vi.SAMPLED,ui.RGBA8,i>>1,r>>1))),e.downsampleFramebuffers[o]=t.createFramebuffer(new Fr(e.renderPass,[e.downsampleTexs[o]])),e.upsampleTexs.push(t.createTexture(new pr(gi.TEX2D,vi.COLOR_ATTACHMENT|vi.SAMPLED,ui.RGBA8,i,r))),e.upsampleFramebuffers[o]=t.createFramebuffer(new Fr(e.renderPass,[e.upsampleTexs[o]])),i>>=1,r>>=1;e.combineTex=t.createTexture(new pr(gi.TEX2D,vi.COLOR_ATTACHMENT|vi.SAMPLED,ui.RGBA8,this._width,this._height)),e.combineFramebuffer=t.createFramebuffer(new Fr(e.renderPass,[e.combineTex])),e.sampler=this.globalDSManager.linearSampler}},n.on=function(e,t,n,i){return this._eventProcessor.on(e,t,n,i)},n.once=function(e,t,n){return this._eventProcessor.once(e,t,n)},n.off=function(e,t,n){this._eventProcessor.off(e,t,n)},n.emit=function(e,t,n,i,r,o){this._eventProcessor.emit(e,t,n,i,r,o)},n.targetOff=function(e){this._eventProcessor.targetOff(e)},n.removeAll=function(e){this._eventProcessor.removeAll(e)},n.hasEventListener=function(e,t,n){return this._eventProcessor.hasEventListener(e,t,n)},K(t,[{key:"tag",get:function(){return this._tag}},{key:"flows",get:function(){return this._flows}},{key:"quadIAOnscreen",get:function(){return this._quadIAOnscreen}},{key:"quadIAOffscreen",get:function(){return this._quadIAOffscreen}},{key:"constantMacros",get:function(){return this._constantMacros}},{key:"macros",get:function(){return this._macros}},{key:"device",get:function(){return this._device}},{key:"globalDSManager",get:function(){return this._globalDSManager}},{key:"descriptorSetLayout",get:function(){return this._globalDSManager.descriptorSetLayout}},{key:"descriptorSet",get:function(){return this._descriptorSet}},{key:"commandBuffers",get:function(){return this._commandBuffers}},{key:"pipelineUBO",get:function(){return this._pipelineUBO}},{key:"pipelineSceneData",get:function(){return this._pipelineSceneData}},{key:"profiler",get:function(){return this._profiler},set:function(e){this._profiler=e}},{key:"clusterEnabled",get:function(){return this._clusterEnabled},set:function(e){this._clusterEnabled=e}},{key:"bloomEnabled",get:function(){return this._bloomEnabled},set:function(e){this._bloomEnabled=e}}]),t}(Ru),jy=se((Vy=qy).prototype,"_tag",[ky,gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Wy=se(Vy.prototype,"_flows",[Uy,Gy,gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Hy=Vy))||Hy));c.RenderPipeline=rx,function(e){e[e.BLOOM=18]="BLOOM",e[e.POST_PROCESS=19]="POST_PROCESS",e[e.UI=20]="UI"}(Xy||(Xy={})),function(e){e[e.FORWARD=10]="FORWARD"}(Yy||(Yy={})),function(e){e[e.SHADOW=0]="SHADOW",e[e.FORWARD=1]="FORWARD",e[e.UI=10]="UI"}(Ky||(Ky={})),function(e){e[e.GBUFFER=10]="GBUFFER",e[e.LIGHTING=15]="LIGHTING",e[e.TRANSPARENT=18]="TRANSPARENT"}(Qy||(Qy={})),function(e){e[e.SHADOW=0]="SHADOW",e[e.MAIN=1]="MAIN",e[e.UI=10]="UI"}(Zy||(Zy={}));var ox=new Pr;ox.format=ui.RGBA8,ox.beginAccesses=[Oi.FRAGMENT_SHADER_READ_TEXTURE],ox.endAccesses=[Oi.FRAGMENT_SHADER_READ_TEXTURE];var ax=new Ir;ax.format=ui.DEPTH_STENCIL;var sx,cx,lx,ux,hx,fx,_x,px,dx,mx,gx,vx,yx,xx,Sx,Tx,Ex,Ax,Cx,bx,wx,Rx,Px,Ix,Dx,Ox,Mx,Nx,Lx,Fx,Bx,zx,kx,Ux,Gx,Hx,Vx,jx,Wx,qx,Xx,Yx,Kx,Qx,Zx,Jx,$x,eS,tS,nS,iS,rS,oS,aS,sS,cS,lS,uS,hS,fS,_S,pS,dS,mS,gS,vS,yS,xS,SS,TS,ES,AS,CS,bS,wS,RS,PS,IS,DS,OS=new Mr([ox],ax),MS={width:1,height:1,renderPassInfo:OS},NS=e("RenderTexture",hc("cc.RenderTexture")(Jy=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r=1&&this.width<=2048&&this.height>=1&&this.height<=2048},n.readPixels=function(e,t,n,i,r){void 0===e&&(e=0),void 0===t&&(t=0),n=n||this.width,i=i||this.height;var o=this.getGFXTexture();if(!o)return D(7606),null;var a=4*n*i;if(void 0===r)r=new Uint8Array(a);else if(r.length8?D(12004,8):(this._passes=e,this._flushPassInfo(),this._passes[0].batchingScheme===Eg.VB_MERGING&&(this.subMesh.genFlatBuffers(),this._setSubMesh(this.subMesh)),this._descriptorSet&&(this._destroyDescriptorSet(),ZS.layout=e[0].localSetLayout,this._createDescriptorSet(ZS)))}},{key:"shaders",get:function(){return this._shaders}},{key:"subMesh",get:function(){return this._subMesh},set:function(e){this._inputAssembler.destroy(),this._inputAssembler.initialize(e.iaInfo),this._passes[0].batchingScheme===Eg.VB_MERGING&&this.subMesh.genFlatBuffers(),this._setSubMesh(e)}},{key:"priority",get:function(){return this._priority},set:function(e){this._priority=e}},{key:"inputAssembler",get:function(){return this._inputAssembler}},{key:"descriptorSet",get:function(){return this._descriptorSet}},{key:"worldBoundDescriptorSet",get:function(){return this._worldBoundDescriptorSet}},{key:"patches",get:function(){return this._patches}},{key:"planarInstanceShader",get:function(){return this._planarInstanceShader}},{key:"planarShader",get:function(){return this._planarShader}},{key:"native",get:function(){return this._nativeObj}}]),e}(),$S=new Gn,eT=[{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"}(KS||(KS={}));var tT=new mr(Ti.LINEAR,Ti.LINEAR,Ti.NONE,Ei.CLAMP,Ei.CLAMP,Ei.CLAMP),nT=new mr(Ti.LINEAR,Ti.LINEAR,Ti.LINEAR,Ei.CLAMP,Ei.CLAMP,Ei.CLAMP),iT=function(){function e(){this.type=KS.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._localDataUpdated=!0,this._localData=new Float32Array(sd.COUNT),this._localBuffer=null,this._instMatWorldIdx=-1,this._lightmap=null,this._lightmapUVParam=new Kn,this._worldBoundBuffer=null,this._receiveShadow=!1,this._castShadow=!1,this._enabled=!0,this._visFlags=Ip.Enum.NONE,this._device=c.director.root.device}var t=e.prototype;return t._setReceiveShadow=function(e){this._receiveShadow=e},t._init=function(){},t.initialize=function(){this._inited||(this._init(),this._setReceiveShadow(!0),this.castShadow=!1,this.enabled=!0,this.visFlags=Ip.Enum.NONE,this._inited=!0)},t._destroySubmodel=function(e){e.destroy()},t._destroy=function(){},t.destroy=function(){for(var e=this._subModels,t=0;t=0){var o=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,o[r],o[r+1],o[r+2])}else if(this._localBuffer){Gn.toArray(this._localData,i,sd.MAT_WORLD_OFFSET),Gn.inverseTranspose($S,i);var a=Math.abs(Gn.determinant($S)),s=1/Math.sqrt(a);Gn.multiplyScalar($S,$S,s),Gn.toArray(this._localData,$S,sd.MAT_WORLD_IT_OFFSET),this._localBuffer.update(this._localData),this._applyLocalData(),this._applyLocalBuffer()}}},t._updateNativeBounds=function(){},t.createBoundingShape=function(e,t){e&&t&&(this._modelBounds=Hs.fromPoints(Hs.create(),e,t),this._worldBounds=Hs.clone(this._modelBounds),this._updateNativeBounds())},t._createSubModel=function(){return new JS},t.initSubModel=function(e,t,n){this.initialize(),null==this._subModels[e]?this._subModels[e]=this._createSubModel():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)},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?nT:tT),r=this._subModels,o=0;o=0}},{key:"receiveShadow",get:function(){return this._receiveShadow},set:function(e){this._setReceiveShadow(e),this.onMacroPatchesStateChanged()}},{key:"castShadow",get:function(){return this._castShadow},set:function(e){this._castShadow=e}},{key:"node",get:function(){return this._node},set:function(e){this._node=e}},{key:"transform",get:function(){return this._transform},set:function(e){this._transform=e}},{key:"visFlags",get:function(){return this._visFlags},set:function(e){this._visFlags=e}},{key:"enabled",get:function(){return this._enabled},set:function(e){this._enabled=e}},{key:"native",get:function(){return this._nativeObj}}]),e}(),rT=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._root=e,this._createNativeObject()}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,!0},t.activate=function(){},t.update=function(e){var t=this._mainLight;t&&t.update();for(var n=this._sphereLights,i=0;ithis._lightBufferCount&&(this._firstLightBufferView.destroy(),this._lightBufferCount=mn(a.length),this._lightBuffer.resize(this._lightBufferStride*this._lightBufferCount),this._lightBufferData=new Float32Array(this._lightBufferElementCount*this._lightBufferCount),this._firstLightBufferView.initialize(new ur(this._lightBuffer,0,hd.SIZE)));for(var s=0,c=0;s1)e.push("t="+this._targetExp+";"),t="t";else{if(1!==this._exps.length)return;t=this._targetExp}for(var n=0;n0&&(n=bE+this.globalVariables.join(",")+";");var i=TE(["return (function(R){",n||[],this.codeArray,"return o;","})"]);this.result=Function("O","F",i)(this.objs,this.funcs);for(var r=0,o=this.objsToClear_iN$t.length;r0&&(o=n._findChildComponent(r._children,t)))return o}return null},n._findChildComponents=function(e,t,i){for(var r=0;r0&&n._findChildComponents(o._children,t,i)}};var t=n.prototype;function n(t){var n;return ae(n=e.call(this,t)||this,"_parent",UE,ie(n)),ae(n,"_children",GE,ie(n)),ae(n,"_active",HE,ie(n)),ae(n,"_components",VE,ie(n)),ae(n,"_prefab",jE,ie(n)),n._scene=null,n._activeInHierarchy=!1,n._id=ZE.getNewId(),n._name=void 0,n._eventProcessor=new c.NodeEventProcessor(ie(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){Be(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(BE.PARENT_CHANGED,n),n&&!(n._objFlags&YE)){var r=n._children.indexOf(this);n._children.splice(r,1),n._updateSiblingIndex(),n.emit&&n.emit(BE.CHILD_REMOVED,this)}i&&(i._children.push(this),this._siblingIndex=i._children.length-1,i.emit&&i.emit(BE.CHILD_ADDED,this)),this._onHierarchyChanged(n)}},t.getChildByUuid=function(e){if(!e)return v("Invalid uuid"),null;for(var t=this._children,n=0,i=t.length;n0?(c=o,r=o._children,a=0,s[i]=r[a],i++):(s[i]=o,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=JE(e);return t?n._findComponent(this,t):null},t.getComponents=function(e){var t=JE(e),i=[];return t&&n._findComponents(this,t,i),i},t.getComponentInChildren=function(e){var t=JE(e);return t?n._findChildComponent(this._children,t):null},t.getComponentsInChildren=function(e){var t=JE(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=Ze(e)))throw c._RF.peek()&&D(3808,e),TypeError(L(3807,e))}else{if(!e)throw TypeError(L(3804));t=e}if("function"!=typeof t)throw TypeError(L(3809));if(!Ue(t,c.Component))throw TypeError(L(3810));var n=t._requireComponent;if(n)if(Array.isArray(n))for(var i=0;i0},set:function(e){e?this._objFlags|=KE:this._objFlags&=~KE}},{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}(ul),WE.idGenerator=ZE,WE._stacks=[[]],WE._stackId=0,se((kE=qE).prototype,"_persistNode",[dc],Object.getOwnPropertyDescriptor(kE.prototype,"_persistNode"),kE.prototype),se(kE.prototype,"name",[Rc],Object.getOwnPropertyDescriptor(kE.prototype,"name"),kE.prototype),se(kE.prototype,"children",[Rc],Object.getOwnPropertyDescriptor(kE.prototype,"children"),kE.prototype),se(kE.prototype,"active",[Rc],Object.getOwnPropertyDescriptor(kE.prototype,"active"),kE.prototype),se(kE.prototype,"activeInHierarchy",[Rc],Object.getOwnPropertyDescriptor(kE.prototype,"activeInHierarchy"),kE.prototype),se(kE.prototype,"parent",[Rc],Object.getOwnPropertyDescriptor(kE.prototype,"parent"),kE.prototype),UE=se(kE.prototype,"_parent",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),GE=se(kE.prototype,"_children",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),HE=se(kE.prototype,"_active",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),VE=se(kE.prototype,"_components",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),jE=se(kE.prototype,"_prefab",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),zE=kE))||zE);c._BaseNode=uA;var hA=new bn,fA=new Mn,_A=new Mn,pA=new Mn,dA=new In,mA=new In,gA=new Gn,vA=[],yA=[],xA=[],SA=function(){function e(){this._chunks=[],this._freelists=[],this._createChunk()}var t=e.prototype;return t.alloc=function(){for(var e=this._freelists.length,t=0;t=0;n--)t.push(n);this._freelists.push(t)},t._createView=function(e){return xA[0]=this._chunks[e],xA[1]=this._freelists[e].pop(),xA},e}();SA.CAPACITY_PER_CHUNK=256;var TA,EA,AA,CA,bA,wA,RA,PA,IA,DA,OA,MA,NA,LA,FA,BA,zA,kA,UA,GA,HA,VA,jA,WA,qA,XA,YA,KA,QA,ZA,JA,$A,eC,tC,nC,iC,rC,oC,aC,sC,cC,lC,uC,hC,fC,_C,pC,dC,mC,gC,vC,yC,xC,SC,TC,EC,AC,CC,bC,wC,RC,PC,IC,DC,OC,MC,NC,LC,FC,BC=new SA,zC=Symbol("ReserveContentsForAllSyncablePrefab"),kC=e("Node",($E=hc("cc.Node"),eA=Wc(bn),$E((lA=cA=function(e){Z(n,e);var t=n.prototype;function n(t){var n;return(n=e.call(this,t)||this)._uiProps=new XE(ie(n)),n._static=!1,ae(n,"_lpos",iA,ie(n)),ae(n,"_lrot",rA,ie(n)),ae(n,"_lscale",oA,ie(n)),ae(n,"_layer",aA,ie(n)),ae(n,"_euler",sA,ie(n)),n._dirtyFlagsPri=Jv.NONE,n._eulerDirty=!1,n._nodeHandle=0,n._init(),n}return t._init=function(){var e=BC.alloc(),t=e[0],n=e[1];this._hasChangedFlagsChunk=t,this._hasChangedFlagsOffset=n;var i=new Uint32Array(t.buffer,t.byteOffset+4*n,1);this._hasChangedFlags=i,this._pos=new bn,this._rot=new Mn,this._scale=new bn(1,1,1),this._mat=new Gn},n.isNode=function(e){return e instanceof n&&(e.constructor===n||!(e instanceof c.Scene))},t._onPreDestroy=function(){var e=this._onPreDestroyBase();return BC.free(this._hasChangedFlagsChunk,this._hasChangedFlagsOffset),e},t[ah]=function(e){e.writeThis()},t.setParent=function(t,n){void 0===n&&(n=!1),n&&this.updateWorldTransform(),e.prototype.setParent.call(this,t,n)},t._onSetParent=function(t,n){if(e.prototype._onSetParent.call(this,t,n),n){var i=this._parent;i?(i.updateWorldTransform(),Gn.multiply(gA,Gn.invert(gA,i._mat),this._mat),Gn.toRTS(gA,this._lrot,this._lpos,this._lscale)):(bn.copy(this._lpos,this._pos),Mn.copy(this._lrot,this._rot),bn.copy(this._lscale,this._scale)),this._eulerDirty=!0}this.invalidateChildren(Jv.TRS)},t._onHierarchyChanged=function(t){this.eventProcessor.reattach(),e.prototype._onHierarchyChangedBase.call(this,t)},t._onBatchCreated=function(e){this.hasChangedFlags=Jv.TRS,this._dirtyFlags|=Jv.TRS;for(var t=this._children.length,n=0;n=0;){if(c=(t=vA[r--])._hasChangedFlags[0],s=t._dirtyFlagsPri,t.isValid&&(s&c&e)!==e)for(s|=e,t._dirtyFlagsPri=s,t._hasChangedFlags[0]=c|e,a=(i=t._children).length,o=0;o=0;)bn.transformInverseRTS(e,e,n._lrot,n._lpos,n._lscale),n=vA[--i];return e},t.setWorldPosition=function(e,t,n){void 0===t||void 0===n?bn.copy(this._pos,e):bn.set(this._pos,e,t,n);var i=this._parent,r=this._lpos;i?(i.updateWorldTransform(),bn.transformMat4(r,this._pos,Gn.invert(gA,i._mat))):bn.copy(r,this._pos),this.invalidateChildren(Jv.POSITION),1&this._eventMask&&this.emit(BE.TRANSFORM_CHANGED,Jv.POSITION)},t.getWorldPosition=function(e){return this.updateWorldTransform(),e?bn.copy(e,this._pos):bn.copy(new bn,this._pos)},t.setWorldRotation=function(e,t,n,i){void 0===t||void 0===n||void 0===i?Mn.copy(this._rot,e):Mn.set(this._rot,e,t,n,i),this._parent?(this._parent.updateWorldTransform(),Mn.multiply(this._lrot,Mn.conjugate(this._lrot,this._parent._rot),this._rot)):Mn.copy(this._lrot,this._rot),this._eulerDirty=!0,this.invalidateChildren(Jv.ROTATION),1&this._eventMask&&this.emit(BE.TRANSFORM_CHANGED,Jv.ROTATION)},t.setWorldRotationFromEuler=function(e,t,n){Mn.fromEuler(this._rot,e,t,n),this._parent?(this._parent.updateWorldTransform(),Mn.multiply(this._lrot,Mn.conjugate(this._lrot,this._parent._rot),this._rot)):Mn.copy(this._lrot,this._rot),this._eulerDirty=!0,this.invalidateChildren(Jv.ROTATION),1&this._eventMask&&this.emit(BE.TRANSFORM_CHANGED,Jv.ROTATION)},t.getWorldRotation=function(e){return this.updateWorldTransform(),e?Mn.copy(e,this._rot):Mn.copy(new Mn,this._rot)},t.setWorldScale=function(e,t,n){void 0===t||void 0===n?bn.copy(this._scale,e):bn.set(this._scale,e,t,n);var i=this._parent;i?(i.updateWorldTransform(),In.fromQuat(dA,Mn.conjugate(pA,i._rot)),In.multiplyMat4(dA,dA,i._mat),mA.m00=this._scale.x,mA.m04=this._scale.y,mA.m08=this._scale.z,In.multiply(dA,mA,In.invert(dA,dA)),this._lscale.x=bn.set(hA,dA.m00,dA.m01,dA.m02).length(),this._lscale.y=bn.set(hA,dA.m03,dA.m04,dA.m05).length(),this._lscale.z=bn.set(hA,dA.m06,dA.m07,dA.m08).length()):bn.copy(this._lscale,this._scale),this.invalidateChildren(Jv.SCALE),1&this._eventMask&&this.emit(BE.TRANSFORM_CHANGED,Jv.SCALE)},t.getWorldScale=function(e){return this.updateWorldTransform(),e?bn.copy(e,this._scale):bn.copy(new bn,this._scale)},t.getWorldMatrix=function(e){this.updateWorldTransform();var t=e||new Gn;return Gn.copy(t,this._mat)},t.getWorldRS=function(e){this.updateWorldTransform();var t=e||new Gn;return Gn.copy(t,this._mat),t.m12=0,t.m13=0,t.m14=0,t},t.getWorldRT=function(e){this.updateWorldTransform();var t=e||new Gn;return Gn.fromRT(t,this._rot,this._pos)},t.setRTS=function(e,t,n){var i=0;e&&(i|=Jv.ROTATION,void 0!==e.w?(Mn.copy(this._lrot,e),this._eulerDirty=!0):(bn.copy(this._euler,e),Mn.fromEuler(this._lrot,e.x,e.y,e.z),this._eulerDirty=!1)),t&&(bn.copy(this._lpos,t),i|=Jv.POSITION),n&&(bn.copy(this._lscale,n),i|=Jv.SCALE),i&&(this.invalidateChildren(i),1&this._eventMask&&this.emit(BE.TRANSFORM_CHANGED,i))},t.pauseSystemEvents=function(e){this._eventProcessor.setEnabled(!1,e)},t.resumeSystemEvents=function(e){this._eventProcessor.setEnabled(!0,e)},n.resetHasChangedFlags=function(){BC.clear()},n.clearNodeArray=function(){n.ClearFrame0)for(var c=0;c=0&&o.node._components.splice(a,1)}}}function eb(e,t,n){if(!(t.length<=0))for(var i=null,r=0;r0){var c=s.pop();if(!c)continue;for(var l=0;l0){var g=d.pop();if(!g)return;for(var v=0;v=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 kC,this.data.name="(Missing Node)";var n=new c._PrefabInfo;n.asset=this,n.root=this.data,this.data._prefab=n},n.validate=function(){return!!this.data},n.onLoaded=function(){var e=this.data;ib(e),tb(e)},t}(Ru),lb.OptimizationPolicy=yb,lb.OptimizationPolicyThreshold=3,ab=se((ob=ub).prototype,"data",[gc,Rc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),sb=se(ob.prototype,"optimizationPolicy",[gc,Rc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return yb.AUTO}}),cb=se(ob.prototype,"persistent",[gc,Rc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),rb=ob))||rb);tt.value(xb,"_utils",vb),c.Prefab=xb,Re(c,"cc._Prefab","Prefab"),e("PrefabLink",(hb=hc("cc.PrefabLink"),fb=Wc(xb),_b=Pc(),hb((gb=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;rr.x?n[c]:r.x,r.y=n[c+1]>r.y?n[c+1]:r.y,o.x=n[c]r.x?n[c]:r.x,r.y=n[c+1]>r.y?n[c+1]:r.y,r.z=n[c+2]>r.z?n[c+2]:r.z,o.x=n[c]0)for(var r=0;r0?i:null}return null},e._attachMask=function(){this.maskList=this._searchComponentsInParent(t._maskComp)},e.reattach=function(){var e,n=this;this.node.walk((function(i){e||(e=n._searchComponentsInParent(t._maskComp)),i.eventProcessor.maskList=e}))},e.destroy=function(){kb===this._node&&(kb=null),this.capturingTarget&&this.capturingTarget.clear(),this.bubblingTarget&&this.bubblingTarget.clear(),t.callbacksInvoker.emit(Bb.REMOVE_POINTER_EVENT_PROCESSOR,this)},e._isTouchEvent=function(e){return-1!==Gb.indexOf(e)},e._isMouseEvent=function(e){return-1!==Hb.indexOf(e)},e._hasTouchListeners=function(){for(var e=0;e=0;--i)if((t=zb[i]).eventProcessor.capturingTarget&&(e.currentTarget=t,t.eventProcessor.capturingTarget.emit(e.type,e,zb),e.propagationStopped))return void(zb.length=0);if(zb.length=0,e.eventPhase=2,e.currentTarget=n,this.capturingTarget&&this.capturingTarget.emit(e.type,e),!e.propagationImmediateStopped&&this.bubblingTarget&&this.bubblingTarget.emit(e.type,e),!e.propagationStopped&&e.bubbles)for(this.getBubblingTargets(e.type,zb),e.eventPhase=3,i=0;i1?(this._saturation=e/e,this._resource&&(this._resource.saturation=e/e)):(this._saturation=e,this._resource&&(this._resource.saturation=e))}},{key:"pcf",get:function(){return this._pcf},set:function(e){this._pcf=e,this._resource&&(this._resource.pcf=e)}},{key:"maxReceived",get:function(){return this._maxReceived},set:function(e){this._maxReceived=e,this._resource&&(this._resource.maxReceived=e)}},{key:"bias",get:function(){return this._bias},set:function(e){this._bias=e,this._resource&&(this._resource.bias=e)}},{key:"normalBias",get:function(){return this._normalBias},set:function(e){this._normalBias=e,this._resource&&(this._resource.normalBias=e)}},{key:"shadowMapSize",get:function(){return this._size.x},set:function(e){this._size.set(e,e),this._resource&&(this._resource.size.set(e,e),this._resource.shadowMapDirty=!0)}},{key:"size",get:function(){return this._size}},{key:"fixedArea",get:function(){return this._fixedArea},set:function(e){this._fixedArea=e,this._resource&&(this._resource.fixedArea=e)}},{key:"near",get:function(){return this._near},set:function(e){this._near=e,this._resource&&(this._resource.near=e)}},{key:"far",get:function(){return this._far},set:function(e){this._far=Math.min(e,gv.MAX_FAR),this._resource&&(this._resource.far=this._far)}},{key:"invisibleOcclusionRange",get:function(){return this._invisibleOcclusionRange},set:function(e){this._invisibleOcclusionRange=Math.min(e,gv.MAX_FAR),this._resource&&(this._resource.invisibleOcclusionRange=this._invisibleOcclusionRange)}},{key:"shadowDistance",get:function(){return this._shadowDistance},set:function(e){this._shadowDistance=Math.min(e,gv.MAX_FAR),this._resource&&(this._resource.shadowDistance=this._shadowDistance)}},{key:"orthoSize",get:function(){return this._orthoSize},set:function(e){this._orthoSize=e,this._resource&&(this._resource.orthoSize=e)}}]),e}(),IP=se((PP=YP).prototype,"_type",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return pv.Planar}}),DP=se(PP.prototype,"_enabled",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),OP=se(PP.prototype,"_normal",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new bn(0,1,0)}}),MP=se(PP.prototype,"_distance",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),NP=se(PP.prototype,"_shadowColor",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new An(0,0,0,76)}}),LP=se(PP.prototype,"_firstSetCSM",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),FP=se(PP.prototype,"_fixedArea",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),BP=se(PP.prototype,"_pcf",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return dv.HARD}}),zP=se(PP.prototype,"_bias",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1e-5}}),kP=se(PP.prototype,"_normalBias",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),UP=se(PP.prototype,"_near",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.1}}),GP=se(PP.prototype,"_far",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 10}}),HP=se(PP.prototype,"_shadowDistance",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 100}}),VP=se(PP.prototype,"_invisibleOcclusionRange",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 200}}),jP=se(PP.prototype,"_orthoSize",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 5}}),WP=se(PP.prototype,"_maxReceived",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 4}}),qP=se(PP.prototype,"_size",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Wn(512,512)}}),XP=se(PP.prototype,"_saturation",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.75}}),se(PP.prototype,"enabled",[Rc,FR],Object.getOwnPropertyDescriptor(PP.prototype,"enabled"),PP.prototype),se(PP.prototype,"type",[Rc,BR],Object.getOwnPropertyDescriptor(PP.prototype,"type"),PP.prototype),se(PP.prototype,"shadowColor",[zR],Object.getOwnPropertyDescriptor(PP.prototype,"shadowColor"),PP.prototype),se(PP.prototype,"normal",[kR,UR],Object.getOwnPropertyDescriptor(PP.prototype,"normal"),PP.prototype),se(PP.prototype,"distance",[GR,HR,VR],Object.getOwnPropertyDescriptor(PP.prototype,"distance"),PP.prototype),se(PP.prototype,"saturation",[Rc,jR,Bc,WR,qR,XR],Object.getOwnPropertyDescriptor(PP.prototype,"saturation"),PP.prototype),se(PP.prototype,"pcf",[YR,KR,QR],Object.getOwnPropertyDescriptor(PP.prototype,"pcf"),PP.prototype),se(PP.prototype,"maxReceived",[ZR,JR],Object.getOwnPropertyDescriptor(PP.prototype,"maxReceived"),PP.prototype),se(PP.prototype,"bias",[$R,eP,tP],Object.getOwnPropertyDescriptor(PP.prototype,"bias"),PP.prototype),se(PP.prototype,"normalBias",[nP,iP,rP],Object.getOwnPropertyDescriptor(PP.prototype,"normalBias"),PP.prototype),se(PP.prototype,"shadowMapSize",[oP,aP,sP],Object.getOwnPropertyDescriptor(PP.prototype,"shadowMapSize"),PP.prototype),se(PP.prototype,"fixedArea",[cP,lP,uP],Object.getOwnPropertyDescriptor(PP.prototype,"fixedArea"),PP.prototype),se(PP.prototype,"near",[hP,fP,_P],Object.getOwnPropertyDescriptor(PP.prototype,"near"),PP.prototype),se(PP.prototype,"far",[pP,dP,mP],Object.getOwnPropertyDescriptor(PP.prototype,"far"),PP.prototype),se(PP.prototype,"invisibleOcclusionRange",[Rc,gP,Bc,vP,yP,xP],Object.getOwnPropertyDescriptor(PP.prototype,"invisibleOcclusionRange"),PP.prototype),se(PP.prototype,"shadowDistance",[Rc,SP,Bc,TP,EP,AP],Object.getOwnPropertyDescriptor(PP.prototype,"shadowDistance"),PP.prototype),se(PP.prototype,"orthoSize",[CP,bP,wP],Object.getOwnPropertyDescriptor(PP.prototype,"orthoSize"),PP.prototype),RP=PP))||RP)||RP);c.ShadowsInfo=OI;var MI=new bn(-1024,-1024,-1024),NI=new bn(1024,1024,1024),LI=(KP=hc("cc.OctreeInfo"),QP=wc(),ZP=Oc(),JP=Oc(),$P=Dc(),eI=Oc(),tI=Dc(),nI=Mc(),iI=Wc(It),rI=Oc(),KP(oI=QP((hI=function(){function e(){ae(this,"_enabled",sI,this),ae(this,"_minPos",cI,this),ae(this,"_maxPos",lI,this),ae(this,"_depth",uI,this),this._resource=null}return e.prototype.activate=function(e){this._resource=e,this._resource.initialize(this)},K(e,[{key:"enabled",get:function(){return this._enabled},set:function(e){this._enabled!==e&&(this._enabled=e,this._resource&&(this._resource.enabled=e))}},{key:"minPos",get:function(){return this._minPos},set:function(e){this._minPos=e,this._resource&&(this._resource.minPos=e)}},{key:"maxPos",get:function(){return this._maxPos},set:function(e){this._maxPos=e,this._resource&&(this._resource.maxPos=e)}},{key:"depth",get:function(){return this._depth},set:function(e){this._depth=e,this._resource&&(this._resource.depth=e)}}]),e}(),sI=se((aI=hI).prototype,"_enabled",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),cI=se(aI.prototype,"_minPos",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new bn(MI)}}),lI=se(aI.prototype,"_maxPos",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new bn(NI)}}),uI=se(aI.prototype,"_depth",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 8}}),se(aI.prototype,"enabled",[Rc,ZP],Object.getOwnPropertyDescriptor(aI.prototype,"enabled"),aI.prototype),se(aI.prototype,"minPos",[Rc,JP,$P],Object.getOwnPropertyDescriptor(aI.prototype,"minPos"),aI.prototype),se(aI.prototype,"maxPos",[Rc,eI,tI],Object.getOwnPropertyDescriptor(aI.prototype,"maxPos"),aI.prototype),se(aI.prototype,"depth",[Rc,nI,iI,rI],Object.getOwnPropertyDescriptor(aI.prototype,"depth"),aI.prototype),oI=aI))||oI)||oI),FI=(fI=hc("cc.SceneGlobals"),_I=Wc(II),fI((SI=function(){function e(){ae(this,"ambient",mI,this),ae(this,"shadows",gI,this),ae(this,"_skybox",vI,this),ae(this,"fog",yI,this),ae(this,"octree",xI,this)}return e.prototype.activate=function(){var e=c.director.root.pipeline.pipelineSceneData;this.skybox.activate(e.skybox),this.ambient.activate(e.ambient),this.shadows.activate(e.shadows),this.fog.activate(e.fog),this.octree.activate(e.octree)},K(e,[{key:"skybox",get:function(){return this._skybox},set:function(e){this._skybox=e}}]),e}(),mI=se((dI=SI).prototype,"ambient",[gc,Rc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new PI}}),gI=se(dI.prototype,"shadows",[gc,Rc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new OI}}),vI=se(dI.prototype,"_skybox",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new II}}),yI=se(dI.prototype,"fog",[Rc,gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new DI}}),se(dI.prototype,"skybox",[Rc,_I],Object.getOwnPropertyDescriptor(dI.prototype,"skybox"),dI.prototype),xI=se(dI.prototype,"octree",[Rc,gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new LI}}),pI=dI))||pI);c.SceneGlobals=FI;var BI=e("Event",function(){function e(e,t){this.type=void 0,this.bubbles=void 0,this.target=null,this.currentTarget=null,this.eventPhase=0,this.propagationStopped=!1,this.propagationImmediateStopped=!1,this.type=e,this.bubbles=!!t}var t=e.prototype;return t.unuse=function(){this.type=e.NO_TYPE,this.target=null,this.currentTarget=null,this.eventPhase=e.NONE,this.propagationStopped=!1,this.propagationImmediateStopped=!1},t.reuse=function(e,t){this.type=e,this.bubbles=t||!1},t.isStopped=function(){return this.propagationStopped||this.propagationImmediateStopped},t.getCurrentTarget=function(){return this.currentTarget},t.getType=function(){return this.type},e}());BI.NO_TYPE="no_type",BI.TOUCH="touch",BI.MOUSE="mouse",BI.KEYBOARD="keyboard",BI.ACCELERATION="acceleration",BI.NONE=0,BI.CAPTURING_PHASE=1,BI.AT_TARGET=2,BI.BUBBLING_PHASE=3,c.Event=BI;var zI=e("EventAcceleration",function(e){function t(t,n){var i;return(i=e.call(this,Nb.DEVICEMOTION,n)||this).acc=void 0,i.acc=t,i}return Z(t,e),t}(BI));BI.EventAcceleration=zI;var kI=e("EventKeyboard",function(e){function t(t,n,i){var r;return"boolean"==typeof n&&(n=n?Nb.KEY_DOWN:Nb.KEY_UP),(r=e.call(this,n,i)||this).keyCode=void 0,r.rawEvent=void 0,r._isPressed=void 0,r._isPressed=n!==Nb.KEY_UP,"number"==typeof t?r.keyCode=t:(r.keyCode=t.keyCode,r.rawEvent=t),r}return Z(t,e),K(t,[{key:"isPressed",get:function(){return this._isPressed}}]),t}(BI));BI.EventKeyboard=kI;var UI=e("EventMouse",function(e){function t(n,i,r){var o;return(o=e.call(this,n,i)||this).movementX=0,o.movementY=0,o.preventSwallow=!1,o._eventType=void 0,o._button=t.BUTTON_MISSING,o._x=0,o._y=0,o._prevX=0,o._prevY=0,o._scrollX=0,o._scrollY=0,o._eventType=n,r&&(o._prevX=r.x,o._prevY=r.y),o}Z(t,e);var n=t.prototype;return n.setScrollData=function(e,t){this._scrollX=e,this._scrollY=t},n.getScrollX=function(){return this._scrollX},n.getScrollY=function(){return this._scrollY},n.setLocation=function(e,t){this._x=e,this._y=t},n.getLocation=function(e){return e||(e=new Wn),Wn.set(e,this._x,this._y),e},n.getLocationInView=function(e){return e||(e=new Wn),Wn.set(e,this._x,c.view._designResolutionSize.height-this._y),e},n.getUILocation=function(e){return e||(e=new Wn),Wn.set(e,this._x,this._y),c.view._convertToUISpace(e),e},n.getPreviousLocation=function(e){return e||(e=new Wn),Wn.set(e,this._prevX,this._prevY),e},n.getUIPreviousLocation=function(e){return e||(e=new Wn),Wn.set(e,this._prevX,this._prevY),c.view._convertToUISpace(e),e},n.getDelta=function(e){return e||(e=new Wn),Wn.set(e,this._x-this._prevX,this._y-this._prevY),e},n.getDeltaX=function(){return this._x-this._prevX},n.getDeltaY=function(){return this._y-this._prevY},n.getUIDelta=function(e){return e||(e=new Wn),Wn.set(e,(this._x-this._prevX)/c.view.getScaleX(),(this._y-this._prevY)/c.view.getScaleY()),e},n.getUIDeltaX=function(){return(this._x-this._prevX)/c.view.getScaleX()},n.getUIDeltaY=function(){return(this._y-this._prevY)/c.view.getScaleY()},n.setButton=function(e){this._button=e},n.getButton=function(){return this._button},n.getLocationX=function(){return this._x},n.getLocationY=function(){return this._y},n.getUILocationX=function(){var e=c.view.getViewportRect();return(this._x-e.x)/c.view.getScaleX()},n.getUILocationY=function(){var e=c.view.getViewportRect();return(this._y-e.y)/c.view.getScaleY()},K(t,[{key:"eventType",get:function(){return this._eventType}}]),t}(BI));UI.BUTTON_MISSING=-1,UI.BUTTON_LEFT=0,UI.BUTTON_RIGHT=2,UI.BUTTON_MIDDLE=1,UI.BUTTON_4=3,UI.BUTTON_5=4,UI.BUTTON_6=5,UI.BUTTON_7=6,UI.BUTTON_8=7,BI.EventMouse=UI;var GI=new Wn,HI=e("EventTouch",function(e){function t(t,n,i,r){var o;return void 0===r&&(r=[]),(o=e.call(this,i,n)||this).touch=null,o.simulate=!1,o.preventSwallow=!1,o._eventCode=void 0,o._touches=void 0,o._allTouches=void 0,o._eventCode=i,o._touches=t||[],o._allTouches=r,o}Z(t,e);var n=t.prototype;return n.getEventCode=function(){return this._eventCode},n.getTouches=function(){return this._touches},n.getAllTouches=function(){return this._allTouches},n.setLocation=function(e,t){this.touch&&this.touch.setTouchInfo(this.touch.getID(),e,t)},n.getLocation=function(e){return this.touch?this.touch.getLocation(e):new Wn},n.getUILocation=function(e){return this.touch?this.touch.getUILocation(e):new Wn},n.getLocationInView=function(e){return this.touch?this.touch.getLocationInView(e):new Wn},n.getPreviousLocation=function(e){return this.touch?this.touch.getPreviousLocation(e):new Wn},n.getStartLocation=function(e){return this.touch?this.touch.getStartLocation(e):new Wn},n.getUIStartLocation=function(e){return this.touch?this.touch.getUIStartLocation(e):new Wn},n.getID=function(){return this.touch?this.touch.getID():null},n.getDelta=function(e){return this.touch?this.touch.getDelta(e):new Wn},n.getUIDelta=function(e){return this.touch?this.touch.getUIDelta(e):new Wn},n.getDeltaX=function(){return this.touch?this.touch.getDelta(GI).x:0},n.getDeltaY=function(){return this.touch?this.touch.getDelta(GI).y:0},n.getLocationX=function(){return this.touch?this.touch.getLocationX():0},n.getLocationY=function(){return this.touch?this.touch.getLocationY():0},t}(BI));HI.MAX_TOUCHES=5,BI.EventTouch=HI;var VI,jI=e("Acceleration",(function(e,t,n,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),this.x=void 0,this.y=void 0,this.z=void 0,this.timestamp=void 0,this.x=e,this.y=t,this.z=n,this.timestamp=i}));!function(e){e[e.NONE=0]="NONE",e[e.MOBILE_BACK=6]="MOBILE_BACK",e[e.BACKSPACE=8]="BACKSPACE",e[e.TAB=9]="TAB",e[e.ENTER=13]="ENTER",e[e.SHIFT_LEFT=16]="SHIFT_LEFT",e[e.CTRL_LEFT=17]="CTRL_LEFT",e[e.ALT_LEFT=18]="ALT_LEFT",e[e.PAUSE=19]="PAUSE",e[e.CAPS_LOCK=20]="CAPS_LOCK",e[e.ESCAPE=27]="ESCAPE",e[e.SPACE=32]="SPACE",e[e.PAGE_UP=33]="PAGE_UP",e[e.PAGE_DOWN=34]="PAGE_DOWN",e[e.END=35]="END",e[e.HOME=36]="HOME",e[e.ARROW_LEFT=37]="ARROW_LEFT",e[e.ARROW_UP=38]="ARROW_UP",e[e.ARROW_RIGHT=39]="ARROW_RIGHT",e[e.ARROW_DOWN=40]="ARROW_DOWN",e[e.INSERT=45]="INSERT",e[e.DELETE=46]="DELETE",e[e.DIGIT_0=48]="DIGIT_0",e[e.DIGIT_1=49]="DIGIT_1",e[e.DIGIT_2=50]="DIGIT_2",e[e.DIGIT_3=51]="DIGIT_3",e[e.DIGIT_4=52]="DIGIT_4",e[e.DIGIT_5=53]="DIGIT_5",e[e.DIGIT_6=54]="DIGIT_6",e[e.DIGIT_7=55]="DIGIT_7",e[e.DIGIT_8=56]="DIGIT_8",e[e.DIGIT_9=57]="DIGIT_9",e[e.KEY_A=65]="KEY_A",e[e.KEY_B=66]="KEY_B",e[e.KEY_C=67]="KEY_C",e[e.KEY_D=68]="KEY_D",e[e.KEY_E=69]="KEY_E",e[e.KEY_F=70]="KEY_F",e[e.KEY_G=71]="KEY_G",e[e.KEY_H=72]="KEY_H",e[e.KEY_I=73]="KEY_I",e[e.KEY_J=74]="KEY_J",e[e.KEY_K=75]="KEY_K",e[e.KEY_L=76]="KEY_L",e[e.KEY_M=77]="KEY_M",e[e.KEY_N=78]="KEY_N",e[e.KEY_O=79]="KEY_O",e[e.KEY_P=80]="KEY_P",e[e.KEY_Q=81]="KEY_Q",e[e.KEY_R=82]="KEY_R",e[e.KEY_S=83]="KEY_S",e[e.KEY_T=84]="KEY_T",e[e.KEY_U=85]="KEY_U",e[e.KEY_V=86]="KEY_V",e[e.KEY_W=87]="KEY_W",e[e.KEY_X=88]="KEY_X",e[e.KEY_Y=89]="KEY_Y",e[e.KEY_Z=90]="KEY_Z",e[e.NUM_0=96]="NUM_0",e[e.NUM_1=97]="NUM_1",e[e.NUM_2=98]="NUM_2",e[e.NUM_3=99]="NUM_3",e[e.NUM_4=100]="NUM_4",e[e.NUM_5=101]="NUM_5",e[e.NUM_6=102]="NUM_6",e[e.NUM_7=103]="NUM_7",e[e.NUM_8=104]="NUM_8",e[e.NUM_9=105]="NUM_9",e[e.NUM_MULTIPLY=106]="NUM_MULTIPLY",e[e.NUM_PLUS=107]="NUM_PLUS",e[e.NUM_SUBTRACT=109]="NUM_SUBTRACT",e[e.NUM_DECIMAL=110]="NUM_DECIMAL",e[e.NUM_DIVIDE=111]="NUM_DIVIDE",e[e.F1=112]="F1",e[e.F2=113]="F2",e[e.F3=114]="F3",e[e.F4=115]="F4",e[e.F5=116]="F5",e[e.F6=117]="F6",e[e.F7=118]="F7",e[e.F8=119]="F8",e[e.F9=120]="F9",e[e.F10=121]="F10",e[e.F11=122]="F11",e[e.F12=123]="F12",e[e.NUM_LOCK=144]="NUM_LOCK",e[e.SCROLL_LOCK=145]="SCROLL_LOCK",e[e.SEMICOLON=186]="SEMICOLON",e[e.EQUAL=187]="EQUAL",e[e.COMMA=188]="COMMA",e[e.DASH=189]="DASH",e[e.PERIOD=190]="PERIOD",e[e.SLASH=191]="SLASH",e[e.BACK_QUOTE=192]="BACK_QUOTE",e[e.BRACKET_LEFT=219]="BRACKET_LEFT",e[e.BACKSLASH=220]="BACKSLASH",e[e.BRACKET_RIGHT=221]="BRACKET_RIGHT",e[e.QUOTE=222]="QUOTE",e[e.SHIFT_RIGHT=2e3]="SHIFT_RIGHT",e[e.CTRL_RIGHT=2001]="CTRL_RIGHT",e[e.ALT_RIGHT=2002]="ALT_RIGHT",e[e.NUM_ENTER=2003]="NUM_ENTER"}(VI||(VI=e("KeyCode",{})));var WI=new Wn,qI=e("Touch",function(){function e(e,t,n){void 0===n&&(n=0),this._point=new Wn,this._prevPoint=new Wn,this._lastModified=0,this._id=0,this._startPoint=new Wn,this._startPointCaptured=!1,this.setTouchInfo(n,e,t)}var t=e.prototype;return t.getLocation=function(e){return e||(e=new Wn),e.set(this._point.x,this._point.y),e},t.getLocationX=function(){return this._point.x},t.getLocationY=function(){return this._point.y},t.getUILocation=function(e){return e||(e=new Wn),e.set(this._point.x,this._point.y),c.view._convertToUISpace(e),e},t.getUILocationX=function(){var e=c.view.getViewportRect();return(this._point.x-e.x)/c.view.getScaleX()},t.getUILocationY=function(){var e=c.view.getViewportRect();return(this._point.y-e.y)/c.view.getScaleY()},t.getPreviousLocation=function(e){return e||(e=new Wn),e.set(this._prevPoint.x,this._prevPoint.y),e},t.getUIPreviousLocation=function(e){return e||(e=new Wn),e.set(this._prevPoint.x,this._prevPoint.y),c.view._convertToUISpace(e),e},t.getStartLocation=function(e){return e||(e=new Wn),e.set(this._startPoint.x,this._startPoint.y),e},t.getUIStartLocation=function(e){return e||(e=new Wn),e.set(this._startPoint.x,this._startPoint.y),c.view._convertToUISpace(e),e},t.getDelta=function(e){return e||(e=new Wn),e.set(this._point),e.subtract(this._prevPoint),e},t.getUIDelta=function(e){return e||(e=new Wn),WI.set(this._point),WI.subtract(this._prevPoint),e.set(c.view.getScaleX(),c.view.getScaleY()),Wn.divide(e,WI,e),e},t.getLocationInView=function(e){return e||(e=new Wn),e.set(this._point.x,c.view._designResolutionSize.height-this._point.y),e},t.getPreviousLocationInView=function(e){return e||(e=new Wn),e.set(this._prevPoint.x,c.view._designResolutionSize.height-this._prevPoint.y),e},t.getStartLocationInView=function(e){return e||(e=new Wn),e.set(this._startPoint.x,c.view._designResolutionSize.height-this._startPoint.y),e},t.getID=function(){return this._id},t.setTouchInfo=function(e,t,n){void 0===e&&(e=0),this._prevPoint=this._point,this._point=new Wn(t||0,n||0),this._id=e,this._startPointCaptured||(this._startPoint=new Wn(this._point),this._startPointCaptured=!0)},t.setPoint=function(e,t){"object"==typeof e?(this._point.x=e.x,this._point.y=e.y):(this._point.x=e||0,this._point.y=t||0),this._lastModified=c.game.frameStartTime},t.setPrevPoint=function(e,t){this._prevPoint="object"==typeof e?new Wn(e.x,e.y):new Wn(e||0,t||0),this._lastModified=c.game.frameStartTime},K(e,[{key:"lastModified",get:function(){return this._lastModified}}]),e}());c.Touch=qI;var XI,YI,KI=function(){function e(){this._intervalInMileSeconds=200,this._accelTimer=0,this._eventTarget=new Zl,this._deviceEventName=void 0,this._globalEventClass=void 0,this._didAccelerateFunc=void 0,this._globalEventClass=window.DeviceMotionEvent||window.DeviceOrientationEvent,hu.browserType===$l.MOBILE_QQ&&(this._globalEventClass=window.DeviceOrientationEvent),this._deviceEventName=this._globalEventClass===window.DeviceMotionEvent?"devicemotion":"deviceorientation",this._didAccelerateFunc=this._didAccelerate.bind(this)}var t=e.prototype;return t._registerEvent=function(){this._accelTimer=performance.now(),window.addEventListener(this._deviceEventName,this._didAccelerateFunc,!1)},t._unregisterEvent=function(){this._accelTimer=0,window.removeEventListener(this._deviceEventName,this._didAccelerateFunc,!1)},t._didAccelerate=function(e){var t=performance.now();if(!(t-this._accelTimerct.TOUCH_TIMEOUT&&(console.log("The touches is more than MAX_TOUCHES, release touch id "+e.getID()+"."),t.releaseTouch(e.getID()))})),n>=this._touchMap.size},e}()),tD=function(){function e(){this._canvas=void 0,this._eventTarget=new Zl,hu.hasFeature(ru.INPUT_TOUCH)&&(this._canvas=document.getElementById("GameCanvas"),this._canvas||console.warn("failed to access canvas"),this._registerEvent())}var t=e.prototype;return t._registerEvent=function(){var e,t,n,i;null===(e=this._canvas)||void 0===e||e.addEventListener("touchstart",this._createCallback(Lb.TOUCH_START)),null===(t=this._canvas)||void 0===t||t.addEventListener("touchmove",this._createCallback(Lb.TOUCH_MOVE)),null===(n=this._canvas)||void 0===n||n.addEventListener("touchend",this._createCallback(Lb.TOUCH_END)),null===(i=this._canvas)||void 0===i||i.addEventListener("touchcancel",this._createCallback(Lb.TOUCH_CANCEL))},t._createCallback=function(e){var t=this;return function(n){for(var i,r=t._getCanvasRect(),o=[],a=n.changedTouches.length,s=0;s0){var f=new HI(o,!1,e,ct.ENABLE_MULTI_TOUCH?eD.getAllTouches():o);t._eventTarget.emit(e,f)}}},t._getCanvasRect=function(){var e=this._canvas,t=null==e?void 0:e.getBoundingClientRect();return t?new ei(t.x,t.y,t.width,t.height):new ei(0,0,0,0)},t._getLocation=function(e,t){var n=e.clientX-t.x,i=t.y+t.height-e.clientY;if(nh.isFrameRotated){var r=n;n=t.height-i,i=r}var o=nh.devicePixelRatio;return new Wn(n*=o,i*=o)},t.on=function(e,t,n){this._eventTarget.on(e,t,n)},e}();!function(e){e[e.GLOBAL=0]="GLOBAL",e[e.UI=1]="UI"}(YI||(YI={}));var nD=function(){function e(e){this.priority=YI.GLOBAL,this._inputEventTarget=void 0,this._inputEventTarget=e}return e.prototype.dispatchEvent=function(e){return this._inputEventTarget.emit(e.type,e),!0},e}(),iD=((XI={})[Lb.MOUSE_DOWN]=Lb.TOUCH_START,XI[Lb.MOUSE_MOVE]=Lb.TOUCH_MOVE,XI[Lb.MOUSE_UP]=Lb.TOUCH_END,XI),rD=e("Input",function(){function e(){this._dispatchImmediately=!0,this._eventTarget=new Zl,this._touchInput=new tD,this._mouseInput=new JI,this._keyboardInput=new ZI,this._accelerometerInput=new KI,this._eventTouchList=[],this._eventMouseList=[],this._eventKeyboardList=[],this._eventAccelerationList=[],this._needSimulateTouchMoveEvent=!1,this._inputEventDispatcher=void 0,this._eventDispatcherList=[],this._registerEvent(),this._inputEventDispatcher=new nD(this._eventTarget),this._registerEventDispatcher(this._inputEventDispatcher)}var t=e.prototype;return t.on=function(e,t,n){return this._eventTarget.on(e,t,n),t},t.once=function(e,t,n){return this._eventTarget.once(e,t,n),t},t.off=function(e,t,n){this._eventTarget.off(e,t,n)},t.setAccelerometerEnabled=function(e){e?this._accelerometerInput.start():this._accelerometerInput.stop()},t.setAccelerometerInterval=function(e){this._accelerometerInput.setInterval(e)},t._simulateEventTouch=function(e){var t=iD[e.type],n=eD.getTouch(0,e.getLocationX(),e.getLocationY());if(n){var i=[n],r=new HI(i,!1,t,i);t===Lb.TOUCH_END&&eD.releaseTouch(0),this._dispatchOrPushEventTouch(r,this._eventTouchList)}},t._registerEventDispatcher=function(e){this._eventDispatcherList.push(e),this._eventDispatcherList.sort((function(e,t){return t.priority-e.priority}))},t._emitEvent=function(e){for(var t=this._eventDispatcherList.length,n=0;n>>1;r<=o;a=r+o>>>1){var s=e[a],c=s.constructor._executionOrder;if(c>n)o=a-1;else if(ci)o=a-1;else{if(!(l0&&(e.array.sort(AD),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(AD),this._invoke(t),t.array.length=0)},t}(ED),bD=function(e){function t(){return e.apply(this,arguments)||this}Z(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=SD(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=SD(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}(ED);function wD(e,t,n){var i="var a=it.array;for(it.i=0;it.i=0?vD(this._deferredComps,t):(!e.start||e._objFlags&yD||this.startInvoker.remove(e),e.update&&this.updateInvoker.remove(e),e.lateUpdate&&this.lateUpdateInvoker.remove(e))},t.enableComp=function(e,t){if(!(e._objFlags&xD)){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&xD&&(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&yD||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;t0){this._renderQueues.forEach(WS);for(var S=0;S0&&(r.bindPipelineState(f),r.bindInputAssembler(h),r.draw(h)),this._uiPhase.render(e,c),Qg(n,c,r,t.profiler,e),r.endRenderPass()},t}(Ly),kO.initInfo={name:"PostProcessStage",priority:Xy.POST_PROCESS,tag:0},BO=se((FO=UO).prototype,"_postProcessMaterial",[DO,gc,OO],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),zO=se(FO.prototype,"renderQueues",[MO,gc,NO],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),LO=FO))||LO));!function(e){e[e.NONE=0]="NONE",e[e.FXAA=1]="FXAA"}(GO||(GO={}));var QO,ZO,JO,$O,eM,tM,nM,iM,rM=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r>=1,this._renderArea.height>>=1;var n=t.commandBuffers[0],i=t.pipelineSceneData.bloomMaterial.passes[0],r=t.getPipelineRenderData(),o=r.bloom,a=new Float32Array(aM.COUNT);a[aM.TEXTURE_SIZE_OFFSET+2]=this.threshold,n.updateBuffer(this._bloomUBO[0],a),n.beginRenderPass(o.renderPass,o.prefilterFramebuffer,this._renderArea,oM,0,0),n.bindDescriptorSet(Hp.GLOBAL,t.descriptorSet),i.descriptorSet.bindBuffer(0,this._bloomUBO[0]),i.descriptorSet.bindTexture(1,r.outputRenderTargets[0]),i.descriptorSet.bindSampler(1,o.sampler),i.descriptorSet.update(),n.bindDescriptorSet(Hp.MATERIAL,i.descriptorSet);var s=e.window.swapchain?t.quadIAOffscreen:t.quadIAOnscreen,c=null,l=i.getShaderVariant();null!=i&&null!=l&&null!=s&&(c=Lg.getOrCreatePipelineState(t.device,i,l,o.renderPass,s)),null!=c&&(n.bindPipelineState(c),n.bindInputAssembler(s),n.draw(s)),n.endRenderPass()},n._downsamplePass=function(e,t){t.generateRenderArea(e,this._renderArea),this._renderArea.width>>=1,this._renderArea.height>>=1;for(var n=t.commandBuffers[0],i=t.pipelineSceneData.bloomMaterial,r=t.getPipelineRenderData().bloom,o=new Float32Array(aM.COUNT),a=0;a>=1,this._renderArea.height>>=1,n.beginRenderPass(r.renderPass,r.downsampleFramebuffers[a],this._renderArea,oM,0,0);var s=i.passes[1+a],c=s.getShaderVariant();s.descriptorSet.bindBuffer(0,this._bloomUBO[a+1]),0===a?s.descriptorSet.bindTexture(1,r.prefiterTex):s.descriptorSet.bindTexture(1,r.downsampleTexs[a-1]),s.descriptorSet.bindSampler(1,r.sampler),s.descriptorSet.update(),n.bindDescriptorSet(Hp.MATERIAL,s.descriptorSet);var l=e.window.swapchain?t.quadIAOffscreen:t.quadIAOnscreen,u=null;null!=s&&null!=c&&null!=l&&(u=Lg.getOrCreatePipelineState(t.device,s,c,r.renderPass,l)),null!=u&&(n.bindPipelineState(u),n.bindInputAssembler(l),n.draw(l)),n.endRenderPass()}},n._upsamplePass=function(e,t){var n=t.getPipelineRenderData().bloom;t.generateRenderArea(e,this._renderArea),this._renderArea.width>>=this.iterations+1,this._renderArea.height>>=this.iterations+1;for(var i=t.commandBuffers[0],r=t.pipelineSceneData.bloomMaterial,o=new Float32Array(aM.COUNT),a=0;ai.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 iv,this.logoMat.initialize({effectName:"splash-screen"});var t=new mr;t.addressU=Ei.CLAMP,t.addressV=Ei.CLAMP,t.addressW=Ei.CLAMP,this.sampler=e.getSampler(t),this.logoTexture=e.createTexture(new pr(gi.TEX2D,vi.SAMPLED|vi.TRANSFER_DST,ui.RGBA8,this.logoImage.width,this.logoImage.height));var n=this.logoMat.passes[0],i=n.getBinding("mainTexture");n.bindTexture(i,this.logoTexture),this.shader=n.getShaderVariant();var r=n.descriptorSet;r.bindSampler(i,this.sampler),r.update();var o=new ir;o.texExtent.width=this.logoImage.width,o.texExtent.height=this.logoImage.height,o.texExtent.depth=1,e.copyTexImagesToTexture([this.logoImage],this.logoTexture,[o])},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 r=new ir;r.texExtent.width=e.width,r.texExtent.height=e.height,r.texExtent.depth=1,this.watermarkTexture=this.device.createTexture(new pr(gi.TEX2D,vi.SAMPLED|vi.TRANSFER_DST,ui.RGBA8,e.width,e.height)),this.device.copyTexImagesToTexture([e],this.watermarkTexture,[r]),this.watermarkMat=new iv,this.watermarkMat.initialize({effectName:"splash-screen"});var o=this.watermarkMat.passes[0],a=o.getBinding("mainTexture");o.bindTexture(a,this.watermarkTexture),o.descriptorSet.update()},e.frame=function(){var e=this.device,t=this.swapchain;e.acquire([t]);var n=this.cmdBuff,i=this.framebuffer,r=this.renderArea;r.width=t.width,r.height=t.height,n.begin(),n.beginRenderPass(i.renderPass,i,r,this.clearColors,1,0);var o=this.logoMat.passes[0],a=Lg.getOrCreatePipelineState(e,o,this.shader,i.renderPass,this.quadAssmebler);if(n.bindPipelineState(a),n.bindDescriptorSet(Hp.MATERIAL,o.descriptorSet),n.bindInputAssembler(this.quadAssmebler),n.draw(this.quadAssmebler),this.settings.displayWatermark&&this.watermarkMat){var s=this.watermarkMat.passes[0],c=Lg.getOrCreatePipelineState(e,s,this.shader,i.renderPass,this.quadAssmebler);n.bindPipelineState(c),n.bindDescriptorSet(Hp.MATERIAL,s.descriptorSet),n.bindInputAssembler(this.quadAssmebler),n.draw(this.quadAssmebler)}n.endRenderPass(),n.end(),e.flushCommands([n]),e.queue.submit([n]),e.present()},e.destroy=function(){this.callBack=null,this.device=null,this.swapchain=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=null,this.watermarkTexture&&(this.watermarkMat.destroy(),this.watermarkMat=null,this.watermarkTexture.destroy(),this.watermarkTexture=null),this.settings=null,t._ins=void 0},K(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}();EM._ins=void 0,c.internal.SplashScreen=EM;var AM=e("System",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(){},K(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}());AM.Priority=it({LOW:0,MEDIUM:100,HIGH:200,SCHEDULER:1<<31>>>0});var CM=new pe("Scheduler"),bM=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};bM.get=function(e,t,n,i){var r=bM._listEntries.pop();return r?(r.target=e,r.priority=t,r.paused=n,r.markedForDeletion=i):r=new bM(e,t,n,i),r},bM.put=function(e){bM._listEntries.length<20&&(e.target=null,bM._listEntries.push(e))},bM._listEntries=[];var wM=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};wM.get=function(e,t,n,i){var r=wM._hashUpdateEntries.pop();return r?(r.list=e,r.entry=t,r.target=n,r.callback=i):r=new wM(e,t,n,i),r},wM.put=function(e){wM._hashUpdateEntries.length<20&&(e.list=e.entry=e.target=e.callback=null,wM._hashUpdateEntries.push(e))},wM._hashUpdateEntries=[];var RM=function(e,t,n,i,r,o){this.timers=void 0,this.target=void 0,this.timerIndex=void 0,this.currentTimer=void 0,this.currentTimerSalvaged=void 0,this.paused=void 0,this.timers=e,this.target=t,this.timerIndex=n,this.currentTimer=i,this.currentTimerSalvaged=r,this.paused=o};RM.get=function(e,t,n,i,r,o){var a=RM._hashTimerEntries.pop();return a?(a.timers=e,a.target=t,a.timerIndex=n,a.currentTimer=i,a.currentTimerSalvaged=r,a.paused=o):a=new RM(e,t,n,i,r,o),a},RM.put=function(e){RM._hashTimerEntries.length<20&&(e.timers=e.target=e.currentTimer=null,RM._hashTimerEntries.push(e))},RM._hashTimerEntries=[];var PM=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,r,o){return this._lock=!1,this._scheduler=e,this._target=n,this._callback=t,this._elapsed=-1,this._interval=i,this._delay=o,this._useDelay=this._delay>0,this._repeat=r,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}();PM._timers=[],PM.get=function(){return PM._timers.pop()||new PM},PM.put=function(e){PM._timers.length<20&&!e._lock&&(e._scheduler=e._target=e._callback=null,PM._timers.push(e))};var IM,DM=e("Scheduler",function(e){function t(){var t;return(t=e.call(this)||this)._timeScale=void 0,t._updatesNegList=void 0,t._updates0List=void 0,t._updatesPosList=void 0,t._hashForUpdates=void 0,t._hashForTimers=void 0,t._currentTarget=void 0,t._currentTargetSalvaged=void 0,t._updateHashLocked=void 0,t._arrayForTimers=void 0,t._timeScale=1,t._updatesNegList=[],t._updates0List=[],t._updatesPosList=[],t._hashForUpdates=be(!0),t._hashForTimers=be(!0),t._currentTarget=null,t._currentTargetSalvaged=!1,t._updateHashLocked=!1,t._arrayForTimers=[],t}Z(t,e),t.enableForTarget=function(e){var t=!1;(e.uuid||e.id)&&(t=!0),t||(e.__instanceId?P(1513):e.id=CM.getNewId())};var n=t.prototype;return n.setTimeScale=function(e){this._timeScale=e},n.getTimeScale=function(){return this._timeScale},n.update=function(e){var t,n,i,r,o;for(this._updateHashLocked=!0,1!==this._timeScale&&(e*=this._timeScale),t=0,i=(n=this._updatesNegList).length;t=o&&i.timerIndex--,void(0===r.length&&(this._currentTarget===i?this._currentTargetSalvaged=!0:this._removeHashElement(i)))}}else D(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 D(1510)}},n.unscheduleAllForTarget=function(e){if(e){var t=e.uuid||e.id;if(t){var n=this._hashForTimers[t];if(n){var i=n.timers;i.indexOf(n.currentTimer)>-1&&!n.currentTimerSalvaged&&(n.currentTimerSalvaged=!0);for(var r=0,o=i.length;r=0;t--)n=r[t],this.unscheduleAllForTarget(n.target);var o=0;if(e<0)for(t=0;t=e&&this.unscheduleUpdate(i.target),o===this._updatesNegList.length&&t++;if(e<=0)for(t=0;t=e&&this.unscheduleUpdate(i.target),o===this._updatesPosList.length&&t++},n.isScheduled=function(e,t){N(e,1508),N(t,1509);var n=t.uuid||t.id;if(!n)return D(1510),!1;var i=this._hashForTimers[n];if(!i)return!1;if(null==i.timers)return!1;for(var r=i.timers,o=0;o=e&&(r.paused=!0,o.push(r.target));if(e<=0)for(n=0;n=e&&(r.paused=!0,o.push(r.target));return o},n.resumeTargets=function(e){if(e)for(var t=0;t1&&(this._fps=this._frameCount,this._frameCount=0,this._fpsTime=0);for(var t=0;t0){this._device.acquire([c.game._swapchain]);var o=this._scenes,a=c.director.getTotalFrames();this._batcher&&(this._batcher.update(),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:"useDeferredPipeline",get:function(){return this._useDeferredPipeline}}]),t}();c.Root=NM;var LM=e("Game",function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;rthis._startTime?(e-this._startTime)/1e3:0,this._deltaTime>t.DEBUG_DT_THRESHOLD&&(this._deltaTime=this.frameTime/1e3),this._startTime=e,this._deltaTime},i._updateCallback=function(){var e,t=this,n=c.director;if(30===this._frameRate){var i=!0;e=function(e){t._intervalId=window.rAF(t._frameCB),(i=!i)||n.tick(t._calculateDT(e))}}else e=function(e){n.tick(t._calculateDT(e)),t._intervalId=window.rAF(t._frameCB)};this._frameCB=e},i._runMainLoop=function(){if(this._inited){var e=this.config,t=c.director;B(!!e.showFPS),t.startAnimation(),this.resume()}},i._initConfig=function(e){"number"!=typeof e.debugMode&&(e.debugMode=O.NONE),e.exposeClassName=!!e.exposeClassName,"number"!=typeof e.frameRate&&(e.frameRate=60);var t=e.renderMode;("number"!=typeof t||t>3||t<0)&&(e.renderMode=0),e.showFPS=!!e.showFPS,E(e.debugMode),this.config=e,this._configLoaded=!0,this.frameRate=e.frameRate},i._determineRenderType=function(){var e=this.config,n=parseInt(e.renderMode,10);this.renderType=t.RENDER_TYPE_CANVAS;var i=!1;if(1===n?(this.renderType=t.RENDER_TYPE_CANVAS,i=!0):0===n||2===n?(this.renderType=t.RENDER_TYPE_WEBGL,i=!0):3===n&&(this.renderType=t.RENDER_TYPE_HEADLESS,i=!0),!i)throw new Error(L(3820,n))},i._initDevice=function(){if(!this._rendererInitialized){var e=this.config.adapter;if(e&&(this.canvas=e.canvas,this.frame=e.frame,this.container=e.container),this._determineRenderType(),this.renderType===t.RENDER_TYPE_WEBGL){var n=new cr(Wp),i=!!window.WebGL2RenderingContext,r=window.navigator.userAgent.toLowerCase();(-1!==r.indexOf("safari")&&-1===r.indexOf("chrome")||oh.browserType===$l.UC)&&(i=!1);var o=[];i&&c.WebGL2Device&&o.push(c.WebGL2Device),c.WebGLDevice&&o.push(c.WebGLDevice),c.EmptyDevice&&o.push(c.EmptyDevice),lo.canvas=this.canvas;for(var a=0;a0&&t>0){this._updateResolutionPolicy(n);var i=this._resolutionPolicy;i&&i.preApply(this),this._designResolutionSize.width=e,this._designResolutionSize.height=t;var r=i.apply(this,this._designResolutionSize);if(r.scale&&2===r.scale.length&&(this._scaleX=r.scale[0],this._scaleY=r.scale[1]),r.viewport){var o=this._viewportRect,a=this._visibleRect,s=r.viewport;o.x=s.x,o.y=s.y,o.width=s.width,o.height=s.height,a.x=0,a.y=0,a.width=s.width/this._scaleX,a.height=s.height/this._scaleY}i.postApply(this),HM.width=this._visibleRect.width,HM.height=this._visibleRect.height,GM&&GM.init(this._visibleRect),this.emit("design-resolution-changed")}else D(2200)},n.getDesignResolutionSize=function(){return new Jn(this._designResolutionSize.width,this._designResolutionSize.height)},n.setRealPixelResolution=function(e,t,n){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 nh.devicePixelRatio},n.convertToLocationInView=function(e,t,n,i){void 0===i&&(i=new Wn);var r=nh.devicePixelRatio*(e-n.left),o=nh.devicePixelRatio*(n.top+n.height-t);return nh.isFrameRotated?(i.x=rh.windowSize.width-o,i.y=r):(i.x=r,i.y=o),i},n._convertToUISpace=function(e){var t=this._viewportRect;e.x=(e.x-t.x)/this._scaleX,e.y=(e.y-t.y)/this._scaleY},n._updateAdaptResult=function(){var e;c.director.root.resize(rh.windowSize.width,rh.windowSize.height);var t=this._designResolutionSize.width,n=this._designResolutionSize.height;t>0&&this.setDesignResolutionSize(t,n,this._resolutionPolicy),this.emit("canvas-resize"),null===(e=this._resizeCallback)||void 0===e||e.call(this)},t}(Zl));jM.instance=void 0;var WM=function(){function e(){this.name="ContainerStrategy"}var t=e.prototype;return t.preApply=function(){},t.apply=function(){},t.postApply=function(){},t._setupCanvas=function(){var e=FM.canvas;if(e){var t=rh.windowSize;e.width=t.width,e.height=t.height}},e}();WM.EQUAL_TO_FRAME=void 0,WM.PROPORTION_TO_FRAME=void 0;var qM=function(){function e(){this.name="ContentStrategy",this._result=void 0,this._result={scale:[1,1],viewport:null}}var t=e.prototype;return t.preApply=function(){},t.apply=function(){return{scale:[1,1]}},t.postApply=function(){},t._buildResult=function(e,t,n,i,r,o){Math.abs(e-n)<2&&(n=e),Math.abs(t-i)<2&&(i=t);var a=new ei(Math.round((e-n)/2),Math.round((t-i)/2),n,i);return this._result.scale=[r,o],this._result.viewport=a,this._result},e}();qM.EXACT_FIT=void 0,qM.SHOW_ALL=void 0,qM.NO_BORDER=void 0,qM.FIXED_HEIGHT=void 0,qM.FIXED_WIDTH=void 0,function(){var e=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;rt.length)||47===e.charCodeAt(t.length)}(r,e)||!e)for(var o=0,a=n.length;o0&&function(e){var t=Object.create(null);if(t[e._uuid]=e.refCount,$M(e,t,eN,-1),eN.length=0,0!==t[e._uuid])return t[e._uuid];for(var n in t)0!==t[n]&&$M(ml.get(n),t,eN,1);return eN.length=0,t[e._uuid]}(e)>0)){ml.remove(n);for(var i=tg.getDeps(n),r=0,o=i.length;rthis._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&&(vt(this._handleQueue.bind(this),e,t),this._checkNextPeriod=!0)},K(e,[{key:"remoteServerAddress",get:function(){return this._remoteServerAddress}}]),e}());function PN(e,t,n,i){var r=null,o=null;try{(r=new Km)._nativeUrl=e,r._nativeAsset=t}catch(e){o=e}i(o,r)}function IN(e,t,n,i){var r=new iO;r.json=t,i(null,r)}function DN(e,t,n,i){var r=new nO;r.text=t,i(null,r)}function ON(e,t,n,i){var r=new Rb;r._nativeUrl=e,r._nativeAsset=t,i(null,r)}function MN(e,t,n,i){var r=new Ru;r._nativeUrl=e,r._nativeAsset=t,i(null,r)}function NN(e,n,i,r){var o=yl.get(n.name);o||(o=n.name===El.RESOURCES?pN:new _N,n.base=n.base||e+"/",o.init(n)),t.import("virtual:///prerequisite-imports/"+o.name).then((function(){r(null,o)})).catch(r)}var LN=new(function(){function e(){this._creating=new _l,this._producers={".png":PN,".jpg":PN,".bmp":PN,".jpeg":PN,".gif":PN,".ico":PN,".tiff":PN,".webp":PN,".image":PN,".pvr":PN,".pkm":PN,".txt":DN,".xml":DN,".vsh":DN,".fsh":DN,".atlas":DN,".tmx":DN,".tsx":DN,".fnt":DN,".json":IN,".ExportJson":IN,".binary":ON,".bin":ON,".dbbin":ON,".skel":ON,bundle:NN,default:MN}}var t=e.prototype;return t.register=function(e,t){"object"==typeof e?tt.mixin(this._producers,e):this._producers[e]=t},t.create=function(e,t,n,i,r){var o=this,a=this._producers[n]||this._producers.default,s=ml.get(e);if(i.reloadAsset||!s){var c=this._creating.get(e);c?c.push(r):(this._creating.add(e,[r]),a(e,t,i,(function(t,n){!t&&n instanceof Ru&&(n._uuid=e,sN(e,n,i.cacheAsset));for(var r=o._creating.remove(e),a=0,s=r.length;a0){var a=Cl.create({input:o,progress:r,options:i,onProgress:e.onProgress,onError:Cl.prototype.recycle,onComplete:function(i){var r;i||((r=e.output).push.apply(r,a.output),a.recycle()),n&&zN(e),t(i)}});Sl.async(a)}else n&&zN(e),t()}))}function zN(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?bm.RGBA_ASTC_4x4:5===e?4===t?bm.RGBA_ASTC_5x4:bm.RGBA_ASTC_5x5:6===e?5===t?bm.RGBA_ASTC_6x5:bm.RGBA_ASTC_6x6:8===e?5===t?bm.RGBA_ASTC_8x5:6===t?bm.RGBA_ASTC_8x6:bm.RGBA_ASTC_8x8:10===e?5===t?bm.RGBA_ASTC_10x5:6===t?bm.RGBA_ASTC_10x6:8===t?bm.RGBA_ASTC_10x8:bm.RGBA_ASTC_10x10:10===t?bm.RGBA_ASTC_12x10:bm.RGBA_ASTC_12x12}(s,c),h=a[7]+(a[8]<<8)+(a[9]<<16),f=a[10]+(a[11]<<8)+(a[12]<<16);a[13],a[14],a[15],r={_data:new Uint8Array(o,16),_compressed:!0,width:h,height:f,format:u}}catch(e){i=e}n(i,r)},t.parsePlist=function(e,t,n){var i=null,r=UN.parse(e);r||(i=new Error("parse failed")),n(i,r)},t.parseImport=function(e,t,n){if(e){var i=null,r=null;try{i=$m(e,t)}catch(e){r=e}n(r,i)}else n(new Error("The json file of asset "+t.__uuid__+" is empty or missing"))},t.init=function(){this._parsing.clear()},t.register=function(e,t){"object"==typeof e?Be(this._parsers,e):this._parsers[e]=t},t.parse=function(e,t,n,i,r){var o=this,a=vl.get(e);if(a)r(null,a);else{var s=this._parsing.get(e);if(s)s.push(r);else{var c=this._parsers[n];c?(this._parsing.add(e,[r]),c(t,i,(function(t,n){t?gl.remove(e):Nl(n)||vl.add(e,n);for(var i=o._parsing.remove(e),r=0,a=i.length;r1){var l=Object.create(null);t.forEach((function(e){l[e._uuid]=e})),r={isCompleted:eL,_map:l}}else r=t[0]}n&&n(e,r)}))},t.getXMLHttpRequest=function(){return new XMLHttpRequest},t.getItem=function(e){return ZN.assets.has(e)?{content:ZN.assets.get(e)}:null},t.loadRes=function(e,t,n,i){var r=this._parseLoadResArgs(t,n,i),o=r.type,a=r.onProgress,s=r.onComplete,c=mu(e);c&&!pN.getInfoWithPath(e,o)&&(e=e.slice(0,-c.length)),pN.load(e,o,a,s)},t.loadResArray=function(e,t,n,i){var r=this._parseLoadResArgs(t,n,i),o=r.type,a=r.onProgress,s=r.onComplete;e.forEach((function(t,n){var i=mu(t);i&&!pN.getInfoWithPath(t,o)&&(e[n]=t.slice(0,-i.length))})),pN.load(e,o,a,s)},t.loadResDir=function(e,t,n,i){var r=this._parseLoadResArgs(t,n,i),o=r.type,a=r.onProgress,s=r.onComplete;pN.loadDir(e,o,a,(function(t,n){var i=[];t||(i=pN.getDirWithPath(e,o).map((function(e){return e.path}))),s&&s(t,n,i)}))},t.getRes=function(e,t){return ml.has(e)?ml.get(e):pN.get(e,t)},t.getResCount=function(){return ml.count},t.getDependsRecursively=function(e){if(!e)return[];var t="string"==typeof e?e:e._uuid;return tg.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);RN.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);HN.register(t)},t.release=function(e){if(Array.isArray(e))for(var t=0;t1?n-1:0),r=1;r=this._materials.length?null:this._materials[e]},n.setMaterial=function(e,t){e&&e instanceof hT&&console.error("Can't set a material instance to a sharedMaterial slot"),this._materials[t]=e;var n=this._materialInstances[t];n&&(n.destroy(),this._materialInstances[t]=null),this._onMaterialModified(t,this._materials[t])},n.getMaterialInstance=function(e){if(!this._materials[e])return null;if(!this._materialInstances[e]){cB.parent=this._materials[e],cB.owner=this,cB.subModelIdx=e;var t=new hT(cB);cB.parent=null,cB.owner=null,cB.subModelIdx=0,this.setMaterialInstance(t,e)}return this._materialInstances[e]},n.setMaterialInstance=function(e,t){if("number"==typeof e){P(12007);var n=e;e=t,t=n}var i=this._materialInstances[t];e&&e.parent?e!==i&&(this._materialInstances[t]=e,this._onMaterialModified(t,e)):(e!==this._materials[t]||i)&&this.setMaterial(e,t)},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(){},K(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(i,e)}}:{set:function(e){t.setUniform(i,e)}}}var r=Ng.getBindingFromHandle(n),o=t.properties[this.uniformName],a=o&&o.value?o.value+"-texture":sm(o.type),s=wg.get(a);return s||(y("Illegal texture default value: "+a+"."),s=wg.get("default-texture")),{set:function(e){e||(e=s);var n=e.getGFXTexture();n&&n.width&&n.height&&(t.bindTexture(r,n),e instanceof Xm&&t.bindSampler(r,c.game._gfxDevice.getSampler(e.getSamplerInfo())))}}},e}(),_B=se((fB=mB).prototype,"passIndex",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),pB=se(fB.prototype,"uniformName",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),dB=se(fB.prototype,"channelIndex",[Hc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){}}),hB=fB))||hB,FB=hc("cc.animation.MorphWeightValueProxy")((SB=function(){function e(){ae(this,"subMeshIndex",yB,this),ae(this,"shapeIndex",xB,this)}return e.prototype.forTarget=function(e){var t=this;return{set:function(n){e.setWeight(n,t.subMeshIndex,t.shapeIndex)}}},e}(),yB=se((vB=SB).prototype,"subMeshIndex",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),xB=se(vB.prototype,"shapeIndex",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),gB=vB))||gB,BB=hc("cc.animation.MorphWeightsValueProxy")((CB=function(){function e(){ae(this,"subMeshIndex",AB,this)}return e.prototype.forTarget=function(e){var t=this;return{set:function(n){e.setWeights(n,t.subMeshIndex)}}},e}(),AB=se((EB=CB).prototype,"subMeshIndex",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),TB=EB))||TB,zB=hc("cc.animation.MorphWeightsAllValueProxy")(bB=function(){function e(){}return e.prototype.forTarget=function(e){return{set:function(t){for(var n,i,r=null!==(n=null===(i=e.mesh)||void 0===i?void 0:i.struct.primitives.length)&&void 0!==n?n:0,o=0;o1e-6){i=!1;break}this._findRatio=i?ak:nc}return e.prototype.sample=function(e){return this._findRatio(this.ratios,e)},e}());c.RatioSampler=nk;var ik=e("AnimCurve",function(){function e(t,n){this.types=void 0,this.type=null,this._values=[],this._lerp=void 0,this._duration=void 0,this._array=void 0,this._duration=n,this._values=t.values;var i=function(t){return"string"==typeof t?t:Array.isArray(t)?t[0]===t[1]&&t[2]===t[3]?e.Linear:e.Bezier(t):e.Linear};if(void 0!==t.easingMethod)this.type=i(t.easingMethod);else if(Array.isArray(t.easingMethods))this.types=t.easingMethods.map(i);else if(void 0!==t.easingMethods){this.types=new Array(this._values.length).fill(null);for(var r=0,o=Object.keys(t.easingMethods);r=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 ok(e,t){if("string"==typeof t){var n=Zf[t];n?e=n(e):D(3906,t)}else Array.isArray(t)&&(e=X_(t,e));return e}function ak(e,t){var n=e.length-1;if(0===n)return 0;var i=e[0];if(tr)return n;var o=(t=(t-i)/(r-i))/(1/n),a=0|o,s=1e-6;return o-a=0)n=r;else{var o=~r,a=o-1;n=a;var s=e[o],c=e[a];i=(t-c)/(s-c)}return{index:n,ratio:i}}!function(){function e(){this._reset()}var t=e.prototype;t.transformTime=function(e){return e-this._timeOffset},t.calculate=function(e,t,n){this._reset();var i=e.length;if(i){var r=e[0],o=e[i-1],a=on(t,r,o),s=on(n,r,o);this._timeOffset=a;var c=function(e,t,n){var i=e.length;n>=t&&t>=e[0]&&e[i-1];var r=sU(e,t),o=r.index,a=r.ratio,s=sU(e,n);return{fromIndex:o,fromRatio:a,toIndex:s.index,toRatio:s.ratio}}(e,a,s),l=c.fromIndex,u=c.fromRatio,h=c.toIndex,f=c.toRatio,_=!u,p=!f;l!==h||u!==f?(_||(this.preLerpIndex=l,this.preLerpRatio=u),this.directKeyframesBegin=_?l:l+1,this.directKeyframesEnd=h+1,p||(this.postLerpIndex=h,this.postLerpRatio=f)):_?(this.directKeyframesBegin=l,this.directKeyframesEnd=l+1):(this.preLerpIndex=l,this.preLerpRatio=u)}},t._reset=function(){this.preLerpIndex=-1,this.preLerpRatio=0,this.directKeyframesBegin=0,this.directKeyframesEnd=0,this.postLerpIndex=-1,this.postLerpRatio=0,this._timeOffset=0},K(e,[{key:"keyframesCount",get:function(){var e=this.preLerpIndex,t=this.directKeyframesBegin;return 0+(e<0?0:1)+(this.directKeyframesEnd-t)+(this.postLerpIndex<0?0:1)}}])}();var cU,lU=function(){function e(e,t){this._nodeEvaluations=void 0,this._nodeEvaluations=e.map((function(e){return e.createEvaluator(t)}))}return e.prototype.evaluate=function(e){this._nodeEvaluations.forEach((function(t){t.evaluate(e)}))},e}(),uU=function(){function e(e,t,n,i,r){this._position=null,this._rotation=null,this._scale=null,t&&(this._position=PU(t.times,t.values,bn,e,"position",r)),n&&(this._rotation=PU(n.times,n.values,Mn,e,"rotation",r)),i&&(this._scale=PU(i.times,i.values,bn,e,"scale",r))}return e.prototype.evaluate=function(e){if(this._position){var t=this._position.evaluator.evaluate(e);this._position.runtimeBinding.setValue(t)}if(this._rotation){var n=this._rotation.evaluator.evaluate(e);this._rotation.runtimeBinding.setValue(n)}if(this._scale){var i=this._scale.evaluator.evaluate(e);this._scale.runtimeBinding.setValue(i)}},e}(),hU=function(){function e(e,t,n){this._times=void 0,this._inputSampleResultCache={just:!1,index:-1,nextIndex:-1,ratio:0},this._values=void 0,this._prevValue=void 0,this._nextValue=void 0,this._resultValue=void 0,this._times=e,this._values=t,this._prevValue=new n,this._nextValue=new n,this._resultValue=new n}return e.prototype.evaluate=function(e){var t=this._times,n=this._values,i=this._resultValue;if(0===t.length)return i;var r=function(e,t,n){var i=e.length,r=e[0],o=e[i-1];if(to)n.just=!0,n.index=i-1;else{var a=nc(e,t);if(a>=0)n.just=!0,n.index=a;else{var s=~a,c=s-1,l=e[c],u=e[s],h=(t-e[c])/(u-l);n.just=!1,n.index=c,n.nextIndex=s,n.ratio=h}}return n}(t,e,this._inputSampleResultCache);return r.just?n.get(r.index,i):n.lerp(r.index,r.nextIndex,r.ratio,this._prevValue,this._nextValue,i),i},e}(),fU={uint8:Uint8Array,uint16:Uint16Array};function _U(e){switch(e.BYTES_PER_ELEMENT){default:case 4:return cU.FLOAT_32;case 8:return cU.FLOAT_64}}!function(e){e[e.FLOAT_32=0]="FLOAT_32",e[e.FLOAT_64=1]="FLOAT_64"}(cU||(cU={}));var pU,dU,mU,gU,vU,yU,xU,SU,TU,EU,AU,CU,bU,wU=hc("cc.animation.QuantizedFloatArray")((Zk=function(){function e(e,t,n,i){void 0===i&&(i=0),ae(this,"originalPrecision",Xk,this),ae(this,"min",Yk,this),ae(this,"extent",Kk,this),ae(this,"values",Qk,this),this.originalPrecision=e,this.values=t,this.extent=n,this.min=i}return e.prototype.toHashString=function(){var e=this.originalPrecision,t=this.min,n=this.extent,i=this.values;return e+" "+tU(t)+" "+tU(n)+" "+i.join(" ")},K(e,[{key:"quantizationType",get:function(){switch(this.values.BYTES_PER_ELEMENT){default:case 1:return"uint8";case 2:return"uint16"}}}]),e}(),Xk=se((qk=Zk).prototype,"originalPrecision",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),Yk=se(qk.prototype,"min",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),Kk=se(qk.prototype,"extent",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),Qk=se(qk.prototype,"values",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:null}),Wk=qk))||Wk;function RU(e,t){return e.values[t]/(1<=0){var f=l.substring(0,h),_=c[f];_&&(u.parent=_)}}for(var p=this._createEvalWithBinder(void 0,(function(e){var t=e.parseTrsPath();if(t){var n=c[t.node];if(n)return GU(n,t.property)}}),void 0),d=0;d0?((o&Ks.PingPong)===Ks.PingPong?t*=-1:c=i,s++):1===t&&c===i-1&&ra)break}c+=t,this._doFire(c,!0)}while(c!==r&&c>-1&&c=t.length||this._ignoreIndex===e))for(var n=t[e],i=this._targetNode.components,r=n.events.length,o=0;o0&&(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.time),this._sampleEvents(e),e},n.onPlay=function(){this.setTime(this._getPlaybackStart()),this._delayTime=this._delay,this._onReplayOrResume(),this.emit(WU.PLAY,this)},n.onStop=function(){this.isPaused||this._onPauseOrStop(),this.emit(WU.STOP,this)},n.onResume=function(){this._onReplayOrResume(),this.emit(WU.RESUME,this)},n.onPause=function(){this._onPauseOrStop(),this.emit(WU.PAUSE,this)},n._sampleCurves=function(e){var t=this._poseOutput,n=this._clipEval;t&&(t.weight=this.weight),n&&n.evaluate(e)},n._process=function(){this._useSimpleProcess?this.simpleProcess():this.process()},n.process=function(){var e,t=this.sample();this._allowLastFrame&&(e=this._lastWrapInfo?this._lastWrapInfo:this._lastWrapInfo=new tc(t),this.repeatCount>1&&(0|t.iterations)>(0|e.iterations)&&this.emit(WU.LASTFRAME,this),e.set(t)),t.stopped&&(this.stop(),this.emit(WU.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(e+n),this._sampleEvents(this.getWrappedInfo(this.time,this._wrappedInfo)),this._allowLastFrame&&(Number.isNaN(this._lastIterations)&&(this._lastIterations=i),(this.time>0&&this._lastIterations>i||this.time<0&&this._lastIterations0&&(e-=1),1&e&&(n=!n)),(t&Ks.Reverse)===Ks.Reverse&&(n=!n),n},n.getWrappedInfo=function(e,t){t=t||new tc;var n=this._getPlaybackStart(),i=this._getPlaybackEnd()-n,r=!1,o=this.repeatCount,a=(e-=n)>0?e/i:-e/i;if(a>=o){a=o,r=!0;var s=o-(0|o);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&Ks.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=r,t.iterations=a,t},n._getPlaybackStart=function(){return this._playbackRange.min},n._getPlaybackEnd=function(){return this._playbackRange.max},n._sampleEvents=function(e){var t;null===(t=this._clipEventEval)||void 0===t||t.sample(e.ratio,e.direction,e.iterations)},n._emit=function(e,t){this._target&&this._target.isValid&&this._target.emit(e,e,t)},n._onReplayOrResume=function(){c.director.getAnimationManager().addAnimation(this)},n._onPauseOrStop=function(){c.director.getAnimationManager().removeAnimation(this)},K(t,[{key:"clip",get:function(){return this._clip}},{key:"name",get:function(){return this._name}},{key:"length",get:function(){return this.duration}},{key:"wrapMode",get:function(){return this._wrapMode},set:function(e){var t;this._wrapMode=e,this.time=0,e&Ks.Loop?this.repeatCount=1/0:this.repeatCount=1,null===(t=this._clipEventEval)||void 0===t||t.setWrapMode(e)}},{key:"repeatCount",get:function(){return this._repeatCount},set:function(e){this._repeatCount=e;var t=this._wrapMode&Ks.ShouldWrap,n=(this.wrapMode&Ks.Reverse)===Ks.Reverse;this._useSimpleProcess=e===1/0&&!t&&!n}},{key:"delay",get:function(){return this._delay},set:function(e){this._delayTime=this._delay=e}},{key:"playbackRange",get:function(){return this._playbackRange},set:function(e){e.max,e.min,this._playbackRange.min=Math.max(e.min,0),this._playbackRange.max=Math.min(e.max,this.duration),this._playbackDuration=this._playbackRange.max-this._playbackRange.min,this.setTime(0)}},{key:"current",get:function(){return this.getWrappedInfo(this.time).time}},{key:"ratio",get:function(){return this.current/this.duration}},{key:"weight",get:function(){return this._weight},set:function(e){this._weight=e,this._poseOutput&&(this._poseOutput.weight=e)}},{key:"curveLoaded",get:function(){return this._curveLoaded}}]),t}(qU));c.AnimationState=YU;var KU,QU,ZU,JU,$U,eG,tG,nG,iG,rG,oG,aG,sG,cG,lG,uG,hG,fG=function(e){function t(t){var n;return(n=e.call(this)||this)._managedStates=[],n._fadings=[],n._scheduled=!1,n._scheduler=null!=t?t:c.director.getAnimationManager(),n}Z(t,e);var n=t.prototype;return n.update=function(e){if(!this.isMotionless){var t=this._managedStates,n=this._fadings;if(1===t.length&&1===n.length){var i=t[0].state;i&&(i.weight=1)}else this._calculateWeights(e);1===t.length&&1===n.length&&this._unscheduleThis()}},n.crossFade=function(e,t){var n;0===this._managedStates.length&&(t=0),0===t&&this.clear();var i=this._managedStates.find((function(t){return t.state===e}));i?(null===(n=i.state)||void 0===n?void 0:n.isMotionless)&&i.state.play():(i={state:e,reference:0},e&&e.play(),this._managedStates.push(i)),++i.reference,this._fadings.unshift({easeDuration:t,easeTime:0,target:i}),this.isMotionless||this._scheduleThis()},n.clear=function(){for(var e=0;e=c.easeDuration){a=s+1,c.easeTime=c.easeDuration;break}}if(a!==n.length){for(var h=a;h=0||(this._clips.push(e),this.createState(e)))}}]),t}(Ql(Ku)),uG.EventType=WU,se((aG=hG).prototype,"clips",[$U,eG],Object.getOwnPropertyDescriptor(aG.prototype,"clips"),aG.prototype),se(aG.prototype,"defaultClip",[tG,nG],Object.getOwnPropertyDescriptor(aG.prototype,"defaultClip"),aG.prototype),sG=se(aG.prototype,"playOnLoad",[gc,iG],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),cG=se(aG.prototype,"_clips",[rG],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),lG=se(aG.prototype,"_defaultClip",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),oG=aG))||oG)||oG)||oG)||oG)||oG));function pG(e,t){return e===t||!!e&&!!t&&e._uuid===t._uuid&&e._uuid}c.Animation=_G,z(_G.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 _G.prototype.removeState.call(this,e.name)}}]),c.AnimationComponent=_G,tt.setClassAlias(_G,"cc.AnimationComponent");var dG,mG,gG,vG=function(){function e(){this._nodeBlendStates=new Map}var t=e.prototype;return t.createWriter=function(e,t,n,i){var r=this.ref(e,t);return new yG(e,t,r,n,i)},t.destroyWriter=function(e){var t=e;this.deRef(t.node,t.property)},t.ref=function(e,t){var n=this._nodeBlendStates.get(e);return n||(n=new EG,this._nodeBlendStates.set(e,n)),n.refProperty(t)},t.deRef=function(e,t){var n=this._nodeBlendStates.get(e);n&&(n.deRefProperty(t),n.empty&&this._nodeBlendStates.delete(e))},t.apply=function(){this._nodeBlendStates.forEach((function(e,t){e.apply(t)}))},e}(),yG=function(){function e(e,t,n,i,r){this._node=e,this._property=t,this._propertyBlendState=n,this._host=i,this._constants=r}var t=e.prototype;return t.getValue=function(){return this._node[this._property]},t.setValue=function(e){var t=this._propertyBlendState,n=this._host.weight;t.blend(e,n)},K(e,[{key:"node",get:function(){return this._node}},{key:"property",get:function(){return this._property}}]),e}(),xG=function(e){this.blendedWeight=0,this.blendedValue=void 0,this.refCount=0,this.blendedValue=e},SG=function(e){function t(){return e.call(this,new bn)||this}Z(t,e);var n=t.prototype;return n.blend=function(e,t){var n=this.blendedValue;1===t?bn.copy(n,e):bn.scaleAndAdd(n,n,e,t),this.blendedWeight+=t},n.reset=function(){this.blendedWeight=0,bn.zero(this.blendedValue)},t}(xG),TG=function(e){function t(){return e.call(this,new Mn)||this}Z(t,e);var n=t.prototype;return n.blend=function(e,t){if(0!==t){var n=this.blendedValue,i=this.blendedWeight;if(1===t)Mn.copy(n,e);else{var r=t/(i+t);Mn.slerp(n,n,e,r)}this.blendedWeight+=t}},n.reset=function(){this.blendedWeight=0,Mn.identity(this.blendedValue)},t}(xG),EG=function(){function e(){this._properties={}}var t=e.prototype;return t.refProperty=function(e){var t,n,i,r=this._properties;switch(e){default:case"position":case"scale":case"eulerAngles":i=null!==(t=r[e])&&void 0!==t?t:r[e]=new SG;break;case"rotation":i=null!==(n=r[e])&&void 0!==n?n:r[e]=new TG}return++i.refCount,i},t.deRefProperty=function(e){var t=this._properties,n=t[e];n&&(--n.refCount,n.refCount>0||delete t[e])},t.apply=function(e){var t,n,i,r=this._properties,o=r.position,a=r.scale,s=r.rotation,c=r.eulerAngles,l=!1,u=!1,h=!1,f=!1;o&&o.blendedWeight&&(l=!0,o.blendedWeight<1&&o.blend(e.position,1-o.blendedWeight),t=o.blendedValue),a&&a.blendedWeight&&(u=!0,a.blendedWeight<1&&a.blend(e.scale,1-a.blendedWeight),n=a.blendedValue),c&&c.blendedWeight&&(f=!0,c.blendedWeight<1&&c.blend(e.eulerAngles,1-c.blendedWeight),i=c.blendedValue),s&&s.blendedWeight&&(h=!0,s.blendedWeight<1&&s.blend(e.rotation,1-s.blendedWeight),i=s.blendedValue),(i||t||n)&&e.setRTS(i,t,n),l&&o.reset(),u&&a.reset(),h&&s.reset(),f&&c.reset()},K(e,[{key:"empty",get:function(){var e=this._properties;return!(e.position||e.rotation||e.eulerAngles||e.scale)}}]),e}(),AG=[],CG=new Map;function bG(e,t){for(var n=0,i=Gn.IDENTITY;e;){if(e.stamp===t||e.stamp+1===t&&!e.node.hasChangedFlags){i=e.world,e.stamp=t;break}e.stamp=t,AG[n++]=e,e=e.parent}for(;n>0;){e=AG[--n],AG[n]=null;var r=e.node;Gn.fromRTS(e.local,r.rotation,r.position,r.scale),i=Gn.multiply(e.world,i,e.local)}return i}function wG(e,t){for(var n,i=null,r=0;e!==t;){var o=e.uuid;if(CG.has(o)){i=CG.get(o);break}i={node:e,local:new Gn,world:new Gn,stamp:-1,parent:null},CG.set(o,i),AG[r++]=i,e=e.parent,i=null}for(;r>0;)n=AG[--r],AG[r]=null,n.parent=i,i=n;return i}function RG(e){for(var t=CG.get(e.uuid)||null;t;)CG.delete(t.node.uuid),t=t.parent}var PG=e("AnimationManager",hc((gG=mG=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r=0?this._crossFades.fastRemoveAt(t):D(3907)},n.update=function(e){var t=this._delayEvents,n=this._crossFades,i=this._sockets,r=n.array;for(n.i=0;n.i=0?this._anims.fastRemoveAt(t):D(3907)},n.pushDelayEvent=function(e,t,n){this._delayEvents.push({fn:e,thisArg:t,args:n})},n.addSockets=function(e,t){for(var n=this,i=function(i){var r=t[i];if(n._sockets.find((function(e){return e.target===r.target})))return"continue";var o=e.getChildByPath(r.path),a=r.target&&o&&wG(o,e);a&&n._sockets.push({target:r.target,transform:a})},r=0;rthis._width&&(this._x=2,this._y=this._nexty),this._y+s+2>this._nexty&&(this._nexty=this._y+s+2),this._nexty>this._height)return null;c.internal.dynamicAtlasManager.textureBleeding&&((a<=8||s<=8)&&(this._texture.drawTextureAt(n.image,this._x-1,this._y-1),this._texture.drawTextureAt(n.image,this._x-1,this._y+1),this._texture.drawTextureAt(n.image,this._x+1,this._y-1),this._texture.drawTextureAt(n.image,this._x+1,this._y+1)),this._texture.drawTextureAt(n.image,this._x-1,this._y),this._texture.drawTextureAt(n.image,this._x+1,this._y),this._texture.drawTextureAt(n.image,this._x,this._y-1),this._texture.drawTextureAt(n.image,this._x,this._y+1)),this._texture.drawTextureAt(n.image,this._x,this._y),this._innerTextureInfos[n.getId()]={x:this._x,y:this._y,texture:n},this._count++,r+=this._x,o+=this._y,this._x+=a+2}var l={x:r,y:o,texture:this._texture};return this._innerSpriteFrames.push(e),l},t.deleteInnerTexture=function(e){e&&this._innerTextureInfos[e.getId()]&&(delete this._innerTextureInfos[e.getId()],this._count--)},t.isEmpty=function(){return this._count<=0},t.reset=function(){this._x=2,this._y=2,this._nexty=2;for(var e=this._innerSpriteFrames,t=0,n=e.length;t=0;n--)t=this._atlases[n],tt.array.fastRemove(t._innerSpriteFrames,e);var i=e._original._texture;this.deleteAtlasTexture(i)}},t.deleteAtlasTexture=function(e){if(e)for(var t=this._atlases.length-1;t>=0;t--)this._atlases[t].deleteInnerTexture(e),this._atlases[t].isEmpty()&&(this._atlases[t].destroy(),this._atlases.splice(t,1),this._atlasIndex--)},t.packToDynamicAtlas=function(e,t){if(t&&!t._original&&t.packable&&t.texture&&t.texture.width>0&&t.texture.height>0){var n=this.insertSpriteFrame(t);n&&t._setDynamicAtlasFrame(n)}},K(e,[{key:"enabled",get:function(){return this._enabled},set:function(e){this._enabled!==e&&(e?(this.reset(),c.director.on(c.Director.EVENT_BEFORE_SCENE_LAUNCH,this.beforeSceneLoad,this)):(this.reset(),c.director.off(c.Director.EVENT_BEFORE_SCENE_LAUNCH,this.beforeSceneLoad,this)),this._enabled=e)}},{key:"maxAtlasCount",get:function(){return this._maxAtlasCount},set:function(e){this._maxAtlasCount=e}},{key:"atlasCount",get:function(){return this._atlases.length}},{key:"textureBleeding",get:function(){return this._textureBleeding},set:function(e){this._textureBleeding=e}},{key:"textureSize",get:function(){return this._textureSize},set:function(e){this._textureSize=e}},{key:"maxFrameSize",get:function(){return this._maxFrameSize},set:function(e){this._maxFrameSize=e}}]),e}();YG.instance=void 0;var KG,QG,ZG,JG=e("dynamicAtlasManager",YG.instance=new YG);c.internal.dynamicAtlasManager=JG;var $G,eH,tH,nH,iH=[{u:0,v:0},{u:0,v:0},{u:0,v:0},{u:0,v:0}],rH=e("SpriteFrame",hc("cc.SpriteFrame")((ZG=QG=function(e){function t(){var t;return(t=e.call(this)||this).vertices=null,t.uv=[],t.unbiasUV=[],t.uvSliced=[],t._rect=new ei,t._offset=new Wn,t._originalSize=new Jn,t._rotated=!1,t._capInsets=[0,0,0,0],t._atlasUuid="",t._texture=void 0,t._isFlipUVY=!1,t._isFlipUVX=!1,t._original=null,t._packable=!0,t}Z(t,e),t.createWithImage=function(e){var n=e instanceof Km?e:new Km(e),i=new vg;i.image=n;var r=new t;return r.texture=i,r};var n=t.prototype;return n.textureLoaded=function(){return!!this.texture},n.isRotated=function(){return this._rotated},n.setRotated=function(e){this.rotated=e},n.getRect=function(e){return e?(e.set(this._rect),e):this._rect.clone()},n.setRect=function(e){this.rect=e},n.getOriginalSize=function(e){return e?(e.set(this._originalSize),e):this._originalSize.clone()},n.setOriginalSize=function(e){this.originalSize=e},n.getOffset=function(e){return e?(e.set(this._offset),e):this._offset.clone()},n.setOffset=function(e){this.offset=e},n.getGFXTexture=function(){return this._texture.getGFXTexture()},n.getGFXSampler=function(){return this._texture.getGFXSampler()},n.getHash=function(){return this._texture.getHash()},n.getSamplerInfo=function(){return this._texture.getSamplerInfo()},n.reset=function(e,t){void 0===t&&(t=!1);var n=!1;t&&(this._originalSize.set(0,0),this._rect.set(0,0,0,0),this._offset.set(0,0),this._capInsets=[0,0,0,0],this._rotated=!1,n=!0),e&&(e.texture&&(this._rect.x=this._rect.y=0,this._rect.width=e.texture.width,this._rect.height=e.texture.height,this._refreshTexture(e.texture),this.checkRect(this._texture)),e.originalSize&&this._originalSize.set(e.originalSize),e.rect&&this._rect.set(e.rect),e.offset&&this._offset.set(e.offset),void 0!==e.borderTop&&(this._capInsets[1]=e.borderTop),void 0!==e.borderBottom&&(this._capInsets[3]=e.borderBottom),void 0!==e.borderLeft&&(this._capInsets[0]=e.borderLeft),void 0!==e.borderRight&&(this._capInsets[2]=e.borderRight),void 0!==e.isRotate&&(this._rotated=!!e.isRotate),void 0!==e.isFlipUv&&(this._isFlipUVY=!!e.isFlipUv),n=!0),n&&this.texture&&this._calculateUV()},n.checkRect=function(e){var t=this._rect,n=t.x,i=t.y;return this._rotated?(n+=t.height,i+=t.width):(n+=t.width,i+=t.height),n>e.width?(D(3300,this.name+"/"+e.name,n,e.width),!1):!(i>e.height&&(D(3301,this.name+"/"+e.name,i,e.height),1))},n.destroy=function(){return this._packable&&JG&&JG.deleteAtlasSpriteFrame(this),e.prototype.destroy.call(this)},n._calculateSlicedUV=function(){var e=this._rect,n=this.texture,i=n.width,r=n.height,o=this._capInsets[0],a=this._capInsets[2],s=e.width-o-a,c=this._capInsets[1],l=this._capInsets[3],u=e.height-c-l,h=this.uvSliced;if(h.length=0,this._rotated){iH[0].u=e.x/i,iH[1].u=(e.x+l)/i,iH[2].u=(e.x+l+u)/i,iH[3].u=(e.x+e.height)/i,iH[3].v=e.y/r,iH[2].v=(e.y+o)/r,iH[1].v=(e.y+o+s)/r,iH[0].v=(e.y+e.width)/r;for(var f=0;f<4;++f)for(var _=iH[f],p=0;p<4;++p){var d=iH[3-p];h.push({u:_.u,v:d.v})}}else{iH[0].u=e.x/i,iH[1].u=(e.x+o)/i,iH[2].u=(e.x+o+s)/i,iH[3].u=(e.x+e.width)/i,iH[3].v=e.y/r,iH[2].v=(e.y+c)/r,iH[1].v=(e.y+c+u)/r,iH[0].v=(e.y+e.height)/r;for(var m=0;m<4;++m)for(var g=iH[m],v=0;v<4;++v){var y=iH[v];h.push({u:y.u,v:g.v})}}this.emit(t.EVENT_UV_UPDATED,this)},n._calculateUV=function(){var e=this._rect,t=this.uv,n=this.unbiasUV,i=this.texture,r=i.width,o=i.height;if(this._rotated){var a=0===r?0:e.x/r,s=0===r?1:(e.x+e.height)/r,c=0===o?0:e.y/o,l=0===o?1:(e.y+e.width)/o;this._isFlipUVX&&this._isFlipUVY?(t[0]=s,t[1]=l,t[2]=s,t[3]=c,t[4]=a,t[5]=l,t[6]=a,t[7]=c):this._isFlipUVX?(t[0]=s,t[1]=c,t[2]=s,t[3]=l,t[4]=a,t[5]=c,t[6]=a,t[7]=l):this._isFlipUVY?(t[0]=a,t[1]=l,t[2]=a,t[3]=c,t[4]=s,t[5]=l,t[6]=s,t[7]=c):(t[0]=a,t[1]=c,t[2]=a,t[3]=l,t[4]=s,t[5]=c,t[6]=s,t[7]=l);var u=0===r?0:e.x/r,h=0===r?1:(e.x+e.height)/r,f=0===o?0:e.y/o,_=0===o?1:(e.y+e.width)/o;this._isFlipUVX&&this._isFlipUVY?(n[0]=h,n[1]=_,n[2]=h,n[3]=f,n[4]=u,n[5]=_,n[6]=u,n[7]=f):this._isFlipUVX?(n[0]=h,n[1]=f,n[2]=h,n[3]=_,n[4]=u,n[5]=f,n[6]=u,n[7]=_):this._isFlipUVY?(n[0]=u,n[1]=_,n[2]=u,n[3]=f,n[4]=h,n[5]=_,n[6]=h,n[7]=f):(n[0]=u,n[1]=f,n[2]=u,n[3]=_,n[4]=h,n[5]=f,n[6]=h,n[7]=_)}else{var p=0===r?0:e.x/r,d=0===r?1:(e.x+e.width)/r,m=0===o?1:(e.y+e.height)/o,g=0===o?0:e.y/o;this._isFlipUVX&&this._isFlipUVY?(t[0]=d,t[1]=g,t[2]=p,t[3]=g,t[4]=d,t[5]=m,t[6]=p,t[7]=m):this._isFlipUVX?(t[0]=d,t[1]=m,t[2]=p,t[3]=m,t[4]=d,t[5]=g,t[6]=p,t[7]=g):this._isFlipUVY?(t[0]=p,t[1]=g,t[2]=d,t[3]=g,t[4]=p,t[5]=m,t[6]=d,t[7]=m):(t[0]=p,t[1]=m,t[2]=d,t[3]=m,t[4]=p,t[5]=g,t[6]=d,t[7]=g);var v=0===r?0:e.x/r,y=0===r?1:(e.x+e.width)/r,x=0===o?1:(e.y+e.height)/o,S=0===o?0:e.y/o;this._isFlipUVX&&this._isFlipUVY?(n[0]=y,n[1]=S,n[2]=v,n[3]=S,n[4]=y,n[5]=x,n[6]=v,n[7]=x):this._isFlipUVX?(n[0]=y,n[1]=x,n[2]=v,n[3]=x,n[4]=y,n[5]=S,n[6]=v,n[7]=S):this._isFlipUVY?(n[0]=v,n[1]=S,n[2]=y,n[3]=S,n[4]=v,n[5]=x,n[6]=y,n[7]=x):(n[0]=v,n[1]=x,n[2]=y,n[3]=x,n[4]=v,n[5]=S,n[6]=y,n[7]=S)}var T=this.vertices;if(T){T.nu.length=0,T.nv.length=0;for(var E=0;Ee.maxFrameSize||i>e.maxFrameSize?this._packable=!1:t.image&&t.image instanceof HTMLCanvasElement&&(this._packable=!0)}else this._packable=!1}},n._serialize=function(){return null},n._deserialize=function(e){var t=e,n=t.rect;n&&(this._rect=new ei(n.x,n.y,n.width,n.height));var i=t.offset;t.offset&&(this._offset=new Wn(i.x,i.y));var r=t.originalSize;t.originalSize&&(this._originalSize=new Jn(r.width,r.height)),this._rotated=!!t.rotated,this._name=t.name,this._packable=!!t.packable;var o=t.capInsets;o&&(this._capInsets[0]=o[0],this._capInsets[1]=o[1],this._capInsets[2]=o[2],this._capInsets[3]=o[3]),this.vertices=t.vertices,this.vertices&&(this.vertices.nu=[],this.vertices.nv=[])},n.clone=function(){var e,n,i,r,o,a,s,c,l=new t,u=this.vertices;return l.vertices=u?{x:u.x,y:u.y,triangles:u.triangles,nu:null===(e=u.nu)||void 0===e?void 0:e.slice(0),u:null===(n=u.u)||void 0===n?void 0:n.slice(0),nv:null===(i=u.nv)||void 0===i?void 0:i.slice(0),v:null===(r=u.v)||void 0===r?void 0:r.slice(0)}:null,(o=l.uv).splice.apply(o,[0,l.uv.length].concat(this.uv)),(a=l.unbiasUV).splice.apply(a,[0,l.unbiasUV.length].concat(this.unbiasUV)),(s=l.uvSliced).splice.apply(s,[0,l.uvSliced.length].concat(this.uvSliced)),l._rect.set(this._rect),l._offset.set(this._offset),l._originalSize.set(this._originalSize),l._rotated=this._rotated,(c=l._capInsets).splice.apply(c,[0,l._capInsets.length].concat(this._capInsets)),l._atlasUuid=this._atlasUuid,l._texture=this._texture,l._isFlipUVX=this._isFlipUVX,l._isFlipUVY=this._isFlipUVY,l},n._refreshTexture=function(e){this._texture=e;var t=this._texture,n={},i=!1;0!==this._rect.width&&0!==this._rect.height&&this.checkRect(t)||(n.rect=new ei(0,0,t.width,t.height),i=!0),(0===this._originalSize.width||0===this._originalSize.height||i)&&(n.originalSize=new Jn(t.width,t.height),i=!0),i&&(this.reset(n),this.onLoaded()),this._checkPackable()},n.initDefault=function(t){e.prototype.initDefault.call(this,t);var n=new vg;n.initDefault(),this._refreshTexture(n),this._calculateUV()},n.validate=function(){return this._texture&&this._rect&&0!==this._rect.width&&0!==this._rect.height},K(t,[{key:"insetTop",get:function(){return this._capInsets[1]},set:function(e){this._capInsets[1]!==e&&(this._capInsets[1]=e,this._texture&&this._calculateSlicedUV())}},{key:"insetBottom",get:function(){return this._capInsets[3]},set:function(e){this._capInsets[3]!==e&&(this._capInsets[3]=e,this._texture&&this._calculateSlicedUV())}},{key:"insetLeft",get:function(){return this._capInsets[0]},set:function(e){this._capInsets[0]!==e&&(this._capInsets[0]=e,this._texture&&this._calculateSlicedUV())}},{key:"insetRight",get:function(){return this._capInsets[2]},set:function(e){this._capInsets[2]!==e&&(this._capInsets[2]=e,this._texture&&this._calculateSlicedUV())}},{key:"rect",get:function(){return this._rect},set:function(e){this._rect.equals(e)||(this._rect.set(e),this._texture&&this._calculateUV())}},{key:"originalSize",get:function(){return this._originalSize},set:function(e){this._originalSize.equals(e)||(this._originalSize.set(e),this._texture&&this._calculateUV())}},{key:"offset",get:function(){return this._offset},set:function(e){this._offset.set(e)}},{key:"rotated",get:function(){return this._rotated},set:function(e){this._rotated!==e&&(this._rotated=e,this._texture&&this._calculateUV())}},{key:"texture",get:function(){return this._texture},set:function(e){e?this.reset({texture:e},!0):console.warn("Error Texture in "+this.name)}},{key:"atlasUuid",get:function(){return this._atlasUuid},set:function(e){this._atlasUuid=e}},{key:"width",get:function(){return this._texture.width}},{key:"height",get:function(){return this._texture.height}},{key:"_textureSource",set:function(e){window.Build?this._texture=e:e&&(this._refreshTexture(e),this._calculateUV())}},{key:"flipUVX",get:function(){return this._isFlipUVX},set:function(e){this._isFlipUVX=e,this._calculateUV()}},{key:"flipUVY",get:function(){return this._isFlipUVY},set:function(e){this._isFlipUVY=e,this._calculateUV()}},{key:"packable",get:function(){return this._packable},set:function(e){this._packable=e}},{key:"original",get:function(){return this._original}}]),t}(Ru),QG.EVENT_UV_UPDATED="uv_updated",KG=ZG))||KG);c.SpriteFrame=rH;var oH,aH=e("SpriteAtlas",hc("cc.SpriteAtlas")((nH=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r0){var t=this.spriteFrames[e[0]];return t&&t.texture}return null},n.getSpriteFrame=function(e){var t=this.spriteFrames[e];return t?(t.name||(t.name=e),t):null},n.getSpriteFrames=function(){for(var e=[],t=this.spriteFrames,n=0,i=Object.keys(t);n=this.limit){var i=this.tail;delete this.datas[i.key],this.count--,this.tail=i.prev,this.tail.next=null,i.prev=null,i.next=null,PH.put(i)}this.moveToHead(n)},t.remove=function(e){e.prev?e.prev.next=e.next:this.head=e.next,e.next?e.next.prev=e.prev:this.tail=e.prev,delete this.datas[e.key],this.count--},t.get=function(e){var t=this.datas[e];return t?(this.remove(t),this.moveToHead(t),t.value):null},t.clear=function(){this.count=0,this.datas={},this.head=null,this.tail=null},t.has=function(e){return!!this.datas[e]},t.delete=function(e){var t=this.datas[e];this.remove(t)},e}())(100),OH=/([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûа-яА-ЯЁё]+|\S)/,MH=/^[!,.:;'}\]%\?>、‘“》?。,!]/,NH=/([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłę湯ŹŚÓŃŁĘĆĄ-яА-ЯЁё]+|\S)$/,LH=/[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłę湯ŹŚÓŃŁĘĆĄ-яА-ЯЁё]+$/,FH=/^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłę湯ŹŚÓŃŁĘĆĄ-яА-ЯЁё]/;function BH(e){return/^[\u4E00-\u9FFF\u3400-\u4DFF]+$/.test(e)||/[\u3000-\u303F]|[\u3040-\u309F]|[\u30A0-\u30FF]|[\uFF00-\uFFEF]|[\u4E00-\u9FAF]|[\u2605-\u2606]|[\u2190-\u2195]|\u203B/g.test(e)||/^[\u1100-\u11FF]|[\u3130-\u318F]|[\uA960-\uA97F]|[\uAC00-\uD7AF]|[\uD7B0-\uD7FF]+$/.test(e)}function zH(e){var t=e.charCodeAt(0);return t>=9&&t<=13||32===t||133===t||160===t||5760===t||t>=8192&&t<=8202||8232===t||8233===t||8239===t||8287===t||12288===t}function kH(e,t,n){var i=(n||e.font)+"🎮"+t,r=DH.get(i);if(null!==r)return r;var o=e.measureText(t),a=o&&o.width||0;return DH.put(i,a),a}function UH(e,t,n){var i=t,r=n,o=e[t];if(o>="\udc00"&&o<="\udfff"&&i--,void 0!==n)if(n-1!==t){var a=e[n-1];a>="\ud800"&&a<="\udbff"&&r--}else o>="\ud800"&&o<="\udbff"&&r++;return e.substring(i,r)}function GH(e,t,n,i){var r=[];if(0===e.length||n<0)return r.push(""),r;for(var o=e;t>n&&o.length>1;){for(var a=o.length*(n/t)|0,s=UH(o,a),c=t-i(s),l=s,u=0,h=0;c>n&&h++<10;)a*=n/c,c=t-i(s=UH(o,a|=0));for(h=0;c<=n&&h++<10;){if(s){var f=OH.exec(s);u=f?f[0].length:1,l=s}c=t-i(s=UH(o,a+=u))}0==(a-=u)?(a=1,l=UH(o,1)):1===a&&o[0]>="\ud800"&&o[0]<="\udbff"&&(a=2,l=UH(o,2));var _=UH(o,0,a),p=void 0;MH.test(l||s)&&(0==(a-=(p=NH.exec(_))?p[0].length:0)&&(a=1),l=UH(o,a),_=UH(o,0,a)),FH.test(l)&&(p=LH.exec(_))&&_!==p[0]&&(l=UH(o,a-=p[0].length),_=UH(o,0,a)),(0===r.length||(_=_.trim()).length>0)&&r.push(_),t=i(o=l||s)}return(0===r.length||(o=o.trim()).length>0)&&r.push(o),r}var HH=e("CanvasPool",function(){function e(){this.pool=[]}e.getInstance=function(){return IH||(IH=new e),IH};var t=e.prototype;return t.get=function(){var e=this.pool.pop();if(!e){var t=document.createElement("canvas"),n=t.getContext("2d");e={canvas:t,context:n}}return e},t.put=function(e){this.pool.length>=ct.MAX_LABEL_CANVAS_POOL_SIZE||this.pool.push(e)},e}()),VH=An.WHITE.clone(),jH=function(){this.u=0,this.v=0,this.w=0,this.h=0,this.texture=null,this.offsetX=0,this.offsetY=0,this.valid=!1,this.xAdvance=0},WH="rgba(255, 255, 255, "+(1/255).toFixed(3)+")",qH=function(){function e(e,t){this.image=null,this.labelInfo=void 0,this.char=void 0,this.data=null,this.canvas=null,this.context=null,this.width=0,this.height=0,this.offsetY=0,this.hash=void 0,this.char=e,this.labelInfo=t,this.hash=e.charCodeAt(0)+t.hash}var t=e.prototype;return t.updateRenderData=function(){this._updateProperties(),this._updateTexture()},t.destroy=function(){this.image=null},t._updateProperties=function(){if(this.data=HH.getInstance().get(),this.canvas=this.data.canvas,this.context=this.data.context,this.context){this.context.font=this.labelInfo.fontDesc;var e=kH(this.context,this.char,this.labelInfo.fontDesc),t=2*this.labelInfo.margin+2;this.width=parseFloat(e.toFixed(2))+t,this.height=(1+wH)*this.labelInfo.fontSize+t,this.offsetY=-this.labelInfo.fontSize*wH/2}this.canvas.width!==this.width&&(this.canvas.width=this.width),this.canvas.height!==this.height&&(this.canvas.height=this.height),this.image||(this.image=new Km),this.image.reset(this.canvas)},t._updateTexture=function(){if(this.context&&this.canvas){var e=this.context,t=this.labelInfo,n=this.canvas.width,i=this.canvas.height;e.textAlign="center",e.textBaseline="alphabetic",e.clearRect(0,0,n,i),e.fillStyle=WH,e.fillRect(0,0,n,i),e.font=t.fontDesc;var r=t.fontSize,o=n/2,a=i/2+r*RH+0*r,s=t.color;if(e.lineJoin="round",e.fillStyle="rgba("+s.r+", "+s.g+", "+s.b+", 1)",t.isOutlined){var c=t.out||VH;e.strokeStyle="rgba("+c.r+", "+c.g+", "+c.b+", "+c.a/255+")",e.lineWidth=2*t.margin,e.strokeText(this.char,o,a)}e.fillText(this.char,o,a)}},e}(),XH=function(e){function t(){return e.apply(this,arguments)||this}Z(t,e);var n=t.prototype;return n.initWithSize=function(e,t,n){void 0===n&&(n=bm.RGBA8888),this.reset({width:e,height:t,format:n})},n.drawTextureAt=function(e,t,n){var i=this.getGFXTexture();if(e&&i){var r=this._getGFXDevice();if(r){var o=new ir;o.texOffset.x=t,o.texOffset.y=n,o.texExtent.width=e.width,o.texExtent.height=e.height,r.copyTexImagesToTexture([e.data],i,[o])}else console.warn("Unable to get device")}},t}(vg),YH=function(){function e(e,t){this._x=0,this._y=0,this._nextY=0,this._width=0,this._height=0,this._halfBleed=0,this._dirty=!1;var n=new XH;n.initWithSize(e,t),this.fontDefDictionary=new AH(n),this._halfBleed=1,this._width=e,this._height=t,zM.on(BM.EVENT_BEFORE_SCENE_LAUNCH,this.beforeSceneLoad,this)}var t=e.prototype;return t.insertLetterTexture=function(e){var t=e.image,n=zM.root.device;if(!t||!this.fontDefDictionary||!n)return null;var i=t.width,r=t.height;if(this._x+i+0>this._width&&(this._x=0,this._y=this._nextY),this._y+r>this._nextY&&(this._nextY=this._y+r+0),this._nextY>this._height)return P(12100),null;this.fontDefDictionary.texture.drawTextureAt(t,this._x,this._y),this._dirty=!0;var o=new jH;return o.u=this._x+this._halfBleed,o.v=this._y+this._halfBleed,o.texture=this.fontDefDictionary.texture,o.valid=!0,o.w=e.width-2,o.h=e.height-2,o.xAdvance=o.w,o.offsetY=e.offsetY,this._x+=i+0,this.fontDefDictionary.addLetterDefinitions(e.hash,o),o},t.update=function(){this._dirty&&(this._dirty=!1)},t.reset=function(){this._x=0,this._y=0,this._nextY=0,this.fontDefDictionary.clear()},t.destroy=function(){this.reset(),this.fontDefDictionary&&(this.fontDefDictionary.texture.destroy(),this.fontDefDictionary.texture=null)},t.getTexture=function(){return this.fontDefDictionary.getTexture()},t.beforeSceneLoad=function(){this.clearAllCache()},t.clearAllCache=function(){this.destroy();var e=new XH;e.initWithSize(this._width,this._height),this.fontDefDictionary.texture=e},t.getLetter=function(e){return this.fontDefDictionary.letterDefinitions[e]},t.getLetterDefinitionForChar=function(e,t){var n=e.charCodeAt(0)+t.hash,i=this.fontDefDictionary.letterDefinitions[n];if(!i){var r=new qH(e,t);r.updateRenderData(),i=this.insertLetterTexture(r),r.destroy()}return i},K(e,[{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}}]),e}(),KH={fontAtlas:null,fontSize:0,lineHeight:0,hAlign:0,vAlign:0,hash:"",fontFamily:"",fontDesc:"Arial",color:An.WHITE.clone(),isOutlined:!1,out:An.WHITE.clone(),margin:0},QH=[new br(Xi.ATTR_POSITION,ui.RGB32F)],ZH=[new br(Xi.ATTR_POSITION,ui.RGB32F),new br(Xi.ATTR_COLOR,ui.RGBA32F)],JH=[new br(Xi.ATTR_POSITION,ui.RGB32F),new br(Xi.ATTR_TEX_COORD,ui.RG32F),new br(Xi.ATTR_COLOR,ui.RGBA32F)],$H=[new br(Xi.ATTR_POSITION,ui.RGB32F),new br(Xi.ATTR_TEX_COORD,ui.RG32F),new br(Xi.ATTR_COLOR,ui.RGBA32F),new br(Xi.ATTR_COLOR2,ui.RGBA32F)];function eV(e){for(var t=0,n=0;n>2,vV=new Ul((function(){return{x:0,y:0,z:0,u:0,v:0,color:An.WHITE.clone()}}),128),yV=null,xV=e("BaseRenderData",function(){function e(e){void 0===e&&(e=JH),this.material=null,this.chunk=null,this.dataHash=0,this.isMeshBuffer=!1,this._vc=0,this._ic=0,this._floatStride=0,this._vertexFormat=JH,this._floatStride=e===JH?gV:tV(e)>>2,this._vertexFormat=e}return e.prototype.isValid=function(){return this._ic>0&&this.chunk.vertexAccessor},K(e,[{key:"vertexCount",get:function(){return this._vc}},{key:"indexCount",get:function(){return this._ic}},{key:"stride",get:function(){return this._floatStride<<2}},{key:"floatStride",get:function(){return this._floatStride}},{key:"vertexFormat",get:function(){return this._vertexFormat}}]),e}()),SV=e("RenderData",function(e){function t(t,n){var i;return void 0===t&&(t=JH),(i=e.call(this,t)||this).indices=null,i.vertDirty=!0,i.frame=void 0,i.layer=0,i.blendHash=-1,i.textureHash=0,i.nodeDirty=!0,i.passDirty=!0,i.textureDirty=!0,i.hashDirty=!0,i._data=[],i._pivotX=0,i._pivotY=0,i._width=0,i._height=0,i._accessor=null,n||(n=zM.root.batcher2D.switchBufferAccessor(i._vertexFormat)),i._accessor=n,i}Z(t,e),t.add=function(e,n){void 0===e&&(e=JH),yV||(yV=new Gl((function(){return new t}),32));var i=yV.add();return i._floatStride=e===JH?gV:tV(e)>>2,i._vertexFormat=e,n||(n=zM.root.batcher2D.switchBufferAccessor(i._vertexFormat)),i._accessor=n,i},t.remove=function(e){var t=yV.data.indexOf(e);-1!==t&&(e.clear(),e._accessor=null,yV.removeAt(t))};var n=t.prototype;return n.resize=function(e,t){e===this._vc&&t===this._ic&&this.chunk||(this._vc=e,this._ic=t,this.chunk&&(this._accessor.recycleChunk(this.chunk),this.chunk=null),this.chunk=this._accessor.allocateChunk(e,t),this.updateHash())},n.resizeAndCopy=function(e,t){if(e!==this._vc||t!==this._ic||!this.chunk){this._vc=e,this._ic=t;var n=this.chunk;this.chunk=this._accessor.allocateChunk(e,t),n&&(this.chunk.vb.set(n.vb),this._accessor.recycleChunk(n)),this.updateHash()}},n.getMeshBuffer=function(){return this.chunk&&this._accessor?this._accessor.getMeshBuffer(this.chunk.bufferId):null},n.updateNode=function(e){this.layer=e.node.layer,this.nodeDirty=!1,this.hashDirty=!0},n.updatePass=function(e){this.material=e.getRenderMaterial(0),this.blendHash=e.blendHash,this.passDirty=!1,this.hashDirty=!0},n.updateTexture=function(e){this.frame=e,this.textureHash=e.getHash(),this.textureDirty=!1,this.hashDirty=!0},n.updateHash=function(){var e=""+(this.chunk?this.chunk.bufferId:-1)+this.layer+" "+this.blendHash+" "+this.textureHash;this.dataHash=po(e,666),this.hashDirty=!1},n.updateRenderData=function(e,t){if(this.passDirty&&(this.material=e.getRenderMaterial(0),this.blendHash=e.blendHash,this.passDirty=!1,this.hashDirty=!0),this.nodeDirty){var n=e.node.scene?e._getRenderScene():null;this.layer=e.node.layer,null!==n&&(this.nodeDirty=!1),this.hashDirty=!0}this.textureDirty&&(this.frame=t,this.textureHash=t.getHash(),this.textureDirty=!1,this.hashDirty=!0),this.hashDirty&&this.updateHash()},n.updateSizeNPivot=function(e,t,n,i){e===this._width&&t===this._height&&n===this._pivotX&&i===this._pivotY||(this._width=e,this._height=t,this._pivotX=n,this._pivotY=i,this.vertDirty=!0)},n.clear=function(){this.resize(0,0),this._data.length=0,this._pivotX=0,this._pivotY=0,this._width=0,this._height=0,this.indices=null,this.vertDirty=!0,this.material=null,this.nodeDirty=!0,this.passDirty=!0,this.textureDirty=!0,this.hashDirty=!0,this.layer=0,this.blendHash=-1,this.frame=null,this.textureHash=0,this.dataHash=0},K(t,[{key:"dataLength",get:function(){return this._data.length},set:function(e){var t=this._data;if(t.length!==e){var n=t.length,i=0;for(i=e;i>2,t._vertexFormat=e,t},t.remove=function(e){var t=EV.data.indexOf(e);-1!==t&&(EV.data[t].clear(),EV.removeAt(t))};var n=t.prototype;return n.request=function(e,t){var n=this._byteLength+e*this.stride;return!!this.reserve(e,t)&&(this._vc+=e,this._ic+=t,this._byteLength=n,this.vertexRange=this._vc,this.indexRange=this._ic,!0)},n.reserve=function(e,t){var n=this._byteLength+e*this.stride,i=this.indexCount+t;if(e+this.vertexCount>65535)return!1;var r=this.vData.byteLength,o=this.iData.length,a=this.vData.length,s=this.iData.length;if(n>r||i>o){for(;r=0&&t>=0&&n<=this.vData.byteLength&&this.iData.length,this._vc=e,this._ic=t,this._byteLength=n,this.updateRange(0,e,0,t)},n.updateRange=function(e,t,n,i){t>=0&&i>=0&&t<=this._vc&&this._ic,this.vertexStart=e,this.indexStart=n,this.vertexRange=t,this.indexRange=i},n.requestIA=function(e){this._initIAInfo(e);var t=this._iaPool.add();return t.firstIndex=this.indexStart,t.indexCount=this.indexRange,t},n.uploadBuffers=function(){if(0!==this._byteLength&&this._vertexBuffers[0]&&this._indexBuffer){var e=this._ic,t=new Float32Array(this.vData.buffer,0,this._byteLength>>2),n=new Uint16Array(this.iData.buffer,0,e),i=this._vertexBuffers[0];this._byteLength>i.size&&i.resize(this._byteLength),i.update(t);var r=e<<1;r>this._indexBuffer.size&&this._indexBuffer.resize(r),this._indexBuffer.update(n)}},n.freeIAPool=function(){this._iaPool&&this._iaPool.reset()},n.reset=function(){this._vc=0,this._ic=0,this._byteLength=0,this.vertexStart=0,this.vertexRange=0,this.indexStart=0,this.indexRange=0,this.lastFilledIndex=0,this.lastFilledVertex=0,this.material=null,this.freeIAPool()},n.clear=function(){this.reset(),this._iaPool&&this._iaPool.destroy(),this._vertexBuffers[0]&&(this._vertexBuffers[0].destroy(),this._vertexBuffers=[]),this._iaInfo=null,this.vData=new Float32Array(256*this.stride),this.iData=new Uint16Array(1536)},n._initIAInfo=function(e){var t=this;if(!this._iaInfo){var n=this.stride,i=this._vertexBuffers;i.length||i.push(e.createBuffer(new lr(_i.VERTEX|_i.TRANSFER_DST,mi.DEVICE,n,n)));var r=Uint16Array.BYTES_PER_ELEMENT;this._indexBuffer||(this._indexBuffer=e.createBuffer(new lr(_i.INDEX|_i.TRANSFER_DST,mi.DEVICE,r,r))),this._iaInfo=new Rr(this._vertexFormat,i,this._indexBuffer),this._iaPool=new Gl((function(){return e.createInputAssembler(t._iaInfo)}),1,(function(e){e.destroy()}))}},n._reallocBuffer=function(e,t){var n=this.vData;this.vData=new Float32Array(e),n&&this.vData.set(n,0);var i=this.iData;this.iData=new Uint16Array(t),i&&this.iData.set(i,0)},K(t,[{key:"formatByte",get:function(){return this.stride},set:function(){}},{key:"floatStride",get:function(){return this._floatStride}},{key:"vDataOffset",get:function(){return this._byteLength>>>2}}]),t}(xV)),EV=new Gl((function(){return new TV}),32),AV=new Wn,CV=new Wn,bV=(new bn,new Gn),wV=new Gn,RV=new Gn,PV=new Gn(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),IV=new ei,DV=function(t){return e({UITransform:t,UITransformComponent:t}),t}((nV=hc("cc.UITransform"),iV=wc(),rV=_c(110),oV=Ec(),aV=zc(),sV=Oc(),cV=zc(),lV=Oc(),nV(uV=iV(uV=rV(uV=oV(uV=pc(uV=Tc((dV=pV=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r=0&&o.y>=0&&o.x<=n&&o.y<=i&&(_=!0,a&&a.maskList))for(var p=a.maskList,d=this.node,m=p?p.length:0,g=0,v=0;d&&vy.index){p.length=v;break}}if(_)return!0}}}return!1},n.convertToNodeSpaceAR=function(e,t){return this.node.getWorldMatrix(RV),Gn.invert(bV,RV),t||(t=new bn),bn.transformMat4(t,e,bV)},n.convertToWorldSpaceAR=function(e,t){return this.node.getWorldMatrix(RV),t||(t=new bn),bn.transformMat4(t,e,RV)},n.getBoundingBox=function(){Gn.fromRTS(wV,this.node.getRotation(),this.node.getPosition(),this.node.getScale());var e=this._contentSize.width,t=this._contentSize.height,n=new ei(-this._anchorPoint.x*e,-this._anchorPoint.y*t,e,t);return n.transformMat4(wV),n},n.getBoundingBoxToWorld=function(){return this.node.parent?(this.node.parent.getWorldMatrix(RV),this.getBoundingBoxTo(RV)):this.getBoundingBox()},n.getBoundingBoxTo=function(e){Gn.fromRTS(wV,this.node.getRotation(),this.node.getPosition(),this.node.getScale());var n=this._contentSize.width,i=this._contentSize.height,r=new ei(-this._anchorPoint.x*n,-this._anchorPoint.y*i,n,i);if(Gn.multiply(RV,e,wV),r.transformMat4(RV),!this.node.children)return r;for(var o,a=oe(this.node.children);!(o=a()).done;){var s=o.value;if(s&&s.active){var c=s.getComponent(t);if(c){var l=c.getBoundingBoxTo(e);l&&ei.union(r,r,l)}}}return r},n.getComputeAABB=function(e){var t=this._contentSize.width,n=this._contentSize.height;IV.set(-this._anchorPoint.x*t,-this._anchorPoint.y*n,t,n),IV.transformMat4(this.node.worldMatrix);var i=IV.x+.5*IV.width,r=IV.y+.5*IV.height,o=this.node.worldPosition.z,a=IV.width/2,s=IV.height/2;return null!=e?(Hs.set(e,i,r,o,a,s,.001),e):new Hs(i,r,o,a,s,.001)},n._parentChanged=function(){this.node.getComponent("cc.RenderRoot2D")||this.node.parent&&t.insertChangeMap(this.node.parent)},n._markRenderDataDirty=function(){var e=this.node._uiProps.uiComp;e&&(e.markForUpdateRenderData(),e.renderData&&(e.renderData.vertDirty=!0))},t.insertChangeMap=function(e){var n=e.uuid;t.priorityChangeNodeMap.has(n)||t.priorityChangeNodeMap.set(n,e)},t._sortChildrenSibling=function(e){var t=e.children;t&&t.sort((function(e,t){var n=e._uiProps.uiTransformComp,i=t._uiProps.uiTransformComp,r=(n?n._priority:0)-(i?i._priority:0);return 0===r?e.getSiblingIndex()-t.getSiblingIndex():r}))},t._sortSiblings=function(){t.priorityChangeNodeMap.forEach((function(e){t._sortChildrenSibling(e),e._updateSiblingIndex(),e.emit("childrenSiblingOrderChanged")})),t.priorityChangeNodeMap.clear()},t._cleanChangeMap=function(){t.priorityChangeNodeMap.clear()},K(t,[{key:"contentSize",get:function(){return this._contentSize},set:function(e){this._contentSize.equals(e)||(this._contentSize.set(e),this.node.emit(BE.SIZE_CHANGED),this._markRenderDataDirty())}},{key:"width",get:function(){return this._contentSize.width},set:function(e){this._contentSize.width!==e&&(this._contentSize.width=e,this.node.emit(BE.SIZE_CHANGED),this._markRenderDataDirty())}},{key:"height",get:function(){return this._contentSize.height},set:function(e){this.contentSize.height!==e&&(this._contentSize.height=e,this.node.emit(BE.SIZE_CHANGED),this._markRenderDataDirty())}},{key:"anchorPoint",get:function(){return this._anchorPoint},set:function(e){this._anchorPoint.equals(e)||(this._anchorPoint.set(e),this.node.emit(BE.ANCHOR_CHANGED,this._anchorPoint),this._markRenderDataDirty())}},{key:"anchorX",get:function(){return this._anchorPoint.x},set:function(e){this._anchorPoint.x!==e&&(this._anchorPoint.x=e,this.node.emit(BE.ANCHOR_CHANGED,this._anchorPoint),this._markRenderDataDirty())}},{key:"anchorY",get:function(){return this._anchorPoint.y},set:function(e){this._anchorPoint.y!==e&&(this._anchorPoint.y=e,this.node.emit(BE.ANCHOR_CHANGED,this._anchorPoint),this._markRenderDataDirty())}},{key:"priority",get:function(){return this._priority},set:function(e){this._priority!==e&&(this.node.getComponent("cc.RenderRoot2D")?P(6706):(this._priority=e,this.node.parent&&t.insertChangeMap(this.node.parent)))}},{key:"visibility",get:function(){var e=zM.root.batcher2D.getFirstRenderCamera(this.node);return e?e.visibility:0}},{key:"cameraPriority",get:function(){var e=zM.root.batcher2D.getFirstRenderCamera(this.node);return e?e.priority:0}}]),t}(Ku),pV.EventType=BE,pV.priorityChangeNodeMap=new Map,se((hV=dV).prototype,"contentSize",[aV,sV],Object.getOwnPropertyDescriptor(hV.prototype,"contentSize"),hV.prototype),se(hV.prototype,"anchorPoint",[cV,lV],Object.getOwnPropertyDescriptor(hV.prototype,"anchorPoint"),hV.prototype),fV=se(hV.prototype,"_contentSize",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Jn(100,100)}}),_V=se(hV.prototype,"_anchorPoint",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Wn(.5,.5)}}),uV=hV))||uV)||uV)||uV)||uV)||uV)||uV));zM.on(BM.EVENT_AFTER_UPDATE,DV._sortSiblings),zM.on(BM.EVENT_BEFORE_SCENE_LAUNCH,DV._cleanChangeMap),function(e){e[e.DISABLED=0]="DISABLED",e[e.CLEAR=1]="CLEAR",e[e.ENTER_LEVEL=2]="ENTER_LEVEL",e[e.ENABLED=3]="ENABLED",e[e.EXIT_LEVEL=4]="EXIT_LEVEL",e[e.CLEAR_INVERTED=5]="CLEAR_INVERTED",e[e.ENTER_LEVEL_INVERTED=6]="ENTER_LEVEL_INVERTED"}(mV||(mV={}));var OV,MV,NV,LV,FV,BV,zV,kV,UV,GV,HV,VV,jV,WV,qV,XV,YV,KV,QV,ZV,JV=e("StencilManager",function(){function e(){this.stage=mV.DISABLED,this._maskStack=[],this._stencilPattern={stencilTest:!0,func:Ai.ALWAYS,stencilMask:65535,writeMask:65535,failOp:Ci.KEEP,zFailOp:Ci.KEEP,passOp:Ci.KEEP,ref:1},this.stencilStateMap=new Map,this.stencilStateMapWithDepth=new Map}var t=e.prototype;return t.pushMask=function(e){this._maskStack.push(e)},t.clear=function(e){e.stencilStage=e.inverted?mV.CLEAR_INVERTED:mV.CLEAR},t.enterLevel=function(e){e.graphics.stencilStage=e.inverted?mV.ENTER_LEVEL_INVERTED:mV.ENTER_LEVEL},t.enableMask=function(){this.stage=mV.ENABLED},t.exitMask=function(){0!==this._maskStack.length&&(this._maskStack.pop(),0===this._maskStack.length?this.stage=mV.DISABLED:this.stage=mV.ENABLED)},t.getWriteMask=function(){return 1<0},n._postCanRender=function(){},n.updateMaterial=function(){if(this._customMaterial)return this.setMaterial(this._customMaterial,0),this._renderData&&(this._renderData.material=this._customMaterial,this.markForUpdateRenderData(),this._renderData.passDirty=!0),void(this._blendHash=-1);var e=this._updateBuiltinMaterial();this.setMaterial(e,0),this._renderData&&(this._renderData.material=e,this.markForUpdateRenderData()),this._updateBlendFunc()},n._updateColor=function(){this.node._uiProps.colorDirty=!0,this._assembler&&(this._assembler.updateColor(this),this._renderFlag=this._canRender())},n._updateBlendFunc=function(){var e=this._blendState.targets[0];e||(e=new To,this._blendState.setTarget(0,e)),e.blendDst===this._dstBlendFactor&&e.blendSrc===this._srcBlendFactor||(e.blend=!0,e.blendDstAlpha=bi.ONE_MINUS_SRC_ALPHA,e.blendDst=this._dstBlendFactor,e.blendSrc=this._srcBlendFactor,this.renderData&&(this.renderData.passDirty=!0)),this.updateBlendHash()},n.getBlendState=function(){return this._blendState},n._nodeStateChange=function(){this._renderData&&this.markForUpdateRenderData();for(var e=0;e>16,e|=e>>8,e|=e>>4,e|=e>>2,e|=e>>1,++e}function TW(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"}(gW||(gW={})),function(e){e[e.DEFAULT=1]="DEFAULT",e[e.FORWARD=2]="FORWARD",e[e.SHADOWCAST=4]="SHADOWCAST"}(vW||(vW={}));var EW,AW,CW,bW=function(){function e(e){this._device=void 0,this._format=ui.UNKNOWN,this._formatSize=0,this._chunks=[],this._chunkCount=0,this._handles=[],this._region0=new ir,this._region1=new ir,this._region2=new ir,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=Qr[e.format];this._format=e.format,this._formatSize=t.size,this._channels=t.count,this._bufferViewCtor=oo(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));++r);if(i>=0){var o=this._chunks[n];o.start+=e;var a={chunkIdx:n,start:i,end:i+e,texture:o.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,SW(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,o-=c,l+=c),o>0&&(this._region1.texOffset.x=a,this._region1.texOffset.y=s,o>e.texture.width?(this._region1.texExtent.width=e.texture.width,this._region1.texExtent.height=Math.floor(o/e.texture.width),c=this._region1.texExtent.width*this._region1.texExtent.height):(c=o,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,o-=c,l+=c),o>0&&(this._region2.texOffset.x=a,this._region2.texOffset.y=s,this._region2.texExtent.width=o,this._region2.texExtent.height=1,n.push(new this._bufferViewCtor(t,l*this._formatSize,o*this._channels)),i.push(this._region2)),this._device.copyBuffersToTexture(n,e.texture,i)},t._findAvailableSpace=function(e,t){var n=this._chunks[t],i=!1,r=n.start;if(r+e<=n.size)i=!0;else{r=0;for(var o=this._handles.filter((function(e){return e.chunkIdx===t})).sort((function(e,t){return e.start-t.start})),a=0;an.end?r+e<=n.size?i=!0:e<=n.end&&(n.start=r=0,i=!0):r===n.end&&(n.start=r=0,n.end=n.size,e<=n.end&&(i=!0)),i){n.start+=e;var o={chunkIdx:t,start:r,end:r+e,texture:n.texture};return this._handles.push(o),o}}var a=Math.sqrt(e/this._formatSize),s=this._roundUpFn&&this._roundUpFn(a,this._formatSize)||Math.max(1024,SW(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}(),wW=function(e){if(void 0===xW[e]){var t=1<10||(d=.5*(o+s),m=.5*(a+c),g=.5*((h=.5*(t+i))+(_=.5*(i+o))),v=.5*((f=.5*(n+r))+(p=.5*(r+a))),((C=NW((i-s)*(A=c-n)-(r-c)*(E=s-t)))+(b=NW((o-s)*A-(a-c)*E)))*(C+b)=2*PW)u=2*PW;else for(;u<0;)u+=2*PW;else if(NW(u)>=2*PW)u=2*-PW;else for(;u>0;)u-=2*PW;for(c=0|DW(1,IW(NW(u)/(.5*PW)+.5,5)),h=NW(4/3*(1-OW(s=u/c/2))/MW(s)),a||(h=-h),T=0;T<=c;T++)p=t+(f=OW(l=r+u*(T/c)))*i,d=n+(_=MW(l))*i,m=-_*i*h,g=f*i*h,0===T?e.moveTo(p,d):e.bezierCurveTo(v+x,y+S,p-m,d-g,p,d),v=p,y=d,x=m,S=g}(this,e,t,n,i,r,o)},t.ellipse=function(e,t,n,i){BW(this,e,t,n,i),this._curPath.complex=!1},t.circle=function(e,t,n){BW(this,e,t,n,n),this._curPath.complex=!1},t.rect=function(e,t,n,i){this.moveTo(e,t),this.lineTo(e+n,t),this.lineTo(e+n,t+i),this.lineTo(e,t+i),this.close(),this._curPath.complex=!1},t.roundRect=function(e,t,n,i,r){!function(e,t,n,i,r,o){if(o<.1)e.rect(t,n,i,r);else{var a=IW(o,.5*NW(i))*LW(i),s=IW(o,.5*NW(r))*LW(r);e.moveTo(t,n+s),e.lineTo(t,n+r-s),e.bezierCurveTo(t,n+r-s*(1-FW),t+a*(1-FW),n+r,t+a,n+r),e.lineTo(t+i-a,n+r),e.bezierCurveTo(t+i-a*(1-FW),n+r,t+i,n+r-s*(1-FW),t+i,n+r-s),e.lineTo(t+i,n+s),e.bezierCurveTo(t+i,n+s*(1-FW),t+i-a*(1-FW),n,t+i-a,n),e.lineTo(t+a,n),e.bezierCurveTo(t+a*(1-FW),n,t,n+s*(1-FW),t,n+s),e.close()}}(this,e,t,n,i,r),this._curPath.complex=!1},t.clear=function(){this.pathLength=0,this.pathOffset=0,this.pointsOffset=0,this.dataOffset=0,this._curPath=null,this.paths.length=0,this._points.length=0;for(var e=this._renderDataList,t=0,n=e.length;t0){for(var n=0;nn)for(var i=n;i=0&&o.y>=0&&o.x<=i&&o.y<=r;else if(this.type===kq.ELLIPSE){var c=i/2,l=r/2,u=o.x-.5*i,h=o.y-.5*r;s=u*u/(c*c)+h*h/(l*l)<1}return this._inverted&&(s=!s),s},n._render=function(e){e.commitComp(this,this.renderData,null,this._assembler,null)},n._postRender=function(e){this._postAssembler&&e.commitComp(this,null,null,this._postAssembler,null)},n._nodeStateChange=function(t){e.prototype._nodeStateChange.call(this,t),this._updateGraphics()},n._canRender=function(){return!!e.prototype._canRender.call(this)&&null!==this._graphics&&(this._type!==kq.IMAGE_STENCIL||null!==this._spriteFrame)},n._flushAssembler=function(){var e=t.Assembler.getAssembler(this),n=t.PostAssembler.getAssembler(this);this._assembler!==e&&(this.destroyRenderData(),this._assembler=e),this._postAssembler!==n&&(this._postAssembler=n),this._useRenderData()},n._createGraphics=function(){if(!this._graphics){var e=this._graphics=new zq;e._objFlags|=ul.Flags.IsOnLoadCalled,e.node=this.node,e.node.getWorldMatrix(),e.lineWidth=0;var t=An.WHITE.clone();t.a=0,e.fillColor=t}this._updateMaterial()},n._updateGraphics=function(){if(this._graphics&&(this._type===kq.RECT||this._type===kq.ELLIPSE)){var e=this.node._uiProps.uiTransformComp,t=this._graphics;t.clear();var n=e.contentSize,i=n.width,r=n.height,o=e.anchorPoint,a=-i*o.x,s=-r*o.y;if(this._type===kq.RECT)t.rect(a,s,i,r);else if(this._type===kq.ELLIPSE){for(var c=function(e,t,n){Vq.length=0;for(var i=2*Math.PI/n,r=0;r"]),this._specialSymbolArray.push([/&/g,"&"]),this._specialSymbolArray.push([/"/g,'"']),this._specialSymbolArray.push([/'/g,"'"])}var t=e.prototype;return t.parse=function(e){this._resultObjectArray.length=0,this._stack.length=0;for(var t=0,n=e.length;t",t),r=-1;if(i>=0&&(r=e.lastIndexOf("<",i))",r+1)),r<0)this._stack.pop(),this._processResult(e.substring(t)),t=n;else{var o=e.substring(t,r),a=e.substring(r+1,i);""===a&&(o=e.substring(t,i+1)),this._processResult(o),-1===i?i=r:"/"===e.charAt(r+1)?this._stack.pop():this._addToStack(a),t=i+1}}return this._resultObjectArray},t._attributeToObject=function(e){e=e.trim();var t={},n=/^(color|size)(\s)*=/.exec(e),i="",r=0,o="";if(n){if(i=n[0],""===(e=e.substring(i.length).trim()))return t;switch(r=e.indexOf(" "),i[0]){case"c":t.color=r>-1?e.substring(0,r).trim():e;break;case"s":t.size=parseInt(e)}return r>-1&&(o=e.substring(r+1).trim(),t.event=this._processEventHandler(o)),t}if((n=/^(br(\s)*\/)/.exec(e))&&n[0].length>0&&(i=n[0].trim()).startsWith("br")&&"/"===i[i.length-1])return t.isNewLine=!0,this._resultObjectArray.push({text:"",style:{isNewLine:!0}}),t;var a="";if((n=/^(img(\s)*src(\s)*=[^>]+\/)/.exec(e))&&n[0].length>0&&(i=n[0].trim()).startsWith("img")&&"/"===i[i.length-1]){var s;n=eY.exec(e);for(var c=!1;n;){if(i=(e=e.substring(e.indexOf(n[0]))).substr(0,n[0].length),s=(r=(a=e.substring(i.length).trim()).indexOf(" "))>-1?a.substr(0,r):a,i=(i=i.replace(/[^a-zA-Z]/g,"").trim()).toLowerCase(),e=a.substring(r).trim(),s.endsWith("/")&&(s=s.slice(0,-1)),"src"===i){switch(s.charCodeAt(0)){case 34:case 39:c=!0,s=s.slice(1,-1)}t.isImage=!0,t.src=s}else if("height"===i)t.imageHeight=parseInt(s);else if("width"===i)t.imageWidth=parseInt(s);else if("align"===i){switch(s.charCodeAt(0)){case 34:case 39:s=s.slice(1,-1)}t.imageAlign=s.toLowerCase()}else"offset"===i?t.imageOffset=s:"click"===i&&(t.event=this._processEventHandler(i+"="+s));t.event&&"param"===i&&(t.event[i]=s.replace(/^"|"$/g,"")),n=eY.exec(e)}return c&&t.isImage&&this._resultObjectArray.push({text:"",style:t}),{}}if(n=/^(outline(\s)*[^>]*)/.exec(e)){var l={color:"#ffffff",width:1};if(e=n[0].substring("outline".length).trim()){var u,h=/(\s)*color(\s)*=|(\s)*width(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/;for(n=h.exec(e);n;)i=(e=e.substring(e.indexOf(n[0]))).substr(0,n[0].length),u=(r=(a=e.substring(i.length).trim()).indexOf(" "))>-1?a.substr(0,r):a,i=(i=i.replace(/[^a-zA-Z]/g,"").trim()).toLowerCase(),e=a.substring(r).trim(),"click"===i?t.event=this._processEventHandler(i+"="+u):"color"===i?l.color=u:"width"===i&&(l.width=parseInt(u)),t.event&&"param"===i&&(t.event[i]=u.replace(/^"|"$/g,"")),n=h.exec(e)}t.outline=l}if((n=/^(on|u|b|i)(\s)*/.exec(e))&&n[0].length>0){switch(i=n[0],e=e.substring(i.length).trim(),i[0]){case"u":t.underline=!0;break;case"i":t.italic=!0;break;case"b":t.bold=!0}if(""===e)return t;t.event=this._processEventHandler(e)}return t},t._processEventHandler=function(e){for(var t={},n=0,i=!1,r=$X.exec(e);r;){var o=r[0],a="";if(i=!1,'"'===(e=e.substring(o.length).trim()).charAt(0))(n=e.indexOf('"',1))>-1&&(a=e.substring(1,n).trim(),i=!0),n++;else if("'"===e.charAt(0))(n=e.indexOf("'",1))>-1&&(a=e.substring(1,n).trim(),i=!0),n++;else{var s=/(\S)+/.exec(e);n=(a=s?s[0]:"").length}i&&(t[o=o.substring(0,o.length-1).trim()]=a),e=e.substring(n).trim(),r=$X.exec(e)}return t},t._addToStack=function(e){var t=this._attributeToObject(e);if(0===this._stack.length)this._stack.push(t);else{if(t.isNewLine||t.isImage)return;var n=this._stack[this._stack.length-1];for(var i in n)t[i]||(t[i]=n[i]);this._stack.push(t)}},t._processResult=function(e){0!==e.length&&(e=this._escapeSpecialSymbol(e),this._stack.length>0?this._resultObjectArray.push({text:e,style:this._stack[this._stack.length-1]}):this._resultObjectArray.push({text:e}))},t._escapeSpecialSymbol=function(e){for(var t,n=oe(this._specialSymbolArray);!(t=n()).done;){var i=t.value,r=i[0],o=i[1];e=e.replace(r,o)}return e},e}()),nY=function(t){return e({LabelOutline:t,LabelOutlineComponent:t}),t}((Wq=hc("cc.LabelOutline"),qq=wc(),Xq=_c(110),Yq=Ec(),Kq=fc(mW),Qq=Oc(),Zq=Oc(),Wq(Jq=qq(Jq=Xq(Jq=Yq(Jq=Kq(Jq=Tc((nX=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r=0;t--){var n=e[t];if(n.name===oK||n.name===aK){n.parent===this.node?n.parent=null:e.splice(t,1);var i=lK(n.name);i.node=n,n.name===oK?(i.comp=n.getComponent(mW),sK.put(i)):(i.comp=n.getComponent(rY),cK.put(i))}}e.length=0,this._segments.length=0,this._labelSegmentsCache.length=0,this._linesWidth.length=0,this._lineOffsetX=0,this._lineCount=1,this._labelWidth=0,this._labelHeight=0,this._layoutDirty=!0},n._activateChildren=function(e){for(var t=this.node.children.length-1;t>=0;t--){var n=this.node.children[t];n.name!==oK&&n.name!==aK||(n.active=e)}},n._addLabelSegment=function(e,t){var n;if(0===this._labelSegmentsCache.length)n=this._createFontLabel(e);else{var i=(n=this._labelSegmentsCache.pop()).node.getComponent(mW);i&&(i.string=e)}return n.styleIndex=t,n.lineCount=this._lineCount,n.node._uiProps.uiTransformComp.setAnchorPoint(0,0),n.node.layer=this.node.layer,this.node.addChild(n.node),this._applyTextAttribute(n),this._segments.push(n),n},n._updateRichTextWithMaxWidth=function(e,t,n){var i=t;if(this._lineOffsetX>0&&i+this._lineOffsetX>this._maxWidth)for(var r=0;this._lineOffsetX<=this._maxWidth;){var o=this._getFirstWordLen(e,r,e.length),a=e.substr(r,o),s=this._measureText(n,a);if(!(this._lineOffsetX+s<=this._maxWidth)){if(r>0){var c=e.substr(0,r);this._addLabelSegment(c,n),e=e.substr(r,e.length),i=this._measureText(n,e)}this._updateLineInfo();break}this._lineOffsetX+=s,r+=o}if(i>this._maxWidth)for(var l=GH(e,i,this._maxWidth,this._measureText(n)),u=0;u1&&u0?(s*=a=u/c,c*=a):(s*=a=this._lineHeight/c,c*=a),l>0&&(s=l),this._maxWidth>0?(this._lineOffsetX+s>this._maxWidth&&this._updateLineInfo(),this._lineOffsetX+=s):(this._lineOffsetX+=s,this._lineOffsetX>this._labelWidth&&(this._labelWidth=this._lineOffsetX)),r.node._uiProps.uiTransformComp.setContentSize(s,c),r.lineCount=this._lineCount,r.clickHandler="",r.clickParam="";var h=t.event;h&&(r.clickHandler=h.click,r.clickParam=h.param)}else P(4400)}},n._updateRichText=function(){if(this.enabledInHierarchy){var e=rK.parse(this._string);if(!this._needsUpdateTextLayout(e))return this._textArray=e.slice(),void this._updateLabelSegmentTextAttributes();this._textArray=e.slice(),this._resetState();for(var t,n=!1,i=0;i0){var l=this._measureText(i,c);this._updateRichTextWithMaxWidth(c,l,i),a.length>1&&sthis._labelWidth&&(this._labelWidth=this._lineOffsetX),a.length>1&&s0&&(this._labelWidth=this._maxWidth),this._labelHeight=(this._lineCount+wH)*this._lineHeight,this.node._uiProps.uiTransformComp.setContentSize(this._labelWidth,this._labelHeight),this._updateRichTextPosition(),this._layoutDirty=!1}},n._getFirstWordLen=function(e,t,n){var i=e.charAt(t);if(BH(i)||zH(i))return 1;for(var r=1,o=t+1;ot&&(e=0,t=c);var l=this._labelWidth*(.5*this._horizontalAlign-r);switch(this._horizontalAlign){case hW.LEFT:break;case hW.CENTER:l-=this._linesWidth[c-1]/2;break;case hW.RIGHT:l-=this._linesWidth[c-1]}var u=s.node.position;if(s.node.setPosition(e+l,this._lineHeight*(n-c)-this._labelHeight*o,u.z),c===t&&(e+=s.node._uiProps.uiTransformComp.width),s.node.getComponent(rY)){var h=s.node.position.clone(),f=this._lineHeight,_=this._lineHeight*(1+wH);switch(s.node._uiProps.uiTransformComp.anchorY){case 1:h.y+=f+(_-f)/2;break;case.5:h.y+=_/2;break;default:h.y+=(_-f)/2}if(s.imageOffset){var p=s.imageOffset.split(",");if(1===p.length&&p[0]){var d=parseFloat(p[0]);Number.isInteger(d)&&(h.y+=d)}else if(2===p.length){var m=parseFloat(p[0]),g=parseFloat(p[1]);Number.isInteger(m)&&(h.x+=m),Number.isInteger(g)&&(h.y+=g)}}s.node.position=h}var v=s.node.getComponent(nY);if(v){var y=s.node.position.clone();y.y-=v.width,s.node.position=y}}},n._convertLiteralColorValue=function(e){var t=e.toUpperCase();return An[t]?An[t]:(new An).fromHEX(e)},n._applyTextAttribute=function(e){var t=e.node.getComponent(mW);if(t){this._resetLabelState(t);var n,i=e.styleIndex;if(this._textArray[i]&&(n=this._textArray[i].style),n){if(t.color=this._convertLiteralColorValue(n.color||"white"),t.isBold=!!n.bold,t.isItalic=!!n.italic,t.isUnderline=!!n.underline,n.outline){var r=e.node.getComponent(nY);r||(r=e.node.addComponent(nY)),r.color=this._convertLiteralColorValue(n.outline.color),r.width=n.outline.width}t.fontSize=n.size||this._fontSize,e.clickHandler="",e.clickParam="";var o=n.event;o&&(e.clickHandler=o.click||"",e.clickParam=o.param||"")}t.cacheMode=this._cacheMode,this._font instanceof hH&&!this._isSystemFontUsed?t.font=this._font:t.fontFamily=this._fontFamily,t.useSystemFont=this._isSystemFontUsed,t.lineHeight=this._lineHeight,t.updateRenderData(!0);var a=t._assembler;a&&a.updateRenderData(t)}},n._applyLayer=function(){for(var e,t=oe(this._segments);!(e=t()).done;)e.value.node.layer=this.node.layer},n._resetLabelState=function(e){e.fontSize=this._fontSize,e.color=An.WHITE,e.isBold=!1,e.isItalic=!1,e.isUnderline=!1},K(t,[{key:"string",get:function(){return this._string},set:function(e){this._string!==e&&(this._string=e,this._updateRichTextStatus())}},{key:"horizontalAlign",get:function(){return this._horizontalAlign},set:function(e){this.horizontalAlign!==e&&(this._horizontalAlign=e,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"fontSize",get:function(){return this._fontSize},set:function(e){this._fontSize!==e&&(this._fontSize=e,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"fontFamily",get:function(){return this._fontFamily},set:function(e){this._fontFamily!==e&&(this._fontFamily=e,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"font",get:function(){return this._font},set:function(e){this._font!==e&&(this._font=e,this._layoutDirty=!0,this._font?(this.useSystemFont=!1,this._onTTFLoaded()):this.useSystemFont=!0,this._updateRichTextStatus())}},{key:"useSystemFont",get:function(){return this._isSystemFontUsed},set:function(e){this._isSystemFontUsed!==e&&(this._isSystemFontUsed=e,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"cacheMode",get:function(){return this._cacheMode},set:function(e){this._cacheMode!==e&&(this._cacheMode=e,this._updateRichTextStatus())}},{key:"maxWidth",get:function(){return this._maxWidth},set:function(e){this._maxWidth!==e&&(this._maxWidth=e,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"lineHeight",get:function(){return this._lineHeight},set:function(e){this._lineHeight!==e&&(this._lineHeight=e,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"imageAtlas",get:function(){return this._imageAtlas},set:function(e){this._imageAtlas!==e&&(this._imageAtlas=e,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"handleTouchEvent",get:function(){return this._handleTouchEvent},set:function(e){this._handleTouchEvent!==e&&(this._handleTouchEvent=e,this.enabledInHierarchy&&(this.handleTouchEvent?this._addEventListeners():this._removeEventListeners()))}}]),t}(Ku),JY.HorizontalAlign=hW,JY.VerticalAlign=fW,se((kY=$Y).prototype,"string",[kc,TY],Object.getOwnPropertyDescriptor(kY.prototype,"string"),kY.prototype),se(kY.prototype,"horizontalAlign",[EY,AY],Object.getOwnPropertyDescriptor(kY.prototype,"horizontalAlign"),kY.prototype),se(kY.prototype,"fontSize",[CY],Object.getOwnPropertyDescriptor(kY.prototype,"fontSize"),kY.prototype),se(kY.prototype,"fontFamily",[bY],Object.getOwnPropertyDescriptor(kY.prototype,"fontFamily"),kY.prototype),se(kY.prototype,"font",[wY,RY],Object.getOwnPropertyDescriptor(kY.prototype,"font"),kY.prototype),se(kY.prototype,"useSystemFont",[PY,IY],Object.getOwnPropertyDescriptor(kY.prototype,"useSystemFont"),kY.prototype),se(kY.prototype,"cacheMode",[DY,OY],Object.getOwnPropertyDescriptor(kY.prototype,"cacheMode"),kY.prototype),se(kY.prototype,"maxWidth",[MY],Object.getOwnPropertyDescriptor(kY.prototype,"maxWidth"),kY.prototype),se(kY.prototype,"lineHeight",[NY],Object.getOwnPropertyDescriptor(kY.prototype,"lineHeight"),kY.prototype),se(kY.prototype,"imageAtlas",[LY,FY],Object.getOwnPropertyDescriptor(kY.prototype,"imageAtlas"),kY.prototype),se(kY.prototype,"handleTouchEvent",[BY],Object.getOwnPropertyDescriptor(kY.prototype,"handleTouchEvent"),kY.prototype),UY=se(kY.prototype,"_lineHeight",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 40}}),GY=se(kY.prototype,"_string",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"RichText"}}),HY=se(kY.prototype,"_horizontalAlign",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return hW.LEFT}}),VY=se(kY.prototype,"_fontSize",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 40}}),jY=se(kY.prototype,"_maxWidth",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),WY=se(kY.prototype,"_fontFamily",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"Arial"}}),qY=se(kY.prototype,"_font",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),XY=se(kY.prototype,"_isSystemFontUsed",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),YY=se(kY.prototype,"_userDefinedFont",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),KY=se(kY.prototype,"_cacheMode",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return pW.NONE}}),QY=se(kY.prototype,"_imageAtlas",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),ZY=se(kY.prototype,"_handleTouchEvent",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),zY=kY))||zY)||zY)||zY)||zY)||zY));c.RichText=fK;var _K=function(t){return e({UIMeshRenderer:t,UIModelComponent:t}),t}(hc("cc.UIMeshRenderer")(hK=wc()(hK=_c(110)(hK=Ec()(hK=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r0)for(o=t;o=t;o-=i)a=_Q(o,e[o],e[o+1],a);return a&&lQ(a,a.next)&&(pQ(a),a=a.next),a}function QK(e,t){if(void 0===t&&(t=null),!e)return e;t||(t=e);var n=e,i=!1;do{if(i=!1,n.steiner||!lQ(n,n.next)&&0!==cQ(n.prev,n,n.next))n=n.next;else{if(pQ(n),(n=t=n.prev)===n.next)return null;i=!0}}while(i||n!==t);return t}function ZK(e,t,n,i,r,o,a){if(void 0===a&&(a=0),e){!a&&o&&function(e,t,n,i){var r=e;do{null===r.z&&(r.z=rQ(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){var t=0,n=null,i=null,r=null,o=null,a=0,s=0,c=0,l=1;do{for(n=e,e=null,o=null,a=0;n;){for(a++,i=n,s=0,t=0;t0||c>0&&i;)0===s?(r=i,i=i.nextZ,c--):0!==c&&i?n.z<=i.z?(r=n,n=n.nextZ,s--):(r=i,i=i.nextZ,c--):(r=n,n=n.nextZ,s--),o?o.nextZ=r:e=r,r.prevZ=o,o=r;n=i}o.nextZ=null,l*=2}while(a>1)}(r)}(e,i,r,o);for(var s=e,c=null,l=null;e.prev!==e.next;)if(c=e.prev,l=e.next,o?$K(e,i,r,o):JK(e))t.push(c.i/n),t.push(e.i/n),t.push(l.i/n),pQ(e),e=l.next,s=l.next;else if((e=l)===s){a?1===a?ZK(e=eQ(e,t,n),t,n,i,r,o,2):2===a&&tQ(e,t,n,i,r,o):ZK(QK(e),t,n,i,r,o,1);break}}}function JK(e){var t=e.prev,n=e,i=e.next;if(cQ(t,n,i)>=0)return!1;for(var r=e.next.next;r!==e.prev;){if(aQ(t.x,t.y,n.x,n.y,i.x,i.y,r.x,r.y)&&cQ(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function $K(e,t,n,i){var r=e.prev,o=e,a=e.next;if(cQ(r,o,a)>=0)return!1;for(var s=r.xo.x?r.x>a.x?r.x:a.x:o.x>a.x?o.x:a.x,u=r.y>o.y?r.y>a.y?r.y:a.y:o.y>a.y?o.y:a.y,h=rQ(s,c,t,n,i),f=rQ(l,u,t,n,i),_=e.nextZ;_&&_.z<=f;){if(_!==e.prev&&_!==e.next&&aQ(r.x,r.y,o.x,o.y,a.x,a.y,_.x,_.y)&&cQ(_.prev,_,_.next)>=0)return!1;_=_.nextZ}for(_=e.prevZ;_&&_.z>=h;){if(_!==e.prev&&_!==e.next&&aQ(r.x,r.y,o.x,o.y,a.x,a.y,_.x,_.y)&&cQ(_.prev,_,_.next)>=0)return!1;_=_.prevZ}return!0}function eQ(e,t,n){var i=e;do{var r=i.prev,o=i.next.next;!lQ(r,o)&&uQ(r,i,i.next,o)&&hQ(r,o)&&hQ(o,r)&&(t.push(r.i/n),t.push(i.i/n),t.push(o.i/n),pQ(i),pQ(i.next),i=e=o),i=i.next}while(i!==e);return i}function tQ(e,t,n,i,r,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&sQ(a,s)){var c=fQ(a,s);return a=QK(a,a.next),c=QK(c,c.next),ZK(a,t,n,i,r,o),void ZK(c,t,n,i,r,o)}s=s.next}a=a.next}while(a!==e)}function nQ(e,t){return e.x-t.x}function iQ(e,t){if(t=function(e,t){var n=t,i=e.x,r=e.y,o=-1/0,a=null;do{if(r<=n.y&&r>=n.next.y){var s=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=i&&s>o){if(o=s,s===i){if(r===n.y)return n;if(r===n.next.y)return n.next}a=n.x=n.x&&n.x>=u&&aQ(ra.x)&&hQ(n,e)&&(a=n,f=c),n=n.next;return a}(e,t)){var n=fQ(t,e);QK(n,n.next)}}function rQ(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)/r)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)/r)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function oQ(e){var t=e,n=e;do{t.x=0&&(e-a)*(i-s)-(n-a)*(t-s)>=0&&(n-a)*(o-s)-(r-a)*(i-s)>=0}function sQ(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&uQ(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&hQ(e,t)&&hQ(t,e)&&function(e,t){var n=e,i=!1,r=(e.x+t.x)/2,o=(e.y+t.y)/2;do{n.y>o!=n.next.y>o&&r<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}(e,t)}function cQ(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function lQ(e,t){return e.x===t.x&&e.y===t.y}function uQ(e,t,n,i){return!!(lQ(e,t)&&lQ(n,i)||lQ(e,i)&&lQ(n,t))||cQ(e,t,n)>0!=cQ(e,t,i)>0&&cQ(n,i,e)>0!=cQ(n,i,t)>0}function hQ(e,t){return cQ(e.prev,e,e.next)<0?cQ(e,t,e.next)>=0&&cQ(e,e.prev,t)>=0:cQ(e,t,e.prev)<0||cQ(e,e.next,t)<0}function fQ(e,t){var n=new YK(e.i,e.x,e.y),i=new YK(t.i,t.x,t.y),r=e.next,o=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,o.next=i,i.prev=o,i}function _Q(e,t,n,i){var r=new YK(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function pQ(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function dQ(e,t,n){n=n||3;var i=t?t.length:0,r=i?t[0]*n:e.length,o=KK(e,0,r,n,!0),a=[];if(!o)return a;var s=0,c=0,l=0,u=0,h=0,f=0,_=0;if(i&&(o=function(e,t,n,i){var r,o=[],a=0,s=null;for(a=0,r=t.length;a80*n){s=l=e[0],c=u=e[1];for(var p=n;pl&&(l=h),f>u&&(u=f);_=Math.max(l-s,u-c)}return ZK(o,a,n,s,c,_),a}for(var mQ=Math.PI,gQ=Math.min,vQ=Math.max,yQ=Math.ceil,xQ=Math.acos,SQ=Math.cos,TQ=Math.sin,EQ=Math.atan2,AQ=null,CQ=null,bQ=new An,wQ=[],RQ=0;RQ<4;RQ++)wQ.push(new bn);function PQ(e,t,n){return en?n:e}var IQ={useModel:!0,updateRenderData:function(){},fillBuffers:function(){},renderIA:function(){},getRenderData:function(e,t){if(!CQ)return null;var n=CQ.getRenderDataList(),i=n[CQ.dataOffset];if(!i)return null;var r=i,o=r?r.vertexStart+t:0;return(o>65535||3*o>131070)&&(++CQ.dataOffset,CQ.dataOffset0&&(r=1/t);for(var o=e.paths,a=e.pathOffset,s=e.pathLength;a1e-6){var x=1/p;x>600&&(x=600),f.dmx*=x,f.dmy*=x}f.dx*h.dy-h.dx*f.dy>0&&(f.flags|=CW.PT_LEFT),p*(d=vQ(11,gQ(h.len,f.len)*r))*d<1&&(f.flags|=CW.PT_INNERBEVEL),f.flags&CW.PT_CORNER&&(p*i*i<1||n===AW.BEVEL||n===AW.ROUND)&&(f.flags|=CW.PT_BEVEL),0!=(f.flags&(CW.PT_BEVEL|CW.PT_INNERBEVEL))&&c.bevel++,h=f,f=l[_+1]}}},_flattenPaths:function(e){for(var t=e.paths,n=e.pathOffset,i=e.pathLength;n2&&a.equals(s)&&(r.closed=!0,o.pop(),a=o[o.length-1]);for(var c=0,l=o.length;cm&&(g-=2*mQ),this._vSet(f,_,1),this._vSet(l-o*i,t.y-a*i,-1);for(var v=PQ(yQ((m-g)/mQ)*r,2,r),y=0;y0&&i>0&&x+l.w*KQ>cZ&&!zH(h)){zQ.push(a),a=0,n++,i=0,r-=iZ*this._getFontScale()+0,g=!0;break}HQ.x=x,HQ.y=r-l.offsetY*KQ,this._recordLetterInfo(HQ,h,y,n),y+1HQ.y-l.h*KQ&&(p=HQ.y-l.h*KQ)}else this._recordPlaceholderInfo(y,h),console.log("Can't find letter definition in texture atlas "+VQ.atlasName+" for letter:"+h);else this._recordPlaceholderInfo(y,h)}g||(i=m,s<_&&(s=_),c>p&&(c=p),o<(a=d)&&(o=a),u+=f)}else zQ.push(a),a=0,n++,i=0,r-=iZ*this._getFontScale()+0,this._recordPlaceholderInfo(u,h),u++}return zQ.push(a),WQ=(jQ=n+1)*iZ*this._getFontScale(),jQ>1&&(WQ+=0*(jQ-1)),GQ.width=aZ,GQ.height=sZ,aZ<=0&&(GQ.width=parseFloat(o.toFixed(2))+2*KH.margin),sZ<=0&&(GQ.height=parseFloat(WQ.toFixed(2))+2*KH.margin),XQ=GQ.height,YQ=0,s>0&&(XQ=GQ.height+s),c<-WQ&&(YQ=WQ+c),!0},_getFirstCharLen:function(){return 1},_getFontScale:function(){return rZ===_W.SHRINK?KQ:1},_getFirstWordLen:function(e,t,n){var i=e.charAt(t);if(BH(i)||"\n"===i||zH(i))return 1;var r=1,o=KH.fontAtlas.getLetterDefinitionForChar(i,KH);if(!o)return r;for(var a=o.xAdvance*KQ+nZ,s=t+1;scZ&&!zH(i)&&cZ>0)return r;if(a+=o.xAdvance*KQ+nZ,"\n"===i||zH(i)||BH(i))break;r++}return r},_multilineTextWrapByWord:function(){return this._multilineTextWrap(this._getFirstWordLen)},_multilineTextWrapByChar:function(){return this._multilineTextWrap(this._getFirstCharLen)},_recordPlaceholderInfo:function(e,t){if(e>=BQ.length){var n=new OQ;BQ.push(n)}BQ[e].char=t,BQ[e].hash=""+t.charCodeAt(0)+KH.hash,BQ[e].valid=!1},_recordLetterInfo:function(e,t,n,i){if(n>=BQ.length){var r=new OQ;BQ.push(r)}var o=""+t.charCodeAt(0)+KH.hash;BQ[n].line=i,BQ[n].char=t,BQ[n].hash=o,BQ[n].valid=KH.fontAtlas.getLetter(o).valid,BQ[n].x=e.x,BQ[n].y=e.y},_alignText:function(){WQ=0,zQ.length=0,this._multilineTextWrapByWord(),this._computeAlignmentOffset(),rZ===_W.SHRINK&&JQ>0&&this._isVerticalClamp()&&this._shrinkLabelToContentSize(this._isVerticalClamp),this._updateQuads()||rZ===_W.SHRINK&&this._shrinkLabelToContentSize(this._isHorizontalClamp)},_scaleFontSizeDown:function(e){var t=!0;e||(e=.1,t=!1),JQ=e,t&&this._updateContent()},_shrinkLabelToContentSize:function(e){for(var t=0,n=0|JQ,i=0;t>1;if(r<=0)break;KQ=r/$Q,this._multilineTextWrapByWord(),this._computeAlignmentOffset(),e()?n=i-1:t=i}t>=0&&this._scaleFontSizeDown(t)},_isVerticalClamp:function(){return WQ>GQ.height},_isHorizontalClamp:function(){for(var e=!1,t=0,n=ZQ.length;t0)if(oZ){if(zQ[a]>GQ.width&&(o>GQ.width||o<0)){e=!0;break}}else if(o>GQ.width){e=!0;break}}}return e},_isHorizontalClamped:function(e,t){var n=zQ[t],i=e>GQ.width||e<0;return oZ?n>GQ.width&&i:i},_updateQuads:function(){if(!NQ)return!1;var e=QQ?QQ.texture:KH.fontAtlas.getTexture(),t=NQ.renderData;t.dataLength=0,t.resize(0,0);for(var n=LQ.anchorPoint,i=GQ,r=n.x*i.width,o=n.y*i.height,a=!0,s=0,c=ZQ.length;s0){if(h>XQ){var f=h-XQ;MQ.y+=f,MQ.height-=f,h-=f}h-u.h*KQ0&&this._isHorizontalClamped(p,_))if(rZ===_W.CLAMP)MQ.width=0;else if(rZ===_W.SHRINK){if(GQ.width>u.w){a=!1;break}MQ.width=0}if(MQ.height>0&&MQ.width>0){var d=this._determineRect(),m=l.x+kQ[l.line];this.appendQuad(NQ,e,MQ,d,m-r,h-o,KQ)}}else console.warn("Can't find letter in this bitmap-font")}}return a},appendQuad:function(){},_determineRect:function(){var e=QQ.isRotated(),t=QQ.getOriginalSize(),n=QQ.getRect(),i=QQ.getOffset(),r=i.x+(t.width-n.width)/2,o=i.y-(t.height-n.height)/2;if(e){var a=MQ.x;MQ.x=n.x+n.height-MQ.y-MQ.height-o,MQ.y=a+n.y-r,MQ.y<0&&(MQ.height+=o)}else MQ.x+=n.x-r,MQ.y+=n.y+o;return e},_computeAlignmentOffset:function(){switch(kQ.length=0,eZ){case hW.LEFT:for(var e=0;e0&&(n=n+e.margin+e.out.toHEX()),""+e.fontSize+e.fontFamily+t+n}(KH)},_getFontDesc:function(){return KH.fontSize.toString()+"px "+KH.fontFamily},_computeHorizontalKerningForText:function(){},_determineRect:function(){return!1}}),pZ=new An(255,255,255,255),dZ={createData:function(e){return e.requestRenderData()},fillBuffers:function(e){if(e.renderData){var t=e.node;pZ.a=255*t._uiProps.opacity,WG(t,0,e.renderData,pZ)}},updateColor:function(){},appendQuad:hZ.appendQuad};Fe(dZ,_Z);var mZ=mW.Overflow,gZ=(1/255).toFixed(3),vZ=null,yZ=null,xZ=null,SZ="",TZ="",EZ=0,AZ=0,CZ=[],bZ=new Jn,wZ=0,RZ=0,PZ=0,IZ=new An,DZ="",OZ=mZ.NONE,MZ=!1,NZ=null,LZ=An.BLACK.clone(),FZ=null,BZ=An.BLACK.clone(),zZ=new ei,kZ=Jn.ZERO.clone(),UZ=Jn.ZERO.clone(),GZ=Wn.ZERO.clone(),HZ=Wn.ZERO.clone(),VZ=0,jZ=0,WZ=!1,qZ=!1,XZ=!1,YZ=["left","center","right"],KZ={getAssemblerData:function(){return mW._canvasPool.get()},resetAssemblerData:function(e){e&&mW._canvasPool.put(e)},updateRenderData:function(e){if(e.renderData){if(e.renderData.vertDirty){var t=e.node._uiProps.uiTransformComp;this._updateFontFamily(e),this._updateProperties(e,t),this._calculateLabelFont(),this._updateLabelDimensions(),this._updateTexture(e),this._calDynamicAtlas(e),e.actualFontSize=EZ,t.setContentSize(bZ),this.updateVertexData(e),this.updateUVs(e),e.markForUpdateRenderData(!1),vZ=null,yZ=null,xZ=null}e.spriteFrame&&e.renderData.updateRenderData(e,e.spriteFrame)}},updateVertexData:function(){},updateUVs:function(){},_updateFontFamily:function(e){DZ=e.useSystemFont?e.fontFamily||"Arial":e.font&&e.font._nativeAsset||"Arial"},_updateProperties:function(e,t){var n=e.assemblerData;n&&(vZ=n.context,yZ=n.canvas,xZ=e.spriteFrame,TZ=e.string.toString(),EZ=e.fontSize,AZ=EZ,OZ=e.overflow,UZ.width=bZ.width=t.width,UZ.height=bZ.height=t.height,jZ=e.underlineHeight,wZ=e.lineHeight,RZ=e.horizontalAlign,PZ=e.verticalAlign,IZ=e.color,e.node._uiProps.opacity,WZ=e.isBold,qZ=e.isItalic,XZ=e.isUnderline,MZ=OZ!==mZ.NONE&&(OZ===mZ.RESIZE_HEIGHT||e.enableWrapText),(NZ=(NZ=nY&&e.getComponent(nY))&&NZ.enabled&&NZ.width>0?NZ:null)&&LZ.set(NZ.color),(FZ=(FZ=qK&&e.getComponent(qK))&&FZ.enabled?FZ:null)&&BZ.set(FZ.color),this._updatePaddingRect())},_updatePaddingRect:function(){var e=0,t=0,n=0,i=0,r=0;if(kZ.width=kZ.height=0,NZ&&(e=t=n=i=r=NZ.width,kZ.width=kZ.height=2*r),FZ){var o=FZ.blur+r,a=FZ.offset.x,s=FZ.offset.y;n=Math.max(n,-a+o),i=Math.max(i,a+o),e=Math.max(e,s+o),t=Math.max(t,-s+o)}if(qZ){var c=AZ*Math.tan(.20943951);i+=c,kZ.width+=c}zZ.x=n,zZ.y=e,zZ.width=n+i,zZ.height=e+t},_calculateFillTextStartPosition:function(){var e=0;RZ===hW.RIGHT?e=bZ.width-zZ.width:RZ===hW.CENTER&&(e=(bZ.width-zZ.width)/2);var t=this._getLineHeight()*(CZ.length-1),n=EZ*(1-wH/2);if(PZ!==fW.TOP){var i=t+zZ.height+EZ-bZ.height;PZ===fW.BOTTOM?n-=i+=wH/2*EZ:n-=i/2}n+=0*EZ,GZ.set(e+zZ.x,n+zZ.y)},_updateTexture:function(e){if(vZ&&yZ){vZ.clearRect(0,0,yZ.width,yZ.height),vZ.font=SZ,this._calculateFillTextStartPosition();var t=this._getLineHeight();vZ.lineJoin="round",NZ?(vZ.fillStyle="rgba("+LZ.r+", "+LZ.g+", "+LZ.b+", "+gZ+")",vZ.fillRect(0,0,yZ.width,yZ.height)):e._srcBlendFactor===bi.SRC_ALPHA&&(vZ.fillStyle="rgba("+IZ.r+", "+IZ.g+", "+IZ.b+", "+gZ+")",vZ.fillRect(0,0,yZ.width,yZ.height)),vZ.fillStyle="rgb("+IZ.r+", "+IZ.g+", "+IZ.b+")";var n=GZ.x,i=0;this._drawTextEffect(GZ,t);for(var r=0;r1&&FZ,i=this._measureText(vZ,SZ),r=0,o=0;FZ&&this._setupShadow(),NZ&&this._setupOutline();for(var a=0;a>1)<=0){w(4003);break}EZ=l,SZ=this._getFontDesc(),vZ.font=SZ;var u=this._getLineHeight();for(i=0,n=0;na?c=l-1:s=l}0===s?w(4003):(EZ=s,SZ=this._getFontDesc(),vZ.font=SZ)}else{for(i=e.length*this._getLineHeight(),n=0;nr?t:r}n=(CZ.length+wH)*this._getLineHeight();var o=parseFloat(t.toFixed(2)),a=parseFloat(n.toFixed(2));bZ.width=o+zZ.width,bZ.height=a+zZ.height,UZ.width=o+kZ.width,UZ.height=a+kZ.height;break;case mZ.SHRINK:this._calculateShrinkFont(e),this._calculateWrapText(e);break;case mZ.CLAMP:this._calculateWrapText(e);break;case mZ.RESIZE_HEIGHT:this._calculateWrapText(e);var s=(CZ.length+wH)*this._getLineHeight();bZ.height=s+zZ.height,UZ.height=s+kZ.height}}}},QZ=An.WHITE.clone(),ZZ={createData:function(e){var t=e.requestRenderData();t.dataLength=2,t.resize(4,6);var n=t.chunk.vb;n[3]=n[21]=n[22]=n[31]=0,n[4]=n[12]=n[13]=n[30]=1;for(var i=5,r=0;r<4;r++)An.toArray(n,QZ,i),i+=9;return t},fillBuffers:function(e){var t=e.renderData.chunk,n=e.renderData.data,i=e.node,r=t.vb,o=n[0],a=n[1];i.updateWorldTransform();var s=i._pos,c=i._rot,l=i._scale,u=o.x*l.x,h=a.x*l.x,f=o.y*l.y,_=a.y*l.y,p=c.x,d=c.y,m=c.z,g=c.w,v=p*d,y=m*g,x=p*p-d*d,S=g*g-m*m,T=S+x,E=2*(v-y),A=S-x,C=2*(v+y),b=s.x,w=s.y;r[0]=T*u+E*f+b,r[1]=A*f+C*u+w,r[9]=T*h+E*f+b,r[10]=A*f+C*h+w,r[18]=T*u+E*_+b,r[19]=A*_+C*u+w,r[27]=T*h+E*_+b,r[28]=A*_+C*h+w;var R=t.bufferId,P=t.vertexOffset,I=t.vertexAccessor.getMeshBuffer(t.bufferId),D=t.vertexAccessor.getIndexBuffer(R),O=I.indexOffset;D[O++]=P,D[O++]=P+1,D[O++]=P+2,D[O++]=P+2,D[O++]=P+1,D[O++]=P+3,I.indexOffset+=6},updateVertexData:function(e){var t=e.renderData;if(t){var n=e.node._uiProps.uiTransformComp,i=n.width,r=n.height,o=n.anchorX*i,a=n.anchorY*r,s=t.data;s[0].x=-o,s[0].y=-a,s[1].x=i-o,s[1].y=r-a}},updateUVs:function(e){var t=e.renderData;if(t&&e.ttfSpriteFrame){var n=t.chunk.vb,i=e.ttfSpriteFrame.uv;n[3]=i[0],n[4]=i[1],n[12]=i[2],n[13]=i[3],n[21]=i[4],n[22]=i[5],n[30]=i[6],n[31]=i[7]}},updateColor:function(){}};Fe(ZZ,KZ);var JZ=e("labelAssembler",{getAssembler:function(e){var t=ZZ;return e.font instanceof CH?t=hZ:e.cacheMode===mW.CacheMode.CHAR&&(t=dZ),t}});mW.Assembler=JZ;var $Z=rY.FillType,eJ=new Gn,tJ=new bn,nJ={updateRenderData:function(e){var t=e.spriteFrame;JG.packToDynamicAtlas(e,t);var n=e.renderData;if(n&&t){if(n.updateRenderData(e,t),!n.vertDirty)return;var i=e.fillStart,r=e.fillRange;r<0&&(i+=r,r=-r),r=(r=(r=i+r)>1?1:r)<0?0:r;var o=(i=(i=i>1?1:i)<0?0:i)+(r=(r-=i)<0?0:r);o=o>1?1:o,this.updateUVs(e,i,o),this.updateVertexData(e,i,o)}},updateUVs:function(e,t,n){var i=e.spriteFrame,r=e.renderData.chunk.vb,o=i.width,a=i.height,s=i.rect,c=0,l=0,u=0,h=0,f=0,_=0,p=0,d=0,m=0,g=0;switch(i.isRotated()?(c=s.x/o,l=(s.y+s.width)/a,u=f=c,p=m=(s.x+s.height)/o,_=g=l,h=d=s.y/a):(c=s.x/o,l=(s.y+s.height)/a,u=p=c,f=m=(s.x+s.width)/o,h=_=l,d=g=s.y/a),e.fillType){case $Z.HORIZONTAL:r[3]=u+(f-u)*t,r[4]=h+(_-h)*t,r[12]=u+(f-u)*n,r[13]=h+(_-h)*n,r[21]=p+(m-p)*t,r[22]=d+(g-d)*t,r[30]=p+(m-p)*n,r[31]=d+(g-d)*n;break;case $Z.VERTICAL:r[3]=u+(p-u)*t,r[4]=h+(d-h)*t,r[12]=f+(m-f)*t,r[13]=_+(g-_)*t,r[21]=u+(p-u)*n,r[22]=h+(d-h)*n,r[30]=f+(m-f)*n,r[31]=_+(g-_)*n;break;default:D(2626)}},updateVertexData:function(e,t,n){var i=e.renderData.data,r=e.node._uiProps.uiTransformComp,o=r.width,a=r.height,s=r.anchorX*o,c=r.anchorY*a,l=-s,u=-c,h=o-s,f=a-c,_=0;switch(e.fillType){case $Z.HORIZONTAL:_=l+(h-l)*n,l+=(h-l)*t,h=_;break;case $Z.VERTICAL:_=u+(f-u)*n,u+=(f-u)*t,f=_;break;default:D(2626)}i[0].x=l,i[0].y=u,i[1].x=h,i[1].y=u,i[2].x=l,i[2].y=f,i[3].x=h,i[3].y=f},createData:function(e){var t=e.requestRenderData();t.dataLength=4,t.resize(4,6);for(var n,i=oe(t.data);!(n=i()).done;)n.value.z=0;return t},updateWorldVertexData:function(e,t){e.node.getWorldMatrix(eJ);for(var n=e.renderData.floatStride,i=e.renderData.data,r=t.vb,o=0,a=0;a<4;a++){var s=i[a];bn.transformMat4(tJ,s,eJ),r[o=a*n]=tJ.x,r[o+1]=tJ.y,r[o+2]=tJ.z}},fillBuffers:function(e){var t=e.renderData,n=t.chunk;(e.node.hasChangedFlags||t.vertDirty)&&(this.updateWorldVertexData(e,n),t.vertDirty=!1);var i=n.bufferId,r=n.vertexOffset,o=n.vertexAccessor.getMeshBuffer(n.bufferId),a=n.vertexAccessor.getIndexBuffer(i),s=o.indexOffset;a[s++]=r,a[s++]=r+1,a[s++]=r+2,a[s++]=r+2,a[s++]=r+1,a[s++]=r+3,o.indexOffset+=6},updateColor:function(e){for(var t=e.renderData,n=t.chunk.vb,i=t.floatStride,r=5,o=e.color,a=o.r/255,s=o.g/255,c=o.b/255,l=e.node._uiProps.opacity,u=0;u<4;u++)n[r]=a,n[r+1]=s,n[r+2]=c,n[r+3]=l,r+=i}},iJ=2*Math.PI,rJ=1e-6,oJ=new Gn,aJ=new bn,sJ=[new Wn,new Wn,new Wn,new Wn],cJ=new Array(4),lJ=new Array(8),uJ=[new Wn,new Wn,new Wn,new Wn],hJ=[new Wn,new Wn,new Wn,new Wn],fJ=new Wn,_J=[new Wn,new Wn,new Wn,new Wn];function pJ(e,t,n,i,r,o,a){var s=Math.sin(o);s=Math.abs(s)>rJ?s:0;var c=Math.cos(o),l=0,u=0;if(0!==(c=Math.abs(c)>rJ?c:0)){if(l=s/c,(e-r.x)*c>0){var h=r.y+l*(e-r.x);a[0].x=e,a[0].y=h}if((t-r.x)*c>0){var f=r.y+l*(t-r.x);a[2].x=t,a[2].y=f}}if(0!==s){if(u=c/s,(i-r.y)*s>0){var _=r.x+u*(i-r.y);a[3].x=_,a[3].y=i}if((n-r.y)*s>0){var p=r.x+u*(n-r.y);a[1].x=p,a[1].y=n}}}function dJ(e,t){var n=t.x-e.x,i=t.y-e.y;if(0===n&&0===i)return 0;if(0===n)return i>0?.5*Math.PI:1.5*Math.PI;var r=Math.atan(i/n);return n<0&&(r+=Math.PI),r}function mJ(e,t,n,i,r){var o=cJ,a=o[0],s=o[1],c=o[2],l=o[3];e[t].x=n.x,e[t].y=n.y,e[t+1].x=i.x,e[t+1].y=i.y,e[t+2].x=r.x,e[t+2].y=r.y,gJ((n.x-a)/(c-a),(n.y-s)/(l-s),e,t),gJ((i.x-a)/(c-a),(i.y-s)/(l-s),e,t+1),gJ((r.x-a)/(c-a),(r.y-s)/(l-s),e,t+2)}function gJ(e,t,n,i){var r=lJ,o=r[0]+(r[2]-r[0])*e,a=r[4]+(r[6]-r[4])*e,s=r[1]+(r[3]-r[1])*e,c=r[5]+(r[7]-r[5])*e,l=n[i];l.u=o+(a-o)*t,l.v=s+(c-s)*t}for(var vJ={useModel:!1,createData:function(e){return e.requestRenderData()},updateRenderData:function(e){var t=e.spriteFrame;JG.packToDynamicAtlas(e,t),this.updateUVs(e);var n=e.renderData;if(n&&t){if(!n.vertDirty)return;var i=n.data,r=e.fillStart,o=e.fillRange;for(o<0&&(r+=o,o=-o);r>=1;)r-=1;for(;r<0;)r+=1;var a=(r*=iJ)+(o*=iJ);!function(e){var t=e.node._uiProps.uiTransformComp,n=t.width,i=t.height,r=t.anchorX*n,o=t.anchorY*i,a=-r,s=-o,c=n-r,l=i-o,u=cJ;u[0]=a,u[1]=s,u[2]=c,u[3]=l;var h=e.fillCenter,f=fJ.x=Math.min(Math.max(0,h.x),1)*(c-a)+a,_=fJ.y=Math.min(Math.max(0,h.y),1)*(l-s)+s;sJ[0].x=sJ[3].x=a,sJ[1].x=sJ[2].x=c,sJ[0].y=sJ[1].y=s,sJ[2].y=sJ[3].y=l;for(var p,d=oe(_J);!(p=d()).done;){var m=p.value;Wn.set(m,0,0)}f!==u[0]&&Wn.set(_J[0],3,0),f!==u[2]&&Wn.set(_J[2],1,2),_!==u[1]&&Wn.set(_J[1],0,1),_!==u[3]&&Wn.set(_J[3],2,3)}(e),function(e){var t=e.width,n=e.height,i=e.getRect(),r=0,o=0,a=0,s=0,c=lJ;e.isRotated()?(r=i.x/t,o=(i.x+i.height)/t,a=i.y/n,s=(i.y+i.width)/n,c[0]=c[2]=r,c[4]=c[6]=o,c[3]=c[7]=s,c[1]=c[5]=a):(r=i.x/t,o=(i.x+i.width)/t,a=i.y/n,s=(i.y+i.height)/n,c[0]=c[4]=r,c[2]=c[6]=o,c[1]=c[3]=s,c[5]=c[7]=a)}(t),pJ(cJ[0],cJ[2],cJ[1],cJ[3],fJ,r,uJ),pJ(cJ[0],cJ[2],cJ[1],cJ[3],fJ,r+o,hJ);for(var s=0,c=0;c<4;++c){var l=_J[c];if(l)if(o>=iJ)n.dataLength=s+3,mJ(i,s,fJ,sJ[l.x],sJ[l.y]),s+=3;else{var u=dJ(fJ,sJ[l.x]),h=dJ(fJ,sJ[l.y]);h=a||(u>=r?(n.dataLength=s+3,mJ(i,s,fJ,sJ[l.x],h>=a?hJ[c]:sJ[l.y]),s+=3):h>r&&(h<=a?(n.dataLength=s+3,mJ(i,s,fJ,uJ[c],sJ[l.y]),s+=3):(n.dataLength=s+3,mJ(i,s,fJ,uJ[c],hJ[c]),s+=3))),u+=iJ,h+=iJ}}n.resize(s,s),n.updateRenderData(e,t)}},fillBuffers:function(e){var t=e.node,n=e.renderData,i=n.chunk;(t.hasChangedFlags||n.vertDirty)&&(this.updateWorldVertexAndUVData(e,i),n.vertDirty=!1),this.updataColorLate(e);for(var r=i.bufferId,o=i.vertexOffset,a=i.vertexAccessor.getMeshBuffer(i.bufferId),s=i.vertexAccessor.getIndexBuffer(r),c=a.indexOffset,l=0;l1?1:p,d=Number.isNaN(d)||d>1?1:d,f=f<0?0:f,_=_<0?0:_,t[0].x=-o,t[0].y=-a,t[1].x=c*p-o,t[1].y=h*d-a,t[2].x=t[1].x+f,t[2].y=t[1].y+_,t[3].x=i-o,t[3].y=r-a},fillBuffers:function(e){var t=e.renderData,n=t.chunk;(e.node.hasChangedFlags||t.vertDirty)&&(this.updateWorldVertexData(e,n),t.vertDirty=!1);for(var i=n.bufferId,r=n.vertexOffset,o=n.vertexAccessor.getMeshBuffer(n.bufferId),a=n.vertexAccessor.getIndexBuffer(i),s=o.indexOffset,c=0;c<3;++c)for(var l=0;l<3;++l){var u=r+4*c+l;a[s++]=u,a[s++]=u+1,a[s++]=u+4,a[s++]=u+1,a[s++]=u+5,a[s++]=u+4}o.indexOffset=s},updateWorldVertexData:function(e,t){e.node.getWorldMatrix(EJ);for(var n=e.renderData,i=n.floatStride,r=n.data,o=t.vb,a=0,s=0;s<4;++s)for(var c=r[s],l=0;l<4;++l){var u=r[l];bn.set(TJ,u.x,c.y,0),bn.transformMat4(TJ,TJ,EJ),a=(4*s+l)*i,o[a++]=TJ.x,o[a++]=TJ.y,o[a++]=TJ.z}},updateUVs:function(e){if(e.spriteFrame)for(var t=e.renderData,n=t.chunk.vb,i=t.floatStride,r=e.spriteFrame.uvSliced,o=3,a=0;a<16;a++)n[o]=r[a].u,n[o+1]=r[a].v,o+=i},updateColor:function(e){for(var t=e.renderData,n=t.chunk.vb,i=t.floatStride,r=5,o=e.color,a=o.r/255,s=o.g/255,c=o.b/255,l=e.node._uiProps.opacity,u=0;u<16;u++)n[r]=a,n[r+1]=s,n[r+2]=c,n[r+3]=l,r+=i}},CJ=[],bJ=0;bJ<4;bJ++)CJ.push(new bn);var wJ=new Gn,RJ={createData:function(e){return e.requestRenderData()},updateRenderData:function(e){var t=e.renderData,n=e.spriteFrame;if(n&&t&&(t.updateRenderData(e,n),t.vertDirty)){var i=e.node._uiProps.uiTransformComp,r=Math.abs(i.width),o=Math.abs(i.height),a=n.getRect(),s=n.insetLeft,c=n.insetRight,l=a.width-s-c,u=n.insetTop,h=n.insetBottom,f=a.height-u-h,_=r-s-c,p=o-u-h;_=_>0?_:0,p=p>0?p:0;var d=0===l?_:_/l,m=0===f?p:p/f,g=Math.ceil(m+2),v=Math.ceil(d+2);t.dataLength=Math.max(8,g+1,v+1),this.updateVerts(e,_,p,g,v),t.resize(g*v*4,g*v*6)}},updateUVs:function(e){e.renderData.vertDirty=!0,e.markForUpdateRenderData()},fillBuffers:function(e){var t=e.node,n=e.renderData,i=n.chunk;(t.hasChangedFlags||n.vertDirty)&&(this.updateWorldVertexAndUVData(e,i),n.vertDirty=!1),this.updataColorLate(e);for(var r=i.bufferId,o=i.vertexOffset,a=i.vertexAccessor.getMeshBuffer(i.bufferId),s=i.vertexAccessor.getIndexBuffer(r),c=a.indexOffset,l=0;l0?S:0,T=T>0?T:0;for(var E=0===g?S:S/g,A=0===x?T:T/x,C=Math.ceil(A+2),b=Math.ceil(E+2),w=0,R=0,P=0,I=0,D=0,O=0,M=C;Ox?T>=X*x?1:A%1:A;for(var K=0,Q=b;Kg?S>=K*g?1:E%1:E;var Z=w+3,J=Z+1;h?(0===X?(W[0]=_[0].u,W[1]=_[0].u,W[2]=_[4].u+(_[8].u-_[4].u)*j):X1?1:s.width/(d+m),T=s.height/(v+y)>1?1:s.height/(v+y);o=g>0?Math.floor(1e3*t)/1e3%g==0?g:t%g:t,a=x>0?Math.floor(1e3*n)/1e3%x==0?x:n%x:n;for(var E=0;E<=r;E++)0===E?c[E].x=-_:E>0&&E0?E===r-1?d+o+g*(E-2)-_:d+Math.min(g,t)+g*(E-2)-_:d+t-_:E===r&&(c[E].x=Math.min(d+t+m,h)-_);for(var A=0;A<=i;A++)0===A?c[A].y=-p:A>0&&A0?A===i-1?y+a+(A-2)*x-p:y+Math.min(x,n)+(A-2)*x-p:y+n-p:A===i&&(c[A].y=Math.min(y+n+v,f)-p)},updataColorLate:function(e){for(var t=e.renderData,n=t.chunk.vb,i=t.floatStride,r=t.vertexCount,o=5,a=e.color,s=a.r/255,c=a.g/255,l=a.b/255,u=e.node._uiProps.opacity,h=0;hthis._initVDataCount||i>this._initIDataCount)},t.uploadBuffers=function(){if(0!==this.byteOffset&&this._dirty){for(var e=oh.__isWebIOS14OrIPadOS14Env?this._nextFreeIAHandle:1,t=this.byteOffset,n=this.indexOffset,i=0;i>2),a=new Uint16Array(this.iData.buffer,0,n),s=r.vertexBuffers[0];t>s.size&&s.resize(t),s.update(o),2*n>r.indexBuffer.size&&r.indexBuffer.resize(2*n),r.indexBuffer.update(a)}this._dirty=!1}},t.createNewIA=function(e){var t,n,i;if(oh.__isWebIOS14OrIPadOS14Env||!this._iaPool[0]){var r=this._vertexFormatBytes=this._floatsPerVertex*Float32Array.BYTES_PER_ELEMENT,o=Uint16Array.BYTES_PER_ELEMENT,a=e.createBuffer(new lr(_i.VERTEX|_i.TRANSFER_DST,mi.HOST|mi.DEVICE,r,r));i=e.createBuffer(new lr(_i.INDEX|_i.TRANSFER_DST,mi.HOST|mi.DEVICE,o,o)),n=[a],this._iaInfo=new Rr(this._attributes,n,i),t=e.createInputAssembler(this._iaInfo)}else t=e.createInputAssembler(this._iaInfo),n=this._iaInfo.vertexBuffers,i=this._iaInfo.indexBuffer;return{ia:t,vertexBuffers:n,indexBuffer:i}},K(e,[{key:"attributes",get:function(){return this._attributes}},{key:"vertexFormatBytes",get:function(){return this._vertexFormatBytes}}]),e}()),zJ=[rD.EventType.MOUSE_DOWN,rD.EventType.MOUSE_MOVE,rD.EventType.MOUSE_UP,rD.EventType.MOUSE_WHEEL],kJ=[rD.EventType.TOUCH_START,rD.EventType.TOUCH_MOVE,rD.EventType.TOUCH_END,rD.EventType.TOUCH_CANCEL],UJ=(new(function(){function e(){this.priority=YI.UI,this._isListDirty=!1,this._inDispatchCount=0,this._pointerEventProcessorList=[],this._processorListToAdd=[],this._processorListToRemove=[],oD._registerEventDispatcher(this),TI.callbacksInvoker.on(Bb.ADD_POINTER_EVENT_PROCESSOR,this.addPointerEventProcessor,this),TI.callbacksInvoker.on(Bb.REMOVE_POINTER_EVENT_PROCESSOR,this.removePointerEventProcessor,this),TI.callbacksInvoker.on(Bb.MARK_LIST_DIRTY,this._markListDirty,this)}var t=e.prototype;return t.dispatchEvent=function(e){var t=e.type;return kJ.includes(t)?this.dispatchEventTouch(e):!zJ.includes(t)||this.dispatchEventMouse(e)},t.addPointerEventProcessor=function(e){0===this._inDispatchCount?this._pointerEventProcessorList.includes(e)||(this._pointerEventProcessorList.push(e),this._isListDirty=!0):this._processorListToAdd.includes(e)||this._processorListToAdd.push(e),tt.array.remove(this._processorListToRemove,e)},t.removePointerEventProcessor=function(e){0===this._inDispatchCount?(tt.array.remove(this._pointerEventProcessorList,e),this._isListDirty=!0):this._processorListToRemove.includes(e)||this._processorListToRemove.push(e),tt.array.remove(this._processorListToAdd,e)},t.dispatchEventMouse=function(e){this._inDispatchCount++,this._sortPointerEventProcessorList();for(var t=this._pointerEventProcessorList,n=t.length,i=!0,r=0;r0){var s=a.claimedTouchIdList.indexOf(i.getID());if(-1!==s){if(a._handleEventTouch(e),e.type!==Lb.TOUCH_END&&e.type!==Lb.TOUCH_CANCEL||tt.array.removeAt(a.claimedTouchIdList,s),r=!1,!e.preventSwallow)break;e.preventSwallow=!1}}}return--this._inDispatchCount<=0&&this._updatePointerEventProcessorList(),r},t._updatePointerEventProcessorList=function(){for(var e=this._processorListToAdd,t=e.length,n=0;n=i){s=n[l],o=c,a=l;break}if(s)break}if(s||(o=this._allocateBuffer(),(r=this._buffers[o])&&r.checkCapacity(e,t)&&(a=0,s=this._freeLists[o][a])),s){var u=s.offset/this.vertexFormatBytes,h=new Float32Array(r.vData.buffer,s.offset,i>>2).fill(0);return this._allocateChunkFromEntry(o,a,s,i),new HJ(this,o,u,h,t)}return P(9004,i),null},n.recycleChunk=function(e){var t=this._freeLists[e.bufferId],n=this._buffers[e.bufferId],i=e.vertexOffset*this.vertexFormatBytes,r=e.vb.byteLength;if(0!==r){for(var o=!1,a=0,s=null,c=t[a];c&&c.offset=0,9004,e,n.offset,n.length),0===r?(this._freeLists[e].splice(t,1),GJ.free(n)):(n.offset+=i,n.length=r)},n._allocateBuffer=function(){N(this._buffers.length===this._freeLists.length,9003);var e=new BJ,t=this._vCount*this._floatsPerVertex;e.initialize(this._device,this._attributes,t,this._iCount),this._buffers.push(e);var n=GJ.alloc();n.offset=0,n.length=e.vData.byteLength;var i=[n];return this._freeLists.push(i),this._buffers.length-1},t}(UJ);VJ.IB_SCALE=4;var jJ=new kr(null),WJ=new Gn,qJ=e("UI",function(){function e(e){var t=this;this.device=void 0,this._screens=[],this._staticVBBuffer=null,this._bufferAccessors=new Map,this._drawBatchPool=void 0,this._batches=void 0,this._currBID=-1,this._indexStart=0,this._emptyMaterial=new iv,this._currRenderData=null,this._currMaterial=this._emptyMaterial,this._currTexture=null,this._currSampler=null,this._currStaticRoot=null,this._currComponent=null,this._currTransform=null,this._currTextureHash=0,this._currSamplerHash=0,this._currLayer=0,this._currDepthStencilStateStage=null,this._currIsStatic=!1,this._currHash=0,this._pOpacity=1,this._opacityDirty=0,this._descriptorSetCache=new YJ,this._meshDataArray=[],this._root=e,this.device=e.device,this._batches=new Hl(64),this._drawBatchPool=new Ul((function(){return new jK}),128,(function(e){return e.destroy(t)}))}var t=e.prototype;return t.initialize=function(){return!0},t.destroy=function(){for(var e=0;et)for(;t0&&(this._meshDataArray.forEach((function(e){e.uploadBuffers()})),this._bufferAccessors.forEach((function(e){e.uploadBuffers(),e.reset()})),this._descriptorSetCache.update())},t.reset=function(){for(var e=0;e0){!function(e,t){for(var n,i,r,o=e.vertexFormat,a=e.chunk.vb,s=0,c=0;c>>0;else if(i.size/i.count==4)for(var h=s+3;h>2}}(r.renderData,a);var c=r.renderData.getMeshBuffer();c&&c.setDirty()}if(n.length>0&&!e._static)for(var l=0;l=0;n--)e.splice(t[n],1)},t.reset=function(){var e=this;this._localDescriptorSetCache.forEach((function(t){e._localCachePool.free(t)})),this._localDescriptorSetCache.length=0},t.releaseDescriptorSetCache=function(e){var t=this._dsCacheHashByTexture.get(e);t&&this._descriptorSetCache.has(t)&&(this._descriptorSetCache.get(t).destroy(),this._descriptorSetCache.delete(t),this._dsCacheHashByTexture.delete(e))},t.destroy=function(){this._descriptorSetCache.forEach((function(e){e.destroy()})),this._descriptorSetCache.clear(),this._dsCacheHashByTexture.clear(),this._localDescriptorSetCache.length=0,this._localCachePool.destroy()},e}();c.internal.Batcher2D=qJ,U(BJ.prototype,"MeshBuffer",["byteStart","vertexStart","indicesStart","request"].map((function(e){return{name:e,suggest:"please use meshBuffer.accessor."+e+" instead"}}))),z(BJ.prototype,"MeshBuffer",[{name:"indicesOffset",newName:"indexOffset"}]),k(BJ.prototype,"MeshBuffer",[{name:"vertexBuffers"},{name:"indexBuffer"}]),z(qJ.prototype,"Batcher2D",[{name:"currBufferBatch",newName:"currBufferAccessor"},{name:"acquireBufferBatch",newName:"switchBufferAccessor"}]),k(TV.prototype,"MeshRenderData",[{name:"formatByte"},{name:"byteStart"},{name:"byteCount"}]),z(TV.prototype,"MeshRenderData",[{name:"indicesStart",newName:"indexStart"}]),e("QuadRenderData",function(e){function t(t){var n;return n=e.call(this,t)||this,P(9006),n}return Z(t,e),t}(TV));var KJ,QJ,ZJ=null,JJ=-1,$J="BES bswy:->@123丁ぁᄁ",e$=Object.create(null),t$=[],n$=3e3;function i$(){for(var e=!0,t=Date.now(),n=t$.length-1;n>=0;n--){var i=t$[n],r=i.fontFamilyName;if(t-i.startTime>n$)P(4933,r),i.onComplete(null,r),t$.splice(n,1);else{var o=i.refWidth,a="40px "+r;ZJ.font=a,o!==kH(ZJ,$J,a)?(t$.splice(n,1),i.onComplete(null,r)):e=!1}}e&&(clearInterval(JJ),JJ=-1)}function r$(e,t,n){var i=function(e){var t=e.lastIndexOf(".ttf");if(-1===t)return e;var n,i=e.lastIndexOf("/");return-1!==(n=-1===i?e.substring(0,t)+"_LABEL":e.substring(i+1,t)+"_LABEL").indexOf(" ")&&(n='"'+n+'"'),n}(e);if(e$[i])n(null,i);else{if(!ZJ){var r=document.createElement("canvas");r.width=100,r.height=100,ZJ=r.getContext("2d")}var o=kH(ZJ,$J,"40px "+i),a=document.createElement("style");a.type="text/css";var s="";Number.isNaN(i)?s+="@font-face { font-family:"+i+"; src:":s+='@font-face { font-family:"'+i+'"; src:',s+='url("'+e+'");',a.textContent=s+"}",document.body.appendChild(a);var c=document.createElement("div"),l=c.style;if(l.fontFamily=i,c.innerHTML=".",l.position="absolute",l.left="-100px",l.top="-100px",document.body.appendChild(c),function(){if(void 0===KJ)if("FontFace"in window){var e=/Gecko.*Firefox\/(\d+)/.exec(window.navigator.userAgent),t=/OS X.*Version\/10\..*Safari/.exec(window.navigator.userAgent)&&/Apple/.exec(window.navigator.vendor);KJ=e?parseInt(e[1],10)>42:!t}else KJ=!1;return KJ}())!function(e,t,n){var i=new Promise((function(n,i){!function r(){Date.now()-e>=n$?i():document.fonts.load("40px "+t).then((function(e){e.length>=1?n():setTimeout(r,100)}),(function(){i()}))}()})),r=null,o=new Promise((function(e,t){r=setTimeout(t,n$)}));Promise.race([o,i]).then((function(){r&&(clearTimeout(r),r=null),n(null,t)}),(function(){P(4933,t),n(null,t)}))}(Date.now(),i,n);else{var u={fontFamilyName:i,refWidth:o,onComplete:n,startTime:Date.now()};t$.push(u),-1===JJ&&(JJ=setInterval(i$,100))}e$[i]=a}}function o$(e,t,n,i){var r=new SH;r._nativeUrl=e,r._nativeAsset=t,i(null,r)}RN.register({".font":r$,".eot":r$,".ttf":r$,".woff":r$,".svg":r$,".ttc":r$}),LN.register({".font":o$,".eot":o$,".ttf":o$,".woff":o$,".svg":o$,".ttc":o$}),c.UI={MeshBuffer:BJ,spriteAssembler:DJ,graphicsAssembler:DQ,labelAssembler:JZ,RenderData:SV,MeshRenderData:TV},function(e){e[e.positions=Xi.ATTR_POSITION]="positions",e[e.normals=Xi.ATTR_NORMAL]="normals",e[e.uvs=Xi.ATTR_TEX_COORD]="uvs",e[e.colors=Xi.ATTR_COLOR]="colors"}(QJ||(QJ={}));var a$,s$,c$,l$,u$,h$=function(){function e(){this._arrayBufferOrPaddings=[],this._length=0}var t=e.prototype;return t.setNextAlignment=function(e){if(0!==e){var t=this._length%e;if(0!==t){var n=e-t;this._arrayBufferOrPaddings.push(n),this._length+=n}}},t.addBuffer=function(e){var t=this._length;return this._arrayBufferOrPaddings.push(e),this._length+=e.byteLength,t},t.getLength=function(){return this._length},t.getCombined=function(){var e=new Uint8Array(this._length),t=0;return this._arrayBufferOrPaddings.forEach((function(n){"number"==typeof n?t+=n:(e.set(new Uint8Array(n),t),t+=n.byteLength)})),e.buffer},e}(),f$=function(){function e(e,t){if(this._mesh=void 0,this._subMeshRenderings=[],this._mesh=e,this._mesh.struct.morph){var n=this._mesh.struct.primitives.length;this._subMeshRenderings=new Array(n).fill(null);for(var i=0;igd.MAX_MORPH_TARGET_COUNT?this._subMeshRenderings[i]=new p$(this._mesh,i,this._mesh.struct.morph,t):this._subMeshRenderings[i]=new _$(this._mesh,i,this._mesh.struct.morph,t))}}}return e.prototype.createInstance=function(){for(var e=this,t=this._mesh.struct.primitives.length,n=new Array(t),i=0;i>1;return{width:1<<(1&t?i+1:i),height:1<=65536){P(10001,f,65536);continue}u>>=1,h>>=1}a=t.createBuffer(new lr(_i.INDEX,mi.DEVICE,h,u)),s=new(y$(l.stride))(e,l.offset,l.count),l.stride!==u&&(s=y$(u).from(s)),a.update(s)}var _=o.vertexBundelIndices.map((function(e){return n[e]})),p=[];if(o.vertexBundelIndices.length>0)for(var d=o.vertexBundelIndices[0],m=this._struct.vertexBundles[d].attributes,g=0;g=i.length)){bn.transformMat4(S$,x$,i[p]),n[p]=!0;var d=t[p];bn.min(d.center,d.center,S$),bn.max(d.halfExtents,d.halfExtents,S$)}}}}for(var m=0;m=this._struct.primitives.length)return null;var t=this._struct.primitives[e];if(!t.indexView)return null;var n=t.indexView.stride;return new(1===n?Uint8Array:2===n?Uint16Array:Uint32Array)(this._data.buffer,t.indexView.offset,t.indexView.count)},n.copyIndices=function(e,t){if(e>=this._struct.primitives.length)return!1;var n=this._struct.primitives[e];if(!n.indexView)return!1;for(var i=n.indexView.count,r=1===n.indexView.stride?ui.R8UI:2===n.indexView.stride?ui.R16UI:ui.R32UI,o=w$(new DataView(this._data.buffer),r),a=0;a=this._struct.primitives.length))for(var i,r=oe(this._struct.primitives[e].vertexBundelIndices);!(i=r()).done;){var o=i.value,a=this._struct.vertexBundles[o],s=a.attributes.findIndex((function(e){return e.name===t}));if(!(s<0)){n(a,s);break}}},n._createVertexBuffers=function(e,t){return this._struct.vertexBundles.map((function(n){var i=e.createBuffer(new lr(_i.VERTEX,mi.DEVICE,n.view.length,n.view.stride)),r=new Uint8Array(t,n.view.offset,n.view.length);return i.update(r),i}))},n.initDefault=function(t){e.prototype.initDefault.call(this,t),this.reset({struct:{vertexBundles:[],primitives:[]},data:T$})},K(t,[{key:"_nativeAsset",get:function(){return this._data.buffer},set:function(e){this._data=new Uint8Array(e)}},{key:"subMeshCount",get:function(){var e=this.renderingSubMeshes;return e?e.length:0}},{key:"minPosition",get:function(){return this.struct.minPosition}},{key:"maxPosition",get:function(){return this.struct.maxPosition}},{key:"struct",get:function(){return this._struct}},{key:"data",get:function(){return this._data}},{key:"hash",get:function(){return this._hash||(this._hash=po(this._data,666)),this._hash}},{key:"jointBufferIndices",get:function(){return this._jointBufferIndices?this._jointBufferIndices:this._jointBufferIndices=this._struct.primitives.map((function(e){return e.jointMapIndex||0}))}},{key:"renderingSubMeshes",get:function(){return this.initialize(),this._renderingSubMeshes}}]),t}(Ru),c$=se((s$=u$).prototype,"_struct",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return{vertexBundles:[],primitives:[]}}}),l$=se(s$.prototype,"_hash",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),a$=s$))||a$);function A$(e,t){for(var n=0,i=0;i0){if(i=null,e.attributes)for(var l,u=oe(e.attributes);!(l=u()).done;){var h=l.value;if(h.name===Xi.ATTR_POSITION){i=h;break}}i||(i=P$[0]),r.push(i);var f=Qr[i.format];s=Math.max(s,Math.floor(c.length/f.count)),a.push({offset:o,data:c,attribute:i}),o+=f.size}if(e.normals&&e.normals.length>0){if(i=null,e.attributes)for(var _,p=oe(e.attributes);!(_=p()).done;){var d=_.value;if(d.name===Xi.ATTR_NORMAL){i=d;break}}i||(i=P$[1]);var m=Qr[i.format];r.push(i),s=Math.max(s,Math.floor(e.normals.length/m.count)),a.push({offset:o,data:e.normals,attribute:i}),o+=m.size}if(e.uvs&&e.uvs.length>0){if(i=null,e.attributes)for(var g,v=oe(e.attributes);!(g=v()).done;){var y=g.value;if(y.name===Xi.ATTR_TEX_COORD){i=y;break}}i||(i=P$[2]);var x=Qr[i.format];r.push(i),s=Math.max(s,Math.floor(e.uvs.length/x.count)),a.push({offset:o,data:e.uvs,attribute:i}),o+=x.size}if(e.tangents&&e.tangents.length>0){if(i=null,e.attributes)for(var S,T=oe(e.attributes);!(S=T()).done;){var E=S.value;if(E.name===Xi.ATTR_TANGENT){i=E;break}}i||(i=P$[3]);var A=Qr[i.format];r.push(i),s=Math.max(s,Math.floor(e.tangents.length/A.count)),a.push({offset:o,data:e.tangents,attribute:i}),o+=A.size}if(e.colors&&e.colors.length>0){if(i=null,e.attributes)for(var C,b=oe(e.attributes);!(C=b()).done;){var w=C.value;if(w.name===Xi.ATTR_COLOR){i=w;break}}i||(i=P$[4]);var R=Qr[i.format];r.push(i),s=Math.max(s,Math.floor(e.colors.length/R.count)),a.push({offset:o,data:e.colors,attribute:i}),o+=R.size}if(e.customAttributes)for(var P,I=oe(e.customAttributes);!(P=I()).done;){var D=P.value,O=Qr[D.attr.format];r.push(D.attr),s=Math.max(s,Math.floor(D.values.length/O.count)),a.push({offset:o,data:D.values,attribute:D.attr}),o+=O.size}for(var M=new h$,N=new ArrayBuffer(s*o),L=new DataView(N),F=0,B=a;F=n.length||n[t].length===e.length&&(n[t]=e.slice(0),this._uploadSubMeshShapesWeights(t))},n.setWeight=function(e,t,n){var i=this._subMeshShapesWeights;if(!(t>=i.length)){var r=i[t];n>=r.length||(r[n]=e,this._uploadSubMeshShapesWeights(t))}},n.setInstancedAttribute=function(e,t){if(this.model)for(var n=this.model.instancedAttributes,i=n.attributes,r=n.views,o=0;o0&&this.bindposes.length>0},K(t,[{key:"joints",get:function(){return this._joints},set:function(e){this._joints=e}},{key:"bindposes",get:function(){return this._bindposes},set:function(e){this._bindposes=e}},{key:"inverseBindposes",get:function(){if(!this._invBindposes){this._invBindposes=[];for(var e=0;e0&&e.refCount--,!e.refCount&&e.readyToBeDeleted){var t=e.skeletonHash^e.clipHash;(void 0!==this._chunkIdxMap.get(t)?this._customPool:this._pool).free(e.handle),this._textureBuffers.get(t)===e&&this._textureBuffers.delete(t)}},t.releaseSkeleton=function(e){for(var t=this._textureBuffers.values(),n=t.next();!n.done;){var i=n.value;i.skeletonHash===e.hash&&(i.readyToBeDeleted=!0,i.refCount?this._textureBuffers.delete(i.skeletonHash^i.clipHash):this.releaseHandle(i)),n=t.next()}},t.releaseAnimationClip=function(e){for(var t=this._textureBuffers.values(),n=t.next();!n.done;){var i=n.value;i.clipHash===e.hash&&(i.readyToBeDeleted=!0,i.refCount?this._textureBuffers.delete(i.skeletonHash^i.clipHash):this.releaseHandle(i)),n=t.next()}},t._createAnimInfos=function(e,t,n){for(var i=[],r=e.joints,o=e.bindposes,a=r.length,s=tk.getOrExtract(t),c=0;c=0&&(t.push(r),e.push(a))}}var v2,y2,x2,S2,T2,E2,A2,C2,b2,w2,R2,P2,I2,D2,O2,M2,N2,L2,F2,B2,z2,k2,U2,G2,H2,V2,j2,W2,q2,X2,Y2,K2,Q2,Z2,J2,$2,e4,t4,n4,i4,r4,o4,a4,s4,c4,l4=new bn,u4=new bn,h4=new bn,f4=new bn,_4=new Gn,p4=new Hs,d4=function(e){function t(){var t;return(t=e.call(this)||this).uploadAnimation=null,t._buffers=[],t._dataArray=[],t._joints=[],t._bufferIndices=null,t.type=KS.SKINNING,t}Z(t,e);var n=t.prototype;return n._init=function(){},n.destroy=function(){if(this.bindSkeleton(),this._buffers.length){for(var t=0;t=0?this.instancedAttributes.views[i][0]=n.data[0]:n.dirty&&(n.buffer.update(n.data),n.dirty=!1),!0},n._applyNativeJointMedium=function(){},n._updateModelBounds=function(e){this._modelBounds=e},n.uploadAnimation=function(e){if(this._skeleton&&this._mesh&&this.uploadedAnim!==e){this.uploadedAnim=e;var t=this._dataPoolManager,n=null;e?(n=t.jointTexturePool.getSequencePoseTexture(this._skeleton,e,this._mesh,this.transform),this._jointsMedium.boundsInfo=n&&n.bounds.get(this._mesh.hash),this._updateModelBounds(null)):(n=t.jointTexturePool.getDefaultPoseTexture(this._skeleton,this._mesh,this.transform),this._jointsMedium.boundsInfo=null,this._updateModelBounds(n&&n.bounds.get(this._mesh.hash)[0])),this._applyJointTexture(n),this._applyNativeJointMedium()}},n._applyJointTexture=function(e){void 0===e&&(e=null);var t=this._jointsMedium.texture;if(t&&t!==e&&this._dataPoolManager.jointTexturePool.releaseHandle(t),this._jointsMedium.texture=e,e){var n=this._jointsMedium,i=n.buffer,r=n.jointTextureInfo;r[0]=e.handle.texture.width,r[1]=this._skeleton.joints.length,r[2]=e.pixelOffset+.1,r[3]=1/r[0],this.updateInstancedJointTextureInfo(),i&&i.update(r);for(var o=e.handle.texture,a=0;a=0){var r=this.instancedAttributes.views[i];r[0]=n.data[0],r[1]=t[1],r[2]=t[2]}},t}(y0),v4=function(t){return e({SkinnedMeshRenderer:t,SkinningModelComponent:t}),t}((v2=hc("cc.SkinnedMeshRenderer"),y2=wc(),x2=_c(100),S2=Ec(),T2=Wc(X0),E2=Wc(kC),A2=Wc(X0),C2=Wc(kC),b2=Oc(),v2(w2=y2(w2=x2(w2=Tc(w2=S2((D2=function(e){function t(){var t;return ae(t=e.call(this)||this,"_skeleton",P2,ie(t)),ae(t,"_skinningRoot",I2,ie(t)),t._clip=null,t.associatedAnimation=null,t._modelType=g4,t}Z(t,e);var n=t.prototype;return n.onLoad=function(){this._tryBindAnimation()},n.onDestroy=function(){this.associatedAnimation&&(this.associatedAnimation.notifySkinnedMeshRemoved(this),this.associatedAnimation),e.prototype.onDestroy.call(this)},n.uploadAnimation=function(e){this._clip=e,this.model&&this.model.uploadAnimation&&this.model.uploadAnimation(e)},n.setUseBakedAnimation=function(e,t){void 0===e&&(e=!0),void 0===t&&(t=!1);var n=e?g4:d4;(t||this._modelType!==n)&&(this._modelType=n,this._model&&(c.director.root.destroyModel(this._model),this._model=null,this._models.length=0,this._updateModels(),this._updateCastShadow(),this.enabledInHierarchy&&this._attachToScene()))},n.setMaterial=function(t,n){e.prototype.setMaterial.call(this,t,n),this._modelType===d4&&this.getMaterialInstance(n)},n._updateModelParams=function(){this._update(),e.prototype._updateModelParams.call(this)},n._tryBindAnimation=function(){var e=this._skinningRoot;if(e){for(var t=!1,n=this.node;n;n=n.parent)if(n===e){t=!0;break}if(t){var i=e.getComponent("cc.SkeletalAnimation");i?i.notifySkinnedMeshAdded(this):this.setUseBakedAnimation(!1)}}},n._update=function(){this.model&&(this.model.bindSkeleton(this._skeleton,this._skinningRoot,this._mesh),this.model.uploadAnimation&&this.model.uploadAnimation(this._clip))},K(t,[{key:"skeleton",get:function(){return this._skeleton},set:function(e){e!==this._skeleton&&(this._skeleton=e,this._update())}},{key:"skinningRoot",get:function(){return this._skinningRoot},set:function(e){this._skinningRoot=e,this._tryBindAnimation(),e!==this._skinningRoot&&this._update()}},{key:"model",get:function(){return this._model}}]),t}(E0),P2=se((R2=D2).prototype,"_skeleton",[T2],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),I2=se(R2.prototype,"_skinningRoot",[E2],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),se(R2.prototype,"skeleton",[A2],Object.getOwnPropertyDescriptor(R2.prototype,"skeleton"),R2.prototype),se(R2.prototype,"skinningRoot",[C2,b2],Object.getOwnPropertyDescriptor(R2.prototype,"skinningRoot"),R2.prototype),w2=R2))||w2)||w2)||w2)||w2)||w2)),y4=new br(Xi.ATTR_BATCH_ID,ui.R32F),x4=new br(Xi.ATTR_BATCH_UV,ui.RG32F),S4=Qr[y4.format].size+Qr[x4.format].size,T4=function(t){return e({SkinnedMeshUnit:t,SkinningModelUnit:t}),t}((O2=hc("cc.SkinnedMeshUnit"),M2=Wc(E$),N2=Wc(X0),L2=Wc(iv),F2=Wc(v4),O2((W2=function(){function e(){ae(this,"mesh",k2,this),ae(this,"skeleton",U2,this),ae(this,"material",G2,this),ae(this,"_localTransform",H2,this),ae(this,"_offset",V2,this),ae(this,"_size",j2,this)}return K(e,[{key:"offset",get:function(){return this._offset},set:function(e){Wn.copy(this._offset,e)}},{key:"size",get:function(){return this._size},set:function(e){Wn.copy(this._size,e)}},{key:"copyFrom",get:function(){return null},set:function(e){e&&(this.mesh=e.mesh,this.skeleton=e.skeleton,this.material=e.getMaterial(0),e.skinningRoot&&LG(e.node,e.skinningRoot,this._localTransform))}}]),e}(),k2=se((z2=W2).prototype,"mesh",[M2],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),U2=se(z2.prototype,"skeleton",[N2],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),G2=se(z2.prototype,"material",[L2],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),H2=se(z2.prototype,"_localTransform",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Gn}}),V2=se(z2.prototype,"_offset",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Wn(0,0)}}),j2=se(z2.prototype,"_size",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Wn(1,1)}}),se(z2.prototype,"offset",[Rc],Object.getOwnPropertyDescriptor(z2.prototype,"offset"),z2.prototype),se(z2.prototype,"size",[Rc],Object.getOwnPropertyDescriptor(z2.prototype,"size"),z2.prototype),se(z2.prototype,"copyFrom",[F2],Object.getOwnPropertyDescriptor(z2.prototype,"copyFrom"),z2.prototype),B2=z2))||B2)),E4=new Gn,A4=(new Gn,new bn),C4=function(t){return e({SkinnedMeshBatchRenderer:t,BatchedSkinningModelComponent:t}),t}((q2=hc("cc.SkinnedMeshBatchRenderer"),X2=wc(),Y2=_c(100),K2=Ec(),Q2=Oc(),Z2=Wc([Mt]),J2=Oc(),$2=Wc([T4]),e4=Oc(),t4=Pc(),n4=Pc(),q2(i4=X2(i4=Y2(i4=Tc(i4=K2((c4=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r=fi.SAMPLER1D){var o=null;e.batchableTextureNames.find((function(e){return e===n}))?((o=e._textures[n])||(o=e.createTexture(n)),e.cookTextures(o,n,i)):e.units.some((function(e){return o=e.material&&e.material.getProperty(n,i)})),o&&t.setProperty(n,o,i)}else{for(var a=[],s=0;s=0)return"continue";e.push(i),t.push(Gn.multiply(new Gn,r.bindposes[n]||Gn.IDENTITY,E4))},a=0;ae[n]?1:e[t]0&&p.copyBuffersToTexture(o,_,a),i.length>0&&p.copyTexImagesToTexture(i,_,r)},n.createTexture=function(e){var t=new vg;return t.setFilters(Rm.LINEAR,Rm.LINEAR),t.setMipFilter(Rm.NEAREST),t.reset({width:this.atlasSize,height:this.atlasSize,format:bm.RGBA8888}),this._textures[e]=t,t},n.resizeAtlases=function(){for(var e in this._textures)this._textures[e].reset({width:this.atlasSize,height:this.atlasSize,format:bm.RGBA8888})},n._createUnitMesh=function(e,t){for(var n=JSON.parse(JSON.stringify(t.struct)),i={},r=0;r=this.duration&&(this._startTime=this._now(),this._startOffset=0),t%this.duration},t.start=function(){this._isPaused=!1,this._startTime=this._now()},t.pause=function(){this._isPaused||(this._isPaused=!0,this._startOffset=this._calculateCurrentTime())},t.stop=function(){this._isPaused=!0,this._startOffset=0},t.seek=function(e){this._startTime=this._now(),this._startOffset=on(e,0,this.duration)},K(e,[{key:"duration",get:function(){return this._nativeAudio.duration}},{key:"currentTime",get:function(){return this._isPaused?this._startOffset:this._calculateCurrentTime()}}]),e}(),_3=new(function(){function e(){this._audioBufferDataMap={}}var t=e.prototype;return t.addCache=function(e,t){this._audioBufferDataMap[e]?console.warn("Audio buffer "+e+" has been cached"):this._audioBufferDataMap[e]={usedCount:1,audioBuffer:t}},t.retainCache=function(e){var t=this._audioBufferDataMap[e];t?t.usedCount++:console.warn("Audio buffer cache "+e+" has not been added.")},t.getCache=function(e){var t=this._audioBufferDataMap[e];return null==t?void 0:t.audioBuffer},t.tryReleasingCache=function(e){var t=this._audioBufferDataMap[e];t?--t.usedCount<=0&&delete this._audioBufferDataMap[e]:console.warn("Audio buffer cache "+e+" has not been added.")},e}()),p3=window.AudioContext||window.webkitAudioContext||window.mozAudioContext,d3=function(){function e(){this._context=void 0,this._context=new(window.AudioContext||window.webkitAudioContext||window.mozAudioContext)}var t=e.prototype;return t.decodeAudioData=function(e){var t=this;return new Promise((function(n){var i=t._context.decodeAudioData(e,(function(e){n(e)}),(function(e){console.error("failed to load Web Audio",e)}));null==i||i.catch((function(){}))}))},t.runContext=function(){var e=this;return new Promise((function(t){var n=e._context;if(n.resume)if("running"!==n.state){var i=document.getElementById("GameCanvas"),r=function(){n.resume().then(t).catch((function(){}))};null==i||i.addEventListener("touchend",r,{once:!0,capture:!0}),null==i||i.addEventListener("mouseup",r,{once:!0,capture:!0})}else t();else t()}))},t.createBufferSource=function(e,t){var n=this._context.createBufferSource();return void 0!==e&&(n.buffer=e),void 0!==t&&(n.loop=t),n},t.createGain=function(e){void 0===e&&(e=1);var t=this._context.createGain();return this.setGainValue(t,e),t},t.setGainValue=function(e,t){if(e.gain.setTargetAtTime)try{e.gain.setTargetAtTime(t,this._context.currentTime,0)}catch(n){e.gain.setTargetAtTime(t,this._context.currentTime,.01)}else e.gain.value=t},t.connectContext=function(e){this._context&&e.connect(this._context.destination)},K(e,[{key:"currentTime",get:function(){return this._context.currentTime}}]),e}();d3.support=!!p3,d3.support&&(l3=new d3);var m3,g3,v3,y3,x3,S3=function(){function e(e,t,n){this._duration=void 0,this._bufferSourceNode=void 0,this._onPlayCb=void 0,this._currentTimer=0,this._url=void 0,this._onEndCb=void 0,this._duration=e.duration,this._url=n,this._bufferSourceNode=l3.createBufferSource(e,!1);var i=l3.createGain(t);this._bufferSourceNode.connect(i),l3.connectContext(i)}var t=e.prototype;return t.play=function(){var e=this;this._bufferSourceNode.start(),l3.runContext().then((function(){var t;null===(t=e.onPlay)||void 0===t||t.call(e),e._currentTimer=window.setTimeout((function(){var t;_3.tryReleasingCache(e._url),null===(t=e.onEnd)||void 0===t||t.call(e)}),1e3*e._duration)})).catch((function(){}))},t.stop=function(){clearTimeout(this._currentTimer),_3.tryReleasingCache(this._url),this._bufferSourceNode.stop(),this._bufferSourceNode.buffer=null},K(e,[{key:"onPlay",get:function(){return this._onPlayCb},set:function(e){this._onPlayCb=e}},{key:"onEnd",get:function(){return this._onEndCb},set:function(e){this._onEndCb=e}}]),e}(),T3=(se((c3=function(){function e(e,t){this._src=void 0,this._audioBuffer=void 0,this._sourceNode=void 0,this._gainNode=void 0,this._currentTimer=0,this._volume=1,this._loop=!1,this._state=t3.INIT,this._audioTimer=void 0,this._eventTarget=new Zl,this._operationQueue=[],this._audioBuffer=e,this._audioTimer=new f3(e),this._gainNode=l3.createGain(),l3.connectContext(this._gainNode),this._src=t,hu.on("hide",this._onHide,this),hu.on("show",this._onShow,this)}var t=e.prototype;return t.destroy=function(){this._audioTimer.destroy(),this._audioBuffer&&(this._audioBuffer=null),_3.tryReleasingCache(this._src),hu.off("hide",this._onHide,this),hu.off("show",this._onShow,this)},e.load=function(t){return new Promise((function(n){e.loadNative(t).then((function(i){n(new e(i,t))})).catch((function(){}))}))},e.loadNative=function(e){return new Promise((function(t,n){var i=_3.getCache(e);if(i)return _3.retainCache(e),void t(i);var r=new XMLHttpRequest,o="load audio failed: "+e+", status: ";r.open("GET",e,!0),r.responseType="arraybuffer",r.onload=function(){200===r.status||0===r.status?l3.decodeAudioData(r.response).then((function(n){_3.addCache(e,n),t(n)})).catch((function(){})):n(new Error(""+o+r.status+"(no response)"))},r.onerror=function(){n(new Error(""+o+r.status+"(error)"))},r.ontimeout=function(){n(new Error(""+o+r.status+"(time out)"))},r.onabort=function(){n(new Error(""+o+r.status+"(abort)"))},r.send(null)}))},e.loadOneShotAudio=function(t,n){return new Promise((function(i,r){e.loadNative(t).then((function(e){var r=new S3(e,n,t);i(r)})).catch(r)}))},t._onHide=function(){var e=this;this._state===t3.PLAYING&&this.pause().then((function(){e._state=t3.INTERRUPTED,e._eventTarget.emit($4.INTERRUPTION_BEGIN)})).catch((function(){}))},t._onShow=function(){var e=this;this._state===t3.INTERRUPTED&&this.play().then((function(){e._eventTarget.emit($4.INTERRUPTION_END)})).catch((function(){}))},t.seek=function(e){var t=this;return new Promise((function(n){t._audioTimer.seek(e),t._state===t3.PLAYING?t._doPlay().then(n).catch((function(){})):n()}))},t.play=function(){return this._doPlay()},t._doPlay=function(){var e=this;return new Promise((function(t){e._stopSourceNode(),e._sourceNode=l3.createBufferSource(e._audioBuffer,e.loop),e._sourceNode.connect(e._gainNode),e._sourceNode.start(0,e._audioTimer.currentTime),l3.runContext().then((function(){e._state=t3.PLAYING,e._audioTimer.start(),window.clearTimeout(e._currentTimer),e._currentTimer=window.setTimeout((function t(){e.loop?e._currentTimer=window.setTimeout(t,1e3*e._audioBuffer.duration):(e._audioTimer.stop(),e._eventTarget.emit($4.ENDED),e._state=t3.INIT)}),1e3*(e._audioBuffer.duration-e._audioTimer.currentTime)),t()})).catch((function(){}))}))},t._stopSourceNode=function(){try{this._sourceNode&&(this._sourceNode.stop(),this._sourceNode.buffer=null)}catch(e){}},t.pause=function(){return this._state===t3.PLAYING&&this._sourceNode?(this._audioTimer.pause(),this._state=t3.PAUSED,window.clearTimeout(this._currentTimer),this._stopSourceNode(),Promise.resolve()):Promise.resolve()},t.stop=function(){return this._sourceNode?(this._audioTimer.stop(),this._state=t3.STOPPED,window.clearTimeout(this._currentTimer),this._stopSourceNode(),Promise.resolve()):Promise.resolve()},t.onInterruptionBegin=function(e){this._eventTarget.on($4.INTERRUPTION_BEGIN,e)},t.offInterruptionBegin=function(e){this._eventTarget.off($4.INTERRUPTION_BEGIN,e)},t.onInterruptionEnd=function(e){this._eventTarget.on($4.INTERRUPTION_END,e)},t.offInterruptionEnd=function(e){this._eventTarget.off($4.INTERRUPTION_END,e)},t.onEnded=function(e){this._eventTarget.on($4.ENDED,e)},t.offEnded=function(e){this._eventTarget.off($4.ENDED,e)},K(e,[{key:"src",get:function(){return this._src}},{key:"type",get:function(){return e3.WEB_AUDIO}},{key:"state",get:function(){return this._state}},{key:"loop",get:function(){return this._loop},set:function(e){this._loop=e,this._sourceNode&&(this._sourceNode.loop=e)}},{key:"volume",get:function(){return this._volume},set:function(e){e=an(e),this._volume=e,l3.setGainValue(this._gainNode,e)}},{key:"duration",get:function(){return this._audioBuffer.duration}},{key:"currentTime",get:function(){return this._audioTimer.currentTime}}]),e}()).prototype,"seek",[a3],Object.getOwnPropertyDescriptor(c3.prototype,"seek"),c3.prototype),se(c3.prototype,"play",[a3],Object.getOwnPropertyDescriptor(c3.prototype,"play"),c3.prototype),se(c3.prototype,"pause",[a3],Object.getOwnPropertyDescriptor(c3.prototype,"pause"),c3.prototype),se(c3.prototype,"stop",[a3],Object.getOwnPropertyDescriptor(c3.prototype,"stop"),c3.prototype),c3),E3=function(){function e(e){this._audio=void 0,this._audio=e}var t=e.prototype;return t.play=function(){this._audio.play()},t.stop=function(){this._audio.stop()},K(e,[{key:"onPlay",get:function(){return this._audio.onPlay},set:function(e){this._audio.onPlay=e}},{key:"onEnd",get:function(){return this._audio.onEnd},set:function(e){this._audio.onEnd=e}}]),e}(),A3=function(){function e(e){this._player=void 0,this._player=e}e.load=function(t,n){return new Promise((function(i){(null==n?void 0:n.audioLoadMode)!==e3.DOM_AUDIO&&d3.support?T3.load(t).then((function(t){i(new e(t))})).catch((function(){})):(d3.support||P(5201),h3.load(t).then((function(t){i(new e(t))})).catch((function(){})))}))};var t=e.prototype;return t.destroy=function(){this._player.destroy()},e.loadNative=function(e,t){return(null==t?void 0:t.audioLoadMode)!==e3.DOM_AUDIO&&d3.support?T3.loadNative(e):(d3.support||P(5201),h3.loadNative(e))},e.loadOneShotAudio=function(e,t,n){return new Promise((function(i,r){(null==n?void 0:n.audioLoadMode)!==e3.DOM_AUDIO&&d3.support?T3.loadOneShotAudio(e,t).then((function(e){i(new E3(e))})).catch(r):(d3.support||P(5201),h3.loadOneShotAudio(e,t).then((function(e){i(new E3(e))})).catch(r))}))},t.seek=function(e){return this._player.seek(e)},t.play=function(){return this._player.play()},t.pause=function(){return this._player.pause()},t.stop=function(){return this._player.stop()},t.onInterruptionBegin=function(e){this._player.onInterruptionBegin(e)},t.offInterruptionBegin=function(e){this._player.offInterruptionBegin(e)},t.onInterruptionEnd=function(e){this._player.onInterruptionEnd(e)},t.offInterruptionEnd=function(e){this._player.offInterruptionEnd(e)},t.onEnded=function(e){this._player.onEnded(e)},t.offEnded=function(e){this._player.offEnded(e)},K(e,[{key:"src",get:function(){return this._player.src}},{key:"type",get:function(){return this._player.type}},{key:"state",get:function(){return this._player.state}},{key:"loop",get:function(){return this._player.loop},set:function(e){this._player.loop=e}},{key:"volume",get:function(){return this._player.volume},set:function(e){this._player.volume=e}},{key:"duration",get:function(){return this._player.duration}},{key:"currentTime",get:function(){return this._player.currentTime}}]),e}();A3.maxAudioChannel=24;var C3=e("AudioClip",hc("cc.AudioClip")((x3=y3=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r-1?(e[n].playTime=performance.now(),!1):(e.push({audio:t,playTime:performance.now()}),!0)},t.addPlaying=function(e){if(e instanceof A3){if(this._tryAddPlaying(this._audioPlayerInfoList,e))return}else this._tryAddPlaying(this._oneShotAudioInfoList,e)},t._tryRemovePlaying=function(e,t){var n=this._findIndex(e,t);return-1!==n&&(ue(e,n),!0)},t.removePlaying=function(e){if(e instanceof A3){if(this._tryRemovePlaying(this._audioPlayerInfoList,e))return}else this._tryRemovePlaying(this._oneShotAudioInfoList,e)},t.discardOnePlayingIfNeeded=function(){var e;this._audioPlayerInfoList.length+this._oneShotAudioInfoList.length0?this._oneShotAudioInfoList.forEach((function(t){(!e||t.playTime=0&&C.gpuDescriptors[b],R=null,P=0;if(w&&w.gpuBuffer){var I=w.gpuBuffer,D=T[A.set],O=D&&D[A.binding];O>=0&&(P=r[O]),"vf32"in I?R=I.vf32:(P+=I.offset,R=I.gpuBuffer.vf32),P>>=2}if(R)for(var M=A.glActiveUniforms.length,N=0;N=0&&Pe.gpuDescriptors[Ie],Oe=Re.units.length,Me=0;Me0){var Le=De.gpuTexture,Fe=u.glTexUnits[Ne];Fe.glTexture!==Le.glTexture&&(u.texUnit!==Ne&&(l.activeTexture(l.TEXTURE0+Ne),u.texUnit=Ne),Le.glTexture?l.bindTexture(Le.glTarget,Le.glTexture):l.bindTexture(Le.glTarget,e.nullTex2D.gpuTexture.glTexture),Fe.glTexture=Le.glTexture);var Be=De.gpuSampler;Le.isPowerOf2?(a=Be.glWrapS,s=Be.glWrapT):(a=l.CLAMP_TO_EDGE,s=l.CLAMP_TO_EDGE),c=Le.isPowerOf2?Le.mipLevel<=1&&(Be.glMinFilter===l.LINEAR_MIPMAP_NEAREST||Be.glMinFilter===l.LINEAR_MIPMAP_LINEAR)?l.LINEAR:Be.glMinFilter:Be.glMinFilter===l.LINEAR||Be.glMinFilter===l.LINEAR_MIPMAP_NEAREST||Be.glMinFilter===l.LINEAR_MIPMAP_LINEAR?l.LINEAR:l.NEAREST,Le.glWrapS!==a&&(u.texUnit!==Ne&&(l.activeTexture(l.TEXTURE0+Ne),u.texUnit=Ne),l.texParameteri(Le.glTarget,l.TEXTURE_WRAP_S,a),Le.glWrapS=a),Le.glWrapT!==s&&(u.texUnit!==Ne&&(l.activeTexture(l.TEXTURE0+Ne),u.texUnit=Ne),l.texParameteri(Le.glTarget,l.TEXTURE_WRAP_T,s),Le.glWrapT=s),Le.glMinFilter!==c&&(u.texUnit!==Ne&&(l.activeTexture(l.TEXTURE0+Ne),u.texUnit=Ne),l.texParameteri(Le.glTarget,l.TEXTURE_MIN_FILTER,c),Le.glMinFilter=c),Le.glMagFilter!==Be.glMagFilter&&(u.texUnit!==Ne&&(l.activeTexture(l.TEXTURE0+Ne),u.texUnit=Ne),l.texParameteri(Le.glTarget,l.TEXTURE_MAG_FILTER,Be.glMagFilter),Le.glMagFilter=Be.glMagFilter)}De=Pe.gpuDescriptors[++Ie]}else x("Sampler binding '"+Re.name+"' at set "+Re.set+" binding "+Re.binding+" index "+Me+" is not bounded")}}if(n&&h&&(f||v5.gpuInputAssembler!==n)){v5.gpuInputAssembler=n;var ze=e.extensions.ANGLE_instanced_arrays;if(e.extensions.useVAO){var ke=e.extensions.OES_vertex_array_object,Ue=n.glVAOs.get(h.glProgram);if(!Ue){var Ge;Ue=ke.createVertexArrayOES(),n.glVAOs.set(h.glProgram,Ue),ke.bindVertexArrayOES(Ue),l.bindBuffer(l.ARRAY_BUFFER,null),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,null),u.glArrayBuffer=null,u.glElementArrayBuffer=null;for(var He=h.glInputs.length,Ve=0;Ve=0&&(l.enableVertexAttribArray(st),u.glEnabledAttribLocs[st]=!0),u.glCurrentAttribLocs[st]=!0,l.vertexAttribPointer(st,nt.count,nt.glType,nt.isNormalized,nt.stride,ct),ze&&ze.vertexAttribDivisorANGLE(st,nt.isInstanced?1:0)}}}var lt=n.gpuIndexBuffer;lt&&u.glElementArrayBuffer!==lt.glBuffer&&(l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,lt.glBuffer),u.glElementArrayBuffer=lt.glBuffer);for(var ut=0;ut0){var _=t.firstIndex*c.stride;r.drawElementsInstancedANGLE(s,t.indexCount,a.glIndexType,_,t.instanceCount)}}else t.vertexCount>0&&r.drawArraysInstancedANGLE(s,t.firstVertex,t.vertexCount,t.instanceCount);else if(c){if(t.indexCount>0){var p=t.firstIndex*c.stride;n.drawElements(s,t.indexCount,a.glIndexType,p)}}else t.vertexCount>0&&n.drawArrays(s,t.firstVertex,t.vertexCount)}}var T5=new Array(o5.COUNT);function E5(e,t){T5.fill(0);for(var n=0;n0,this.instancedDraw=!!t.instanceCount,this.drawCount=Math.max(e+1,this.drawCount),this.drawByIndex?(this.counts[e]=t.indexCount,this.offsets[e]=t.firstIndex):(this.counts[e]=t.vertexCount,this.offsets[e]=t.firstVertex),this.instances[e]=Math.max(1,t.instanceCount)},t._ensureCapacity=function(e){if(!(this._capacity>e)){this._capacity=r(e);var t=new Int32Array(this._capacity),n=new Int32Array(this._capacity),i=new Int32Array(this._capacity);this.byteOffsets=new Int32Array(this._capacity),t.set(this.counts),n.set(this.offsets),i.set(this.instances),this.counts=t,this.offsets=n,this.instances=i}},e}(),b5=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r0&&(this._uniformBuffer=new Uint8Array(this._size)),this._gpuBuffer={usage:this._usage,memUsage:this._memUsage,size:this._size,stride:this._stride,buffer:null,vf32:null,indirects:new C5,glTarget:0,glBuffer:null},this._usage&_i.UNIFORM&&(this._gpuBuffer.buffer=this._uniformBuffer),function(e,t){var n=e.gl,i=e.stateCache,r=t.memUsage&mi.HOST?n.DYNAMIC_DRAW:n.STATIC_DRAW;if(t.usage&_i.VERTEX){t.glTarget=n.ARRAY_BUFFER;var o=n.createBuffer();o&&(t.glBuffer=o,t.size>0&&(e.extensions.useVAO&&i.glVAO&&(e.extensions.OES_vertex_array_object.bindVertexArrayOES(null),i.glVAO=null),v5.gpuInputAssembler=null,e.stateCache.glArrayBuffer!==t.glBuffer&&(n.bindBuffer(n.ARRAY_BUFFER,t.glBuffer),e.stateCache.glArrayBuffer=t.glBuffer),n.bufferData(n.ARRAY_BUFFER,t.size,r),n.bindBuffer(n.ARRAY_BUFFER,null),e.stateCache.glArrayBuffer=null))}else if(t.usage&_i.INDEX){t.glTarget=n.ELEMENT_ARRAY_BUFFER;var a=n.createBuffer();a&&(t.glBuffer=a,t.size>0&&(e.extensions.useVAO&&i.glVAO&&(e.extensions.OES_vertex_array_object.bindVertexArrayOES(null),i.glVAO=null),v5.gpuInputAssembler=null,e.stateCache.glElementArrayBuffer!==t.glBuffer&&(n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t.glBuffer),e.stateCache.glElementArrayBuffer=t.glBuffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.size,r),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null),e.stateCache.glElementArrayBuffer=null))}else t.usage&_i.UNIFORM?(t.glTarget=n.NONE,t.buffer&&(t.vf32=new Float32Array(t.buffer.buffer))):(t.usage&_i.INDIRECT||t.usage&_i.TRANSFER_DST||t.usage&_i.TRANSFER_SRC||console.error("Unsupported BufferType, create buffer failed."),t.glTarget=n.NONE)}(J3.instance,this._gpuBuffer),J3.instance.memoryStatus.bufferSize+=this._size},n.destroy=function(){this._gpuBuffer&&(function(e,t){var n=e.gl,i=e.stateCache;if(t.glBuffer){switch(t.glTarget){case n.ARRAY_BUFFER:e.extensions.useVAO&&i.glVAO&&(e.extensions.OES_vertex_array_object.bindVertexArrayOES(null),e.stateCache.glVAO=null),v5.gpuInputAssembler=null,n.bindBuffer(n.ARRAY_BUFFER,null),e.stateCache.glArrayBuffer=null;break;case n.ELEMENT_ARRAY_BUFFER:e.extensions.useVAO&&i.glVAO&&(e.extensions.OES_vertex_array_object.bindVertexArrayOES(null),e.stateCache.glVAO=null),v5.gpuInputAssembler=null,n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null),e.stateCache.glElementArrayBuffer=null}n.deleteBuffer(t.glBuffer),t.glBuffer=null}}(J3.instance,this._gpuBuffer),J3.instance.memoryStatus.bufferSize-=this._size,this._gpuBuffer=null),this._gpuBufferView&&(this._gpuBufferView=null)},n.resize=function(e){if(this._isBufferView)console.warn("cannot resize buffer views!");else{var t=this._size;t!==e&&(this._size=e,this._count=this._size/this._stride,this._uniformBuffer&&(this._uniformBuffer=new Uint8Array(e)),this._gpuBuffer&&(this._uniformBuffer&&(this._gpuBuffer.buffer=this._uniformBuffer),this._gpuBuffer.size=e,e>0&&(function(e,t){var n=e.gl,i=e.stateCache,r=t.memUsage&mi.HOST?n.DYNAMIC_DRAW:n.STATIC_DRAW;t.usage&_i.VERTEX?(e.extensions.useVAO&&i.glVAO&&(e.extensions.OES_vertex_array_object.bindVertexArrayOES(null),i.glVAO=null),v5.gpuInputAssembler=null,e.stateCache.glArrayBuffer!==t.glBuffer&&n.bindBuffer(n.ARRAY_BUFFER,t.glBuffer),t.buffer?n.bufferData(n.ARRAY_BUFFER,t.buffer,r):n.bufferData(n.ARRAY_BUFFER,t.size,r),n.bindBuffer(n.ARRAY_BUFFER,null),e.stateCache.glArrayBuffer=null):t.usage&_i.INDEX?(e.extensions.useVAO&&i.glVAO&&(e.extensions.OES_vertex_array_object.bindVertexArrayOES(null),i.glVAO=null),v5.gpuInputAssembler=null,e.stateCache.glElementArrayBuffer!==t.glBuffer&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t.glBuffer),t.buffer?n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.buffer,r):n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.size,r),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null),e.stateCache.glElementArrayBuffer=null):t.usage&_i.UNIFORM?t.buffer&&(t.vf32=new Float32Array(t.buffer.buffer)):(t.usage&_i.INDIRECT||t.usage&_i.TRANSFER_DST||t.usage&_i.TRANSFER_SRC||console.error("Unsupported BufferType, create buffer failed."),t.glTarget=n.NONE)}(J3.instance,this._gpuBuffer),J3.instance.memoryStatus.bufferSize-=t,J3.instance.memoryStatus.bufferSize+=e)))}},n.update=function(e,t){var n;this._isBufferView?console.warn("cannot update through buffer views!"):(n=void 0!==t?t:this._usage&_i.INDIRECT?0:e.byteLength,g5(J3.instance,this._gpuBuffer,e,0,n))},K(t,[{key:"gpuBuffer",get:function(){return this._gpuBuffer}},{key:"gpuBufferView",get:function(){return this._gpuBufferView}}]),t}(so),w5=function(){function e(e,t){this._frees=void 0,this._freeIdx=0,this._freeCmds=void 0,this._frees=new Array(t),this._freeCmds=new Hl(t);for(var n=0;nn&&(n=o.binding)}this._bindingIndices=Array(n+1).fill(-1);for(var a=this._descriptorIndices=Array(n+1).fill(-1),s=0;s0){t.glBlocks=new Array(t.blocks.length);for(var y=0;y0){t.glSamplerTextures=new Array(t.samplerTextures.length);for(var I=0;Ie.capabilities.maxTextureSize&&D(9100,o,e.capabilities.maxTextureSize),!e.extensions.WEBGL_depth_texture&&Qr[t.format].hasDepth)t.glInternalFmt=function(e,t){switch(e){case ui.R5G6B5:return t.RGB565;case ui.RGB5A1:return t.RGB5_A1;case ui.RGBA4:return t.RGBA4;case ui.RGBA16F:return Q3.RGBA16F_EXT;case ui.RGBA32F:return Q3.RGBA32F_EXT;case ui.SRGB8_A8:return Q3.SRGB8_ALPHA8_EXT;case ui.DEPTH:return t.DEPTH_COMPONENT16;case ui.DEPTH_STENCIL:return t.DEPTH_STENCIL;default:return console.error("Unsupported Format, convert to WebGL internal format failed."),t.RGBA}}(t.format,n),t.glRenderbuffer=n.createRenderbuffer(),t.size>0&&(e.stateCache.glRenderbuffer!==t.glRenderbuffer&&(n.bindRenderbuffer(n.RENDERBUFFER,t.glRenderbuffer),e.stateCache.glRenderbuffer=t.glRenderbuffer),n.renderbufferStorage(n.RENDERBUFFER,t.glInternalFmt,i,r));else if(t.glTexture=n.createTexture(),t.size>0){var a=e.stateCache.glTexUnits[e.stateCache.texUnit];if(a.glTexture!==t.glTexture&&(n.bindTexture(n.TEXTURE_2D,t.glTexture),a.glTexture=t.glTexture),Qr[t.format].isCompressed)for(var s=0;s>1),r=Math.max(1,r>>1)}else for(var u=0;u>1),r=Math.max(1,r>>1);t.isPowerOf2?(t.glWrapS=n.REPEAT,t.glWrapT=n.REPEAT):(t.glWrapS=n.CLAMP_TO_EDGE,t.glWrapT=n.CLAMP_TO_EDGE),t.glMinFilter=n.LINEAR,t.glMagFilter=n.LINEAR,n.texParameteri(t.glTarget,n.TEXTURE_WRAP_S,t.glWrapS),n.texParameteri(t.glTarget,n.TEXTURE_WRAP_T,t.glWrapT),n.texParameteri(t.glTarget,n.TEXTURE_MIN_FILTER,t.glMinFilter),n.texParameteri(t.glTarget,n.TEXTURE_MAG_FILTER,t.glMagFilter)}break;case gi.CUBE:t.glTarget=n.TEXTURE_CUBE_MAP;var h=Math.max(i,r);if(h>e.capabilities.maxCubeMapTextureSize&&D(9100,h,e.capabilities.maxTextureSize),t.glTexture=n.createTexture(),t.size>0){var f=e.stateCache.glTexUnits[e.stateCache.texUnit];if(f.glTexture!==t.glTexture&&(n.bindTexture(n.TEXTURE_CUBE_MAP,t.glTexture),f.glTexture=t.glTexture),Qr[t.format].isCompressed)for(var _=0;_<6;++_){i=t.width,r=t.height;for(var p=0;p>1),r=Math.max(1,r>>1)}}else for(var g=0;g<6;++g){i=t.width,r=t.height;for(var v=0;v>1),r=Math.max(1,r>>1)}t.isPowerOf2?(t.glWrapS=n.REPEAT,t.glWrapT=n.REPEAT):(t.glWrapS=n.CLAMP_TO_EDGE,t.glWrapT=n.CLAMP_TO_EDGE),t.glMinFilter=n.LINEAR,t.glMagFilter=n.LINEAR,n.texParameteri(t.glTarget,n.TEXTURE_WRAP_S,t.glWrapS),n.texParameteri(t.glTarget,n.TEXTURE_WRAP_T,t.glWrapT),n.texParameteri(t.glTarget,n.TEXTURE_MIN_FILTER,t.glMinFilter),n.texParameteri(t.glTarget,n.TEXTURE_MAG_FILTER,t.glMagFilter)}break;default:console.error("Unsupported TextureType, create texture failed."),t.type=gi.TEX2D,t.glTarget=n.TEXTURE_2D}}(J3.instance,this._gpuTexture),J3.instance.memoryStatus.textureSize+=this._size)},n.destroy=function(){this._gpuTexture&&(function(e,t){var n=e.gl;if(t.glTexture){var i=e.stateCache.glTexUnits,r=e.stateCache.texUnit;n.deleteTexture(t.glTexture);for(var o=0;oe.capabilities.maxTextureSize&&D(9100,o,e.capabilities.maxTextureSize),t.glRenderbuffer)e.stateCache.glRenderbuffer!==t.glRenderbuffer&&(n.bindRenderbuffer(n.RENDERBUFFER,t.glRenderbuffer),e.stateCache.glRenderbuffer=t.glRenderbuffer),n.renderbufferStorage(n.RENDERBUFFER,t.glInternalFmt,i,r);else if(t.glTexture){var a=e.stateCache.glTexUnits[e.stateCache.texUnit];if(a.glTexture!==t.glTexture&&(n.bindTexture(n.TEXTURE_2D,t.glTexture),a.glTexture=t.glTexture),Qr[t.format].isCompressed)for(var s=0;s>1),r=Math.max(1,r>>1)}else for(var u=0;u>1),r=Math.max(1,r>>1)}break;case gi.CUBE:t.glTarget=n.TEXTURE_CUBE_MAP;var h=Math.max(i,r);h>e.capabilities.maxCubeMapTextureSize&&D(9100,h,e.capabilities.maxTextureSize);var f=e.stateCache.glTexUnits[e.stateCache.texUnit];if(f.glTexture!==t.glTexture&&(n.bindTexture(n.TEXTURE_CUBE_MAP,t.glTexture),f.glTexture=t.glTexture),Qr[t.format].isCompressed)for(var _=0;_<6;++_){i=t.width,r=t.height;for(var p=0;p>1),r=Math.max(1,r>>1)}}else for(var g=0;g<6;++g){i=t.width,r=t.height;for(var v=0;v>1),r=Math.max(1,r>>1)}break;default:console.error("Unsupported TextureType, create texture failed."),t.type=gi.TEX2D,t.glTarget=n.TEXTURE_2D}}}(J3.instance,this._gpuTexture),J3.instance.memoryStatus.textureSize-=n,J3.instance.memoryStatus.textureSize+=this._size)},n.initAsSwapchainTexture=function(e){var t=new pr;t.format=e.format,t.usage=Qr[e.format].hasDepth?vi.DEPTH_STENCIL_ATTACHMENT:vi.COLOR_ATTACHMENT,t.width=e.width,t.height=e.height,this.initialize(t,!0)},K(t,[{key:"gpuTexture",get:function(){return this._gpuTexture}}]),t}(Io),j5="webglcontextlost";function W5(e,t){for(var n=["","WEBKIT_","MOZ_"],i=0;ie.capabilities.maxTextureSize&&D(9100,o,e.capabilities.maxTextureSize),t.samples===xi.ONE){if(t.glTexture=n.createTexture(),t.size>0){var a=e.stateCache.glTexUnits[e.stateCache.texUnit];if(a.glTexture!==t.glTexture&&(n.bindTexture(n.TEXTURE_2D,t.glTexture),a.glTexture=t.glTexture),Qr[t.format].isCompressed)for(var s=0;s>1),r=Math.max(1,r>>1)}else n.texStorage2D(n.TEXTURE_2D,t.mipLevel,t.glInternalFmt,i,r)}}else t.glRenderbuffer=n.createRenderbuffer(),t.size>0&&(e.stateCache.glRenderbuffer!==t.glRenderbuffer&&(n.bindRenderbuffer(n.RENDERBUFFER,t.glRenderbuffer),e.stateCache.glRenderbuffer=t.glRenderbuffer),n.renderbufferStorageMultisample(n.RENDERBUFFER,t.samples,t.glInternalFmt,t.width,t.height));break;case gi.CUBE:t.glTarget=n.TEXTURE_CUBE_MAP;var u=Math.max(i,r);if(u>e.capabilities.maxCubeMapTextureSize&&D(9100,u,e.capabilities.maxTextureSize),t.glTexture=n.createTexture(),t.size>0){var h=e.stateCache.glTexUnits[e.stateCache.texUnit];if(h.glTexture!==t.glTexture&&(n.bindTexture(n.TEXTURE_CUBE_MAP,t.glTexture),h.glTexture=t.glTexture),Qr[t.format].isCompressed)for(var f=0;f>1),r=Math.max(1,r>>1)}else n.texStorage2D(n.TEXTURE_CUBE_MAP,t.mipLevel,t.glInternalFmt,i,r)}break;default:console.error("Unsupported TextureType, create texture failed."),t.type=gi.TEX2D,t.glTarget=n.TEXTURE_2D}}function y8(e,t){var n=e.gl;if(t.glTexture){var i=e.stateCache.glTexUnits,r=e.stateCache.texUnit;n.deleteTexture(t.glTexture);for(var o=0;o=0&&T.gpuDescriptors[E];if(A&&A.gpuBuffer){var C=v[S.set],b=C&&C[S.binding],w=A.gpuBuffer.glOffset;b>=0&&(w+=r[b]),s.glBindUBOs[S.glBinding]===A.gpuBuffer.glBuffer&&s.glBindUBOOffsets[S.glBinding]===w||(w?a.bindBufferRange(a.UNIFORM_BUFFER,S.glBinding,A.gpuBuffer.glBuffer,w,A.gpuBuffer.size):a.bindBufferBase(a.UNIFORM_BUFFER,S.glBinding,A.gpuBuffer.glBuffer),s.glUniformBuffer=s.glBindUBOs[S.glBinding]=A.gpuBuffer.glBuffer,s.glBindUBOOffsets[S.glBinding]=w)}else x("Buffer binding '"+S.name+"' at set "+S.set+" binding "+S.binding+" is not bounded")}for(var R=c.glSamplerTextures.length,P=0;P=0&&D.gpuDescriptors[O],N=0;N0){var B=M.gpuTexture;F.glTexture!==B.glTexture&&(s.texUnit!==L&&(a.activeTexture(a.TEXTURE0+L),s.texUnit=L),B.glTexture?a.bindTexture(B.glTarget,B.glTexture):a.bindTexture(B.glTarget,e.nullTex2D.gpuTexture.glTexture),F.glTexture=B.glTexture);var z=M.gpuSampler;s.glSamplerUnits[L]!==z.glSampler&&(a.bindSampler(L,z.glSampler),s.glSamplerUnits[L]=z.glSampler)}M=D.gpuDescriptors[++O]}else x("Sampler binding '"+I.name+"' at set "+I.set+" binding "+I.binding+" index "+N+" is not bounded")}}if(n&&c&&(l||x8.gpuInputAssembler!==n))if(x8.gpuInputAssembler=n,e.extensions.useVAO){var k=n.glVAOs.get(c.glProgram);if(!k){var U;k=a.createVertexArray(),n.glVAOs.set(c.glProgram,k),a.bindVertexArray(k),a.bindBuffer(a.ARRAY_BUFFER,null),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,null),s.glArrayBuffer=null,s.glElementArrayBuffer=null;for(var G=0;G=0&&(a.enableVertexAttribArray(ne),s.glEnabledAttribLocs[ne]=!0),s.glCurrentAttribLocs[ne]=!0,a.vertexAttribPointer(ne,J.count,J.glType,J.isNormalized,J.stride,ie),a.vertexAttribDivisor(ne,J.isInstanced?1:0)}}}var re=n.gpuIndexBuffer;re&&s.glElementArrayBuffer!==re.glBuffer&&(a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,re.glBuffer),s.glElementArrayBuffer=re.glBuffer);for(var oe=0;oe0){var h=t.firstIndex*a.stride;n.drawElementsInstanced(r,t.indexCount,i.glIndexType,h,t.instanceCount)}}else t.vertexCount>0&&n.drawArraysInstanced(r,t.firstVertex,t.vertexCount,t.instanceCount);else if(a){if(t.indexCount>0){var f=t.firstIndex*a.stride;n.drawElements(r,t.indexCount,i.glIndexType,f)}}else t.vertexCount>0&&n.drawArrays(r,t.firstVertex,t.vertexCount)}}var A8=new Array(o8.COUNT);function C8(e,t){A8.fill(0);for(var n=0;n0,this.instancedDraw=!!t.instanceCount,this.drawCount=Math.max(e+1,this.drawCount),this.drawByIndex?(this.counts[e]=t.indexCount,this.offsets[e]=t.firstIndex):(this.counts[e]=t.vertexCount,this.offsets[e]=t.firstVertex),this.instances[e]=Math.max(1,t.instanceCount)},t._ensureCapacity=function(e){if(!(this._capacity>e)){this._capacity=r(e);var t=new Int32Array(this._capacity),n=new Int32Array(this._capacity),i=new Int32Array(this._capacity);this.byteOffsets=new Int32Array(this._capacity),t.set(this.counts),n.set(this.offsets),i.set(this.instances),this.counts=t,this.offsets=n,this.instances=i}},e}(),R8=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r0&&(e.extensions.useVAO&&i.glVAO&&(n.bindVertexArray(null),i.glVAO=null),x8.gpuInputAssembler=null,e.stateCache.glArrayBuffer!==t.glBuffer&&(n.bindBuffer(n.ARRAY_BUFFER,t.glBuffer),e.stateCache.glArrayBuffer=t.glBuffer),n.bufferData(n.ARRAY_BUFFER,t.size,r),n.bindBuffer(n.ARRAY_BUFFER,null),e.stateCache.glArrayBuffer=null))}else if(t.usage&_i.INDEX){t.glTarget=n.ELEMENT_ARRAY_BUFFER;var a=n.createBuffer();a&&(t.glBuffer=a,t.size>0&&(e.extensions.useVAO&&i.glVAO&&(n.bindVertexArray(null),i.glVAO=null),x8.gpuInputAssembler=null,e.stateCache.glElementArrayBuffer!==t.glBuffer&&(n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t.glBuffer),e.stateCache.glElementArrayBuffer=t.glBuffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.size,r),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null),e.stateCache.glElementArrayBuffer=null))}else if(t.usage&_i.UNIFORM){t.glTarget=n.UNIFORM_BUFFER;var s=n.createBuffer();s&&t.size>0&&(t.glBuffer=s,e.stateCache.glUniformBuffer!==t.glBuffer&&(n.bindBuffer(n.UNIFORM_BUFFER,t.glBuffer),e.stateCache.glUniformBuffer=t.glBuffer),n.bufferData(n.UNIFORM_BUFFER,t.size,r),n.bindBuffer(n.UNIFORM_BUFFER,null),e.stateCache.glUniformBuffer=null)}else t.usage&_i.INDIRECT||t.usage&_i.TRANSFER_DST||t.usage&_i.TRANSFER_SRC||console.error("Unsupported BufferType, create buffer failed."),t.glTarget=n.NONE}(Z5.instance,this._gpuBuffer),Z5.instance.memoryStatus.bufferSize+=this._size},n.destroy=function(){this._gpuBuffer&&(this._isBufferView||(function(e,t){var n=e.gl,i=e.stateCache;if(t.glBuffer){switch(t.glTarget){case n.ARRAY_BUFFER:e.extensions.useVAO&&i.glVAO&&(n.bindVertexArray(null),e.stateCache.glVAO=null),x8.gpuInputAssembler=null,n.bindBuffer(n.ARRAY_BUFFER,null),e.stateCache.glArrayBuffer=null;break;case n.ELEMENT_ARRAY_BUFFER:e.extensions.useVAO&&i.glVAO&&(n.bindVertexArray(null),e.stateCache.glVAO=null),x8.gpuInputAssembler=null,n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null),e.stateCache.glElementArrayBuffer=null;break;case n.UNIFORM_BUFFER:n.bindBuffer(n.UNIFORM_BUFFER,null),e.stateCache.glUniformBuffer=null}n.deleteBuffer(t.glBuffer),t.glBuffer=null}}(Z5.instance,this._gpuBuffer),Z5.instance.memoryStatus.bufferSize-=this._size),this._gpuBuffer=null)},n.resize=function(e){if(this._isBufferView)console.warn("cannot resize buffer views!");else{var t=this._size;t!==e&&(this._size=e,this._count=this._size/this._stride,this._gpuBuffer&&(this._gpuBuffer.size=e,e>0&&(function(e,t){var n=e.gl,i=e.stateCache,r=t.memUsage&mi.HOST?n.DYNAMIC_DRAW:n.STATIC_DRAW;t.usage&_i.VERTEX?(e.extensions.useVAO&&i.glVAO&&(n.bindVertexArray(null),i.glVAO=null),x8.gpuInputAssembler=null,i.glArrayBuffer!==t.glBuffer&&n.bindBuffer(n.ARRAY_BUFFER,t.glBuffer),t.buffer?n.bufferData(n.ARRAY_BUFFER,t.buffer,r):n.bufferData(n.ARRAY_BUFFER,t.size,r),n.bindBuffer(n.ARRAY_BUFFER,null),i.glArrayBuffer=null):t.usage&_i.INDEX?(e.extensions.useVAO&&i.glVAO&&(n.bindVertexArray(null),i.glVAO=null),x8.gpuInputAssembler=null,e.stateCache.glElementArrayBuffer!==t.glBuffer&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t.glBuffer),t.buffer?n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.buffer,r):n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.size,r),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null),e.stateCache.glElementArrayBuffer=null):t.usage&_i.UNIFORM?(e.stateCache.glUniformBuffer!==t.glBuffer&&n.bindBuffer(n.UNIFORM_BUFFER,t.glBuffer),n.bufferData(n.UNIFORM_BUFFER,t.size,r),n.bindBuffer(n.UNIFORM_BUFFER,null),e.stateCache.glUniformBuffer=null):(t.usage&_i.INDIRECT||t.usage&_i.TRANSFER_DST||t.usage&_i.TRANSFER_SRC||console.error("Unsupported BufferType, create buffer failed."),t.glTarget=n.NONE)}(Z5.instance,this._gpuBuffer),Z5.instance.memoryStatus.bufferSize-=t,Z5.instance.memoryStatus.bufferSize+=e)))}},n.update=function(e,t){var n;this._isBufferView?console.warn("cannot update through buffer views!"):(n=void 0!==t?t:this._usage&_i.INDIRECT?0:e.byteLength,g8(Z5.instance,this._gpuBuffer,e,0,n))},K(t,[{key:"gpuBuffer",get:function(){return this._gpuBuffer}}]),t}(so),P8=function(){function e(e,t){this._frees=void 0,this._freeIdx=0,this._freeCmds=void 0,this._frees=new Array(t),this._freeCmds=new Hl(t);for(var n=0;nn&&(n=o.binding)}this._bindingIndices=Array(n+1).fill(-1);for(var a=this._descriptorIndices=Array(n+1).fill(-1),s=0;s0){t.glSamplerTextures=new Array(t.samplerTextures.length);for(var O=0;Oe.capabilities.maxTextureSize&&D(9100,o,e.capabilities.maxTextureSize),t.samples===xi.ONE){var a=e.stateCache.glTexUnits[e.stateCache.texUnit];if(a.glTexture!==t.glTexture&&(n.bindTexture(n.TEXTURE_2D,t.glTexture),a.glTexture=t.glTexture),Qr[t.format].isCompressed)for(var s=0;s>1),r=Math.max(1,r>>1)}else y8(e,t),v8(e,t)}else t.glRenderbuffer&&(e.stateCache.glRenderbuffer!==t.glRenderbuffer&&(n.bindRenderbuffer(n.RENDERBUFFER,t.glRenderbuffer),e.stateCache.glRenderbuffer=t.glRenderbuffer),n.renderbufferStorageMultisample(n.RENDERBUFFER,t.samples,t.glInternalFmt,t.width,t.height));break;case gi.CUBE:t.type=gi.CUBE,t.glTarget=n.TEXTURE_CUBE_MAP;var u=Math.max(i,r);u>e.capabilities.maxCubeMapTextureSize&&D(9100,u,e.capabilities.maxTextureSize);var h=e.stateCache.glTexUnits[e.stateCache.texUnit];if(h.glTexture!==t.glTexture&&(n.bindTexture(n.TEXTURE_CUBE_MAP,t.glTexture),h.glTexture=t.glTexture),Qr[t.format].isCompressed)for(var f=0;f<6;++f){i=t.width,r=t.height;for(var _=0;_>1),r=Math.max(1,r>>1)}}else y8(e,t),v8(e,t);break;default:console.error("Unsupported TextureType, create texture failed."),t.type=gi.TEX2D,t.glTarget=n.TEXTURE_2D}}}(Z5.instance,this._gpuTexture),Z5.instance.memoryStatus.textureSize-=n,Z5.instance.memoryStatus.textureSize+=this._size)},n.initAsSwapchainTexture=function(e){var t=new pr;t.format=e.format,t.usage=Qr[e.format].hasDepth?vi.DEPTH_STENCIL_ATTACHMENT:vi.COLOR_ATTACHMENT,t.width=e.width,t.height=e.height,this.initialize(t,!0)},K(t,[{key:"gpuTexture",get:function(){return this._gpuTexture}}]),t}(Io),W8="webglcontextlost";function q8(e,t){for(var n=["","WEBKIT_","MOZ_"],i=0;i=0&&s<=1&&c>=0&&c<=1)return!0}return!1}c.WebGL2Device=K8;var Z8=new Wn,J8=new Wn,$8=new Wn,e6=new Wn;function t6(e,t,n){for(var i=n.length,r=0;rr!=h>r&&i<(u-c)*(r-l)/(h-l)+c&&(n=!n)}return n}function i6(e,t,n,i){var r,o=n.x-t.x,a=n.y-t.y,s=o*o+a*a,c=((e.x-t.x)*o+(e.y-t.y)*a)/s;return r=i?s?c<0?t:c>1?n:Z8.set(t.x+c*o,t.y+c*a):t:Z8.set(t.x+c*o,t.y+c*a),o=e.x-r.x,a=e.y-r.y,Math.sqrt(o*o+a*a)}var r6=e("Intersection2D",(function(){}));r6.lineLine=Q8,r6.lineRect=function(e,t,n){var i=Z8.set(n.x,n.y),r=J8.set(n.x,n.yMax),o=$8.set(n.xMax,n.yMax),a=e6.set(n.xMax,n.y);return!!(Q8(e,t,i,r)||Q8(e,t,r,o)||Q8(e,t,o,a)||Q8(e,t,a,i))},r6.linePolygon=t6,r6.rectRect=function(e,t){var n=e.x,i=e.y,r=e.x+e.width,o=e.y+e.height,a=t.x,s=t.y,c=t.x+t.width,l=t.y+t.height;return n<=c&&r>=a&&i<=l&&o>=s},r6.rectPolygon=function(e,t){var n=Z8.set(e.x,e.y),i=J8.set(e.x,e.yMax),r=$8.set(e.xMax,e.yMax),o=e6.set(e.xMax,e.y);if(t6(n,i,t))return!0;if(t6(i,r,t))return!0;if(t6(r,o,t))return!0;if(t6(o,n,t))return!0;for(var a=0,s=t.length;ao+s&&(l=o+s),ra+c&&(u=a+c);var h=i-l,f=r-u;return Math.sqrt(h*h+f*f)<=n},r6.polygonPolygon=function(e,t){var n,i;for(n=0,i=e.length;n1?c=s/l:s=c*l;var u=s/2,h=c/2;if(e.rotation){var f=-u,_=-h,p=u,d=h,m=-St(e.rotation),g=Math.cos(m),v=Math.sin(m);r[i]=f*g-_*v+o,r[i+1]=f*v+_*g+a,r[i+2]=0,r[i+9]=p*g-_*v+o,r[i+10]=p*v+_*g+a,r[i+11]=0,r[i+18]=f*g-d*v+o,r[i+19]=f*v+d*g+a,r[i+20]=0,r[i+27]=p*g-d*v+o,r[i+28]=p*v+d*g+a,r[i+29]=0}else r[i]=o-u,r[i+1]=a-h,r[i+2]=0,r[i+9]=o+u,r[i+10]=a-h,r[i+11]=0,r[i+18]=o-u,r[i+19]=a+h,r[i+20]=0,r[i+27]=o+u,r[i+28]=a+h,r[i+29]=0;An.toArray(r,e.color,i+5),An.toArray(r,e.color,i+14),An.toArray(r,e.color,i+23),An.toArray(r,e.color,i+32)},t.step=function(e){var t=this.sys.assembler,n=this.sys,i=n.node,r=this.particles;if(e=e>t.maxParticleDeltaTime?t.maxParticleDeltaTime:e,i.updateWorldTransform(),n.positionType===u6.FREE){this._worldRotation=function(e){for(var t=0,n=e;n;)t+=n.eulerAngles.z,n=n.parent;return t}(i);var o=i.worldMatrix;f6.x=o.m12,f6.y=o.m13}else n.positionType===u6.RELATIVE?(this._worldRotation=i.eulerAngles.z,f6.x=i.position.x,f6.y=i.position.y):this._worldRotation=0;if(this.active&&n.emissionRate){var a=1/n.emissionRate;for(r.lengtha;)this.emitParticle(f6),this.emitCounter-=a;this.elapsed+=e,-1!==n.duration&&n.durationthis.uvFilled&&this.updateUVs();for(var l=0;l0){if(n.emitterMode===l6.GRAVITY){var h=d6,f=_6,_=p6;(u.pos.x||u.pos.y)&&(f.set(u.pos),f.normalize()),_.set(f),f.multiplyScalar(u.radialAccel);var p=_.x;_.x=-_.y,_.y=p,_.multiplyScalar(u.tangentialAccel),h.set(f),h.add(_),h.add(n.gravity),h.multiplyScalar(e),u.dir.add(h),h.set(u.dir),h.multiplyScalar(e),u.pos.add(h)}else u.angle+=u.degreesPerSecond*e,u.radius+=u.deltaRadius*e,u.pos.x=-Math.cos(u.angle)*u.radius,u.pos.y=-Math.sin(u.angle)*u.radius;u.color.r+=u.deltaColor.r*e,u.color.g+=u.deltaColor.g*e,u.color.b+=u.deltaColor.b*e,u.color.a+=u.deltaColor.a*e,u.size+=u.deltaSize*e,u.size<0&&(u.size=0),u.rotation+=u.deltaRotation*e;var d=_6;d.set(u.pos),n.positionType!==u6.GROUPED&&d.add(u.startPos);var m=m6*l*4;this.updateParticleBuffer(u,d,s,m),++l}else{var g=r[l];l!==r.length-1&&(r[l]=r[r.length-1]),v6.put(g),r.length--,s.resize(s.vertexCount-4,s.indexCount-6)}}0!==r.length||this.active||this.readyToPlay||(this.finished=!0,n._finishedSimulation())},t.requestData=function(e,t){var n=this.renderData.indexCount;this.renderData.request(e,t);for(var i=this.renderData.indexCount/6,r=this.renderData.iData,o=n;o>>0;e=i}for(var r,o=1,a=0,s=e.length,c=0;0>>0}function s(t,n){this.index="number"==typeof n?n:0,this.i=0,this.buffer=t instanceof(o?Uint8Array:Array)?t:new(o?Uint8Array:Array)(32768),2*this.buffer.length<=this.index&&e(Error("invalid index")),this.buffer.length<=this.index&&this.f()}s.prototype.f=function(){var e,t=this.buffer,n=t.length,i=new(o?Uint8Array:Array)(n<<1);if(o)i.set(t);else for(e=0;e>>8&255]<<16|_[e>>>16&255]<<8|_[e>>>24&255])>>32-t:_[e]>>8-t),8>t+a)s=s<>t-i-1&1,8==++a&&(a=0,r[o++]=_[s],s=0,o===r.length&&(r=this.f()));r[o]=s,this.buffer=r,this.i=a,this.index=o},s.prototype.finish=function(){var e,t=this.buffer,n=this.index;return 0c;++c){for(var u=f=c,h=7,f=f>>>1;f;f>>>=1)u<<=1,u|=1&f,--h;l[c]=(u<>>0}var _=l;function p(e){this.buffer=new(o?Uint16Array:Array)(2*e),this.length=0}function d(e){var t,n,i,r,a,s,c,l,u,h=e.length,f=0,_=Number.POSITIVE_INFINITY;for(l=0;lf&&(f=e[l]),e[l]<_&&(_=e[l]);for(t=1<>=1;for(u=s;uo[i]);)r=o[n],o[n]=o[i],o[i]=r,r=o[n+1],o[n+1]=o[i+1],o[i+1]=r,n=i;return this.length},p.prototype.pop=function(){var e,t,n,i,r,o=this.buffer;for(t=o[0],e=o[1],this.length-=2,o[0]=o[this.length],o[1]=o[this.length+1],r=0;!((i=2*r+2)>=this.length)&&(i+2o[i]&&(i+=2),o[i]>o[r]);)n=o[r],o[r]=o[i],o[i]=n,n=o[r+1],o[r+1]=o[i+1],o[i+1]=n,r=i;return{index:e,value:t,length:this.length}};var g,v=2,y={NONE:0,r:1,j:v,N:3},x=[];for(g=0;288>g;g++)switch(n){case 143>=g:x.push([g+48,8]);break;case 255>=g:x.push([g-144+400,9]);break;case 279>=g:x.push([g-256+0,7]);break;case 287>=g:x.push([g-280+192,8]);break;default:e("invalid literal: "+g)}function S(e,t){this.length=e,this.G=t}function T(){var t=E;switch(n){case 3===t:return[257,t-3,0];case 4===t:return[258,t-4,0];case 5===t:return[259,t-5,0];case 6===t:return[260,t-6,0];case 7===t:return[261,t-7,0];case 8===t:return[262,t-8,0];case 9===t:return[263,t-9,0];case 10===t:return[264,t-10,0];case 12>=t:return[265,t-11,1];case 14>=t:return[266,t-13,1];case 16>=t:return[267,t-15,1];case 18>=t:return[268,t-17,1];case 22>=t:return[269,t-19,2];case 26>=t:return[270,t-23,2];case 30>=t:return[271,t-27,2];case 34>=t:return[272,t-31,2];case 42>=t:return[273,t-35,3];case 50>=t:return[274,t-43,3];case 58>=t:return[275,t-51,3];case 66>=t:return[276,t-59,3];case 82>=t:return[277,t-67,4];case 98>=t:return[278,t-83,4];case 114>=t:return[279,t-99,4];case 130>=t:return[280,t-115,4];case 162>=t:return[281,t-131,5];case 194>=t:return[282,t-163,5];case 226>=t:return[283,t-195,5];case 257>=t:return[284,t-227,5];case 258===t:return[285,t-258,0];default:e("invalid length: "+t)}}m.prototype.n=function(){var i,r,a,c,l=this.input;switch(this.h){case 0:for(a=0,c=l.length;a>>8&255,g[y++]=255&f,g[y++]=f>>>8&255,o)g.set(_,y),y+=_.length,g=g.subarray(0,y);else{for(d=0,m=_.length;dK)for(;0K?K:138)>K-3&&J=J?(ne[Z++]=17,ne[Z++]=J-3,ie[17]++):(ne[Z++]=18,ne[Z++]=J-11,ie[18]++),K-=J;else if(ne[Z++]=te[X],ie[te[X]]++,3>--K)for(;0K?K:6)>K-3&&JH;H++)q[H]=z[W[H]];for(M=19;4=E;E++)A=T(),C[E]=A[2]<<24|A[1]<<16|A[0];var b=o?new Uint32Array(C):C;function w(i,r){function a(t,i){var r,o,a,s,c=t.G,l=[],u=0;switch(r=b[t.length],l[u++]=65535&r,l[u++]=r>>16&255,l[u++]=r>>24,n){case 1===c:o=[0,c-1,0];break;case 2===c:o=[1,c-2,0];break;case 3===c:o=[2,c-3,0];break;case 4===c:o=[3,c-4,0];break;case 6>=c:o=[4,c-5,1];break;case 8>=c:o=[5,c-7,1];break;case 12>=c:o=[6,c-9,2];break;case 16>=c:o=[7,c-13,2];break;case 24>=c:o=[8,c-17,3];break;case 32>=c:o=[9,c-25,3];break;case 48>=c:o=[10,c-33,4];break;case 64>=c:o=[11,c-49,4];break;case 96>=c:o=[12,c-65,5];break;case 128>=c:o=[13,c-97,5];break;case 192>=c:o=[14,c-129,6];break;case 256>=c:o=[15,c-193,6];break;case 384>=c:o=[16,c-257,7];break;case 512>=c:o=[17,c-385,7];break;case 768>=c:o=[18,c-513,8];break;case 1024>=c:o=[19,c-769,8];break;case 1536>=c:o=[20,c-1025,9];break;case 2048>=c:o=[21,c-1537,9];break;case 3072>=c:o=[22,c-2049,10];break;case 4096>=c:o=[23,c-3073,10];break;case 6144>=c:o=[24,c-4097,11];break;case 8192>=c:o=[25,c-6145,11];break;case 12288>=c:o=[26,c-8193,12];break;case 16384>=c:o=[27,c-12289,12];break;case 24576>=c:o=[28,c-16385,13];break;case 32768>=c:o=[29,c-24577,13];break;default:e("invalid distance")}for(r=o,l[u++]=r[0],l[u++]=r[1],l[u++]=r[2],a=0,s=l.length;a=l;)x[l++]=0;for(l=0;29>=l;)T[l++]=0}for(x[256]=1,s=0,c=r.length;s=c){for(p&&a(p,-1),l=0,u=c-s;lR&&s+Rw&&(C=A,w=R),258===R)break}_=new S(w,s-C),p?p.length<_.length?(d=r[s-1],g[v++]=d,++x[d],a(_,0)):a(p,-1):_.length2*y[_-1]+x[_]&&(y[_]=2*y[_-1]+x[_]),T[_]=Array(y[_]),E[_]=Array(y[_]);for(f=0;fr[f]?(T[_][d]=m,E[_][d]=v,g+=2):(T[_][d]=r[f],E[_][d]=f,++f);A[_]=0,1===x[_]&&n(_)}for(a=S,s=0,c=i.length;s1<u&&e("undercommitted"),n=0,i=t.length;n>>=1;return s}function I(e,t){this.input=e,this.a=new(o?Uint8Array:Array)(32768),this.h=D.j;var n,i={};for(n in!t&&(t={})||"number"!=typeof t.compressionType||(this.h=t.compressionType),t)i[n]=t[n];i.outputBuffer=this.a,this.z=new m(this.input,i)}var D=y;function O(t,n){switch(this.k=[],this.l=32768,this.e=this.g=this.c=this.q=0,this.input=o?new Uint8Array(t):t,this.s=!1,this.m=N,this.B=!1,!n&&(n={})||(n.index&&(this.c=n.index),n.bufferSize&&(this.l=n.bufferSize),n.bufferType&&(this.m=n.bufferType),n.resize&&(this.B=n.resize)),this.m){case M:this.b=32768,this.a=new(o?Uint8Array:Array)(32768+this.l+258);break;case N:this.b=0,this.a=new(o?Uint8Array:Array)(this.l),this.f=this.J,this.t=this.H,this.o=this.I;break;default:e(Error("invalid inflate mode"))}}I.prototype.n=function(){var t,n,i,r,s,c,l,u=0;switch(l=this.a,t=ue){case ue:n=Math.LOG2E*Math.log(32768)-8;break;default:e(Error("invalid compression method"))}switch(i=n<<4|t,l[u++]=i,t){case ue:switch(this.h){case D.NONE:s=0;break;case D.r:s=1;break;case D.j:s=2;break;default:e(Error("unsupported compression type"))}break;default:e(Error("invalid compression method"))}return r=s<<6|0,l[u++]=r|31-(256*i+r)%31,c=a(this.input),this.z.b=u,u=(l=this.z.n()).length,o&&((l=new Uint8Array(l.buffer)).length<=u+4&&(this.a=new Uint8Array(l.length+4),this.a.set(l),l=this.a),l=l.subarray(0,u+4)),l[u++]=c>>24&255,l[u++]=c>>16&255,l[u++]=c>>8&255,l[u++]=255&c,l},r("Zlib.Deflate",I),r("Zlib.Deflate.compress",(function(e,t){return new I(e,t).n()})),r("Zlib.Deflate.CompressionType",D),r("Zlib.Deflate.CompressionType.NONE",D.NONE),r("Zlib.Deflate.CompressionType.FIXED",D.r),r("Zlib.Deflate.CompressionType.DYNAMIC",D.j);var M=0,N=1,L={D:M,C:N};O.prototype.p=function(){for(;!this.s;){var i=ee(this,3);switch(1&i&&(this.s=n),i>>>=1){case 0:var r=this.input,a=this.c,s=this.a,c=this.b,l=t,u=t,h=t,f=s.length,_=t;switch(this.e=this.g=0,(l=r[a++])===t&&e(Error("invalid uncompressed block header: LEN (first byte)")),u=l,(l=r[a++])===t&&e(Error("invalid uncompressed block header: LEN (second byte)")),u|=l<<8,(l=r[a++])===t&&e(Error("invalid uncompressed block header: NLEN (first byte)")),h=l,(l=r[a++])===t&&e(Error("invalid uncompressed block header: NLEN (second byte)")),u===~(h|=l<<8)&&e(Error("invalid uncompressed block header: length verify")),a+u>r.length&&e(Error("input buffer is broken")),this.m){case M:for(;c+u>s.length;){if(u-=_=f-c,o)s.set(r.subarray(a,a+_),c),c+=_,a+=_;else for(;_--;)s[c++]=r[a++];this.b=c,s=this.f(),c=this.b}break;case N:for(;c+u>s.length;)s=this.f({v:2});break;default:e(Error("invalid inflate mode"))}if(o)s.set(r.subarray(a,a+u),c),c+=u,a+=u;else for(;u--;)s[c++]=r[a++];this.c=a,this.b=c,this.a=s;break;case 1:this.o(Z,$);break;case 2:ne(this);break;default:e(Error("unknown BTYPE: "+i))}}return this.t()};var F,B,z=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],k=o?new Uint16Array(z):z,U=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],G=o?new Uint16Array(U):U,H=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0],V=o?new Uint8Array(H):H,j=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],W=o?new Uint16Array(j):j,q=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],X=o?new Uint8Array(q):q,Y=new(o?Uint8Array:Array)(288);for(F=0,B=Y.length;F=F?8:255>=F?9:279>=F?7:8;var K,Q,Z=d(Y),J=new(o?Uint8Array:Array)(30);for(K=0,Q=J.length;K>>i,n.e=a-i,n.c=c,r}function te(n,i){for(var r,o,a,s=n.g,c=n.e,l=n.input,u=n.c,h=i[0],f=i[1];c>>16,n.g=s>>a,n.e=c-a,n.c=u,65535&o}function ne(e){function t(e,t,n){var i,r,o,a;for(a=0;ar)i>=c&&(this.b=i,n=this.f(),i=this.b),n[i++]=r;else for(s=G[o=r-257],0=c&&(this.b=i,n=this.f(),i=this.b);s--;)n[i]=n[i++-a];for(;8<=this.e;)this.e-=8,this.c--;this.b=i},O.prototype.I=function(e,t){var n=this.a,i=this.b;this.u=e;for(var r,o,a,s,c=n.length;256!==(r=te(this,e));)if(256>r)i>=c&&(c=(n=this.f()).length),n[i++]=r;else for(s=G[o=r-257],0c&&(c=(n=this.f()).length);s--;)n[i]=n[i++-a];for(;8<=this.e;)this.e-=8,this.c--;this.b=i},O.prototype.f=function(){var e,t,n=new(o?Uint8Array:Array)(this.b-32768),i=this.b-32768,r=this.a;if(o)n.set(r.subarray(32768,n.length));else for(e=0,t=n.length;ee;++e)r[e]=r[i+e];return this.b=32768,r},O.prototype.J=function(e){var t,n,i,r=this.input.length/this.c+1|0,a=this.input,s=this.a;return e&&("number"==typeof e.v&&(r=e.v),"number"==typeof e.F&&(r+=e.F)),n=2>r?(i=(a.length-this.c)/this.u[2]/2*258|0)t&&(this.a.length=t),e=this.a),this.buffer=e},ie.prototype.p=function(){var t,n=this.input;return t=this.A.p(),this.c=this.A.c,this.M&&(n[this.c++]<<24|n[this.c++]<<16|n[this.c++]<<8|n[this.c++])>>>0!==a(t)&&e(Error("invalid adler-32 checksum")),t},r("Zlib.Inflate",ie),r("Zlib.Inflate.BufferType",L),L.ADAPTIVE=L.C,L.BLOCK=L.D,r("Zlib.Inflate.prototype.decompress",ie.prototype.p);var re,oe,ae=new(o?Uint8Array:Array)(288);for(re=0,oe=ae.length;re=re?8:255>=re?9:279>=re?7:8;d(ae);var se,ce,le=new(o?Uint8Array:Array)(30);for(se=0,ce=le.length;se=0?io;o>=0?++i:--i)e.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:this.transparency.indexed=this.read(o);var l=255-this.transparency.indexed.length;if(l>0)for(r=0;l>=0?rl;l>=0?++r:--r)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(o)[0];break;case 2:this.transparency.rgb=this.read(o)}break;case"tEXt":var u=this.read(o),h=u.indexOf(0),f=String.fromCharCode.apply(String,u.slice(0,h));this.text[f]=String.fromCharCode.apply(String,u.slice(h+1));break;case"IEND":t&&this.animation.frames.push(t),this.colors=function(){switch(n.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this);var _=this.colorType;this.hasAlphaChannel=4===_||6===_;var p=this.colors+(this.hasAlphaChannel?1:0);return this.pixelBitlength=this.bits*p,this.colorSpace=function(){switch(n.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(this.imgData instanceof Uint8Array||(this.imgData=new Uint8Array(this.imgData)));default:this.pos+=o}if(this.pos+=4,this.pos>this.data.length)throw new Error(L(6017))}}var t=e.prototype;return t.read=function(e){var t=0,n=[];for(t=0;e>=0?te;e>=0?++t:--t)n.push(this.data[this.pos++]);return n},t.readUInt32=function(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]},t.readUInt16=function(){return this.data[this.pos++]<<8|this.data[this.pos++]},t.decodePixels=function(e){if(null==e&&(e=this.imgData),0===e.length)return new Uint8Array(0);e=new T6.Inflate(e,{index:0,verify:!1}).decompress();for(var t=this.pixelBitlength/8,n=t*this.width,i=new Uint8Array(n*this.height),r=e.length,o=0,a=0,s=0,c=0,l=0,u=0,h=0,f=0,_=0,p=0,d=0,m=0,g=0,v=0,y=0,x=0,S=0,T=0,E=0;a>>8*(4-o)):r.push(i);else for(var a=0;a=8?-1!==["RATIONAL","SRATIONAL"].indexOf(t)?(r.push(this.getUint32(i+s)),r.push(this.getUint32(i+s+4))):w(8e3):r.push(this.getBytes(o,i+s))}return"ASCII"===t&&r.forEach((function(e,t,n){n[t]=String.fromCharCode(e)})),r},t.getBytes=function(e,t){if(e<=0)w(8001);else{if(e<=1)return this.getUint8(t);if(e<=2)return this.getUint16(t);if(e<=3)return this.getUint32(t)>>>8;if(e<=4)return this.getUint32(t);w(8002)}return 0},t.getBits=function(e,t,n){n=n||0;var i=t+Math.floor(n/8),r=n+e,o=32-e,a=0,s=0;return r<=0?w(6023):r<=8?(a=24+n,s=this.getUint8(i)):r<=16?(a=16+n,s=this.getUint16(i)):r<=32?(a=n,s=this.getUint32(i)):w(6022),{bits:s<>>o,byteOffset:i+Math.floor(r/8),bitOffset:r%8}},t.parseFileDirectory=function(e){var t=this.getUint16(e),n=[],i=0,r=0;for(i=e+2,r=0;r=0&&F<=127?g=F+1:F>=-127&&F<=-1?v=1-F:C=!0}else{for(var B=this.getUint8(x+T),z=0;z0)for(var le=0;le>4,n=(15&r)<<4|(o=w6[e.charCodeAt(c++)])>>2,i=(3&o)<<6|(a=w6[e.charCodeAt(c++)]),s.push(String.fromCharCode(t)),64!==o&&s.push(String.fromCharCode(n)),64!==a&&s.push(String.fromCharCode(i));return s.join("")},decodeAsArray:function(e,t){var n,i,r,o=this.decode(e),a=[];for(n=0,r=o.length/t;n=0;--i)a[n]+=o.charCodeAt(n*t+i)<<8*i;return a}},D6=function(e){this.data=e,this.debug=!1,this.gpflags=void 0,this.files=0,this.unzipped=[],this.buf32k=new Array(32768),this.bIdx=0,this.modeZIP=!1,this.bytepos=0,this.bb=1,this.bits=0,this.nameBuf=[],this.fileout=void 0,this.literalTree=new Array(D6.LITERALS),this.distanceTree=new Array(32),this.treepos=0,this.Places=null,this.len=0,this.fpos=new Array(17),this.fpos[0]=0,this.flens=void 0,this.fmax=void 0};D6.gunzip=function(e){return e.constructor===Array||e.constructor,new D6(e).gunzip()[0][0]},D6.HufNode=function(){this.b0=0,this.b1=0,this.jump=null,this.jumppos=-1},D6.LITERALS=288,D6.NAMEMAX=256,D6.bitReverse=[0,128,64,192,32,160,96,224,16,144,80,208,48,176,112,240,8,136,72,200,40,168,104,232,24,152,88,216,56,184,120,248,4,132,68,196,36,164,100,228,20,148,84,212,52,180,116,244,12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252,2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242,10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250,6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246,14,142,78,206,46,174,110,238,30,158,94,222,62,190,126,254,1,129,65,193,33,161,97,225,17,145,81,209,49,177,113,241,9,137,73,201,41,169,105,233,25,153,89,217,57,185,121,249,5,133,69,197,37,165,101,229,21,149,85,213,53,181,117,245,13,141,77,205,45,173,109,237,29,157,93,221,61,189,125,253,3,131,67,195,35,163,99,227,19,147,83,211,51,179,115,243,11,139,75,203,43,171,107,235,27,155,91,219,59,187,123,251,7,135,71,199,39,167,103,231,23,151,87,215,55,183,119,247,15,143,79,207,47,175,111,239,31,159,95,223,63,191,127,255],D6.cplens=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],D6.cplext=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,99,99],D6.cpdist=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],D6.cpdext=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],D6.border=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],D6.prototype.gunzip=function(){return this.outputArr=[],this.nextFile(),this.unzipped},D6.prototype.readByte=function(){return this.bits+=8,this.bytepos>=1,0===this.bb&&(this.bb=this.readByte(),e=1&this.bb,this.bb=this.bb>>1|128),e},D6.prototype.readBits=function(e){for(var t=0,n=e;n--;)t=t<<1|this.readBit();return e&&(t=D6.bitReverse[t]>>8-e),t},D6.prototype.flushBuffer=function(){this.bIdx=0},D6.prototype.addBuffer=function(e){this.buf32k[this.bIdx++]=e,this.outputArr.push(String.fromCharCode(e)),32768===this.bIdx&&(this.bIdx=0)},D6.prototype.IsPat=function(){for(;;){if(this.fpos[this.len]>=this.fmax)return-1;if(this.flens[this.fpos[this.len]]===this.len)return this.fpos[this.len]++;this.fpos[this.len]++}},D6.prototype.Rec=function(){var e,t=this.Places[this.treepos];if(17===this.len)return-1;if(this.treepos++,this.len++,(e=this.IsPat())>=0)t.b0=e;else if(t.b0=32768,this.Rec())return-1;if((e=this.IsPat())>=0)t.b1=e,t.jump=null;else if(t.b1=32768,t.jump=this.Places[this.treepos],t.jumppos=this.treepos,this.Rec())return-1;return this.len--,0},D6.prototype.CreateTree=function(e,t,n){var i;for(this.Places=e,this.treepos=0,this.flens=n,this.fmax=t,i=0;i<17;i++)this.fpos[i]=0;return this.len=0,this.Rec()?-1:0},D6.prototype.DecodeValue=function(e){for(var t,n,i=0,r=e[i];;)if(this.readBit()){if(!(32768&r.b1))return r.b1;for(r=r.jump,t=e.length,n=0;n>1)>23?(a=a<<1|this.readBit())>199?a=(a-=128)<<1|this.readBit():(a-=48)>143&&(a+=136):a+=256,a<256)this.addBuffer(a);else{if(256===a)break;for(a-=257,p=this.readBits(D6.cplext[a])+D6.cplens[a],a=D6.bitReverse[this.readBits(5)]>>3,D6.cpdext[a]>8?(d=this.readBits(8),d|=this.readBits(D6.cpdext[a]-8)<<8):d=this.readBits(D6.cpdext[a]),d+=D6.cpdist[a],a=0;as)return this.flushBuffer(),1;for(f=n?h[n-1]:0;a--;)h[n++]=f}else{if(n+(a=17===a?3+this.readBits(3):11+this.readBits(7))>s)return this.flushBuffer(),1;for(;a--;)h[n++]=0}for(p=this.literalTree.length,n=0;n=256){var p,d;if(0==(a-=256))break;for(a--,p=this.readBits(D6.cplext[a])+D6.cplens[a],a=this.DecodeValue(this.distanceTree),D6.cpdext[a]>8?(d=this.readBits(8),d|=this.readBits(D6.cpdext[a]-8)<<8):d=this.readBits(D6.cpdext[a]),d+=D6.cpdist[a];p--;)o=this.buf32k[this.bIdx-d&32767],this.addBuffer(o)}else this.addBuffer(a)}}while(!e);return this.flushBuffer(),this.byteAlign(),0},D6.prototype.unzipFile=function(e){var t;for(this.gunzip(),t=0;t=0;--i)a[n]+=o.charCodeAt(n*t+i)<<8*i;return a},w9.unzipAsArray=function(e,t){t=t||1;var n,i,r,o=this.unzip(e),a=[];for(n=0,r=o.length/t;n=0;--i)a[n]+=o.charCodeAt(n*t+i)<<8*i;return a},function(e){e[e.JPG=0]="JPG",e[e.PNG=1]="PNG",e[e.TIFF=2]="TIFF",e[e.WEBP=3]="WEBP",e[e.PVR=4]="PVR",e[e.ETC=5]="ETC",e[e.S3TC=6]="S3TC",e[e.ATITC=7]="ATITC",e[e.TGA=8]="TGA",e[e.RAWDATA=9]="RAWDATA",e[e.UNKNOWN=10]="UNKNOWN"}(b9||(b9={}));var P9,I9,D9,O9,M9,N9,L9,F9,B9,z9,k9,U9,G9,H9,V9=e("ParticleSystem2D",(O6=hc("cc.ParticleSystem2D"),M6=Ec(),N6=zc(),L6=Oc(),F6=Wc(x6),B6=zc(),z6=Oc(),k6=Wc(rH),U6=Oc(),G6=Oc(),H6=Oc(),V6=Oc(),j6=Oc(),W6=Oc(),q6=Oc(),X6=Oc(),Y6=Pc(),K6=Oc(),Q6=Oc(),Z6=Oc(),J6=Oc(),$6=Oc(),e7=Oc(),t7=Oc(),n7=Oc(),i7=Oc(),r7=Oc(),o7=Oc(),a7=Oc(),s7=Oc(),c7=Wc(u6),l7=Oc(),u7=zc(),h7=Oc(),f7=Wc(l6),_7=Oc(),p7=Oc(),d7=Oc(),m7=Oc(),g7=Oc(),v7=Oc(),y7=Oc(),x7=Oc(),S7=Oc(),T7=Oc(),E7=Oc(),A7=Oc(),C7=Oc(),b7=Oc(),w7=Oc(),R7=zc(),P7=Oc(),I7=zc(),D7=Oc(),O7=vc("preview"),O6(M7=M6(M7=Ac(M7=Tc((C9=A9=function(e){function t(){var t;return ae(t=e.call(this)||this,"duration",L7,ie(t)),ae(t,"emissionRate",F7,ie(t)),ae(t,"life",B7,ie(t)),ae(t,"lifeVar",z7,ie(t)),ae(t,"angle",k7,ie(t)),ae(t,"angleVar",U7,ie(t)),ae(t,"startSize",G7,ie(t)),ae(t,"startSizeVar",H7,ie(t)),ae(t,"endSize",V7,ie(t)),ae(t,"endSizeVar",j7,ie(t)),ae(t,"startSpin",W7,ie(t)),ae(t,"startSpinVar",q7,ie(t)),ae(t,"endSpin",X7,ie(t)),ae(t,"endSpinVar",Y7,ie(t)),ae(t,"sourcePos",K7,ie(t)),ae(t,"posVar",Q7,ie(t)),ae(t,"emitterMode",Z7,ie(t)),ae(t,"gravity",J7,ie(t)),ae(t,"speed",$7,ie(t)),ae(t,"speedVar",e9,ie(t)),ae(t,"tangentialAccel",t9,ie(t)),ae(t,"tangentialAccelVar",n9,ie(t)),ae(t,"radialAccel",i9,ie(t)),ae(t,"radialAccelVar",r9,ie(t)),ae(t,"rotationIsDir",o9,ie(t)),ae(t,"startRadius",a9,ie(t)),ae(t,"startRadiusVar",s9,ie(t)),ae(t,"endRadius",c9,ie(t)),ae(t,"endRadiusVar",l9,ie(t)),ae(t,"rotatePerS",u9,ie(t)),ae(t,"rotatePerSVar",h9,ie(t)),t.aspectRatio=1,ae(t,"playOnLoad",f9,ie(t)),ae(t,"autoRemoveOnFinish",_9,ie(t)),ae(t,"_preview",p9,ie(t)),ae(t,"_custom",d9,ie(t)),ae(t,"_file",m9,ie(t)),ae(t,"_spriteFrame",g9,ie(t)),ae(t,"_totalParticles",v9,ie(t)),ae(t,"_startColor",y9,ie(t)),ae(t,"_startColorVar",x9,ie(t)),ae(t,"_endColor",S9,ie(t)),ae(t,"_endColorVar",T9,ie(t)),ae(t,"_positionType",E9,ie(t)),t._stopped=!0,t.initProperties(),t}Z(t,e);var n=t.prototype;return n.onEnable=function(){e.prototype.onEnable.call(this),this._updateMaterial()},n.onDestroy=function(){e.prototype.onDestroy.call(this),this.autoRemoveOnFinish&&(this.autoRemoveOnFinish=!1),this._simulator.uvFilled=0,this._simulator.renderData&&this._assembler&&this._assembler.removeData(this._simulator.renderData)},n.initProperties=function(){this._previewTimer=null,this._focused=!1,this.aspectRatio=1,this._simulator=new y6(this)},n.onFocusInEditor=function(){this._focused=!0;for(var e=R9(this.node),t=0;t=this.totalParticles},n._applyFile=function(){var e=this._file;if(e){if(!e)return void D(6029);if(!this.isValid)return;this._plistFile=e.nativeUrl,this._custom||(this._spriteFrame!==e.spriteFrame&&(this.spriteFrame=e.spriteFrame),this._initWithDictionary(e._nativeAsset)),this._spriteFrame?!this._renderSpriteFrame&&this._spriteFrame&&this._applySpriteFrame():e.spriteFrame?this.spriteFrame=e.spriteFrame:this._custom&&this._initTextureWithDictionary(e._nativeAsset)}},n._initTextureWithDictionary=function(e){var t,n=this;if(e.spriteFrameUuid){var i=e.spriteFrameUuid;ZN.loadAny(i,(function(t,i){t?(e.spriteFrameUuid=void 0,n._initTextureWithDictionary(e),x(t)):n.spriteFrame=i}))}else{var r=Su(this._plistFile,e.textureFileName||"");if(e.textureFileName)ZN.loadRemote(r,(function(t,i){t?(e.textureFileName=void 0,n._initTextureWithDictionary(e),x(t)):n.spriteFrame=i?rH.createWithImage(i):rH.createWithImage(wg.get("white-texture"))}));else if(e.textureImageData){var o=e.textureImageData;if(!(o&&o.length>0))return!1;var a=ZN.assets.get(r);if(!a){var s=w9.unzipBase64AsArray(o,1);if(!s)return P(6030,this._file.name),!1;var c=(t=s).length>8&&137===t[0]&&80===t[1]&&78===t[2]&&71===t[3]&&13===t[4]&&10===t[5]&&26===t[6]&&10===t[7]?b9.PNG:t.length>2&&(73===t[0]&&73===t[1]||77===t[0]&&77===t[1]||255===t[0]&&216===t[1])?b9.TIFF:b9.UNKNOWN;if(c!==b9.TIFF&&c!==b9.PNG)return P(6031,this._file.name),!1;var l=document.createElement("canvas");c===b9.PNG?new E6(s).render(l):(this._tiffReader||(this._tiffReader=new A6),this._tiffReader.parseTIFF(s,l)),a=new Km(l),ZN.assets.add(r,a)}a||P(6032,this._file.name),this.spriteFrame=a?rH.createWithImage(a):rH.createWithImage(wg.get("white-texture"))}}return!0},n._initWithDictionary=function(e){this.totalParticles=parseInt(e.maxParticles||0),this.life=parseFloat(e.particleLifespan||0),this.lifeVar=parseFloat(e.particleLifespanVariance||0);var t=e.emissionRate;this.emissionRate=t||Math.min(this.totalParticles/this.life,Number.MAX_VALUE),this.duration=parseFloat(e.duration||0),this._srcBlendFactor=parseInt(e.blendFuncSource||bi.SRC_ALPHA),this._dstBlendFactor=parseInt(e.blendFuncDestination||bi.ONE_MINUS_SRC_ALPHA);var n=this._startColor;n.r=255*parseFloat(e.startColorRed||0),n.g=255*parseFloat(e.startColorGreen||0),n.b=255*parseFloat(e.startColorBlue||0),n.a=255*parseFloat(e.startColorAlpha||0);var i=this._startColorVar;i.r=255*parseFloat(e.startColorVarianceRed||0),i.g=255*parseFloat(e.startColorVarianceGreen||0),i.b=255*parseFloat(e.startColorVarianceBlue||0),i.a=255*parseFloat(e.startColorVarianceAlpha||0);var r=this._endColor;r.r=255*parseFloat(e.finishColorRed||0),r.g=255*parseFloat(e.finishColorGreen||0),r.b=255*parseFloat(e.finishColorBlue||0),r.a=255*parseFloat(e.finishColorAlpha||0);var o=this._endColorVar;if(o.r=255*parseFloat(e.finishColorVarianceRed||0),o.g=255*parseFloat(e.finishColorVarianceGreen||0),o.b=255*parseFloat(e.finishColorVarianceBlue||0),o.a=255*parseFloat(e.finishColorVarianceAlpha||0),this.startSize=parseFloat(e.startParticleSize||0),this.startSizeVar=parseFloat(e.startParticleSizeVariance||0),this.endSize=parseFloat(e.finishParticleSize||0),this.endSizeVar=parseFloat(e.finishParticleSizeVariance||0),this.positionType=parseFloat(void 0!==e.positionType?e.positionType:u6.FREE),this.sourcePos.set(0,0),this.posVar.set(parseFloat(e.sourcePositionVariancex||0),parseFloat(e.sourcePositionVariancey||0)),this.angle=parseFloat(e.angle||0),this.angleVar=parseFloat(e.angleVariance||0),this.startSpin=parseFloat(e.rotationStart||0),this.startSpinVar=parseFloat(e.rotationStartVariance||0),this.endSpin=parseFloat(e.rotationEnd||0),this.endSpinVar=parseFloat(e.rotationEndVariance||0),this.emitterMode=parseInt(e.emitterType||l6.GRAVITY),this.emitterMode===l6.GRAVITY){this.gravity.set(parseFloat(e.gravityx||0),parseFloat(e.gravityy||0)),this.speed=parseFloat(e.speed||0),this.speedVar=parseFloat(e.speedVariance||0),this.radialAccel=parseFloat(e.radialAcceleration||0),this.radialAccelVar=parseFloat(e.radialAccelVariance||0),this.tangentialAccel=parseFloat(e.tangentialAcceleration||0),this.tangentialAccelVar=parseFloat(e.tangentialAccelVariance||0);var a=e.rotationIsDir||"";null!==a?(a=a.toString().toLowerCase(),this.rotationIsDir="true"===a||"1"===a):this.rotationIsDir=!1}else{if(this.emitterMode!==l6.RADIUS)return P(6009),!1;this.startRadius=parseFloat(e.maxRadius||0),this.startRadiusVar=parseFloat(e.maxRadiusVariance||0),this.endRadius=parseFloat(e.minRadius||0),this.endRadiusVar=parseFloat(e.minRadiusVariance||0),this.rotatePerS=parseFloat(e.rotatePerSecond||0),this.rotatePerSVar=parseFloat(e.rotatePerSecondVariance||0)}return this._initTextureWithDictionary(e),!0},n._syncAspect=function(){if(this._renderSpriteFrame){var e=this._renderSpriteFrame.rect;this.aspectRatio=e.width/e.height}},n._applySpriteFrame=function(){this._renderSpriteFrame=this._renderSpriteFrame||this._spriteFrame,this._renderSpriteFrame?this._renderSpriteFrame.texture&&(this._simulator.updateUVs(!0),this._syncAspect(),this._updateMaterial(),this._stopped=!1,this._renderFlag=this._canRender()):this.resetSystem()},n._getTexture=function(){return this._renderSpriteFrame&&this._renderSpriteFrame.texture},n._updateMaterial=function(){var e=this.getMaterialInstance(0);e&&e.recompileShaders({USE_LOCAL:this._positionType!==u6.FREE})},n._finishedSimulation=function(){this.resetSystem(),this.stopSystem(),this._renderFlag=this._canRender(),this.autoRemoveOnFinish&&this._stopped&&this.node.destroy()},n._canRender=function(){return e.prototype._canRender.call(this)&&!this._stopped&&null!==this._renderSpriteFrame},n._render=function(e){this._positionType===u6.RELATIVE?e.commitComp(this,this._simulator.renderData,this._renderSpriteFrame,this._assembler,this.node.parent):this.positionType===u6.GROUPED?e.commitComp(this,this._simulator.renderData,this._renderSpriteFrame,this._assembler,this.node):e.commitComp(this,this._simulator.renderData,this._renderSpriteFrame,this._assembler,null)},K(t,[{key:"custom",get:function(){return this._custom},set:function(e){this._custom!==e&&(this._custom=e,this._applyFile())}},{key:"file",get:function(){return this._file},set:function(e){this._file!==e&&(this._file=e,e?this._applyFile():this.custom=!0)}},{key:"spriteFrame",get:function(){return this._spriteFrame},set:function(e){this._renderSpriteFrame!==e&&(this._renderSpriteFrame=e,e&&!e._uuid||(this._spriteFrame=e),this._applySpriteFrame())}},{key:"particleCount",get:function(){return this._simulator.particles.length}},{key:"totalParticles",get:function(){return this._totalParticles},set:function(e){this._totalParticles!==e&&(this._totalParticles=e)}},{key:"startColor",get:function(){return this._startColor},set:function(e){this._startColor.r=e.r,this._startColor.g=e.g,this._startColor.b=e.b,this._startColor.a=e.a}},{key:"startColorVar",get:function(){return this._startColorVar},set:function(e){this._startColorVar.r=e.r,this._startColorVar.g=e.g,this._startColorVar.b=e.b,this._startColorVar.a=e.a}},{key:"color",get:function(){return this._color},set:function(){}},{key:"endColor",get:function(){return this._endColor},set:function(e){this._endColor.r=e.r,this._endColor.g=e.g,this._endColor.b=e.b,this._endColor.a=e.a}},{key:"endColorVar",get:function(){return this._endColorVar},set:function(e){this._endColorVar.r=e.r,this._endColorVar.g=e.g,this._endColorVar.b=e.b,this._endColorVar.a=e.a}},{key:"positionType",get:function(){return this._positionType},set:function(e){this._positionType=e,this._updateMaterial()}},{key:"preview",get:function(){return this._preview},set:function(e){e?this._startPreview():this._stopPreview(),this._preview=e}},{key:"stopped",get:function(){return this._stopped}},{key:"active",get:function(){return this._simulator.active}},{key:"assembler",get:function(){return this._assembler}}]),t}(dW),A9.EmitterMode=l6,A9.PositionType=u6,A9.DURATION_INFINITY=-1,A9.START_SIZE_EQUAL_TO_END_SIZE=-1,A9.START_RADIUS_EQUAL_TO_END_RADIUS=-1,se((N7=C9).prototype,"custom",[Rc,N6,L6],Object.getOwnPropertyDescriptor(N7.prototype,"custom"),N7.prototype),se(N7.prototype,"file",[F6,B6,z6],Object.getOwnPropertyDescriptor(N7.prototype,"file"),N7.prototype),se(N7.prototype,"spriteFrame",[k6,U6],Object.getOwnPropertyDescriptor(N7.prototype,"spriteFrame"),N7.prototype),se(N7.prototype,"totalParticles",[Rc,G6],Object.getOwnPropertyDescriptor(N7.prototype,"totalParticles"),N7.prototype),L7=se(N7.prototype,"duration",[gc,Rc,H6],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return-1}}),F7=se(N7.prototype,"emissionRate",[gc,Rc,V6],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 10}}),B7=se(N7.prototype,"life",[gc,Rc,j6],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),z7=se(N7.prototype,"lifeVar",[gc,Rc,W6],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),se(N7.prototype,"startColor",[Rc,q6],Object.getOwnPropertyDescriptor(N7.prototype,"startColor"),N7.prototype),se(N7.prototype,"startColorVar",[Rc,X6],Object.getOwnPropertyDescriptor(N7.prototype,"startColorVar"),N7.prototype),se(N7.prototype,"color",[Y6],Object.getOwnPropertyDescriptor(N7.prototype,"color"),N7.prototype),se(N7.prototype,"endColor",[Rc,K6],Object.getOwnPropertyDescriptor(N7.prototype,"endColor"),N7.prototype),se(N7.prototype,"endColorVar",[Rc,Q6],Object.getOwnPropertyDescriptor(N7.prototype,"endColorVar"),N7.prototype),k7=se(N7.prototype,"angle",[gc,Rc,Z6],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 90}}),U7=se(N7.prototype,"angleVar",[gc,Rc,J6],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 20}}),G7=se(N7.prototype,"startSize",[gc,Rc,$6],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 50}}),H7=se(N7.prototype,"startSizeVar",[gc,Rc,e7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),V7=se(N7.prototype,"endSize",[gc,Rc,t7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),j7=se(N7.prototype,"endSizeVar",[gc,Rc,n7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),W7=se(N7.prototype,"startSpin",[gc,Rc,i7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),q7=se(N7.prototype,"startSpinVar",[gc,Rc,r7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),X7=se(N7.prototype,"endSpin",[gc,Rc,o7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Y7=se(N7.prototype,"endSpinVar",[gc,Rc,a7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),K7=se(N7.prototype,"sourcePos",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Wn.ZERO.clone()}}),Q7=se(N7.prototype,"posVar",[gc,Rc,s7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Wn.ZERO.clone()}}),se(N7.prototype,"positionType",[c7,l7],Object.getOwnPropertyDescriptor(N7.prototype,"positionType"),N7.prototype),se(N7.prototype,"preview",[Rc,u7,h7],Object.getOwnPropertyDescriptor(N7.prototype,"preview"),N7.prototype),Z7=se(N7.prototype,"emitterMode",[gc,Rc,f7,_7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return l6.GRAVITY}}),J7=se(N7.prototype,"gravity",[gc,Rc,p7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Wn.ZERO.clone()}}),$7=se(N7.prototype,"speed",[gc,Rc,d7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 180}}),e9=se(N7.prototype,"speedVar",[gc,Rc,m7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 50}}),t9=se(N7.prototype,"tangentialAccel",[gc,Rc,g7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 80}}),n9=se(N7.prototype,"tangentialAccelVar",[gc,Rc,v7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),i9=se(N7.prototype,"radialAccel",[gc,Rc,y7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),r9=se(N7.prototype,"radialAccelVar",[gc,Rc,x7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),o9=se(N7.prototype,"rotationIsDir",[gc,Rc,S7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),a9=se(N7.prototype,"startRadius",[gc,Rc,T7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),s9=se(N7.prototype,"startRadiusVar",[gc,Rc,E7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),c9=se(N7.prototype,"endRadius",[gc,Rc,A7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),l9=se(N7.prototype,"endRadiusVar",[gc,Rc,C7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),u9=se(N7.prototype,"rotatePerS",[gc,Rc,b7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),h9=se(N7.prototype,"rotatePerSVar",[gc,Rc,w7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),f9=se(N7.prototype,"playOnLoad",[gc,Rc,R7,P7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),_9=se(N7.prototype,"autoRemoveOnFinish",[gc,Rc,I7,D7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),p9=se(N7.prototype,"_preview",[O7],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),d9=se(N7.prototype,"_custom",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),m9=se(N7.prototype,"_file",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),g9=se(N7.prototype,"_spriteFrame",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),v9=se(N7.prototype,"_totalParticles",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 150}}),y9=se(N7.prototype,"_startColor",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new An(255,255,255,255)}}),x9=se(N7.prototype,"_startColorVar",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new An(0,0,0,0)}}),S9=se(N7.prototype,"_endColor",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new An(255,255,255,0)}}),T9=se(N7.prototype,"_endColorVar",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new An(0,0,0,0)}}),E9=se(N7.prototype,"_positionType",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return u6.FREE}}),M7=N7))||M7)||M7)||M7)||M7)),j9=function(){function e(e,t){this.point=new Wn,this.dir=new Wn,this.distance=0,this.time=0,e&&this.point.set(e),t&&this.dir.set(t)}var t=e.prototype;return t.setPoint=function(e,t){this.point.x=e,this.point.y=t},t.setDir=function(e,t){this.dir.x=e,this.dir.y=t},e}(),W9=e("MotionStreak",(P9=hc("cc.MotionStreak"),I9=Ec(),D9=wc(),O9=Wc(vg),P9(M9=Tc(M9=Ac(M9=I9(M9=D9((H9=G9=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r1){var c=s[0],l=c.point.x-o,u=c.point.y-a;l*l+u*u=0;E--){var A=s[E],C=A.point,b=A.dir;if(A.time-=t,A.time<0)s.splice(E,1);else{var w=A.time/S,R=s[E-1];if(!T){if(!R){s.splice(E,1);continue}C.x=R.point.x-b.x*w,C.y=R.point.y-b.y*w}T=!0,Y9(q9,b);var P=(w*v<<24>>>0)+(g<<16)+(m<<8)+d,I=f;x[I].x=C.x+q9.x*i,x[I].y=C.y+q9.y*i,x[I].u=1,x[I].v=w,x[I].color._val=P,x[I+=1].x=C.x-q9.x*i,x[I].y=C.y-q9.y*i,x[I].u=0,x[I].v=w,x[I].color._val=P,f+=2}}h=f<=2?0:3*(f-2),_.resize(f,h)}},updateRenderDataCache:function(e,t){t.passDirty&&t.updatePass(e),t.nodeDirty&&t.updateNode(e),t.textureDirty&&e.texture&&(t.updateTexture(e.texture),t.material=e.getRenderMaterial(0)),t.hashDirty&&t.updateHash()},updateRenderData:function(){},updateColor:function(){},fillBuffers:function(e){for(var t=e.renderData,n=t.chunk,i=t.data,r=t.vertexCount,o=t.indexCount,a=n.vb,s=0,c=0;c0}function see(e,t,n){return pee(e,t,n)>=0}function cee(e,t,n){return pee(e,t,n)<=0}function lee(e,t){var n=t.x-e.x,i=t.y-e.y;return n*n+i*i}function uee(e){hee(e)||e.reverse()}function hee(e){return e.length<3||function(e){var t,n=0;for(t=0;t0}function fee(e,t,n,i){var r,o=new Wn,a=t.y-e.y,s=e.x-t.x,c=a*e.x+s*e.y,l=i.y-n.y,u=n.x-i.x,h=l*n.x+u*n.y,f=a*u-l*s;return r=f,0,Math.abs(r-0)<=1e-6||(o.x=(u*c-s*h)/f,o.y=(a*h-l*c)/f),o}function _ee(e,t,n,i,r){if(e==n||e==i||t==n||t==i)return!1;var o=e.x,a=e.y,s=t.x,c=t.y,l=n.x,u=n.y,h=i.x,f=i.y;if(Math.max(o,s)0&&_<1&&p>0&&p<1&&(r.x=o+_*(s-o),r.y=a+_*(c-a),!0))}function pee(e,t,n){return e.x*(t.y-n.y)+t.x*(n.y-e.y)+n.x*(e.y-t.y)}V9.Assembler=eee;var dee,mee,gee,vee,yee,xee=Object.freeze({__proto__:null,ConvexPartition:function e(t){uee(t);for(var n,i,r,o,a,s,c=[],l=new Wn,u=new Wn,h=0,f=0,_=0;_m&&(g=v,m=y)}a=nee(_,g,t),s=nee(g,_,t)}return(c=c.concat(e(a))).concat(e(s))}c.push(t);for(var x=c.length-1;x>=0;x--)0==c[x].length&&c.splice(x,0);return c},ForceCounterClockWise:uee,IsCounterClockWise:hee});!function(e){e[e.Static=0]="Static",e[e.Kinematic=1]="Kinematic",e[e.Dynamic=2]="Dynamic",e[e.Animated=3]="Animated"}(dee||(dee=e("ERigidBody2DType",{}))),it(dee),function(e){e[e.None=0]="None",e[e.BOX=1]="BOX",e[e.CIRCLE=2]="CIRCLE",e[e.POLYGON=3]="POLYGON"}(mee||(mee=e("ECollider2DType",{}))),it(mee),function(e){e[e.None=0]="None",e[e.DISTANCE=1]="DISTANCE",e[e.SPRING=2]="SPRING",e[e.WHEEL=3]="WHEEL",e[e.MOUSE=4]="MOUSE",e[e.FIXED=5]="FIXED",e[e.SLIDER=6]="SLIDER",e[e.RELATIVE=7]="RELATIVE",e[e.HINGE=8]="HINGE"}(gee||(gee=e("EJoint2DType",{}))),it(gee),function(e){e[e.DEFAULT=1]="DEFAULT"}(vee||(vee=e("PhysicsGroup",{}))),it(vee),function(e){e[e.Closest=0]="Closest",e[e.Any=1]="Any",e[e.AllClosest=2]="AllClosest",e[e.All=3]="All"}(yee||(yee=e("ERaycast2DType",{})));var See,Tee=e("Contact2DType",{None:"none-contact",BEGIN_CONTACT:"begin-contact",END_CONTACT:"end-contact",PRE_SOLVE:"pre-solve",POST_SOLVE:"post-solve"});!function(e){e[e.None=0]="None",e[e.Shape=1]="Shape",e[e.Joint=2]="Joint",e[e.Aabb=4]="Aabb",e[e.Pair=8]="Pair",e[e.CenterOfMass=16]="CenterOfMass",e[e.Particle=32]="Particle",e[e.Controller=64]="Controller",e[e.All=63]="All"}(See||(See=e("EPhysics2DDrawFlags",{})));var Eee=e("PHYSICS_2D_PTM_RATIO",32),Aee=function(){return 0},Cee={impl:null,rigidBody:null,isAwake:!1,isSleeping:!1,initialize:Aee,setType:Aee,setLinearDamping:Aee,setAngularDamping:Aee,setGravityScale:Aee,setFixedRotation:Aee,setAllowSleep:Aee,isActive:Aee,setActive:Aee,wakeUp:Aee,sleep:Aee,getMass:Aee,getInertia:Aee,getLinearVelocity:Aee,setLinearVelocity:Aee,getLinearVelocityFromWorldPoint:Aee,getAngularVelocity:Aee,setAngularVelocity:Aee,getLocalVector:Aee,getWorldVector:Aee,getLocalPoint:Aee,getWorldPoint:Aee,getLocalCenter:Aee,getWorldCenter:Aee,applyForce:Aee,applyForceToCenter:Aee,applyTorque:Aee,applyLinearImpulse:Aee,applyLinearImpulseToCenter:Aee,applyAngularImpulse:Aee,onEnable:Aee,onDisable:Aee,onDestroy:Aee},bee={INITED:!1};var wee,Ree,Pee,Iee,Dee,Oee,Mee={INITED:!1},Nee={impl:null,initialize:Aee,setDampingRatio:Aee,setFrequency:Aee,setMaxForce:Aee,setTarget:Aee,setDistance:Aee,setAngularOffset:Aee,setCorrectionFactor:Aee,setLinearOffset:Aee,setMaxLength:Aee,setMaxTorque:Aee,setLowerLimit:Aee,setUpperLimit:Aee,setMaxMotorForce:Aee,setMaxMotorTorque:Aee,setMotorSpeed:Aee,enableLimit:Aee,enableMotor:Aee,setLowerAngle:Aee,setUpperAngle:Aee};!function(e){e[e.DYNAMIC=1]="DYNAMIC",e[e.STATIC=2]="STATIC",e[e.KINEMATIC=4]="KINEMATIC"}(wee||(wee={})),it(wee),function(e){e[e.X_AXIS=0]="X_AXIS",e[e.Y_AXIS=1]="Y_AXIS",e[e.Z_AXIS=2]="Z_AXIS"}(Ree||(Ree={})),it(Ree),function(e){e[e.VERTEX=1]="VERTEX",e[e.LINE=2]="LINE",e[e.TRIANGLE=3]="TRIANGLE",e[e.TETRAHEDRON=4]="TETRAHEDRON"}(Pee||(Pee={})),it(Pee),function(e){e[e.BOX=0]="BOX",e[e.SPHERE=1]="SPHERE",e[e.CAPSULE=2]="CAPSULE",e[e.CYLINDER=3]="CYLINDER",e[e.CONE=4]="CONE",e[e.MESH=5]="MESH",e[e.PLANE=6]="PLANE",e[e.SIMPLEX=7]="SIMPLEX",e[e.TERRAIN=8]="TERRAIN"}(Iee||(Iee={})),it(Iee),function(e){e[e.POINT_TO_POINT=0]="POINT_TO_POINT",e[e.HINGE=1]="HINGE",e[e.CONE_TWIST=2]="CONE_TWIST"}(Dee||(Dee={})),it(Dee),function(e){e[e.DEFAULT=1]="DEFAULT"}(Oee||(Oee={})),it(Oee);var Lee,Fee,Bee,zee,kee,Uee,Gee,Hee,Vee,jee,Wee,qee,Xee,Yee,Kee,Qee,Zee,Jee,$ee,ete=function(e){if(1===e){for(var t=this,n=function(e){var n="_"+(1<t;)this.physicsWorld.step(t,n,i),this._accumulator-=t;for(var o=this._delayEvents,a=0,s=o.length;ac&&(c=f),fl&&(l=_),_=0){t.splice(n,1);for(var i=this._contacts,r=i.length-1;r>=0;r--){var o=i[r];o.shape1!==e&&o.shape2!==e||(o.touching&&this._emitCollide(o,Tee.END_CONTACT),i.splice(r,1))}}},t.updateShapeGroup=function(e){this.removeShape(e),this.addShape(e)},t.step=function(){for(var e=this._shapes,t=0,n=e.length;t0){e.moveTo(o[0].x,o[0].y);for(var a=1;athis._opts.over},t._average=function(e,t){if(void 0===t&&(t=0),this._opts.average){this._accumValue+=e,++this._accumSamples;var n=t;n-this._accumStart>=this._opts.average&&(this._averageValue=this._accumValue/this._accumSamples,this._accumValue=0,this._accumStart=n,this._accumSamples=0)}},K(e,[{key:"value",get:function(){return this._value},set:function(e){this._value=e}}]),e}(),lie=hc("cc.PerfCounter")(sie=function(e){function t(t,n,i){var r;return(r=e.call(this,t,n,i)||this)._time=void 0,r._time=i,r}Z(t,e);var n=t.prototype;return n.start=function(e){void 0===e&&(e=0),this._time=e},n.end=function(e){void 0===e&&(e=0),this._value=e-this._time,this._average(this._value)},n.tick=function(){this.end(),this.start()},n.frame=function(e){var t=e,n=t-this._time;this._total++,n>(this._opts.average||1e3)&&(this._value=1e3*this._total/n,this._total=0,this._time=t,this._average(this._value))},t}(cie))||sie,uie="0123456789. ",hie=500,fie={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,".":10},_ie={fps:{desc:"Framerate (FPS)",below:30,average:hie,isInteger:!0},draws:{desc:"Draw call",isInteger:!0},frame:{desc:"Frame time (ms)",min:0,max:50,average:hie},instances:{desc:"Instance Count",isInteger:!0},tricount:{desc:"Triangle",isInteger:!0},logic:{desc:"Game Logic (ms)",min:0,max:50,average:hie,color:"#080"},physics:{desc:"Physics (ms)",min:0,max:50,average:hie},render:{desc:"Renderer (ms)",min:0,max:50,average:hie,color:"#f90"},textureMemory:{desc:"GFX Texture Mem(M)"},bufferMemory:{desc:"GFX Buffer Mem(M)"}},pie=e("Profiler",function(){function e(){this._stats=null,this.id="__Profiler__",this._showFPS=!1,this._rootNode=null,this._device=null,this._swapchain=null,this._pipeline=null,this._meshRenderer=null,this._canvas=null,this._ctx=null,this._texture=null,this._region=new ir,this._canvasArr=[],this._regionArr=[this._region],this.digitsData=null,this.offsetData=null,this.pass=null,this._canvasDone=!1,this._statsDone=!1,this._inited=!1,this._lineHeight=256/(Object.keys(_ie).length+1),this._wordHeight=0,this._eachNumWidth=0,this._totalLines=0,this.lastTime=0,this._canvas=document.createElement("canvas"),this._ctx=this._canvas.getContext("2d"),this._canvasArr.push(this._canvas)}var t=e.prototype;return t.reset=function(){this._stats=null,this._showFPS=!1,this._rootNode=null,this._device=null,this._swapchain=null,this._pipeline=null,this._meshRenderer&&this._meshRenderer.destroy(),this._meshRenderer=null,this.digitsData=null,this.offsetData=null,this.pass=null,this._canvasDone=!1,this._statsDone=!1,this._inited=!1,this._lineHeight=256/(Object.keys(_ie).length+1),this._wordHeight=0,this._eachNumWidth=0,this._totalLines=0,this.lastTime=0},t.isShowingStats=function(){return this._showFPS},t.hideStats=function(){this._showFPS&&(this._rootNode&&(this._rootNode.active=!1),c.director.off(c.Director.EVENT_BEFORE_UPDATE,this.beforeUpdate,this),c.director.off(c.Director.EVENT_AFTER_UPDATE,this.afterUpdate,this),c.director.off(c.Director.EVENT_BEFORE_PHYSICS,this.beforePhysics,this),c.director.off(c.Director.EVENT_AFTER_PHYSICS,this.afterPhysics,this),c.director.off(c.Director.EVENT_BEFORE_DRAW,this.beforeDraw,this),c.director.off(c.Director.EVENT_AFTER_DRAW,this.afterDraw,this),this._showFPS=!1,this._pipeline.profiler=null,c.game.config.showFPS=!1)},t.showStats=function(){if(!this._showFPS){if(!this._device){var e=c.director.root;this._device=e.device,this._swapchain=e.mainWindow.swapchain,this._pipeline=e.pipeline}this.generateCanvas(),this.generateStats(),c.game.once(c.Game.EVENT_ENGINE_INITED,this.generateNode,this),this._rootNode&&(this._rootNode.active=!0),c.director.on(c.Director.EVENT_BEFORE_UPDATE,this.beforeUpdate,this),c.director.on(c.Director.EVENT_AFTER_UPDATE,this.afterUpdate,this),c.director.on(c.Director.EVENT_BEFORE_PHYSICS,this.beforePhysics,this),c.director.on(c.Director.EVENT_AFTER_PHYSICS,this.afterPhysics,this),c.director.on(c.Director.EVENT_BEFORE_DRAW,this.beforeDraw,this),c.director.on(c.Director.EVENT_AFTER_DRAW,this.afterDraw,this),this._showFPS=!0,this._canvasDone=!0,this._statsDone=!0,c.game.config.showFPS=!0}},t.generateCanvas=function(){if(!this._canvasDone){this._ctx&&this._canvas&&(this._canvas.width=256,this._canvas.height=256,this._canvas.style.width=""+this._canvas.width,this._canvas.style.height=""+this._canvas.height,this._ctx.font="23px Arial",this._ctx.textBaseline="top",this._ctx.fillStyle="#fff",this._texture=this._device.createTexture(new pr(gi.TEX2D,vi.SAMPLED|vi.TRANSFER_DST,ui.RGBA8,256,256)),this._region.texExtent.width=256,this._region.texExtent.height=256)}},t.generateStats=function(){if(!this._statsDone&&this._ctx&&this._canvas){this._stats=null;var e=performance.now();this._ctx.textAlign="left";var t=0;for(var n in _ie){var i=_ie[n];this._ctx.fillText(i.desc,0,t*this._lineHeight),i.counter=new lie(n,i,e),t++}this._totalLines=t,this._wordHeight=this._totalLines*this._lineHeight/this._canvas.height;for(var r=0;r=0;s--){var c=8*n+s,l=a[a.length-(8-s)],u=fie[l];void 0===u&&(u=11),i[c]=u}n++}}}},e}()),die=e("profiler",new pie);c.profiler=die;var mie,gie,vie=(mie=function(e,t){return(mie=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}mie(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});!function(e){var t,n,i,r=function(){function e(e,t,n){if(null==e)throw new Error("name cannot be null.");if(null==t)throw new Error("timelines cannot be null.");this.name=e,this.timelines=t,this.timelineIds=[];for(var i=0;i0&&(t%=this.duration));for(var c=this.timelines,l=0,u=c.length;l>>1;;){if(e[(o+1)*n]<=t?i=o+1:r=o,i==r)return(i+1)*n;o=i+r>>>1}},e.linearSearch=function(e,t,n){for(var i=0,r=e.length-n;i<=r;i+=n)if(e[i]>t)return i;return-1},e}();e.Animation=r,function(e){e[e.setup=0]="setup",e[e.first=1]="first",e[e.replace=2]="replace",e[e.add=3]="add"}(t=e.MixBlend||(e.MixBlend={})),function(e){e[e.mixIn=0]="mixIn",e[e.mixOut=1]="mixOut"}(n=e.MixDirection||(e.MixDirection={})),function(e){e[e.rotate=0]="rotate",e[e.translate=1]="translate",e[e.scale=2]="scale",e[e.shear=3]="shear",e[e.attachment=4]="attachment",e[e.color=5]="color",e[e.deform=6]="deform",e[e.event=7]="event",e[e.drawOrder=8]="drawOrder",e[e.ikConstraint=9]="ikConstraint",e[e.transformConstraint=10]="transformConstraint",e[e.pathConstraintPosition=11]="pathConstraintPosition",e[e.pathConstraintSpacing=12]="pathConstraintSpacing",e[e.pathConstraintMix=13]="pathConstraintMix",e[e.twoColor=14]="twoColor"}(i=e.TimelineType||(e.TimelineType={}));var o=function(){function t(n){if(n<=0)throw new Error("frameCount must be > 0: "+n);this.curves=e.Utils.newFloatArray((n-1)*t.BEZIER_SIZE)}return t.prototype.getFrameCount=function(){return this.curves.length/t.BEZIER_SIZE+1},t.prototype.setLinear=function(e){this.curves[e*t.BEZIER_SIZE]=t.LINEAR},t.prototype.setStepped=function(e){this.curves[e*t.BEZIER_SIZE]=t.STEPPED},t.prototype.getCurveType=function(e){var n=e*t.BEZIER_SIZE;if(n==this.curves.length)return t.LINEAR;var i=this.curves[n];return i==t.LINEAR?t.LINEAR:i==t.STEPPED?t.STEPPED:t.BEZIER},t.prototype.setCurve=function(e,n,i,r,o){var a=.03*(2*-n+r),s=.03*(2*-i+o),c=.006*(3*(n-r)+1),l=.006*(3*(i-o)+1),u=2*a+c,h=2*s+l,f=.3*n+a+.16666667*c,_=.3*i+s+.16666667*l,p=e*t.BEZIER_SIZE,d=this.curves;d[p++]=t.BEZIER;for(var m=f,g=_,v=p+t.BEZIER_SIZE-1;p=i){var u=void 0,h=void 0;return o==c?(u=0,h=0):(u=r[o-2],h=r[o-1]),h+(r[o+1]-h)*(i-u)/(s-u)}var f=r[o-1];return f+(1-f)*(i-s)/(1-s)},t.LINEAR=0,t.STEPPED=1,t.BEZIER=2,t.BEZIER_SIZE=19,t}();e.CurveTimeline=o;var a=function(n){function o(t){var i=n.call(this,t)||this;return i.frames=e.Utils.newFloatArray(t<<1),i}return vie(o,n),o.prototype.getPropertyId=function(){return(i.rotate<<24)+this.boneIndex},o.prototype.setFrame=function(e,t,n){e<<=1,this.frames[e]=t,this.frames[e+o.ROTATION]=n},o.prototype.apply=function(e,n,i,a,s,c){var l=this.frames,u=e.bones[this.boneIndex];if(u.active)if(i=l[l.length-o.ENTRIES]){var f=l[l.length+o.PREV_ROTATION];switch(c){case t.setup:u.rotation=u.data.rotation+f*s;break;case t.first:case t.replace:f+=u.data.rotation-u.rotation,f-=360*(16384-(16384.499999999996-f/360|0));case t.add:u.rotation+=f*s}}else{var _=r.binarySearch(l,i,o.ENTRIES),p=l[_+o.PREV_ROTATION],d=l[_],m=this.getCurvePercent((_>>1)-1,1-(i-d)/(l[_+o.PREV_TIME]-d)),g=l[_+o.ROTATION]-p;switch(g=p+(g-360*(16384-(16384.499999999996-g/360|0)))*m,c){case t.setup:u.rotation=u.data.rotation+(g-360*(16384-(16384.499999999996-g/360|0)))*s;break;case t.first:case t.replace:g+=u.data.rotation-u.rotation;case t.add:u.rotation+=(g-360*(16384-(16384.499999999996-g/360|0)))*s}}},o.ENTRIES=2,o.PREV_TIME=-2,o.PREV_ROTATION=-1,o.ROTATION=1,o}(o);e.RotateTimeline=a;var s=function(n){function o(t){var i=n.call(this,t)||this;return i.frames=e.Utils.newFloatArray(t*o.ENTRIES),i}return vie(o,n),o.prototype.getPropertyId=function(){return(i.translate<<24)+this.boneIndex},o.prototype.setFrame=function(e,t,n,i){e*=o.ENTRIES,this.frames[e]=t,this.frames[e+o.X]=n,this.frames[e+o.Y]=i},o.prototype.apply=function(e,n,i,a,s,c){var l=this.frames,u=e.bones[this.boneIndex];if(u.active)if(i=l[l.length-o.ENTRIES])h=l[l.length+o.PREV_X],f=l[l.length+o.PREV_Y];else{var _=r.binarySearch(l,i,o.ENTRIES);h=l[_+o.PREV_X],f=l[_+o.PREV_Y];var p=l[_],d=this.getCurvePercent(_/o.ENTRIES-1,1-(i-p)/(l[_+o.PREV_TIME]-p));h+=(l[_+o.X]-h)*d,f+=(l[_+o.Y]-f)*d}switch(c){case t.setup:u.x=u.data.x+h*s,u.y=u.data.y+f*s;break;case t.first:case t.replace:u.x+=(u.data.x+h-u.x)*s,u.y+=(u.data.y+f-u.y)*s;break;case t.add:u.x+=h*s,u.y+=f*s}}},o.ENTRIES=3,o.PREV_TIME=-3,o.PREV_X=-2,o.PREV_Y=-1,o.X=1,o.Y=2,o}(o);e.TranslateTimeline=s;var c=function(o){function a(e){return o.call(this,e)||this}return vie(a,o),a.prototype.getPropertyId=function(){return(i.scale<<24)+this.boneIndex},a.prototype.apply=function(i,o,s,c,l,u,h){var f=this.frames,_=i.bones[this.boneIndex];if(_.active)if(s=f[f.length-a.ENTRIES])p=f[f.length+a.PREV_X]*_.data.scaleX,d=f[f.length+a.PREV_Y]*_.data.scaleY;else{var m=r.binarySearch(f,s,a.ENTRIES);p=f[m+a.PREV_X],d=f[m+a.PREV_Y];var g=f[m],v=this.getCurvePercent(m/a.ENTRIES-1,1-(s-g)/(f[m+a.PREV_TIME]-g));p=(p+(f[m+a.X]-p)*v)*_.data.scaleX,d=(d+(f[m+a.Y]-d)*v)*_.data.scaleY}if(1==l)u==t.add?(_.scaleX+=p-_.data.scaleX,_.scaleY+=d-_.data.scaleY):(_.scaleX=p,_.scaleY=d);else{var y=0,x=0;if(h==n.mixOut)switch(u){case t.setup:y=_.data.scaleX,x=_.data.scaleY,_.scaleX=y+(Math.abs(p)*e.MathUtils.signum(y)-y)*l,_.scaleY=x+(Math.abs(d)*e.MathUtils.signum(x)-x)*l;break;case t.first:case t.replace:y=_.scaleX,x=_.scaleY,_.scaleX=y+(Math.abs(p)*e.MathUtils.signum(y)-y)*l,_.scaleY=x+(Math.abs(d)*e.MathUtils.signum(x)-x)*l;break;case t.add:y=_.scaleX,x=_.scaleY,_.scaleX=y+(Math.abs(p)*e.MathUtils.signum(y)-_.data.scaleX)*l,_.scaleY=x+(Math.abs(d)*e.MathUtils.signum(x)-_.data.scaleY)*l}else switch(u){case t.setup:y=Math.abs(_.data.scaleX)*e.MathUtils.signum(p),x=Math.abs(_.data.scaleY)*e.MathUtils.signum(d),_.scaleX=y+(p-y)*l,_.scaleY=x+(d-x)*l;break;case t.first:case t.replace:y=Math.abs(_.scaleX)*e.MathUtils.signum(p),x=Math.abs(_.scaleY)*e.MathUtils.signum(d),_.scaleX=y+(p-y)*l,_.scaleY=x+(d-x)*l;break;case t.add:y=e.MathUtils.signum(p),x=e.MathUtils.signum(d),_.scaleX=Math.abs(_.scaleX)*y+(p-Math.abs(_.data.scaleX)*y)*l,_.scaleY=Math.abs(_.scaleY)*x+(d-Math.abs(_.data.scaleY)*x)*l}}}},a}(s);e.ScaleTimeline=c;var l=function(e){function n(t){return e.call(this,t)||this}return vie(n,e),n.prototype.getPropertyId=function(){return(i.shear<<24)+this.boneIndex},n.prototype.apply=function(e,i,o,a,s,c){var l=this.frames,u=e.bones[this.boneIndex];if(u.active)if(o=l[l.length-n.ENTRIES])h=l[l.length+n.PREV_X],f=l[l.length+n.PREV_Y];else{var _=r.binarySearch(l,o,n.ENTRIES);h=l[_+n.PREV_X],f=l[_+n.PREV_Y];var p=l[_],d=this.getCurvePercent(_/n.ENTRIES-1,1-(o-p)/(l[_+n.PREV_TIME]-p));h+=(l[_+n.X]-h)*d,f+=(l[_+n.Y]-f)*d}switch(c){case t.setup:u.shearX=u.data.shearX+h*s,u.shearY=u.data.shearY+f*s;break;case t.first:case t.replace:u.shearX+=(u.data.shearX+h-u.shearX)*s,u.shearY+=(u.data.shearY+f-u.shearY)*s;break;case t.add:u.shearX+=h*s,u.shearY+=f*s}}},n}(s);e.ShearTimeline=l;var u=function(n){function o(t){var i=n.call(this,t)||this;return i.frames=e.Utils.newFloatArray(t*o.ENTRIES),i}return vie(o,n),o.prototype.getPropertyId=function(){return(i.color<<24)+this.slotIndex},o.prototype.setFrame=function(e,t,n,i,r,a){e*=o.ENTRIES,this.frames[e]=t,this.frames[e+o.R]=n,this.frames[e+o.G]=i,this.frames[e+o.B]=r,this.frames[e+o.A]=a},o.prototype.apply=function(e,n,i,a,s,c){var l=e.slots[this.slotIndex];if(l.bone.active){var u=this.frames;if(i=u[u.length-o.ENTRIES]){var g=u.length;_=u[g+o.PREV_R],p=u[g+o.PREV_G],d=u[g+o.PREV_B],m=u[g+o.PREV_A]}else{var v=r.binarySearch(u,i,o.ENTRIES);_=u[v+o.PREV_R],p=u[v+o.PREV_G],d=u[v+o.PREV_B],m=u[v+o.PREV_A];var y=u[v],x=this.getCurvePercent(v/o.ENTRIES-1,1-(i-y)/(u[v+o.PREV_TIME]-y));_+=(u[v+o.R]-_)*x,p+=(u[v+o.G]-p)*x,d+=(u[v+o.B]-d)*x,m+=(u[v+o.A]-m)*x}1==s?l.color.set(_,p,d,m):(h=l.color,c==t.setup&&h.setFromColor(l.data.color),h.add((_-h.r)*s,(p-h.g)*s,(d-h.b)*s,(m-h.a)*s))}}},o.ENTRIES=5,o.PREV_TIME=-5,o.PREV_R=-4,o.PREV_G=-3,o.PREV_B=-2,o.PREV_A=-1,o.R=1,o.G=2,o.B=3,o.A=4,o}(o);e.ColorTimeline=u;var h=function(n){function o(t){var i=n.call(this,t)||this;return i.frames=e.Utils.newFloatArray(t*o.ENTRIES),i}return vie(o,n),o.prototype.getPropertyId=function(){return(i.twoColor<<24)+this.slotIndex},o.prototype.setFrame=function(e,t,n,i,r,a,s,c,l){e*=o.ENTRIES,this.frames[e]=t,this.frames[e+o.R]=n,this.frames[e+o.G]=i,this.frames[e+o.B]=r,this.frames[e+o.A]=a,this.frames[e+o.R2]=s,this.frames[e+o.G2]=c,this.frames[e+o.B2]=l},o.prototype.apply=function(e,n,i,a,s,c){var l=e.slots[this.slotIndex];if(l.bone.active){var u=this.frames;if(i=u[u.length-o.ENTRIES]){var T=u.length;d=u[T+o.PREV_R],m=u[T+o.PREV_G],g=u[T+o.PREV_B],v=u[T+o.PREV_A],y=u[T+o.PREV_R2],x=u[T+o.PREV_G2],S=u[T+o.PREV_B2]}else{var E=r.binarySearch(u,i,o.ENTRIES);d=u[E+o.PREV_R],m=u[E+o.PREV_G],g=u[E+o.PREV_B],v=u[E+o.PREV_A],y=u[E+o.PREV_R2],x=u[E+o.PREV_G2],S=u[E+o.PREV_B2];var A=u[E],C=this.getCurvePercent(E/o.ENTRIES-1,1-(i-A)/(u[E+o.PREV_TIME]-A));d+=(u[E+o.R]-d)*C,m+=(u[E+o.G]-m)*C,g+=(u[E+o.B]-g)*C,v+=(u[E+o.A]-v)*C,y+=(u[E+o.R2]-y)*C,x+=(u[E+o.G2]-x)*C,S+=(u[E+o.B2]-S)*C}1==s?(l.color.set(d,m,g,v),l.darkColor.set(y,x,S,1)):(h=l.color,f=l.darkColor,c==t.setup&&(h.setFromColor(l.data.color),f.setFromColor(l.data.darkColor)),h.add((d-h.r)*s,(m-h.g)*s,(g-h.b)*s,(v-h.a)*s),f.add((y-f.r)*s,(x-f.g)*s,(S-f.b)*s,0))}}},o.ENTRIES=8,o.PREV_TIME=-8,o.PREV_R=-7,o.PREV_G=-6,o.PREV_B=-5,o.PREV_A=-4,o.PREV_R2=-3,o.PREV_G2=-2,o.PREV_B2=-1,o.R=1,o.G=2,o.B=3,o.A=4,o.R2=5,o.G2=6,o.B2=7,o}(o);e.TwoColorTimeline=h;var f=function(){function o(t){this.frames=e.Utils.newFloatArray(t),this.attachmentNames=new Array(t)}return o.prototype.getPropertyId=function(){return(i.attachment<<24)+this.slotIndex},o.prototype.getFrameCount=function(){return this.frames.length},o.prototype.setFrame=function(e,t,n){this.frames[e]=t,this.attachmentNames[e]=n},o.prototype.apply=function(e,i,o,a,s,c,l){var u=e.slots[this.slotIndex];if(u.bone.active)if(l!=n.mixOut||c!=t.setup){var h=this.frames;if(o=h[h.length-1]?h.length-1:r.binarySearch(h,o,1)-1;var p=this.attachmentNames[_];e.slots[this.slotIndex].setAttachment(null==p?null:e.getAttachment(this.slotIndex,p))}}else{var d=u.data.attachmentName;u.setAttachment(null==d?null:e.getAttachment(this.slotIndex,d))}},o}();e.AttachmentTimeline=f;var _=null,p=function(n){function o(t){var i=n.call(this,t)||this;return i.frames=e.Utils.newFloatArray(t),i.frameVertices=new Array(t),null==_&&(_=e.Utils.newFloatArray(64)),i}return vie(o,n),o.prototype.getPropertyId=function(){return(i.deform<<27)+ +this.attachment.id+this.slotIndex},o.prototype.setFrame=function(e,t,n){this.frames[e]=t,this.frameVertices[e]=n},o.prototype.apply=function(n,i,o,a,s,c){var l=n.slots[this.slotIndex];if(l.bone.active){var u=l.getAttachment();if(u instanceof e.VertexAttachment&&u.deformAttachment==this.attachment){var h=l.deform;0==h.length&&(c=t.setup);var f=this.frameVertices,_=f[0].length,p=this.frames;if(o=p[p.length-1]){var x=f[p.length-1];if(1==s)if(c==t.add)if(null==(d=u).bones){g=d.vertices;for(var S=0;S<_;S++)y[S]+=x[S]-g[S]}else for(var T=0;T<_;T++)y[T]+=x[T];else e.Utils.arrayCopy(x,0,y,0,_);else switch(c){case t.setup:var E=u;if(null==E.bones){g=E.vertices;for(var A=0;A<_;A++){var C=g[A];y[A]=C+(x[A]-C)*s}}else for(var b=0;b<_;b++)y[b]=x[b]*s;break;case t.first:case t.replace:for(var w=0;w<_;w++)y[w]+=(x[w]-y[w])*s;case t.add:if(null==(d=u).bones){g=d.vertices;for(var R=0;R<_;R++)y[R]+=(x[R]-g[R])*s}else for(var P=0;P<_;P++)y[P]+=x[P]*s}}else{var I=r.binarySearch(p,o),D=f[I-1],O=f[I],M=p[I],N=this.getCurvePercent(I-1,1-(o-M)/(p[I-1]-M));if(1==s)if(c==t.add)if(null==(d=u).bones){g=d.vertices;for(var L=0;L<_;L++){var F=D[L];y[L]+=F+(O[L]-F)*N-g[L]}}else for(var B=0;B<_;B++)F=D[B],y[B]+=F+(O[B]-F)*N;else for(var z=0;z<_;z++)F=D[z],y[z]=F+(O[z]-F)*N;else switch(c){case t.setup:var k=u;if(null==k.bones){g=k.vertices;for(var U=0;U<_;U++)F=D[U],C=g[U],y[U]=C+(F+(O[U]-F)*N-C)*s}else for(var G=0;G<_;G++)F=D[G],y[G]=(F+(O[G]-F)*N)*s;break;case t.first:case t.replace:for(var H=0;H<_;H++)F=D[H],y[H]+=(F+(O[H]-F)*N-y[H])*s;break;case t.add:if(null==(d=u).bones){g=d.vertices;for(var V=0;V<_;V++)F=D[V],y[V]+=(F+(O[V]-F)*N-g[V])*s}else for(var j=0;j<_;j++)F=D[j],y[j]+=(F+(O[j]-F)*N)*s}}}}}},o}(o);e.DeformTimeline=p;var d=function(){function t(t){this.frames=e.Utils.newFloatArray(t),this.events=new Array(t)}return t.prototype.getPropertyId=function(){return i.event<<24},t.prototype.getFrameCount=function(){return this.frames.length},t.prototype.setFrame=function(e,t){this.frames[e]=t.time,this.events[e]=t},t.prototype.apply=function(e,t,n,i,o,a,s){if(null!=i){var c=this.frames,l=this.frames.length;if(t>n)this.apply(e,t,Number.MAX_VALUE,i,o,a,s),t=-1;else if(t>=c[l-1])return;if(!(n0&&c[u-1]==h;)u--;for(;u=c[u];u++)i.push(this.events[u])}}},t}();e.EventTimeline=d;var m=function(){function o(t){this.frames=e.Utils.newFloatArray(t),this.drawOrders=new Array(t)}return o.prototype.getPropertyId=function(){return i.drawOrder<<24},o.prototype.getFrameCount=function(){return this.frames.length},o.prototype.setFrame=function(e,t,n){this.frames[e]=t,this.drawOrders[e]=n},o.prototype.apply=function(i,o,a,s,c,l,u){var h=i.drawOrder,f=i.slots;if(u!=n.mixOut||l!=t.setup){var _=this.frames;if(a<_[0])l!=t.setup&&l!=t.first||e.Utils.arrayCopy(i.slots,0,i.drawOrder,0,i.slots.length);else{var p;p=a>=_[_.length-1]?_.length-1:r.binarySearch(_,a)-1;var d=this.drawOrders[p];if(null==d)e.Utils.arrayCopy(f,0,h,0,f.length);else for(var m=0,g=d.length;m=h[h.length-a.ENTRIES])l==t.setup?(f.mix=f.data.mix+(h[h.length+a.PREV_MIX]-f.data.mix)*c,f.softness=f.data.softness+(h[h.length+a.PREV_SOFTNESS]-f.data.softness)*c,u==n.mixOut?(f.bendDirection=f.data.bendDirection,f.compress=f.data.compress,f.stretch=f.data.stretch):(f.bendDirection=h[h.length+a.PREV_BEND_DIRECTION],f.compress=0!=h[h.length+a.PREV_COMPRESS],f.stretch=0!=h[h.length+a.PREV_STRETCH])):(f.mix+=(h[h.length+a.PREV_MIX]-f.mix)*c,f.softness+=(h[h.length+a.PREV_SOFTNESS]-f.softness)*c,u==n.mixIn&&(f.bendDirection=h[h.length+a.PREV_BEND_DIRECTION],f.compress=0!=h[h.length+a.PREV_COMPRESS],f.stretch=0!=h[h.length+a.PREV_STRETCH]));else{var _=r.binarySearch(h,o,a.ENTRIES),p=h[_+a.PREV_MIX],d=h[_+a.PREV_SOFTNESS],m=h[_],g=this.getCurvePercent(_/a.ENTRIES-1,1-(o-m)/(h[_+a.PREV_TIME]-m));l==t.setup?(f.mix=f.data.mix+(p+(h[_+a.MIX]-p)*g-f.data.mix)*c,f.softness=f.data.softness+(d+(h[_+a.SOFTNESS]-d)*g-f.data.softness)*c,u==n.mixOut?(f.bendDirection=f.data.bendDirection,f.compress=f.data.compress,f.stretch=f.data.stretch):(f.bendDirection=h[_+a.PREV_BEND_DIRECTION],f.compress=0!=h[_+a.PREV_COMPRESS],f.stretch=0!=h[_+a.PREV_STRETCH])):(f.mix+=(p+(h[_+a.MIX]-p)*g-f.mix)*c,f.softness+=(d+(h[_+a.SOFTNESS]-d)*g-f.softness)*c,u==n.mixIn&&(f.bendDirection=h[_+a.PREV_BEND_DIRECTION],f.compress=0!=h[_+a.PREV_COMPRESS],f.stretch=0!=h[_+a.PREV_STRETCH]))}},a.ENTRIES=6,a.PREV_TIME=-6,a.PREV_MIX=-5,a.PREV_SOFTNESS=-4,a.PREV_BEND_DIRECTION=-3,a.PREV_COMPRESS=-2,a.PREV_STRETCH=-1,a.MIX=1,a.SOFTNESS=2,a.BEND_DIRECTION=3,a.COMPRESS=4,a.STRETCH=5,a}(o);e.IkConstraintTimeline=g;var v=function(n){function o(t){var i=n.call(this,t)||this;return i.frames=e.Utils.newFloatArray(t*o.ENTRIES),i}return vie(o,n),o.prototype.getPropertyId=function(){return(i.transformConstraint<<24)+this.transformConstraintIndex},o.prototype.setFrame=function(e,t,n,i,r,a){e*=o.ENTRIES,this.frames[e]=t,this.frames[e+o.ROTATE]=n,this.frames[e+o.TRANSLATE]=i,this.frames[e+o.SCALE]=r,this.frames[e+o.SHEAR]=a},o.prototype.apply=function(e,n,i,a,s,c){var l=this.frames,u=e.transformConstraints[this.transformConstraintIndex];if(u.active)if(i=l[l.length-o.ENTRIES]){var m=l.length;f=l[m+o.PREV_ROTATE],_=l[m+o.PREV_TRANSLATE],p=l[m+o.PREV_SCALE],d=l[m+o.PREV_SHEAR]}else{var g=r.binarySearch(l,i,o.ENTRIES);f=l[g+o.PREV_ROTATE],_=l[g+o.PREV_TRANSLATE],p=l[g+o.PREV_SCALE],d=l[g+o.PREV_SHEAR];var v=l[g],y=this.getCurvePercent(g/o.ENTRIES-1,1-(i-v)/(l[g+o.PREV_TIME]-v));f+=(l[g+o.ROTATE]-f)*y,_+=(l[g+o.TRANSLATE]-_)*y,p+=(l[g+o.SCALE]-p)*y,d+=(l[g+o.SHEAR]-d)*y}c==t.setup?(h=u.data,u.rotateMix=h.rotateMix+(f-h.rotateMix)*s,u.translateMix=h.translateMix+(_-h.translateMix)*s,u.scaleMix=h.scaleMix+(p-h.scaleMix)*s,u.shearMix=h.shearMix+(d-h.shearMix)*s):(u.rotateMix+=(f-u.rotateMix)*s,u.translateMix+=(_-u.translateMix)*s,u.scaleMix+=(p-u.scaleMix)*s,u.shearMix+=(d-u.shearMix)*s)}},o.ENTRIES=5,o.PREV_TIME=-5,o.PREV_ROTATE=-4,o.PREV_TRANSLATE=-3,o.PREV_SCALE=-2,o.PREV_SHEAR=-1,o.ROTATE=1,o.TRANSLATE=2,o.SCALE=3,o.SHEAR=4,o}(o);e.TransformConstraintTimeline=v;var y=function(n){function o(t){var i=n.call(this,t)||this;return i.frames=e.Utils.newFloatArray(t*o.ENTRIES),i}return vie(o,n),o.prototype.getPropertyId=function(){return(i.pathConstraintPosition<<24)+this.pathConstraintIndex},o.prototype.setFrame=function(e,t,n){e*=o.ENTRIES,this.frames[e]=t,this.frames[e+o.VALUE]=n},o.prototype.apply=function(e,n,i,a,s,c){var l=this.frames,u=e.pathConstraints[this.pathConstraintIndex];if(u.active)if(i=l[l.length-o.ENTRIES])h=l[l.length+o.PREV_VALUE];else{var f=r.binarySearch(l,i,o.ENTRIES);h=l[f+o.PREV_VALUE];var _=l[f],p=this.getCurvePercent(f/o.ENTRIES-1,1-(i-_)/(l[f+o.PREV_TIME]-_));h+=(l[f+o.VALUE]-h)*p}c==t.setup?u.position=u.data.position+(h-u.data.position)*s:u.position+=(h-u.position)*s}},o.ENTRIES=2,o.PREV_TIME=-2,o.PREV_VALUE=-1,o.VALUE=1,o}(o);e.PathConstraintPositionTimeline=y;var x=function(e){function n(t){return e.call(this,t)||this}return vie(n,e),n.prototype.getPropertyId=function(){return(i.pathConstraintSpacing<<24)+this.pathConstraintIndex},n.prototype.apply=function(e,i,o,a,s,c){var l=this.frames,u=e.pathConstraints[this.pathConstraintIndex];if(u.active)if(o=l[l.length-n.ENTRIES])h=l[l.length+n.PREV_VALUE];else{var f=r.binarySearch(l,o,n.ENTRIES);h=l[f+n.PREV_VALUE];var _=l[f],p=this.getCurvePercent(f/n.ENTRIES-1,1-(o-_)/(l[f+n.PREV_TIME]-_));h+=(l[f+n.VALUE]-h)*p}c==t.setup?u.spacing=u.data.spacing+(h-u.data.spacing)*s:u.spacing+=(h-u.spacing)*s}},n}(y);e.PathConstraintSpacingTimeline=x;var S=function(n){function o(t){var i=n.call(this,t)||this;return i.frames=e.Utils.newFloatArray(t*o.ENTRIES),i}return vie(o,n),o.prototype.getPropertyId=function(){return(i.pathConstraintMix<<24)+this.pathConstraintIndex},o.prototype.setFrame=function(e,t,n,i){e*=o.ENTRIES,this.frames[e]=t,this.frames[e+o.ROTATE]=n,this.frames[e+o.TRANSLATE]=i},o.prototype.apply=function(e,n,i,a,s,c){var l=this.frames,u=e.pathConstraints[this.pathConstraintIndex];if(u.active)if(i=l[l.length-o.ENTRIES])h=l[l.length+o.PREV_ROTATE],f=l[l.length+o.PREV_TRANSLATE];else{var _=r.binarySearch(l,i,o.ENTRIES);h=l[_+o.PREV_ROTATE],f=l[_+o.PREV_TRANSLATE];var p=l[_],d=this.getCurvePercent(_/o.ENTRIES-1,1-(i-p)/(l[_+o.PREV_TIME]-p));h+=(l[_+o.ROTATE]-h)*d,f+=(l[_+o.TRANSLATE]-f)*d}c==t.setup?(u.rotateMix=u.data.rotateMix+(h-u.data.rotateMix)*s,u.translateMix=u.data.translateMix+(f-u.data.translateMix)*s):(u.rotateMix+=(h-u.rotateMix)*s,u.translateMix+=(f-u.translateMix)*s)}},o.ENTRIES=3,o.PREV_TIME=-3,o.PREV_ROTATE=-2,o.PREV_TRANSLATE=-1,o.ROTATE=1,o.TRANSLATE=2,o}(o);e.PathConstraintMixTimeline=S}(gie||(gie={})),function(e){var t=function(){function t(t){this.tracks=new Array,this.timeScale=1,this.events=new Array,this.listeners=new Array,this.queue=new r(this),this.propertyIDs=new e.IntSet,this.animationsChanged=!1,this.trackEntryPool=new e.Pool((function(){return new n})),this.data=t}return t.prototype.update=function(e){e*=this.timeScale;for(var t=this.tracks,n=0,i=t.length;n0){if(r.delay-=o,r.delay>0)continue;o=-r.delay,r.delay=0}var a=r.next;if(null!=a){var s=r.trackLast-a.delay;if(s>=0){for(a.delay=0,a.trackTime+=0==r.timeScale?0:(s/r.timeScale+e)*a.timeScale,r.trackTime+=o,this.setCurrent(n,a,!0);null!=a.mixingFrom;)a.mixTime+=e,a=a.mixingFrom;continue}}else if(r.trackLast>=r.trackEnd&&null==r.mixingFrom){t[n]=null,this.queue.end(r),this.disposeNext(r);continue}if(null!=r.mixingFrom&&this.updateMixingFrom(r,e)){var c=r.mixingFrom;for(r.mixingFrom=null,null!=c&&(c.mixingTo=null);null!=c;)this.queue.end(c),c=c.mixingFrom}r.trackTime+=o}}this.queue.drain()},t.prototype.updateMixingFrom=function(e,t){var n=e.mixingFrom;if(null==n)return!0;var i=this.updateMixingFrom(n,t);return n.animationLast=n.nextAnimationLast,n.trackLast=n.nextTrackLast,e.mixTime>0&&e.mixTime>=e.mixDuration?(0!=n.totalAlpha&&0!=e.mixDuration||(e.mixingFrom=n.mixingFrom,null!=n.mixingFrom&&(n.mixingFrom.mixingTo=e),e.interruptAlpha=n.interruptAlpha,this.queue.end(n)),i):(n.trackTime+=t*n.timeScale,e.mixTime+=t,!1)},t.prototype.apply=function(n){if(null==n)throw new Error("skeleton cannot be null.");this.animationsChanged&&this._animationsChanged();for(var i=this.events,r=this.tracks,o=!1,a=0,s=r.length;a0)){o=!0;var l=0==a?e.MixBlend.first:c.mixBlend,u=c.alpha;null!=c.mixingFrom?u*=this.applyMixingFrom(c,n,l):c.trackTime>=c.trackEnd&&null==c.next&&(u=0);var h=c.animationLast,f=c.getAnimationTime(),_=c.animation.timelines.length,p=c.animation.timelines;if(0==a&&1==u||l==e.MixBlend.add)for(var d=0;d<_;d++)e.Utils.webkit602BugfixHelper(u,l),p[d].apply(n,h,f,i,u,l,e.MixDirection.mixIn);else{var m=c.timelineMode,g=0==c.timelinesRotation.length;g&&e.Utils.setArraySize(c.timelinesRotation,_<<1,null);var v=c.timelinesRotation;for(d=0;d<_;d++){var y=p[d],x=(m[d]&t.NOT_LAST-1)==t.SUBSEQUENT?l:e.MixBlend.setup;y instanceof e.RotateTimeline?this.applyRotateTimeline(y,n,f,u,x,v,d<<1,g):(e.Utils.webkit602BugfixHelper(u,l),y.apply(n,h,f,i,u,x,e.MixDirection.mixIn))}}this.queueEvents(c,f),i.length=0,c.nextAnimationLast=f,c.nextTrackLast=c.trackTime}}return this.queue.drain(),o},t.prototype.applyMixingFrom=function(n,i,r){var o=n.mixingFrom;null!=o.mixingFrom&&this.applyMixingFrom(o,i,r);var a=0;0==n.mixDuration?(a=1,r==e.MixBlend.first&&(r=e.MixBlend.setup)):((a=n.mixTime/n.mixDuration)>1&&(a=1),r!=e.MixBlend.first&&(r=o.mixBlend));var s=a0&&this.queueEvents(o,h),this.events.length=0,o.nextAnimationLast=h,o.nextTrackLast=o.trackTime,a},t.prototype.applyRotateTimeline=function(t,n,i,r,o,a,s,c){if(c&&(a[s]=0),1!=r){var l=t,u=l.frames,h=n.bones[l.boneIndex];if(h.active){var f=0,_=0;if(i=u[u.length-e.RotateTimeline.ENTRIES])_=h.data.rotation+u[u.length+e.RotateTimeline.PREV_ROTATION];else{var p=e.Animation.binarySearch(u,i,e.RotateTimeline.ENTRIES),d=u[p+e.RotateTimeline.PREV_ROTATION],m=u[p],g=l.getCurvePercent((p>>1)-1,1-(i-m)/(u[p+e.RotateTimeline.PREV_TIME]-m));_=u[p+e.RotateTimeline.ROTATION]-d,_=d+(_-=360*(16384-(16384.499999999996-_/360|0)))*g+h.data.rotation,_-=360*(16384-(16384.499999999996-_/360|0))}var v=0,y=_-f;if(0==(y-=360*(16384-(16384.499999999996-y/360|0))))v=a[s];else{var x=0,S=0;c?(x=0,S=y):(x=a[s],S=a[s+1]);var T=y>0,E=x>=0;e.MathUtils.signum(S)!=e.MathUtils.signum(y)&&Math.abs(S)<=90&&(Math.abs(x)>180&&(x+=360*e.MathUtils.signum(x)),E=T),v=y+x-x%360,E!=T&&(v+=360*e.MathUtils.signum(x)),a[s]=v}a[s+1]=y,f+=v*r,h.rotation=f-360*(16384-(16384.499999999996-f/360|0))}}else t.apply(n,0,i,null,1,o,e.MixDirection.mixIn)},t.prototype.queueEvents=function(e,t){for(var n=e.animationStart,i=e.animationEnd,r=i-n,o=e.trackLast%r,a=this.events,s=0,c=a.length;si||this.queue.event(e,l)}for((e.loop?0==r||o>e.trackTime%r:t>=i&&e.animationLast=this.tracks.length)){var t=this.tracks[e];if(null!=t){this.queue.end(t),this.disposeNext(t);for(var n=t;;){var i=n.mixingFrom;if(null==i)break;this.queue.end(i),n.mixingFrom=null,n.mixingTo=null,n=i}this.tracks[t.trackIndex]=null,this.queue.drain()}}},t.prototype.setCurrent=function(e,t,n){var i=this.expandToIndex(e);this.tracks[e]=t,null!=i&&(n&&this.queue.interrupt(i),t.mixingFrom=i,i.mixingTo=t,t.mixTime=0,null!=i.mixingFrom&&i.mixDuration>0&&(t.interruptAlpha*=Math.min(1,i.mixTime/i.mixDuration)),i.timelinesRotation.length=0),this.queue.start(t)},t.prototype.setAnimation=function(e,t,n){var i=this.data.skeletonData.findAnimation(t);if(null==i)throw new Error("Animation not found: "+t);return this.setAnimationWith(e,i,n)},t.prototype.setAnimationWith=function(e,t,n){if(null==t)throw new Error("animation cannot be null.");var i=!0,r=this.expandToIndex(e);null!=r&&(-1==r.nextTrackLast?(this.tracks[e]=r.mixingFrom,this.queue.interrupt(r),this.queue.end(r),this.disposeNext(r),r=r.mixingFrom,i=!1):this.disposeNext(r));var o=this.trackEntry(e,t,n,r);return this.setCurrent(e,o,i),this.queue.drain(),o},t.prototype.addAnimation=function(e,t,n,i){var r=this.data.skeletonData.findAnimation(t);if(null==r)throw new Error("Animation not found: "+t);return this.addAnimationWith(e,r,n,i)},t.prototype.addAnimationWith=function(e,t,n,i){if(null==t)throw new Error("animation cannot be null.");var r=this.expandToIndex(e);if(null!=r)for(;null!=r.next;)r=r.next;var o=this.trackEntry(e,t,n,r);if(null==r)this.setCurrent(e,o,!0),this.queue.drain();else if(r.next=o,i<=0){var a=r.animationEnd-r.animationStart;0!=a?(r.loop?i+=a*(1+(r.trackTime/a|0)):i+=Math.max(a,r.trackTime),i-=this.data.getMix(r.animation,t)):i=r.trackTime}return o.delay=i,o},t.prototype.setEmptyAnimation=function(e,n){var i=this.setAnimationWith(e,t.emptyAnimation,!1);return i.mixDuration=n,i.trackEnd=n,i},t.prototype.addEmptyAnimation=function(e,n,i){i<=0&&(i-=n);var r=this.addAnimationWith(e,t.emptyAnimation,!1,i);return r.mixDuration=n,r.trackEnd=n,r},t.prototype.setEmptyAnimations=function(e){var t=this.queue.drainDisabled;this.queue.drainDisabled=!0;for(var n=0,i=this.tracks.length;n=0;t--)for(var i=this.tracks[t];null!=i;)this.computeNotLast(i),i=i.mixingFrom},t.prototype.computeHold=function(n){var i=n.mixingTo,r=n.animation.timelines,o=n.animation.timelines.length,a=e.Utils.setArraySize(n.timelineMode,o);n.timelineHoldMix.length=0;var s=e.Utils.setArraySize(n.timelineHoldMix,o),c=this.propertyIDs;if(null!=i&&i.holdPrevious)for(var l=0;l0){a[l]=t.HOLD_MIX,s[l]=f;continue e}break}a[l]=t.HOLD}else a[l]=t.SUBSEQUENT}},t.prototype.computeNotLast=function(n){for(var i=n.animation.timelines,r=n.animation.timelines.length,o=n.timelineMode,a=this.propertyIDs,s=0;s=this.tracks.length?null:this.tracks[e]},t.prototype.addListener=function(e){if(null==e)throw new Error("listener cannot be null.");this.listeners.push(e)},t.prototype.removeListener=function(e){var t=this.listeners.indexOf(e);t>=0&&this.listeners.splice(t,1)},t.prototype.clearListeners=function(){this.listeners.length=0},t.prototype.clearListenerNotifications=function(){this.queue.clear()},t.emptyAnimation=new e.Animation("",[],0),t.SUBSEQUENT=0,t.FIRST=1,t.HOLD=2,t.HOLD_MIX=3,t.NOT_LAST=4,t}();e.AnimationState=t;var n=function(){function t(){this.mixBlend=e.MixBlend.replace,this.timelineMode=new Array,this.timelineHoldMix=new Array,this.timelinesRotation=new Array}return t.prototype.reset=function(){this.next=null,this.mixingFrom=null,this.mixingTo=null,this.animation=null,this.listener=null,this.timelineMode.length=0,this.timelineHoldMix.length=0,this.timelinesRotation.length=0},t.prototype.getAnimationTime=function(){if(this.loop){var e=this.animationEnd-this.animationStart;return 0==e?this.animationStart:this.trackTime%e+this.animationStart}return Math.min(this.trackTime+this.animationStart,this.animationEnd)},t.prototype.setAnimationLast=function(e){this.animationLast=e,this.nextAnimationLast=e},t.prototype.isComplete=function(){return this.trackTime>=this.animationEnd-this.animationStart},t.prototype.resetRotationDirections=function(){this.timelinesRotation.length=0},t}();e.TrackEntry=n;var i,r=function(){function e(e){this.objects=[],this.drainDisabled=!1,this.animState=e}return e.prototype.start=function(e){this.objects.push(i.start),this.objects.push(e),this.animState.animationsChanged=!0},e.prototype.interrupt=function(e){this.objects.push(i.interrupt),this.objects.push(e)},e.prototype.end=function(e){this.objects.push(i.end),this.objects.push(e),this.animState.animationsChanged=!0},e.prototype.dispose=function(e){this.objects.push(i.dispose),this.objects.push(e)},e.prototype.complete=function(e){this.objects.push(i.complete),this.objects.push(e)},e.prototype.event=function(e,t){this.objects.push(i.event),this.objects.push(e),this.objects.push(t)},e.prototype.drain=function(){if(!this.drainDisabled){this.drainDisabled=!0;for(var e=this.objects,t=this.animState.listeners,n=0;n=0?n.substring(0,n.lastIndexOf("/")):"";n=this.pathPrefix+n,this.toLoad++,t.downloadText(n,(function(t){var s={count:0},c=new Array;try{new e.TextureAtlas(t,(function(t){c.push(a+"/"+t);var n=document.createElement("img");return n.width=16,n.height=16,new e.FakeTexture(n)}))}catch(e){var l=e;return o.errors[n]="Couldn't load texture atlas "+n+": "+l.message,r&&r(n,"Couldn't load texture atlas "+n+": "+l.message),o.toLoad--,void o.loaded++}for(var u=function(l){var u=!1;o.loadTexture(l,(function(l){if(s.count++,s.count==c.length)if(u)o.errors[n]="Couldn't load texture atlas page "+l+"} of atlas "+n,r&&r(n,"Couldn't load texture atlas page "+l+" of atlas "+n),o.toLoad--,o.loaded++;else try{var h=new e.TextureAtlas(t,(function(e){return o.get(a+"/"+e)}));o.assets[n]=h,i&&i(n,h),o.toLoad--,o.loaded++}catch(e){var f=e;o.errors[n]="Couldn't load texture atlas "+n+": "+f.message,r&&r(n,"Couldn't load texture atlas "+n+": "+f.message),o.toLoad--,o.loaded++}}),(function(e){u=!0,s.count++,s.count==c.length&&(o.errors[n]="Couldn't load texture atlas page "+e+"} of atlas "+n,r&&r(n,"Couldn't load texture atlas page "+e+" of atlas "+n),o.toLoad--,o.loaded++)}))},h=0,f=c;h0},t.prototype.getErrors=function(){return this.errors},t}();e.AssetManager=t}(gie||(gie={})),function(e){var t=function(){function t(e){this.atlas=e}return t.prototype.newRegionAttachment=function(t,n,i){var r=this.atlas.findRegion(i);if(null==r)return null;r.renderObject=r;var o=new e.RegionAttachment(n);return o.setRegion(r),o},t.prototype.newMeshAttachment=function(t,n,i){var r=this.atlas.findRegion(i);if(null==r)return null;r.renderObject=r;var o=new e.MeshAttachment(n);return o.region=r,o},t.prototype.newBoundingBoxAttachment=function(t,n){return new e.BoundingBoxAttachment(n)},t.prototype.newPathAttachment=function(t,n){return new e.PathAttachment(n)},t.prototype.newPointAttachment=function(t,n){return new e.PointAttachment(n)},t.prototype.newClippingAttachment=function(t,n){return new e.ClippingAttachment(n)},t}();e.AtlasAttachmentLoader=t}(gie||(gie={})),function(e){var t;(t=e.BlendMode||(e.BlendMode={}))[t.Normal=0]="Normal",t[t.Additive=1]="Additive",t[t.Multiply=2]="Multiply",t[t.Screen=3]="Screen"}(gie||(gie={})),function(e){var t=function(){function t(e,t,n){if(this.children=new Array,this.x=0,this.y=0,this.rotation=0,this.scaleX=0,this.scaleY=0,this.shearX=0,this.shearY=0,this.ax=0,this.ay=0,this.arotation=0,this.ascaleX=0,this.ascaleY=0,this.ashearX=0,this.ashearY=0,this.appliedValid=!1,this.a=0,this.b=0,this.c=0,this.d=0,this.worldY=0,this.worldX=0,this.sorted=!1,this.active=!1,null==e)throw new Error("data cannot be null.");if(null==t)throw new Error("skeleton cannot be null.");this.data=e,this.skeleton=t,this.parent=n,this.setToSetupPose()}return t.prototype.isActive=function(){return this.active},t.prototype.update=function(){this.updateWorldTransformWith(this.x,this.y,this.rotation,this.scaleX,this.scaleY,this.shearX,this.shearY)},t.prototype.updateWorldTransform=function(){this.updateWorldTransformWith(this.x,this.y,this.rotation,this.scaleX,this.scaleY,this.shearX,this.shearY)},t.prototype.updateWorldTransformWith=function(t,n,i,r,o,a,s){this.ax=t,this.ay=n,this.arotation=i,this.ascaleX=r,this.ascaleY=o,this.ashearX=a,this.ashearY=s,this.appliedValid=!0;var c=this.parent;if(null==c){var l=this.skeleton,u=i+90+s,h=l.scaleX,f=l.scaleY;return this.a=e.MathUtils.cosDeg(i+a)*r*h,this.b=e.MathUtils.cosDeg(u)*o*h,this.c=e.MathUtils.sinDeg(i+a)*r*f,this.d=e.MathUtils.sinDeg(u)*o*f,this.worldX=t*h+l.x,void(this.worldY=n*f+l.y)}var _=c.a,p=c.b,d=c.c,m=c.d;switch(this.worldX=_*t+p*n+c.worldX,this.worldY=d*t+m*n+c.worldY,this.data.transformMode){case e.TransformMode.Normal:u=i+90+s;var g=e.MathUtils.cosDeg(i+a)*r,v=e.MathUtils.cosDeg(u)*o,y=e.MathUtils.sinDeg(i+a)*r,x=e.MathUtils.sinDeg(u)*o;return this.a=_*g+p*y,this.b=_*v+p*x,this.c=d*g+m*y,void(this.d=d*v+m*x);case e.TransformMode.OnlyTranslation:u=i+90+s,this.a=e.MathUtils.cosDeg(i+a)*r,this.b=e.MathUtils.cosDeg(u)*o,this.c=e.MathUtils.sinDeg(i+a)*r,this.d=e.MathUtils.sinDeg(u)*o;break;case e.TransformMode.NoRotationOrReflection:var S=0;(A=_*_+d*d)>1e-4?(p=d*(A=Math.abs(_*m-p*d)/A),m=_*A,S=Math.atan2(d,_)*e.MathUtils.radDeg):(_=0,d=0,S=90-Math.atan2(m,p)*e.MathUtils.radDeg);var T=i+a-S,E=i+s-S+90;g=e.MathUtils.cosDeg(T)*r,v=e.MathUtils.cosDeg(E)*o,y=e.MathUtils.sinDeg(T)*r,x=e.MathUtils.sinDeg(E)*o,this.a=_*g-p*y,this.b=_*v-p*x,this.c=d*g+m*y,this.d=d*v+m*x;break;case e.TransformMode.NoScale:case e.TransformMode.NoScaleOrReflection:var A,C=e.MathUtils.cosDeg(i),b=e.MathUtils.sinDeg(i),w=(_*C+p*b)/this.skeleton.scaleX,R=(d*C+m*b)/this.skeleton.scaleY;(A=Math.sqrt(w*w+R*R))>1e-5&&(A=1/A),w*=A,R*=A,A=Math.sqrt(w*w+R*R),this.data.transformMode==e.TransformMode.NoScale&&_*m-p*d<0!=(this.skeleton.scaleX<0!=this.skeleton.scaleY<0)&&(A=-A);var P=Math.PI/2+Math.atan2(R,w),I=Math.cos(P)*A,D=Math.sin(P)*A;g=e.MathUtils.cosDeg(a)*r,v=e.MathUtils.cosDeg(90+s)*o,y=e.MathUtils.sinDeg(a)*r,x=e.MathUtils.sinDeg(90+s)*o,this.a=w*g+I*y,this.b=w*v+I*x,this.c=R*g+D*y,this.d=R*v+D*x}this.a*=this.skeleton.scaleX,this.b*=this.skeleton.scaleX,this.c*=this.skeleton.scaleY,this.d*=this.skeleton.scaleY},t.prototype.setToSetupPose=function(){var e=this.data;this.x=e.x,this.y=e.y,this.rotation=e.rotation,this.scaleX=e.scaleX,this.scaleY=e.scaleY,this.shearX=e.shearX,this.shearY=e.shearY},t.prototype.getWorldRotationX=function(){return Math.atan2(this.c,this.a)*e.MathUtils.radDeg},t.prototype.getWorldRotationY=function(){return Math.atan2(this.d,this.b)*e.MathUtils.radDeg},t.prototype.getWorldScaleX=function(){return Math.sqrt(this.a*this.a+this.c*this.c)},t.prototype.getWorldScaleY=function(){return Math.sqrt(this.b*this.b+this.d*this.d)},t.prototype.updateAppliedTransform=function(){this.appliedValid=!0;var t=this.parent;if(null==t)return this.ax=this.worldX,this.ay=this.worldY,this.arotation=Math.atan2(this.c,this.a)*e.MathUtils.radDeg,this.ascaleX=Math.sqrt(this.a*this.a+this.c*this.c),this.ascaleY=Math.sqrt(this.b*this.b+this.d*this.d),this.ashearX=0,void(this.ashearY=Math.atan2(this.a*this.b+this.c*this.d,this.a*this.d-this.b*this.c)*e.MathUtils.radDeg);var n=t.a,i=t.b,r=t.c,o=t.d,a=1/(n*o-i*r),s=this.worldX-t.worldX,c=this.worldY-t.worldY;this.ax=s*o*a-c*i*a,this.ay=c*n*a-s*r*a;var l=a*o,u=a*n,h=a*i,f=a*r,_=l*this.a-h*this.c,p=l*this.b-h*this.d,d=u*this.c-f*this.a,m=u*this.d-f*this.b;if(this.ashearX=0,this.ascaleX=Math.sqrt(_*_+d*d),this.ascaleX>1e-4){var g=_*m-p*d;this.ascaleY=g/this.ascaleX,this.ashearY=Math.atan2(_*p+d*m,g)*e.MathUtils.radDeg,this.arotation=Math.atan2(d,_)*e.MathUtils.radDeg}else this.ascaleX=0,this.ascaleY=Math.sqrt(p*p+m*m),this.ashearY=0,this.arotation=90-Math.atan2(m,p)*e.MathUtils.radDeg},t.prototype.worldToLocal=function(e){var t=this.a,n=this.b,i=this.c,r=this.d,o=1/(t*r-n*i),a=e.x-this.worldX,s=e.y-this.worldY;return e.x=a*r*o-s*n*o,e.y=s*t*o-a*i*o,e},t.prototype.localToWorld=function(e){var t=e.x,n=e.y;return e.x=t*this.a+n*this.b+this.worldX,e.y=t*this.c+n*this.d+this.worldY,e},t.prototype.worldToLocalRotation=function(t){var n=e.MathUtils.sinDeg(t),i=e.MathUtils.cosDeg(t);return Math.atan2(this.a*n-this.c*i,this.d*i-this.b*n)*e.MathUtils.radDeg+this.rotation-this.shearX},t.prototype.localToWorldRotation=function(t){t-=this.rotation-this.shearX;var n=e.MathUtils.sinDeg(t),i=e.MathUtils.cosDeg(t);return Math.atan2(i*this.c+n*this.d,i*this.a+n*this.b)*e.MathUtils.radDeg},t.prototype.rotateWorld=function(t){var n=this.a,i=this.b,r=this.c,o=this.d,a=e.MathUtils.cosDeg(t),s=e.MathUtils.sinDeg(t);this.a=a*n-s*r,this.b=a*i-s*o,this.c=s*n+a*r,this.d=s*i+a*o,this.appliedValid=!1},t}();e.Bone=t}(gie||(gie={})),function(e){var t;e.BoneData=function(n,i,r){if(this.x=0,this.y=0,this.rotation=0,this.scaleX=1,this.scaleY=1,this.shearX=0,this.shearY=0,this.transformMode=t.Normal,this.skinRequired=!1,this.color=new e.Color,n<0)throw new Error("index must be >= 0.");if(null==i)throw new Error("name cannot be null.");this.index=n,this.name=i,this.parent=r},function(e){e[e.Normal=0]="Normal",e[e.OnlyTranslation=1]="OnlyTranslation",e[e.NoRotationOrReflection=2]="NoRotationOrReflection",e[e.NoScale=3]="NoScale",e[e.NoScaleOrReflection=4]="NoScaleOrReflection"}(t=e.TransformMode||(e.TransformMode={}))}(gie||(gie={})),function(e){e.ConstraintData=function(e,t,n){this.name=e,this.order=t,this.skinRequired=n}}(gie||(gie={})),function(e){e.Event=function(e,t){if(null==t)throw new Error("data cannot be null.");this.time=e,this.data=t}}(gie||(gie={})),function(e){e.EventData=function(e){this.name=e}}(gie||(gie={})),function(e){var t=function(){function t(e,t){if(this.bendDirection=0,this.compress=!1,this.stretch=!1,this.mix=1,this.softness=0,this.active=!1,null==e)throw new Error("data cannot be null.");if(null==t)throw new Error("skeleton cannot be null.");this.data=e,this.mix=e.mix,this.softness=e.softness,this.bendDirection=e.bendDirection,this.compress=e.compress,this.stretch=e.stretch,this.bones=new Array;for(var n=0;n180?p-=360:p<-180&&(p+=360);var d=t.ascaleX,m=t.ascaleY;if(r||o){var g=t.data.length*d,v=Math.sqrt(f*f+_*_);if(r&&vg&&g>1e-4){var y=(v/g-1)*s+1;d*=y,a&&(m*=y)}}t.updateWorldTransformWith(t.ax,t.ay,t.arotation+p*s,d,m,t.ashearX,t.ashearY)},t.prototype.apply2=function(t,n,i,r,o,a,s,c){if(0!=c){t.appliedValid||t.updateAppliedTransform(),n.appliedValid||n.updateAppliedTransform();var l=t.ax,u=t.ay,h=t.ascaleX,f=h,_=t.ascaleY,p=n.ascaleX,d=0,m=0,g=0;h<0?(h=-h,d=180,g=-1):(d=0,g=1),_<0&&(_=-_,g=-g),p<0?(p=-p,m=180):m=0;var v=n.ax,y=0,x=0,S=0,T=t.a,E=t.b,A=t.c,C=t.d,b=Math.abs(h-_)<=1e-4;b?(x=T*v+E*(y=n.ay)+t.worldX,S=A*v+C*y+t.worldY):(y=0,x=T*v+t.worldX,S=A*v+t.worldY);var w=t.parent;T=w.a,E=w.b,A=w.c;var R,P,I=1/(T*(C=w.d)-E*A),D=x-w.worldX,O=S-w.worldY,M=(D*C-O*E)*I-l,N=(O*T-D*A)*I-u,L=Math.sqrt(M*M+N*N),F=n.data.length*p;if(L<1e-4)return this.apply1(t,i,r,!1,a,!1,c),void n.updateWorldTransformWith(v,y,0,n.ascaleX,n.ascaleY,n.ashearX,n.ashearY);var B=((D=i-w.worldX)*C-(O=r-w.worldY)*E)*I-l,z=(O*T-D*A)*I-u,k=B*B+z*z;if(0!=s){s*=h*(p+1)/2;var U=Math.sqrt(k),G=U-L-F*h+s;if(G>0){var H=Math.min(1,G/(2*s))-1;k=(B-=(H=(G-s*(1-H*H))/U)*B)*B+(z-=H*z)*z}}e:if(b){var V=(k-L*L-(F*=h)*F)/(2*L*F);V<-1?V=-1:V>1&&(V=1,a&&(f*=(Math.sqrt(k)/(L+F)-1)*c+1)),P=Math.acos(V)*o,T=L+F*V,E=F*Math.sin(P),R=Math.atan2(z*T-B*E,B*T+z*E)}else{var j=(T=h*F)*T,W=(E=_*F)*E,q=Math.atan2(z,B),X=-2*W*L,Y=W-j;if((C=X*X-4*Y*(A=W*L*L+j*k-j*W))>=0){var K=Math.sqrt(C);X<0&&(K=-K);var Q=(K=-(X+K)/2)/Y,Z=A/K,J=Math.abs(Q)=-1&&A<=1&&(A=Math.acos(A),(C=(D=T*Math.cos(A)+L)*D+(O=E*Math.sin(A))*O)oe&&(ie=A,oe=C,re=D,ae=O)),k<=(te+oe)/2?(R=q-Math.atan2(ne*o,ee),P=$*o):(R=q-Math.atan2(ae*o,re),P=ie*o)}var se=Math.atan2(y,v)*g,ce=t.arotation;(R=(R-se)*e.MathUtils.radDeg+d-ce)>180?R-=360:R<-180&&(R+=360),t.updateWorldTransformWith(l,u,ce+R*c,f,t.ascaleY,0,0),ce=n.arotation,(P=((P+se)*e.MathUtils.radDeg-n.ashearX)*g+m-ce)>180?P-=360:P<-180&&(P+=360),n.updateWorldTransformWith(v,y,ce+P*c,n.ascaleX,n.ascaleY,n.ashearX,n.ashearY)}else n.updateWorldTransform()},t}();e.IkConstraint=t}(gie||(gie={})),function(e){var t=function(e){function t(t){var n=e.call(this,t,0,!1)||this;return n.bones=new Array,n.bendDirection=1,n.compress=!1,n.stretch=!1,n.uniform=!1,n.mix=1,n.softness=0,n}return vie(t,e),t}(e.ConstraintData);e.IkConstraintData=t}(gie||(gie={})),function(e){var t=function(){function t(e,t){if(this.position=0,this.spacing=0,this.rotateMix=0,this.translateMix=0,this.spaces=new Array,this.positions=new Array,this.world=new Array,this.curves=new Array,this.lengths=new Array,this.segments=new Array,this.active=!1,null==e)throw new Error("data cannot be null.");if(null==t)throw new Error("skeleton cannot be null.");this.data=e,this.bones=new Array;for(var n=0,i=e.bones.length;n0;if(r>0||o){var a=this.data,s=a.spacingMode==e.SpacingMode.Percent,c=a.rotateMode,l=c==e.RotateMode.Tangent,u=c==e.RotateMode.ChainScale,h=this.bones.length,f=l?h:h+1,_=this.bones,p=e.Utils.setArraySize(this.spaces,f),d=null,m=this.spacing;if(u||!s){u&&(d=e.Utils.setArraySize(this.lengths,h));for(var g=a.spacingMode==e.SpacingMode.Length,v=0,y=f-1;v0?e.MathUtils.degRad:-e.MathUtils.degRad),v=0;for(var I=3;ve.MathUtils.PI?U-=e.MathUtils.PI2:U<-e.MathUtils.PI&&(U+=e.MathUtils.PI2),U*=i,G=Math.cos(U),H=Math.sin(U),D.a=G*F-H*z,D.b=G*B-H*k,D.c=H*F+G*z,D.d=H*B+G*k}D.appliedValid=!1}}}},t.prototype.computeWorldPositions=function(n,i,r,o,a){var s=this.target,c=this.position,l=this.spaces,u=e.Utils.setArraySize(this.positions,3*i+2),h=null,f=n.closed,_=n.worldVerticesLength,p=_/6,d=t.NONE;if(!n.constantSpeed){var m=n.lengths,g=m[p-=f?1:2];if(o&&(c*=g),a)for(var v=1;vg){d!=t.AFTER&&(d=t.AFTER,n.computeWorldVertices(s,_-6,4,h,0,2)),this.addAfterPosition(S-g,h,0,u,y);continue}}for(;;x++){var T=m[x];if(!(S>T)){0==x?S/=T:S=(S-(K=m[x-1]))/(T-K);break}}x!=d&&(d=x,f&&x==p?(n.computeWorldVertices(s,_-4,4,h,0,2),n.computeWorldVertices(s,0,4,h,4,2)):n.computeWorldVertices(s,6*x+2,8,h,0,2)),this.addCurvePosition(S,h[0],h[1],h[2],h[3],h[4],h[5],h[6],h[7],u,y,r||v>0&&0==W)}return u}f?(_+=2,h=e.Utils.setArraySize(this.world,_),n.computeWorldVertices(s,2,_-4,h,0,2),n.computeWorldVertices(s,0,2,h,_-4,2),h[_-2]=h[0],h[_-1]=h[1]):(p--,_-=4,h=e.Utils.setArraySize(this.world,_),n.computeWorldVertices(s,2,_,h,0,2));for(var E=e.Utils.setArraySize(this.curves,p),A=0,C=h[0],b=h[1],w=0,R=0,P=0,I=0,D=0,O=0,M=0,N=0,L=0,F=0,B=0,z=0,k=0,U=0,G=(v=0,2);vA){this.addAfterPosition(S-A,h,_-4,u,y);continue}}for(;;x++){var q=E[x];if(!(S>q)){0==x?S/=q:S=(S-(K=E[x-1]))/(q-K);break}}if(x!=d){d=x;var X=6*x;for(C=h[X],b=h[X+1],w=h[X+2],R=h[X+3],P=h[X+4],I=h[X+5],B=2*(M=.03*(C-2*w+P))+(L=.006*(3*(w-P)-C+(D=h[X+6]))),z=2*(N=.03*(b-2*R+I))+(F=.006*(3*(R-I)-b+(O=h[X+7]))),k=.3*(w-C)+M+.16666667*L,U=.3*(R-b)+N+.16666667*F,V=Math.sqrt(k*k+U*U),H[0]=V,X=1;X<8;X++)k+=B,U+=z,B+=L,z+=F,V+=Math.sqrt(k*k+U*U),H[X]=V;k+=B,U+=z,V+=Math.sqrt(k*k+U*U),H[8]=V,k+=B+L,U+=z+F,V+=Math.sqrt(k*k+U*U),H[9]=V,j=0}for(S*=V;;j++){var Y=H[j];if(!(S>Y)){var K;0==j?S/=Y:S=j+(S-(K=H[j-1]))/(Y-K);break}}this.addCurvePosition(.1*S,C,b,w,R,P,I,D,O,u,y,r||v>0&&0==W)}return u},t.prototype.addBeforePosition=function(e,t,n,i,r){var o=t[n],a=t[n+1],s=t[n+2]-o,c=t[n+3]-a,l=Math.atan2(c,s);i[r]=o+e*Math.cos(l),i[r+1]=a+e*Math.sin(l),i[r+2]=l},t.prototype.addAfterPosition=function(e,t,n,i,r){var o=t[n+2],a=t[n+3],s=o-t[n],c=a-t[n+1],l=Math.atan2(c,s);i[r]=o+e*Math.cos(l),i[r+1]=a+e*Math.sin(l),i[r+2]=l},t.prototype.addCurvePosition=function(e,t,n,i,r,o,a,s,c,l,u,h){if(0==e||isNaN(e))return l[u]=t,l[u+1]=n,void(l[u+2]=Math.atan2(r-n,i-t));var f=e*e,_=f*e,p=1-e,d=p*p,m=d*p,g=p*e,v=3*g,y=p*v,x=v*e,S=t*m+i*y+o*x+s*_,T=n*m+r*y+a*x+c*_;l[u]=S,l[u+1]=T,h&&(l[u+2]=e<.001?Math.atan2(r-n,i-t):Math.atan2(T-(n*d+r*g*2+a*f),S-(t*d+i*g*2+o*f)))},t.NONE=-1,t.BEFORE=-2,t.AFTER=-3,t.epsilon=1e-5,t}();e.PathConstraint=t}(gie||(gie={})),function(e){var t,n,i,r=function(e){function t(t){var n=e.call(this,t,0,!1)||this;return n.bones=new Array,n}return vie(t,e),t}(e.ConstraintData);e.PathConstraintData=r,(i=e.PositionMode||(e.PositionMode={}))[i.Fixed=0]="Fixed",i[i.Percent=1]="Percent",(n=e.SpacingMode||(e.SpacingMode={}))[n.Length=0]="Length",n[n.Fixed=1]="Fixed",n[n.Percent=2]="Percent",(t=e.RotateMode||(e.RotateMode={}))[t.Tangent=0]="Tangent",t[t.Chain=1]="Chain",t[t.ChainScale=2]="ChainScale"}(gie||(gie={})),function(e){var t=function(){function e(e){this.toLoad=new Array,this.assets={},this.clientId=e}return e.prototype.loaded=function(){var e=0;for(var t in this.assets)e++;return e},e}(),n=function(){function e(e){void 0===e&&(e=""),this.clientAssets={},this.queuedAssets={},this.rawAssets={},this.errors={},this.pathPrefix=e}return e.prototype.queueAsset=function(e,n,i){var r=this.clientAssets[e];return null==r&&(r=new t(e),this.clientAssets[e]=r),null!==n&&(r.textureLoader=n),r.toLoad.push(i),this.queuedAssets[i]!==i&&(this.queuedAssets[i]=i,!0)},e.prototype.loadText=function(e,t){var n=this;if(t=this.pathPrefix+t,this.queueAsset(e,null,t)){var i=new XMLHttpRequest;i.onreadystatechange=function(){i.readyState==XMLHttpRequest.DONE&&(i.status>=200&&i.status<300?n.rawAssets[t]=i.responseText:n.errors[t]="Couldn't load text "+t+": status "+i.status+", "+i.responseText)},i.open("GET",t,!0),i.send()}},e.prototype.loadJson=function(e,t){var n=this;if(t=this.pathPrefix+t,this.queueAsset(e,null,t)){var i=new XMLHttpRequest;i.onreadystatechange=function(){i.readyState==XMLHttpRequest.DONE&&(i.status>=200&&i.status<300?n.rawAssets[t]=JSON.parse(i.responseText):n.errors[t]="Couldn't load text "+t+": status "+i.status+", "+i.responseText)},i.open("GET",t,!0),i.send()}},e.prototype.loadTexture=function(e,t,n){var i=this;if(n=this.pathPrefix+n,this.queueAsset(e,t,n)){var r=new Image;r.src=n,r.crossOrigin="anonymous",r.onload=function(){i.rawAssets[n]=r},r.onerror=function(){i.errors[n]="Couldn't load image "+n}}},e.prototype.get=function(e,t){t=this.pathPrefix+t;var n=this.clientAssets[e];return null==n||n.assets[t]},e.prototype.updateClientAssets=function(e){for(var t=0;t0},e.prototype.getErrors=function(){return this.errors},e}();e.SharedAssetManager=n}(gie||(gie={})),function(e){var t=function(){function t(t){if(this._updateCache=new Array,this.updateCacheReset=new Array,this.time=0,this.scaleX=1,this.scaleY=1,this.x=0,this.y=0,null==t)throw new Error("data cannot be null.");this.data=t,this.bones=new Array;for(var n=0;n1){var o=i[i.length-1];this._updateCache.indexOf(o)>-1||this.updateCacheReset.push(o)}this._updateCache.push(t),this.sortReset(r.children),i[i.length-1].sorted=!0}},t.prototype.sortPathConstraint=function(t){if(t.active=t.target.bone.isActive()&&(!t.data.skinRequired||null!=this.skin&&e.Utils.contains(this.skin.constraints,t.data,!0)),t.active){var n=t.target,i=n.data.index,r=n.bone;null!=this.skin&&this.sortPathConstraintAttachment(this.skin,i,r),null!=this.data.defaultSkin&&this.data.defaultSkin!=this.skin&&this.sortPathConstraintAttachment(this.data.defaultSkin,i,r);for(var o=0,a=this.data.skins.length;o-1||this.updateCacheReset.push(o)}else for(r=0;r0){x=new e.DrawOrderTimeline(F);var B=r.slots.length;for(u=0;u=0;_--)k[_]=-1;var U=e.Utils.newArray(B-z,0),G=0,H=0;for(_=0;_=0;_--)-1==k[_]&&(k[_]=U[--H]);x.setFrame(u,v,k)}o.push(x),s=Math.max(s,x.frames[F-1])}var V=n.readInt(!0);if(V>0){for(x=new e.EventTimeline(V),u=0;u>>1^-(1&n)},e.prototype.readStringRef=function(){var e=this.readInt(!0);return 0==e?null:this.strings[e-1]},e.prototype.readString=function(){var e=this.readInt(!0);switch(e){case 0:return null;case 1:return""}e--;for(var t="",n=0;n>4){case 12:case 13:t+=String.fromCharCode((31&i)<<6|63&this.readByte()),n+=2;break;case 14:t+=String.fromCharCode((15&i)<<12|(63&this.readByte())<<6|63&this.readByte()),n+=3;break;default:t+=String.fromCharCode(i),n++}}return t},e.prototype.readFloat=function(){var e=this.buffer.getFloat32(this.index);return this.index+=4,e},e.prototype.readBoolean=function(){return 0!=this.readByte()},e}(),i=function(e,t,n,i,r){this.mesh=e,this.skin=t,this.slotIndex=n,this.parent=i,this.inheritDeform=r},r=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.bones=e,this.vertices=t}}(gie||(gie={})),function(e){var t=function(){function t(){this.minX=0,this.minY=0,this.maxX=0,this.maxY=0,this.boundingBoxes=new Array,this.polygons=new Array,this.polygonPool=new e.Pool((function(){return e.Utils.newFloatArray(16)}))}return t.prototype.update=function(t,n){if(null==t)throw new Error("skeleton cannot be null.");var i=this.boundingBoxes,r=this.polygons,o=this.polygonPool,a=t.slots,s=a.length;i.length=0,o.freeAll(r),r.length=0;for(var c=0;c=this.minX&&e<=this.maxX&&t>=this.minY&&t<=this.maxY},t.prototype.aabbIntersectsSegment=function(e,t,n,i){var r=this.minX,o=this.minY,a=this.maxX,s=this.maxY;if(e<=r&&n<=r||t<=o&&i<=o||e>=a&&n>=a||t>=s&&i>=s)return!1;var c=(i-t)/(n-e),l=c*(r-e)+t;if(l>o&&lo&&lr&&ur&&ue.minX&&this.minYe.minY},t.prototype.containsPoint=function(e,t){for(var n=this.polygons,i=0,r=n.length;i=n||l=n){var u=i[s];u+(n-c)/(l-c)*(i[o]-u)=u&&y<=_||y>=_&&y<=u)&&(y>=t&&y<=i||y>=i&&y<=t)){var x=(l*g-c*d)/v;if((x>=h&&x<=p||x>=p&&x<=h)&&(x>=n&&x<=r||x>=r&&x<=n))return!0}u=_,h=p}return!1},t.prototype.getPolygon=function(e){if(null==e)throw new Error("boundingBox cannot be null.");var t=this.boundingBoxes.indexOf(e);return-1==t?null:this.polygons[t]},t.prototype.getWidth=function(){return this.maxX-this.minX},t.prototype.getHeight=function(){return this.maxY-this.minY},t}();e.SkeletonBounds=t}(gie||(gie={})),function(e){var t=function(){function t(){this.triangulator=new e.Triangulator,this.clippingPolygon=new Array,this.clipOutput=new Array,this.clippedVertices=new Array,this.clippedTriangles=new Array,this.scratch=new Array}return t.prototype.clipStart=function(n,i){if(null!=this.clipAttachment)return 0;this.clipAttachment=i;var r=i.worldVerticesLength,o=e.Utils.setArraySize(this.clippingPolygon,r);i.computeWorldVertices(n,0,r,o,0,2);var a=this.clippingPolygon;t.makeClockwise(a);for(var s=this.clippingPolygons=this.triangulator.decompose(a,this.triangulator.triangulate(a)),c=0,l=s.length;c>1,H=this.clipOutput,V=e.Utils.setArraySize(_,N+G*g),j=0;j=2?(u=s,s=this.scratch):u=this.scratch,u.length=0,u.push(e),u.push(t),u.push(n),u.push(i),u.push(r),u.push(o),u.push(e),u.push(t),s.length=0;for(var h=a,f=a.length-4,_=0;;_+=2){for(var p=h[_],d=h[_+1],m=h[_+2],g=h[_+3],v=p-m,y=d-g,x=u,S=u.length-2,T=s.length,E=0;E0;if(v*(C-g)-y*(A-m)>0){if(R){s.push(b),s.push(w);continue}var P=(D=w-C)*(m-p)-(O=b-A)*(g-d);if(Math.abs(P)>1e-6){var I=(O*(d-C)-D*(p-A))/P;s.push(p+(m-p)*I),s.push(d+(g-d)*I)}else s.push(p),s.push(d)}else if(R){var D,O;P=(D=w-C)*(m-p)-(O=b-A)*(g-d),Math.abs(P)>1e-6?(I=(O*(d-C)-D*(p-A))/P,s.push(p+(m-p)*I),s.push(d+(g-d)*I)):(s.push(p),s.push(d)),s.push(b),s.push(w)}l=!0}if(T==s.length)return c.length=0,!0;if(s.push(s[0]),s.push(s[1]),_==f)break;var M=s;(s=u).length=0,u=M}if(c!=s){c.length=0,_=0;for(var N=s.length-2;_>1;s=0;f--)-1==q[f]&&(q[f]=Y[--Q])}x.setFrame(h++,this.getValue(W,"time",0),q)}o.push(x),a=Math.max(a,x.frames[x.getFrameCount()-1])}if(t.events){for(x=new e.EventTimeline(t.events.length),h=0,f=0;f=i.length&&(i.length=e+1),i[e]||(i[e]={}),i[e][t]=n},n.prototype.addSkin=function(e){for(var t=0;t= 0.");if(null==n)throw new Error("name cannot be null.");if(null==i)throw new Error("boneData cannot be null.");this.index=t,this.name=n,this.boneData=i}}(gie||(gie={})),function(e){var t,n,i=function(){function e(e){this._image=e}return e.prototype.getImage=function(){return this._image},e.filterFromString=function(e){switch(e.toLowerCase()){case"nearest":return t.Nearest;case"linear":return t.Linear;case"mipmap":return t.MipMap;case"mipmapnearestnearest":return t.MipMapNearestNearest;case"mipmaplinearnearest":return t.MipMapLinearNearest;case"mipmapnearestlinear":return t.MipMapNearestLinear;case"mipmaplinearlinear":return t.MipMapLinearLinear;default:throw new Error("Unknown texture filter "+e)}},e.wrapFromString=function(e){switch(e.toLowerCase()){case"mirroredtepeat":return n.MirroredRepeat;case"clamptoedge":return n.ClampToEdge;case"repeat":return n.Repeat;default:throw new Error("Unknown texture wrap "+e)}},e}();e.Texture=i,function(e){e[e.Nearest=9728]="Nearest",e[e.Linear=9729]="Linear",e[e.MipMap=9987]="MipMap",e[e.MipMapNearestNearest=9984]="MipMapNearestNearest",e[e.MipMapLinearNearest=9985]="MipMapLinearNearest",e[e.MipMapNearestLinear=9986]="MipMapNearestLinear",e[e.MipMapLinearLinear=9987]="MipMapLinearLinear"}(t=e.TextureFilter||(e.TextureFilter={})),function(e){e[e.MirroredRepeat=33648]="MirroredRepeat",e[e.ClampToEdge=33071]="ClampToEdge",e[e.Repeat=10497]="Repeat"}(n=e.TextureWrap||(e.TextureWrap={}));e.TextureRegion=function(){this.u=0,this.v=0,this.u2=0,this.v2=0,this.width=0,this.height=0,this.rotate=!1,this.offsetX=0,this.offsetY=0,this.originalWidth=0,this.originalHeight=0};var r=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return vie(t,e),t.prototype.setFilters=function(){},t.prototype.setWraps=function(){},t.prototype.dispose=function(){},t}(i);e.FakeTexture=r}(gie||(gie={})),function(e){var t=function(){function t(e,t){this.pages=new Array,this.regions=new Array,this.load(e,t)}return t.prototype.load=function(t,o){if(null==o)throw new Error("textureLoader cannot be null.");for(var a=new n(t),s=new Array(4),c=null;;){var l=a.readLine();if(null==l)break;if(0==(l=l.trim()).length)c=null;else if(c){var u=new r;u.name=l,u.page=c;var h=a.readValue();"true"==h.toLocaleLowerCase()?u.degrees=90:"false"==h.toLocaleLowerCase()?u.degrees=0:u.degrees=parseFloat(h),u.rotate=90==u.degrees,a.readTuple(s);var f=parseInt(s[0]),_=parseInt(s[1]);a.readTuple(s);var p=parseInt(s[0]),d=parseInt(s[1]);u.u=f/c.width,u.v=_/c.height,u.rotate?(u.u2=(f+d)/c.width,u.v2=(_+p)/c.height):(u.u2=(f+p)/c.width,u.v2=(_+d)/c.height),u.x=f,u.y=_,u.width=Math.abs(p),u.height=Math.abs(d),4==a.readTuple(s)&&4==a.readTuple(s)&&a.readTuple(s),u.originalWidth=parseInt(s[0]),u.originalHeight=parseInt(s[1]),a.readTuple(s),u.offsetX=parseInt(s[0]),u.offsetY=parseInt(s[1]),u.index=parseInt(a.readValue()),u.texture=c.texture,this.regions.push(u)}else{(c=new i).name=l,2==a.readTuple(s)&&(c.width=parseInt(s[0]),c.height=parseInt(s[1]),a.readTuple(s)),a.readTuple(s),c.minFilter=e.Texture.filterFromString(s[0]),c.magFilter=e.Texture.filterFromString(s[1]);var m=a.readValue();c.uWrap=e.TextureWrap.ClampToEdge,c.vWrap=e.TextureWrap.ClampToEdge,"x"==m?c.uWrap=e.TextureWrap.Repeat:"y"==m?c.vWrap=e.TextureWrap.Repeat:"xy"==m&&(c.uWrap=c.vWrap=e.TextureWrap.Repeat),c.texture=o(l),c.texture.setFilters(c.minFilter,c.magFilter),c.texture.setWraps(c.uWrap,c.vWrap),c.width=c.texture.getImage().width,c.height=c.texture.getImage().height,this.pages.push(c)}}},t.prototype.findRegion=function(e){for(var t=0;t=this.lines.length?null:this.lines[this.index++]},e.prototype.readValue=function(){var e=this.readLine(),t=e.indexOf(":");if(-1==t)throw new Error("Invalid line: "+e);return e.substring(t+1).trim()},e.prototype.readTuple=function(e){var t=this.readLine(),n=t.indexOf(":");if(-1==n)throw new Error("Invalid line: "+t);for(var i=0,r=n+1;i<3;i++){var o=t.indexOf(",",r);if(-1==o)break;e[i]=t.substr(r,o-r).trim(),r=o+1}return e[i]=t.substring(r).trim(),i+1},e}(),i=function(){};e.TextureAtlasPage=i;var r=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return vie(t,e),t}(e.TextureRegion);e.TextureAtlasRegion=r}(gie||(gie={})),function(e){var t=function(){function t(t,n){if(this.rotateMix=0,this.translateMix=0,this.scaleMix=0,this.shearMix=0,this.temp=new e.Vector2,this.active=!1,null==t)throw new Error("data cannot be null.");if(null==n)throw new Error("skeleton cannot be null.");this.data=t,this.rotateMix=t.rotateMix,this.translateMix=t.translateMix,this.scaleMix=t.scaleMix,this.shearMix=t.shearMix,this.bones=new Array;for(var i=0;i0?e.MathUtils.degRad:-e.MathUtils.degRad,h=this.data.offsetRotation*u,f=this.data.offsetShearY*u,_=this.bones,p=0,d=_.length;pe.MathUtils.PI?w-=e.MathUtils.PI2:w<-e.MathUtils.PI&&(w+=e.MathUtils.PI2),w*=t;var T=Math.cos(w),E=Math.sin(w);m.a=T*v-E*x,m.b=T*y-E*S,m.c=E*v+T*x,m.d=E*y+T*S,g=!0}if(0!=n){var A=this.temp;o.localToWorld(A.set(this.data.offsetX,this.data.offsetY)),m.worldX+=(A.x-m.worldX)*n,m.worldY+=(A.y-m.worldY)*n,g=!0}if(i>0){var C=Math.sqrt(m.a*m.a+m.c*m.c),b=Math.sqrt(a*a+c*c);C>1e-5&&(C=(C+(b-C+this.data.offsetScaleX)*i)/C),m.a*=C,m.c*=C,C=Math.sqrt(m.b*m.b+m.d*m.d),b=Math.sqrt(s*s+l*l),C>1e-5&&(C=(C+(b-C+this.data.offsetScaleY)*i)/C),m.b*=C,m.d*=C,g=!0}if(r>0){y=m.b,S=m.d;var w,R=Math.atan2(S,y);(w=Math.atan2(l,s)-Math.atan2(c,a)-(R-Math.atan2(m.c,m.a)))>e.MathUtils.PI?w-=e.MathUtils.PI2:w<-e.MathUtils.PI&&(w+=e.MathUtils.PI2),w=R+(w+f)*r,C=Math.sqrt(y*y+S*S),m.b=Math.cos(w)*C,m.d=Math.sin(w)*C,g=!0}g&&(m.appliedValid=!1)}},t.prototype.applyRelativeWorld=function(){for(var t=this.rotateMix,n=this.translateMix,i=this.scaleMix,r=this.shearMix,o=this.target,a=o.a,s=o.b,c=o.c,l=o.d,u=a*l-s*c>0?e.MathUtils.degRad:-e.MathUtils.degRad,h=this.data.offsetRotation*u,f=this.data.offsetShearY*u,_=this.bones,p=0,d=_.length;pe.MathUtils.PI?m-=e.MathUtils.PI2:m<-e.MathUtils.PI&&(m+=e.MathUtils.PI2),m*=t;var E=Math.cos(m),A=Math.sin(m);g.a=E*y-A*S,g.b=E*x-A*T,g.c=A*y+E*S,g.d=A*x+E*T,v=!0}if(0!=n){var C=this.temp;o.localToWorld(C.set(this.data.offsetX,this.data.offsetY)),g.worldX+=C.x*n,g.worldY+=C.y*n,v=!0}if(i>0){var b=(Math.sqrt(a*a+c*c)-1+this.data.offsetScaleX)*i+1;g.a*=b,g.c*=b,b=(Math.sqrt(s*s+l*l)-1+this.data.offsetScaleY)*i+1,g.b*=b,g.d*=b,v=!0}if(r>0)(m=Math.atan2(l,s)-Math.atan2(c,a))>e.MathUtils.PI?m-=e.MathUtils.PI2:m<-e.MathUtils.PI&&(m+=e.MathUtils.PI2),x=g.b,T=g.d,m=Math.atan2(T,x)+(m-e.MathUtils.PI/2+f)*r,b=Math.sqrt(x*x+T*T),g.b=Math.cos(m)*b,g.d=Math.sin(m)*b,v=!0;v&&(g.appliedValid=!1)}},t.prototype.applyAbsoluteLocal=function(){var e=this.rotateMix,t=this.translateMix,n=this.scaleMix,i=this.shearMix,r=this.target;r.appliedValid||r.updateAppliedTransform();for(var o=this.bones,a=0,s=o.length;a1e-5&&(_=(_+(r.ascaleX-_+this.data.offsetScaleX)*n)/_),p>1e-5&&(p=(p+(r.ascaleY-p+this.data.offsetScaleY)*n)/p));var d=c.ashearY;0!=i&&(u=r.ashearY-d+this.data.offsetShearY,u-=360*(16384-(16384.499999999996-u/360|0)),c.shearY+=u*i),c.updateWorldTransformWith(h,f,l,_,p,c.ashearX,d)}},t.prototype.applyRelativeLocal=function(){var e=this.rotateMix,t=this.translateMix,n=this.scaleMix,i=this.shearMix,r=this.target;r.appliedValid||r.updateAppliedTransform();for(var o=this.bones,a=0,s=o.length;a1e-5&&(f*=(r.ascaleX-1+this.data.offsetScaleX)*n+1),_>1e-5&&(_*=(r.ascaleY-1+this.data.offsetScaleY)*n+1));var p=c.ashearY;0!=i&&(p+=(r.ashearY+this.data.offsetShearY)*i),c.updateWorldTransformWith(u,h,l,f,_,c.ashearX,p)}},t}();e.TransformConstraint=t}(gie||(gie={})),function(e){var t=function(e){function t(t){var n=e.call(this,t,0,!1)||this;return n.bones=new Array,n.rotateMix=0,n.translateMix=0,n.scaleMix=0,n.shearMix=0,n.offsetRotation=0,n.offsetX=0,n.offsetY=0,n.offsetScaleX=0,n.offsetScaleY=0,n.offsetShearY=0,n.relative=!1,n.local=!1,n}return vie(t,e),t}(e.ConstraintData);e.TransformConstraintData=t}(gie||(gie={})),function(e){var t=function(){function t(){this.convexPolygons=new Array,this.convexPolygonsIndices=new Array,this.indicesArray=new Array,this.isConcaveArray=new Array,this.triangles=new Array,this.polygonPool=new e.Pool((function(){return new Array})),this.polygonIndicesPool=new e.Pool((function(){return new Array}))}return t.prototype.triangulate=function(e){var n=e,i=e.length>>1,r=this.indicesArray;r.length=0;for(var o=0;o3;){for(var l=i-1,u=(o=0,1);;){e:if(!a[o]){for(var h=r[l]<<1,f=r[o]<<1,_=r[u]<<1,p=n[h],d=n[h+1],m=n[f],g=n[f+1],v=n[_],y=n[_+1],x=(u+1)%i;x!=l;x=(x+1)%i)if(a[x]){var S=r[x]<<1,T=n[S],E=n[S+1];if(t.positiveArea(v,y,p,d,T,E)&&t.positiveArea(p,d,m,g,T,E)&&t.positiveArea(m,g,v,y,T,E))break e}break}if(0==u){do{if(!a[o])break;o--}while(o>0);break}l=o,o=u,u=(u+1)%i}c.push(r[(i+o-1)%i]),c.push(r[o]),c.push(r[(o+1)%i]),r.splice(o,1),a.splice(o,1);var A=(--i+o-1)%i,C=o==i?0:o;a[A]=t.isConcave(A,i,n,r),a[C]=t.isConcave(C,i,n,r)}return 3==i&&(c.push(r[2]),c.push(r[0]),c.push(r[1])),c},t.prototype.decompose=function(e,n){var i=e,r=this.convexPolygons;this.polygonPool.freeAll(r),r.length=0;var o=this.convexPolygonsIndices;this.polygonIndicesPool.freeAll(o),o.length=0;var a=this.polygonIndicesPool.obtain();a.length=0;var s=this.polygonPool.obtain();s.length=0;for(var c=-1,l=0,u=0,h=n.length;u0?(r.push(s),o.push(a)):(this.polygonPool.free(s),this.polygonIndicesPool.free(a)),(s=this.polygonPool.obtain()).length=0,s.push(d),s.push(m),s.push(g),s.push(v),s.push(y),s.push(x),(a=this.polygonIndicesPool.obtain()).length=0,a.push(f),a.push(_),a.push(p),l=t.winding(d,m,g,v,y,x),c=f)}for(s.length>0&&(r.push(s),o.push(a)),u=0,h=r.length;u=0;u--)0==(s=r[u]).length&&(r.splice(u,1),this.polygonPool.free(s),a=o[u],o.splice(u,1),this.polygonIndicesPool.free(a));return r},t.isConcave=function(e,t,n,i){var r=i[(t+e-1)%t]<<1,o=i[e]<<1,a=i[(e+1)%t]<<1;return!this.positiveArea(n[r],n[r+1],n[o],n[o+1],n[a],n[a+1])},t.positiveArea=function(e,t,n,i,r,o){return e*(o-i)+n*(t-o)+r*(i-t)>=0},t.winding=function(e,t,n,i,r,o){var a=n-e,s=i-t;return r*s-o*a+a*t-e*s>=0?1:-1},t}();e.Triangulator=t}(gie||(gie={})),function(e){var t=function(){function e(){this.array=new Array}return e.prototype.add=function(e){var t=this.contains(e);return this.array[0|e]=0|e,!t},e.prototype.contains=function(e){return null!=this.array[0|e]},e.prototype.remove=function(e){this.array[0|e]=void 0},e.prototype.clear=function(){this.array.length=0},e}();e.IntSet=t;var n=function(){function e(e,t,n,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),this.r=e,this.g=t,this.b=n,this.a=i}return e.prototype.set=function(e,t,n,i){return this.r=e,this.g=t,this.b=n,this.a=i,this.clamp(),this},e.prototype.setFromColor=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a,this},e.prototype.setFromString=function(e){return e="#"==e.charAt(0)?e.substr(1):e,this.r=parseInt(e.substr(0,2),16)/255,this.g=parseInt(e.substr(2,2),16)/255,this.b=parseInt(e.substr(4,2),16)/255,this.a=(8!=e.length?255:parseInt(e.substr(6,2),16))/255,this},e.prototype.add=function(e,t,n,i){return this.r+=e,this.g+=t,this.b+=n,this.a+=i,this.clamp(),this},e.prototype.clamp=function(){return this.r<0?this.r=0:this.r>1&&(this.r=1),this.g<0?this.g=0:this.g>1&&(this.g=1),this.b<0?this.b=0:this.b>1&&(this.b=1),this.a<0?this.a=0:this.a>1&&(this.a=1),this},e.rgba8888ToColor=function(e,t){e.r=((4278190080&t)>>>24)/255,e.g=((16711680&t)>>>16)/255,e.b=((65280&t)>>>8)/255,e.a=(255&t)/255},e.rgb888ToColor=function(e,t){e.r=((16711680&t)>>>16)/255,e.g=((65280&t)>>>8)/255,e.b=(255&t)/255},e.WHITE=new e(1,1,1,1),e.RED=new e(1,0,0,1),e.GREEN=new e(0,1,0,1),e.BLUE=new e(0,0,1,1),e.MAGENTA=new e(1,0,1,1),e}();e.Color=n;var i=function(){function e(){}return e.clamp=function(e,t,n){return en?n:e},e.cosDeg=function(t){return Math.cos(t*e.degRad)},e.sinDeg=function(t){return Math.sin(t*e.degRad)},e.signum=function(e){return e>0?1:e<0?-1:0},e.toInt=function(e){return e>0?Math.floor(e):Math.ceil(e)},e.cbrt=function(e){var t=Math.pow(Math.abs(e),1/3);return e<0?-t:t},e.randomTriangular=function(t,n){return e.randomTriangularWith(t,n,.5*(t+n))},e.randomTriangularWith=function(e,t,n){var i=Math.random(),r=t-e;return i<=(n-e)/r?e+Math.sqrt(i*r*(n-e)):t-Math.sqrt((1-i)*r*(t-n))},e.PI=3.1415927,e.PI2=2*e.PI,e.radiansToDegrees=180/e.PI,e.radDeg=e.radiansToDegrees,e.degreesToRadians=e.PI/180,e.degRad=e.degreesToRadians,e}();e.MathUtils=i;var r=function(){function e(){}return e.prototype.apply=function(e,t,n){return e+(t-e)*this.applyInternal(n)},e}();e.Interpolation=r;var o=function(e){function t(t){var n=e.call(this)||this;return n.power=2,n.power=t,n}return vie(t,e),t.prototype.applyInternal=function(e){return e<=.5?Math.pow(2*e,this.power)/2:Math.pow(2*(e-1),this.power)/(this.power%2==0?-2:2)+1},t}(r);e.Pow=o;var a=function(e){function t(t){return e.call(this,t)||this}return vie(t,e),t.prototype.applyInternal=function(e){return Math.pow(e-1,this.power)*(this.power%2==0?-1:1)+1},t}(o);e.PowOut=a;var s=function(){function e(){}return e.arrayCopy=function(e,t,n,i,r){for(var o=t,a=i;o=n?t:e.setArraySize(t,n,i)},e.newArray=function(e,t){for(var n=new Array(e),i=0;i0?this.items.pop():this.instantiator()},e.prototype.free=function(e){e.reset&&e.reset(),this.items.push(e)},e.prototype.freeAll=function(e){for(var t=0;tthis.maxDelta&&(this.delta=this.maxDelta),this.lastTime=e,this.frameCount++,this.frameTime>1&&(this.framesPerSecond=this.frameCount/this.frameTime,this.frameTime=0,this.frameCount=0)},e}();e.TimeKeeper=h;var f=function(){function e(e){void 0===e&&(e=32),this.addedValues=0,this.lastValue=0,this.mean=0,this.dirty=!0,this.values=new Array(e)}return e.prototype.hasEnoughData=function(){return this.addedValues>=this.values.length},e.prototype.addValue=function(e){this.addedValuesthis.values.length-1&&(this.lastValue=0),this.dirty=!0},e.prototype.getMean=function(){if(this.hasEnoughData()){if(this.dirty){for(var e=0,t=0;t>1)*o;var a=e.bone.skeleton,s=e.deform,c=this.vertices,l=this.bones;if(null!=l){for(var u=0,h=0,f=0;f0&&(c=s);for(var x,S=(x=e.bone).worldX,T=x.worldY,E=x.a,A=x.b,C=x.c,b=x.d,w=t,R=r;R>>0)+(Vie.b<<16)+(Vie.g<<8)+Vie.r,Aie=(jie.a<<24>>>0)+(jie.b<<16)+(jie.g<<8)+jie.r,kie!==Eie||Uie!==Aie){var o=this._tempColors;kie=Eie,Uie=Aie,zie>0&&(o[zie-1].vfOffset=Oie),o[zie++]={fr:Vie.r,fg:Vie.g,fb:Vie.b,fa:Vie.a,dr:jie.r,dg:jie.g,db:jie.b,da:jie.a,vfOffset:0}}if(i.isClipping()){i.clipTriangles(Rie,Gie,Pie,Hie,Rie,Vie,jie,!0,6,Oie,Oie+2);var a=i.clippedVertices,s=i.clippedTriangles;Hie=s.length,Gie=a.length/12*6;for(var c=0,l=Die,u=s.length;c0&&(o[zie-1].vfOffset=Oie),o.length=zie,a.length=Iie;var s=Bie-1;if(s>=0)if(Fie>0){var c=r[s];c.indexCount=Fie,c.vfCount=13*Lie,c.vertexCount=Lie,r.length=Bie}else r.length=Bie-1;if(0!==r.length){var l=i.vertices,u=Oie/6,h=13*u;(!l||l.lengththis.maxVertexCount?u:this.maxVertexCount,this.maxIndexCount=p.length>this.maxIndexCount?p.length:this.maxIndexCount}},t.needToUpdate=function(e){return!this.isCompleted&&this.totalTime<30&&(void 0===e||this._frameIdx=0&&(Fie>0?((h=p[u]).indexCount=Fie,h.vertexCount=Lie,h.vfCount=13*Lie):Bie--),p[Bie]={tex:l,blendMode:f,indexCount:0,vertexCount:0,vfCount:0},Bie++,Fie=0,Lie=0),s)a=Wie,Gie=24,Hie=6,n.computeWorldVertices(_.bone,Rie,Oie,6);else if(c){var A=n;a=A.triangles,Gie=6*(A.worldVerticesLength>>1),Hie=a.length,A.computeWorldVertices(_,0,A.worldVerticesLength,Rie,Oie,6)}if(0!==Gie&&0!==Hie){for(var C=0,b=Die,w=a.length;C0){for(var D=Die,O=Die+Hie;D>8&255)/255,t[n+2]=(e>>16&255)/255,t[n+3]=(e>>24&255)/255},e}(),Xie=function(){function e(){this._privateMode=void 0,this._skeletonCache=void 0,this._animationPool=void 0,this._privateMode=!1,this._animationPool={},this._skeletonCache={}}var t=e.prototype;return t.enablePrivateMode=function(){this._privateMode=!0},t.clear=function(){this._animationPool={},this._skeletonCache={}},t.removeSkeleton=function(e){var t=this._skeletonCache[e];if(t){var n=t.animationsCache;for(var i in n){var r=n[i];r&&(this._animationPool[e+"#"+i]=r,r.clear())}delete this._skeletonCache[e]}},t.getSkeletonCache=function(e,t){var n=this._skeletonCache[e];if(!n){var i=new Cie.Skeleton(t),r=new Cie.SkeletonClipping,o=new Cie.AnimationStateData(i.data),a=new Cie.AnimationState(o),s=new bie;a.addListener(s),this._skeletonCache[e]=n={skeleton:i,clipper:r,state:a,listener:s,animationsCache:{},curAnimationCache:null}}return n},t.getAnimationCache=function(e,t){var n=this._skeletonCache[e];return n?n.animationsCache[t]:null},t.invalidAnimationCache=function(e){var t=this._skeletonCache[e];if(t&&t.skeleton){var n=t.animationsCache;for(var i in n)n[i].invalidAllFrame()}},t.initAnimationCache=function(e,t){if(!t)return null;var n=this._skeletonCache[e],i=n&&n.skeleton;if(!i)return null;if(!i.data.findAnimation(t))return null;var r=n.animationsCache,o=r[t];if(!o){var a=e+"#"+t;(o=this._animationPool[a])?delete this._animationPool[a]:(o=new qie)._privateMode=this._privateMode,o.init(n,t),r[t]=o}return o},t.updateAnimationCache=function(e,t){if(t){var n=this.initAnimationCache(e,t);if(!n)return;n.updateAllFrame()}else{var i=this._skeletonCache[e];if(!i||!i.skeleton)return;var r=i.animationsCache;for(var o in r)r[o].updateAllFrame()}},e}();Xie.FrameTime=wie,Xie.sharedCache=new Xie;var Yie,Kie,Qie,Zie,Jie,$ie,ere,tre,nre,ire,rre,ore=new Gn,are=new bn,sre=function(){function e(){this._inited=!1,this._skeleton=null,this._skeletonNode=null,this._skeletonComp=null,this._inited=!1,this._skeleton=null,this._skeletonNode=null,this._skeletonComp=null}var t=e.prototype;return t.init=function(e){this._inited=!0,this._skeleton=e._skeleton,this._skeletonNode=e.node,this._skeletonComp=e},t.reset=function(){this._inited=!1,this._skeleton=null,this._skeletonNode=null,this._skeletonComp=null},t._syncAttachedNode=function(){if(this._inited){var e=this._skeletonComp.socketNodes;if(0!==e.size){var t;if(t=this._skeletonComp.isAnimationCached()?this._skeletonComp._curFrame&&this._skeletonComp._curFrame.boneInfos:this._skeleton.bones)for(var n,i=function(e,t){are.set(e.scale);var n=ore;n.m00=t.a,n.m01=t.c,n.m04=t.b,n.m05=t.d,n.m12=t.worldX,n.m13=t.worldY,e.matrix=ore,e.scale=are},r=oe(e.keys());!(n=r()).done;){var o=n.value,a=e.get(o);if(a&&a.isValid){var s=t[o];s?i(a,s):(a.removeFromParent(),a.destroy(),e.delete(o))}else e.delete(o)}}}},e}(),cre=function(e){function t(t){var n;return(n=e.call(this,t)||this).name="sp.SkeletonTexture",n._texture=null,n._material=null,n}Z(t,e);var n=t.prototype;return n.setRealTexture=function(e){this._texture=e},n.getRealTexture=function(){return this._texture},n.setFilters=function(e,t){this._texture&&this.getRealTexture().setFilters(lre(e),lre(t))},n.setWraps=function(e,t){this._texture&&this.getRealTexture().setWrapMode(ure(e),ure(t))},n.dispose=function(){},t}(Cie.Texture);function lre(e){switch(e){case Cie.TextureFilter.Nearest:case Cie.TextureFilter.MipMapNearestNearest:case Cie.TextureFilter.MipMapLinearNearest:return Rm.NEAREST;case Cie.TextureFilter.MipMap:case Cie.TextureFilter.MipMapNearestLinear:case Cie.TextureFilter.MipMapLinearLinear:case Cie.TextureFilter.Linear:default:return Rm.LINEAR}}function ure(e){switch(e){case Cie.TextureWrap.MirroredRepeat:return wm.MIRRORED_REPEAT;case Cie.TextureWrap.ClampToEdge:return wm.CLAMP_TO_EDGE;case Cie.TextureWrap.Repeat:default:return wm.REPEAT}}var hre=(Yie=hc("sp.SkeletonData"),Kie=Wc([vg]),Qie=Wc([Mt]),Yie((rre=function(e){function t(){var t;return ae(t=e.call(this)||this,"_skeletonJson",$ie,ie(t)),ae(t,"textures",ere,ie(t)),ae(t,"textureNames",tre,ie(t)),ae(t,"scale",nre,ie(t)),ae(t,"_atlasText",ire,ie(t)),t._buffer=void 0,t._skeletonCache=null,t._atlasCache=null,t._skinsEnum=null,t._animsEnum=null,t.reset(),t}Z(t,e);var n=t.prototype;return n.createNode=function(e){var t=new kC(this.name);return t.addComponent("cc.Skeleton").skeletonData=this,e(null,t)},n.reset=function(){this._skeletonCache=null,this._atlasCache=null},n.resetEnums=function(){},n.getRuntimeData=function(e){if(this._skeletonCache)return this._skeletonCache;if(!(this.textures&&this.textures.length>0)&&this.textureNames&&this.textureNames.length>0)return e||console.error(this.name+" no textures found!"),null;var t=this._getAtlas(e);if(!t)return null;var n=new Cie.AtlasAttachmentLoader(t),i=null,r=null;return this.skeletonJson?(r=new Cie.SkeletonJson(n),i=this.skeletonJson):(r=new Cie.SkeletonBinary(n),i=new Uint8Array(this._nativeAsset)),r.scale=this.scale,this._skeletonCache=r.readSkeletonData(i),t.dispose(),this._skeletonCache},n.getSkinsEnum=function(){if(this._skinsEnum)return this._skinsEnum;var e=this.getRuntimeData(!0);if(e){for(var t=e.skins,n={},i=0;i1)return this._animsEnum;var e=this.getRuntimeData(!0);if(e){for(var t={"":0},n=e.animations,i=0;i"]=0]=""}(uoe||(uoe={})),at(uoe),function(e){e[e.REALTIME=0]="REALTIME",e[e.SHARED_CACHE=1]="SHARED_CACHE",e[e.PRIVATE_CACHE=2]="PRIVATE_CACHE"}(hoe||(hoe={})),at(hoe),function(e){e[e.COLORED_TEXTURED=0]="COLORED_TEXTURED",e[e.TWO_COLORED=1]="TWO_COLORED"}(foe||(foe={}));var doe=(fre=hc("sp.Skeleton.SpineSocket"),_re=Wc(kC),fre((mre=se((dre=function(e,t){void 0===e&&(e=""),void 0===t&&(t=null),ae(this,"path",mre,this),ae(this,"target",gre,this),this.path=e,this.target=t}).prototype,"path",[gc,Rc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),gre=se(dre.prototype,"target",[_re,Rc,gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),pre=dre))||pre);tt.setClassAlias(doe,"sp.Skeleton.SpineSocket");var moe=(vre=hc("sp.Skeleton"),yre=wc(),xre=Ec(),Sre=Wc(iv),Tre=zc(),Ere=Dc(),Are=Wc(hre),Cre=Dc(),bre=Wc(loe),wre=Oc(),Rre=Dc(),Pre=Wc(uoe),Ire=Oc(),Dre=Dc(),Ore=Oc(),Mre=Wc(hoe),Nre=Oc(),Lre=Oc(),Fre=Oc(),Bre=Oc(),zre=Oc(),kre=Oc(),Ure=Oc(),Gre=Wc([doe]),Hre=Oc(),Vre=Pc(),jre=Pc(),vre(Wre=yre(Wre=xre(Wre=Tc((coe=soe=function(e){function t(){var t;return ae(t=e.call(this)||this,"loop",Xre,ie(t)),t.enableBatch=!1,t._frameCache=null,t._curFrame=null,t._effectDelegate=null,t._skeleton=void 0,t._clipper=void 0,t._debugRenderer=void 0,t._startSlotIndex=void 0,t._endSlotIndex=void 0,t._startEntry=void 0,t._endEntry=void 0,t.attachUtil=void 0,t.maxVertexCount=0,t.maxIndexCount=0,t._materialCache={},t._enumSkins=it({}),t._enumAnimations=it({}),t._playTimes=0,ae(t,"_timeScale",Yre,ie(t)),t._paused=!1,t._accTime=0,t._playCount=0,t._skeletonCache=null,t._animationName="",t._animationQueue=[],t._headAniInfo=null,t._isAniComplete=!0,ae(t,"_useTint",Kre,ie(t)),ae(t,"_preCacheMode",Qre,ie(t)),ae(t,"_cacheMode",Zre,ie(t)),ae(t,"_defaultCacheMode",Jre,ie(t)),ae(t,"_debugBones",$re,ie(t)),ae(t,"_debugSlots",eoe,ie(t)),ae(t,"_skeletonData",toe,ie(t)),ae(t,"_premultipliedAlpha",noe,ie(t)),ae(t,"defaultSkin",ioe,ie(t)),ae(t,"defaultAnimation",roe,ie(t)),ae(t,"_sockets",ooe,ie(t)),t._drawIdx=0,t._drawList=new Gl((function(){return{material:null,texture:null,indexOffset:0,indexCount:0}}),1),ae(t,"_debugMesh",aoe,ie(t)),t._rootBone=void 0,t._state=void 0,t._listener=void 0,t._socketNodes=new Map,t._cachedSockets=new Map,t._effectDelegate=null,t._skeleton=null,t._rootBone=null,t._listener=null,t._debugRenderer=null,t._startSlotIndex=-1,t._endSlotIndex=-1,t._startEntry={animation:{name:""},trackIndex:0},t._endEntry={animation:{name:""},trackIndex:0},t.attachUtil=new sre,poe(ie(t),"_defaultSkinIndex",t._enumSkins),poe(ie(t),"_animationIndex",t._enumAnimations),t}Z(t,e);var n=t.prototype;return n.setSkeletonData=function(e){var t=this.node._uiProps.uiTransformComp;if(null!=e.width&&null!=e.height&&t.setContentSize(e.width,e.height),this._cacheMode===hoe.SHARED_CACHE?this._skeletonCache=Xie.sharedCache:this._cacheMode===hoe.PRIVATE_CACHE&&(this._skeletonCache=new Xie,this._skeletonCache.enablePrivateMode()),this.isAnimationCached()){(this.debugBones||this.debugSlots)&&y("Debug bones or slots is invalid in cached mode");var n=this._skeletonCache.getSkeletonCache(this.skeletonData._uuid,e);this._skeleton=n.skeleton,this._clipper=n.clipper,this._rootBone=this._skeleton.getRootBone()}else this._skeleton=new Cie.Skeleton(e),this._clipper=new Cie.SkeletonClipping,this._rootBone=this._skeleton.getRootBone();this._flushAssembler()},n.setSlotsRange=function(e,t){this.isAnimationCached()?y("Slots visible range can not be modified in cached mode."):(this._startSlotIndex=e,this._endSlotIndex=t)},n.setAnimationStateData=function(e){if(this.isAnimationCached())y("'setAnimationStateData' interface can not be invoked in cached mode.");else{var t=new Cie.AnimationState(e);this._listener&&(this._state&&this._state.removeListener(this._listener),t.addListener(this._listener)),this._state=t}},n.__preload=function(){e.prototype.__preload.call(this);for(var t=this.node.children,n=0,i=t.length;nthis._headAniInfo.delay){var i=this._headAniInfo;this._headAniInfo=null,this.setAnimation(0,i.animationName,i.loop)}return}this._updateCache(e)}else this._updateRealtime(e)},n.setVertexEffectDelegate=function(e){this._effectDelegate=e},n.setToSetupPose=function(){this._skeleton&&this._skeleton.setToSetupPose()},n.setBonesToSetupPose=function(){this._skeleton&&this._skeleton.setBonesToSetupPose()},n.setSlotsToSetupPose=function(){this._skeleton&&this._skeleton.setSlotsToSetupPose()},n.updateAnimationCache=function(e){if(this.isAnimationCached()){var t=this._skeletonData._uuid;this._skeletonCache&&this._skeletonCache.updateAnimationCache(t,e)}},n.invalidAnimationCache=function(){this.isAnimationCached()&&this._skeletonCache&&this._skeletonCache.invalidAnimationCache(this._skeletonData._uuid)},n.findBone=function(e){return this._skeleton?this._skeleton.findBone(e):null},n.findSlot=function(e){return this._skeleton?this._skeleton.findSlot(e):null},n.setSkin=function(e){this._skeleton&&(this._skeleton.setSkinByName(e),this._skeleton.setSlotsToSetupPose()),this.invalidAnimationCache()},n.getAttachment=function(e,t){return this._skeleton?this._skeleton.getAttachmentByName(e,t):null},n.setAttachment=function(e,t){this._skeleton&&this._skeleton.setAttachment(e,t),this.invalidAnimationCache()},n.getTextureAtlas=function(e){return e.region},n.setMix=function(e,t,n){this._state&&this._state.data.setMix(e,t,n)},n.setAnimation=function(e,t,n){if(this._playTimes=n?0:1,this._animationName=t,this.isAnimationCached()){if(0!==e&&y("Track index can not greater than 0 in cached mode."),!this._skeletonCache)return null;var i=this._skeletonCache.getAnimationCache(this._skeletonData._uuid,t);i||(i=this._skeletonCache.initAnimationCache(this._skeletonData._uuid,t)),i&&(this._isAniComplete=!1,this._accTime=0,this._playCount=0,this._frameCache=i,this._socketNodes.size>0&&this._frameCache.enableCacheAttachedInfo(),this._frameCache.updateToFrame(0),this._curFrame=this._frameCache.frames[0])}else if(this._skeleton){var r=this._skeleton.data.findAnimation(t);if(!r)return w(7509,t),null;var o=this._state.setAnimationWith(e,r,n);return this._state.apply(this._skeleton),o}return null},n.addAnimation=function(e,t,n,i){if(i=i||0,this.isAnimationCached())0!==e&&y("Track index can not greater than 0 in cached mode."),this._animationQueue.push({animationName:t,loop:n,delay:i});else if(this._skeleton){var r,o=this._skeleton.data.findAnimation(t);return o?null===(r=this._state)||void 0===r?void 0:r.addAnimationWith(e,o,n,i):(w(7510,t),null)}return null},n.findAnimation=function(e){return this._skeleton?this._skeleton.data.findAnimation(e):null},n.getCurrent=function(e){if(this.isAnimationCached())y("'getCurrent' interface can not be invoked in cached mode.");else if(this._state)return this._state.getCurrent(e);return null},n.clearTracks=function(){this.isAnimationCached()?y("'clearTracks' interface can not be invoked in cached mode."):this._state&&(this._state.clearTracks(),this.setToSetupPose())},n.clearTrack=function(e){this.isAnimationCached()?y("'clearTrack' interface can not be invoked in cached mode."):this._state&&this._state.clearTrack(e)},n.setStartListener=function(e){this._ensureListener(),this._listener.start=e},n.setInterruptListener=function(e){this._ensureListener(),this._listener.interrupt=e},n.setEndListener=function(e){this._ensureListener(),this._listener.end=e},n.setDisposeListener=function(e){this._ensureListener(),this._listener.dispose=e},n.setCompleteListener=function(e){this._ensureListener(),this._listener.complete=e},n.setEventListener=function(e){this._ensureListener(),this._listener.event=e},n.setTrackStartListener=function(e,t){bie.getListeners(e).start=t},n.setTrackInterruptListener=function(e,t){bie.getListeners(e).interrupt=t},n.setTrackEndListener=function(e,t){bie.getListeners(e).end=t},n.setTrackDisposeListener=function(e,t){bie.getListeners(e).dispose=t},n.setTrackCompleteListener=function(e,t){bie.getListeners(e).complete=function(e){var n=Math.floor(e.trackTime/e.animationEnd);t(e,n)}},n.setTrackEventListener=function(e,t){bie.getListeners(e).event=t},n.getState=function(){return this._state},n.onEnable=function(){e.prototype.onEnable.call(this),this._flushAssembler(),_oe.getInstance().add(this)},n.onDisable=function(){e.prototype.onDisable.call(this),_oe.getInstance().remove(this)},n.onDestroy=function(){this._cleanMaterialCache(),this._drawList.destroy(),e.prototype.onDestroy.call(this)},n.destroyRenderData=function(){this._drawList.reset(),e.prototype.destroyRenderData.call(this)},n.getMaterialForBlendAndTint=function(e,t,n){var i=n+"/"+e+"/"+t,r=this._materialCache[i];if(r)return r;var o=this.customMaterial;null===o&&(o=wg.get("default-spine-material"));var a=!1;switch(n){case foe.TWO_COLORED:a=!0;break;case foe.COLORED_TEXTURED:}return r=new hT({parent:o,subModelIdx:0,owner:this}),this._materialCache[i]=r,r.overridePipelineStates({blendState:{blendColor:An.WHITE,targets:[{blendEq:wi.ADD,blendAlphaEq:wi.ADD,blendSrc:e,blendDst:t,blendSrcAlpha:e,blendDstAlpha:t}]}}),r.recompileShaders({TWO_COLORED:a,USE_LOCAL:!0}),r},n.onRestore=function(){this.updateMaterial(),this._renderFlag=this._canRender(),this.markForUpdateRenderData()},n.updateMaterial=function(){if(this._customMaterial)return this.setMaterial(this._customMaterial,0),void(this._blendHash=-1);var e=this._updateBuiltinMaterial();this.setMaterial(e,0),this._updateBlendFunc(),this._blendHash=-1},n.querySockets=function(){return this._skeleton?(0===this._cachedSockets.size&&this._indexBoneSockets(),this._cachedSockets.size>0?Array.from(this._cachedSockets.keys()).sort():[]):[]},n._requestDrawData=function(e,t,n,i){var r=this._drawList.add();return r.material=e,r.texture=t,r.indexOffset=n,r.indexCount=i,r},n._render=function(e){if(this._renderData&&this._drawList){var t=this._renderData,n=t.chunk,i=n.vertexAccessor,r=t.getMeshBuffer(),o=r.indexOffset;i.appendIndices(n.bufferId,t.indices);for(var a=0;athis.maxVertexCount?t.maxVertexCount:this.maxVertexCount,this.maxIndexCount=t.maxIndexCount>this.maxIndexCount?t.maxIndexCount:this.maxIndexCount,this._renderData.resize(this.maxVertexCount,this.maxIndexCount),(!this._renderData.indices||this.maxIndexCount>this._renderData.indices.length)&&(this._renderData.indices=new Uint16Array(this.maxIndexCount)))),t.isCompleted&&r>=n.length){if(this._playCount++,this._playTimes>0&&this._playCount>=this._playTimes)return this._curFrame=n[n.length-1],this._accTime=0,this._playCount=0,this._isAniComplete=!0,this._emitCacheCompleteEvent(),void this.markForUpdateRenderData();this._accTime=0,r=0,this._emitCacheCompleteEvent()}this._curFrame=n[r],this.markForUpdateRenderData()}},n._updateRealtime=function(e){var t=this._skeleton,n=this._state;t&&(t.update(e),n&&(n.update(e),n.apply(t)),this.markForUpdateRenderData())},n._indexBoneSockets=function(){if(this._skeleton){this._cachedSockets.clear();for(var e=this._skeleton.bones,t=function t(n){return null==n.parent?n.data.name||"":t(e[n.parent.data.index])+"/"+n.data.name},n=0,i=e.length;n>1,a+=f.triangles.length)}}(t=SV.add(n?$H:JH,i)).resize(o,a),t.indices&&a===t.indices.length||(t.indices=new Uint16Array(a)),e.maxVertexCount=o,e.maxIndexCount=a}return t},updateRenderData:function(e){tae=e;var t=e._skeleton;!e.isAnimationCached()&&t&&t.updateWorldTransform(),t&&function(e){if(e._skeleton){var t,n=e.color;Coe=n.r/255,boe=n.g/255,woe=n.b/255,Roe=n.a/255,Soe=e.useTint||e.isAnimationCached(),Poe=Soe?13:9,e.drawList.reset(),tae=e,nae=e.node,iae=e.renderData,Pae=null,Loe=!0,goe=e.premultipliedAlpha,voe=1,cae=0,aae=!1,Rae=e._effectDelegate&&e._effectDelegate._vertexEffect,(4294967295!==n._val||goe)&&(aae=!0),Soe&&(cae|=1),tae.enableBatch&&(t=nae.worldMatrix,Loe=!1,cae|=16),e.isAnimationCached()?function(e){var t=tae._curFrame;if(t){var n=t.segments;if(0!==n.length){Ioe=12,Eae=0,Aae=0,Tae=0,Cae=0;var i=null,r=t.vertices,o=t.indices,a=0,s=0,c=0,l=0;e&&(zoe=e.m00,Goe=e.m01,koe=e.m04,Hoe=e.m05,Uoe=e.m12,Voe=e.m13);var u=16&cae,h=u&&(1===zoe&&0===Goe&&0===koe&&1===Hoe),f=t.colors,_=0,p=f[_++],d=p.vfOffset;Oae(p);for(var m=0,g=iae,v=g.chunk.vb,y=g.indices,x=0,S=n.length;x0&&(tae._requestDrawData(Pae,Iae,m,E),m=Cae),Pae=i,Iae=T.tex}Sae=T.vertexCount,Aae=T.indexCount,a=g.chunk.vertexOffset;for(var A=Cae,C=Cae+Aae;A=d&&(Oae(p=f[_++]),d=p.vfOffset),v.set(vae,D+5),v.set(yae,D+9);s+=l,Tae+=Sae,Cae+=Aae,Sae=0,Aae=0}}var M=Cae-m;Iae&&M>0&&tae._requestDrawData(Pae,Iae,m,M)}}}(t):(Rae&&Rae.begin(e._skeleton),function(e,t){var n=iae;oae=n.chunk.vb,rae=n.indices,bae=tae.maxVertexCount,wae=tae.maxIndexCount;var i,r,o,a,s,c,l=tae._skeleton,u=l.color,h=tae._debugRenderer,f=tae._clipper,_=null;yoe=tae._startSlotIndex,xoe=tae._endSlotIndex,Noe=!1,-1===yoe&&(Noe=!0),Toe=tae.debugSlots,Eoe=tae.debugBones,Aoe=tae.debugMesh,h&&(Eoe||Toe||Aoe)&&(h.clear(),h.lineWidth=5),Ioe=12,xae=0,Tae=0,Eae=0,Aae=0,Cae=0;for(var p=0,d=0,m=l.drawOrder.length;d=0&&yoe===c.data.index&&(Noe=!0),Noe)if(xoe>=0&&xoe===c.data.index&&(Noe=!1),xae=0,Aae=0,i=c.getAttachment())if(a=i instanceof Cie.RegionAttachment,s=i instanceof Cie.MeshAttachment,i instanceof Cie.ClippingAttachment)f.clipStart(c,i);else if(a||s){var g=i.region.texture.getRealTexture();if(_=Dae(c.data.blendMode)){if(Pae||(Pae=_),Loe||_.hash!==Pae.hash||g&&Iae!==g){Loe=!1;var v=Cae-p;v>0&&(tae._requestDrawData(Pae,Iae,p,v),p=Cae),Iae=g,Pae=_}if(a){if(o=lae,xae=(Sae=4)*Poe,Aae=6,i.computeWorldVertices(c.bone,oae,Eae,Poe),h&&Toe){h.strokeColor=uae,h.moveTo(oae[Eae],oae[Eae+1]);for(var y=Eae+Poe,x=Eae+xae;y>1,xae=Sae*Poe,Aae=o.length,S.computeWorldVertices(c,0,S.worldVerticesLength,oae,Eae,Poe),h&&Aoe){h.strokeColor=_ae;for(var T=0,E=o.length;T0){for(var D=n.chunk.vertexOffset,O=Cae,M=Cae+Aae;O0&&tae._requestDrawData(Pae,Iae,p,F),f.clipEnd(),h&&Eoe){var B;h.strokeColor=hae,h.fillColor=uae;for(var z=0,k=l.bones.length;zr.vertexCount&&(r.resizeAndCopy(bae,wae>r.indexCount?wae:r.indexCount),oae=r.chunk.vb,s=!0),wae>rae.length&&(rae=r.indices=new Uint16Array(wae),s=!0),s)for(var c=r.chunk.vertexOffset-a,l=0;l0&&rae.set(c,Cae),Rae)for(var l=0,u=s.length,h=Eae;l1,T=x[0],E=T.getAttribute("source");E=E.replace(/\\/g,"/");var A=m.getElementsByTagName("tile"),C=A&&A.length||1,b=null,R=m.getAttribute("name")||"",P=parseInt(m.getAttribute("spacing"))||0,I=parseInt(m.getAttribute("margin"))||0,O=n||parseInt(m.getAttribute("firstgid"))||0,M=new Jn(0,0);M.width=parseFloat(m.getAttribute("tilewidth")),M.height=parseFloat(m.getAttribute("tileheight"));var N=m.getElementsByTagName("tileoffset")[0],L=0,F=0;N&&(L=parseFloat(N.getAttribute("x"))||0,F=parseFloat(N.getAttribute("y"))||0);for(var B=null,z=0;z0){var j=V[0],W=j.getAttribute("source");if(W=W.replace(/\\/g,"/"),B.imageName=W,B.imageSize.width=parseFloat(j.getAttribute("width"))||0,B.imageSize.height=parseFloat(j.getAttribute("height"))||0,B._tileSize.width=B.imageSize.width,B._tileSize.height=B.imageSize.height,B.sourceImage=this._spriteFrameMap[W],!B.sourceImage){var q=e.getNameWithPostfix(W);if(B.imageName=q,B.sourceImage=this._spriteFrameMap[q],!B.sourceImage){var X=e.getShortName(W);B.imageName=X,B.sourceImage=this._spriteFrameMap[X],B.sourceImage||(D(7221,W),console.warn("Please try asset type of "+W+" to 'sprite-frame'"))}}B.firstGid=this.parentGID&Vae.FLIPPED_MASK}var Y=(Vae.FLIPPED_MASK&this.parentGID)>>>0;this._tileProperties.set(Y,nse(b));var K=b.getElementsByTagName("animation");if(K&&K.length>0){var Q=K[0].getElementsByTagName("frame"),Z={frames:[],dt:0,frameIdx:0};this._tileAnimations.set(Y,Z);for(var J=Z.frames,$=0;$0){var _=f[0];u.type=Xae.TEXT,u.wrap="1"===_.getAttribute("wrap"),u.color=tse(_.getAttribute("color")),u.halign=$ae(_.getAttribute("halign")),u.valign=ese(_.getAttribute("valign")),u.pixelsize=parseInt(_.getAttribute("pixelsize"))||16,u.text=_.childNodes[0].nodeValue}var p=l.getAttribute("gid");p&&(u.gid=parseInt(p),u.type=Xae.IMAGE);var d=l.getElementsByTagName("ellipse");d&&d.length>0&&(u.type=Xae.ELLIPSE);var m=l.getElementsByTagName("polygon");if(m&&m.length>0){u.type=Xae.POLYGON;var g=m[0].getAttribute("points");g&&(u.points=this._parsePointsString(g))}var v=l.getElementsByTagName("polyline");if(v&&v.length>0){u.type=Xae.POLYLINE;var y=v[0].getAttribute("points");y&&(u.polylinePoints=this._parsePointsString(y))}u.type||(u.type=Xae.RECT),t.objects.push(u)}"index"!==a&&t.objects.sort((function(e,t){return e.y-t.y}))}return t},t._parsePointsString=function(e){if(!e)return null;for(var t=[],n=e.split(" "),i=0;i1)if(n){y._name=n.name;var E=n.unbiasUV[0],A=n.rotated?n.unbiasUV[1]:n.unbiasUV[5];y.l=E+(y.x+.5)/h,y.t=A+(y.y+.5)/f,y.r=E+(y.x+y.width-.5)/h,y.b=A+(y.y+y.height-.5)/f,y._rect=new ei(y.x,y.y,y.width,y.height)}else y.l=y.x/h,y.t=y.y/f,y.r=(y.x+y.width)/h,y.b=(y.y+y.height)/f,y._rect=new ei(y.x,y.y,y.width,y.height);else n.rotated?(y._rotated=!0,y._name=n.name,y._rect=n.getRect(),y.l=n.unbiasUV[0],y.t=n.unbiasUV[1],y.r=n.unbiasUV[4],y.b=n.unbiasUV[3]):(y._name=n.name,y._rect=n.getRect(),y.l=n.unbiasUV[0],y.t=n.unbiasUV[5],y.r=n.unbiasUV[2],y.b=n.unbiasUV[1]);y.cx=(y.l+y.r)/2,y.cy=(y.t+y.b)/2,t.set(T,y)}}for(var Tse,Ese,Ase,Cse,bse,wse,Rse,Pse,Ise,Dse,Ose,Mse,Nse,Lse,Fse,Bse,zse,kse,Use,Gse,Hse,Vse,jse,Wse,qse,Xse,Yse,Kse,Qse,Zse,Jse,$se,ece,tce,nce,ice,rce,oce,ace=new Gn,sce=new Wn,cce=new bn,lce=new bn,uce={row:0,col:0},hce=e("TiledUserNodeData",hc("cc.TiledUserNodeData")(gse=function(e){function t(){var t;return(t=e.call(this)||this)._index=-1,t._row=-1,t._col=-1,t._tiledLayer=null,t}return Z(t,e),t}(Ku))||gse),fce=e("TiledLayer",hc("cc.TiledLayer")(vse=function(e){function t(){var t;return(t=e.call(this)||this)._userNodeGrid={},t._userNodeMap={},t._userNodeDirty=!1,t.tiledTiles=[],t._viewPort={x:-1,y:-1,width:-1,height:-1},t._cullingRect={leftDown:{row:-1,col:-1},rightTop:{row:-1,col:-1}},t._cullingDirty=!0,t._rightTop={row:-1,col:-1},t._layerInfo=null,t._mapInfo=null,t._topOffset=0,t._downOffset=0,t._leftOffset=0,t._rightOffset=0,t.tiles=[],t.vertices=[],t._verticesDirty=!0,t._layerName="",t._layerSize=void 0,t._minGID=void 0,t._maxGID=void 0,t._layerOrientation=null,t._opacity=void 0,t._tintColor=void 0,t.texGrids=null,t._textures=[],t._tilesets=[],t._leftDownToCenterX=0,t._leftDownToCenterY=0,t._hasTiledNodeGrid=!1,t._hasAniGrid=!1,t._animations=null,t._enableCulling=void 0,t.colorChanged=!1,t._properties=void 0,t.renderOrder=void 0,t._staggerAxis=void 0,t._staggerIndex=void 0,t._hexSideLength=void 0,t._mapTileSize=void 0,t._odd_even=void 0,t._diffX1=void 0,t._diffY1=void 0,t._useAutomaticVertexZ=void 0,t._vertexZvalue=void 0,t._offset=void 0,t._meshRenderDataArray=null,t._meshRenderDataArrayIdx=0,t}Z(t,e);var n=t.prototype;return n.hasTiledNode=function(){return this._hasTiledNodeGrid},n.hasAnimation=function(){return this._hasAniGrid},n.addUserNode=function(e){var t=e.getComponent(hce);return t?(y("CCTiledLayer:addUserNode node has been added"),!1):(t=e.addComponent(hce),e.parent=this.node,this._userNodeMap[e.uuid]=t,t._row=-1,t._col=-1,t._tiledLayer=this,this._nodeLocalPosToLayerPos(e.getPosition(),sce),this._positionToRowCol(sce.x,sce.y,uce),this._addUserNodeToGrid(t,uce),this._updateCullingOffsetByUserNode(e),e.on(BE.TRANSFORM_CHANGED,this._userNodePosChange,t),e.on(BE.SIZE_CHANGED,this._userNodeSizeChange,t),!0)},n.removeUserNode=function(e){var t=e.getComponent(hce);return t?(e.off(BE.TRANSFORM_CHANGED,this._userNodePosChange,t),e.off(BE.SIZE_CHANGED,this._userNodeSizeChange,t),this._removeUserNodeFromGrid(t),delete this._userNodeMap[e.uuid],e._removeComponent(t),t.destroy(),e.removeFromParent(),!0):(y("CCTiledLayer:removeUserNode node is not exist"),!1)},n.destroyUserNode=function(e){this.removeUserNode(e),e.destroy()},n._nodeLocalPosToLayerPos=function(e,t){t.x=e.x+this._leftDownToCenterX,t.y=e.y+this._leftDownToCenterY},n.getNodesByRowCol=function(e,t){var n=this._userNodeGrid[e];return n?n[t]:null},n.getNodesCountByRow=function(e){var t=this._userNodeGrid[e];return t?t.count:0},n._updateAllUserNode=function(){for(var e in this._userNodeGrid={},this._userNodeMap){var t=this._userNodeMap[e];this._nodeLocalPosToLayerPos(t.node.getPosition(),sce),this._positionToRowCol(sce.x,sce.y,uce),this._addUserNodeToGrid(t,uce),this._updateCullingOffsetByUserNode(t.node)}},n._updateCullingOffsetByUserNode=function(e){var t=e._uiProps.uiTransformComp.contentSize;this._topOffsetthis._rightTop.row&&(e.row=this._rightTop.row),n<0&&(e.col=0),n>this._rightTop.col&&(e.col=this._rightTop.col)},n._addUserNodeToGrid=function(e,t){var n=t.row,i=t.col,r=this._userNodeGrid[n]=this._userNodeGrid[n]||{count:0},o=r[i]=r[i]||{count:0,list:[]};e._row=n,e._col=i,e._index=o.list.length,r.count++,o.count++,o.list.push(e),this._userNodeDirty=!0},n.isUserNodeDirty=function(){return this._userNodeDirty},n.setUserNodeDirty=function(e){this._userNodeDirty=e},n.onEnable=function(){e.prototype.onEnable.call(this),this.node.on(BE.ANCHOR_CHANGED,this._syncAnchorPoint,this),this.node.on(BE.TRANSFORM_CHANGED,this.updateCulling,this),this.node.on(BE.SIZE_CHANGED,this.updateCulling,this),this.node.parent.on(BE.TRANSFORM_CHANGED,this.updateCulling,this),this.node.parent.on(BE.SIZE_CHANGED,this.updateCulling,this),this.markForUpdateRenderData(),this.scheduleOnce(this.updateCulling.bind(this))},n.onDisable=function(){var t,n;e.prototype.onDisable.call(this),null===(t=this.node.parent)||void 0===t||t.off(BE.SIZE_CHANGED,this.updateCulling,this),null===(n=this.node.parent)||void 0===n||n.off(BE.TRANSFORM_CHANGED,this.updateCulling,this),this.node.off(BE.SIZE_CHANGED,this.updateCulling,this),this.node.off(BE.TRANSFORM_CHANGED,this.updateCulling,this),this.node.off(BE.ANCHOR_CHANGED,this._syncAnchorPoint,this)},n._syncAnchorPoint=function(){var e=this.node,t=e._uiProps.uiTransformComp,n=e.getScale();this._leftDownToCenterX=t.width*t.anchorX*n.x,this._leftDownToCenterY=t.height*t.anchorY*n.y,this._cullingDirty=!0,this.markForUpdateRenderData()},n.getLayerName=function(){return this._layerName},n.setLayerName=function(e){this._layerName=e},n.getProperty=function(e){return this._properties[e]},n.getPositionAt=function(e,t){var n;switch(void 0!==t?(n=Math.floor(e),t=Math.floor(t)):(n=Math.floor(e.x),t=Math.floor(e.y)),this._layerOrientation){case Gae.ORTHO:return this._positionForOrthoAt(n,t);case Gae.ISO:return this._positionForIsoAt(n,t);case Gae.HEX:return this._positionForHexAt(n,t)}return null},n.isInvalidPosition=function(e,t){return e>=this._layerSize.width||t>=this._layerSize.height||e<0||t<0},n._positionForIsoAt=function(e,t){var n=0,i=0,r=Math.floor(e)+Math.floor(t)*this._layerSize.width,o=this.tiles[r];if(o){var a=(o&Vae.FLIPPED_MASK)>>>0,s=this.texGrids.get(a).tileset.tileOffset;n=s.x,i=s.y}return new Wn(.5*this._mapTileSize.width*(this._layerSize.height+e-t-1)+n,.5*this._mapTileSize.height*(this._layerSize.width-e+this._layerSize.height-t-2)-i)},n._positionForOrthoAt=function(e,t){var n=0,i=0,r=Math.floor(e)+Math.floor(t)*this._layerSize.width,o=this.tiles[r];if(o){var a=(o&Vae.FLIPPED_MASK)>>>0,s=this.texGrids.get(a).tileset.tileOffset;n=s.x,i=s.y}return new Wn(e*this._mapTileSize.width+n,(this._layerSize.height-t-1)*this._mapTileSize.height-i)},n._positionForHexAt=function(e,t){var n,i=this._mapTileSize.width,r=this._mapTileSize.height,o=this._layerSize.height,a=Math.floor(e)+Math.floor(t)*this._layerSize.width,s=(this.tiles[a]&Vae.FLIPPED_MASK)>>>0;n=this.texGrids.get(s)?this.texGrids.get(s).tileset.tileOffset:{x:0,y:0};var c=this._staggerIndex===Wae.STAGGERINDEX_ODD?1:-1,l=0,u=0,h=0,f=0;switch(this._staggerAxis){case jae.STAGGERAXIS_Y:h=0,t%2==1&&(h=i/2*c),l=e*i+h+n.x,u=(o-t-1)*(r-(r-this._hexSideLength)/2)-n.y;break;case jae.STAGGERAXIS_X:f=0,e%2==1&&(f=r/2*-c),l=e*(i-(i-this._hexSideLength)/2)+n.x,u=(o-t-1)*r+f-n.y}return new Wn(l,u)},n.setTilesGIDAt=function(e,t,n,i){if(e&&0!==e.length&&!(i<=0)){n<0&&(n=0),t<0&&(t=0);for(var r=0,o=t+i,a=n;;a++)for(var s=t;s=e.length)return;this._updateTileForGID(e[r],s,a),r++}}},n.setTileGIDAt=function(e,t,n,i){var r=(e&Vae.FLIPPED_MASK)>>>0;if(t=Math.floor(t),n=Math.floor(n),this.isInvalidPosition(t,n))throw new Error("cc.TiledLayer.setTileGIDAt(): invalid position");this.tiles&&this._tilesets&&0!==this._tilesets.length?0!==r&&r>>0,t,n)):w(7238)},n._updateTileForGID=function(e,t,n){var i=0|t+n*this._layerSize.width;if(!(i>=this.tiles.length)&&e!==this.tiles[i]){var r=(e&Vae.FLIPPED_MASK)>>>0;this.texGrids.get(r)?(this.tiles[i]=e,this._updateVertex(t,n)):this.tiles[i]=0,this._cullingDirty=!0}},n.getTileGIDAt=function(e,t){if(this.isInvalidPosition(e,t))throw new Error("cc.TiledLayer.getTileGIDAt(): invalid position");if(!this.tiles)return w(7237),null;var n=Math.floor(e)+Math.floor(t)*this._layerSize.width;return(this.tiles[n]&Vae.FLIPPED_MASK)>>>0},n.getTileFlagsAt=function(e,t){if(this.isInvalidPosition(e,t))throw new Error("TiledLayer.getTileFlagsAt: invalid position");if(!this.tiles)return w(7240),null;var n=Math.floor(e)+Math.floor(t)*this._layerSize.width;return(this.tiles[n]&Vae.FLIPPED_ALL)>>>0},n.setCullingDirty=function(e){this._cullingDirty=e},n.isCullingDirty=function(){return this._cullingDirty},n.updateViewPort=function(e,t,n,i){if(this._viewPort.width!==n||this._viewPort.height!==i||this._viewPort.x!==e||this._viewPort.y!==t){this._viewPort.x=e,this._viewPort.y=t,this._viewPort.width=n,this._viewPort.height=i;var r=1;this._layerOrientation===Gae.ISO&&(r=2);var o=this._viewPort.x-this._offset.x+this._leftDownToCenterX,a=this._viewPort.y-this._offset.y+this._leftDownToCenterY,s=o-this._leftOffset,c=a-this._downOffset,l=o+n+this._rightOffset,u=a+i+this._topOffset,h=this._cullingRect.leftDown,f=this._cullingRect.rightTop;s<0&&(s=0),c<0&&(c=0),this._positionToRowCol(s,c,uce),uce.row-=r,uce.col-=r,uce.row=uce.row>0?uce.row:0,uce.col=uce.col>0?uce.col:0,uce.row===h.row&&uce.col===h.col||(h.row=uce.row,h.col=uce.col,this._cullingDirty=!0),l<0||u<0?(uce.row=-1,uce.col=-1):(this._positionToRowCol(l,u,uce),uce.row++,uce.col++),uce.row>this._rightTop.row&&(uce.row=this._rightTop.row),uce.col>this._rightTop.col&&(uce.col=this._rightTop.col),uce.row===f.row&&uce.col===f.col||(f.row=uce.row,f.col=uce.col,this._cullingDirty=!0,this.markForUpdateRenderData())}},n._positionToRowCol=function(e,t,n){var i=this._mapTileSize.width,r=this._mapTileSize.height,o=.5*i,a=.5*r,s=0,c=0,l=0,u=0,h=this._staggerAxis;switch(this._layerOrientation){case Gae.ORTHO:c=Math.floor(e/i),s=Math.floor(t/r);break;case Gae.ISO:c=Math.floor(e/o),s=Math.floor(t/a);break;case Gae.HEX:h===jae.STAGGERAXIS_Y?(l=(s=Math.floor(t/(r-this._diffY1)))%2==1?o*this._odd_even:0,c=Math.floor((e-l)/i)):(u=(c=Math.floor(e/(i-this._diffX1)))%2==1?a*-this._odd_even:0,s=Math.floor((t-u)/r))}return n.row=s,n.col=c,n},n.updateCulling=function(){if(this._enableCulling){this.node.updateWorldTransform(),Gn.invert(ace,this.node.getWorldMatrix());var e=zM.root.batcher2D.getFirstRenderCamera(this.node);e&&(cce.x=0,cce.y=0,cce.z=0,lce.x=e.width,lce.y=e.height,lce.z=0,e.screenToWorld(cce,cce),e.screenToWorld(lce,lce),bn.transformMat4(cce,cce,ace),bn.transformMat4(lce,lce,ace),this.updateViewPort(cce.x,cce.y,lce.x-cce.x,lce.y-cce.y))}},n.getLayerOrientation=function(){return this._layerOrientation},n.getProperties=function(){return this._properties},n._updateVertex=function(e,t){var n=Vae.FLIPPED_MASK,i=this.vertices,r=this._layerOrientation,o=this.tiles;if(o){var a,s,c,l,u=this._rightTop,h=this._mapTileSize.width,f=this._mapTileSize.height,_=.5*h,p=.5*f,d=this._layerSize.height,m=this._layerSize.width,g=this.texGrids,v=0,y=0;r===Gae.HEX&&(a=this._staggerAxis,s=this._diffX1,c=this._diffY1,l=this._odd_even);var x,S,T,E=0,A=0,C=0,b=0,w=t*m+e;x=(o[w]&n)>>>0;var R=g.get(x);if(R){switch(this._animations.get(x)&&(this._hasAniGrid=this._hasAniGrid||!0),r){case Gae.ORTHO:v=(E=e)*h,y=(A=d-t-1)*f;break;case Gae.ISO:v=_*(E=d+e-t-1),y=p*(A=d+m-e-t-2);break;case Gae.HEX:v=e*(h-s)+(a===jae.STAGGERAXIS_Y&&t%2==1?_*l:0),y=(d-t-1)*(f-c)+(a===jae.STAGGERAXIS_X&&e%2==1?p*-l:0),E=e,A=d-t-1}var P=i[A]=i[A]||{minCol:0,maxCol:0},I=P[E]=P[E]||{};P.minCol>E&&(P.minCol=E),P.maxCol=0&&this._textures.length>e?this._textures[e]:null},n.getTextures=function(){return this._textures},n.setTexture=function(e){this.setTextures([e])},n.setTextures=function(e){this._textures=e,this.markForUpdateRenderData()},n.getLayerSize=function(){return this._layerSize},n.getMapTileSize=function(){return this._mapTileSize},n.getTileSet=function(e){return e=e||0,this._tilesets&&e>=0&&this._tilesets.length>e?this._tilesets[e]:null},n.getTileSets=function(){return this._tilesets},n.setTileSet=function(e){this.setTileSets([e])},n.setTileSets=function(e){this._tilesets=e;var t=this._textures=[],n=this.texGrids;n.clear();for(var i=0;i0&&e[e.length-1].subNodes&&0===e[e.length-1].subNodes.length;)e.pop();if(e.length>0){var t=e[e.length-1];if(t.renderData&&0===t.renderData.vertexCount)return t}var n=TV.add(),i={renderData:n,texture:null};return n.material=this.getRenderMaterial(0),this._meshRenderDataArray.push(i),i},n.requestSubNodesData=function(){this._meshRenderDataArray||(this._meshRenderDataArray=[]);var e=this._meshRenderDataArray;if(e.length>0&&e[e.length-1].subNodes&&0===e[e.length-1].subNodes.length)return e[e.length-1];var t={subNodes:[]};return this._meshRenderDataArray.push(t),t},n.destroyRenderData=function(){this._meshRenderDataArray&&(this._meshRenderDataArray.forEach((function(e){var t=e.renderData;t&&TV.remove(t)})),this._meshRenderDataArray.length=0),e.prototype.destroyRenderData.call(this)},n._flushAssembler=function(){var e=t.Assembler.getAssembler(this);this._assembler!==e&&(this._assembler=e),this._meshRenderDataArray||this._assembler&&this._assembler.createData&&(this._assembler.createData(this),this.markForUpdateRenderData(),this._updateColor())},n._render=function(e){if(this._meshRenderDataArray){for(var t=0;t>>0,O=n.get(D);if(!O)continue;var M=O.tileset,N="img"+x.id;g[N]=!0;var L=this.node.getChildByName(N);x.width=x.width||O.width,x.height=x.height||O.height,L&&L._objFlags&ul.Flags.HideInHierarchy&&(L.removeFromParent(),L.hideFlags|=ul.Flags.DontSave,L.destroy(),L=null),L||(L=new kC),this._animations.get(D)&&(this.aniObjects.push({object:x,imgNode:L,gridGID:D}),this._hasAniObj=!0);var F=M.tileOffset.x,B=M.tileOffset.y;L.active=x.visible,L.setRotationFromEuler(0,0,-x.rotation),L.setPosition(x.x-p,x.y-d),L.name=N,L.parent=this.node,L.setSiblingIndex(v);var z=L.getComponent(rY);z||(z=L.addComponent(rY));var k=L._uiProps.uiTransformComp;h?(k.anchorX=.5+F/x.width,k.anchorY=B/x.height):(k.anchorX=F/x.width,k.anchorY=B/x.height),this._tintColor?(u.set(this._tintColor),u.a*=this._opacity/255,z.color.set(u)):z.color.a*=this._opacity/255,z.sizeMode=rY.SizeMode.CUSTOM,z._srcBlendFactor=this._premultiplyAlpha?bi.ONE:bi.SRC_ALPHA,z._dstBlendFactor=bi.ONE_MINUS_SRC_ALPHA,z._updateBlendFunc();var U=O.spriteFrame;U=U?U.clone():new rH,(I&r)>>>0&&(U.flipUVX=!U.flipUVX),(I&o)>>>0&&(U.flipUVY=!U.flipUVY),U.rotated=O._rotated,U.rect=O._rect,z.spriteFrame=U,k.setContentSize(x.width,x.height),z.markForUpdateRenderData()}}this._objects=m;for(var G=this.node.children,H=/^(?:img|text)\d+$/,V=0,j=G.length;V0&&(m[p[g]]=d[g].text);var v=new yse(n.tmxXmlStr,m,a,s,h),y=v.getTilesets();y&&0!==y.length||w(7241),this._buildWithMapInfo(v)}else this._releaseMapInfo()},n._releaseMapInfo=function(){for(var e=this._layers,t=0,n=e.length;t0)for(var T=0,E=v.length;T=s.length&&(a.frameIdx=0),c=s[a.frameIdx]),i.set(o,c.grid)}for(var l=this.getLayers(),u=0,h=l.length;u65535&&console.error("Vertex count exceeds 65535"),t},updateRenderData:function(e){e.updateCulling();var t=e.requestMeshRenderData();if(Pce=e.leftDownToCenterX,Ice=e.leftDownToCenterY,vce=t,e.colorChanged||e.isCullingDirty()||e.isUserNodeDirty()||e.hasAnimation()||e.hasTiledNode()||e.node.hasChangedFlags){var n,i;if(e.colorChanged=!1,e.destroyRenderData(),e.enableCulling){var r=e.cullingRect;n=r.leftDown,i=r.rightTop}else n=Tce,i=e.rightTop;switch(e.renderOrder){case qae.RightDown:Nce(n,i,-1,1,e);break;case qae.LeftDown:Nce(n,i,-1,-1,e);break;case qae.RightUp:Nce(n,i,1,1,e);break;case qae.LeftUp:default:Nce(n,i,1,-1,e)}e.setCullingDirty(!1),e.setUserNodeDirty(!1)}vce=null},updateColor:function(e){var t=e.color,n=new Float32Array(4);n[0]=t.r/255,n[1]=t.g/255,n[2]=t.b/255,n[3]=t.a/255;var i=e.meshRenderDataArray;if(i)for(var r,o=oe(i);!(r=o()).done;){var a=r.value;if(a.renderData)for(var s=a.renderData,c=s.vData,l=s.vertexStart,u=s.vertexCount;l>>0&&(n=Ace,Ace=Cce,Cce=n),(t&Vae.HORIZONTAL)>>>0&&(n=Ece,Ece=Cce,Cce=n,n=Ace,Ace=bce,bce=n),(t&Vae.VERTICAL)>>>0&&(n=Ece,Ece=Ace,Ace=n,n=Cce,Cce=bce,bce=n)}function Mce(e,t,n){e||(e=t.texture),vce.texture||(vce.texture=e),(vce=n.requestMeshRenderData()).texture=t.texture}function Nce(e,t,n,i,r){if(!(!vce||t.row<0||t.col<0)){vce.renderData||(vce=r.requestMeshRenderData());var o=vce.renderData.vData,a=r.node.worldMatrix;wce=0,Rce=0;var s,c,l,u,h,f,_,p,d,m=r.tiledTiles,g=r.texGrids,v=r.tiles,y=18,x=27,S=r.vertices,T=0,E=0,A=0,C=0,b=0,w=null,R=0,P=!0;yce=Oce;var I=new Float32Array(4);for(I[0]=r.color.r/255,I[1]=r.color.g/255,I[2]=r.color.b/255,I[3]=r.color.a/255,-1===n?(u=t.row,h=e.row):(u=e.row,h=t.row);(h-u)*n>=0;u+=n)for(s=S[u],R=r.getNodesCountByRow(u),P=s&&0===R,1===i?(c=P&&e.cols.maxCol?s.maxCol:t.col):(c=P&&t.col>s.maxCol?s.maxCol:t.col,l=P&&e.col=0;c+=i){if(f=s&&s[c],R>0){var D=r.requestSubNodesData(),O=r.getNodesByRowCol(u,c);O&&O.count>0&&(D.subNodes=r.getNodesByRowCol(u,c).list,w=null,vce=r.requestMeshRenderData())}if(f&&(T=v[f.index],p=g.get((T&Vae.FLIPPED_MASK)>>>0))){w!==p.texture&&(Mce(w,p,r),w=p.texture),_=p.tileset._tileSize,E=f.left-Pce,A=f.bottom-Ice,C=E+_.width,b=A+_.height,d=m[f.index];var M=vce.renderData;M.reserve(4,0),Rce=9*M.vertexCount,o=M.vData,d?d.node.active&&Lce(d.node,I,o,E,C,b,A,!1):(mce[0].x=E,mce[0].y=b,mce[1].x=E,mce[1].y=A,mce[2].x=C,mce[2].y=b,mce[3].x=C,mce[3].y=A,mce[0].transformMat4(a),o[Rce]=mce[0].x,o[Rce+1]=mce[0].y,o[Rce+2]=mce[0].z,mce[1].transformMat4(a),o[Rce+9]=mce[1].x,o[Rce+9+1]=mce[1].y,o[Rce+9+2]=mce[1].z,mce[2].transformMat4(a),o[Rce+y]=mce[2].x,o[Rce+y+1]=mce[2].y,o[Rce+y+2]=mce[2].z,mce[3].transformMat4(a),o[Rce+x]=mce[3].x,o[Rce+x+1]=mce[3].y,o[Rce+x+2]=mce[3].z,o.set(I,Rce+5),o.set(I,Rce+9+5),o.set(I,Rce+y+5),o.set(I,Rce+x+5)),yce(p,T),o[Rce+3]=Ece.x,o[Rce+4]=Ece.y,o[Rce+9+3]=Ace.x,o[Rce+9+4]=Ace.y,o[Rce+y+3]=Cce.x,o[Rce+y+4]=Cce.y,o[Rce+x+3]=bce.x,o[Rce+x+4]=bce.y,wce++,M.request(4,6),M.resize(M.vertexCount,M.indexCount),wce>=dce&&(Mce(w,p,r),w=p.texture)}}}}function Lce(e,t,n,i,r,o,a,s){var c=18,l=27;e.updateWorldTransform(),Gn.fromRTS(xce,e.rotation,e.position,e.scale),bn.set(Sce,-(i+Pce),-(a+Ice),0),Gn.transform(xce,xce,Sce),Gn.multiply(xce,e.parent.worldMatrix,xce);var u=xce,h=u.m12,f=u.m13,_=u.m00,p=u.m01,d=u.m04,m=u.m05,g=1===_&&0===p&&0===d&&1===m;if(s){var v=(i+r)/2,y=(o+a)/2;g?(n[Rce]=v+h,n[Rce+1]=o+f,n[Rce+9]=i+h,n[Rce+9+1]=y+f,n[Rce+c]=r+h,n[Rce+c+1]=y+f,n[Rce+l]=v+h,n[Rce+l+1]=a+f):(n[Rce]=v*_+o*d+h,n[Rce+1]=v*p+o*m+f,n[Rce+9]=i*_+y*d+h,n[Rce+9+1]=i*p+y*m+f,n[Rce+c]=r*_+y*d+h,n[Rce+c+1]=r*p+y*m+f,n[Rce+l]=v*_+a*d+h,n[Rce+l+1]=v*p+a*m+f)}else g?(n[Rce]=i+h,n[Rce+1]=o+f,n[Rce+9]=i+h,n[Rce+9+1]=a+f,n[Rce+c]=r+h,n[Rce+c+1]=o+f,n[Rce+l]=r+h,n[Rce+l+1]=a+f):(n[Rce]=i*_+o*d+h,n[Rce+1]=i*p+o*m+f,n[Rce+9]=i*_+a*d+h,n[Rce+9+1]=i*p+a*m+f,n[Rce+c]=r*_+o*d+h,n[Rce+c+1]=r*p+o*m+f,n[Rce+l]=r*_+a*d+h,n[Rce+l+1]=r*p+a*m+f);n.set(t,Rce+5),n.set(t,Rce+9+5),n.set(t,Rce+c+5),n.set(t,Rce+l+5)}var Fce=e("tiledLayerAssembler",{getAssembler:function(){return Dce}});fce.Assembler=Fce;var Bce=function(){function e(){this.originalTarget=null,this.target=null,this.tag=e.TAG_INVALID}var t=e.prototype;return t.clone=function(){var t=new e;return t.originalTarget=null,t.target=null,t.tag=this.tag,t},t.isDone=function(){return!0},t.startWithTarget=function(e){this.originalTarget=e,this.target=e},t.stop=function(){this.target=null},t.step=function(){w(1006)},t.update=function(){w(1007)},t.getTarget=function(){return this.target},t.setTarget=function(e){this.target=e},t.getOriginalTarget=function(){return this.originalTarget},t.setOriginalTarget=function(e){this.originalTarget=e},t.getTag=function(){return this.tag},t.setTag=function(e){this.tag=e},t.reverse=function(){return w(1008),null},t.retain=function(){},t.release=function(){},e}();Bce.TAG_INVALID=-1;var zce=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r=i&&n.actionIndex--;break}}},t._removeActionByTag=function(e,t,n){for(var i=0,r=t.actions.length;i=0;--i){var r=t.actions[i];if(r&&r.getTag()===e){if(n&&r.getOriginalTarget()!==n)continue;this._removeActionAtIndex(i,t)}}},t.removeActionByTag=function(e,t){var n=this;e===Bce.TAG_INVALID&&w(1002);var i=this._hashTargets;if(t){var r=i.get(t);r&&this._removeActionByTag(e,r,t)}else i.forEach((function(t){n._removeActionByTag(e,t)}))},t.removeAllActionsByTag=function(e,t){var n=this;e===Bce.TAG_INVALID&&w(1002);var i=this._hashTargets;if(t){var r=i.get(t);r&&this._removeAllActionsByTag(e,r,t)}else i.forEach((function(t){n._removeAllActionsByTag(e,t)}))},t.getActionByTag=function(e,t){e===Bce.TAG_INVALID&&w(1004);var n=this._hashTargets.get(t);if(n){if(null!=n.actions)for(var i=0;i=e&&t.actionIndex--,0===t.actions.length&&this._deleteHashElement(t)},t._deleteHashElement=function(e){var t=!1;if(e&&!e.lock&&this._hashTargets.get(e.target)){this._hashTargets.delete(e.target);for(var n=this._arrayTargets,i=0,r=n.length;i=this._duration},n._cloneDecoration=function(e){e._repeatForever=this._repeatForever,e._speed=this._speed,e._timesForRepeat=this._timesForRepeat,e._easeList=this._easeList,e._speedMethod=this._speedMethod,e._repeatMethod=this._repeatMethod},n._reverseEaseList=function(e){if(this._easeList){e._easeList=[];for(var t=0;t1.192092896e-7?this._duration:1.192092896e-7);t=t<1?t:1,this.update(t>0?t:0),this._repeatMethod&&this._timesForRepeat>1&&this.isDone()&&(this._repeatForever||this._timesForRepeat--,this.startWithTarget(this.target),this.step(this._elapsed-this._duration))},n.startWithTarget=function(e){Bce.prototype.startWithTarget.call(this,e),this._elapsed=0,this._firstTick=!0},n.reverse=function(){return w(1010),this},n.setAmplitudeRate=function(){w(1011)},n.getAmplitudeRate=function(){return w(1012),0},n.speed=function(e){return e<=0?(w(1013),this):(this._speedMethod=!0,this._speed*=e,this)},n.getSpeed=function(){return this._speed},n.setSpeed=function(e){return this._speed=e,this},n.repeat=function(e){return e=Math.round(e),isNaN(e)||e<1?(w(1014),this):(this._repeatMethod=!0,this._timesForRepeat*=e,this)},n.repeatForever=function(){return this._repeatMethod=!0,this._timesForRepeat=this.MAX_VALUE,this._repeatForever=!0,this},t}(zce),Kce=function(e){function t(n){var i;(i=e.call(this)||this)._actions=[],i._split=0,i._last=0,i._reversed=!1;var r=n instanceof Array?n:arguments;if(1===r.length)return D(1019),ie(i);var o=r.length-1;if(o>=0&&null==r[o]&&w(1015),o>=0){for(var a,s=r[0],c=1;c1?t%1:t),this._last=i)},n.reverse=function(){var e=t._actionOneTwo(this._actions[1].reverse(),this._actions[0].reverse());return this._cloneDecoration(e),this._reverseEaseList(e),e._reversed=!0,e},t}(Yce);function Qce(e){var t=e instanceof Array?e:arguments;if(1===t.length)return D(1019),null;var n=t.length-1;n>=0&&null==t[n]&&w(1015);var i=null;if(n>=0){i=t[0];for(var r=1;r<=n;r++)t[r]&&(i=Kce._actionOneTwo(i,t[r]))}return i}Kce._actionOneTwo=function(e,t){var n=new Kce;return n.initWithTwoActions(e,t),n};var Zce=function(e){function t(t,n){var i;return(i=e.call(this)||this)._times=0,i._total=0,i._nextDt=0,i._actionInstant=!1,i._innerAction=null,void 0!==n&&i.initWithAction(t,n),i}Z(t,e);var n=t.prototype;return n.initWithAction=function(e,t){var n=e._duration*t;return!!this.initWithDuration(n)&&(this._times=t,this._innerAction=e,e instanceof Vce&&(this._actionInstant=!0,this._times-=1),this._total=0,!0)},n.clone=function(){var e=new t;return this._cloneDecoration(e),e.initWithAction(this._innerAction.clone(),this._times),e},n.startWithTarget=function(e){this._total=0,this._nextDt=this._innerAction._duration/this._duration,Yce.prototype.startWithTarget.call(this,e),this._innerAction.startWithTarget(e)},n.stop=function(){this._innerAction.stop(),Bce.prototype.stop.call(this)},n.update=function(e){e=this._computeEaseTime(e);var t=this._innerAction,n=this._duration,i=this._times,r=this._nextDt;if(e>=r){for(;e>r&&this._total1?1:r;e>=1&&this._total=0&&null==r[o]&&w(1015),o>=0){for(var a,s=r[0],c=1;cr?this._two=Kce._actionOneTwo(t,nle(i-r)):i0&&null==t[t.length-1]&&w(1015);for(var n=t[0],i=1;i0&&(n=this._time/this._duration),n>=1&&(n=1),this._transition===due.COLOR){var i=t._uiProps.uiComp;An.lerp(vue,this._fromColor,this._toColor,n),i&&(i.color=vue)}else this.transition===due.SCALE&&(t.getScale(this._targetScale),this._targetScale.x=sn(this._fromScale.x,this._toScale.x,n),this._targetScale.y=sn(this._fromScale.y,this._toScale.y,n),t.setScale(this._targetScale));1===n&&(this._transitionFinished=!0)}},n._resizeNodeToTargetNode=function(){this.target&&this.target._uiProps.uiTransformComp},n._resetState=function(){this._pressed=!1,this._hovered=!1;var e=this.target;if(e){var t=this._transition;if(t===due.COLOR&&this._interactable){var n=e.getComponent(dW);n&&(n.color=this._normalColor)}else t===due.SCALE&&this._originalScale&&e.setScale(this._originalScale);this._transitionFinished=!0}},n._registerNodeEvent=function(){this.node.on(BE.TOUCH_START,this._onTouchBegan,this),this.node.on(BE.TOUCH_MOVE,this._onTouchMove,this),this.node.on(BE.TOUCH_END,this._onTouchEnded,this),this.node.on(BE.TOUCH_CANCEL,this._onTouchCancel,this),this.node.on(BE.MOUSE_ENTER,this._onMouseMoveIn,this),this.node.on(BE.MOUSE_LEAVE,this._onMouseMoveOut,this)},n._registerTargetEvent=function(e){e.on(BE.TRANSFORM_CHANGED,this._onTargetTransformChanged,this)},n._unregisterNodeEvent=function(){this.node.off(BE.TOUCH_START,this._onTouchBegan,this),this.node.off(BE.TOUCH_MOVE,this._onTouchMove,this),this.node.off(BE.TOUCH_END,this._onTouchEnded,this),this.node.off(BE.TOUCH_CANCEL,this._onTouchCancel,this),this.node.off(BE.MOUSE_ENTER,this._onMouseMoveIn,this),this.node.off(BE.MOUSE_LEAVE,this._onMouseMoveOut,this)},n._unregisterTargetEvent=function(e){e.off(BE.TRANSFORM_CHANGED)},n._getTargetSprite=function(e){var t=null;return e&&(t=e.getComponent(rY)),t},n._applyTarget=function(){this.target&&(this._sprite=this._getTargetSprite(this.target),this._originalScale||(this._originalScale=new bn),bn.copy(this._originalScale,this.target.getScale()),this._registerTargetEvent(this.target))},n._onTargetSpriteFrameChanged=function(e){this._transition===due.SPRITE&&this._setCurrentStateSpriteFrame(e.spriteFrame)},n._setCurrentStateSpriteFrame=function(e){if(e)switch(this._getButtonState()){case mue.NORMAL:this._normalSprite=e;break;case mue.HOVER:this._hoverSprite=e;break;case mue.PRESSED:this._pressedSprite=e;break;case mue.DISABLED:this._disabledSprite=e}},n._onTargetColorChanged=function(e){this._transition===due.COLOR&&this._setCurrentStateColor(e)},n._setCurrentStateColor=function(e){switch(this._getButtonState()){case mue.NORMAL:this._normalColor=e;break;case mue.HOVER:this._hoverColor=e;break;case mue.PRESSED:this._pressedColor=e;break;case mue.DISABLED:this._disabledColor=e}},n._onTargetTransformChanged=function(e){e&Jv.SCALE&&this._originalScale&&this._transition===due.SCALE&&this._transitionFinished&&bn.copy(this._originalScale,this.target.getScale())},n._onTouchBegan=function(e){this._interactable&&this.enabledInHierarchy&&(this._pressed=!0,this._updateState(),e&&(e.propagationStopped=!0))},n._onTouchMove=function(e){if(this._interactable&&this.enabledInHierarchy&&this._pressed&&e){var t=e.touch;if(t){var n,i=this.node._uiProps.uiTransformComp.isHit(t.getUILocation());this._transition===due.SCALE&&this.target&&this._originalScale?i?(bn.copy(this._fromScale,this._originalScale),bn.multiplyScalar(this._toScale,this._originalScale,this._zoomScale),this._transitionFinished=!1):(this._time=0,this._transitionFinished=!0,this.target.setScale(this._originalScale)):(n=i?mue.PRESSED:mue.NORMAL,this._applyTransition(n)),e&&(e.propagationStopped=!0)}}},n._onTouchEnded=function(e){this._interactable&&this.enabledInHierarchy&&(this._pressed&&(NF.emitEvents(this.clickEvents,e),this.node.emit(gue.CLICK,this)),this._pressed=!1,this._updateState(),e&&(e.propagationStopped=!0))},n._onTouchCancel=function(){this._interactable&&this.enabledInHierarchy&&(this._pressed=!1,this._updateState())},n._onMouseMoveIn=function(){!this._pressed&&this.interactable&&this.enabledInHierarchy&&(this._transition!==due.SPRITE||this._hoverSprite)&&(this._hovered||(this._hovered=!0,this._updateState()))},n._onMouseMoveOut=function(){this._hovered&&(this._hovered=!1,this._updateState())},n._updateState=function(){var e=this._getButtonState();this._applyTransition(e)},n._getButtonState=function(){var e=mue.NORMAL;return this._interactable?this._pressed?e=mue.PRESSED:this._hovered&&(e=mue.HOVER):e=mue.DISABLED,e.toString()},n._updateColorTransition=function(e){var t,n=this[e+"Color"],i=null===(t=this.target)||void 0===t?void 0:t.getComponent(dW);i&&(e===mue.DISABLED?i.color=n:(this._fromColor=i.color.clone(),this._toColor=n,this._time=0,this._transitionFinished=!1))},n._updateSpriteTransition=function(e){var t=this[e+"Sprite"];this._sprite&&t&&(this._sprite.spriteFrame=t)},n._updateScaleTransition=function(e){this._interactable&&(e===mue.PRESSED?this._zoomUp():this._zoomBack())},n._zoomUp=function(){this._originalScale&&(bn.copy(this._fromScale,this._originalScale),bn.multiplyScalar(this._toScale,this._originalScale,this._zoomScale),this._time=0,this._transitionFinished=!1)},n._zoomBack=function(){this.target&&this._originalScale&&(bn.copy(this._fromScale,this.target.getScale()),bn.copy(this._toScale,this._originalScale),this._time=0,this._transitionFinished=!1)},n._applyTransition=function(e){var t=this._transition;t===due.COLOR?this._updateColorTransition(e):t===due.SPRITE?this._updateSpriteTransition(e):t===due.SCALE&&this._updateScaleTransition(e)},K(t,[{key:"target",get:function(){return this._target||this.node},set:function(e){this._target!==e&&(this._target&&this._unregisterTargetEvent(this._target),this._target=e,this._applyTarget())}},{key:"interactable",get:function(){return this._interactable},set:function(e){this._interactable=e,this._updateState(),this._interactable||this._resetState()}},{key:"_resizeToTarget",set:function(e){e&&this._resizeNodeToTargetNode()}},{key:"transition",get:function(){return this._transition},set:function(e){this._transition!==e&&(this._transition===due.COLOR?this._updateColorTransition(mue.NORMAL):this._transition===due.SPRITE&&this._updateSpriteTransition(mue.NORMAL),this._transition=e,this._updateState())}},{key:"normalColor",get:function(){return this._normalColor},set:function(e){this._normalColor!==e&&(this._normalColor.set(e),this._updateState())}},{key:"pressedColor",get:function(){return this._pressedColor},set:function(e){this._pressedColor!==e&&this._pressedColor.set(e)}},{key:"hoverColor",get:function(){return this._hoverColor},set:function(e){this._hoverColor!==e&&this._hoverColor.set(e)}},{key:"disabledColor",get:function(){return this._disabledColor},set:function(e){this._disabledColor!==e&&(this._disabledColor.set(e),this._updateState())}},{key:"duration",get:function(){return this._duration},set:function(e){this._duration!==e&&(this._duration=e)}},{key:"zoomScale",get:function(){return this._zoomScale},set:function(e){this._zoomScale!==e&&(this._zoomScale=e)}},{key:"normalSprite",get:function(){return this._normalSprite},set:function(e){if(this._normalSprite!==e){this._normalSprite=e;var t=this.node.getComponent(rY);t&&(t.spriteFrame=e),this._updateState()}}},{key:"pressedSprite",get:function(){return this._pressedSprite},set:function(e){this._pressedSprite!==e&&(this._pressedSprite=e,this._updateState())}},{key:"hoverSprite",get:function(){return this._hoverSprite},set:function(e){this._hoverSprite!==e&&(this._hoverSprite=e,this._updateState())}},{key:"disabledSprite",get:function(){return this._disabledSprite},set:function(e){this._disabledSprite!==e&&(this._disabledSprite=e,this._updateState())}}]),t}(Ku),sue.Transition=due,sue.EventType=gue,se((qle=cue).prototype,"target",[cle,lle,ule],Object.getOwnPropertyDescriptor(qle.prototype,"target"),qle.prototype),se(qle.prototype,"interactable",[hle,fle],Object.getOwnPropertyDescriptor(qle.prototype,"interactable"),qle.prototype),se(qle.prototype,"transition",[_le,ple,dle],Object.getOwnPropertyDescriptor(qle.prototype,"transition"),qle.prototype),se(qle.prototype,"normalColor",[mle,gle],Object.getOwnPropertyDescriptor(qle.prototype,"normalColor"),qle.prototype),se(qle.prototype,"pressedColor",[vle,yle],Object.getOwnPropertyDescriptor(qle.prototype,"pressedColor"),qle.prototype),se(qle.prototype,"hoverColor",[xle,Sle],Object.getOwnPropertyDescriptor(qle.prototype,"hoverColor"),qle.prototype),se(qle.prototype,"disabledColor",[Tle,Ele],Object.getOwnPropertyDescriptor(qle.prototype,"disabledColor"),qle.prototype),se(qle.prototype,"duration",[Ale,Cle,ble,wle],Object.getOwnPropertyDescriptor(qle.prototype,"duration"),qle.prototype),se(qle.prototype,"zoomScale",[Rle,Ple],Object.getOwnPropertyDescriptor(qle.prototype,"zoomScale"),qle.prototype),se(qle.prototype,"normalSprite",[Ile,Dle,Ole],Object.getOwnPropertyDescriptor(qle.prototype,"normalSprite"),qle.prototype),se(qle.prototype,"pressedSprite",[Mle,Nle,Lle],Object.getOwnPropertyDescriptor(qle.prototype,"pressedSprite"),qle.prototype),se(qle.prototype,"hoverSprite",[Fle,Ble,zle],Object.getOwnPropertyDescriptor(qle.prototype,"hoverSprite"),qle.prototype),se(qle.prototype,"disabledSprite",[kle,Ule,Gle],Object.getOwnPropertyDescriptor(qle.prototype,"disabledSprite"),qle.prototype),Xle=se(qle.prototype,"clickEvents",[Hle,gc,Vle,jle],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Yle=se(qle.prototype,"_interactable",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Kle=se(qle.prototype,"_transition",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return due.NONE}}),Qle=se(qle.prototype,"_normalColor",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return An.WHITE.clone()}}),Zle=se(qle.prototype,"_hoverColor",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new An(211,211,211,255)}}),Jle=se(qle.prototype,"_pressedColor",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return An.WHITE.clone()}}),$le=se(qle.prototype,"_disabledColor",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new An(124,124,124,255)}}),eue=se(qle.prototype,"_normalSprite",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),tue=se(qle.prototype,"_hoverSprite",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),nue=se(qle.prototype,"_pressedSprite",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),iue=se(qle.prototype,"_disabledSprite",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),rue=se(qle.prototype,"_duration",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return.1}}),oue=se(qle.prototype,"_zoomScale",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1.2}}),aue=se(qle.prototype,"_target",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Wle=qle))||Wle)||Wle)||Wle)||Wle)||Wle)||Wle));c.Button=yue;var xue,Sue,Tue,Eue=function(){function e(){}return e.add=function(e){var t=this._tabIndexList;-1===t.indexOf(e)&&t.push(e)},e.remove=function(e){var t=this._tabIndexList,n=t.indexOf(e);-1!==n&&t.splice(n,1)},e.resort=function(){this._tabIndexList.sort((function(e,t){return e._delegate.tabIndex-t._delegate.tabIndex}))},e.next=function(e){var t=this._tabIndexList,n=t.indexOf(e);if(e.setFocus(!1),-1!==n){var i=t[n+1];i&&i._delegate.tabIndex>=0&&i.setFocus(!0)}},e}();Eue._tabIndexList=[],function(e){e[e.DEFAULT=0]="DEFAULT",e[e.DONE=1]="DONE",e[e.SEND=2]="SEND",e[e.SEARCH=3]="SEARCH",e[e.GO=4]="GO",e[e.NEXT=5]="NEXT"}(xue||(xue={})),it(xue),function(e){e[e.ANY=0]="ANY",e[e.EMAIL_ADDR=1]="EMAIL_ADDR",e[e.NUMERIC=2]="NUMERIC",e[e.PHONE_NUMBER=3]="PHONE_NUMBER",e[e.URL=4]="URL",e[e.DECIMAL=5]="DECIMAL",e[e.SINGLE_LINE=6]="SINGLE_LINE"}(Sue||(Sue={})),it(Sue),function(e){e[e.PASSWORD=0]="PASSWORD",e[e.SENSITIVE=1]="SENSITIVE",e[e.INITIAL_CAPS_WORD=2]="INITIAL_CAPS_WORD",e[e.INITIAL_CAPS_SENTENCE=3]="INITIAL_CAPS_SENTENCE",e[e.INITIAL_CAPS_ALL_CHARACTERS=4]="INITIAL_CAPS_ALL_CHARACTERS",e[e.DEFAULT=5]="DEFAULT"}(Tue||(Tue={})),it(Tue);var Aue,Cue,bue,wue,Rue,Pue,Iue,Due,Oue,Mue,Nue,Lue,Fue,Bue,zue,kue,Uue,Gue,Hue,Vue,jue,Wue,que,Xue,Yue,Kue,Que,Zue,Jue,$ue,ehe,the,nhe,ihe,rhe,ohe,ahe,she,che,lhe,uhe,hhe,fhe,_he,phe,dhe,mhe,ghe,vhe,yhe,xhe,She,The,Ehe,Ahe,Che,bhe,whe,Rhe,Phe,Ihe,Dhe=function(){function e(){this._editing=!1,this._delegate=null}var t=e.prototype;return t.init=function(){},t.onEnable=function(){},t.update=function(){},t.onDisable=function(){this._editing&&this.endEditing()},t.clear=function(){this._delegate=null},t.setTabIndex=function(){},t.setSize=function(){},t.setFocus=function(e){e?this.beginEditing():this.endEditing()},t.isFocused=function(){return this._editing},t.beginEditing=function(){},t.endEditing=function(){},e}(),Ohe=new Gn,Mhe=new Gn,Nhe=new bn,Lhe=null,Fhe=0,Bhe=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r=0&&(t.value=t.value.slice(0,r)),i._editBoxTextChanged(t.value)}},i.onClick=function(){e._editing&&oh.isMobile&&e._adjustWindowScroll()},i.onKeydown=function(n){n.keyCode===VI.ENTER?(n.propagationStopped=!0,e._delegate._editBoxEditingReturn(),e._isTextArea||t.blur()):n.keyCode===VI.TAB&&(n.propagationStopped=!0,n.preventDefault(),Eue.next(e))},i.onBlur=function(){oh.isMobile&&n&&i.compositionEnd(),e._editing=!1,Lhe=null,e._hideDom(),e._delegate._editBoxEditingDidEnded()},t.addEventListener("compositionstart",i.compositionStart),t.addEventListener("compositionend",i.compositionEnd),t.addEventListener("input",i.onInput),t.addEventListener("keydown",i.onKeydown),t.addEventListener("blur",i.onBlur),t.addEventListener("touchstart",i.onClick)}},n._removeEventListeners=function(){if(this._edTxt){var e=this._edTxt,t=this.__eventListeners;e.removeEventListener("compositionstart",t.compositionStart),e.removeEventListener("compositionend",t.compositionEnd),e.removeEventListener("input",t.onInput),e.removeEventListener("keydown",t.onKeydown),e.removeEventListener("blur",t.onBlur),e.removeEventListener("touchstart",t.onClick),t.compositionStart=null,t.compositionEnd=null,t.onInput=null,t.onKeydown=null,t.onBlur=null,t.onClick=null}},t}(Dhe);!function(e){e.EDITING_DID_BEGAN="editing-did-began",e.EDITING_DID_ENDED="editing-did-ended",e.TEXT_CHANGED="text-changed",e.EDITING_RETURN="editing-return"}(Ihe||(Ihe={}));var zhe,khe,Uhe,Ghe,Hhe,Vhe,jhe,Whe,qhe,Xhe,Yhe,Khe,Qhe,Zhe,Jhe,$he,efe,tfe,nfe,ife,rfe,ofe,afe,sfe,cfe,lfe,ufe,hfe,ffe,_fe,pfe,dfe,mfe,gfe,vfe,yfe,xfe,Sfe,Tfe,Efe,Afe,Cfe,bfe,wfe,Rfe,Pfe,Ife,Dfe,Ofe,Mfe,Nfe,Lfe,Ffe,Bfe,zfe,kfe,Ufe,Gfe,Hfe,Vfe,jfe,Wfe=function(t){return e({EditBox:t,EditBoxComponent:t}),t}((Aue=hc("cc.EditBox"),Cue=wc(),bue=_c(110),wue=Ec(),Rue=fc(DV),Pue=zc(),Iue=Oc(),Due=zc(),Oue=Oc(),Mue=Wc(mW),Nue=zc(),Lue=Oc(),Fue=Wc(mW),Bue=zc(),zue=Oc(),kue=Wc(rH),Uue=zc(),Gue=Oc(),Hue=Wc(Tue),Vue=zc(),jue=Oc(),Wue=Wc(Sue),que=zc(),Xue=Oc(),Yue=Wc(xue),Kue=zc(),Que=Oc(),Zue=zc(),Jue=Oc(),$ue=zc(),ehe=Oc(),the=Wc([NF]),nhe=zc(),ihe=Oc(),rhe=Wc([NF]),ohe=zc(),ahe=Oc(),she=Wc([NF]),che=zc(),lhe=Oc(),uhe=Wc([NF]),hhe=zc(),fhe=Oc(),Aue(_he=Cue(_he=bue(_he=wue(_he=Rue(_he=Tc((Phe=Rhe=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r=0&&e.length>=this._maxLength&&(e=e.slice(0,this._maxLength)),this._string=e,this._updateString(e)}},{key:"placeholder",get:function(){return this._placeholderLabel?this._placeholderLabel.string:""},set:function(e){this._placeholderLabel&&(this._placeholderLabel.string=e)}},{key:"textLabel",get:function(){return this._textLabel},set:function(e){this._textLabel!==e&&(this._textLabel=e,this._textLabel&&(this._updateTextLabel(),this._updateLabels()))}},{key:"placeholderLabel",get:function(){return this._placeholderLabel},set:function(e){this._placeholderLabel!==e&&(this._placeholderLabel=e,this._placeholderLabel&&(this._updatePlaceholderLabel(),this._updateLabels()))}},{key:"backgroundImage",get:function(){return this._backgroundImage},set:function(e){this._backgroundImage!==e&&(this._backgroundImage=e,this._ensureBackgroundSprite(),this._background.spriteFrame=e)}},{key:"inputFlag",get:function(){return this._inputFlag},set:function(e){this._inputFlag=e,this._updateString(this._string)}},{key:"inputMode",get:function(){return this._inputMode},set:function(e){this._inputMode!==e&&(this._inputMode=e,this._updateTextLabel(),this._updatePlaceholderLabel())}},{key:"returnType",get:function(){return this._returnType},set:function(e){this._returnType=e}},{key:"maxLength",get:function(){return this._maxLength},set:function(e){this._maxLength=e}},{key:"tabIndex",get:function(){return this._tabIndex},set:function(e){this._tabIndex!==e&&(this._tabIndex=e,this._impl&&this._impl.setTabIndex(e))}}]),t}(Ku),Rhe._EditBoxImpl=Dhe,Rhe.KeyboardReturnType=xue,Rhe.InputFlag=Tue,Rhe.InputMode=Sue,Rhe.EventType=Ihe,se((phe=Phe).prototype,"string",[Pue,Iue],Object.getOwnPropertyDescriptor(phe.prototype,"string"),phe.prototype),se(phe.prototype,"placeholder",[Due,Oue],Object.getOwnPropertyDescriptor(phe.prototype,"placeholder"),phe.prototype),se(phe.prototype,"textLabel",[Mue,Nue,Lue],Object.getOwnPropertyDescriptor(phe.prototype,"textLabel"),phe.prototype),se(phe.prototype,"placeholderLabel",[Fue,Bue,zue],Object.getOwnPropertyDescriptor(phe.prototype,"placeholderLabel"),phe.prototype),se(phe.prototype,"backgroundImage",[kue,Uue,Gue],Object.getOwnPropertyDescriptor(phe.prototype,"backgroundImage"),phe.prototype),se(phe.prototype,"inputFlag",[Hue,Vue,jue],Object.getOwnPropertyDescriptor(phe.prototype,"inputFlag"),phe.prototype),se(phe.prototype,"inputMode",[Wue,que,Xue],Object.getOwnPropertyDescriptor(phe.prototype,"inputMode"),phe.prototype),se(phe.prototype,"returnType",[Yue,Kue,Que],Object.getOwnPropertyDescriptor(phe.prototype,"returnType"),phe.prototype),se(phe.prototype,"maxLength",[Zue,Jue],Object.getOwnPropertyDescriptor(phe.prototype,"maxLength"),phe.prototype),se(phe.prototype,"tabIndex",[$ue,ehe],Object.getOwnPropertyDescriptor(phe.prototype,"tabIndex"),phe.prototype),dhe=se(phe.prototype,"editingDidBegan",[the,gc,nhe,ihe],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),mhe=se(phe.prototype,"textChanged",[rhe,gc,ohe,ahe],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),ghe=se(phe.prototype,"editingDidEnded",[she,gc,che,lhe],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),vhe=se(phe.prototype,"editingReturn",[uhe,gc,hhe,fhe],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),yhe=se(phe.prototype,"_textLabel",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),xhe=se(phe.prototype,"_placeholderLabel",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),She=se(phe.prototype,"_returnType",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return xue.DEFAULT}}),The=se(phe.prototype,"_string",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),Ehe=se(phe.prototype,"_tabIndex",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Ahe=se(phe.prototype,"_backgroundImage",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Che=se(phe.prototype,"_inputFlag",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Tue.DEFAULT}}),bhe=se(phe.prototype,"_inputMode",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Sue.ANY}}),whe=se(phe.prototype,"_maxLength",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 20}}),_he=phe))||_he)||_he)||_he)||_he)||_he)||_he));"object"==typeof window&&"object"==typeof document&&(Wfe._EditBoxImpl=Bhe),c.internal.EditBox=Wfe,function(e){e[e.NONE=0]="NONE",e[e.HORIZONTAL=1]="HORIZONTAL",e[e.VERTICAL=2]="VERTICAL",e[e.GRID=3]="GRID"}(kfe||(kfe={})),at(kfe),function(e){e[e.NONE=0]="NONE",e[e.CONTAINER=1]="CONTAINER",e[e.CHILDREN=2]="CHILDREN"}(Ufe||(Ufe={})),at(Ufe),function(e){e[e.HORIZONTAL=0]="HORIZONTAL",e[e.VERTICAL=1]="VERTICAL"}(Gfe||(Gfe={})),at(Gfe),function(e){e[e.BOTTOM_TO_TOP=0]="BOTTOM_TO_TOP",e[e.TOP_TO_BOTTOM=1]="TOP_TO_BOTTOM"}(Hfe||(Hfe={})),at(Hfe),function(e){e[e.LEFT_TO_RIGHT=0]="LEFT_TO_RIGHT",e[e.RIGHT_TO_LEFT=1]="RIGHT_TO_LEFT"}(Vfe||(Vfe={})),at(Vfe),function(e){e[e.NONE=0]="NONE",e[e.FIXED_ROW=1]="FIXED_ROW",e[e.FIXED_COL=2]="FIXED_COL"}(jfe||(jfe={})),at(jfe);var qfe,Xfe,Yfe,Kfe,Qfe,Zfe,Jfe,$fe,e_e,t_e,n_e,i_e,r_e,o_e,a_e,s_e,c_e,l_e,u_e,h_e,f_e,__e,p_e,d_e=new bn,m_e=function(t){return e({Layout:t,LayoutComponent:t}),t}((zhe=hc("cc.Layout"),khe=wc(),Uhe=_c(110),Ghe=Ec(),Hhe=fc(DV),Vhe=Pc(),jhe=Oc(),Whe=Pc(),qhe=Oc(),Xhe=Wc(kfe),Yhe=zc(),Khe=Oc(),Qhe=Wc(Ufe),Zhe=Pc(),Jhe=Oc(),$he=Pc(),efe=Oc(),tfe=Wc(Gfe),nfe=Oc(),ife=Oc(),rfe=Oc(),ofe=Oc(),afe=Oc(),sfe=Oc(),cfe=Oc(),lfe=Wc(Hfe),ufe=Oc(),hfe=Wc(Vfe),ffe=Oc(),_fe=Wc(jfe),pfe=Pc(),dfe=Oc(),mfe=Pc(),gfe=Oc(),vfe=Oc(),zhe(yfe=khe(yfe=Uhe(yfe=Ghe(yfe=Hhe(yfe=Tc((zfe=Bfe=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r0&&(this._doLayout(),this._layoutDirty=!1)},n.onEnable=function(){this._addEventListeners();var e=this.node._uiProps.uiTransformComp;e.contentSize.equals(Jn.ZERO)&&e.setContentSize(this._layoutSize),this._childrenChanged()},n.onDisable=function(){this._usefulLayoutObj.length=0,this._removeEventListeners()},n._checkUsefulObj=function(){this._usefulLayoutObj.length=0;for(var e=this.node.children,t=0;tf&&(_=Math.max(f,_),h=f||w,f=w),l+=a*(C*b+this._spacingX);var R=a*(1-C)*b;if(t){if(o>0)(p=y/o>0&&y%o==0)&&(h=f>w?f:h);else if(b>e-g)l>c+a*C*b&&(p=!0);else{var P=(1-this._horizontalDirection-r.x)*e,I=l+R+a*(a>0?this._paddingRight:this._paddingLeft);p=Math.abs(I)>Math.abs(P)}p&&(l=c+a*C*b,w!==f&&(h=f),u+=h+this._spacingY,h=f=w)}var D=n(S,x,u);i&&S.setPosition(l,D),l+=R}return h=Math.max(h,f),Math.max(_,u+h)+this._getPaddingV()},n._doLayoutVertically=function(e,t,n,i){var r=this.node._uiProps.uiTransformComp.anchorPoint,o=this._getFixedBreakingNum(),a=1,s=this._paddingBottom;this._verticalDirection===Hfe.TOP_TO_BOTTOM&&(a=-1,s=this._paddingTop);var c=(this._verticalDirection-r.y)*e+a*s,l=c-a*this._spacingY,u=0,h=0,f=0,_=0,p=!1,d=this._usefulLayoutObj.length,m=this._cellSize.height,g=this._getPaddingV();this._layoutType!==kfe.GRID&&this._resizeMode===Ufe.CHILDREN&&(m=(e-g-(d-1)*this._spacingY)/d);for(var v=this._usefulLayoutObj,y=0;yu&&(h=Math.max(u,h),f=u||b,u=b),l+=a*(C*w+this._spacingY);var R=a*(1-C)*w;if(t){if(o>0)(p=y/o>0&&y%o==0)&&(f=u>w?u:f);else if(w>e-g)l>c+a*C*w&&(p=!0);else{var P=(1-this._verticalDirection-r.y)*e,I=l+R+a*(a>0?this._paddingTop:this._paddingBottom);p=Math.abs(I)>Math.abs(P)}p&&(l=c+a*C*w,b!==u&&(f=u),_+=f+this._spacingX,f=u=b)}var D=n(S,x,_);i&&(S.getPosition(d_e),S.setPosition(D,l,d_e.z)),l+=R}return f=Math.max(f,u),Math.max(h,_+f)+this._getPaddingH()},n._doLayoutGridAxisHorizontal=function(e,t){var n=this,i=t.width,r=1,o=-e.y*t.height,a=this._paddingBottom;this._verticalDirection===Hfe.TOP_TO_BOTTOM&&(r=-1,o=(1-e.y)*t.height,a=this._paddingTop);var s=function(e,t,i){return o+r*(i+(1-t.anchorY)*t.height*n._getUsedScaleValue(e.scale.y)+a)},c=0;this._resizeMode===Ufe.CONTAINER&&(c=this._doLayoutHorizontally(i,!0,s,!1),o=-e.y*c,this._verticalDirection===Hfe.TOP_TO_BOTTOM&&(r=-1,o=(1-e.y)*c)),this._doLayoutHorizontally(i,!0,s,!0),this._resizeMode===Ufe.CONTAINER&&this.node._uiProps.uiTransformComp.setContentSize(i,c)},n._doLayoutGridAxisVertical=function(e,t){var n=this,i=t.height,r=1,o=-e.x*t.width,a=this._paddingLeft;this._horizontalDirection===Vfe.RIGHT_TO_LEFT&&(r=-1,o=(1-e.x)*t.width,a=this._paddingRight);var s=function(e,t,i){return o+r*(i+(1-t.anchorX)*t.width*n._getUsedScaleValue(e.scale.x)+a)},c=0;this._resizeMode===Ufe.CONTAINER&&(c=this._doLayoutVertically(i,!0,s,!1),o=-e.x*c,this._horizontalDirection===Vfe.RIGHT_TO_LEFT&&(r=-1,o=(1-e.x)*c)),this._doLayoutVertically(i,!0,s,!0),this._resizeMode===Ufe.CONTAINER&&this.node._uiProps.uiTransformComp.setContentSize(c,i)},n._doLayoutGrid=function(){var e=this.node._uiProps.uiTransformComp,t=e.anchorPoint,n=e.contentSize;this.startAxis===Gfe.HORIZONTAL?this._doLayoutGridAxisHorizontal(t,n):this.startAxis===Gfe.VERTICAL&&this._doLayoutGridAxisVertical(t,n)},n._getHorizontalBaseWidth=function(){var e=this._usefulLayoutObj,t=0,n=e.length;if(this._resizeMode===Ufe.CONTAINER){for(var i=0;i0?i:-i)),n*(t/r)},n._calculatePosition=function(e,t,n,i,r,o,a){var s=t-n;o&&(s+=Math.abs(o));var c=0;s&&(c=an(c=r/s));var l=(i-a)*c;this._direction===H_e.VERTICAL?e.set(0,l):e.set(l,0)},n._updateLength=function(e){if(this._handle){var t=this._handle.node._uiProps.uiTransformComp,n=t.contentSize,i=t.anchorPoint;i.x===q_e.x&&i.y===q_e.y||t.setAnchorPoint(q_e),this._direction===H_e.HORIZONTAL?t.setContentSize(e,n.height):t.setContentSize(n.width,e)}},n._processAutoHide=function(e){if(this._enableAutoHide&&!(this._autoHideRemainingTime<=0)&&!this._touching&&(this._autoHideRemainingTime-=e,this._autoHideRemainingTime<=this._autoHideTime)){this._autoHideRemainingTime=Math.max(0,this._autoHideRemainingTime);var t=this._opacity*(this._autoHideRemainingTime/this._autoHideTime);this._setOpacity(t)}},K(t,[{key:"handle",get:function(){return this._handle},set:function(e){this._handle!==e&&(this._handle=e,this.onScroll(Wn.ZERO))}},{key:"direction",get:function(){return this._direction},set:function(e){this._direction!==e&&(this._direction=e,this.onScroll(Wn.ZERO))}},{key:"enableAutoHide",get:function(){return this._enableAutoHide},set:function(e){this._enableAutoHide!==e&&(this._enableAutoHide=e,this._enableAutoHide&&this._setOpacity(0))}},{key:"autoHideTime",get:function(){return this._autoHideTime},set:function(e){this._autoHideTime!==e&&(this._autoHideTime=e)}}]),t}(Ku),k_e.Direction=H_e,se((M_e=U_e).prototype,"handle",[T_e,E_e,A_e],Object.getOwnPropertyDescriptor(M_e.prototype,"handle"),M_e.prototype),se(M_e.prototype,"direction",[C_e,b_e,w_e],Object.getOwnPropertyDescriptor(M_e.prototype,"direction"),M_e.prototype),se(M_e.prototype,"enableAutoHide",[R_e,P_e],Object.getOwnPropertyDescriptor(M_e.prototype,"enableAutoHide"),M_e.prototype),se(M_e.prototype,"autoHideTime",[I_e,D_e],Object.getOwnPropertyDescriptor(M_e.prototype,"autoHideTime"),M_e.prototype),N_e=se(M_e.prototype,"_scrollView",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),L_e=se(M_e.prototype,"_handle",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),F_e=se(M_e.prototype,"_direction",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return H_e.HORIZONTAL}}),B_e=se(M_e.prototype,"_enableAutoHide",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),z_e=se(M_e.prototype,"_autoHideTime",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),O_e=M_e))||O_e)||O_e)||O_e)||O_e)||O_e));c.ScrollBar=Q_e;var Z_e,J_e,$_e,epe,tpe,npe,ipe,rpe,ope,ape,spe,cpe,lpe,upe,hpe,fpe,_pe,ppe,dpe,mpe,gpe,vpe,ype,xpe,Spe,Tpe,Epe,Ape,Cpe,bpe,wpe,Rpe,Ppe,Ipe,Dpe,Ope,Mpe,Npe,Lpe,Fpe,Bpe,zpe,kpe,Upe,Gpe,Hpe,Vpe,jpe,Wpe=e("ViewGroup",hc("cc.ViewGroup")(K_e=_c(110)(K_e=function(e){function t(){return e.apply(this,arguments)||this}return Z(t,e),t}(Ku))||K_e)||K_e);c.ViewGroup=Wpe;var qpe,Xpe=1e-4,Ype=new bn,Kpe=new bn,Qpe=new Wn,Zpe=new Wn,Jpe=function(){return(new Date).getMilliseconds()},$pe={"scroll-to-top":0,"scroll-to-bottom":1,"scroll-to-left":2,"scroll-to-right":3,scrolling:4,"bounce-bottom":6,"bounce-left":7,"bounce-right":8,"bounce-top":5,"scroll-ended":9,"touch-up":10,"scroll-ended-with-threshold":11,"scroll-began":12};!function(e){e.SCROLL_TO_TOP="scroll-to-top",e.SCROLL_TO_BOTTOM="scroll-to-bottom",e.SCROLL_TO_LEFT="scroll-to-left",e.SCROLL_TO_RIGHT="scroll-to-right",e.SCROLL_BEGAN="scroll-began",e.SCROLL_ENDED="scroll-ended",e.BOUNCE_TOP="bounce-top",e.BOUNCE_BOTTOM="bounce-bottom",e.BOUNCE_LEFT="bounce-left",e.BOUNCE_RIGHT="bounce-right",e.SCROLLING="scrolling",e.SCROLL_ENG_WITH_THRESHOLD="scroll-ended-with-threshold",e.TOUCH_UP="touch-up"}(qpe||(qpe={}));var ede,tde,nde,ide,rde,ode,ade,sde,cde,lde,ude,hde,fde,_de,pde,dde,mde,gde,vde,yde,xde,Sde=function(t){return e({ScrollView:t,ScrollViewComponent:t}),t}((Z_e=hc("cc.ScrollView"),J_e=wc(),$_e=_c(110),epe=Ec(),tpe=fc(DV),npe=Mc(),ipe=zc(),rpe=Oc(),ope=Mc(),ape=zc(),spe=Oc(),cpe=zc(),lpe=Oc(),upe=zc(),hpe=Oc(),fpe=Wc(kC),_pe=zc(),ppe=Oc(),dpe=zc(),mpe=Oc(),gpe=Wc(Q_e),vpe=zc(),ype=Oc(),xpe=zc(),Spe=Oc(),Tpe=Wc(Q_e),Epe=zc(),Ape=Oc(),Cpe=zc(),bpe=Oc(),wpe=Wc([NF]),Rpe=zc(),Ppe=Oc(),Z_e(Ipe=J_e(Ipe=$_e(Ipe=epe(Ipe=tpe((jpe=Vpe=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r=0?t:0,n=n>=0?n:0)},n.scrollToPercentHorizontal=function(e,t,n){var i=this._calculateMovePercentDelta({anchor:new Wn(e,0),applyToHorizontal:!0,applyToVertical:!1});t?this._startAutoScroll(i,t,!1!==n):this._moveContent(i)},n.scrollTo=function(e,t,n){var i=this._calculateMovePercentDelta({anchor:new Wn(e),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(i,t,n):this._moveContent(i)},n.scrollToPercentVertical=function(e,t,n){var i=this._calculateMovePercentDelta({anchor:new Wn(0,e),applyToHorizontal:!1,applyToVertical:!0});t?this._startAutoScroll(i,t,n):this._moveContent(i)},n.stopAutoScroll=function(){this._autoScrolling=!1,this._autoScrollAccumulatedTime=this._autoScrollTotalTime},n.setContentPosition=function(e){this._setContentPosition(e)},n._setContentPosition=function(e){if(this._content){var t=this._getContentPosition();Math.abs(e.x-t.x)7&&!this._touchMoved&&e.target!==this.node){var r=new HI(e.getTouches(),e.bubbles,Nb.TOUCH_CANCEL);r.touch=e.touch,r.simulate=!0,e.target.dispatchEvent(r),this._touchMoved=!0}this._stopPropagationIfTargetIsMe(e)}}},n._onTouchEnded=function(e,t){if(this.enabledInHierarchy&&this._content&&e&&!this._hasNestedViewGroup(e,t)){this._dispatchEvent(qpe.TOUCH_UP);var n=e.touch;this._handleReleaseLogic(n),this._touchMoved?e.propagationStopped=!0:this._stopPropagationIfTargetIsMe(e)}},n._onTouchCancelled=function(e,t){if(this.enabledInHierarchy&&this._content&&!this._hasNestedViewGroup(e,t)){if(e&&!e.simulate){var n=e.touch;this._handleReleaseLogic(n)}this._stopPropagationIfTargetIsMe(e)}},n._calculateBoundary=function(){if(this._content&&this.view){var e=this._content.getComponent(m_e);e&&e.enabledInHierarchy&&e.updateLayout();var t=this.view,n=t.width*t.anchorX,i=t.height*t.anchorY;this._leftBoundary=-n,this._bottomBoundary=-i,this._rightBoundary=this._leftBoundary+t.width,this._topBoundary=this._bottomBoundary+t.height,this._moveContentToTopLeft(t.contentSize)}},n._hasNestedViewGroup=function(e,t){if(!e||e.eventPhase!==BI.CAPTURING_PHASE)return!1;if(t)for(var n,i=oe(t);!(n=i()).done;){var r=n.value;if(this.node===r)return!(!e.target||!e.target.getComponent(Wpe));if(r.getComponent(Wpe))return!0}return!1},n._startInertiaScroll=function(e){var t=new bn(e);t.multiplyScalar(.7),this._startAttenuatingAutoScroll(t,e)},n._calculateAttenuatedFactor=function(e){return this.brake<=0?1-this.brake:(1-this.brake)*(1/(1+14e-6*e+e*e*8e-9))},n._startAttenuatingAutoScroll=function(e,t){var n=e.clone();if(n.normalize(),this._content&&this.view){var i=this._content._uiProps.uiTransformComp.contentSize,r=this.view.contentSize,o=i.width-r.width,a=i.height-r.height,s=this._calculateAttenuatedFactor(o),c=this._calculateAttenuatedFactor(a);n.x=n.x*o*(1-this.brake)*s,n.y=n.y*a*c*(1-this.brake),n.z=0}var l=e.length(),u=n.length()/l;if(n.add(e),this.brake>0&&u>7){u=Math.sqrt(u);var h=e.clone();h.multiplyScalar(u),n.set(h),n.add(e)}var f=this._calculateAutoScrollTimeByInitialSpeed(t.length());this.brake>0&&u>3&&(f*=u=3),0===this.brake&&u>1&&(f*=u),this._startAutoScroll(n,f,!0)},n._calculateAutoScrollTimeByInitialSpeed=function(e){return Math.sqrt(Math.sqrt(e/5))},n._startAutoScroll=function(e,t,n){void 0===n&&(n=!1);var i=this._flattenVectorByDirection(e);this._autoScrolling=!0,this._autoScrollTargetDelta=i,this._autoScrollAttenuate=n,bn.copy(this._autoScrollStartPosition,this._getContentPosition()),this._autoScrollTotalTime=t,this._autoScrollAccumulatedTime=0,this._autoScrollBraking=!1,this._isScrollEndedWithThresholdEventFired=!1,this._autoScrollBrakingStartPosition.set(0,0,0),this._getHowMuchOutOfBoundary().equals(bn.ZERO,Xpe)||(this._autoScrollCurrentlyOutOfBoundary=!0)},n._calculateTouchMoveVelocity=function(){var e=new bn,t=0;if((t=this._touchMoveTimeDeltas.reduce((function(e,t){return e+t}),t))<=0||t>=.5)e.set(bn.ZERO);else{var n=new bn;n=this._touchMoveDisplacements.reduce((function(e,t){return e.add(t),e}),n),e.set(n.x*(1-this.brake)/t,n.y*(1-this.brake)/t,n.z)}return e},n._flattenVectorByDirection=function(e){var t=e;return t.x=this.horizontal?t.x:0,t.y=this.vertical?t.y:0,t},n._moveContent=function(e,t){var n=this._flattenVectorByDirection(e);Ype.set(this._getContentPosition()),Ype.add(n),Ype.set(Math.round(1e4*Ype.x)*Xpe,Math.round(1e4*Ype.y)*Xpe,Ype.z),this._setContentPosition(Ype);var i=this._getHowMuchOutOfBoundary();Qpe.set(i.x,i.y),this._updateScrollBar(Qpe),this.elastic&&t&&this._startBounceBackIfNeeded()},n._getContentLeftBoundary=function(){if(!this._content)return-1;var e=this._getContentPosition(),t=this._content._uiProps.uiTransformComp;return e.x-t.anchorX*t.width},n._getContentRightBoundary=function(){if(!this._content)return-1;var e=this._content._uiProps.uiTransformComp;return this._getContentLeftBoundary()+e.width},n._getContentTopBoundary=function(){if(!this._content)return-1;var e=this._content._uiProps.uiTransformComp;return this._getContentBottomBoundary()+e.height},n._getContentBottomBoundary=function(){if(!this._content)return-1;var e=this._getContentPosition(),t=this._content._uiProps.uiTransformComp;return e.y-t.anchorY*t.height},n._getHowMuchOutOfBoundary=function(e){if((e=e||new bn).equals(bn.ZERO,Xpe)&&!this._outOfBoundaryAmountDirty)return this._outOfBoundaryAmount;var t=new bn,n=this._getContentLeftBoundary(),i=this._getContentRightBoundary();n+e.x>this._leftBoundary?t.x=this._leftBoundary-(n+e.x):i+e.xthis._bottomBoundary&&(t.y=this._bottomBoundary-(o+e.y)),e.equals(bn.ZERO,Xpe)&&(this._outOfBoundaryAmount=t,this._outOfBoundaryAmountDirty=!1),this._clampDelta(t),t},n._updateScrollBar=function(e){this._horizontalScrollBar&&this._horizontalScrollBar.onScroll(e),this.verticalScrollBar&&this.verticalScrollBar.onScroll(e)},n._onScrollBarTouchBegan=function(){this._horizontalScrollBar&&this._horizontalScrollBar.onTouchBegan(),this.verticalScrollBar&&this.verticalScrollBar.onTouchBegan()},n._onScrollBarTouchEnded=function(){this._horizontalScrollBar&&this._horizontalScrollBar.onTouchEnded(),this.verticalScrollBar&&this.verticalScrollBar.onTouchEnded()},n._dispatchEvent=function(e){if(e===qpe.SCROLL_ENDED)this._scrollEventEmitMask=0;else if(e===qpe.SCROLL_TO_TOP||e===qpe.SCROLL_TO_BOTTOM||e===qpe.SCROLL_TO_LEFT||e===qpe.SCROLL_TO_RIGHT){var t=1<<$pe[e];if(this._scrollEventEmitMask&t)return;this._scrollEventEmitMask|=t}NF.emitEvents(this.scrollEvents,this,$pe[e]),this.node.emit(e,this)},n._adjustContentOutOfBoundary=function(){if(this._content&&(this._outOfBoundaryAmountDirty=!0,this._isOutOfBoundary())){var e=this._getHowMuchOutOfBoundary();Ype.set(this._getContentPosition()),Ype.add(e),this._content.setPosition(Ype),this._updateScrollBar(Wn.ZERO)}},n._hideScrollBar=function(){this._horizontalScrollBar&&this._horizontalScrollBar.hide(),this._verticalScrollBar&&this._verticalScrollBar.hide()},n._updateScrollBarState=function(){if(this._content&&this.view){var e=this.view,t=this._content._uiProps.uiTransformComp;this.verticalScrollBar&&(t.height0?u.y-s*l+n.y>=this._bottomBoundary&&(i=qpe.SCROLL_TO_BOTTOM):n.y<0&&u.y-s*l+l+n.y<=this._topBoundary&&(i=qpe.SCROLL_TO_TOP)),this.horizontal&&(n.x<0?u.x-a*c+c+n.x<=this._rightBoundary&&(r=qpe.SCROLL_TO_RIGHT):n.x>0&&u.x-a*c+n.x>=this._leftBoundary&&(r=qpe.SCROLL_TO_LEFT))}this._moveContent(n,!1),(this.horizontal&&0!==n.x||this.vertical&&0!==n.y)&&(this._scrolling||(this._scrolling=!0,this._dispatchEvent(qpe.SCROLL_BEGAN)),this._dispatchEvent(qpe.SCROLLING)),""!==i&&this._dispatchEvent(i),""!==r&&this._dispatchEvent(r)},n._handlePressLogic=function(){this._autoScrolling&&this._dispatchEvent(qpe.SCROLL_ENDED),this._autoScrolling=!1,this._isBouncing=!1,this._touchMovePreviousTimestamp=Jpe(),this._touchMoveDisplacements.length=0,this._touchMoveTimeDeltas.length=0,this._onScrollBarTouchBegan()},n._clampDelta=function(e){if(this._content&&this.view){var t=this.view.contentSize,n=this._content._uiProps.uiTransformComp;n.width=5;)this._touchMoveDisplacements.shift(),this._touchMoveTimeDeltas.shift();this._touchMoveDisplacements.push(t);var n=Jpe();this._touchMoveTimeDeltas.push((n-this._touchMovePreviousTimestamp)/1e3),this._touchMovePreviousTimestamp=n},n._startBounceBackIfNeeded=function(){if(!this.elastic)return!1;var e=this._getHowMuchOutOfBoundary();if(this._clampDelta(e),e.equals(bn.ZERO,Xpe))return!1;var t=Math.max(this.bounceDuration,0);return this._startAutoScroll(e,t,!0),this._isBouncing||(e.y>0&&this._dispatchEvent(qpe.BOUNCE_TOP),e.y<0&&this._dispatchEvent(qpe.BOUNCE_BOTTOM),e.x>0&&this._dispatchEvent(qpe.BOUNCE_RIGHT),e.x<0&&this._dispatchEvent(qpe.BOUNCE_LEFT),this._isBouncing=!0),!0},n._processInertiaScroll=function(){if(!this._startBounceBackIfNeeded()&&this.inertia){var e=this._calculateTouchMoveVelocity();!e.equals(Ype,Xpe)&&this.brake<1&&this._startInertiaScroll(e)}this._onScrollBarTouchEnded()},n._isOutOfBoundary=function(){return!this._getHowMuchOutOfBoundary().equals(bn.ZERO,Xpe)},n._isNecessaryAutoScrollBrake=function(){if(this._autoScrollBraking)return!0;if(this._isOutOfBoundary()){if(!this._autoScrollCurrentlyOutOfBoundary)return this._autoScrollCurrentlyOutOfBoundary=!0,this._autoScrollBraking=!0,this._autoScrollBrakingStartPosition=this._getContentPosition(),!0}else this._autoScrollCurrentlyOutOfBoundary=!1;return!1},n._processAutoScrolling=function(e){var t=this._isNecessaryAutoScrollBrake(),n=t?.05:1;this._autoScrollAccumulatedTime+=e*(1/n);var i,r=Math.min(1,this._autoScrollAccumulatedTime/this._autoScrollTotalTime);this._autoScrollAttenuate&&(i=r,r=(i-=1)*i*i*i*i+1);var o=this._autoScrollTargetDelta.clone();o.multiplyScalar(r);var a=this._autoScrollStartPosition.clone();a.add(o);var s=Math.abs(r-1)<=Xpe;if(Math.abs(r-1)<=this.getScrollEndedEventTiming()&&!this._isScrollEndedWithThresholdEventFired&&(this._dispatchEvent(qpe.SCROLL_ENG_WITH_THRESHOLD),this._isScrollEndedWithThresholdEventFired=!0),this.elastic){var c=a.clone();c.subtract(this._autoScrollBrakingStartPosition),t&&c.multiplyScalar(n),a.set(this._autoScrollBrakingStartPosition),a.add(c)}else{var l=a.clone();l.subtract(this.getContentPosition());var u=this._getHowMuchOutOfBoundary(l);u.equals(bn.ZERO,Xpe)||(a.add(u),s=!0)}s&&(this._autoScrolling=!1);var h=a.clone();h.subtract(this._getContentPosition()),this._clampDelta(h),this._moveContent(h,s),this._dispatchEvent(qpe.SCROLLING),this._autoScrolling||(this._isBouncing=!1,this._scrolling=!1,this._dispatchEvent(qpe.SCROLL_ENDED))},n._checkMouseWheel=function(e){if(!this._getHowMuchOutOfBoundary().equals(bn.ZERO,Xpe))return this._processInertiaScroll(),this.unschedule(this._checkMouseWheel),this._dispatchEvent(qpe.SCROLL_ENDED),void(this._stopMouseWheel=!1);this._mouseWheelEventElapsedTime+=e,this._mouseWheelEventElapsedTime>.1&&(this._onScrollBarTouchEnded(),this.unschedule(this._checkMouseWheel),this._dispatchEvent(qpe.SCROLL_ENDED),this._stopMouseWheel=!1)},n._calculateMovePercentDelta=function(e){var t=e.anchor,n=e.applyToHorizontal,i=e.applyToVertical;this._calculateBoundary(),t.clampf(Wn.ZERO,Wn.ONE);var r=this._getContentBottomBoundary()-this._bottomBoundary;r=-r;var o=this._getContentLeftBoundary()-this._leftBoundary;o=-o;var a=new bn;if(this._content&&this.view){var s=0,c=this._content._uiProps.uiTransformComp.contentSize,l=this.view.contentSize;n&&(s=c.width-l.width,a.x=o-s*t.x),i&&(s=c.height-l.height,a.y=r-s*t.y)}return a},n._moveContentToTopLeft=function(e){var t=this._getContentBottomBoundary()-this._bottomBoundary;t=-t;var n=new bn,i=0,r=this._getContentLeftBoundary()-this._leftBoundary;if(r=-r,this._content){var o=this._content._uiProps.uiTransformComp.contentSize;o.height1)for(var i=n[0],r=0;r0){var n=this.node.parent&&this.node.parent._uiProps,i=n&&n.uiTransformComp,r=i?i.contentSize:GM;this.isAlignLeft&&e===Jme.LEFT?this._left=t?this._left*r.width:this._left/r.width:this.isAlignRight&&e===Jme.RIGHT?this._right=t?this._right*r.width:this._right/r.width:this.isAlignHorizontalCenter&&e===Jme.CENTER?this._horizontalCenter=t?this._horizontalCenter*r.width:this._horizontalCenter/r.width:this.isAlignTop&&e===Jme.TOP?this._top=t?this._top*r.height:this._top/r.height:this.isAlignBottom&&e===Jme.BOT?this._bottom=t?this._bottom*r.height:this._bottom/r.height:this.isAbsoluteVerticalCenter&&e===Jme.MID&&(this._verticalCenter=this._verticalCenter/r.height),this._recursiveDirty()}},n._registerTargetEvents=function(){var e=this._target||this.node.parent;e&&e.getComponent(DV)&&(e.on(BE.TRANSFORM_CHANGED,this._setDirtyByMode,this),e.on(BE.SIZE_CHANGED,this._setDirtyByMode,this),e.on(BE.ANCHOR_CHANGED,this._setDirtyByMode,this))},n._unregisterTargetEvents=function(){var e=this._target||this.node.parent;e&&(e.off(BE.TRANSFORM_CHANGED,this._setDirtyByMode,this),e.off(BE.SIZE_CHANGED,this._setDirtyByMode,this),e.off(BE.ANCHOR_CHANGED,this._setDirtyByMode,this))},n._unregisterOldParentEvents=function(e){var t=this._target||e;t&&(t.off(BE.TRANSFORM_CHANGED,this._setDirtyByMode,this),t.off(BE.SIZE_CHANGED,this._setDirtyByMode,this))},n._setDirtyByMode=function(){this.alignMode===Zme.ALWAYS&&this._recursiveDirty()},n._setAlign=function(e,t){if(t!==(this._alignFlags&e)>0){var n=(e&Tge)>0,i=this.node._uiProps.uiTransformComp;t?(this._alignFlags|=e,n?(this.isAlignHorizontalCenter=!1,this.isStretchWidth&&(this._originalWidth=i.width)):(this.isAlignVerticalCenter=!1,this.isStretchHeight&&(this._originalHeight=i.height))):(n?this.isStretchWidth&&(i.width=this._originalWidth):this.isStretchHeight&&(i.height=this._originalHeight),this._alignFlags&=~e)}},n._recursiveDirty=function(){this._dirty||(this._dirty=!0)},K(t,[{key:"target",get:function(){return this._target},set:function(e){this._target!==e&&(this._unregisterTargetEvents(),this._target=e,this._registerTargetEvents(),this._validateTargetInDEV(),this._recursiveDirty())}},{key:"isAlignTop",get:function(){return(this._alignFlags&Jme.TOP)>0},set:function(e){this._setAlign(Jme.TOP,e),this._recursiveDirty()}},{key:"isAlignBottom",get:function(){return(this._alignFlags&Jme.BOT)>0},set:function(e){this._setAlign(Jme.BOT,e),this._recursiveDirty()}},{key:"isAlignLeft",get:function(){return(this._alignFlags&Jme.LEFT)>0},set:function(e){this._setAlign(Jme.LEFT,e),this._recursiveDirty()}},{key:"isAlignRight",get:function(){return(this._alignFlags&Jme.RIGHT)>0},set:function(e){this._setAlign(Jme.RIGHT,e),this._recursiveDirty()}},{key:"isAlignVerticalCenter",get:function(){return(this._alignFlags&Jme.MID)>0},set:function(e){e?(this.isAlignTop=!1,this.isAlignBottom=!1,this._alignFlags|=Jme.MID):this._alignFlags&=~Jme.MID,this._recursiveDirty()}},{key:"isAlignHorizontalCenter",get:function(){return(this._alignFlags&Jme.CENTER)>0},set:function(e){e?(this.isAlignLeft=!1,this.isAlignRight=!1,this._alignFlags|=Jme.CENTER):this._alignFlags&=~Jme.CENTER,this._recursiveDirty()}},{key:"isStretchWidth",get:function(){return(this._alignFlags&Tge)===Tge}},{key:"isStretchHeight",get:function(){return(this._alignFlags&Sge)===Sge}},{key:"top",get:function(){return this._top},set:function(e){this._top=e,this._recursiveDirty()}},{key:"editorTop",get:function(){return this._isAbsTop?this._top:100*this._top},set:function(e){this._top=this._isAbsTop?e:e/100,this._recursiveDirty()}},{key:"bottom",get:function(){return this._bottom},set:function(e){this._bottom=e,this._recursiveDirty()}},{key:"editorBottom",get:function(){return this._isAbsBottom?this._bottom:100*this._bottom},set:function(e){this._bottom=this._isAbsBottom?e:e/100,this._recursiveDirty()}},{key:"left",get:function(){return this._left},set:function(e){this._left=e,this._recursiveDirty()}},{key:"editorLeft",get:function(){return this._isAbsLeft?this._left:100*this._left},set:function(e){this._left=this._isAbsLeft?e:e/100,this._recursiveDirty()}},{key:"right",get:function(){return this._right},set:function(e){this._right=e,this._recursiveDirty()}},{key:"editorRight",get:function(){return this._isAbsRight?this._right:100*this._right},set:function(e){this._right=this._isAbsRight?e:e/100,this._recursiveDirty()}},{key:"horizontalCenter",get:function(){return this._horizontalCenter},set:function(e){this._horizontalCenter=e,this._recursiveDirty()}},{key:"editorHorizontalCenter",get:function(){return this._isAbsHorizontalCenter?this._horizontalCenter:100*this._horizontalCenter},set:function(e){this._horizontalCenter=this._isAbsHorizontalCenter?e:e/100,this._recursiveDirty()}},{key:"verticalCenter",get:function(){return this._verticalCenter},set:function(e){this._verticalCenter=e,this._recursiveDirty()}},{key:"editorVerticalCenter",get:function(){return this._isAbsVerticalCenter?this._verticalCenter:100*this._verticalCenter},set:function(e){this._verticalCenter=this._isAbsVerticalCenter?e:e/100,this._recursiveDirty()}},{key:"isAbsoluteTop",get:function(){return this._isAbsTop},set:function(e){this._isAbsTop!==e&&(this._isAbsTop=e,this._autoChangedValue(Jme.TOP,this._isAbsTop))}},{key:"isAbsoluteBottom",get:function(){return this._isAbsBottom},set:function(e){this._isAbsBottom!==e&&(this._isAbsBottom=e,this._autoChangedValue(Jme.BOT,this._isAbsBottom))}},{key:"isAbsoluteLeft",get:function(){return this._isAbsLeft},set:function(e){this._isAbsLeft!==e&&(this._isAbsLeft=e,this._autoChangedValue(Jme.LEFT,this._isAbsLeft))}},{key:"isAbsoluteRight",get:function(){return this._isAbsRight},set:function(e){this._isAbsRight!==e&&(this._isAbsRight=e,this._autoChangedValue(Jme.RIGHT,this._isAbsRight))}},{key:"isAbsoluteHorizontalCenter",get:function(){return this._isAbsHorizontalCenter},set:function(e){this._isAbsHorizontalCenter!==e&&(this._isAbsHorizontalCenter=e,this._autoChangedValue(Jme.CENTER,this._isAbsHorizontalCenter))}},{key:"isAbsoluteVerticalCenter",get:function(){return this._isAbsVerticalCenter},set:function(e){this._isAbsVerticalCenter!==e&&(this._isAbsVerticalCenter=e,this._autoChangedValue(Jme.MID,this._isAbsVerticalCenter))}},{key:"alignMode",get:function(){return this._alignMode},set:function(e){this._alignMode=e,this._recursiveDirty()}},{key:"alignFlags",get:function(){return this._alignFlags},set:function(e){this._alignFlags!==e&&(this._alignFlags=e,this._recursiveDirty())}}]),t}(Ku),Yme.AlignMode=Zme,se((Pme=Kme).prototype,"target",[ume,hme],Object.getOwnPropertyDescriptor(Pme.prototype,"target"),Pme.prototype),se(Pme.prototype,"isAlignTop",[fme],Object.getOwnPropertyDescriptor(Pme.prototype,"isAlignTop"),Pme.prototype),se(Pme.prototype,"isAlignBottom",[_me],Object.getOwnPropertyDescriptor(Pme.prototype,"isAlignBottom"),Pme.prototype),se(Pme.prototype,"isAlignLeft",[pme],Object.getOwnPropertyDescriptor(Pme.prototype,"isAlignLeft"),Pme.prototype),se(Pme.prototype,"isAlignRight",[dme],Object.getOwnPropertyDescriptor(Pme.prototype,"isAlignRight"),Pme.prototype),se(Pme.prototype,"isAlignVerticalCenter",[mme],Object.getOwnPropertyDescriptor(Pme.prototype,"isAlignVerticalCenter"),Pme.prototype),se(Pme.prototype,"isAlignHorizontalCenter",[gme],Object.getOwnPropertyDescriptor(Pme.prototype,"isAlignHorizontalCenter"),Pme.prototype),se(Pme.prototype,"isStretchWidth",[vme],Object.getOwnPropertyDescriptor(Pme.prototype,"isStretchWidth"),Pme.prototype),se(Pme.prototype,"isStretchHeight",[yme],Object.getOwnPropertyDescriptor(Pme.prototype,"isStretchHeight"),Pme.prototype),se(Pme.prototype,"top",[xme],Object.getOwnPropertyDescriptor(Pme.prototype,"top"),Pme.prototype),se(Pme.prototype,"editorTop",[Rc],Object.getOwnPropertyDescriptor(Pme.prototype,"editorTop"),Pme.prototype),se(Pme.prototype,"bottom",[Sme],Object.getOwnPropertyDescriptor(Pme.prototype,"bottom"),Pme.prototype),se(Pme.prototype,"editorBottom",[Rc],Object.getOwnPropertyDescriptor(Pme.prototype,"editorBottom"),Pme.prototype),se(Pme.prototype,"left",[Tme],Object.getOwnPropertyDescriptor(Pme.prototype,"left"),Pme.prototype),se(Pme.prototype,"editorLeft",[Rc],Object.getOwnPropertyDescriptor(Pme.prototype,"editorLeft"),Pme.prototype),se(Pme.prototype,"right",[Eme],Object.getOwnPropertyDescriptor(Pme.prototype,"right"),Pme.prototype),se(Pme.prototype,"editorRight",[Rc],Object.getOwnPropertyDescriptor(Pme.prototype,"editorRight"),Pme.prototype),se(Pme.prototype,"horizontalCenter",[Ame],Object.getOwnPropertyDescriptor(Pme.prototype,"horizontalCenter"),Pme.prototype),se(Pme.prototype,"editorHorizontalCenter",[Rc],Object.getOwnPropertyDescriptor(Pme.prototype,"editorHorizontalCenter"),Pme.prototype),se(Pme.prototype,"verticalCenter",[Cme],Object.getOwnPropertyDescriptor(Pme.prototype,"verticalCenter"),Pme.prototype),se(Pme.prototype,"editorVerticalCenter",[Rc],Object.getOwnPropertyDescriptor(Pme.prototype,"editorVerticalCenter"),Pme.prototype),se(Pme.prototype,"isAbsoluteTop",[Rc],Object.getOwnPropertyDescriptor(Pme.prototype,"isAbsoluteTop"),Pme.prototype),se(Pme.prototype,"isAbsoluteBottom",[Rc],Object.getOwnPropertyDescriptor(Pme.prototype,"isAbsoluteBottom"),Pme.prototype),se(Pme.prototype,"isAbsoluteLeft",[Rc],Object.getOwnPropertyDescriptor(Pme.prototype,"isAbsoluteLeft"),Pme.prototype),se(Pme.prototype,"isAbsoluteRight",[Rc],Object.getOwnPropertyDescriptor(Pme.prototype,"isAbsoluteRight"),Pme.prototype),se(Pme.prototype,"isAbsoluteHorizontalCenter",[Rc],Object.getOwnPropertyDescriptor(Pme.prototype,"isAbsoluteHorizontalCenter"),Pme.prototype),se(Pme.prototype,"isAbsoluteVerticalCenter",[Rc],Object.getOwnPropertyDescriptor(Pme.prototype,"isAbsoluteVerticalCenter"),Pme.prototype),se(Pme.prototype,"alignMode",[bme,wme],Object.getOwnPropertyDescriptor(Pme.prototype,"alignMode"),Pme.prototype),se(Pme.prototype,"alignFlags",[Rc],Object.getOwnPropertyDescriptor(Pme.prototype,"alignFlags"),Pme.prototype),Ime=se(Pme.prototype,"_alignFlags",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Dme=se(Pme.prototype,"_target",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Ome=se(Pme.prototype,"_left",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Mme=se(Pme.prototype,"_right",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Nme=se(Pme.prototype,"_top",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Lme=se(Pme.prototype,"_bottom",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Fme=se(Pme.prototype,"_horizontalCenter",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Bme=se(Pme.prototype,"_verticalCenter",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),zme=se(Pme.prototype,"_isAbsLeft",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),kme=se(Pme.prototype,"_isAbsRight",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Ume=se(Pme.prototype,"_isAbsTop",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Gme=se(Pme.prototype,"_isAbsBottom",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Hme=se(Pme.prototype,"_isAbsHorizontalCenter",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Vme=se(Pme.prototype,"_isAbsVerticalCenter",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),jme=se(Pme.prototype,"_originalWidth",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Wme=se(Pme.prototype,"_originalHeight",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),qme=se(Pme.prototype,"_alignMode",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Zme.ON_WINDOW_RESIZE}}),Xme=se(Pme.prototype,"_lockFlags",[gc,yc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Rme=Pme))||Rme)||Rme)||Rme)||Rme)||Rme)||Rme));c.internal.computeInverseTransForTarget=tge,c.internal.getReadonlyNodeSize=ege,c.Widget=Ege;var Age,Cge=new An;!function(e){e[e.HORIZONTAL=0]="HORIZONTAL",e[e.VERTICAL=1]="VERTICAL"}(Age||(Age={})),at(Age);var bge,wge,Rge,Pge,Ige,Dge,Oge,Mge,Nge,Lge,Fge,Bge,zge,kge,Uge,Gge,Hge,Vge,jge,Wge,qge,Xge,Yge,Kge,Qge,Zge,Jge,$ge,eve,tve,nve,ive,rve,ove,ave,sve,cve,lve,uve,hve,fve,_ve,pve,dve=function(t){return e({PageViewIndicator:t,PageViewIndicatorComponent:t}),t}((nge=hc("cc.PageViewIndicator"),ige=wc(),rge=_c(110),oge=Ec(),age=Wc(rH),sge=Oc(),cge=Wc(Age),lge=Oc(),uge=Wc(Jn),hge=Oc(),fge=Oc(),nge(_ge=ige(_ge=rge(_ge=oge((xge=yge=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r=e.length)){for(var n=0;ne.length)for(n=0;n0;--n){var i=e[n-1];this.node.removeChild(i),e.splice(n-1,1)}this._layout&&this._layout.enabledInHierarchy&&this._layout.updateLayout(),this._changedState()}}},K(t,[{key:"spriteFrame",get:function(){return this._spriteFrame},set:function(e){this._spriteFrame!==e&&(this._spriteFrame=e)}},{key:"direction",get:function(){return this._direction},set:function(e){this._direction!==e&&(this._direction=e)}},{key:"cellSize",get:function(){return this._cellSize},set:function(e){this._cellSize!==e&&(this._cellSize=e)}}]),t}(Ku),yge.Direction=Age,se((pge=xge).prototype,"spriteFrame",[age,sge],Object.getOwnPropertyDescriptor(pge.prototype,"spriteFrame"),pge.prototype),se(pge.prototype,"direction",[cge,lge],Object.getOwnPropertyDescriptor(pge.prototype,"direction"),pge.prototype),se(pge.prototype,"cellSize",[uge,hge],Object.getOwnPropertyDescriptor(pge.prototype,"cellSize"),pge.prototype),dge=se(pge.prototype,"spacing",[gc,fge],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),mge=se(pge.prototype,"_spriteFrame",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),gge=se(pge.prototype,"_direction",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Age.HORIZONTAL}}),vge=se(pge.prototype,"_cellSize",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Jn(20,20)}}),_ge=pge))||_ge)||_ge)||_ge)||_ge));c.PageViewIndicator=dve;var mve,gve,vve,yve=new Wn;!function(e){e[e.Unified=0]="Unified",e[e.Free=1]="Free"}(mve||(mve={})),at(mve),function(e){e[e.Horizontal=0]="Horizontal",e[e.Vertical=1]="Vertical"}(gve||(gve={})),at(gve),function(e){e.PAGE_TURNING="page-turning"}(vve||(vve={}));var xve=function(t){return e({PageView:t,PageViewComponent:t}),t}((bge=hc("cc.PageView"),wge=wc(),Rge=_c(110),Pge=Ec(),Ige=Wc(mve),Dge=Oc(),Oge=Wc(gve),Mge=Oc(),Nge=Mc(),Lge=Oc(),Fge=Mc(),Bge=Oc(),zge=Wc(dve),kge=Oc(),Uge=Oc(),Gge=Wc(Q_e),Hge=Pc(),Vge=Wc(Q_e),jge=Pc(),Wge=Pc(),qge=Pc(),Xge=Pc(),Yge=Wc([NF]),Kge=Pc(),Qge=Oc(),Zge=Wc([NF]),Jge=Oc(),bge($ge=wge($ge=Rge($ge=Pge((pve=_ve=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r=this._pages.length)this.addPage(e);else{if(!e._uiProps.uiTransformComp)return void w(4301);this._pages.splice(t,0,e),this.content.insertChild(e,t),this._updatePageView()}},n.removePage=function(e){if(e&&this.content){var t=this._pages.indexOf(e);-1!==t?this.removePageAtIndex(t):P(4300,e.name)}},n.removePageAtIndex=function(e){var t=this._pages;if(!(e<0||e>=t.length)){var n=t[e];n&&this.content&&(this.content.removeChild(n),t.splice(e,1),this._updatePageView())}},n.removeAllPages=function(){if(this.content){for(var e=this._pages,t=0,n=e.length;t=this._pages.length||(this._curPageIdx=e,this.scrollToOffset(this._moveOffsetValue(e),t,!0),this.indicator&&this.indicator._changedState())},n.getScrollEndedEventTiming=function(){return this.pageTurningEventTiming},n._updatePageView=function(){if(this.content){var e=this.content.getComponent(m_e);e&&e.enabled&&e.updateLayout();var t=this._pages.length;this._curPageIdx>=t&&(this._curPageIdx=0===t?0:t-1,this._lastPageIdx=this._curPageIdx);for(var n=this._initContentPos,i=0;i0){var n=this._pages[0]._uiProps.uiTransformComp,i=this._pages[this._pages.length-1]._uiProps.uiTransformComp;this.direction===gve.Horizontal?(t.paddingLeft=(e.width-n.width)/2,t.paddingRight=(e.width-i.width)/2):this.direction===gve.Vertical&&(t.paddingTop=(e.height-n.height)/2,t.paddingBottom=(e.height-i.height)/2)}t.updateLayout()}}},n._initPages=function(){if(this.content){this._initContentPos=this.content.position;for(var e=this.content.children,t=0;t=0||this._pages.push(n)}this._syncScrollDirection(),this._syncSizeMode(),this._updatePageView()}},n._dispatchPageTurningEvent=function(){this._lastPageIdx!==this._curPageIdx&&(this._lastPageIdx=this._curPageIdx,NF.emitEvents(this.pageEvents,this,vve.PAGE_TURNING),this.node.emit(vve.PAGE_TURNING,this))},n._isQuicklyScrollable=function(e){if(this.direction===gve.Horizontal){if(Math.abs(e.x)>this.autoPageTurningThreshold)return!0}else if(this.direction===gve.Vertical&&Math.abs(e.y)>this.autoPageTurningThreshold)return!0;return!1},n._moveOffsetValue=function(e){var t=new Wn;if(this._sizeMode===mve.Free)this.direction===gve.Horizontal?t.x=this._scrollCenterOffsetX[e]:this.direction===gve.Vertical&&(t.y=this._scrollCenterOffsetY[e]);else{var n=this.view;if(!n)return t;this.direction===gve.Horizontal?t.x=e*n.width:this.direction===gve.Vertical&&(t.y=e*n.height)}return t},n._getDragDirection=function(e){return this._direction===gve.Horizontal?0===e.x?0:e.x>0?1:-1:0===e.y?0:e.y<0?1:-1},n._isScrollable=function(e,t,n){if(this._sizeMode===mve.Free){var i=0,r=0;if(this.direction===gve.Horizontal)return i=this._scrollCenterOffsetX[t],r=this._scrollCenterOffsetX[n],Math.abs(e.x)>=Math.abs(i-r)*this.scrollThreshold;if(this.direction===gve.Vertical)return i=this._scrollCenterOffsetY[t],r=this._scrollCenterOffsetY[n],Math.abs(e.y)>=Math.abs(i-r)*this.scrollThreshold}else{var o=this.view;if(!o)return!1;if(this.direction===gve.Horizontal)return Math.abs(e.x)>=o.width*this.scrollThreshold;if(this.direction===gve.Vertical)return Math.abs(e.y)>=o.height*this.scrollThreshold}return!1},n._autoScrollToPage=function(){if(this._startBounceBackIfNeeded()){var e=this._getHowMuchOutOfBoundary();this._clampDelta(e),(e.x>0||e.y<0)&&(this._curPageIdx=0===this._pages.length?0:this._pages.length-1),(e.x<0||e.y>0)&&(this._curPageIdx=0),this.indicator&&this.indicator._changedState()}else{var t=new Wn;Wn.subtract(t,this._touchBeganPosition,this._touchEndPosition);var n=this._curPageIdx,i=n+this._getDragDirection(t),r=this.pageTurningSpeed*Math.abs(n-i);if(i1e-10?t:e}var i=e.node,r=i.parent;if(r){var o=Cve;o.set(0,0);var a=bve;if(a.set(1,1),e.target&&tge(i,r=e.target,o,a),!t)return;var s=r._uiProps&&r._uiProps.uiTransformComp,c=s?s.anchorPoint:Tve,l=i._uiProps.uiTransformComp,u=ege(r),h=l.anchorPoint,f=i.getPosition(),_=Jme,p=i.getScale(),d=0;if(t&_.LEFT){var m=-c.x*u.width;m+=o.x,m*=a.x,d=f.x-h.x*l.width*p.x-m,e.isAbsoluteLeft||(d/=u.width),d/=a.x,e.left=n(e.left,d)}if(t&_.RIGHT){var g=(1-c.x)*u.width;g+=o.x,d=(g*=a.x)-(f.x+(1-h.x)*l.width*p.x),e.isAbsoluteRight||(d/=u.width),d/=a.x,e.right=n(e.right,d)}if(t&_.TOP){var v=(1-c.y)*u.height;v+=o.y,d=(v*=a.y)-(f.y+(1-h.y)*l.height*p.y),e.isAbsoluteTop||(d/=u.height),d/=a.y,e.top=n(e.top,d)}if(t&_.BOT){var y=-c.y*u.height;y+=o.y,y*=a.y,d=f.y-h.y*l.height*p.y-y,e.isAbsoluteBottom||(d/=u.height),d/=a.y,e.bottom=n(e.bottom,d)}}},updateAlignment:function e(t){var n=t.parent;n&&kC.isNode(n)&&e(n);var i=t.getComponent(Ege);i&&n&&wve(t,i)},AlignMode:Zme,AlignFlags:Jme});zM.on(BM.EVENT_INIT,(function(){Ove.init()}));var Mve,Nve,Lve,Fve,Bve,zve,kve,Uve,Gve,Hve,Vve,jve,Wve,qve,Xve,Yve,Kve,Qve,Zve,Jve=function(t){return e({SafeArea:t,SafeAreaComponent:t}),t}(hc("cc.SafeArea")(Ive=wc()(Ive=_c(110)(Ive=Tc(Ive=Ec()(Ive=fc(Ege)(Ive=function(e){function t(){return e.apply(this,arguments)||this}Z(t,e);var n=t.prototype;return n.onEnable=function(){this.updateArea(),nh.on("window-resize",this.updateArea,this),nh.on("orientation-change",this.updateArea,this)},n.onDisable=function(){nh.off("window-resize",this.updateArea,this),nh.off("orientation-change",this.updateArea,this)},n.updateArea=function(){var e=this.node.getComponent(Ege),t=this.node.getComponent(DV);if(e&&t){e.updateAlignment();var n=this.node.position.clone(),i=t.anchorPoint.clone();e.isAlignTop=e.isAlignBottom=e.isAlignLeft=e.isAlignRight=!0;var r=YM.getVisibleSize(),o=r.width,a=r.height,s=oh.getSafeAreaRect();e.top=a-s.y-s.height,e.bottom=s.y,e.left=s.x,e.right=o-s.x-s.width,e.updateAlignment();var c=this.node.position.clone(),l=i.x-(c.x-n.x)/t.width,u=i.y-(c.y-n.y)/t.height;t.setAnchorPoint(l,u),Ove.add(e)}},t}(Ku))||Ive)||Ive)||Ive)||Ive)||Ive)||Ive);c.SafeArea=Jve;var $ve,eye=function(t){return e({UICoordinateTracker:t,UICoordinateTrackerComponent:t}),t}((Mve=hc("cc.UICoordinateTracker"),Nve=wc(),Lve=Ec(),Fve=_c(110),Bve=Wc(kC),zve=Oc(),kve=Wc($F),Uve=Oc(),Gve=Oc(),Hve=Oc(),Vve=Wc([NF]),jve=Oc(),Mve(Wve=Nve(Wve=Lve(Wve=Fve((se((qve=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r0)){var n=this._distance/Math.abs(this._viewPos.z);NF.emitEvents(this.syncEvents,this._transformPos,n)}},n._checkCanMove=function(){this._canMove=!(!this._camera||!this._target)},K(t,[{key:"target",get:function(){return this._target},set:function(e){this._target!==e&&(this._target=e,this._checkCanMove())}},{key:"camera",get:function(){return this._camera},set:function(e){this._camera!==e&&(this._camera=e,this._checkCanMove())}},{key:"useScale",get:function(){return this._useScale},set:function(e){this._useScale!==e&&(this._useScale=e)}},{key:"distance",get:function(){return this._distance},set:function(e){this._distance!==e&&(this._distance=e)}}]),t}(Ku)).prototype,"target",[Bve,zve],Object.getOwnPropertyDescriptor(qve.prototype,"target"),qve.prototype),se(qve.prototype,"camera",[kve,Uve],Object.getOwnPropertyDescriptor(qve.prototype,"camera"),qve.prototype),se(qve.prototype,"useScale",[Gve],Object.getOwnPropertyDescriptor(qve.prototype,"useScale"),qve.prototype),se(qve.prototype,"distance",[Hve],Object.getOwnPropertyDescriptor(qve.prototype,"distance"),qve.prototype),Xve=se(qve.prototype,"syncEvents",[Vve,gc,jve],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),Yve=se(qve.prototype,"_target",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Kve=se(qve.prototype,"_camera",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Qve=se(qve.prototype,"_useScale",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Zve=se(qve.prototype,"_distance",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),Wve=qve))||Wve)||Wve)||Wve)||Wve)),tye=[BE.TOUCH_START,BE.TOUCH_END,BE.TOUCH_MOVE,BE.MOUSE_DOWN,BE.MOUSE_MOVE,BE.MOUSE_UP,BE.MOUSE_ENTER,BE.MOUSE_LEAVE,BE.MOUSE_WHEEL];function nye(e){e.propagationStopped=!0}var iye,rye,oye,aye,sye,cye,lye,uye,hye,fye,_ye,pye,dye=function(t){return e({BlockInputEvents:t,BlockInputEventsComponent:t}),t}(hc("cc.BlockInputEvents")($ve=wc()($ve=Ec()($ve=function(e){function t(){return e.apply(this,arguments)||this}Z(t,e);var n=t.prototype;return n.onEnable=function(){for(var e=0;ei?i:n;t.width*=r,t.height*=r;var o=YM.getViewportRect(),a=t.getBoundingBoxToWorld(),s=YM.getVisibleSize(),c=nh.devicePixelRatio,l=(o.width*(a.x/s.width)+o.x)/c,u=(o.height*(a.y/s.height)+o.y)/c,h=o.width*(a.width/s.width)/c,f=o.height*(a.height/s.height)/c;this._openDataContext.postMessage({fromEngine:!0,type:"engine",event:"viewport",x:l,y:u,width:h,height:f})}},n._updateSubContextTexture=function(){var e=this._imageAsset;if(e&&this._openDataContext&&!(e.width<=0||e.height<=0)){var t=this._openDataContext.canvas;e.reset(t),(t.width>e.width||t.height>e.height)&&this._texture.create(t.width,t.height),this._texture.uploadData(t)}},n._registerNodeEvent=function(){this.node.on(BE.TRANSFORM_CHANGED,this._updateSubContextView,this),this.node.on(BE.SIZE_CHANGED,this._updateSubContextView,this),this.node.on(BE.LAYER_CHANGED,this._updateContentLayer,this)},n._unregisterNodeEvent=function(){this.node.off(BE.TRANSFORM_CHANGED,this._updateSubContextView,this),this.node.off(BE.SIZE_CHANGED,this._updateSubContextView,this),this.node.off(BE.LAYER_CHANGED,this._updateContentLayer,this)},n._updateContentLayer=function(){this._content.layer=this.node.layer},n.update=function(e){void 0===e?this._updateSubContextTexture():performance.now()-this._updatedTime>=this._updateInterval&&(this._updatedTime+=this._updateInterval,this._updateSubContextTexture())},n.onDestroy=function(){this._content.destroy(),this._texture.destroy(),this._sprite&&this._sprite.destroy(),this._imageAsset.destroy(),this._openDataContext=null},K(t,[{key:"designResolutionSize",get:function(){return this._designResolutionSize},set:function(){}},{key:"fps",get:function(){return this._fps},set:function(e){this._fps!==e&&(this._fps=e,this._updateInterval=1e3/e)}}]),t}(Ku)).prototype,"designResolutionSize",[cye],Object.getOwnPropertyDescriptor(hye.prototype,"designResolutionSize"),hye.prototype),se(hye.prototype,"fps",[lye],Object.getOwnPropertyDescriptor(hye.prototype,"fps"),hye.prototype),fye=se(hye.prototype,"_fps",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 60}}),_ye=se(hye.prototype,"_designResolutionSize",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Jn(640,960)}}),uye=hye))||uye)||uye)||uye)||uye)||uye));c.SubContextView=gye;var vye,yye,xye,Sye,Tye=e("UIReorderComponent",hc("cc.UIReorderComponent")(pye=function(){P(1408,"UIReorderComponent")})||pye);c.UIReorderComponent=Tye,c.ButtonComponent=yue,tt.setClassAlias(yue,"cc.ButtonComponent"),c.EditBoxComponent=Wfe,tt.setClassAlias(Wfe,"cc.EditBoxComponent"),c.LayoutComponent=m_e,tt.setClassAlias(m_e,"cc.LayoutComponent"),c.ProgressBarComponent=G_e,tt.setClassAlias(G_e,"cc.ProgressBarComponent"),c.ScrollViewComponent=Sde,tt.setClassAlias(Sde,"cc.ScrollViewComponent"),c.ScrollBarComponent=Q_e,tt.setClassAlias(Q_e,"cc.ScrollBarComponent"),c.SliderComponent=jde,tt.setClassAlias(jde,"cc.SliderComponent"),c.ToggleComponent=rme,tt.setClassAlias(rme,"cc.ToggleComponent"),c.ToggleContainerComponent=Qme,tt.setClassAlias(Qme,"cc.ToggleContainerComponent"),c.WidgetComponent=Ege,tt.setClassAlias(Ege,"cc.WidgetComponent"),c.PageViewComponent=xve,tt.setClassAlias(xve,"cc.PageViewComponent"),c.PageViewIndicatorComponent=dve,tt.setClassAlias(dve,"cc.PageViewIndicatorComponent"),c.SafeAreaComponent=Jve,tt.setClassAlias(Jve,"cc.SafeAreaComponent"),tt.setClassAlias(eye,"cc.UICoordinateTrackerComponent"),c.BlockInputEventsComponent=dye,tt.setClassAlias(dye,"cc.BlockInputEventsComponent");var Eye=e("VideoClip",hc("cc.VideoClip")((Sye=function(e){function t(){var t;return ae(t=e.call(this)||this,"_duration",xye,ie(t)),t._video=null,t}return Z(t,e),K(t,[{key:"_nativeAsset",get:function(){return this._video},set:function(e){this._video=e,this._duration=e?e.duration:0}}]),t}(Ru),xye=se((yye=Sye).prototype,"_duration",[gc],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),vye=yye))||vye);function Aye(e,t,n){var i=document.createElement("video"),r=document.createElement("source");i.appendChild(r);var o=new XMLHttpRequest;o.open("GET",e,!0),o.responseType="blob",o.onload=function(){200===this.status||0===this.status?(r.src=URL.createObjectURL(this.response),n(null,i)):n(new Error(o.status+"(no response)"))},o.onerror=function(){var t="load video failure - "+e;v(t),n(new Error(t))},o.send()}function Cye(e,t,n,i){var r=new Eye;r._nativeUrl=e,r._nativeAsset=t,i(null,r)}RN.register({".mp4":Aye,".avi":Aye,".mov":Aye,".mpg":Aye,".mpeg":Aye,".rm":Aye,".rmvb":Aye}),LN.register({".mp4":Cye,".avi":Cye,".mov":Cye,".mpg":Cye,".mpeg":Cye,".rm":Cye,".rmvb":Cye});var bye,wye,Rye=it({REMOTE:0,LOCAL:1});!function(e){e.NONE="none",e.PLAYING="playing",e.PAUSED="paused",e.STOPPED="stopped",e.COMPLETED="completed",e.META_LOADED="meta-loaded",e.READY_TO_PLAY="ready-to-play",e.ERROR="error",e.CLICKED="clicked"}(bye||(bye={})),function(e){e[e.HAVE_NOTHING=0]="HAVE_NOTHING",e[e.HAVE_METADATA=1]="HAVE_METADATA",e[e.HAVE_CURRENT_DATA=2]="HAVE_CURRENT_DATA",e[e.HAVE_FUTURE_DATA=3]="HAVE_FUTURE_DATA",e[e.HAVE_ENOUGH_DATA=4]="HAVE_ENOUGH_DATA"}(wye||(wye={}));var Pye=function(){function e(e){var t=this;this._componentEventList=new Map,this._state=bye.NONE,this._video=null,this._onHide=void 0,this._onShow=void 0,this._interrupted=!1,this._loaded=!1,this._loadedMeta=!1,this._ignorePause=!1,this._fullScreenOnAwake=!1,this._visible=!0,this._playing=!1,this._cachedCurrentTime=-1,this._waitingFullscreen=!1,this._waitingPlay=!1,this._keepAspectRatio=!1,this._component=null,this._uiTrans=null,this._node=null,this._stayOnBottom=!1,this._dirty=!1,this._forceUpdate=!1,this._w=0,this._h=0,this._m00=0,this._m01=0,this._m04=0,this._m05=0,this._m12=0,this._m13=0,this._component=e,this._node=e.node,this._uiTrans=e.node.getComponent(DV),this._onHide=function(){t.video&&t._state===bye.PLAYING&&(t.video.pause(),t._interrupted=!0)},this._onShow=function(){t._interrupted&&t.video&&(t.video.play(),t._interrupted=!1)},c.game.on(c.Game.EVENT_HIDE,this._onHide),c.game.on(c.Game.EVENT_SHOW,this._onShow)}var t=e.prototype;return t.onLoadedMetadata=function(e){this._loadedMeta=!0,this._forceUpdate=!0,this._visible?this.enable():this.disable(),this.dispatchEvent(bye.META_LOADED);var t=e.target;this._keepAspectRatio&&t&&this.syncUITransform(t.videoWidth,t.videoHeight),this.delayedFullScreen(),this.delayedPlay()},t.onCanPlay=function(){this._loaded=!0,this.dispatchEvent(bye.READY_TO_PLAY)},t.onPlay=function(){this._playing=!0,this.dispatchEvent(bye.PLAYING)},t.onPlaying=function(){this.dispatchEvent(bye.PLAYING)},t.onPause=function(){this._ignorePause?this._ignorePause=!1:(this._playing=!1,this.dispatchEvent(bye.PAUSED))},t.onStoped=function(){this._playing=!1,this._ignorePause=!1,this.dispatchEvent(bye.STOPPED)},t.onEnded=function(){this.dispatchEvent(bye.COMPLETED)},t.onClick=function(){this.dispatchEvent(bye.CLICKED)},t.onError=function(e){this.dispatchEvent(bye.ERROR);var t=e.target;t&&t.error&&x("Error "+t.error.code+"; details: "+t.error.message)},t.play=function(){this._loadedMeta||this._loaded?this.canPlay():this._waitingPlay=!0},t.delayedPlay=function(){this._waitingPlay&&(this.canPlay(),this._waitingPlay=!1)},t.syncFullScreenOnAwake=function(e){this._fullScreenOnAwake=e,this._loadedMeta||this._loaded?this.canFullScreen(e):this._waitingFullscreen=!0},t.delayedFullScreen=function(){this._waitingFullscreen&&(this.canFullScreen(this._fullScreenOnAwake),this._waitingFullscreen=!1)},t.dispatchEvent=function(e){var t=this._componentEventList.get(e);t&&(this._state=e,t.call(this))},t.syncUITransform=function(e,t){this._uiTrans&&(this._uiTrans.width=e,this._uiTrans.height=t)},t.syncCurrentTime=function(){this.video&&-1!==this._cachedCurrentTime&&this.video.currentTime!==this._cachedCurrentTime&&(this.seekTo(this._cachedCurrentTime),this._cachedCurrentTime=-1)},t.destroy=function(){this.removeVideoPlayer(),this._componentEventList.clear(),c.game.off(c.Game.EVENT_HIDE,this._onHide),c.game.off(c.Game.EVENT_SHOW,this._onShow)},K(e,[{key:"fullScreenOnAwake",get:function(){return this._fullScreenOnAwake}},{key:"loaded",get:function(){return this._loaded}},{key:"componentEventList",get:function(){return this._componentEventList}},{key:"video",get:function(){return this._video}},{key:"state",get:function(){return this._state}},{key:"isPlaying",get:function(){return this._playing}},{key:"UICamera",get:function(){return zM.root.batcher2D.getFirstRenderCamera(this._node)}}]),e}();c.internal.VideoPlayerImpl=Pye;var Iye,Dye,Oye,Mye,Nye,Lye,Fye,Bye,zye,kye,Uye,Gye,Hye,Vye,jye,Wye,qye,Xye,Yye,Kye,Qye,Zye,Jye,$ye,exe,txe,nxe,ixe,rxe,oxe,axe,sxe,cxe,lxe,uxe,hxe,fxe,_xe,pxe,dxe=-Math.pow(2,15),mxe=jn(),gxe=function(e){function t(t){var n;return(n=e.call(this,t)||this)._eventList=new Map,n._clearColorA=-1,n._clearFlag=void 0,n}Z(t,e);var n=t.prototype;return n.addListener=function(e,t){this._video&&(this._eventList.set(e,t),this._video.addEventListener(e,t))},n.removeAllListeners=function(){var e=this;this._eventList.forEach((function(t,n){e._video&&e._video.removeEventListener(n,t)})),this._eventList.clear()},n.canPlay=function(){var e=this;if(this.video){var t=this.video.play();window.Promise&&t instanceof Promise&&t.catch((function(){})).then((function(){e.syncCurrentTime()}))}},n.pause=function(){this.video&&(this.video.pause(),this._cachedCurrentTime=this.video.currentTime)},n.resume=function(){this.play()},n.stop=function(){var e=this;this.video&&(this._ignorePause=!0,this.video.currentTime=0,this.video.pause(),this._cachedCurrentTime=0,setTimeout((function(){e._ignorePause=!1,e.dispatchEvent(bye.STOPPED)}),0))},n.syncClip=function(e){this.removeVideoPlayer(),e&&this.createVideoPlayer(e.nativeUrl)},n.syncURL=function(e){this.removeVideoPlayer(),e&&this.createVideoPlayer(e)},n.syncPlaybackRate=function(e){oh.browserType!==$l.UC?this.video&&(this.video.playbackRate=e):y("playbackRate is not supported by the uc mobile browser.")},n.syncVolume=function(e){this.video&&(this.video.volume=e)},n.syncMute=function(e){this.video&&(this.video.muted=e)},n.syncLoop=function(e){this.video&&(this.video.loop=e)},n.getDuration=function(){return this.video?this.video.duration:0},n.getCurrentTime=function(){return this.video?this.video.currentTime:-1},n.seekTo=function(e){this.video&&(this.video.currentTime=e)},n.canFullScreen=function(e){var t=this,n=this._video;if(n&&n.readyState===wye.HAVE_ENOUGH_DATA)return oh.os===nu.IOS&&oh.isBrowser?(e?n.webkitEnterFullscreen&&n.webkitEnterFullscreen():n.webkitExitFullscreen&&n.webkitExitFullscreen(),void(this._fullScreenOnAwake=n.webkitDisplayingFullscreen)):rh.supportsFullScreen?void(e?(oh.browserType===$l.IE&&(n.style.transform=""),n.setAttribute("x5-video-player-fullscreen","true"),rh.requestFullScreen(n,(function(e){var i=oh.browserType===$l.IE?e.msFullscreenElement:e.fullscreenElement;t._fullScreenOnAwake=i===n}),(function(){t._fullScreenOnAwake=!1}))):(n.removeAttribute("x5-video-player-fullscreen"),rh.exitFullScreen())):(this._fullScreenOnAwake=e,this._forceUpdate=!0,void this.syncMatrix())},n.syncStayOnBottom=function(e){this._video&&(this._video.style["z-index"]=e?dxe:0,this._stayOnBottom=e),this._dirty=!0},n.syncKeepAspectRatio=function(e){this._keepAspectRatio=e,e&&this._loadedMeta&&this._video&&this.syncUITransform(this._video.videoWidth,this._video.videoHeight)},n.removeVideoPlayer=function(){var e=this._video;e&&mt(FM.container,e)&&(FM.container.removeChild(e),this.removeAllListeners()),this._cachedCurrentTime=0,this._playing=!1,this._loaded=!1,this._loadedMeta=!1,this._video=null},n.createVideoPlayer=function(e){var t=this._video=document.createElement("video");t.className="cocosVideo",t.style.visibility="hidden",t.style.position="absolute",t.style.bottom="0px",t.style.left="0px",t.style["transform-origin"]="0px 100% 0px",t.style["-webkit-transform-origin"]="0px 100% 0px",t.setAttribute("preload","auto"),t.setAttribute("webkit-playsinline",""),t.setAttribute("x5-playsinline",""),t.setAttribute("playsinline",""),this._bindDomEvent(),FM.container.appendChild(t);var n=document.createElement("source");t.appendChild(n),n.src=e},n._bindDomEvent=function(){this._video,this.addListener("loadedmetadata",this.onLoadedMetadata.bind(this)),this.addListener("canplay",this.onCanPlay.bind(this)),this.addListener("canplaythrough",this.onCanPlay.bind(this)),this.addListener("play",this.onPlay.bind(this)),this.addListener("playing",this.onPlaying.bind(this)),this.addListener("pause",this.onPause.bind(this)),this.addListener("click",this.onClick.bind(this)),this.addListener("ended",this.onEnded.bind(this)),this.addListener("error",this.onError.bind(this))},n.onCanPlay=function(t){var n=t.target;if(!this._loaded||!n)switch(n.readyState){case wye.HAVE_METADATA:case wye.HAVE_ENOUGH_DATA:e.prototype.onCanPlay.call(this,t)}},n.enable=function(){if(this._video){if(this._visible=!0,"visible"===this._video.style.visibility)return;this._video.style.visibility="visible"}},n.disable=function(e){if(this._video){if(!e&&this._playing&&this._video.pause(),this._visible=!1,"hidden"===this._video.style.visibility)return;this._video.style.visibility="hidden"}},n.syncMatrix=function(){if(this._video&&this._visible&&this._component){var e=this.UICamera;if(e&&!rh.fullScreen()){this._dirty&&(this._dirty=!1,this._stayOnBottom?(this._clearColorA=e.clearColor.w,this._clearFlag=e.clearFlag,e.clearColor.w=0,e.clearFlag=Wi.ALL):this._clearFlag&&(e.clearColor.w=this._clearColorA,e.clearFlag=this._clearFlag,this._clearColorA=-1,this._clearFlag=null)),this._component.node.getWorldMatrix(mxe),e.update(!0),e.worldMatrixToScreen(mxe,mxe,FM.canvas.width,FM.canvas.height);var t=0,n=0;if(this._fullScreenOnAwake?(t=GM.width,n=GM.height):(t=this._uiTrans.contentSize.width,n=this._uiTrans.contentSize.height),this._forceUpdate||this._m00!==mxe.m00||this._m01!==mxe.m01||this._m04!==mxe.m04||this._m05!==mxe.m05||this._m12!==mxe.m12||this._m13!==mxe.m13||this._w!==t||this._h!==n){this._m00=mxe.m00,this._m01=mxe.m01,this._m04=mxe.m04,this._m05=mxe.m05,this._m12=mxe.m12,this._m13=mxe.m13,this._w=t,this._h=n;var i=nh.devicePixelRatio,r=1/i,o=1/i,a=FM.container,s=mxe.m00*r,c=mxe.m01,l=mxe.m04,u=mxe.m05*o;this._video.style.width=this._w+"px",this._video.style.height=this._h+"px",oh.browserType!==$l.MOBILE_QQ?this._video.style.objectFit=this._keepAspectRatio?"none":"fill":y("keepAspectRatio is not supported by the qq mobile browser.");var h=this._w*r,f=this._h*o,_=this._uiTrans.anchorPoint,p=_.x,d=_.y,m=h*mxe.m00*p,g=f*mxe.m05*d,v=a&&a.style.paddingLeft?parseInt(a.style.paddingLeft):0,x=a&&a.style.paddingBottom?parseInt(a.style.paddingBottom):0,S="matrix("+s+","+-c+","+-l+","+u+","+(mxe.m12*r-m+v)+","+-(mxe.m13*o-g+x)+")";this._video.style.transform=S,this._video.style["-webkit-transform"]=S,oh.browserType!==$l.IE&&(this._forceUpdate=!1)}}}},t}(Pye),vxe=function(){function e(){}return e.getImpl=function(e){return new gxe(e)},e}();c.internal.VideoPlayerImplManager=vxe;var yxe,xxe=e("VideoPlayer",(Iye=hc("cc.VideoPlayer"),Dye=wc(),Oye=Ec(),Mye=fc(DV),Nye=Wc(Eye),Lye=Wc(Rye),Fye=Oc(),Bye=Oc(),zye=Wc(Eye),kye=Oc(),Uye=Oc(),Gye=Mc(),Hye=Oc(),Vye=Mc(),jye=Oc(),Wye=Oc(),qye=Oc(),Xye=Oc(),Yye=Oc(),Kye=Oc(),Qye=Wc([NF]),Zye=zc(),Jye=Oc(),Iye($ye=Dye($ye=Oye($ye=Mye($ye=Tc((pxe=_xe=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r1?n-1:0),r=1;r