System.register([],(function(e,t){"use strict";return{execute:function(){e({BitMask:ot,CCClass:$t,CacheMode:void 0,DebugMode:void 0,Enum:ct,Eventify:T_,GFXAPI:void 0,GFXAddress:void 0,GFXAttributeName:void 0,GFXBlendFactor:void 0,GFXBlendOp:void 0,GFXBufferAccessBit:void 0,GFXBufferFlagBit:void 0,GFXBufferUsageBit:void 0,GFXClearFlag:void 0,GFXColorMask:void 0,GFXCommandBufferType:void 0,GFXComparisonFunc:void 0,GFXCullMode:void 0,GFXDescriptorType:void 0,GFXDynamicStateFlagBit:void 0,GFXFeature:void 0,GFXFilter:void 0,GFXFormat:void 0,GFXFormatSize:As,GFXFormatSurfaceSize:xs,GFXFormatType:void 0,GFXLoadOp:void 0,GFXMemoryUsageBit:void 0,GFXObjectType:void 0,GFXPipelineBindPoint:void 0,GFXPolygonMode:void 0,GFXPrimitiveMode:void 0,GFXQueueType:void 0,GFXSampleCount:void 0,GFXShadeModel:void 0,GFXShaderStageFlagBit:void 0,GFXStencilFace:void 0,GFXStencilOp:void 0,GFXStoreOp:void 0,GFXSurfaceTransform:void 0,GFXTextureFlagBit:void 0,GFXTextureLayout:void 0,GFXTextureType:void 0,GFXTextureUsageBit:void 0,GFXType:void 0,HorizontalTextAlignment:void 0,InstanceMaterialType:void 0,Overflow:void 0,SystemEventType:void 0,VerticalTextAlignment:void 0,WorldNode3DToLocalNodeUI:gA,WorldNode3DToWorldNodeUI:vA,absMax:xn,absMaxComponent:An,approx:on,assert:d,assertID:R,bezier:gM,bezierByTime:xM,ccenum:ht,clamp:cn,clamp01:ln,color:Rn,computeRatioByType:wM,deserialize:Af,earcut:VY,equals:sn,error:f,errorID:A,find:nw,fragmentText:Ok,getBaselineOffset:function(){return 0},getError:b,getPathFromRoot:function(e,t){for(var n=e,i="";null!==n&&n!==t;)i=n.name+"/"+i,n=n.parent;return i.slice(0,-1)},getWorldTransformUntilRoot:HN,instantiate:IE,inverseLerp:Tn,isCustomTargetModifier:KN,isDisplayStats:w,isElementModifier:YN,isPropertyModifier:XN,isUnicodeCJK:Rk,isUnicodeSpace:bk,isValid:d_,lerp:un,log:h,logID:y,markAsWarning:void 0,mat4:jn,murmurhash2_32_gc:Vs,nextPow2:yn,pingPong:En,pseudoRandom:mn,pseudoRandomRange:gn,pseudoRandomRangeInt:vn,quat:Gn,randomRange:dn,randomRangeInt:pn,rect:ni,removeProperty:void 0,repeat:Sn,replaceProperty:void 0,safeMeasureText:wk,sampleAnimationCurve:bM,setDefaultLogTimes:function(e){e>0&&(he=e)},setDisplayStats:I,size:ei,toDegree:_n,toRadian:hn,v2:Kn,v3:On,v4:Qn,warn:_,warnID:E});var n="undefined"==typeof window?global:window,i=e("cclegacy",{_global:n});i.internal={},n.CC_BUILD=!0,n.CC_TEST=!1,n.CC_EDITOR=!1,n.CC_PREVIEW=!1,n.CC_DEV=!1,n.CC_DEBUG=!1,n.CC_JSB=!1,n.CC_BYTEDANCE=!1,n.CC_WECHAT=!1,n.CC_ALIPAY=!1,n.CC_XIAOMI=!1,n.CC_BAIDU=!1,n.CC_COCOSPLAY=!1,n.CC_HUAWEI=!1,n.CC_OPPO=!1,n.CC_VIVO=!1,n.CC_MINIGAME=!1,n.CC_RUNTIME_BASED=!1,n.CC_SUPPORT_JIT=!0,n.CocosEngine=i.ENGINE_VERSION="3.0.0",n.cc=i;var r="https://github.com/cocos-creator/engine/blob/3d/EngineErrorMap.md",a=null,s=console.log.bind(console),o=s,c=s,l=function(e,t){if(!e){for(var n=arguments.length,i=new Array(n>2?n-2:0),r=2;r1?t-1:0),r=1;r1?t-1:0),i=1;i1?t-1:0),i=1;i1?t-1:0),i=1;i2?n-2:0),r=2;rx.ERROR){var t=function(e){if(i.game.canvas){if(!a){var t=document.createElement("Div");t.setAttribute("id","logInfoDiv"),t.setAttribute("width","200"),t.setAttribute("height",i.game.canvas.height);var n=t.style;n.zIndex="99999",n.position="absolute",n.top=n.left="0",(a=document.createElement("textarea")).setAttribute("rows","20"),a.setAttribute("cols","30"),a.setAttribute("disabled","true");var r=a.style;r.backgroundColor="transparent",r.borderBottom="1px solid #cccccc",r.borderTopWidth=r.borderLeftWidth=r.borderRightWidth="0px",r.borderTopStyle=r.borderLeftStyle=r.borderRightStyle="none",r.padding="0px",r.margin="0px",t.appendChild(a),i.game.canvas.parentNode.appendChild(t)}a.value=a.value+e+"\r\n",a.scrollTop=a.scrollHeight}};c=function(e){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r2?i-2:0),a=2;a1?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),s=1;s1?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;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 z(e){var t=M.exec(e);return t?t[2]:""}function U(e,t){t=t||"";var n=e.indexOf("?"),i="";return n>0&&(i=e.substring(n),e=e.substring(0,n)),(n=e.lastIndexOf("."))<0?e+t+i:e.substring(0,n)+t+i}function G(e,t,n){if(0===t.indexOf("."))return U(e,t);var i=e.indexOf("?"),r="",a=n?B(e):"";return i>0&&(r=e.substring(i),e=e.substring(0,i)),i=(i=e.lastIndexOf("/"))<=0?0:i+1,e.substring(0,i)+t+a+r}function k(e){var t=e=String(e);do{t=e,e=e.replace(N,"")}while(t.length!==e.length);return e}function H(e){return e.replace(/[\/\\]$/,"")}function V(){return i.sys.os===i.sys.OS_WINDOWS?"\\":"/"}function W(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,i=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}function Q(e,t,n,i){n&&Object.defineProperty(e,t,{enumerable:n.enumerable,configurable:n.configurable,writable:n.writable,value:n.initializer?n.initializer.call(i):void 0})}function J(e,t,n,i,r){var a={};return Object.keys(i).forEach((function(e){a[e]=i[e]})),a.enumerable=!!a.enumerable,a.configurable=!!a.configurable,("value"in a||a.initializer)&&(a.writable=!0),a=n.slice().reverse().reduce((function(n,i){return i(e,t,n)||n}),a),r&&void 0!==a.initializer&&(a.value=a.initializer?a.initializer.call(r):void 0,a.initializer=void 0),void 0===a.initializer&&(Object.defineProperty(e,t,a),a=null),a}e("path",Object.freeze({__proto__:null,join:D,extname:B,mainFileName:L,basename:F,dirname:z,changeExtname:U,changeBasename:G,_normalize:k,stripSep:H,getSeperator:V})),i.log=h,i.warn=_,i.error=f,i.assert=d,i._throw=m,i.logID=y,i.warnID=E,i.errorID=A,i.assertID=R,i.debug=O,i.path={join:D,extname:B,mainFileName:L,basename:F,dirname:z,changeExtname:U,changeBasename:G,_normalize:k,stripSep:H,get sep(){return V()}};var $=0,ee={};function te(e){var t,n;return t=(e>65535)<<4,t|=n=((e>>>=t)>255)<<3,t|=n=((e>>>=n)>15)<<2,(t|=n=((e>>>=n)>3)<<1)|(e>>>=n)>>1}function ne(e){var t=32;return(e&=-e)&&t--,65535&e&&(t-=16),16711935&e&&(t-=8),252645135&e&&(t-=4),858993459&e&&(t-=2),1431655765&e&&(t-=1),t}function ie(e){return e+=0===e,--e,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,1+(e|=e>>>16)}var re=new Array(256);!function(e){for(var t=0;t<256;++t){var n=t,i=t,r=7;for(n>>>=1;n;n>>>=1)i<<=1,i|=1&n,--r;e[t]=i<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:ne,nextPow2:ie,prevPow2:function(e){return e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,(e|=e>>>16)-(e>>>1)},parity:function(e){return e^=e>>>16,e^=e>>>8,e^=e>>>4,27030>>>(e&=15)&1},reverse:function(e){return re[255&e]<<24|re[e>>>8&255]<<16|re[e>>>16&255]<<8|re[e>>>24&255]},interleave2:function(e,t){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e&=65535)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t&=65535)|t<<8))|t<<4))|t<<2))|t<<1))<<1},deinterleave2:function(e,t){return(e=65535&((e=16711935&((e=252645135&((e=858993459&((e=e>>>t&1431655765)|e>>>1))|e>>>2))|e>>>4))|e>>>16))<<16>>16},interleave3:function(e,t,n){return e=1227133513&((e=3272356035&((e=251719695&((e=4278190335&((e&=1023)|e<<16))|e<<8))|e<<4))|e<<2),(e|=(t=1227133513&((t=3272356035&((t=251719695&((t=4278190335&((t&=1023)|t<<16))|t<<8))|t<<4))|t<<2))<<1)|(n=1227133513&((n=3272356035&((n=251719695&((n=4278190335&((n&=1023)|n<<16))|n<<8))|n<<4))|n<<2))<<2},deinterleave3:function(e,t){return(e=1023&((e=4278190335&((e=251719695&((e=3272356035&((e=e>>>t&1227133513)|e>>>2))|e>>>4))|e>>>8))|e>>>16))<<22>>22},nextCombination:function(e){var t=e|e-1;return t+1|(~t&-~t)-1>>>ne(e)+1}});e("bits",ae);var se,oe,ce,le,ue,he=10,_e=0,fe=new Map;ce=function(e,t,n,i,r,a){var s=fe.get(a);s&&s.logTimes>s.count&&(r("'%s' is deprecated, please use '%s' instead.",e+"."+t,n+"."+i),s.count++)},se=e("replaceProperty",(function(e,t,n){null!=e&&n.forEach((function(n){var i=_e++;fe.set(i,{id:i,count:0,logTimes:void 0!==n.logTimes?n.logTimes:he});var r=null!=n.target?n.target:e,a=null!=n.newName?n.newName:n.name,s=null!=n.targetName?n.targetName:t,o=r==e;if(null!=n.customFunction)e[n.name]=function(){var e;return ce(t,n.name,s,a,_,i),(e=n.customFunction).call.apply(e,[this].concat(Array.prototype.slice.call(arguments)))};else if(null!=n.customSetter||null!=n.customGetter){var c=null!=n.customSetter,l=null!=n.customGetter;c&&l?Object.defineProperty(e,n.name,{get:function(){return ce(t,n.name,s,a,_,i),n.customGetter.call(this)},set:function(e){ce(t,n.name,s,a,_,i),n.customSetter.call(this,e)},enumerable:!1}):c?Object.defineProperty(e,n.name,{set:function(e){ce(t,n.name,s,a,_,i),n.customSetter.call(this,e)},enumerable:!1}):l&&Object.defineProperty(e,n.name,{get:function(){return ce(t,n.name,s,a,_,i),n.customGetter.call(this)},enumerable:!1})}else Object.defineProperty(e,n.name,{get:function(){return ce(t,n.name,s,a,_,i),o?this[a]:r[a]},set:function(e){ce(t,n.name,s,a,_,i),o?this[a]=e:r[a]=e},enumerable:!1})}))})),ue=function(e,t,n,i,r){var a=fe.get(i),s=void 0===r?"":"("+r+")";a&&a.logTimes>a.count&&(n("'%s' has been removed. "+s,e+"."+t),a.count++)},oe=e("removeProperty",(function(e,t,n){null!=e&&n.forEach((function(n){var i=_e++;fe.set(i,{id:i,count:0,logTimes:void 0!==n.logTimes?n.logTimes:he}),Object.defineProperty(e,n.name,{get:function(){return ue(t,n.name,f,i,n.suggest)},set:function(){ue(t,n.name,f,i,n.suggest)},enumerable:!1})}))})),le=function(e,t,n,i,r){var a=fe.get(i),s=void 0===r?"":"("+r+")";a&&a.logTimes>a.count&&(n("'%s' is deprecated. "+s,e+"."+t),a.count++)},e("markAsWarning",(function(e,t,n){if(null!=e){var i=function(e,t,n,i,r,a){if(e.get){var s=e.get();e.get=function(){return le(t,n,i,r,a),s.call(this)}}if(e.set){var o=Object.create(e.set);e.set=function(e){le(t,n,i,r,a),o.call(this,e)}}};n.forEach((function(n){var r=n.name,a=Object.getOwnPropertyDescriptor(e,r);if(a){var s=_e++;if(fe.set(s,{id:s,count:0,logTimes:void 0!==n.logTimes?n.logTimes:he}),null!=a.value)if("function"==typeof a.value){var o=a.value;e[r]=function(){return le(t,r,_,s,n.suggest),o.call.apply(o,[this].concat(Array.prototype.slice.call(arguments)))}}else i(a,t,r,_,s,n.suggest);else i(a,t,r,_,s,n.suggest);Object.defineProperty(e,r,{enumerable:!1})}}))}}));var de=function(){function e(e){this.i=0,this.array=e}var t=e.prototype;return t.remove=function(e){var t=this.array.indexOf(e);t>=0&&this.removeAt(t)},t.removeAt=function(e){this.array.splice(e,1),e<=this.i&&--this.i},t.fastRemove=function(e){var t=this.array.indexOf(e);t>=0&&this.fastRemoveAt(t)},t.fastRemoveAt=function(e){var t=this.array;t[e]=t[t.length-1],--t.length,e<=this.i&&--this.i},t.push=function(e){this.array.push(e)},j(e,[{key:"length",get:function(){return this.array.length},set:function(e){this.array.length=e,this.i>=e&&(this.i=e-1)}}]),e}();function pe(e,t){e.splice(t,1)}function me(e,t){var n=e.length;t<0||t>=n||(e[t]=e[n-1],e.length=n-1)}function ge(e,t){var n=e.indexOf(t);return n>=0&&(pe(e,n),!0)}function ve(e,t){return e.indexOf(t)>=0}var ye=Object.freeze({__proto__:null,removeAt:pe,fastRemoveAt:me,remove:ge,fastRemove:function(e,t){var n=e.indexOf(t);n>=0&&(e[n]=e[e.length-1],--e.length)},removeIf:function(e,t){var n=e.findIndex(t);if(n>=0){var i=e[n];return pe(e,n),i}},verifyType:function(e,t){if(e&&e.length>0)for(var n,i=Z(e);!(n=i()).done;)if(!(n.value instanceof t))return y(1300),!1;return!0},removeArray:function(e,t){for(var n=0,i=t.length;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}(),at=ye,st={IDGenerator:Se,Pool:rt,array:ye,isNumber:Ae,isString:xe,isEmptyObject:Ce,getPropertyDescriptor:Ue,addon:ke,mixin:He,extend:Ve,getSuper:We,isChildClassOf:je,clear:qe,value:be,getset:we,get:Ie,set:Oe,unregisterClass:et,getClassName:Me,setClassName:Je,setClassAlias:$e,getClassByName:nt,get _registeredClassNames(){return q({},Ye)},set _registeredClassNames(e){qe(Ye),Object.assign(Ye,e)},get _registeredClassIds(){return q({},Xe)},set _registeredClassIds(e){qe(Xe),Object.assign(Xe,e)},_getClassId:it,_setClassId:Ze,_getClassById:tt,obsolete:Ne,obsoletes:De,formatStr:Fe,shiftArguments:ze,createMap:Pe};function ot(e){if("__bitmask__"in e)return e;be(e,"__bitmask__",null,!0);for(var t=-1,n=Object.keys(e),i=0;in){var i=t;t=n,n=i}return e=0;r--){var a=n[r];a.hasOwnProperty("__attrs__")&&a.__attrs__||wt(a,(t=n[r+1])&&t.__attrs__)}return wt(e,(t=n[0])&&t.__attrs__),e.__attrs__}function Ot(e,t){var n=Pt(e),i=t+"$_$",r={};for(var a in n)a.startsWith(i)&&(r[a.slice(i.length)]=n[a]);return r}function Pt(e){return e.hasOwnProperty("__attrs__")&&e.__attrs__||It(e)}function Mt(e,t,n,i){Pt(e)[t+"$_$"+n]=i}i.misc={BUILTIN_CLASSID_RE:dt,BASE64_VALUES:vt,propertyDefine:yt,pushToMap:St,contains:Et,isDomNode:Tt,callInNextTick:At,isPlainEmptyObj_DEV:xt,clampf:Ct,degreesToRadians:Rt,radiansToDegrees:bt},e("misc",Object.freeze({__proto__:null,BUILTIN_CLASSID_RE:dt,BASE64_VALUES:vt,propertyDefine:yt,pushToMap:St,contains:Et,isDomNode:Tt,callInNextTick:At,tryCatchFunctor_EDITOR:function(e){return Function("target","try {\n target."+e+"();\n}\ncatch (e) {\n cc._throw(e);\n}")},isPlainEmptyObj_DEV:xt,clampf:Ct,degreesToRadians:Rt,radiansToDegrees:bt}));var Nt=function(){function e(e,t){this.name=void 0,this.default=void 0,this.name=e,this.default=t}return e.prototype.toString=function(){return this.name},e}(),Dt=e("CCInteger",new Nt("Integer",0));i.Integer=Dt,i.CCInteger=Dt;var Bt=e("CCFloat",new Nt("Float",0));i.Float=Bt,i.CCFloat=Bt;var Lt=e("CCBoolean",new Nt("Boolean",!1));i.Boolean=Lt,i.CCBoolean=Lt;var Ft=e("CCString",new Nt("String",""));function zt(e,t){return function(n,i){var r='"'+Me(n)+"."+i+'"',a=Ot(n,i),s=a.type;if(s===Dt||s===Bt?s="Number":s!==Ft&&s!==Lt||(s=""+s),s===e){if(a.hasOwnProperty("default")){var o=a.default;if(void 0!==o&&!Array.isArray(o)&&!xt(o)){var c=typeof o,l=e.toLowerCase();if(c===l)if("object"===l){if(!o||o instanceof a.ctor)return;E(3605,r,Me(a.ctor))}else"Number"!==e&&E(3606,t,r,e);else{if("function"===c)return;e===Ft.default&&null==o?E(3607,r):E(3611,t,r,c)}delete a.type}}}else E(3604,r)}}i.String=Ft,i.CCString=Ft;var Ut=Object.freeze({__proto__:null,DELIMETER:"$_$",createAttrsSingle:wt,createAttrs:It,attr:Ot,getClassAttrs:Pt,setClassAttr:Mt,PrimitiveType:Nt,CCInteger:Dt,CCFloat:Bt,CCBoolean:Lt,CCString:Ft,getTypeChecker_ET:zt,getObjTypeChecker_ET:function(e){return function(t,n){zt("Object","type")(t,n);var r=Pt(t)[n+"$_$default"],a=i.Class.getDefault(r);if(!Array.isArray(a)&&je(e,i.ValueType)){var s=Me(e),o=Fe('No need to specify the "type" of "%s.%s" because %s is a child class of ValueType.',Me(t),n,s);r?h(o):E(3612,o,s,Me(t),n,s)}}}}),Gt={default:{},serializable:{},editorOnly:{},formerlySerializedAs:{}};function kt(e,t,n,i){if(!e.get&&!e.set&&e.hasOwnProperty("default")){var r="_N$"+t;e.get=function(){return this[r]},e.set=function(e){var t=this[r];this[r]=e,n.call(this,t)};var a={};for(var s in i[r]=a,Gt){var o=Gt[s];e.hasOwnProperty(s)&&(a[s]=e[s],o.canUsedInGet||delete e[s])}}}function Ht(e,t,n,r){if(Array.isArray(t)){if(!(t.length>0))return A(5508,n,r);e.type=t=t[0]}"function"==typeof t&&(t===String?e.type=i.String:t===Boolean?e.type=i.Boolean:t===Number&&(e.type=i.Float))}function Vt(e,t,n){var i=e?{_short:!0}:{_short:!0,default:t};return n&&(i.type=n),i}function Wt(e,t){if(!e||e.constructor!==Object){if(Array.isArray(e)&&e.length>0)return Vt(t,[],e);if("function"==typeof e){var n=e;return Vt(t,je(n,i.ValueType)?new n:null,n)}return Vt(t,e instanceof Nt?e.default:e)}return null}var jt=[];function qt(){return jt[jt.length-1]}i._RF={push:function(e,t,n,i){void 0===n&&(n=t,t=""),jt.push({uuid:t,script:n,module:e,exports:e.exports,beh:null,importMeta:i})},pop:function(){var e=jt.pop(),t=e.module,n=t.exports;if(n===e.exports){for(var i in n)return;t.exports=n=e.cls}},peek:qt};var Xt={datas:null,push:function(e){if(this.datas)this.datas.push(e);else{this.datas=[e];var t=this;setTimeout((function(){t.init()}),0)}},init:function(){var e=this.datas;if(e){for(var t=0;t0?a:null,!0);var o=s.prototype;if(t&&(s.$super=t),n){for(var c=n.length-1;c>=0;c--){var l=n[c];Qt(o,l.prototype),$t._isCCClass(l)&&Qt(Pt(s),Pt(l))}o.constructor=s}return Je(e,s),s}(e,t,n,r);if(s)if(je(t,a)){var c=s.uuid;c&&Ze(c,o),s.cls=o}else je(s.cls,a)||(s.cls=o);return o}(t,n,r,e);t||(t=i.js.getClassName(a)),a._sealed=!0,n&&(n._sealed=!1);var s=e.properties;"function"==typeof s||n&&null===n.__props__||r&&r.some((function(e){return null===e.__props__}))?(Xt.push({cls:a,props:s,mixins:r}),a.__props__=a.__values__=null):Jt(a,t,s,n,e.mixins);var o=e.editor;return o&&je(n,i.Component)&&i.Component._registerEditorProps(a,o),a}$t._isCCClass=function(e){var t;return null==e||null===(t=e.hasOwnProperty)||void 0===t?void 0:t.call(e,"__ctors__")},$t.fastDefine=function(e,t,n){Je(e,t);for(var i=t.__props__=t.__values__=Object.keys(n),r=Pt(t),a=0;a=2&&((r||s())[a+"min"]=u[0],r[a+"max"]=u[1],u.length>2&&(r[a+"step"]=u[2])),l("min","number"),l("max","number"),l("step","number")}$t.isArray=function(e){return e=Zt(e),Array.isArray(e)},$t.getDefault=Zt,$t.escapeForJS=function(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")},$t.IDENTIFIER_RE=/^[A-Za-z_$][0-9A-Za-z_$]*$/,$t.getNewValueTypeCode=function(e){for(var t=Me(e),n=e.constructor,i="new "+t+"(",r=0;rn){var i=t;t=n,n=i}return en?n:e}function ln(e){return e<0?0:e>1?1:e}function un(e,t,n){return e+(t-e)*n}function hn(e){return e*nn}function _n(e){return e*rn}var fn=e("random",Math.random);function dn(e,t){return Math.random()*(t-e)+e}function pn(e,t){return Math.floor(dn(e,t))}function mn(e){return(e=(9301*e+49297)%233280)/233280}function gn(e,t,n){return mn(e)*(n-t)+t}function vn(e,t,n){return Math.floor(gn(e,t,n))}function yn(e){return--e,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e}function Sn(e,t){return e-Math.floor(e/t)*t}function En(e,t){return e=Sn(e,2*t),t-Math.abs(e-t)}function Tn(e,t,n){return(n-e)/(t-e)}function An(e){return Math.abs(e.x)>Math.abs(e.y)?Math.abs(e.x)>Math.abs(e.z)?e.x:e.z:Math.abs(e.y)>Math.abs(e.z)?e.y:e.z}function xn(e,t){return Math.abs(e)>Math.abs(t)?e:t}var Cn=e("Color",function(e){function t(t,n,i,r){var a;return(a=e.call(this)||this)._val=0,"string"==typeof t?a.fromHEX(t):void 0!==n?a.set(t,n,i,r):a.set(t),a}X(t,e),t.clone=function(e){var n=new t;return e._val?n._val=e._val:n._val=(e.a<<24>>>0)+(e.b<<16)+(e.g<<8)+e.r,n},t.copy=function(e,t){return e.r=t.r,e.g=t.g,e.b=t.b,e.a=t.a,e},t.set=function(e,t,n,i,r){return e.r=t,e.g=n,e.b=i,e.a=r,e},t.fromHEX=function(e,t){return t=0===t.indexOf("#")?t.substring(1):t,e.r=parseInt(t.substr(0,2),16)||0,e.g=parseInt(t.substr(2,2),16)||0,e.b=parseInt(t.substr(4,2),16)||0,e.a=parseInt(t.substr(6,2),16)||255,e._val=(e.a<<24>>>0)+(e.b<<16)+(e.g<<8)+e.r,e},t.add=function(e,t,n){return e.r=t.r+n.r,e.g=t.g+n.g,e.b=t.b+n.b,e.a=t.a+n.a,e},t.subtract=function(e,t,n){return e.r=t.r-n.r,e.g=t.g-n.g,e.b=t.b-n.b,e.a=t.a-n.a,e},t.multiply=function(e,t,n){return e.r=t.r*n.r,e.g=t.g*n.g,e.b=t.b*n.b,e.a=t.a*n.a,e},t.divide=function(e,t,n){return e.r=t.r/n.r,e.g=t.g/n.g,e.b=t.b/n.b,e.a=t.a/n.a,e},t.scale=function(e,t,n){return e.r=t.r*n,e.g=t.g*n,e.b=t.b*n,e.a=t.a*n,e},t.lerp=function(e,t,n,i){var r=t.r,a=t.g,s=t.b,o=t.a;return r+=(n.r-r)*i,a+=(n.g-a)*i,s+=(n.b-s)*i,o+=(n.a-o)*i,e._val=Math.floor((o<<24>>>0)+(s<<16)+(a<<8)+r),e},t.toArray=function(e,n,i){void 0===i&&(i=0);var r=n instanceof t||n.a>1?1/255:1;return e[i+0]=n.r*r,e[i+1]=n.g*r,e[i+2]=n.b*r,e[i+3]=n.a*r,e},t.fromArray=function(e,t,n){return void 0===n&&(n=0),t.r=255*e[n+0],t.g=255*e[n+1],t.b=255*e[n+2],t.a=255*e[n+3],t},t.strictEquals=function(e,t){return e.r===t.r&&e.g===t.g&&e.b===t.b&&e.a===t.a},t.equals=function(e,t,n){return void 0===n&&(n=an),Math.abs(e.r-t.r)<=n*Math.max(1,Math.abs(e.r),Math.abs(t.r))&&Math.abs(e.g-t.g)<=n*Math.max(1,Math.abs(e.g),Math.abs(t.g))&&Math.abs(e.b-t.b)<=n*Math.max(1,Math.abs(e.b),Math.abs(t.b))&&Math.abs(e.a-t.a)<=n*Math.max(1,Math.abs(e.a),Math.abs(t.a))},t.hex=function(e){return(255*e.r<<24|255*e.g<<16|255*e.b<<8|255*e.a)>>>0},j(t,[{key:"r",get:function(){return 255&this._val},set:function(e){e=~~cn(e,0,255),this._val=(4294967040&this._val|e)>>>0}},{key:"g",get:function(){return(65280&this._val)>>8},set:function(e){e=~~cn(e,0,255),this._val=(4294902015&this._val|e<<8)>>>0}},{key:"b",get:function(){return(16711680&this._val)>>16},set:function(e){e=~~cn(e,0,255),this._val=(4278255615&this._val|e<<16)>>>0}},{key:"a",get:function(){return(4278190080&this._val)>>>24},set:function(e){e=~~cn(e,0,255),this._val=(16777215&this._val|e<<24)>>>0}},{key:"x",get:function(){return this.r*(1/255)},set:function(e){this.r=255*e}},{key:"y",get:function(){return this.g*(1/255)},set:function(e){this.g=255*e}},{key:"z",get:function(){return this.b*(1/255)},set:function(e){this.b=255*e}},{key:"w",get:function(){return this.a*(1/255)},set:function(e){this.a=255*e}}]);var n=t.prototype;return n.clone=function(){var e=new t;return e._val=this._val,e},n.equals=function(e){return e&&this._val===e._val},n.lerp=function(e,t){var n=this.r,i=this.g,r=this.b,a=this.a;return n+=(e.r-n)*t,i+=(e.g-i)*t,r+=(e.b-r)*t,a+=(e.a-a)*t,this._val=Math.floor((a<<24>>>0)+(r<<16)+(i<<8)+n),this},n.toString=function(){return"rgba("+this.r.toFixed()+", "+this.g.toFixed()+", "+this.b.toFixed()+", "+this.a.toFixed()+")"},n.toCSS=function(e){return void 0===e&&(e="rgba"),"rgba"===e?"rgba("+this.r+","+this.g+","+this.b+","+(this.a*(1/255)).toFixed(2)+")":"rgb"===e?"rgb("+this.r+","+this.g+","+this.b+")":"#"+this.toHEX(e)},n.fromHEX=function(e){e=0===e.indexOf("#")?e.substring(1):e;var t=parseInt(e.substr(0,2),16)||0,n=parseInt(e.substr(2,2),16)||0,i=parseInt(e.substr(4,2),16)||0,r=parseInt(e.substr(6,2),16)||255;return this._val=(r<<24>>>0)+(i<<16)+(n<<8)+(0|t),this},n.toHEX=function(e){void 0===e&&(e="#rrggbb");var t=[(this.r<16?"0":"")+this.r.toString(16),(this.g<16?"0":"")+this.g.toString(16),(this.b<16?"0":"")+this.b.toString(16)];return"#rgb"===e?(t[0]=t[0][0],t[1]=t[1][0],t[2]=t[2][0]):"#rrggbbaa"===e&&t.push((this.a<16?"0":"")+this.a.toString(16)),t.join("")},n.toRGBValue=function(){return 16777215&this._val},n.fromHSV=function(e,t,n){var i=0,r=0,a=0;if(0===t)i=r=a=n;else if(0===n)i=r=a=0;else{1===e&&(e=0),e*=6;var s=Math.floor(e),o=e-s,c=n*(1-t),l=n*(1-t*o),u=n*(1-t*(1-o));switch(s){case 0:i=n,r=u,a=c;break;case 1:i=l,r=n,a=c;break;case 2:i=c,r=n,a=u;break;case 3:i=c,r=l,a=n;break;case 4:i=u,r=c,a=n;break;case 5:i=n,r=c,a=l}}return i*=255,r*=255,a*=255,this._val=(this.a<<24>>>0)+(a<<16)+(r<<8)+(0|i),this},n.toHSV=function(){var e=this.r*(1/255),t=this.g*(1/255),n=this.b*(1/255),i={h:0,s:0,v:0},r=Math.max(e,t,n),a=Math.min(e,t,n),s=0;return i.v=r,i.s=r?(r-a)/r:0,i.s?(s=r-a,i.h=e===r?(t-n)/s:t===r?2+(n-e)/s:4+(e-t)/s,i.h/=6,i.h<0&&(i.h+=1)):i.h=0,i},n.set=function(e,t,n,i){return"object"==typeof e?null!=e._val?this._val=e._val:(t=e.g||0,n=e.b||0,i="number"==typeof e.a?e.a:255,e=e.r||0,this._val=(i<<24>>>0)+(n<<16)+(t<<8)+(0|e)):(e=e||0,t=t||0,n=n||0,i="number"==typeof i?i:255,this._val=(i<<24>>>0)+(n<<16)+(t<<8)+(0|e)),this},n.multiply=function(e){var t=(255&this._val)*e.r>>8,n=(65280&this._val)*e.g>>8,i=(16711680&this._val)*e.b>>8,r=((4278190080&this._val)>>>8)*e.a;return this._val=4278190080&r|16711680&i|65280&n|255&t,this},n._set_r_unsafe=function(e){return this._val=(4294967040&this._val|e)>>>0,this},n._set_g_unsafe=function(e){return this._val=(4294902015&this._val|e<<8)>>>0,this},n._set_b_unsafe=function(e){return this._val=(4278255615&this._val|e<<16)>>>0,this},n._set_a_unsafe=function(e){return this._val=(16777215&this._val|e<<24)>>>0,this},t}(_t));function Rn(e,t,n,i){return new Cn(e,t,n,i)}Cn.WHITE=Object.freeze(new Cn(255,255,255,255)),Cn.GRAY=Object.freeze(new Cn(127,127,127,255)),Cn.BLACK=Object.freeze(new Cn(0,0,0,255)),Cn.TRANSPARENT=Object.freeze(new Cn(0,0,0,0)),Cn.RED=Object.freeze(new Cn(255,0,0,255)),Cn.GREEN=Object.freeze(new Cn(0,255,0,255)),Cn.BLUE=Object.freeze(new Cn(0,0,255,255)),Cn.CYAN=Object.freeze(new Cn(0,255,255,255)),Cn.MAGENTA=Object.freeze(new Cn(255,0,255,255)),Cn.YELLOW=Object.freeze(new Cn(255,255,0,255)),$t.fastDefine("cc.Color",Cn,{r:0,g:0,b:0,a:255}),i.Color=Cn,i.color=Rn;var bn=e("Vec3",function(e){function t(t,n,i){var r;return r=e.call(this)||this,t&&"object"==typeof t?(r.x=t.x,r.y=t.y,r.z=t.z):(r.x=t||0,r.y=n||0,r.z=i||0),r}X(t,e),t.zero=function(e){return e.x=0,e.y=0,e.z=0,e},t.clone=function(e){return new t(e.x,e.y,e.z)},t.copy=function(e,t){return e.x=t.x,e.y=t.y,e.z=t.z,e},t.set=function(e,t,n,i){return e.x=t,e.y=n,e.z=i,e},t.add=function(e,t,n){return e.x=t.x+n.x,e.y=t.y+n.y,e.z=t.z+n.z,e},t.subtract=function(e,t,n){return e.x=t.x-n.x,e.y=t.y-n.y,e.z=t.z-n.z,e},t.multiply=function(e,t,n){return e.x=t.x*n.x,e.y=t.y*n.y,e.z=t.z*n.z,e},t.divide=function(e,t,n){return e.x=t.x/n.x,e.y=t.y/n.y,e.z=t.z/n.z,e},t.ceil=function(e,t){return e.x=Math.ceil(t.x),e.y=Math.ceil(t.y),e.z=Math.ceil(t.z),e},t.floor=function(e,t){return e.x=Math.floor(t.x),e.y=Math.floor(t.y),e.z=Math.floor(t.z),e},t.min=function(e,t,n){return e.x=Math.min(t.x,n.x),e.y=Math.min(t.y,n.y),e.z=Math.min(t.z,n.z),e},t.max=function(e,t,n){return e.x=Math.max(t.x,n.x),e.y=Math.max(t.y,n.y),e.z=Math.max(t.z,n.z),e},t.round=function(e,t){return e.x=Math.round(t.x),e.y=Math.round(t.y),e.z=Math.round(t.z),e},t.multiplyScalar=function(e,t,n){return e.x=t.x*n,e.y=t.y*n,e.z=t.z*n,e},t.scaleAndAdd=function(e,t,n,i){return e.x=t.x+n.x*i,e.y=t.y+n.y*i,e.z=t.z+n.z*i,e},t.distance=function(e,t){var n=t.x-e.x,i=t.y-e.y,r=t.z-e.z;return Math.sqrt(n*n+i*i+r*r)},t.squaredDistance=function(e,t){var n=t.x-e.x,i=t.y-e.y,r=t.z-e.z;return n*n+i*i+r*r},t.len=function(e){var t=e.x,n=e.y,i=e.z;return Math.sqrt(t*t+n*n+i*i)},t.lengthSqr=function(e){var t=e.x,n=e.y,i=e.z;return t*t+n*n+i*i},t.negate=function(e,t){return e.x=-t.x,e.y=-t.y,e.z=-t.z,e},t.invert=function(e,t){return e.x=1/t.x,e.y=1/t.y,e.z=1/t.z,e},t.invertSafe=function(e,t){var n=t.x,i=t.y,r=t.z;return Math.abs(n)0&&(a=1/Math.sqrt(a),e.x=n*a,e.y=i*a,e.z=r*a),e},t.dot=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z},t.cross=function(e,t,n){var i=t.x,r=t.y,a=t.z,s=n.x,o=n.y,c=n.z;return e.x=r*c-a*o,e.y=a*s-i*c,e.z=i*o-r*s,e},t.lerp=function(e,t,n,i){return e.x=t.x+i*(n.x-t.x),e.y=t.y+i*(n.y-t.y),e.z=t.z+i*(n.z-t.z),e},t.random=function(e,t){t=t||1;var n=2*fn()*Math.PI,i=2*fn()-1,r=Math.sqrt(1-i*i);return e.x=r*Math.cos(n)*t,e.y=r*Math.sin(n)*t,e.z=i*t,e},t.transformMat4=function(e,t,n){var i=t.x,r=t.y,a=t.z,s=n.m03*i+n.m07*r+n.m11*a+n.m15;return s=s?Math.abs(1/s):1,e.x=(n.m00*i+n.m04*r+n.m08*a+n.m12)*s,e.y=(n.m01*i+n.m05*r+n.m09*a+n.m13)*s,e.z=(n.m02*i+n.m06*r+n.m10*a+n.m14)*s,e},t.transformMat4Normal=function(e,t,n){var i=t.x,r=t.y,a=t.z,s=n.m03*i+n.m07*r+n.m11*a;return s=s?Math.abs(1/s):1,e.x=(n.m00*i+n.m04*r+n.m08*a)*s,e.y=(n.m01*i+n.m05*r+n.m09*a)*s,e.z=(n.m02*i+n.m06*r+n.m10*a)*s,e},t.transformMat3=function(e,t,n){var i=t.x,r=t.y,a=t.z;return e.x=i*n.m00+r*n.m03+a*n.m06,e.y=i*n.m01+r*n.m04+a*n.m07,e.z=i*n.m02+r*n.m05+a*n.m08,e},t.transformAffine=function(e,t,n){var i=t.x,r=t.y,a=t.z;return e.x=n.m00*i+n.m04*r+n.m08*a+n.m12,e.y=n.m01*i+n.m05*r+n.m09*a+n.m13,e.x=n.m02*i+n.m06*r+n.m10*a+n.m14,e},t.transformQuat=function(e,t,n){var i=n.w*t.x+n.y*t.z-n.z*t.y,r=n.w*t.y+n.z*t.x-n.x*t.z,a=n.w*t.z+n.x*t.y-n.y*t.x,s=-n.x*t.x-n.y*t.y-n.z*t.z;return e.x=i*n.w+s*-n.x+r*-n.z-a*-n.y,e.y=r*n.w+s*-n.y+a*-n.x-i*-n.z,e.z=a*n.w+s*-n.z+i*-n.y-r*-n.x,e},t.transformRTS=function(e,t,n,i,r){var a=t.x*r.x,s=t.y*r.y,o=t.z*r.z,c=n.w*a+n.y*o-n.z*s,l=n.w*s+n.z*a-n.x*o,u=n.w*o+n.x*s-n.y*a,h=-n.x*a-n.y*s-n.z*o;return e.x=c*n.w+h*-n.x+l*-n.z-u*-n.y+i.x,e.y=l*n.w+h*-n.y+u*-n.x-c*-n.z+i.y,e.z=u*n.w+h*-n.z+c*-n.y-l*-n.x+i.z,e},t.transformInverseRTS=function(e,t,n,i,r){var a=t.x-i.x,s=t.y-i.y,o=t.z-i.z,c=n.w*a-n.y*o+n.z*s,l=n.w*s-n.z*a+n.x*o,u=n.w*o-n.x*s+n.y*a,h=n.x*a+n.y*s+n.z*o;return e.x=(c*n.w+h*n.x+l*n.z-u*n.y)/r.x,e.y=(l*n.w+h*n.y+u*n.x-c*n.z)/r.y,e.z=(u*n.w+h*n.z+c*n.y-l*n.x)/r.z,e},t.rotateX=function(e,t,n,i){var r=t.x-n.x,a=t.y-n.y,s=t.z-n.z,o=Math.cos(i),c=Math.sin(i),l=r,u=a*o-s*c,h=a*c+s*o;return e.x=l+n.x,e.y=u+n.y,e.z=h+n.z,e},t.rotateY=function(e,t,n,i){var r=t.x-n.x,a=t.y-n.y,s=t.z-n.z,o=Math.cos(i),c=Math.sin(i),l=s*c+r*o,u=a,h=s*o-r*c;return e.x=l+n.x,e.y=u+n.y,e.z=h+n.z,e},t.rotateZ=function(e,t,n,i){var r=t.x-n.x,a=t.y-n.y,s=t.z-n.z,o=Math.cos(i),c=Math.sin(i),l=r*o-a*c,u=r*c+a*o,h=s;return e.x=l+n.x,e.y=u+n.y,e.z=h+n.z,e},t.toArray=function(e,t,n){return void 0===n&&(n=0),e[n+0]=t.x,e[n+1]=t.y,e[n+2]=t.z,e},t.fromArray=function(e,t,n){return void 0===n&&(n=0),e.x=t[n+0],e.y=t[n+1],e.z=t[n+2],e},t.strictEquals=function(e,t){return e.x===t.x&&e.y===t.y&&e.z===t.z},t.equals=function(e,t,n){void 0===n&&(n=an);var i=e.x,r=e.y,a=e.z,s=t.x,o=t.y,c=t.z;return Math.abs(i-s)<=n*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(r-o)<=n*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(a-c)<=n*Math.max(1,Math.abs(a),Math.abs(c))},t.angle=function(e,n){t.normalize(wn,e),t.normalize(In,n);var i=t.dot(wn,In);return i>1?0:i<-1?Math.PI:Math.acos(i)},t.projectOnPlane=function(e,n,i){return t.subtract(e,n,t.project(e,n,i))},t.project=function(e,n,i){var r=t.lengthSqr(i);return r<1e-6?t.set(e,0,0,0):t.multiplyScalar(e,i,t.dot(n,i)/r)};var n=t.prototype;return n.clone=function(){return new t(this.x,this.y,this.z)},n.set=function(e,t,n){return e&&"object"==typeof e?(this.x=e.x,this.y=e.y,this.z=e.z):(this.x=e||0,this.y=t||0,this.z=n||0),this},n.equals=function(e,t){return void 0===t&&(t=an),Math.abs(this.x-e.x)<=t*Math.max(1,Math.abs(this.x),Math.abs(e.x))&&Math.abs(this.y-e.y)<=t*Math.max(1,Math.abs(this.y),Math.abs(e.y))&&Math.abs(this.z-e.z)<=t*Math.max(1,Math.abs(this.z),Math.abs(e.z))},n.equals3f=function(e,t,n,i){return void 0===i&&(i=an),Math.abs(this.x-e)<=i*Math.max(1,Math.abs(this.x),Math.abs(e))&&Math.abs(this.y-t)<=i*Math.max(1,Math.abs(this.y),Math.abs(t))&&Math.abs(this.z-n)<=i*Math.max(1,Math.abs(this.z),Math.abs(n))},n.strictEquals=function(e){return this.x===e.x&&this.y===e.y&&this.z===e.z},n.strictEquals3f=function(e,t,n){return this.x===e&&this.y===t&&this.z===n},n.toString=function(){return"("+this.x.toFixed(2)+", "+this.y.toFixed(2)+", "+this.z.toFixed(2)+")"},n.lerp=function(e,t){return this.x+=t*(e.x-this.x),this.y+=t*(e.y-this.y),this.z+=t*(e.z-this.z),this},n.add=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this},n.add3f=function(e,t,n){return this.x+=e,this.y+=t,this.z+=n,this},n.subtract=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this},n.subtract3f=function(e,t,n){return this.x-=e,this.y-=t,this.z-=n,this},n.multiplyScalar=function(e){return"object"==typeof e&&console.warn("should use Vec3.multiply for vector * vector operation"),this.x*=e,this.y*=e,this.z*=e,this},n.multiply=function(e){return"object"!=typeof e&&console.warn("should use Vec3.scale for vector * scalar operation"),this.x*=e.x,this.y*=e.y,this.z*=e.z,this},n.multiply3f=function(e,t,n){return this.x*=e,this.y*=t,this.z*=n,this},n.divide=function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this},n.divide3f=function(e,t,n){return this.x/=e,this.y/=t,this.z/=n,this},n.negative=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},n.clampf=function(e,t){return this.x=cn(this.x,e.x,t.x),this.y=cn(this.y,e.y,t.y),this.z=cn(this.z,e.z,t.z),this},n.dot=function(e){return this.x*e.x+this.y*e.y+this.z*e.z},n.cross=function(e){var t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,s=e.z;return this.x=n*s-i*a,this.y=i*r-t*s,this.z=t*a-n*r,this},n.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},n.lengthSqr=function(){return this.x*this.x+this.y*this.y+this.z*this.z},n.normalize=function(){var e=this.x,t=this.y,n=this.z,i=e*e+t*t+n*n;return i>0&&(i=1/Math.sqrt(i),this.x=e*i,this.y=t*i,this.z=n*i),this},n.transformMat4=function(e){var t=this.x,n=this.y,i=this.z,r=e.m03*t+e.m07*n+e.m11*i+e.m15;return r=r?1/r:1,this.x=(e.m00*t+e.m04*n+e.m08*i+e.m12)*r,this.y=(e.m01*t+e.m05*n+e.m09*i+e.m13)*r,this.z=(e.m02*t+e.m06*n+e.m10*i+e.m14)*r,this},t}(_t));bn.UNIT_X=Object.freeze(new bn(1,0,0)),bn.UNIT_Y=Object.freeze(new bn(0,1,0)),bn.UNIT_Z=Object.freeze(new bn(0,0,1)),bn.RIGHT=Object.freeze(new bn(1,0,0)),bn.UP=Object.freeze(new bn(0,1,0)),bn.FORWARD=Object.freeze(new bn(0,0,-1)),bn.ZERO=Object.freeze(new bn(0,0,0)),bn.ONE=Object.freeze(new bn(1,1,1)),bn.NEG_ONE=Object.freeze(new bn(-1,-1,-1));var wn=new bn,In=new bn;function On(e,t,n){return new bn(e,t,n)}$t.fastDefine("cc.Vec3",bn,{x:0,y:0,z:0}),i.Vec3=bn,i.v3=On;var Pn=e("Mat3",function(e){function t(t,n,i,r,a,s,o,c,l){var u;return void 0===t&&(t=1),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===a&&(a=1),void 0===s&&(s=0),void 0===o&&(o=0),void 0===c&&(c=0),void 0===l&&(l=1),u=e.call(this)||this,"object"==typeof t?(u.m00=t.m00,u.m01=t.m01,u.m02=t.m02,u.m03=t.m03,u.m04=t.m04,u.m05=t.m05,u.m06=t.m06,u.m07=t.m07,u.m08=t.m08):(u.m00=t,u.m01=n,u.m02=i,u.m03=r,u.m04=a,u.m05=s,u.m06=o,u.m07=c,u.m08=l),u}X(t,e),t.clone=function(e){return new t(e.m00,e.m01,e.m02,e.m03,e.m04,e.m05,e.m06,e.m07,e.m08)},t.copy=function(e,t){return e.m00=t.m00,e.m01=t.m01,e.m02=t.m02,e.m03=t.m03,e.m04=t.m04,e.m05=t.m05,e.m06=t.m06,e.m07=t.m07,e.m08=t.m08,e},t.set=function(e,t,n,i,r,a,s,o,c,l){return e.m00=t,e.m01=n,e.m02=i,e.m03=r,e.m04=a,e.m05=s,e.m06=o,e.m07=c,e.m08=l,e},t.identity=function(e){return e.m00=1,e.m01=0,e.m02=0,e.m03=0,e.m04=1,e.m05=0,e.m06=0,e.m07=0,e.m08=1,e},t.transpose=function(e,t){if(e===t){var n=t.m01,i=t.m02,r=t.m05;e.m01=t.m03,e.m02=t.m06,e.m03=n,e.m05=t.m07,e.m06=i,e.m07=r}else e.m00=t.m00,e.m01=t.m03,e.m02=t.m06,e.m03=t.m01,e.m04=t.m04,e.m05=t.m07,e.m06=t.m02,e.m07=t.m05,e.m08=t.m08;return e},t.invert=function(e,t){var n=t.m00,i=t.m01,r=t.m02,a=t.m03,s=t.m04,o=t.m05,c=t.m06,l=t.m07,u=t.m08,h=u*s-o*l,_=-u*a+o*c,f=l*a-s*c,d=n*h+i*_+r*f;return 0===d?(e.m00=0,e.m01=0,e.m02=0,e.m03=0,e.m04=0,e.m05=0,e.m06=0,e.m07=0,e.m08=0,e):(d=1/d,e.m00=h*d,e.m01=(-u*i+r*l)*d,e.m02=(o*i-r*s)*d,e.m03=_*d,e.m04=(u*n-r*c)*d,e.m05=(-o*n+r*a)*d,e.m06=f*d,e.m07=(-l*n+i*c)*d,e.m08=(s*n-i*a)*d,e)},t.determinant=function(e){var t=e.m00,n=e.m01,i=e.m02,r=e.m03,a=e.m04,s=e.m05,o=e.m06,c=e.m07,l=e.m08;return t*(l*a-s*c)+n*(-l*r+s*o)+i*(c*r-a*o)},t.multiply=function(e,t,n){var i=t.m00,r=t.m01,a=t.m02,s=t.m03,o=t.m04,c=t.m05,l=t.m06,u=t.m07,h=t.m08,_=n.m00,f=n.m01,d=n.m02,p=n.m03,m=n.m04,g=n.m05,v=n.m06,y=n.m07,S=n.m08;return e.m00=_*i+f*s+d*l,e.m01=_*r+f*o+d*u,e.m02=_*a+f*c+d*h,e.m03=p*i+m*s+g*l,e.m04=p*r+m*o+g*u,e.m05=p*a+m*c+g*h,e.m06=v*i+y*s+S*l,e.m07=v*r+y*o+S*u,e.m08=v*a+y*c+S*h,e},t.multiplyMat4=function(e,t,n){var i=t.m00,r=t.m01,a=t.m02,s=t.m03,o=t.m04,c=t.m05,l=t.m06,u=t.m07,h=t.m08,_=n.m00,f=n.m01,d=n.m02,p=n.m04,m=n.m05,g=n.m06,v=n.m08,y=n.m09,S=n.m10;return e.m00=_*i+f*s+d*l,e.m01=_*r+f*o+d*u,e.m02=_*a+f*c+d*h,e.m03=p*i+m*s+g*l,e.m04=p*r+m*o+g*u,e.m05=p*a+m*c+g*h,e.m06=v*i+y*s+S*l,e.m07=v*r+y*o+S*u,e.m08=v*a+y*c+S*h,e},t.transform=function(e,t,n){var i=t.m00,r=t.m01,a=t.m02,s=t.m03,o=t.m04,c=t.m05,l=t.m06,u=t.m07,h=t.m08,_=n.x,f=n.y;return e.m00=i,e.m01=r,e.m02=a,e.m03=s,e.m04=o,e.m05=c,e.m06=_*i+f*s+l,e.m07=_*r+f*o+u,e.m08=_*a+f*c+h,e},t.scale=function(e,t,n){var i=n.x,r=n.y;return e.m00=i*t.m00,e.m01=i*t.m01,e.m02=i*t.m02,e.m03=r*t.m03,e.m04=r*t.m04,e.m05=r*t.m05,e.m06=t.m06,e.m07=t.m07,e.m08=t.m08,e},t.rotate=function(e,t,n){var i=t.m00,r=t.m01,a=t.m02,s=t.m03,o=t.m04,c=t.m05,l=t.m06,u=t.m07,h=t.m08,_=Math.sin(n),f=Math.cos(n);return e.m00=f*i+_*s,e.m01=f*r+_*o,e.m02=f*a+_*c,e.m03=f*s-_*i,e.m04=f*o-_*r,e.m05=f*c-_*a,e.m06=l,e.m07=u,e.m08=h,e},t.fromMat4=function(e,t){return e.m00=t.m00,e.m01=t.m01,e.m02=t.m02,e.m03=t.m04,e.m04=t.m05,e.m05=t.m06,e.m06=t.m08,e.m07=t.m09,e.m08=t.m10,e},t.fromViewUp=function(e,n,i){return bn.lengthSqr(n).999999?(e.x=0,e.y=0,e.z=0,e.w=1,e):(bn.cross(Fn,n,i),e.x=Fn.x,e.y=Fn.y,e.z=Fn.z,e.w=1+r,t.normalize(e,e))},t.getAxisAngle=function(e,t){var n=2*Math.acos(t.w),i=Math.sin(n/2);return 0!==i?(e.x=t.x/i,e.y=t.y/i,e.z=t.z/i):(e.x=1,e.y=0,e.z=0),n},t.multiply=function(e,t,n){var i=t.x*n.w+t.w*n.x+t.y*n.z-t.z*n.y,r=t.y*n.w+t.w*n.y+t.z*n.x-t.x*n.z,a=t.z*n.w+t.w*n.z+t.x*n.y-t.y*n.x,s=t.w*n.w-t.x*n.x-t.y*n.y-t.z*n.z;return e.x=i,e.y=r,e.z=a,e.w=s,e},t.multiplyScalar=function(e,t,n){return e.x=t.x*n,e.y=t.y*n,e.z=t.z*n,e.w=t.w*n,e},t.scaleAndAdd=function(e,t,n,i){return e.x=t.x+n.x*i,e.y=t.y+n.y*i,e.z=t.z+n.z*i,e.w=t.w+n.w*i,e},t.rotateX=function(e,t,n){n*=.5;var i=Math.sin(n),r=Math.cos(n),a=t.x,s=t.y,o=t.z,c=t.w;return e.x=a*r+c*i,e.y=s*r+o*i,e.z=o*r-s*i,e.w=c*r-a*i,e},t.rotateY=function(e,t,n){n*=.5;var i=Math.sin(n),r=Math.cos(n),a=t.x,s=t.y,o=t.z,c=t.w;return e.x=a*r-o*i,e.y=s*r+c*i,e.z=o*r+a*i,e.w=c*r-s*i,e},t.rotateZ=function(e,t,n){n*=.5;var i=Math.sin(n),r=Math.cos(n),a=t.x,s=t.y,o=t.z,c=t.w;return e.x=a*r+s*i,e.y=s*r-a*i,e.z=o*r+c*i,e.w=c*r-o*i,e},t.rotateAround=function(e,n,i,r){return t.invert(Bn,n),bn.transformQuat(Fn,i,Bn),t.fromAxisAngle(Bn,Fn,r),t.multiply(e,n,Bn),e},t.rotateAroundLocal=function(e,n,i,r){return t.fromAxisAngle(Bn,i,r),t.multiply(e,n,Bn),e},t.calculateW=function(e,t){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=Math.sqrt(Math.abs(1-t.x*t.x-t.y*t.y-t.z*t.z)),e},t.dot=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w},t.lerp=function(e,t,n,i){return e.x=t.x+i*(n.x-t.x),e.y=t.y+i*(n.y-t.y),e.z=t.z+i*(n.z-t.z),e.w=t.w+i*(n.w-t.w),e},t.slerp=function(e,t,n,i){var r=0,a=0,s=n.x,o=n.y,c=n.z,l=n.w,u=t.x*n.x+t.y*n.y+t.z*n.z+t.w*n.w;if(u<0&&(u=-u,s=-s,o=-o,c=-c,l=-l),1-u>1e-6){var h=Math.acos(u),_=Math.sin(h);r=Math.sin((1-i)*h)/_,a=Math.sin(i*h)/_}else r=1-i,a=i;return e.x=r*t.x+a*s,e.y=r*t.y+a*o,e.z=r*t.z+a*c,e.w=r*t.w+a*l,e},t.sqlerp=function(e,n,i,r,a,s){return t.slerp(Bn,n,a,s),t.slerp(Ln,i,r,s),t.slerp(e,Bn,Ln,2*s*(1-s)),e},t.invert=function(e,t){var n=t.x*t.x+t.y*t.y+t.z*t.z+t.w*t.w,i=n?1/n:0;return e.x=-t.x*i,e.y=-t.y*i,e.z=-t.z*i,e.w=t.w*i,e},t.conjugate=function(e,t){return e.x=-t.x,e.y=-t.y,e.z=-t.z,e.w=t.w,e},t.len=function(e){return Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z+e.w*e.w)},t.lengthSqr=function(e){return e.x*e.x+e.y*e.y+e.z*e.z+e.w*e.w},t.normalize=function(e,t){var n=t.x*t.x+t.y*t.y+t.z*t.z+t.w*t.w;return n>0&&(n=1/Math.sqrt(n),e.x=t.x*n,e.y=t.y*n,e.z=t.z*n,e.w=t.w*n),e},t.fromAxes=function(e,n,i,r){return Pn.set(zn,n.x,n.y,n.z,i.x,i.y,i.z,r.x,r.y,r.z),t.normalize(e,t.fromMat3(e,zn))},t.fromViewUp=function(e,n,i){return Pn.fromViewUp(zn,n,i),t.normalize(e,t.fromMat3(e,zn))},t.fromAxisAngle=function(e,t,n){n*=.5;var i=Math.sin(n);return e.x=i*t.x,e.y=i*t.y,e.z=i*t.z,e.w=Math.cos(n),e},t.fromMat3=function(e,t){var n=t.m00,i=t.m03,r=t.m06,a=t.m01,s=t.m04,o=t.m07,c=t.m02,l=t.m05,u=t.m08,h=n+s+u;if(h>0){var _=.5/Math.sqrt(h+1);e.w=.25/_,e.x=(l-o)*_,e.y=(r-c)*_,e.z=(a-i)*_}else if(n>s&&n>u){var f=2*Math.sqrt(1+n-s-u);e.w=(l-o)/f,e.x=.25*f,e.y=(i+a)/f,e.z=(r+c)/f}else if(s>u){var d=2*Math.sqrt(1+s-n-u);e.w=(r-c)/d,e.x=(i+a)/d,e.y=.25*d,e.z=(o+l)/d}else{var p=2*Math.sqrt(1+u-n-s);e.w=(a-i)/p,e.x=(r+c)/p,e.y=(o+l)/p,e.z=.25*p}return e},t.fromEuler=function(e,t,n,i){t*=Un,n*=Un,i*=Un;var r=Math.sin(t),a=Math.cos(t),s=Math.sin(n),o=Math.cos(n),c=Math.sin(i),l=Math.cos(i);return e.x=r*o*l+a*s*c,e.y=a*s*l+r*o*c,e.z=a*o*c-r*s*l,e.w=a*o*l-r*s*c,e},t.fromAngleZ=function(e,t){return t*=Un,e.x=e.y=0,e.z=Math.sin(t),e.w=Math.cos(t),e},t.toAxisX=function(e,t){var n=2*t.y,i=2*t.z;return e.x=1-n*t.y-i*t.z,e.y=n*t.x+i*t.w,e.z=i*t.x+n*t.w,e},t.toAxisY=function(e,t){var n=2*t.x,i=2*t.y,r=2*t.z;return e.x=i*t.x-r*t.w,e.y=1-n*t.x-r*t.z,e.z=r*t.y+n*t.w,e},t.toAxisZ=function(e,t){var n=2*t.x,i=2*t.y,r=2*t.z;return e.x=r*t.x-i*t.w,e.y=r*t.y-n*t.w,e.z=1-n*t.x-i*t.y,e},t.toEuler=function(e,t,n){var i=t.x,r=t.y,a=t.z,s=t.w,o=0,c=0,l=0,u=i*r+a*s;if(u>.499999)o=0,c=_n(2*Math.atan2(i,s)),l=90;else if(u<-.499999)o=0,c=-_n(2*Math.atan2(i,s)),l=-90;else{var h=i*i,_=r*r,f=a*a;o=_n(Math.atan2(2*i*s-2*r*a,1-2*h-2*f)),c=_n(Math.atan2(2*r*s-2*i*a,1-2*_-2*f)),l=_n(Math.asin(2*u)),n&&(o=-180*Math.sign(o+1e-6)+o,c=-180*Math.sign(c+1e-6)+c,l=180*Math.sign(l+1e-6)-l)}return e.x=o,e.y=c,e.z=l,e},t.toArray=function(e,t,n){return void 0===n&&(n=0),e[n+0]=t.x,e[n+1]=t.y,e[n+2]=t.z,e[n+3]=t.w,e},t.fromArray=function(e,t,n){return void 0===n&&(n=0),e.x=t[n+0],e.y=t[n+1],e.z=t[n+2],e.w=t[n+3],e},t.strictEquals=function(e,t){return e.x===t.x&&e.y===t.y&&e.z===t.z&&e.w===t.w},t.equals=function(e,t,n){return void 0===n&&(n=an),Math.abs(e.x-t.x)<=n*Math.max(1,Math.abs(e.x),Math.abs(t.x))&&Math.abs(e.y-t.y)<=n*Math.max(1,Math.abs(e.y),Math.abs(t.y))&&Math.abs(e.z-t.z)<=n*Math.max(1,Math.abs(e.z),Math.abs(t.z))&&Math.abs(e.w-t.w)<=n*Math.max(1,Math.abs(e.w),Math.abs(t.w))};var n=t.prototype;return n.clone=function(){return new t(this.x,this.y,this.z,this.w)},n.set=function(e,t,n,i){return e&&"object"==typeof e?(this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w):(this.x=e||0,this.y=t||0,this.z=n||0,this.w=null!=i?i:1),this},n.equals=function(e,t){return void 0===t&&(t=an),Math.abs(this.x-e.x)<=t*Math.max(1,Math.abs(this.x),Math.abs(e.x))&&Math.abs(this.y-e.y)<=t*Math.max(1,Math.abs(this.y),Math.abs(e.y))&&Math.abs(this.z-e.z)<=t*Math.max(1,Math.abs(this.z),Math.abs(e.z))&&Math.abs(this.w-e.w)<=t*Math.max(1,Math.abs(this.w),Math.abs(e.w))},n.strictEquals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w},n.getEulerAngles=function(e){return t.toEuler(e,this)},n.lerp=function(e,t){return this.x+=t*(e.x-this.x),this.y+=t*(e.y-this.y),this.z+=t*(e.z-this.z),this.w+=t*(e.w-this.w),this},n.slerp=function(e,n){return t.slerp(this,this,e,n)},n.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},n.lengthSqr=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},t}(_t));Dn.IDENTITY=Object.freeze(new Dn);var Bn=new Dn,Ln=new Dn,Fn=new bn,zn=new Pn,Un=.5*Math.PI/180;function Gn(e,t,n,i){return void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=1),new Dn(e,t,n,i)}$t.fastDefine("cc.Quat",Dn,{x:0,y:0,z:0,w:1}),i.Quat=Dn,i.quat=Gn;var kn=Object.freeze([Object.freeze([1,0,0,1]),Object.freeze([0,1,-1,0]),Object.freeze([-1,0,0,-1]),Object.freeze([0,-1,1,0])]),Hn=e("Mat4",function(e){function t(t,n,i,r,a,s,o,c,l,u,h,_,f,d,p,m){var g;return void 0===t&&(t=1),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===a&&(a=0),void 0===s&&(s=1),void 0===o&&(o=0),void 0===c&&(c=0),void 0===l&&(l=0),void 0===u&&(u=0),void 0===h&&(h=1),void 0===_&&(_=0),void 0===f&&(f=0),void 0===d&&(d=0),void 0===p&&(p=0),void 0===m&&(m=1),(g=e.call(this)||this).m00=void 0,g.m01=void 0,g.m02=void 0,g.m03=void 0,g.m04=void 0,g.m05=void 0,g.m06=void 0,g.m07=void 0,g.m08=void 0,g.m09=void 0,g.m10=void 0,g.m11=void 0,g.m12=void 0,g.m13=void 0,g.m14=void 0,g.m15=void 0,"object"==typeof t?(g.m00=t.m00,g.m01=t.m01,g.m02=t.m02,g.m03=t.m03,g.m04=t.m04,g.m05=t.m05,g.m06=t.m06,g.m07=t.m07,g.m08=t.m08,g.m09=t.m09,g.m10=t.m10,g.m11=t.m11,g.m12=t.m12,g.m13=t.m13,g.m14=t.m14,g.m15=t.m15):(g.m00=t,g.m01=n,g.m02=i,g.m03=r,g.m04=a,g.m05=s,g.m06=o,g.m07=c,g.m08=l,g.m09=u,g.m10=h,g.m11=_,g.m12=f,g.m13=d,g.m14=p,g.m15=m),g}X(t,e),t.clone=function(e){return new t(e.m00,e.m01,e.m02,e.m03,e.m04,e.m05,e.m06,e.m07,e.m08,e.m09,e.m10,e.m11,e.m12,e.m13,e.m14,e.m15)},t.copy=function(e,t){return e.m00=t.m00,e.m01=t.m01,e.m02=t.m02,e.m03=t.m03,e.m04=t.m04,e.m05=t.m05,e.m06=t.m06,e.m07=t.m07,e.m08=t.m08,e.m09=t.m09,e.m10=t.m10,e.m11=t.m11,e.m12=t.m12,e.m13=t.m13,e.m14=t.m14,e.m15=t.m15,e},t.set=function(e,t,n,i,r,a,s,o,c,l,u,h,_,f,d,p,m){return e.m00=t,e.m01=n,e.m02=i,e.m03=r,e.m04=a,e.m05=s,e.m06=o,e.m07=c,e.m08=l,e.m09=u,e.m10=h,e.m11=_,e.m12=f,e.m13=d,e.m14=p,e.m15=m,e},t.identity=function(e){return e.m00=1,e.m01=0,e.m02=0,e.m03=0,e.m04=0,e.m05=1,e.m06=0,e.m07=0,e.m08=0,e.m09=0,e.m10=1,e.m11=0,e.m12=0,e.m13=0,e.m14=0,e.m15=1,e},t.transpose=function(e,t){if(e===t){var n=t.m01,i=t.m02,r=t.m03,a=t.m06,s=t.m07,o=t.m11;e.m01=t.m04,e.m02=t.m08,e.m03=t.m12,e.m04=n,e.m06=t.m09,e.m07=t.m13,e.m08=i,e.m09=a,e.m11=t.m14,e.m12=r,e.m13=s,e.m14=o}else e.m00=t.m00,e.m01=t.m04,e.m02=t.m08,e.m03=t.m12,e.m04=t.m01,e.m05=t.m05,e.m06=t.m09,e.m07=t.m13,e.m08=t.m02,e.m09=t.m06,e.m10=t.m10,e.m11=t.m14,e.m12=t.m03,e.m13=t.m07,e.m14=t.m11,e.m15=t.m15;return e},t.invert=function(e,t){var n=t.m00,i=t.m01,r=t.m02,a=t.m03,s=t.m04,o=t.m05,c=t.m06,l=t.m07,u=t.m08,h=t.m09,_=t.m10,f=t.m11,d=t.m12,p=t.m13,m=t.m14,g=t.m15,v=n*o-i*s,y=n*c-r*s,S=n*l-a*s,E=i*c-r*o,T=i*l-a*o,A=r*l-a*c,x=u*p-h*d,C=u*m-_*d,R=u*g-f*d,b=h*m-_*p,w=h*g-f*p,I=_*g-f*m,O=v*I-y*w+S*b+E*R-T*C+A*x;return 0===O?(e.m00=0,e.m01=0,e.m02=0,e.m03=0,e.m04=0,e.m05=0,e.m06=0,e.m07=0,e.m08=0,e.m09=0,e.m10=0,e.m11=0,e.m12=0,e.m13=0,e.m14=0,e.m15=0,e):(O=1/O,e.m00=(o*I-c*w+l*b)*O,e.m01=(r*w-i*I-a*b)*O,e.m02=(p*A-m*T+g*E)*O,e.m03=(_*T-h*A-f*E)*O,e.m04=(c*R-s*I-l*C)*O,e.m05=(n*I-r*R+a*C)*O,e.m06=(m*S-d*A-g*y)*O,e.m07=(u*A-_*S+f*y)*O,e.m08=(s*w-o*R+l*x)*O,e.m09=(i*R-n*w-a*x)*O,e.m10=(d*T-p*S+g*v)*O,e.m11=(h*S-u*T-f*v)*O,e.m12=(o*C-s*b-c*x)*O,e.m13=(n*b-i*C+r*x)*O,e.m14=(p*y-d*E-m*v)*O,e.m15=(u*E-h*y+_*v)*O,e)},t.determinant=function(e){var t=e.m00,n=e.m01,i=e.m02,r=e.m03,a=e.m04,s=e.m05,o=e.m06,c=e.m07,l=e.m08,u=e.m09,h=e.m10,_=e.m11,f=e.m12,d=e.m13,p=e.m14,m=e.m15;return(t*s-n*a)*(h*m-_*p)-(t*o-i*a)*(u*m-_*d)+(t*c-r*a)*(u*p-h*d)+(n*o-i*s)*(l*m-_*f)-(n*c-r*s)*(l*p-h*f)+(i*c-r*o)*(l*d-u*f)},t.multiply=function(e,t,n){var i=t.m00,r=t.m01,a=t.m02,s=t.m03,o=t.m04,c=t.m05,l=t.m06,u=t.m07,h=t.m08,_=t.m09,f=t.m10,d=t.m11,p=t.m12,m=t.m13,g=t.m14,v=t.m15,y=n.m00,S=n.m01,E=n.m02,T=n.m03;return e.m00=y*i+S*o+E*h+T*p,e.m01=y*r+S*c+E*_+T*m,e.m02=y*a+S*l+E*f+T*g,e.m03=y*s+S*u+E*d+T*v,y=n.m04,S=n.m05,E=n.m06,T=n.m07,e.m04=y*i+S*o+E*h+T*p,e.m05=y*r+S*c+E*_+T*m,e.m06=y*a+S*l+E*f+T*g,e.m07=y*s+S*u+E*d+T*v,y=n.m08,S=n.m09,E=n.m10,T=n.m11,e.m08=y*i+S*o+E*h+T*p,e.m09=y*r+S*c+E*_+T*m,e.m10=y*a+S*l+E*f+T*g,e.m11=y*s+S*u+E*d+T*v,y=n.m12,S=n.m13,E=n.m14,T=n.m15,e.m12=y*i+S*o+E*h+T*p,e.m13=y*r+S*c+E*_+T*m,e.m14=y*a+S*l+E*f+T*g,e.m15=y*s+S*u+E*d+T*v,e},t.transform=function(e,t,n){var i=n.x,r=n.y,a=n.z;if(t===e)e.m12=t.m00*i+t.m04*r+t.m08*a+t.m12,e.m13=t.m01*i+t.m05*r+t.m09*a+t.m13,e.m14=t.m02*i+t.m06*r+t.m10*a+t.m14,e.m15=t.m03*i+t.m07*r+t.m11*a+t.m15;else{var s=t.m00,o=t.m01,c=t.m02,l=t.m03,u=t.m04,h=t.m05,_=t.m06,f=t.m07,d=t.m08,p=t.m09,m=t.m10,g=t.m11;t.m12,t.m13,t.m14,t.m15,e.m00=s,e.m01=o,e.m02=c,e.m03=l,e.m04=u,e.m05=h,e.m06=_,e.m07=f,e.m08=d,e.m09=p,e.m10=m,e.m11=g,e.m12=s*i+u*r+d*a+t.m12,e.m13=o*i+h*r+p*a+t.m13,e.m14=c*i+_*r+m*a+t.m14,e.m15=l*i+f*r+g*a+t.m15}return e},t.translate=function(e,t,n){return console.warn("function changed"),t===e?(e.m12+=n.x,e.m13+=n.y,e.m14+=n.z):(e.m00=t.m00,e.m01=t.m01,e.m02=t.m02,e.m03=t.m03,e.m04=t.m04,e.m05=t.m05,e.m06=t.m06,e.m07=t.m07,e.m08=t.m08,e.m09=t.m09,e.m10=t.m10,e.m11=t.m11,e.m12+=n.x,e.m13+=n.y,e.m14+=n.z,e.m15=t.m15),e},t.scale=function(e,t,n){var i=n.x,r=n.y,a=n.z;return e.m00=t.m00*i,e.m01=t.m01*i,e.m02=t.m02*i,e.m03=t.m03*i,e.m04=t.m04*r,e.m05=t.m05*r,e.m06=t.m06*r,e.m07=t.m07*r,e.m08=t.m08*a,e.m09=t.m09*a,e.m10=t.m10*a,e.m11=t.m11*a,e.m12=t.m12,e.m13=t.m13,e.m14=t.m14,e.m15=t.m15,e},t.rotate=function(e,t,n,i){var r=i.x,a=i.y,s=i.z,o=Math.sqrt(r*r+a*a+s*s);if(Math.abs(o)0?(i=2*Math.sqrt(n+1),e.w=.25*i,e.x=(t.m06-t.m09)/i,e.y=(t.m08-t.m02)/i,e.z=(t.m01-t.m04)/i):t.m00>t.m05&&t.m00>t.m10?(i=2*Math.sqrt(1+t.m00-t.m05-t.m10),e.w=(t.m06-t.m09)/i,e.x=.25*i,e.y=(t.m01+t.m04)/i,e.z=(t.m08+t.m02)/i):t.m05>t.m10?(i=2*Math.sqrt(1+t.m05-t.m00-t.m10),e.w=(t.m08-t.m02)/i,e.x=(t.m01+t.m04)/i,e.y=.25*i,e.z=(t.m06+t.m09)/i):(i=2*Math.sqrt(1+t.m10-t.m00-t.m05),e.w=(t.m01-t.m04)/i,e.x=(t.m08+t.m02)/i,e.y=(t.m06+t.m09)/i,e.z=.25*i),e},t.toRTS=function(e,t,n,i){i.x=bn.set(Vn,e.m00,e.m01,e.m02).length(),Wn.m00=e.m00/i.x,Wn.m01=e.m01/i.x,Wn.m02=e.m02/i.x,i.y=bn.set(Vn,e.m04,e.m05,e.m06).length(),Wn.m03=e.m04/i.y,Wn.m04=e.m05/i.y,Wn.m05=e.m06/i.y,i.z=bn.set(Vn,e.m08,e.m09,e.m10).length(),Wn.m06=e.m08/i.z,Wn.m07=e.m09/i.z,Wn.m08=e.m10/i.z,Pn.determinant(Wn)<0&&(i.x*=-1,Wn.m00*=-1,Wn.m01*=-1,Wn.m02*=-1),Dn.fromMat3(t,Wn),bn.set(n,e.m12,e.m13,e.m14)},t.fromRTS=function(e,t,n,i){var r=t.x,a=t.y,s=t.z,o=t.w,c=r+r,l=a+a,u=s+s,h=r*c,_=r*l,f=r*u,d=a*l,p=a*u,m=s*u,g=o*c,v=o*l,y=o*u,S=i.x,E=i.y,T=i.z;return e.m00=(1-(d+m))*S,e.m01=(_+y)*S,e.m02=(f-v)*S,e.m03=0,e.m04=(_-y)*E,e.m05=(1-(h+m))*E,e.m06=(p+g)*E,e.m07=0,e.m08=(f+v)*T,e.m09=(p-g)*T,e.m10=(1-(h+d))*T,e.m11=0,e.m12=n.x,e.m13=n.y,e.m14=n.z,e.m15=1,e},t.fromRTSOrigin=function(e,t,n,i,r){var a=t.x,s=t.y,o=t.z,c=t.w,l=a+a,u=s+s,h=o+o,_=a*l,f=a*u,d=a*h,p=s*u,m=s*h,g=o*h,v=c*l,y=c*u,S=c*h,E=i.x,T=i.y,A=i.z,x=r.x,C=r.y,R=r.z;return e.m00=(1-(p+g))*E,e.m01=(f+S)*E,e.m02=(d-y)*E,e.m03=0,e.m04=(f-S)*T,e.m05=(1-(_+g))*T,e.m06=(m+v)*T,e.m07=0,e.m08=(d+y)*A,e.m09=(m-v)*A,e.m10=(1-(_+p))*A,e.m11=0,e.m12=n.x+x-(e.m00*x+e.m04*C+e.m08*R),e.m13=n.y+C-(e.m01*x+e.m05*C+e.m09*R),e.m14=n.z+R-(e.m02*x+e.m06*C+e.m10*R),e.m15=1,e},t.fromQuat=function(e,t){var n=t.x,i=t.y,r=t.z,a=t.w,s=n+n,o=i+i,c=r+r,l=n*s,u=i*s,h=i*o,_=r*s,f=r*o,d=r*c,p=a*s,m=a*o,g=a*c;return e.m00=1-h-d,e.m01=u+g,e.m02=_-m,e.m03=0,e.m04=u-g,e.m05=1-l-d,e.m06=f+p,e.m07=0,e.m08=_+m,e.m09=f-p,e.m10=1-l-h,e.m11=0,e.m12=0,e.m13=0,e.m14=0,e.m15=1,e},t.frustum=function(e,t,n,i,r,a,s){var o=1/(n-t),c=1/(r-i),l=1/(a-s);return e.m00=2*a*o,e.m01=0,e.m02=0,e.m03=0,e.m04=0,e.m05=2*a*c,e.m06=0,e.m07=0,e.m08=(n+t)*o,e.m09=(r+i)*c,e.m10=(s+a)*l,e.m11=-1,e.m12=0,e.m13=0,e.m14=s*a*2*l,e.m15=0,e},t.perspective=function(e,t,n,i,r,a,s,o,c){void 0===a&&(a=!0),void 0===s&&(s=-1),void 0===o&&(o=1),void 0===c&&(c=0);var l=1/Math.tan(t/2),u=1/(i-r),h=a?l/n:l,_=(a?l:l*n)*o,f=kn[c];return e.m00=h*f[0],e.m01=h*f[1],e.m02=0,e.m03=0,e.m04=_*f[2],e.m05=_*f[3],e.m06=0,e.m07=0,e.m08=0,e.m09=0,e.m10=(r-s*i)*u,e.m11=-1,e.m12=0,e.m13=0,e.m14=r*i*u*(1-s),e.m15=0,e},t.ortho=function(e,t,n,i,r,a,s,o,c,l){void 0===o&&(o=-1),void 0===c&&(c=1),void 0===l&&(l=0);var u=1/(t-n),h=1/(i-r)*c,_=1/(a-s),f=-2*u,d=-2*h,p=(t+n)*u,m=(r+i)*h,g=kn[l];return e.m00=f*g[0],e.m01=f*g[1],e.m02=0,e.m03=0,e.m04=d*g[2],e.m05=d*g[3],e.m06=0,e.m07=0,e.m08=0,e.m09=0,e.m10=_*(1-o),e.m11=0,e.m12=p*g[0]+m*g[2],e.m13=p*g[1]+m*g[3],e.m14=(a-o*s)*_,e.m15=1,e},t.lookAt=function(e,t,n,i){var r=t.x,a=t.y,s=t.z,o=i.x,c=i.y,l=i.z,u=r-n.x,h=a-n.y,_=s-n.z,f=1/Math.sqrt(u*u+h*h+_*_),d=c*(_*=f)-l*(h*=f),p=l*(u*=f)-o*_,m=o*h-c*u,g=h*(m*=f=1/Math.sqrt(d*d+p*p+m*m))-_*(p*=f),v=_*(d*=f)-u*m,y=u*p-h*d;return e.m00=d,e.m01=g,e.m02=u,e.m03=0,e.m04=p,e.m05=v,e.m06=h,e.m07=0,e.m08=m,e.m09=y,e.m10=_,e.m11=0,e.m12=-(d*r+p*a+m*s),e.m13=-(g*r+v*a+y*s),e.m14=-(u*r+h*a+_*s),e.m15=1,e},t.inverseTranspose=function(e,t){var n=t.m00,i=t.m01,r=t.m02,a=t.m03,s=t.m04,o=t.m05,c=t.m06,l=t.m07,u=t.m08,h=t.m09,_=t.m10,f=t.m11,d=t.m12,p=t.m13,m=t.m14,g=t.m15,v=n*o-i*s,y=n*c-r*s,S=n*l-a*s,E=i*c-r*o,T=i*l-a*o,A=r*l-a*c,x=u*p-h*d,C=u*m-_*d,R=u*g-f*d,b=h*m-_*p,w=h*g-f*p,I=_*g-f*m,O=v*I-y*w+S*b+E*R-T*C+A*x;return O?(O=1/O,e.m00=(o*I-c*w+l*b)*O,e.m01=(c*R-s*I-l*C)*O,e.m02=(s*w-o*R+l*x)*O,e.m03=0,e.m04=(r*w-i*I-a*b)*O,e.m05=(n*I-r*R+a*C)*O,e.m06=(i*R-n*w-a*x)*O,e.m07=0,e.m08=(p*A-m*T+g*E)*O,e.m09=(m*S-d*A-g*y)*O,e.m10=(d*T-p*S+g*v)*O,e.m11=0,e.m12=0,e.m13=0,e.m14=0,e.m15=1,e):null},t.toArray=function(e,t,n){return void 0===n&&(n=0),e[n+0]=t.m00,e[n+1]=t.m01,e[n+2]=t.m02,e[n+3]=t.m03,e[n+4]=t.m04,e[n+5]=t.m05,e[n+6]=t.m06,e[n+7]=t.m07,e[n+8]=t.m08,e[n+9]=t.m09,e[n+10]=t.m10,e[n+11]=t.m11,e[n+12]=t.m12,e[n+13]=t.m13,e[n+14]=t.m14,e[n+15]=t.m15,e},t.fromArray=function(e,t,n){return void 0===n&&(n=0),e.m00=t[n+0],e.m01=t[n+1],e.m02=t[n+2],e.m03=t[n+3],e.m04=t[n+4],e.m05=t[n+5],e.m06=t[n+6],e.m07=t[n+7],e.m08=t[n+8],e.m09=t[n+9],e.m10=t[n+10],e.m11=t[n+11],e.m12=t[n+12],e.m13=t[n+13],e.m14=t[n+14],e.m15=t[n+15],e},t.add=function(e,t,n){return e.m00=t.m00+n.m00,e.m01=t.m01+n.m01,e.m02=t.m02+n.m02,e.m03=t.m03+n.m03,e.m04=t.m04+n.m04,e.m05=t.m05+n.m05,e.m06=t.m06+n.m06,e.m07=t.m07+n.m07,e.m08=t.m08+n.m08,e.m09=t.m09+n.m09,e.m10=t.m10+n.m10,e.m11=t.m11+n.m11,e.m12=t.m12+n.m12,e.m13=t.m13+n.m13,e.m14=t.m14+n.m14,e.m15=t.m15+n.m15,e},t.subtract=function(e,t,n){return e.m00=t.m00-n.m00,e.m01=t.m01-n.m01,e.m02=t.m02-n.m02,e.m03=t.m03-n.m03,e.m04=t.m04-n.m04,e.m05=t.m05-n.m05,e.m06=t.m06-n.m06,e.m07=t.m07-n.m07,e.m08=t.m08-n.m08,e.m09=t.m09-n.m09,e.m10=t.m10-n.m10,e.m11=t.m11-n.m11,e.m12=t.m12-n.m12,e.m13=t.m13-n.m13,e.m14=t.m14-n.m14,e.m15=t.m15-n.m15,e},t.multiplyScalar=function(e,t,n){return e.m00=t.m00*n,e.m01=t.m01*n,e.m02=t.m02*n,e.m03=t.m03*n,e.m04=t.m04*n,e.m05=t.m05*n,e.m06=t.m06*n,e.m07=t.m07*n,e.m08=t.m08*n,e.m09=t.m09*n,e.m10=t.m10*n,e.m11=t.m11*n,e.m12=t.m12*n,e.m13=t.m13*n,e.m14=t.m14*n,e.m15=t.m15*n,e},t.multiplyScalarAndAdd=function(e,t,n,i){return e.m00=t.m00+n.m00*i,e.m01=t.m01+n.m01*i,e.m02=t.m02+n.m02*i,e.m03=t.m03+n.m03*i,e.m04=t.m04+n.m04*i,e.m05=t.m05+n.m05*i,e.m06=t.m06+n.m06*i,e.m07=t.m07+n.m07*i,e.m08=t.m08+n.m08*i,e.m09=t.m09+n.m09*i,e.m10=t.m10+n.m10*i,e.m11=t.m11+n.m11*i,e.m12=t.m12+n.m12*i,e.m13=t.m13+n.m13*i,e.m14=t.m14+n.m14*i,e.m15=t.m15+n.m15*i,e},t.strictEquals=function(e,t){return e.m00===t.m00&&e.m01===t.m01&&e.m02===t.m02&&e.m03===t.m03&&e.m04===t.m04&&e.m05===t.m05&&e.m06===t.m06&&e.m07===t.m07&&e.m08===t.m08&&e.m09===t.m09&&e.m10===t.m10&&e.m11===t.m11&&e.m12===t.m12&&e.m13===t.m13&&e.m14===t.m14&&e.m15===t.m15},t.equals=function(e,t,n){return void 0===n&&(n=an),Math.abs(e.m00-t.m00)<=n*Math.max(1,Math.abs(e.m00),Math.abs(t.m00))&&Math.abs(e.m01-t.m01)<=n*Math.max(1,Math.abs(e.m01),Math.abs(t.m01))&&Math.abs(e.m02-t.m02)<=n*Math.max(1,Math.abs(e.m02),Math.abs(t.m02))&&Math.abs(e.m03-t.m03)<=n*Math.max(1,Math.abs(e.m03),Math.abs(t.m03))&&Math.abs(e.m04-t.m04)<=n*Math.max(1,Math.abs(e.m04),Math.abs(t.m04))&&Math.abs(e.m05-t.m05)<=n*Math.max(1,Math.abs(e.m05),Math.abs(t.m05))&&Math.abs(e.m06-t.m06)<=n*Math.max(1,Math.abs(e.m06),Math.abs(t.m06))&&Math.abs(e.m07-t.m07)<=n*Math.max(1,Math.abs(e.m07),Math.abs(t.m07))&&Math.abs(e.m08-t.m08)<=n*Math.max(1,Math.abs(e.m08),Math.abs(t.m08))&&Math.abs(e.m09-t.m09)<=n*Math.max(1,Math.abs(e.m09),Math.abs(t.m09))&&Math.abs(e.m10-t.m10)<=n*Math.max(1,Math.abs(e.m10),Math.abs(t.m10))&&Math.abs(e.m11-t.m11)<=n*Math.max(1,Math.abs(e.m11),Math.abs(t.m11))&&Math.abs(e.m12-t.m12)<=n*Math.max(1,Math.abs(e.m12),Math.abs(t.m12))&&Math.abs(e.m13-t.m13)<=n*Math.max(1,Math.abs(e.m13),Math.abs(t.m13))&&Math.abs(e.m14-t.m14)<=n*Math.max(1,Math.abs(e.m14),Math.abs(t.m14))&&Math.abs(e.m15-t.m15)<=n*Math.max(1,Math.abs(e.m15),Math.abs(t.m15))};var n=t.prototype;return n.clone=function(){return new t(this.m00,this.m01,this.m02,this.m03,this.m04,this.m05,this.m06,this.m07,this.m08,this.m09,this.m10,this.m11,this.m12,this.m13,this.m14,this.m15)},n.set=function(e,t,n,i,r,a,s,o,c,l,u,h,_,f,d,p){return void 0===e&&(e=1),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===a&&(a=1),void 0===s&&(s=0),void 0===o&&(o=0),void 0===c&&(c=0),void 0===l&&(l=0),void 0===u&&(u=1),void 0===h&&(h=0),void 0===_&&(_=0),void 0===f&&(f=0),void 0===d&&(d=0),void 0===p&&(p=1),"object"==typeof e?(this.m01=e.m01,this.m02=e.m02,this.m03=e.m03,this.m04=e.m04,this.m05=e.m05,this.m06=e.m06,this.m07=e.m07,this.m08=e.m08,this.m09=e.m09,this.m10=e.m10,this.m11=e.m11,this.m12=e.m12,this.m13=e.m13,this.m14=e.m14,this.m15=e.m15,this.m00=e.m00):(this.m01=t,this.m02=n,this.m03=i,this.m04=r,this.m05=a,this.m06=s,this.m07=o,this.m08=c,this.m09=l,this.m10=u,this.m11=h,this.m12=_,this.m13=f,this.m14=d,this.m15=p,this.m00=e),this},n.equals=function(e,t){return void 0===t&&(t=an),Math.abs(this.m00-e.m00)<=t*Math.max(1,Math.abs(this.m00),Math.abs(e.m00))&&Math.abs(this.m01-e.m01)<=t*Math.max(1,Math.abs(this.m01),Math.abs(e.m01))&&Math.abs(this.m02-e.m02)<=t*Math.max(1,Math.abs(this.m02),Math.abs(e.m02))&&Math.abs(this.m03-e.m03)<=t*Math.max(1,Math.abs(this.m03),Math.abs(e.m03))&&Math.abs(this.m04-e.m04)<=t*Math.max(1,Math.abs(this.m04),Math.abs(e.m04))&&Math.abs(this.m05-e.m05)<=t*Math.max(1,Math.abs(this.m05),Math.abs(e.m05))&&Math.abs(this.m06-e.m06)<=t*Math.max(1,Math.abs(this.m06),Math.abs(e.m06))&&Math.abs(this.m07-e.m07)<=t*Math.max(1,Math.abs(this.m07),Math.abs(e.m07))&&Math.abs(this.m08-e.m08)<=t*Math.max(1,Math.abs(this.m08),Math.abs(e.m08))&&Math.abs(this.m09-e.m09)<=t*Math.max(1,Math.abs(this.m09),Math.abs(e.m09))&&Math.abs(this.m10-e.m10)<=t*Math.max(1,Math.abs(this.m10),Math.abs(e.m10))&&Math.abs(this.m11-e.m11)<=t*Math.max(1,Math.abs(this.m11),Math.abs(e.m11))&&Math.abs(this.m12-e.m12)<=t*Math.max(1,Math.abs(this.m12),Math.abs(e.m12))&&Math.abs(this.m13-e.m13)<=t*Math.max(1,Math.abs(this.m13),Math.abs(e.m13))&&Math.abs(this.m14-e.m14)<=t*Math.max(1,Math.abs(this.m14),Math.abs(e.m14))&&Math.abs(this.m15-e.m15)<=t*Math.max(1,Math.abs(this.m15),Math.abs(e.m15))},n.strictEquals=function(e){return this.m00===e.m00&&this.m01===e.m01&&this.m02===e.m02&&this.m03===e.m03&&this.m04===e.m04&&this.m05===e.m05&&this.m06===e.m06&&this.m07===e.m07&&this.m08===e.m08&&this.m09===e.m09&&this.m10===e.m10&&this.m11===e.m11&&this.m12===e.m12&&this.m13===e.m13&&this.m14===e.m14&&this.m15===e.m15},n.toString=function(){return"[\n"+this.m00+", "+this.m01+", "+this.m02+", "+this.m03+",\n"+this.m04+", "+this.m05+", "+this.m06+", "+this.m07+",\n"+this.m08+", "+this.m09+", "+this.m10+", "+this.m11+",\n"+this.m12+", "+this.m13+", "+this.m14+", "+this.m15+"\n]"},n.identity=function(){return this.m00=1,this.m01=0,this.m02=0,this.m03=0,this.m04=0,this.m05=1,this.m06=0,this.m07=0,this.m08=0,this.m09=0,this.m10=1,this.m11=0,this.m12=0,this.m13=0,this.m14=0,this.m15=1,this},n.zero=function(){return this.m00=0,this.m01=0,this.m02=0,this.m03=0,this.m04=0,this.m05=0,this.m06=0,this.m07=0,this.m08=0,this.m09=0,this.m10=0,this.m11=0,this.m12=0,this.m13=0,this.m14=0,this.m15=0,this},n.transpose=function(){var e=this.m01,t=this.m02,n=this.m03,i=this.m06,r=this.m07,a=this.m11;return this.m01=this.m04,this.m02=this.m08,this.m03=this.m12,this.m04=e,this.m06=this.m09,this.m07=this.m13,this.m08=t,this.m09=i,this.m11=this.m14,this.m12=n,this.m13=r,this.m14=a,this},n.invert=function(){var e=this.m00,t=this.m01,n=this.m02,i=this.m03,r=this.m04,a=this.m05,s=this.m06,o=this.m07,c=this.m08,l=this.m09,u=this.m10,h=this.m11,_=this.m12,f=this.m13,d=this.m14,p=this.m15,m=e*a-t*r,g=e*s-n*r,v=e*o-i*r,y=t*s-n*a,S=t*o-i*a,E=n*o-i*s,T=c*f-l*_,A=c*d-u*_,x=c*p-h*_,C=l*d-u*f,R=l*p-h*f,b=u*p-h*d,w=m*b-g*R+v*C+y*x-S*A+E*T;return 0===w?(this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),this):(w=1/w,this.m00=(a*b-s*R+o*C)*w,this.m01=(n*R-t*b-i*C)*w,this.m02=(f*E-d*S+p*y)*w,this.m03=(u*S-l*E-h*y)*w,this.m04=(s*x-r*b-o*A)*w,this.m05=(e*b-n*x+i*A)*w,this.m06=(d*v-_*E-p*g)*w,this.m07=(c*E-u*v+h*g)*w,this.m08=(r*R-a*x+o*T)*w,this.m09=(t*x-e*R-i*T)*w,this.m10=(_*S-f*v+p*m)*w,this.m11=(l*v-c*S-h*m)*w,this.m12=(a*A-r*C-s*T)*w,this.m13=(e*C-t*A+n*T)*w,this.m14=(f*g-_*y-d*m)*w,this.m15=(c*y-l*g+u*m)*w,this)},n.determinant=function(){var e=this.m00,t=this.m01,n=this.m02,i=this.m03,r=this.m04,a=this.m05,s=this.m06,o=this.m07,c=this.m08,l=this.m09,u=this.m10,h=this.m11,_=this.m12,f=this.m13,d=this.m14,p=this.m15;return(e*a-t*r)*(u*p-h*d)-(e*s-n*r)*(l*p-h*f)+(e*o-i*r)*(l*d-u*f)+(t*s-n*a)*(c*p-h*_)-(t*o-i*a)*(c*d-u*_)+(n*o-i*s)*(c*f-l*_)},n.add=function(e){return this.m00+=e.m00,this.m01+=e.m01,this.m02+=e.m02,this.m03+=e.m03,this.m04+=e.m04,this.m05+=e.m05,this.m06+=e.m06,this.m07+=e.m07,this.m08+=e.m08,this.m09+=e.m09,this.m10+=e.m10,this.m11+=e.m11,this.m12+=e.m12,this.m13+=e.m13,this.m14+=e.m14,this.m15+=e.m15,this},n.subtract=function(e){return this.m00-=e.m00,this.m01-=e.m01,this.m02-=e.m02,this.m03-=e.m03,this.m04-=e.m04,this.m05-=e.m05,this.m06-=e.m06,this.m07-=e.m07,this.m08-=e.m08,this.m09-=e.m09,this.m10-=e.m10,this.m11-=e.m11,this.m12-=e.m12,this.m13-=e.m13,this.m14-=e.m14,this.m15-=e.m15,this},n.multiply=function(e){var t=this.m00,n=this.m01,i=this.m02,r=this.m03,a=this.m04,s=this.m05,o=this.m06,c=this.m07,l=this.m08,u=this.m09,h=this.m10,_=this.m11,f=this.m12,d=this.m13,p=this.m14,m=this.m15,g=e.m00,v=e.m01,y=e.m02,S=e.m03;return this.m00=g*t+v*a+y*l+S*f,this.m01=g*n+v*s+y*u+S*d,this.m02=g*i+v*o+y*h+S*p,this.m03=g*r+v*c+y*_+S*m,g=e.m04,v=e.m05,y=e.m06,S=e.m07,this.m04=g*t+v*a+y*l+S*f,this.m05=g*n+v*s+y*u+S*d,this.m06=g*i+v*o+y*h+S*p,this.m07=g*r+v*c+y*_+S*m,g=e.m08,v=e.m09,y=e.m10,S=e.m11,this.m08=g*t+v*a+y*l+S*f,this.m09=g*n+v*s+y*u+S*d,this.m10=g*i+v*o+y*h+S*p,this.m11=g*r+v*c+y*_+S*m,g=e.m12,v=e.m13,y=e.m14,S=e.m15,this.m12=g*t+v*a+y*l+S*f,this.m13=g*n+v*s+y*u+S*d,this.m14=g*i+v*o+y*h+S*p,this.m15=g*r+v*c+y*_+S*m,this},n.multiplyScalar=function(e){return this.m00*=e,this.m01*=e,this.m02*=e,this.m03*=e,this.m04*=e,this.m05*=e,this.m06*=e,this.m07*=e,this.m08*=e,this.m09*=e,this.m10*=e,this.m11*=e,this.m12*=e,this.m13*=e,this.m14*=e,this.m15*=e,this},n.translate=function(e){return console.warn("function changed"),this.m12+=e.x,this.m13+=e.y,this.m14+=e.z,this},n.scale=function(e){var t=e.x,n=e.y,i=e.z;return this.m00*=t,this.m01*=t,this.m02*=t,this.m03*=t,this.m04*=n,this.m05*=n,this.m06*=n,this.m07*=n,this.m08*=i,this.m09*=i,this.m10*=i,this.m11*=i,this},n.rotate=function(e,t){var n=t.x,i=t.y,r=t.z,a=Math.sqrt(n*n+i*i+r*r);if(Math.abs(a)0?(n=2*Math.sqrt(t+1),e.w=.25*n,e.x=(this.m06-this.m09)/n,e.y=(this.m08-this.m02)/n,e.z=(this.m01-this.m04)/n):this.m00>this.m05&&this.m00>this.m10?(n=2*Math.sqrt(1+this.m00-this.m05-this.m10),e.w=(this.m06-this.m09)/n,e.x=.25*n,e.y=(this.m01+this.m04)/n,e.z=(this.m08+this.m02)/n):this.m05>this.m10?(n=2*Math.sqrt(1+this.m05-this.m00-this.m10),e.w=(this.m08-this.m02)/n,e.x=(this.m01+this.m04)/n,e.y=.25*n,e.z=(this.m06+this.m09)/n):(n=2*Math.sqrt(1+this.m10-this.m00-this.m05),e.w=(this.m01-this.m04)/n,e.x=(this.m08+this.m02)/n,e.y=(this.m06+this.m09)/n,e.z=.25*n),e},n.fromRTS=function(e,t,n){var i=e.x,r=e.y,a=e.z,s=e.w,o=i+i,c=r+r,l=a+a,u=i*o,h=i*c,_=i*l,f=r*c,d=r*l,p=a*l,m=s*o,g=s*c,v=s*l,y=n.x,S=n.y,E=n.z;return this.m00=(1-(f+p))*y,this.m01=(h+v)*y,this.m02=(_-g)*y,this.m03=0,this.m04=(h-v)*S,this.m05=(1-(u+p))*S,this.m06=(d+m)*S,this.m07=0,this.m08=(_+g)*E,this.m09=(d-m)*E,this.m10=(1-(u+f))*E,this.m11=0,this.m12=t.x,this.m13=t.y,this.m14=t.z,this.m15=1,this},n.fromQuat=function(e){var t=e.x,n=e.y,i=e.z,r=e.w,a=t+t,s=n+n,o=i+i,c=t*a,l=n*a,u=n*s,h=i*a,_=i*s,f=i*o,d=r*a,p=r*s,m=r*o;return this.m00=1-u-f,this.m01=l+m,this.m02=h-p,this.m03=0,this.m04=l-m,this.m05=1-c-f,this.m06=_+d,this.m07=0,this.m08=h+p,this.m09=_-d,this.m10=1-c-u,this.m11=0,this.m12=0,this.m13=0,this.m14=0,this.m15=1,this},t}(_t));Hn.IDENTITY=Object.freeze(new Hn);var Vn=new bn,Wn=new Pn;function jn(e,t,n,i,r,a,s,o,c,l,u,h,_,f,d,p){return new Hn(e,t,n,i,r,a,s,o,c,l,u,h,_,f,d,p)}$t.fastDefine("cc.Mat4",Hn,{m00:1,m01:0,m02:0,m03:0,m04:0,m05:1,m06:0,m07:0,m08:0,m09:0,m10:1,m11:0,m12:0,m13:0,m14:0,m15:1}),i.Mat4=Hn,i.mat4=jn;var qn=e("Vec2",function(e){function t(t,n){var i;return i=e.call(this)||this,t&&"object"==typeof t?(i.x=t.x,i.y=t.y):(i.x=t||0,i.y=n||0),i}X(t,e),t.clone=function(e){return new t(e.x,e.y)},t.copy=function(e,t){return e.x=t.x,e.y=t.y,e},t.set=function(e,t,n){return e.x=t,e.y=n,e},t.add=function(e,t,n){return e.x=t.x+n.x,e.y=t.y+n.y,e},t.subtract=function(e,t,n){return e.x=t.x-n.x,e.y=t.y-n.y,e},t.multiply=function(e,t,n){return e.x=t.x*n.x,e.y=t.y*n.y,e},t.divide=function(e,t,n){return e.x=t.x/n.x,e.y=t.y/n.y,e},t.ceil=function(e,t){return e.x=Math.ceil(t.x),e.y=Math.ceil(t.y),e},t.floor=function(e,t){return e.x=Math.floor(t.x),e.y=Math.floor(t.y),e},t.min=function(e,t,n){return e.x=Math.min(t.x,n.x),e.y=Math.min(t.y,n.y),e},t.max=function(e,t,n){return e.x=Math.max(t.x,n.x),e.y=Math.max(t.y,n.y),e},t.round=function(e,t){return e.x=Math.round(t.x),e.y=Math.round(t.y),e},t.multiplyScalar=function(e,t,n){return e.x=t.x*n,e.y=t.y*n,e},t.scaleAndAdd=function(e,t,n,i){return e.x=t.x+n.x*i,e.y=t.y+n.y*i,e},t.distance=function(e,t){var n=t.x-e.x,i=t.y-e.y;return Math.sqrt(n*n+i*i)},t.squaredDistance=function(e,t){var n=t.x-e.x,i=t.y-e.y;return n*n+i*i},t.len=function(e){var t=e.x,n=e.y;return Math.sqrt(t*t+n*n)},t.lengthSqr=function(e){var t=e.x,n=e.y;return t*t+n*n},t.negate=function(e,t){return e.x=-t.x,e.y=-t.y,e},t.inverse=function(e,t){return e.x=1/t.x,e.y=1/t.y,e},t.inverseSafe=function(e,t){var n=t.x,i=t.y;return Math.abs(n)0&&(r=1/Math.sqrt(r),e.x=n*r,e.y=i*r),e},t.dot=function(e,t){return e.x*t.x+e.y*t.y},t.cross=function(e,t,n){return e.x=e.y=0,e.z=t.x*n.y-t.y*n.x,e},t.lerp=function(e,t,n,i){var r=t.x,a=t.y;return e.x=r+i*(n.x-r),e.y=a+i*(n.y-a),e},t.random=function(e,t){t=t||1;var n=2*fn()*Math.PI;return e.x=Math.cos(n)*t,e.y=Math.sin(n)*t,e},t.transformMat3=function(e,t,n){var i=t.x,r=t.y;return e.x=n.m00*i+n.m03*r+n.m06,e.y=n.m01*i+n.m04*r+n.m07,e},t.transformMat4=function(e,t,n){var i=t.x,r=t.y;return e.x=n.m00*i+n.m04*r+n.m12,e.y=n.m01*i+n.m05*r+n.m13,e},t.str=function(e){return"Vec2("+e.x+", "+e.y+")"},t.toArray=function(e,t,n){return void 0===n&&(n=0),e[n+0]=t.x,e[n+1]=t.y,e},t.fromArray=function(e,t,n){return void 0===n&&(n=0),e.x=t[n+0],e.y=t[n+1],e},t.strictEquals=function(e,t){return e.x===t.x&&e.y===t.y},t.equals=function(e,t,n){return void 0===n&&(n=an),Math.abs(e.x-t.x)<=n*Math.max(1,Math.abs(e.x),Math.abs(t.x))&&Math.abs(e.y-t.y)<=n*Math.max(1,Math.abs(e.y),Math.abs(t.y))},t.angle=function(e,n){t.normalize(Xn,e),t.normalize(Yn,n);var i=t.dot(Xn,Yn);return i>1?0:i<-1?Math.PI:Math.acos(i)};var n=t.prototype;return n.clone=function(){return new t(this.x,this.y)},n.set=function(e,t){return e&&"object"==typeof e?(this.x=e.x,this.y=e.y):(this.x=e||0,this.y=t||0),this},n.equals=function(e,t){return void 0===t&&(t=an),Math.abs(this.x-e.x)<=t*Math.max(1,Math.abs(this.x),Math.abs(e.x))&&Math.abs(this.y-e.y)<=t*Math.max(1,Math.abs(this.y),Math.abs(e.y))},n.equals2f=function(e,t,n){return void 0===n&&(n=an),Math.abs(this.x-e)<=n*Math.max(1,Math.abs(this.x),Math.abs(e))&&Math.abs(this.y-t)<=n*Math.max(1,Math.abs(this.y),Math.abs(t))},n.strictEquals=function(e){return e&&this.x===e.x&&this.y===e.y},n.strictEquals2f=function(e,t){return this.x===e&&this.y===t},n.toString=function(){return"("+this.x.toFixed(2)+", "+this.y.toFixed(2)+")"},n.lerp=function(e,t){var n=this.x,i=this.y;return this.x=n+t*(e.x-n),this.y=i+t*(e.y-i),this},n.clampf=function(e,t){return this.x=cn(this.x,e.x,t.x),this.y=cn(this.y,e.y,t.y),this},n.add=function(e){return this.x+=e.x,this.y+=e.y,this},n.add2f=function(e,t){return this.x+=e,this.y+=t,this},n.subtract=function(e){return this.x-=e.x,this.y-=e.y,this},n.subtract2f=function(e,t){return this.x-=e,this.y-=t,this},n.multiplyScalar=function(e){return"object"==typeof e&&console.warn("should use Vec2.multiply for vector * vector operation"),this.x*=e,this.y*=e,this},n.multiply=function(e){return"object"!=typeof e&&console.warn("should use Vec2.scale for vector * scalar operation"),this.x*=e.x,this.y*=e.y,this},n.multiply2f=function(e,t){return this.x*=e,this.y*=t,this},n.divide=function(e){return this.x/=e.x,this.y/=e.y,this},n.divide2f=function(e,t){return this.x/=e,this.y/=t,this},n.negative=function(){return this.x=-this.x,this.y=-this.y,this},n.dot=function(e){return this.x*e.x+this.y*e.y},n.cross=function(e){return this.x*e.y-this.y*e.x},n.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},n.lengthSqr=function(){return this.x*this.x+this.y*this.y},n.normalize=function(){var e=this.x,t=this.y,n=e*e+t*t;return n>0&&(n=1/Math.sqrt(n),this.x*=n,this.y*=n),this},n.angle=function(e){var t=this.lengthSqr(),n=e.lengthSqr();if(0===t||0===n)return console.warn("Can't get angle between zero vector"),0;var i=this.dot(e)/Math.sqrt(t*n);return i=cn(i,-1,1),Math.acos(i)},n.signAngle=function(e){var t=this.angle(e);return this.cross(e)<0?-t:t},n.rotate=function(e){var t=this.x,n=this.y,i=Math.sin(e),r=Math.cos(e);return this.x=r*t-i*n,this.y=i*t+r*n,this},n.project=function(e){var t=this.dot(e)/e.dot(e);return this.x=e.x*t,this.y=e.y*t,this},n.transformMat4=function(e){var t=this.x,n=this.y;return this.x=e.m00*t+e.m04*n+e.m12,this.y=e.m01*t+e.m05*n+e.m13,this},t}(_t));qn.ZERO=Object.freeze(new qn(0,0)),qn.ONE=Object.freeze(new qn(1,1)),qn.NEG_ONE=Object.freeze(new qn(-1,-1)),qn.UNIT_X=Object.freeze(new qn(1,0)),qn.UNIT_Y=Object.freeze(new qn(0,1));var Xn=new qn,Yn=new qn;function Kn(e,t){return new qn(e,t)}$t.fastDefine("cc.Vec2",qn,{x:0,y:0}),i.Vec2=qn,i.v2=Kn;var Zn=e("Vec4",function(e){function t(t,n,i,r){var a;return a=e.call(this)||this,t&&"object"==typeof t?(a.x=t.x,a.y=t.y,a.z=t.z,a.w=t.w):(a.x=t||0,a.y=n||0,a.z=i||0,a.w=r||0),a}X(t,e),t.clone=function(e){return new t(e.x,e.y,e.z,e.w)},t.copy=function(e,t){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e},t.set=function(e,t,n,i,r){return e.x=t,e.y=n,e.z=i,e.w=r,e},t.add=function(e,t,n){return e.x=t.x+n.x,e.y=t.y+n.y,e.z=t.z+n.z,e.w=t.w+n.w,e},t.subtract=function(e,t,n){return e.x=t.x-n.x,e.y=t.y-n.y,e.z=t.z-n.z,e.w=t.w-n.w,e},t.multiply=function(e,t,n){return e.x=t.x*n.x,e.y=t.y*n.y,e.z=t.z*n.z,e.w=t.w*n.w,e},t.divide=function(e,t,n){return e.x=t.x/n.x,e.y=t.y/n.y,e.z=t.z/n.z,e.w=t.w/n.w,e},t.ceil=function(e,t){return e.x=Math.ceil(t.x),e.y=Math.ceil(t.y),e.z=Math.ceil(t.z),e.w=Math.ceil(t.w),e},t.floor=function(e,t){return e.x=Math.floor(t.x),e.y=Math.floor(t.y),e.z=Math.floor(t.z),e.w=Math.floor(t.w),e},t.min=function(e,t,n){return e.x=Math.min(t.x,n.x),e.y=Math.min(t.y,n.y),e.z=Math.min(t.z,n.z),e.w=Math.min(t.w,n.w),e},t.max=function(e,t,n){return e.x=Math.max(t.x,n.x),e.y=Math.max(t.y,n.y),e.z=Math.max(t.z,n.z),e.w=Math.max(t.w,n.w),e},t.round=function(e,t){return e.x=Math.round(t.x),e.y=Math.round(t.y),e.z=Math.round(t.z),e.w=Math.round(t.w),e},t.multiplyScalar=function(e,t,n){return e.x=t.x*n,e.y=t.y*n,e.z=t.z*n,e.w=t.w*n,e},t.scaleAndAdd=function(e,t,n,i){return e.x=t.x+n.x*i,e.y=t.y+n.y*i,e.z=t.z+n.z*i,e.w=t.w+n.w*i,e},t.distance=function(e,t){var n=t.x-e.x,i=t.y-e.y,r=t.z-e.z,a=t.w-e.w;return Math.sqrt(n*n+i*i+r*r+a*a)},t.squaredDistance=function(e,t){var n=t.x-e.x,i=t.y-e.y,r=t.z-e.z,a=t.w-e.w;return n*n+i*i+r*r+a*a},t.len=function(e){var t=e.x,n=e.y,i=e.z,r=e.w;return Math.sqrt(t*t+n*n+i*i+r*r)},t.lengthSqr=function(e){var t=e.x,n=e.y,i=e.z,r=e.w;return t*t+n*n+i*i+r*r},t.negate=function(e,t){return e.x=-t.x,e.y=-t.y,e.z=-t.z,e.w=-t.w,e},t.inverse=function(e,t){return e.x=1/t.x,e.y=1/t.y,e.z=1/t.z,e.w=1/t.w,e},t.inverseSafe=function(e,t){var n=t.x,i=t.y,r=t.z,a=t.w;return Math.abs(n)0&&(s=1/Math.sqrt(s),e.x=n*s,e.y=i*s,e.z=r*s,e.w=a*s),e},t.dot=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w},t.lerp=function(e,t,n,i){return e.x=t.x+i*(n.x-t.x),e.y=t.y+i*(n.y-t.y),e.z=t.z+i*(n.z-t.z),e.w=t.w+i*(n.w-t.w),e},t.random=function(e,t){t=t||1;var n=2*fn()*Math.PI,i=2*fn()-1,r=Math.sqrt(1-i*i);return e.x=r*Math.cos(n)*t,e.y=r*Math.sin(n)*t,e.z=i*t,e.w=0,e},t.transformMat4=function(e,t,n){var i=t.x,r=t.y,a=t.z,s=t.w;return e.x=n.m00*i+n.m04*r+n.m08*a+n.m12*s,e.y=n.m01*i+n.m05*r+n.m09*a+n.m13*s,e.z=n.m02*i+n.m06*r+n.m10*a+n.m14*s,e.w=n.m03*i+n.m07*r+n.m11*a+n.m15*s,e},t.transformAffine=function(e,t,n){var i=t.x,r=t.y,a=t.z,s=t.w;return e.x=n.m00*i+n.m01*r+n.m02*a+n.m03*s,e.y=n.m04*i+n.m05*r+n.m06*a+n.m07*s,e.x=n.m08*i+n.m09*r+n.m10*a+n.m11*s,e.w=t.w,e},t.transformQuat=function(e,t,n){var i=t.x,r=t.y,a=t.z,s=n.x,o=n.y,c=n.z,l=n.w,u=l*i+o*a-c*r,h=l*r+c*i-s*a,_=l*a+s*r-o*i,f=-s*i-o*r-c*a;return e.x=u*l+f*-s+h*-c-_*-o,e.y=h*l+f*-o+_*-s-u*-c,e.z=_*l+f*-c+u*-o-h*-s,e.w=t.w,e},t.toArray=function(e,t,n){return void 0===n&&(n=0),e[n+0]=t.x,e[n+1]=t.y,e[n+2]=t.z,e[n+3]=t.w,e},t.fromArray=function(e,t,n){return void 0===n&&(n=0),e.x=t[n+0],e.y=t[n+1],e.z=t[n+2],e.w=t[n+3],e},t.strictEquals=function(e,t){return e.x===t.x&&e.y===t.y&&e.z===t.z&&e.w===t.w},t.equals=function(e,t,n){return void 0===n&&(n=an),Math.abs(e.x-t.x)<=n*Math.max(1,Math.abs(e.x),Math.abs(t.x))&&Math.abs(e.y-t.y)<=n*Math.max(1,Math.abs(e.y),Math.abs(t.y))&&Math.abs(e.z-t.z)<=n*Math.max(1,Math.abs(e.z),Math.abs(t.z))&&Math.abs(e.w-t.w)<=n*Math.max(1,Math.abs(e.w),Math.abs(t.w))};var n=t.prototype;return n.clone=function(){return new t(this.x,this.y,this.z,this.w)},n.set=function(e,t,n,i){return e&&"object"==typeof e?(this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w):(this.x=e||0,this.y=t||0,this.z=n||0,this.w=i||0),this},n.equals=function(e,t){return void 0===t&&(t=an),Math.abs(this.x-e.x)<=t*Math.max(1,Math.abs(this.x),Math.abs(e.x))&&Math.abs(this.y-e.y)<=t*Math.max(1,Math.abs(this.y),Math.abs(e.y))&&Math.abs(this.z-e.z)<=t*Math.max(1,Math.abs(this.z),Math.abs(e.z))&&Math.abs(this.w-e.w)<=t*Math.max(1,Math.abs(this.w),Math.abs(e.w))},n.equals4f=function(e,t,n,i,r){return void 0===r&&(r=an),Math.abs(this.x-e)<=r*Math.max(1,Math.abs(this.x),Math.abs(e))&&Math.abs(this.y-t)<=r*Math.max(1,Math.abs(this.y),Math.abs(t))&&Math.abs(this.z-n)<=r*Math.max(1,Math.abs(this.z),Math.abs(n))&&Math.abs(this.w-i)<=r*Math.max(1,Math.abs(this.w),Math.abs(i))},n.strictEquals=function(e){return this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w},n.strictEquals4f=function(e,t,n,i){return this.x===e&&this.y===t&&this.z===n&&this.w===i},n.lerp=function(e,t){var n=this.x,i=this.y,r=this.z,a=this.w;return this.x=n+t*(e.x-n),this.y=i+t*(e.y-i),this.z=r+t*(e.z-r),this.w=a+t*(e.w-a),this},n.toString=function(){return"("+this.x.toFixed(2)+", "+this.y.toFixed(2)+", "+this.z.toFixed(2)+", "+this.w.toFixed(2)+")"},n.clampf=function(e,t){return this.x=cn(this.x,e.x,t.x),this.y=cn(this.y,e.y,t.y),this.z=cn(this.z,e.z,t.z),this.w=cn(this.w,e.w,t.w),this},n.add=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this},n.add4f=function(e,t,n,i){return this.x+=e,this.y+=t,this.z+=n,this.w+=i,this},n.subtract=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this},n.subtract4f=function(e,t,n,i){return this.x-=e,this.y-=t,this.z-=n,this.w-=i,this},n.multiplyScalar=function(e){return"object"==typeof e&&console.warn("should use Vec4.multiply for vector * vector operation"),this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},n.multiply=function(e){return"object"!=typeof e&&console.warn("should use Vec4.scale for vector * scalar operation"),this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this},n.multiply4f=function(e,t,n,i){return this.x*=e,this.y*=t,this.z*=n,this.w*=i,this},n.divide=function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this},n.divide4f=function(e,t,n,i){return this.x/=e,this.y/=t,this.z/=n,this.w/=i,this},n.negative=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},n.dot=function(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w},n.cross=function(e){var t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,s=e.z;return this.x=n*s-i*a,this.y=i*r-t*s,this.z=t*a-n*r,this},n.length=function(){var e=this.x,t=this.y,n=this.z,i=this.w;return Math.sqrt(e*e+t*t+n*n+i*i)},n.lengthSqr=function(){var e=this.x,t=this.y,n=this.z,i=this.w;return e*e+t*t+n*n+i*i},n.normalize=function(){var e=this.x,t=this.y,n=this.z,i=this.w,r=e*e+t*t+n*n+i*i;return r>0&&(r=1/Math.sqrt(r),this.x=e*r,this.y=t*r,this.z=n*r,this.w=i*r),this},n.transformMat4=function(e){var t=this.x,n=this.y,i=this.z,r=this.w;return this.x=e.m00*t+e.m04*n+e.m08*i+e.m12*r,this.y=e.m01*t+e.m05*n+e.m09*i+e.m13*r,this.z=e.m02*t+e.m06*n+e.m10*i+e.m14*r,this.w=e.m03*t+e.m07*n+e.m11*i+e.m15*r,this},t}(_t));function Qn(e,t,n,i){return new Zn(e,t,n,i)}Zn.ZERO=Object.freeze(new Zn(0,0,0,0)),Zn.ONE=Object.freeze(new Zn(1,1,1,1)),Zn.NEG_ONE=Object.freeze(new Zn(-1,-1,-1,-1)),$t.fastDefine("cc.Vec4",Zn,{x:0,y:0,z:0,w:0}),i.Vec4=Zn,i.v4=Qn,se(qn,"Vec2",[{name:"sub",newName:"subtract",target:qn,targetName:"Vec2"},{name:"mul",newName:"multiply",target:qn,targetName:"Vec2"},{name:"div",newName:"divide",target:qn,targetName:"Vec2"},{name:"dist",newName:"distance",target:qn,targetName:"Vec2"},{name:"sqrDist",newName:"squaredDistance",target:qn,targetName:"Vec2"},{name:"mag",newName:"len",target:qn,targetName:"Vec2"},{name:"sqrMag",newName:"lengthSqr",target:qn,targetName:"Vec2"},{name:"scale",newName:"multiplyScalar",target:qn,targetName:"Vec2"},{name:"exactEquals",newName:"strictEquals",target:qn,targetName:"Vec2"}]),se(qn.prototype,"Vec2",[{name:"mag",newName:"length",target:qn.prototype,targetName:"Vec2"},{name:"magSqr",newName:"lengthSqr",target:qn.prototype,targetName:"Vec2"},{name:"scale",newName:"multiplyScalar",target:qn.prototype,targetName:"Vec2"},{name:"exactEquals",newName:"strictEquals",target:qn.prototype,targetName:"Vec2"}]),se(bn,"Vec3",[{name:"sub",newName:"subtract",target:bn,targetName:"Vec3"},{name:"mul",newName:"multiply",target:bn,targetName:"Vec3"},{name:"div",newName:"divide",target:bn,targetName:"Vec3"},{name:"dist",newName:"distance",target:bn,targetName:"Vec3"},{name:"sqrDist",newName:"squaredDistance",target:bn,targetName:"Vec3"},{name:"mag",newName:"len",target:bn,targetName:"Vec3"},{name:"sqrMag",newName:"lengthSqr",target:bn,targetName:"Vec3"},{name:"scale",newName:"multiplyScalar",target:bn,targetName:"Vec3"},{name:"exactEquals",newName:"strictEquals",target:bn,targetName:"Vec3"}]),se(bn.prototype,"Vec3",[{name:"mag",newName:"length",target:bn.prototype,targetName:"Vec3"},{name:"magSqr",newName:"lengthSqr",target:bn.prototype,targetName:"Vec3"},{name:"scale",newName:"multiplyScalar",target:bn.prototype,targetName:"Vec3"},{name:"exactEquals",newName:"strictEquals",target:bn.prototype,targetName:"Vec3"}]),se(Zn,"Vec4",[{name:"sub",newName:"subtract",target:Zn,targetName:"Vec4"},{name:"mul",newName:"multiply",target:Zn,targetName:"Vec4"},{name:"div",newName:"divide",target:Zn,targetName:"Vec4"},{name:"dist",newName:"distance",target:Zn,targetName:"Vec4"},{name:"sqrDist",newName:"squaredDistance",target:Zn,targetName:"Vec4"},{name:"mag",newName:"len",target:Zn,targetName:"Vec4"},{name:"sqrMag",newName:"lengthSqr",target:Zn,targetName:"Vec4"},{name:"scale",newName:"multiplyScalar",target:Zn,targetName:"Vec4"},{name:"exactEquals",newName:"strictEquals",target:Zn,targetName:"Vec4"}]),se(Zn.prototype,"Vec4",[{name:"mag",newName:"length",target:Zn.prototype,targetName:"Vec4"},{name:"magSqr",newName:"lengthSqr",target:Zn.prototype,targetName:"Vec4"},{name:"scale",newName:"multiplyScalar",target:Zn.prototype,targetName:"Vec4"},{name:"exactEquals",newName:"strictEquals",target:Zn.prototype,targetName:"Vec4"}]),se(Dn,"Quat",[{name:"mag",newName:"len",target:Dn,targetName:"Quat"},{name:"mul",newName:"multiply",target:Dn,targetName:"Quat"},{name:"sqrMag",newName:"lengthSqr",target:Dn,targetName:"Quat"},{name:"scale",newName:"multiplyScalar",target:Dn,targetName:"Quat"},{name:"exactEquals",newName:"strictEquals",target:Dn,targetName:"Quat"}]),se(Dn.prototype,"Quat",[{name:"scale",newName:"multiplyScalar",target:Dn.prototype,targetName:"Quat"},{name:"exactEquals",newName:"strictEquals",target:Dn.prototype,targetName:"Quat"}]),se(Cn,"Color",[{name:"sub",newName:"subtract",target:Cn,targetName:"Color"},{name:"mul",newName:"multiply",target:Cn,targetName:"Color"},{name:"div",newName:"divide",target:Cn,targetName:"Color"},{name:"exactEquals",newName:"strictEquals",target:Cn,targetName:"Color"},{name:"fromHex",newName:"fromHEX",customFunction:function(){for(var e=arguments.length,t=new Array(e),n=0;n=e.x&&this.y<=e.y&&this.y+this.height>=e.y},n.containsRect=function(e){return this.x<=e.x&&this.x+this.width>=e.x+e.width&&this.y<=e.y&&this.y+this.height>=e.y+e.height},n.transformMat4=function(e){var t=this.x,n=this.y,i=t+this.width,r=n+this.height,a=e.m00*t+e.m04*n+e.m12,s=e.m01*t+e.m05*n+e.m13,o=e.m00*i+e.m04*n+e.m12,c=e.m01*i+e.m05*n+e.m13,l=e.m00*t+e.m04*r+e.m12,u=e.m01*t+e.m05*r+e.m13,h=e.m00*i+e.m04*r+e.m12,_=e.m01*i+e.m05*r+e.m13,f=Math.min(a,o,l,h),d=Math.max(a,o,l,h),p=Math.min(s,c,u,_),m=Math.max(s,c,u,_);return this.x=f,this.y=p,this.width=d-f,this.height=m-p,this},n.transformMat4ToPoints=function(e,t,n,i,r){var a=this.x,s=this.y,o=a+this.width,c=s+this.height;t.x=e.m00*a+e.m04*s+e.m12,t.y=e.m01*a+e.m05*s+e.m13,r.x=e.m00*o+e.m04*s+e.m12,r.y=e.m01*o+e.m05*s+e.m13,n.x=e.m00*a+e.m04*c+e.m12,n.y=e.m01*a+e.m05*c+e.m13,i.x=e.m00*o+e.m04*c+e.m12,i.y=e.m01*o+e.m05*c+e.m13},t}(_t));function ni(e,t,n,i){return void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),new ti(e,t,n,i)}$t.fastDefine("cc.Rect",ti,{x:0,y:0,width:0,height:0}),i.Rect=ti,i.rect=ni;var ii=Object.freeze({__proto__:null,bits:ae,Vec2:qn,v2:Kn,Vec3:bn,v3:On,Vec4:Zn,v4:Qn,Quat:Dn,quat:Gn,Mat3:Pn,Mat4:Hn,mat4:jn,AffineTransform:Jn,Size:$n,size:ei,Rect:ti,rect:ni,Color:Cn,color:Rn,EPSILON:an,equals:sn,approx:on,clamp:cn,clamp01:ln,lerp:un,toRadian:hn,toDegree:_n,random:fn,randomRange:dn,randomRangeInt:pn,pseudoRandom:mn,pseudoRandomRange:gn,pseudoRandomRangeInt:vn,nextPow2:yn,repeat:Sn,pingPong:En,inverseLerp:Tn,absMaxComponent:An,absMax:xn});e("math",ii);var ri,ai,si,oi,ci,li,ui,hi,_i,fi,di,pi,mi,gi,vi,yi,Si,Ei,Ti,Ai,xi,Ci,Ri,bi,wi=function(){function e(e,t,n){this._arrayBuffers=[],this._chunkSize=void 0,this._chunkSize=n*(1<>this._entryBits,i=this._entryMask&e;return(this._dataType[t]===bi.UINT32?this._uint32BufferViews:this._float32BufferViews)[n][i][t]},t.set=function(e,t,n){var i=(this._chunkMask&e)>>this._entryBits,r=this._entryMask&e;(this._dataType[t]===bi.UINT32?this._uint32BufferViews:this._float32BufferViews)[i][r][t]=n},t.setVec2=function(){},t.setVec3=function(){},t.setVec4=function(){},t.setMat4=function(){},t.free=function(e){var t=(this._chunkMask&e)>>this._entryBits,n=this._entryMask&e;(this._hasUint32?this._uint32BufferViews:this._float32BufferViews)[t][n].fill(0),this._freelists[t].push(n)},e}(),Ni=function(){function e(e,t,n){this._ctor=void 0,this._dtor=void 0,this._indexMask=void 0,this._poolFlag=void 0,this._array=[],this._freelist=[],this._nativePool=void 0,this._ctor=t,n&&(this._dtor=n),this._poolFlag=1<<29,this._indexMask=~this._poolFlag,this._nativePool=new Ii(e,this._array)}var t=e.prototype;return t.alloc=function(){for(var e=arguments.length,t=new Array(e),n=0;n=r.length){for(var s=r.length;a>=s;)s+=this._step;s*=this._viewCtor.BYTES_PER_ELEMENT;var o=new this._viewCtor(this._nativeBufferAllocator.alloc(i,s));o.set(r),r=o,this._buffers.set(i,r)}r[a]=n;var c=r[0];r[0]=a>c?a:c}},n.erase=function(e,t){var n=this._bufferIdxMask&e,i=this._buffers.get(n);if(i&&!(t>=i[0])){for(var r=t+1;r=i[0]?0:i[t+1]},n.length=function(e){var t=this._bufferIdxMask&e,n=this._buffers.get(t);return n?n[0]:0},t}(Di);function Li(e,t,n,i){void 0===i&&(i=!0);for(var r=t.length(e),a=0;aga.x?ga.x:e.x,e.y=e.y>ga.y?ga.y:e.y,e.z=e.z>ga.z?ga.z:e.z,e}function Ta(e,t,n){bn.set(_a,n.orientation.m00,n.orientation.m01,n.orientation.m02),bn.set(fa,n.orientation.m03,n.orientation.m04,n.orientation.m05),bn.set(da,n.orientation.m06,n.orientation.m07,n.orientation.m08),va[0]=_a,va[1]=fa,va[2]=da,ya[0]=n.halfExtents.x,ya[1]=n.halfExtents.y,ya[2]=n.halfExtents.z,bn.subtract(pa,t,n.center),bn.set(e,n.center.x,n.center.y,n.center.z);for(var i=0;i<3;i++){var r=bn.dot(pa,va[i]);r>ya[i]&&(r=ya[i]),r<-ya[i]&&(r=-ya[i]),e.x+=r*va[i].x,e.y+=r*va[i].y,e.z+=r*va[i].z}return e}var Aa=Object.freeze({__proto__:null,point_plane:Sa,pt_point_plane:function(e,t,n){var i=Sa(t,n);return bn.subtract(e,t,bn.multiplyScalar(e,n.n,i))},pt_point_aabb:Ea,pt_point_obb:Ta,pt_point_line:function(e,t,n,i){bn.subtract(_a,n,i);var r=_a,a=bn.lengthSqr(r);if(0==a)bn.copy(e,n);else{bn.subtract(_a,t,n);var s=bn.dot(_a,r)/a;s<0?bn.copy(e,n):s>1?bn.copy(e,i):bn.scaleAndAdd(e,n,r,s)}}}),xa={SHAPE_RAY:1,SHAPE_LINE:2,SHAPE_SPHERE:4,SHAPE_AABB:8,SHAPE_OBB:16,SHAPE_PLANE:32,SHAPE_TRIANGLE:64,SHAPE_FRUSTUM:128,SHAPE_FRUSTUM_ACCURATE:256,SHAPE_CAPSULE:512},Ca=function(){function e(e,t,n,i,r,a){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===a&&(a=-1),this.s=void 0,this.e=void 0,this._type=void 0,this._type=xa.SHAPE_LINE,this.s=new bn(e,t,n),this.e=new bn(i,r,a)}return e.create=function(t,n,i,r,a,s){return new e(t,n,i,r,a,s)},e.clone=function(t){return new e(t.s.x,t.s.y,t.s.z,t.e.x,t.e.y,t.e.z)},e.copy=function(e,t){return bn.copy(e.s,t.s),bn.copy(e.e,t.e),e},e.fromPoints=function(e,t,n){return bn.copy(e.s,t),bn.copy(e.e,n),e},e.set=function(e,t,n,i,r,a,s){return e.s.x=t,e.s.y=n,e.s.z=i,e.e.x=r,e.e.y=a,e.e.z=s,e},e.len=function(e){return bn.distance(e.s,e.e)},j(e,[{key:"type",get:function(){return this._type}}]),e.prototype.length=function(){return bn.distance(this.s,this.e)},e}(),Ra=function(){function e(e,t,n,i,r,a){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===a&&(a=-1),this.o=void 0,this.d=void 0,this._type=void 0,this._type=xa.SHAPE_RAY,this.o=new bn(e,t,n),this.d=new bn(i,r,a)}return e.create=function(t,n,i,r,a,s){return void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===a&&(a=0),void 0===s&&(s=1),new e(t,n,i,r,a,s)},e.clone=function(t){return new e(t.o.x,t.o.y,t.o.z,t.d.x,t.d.y,t.d.z)},e.copy=function(e,t){return bn.copy(e.o,t.o),bn.copy(e.d,t.d),e},e.fromPoints=function(e,t,n){return bn.copy(e.o,t),bn.normalize(e.d,bn.subtract(e.d,n,t)),e},e.set=function(e,t,n,i,r,a,s){return e.o.x=t,e.o.y=n,e.o.z=i,e.d.x=r,e.d.y=a,e.d.z=s,e},j(e,[{key:"type",get:function(){return this._type}}]),e.prototype.computeHit=function(e,t){bn.normalize(e,this.d),bn.scaleAndAdd(e,this.o,e,t)},e}(),ba=new bn,wa=new bn,Ia=new bn,Oa=new bn;function Pa(e){return Math.max(Math.max(e.x,e.y),e.z)}var Ma,Na=function(){function e(e,t,n,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=1),this._center=new bn(0,0,0),this._poolHandle=0,this._type=void 0,this._type=xa.SHAPE_SPHERE,this._center=new bn(e,t,n),this._poolHandle=Yr.alloc(),Yr.setVec3(this._poolHandle,Vr.CENTER,this._center),Yr.set(this._poolHandle,Vr.RADIUS,i)}e.create=function(t,n,i,r){return new e(t,n,i,r)},e.clone=function(t){return new e(t.center.x,t.center.y,t.center.z,t.radius)},e.copy=function(e,t){return bn.copy(e.center,t.center),e.radius=t.radius,e},e.fromPoints=function(e,t,n){return bn.multiplyScalar(e.center,bn.add(ba,t,n),.5),e.radius=.5*bn.subtract(ba,n,t).length(),e},e.set=function(e,t,n,i,r){return e.center.x=t,e.center.y=n,e.center.z=i,e.radius=r,e},e.mergePoint=function(e,t,n){if(t.radius<0)return e.center.set(n),e.radius=0,e;bn.subtract(wa,n,t.center);var i=wa.length();if(i>t.radius){var r=.5*(i-t.radius);e.radius+=r,bn.multiplyScalar(wa,wa,r/i),bn.add(e.center,e.center,wa)}return e},e.mergeAABB=function(t,n,i){return i.getBoundary(Ia,Oa),e.mergePoint(t,n,Ia),e.mergePoint(t,n,Oa),t},j(e,[{key:"center",get:function(){return this._center},set:function(e){this._center=e,Yr.setVec3(this._poolHandle,Vr.CENTER,this._center)}},{key:"radius",get:function(){return Yr.get(this._poolHandle,Vr.RADIUS)},set:function(e){Yr.set(this._poolHandle,Vr.RADIUS,e)}},{key:"handle",get:function(){return this._poolHandle}},{key:"type",get:function(){return this._type}}]);var t=e.prototype;return t.destroy=function(){this._poolHandle&&(Yr.free(this._poolHandle),this._poolHandle=0)},t.clone=function(){return e.clone(this)},t.copy=function(t){return e.copy(this,t)},t.getBoundary=function(e,t){bn.set(e,this.center.x-this.radius,this.center.y-this.radius,this.center.z-this.radius),bn.set(t,this.center.x+this.radius,this.center.y+this.radius,this.center.z+this.radius)},t.transform=function(e,t,n,i,r){bn.transformMat4(r.center,this.center,e),r.radius=this.radius*Pa(i)},t.translateAndRotate=function(e,t,n){bn.transformMat4(n.center,this.center,e)},t.setScale=function(e,t){t.radius=this.radius*Pa(e)},e}(),Da=function(){function e(e,t,n,i,r,a,s,o,c){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=1),void 0===r&&(r=0),void 0===a&&(a=0),void 0===s&&(s=0),void 0===o&&(o=1),void 0===c&&(c=0),this.a=void 0,this.b=void 0,this.c=void 0,this._type=void 0,this._type=xa.SHAPE_TRIANGLE,this.a=new bn(e,t,n),this.b=new bn(i,r,a),this.c=new bn(s,o,c)}return e.create=function(t,n,i,r,a,s,o,c,l){return void 0===t&&(t=1),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===a&&(a=0),void 0===s&&(s=0),void 0===o&&(o=0),void 0===c&&(c=0),void 0===l&&(l=1),new e(t,n,i,r,a,s,o,c,l)},e.clone=function(t){return new e(t.a.x,t.a.y,t.a.z,t.b.x,t.b.y,t.b.z,t.c.x,t.c.y,t.c.z)},e.copy=function(e,t){return bn.copy(e.a,t.a),bn.copy(e.b,t.b),bn.copy(e.c,t.c),e},e.fromPoints=function(e,t,n,i){return bn.copy(e.a,t),bn.copy(e.b,n),bn.copy(e.c,i),e},e.set=function(e,t,n,i,r,a,s,o,c,l){return e.a.x=t,e.a.y=n,e.a.z=i,e.b.x=r,e.b.y=a,e.b.z=s,e.c.x=o,e.c.y=c,e.c.z=l,e},j(e,[{key:"type",get:function(){return this._type}}]),e}(),Ba=e("GFX_MAX_ATTACHMENTS",4);!function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.BUFFER=1]="BUFFER",e[e.TEXTURE=2]="TEXTURE",e[e.RENDER_PASS=3]="RENDER_PASS",e[e.FRAMEBUFFER=4]="FRAMEBUFFER",e[e.SAMPLER=5]="SAMPLER",e[e.SHADER=6]="SHADER",e[e.DESCRIPTOR_SET_LAYOUT=7]="DESCRIPTOR_SET_LAYOUT",e[e.PIPELINE_LAYOUT=8]="PIPELINE_LAYOUT",e[e.PIPELINE_STATE=9]="PIPELINE_STATE",e[e.DESCRIPTOR_SET=10]="DESCRIPTOR_SET",e[e.INPUT_ASSEMBLER=11]="INPUT_ASSEMBLER",e[e.COMMAND_BUFFER=12]="COMMAND_BUFFER",e[e.FENCE=13]="FENCE",e[e.QUEUE=14]="QUEUE",e[e.WINDOW=15]="WINDOW"}(Ma||(Ma=e("GFXObjectType",{})));var La,Fa,za,Ua,Ga,ka,Ha,Va,Wa,ja,qa,Xa,Ya,Ka,Za,Qa,Ja,$a,es,ts,ns,is,rs,as,ss,os,cs,ls,us,hs,_s,fs,ds,ps,ms,gs,vs,ys=e("GFXObject",function(){function e(e){this._gfxType=Ma.UNKNOWN,this._gfxType=e}return j(e,[{key:"gfxType",get:function(){return this._gfxType}}]),e}());!function(e){e.ATTR_POSITION="a_position",e.ATTR_NORMAL="a_normal",e.ATTR_TANGENT="a_tangent",e.ATTR_BITANGENT="a_bitangent",e.ATTR_WEIGHTS="a_weights",e.ATTR_JOINTS="a_joints",e.ATTR_COLOR="a_color",e.ATTR_COLOR1="a_color1",e.ATTR_COLOR2="a_color2",e.ATTR_TEX_COORD="a_texCoord",e.ATTR_TEX_COORD1="a_texCoord1",e.ATTR_TEX_COORD2="a_texCoord2",e.ATTR_TEX_COORD3="a_texCoord3",e.ATTR_TEX_COORD4="a_texCoord4",e.ATTR_TEX_COORD5="a_texCoord5",e.ATTR_TEX_COORD6="a_texCoord6",e.ATTR_TEX_COORD7="a_texCoord7",e.ATTR_TEX_COORD8="a_texCoord8",e.ATTR_BATCH_ID="a_batch_id",e.ATTR_BATCH_UV="a_batch_uv"}(La||(La=e("GFXAttributeName",{}))),function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.BOOL=1]="BOOL",e[e.BOOL2=2]="BOOL2",e[e.BOOL3=3]="BOOL3",e[e.BOOL4=4]="BOOL4",e[e.INT=5]="INT",e[e.INT2=6]="INT2",e[e.INT3=7]="INT3",e[e.INT4=8]="INT4",e[e.UINT=9]="UINT",e[e.UINT2=10]="UINT2",e[e.UINT3=11]="UINT3",e[e.UINT4=12]="UINT4",e[e.FLOAT=13]="FLOAT",e[e.FLOAT2=14]="FLOAT2",e[e.FLOAT3=15]="FLOAT3",e[e.FLOAT4=16]="FLOAT4",e[e.MAT2=17]="MAT2",e[e.MAT2X3=18]="MAT2X3",e[e.MAT2X4=19]="MAT2X4",e[e.MAT3X2=20]="MAT3X2",e[e.MAT3=21]="MAT3",e[e.MAT3X4=22]="MAT3X4",e[e.MAT4X2=23]="MAT4X2",e[e.MAT4X3=24]="MAT4X3",e[e.MAT4=25]="MAT4",e[e.SAMPLER1D=26]="SAMPLER1D",e[e.SAMPLER1D_ARRAY=27]="SAMPLER1D_ARRAY",e[e.SAMPLER2D=28]="SAMPLER2D",e[e.SAMPLER2D_ARRAY=29]="SAMPLER2D_ARRAY",e[e.SAMPLER3D=30]="SAMPLER3D",e[e.SAMPLER_CUBE=31]="SAMPLER_CUBE",e[e.COUNT=32]="COUNT"}(Fa||(Fa=e("GFXType",{}))),function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.A8=1]="A8",e[e.L8=2]="L8",e[e.LA8=3]="LA8",e[e.R8=4]="R8",e[e.R8SN=5]="R8SN",e[e.R8UI=6]="R8UI",e[e.R8I=7]="R8I",e[e.R16F=8]="R16F",e[e.R16UI=9]="R16UI",e[e.R16I=10]="R16I",e[e.R32F=11]="R32F",e[e.R32UI=12]="R32UI",e[e.R32I=13]="R32I",e[e.RG8=14]="RG8",e[e.RG8SN=15]="RG8SN",e[e.RG8UI=16]="RG8UI",e[e.RG8I=17]="RG8I",e[e.RG16F=18]="RG16F",e[e.RG16UI=19]="RG16UI",e[e.RG16I=20]="RG16I",e[e.RG32F=21]="RG32F",e[e.RG32UI=22]="RG32UI",e[e.RG32I=23]="RG32I",e[e.RGB8=24]="RGB8",e[e.SRGB8=25]="SRGB8",e[e.RGB8SN=26]="RGB8SN",e[e.RGB8UI=27]="RGB8UI",e[e.RGB8I=28]="RGB8I",e[e.RGB16F=29]="RGB16F",e[e.RGB16UI=30]="RGB16UI",e[e.RGB16I=31]="RGB16I",e[e.RGB32F=32]="RGB32F",e[e.RGB32UI=33]="RGB32UI",e[e.RGB32I=34]="RGB32I",e[e.RGBA8=35]="RGBA8",e[e.BGRA8=36]="BGRA8",e[e.SRGB8_A8=37]="SRGB8_A8",e[e.RGBA8SN=38]="RGBA8SN",e[e.RGBA8UI=39]="RGBA8UI",e[e.RGBA8I=40]="RGBA8I",e[e.RGBA16F=41]="RGBA16F",e[e.RGBA16UI=42]="RGBA16UI",e[e.RGBA16I=43]="RGBA16I",e[e.RGBA32F=44]="RGBA32F",e[e.RGBA32UI=45]="RGBA32UI",e[e.RGBA32I=46]="RGBA32I",e[e.R5G6B5=47]="R5G6B5",e[e.R11G11B10F=48]="R11G11B10F",e[e.RGB5A1=49]="RGB5A1",e[e.RGBA4=50]="RGBA4",e[e.RGB10A2=51]="RGB10A2",e[e.RGB10A2UI=52]="RGB10A2UI",e[e.RGB9E5=53]="RGB9E5",e[e.D16=54]="D16",e[e.D16S8=55]="D16S8",e[e.D24=56]="D24",e[e.D24S8=57]="D24S8",e[e.D32F=58]="D32F",e[e.D32F_S8=59]="D32F_S8",e[e.BC1=60]="BC1",e[e.BC1_ALPHA=61]="BC1_ALPHA",e[e.BC1_SRGB=62]="BC1_SRGB",e[e.BC1_SRGB_ALPHA=63]="BC1_SRGB_ALPHA",e[e.BC2=64]="BC2",e[e.BC2_SRGB=65]="BC2_SRGB",e[e.BC3=66]="BC3",e[e.BC3_SRGB=67]="BC3_SRGB",e[e.BC4=68]="BC4",e[e.BC4_SNORM=69]="BC4_SNORM",e[e.BC5=70]="BC5",e[e.BC5_SNORM=71]="BC5_SNORM",e[e.BC6H_UF16=72]="BC6H_UF16",e[e.BC6H_SF16=73]="BC6H_SF16",e[e.BC7=74]="BC7",e[e.BC7_SRGB=75]="BC7_SRGB",e[e.ETC_RGB8=76]="ETC_RGB8",e[e.ETC2_RGB8=77]="ETC2_RGB8",e[e.ETC2_SRGB8=78]="ETC2_SRGB8",e[e.ETC2_RGB8_A1=79]="ETC2_RGB8_A1",e[e.ETC2_SRGB8_A1=80]="ETC2_SRGB8_A1",e[e.ETC2_RGBA8=81]="ETC2_RGBA8",e[e.ETC2_SRGB8_A8=82]="ETC2_SRGB8_A8",e[e.EAC_R11=83]="EAC_R11",e[e.EAC_R11SN=84]="EAC_R11SN",e[e.EAC_RG11=85]="EAC_RG11",e[e.EAC_RG11SN=86]="EAC_RG11SN",e[e.PVRTC_RGB2=87]="PVRTC_RGB2",e[e.PVRTC_RGBA2=88]="PVRTC_RGBA2",e[e.PVRTC_RGB4=89]="PVRTC_RGB4",e[e.PVRTC_RGBA4=90]="PVRTC_RGBA4",e[e.PVRTC2_2BPP=91]="PVRTC2_2BPP",e[e.PVRTC2_4BPP=92]="PVRTC2_4BPP",e[e.ASTC_RGBA_4x4=93]="ASTC_RGBA_4x4",e[e.ASTC_RGBA_5x4=94]="ASTC_RGBA_5x4",e[e.ASTC_RGBA_5x5=95]="ASTC_RGBA_5x5",e[e.ASTC_RGBA_6x5=96]="ASTC_RGBA_6x5",e[e.ASTC_RGBA_6x6=97]="ASTC_RGBA_6x6",e[e.ASTC_RGBA_8x5=98]="ASTC_RGBA_8x5",e[e.ASTC_RGBA_8x6=99]="ASTC_RGBA_8x6",e[e.ASTC_RGBA_8x8=100]="ASTC_RGBA_8x8",e[e.ASTC_RGBA_10x5=101]="ASTC_RGBA_10x5",e[e.ASTC_RGBA_10x6=102]="ASTC_RGBA_10x6",e[e.ASTC_RGBA_10x8=103]="ASTC_RGBA_10x8",e[e.ASTC_RGBA_10x10=104]="ASTC_RGBA_10x10",e[e.ASTC_RGBA_12x10=105]="ASTC_RGBA_12x10",e[e.ASTC_RGBA_12x12=106]="ASTC_RGBA_12x12",e[e.ASTC_SRGBA_4x4=107]="ASTC_SRGBA_4x4",e[e.ASTC_SRGBA_5x4=108]="ASTC_SRGBA_5x4",e[e.ASTC_SRGBA_5x5=109]="ASTC_SRGBA_5x5",e[e.ASTC_SRGBA_6x5=110]="ASTC_SRGBA_6x5",e[e.ASTC_SRGBA_6x6=111]="ASTC_SRGBA_6x6",e[e.ASTC_SRGBA_8x5=112]="ASTC_SRGBA_8x5",e[e.ASTC_SRGBA_8x6=113]="ASTC_SRGBA_8x6",e[e.ASTC_SRGBA_8x8=114]="ASTC_SRGBA_8x8",e[e.ASTC_SRGBA_10x5=115]="ASTC_SRGBA_10x5",e[e.ASTC_SRGBA_10x6=116]="ASTC_SRGBA_10x6",e[e.ASTC_SRGBA_10x8=117]="ASTC_SRGBA_10x8",e[e.ASTC_SRGBA_10x10=118]="ASTC_SRGBA_10x10",e[e.ASTC_SRGBA_12x10=119]="ASTC_SRGBA_12x10",e[e.ASTC_SRGBA_12x12=120]="ASTC_SRGBA_12x12"}(za||(za=e("GFXFormat",{}))),function(e){e[e.NONE=0]="NONE",e[e.TRANSFER_SRC=1]="TRANSFER_SRC",e[e.TRANSFER_DST=2]="TRANSFER_DST",e[e.INDEX=4]="INDEX",e[e.VERTEX=8]="VERTEX",e[e.UNIFORM=16]="UNIFORM",e[e.STORAGE=32]="STORAGE",e[e.INDIRECT=64]="INDIRECT"}(Ua||(Ua=e("GFXBufferUsageBit",{}))),function(e){e[e.NONE=0]="NONE",e[e.DEVICE=1]="DEVICE",e[e.HOST=2]="HOST"}(Ga||(Ga=e("GFXMemoryUsageBit",{}))),function(e){e[e.NONE=0]="NONE",e[e.BAKUP_BUFFER=4]="BAKUP_BUFFER"}(ka||(ka=e("GFXBufferFlagBit",{}))),function(e){e[e.NONE=0]="NONE",e[e.READ=1]="READ",e[e.WRITE=2]="WRITE"}(Ha||(Ha=e("GFXBufferAccessBit",{}))),function(e){e[e.POINT_LIST=0]="POINT_LIST",e[e.LINE_LIST=1]="LINE_LIST",e[e.LINE_STRIP=2]="LINE_STRIP",e[e.LINE_LOOP=3]="LINE_LOOP",e[e.LINE_LIST_ADJACENCY=4]="LINE_LIST_ADJACENCY",e[e.LINE_STRIP_ADJACENCY=5]="LINE_STRIP_ADJACENCY",e[e.ISO_LINE_LIST=6]="ISO_LINE_LIST",e[e.TRIANGLE_LIST=7]="TRIANGLE_LIST",e[e.TRIANGLE_STRIP=8]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=9]="TRIANGLE_FAN",e[e.TRIANGLE_LIST_ADJACENCY=10]="TRIANGLE_LIST_ADJACENCY",e[e.TRIANGLE_STRIP_ADJACENCY=11]="TRIANGLE_STRIP_ADJACENCY",e[e.TRIANGLE_PATCH_ADJACENCY=12]="TRIANGLE_PATCH_ADJACENCY",e[e.QUAD_PATCH_LIST=13]="QUAD_PATCH_LIST"}(Va||(Va=e("GFXPrimitiveMode",{}))),function(e){e[e.FILL=0]="FILL",e[e.POINT=1]="POINT",e[e.LINE=2]="LINE"}(Wa||(Wa=e("GFXPolygonMode",{}))),function(e){e[e.GOURAND=0]="GOURAND",e[e.FLAT=1]="FLAT"}(ja||(ja=e("GFXShadeModel",{}))),function(e){e[e.NONE=0]="NONE",e[e.FRONT=1]="FRONT",e[e.BACK=2]="BACK"}(qa||(qa=e("GFXCullMode",{}))),function(e){e[e.NEVER=0]="NEVER",e[e.LESS=1]="LESS",e[e.EQUAL=2]="EQUAL",e[e.LESS_EQUAL=3]="LESS_EQUAL",e[e.GREATER=4]="GREATER",e[e.NOT_EQUAL=5]="NOT_EQUAL",e[e.GREATER_EQUAL=6]="GREATER_EQUAL",e[e.ALWAYS=7]="ALWAYS"}(Xa||(Xa=e("GFXComparisonFunc",{}))),function(e){e[e.ZERO=0]="ZERO",e[e.KEEP=1]="KEEP",e[e.REPLACE=2]="REPLACE",e[e.INCR=3]="INCR",e[e.DECR=4]="DECR",e[e.INVERT=5]="INVERT",e[e.INCR_WRAP=6]="INCR_WRAP",e[e.DECR_WRAP=7]="DECR_WRAP"}(Ya||(Ya=e("GFXStencilOp",{}))),function(e){e[e.ADD=0]="ADD",e[e.SUB=1]="SUB",e[e.REV_SUB=2]="REV_SUB",e[e.MIN=3]="MIN",e[e.MAX=4]="MAX"}(Ka||(Ka=e("GFXBlendOp",{}))),function(e){e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_ALPHA=2]="SRC_ALPHA",e[e.DST_ALPHA=3]="DST_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=4]="ONE_MINUS_SRC_ALPHA",e[e.ONE_MINUS_DST_ALPHA=5]="ONE_MINUS_DST_ALPHA",e[e.SRC_COLOR=6]="SRC_COLOR",e[e.DST_COLOR=7]="DST_COLOR",e[e.ONE_MINUS_SRC_COLOR=8]="ONE_MINUS_SRC_COLOR",e[e.ONE_MINUS_DST_COLOR=9]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA_SATURATE=10]="SRC_ALPHA_SATURATE",e[e.CONSTANT_COLOR=11]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=12]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=13]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=14]="ONE_MINUS_CONSTANT_ALPHA"}(Za||(Za=e("GFXBlendFactor",{}))),function(e){e[e.NONE=0]="NONE",e[e.R=1]="R",e[e.G=2]="G",e[e.B=4]="B",e[e.A=8]="A",e[e.ALL=15]="ALL"}(Qa||(Qa=e("GFXColorMask",{}))),function(e){e[e.NONE=0]="NONE",e[e.POINT=1]="POINT",e[e.LINEAR=2]="LINEAR",e[e.ANISOTROPIC=3]="ANISOTROPIC"}(Ja||(Ja=e("GFXFilter",{}))),function(e){e[e.WRAP=0]="WRAP",e[e.MIRROR=1]="MIRROR",e[e.CLAMP=2]="CLAMP",e[e.BORDER=3]="BORDER"}($a||($a=e("GFXAddress",{}))),function(e){e[e.TEX1D=0]="TEX1D",e[e.TEX2D=1]="TEX2D",e[e.TEX3D=2]="TEX3D",e[e.CUBE=3]="CUBE",e[e.TEX1D_ARRAY=4]="TEX1D_ARRAY",e[e.TEX2D_ARRAY=5]="TEX2D_ARRAY"}(es||(es=e("GFXTextureType",{}))),function(e){e[e.NONE=0]="NONE",e[e.TRANSFER_SRC=1]="TRANSFER_SRC",e[e.TRANSFER_DST=2]="TRANSFER_DST",e[e.SAMPLED=4]="SAMPLED",e[e.STORAGE=8]="STORAGE",e[e.COLOR_ATTACHMENT=16]="COLOR_ATTACHMENT",e[e.DEPTH_STENCIL_ATTACHMENT=32]="DEPTH_STENCIL_ATTACHMENT",e[e.TRANSIENT_ATTACHMENT=64]="TRANSIENT_ATTACHMENT",e[e.INPUT_ATTACHMENT=128]="INPUT_ATTACHMENT"}(ts||(ts=e("GFXTextureUsageBit",{}))),function(e){e[e.X1=0]="X1",e[e.X2=1]="X2",e[e.X4=2]="X4",e[e.X8=3]="X8",e[e.X16=4]="X16",e[e.X32=5]="X32",e[e.X64=6]="X64"}(ns||(ns=e("GFXSampleCount",{}))),function(e){e[e.NONE=0]="NONE",e[e.GEN_MIPMAP=1]="GEN_MIPMAP",e[e.CUBEMAP=2]="CUBEMAP",e[e.BAKUP_BUFFER=4]="BAKUP_BUFFER",e[e.IMMUTABLE=8]="IMMUTABLE"}(is||(is=e("GFXTextureFlagBit",{}))),function(e){e[e.NONE=0]="NONE",e[e.VERTEX=1]="VERTEX",e[e.CONTROL=2]="CONTROL",e[e.EVALUATION=4]="EVALUATION",e[e.GEOMETRY=8]="GEOMETRY",e[e.FRAGMENT=16]="FRAGMENT",e[e.COMPUTE=32]="COMPUTE",e[e.ALL=63]="ALL"}(rs||(rs=e("GFXShaderStageFlagBit",{}))),function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.UNIFORM_BUFFER=1]="UNIFORM_BUFFER",e[e.DYNAMIC_UNIFORM_BUFFER=2]="DYNAMIC_UNIFORM_BUFFER",e[e.STORAGE_BUFFER=4]="STORAGE_BUFFER",e[e.DYNAMIC_STORAGE_BUFFER=8]="DYNAMIC_STORAGE_BUFFER",e[e.SAMPLER=16]="SAMPLER"}(as||(as=e("GFXDescriptorType",{}))),function(e){e[e.PRIMARY=0]="PRIMARY",e[e.SECONDARY=1]="SECONDARY"}(ss||(ss=e("GFXCommandBufferType",{}))),function(e){e[e.LOAD=0]="LOAD",e[e.CLEAR=1]="CLEAR",e[e.DISCARD=2]="DISCARD"}(os||(os=e("GFXLoadOp",{}))),function(e){e[e.STORE=0]="STORE",e[e.DISCARD=1]="DISCARD"}(cs||(cs=e("GFXStoreOp",{}))),function(e){e[e.UNDEFINED=0]="UNDEFINED",e[e.GENERAL=1]="GENERAL",e[e.COLOR_ATTACHMENT_OPTIMAL=2]="COLOR_ATTACHMENT_OPTIMAL",e[e.DEPTH_STENCIL_ATTACHMENT_OPTIMAL=3]="DEPTH_STENCIL_ATTACHMENT_OPTIMAL",e[e.DEPTH_STENCIL_READONLY_OPTIMAL=4]="DEPTH_STENCIL_READONLY_OPTIMAL",e[e.SHADER_READONLY_OPTIMAL=5]="SHADER_READONLY_OPTIMAL",e[e.TRANSFER_SRC_OPTIMAL=6]="TRANSFER_SRC_OPTIMAL",e[e.TRANSFER_DST_OPTIMAL=7]="TRANSFER_DST_OPTIMAL",e[e.PREINITIALIZED=8]="PREINITIALIZED",e[e.PRESENT_SRC=9]="PRESENT_SRC"}(ls||(ls=e("GFXTextureLayout",{}))),function(e){e[e.GRAPHICS=0]="GRAPHICS",e[e.COMPUTE=1]="COMPUTE",e[e.RAY_TRACING=2]="RAY_TRACING"}(us||(us=e("GFXPipelineBindPoint",{}))),function(e){e[e.NONE=0]="NONE",e[e.VIEWPORT=1]="VIEWPORT",e[e.SCISSOR=2]="SCISSOR",e[e.LINE_WIDTH=4]="LINE_WIDTH",e[e.DEPTH_BIAS=8]="DEPTH_BIAS",e[e.BLEND_CONSTANTS=16]="BLEND_CONSTANTS",e[e.DEPTH_BOUNDS=32]="DEPTH_BOUNDS",e[e.STENCIL_WRITE_MASK=64]="STENCIL_WRITE_MASK",e[e.STENCIL_COMPARE_MASK=128]="STENCIL_COMPARE_MASK"}(hs||(hs=e("GFXDynamicStateFlagBit",{}))),function(e){e[e.FRONT=0]="FRONT",e[e.BACK=1]="BACK",e[e.ALL=2]="ALL"}(_s||(_s=e("GFXStencilFace",{}))),function(e){e[e.GRAPHICS=0]="GRAPHICS",e[e.COMPUTE=1]="COMPUTE",e[e.TRANSFER=2]="TRANSFER"}(fs||(fs=e("GFXQueueType",{}))),function(e){e[e.NONE=0]="NONE",e[e.COLOR=1]="COLOR",e[e.DEPTH=2]="DEPTH",e[e.STENCIL=4]="STENCIL",e[e.DEPTH_STENCIL=6]="DEPTH_STENCIL",e[e.ALL=7]="ALL"}(ds||(ds=e("GFXClearFlag",{}))),function(e){e[e.NONE=0]="NONE",e[e.UNORM=1]="UNORM",e[e.SNORM=2]="SNORM",e[e.UINT=3]="UINT",e[e.INT=4]="INT",e[e.UFLOAT=5]="UFLOAT",e[e.FLOAT=6]="FLOAT"}(ps||(ps=e("GFXFormatType",{}))),function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.GLES2=1]="GLES2",e[e.GLES3=2]="GLES3",e[e.METAL=3]="METAL",e[e.VULKAN=4]="VULKAN",e[e.WEBGL=5]="WEBGL",e[e.WEBGL2=6]="WEBGL2",e[e.WEBGPU=7]="WEBGPU"}(ms||(ms=e("GFXAPI",{}))),function(e){e[e.IDENTITY=0]="IDENTITY",e[e.ROTATE_90=1]="ROTATE_90",e[e.ROTATE_180=2]="ROTATE_180",e[e.ROTATE_270=3]="ROTATE_270"}(gs||(gs=e("GFXSurfaceTransform",{}))),function(e){e[e.COLOR_FLOAT=0]="COLOR_FLOAT",e[e.COLOR_HALF_FLOAT=1]="COLOR_HALF_FLOAT",e[e.TEXTURE_FLOAT=2]="TEXTURE_FLOAT",e[e.TEXTURE_HALF_FLOAT=3]="TEXTURE_HALF_FLOAT",e[e.TEXTURE_FLOAT_LINEAR=4]="TEXTURE_FLOAT_LINEAR",e[e.TEXTURE_HALF_FLOAT_LINEAR=5]="TEXTURE_HALF_FLOAT_LINEAR",e[e.FORMAT_R11G11B10F=6]="FORMAT_R11G11B10F",e[e.FORMAT_D16=7]="FORMAT_D16",e[e.FORMAT_D16S8=8]="FORMAT_D16S8",e[e.FORMAT_D24=9]="FORMAT_D24",e[e.FORMAT_D24S8=10]="FORMAT_D24S8",e[e.FORMAT_D32F=11]="FORMAT_D32F",e[e.FORMAT_D32FS8=12]="FORMAT_D32FS8",e[e.FORMAT_ETC1=13]="FORMAT_ETC1",e[e.FORMAT_ETC2=14]="FORMAT_ETC2",e[e.FORMAT_DXT=15]="FORMAT_DXT",e[e.FORMAT_PVRTC=16]="FORMAT_PVRTC",e[e.FORMAT_ASTC=17]="FORMAT_ASTC",e[e.FORMAT_RGB8=18]="FORMAT_RGB8",e[e.MSAA=19]="MSAA",e[e.ELEMENT_INDEX_UINT=20]="ELEMENT_INDEX_UINT",e[e.INSTANCED_ARRAYS=21]="INSTANCED_ARRAYS",e[e.MULTIPLE_RENDER_TARGETS=22]="MULTIPLE_RENDER_TARGETS",e[e.BLEND_MINMAX=23]="BLEND_MINMAX",e[e.DEPTH_BOUNDS=24]="DEPTH_BOUNDS",e[e.LINE_WIDTH=25]="LINE_WIDTH",e[e.STENCIL_WRITE_MASK=26]="STENCIL_WRITE_MASK",e[e.STENCIL_COMPARE_MASK=27]="STENCIL_COMPARE_MASK",e[e.COUNT=28]="COUNT"}(vs||(vs=e("GFXFeature",{})));var Ss=e("GFXFormatInfo",(function(e,t,n,i,r,a,s,o){this.name=e,this.size=t,this.count=n,this.type=i,this.hasAlpha=r,this.hasDepth=a,this.hasStencil=s,this.isCompressed=o})),Es=e("GFXMemoryStatus",(function(e,t){void 0===e&&(e=0),void 0===t&&(t=0),this.bufferSize=e,this.textureSize=t})),Ts=e("GFXFormatInfos",Object.freeze([new Ss("UNKNOWN",0,0,ps.NONE,!1,!1,!1,!1),new Ss("A8",1,1,ps.UNORM,!0,!1,!1,!1),new Ss("L8",1,1,ps.UNORM,!1,!1,!1,!1),new Ss("LA8",1,2,ps.UNORM,!0,!1,!1,!1),new Ss("R8",1,1,ps.UNORM,!1,!1,!1,!1),new Ss("R8SN",1,1,ps.SNORM,!1,!1,!1,!1),new Ss("R8UI",1,1,ps.UINT,!1,!1,!1,!1),new Ss("R8I",1,1,ps.INT,!1,!1,!1,!1),new Ss("R16F",2,1,ps.FLOAT,!1,!1,!1,!1),new Ss("R16UI",2,1,ps.UINT,!1,!1,!1,!1),new Ss("R16I",2,1,ps.INT,!1,!1,!1,!1),new Ss("R32F",4,1,ps.FLOAT,!1,!1,!1,!1),new Ss("R32UI",4,1,ps.UINT,!1,!1,!1,!1),new Ss("R32I",4,1,ps.INT,!1,!1,!1,!1),new Ss("RG8",2,2,ps.UNORM,!1,!1,!1,!1),new Ss("RG8SN",2,2,ps.SNORM,!1,!1,!1,!1),new Ss("RG8UI",2,2,ps.UINT,!1,!1,!1,!1),new Ss("RG8I",2,2,ps.INT,!1,!1,!1,!1),new Ss("RG16F",4,2,ps.FLOAT,!1,!1,!1,!1),new Ss("RG16UI",4,2,ps.UINT,!1,!1,!1,!1),new Ss("RG16I",4,2,ps.INT,!1,!1,!1,!1),new Ss("RG32F",8,2,ps.FLOAT,!1,!1,!1,!1),new Ss("RG32UI",8,2,ps.UINT,!1,!1,!1,!1),new Ss("RG32I",8,2,ps.INT,!1,!1,!1,!1),new Ss("RGB8",3,3,ps.UNORM,!1,!1,!1,!1),new Ss("SRGB8",3,3,ps.UNORM,!1,!1,!1,!1),new Ss("RGB8SN",3,3,ps.SNORM,!1,!1,!1,!1),new Ss("RGB8UI",3,3,ps.UINT,!1,!1,!1,!1),new Ss("RGB8I",3,3,ps.INT,!1,!1,!1,!1),new Ss("RGB16F",6,3,ps.FLOAT,!1,!1,!1,!1),new Ss("RGB16UI",6,3,ps.UINT,!1,!1,!1,!1),new Ss("RGB16I",6,3,ps.INT,!1,!1,!1,!1),new Ss("RGB32F",12,3,ps.FLOAT,!1,!1,!1,!1),new Ss("RGB32UI",12,3,ps.UINT,!1,!1,!1,!1),new Ss("RGB32I",12,3,ps.INT,!1,!1,!1,!1),new Ss("RGBA8",4,4,ps.UNORM,!0,!1,!1,!1),new Ss("BGRA8",4,4,ps.UNORM,!0,!1,!1,!1),new Ss("SRGB8_A8",4,4,ps.UNORM,!0,!1,!1,!1),new Ss("RGBA8SN",4,4,ps.SNORM,!0,!1,!1,!1),new Ss("RGBA8UI",4,4,ps.UINT,!0,!1,!1,!1),new Ss("RGBA8I",4,4,ps.INT,!0,!1,!1,!1),new Ss("RGBA16F",8,4,ps.FLOAT,!0,!1,!1,!1),new Ss("RGBA16UI",8,4,ps.UINT,!0,!1,!1,!1),new Ss("RGBA16I",8,4,ps.INT,!0,!1,!1,!1),new Ss("RGBA32F",16,4,ps.FLOAT,!0,!1,!1,!1),new Ss("RGBA32UI",16,4,ps.UINT,!0,!1,!1,!1),new Ss("RGBA32I",16,4,ps.INT,!0,!1,!1,!1),new Ss("R5G6B5",2,3,ps.UNORM,!1,!1,!1,!1),new Ss("R11G11B10F",4,3,ps.FLOAT,!1,!1,!1,!1),new Ss("RGB5A1",2,4,ps.UNORM,!0,!1,!1,!1),new Ss("RGBA4",2,4,ps.UNORM,!0,!1,!1,!1),new Ss("RGB10A2",2,4,ps.UNORM,!0,!1,!1,!1),new Ss("RGB10A2UI",2,4,ps.UINT,!0,!1,!1,!1),new Ss("RGB9E5",2,4,ps.FLOAT,!0,!1,!1,!1),new Ss("D16",2,1,ps.UINT,!1,!0,!1,!1),new Ss("D16S8",3,2,ps.UINT,!1,!0,!0,!1),new Ss("D24",3,1,ps.UINT,!1,!0,!1,!1),new Ss("D24S8",4,2,ps.UINT,!1,!0,!0,!1),new Ss("D32F",4,1,ps.FLOAT,!1,!0,!1,!1),new Ss("D32FS8",5,2,ps.FLOAT,!1,!0,!0,!1),new Ss("BC1",1,3,ps.UNORM,!1,!1,!1,!0),new Ss("BC1_ALPHA",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("BC1_SRGB",1,3,ps.UNORM,!1,!1,!1,!0),new Ss("BC1_SRGB_ALPHA",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("BC2",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("BC2_SRGB",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("BC3",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("BC3_SRGB",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("BC4",1,1,ps.UNORM,!1,!1,!1,!0),new Ss("BC4_SNORM",1,1,ps.SNORM,!1,!1,!1,!0),new Ss("BC5",1,2,ps.UNORM,!1,!1,!1,!0),new Ss("BC5_SNORM",1,2,ps.SNORM,!1,!1,!1,!0),new Ss("BC6H_UF16",1,3,ps.UFLOAT,!1,!1,!1,!0),new Ss("BC6H_SF16",1,3,ps.FLOAT,!1,!1,!1,!0),new Ss("BC7",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("BC7_SRGB",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ETC_RGB8",1,3,ps.UNORM,!1,!1,!1,!0),new Ss("ETC2_RGB8",1,3,ps.UNORM,!1,!1,!1,!0),new Ss("ETC2_SRGB8",1,3,ps.UNORM,!1,!1,!1,!0),new Ss("ETC2_RGB8_A1",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ETC2_SRGB8_A1",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ETC2_RGBA8",2,4,ps.UNORM,!0,!1,!1,!0),new Ss("ETC2_SRGB8_A8",2,4,ps.UNORM,!0,!1,!1,!0),new Ss("EAC_R11",1,1,ps.UNORM,!1,!1,!1,!0),new Ss("EAC_R11SN",1,1,ps.SNORM,!1,!1,!1,!0),new Ss("EAC_RG11",2,2,ps.UNORM,!1,!1,!1,!0),new Ss("EAC_RG11SN",2,2,ps.SNORM,!1,!1,!1,!0),new Ss("PVRTC_RGB2",2,3,ps.UNORM,!1,!1,!1,!0),new Ss("PVRTC_RGBA2",2,4,ps.UNORM,!0,!1,!1,!0),new Ss("PVRTC_RGB4",2,3,ps.UNORM,!1,!1,!1,!0),new Ss("PVRTC_RGBA4",2,4,ps.UNORM,!0,!1,!1,!0),new Ss("PVRTC2_2BPP",2,4,ps.UNORM,!0,!1,!1,!0),new Ss("PVRTC2_4BPP",2,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_RGBA_4x4",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_RGBA_5x4",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_RGBA_5x5",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_RGBA_6x5",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_RGBA_6x6",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_RGBA_8x5",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_RGBA_8x6",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_RGBA_8x8",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_RGBA_10x5",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_RGBA_10x6",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_RGBA_10x8",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_RGBA_10x10",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_RGBA_12x10",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_RGBA_12x12",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_SRGBA_4x4",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_SRGBA_5x4",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_SRGBA_5x5",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_SRGBA_6x5",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_SRGBA_6x6",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_SRGBA_8x5",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_SRGBA_8x6",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_SRGBA_8x8",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_SRGBA_10x5",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_SRGBA_10x6",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_SRGBA_10x8",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_SRGBA_10x10",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_SRGBA_12x10",1,4,ps.UNORM,!0,!1,!1,!0),new Ss("ASTC_SRGBA_12x12",1,4,ps.UNORM,!0,!1,!1,!0)]));function As(e,t,n,i){if(!Ts[e].isCompressed)return t*n*i*Ts[e].size;switch(e){case za.BC1:case za.BC1_ALPHA:case za.BC1_SRGB:case za.BC1_SRGB_ALPHA:return Math.ceil(t/4)*Math.ceil(n/4)*8*i;case za.BC2:case za.BC2_SRGB:case za.BC3:case za.BC3_SRGB:case za.BC4:case za.BC4_SNORM:case za.BC6H_SF16:case za.BC6H_UF16:case za.BC7:case za.BC7_SRGB:return Math.ceil(t/4)*Math.ceil(n/4)*16*i;case za.BC5:case za.BC5_SNORM:return Math.ceil(t/4)*Math.ceil(n/4)*32*i;case za.ETC_RGB8:case za.ETC2_RGB8:case za.ETC2_SRGB8:case za.ETC2_RGB8_A1:case za.EAC_R11:case za.EAC_R11SN:return Math.ceil(t/4)*Math.ceil(n/4)*8*i;case za.ETC2_RGBA8:case za.ETC2_SRGB8_A1:case za.EAC_RG11:case za.EAC_RG11SN:return Math.ceil(t/4)*Math.ceil(n/4)*16*i;case za.PVRTC_RGB2:case za.PVRTC_RGBA2:case za.PVRTC2_2BPP:return Math.ceil(Math.max(t,16)*Math.max(n,8)/4)*i;case za.PVRTC_RGB4:case za.PVRTC_RGBA4:case za.PVRTC2_4BPP:return Math.ceil(Math.max(t,8)*Math.max(n,8)/2)*i;case za.ASTC_RGBA_4x4:case za.ASTC_SRGBA_4x4:return Math.ceil(t/4)*Math.ceil(n/4)*16*i;case za.ASTC_RGBA_5x4:case za.ASTC_SRGBA_5x4:return Math.ceil(t/5)*Math.ceil(n/4)*16*i;case za.ASTC_RGBA_5x5:case za.ASTC_SRGBA_5x5:return Math.ceil(t/5)*Math.ceil(n/5)*16*i;case za.ASTC_RGBA_6x5:case za.ASTC_SRGBA_6x5:return Math.ceil(t/6)*Math.ceil(n/5)*16*i;case za.ASTC_RGBA_6x6:case za.ASTC_SRGBA_6x6:return Math.ceil(t/6)*Math.ceil(n/6)*16*i;case za.ASTC_RGBA_8x5:case za.ASTC_SRGBA_8x5:return Math.ceil(t/8)*Math.ceil(n/5)*16*i;case za.ASTC_RGBA_8x6:case za.ASTC_SRGBA_8x6:return Math.ceil(t/8)*Math.ceil(n/6)*16*i;case za.ASTC_RGBA_8x8:case za.ASTC_SRGBA_8x8:return Math.ceil(t/8)*Math.ceil(n/8)*16*i;case za.ASTC_RGBA_10x5:case za.ASTC_SRGBA_10x5:return Math.ceil(t/10)*Math.ceil(n/5)*16*i;case za.ASTC_RGBA_10x6:case za.ASTC_SRGBA_10x6:return Math.ceil(t/10)*Math.ceil(n/6)*16*i;case za.ASTC_RGBA_10x8:case za.ASTC_SRGBA_10x8:return Math.ceil(t/10)*Math.ceil(n/8)*16*i;case za.ASTC_RGBA_10x10:case za.ASTC_SRGBA_10x10:return Math.ceil(t/10)*Math.ceil(n/10)*16*i;case za.ASTC_RGBA_12x10:case za.ASTC_SRGBA_12x10:return Math.ceil(t/12)*Math.ceil(n/10)*16*i;case za.ASTC_RGBA_12x12:case za.ASTC_SRGBA_12x12:return Math.ceil(t/12)*Math.ceil(n/12)*16*i;default:return 0}}function xs(e,t,n,i,r){for(var a=0,s=0;s>1,1),n=Math.max(n>>1,1);return a}var Cs=[0,4,8,12,16,4,8,12,16,4,8,12,16,4,8,12,16,16,24,32,24,36,48,32,48,64,4,4,4,4,4,4];function Rs(e){return Cs[e]||0}function bs(e){var t=e.size/e.count;switch(e.type){case ps.UNORM:case ps.UINT:switch(t){case 1:return Uint8Array;case 2:return Uint16Array;case 4:return Uint32Array}break;case ps.SNORM:case ps.INT:switch(t){case 1:return Int8Array;case 2:return Int16Array;case 4:return Int32Array}break;case ps.FLOAT:return Float32Array}return Float32Array}var ws=e("GFXDrawInfo",(function(e,t,n,i,r,a,s){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===a&&(a=0),void 0===s&&(s=0),this.vertexCount=e,this.firstVertex=t,this.indexCount=n,this.firstIndex=i,this.vertexOffset=r,this.instanceCount=a,this.firstInstance=s})),Is=e("GFX_DRAW_INFO_SIZE",28),Os=e("GFXIndirectBuffer",(function(e){void 0===e&&(e=[]),this.drawInfos=e})),Ps=e("GFXBufferInfo",(function(e,t,n,i,r){void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=ka.NONE),this.usage=e,this.memUsage=t,this.size=n,this.stride=i,this.flags=r})),Ms=e("GFXBufferViewInfo",(function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=0),this.buffer=e,this.offset=t,this.range=n})),Ns=e("GFXBuffer",function(e){function t(t){var n;return(n=e.call(this,Ma.BUFFER)||this)._device=void 0,n._usage=Ua.NONE,n._memUsage=Ga.NONE,n._size=0,n._stride=1,n._count=0,n._flags=ka.NONE,n._bakcupBuffer=null,n._indirectBuffer=null,n._isBufferView=!1,n._device=t,n}return X(t,e),j(t,[{key:"usage",get:function(){return this._usage}},{key:"memUsage",get:function(){return this._memUsage}},{key:"size",get:function(){return this._size}},{key:"stride",get:function(){return this._stride}},{key:"count",get:function(){return this._count}},{key:"flags",get:function(){return this._flags}},{key:"backupBuffer",get:function(){return this._bakcupBuffer}}]),t}(ys)),Ds=e("GFXCommandBufferInfo",(function(e,t){void 0===t&&(t=ss.PRIMARY),this.queue=e,this.type=t})),Bs=e("GFXCommandBuffer",function(e){function t(t){var n;return(n=e.call(this,Ma.COMMAND_BUFFER)||this)._device=void 0,n._queue=null,n._type=ss.PRIMARY,n._numDrawCalls=0,n._numInstances=0,n._numTris=0,n._device=t,n}return X(t,e),j(t,[{key:"type",get:function(){return this._type}},{key:"queue",get:function(){return this._queue}},{key:"numDrawCalls",get:function(){return this._numDrawCalls}},{key:"numInstances",get:function(){return this._numInstances}},{key:"numTris",get:function(){return this._numTris}}]),t}(ys));ht(za);var Ls=e("GFXBindingMappingInfo",(function(e,t,n){void 0===e&&(e=[]),void 0===t&&(t=[]),void 0===n&&(n=0),this.bufferOffsets=e,this.samplerOffsets=t,this.flexibleSet=n})),Fs=e("GFXDeviceInfo",(function(e,t,n,i,r,a,s){void 0===t&&(t=!0),void 0===n&&(n=!0),void 0===i&&(i=1),void 0===r&&(r=1),void 0===a&&(a=1),void 0===s&&(s=new Ls),this.canvasElm=e,this.isAntialias=t,this.isPremultipliedAlpha=n,this.devicePixelRatio=i,this.nativeWidth=r,this.nativeHeight=a,this.bindingMappingInfo=s})),zs=e("GFXDevice",function(){function e(){this._canvas=null,this._canvas2D=null,this._gfxAPI=ms.UNKNOWN,this._transform=gs.IDENTITY,this._deviceName="",this._renderer="",this._vendor="",this._version="",this._features=new Array(vs.COUNT),this._queue=null,this._cmdBuff=null,this._devicePixelRatio=1,this._width=0,this._height=0,this._nativeWidth=0,this._nativeHeight=0,this._maxVertexAttributes=0,this._maxVertexUniformVectors=0,this._maxFragmentUniformVectors=0,this._maxTextureUnits=0,this._maxVertexTextureUnits=0,this._maxUniformBufferBindings=0,this._maxUniformBlockSize=0,this._maxTextureSize=0,this._maxCubeMapTextureSize=0,this._uboOffsetAlignment=1,this._depthBits=0,this._stencilBits=0,this._colorFmt=za.UNKNOWN,this._depthStencilFmt=za.UNKNOWN,this._macros=new Map,this._numDrawCalls=0,this._numInstances=0,this._numTris=0,this._memoryStatus=new Es,this._clipSpaceMinZ=-1,this._screenSpaceSignY=1,this._UVSpaceSignY=-1}return e.prototype.hasFeature=function(e){return this._features[e]},j(e,[{key:"canvas",get:function(){return this._canvas}},{key:"canvas2D",get:function(){return this._canvas2D}},{key:"gfxAPI",get:function(){return this._gfxAPI}},{key:"queue",get:function(){return this._queue}},{key:"commandBuffer",get:function(){return this._cmdBuff}},{key:"devicePixelRatio",get:function(){return this._devicePixelRatio}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"nativeWidth",get:function(){return this._nativeWidth}},{key:"nativeHeight",get:function(){return this._nativeHeight}},{key:"renderer",get:function(){return this._renderer}},{key:"vendor",get:function(){return this._vendor}},{key:"maxVertexAttributes",get:function(){return this._maxVertexAttributes}},{key:"maxVertexUniformVectors",get:function(){return this._maxVertexUniformVectors}},{key:"maxFragmentUniformVectors",get:function(){return this._maxFragmentUniformVectors}},{key:"maxTextureUnits",get:function(){return this._maxTextureUnits}},{key:"maxVertexTextureUnits",get:function(){return this._maxVertexTextureUnits}},{key:"maxUniformBufferBindings",get:function(){return this._maxUniformBufferBindings}},{key:"maxUniformBlockSize",get:function(){return this._maxUniformBlockSize}},{key:"maxTextureSize",get:function(){return this._maxTextureSize}},{key:"maxCubeMapTextureSize",get:function(){return this._maxCubeMapTextureSize}},{key:"uboOffsetAlignment",get:function(){return this._uboOffsetAlignment}},{key:"depthBits",get:function(){return this._depthBits}},{key:"stencilBits",get:function(){return this._stencilBits}},{key:"colorFormat",get:function(){return this._colorFmt}},{key:"depthStencilFormat",get:function(){return this._depthStencilFmt}},{key:"macros",get:function(){return this._macros}},{key:"numDrawCalls",get:function(){return this._numDrawCalls}},{key:"numInstances",get:function(){return this._numInstances}},{key:"numTris",get:function(){return this._numTris}},{key:"memoryStatus",get:function(){return this._memoryStatus}},{key:"clipSpaceMinZ",get:function(){return this._clipSpaceMinZ}},{key:"screenSpaceSignY",get:function(){return this._screenSpaceSignY}},{key:"UVSpaceSignY",get:function(){return this._UVSpaceSignY}},{key:"surfaceTransform",get:function(){return this._transform}}]),e}()),Us=e("GFXFramebufferInfo",(function(e,t,n,i,r){void 0===t&&(t=[]),void 0===n&&(n=null),void 0===i&&(i=[]),void 0===r&&(r=0),this.renderPass=e,this.colorTextures=t,this.depthStencilTexture=n,this.colorMipmapLevels=i,this.depStencilMipmapLevel=r})),Gs=e("GFXFramebuffer",function(e){function t(t){var n;return(n=e.call(this,Ma.FRAMEBUFFER)||this)._device=void 0,n._renderPass=null,n._colorTextures=[],n._depthStencilTexture=null,n._device=t,n}return X(t,e),j(t,[{key:"renderPass",get:function(){return this._renderPass}},{key:"colorTextures",get:function(){return this._colorTextures}},{key:"depthStencilTexture",get:function(){return this._depthStencilTexture}}]),t}(ys)),ks=String.prototype.charCodeAt;function Hs(e){return this[e]}function Vs(e,t){for(var n=e.length,i=t^n,r=0,a="string"==typeof e?ks:Hs;n>=4;){var s=255&a.call(e,r)|(255&a.call(e,++r))<<8|(255&a.call(e,++r))<<16|(255&a.call(e,++r))<<24;s=1540483477*(65535&s)+((1540483477*(s>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(s=1540483477*(65535&(s^=s>>>24))+((1540483477*(s>>>16)&65535)<<16)),n-=4,++r}switch(n){case 3:i^=(255&a.call(e,r+2))<<16;case 2:i^=(255&a.call(e,r+1))<<8;case 1:i=1540483477*(65535&(i^=255&a.call(e,r)))+((1540483477*(i>>>16)&65535)<<16)}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0}var Ws=e("GFXAttribute",(function(e,t,n,i,r,a){void 0===e&&(e=""),void 0===t&&(t=za.UNKNOWN),void 0===n&&(n=!1),void 0===i&&(i=0),void 0===r&&(r=!1),void 0===a&&(a=0),this.name=e,this.format=t,this.isNormalized=n,this.stream=i,this.isInstanced=r,this.location=a})),js=e("GFXInputAssemblerInfo",(function(e,t,n,i){void 0===e&&(e=[]),void 0===t&&(t=[]),void 0===n&&(n=null),void 0===i&&(i=null),this.attributes=e,this.vertexBuffers=t,this.indexBuffer=n,this.indirectBuffer=i})),qs=e("GFXInputAssembler",function(e){function t(t){var n;return(n=e.call(this,Ma.INPUT_ASSEMBLER)||this)._device=void 0,n._attributes=[],n._vertexBuffers=[],n._indexBuffer=null,n._vertexCount=0,n._firstVertex=0,n._indexCount=0,n._firstIndex=0,n._vertexOffset=0,n._instanceCount=0,n._firstInstance=0,n._attributesHash=0,n._indirectBuffer=null,n._device=t,n}X(t,e),j(t,[{key:"vertexBuffers",get:function(){return this._vertexBuffers}},{key:"indexBuffer",get:function(){return this._indexBuffer}},{key:"attributes",get:function(){return this._attributes}},{key:"attributesHash",get:function(){return this._attributesHash}},{key:"vertexCount",get:function(){return this._vertexCount},set:function(e){this._vertexCount=e}},{key:"firstVertex",get:function(){return this._firstVertex},set:function(e){this._firstVertex=e}},{key:"indexCount",get:function(){return this._indexCount},set:function(e){this._indexCount=e}},{key:"firstIndex",get:function(){return this._firstIndex},set:function(e){this._firstIndex=e}},{key:"vertexOffset",get:function(){return this._vertexOffset},set:function(e){this._vertexOffset=e}},{key:"instanceCount",get:function(){return this._instanceCount},set:function(e){this._instanceCount=e}},{key:"firstInstance",get:function(){return this._firstInstance},set:function(e){this._firstInstance=e}},{key:"indirectBuffer",get:function(){return this._indirectBuffer}}]);var n=t.prototype;return n.getVertexBuffer=function(e){return void 0===e&&(e=0),e=0){var o=this._colorInfos[n.depthStencil];e+="ds,"+o.format+","+o.sampleCount}}else{e+="ca";for(var c=0;c0&&0==(e&e-1)}var bo=e("GFXTexture",function(e){function t(t){var n;return(n=e.call(this,Ma.TEXTURE)||this)._device=void 0,n._type=es.TEX2D,n._usage=ts.NONE,n._format=za.UNKNOWN,n._width=0,n._height=0,n._depth=1,n._layerCount=1,n._levelCount=1,n._samples=ns.X1,n._flags=is.NONE,n._isPowerOf2=!1,n._size=0,n._buffer=null,n._device=t,n}return X(t,e),j(t,[{key:"type",get:function(){return this._type}},{key:"usage",get:function(){return this._usage}},{key:"format",get:function(){return this._format}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"depth",get:function(){return this._depth}},{key:"layerCount",get:function(){return this._layerCount}},{key:"levelCount",get:function(){return this._levelCount}},{key:"samples",get:function(){return this._samples}},{key:"flags",get:function(){return this._flags}},{key:"size",get:function(){return this._size}},{key:"buffer",get:function(){return this._buffer}}]),t}(ys)),wo={Device:zs,Buffer:Ns,Texture:bo,Sampler:go,Shader:Ao,InputAssembler:qs,RenderPass:po,Framebuffer:Gs,PipelineState:oo,CommandBuffer:Bs,Queue:lo,FormatSize:As,FormatSurfaceSize:xs,GetTypeSize:Rs,getTypedArrayConstructor:bs,MAX_ATTACHMENTS:Ba,ObjectType:Ma,Obj:ys,AttributeName:La,Type:Fa,Format:za,BufferUsageBit:Ua,MemoryUsageBit:Ga,BufferFlagBit:ka,BufferAccessBit:Ha,PrimitiveMode:Va,PolygonMode:Wa,ShadeModel:ja,CullMode:qa,ComparisonFunc:Xa,StencilOp:Ya,BlendOp:Ka,BlendFactor:Za,ColorMask:Qa,Filter:Ja,Address:$a,TextureType:es,TextureUsageBit:ts,SampleCount:ns,TextureFlagBit:is,ShaderStageFlagBit:rs,DescriptorType:as,CommandBufferType:ss,LoadOp:os,StoreOp:cs,TextureLayout:ls,PipelineBindPoint:us,DynamicStateFlagBit:hs,StencilFace:_s,QueueType:fs,Rect:Xs,Viewport:Ys,Color:Ks,ClearFlag:ds,Offset:Zs,Extent:Qs,TextureSubres:Js,TextureCopy:$s,BufferTextureCopy:eo,FormatType:ps,FormatInfo:Ss,MemoryStatus:Es,FormatInfos:Ts},Io=e("GFX_DESCRIPTOR_BUFFER_TYPE",as.UNIFORM_BUFFER|as.DYNAMIC_UNIFORM_BUFFER|as.STORAGE_BUFFER|as.DYNAMIC_STORAGE_BUFFER),Oo=e("GFX_DESCRIPTOR_SAMPLER_TYPE",as.SAMPLER),Po=e("GFXDescriptorSetInfo",(function(e){this.layout=e})),Mo=e("GFXDescriptorSet",function(e){function t(t){var n;return(n=e.call(this,Ma.DESCRIPTOR_SET)||this)._device=void 0,n._layout=null,n._buffers=[],n._textures=[],n._samplers=[],n._isDirty=!1,n._device=t,n}X(t,e),j(t,[{key:"layout",get:function(){return this._layout}}]);var n=t.prototype;return n.bindBuffer=function(e,t,n){void 0===n&&(n=0);var i=this._layout.bindingIndices[e],r=this._layout.bindings[i];if(r)if(r.descriptorType&Io){var a=this._layout.descriptorIndices[e];this._buffers[a+n]!==t&&(this._buffers[a+n]=t,this._isDirty=!0)}else console.warn("Setting binding is not DescriptorType.UNIFORM_BUFFER.")},n.bindSampler=function(e,t,n){void 0===n&&(n=0);var i=this._layout.bindingIndices[e],r=this._layout.bindings[i];if(r)if(r.descriptorType&Oo){var a=this._layout.descriptorIndices[e];this._samplers[a+n]!==t&&(this._samplers[a+n]=t,this._isDirty=!0)}else console.warn("Setting binding is not DescriptorType.SAMPLER.")},n.bindTexture=function(e,t,n){void 0===n&&(n=0);var i=this._layout.bindingIndices[e],r=this._layout.bindings[i];if(r)if(r.descriptorType&Oo){var a=this._layout.descriptorIndices[e];this._textures[a+n]!==t&&(this._textures[a+n]=t,this._isDirty=!0)}else console.warn("Setting binding is not DescriptorType.SAMPLER.")},n.getBuffer=function(e,t){void 0===t&&(t=0);var n=this._layout.descriptorIndices[e];return this._buffers[n+t]},n.getSampler=function(e,t){void 0===t&&(t=0);var n=this._layout.descriptorIndices[e];return this._samplers[n+t]},n.getTexture=function(e,t){void 0===t&&(t=0);var n=this._layout.descriptorIndices[e];return this._textures[n+t]},t}(ys)),No=e("GFXDescriptorSetLayoutBinding",(function(e,t,n,i,r){void 0===e&&(e=-1),void 0===t&&(t=as.UNKNOWN),void 0===n&&(n=0),void 0===i&&(i=rs.NONE),void 0===r&&(r=[]),this.binding=e,this.descriptorType=t,this.count=n,this.stageFlags=i,this.immutableSamplers=r})),Do=e("GFXDescriptorSetLayoutInfo",(function(e){void 0===e&&(e=[]),this.bindings=e})),Bo=e("GFX_DESCRIPTOR_DYNAMIC_TYPE",as.DYNAMIC_STORAGE_BUFFER|as.DYNAMIC_UNIFORM_BUFFER),Lo=e("GFXDescriptorSetLayout",function(e){function t(t){var n;return(n=e.call(this,Ma.DESCRIPTOR_SET_LAYOUT)||this)._device=void 0,n._bindings=[],n._bindingIndices=[],n._descriptorIndices=[],n._device=t,n}return X(t,e),j(t,[{key:"bindings",get:function(){return this._bindings}},{key:"bindingIndices",get:function(){return this._bindingIndices}},{key:"descriptorIndices",get:function(){return this._descriptorIndices}}]),t}(ys)),Fo=e("GFXPipelineLayoutInfo",(function(e){void 0===e&&(e=[]),this.setLayouts=e})),zo=e("GFXPipelineLayout",function(e){function t(t){var n;return(n=e.call(this,Ma.PIPELINE_LAYOUT)||this)._device=void 0,n._setLayouts=[],n._device=t,n}return X(t,e),j(t,[{key:"setLayouts",get:function(){return this._setLayouts}}]),t}(ys)),Uo=e("GFXFenceInfo",(function(){})),Go=e("GFXFence",function(e){function t(t){var n;return(n=e.call(this,Ma.FENCE)||this)._device=void 0,n._device=t,n}return X(t,e),t}(ys));se(i,"cc",[{name:"GFXDynamicState",newName:"DynamicStateFlagBit"},{name:"GFXBindingType",newName:"DescriptorType"},{name:"GFXBindingLayout",newName:"DescriptorSet"}]),oe(Bs.prototype,"CommandBuffer.prototype",[{name:"bindBindingLayout",suggest:"Use `bindDescriptorSet` instead"}]);var ko,Ho={MAX_ATTACHMENTS:"GFX_MAX_ATTACHMENTS",Obj:"GFXObject",getTypedArrayConstructor:""};for(var Vo in wo){var Wo=Ho[Vo];""!==Wo&&(void 0===Wo&&(Wo="GFX"+Vo),se(i,"cc",[{name:Wo,newName:Vo,target:i.gfx,targetName:"cc.gfx"}]))}i.gfx=wo,e("gfx",Object.freeze({__proto__:null,DESCRIPTOR_BUFFER_TYPE:Io,DESCRIPTOR_SAMPLER_TYPE:Oo,DescriptorSetInfo:Po,DescriptorSet:Mo,DrawInfo:ws,DRAW_INFO_SIZE:Is,IndirectBuffer:Os,BufferInfo:Ps,BufferViewInfo:Ms,Buffer:Ns,CommandBufferInfo:Ds,CommandBuffer:Bs,MAX_ATTACHMENTS:Ba,get ObjectType(){return Ma},Obj:ys,get AttributeName(){return La},get Type(){return Fa},get Format(){return za},get BufferUsageBit(){return Ua},get MemoryUsageBit(){return Ga},get BufferFlagBit(){return ka},get BufferAccessBit(){return Ha},get PrimitiveMode(){return Va},get PolygonMode(){return Wa},get ShadeModel(){return ja},get CullMode(){return qa},get ComparisonFunc(){return Xa},get StencilOp(){return Ya},get BlendOp(){return Ka},get BlendFactor(){return Za},get ColorMask(){return Qa},get Filter(){return Ja},get Address(){return $a},get TextureType(){return es},get TextureUsageBit(){return ts},get SampleCount(){return ns},get TextureFlagBit(){return is},get ShaderStageFlagBit(){return rs},get DescriptorType(){return as},get CommandBufferType(){return ss},get LoadOp(){return os},get StoreOp(){return cs},get TextureLayout(){return ls},get PipelineBindPoint(){return us},get DynamicStateFlagBit(){return hs},get StencilFace(){return _s},get QueueType(){return fs},get ClearFlag(){return ds},get FormatType(){return ps},get API(){return ms},get SurfaceTransform(){return gs},get Feature(){return vs},FormatInfo:Ss,MemoryStatus:Es,FormatInfos:Ts,FormatSize:As,FormatSurfaceSize:xs,GetTypeSize:Rs,getTypedArrayConstructor:bs,Rect:Xs,Viewport:Ys,Color:Ks,Offset:Zs,Extent:Qs,TextureSubres:Js,TextureCopy:$s,BufferTextureCopy:eo,BindingMappingInfo:Ls,DeviceInfo:Fs,Device:zs,FramebufferInfo:Us,Framebuffer:Gs,Attribute:Ws,InputAssemblerInfo:js,InputAssembler:qs,DescriptorSetLayoutBinding:No,DescriptorSetLayoutInfo:Do,DESCRIPTOR_DYNAMIC_TYPE:Bo,DescriptorSetLayout:Lo,PipelineLayoutInfo:Fo,PipelineLayout:zo,RasterizerState:to,DepthStencilState:no,BlendTarget:io,BlendState:ro,InputState:ao,PipelineStateInfo:so,PipelineState:oo,FenceInfo:Uo,Fence:Go,QueueInfo:co,Queue:lo,ColorAttachment:uo,DepthStencilAttachment:ho,SubPassInfo:_o,RenderPassInfo:fo,RenderPass:po,SamplerInfo:mo,Sampler:go,ShaderStage:vo,Uniform:yo,UniformBlock:So,UniformSampler:Eo,ShaderInfo:To,Shader:Ao,TextureInfo:xo,TextureViewInfo:Co,IsPowerOf2:Ro,Texture:bo})),function(e){e[e.ALL=0]="ALL",e[e.CLOSEST=1]="CLOSEST",e[e.ANY=2]="ANY"}(ko||(ko={}));var jo,qo,Xo,Yo,Ko,Zo,Qo,Jo,$o=(jo=new bn(0,0,0),function(e,t){var n=bn.dot(e.d,t.n);if(Math.abs(n)-Number.EPSILON))return 0;var r=1/i;bn.subtract(Ko,e.o,t.a);var a=bn.dot(Ko,Yo)*r;if(a<0||a>1)return 0;bn.cross(Zo,Ko,qo);var s=bn.dot(e.d,Zo)*r;if(s<0||a+s>1)return 0;var o=bn.dot(Xo,Zo)*r;return o<0?0:o}),tc=function(){var e=new bn(0,0,0);return function(t,n){var i=n.radius,r=n.center,a=t.o,s=t.d,o=i*i;bn.subtract(e,r,a);var c=e.lengthSqr(),l=bn.dot(e,s),u=o-(c-l*l);if(u<0)return 0;var h=Math.sqrt(u),_=cp?0:d>0?d:p}var rc,ac,sc,oc,cc=function(){var e=new bn,t=new bn,n=new bn,i=new bn,r=new bn,a=new bn,s=new bn,o=new Array(3),c=new Array(3),l=new Array(3),u=new Array(6);return function(h,_){o[0]=_.halfExtents.x,o[1]=_.halfExtents.y,o[2]=_.halfExtents.z,e=_.center,t=h.o,n=h.d,bn.set(i,_.orientation.m00,_.orientation.m01,_.orientation.m02),bn.set(r,_.orientation.m03,_.orientation.m04,_.orientation.m05),bn.set(a,_.orientation.m06,_.orientation.m07,_.orientation.m08),bn.subtract(s,e,t),c[0]=bn.dot(i,n),c[1]=bn.dot(r,n),c[2]=bn.dot(a,n),l[0]=bn.dot(i,s),l[1]=bn.dot(r,s),l[2]=bn.dot(a,s);for(var f=0;f<3;++f){if(0===c[f]){if(-l[f]-o[f]>0||-l[f]+o[f]<0)return 0;c[f]=1e-7}u[2*f+0]=(l[f]+o[f])/c[f],u[2*f+1]=(l[f]-o[f])/c[f]}var d=Math.max(Math.max(Math.min(u[0],u[1]),Math.min(u[2],u[3])),Math.min(u[4],u[5])),p=Math.min(Math.min(Math.max(u[0],u[1]),Math.max(u[2],u[3])),Math.max(u[4],u[5]));return p<0||d>p?0:d>0?d:p}}(),lc=function(){var e=new bn,t=new bn,n=new bn,i=new bn,r=new bn,a=new bn,s=new bn,o=new Na;return function(c,l){var u=l.radius*l.radius,h=bn.normalize(e,c.d),_=l.ellipseCenter0,f=l.ellipseCenter1,d=bn.subtract(t,f,_);if(d.equals(bn.ZERO))return o.radius=l.radius,o.center.set(l.ellipseCenter0),Xc.raySphere(c,o);var p=c.o,m=bn.subtract(n,p,_),g=bn.cross(i,h,d),v=g.lengthSqr();if(0===v){o.radius=l.radius;var y=bn.subtract(r,f,p);return m.lengthSqr()=0&&w<=1?x:w<0?(o.radius=l.radius,o.center.set(l.ellipseCenter0),Xc.raySphere(c,o)):w>1?(o.radius=l.radius,o.center.set(l.ellipseCenter1),Xc.raySphere(c,o)):0}}(),uc=(rc=Da.create(),ac={distance:1/0,doubleSided:!1,mode:ko.ANY},sc=0,oc=function(e,t,n,i,r,a){e===ko.CLOSEST?(sc>t||0===sc)&&(sc=t,a&&(0===a.length?a.push({distance:t,vertexIndex0:n/3,vertexIndex1:i/3,vertexIndex2:r/3}):(a[0].distance=t,a[0].vertexIndex0=n/3,a[0].vertexIndex1=i/3,a[0].vertexIndex2=r/3))):(sc=t,a&&a.push({distance:t,vertexIndex0:n/3,vertexIndex1:i/3,vertexIndex2:r/3}))},function(e,t,n){if(sc=0,0===t.geometricInfo.positions.length)return sc;var i=void 0===n?ac:n;if(ic(e,t.geometricInfo.boundingBox.min,t.geometricInfo.boundingBox.max)){var r=t.primitiveMode,a=t.geometricInfo;!function(e,t,n,i,r){if(n===Va.TRIANGLE_LIST)for(var a=t.length,s=0;sr.distance)&&(oc(r.mode,u,o,c,l,r.result),r.mode===ko.ANY))return u}else if(n===Va.TRIANGLE_STRIP)for(var h=t.length-2,_=0,f=0;fr.distance)&&(oc(r.mode,g,d,p,m,r.result),r.mode===ko.ANY))return g}else if(n===Va.TRIANGLE_FAN){var v=t.length-1,y=3*t[0];bn.set(rc.a,e[y],e[y+1],e[y+2]);for(var S=1;Sr.distance)&&(oc(r.mode,A,y,E,T,r.result),r.mode===ko.ANY))return A}}}(a.positions,a.indices,r,e,i)}return sc}),hc=function(){var e=0,t={distance:1/0,doubleSided:!1,mode:ko.ANY};return function(n,i,r){e=0;var a=void 0===r?t:r,s=i.renderingSubMeshes.length,o=i.struct.minPosition,c=i.struct.maxPosition;if(o&&c&&!ic(n,o,c))return e;for(var l=0;lh)&&(e=h,a.subIndices&&(a.subIndices[0]=l));else if(e=h,a.subIndices&&a.subIndices.push(l),a.mode===ko.ANY)return h}return e&&a.mode===ko.CLOSEST&&(a.result&&(a.result[0].distance=e,a.result.length=1),a.subIndices&&(a.subIndices.length=1)),e}}(),_c=function(){var e=0,t={distance:1/0,doubleSided:!1,mode:ko.ANY},n=new Ra,i=new Hn;return function(r,a,s){e=0;var o=void 0===s?t:s,c=a.worldBounds;if(c&&!nc(r,c))return e;Ra.copy(n,r),a.node&&(Hn.invert(i,a.node.getWorldMatrix(i)),bn.transformMat4(n.o,r.o,i),bn.transformMat4Normal(n.d,r.d,i));for(var l=a.subModels,u=0;u_)&&(e=_,o.subIndices&&(o.subIndices[0]=u));else if(e=_,o.subIndices&&o.subIndices.push(u),o.mode===ko.ANY)return _}return e&&o.mode===ko.CLOSEST&&(o.result&&(o.result[0].distance=e,o.result.length=1),o.subIndices&&(o.subIndices.length=1)),e}}(),fc=function(){var e=new bn(0,0,0);return function(t,n){bn.subtract(e,t.e,t.s);var i=(n.d-bn.dot(t.s,n.n))/bn.dot(e,n.n);return i<0||i>1?0:i}}(),dc=function(){var e=new bn(0,0,0),t=new bn(0,0,0),n=new bn(0,0,0),i=new bn(0,0,0),r=new bn(0,0,0),a=new bn(0,0,0);return function(s,o,c){bn.subtract(e,o.b,o.a),bn.subtract(t,o.c,o.a),bn.subtract(n,s.s,s.e),bn.cross(r,e,t);var l=bn.dot(n,r);if(l<=0)return 0;bn.subtract(i,s.s,o.a);var u=bn.dot(i,r);if(u<0||u>l)return 0;bn.cross(a,n,i);var h=bn.dot(t,a);if(h<0||h>l)return 0;var _=-bn.dot(e,a);if(_<0||h+_>l)return 0;if(c){var f=1/l,d=1-(h*=f)-(_*=f);bn.set(c,o.a.x*d+o.b.x*h+o.c.x*_,o.a.y*d+o.b.y*h+o.c.y*_,o.a.z*d+o.b.z*h+o.c.z*_)}return 1}}(),pc=new Ra;function mc(e,t){pc.o.set(e.s),bn.subtract(pc.d,e.e,e.s),pc.d.normalize();var n=nc(pc,t);return n<=e.length()?n:0}function gc(e,t){pc.o.set(e.s),bn.subtract(pc.d,e.e,e.s),pc.d.normalize();var n=cc(pc,t);return n<=e.length()?n:0}function vc(e,t){pc.o.set(e.s),bn.subtract(pc.d,e.e,e.s),pc.d.normalize();var n=tc(pc,t);return n<=e.length()?n:0}var yc,Sc,Ec,Tc,Ac=(yc=new bn,Sc=new bn,Ec=new bn,Tc=new bn,function(e,t){return bn.subtract(yc,e.center,e.halfExtents),bn.add(Sc,e.center,e.halfExtents),bn.subtract(Ec,t.center,t.halfExtents),bn.add(Tc,t.center,t.halfExtents),yc.x<=Tc.x&&Sc.x>=Ec.x&&yc.y<=Tc.y&&Sc.y>=Ec.y&&yc.z<=Tc.z&&Sc.z>=Ec.z});function xc(e,t,n,i,r,a){bn.set(a[0],e.x+n.x*t.x+i.x*t.y+r.x*t.z,e.y+n.y*t.x+i.y*t.y+r.y*t.z,e.z+n.z*t.x+i.z*t.y+r.z*t.z),bn.set(a[1],e.x-n.x*t.x+i.x*t.y+r.x*t.z,e.y-n.y*t.x+i.y*t.y+r.y*t.z,e.z-n.z*t.x+i.z*t.y+r.z*t.z),bn.set(a[2],e.x+n.x*t.x-i.x*t.y+r.x*t.z,e.y+n.y*t.x-i.y*t.y+r.y*t.z,e.z+n.z*t.x-i.z*t.y+r.z*t.z),bn.set(a[3],e.x+n.x*t.x+i.x*t.y-r.x*t.z,e.y+n.y*t.x+i.y*t.y-r.y*t.z,e.z+n.z*t.x+i.z*t.y-r.z*t.z),bn.set(a[4],e.x-n.x*t.x-i.x*t.y-r.x*t.z,e.y-n.y*t.x-i.y*t.y-r.y*t.z,e.z-n.z*t.x-i.z*t.y-r.z*t.z),bn.set(a[5],e.x+n.x*t.x-i.x*t.y-r.x*t.z,e.y+n.y*t.x-i.y*t.y-r.y*t.z,e.z+n.z*t.x-i.z*t.y-r.z*t.z),bn.set(a[6],e.x-n.x*t.x+i.x*t.y-r.x*t.z,e.y-n.y*t.x+i.y*t.y-r.y*t.z,e.z-n.z*t.x+i.z*t.y-r.z*t.z),bn.set(a[7],e.x-n.x*t.x-i.x*t.y+r.x*t.z,e.y-n.y*t.x-i.y*t.y+r.y*t.z,e.z-n.z*t.x-i.z*t.y+r.z*t.z)}function Cc(e,t){for(var n=bn.dot(t,e[0]),i=n,r=1;r<8;++r){var a=bn.dot(t,e[r]);n=ai?a:i}return[n,i]}var Rc,bc,wc,Ic=function(){for(var e=new Array(15),t=0;t<15;t++)e[t]=new bn(0,0,0);for(var n=new Array(8),i=new Array(8),r=0;r<8;r++)n[r]=new bn(0,0,0),i[r]=new bn(0,0,0);var a=new bn,s=new bn;return function(t,r){bn.set(e[0],1,0,0),bn.set(e[1],0,1,0),bn.set(e[2],0,0,1),bn.set(e[3],r.orientation.m00,r.orientation.m01,r.orientation.m02),bn.set(e[4],r.orientation.m03,r.orientation.m04,r.orientation.m05),bn.set(e[5],r.orientation.m06,r.orientation.m07,r.orientation.m08);for(var o=0;o<3;++o)bn.cross(e[6+3*o],e[o],e[0]),bn.cross(e[7+3*o],e[o],e[1]),bn.cross(e[7+3*o],e[o],e[2]);bn.subtract(a,t.center,t.halfExtents),bn.add(s,t.center,t.halfExtents),function(e,t,n){bn.set(n[0],e.x,t.y,t.z),bn.set(n[1],e.x,t.y,e.z),bn.set(n[2],e.x,e.y,t.z),bn.set(n[3],e.x,e.y,e.z),bn.set(n[4],t.x,t.y,t.z),bn.set(n[5],t.x,t.y,e.z),bn.set(n[6],t.x,e.y,t.z),bn.set(n[7],t.x,e.y,e.z)}(a,s,n),xc(r.center,r.halfExtents,e[3],e[4],e[5],i);for(var c=0;c<15;++c){var l=Cc(n,e[c]),u=Cc(i,e[c]);if(u[0]>l[1]||l[0]>u[1])return 0}return 1}}(),Oc=function(e,t){var n=e.halfExtents.x*Math.abs(t.n.x)+e.halfExtents.y*Math.abs(t.n.y)+e.halfExtents.z*Math.abs(t.n.z),i=bn.dot(t.n,e.center);return i+nt.d?0:1},Pc=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}}(),Nc=(Rc=new bn(0,0,0),bc=new Pn,function(e,t){return bn.subtract(Rc,t,e.center),bn.transformMat3(Rc,Rc,Pn.transpose(bc,e.orientation)),n=Rc,i=e.halfExtents,Math.abs(n.x)t.d?0:1}),Bc=function(e,t){for(var n=0;nr.halfExtents.x?n++:t<-r.halfExtents.x&&i++;if(n===s.vertices.length||i===s.vertices.length)return 0;n=0,i=0;for(var _=0;_r.halfExtents.y?n++:t<-r.halfExtents.y&&i++;if(n===s.vertices.length||i===s.vertices.length)return 0;n=0,i=0;for(var f=0;fr.halfExtents.z?n++:t<-r.halfExtents.z&&i++;return n===s.vertices.length||i===s.vertices.length?0:1}}(),Fc=function(){for(var e=new Array(15),t=0;t<15;t++)e[t]=new bn(0,0,0);for(var n=new Array(8),i=new Array(8),r=0;r<8;r++)n[r]=new bn(0,0,0),i[r]=new bn(0,0,0);return function(t,r){bn.set(e[0],t.orientation.m00,t.orientation.m01,t.orientation.m02),bn.set(e[1],t.orientation.m03,t.orientation.m04,t.orientation.m05),bn.set(e[2],t.orientation.m06,t.orientation.m07,t.orientation.m08),bn.set(e[3],r.orientation.m00,r.orientation.m01,r.orientation.m02),bn.set(e[4],r.orientation.m03,r.orientation.m04,r.orientation.m05),bn.set(e[5],r.orientation.m06,r.orientation.m07,r.orientation.m08);for(var a=0;a<3;++a)bn.cross(e[6+3*a],e[a],e[0]),bn.cross(e[7+3*a],e[a],e[1]),bn.cross(e[7+3*a],e[a],e[2]);xc(t.center,t.halfExtents,e[0],e[1],e[2],n),xc(r.center,r.halfExtents,e[3],e[4],e[5],i);for(var s=0;s<15;++s){var o=Cc(n,e[s]),c=Cc(i,e[s]);if(c[0]>o[1]||o[0]>c[1])return 0}return 1}}(),zc=function(){for(var e=new Na,t=new bn,n=new bn,i=new bn,r=new Array(8),a=0;a<8;a++)r[a]=new bn;for(var s=new Array(8),o=0;o<8;o++)s[o]=new bn;return function(a,o){if(0===bn.squaredDistance(o.ellipseCenter0,o.ellipseCenter1))return e.radius=o.radius,e.center.set(o.ellipseCenter0),Xc.sphereOBB(e,a);t.x=a.orientation.m00,t.y=a.orientation.m01,t.z=a.orientation.m02,n.x=a.orientation.m03,n.y=a.orientation.m04,n.z=a.orientation.m05,i.x=a.orientation.m06,i.y=a.orientation.m07,i.z=a.orientation.m08,xc(a.center,a.halfExtents,t,n,i,r);var c=s,l=bn.copy(c[0],t),u=bn.copy(c[1],n),h=bn.copy(c[2],i);bn.subtract(c[3],o.center,a.center).normalize();var _=bn.subtract(c[4],o.ellipseCenter0,o.ellipseCenter1);_.normalize(),bn.cross(c[5],l,_),bn.cross(c[6],u,_),bn.cross(c[7],h,_);for(var f=0;f<8;++f){var d=Cc(r,c[f]),p=bn.dot(c[f],o.ellipseCenter0),m=bn.dot(c[f],o.ellipseCenter1),g=Math.max(p,m),v=Math.min(p,m)-o.radius,y=g+o.radius;if(v>d[1]||d[0]>y)return 0}return 1}}(),Uc=function(e,t){var n=bn.dot(t.n,e.center),i=e.radius*t.n.length();return n+it.d?0:1},Gc=function(e,t){for(var n=0;nl)){bn.add(e,o,bn.multiplyScalar(e,c,s));for(var h=0;h<6;h++)if(h!==r&&h!==r+t[r]){var _=i.planes[h];if(bn.dot(_.n,e)<_.d)return 0}}}return 1}}(),Hc=function(e,t){var n=e.radius+t.radius;return bn.squaredDistance(e.center,t.center)1?bn.squaredDistance(n.center,i.ellipseCenter1)E&&(l=E,h=y+m,T=g)),h<0?(h=0,-v<0?l=0:-v>p?l=E:(l=-v,E=p)):h>T&&(h=T,-v+m<0?l=0:-v+m>p?l=E:(l=-v+m,E=p)),c=Math.abs(l)0&&(e.d=t.d/n),e},j(e,[{key:"type",get:function(){return this._type}},{key:"x",set:function(e){this.n.x=e},get:function(){return this.n.x}},{key:"y",set:function(e){this.n.y=e},get:function(){return this.n.y}},{key:"z",set:function(e){this.n.z=e},get:function(){return this.n.z}},{key:"w",set:function(e){this.d=e},get:function(){return this.d}}]),e.prototype.transform=function(e){Hn.invert(Zc,e),Hn.transpose(Zc,Zc),Zn.set(Qc,this.n.x,this.n.y,this.n.z,this.d),Zn.transformMat4(Qc,Qc,Zc),bn.set(this.n,Qc.x,Qc.y,Qc.z),this.d=Qc.w},e}(),$c=new bn,el=new bn,tl=new bn,nl=new bn,il=new Pn,rl=function(e,t,n){il.m00=Math.abs(n.m00),il.m01=Math.abs(n.m01),il.m02=Math.abs(n.m02),il.m03=Math.abs(n.m04),il.m04=Math.abs(n.m05),il.m05=Math.abs(n.m06),il.m06=Math.abs(n.m08),il.m07=Math.abs(n.m09),il.m08=Math.abs(n.m10),bn.transformMat3(e,t,il)},al=function(){function e(e,t,n,i,r,a){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=1),void 0===r&&(r=1),void 0===a&&(a=1),this.center=void 0,this.halfExtents=void 0,this._type=void 0,this._type=xa.SHAPE_AABB,this.center=new bn(e,t,n),this.halfExtents=new bn(i,r,a)}e.create=function(t,n,i,r,a,s){return new e(t,n,i,r,a,s)},e.clone=function(t){return new e(t.center.x,t.center.y,t.center.z,t.halfExtents.x,t.halfExtents.y,t.halfExtents.z)},e.copy=function(e,t){return bn.copy(e.center,t.center),bn.copy(e.halfExtents,t.halfExtents),e},e.fromPoints=function(e,t,n){return bn.add($c,n,t),bn.subtract(el,n,t),bn.multiplyScalar(e.center,$c,.5),bn.multiplyScalar(e.halfExtents,el,.5),e},e.set=function(e,t,n,i,r,a,s){return bn.set(e.center,t,n,i),bn.set(e.halfExtents,r,a,s),e},e.merge=function(t,n,i){return bn.subtract($c,n.center,n.halfExtents),bn.subtract(el,i.center,i.halfExtents),bn.add(tl,n.center,n.halfExtents),bn.add(nl,i.center,i.halfExtents),bn.max(nl,tl,nl),bn.min(tl,$c,el),e.fromPoints(t,tl,nl)},e.toBoundingSphere=function(e,t){t.getBoundary($c,el),e.center.set($c),e.radius=0,bn.subtract(tl,el,e.center);var n=tl.length(),i=.5*n;return e.radius+=i,bn.multiplyScalar(tl,tl,i/n),bn.add(e.center,e.center,tl),e},e.transform=function(e,t,n){return bn.transformMat4(e.center,t.center,n),rl(e.halfExtents,t.halfExtents,n),e},j(e,[{key:"type",get:function(){return this._type}}]);var t=e.prototype;return t.getBoundary=function(e,t){bn.subtract(e,this.center,this.halfExtents),bn.add(t,this.center,this.halfExtents)},t.transform=function(e,t,n,i,r){bn.transformMat4(r.center,this.center,e),rl(r.halfExtents,this.halfExtents,e)},t.clone=function(){return e.clone(this)},t.copy=function(t){return e.copy(this,t)},e}(),sl=new bn,ol=new bn,cl=new Pn,ll=function(){function e(e,t,n,i,r,a,s,o,c,l,u,h,_,f,d){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=1),void 0===r&&(r=1),void 0===a&&(a=1),void 0===s&&(s=1),void 0===o&&(o=0),void 0===c&&(c=0),void 0===l&&(l=0),void 0===u&&(u=1),void 0===h&&(h=0),void 0===_&&(_=0),void 0===f&&(f=0),void 0===d&&(d=1),this.center=void 0,this.halfExtents=void 0,this.orientation=void 0,this._type=void 0,this._type=xa.SHAPE_OBB,this.center=new bn(e,t,n),this.halfExtents=new bn(i,r,a),this.orientation=new Pn(s,o,c,l,u,h,_,f,d)}e.create=function(t,n,i,r,a,s,o,c,l,u,h,_,f,d,p){return new e(t,n,i,r,a,s,o,c,l,u,h,_,f,d,p)},e.clone=function(t){return new e(t.center.x,t.center.y,t.center.z,t.halfExtents.x,t.halfExtents.y,t.halfExtents.z,t.orientation.m00,t.orientation.m01,t.orientation.m02,t.orientation.m03,t.orientation.m04,t.orientation.m05,t.orientation.m06,t.orientation.m07,t.orientation.m08)},e.copy=function(e,t){return bn.copy(e.center,t.center),bn.copy(e.halfExtents,t.halfExtents),Pn.copy(e.orientation,t.orientation),e},e.fromPoints=function(e,t,n){return bn.multiplyScalar(e.center,bn.add(sl,t,n),.5),bn.multiplyScalar(e.halfExtents,bn.subtract(ol,n,t),.5),Pn.identity(e.orientation),e},e.set=function(e,t,n,i,r,a,s,o,c,l,u,h,_,f,d,p){return bn.set(e.center,t,n,i),bn.set(e.halfExtents,r,a,s),Pn.set(e.orientation,o,c,l,u,h,_,f,d,p),e},j(e,[{key:"type",get:function(){return this._type}}]);var t=e.prototype;return t.getBoundary=function(e,t){!function(e,t,n){cl.m00=Math.abs(n.m00),cl.m01=Math.abs(n.m01),cl.m02=Math.abs(n.m02),cl.m03=Math.abs(n.m03),cl.m04=Math.abs(n.m04),cl.m05=Math.abs(n.m05),cl.m06=Math.abs(n.m06),cl.m07=Math.abs(n.m07),cl.m08=Math.abs(n.m08),bn.transformMat3(e,t,cl)}(sl,this.halfExtents,this.orientation),bn.subtract(e,this.center,sl),bn.add(t,this.center,sl)},t.transform=function(e,t,n,i,r){bn.transformMat4(r.center,this.center,e),Pn.fromQuat(r.orientation,n),bn.multiply(r.halfExtents,this.halfExtents,i)},t.translateAndRotate=function(e,t,n){bn.transformMat4(n.center,this.center,e),Pn.fromQuat(n.orientation,t)},t.setScale=function(e,t){bn.multiply(t.halfExtents,this.halfExtents,e)},e}(),ul=function(){function e(e,t,n){void 0===e&&(e=.5),void 0===t&&(t=.5),void 0===n&&(n=1),this._type=void 0,this.radius=void 0,this.halfHeight=void 0,this.axis=void 0,this.center=void 0,this.rotation=void 0,this.ellipseCenter0=void 0,this.ellipseCenter1=void 0,this._type=xa.SHAPE_CAPSULE,this.radius=e,this.halfHeight=t,this.axis=n,this.center=new bn,this.rotation=new Dn,this.ellipseCenter0=new bn(0,t,0),this.ellipseCenter1=new bn(0,-t,0),this.updateCache()}j(e,[{key:"type",get:function(){return this._type}}]);var t=e.prototype;return t.transform=function(e,t,n,i,r){var a=i,s=An(a);r.radius=this.radius*Math.abs(s);var o=(this.halfHeight+this.radius)*Math.abs(a.y)-r.radius;o<0&&(o=0),r.halfHeight=o,bn.transformMat4(r.center,this.center,e),Dn.multiply(r.rotation,this.rotation,n),r.updateCache()},t.updateCache=function(){this.updateLocalCenter(),bn.transformQuat(this.ellipseCenter0,this.ellipseCenter0,this.rotation),bn.transformQuat(this.ellipseCenter1,this.ellipseCenter1,this.rotation),this.ellipseCenter0.add(this.center),this.ellipseCenter1.add(this.center)},t.updateLocalCenter=function(){var e=this.halfHeight;switch(this.axis){case 0:this.ellipseCenter0.set(e,0,0),this.ellipseCenter1.set(-e,0,0);break;case 1:this.ellipseCenter0.set(0,e,0),this.ellipseCenter1.set(0,-e,0);break;case 2:this.ellipseCenter0.set(0,0,e),this.ellipseCenter1.set(0,0,-e)}},e}(),hl=new Array(8);hl[0]=new bn(1,1,1),hl[1]=new bn(-1,1,1),hl[2]=new bn(-1,-1,1),hl[3]=new bn(1,-1,1),hl[4]=new bn(1,1,-1),hl[5]=new bn(-1,1,-1),hl[6]=new bn(-1,-1,-1),hl[7]=new bn(1,-1,-1);var _l,fl,dl,pl=function(){function e(){this._type=void 0,this.planes=void 0,this.vertices=void 0,this._type=xa.SHAPE_FRUSTUM,this.planes=new Array(6);for(var e=0;e<6;++e)this.planes[e]=Jc.create(0,0,0,0);this.vertices=new Array(8);for(var t=0;t<8;++t)this.vertices[t]=new bn}e.create=function(){return new e},e.clone=function(t){return e.copy(new e,t)},e.copy=function(e,t){e._type=t._type;for(var n=0;n<6;++n)Jc.copy(e.planes[n],t.planes[n]);for(var i=0;i<8;++i)bn.copy(e.vertices[i],t.vertices[i]);return e},j(e,[{key:"accurate",set:function(e){this._type=e?xa.SHAPE_FRUSTUM_ACCURATE:xa.SHAPE_FRUSTUM}},{key:"type",get:function(){return this._type}}]);var t=e.prototype;return t.update=function(e,t){if(bn.set(this.planes[0].n,e.m03+e.m00,e.m07+e.m04,e.m11+e.m08),this.planes[0].d=-(e.m15+e.m12),bn.set(this.planes[1].n,e.m03-e.m00,e.m07-e.m04,e.m11-e.m08),this.planes[1].d=-(e.m15-e.m12),bn.set(this.planes[2].n,e.m03+e.m01,e.m07+e.m05,e.m11+e.m09),this.planes[2].d=-(e.m15+e.m13),bn.set(this.planes[3].n,e.m03-e.m01,e.m07-e.m05,e.m11-e.m09),this.planes[3].d=-(e.m15-e.m13),bn.set(this.planes[4].n,e.m03+e.m02,e.m07+e.m06,e.m11+e.m10),this.planes[4].d=-(e.m15+e.m14),bn.set(this.planes[5].n,e.m03-e.m02,e.m07-e.m06,e.m11-e.m10),this.planes[5].d=-(e.m15-e.m14),this._type===xa.SHAPE_FRUSTUM_ACCURATE){for(var n=0;n<6;n++){var i=this.planes[n],r=1/i.n.length();bn.multiplyScalar(i.n,i.n,r),i.d*=r}for(var a=0;a<8;a++)bn.transformMat4(this.vertices[a],hl[a],t)}},t.transform=function(e){if(this._type===xa.SHAPE_FRUSTUM_ACCURATE){for(var t=0;t<8;t++)bn.transformMat4(this.vertices[t],this.vertices[t],e);Jc.fromPoints(this.planes[0],this.vertices[1],this.vertices[5],this.vertices[6]),Jc.fromPoints(this.planes[1],this.vertices[3],this.vertices[7],this.vertices[4]),Jc.fromPoints(this.planes[2],this.vertices[6],this.vertices[7],this.vertices[3]),Jc.fromPoints(this.planes[3],this.vertices[0],this.vertices[4],this.vertices[5]),Jc.fromPoints(this.planes[4],this.vertices[2],this.vertices[3],this.vertices[0]),Jc.fromPoints(this.planes[0],this.vertices[7],this.vertices[6],this.vertices[5])}},e}();function ml(e,t){if(t&&0!==e){for(var n=t.vertices,i=Cr.VERTICES,r=0;r<8;++r)Or.setVec3(e,i,n[r]),i+=3;for(var a=t.planes,s=Cr.PLANES,o=0;o<6;o++,s+=4)Or.setVec4(e,s,a[o])}}pl.createOrtho=(_l=new bn,function(e,t,n,i,r,a){var s=t/2,o=n/2;bn.set(_l,s,o,i),bn.transformMat4(e.vertices[0],_l,a),bn.set(_l,-s,o,i),bn.transformMat4(e.vertices[1],_l,a),bn.set(_l,-s,-o,i),bn.transformMat4(e.vertices[2],_l,a),bn.set(_l,s,-o,i),bn.transformMat4(e.vertices[3],_l,a),bn.set(_l,s,o,r),bn.transformMat4(e.vertices[4],_l,a),bn.set(_l,-s,o,r),bn.transformMat4(e.vertices[5],_l,a),bn.set(_l,-s,-o,r),bn.transformMat4(e.vertices[6],_l,a),bn.set(_l,s,-o,r),bn.transformMat4(e.vertices[7],_l,a),Jc.fromPoints(e.planes[0],e.vertices[1],e.vertices[6],e.vertices[5]),Jc.fromPoints(e.planes[1],e.vertices[3],e.vertices[4],e.vertices[7]),Jc.fromPoints(e.planes[2],e.vertices[6],e.vertices[3],e.vertices[7]),Jc.fromPoints(e.planes[3],e.vertices[0],e.vertices[5],e.vertices[4]),Jc.fromPoints(e.planes[4],e.vertices[2],e.vertices[0],e.vertices[3]),Jc.fromPoints(e.planes[0],e.vertices[7],e.vertices[5],e.vertices[6])}),function(e){e[e.Default=0]="Default",e[e.Normal=1]="Normal",e[e.Loop=2]="Loop",e[e.ShouldWrap=4]="ShouldWrap",e[e.Clamp=8]="Clamp",e[e.PingPong=22]="PingPong",e[e.Reverse=36]="Reverse"}(fl||(fl={})),function(e){e[e.Default=fl.Default]="Default",e[e.Normal=fl.Normal]="Normal",e[e.Reverse=fl.Reverse]="Reverse",e[e.Loop=fl.Loop]="Loop",e[e.LoopReverse=fl.Loop|fl.Reverse]="LoopReverse",e[e.PingPong=fl.PingPong]="PingPong",e[e.PingPongReverse=fl.PingPong|fl.Reverse]="PingPongReverse"}(dl||(dl={})),ht(dl);var gl=function(){function e(e){this.ratio=0,this.time=0,this.direction=1,this.stopped=!0,this.iterations=0,this.frameIndex=void 0,e&&this.set(e)}return e.prototype.set=function(e){this.ratio=e.ratio,this.time=e.time,this.direction=e.direction,this.stopped=e.stopped,this.iterations=e.iterations,this.frameIndex=e.frameIndex},e}(),vl=ct({Default:fl.Default,Normal:fl.Normal,Clamp:fl.Clamp,Loop:fl.Loop,PingPong:fl.PingPong}),yl=function(){this.time=0,this.value=0,this.inTangent=0,this.outTangent=0};$t.fastDefine("cc.Keyframe",yl,{time:0,value:0,inTangent:0,outTangent:0});var Sl=function(){function e(){this.index=void 0,this.time=void 0,this.endTime=void 0,this.coefficient=void 0,this.index=-1,this.time=0,this.endTime=0,this.coefficient=new Float32Array(4)}return e.prototype.evaluate=function(e){return t=e-this.time,n=this.coefficient,t*(t*(t*n[0]+n[1])+n[2])+n[3];var t,n},e}(),El=function(){function e(t){void 0===t&&(t=null),this.keyFrames=void 0,this.preWrapMode=vl.Loop,this.postWrapMode=vl.Clamp,this.cachedKey=void 0,this.keyFrames=t||[].concat(e.defaultKF),this.cachedKey=new Sl}var t=e.prototype;return t.addKey=function(e){null==this.keyFrames&&(this.keyFrames=[]),this.keyFrames.push(e)},t.evaluate_slow=function(e){var t=e,n=e<0?this.preWrapMode:this.postWrapMode,i=this.keyFrames[0].time,r=this.keyFrames[this.keyFrames.length-1].time;switch(n){case vl.Loop:t=Sn(e-i,r-i)+i;break;case vl.PingPong:t=En(e-i,r-i)+i;break;case vl.Default:case vl.Normal:case vl.Clamp:default:t=cn(e,i,r)}var a=0;if(t>this.keyFrames[0].time)if(t>=this.keyFrames[this.keyFrames.length-1].time)a=this.keyFrames.length-2;else for(var s=0;s=this.keyFrames[0].time&&t<=this.keyFrames[s+1].time){a=s;break}var o=this.keyFrames[a],c=this.keyFrames[a+1],l=Tn(o.time,c.time,t),u=c.time-o.time,h=o.outTangent*u,_=c.inTangent*u,f=l*l,d=f*l,p=d-2*f+l,m=d-f,g=-2*d+3*f;return(2*d-3*f+1)*o.value+p*h+m*_+g*c.value},t.evaluate=function(e){var t=e,n=e<0?this.preWrapMode:this.postWrapMode,i=this.keyFrames[0].time,r=this.keyFrames[this.keyFrames.length-1].time;switch(n){case vl.Loop:t=Sn(e-i,r-i)+i;break;case vl.PingPong:t=En(e-i,r-i)+i;break;case vl.Default:case vl.Normal:case vl.Clamp:default:t=cn(e,i,r)}if(t>=this.cachedKey.time&&tthis.keyFrames[n].time)for(var i=0;i<3;i++){var r=n+i;if(r+1t)return r}else for(var a=0;a<3;a++){var s=n-a;if(s>=0&&this.keyFrames[s-1].time<=t)return s-1}for(var o,c=0,l=this.keyFrames.length;l-c>1;)o=Math.floor((c+l)/2),this.keyFrames[o].time>=t?l=o:c=o;return c},e}();function Tl(e,t){console.warn(e+" is deprecated, please use "+t+" instead.")}El.defaultKF=[{time:0,value:1,inTangent:0,outTangent:0},{time:1,value:1,inTangent:0,outTangent:0}],$t.fastDefine("cc.AnimationCurve",El,{preWrapMode:vl.Default,postWrapMode:vl.Default,keyFrames:[]}),se(Xc,"intersect",[{name:"ray_aabb",newName:"rayAABB"},{name:"ray_plane",newName:"rayPlane"},{name:"ray_triangle",newName:"rayTriangle"},{name:"ray_sphere",newName:"raySphere"},{name:"ray_obb",newName:"rayOBB"},{name:"ray_capsule",newName:"rayCapsule"},{name:"ray_subMesh",newName:"raySubMesh"},{name:"ray_mesh",newName:"rayMesh"},{name:"ray_model",newName:"rayModel"},{name:"line_plane",newName:"linePlane"},{name:"line_triangle",newName:"lineTriangle"},{name:"line_aabb",newName:"lineAABB"},{name:"line_obb",newName:"lineOBB"},{name:"line_sphere",newName:"lineSphere"},{name:"aabb_aabb",newName:"aabbWithAABB"},{name:"aabb_obb",newName:"aabbWithOBB"},{name:"aabb_plane",newName:"aabbPlane"},{name:"aabb_frustum",newName:"aabbFrustum"},{name:"aabbFrustum_accurate",newName:"aabbFrustumAccurate"},{name:"obb_point",newName:"obbPoint"},{name:"obb_plane",newName:"obbPlane"},{name:"obb_frustum",newName:"obbFrustum"},{name:"obbFrustum_accurate",newName:"obbFrustumAccurate"},{name:"obb_obb",newName:"obbWithOBB"},{name:"obb_capsule",newName:"obbCapsule"},{name:"sphere_plane",newName:"spherePlane"},{name:"sphere_frustum",newName:"sphereFrustum"},{name:"sphereFrustum_accurate",newName:"sphereFrustumAccurate"},{name:"sphere_sphere",newName:"sphereWithSphere"},{name:"sphere_aabb",newName:"sphereAABB"},{name:"sphere_obb",newName:"sphereOBB"},{name:"sphere_capsule",newName:"sphereCapsule"},{name:"capsule_capsule",newName:"capsuleWithCapsule"}]);var Al=function(e){function t(){var t;return t=e.call(this)||this,Tl("line","Line"),t}return X(t,e),t}(Ca),xl=function(e){function t(){var t;return t=e.call(this)||this,Tl("plane","Plane"),t}return X(t,e),t}(Jc),Cl=function(e){function t(){var t;return t=e.call(this)||this,Tl("ray","Ray"),t}return X(t,e),t}(Ra),Rl=function(e){function t(){var t;return t=e.call(this)||this,Tl("triangle","Triangle"),t}return X(t,e),t}(Da),bl=function(e){function t(){var t;return t=e.call(this)||this,Tl("sphere","Sphere"),t}return X(t,e),t}(Na),wl=function(e){function t(){var t;return t=e.call(this)||this,Tl("aabb","AABB"),t}return X(t,e),t}(al),Il=function(e){function t(){var t;return t=e.call(this)||this,Tl("obb","OBB"),t}return X(t,e),t}(ll),Ol=function(e){function t(){var t;return t=e.call(this)||this,Tl("capsule","Capsule"),t}return X(t,e),t}(ul),Pl=function(e){function t(){var t;return t=e.call(this)||this,Tl("frustum","Frustum"),t}return X(t,e),t}(pl),Ml=Object.freeze({__proto__:null,distance:Aa,enums:xa,intersect:Xc,Line:Ca,Plane:Jc,Ray:Ra,Triangle:Da,Sphere:Na,AABB:al,OBB:ll,Capsule:ul,Frustum:pl,Keyframe:yl,AnimationCurve:El,get ERaycastMode(){return ko},line:Al,plane:xl,ray:Cl,triangle:Rl,sphere:bl,aabb:wl,obb:Il,capsule:Ol,frustum:Pl});e("geometry",Ml);var Nl,Dl,Bl={NONE:0,IGNORE_RAYCAST:1<<20,GIZMOS:1<<21,EDITOR:1<<22,UI_3D:1<<23,SCENE_GIZMO:1<<24,UI_2D:1<<25,PROFILER:1<<28,DEFAULT:1<<30,ALL:4294967295},Ll=e("Layers",function(){function e(){}return e.makeMaskInclude=function(e){for(var t,n=0,i=Z(e);!(t=i()).done;)n|=t.value;return n},e.makeMaskExclude=function(t){return~e.makeMaskInclude(t)},e.addLayer=function(t,n){void 0!==n?n>19||n<0?console.warn("maximum layers reached."):(e.Enum[t]=1<19||t<0?console.warn("do not change buildin layers."):(delete e.Enum[e.Enum[t]],delete e.Enum[t],delete e.BitMask[e.BitMask[t]],delete e.BitMask[t])},e}());Ll.Enum=ct(Bl),Ll.BitMask=ot(q({},Bl)),i.Layers=Ll,function(e){e[e.DEFAULT=100]="DEFAULT",e[e.UI=200]="UI"}(Nl||(Nl={})),i.RenderPassStage=Nl,function(e){e[e.MIN=0]="MIN",e[e.MAX=255]="MAX",e[e.DEFAULT=128]="DEFAULT"}(Dl||(Dl={}));var Fl,zl={bindings:[],layouts:{}},Ul={bindings:[],layouts:{}};!function(e){e[e.UBO_GLOBAL=0]="UBO_GLOBAL",e[e.UBO_CAMERA=1]="UBO_CAMERA",e[e.UBO_SHADOW=2]="UBO_SHADOW",e[e.SAMPLER_SHADOWMAP=3]="SAMPLER_SHADOWMAP",e[e.SAMPLER_ENVIRONMENT=4]="SAMPLER_ENVIRONMENT",e[e.SAMPLER_SPOT_LIGHTING_MAP=5]="SAMPLER_SPOT_LIGHTING_MAP",e[e.COUNT=6]="COUNT"}(Fl||(Fl={}));var Gl,kl=Fl.SAMPLER_SHADOWMAP,Hl=Fl.COUNT-kl;!function(e){e[e.UBO_LOCAL=0]="UBO_LOCAL",e[e.UBO_FORWARD_LIGHTS=1]="UBO_FORWARD_LIGHTS",e[e.UBO_SKINNING_ANIMATION=2]="UBO_SKINNING_ANIMATION",e[e.UBO_SKINNING_TEXTURE=3]="UBO_SKINNING_TEXTURE",e[e.UBO_MORPH=4]="UBO_MORPH",e[e.SAMPLER_JOINTS=5]="SAMPLER_JOINTS",e[e.SAMPLER_MORPH_POSITION=6]="SAMPLER_MORPH_POSITION",e[e.SAMPLER_MORPH_NORMAL=7]="SAMPLER_MORPH_NORMAL",e[e.SAMPLER_MORPH_TANGENT=8]="SAMPLER_MORPH_TANGENT",e[e.SAMPLER_LIGHTMAP=9]="SAMPLER_LIGHTMAP",e[e.SAMPLER_SPRITE=10]="SAMPLER_SPRITE",e[e.COUNT=11]="COUNT"}(Gl||(Gl={}));var Vl,Wl=Gl.SAMPLER_JOINTS,jl=Gl.COUNT-Wl;!function(e){e[e.GLOBAL=0]="GLOBAL",e[e.MATERIAL=1]="MATERIAL",e[e.LOCAL=2]="LOCAL"}(Vl||(Vl={}));var ql=new Ls;ql.bufferOffsets=[0,kl+Wl,kl],ql.samplerOffsets=[-kl,Hl+jl,Hl-Wl],ql.flexibleSet=1;var Xl=function(){};Xl.SIZE=4*(Xl.COUNT=4+(Xl.SCREEN_SIZE_OFFSET=4+(Xl.NATIVE_SIZE_OFFSET=4+(Xl.TIME_OFFSET=0)))),Xl.NAME="CCGlobal",Xl.BINDING=Fl.UBO_GLOBAL,Xl.DESCRIPTOR=new No(Xl.BINDING,as.UNIFORM_BUFFER,1,rs.ALL),Xl.LAYOUT=new So(Vl.GLOBAL,Xl.BINDING,Xl.NAME,[new yo("cc_time",Fa.FLOAT4,1),new yo("cc_screenSize",Fa.FLOAT4,1),new yo("cc_nativeSize",Fa.FLOAT4,1)],1),zl.layouts[Xl.NAME]=Xl.LAYOUT,zl.bindings[Xl.BINDING]=Xl.DESCRIPTOR;var Yl=function(){};Yl.SIZE=4*(Yl.COUNT=4+(Yl.GLOBAL_FOG_ADD_OFFSET=4+(Yl.GLOBAL_FOG_BASE_OFFSET=4+(Yl.GLOBAL_FOG_COLOR_OFFSET=4+(Yl.AMBIENT_GROUND_OFFSET=4+(Yl.AMBIENT_SKY_OFFSET=4+(Yl.MAIN_LIT_COLOR_OFFSET=4+(Yl.MAIN_LIT_DIR_OFFSET=4+(Yl.EXPOSURE_OFFSET=4+(Yl.SCREEN_SCALE_OFFSET=4+(Yl.CAMERA_POS_OFFSET=16+(Yl.MAT_VIEW_PROJ_INV_OFFSET=16+(Yl.MAT_VIEW_PROJ_OFFSET=16+(Yl.MAT_PROJ_INV_OFFSET=16+(Yl.MAT_PROJ_OFFSET=16+(Yl.MAT_VIEW_INV_OFFSET=16+(Yl.MAT_VIEW_OFFSET=0))))))))))))))))),Yl.NAME="CCCamera",Yl.BINDING=Fl.UBO_CAMERA,Yl.DESCRIPTOR=new No(Yl.BINDING,as.UNIFORM_BUFFER,1,rs.ALL),Yl.LAYOUT=new So(Vl.GLOBAL,Yl.BINDING,Yl.NAME,[new yo("cc_matView",Fa.MAT4,1),new yo("cc_matViewInv",Fa.MAT4,1),new yo("cc_matProj",Fa.MAT4,1),new yo("cc_matProjInv",Fa.MAT4,1),new yo("cc_matViewProj",Fa.MAT4,1),new yo("cc_matViewProjInv",Fa.MAT4,1),new yo("cc_cameraPos",Fa.FLOAT4,1),new yo("cc_screenScale",Fa.FLOAT4,1),new yo("cc_exposure",Fa.FLOAT4,1),new yo("cc_mainLitDir",Fa.FLOAT4,1),new yo("cc_mainLitColor",Fa.FLOAT4,1),new yo("cc_ambientSky",Fa.FLOAT4,1),new yo("cc_ambientGround",Fa.FLOAT4,1),new yo("cc_fogColor",Fa.FLOAT4,1),new yo("cc_fogBase",Fa.FLOAT4,1),new yo("cc_fogAdd",Fa.FLOAT4,1)],1),zl.layouts[Yl.NAME]=Yl.LAYOUT,zl.bindings[Yl.BINDING]=Yl.DESCRIPTOR;var Kl=function(){};Kl.SIZE=4*(Kl.COUNT=4+(Kl.SHADOW_INFO_OFFSET=4+(Kl.SHADOW_COLOR_OFFSET=16+(Kl.MAT_LIGHT_VIEW_PROJ_OFFSET=16+(Kl.MAT_LIGHT_PLANE_PROJ_OFFSET=0))))),Kl.NAME="CCShadow",Kl.BINDING=Fl.UBO_SHADOW,Kl.DESCRIPTOR=new No(Kl.BINDING,as.UNIFORM_BUFFER,1,rs.ALL),Kl.LAYOUT=new So(Vl.GLOBAL,Kl.BINDING,Kl.NAME,[new yo("cc_matLightPlaneProj",Fa.MAT4,1),new yo("cc_matLightViewProj",Fa.MAT4,1),new yo("cc_shadowColor",Fa.FLOAT4,1),new yo("cc_shadowInfo",Fa.FLOAT4,1)],1),zl.layouts[Kl.NAME]=Kl.LAYOUT,zl.bindings[Kl.BINDING]=Kl.DESCRIPTOR;var Zl=Fl.SAMPLER_SHADOWMAP,Ql=new No(Zl,as.SAMPLER,1,rs.FRAGMENT),Jl=new Eo(Vl.GLOBAL,Zl,"cc_shadowMap",Fa.SAMPLER2D,1);zl.layouts.cc_shadowMap=Jl,zl.bindings[Zl]=Ql;var $l=Fl.SAMPLER_ENVIRONMENT,eu=new No($l,as.SAMPLER,1,rs.FRAGMENT),tu=new Eo(Vl.GLOBAL,$l,"cc_environment",Fa.SAMPLER_CUBE,1);zl.layouts.cc_environment=tu,zl.bindings[$l]=eu;var nu=Fl.SAMPLER_SPOT_LIGHTING_MAP,iu=new No(nu,as.SAMPLER,1,rs.FRAGMENT),ru=new Eo(Vl.GLOBAL,nu,"cc_spotLightingMap",Fa.SAMPLER2D,1);zl.layouts.cc_spotLightingMap=ru,zl.bindings[nu]=iu;var au=function(){};au.SIZE=4*(au.COUNT=4+(au.LIGHTINGMAP_UVPARAM=16+(au.MAT_WORLD_IT_OFFSET=16+(au.MAT_WORLD_OFFSET=0)))),au.NAME="CCLocal",au.BINDING=Gl.UBO_LOCAL,au.DESCRIPTOR=new No(au.BINDING,as.UNIFORM_BUFFER,1,rs.VERTEX),au.LAYOUT=new So(Vl.LOCAL,au.BINDING,au.NAME,[new yo("cc_matWorld",Fa.MAT4,1),new yo("cc_matWorldIT",Fa.MAT4,1),new yo("cc_lightingMapUVParam",Fa.FLOAT4,1)],1),Ul.layouts[au.NAME]=au.LAYOUT,Ul.bindings[au.BINDING]=au.DESCRIPTOR;var su=function(){};su.BATCHING_COUNT=10,su.MAT_WORLDS_OFFSET=0,su.SIZE=4*(su.COUNT=16*su.BATCHING_COUNT),su.NAME="CCLocalBatched",su.BINDING=Gl.UBO_LOCAL,su.DESCRIPTOR=new No(su.BINDING,as.UNIFORM_BUFFER,1,rs.VERTEX),su.LAYOUT=new So(Vl.LOCAL,su.BINDING,su.NAME,[new yo("cc_matWorlds",Fa.MAT4,su.BATCHING_COUNT)],1),Ul.layouts[su.NAME]=su.LAYOUT,Ul.bindings[su.BINDING]=su.DESCRIPTOR;var ou=function(){};ou.LIGHTS_PER_PASS=1,ou.SIZE=4*(ou.COUNT=(ou.LIGHT_DIR_OFFSET=(ou.LIGHT_SIZE_RANGE_ANGLE_OFFSET=(ou.LIGHT_COLOR_OFFSET=(ou.LIGHT_POS_OFFSET=0)+4*ou.LIGHTS_PER_PASS)+4*ou.LIGHTS_PER_PASS)+4*ou.LIGHTS_PER_PASS)+4*ou.LIGHTS_PER_PASS),ou.NAME="CCForwardLight",ou.BINDING=Gl.UBO_FORWARD_LIGHTS,ou.DESCRIPTOR=new No(ou.BINDING,as.DYNAMIC_UNIFORM_BUFFER,1,rs.FRAGMENT),ou.LAYOUT=new So(Vl.LOCAL,ou.BINDING,ou.NAME,[new yo("cc_lightPos",Fa.FLOAT4,ou.LIGHTS_PER_PASS),new yo("cc_lightColor",Fa.FLOAT4,ou.LIGHTS_PER_PASS),new yo("cc_lightSizeRangeAngle",Fa.FLOAT4,ou.LIGHTS_PER_PASS),new yo("cc_lightDir",Fa.FLOAT4,ou.LIGHTS_PER_PASS)],1),Ul.layouts[ou.NAME]=ou.LAYOUT,Ul.bindings[ou.BINDING]=ou.DESCRIPTOR;var cu=function(){};cu.SIZE=4*(cu.COUNT=4+(cu.JOINTS_TEXTURE_INFO_OFFSET=0)),cu.NAME="CCSkinningTexture",cu.BINDING=Gl.UBO_SKINNING_TEXTURE,cu.DESCRIPTOR=new No(cu.BINDING,as.UNIFORM_BUFFER,1,rs.VERTEX),cu.LAYOUT=new So(Vl.LOCAL,cu.BINDING,cu.NAME,[new yo("cc_jointTextureInfo",Fa.FLOAT4,1)],1),Ul.layouts[cu.NAME]=cu.LAYOUT,Ul.bindings[cu.BINDING]=cu.DESCRIPTOR;var lu=function(){};lu.SIZE=4*(lu.COUNT=4+(lu.JOINTS_ANIM_INFO_OFFSET=0)),lu.NAME="CCSkinningAnimation",lu.BINDING=Gl.UBO_SKINNING_ANIMATION,lu.DESCRIPTOR=new No(lu.BINDING,as.UNIFORM_BUFFER,1,rs.VERTEX),lu.LAYOUT=new So(Vl.LOCAL,lu.BINDING,lu.NAME,[new yo("cc_jointAnimInfo",Fa.FLOAT4,1)],1),Ul.layouts[lu.NAME]=lu.LAYOUT,Ul.bindings[lu.BINDING]=lu.DESCRIPTOR;var uu=function(){};uu.SIZE=4*(uu.COUNT=360+(uu.JOINTS_OFFSET=0)),uu.NAME="CCSkinning",uu.BINDING=Gl.UBO_SKINNING_TEXTURE,uu.DESCRIPTOR=new No(uu.BINDING,as.UNIFORM_BUFFER,1,rs.VERTEX),uu.LAYOUT=new So(Vl.LOCAL,uu.BINDING,uu.NAME,[new yo("cc_joints",Fa.FLOAT4,90)],1),Ul.layouts[uu.NAME]=uu.LAYOUT,Ul.bindings[uu.BINDING]=uu.DESCRIPTOR;var hu=function(){};hu.MAX_MORPH_TARGET_COUNT=60,hu.OFFSET_OF_WEIGHTS=0,hu.OFFSET_OF_VERTICES_COUNT=4+(hu.OFFSET_OF_DISPLACEMENT_TEXTURE_HEIGHT=4+(hu.OFFSET_OF_DISPLACEMENT_TEXTURE_WIDTH=4*hu.MAX_MORPH_TARGET_COUNT)),hu.COUNT_BASE_4_BYTES=4*Math.ceil(hu.MAX_MORPH_TARGET_COUNT/4)+4,hu.SIZE=4*hu.COUNT_BASE_4_BYTES,hu.NAME="CCMorph",hu.BINDING=Gl.UBO_MORPH,hu.DESCRIPTOR=new No(hu.BINDING,as.UNIFORM_BUFFER,1,rs.VERTEX),hu.LAYOUT=new So(Vl.LOCAL,hu.BINDING,hu.NAME,[new yo("cc_displacementWeights",Fa.FLOAT4,hu.MAX_MORPH_TARGET_COUNT/4),new yo("cc_displacementTextureInfo",Fa.FLOAT4,1)],1),Ul.layouts[hu.NAME]=hu.LAYOUT,Ul.bindings[hu.BINDING]=hu.DESCRIPTOR;var _u=Gl.SAMPLER_JOINTS,fu=new No(_u,as.SAMPLER,1,rs.VERTEX),du=new Eo(Vl.LOCAL,_u,"cc_jointTexture",Fa.SAMPLER2D,1);Ul.layouts.cc_jointTexture=du,Ul.bindings[_u]=fu;var pu=Gl.SAMPLER_MORPH_POSITION,mu=new No(pu,as.SAMPLER,1,rs.VERTEX),gu=new Eo(Vl.LOCAL,pu,"cc_PositionDisplacements",Fa.SAMPLER2D,1);Ul.layouts.cc_PositionDisplacements=gu,Ul.bindings[pu]=mu;var vu=Gl.SAMPLER_MORPH_NORMAL,yu=new No(vu,as.SAMPLER,1,rs.VERTEX),Su=new Eo(Vl.LOCAL,vu,"cc_NormalDisplacements",Fa.SAMPLER2D,1);Ul.layouts.cc_NormalDisplacements=Su,Ul.bindings[vu]=yu;var Eu=Gl.SAMPLER_MORPH_TANGENT,Tu=new No(Eu,as.SAMPLER,1,rs.VERTEX),Au=new Eo(Vl.LOCAL,Eu,"cc_TangentDisplacements",Fa.SAMPLER2D,1);Ul.layouts.cc_TangentDisplacements=Au,Ul.bindings[Eu]=Tu;var xu=Gl.SAMPLER_LIGHTMAP,Cu=new No(xu,as.SAMPLER,1,rs.FRAGMENT),Ru=new Eo(Vl.LOCAL,xu,"cc_lightingMap",Fa.SAMPLER2D,1);Ul.layouts.cc_lightingMap=Ru,Ul.bindings[xu]=Cu;var bu=Gl.SAMPLER_SPRITE,wu=new No(bu,as.SAMPLER,1,rs.FRAGMENT),Iu=new Eo(Vl.LOCAL,bu,"cc_spriteTexture",Fa.SAMPLER2D,1);Ul.layouts.cc_spriteTexture=Iu,Ul.bindings[bu]=wu;var Ou,Pu,Mu,Nu,Du,Bu=Ll.makeMaskExclude([Ll.BitMask.UI_2D,Ll.BitMask.GIZMOS,Ll.BitMask.EDITOR,Ll.BitMask.SCENE_GIZMO,Ll.BitMask.PROFILER]),Lu=Ll.makeMaskExclude([Ll.BitMask.UI_2D,Ll.BitMask.PROFILER]),Fu=Ll.Enum.ALL;e("pipeline",Object.freeze({__proto__:null,PIPELINE_FLOW_FORWARD:"ForwardFlow",PIPELINE_FLOW_SHADOW:"ShadowFlow",PIPELINE_FLOW_SMAA:"SMAAFlow",PIPELINE_FLOW_TONEMAP:"ToneMapFlow",get RenderPassStage(){return Nl},get RenderPriority(){return Dl},globalDescriptorSetLayout:zl,localDescriptorSetLayout:Ul,get PipelineGlobalBindings(){return Fl},get ModelLocalBindings(){return Gl},get SetIndex(){return Vl},bindingMappingInfo:ql,UBOGlobal:Xl,UBOCamera:Yl,UBOShadow:Kl,UNIFORM_SHADOWMAP_BINDING:Zl,UNIFORM_ENVIRONMENT_BINDING:$l,UNIFORM_SPOT_LIGHTING_MAP_TEXTURE_BINDING:nu,UBOLocal:au,INST_MAT_WORLD:"a_matWorld0",UBOLocalBatched:su,UBOForwardLight:ou,JOINT_UNIFORM_CAPACITY:30,UBOSkinningTexture:cu,UBOSkinningAnimation:lu,INST_JOINT_ANIM_INFO:"a_jointAnimInfo",UBOSkinning:uu,UBOMorph:hu,UNIFORM_JOINT_TEXTURE_BINDING:_u,UNIFORM_POSITION_MORPH_TEXTURE_BINDING:pu,UNIFORM_NORMAL_MORPH_TEXTURE_BINDING:vu,UNIFORM_TANGENT_MORPH_TEXTURE_BINDING:Eu,UNIFORM_LIGHTMAP_TEXTURE_BINDING:xu,UNIFORM_SPRITE_TEXTURE_BINDING:bu,CAMERA_DEFAULT_MASK:Bu,CAMERA_EDITOR_MASK:Lu,MODEL_ALWAYS_MASK:Fu})),function(e){e[e.VERTICAL=0]="VERTICAL",e[e.HORIZONTAL=1]="HORIZONTAL"}(Ou||(Ou={})),function(e){e[e.ORTHO=0]="ORTHO",e[e.PERSPECTIVE=1]="PERSPECTIVE"}(Pu||(Pu={})),function(e){e[e.F1_8=0]="F1_8",e[e.F2_0=1]="F2_0",e[e.F2_2=2]="F2_2",e[e.F2_5=3]="F2_5",e[e.F2_8=4]="F2_8",e[e.F3_2=5]="F3_2",e[e.F3_5=6]="F3_5",e[e.F4_0=7]="F4_0",e[e.F4_5=8]="F4_5",e[e.F5_0=9]="F5_0",e[e.F5_6=10]="F5_6",e[e.F6_3=11]="F6_3",e[e.F7_1=12]="F7_1",e[e.F8_0=13]="F8_0",e[e.F9_0=14]="F9_0",e[e.F10_0=15]="F10_0",e[e.F11_0=16]="F11_0",e[e.F13_0=17]="F13_0",e[e.F14_0=18]="F14_0",e[e.F16_0=19]="F16_0",e[e.F18_0=20]="F18_0",e[e.F20_0=21]="F20_0",e[e.F22_0=22]="F22_0"}(Mu||(Mu={})),function(e){e[e.ISO100=0]="ISO100",e[e.ISO200=1]="ISO200",e[e.ISO400=2]="ISO400",e[e.ISO800=3]="ISO800"}(Nu||(Nu={})),function(e){e[e.D1=0]="D1",e[e.D2=1]="D2",e[e.D4=2]="D4",e[e.D8=3]="D8",e[e.D15=4]="D15",e[e.D30=5]="D30",e[e.D60=6]="D60",e[e.D125=7]="D125",e[e.D250=8]="D250",e[e.D500=9]="D500",e[e.D1000=10]="D1000",e[e.D2000=11]="D2000",e[e.D4000=12]="D4000"}(Du||(Du={}));var zu,Uu,Gu=[1.8,2,2.2,2.5,2.8,3.2,3.5,4,4.5,5,5.6,6.3,7.1,8,9,10,11,13,14,16,18,20,22],ku=[1,.5,1/4,1/8,1/15,1/30,1/60,.008,.004,.002,.001,5e-4,1/4e3],Hu=[100,200,400,800],Vu=new bn,Wu=new bn,ju=new Hn,qu=ds.STENCIL<<1,Xu=[],Yu=function(){function e(e){if(this.isWindowSize=!0,this.screenScale=void 0,this._device=void 0,this._scene=null,this._node=null,this._name=null,this._enabled=!1,this._proj=-1,this._aspect=void 0,this._orthoHeight=10,this._fovAxis=Ou.VERTICAL,this._fov=hn(45),this._nearClip=1,this._farClip=1e3,this._clearColor=new Ks(.2,.2,.2,1),this._viewport=new ti(0,0,1,1),this._curTransform=gs.IDENTITY,this._isProjDirty=!0,this._matView=new Hn,this._matViewInv=null,this._matProj=new Hn,this._matProjInv=new Hn,this._matViewProj=new Hn,this._matViewProjInv=new Hn,this._frustum=new pl,this._forward=new bn,this._position=new bn,this._priority=0,this._aperture=Mu.F16_0,this._apertureValue=void 0,this._shutter=Du.D125,this._shutterValue=0,this._iso=Nu.ISO100,this._isoValue=0,this._ec=0,this._poolHandle=0,this._frustumHandle=0,this._window=null,this._device=e,this._apertureValue=Gu[this._aperture],this._shutterValue=ku[this._shutter],this._isoValue=Hu[this._iso],this._aspect=this.screenScale=1,!Xu.length){var t=e.screenSpaceSignY;Xu[gs.IDENTITY]=new Hn(1,0,0,0,0,t),Xu[gs.ROTATE_90]=new Hn(0,1,0,0,-t,0),Xu[gs.ROTATE_180]=new Hn(-1,0,0,0,0,-t),Xu[gs.ROTATE_270]=new Hn(0,-1,0,0,t,0)}}var t=e.prototype;return t.initialize=function(e){this._name=e.name,this._node=e.node,this._proj=e.projection,this._priority=e.priority||0,this._aspect=this.screenScale=1;var t=this._poolHandle=vr.alloc();vr.set(t,fr.WIDTH,1),vr.set(t,fr.HEIGHT,1),vr.set(t,fr.CLEAR_FLAG,ds.NONE),vr.set(t,fr.CLEAR_DEPTH,1),vr.set(t,fr.NODE,this._node.handle),vr.set(t,fr.VISIBILITY,Bu),this._scene&&vr.set(t,fr.SCENE,this._scene.handle),this.updateExposure(),this.changeTargetWindow(e.window),console.log("Created Camera: "+this._name+" "+vr.get(t,fr.WIDTH)+"x"+vr.get(t,fr.HEIGHT))},t.destroy=function(){this._window&&this._window.detachCamera(this),this._name=null,this._poolHandle&&(vr.free(this._poolHandle),this._poolHandle=0,this._frustumHandle&&(Or.free(this._frustumHandle),this._frustumHandle=0))},t.attachToScene=function(e){this._scene=e,this._enabled=!0,vr.set(this._poolHandle,fr.SCENE,e.handle)},t.detachFromScene=function(){this._scene=null,this._enabled=!1,vr.set(this._poolHandle,fr.SCENE,0)},t.resize=function(e,t){var n=this._poolHandle;vr.set(n,fr.WIDTH,e),vr.set(n,fr.HEIGHT,t),this._aspect=e*this._viewport.width/(t*this._viewport.height),this._isProjDirty=!0},t.setFixedSize=function(e,t){var n=this._poolHandle;vr.set(n,fr.WIDTH,e),vr.set(n,fr.HEIGHT,t),this._aspect=e*this._viewport.width/(t*this._viewport.height),this.isWindowSize=!1},t.update=function(e){if(void 0===e&&(e=!1),this._node){var t=!1;(this._node.hasChangedFlags||e)&&(Hn.invert(this._matView,this._node.worldMatrix),vr.setMat4(this._poolHandle,fr.MAT_VIEW,this._matView),this._forward.x=-this._matView.m02,this._forward.y=-this._matView.m06,this._forward.z=-this._matView.m10,this._node.getWorldPosition(this._position),vr.setVec3(this._poolHandle,fr.POSITION,this._position),vr.setVec3(this._poolHandle,fr.FORWARD,this._forward),t=!0);var n=this._device.surfaceTransform;if(this._isProjDirty||this._curTransform!==n){this._curTransform=n;var i=this._device.screenSpaceSignY;if(this._window&&this._window.hasOffScreenAttachments&&(i*=this._device.UVSpaceSignY,n=gs.IDENTITY),this._proj===Pu.PERSPECTIVE)Hn.perspective(this._matProj,this._fov,this._aspect,this._nearClip,this._farClip,this._fovAxis===Ou.VERTICAL,this._device.clipSpaceMinZ,i,n);else{var r=this._orthoHeight*this._aspect,a=this._orthoHeight;Hn.ortho(this._matProj,-r,r,-a,a,this._nearClip,this._farClip,this._device.clipSpaceMinZ,i,n)}Hn.invert(this._matProjInv,this._matProj),vr.setMat4(this._poolHandle,fr.MAT_PROJ,this._matProj),vr.setMat4(this._poolHandle,fr.MAT_PROJ_INV,this._matProjInv),t=!0,this._isProjDirty=!1}t&&(Hn.multiply(this._matViewProj,this._matProj,this._matView),Hn.invert(this._matViewProjInv,this._matViewProj),this._frustum.update(this._matViewProj,this._matViewProjInv),vr.setMat4(this._poolHandle,fr.MAT_VIEW_PROJ,this._matViewProj),vr.setMat4(this._poolHandle,fr.MAT_VIEW_PROJ_INV,this._matViewProjInv),ml(this._frustumHandle,this._frustum))}},t.changeTargetWindow=function(e){void 0===e&&(e=null),this._window&&this._window.detachCamera(this);var t=e||i.director.root.mainWindow;t&&(t.attachCamera(this),this.resize(t.width,t.height),this._window=t,vr.set(this._poolHandle,fr.WINDOW,t.handle))},t.detachCamera=function(){this._window&&this._window.detachCamera(this)},t.screenPointToRay=function(e,t,n){if(!this._node)return null;var i=this._poolHandle,r=vr.get(i,fr.WIDTH),a=vr.get(i,fr.HEIGHT),s=this._viewport.x*r,o=this._viewport.y*a,c=this._viewport.width*r,l=this._viewport.height*a,u=this._proj===Pu.PERSPECTIVE,h=this._device.screenSpaceSignY,_=kn[this._curTransform];bn.set(Vu,(t-s)/c*2-1,(n-o)/l*2-1,u?1:-1);var f=Vu.x,d=Vu.y;return Vu.x=f*_[0]+d*_[2]*h,Vu.y=f*_[1]+d*_[3]*h,bn.transformMat4(u?Vu:e.o,Vu,this._matViewProjInv),u?(this._node.getWorldPosition(Wu),Ra.fromPoints(e,Wu,Vu)):bn.transformQuat(e.d,bn.FORWARD,this._node.worldRotation),e},t.screenToWorld=function(e,t){var n=this._poolHandle,i=vr.get(n,fr.WIDTH),r=vr.get(n,fr.HEIGHT),a=this._viewport.x*i,s=this._viewport.y*r,o=this._viewport.width*i,c=this._viewport.height*r,l=this._device.screenSpaceSignY,u=kn[this._curTransform];if(this._proj===Pu.PERSPECTIVE){bn.set(e,(t.x-a)/o*2-1,(t.y-s)/c*2-1,1);var h=e.x,_=e.y;e.x=h*u[0]+_*u[2]*l,e.y=h*u[1]+_*u[3]*l,bn.transformMat4(e,e,this._matViewProjInv),this._node&&this._node.getWorldPosition(Vu),bn.lerp(e,Vu,e,un(this._nearClip/this._farClip,1,t.z))}else{bn.set(e,(t.x-a)/o*2-1,(t.y-s)/c*2-1,2*t.z-1);var f=e.x,d=e.y;e.x=f*u[0]+d*u[2]*l,e.y=f*u[1]+d*u[3]*l,bn.transformMat4(e,e,this._matViewProjInv)}return e},t.worldToScreen=function(e,t){var n=this._poolHandle,i=vr.get(n,fr.WIDTH),r=vr.get(n,fr.HEIGHT),a=this._viewport.x*i,s=this._viewport.y*r,o=this._viewport.width*i,c=this._viewport.height*r,l=this._device.screenSpaceSignY,u=kn[this._curTransform];bn.transformMat4(e,t,this._matViewProj);var h=e.x,_=e.y;return e.x=h*u[0]+_*u[2]*l,e.y=h*u[1]+_*u[3]*l,e.x=a+.5*(e.x+1)*o,e.y=s+.5*(e.y+1)*c,e.z=.5*e.z+.5,e},t.worldMatrixToScreen=function(e,t,n,i){Hn.multiply(e,this._matViewProj,t),Hn.multiply(e,Xu[this._curTransform],e);var r=n/2,a=i/2;return Hn.identity(ju),Hn.transform(ju,ju,bn.set(Vu,r,a,0)),Hn.scale(ju,ju,bn.set(Vu,r,a,1)),Hn.multiply(e,ju,e),e},t.updateExposure=function(){var e=Math.log2(this._apertureValue*this._apertureValue/this._shutterValue*100/this._isoValue);vr.set(this._poolHandle,fr.EXPOSURE,.833333/Math.pow(2,e))},j(e,[{key:"node",set:function(e){this._node=e},get:function(){return this._node}},{key:"enabled",set:function(e){this._enabled=e},get:function(){return this._enabled}},{key:"orthoHeight",set:function(e){this._orthoHeight=e,this._isProjDirty=!0},get:function(){return this._orthoHeight}},{key:"projectionType",set:function(e){this._proj=e,this._isProjDirty=!0},get:function(){return this._proj}},{key:"fovAxis",set:function(e){this._fovAxis=e,this._isProjDirty=!0},get:function(){return this._fovAxis}},{key:"fov",set:function(e){this._fov=e,this._isProjDirty=!0},get:function(){return this._fov}},{key:"nearClip",set:function(e){this._nearClip=e,this._isProjDirty=!0},get:function(){return this._nearClip}},{key:"farClip",set:function(e){this._farClip=e,this._isProjDirty=!0},get:function(){return this._farClip}},{key:"clearColor",set:function(e){this._clearColor.x=e.x,this._clearColor.y=e.y,this._clearColor.z=e.z,this._clearColor.w=e.w,vr.setVec4(this._poolHandle,fr.CLEAR_COLOR,e)},get:function(){return this._clearColor}},{key:"viewport",get:function(){return this._viewport},set:function(e){var t=e.x,n=e.width,i=e.height,r=this._device.screenSpaceSignY<0?1-e.y-i:e.y;switch(this._device.surfaceTransform){case gs.ROTATE_90:this._viewport.x=1-r-i,this._viewport.y=t,this._viewport.width=i,this._viewport.height=n;break;case gs.ROTATE_180:this._viewport.x=1-t-n,this._viewport.y=1-r-i,this._viewport.width=n,this._viewport.height=i;break;case gs.ROTATE_270:this._viewport.x=r,this._viewport.y=1-t-n,this._viewport.width=i,this._viewport.height=n;break;case gs.IDENTITY:this._viewport.x=t,this._viewport.y=r,this._viewport.width=n,this._viewport.height=i}vr.setVec4(this._poolHandle,fr.VIEW_PORT,this._viewport),this.resize(this.width,this.height)}},{key:"scene",get:function(){return this._scene}},{key:"name",get:function(){return this._name}},{key:"width",get:function(){return vr.get(this._poolHandle,fr.WIDTH)}},{key:"height",get:function(){return vr.get(this._poolHandle,fr.HEIGHT)}},{key:"aspect",get:function(){return this._aspect}},{key:"matView",set:function(e){this._matView=e,vr.setMat4(this._poolHandle,fr.MAT_VIEW,this._matView)},get:function(){return this._matView}},{key:"matViewInv",set:function(e){this._matViewInv=e},get:function(){return this._matViewInv||this._node.worldMatrix}},{key:"matProj",set:function(e){this._matProj=e,vr.setMat4(this._poolHandle,fr.MAT_PROJ,this._matProj)},get:function(){return this._matProj}},{key:"matProjInv",set:function(e){this._matProjInv=e,vr.setMat4(this._poolHandle,fr.MAT_PROJ_INV,this._matProjInv)},get:function(){return this._matProjInv}},{key:"matViewProj",set:function(e){this._matViewProj=e,vr.setMat4(this._poolHandle,fr.MAT_VIEW_PROJ,this._matViewProj)},get:function(){return this._matViewProj}},{key:"matViewProjInv",set:function(e){this._matViewProjInv=e,vr.setMat4(this._poolHandle,fr.MAT_VIEW_PROJ_INV,this._matViewProjInv)},get:function(){return this._matViewProjInv}},{key:"frustum",set:function(e){this._frustum=e,ml(this._frustumHandle,e)},get:function(){return this._frustum}},{key:"window",set:function(e){this._window=e,e&&vr.set(this._poolHandle,fr.WINDOW,e.handle)},get:function(){return this._window}},{key:"forward",set:function(e){this._forward=e,vr.setVec3(this._poolHandle,fr.FORWARD,this._forward)},get:function(){return this._forward}},{key:"position",set:function(e){this._position=e,vr.setVec3(this._poolHandle,fr.POSITION,this._position)},get:function(){return this._position}},{key:"visibility",set:function(e){vr.set(this._poolHandle,fr.VISIBILITY,e)},get:function(){return vr.get(this._poolHandle,fr.VISIBILITY)}},{key:"priority",get:function(){return this._priority},set:function(e){this._priority=e}},{key:"aperture",set:function(e){this._aperture=e,this._apertureValue=Gu[this._aperture],this.updateExposure()},get:function(){return this._aperture}},{key:"apertureValue",get:function(){return this._apertureValue}},{key:"shutter",set:function(e){this._shutter=e,this._shutterValue=ku[this._shutter],this.updateExposure()},get:function(){return this._shutter}},{key:"shutterValue",get:function(){return this._shutterValue}},{key:"iso",set:function(e){this._iso=e,this._isoValue=Hu[this._iso],this.updateExposure()},get:function(){return this._iso}},{key:"isoValue",get:function(){return this._isoValue}},{key:"ec",set:function(e){this._ec=e},get:function(){return this._ec}},{key:"exposure",get:function(){return vr.get(this._poolHandle,fr.EXPOSURE)}},{key:"clearFlag",get:function(){return vr.get(this._poolHandle,fr.CLEAR_FLAG)},set:function(e){vr.set(this._poolHandle,fr.CLEAR_FLAG,e)}},{key:"clearDepth",get:function(){return vr.get(this._poolHandle,fr.CLEAR_DEPTH)},set:function(e){vr.set(this._poolHandle,fr.CLEAR_DEPTH,e)}},{key:"clearStencil",get:function(){return vr.get(this._poolHandle,fr.CLEAR_STENCIL)},set:function(e){vr.set(this._poolHandle,fr.CLEAR_STENCIL,e)}},{key:"handle",get:function(){return this._poolHandle}}]),e}();!function(e){e[e.LOCAL=0]="LOCAL",e[e.WORLD=1]="WORLD"}(zu||(zu={})),function(e){e[e.NONE=0]="NONE",e[e.POSITION=1]="POSITION",e[e.ROTATION=2]="ROTATION",e[e.SCALE=4]="SCALE",e[e.RS=e.ROTATION|e.SCALE]="RS",e[e.TRS=e.POSITION|e.ROTATION|e.SCALE]="TRS",e[e.TRS_MASK=~e.TRS]="TRS_MASK"}(Uu||(Uu={})),i.internal.TransformBit=Uu;var Ku=function(){function e(e){this._root=void 0,this._name="",this._cameras=[],this._models=[],this._batches=[],this._directionalLights=[],this._sphereLights=[],this._spotLights=[],this._mainLight=null,this._modelId=0,this._scenePoolHandle=0,this._modelArrayHandle=0,this._batchArrayHandle=0,this._sphereLightsHandle=0,this._spotLightsHandle=0,this._root=e,this._createHandles()}e.registerCreateFunc=function(t){t._createSceneFun=function(t){return new e(t)}},j(e,[{key:"root",get:function(){return this._root}},{key:"name",get:function(){return this._name}},{key:"cameras",get:function(){return this._cameras}},{key:"mainLight",get:function(){return this._mainLight}},{key:"sphereLights",get:function(){return this._sphereLights}},{key:"spotLights",get:function(){return this._spotLights}},{key:"models",get:function(){return this._models}},{key:"handle",get:function(){return this._scenePoolHandle}},{key:"batches",get:function(){return this._batches}}]);var t=e.prototype;return t.initialize=function(e){return this._name=e.name,this._createHandles(),!0},t.update=function(e){var t=this._mainLight;t&&t.update();for(var n=this._sphereLights,i=0;ithis.pipes.length?(E(4921),this):(this.pipes.splice(t,0,e),this)},t.append=function(e){return this.pipes.push(e),this},t.remove=function(e){return this.pipes.splice(e,1),this},t.sync=function(e){var t=this.pipes;if(0===t.length)return null;e.isFinish=!1;for(var n=0,i=t.length;n>2],Qh[Jh[i++]]=Kh[(3&r)<<2|a>>4],Qh[Jh[i++]]=Kh[15&a]}return e.replace(t,Qh.join(""))}var e_=/.*[/\\][0-9a-fA-F]{2}[/\\]([0-9a-fA-F-@]{8,}).*/;function t_(e){var t=e_.exec(e);return t?t[1]:""}function n_(e,t){(t=t||Object.create(null)).__isNative__=t.isNative,t.ext=t.nativeExt;var n=Hh.find((function(t){return!!t.getAssetInfo(e)}));return n&&(t.bundle=n.name),a_(e,t)}function i_(e){return e&&(e instanceof i.SceneAsset||e instanceof i.Scene)}function r_(e){return e&&(46===e.charCodeAt(0)&&47===e.charCodeAt(1)?e=e.slice(2):47===e.charCodeAt(0)&&(e=e.slice(1))),e}function a_(e,t){var n=Yh.create({input:e,options:t}),i=[];try{for(var r,a=Z(jh.sync(n));!(r=a()).done;){var s=r.value,o=s.url;s.recycle(),i.push(o)}}catch(e){for(var c,l=Z(n.output);!(c=l()).done;)c.value.recycle();f(e.message,e.stack)}return n.recycle(),i.length>1?i:i[0]}var s_=Object.freeze({__proto__:null,getUuidFromURL:t_,getUrlWithUuid:n_,isScene:i_,normalize:r_,transform:a_,decodeUuid:$h}),o_=e("Event",function(){function e(e,t){this.type=void 0,this.bubbles=void 0,this.target=null,this.currentTarget=null,this.eventPhase=0,this.propagationStopped=!1,this.propagationImmediateStopped=!1,this.type=e,this.bubbles=!!t}var t=e.prototype;return t.unuse=function(){this.type=e.NO_TYPE,this.target=null,this.currentTarget=null,this.eventPhase=e.NONE,this.propagationStopped=!1,this.propagationImmediateStopped=!1},t.reuse=function(e,t){this.type=e,this.bubbles=t||!1},t.isStopped=function(){return this.propagationStopped||this.propagationImmediateStopped},t.getCurrentTarget=function(){return this.currentTarget},t.getType=function(){return this.type},e}());o_.NO_TYPE="no_type",o_.TOUCH="touch",o_.MOUSE="mouse",o_.KEYBOARD="keyboard",o_.ACCELERATION="acceleration",o_.NONE=0,o_.CAPTURING_PHASE=1,o_.AT_TARGET=2,o_.BUBBLING_PHASE=3,i.Event=o_;var c_=e("Pool",function(){function e(e,t){this._ctor=void 0,this._elementsPerBatch=void 0,this._nextAvail=void 0,this._freepool=[],this._ctor=e,this._elementsPerBatch=Math.max(t,1),this._nextAvail=this._elementsPerBatch-1;for(var n=0;nthis._data.length)for(var t=this._data.length;t=this._data.length&&this.resize(2*this._data.length),this._data[this._count++]},t.removeAt=function(e){if(!(e>=this._count)){var t=this._count-1,n=this._data[e];this._data[e]=this._data[t],this._data[t]=n,this._count-=1}},j(e,[{key:"length",get:function(){return this._count}},{key:"data",get:function(){return this._data}}]),e}()),u_=e("CachedArray",function(){function e(e,t){this.array=void 0,this.length=0,this._compareFn=void 0,this.array=new Array(e),this.length=0,this._compareFn=void 0!==t?t:function(e,t){return e-t}}var t=e.prototype;return t.push=function(e){this.array[this.length++]=e},t.pop=function(){return this.array[--this.length]},t.get=function(e){return this.array[e]},t.clear=function(){this.length=0},t.destroy=function(){this.length=0,this.array.length=0},t.sort=function(){this.array.length=this.length,this.array.sort(this._compareFn)},t.concat=function(e){for(var t=0;t=this.length||e<0)){var t=--this.length;this.array[e]=this.array[t]}},t.indexOf=function(e){return this.array.indexOf(e)},e}());e("memop",Object.freeze({__proto__:null,Pool:c_,RecyclePool:l_,CachedArray:u_}));var h_=[],__=e("CCObject",function(){function e(e){void 0===e&&(e=""),this._objFlags=void 0,this._name=void 0,this._name=e,this._objFlags=0}e._deferredDestroy=function(){for(var e=h_.length,t=0;t=0;--e)this.callbackInfos[e]||p_(this.callbackInfos,e);this.containCanceled=!1},t.clear=function(){this.cancelAll(),this.callbackInfos.length=0,this.isInvoking=!1,this.containCanceled=!1},e}(),S_=new c_((function(){return new y_}),16),E_=function(){function e(){this._callbackTable=Pe(!0)}var t=e.prototype;return t.on=function(e,t,n,i){if(!this.hasEventListener(e,t,n)){var r=this._callbackTable[e];r||(r=this._callbackTable[e]=S_.alloc());var a=v_.alloc();a.set(t,n,i),r.callbackInfos.push(a)}return t},t.hasEventListener=function(e,t,n){var i=this._callbackTable&&this._callbackTable[e];if(!i)return!1;var r=i.callbackInfos;if(!t){if(i.isInvoking){for(var a=0;a0}for(var s=0;s0&&this._ref--,e&&i.assetManager._releaseManager.tryRelease(this),this},n.onLoaded=function(){},j(t,[{key:"_nativeDep",get:function(){if(this._native)return{__isNative__:!0,uuid:this._uuid,ext:this._native}}},{key:"refCount",get:function(){return this._ref}}]),t}(T_(__)),R_.preventDeferredLoadDependents=!1,R_.preventPreloadNativeObject=!1,C_=J((x_=b_).prototype,"_native",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),J(x_.prototype,"_nativeAsset",[oh],Object.getOwnPropertyDescriptor(x_.prototype,"_nativeAsset"),x_.prototype),A_=x_))||A_);I_.prototype.createNode=null,i.Asset=I_;var O_,P_,M_,N_,D_,B_,L_,F_=1024;function z_(e){return i.sys.capabilities.imageBitmap&&e instanceof ImageBitmap}!function(e){e[e.RGB565=za.R5G6B5]="RGB565",e[e.RGB5A1=za.RGB5A1]="RGB5A1",e[e.RGBA4444=za.RGBA4]="RGBA4444",e[e.RGB888=za.RGB8]="RGB888",e[e.RGB32F=za.RGB32F]="RGB32F",e[e.RGBA8888=za.RGBA8]="RGBA8888",e[e.RGBA32F=za.RGBA32F]="RGBA32F",e[e.A8=za.A8]="A8",e[e.I8=za.L8]="I8",e[e.AI8=za.LA8]="AI8",e[e.RGB_PVRTC_2BPPV1=za.PVRTC_RGB2]="RGB_PVRTC_2BPPV1",e[e.RGBA_PVRTC_2BPPV1=za.PVRTC_RGBA2]="RGBA_PVRTC_2BPPV1",e[e.RGB_A_PVRTC_2BPPV1=F_++]="RGB_A_PVRTC_2BPPV1",e[e.RGB_PVRTC_4BPPV1=za.PVRTC_RGB4]="RGB_PVRTC_4BPPV1",e[e.RGBA_PVRTC_4BPPV1=za.PVRTC_RGBA4]="RGBA_PVRTC_4BPPV1",e[e.RGB_A_PVRTC_4BPPV1=F_++]="RGB_A_PVRTC_4BPPV1",e[e.RGB_ETC1=za.ETC_RGB8]="RGB_ETC1",e[e.RGBA_ETC1=F_++]="RGBA_ETC1",e[e.RGB_ETC2=za.ETC2_RGB8]="RGB_ETC2",e[e.RGBA_ETC2=za.ETC2_RGBA8]="RGBA_ETC2",e[e.RGBA_ASTC_4x4=za.ASTC_RGBA_4x4]="RGBA_ASTC_4x4",e[e.RGBA_ASTC_5x4=za.ASTC_RGBA_5x4]="RGBA_ASTC_5x4",e[e.RGBA_ASTC_5x5=za.ASTC_RGBA_5x5]="RGBA_ASTC_5x5",e[e.RGBA_ASTC_6x5=za.ASTC_RGBA_6x5]="RGBA_ASTC_6x5",e[e.RGBA_ASTC_6x6=za.ASTC_RGBA_6x6]="RGBA_ASTC_6x6",e[e.RGBA_ASTC_8x5=za.ASTC_RGBA_8x5]="RGBA_ASTC_8x5",e[e.RGBA_ASTC_8x6=za.ASTC_RGBA_8x6]="RGBA_ASTC_8x6",e[e.RGBA_ASTC_8x8=za.ASTC_RGBA_8x8]="RGBA_ASTC_8x8",e[e.RGBA_ASTC_10x5=za.ASTC_RGBA_10x5]="RGBA_ASTC_10x5",e[e.RGBA_ASTC_10x6=za.ASTC_RGBA_10x6]="RGBA_ASTC_10x6",e[e.RGBA_ASTC_10x8=za.ASTC_RGBA_10x8]="RGBA_ASTC_10x8",e[e.RGBA_ASTC_10x10=za.ASTC_RGBA_10x10]="RGBA_ASTC_10x10",e[e.RGBA_ASTC_12x10=za.ASTC_RGBA_12x10]="RGBA_ASTC_12x10",e[e.RGBA_ASTC_12x12=za.ASTC_RGBA_12x12]="RGBA_ASTC_12x12"}(O_||(O_={})),function(e){e[e.REPEAT=$a.WRAP]="REPEAT",e[e.CLAMP_TO_EDGE=$a.CLAMP]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=$a.MIRROR]="MIRRORED_REPEAT",e[e.CLAMP_TO_BORDER=$a.BORDER]="CLAMP_TO_BORDER"}(P_||(P_={})),function(e){e[e.NONE=Ja.NONE]="NONE",e[e.LINEAR=Ja.LINEAR]="LINEAR",e[e.NEAREST=Ja.POINT]="NEAREST"}(M_||(M_={}));var U_,G_=e("ImageAsset",ih("cc.ImageAsset")((L_=B_=function(e){function t(t){var n;return(n=e.call(this)||this)._nativeData=void 0,n._tex=void 0,n._exportedExts=void 0,n._format=O_.RGBA8888,n._width=0,n._height=0,n.loaded=!1,n._nativeData={_data:null,width:0,height:0,format:0,_compressed:!1},void 0!==t&&n.reset(t),n}X(t,e),j(t,[{key:"_nativeAsset",get:function(){return this._nativeData},set:function(e){e instanceof HTMLElement||z_(e)||(e.format=e.format||this._format),this.reset(e)}},{key:"data",get:function(){return this._nativeData&&((e=this._nativeData)instanceof HTMLImageElement||e instanceof HTMLCanvasElement||z_(e))?this._nativeData:this._nativeData&&this._nativeData._data;var e}},{key:"width",get:function(){return this._nativeData.width||this._width}},{key:"height",get:function(){return this._nativeData.height||this._height}},{key:"format",get:function(){return this._format}},{key:"isCompressed",get:function(){return this._format>=O_.RGB_ETC1&&this._format<=O_.RGBA_ASTC_12x12||this._format>=O_.RGB_A_PVRTC_2BPPV1&&this._format<=O_.RGBA_ETC1}},{key:"url",get:function(){return this.nativeUrl}},{key:"_texture",set:function(e){this._tex=e},get:function(){if(!this._tex){var e=new i.Texture2D;e.name=this.nativeUrl,e.image=this,this._tex=e}return this._tex}}]);var n=t.prototype;return n.reset=function(e){var t=this;z_(e)?(this._nativeData=e,this._onDataComplete()):e instanceof HTMLElement?(this._nativeData=e,e.complete||e instanceof HTMLCanvasElement?this._onDataComplete():(this.loaded=!1,e.addEventListener("load",(function(){t._onDataComplete()})),e.addEventListener("error",(function(e){E(3119,e.message)})))):(this._nativeData=e,this._format=e.format,this._onDataComplete())},n.destroy=function(){return this.data&&this.data instanceof HTMLImageElement?(this.data.src="",this._setRawAsset("")):z_(this.data)&&this.data.close&&this.data.close(),e.prototype.destroy.call(this)},n._serialize=function(){},n._deserialize=function(e){var n="";"string"==typeof e?n=e:(this._width=e.w,this._height=e.h,n=e.fmt);for(var r,a=i.director.root?i.director.root.device:null,s=n.split("_"),o="",c=Number.MAX_VALUE,l=this._format,u="",h=i.macro.SUPPORT_TEXTURE_FORMATS,_=Z(s);!(r=_()).done;){var f=r.value.split("@"),d=parseInt(f[0],void 0),p=t.extnames[d]||f[0],m=h.indexOf(p);if(-1!==m&&m>2&3,W_.mipFilter=t>>4&3,W_.addressU=t>>6&3,W_.addressV=t>>8&3,W_.addressW=t>>10&3,W_.maxAnisotropy=t>>12&15,W_.cmpFunc=t>>16&15,W_.minLOD=t>>20&15,W_.maxLOD=t>>24&15,W_.mipLODBias=t>>28&15,W_.borderColor=V_,this._cache[t]=e.createSampler(W_))},e}());i.samplerLib=af;var sf=new Se("Tex"),of=ih("cc.TextureBase")((rf=nf=function(e){function t(){var t;return Q(t=e.call(this)||this,"_format",Y_,Y(t)),Q(t,"_minFilter",K_,Y(t)),Q(t,"_magFilter",Z_,Y(t)),Q(t,"_mipFilter",Q_,Y(t)),Q(t,"_wrapS",J_,Y(t)),Q(t,"_wrapT",$_,Y(t)),Q(t,"_wrapR",ef,Y(t)),Q(t,"_anisotropy",tf,Y(t)),t._width=1,t._height=1,t._id=void 0,t._samplerInfo=[],t._samplerHash=0,t._gfxSampler=null,t._gfxDevice=null,t._textureHash=0,t._id=sf.getNewId(),t.loaded=!1,t._gfxDevice=t._getGFXDevice(),t._textureHash=Vs(t._id,666),t}X(t,e),j(t,[{key:"isCompressed",get:function(){return this._format>=O_.RGB_ETC1&&this._format<=O_.RGBA_ASTC_12x12||this._format>=O_.RGB_A_PVRTC_2BPPV1&&this._format<=O_.RGBA_ETC1}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}}]);var n=t.prototype;return n.getId=function(){return this._id},n.getPixelFormat=function(){return this._format},n.getAnisotropy=function(){return this._anisotropy},n.setWrapMode=function(e,t,n){this._wrapS=e,this._samplerInfo[U_.addressU]=e,this._wrapT=t,this._samplerInfo[U_.addressV]=t,void 0!==n&&(this._wrapR=n,this._samplerInfo[U_.addressW]=n),this._samplerHash=j_(this._samplerInfo),this._gfxDevice&&(this._gfxSampler=af.getSampler(this._gfxDevice,this._samplerHash))},n.setFilters=function(e,t){this._minFilter=e,this._samplerInfo[U_.minFilter]=e,this._magFilter=t,this._samplerInfo[U_.magFilter]=t,this._samplerHash=j_(this._samplerInfo),this._gfxDevice&&(this._gfxSampler=af.getSampler(this._gfxDevice,this._samplerHash))},n.setMipFilter=function(e){this._mipFilter=e,this._samplerInfo[U_.mipFilter]=e,this._samplerInfo[U_.maxLOD]=e===M_.NONE?0:15,this._samplerHash=j_(this._samplerInfo),this._gfxDevice&&(this._gfxSampler=af.getSampler(this._gfxDevice,this._samplerHash))},n.setAnisotropy=function(e){this._anisotropy=e,this._samplerInfo[U_.maxAnisotropy]=e,this._samplerHash=j_(this._samplerInfo),this._gfxDevice&&(this._gfxSampler=af.getSampler(this._gfxDevice,this._samplerHash))},n.destroy=function(){var t=e.prototype.destroy.call(this);return t&&i.director.root&&i.director.root.batcher2D&&i.director.root.batcher2D._releaseDescriptorSetCache(this._textureHash),t},n.getHash=function(){return this._textureHash},n.getGFXTexture=function(){return null},n.getSamplerHash=function(){return this._samplerHash},n.getGFXSampler=function(){return this._gfxSampler||(this._gfxDevice?this._gfxSampler=af.getSampler(this._gfxDevice,this._samplerHash):A(9302)),this._gfxSampler},n._serialize=function(){return""},n._deserialize=function(e){var t=e.split(",");t.unshift(""),t.length>=5&&(this.setFilters(parseInt(t[1]),parseInt(t[2])),this.setWrapMode(parseInt(t[3]),parseInt(t[4]))),t.length>=7&&(this.setMipFilter(parseInt(t[5])),this.setAnisotropy(parseInt(t[6])))},n._getGFXDevice=function(){return i.director.root?i.director.root.device:null},n._getGFXFormat=function(){return this._getGFXPixelFormat(this._format)},n._setGFXFormat=function(e){this._format=void 0===e?O_.RGBA8888:e},n._getGFXPixelFormat=function(e){return e===O_.RGBA_ETC1?e=O_.RGB_ETC1:e===O_.RGB_A_PVRTC_4BPPV1?e=O_.RGB_PVRTC_4BPPV1:e===O_.RGB_A_PVRTC_2BPPV1&&(e=O_.RGB_PVRTC_2BPPV1),e},t}(I_),nf.PixelFormat=O_,nf.WrapMode=P_,nf.Filter=M_,Y_=J((X_=rf).prototype,"_format",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return O_.RGBA8888}}),K_=J(X_.prototype,"_minFilter",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return M_.LINEAR}}),Z_=J(X_.prototype,"_magFilter",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return M_.LINEAR}}),Q_=J(X_.prototype,"_mipFilter",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return M_.NONE}}),J_=J(X_.prototype,"_wrapS",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return P_.REPEAT}}),$_=J(X_.prototype,"_wrapT",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return P_.REPEAT}}),ef=J(X_.prototype,"_wrapR",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return P_.REPEAT}}),tf=J(X_.prototype,"_anisotropy",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 8}}),q_=X_))||q_;i.TextureBase=of;var cf=[qn,bn,Zn,Dn,Cn,$n,ti,Hn];function lf(e,t){e.x=t[1],e.y=t[2],e.z=t[3],e.w=t[4]}var uf=[function(e,t){e.x=t[1],e.y=t[2]},function(e,t){e.x=t[1],e.y=t[2],e.z=t[3]},lf,lf,function(e,t){e._val=t[1]},function(e,t){e.width=t[1],e.height=t[2]},function(e,t){e.x=t[1],e.y=t[2],e.width=t[3],e.height=t[4]},function(e,t){Hn.fromArray(e,t,1)}],hf=e("Details",function(){function e(){this.uuidObjList=null,this.uuidPropList=null,this.uuidList=null}var t=e.prototype;return t.init=function(e){this.uuidObjList=e[8],this.uuidPropList=e[9],this.uuidList=e[10]},t.reset=function(){this.uuidList=null,this.uuidObjList=null,this.uuidPropList=null},t.push=function(e,t,n){this.uuidObjList.push(e),this.uuidPropList.push(t),this.uuidList.push(n)},e}());function _f(e,t){for(var n=e[4][t[0]],i=n[0],r=new(0,i[0]),a=i[1],s=i[2],o=n[n.length-1],c=1;c=0?t[n]=e[5][i]:e[7][3*~i]=t}function pf(e){return function(t,n,i,r){n[i]=r;for(var a=0;a=0){var h=o[l];t[s]=ff(e,h,u)}else(0,vf[l=~l])(e,t,s,u)}return r}(e);return i.game._isCloning=!1,e[7]&&function(e,t,n){for(var i=e.length-1,r=0,a=3*e[i];r=0?s[n[c]]=o:s[~c]=o}for(;r=0?l[n[h]]=u:l[~h]=u}}(e[7],c,e[2]),function(e){for(var t=e[5],n=e[2],i=e[1],r=e[8],a=e[9],s=e[10],o=0;o=0?n[l]:~l,a[o]=l);var u=s[o];"number"==typeof u&&(s[o]=i[u])}}(e),r=c[l],a&&hf.pool.put(t),r}vf[0]=function(e,t,n,i){t[n]=i},vf[1]=df,vf[2]=pf(df),vf[3]=pf(mf),vf[4]=gf,vf[5]=function(e,t,n,i){uf[i[0]](t[n],i)},vf[6]=mf,vf[7]=function(e,t,n,i){t[n].set(i)},vf[8]=function(e,t,n,i){var r=new cf[i[0]];uf[i[0]](r,i),t[n]=r},vf[9]=pf(gf),vf[10]=function(e,t,n,i){var r=e[3][i[0]];t[n]=ff(e,r,i[1])},vf[11]=function(e,t,n,i){var r=i[0];t[n]=r;for(var a=1;a=0,1620),n=isNaN(n)?i.macro.REPEAT_FOREVER:n,r=r||0;var a=i.director.getScheduler(),s=a.isTargetPaused(this);a.schedule(e,this,t,n,r,s)},n.scheduleOnce=function(e,t){void 0===t&&(t=0),this.schedule(e,0,0,t)},n.unschedule=function(e){e&&i.director.getScheduler().unschedule(e,this)},n.unscheduleAllCallbacks=function(){i.director.getScheduler().unscheduleAllForTarget(this)},j(t,[{key:"name",get:function(){if(this._name)return this._name;var e=Me(this),t=e.lastIndexOf(".");return t>=0&&(e=e.slice(t+1)),this.node.name+"<"+e+">"},set:function(e){this._name=e}},{key:"uuid",get:function(){return this._id}},{key:"__scriptAsset",get:function(){return null}},{key:"enabled",get:function(){return this._enabled},set:function(e){if(this._enabled!==e&&(this._enabled=e,this.node.activeInHierarchy)){var t=i.director._compScheduler;e?t.enableComp(this):t.disableComp(this)}}},{key:"enabledInHierarchy",get:function(){return this._enabled&&this.node&&this.node.activeInHierarchy}},{key:"_isOnLoadCalled",get:function(){return this._objFlags&Yf}}]),t}(__),Gf.system=null,J((Lf=kf).prototype,"__scriptAsset",[Mf,Nf,Df,Ih],Object.getOwnPropertyDescriptor(Lf.prototype,"__scriptAsset"),Lf.prototype),Ff=J(Lf.prototype,"node",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),zf=J(Lf.prototype,"_enabled",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),Uf=J(Lf.prototype,"__prefab",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Bf=Lf))||Bf)),Zf=Kf.prototype;Zf.update=null,Zf.lateUpdate=null,Zf.__preload=null,Zf.onLoad=null,Zf.start=null,Zf.onEnable=null,Zf.onDisable=null,Zf.onDestroy=null,Zf.onFocusInEditor=null,Zf.onLostFocusInEditor=null,Zf.resetInEditor=null,Zf._getLocalBounds=null,Zf.onRestore=null,Kf._requireComponent=null,Kf._executionOrder=0,be(Kf,"_registerEditorProps",(function(e,t){var n=t.requireComponent;n&&(e._requireComponent=n);var i=t.executionOrder;i&&"number"==typeof i&&(e._executionOrder=i)})),i.Component=Kf;var Qf=e("MissingScript",ih("cc.MissingScript")(Vf=dh()((qf=function(e){function t(){var t;return Q(t=e.call(this)||this,"_$erialized",jf,Y(t)),t}return X(t,e),t.safeFindClass=function(e){var t=tt(e);if(t)return t;i.deserialize.reportMissingClass(e)},t.prototype.onLoad=function(){E(4600,this.node.name)},t}(Kf),jf=J((Wf=qf).prototype,"_$erialized",[ch,lh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),Vf=Wf))||Vf)||Vf);function Jf(e,t){var n;n=Qf.safeFindClass;var i,r=hf.pool.get();try{i=Af(e,r,{classFinder:n,customEnv:t})}catch(e){throw f(e),hf.pool.put(r),e}i._uuid=t.__uuid__||"";for(var a=r.uuidList,s=r.uuidObjList,o=r.uuidPropList,c=[],l=0;l>t,r.texExtent.height=this._textureHeight>>t,r.texSubres.mipLevel=t,r.texSubres.baseArrayLayer=n,ArrayBuffer.isView(e)?i.copyBuffersToTexture([e],this._gfxTexture,td):i.copyTexImagesToTexture([e],this._gfxTexture,td)}}},n._assignImage=function(e,t,n){var r=this,a=function(){var i=e.data;if(i&&(r.uploadData(i,t,n),r._checkTextureLoaded(),ft.CLEANUP_IMAGE_CACHE)){var a=ed.getDeps(r._uuid),s=a.indexOf(e._uuid);-1!==s&&(me(a,s),e.decRef())}};if(e.loaded)a();else{if(e.once("load",(function(){a()})),!this.isCompressed){var s=i.builtinResMgr.get("black-texture").image;this.uploadData(s.data,t,n)}i.assetManager.postLoadNative(e)}},n._checkTextureLoaded=function(){this._textureReady()},n._textureReady=function(){this.loaded=!0,this.emit("load")},n._setMipmapLevel=function(e){this._mipmapLevel=e<1?1:e},n._getGfxTextureCreateInfo=function(){return null},n._tryReset=function(){if(this._tryDestroyTexture(),0!==this._mipmapLevel){var e=this._getGFXDevice();e&&this._createTexture(e)}},n._createTexture=function(e){if(0!==this._width&&0!==this._height){var t=is.NONE;this._mipFilter!==M_.NONE&&function(e,t,n){return!(e.gfxAPI===ms.WEBGL)||nd(t)&&nd(n)}(e,this._width,this._height)&&(this._mipmapLevel=function(e,t){for(var n=Math.max(e,t),i=0;n;)n>>=1,i++;return i}(this._width,this._height),t=is.GEN_MIPMAP);var n=this._getGfxTextureCreateInfo({usage:ts.SAMPLED|ts.TRANSFER_DST,format:this._getGFXFormat(),levelCount:this._mipmapLevel,flags:t|is.IMMUTABLE});if(n){var i=e.createTexture(n);this._textureWidth=n.width,this._textureHeight=n.height,this._gfxTexture=i}}},n._tryDestroyTexture=function(){this._gfxTexture&&(this._gfxTexture.destroy(),this._gfxTexture=null)},j(t,[{key:"mipmapLevel",get:function(){return this._mipmapLevel}}]),t}(of))||$f;i.SimpleTexture=ld;var ud,hd,_d,fd,dd,pd,md=e("Texture2D",(id=ih("cc.Texture2D"),rd=Dh([G_]),id((cd=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r=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(){},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}(ld),od=J((sd=cd).prototype,"_mipmaps",[rd],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),ad=sd))||ad));i.Texture2D=md,function(e){e[e.right=0]="right",e[e.left=1]="left",e[e.top=2]="top",e[e.bottom=3]="bottom",e[e.front=4]="front",e[e.back=5]="back"}(pd||(pd={}));var gd=e("TextureCube",ih("cc.TextureCube")((dd=fd=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r=this._mipmaps.length))for(var i=Math.min(void 0===t?this._mipmaps.length:t,this._mipmaps.length-e),r=function(t){var i=e+t;vd(n._mipmaps[i],(function(e,t){n._assignImage(e,i,t)}))},a=0;a0){var n=this._mipmaps[0].front;this.reset({width:n.width,height:n.height,format:n.format,mipmapLevel:this._mipmaps.length}),this._mipmaps.forEach((function(e,n){vd(e,(function(e,i){t._assignImage(e,n,i)}))}))}else this.reset({width:0,height:0,mipmapLevel:this._mipmaps.length})}},{key:"image",get:function(){return 0===this._mipmaps.length?null:this._mipmaps[0]},set:function(e){this.mipmaps=e?[e]:[]}}]),t}(ld),fd.FaceIndex=pd,_d=J((hd=dd).prototype,"_mipmaps",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),ud=hd))||ud);function vd(e,t){t(e.front,pd.front),t(e.back,pd.back),t(e.left,pd.left),t(e.right,pd.right),t(e.top,pd.top),t(e.bottom,pd.bottom)}i.TextureCube=gd;var yd,Sd,Ed,Td=e("effects",[{name:"billboard",techniques:[{name:"add",passes:[{rasterizerState:{cullMode:0},blendState:{targets:[{blend:!0,blendSrc:2,blendDst:1,blendSrcAlpha:2,blendDstAlpha:1}]},program:"billboard|vert:vs_main|tinted-fs:add",depthStencilState:{depthTest:!0,depthWrite:!1},properties:{mainTexture:{value:"grey",type:28},mainTiling_Offset:{value:[1,1,0,0],type:16},tintColor:{value:[.5,.5,.5,.5],type:16}}}]}],shaders:[{name:"billboard|vert:vs_main|tinted-fs:add",hash:2143664850,builtins:{globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplers:[]},locals:{blocks:[{name:"CCLocal",defines:[]}],samplers:[]}},defines:[{name:"CC_USE_HDR",type:"boolean"}],blocks:[{name:"Constants",defines:[],binding:0,stageFlags:1,members:[{name:"mainTiling_Offset",type:16,count:1},{name:"frameTile_velLenScale",type:16,count:1},{name:"scale",type:16,count:1}]},{name:"builtin",defines:[],binding:1,stageFlags:1,members:[{name:"cc_size_rotation",type:16,count:1}]},{name:"FragConstants",defines:[],binding:2,stageFlags:16,members:[{name:"tintColor",type:16,count:1}]}],samplers:[{name:"mainTexture",type:28,count:1,defines:[],stageFlags:16,binding:3}],attributes:[{name:"a_position",type:15,count:1,defines:[],stageFlags:1,format:32,location:0},{name:"a_texCoord",type:14,count:1,defines:[],stageFlags:1,format:21,location:1},{name:"a_color",type:16,count:1,defines:[],stageFlags:1,format:44,location:2}]}]},{name:"clear-stencil",techniques:[{passes:[{blendState:{targets:[{blend:!0}]},rasterizerState:{cullMode:0},program:"clear-stencil|sprite-vs:vert|sprite-fs:frag",depthStencilState:{depthTest:!1,depthWrite:!1}}]}],shaders:[{name:"clear-stencil|sprite-vs:vert|sprite-fs:frag",hash:1062464958,builtins:{globals:{blocks:[],samplers:[]},locals:{blocks:[],samplers:[]}},defines:[],blocks:[],samplers:[],attributes:[{name:"a_position",type:15,count:1,defines:[],stageFlags:1,format:32,location:0}]}]},{name:"graphics",techniques:[{passes:[{blendState:{targets:[{blend:!0,blendSrc:1,blendDst:4,blendSrcAlpha:1,blendDstAlpha:4}]},rasterizerState:{cullMode:0},program:"graphics|vs:vert|fs:frag",depthStencilState:{depthTest:!1,depthWrite:!1}}]}],shaders:[{name:"graphics|vs:vert|fs:frag",hash:3946667351,builtins:{globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplers:[]},locals:{blocks:[{name:"CCLocal",defines:[]}],samplers:[]}},defines:[],blocks:[],samplers:[],attributes:[{name:"a_position",type:15,count:1,defines:[],stageFlags:1,format:32,location:0},{name:"a_color",type:16,count:1,defines:[],stageFlags:1,format:44,location:1},{name:"a_dist",type:13,count:1,defines:[],stageFlags:1,format:11,location:2}]}]},{name:"particle-gpu",techniques:[{name:"add",passes:[{rasterizerState:{cullMode:0},blendState:{targets:[{blend:!0,blendSrc:2,blendDst:1,blendSrcAlpha:2,blendDstAlpha:1}]},program:"particle-gpu|particle-vs-gpu:gpvs_main|tinted-fs:add",depthStencilState:{depthTest:!0,depthWrite:!1},properties:{mainTexture:{value:"grey",type:28},mainTiling_Offset:{value:[1,1,0,0],type:16},tintColor:{value:[.5,.5,.5,.5],type:16}}}]}],shaders:[{name:"particle-gpu|particle-vs-gpu:gpvs_main|tinted-fs:add",hash:3696836305,builtins:{globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplers:[]},locals:{blocks:[{name:"CCLocal",defines:[]}],samplers:[]}},defines:[{name:"CC_RENDER_MODE",type:"number",range:[0,4]},{name:"COLOR_OVER_TIME_MODULE_ENABLE",type:"boolean"},{name:"ROTATION_OVER_TIME_MODULE_ENABLE",type:"boolean"},{name:"SIZE_OVER_TIME_MODULE_ENABLE",type:"boolean"},{name:"FORCE_OVER_TIME_MODULE_ENABLE",type:"boolean"},{name:"VELOCITY_OVER_TIME_MODULE_ENABLE",type:"boolean"},{name:"TEXTURE_ANIMATION_MODULE_ENABLE",type:"boolean"},{name:"CC_USE_WORLD_SPACE",type:"boolean"},{name:"CC_USE_HDR",type:"boolean"}],blocks:[{name:"Constants",defines:[],binding:0,stageFlags:1,members:[{name:"mainTiling_Offset",type:16,count:1},{name:"frameTile_velLenScale",type:16,count:1},{name:"scale",type:16,count:1}]},{name:"SampleConstants",defines:[],binding:1,stageFlags:1,members:[{name:"u_sampleInfo",type:16,count:1}]},{name:"TickConstants",defines:[],binding:2,stageFlags:1,members:[{name:"u_worldRot",type:16,count:1},{name:"u_timeDelta",type:16,count:1}]},{name:"ColorConstant",defines:["COLOR_OVER_TIME_MODULE_ENABLE"],binding:3,stageFlags:1,members:[{name:"u_color_mode",type:5,count:1}]},{name:"RotationConstant",defines:["ROTATION_OVER_TIME_MODULE_ENABLE"],binding:4,stageFlags:1,members:[{name:"u_rotation_mode",type:5,count:1}]},{name:"SizeConstant",defines:["SIZE_OVER_TIME_MODULE_ENABLE"],binding:5,stageFlags:1,members:[{name:"u_size_mode",type:5,count:1}]},{name:"ForceConstant",defines:["FORCE_OVER_TIME_MODULE_ENABLE"],binding:6,stageFlags:1,members:[{name:"u_force_mode",type:5,count:1},{name:"u_force_space",type:5,count:1}]},{name:"VelocityConstant",defines:["VELOCITY_OVER_TIME_MODULE_ENABLE"],binding:7,stageFlags:1,members:[{name:"u_velocity_mode",type:5,count:1},{name:"u_velocity_space",type:5,count:1}]},{name:"AnimationConstant",defines:["TEXTURE_ANIMATION_MODULE_ENABLE"],binding:8,stageFlags:1,members:[{name:"u_anim_info",type:16,count:1}]},{name:"FragConstants",defines:[],binding:9,stageFlags:16,members:[{name:"tintColor",type:16,count:1}]}],samplers:[{name:"color_over_time_tex0",type:28,count:1,defines:["COLOR_OVER_TIME_MODULE_ENABLE"],stageFlags:1,binding:10},{name:"rotation_over_time_tex0",type:28,count:1,defines:["ROTATION_OVER_TIME_MODULE_ENABLE"],stageFlags:1,binding:11},{name:"size_over_time_tex0",type:28,count:1,defines:["SIZE_OVER_TIME_MODULE_ENABLE"],stageFlags:1,binding:12},{name:"force_over_time_tex0",type:28,count:1,defines:["FORCE_OVER_TIME_MODULE_ENABLE"],stageFlags:1,binding:13},{name:"velocity_over_time_tex0",type:28,count:1,defines:["VELOCITY_OVER_TIME_MODULE_ENABLE"],stageFlags:1,binding:14},{name:"texture_animation_tex0",type:28,count:1,defines:["TEXTURE_ANIMATION_MODULE_ENABLE"],stageFlags:1,binding:15},{name:"mainTexture",type:28,count:1,defines:[],stageFlags:16,binding:16}],attributes:[{name:"a_position_starttime",type:16,count:1,defines:[],stageFlags:1,format:44,location:0},{name:"a_size_uv",type:16,count:1,defines:[],stageFlags:1,format:44,location:1},{name:"a_rotation_uv",type:16,count:1,defines:[],stageFlags:1,format:44,location:2},{name:"a_color",type:16,count:1,defines:[],stageFlags:1,format:44,location:3},{name:"a_dir_life",type:16,count:1,defines:[],stageFlags:1,format:44,location:4},{name:"a_rndSeed",type:13,count:1,defines:[],stageFlags:1,format:11,location:5},{name:"a_texCoord",type:15,count:1,defines:["CC_RENDER_MODE"],stageFlags:1,format:32,location:6},{name:"a_texCoord3",type:15,count:1,defines:["CC_RENDER_MODE"],stageFlags:1,format:32,location:7},{name:"a_normal",type:15,count:1,defines:["CC_RENDER_MODE"],stageFlags:1,format:32,location:8},{name:"a_color1",type:16,count:1,defines:["CC_RENDER_MODE"],stageFlags:1,format:44,location:9}]}]},{name:"particle-trail",techniques:[{name:"add",passes:[{rasterizerState:{cullMode:0},blendState:{targets:[{blend:!0,blendSrc:2,blendDst:1,blendSrcAlpha:2,blendDstAlpha:1}]},program:"particle-trail|particle-trail:vs_main|tinted-fs:add",depthStencilState:{depthTest:!0,depthWrite:!1},properties:{mainTexture:{value:"grey",type:28},mainTiling_Offset:{value:[1,1,0,0],type:16},frameTile_velLenScale:{value:[1,1,0,0],type:16},tintColor:{value:[.5,.5,.5,.5],type:16}}}]}],shaders:[{name:"particle-trail|particle-trail:vs_main|tinted-fs:add",hash:4115155772,builtins:{globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplers:[]},locals:{blocks:[{name:"CCLocal",defines:[]}],samplers:[]}},defines:[{name:"CC_RENDER_MODE",type:"number",range:[0,4]},{name:"CC_DRAW_WIRE_FRAME",type:"boolean"},{name:"CC_USE_WORLD_SPACE",type:"boolean"},{name:"CC_USE_HDR",type:"boolean"}],blocks:[{name:"Constants",defines:[],binding:0,stageFlags:1,members:[{name:"mainTiling_Offset",type:16,count:1},{name:"frameTile_velLenScale",type:16,count:1},{name:"scale",type:16,count:1}]},{name:"FragConstants",defines:[],binding:1,stageFlags:16,members:[{name:"tintColor",type:16,count:1}]}],samplers:[{name:"mainTexture",type:28,count:1,defines:[],stageFlags:16,binding:2}],attributes:[{name:"a_position",type:15,count:1,defines:[],stageFlags:1,format:32,location:0},{name:"a_texCoord",type:16,count:1,defines:[],stageFlags:1,format:44,location:1},{name:"a_texCoord1",type:15,count:1,defines:[],stageFlags:1,format:32,location:2},{name:"a_texCoord2",type:15,count:1,defines:[],stageFlags:1,format:32,location:3},{name:"a_color",type:16,count:1,defines:[],stageFlags:1,format:44,location:4}]}]},{name:"particle",techniques:[{name:"add",passes:[{rasterizerState:{cullMode:0},blendState:{targets:[{blend:!0,blendSrc:2,blendDst:1,blendSrcAlpha:2,blendDstAlpha:1}]},program:"particle|particle-vs-legacy:lpvs_main|tinted-fs:add",depthStencilState:{depthTest:!0,depthWrite:!1},properties:{mainTexture:{value:"grey",type:28},mainTiling_Offset:{value:[1,1,0,0],type:16},tintColor:{value:[.5,.5,.5,.5],type:16}}}]}],shaders:[{name:"particle|particle-vs-legacy:lpvs_main|tinted-fs:add",hash:66662317,builtins:{globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplers:[]},locals:{blocks:[{name:"CCLocal",defines:[]}],samplers:[]}},defines:[{name:"CC_RENDER_MODE",type:"number",range:[0,4]},{name:"CC_USE_WORLD_SPACE",type:"boolean"},{name:"CC_USE_HDR",type:"boolean"}],blocks:[{name:"Constants",defines:[],binding:0,stageFlags:1,members:[{name:"mainTiling_Offset",type:16,count:1},{name:"frameTile_velLenScale",type:16,count:1},{name:"scale",type:16,count:1}]},{name:"FragConstants",defines:[],binding:1,stageFlags:16,members:[{name:"tintColor",type:16,count:1}]}],samplers:[{name:"mainTexture",type:28,count:1,defines:[],stageFlags:16,binding:2}],attributes:[{name:"a_position",type:15,count:1,defines:[],stageFlags:1,format:32,location:0},{name:"a_texCoord",type:15,count:1,defines:[],stageFlags:1,format:32,location:1},{name:"a_texCoord1",type:15,count:1,defines:[],stageFlags:1,format:32,location:2},{name:"a_texCoord2",type:15,count:1,defines:[],stageFlags:1,format:32,location:3},{name:"a_color",type:16,count:1,defines:[],stageFlags:1,format:44,location:4},{name:"a_color1",type:15,count:1,defines:["CC_RENDER_MODE"],stageFlags:1,format:32,location:8},{name:"a_texCoord3",type:15,count:1,defines:["CC_RENDER_MODE"],stageFlags:1,format:32,location:6},{name:"a_normal",type:15,count:1,defines:["CC_RENDER_MODE"],stageFlags:1,format:32,location:7}]}]},{name:"spine",techniques:[{passes:[{blendState:{targets:[{blend:!0,blendSrc:2,blendDst:4,blendDstAlpha:4}]},rasterizerState:{cullMode:0},program:"spine|sprite-vs:vert|sprite-fs:frag",depthStencilState:{depthTest:!1,depthWrite:!1},properties:{alphaThreshold:{value:[.5],type:13}}}]}],shaders:[{name:"spine|sprite-vs:vert|sprite-fs:frag",hash:4078504952,builtins:{globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplers:[]},locals:{blocks:[{name:"CCLocal",defines:["USE_LOCAL"]}],samplers:[{name:"cc_spriteTexture",defines:[]}]}},defines:[{name:"USE_LOCAL",type:"boolean"},{name:"TWO_COLORED",type:"boolean"},{name:"USE_ALPHA_TEST",type:"boolean"}],blocks:[{name:"ALPHA_TEST_DATA",defines:["USE_ALPHA_TEST"],binding:0,stageFlags:16,members:[{name:"alphaThreshold",type:13,count:1}]}],samplers:[],attributes:[{name:"a_position",type:15,count:1,defines:[],stageFlags:1,format:32,location:0},{name:"a_texCoord",type:14,count:1,defines:[],stageFlags:1,format:21,location:1},{name:"a_color",type:16,count:1,defines:[],stageFlags:1,format:44,location:2},{name:"a_color2",type:16,count:1,defines:["TWO_COLORED"],stageFlags:1,format:44,location:3}]}]},{name:"sprite",techniques:[{passes:[{blendState:{targets:[{blend:!0,blendSrc:2,blendDst:4,blendDstAlpha:4}]},rasterizerState:{cullMode:0},program:"sprite|sprite-vs:vert|sprite-fs:frag",depthStencilState:{depthTest:!1,depthWrite:!1},properties:{alphaThreshold:{value:[.5],type:13}}}]}],shaders:[{name:"sprite|sprite-vs:vert|sprite-fs:frag",hash:3990469549,builtins:{globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplers:[]},locals:{blocks:[{name:"CCLocal",defines:["USE_LOCAL"]}],samplers:[{name:"cc_spriteTexture",defines:["USE_TEXTURE"]}]}},defines:[{name:"USE_LOCAL",type:"boolean"},{name:"USE_PIXEL_ALIGNMENT",type:"boolean"},{name:"CC_USE_EMBEDDED_ALPHA",type:"boolean"},{name:"USE_ALPHA_TEST",type:"boolean"},{name:"USE_TEXTURE",type:"boolean"},{name:"IS_GRAY",type:"boolean"}],blocks:[{name:"ALPHA_TEST_DATA",defines:["USE_ALPHA_TEST"],binding:0,stageFlags:16,members:[{name:"alphaThreshold",type:13,count:1}]}],samplers:[],attributes:[{name:"a_position",type:15,count:1,defines:[],stageFlags:1,format:32,location:0},{name:"a_texCoord",type:14,count:1,defines:[],stageFlags:1,format:21,location:1},{name:"a_color",type:16,count:1,defines:[],stageFlags:1,format:44,location:2}]}]},{name:"standard",techniques:[{name:"opaque",passes:[{program:"standard|standard-vs:vert|standard-fs:frag",properties:{tilingOffset:{value:[1,1,0,0],type:16},mainColor:{value:[1,1,1,1],type:16,handleInfo:["albedo",0,16]},albedoScale:{value:[1,1,1],type:15,handleInfo:["albedoScaleAndCutoff",0,15]},alphaThreshold:{value:[.5],type:13,handleInfo:["albedoScaleAndCutoff",3,13]},occlusion:{value:[1],type:13,handleInfo:["pbrParams",0,13]},roughness:{value:[.8],type:13,handleInfo:["pbrParams",1,13]},metallic:{value:[.6],type:13,handleInfo:["pbrParams",2,13]},normalStrenth:{value:[1],type:13,handleInfo:["pbrParams",3,13]},emissive:{value:[0,0,0,1],type:16},emissiveScale:{value:[1,1,1],type:15,handleInfo:["emissiveScaleParam",0,15]},mainTexture:{value:"grey",type:28,handleInfo:["albedoMap",0,28]},normalMap:{value:"normal",type:28},pbrMap:{value:"grey",type:28},metallicRoughnessMap:{value:"grey",type:28},occlusionMap:{value:"white",type:28},emissiveMap:{value:"grey",type:28},albedo:{type:16,value:[1,1,1,1]},albedoScaleAndCutoff:{type:16,value:[1,1,1,.5]},pbrParams:{type:16,value:[1,.8,.6,1]},emissiveScaleParam:{type:16,value:[1,1,1,0]},albedoMap:{type:28,value:"grey"}}},{phase:"forward-add",propertyIndex:0,embeddedMacros:{CC_FORWARD_ADD:!0},blendState:{targets:[{blend:!0,blendSrc:1,blendDst:1,blendSrcAlpha:0,blendDstAlpha:1}]},program:"standard|standard-vs:vert|standard-fs:frag",depthStencilState:{depthFunc:2,depthTest:!0,depthWrite:!1},properties:{tilingOffset:{value:[1,1,0,0],type:16},mainColor:{value:[1,1,1,1],type:16,handleInfo:["albedo",0,16]},albedoScale:{value:[1,1,1],type:15,handleInfo:["albedoScaleAndCutoff",0,15]},alphaThreshold:{value:[.5],type:13,handleInfo:["albedoScaleAndCutoff",3,13]},occlusion:{value:[1],type:13,handleInfo:["pbrParams",0,13]},roughness:{value:[.8],type:13,handleInfo:["pbrParams",1,13]},metallic:{value:[.6],type:13,handleInfo:["pbrParams",2,13]},normalStrenth:{value:[1],type:13,handleInfo:["pbrParams",3,13]},emissive:{value:[0,0,0,1],type:16},emissiveScale:{value:[1,1,1],type:15,handleInfo:["emissiveScaleParam",0,15]},mainTexture:{value:"grey",type:28,handleInfo:["albedoMap",0,28]},normalMap:{value:"normal",type:28},pbrMap:{value:"grey",type:28},metallicRoughnessMap:{value:"grey",type:28},occlusionMap:{value:"white",type:28},emissiveMap:{value:"grey",type:28},albedo:{type:16,value:[1,1,1,1]},albedoScaleAndCutoff:{type:16,value:[1,1,1,.5]},pbrParams:{type:16,value:[1,.8,.6,1]},emissiveScaleParam:{type:16,value:[1,1,1,0]},albedoMap:{type:28,value:"grey"}}},{phase:"shadow-caster",propertyIndex:0,rasterizerState:{cullMode:1},program:"standard|shadow-caster-vs:vert|shadow-caster-fs:frag",properties:{tilingOffset:{value:[1,1,0,0],type:16},mainColor:{value:[1,1,1,1],type:16,handleInfo:["albedo",0,16]},albedoScale:{value:[1,1,1],type:15,handleInfo:["albedoScaleAndCutoff",0,15]},alphaThreshold:{value:[.5],type:13,handleInfo:["albedoScaleAndCutoff",3,13]},occlusion:{value:[1],type:13,handleInfo:["pbrParams",0,13]},roughness:{value:[.8],type:13,handleInfo:["pbrParams",1,13]},metallic:{value:[.6],type:13,handleInfo:["pbrParams",2,13]},normalStrenth:{value:[1],type:13,handleInfo:["pbrParams",3,13]},emissive:{value:[0,0,0,1],type:16},emissiveScale:{value:[1,1,1],type:15,handleInfo:["emissiveScaleParam",0,15]},mainTexture:{value:"grey",type:28,handleInfo:["albedoMap",0,28]},albedo:{type:16,value:[1,1,1,1]},albedoScaleAndCutoff:{type:16,value:[1,1,1,.5]},pbrParams:{type:16,value:[1,.8,.6,1]},emissiveScaleParam:{type:16,value:[1,1,1,0]},albedoMap:{type:28,value:"grey"}}}]}],shaders:[{name:"standard|standard-vs:vert|standard-fs:frag",hash:2668109714,builtins:{globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]},{name:"CCShadow",defines:[]}],samplers:[{name:"cc_environment",defines:["CC_USE_IBL"]},{name:"cc_shadowMap",defines:["CC_RECEIVE_SHADOW"]},{name:"cc_spotLightingMap",defines:["CC_RECEIVE_SHADOW"]}]},locals:{blocks:[{name:"CCMorph",defines:["CC_USE_MORPH"]},{name:"CCSkinningTexture",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION"]},{name:"CCSkinningAnimation",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION"]},{name:"CCSkinning",defines:["CC_USE_SKINNING","!CC_USE_BAKED_ANIMATION"]},{name:"CCLocalBatched",defines:["!USE_INSTANCING","USE_BATCHING"]},{name:"CCLocal",defines:["!USE_INSTANCING","!USE_BATCHING"]},{name:"CCForwardLight",defines:["CC_FORWARD_ADD"]}],samplers:[{name:"cc_PositionDisplacements",defines:["CC_USE_MORPH","CC_MORPH_TARGET_HAS_POSITION"]},{name:"cc_NormalDisplacements",defines:["CC_USE_MORPH","CC_MORPH_TARGET_HAS_NORMAL"]},{name:"cc_TangentDisplacements",defines:["CC_USE_MORPH","CC_MORPH_TARGET_HAS_TANGENT"]},{name:"cc_jointTexture",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION"]},{name:"cc_lightingMap",defines:["USE_LIGHTMAP","!USE_BATCHING","!CC_FORWARD_ADD"]}]}},defines:[{name:"CC_USE_MORPH",type:"boolean"},{name:"CC_MORPH_TARGET_COUNT",type:"number",range:[2,8]},{name:"CC_SUPPORT_FLOAT_TEXTURE",type:"boolean"},{name:"CC_MORPH_PRECOMPUTED",type:"boolean"},{name:"CC_MORPH_TARGET_HAS_POSITION",type:"boolean"},{name:"CC_MORPH_TARGET_HAS_NORMAL",type:"boolean"},{name:"CC_MORPH_TARGET_HAS_TANGENT",type:"boolean"},{name:"CC_USE_SKINNING",type:"boolean"},{name:"CC_USE_BAKED_ANIMATION",type:"boolean"},{name:"USE_INSTANCING",type:"boolean"},{name:"USE_BATCHING",type:"boolean"},{name:"USE_LIGHTMAP",type:"boolean"},{name:"CC_USE_FOG",type:"number",range:[0,4]},{name:"CC_FORWARD_ADD",type:"boolean"},{name:"USE_VERTEX_COLOR",type:"boolean"},{name:"USE_NORMAL_MAP",type:"boolean"},{name:"HAS_SECOND_UV",type:"boolean"},{name:"CC_USE_IBL",type:"number",range:[0,2]},{name:"CC_RECEIVE_SHADOW",type:"boolean"},{name:"CC_USE_HDR",type:"boolean"},{name:"USE_ALBEDO_MAP",type:"boolean"},{name:"ALBEDO_UV",type:"string",options:["v_uv","v_uv1"]},{name:"NORMAL_UV",type:"string",options:["v_uv","v_uv1"]},{name:"PBR_UV",type:"string",options:["v_uv","v_uv1"]},{name:"USE_PBR_MAP",type:"boolean"},{name:"USE_METALLIC_ROUGHNESS_MAP",type:"boolean"},{name:"USE_OCCLUSION_MAP",type:"boolean"},{name:"USE_EMISSIVE_MAP",type:"boolean"},{name:"EMISSIVE_UV",type:"string",options:["v_uv","v_uv1"]},{name:"USE_ALPHA_TEST",type:"boolean"},{name:"ALPHA_TEST_CHANNEL",type:"string",options:["a","r"]}],blocks:[{name:"Constants",defines:[],binding:0,stageFlags:17,members:[{name:"tilingOffset",type:16,count:1},{name:"albedo",type:16,count:1},{name:"albedoScaleAndCutoff",type:16,count:1},{name:"pbrParams",type:16,count:1},{name:"emissive",type:16,count:1},{name:"emissiveScaleParam",type:16,count:1}]}],samplers:[{name:"albedoMap",type:28,count:1,defines:["USE_ALBEDO_MAP"],stageFlags:16,binding:1},{name:"normalMap",type:28,count:1,defines:["USE_NORMAL_MAP"],stageFlags:16,binding:2},{name:"pbrMap",type:28,count:1,defines:["USE_PBR_MAP"],stageFlags:16,binding:3},{name:"metallicRoughnessMap",type:28,count:1,defines:["USE_METALLIC_ROUGHNESS_MAP"],stageFlags:16,binding:4},{name:"occlusionMap",type:28,count:1,defines:["USE_OCCLUSION_MAP"],stageFlags:16,binding:5},{name:"emissiveMap",type:28,count:1,defines:["USE_EMISSIVE_MAP"],stageFlags:16,binding:6}],attributes:[{name:"a_position",type:15,count:1,defines:[],stageFlags:1,format:32,location:0},{name:"a_normal",type:15,count:1,defines:[],stageFlags:1,format:32,location:1},{name:"a_texCoord",type:14,count:1,defines:[],stageFlags:1,format:21,location:2},{name:"a_tangent",type:16,count:1,defines:[],stageFlags:1,format:44,location:3},{name:"a_vertexId",type:13,count:1,defines:["CC_USE_MORPH"],stageFlags:1,format:11,location:6},{name:"a_joints",type:12,count:1,defines:["CC_USE_SKINNING"],stageFlags:1,format:42,location:4},{name:"a_weights",type:16,count:1,defines:["CC_USE_SKINNING"],stageFlags:1,format:44,location:5},{name:"a_jointAnimInfo",type:16,count:1,defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION","USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:7},{name:"a_matWorld0",type:16,count:1,defines:["USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:8},{name:"a_matWorld1",type:16,count:1,defines:["USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:9},{name:"a_matWorld2",type:16,count:1,defines:["USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:10},{name:"a_lightingMapUVParam",type:16,count:1,defines:["USE_INSTANCING","USE_LIGHTMAP"],stageFlags:1,format:44,isInstanced:!0,location:11},{name:"a_dyn_batch_id",type:13,count:1,defines:["!USE_INSTANCING","USE_BATCHING"],stageFlags:1,format:11,location:12},{name:"a_color",type:16,count:1,defines:["USE_VERTEX_COLOR"],stageFlags:1,format:44,location:13},{name:"a_texCoord1",type:14,count:1,defines:[],stageFlags:1,format:21,location:14}]},{name:"standard|shadow-caster-vs:vert|shadow-caster-fs:frag",hash:3020491,builtins:{globals:{blocks:[{name:"CCShadow",defines:[]}],samplers:[]},locals:{blocks:[{name:"CCMorph",defines:["CC_USE_MORPH"]},{name:"CCSkinningTexture",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION"]},{name:"CCSkinningAnimation",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION"]},{name:"CCSkinning",defines:["CC_USE_SKINNING","!CC_USE_BAKED_ANIMATION"]},{name:"CCLocalBatched",defines:["!USE_INSTANCING","USE_BATCHING"]},{name:"CCLocal",defines:["!USE_INSTANCING","!USE_BATCHING"]}],samplers:[{name:"cc_PositionDisplacements",defines:["CC_USE_MORPH","CC_MORPH_TARGET_HAS_POSITION"]},{name:"cc_NormalDisplacements",defines:["CC_USE_MORPH","CC_MORPH_TARGET_HAS_NORMAL"]},{name:"cc_TangentDisplacements",defines:["CC_USE_MORPH","CC_MORPH_TARGET_HAS_TANGENT"]},{name:"cc_jointTexture",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION"]}]}},defines:[{name:"CC_USE_MORPH",type:"boolean"},{name:"CC_MORPH_TARGET_COUNT",type:"number",range:[2,8]},{name:"CC_SUPPORT_FLOAT_TEXTURE",type:"boolean"},{name:"CC_MORPH_PRECOMPUTED",type:"boolean"},{name:"CC_MORPH_TARGET_HAS_POSITION",type:"boolean"},{name:"CC_MORPH_TARGET_HAS_NORMAL",type:"boolean"},{name:"CC_MORPH_TARGET_HAS_TANGENT",type:"boolean"},{name:"CC_USE_SKINNING",type:"boolean"},{name:"CC_USE_BAKED_ANIMATION",type:"boolean"},{name:"USE_INSTANCING",type:"boolean"},{name:"USE_BATCHING",type:"boolean"},{name:"USE_LIGHTMAP",type:"boolean"},{name:"HAS_SECOND_UV",type:"boolean"},{name:"USE_ALBEDO_MAP",type:"boolean"},{name:"ALBEDO_UV",type:"string",options:["v_uv","v_uv1"]},{name:"USE_ALPHA_TEST",type:"boolean"},{name:"ALPHA_TEST_CHANNEL",type:"string",options:["a","r"]}],blocks:[{name:"Constants",defines:[],binding:0,stageFlags:17,members:[{name:"tilingOffset",type:16,count:1},{name:"albedo",type:16,count:1},{name:"albedoScaleAndCutoff",type:16,count:1},{name:"pbrParams",type:16,count:1},{name:"emissive",type:16,count:1},{name:"emissiveScaleParam",type:16,count:1}]}],samplers:[{name:"albedoMap",type:28,count:1,defines:["USE_ALBEDO_MAP"],stageFlags:16,binding:1}],attributes:[{name:"a_position",type:15,count:1,defines:[],stageFlags:1,format:32,location:0},{name:"a_normal",type:15,count:1,defines:[],stageFlags:1,format:32,location:1},{name:"a_texCoord",type:14,count:1,defines:[],stageFlags:1,format:21,location:2},{name:"a_tangent",type:16,count:1,defines:[],stageFlags:1,format:44,location:3},{name:"a_vertexId",type:13,count:1,defines:["CC_USE_MORPH"],stageFlags:1,format:11,location:6},{name:"a_joints",type:12,count:1,defines:["CC_USE_SKINNING"],stageFlags:1,format:42,location:4},{name:"a_weights",type:16,count:1,defines:["CC_USE_SKINNING"],stageFlags:1,format:44,location:5},{name:"a_jointAnimInfo",type:16,count:1,defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION","USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:7},{name:"a_matWorld0",type:16,count:1,defines:["USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:8},{name:"a_matWorld1",type:16,count:1,defines:["USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:9},{name:"a_matWorld2",type:16,count:1,defines:["USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:10},{name:"a_lightingMapUVParam",type:16,count:1,defines:["USE_INSTANCING","USE_LIGHTMAP"],stageFlags:1,format:44,isInstanced:!0,location:11},{name:"a_dyn_batch_id",type:13,count:1,defines:["!USE_INSTANCING","USE_BATCHING"],stageFlags:1,format:11,location:12},{name:"a_texCoord1",type:14,count:1,defines:[],stageFlags:1,format:21,location:13}]}]},{name:"terrain",techniques:[{name:"opaque",passes:[{program:"terrain|terrain-vs:vert|terrain-fs:frag",properties:{UVScale:{value:[1,1,1,1],type:16},lightMapUVParam:{value:[0,0,0,0],type:16},metallic:{value:[0,0,0,0],type:16},roughness:{value:[1,1,1,1],type:16},weightMap:{value:"black",type:28},detailMap0:{value:"grey",type:28},detailMap1:{value:"grey",type:28},detailMap2:{value:"grey",type:28},detailMap3:{value:"grey",type:28},normalMap0:{value:"normal-texture",type:28},normalMap1:{value:"normal-texture",type:28},normalMap2:{value:"normal-texture",type:28},normalMap3:{value:"normal-texture",type:28},lightMap:{value:"grey",type:28}}},{phase:"forward-add",propertyIndex:0,embeddedMacros:{CC_FORWARD_ADD:!0},blendState:{targets:[{blend:!0,blendSrc:1,blendDst:1,blendSrcAlpha:0,blendDstAlpha:1}]},program:"terrain|terrain-vs:vert|terrain-fs:frag",depthStencilState:{depthFunc:2,depthTest:!0,depthWrite:!1},properties:{UVScale:{value:[1,1,1,1],type:16},lightMapUVParam:{value:[0,0,0,0],type:16},metallic:{value:[0,0,0,0],type:16},roughness:{value:[1,1,1,1],type:16},weightMap:{value:"black",type:28},detailMap0:{value:"grey",type:28},detailMap1:{value:"grey",type:28},detailMap2:{value:"grey",type:28},detailMap3:{value:"grey",type:28},normalMap0:{value:"normal-texture",type:28},normalMap1:{value:"normal-texture",type:28},normalMap2:{value:"normal-texture",type:28},normalMap3:{value:"normal-texture",type:28},lightMap:{value:"grey",type:28}}},{phase:"shadow-add",propertyIndex:0,rasterizerState:{cullMode:2},program:"terrain|shadow-caster-vs:vert|shadow-caster-fs:frag"}]}],shaders:[{name:"terrain|terrain-vs:vert|terrain-fs:frag",hash:2952542850,builtins:{globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]},{name:"CCShadow",defines:[]}],samplers:[{name:"cc_environment",defines:["CC_USE_IBL"]},{name:"cc_shadowMap",defines:["CC_RECEIVE_SHADOW"]},{name:"cc_spotLightingMap",defines:["CC_RECEIVE_SHADOW"]}]},locals:{blocks:[{name:"CCLocal",defines:[]},{name:"CCForwardLight",defines:["CC_FORWARD_ADD"]}],samplers:[]}},defines:[{name:"CC_USE_FOG",type:"number",range:[0,4]},{name:"CC_FORWARD_ADD",type:"boolean"},{name:"USE_NORMALMAP",type:"boolean"},{name:"USE_LIGHTMAP",type:"boolean"},{name:"CC_USE_IBL",type:"number",range:[0,2]},{name:"CC_RECEIVE_SHADOW",type:"boolean"},{name:"USE_BATCHING",type:"boolean"},{name:"CC_USE_HDR",type:"boolean"},{name:"LAYERS",type:"number",range:[0,4]},{name:"USE_PBR",type:"boolean"}],blocks:[{name:"TexCoords",defines:[],binding:0,stageFlags:1,members:[{name:"UVScale",type:16,count:1},{name:"lightMapUVParam",type:16,count:1}]},{name:"PbrParams",defines:[],binding:1,stageFlags:16,members:[{name:"metallic",type:16,count:1},{name:"roughness",type:16,count:1}]}],samplers:[{name:"weightMap",type:28,count:1,defines:[],stageFlags:16,binding:2},{name:"detailMap0",type:28,count:1,defines:[],stageFlags:16,binding:3},{name:"detailMap1",type:28,count:1,defines:[],stageFlags:16,binding:4},{name:"detailMap2",type:28,count:1,defines:[],stageFlags:16,binding:5},{name:"detailMap3",type:28,count:1,defines:[],stageFlags:16,binding:6},{name:"normalMap0",type:28,count:1,defines:[],stageFlags:16,binding:7},{name:"normalMap1",type:28,count:1,defines:[],stageFlags:16,binding:8},{name:"normalMap2",type:28,count:1,defines:[],stageFlags:16,binding:9},{name:"normalMap3",type:28,count:1,defines:[],stageFlags:16,binding:10},{name:"lightMap",type:28,count:1,defines:[],stageFlags:16,binding:11}],attributes:[{name:"a_position",type:15,count:1,defines:[],stageFlags:1,format:32,location:0},{name:"a_normal",type:15,count:1,defines:[],stageFlags:1,format:32,location:1},{name:"a_texCoord",type:14,count:1,defines:[],stageFlags:1,format:21,location:2}]},{name:"terrain|shadow-caster-vs:vert|shadow-caster-fs:frag",hash:3874167763,builtins:{globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]},{name:"CCShadow",defines:[]}],samplers:[]},locals:{blocks:[{name:"CCLocal",defines:[]}],samplers:[]}},defines:[],blocks:[],samplers:[],attributes:[{name:"a_position",type:15,count:1,defines:[],stageFlags:1,format:32,location:0},{name:"a_normal",type:15,count:1,defines:[],stageFlags:1,format:32,location:1},{name:"a_texCoord",type:14,count:1,defines:[],stageFlags:1,format:21,location:2}]}]},{name:"unlit",techniques:[{name:"opaque",passes:[{program:"unlit|unlit-vs:vert|unlit-fs:frag",properties:{mainTexture:{value:"grey",type:28},tilingOffset:{value:[1,1,0,0],type:16},mainColor:{value:[1,1,1,1],type:16},colorScale:{value:[1,1,1],type:15,handleInfo:["colorScaleAndCutoff",0,15]},alphaThreshold:{value:[.5],type:13,handleInfo:["colorScaleAndCutoff",3,13]},color:{type:16,handleInfo:["mainColor",0,16]},colorScaleAndCutoff:{type:16,value:[1,1,1,.5]}}}]}],shaders:[{name:"unlit|unlit-vs:vert|unlit-fs:frag",hash:3822871803,builtins:{globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplers:[]},locals:{blocks:[{name:"CCMorph",defines:["CC_USE_MORPH"]},{name:"CCSkinningTexture",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION"]},{name:"CCSkinningAnimation",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION"]},{name:"CCSkinning",defines:["CC_USE_SKINNING","!CC_USE_BAKED_ANIMATION"]},{name:"CCLocalBatched",defines:["!USE_INSTANCING","USE_BATCHING"]},{name:"CCLocal",defines:["!USE_INSTANCING","!USE_BATCHING"]}],samplers:[{name:"cc_PositionDisplacements",defines:["CC_USE_MORPH","CC_MORPH_TARGET_HAS_POSITION"]},{name:"cc_NormalDisplacements",defines:["CC_USE_MORPH","CC_MORPH_TARGET_HAS_NORMAL"]},{name:"cc_TangentDisplacements",defines:["CC_USE_MORPH","CC_MORPH_TARGET_HAS_TANGENT"]},{name:"cc_jointTexture",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION"]}]}},defines:[{name:"CC_USE_MORPH",type:"boolean"},{name:"CC_MORPH_TARGET_COUNT",type:"number",range:[2,8]},{name:"CC_SUPPORT_FLOAT_TEXTURE",type:"boolean"},{name:"CC_MORPH_PRECOMPUTED",type:"boolean"},{name:"CC_MORPH_TARGET_HAS_POSITION",type:"boolean"},{name:"CC_MORPH_TARGET_HAS_NORMAL",type:"boolean"},{name:"CC_MORPH_TARGET_HAS_TANGENT",type:"boolean"},{name:"CC_USE_SKINNING",type:"boolean"},{name:"CC_USE_BAKED_ANIMATION",type:"boolean"},{name:"USE_INSTANCING",type:"boolean"},{name:"USE_BATCHING",type:"boolean"},{name:"USE_LIGHTMAP",type:"boolean"},{name:"CC_USE_FOG",type:"number",range:[0,4]},{name:"CC_FORWARD_ADD",type:"boolean"},{name:"USE_VERTEX_COLOR",type:"boolean"},{name:"USE_TEXTURE",type:"boolean"},{name:"CC_USE_HDR",type:"boolean"},{name:"USE_ALPHA_TEST",type:"boolean"},{name:"ALPHA_TEST_CHANNEL",type:"string",options:["a","r","g","b"]}],blocks:[{name:"TexCoords",defines:["USE_TEXTURE"],binding:0,stageFlags:1,members:[{name:"tilingOffset",type:16,count:1}]},{name:"Constant",defines:[],binding:1,stageFlags:16,members:[{name:"mainColor",type:16,count:1},{name:"colorScaleAndCutoff",type:16,count:1}]}],samplers:[{name:"mainTexture",type:28,count:1,defines:["USE_TEXTURE"],stageFlags:16,binding:2}],attributes:[{name:"a_position",type:15,count:1,defines:[],stageFlags:1,format:32,location:0},{name:"a_normal",type:15,count:1,defines:[],stageFlags:1,format:32,location:1},{name:"a_texCoord",type:14,count:1,defines:[],stageFlags:1,format:21,location:2},{name:"a_tangent",type:16,count:1,defines:[],stageFlags:1,format:44,location:3},{name:"a_vertexId",type:13,count:1,defines:["CC_USE_MORPH"],stageFlags:1,format:11,location:6},{name:"a_joints",type:12,count:1,defines:["CC_USE_SKINNING"],stageFlags:1,format:42,location:4},{name:"a_weights",type:16,count:1,defines:["CC_USE_SKINNING"],stageFlags:1,format:44,location:5},{name:"a_jointAnimInfo",type:16,count:1,defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION","USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:7},{name:"a_matWorld0",type:16,count:1,defines:["USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:8},{name:"a_matWorld1",type:16,count:1,defines:["USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:9},{name:"a_matWorld2",type:16,count:1,defines:["USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:10},{name:"a_lightingMapUVParam",type:16,count:1,defines:["USE_INSTANCING","USE_LIGHTMAP"],stageFlags:1,format:44,isInstanced:!0,location:11},{name:"a_dyn_batch_id",type:13,count:1,defines:["!USE_INSTANCING","USE_BATCHING"],stageFlags:1,format:11,location:12},{name:"a_color",type:16,count:1,defines:["USE_VERTEX_COLOR"],stageFlags:1,format:44,location:13}]}]},{name:"planar-shadow",techniques:[{passes:[{phase:"planarShadow",blendState:{targets:[{blend:!0,blendSrc:2,blendDst:4,blendDstAlpha:4}]},program:"planar-shadow|planar-shadow-vs:vert|planar-shadow-fs:frag",depthStencilState:{depthTest:!0,depthWrite:!1,stencilTestFront:!0,stencilFuncFront:5,stencilPassOpFront:2,stencilRefBack:128,stencilRefFront:128,stencilReadMaskBack:128,stencilReadMaskFront:128,stencilWriteMaskBack:128,stencilWriteMaskFront:128}}]}],shaders:[{name:"planar-shadow|planar-shadow-vs:vert|planar-shadow-fs:frag",hash:2901856202,builtins:{globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]},{name:"CCShadow",defines:[]}],samplers:[]},locals:{blocks:[{name:"CCMorph",defines:["CC_USE_MORPH"]},{name:"CCSkinningTexture",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION"]},{name:"CCSkinningAnimation",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION"]},{name:"CCSkinning",defines:["CC_USE_SKINNING","!CC_USE_BAKED_ANIMATION"]},{name:"CCLocalBatched",defines:["!USE_INSTANCING","USE_BATCHING"]},{name:"CCLocal",defines:["!USE_INSTANCING","!USE_BATCHING"]}],samplers:[{name:"cc_PositionDisplacements",defines:["CC_USE_MORPH","CC_MORPH_TARGET_HAS_POSITION"]},{name:"cc_NormalDisplacements",defines:["CC_USE_MORPH","CC_MORPH_TARGET_HAS_NORMAL"]},{name:"cc_TangentDisplacements",defines:["CC_USE_MORPH","CC_MORPH_TARGET_HAS_TANGENT"]},{name:"cc_jointTexture",defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION"]}]}},defines:[{name:"CC_USE_MORPH",type:"boolean"},{name:"CC_MORPH_TARGET_COUNT",type:"number",range:[2,8]},{name:"CC_SUPPORT_FLOAT_TEXTURE",type:"boolean"},{name:"CC_MORPH_PRECOMPUTED",type:"boolean"},{name:"CC_MORPH_TARGET_HAS_POSITION",type:"boolean"},{name:"CC_MORPH_TARGET_HAS_NORMAL",type:"boolean"},{name:"CC_MORPH_TARGET_HAS_TANGENT",type:"boolean"},{name:"CC_USE_SKINNING",type:"boolean"},{name:"CC_USE_BAKED_ANIMATION",type:"boolean"},{name:"USE_INSTANCING",type:"boolean"},{name:"USE_BATCHING",type:"boolean"},{name:"USE_LIGHTMAP",type:"boolean"},{name:"CC_USE_HDR",type:"boolean"}],blocks:[],samplers:[],attributes:[{name:"a_position",type:15,count:1,defines:[],stageFlags:1,format:32,location:0},{name:"a_normal",type:15,count:1,defines:[],stageFlags:1,format:32,location:1},{name:"a_texCoord",type:14,count:1,defines:[],stageFlags:1,format:21,location:2},{name:"a_tangent",type:16,count:1,defines:[],stageFlags:1,format:44,location:3},{name:"a_vertexId",type:13,count:1,defines:["CC_USE_MORPH"],stageFlags:1,format:11,location:6},{name:"a_joints",type:12,count:1,defines:["CC_USE_SKINNING"],stageFlags:1,format:42,location:4},{name:"a_weights",type:16,count:1,defines:["CC_USE_SKINNING"],stageFlags:1,format:44,location:5},{name:"a_jointAnimInfo",type:16,count:1,defines:["CC_USE_SKINNING","CC_USE_BAKED_ANIMATION","USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:7},{name:"a_matWorld0",type:16,count:1,defines:["USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:8},{name:"a_matWorld1",type:16,count:1,defines:["USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:9},{name:"a_matWorld2",type:16,count:1,defines:["USE_INSTANCING"],stageFlags:1,format:44,isInstanced:!0,location:10},{name:"a_lightingMapUVParam",type:16,count:1,defines:["USE_INSTANCING","USE_LIGHTMAP"],stageFlags:1,format:44,isInstanced:!0,location:11},{name:"a_dyn_batch_id",type:13,count:1,defines:["!USE_INSTANCING","USE_BATCHING"],stageFlags:1,format:11,location:12}]}]},{name:"skybox",techniques:[{passes:[{rasterizerState:{cullMode:0},program:"skybox|sky-vs:vert|sky-fs:frag",priority:245,depthStencilState:{depthTest:!0,depthWrite:!1}}]}],shaders:[{name:"skybox|sky-vs:vert|sky-fs:frag",hash:2319917655,builtins:{globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplers:[{name:"cc_environment",defines:[]}]},locals:{blocks:[],samplers:[]}},defines:[{name:"CC_USE_IBL",type:"number",range:[0,2]},{name:"CC_USE_HDR",type:"boolean"},{name:"USE_RGBE_CUBEMAP",type:"boolean"}],blocks:[],samplers:[],attributes:[{name:"a_position",type:15,count:1,defines:[],stageFlags:1,format:32,location:0},{name:"a_normal",type:15,count:1,defines:[],stageFlags:1,format:32,location:1},{name:"a_texCoord",type:14,count:1,defines:[],stageFlags:1,format:21,location:2},{name:"a_tangent",type:16,count:1,defines:[],stageFlags:1,format:44,location:3}]}]},{name:"profiler",techniques:[{passes:[{blendState:{targets:[{blend:!0,blendSrc:2,blendDst:4,blendDstAlpha:4}]},rasterizerState:{cullMode:0},program:"profiler|profiler-vs:vert|profiler-fs:frag",depthStencilState:{depthTest:!1,depthWrite:!1}}]}],shaders:[{name:"profiler|profiler-vs:vert|profiler-fs:frag",hash:2029303284,builtins:{globals:{blocks:[{name:"CCGlobal",defines:[]},{name:"CCCamera",defines:[]}],samplers:[]},locals:{blocks:[],samplers:[]}},defines:[{name:"CC_USE_HDR",type:"boolean"}],blocks:[{name:"Constants",defines:[],binding:0,stageFlags:1,members:[{name:"offset",type:16,count:1}]},{name:"PerFrameInfo",defines:[],binding:1,stageFlags:1,members:[{name:"digits",type:16,count:20}]}],samplers:[{name:"mainTexture",type:28,count:1,defines:[],stageFlags:16,binding:2}],attributes:[{name:"a_position",type:15,count:1,defines:[],stageFlags:1,format:32,location:0},{name:"a_color",type:16,count:1,defines:[],stageFlags:1,format:44,location:1}]}]},{name:"splash-screen",techniques:[{passes:[{blendState:{targets:[{blend:!0,blendSrc:2,blendDst:4,blendDstAlpha:4}]},rasterizerState:{cullMode:0},program:"splash-screen|splash-screen-vs:vert|splash-screen-fs:frag",depthStencilState:{depthTest:!1,depthWrite:!1}}]}],shaders:[{name:"splash-screen|splash-screen-vs:vert|splash-screen-fs:frag",hash:2106901053,builtins:{globals:{blocks:[],samplers:[]},locals:{blocks:[],samplers:[]}},defines:[],blocks:[{name:"splashFrag",defines:[],binding:0,stageFlags:16,members:[{name:"u_precent",type:13,count:1}]}],samplers:[{name:"mainTexture",type:28,count:1,defines:[],stageFlags:16,binding:1}],attributes:[{name:"a_position",type:14,count:1,defines:[],stageFlags:1,format:21,location:0},{name:"a_texCoord",type:14,count:1,defines:[],stageFlags:1,format:21,location:1}]}]}]);!function(e){e[e.UBO=0]="UBO",e[e.SAMPLER=1]="SAMPLER"}(Ed||(Ed={}));var Ad=function(e,t,n,i,r){return void 0===r&&(r=0),e<<28&4026531840|i<<22&264241152|t<<20&3145728|n<<14&1032192|16383&r},xd=function(e){return(4026531840&e)>>>28},Cd=function(e){return(264241152&e)>>>22},Rd=function(e){return(1032192&e)>>>14},bd=function(e){return 16383&e},wd=function(e,t){return-264241153&e|t<<22&264241152},Id=((yd={})[Fa.UNKNOWN]=function(){return console.warn("illegal uniform handle")},yd[Fa.INT]=function(e,t,n){return void 0===n&&(n=0),e[n]},yd[Fa.INT2]=function(e,t,n){return void 0===n&&(n=0),qn.fromArray(t,e,n)},yd[Fa.INT3]=function(e,t,n){return void 0===n&&(n=0),bn.fromArray(t,e,n)},yd[Fa.INT4]=function(e,t,n){return void 0===n&&(n=0),Zn.fromArray(t,e,n)},yd[Fa.FLOAT]=function(e,t,n){return void 0===n&&(n=0),e[n]},yd[Fa.FLOAT2]=function(e,t,n){return void 0===n&&(n=0),qn.fromArray(t,e,n)},yd[Fa.FLOAT3]=function(e,t,n){return void 0===n&&(n=0),bn.fromArray(t,e,n)},yd[Fa.FLOAT4]=function(e,t,n){return void 0===n&&(n=0),Zn.fromArray(t,e,n)},yd[Fa.MAT3]=function(e,t,n){return void 0===n&&(n=0),Pn.fromArray(t,e,n)},yd[Fa.MAT4]=function(e,t,n){return void 0===n&&(n=0),Hn.fromArray(t,e,n)},yd),Od=((Sd={})[Fa.UNKNOWN]=function(){return console.warn("illegal uniform handle")},Sd[Fa.INT]=function(e,t,n){return void 0===n&&(n=0),e[n]=t},Sd[Fa.INT2]=function(e,t,n){return void 0===n&&(n=0),qn.toArray(e,t,n)},Sd[Fa.INT3]=function(e,t,n){return void 0===n&&(n=0),bn.toArray(e,t,n)},Sd[Fa.INT4]=function(e,t,n){return void 0===n&&(n=0),Zn.toArray(e,t,n)},Sd[Fa.FLOAT]=function(e,t,n){return void 0===n&&(n=0),e[n]=t},Sd[Fa.FLOAT2]=function(e,t,n){return void 0===n&&(n=0),qn.toArray(e,t,n)},Sd[Fa.FLOAT3]=function(e,t,n){return void 0===n&&(n=0),bn.toArray(e,t,n)},Sd[Fa.FLOAT4]=function(e,t,n){return void 0===n&&(n=0),Zn.toArray(e,t,n)},Sd[Fa.MAT3]=function(e,t,n){return void 0===n&&(n=0),Pn.toArray(e,t,n)},Sd[Fa.MAT4]=function(e,t,n){return void 0===n&&(n=0),Hn.toArray(e,t,n)},Sd),Pd=[Object.freeze([0]),Object.freeze([0,0]),Object.freeze([0,0,0,0]),Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])];function Md(e){switch(e){case Fa.BOOL:case Fa.INT:case Fa.UINT:case Fa.FLOAT:return Pd[0];case Fa.BOOL2:case Fa.INT2:case Fa.UINT2:case Fa.FLOAT2:return Pd[1];case Fa.BOOL4:case Fa.INT4:case Fa.UINT4:case Fa.FLOAT4:return Pd[2];case Fa.MAT4:return Pd[3];case Fa.SAMPLER2D:return"default-texture";case Fa.SAMPLER_CUBE:return"default-cube-texture"}return Pd[0]}function Nd(e,t){for(var n=Object.entries(t),i=!1,r=0;r31&&(n.uber=!0),this._templates[e.name]=n,!this._templateInfos[n.hash]){var s={};s.samplerStartBinding=n.blocks.length,s.gfxBlocks=[],s.gfxSamplers=[],s.bindings=[],s.blockSizes=[];for(var o=0;o>2)*o.count}for(var c=0;c 0.) {\n float s = 0.5 / sqrt(trace + 1.0);\n quat.w = 0.25 / s;\n quat.x = (m[2][1] - m[1][2]) * s;\n quat.y = (m[0][2] - m[2][0]) * s;\n quat.z = (m[1][0] - m[0][1]) * s;\n } else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\n float s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\n quat.w = (m[2][1] - m[1][2]) / s;\n quat.x = 0.25 * s;\n quat.y = (m[0][1] + m[1][0]) / s;\n quat.z = (m[0][2] + m[2][0]) / s;\n } else if (m[1][1] > m[2][2]) {\n float s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\n quat.w = (m[0][2] - m[2][0]) / s;\n quat.x = (m[0][1] + m[1][0]) / s;\n quat.y = 0.25 * s;\n quat.z = (m[1][2] + m[2][1]) / s;\n } else {\n float s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\n quat.w = (m[1][0] - m[0][1]) / s;\n quat.x = (m[0][2] + m[2][0]) / s;\n quat.y = (m[1][2] + m[2][1]) / s;\n quat.z = 0.25 * s;\n }\n float len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\n if (len > 0.) {\n len = 1. / sqrt(len);\n quat.x = quat.x * len;\n quat.y = quat.y * len;\n quat.z = quat.z * len;\n quat.w = quat.w * len;\n }\n return quat;\n}\nvec4 quaternionFromEuler (vec3 angle){\n float x = angle.x / 2.;\n float y = angle.y / 2.;\n float z = angle.z / 2.;\n float sx = sin(x);\n float cx = cos(x);\n float sy = sin(y);\n float cy = cos(y);\n float sz = sin(z);\n float cz = cos(z);\n vec4 quat = vec4(0);\n quat.x = sx * cy * cz + cx * sy * sz;\n quat.y = cx * sy * cz + sx * cy * sz;\n quat.z = cx * cy * sz - sx * sy * cz;\n quat.w = cx * cy * cz - sx * sy * sz;\n return quat;\n}\nvec4 quatMultiply (vec4 a, vec4 b){\n vec4 quat;\n quat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\n quat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\n quat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\n quat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\n return quat;\n}\nvoid rotateVecFromQuat (inout vec3 v, vec4 q){\n float ix = q.w * v.x + q.y * v.z - q.z * v.y;\n float iy = q.w * v.y + q.z * v.x - q.x * v.z;\n float iz = q.w * v.z + q.x * v.y - q.y * v.x;\n float iw = -q.x * v.x - q.y * v.y - q.z * v.z;\n v.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\n v.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\n v.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace (vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\n vec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\n vec4 rotQuat = quatMultiply(viewQuat, q);\n rotateVecFromQuat(pos, rotQuat);\n return pos;\n}\nvoid rotateCorner (inout vec2 corner, float angle){\n float xOS = cos(angle) * corner.x - sin(angle) * corner.y;\n float yOS = sin(angle) * corner.x + cos(angle) * corner.y;\n corner.x = xOS;\n corner.y = yOS;\n}\nvarying mediump vec2 uv;\nvarying mediump vec4 color;\nvoid computeVertPos (inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n , mat4 viewInv\n) {\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\n vec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\n vec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n}\nattribute vec3 a_position;\nattribute vec2 a_texCoord;\nattribute vec4 a_color;\nuniform vec4 cc_size_rotation;\nvec4 vs_main() {\n vec4 pos = vec4(a_position, 1);\n pos = cc_matWorld * pos;\n vec2 vertOffset = a_texCoord.xy - 0.5;\n computeVertPos(pos, vertOffset, quaternionFromEuler(vec3(0., 0., cc_size_rotation.z)), vec3(cc_size_rotation.xy, 0.), cc_matViewInv);\n pos = cc_matViewProj * pos;\n uv = a_texCoord.xy;\n color = a_color;\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }",frag:"\nprecision mediump float;\nuniform mediump vec4 cc_exposure;\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n #if CC_USE_HDR\n color.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n #endif\n return color;\n}\nvarying vec2 uv;\nvarying vec4 color;\nuniform sampler2D mainTexture;\nuniform vec4 tintColor;\nvec4 add () {\n vec4 col = 2.0 * color * tintColor * texture2D(mainTexture, uv);\n return CCFragOutput(col);\n}\nvoid main() { gl_FragColor = add(); }"}],[{vert:"\nprecision highp float;\nattribute vec3 a_position;\nvec4 vert () {\n vec4 pos = vec4(a_position, 1);\n return pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nvec4 frag () {\n vec4 o = vec4(1.0);\n return o;\n}\nvoid main() { gl_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nuniform highp mat4 cc_matViewProj;\nuniform highp mat4 cc_matWorld;\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\nattribute float a_dist;\nvarying float v_dist;\nvec4 vert () {\n vec4 pos = vec4(a_position, 1);\n pos = cc_matViewProj * cc_matWorld * pos;\n v_color = a_color;\n v_dist = a_dist;\n return pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\n#ifdef GL_OES_standard_derivatives\n#extension GL_OES_standard_derivatives: enable\n#endif\nprecision highp float;\nvarying vec4 v_color;\nvarying float v_dist;\nvec4 frag () {\n vec4 o = v_color;\n #ifdef GL_OES_standard_derivatives\n float aa = fwidth(v_dist);\n #else\n float aa = 0.05;\n #endif\n float alpha = 1. - smoothstep(-aa, 0., abs(v_dist) - 1.0);\n o.rgb *= o.a;\n o *= alpha;\n return o;\n}\nvoid main() { gl_FragColor = frag(); }"}],[{vert:"\nprecision mediump float;\nvec4 quaternionFromAxis (vec3 xAxis,vec3 yAxis,vec3 zAxis){\n mat3 m = mat3(xAxis,yAxis,zAxis);\n float trace = m[0][0] + m[1][1] + m[2][2];\n vec4 quat;\n if (trace > 0.) {\n float s = 0.5 / sqrt(trace + 1.0);\n quat.w = 0.25 / s;\n quat.x = (m[2][1] - m[1][2]) * s;\n quat.y = (m[0][2] - m[2][0]) * s;\n quat.z = (m[1][0] - m[0][1]) * s;\n } else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\n float s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\n quat.w = (m[2][1] - m[1][2]) / s;\n quat.x = 0.25 * s;\n quat.y = (m[0][1] + m[1][0]) / s;\n quat.z = (m[0][2] + m[2][0]) / s;\n } else if (m[1][1] > m[2][2]) {\n float s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\n quat.w = (m[0][2] - m[2][0]) / s;\n quat.x = (m[0][1] + m[1][0]) / s;\n quat.y = 0.25 * s;\n quat.z = (m[1][2] + m[2][1]) / s;\n } else {\n float s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\n quat.w = (m[1][0] - m[0][1]) / s;\n quat.x = (m[0][2] + m[2][0]) / s;\n quat.y = (m[1][2] + m[2][1]) / s;\n quat.z = 0.25 * s;\n }\n float len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\n if (len > 0.) {\n len = 1. / sqrt(len);\n quat.x = quat.x * len;\n quat.y = quat.y * len;\n quat.z = quat.z * len;\n quat.w = quat.w * len;\n }\n return quat;\n}\nvec4 quaternionFromEuler (vec3 angle){\n float x = angle.x / 2.;\n float y = angle.y / 2.;\n float z = angle.z / 2.;\n float sx = sin(x);\n float cx = cos(x);\n float sy = sin(y);\n float cy = cos(y);\n float sz = sin(z);\n float cz = cos(z);\n vec4 quat = vec4(0);\n quat.x = sx * cy * cz + cx * sy * sz;\n quat.y = cx * sy * cz + sx * cy * sz;\n quat.z = cx * cy * sz - sx * sy * cz;\n quat.w = cx * cy * cz - sx * sy * sz;\n return quat;\n}\nmat4 matrixFromRT (vec4 q, vec3 p){\n float x2 = q.x + q.x;\n float y2 = q.y + q.y;\n float z2 = q.z + q.z;\n float xx = q.x * x2;\n float xy = q.x * y2;\n float xz = q.x * z2;\n float yy = q.y * y2;\n float yz = q.y * z2;\n float zz = q.z * z2;\n float wx = q.w * x2;\n float wy = q.w * y2;\n float wz = q.w * z2;\n return mat4(\n 1. - (yy + zz), xy + wz, xz - wy, 0,\n xy - wz, 1. - (xx + zz), yz + wx, 0,\n xz + wy, yz - wx, 1. - (xx + yy), 0,\n p.x, p.y, p.z, 1\n );\n}\nmat4 matFromRTS (vec4 q, vec3 t, vec3 s){\n float x = q.x, y = q.y, z = q.z, w = q.w;\n float x2 = x + x;\n float y2 = y + y;\n float z2 = z + z;\n float xx = x * x2;\n float xy = x * y2;\n float xz = x * z2;\n float yy = y * y2;\n float yz = y * z2;\n float zz = z * z2;\n float wx = w * x2;\n float wy = w * y2;\n float wz = w * z2;\n float sx = s.x;\n float sy = s.y;\n float sz = s.z;\n return mat4((1. - (yy + zz)) * sx, (xy + wz) * sx, (xz - wy) * sx, 0,\n (xy - wz) * sy, (1. - (xx + zz)) * sy, (yz + wx) * sy, 0,\n (xz + wy) * sz, (yz - wx) * sz, (1. - (xx + yy)) * sz, 0,\n t.x, t.y, t.z, 1);\n}\nvec4 quatMultiply (vec4 a, vec4 b){\n vec4 quat;\n quat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\n quat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\n quat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\n quat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\n return quat;\n}\nvoid rotateVecFromQuat (inout vec3 v, vec4 q){\n float ix = q.w * v.x + q.y * v.z - q.z * v.y;\n float iy = q.w * v.y + q.z * v.x - q.x * v.z;\n float iz = q.w * v.z + q.x * v.y - q.y * v.x;\n float iw = -q.x * v.x - q.y * v.y - q.z * v.z;\n v.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\n v.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\n v.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace (vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\n vec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\n vec4 rotQuat = quatMultiply(viewQuat, q);\n rotateVecFromQuat(pos, rotQuat);\n return pos;\n}\nvoid rotateCorner (inout vec2 corner, float angle){\n float xOS = cos(angle) * corner.x - sin(angle) * corner.y;\n float yOS = sin(angle) * corner.x + cos(angle) * corner.y;\n corner.x = xOS;\n corner.y = yOS;\n}\nuniform vec4 mainTiling_Offset;\nuniform vec4 frameTile_velLenScale;\nuniform vec4 scale;\nuniform highp mat4 cc_matView;\nuniform highp mat4 cc_matViewInv;\nuniform highp mat4 cc_matViewProj;\nuniform highp vec4 cc_cameraPos;\nuniform highp mat4 cc_matWorld;\nvarying mediump vec2 uv;\nvarying mediump vec4 color;\nvoid computeVertPos (inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n#if CC_RENDER_MODE == 0 || CC_RENDER_MODE == 3\n , mat4 viewInv\n#endif\n#if CC_RENDER_MODE == 1\n , vec3 eye\n , vec4 velocity\n , float velocityScale\n , float lengthScale\n , float xIndex\n#endif\n) {\n#if CC_RENDER_MODE == 0\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\n vec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\n vec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_RENDER_MODE == 1\n vec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\n vec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\n pos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_RENDER_MODE == 2\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = vec3(1, 0, 0);\n vec3 camY = vec3(0, 0, -1);\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_RENDER_MODE == 3\n vec2 viewSpaceVert = vec2(vertOffset.x * s.x, vertOffset.y * s.y);\n rotateCorner(viewSpaceVert, q.z);\n vec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\n vec3 camY = vec3(0, 1, 0);\n vec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\n pos.xyz += offset;\n#else\n pos.x += vertOffset.x;\n pos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV (float frameIndex, vec2 vertIndex, vec2 frameTile){\n vec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\n aniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if CC_RENDER_MODE != 4\n vertIndex.y = 1. - vertIndex.y;\n#endif\n return (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nuniform vec4 u_sampleInfo;\nuniform vec4 u_worldRot;\nuniform vec4 u_timeDelta;\nattribute vec4 a_position_starttime;\nattribute vec4 a_size_uv;\nattribute vec4 a_rotation_uv;\nattribute vec4 a_color;\nattribute vec4 a_dir_life;\nattribute float a_rndSeed;\n#if CC_RENDER_MODE == 4\n attribute vec3 a_texCoord;\n attribute vec3 a_texCoord3;\n attribute vec3 a_normal;\n attribute vec4 a_color1;\n#endif\nvec3 unpackCurveData (sampler2D tex, vec2 coord) {\n vec4 a = texture2D(tex, coord);\n vec4 b = texture2D(tex, coord + u_sampleInfo.y);\n float c = fract(coord.x * u_sampleInfo.x);\n return mix(a.xyz, b.xyz, c);\n}\nvec3 unpackCurveData (sampler2D tex, vec2 coord, out float w) {\n vec4 a = texture2D(tex, coord);\n vec4 b = texture2D(tex, coord + u_sampleInfo.y);\n float c = fract(coord.x * u_sampleInfo.x);\n w = mix(a.w, b.w, c);\n return mix(a.xyz, b.xyz, c);\n}\nfloat pseudoRandom (float seed) {\n seed = mod(seed, 233280.);\n float q = (seed * 9301. + 49297.) / 233280.;\n return fract(q);\n}\n#if COLOR_OVER_TIME_MODULE_ENABLE\n uniform sampler2D color_over_time_tex0;\n uniform int u_color_mode;\n#endif\n#if ROTATION_OVER_TIME_MODULE_ENABLE\n uniform sampler2D rotation_over_time_tex0;\n uniform int u_rotation_mode;\n#endif\n#if SIZE_OVER_TIME_MODULE_ENABLE\n uniform sampler2D size_over_time_tex0;\n uniform int u_size_mode;\n#endif\n#if FORCE_OVER_TIME_MODULE_ENABLE\n uniform sampler2D force_over_time_tex0;\n uniform int u_force_mode;\nuniform int u_force_space;\n#endif\n#if VELOCITY_OVER_TIME_MODULE_ENABLE\n uniform sampler2D velocity_over_time_tex0;\n uniform int u_velocity_mode;\nuniform int u_velocity_space;\n#endif\n#if TEXTURE_ANIMATION_MODULE_ENABLE\n uniform sampler2D texture_animation_tex0;\n uniform vec4 u_anim_info;\n#endif\nfloat repeat (float t, float length) {\n return t - floor(t / length) * length;\n}\nvec4 rotateQuat (vec4 p, vec4 q) {\n vec3 iv = cross(q.xyz, p.xyz) + q.w * p.xyz;\n vec3 res = p.xyz + 2.0 * cross(q.xyz, iv);\n return vec4(res.xyz, p.w);\n}\nvec4 gpvs_main () {\n float activeTime = u_timeDelta.x - a_position_starttime.w;\n float normalizedTime = clamp(activeTime / a_dir_life.w, 0.0, 1.0);\n vec2 timeCoord0 = vec2(normalizedTime, 0.);\n vec2 timeCoord1 = vec2(normalizedTime, 1.);\n #if CC_RENDER_MODE == 4\n vec2 vertIdx = vec2(a_texCoord.x, a_texCoord.y);\n #else\n vec2 vertIdx = vec2(a_size_uv.w, a_rotation_uv.w);\n #endif\n vec4 velocity = vec4(a_dir_life.xyz, 0.);\n vec4 pos = vec4(a_position_starttime.xyz, 1.);\n vec3 size = a_size_uv.xyz;\n #if SIZE_OVER_TIME_MODULE_ENABLE\n if (u_size_mode == 1) {\n size *= unpackCurveData(size_over_time_tex0, timeCoord0);\n } else {\n vec3 size_0 = unpackCurveData(size_over_time_tex0, timeCoord0);\n vec3 size_1 = unpackCurveData(size_over_time_tex0, timeCoord1);\n float factor_s = pseudoRandom(a_rndSeed + 39825.);\n size *= mix(size_0, size_1, factor_s);\n }\n #endif\n vec3 compScale = scale.xyz * size;\n #if FORCE_OVER_TIME_MODULE_ENABLE\n vec3 forceAnim = vec3(0.);\n if (u_force_mode == 1) {\n forceAnim = unpackCurveData(force_over_time_tex0, timeCoord0);\n } else {\n vec3 force_0 = unpackCurveData(force_over_time_tex0, timeCoord0);\n vec3 force_1 = unpackCurveData(force_over_time_tex0, timeCoord1);\n float factor_f = pseudoRandom(a_rndSeed + 212165.);\n forceAnim = mix(force_0, force_1, factor_f);\n }\n vec4 forceTrack = vec4(forceAnim, 0.);\n if (u_force_space == 0) {\n forceTrack = rotateQuat(forceTrack, u_worldRot);\n }\n velocity.xyz += forceTrack.xyz;\n #endif\n #if VELOCITY_OVER_TIME_MODULE_ENABLE\n float speedModifier0 = 1.;\n float speedModifier1 = 1.;\n vec3 velocityAnim = vec3(0.);\n if (u_velocity_mode == 1) {\n velocityAnim = unpackCurveData(velocity_over_time_tex0, timeCoord0, speedModifier0);\n } else {\n vec3 vectory_0 = unpackCurveData(velocity_over_time_tex0, timeCoord0, speedModifier0);\n vec3 vectory_1 = unpackCurveData(velocity_over_time_tex0, timeCoord1, speedModifier1);\n float factor_v = pseudoRandom(a_rndSeed + 197866.);\n velocityAnim = mix(vectory_0, vectory_1, factor_v);\n speedModifier0 = mix(speedModifier0, speedModifier1, factor_v);\n }\n vec4 velocityTrack = vec4(velocityAnim, 0.);\n if (u_velocity_space == 0) {\n velocityTrack = rotateQuat(velocityTrack, u_worldRot);\n }\n velocity.xyz += velocityTrack.xyz;\n velocity.xyz *= speedModifier0;\n #endif\n pos.xyz += velocity.xyz * normalizedTime * a_dir_life.w;\n #if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n #if CC_RENDER_MODE == 1\n velocity = rotateQuat(velocity, u_worldRot);\n #endif\n #endif\n vec3 rotation = a_rotation_uv.xyz;\n #if ROTATION_OVER_TIME_MODULE_ENABLE\n if (u_rotation_mode == 1) {\n rotation += unpackCurveData(rotation_over_time_tex0, timeCoord0) * normalizedTime * a_dir_life.w;\n } else {\n vec3 rotation_0 = unpackCurveData(rotation_over_time_tex0, timeCoord0);\n vec3 rotation_1 = unpackCurveData(rotation_over_time_tex0, timeCoord1);\n float factor_r = pseudoRandom(a_rndSeed + 125292.);\n rotation += mix(rotation_0, rotation_1, factor_r) * normalizedTime * a_dir_life.w;\n }\n #endif\n #if COLOR_OVER_TIME_MODULE_ENABLE\n if (u_color_mode == 1) {\n color = a_color * texture2D(color_over_time_tex0, timeCoord0);\n } else {\n vec4 color_0 = texture2D(color_over_time_tex0, timeCoord0);\n vec4 color_1 = texture2D(color_over_time_tex0, timeCoord1);\n float factor_c = pseudoRandom(a_rndSeed + 91041.);\n color = a_color * mix(color_0, color_1, factor_c);\n }\n #else\n color = a_color;\n #endif\n #if CC_RENDER_MODE != 4\n vec2 cornerOffset = vec2((vertIdx - 0.5));\n #if CC_RENDER_MODE == 0\n vec3 rotEuler = rotation.xyz;\n #elif CC_RENDER_MODE == 1\n vec3 rotEuler = vec3(0.);\n #else\n vec3 rotEuler = vec3(0., 0., rotation.z);\n #endif\n computeVertPos(pos, cornerOffset, quaternionFromEuler(rotEuler), compScale\n #if CC_RENDER_MODE == 0 || CC_RENDER_MODE == 3\n , cc_matViewInv\n #endif\n #if CC_RENDER_MODE == 1\n , cc_cameraPos.xyz\n , velocity\n , frameTile_velLenScale.z\n , frameTile_velLenScale.w\n , a_size_uv.w\n #endif\n );\n #else\n mat4 xformNoScale = matrixFromRT(quaternionFromEuler(rotation), pos.xyz);\n mat4 xform = matFromRTS(quaternionFromEuler(rotation), pos.xyz, compScale);\n pos = xform * vec4(a_texCoord3, 1);\n vec4 normal = xformNoScale * vec4(a_normal, 0);\n color *= a_color1;\n #endif\n pos = cc_matViewProj * pos;\n float frameIndex = 0.;\n #if TEXTURE_ANIMATION_MODULE_ENABLE\n float startFrame = 0.;\n vec3 frameInfo = vec3(0.);\n if (int(u_anim_info.x) == 1) {\n frameInfo = unpackCurveData(texture_animation_tex0, timeCoord0);\n } else {\n vec3 frameInfo0 = unpackCurveData(texture_animation_tex0, timeCoord0);\n vec3 frameInfo1 = unpackCurveData(texture_animation_tex0, timeCoord1);\n float factor_t = pseudoRandom(a_rndSeed + 90794.);\n frameInfo = mix(frameInfo0, frameInfo1, factor_t);\n }\n startFrame = frameInfo.x / u_anim_info.y;\n frameIndex = repeat(u_anim_info.z * (frameInfo.y + startFrame), 1.);\n #endif\n uv = computeUV(frameIndex, vertIdx, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\n return pos;\n}\nvoid main() { gl_Position = gpvs_main(); }",frag:"\nprecision mediump float;\nuniform mediump vec4 cc_exposure;\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n #if CC_USE_HDR\n color.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n #endif\n return color;\n}\nvarying vec2 uv;\nvarying vec4 color;\nuniform sampler2D mainTexture;\nuniform vec4 tintColor;\nvec4 add () {\n vec4 col = 2.0 * color * tintColor * texture2D(mainTexture, uv);\n return CCFragOutput(col);\n}\nvoid main() { gl_FragColor = add(); }"}],[{vert:"\nprecision mediump float;\nuniform vec4 mainTiling_Offset;\nuniform highp mat4 cc_matViewProj;\nuniform highp vec4 cc_cameraPos;\nuniform highp mat4 cc_matWorld;\nvarying mediump vec2 uv;\nvarying mediump vec4 color;\nattribute vec3 a_position;\nattribute vec4 a_texCoord;\nattribute vec3 a_texCoord1;\nattribute vec3 a_texCoord2;\nattribute vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\n varying vec3 vBarycentric;\n#endif\nvec4 vs_main() {\n highp vec4 pos = vec4(a_position, 1);\n vec4 velocity = vec4(a_texCoord1.xyz, 0);\n #if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n velocity = cc_matWorld * velocity;\n #endif\n float vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\n vec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\n pos.xyz += camUp * vertOffset;\n pos = cc_matViewProj * pos;\n uv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\n color = a_color;\n #if CC_DRAW_WIRE_FRAME\n vBarycentric = a_texCoord2;\n #endif\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }",frag:"\n precision mediump float;\nuniform mediump vec4 cc_exposure;\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n #if CC_USE_HDR\n color.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n #endif\n return color;\n}\n varying vec2 uv;\n varying vec4 color;\n #if CC_DRAW_WIRE_FRAME\n varying vec3 vBarycentric;\n #endif\n uniform sampler2D mainTexture;\n uniform vec4 tintColor;\n vec4 add () {\n vec4 col = 2.0 * color * tintColor * texture2D(mainTexture, uv);\n#if CC_DRAW_WIRE_FRAME\n if (any(lessThan(vBarycentric, vec3(0.02)))) {\n col = vec4(0., 1., 1., 1.);\n }\n#endif\n return CCFragOutput(col);\n }\nvoid main() { gl_FragColor = add(); }"}],[{vert:"\nprecision highp float;\nvec4 quaternionFromAxis (vec3 xAxis,vec3 yAxis,vec3 zAxis){\n mat3 m = mat3(xAxis,yAxis,zAxis);\n float trace = m[0][0] + m[1][1] + m[2][2];\n vec4 quat;\n if (trace > 0.) {\n float s = 0.5 / sqrt(trace + 1.0);\n quat.w = 0.25 / s;\n quat.x = (m[2][1] - m[1][2]) * s;\n quat.y = (m[0][2] - m[2][0]) * s;\n quat.z = (m[1][0] - m[0][1]) * s;\n } else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\n float s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\n quat.w = (m[2][1] - m[1][2]) / s;\n quat.x = 0.25 * s;\n quat.y = (m[0][1] + m[1][0]) / s;\n quat.z = (m[0][2] + m[2][0]) / s;\n } else if (m[1][1] > m[2][2]) {\n float s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\n quat.w = (m[0][2] - m[2][0]) / s;\n quat.x = (m[0][1] + m[1][0]) / s;\n quat.y = 0.25 * s;\n quat.z = (m[1][2] + m[2][1]) / s;\n } else {\n float s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\n quat.w = (m[1][0] - m[0][1]) / s;\n quat.x = (m[0][2] + m[2][0]) / s;\n quat.y = (m[1][2] + m[2][1]) / s;\n quat.z = 0.25 * s;\n }\n float len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\n if (len > 0.) {\n len = 1. / sqrt(len);\n quat.x = quat.x * len;\n quat.y = quat.y * len;\n quat.z = quat.z * len;\n quat.w = quat.w * len;\n }\n return quat;\n}\nvec4 quaternionFromEuler (vec3 angle){\n float x = angle.x / 2.;\n float y = angle.y / 2.;\n float z = angle.z / 2.;\n float sx = sin(x);\n float cx = cos(x);\n float sy = sin(y);\n float cy = cos(y);\n float sz = sin(z);\n float cz = cos(z);\n vec4 quat = vec4(0);\n quat.x = sx * cy * cz + cx * sy * sz;\n quat.y = cx * sy * cz + sx * cy * sz;\n quat.z = cx * cy * sz - sx * sy * cz;\n quat.w = cx * cy * cz - sx * sy * sz;\n return quat;\n}\nmat4 matrixFromRT (vec4 q, vec3 p){\n float x2 = q.x + q.x;\n float y2 = q.y + q.y;\n float z2 = q.z + q.z;\n float xx = q.x * x2;\n float xy = q.x * y2;\n float xz = q.x * z2;\n float yy = q.y * y2;\n float yz = q.y * z2;\n float zz = q.z * z2;\n float wx = q.w * x2;\n float wy = q.w * y2;\n float wz = q.w * z2;\n return mat4(\n 1. - (yy + zz), xy + wz, xz - wy, 0,\n xy - wz, 1. - (xx + zz), yz + wx, 0,\n xz + wy, yz - wx, 1. - (xx + yy), 0,\n p.x, p.y, p.z, 1\n );\n}\nmat4 matFromRTS (vec4 q, vec3 t, vec3 s){\n float x = q.x, y = q.y, z = q.z, w = q.w;\n float x2 = x + x;\n float y2 = y + y;\n float z2 = z + z;\n float xx = x * x2;\n float xy = x * y2;\n float xz = x * z2;\n float yy = y * y2;\n float yz = y * z2;\n float zz = z * z2;\n float wx = w * x2;\n float wy = w * y2;\n float wz = w * z2;\n float sx = s.x;\n float sy = s.y;\n float sz = s.z;\n return mat4((1. - (yy + zz)) * sx, (xy + wz) * sx, (xz - wy) * sx, 0,\n (xy - wz) * sy, (1. - (xx + zz)) * sy, (yz + wx) * sy, 0,\n (xz + wy) * sz, (yz - wx) * sz, (1. - (xx + yy)) * sz, 0,\n t.x, t.y, t.z, 1);\n}\nvec4 quatMultiply (vec4 a, vec4 b){\n vec4 quat;\n quat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\n quat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\n quat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\n quat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\n return quat;\n}\nvoid rotateVecFromQuat (inout vec3 v, vec4 q){\n float ix = q.w * v.x + q.y * v.z - q.z * v.y;\n float iy = q.w * v.y + q.z * v.x - q.x * v.z;\n float iz = q.w * v.z + q.x * v.y - q.y * v.x;\n float iw = -q.x * v.x - q.y * v.y - q.z * v.z;\n v.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\n v.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\n v.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace (vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\n vec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\n vec4 rotQuat = quatMultiply(viewQuat, q);\n rotateVecFromQuat(pos, rotQuat);\n return pos;\n}\nvoid rotateCorner (inout vec2 corner, float angle){\n float xOS = cos(angle) * corner.x - sin(angle) * corner.y;\n float yOS = sin(angle) * corner.x + cos(angle) * corner.y;\n corner.x = xOS;\n corner.y = yOS;\n}\nuniform vec4 mainTiling_Offset;\nuniform vec4 frameTile_velLenScale;\nuniform vec4 scale;\nuniform highp mat4 cc_matView;\nuniform highp mat4 cc_matViewInv;\nuniform highp mat4 cc_matViewProj;\nuniform highp vec4 cc_cameraPos;\nuniform highp mat4 cc_matWorld;\nvarying mediump vec2 uv;\nvarying mediump vec4 color;\nvoid computeVertPos (inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n#if CC_RENDER_MODE == 0 || CC_RENDER_MODE == 3\n , mat4 viewInv\n#endif\n#if CC_RENDER_MODE == 1\n , vec3 eye\n , vec4 velocity\n , float velocityScale\n , float lengthScale\n , float xIndex\n#endif\n) {\n#if CC_RENDER_MODE == 0\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\n vec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\n vec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_RENDER_MODE == 1\n vec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\n vec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\n pos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_RENDER_MODE == 2\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = vec3(1, 0, 0);\n vec3 camY = vec3(0, 0, -1);\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_RENDER_MODE == 3\n vec2 viewSpaceVert = vec2(vertOffset.x * s.x, vertOffset.y * s.y);\n rotateCorner(viewSpaceVert, q.z);\n vec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\n vec3 camY = vec3(0, 1, 0);\n vec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\n pos.xyz += offset;\n#else\n pos.x += vertOffset.x;\n pos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV (float frameIndex, vec2 vertIndex, vec2 frameTile){\n vec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\n aniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if CC_RENDER_MODE != 4\n vertIndex.y = 1. - vertIndex.y;\n#endif\n return (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nattribute vec3 a_position;\nattribute vec3 a_texCoord;\nattribute vec3 a_texCoord1;\nattribute vec3 a_texCoord2;\nattribute vec4 a_color;\n#if CC_RENDER_MODE == 1\n attribute vec3 a_color1;\n#endif\n#if CC_RENDER_MODE == 4\n attribute vec3 a_texCoord3;\n attribute vec3 a_normal;\n attribute vec4 a_color1;\n#endif\nvec4 lpvs_main () {\n vec3 compScale = scale.xyz * a_texCoord1;\n vec4 pos = vec4(a_position, 1);\n #if CC_RENDER_MODE == 1\n vec4 velocity = vec4(a_color1.xyz, 0);\n #endif\n #if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n #if CC_RENDER_MODE == 1\n velocity = cc_matWorld * velocity;\n #endif\n #endif\n #if CC_RENDER_MODE != 4\n vec2 cornerOffset = vec2((a_texCoord.xy - 0.5));\n #if CC_RENDER_MODE == 0\n vec3 rotEuler = a_texCoord2;\n #elif CC_RENDER_MODE == 1\n vec3 rotEuler = vec3(0.);\n #else\n vec3 rotEuler = vec3(0., 0., a_texCoord2.z);\n #endif\n computeVertPos(pos, cornerOffset, quaternionFromEuler(rotEuler), compScale\n #if CC_RENDER_MODE == 0 || CC_RENDER_MODE == 3\n , cc_matViewInv\n #endif\n #if CC_RENDER_MODE == 1\n , cc_cameraPos.xyz\n , velocity\n , frameTile_velLenScale.z\n , frameTile_velLenScale.w\n , a_texCoord.x\n #endif\n );\n color = a_color;\n #else\n mat4 xformNoScale = matrixFromRT(quaternionFromEuler(a_texCoord2), pos.xyz);\n mat4 xform = matFromRTS(quaternionFromEuler(a_texCoord2), pos.xyz, compScale);\n pos = xform * vec4(a_texCoord3, 1);\n vec4 normal = xformNoScale * vec4(a_normal, 0);\n color = a_color * a_color1;\n #endif\n uv = computeUV(a_texCoord.z, a_texCoord.xy, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\n pos = cc_matViewProj * pos;\n return pos;\n}\nvoid main() { gl_Position = lpvs_main(); }",frag:"\nprecision mediump float;\nuniform mediump vec4 cc_exposure;\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n #if CC_USE_HDR\n color.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n #endif\n return color;\n}\nvarying vec2 uv;\nvarying vec4 color;\nuniform sampler2D mainTexture;\nuniform vec4 tintColor;\nvec4 add () {\n vec4 col = 2.0 * color * tintColor * texture2D(mainTexture, uv);\n return CCFragOutput(col);\n}\nvoid main() { gl_FragColor = add(); }"}],[{vert:"\nprecision highp float;\nuniform highp mat4 cc_matViewProj;\n#if USE_LOCAL\nuniform highp mat4 cc_matWorld;\n#endif\nattribute vec3 a_position;\nattribute vec2 a_texCoord;\nattribute vec4 a_color;\nvarying vec4 v_light;\nvarying vec2 uv0;\n#if TWO_COLORED\n attribute vec4 a_color2;\n varying vec4 v_dark;\n#endif\nvec4 vert () {\n vec4 pos = vec4(a_position, 1);\n #if USE_LOCAL\n pos = cc_matWorld * pos;\n #endif\n pos = cc_matViewProj * pos;\n uv0 = a_texCoord;\n v_light = a_color;\n #if TWO_COLORED\n v_dark = a_color2;\n #endif\n return pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvarying vec4 v_light;\n#if TWO_COLORED\n varying vec4 v_dark;\n#endif\nvarying vec2 uv0;\nuniform sampler2D cc_spriteTexture;\nvec4 frag () {\n vec4 o = vec4(1, 1, 1, 1);\n #if TWO_COLORED\n vec4 texColor = vec4(1, 1, 1, 1);\n texColor *= texture2D(cc_spriteTexture, uv0);\n o.a = texColor.a * v_light.a;\n o.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;\n #else\n o *= texture2D(cc_spriteTexture, uv0);\n o *= v_light;\n #endif\n ALPHA_TEST(o);\n return o;\n}\nvoid main() { gl_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nuniform highp mat4 cc_matView;\nuniform highp mat4 cc_matProj;\nuniform highp mat4 cc_matViewProj;\n#if USE_LOCAL\nuniform highp mat4 cc_matWorld;\n#endif\nattribute vec3 a_position;\nattribute vec2 a_texCoord;\nattribute vec4 a_color;\nvarying vec4 color;\nvarying vec2 uv0;\nvec4 vert () {\n vec4 pos = vec4(a_position, 1);\n #if USE_LOCAL\n pos = cc_matWorld * pos;\n #endif\n #if USE_PIXEL_ALIGNMENT\n pos = cc_matView * pos;\n pos.xyz = floor(pos.xyz);\n pos = cc_matProj * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n uv0 = a_texCoord;\n color = a_color;\n return pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nvec4 CCSampleWithAlphaSeparated(sampler2D tex, vec2 uv) {\n#if CC_USE_EMBEDDED_ALPHA\n return vec4(texture2D(tex, uv).rgb, texture2D(tex, uv + vec2(0.0, 0.5)).r);\n#else\n return texture2D(tex, uv);\n#endif\n}\n#if USE_ALPHA_TEST\n uniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvarying vec4 color;\n#if USE_TEXTURE\n varying vec2 uv0;\n uniform sampler2D cc_spriteTexture;\n#endif\nvec4 frag () {\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n o *= CCSampleWithAlphaSeparated(cc_spriteTexture, uv0);\n #if IS_GRAY\n float gray = 0.2126 * o.r + 0.7152 * o.g + 0.0722 * o.b;\n o.r = o.g = o.b = gray;\n #endif\n #endif\n o *= color;\n ALPHA_TEST(o);\n return o;\n}\nvoid main() { gl_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\n rgba = rgba * 255.0;\n highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\n highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\n highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\n highp vec4 position;\n vec3 normal;\n vec4 tangent;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nattribute vec4 a_tangent;\n#if CC_USE_MORPH\n attribute float a_vertexId;\n int getVertexId() {\n return int(a_vertexId);\n }\nuniform vec4 cc_displacementWeights[15];\nuniform vec4 cc_displacementTextureInfo;\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\n float pixelIndexF = float(pixelIndex);\n float x = mod(pixelIndexF, textureResolution.x);\n float y = floor(pixelIndexF / textureResolution.x);\n return vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\n return (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_SUPPORT_FLOAT_TEXTURE\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 uv = getPixelCoordFromLocation(location, cc_displacementTextureInfo.xy);\n return texture2D(tex, uv);\n }\n#else\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex * 4;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\n return vec4(\n decode32(texture2D(tex, x)),\n decode32(texture2D(tex, y)),\n decode32(texture2D(tex, z)),\n 1.0\n );\n }\n#endif\nfloat getDisplacementWeight(int index) {\n int quot = index / 4;\n int remainder = index - quot * 4;\n if (remainder == 0) {\n return cc_displacementWeights[quot].x;\n } else if (remainder == 1) {\n return cc_displacementWeights[quot].y;\n } else if (remainder == 2) {\n return cc_displacementWeights[quot].z;\n } else {\n return cc_displacementWeights[quot].w;\n }\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\n return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\n vec3 result = vec3(0, 0, 0);\n int nVertices = int(cc_displacementTextureInfo.z);\n for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\n result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n }\n return result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\n uniform sampler2D cc_PositionDisplacements;\n vec3 getPositionDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n uniform sampler2D cc_NormalDisplacements;\n vec3 getNormalDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n uniform sampler2D cc_TangentDisplacements;\n vec3 getTangentDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n }\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\n int vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\n attr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n attr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n attr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\n attribute vec4 a_joints;\nattribute vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n #if USE_INSTANCING\n attribute highp vec4 a_jointAnimInfo;\n #endif\n uniform highp vec4 cc_jointTextureInfo;\n uniform highp vec4 cc_jointAnimInfo;\n uniform highp sampler2D cc_jointTexture;\n #else\n uniform highp vec4 cc_joints[90];\n#endif\n#if CC_USE_BAKED_ANIMATION\n #if CC_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y));\n vec4 v2 = texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y));\n vec4 v3 = texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n );\n vec4 v2 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n );\n vec4 v3 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n#else\n mat4 getJointMatrix (float i) {\n int idx = int(i);\n vec4 v1 = cc_joints[idx * 3];\n vec4 v2 = cc_joints[idx * 3 + 1];\n vec4 v3 = cc_joints[idx * 3 + 2];\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n#endif\nmat4 skinMatrix () {\n vec4 joints = vec4(a_joints);\n return getJointMatrix(joints.x) * a_weights.x\n + getJointMatrix(joints.y) * a_weights.y\n + getJointMatrix(joints.z) * a_weights.z\n + getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\n mat4 m = skinMatrix();\n position = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\n mat4 m = skinMatrix();\n attr.position = m * attr.position;\n attr.normal = (m * vec4(attr.normal, 0.0)).xyz;\n attr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nuniform highp mat4 cc_matView;\nuniform highp mat4 cc_matProj;\nuniform highp vec4 cc_cameraPos;\nuniform mediump vec4 cc_fogBase;\nuniform mediump vec4 cc_fogAdd;\n#if USE_INSTANCING\n attribute vec4 a_matWorld0;\n attribute vec4 a_matWorld1;\n attribute vec4 a_matWorld2;\n #if USE_LIGHTMAP\n attribute vec4 a_lightingMapUVParam;\n #endif\n#elif USE_BATCHING\n attribute float a_dyn_batch_id;\n uniform highp mat4 cc_matWorlds[10];\n#else\nuniform highp mat4 cc_matWorld;\nuniform highp mat4 cc_matWorldIT;\nuniform highp vec4 cc_lightingMapUVParam;\n#endif\nuniform vec4 tilingOffset;\nfloat LinearFog(vec4 pos) {\n vec4 wPos = pos;\n float cam_dis = distance(cc_cameraPos, wPos);\n float fogStart = cc_fogBase.x;\n float fogEnd = cc_fogBase.y;\n return clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float fogDensity = cc_fogBase.z;\n float cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\n float f = exp(-cam_dis * fogDensity);\n return f;\n}\nfloat ExpSquaredFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float fogDensity = cc_fogBase.z;\n float cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\n float f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\n return f;\n}\nfloat LayeredFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float _FogTop = cc_fogAdd.x;\n float _FogRange = cc_fogAdd.y;\n vec3 camWorldProj = cc_cameraPos.xyz;\n camWorldProj.y = 0.;\n vec3 worldPosProj = wPos.xyz;\n worldPosProj.y = 0.;\n float fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\n float fDeltaY, fDensityIntegral;\n if (cc_cameraPos.y > _FogTop) {\n if (wPos.y < _FogTop) {\n fDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\n fDensityIntegral = fDeltaY * fDeltaY * 0.5;\n } else {\n fDeltaY = 0.;\n fDensityIntegral = 0.;\n }\n } else {\n if (wPos.y < _FogTop) {\n float fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\n float fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\n fDeltaY = abs(fDeltaA - fDeltaB);\n fDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n } else {\n fDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\n fDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n }\n }\n float fDensity;\n if (fDeltaY != 0.) {\n fDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n } else {\n fDensity = 0.;\n }\n float f = exp(-fDensity);\n return f;\n}\nfloat CC_TRANSFER_FOG(vec4 pos) {\n #if CC_USE_FOG == 0\n return LinearFog(pos);\n\t#elif CC_USE_FOG == 1\n return ExpFog(pos);\n #elif CC_USE_FOG == 2\n return ExpSquaredFog(pos);\n #elif CC_USE_FOG == 3\n return LayeredFog(pos);\n #endif\n return 1.;\n}\nvarying highp vec4 v_shadowPos;\nuniform highp mat4 cc_matLightViewProj;\n#if USE_VERTEX_COLOR\n attribute vec4 a_color;\n varying vec4 v_color;\n#endif\nvarying vec3 v_position;\nvarying vec3 v_normal;\nvarying vec2 v_uv;\nvarying vec2 v_uv1;\nvarying float v_fog_factor;\n#if USE_NORMAL_MAP\n varying vec3 v_tangent;\n varying vec3 v_bitangent;\n#endif\n#if HAS_SECOND_UV || USE_LIGHTMAP\n attribute vec2 a_texCoord1;\n#endif\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\n varying vec2 v_luv;\nvoid CCLightingMapCaclUV()\n{\n#if !USE_INSTANCING\n v_luv = cc_lightingMapUVParam.xy + a_texCoord1 * cc_lightingMapUVParam.zw;\n#else\n v_luv = a_lightingMapUVParam.xy + a_texCoord1 * a_lightingMapUVParam.zw;\n#endif\n}\n#endif\nvec4 vert () {\n StandardVertInput In;\n In.position = vec4(a_position, 1.0);\n In.normal = a_normal;\n In.tangent = a_tangent;\n #if CC_USE_MORPH\n applyMorph(In);\n #endif\n #if CC_USE_SKINNING\n CCSkin(In);\n #endif\n mat4 matWorld, matWorldIT;\n #if USE_INSTANCING\n matWorld = mat4(\n vec4(a_matWorld0.xyz, 0.0),\n vec4(a_matWorld1.xyz, 0.0),\n vec4(a_matWorld2.xyz, 0.0),\n vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n );\n matWorldIT = matWorld;\n #elif USE_BATCHING\n matWorld = cc_matWorlds[int(a_dyn_batch_id)];\n matWorldIT = matWorld;\n #else\n matWorld = cc_matWorld;\n matWorldIT = cc_matWorldIT;\n #endif\n vec4 pos = matWorld * In.position;\n v_position = pos.xyz;\n v_normal = normalize((matWorldIT * vec4(In.normal, 0.0)).xyz);\n #if USE_NORMAL_MAP\n v_tangent = normalize((matWorld * vec4(In.tangent.xyz, 0.0)).xyz);\n v_bitangent = cross(v_normal, v_tangent) * In.tangent.w;\n #endif\n v_uv = a_texCoord * tilingOffset.xy + tilingOffset.zw;\n #if HAS_SECOND_UV\n v_uv1 = a_texCoord1 * tilingOffset.xy + tilingOffset.zw;\n #endif\n #if USE_VERTEX_COLOR\n v_color = a_color;\n #endif\n v_fog_factor = CC_TRANSFER_FOG(pos);\n #if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\n CCLightingMapCaclUV();\n #endif\n v_shadowPos = cc_matLightViewProj * pos;\n return cc_matProj * (cc_matView * matWorld) * In.position;\n}\nvoid main() { gl_Position = vert(); }",frag:"\n#ifdef GL_EXT_shader_texture_lod\n#extension GL_EXT_shader_texture_lod: enable\n#endif\nprecision highp float;\nuniform highp vec4 cc_cameraPos;\nuniform mediump vec4 cc_exposure;\nuniform mediump vec4 cc_mainLitDir;\nuniform mediump vec4 cc_mainLitColor;\nuniform mediump vec4 cc_ambientSky;\nuniform mediump vec4 cc_ambientGround;\nuniform mediump vec4 cc_fogColor;\nuniform lowp vec4 cc_shadowColor;\nuniform lowp vec4 cc_shadowInfo;\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\nvec3 unpackRGBE (vec4 rgbe) {\n return rgbe.rgb * pow(2.0, rgbe.a * 255.0 - 128.0);\n}\nvec4 fragTextureLod (sampler2D tex, vec2 coord, float lod) {\n #ifdef GL_EXT_shader_texture_lod\n return texture2DLodEXT(tex, coord, lod);\n #else\n return texture2D(tex, coord, lod);\n #endif\n}\nvec4 fragTextureLod (samplerCube tex, vec3 coord, float lod) {\n #ifdef GL_EXT_shader_texture_lod\n return textureCubeLodEXT(tex, coord, lod);\n #else\n return textureCube(tex, coord, lod);\n #endif\n}\n#endif\n#if CC_RECEIVE_SHADOW\nvarying highp vec4 v_shadowPos;\n#if CC_RECEIVE_SHADOW\n uniform sampler2D cc_shadowMap;\n uniform sampler2D cc_spotLightingMap;\n float CCGetShadowFactorX1 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float closestDepth = dot(texture2D(cc_shadowMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n float shadow = step(closestDepth, clipPos.z - cc_shadowInfo.w);\n return shadow;\n }\n float CCGetShadowFactorX5 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n float closestDepth = 0.0;\n closestDepth = dot(texture2D(cc_shadowMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_shadowMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_shadowMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_shadowMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n return shadow / 5.0;\n }\n float CCGetShadowFactorX9 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -1; i <= 1; i++) {\n for (int j = -1; j <= 1; j++) {\n float closestDepth = dot(texture2D(cc_shadowMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 9.0;\n }\n float CCGetShadowFactorX25 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -2; i <= 2; i++) {\n for (int j = -2; j <= 2; j++) {\n float closestDepth = dot(texture2D(cc_shadowMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 25.0;\n }\n float CCGetDirLightShadowFactorX1 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float closestDepth = dot(texture2D(cc_spotLightingMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n float shadow = step(closestDepth, clipPos.z - cc_shadowInfo.w);\n return shadow;\n }\n float CCGetDirLightShadowFactorX5 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n float closestDepth = 0.0;\n closestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n return shadow / 5.0;\n }\n float CCGetDirLightShadowFactorX9 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -1; i <= 1; i++) {\n for (int j = -1; j <= 1; j++) {\n float closestDepth = dot(texture2D(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 9.0;\n }\n float CCGetDirLightShadowFactorX25 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -2; i <= 2; i++) {\n for (int j = -2; j <= 2; j++) {\n float closestDepth = dot(texture2D(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 25.0;\n }\n#endif\n#endif\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nfloat GGXMobile (float roughness, float NoH, vec3 H, vec3 N) {\n vec3 NxH = cross(N, H);\n float OneMinusNoHSqr = dot(NxH, NxH);\n float a = roughness * roughness;\n float n = NoH * a;\n float p = a / (OneMinusNoHSqr + n * n);\n return p * p;\n}\nfloat CalcSpecular (float roughness, float NoH, vec3 H, vec3 N) {\n return (roughness*0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox (vec3 specular, float roughness, float NoV) {\n const vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\n const vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\n vec4 r = roughness * c0 + c1;\n float a004 = min( r.x * r.x, exp2( -9.28 * NoV ) ) * r.x + r.y;\n vec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n AB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\n return specular * AB.x + AB.y;\n}\nstruct StandardSurface {\n vec4 albedo;\n vec3 position;\n vec3 normal;\n vec3 emissive;\n vec4 lightmap;\n float roughness;\n float metallic;\n float occlusion;\n};\n#if CC_FORWARD_ADD\nuniform highp vec4 cc_lightPos[1];\nuniform vec4 cc_lightColor[1];\nuniform vec4 cc_lightSizeRangeAngle[1];\nuniform vec4 cc_lightDir[1];\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\n float factor = distSqr * invSqrAttRadius;\n float smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\n return smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\n float attenuation = 1.0 / max(distSqr, 0.01*0.01);\n attenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\n return attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\n float cd = dot(litDir, L);\n float attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\n return (attenuation * attenuation);\n}\n vec4 CCStandardShading (StandardSurface s) {\n vec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\n vec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\n vec3 diffuseContrib = diffuse / 3.14159265359;\n vec3 N = normalize(s.normal);\n vec3 V = normalize(cc_cameraPos.xyz - s.position);\n float NV = max(abs(dot(N, V)), 0.001);\n specular = BRDFApprox(specular, s.roughness, NV);\n vec3 finalColor = vec3(0.0);\n for (int i = 0; i < 1; i++) {\n vec3 SLU = cc_lightPos[i].xyz - s.position;\n vec3 SL = normalize(SLU);\n vec3 SH = normalize(SL + V);\n float SNL = max(dot(N, SL), 0.001);\n float SNH = max(dot(N, SH), 0.0);\n float distSqr = dot(SLU, SLU);\n float litRadius = cc_lightSizeRangeAngle[i].x;\n float litRadiusSqr = litRadius * litRadius;\n float illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\n float attRadiusSqrInv = 1.0 / max(cc_lightSizeRangeAngle[i].y, 0.01);\n attRadiusSqrInv *= attRadiusSqrInv;\n float att = GetDistAtt(distSqr, attRadiusSqrInv);\n vec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\n if (cc_lightPos[i].w > 0.0) {\n float cosInner = max(dot(-cc_lightDir[i].xyz, SL), 0.01);\n float cosOuter = cc_lightSizeRangeAngle[i].z;\n float litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\n float litAngleOffset = -cosOuter * litAngleScale;\n att *= GetAngleAtt(SL, -cc_lightDir[i].xyz, litAngleScale, litAngleOffset);\n }\n vec3 lightColor = cc_lightColor[i].rgb;\n #if CC_RECEIVE_SHADOW\n if (cc_lightPos[i].w > 0.0) {\n {\n float pcf = cc_shadowInfo.z + 0.001;\n float shadowAttenuation = 0.0;\n if (pcf > 3.0) shadowAttenuation = CCGetDirLightShadowFactorX25();\n else if (3.0 > pcf && pcf > 2.0) shadowAttenuation = CCGetDirLightShadowFactorX9();\n else if (2.0 > pcf && pcf > 1.0) shadowAttenuation = CCGetDirLightShadowFactorX5();\n else shadowAttenuation = CCGetDirLightShadowFactorX1();\n lightColor *= 1.0 - shadowAttenuation;\n }\n }\n #endif\n finalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n }\n finalColor = finalColor * s.occlusion;\n return vec4(finalColor, 0.0);\n }\n#else\n vec4 CCStandardShading (StandardSurface s) {\n vec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\n vec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\n vec3 N = normalize(s.normal);\n vec3 V = normalize(cc_cameraPos.xyz - s.position);\n float NV = max(abs(dot(N, V)), 0.001);\n specular = BRDFApprox(specular, s.roughness, NV);\n vec3 L = normalize(-cc_mainLitDir.xyz);\n vec3 H = normalize(L+V);\n float NH = max(dot(N, H), 0.0);\n float NL = max(dot(N, L), 0.001);\n vec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w;\n #if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\n finalColor = s.lightmap.a * s.lightmap.rgb + (1.0 - s.lightmap.a) * finalColor;\n #endif\n vec3 diffuseContrib = diffuse / 3.14159265359;\n vec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\n finalColor *= (diffuseContrib + specularContrib);\n float fAmb = 0.5 - N.y * 0.5;\n vec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb) * cc_ambientSky.w;\n finalColor += (ambDiff.rgb * diffuse);\n #if CC_USE_IBL\n vec3 R = normalize(reflect(-V, N));\n vec4 envmap = fragTextureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n #if CC_USE_IBL == 2\n vec3 env = unpackRGBE(envmap);\n #else\n vec3 env = SRGBToLinear(envmap.rgb);\n #endif\n finalColor += env * cc_ambientSky.w * specular;\n #endif\n finalColor = finalColor * s.occlusion;\n #if CC_USE_HDR\n s.emissive *= cc_exposure.w;\n #endif\n finalColor += s.emissive;\n #if CC_RECEIVE_SHADOW\n {\n float pcf = cc_shadowInfo.z + 0.001;\n float shadowAttenuation = 0.0;\n if (pcf > 3.0) shadowAttenuation = CCGetShadowFactorX25();\n else if (3.0 > pcf && pcf > 2.0) shadowAttenuation = CCGetShadowFactorX9();\n else if (2.0 > pcf && pcf > 1.0) shadowAttenuation = CCGetShadowFactorX5();\n else shadowAttenuation = CCGetShadowFactorX1();\n vec3 shadowColor = cc_shadowColor.rgb * cc_shadowColor.a + finalColor.rgb * (1.0 - cc_shadowColor.a);\n finalColor.rgb = shadowColor.rgb * shadowAttenuation * NL + finalColor.rgb * (1.0 - shadowAttenuation * NL);\n }\n #endif\n return vec4(finalColor, s.albedo.a);\n }\n#endif\nvec3 ACESToneMap (vec3 color) {\n color = min(color, vec3(8.0));\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n #if !CC_USE_HDR\n color.rgb = sqrt(ACESToneMap(color.rgb));\n #endif\n return color;\n}\nuniform vec4 albedo;\nuniform vec4 albedoScaleAndCutoff;\nuniform vec4 pbrParams;\nuniform vec4 emissive;\nuniform vec4 emissiveScaleParam;\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\n varying vec2 v_luv;\nuniform sampler2D cc_lightingMap;\n#endif\nvarying vec3 v_position;\nvarying vec2 v_uv;\nvarying vec2 v_uv1;\nvarying vec3 v_normal;\nvarying float v_fog_factor;\n#if USE_VERTEX_COLOR\n varying vec4 v_color;\n#endif\n#if USE_ALBEDO_MAP\n uniform sampler2D albedoMap;\n#endif\n#if USE_NORMAL_MAP\n varying vec3 v_tangent;\n varying vec3 v_bitangent;\n uniform sampler2D normalMap;\n#endif\n#if USE_PBR_MAP\n uniform sampler2D pbrMap;\n#endif\n#if USE_METALLIC_ROUGHNESS_MAP\n uniform sampler2D metallicRoughnessMap;\n#endif\n#if USE_OCCLUSION_MAP\n uniform sampler2D occlusionMap;\n#endif\n#if USE_EMISSIVE_MAP\n uniform sampler2D emissiveMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\nvoid surf (out StandardSurface s) {\n vec4 baseColor = albedo;\n #if USE_VERTEX_COLOR\n baseColor *= v_color;\n #endif\n #if USE_ALBEDO_MAP\n vec4 texColor = texture2D(albedoMap, ALBEDO_UV);\n texColor.rgb = SRGBToLinear(texColor.rgb);\n baseColor *= texColor;\n #endif\n s.albedo = baseColor;\n s.albedo.rgb *= albedoScaleAndCutoff.xyz;\n #if USE_ALPHA_TEST\n if (s.albedo.ALPHA_TEST_CHANNEL < albedoScaleAndCutoff.w) discard;\n #endif\n #if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\n s.lightmap = texture2D(cc_lightingMap, v_luv);\n #endif\n s.normal = v_normal;\n #if USE_NORMAL_MAP\n vec3 nmmp = texture2D(normalMap, NORMAL_UV).xyz - vec3(0.5);\n s.normal =\n (nmmp.x * pbrParams.w) * normalize(v_tangent) +\n (nmmp.y * pbrParams.w) * normalize(v_bitangent) +\n nmmp.z * normalize(s.normal);\n #endif\n s.position = v_position;\n vec4 pbr = pbrParams;\n #if USE_PBR_MAP\n vec4 res = texture2D(pbrMap, PBR_UV);\n pbr.x *= res.r;\n pbr.y *= res.g;\n pbr.z *= res.b;\n #endif\n #if USE_METALLIC_ROUGHNESS_MAP\n vec4 metallicRoughness = texture2D(metallicRoughnessMap, PBR_UV);\n pbr.z *= metallicRoughness.b;\n pbr.y *= metallicRoughness.g;\n #endif\n #if USE_OCCLUSION_MAP\n pbr.x *= texture2D(occlusionMap, PBR_UV).r;\n #endif\n s.occlusion = clamp(pbr.x, 0.0, 0.96);\n s.roughness = clamp(pbr.y, 0.04, 1.0);\n s.metallic = pbr.z;\n s.emissive = emissive.rgb * emissiveScaleParam.xyz;\n #if USE_EMISSIVE_MAP\n s.emissive *= SRGBToLinear(texture2D(emissiveMap, EMISSIVE_UV).rgb);\n #endif\n}\nvec4 frag () {\n StandardSurface s; surf(s);\n vec4 color = CCStandardShading(s);\n color = vec4(mix(CC_FORWARD_ADD > 0 ? vec3(0.0) : cc_fogColor.rgb, color.rgb, v_fog_factor), color.a);\n return CCFragOutput(color);\n}\nvoid main() { gl_FragColor = frag(); }"},{vert:"\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\n rgba = rgba * 255.0;\n highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\n highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\n highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\n highp vec4 position;\n vec3 normal;\n vec4 tangent;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nattribute vec4 a_tangent;\n#if CC_USE_MORPH\n attribute float a_vertexId;\n int getVertexId() {\n return int(a_vertexId);\n }\nuniform vec4 cc_displacementWeights[15];\nuniform vec4 cc_displacementTextureInfo;\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\n float pixelIndexF = float(pixelIndex);\n float x = mod(pixelIndexF, textureResolution.x);\n float y = floor(pixelIndexF / textureResolution.x);\n return vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\n return (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_SUPPORT_FLOAT_TEXTURE\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 uv = getPixelCoordFromLocation(location, cc_displacementTextureInfo.xy);\n return texture2D(tex, uv);\n }\n#else\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex * 4;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\n return vec4(\n decode32(texture2D(tex, x)),\n decode32(texture2D(tex, y)),\n decode32(texture2D(tex, z)),\n 1.0\n );\n }\n#endif\nfloat getDisplacementWeight(int index) {\n int quot = index / 4;\n int remainder = index - quot * 4;\n if (remainder == 0) {\n return cc_displacementWeights[quot].x;\n } else if (remainder == 1) {\n return cc_displacementWeights[quot].y;\n } else if (remainder == 2) {\n return cc_displacementWeights[quot].z;\n } else {\n return cc_displacementWeights[quot].w;\n }\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\n return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\n vec3 result = vec3(0, 0, 0);\n int nVertices = int(cc_displacementTextureInfo.z);\n for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\n result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n }\n return result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\n uniform sampler2D cc_PositionDisplacements;\n vec3 getPositionDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n uniform sampler2D cc_NormalDisplacements;\n vec3 getNormalDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n uniform sampler2D cc_TangentDisplacements;\n vec3 getTangentDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n }\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\n int vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\n attr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n attr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n attr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\n attribute vec4 a_joints;\nattribute vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n #if USE_INSTANCING\n attribute highp vec4 a_jointAnimInfo;\n #endif\n uniform highp vec4 cc_jointTextureInfo;\n uniform highp vec4 cc_jointAnimInfo;\n uniform highp sampler2D cc_jointTexture;\n #else\n uniform highp vec4 cc_joints[90];\n#endif\n#if CC_USE_BAKED_ANIMATION\n #if CC_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y));\n vec4 v2 = texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y));\n vec4 v3 = texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n );\n vec4 v2 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n );\n vec4 v3 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n#else\n mat4 getJointMatrix (float i) {\n int idx = int(i);\n vec4 v1 = cc_joints[idx * 3];\n vec4 v2 = cc_joints[idx * 3 + 1];\n vec4 v3 = cc_joints[idx * 3 + 2];\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n#endif\nmat4 skinMatrix () {\n vec4 joints = vec4(a_joints);\n return getJointMatrix(joints.x) * a_weights.x\n + getJointMatrix(joints.y) * a_weights.y\n + getJointMatrix(joints.z) * a_weights.z\n + getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\n mat4 m = skinMatrix();\n position = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\n mat4 m = skinMatrix();\n attr.position = m * attr.position;\n attr.normal = (m * vec4(attr.normal, 0.0)).xyz;\n attr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\n#if USE_INSTANCING\n attribute vec4 a_matWorld0;\n attribute vec4 a_matWorld1;\n attribute vec4 a_matWorld2;\n #if USE_LIGHTMAP\n attribute vec4 a_lightingMapUVParam;\n #endif\n#elif USE_BATCHING\n attribute float a_dyn_batch_id;\n uniform highp mat4 cc_matWorlds[10];\n#else\nuniform highp mat4 cc_matWorld;\nuniform highp mat4 cc_matWorldIT;\n#endif\nuniform vec4 tilingOffset;\nuniform highp mat4 cc_matLightViewProj;\n#if HAS_SECOND_UV || USE_LIGHTMAP\n attribute vec2 a_texCoord1;\n#endif\nvarying vec2 v_uv;\nvarying vec2 v_uv1;\nvarying float v_clip_depth;\nvec4 vert () {\n StandardVertInput In;\n In.position = vec4(a_position, 1.0);\n In.normal = a_normal;\n In.tangent = a_tangent;\n #if CC_USE_MORPH\n applyMorph(In);\n #endif\n #if CC_USE_SKINNING\n CCSkin(In);\n #endif\n mat4 matWorld, matWorldIT;\n #if USE_INSTANCING\n matWorld = mat4(\n vec4(a_matWorld0.xyz, 0.0),\n vec4(a_matWorld1.xyz, 0.0),\n vec4(a_matWorld2.xyz, 0.0),\n vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n );\n matWorldIT = matWorld;\n #elif USE_BATCHING\n matWorld = cc_matWorlds[int(a_dyn_batch_id)];\n matWorldIT = matWorld;\n #else\n matWorld = cc_matWorld;\n matWorldIT = cc_matWorldIT;\n #endif\n vec4 worldPos = matWorld * In.position;\n vec4 clipPos = cc_matLightViewProj * worldPos;\n v_uv = a_texCoord * tilingOffset.xy + tilingOffset.zw;\n #if HAS_SECOND_UV\n v_uv1 = a_texCoord1 * tilingOffset.xy + tilingOffset.zw;\n #endif\n v_clip_depth = clipPos.z / clipPos.w * 0.5 + 0.5;\n return clipPos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nuniform vec4 albedo;\nuniform vec4 albedoScaleAndCutoff;\nvec4 packDepthToRGBA (float depth) {\n vec4 ret = vec4(1.0, 255.0, 65025.0, 160581375.0) * depth;\n ret = fract(ret);\n ret -= ret.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n return ret;\n}\nvarying vec2 v_uv;\nvarying vec2 v_uv1;\nvarying float v_clip_depth;\n#if USE_ALBEDO_MAP\n uniform sampler2D albedoMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\nvec4 frag () {\n vec4 baseColor = albedo;\n #if USE_ALBEDO_MAP\n baseColor *= texture2D(albedoMap, ALBEDO_UV);\n #endif\n #if USE_ALPHA_TEST\n if (baseColor.ALPHA_TEST_CHANNEL < albedoScaleAndCutoff.w) discard;\n #endif\n return packDepthToRGBA(v_clip_depth);\n}\nvoid main() { gl_FragColor = frag(); }"}],[{vert:"\nprecision mediump float;\nuniform highp mat4 cc_matViewProj;\nuniform highp vec4 cc_cameraPos;\nuniform mediump vec4 cc_fogBase;\nuniform mediump vec4 cc_fogAdd;\nuniform highp mat4 cc_matWorld;\nfloat LinearFog(vec4 pos) {\n vec4 wPos = pos;\n float cam_dis = distance(cc_cameraPos, wPos);\n float fogStart = cc_fogBase.x;\n float fogEnd = cc_fogBase.y;\n return clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float fogDensity = cc_fogBase.z;\n float cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\n float f = exp(-cam_dis * fogDensity);\n return f;\n}\nfloat ExpSquaredFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float fogDensity = cc_fogBase.z;\n float cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\n float f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\n return f;\n}\nfloat LayeredFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float _FogTop = cc_fogAdd.x;\n float _FogRange = cc_fogAdd.y;\n vec3 camWorldProj = cc_cameraPos.xyz;\n camWorldProj.y = 0.;\n vec3 worldPosProj = wPos.xyz;\n worldPosProj.y = 0.;\n float fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\n float fDeltaY, fDensityIntegral;\n if (cc_cameraPos.y > _FogTop) {\n if (wPos.y < _FogTop) {\n fDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\n fDensityIntegral = fDeltaY * fDeltaY * 0.5;\n } else {\n fDeltaY = 0.;\n fDensityIntegral = 0.;\n }\n } else {\n if (wPos.y < _FogTop) {\n float fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\n float fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\n fDeltaY = abs(fDeltaA - fDeltaB);\n fDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n } else {\n fDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\n fDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n }\n }\n float fDensity;\n if (fDeltaY != 0.) {\n fDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n } else {\n fDensity = 0.;\n }\n float f = exp(-fDensity);\n return f;\n}\nfloat CC_TRANSFER_FOG(vec4 pos) {\n #if CC_USE_FOG == 0\n return LinearFog(pos);\n\t#elif CC_USE_FOG == 1\n return ExpFog(pos);\n #elif CC_USE_FOG == 2\n return ExpSquaredFog(pos);\n #elif CC_USE_FOG == 3\n return LayeredFog(pos);\n #endif\n return 1.;\n}\nvarying highp vec4 v_shadowPos;\nuniform highp mat4 cc_matLightViewProj;\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nvarying highp vec3 v_position;\nvarying mediump vec3 v_normal;\n#if USE_NORMALMAP\n varying mediump vec3 v_tangent;\n varying mediump vec3 v_binormal;\n#endif\nvarying mediump vec2 uvw;\nvarying mediump vec2 uv0;\nvarying mediump vec2 uv1;\nvarying mediump vec2 uv2;\nvarying mediump vec2 uv3;\nvarying mediump vec2 luv;\nvarying mediump vec3 diffuse;\nvarying mediump float v_fog_factor;\nuniform vec4 UVScale;\nuniform vec4 lightMapUVParam;\nvec4 vert () {\n vec3 worldPos;\n worldPos.x = cc_matWorld[3][0] + a_position.x;\n worldPos.y = cc_matWorld[3][1] + a_position.y;\n worldPos.z = cc_matWorld[3][2] + a_position.z;\n vec4 pos = vec4(worldPos, 1.0);\n pos = cc_matViewProj * pos;\n uvw = a_texCoord;\n uv0 = a_position.xz * UVScale.x;\n uv1 = a_position.xz * UVScale.y;\n uv2 = a_position.xz * UVScale.z;\n uv3 = a_position.xz * UVScale.w;\n #if USE_LIGHTMAP\n luv = lightMapUVParam.xy + a_texCoord * lightMapUVParam.zw;\n #endif\n v_position = worldPos;\n v_normal = a_normal;\n v_fog_factor = CC_TRANSFER_FOG(vec4(worldPos, 1.0));\n #if USE_NORMALMAP\n v_tangent = vec3(1.0, 0.0, 0.0);\n v_binormal = vec3(0.0, 0.0, 1.0);\n v_binormal = cross(v_tangent, a_normal);\n v_tangent = cross(a_normal, v_binormal);\n #endif\n v_shadowPos = cc_matLightViewProj * vec4(worldPos, 1.0);\n return pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\n#ifdef GL_EXT_shader_texture_lod\n#extension GL_EXT_shader_texture_lod: enable\n#endif\nprecision highp float;\nuniform highp vec4 cc_cameraPos;\nuniform mediump vec4 cc_exposure;\nuniform mediump vec4 cc_mainLitDir;\nuniform mediump vec4 cc_mainLitColor;\nuniform mediump vec4 cc_ambientSky;\nuniform mediump vec4 cc_ambientGround;\nuniform mediump vec4 cc_fogColor;\nuniform lowp vec4 cc_shadowColor;\nuniform lowp vec4 cc_shadowInfo;\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\nvec3 unpackRGBE (vec4 rgbe) {\n return rgbe.rgb * pow(2.0, rgbe.a * 255.0 - 128.0);\n}\nvec4 fragTextureLod (sampler2D tex, vec2 coord, float lod) {\n #ifdef GL_EXT_shader_texture_lod\n return texture2DLodEXT(tex, coord, lod);\n #else\n return texture2D(tex, coord, lod);\n #endif\n}\nvec4 fragTextureLod (samplerCube tex, vec3 coord, float lod) {\n #ifdef GL_EXT_shader_texture_lod\n return textureCubeLodEXT(tex, coord, lod);\n #else\n return textureCube(tex, coord, lod);\n #endif\n}\n#endif\n#if CC_RECEIVE_SHADOW\nvarying highp vec4 v_shadowPos;\n#if CC_RECEIVE_SHADOW\n uniform sampler2D cc_shadowMap;\n uniform sampler2D cc_spotLightingMap;\n float CCGetShadowFactorX1 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float closestDepth = dot(texture2D(cc_shadowMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n float shadow = step(closestDepth, clipPos.z - cc_shadowInfo.w);\n return shadow;\n }\n float CCGetShadowFactorX5 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n float closestDepth = 0.0;\n closestDepth = dot(texture2D(cc_shadowMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_shadowMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_shadowMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_shadowMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n return shadow / 5.0;\n }\n float CCGetShadowFactorX9 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -1; i <= 1; i++) {\n for (int j = -1; j <= 1; j++) {\n float closestDepth = dot(texture2D(cc_shadowMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 9.0;\n }\n float CCGetShadowFactorX25 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -2; i <= 2; i++) {\n for (int j = -2; j <= 2; j++) {\n float closestDepth = dot(texture2D(cc_shadowMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 25.0;\n }\n float CCGetDirLightShadowFactorX1 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float closestDepth = dot(texture2D(cc_spotLightingMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n float shadow = step(closestDepth, clipPos.z - cc_shadowInfo.w);\n return shadow;\n }\n float CCGetDirLightShadowFactorX5 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n float closestDepth = 0.0;\n closestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture2D(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n return shadow / 5.0;\n }\n float CCGetDirLightShadowFactorX9 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -1; i <= 1; i++) {\n for (int j = -1; j <= 1; j++) {\n float closestDepth = dot(texture2D(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 9.0;\n }\n float CCGetDirLightShadowFactorX25 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -2; i <= 2; i++) {\n for (int j = -2; j <= 2; j++) {\n float closestDepth = dot(texture2D(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 25.0;\n }\n#endif\n#endif\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nfloat GGXMobile (float roughness, float NoH, vec3 H, vec3 N) {\n vec3 NxH = cross(N, H);\n float OneMinusNoHSqr = dot(NxH, NxH);\n float a = roughness * roughness;\n float n = NoH * a;\n float p = a / (OneMinusNoHSqr + n * n);\n return p * p;\n}\nfloat CalcSpecular (float roughness, float NoH, vec3 H, vec3 N) {\n return (roughness*0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox (vec3 specular, float roughness, float NoV) {\n const vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\n const vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\n vec4 r = roughness * c0 + c1;\n float a004 = min( r.x * r.x, exp2( -9.28 * NoV ) ) * r.x + r.y;\n vec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n AB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\n return specular * AB.x + AB.y;\n}\nstruct StandardSurface {\n vec4 albedo;\n vec3 position;\n vec3 normal;\n vec3 emissive;\n vec4 lightmap;\n float roughness;\n float metallic;\n float occlusion;\n};\n#if CC_FORWARD_ADD\nuniform highp vec4 cc_lightPos[1];\nuniform vec4 cc_lightColor[1];\nuniform vec4 cc_lightSizeRangeAngle[1];\nuniform vec4 cc_lightDir[1];\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\n float factor = distSqr * invSqrAttRadius;\n float smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\n return smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\n float attenuation = 1.0 / max(distSqr, 0.01*0.01);\n attenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\n return attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\n float cd = dot(litDir, L);\n float attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\n return (attenuation * attenuation);\n}\n vec4 CCStandardShading (StandardSurface s) {\n vec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\n vec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\n vec3 diffuseContrib = diffuse / 3.14159265359;\n vec3 N = normalize(s.normal);\n vec3 V = normalize(cc_cameraPos.xyz - s.position);\n float NV = max(abs(dot(N, V)), 0.001);\n specular = BRDFApprox(specular, s.roughness, NV);\n vec3 finalColor = vec3(0.0);\n for (int i = 0; i < 1; i++) {\n vec3 SLU = cc_lightPos[i].xyz - s.position;\n vec3 SL = normalize(SLU);\n vec3 SH = normalize(SL + V);\n float SNL = max(dot(N, SL), 0.001);\n float SNH = max(dot(N, SH), 0.0);\n float distSqr = dot(SLU, SLU);\n float litRadius = cc_lightSizeRangeAngle[i].x;\n float litRadiusSqr = litRadius * litRadius;\n float illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\n float attRadiusSqrInv = 1.0 / max(cc_lightSizeRangeAngle[i].y, 0.01);\n attRadiusSqrInv *= attRadiusSqrInv;\n float att = GetDistAtt(distSqr, attRadiusSqrInv);\n vec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\n if (cc_lightPos[i].w > 0.0) {\n float cosInner = max(dot(-cc_lightDir[i].xyz, SL), 0.01);\n float cosOuter = cc_lightSizeRangeAngle[i].z;\n float litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\n float litAngleOffset = -cosOuter * litAngleScale;\n att *= GetAngleAtt(SL, -cc_lightDir[i].xyz, litAngleScale, litAngleOffset);\n }\n vec3 lightColor = cc_lightColor[i].rgb;\n #if CC_RECEIVE_SHADOW\n if (cc_lightPos[i].w > 0.0) {\n {\n float pcf = cc_shadowInfo.z + 0.001;\n float shadowAttenuation = 0.0;\n if (pcf > 3.0) shadowAttenuation = CCGetDirLightShadowFactorX25();\n else if (3.0 > pcf && pcf > 2.0) shadowAttenuation = CCGetDirLightShadowFactorX9();\n else if (2.0 > pcf && pcf > 1.0) shadowAttenuation = CCGetDirLightShadowFactorX5();\n else shadowAttenuation = CCGetDirLightShadowFactorX1();\n lightColor *= 1.0 - shadowAttenuation;\n }\n }\n #endif\n finalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n }\n finalColor = finalColor * s.occlusion;\n return vec4(finalColor, 0.0);\n }\n#else\n vec4 CCStandardShading (StandardSurface s) {\n vec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\n vec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\n vec3 N = normalize(s.normal);\n vec3 V = normalize(cc_cameraPos.xyz - s.position);\n float NV = max(abs(dot(N, V)), 0.001);\n specular = BRDFApprox(specular, s.roughness, NV);\n vec3 L = normalize(-cc_mainLitDir.xyz);\n vec3 H = normalize(L+V);\n float NH = max(dot(N, H), 0.0);\n float NL = max(dot(N, L), 0.001);\n vec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w;\n #if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\n finalColor = s.lightmap.a * s.lightmap.rgb + (1.0 - s.lightmap.a) * finalColor;\n #endif\n vec3 diffuseContrib = diffuse / 3.14159265359;\n vec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\n finalColor *= (diffuseContrib + specularContrib);\n float fAmb = 0.5 - N.y * 0.5;\n vec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb) * cc_ambientSky.w;\n finalColor += (ambDiff.rgb * diffuse);\n #if CC_USE_IBL\n vec3 R = normalize(reflect(-V, N));\n vec4 envmap = fragTextureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n #if CC_USE_IBL == 2\n vec3 env = unpackRGBE(envmap);\n #else\n vec3 env = SRGBToLinear(envmap.rgb);\n #endif\n finalColor += env * cc_ambientSky.w * specular;\n #endif\n finalColor = finalColor * s.occlusion;\n #if CC_USE_HDR\n s.emissive *= cc_exposure.w;\n #endif\n finalColor += s.emissive;\n #if CC_RECEIVE_SHADOW\n {\n float pcf = cc_shadowInfo.z + 0.001;\n float shadowAttenuation = 0.0;\n if (pcf > 3.0) shadowAttenuation = CCGetShadowFactorX25();\n else if (3.0 > pcf && pcf > 2.0) shadowAttenuation = CCGetShadowFactorX9();\n else if (2.0 > pcf && pcf > 1.0) shadowAttenuation = CCGetShadowFactorX5();\n else shadowAttenuation = CCGetShadowFactorX1();\n vec3 shadowColor = cc_shadowColor.rgb * cc_shadowColor.a + finalColor.rgb * (1.0 - cc_shadowColor.a);\n finalColor.rgb = shadowColor.rgb * shadowAttenuation * NL + finalColor.rgb * (1.0 - shadowAttenuation * NL);\n }\n #endif\n return vec4(finalColor, s.albedo.a);\n }\n#endif\nvec3 ACESToneMap (vec3 color) {\n color = min(color, vec3(8.0));\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n #if !CC_USE_HDR\n color.rgb = sqrt(ACESToneMap(color.rgb));\n #endif\n return color;\n}\nvarying highp vec3 v_position;\nvarying mediump vec3 v_normal;\n#if USE_NORMALMAP\n varying mediump vec3 v_tangent;\n varying mediump vec3 v_binormal;\n#endif\nvarying mediump vec2 uvw;\nvarying mediump vec2 uv0;\nvarying mediump vec2 uv1;\nvarying mediump vec2 uv2;\nvarying mediump vec2 uv3;\nvarying mediump vec3 diffuse;\nvarying mediump vec2 luv;\nvarying mediump float v_fog_factor;\nuniform vec4 metallic;\nuniform vec4 roughness;\nuniform sampler2D weightMap;\nuniform sampler2D detailMap0;\nuniform sampler2D detailMap1;\nuniform sampler2D detailMap2;\nuniform sampler2D detailMap3;\nuniform sampler2D normalMap0;\nuniform sampler2D normalMap1;\nuniform sampler2D normalMap2;\nuniform sampler2D normalMap3;\nuniform sampler2D lightMap;\nvoid surf (out StandardSurface s) {\n #if LAYERS > 1\n vec4 w = texture2D(weightMap, uvw);\n #endif\n vec4 baseColor = vec4(0, 0, 0, 0);\n #if LAYERS == 1\n baseColor = texture2D(detailMap0, uv0);\n #elif LAYERS == 2\n baseColor += texture2D(detailMap0, uv0) * w.r;\n baseColor += texture2D(detailMap1, uv1) * w.g;\n #elif LAYERS == 3\n baseColor += texture2D(detailMap0, uv0) * w.r;\n baseColor += texture2D(detailMap1, uv1) * w.g;\n baseColor += texture2D(detailMap2, uv2) * w.b;\n #elif LAYERS == 4\n baseColor += texture2D(detailMap0, uv0) * w.r;\n baseColor += texture2D(detailMap1, uv1) * w.g;\n baseColor += texture2D(detailMap2, uv2) * w.b;\n baseColor += texture2D(detailMap3, uv3) * w.a;\n #else\n baseColor = texture2D(detailMap0, uv0);\n #endif\n s.position = v_position;\n #if USE_NORMALMAP\n vec4 baseNormal = vec4(0, 0, 0, 0);\n #if LAYERS == 1\n baseNormal = texture2D(normalMap0, uv0);\n #elif LAYERS == 2\n baseNormal += texture2D(normalMap0, uv0) * w.r;\n baseNormal += texture2D(normalMap1, uv1) * w.g;\n #elif LAYERS == 3\n baseNormal += texture2D(normalMap0, uv0) * w.r;\n baseNormal += texture2D(normalMap1, uv1) * w.g;\n baseNormal += texture2D(normalMap2, uv2) * w.b;\n #elif LAYERS == 4\n baseNormal += texture2D(normalMap0, uv0) * w.r;\n baseNormal += texture2D(normalMap1, uv1) * w.g;\n baseNormal += texture2D(normalMap2, uv2) * w.b;\n baseNormal += texture2D(normalMap3, uv3) * w.a;\n #else\n baseNormal = texture2D(normalMap0, uv0);\n #endif\n vec3 nmmp = baseNormal.xyz - vec3(0.5);\n s.normal =\n nmmp.x * normalize(v_tangent) +\n nmmp.y * normalize(v_binormal) +\n nmmp.z * normalize(v_normal);\n #else\n s.normal = v_normal;\n #endif\n s.albedo = vec4(SRGBToLinear(baseColor.rgb), 1.0);\n s.occlusion = 1.0;\n #if USE_PBR\n s.roughness = 0.0;\n #if LAYERS == 1\n s.roughness = roughness.x;\n #elif LAYERS == 2\n s.roughness += roughness.x * w.r;\n s.roughness += roughness.y * w.g;\n #elif LAYERS == 3\n s.roughness += roughness.x * w.r;\n s.roughness += roughness.y * w.g;\n s.roughness += roughness.z * w.b;\n #elif LAYERS == 4\n s.roughness += roughness.x * w.r;\n s.roughness += roughness.y * w.g;\n s.roughness += roughness.z * w.b;\n s.roughness += roughness.w * w.a;\n #else\n s.roughness = 1.0;\n #endif\n s.metallic = 0.0;\n #if LAYERS == 1\n s.metallic = metallic.x;\n #elif LAYERS == 2\n s.metallic += metallic.x * w.r;\n s.metallic += metallic.y * w.g;\n #elif LAYERS == 3\n s.metallic += metallic.x * w.r;\n s.metallic += metallic.y * w.g;\n s.metallic += metallic.z * w.b;\n #elif LAYERS == 4\n s.metallic += metallic.x * w.r;\n s.metallic += metallic.y * w.g;\n s.metallic += metallic.z * w.b;\n s.metallic += metallic.w * w.a;\n #else\n s.metallic = 0.0;\n #endif\n #else\n s.roughness = 1.0;\n s.metallic = 0.0;\n #endif\n s.emissive = vec3(0.0, 0.0, 0.0);\n #if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\n s.lightmap = texture2D(lightMap, luv);\n #else\n s.lightmap = vec4(0.0, 0.0, 0.0, 0.0);\n #endif\n}\nvec4 frag () {\n StandardSurface s; surf(s);\n vec4 color = CCStandardShading(s);\n color = vec4(mix(CC_FORWARD_ADD > 0 ? vec3(0.0) : cc_fogColor.rgb, color.rgb, v_fog_factor), color.a);\n return CCFragOutput(color);\n}\nvoid main() { gl_FragColor = frag(); }"},{vert:"\nprecision highp float;\nuniform highp mat4 cc_matWorld;\nuniform highp mat4 cc_matLightViewProj;\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nvarying vec2 v_clip_depth;\nvec4 vert () {\n vec4 worldPos;\n worldPos.x = cc_matWorld[3][0] + a_position.x;\n worldPos.y = cc_matWorld[3][1] + a_position.y;\n worldPos.z = cc_matWorld[3][2] + a_position.z;\n worldPos.w = 1.0;\n vec4 clipPos = cc_matLightViewProj * worldPos;\n v_clip_depth = clipPos.zw;\n return clipPos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nvec4 packDepthToRGBA (float depth) {\n vec4 ret = vec4(1.0, 255.0, 65025.0, 160581375.0) * depth;\n ret = fract(ret);\n ret -= ret.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n return ret;\n}\nvarying vec2 v_clip_depth;\nvec4 frag () {\n return packDepthToRGBA(v_clip_depth.x / v_clip_depth.y * 0.5 + 0.5);\n}\nvoid main() { gl_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\n rgba = rgba * 255.0;\n highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\n highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\n highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\n highp vec4 position;\n vec3 normal;\n vec4 tangent;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nattribute vec4 a_tangent;\n#if CC_USE_MORPH\n attribute float a_vertexId;\n int getVertexId() {\n return int(a_vertexId);\n }\nuniform vec4 cc_displacementWeights[15];\nuniform vec4 cc_displacementTextureInfo;\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\n float pixelIndexF = float(pixelIndex);\n float x = mod(pixelIndexF, textureResolution.x);\n float y = floor(pixelIndexF / textureResolution.x);\n return vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\n return (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_SUPPORT_FLOAT_TEXTURE\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 uv = getPixelCoordFromLocation(location, cc_displacementTextureInfo.xy);\n return texture2D(tex, uv);\n }\n#else\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex * 4;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\n return vec4(\n decode32(texture2D(tex, x)),\n decode32(texture2D(tex, y)),\n decode32(texture2D(tex, z)),\n 1.0\n );\n }\n#endif\nfloat getDisplacementWeight(int index) {\n int quot = index / 4;\n int remainder = index - quot * 4;\n if (remainder == 0) {\n return cc_displacementWeights[quot].x;\n } else if (remainder == 1) {\n return cc_displacementWeights[quot].y;\n } else if (remainder == 2) {\n return cc_displacementWeights[quot].z;\n } else {\n return cc_displacementWeights[quot].w;\n }\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\n return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\n vec3 result = vec3(0, 0, 0);\n int nVertices = int(cc_displacementTextureInfo.z);\n for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\n result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n }\n return result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\n uniform sampler2D cc_PositionDisplacements;\n vec3 getPositionDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n uniform sampler2D cc_NormalDisplacements;\n vec3 getNormalDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n uniform sampler2D cc_TangentDisplacements;\n vec3 getTangentDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n }\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\n int vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\n attr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n attr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n attr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\n attribute vec4 a_joints;\nattribute vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n #if USE_INSTANCING\n attribute highp vec4 a_jointAnimInfo;\n #endif\n uniform highp vec4 cc_jointTextureInfo;\n uniform highp vec4 cc_jointAnimInfo;\n uniform highp sampler2D cc_jointTexture;\n #else\n uniform highp vec4 cc_joints[90];\n#endif\n#if CC_USE_BAKED_ANIMATION\n #if CC_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y));\n vec4 v2 = texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y));\n vec4 v3 = texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n );\n vec4 v2 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n );\n vec4 v3 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n#else\n mat4 getJointMatrix (float i) {\n int idx = int(i);\n vec4 v1 = cc_joints[idx * 3];\n vec4 v2 = cc_joints[idx * 3 + 1];\n vec4 v3 = cc_joints[idx * 3 + 2];\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n#endif\nmat4 skinMatrix () {\n vec4 joints = vec4(a_joints);\n return getJointMatrix(joints.x) * a_weights.x\n + getJointMatrix(joints.y) * a_weights.y\n + getJointMatrix(joints.z) * a_weights.z\n + getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\n mat4 m = skinMatrix();\n position = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\n mat4 m = skinMatrix();\n attr.position = m * attr.position;\n attr.normal = (m * vec4(attr.normal, 0.0)).xyz;\n attr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nuniform highp mat4 cc_matView;\nuniform highp mat4 cc_matProj;\nuniform highp vec4 cc_cameraPos;\nuniform mediump vec4 cc_fogBase;\nuniform mediump vec4 cc_fogAdd;\n#if USE_INSTANCING\n attribute vec4 a_matWorld0;\n attribute vec4 a_matWorld1;\n attribute vec4 a_matWorld2;\n #if USE_LIGHTMAP\n attribute vec4 a_lightingMapUVParam;\n #endif\n#elif USE_BATCHING\n attribute float a_dyn_batch_id;\n uniform highp mat4 cc_matWorlds[10];\n#else\nuniform highp mat4 cc_matWorld;\n#endif\nfloat LinearFog(vec4 pos) {\n vec4 wPos = pos;\n float cam_dis = distance(cc_cameraPos, wPos);\n float fogStart = cc_fogBase.x;\n float fogEnd = cc_fogBase.y;\n return clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float fogDensity = cc_fogBase.z;\n float cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\n float f = exp(-cam_dis * fogDensity);\n return f;\n}\nfloat ExpSquaredFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float fogDensity = cc_fogBase.z;\n float cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\n float f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\n return f;\n}\nfloat LayeredFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float _FogTop = cc_fogAdd.x;\n float _FogRange = cc_fogAdd.y;\n vec3 camWorldProj = cc_cameraPos.xyz;\n camWorldProj.y = 0.;\n vec3 worldPosProj = wPos.xyz;\n worldPosProj.y = 0.;\n float fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\n float fDeltaY, fDensityIntegral;\n if (cc_cameraPos.y > _FogTop) {\n if (wPos.y < _FogTop) {\n fDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\n fDensityIntegral = fDeltaY * fDeltaY * 0.5;\n } else {\n fDeltaY = 0.;\n fDensityIntegral = 0.;\n }\n } else {\n if (wPos.y < _FogTop) {\n float fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\n float fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\n fDeltaY = abs(fDeltaA - fDeltaB);\n fDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n } else {\n fDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\n fDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n }\n }\n float fDensity;\n if (fDeltaY != 0.) {\n fDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n } else {\n fDensity = 0.;\n }\n float f = exp(-fDensity);\n return f;\n}\nfloat CC_TRANSFER_FOG(vec4 pos) {\n #if CC_USE_FOG == 0\n return LinearFog(pos);\n\t#elif CC_USE_FOG == 1\n return ExpFog(pos);\n #elif CC_USE_FOG == 2\n return ExpSquaredFog(pos);\n #elif CC_USE_FOG == 3\n return LayeredFog(pos);\n #endif\n return 1.;\n}\n#if USE_VERTEX_COLOR\n attribute lowp vec4 a_color;\n varying lowp vec4 v_color;\n#endif\n#if USE_TEXTURE\n varying vec2 v_uv;\n uniform vec4 tilingOffset;\n#endif\nvarying float factor_fog;\nvec4 vert () {\n vec4 position;\n position = vec4(a_position, 1.0);\n #if CC_USE_MORPH\n applyMorph(position);\n #endif\n #if CC_USE_SKINNING\n CCSkin(position);\n #endif\n mat4 matWorld;\n #if USE_INSTANCING\n matWorld = mat4(\n vec4(a_matWorld0.xyz, 0.0),\n vec4(a_matWorld1.xyz, 0.0),\n vec4(a_matWorld2.xyz, 0.0),\n vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n );\n #elif USE_BATCHING\n matWorld = cc_matWorlds[int(a_dyn_batch_id)];\n #else\n matWorld = cc_matWorld;\n #endif\n #if USE_TEXTURE\n v_uv = a_texCoord * tilingOffset.xy + tilingOffset.zw;\n #endif\n #if USE_VERTEX_COLOR\n v_color = a_color;\n #endif\n factor_fog = CC_TRANSFER_FOG(matWorld * position);\n return cc_matProj * (cc_matView * matWorld) * position;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nuniform mediump vec4 cc_exposure;\nuniform mediump vec4 cc_fogColor;\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n #if CC_USE_HDR\n color.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n #endif\n return color;\n}\n#if USE_ALPHA_TEST\n#endif\n#if USE_TEXTURE\n varying vec2 v_uv;\n uniform sampler2D mainTexture;\n#endif\nuniform vec4 mainColor;\nuniform vec4 colorScaleAndCutoff;\n#if USE_VERTEX_COLOR\n varying lowp vec4 v_color;\n#endif\nvarying float factor_fog;\nvec4 frag () {\n vec4 o = mainColor;\n o.rgb *= colorScaleAndCutoff.xyz;\n #if USE_VERTEX_COLOR\n o *= v_color;\n #endif\n #if USE_TEXTURE\n o *= texture2D(mainTexture, v_uv);\n #endif\n #if USE_ALPHA_TEST\n if (o.ALPHA_TEST_CHANNEL < colorScaleAndCutoff.w) discard;\n #endif\n o = vec4(mix(CC_FORWARD_ADD > 0 ? vec3(0.0) : cc_fogColor.rgb, o.rgb, factor_fog), o.a);\n return CCFragOutput(o);\n}\nvoid main() { gl_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\n rgba = rgba * 255.0;\n highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\n highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\n highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\n highp vec4 position;\n vec3 normal;\n vec4 tangent;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nattribute vec4 a_tangent;\n#if CC_USE_MORPH\n attribute float a_vertexId;\n int getVertexId() {\n return int(a_vertexId);\n }\nuniform vec4 cc_displacementWeights[15];\nuniform vec4 cc_displacementTextureInfo;\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\n float pixelIndexF = float(pixelIndex);\n float x = mod(pixelIndexF, textureResolution.x);\n float y = floor(pixelIndexF / textureResolution.x);\n return vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\n return (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_SUPPORT_FLOAT_TEXTURE\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 uv = getPixelCoordFromLocation(location, cc_displacementTextureInfo.xy);\n return texture2D(tex, uv);\n }\n#else\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex * 4;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\n return vec4(\n decode32(texture2D(tex, x)),\n decode32(texture2D(tex, y)),\n decode32(texture2D(tex, z)),\n 1.0\n );\n }\n#endif\nfloat getDisplacementWeight(int index) {\n int quot = index / 4;\n int remainder = index - quot * 4;\n if (remainder == 0) {\n return cc_displacementWeights[quot].x;\n } else if (remainder == 1) {\n return cc_displacementWeights[quot].y;\n } else if (remainder == 2) {\n return cc_displacementWeights[quot].z;\n } else {\n return cc_displacementWeights[quot].w;\n }\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\n return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\n vec3 result = vec3(0, 0, 0);\n int nVertices = int(cc_displacementTextureInfo.z);\n for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\n result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n }\n return result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\n uniform sampler2D cc_PositionDisplacements;\n vec3 getPositionDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n uniform sampler2D cc_NormalDisplacements;\n vec3 getNormalDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n uniform sampler2D cc_TangentDisplacements;\n vec3 getTangentDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n }\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\n int vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\n attr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n attr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n attr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\n attribute vec4 a_joints;\nattribute vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n #if USE_INSTANCING\n attribute highp vec4 a_jointAnimInfo;\n #endif\n uniform highp vec4 cc_jointTextureInfo;\n uniform highp vec4 cc_jointAnimInfo;\n uniform highp sampler2D cc_jointTexture;\n #else\n uniform highp vec4 cc_joints[90];\n#endif\n#if CC_USE_BAKED_ANIMATION\n #if CC_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y));\n vec4 v2 = texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y));\n vec4 v3 = texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n );\n vec4 v2 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n );\n vec4 v3 = vec4(\n decode32(texture2D(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\n decode32(texture2D(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n#else\n mat4 getJointMatrix (float i) {\n int idx = int(i);\n vec4 v1 = cc_joints[idx * 3];\n vec4 v2 = cc_joints[idx * 3 + 1];\n vec4 v3 = cc_joints[idx * 3 + 2];\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n#endif\nmat4 skinMatrix () {\n vec4 joints = vec4(a_joints);\n return getJointMatrix(joints.x) * a_weights.x\n + getJointMatrix(joints.y) * a_weights.y\n + getJointMatrix(joints.z) * a_weights.z\n + getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\n mat4 m = skinMatrix();\n position = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\n mat4 m = skinMatrix();\n attr.position = m * attr.position;\n attr.normal = (m * vec4(attr.normal, 0.0)).xyz;\n attr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nuniform highp mat4 cc_matView;\nuniform highp mat4 cc_matProj;\n#if USE_INSTANCING\n attribute vec4 a_matWorld0;\n attribute vec4 a_matWorld1;\n attribute vec4 a_matWorld2;\n #if USE_LIGHTMAP\n attribute vec4 a_lightingMapUVParam;\n #endif\n#elif USE_BATCHING\n attribute float a_dyn_batch_id;\n uniform highp mat4 cc_matWorlds[10];\n#else\nuniform highp mat4 cc_matWorld;\n#endif\nuniform highp mat4 cc_matLightPlaneProj;\nvec4 vert () {\n vec4 position;\n position = vec4(a_position, 1.0);\n #if CC_USE_MORPH\n applyMorph(position);\n #endif\n #if CC_USE_SKINNING\n CCSkin(position);\n #endif\n mat4 matWorld;\n #if USE_INSTANCING\n matWorld = mat4(\n vec4(a_matWorld0.xyz, 0.0),\n vec4(a_matWorld1.xyz, 0.0),\n vec4(a_matWorld2.xyz, 0.0),\n vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n );\n #elif USE_BATCHING\n matWorld = cc_matWorlds[int(a_dyn_batch_id)];\n #else\n matWorld = cc_matWorld;\n #endif\n position = cc_matProj * (cc_matView * cc_matLightPlaneProj * matWorld) * position;\n position.z -= 0.0001;\n return position;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision mediump float;\nuniform lowp vec4 cc_shadowColor;\nuniform mediump vec4 cc_exposure;\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n #if CC_USE_HDR\n color.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n #endif\n return color;\n}\nvec4 frag () {\n return CCFragOutput(cc_shadowColor);\n}\nvoid main() { gl_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nuniform highp mat4 cc_matView;\nuniform highp mat4 cc_matProj;\nstruct StandardVertInput {\n highp vec4 position;\n vec3 normal;\n vec4 tangent;\n};\nattribute vec3 a_position;\nattribute vec3 a_normal;\nattribute vec2 a_texCoord;\nattribute vec4 a_tangent;\nvarying mediump vec4 viewDir;\nvec4 vert () {\n viewDir = vec4(a_position, 1.0);\n mat4 matViewRotOnly = mat4(mat3(cc_matView));\n mat4 matProj = cc_matProj;\n if (matProj[3].w > 0.0) {\n vec2 scale = vec2(48.0, 24.0);\n matProj[0].xy *= scale;\n matProj[1].xy *= scale;\n matProj[2].zw = vec2(-1.0);\n matProj[3].zw = vec2(0.0);\n }\n vec4 pos = matProj * matViewRotOnly * viewDir;\n pos.z = 0.99999 * pos.w;\n return pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision mediump float;\nuniform mediump vec4 cc_ambientSky;\nuniform samplerCube cc_environment;\nvec3 unpackRGBE (vec4 rgbe) {\n return rgbe.rgb * pow(2.0, rgbe.a * 255.0 - 128.0);\n}\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec3 ACESToneMap (vec3 color) {\n color = min(color, vec3(8.0));\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n #if !CC_USE_HDR\n color.rgb = sqrt(ACESToneMap(color.rgb));\n #endif\n return color;\n}\nvarying mediump vec4 viewDir;\nvec4 frag () {\n #if USE_RGBE_CUBEMAP\n vec3 c = unpackRGBE(textureCube(cc_environment, viewDir.xyz));\n #else\n vec3 c = SRGBToLinear(textureCube(cc_environment, viewDir.xyz).rgb);\n #endif\n return CCFragOutput(vec4(c * cc_ambientSky.w, 1.0));\n}\nvoid main() { gl_FragColor = frag(); }"}],[{vert:"\nprecision mediump float;\nuniform highp mat4 cc_matViewProj;\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec2 v_uv;\nuniform vec4 offset;\nuniform vec4 digits[20];\nfloat getComponent(vec4 v, float i) {\n if (i < 1.0) { return v.x; }\n else if (i < 2.0) { return v.y; }\n else if (i < 3.0) { return v.z; }\n else { return v.w; }\n}\nvec4 vert () {\n vec4 position = cc_matViewProj * vec4(a_position, 1.0);\n position.xy += offset.xy;\n v_uv = a_color.xy;\n if (a_color.z >= 0.0) {\n float n = getComponent(digits[int(a_color.z)], a_color.w);\n v_uv += vec2(offset.z * n, 0.0);\n }\n return position;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision mediump float;\nuniform mediump vec4 cc_exposure;\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n #if CC_USE_HDR\n color.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n #endif\n return color;\n}\nvarying vec2 v_uv;\nuniform sampler2D mainTexture;\nvec4 frag () {\n return CCFragOutput(texture2D(mainTexture, v_uv));\n}\nvoid main() { gl_FragColor = frag(); }"}],[{vert:"\nprecision mediump float;\nattribute vec2 a_position;\nattribute vec2 a_texCoord;\nvarying vec2 v_uv;\nvec4 vert () {\n vec4 pos = vec4(a_position, 0, 1);\n v_uv = a_texCoord;\n return pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision mediump float;\nvarying vec2 v_uv;\nuniform sampler2D mainTexture;\nuniform float u_precent;\nvec4 frag () {\n vec4 color = texture2D(mainTexture, v_uv);\n float precent = clamp(u_precent, 0.0, 1.0);\n color.xyz *= precent;\n return color;\n}\nvoid main() { gl_FragColor = frag(); }"}]],glsl3:[[{vert:"\nprecision mediump float;\nlayout(std140) uniform Constants {\n vec4 mainTiling_Offset;\n vec4 frameTile_velLenScale;\n vec4 scale;\n};\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nlayout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n};\nvec4 quaternionFromAxis (vec3 xAxis,vec3 yAxis,vec3 zAxis){\n mat3 m = mat3(xAxis,yAxis,zAxis);\n float trace = m[0][0] + m[1][1] + m[2][2];\n vec4 quat;\n if (trace > 0.) {\n float s = 0.5 / sqrt(trace + 1.0);\n quat.w = 0.25 / s;\n quat.x = (m[2][1] - m[1][2]) * s;\n quat.y = (m[0][2] - m[2][0]) * s;\n quat.z = (m[1][0] - m[0][1]) * s;\n } else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\n float s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\n quat.w = (m[2][1] - m[1][2]) / s;\n quat.x = 0.25 * s;\n quat.y = (m[0][1] + m[1][0]) / s;\n quat.z = (m[0][2] + m[2][0]) / s;\n } else if (m[1][1] > m[2][2]) {\n float s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\n quat.w = (m[0][2] - m[2][0]) / s;\n quat.x = (m[0][1] + m[1][0]) / s;\n quat.y = 0.25 * s;\n quat.z = (m[1][2] + m[2][1]) / s;\n } else {\n float s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\n quat.w = (m[1][0] - m[0][1]) / s;\n quat.x = (m[0][2] + m[2][0]) / s;\n quat.y = (m[1][2] + m[2][1]) / s;\n quat.z = 0.25 * s;\n }\n float len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\n if (len > 0.) {\n len = 1. / sqrt(len);\n quat.x = quat.x * len;\n quat.y = quat.y * len;\n quat.z = quat.z * len;\n quat.w = quat.w * len;\n }\n return quat;\n}\nvec4 quaternionFromEuler (vec3 angle){\n float x = angle.x / 2.;\n float y = angle.y / 2.;\n float z = angle.z / 2.;\n float sx = sin(x);\n float cx = cos(x);\n float sy = sin(y);\n float cy = cos(y);\n float sz = sin(z);\n float cz = cos(z);\n vec4 quat = vec4(0);\n quat.x = sx * cy * cz + cx * sy * sz;\n quat.y = cx * sy * cz + sx * cy * sz;\n quat.z = cx * cy * sz - sx * sy * cz;\n quat.w = cx * cy * cz - sx * sy * sz;\n return quat;\n}\nvec4 quatMultiply (vec4 a, vec4 b){\n vec4 quat;\n quat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\n quat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\n quat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\n quat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\n return quat;\n}\nvoid rotateVecFromQuat (inout vec3 v, vec4 q){\n float ix = q.w * v.x + q.y * v.z - q.z * v.y;\n float iy = q.w * v.y + q.z * v.x - q.x * v.z;\n float iz = q.w * v.z + q.x * v.y - q.y * v.x;\n float iw = -q.x * v.x - q.y * v.y - q.z * v.z;\n v.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\n v.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\n v.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace (vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\n vec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\n vec4 rotQuat = quatMultiply(viewQuat, q);\n rotateVecFromQuat(pos, rotQuat);\n return pos;\n}\nvoid rotateCorner (inout vec2 corner, float angle){\n float xOS = cos(angle) * corner.x - sin(angle) * corner.y;\n float yOS = sin(angle) * corner.x + cos(angle) * corner.y;\n corner.x = xOS;\n corner.y = yOS;\n}\nout mediump vec2 uv;\nout mediump vec4 color;\nvoid computeVertPos (inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n , mat4 viewInv\n) {\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\n vec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\n vec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n}\nin vec3 a_position;\nin vec2 a_texCoord;\nin vec4 a_color;\nlayout(std140) uniform builtin {\n vec4 cc_size_rotation;\n};\nvec4 vs_main() {\n vec4 pos = vec4(a_position, 1);\n pos = cc_matWorld * pos;\n vec2 vertOffset = a_texCoord.xy - 0.5;\n computeVertPos(pos, vertOffset, quaternionFromEuler(vec3(0., 0., cc_size_rotation.z)), vec3(cc_size_rotation.xy, 0.), cc_matViewInv);\n pos = cc_matViewProj * pos;\n uv = a_texCoord.xy;\n color = a_color;\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }",frag:"\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n #if CC_USE_HDR\n color.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n #endif\n return color;\n}\nin vec2 uv;\nin vec4 color;\nuniform sampler2D mainTexture;\nlayout(std140) uniform FragConstants {\n vec4 tintColor;\n};\nvec4 add () {\n vec4 col = 2.0 * color * tintColor * texture(mainTexture, uv);\n return CCFragOutput(col);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = add(); }"}],[{vert:"\nprecision highp float;\nin vec3 a_position;\nvec4 vert () {\n vec4 pos = vec4(a_position, 1);\n return pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nvec4 frag () {\n vec4 o = vec4(1.0);\n return o;\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nlayout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n};\nin vec3 a_position;\nin vec4 a_color;\nout vec4 v_color;\nin float a_dist;\nout float v_dist;\nvec4 vert () {\n vec4 pos = vec4(a_position, 1);\n pos = cc_matViewProj * cc_matWorld * pos;\n v_color = a_color;\n v_dist = a_dist;\n return pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nin vec4 v_color;\nin float v_dist;\nvec4 frag () {\n vec4 o = v_color;\n float aa = fwidth(v_dist);\n float alpha = 1. - smoothstep(-aa, 0., abs(v_dist) - 1.0);\n o.rgb *= o.a;\n o *= alpha;\n return o;\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}],[{vert:"\nprecision mediump float;\nvec4 quaternionFromAxis (vec3 xAxis,vec3 yAxis,vec3 zAxis){\n mat3 m = mat3(xAxis,yAxis,zAxis);\n float trace = m[0][0] + m[1][1] + m[2][2];\n vec4 quat;\n if (trace > 0.) {\n float s = 0.5 / sqrt(trace + 1.0);\n quat.w = 0.25 / s;\n quat.x = (m[2][1] - m[1][2]) * s;\n quat.y = (m[0][2] - m[2][0]) * s;\n quat.z = (m[1][0] - m[0][1]) * s;\n } else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\n float s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\n quat.w = (m[2][1] - m[1][2]) / s;\n quat.x = 0.25 * s;\n quat.y = (m[0][1] + m[1][0]) / s;\n quat.z = (m[0][2] + m[2][0]) / s;\n } else if (m[1][1] > m[2][2]) {\n float s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\n quat.w = (m[0][2] - m[2][0]) / s;\n quat.x = (m[0][1] + m[1][0]) / s;\n quat.y = 0.25 * s;\n quat.z = (m[1][2] + m[2][1]) / s;\n } else {\n float s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\n quat.w = (m[1][0] - m[0][1]) / s;\n quat.x = (m[0][2] + m[2][0]) / s;\n quat.y = (m[1][2] + m[2][1]) / s;\n quat.z = 0.25 * s;\n }\n float len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\n if (len > 0.) {\n len = 1. / sqrt(len);\n quat.x = quat.x * len;\n quat.y = quat.y * len;\n quat.z = quat.z * len;\n quat.w = quat.w * len;\n }\n return quat;\n}\nvec4 quaternionFromEuler (vec3 angle){\n float x = angle.x / 2.;\n float y = angle.y / 2.;\n float z = angle.z / 2.;\n float sx = sin(x);\n float cx = cos(x);\n float sy = sin(y);\n float cy = cos(y);\n float sz = sin(z);\n float cz = cos(z);\n vec4 quat = vec4(0);\n quat.x = sx * cy * cz + cx * sy * sz;\n quat.y = cx * sy * cz + sx * cy * sz;\n quat.z = cx * cy * sz - sx * sy * cz;\n quat.w = cx * cy * cz - sx * sy * sz;\n return quat;\n}\nmat4 matrixFromRT (vec4 q, vec3 p){\n float x2 = q.x + q.x;\n float y2 = q.y + q.y;\n float z2 = q.z + q.z;\n float xx = q.x * x2;\n float xy = q.x * y2;\n float xz = q.x * z2;\n float yy = q.y * y2;\n float yz = q.y * z2;\n float zz = q.z * z2;\n float wx = q.w * x2;\n float wy = q.w * y2;\n float wz = q.w * z2;\n return mat4(\n 1. - (yy + zz), xy + wz, xz - wy, 0,\n xy - wz, 1. - (xx + zz), yz + wx, 0,\n xz + wy, yz - wx, 1. - (xx + yy), 0,\n p.x, p.y, p.z, 1\n );\n}\nmat4 matFromRTS (vec4 q, vec3 t, vec3 s){\n float x = q.x, y = q.y, z = q.z, w = q.w;\n float x2 = x + x;\n float y2 = y + y;\n float z2 = z + z;\n float xx = x * x2;\n float xy = x * y2;\n float xz = x * z2;\n float yy = y * y2;\n float yz = y * z2;\n float zz = z * z2;\n float wx = w * x2;\n float wy = w * y2;\n float wz = w * z2;\n float sx = s.x;\n float sy = s.y;\n float sz = s.z;\n return mat4((1. - (yy + zz)) * sx, (xy + wz) * sx, (xz - wy) * sx, 0,\n (xy - wz) * sy, (1. - (xx + zz)) * sy, (yz + wx) * sy, 0,\n (xz + wy) * sz, (yz - wx) * sz, (1. - (xx + yy)) * sz, 0,\n t.x, t.y, t.z, 1);\n}\nvec4 quatMultiply (vec4 a, vec4 b){\n vec4 quat;\n quat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\n quat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\n quat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\n quat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\n return quat;\n}\nvoid rotateVecFromQuat (inout vec3 v, vec4 q){\n float ix = q.w * v.x + q.y * v.z - q.z * v.y;\n float iy = q.w * v.y + q.z * v.x - q.x * v.z;\n float iz = q.w * v.z + q.x * v.y - q.y * v.x;\n float iw = -q.x * v.x - q.y * v.y - q.z * v.z;\n v.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\n v.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\n v.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace (vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\n vec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\n vec4 rotQuat = quatMultiply(viewQuat, q);\n rotateVecFromQuat(pos, rotQuat);\n return pos;\n}\nvoid rotateCorner (inout vec2 corner, float angle){\n float xOS = cos(angle) * corner.x - sin(angle) * corner.y;\n float yOS = sin(angle) * corner.x + cos(angle) * corner.y;\n corner.x = xOS;\n corner.y = yOS;\n}\nlayout(std140) uniform Constants {\n vec4 mainTiling_Offset;\n vec4 frameTile_velLenScale;\n vec4 scale;\n};\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nlayout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n};\nout mediump vec2 uv;\nout mediump vec4 color;\nvoid computeVertPos (inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n#if CC_RENDER_MODE == 0 || CC_RENDER_MODE == 3\n , mat4 viewInv\n#endif\n#if CC_RENDER_MODE == 1\n , vec3 eye\n , vec4 velocity\n , float velocityScale\n , float lengthScale\n , float xIndex\n#endif\n) {\n#if CC_RENDER_MODE == 0\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\n vec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\n vec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_RENDER_MODE == 1\n vec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\n vec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\n pos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_RENDER_MODE == 2\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = vec3(1, 0, 0);\n vec3 camY = vec3(0, 0, -1);\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_RENDER_MODE == 3\n vec2 viewSpaceVert = vec2(vertOffset.x * s.x, vertOffset.y * s.y);\n rotateCorner(viewSpaceVert, q.z);\n vec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\n vec3 camY = vec3(0, 1, 0);\n vec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\n pos.xyz += offset;\n#else\n pos.x += vertOffset.x;\n pos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV (float frameIndex, vec2 vertIndex, vec2 frameTile){\n vec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\n aniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if CC_RENDER_MODE != 4\n vertIndex.y = 1. - vertIndex.y;\n#endif\n return (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nlayout(std140) uniform SampleConstants {\n vec4 u_sampleInfo;\n};\nlayout(std140) uniform TickConstants {\n vec4 u_worldRot;\n vec4 u_timeDelta;\n};\nin vec4 a_position_starttime;\nin vec4 a_size_uv;\nin vec4 a_rotation_uv;\nin vec4 a_color;\nin vec4 a_dir_life;\nin float a_rndSeed;\n#if CC_RENDER_MODE == 4\n in vec3 a_texCoord;\n in vec3 a_texCoord3;\n in vec3 a_normal;\n in vec4 a_color1;\n#endif\nvec3 unpackCurveData (sampler2D tex, vec2 coord) {\n vec4 a = texture(tex, coord);\n vec4 b = texture(tex, coord + u_sampleInfo.y);\n float c = fract(coord.x * u_sampleInfo.x);\n return mix(a.xyz, b.xyz, c);\n}\nvec3 unpackCurveData (sampler2D tex, vec2 coord, out float w) {\n vec4 a = texture(tex, coord);\n vec4 b = texture(tex, coord + u_sampleInfo.y);\n float c = fract(coord.x * u_sampleInfo.x);\n w = mix(a.w, b.w, c);\n return mix(a.xyz, b.xyz, c);\n}\nfloat pseudoRandom (float seed) {\n seed = mod(seed, 233280.);\n float q = (seed * 9301. + 49297.) / 233280.;\n return fract(q);\n}\n#if COLOR_OVER_TIME_MODULE_ENABLE\n uniform sampler2D color_over_time_tex0;\n layout(std140) uniform ColorConstant {\n int u_color_mode;\n };\n#endif\n#if ROTATION_OVER_TIME_MODULE_ENABLE\n uniform sampler2D rotation_over_time_tex0;\n layout(std140) uniform RotationConstant {\n int u_rotation_mode;\n };\n#endif\n#if SIZE_OVER_TIME_MODULE_ENABLE\n uniform sampler2D size_over_time_tex0;\n layout(std140) uniform SizeConstant {\n int u_size_mode;\n };\n#endif\n#if FORCE_OVER_TIME_MODULE_ENABLE\n uniform sampler2D force_over_time_tex0;\n layout(std140) uniform ForceConstant {\n int u_force_mode;\n int u_force_space;\n };\n#endif\n#if VELOCITY_OVER_TIME_MODULE_ENABLE\n uniform sampler2D velocity_over_time_tex0;\n layout(std140) uniform VelocityConstant {\n int u_velocity_mode;\n int u_velocity_space;\n };\n#endif\n#if TEXTURE_ANIMATION_MODULE_ENABLE\n uniform sampler2D texture_animation_tex0;\n layout(std140) uniform AnimationConstant {\n vec4 u_anim_info;\n };\n#endif\nfloat repeat (float t, float length) {\n return t - floor(t / length) * length;\n}\nvec4 rotateQuat (vec4 p, vec4 q) {\n vec3 iv = cross(q.xyz, p.xyz) + q.w * p.xyz;\n vec3 res = p.xyz + 2.0 * cross(q.xyz, iv);\n return vec4(res.xyz, p.w);\n}\nvec4 gpvs_main () {\n float activeTime = u_timeDelta.x - a_position_starttime.w;\n float normalizedTime = clamp(activeTime / a_dir_life.w, 0.0, 1.0);\n vec2 timeCoord0 = vec2(normalizedTime, 0.);\n vec2 timeCoord1 = vec2(normalizedTime, 1.);\n #if CC_RENDER_MODE == 4\n vec2 vertIdx = vec2(a_texCoord.x, a_texCoord.y);\n #else\n vec2 vertIdx = vec2(a_size_uv.w, a_rotation_uv.w);\n #endif\n vec4 velocity = vec4(a_dir_life.xyz, 0.);\n vec4 pos = vec4(a_position_starttime.xyz, 1.);\n vec3 size = a_size_uv.xyz;\n #if SIZE_OVER_TIME_MODULE_ENABLE\n if (u_size_mode == 1) {\n size *= unpackCurveData(size_over_time_tex0, timeCoord0);\n } else {\n vec3 size_0 = unpackCurveData(size_over_time_tex0, timeCoord0);\n vec3 size_1 = unpackCurveData(size_over_time_tex0, timeCoord1);\n float factor_s = pseudoRandom(a_rndSeed + 39825.);\n size *= mix(size_0, size_1, factor_s);\n }\n #endif\n vec3 compScale = scale.xyz * size;\n #if FORCE_OVER_TIME_MODULE_ENABLE\n vec3 forceAnim = vec3(0.);\n if (u_force_mode == 1) {\n forceAnim = unpackCurveData(force_over_time_tex0, timeCoord0);\n } else {\n vec3 force_0 = unpackCurveData(force_over_time_tex0, timeCoord0);\n vec3 force_1 = unpackCurveData(force_over_time_tex0, timeCoord1);\n float factor_f = pseudoRandom(a_rndSeed + 212165.);\n forceAnim = mix(force_0, force_1, factor_f);\n }\n vec4 forceTrack = vec4(forceAnim, 0.);\n if (u_force_space == 0) {\n forceTrack = rotateQuat(forceTrack, u_worldRot);\n }\n velocity.xyz += forceTrack.xyz;\n #endif\n #if VELOCITY_OVER_TIME_MODULE_ENABLE\n float speedModifier0 = 1.;\n float speedModifier1 = 1.;\n vec3 velocityAnim = vec3(0.);\n if (u_velocity_mode == 1) {\n velocityAnim = unpackCurveData(velocity_over_time_tex0, timeCoord0, speedModifier0);\n } else {\n vec3 vectory_0 = unpackCurveData(velocity_over_time_tex0, timeCoord0, speedModifier0);\n vec3 vectory_1 = unpackCurveData(velocity_over_time_tex0, timeCoord1, speedModifier1);\n float factor_v = pseudoRandom(a_rndSeed + 197866.);\n velocityAnim = mix(vectory_0, vectory_1, factor_v);\n speedModifier0 = mix(speedModifier0, speedModifier1, factor_v);\n }\n vec4 velocityTrack = vec4(velocityAnim, 0.);\n if (u_velocity_space == 0) {\n velocityTrack = rotateQuat(velocityTrack, u_worldRot);\n }\n velocity.xyz += velocityTrack.xyz;\n velocity.xyz *= speedModifier0;\n #endif\n pos.xyz += velocity.xyz * normalizedTime * a_dir_life.w;\n #if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n #if CC_RENDER_MODE == 1\n velocity = rotateQuat(velocity, u_worldRot);\n #endif\n #endif\n vec3 rotation = a_rotation_uv.xyz;\n #if ROTATION_OVER_TIME_MODULE_ENABLE\n if (u_rotation_mode == 1) {\n rotation += unpackCurveData(rotation_over_time_tex0, timeCoord0) * normalizedTime * a_dir_life.w;\n } else {\n vec3 rotation_0 = unpackCurveData(rotation_over_time_tex0, timeCoord0);\n vec3 rotation_1 = unpackCurveData(rotation_over_time_tex0, timeCoord1);\n float factor_r = pseudoRandom(a_rndSeed + 125292.);\n rotation += mix(rotation_0, rotation_1, factor_r) * normalizedTime * a_dir_life.w;\n }\n #endif\n #if COLOR_OVER_TIME_MODULE_ENABLE\n if (u_color_mode == 1) {\n color = a_color * texture(color_over_time_tex0, timeCoord0);\n } else {\n vec4 color_0 = texture(color_over_time_tex0, timeCoord0);\n vec4 color_1 = texture(color_over_time_tex0, timeCoord1);\n float factor_c = pseudoRandom(a_rndSeed + 91041.);\n color = a_color * mix(color_0, color_1, factor_c);\n }\n #else\n color = a_color;\n #endif\n #if CC_RENDER_MODE != 4\n vec2 cornerOffset = vec2((vertIdx - 0.5));\n #if CC_RENDER_MODE == 0\n vec3 rotEuler = rotation.xyz;\n #elif CC_RENDER_MODE == 1\n vec3 rotEuler = vec3(0.);\n #else\n vec3 rotEuler = vec3(0., 0., rotation.z);\n #endif\n computeVertPos(pos, cornerOffset, quaternionFromEuler(rotEuler), compScale\n #if CC_RENDER_MODE == 0 || CC_RENDER_MODE == 3\n , cc_matViewInv\n #endif\n #if CC_RENDER_MODE == 1\n , cc_cameraPos.xyz\n , velocity\n , frameTile_velLenScale.z\n , frameTile_velLenScale.w\n , a_size_uv.w\n #endif\n );\n #else\n mat4 xformNoScale = matrixFromRT(quaternionFromEuler(rotation), pos.xyz);\n mat4 xform = matFromRTS(quaternionFromEuler(rotation), pos.xyz, compScale);\n pos = xform * vec4(a_texCoord3, 1);\n vec4 normal = xformNoScale * vec4(a_normal, 0);\n color *= a_color1;\n #endif\n pos = cc_matViewProj * pos;\n float frameIndex = 0.;\n #if TEXTURE_ANIMATION_MODULE_ENABLE\n float startFrame = 0.;\n vec3 frameInfo = vec3(0.);\n if (int(u_anim_info.x) == 1) {\n frameInfo = unpackCurveData(texture_animation_tex0, timeCoord0);\n } else {\n vec3 frameInfo0 = unpackCurveData(texture_animation_tex0, timeCoord0);\n vec3 frameInfo1 = unpackCurveData(texture_animation_tex0, timeCoord1);\n float factor_t = pseudoRandom(a_rndSeed + 90794.);\n frameInfo = mix(frameInfo0, frameInfo1, factor_t);\n }\n startFrame = frameInfo.x / u_anim_info.y;\n frameIndex = repeat(u_anim_info.z * (frameInfo.y + startFrame), 1.);\n #endif\n uv = computeUV(frameIndex, vertIdx, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\n return pos;\n}\nvoid main() { gl_Position = gpvs_main(); }",frag:"\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n #if CC_USE_HDR\n color.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n #endif\n return color;\n}\nin vec2 uv;\nin vec4 color;\nuniform sampler2D mainTexture;\nlayout(std140) uniform FragConstants {\n vec4 tintColor;\n};\nvec4 add () {\n vec4 col = 2.0 * color * tintColor * texture(mainTexture, uv);\n return CCFragOutput(col);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = add(); }"}],[{vert:"\nprecision mediump float;\nlayout(std140) uniform Constants {\n vec4 mainTiling_Offset;\n vec4 frameTile_velLenScale;\n vec4 scale;\n};\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nlayout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n};\nout mediump vec2 uv;\nout mediump vec4 color;\nin vec3 a_position;\nin vec4 a_texCoord;\nin vec3 a_texCoord1;\nin vec3 a_texCoord2;\nin vec4 a_color;\n#if CC_DRAW_WIRE_FRAME\n out vec3 vBarycentric;\n#endif\nvec4 vs_main() {\n highp vec4 pos = vec4(a_position, 1);\n vec4 velocity = vec4(a_texCoord1.xyz, 0);\n #if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n velocity = cc_matWorld * velocity;\n #endif\n float vertOffset = (a_texCoord.x - 0.5) * a_texCoord.y;\n vec3 camUp = normalize(cross(pos.xyz - cc_cameraPos.xyz, velocity.xyz));\n pos.xyz += camUp * vertOffset;\n pos = cc_matViewProj * pos;\n uv = a_texCoord.zw * mainTiling_Offset.xy + mainTiling_Offset.zw;;\n color = a_color;\n #if CC_DRAW_WIRE_FRAME\n vBarycentric = a_texCoord2;\n #endif\n return pos;\n}\nvoid main() { gl_Position = vs_main(); }",frag:"\n precision mediump float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n #if CC_USE_HDR\n color.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n #endif\n return color;\n}\n in vec2 uv;\n in vec4 color;\n #if CC_DRAW_WIRE_FRAME\n in vec3 vBarycentric;\n #endif\n uniform sampler2D mainTexture;\n layout(std140) uniform FragConstants {\n vec4 tintColor;\n };\n vec4 add () {\n vec4 col = 2.0 * color * tintColor * texture(mainTexture, uv);\n#if CC_DRAW_WIRE_FRAME\n if (any(lessThan(vBarycentric, vec3(0.02)))) {\n col = vec4(0., 1., 1., 1.);\n }\n#endif\n return CCFragOutput(col);\n }\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = add(); }"}],[{vert:"\nprecision highp float;\nvec4 quaternionFromAxis (vec3 xAxis,vec3 yAxis,vec3 zAxis){\n mat3 m = mat3(xAxis,yAxis,zAxis);\n float trace = m[0][0] + m[1][1] + m[2][2];\n vec4 quat;\n if (trace > 0.) {\n float s = 0.5 / sqrt(trace + 1.0);\n quat.w = 0.25 / s;\n quat.x = (m[2][1] - m[1][2]) * s;\n quat.y = (m[0][2] - m[2][0]) * s;\n quat.z = (m[1][0] - m[0][1]) * s;\n } else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\n float s = 2.0 * sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]);\n quat.w = (m[2][1] - m[1][2]) / s;\n quat.x = 0.25 * s;\n quat.y = (m[0][1] + m[1][0]) / s;\n quat.z = (m[0][2] + m[2][0]) / s;\n } else if (m[1][1] > m[2][2]) {\n float s = 2.0 * sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]);\n quat.w = (m[0][2] - m[2][0]) / s;\n quat.x = (m[0][1] + m[1][0]) / s;\n quat.y = 0.25 * s;\n quat.z = (m[1][2] + m[2][1]) / s;\n } else {\n float s = 2.0 * sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]);\n quat.w = (m[1][0] - m[0][1]) / s;\n quat.x = (m[0][2] + m[2][0]) / s;\n quat.y = (m[1][2] + m[2][1]) / s;\n quat.z = 0.25 * s;\n }\n float len = quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w;\n if (len > 0.) {\n len = 1. / sqrt(len);\n quat.x = quat.x * len;\n quat.y = quat.y * len;\n quat.z = quat.z * len;\n quat.w = quat.w * len;\n }\n return quat;\n}\nvec4 quaternionFromEuler (vec3 angle){\n float x = angle.x / 2.;\n float y = angle.y / 2.;\n float z = angle.z / 2.;\n float sx = sin(x);\n float cx = cos(x);\n float sy = sin(y);\n float cy = cos(y);\n float sz = sin(z);\n float cz = cos(z);\n vec4 quat = vec4(0);\n quat.x = sx * cy * cz + cx * sy * sz;\n quat.y = cx * sy * cz + sx * cy * sz;\n quat.z = cx * cy * sz - sx * sy * cz;\n quat.w = cx * cy * cz - sx * sy * sz;\n return quat;\n}\nmat4 matrixFromRT (vec4 q, vec3 p){\n float x2 = q.x + q.x;\n float y2 = q.y + q.y;\n float z2 = q.z + q.z;\n float xx = q.x * x2;\n float xy = q.x * y2;\n float xz = q.x * z2;\n float yy = q.y * y2;\n float yz = q.y * z2;\n float zz = q.z * z2;\n float wx = q.w * x2;\n float wy = q.w * y2;\n float wz = q.w * z2;\n return mat4(\n 1. - (yy + zz), xy + wz, xz - wy, 0,\n xy - wz, 1. - (xx + zz), yz + wx, 0,\n xz + wy, yz - wx, 1. - (xx + yy), 0,\n p.x, p.y, p.z, 1\n );\n}\nmat4 matFromRTS (vec4 q, vec3 t, vec3 s){\n float x = q.x, y = q.y, z = q.z, w = q.w;\n float x2 = x + x;\n float y2 = y + y;\n float z2 = z + z;\n float xx = x * x2;\n float xy = x * y2;\n float xz = x * z2;\n float yy = y * y2;\n float yz = y * z2;\n float zz = z * z2;\n float wx = w * x2;\n float wy = w * y2;\n float wz = w * z2;\n float sx = s.x;\n float sy = s.y;\n float sz = s.z;\n return mat4((1. - (yy + zz)) * sx, (xy + wz) * sx, (xz - wy) * sx, 0,\n (xy - wz) * sy, (1. - (xx + zz)) * sy, (yz + wx) * sy, 0,\n (xz + wy) * sz, (yz - wx) * sz, (1. - (xx + yy)) * sz, 0,\n t.x, t.y, t.z, 1);\n}\nvec4 quatMultiply (vec4 a, vec4 b){\n vec4 quat;\n quat.x = a.x * b.w + a.w * b.x + a.y * b.z - a.z * b.y;\n quat.y = a.y * b.w + a.w * b.y + a.z * b.x - a.x * b.z;\n quat.z = a.z * b.w + a.w * b.z + a.x * b.y - a.y * b.x;\n quat.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;\n return quat;\n}\nvoid rotateVecFromQuat (inout vec3 v, vec4 q){\n float ix = q.w * v.x + q.y * v.z - q.z * v.y;\n float iy = q.w * v.y + q.z * v.x - q.x * v.z;\n float iz = q.w * v.z + q.x * v.y - q.y * v.x;\n float iw = -q.x * v.x - q.y * v.y - q.z * v.z;\n v.x = ix * q.w + iw * -q.x + iy * -q.z - iz * -q.y;\n v.y = iy * q.w + iw * -q.y + iz * -q.x - ix * -q.z;\n v.z = iz * q.w + iw * -q.z + ix * -q.y - iy * -q.x;\n}\nvec3 rotateInLocalSpace (vec3 pos, vec3 xAxis, vec3 yAxis, vec3 zAxis, vec4 q){\n vec4 viewQuat = quaternionFromAxis(xAxis, yAxis, zAxis);\n vec4 rotQuat = quatMultiply(viewQuat, q);\n rotateVecFromQuat(pos, rotQuat);\n return pos;\n}\nvoid rotateCorner (inout vec2 corner, float angle){\n float xOS = cos(angle) * corner.x - sin(angle) * corner.y;\n float yOS = sin(angle) * corner.x + cos(angle) * corner.y;\n corner.x = xOS;\n corner.y = yOS;\n}\nlayout(std140) uniform Constants {\n vec4 mainTiling_Offset;\n vec4 frameTile_velLenScale;\n vec4 scale;\n};\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nlayout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n};\nout mediump vec2 uv;\nout mediump vec4 color;\nvoid computeVertPos (inout vec4 pos, vec2 vertOffset, vec4 q, vec3 s\n#if CC_RENDER_MODE == 0 || CC_RENDER_MODE == 3\n , mat4 viewInv\n#endif\n#if CC_RENDER_MODE == 1\n , vec3 eye\n , vec4 velocity\n , float velocityScale\n , float lengthScale\n , float xIndex\n#endif\n) {\n#if CC_RENDER_MODE == 0\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = normalize(vec3(viewInv[0][0], viewInv[1][0], viewInv[2][0]));\n vec3 camY = normalize(vec3(viewInv[0][1], viewInv[1][1], viewInv[2][1]));\n vec3 camZ = normalize(vec3(viewInv[0][2], viewInv[1][2], viewInv[2][2]));\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, camZ, q);\n#elif CC_RENDER_MODE == 1\n vec3 camRight = normalize(cross(pos.xyz - eye, velocity.xyz)) * s.x;\n vec3 camUp = velocity.xyz * velocityScale + normalize(velocity.xyz) * lengthScale * s.y;\n pos.xyz += (camRight * abs(vertOffset.x) * sign(vertOffset.y)) - camUp * xIndex;\n#elif CC_RENDER_MODE == 2\n vec3 viewSpaceVert = vec3(vertOffset.x * s.x, vertOffset.y * s.y, 0.);\n vec3 camX = vec3(1, 0, 0);\n vec3 camY = vec3(0, 0, -1);\n pos.xyz += rotateInLocalSpace(viewSpaceVert, camX, camY, cross(camX, camY), q);\n#elif CC_RENDER_MODE == 3\n vec2 viewSpaceVert = vec2(vertOffset.x * s.x, vertOffset.y * s.y);\n rotateCorner(viewSpaceVert, q.z);\n vec3 camX = normalize(vec3(cc_matView[0][0], cc_matView[1][0], cc_matView[2][0]));\n vec3 camY = vec3(0, 1, 0);\n vec3 offset = camX * viewSpaceVert.x + camY * viewSpaceVert.y;\n pos.xyz += offset;\n#else\n pos.x += vertOffset.x;\n pos.y += vertOffset.y;\n#endif\n}\nvec2 computeUV (float frameIndex, vec2 vertIndex, vec2 frameTile){\n vec2 aniUV = vec2(0, floor(frameIndex * frameTile.y));\n aniUV.x = floor(frameIndex * frameTile.x * frameTile.y - aniUV.y * frameTile.x);\n#if CC_RENDER_MODE != 4\n vertIndex.y = 1. - vertIndex.y;\n#endif\n return (aniUV.xy + vertIndex) / vec2(frameTile.x, frameTile.y);\n}\nin vec3 a_position;\nin vec3 a_texCoord;\nin vec3 a_texCoord1;\nin vec3 a_texCoord2;\nin vec4 a_color;\n#if CC_RENDER_MODE == 1\n in vec3 a_color1;\n#endif\n#if CC_RENDER_MODE == 4\n in vec3 a_texCoord3;\n in vec3 a_normal;\n in vec4 a_color1;\n#endif\nvec4 lpvs_main () {\n vec3 compScale = scale.xyz * a_texCoord1;\n vec4 pos = vec4(a_position, 1);\n #if CC_RENDER_MODE == 1\n vec4 velocity = vec4(a_color1.xyz, 0);\n #endif\n #if !CC_USE_WORLD_SPACE\n pos = cc_matWorld * pos;\n #if CC_RENDER_MODE == 1\n velocity = cc_matWorld * velocity;\n #endif\n #endif\n #if CC_RENDER_MODE != 4\n vec2 cornerOffset = vec2((a_texCoord.xy - 0.5));\n #if CC_RENDER_MODE == 0\n vec3 rotEuler = a_texCoord2;\n #elif CC_RENDER_MODE == 1\n vec3 rotEuler = vec3(0.);\n #else\n vec3 rotEuler = vec3(0., 0., a_texCoord2.z);\n #endif\n computeVertPos(pos, cornerOffset, quaternionFromEuler(rotEuler), compScale\n #if CC_RENDER_MODE == 0 || CC_RENDER_MODE == 3\n , cc_matViewInv\n #endif\n #if CC_RENDER_MODE == 1\n , cc_cameraPos.xyz\n , velocity\n , frameTile_velLenScale.z\n , frameTile_velLenScale.w\n , a_texCoord.x\n #endif\n );\n color = a_color;\n #else\n mat4 xformNoScale = matrixFromRT(quaternionFromEuler(a_texCoord2), pos.xyz);\n mat4 xform = matFromRTS(quaternionFromEuler(a_texCoord2), pos.xyz, compScale);\n pos = xform * vec4(a_texCoord3, 1);\n vec4 normal = xformNoScale * vec4(a_normal, 0);\n color = a_color * a_color1;\n #endif\n uv = computeUV(a_texCoord.z, a_texCoord.xy, frameTile_velLenScale.xy) * mainTiling_Offset.xy + mainTiling_Offset.zw;\n pos = cc_matViewProj * pos;\n return pos;\n}\nvoid main() { gl_Position = lpvs_main(); }",frag:"\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n #if CC_USE_HDR\n color.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n #endif\n return color;\n}\nin vec2 uv;\nin vec4 color;\nuniform sampler2D mainTexture;\nlayout(std140) uniform FragConstants {\n vec4 tintColor;\n};\nvec4 add () {\n vec4 col = 2.0 * color * tintColor * texture(mainTexture, uv);\n return CCFragOutput(col);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = add(); }"}],[{vert:"\nprecision highp float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\n#if USE_LOCAL\nlayout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n};\n#endif\nin vec3 a_position;\nin vec2 a_texCoord;\nin vec4 a_color;\nout vec4 v_light;\nout vec2 uv0;\n#if TWO_COLORED\n in vec4 a_color2;\n out vec4 v_dark;\n#endif\nvec4 vert () {\n vec4 pos = vec4(a_position, 1);\n #if USE_LOCAL\n pos = cc_matWorld * pos;\n #endif\n pos = cc_matViewProj * pos;\n uv0 = a_texCoord;\n v_light = a_color;\n #if TWO_COLORED\n v_dark = a_color2;\n #endif\n return pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\n#if USE_ALPHA_TEST\n layout(std140) uniform ALPHA_TEST_DATA {\n float alphaThreshold;\n };\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nin vec4 v_light;\n#if TWO_COLORED\n in vec4 v_dark;\n#endif\nin vec2 uv0;\nuniform sampler2D cc_spriteTexture;\nvec4 frag () {\n vec4 o = vec4(1, 1, 1, 1);\n #if TWO_COLORED\n vec4 texColor = vec4(1, 1, 1, 1);\n texColor *= texture(cc_spriteTexture, uv0);\n o.a = texColor.a * v_light.a;\n o.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;\n #else\n o *= texture(cc_spriteTexture, uv0);\n o *= v_light;\n #endif\n ALPHA_TEST(o);\n return o;\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\n#if USE_LOCAL\nlayout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n};\n#endif\nin vec3 a_position;\nin vec2 a_texCoord;\nin vec4 a_color;\nout vec4 color;\nout vec2 uv0;\nvec4 vert () {\n vec4 pos = vec4(a_position, 1);\n #if USE_LOCAL\n pos = cc_matWorld * pos;\n #endif\n #if USE_PIXEL_ALIGNMENT\n pos = cc_matView * pos;\n pos.xyz = floor(pos.xyz);\n pos = cc_matProj * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n uv0 = a_texCoord;\n color = a_color;\n return pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nvec4 CCSampleWithAlphaSeparated(sampler2D tex, vec2 uv) {\n#if CC_USE_EMBEDDED_ALPHA\n return vec4(texture(tex, uv).rgb, texture(tex, uv + vec2(0.0, 0.5)).r);\n#else\n return texture(tex, uv);\n#endif\n}\n#if USE_ALPHA_TEST\n layout(std140) uniform ALPHA_TEST_DATA {\n float alphaThreshold;\n };\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nin vec4 color;\n#if USE_TEXTURE\n in vec2 uv0;\n uniform sampler2D cc_spriteTexture;\n#endif\nvec4 frag () {\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n o *= CCSampleWithAlphaSeparated(cc_spriteTexture, uv0);\n #if IS_GRAY\n float gray = 0.2126 * o.r + 0.7152 * o.g + 0.0722 * o.b;\n o.r = o.g = o.b = gray;\n #endif\n #endif\n o *= color;\n ALPHA_TEST(o);\n return o;\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\n rgba = rgba * 255.0;\n highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\n highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\n highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\n highp vec4 position;\n vec3 normal;\n vec4 tangent;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nin vec4 a_tangent;\n#if CC_USE_MORPH\n in float a_vertexId;\n int getVertexId() {\n return int(a_vertexId);\n }\nlayout(std140) uniform CCMorph {\n vec4 cc_displacementWeights[15];\n vec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\n float pixelIndexF = float(pixelIndex);\n float x = mod(pixelIndexF, textureResolution.x);\n float y = floor(pixelIndexF / textureResolution.x);\n return vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\n return (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_SUPPORT_FLOAT_TEXTURE\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\n ivec2 texSize = textureSize(tex, 0);\n return texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n }\n#else\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex * 4;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\n return vec4(\n decode32(texture(tex, x)),\n decode32(texture(tex, y)),\n decode32(texture(tex, z)),\n 1.0\n );\n }\n#endif\nfloat getDisplacementWeight(int index) {\n int quot = index / 4;\n int remainder = index - quot * 4;\n if (remainder == 0) {\n return cc_displacementWeights[quot].x;\n } else if (remainder == 1) {\n return cc_displacementWeights[quot].y;\n } else if (remainder == 2) {\n return cc_displacementWeights[quot].z;\n } else {\n return cc_displacementWeights[quot].w;\n }\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\n return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\n vec3 result = vec3(0, 0, 0);\n int nVertices = int(cc_displacementTextureInfo.z);\n for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\n result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n }\n return result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\n uniform sampler2D cc_PositionDisplacements;\n vec3 getPositionDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n uniform sampler2D cc_NormalDisplacements;\n vec3 getNormalDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n uniform sampler2D cc_TangentDisplacements;\n vec3 getTangentDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n }\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\n int vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\n attr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n attr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n attr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\n in vec4 a_joints;\nin vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n #if USE_INSTANCING\n in highp vec4 a_jointAnimInfo;\n #endif\n layout(std140) uniform CCSkinningTexture {\n highp vec4 cc_jointTextureInfo;\n };\n layout(std140) uniform CCSkinningAnimation {\n highp vec4 cc_jointAnimInfo;\n };\n uniform highp sampler2D cc_jointTexture;\n #else\n layout(std140) uniform CCSkinning {\n highp vec4 cc_joints[30 * 3];\n };\n#endif\n#if CC_USE_BAKED_ANIMATION\n #if CC_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\n vec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\n vec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n );\n vec4 v2 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n );\n vec4 v3 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n#else\n mat4 getJointMatrix (float i) {\n int idx = int(i);\n vec4 v1 = cc_joints[idx * 3];\n vec4 v2 = cc_joints[idx * 3 + 1];\n vec4 v3 = cc_joints[idx * 3 + 2];\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n#endif\nmat4 skinMatrix () {\n vec4 joints = vec4(a_joints);\n return getJointMatrix(joints.x) * a_weights.x\n + getJointMatrix(joints.y) * a_weights.y\n + getJointMatrix(joints.z) * a_weights.z\n + getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\n mat4 m = skinMatrix();\n position = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\n mat4 m = skinMatrix();\n attr.position = m * attr.position;\n attr.normal = (m * vec4(attr.normal, 0.0)).xyz;\n attr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\n#if USE_INSTANCING\n in vec4 a_matWorld0;\n in vec4 a_matWorld1;\n in vec4 a_matWorld2;\n #if USE_LIGHTMAP\n in vec4 a_lightingMapUVParam;\n #endif\n#elif USE_BATCHING\n in float a_dyn_batch_id;\n layout(std140) uniform CCLocalBatched {\n highp mat4 cc_matWorlds[10];\n };\n#else\nlayout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n};\n#endif\nlayout(std140) uniform Constants {\n vec4 tilingOffset;\n vec4 albedo;\n vec4 albedoScaleAndCutoff;\n vec4 pbrParams;\n vec4 emissive;\n vec4 emissiveScaleParam;\n};\nfloat LinearFog(vec4 pos) {\n vec4 wPos = pos;\n float cam_dis = distance(cc_cameraPos, wPos);\n float fogStart = cc_fogBase.x;\n float fogEnd = cc_fogBase.y;\n return clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float fogDensity = cc_fogBase.z;\n float cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\n float f = exp(-cam_dis * fogDensity);\n return f;\n}\nfloat ExpSquaredFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float fogDensity = cc_fogBase.z;\n float cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\n float f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\n return f;\n}\nfloat LayeredFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float _FogTop = cc_fogAdd.x;\n float _FogRange = cc_fogAdd.y;\n vec3 camWorldProj = cc_cameraPos.xyz;\n camWorldProj.y = 0.;\n vec3 worldPosProj = wPos.xyz;\n worldPosProj.y = 0.;\n float fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\n float fDeltaY, fDensityIntegral;\n if (cc_cameraPos.y > _FogTop) {\n if (wPos.y < _FogTop) {\n fDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\n fDensityIntegral = fDeltaY * fDeltaY * 0.5;\n } else {\n fDeltaY = 0.;\n fDensityIntegral = 0.;\n }\n } else {\n if (wPos.y < _FogTop) {\n float fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\n float fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\n fDeltaY = abs(fDeltaA - fDeltaB);\n fDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n } else {\n fDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\n fDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n }\n }\n float fDensity;\n if (fDeltaY != 0.) {\n fDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n } else {\n fDensity = 0.;\n }\n float f = exp(-fDensity);\n return f;\n}\nfloat CC_TRANSFER_FOG(vec4 pos) {\n #if CC_USE_FOG == 0\n return LinearFog(pos);\n\t#elif CC_USE_FOG == 1\n return ExpFog(pos);\n #elif CC_USE_FOG == 2\n return ExpSquaredFog(pos);\n #elif CC_USE_FOG == 3\n return LayeredFog(pos);\n #endif\n return 1.;\n}\nout highp vec4 v_shadowPos;\nlayout(std140) uniform CCShadow {\n highp mat4 cc_matLightPlaneProj;\n highp mat4 cc_matLightViewProj;\n lowp vec4 cc_shadowColor;\n lowp vec4 cc_shadowInfo;\n};\n#if USE_VERTEX_COLOR\n in vec4 a_color;\n out vec4 v_color;\n#endif\nout vec3 v_position;\nout vec3 v_normal;\nout vec2 v_uv;\nout vec2 v_uv1;\nout float v_fog_factor;\n#if USE_NORMAL_MAP\n out vec3 v_tangent;\n out vec3 v_bitangent;\n#endif\n#if HAS_SECOND_UV || USE_LIGHTMAP\n in vec2 a_texCoord1;\n#endif\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\n out vec2 v_luv;\nvoid CCLightingMapCaclUV()\n{\n#if !USE_INSTANCING\n v_luv = cc_lightingMapUVParam.xy + a_texCoord1 * cc_lightingMapUVParam.zw;\n#else\n v_luv = a_lightingMapUVParam.xy + a_texCoord1 * a_lightingMapUVParam.zw;\n#endif\n}\n#endif\nvec4 vert () {\n StandardVertInput In;\n In.position = vec4(a_position, 1.0);\n In.normal = a_normal;\n In.tangent = a_tangent;\n #if CC_USE_MORPH\n applyMorph(In);\n #endif\n #if CC_USE_SKINNING\n CCSkin(In);\n #endif\n mat4 matWorld, matWorldIT;\n #if USE_INSTANCING\n matWorld = mat4(\n vec4(a_matWorld0.xyz, 0.0),\n vec4(a_matWorld1.xyz, 0.0),\n vec4(a_matWorld2.xyz, 0.0),\n vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n );\n matWorldIT = matWorld;\n #elif USE_BATCHING\n matWorld = cc_matWorlds[int(a_dyn_batch_id)];\n matWorldIT = matWorld;\n #else\n matWorld = cc_matWorld;\n matWorldIT = cc_matWorldIT;\n #endif\n vec4 pos = matWorld * In.position;\n v_position = pos.xyz;\n v_normal = normalize((matWorldIT * vec4(In.normal, 0.0)).xyz);\n #if USE_NORMAL_MAP\n v_tangent = normalize((matWorld * vec4(In.tangent.xyz, 0.0)).xyz);\n v_bitangent = cross(v_normal, v_tangent) * In.tangent.w;\n #endif\n v_uv = a_texCoord * tilingOffset.xy + tilingOffset.zw;\n #if HAS_SECOND_UV\n v_uv1 = a_texCoord1 * tilingOffset.xy + tilingOffset.zw;\n #endif\n #if USE_VERTEX_COLOR\n v_color = a_color;\n #endif\n v_fog_factor = CC_TRANSFER_FOG(pos);\n #if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\n CCLightingMapCaclUV();\n #endif\n v_shadowPos = cc_matLightViewProj * pos;\n return cc_matProj * (cc_matView * matWorld) * In.position;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nlayout(std140) uniform CCShadow {\n highp mat4 cc_matLightPlaneProj;\n highp mat4 cc_matLightViewProj;\n lowp vec4 cc_shadowColor;\n lowp vec4 cc_shadowInfo;\n};\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\nvec3 unpackRGBE (vec4 rgbe) {\n return rgbe.rgb * pow(2.0, rgbe.a * 255.0 - 128.0);\n}\nvec4 fragTextureLod (sampler2D tex, vec2 coord, float lod) {\n return textureLod(tex, coord, lod);\n}\nvec4 fragTextureLod (samplerCube tex, vec3 coord, float lod) {\n return textureLod(tex, coord, lod);\n}\n#endif\n#if CC_RECEIVE_SHADOW\nin highp vec4 v_shadowPos;\n#if CC_RECEIVE_SHADOW\n uniform sampler2D cc_shadowMap;\n uniform sampler2D cc_spotLightingMap;\n float CCGetShadowFactorX1 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float closestDepth = dot(texture(cc_shadowMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n float shadow = step(closestDepth, clipPos.z - cc_shadowInfo.w);\n return shadow;\n }\n float CCGetShadowFactorX5 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n float closestDepth = 0.0;\n closestDepth = dot(texture(cc_shadowMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_shadowMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_shadowMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_shadowMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n return shadow / 5.0;\n }\n float CCGetShadowFactorX9 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -1; i <= 1; i++) {\n for (int j = -1; j <= 1; j++) {\n float closestDepth = dot(texture(cc_shadowMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 9.0;\n }\n float CCGetShadowFactorX25 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -2; i <= 2; i++) {\n for (int j = -2; j <= 2; j++) {\n float closestDepth = dot(texture(cc_shadowMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 25.0;\n }\n float CCGetDirLightShadowFactorX1 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float closestDepth = dot(texture(cc_spotLightingMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n float shadow = step(closestDepth, clipPos.z - cc_shadowInfo.w);\n return shadow;\n }\n float CCGetDirLightShadowFactorX5 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n float closestDepth = 0.0;\n closestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n return shadow / 5.0;\n }\n float CCGetDirLightShadowFactorX9 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -1; i <= 1; i++) {\n for (int j = -1; j <= 1; j++) {\n float closestDepth = dot(texture(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 9.0;\n }\n float CCGetDirLightShadowFactorX25 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -2; i <= 2; i++) {\n for (int j = -2; j <= 2; j++) {\n float closestDepth = dot(texture(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 25.0;\n }\n#endif\n#endif\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nfloat GGXMobile (float roughness, float NoH, vec3 H, vec3 N) {\n vec3 NxH = cross(N, H);\n float OneMinusNoHSqr = dot(NxH, NxH);\n float a = roughness * roughness;\n float n = NoH * a;\n float p = a / (OneMinusNoHSqr + n * n);\n return p * p;\n}\nfloat CalcSpecular (float roughness, float NoH, vec3 H, vec3 N) {\n return (roughness*0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox (vec3 specular, float roughness, float NoV) {\n const vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\n const vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\n vec4 r = roughness * c0 + c1;\n float a004 = min( r.x * r.x, exp2( -9.28 * NoV ) ) * r.x + r.y;\n vec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n AB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\n return specular * AB.x + AB.y;\n}\nstruct StandardSurface {\n vec4 albedo;\n vec3 position;\n vec3 normal;\n vec3 emissive;\n vec4 lightmap;\n float roughness;\n float metallic;\n float occlusion;\n};\n#if CC_FORWARD_ADD\nlayout(std140) uniform CCForwardLight {\n highp vec4 cc_lightPos[1];\n vec4 cc_lightColor[1];\n vec4 cc_lightSizeRangeAngle[1];\n vec4 cc_lightDir[1];\n};\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\n float factor = distSqr * invSqrAttRadius;\n float smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\n return smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\n float attenuation = 1.0 / max(distSqr, 0.01*0.01);\n attenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\n return attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\n float cd = dot(litDir, L);\n float attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\n return (attenuation * attenuation);\n}\n vec4 CCStandardShading (StandardSurface s) {\n vec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\n vec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\n vec3 diffuseContrib = diffuse / 3.14159265359;\n vec3 N = normalize(s.normal);\n vec3 V = normalize(cc_cameraPos.xyz - s.position);\n float NV = max(abs(dot(N, V)), 0.001);\n specular = BRDFApprox(specular, s.roughness, NV);\n vec3 finalColor = vec3(0.0);\n for (int i = 0; i < 1; i++) {\n vec3 SLU = cc_lightPos[i].xyz - s.position;\n vec3 SL = normalize(SLU);\n vec3 SH = normalize(SL + V);\n float SNL = max(dot(N, SL), 0.001);\n float SNH = max(dot(N, SH), 0.0);\n float distSqr = dot(SLU, SLU);\n float litRadius = cc_lightSizeRangeAngle[i].x;\n float litRadiusSqr = litRadius * litRadius;\n float illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\n float attRadiusSqrInv = 1.0 / max(cc_lightSizeRangeAngle[i].y, 0.01);\n attRadiusSqrInv *= attRadiusSqrInv;\n float att = GetDistAtt(distSqr, attRadiusSqrInv);\n vec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\n if (cc_lightPos[i].w > 0.0) {\n float cosInner = max(dot(-cc_lightDir[i].xyz, SL), 0.01);\n float cosOuter = cc_lightSizeRangeAngle[i].z;\n float litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\n float litAngleOffset = -cosOuter * litAngleScale;\n att *= GetAngleAtt(SL, -cc_lightDir[i].xyz, litAngleScale, litAngleOffset);\n }\n vec3 lightColor = cc_lightColor[i].rgb;\n #if CC_RECEIVE_SHADOW\n if (cc_lightPos[i].w > 0.0) {\n {\n float pcf = cc_shadowInfo.z + 0.001;\n float shadowAttenuation = 0.0;\n if (pcf > 3.0) shadowAttenuation = CCGetDirLightShadowFactorX25();\n else if (3.0 > pcf && pcf > 2.0) shadowAttenuation = CCGetDirLightShadowFactorX9();\n else if (2.0 > pcf && pcf > 1.0) shadowAttenuation = CCGetDirLightShadowFactorX5();\n else shadowAttenuation = CCGetDirLightShadowFactorX1();\n lightColor *= 1.0 - shadowAttenuation;\n }\n }\n #endif\n finalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n }\n finalColor = finalColor * s.occlusion;\n return vec4(finalColor, 0.0);\n }\n#else\n vec4 CCStandardShading (StandardSurface s) {\n vec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\n vec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\n vec3 N = normalize(s.normal);\n vec3 V = normalize(cc_cameraPos.xyz - s.position);\n float NV = max(abs(dot(N, V)), 0.001);\n specular = BRDFApprox(specular, s.roughness, NV);\n vec3 L = normalize(-cc_mainLitDir.xyz);\n vec3 H = normalize(L+V);\n float NH = max(dot(N, H), 0.0);\n float NL = max(dot(N, L), 0.001);\n vec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w;\n #if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\n finalColor = s.lightmap.a * s.lightmap.rgb + (1.0 - s.lightmap.a) * finalColor;\n #endif\n vec3 diffuseContrib = diffuse / 3.14159265359;\n vec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\n finalColor *= (diffuseContrib + specularContrib);\n float fAmb = 0.5 - N.y * 0.5;\n vec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb) * cc_ambientSky.w;\n finalColor += (ambDiff.rgb * diffuse);\n #if CC_USE_IBL\n vec3 R = normalize(reflect(-V, N));\n vec4 envmap = fragTextureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n #if CC_USE_IBL == 2\n vec3 env = unpackRGBE(envmap);\n #else\n vec3 env = SRGBToLinear(envmap.rgb);\n #endif\n finalColor += env * cc_ambientSky.w * specular;\n #endif\n finalColor = finalColor * s.occlusion;\n #if CC_USE_HDR\n s.emissive *= cc_exposure.w;\n #endif\n finalColor += s.emissive;\n #if CC_RECEIVE_SHADOW\n {\n float pcf = cc_shadowInfo.z + 0.001;\n float shadowAttenuation = 0.0;\n if (pcf > 3.0) shadowAttenuation = CCGetShadowFactorX25();\n else if (3.0 > pcf && pcf > 2.0) shadowAttenuation = CCGetShadowFactorX9();\n else if (2.0 > pcf && pcf > 1.0) shadowAttenuation = CCGetShadowFactorX5();\n else shadowAttenuation = CCGetShadowFactorX1();\n vec3 shadowColor = cc_shadowColor.rgb * cc_shadowColor.a + finalColor.rgb * (1.0 - cc_shadowColor.a);\n finalColor.rgb = shadowColor.rgb * shadowAttenuation * NL + finalColor.rgb * (1.0 - shadowAttenuation * NL);\n }\n #endif\n return vec4(finalColor, s.albedo.a);\n }\n#endif\nvec3 ACESToneMap (vec3 color) {\n color = min(color, vec3(8.0));\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n #if !CC_USE_HDR\n color.rgb = sqrt(ACESToneMap(color.rgb));\n #endif\n return color;\n}\nlayout(std140) uniform Constants {\n vec4 tilingOffset;\n vec4 albedo;\n vec4 albedoScaleAndCutoff;\n vec4 pbrParams;\n vec4 emissive;\n vec4 emissiveScaleParam;\n};\n#if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\n in vec2 v_luv;\nuniform sampler2D cc_lightingMap;\n#endif\nin vec3 v_position;\nin vec2 v_uv;\nin vec2 v_uv1;\nin vec3 v_normal;\nin float v_fog_factor;\n#if USE_VERTEX_COLOR\n in vec4 v_color;\n#endif\n#if USE_ALBEDO_MAP\n uniform sampler2D albedoMap;\n#endif\n#if USE_NORMAL_MAP\n in vec3 v_tangent;\n in vec3 v_bitangent;\n uniform sampler2D normalMap;\n#endif\n#if USE_PBR_MAP\n uniform sampler2D pbrMap;\n#endif\n#if USE_METALLIC_ROUGHNESS_MAP\n uniform sampler2D metallicRoughnessMap;\n#endif\n#if USE_OCCLUSION_MAP\n uniform sampler2D occlusionMap;\n#endif\n#if USE_EMISSIVE_MAP\n uniform sampler2D emissiveMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\nvoid surf (out StandardSurface s) {\n vec4 baseColor = albedo;\n #if USE_VERTEX_COLOR\n baseColor *= v_color;\n #endif\n #if USE_ALBEDO_MAP\n vec4 texColor = texture(albedoMap, ALBEDO_UV);\n texColor.rgb = SRGBToLinear(texColor.rgb);\n baseColor *= texColor;\n #endif\n s.albedo = baseColor;\n s.albedo.rgb *= albedoScaleAndCutoff.xyz;\n #if USE_ALPHA_TEST\n if (s.albedo.ALPHA_TEST_CHANNEL < albedoScaleAndCutoff.w) discard;\n #endif\n #if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\n s.lightmap = texture(cc_lightingMap, v_luv);\n #endif\n s.normal = v_normal;\n #if USE_NORMAL_MAP\n vec3 nmmp = texture(normalMap, NORMAL_UV).xyz - vec3(0.5);\n s.normal =\n (nmmp.x * pbrParams.w) * normalize(v_tangent) +\n (nmmp.y * pbrParams.w) * normalize(v_bitangent) +\n nmmp.z * normalize(s.normal);\n #endif\n s.position = v_position;\n vec4 pbr = pbrParams;\n #if USE_PBR_MAP\n vec4 res = texture(pbrMap, PBR_UV);\n pbr.x *= res.r;\n pbr.y *= res.g;\n pbr.z *= res.b;\n #endif\n #if USE_METALLIC_ROUGHNESS_MAP\n vec4 metallicRoughness = texture(metallicRoughnessMap, PBR_UV);\n pbr.z *= metallicRoughness.b;\n pbr.y *= metallicRoughness.g;\n #endif\n #if USE_OCCLUSION_MAP\n pbr.x *= texture(occlusionMap, PBR_UV).r;\n #endif\n s.occlusion = clamp(pbr.x, 0.0, 0.96);\n s.roughness = clamp(pbr.y, 0.04, 1.0);\n s.metallic = pbr.z;\n s.emissive = emissive.rgb * emissiveScaleParam.xyz;\n #if USE_EMISSIVE_MAP\n s.emissive *= SRGBToLinear(texture(emissiveMap, EMISSIVE_UV).rgb);\n #endif\n}\nvec4 frag () {\n StandardSurface s; surf(s);\n vec4 color = CCStandardShading(s);\n color = vec4(mix(CC_FORWARD_ADD > 0 ? vec3(0.0) : cc_fogColor.rgb, color.rgb, v_fog_factor), color.a);\n return CCFragOutput(color);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"},{vert:"\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\n rgba = rgba * 255.0;\n highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\n highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\n highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\n highp vec4 position;\n vec3 normal;\n vec4 tangent;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nin vec4 a_tangent;\n#if CC_USE_MORPH\n in float a_vertexId;\n int getVertexId() {\n return int(a_vertexId);\n }\nlayout(std140) uniform CCMorph {\n vec4 cc_displacementWeights[15];\n vec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\n float pixelIndexF = float(pixelIndex);\n float x = mod(pixelIndexF, textureResolution.x);\n float y = floor(pixelIndexF / textureResolution.x);\n return vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\n return (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_SUPPORT_FLOAT_TEXTURE\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\n ivec2 texSize = textureSize(tex, 0);\n return texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n }\n#else\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex * 4;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\n return vec4(\n decode32(texture(tex, x)),\n decode32(texture(tex, y)),\n decode32(texture(tex, z)),\n 1.0\n );\n }\n#endif\nfloat getDisplacementWeight(int index) {\n int quot = index / 4;\n int remainder = index - quot * 4;\n if (remainder == 0) {\n return cc_displacementWeights[quot].x;\n } else if (remainder == 1) {\n return cc_displacementWeights[quot].y;\n } else if (remainder == 2) {\n return cc_displacementWeights[quot].z;\n } else {\n return cc_displacementWeights[quot].w;\n }\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\n return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\n vec3 result = vec3(0, 0, 0);\n int nVertices = int(cc_displacementTextureInfo.z);\n for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\n result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n }\n return result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\n uniform sampler2D cc_PositionDisplacements;\n vec3 getPositionDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n uniform sampler2D cc_NormalDisplacements;\n vec3 getNormalDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n uniform sampler2D cc_TangentDisplacements;\n vec3 getTangentDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n }\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\n int vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\n attr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n attr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n attr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\n in vec4 a_joints;\nin vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n #if USE_INSTANCING\n in highp vec4 a_jointAnimInfo;\n #endif\n layout(std140) uniform CCSkinningTexture {\n highp vec4 cc_jointTextureInfo;\n };\n layout(std140) uniform CCSkinningAnimation {\n highp vec4 cc_jointAnimInfo;\n };\n uniform highp sampler2D cc_jointTexture;\n #else\n layout(std140) uniform CCSkinning {\n highp vec4 cc_joints[30 * 3];\n };\n#endif\n#if CC_USE_BAKED_ANIMATION\n #if CC_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\n vec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\n vec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n );\n vec4 v2 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n );\n vec4 v3 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n#else\n mat4 getJointMatrix (float i) {\n int idx = int(i);\n vec4 v1 = cc_joints[idx * 3];\n vec4 v2 = cc_joints[idx * 3 + 1];\n vec4 v3 = cc_joints[idx * 3 + 2];\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n#endif\nmat4 skinMatrix () {\n vec4 joints = vec4(a_joints);\n return getJointMatrix(joints.x) * a_weights.x\n + getJointMatrix(joints.y) * a_weights.y\n + getJointMatrix(joints.z) * a_weights.z\n + getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\n mat4 m = skinMatrix();\n position = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\n mat4 m = skinMatrix();\n attr.position = m * attr.position;\n attr.normal = (m * vec4(attr.normal, 0.0)).xyz;\n attr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\n#if USE_INSTANCING\n in vec4 a_matWorld0;\n in vec4 a_matWorld1;\n in vec4 a_matWorld2;\n #if USE_LIGHTMAP\n in vec4 a_lightingMapUVParam;\n #endif\n#elif USE_BATCHING\n in float a_dyn_batch_id;\n layout(std140) uniform CCLocalBatched {\n highp mat4 cc_matWorlds[10];\n };\n#else\nlayout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n};\n#endif\nlayout(std140) uniform Constants {\n vec4 tilingOffset;\n vec4 albedo;\n vec4 albedoScaleAndCutoff;\n vec4 pbrParams;\n vec4 emissive;\n vec4 emissiveScaleParam;\n};\nlayout(std140) uniform CCShadow {\n highp mat4 cc_matLightPlaneProj;\n highp mat4 cc_matLightViewProj;\n lowp vec4 cc_shadowColor;\n lowp vec4 cc_shadowInfo;\n};\n#if HAS_SECOND_UV || USE_LIGHTMAP\n in vec2 a_texCoord1;\n#endif\nout vec2 v_uv;\nout vec2 v_uv1;\nout float v_clip_depth;\nvec4 vert () {\n StandardVertInput In;\n In.position = vec4(a_position, 1.0);\n In.normal = a_normal;\n In.tangent = a_tangent;\n #if CC_USE_MORPH\n applyMorph(In);\n #endif\n #if CC_USE_SKINNING\n CCSkin(In);\n #endif\n mat4 matWorld, matWorldIT;\n #if USE_INSTANCING\n matWorld = mat4(\n vec4(a_matWorld0.xyz, 0.0),\n vec4(a_matWorld1.xyz, 0.0),\n vec4(a_matWorld2.xyz, 0.0),\n vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n );\n matWorldIT = matWorld;\n #elif USE_BATCHING\n matWorld = cc_matWorlds[int(a_dyn_batch_id)];\n matWorldIT = matWorld;\n #else\n matWorld = cc_matWorld;\n matWorldIT = cc_matWorldIT;\n #endif\n vec4 worldPos = matWorld * In.position;\n vec4 clipPos = cc_matLightViewProj * worldPos;\n v_uv = a_texCoord * tilingOffset.xy + tilingOffset.zw;\n #if HAS_SECOND_UV\n v_uv1 = a_texCoord1 * tilingOffset.xy + tilingOffset.zw;\n #endif\n v_clip_depth = clipPos.z / clipPos.w * 0.5 + 0.5;\n return clipPos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nlayout(std140) uniform Constants {\n vec4 tilingOffset;\n vec4 albedo;\n vec4 albedoScaleAndCutoff;\n vec4 pbrParams;\n vec4 emissive;\n vec4 emissiveScaleParam;\n};\nvec4 packDepthToRGBA (float depth) {\n vec4 ret = vec4(1.0, 255.0, 65025.0, 160581375.0) * depth;\n ret = fract(ret);\n ret -= ret.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n return ret;\n}\nin vec2 v_uv;\nin vec2 v_uv1;\nin float v_clip_depth;\n#if USE_ALBEDO_MAP\n uniform sampler2D albedoMap;\n#endif\n#if USE_ALPHA_TEST\n#endif\nvec4 frag () {\n vec4 baseColor = albedo;\n #if USE_ALBEDO_MAP\n baseColor *= texture(albedoMap, ALBEDO_UV);\n #endif\n #if USE_ALPHA_TEST\n if (baseColor.ALPHA_TEST_CHANNEL < albedoScaleAndCutoff.w) discard;\n #endif\n return packDepthToRGBA(v_clip_depth);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}],[{vert:"\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nlayout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n};\nfloat LinearFog(vec4 pos) {\n vec4 wPos = pos;\n float cam_dis = distance(cc_cameraPos, wPos);\n float fogStart = cc_fogBase.x;\n float fogEnd = cc_fogBase.y;\n return clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float fogDensity = cc_fogBase.z;\n float cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\n float f = exp(-cam_dis * fogDensity);\n return f;\n}\nfloat ExpSquaredFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float fogDensity = cc_fogBase.z;\n float cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\n float f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\n return f;\n}\nfloat LayeredFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float _FogTop = cc_fogAdd.x;\n float _FogRange = cc_fogAdd.y;\n vec3 camWorldProj = cc_cameraPos.xyz;\n camWorldProj.y = 0.;\n vec3 worldPosProj = wPos.xyz;\n worldPosProj.y = 0.;\n float fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\n float fDeltaY, fDensityIntegral;\n if (cc_cameraPos.y > _FogTop) {\n if (wPos.y < _FogTop) {\n fDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\n fDensityIntegral = fDeltaY * fDeltaY * 0.5;\n } else {\n fDeltaY = 0.;\n fDensityIntegral = 0.;\n }\n } else {\n if (wPos.y < _FogTop) {\n float fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\n float fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\n fDeltaY = abs(fDeltaA - fDeltaB);\n fDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n } else {\n fDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\n fDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n }\n }\n float fDensity;\n if (fDeltaY != 0.) {\n fDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n } else {\n fDensity = 0.;\n }\n float f = exp(-fDensity);\n return f;\n}\nfloat CC_TRANSFER_FOG(vec4 pos) {\n #if CC_USE_FOG == 0\n return LinearFog(pos);\n\t#elif CC_USE_FOG == 1\n return ExpFog(pos);\n #elif CC_USE_FOG == 2\n return ExpSquaredFog(pos);\n #elif CC_USE_FOG == 3\n return LayeredFog(pos);\n #endif\n return 1.;\n}\nout highp vec4 v_shadowPos;\nlayout(std140) uniform CCShadow {\n highp mat4 cc_matLightPlaneProj;\n highp mat4 cc_matLightViewProj;\n lowp vec4 cc_shadowColor;\n lowp vec4 cc_shadowInfo;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nout highp vec3 v_position;\nout mediump vec3 v_normal;\n#if USE_NORMALMAP\n out mediump vec3 v_tangent;\n out mediump vec3 v_binormal;\n#endif\nout mediump vec2 uvw;\nout mediump vec2 uv0;\nout mediump vec2 uv1;\nout mediump vec2 uv2;\nout mediump vec2 uv3;\nout mediump vec2 luv;\nout mediump vec3 diffuse;\nout mediump float v_fog_factor;\nlayout(std140) uniform TexCoords {\n vec4 UVScale;\n vec4 lightMapUVParam;\n};\nvec4 vert () {\n vec3 worldPos;\n worldPos.x = cc_matWorld[3][0] + a_position.x;\n worldPos.y = cc_matWorld[3][1] + a_position.y;\n worldPos.z = cc_matWorld[3][2] + a_position.z;\n vec4 pos = vec4(worldPos, 1.0);\n pos = cc_matViewProj * pos;\n uvw = a_texCoord;\n uv0 = a_position.xz * UVScale.x;\n uv1 = a_position.xz * UVScale.y;\n uv2 = a_position.xz * UVScale.z;\n uv3 = a_position.xz * UVScale.w;\n #if USE_LIGHTMAP\n luv = lightMapUVParam.xy + a_texCoord * lightMapUVParam.zw;\n #endif\n v_position = worldPos;\n v_normal = a_normal;\n v_fog_factor = CC_TRANSFER_FOG(vec4(worldPos, 1.0));\n #if USE_NORMALMAP\n v_tangent = vec3(1.0, 0.0, 0.0);\n v_binormal = vec3(0.0, 0.0, 1.0);\n v_binormal = cross(v_tangent, a_normal);\n v_tangent = cross(a_normal, v_binormal);\n #endif\n v_shadowPos = cc_matLightViewProj * vec4(worldPos, 1.0);\n return pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nlayout(std140) uniform CCShadow {\n highp mat4 cc_matLightPlaneProj;\n highp mat4 cc_matLightViewProj;\n lowp vec4 cc_shadowColor;\n lowp vec4 cc_shadowInfo;\n};\n#if CC_USE_IBL\nuniform samplerCube cc_environment;\nvec3 unpackRGBE (vec4 rgbe) {\n return rgbe.rgb * pow(2.0, rgbe.a * 255.0 - 128.0);\n}\nvec4 fragTextureLod (sampler2D tex, vec2 coord, float lod) {\n return textureLod(tex, coord, lod);\n}\nvec4 fragTextureLod (samplerCube tex, vec3 coord, float lod) {\n return textureLod(tex, coord, lod);\n}\n#endif\n#if CC_RECEIVE_SHADOW\nin highp vec4 v_shadowPos;\n#if CC_RECEIVE_SHADOW\n uniform sampler2D cc_shadowMap;\n uniform sampler2D cc_spotLightingMap;\n float CCGetShadowFactorX1 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float closestDepth = dot(texture(cc_shadowMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n float shadow = step(closestDepth, clipPos.z - cc_shadowInfo.w);\n return shadow;\n }\n float CCGetShadowFactorX5 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n float closestDepth = 0.0;\n closestDepth = dot(texture(cc_shadowMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_shadowMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_shadowMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_shadowMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_shadowMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n return shadow / 5.0;\n }\n float CCGetShadowFactorX9 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -1; i <= 1; i++) {\n for (int j = -1; j <= 1; j++) {\n float closestDepth = dot(texture(cc_shadowMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 9.0;\n }\n float CCGetShadowFactorX25 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -2; i <= 2; i++) {\n for (int j = -2; j <= 2; j++) {\n float closestDepth = dot(texture(cc_shadowMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 25.0;\n }\n float CCGetDirLightShadowFactorX1 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float closestDepth = dot(texture(cc_spotLightingMap, clipPos.xy), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n float shadow = step(closestDepth, clipPos.z - cc_shadowInfo.w);\n return shadow;\n }\n float CCGetDirLightShadowFactorX5 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n float closestDepth = 0.0;\n closestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x - offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x, clipPos.y)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y - offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n closestDepth = dot(texture(cc_spotLightingMap, vec2(clipPos.x + offsetx, clipPos.y + offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n return shadow / 5.0;\n }\n float CCGetDirLightShadowFactorX9 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -1; i <= 1; i++) {\n for (int j = -1; j <= 1; j++) {\n float closestDepth = dot(texture(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 9.0;\n }\n float CCGetDirLightShadowFactorX25 () {\n vec3 clipPos = v_shadowPos.xyz / v_shadowPos.w * 0.5 + 0.5;\n if (clipPos.x < 0.0 || clipPos.x > 1.0 ||\n clipPos.y < 0.0 || clipPos.y > 1.0 ||\n clipPos.z <-1.0 || clipPos.z > 1.0) { return 0.0; }\n float offsetx = 1.0 / cc_shadowInfo.x;\n float offsety = 1.0 / cc_shadowInfo.y;\n float shadow = 0.0;\n for (int i = -2; i <= 2; i++) {\n for (int j = -2; j <= 2; j++) {\n float closestDepth = dot(texture(cc_spotLightingMap, clipPos.xy + vec2(i, j) * vec2(offsetx, offsety)), vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0));\n shadow += step(closestDepth, clipPos.z - cc_shadowInfo.w);\n }\n }\n return shadow / 25.0;\n }\n#endif\n#endif\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nfloat GGXMobile (float roughness, float NoH, vec3 H, vec3 N) {\n vec3 NxH = cross(N, H);\n float OneMinusNoHSqr = dot(NxH, NxH);\n float a = roughness * roughness;\n float n = NoH * a;\n float p = a / (OneMinusNoHSqr + n * n);\n return p * p;\n}\nfloat CalcSpecular (float roughness, float NoH, vec3 H, vec3 N) {\n return (roughness*0.25 + 0.25) * GGXMobile(roughness, NoH, H, N);\n}\nvec3 BRDFApprox (vec3 specular, float roughness, float NoV) {\n const vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);\n const vec4 c1 = vec4(1.0, 0.0425, 1.04, -0.04);\n vec4 r = roughness * c0 + c1;\n float a004 = min( r.x * r.x, exp2( -9.28 * NoV ) ) * r.x + r.y;\n vec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n AB.y *= clamp(50.0 * specular.g, 0.0, 1.0);\n return specular * AB.x + AB.y;\n}\nstruct StandardSurface {\n vec4 albedo;\n vec3 position;\n vec3 normal;\n vec3 emissive;\n vec4 lightmap;\n float roughness;\n float metallic;\n float occlusion;\n};\n#if CC_FORWARD_ADD\nlayout(std140) uniform CCForwardLight {\n highp vec4 cc_lightPos[1];\n vec4 cc_lightColor[1];\n vec4 cc_lightSizeRangeAngle[1];\n vec4 cc_lightDir[1];\n};\nfloat SmoothDistAtt (float distSqr, float invSqrAttRadius) {\n float factor = distSqr * invSqrAttRadius;\n float smoothFactor = clamp(1.0 - factor * factor, 0.0, 1.0);\n return smoothFactor * smoothFactor;\n}\nfloat GetDistAtt (float distSqr, float invSqrAttRadius) {\n float attenuation = 1.0 / max(distSqr, 0.01*0.01);\n attenuation *= SmoothDistAtt(distSqr , invSqrAttRadius);\n return attenuation;\n}\nfloat GetAngleAtt (vec3 L, vec3 litDir, float litAngleScale, float litAngleOffset) {\n float cd = dot(litDir, L);\n float attenuation = clamp(cd * litAngleScale + litAngleOffset, 0.0, 1.0);\n return (attenuation * attenuation);\n}\n vec4 CCStandardShading (StandardSurface s) {\n vec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\n vec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\n vec3 diffuseContrib = diffuse / 3.14159265359;\n vec3 N = normalize(s.normal);\n vec3 V = normalize(cc_cameraPos.xyz - s.position);\n float NV = max(abs(dot(N, V)), 0.001);\n specular = BRDFApprox(specular, s.roughness, NV);\n vec3 finalColor = vec3(0.0);\n for (int i = 0; i < 1; i++) {\n vec3 SLU = cc_lightPos[i].xyz - s.position;\n vec3 SL = normalize(SLU);\n vec3 SH = normalize(SL + V);\n float SNL = max(dot(N, SL), 0.001);\n float SNH = max(dot(N, SH), 0.0);\n float distSqr = dot(SLU, SLU);\n float litRadius = cc_lightSizeRangeAngle[i].x;\n float litRadiusSqr = litRadius * litRadius;\n float illum = 3.14159265359 * (litRadiusSqr / max(litRadiusSqr , distSqr));\n float attRadiusSqrInv = 1.0 / max(cc_lightSizeRangeAngle[i].y, 0.01);\n attRadiusSqrInv *= attRadiusSqrInv;\n float att = GetDistAtt(distSqr, attRadiusSqrInv);\n vec3 lspec = specular * CalcSpecular(s.roughness, SNH, SH, N);\n if (cc_lightPos[i].w > 0.0) {\n float cosInner = max(dot(-cc_lightDir[i].xyz, SL), 0.01);\n float cosOuter = cc_lightSizeRangeAngle[i].z;\n float litAngleScale = 1.0 / max(0.001, cosInner - cosOuter);\n float litAngleOffset = -cosOuter * litAngleScale;\n att *= GetAngleAtt(SL, -cc_lightDir[i].xyz, litAngleScale, litAngleOffset);\n }\n vec3 lightColor = cc_lightColor[i].rgb;\n #if CC_RECEIVE_SHADOW\n if (cc_lightPos[i].w > 0.0) {\n {\n float pcf = cc_shadowInfo.z + 0.001;\n float shadowAttenuation = 0.0;\n if (pcf > 3.0) shadowAttenuation = CCGetDirLightShadowFactorX25();\n else if (3.0 > pcf && pcf > 2.0) shadowAttenuation = CCGetDirLightShadowFactorX9();\n else if (2.0 > pcf && pcf > 1.0) shadowAttenuation = CCGetDirLightShadowFactorX5();\n else shadowAttenuation = CCGetDirLightShadowFactorX1();\n lightColor *= 1.0 - shadowAttenuation;\n }\n }\n #endif\n finalColor += SNL * lightColor * cc_lightColor[i].w * illum * att * (diffuseContrib + lspec);\n }\n finalColor = finalColor * s.occlusion;\n return vec4(finalColor, 0.0);\n }\n#else\n vec4 CCStandardShading (StandardSurface s) {\n vec3 diffuse = s.albedo.rgb * (1.0 - s.metallic);\n vec3 specular = mix(vec3(0.04), s.albedo.rgb, s.metallic);\n vec3 N = normalize(s.normal);\n vec3 V = normalize(cc_cameraPos.xyz - s.position);\n float NV = max(abs(dot(N, V)), 0.001);\n specular = BRDFApprox(specular, s.roughness, NV);\n vec3 L = normalize(-cc_mainLitDir.xyz);\n vec3 H = normalize(L+V);\n float NH = max(dot(N, H), 0.0);\n float NL = max(dot(N, L), 0.001);\n vec3 finalColor = NL * cc_mainLitColor.rgb * cc_mainLitColor.w;\n #if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\n finalColor = s.lightmap.a * s.lightmap.rgb + (1.0 - s.lightmap.a) * finalColor;\n #endif\n vec3 diffuseContrib = diffuse / 3.14159265359;\n vec3 specularContrib = specular * CalcSpecular(s.roughness, NH, H, N);\n finalColor *= (diffuseContrib + specularContrib);\n float fAmb = 0.5 - N.y * 0.5;\n vec3 ambDiff = mix(cc_ambientSky.rgb, cc_ambientGround.rgb, fAmb) * cc_ambientSky.w;\n finalColor += (ambDiff.rgb * diffuse);\n #if CC_USE_IBL\n vec3 R = normalize(reflect(-V, N));\n vec4 envmap = fragTextureLod(cc_environment, R, s.roughness * cc_ambientGround.w);\n #if CC_USE_IBL == 2\n vec3 env = unpackRGBE(envmap);\n #else\n vec3 env = SRGBToLinear(envmap.rgb);\n #endif\n finalColor += env * cc_ambientSky.w * specular;\n #endif\n finalColor = finalColor * s.occlusion;\n #if CC_USE_HDR\n s.emissive *= cc_exposure.w;\n #endif\n finalColor += s.emissive;\n #if CC_RECEIVE_SHADOW\n {\n float pcf = cc_shadowInfo.z + 0.001;\n float shadowAttenuation = 0.0;\n if (pcf > 3.0) shadowAttenuation = CCGetShadowFactorX25();\n else if (3.0 > pcf && pcf > 2.0) shadowAttenuation = CCGetShadowFactorX9();\n else if (2.0 > pcf && pcf > 1.0) shadowAttenuation = CCGetShadowFactorX5();\n else shadowAttenuation = CCGetShadowFactorX1();\n vec3 shadowColor = cc_shadowColor.rgb * cc_shadowColor.a + finalColor.rgb * (1.0 - cc_shadowColor.a);\n finalColor.rgb = shadowColor.rgb * shadowAttenuation * NL + finalColor.rgb * (1.0 - shadowAttenuation * NL);\n }\n #endif\n return vec4(finalColor, s.albedo.a);\n }\n#endif\nvec3 ACESToneMap (vec3 color) {\n color = min(color, vec3(8.0));\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n #if !CC_USE_HDR\n color.rgb = sqrt(ACESToneMap(color.rgb));\n #endif\n return color;\n}\nin highp vec3 v_position;\nin mediump vec3 v_normal;\n#if USE_NORMALMAP\n in mediump vec3 v_tangent;\n in mediump vec3 v_binormal;\n#endif\nin mediump vec2 uvw;\nin mediump vec2 uv0;\nin mediump vec2 uv1;\nin mediump vec2 uv2;\nin mediump vec2 uv3;\nin mediump vec3 diffuse;\nin mediump vec2 luv;\nin mediump float v_fog_factor;\nlayout(std140) uniform PbrParams {\n vec4 metallic;\n vec4 roughness;\n};\nuniform sampler2D weightMap;\nuniform sampler2D detailMap0;\nuniform sampler2D detailMap1;\nuniform sampler2D detailMap2;\nuniform sampler2D detailMap3;\nuniform sampler2D normalMap0;\nuniform sampler2D normalMap1;\nuniform sampler2D normalMap2;\nuniform sampler2D normalMap3;\nuniform sampler2D lightMap;\nvoid surf (out StandardSurface s) {\n #if LAYERS > 1\n vec4 w = texture(weightMap, uvw);\n #endif\n vec4 baseColor = vec4(0, 0, 0, 0);\n #if LAYERS == 1\n baseColor = texture(detailMap0, uv0);\n #elif LAYERS == 2\n baseColor += texture(detailMap0, uv0) * w.r;\n baseColor += texture(detailMap1, uv1) * w.g;\n #elif LAYERS == 3\n baseColor += texture(detailMap0, uv0) * w.r;\n baseColor += texture(detailMap1, uv1) * w.g;\n baseColor += texture(detailMap2, uv2) * w.b;\n #elif LAYERS == 4\n baseColor += texture(detailMap0, uv0) * w.r;\n baseColor += texture(detailMap1, uv1) * w.g;\n baseColor += texture(detailMap2, uv2) * w.b;\n baseColor += texture(detailMap3, uv3) * w.a;\n #else\n baseColor = texture(detailMap0, uv0);\n #endif\n s.position = v_position;\n #if USE_NORMALMAP\n vec4 baseNormal = vec4(0, 0, 0, 0);\n #if LAYERS == 1\n baseNormal = texture(normalMap0, uv0);\n #elif LAYERS == 2\n baseNormal += texture(normalMap0, uv0) * w.r;\n baseNormal += texture(normalMap1, uv1) * w.g;\n #elif LAYERS == 3\n baseNormal += texture(normalMap0, uv0) * w.r;\n baseNormal += texture(normalMap1, uv1) * w.g;\n baseNormal += texture(normalMap2, uv2) * w.b;\n #elif LAYERS == 4\n baseNormal += texture(normalMap0, uv0) * w.r;\n baseNormal += texture(normalMap1, uv1) * w.g;\n baseNormal += texture(normalMap2, uv2) * w.b;\n baseNormal += texture(normalMap3, uv3) * w.a;\n #else\n baseNormal = texture(normalMap0, uv0);\n #endif\n vec3 nmmp = baseNormal.xyz - vec3(0.5);\n s.normal =\n nmmp.x * normalize(v_tangent) +\n nmmp.y * normalize(v_binormal) +\n nmmp.z * normalize(v_normal);\n #else\n s.normal = v_normal;\n #endif\n s.albedo = vec4(SRGBToLinear(baseColor.rgb), 1.0);\n s.occlusion = 1.0;\n #if USE_PBR\n s.roughness = 0.0;\n #if LAYERS == 1\n s.roughness = roughness.x;\n #elif LAYERS == 2\n s.roughness += roughness.x * w.r;\n s.roughness += roughness.y * w.g;\n #elif LAYERS == 3\n s.roughness += roughness.x * w.r;\n s.roughness += roughness.y * w.g;\n s.roughness += roughness.z * w.b;\n #elif LAYERS == 4\n s.roughness += roughness.x * w.r;\n s.roughness += roughness.y * w.g;\n s.roughness += roughness.z * w.b;\n s.roughness += roughness.w * w.a;\n #else\n s.roughness = 1.0;\n #endif\n s.metallic = 0.0;\n #if LAYERS == 1\n s.metallic = metallic.x;\n #elif LAYERS == 2\n s.metallic += metallic.x * w.r;\n s.metallic += metallic.y * w.g;\n #elif LAYERS == 3\n s.metallic += metallic.x * w.r;\n s.metallic += metallic.y * w.g;\n s.metallic += metallic.z * w.b;\n #elif LAYERS == 4\n s.metallic += metallic.x * w.r;\n s.metallic += metallic.y * w.g;\n s.metallic += metallic.z * w.b;\n s.metallic += metallic.w * w.a;\n #else\n s.metallic = 0.0;\n #endif\n #else\n s.roughness = 1.0;\n s.metallic = 0.0;\n #endif\n s.emissive = vec3(0.0, 0.0, 0.0);\n #if USE_LIGHTMAP && !USE_BATCHING && !CC_FORWARD_ADD\n s.lightmap = texture(lightMap, luv);\n #else\n s.lightmap = vec4(0.0, 0.0, 0.0, 0.0);\n #endif\n}\nvec4 frag () {\n StandardSurface s; surf(s);\n vec4 color = CCStandardShading(s);\n color = vec4(mix(CC_FORWARD_ADD > 0 ? vec3(0.0) : cc_fogColor.rgb, color.rgb, v_fog_factor), color.a);\n return CCFragOutput(color);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"},{vert:"\nprecision highp float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nlayout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n};\nlayout(std140) uniform CCShadow {\n highp mat4 cc_matLightPlaneProj;\n highp mat4 cc_matLightViewProj;\n lowp vec4 cc_shadowColor;\n lowp vec4 cc_shadowInfo;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nout vec2 v_clip_depth;\nvec4 vert () {\n vec4 worldPos;\n worldPos.x = cc_matWorld[3][0] + a_position.x;\n worldPos.y = cc_matWorld[3][1] + a_position.y;\n worldPos.z = cc_matWorld[3][2] + a_position.z;\n worldPos.w = 1.0;\n vec4 clipPos = cc_matLightViewProj * worldPos;\n v_clip_depth = clipPos.zw;\n return clipPos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nvec4 packDepthToRGBA (float depth) {\n vec4 ret = vec4(1.0, 255.0, 65025.0, 160581375.0) * depth;\n ret = fract(ret);\n ret -= ret.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n return ret;\n}\nin vec2 v_clip_depth;\nvec4 frag () {\n return packDepthToRGBA(v_clip_depth.x / v_clip_depth.y * 0.5 + 0.5);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\n rgba = rgba * 255.0;\n highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\n highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\n highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\n highp vec4 position;\n vec3 normal;\n vec4 tangent;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nin vec4 a_tangent;\n#if CC_USE_MORPH\n in float a_vertexId;\n int getVertexId() {\n return int(a_vertexId);\n }\nlayout(std140) uniform CCMorph {\n vec4 cc_displacementWeights[15];\n vec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\n float pixelIndexF = float(pixelIndex);\n float x = mod(pixelIndexF, textureResolution.x);\n float y = floor(pixelIndexF / textureResolution.x);\n return vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\n return (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_SUPPORT_FLOAT_TEXTURE\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\n ivec2 texSize = textureSize(tex, 0);\n return texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n }\n#else\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex * 4;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\n return vec4(\n decode32(texture(tex, x)),\n decode32(texture(tex, y)),\n decode32(texture(tex, z)),\n 1.0\n );\n }\n#endif\nfloat getDisplacementWeight(int index) {\n int quot = index / 4;\n int remainder = index - quot * 4;\n if (remainder == 0) {\n return cc_displacementWeights[quot].x;\n } else if (remainder == 1) {\n return cc_displacementWeights[quot].y;\n } else if (remainder == 2) {\n return cc_displacementWeights[quot].z;\n } else {\n return cc_displacementWeights[quot].w;\n }\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\n return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\n vec3 result = vec3(0, 0, 0);\n int nVertices = int(cc_displacementTextureInfo.z);\n for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\n result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n }\n return result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\n uniform sampler2D cc_PositionDisplacements;\n vec3 getPositionDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n uniform sampler2D cc_NormalDisplacements;\n vec3 getNormalDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n uniform sampler2D cc_TangentDisplacements;\n vec3 getTangentDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n }\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\n int vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\n attr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n attr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n attr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\n in vec4 a_joints;\nin vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n #if USE_INSTANCING\n in highp vec4 a_jointAnimInfo;\n #endif\n layout(std140) uniform CCSkinningTexture {\n highp vec4 cc_jointTextureInfo;\n };\n layout(std140) uniform CCSkinningAnimation {\n highp vec4 cc_jointAnimInfo;\n };\n uniform highp sampler2D cc_jointTexture;\n #else\n layout(std140) uniform CCSkinning {\n highp vec4 cc_joints[30 * 3];\n };\n#endif\n#if CC_USE_BAKED_ANIMATION\n #if CC_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\n vec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\n vec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n );\n vec4 v2 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n );\n vec4 v3 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n#else\n mat4 getJointMatrix (float i) {\n int idx = int(i);\n vec4 v1 = cc_joints[idx * 3];\n vec4 v2 = cc_joints[idx * 3 + 1];\n vec4 v3 = cc_joints[idx * 3 + 2];\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n#endif\nmat4 skinMatrix () {\n vec4 joints = vec4(a_joints);\n return getJointMatrix(joints.x) * a_weights.x\n + getJointMatrix(joints.y) * a_weights.y\n + getJointMatrix(joints.z) * a_weights.z\n + getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\n mat4 m = skinMatrix();\n position = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\n mat4 m = skinMatrix();\n attr.position = m * attr.position;\n attr.normal = (m * vec4(attr.normal, 0.0)).xyz;\n attr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\n#if USE_INSTANCING\n in vec4 a_matWorld0;\n in vec4 a_matWorld1;\n in vec4 a_matWorld2;\n #if USE_LIGHTMAP\n in vec4 a_lightingMapUVParam;\n #endif\n#elif USE_BATCHING\n in float a_dyn_batch_id;\n layout(std140) uniform CCLocalBatched {\n highp mat4 cc_matWorlds[10];\n };\n#else\nlayout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n};\n#endif\nfloat LinearFog(vec4 pos) {\n vec4 wPos = pos;\n float cam_dis = distance(cc_cameraPos, wPos);\n float fogStart = cc_fogBase.x;\n float fogEnd = cc_fogBase.y;\n return clamp((fogEnd - cam_dis) / (fogEnd - fogStart), 0., 1.);\n}\nfloat ExpFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float fogDensity = cc_fogBase.z;\n float cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\n float f = exp(-cam_dis * fogDensity);\n return f;\n}\nfloat ExpSquaredFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float fogDensity = cc_fogBase.z;\n float cam_dis = distance(cc_cameraPos, wPos) / fogAtten * 4.;\n float f = exp(-cam_dis * cam_dis * fogDensity * fogDensity);\n return f;\n}\nfloat LayeredFog(vec4 pos) {\n vec4 wPos = pos;\n float fogAtten = cc_fogAdd.z;\n float _FogTop = cc_fogAdd.x;\n float _FogRange = cc_fogAdd.y;\n vec3 camWorldProj = cc_cameraPos.xyz;\n camWorldProj.y = 0.;\n vec3 worldPosProj = wPos.xyz;\n worldPosProj.y = 0.;\n float fDeltaD = distance(worldPosProj, camWorldProj) / fogAtten * 2.0;\n float fDeltaY, fDensityIntegral;\n if (cc_cameraPos.y > _FogTop) {\n if (wPos.y < _FogTop) {\n fDeltaY = (_FogTop - wPos.y) / _FogRange * 2.0;\n fDensityIntegral = fDeltaY * fDeltaY * 0.5;\n } else {\n fDeltaY = 0.;\n fDensityIntegral = 0.;\n }\n } else {\n if (wPos.y < _FogTop) {\n float fDeltaA = (_FogTop - cc_cameraPos.y) / _FogRange * 2.;\n float fDeltaB = (_FogTop - wPos.y) / _FogRange * 2.;\n fDeltaY = abs(fDeltaA - fDeltaB);\n fDensityIntegral = abs((fDeltaA * fDeltaA * 0.5) - (fDeltaB * fDeltaB * 0.5));\n } else {\n fDeltaY = abs(_FogTop - cc_cameraPos.y) / _FogRange * 2.;\n fDensityIntegral = abs(fDeltaY * fDeltaY * 0.5);\n }\n }\n float fDensity;\n if (fDeltaY != 0.) {\n fDensity = (sqrt(1.0 + ((fDeltaD / fDeltaY) * (fDeltaD / fDeltaY)))) * fDensityIntegral;\n } else {\n fDensity = 0.;\n }\n float f = exp(-fDensity);\n return f;\n}\nfloat CC_TRANSFER_FOG(vec4 pos) {\n #if CC_USE_FOG == 0\n return LinearFog(pos);\n\t#elif CC_USE_FOG == 1\n return ExpFog(pos);\n #elif CC_USE_FOG == 2\n return ExpSquaredFog(pos);\n #elif CC_USE_FOG == 3\n return LayeredFog(pos);\n #endif\n return 1.;\n}\n#if USE_VERTEX_COLOR\n in lowp vec4 a_color;\n out lowp vec4 v_color;\n#endif\n#if USE_TEXTURE\n out vec2 v_uv;\n layout(std140) uniform TexCoords {\n vec4 tilingOffset;\n };\n#endif\nout float factor_fog;\nvec4 vert () {\n vec4 position;\n position = vec4(a_position, 1.0);\n #if CC_USE_MORPH\n applyMorph(position);\n #endif\n #if CC_USE_SKINNING\n CCSkin(position);\n #endif\n mat4 matWorld;\n #if USE_INSTANCING\n matWorld = mat4(\n vec4(a_matWorld0.xyz, 0.0),\n vec4(a_matWorld1.xyz, 0.0),\n vec4(a_matWorld2.xyz, 0.0),\n vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n );\n #elif USE_BATCHING\n matWorld = cc_matWorlds[int(a_dyn_batch_id)];\n #else\n matWorld = cc_matWorld;\n #endif\n #if USE_TEXTURE\n v_uv = a_texCoord * tilingOffset.xy + tilingOffset.zw;\n #endif\n #if USE_VERTEX_COLOR\n v_color = a_color;\n #endif\n factor_fog = CC_TRANSFER_FOG(matWorld * position);\n return cc_matProj * (cc_matView * matWorld) * position;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision highp float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n #if CC_USE_HDR\n color.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n #endif\n return color;\n}\n#if USE_ALPHA_TEST\n#endif\n#if USE_TEXTURE\n in vec2 v_uv;\n uniform sampler2D mainTexture;\n#endif\nlayout(std140) uniform Constant {\n vec4 mainColor;\n vec4 colorScaleAndCutoff;\n};\n#if USE_VERTEX_COLOR\n in lowp vec4 v_color;\n#endif\nin float factor_fog;\nvec4 frag () {\n vec4 o = mainColor;\n o.rgb *= colorScaleAndCutoff.xyz;\n #if USE_VERTEX_COLOR\n o *= v_color;\n #endif\n #if USE_TEXTURE\n o *= texture(mainTexture, v_uv);\n #endif\n #if USE_ALPHA_TEST\n if (o.ALPHA_TEST_CHANNEL < colorScaleAndCutoff.w) discard;\n #endif\n o = vec4(mix(CC_FORWARD_ADD > 0 ? vec3(0.0) : cc_fogColor.rgb, o.rgb, factor_fog), o.a);\n return CCFragOutput(o);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nhighp float decode32 (highp vec4 rgba) {\n rgba = rgba * 255.0;\n highp float Sign = 1.0 - (step(128.0, (rgba[3]) + 0.5)) * 2.0;\n highp float Exponent = 2.0 * (mod(float(int((rgba[3]) + 0.5)), 128.0)) + (step(128.0, (rgba[2]) + 0.5)) - 127.0;\n highp float Mantissa = (mod(float(int((rgba[2]) + 0.5)), 128.0)) * 65536.0 + rgba[1] * 256.0 + rgba[0] + 8388608.0;\n return Sign * exp2(Exponent - 23.0) * Mantissa;\n}\nstruct StandardVertInput {\n highp vec4 position;\n vec3 normal;\n vec4 tangent;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nin vec4 a_tangent;\n#if CC_USE_MORPH\n in float a_vertexId;\n int getVertexId() {\n return int(a_vertexId);\n }\nlayout(std140) uniform CCMorph {\n vec4 cc_displacementWeights[15];\n vec4 cc_displacementTextureInfo;\n};\nvec2 getPixelLocation(vec2 textureResolution, int pixelIndex) {\n float pixelIndexF = float(pixelIndex);\n float x = mod(pixelIndexF, textureResolution.x);\n float y = floor(pixelIndexF / textureResolution.x);\n return vec2(x, y);\n}\nvec2 getPixelCoordFromLocation(vec2 location, vec2 textureResolution) {\n return (vec2(location.x, location.y) + .5) / textureResolution;\n}\n#if CC_SUPPORT_FLOAT_TEXTURE\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int pixelIndex) {\n ivec2 texSize = textureSize(tex, 0);\n return texelFetch(tex, ivec2(pixelIndex % texSize.x, pixelIndex / texSize.x), 0);\n }\n#else\n vec4 fetchVec3ArrayFromTexture(sampler2D tex, int elementIndex) {\n int pixelIndex = elementIndex * 4;\n vec2 location = getPixelLocation(cc_displacementTextureInfo.xy, pixelIndex);\n vec2 x = getPixelCoordFromLocation(location + vec2(0.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 y = getPixelCoordFromLocation(location + vec2(1.0, 0.0), cc_displacementTextureInfo.xy);\n vec2 z = getPixelCoordFromLocation(location + vec2(2.0, 0.0), cc_displacementTextureInfo.xy);\n return vec4(\n decode32(texture(tex, x)),\n decode32(texture(tex, y)),\n decode32(texture(tex, z)),\n 1.0\n );\n }\n#endif\nfloat getDisplacementWeight(int index) {\n int quot = index / 4;\n int remainder = index - quot * 4;\n if (remainder == 0) {\n return cc_displacementWeights[quot].x;\n } else if (remainder == 1) {\n return cc_displacementWeights[quot].y;\n } else if (remainder == 2) {\n return cc_displacementWeights[quot].z;\n } else {\n return cc_displacementWeights[quot].w;\n }\n}\nvec3 getVec3DisplacementFromTexture(sampler2D tex, int vertexIndex) {\n#if CC_MORPH_PRECOMPUTED\n return fetchVec3ArrayFromTexture(tex, vertexIndex).rgb;\n#else\n vec3 result = vec3(0, 0, 0);\n int nVertices = int(cc_displacementTextureInfo.z);\n for (int iTarget = 0; iTarget < CC_MORPH_TARGET_COUNT; ++iTarget) {\n result += (fetchVec3ArrayFromTexture(tex, nVertices * iTarget + vertexIndex).rgb * getDisplacementWeight(iTarget));\n }\n return result;\n#endif\n}\n#if CC_MORPH_TARGET_HAS_POSITION\n uniform sampler2D cc_PositionDisplacements;\n vec3 getPositionDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_PositionDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n uniform sampler2D cc_NormalDisplacements;\n vec3 getNormalDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_NormalDisplacements, vertexId);\n }\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n uniform sampler2D cc_TangentDisplacements;\n vec3 getTangentDisplacement(int vertexId) {\n return getVec3DisplacementFromTexture(cc_TangentDisplacements, vertexId);\n }\n#endif\nvoid applyMorph (inout StandardVertInput attr) {\n int vertexId = getVertexId();\n#if CC_MORPH_TARGET_HAS_POSITION\n attr.position.xyz = attr.position.xyz + getPositionDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_NORMAL\n attr.normal.xyz = attr.normal.xyz + getNormalDisplacement(vertexId);\n#endif\n#if CC_MORPH_TARGET_HAS_TANGENT\n attr.tangent.xyz = attr.tangent.xyz + getTangentDisplacement(vertexId);\n#endif\n}\nvoid applyMorph (inout vec4 position) {\n#if CC_MORPH_TARGET_HAS_POSITION\n position.xyz = position.xyz + getPositionDisplacement(getVertexId());\n#endif\n}\n#endif\n#if CC_USE_SKINNING\n in vec4 a_joints;\nin vec4 a_weights;\n#if CC_USE_BAKED_ANIMATION\n #if USE_INSTANCING\n in highp vec4 a_jointAnimInfo;\n #endif\n layout(std140) uniform CCSkinningTexture {\n highp vec4 cc_jointTextureInfo;\n };\n layout(std140) uniform CCSkinningAnimation {\n highp vec4 cc_jointAnimInfo;\n };\n uniform highp sampler2D cc_jointTexture;\n #else\n layout(std140) uniform CCSkinning {\n highp vec4 cc_joints[30 * 3];\n };\n#endif\n#if CC_USE_BAKED_ANIMATION\n #if CC_SUPPORT_FLOAT_TEXTURE\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 3.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 3.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = texture(cc_jointTexture, vec2((x + 0.5) * invSize, y));\n vec4 v2 = texture(cc_jointTexture, vec2((x + 1.5) * invSize, y));\n vec4 v3 = texture(cc_jointTexture, vec2((x + 2.5) * invSize, y));\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #else\n mat4 getJointMatrix (float i) {\n #if USE_INSTANCING\n highp float j = 12.0 * (a_jointAnimInfo.x * a_jointAnimInfo.y + i) + a_jointAnimInfo.z;\n #else\n highp float j = 12.0 * (cc_jointAnimInfo.x * cc_jointTextureInfo.y + i) + cc_jointTextureInfo.z;\n #endif\n highp float invSize = cc_jointTextureInfo.w;\n highp float y = floor(j * invSize);\n highp float x = j - y * cc_jointTextureInfo.x;\n y = (y + 0.5) * invSize;\n vec4 v1 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 0.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 1.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 2.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 3.5) * invSize, y)))\n );\n vec4 v2 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 4.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 5.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 6.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 7.5) * invSize, y)))\n );\n vec4 v3 = vec4(\n decode32(texture(cc_jointTexture, vec2((x + 8.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 9.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 10.5) * invSize, y))),\n decode32(texture(cc_jointTexture, vec2((x + 11.5) * invSize, y)))\n );\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n #endif\n#else\n mat4 getJointMatrix (float i) {\n int idx = int(i);\n vec4 v1 = cc_joints[idx * 3];\n vec4 v2 = cc_joints[idx * 3 + 1];\n vec4 v3 = cc_joints[idx * 3 + 2];\n return mat4(vec4(v1.xyz, 0.0), vec4(v2.xyz, 0.0), vec4(v3.xyz, 0.0), vec4(v1.w, v2.w, v3.w, 1.0));\n }\n#endif\nmat4 skinMatrix () {\n vec4 joints = vec4(a_joints);\n return getJointMatrix(joints.x) * a_weights.x\n + getJointMatrix(joints.y) * a_weights.y\n + getJointMatrix(joints.z) * a_weights.z\n + getJointMatrix(joints.w) * a_weights.w;\n}\nvoid CCSkin (inout vec4 position) {\n mat4 m = skinMatrix();\n position = m * position;\n}\nvoid CCSkin (inout StandardVertInput attr) {\n mat4 m = skinMatrix();\n attr.position = m * attr.position;\n attr.normal = (m * vec4(attr.normal, 0.0)).xyz;\n attr.tangent.xyz = (m * vec4(attr.tangent.xyz, 0.0)).xyz;\n}\n#endif\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\n#if USE_INSTANCING\n in vec4 a_matWorld0;\n in vec4 a_matWorld1;\n in vec4 a_matWorld2;\n #if USE_LIGHTMAP\n in vec4 a_lightingMapUVParam;\n #endif\n#elif USE_BATCHING\n in float a_dyn_batch_id;\n layout(std140) uniform CCLocalBatched {\n highp mat4 cc_matWorlds[10];\n };\n#else\nlayout(std140) uniform CCLocal {\n highp mat4 cc_matWorld;\n highp mat4 cc_matWorldIT;\n highp vec4 cc_lightingMapUVParam;\n};\n#endif\nlayout(std140) uniform CCShadow {\n highp mat4 cc_matLightPlaneProj;\n highp mat4 cc_matLightViewProj;\n lowp vec4 cc_shadowColor;\n lowp vec4 cc_shadowInfo;\n};\nvec4 vert () {\n vec4 position;\n position = vec4(a_position, 1.0);\n #if CC_USE_MORPH\n applyMorph(position);\n #endif\n #if CC_USE_SKINNING\n CCSkin(position);\n #endif\n mat4 matWorld;\n #if USE_INSTANCING\n matWorld = mat4(\n vec4(a_matWorld0.xyz, 0.0),\n vec4(a_matWorld1.xyz, 0.0),\n vec4(a_matWorld2.xyz, 0.0),\n vec4(a_matWorld0.w, a_matWorld1.w, a_matWorld2.w, 1.0)\n );\n #elif USE_BATCHING\n matWorld = cc_matWorlds[int(a_dyn_batch_id)];\n #else\n matWorld = cc_matWorld;\n #endif\n position = cc_matProj * (cc_matView * cc_matLightPlaneProj * matWorld) * position;\n position.z -= 0.0001;\n return position;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision mediump float;\nlayout(std140) uniform CCShadow {\n highp mat4 cc_matLightPlaneProj;\n highp mat4 cc_matLightViewProj;\n lowp vec4 cc_shadowColor;\n lowp vec4 cc_shadowInfo;\n};\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n #if CC_USE_HDR\n color.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n #endif\n return color;\n}\nvec4 frag () {\n return CCFragOutput(cc_shadowColor);\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}],[{vert:"\nprecision highp float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nstruct StandardVertInput {\n highp vec4 position;\n vec3 normal;\n vec4 tangent;\n};\nin vec3 a_position;\nin vec3 a_normal;\nin vec2 a_texCoord;\nin vec4 a_tangent;\nout mediump vec4 viewDir;\nvec4 vert () {\n viewDir = vec4(a_position, 1.0);\n mat4 matViewRotOnly = mat4(mat3(cc_matView));\n mat4 matProj = cc_matProj;\n if (matProj[3].w > 0.0) {\n vec2 scale = vec2(48.0, 24.0);\n matProj[0].xy *= scale;\n matProj[1].xy *= scale;\n matProj[2].zw = vec2(-1.0);\n matProj[3].zw = vec2(0.0);\n }\n vec4 pos = matProj * matViewRotOnly * viewDir;\n pos.z = 0.99999 * pos.w;\n return pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nuniform samplerCube cc_environment;\nvec3 unpackRGBE (vec4 rgbe) {\n return rgbe.rgb * pow(2.0, rgbe.a * 255.0 - 128.0);\n}\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec3 ACESToneMap (vec3 color) {\n color = min(color, vec3(8.0));\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nvec4 CCFragOutput (vec4 color) {\n #if !CC_USE_HDR\n color.rgb = sqrt(ACESToneMap(color.rgb));\n #endif\n return color;\n}\nin mediump vec4 viewDir;\nvec4 frag () {\n #if USE_RGBE_CUBEMAP\n vec3 c = unpackRGBE(texture(cc_environment, viewDir.xyz));\n #else\n vec3 c = SRGBToLinear(texture(cc_environment, viewDir.xyz).rgb);\n #endif\n return CCFragOutput(vec4(c * cc_ambientSky.w, 1.0));\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}],[{vert:"\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nin vec3 a_position;\nin vec4 a_color;\nout vec2 v_uv;\nlayout(std140) uniform Constants {\n vec4 offset;\n};\nlayout(std140) uniform PerFrameInfo {\n vec4 digits[8 * 10 / 4];\n};\nfloat getComponent(vec4 v, float i) {\n if (i < 1.0) { return v.x; }\n else if (i < 2.0) { return v.y; }\n else if (i < 3.0) { return v.z; }\n else { return v.w; }\n}\nvec4 vert () {\n vec4 position = cc_matViewProj * vec4(a_position, 1.0);\n position.xy += offset.xy;\n v_uv = a_color.xy;\n if (a_color.z >= 0.0) {\n float n = getComponent(digits[int(a_color.z)], a_color.w);\n v_uv += vec2(offset.z * n, 0.0);\n }\n return position;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision mediump float;\nlayout(std140) uniform CCGlobal {\n highp vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_nativeSize;\n};\nlayout(std140) uniform CCCamera {\n highp mat4 cc_matView;\n highp mat4 cc_matViewInv;\n highp mat4 cc_matProj;\n highp mat4 cc_matProjInv;\n highp mat4 cc_matViewProj;\n highp mat4 cc_matViewProjInv;\n highp vec4 cc_cameraPos;\n mediump vec4 cc_screenScale;\n mediump vec4 cc_exposure;\n mediump vec4 cc_mainLitDir;\n mediump vec4 cc_mainLitColor;\n mediump vec4 cc_ambientSky;\n mediump vec4 cc_ambientGround;\n mediump vec4 cc_fogColor;\n mediump vec4 cc_fogBase;\n mediump vec4 cc_fogAdd;\n};\nvec3 SRGBToLinear (vec3 gamma) {\n return gamma * gamma;\n}\nvec4 CCFragOutput (vec4 color) {\n #if CC_USE_HDR\n color.rgb = mix(color.rgb, SRGBToLinear(color.rgb) * cc_exposure.w, vec3(cc_exposure.z));\n #endif\n return color;\n}\nin vec2 v_uv;\nuniform sampler2D mainTexture;\nvec4 frag () {\n return CCFragOutput(texture(mainTexture, v_uv));\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}],[{vert:"\nprecision mediump float;\nin vec2 a_position;\nin vec2 a_texCoord;\nout vec2 v_uv;\nvec4 vert () {\n vec4 pos = vec4(a_position, 0, 1);\n v_uv = a_texCoord;\n return pos;\n}\nvoid main() { gl_Position = vert(); }",frag:"\nprecision mediump float;\nin vec2 v_uv;\nuniform sampler2D mainTexture;\nlayout(std140) uniform splashFrag {\n float u_precent;\n};\nvec4 frag () {\n vec4 color = texture(mainTexture, v_uv);\n float precent = clamp(u_precent, 0.0, 1.0);\n color.xyz *= precent;\n return color;\n}\nlayout(location = 0) out vec4 cc_FragColor;\nvoid main() { cc_FragColor = frag(); }"}]]},qd=function(){function e(){this._device=null,this._resources={}}var t=e.prototype;return t.initBuiltinRes=function(e){var t=this;this._device=e;var n=this._resources,r=document.createElement("canvas"),a=r.getContext("2d"),s=new G_(r),o=r.width=r.height=2;a.fillStyle="#000",a.fillRect(0,0,o,o);var c=new md;c._uuid="black-texture",c.image=s,n[c._uuid]=c,a.fillStyle="rgba(0,0,0,0)",a.fillRect(0,0,o,o);for(var l=new Uint8Array(16),u=0;u>2,s=this._blocks[i],o=e.getOffsetFromHandle(t),c=0;c>2)*a.count,l=0;l+o.length<=c;l+=o.length)n.set(o,i+l);i+=c}this._rootBufferDirty=!0},t.resetTextures=function(){for(var e=0;e15e3&&(t=15e3);var n=t*t,i=(.860117757+.000154118254*t+1.28641212e-7*n)/(1+.000842420235*t+7.08145163e-7*n),r=(.317398726+422806245e-13*t+4.20481691e-8*n)/(1-289741816e-13*t+1.61456053e-7*n),a=2*i-8*r+4,s=3*i/a,o=2*r/a,c=1/o*s,l=1/o*(1-s-o);e.x=3.2404542*c-1.5371385+-.4985314*l,e.y=-.969266*c+1.8760108+.041556*l,e.z=.0556434*c-.2040259+1.0572252*l}oe(tp,"VisibilityFlags",[{name:"GENERAL"}]),se(tp,"VisibilityFlags",[{name:"ALWALS",newName:"ALWALS",target:Ll.Enum,targetName:"ALWALS"},{name:"PROFILER",newName:"PROFILER",target:Ll.Enum,targetName:"PROFILER"},{name:"GIZMOS",newName:"GIZMOS",target:Ll.Enum,targetName:"GIZMOS"},{name:"EDITOR",newName:"EDITOR",target:Ll.Enum,targetName:"EDITOR"},{name:"UI",newName:"UI",target:Ll.Enum,targetName:"UI_3D"},{name:"UI2D",newName:"UI2D",target:Ll.Enum,targetName:"UI_2D"}]),i.VisibilityFlags=tp,se(Jd.prototype,"Pass.prototype",[{name:"getBindingTypeFromHandle",newName:"getDescriptorTypeFromHandle"}]),oe(Yu.prototype,"Camera.prototype",[{name:"getSplitFrustum"}]),function(e){e[e.DIRECTIONAL=0]="DIRECTIONAL",e[e.SPHERE=1]="SPHERE",e[e.SPOT=2]="SPOT",e[e.UNKNOWN=3]="UNKNOWN"}(ep||(ep={}));var ip=function(e){return 4*Math.PI*Math.PI*e*e},rp=function(){function e(){this._baked=!1,this._color=new bn(1,1,1),this._colorTemp=6550,this._colorTempRGB=new bn(1,1,1),this._scene=null,this._node=null,this._name=null,this._handle=0}var t=e.prototype;return t.initialize=function(){this._handle=jr.alloc(),jr.setVec3(this._handle,kr.COLOR,this._color),jr.setVec3(this._handle,kr.COLOR_TEMPERATURE_RGB,this._colorTempRGB),jr.set(this._handle,kr.TYPE,ep.UNKNOWN)},t.attachToScene=function(e){this._scene=e},t.detachFromScene=function(){this._scene=null},t.destroy=function(){this._name=null,this._node=null,this._handle&&(jr.free(this._handle),this._handle=0)},t.update=function(){},j(e,[{key:"baked",get:function(){return this._baked},set:function(e){this._baked=e}},{key:"color",set:function(e){this._color.set(e),jr.setVec3(this._handle,kr.COLOR,e)},get:function(){return this._color}},{key:"useColorTemperature",set:function(e){jr.set(this._handle,kr.USE_COLOR_TEMPERATURE,e?1:0)},get:function(){return 1===jr.get(this._handle,kr.USE_COLOR_TEMPERATURE)}},{key:"colorTemperature",set:function(e){this._colorTemp=e,np(this._colorTempRGB,this._colorTemp),jr.setVec3(this._handle,kr.COLOR_TEMPERATURE_RGB,this._colorTempRGB)},get:function(){return this._colorTemp}},{key:"colorTemperatureRGB",get:function(){return this._colorTempRGB}},{key:"node",set:function(e){this._node=e,this._node&&(this._node.hasChangedFlags|=Uu.ROTATION,jr.set(this._handle,kr.NODE,this._node.handle))},get:function(){return this._node}},{key:"type",get:function(){return jr.get(this._handle,kr.TYPE)}},{key:"name",get:function(){return this._name},set:function(e){this._name=e}},{key:"scene",get:function(){return this._scene}},{key:"handle",get:function(){return this._handle}}]),e}(),ap=new bn(0,0,-1),sp=new bn,op=function(e){function t(){var t;return(t=e.call(this)||this)._dir=new bn(1,-1,-1),t._shadowRange=1e3,t._shadowIntensity=0,t._shadowFadeDistance=0,t._shadowDistance=0,t._fadeStart=.8,t._splits=new Zn(1,0,0,0),t._biasAutoAdjust=1,t}X(t,e),j(t,[{key:"shadowRange",set:function(e){this._shadowRange=e},get:function(){return this._shadowRange}},{key:"shadowIntensitywRange",set:function(e){this._shadowIntensity=e}},{key:"shadowIntensity",get:function(){return this._shadowIntensity}},{key:"shadowFadeDistance",set:function(e){this._shadowFadeDistance=e},get:function(){return this._shadowFadeDistance}},{key:"shadowDistance",set:function(e){this._shadowDistance=e},get:function(){return this._shadowDistance}},{key:"fadeStart",set:function(e){this._fadeStart=e},get:function(){return this._fadeStart}},{key:"splits",set:function(e){this._splits=e},get:function(){return this._splits}},{key:"biasAutoAdjust",set:function(e){this._biasAutoAdjust=e},get:function(){return this._biasAutoAdjust}},{key:"direction",set:function(e){bn.normalize(this._dir,e),jr.setVec3(this._handle,kr.DIRECTION,this._dir)},get:function(){return this._dir}},{key:"illuminance",set:function(e){jr.set(this._handle,kr.ILLUMINANCE,e)},get:function(){return jr.get(this._handle,kr.ILLUMINANCE)}}]);var n=t.prototype;return n.initialize=function(){e.prototype.initialize.call(this),jr.set(this._handle,kr.ILLUMINANCE,ha.SUN_ILLUM),jr.setVec3(this._handle,kr.DIRECTION,this._dir),jr.set(this._handle,kr.TYPE,ep.DIRECTIONAL)},n.update=function(){this._node&&this._node.hasChangedFlags&&(this.direction=bn.transformQuat(sp,ap,this._node.worldRotation))},t}(rp),cp=new Po(null),lp=function(){function e(){this._device=null,this._passes=null,this._subMesh=null,this._patches=null,this._handle=0,this._priority=Dl.DEFAULT,this._inputAssembler=null,this._descriptorSet=null}var t=e.prototype;return t.initialize=function(e,t,n){void 0===n&&(n=null),this._device=i.director.root.device,this._subMesh=e,this._patches=n,this._passes=t,this._handle=ir.alloc(),this._flushPassInfo(),t[0].batchingScheme===Wd.VB_MERGING&&this._subMesh.genFlatBuffers(),cp.layout=t[0].localSetLayout;var r=Ui.alloc(this._device,cp),a=Gi.alloc(this._device,e.iaInfo);ir.set(this._handle,Ji.PRIORITY,Dl.DEFAULT),ir.set(this._handle,Ji.INPUT_ASSEMBLER,a),ir.set(this._handle,Ji.DESCRIPTOR_SET,r),ir.set(this._handle,Ji.SUB_MESH,e.handle),this._inputAssembler=Gi.get(a),this._descriptorSet=Ui.get(r)},t.initPlanarShadowShader=function(){var e=i.director.root.pipeline.shadows.getPlanarShader(this._patches);ir.set(this._handle,Ji.PLANAR_SHADER,e)},t.destroy=function(){Ui.free(ir.get(this._handle,Ji.DESCRIPTOR_SET)),Gi.free(ir.get(this._handle,Ji.INPUT_ASSEMBLER)),ir.free(this._handle),this._descriptorSet=null,this._inputAssembler=null,this._priority=Dl.DEFAULT,this._handle=0,this._patches=null,this._subMesh=null,this._passes=null},t.update=function(){for(var e=0;e=1024)&&l.lightingMap===a){if(l.stride!==i)return;if(l.count>=l.capacity){l.capacity<<=1;var u=l.stride*l.capacity,h=l.data;l.data=new Uint8Array(u),l.data.set(h),l.vb.resize(u)}return l.hShader!==s&&(l.hShader=s),l.hDescriptorSet!==o&&(l.hDescriptorSet=o),l.data.set(t.buffer,l.stride*l.count++),void(this.hasPendingModels=!0)}}for(var _=this._device.createBuffer(new Ps(Ua.VERTEX|Ua.TRANSFER_DST,Ga.HOST|Ga.DEVICE,32*i,i)),f=new Uint8Array(32*i),d=r.vertexBuffers.slice(),p=r.attributes.slice(),m=r.indexBuffer,g=0;g=0}},{key:"receiveShadow",get:function(){return!!sr.get(this._handle,tr.RECEIVE_SHADOW)},set:function(e){sr.set(this._handle,tr.RECEIVE_SHADOW,e?1:0),this.onMacroPatchesStateChanged()}},{key:"castShadow",get:function(){return!!sr.get(this._handle,tr.CAST_SHADOW)},set:function(e){sr.set(this._handle,tr.CAST_SHADOW,e?1:0)}},{key:"handle",get:function(){return this._handle}},{key:"node",get:function(){return this._node},set:function(e){this._node=e,sr.set(this._handle,tr.NODE,e.handle)}},{key:"transform",get:function(){return this._transform},set:function(e){this._transform=e,sr.set(this._handle,tr.TRANSFORM,e.handle)}},{key:"visFlags",get:function(){return sr.get(this._handle,tr.VIS_FLAGS)},set:function(e){sr.set(this._handle,tr.VIS_FLAGS,e)}},{key:"enabled",get:function(){return!!sr.get(this._handle,tr.ENABLED)},set:function(e){sr.set(this._handle,tr.ENABLED,e?1:0)}}]);var t=e.prototype;return t.initialize=function(){if(!this._inited){this._handle=sr.alloc();var e=Vi.alloc(),t=ji.alloc();sr.set(this._handle,tr.INSTANCED_ATTR_ARRAY,t),sr.set(this._handle,tr.SUB_MODEL_ARRAY,e),sr.set(this._handle,tr.VIS_FLAGS,Ll.Enum.NONE),sr.set(this._handle,tr.ENABLED,1),sr.set(this._handle,tr.RECEIVE_SHADOW,1),sr.set(this._handle,tr.CAST_SHADOW,0),this._inited=!0}},t.destroy=function(){for(var e=this._subModels,t=0;t=0){var a=this.instancedAttributes.views;!function(e,t,n,i){t[0]=e.m00,t[1]=e.m01,t[2]=e.m02,t[3]=e.m12,n[0]=e.m04,n[1]=e.m05,n[2]=e.m06,n[3]=e.m13,i[0]=e.m08,i[1]=e.m09,i[2]=e.m10,i[3]=e.m14}(i,a[r],a[r+1],a[r+2])}else this._localBuffer&&(Hn.toArray(this._localData,i,au.MAT_WORLD_OFFSET),Hn.inverseTranspose(fp,i),Hn.toArray(this._localData,fp,au.MAT_WORLD_IT_OFFSET),this._localBuffer.update(this._localData))}},t.createBoundingShape=function(e,t){e&&t&&(this._modelBounds=al.fromPoints(al.create(),e,t),this._worldBounds=al.clone(this._modelBounds),0===this._hWorldBounds&&(this._hWorldBounds=_r.alloc(),sr.set(this._handle,tr.WORLD_BOUNDS,this._hWorldBounds)),_r.setVec3(this._hWorldBounds,or.CENTER,this._worldBounds.center),_r.setVec3(this._hWorldBounds,or.HALF_EXTENSION,this._worldBounds.halfExtents))},t.initSubModel=function(e,t,n){this.initialize();var i=!1;if(null==this._subModels[e]?(this._subModels[e]=dp.alloc(),i=!0):this._subModels[e].destroy(),this._subModels[e].initialize(t,n.passes,this.getMacroPatches(e)),this._subModels[e].initPlanarShadowShader(),this._updateAttributesAndBinding(e),i){var r=sr.get(this._handle,tr.SUB_MODEL_ARRAY);Vi.assign(r,e,this._subModels[e].handle)}},t.setSubModelMesh=function(e,t){this._subModels[e]&&(this._subModels[e].subMesh=t)},t.setSubModelMaterial=function(e,t){this._subModels[e]&&(this._subModels[e].passes=t.passes,this._updateAttributesAndBinding(e))},t.onGlobalPipelineStateChanged=function(){for(var e=this._subModels,t=0;t1?Bp:Dp),r=this._subModels,a=0;a=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 s=this._props[this._passes[t].propertyIndex];if(e in s)return s[e]}return null},n.copy=function(e){this._techIdx=e._techIdx,this._props.length=e._props.length;for(var t=0;t>16,e|=e>>8,e|=e>>4,e|=e>>2,e|=e>>1,++e}function Tm(e,t){return Math.ceil(e/t)*t}!function(e){e[e.OPAQUE=0]="OPAQUE",e[e.TRANSPARENT=1]="TRANSPARENT",e[e.OVERLAY=2]="OVERLAY"}(um||(um={})),function(e){e[e.DEFAULT=1]="DEFAULT",e[e.FORWARD=2]="FORWARD",e[e.SHADOWCAST=4]="SHADOWCAST"}(hm||(hm={}));var Am=function(){function e(e){this._device=void 0,this._format=za.UNKNOWN,this._formatSize=0,this._chunks=[],this._chunkCount=0,this._handles=[],this._region0=new eo,this._region1=new eo,this._region2=new eo,this._roundUpFn=null,this._bufferViewCtor=Uint8Array,this._channels=4,this._alignment=1,this._device=e}var t=e.prototype;return t.initialize=function(e){var t=Ts[e.format];this._format=e.format,this._formatSize=t.size,this._channels=t.count,this._bufferViewCtor=bs(t),this._roundUpFn=e.roundUpFn||null,this._alignment=e.alignment||1,e.inOrderFree&&(this.alloc=this._McDonaldAlloc)},t.destroy=function(){for(var e=0;e=0));++r);if(i>=0){var a=this._chunks[n];a.start+=e;var s={chunkIdx:n,start:i,end:i+e,texture:a.texture};return this._handles.push(s),s}var o=Math.sqrt(e/this._formatSize),c=this._roundUpFn&&this._roundUpFn(o,this._formatSize)||Math.max(1024,Em(o)),l=this._chunks[this.createChunk(c)];l.start+=e;var u={chunkIdx:this._chunkCount-1,start:0,end:e,texture:l.texture};return this._handles.push(u),u},t.free=function(e){for(var t=0;t0&&(this._region0.texOffset.x=s,this._region0.texOffset.y=o,this._region0.texExtent.width=c,this._region0.texExtent.height=1,n.push(new this._bufferViewCtor(t,l*this._formatSize,c*this._channels)),i.push(this._region0),s=0,o+=1,a-=c,l+=c),a>0&&(this._region1.texOffset.x=s,this._region1.texOffset.y=o,a>e.texture.width?(this._region1.texExtent.width=e.texture.width,this._region1.texExtent.height=Math.floor(a/e.texture.width),c=this._region1.texExtent.width*this._region1.texExtent.height):(c=a,this._region1.texExtent.width=c,this._region1.texExtent.height=1),n.push(new this._bufferViewCtor(t,l*this._formatSize,c*this._channels)),i.push(this._region1),s=0,o+=this._region1.texExtent.height,a-=c,l+=c),a>0&&(this._region2.texOffset.x=s,this._region2.texOffset.y=o,this._region2.texExtent.width=a,this._region2.texExtent.height=1,n.push(new this._bufferViewCtor(t,l*this._formatSize,a*this._channels)),i.push(this._region2)),this._device.copyBuffersToTexture(n,e.texture,i)},t._findAvailableSpace=function(e,t){var n=this._chunks[t],i=!1,r=n.start;if(r+e<=n.size)i=!0;else{r=0;for(var a=this._handles.filter((function(e){return e.chunkIdx===t})).sort((function(e,t){return e.start-t.start})),s=0;sn.end?r+e<=n.size?i=!0:e<=n.end&&(n.start=r=0,i=!0):r===n.end&&(n.start=r=0,n.end=n.size,e<=n.end&&(i=!0)),i){n.start+=e;var a={chunkIdx:t,start:r,end:r+e,texture:n.texture};return this._handles.push(a),a}}var s=Math.sqrt(e/this._formatSize),o=this._roundUpFn&&this._roundUpFn(s,this._formatSize)||Math.max(1024,Em(s)),c=this._chunks[this.createChunk(o)];c.start+=e;var l={chunkIdx:this._chunkCount,start:0,end:e,texture:c.texture};return this._handles.push(l),l},e}(),xm=function(e){if(void 0===ee[e]){var t=1<<$;ee[e]=t,$+=1}},Cm=Object.freeze({__proto__:null,addStage:xm,scene:Sm,createIA:function(e,t){if(!t.positions)return console.error("The data must have positions field"),null;for(var n=[],i=t.positions.length/3,r=0;r>>20},getBindingFromHandle:Rd,getOffsetFromHandle:bd,customizeType:wd,type2reader:Id,type2writer:Od,getDefaultFromType:Md,overrideMacros:Nd,get BatchingSchemes(){return Wd},Pass:Jd,getDeviceShaderVersion:Gd,programLib:kd,get SamplerInfoIndex(){return U_},defaultSamplerHash:H_,genSamplerHash:j_,samplerLib:af,nearestPOT:Em,TextureBufferPool:Am,MaterialInstance:sm,PassInstance:am,ObjectPool:Ni,freeHandleArray:Li,get PoolType(){return Pi},NULL_HANDLE:0,ShaderPool:zi,DSPool:Ui,IAPool:Gi,PipelineLayoutPool:ki,FramebufferPool:Hi,SubModelArrayPool:Vi,ModelArrayPool:Wi,AttributeArrayPool:ji,FlatBufferArrayPool:qi,LightArrayPool:Xi,BlendTargetArrayPool:Yi,UIBatchArrayPool:Ki,RawBufferPool:Zi,RawObjectPool:Qi,get PassView(){return Fi},PassPool:er,get SubModelView(){return Ji},SubModelPool:ir,get ModelView(){return tr},ModelPool:sr,get BatchView2D(){return rr},BatchPool2D:lr,get AABBView(){return or},AABBPool:_r,get SceneView(){return ur},ScenePool:pr,get CameraView(){return fr},CameraPool:vr,get NodeView(){return mr},NodePool:Er,get RootView(){return Sr},RootPool:xr,get RenderWindowView(){return Tr},RenderWindowPool:br,get FrustumView(){return Cr},FrustumPool:Or,get AmbientView(){return wr},AmbientPool:Nr,get SkyboxView(){return Mr},SkyboxPool:Lr,get FogView(){return Dr},FogPool:Ur,get ShadowsView(){return zr},ShadowsPool:Hr,get LightView(){return kr},LightPool:jr,get SphereView(){return Vr},SpherePool:Yr,get FlatBufferView(){return Xr},FlatBufferPool:Qr,get SubMeshView(){return Kr},SubMeshPool:ea,get RasterizerStateView(){return Jr},RasterizerStatePool:ia,get DepthStencilStateView(){return ta},DepthStencilStatePool:sa,get BlendTargetView(){return ra},BlendTargetPool:ca,get BlendStateView(){return oa},BlendStatePool:ua});function Rm(e){return e*e}function bm(e){return e*(2-e)}function wm(e){return e*e*e}function Im(e){return--e*e*e+1}function Om(e){return e*e*e*e}function Pm(e){return 1- --e*e*e*e}function Mm(e){return e*e*e*e*e}function Nm(e){return--e*e*e*e*e+1}function Dm(e){return 1-Math.cos(e*Math.PI/2)}function Bm(e){return Math.sin(e*Math.PI/2)}function Lm(e){return 0===e?0:Math.pow(1024,e-1)}function Fm(e){return 1===e?1:1-Math.pow(2,-10*e)}function zm(e){return 1-Math.sqrt(1-e*e)}function Um(e){return Math.sqrt(1- --e*e)}function Gm(e){var t,n=.1;return 0===e?0:1===e?1:(!n||n<1?(n=1,t=.1):t=.4*Math.asin(1/n)/(2*Math.PI),-n*Math.pow(2,10*(e-=1))*Math.sin(2*(e-t)*Math.PI/.4))}function km(e){var t,n=.1;return 0===e?0:1===e?1:(!n||n<1?(n=1,t=.1):t=.4*Math.asin(1/n)/(2*Math.PI),n*Math.pow(2,-10*e)*Math.sin(2*(e-t)*Math.PI/.4)+1)}function Hm(e){var t=1.70158;return e*e*((t+1)*e-t)}function Vm(e){var t=1.70158;return--e*e*((t+1)*e+t)+1}function Wm(e){return 1-jm(1-e)}function jm(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375}e("renderer",Cm);var qm=ng(Rm,bm),Xm=ng(wm,Im),Ym=ng(Om,Pm),Km=ng(Mm,Nm),Zm=ng(Dm,Bm),Qm=ng(Lm,Fm),Jm=ng(zm,Um),$m=ng(Gm,km),eg=ng(Hm,Vm),tg=ng(Wm,jm);function ng(e,t){return function(n){return n<.5?t(2*n)/2:e(2*n-1)/2+.5}}var ig,rg=Object.freeze({__proto__:null,constant:function(){return 0},linear:function(e){return e},quadIn:Rm,quadOut:bm,quadInOut:function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)},cubicIn:wm,cubicOut:Im,cubicInOut:function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)},quartIn:Om,quartOut:Pm,quartInOut:function(e){return(e*=2)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2)},quintIn:Mm,quintOut:Nm,quintInOut:function(e){return(e*=2)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2)},sineIn:Dm,sineOut:Bm,sineInOut:function(e){return.5*(1-Math.cos(Math.PI*e))},expoIn:Lm,expoOut:Fm,expoInOut:function(e){return 0===e?0:1===e?1:(e*=2)<1?.5*Math.pow(1024,e-1):.5*(2-Math.pow(2,-10*(e-1)))},circIn:zm,circOut:Um,circInOut:function(e){return(e*=2)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1)},elasticIn:Gm,elasticOut:km,elasticInOut:function(e){var t,n=.1;return 0===e?0:1===e?1:(!n||n<1?(n=1,t=.1):t=.4*Math.asin(1/n)/(2*Math.PI),(e*=2)<1?n*Math.pow(2,10*(e-=1))*Math.sin(2*(e-t)*Math.PI/.4)*-.5:n*Math.pow(2,-10*(e-=1))*Math.sin(2*(e-t)*Math.PI/.4)*.5+1)},backIn:Hm,backOut:Vm,backInOut:function(e){var t=2.5949095;return(e*=2)<1?e*e*((t+1)*e-t)*.5:.5*((e-=2)*e*((t+1)*e+t)+2)},bounceIn:Wm,bounceOut:jm,bounceInOut:function(e){return e<.5?.5*Wm(2*e):.5*jm(2*e-1)+.5},smooth:function(e){return e<=0?0:e>=1?1:e*e*(3-2*e)},fade:function(e){return e<=0?0:e>=1?1:e*e*e*(e*(6*e-15)+10)},quadOutIn:qm,cubicOutIn:Xm,quartOutIn:Ym,quintOutIn:Km,sineOutIn:Zm,expoOutIn:Qm,circOutIn:Jm,elasticOutIn:$m,backOutIn:eg,bounceOutIn:tg});e("easing",rg),function(e){e[e.NONE=0]="NONE",e[e.LAN=1]="LAN",e[e.WWAN=2]="WWAN"}(ig||(ig={}));var ag,sg,og,cg,lg,ug,hg,_g,fg,dg,pg,mg=e("sys",{NetworkType:ig,LANGUAGE_ENGLISH:"en",LANGUAGE_CHINESE:"zh",LANGUAGE_FRENCH:"fr",LANGUAGE_ITALIAN:"it",LANGUAGE_GERMAN:"de",LANGUAGE_SPANISH:"es",LANGUAGE_DUTCH:"du",LANGUAGE_RUSSIAN:"ru",LANGUAGE_KOREAN:"ko",LANGUAGE_JAPANESE:"ja",LANGUAGE_HUNGARIAN:"hu",LANGUAGE_PORTUGUESE:"pt",LANGUAGE_ARABIC:"ar",LANGUAGE_NORWEGIAN:"no",LANGUAGE_POLISH:"pl",LANGUAGE_TURKISH:"tr",LANGUAGE_UKRAINIAN:"uk",LANGUAGE_ROMANIAN:"ro",LANGUAGE_BULGARIAN:"bg",LANGUAGE_UNKNOWN:"unknown",OS_IOS:"iOS",OS_ANDROID:"Android",OS_WINDOWS:"Windows",OS_LINUX:"Linux",OS_OSX:"OS X",OS_UNKNOWN:"Unknown",UNKNOWN:-1,WIN32:0,LINUX:1,MACOS:2,ANDROID:3,IPHONE:4,IPAD:5,BLACKBERRY:6,NACL:7,EMSCRIPTEN:8,TIZEN:9,WINRT:10,WP8:11,MOBILE_BROWSER:100,DESKTOP_BROWSER:101,EDITOR_PAGE:102,EDITOR_CORE:103,WECHAT_GAME:104,QQ_PLAY:105,FB_PLAYABLE_ADS:106,BAIDU_MINI_GAME:107,VIVO_MINI_GAME:108,OPPO_MINI_GAME:109,HUAWEI_QUICK_GAME:110,XIAOMI_QUICK_GAME:111,COCOSPLAY:112,ALIPAY_MINI_GAME:113,QTT_MINI_GAME:116,BYTEDANCE_MINI_GAME:117,LINKSURE_MINI_GAME:119,BROWSER_TYPE_WECHAT:"wechat",BROWSER_TYPE_ANDROID:"androidbrowser",BROWSER_TYPE_IE:"ie",BROWSER_TYPE_EDGE:"edge",BROWSER_TYPE_QQ:"qqbrowser",BROWSER_TYPE_MOBILE_QQ:"mqqbrowser",BROWSER_TYPE_UC:"ucbrowser",BROWSER_TYPE_UCBS:"ucbs",BROWSER_TYPE_360:"360browser",BROWSER_TYPE_BAIDU_APP:"baiduboxapp",BROWSER_TYPE_BAIDU:"baidubrowser",BROWSER_TYPE_MAXTHON:"maxthon",BROWSER_TYPE_OPERA:"opera",BROWSER_TYPE_OUPENG:"oupeng",BROWSER_TYPE_MIUI:"miuibrowser",BROWSER_TYPE_FIREFOX:"firefox",BROWSER_TYPE_SAFARI:"safari",BROWSER_TYPE_CHROME:"chrome",BROWSER_TYPE_LIEBAO:"liebao",BROWSER_TYPE_QZONE:"qzone",BROWSER_TYPE_SOUGOU:"sogou",BROWSER_TYPE_HUAWEI:"huawei",BROWSER_TYPE_UNKNOWN:"unknown",isNative:!1,isBrowser:"object"==typeof window&&"object"==typeof document,isMobile:!1,isLittleEndian:(ag=new ArrayBuffer(2),new DataView(ag).setInt16(0,256,!0),256===new Int16Array(ag)[0]),platform:-1,language:"unknown",languageCode:"unknown",os:"Unknown",osVersion:"",osMainVersion:0,browserType:"unknown",browserVersion:"",windowPixelResolution:null,capabilities:null,localStorage:null,__audioSupport:null,__videoSupport:null,getNetworkType:function(){return ig.LAN},getBatteryLevel:function(){return 1},garbageCollect:function(){},isObjectValid:function(e){return null!=e},dump:function(){var e="";e+="isMobile : "+this.isMobile+"\r\n",e+="language : "+this.language+"\r\n",e+="browserType : "+this.browserType+"\r\n",e+="browserVersion : "+this.browserVersion+"\r\n",e+="capabilities : "+JSON.stringify(this.capabilities)+"\r\n",e+="os : "+this.os+"\r\n",e+="osVersion : "+this.osVersion+"\r\n",e+="platform : "+this.platform+"\r\n",h(e+="Using "+(i.game.renderType===i.game.RENDER_TYPE_WEBGL?"WEBGL":"CANVAS")+" renderer.\r\n")},openURL:function(e){window.open(e)},now:function(){return Date.now?Date.now():+new Date},restartVM:function(){},getSafeAreaRect:function(){var e=i.view.getVisibleSize();return i.rect(0,0,e.width,e.height)},__init:function(){var e=window,t=e.navigator,n=document,i=n.documentElement,r=t.userAgent.toLowerCase();mg.isMobile=/mobile|android|iphone|ipad/.test(r),mg.platform=mg.isMobile?mg.MOBILE_BROWSER:mg.DESKTOP_BROWSER;var a=t.language;mg.languageCode=a.toLowerCase(),a=(a=a||t.browserLanguage)?a.split("-")[0]:mg.LANGUAGE_ENGLISH,mg.language=a;var s=!1,o=!1,c="",l=0,u=/android\s*(\d+(?:\.\d+)*)/i.exec(r)||/android\s*(\d+(?:\.\d+)*)/i.exec(t.platform);u&&(s=!0,c=u[1]||"",l=parseInt(c)||0),(u=/(iPad|iPhone|iPod).*OS ((\d+_?){2,3})/i.exec(r))?(o=!0,c=u[2]||"",l=parseInt(c)||0):(/(iPhone|iPad|iPod)/.exec(t.platform)||"MacIntel"===t.platform&&t.maxTouchPoints&&t.maxTouchPoints>1)&&(o=!0,c="",l=0);var h=mg.OS_UNKNOWN;-1!==t.appVersion.indexOf("Win")?h=mg.OS_WINDOWS:o?h=mg.OS_IOS:-1!==t.appVersion.indexOf("Mac")?h=mg.OS_OSX:-1!==t.appVersion.indexOf("X11")&&-1===t.appVersion.indexOf("Linux")?h=mg.OS_UNIX:s?h=mg.OS_ANDROID:-1===t.appVersion.indexOf("Linux")&&-1===r.indexOf("ubuntu")||(h=mg.OS_LINUX),mg.os=h,mg.osVersion=c,mg.osMainVersion=l,mg.browserType=mg.BROWSER_TYPE_UNKNOWN,function(){var e=/mqqbrowser|micromessenger|qqbrowser|sogou|qzone|liebao|maxthon|ucbs|360 aphone|360browser|baiduboxapp|baidubrowser|maxthon|mxbrowser|miuibrowser/i.exec(r)||/qq|qqbrowser|ucbrowser|ubrowser|edge|HuaweiBrowser/i.exec(r)||/chrome|safari|firefox|trident|opera|opr\/|oupeng/i.exec(r),t=e?e[0].toLowerCase():mg.BROWSER_TYPE_UNKNOWN;("safari"===t&&s||"qq"===t&&/android.*applewebkit/i.test(r))&&(t=mg.BROWSER_TYPE_ANDROID);var n={micromessenger:mg.BROWSER_TYPE_WECHAT,trident:mg.BROWSER_TYPE_IE,edge:mg.BROWSER_TYPE_EDGE,"360 aphone":mg.BROWSER_TYPE_360,mxbrowser:mg.BROWSER_TYPE_MAXTHON,"opr/":mg.BROWSER_TYPE_OPERA,ubrowser:mg.BROWSER_TYPE_UC,huaweibrowser:mg.BROWSER_TYPE_HUAWEI};mg.browserType=n[t]||t}(),mg.browserVersion="",function(){var e=/(mqqbrowser|micromessenger|qqbrowser|sogou|qzone|liebao|maxthon|uc|ucbs|360 aphone|360|baiduboxapp|baidu|maxthon|mxbrowser|miui(?:.hybrid)?)(mobile)?(browser)?\/?([\d.]+)/i.exec(r);e||(e=/(qq|chrome|safari|firefox|trident|opera|opr\/|oupeng)(mobile)?(browser)?\/?([\d.]+)/i.exec(r)),mg.browserVersion=e?e[4]:""}();var _=window.innerWidth||document.documentElement.clientWidth,f=window.innerHeight||document.documentElement.clientHeight,d=window.devicePixelRatio||1;mg.windowPixelResolution={width:d*_,height:d*f};var p,m=document.createElement("canvas");try{var g=mg.localStorage=e.localStorage;g.setItem("storage",""),g.removeItem("storage"),g=null}catch(e){var v=function(){E(5200)};mg.localStorage={getItem:v,setItem:v,removeItem:v,clear:v}}try{p=m.toDataURL("image/webp").startsWith("data:image/webp")}catch(e){p=!1}var S=!!m.getContext("2d"),T=!1;e.WebGLRenderingContext&&(T=!0);var A,x=mg.capabilities={canvas:S,opengl:T,webp:p,imageBitmap:!1,touches:!1,mouse:!1,keyboard:!1,accelerometer:!1};"undefined"!=typeof createImageBitmap&&"undefined"!=typeof Blob&&(m.width=m.height=2,createImageBitmap(m,{}).then((function(e){x.imageBitmap=!0,e.close&&e.close()})).catch((function(){}))),(void 0!==i.ontouchstart||void 0!==n.ontouchstart||t.msPointerEnabled)&&(x.touches=!0),void 0!==i.onmouseup&&(x.mouse=!0),void 0!==i.onkeyup&&(x.keyboard=!0),(e.DeviceMotionEvent||e.DeviceOrientationEvent)&&(x.accelerometer=!0),A={ONLY_ONE:!1,WEB_AUDIO:!!(window.AudioContext||window.webkitAudioContext||window.mozAudioContext),DELAY_CREATE_CTX:!1},mg.os===mg.OS_IOS&&(A.USE_LOADER_EVENT="loadedmetadata"),mg.browserType===mg.BROWSER_TYPE_FIREFOX&&(A.DELAY_CREATE_CTX=!0,A.USE_LOADER_EVENT="canplay"),mg.os===mg.OS_ANDROID&&mg.browserType===mg.BROWSER_TYPE_UC&&(A.ONE_SOURCE=!0);try{A.WEB_AUDIO&&(A._context=null,Object.defineProperty(A,"context",{get:function(){return this._context?this._context:this._context=new(window.AudioContext||window.webkitAudioContext||window.mozAudioContext)}}))}catch(e){A.WEB_AUDIO=!1,y(5201)}var C,R=[];(C=document.createElement("audio")).canPlayType&&(C.canPlayType('audio/ogg; codecs="vorbis"')&&R.push(".ogg"),C.canPlayType("audio/mpeg")&&R.push(".mp3"),C.canPlayType('audio/wav; codecs="1"')&&R.push(".wav"),C.canPlayType("audio/mp4")&&R.push(".mp4"),C.canPlayType("audio/x-m4a")&&R.push(".m4a")),A.format=R,mg.__audioSupport=A,mg.__videoSupport={format:[]},function(){var e=document.createElement("video");if(e.canPlayType){var t=mg.__videoSupport.format;["mp4","webm"].forEach((function(n){e.canPlayType("video/"+n)&&t.push("."+n)})),mg.__videoSupport.format=t}}(),mg.__isWebIOS14OrIPadOS14Env=(mg.os===mg.OS_IOS||mg.os===mg.MACOS)&&mg.isBrowser&&/(OS 1[4-9])|(Version\/1[4-9])/.test(window.navigator.userAgent)}});"object"==typeof window&&"object"==typeof document&&mg.__init(),i.sys=mg;var gg,vg,yg,Sg,Eg,Tg,Ag,xg,Cg,Rg,bg,wg,Ig,Og=e("RenderStage",(sg=ih("RenderStage"),og=Rh(),cg=Rh(),lg=Rh(),sg((pg=function(){function e(){Q(this,"_name",_g,this),Q(this,"_priority",fg,this),Q(this,"_tag",dg,this)}var t=e.prototype;return t.initialize=function(e){return this._name=e.name,this._priority=e.priority,e.tag&&(this._tag=e.tag),!0},t.activate=function(e,t){this._pipeline=e,this._flow=t},j(e,[{key:"name",get:function(){return this._name}},{key:"priority",get:function(){return this._priority}},{key:"tag",get:function(){return this._tag}}]),e}(),_g=J((hg=pg).prototype,"_name",[og,ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),fg=J(hg.prototype,"_priority",[cg,ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),dg=J(hg.prototype,"_tag",[lg,ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),ug=hg))||ug));i.RenderStage=Og;var Pg,Mg,Ng,Dg,Bg,Lg,Fg,zg,Ug,Gg=e("RenderFlow",(gg=ih("RenderFlow"),vg=Rh(),yg=Rh(),Sg=Rh(),Eg=Rh(),Tg=Dh([Og]),gg((Ig=function(){function e(){Q(this,"_name",Cg,this),Q(this,"_priority",Rg,this),Q(this,"_tag",bg,this),Q(this,"_stages",wg,this)}var t=e.prototype;return t.initialize=function(e){return this._name=e.name,this._priority=e.priority,this._stages=e.stages,e.tag&&(this._tag=e.tag),!0},t.activate=function(e){this._pipeline=e,this._stages.sort((function(e,t){return e.priority-t.priority}));for(var t=0,n=this._stages.length;tm.size&&(m.resize(r),_.vbDatas[d]=new Uint8Array(r),_.vbDatas[d].set(g)),_.vbDatas[d].set(p.buffer,_.vbCount*p.stride)}var v=_.vbIdxData;(a=4*(s+_.vbCount))>_.vbIdx.size&&(_.vbIdx.resize(a),_.vbIdxData=new Float32Array(a/Float32Array.BYTES_PER_ELEMENT),_.vbIdxData.set(v),v=_.vbIdxData);var y=_.vbCount,S=y+s,E=_.mergeCount;if(v[y]!==E||v[S-1]!==E)for(var T=y;Tthis._lightBufferCount&&(this._firstLightBufferView.destroy(),this._lightBufferCount=yn(this._validLights.length),this._lightBuffer.resize(this._lightBufferStride*this._lightBufferCount),this._lightBufferData=new Float32Array(this._lightBufferElementCount*this._lightBufferCount),this._firstLightBufferView.initialize(new Ms(this._lightBuffer,0,ou.SIZE)));for(var i=0,r=0;iiv.length&&iv.push(a)}return iv}(e,n.maxReceived);if(function(e,t){var n=t.scene,i=e.shadows,r=e.shadowObjects;sv.freeArray(r),r.length=0,nv=!1;for(var a=n.models,s=0;s0)for(var o=0;o1)e.push("t="+this._targetExp+";"),t="t";else{if(1!==this._exps.length)return;t=this._targetExp}for(var n=0;n0&&(n="var "+this.globalVariables.join(",")+";");var i=function(e){var t=[];return function e(t,n){for(var i,r=Z(n);!(i=r()).done;){var a=i.value;Array.isArray(a)?e(t,a):t.push(a)}}(t,e),t.join("")}(["return (function(R){",n||[],this.codeArray,"return o;","})"]);this.result=Function("O","F",i)(this.objs,this.funcs);for(var r=0,a=this.objsToClear_iN$t.length;r>3},i=n.storageUnit,r=BE(n.elementType),a=new(LE(i))(e,this._byteOffset,this._unitCount),s=new Array(this._length),o=0;o0){var c=o.pop();if(!c)continue;for(var l=0;l0){var g=p.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},t}(I_),rA.OptimizationPolicy=dA,rA.OptimizationPolicyThreshold=3,tA=J((eA=aA).prototype,"data",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),nA=J(eA.prototype,"optimizationPolicy",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return dA.AUTO}}),iA=J(eA.prototype,"asyncLoadAssets",[ch,gh],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),$T=eA))||$T);st.value(pA,"_utils",fA),i.Prefab=pA,Ne(i,"cc._Prefab","Prefab"),e("PrefabLink",(sA=ih("cc.PrefabLink"),oA=Dh(pA),cA=vh(),sA((_A=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r0){var a=e.children;if(a)for(var s=0;s=0;l--){var u=c[l];if(u===e){i.js.array.removeAt(c,l),u._setRegistered(!1);break}}}},t.removeListeners=function(e,t){if(void 0===t&&(t=!1),i.js.isNumber(e)||e instanceof i._BaseNode)if(void 0!==e._id){var n=this._nodeListenersMap[e._id];if(n){for(var r=i.js.array.copy(n),a=0;a0)for(var a=e.children,s=0,o=a?a.length:0;s=0;n--)(t=e[n])._setRegistered(!1),null!=t._getSceneGraphPriority()&&(this._dissociateNodeAndEventListener(t._getSceneGraphPriority(),t),t._setSceneGraphPriority(null)),0===this._inDispatch&&i.js.array.removeAt(e,n)},t._removeListenersForListenerID=function(e){var t=this._listenersMap[e];if(t){var n=t.getFixedPriorityListeners(),r=t.getSceneGraphPriorityListeners();this._removeAllListenersInVector(r),this._removeAllListenersInVector(n),delete this._priorityDirtyFlagMap[e],this._inDispatch||(t.clear(),delete this._listenersMap[e])}for(var a=this._toAddedListeners,s=a.length-1;s>=0;s--){var o=a[s];o&&o._getListenerID()===e&&i.js.array.removeAt(a,s)}},t._sortEventListeners=function(e){var t=0,n=this._priorityDirtyFlagMap;n[e]&&(t=n[e]),0!==t&&(n[e]=0,1&t&&this._sortListenersOfFixedPriority(e),2&t&&i.director.getScene()&&this._sortListenersOfSceneGraphPriority(e))},t._sortListenersOfSceneGraphPriority=function(e){var t=this._getListeners(e);if(t){var n=t.getSceneGraphPriorityListeners();if(n&&0!==n.length){var i=t.getSceneGraphPriorityListeners();i.forEach((function(e){var t=e._getSceneGraphPriority()._uiProps.uiTransformComp;e._cameraPriority=t.cameraPriority})),i.sort(this._sortEventListenersOfSceneGraphPriorityDes)}}},t._sortEventListenersOfSceneGraphPriorityDes=function(e,t){var n=e._getSceneGraphPriority(),i=t._getSceneGraphPriority();if(!(t&&i&&i._activeInHierarchy&&i._uiProps.uiTransformComp))return-1;if(!(e&&n&&n._activeInHierarchy&&n._uiProps.uiTransformComp))return 1;var r=n,a=i,s=!1;if(e._cameraPriority!==t._cameraPriority)return t._cameraPriority-e._cameraPriority;for(;r.parent._id!==a.parent._id;)r=null===r.parent.parent?(s=!0)&&i:r.parent,a=null===a.parent.parent?(s=!0)&&n:a.parent;if(r._id===a._id){if(r._id===i._id)return-1;if(r._id===n._id)return 1}var o=r.getSiblingIndex(),c=a.getSiblingIndex();return s?o-c:c-o},t._sortListenersOfFixedPriority=function(e){var t=this._listenersMap[e];if(t){var n=t.getFixedPriorityListeners();if(n&&0!==n.length){n.sort(this._sortListenersOfFixedPriorityAsc);for(var i=0,r=n.length;i=0);)++i;t.gt0Index=i}}},t._sortListenersOfFixedPriorityAsc=function(e,t){return e._getFixedPriority()-t._getFixedPriority()},t._onUpdateListeners=function(e){var t=e.getFixedPriorityListeners(),n=e.getSceneGraphPriorityListeners(),r=this._toRemovedListeners;if(n)for(var a=n.length-1;a>=0;a--){var s=n[a];if(!s._isRegistered()){i.js.array.removeAt(n,a);var o=r.indexOf(s);-1!==o&&r.splice(o,1)}}if(t)for(var c=t.length-1;c>=0;c--){var l=t[c];if(!l._isRegistered()){i.js.array.removeAt(t,c);var u=r.indexOf(l);-1!==u&&r.splice(u,1)}}n&&0===n.length&&e.clearSceneGraphListeners(),t&&0===t.length&&e.clearFixedListeners()},t._updateTouchListeners=function(){var e=this._inDispatch;if(R(e>0,3508),!(e>1)){var t;(t=this._listenersMap[MA.TOUCH_ONE_BY_ONE])&&this._onUpdateListeners(t),(t=this._listenersMap[MA.TOUCH_ALL_AT_ONCE])&&this._onUpdateListeners(t),R(1===e,3509);var n=this._toAddedListeners;if(0!==n.length){for(var i=0,r=n.length;i0&&-1!==(a=e._claimedTouches.indexOf(i))){if(r=!0,!ft.ENABLE_MULTI_TOUCH&&BA._currentTouch&&BA._currentTouch!==i)return!1;s===TA.MOVED&&e.onTouchMoved?e.onTouchMoved(i,n):s===TA.ENDED?(e.onTouchEnded&&e.onTouchEnded(i,n),e._isRegistered()&&e._claimedTouches.splice(a,1),(ft.ENABLE_MULTI_TOUCH||BA._currentTouch===i)&&(BA._currentTouch=null),BA._currentTouchListener=null):s===TA.CANCELLED&&(e.onTouchCancelled&&e.onTouchCancelled(i,n),e._isRegistered()&&e._claimedTouches.splice(a,1),(ft.ENABLE_MULTI_TOUCH||BA._currentTouch===i)&&(BA._currentTouch=null),BA._currentTouchListener=null)}return n.isStopped()?(BA._updateTouchListeners(n),!0):!!(r&&e._isRegistered()&&e.swallowTouches)&&(t.needsMutableSet&&t.touches.splice(i,1),!0)},t._dispatchTouchEvent=function(e){this._sortEventListeners(MA.TOUCH_ONE_BY_ONE),this._sortEventListeners(MA.TOUCH_ALL_AT_ONCE);var t=this._getListeners(MA.TOUCH_ONE_BY_ONE),n=this._getListeners(MA.TOUCH_ALL_AT_ONCE);if(null!==t||null!==n){var r=e.getTouches(),a=i.js.array.copy(r),s={event:e,needsMutableSet:t&&n,touches:a,selTouch:null};if(t)for(var o=0;o0&&(this._dispatchEventToListeners(n,this._onTouchesEventCallback,{event:e,touches:a}),e.isStopped())||this._updateTouchListeners(e)}},t._onTouchesEventCallback=function(e,t){if(!e._isRegistered())return!1;var n=t.event,i=t.touches,r=n.getEventCode();return n.currentTarget=e._getSceneGraphPriority(),r===TA.BEGAN&&e.onTouchesBegan?e.onTouchesBegan(i,n):r===TA.MOVED&&e.onTouchesMoved?e.onTouchesMoved(i,n):r===TA.ENDED&&e.onTouchesEnded?e.onTouchesEnded(i,n):r===TA.CANCELLED&&e.onTouchesCancelled&&e.onTouchesCancelled(i,n),!!n.isStopped()&&(BA._updateTouchListeners(n),!0)},t._associateNodeAndEventListener=function(e,t){var n=this._nodeListenersMap[e.uuid];n||(n=[],this._nodeListenersMap[e.uuid]=n),n.push(t)},t._dissociateNodeAndEventListener=function(e,t){var n=this._nodeListenersMap[e.uuid];n&&(i.js.array.remove(n,t),0===n.length&&delete this._nodeListenersMap[e.uuid])},t._dispatchEventToListeners=function(e,t,n){var i=!1,r=e.getFixedPriorityListeners(),a=e.getSceneGraphPriorityListeners(),s=0;if(r&&0!==r.length)for(;s=0;n--){var r=e[n];if(r._onCustomEvent===t||r.onEvent===t)return r._setRegistered(!1),null!=r._getSceneGraphPriority()&&(this._dissociateNodeAndEventListener(r._getSceneGraphPriority(),r),r._setSceneGraphPriority(null)),0===this._inDispatch?i.js.array.removeAt(e,n):this._toRemovedListeners.push(r),!0}return!1},t._removeListenerInVector=function(e,t){if(null==e)return!1;for(var n=e.length-1;n>=0;n--){var r=e[n];if(r===t)return r._setRegistered(!1),null!=r._getSceneGraphPriority()&&(this._dissociateNodeAndEventListener(r._getSceneGraphPriority(),r),r._setSceneGraphPriority(null)),0===this._inDispatch?i.js.array.removeAt(e,n):this._toRemovedListeners.push(r),!0}return!1},e}(),BA=e("eventManager",new DA);i.eventManager=BA;var LA=new qn,FA=e("Touch",function(){function e(e,t,n){void 0===n&&(n=0),this._point=new qn,this._prevPoint=new qn,this._lastModified=0,this._id=0,this._startPoint=new qn,this._startPointCaptured=!1,this.setTouchInfo(n,e,t)}j(e,[{key:"lastModified",get:function(){return this._lastModified}}]);var t=e.prototype;return t.getLocation=function(e){return e||(e=new qn),e.set(this._point.x,this._point.y),e},t.getLocationX=function(){return this._point.x},t.getLocationY=function(){return this._point.y},t.getUILocation=function(e){return e||(e=new qn),e.set(this._point.x,this._point.y),i.view._convertPointWithScale(e),e},t.getUILocationX=function(){var e=i.view.getViewportRect();return(this._point.x-e.x)/i.view.getScaleX()},t.getUILocationY=function(){var e=i.view.getViewportRect();return(this._point.y-e.y)/i.view.getScaleY()},t.getPreviousLocation=function(e){return e||(e=new qn),e.set(this._prevPoint.x,this._prevPoint.y),e},t.getUIPreviousLocation=function(e){return e||(e=new qn),e.set(this._prevPoint.x,this._prevPoint.y),i.view._convertPointWithScale(e),e},t.getStartLocation=function(e){return e||(e=new qn),e.set(this._startPoint.x,this._startPoint.y),e},t.getUIStartLocation=function(e){return e||(e=new qn),e.set(this._startPoint.x,this._startPoint.y),i.view._convertPointWithScale(e),e},t.getDelta=function(e){return e||(e=new qn),e.set(this._point),e.subtract(this._prevPoint),e},t.getUIDelta=function(e){return e||(e=new qn),LA.set(this._point),LA.subtract(this._prevPoint),e.set(i.view.getScaleX(),i.view.getScaleY()),qn.divide(e,LA,e),e},t.getLocationInView=function(e){return e||(e=new qn),e.set(this._point.x,i.view._designResolutionSize.height-this._point.y),e},t.getPreviousLocationInView=function(e){return e||(e=new qn),e.set(this._prevPoint.x,i.view._designResolutionSize.height-this._prevPoint.y),e},t.getStartLocationInView=function(e){return e||(e=new qn),e.set(this._startPoint.x,i.view._designResolutionSize.height-this._startPoint.y),e},t.getID=function(){return this._id},t.setTouchInfo=function(e,t,n){void 0===e&&(e=0),this._prevPoint=this._point,this._point=new qn(t||0,n||0),this._id=e,this._startPointCaptured||(this._startPoint=new qn(this._point),this._startPointCaptured=!0)},t.setPoint=function(e,t){"object"==typeof e?(this._point.x=e.x,this._point.y=e.y):(this._point.x=e||0,this._point.y=t||0),this._lastModified=i.director.getCurrentTime()},t.setPrevPoint=function(e,t){this._prevPoint="object"==typeof e?new qn(e.x,e.y):new qn(e||0,t||0),this._lastModified=i.director.getCurrentTime()},e}());i.Touch=FA;var zA,UA=ft.TOUCH_TIMEOUT,GA=new qn,kA=new qn,HA=e("Acceleration",(function(e,t,n,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),this.x=void 0,this.y=void 0,this.z=void 0,this.timestamp=void 0,this.x=e,this.y=t,this.z=n,this.timestamp=i}));i.internal.Acceleration=HA;var VA=new(function(){function e(){this._mousePressed=!1,this._isRegisterEvent=!1,this._preTouchPoint=new qn,this._prevMousePoint=new qn,this._preTouchPool=[],this._preTouchPoolPointer=0,this._touches=[],this._touchesIntegerDict={},this._indexBitsUsed=0,this._maxTouches=8,this._accelEnabled=!1,this._accelInterval=.2,this._accelMinus=1,this._accelCurTime=0,this._acceleration=null,this._accelDeviceEvent=null,this._glView=null,this._pointLocked=!1}var t=e.prototype;return t.handleTouchesBegin=function(e){for(var t=[],n=this._touchesIntegerDict,i=0;i0){var c=new TA(t,!1,TA.BEGAN,ft.ENABLE_MULTI_TOUCH?this._getUsefulTouches():t);BA.dispatchEvent(c)}},t.handleTouchesMove=function(e){for(var t=[],n=this._touches,i=0;i0){var o=new TA(t,!1,TA.MOVED,ft.ENABLE_MULTI_TOUCH?this._getUsefulTouches():t);BA.dispatchEvent(o)}},t.handleTouchesEnd=function(e){var t=this.getSetOfTouchesEndOrCancel(e);if(t.length>0){var n=new TA(t,!1,TA.ENDED,ft.ENABLE_MULTI_TOUCH?this._getUsefulTouches():t);BA.dispatchEvent(n)}this._preTouchPool.length=0},t.handleTouchesCancel=function(e){var t=this.getSetOfTouchesEndOrCancel(e);if(t.length>0){var n=new TA(t,!1,TA.CANCELLED,ft.ENABLE_MULTI_TOUCH?this._getUsefulTouches():t);BA.dispatchEvent(n)}this._preTouchPool.length=0},t.getSetOfTouchesEndOrCancel=function(e){for(var t=[],n=this._touches,i=this._touchesIntegerDict,r=0;r=0;r--)if(n[r].getID()===i){t=n[r];break}return t||(t=e),t},t.setPreTouch=function(e){for(var t=!1,n=this._preTouchPool,i=e.getID(),r=n.length-1;r>=0;r--)if(n[r].getID()===i){n[r]=e,t=!0;break}t||(n.length<=50?n.push(e):(n[this._preTouchPoolPointer]=e,this._preTouchPoolPointer=(this._preTouchPoolPointer+1)%50))},t.getTouchByXY=function(e,t,n,i){var r=this._preTouchPoint,a=this._glView.convertToLocationInView(t,n,i);this._pointLocked&&(a.x=r.x+e.movementX,a.y=r.y-e.movementY);var s=new FA(a.x,a.y,0);return s.setPrevPoint(r.x,r.y),r.x=a.x,r.y=a.y,s},t.getMouseEvent=function(e,t,n){var i=this._prevMousePoint,r=new EA(n,!1,i);return i.x=e.x,i.y=e.y,this._glView._convertMouseToLocation(i,t),r.setLocation(i.x,i.y),r},t.getPointByEvent=function(e,t){return null!=e.pageX?{x:e.pageX,y:e.pageY}:(t.left-=document.body.scrollLeft,t.top-=document.body.scrollTop,{x:e.clientX,y:e.clientY})},t.getTouchesByEvent=function(e,t){for(var n=[],i=this._glView,r=this._preTouchPoint,a=e.changedTouches.length,s=0;sthis._accelInterval&&(this._accelCurTime-=this._accelInterval,BA.dispatchEvent(new AA(this._acceleration))),this._accelCurTime+=e},t.setAccelerometerInterval=function(e){this._accelInterval!==e&&(this._accelInterval=e)},t._getUnUsedIndex=function(){for(var e=this._indexBitsUsed,t=i.director.getCurrentTime(),n=0;nUA){this._removeUsedIndexBit(n);var a=r.getID();return null!==a&&delete this._touchesIntegerDict[a],n}e>>=1}return-1},t._removeUsedIndexBit=function(e){if(!(e<0||e>=this._maxTouches)){var t=1<2||t<0)&&(e.renderMode=0),"boolean"!=typeof e.registerSystemEvent&&(e.registerSystemEvent=!0),e.showFPS=!!e.showFPS,this.collisionMatrix=e.collisionMatrix||[],this.groupList=e.groupList||[],p(e.debugMode),this.config=e,this._configLoaded=!0,this._setAnimFrame()},n._determineRenderType=function(){var e=this.config,n=parseInt(e.renderMode,10);this.renderType=t.RENDER_TYPE_CANVAS;var r=!1;if(0===n?i.sys.capabilities.opengl?(this.renderType=t.RENDER_TYPE_WEBGL,r=!0):i.sys.capabilities.canvas&&(this.renderType=t.RENDER_TYPE_CANVAS,r=!0):1===n&&i.sys.capabilities.canvas?(this.renderType=t.RENDER_TYPE_CANVAS,r=!0):2===n&&i.sys.capabilities.opengl&&(this.renderType=t.RENDER_TYPE_WEBGL,r=!0),!r)throw new Error(b(3820,n))},n._initDevice=function(){if(!this._rendererInitialized){if(this.canvas=this.config.adapter.canvas,this.frame=this.config.adapter.frame,this.container=this.config.adapter.container,this._determineRenderType(),this.renderType===t.RENDER_TYPE_WEBGL){var e=[],n=!!window.WebGL2RenderingContext,r=window.navigator.userAgent.toLowerCase();(-1!==r.indexOf("safari")&&-1===r.indexOf("chrome")||mg.browserType===mg.BROWSER_TYPE_UC)&&(n=!1),n&&i.WebGL2Device&&e.push(i.WebGL2Device),i.WebGLDevice&&e.push(i.WebGLDevice);for(var a=new Fs(this.canvas,ft.ENABLE_WEBGL_ANTIALIAS,!1,window.devicePixelRatio,mg.windowPixelResolution.width,mg.windowPixelResolution.height,ql),s=0;s-1&&(i.onfocus=o),"onpageshow"in window&&"onpagehide"in window&&(i.addEventListener("pagehide",s),i.addEventListener("pageshow",o),document.addEventListener("pagehide",s),document.addEventListener("pageshow",o)),this.on(t.EVENT_HIDE,(function(){n.pause()})),this.on(t.EVENT_SHOW,(function(){n.resume()}))},n._setRenderPipelineNShowSplash=function(){var e=this;return Promise.resolve(this._setupRenderPipeline()).then((function(){return Promise.resolve(e._showSplashScreen()).then((function(){e._inited=!0,e._setAnimFrame(),e._runMainLoop(),e._safeEmit(t.EVENT_GAME_INITED),e.onStart&&e.onStart()}))}))},n._setupRenderPipeline=function(){var e=this,t=this.config.renderPipeline;return t?new Promise((function(e,n){i.assetManager.loadAny(t,(function(t,i){return!t&&i instanceof Vg?e(i):n(t)}))})).then((function(t){e._setRenderPipeline(t)})).catch((function(n){_(n),_("Failed load render pipeline: "+t+", engine failed to initialize, will fallback to default pipeline"),e._setRenderPipeline()})):this._setRenderPipeline()},n._showSplashScreen=function(){if(i.internal.SplashScreen){var e=i.internal.SplashScreen.instance;return e.main(i.director.root),new Promise((function(t){e.setOnFinish((function(){return t()})),e.loadFinish=!0}))}return null},n._setRenderPipeline=function(e){i.director.root.setRenderPipeline(e)||this._setRenderPipeline(),this._rendererInitialized=!0,this._safeEmit(t.EVENT_RENDERER_INITED)},n._safeEmit=function(e){this.emit(e)},j(t,[{key:"inited",get:function(){return this._inited}},{key:"frameTime",get:function(){return this._frameTime}}]),t}(w_));WA.EVENT_HIDE="game_on_hide",WA.EVENT_SHOW="game_on_show",WA.EVENT_LOW_MEMORY="game_on_low_memory",WA.EVENT_GAME_INITED="game_inited",WA.EVENT_ENGINE_INITED="engine_inited",WA.EVENT_RENDERER_INITED="renderer_inited",WA.EVENT_RESTART="game_on_restart",WA.RENDER_TYPE_CANVAS=0,WA.RENDER_TYPE_WEBGL=1,WA.RENDER_TYPE_OPENGL=2,i.Game=WA;var jA=e("game",i.game=new WA),qA={topLeft:i.v2(0,0),topRight:i.v2(0,0),top:i.v2(0,0),bottomLeft:i.v2(0,0),bottomRight:i.v2(0,0),bottom:i.v2(0,0),center:i.v2(0,0),left:i.v2(0,0),right:i.v2(0,0),width:0,height:0,init:function(e){var t=this.width=e.width,n=this.height=e.height,i=e.x,r=e.y,a=r+n,s=i+t;this.topLeft.x=i,this.topLeft.y=a,this.topRight.x=s,this.topRight.y=a,this.top.x=i+t/2,this.top.y=a,this.bottomLeft.x=i,this.bottomLeft.y=r,this.bottomRight.x=s,this.bottomRight.y=r,this.bottom.x=i+t/2,this.bottom.y=r,this.center.x=i+t/2,this.center.y=r+n/2,this.left.x=i,this.left.y=r+n/2,this.right.x=s,this.right.y=r+n/2}};i.visibleRect=qA;var XA=new(function(){function e(){this.html=void 0,this.meta={width:"device-width"},this.adaptationType=i.sys.browserType}var t=e.prototype;return t.init=function(){this.html=document.getElementsByTagName("html")[0]},t.availWidth=function(e){return i.sys.isMobile||!e||e===this.html?window.innerWidth:e.clientWidth},t.availHeight=function(e){return i.sys.isMobile||!e||e===this.html?window.innerHeight:e.clientHeight},e}());switch(i.sys.os===i.sys.OS_IOS&&(XA.adaptationType=i.sys.BROWSER_TYPE_SAFARI),XA.adaptationType){case i.sys.BROWSER_TYPE_SAFARI:XA.meta["minimal-ui"]="true",XA.availWidth=function(e){return e.clientWidth},XA.availHeight=function(e){return e.clientHeight};break;case i.sys.BROWSER_TYPE_SOUGOU:case i.sys.BROWSER_TYPE_UC:XA.availWidth=function(e){return e.clientWidth},XA.availHeight=function(e){return e.clientHeight}}var YA=e("View",function(e){function t(){var t;(t=e.call(this)||this)._resizeWithBrowserSize=void 0,t._designResolutionSize=void 0,t._originalDesignResolutionSize=void 0,t._frameSize=void 0,t._scaleX=void 0,t._scaleY=void 0,t._viewportRect=void 0,t._visibleRect=void 0,t._autoFullScreen=void 0,t._devicePixelRatio=void 0,t._maxPixelRatio=void 0,t._retinaEnabled=void 0,t._resizeCallback=void 0,t._resizing=void 0,t._orientationChanging=void 0,t._isRotated=void 0,t._orientation=void 0,t._isAdjustViewport=void 0,t._resolutionPolicy=void 0,t._rpExactFit=void 0,t._rpShowAll=void 0,t._rpNoBorder=void 0,t._rpFixedHeight=void 0,t._rpFixedWidth=void 0;var n=KA,r=ZA;return t._frameSize=new $n(0,0),t._designResolutionSize=new $n(0,0),t._originalDesignResolutionSize=new $n(0,0),t._scaleX=1,t._scaleY=1,t._viewportRect=new ti(0,0,0,0),t._visibleRect=new ti(0,0,0,0),t._autoFullScreen=!1,t._devicePixelRatio=1,t._maxPixelRatio=2,t._retinaEnabled=!1,t._resizeCallback=null,t._resizing=!1,t._resizeWithBrowserSize=!1,t._orientationChanging=!0,t._isRotated=!1,t._orientation=i.macro.ORIENTATION_AUTO,t._isAdjustViewport=!0,t._rpExactFit=new QA(n.EQUAL_TO_FRAME,r.EXACT_FIT),t._rpShowAll=new QA(n.EQUAL_TO_FRAME,r.SHOW_ALL),t._rpNoBorder=new QA(n.EQUAL_TO_FRAME,r.NO_BORDER),t._rpFixedHeight=new QA(n.EQUAL_TO_FRAME,r.FIXED_HEIGHT),t._rpFixedWidth=new QA(n.EQUAL_TO_FRAME,r.FIXED_WIDTH),t._resolutionPolicy=t._rpShowAll,i.game.once(i.Game.EVENT_ENGINE_INITED,t.init,Y(t)),t}X(t,e);var n=t.prototype;return n.init=function(){XA.init(),this._initFrameSize();var e=i.game.canvas.width,t=i.game.canvas.height;this._designResolutionSize.width=e,this._designResolutionSize.height=t,this._originalDesignResolutionSize.width=e,this._originalDesignResolutionSize.height=t,this._viewportRect.width=e,this._viewportRect.height=t,this._visibleRect.width=e,this._visibleRect.height=t,i.winSize.width=this._visibleRect.width,i.winSize.height=this._visibleRect.height,i.visibleRect&&i.visibleRect.init(this._visibleRect)},n.resizeWithBrowserSize=function(e){e?this._resizeWithBrowserSize||(this._resizeWithBrowserSize=!0,window.addEventListener("resize",this._resizeEvent),window.addEventListener("orientationchange",this._orientationChange)):this._resizeWithBrowserSize&&(this._resizeWithBrowserSize=!1,window.removeEventListener("resize",this._resizeEvent),window.removeEventListener("orientationchange",this._orientationChange))},n.setResizeCallback=function(e){"function"!=typeof e&&null!=e||(this._resizeCallback=e)},n.setOrientation=function(e){(e&=i.macro.ORIENTATION_AUTO)&&this._orientation!==e&&(this._orientation=e)},n.adjustViewportMeta=function(e){this._isAdjustViewport=e},n.enableRetina=function(e){this._retinaEnabled=!!e},n.isRetinaEnabled=function(){return this._retinaEnabled},n.enableAutoFullScreen=function(e){e&&e!==this._autoFullScreen&&i.sys.isMobile&&i.sys.browserType!==i.sys.BROWSER_TYPE_WECHAT?(this._autoFullScreen=!0,i.screen.autoFullScreen(i.game.frame)):this._autoFullScreen=!1},n.isAutoFullScreenEnabled=function(){return this._autoFullScreen},n.setCanvasSize=function(e,t){var n=i.game.canvas,r=i.game.container;this._devicePixelRatio=window.devicePixelRatio,n.width=mg.windowPixelResolution.width,n.height=mg.windowPixelResolution.height,n.style.width=e+"px",n.style.height=t+"px",r.style.width=e+"px",r.style.height=t+"px",this._resizeEvent()},n.getCanvasSize=function(){return new $n(i.game.canvas.width,i.game.canvas.height)},n.getFrameSize=function(){return new $n(this._frameSize.width,this._frameSize.height)},n.setFrameSize=function(e,t){this._frameSize.width=e,this._frameSize.height=t,i.game.frame.style.width=e+"px",i.game.frame.style.height=t+"px",this._resizeEvent()},n.getVisibleSize=function(){return new $n(this._visibleRect.width,this._visibleRect.height)},n.getVisibleSizeInPixel=function(){return new $n(this._visibleRect.width*this._scaleX,this._visibleRect.height*this._scaleY)},n.getVisibleOrigin=function(){return new qn(this._visibleRect.x,this._visibleRect.y)},n.getVisibleOriginInPixel=function(){return new qn(this._visibleRect.x*this._scaleX,this._visibleRect.y*this._scaleY)},n.getResolutionPolicy=function(){return this._resolutionPolicy},n.setResolutionPolicy=function(e){if(e instanceof QA)this._resolutionPolicy=e;else{var t=QA;e===t.EXACT_FIT&&(this._resolutionPolicy=this._rpExactFit),e===t.SHOW_ALL&&(this._resolutionPolicy=this._rpShowAll),e===t.NO_BORDER&&(this._resolutionPolicy=this._rpNoBorder),e===t.FIXED_HEIGHT&&(this._resolutionPolicy=this._rpFixedHeight),e===t.FIXED_WIDTH&&(this._resolutionPolicy=this._rpFixedWidth)}},n.setDesignResolutionSize=function(e,t,n){if(e>0&&t>0){this.setResolutionPolicy(n);var r=this._resolutionPolicy;if(r&&r.preApply(this),i.sys.isMobile&&this._adjustViewportMeta(),this._orientationChanging=!0,this._resizing||this._initFrameSize(),r){this._originalDesignResolutionSize.width=this._designResolutionSize.width=e,this._originalDesignResolutionSize.height=this._designResolutionSize.height=t;var a=r.apply(this,this._designResolutionSize);if(a.scale&&2===a.scale.length&&(this._scaleX=a.scale[0],this._scaleY=a.scale[1]),a.viewport){var s=this._viewportRect,o=this._visibleRect,c=a.viewport;s.x=c.x,s.y=c.y,s.width=c.width,s.height=c.height,o.x=0,o.y=0,o.width=c.width/this._scaleX,o.height=c.height/this._scaleY}r.postApply(this),i.winSize.width=this._visibleRect.width,i.winSize.height=this._visibleRect.height,qA&&qA.init(this._visibleRect),this.emit("design-resolution-changed")}else y(2201)}else A(2200)},n.getDesignResolutionSize=function(){return new $n(this._designResolutionSize.width,this._designResolutionSize.height)},n.setRealPixelResolution=function(e,t,n){this._setViewportMeta({width:e},!0),document.documentElement.style.width=e+"px",document.body.style.width=e+"px",document.body.style.left="0px",document.body.style.top="0px",this.setDesignResolutionSize(e,t,n)},n.getViewportRect=function(){return this._viewportRect},n.getScaleX=function(){return this._scaleX},n.getScaleY=function(){return this._scaleY},n.getDevicePixelRatio=function(){return this._devicePixelRatio},n.convertToLocationInView=function(e,t,n,r){var a=r||new qn,s=this._devicePixelRatio*(e-n.left),o=this._devicePixelRatio*(n.top+n.height-t);return this._isRotated?(a.x=i.game.canvas.width-o,a.y=s):(a.x=s,a.y=o),i.GAME_VIEW&&(a.x/=i.gameView.canvas.width/i.game.canvas.width,a.y/=i.gameView.canvas.height/i.game.canvas.height),a},n._convertPointWithScale=function(e){var t=this._viewportRect;e.x=(e.x-t.x)/this._scaleX,e.y=(e.y-t.y)/this._scaleY},n._resizeEvent=function(){var e=i.view,t=e._frameSize.width,n=e._frameSize.height,r=e._isRotated;if(i.sys.isMobile){var a=i.game.container.style,s=a.margin;a.margin="0",a.display="none",e._initFrameSize(),a.margin=s,a.display="block"}else e._initFrameSize();if(e._orientationChanging||e._isRotated!==r||e._frameSize.width!==t||e._frameSize.height!==n){var o=e._originalDesignResolutionSize.width,c=e._originalDesignResolutionSize.height;e._resizing=!0,o>0&&e.setDesignResolutionSize(o,c,e._resolutionPolicy),e._resizing=!1,e.emit("canvas-resize"),e._resizeCallback&&e._resizeCallback.call()}},n._orientationChange=function(){i.view._orientationChanging=!0,i.view._resizeEvent()},n._initFrameSize=function(){var e=this._frameSize,t=XA.availWidth(i.game.frame),n=XA.availHeight(i.game.frame),r=t>=n;!i.sys.isMobile||r&&this._orientation&i.macro.ORIENTATION_LANDSCAPE||!r&&this._orientation&i.macro.ORIENTATION_PORTRAIT?(e.width=t,e.height=n,i.game.container.style["-webkit-transform"]="rotate(0deg)",i.game.container.style.transform="rotate(0deg)",this._isRotated=!1):(e.width=n,e.height=t,i.game.container.style["-webkit-transform"]="rotate(90deg)",i.game.container.style.transform="rotate(90deg)",i.game.container.style["-webkit-transform-origin"]="0px 0px 0px",i.game.container.style.transformOrigin="0px 0px 0px",this._isRotated=!0,i.game.canvas.style["-webkit-transform"]="translateZ(0px)",i.game.canvas.style.transform="translateZ(0px)"),this._orientationChanging&&setTimeout((function(){i.view._orientationChanging=!1}),1e3)},n._adjustSizeKeepCanvasSize=function(){var e=this._originalDesignResolutionSize.width,t=this._originalDesignResolutionSize.height;e>0&&this.setDesignResolutionSize(e,t,this._resolutionPolicy)},n._setViewportMeta=function(e,t){var n=document.getElementById("cocosMetaElement");n&&t&&document.head.removeChild(n);var i,r,a,s=document.getElementsByName("viewport"),o=s?s[0]:null;for(r in i=o?o.content:"",(n=n||document.createElement("meta")).id="cocosMetaElement",n.name="viewport",n.content="",e)-1===i.indexOf(r)?i+=","+r+"="+e[r]:t&&(a=new RegExp(r+"s*=s*[^,]+"),i=i.replace(a,r+"="+e[r]));/^,/.test(i)&&(i=i.substr(1)),n.content=i,o&&(o.content=i),document.head.appendChild(n)},n._adjustViewportMeta=function(){this._isAdjustViewport&&(this._setViewportMeta(XA.meta,!1),this._isAdjustViewport=!1)},n._convertMouseToLocation=function(e,t){e.x=this._devicePixelRatio*(e.x-t.left),e.y=this._devicePixelRatio*(t.top+t.height-e.y),i.GAME_VIEW&&(e.x/=i.gameView.canvas.width/i.game.canvas.width,e.y/=i.gameView.canvas.height/i.game.canvas.height)},n._convertTouchWidthScale=function(e){var t=this._viewportRect,n=this._scaleX,i=this._scaleY;e._point.x=(e._point.x-t.x)/n,e._point.y=(e._point.y-t.y)/i,e._prevPoint.x=(e._prevPoint.x-t.x)/n,e._prevPoint.y=(e._prevPoint.y-t.y)/i},n._convertTouchesWithScale=function(e){for(var t,n,i=this._viewportRect,r=this._scaleX,a=this._scaleY,s=0;se.setting.totalTime&&(e.splashFinish=!0),requestAnimationFrame(t)}}))},e.hide=function(){cancelAnimationFrame(this.handle),this.cancelAnimate=!0,setTimeout(this.destroy.bind(this))},e.frame=function(){if(!this.cancelAnimate){var e=this.device;e.acquire();var t=this.cmdBuff,n=this.framebuffer,i=this.renderArea;i.height=e.height,i.width=e.width,t.begin(),t.beginRenderPass(n.renderPass,n,i,this.clearColors,1,0);var r=this.material.passes[0],a=Wg.getOrCreatePipelineState(e,r,this.shader,n.renderPass,this.assmebler);if(t.bindPipelineState(a),t.bindDescriptorSet(Vl.MATERIAL,r.descriptorSet),t.bindInputAssembler(this.assmebler),t.draw(this.assmebler),this.setting.displayWatermark&&this.textShader&&this.textAssmebler){var s=this.textMaterial.passes[0],o=Wg.getOrCreatePipelineState(e,s,this.textShader,n.renderPass,this.textAssmebler);t.bindPipelineState(o),t.bindDescriptorSet(Vl.MATERIAL,s.descriptorSet),t.bindInputAssembler(this.textAssmebler),t.draw(this.textAssmebler)}t.endRenderPass(),t.end(),e.queue.submit([t]),e.present()}},e.initText=function(){this.textImg=document.createElement("canvas"),this.textImg.width=330,this.textImg.height=30,this.textImg.style.width=""+this.textImg.width,this.textImg.style.height=""+this.textImg.height;var e=this.textImg.getContext("2d");e.font="18px Arial",e.textBaseline="top",e.textAlign="left",e.fillStyle="`#424242`";var t="Powered by Cocos Creator",n=e.measureText(t);e.fillText(t,(330-n.width)/2,6),this.textRegion=new eo,this.textRegion.texExtent.width=this.textImg.width,this.textRegion.texExtent.height=this.textImg.height,this.textRegion.texExtent.depth=1,this.textTexture=this.device.createTexture(new xo(es.TEX2D,ts.SAMPLED|ts.TRANSFER_DST,za.RGBA8,this.textImg.width,this.textImg.height)),this.device.copyTexImagesToTexture([this.textImg],this.textTexture,[this.textRegion]),this.textMaterial=new em,this.textMaterial.initialize({effectName:"splash-screen"});var i=this.textMaterial.passes[0],r=i.getBinding("mainTexture");i.bindTexture(r,this.textTexture),this.textShader=zi.get(i.getShaderVariant()),Ui.get(er.get(i.handle,Fi.DESCRIPTOR_SET)).update();var a=4*Float32Array.BYTES_PER_ELEMENT,s=4*a;this.textVB=this.device.createBuffer(new Ps(Ua.VERTEX|Ua.TRANSFER_DST,Ga.HOST|Ga.DEVICE,s,a));var o=new Float32Array(16),c=-this.textImg.width/2,l=this.textImg.height;l=this.screenWidtht.priority?-1:0};var t=e.prototype;return t.init=function(){},t.update=function(){},t.postUpdate=function(){},j(e,[{key:"priority",set:function(e){this._priority=e},get:function(){return this._priority}},{key:"id",set:function(e){this._id=e},get:function(){return this._id}}]),e}()),lx=new Se("Scheduler"),ux=function(e,t,n,i){this.target=void 0,this.priority=void 0,this.paused=void 0,this.markedForDeletion=void 0,this.target=e,this.priority=t,this.paused=n,this.markedForDeletion=i};ux.get=function(e,t,n,i){var r=ux._listEntries.pop();return r?(r.target=e,r.priority=t,r.paused=n,r.markedForDeletion=i):r=new ux(e,t,n,i),r},ux.put=function(e){ux._listEntries.length<20&&(e.target=null,ux._listEntries.push(e))},ux._listEntries=[];var hx=function(e,t,n,i){this.list=void 0,this.entry=void 0,this.target=void 0,this.callback=void 0,this.list=e,this.entry=t,this.target=n,this.callback=i};hx.get=function(e,t,n,i){var r=hx._hashUpdateEntries.pop();return r?(r.list=e,r.entry=t,r.target=n,r.callback=i):r=new hx(e,t,n,i),r},hx.put=function(e){hx._hashUpdateEntries.length<20&&(e.list=e.entry=e.target=e.callback=null,hx._hashUpdateEntries.push(e))},hx._hashUpdateEntries=[];var _x=function(e,t,n,i,r,a){this.timers=void 0,this.target=void 0,this.timerIndex=void 0,this.currentTimer=void 0,this.currentTimerSalvaged=void 0,this.paused=void 0,this.timers=e,this.target=t,this.timerIndex=n,this.currentTimer=i,this.currentTimerSalvaged=r,this.paused=a};_x.get=function(e,t,n,i,r,a){var s=_x._hashTimerEntries.pop();return s?(s.timers=e,s.target=t,s.timerIndex=n,s.currentTimer=i,s.currentTimerSalvaged=r,s.paused=a):s=new _x(e,t,n,i,r,a),s},_x.put=function(e){_x._hashTimerEntries.length<20&&(e.timers=e.target=e.currentTimer=null,_x._hashTimerEntries.push(e))},_x._hashTimerEntries=[];var fx=function(){function e(){this._lock=void 0,this._scheduler=void 0,this._elapsed=void 0,this._runForever=void 0,this._useDelay=void 0,this._timesExecuted=void 0,this._repeat=void 0,this._delay=void 0,this._interval=void 0,this._target=void 0,this._callback=void 0,this._lock=!1,this._scheduler=null,this._elapsed=-1,this._runForever=!1,this._useDelay=!1,this._timesExecuted=0,this._repeat=0,this._delay=0,this._interval=0,this._target=null,this._callback=null}var t=e.prototype;return t.initWithCallback=function(e,t,n,r,a,s){return this._lock=!1,this._scheduler=e,this._target=n,this._callback=t,this._elapsed=-1,this._interval=r,this._delay=s,this._useDelay=this._delay>0,this._repeat=a,this._runForever=this._repeat===i.macro.REPEAT_FOREVER,!0},t.getInterval=function(){return this._interval},t.setInterval=function(e){this._interval=e},t.update=function(e){-1===this._elapsed?(this._elapsed=0,this._timesExecuted=0):(this._elapsed+=e,this._runForever&&!this._useDelay?this._elapsed>=this._interval&&(this.trigger(),this._elapsed=0):(this._useDelay?this._elapsed>=this._delay&&(this.trigger(),this._elapsed-=this._delay,this._timesExecuted+=1,this._useDelay=!1):this._elapsed>=this._interval&&(this.trigger(),this._elapsed=0,this._timesExecuted+=1),this._callback&&!this._runForever&&this._timesExecuted>this._repeat&&this.cancel()))},t.getCallback=function(){return this._callback},t.trigger=function(){this._target&&this._callback&&(this._lock=!0,this._callback.call(this._target,this._elapsed),this._lock=!1)},t.cancel=function(){this._scheduler.unschedule(this._callback,this._target)},e}();fx._timers=[],fx.get=function(){return fx._timers.pop()||new fx},fx.put=function(e){fx._timers.length<20&&!e._lock&&(e._scheduler=e._target=e._callback=null,fx._timers.push(e))};var dx=e("Scheduler",function(e){function t(){var t;return(t=e.call(this)||this)._timeScale=void 0,t._updatesNegList=void 0,t._updates0List=void 0,t._updatesPosList=void 0,t._hashForUpdates=void 0,t._hashForTimers=void 0,t._currentTarget=void 0,t._currentTargetSalvaged=void 0,t._updateHashLocked=void 0,t._arrayForTimers=void 0,t._timeScale=1,t._updatesNegList=[],t._updates0List=[],t._updatesPosList=[],t._hashForUpdates=Pe(!0),t._hashForTimers=Pe(!0),t._currentTarget=null,t._currentTargetSalvaged=!1,t._updateHashLocked=!1,t._arrayForTimers=[],t}X(t,e),t.enableForTarget=function(e){var t=!1;(e.uuid||e.id)&&(t=!0),t||(e.__instanceId?E(1513):e.id=lx.getNewId())};var n=t.prototype;return n.setTimeScale=function(e){this._timeScale=e},n.getTimeScale=function(){return this._timeScale},n.update=function(e){var t,n,i,r,a;for(this._updateHashLocked=!0,1!==this._timeScale&&(e*=this._timeScale),t=0,i=(n=this._updatesNegList).length;t=a&&i.timerIndex--,void(0===r.length&&(this._currentTarget===i?this._currentTargetSalvaged=!0:this._removeHashElement(i)))}}else A(1510)}},n.unscheduleUpdate=function(e){if(e){var t=e.uuid||e.id;if(t){var n=this._hashForUpdates[t];n&&(this._updateHashLocked?n.entry.markedForDeletion=!0:this._removeUpdateFromHash(n.entry))}else A(1510)}},n.unscheduleAllForTarget=function(e){if(e){var t=e.uuid||e.id;if(t){var n=this._hashForTimers[t];if(n){var i=n.timers;i.indexOf(n.currentTimer)>-1&&!n.currentTimerSalvaged&&(n.currentTimerSalvaged=!0);for(var r=0,a=i.length;r=0;t--)n=r[t],this.unscheduleAllForTarget(n.target);var a=0;if(e<0)for(t=0;t=e&&this.unscheduleUpdate(i.target),a===this._updatesNegList.length&&t++;if(e<=0)for(t=0;t=e&&this.unscheduleUpdate(i.target),a===this._updatesPosList.length&&t++},n.isScheduled=function(e,t){R(e,1508),R(t,1509);var n=t.uuid||t.id;if(n){var i=this._hashForTimers[n];if(!i)return!1;if(null==i.timers)return!1;for(var r=i.timers,a=0;a=e&&(r.paused=!0,a.push(r.target));if(e<=0)for(n=0;n=e&&(r.paused=!0,a.push(r.target));return a},n.resumeTargets=function(e){if(e)for(var t=0;t=0?(this._depthStencilTexture=e.createTexture(new xo(es.TEX2D,ts.DEPTH_STENCIL_ATTACHMENT|ts.SAMPLED,r.format,this._width,this._height)),br.set(this._poolHandle,Tr.HAS_OFF_SCREEN_ATTACHMENTS,1)):br.set(this._poolHandle,Tr.HAS_ON_SCREEN_ATTACHMENTS,1));var c=Hi.alloc(e,new Us(this._renderPass,this._colorTextures,this._depthStencilTexture));return br.set(this._poolHandle,Tr.FRAMEBUFFER,c),!0},t.destroy=function(){this.clearCameras(),this._depthStencilTexture&&(this._depthStencilTexture.destroy(),this._depthStencilTexture=null);for(var e=0;ethis._nativeWidth||t>this._nativeHeight){this._nativeWidth=e,this._nativeHeight=t;var n=!1;this._depthStencilTexture&&(this._depthStencilTexture.resize(e,t),n=!0);for(var i=0;i0?(this._fixedFPS=e,this._fixedFPSFrameTime=1e3/e):this._fixedFPSFrameTime=0},get:function(){return this._fixedFPS}},{key:"dataPoolManager",get:function(){return this._dataPoolMgr}},{key:"handle",get:function(){return this._poolHandle}}]);var t=e.prototype;return t.initialize=function(){var e=this;this._poolHandle=xr.alloc();var t=new uo,n=new ho;n.depthStoreOp=cs.DISCARD,n.stencilStoreOp=cs.DISCARD;var r=new fo([t],n);return this._mainWindow=this.createWindow({title:"rootMainWindow",width:this._device.width,height:this._device.height,renderPassInfo:r,swapchainBufferIndices:-1}),this._curWindow=this._mainWindow,Promise.resolve(Xd.initBuiltinRes(this._device)).then((function(){i.view.on("design-resolution-changed",(function(){var t=i.game.canvas.width,n=i.game.canvas.height;e.resize(t,n)}),e)}))},t.destroy=function(){this.destroyScenes(),this._pipeline&&(this._pipeline.destroy(),this._pipeline=null),this._batcher&&(this._batcher.destroy(),this._batcher=null),this._curWindow=null,this._mainWindow=null,this.dataPoolManager.clear(),this._poolHandle&&(xr.free(this._poolHandle),this._poolHandle=0)},t.resize=function(e,t){this._device.resize(e,t),this._mainWindow.resize(e,t);for(var n,i=Z(this._windows);!(n=i()).done;){var r=n.value;r.shouldSyncSizeWithSwapchain&&r.resize(e,t)}},t.setRenderPipeline=function(e){if(e||(e=this.createDefaultPipeline()),this._pipeline=e,!this._pipeline.activate())return!1;var t=i.director.getScene();return t&&t.globals.activate(),this.onGlobalPipelineStateChanged(),!(!this._batcher&&i.internal.Batcher2D&&(this._batcher=new i.internal.Batcher2D(this),!this._batcher.initialize())&&(this.destroy(),1))},t.createDefaultPipeline=function(){var e=new tE;return e.initialize({flows:[]}),e},t.onGlobalPipelineStateChanged=function(){for(var e=0;e1&&(this._fps=this._frameCount,this._frameCount=0,this._fpsTime=0);for(var n=0;nr.x?n[c]:r.x,r.y=n[c+1]>r.y?n[c+1]:r.y,a.x=n[c]r.x?n[c]:r.x,r.y=n[c+1]>r.y?n[c+1]:r.y,r.z=n[c+2]>r.z?n[c+2]:r.z,a.x=n[c]0&&(a=n._findChildComponent(r._children,t)))return a}return null},n._findChildComponents=function(e,t,i){for(var r=0;r0&&n._findChildComponents(a._children,t,i)}};var t=n.prototype;function n(t){var n;return Q(n=e.call(this,t)||this,"_parent",qx,Y(n)),Q(n,"_children",Xx,Y(n)),Q(n,"_active",Yx,Y(n)),Q(n,"_components",Kx,Y(n)),Q(n,"_prefab",Zx,Y(n)),n._scene=null,n._activeInHierarchy=!1,n._id=iC.getNewId(),n._name=void 0,n._eventProcessor=new i.NodeEventProcessor(Y(n)),n._eventMask=0,n._siblingIndex=0,n._registerIfAttached=void 0,n._name=void 0!==t?t:"New Node",n}return t._updateScene=function(){null==this._parent?f("Node %s(%s) has not attached to a scene.",this.name,this.uuid):this._scene=this._parent._scene},j(n,[{key:"components",get:function(){return this._components}},{key:"_persistNode",get:function(){return(this._objFlags&tC)>0},set:function(e){e?this._objFlags|=tC:this._objFlags&=~tC}},{key:"name",get:function(){return this._name},set:function(e){this._name=e}},{key:"uuid",get:function(){return this._id}},{key:"children",get:function(){return this._children}},{key:"active",get:function(){return this._active},set:function(e){if(this._active!==e){this._active=e;var t=this._parent;t&&t._activeInHierarchy&&i.director._nodeActivator.activateNode(this,e)}}},{key:"activeInHierarchy",get:function(){return this._activeInHierarchy}},{key:"parent",get:function(){return this._parent},set:function(e){this.setParent(e)}},{key:"scene",get:function(){return this._scene}},{key:"eventProcessor",get:function(){return this._eventProcessor}}]),t.attr=function(e){He(this,e)},t.getParent=function(){return this._parent},t.setParent=function(e,t){if(void 0===t&&(t=!1),this._parent!==e){var n=this._parent,i=e;if(this._parent=i,this._siblingIndex=0,this._onSetParent(n,t),this.emit&&this.emit(JA.PARENT_CHANGED,n),n&&!(n._objFlags&eC)){var r=n._children.indexOf(this);n._children.splice(r,1),n._updateSiblingIndex(),n.emit&&n.emit(JA.CHILD_REMOVED,this)}i&&(i._children.push(this),this._siblingIndex=i._children.length-1,i.emit&&i.emit(JA.CHILD_ADDED,this)),this._onHierarchyChanged(n)}},t.getChildByUuid=function(e){if(!e)return h("Invalid uuid"),null;for(var t=this._children,n=0,i=t.length;n0?(c=a,r=a._children,s=0,o[i]=r[s],i++):(o[i]=a,i++,l=!0);o.length=0,n._stackId--},t.removeFromParent=function(){this._parent&&this._parent.removeChild(this)},t.removeChild=function(e){this._children.indexOf(e)>-1&&(e.parent=null)},t.removeAllChildren=function(){for(var e=this._children,t=e.length-1;t>=0;t--){var n=e[t];n&&(n.parent=null)}this._children.length=0},t.isChildOf=function(e){var t=this;do{if(t===e)return!0;t=t._parent}while(t);return!1},t.getComponent=function(e){var t=rC(e);return t?n._findComponent(this,t):null},t.getComponents=function(e){var t=rC(e),i=[];return t&&n._findComponents(this,t,i),i},t.getComponentInChildren=function(e){var t=rC(e);return t?n._findChildComponent(this._children,t):null},t.getComponentsInChildren=function(e){var t=rC(e),i=[];return t&&(n._findComponents(this,t,i),n._findChildComponents(this._children,t,i)),i},t.addComponent=function(e){var t;if("string"==typeof e){if(!(t=nt(e)))throw i._RF.peek()&&A(3808,e),TypeError(b(3807,e))}else{if(!e)throw TypeError(b(3804));t=e}if("function"!=typeof t)throw TypeError(b(3809));if(!je(t,i.Component))throw TypeError(b(3810));var n=t._requireComponent;n&&!this.getComponent(n)&&this.addComponent(n);var r=new t;return r.node=this,this._components.push(r),this._activeInHierarchy&&i.director._nodeActivator.activateComp(r),r},t.removeComponent=function(e){if(e){var t=null;(t=e instanceof Kf?e:this.getComponent(e))&&t.destroy()}else A(3813)},t.on=function(e,t,n,i){switch(void 0===i&&(i=!1),e){case JA.TRANSFORM_CHANGED:this._eventMask|=1}this._eventProcessor.on(e,t,n,i)},t.off=function(e,t,n,i){if(void 0===i&&(i=!1),this._eventProcessor.off(e,t,n,i),!this._eventProcessor.hasEventListener(e))switch(e){case JA.TRANSFORM_CHANGED:this._eventMask&=-2}},t.once=function(e,t,n,i){this._eventProcessor.once(e,t,n,i)},t.emit=function(e,t,n,i,r,a){this._eventProcessor.emit(e,t,n,i,r,a)},t.dispatchEvent=function(e){this._eventProcessor.dispatchEvent(e)},t.hasEventListener=function(e,t,n){return this._eventProcessor.hasEventListener(e,t,n)},t.targetOff=function(e){this._eventProcessor.targetOff(e),1&this._eventMask&&!this._eventProcessor.hasEventListener(JA.TRANSFORM_CHANGED)&&(this._eventMask&=-2)},t.destroy=function(){return!!e.prototype.destroy.call(this)&&(this.active=!1,!0)},t.destroyAllChildren=function(){for(var e=this._children,t=0;t=0;)bn.transformInverseRTS(e,e,n._lrot,n._lpos,n._lscale),n=SC[--i];return e},n.setWorldPosition=function(e,t,n){void 0===t||void 0===n?bn.copy(this._pos,e):bn.set(this._pos,e,t,n),Er.setVec3(this._poolHandle,mr.WORLD_POSITION,this._pos);var i=this._parent,r=this._lpos;i?(i.updateWorldTransform(),bn.transformMat4(r,this._pos,Hn.invert(xC,i._mat))):bn.copy(r,this._pos),this.invalidateChildren(Uu.POSITION),1&this._eventMask&&this.emit(JA.TRANSFORM_CHANGED,Uu.POSITION)},n.getWorldPosition=function(e){return this.updateWorldTransform(),e?bn.copy(e,this._pos):bn.copy(new bn,this._pos)},n.setWorldRotation=function(e,t,n,i){void 0===t||void 0===n||void 0===i?Dn.copy(this._rot,e):Dn.set(this._rot,e,t,n,i),Er.setVec4(this._poolHandle,mr.WORLD_ROTATION,this._rot),this._parent?(this._parent.updateWorldTransform(),Dn.multiply(this._lrot,Dn.conjugate(this._lrot,this._parent._rot),this._rot)):Dn.copy(this._lrot,this._rot),this._eulerDirty=!0,this.invalidateChildren(Uu.ROTATION),1&this._eventMask&&this.emit(JA.TRANSFORM_CHANGED,Uu.ROTATION)},n.setWorldRotationFromEuler=function(e,t,n){Dn.fromEuler(this._rot,e,t,n),this._parent?(this._parent.updateWorldTransform(),Dn.multiply(this._lrot,Dn.conjugate(this._lrot,this._parent._rot),this._rot)):Dn.copy(this._lrot,this._rot),this._eulerDirty=!0,this.invalidateChildren(Uu.ROTATION),1&this._eventMask&&this.emit(JA.TRANSFORM_CHANGED,Uu.ROTATION)},n.getWorldRotation=function(e){return this.updateWorldTransform(),e?Dn.copy(e,this._rot):Dn.copy(new Dn,this._rot)},n.setWorldScale=function(e,t,n){void 0===t||void 0===n?bn.copy(this._scale,e):bn.set(this._scale,e,t,n),Er.setVec3(this._poolHandle,mr.WORLD_SCALE,this._scale);var i=this._parent;i?(i.updateWorldTransform(),Pn.fromQuat(TC,Dn.conjugate(EC,i._rot)),Pn.multiplyMat4(TC,TC,i._mat),AC.m00=this._scale.x,AC.m04=this._scale.y,AC.m08=this._scale.z,Pn.multiply(TC,AC,Pn.invert(TC,TC)),this._lscale.x=bn.set(gC,TC.m00,TC.m01,TC.m02).length(),this._lscale.y=bn.set(gC,TC.m03,TC.m04,TC.m05).length(),this._lscale.z=bn.set(gC,TC.m06,TC.m07,TC.m08).length()):bn.copy(this._lscale,this._scale),this.invalidateChildren(Uu.SCALE),1&this._eventMask&&this.emit(JA.TRANSFORM_CHANGED,Uu.SCALE)},n.getWorldScale=function(e){return this.updateWorldTransform(),e?bn.copy(e,this._scale):bn.copy(new bn,this._scale)},n.getWorldMatrix=function(e){this.updateWorldTransform();var t=e||new Hn;return Hn.copy(t,this._mat)},n.getWorldRS=function(e){this.updateWorldTransform();var t=e||new Hn;return Hn.copy(t,this._mat),t.m12=0,t.m13=0,t.m14=0,t},n.getWorldRT=function(e){this.updateWorldTransform();var t=e||new Hn;return Hn.fromRT(t,this._rot,this._pos)},n.setRTS=function(e,t,n){var i=0;e&&(i|=Uu.ROTATION,void 0!==e.w?(Dn.copy(this._lrot,e),this._eulerDirty=!0):(bn.copy(this._euler,e),Dn.fromEuler(this._lrot,e.x,e.y,e.z),this._eulerDirty=!1)),t&&(bn.copy(this._lpos,t),i|=Uu.POSITION),n&&(bn.copy(this._lscale,n),i|=Uu.SCALE),i&&(this.invalidateChildren(i),1&this._eventMask&&this.emit(JA.TRANSFORM_CHANGED,i))},n.pauseSystemEvents=function(e){BA.pauseTarget(this,e)},n.resumeSystemEvents=function(e){BA.resumeTarget(this,e)},j(t,[{key:"handle",get:function(){return this._poolHandle}},{key:"position",get:function(){return this._lpos},set:function(e){this.setPosition(e)}},{key:"worldPosition",get:function(){return this.updateWorldTransform(),this._pos},set:function(e){this.setWorldPosition(e)}},{key:"rotation",get:function(){return this._lrot},set:function(e){this.setRotation(e)}},{key:"eulerAngles",set:function(e){this.setRotationFromEuler(e.x,e.y,e.z)},get:function(){return this._eulerDirty&&(Dn.toEuler(this._euler,this._lrot),this._eulerDirty=!1),this._euler}},{key:"angle",get:function(){return this._euler.z},set:function(e){bn.set(this._euler,0,0,e),Dn.fromAngleZ(this._lrot,e),this._eulerDirty=!1,this.invalidateChildren(Uu.ROTATION),1&this._eventMask&&this.emit(JA.TRANSFORM_CHANGED,Uu.ROTATION)}},{key:"worldRotation",get:function(){return this.updateWorldTransform(),this._rot},set:function(e){this.setWorldRotation(e)}},{key:"scale",get:function(){return this._lscale},set:function(e){this.setScale(e)}},{key:"worldScale",get:function(){return this.updateWorldTransform(),this._scale},set:function(e){this.setWorldScale(e)}},{key:"matrix",set:function(e){Hn.toRTS(e,this._lrot,this._lpos,this._lscale),this.invalidateChildren(Uu.TRS),this._eulerDirty=!0,1&this._eventMask&&this.emit(JA.TRANSFORM_CHANGED,Uu.TRS)}},{key:"worldMatrix",get:function(){return this.updateWorldTransform(),this._mat}},{key:"forward",get:function(){return bn.transformQuat(new bn,bn.FORWARD,this.worldRotation)},set:function(e){var t=e.length();bn.multiplyScalar(gC,e,-1/t),Dn.fromViewUp(vC,gC),this.setWorldRotation(vC)}},{key:"layer",set:function(e){this._layer=e,Er.set(this._poolHandle,mr.LAYER,this._layer),this.emit(JA.LAYER_CHANGED,this._layer)},get:function(){return this._layer}},{key:"hasChangedFlags",get:function(){return CC.get(this)||0},set:function(e){CC.set(this,e),Er.set(this._poolHandle,mr.FLAGS_CHANGED,e)}}]),t}(mC),dC.bookOfChange=CC,dC.EventType=JA,dC.NodeSpace=zu,dC.TransformDirtyBit=Uu,dC.TransformBit=Uu,lC=J((cC=pC).prototype,"_lpos",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new bn}}),uC=J(cC.prototype,"_lrot",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Dn}}),hC=J(cC.prototype,"_lscale",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new bn(1,1,1)}}),_C=J(cC.prototype,"_layer",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return Ll.Enum.DEFAULT}}),fC=J(cC.prototype,"_euler",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new bn}}),J(cC.prototype,"eulerAngles",[sC],Object.getOwnPropertyDescriptor(cC.prototype,"eulerAngles"),cC.prototype),J(cC.prototype,"angle",[gh],Object.getOwnPropertyDescriptor(cC.prototype,"angle"),cC.prototype),J(cC.prototype,"layer",[gh],Object.getOwnPropertyDescriptor(cC.prototype,"layer"),cC.prototype),oC=cC))||oC));i.Node=RC;var bC=new Array(16),wC=null,IC=new qn,OC=[JA.TOUCH_START.toString(),JA.TOUCH_MOVE.toString(),JA.TOUCH_END.toString(),JA.TOUCH_CANCEL.toString()],PC=[JA.MOUSE_DOWN.toString(),JA.MOUSE_ENTER.toString(),JA.MOUSE_MOVE.toString(),JA.MOUSE_LEAVE.toString(),JA.MOUSE_UP.toString(),JA.MOUSE_WHEEL.toString()];function MC(e,t){var n=this.owner;return!(!n||!n._uiProps.uiTransformComp||(e.getUILocation(IC),!n._uiProps.uiTransformComp.isHit(IC,this)||(t.type=JA.TOUCH_START.toString(),t.touch=e,t.bubbles=!0,n.dispatchEvent(t),0)))}function NC(e,t){var n=this.owner;return!(!n||!n._uiProps.uiTransformComp||(t.type=JA.TOUCH_MOVE.toString(),t.touch=e,t.bubbles=!0,n.dispatchEvent(t),0))}function DC(e,t){var n=this.owner;n&&n._uiProps.uiTransformComp&&(e.getUILocation(IC),n._uiProps.uiTransformComp.isHit(IC,this)?t.type=JA.TOUCH_END.toString():t.type=JA.TOUCH_CANCEL.toString(),t.touch=e,t.bubbles=!0,n.dispatchEvent(t))}function BC(e,t){var n=this.owner;n&&n._uiProps.uiTransformComp&&(t.type=JA.TOUCH_CANCEL.toString(),t.touch=e,t.bubbles=!0,n.dispatchEvent(t))}function LC(e){var t=this.owner;t&&t._uiProps.uiTransformComp&&(IC=e.getUILocation(),t._uiProps.uiTransformComp.isHit(IC,this)&&(e.type=JA.MOUSE_DOWN.toString(),e.bubbles=!0,t.dispatchEvent(e)))}function FC(e){var t=this.owner;if(t&&t._uiProps.uiTransformComp){if(IC=e.getUILocation(),t._uiProps.uiTransformComp.isHit(IC,this))this._previousIn||(wC&&wC.eventProcessor.mouseListener&&(e.type=JA.MOUSE_LEAVE,wC.dispatchEvent(e),wC.eventProcessor.mouseListener&&(wC.eventProcessor.mouseListener._previousIn=!1)),wC=t,e.type=JA.MOUSE_ENTER.toString(),t.dispatchEvent(e),this._previousIn=!0),e.type=JA.MOUSE_MOVE.toString(),e.bubbles=!0,t.dispatchEvent(e);else{if(!this._previousIn)return;e.type=JA.MOUSE_LEAVE.toString(),t.dispatchEvent(e),this._previousIn=!1,wC=null}e.propagationStopped=!0}}function zC(e){var t=this.owner;t&&t._uiProps.uiTransformComp&&(IC=e.getUILocation(),t._uiProps.uiTransformComp.isHit(IC,this)&&(e.type=JA.MOUSE_UP.toString(),e.bubbles=!0,t.dispatchEvent(e),e.propagationStopped=!0))}function UC(e){var t=this.owner;t&&t._uiProps.uiTransformComp&&(IC=e.getUILocation(),t._uiProps.uiTransformComp.isHit(IC,this)&&(e.type=JA.MOUSE_WHEEL.toString(),e.bubbles=!0,t.dispatchEvent(e),e.propagationStopped=!0))}function GC(e,t){if(t){for(var n=0,i=[],r=e;r&&RC.isNode(r);r=r.parent,++n){var a=r.getComponent(t);if(a){var s={index:n,comp:a};i?i.push(s):i=[s]}}return i.length>0?i:null}return null}function kC(e,t){if(!e._persistNode){if(e.eventProcessor.bubblingTargets)for(var n=0;n=0;--i)if((n=bC[i]).eventProcessor.capturingTargets&&(t.currentTarget=n,n.eventProcessor.capturingTargets.emit(t.type,t,bC),t.propagationStopped))return void(bC.length=0);if(bC.length=0,t.eventPhase=2,t.currentTarget=e,e.eventProcessor.capturingTargets&&e.eventProcessor.capturingTargets.emit(t.type,t),!t.propagationImmediateStopped&&e.eventProcessor.bubblingTargets&&e.eventProcessor.bubblingTargets.emit(t.type,t),!t.propagationStopped&&t.bubbles)for(e.eventProcessor.getBubblingTargets(t.type,bC),t.eventPhase=3,i=0;i>>1;r<=a;s=r+a>>>1){var o=e[s],c=o.constructor._executionOrder;if(c>n)a=s-1;else if(ci)a=s-1;else{if(!(l0&&(e.array.sort(uw),this._invoke(e),e.array.length=0),this._invoke(this._zero),this._zero.array.length=0;var t=this._pos;t.array.length>0&&(t.array.sort(uw),this._invoke(t),t.array.length=0)},t}(lw),_w=function(e){function t(){return e.apply(this,arguments)||this}X(t,e);var n=t.prototype;return n.add=function(e){var t=e.constructor._executionOrder;if(0===t)this._zero.array.push(e);else{var n=t<0?this._neg.array:this._pos.array,i=ow(n,e);i<0&&n.splice(~i,0,e)}},n.remove=function(e){var t=e.constructor._executionOrder;if(0===t)this._zero.fastRemove(e);else{var n=t<0?this._neg:this._pos,i=ow(n.array,e);i>=0&&n.removeAt(i)}},n.invoke=function(e){this._neg.array.length>0&&this._invoke(this._neg,e),this._invoke(this._zero,e),this._pos.array.length>0&&this._invoke(this._pos,e)},t}(lw);function fw(e,t,n){var r="var a=it.array;for(it.i=0;it.i=0?rw(this._deferredComps,t):(!e.start||e._objFlags&aw||this.startInvoker.remove(e),e.update&&this.updateInvoker.remove(e),e.lateUpdate&&this.lateUpdateInvoker.remove(e))},t.enableComp=function(e,t){if(!(e._objFlags&sw)){if(e.onEnable){if(t)return void t.add(e);if(e.onEnable(),!e.node._activeInHierarchy)return}this._onEnabled(e)}},t.disableComp=function(e){e._objFlags&sw&&(e.onDisable&&e.onDisable(),this._onDisabled(e))},t.startPhase=function(){this._updating=!0,this.startInvoker.invoke(),this._startForNewComps()},t.updatePhase=function(e){this.updateInvoker.invoke(e)},t.lateUpdatePhase=function(e){this.lateUpdateInvoker.invoke(e),this._updating=!1,this._startForNewComps()},t._startForNewComps=function(){this._deferredComps.length>0&&(this._deferredSchedule(),this.startInvoker.invoke())},t._scheduleImmediate=function(e){"function"!=typeof e.start||e._objFlags&aw||this.startInvoker.add(e),"function"==typeof e.update&&this.updateInvoker.add(e),"function"==typeof e.lateUpdate&&this.lateUpdateInvoker.add(e)},t._deferredSchedule=function(){for(var e=this._deferredComps,t=0,n=e.length;tthis._lastUpdate?(e-this._lastUpdate)/1e3:0,this._lastUpdate=e},n.convertToGL=function(e){var t=i.game.container,n=i.view,r=t.getBoundingClientRect(),a=r.left+window.pageXOffset-t.clientLeft,s=r.top+window.pageYOffset-t.clientTop,o=n._devicePixelRatio*(e.x-a),c=n._devicePixelRatio*(s+r.height-e.y);return n._isRotated?Kn(n._viewportRect.width-c,o):Kn(o,c)},n.convertToUI=function(e){var t=i.game.container,n=i.view,r=t.getBoundingClientRect(),a=r.left+window.pageXOffset-t.clientLeft,s=r.top+window.pageYOffset-t.clientTop,o=Kn(0,0);return n._isRotated?(o.x=a+e.y/n._devicePixelRatio,o.y=s+r.height-(n._viewportRect.width-e.x)/n._devicePixelRatio):(o.x=a+e.x*n._devicePixelRatio,o.y=s+r.height-e.y*n._devicePixelRatio),o},n.end=function(){this._purgeDirectorInNextLoop=!0},n.getWinSize=function(){return ei(i.winSize)},n.getWinSizeInPixels=function(){return ei(i.winSize)},n.pause=function(){this._paused||(this._paused=!0)},n.purgeCachedData=function(){i.assetManager.releaseAll()},n.purgeDirector=function(){this._scheduler.unscheduleAll(),this._compScheduler.unscheduleAll(),this._nodeActivator.reset(),BA&&BA.setEnabled(!1),i.isValid(this._scene)&&this._scene.destroy(),this._scene=null,this.stopAnimation(),i.assetManager.releaseAll()},n.reset=function(){this.purgeDirector(),this.emit(t.EVENT_RESET),BA&&BA.setEnabled(!0),this.startAnimation()},n.runSceneImmediate=function(e,t,n){e instanceof Fx&&(e=e.scene),R(e instanceof tw,1216),e._load();for(var r=Object.keys(i.game._persistRootNodes).map((function(e){return i.game._persistRootNodes[e]})),a=0;at.length)||47===e.charCodeAt(t.length)}(r,e)||!e)for(var a=0,s=n.length;a0&&function(e){var t=Object.create(null);if(t[e._uuid]=e.refCount,Dw(e,t,Bw,-1),Bw.length=0,0!==t[e._uuid])return t[e._uuid];for(var n in t)0!==t[n]&&Dw(Uh.get(n),t,Bw,1);return Bw.length=0,t[e._uuid]}(e)>0)){Uh.remove(n);for(var i=ed.getDeps(n),r=0,a=i.length;rn?r&&r(s,o):setTimeout((function(){e(t,n,i,r,a)}),i)}))}((function(n,s){if(0===n&&a._downloading.add(e,[r]),a.limited){a._updateTime();var o=function(e,t){a._totalNum--,a._handleQueueInNextFrame(h,_),s(e,t)};a._totalNumthis._maxInterval?this._maxInterval:t;e-this._lastDate>1e3*n&&(this._totalNumThisPeriod=0,this._lastDate=e)},n._handleQueue=function(e,t){for(this._checkNextPeriod=!1,this._updateTime();this._queue.length>0&&this._totalNum0&&(At(this._handleQueue.bind(this),e,t),this._checkNextPeriod=!0)},j(e,[{key:"remoteServerAddress",get:function(){return this._remoteServerAddress}}]),e}());function oI(e,t,n,i){var r=null,a=null;try{(r=new G_)._nativeUrl=e,r._nativeAsset=t}catch(e){a=e}i(a,r)}function cI(e,t,n,i){var r=new Vx;r.json=t,i(null,r)}function lI(e,t,n,i){var r=new Hx;r.text=t,i(null,r)}function uI(e,t,n,i){var r=new Ex;r._nativeUrl=e,r._nativeAsset=t,i(null,r)}function hI(e,t,n,i){var r=new I_;r._nativeUrl=e,r._nativeAsset=t,i(null,r)}function _I(e,t,n,i){var r=Hh.get(t.name);r||(r=t.name===qh.RESOURCES?Yw:new Xw,t.base=t.base||e+"/",r.init(t)),i(null,r)}var fI=new(function(){function e(){this._creating=new Lh,this._producers={".png":oI,".jpg":oI,".bmp":oI,".jpeg":oI,".gif":oI,".ico":oI,".tiff":oI,".webp":oI,".image":oI,".pvr":oI,".pkm":oI,".txt":lI,".xml":lI,".vsh":lI,".fsh":lI,".atlas":lI,".tmx":lI,".tsx":lI,".fnt":lI,".json":cI,".ExportJson":cI,".binary":uI,".bin":uI,".dbbin":uI,".skel":uI,bundle:_I,default:hI}}var t=e.prototype;return t.register=function(e,t){"object"==typeof e?st.mixin(this._producers,e):this._producers[e]=t},t.create=function(e,t,n,i,r){var a=this,s=this._producers[n]||this._producers.default,o=Uh.get(e);if(i.reloadAsset||!o){var c=this._creating.get(e);c?c.push(r):(this._creating.add(e,[r]),s(e,t,i,(function(t,n){!t&&n instanceof I_&&(n._uuid=e,kw(e,n,i.cacheAsset));for(var r=a._creating.remove(e),s=0,o=r.length;s0){var i=Yh.create({input:s,progress:a,options:r,onProgress:e.onProgress,onError:Yh.prototype.recycle,onComplete:function(r){var a;r||((a=e.output).push.apply(a,i.output),i.recycle()),n&&mI(e),t(r)}});Wh.async(i)}else n&&mI(e),t()}))}function mI(e){for(var t=e.output,n=0,i=t.length;n6||c<3||c>6||l<3||l>6)&&(o<4||7===o||9===o||11===o||o>12||c<4||7===c||9===c||11===c||c>12||1!==l))throw new Error("Invalid block number in ASTC header");var u=function(e,t){return 4===e?O_.RGBA_ASTC_4x4:5===e?4===t?O_.RGBA_ASTC_5x4:O_.RGBA_ASTC_5x5:6===e?5===t?O_.RGBA_ASTC_6x5:O_.RGBA_ASTC_6x6:8===e?5===t?O_.RGBA_ASTC_8x5:6===t?O_.RGBA_ASTC_8x6:O_.RGBA_ASTC_8x8:10===e?5===t?O_.RGBA_ASTC_10x5:6===t?O_.RGBA_ASTC_10x6:8===t?O_.RGBA_ASTC_10x8:O_.RGBA_ASTC_10x10:10===t?O_.RGBA_ASTC_12x10:O_.RGBA_ASTC_12x12}(o,c),h=s[7]+(s[8]<<8)+(s[9]<<16),_=s[10]+(s[11]<<8)+(s[12]<<16);s[13],s[14],s[15],r={_data:new Uint8Array(a,16),_compressed:!0,width:h,height:_,format:u}}catch(e){i=e}n(i,r)},t.parsePlist=function(e,t,n){var i=null,r=vI.parse(e);r||(i=new Error("parse failed")),n(i,r)},t.parseImport=function(e,t,n){if(e){var i=null,r=null;try{i=Jf(e,t)}catch(e){r=e}n(r,i)}else n(new Error("The json file of asset "+t.__uuid__+" is empty or missing"))},t.init=function(){this._parsing.clear()},t.register=function(e,t){"object"==typeof e?He(this._parsers,e):this._parsers[e]=t},t.parse=function(e,t,n,i,r){var a=this,s=kh.get(e);if(s)r(null,s);else{var o=this._parsing.get(e);if(o)o.push(r);else{var c=this._parsers[n];c?(this._parsing.add(e,[r]),c(t,i,(function(t,n){t?Gh.remove(e):i_(n)||kh.add(e,n);for(var i=a._parsing.remove(e),r=0,s=i.length;r1){var l=Object.create(null);t.forEach((function(e){l[e._uuid]=e})),r={isCompleted:NI,_map:l}}else r=t[0]}n&&n(e,r)}))},t.getXMLHttpRequest=function(){return new XMLHttpRequest},t.getItem=function(e){return OI.assets.has(e)?{content:OI.assets.get(e)}:null},t.loadRes=function(e,t,n,i){var r=this._parseLoadResArgs(t,n,i),a=r.type,s=r.onProgress,o=r.onComplete,c=B(e);c&&!Yw.getInfoWithPath(e,a)&&(e=e.slice(0,-c.length)),Yw.load(e,a,s,o)},t.loadResArray=function(e,t,n,i){var r=this._parseLoadResArgs(t,n,i),a=r.type,s=r.onProgress,o=r.onComplete;e.forEach((function(t,n){var i=B(t);i&&!Yw.getInfoWithPath(t,a)&&(e[n]=t.slice(0,-i.length))})),Yw.load(e,a,s,o)},t.loadResDir=function(e,t,n,i){var r=this._parseLoadResArgs(t,n,i),a=r.type,s=r.onProgress,o=r.onComplete;Yw.loadDir(e,a,s,(function(t,n){var i=[];t||(i=Yw.getDirWithPath(e,a).map((function(e){return e.path}))),o&&o(t,n,i)}))},t.getRes=function(e,t){return Uh.has(e)?Uh.get(e):Yw.get(e,t)},t.getResCount=function(){return Uh.count},t.getDependsRecursively=function(e){if(!e)return[];var t="string"==typeof e?e:e._uuid;return ed.getDepsRecursively(t).concat([t])},t.addDownloadHandlers=function(e){var t=Object.create(null),n=function(n){var i=e[n];t["."+n]=function(e,t,n){i({url:e},n)}};for(var i in e)n(i);sI.register(t)},t.addLoadHandlers=function(e){var t=Object.create(null),n=function(n){var i=e[n];t["."+n]=function(e,t,n){i({content:e},n)}};for(var i in e)n(i);SI.register(t)},t.release=function(e){if(Array.isArray(e))for(var t=0;t1?n-1:0),r=1;r=this._materials.length?null:this._materials[e]},n.setMaterial=function(e,t){e&&e instanceof sm&&console.error("Can't set a material instance to a sharedMaterial slot"),this._materials[t]=e;var n=this._materialInstances[t];n?n.parent!==this._materials[t]&&(n.destroy(),this._materialInstances[t]=null,this._onMaterialModified(t,this._materials[t])):this._onMaterialModified(t,this._materials[t])},n.getMaterialInstance=function(e){if(!this._materials[e])return null;if(!this._materialInstances[e]){FP.parent=this._materials[e],FP.owner=this,FP.subModelIdx=e;var t=new sm(FP);this.setMaterialInstance(e,t)}return this._materialInstances[e]},n.setMaterialInstance=function(e,t){t&&t.parent?t!==this._materialInstances[e]&&(this._materialInstances[e]=t,this._onMaterialModified(e,t)):t!==this._materials[e]&&this.setMaterial(t,e)},n.getRenderMaterial=function(e){return this._materialInstances[e]||this._materials[e]},n._collectModels=function(){return this._models},n._attachToScene=function(){},n._detachFromScene=function(){},n._onMaterialModified=function(){},n._onRebuildPSO=function(){},n._clearMaterials=function(){},n._onVisibilityChange=function(){},j(t,[{key:"visibility",get:function(){return this._visFlags},set:function(e){this._visFlags=e,this._onVisibilityChange(e)}},{key:"sharedMaterials",get:function(){return this._materials},set:function(e){for(var t=0;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(a,e)}}:{set:function(e){t.setUniform(a,e)}}}if(r===Ed.SAMPLER){var s=Jd.getBindingFromHandle(n),o=t.properties[this.uniformName],c=o&&o.value?o.value+"-texture":Md(o.type),l=Xd.get(c);return l||(_("Illegal texture default value: "+c+"."),l=Xd.get("default-texture")),{set:function(e){e||(e=l);var n=e.getGFXTexture();n&&n.width&&n.height&&(t.bindTexture(s,n),e instanceof of&&t.bindSampler(s,af.getSampler(i.game._gfxDevice,e.getSamplerHash())))}}}throw new Error("Animations are not available for uniforms with property type "+r+".")},e}(),VP=J((HP=qP).prototype,"passIndex",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),WP=J(HP.prototype,"uniformName",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return""}}),jP=J(HP.prototype,"channelIndex",[Ph],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){}}),kP=HP))||kP,cM=ih("cc.animation.MorphWeightsValueProxy")(($P=function(){function e(){Q(this,"subMeshIndex",JP,this)}return e.prototype.forTarget=function(e){var t=this;return{set:function(n){e.setWeights(n,t.subMeshIndex)}}},e}(),JP=J((QP=$P).prototype,"subMeshIndex",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),ZP=QP))||ZP,lM=ih("cc.animation.MorphWeightsAllValueProxy")(eM=function(){function e(){}return e.prototype.forTarget=function(e){return{set:function(t){for(var n,i,r=null!==(n=null===(i=e.mesh)||void 0===i?void 0:i.struct.primitives.length)&&void 0!==n?n:0,a=0;a>>1;i<=r;a=i+r>>>1){var s=e[a];if(s>t+n)r=a-1;else{if(!(s1?1:T),x=2*AM(E);return i=x*vM(A*(1/3))-f,r=x*vM((A+EM)*(1/3))-f,a=x*vM((A+2*EM)*(1/3))-f,i>=0&&i<=1?r>=0&&r<=1?a>=0&&a<=1?SM(i,r,a):SM(i,r):a>=0&&a<=1?SM(i,a):i:r>=0&&r<=1?a>=0&&a<=1?SM(r,a):r:a}if(0===y)return r=-(n=v<0?AM(-v):-AM(v))-f,(i=2*n-f)>=0&&i<=1?r>=0&&r<=1?SM(i,r):i:r;var C=TM(y);return(n=AM(-v+C))-AM(v+C)-f}(e,t),i=e[1];return((1-n)*(i+(e[3]-i)*n)*3+n*n)*n}i.bezierByTime=xM;var CM=e("RatioSampler",function(){function e(e){var t,n;this.ratios=void 0,this._findRatio=void 0,this.ratios=e;for(var i=!0,r=1,a=e.length;r1e-6){i=!1;break}this._findRatio=i?IM:mM}return e.prototype.sample=function(e){return this._findRatio(this.ratios,e)},e}());i.RatioSampler=CM;var RM=e("AnimCurve",function(){function e(t,n){this.types=void 0,this.type=null,this._values=[],this._lerp=void 0,this._duration=void 0,this._array=void 0,this._duration=n,this._values=t.values;var i=function(t){return"string"==typeof t?t:Array.isArray(t)?t[0]===t[1]&&t[2]===t[3]?e.Linear:e.Bezier(t):e.Linear};if(void 0!==t.easingMethod)this.type=i(t.easingMethod);else if(Array.isArray(t.easingMethods))this.types=t.easingMethods.map(i);else if(void 0!==t.easingMethods){this.types=new Array(this._values.length).fill(null);for(var r=0,a=Object.keys(t.easingMethods);r=t.ratios.length))return e.valueBetween(n,i-1,t.ratios[i-1],i,t.ratios[i]);i=t.ratios.length-1}return e.valueAt(i)}function wM(e,t){if("string"==typeof t){var n=rg[t];n?e=n(e):A(3906,t)}else Array.isArray(t)&&(e=xM(t,e));return e}function IM(e,t){var n=e.length-1;if(0===n)return 0;var i=e[0];if(tr)return n;var a=(t=(t-i)/(r-i))/(1/n),s=0|a;return a-s<1e-6?s:s+1-a<1e-6?s+1:~(s+1)}RM.Linear=null,i.AnimCurve=RM,e("EventInfo",function(){function e(){this.events=[]}return e.prototype.add=function(e,t){this.events.push({func:e||"",params:t||[]})},e}()),i.sampleAnimationCurve=bM;var OM,PM,MM,NM,DM,BM,LM,FM,zM,UM,GM,kM,HM,VM,WM=function(){function e(e,t,n,i){return e.lerp(t,n,i)}return function(t){if(null!==t){if("number"==typeof t)return un;if("object"==typeof t&&t.constructor){if(t instanceof Dn)return n=new Dn,function(e,t,i){return Dn.slerp(n,e,t,i)};if(t instanceof _t)return function(e){var t=new e;return function(n,i,r){return e.lerp(t,n,i,r),t}}(t.constructor);if(t.constructor===Number)return un;if("function"==typeof t.lerp)return e}var n}}}(),jM=e("SkelAnimDataHub",function(){function e(){}return e.getOrExtract=function(t){var n=e.pool.get(t);return n&&n.info.sample===t.sample||(n&&i.director.root.dataPoolManager.releaseAnimationClip(t),n=function(e){var t={};e.curves.forEach((function(e){if(!e.valueAdapter&&GP(e.modifiers[0],XP)&&UP(e.modifiers[1])){var n=e.modifiers[0].path,i=t[n];i||(i=t[n]={}),i[e.modifiers[1]]={values:e.data.values,keys:e.data.keys}}}));for(var n=Math.ceil(e.sample*e.duration)+1,i=function(){var i=a[r],s=t[i];if(!s)return"continue";Object.defineProperty(s,"worldMatrix",{get:function(){if(!s._worldMatrix){var r=s.position,a=s.rotation,o=s.scale;qM(e,r,n),qM(e,a,n),qM(e,o,n),function(e,t,n){var i=n.position.values,r=n.rotation.values,a=n.scale.values,s=i.map((function(){return new Hn})),o=t.lastIndexOf("/"),c=null;if(o>0){var l=e[t.substring(0,o)];if(!l)return void console.warn("no data for parent bone?");c=l.worldMatrix.values}for(var u=0;ui.length-1?c=i[o=i.length-1]:0===o&&(o=1);var l=t.values[o-1].clone(),u=i[o]-i[o-1],h=u?ln((c-i[o-1])/u):1;a?l.slerp(t.values[o],h):l.lerp(t.values[o],h),r[s]=l}else for(var _=0;_0||(delete n.properties[t],function(e){return!(e.properties.position||e.properties.rotation||e.properties.eulerAngles||e.properties.scale)}(n)&&this._nodeBlendStates.delete(e)))}},t.apply=function(){this._nodeBlendStates.forEach((function(e,t){if(e.dirty){e.dirty=!1;var n,i,r,a=e.properties,s=a.position,o=a.scale,c=a.rotation,l=a.eulerAngles,u=!1;s&&0!==s.weight&&(s.weight=0,n=s.value,u=!0),o&&0!==o.weight&&(o.weight=0,i=o.value,u=!0),c&&0!==c.weight&&(c.weight=0,r=c.value,u=!0),l&&0!==l.weight&&(l.weight=0,r=l.value,u=!0),u&&t.setRTS(r,n,i)}})),this._states.forEach((function(e){e.onBlendFinished()}))},t.bindState=function(e){this._states.add(e)},t.unbindState=function(e){this._states.delete(e)},e}();function eN(e){return!function(e){return"rotation"===e}(e)}var tN,nN=function(){function e(e,t){this.weight=0,this.value=void 0,this.refCount=0,this._node=void 0,this._node=e,this.value=t}return e.prototype.markAsDirty=function(){this._node.dirty=!0},e}();function iN(e,t,n){return 0===n.weight&&bn.zero(n.value),0===t?n.value:1===t?bn.copy(n.value,e):bn.scaleAndAdd(n.value,n.value,e,t)}function rN(e,t,n){if(0===n.weight&&Dn.identity(n.value),0===t)return n.value;if(1===t)return Dn.copy(n.value,e);var i=t/(n.weight+t);return Dn.slerp(n.value,n.value,e,i)}!function(e){e.PLAY="play",e.STOP="stop",e.PAUSE="pause",e.RESUME="resume",e.LASTFRAME="lastframe",e.FINISHED="finished"}(tN||(tN={})),ht(tN);var aN=function(){function e(e,t,n){this.commonTargetIndex=void 0,this._curve=void 0,this._boundTarget=void 0,this._rootTargetProperty=void 0,this._curveDetail=void 0,this._curve=e.curve,this._curveDetail=e,this._boundTarget=n}var t=e.prototype;return t.applySample=function(e,t,n,i,r){var a;this._curve.empty()||(a=this._curve.hasLerp()&&n?this._curve.valueBetween(e,i.from,i.fromRatio,i.to,i.toRatio):this._curve.valueAt(t),this._setValue(a,r))},t._setValue=function(e){this._boundTarget.setValue(e)},j(e,[{key:"propertyName",get:function(){return this._rootTargetProperty||""}},{key:"curveDetail",get:function(){return this._curveDetail}}]),e}(),sN=e("AnimationState",function(e){function t(t,n){var i;return void 0===n&&(n=""),(i=e.call(this)||this).duration=1,i.speed=1,i.time=0,i.weight=0,i.frameRate=0,i._targetNode=null,i._curveLoaded=!1,i._clip=void 0,i._process=i.process,i._samplerSharedGroups=[],i._target=null,i._ignoreIndex=-1,i._commonTargetStatuses=[],i._wrapMode=dl.Normal,i._repeatCount=1,i._delay=0,i._delayTime=0,i._currentFramePlayed=!1,i._name=void 0,i._lastIterations=void 0,i._lastWrapInfo=null,i._lastWrapInfoEvent=null,i._wrappedInfo=new gl,i._blendStateBuffer=null,i._blendStateWriters=[],i._allowLastFrame=!1,i._blendStateWriterHost={weight:0,enabled:!1},i._clip=t,i._name=n||t&&t.name,i}X(t,e),j(t,[{key:"clip",get:function(){return this._clip}},{key:"name",get:function(){return this._name}},{key:"length",get:function(){return this.duration}},{key:"wrapMode",get:function(){return this._wrapMode},set:function(e){this._wrapMode=e,this.time=0,e&fl.Loop?this.repeatCount=1/0:this.repeatCount=1}},{key:"repeatCount",get:function(){return this._repeatCount},set:function(e){this._repeatCount=e;var t=this._wrapMode&fl.ShouldWrap,n=(this.wrapMode&fl.Reverse)===fl.Reverse;this._process=e!==1/0||t||n?this.process:this.simpleProcess}},{key:"delay",get:function(){return this._delay},set:function(e){this._delayTime=this._delay=e}},{key:"current",get:function(){return this.getWrappedInfo(this.time).time}},{key:"ratio",get:function(){return this.current/this.duration}}]);var n=t.prototype;return n.initialize=function(e,t){var n,r,a=this;if(!this._curveLoaded){this._curveLoaded=!0,this._destroyBlendStateWriters(),this._samplerSharedGroups.length=0,this._blendStateBuffer=null!==(n=null===(r=i.director.getAnimationManager())||void 0===r?void 0:r.blendState)&&void 0!==n?n:null,this._blendStateBuffer&&this._blendStateBuffer.bindState(this),this._targetNode=e;var s=this._clip;this.duration=s.duration,this.speed=s.speed,this.wrapMode=s.wrapMode,this.frameRate=s.sample,(this.wrapMode&fl.Loop)===fl.Loop?this.repeatCount=1/0:this.repeatCount=1;var o=function(e,t,n,i,r){if(!function(e){var t;if(1===e.length&&"string"==typeof e[0])t=e[0];else if(e.length>1){for(var n=0;n0&&(this._delayTime-=e,this._delayTime>0)||(this._currentFramePlayed?this.time+=e*this.speed:this._currentFramePlayed=!0,this._process())},n.sample=function(){var e=this.getWrappedInfo(this.time,this._wrappedInfo);return this._sampleCurves(e.ratio),this._sampleEvents(e),e},n.onPlay=function(){this.setTime(0),this._delayTime=this._delay,this._onReplayOrResume(),this.emit(tN.PLAY,this)},n.onStop=function(){this.isPaused||this._onPauseOrStop(),this.emit(tN.STOP,this)},n.onResume=function(){this._onReplayOrResume(),this.emit(tN.RESUME,this)},n.onPause=function(){this._onPauseOrStop(),this.emit(tN.PAUSE,this)},n._sampleCurves=function(e){this._blendStateWriterHost.weight=this.weight,this._blendStateWriterHost.enabled=!0;for(var t=0;t=s.ratios.length?c=s.ratios.length-1:(l=!0,o.from=c-1,o.fromRatio=s.ratios[o.from],o.to=c,o.toRatio=s.ratios[o.to],c=o.from)):c=0;for(var u=0,h=a.curves.length;u1&&(0|t.iterations)>(0|e.iterations)&&this.emit(tN.LASTFRAME,this),e.set(t)),t.stopped&&(this.stop(),this.emit(tN.FINISHED,this))},n.simpleProcess=function(){var e=this.duration,t=this.time%e;t<0&&(t+=e);var n=t/e;this._sampleCurves(n),this._clip.hasEvents()&&this._sampleEvents(this.getWrappedInfo(this.time,this._wrappedInfo)),this._allowLastFrame&&(void 0===this._lastIterations&&(this._lastIterations=n),(this.time>0&&this._lastIterations>n||this.time<0&&this._lastIterations0&&(e-=1),1&e&&(n=!n)),(t&fl.Reverse)===fl.Reverse&&(n=!n),n},n.getWrappedInfo=function(e,t){t=t||new gl;var n=!1,i=this.duration,r=this.repeatCount,a=e>0?e/i:-e/i;if(a>=r){a=r,n=!0;var s=r-(0|r);0===s&&(s=1),e=s*i*(e>0?1:-1)}if(e>i){var o=e%i;e=0===o?i:o}else e<0&&0!=(e%=i)&&(e+=i);var c=!1,l=this._wrapMode&fl.ShouldWrap;l&&(c=this._needReverse(a));var u=c?-1:1;return this.speed<0&&(u*=-1),l&&c&&(e=i-e),t.ratio=e/i,t.time=e,t.direction=u,t.stopped=n,t.iterations=a,t},n._sampleEvents=function(e){var t=this._clip.eventGroups.length,n=e.direction,r=this._clip.getEventGroupIndexAtRatio(e.ratio);if(r<0&&(r=~r-1,n<0&&(r+=1)),this._ignoreIndex!==r&&(this._ignoreIndex=-1),e.frameIndex=r,!this._lastWrapInfoEvent)return this._fireEvent(r),void(this._lastWrapInfoEvent=new gl(e));var a=this.wrapMode,s=oN(e.iterations),o=this._lastWrapInfoEvent,c=oN(o.iterations),l=o.frameIndex,u=o.direction,h=-1!==c&&s!==c;if(l===r&&h&&1===t)this._fireEvent(0);else if(l!==r||h){n=u;do{if(l!==r){if(-1===n&&0===l&&r>0?((a&fl.PingPong)===fl.PingPong?n*=-1:l=t,c++):1===n&&l===t-1&&rs)break}l+=n,i.director.getAnimationManager().pushDelayEvent(this._fireEvent,this,[l])}while(l!==r&&l>-1&&l=t.length||this._ignoreIndex===e))for(var n,i=t[e],r=this._targetNode.components,a=Z(i.events);!(n=a()).done;)for(var s,o=n.value,c=o.functionName,l=Z(r);!(s=l()).done;){var u=s.value,h=u[c];"function"==typeof h&&h.apply(u,o.parameters)}}},n._onReplayOrResume=function(){i.director.getAnimationManager().addAnimation(this)},n._onPauseOrStop=function(){i.director.getAnimationManager().removeAnimation(this)},n._destroyBlendStateWriters=function(){for(var e=0;e=s.easeDuration){r=a+1,s.easeTime=s.easeDuration;break}}if(r!==this._fadings.length){for(var l=r;l=0||(this._clips.push(e),this.createState(e)))}}]),t}(T_(Kf)),AN.EventType=tN,J((yN=xN).prototype,"clips",[_N,fN],Object.getOwnPropertyDescriptor(yN.prototype,"clips"),yN.prototype),J(yN.prototype,"defaultClip",[dN,pN],Object.getOwnPropertyDescriptor(yN.prototype,"defaultClip"),yN.prototype),SN=J(yN.prototype,"playOnLoad",[ch,mN],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!1}}),EN=J(yN.prototype,"_clips",[gN],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return[]}}),TN=J(yN.prototype,"_defaultClip",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),vN=yN))||vN)||vN)||vN)||vN)||vN));function bN(e,t){return e===t||!(!e||!t||e.name!==t.name&&e._uuid!==t._uuid)}se(RN.prototype,"Animation",[{name:"getAnimationState",newName:"getState"},{name:"addClip",newName:"createState"},{name:"removeClip",newName:"removeState",customFunction:function(){var e=arguments.length<=0?void 0:arguments[0];return RN.prototype.removeState.call(this,e.name)}}]),i.AnimationComponent=RN,st.setClassAlias(RN,"cc.AnimationComponent");var wN,IN,ON,PN=[],MN=new Map;function NN(e,t){for(var n=0,i=Hn.IDENTITY;e;){if(e.stamp===t||e.stamp+1===t&&!e.node.hasChangedFlags){i=e.world,e.stamp=t;break}e.stamp=t,PN[n++]=e,e=e.parent}for(;n>0;){var r=(e=PN[--n]).node;Hn.fromRTS(e.local,r.rotation,r.position,r.scale),i=Hn.multiply(e.world,i,e.local)}return i}function DN(e,t){for(var n,i=null,r=0;e!==t;){var a=e.uuid;if(MN.has(a)){i=MN.get(a);break}i={node:e,local:new Hn,world:new Hn,stamp:-1,parent:null},MN.set(a,i),PN[r++]=i,e=e.parent,i=null}for(;r>0;)(n=PN[--r]).parent=i,i=n;return i}function BN(e){for(var t=MN.get(e.uuid)||null;t;)MN.delete(t.node.uuid),t=t.parent}var LN=e("AnimationManager",ih((ON=IN=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r=0?this._anims.fastRemoveAt(t):A(3907)},n.pushDelayEvent=function(e,t,n){this._delayEvents.push({fn:e,thisArg:t,args:n})},n.addSockets=function(e,t){for(var n=this,i=function(i){var r=t[i];if(n._sockets.find((function(e){return e.target===r.target})))return"continue";var a=e.getChildByPath(r.path),s=r.target&&a&&DN(a,e);s&&n._sockets.push({target:r.target,transform:s})},r=0;r=0&&M.gpuDescriptors[N],B=null,L=0;if(D&&D.gpuBuffer){var F=D.gpuBuffer,z=I[P.set],U=z&&z[P.binding];U>=0&&(L=r[U]),"vf32"in F?B=F.vf32:(L+=F.offset,B=F.gpuBuffer.vf32),L>>=2}if(B)for(var G=P.glActiveUniforms.length,k=0;k=0&&Le.gpuDescriptors[Fe],Ue=Be.units.length,Ge=0;Ge0){var He=ze.gpuTexture,Ve=v.glTexUnits[ke];Ve.glTexture!==He.glTexture&&(v.texUnit!==ke&&(g.activeTexture(g.TEXTURE0+ke),v.texUnit=ke),He.glTexture?g.bindTexture(He.glTarget,He.glTexture):g.bindTexture(He.glTarget,e.nullTex2D.gpuTexture.glTexture),Ve.glTexture=He.glTexture);var We=ze.gpuSampler;He.isPowerOf2?(d=We.glWrapS,p=We.glWrapT):(d=g.CLAMP_TO_EDGE,p=g.CLAMP_TO_EDGE),m=He.isPowerOf2?He.mipLevel<=1&&(We.glMinFilter===g.LINEAR_MIPMAP_NEAREST||We.glMinFilter===g.LINEAR_MIPMAP_LINEAR)?g.LINEAR:We.glMinFilter:We.glMinFilter===g.LINEAR||We.glMinFilter===g.LINEAR_MIPMAP_NEAREST||We.glMinFilter===g.LINEAR_MIPMAP_LINEAR?g.LINEAR:g.NEAREST,He.glWrapS!==d&&(v.texUnit!==ke&&(g.activeTexture(g.TEXTURE0+ke),v.texUnit=ke),g.texParameteri(He.glTarget,g.TEXTURE_WRAP_S,d),He.glWrapS=d),He.glWrapT!==p&&(v.texUnit!==ke&&(g.activeTexture(g.TEXTURE0+ke),v.texUnit=ke),g.texParameteri(He.glTarget,g.TEXTURE_WRAP_T,p),He.glWrapT=p),He.glMinFilter!==m&&(v.texUnit!==ke&&(g.activeTexture(g.TEXTURE0+ke),v.texUnit=ke),g.texParameteri(He.glTarget,g.TEXTURE_MIN_FILTER,m),He.glMinFilter=m),He.glMagFilter!==We.glMagFilter&&(v.texUnit!==ke&&(g.activeTexture(g.TEXTURE0+ke),v.texUnit=ke),g.texParameteri(He.glTarget,g.TEXTURE_MAG_FILTER,We.glMagFilter),He.glMagFilter=We.glMagFilter)}ze=Le.gpuDescriptors[++Fe]}else f("Sampler binding '"+Be.name+"' at set "+Be.set+" binding "+Be.binding+" index "+Ge+" is not bounded")}}if(n&&y&&(S||SD.gpuInputAssembler!==n)){SD.gpuInputAssembler=n;var je=e.ANGLE_instanced_arrays;if(e.useVAO){var qe=e.OES_vertex_array_object,Xe=n.glVAOs.get(y.glProgram);if(!Xe){var Ye;Xe=qe.createVertexArrayOES(),n.glVAOs.set(y.glProgram,Xe),qe.bindVertexArrayOES(Xe),g.bindBuffer(g.ARRAY_BUFFER,null),g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,null),v.glArrayBuffer=null,v.glElementArrayBuffer=null;for(var Ke=y.glInputs.length,Ze=0;Ze=0&&(g.enableVertexAttribArray(dt),v.glEnabledAttribLocs[dt]=!0),v.glCurrentAttribLocs[dt]=!0,g.vertexAttribPointer(dt,lt.count,lt.glType,lt.isNormalized,lt.stride,pt),je&&je.vertexAttribDivisorANGLE(dt,lt.isInstanced?1:0)}}}var mt=n.gpuIndexBuffer;mt&&v.glElementArrayBuffer!==mt.glBuffer&&(g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,mt.glBuffer),v.glElementArrayBuffer=mt.glBuffer);for(var gt=0;gt0){var u=c.firstIndex*l.stride;i.drawElementsInstancedANGLE(a,c.indexCount,r.glIndexType,u,c.instanceCount)}}else c.vertexCount>0&&i.drawArraysInstancedANGLE(a,c.firstVertex,c.vertexCount,c.instanceCount);else if(l){if(c.indexCount>0){var h=c.firstIndex*l.stride;n.drawElements(a,c.indexCount,r.glIndexType,h)}}else c.vertexCount>0&&n.drawArrays(a,c.firstVertex,c.vertexCount)}else{var _=r.gpuIndexBuffer;if(t.instanceCount&&i)if(_){if(t.indexCount>0){var f=t.firstIndex*_.stride;i.drawElementsInstancedANGLE(a,t.indexCount,r.glIndexType,f,t.instanceCount)}}else t.vertexCount>0&&i.drawArraysInstancedANGLE(a,t.firstVertex,t.vertexCount,t.instanceCount);else if(_){if(t.indexCount>0){var d=t.firstIndex*_.stride;n.drawElements(a,t.indexCount,r.glIndexType,d)}}else t.vertexCount>0&&n.drawArrays(a,t.firstVertex,t.vertexCount)}}var xD=new Array(oD.COUNT);function CD(e,t){xD.fill(0);for(var n=0;n0&&(this._uniformBuffer=new Uint8Array(this._size)),this._gpuBuffer={usage:this._usage,memUsage:this._memUsage,size:this._size,stride:this._stride,buffer:this._bakcupBuffer,vf32:null,indirects:[],glTarget:0,glBuffer:null},e.usage&Ua.INDIRECT&&(this._gpuBuffer.indirects=this._indirectBuffer.drawInfos),this._usage&Ua.UNIFORM&&(this._gpuBuffer.buffer=this._uniformBuffer),function(e,t){var n=e.gl,i=e.stateCache,r=t.memUsage&Ga.HOST?n.DYNAMIC_DRAW:n.STATIC_DRAW;if(t.usage&Ua.VERTEX){t.glTarget=n.ARRAY_BUFFER;var a=n.createBuffer();a&&(t.glBuffer=a,t.size>0&&(e.useVAO&&i.glVAO&&(e.OES_vertex_array_object.bindVertexArrayOES(null),i.glVAO=SD.gpuInputAssembler=null),e.stateCache.glArrayBuffer!==t.glBuffer&&(n.bindBuffer(n.ARRAY_BUFFER,t.glBuffer),e.stateCache.glArrayBuffer=t.glBuffer),n.bufferData(n.ARRAY_BUFFER,t.size,r),n.bindBuffer(n.ARRAY_BUFFER,null),e.stateCache.glArrayBuffer=null))}else if(t.usage&Ua.INDEX){t.glTarget=n.ELEMENT_ARRAY_BUFFER;var s=n.createBuffer();s&&(t.glBuffer=s,t.size>0&&(e.useVAO&&i.glVAO&&(e.OES_vertex_array_object.bindVertexArrayOES(null),i.glVAO=SD.gpuInputAssembler=null),e.stateCache.glElementArrayBuffer!==t.glBuffer&&(n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t.glBuffer),e.stateCache.glElementArrayBuffer=t.glBuffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.size,r),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null),e.stateCache.glElementArrayBuffer=null))}else t.usage&Ua.UNIFORM?(t.glTarget=n.NONE,t.buffer&&(t.vf32=new Float32Array(t.buffer.buffer))):(t.usage&Ua.INDIRECT||t.usage&Ua.TRANSFER_DST||t.usage&Ua.TRANSFER_SRC||console.error("Unsupported BufferType, create buffer failed."),t.glTarget=n.NONE)}(this._device,this._gpuBuffer),this._device.memoryStatus.bufferSize+=this._size;return!0},n.destroy=function(){var e,t;this._gpuBuffer&&(e=this._device,(t=this._gpuBuffer).glBuffer&&(e.gl.deleteBuffer(t.glBuffer),t.glBuffer=null),this._device.memoryStatus.bufferSize-=this._size,this._gpuBuffer=null),this._gpuBufferView&&(this._gpuBufferView=null),this._bakcupBuffer=null},n.resize=function(e){if(this._isBufferView)console.warn("cannot resize buffer views!");else{var t=this._size;if(t!==e){if(this._size=e,this._count=this._size/this._stride,this._bakcupBuffer){var n=this._bakcupBuffer;this._bakcupBuffer=new Uint8Array(this._size),this._bakcupBuffer.set(n),this._device.memoryStatus.bufferSize-=t,this._device.memoryStatus.bufferSize+=e}this._uniformBuffer&&(this._uniformBuffer=new Uint8Array(e)),this._gpuBuffer&&(this._uniformBuffer?this._gpuBuffer.buffer=this._uniformBuffer:this._bakcupBuffer&&(this._gpuBuffer.buffer=this._bakcupBuffer),this._gpuBuffer.size=e,e>0&&(function(e,t){var n=e.gl,i=e.stateCache,r=t.memUsage&Ga.HOST?n.DYNAMIC_DRAW:n.STATIC_DRAW;t.usage&Ua.VERTEX?(e.useVAO&&i.glVAO&&(e.OES_vertex_array_object.bindVertexArrayOES(null),i.glVAO=SD.gpuInputAssembler=null),e.stateCache.glArrayBuffer!==t.glBuffer&&n.bindBuffer(n.ARRAY_BUFFER,t.glBuffer),t.buffer?n.bufferData(n.ARRAY_BUFFER,t.buffer,r):n.bufferData(n.ARRAY_BUFFER,t.size,r),n.bindBuffer(n.ARRAY_BUFFER,null),e.stateCache.glArrayBuffer=null):t.usage&Ua.INDEX?(e.useVAO&&i.glVAO&&(e.OES_vertex_array_object.bindVertexArrayOES(null),i.glVAO=SD.gpuInputAssembler=null),e.stateCache.glElementArrayBuffer!==t.glBuffer&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t.glBuffer),t.buffer?n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.buffer,r):n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.size,r),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null),e.stateCache.glElementArrayBuffer=null):t.usage&Ua.UNIFORM?t.buffer&&(t.vf32=new Float32Array(t.buffer.buffer)):(t.usage&Ua.INDIRECT||t.usage&Ua.TRANSFER_DST||t.usage&Ua.TRANSFER_SRC||console.error("Unsupported BufferType, create buffer failed."),t.glTarget=n.NONE)}(this._device,this._gpuBuffer),this._device.memoryStatus.bufferSize-=t,this._device.memoryStatus.bufferSize+=e))}}},n.update=function(e,t){if(this._isBufferView)console.warn("cannot update through buffer views!");else{var n;if(n=void 0!==t?t:this._usage&Ua.INDIRECT?0:e.byteLength,this._bakcupBuffer&&e!==this._bakcupBuffer.buffer){var i=new Uint8Array(e,0,t);this._bakcupBuffer.set(i)}yD(this._device,this._gpuBuffer,e,0,n)}},j(t,[{key:"gpuBuffer",get:function(){return this._gpuBuffer}},{key:"gpuBufferView",get:function(){return this._gpuBufferView}}]),t}(Ns),wD=function(){function e(e,t){this._frees=void 0,this._freeIdx=0,this._freeCmds=void 0,this._frees=new Array(t),this._freeCmds=new u_(t);for(var n=0;nn&&(n=a.binding)}this._bindingIndices=Array(n+1).fill(-1);for(var s=this._descriptorIndices=Array(n+1).fill(-1),o=0;o0){t.glBlocks=new Array(t.blocks.length);for(var y=0;y0){t.glSamplers=new Array(t.samplers.length);for(var O=0;Oe.maxTextureSize&&A(9100,a,e.maxTextureSize),!e.WEBGL_depth_texture&&Ts[t.format].hasDepth){var s=n.createRenderbuffer();s&&t.size>0&&(t.glRenderbuffer=s,e.stateCache.glRenderbuffer!==t.glRenderbuffer&&(n.bindRenderbuffer(n.RENDERBUFFER,t.glRenderbuffer),e.stateCache.glRenderbuffer=t.glRenderbuffer),t.glInternalFmt===n.DEPTH_COMPONENT&&(t.glInternalFmt=n.DEPTH_COMPONENT16),n.renderbufferStorage(n.RENDERBUFFER,t.glInternalFmt,i,r))}else if(t.samples===ns.X1){var o=n.createTexture();if(o&&t.size>0){t.glTexture=o;var c=e.stateCache.glTexUnits[e.stateCache.texUnit];if(c.glTexture!==t.glTexture&&(n.bindTexture(n.TEXTURE_2D,t.glTexture),c.glTexture=t.glTexture),Ts[t.format].isCompressed)if(t.glInternalFmt!==QN.COMPRESSED_RGB_ETC1_WEBGL)for(var l=0;l>1),r=Math.max(1,r>>1)}else{var _=As(t.format,2,2,1),f=new Uint8Array(_);n.compressedTexImage2D(n.TEXTURE_2D,0,t.glInternalFmt,2,2,0,f)}else for(var d=0;d>1),r=Math.max(1,r>>1);t.isPowerOf2?(t.glWrapS=n.REPEAT,t.glWrapT=n.REPEAT):(t.glWrapS=n.CLAMP_TO_EDGE,t.glWrapT=n.CLAMP_TO_EDGE),t.glMinFilter=n.LINEAR,t.glMagFilter=n.LINEAR,n.texParameteri(t.glTarget,n.TEXTURE_WRAP_S,t.glWrapS),n.texParameteri(t.glTarget,n.TEXTURE_WRAP_T,t.glWrapT),n.texParameteri(t.glTarget,n.TEXTURE_MIN_FILTER,t.glMinFilter),n.texParameteri(t.glTarget,n.TEXTURE_MAG_FILTER,t.glMagFilter)}else n.deleteTexture(o)}break;case es.CUBE:t.glTarget=n.TEXTURE_CUBE_MAP;var p=Math.max(i,r);p>e.maxCubeMapTextureSize&&A(9100,p,e.maxTextureSize);var m=n.createTexture();if(m&&t.size>0){t.glTexture=m;var g=e.stateCache.glTexUnits[e.stateCache.texUnit];if(g.glTexture!==t.glTexture&&(n.bindTexture(n.TEXTURE_CUBE_MAP,t.glTexture),g.glTexture=t.glTexture),Ts[t.format].isCompressed)if(t.glInternalFmt!==QN.COMPRESSED_RGB_ETC1_WEBGL)for(var v=0;v<6;++v){i=t.width,r=t.height;for(var y=0;y>1),r=Math.max(1,r>>1)}}else for(var T=0;T<6;++T){var x=As(t.format,2,2,1),C=new Uint8Array(x);n.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+T,0,t.glInternalFmt,2,2,0,C)}else for(var R=0;R<6;++R){i=t.width,r=t.height;for(var b=0;b>1),r=Math.max(1,r>>1)}t.isPowerOf2?(t.glWrapS=n.REPEAT,t.glWrapT=n.REPEAT):(t.glWrapS=n.CLAMP_TO_EDGE,t.glWrapT=n.CLAMP_TO_EDGE),t.glMinFilter=n.LINEAR,t.glMagFilter=n.LINEAR,n.texParameteri(t.glTarget,n.TEXTURE_WRAP_S,t.glWrapS),n.texParameteri(t.glTarget,n.TEXTURE_WRAP_T,t.glWrapT),n.texParameteri(t.glTarget,n.TEXTURE_MIN_FILTER,t.glMinFilter),n.texParameteri(t.glTarget,n.TEXTURE_MAG_FILTER,t.glMagFilter)}break;default:console.error("Unsupported TextureType, create texture failed."),t.type=es.TEX2D,t.glTarget=n.TEXTURE_2D}}(this._device,this._gpuTexture),this._device.memoryStatus.textureSize+=this._size,!0)},n.destroy=function(){var e,t;this._gpuTexture&&(e=this._device,(t=this._gpuTexture).glTexture&&(e.gl.deleteTexture(t.glTexture),t.glTexture=null),t.glRenderbuffer&&(e.gl.deleteRenderbuffer(t.glRenderbuffer),t.glRenderbuffer=null),this._device.memoryStatus.textureSize-=this._size,this._gpuTexture=null),this._buffer=null},n.resize=function(e,t){var n=this._size;this._width=e,this._height=t,this._size=xs(this._format,this.width,this.height,this.depth,this._levelCount)*this._layerCount,this._gpuTexture&&(this._gpuTexture.width=e,this._gpuTexture.height=t,this._gpuTexture.size=this._size,function(e,t){var n=e.gl;t.glInternalFmt=eD(t.format,n),t.glFormat=tD(t.format,n),t.glType=$N(t.format,n);var i=t.width,r=t.height;switch(t.type){case es.TEX2D:t.glTarget=n.TEXTURE_2D;var a=Math.max(i,r);if(a>e.maxTextureSize&&A(9100,a,e.maxTextureSize),t.glRenderbuffer)e.stateCache.glRenderbuffer!==t.glRenderbuffer&&(n.bindRenderbuffer(n.RENDERBUFFER,t.glRenderbuffer),e.stateCache.glRenderbuffer=t.glRenderbuffer),n.renderbufferStorage(n.RENDERBUFFER,t.glInternalFmt,i,r);else if(t.glTexture){var s=e.stateCache.glTexUnits[e.stateCache.texUnit];if(s.glTexture!==t.glTexture&&(n.bindTexture(n.TEXTURE_2D,t.glTexture),s.glTexture=t.glTexture),Ts[t.format].isCompressed){if(t.glInternalFmt!==QN.COMPRESSED_RGB_ETC1_WEBGL)for(var o=0;o>1),r=Math.max(1,r>>1)}}else for(var u=0;u>1),r=Math.max(1,r>>1)}break;case es.CUBE:t.glTarget=n.TEXTURE_CUBE_MAP;var h=Math.max(i,r);h>e.maxCubeMapTextureSize&&A(9100,h,e.maxTextureSize);var _=e.stateCache.glTexUnits[e.stateCache.texUnit];if(_.glTexture!==t.glTexture&&(n.bindTexture(n.TEXTURE_CUBE_MAP,t.glTexture),_.glTexture=t.glTexture),Ts[t.format].isCompressed){if(t.glInternalFmt!==QN.COMPRESSED_RGB_ETC1_WEBGL)for(var f=0;f<6;++f){i=t.width,r=t.height;for(var d=0;d>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=es.TEX2D,t.glTarget=n.TEXTURE_2D}}(this._device,this._gpuTexture),this._device.memoryStatus.textureSize-=n,this._device.memoryStatus.textureSize+=this._size)},j(t,[{key:"gpuTexture",get:function(){return this._gpuTexture}}]),t}(bo),XD=e("WebGLDevice",function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r=0&&I.gpuDescriptors[O];if(P&&P.gpuBuffer){var M=R[w.set],N=M&&M[w.binding],D=P.gpuBuffer.glOffset;N>=0&&(D+=r[N]),p.glBindUBOs[w.glBinding]===P.gpuBuffer.glBuffer&&p.glBindUBOOffsets[w.glBinding]===D||(D?d.bindBufferRange(d.UNIFORM_BUFFER,w.glBinding,P.gpuBuffer.glBuffer,D,P.gpuBuffer.size):d.bindBufferBase(d.UNIFORM_BUFFER,w.glBinding,P.gpuBuffer.glBuffer),p.glUniformBuffer=p.glBindUBOs[w.glBinding]=P.gpuBuffer.glBuffer,p.glBindUBOOffsets[w.glBinding]=D)}else f("Buffer binding '"+w.name+"' at set "+w.set+" binding "+w.binding+" is not bounded")}for(var B=m.glSamplers.length,L=0;L=0&&z.gpuDescriptors[U],k=0;k0){var W=G.gpuTexture;V.glTexture!==W.glTexture&&(p.texUnit!==H&&(d.activeTexture(d.TEXTURE0+H),p.texUnit=H),W.glTexture?d.bindTexture(W.glTarget,W.glTexture):d.bindTexture(W.glTarget,e.nullTex2D.gpuTexture.glTexture),V.glTexture=W.glTexture);var j=G.gpuSampler;p.glSamplerUnits[H]!==j.glSampler&&(d.bindSampler(H,j.glSampler),p.glSamplerUnits[H]=j.glSampler)}G=z.gpuDescriptors[++U]}else f("Sampler binding '"+F.name+"' at set "+F.set+" binding "+F.binding+" index "+k+" is not bounded")}}if(n&&m&&(g||vB.gpuInputAssembler!==n))if(vB.gpuInputAssembler=n,e.useVAO){var q=n.glVAOs.get(m.glProgram);if(!q){var X;q=d.createVertexArray(),n.glVAOs.set(m.glProgram,q),d.bindVertexArray(q),d.bindBuffer(d.ARRAY_BUFFER,null),d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,null),p.glArrayBuffer=null,p.glElementArrayBuffer=null;for(var Y=0;Y=0&&(d.enableVertexAttribArray(le),p.glEnabledAttribLocs[le]=!0),p.glCurrentAttribLocs[le]=!0,d.vertexAttribPointer(le,ae.count,ae.glType,ae.isNormalized,ae.stride,ue),d.vertexAttribDivisor(le,ae.isInstanced?1:0)}}}var he=n.gpuIndexBuffer;he&&p.glElementArrayBuffer!==he.glBuffer&&(d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,he.glBuffer),p.glElementArrayBuffer=he.glBuffer);for(var _e=0;_e0){var l=o.firstIndex*c.stride;n.drawElementsInstanced(r,o.indexCount,i.glIndexType,l,o.instanceCount)}}else o.vertexCount>0&&n.drawArraysInstanced(r,o.firstVertex,o.vertexCount,o.instanceCount);else if(c){if(o.indexCount>0){var u=o.firstIndex*c.stride;n.drawElements(r,o.indexCount,i.glIndexType,u)}}else o.vertexCount>0&&n.drawArrays(r,o.firstVertex,o.vertexCount)}else if(t.instanceCount)if(i.gpuIndexBuffer){if(t.indexCount>0){var h=t.firstIndex*i.gpuIndexBuffer.stride;n.drawElementsInstanced(r,t.indexCount,i.glIndexType,h,t.instanceCount)}}else t.vertexCount>0&&n.drawArraysInstanced(r,t.firstVertex,t.vertexCount,t.instanceCount);else if(i.gpuIndexBuffer){if(t.indexCount>0){var _=t.firstIndex*i.gpuIndexBuffer.stride;n.drawElements(r,t.indexCount,i.glIndexType,_)}}else t.vertexCount>0&&n.drawArrays(r,t.firstVertex,t.vertexCount)}var TB=new Array(aB.COUNT);function AB(e,t){TB.fill(0);for(var n=0;n0&&(e.useVAO&&i.glVAO&&(n.bindVertexArray(null),i.glVAO=vB.gpuInputAssembler=null),e.stateCache.glArrayBuffer!==t.glBuffer&&(n.bindBuffer(n.ARRAY_BUFFER,t.glBuffer),e.stateCache.glArrayBuffer=t.glBuffer),n.bufferData(n.ARRAY_BUFFER,t.size,r),n.bindBuffer(n.ARRAY_BUFFER,null),e.stateCache.glArrayBuffer=null))}else if(t.usage&Ua.INDEX){t.glTarget=n.ELEMENT_ARRAY_BUFFER;var s=n.createBuffer();s&&(t.glBuffer=s,t.size>0&&(e.useVAO&&i.glVAO&&(n.bindVertexArray(null),i.glVAO=vB.gpuInputAssembler=null),e.stateCache.glElementArrayBuffer!==t.glBuffer&&(n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t.glBuffer),e.stateCache.glElementArrayBuffer=t.glBuffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.size,r),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null),e.stateCache.glElementArrayBuffer=null))}else if(t.usage&Ua.UNIFORM){t.glTarget=n.UNIFORM_BUFFER;var o=n.createBuffer();o&&t.size>0&&(t.glBuffer=o,e.stateCache.glUniformBuffer!==t.glBuffer&&(n.bindBuffer(n.UNIFORM_BUFFER,t.glBuffer),e.stateCache.glUniformBuffer=t.glBuffer),n.bufferData(n.UNIFORM_BUFFER,t.size,r),n.bindBuffer(n.UNIFORM_BUFFER,null),e.stateCache.glUniformBuffer=null)}else t.usage&Ua.INDIRECT||t.usage&Ua.TRANSFER_DST||t.usage&Ua.TRANSFER_SRC||console.error("Unsupported BufferType, create buffer failed."),t.glTarget=n.NONE}(this._device,this._gpuBuffer),this._device.memoryStatus.bufferSize+=this._size;return!0},n.destroy=function(){this._gpuBuffer&&(this._isBufferView||(function(e,t){var n=e.gl;if(t.glBuffer){switch(t.glTarget){case n.ARRAY_BUFFER:e.useVAO&&e.stateCache.glVAO&&(n.bindVertexArray(null),e.stateCache.glVAO=vB.gpuInputAssembler=null),n.bindBuffer(n.ARRAY_BUFFER,null),e.stateCache.glArrayBuffer=null;break;case n.ELEMENT_ARRAY_BUFFER:e.useVAO&&e.stateCache.glVAO&&(n.bindVertexArray(null),e.stateCache.glVAO=vB.gpuInputAssembler=null),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null),e.stateCache.glElementArrayBuffer=null;break;case n.UNIFORM_BUFFER:n.bindBuffer(n.UNIFORM_BUFFER,null),e.stateCache.glUniformBuffer=null}n.deleteBuffer(t.glBuffer),t.glBuffer=null}}(this._device,this._gpuBuffer),this._device.memoryStatus.bufferSize-=this._size),this._gpuBuffer=null),this._bakcupBuffer=null},n.resize=function(e){if(this._isBufferView)console.warn("cannot resize buffer views!");else{var t=this._size;if(t!==e){if(this._size=e,this._count=this._size/this._stride,this._bakcupBuffer){var n=this._bakcupBuffer;this._bakcupBuffer=new Uint8Array(this._size),this._bakcupBuffer.set(n),this._device.memoryStatus.bufferSize-=t,this._device.memoryStatus.bufferSize+=e}this._gpuBuffer&&(this._bakcupBuffer&&(this._gpuBuffer.buffer=this._bakcupBuffer),this._gpuBuffer.size=e,e>0&&(function(e,t){var n=e.gl,i=e.stateCache,r=t.memUsage&Ga.HOST?n.DYNAMIC_DRAW:n.STATIC_DRAW;t.usage&Ua.VERTEX?(e.useVAO&&i.glVAO&&(n.bindVertexArray(null),i.glVAO=vB.gpuInputAssembler=null),i.glArrayBuffer!==t.glBuffer&&n.bindBuffer(n.ARRAY_BUFFER,t.glBuffer),t.buffer?n.bufferData(n.ARRAY_BUFFER,t.buffer,r):n.bufferData(n.ARRAY_BUFFER,t.size,r),n.bindBuffer(n.ARRAY_BUFFER,null),i.glArrayBuffer=null):t.usage&Ua.INDEX?(e.useVAO&&i.glVAO&&(n.bindVertexArray(null),i.glVAO=vB.gpuInputAssembler=null),e.stateCache.glElementArrayBuffer!==t.glBuffer&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,t.glBuffer),t.buffer?n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.buffer,r):n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.size,r),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null),e.stateCache.glElementArrayBuffer=null):t.usage&Ua.UNIFORM?(e.stateCache.glUniformBuffer!==t.glBuffer&&n.bindBuffer(n.UNIFORM_BUFFER,t.glBuffer),n.bufferData(n.UNIFORM_BUFFER,t.size,r),n.bindBuffer(n.UNIFORM_BUFFER,null),e.stateCache.glUniformBuffer=null):(t.usage&Ua.INDIRECT||t.usage&Ua.TRANSFER_DST||t.usage&Ua.TRANSFER_SRC||console.error("Unsupported BufferType, create buffer failed."),t.glTarget=n.NONE)}(this._device,this._gpuBuffer),this._device.memoryStatus.bufferSize-=t,this._device.memoryStatus.bufferSize+=e))}}},n.update=function(e,t){if(this._isBufferView)console.warn("cannot update through buffer views!");else{var n;if(n=void 0!==t?t:this._usage&Ua.INDIRECT?0:e.byteLength,this._bakcupBuffer&&e!==this._bakcupBuffer.buffer){var i=new Uint8Array(e,0,t);this._bakcupBuffer.set(i)}gB(this._device,this._gpuBuffer,e,0,n)}},j(t,[{key:"gpuBuffer",get:function(){return this._gpuBuffer}}]),t}(Ns),bB=function(){function e(e,t){this._frees=void 0,this._freeIdx=0,this._freeCmds=void 0,this._frees=new Array(t),this._freeCmds=new u_(t);for(var n=0;nn&&(n=a.binding)}this._bindingIndices=Array(n+1).fill(-1);for(var s=this._descriptorIndices=Array(n+1).fill(-1),o=0;o0){t.glSamplers=new Array(t.samplers.length);for(var I=0;Ie.maxTextureSize&&A(9100,a,e.maxTextureSize),t.samples===ns.X1){var s=n.createTexture();if(s&&t.size>0){t.glTexture=s;var o=e.stateCache.glTexUnits[e.stateCache.texUnit];if(o.glTexture!==t.glTexture&&(n.bindTexture(n.TEXTURE_2D,t.glTexture),o.glTexture=t.glTexture),t.flags&is.IMMUTABLE)n.texStorage2D(n.TEXTURE_2D,t.mipLevel,t.glInternalFmt,i,r);else if(Ts[t.format].isCompressed)if(t.glInternalFmt!==QN.COMPRESSED_RGB_ETC1_WEBGL)for(var c=0;c>1),r=Math.max(1,r>>1)}else{var h=As(t.format,2,2,1),_=new Uint8Array(h);n.compressedTexImage2D(n.TEXTURE_2D,0,t.glInternalFmt,2,2,0,_)}else for(var f=0;f>1),r=Math.max(1,r>>1)}else n.deleteTexture(s)}else{var d=n.createRenderbuffer();d&&t.size>0&&(t.glRenderbuffer=d,e.stateCache.glRenderbuffer!==t.glRenderbuffer&&(n.bindRenderbuffer(n.RENDERBUFFER,t.glRenderbuffer),e.stateCache.glRenderbuffer=t.glRenderbuffer),n.renderbufferStorageMultisample(n.RENDERBUFFER,ZD[t.samples],t.glInternalFmt,t.width,t.height))}break;case es.CUBE:t.glTarget=n.TEXTURE_CUBE_MAP;var p=Math.max(i,r);p>e.maxCubeMapTextureSize&&A(9100,p,e.maxTextureSize);var m=n.createTexture();if(m&&t.size>0){t.glTexture=m;var g=e.stateCache.glTexUnits[e.stateCache.texUnit];if(g.glTexture!==t.glTexture&&(n.bindTexture(n.TEXTURE_CUBE_MAP,t.glTexture),g.glTexture=t.glTexture),t.flags&is.IMMUTABLE)n.texStorage2D(n.TEXTURE_CUBE_MAP,t.mipLevel,t.glInternalFmt,i,r);else if(Ts[t.format].isCompressed)if(t.glInternalFmt!==QN.COMPRESSED_RGB_ETC1_WEBGL)for(var v=0;v>1),r=Math.max(1,r>>1)}else for(var T=0;T<6;++T){var x=As(t.format,2,2,1),C=new Uint8Array(x);n.compressedTexImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+T,0,t.glInternalFmt,2,2,0,C)}else for(var R=0;R>1),r=Math.max(1,r>>1)}}break;default:console.error("Unsupported TextureType, create texture failed."),t.type=es.TEX2D,t.glTarget=n.TEXTURE_2D}}(this._device,this._gpuTexture),this._device.memoryStatus.textureSize+=this._size,!0)},n.destroy=function(){var e,t;this._gpuTexture&&(e=this._device,(t=this._gpuTexture).glTexture&&(e.gl.deleteTexture(t.glTexture),t.glTexture=null),t.glRenderbuffer&&(e.gl.deleteRenderbuffer(t.glRenderbuffer),t.glRenderbuffer=null),this._device.memoryStatus.textureSize-=this._size,this._gpuTexture=null),this._buffer=null},n.resize=function(e,t){var n=this._size;this._width=e,this._height=t,this._size=xs(this._format,this.width,this.height,this.depth,this._levelCount)*this._layerCount,this._gpuTexture&&(this._gpuTexture.width=e,this._gpuTexture.height=t,this._gpuTexture.size=this._size,function(e,t){var n=e.gl;t.glInternalFmt=$D(t.format,n),t.glFormat=eB(t.format,n),t.glType=JD(t.format,n);var i=t.width,r=t.height;switch(t.type){case es.TEX2D:t.glTarget=n.TEXTURE_2D;var a=Math.max(i,r);if(a>e.maxTextureSize&&A(9100,a,e.maxTextureSize),t.samples===ns.X1){var s=e.stateCache.glTexUnits[e.stateCache.texUnit];if(s.glTexture!==t.glTexture&&(n.bindTexture(n.TEXTURE_2D,t.glTexture),s.glTexture=t.glTexture),Ts[t.format].isCompressed){if(t.glInternalFmt!==QN.COMPRESSED_RGB_ETC1_WEBGL)for(var o=0;o>1),r=Math.max(1,r>>1)}}else for(var u=0;u>1),r=Math.max(1,r>>1)}else{var h=n.createRenderbuffer();h&&t.size>0&&(t.glRenderbuffer=h,e.stateCache.glRenderbuffer!==t.glRenderbuffer&&(n.bindRenderbuffer(n.RENDERBUFFER,t.glRenderbuffer),e.stateCache.glRenderbuffer=t.glRenderbuffer),n.renderbufferStorageMultisample(n.RENDERBUFFER,ZD[t.samples],t.glInternalFmt,t.width,t.height))}break;case es.CUBE:t.type=es.CUBE,t.glTarget=n.TEXTURE_CUBE_MAP;var _=Math.max(i,r);_>e.maxCubeMapTextureSize&&A(9100,_,e.maxTextureSize);var f=e.stateCache.glTexUnits[e.stateCache.texUnit];if(f.glTexture!==t.glTexture&&(n.bindTexture(n.TEXTURE_CUBE_MAP,t.glTexture),f.glTexture=t.glTexture),Ts[t.format].isCompressed){if(t.glInternalFmt!==QN.COMPRESSED_RGB_ETC1_WEBGL)for(var d=0;d<6;++d){i=t.width,r=t.height;for(var p=0;p>1),r=Math.max(1,r>>1)}}}else for(var v=0;v<6;++v){i=t.width,r=t.height;for(var y=0;y>1),r=Math.max(1,r>>1)}break;default:console.error("Unsupported TextureType, create texture failed."),t.type=es.TEX2D,t.glTarget=n.TEXTURE_2D}}(this._device,this._gpuTexture),this._device.memoryStatus.textureSize-=n,this._device.memoryStatus.textureSize+=this._size)},j(t,[{key:"gpuTexture",get:function(){return this._gpuTexture}}]),t}(bo),jB=e("WebGL2Device",function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r0&&(c|=s.COLOR_BUFFER_BIT),t.gpuDepthStencilTexture&&(c|=s.DEPTH_BUFFER_BIT,Ts[t.gpuDepthStencilTexture.format].hasStencil&&(c|=s.STENCIL_BUFFER_BIT));var l=a===Ja.LINEAR||a===Ja.ANISOTROPIC?s.LINEAR:s.NEAREST;s.blitFramebuffer(i.x,i.y,i.x+i.width,i.y+i.height,r.x,r.y,r.x+r.width,r.y+r.height,c,l),o&&s.bindFramebuffer(s.FRAMEBUFFER,e.stateCache.glFramebuffer)}(this,e.gpuFramebuffer,t.gpuFramebuffer,n,i,r)},n.getExtension=function(e){for(var t=["","WEBKIT_","MOZ_"],n=0;nhu.MAX_MORPH_TARGET_COUNT?this._subMeshRenderings[i]=new tL(this._mesh,i,this._mesh.struct.morph,t):this._subMeshRenderings[i]=new eL(this._mesh,i,this._mesh.struct.morph,t))}}}return e.prototype.createInstance=function(){for(var e=this,t=this._mesh.struct.primitives.length,n=new Array(t),i=0;i>1;return{width:1<<(1&t?n+1:n),height:1<=65536)return E(10001,_,65536),"continue";u>>=1,h>>=1}o=n.createBuffer(new Ps(Ua.INDEX,Ga.DEVICE,h,u)),c=new(sL(l.stride))(t,l.offset,l.count),l.stride!==u&&(c=sL(u).from(c)),e.loaded?o.update(c):e.once("load",(function(){o.update(c)}))}var f=s.vertexBundelIndices.map((function(e){return r[e]})),d=[];if(s.vertexBundelIndices.length>0)for(var p=s.vertexBundelIndices[0],m=e._struct.vertexBundles[p].attributes,g=0;g=i.length)){bn.transformMat4(cL,oL,i[d]),n[d]=!0;var p=t[d];bn.min(p.center,p.center,cL),bn.max(p.halfExtents,p.halfExtents,cL)}}}}for(var m=0;m=this._struct.primitives.length)return null;var t=this._struct.primitives[e];if(!t.indexView)return null;var n=t.indexView.stride;return new(1===n?Uint8Array:2===n?Uint16Array:Uint32Array)(this._data.buffer,t.indexView.offset,t.indexView.count)},n.copyIndices=function(e,t){if(e>=this._struct.primitives.length)return!1;var n=this._struct.primitives[e];if(!n.indexView)return!1;for(var i=n.indexView.count,r=1===n.indexView.stride?za.R8UI:2===n.indexView.stride?za.R16UI:za.R32UI,a=dL(new DataView(this._data.buffer),r),s=0;s=this._struct.primitives.length))for(var i,r=Z(this._struct.primitives[e].vertexBundelIndices);!(i=r()).done;){var a=i.value,s=this._struct.vertexBundles[a],o=s.attributes.findIndex((function(e){return e.name===t}));if(!(o<0)){n(s,o);break}}},n._createVertexBuffers=function(e,t){var n=this;return this._struct.vertexBundles.map((function(i){var r=e.createBuffer(new Ps(Ua.VERTEX,Ga.DEVICE,i.view.length,i.view.stride)),a=new Uint8Array(t,i.view.offset,i.view.length);return n.loaded?r.update(a):n.once("load",(function(){r.update(a)})),r}))},t}(I_),YB=J((XB=QB).prototype,"_struct",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return{vertexBundles:[],primitives:[]}}}),KB=J(XB.prototype,"_dataLength",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),ZB=J(XB.prototype,"_hash",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),qB=XB))||qB);function hL(e,t){for(var n=0,i=0;i0){if(i=null,e.attributes)for(var l,u=Z(e.attributes);!(l=u()).done;){var h=l.value;if(h.name===La.ATTR_POSITION){i=h;break}}i||(i=mL[0]),r.push(i);var _=Ts[i.format];o=Math.max(o,Math.floor(c.length/_.count)),s.push({offset:a,data:c,attribute:i}),a+=_.size}if(e.normals&&e.normals.length>0){if(i=null,e.attributes)for(var f,d=Z(e.attributes);!(f=d()).done;){var p=f.value;if(p.name===La.ATTR_NORMAL){i=p;break}}i||(i=mL[1]);var m=Ts[i.format];r.push(i),o=Math.max(o,Math.floor(e.normals.length/m.count)),s.push({offset:a,data:e.normals,attribute:i}),a+=m.size}if(e.uvs&&e.uvs.length>0){if(i=null,e.attributes)for(var g,v=Z(e.attributes);!(g=v()).done;){var y=g.value;if(y.name===La.ATTR_TEX_COORD){i=y;break}}i||(i=mL[2]);var S=Ts[i.format];r.push(i),o=Math.max(o,Math.floor(e.uvs.length/S.count)),s.push({offset:a,data:e.uvs,attribute:i}),a+=S.size}if(e.tangents&&e.tangents.length>0){if(i=null,e.attributes)for(var E,T=Z(e.attributes);!(E=T()).done;){var A=E.value;if(A.name===La.ATTR_TANGENT){i=A;break}}i||(i=mL[3]);var x=Ts[i.format];r.push(i),o=Math.max(o,Math.floor(e.tangents.length/x.count)),s.push({offset:a,data:e.tangents,attribute:i}),a+=x.size}if(e.colors&&e.colors.length>0){if(i=null,e.attributes)for(var C,R=Z(e.attributes);!(C=R()).done;){var b=C.value;if(b.name===La.ATTR_COLOR){i=b;break}}i||(i=mL[4]);var w=Ts[i.format];r.push(i),o=Math.max(o,Math.floor(e.colors.length/w.count)),s.push({offset:a,data:e.colors,attribute:i}),a+=w.size}if(e.customAttributes)for(var I,O=Z(e.customAttributes);!(I=O()).done;){var P=I.value,M=Ts[P.attr.format];r.push(P.attr),o=Math.max(o,Math.floor(P.values.length/M.count)),s.push({offset:a,data:P.values,attribute:P.attr}),a+=M.size}for(var N=new JB,D=new ArrayBuffer(o*a),B=new DataView(D),L=0,F=s;L0&&e.refCount--,!e.refCount&&e.readyToBeDeleted){var t=e.skeletonHash^e.clipHash;(void 0!==this._chunkIdxMap.get(t)?this._customPool:this._pool).free(e.handle),this._textureBuffers.get(t)===e&&this._textureBuffers.delete(t)}},t.releaseSkeleton=function(e){for(var t=this._textureBuffers.values(),n=t.next();!n.done;){var i=n.value;i.skeletonHash===e.hash&&(i.readyToBeDeleted=!0,i.refCount?this._textureBuffers.delete(i.skeletonHash^i.clipHash):this.releaseHandle(i)),n=t.next()}},t.releaseAnimationClip=function(e){for(var t=this._textureBuffers.values(),n=t.next();!n.done;){var i=n.value;i.clipHash===e.hash&&(i.readyToBeDeleted=!0,i.refCount?this._textureBuffers.delete(i.skeletonHash^i.clipHash):this.releaseHandle(i)),n=t.next()}},t._createAnimInfos=function(e,t,n){for(var i=[],r=e.joints,a=e.bindposes,s=r.length,o=jM.getOrExtract(t),c=0;c=0&&(t.push(r),e.push(s))}}var Qz,Jz,$z,eU,tU,nU,iU,rU,aU,sU,oU,cU,lU,uU,hU,_U,fU,dU,pU,mU,gU,vU,yU,SU,EU,TU,AU,xU,CU,RU,bU,wU,IU,OU,PU,MU,NU,DU,BU,LU,FU,zU,UU,GU,kU,HU=new bn,VU=new bn,WU=new bn,jU=new bn,qU=new Hn,XU=new al,YU=function(e){function t(){var t;return(t=e.call(this)||this).uploadAnimation=null,t._buffers=[],t._dataArray=[],t._joints=[],t._bufferIndices=null,t.type=hp.SKINNING,t}X(t,e);var n=t.prototype;return n.destroy=function(){if(this.bindSkeleton(),this._buffers.length){for(var t=0;t=0?this.instancedAttributes.views[i][0]=n.data[0]:n.dirty&&(n.buffer.update(n.data),n.dirty=!1),!0},n.uploadAnimation=function(e){if(this._skeleton&&this._mesh&&this.uploadedAnim!==e){this.uploadedAnim=e;var t=this._dataPoolManager,n=null;e?(n=t.jointTexturePool.getSequencePoseTexture(this._skeleton,e,this._mesh,this.transform),this._jointsMedium.boundsInfo=n&&n.bounds.get(this._mesh.hash),this._modelBounds=null):(n=t.jointTexturePool.getDefaultPoseTexture(this._skeleton,this._mesh,this.transform),this._jointsMedium.boundsInfo=null,this._modelBounds=n&&n.bounds.get(this._mesh.hash)[0]),this._applyJointTexture(n)}},n._applyJointTexture=function(e){void 0===e&&(e=null);var t=this._jointsMedium.texture;if(t&&t!==e&&this._dataPoolManager.jointTexturePool.releaseHandle(t),this._jointsMedium.texture=e,e){var n=this._jointsMedium,i=n.buffer,r=n.jointTextureInfo;r[0]=e.handle.texture.width,r[1]=this._skeleton.joints.length,r[2]=e.pixelOffset+.1,r[3]=1/r[0],this.updateInstancedJointTextureInfo(),i&&i.update(r);for(var a=e.handle.texture,s=0;s=0){var r=this.instancedAttributes.views[i];r[0]=n.data[0],r[1]=t[1],r[2]=t[2]}},t}(sF),QU=function(t){return e({SkinnedMeshRenderer:t,SkinningModelComponent:t}),t}((Qz=ih("cc.SkinnedMeshRenderer"),Jz=mh(),$z=ah(100),eU=_h(),tU=Dh(NF),nU=Dh(RC),iU=Dh(NF),rU=Dh(RC),aU=Sh(),Qz(sU=Jz(sU=$z(sU=hh(sU=eU((uU=function(e){function t(){var t;return Q(t=e.call(this)||this,"_skeleton",cU,Y(t)),Q(t,"_skinningRoot",lU,Y(t)),t._clip=null,t._modelType=ZU,t}X(t,e),j(t,[{key:"skeleton",get:function(){return this._skeleton},set:function(e){e!==this._skeleton&&(this._skeleton=e,this._update())}},{key:"skinningRoot",get:function(){return this._skinningRoot},set:function(e){e!==this._skinningRoot&&(this._skinningRoot=e,this._updateModelType(),this._update())}},{key:"model",get:function(){return this._model}}]);var n=t.prototype;return n.__preload=function(){this._updateModelType()},n.uploadAnimation=function(e){this._clip=e,this.model&&this.model.uploadAnimation&&this.model.uploadAnimation(e)},n.setUseBakedAnimation=function(e){void 0===e&&(e=!0);var t=e?ZU:YU;this._modelType!==t&&(this._modelType=t,this._model&&(i.director.root.destroyModel(this._model),this._model=null,this._models.length=0,this._updateModels(),this._updateCastShadow(),this.enabledInHierarchy&&this._attachToScene()))},n.setMaterial=function(t,n){e.prototype.setMaterial.call(this,t,n),this._modelType===YU&&this.getMaterialInstance(n)},n._updateModelParams=function(){this._update(),e.prototype._updateModelParams.call(this)},n._updateModelType=function(){if(this._skinningRoot){var e=this._skinningRoot.getComponent("cc.SkeletalAnimation");e&&this.setUseBakedAnimation(e.useBakedAnimation)}},n._update=function(){this.model&&(this.model.bindSkeleton(this._skeleton,this._skinningRoot,this._mesh),this.model.uploadAnimation&&this.model.uploadAnimation(this._clip))},t}(uF),cU=J((oU=uU).prototype,"_skeleton",[tU],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),lU=J(oU.prototype,"_skinningRoot",[nU],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),J(oU.prototype,"skeleton",[iU],Object.getOwnPropertyDescriptor(oU.prototype,"skeleton"),oU.prototype),J(oU.prototype,"skinningRoot",[rU,aU],Object.getOwnPropertyDescriptor(oU.prototype,"skinningRoot"),oU.prototype),sU=oU))||sU)||sU)||sU)||sU)||sU)),JU=new Ws(La.ATTR_BATCH_ID,za.R32F),$U=new Ws(La.ATTR_BATCH_UV,za.RG32F),eG=Ts[JU.format].size+Ts[$U.format].size,tG=function(t){return e({SkinnedMeshUnit:t,SkinningModelUnit:t}),t}((hU=ih("cc.SkinnedMeshUnit"),_U=Dh(uL),fU=Dh(NF),dU=Dh(em),pU=Dh(QU),hU((xU=function(){function e(){Q(this,"mesh",vU,this),Q(this,"skeleton",yU,this),Q(this,"material",SU,this),Q(this,"_localTransform",EU,this),Q(this,"_offset",TU,this),Q(this,"_size",AU,this)}return j(e,[{key:"offset",set:function(e){qn.copy(this._offset,e)},get:function(){return this._offset}},{key:"size",set:function(e){qn.copy(this._size,e)},get:function(){return this._size}},{key:"copyFrom",set:function(e){e&&(this.mesh=e.mesh,this.skeleton=e.skeleton,this.material=e.getMaterial(0),e.skinningRoot&&HN(e.node,e.skinningRoot,this._localTransform))},get:function(){return null}}]),e}(),vU=J((gU=xU).prototype,"mesh",[_U],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),yU=J(gU.prototype,"skeleton",[fU],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),SU=J(gU.prototype,"material",[dU],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),EU=J(gU.prototype,"_localTransform",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new Hn}}),TU=J(gU.prototype,"_offset",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new qn(0,0)}}),AU=J(gU.prototype,"_size",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new qn(1,1)}}),J(gU.prototype,"offset",[gh],Object.getOwnPropertyDescriptor(gU.prototype,"offset"),gU.prototype),J(gU.prototype,"size",[gh],Object.getOwnPropertyDescriptor(gU.prototype,"size"),gU.prototype),J(gU.prototype,"copyFrom",[pU],Object.getOwnPropertyDescriptor(gU.prototype,"copyFrom"),gU.prototype),mU=gU))||mU)),nG=new Hn,iG=(new Hn,new bn),rG=function(t){return e({SkinnedMeshBatchRenderer:t,BatchedSkinningModelComponent:t}),t}((CU=ih("cc.SkinnedMeshBatchRenderer"),RU=mh(),bU=ah(100),wU=_h(),IU=Sh(),OU=Dh([Ft]),PU=Sh(),MU=Dh([tG]),NU=Sh(),DU=vh(),BU=vh(),CU(LU=RU(LU=bU(LU=hh(LU=wU((kU=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r=Fa.SAMPLER1D){var a=null;e.batchableTextureNames.find((function(e){return e===n}))?((a=e._textures[n])||(a=e.createTexture(n)),e.cookTextures(a,n,i)):e.units.some((function(e){return a=e.material&&e.material.getProperty(n,i)})),a&&t.setProperty(n,a,i)}else{for(var s=[],o=0;o=0)return"continue";e.push(i),t.push(Hn.multiply(new Hn,r.bindposes[n]||Hn.IDENTITY,nG))},s=0;se[n]?1:e[t]0&&d.copyBuffersToTexture(s,f,o),r.length>0&&d.copyTexImagesToTexture(r,f,a)},n.createTexture=function(e){var t=new md;return t.setFilters(M_.LINEAR,M_.LINEAR),t.setMipFilter(M_.NEAREST),t.reset({width:this.atlasSize,height:this.atlasSize,format:O_.RGBA8888}),t.loaded=!0,this._textures[e]=t,t},n.resizeAtlases=function(){for(var e in this._textures)this._textures[e].reset({width:this.atlasSize,height:this.atlasSize,format:O_.RGBA8888})},n._createUnitMesh=function(e,t){for(var n=JSON.parse(JSON.stringify(t.struct)),r={},a=0;a>2,o=n.vertexCount,c=a.indicesOffset,l=a.vertexOffset;a.request(o,n.indicesCount)||(a=t.currBufferBatch,o=0,c=0,l=0);var u=a.vData,h=a.iData;e.getWorldMatrix(BG);for(var _=0;_this._width&&(this._x=2,this._y=this._nexty),this._y+c+2>this._nexty&&(this._nexty=this._y+c+2),this._nexty>this._height)return null;i.internal.dynamicAtlasManager.textureBleeding&&((o<=8||c<=8)&&(this._texture.drawTextureAt(n.image,this._x-1,this._y-1),this._texture.drawTextureAt(n.image,this._x-1,this._y+1),this._texture.drawTextureAt(n.image,this._x+1,this._y-1),this._texture.drawTextureAt(n.image,this._x+1,this._y+1)),this._texture.drawTextureAt(n.image,this._x-1,this._y),this._texture.drawTextureAt(n.image,this._x+1,this._y),this._texture.drawTextureAt(n.image,this._x,this._y-1),this._texture.drawTextureAt(n.image,this._x,this._y+1)),this._texture.drawTextureAt(n.image,this._x,this._y),this._innerTextureInfos[n.getId()]={x:this._x,y:this._y,texture:n},this._count++,a+=this._x,s+=this._y,this._x+=o+2}var l={x:a,y:s,texture:this._texture};return this._innerSpriteFrames.push(e),l},t.deleteInnerTexture=function(e){e&&this._innerTextureInfos[e.getId()]&&(delete this._innerTextureInfos[e.getId()],this._count--)},t.isEmpty=function(){return this._count<=0},t.reset=function(){this._x=2,this._y=2,this._nexty=2;for(var e=this._innerSpriteFrames,t=0,n=e.length;t=0;t--)this._atlases[t].deleteInnerTexture(e),this._atlases[t].isEmpty()&&(this._atlases[t].destroy(),this._atlases.splice(t,1),this._atlasIndex--)},t.packToDynamicAtlas=function(e,t){if(!t._original&&t.packable){var n=this.insertSpriteFrame(t);n&&t._setDynamicAtlasFrame(n)}},j(e,[{key:"enabled",get:function(){return this._enabled},set:function(e){this._enabled!==e&&(e?(this.reset(),i.director.on(i.Director.EVENT_BEFORE_SCENE_LAUNCH,this.beforeSceneLoad,this)):i.director.off(i.Director.EVENT_BEFORE_SCENE_LAUNCH,this.beforeSceneLoad,this),this._enabled=e)}},{key:"maxAtlasCount",get:function(){return this._maxAtlasCount},set:function(e){this._maxAtlasCount=e}},{key:"atlasCount",get:function(){return this._atlases.length}},{key:"textureBleeding",get:function(){return this._textureBleeding},set:function(e){this._textureBleeding=e}},{key:"textureSize",get:function(){return this._textureSize},set:function(e){this._textureSize=e}},{key:"maxFrameSize",get:function(){return this._maxFrameSize},set:function(e){this._maxFrameSize=e}}]),e}();UG.instance=void 0;var GG,kG=e("dynamicAtlasManager",UG.instance=new UG);i.internal.dynamicAtlasManager=kG;var HG,VG,WG,jG,qG=[{u:0,v:0},{u:0,v:0},{u:0,v:0},{u:0,v:0}],XG=e("SpriteFrame",ih("cc.SpriteFrame")(GG=function(e){function t(){var t;return(t=e.call(this)||this).vertices=null,t.uv=[],t.uvHash=0,t.unbiasUV=[],t.uvSliced=[],t._rect=new ti,t._offset=new qn,t._originalSize=new $n,t._rotated=!1,t._capInsets=[0,0,0,0],t._atlasUuid="",t._texture=void 0,t._isFlipUVY=!1,t._isFlipUVX=!1,t._original=null,t._packable=!0,t}X(t,e),t.createWithImage=function(e){var n=e instanceof G_?e:new G_(e),i=new md;i.image=n;var r=new t;return r.texture=i,r},j(t,[{key:"insetTop",get:function(){return this._capInsets[1]},set:function(e){this._capInsets[1]!==e&&(this._capInsets[1]=e,this._texture&&this._calculateSlicedUV())}},{key:"insetBottom",get:function(){return this._capInsets[3]},set:function(e){this._capInsets[3]!==e&&(this._capInsets[3]=e,this._texture&&this._calculateSlicedUV())}},{key:"insetLeft",get:function(){return this._capInsets[0]},set:function(e){this._capInsets[0]!==e&&(this._capInsets[0]=e,this._texture&&this._calculateSlicedUV())}},{key:"insetRight",get:function(){return this._capInsets[2]},set:function(e){this._capInsets[2]!==e&&(this._capInsets[2]=e,this._texture&&this._calculateSlicedUV())}},{key:"rect",get:function(){return this._rect},set:function(e){this._rect.equals(e)||(this._rect.set(e),this._texture&&this._calculateUV())}},{key:"originalSize",get:function(){return this._originalSize},set:function(e){this._originalSize.equals(e)||(this._originalSize.set(e),this._texture&&this._calculateUV())}},{key:"offset",get:function(){return this._offset},set:function(e){this._offset.set(e)}},{key:"rotated",get:function(){return this._rotated},set:function(e){this._rotated!==e&&(this._rotated=e,this._texture&&this._calculateUV())}},{key:"texture",get:function(){return this._texture},set:function(e){e?this.reset({texture:e},!0):console.warn("Error Texture in "+this.name)}},{key:"atlasUuid",get:function(){return this._atlasUuid},set:function(e){this._atlasUuid=e}},{key:"width",get:function(){return this._texture.width}},{key:"height",get:function(){return this._texture.height}},{key:"_textureSource",set:function(e){window.Build?this._texture=e:e&&(this._refreshTexture(e),this._calculateUV())}},{key:"flipUVX",get:function(){return this._isFlipUVX},set:function(e){this._isFlipUVX=e,this._calculateUV()}},{key:"flipUVY",get:function(){return this._isFlipUVY},set:function(e){this._isFlipUVY=e,this._calculateUV()}},{key:"packable",get:function(){return this._packable},set:function(e){this._packable=e}},{key:"original",get:function(){return this._original}}]);var n=t.prototype;return n.textureLoaded=function(){return this.texture&&this.texture.loaded},n.isRotated=function(){return this._rotated},n.setRotated=function(e){this.rotated=e},n.getRect=function(e){return e?(e.set(this._rect),e):this._rect.clone()},n.setRect=function(e){this.rect=e},n.getOriginalSize=function(e){return e?(e.set(this._originalSize),e):this._originalSize.clone()},n.setOriginalSize=function(e){this.originalSize=e},n.getOffset=function(e){return e?(e.set(this._offset),e):this._offset.clone()},n.setOffset=function(e){this.offset=e},n.getGFXTexture=function(){return this._texture.getGFXTexture()},n.getGFXSampler=function(){return this._texture.getGFXSampler()},n.getHash=function(){return this._texture.getHash()},n.getSamplerHash=function(){return this._texture.getSamplerHash()},n.reset=function(e,t){void 0===t&&(t=!1);var n=!1;t&&(this._originalSize.set(0,0),this._rect.set(0,0,0,0),this._offset.set(0,0),this._capInsets=[0,0,0,0],this._rotated=!1,n=!0),e&&(e.texture&&(this.loaded=!1,this._rect.x=this._rect.y=0,this._rect.width=e.texture.width,this._rect.height=e.texture.height,this._refreshTexture(e.texture),this.checkRect(this._texture)),e.originalSize&&this._originalSize.set(e.originalSize),e.rect&&this._rect.set(e.rect),e.offset&&this._offset.set(e.offset),void 0!==e.borderTop&&(this._capInsets[1]=e.borderTop),void 0!==e.borderBottom&&(this._capInsets[3]=e.borderBottom),void 0!==e.borderLeft&&(this._capInsets[0]=e.borderLeft),void 0!==e.borderRight&&(this._capInsets[2]=e.borderRight),void 0!==e.isRotate&&(this._rotated=!!e.isRotate),void 0!==e.isFlipUv&&(this._isFlipUVY=!!e.isFlipUv),n=!0),n&&this.texture&&this._calculateUV()},n.checkRect=function(e){var t=this._rect,n=t.x,i=t.y;return this._rotated?(n+=t.height,i+=t.width):(n+=t.width,i+=t.height),n>e.width?(A(3300,this.name+"/"+e.name,n,e.width),!1):!(i>e.height&&(A(3301,this.name+"/"+e.name,i,e.height),1))},n.onLoaded=function(){this.loaded=!0,this.emit("load")},n.destroy=function(){return this._packable&&kG&&kG.deleteAtlasSpriteFrame(this),e.prototype.destroy.call(this)},n._calculateSlicedUV=function(){var e=this._rect,t=this.texture,n=t.width,i=t.height,r=this._capInsets[0],a=this._capInsets[2],s=e.width-r-a,o=this._capInsets[1],c=this._capInsets[3],l=e.height-o-c,u=this.uvSliced;if(u.length=0,this._rotated){qG[0].u=(e.x+.5)/n,qG[1].u=(e.x+c)/n,qG[2].u=(e.x+c+l)/n,qG[3].u=(e.x+e.height-.5)/n,qG[3].v=(e.y+.5)/i,qG[2].v=(e.y+r)/i,qG[1].v=(e.y+r+s)/i,qG[0].v=(e.y+e.width-.5)/i;for(var h=0;h<4;++h)for(var _=qG[h],f=0;f<4;++f){var d=qG[3-f];u.push({u:_.u,v:d.v})}}else{qG[0].u=(e.x+.5)/n,qG[1].u=(e.x+r)/n,qG[2].u=(e.x+r+s)/n,qG[3].u=(e.x+e.width-.5)/n,qG[3].v=(e.y+.5)/i,qG[2].v=(e.y+o)/i,qG[1].v=(e.y+o+l)/i,qG[0].v=(e.y+e.height-.5)/i;for(var p=0;p<4;++p)for(var m=qG[p],g=0;g<4;++g){var v=qG[g];u.push({u:v.u,v:m.v})}}},n._calculateUV=function(){var e=this._rect,t=this.uv,n=this.unbiasUV,i=this.texture,r=i.width,a=i.height;if(this._rotated){var s=0===r?0:(e.x+.5)/r,o=0===r?0:(e.x+e.height-.5)/r,c=0===a?0:(e.y+.5)/a,l=0===a?0:(e.y+e.width-.5)/a;this._isFlipUVX&&this._isFlipUVY?(t[0]=o,t[1]=l,t[2]=o,t[3]=c,t[4]=s,t[5]=l,t[6]=s,t[7]=c):this._isFlipUVX?(t[0]=o,t[1]=c,t[2]=o,t[3]=l,t[4]=s,t[5]=c,t[6]=s,t[7]=l):this._isFlipUVY?(t[0]=s,t[1]=l,t[2]=s,t[3]=c,t[4]=o,t[5]=l,t[6]=o,t[7]=c):(t[0]=s,t[1]=c,t[2]=s,t[3]=l,t[4]=o,t[5]=c,t[6]=o,t[7]=l);var u=0===r?0:e.x/r,h=0===r?0:(e.x+e.height)/r,_=0===a?0:e.y/a,f=0===a?0:(e.y+e.width)/a;this._isFlipUVX&&this._isFlipUVY?(n[0]=h,n[1]=f,n[2]=h,n[3]=_,n[4]=u,n[5]=f,n[6]=u,n[7]=_):this._isFlipUVX?(n[0]=h,n[1]=_,n[2]=h,n[3]=f,n[4]=u,n[5]=_,n[6]=u,n[7]=f):this._isFlipUVY?(n[0]=u,n[1]=f,n[2]=u,n[3]=_,n[4]=h,n[5]=f,n[6]=h,n[7]=_):(n[0]=u,n[1]=_,n[2]=u,n[3]=f,n[4]=h,n[5]=_,n[6]=h,n[7]=f)}else{var d=0===r?0:(e.x+.5)/r,p=0===r?0:(e.x+e.width-.5)/r,m=0===a?0:(e.y+e.height-.5)/a,g=0===a?0:(e.y+.5)/a;this._isFlipUVX&&this._isFlipUVY?(t[0]=p,t[1]=g,t[2]=d,t[3]=g,t[4]=p,t[5]=m,t[6]=d,t[7]=m):this._isFlipUVX?(t[0]=p,t[1]=m,t[2]=d,t[3]=m,t[4]=p,t[5]=g,t[6]=d,t[7]=g):this._isFlipUVY?(t[0]=d,t[1]=g,t[2]=p,t[3]=g,t[4]=d,t[5]=m,t[6]=p,t[7]=m):(t[0]=d,t[1]=m,t[2]=p,t[3]=m,t[4]=d,t[5]=g,t[6]=p,t[7]=g);var v=0===r?0:e.x/r,y=0===r?0:(e.x+e.width)/r,S=0===a?0:(e.y+e.height)/a,E=0===a?0:e.y/a;this._isFlipUVX&&this._isFlipUVY?(n[0]=y,n[1]=E,n[2]=v,n[3]=E,n[4]=y,n[5]=S,n[6]=v,n[7]=S):this._isFlipUVX?(n[0]=y,n[1]=S,n[2]=v,n[3]=S,n[4]=y,n[5]=E,n[6]=v,n[7]=E):this._isFlipUVY?(n[0]=v,n[1]=E,n[2]=y,n[3]=E,n[4]=v,n[5]=S,n[6]=y,n[7]=S):(n[0]=v,n[1]=S,n[2]=y,n[3]=S,n[4]=v,n[5]=E,n[6]=y,n[7]=E)}for(var T="",A=0;Ae.maxFrameSize||i>e.maxFrameSize?this._packable=!1:t.image&&t.image instanceof HTMLCanvasElement&&(this._packable=!0)}else this._packable=!1}},n._serialize=function(){},n._deserialize=function(e){var t=e,n=t.rect;n&&(this._rect=new ti(n.x,n.y,n.width,n.height));var i=t.offset;t.offset&&(this._offset=new qn(i.x,i.y));var r=t.originalSize;t.originalSize&&(this._originalSize=new $n(r.width,r.height)),this._rotated=!!t.rotated,this._name=t.name,this._packable=!!t.packable;var a=t.capInsets;a&&(this._capInsets[0]=a[0],this._capInsets[1]=a[1],this._capInsets[2]=a[2],this._capInsets[3]=a[3]),this.vertices=t.vertices,this.vertices&&(this.vertices.nu=[],this.vertices.nv=[])},n.clone=function(){var e,n,i,r,a,s,o,c,l=new t,u=this.vertices;return l.vertices=u?{x:u.x,y:u.y,triangles:u.triangles,nu:null===(e=u.nu)||void 0===e?void 0:e.slice(0),u:null===(n=u.u)||void 0===n?void 0:n.slice(0),nv:null===(i=u.nv)||void 0===i?void 0:i.slice(0),v:null===(r=u.v)||void 0===r?void 0:r.slice(0)}:null,(a=l.uv).splice.apply(a,[0,l.uv.length].concat(this.uv)),l.uvHash=this.uvHash,(s=l.unbiasUV).splice.apply(s,[0,l.unbiasUV.length].concat(this.unbiasUV)),(o=l.uvSliced).splice.apply(o,[0,l.uvSliced.length].concat(this.uvSliced)),l._rect.set(this._rect),l._offset.set(this._offset),l._originalSize.set(this._originalSize),l._rotated=this._rotated,(c=l._capInsets).splice.apply(c,[0,l._capInsets.length].concat(this._capInsets)),l._atlasUuid=this._atlasUuid,l._texture=this._texture,l._isFlipUVX=this._isFlipUVX,l._isFlipUVY=this._isFlipUVY,l},n._textureLoaded=function(){var e=this._texture,t={},n=!1;0!==this._rect.width&&0!==this._rect.height&&this.checkRect(e)||(t.rect=new ti(0,0,e.width,e.height),n=!0),(0===this._originalSize.width||0===this._originalSize.height||n)&&(t.originalSize=new $n(e.width,e.height),n=!0),n&&(this.reset(t),this.onLoaded()),this._checkPackable()},n._refreshTexture=function(e){this._texture=e,e.loaded?this._textureLoaded():e.once("load",this._textureLoaded,this)},t}(I_))||GG);i.SpriteFrame=XG;var YG,KG=e("SpriteAtlas",ih("cc.SpriteAtlas")((jG=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;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,vk.put(i)}this.moveToHead(n)},t.remove=function(e){e.prev?e.prev.next=e.next:this.head=e.next,e.next?e.next.prev=e.prev:this.tail=e.prev,delete this.datas[e.key],this.count--},t.get=function(e){var t=this.datas[e];return t?(this.remove(t),this.moveToHead(t),t.value):null},t.clear=function(){this.count=0,this.datas={},this.head=null,this.tail=null},t.has=function(e){return!!this.datas[e]},t.delete=function(e){var t=this.datas[e];this.remove(t)},e}())(100),Ek=/([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûа-яА-ЯЁё]+|\S)/,Tk=/^[!,.:;'}\]%\?>、‘“》?。,!]/,Ak=/([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁё]+|\S)$/,xk=/[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁё]+$/,Ck=/^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁё]/;function Rk(e){return/^[\u4E00-\u9FFF\u3400-\u4DFF]+$/.test(e)||/[\u3000-\u303F]|[\u3040-\u309F]|[\u30A0-\u30FF]|[\uFF00-\uFFEF]|[\u4E00-\u9FAF]|[\u2605-\u2606]|[\u2190-\u2195]|\u203B/g.test(e)||/^[\u1100-\u11FF]|[\u3130-\u318F]|[\uA960-\uA97F]|[\uAC00-\uD7AF]|[\uD7B0-\uD7FF]+$/.test(e)}function bk(e){var t=e.charCodeAt(0);return t>=9&&t<=13||32===t||133===t||160===t||5760===t||t>=8192&&t<=8202||8232===t||8233===t||8239===t||8287===t||12288===t}function wk(e,t,n){var i=(n||e.font)+"🎮"+t,r=Sk.get(i);if(null!==r)return r;var a=e.measureText(t),s=a&&a.width||0;return Sk.put(i,s),s}function Ik(e,t,n){var i=t,r=n,a=e[t];if(a>="\udc00"&&a<="\udfff"&&i--,void 0!==n)if(n-1!==t){var s=e[n-1];s>="\ud800"&&s<="\udbff"&&r--}else a>="\ud800"&&a<="\udbff"&&r++;return e.substring(i,r)}function Ok(e,t,n,i){var r=[];if(0===e.length||n<0)return r.push(""),r;for(var a=e;t>n&&a.length>1;){for(var s=a.length*(n/t)|0,o=Ik(a,s),c=t-i(o),l=o,u=0,h=0;c>n&&h++<10;)s*=n/c,c=t-i(o=Ik(a,s|=0));for(h=0;c<=n&&h++<10;){if(o){var _=Ek.exec(o);u=_?_[0].length:1,l=o}c=t-i(o=Ik(a,s+=u))}0==(s-=u)?(s=1,l=Ik(a,1)):1===s&&a[0]>="\ud800"&&a[0]<="\udbff"&&(s=2,l=Ik(a,2));var f=Ik(a,0,s),d=void 0;Tk.test(l||o)&&(0==(s-=(d=Ak.exec(f))?d[0].length:0)&&(s=1),l=Ik(a,s),f=Ik(a,0,s)),Ck.test(l)&&(d=xk.exec(f))&&f!==d[0]&&(l=Ik(a,s-=d[0].length),f=Ik(a,0,s)),(0===r.length||(f=f.trim()).length>0)&&r.push(f),t=i(a=l||o)}return(0===r.length||(a=a.trim()).length>0)&&r.push(a),r}var Pk,Mk,Nk,Dk,Bk,Lk,Fk,zk,Uk,Gk,kk,Hk,Vk,Wk,jk,qk,Xk,Yk=e("CanvasPool",function(){function e(){this.pool=[]}e.getInstance=function(){return yk||(yk=new e),yk};var t=e.prototype;return t.get=function(){var e=this.pool.pop();if(!e){var t=document.createElement("canvas"),n=t.getContext("2d");e={canvas:t,context:n}}return e},t.put=function(e){this.pool.length>=ft.MAX_LABEL_CANVAS_POOL_SIZE||this.pool.push(e)},e}()),Kk=Cn.WHITE.clone(),Zk=function(){this.u=0,this.v=0,this.w=0,this.h=0,this.texture=null,this.offsetX=0,this.offsetY=0,this.valid=!1,this.xAdvance=0},Qk="rgba(255, 255, 255, "+(1/255).toFixed(3)+")",Jk=function(){function e(e,t){this.image=null,this.labelInfo=void 0,this.char=void 0,this.data=null,this.canvas=null,this.context=null,this.width=0,this.height=0,this.offsetY=0,this.hash=void 0,this.char=e,this.labelInfo=t,this.hash=e.charCodeAt(0)+t.hash}var t=e.prototype;return t.updateRenderData=function(){this._updateProperties(),this._updateTexture()},t.destroy=function(){this.image=null},t._updateProperties=function(){if(this.data=Yk.getInstance().get(),this.canvas=this.data.canvas,this.context=this.data.context,this.context){this.context.font=this.labelInfo.fontDesc;var e=wk(this.context,this.char,this.labelInfo.fontDesc),t=2*this.labelInfo.margin+2;this.width=parseFloat(e.toFixed(2))+t,this.height=(1+mk)*this.labelInfo.fontSize+t,this.offsetY=-this.labelInfo.fontSize*mk/2}this.canvas.width!==this.width&&(this.canvas.width=this.width),this.canvas.height!==this.height&&(this.canvas.height=this.height),this.image||(this.image=new G_),this.image.reset(this.canvas)},t._updateTexture=function(){if(this.context&&this.canvas){var e=this.context,t=this.labelInfo,n=this.canvas.width,i=this.canvas.height;e.textAlign="center",e.textBaseline="alphabetic",e.clearRect(0,0,n,i),e.fillStyle=Qk,e.fillRect(0,0,n,i),e.font=t.fontDesc;var r=t.fontSize,a=n/2,s=i/2+r*gk+0*r,o=t.color;if(e.lineJoin="round",e.fillStyle="rgba("+o.r+", "+o.g+", "+o.b+", 1)",t.isOutlined){var c=t.out||Kk;e.strokeStyle="rgba("+c.r+", "+c.g+", "+c.b+", "+c.a/255+")",e.lineWidth=2*t.margin,e.strokeText(this.char,a,s)}e.fillText(this.char,a,s)}},e}(),$k=function(e){function t(){return e.apply(this,arguments)||this}X(t,e);var n=t.prototype;return n.initWithSize=function(e,t,n){void 0===n&&(n=O_.RGBA8888),this.reset({width:e,height:t,format:n}),this.loaded=!0,this.emit("load")},n.drawTextureAt=function(e,t,n){var i=this.getGFXTexture();if(e&&i){var r=this._getGFXDevice();if(r){var a=new eo;a.texOffset.x=t,a.texOffset.y=n,a.texExtent.width=e.width,a.texExtent.height=e.height,r.copyTexImagesToTexture([e.data],i,[a])}else console.warn("Unable to get device")}},t}(md),eH=function(){function e(e,t){this._x=0,this._y=0,this._nextY=0,this._width=0,this._height=0,this._halfBleed=0,this._dirty=!1;var n=new $k;n.initWithSize(e,t),this.fontDefDictionary=new fk(n),this._halfBleed=1,this._width=e,this._height=t,Ow.on(Iw.EVENT_BEFORE_SCENE_LAUNCH,this.beforeSceneLoad,this)}j(e,[{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}}]);var t=e.prototype;return t.insertLetterTexture=function(e){var t=e.image,n=Ow.root.device;if(!t||!this.fontDefDictionary||!n)return null;var i=t.width,r=t.height;if(this._x+i+0>this._width&&(this._x=0,this._y=this._nextY),this._y+r>this._nextY&&(this._nextY=this._y+r+0),this._nextY>this._height)return null;this.fontDefDictionary.texture.drawTextureAt(t,this._x,this._y),this._dirty=!0;var a=new Zk;return a.u=this._x+this._halfBleed,a.v=this._y+this._halfBleed,a.texture=this.fontDefDictionary.texture,a.valid=!0,a.w=e.width-2,a.h=e.height-2,a.xAdvance=a.w,a.offsetY=e.offsetY,this._x+=i+0,this.fontDefDictionary.addLetterDefinitions(e.hash,a),a},t.update=function(){this._dirty&&(this._dirty=!1)},t.reset=function(){this._x=0,this._y=0,this._nextY=0,this.fontDefDictionary.clear()},t.destroy=function(){this.reset(),this.fontDefDictionary&&(this.fontDefDictionary.texture.destroy(),this.fontDefDictionary.texture=null)},t.getTexture=function(){return this.fontDefDictionary.getTexture()},t.beforeSceneLoad=function(){this.clearAllCache()},t.clearAllCache=function(){this.destroy();var e=new $k;e.initWithSize(this._width,this._height),this.fontDefDictionary.texture=e},t.getLetter=function(e){return this.fontDefDictionary.letterDefinitions[e]},t.getLetterDefinitionForChar=function(e,t){var n=e.charCodeAt(0)+t.hash,i=this.fontDefDictionary.letterDefinitions[n];if(!i){var r=new Jk(e,t);r.updateRenderData(),i=this.insertLetterTexture(r),r.destroy()}return i},e}(),tH={fontAtlas:null,fontSize:0,lineHeight:0,hAlign:0,vAlign:0,hash:"",fontFamily:"",fontDesc:"Arial",color:Cn.WHITE.clone(),isOutlined:!1,out:Cn.WHITE.clone(),margin:0},nH=function(){this.material=null,this.vertexCount=0,this.indicesCount=0},iH=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r65535)return!1;var r=this.vData.byteLength,a=this.iData.length,s=this.vData.length,o=this.iData.length;if(n>r||i>a){for(;r>2}},{key:"vDataOffset",get:function(){return this.byteCount>>>2}}]),t}(nH),aH=(function(e){function t(){return e.apply(this,arguments)||this}X(t,e);var n=t.prototype;n._fillQuadBuffer=function(){for(var e=this.iData.length/6,t=this.iData,n=0,i=0;n=0&&s.y>=0&&s.x<=n&&s.y<=r&&(f=!0,t&&t.mask))for(var d=t.mask,p=this.node,m=d?d.length:0,g=0,v=0;p&&vy.index){d.length=v;break}}if(f)return!0}}}return!1},n.convertToNodeSpaceAR=function(e,t){return this.node.getWorldMatrix(_H),Hn.invert(uH,_H),t||(t=new bn),bn.transformMat4(t,e,uH)},n.convertToWorldSpaceAR=function(e,t){return this.node.getWorldMatrix(_H),t||(t=new bn),bn.transformMat4(t,e,_H)},n.getBoundingBox=function(){Hn.fromRTS(hH,this.node.getRotation(),this.node.getPosition(),this.node.getScale());var e=this._contentSize.width,t=this._contentSize.height,n=new ti(-this._anchorPoint.x*e,-this._anchorPoint.y*t,e,t);return n.transformMat4(hH),n},n.getBoundingBoxToWorld=function(){return this.node.parent?(this.node.parent.getWorldMatrix(_H),this.getBoundingBoxTo(_H)):this.getBoundingBox()},n.getBoundingBoxTo=function(e){Hn.fromRTS(hH,this.node.getRotation(),this.node.getPosition(),this.node.getScale());var n=this._contentSize.width,i=this._contentSize.height,r=new ti(-this._anchorPoint.x*n,-this._anchorPoint.y*i,n,i);if(Hn.multiply(_H,e,hH),r.transformMat4(_H),!this.node.children)return r;for(var a,s=Z(this.node.children);!(a=s()).done;){var o=a.value;if(o&&o.active){var c=o.getComponent(t);if(c){var l=c.getBoundingBoxTo(e);l&&ti.union(r,r,l)}}}return r},n.getComputeAABB=function(e){var t=this._contentSize.width,n=this._contentSize.height;dH.set(-this._anchorPoint.x*t,-this._anchorPoint.y*n,t,n),dH.transformMat4(this.node.worldMatrix);var i=dH.x+.5*dH.width,r=dH.y+.5*dH.height,a=this.node.worldPosition.z,s=dH.width/2,o=dH.height/2;return null!=e?(al.set(e,i,r,a,s,o,.001),e):new al(i,r,a,s,o,.001)},n._parentChanged=function(){this.node.getComponent("cc.RenderRoot2D")||this._checkAndSortSiblings()},n._checkAndSortSiblings=function(){var e=this.node.parent&&this.node.parent.children,t=!1;return e&&e.sort((function(e,n){var i=e._uiProps.uiTransformComp,r=n._uiProps.uiTransformComp,a=(i?i.priority:0)-(r?r.priority:0);return 0===a&&(a=e.getSiblingIndex()-n.getSiblingIndex()),t=a>0,a})),t},j(t,[{key:"contentSize",get:function(){return this._contentSize},set:function(e){this._contentSize.equals(e)||(this._contentSize.set(e),this.node.emit(JA.SIZE_CHANGED))}},{key:"width",get:function(){return this._contentSize.width},set:function(e){this._contentSize.width!==e&&(this._contentSize.width=e,this.node.emit(JA.SIZE_CHANGED))}},{key:"height",get:function(){return this._contentSize.height},set:function(e){this.contentSize.height!==e&&(this._contentSize.height=e,this.node.emit(JA.SIZE_CHANGED))}},{key:"anchorPoint",get:function(){return this._anchorPoint},set:function(e){this._anchorPoint.equals(e)||(this._anchorPoint.set(e),this.node.emit(JA.ANCHOR_CHANGED,this._anchorPoint))}},{key:"anchorX",get:function(){return this._anchorPoint.x},set:function(e){this._anchorPoint.x!==e&&(this._anchorPoint.x=e,this.node.emit(JA.ANCHOR_CHANGED,this._anchorPoint))}},{key:"anchorY",get:function(){return this._anchorPoint.y},set:function(e){this._anchorPoint.y!==e&&(this._anchorPoint.y=e,this.node.emit(JA.ANCHOR_CHANGED,this._anchorPoint))}},{key:"priority",get:function(){return this._priority},set:function(e){this._priority!==e&&(this.node.getComponent("cc.RenderRoot2D")?E(6706):(this._priority=e,this._checkAndSortSiblings(),this.node.parent._updateSiblingIndex()))}},{key:"visibility",get:function(){var e=Ow.root.batcher2D.getFirstRenderCamera(this.node);return e?e.visibility:0}},{key:"cameraPriority",get:function(){var e=Ow.root.batcher2D.getFirstRenderCamera(this.node);return e?e.priority:0}}]),t}(Kf),jk.EventType=JA,J((kk=qk).prototype,"contentSize",[Bk,Lk],Object.getOwnPropertyDescriptor(kk.prototype,"contentSize"),kk.prototype),J(kk.prototype,"anchorPoint",[Fk,zk],Object.getOwnPropertyDescriptor(kk.prototype,"anchorPoint"),kk.prototype),J(kk.prototype,"priority",[Uk],Object.getOwnPropertyDescriptor(kk.prototype,"priority"),kk.prototype),Hk=J(kk.prototype,"_priority",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),Vk=J(kk.prototype,"_contentSize",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new $n(100,100)}}),Wk=J(kk.prototype,"_anchorPoint",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return new qn(.5,.5)}}),Gk=kk))||Gk)||Gk)||Gk)||Gk)||Gk)||Gk));!function(e){e[e.DISABLED=0]="DISABLED",e[e.CLEAR=1]="CLEAR",e[e.ENTER_LEVEL=2]="ENTER_LEVEL",e[e.ENABLED=3]="ENABLED",e[e.EXIT_LEVEL=4]="EXIT_LEVEL",e[e.CLEAR_INVERTED=5]="CLEAR_INVERTED",e[e.ENTER_LEVEL_INVERTED=6]="ENTER_LEVEL_INVERTED"}(Xk||(Xk={}));var mH,gH,vH,yH,SH,EH,TH,AH,xH,CH,RH,bH,wH,IH,OH,PH,MH,NH,DH,BH,LH,FH,zH,UH,GH,kH,HH,VH=e("StencilManager",function(){function e(){this.stage=Xk.DISABLED,this._maskStack=[],this._stencilPattern={stencilTest:!0,func:Xa.ALWAYS,stencilMask:65535,writeMask:65535,failOp:Ya.KEEP,zFailOp:Ya.KEEP,passOp:Ya.KEEP,ref:1},this.stencilStateMap=new Map,this.stencilStateMapWithDepth=new Map}var t=e.prototype;return t.pushMask=function(e){this._maskStack.push(e)},t.clear=function(e){e.stencilStage=e.inverted?Xk.CLEAR_INVERTED:Xk.CLEAR},t.enterLevel=function(e){e.graphics.stencilStage=e.inverted?Xk.ENTER_LEVEL_INVERTED:Xk.ENTER_LEVEL},t.enableMask=function(){this.stage=Xk.ENABLED},t.exitMask=function(){0!==this._maskStack.length&&(this._maskStack.pop(),0===this._maskStack.length?this.stage=Xk.DISABLED:this.stage=Xk.ENABLED)},t.getWriteMask=function(){return 1<0},n._postCanRender=function(){},n._updateColor=function(){this._assembler&&this._assembler.updateColor&&this._assembler.updateColor(this)},n._updateBlendFunc=function(){var e=this._blendState.targets[0];e||(e=new io,this._blendState.setTarget(0,e)),e.blendDst===this._dstBlendFactor&&e.blendSrc===this._srcBlendFactor||(e.blend=!0,e.blendDstAlpha=Za.ONE_MINUS_SRC_ALPHA,e.blendDst=this._dstBlendFactor,e.blendSrc=this._srcBlendFactor),this.updateBlendHash()},n.getBlendState=function(){return this._blendState},n._nodeStateChange=function(){this._renderData&&this.markForUpdateRenderData();for(var e=0;e10||(m=.5*(s+c),g=.5*(o+l),v=.5*((_=.5*(n+r))+(d=.5*(r+s))),y=.5*((f=.5*(i+a))+(p=.5*(a+o))),((R=uW((r-c)*(C=l-i)-(a-l)*(x=c-n)))+(b=uW((s-c)*C-(o-l)*x)))*(R+b)=2*aW)u=2*aW;else for(;u<0;)u+=2*aW;else if(uW(u)>=2*aW)u=2*-aW;else for(;u>0;)u-=2*aW;for(c=0|oW(1,sW(uW(u)/(.5*aW)+.5,5)),h=uW(4/3*(1-cW(o=u/c/2))/lW(o)),s||(h=-h),T=0;T<=c;T++)d=t+(_=cW(l=r+u*(T/c)))*i,p=n+(f=lW(l))*i,m=-f*i*h,g=_*i*h,0===T?e.moveTo(d,p):e.bezierCurveTo(v+S,y+E,d-m,p-g,d,p),v=d,y=p,S=m,E=g}(this,e,t,n,i,r,a)},t.ellipse=function(e,t,n,i){fW(this,e,t,n,i),this._curPath.complex=!1},t.circle=function(e,t,n){fW(this,e,t,n,n),this._curPath.complex=!1},t.rect=function(e,t,n,i){this.moveTo(e,t),this.lineTo(e+n,t),this.lineTo(e+n,t+i),this.lineTo(e,t+i),this.close(),this._curPath.complex=!1},t.roundRect=function(e,t,n,i,r){!function(e,t,n,i,r,a){if(a<.1)e.rect(t,n,i,r);else{var s=sW(a,.5*uW(i))*hW(i),o=sW(a,.5*uW(r))*hW(r);e.moveTo(t,n+o),e.lineTo(t,n+r-o),e.bezierCurveTo(t,n+r-o*(1-_W),t+s*(1-_W),n+r,t+s,n+r),e.lineTo(t+i-s,n+r),e.bezierCurveTo(t+i-s*(1-_W),n+r,t+i,n+r-o*(1-_W),t+i,n+r-o),e.lineTo(t+i,n+o),e.bezierCurveTo(t+i,n+o*(1-_W),t+i-s*(1-_W),n,t+i-s,n),e.lineTo(t+s,n),e.bezierCurveTo(t+s*(1-_W),n,t,n+o*(1-_W),t,n+o),e.close()}}(this,e,t,n,i,r),this._curPath.complex=!1},t.clear=function(){this.pathLength=0,this.pathOffset=0,this.pointsOffset=0,this.dataOffset=0,this._curPath=null,this.paths.length=0,this._points.length=0;for(var e=this._renderDataList,t=0,n=e.length;tn)for(var i=n;i=0&&a.y>=0&&a.x<=i&&a.y<=r;else if(this.type===Sj.ELLIPSE){var c=i/2,l=r/2,u=a.x-.5*i,h=a.y-.5*r;o=u*u/(c*c)+h*h/(l*l)<1}return this._inverted&&(o=!o),o},n._render=function(e){e.commitComp(this,null,this._assembler,null)},n._postRender=function(e){this._postAssembler&&e.commitComp(this,null,this._postAssembler,null)},n._nodeStateChange=function(t){e.prototype._nodeStateChange.call(this,t),this._updateGraphics()},n._canRender=function(){return!!e.prototype._canRender.call(this)&&null!==this._graphics&&(this._type!==Sj.IMAGE_STENCIL||null!==this._spriteFrame)},n._flushAssembler=function(){var e=t.Assembler.getAssembler(this),n=t.PostAssembler.getAssembler(this);this._assembler!==e&&(this.destroyRenderData(),this._assembler=e),this._postAssembler!==n&&(this._postAssembler=n),this._useRenderData()},n._createGraphics=function(){if(!this._graphics){var e=this._graphics=new xj;e.node=this.node,e.node.getWorldMatrix(),e.lineWidth=0;var t=Cn.WHITE.clone();t.a=0,e.fillColor=t}this._updateMaterial()},n._updateGraphics=function(){if(this._graphics&&(this._type===Sj.RECT||this._type===Sj.ELLIPSE)){var e=this.node._uiProps.uiTransformComp,t=this._graphics;t.clear();var n=e.contentSize,i=n.width,r=n.height,a=e.anchorPoint,s=-i*a.x,o=-r*a.y;if(this._type===Sj.RECT)t.rect(s,o,i,r);else if(this._type===Sj.ELLIPSE){for(var c=function(e,t,n){wj.length=0;for(var i=2*Math.PI/n,r=0;r"]),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 a=e.substring(t,r),s=e.substring(r+1,i);""===s&&(a=e.substring(t,i+1)),this._processResult(a),-1===i?i=r:"/"===e.charAt(r+1)?this._stack.pop():this._addToStack(s),t=i+1}}return this._resultObjectArray},t._attributeToObject=function(e){e=e.trim();var t={},n=/^(color|size)(\s)*=/.exec(e),i="",r=0,a="";if(n){if(i=n[0],""===(e=e.substring(i.length).trim()))return t;switch(r=e.indexOf(" "),i[0]){case"c":t.color=r>-1?e.substring(0,r).trim():e;break;case"s":t.size=parseInt(e)}return r>-1&&(a=e.substring(r+1).trim(),t.event=this._processEventHandler(a)),t}if((n=/^(br(\s)*\/)/.exec(e))&&n[0].length>0&&(i=n[0].trim()).startsWith("br")&&"/"===i[i.length-1])return t.isNewLine=!0,this._resultObjectArray.push({text:"",style:{isNewLine:!0}}),t;var s="";if((n=/^(img(\s)*src(\s)*=[^>]+\/)/.exec(e))&&n[0].length>0&&(i=n[0].trim()).startsWith("img")&&"/"===i[i.length-1]){var o;n=Mq.exec(e);for(var c=!1;n;){if(i=(e=e.substring(e.indexOf(n[0]))).substr(0,n[0].length),o=(r=(s=e.substring(i.length).trim()).indexOf(" "))>-1?s.substr(0,r):s,i=(i=i.replace(/[^a-zA-Z]/g,"").trim()).toLowerCase(),e=s.substring(r).trim(),o.endsWith("/")&&(o=o.slice(0,-1)),"src"===i){switch(o.charCodeAt(0)){case 34:case 39:c=!0,o=o.slice(1,-1)}t.isImage=!0,t.src=o}else if("height"===i)t.imageHeight=parseInt(o);else if("width"===i)t.imageWidth=parseInt(o);else if("align"===i){switch(o.charCodeAt(0)){case 34:case 39:o=o.slice(1,-1)}t.imageAlign=o.toLowerCase()}else"offset"===i?t.imageOffset=o:"click"===i&&(t.event=this._processEventHandler(i+"="+o));t.event&&"param"===i&&(t.event[i]=o.replace(/^"|"$/g,"")),n=Mq.exec(e)}return c&&t.isImage&&this._resultObjectArray.push({text:"",style:t}),{}}if(n=/^(outline(\s)*[^>]*)/.exec(e)){var l={color:"#ffffff",width:1};if(e=n[0].substring("outline".length).trim()){var u,h=/(\s)*color(\s)*=|(\s)*width(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/;for(n=h.exec(e);n;)i=(e=e.substring(e.indexOf(n[0]))).substr(0,n[0].length),u=(r=(s=e.substring(i.length).trim()).indexOf(" "))>-1?s.substr(0,r):s,i=(i=i.replace(/[^a-zA-Z]/g,"").trim()).toLowerCase(),e=s.substring(r).trim(),"click"===i?t.event=this._processEventHandler(i+"="+u):"color"===i?l.color=u:"width"===i&&(l.width=parseInt(u)),t.event&&"param"===i&&(t.event[i]=u.replace(/^"|"$/g,"")),n=h.exec(e)}t.outline=l}if((n=/^(on|u|b|i)(\s)*/.exec(e))&&n[0].length>0){switch(i=n[0],e=e.substring(i.length).trim(),i[0]){case"u":t.underline=!0;break;case"i":t.italic=!0;break;case"b":t.bold=!0}if(""===e)return t;t.event=this._processEventHandler(e)}return t},t._processEventHandler=function(e){for(var t={},n=0,i=!1,r=Pq.exec(e);r;){var a=r[0],s="";if(i=!1,'"'===(e=e.substring(a.length).trim()).charAt(0))(n=e.indexOf('"',1))>-1&&(s=e.substring(1,n).trim(),i=!0),n++;else if("'"===e.charAt(0))(n=e.indexOf("'",1))>-1&&(s=e.substring(1,n).trim(),i=!0),n++;else{var o=/(\S)+/.exec(e);n=(s=o?o[0]:"").length}i&&(t[a=a.substring(0,a.length-1).trim()]=s),e=e.substring(n).trim(),r=Pq.exec(e)}return t},t._addToStack=function(e){var t=this._attributeToObject(e);if(0===this._stack.length)this._stack.push(t);else{if(t.isNewLine||t.isImage)return;var n=this._stack[this._stack.length-1];for(var i in n)t[i]||(t[i]=n[i]);this._stack.push(t)}},t._processResult=function(e){0!==e.length&&(e=this._escapeSpecialSymbol(e),this._stack.length>0?this._resultObjectArray.push({text:e,style:this._stack[this._stack.length-1]}):this._resultObjectArray.push({text:e}))},t._escapeSpecialSymbol=function(e){for(var t,n=Z(this._specialSymbolArray);!(t=n()).done;){var i=t.value,r=i[0],a=i[1];e=e.replace(r,a)}return e},e}()),Dq=function(t){return e({LabelOutline:t,LabelOutlineComponent:t}),t}((Oj=ih("cc.LabelOutline"),Pj=mh(),Mj=ah(110),Nj=_h(),Dj=rh(rW),Bj=Sh(),Lj=Sh(),Oj(Fj=Pj(Fj=Mj(Fj=Nj(Fj=Dj(Fj=hh((kj=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r=0;t--){var n=e[t];if("RICHTEXT_CHILD"===n.name||"RICHTEXT_Image_CHILD"===n.name){n.parent===this.node?n.parent=null:e.splice(t,1);var i=UX(n.name);i.node=n,"RICHTEXT_CHILD"===n.name?(i.comp=n.getComponent(rW),FX.put(i)):(i.comp=n.getComponent(Kq),zX.put(i))}}e.length=0,this._segments.length=0,this._labelSegmentsCache.length=0,this._linesWidth.length=0,this._lineOffsetX=0,this._lineCount=1,this._labelWidth=0,this._labelHeight=0,this._layoutDirty=!0},n._activateChildren=function(e){for(var t=this.node.children.length-1;t>=0;t--){var n=this.node.children[t];"RICHTEXT_CHILD"!==n.name&&"RICHTEXT_Image_CHILD"!==n.name||(n.active=e)}},n._addLabelSegment=function(e,t){var n;if(0===this._labelSegmentsCache.length)n=this._createFontLabel(e);else{var i=(n=this._labelSegmentsCache.pop()).node.getComponent(rW);i&&(i.string=e)}return n.styleIndex=t,n.lineCount=this._lineCount,n.node._uiProps.uiTransformComp.setAnchorPoint(0,0),n.node.layer=this.node.layer,this._applyTextAttribute(n),this.node.addChild(n.node),this._segments.push(n),n},n._updateRichTextWithMaxWidth=function(e,t,n){var i=t;if(this._lineOffsetX>0&&i+this._lineOffsetX>this._maxWidth)for(var r=0;this._lineOffsetX<=this._maxWidth;){var a=this._getFirstWordLen(e,r,e.length),s=e.substr(r,a),o=this._measureText(n,s);if(!(this._lineOffsetX+o<=this._maxWidth)){if(r>0){var c=e.substr(0,r);this._addLabelSegment(c,n),e=e.substr(r,e.length),i=this._measureText(n,e)}this._updateLineInfo();break}this._lineOffsetX+=o,r+=a}if(i>this._maxWidth)for(var l=Ok(e,i,this._maxWidth,this._measureText(n)),u=0;u1&&u0?(o*=s=u/c,c*=s):(o*=s=this._lineHeight/c,c*=s),l>0&&(o=l),this._maxWidth>0?(this._lineOffsetX+o>this._maxWidth&&this._updateLineInfo(),this._lineOffsetX+=o):(this._lineOffsetX+=o,this._lineOffsetX>this._labelWidth&&(this._labelWidth=this._lineOffsetX)),r.node._uiProps.uiTransformComp.setContentSize(o,c),r.lineCount=this._lineCount,r.clickHandler="",r.clickParam="";var h=t.event;h&&(r.clickHandler=h.click,r.clickParam=h.param)}else E(4400)}},n._updateRichText=function(){if(this.enabledInHierarchy){var e=LX.parse(this._string);if(!this._needsUpdateTextLayout(e))return this._textArray=e.slice(),void this._updateLabelSegmentTextAttributes();this._textArray=e.slice(),this._resetState();for(var t,n=!1,i=0;i0){var l=this._measureText(i,c);this._updateRichTextWithMaxWidth(c,l,i),s.length>1&&othis._labelWidth&&(this._labelWidth=this._lineOffsetX),s.length>1&&o0&&(this._labelWidth=this._maxWidth),this._labelHeight=(this._lineCount+mk)*this._lineHeight,this.node._uiProps.uiTransformComp.setContentSize(this._labelWidth,this._labelHeight),this._updateRichTextPosition(),this._layoutDirty=!1}},n._getFirstWordLen=function(e,t,n){var i=e.charAt(t);if(Rk(i)||bk(i))return 1;for(var r=1,a=t+1;at&&(e=0,t=c);var l=this._labelWidth*(.5*this._horizontalAlign-r);switch(this._horizontalAlign){case ZV.LEFT:break;case ZV.CENTER:l-=this._linesWidth[c-1]/2;break;case ZV.RIGHT:l-=this._linesWidth[c-1]}var u=o.node.position;if(o.node.setPosition(e+l,this._lineHeight*(n-c)-this._labelHeight*a,u.z),c===t&&(e+=o.node._uiProps.uiTransformComp.width),o.node.getComponent(Kq)){var h=o.node.position.clone(),_=this._lineHeight,f=this._lineHeight*(1+mk);switch(o.node._uiProps.uiTransformComp.anchorY){case 1:h.y+=_+(f-_)/2;break;case.5:h.y+=f/2;break;default:h.y+=(f-_)/2}if(o.imageOffset){var d=o.imageOffset.split(",");if(1===d.length&&d[0]){var p=parseFloat(d[0]);Number.isInteger(p)&&(h.y+=p)}else if(2===d.length){var m=parseFloat(d[0]),g=parseFloat(d[1]);Number.isInteger(m)&&(h.x+=m),Number.isInteger(g)&&(h.y+=g)}}o.node.position=h}var v=o.node.getComponent(Dq);if(v){var y=o.node.position.clone();y.y-=v.width,o.node.position=y}}},n._convertLiteralColorValue=function(e){var t=e.toUpperCase();return Cn[t]?Cn[t]:(new Cn).fromHEX(e)},n._applyTextAttribute=function(e){var t=e.node.getComponent(rW);if(t){var n,i=e.styleIndex;if(this._textArray[i]&&(n=this._textArray[i].style),n){if(t.color=this._convertLiteralColorValue(n.color||"white"),t.isBold=!!n.bold,t.isItalic=!!n.italic,t.isUnderline=!!n.underline,n.outline){var r=e.node.getComponent(Dq);r||(r=e.node.addComponent(Dq)),r.color=this._convertLiteralColorValue(n.outline.color),r.width=n.outline.width}t.fontSize=n.size||this._fontSize,e.clickHandler="",e.clickParam="";var a=n.event;a&&(e.clickHandler=a.click||"",e.clickParam=a.param||"")}else t.fontSize=this._fontSize;t.cacheMode=this._cacheMode,this._font instanceof ek&&!this._isSystemFontUsed?t.font=this._font:t.fontFamily=this._fontFamily,t.useSystemFont=this._isSystemFontUsed,t.lineHeight=this._lineHeight,t.updateRenderData(!0);var s=t._assembler;s&&s.updateRenderData(t)}},n._applyLayer=function(){for(var e,t=Z(this._segments);!(e=t()).done;)e.value.node.layer=this.node.layer},t}(BX),NX.HorizontalAlign=ZV,NX.VerticalAlign=QV,J((SX=DX).prototype,"string",[wh,rX],Object.getOwnPropertyDescriptor(SX.prototype,"string"),SX.prototype),J(SX.prototype,"horizontalAlign",[aX,sX],Object.getOwnPropertyDescriptor(SX.prototype,"horizontalAlign"),SX.prototype),J(SX.prototype,"fontSize",[oX],Object.getOwnPropertyDescriptor(SX.prototype,"fontSize"),SX.prototype),J(SX.prototype,"fontFamily",[cX],Object.getOwnPropertyDescriptor(SX.prototype,"fontFamily"),SX.prototype),J(SX.prototype,"font",[lX,uX],Object.getOwnPropertyDescriptor(SX.prototype,"font"),SX.prototype),J(SX.prototype,"useSystemFont",[hX],Object.getOwnPropertyDescriptor(SX.prototype,"useSystemFont"),SX.prototype),J(SX.prototype,"cacheMode",[_X,fX],Object.getOwnPropertyDescriptor(SX.prototype,"cacheMode"),SX.prototype),J(SX.prototype,"maxWidth",[dX],Object.getOwnPropertyDescriptor(SX.prototype,"maxWidth"),SX.prototype),J(SX.prototype,"lineHeight",[pX],Object.getOwnPropertyDescriptor(SX.prototype,"lineHeight"),SX.prototype),J(SX.prototype,"imageAtlas",[mX,gX],Object.getOwnPropertyDescriptor(SX.prototype,"imageAtlas"),SX.prototype),J(SX.prototype,"handleTouchEvent",[vX],Object.getOwnPropertyDescriptor(SX.prototype,"handleTouchEvent"),SX.prototype),EX=J(SX.prototype,"_lineHeight",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 40}}),TX=J(SX.prototype,"_string",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"RichText"}}),AX=J(SX.prototype,"_horizontalAlign",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return ZV.LEFT}}),xX=J(SX.prototype,"_fontSize",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 40}}),CX=J(SX.prototype,"_maxWidth",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),RX=J(SX.prototype,"_fontFamily",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return"Arial"}}),bX=J(SX.prototype,"_font",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),wX=J(SX.prototype,"_isSystemFontUsed",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),IX=J(SX.prototype,"_userDefinedFont",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),OX=J(SX.prototype,"_cacheMode",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return $V.NONE}}),PX=J(SX.prototype,"_imageAtlas",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return null}}),MX=J(SX.prototype,"_handleTouchEvent",[ch],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return!0}}),yX=SX))||yX)||yX)||yX)||yX)||yX)),VX=function(t){return e({UIMeshRenderer:t,UIModelComponent:t}),t}(ih("cc.UIMeshRenderer")(kX=mh()(kX=ah(110)(kX=_h()(kX=function(e){function t(){for(var t,n=arguments.length,i=new Array(n),r=0;r65535)return this._outOfCallback&&this._outOfCallback.call(this._batcher,e,t),!1;var r=this.vData.byteLength,a=this.iData.length;if(n>r||i>a){for(;r>2),t=new Uint16Array(this.iData.buffer,0,this.indicesOffset);this.byteOffset>this.vertexBuffers[0].size&&this.vertexBuffers[0].resize(this.byteOffset),this.vertexBuffers[0].update(e),2*this.indicesOffset>this.indexBuffer.size&&this.indexBuffer.resize(2*this.indicesOffset),this.indexBuffer.update(t),this._dirty=!1}},t._reallocBuffer=function(){this._reallocVData(!0),this._reallocIData(!0)},t._reallocVData=function(e){var t;if(this.vData&&(t=new Uint8Array(this.vData.buffer)),this.vData=new Float32Array(this._initVDataCount),t&&e)for(var n=new Uint8Array(this.vData.buffer),i=0,r=t.length;i0)for(a=t;a=t;a-=i)s=kY(a,e[a],e[a+1],s);return s&&FY(s,s.next)&&(HY(s),s=s.next),s}function xY(e,t){if(void 0===t&&(t=null),!e)return e;t||(t=e);var n=e,i=!1;do{if(i=!1,n.steiner||!FY(n,n.next)&&0!==LY(n.prev,n,n.next))n=n.next;else{if(HY(n),(n=t=n.prev)===n.next)return null;i=!0}}while(i||n!==t);return t}function CY(e,t,n,i,r,a,s){if(void 0===s&&(s=0),e){!s&&a&&function(e,t,n,i){var r=e;do{null===r.z&&(r.z=MY(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){var t=0,n=null,i=null,r=null,a=null,s=0,o=0,c=0,l=1;do{for(n=e,e=null,a=null,s=0;n;){for(s++,i=n,o=0,t=0;t0||c>0&&i;)0===o?(r=i,i=i.nextZ,c--):0!==c&&i?n.z<=i.z?(r=n,n=n.nextZ,o--):(r=i,i=i.nextZ,c--):(r=n,n=n.nextZ,o--),a?a.nextZ=r:e=r,r.prevZ=a,a=r;n=i}a.nextZ=null,l*=2}while(s>1)}(r)}(e,i,r,a);for(var o=e,c=null,l=null;e.prev!==e.next;)if(c=e.prev,l=e.next,a?bY(e,i,r,a):RY(e))t.push(c.i/n),t.push(e.i/n),t.push(l.i/n),HY(e),e=l.next,o=l.next;else if((e=l)===o){s?1===s?CY(e=wY(e,t,n),t,n,i,r,a,2):2===s&&IY(e,t,n,i,r,a):CY(xY(e),t,n,i,r,a,1);break}}}function RY(e){var t=e.prev,n=e,i=e.next;if(LY(t,n,i)>=0)return!1;for(var r=e.next.next;r!==e.prev;){if(DY(t.x,t.y,n.x,n.y,i.x,i.y,r.x,r.y)&&LY(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function bY(e,t,n,i){var r=e.prev,a=e,s=e.next;if(LY(r,a,s)>=0)return!1;for(var o=r.xa.x?r.x>s.x?r.x:s.x:a.x>s.x?a.x:s.x,u=r.y>a.y?r.y>s.y?r.y:s.y:a.y>s.y?a.y:s.y,h=MY(o,c,t,n,i),_=MY(l,u,t,n,i),f=e.nextZ;f&&f.z<=_;){if(f!==e.prev&&f!==e.next&&DY(r.x,r.y,a.x,a.y,s.x,s.y,f.x,f.y)&&LY(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(f=e.prevZ;f&&f.z>=h;){if(f!==e.prev&&f!==e.next&&DY(r.x,r.y,a.x,a.y,s.x,s.y,f.x,f.y)&&LY(f.prev,f,f.next)>=0)return!1;f=f.prevZ}return!0}function wY(e,t,n){var i=e;do{var r=i.prev,a=i.next.next;!FY(r,a)&&zY(r,i,i.next,a)&&UY(r,a)&&UY(a,r)&&(t.push(r.i/n),t.push(i.i/n),t.push(a.i/n),HY(i),HY(i.next),i=e=a),i=i.next}while(i!==e);return i}function IY(e,t,n,i,r,a){var s=e;do{for(var o=s.next.next;o!==s.prev;){if(s.i!==o.i&&BY(s,o)){var c=GY(s,o);return s=xY(s,s.next),c=xY(c,c.next),CY(s,t,n,i,r,a),void CY(c,t,n,i,r,a)}o=o.next}s=s.next}while(s!==e)}function OY(e,t){return e.x-t.x}function PY(e,t){if(t=function(e,t){var n=t,i=e.x,r=e.y,a=-1/0,s=null;do{if(r<=n.y&&r>=n.next.y){var o=n.x+(r-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(o<=i&&o>a){if(a=o,o===i){if(r===n.y)return n;if(r===n.next.y)return n.next}s=n.x=n.x&&n.x>=u&&DY(rs.x)&&UY(n,e)&&(s=n,_=c),n=n.next;return s}(e,t)){var n=GY(t,e);xY(n,n.next)}}function MY(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)/r)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)/r)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function NY(e){var t=e,n=e;do{t.x=0&&(e-s)*(i-o)-(n-s)*(t-o)>=0&&(n-s)*(a-o)-(r-s)*(i-o)>=0}function BY(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&zY(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&UY(e,t)&&UY(t,e)&&function(e,t){var n=e,i=!1,r=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!=n.next.y>a&&r<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}(e,t)}function LY(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function FY(e,t){return e.x===t.x&&e.y===t.y}function zY(e,t,n,i){return!!(FY(e,t)&&FY(n,i)||FY(e,i)&&FY(n,t))||LY(e,t,n)>0!=LY(e,t,i)>0&&LY(n,i,e)>0!=LY(n,i,t)>0}function UY(e,t){return LY(e.prev,e,e.next)<0?LY(e,t,e.next)>=0&&LY(e,e.prev,t)>=0:LY(e,t,e.prev)<0||LY(e,e.next,t)<0}function GY(e,t){var n=new TY(e.i,e.x,e.y),i=new TY(t.i,t.x,t.y),r=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,a.next=i,i.prev=a,i}function kY(e,t,n,i){var r=new TY(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function HY(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function VY(e,t,n){n=n||3;var i=t?t.length:0,r=i?t[0]*n:e.length,a=AY(e,0,r,n,!0),s=[];if(!a)return s;var o=0,c=0,l=0,u=0,h=0,_=0,f=0;if(i&&(a=function(e,t,n,i){var r,a=[],s=0,o=null;for(s=0,r=t.length;s80*n){o=l=e[0],c=u=e[1];for(var d=n;dl&&(l=h),_>u&&(u=_);f=Math.max(l-o,u-c)}return CY(a,s,n,o,c,f),s}for(var WY=Math.PI,jY=Math.min,qY=Math.max,XY=Math.ceil,YY=Math.acos,KY=Math.cos,ZY=Math.sin,QY=Math.atan2,JY=null,$Y=null,eK=new Cn,tK=[],nK=0;nK<4;nK++)tK.push(new bn);function iK(e,t,n){return en?n:e}var rK={useModel:!0,updateRenderData:function(){},fillBuffers:function(){},renderIA:function(){},getRenderData:function(e,t){if(!$Y)return null;var n=$Y.getRenderDataList(),i=n[$Y.dataOffset];if(!i)return null;var r=i,a=r?r.vertexStart+t:0;return(a>65535||3*a>131070)&&(++$Y.dataOffset,$Y.dataOffset0&&(r=1/t);for(var a=e.paths,s=e.pathOffset,o=e.pathLength;s1e-6){var S=1/d;S>600&&(S=600),_.dmx*=S,_.dmy*=S}_.dx*h.dy-h.dx*_.dy>0&&(_.flags|=iW.PT_LEFT),d*(p=qY(11,jY(h.len,_.len)*r))*p<1&&(_.flags|=iW.PT_INNERBEVEL),_.flags&iW.PT_CORNER&&(d*i*i<1||n===nW.BEVEL||n===nW.ROUND)&&(_.flags|=iW.PT_BEVEL),0!=(_.flags&(iW.PT_BEVEL|iW.PT_INNERBEVEL))&&c.bevel++,h=_,_=l[f+1]}}},_flattenPaths:function(e){for(var t=e.paths,n=e.pathOffset,i=e.pathLength;n2&&s.equals(o)&&(r.closed=!0,a.pop(),s=a[a.length-1]);for(var c=0,l=a.length;cm&&(g-=2*WY),this._vSet(_,f,1),this._vSet(l-a*i,t.y-s*i,-1);for(var v=iK(XY((m-g)/WY)*r,2,r),y=0;y0&&i>0&&S+l.w*AK>LK&&!bk(h)){_K.push(s),s=0,n++,i=0,r-=PK*this._getFontScale()+0,g=!0;break}mK.x=S,mK.y=r-l.offsetY*AK,this._recordLetterInfo(mK,h,y,n),y+1mK.y-l.h*AK&&(d=mK.y-l.h*AK)}else this._recordPlaceholderInfo(y,h),console.log("Can't find letter definition in texture atlas "+gK.atlasName+" for letter:"+h);else this._recordPlaceholderInfo(y,h)}g||(i=m,od&&(c=d),a<(s=p)&&(a=s),u+=_)}else _K.push(s),s=0,n++,i=0,r-=PK*this._getFontScale()+0,this._recordPlaceholderInfo(u,h),u++}return _K.push(s),yK=(vK=n+1)*PK*this._getFontScale(),vK>1&&(yK+=0*(vK-1)),pK.width=DK,pK.height=BK,DK<=0&&(pK.width=parseFloat(a.toFixed(2))+2*tH.margin),BK<=0&&(pK.height=parseFloat(yK.toFixed(2))+2*tH.margin),EK=pK.height,TK=0,o>0&&(EK=pK.height+o),c<-yK&&(TK=yK+c),!0},_getFirstCharLen:function(){return 1},_getFontScale:function(){return MK===JV.SHRINK?AK:1},_getFirstWordLen:function(e,t,n){var i=e.charAt(t);if(Rk(i)||"\n"===i||bk(i))return 1;var r=1,a=tH.fontAtlas.getLetterDefinitionForChar(i,tH);if(!a)return r;for(var s=a.xAdvance*AK+OK,o=t+1;oLK&&!bk(i)&&LK>0)return r;if(s+=a.xAdvance*AK+OK,"\n"===i||bk(i)||Rk(i))break;r++}return r},_multilineTextWrapByWord:function(){return this._multilineTextWrap(this._getFirstWordLen)},_multilineTextWrapByChar:function(){return this._multilineTextWrap(this._getFirstCharLen)},_recordPlaceholderInfo:function(e,t){if(e>=hK.length){var n=new sK;hK.push(n)}hK[e].char=t,hK[e].hash=t.charCodeAt(0)+tH.hash,hK[e].valid=!1},_recordLetterInfo:function(e,t,n,i){if(n>=hK.length){var r=new sK;hK.push(r)}var a=t.charCodeAt(0)+tH.hash;hK[n].line=i,hK[n].char=t,hK[n].hash=a,hK[n].valid=tH.fontAtlas.getLetter(a).valid,hK[n].x=e.x,hK[n].y=e.y},_alignText:function(){yK=0,_K.length=0,this._multilineTextWrapByWord(),this._computeAlignmentOffset(),MK===JV.SHRINK&&RK>0&&this._isVerticalClamp()&&this._shrinkLabelToContentSize(this._isVerticalClamp),this._updateQuads()||MK===JV.SHRINK&&this._shrinkLabelToContentSize(this._isHorizontalClamp)},_scaleFontSizeDown:function(e){var t=!0;e||(e=.1,t=!1),RK=e,t&&this._updateContent()},_shrinkLabelToContentSize:function(e){for(var t=0,n=0|RK,i=0;t>1;if(r<=0)break;AK=r/bK,this._multilineTextWrapByWord(),this._computeAlignmentOffset(),e()?n=i-1:t=i}t>=0&&this._scaleFontSizeDown(t)},_isVerticalClamp:function(){return yK>pK.height},_isHorizontalClamp:function(){for(var e=!1,t=0,n=CK.length;t0)if(NK){if(_K[s]>pK.width&&(a>pK.width||a<0)){e=!0;break}}else if(a>pK.width){e=!0;break}}}return e},_isHorizontalClamped:function(e,t){var n=_K[t],i=e>pK.width||e<0;return NK?n>pK.width&&i:i},_updateQuads:function(){if(!cK)return!1;var e=xK?xK.texture:tH.fontAtlas.getTexture(),t=cK.renderData;t.dataLength=t.vertexCount=t.indicesCount=0;for(var n=lK.anchorPoint,i=pK,r=n.x*i.width,a=n.y*i.height,s=!0,o=0,c=CK.length;o0){if(h>EK){var _=h-EK;oK.y+=_,oK.height-=_,h-=_}h-u.h*AK0&&this._isHorizontalClamped(d,f))if(MK===JV.CLAMP)oK.width=0;else if(MK===JV.SHRINK){if(pK.width>u.w){s=!1;break}oK.width=0}if(oK.height>0&&oK.width>0){var p=this._determineRect(),m=l.x+fK[l.line];this.appendQuad(cK,e,oK,p,m-r,h-a,AK)}}else console.warn("Can't find letter in this bitmap-font")}}return s},appendQuad:function(){},_determineRect:function(){var e=xK.isRotated(),t=xK.getOriginalSize(),n=xK.getRect(),i=xK.getOffset(),r=i.x+(t.width-n.width)/2,a=i.y-(t.height-n.height)/2;if(e){var s=oK.x;oK.x=n.x+n.height-oK.y-oK.height-a,oK.y=s+n.y-r,oK.y<0&&(oK.height+=a)}else oK.x+=n.x-r,oK.y+=n.y+a;return e},_computeAlignmentOffset:function(){switch(fK.length=0,wK){case ZV.LEFT:for(var e=0;e0&&(n=n+e.margin+e.out.toHEX()),""+e.fontSize+e.fontFamily+t+n}(tH)},_getFontDesc:function(){return tH.fontSize.toString()+"px "+tH.fontFamily},_computeHorizontalKerningForText:function(){},_determineRect:function(){return!1}}),kK=new Cn(255,255,255,255),HK={createData:function(e){return e.requestRenderData()},fillBuffers:function(e,t){if(e.renderData){var n=e.node;kK.a=e.color.a,LG(n,t,e.renderData,kK)}},appendQuad:zK.appendQuad};ke(HK,GK);var VK=rW.Overflow,WK=null,jK=null,qK=null,XK="",YK="",KK=0,ZK=0,QK=[],JK=new $n,$K=0,eZ=0,tZ=0,nZ=new Cn,iZ="",rZ=VK.NONE,aZ=!1,sZ=null,oZ=Cn.BLACK.clone(),cZ=null,lZ=Cn.BLACK.clone(),uZ=new ti,hZ=$n.ZERO.clone(),_Z=$n.ZERO.clone(),fZ=qn.ZERO.clone(),dZ=qn.ZERO.clone(),pZ=0,mZ=0,gZ=!1,vZ=!1,yZ=!1,SZ=["left","center","right"],EZ={getAssemblerData:function(){return rW._canvasPool.get()},resetAssemblerData:function(e){e&&rW._canvasPool.put(e)},updateRenderData:function(e){if(e.renderData&&e.renderData.vertDirty){var t=e.node._uiProps.uiTransformComp;this._updateFontFamily(e),this._updateProperties(e,t),this._calculateLabelFont(),this._updateLabelDimensions(),this._resetDynamicAtlas(e),this._updateTexture(),this._calDynamicAtlas(e),e.actualFontSize=KK,t.setContentSize(JK),this.updateVertexData(e),this.updateUvs(e),e.markForUpdateRenderData(!1),WK=null,jK=null,qK=null}},updateVertexData:function(){},updateUvs:function(){},_updateFontFamily:function(e){e.useSystemFont?iZ=e.fontFamily||"Arial":e.font?e.font._nativeAsset?iZ=e.font._nativeAsset:(OI.postLoadNative(e.font,(function(){e.isValid&&(iZ=e.font._nativeAsset||"Arial",e.updateRenderData(!0))})),iZ="Arial"):iZ="Arial"},_updateProperties:function(e,t){var n=e.assemblerData;n&&(WK=n.context,jK=n.canvas,qK=e.spriteFrame,YK=e.string.toString(),KK=e.fontSize,ZK=KK,rZ=e.overflow,_Z.width=JK.width=t.width,_Z.height=JK.height=t.height,mZ=e.underlineHeight,$K=e.lineHeight,eZ=e.horizontalAlign,tZ=e.verticalAlign,nZ=e.color,gZ=e.isBold,vZ=e.isItalic,yZ=e.isUnderline,aZ=rZ!==VK.NONE&&(rZ===VK.RESIZE_HEIGHT||e.enableWrapText),(sZ=(sZ=Dq&&e.getComponent(Dq))&&sZ.enabled&&sZ.width>0?sZ:null)&&oZ.set(sZ.color),(cZ=(cZ=SY&&e.getComponent(SY))&&cZ.enabled?cZ:null)&&lZ.set(cZ.color),this._updatePaddingRect())},_updatePaddingRect:function(){var e=0,t=0,n=0,i=0,r=0;if(hZ.width=hZ.height=0,sZ&&(e=t=n=i=r=sZ.width,hZ.width=hZ.height=2*r),cZ){var a=cZ.blur+r,s=cZ.offset.x,o=cZ.offset.y;n=Math.max(n,-s+a),i=Math.max(i,s+a),e=Math.max(e,o+a),t=Math.max(t,-o+a)}if(vZ){var c=ZK*Math.tan(.20943951);i+=c,hZ.width+=c}uZ.x=n,uZ.y=e,uZ.width=n+i,uZ.height=e+t},_calculateFillTextStartPosition:function(){var e=0;eZ===ZV.RIGHT?e=JK.width-uZ.width:eZ===ZV.CENTER&&(e=(JK.width-uZ.width)/2);var t=this._getLineHeight()*(QK.length-1),n=KK*(1-mk/2);if(tZ!==QV.TOP){var i=t+uZ.height+KK-JK.height;tZ===QV.BOTTOM?n-=i+=mk/2*KK:n-=i/2}n+=0*KK,fZ.set(e+uZ.x,n+uZ.y)},_updateTexture:function(){if(WK&&jK){WK.clearRect(0,0,jK.width,jK.height),WK.font=XK,this._calculateFillTextStartPosition();var e=this._getLineHeight();WK.lineJoin="round",WK.fillStyle="rgba("+nZ.r+", "+nZ.g+", "+nZ.b+", 1)";var t,n=fZ.x,r=0;this._drawTextEffect(fZ,e);for(var a=0;a1&&cZ,i=this._measureText(WK,XK),r=0,a=0;cZ&&this._setupShadow(),sZ&&this._setupOutline();for(var s=0;s>1)<=0){y(4003);break}KK=l,XK=this._getFontDesc(),WK.font=XK;var u=this._getLineHeight();for(i=0,n=0;ns?c=l-1:o=l}0===o?y(4003):(KK=o,XK=this._getFontDesc(),WK.font=XK)}else{for(i=e.length*this._getLineHeight(),n=0;nr?t:r}n=(QK.length+mk)*this._getLineHeight();var a=parseFloat(t.toFixed(2)),s=parseFloat(n.toFixed(2));JK.width=a+uZ.width,JK.height=s+uZ.height,_Z.width=a+hZ.width,_Z.height=s+hZ.height;break;case VK.SHRINK:this._calculateShrinkFont(e),this._calculateWrapText(e);break;case VK.CLAMP:this._calculateWrapText(e);break;case VK.RESIZE_HEIGHT:this._calculateWrapText(e);var o=(QK.length+mk)*this._getLineHeight();JK.height=o+uZ.height,_Z.height=o+hZ.height}}}},TZ=Cn.WHITE.clone(),AZ={createData:function(e){var t=e.requestRenderData();t.dataLength=4,t.vertexCount=4,t.indicesCount=6;var n=t.vData=new Float32Array(36);n[3]=n[21]=n[22]=n[31]=0,n[4]=n[12]=n[13]=n[30]=1;for(var i=5,r=0;r<4;r++)Cn.toArray(n,TZ,i),i+=9;return t},fillBuffers:function(e,t){var n=e.renderData,i=n.data,r=e.node,a=t.acquireBufferBatch(),s=a.byteOffset>>2,o=a.indicesOffset,c=a.vertexOffset;a.request()||(a=t.currBufferBatch,o=0,c=0,s=0);var l=a.vData,u=a.iData,h=n.vData,_=i[0],f=i[3];r.updateWorldTransform();var d=r._pos,p=r._rot,m=r._scale,g=_.x*m.x,v=f.x*m.x,y=_.y*m.y,S=f.y*m.y,E=p.x,T=p.y,A=p.z,x=p.w,C=E*T,R=A*x,b=E*E-T*T,w=x*x-A*A,I=w+b,O=2*(C-R),P=w-b,M=2*(C+R),N=d.x,D=d.y;h[0]=I*g+O*y+N,h[1]=P*y+M*g+D,h[9]=I*v+O*y+N,h[10]=P*y+M*v+D,h[18]=I*g+O*S+N,h[19]=P*S+M*g+D,h[27]=I*v+O*S+N,h[28]=P*S+M*v+D,l.set(h,s),u[o++]=c,u[o++]=c+1,u[o++]=c+2,u[o++]=c+2,u[o++]=c+1,u[o++]=c+3},updateVertexData:function(e){var t=e.renderData;if(t){var n=e.node._uiProps.uiTransformComp,i=n.width,r=n.height,a=n.anchorX*i,s=n.anchorY*r,o=t.data;o[0].x=-a,o[0].y=-s,o[3].x=i-a,o[3].y=r-s}},updateUvs:function(e){var t=e.renderData;if(t){var n=t.vData;if(n&&t.uvDirty){var i=e.ttfSpriteFrame.uv;n[3]=i[0],n[4]=i[1],n[12]=i[2],n[13]=i[3],n[21]=i[4],n[22]=i[5],n[30]=i[6],n[31]=i[7],t.uvDirty=!1}}}};ke(AZ,EZ);var xZ=e("labelAssembler",{getAssembler:function(e){var t=AZ;return e.font instanceof dk?t=zK:e.cacheMode===rW.CacheMode.CHAR&&(t=HK),t}});rW.Assembler=xZ;var CZ=Kq.FillType,RZ=new Hn,bZ={useModel:!1,updateRenderData:function(e){var t=e.spriteFrame;kG.packToDynamicAtlas(e,t);var n=e.renderData;if(n&&t){var i=n.uvDirty,r=n.vertDirty;if(!i&&!r)return;var a=e.fillStart,s=e.fillRange;s<0&&(a+=s,s=-s),s=(s=(s=a+s)>1?1:s)<0?0:s;var o=(a=(a=a>1?1:a)<0?0:a)+(s=(s-=a)<0?0:s);o=o>1?1:o,i&&this.updateUVs(e,a,o),r&&(this.updateVertexData&&this.updateVertexData(e,a,o),this.updateWorldVertexData(e))}},updateUVs:function(e,t,n){var i=e.spriteFrame,r=e.renderData,a=r.data,s=i.width,o=i.height,c=i.getRect(),l=0,u=0,h=0,_=0,f=0,d=0,p=0,m=0,g=0,v=0;switch(i.isRotated()?(l=c.x/s,u=(c.y+c.width)/o,h=f=l,p=g=(c.x+c.height)/s,d=v=u,_=m=c.y/o):(l=c.x/s,u=(c.y+c.height)/o,h=p=l,f=g=(c.x+c.width)/s,_=d=u,m=v=c.y/o),e.fillType){case CZ.HORIZONTAL:a[0].u=h+(f-h)*t,a[0].v=_+(d-_)*t,a[1].u=h+(f-h)*n,a[1].v=_+(d-_)*n,a[2].u=p+(g-p)*t,a[2].v=m+(v-m)*t,a[3].u=p+(g-p)*n,a[3].v=m+(v-m)*n;break;case CZ.VERTICAL:a[0].u=h+(p-h)*t,a[0].v=_+(m-_)*t,a[1].u=f+(g-f)*t,a[1].v=d+(v-d)*t,a[2].u=h+(p-h)*n,a[2].v=_+(m-_)*n,a[3].u=f+(g-f)*n,a[3].v=d+(v-d)*n;break;default:A(2626)}r.uvDirty=!1},updateVertexData:function(e,t,n){var i=e.renderData,r=i.data,a=e.node._uiProps.uiTransformComp,s=a.width,o=a.height,c=a.anchorX*s,l=a.anchorY*o,u=-c,h=-l,_=s-c,f=o-l,d=0;switch(e.fillType){case CZ.HORIZONTAL:d=u+(_-u)*n,u+=(_-u)*t,_=d;break;case CZ.VERTICAL:d=h+(f-h)*n,h+=(f-h)*t,f=d;break;default:A(2626)}r[4].x=u,r[4].y=h,r[5].x=_,r[5].y=h,r[6].x=u,r[6].y=f,r[7].x=_,r[7].y=f,i.vertDirty=!1},createData:function(e){var t=e.requestRenderData();t.dataLength=8,t.vertexCount=4,t.indicesCount=6;for(var n,i=Z(t.data);!(n=i()).done;)n.value.z=0;return t},updateWorldVertexData:function(e){var t=e.node,n=e.renderData.data;t.getWorldMatrix(RZ);for(var i=0;i<4;i++){var r=n[i+4],a=n[i];bn.transformMat4(a,r,RZ)}},fillBuffers:function(e,t){e.node.hasChangedFlags&&this.updateWorldVertexData(e),e.node,function(e,t,n,i){var r=n.data,a=t.acquireBufferBatch(),s=a.byteOffset>>2,o=n.vertexCount,c=a.indicesOffset,l=a.vertexOffset;a.request(o,n.indicesCount)||(a=t.currBufferBatch,o=0,c=0,l=0);for(var u=a.vData,h=0;h1e-6?o:0;var c=Math.cos(a),l=0,u=0;if(0!==(c=Math.abs(c)>1e-6?c:0)){if(l=o/c,(e-r.x)*c>0){var h=r.y+l*(e-r.x);s[0].x=e,s[0].y=h}if((t-r.x)*c>0){var _=r.y+l*(t-r.x);s[2].x=t,s[2].y=_}}if(0!==o){if(u=c/o,(i-r.y)*o>0){var f=r.x+u*(i-r.y);s[3].x=f,s[3].y=i}if((n-r.y)*o>0){var d=r.x+u*(n-r.y);s[1].x=d,s[1].y=n}}}function FZ(e,t){var n=t.x-e.x,i=t.y-e.y;if(0===n&&0===i)return 0;if(0===n)return i>0?.5*Math.PI:1.5*Math.PI;var r=Math.atan(i/n);return n<0&&(r+=Math.PI),r}function zZ(e,t,n,i,r){var a=OZ,s=a[0],o=a[1],c=a[2],l=a[3];e[t].x=n.x,e[t].y=n.y,e[t+1].x=i.x,e[t+1].y=i.y,e[t+2].x=r.x,e[t+2].y=r.y,UZ((n.x-s)/(c-s),(n.y-o)/(l-o),e,t),UZ((i.x-s)/(c-s),(i.y-o)/(l-o),e,t+1),UZ((r.x-s)/(c-s),(r.y-o)/(l-o),e,t+2)}function UZ(e,t,n,i){var r=PZ,a=r[0]+(r[2]-r[0])*e,s=r[4]+(r[6]-r[4])*e,o=r[1]+(r[3]-r[1])*e,c=r[5]+(r[7]-r[5])*e,l=n[i];l.u=a+(s-a)*t,l.v=o+(c-o)*t}for(var GZ={useModel:!1,createData:function(e){return e.requestRenderData()},updateRenderData:function(e){var t=e.spriteFrame;kG.packToDynamicAtlas(e,t);var n=e.renderData;if(n&&t&&(n.vertDirty||n.uvDirty)){var i=n.data,r=e.fillStart,a=e.fillRange;for(a<0&&(r+=a,a=-a);r>=1;)r-=1;for(;r<0;)r+=1;var s=(r*=wZ)+(a*=wZ);!function(e){var t=e.node._uiProps.uiTransformComp,n=t.width,i=t.height,r=t.anchorX*n,a=t.anchorY*i,s=-r,o=-a,c=n-r,l=i-a,u=OZ;u[0]=s,u[1]=o,u[2]=c,u[3]=l;var h=e.fillCenter,_=DZ.x=Math.min(Math.max(0,h.x),1)*(c-s)+s,f=DZ.y=Math.min(Math.max(0,h.y),1)*(l-o)+o;IZ[0].x=IZ[3].x=s,IZ[1].x=IZ[2].x=c,IZ[0].y=IZ[1].y=o,IZ[2].y=IZ[3].y=l;for(var d,p=Z(BZ);!(d=p()).done;){var m=d.value;qn.set(m,0,0)}_!==u[0]&&qn.set(BZ[0],3,0),_!==u[2]&&qn.set(BZ[2],1,2),f!==u[1]&&qn.set(BZ[1],0,1),f!==u[3]&&qn.set(BZ[3],2,3)}(e),function(e){var t=e.width,n=e.height,i=e.getRect(),r=0,a=0,s=0,o=0,c=PZ;e.isRotated()?(r=i.x/t,a=(i.x+i.height)/t,s=i.y/n,o=(i.y+i.width)/n,c[0]=c[2]=r,c[4]=c[6]=a,c[3]=c[7]=o,c[1]=c[5]=s):(r=i.x/t,a=(i.x+i.width)/t,s=i.y/n,o=(i.y+i.height)/n,c[0]=c[4]=r,c[2]=c[6]=a,c[1]=c[3]=o,c[5]=c[7]=s)}(t),LZ(OZ[0],OZ[2],OZ[1],OZ[3],DZ,r,MZ),LZ(OZ[0],OZ[2],OZ[1],OZ[3],DZ,r+a,NZ);for(var o=0,c=0;c<4;++c){var l=BZ[c];if(l)if(a>=wZ)n.dataLength=o+3,zZ(i,o,DZ,IZ[l.x],IZ[l.y]),o+=3;else{var u=FZ(DZ,IZ[l.x]),h=FZ(DZ,IZ[l.y]);h=s||(u>=r?(n.dataLength=o+3,zZ(i,o,DZ,IZ[l.x],h>=s?NZ[c]:IZ[l.y]),o+=3):h>r&&(h<=s?(n.dataLength=o+3,zZ(i,o,DZ,MZ[c],IZ[l.y]),o+=3):(n.dataLength=o+3,zZ(i,o,DZ,MZ[c],NZ[c]),o+=3))),u+=wZ,h+=wZ}}n.indicesCount=n.vertexCount=o,n.vertDirty=n.uvDirty=!1}},fillBuffers:function(e,t){!function(e,t,n,i){var r=n.data,a=t.acquireBufferBatch(),s=a.byteOffset>>2,o=n.vertexCount,c=a.indicesOffset,l=a.vertexOffset;a.request(o,n.indicesCount)||(a=t.currBufferBatch,o=0,c=0,l=0);var u=a.vData;e.getWorldMatrix(BG);for(var h=0;h>2,s=r.indicesOffset,o=r.vertexOffset;r.request()||(r=t.currBufferBatch,a=0,s=0,o=0);var c=r.vData,l=r.iData,u=e.renderData.vData,h=n[0],_=n[3],f=i.worldMatrix,d=f.m00,p=f.m01,m=f.m04,g=f.m05,v=f.m12,y=f.m13,S=h.x,E=_.x,T=h.y,A=_.y,x=d*S,C=d*E,R=p*S,b=p*E,w=m*T,I=m*A,O=g*T,P=g*A;u[0]=x+w+v,u[1]=R+O+y,u[9]=C+w+v,u[10]=b+O+y,u[18]=x+I+v,u[19]=R+P+y,u[27]=C+I+v,u[28]=b+P+y,c.set(u,a),l[s++]=o,l[s++]=o+1,l[s++]=o+2,l[s++]=o+2,l[s++]=o+1,l[s++]=o+3}},updateVertexData:function(e){var t=e.renderData;if(t){var n=e.node._uiProps.uiTransformComp,i=t.data,r=n.width,a=n.height,s=n.anchorX*r,o=n.anchorY*a,c=0,l=0,u=0,h=0;if(e.trim)c=-s,l=-o,u=r-s,h=a-o;else{var _=e.spriteFrame,f=_.getOriginalSize(),d=_.getRect(),p=f.width,m=f.height,g=d.width,v=d.height,y=_.getOffset(),S=r/p,E=a/m,T=y.x+(p-g)/2,A=y.x-(p-g)/2;c=T*S-s,l=(y.y+(m-v)/2)*E-o,u=r+A*S-s,h=a+(y.y-(m-v)/2)*E-o}i[0].x=c,i[0].y=l,i[0].z=0,i[3].x=u,i[3].y=h,i[3].z=0,t.vertDirty=!1}},updateUvs:function(e){var t=e.renderData,n=t.vData,i=e.spriteFrame.uv;n[3]=i[0],n[4]=i[1],n[12]=i[2],n[13]=i[3],n[21]=i[4],n[22]=i[5],n[30]=i[6],n[31]=i[7],t.uvDirty=!1},updateColor:function(e){for(var t=e.renderData.vData,n=5,i=e.color,r=i.r/255,a=i.g/255,s=i.b/255,o=i.a/255,c=0;c<4;c++)t[n]=r,t[n+1]=a,t[n+2]=s,t[n+3]=o,n+=9}},WZ=new bn,jZ=new Hn,qZ={useModel:!1,createData:function(e){var t=e.requestRenderData();return t.dataLength=20,t.vertexCount=16,t.indicesCount=54,t},updateRenderData:function(e){var t=e.spriteFrame;kG.packToDynamicAtlas(e,t);var n=e.renderData;n&&t&&n.vertDirty&&(this.updateVertexData(e),this.updateWorldVertexData(e))},updateVertexData:function(e){var t=e.renderData,n=t.data,i=e.node._uiProps.uiTransformComp,r=i.width,a=i.height,s=i.anchorX*r,o=i.anchorY*a,c=e.spriteFrame,l=c.insetLeft,u=c.insetRight,h=c.insetTop,_=c.insetBottom,f=r-l-u,d=a-h-_,p=r/(l+u),m=a/(h+_);p=Number.isNaN(p)||p>1?1:p,m=Number.isNaN(m)||m>1?1:m,f=f<0?0:f,d=d<0?0:d,n[0].x=-s,n[0].y=-o,n[1].x=l*p-s,n[1].y=_*m-o,n[2].x=n[1].x+f,n[2].y=n[1].y+d,n[3].x=r-s,n[3].y=a-o,t.vertDirty=!1},fillBuffers:function(e,t){e.node.hasChangedFlags&&this.updateWorldVertexData(e);var n=t.acquireBufferBatch(),i=e.renderData,r=i.data,a=n.byteOffset>>2,s=i.vertexCount,o=n.indicesOffset,c=n.vertexOffset,l=e.spriteFrame.uvSliced;n.request(s,i.indicesCount)||(n=t.currBufferBatch,a=0,o=0,c=0);for(var u=n.vData,h=n.iData,_=4;_<20;++_){var f=r[_],d=l[_-4];u[a++]=f.x,u[a++]=f.y,u[a++]=f.z,u[a++]=d.u,u[a++]=d.v,Cn.toArray(u,e.color,a),a+=4}for(var p=0;p<3;++p)for(var m=0;m<3;++m){var g=c+4*p+m;h[o++]=g,h[o++]=g+1,h[o++]=g+4,h[o++]=g+1,h[o++]=g+5,h[o++]=g+4}},updateWorldVertexData:function(e){var t=e.node,n=e.renderData.data;t.getWorldMatrix(jZ);for(var i=0;i<4;++i)for(var r=n[i],a=0;a<4;++a){var s=n[a],o=n[4+4*i+a];bn.set(WZ,s.x,r.y,0),bn.transformMat4(o,WZ,jZ)}}},XZ=[],YZ=0;YZ<4;YZ++)XZ.push(new bn);var KZ={useModel:!1,sizableWidth:0,sizableHeight:0,vRepeat:0,hRepeat:0,row:0,col:0,createData:function(e){return e.requestRenderData()},updateRenderData:function(e){var t=e.renderData,n=e.spriteFrame;if(n&&t&&(t.uvDirty||t.vertDirty)){var i=e.node._uiProps.uiTransformComp,r=Math.abs(i.width),a=Math.abs(i.height),s=n.getRect(),o=n.insetLeft,c=n.insetRight,l=s.width-o-c,u=n.insetTop,h=n.insetBottom,_=s.height-u-h;this.sizableWidth=r-o-c,this.sizableHeight=a-u-h,this.sizableWidth=this.sizableWidth>0?this.sizableWidth:0,this.sizableHeight=this.sizableHeight>0?this.sizableHeight:0,this.hRepeat=0===l?this.sizableWidth:this.sizableWidth/l,this.vRepeat=0===_?this.sizableHeight:this.sizableHeight/_,this.row=Math.ceil(this.vRepeat+2),this.col=Math.ceil(this.hRepeat+2),t.dataLength=Math.max(8,this.row+1,this.col+1),this.updateVerts(e),t.vertexCount=this.row*this.col*4,t.indicesCount=this.row*this.col*6,t.uvDirty=!1,t.vertDirty=!1}},fillBuffers:function(e,t){var n=e.node,i=e.renderData,r=t.acquireBufferBatch(),a=r.indicesOffset,s=r.byteOffset>>2,o=r.vertexOffset,c=i.vertexCount,l=i.indicesCount,u=r.vData,h=r.iData;r.request(c,l)||(r=t.currBufferBatch,s=0,a=0,o=0);var _=e.spriteFrame,f=_.isRotated(),d=_.uv,p=_.uvSliced,m=_.getRect(),g=_.insetLeft,v=_.insetRight,y=m.width-g-v,S=_.insetTop,E=_.insetBottom,T=m.height-S-E,A=n.worldMatrix;this.fillVertices(u,s,A,this.row,this.col,i.data);for(var x=0,C=0,R=0,b=this.row;RT?this.sizableHeight>=R*T?1:this.vRepeat%1:this.vRepeat;for(var w=0,I=this.col;wy?this.sizableWidth>=w*y?1:this.hRepeat%1:this.hRepeat;var O=s+3,P=O+1;f?(u[O]=d[0],u[P]=d[1],u[O+9]=d[0],u[P+9]=d[1]+(d[7]-d[1])*x,u[O+18]=d[0]+(d[6]-d[0])*C,u[P+18]=d[1],u[O+27]=u[O+18],u[P+27]=u[P+9]):(0===w?u[O]=d[0]:w>0&&w0&&R0&&w0&&R0&&w0&&R1?1:i.width/(h+_),v=i.height/(d+p)>1?1:i.height/(d+p);t=f>0?Math.floor(1e3*this.sizableWidth)/1e3%f==0?f:this.sizableWidth%f:this.sizableWidth,n=m>0?Math.floor(1e3*this.sizableHeight)/1e3%m==0?m:this.sizableHeight%m:this.sizableHeight;for(var y=0;y<=this.col;y++)0===y?r[y].x=-l:y>0&&y0?y===this.col-1?r[y].x=h+t+f*(y-2)-l:r[y].x=h+Math.min(f,this.sizableWidth)+f*(y-2)-l:r[y].x=h+this.sizableWidth-l:y===this.col&&(r[y].x=Math.min(h+this.sizableWidth+_,o)-l);for(var S=0;S<=this.row;S++)0===S?r[S].y=-u:S>0&&S0?S===this.row-1?r[S].y=p+n+(S-2)*m-u:r[S].y=p+Math.min(m,this.sizableHeight)+(S-2)*m-u:r[S].y=p+this.sizableHeight-u:S===this.row&&(r[S].y=Math.min(p+this.sizableHeight+d,c)-u)}},ZZ=Kq.Type,QZ=Kq.FillType,JZ=e("spriteAssembler",{getAssembler:function(e){var t=VZ,n=e;switch(n.type){case ZZ.SLICED:t=qZ;break;case ZZ.TILED:t=KZ;break;case ZZ.FILLED:t=n.fillType===QZ.RADIAL?GZ:bZ}return t}});Kq.Assembler=JZ;var $Z=VH.sharedManager,eQ={createData:function(e){var t=e.requestRenderData();return t.dataLength=4,t.vertexCount=4,t.indicesCount=6,t.vData=new Float32Array(36),t},updateRenderData:function(e){e.type===Sj.IMAGE_STENCIL&&(VZ.updateRenderData(e),VZ.updateColor(e))},fillBuffers:function(e,t){(e.type!==Sj.IMAGE_STENCIL||e.spriteFrame)&&($Z.pushMask(e),t.finishMergeBatches(),function(e,t){$Z.clear(e),t.commitModel(e,e._clearModel,e._clearStencilMtl)}(e,t),function(e,t){if($Z.enterLevel(e),e.type===Sj.IMAGE_STENCIL){VZ.fillBuffers(e,t);var n=e.graphics.getMaterialInstance(0);t.forceMergeBatches(n,e.spriteFrame,e.graphics)}else e.graphics.updateAssembler(t)}(e,t),$Z.enableMask())}},tQ={fillBuffers:function(){$Z.exitMask()}},nQ={getAssembler:function(){return eQ}},iQ={getAssembler:function(){return tQ}};Ij.Assembler=nQ,Ij.PostAssembler=iQ;var rQ=new Po(null),aQ=new Hn,sQ=e("UI",function(){var e=t.prototype;function t(e){var t=this;this.device=void 0,this._screens=[],this._bufferBatchPool=new l_((function(){return new WX(t)}),128),this._drawBatchPool=void 0,this._meshBuffers=new Map,this._customMeshBuffers=new Map,this._meshBufferUseCount=new Map,this._batches=void 0,this._doUploadBuffersCall=new Map,this._emptyMaterial=new em,this._currScene=null,this._currMaterial=this._emptyMaterial,this._currTexture=null,this._currSampler=null,this._currMeshBuffer=null,this._currStaticRoot=null,this._currComponent=null,this._currTransform=null,this._currTextureHash=0,this._currSamplerHash=0,this._currBlendTargetHash=0,this._currLayer=0,this._currDepthStencilStateStage=null,this._parentOpacity=1,this._descriptorSetCache=new cQ,this._root=e,this.device=e.device,this._batches=new u_(64),this._drawBatchPool=new c_((function(){return new vY}),128)}return e.acquireBufferBatch=function(e){void 0===e&&(e=VW);var t=e===VW?36:qW(e);return this._currMeshBuffer&&this._currMeshBuffer.vertexFormatBytes===t||this._requireBufferBatch(e),this._currMeshBuffer},e.registerCustomBuffer=function(e,t){var n;e instanceof WX?n=e:(n=this._bufferBatchPool.add()).initialize(e,t||this._recreateMeshBuffer.bind(this,e));var i=n.vertexFormatBytes,r=this._customMeshBuffers.get(i);return r||(r=[],this._customMeshBuffers.set(i,r)),r.push(n),n},e.unRegisterCustomBuffer=function(e){var t=this._customMeshBuffers.get(e.vertexFormatBytes);if(t)for(var n=0;n0){for(var e,t=this._doUploadBuffersCall,n=Z(t.keys());!(e=n()).done;){var i=e.value;t.get(i).call(i,this)}for(var r,a=this._meshBuffers,s=Z(a.keys());!(r=s()).done;){var o=r.value,c=a.get(o);c&&c.forEach((function(e){e.uploadBuffers(),e.reset()}))}for(var l,u=this._customMeshBuffers,h=Z(u.keys());!(l=h()).done;){var _=l.value,f=u.get(_);f&&f.forEach((function(e){e.uploadBuffers(),e.reset()}))}this._descriptorSetCache.update()}},e.reset=function(){for(var e=0;e0&&!e._static)for(var r=e.children,a=0;a=r.length?this._currMeshBuffer=this._createMeshBuffer(e):this._currMeshBuffer=r[a],this._meshBufferUseCount.set(i,a+1),t&&n&&this._currMeshBuffer.request(t,n)},e._screenSort=function(e,t){return e.node.getSiblingIndex()-t.node.getSiblingIndex()},e._applyOpacity=function(e){for(var t=e.color.a/255,n=this._parentOpacity*=t,i=this.currBufferBatch,r=i.byteOffset>>2,a=i.vData,s=i.lastByteOffset>>2,o=i.vertexFormatBytes/4,c=s;c=0;n--){var i=fQ[n],r=i.fontFamilyName;if(t-i.startTime>3e3)E(4933,r),i.onComplete(null,r),fQ.splice(n,1);else{var a=i.refWidth,s="40px "+r;uQ.font=s,a!==wk(uQ,"BES bswy:->@123丁ぁᄁ",s)?(fQ.splice(n,1),i.onComplete(null,r)):e=!1}}e&&(clearInterval(hQ),hQ=-1)}function pQ(e,t,n){var i=function(e){var t=e.lastIndexOf(".ttf");if(-1===t)return e;var n,i=e.lastIndexOf("/");return-1!==(n=-1===i?e.substring(0,t)+"_LABEL":e.substring(i+1,t)+"_LABEL").indexOf(" ")&&(n='"'+n+'"'),n}(e);if(_Q[i])n(null,i);else{if(!uQ){var r=document.createElement("canvas");r.width=100,r.height=100,uQ=r.getContext("2d")}var a=wk(uQ,"BES bswy:->@123丁ぁᄁ","40px "+i),s=document.createElement("style");s.type="text/css";var o="";Number.isNaN(i)?o+="@font-face { font-family:"+i+"; src:":o+='@font-face { font-family:"'+i+'"; src:',o+='url("'+e+'");',s.textContent=o+"}",document.body.appendChild(s);var c=document.createElement("div"),l=c.style;if(l.fontFamily=i,c.innerHTML=".",l.position="absolute",l.left="-100px",l.top="-100px",document.body.appendChild(c),function(){if(void 0===lQ)if("FontFace"in window){var e=/Gecko.*Firefox\/(\d+)/.exec(window.navigator.userAgent),t=/OS X.*Version\/10\..*Safari/.exec(window.navigator.userAgent)&&/Apple/.exec(window.navigator.vendor);lQ=e?parseInt(e[1],10)>42:!t}else lQ=!1;return lQ}())!function(e,t,n){var i=new Promise((function(n,i){!function r(){Date.now()-e>=3e3?i():document.fonts.load("40px "+t).then((function(e){e.length>=1?n():setTimeout(r,100)}),(function(){i()}))}()})),r=null,a=new Promise((function(e,t){r=setTimeout(t,3e3)}));Promise.race([a,i]).then((function(){r&&(clearTimeout(r),r=null),n(null,t)}),(function(){E(4933,t),n(null,t)}))}(Date.now(),i,n);else{var u={fontFamilyName:i,refWidth:a,onComplete:n,startTime:Date.now()};fQ.push(u),-1===hQ&&(hQ=setInterval(dQ,100))}_Q[i]=s}}function mQ(e,t,n,i){var r=new uk;r._nativeUrl=e,r._nativeAsset=t,i(null,r)}function gQ(e){return void 0===(e=e||{}).includeNormal&&(e.includeNormal=!0),void 0===e.includeUV&&(e.includeUV=!0),e}sI.register({".font":pQ,".eot":pQ,".ttf":pQ,".woff":pQ,".svg":pQ,".ttc":pQ}),fI.register({".font":mQ,".eot":mQ,".ttf":mQ,".woff":mQ,".svg":mQ,".ttc":mQ}),i.UI={MeshBuffer:WX,spriteAssembler:JZ,graphicsAssembler:aK,labelAssembler:xZ};var vQ=new bn,yQ=new bn,SQ=new bn,EQ=new bn,TQ=new bn,AQ=new bn,xQ=new bn,CQ=new bn,RQ=new bn,bQ=new bn,wQ=new bn,IQ=new bn,OQ=new bn(0,0,0),PQ=new bn(0,0,0);function MQ(e,t,n,i){void 0===e&&(e=.5),void 0===t&&(t=.5),void 0===n&&(n=2),void 0===i&&(i={});var r=.5*n,a=i.radialSegments||32,s=i.heightSegments||1,o=void 0===i.capped||i.capped,c=i.arc||2*Math.PI,l=0;o||(e>0&&l++,t>0&&l++);var u=(a+1)*(s+1);o&&(u+=(a+1)*l+a*l);var h=a*s*6;o&&(h+=a*l*3);var _=new Array(h),f=new Array(3*u),d=new Array(3*u),p=new Array(2*u),m=Math.max(e,t),g=new bn(-m,-r,-m),v=new bn(m,r,m),y=Math.sqrt(m*m+r*r),S=0,E=0;return function(){for(var i=[],o=e-t,l=o*o/n*Math.sign(o),u=0;u<=s;u++){for(var h=[],m=u/s,g=m*o+t,v=0;v<=a;++v){var y=v/a,T=y*c,A=Math.sin(T),x=Math.cos(T);f[3*S]=g*A,f[3*S+1]=m*n-r,f[3*S+2]=g*x,bn.normalize(OQ,bn.set(PQ,A,-l,x)),d[3*S]=OQ.x,d[3*S+1]=OQ.y,d[3*S+2]=OQ.z,p[2*S]=2*(1-y)%1,p[2*S+1]=m,h.push(S),++S}i.push(h)}for(var C=0;C0&&T(!1),e>0&&T(!0)),{positions:f,normals:d,uvs:p,indices:_,minPos:g,maxPos:v,boundingRadius:y};function T(n){for(var i=n?e:t,s=n?1:-1,o=S,l=1;l<=a;++l)f[3*S]=0,f[3*S+1]=r*s,f[3*S+2]=0,d[3*S]=0,d[3*S+1]=s,d[3*S+2]=0,p[2*S]=.5,p[2*S+1]=.5,++S;for(var u=S,h=0;h<=a;++h){var m=h/a*c,g=Math.cos(m),v=Math.sin(m);f[3*S]=i*v,f[3*S+1]=r*s,f[3*S+2]=i*g,d[3*S]=0,d[3*S+1]=s,d[3*S+2]=0,p[2*S]=.5-.5*v*s,p[2*S+1]=.5+.5*g,++S}for(var y=0;y0&&(i[i.length-1]=1),{positions:n,indices:i,minPos:{x:1,y:1,z:0},maxPos:{x:-1,y:-1,z:0},boundingRadius:1,primitiveMode:Va.TRIANGLE_FAN}},translate:function(e,t){for(var n=t.x||0,i=t.y||0,r=t.z||0,a=Math.floor(e.positions.length/3),s=0;sc?c<<16|o:o<<16|c;void 0===r[l]&&(r[l]=0,i.push(o,c))}return e.indices=i,e.primitiveMode=Va.LINE_LIST,e},wireframe:function(e){for(var t=[[0,1],[1,2],[2,0]],n=[],i={},r=0;ro?o<<16|s:s<<16|o;void 0===i[c]&&(i[c]=0,n.push(s,o))}return n},invWinding:function(e){for(var t=[],n=0;n