System.register([],(function(t,e){"use strict";return{execute:function(){function i(t,e){for(var i=0;i=0||(r[i]=t[i]);return r}function f(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function _(t,e){if(t){if("string"==typeof t)return d(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?d(t,e):void 0}}function d(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function m(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}function g(t){var e=m(t,"string");return"symbol"==typeof e?e:String(e)}function y(t,e,i,n){i&&Object.defineProperty(t,e,{enumerable:i.enumerable,configurable:i.configurable,writable:i.writable,value:i.initializer?i.initializer.call(n):void 0})}function v(t,e,i,n,r){var s={};return Object.keys(n).forEach((function(t){s[t]=n[t]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,n){return n(t,e,i)||i}),s),r&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(r):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(t,e,s),s=null),s}function b(t,e){const i="undefined"==typeof window?global:window;return void 0===i[t]?i[t]=e:i[t]}t({$:function(t){return TR.test(t)},J:pR,N:AR,P:CR,W:DR,X:BR,Y:IR,Z:MR,_:p,a0:function(t){return xR.test(t)},a1:kR,a2:RR,a3:FR,aA:F2,aC:function(t,e){for(var i=t,n="";null!==i&&i!==e;)n=i.name+"/"+n,i=i.parent;return n.slice(0,-1)},aD:uY,aR:ps,aT:nr,aV:Nn,aX:Ur,a_:$r,az:R2,b0:gs,b2:Ss,b4:fr,b9:Qi,bB:Ie,bC:Ee,bD:Re,bI:function(t){t>0&&(St=t)},bM:Dt,bN:function(t){for(var e,i=p(t);!(e=i()).done;)Bt(e.value)},bO:function(t){return Tt||(Tt="undefined"==typeof Proxy?{}:new Proxy(t,{get:function(t,e,i){return Bt(e),Reflect.get(t,e,i)}})),Tt},bP:$o,bQ:th,bT:Vi,bU:Ni,ba:Zi,bb:$i,bc:tn,bd:en,be:nn,bf:rn,bg:sn,bh:an,bi:on,bj:hn,bk:un,bl:ln,bm:cn,bn:fn,bo:_n,bp:dn,bq:pn,br:mn,bs:gn,bt:yn,bu:xn,bv:Tn,c3:function(t){return t[hu]},c6:Bo,c8:Q,c9:X,cH:qf,cI:Bc,cJ:jc,cU:lu,cW:Xf,cZ:Ti,c_:Ai,ca:J,cb:Y,cc:K,cd:rt,ce:it,cf:ht,cg:at,ch:lt,ci:_t,cj:dt,ck:ft,d1:vo,d2:bo,d5:function(t,e){e.forEach((function(e){Object.getOwnPropertyNames(e.prototype).forEach((function(i){"constructor"!==i&&Object.defineProperty(t.prototype,i,Object.getOwnPropertyDescriptor(e.prototype,i))}))}))},d6:Z,d7:function(t,e){return kh(t,e,0)},d8:kh,d9:function(t,e,i){for(var n=0,r=t.length-1,s=r>>>1;n<=r;s=n+r>>>1){var a=t[s];if(i(a,e)<0)r=s-1;else{if(!(i(a,e)>0))return s;n=s+1}}return~n},dX:ly,dZ:J$,da:function(){},db:function(){},dc:Me,dd:Zf,dr:GP,fw:function(){return Promise.resolve()},g:CSt,g7:nVt,gQ:rGt,gR:sGt,hh:IZt}),b("CC_WECHAT",!1),b("CC_XIAOMI",!1),b("CC_ALIPAY",!1),b("CC_BYTEDANCE",!1),b("CC_OPPO",!1),b("CC_VIVO",!1),b("CC_HUAWEI",!1),b("CC_MIGU",!1),b("CC_HONOR",!1),b("CC_COCOS_RUNTIME",!1);const S=!1;b("CC_EDITOR",!1);const w=!1;b("CC_PREVIEW",!1),b("CC_BUILD",!0),b("CC_TEST",!1),b("CC_DEBUG",!1),b("CC_DEV",!1),b("CC_MINIGAME",!1),b("CC_RUNTIME_BASED",!1),b("CC_SUPPORT_JIT",!0),b("CC_JSB",!1);const x=!1;var T="undefined"==typeof window?global:window,A=t("aO",{_global:T}),C=A;A.internal={};var D=t("aN","3.8.6");T.CocosEngine=C.ENGINE_VERSION=D,T.cc=C;var B=void 0!==globalThis.jsb&&void 0!==jsb.window?jsb.window:globalThis;T.ccwindow=B;var I=2147483647;function M(t){return(t>0)-(t<0)}function P(t,e){return t^(t^e)&-(t65535)<<4,e|=i=((t>>>=e)>255)<<3,e|=i=((t>>>=i)>15)<<2,(e|=i=((t>>>=i)>3)<<1)|(t>>>=i)>>1}function O(t){return 16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24}function k(t){var e=32;return(t&=-t)&&e--,65535&t&&(e-=16),16711935&t&&(e-=8),252645135&t&&(e-=4),858993459&t&&(e-=2),1431655765&t&&(e-=1),e}function R(t){return--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,1+(t|=t>>>16)}var F=new Array(256);!function(t){for(var e=0;e<256;++e){var i=e,n=e,r=7;for(i>>>=1;i;i>>>=1)n<<=1,n|=1&i,--r;t[e]=n<>31;return(t^e)-e},countTrailingZeros:k,deinterleave2:function(t,e){return(t=65535&((t=16711935&((t=252645135&((t=858993459&((t=t>>>e&1431655765)|t>>>1))|t>>>2))|t>>>4))|t>>>16))<<16>>16},deinterleave3:function(t,e){return(t=1023&((t=4278190335&((t=251719695&((t=3272356035&((t=t>>>e&1227133513)|t>>>2))|t>>>4))|t>>>8))|t>>>16))<<22>>22},interleave2:function(t,e){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t&=65535)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e&=65535)|e<<8))|e<<4))|e<<2))|e<<1))<<1},interleave3:function(t,e,i){return t=1227133513&((t=3272356035&((t=251719695&((t=4278190335&((t&=1023)|t<<16))|t<<8))|t<<4))|t<<2),(t|=(e=1227133513&((e=3272356035&((e=251719695&((e=4278190335&((e&=1023)|e<<16))|e<<8))|e<<4))|e<<2))<<1)|(i=1227133513&((i=3272356035&((i=251719695&((i=4278190335&((i&=1023)|i<<16))|i<<8))|i<<4))|i<<2))<<2},isPow2:function(t){return!(t&t-1||!t)},log10:function(t){return t>=1e9?9:t>=1e8?8:t>=1e7?7:t>=1e6?6:t>=1e5?5:t>=1e4?4:t>=1e3?3:t>=100?2:t>=10?1:0},log2:E,max:P,min:function(t,e){return e^(t^e)&-(t>>k(t)+1},nextPow2:R,parity:function(t){return t^=t>>>16,t^=t>>>8,t^=t>>>4,27030>>>(t&=15)&1},popCount:O,prevPow2:function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)-(t>>>1)},reverse:function(t){return F[255&t]<<24|F[t>>>8&255]<<16|F[t>>>16&255]<<8|F[t>>>24&255]},sign:M});t("aP",L);var V=B.document,N="https://github.com/cocos/cocos-engine/blob/"+D+"/EngineErrorMap.md",z=null,U=console.log.bind(console),G=U,H=U,W=function(t,e){if(!t){for(var i=arguments.length,n=new Array(i>2?i-2:0),r=2;r2?i-2:0),r=2;r4){var e=function(t){if(C.game.canvas){if(!z){var e=V.createElement("Div");e.setAttribute("id","logInfoDiv"),e.setAttribute("width","200");var i=C.game.canvas.height;e.setAttribute("height",""+i);var n=e.style;n.zIndex="99999",n.position="absolute",n.top=n.left="0",(z=V.createElement("textarea")).setAttribute("rows","20"),z.setAttribute("cols","30"),z.setAttribute("disabled","true");var r=z.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",e.appendChild(z),C.game.canvas.parentNode.appendChild(e)}z.value=z.value+t+"\r\n",z.scrollTop=z.scrollHeight}};H=function(){e("ERROR : "+q.apply(void 0,arguments))},W=function(t,i){if(!t){for(var n=arguments.length,r=new Array(n>2?n-2:0),s=2;s2?i-2:0),r=2;r1?n-1:0),s=1;s1?e-1:0),n=1;n1?e-1:0),n=1;n1?e-1:0),n=1;n1?e-1:0),n=1;n2?i-2:0),r=2;r1?e-1:0),n=1;no.count&&(r("'%s' is deprecated, please use '%s' instead. "+a,t+"."+e,i+"."+n),o.count++)},t("bJ",pt=function(t,e,i){null!=t&&i.forEach((function(i){var n=wt++;xt.set(n,{id:n,count:0,logTimes:void 0!==i.logTimes?i.logTimes:St});var r=null!=i.target?i.target:t,s=null!=i.newName?i.newName:i.name,a=null!=i.targetName?i.targetName:e,o=r===t,h=i.suggest?"("+i.suggest+")":"";if(null!=i.customFunction)t[i.name]=function(){var t;return yt(e,i.name,a,s,Y,n,h),(t=i.customFunction).call.apply(t,[this].concat(Array.prototype.slice.call(arguments)))};else if(null!=i.customSetter||null!=i.customGetter){var u=null!=i.customSetter,l=null!=i.customGetter;u&&l?Object.defineProperty(t,i.name,{get:function(){return yt(e,i.name,a,s,Y,n,h),i.customGetter.call(this)},set:function(t){yt(e,i.name,a,s,Y,n,h),i.customSetter.call(this,t)},enumerable:!1}):u?Object.defineProperty(t,i.name,{set:function(t){yt(e,i.name,a,s,Y,n,h),i.customSetter.call(this,t)},enumerable:!1}):l&&Object.defineProperty(t,i.name,{get:function(){return yt(e,i.name,a,s,Y,n,h),i.customGetter.call(this)},enumerable:!1})}else Object.defineProperty(t,i.name,{get:function(){return yt(e,i.name,a,s,Y,n,h),o?this[s]:r[s]},set:function(t){yt(e,i.name,a,s,Y,n,h),o?this[s]=t:r[s]=t},enumerable:!1})}))}),vt=function(t,e,i,n,r){var s=xt.get(n);s&&s.logTimes>s.count&&(i("'%s' has been removed. "+r,t+"."+e),s.count++)},t("bK",mt=function(t,e,i){null!=t&&i.forEach((function(i){var n=wt++;xt.set(n,{id:n,count:0,logTimes:void 0!==i.logTimes?i.logTimes:St});var r=i.suggest?"("+i.suggest+")":"";Object.defineProperty(t,i.name,{get:function(){return vt(e,i.name,J,n,r)},set:function(){vt(e,i.name,J,n,r)},enumerable:!1})}))}),t("bL",gt=function(){});var Tt,At,Ct={};function Dt(t){for(var e in t){var i=t[e];Ct[e]=i}}function Bt(t){var e=Ct[t];if(e){var i=e.newName,n=e.since;e.removed?i?ht(16003,t,n,i):ht(16002,t,n):i?at(16001,t,n,i):at(16e3,t,n)}}var It=function(){function t(t){this.id=0|998*Math.random(),this.prefix=t?t+".":""}return t.prototype.getNewId=function(){return this.prefix+(++this.id).toString()},t}();At=It,It.global=new At("global");var Mt=new It("TmpCId."),Pt="undefined"==typeof Symbol?"__aliases__":Symbol("[[Aliases]]"),Et="__classname__",Ot="__cid__";function kt(t){return"number"==typeof t||t instanceof Number}function Rt(t){return"string"==typeof t||t instanceof String}function Ft(t){for(var e in t)return!1;return!0}var Lt,Vt=(Lt={value:void 0,enumerable:!1,writable:!1,configurable:!0},function(t,e,i,n,r){Lt.value=i,Lt.writable=n,Lt.enumerable=r,Object.defineProperty(t,e,Lt),Lt.value=void 0}),Nt=function(){var t={get:void 0,set:void 0,enumerable:!1};return function(e,i,n,r,s,a){void 0===s&&(s=!1),void 0===a&&(a=!1),"boolean"==typeof r&&(it(1031),s=r,r=void 0),t.get=n,t.set=r,t.enumerable=s,t.configurable=a,Object.defineProperty(e,i,t),t.get=void 0,t.set=void 0}}(),zt=function(){var t={get:void 0,enumerable:!1,configurable:!1};return function(e,i,n,r,s){t.get=n,t.enumerable=r,t.configurable=s,Object.defineProperty(e,i,t),t.get=void 0}}(),Ut=function(){var t={set:void 0,enumerable:!1,configurable:!1};return function(e,i,n,r,s){t.set=n,t.enumerable=r,t.configurable=s,Object.defineProperty(e,i,t),t.set=void 0}}();function Gt(t){var e=Object.create(null);return t&&(e["."]=1,e["/"]=1,delete e["."],delete e["/"]),e}function Ht(t){if("function"==typeof t){var e=t.prototype;if(e&&e.hasOwnProperty(Et)&&e[Et])return e[Et];var i="";if(t.name)i=t.name;else if(t.toString){var n,r=t.toString();(n="["===r.charAt(0)?/\[\w+\s*(\w+)\]/.exec(r):/^function\s*(\w+)/.exec(r))&&2===n.length&&(i=n[1])}return"Object"!==i?i:""}return t&&t.constructor?Ht(t.constructor):""}function Wt(t,e,i,n){var r=/([^.]+)$/,s=r.exec(e)[0],a=r.exec(i)[0];function o(){return this[a]}n?Nt(t,s,o,(function(t){this[a]=t})):zt(t,s,o)}function jt(t,e,i,n){for(var r in i)Wt(t,e+"."+r,i[r],n)}var qt=/(%d)|(%s)/,Xt=/%s/;function Yt(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n0){--this.count;var t=this._pool[this.count];return this._pool[this.count]=null,t}return null},t.put=function(t){var e=this._pool;if(this.count=0&&(this._pool.length=t,this.count>t&&(this.count=t))},e}(),ye=function(){function t(t){this.i=0,this.array=t}var e=t.prototype;return e.remove=function(t){var e=this.array.indexOf(t);e>=0&&this.removeAt(e)},e.removeAt=function(t){this.array.splice(t,1),t<=this.i&&--this.i},e.fastRemove=function(t){var e=this.array.indexOf(t);e>=0&&this.fastRemoveAt(e)},e.fastRemoveAt=function(t){var e=this.array;e[t]=e[e.length-1],--e.length,t<=this.i&&--this.i},e.push=function(t){this.array.push(t)},n(t,[{key:"length",get:function(){return this.array.length},set:function(t){this.array.length=t,this.i>=t&&(this.i=t-1)}}]),t}();function ve(t,e){t.splice(e,1)}function be(t,e){var i=t.length;e<0||e>=i||(t[e]=t[i-1],t.length=i-1)}function Se(t,e){var i=t.indexOf(e);return i>=0&&(ve(t,i),!0)}function we(t,e){var i=t.indexOf(e);i>=0&&(t[i]=t[t.length-1],--t.length)}function xe(t,e){var i=t.findIndex(e);if(i>=0){var n=t[i];return ve(t,i),n}}function Te(t,e){return t.indexOf(e)>=0}function Ae(t){for(var e=0,i=arguments.length<=1?0:arguments.length-1;e0)for(var i,n=p(t);!(i=n()).done;)if(!(i.value instanceof e))return it(1300),!1;return!0}}),De={IDGenerator:It,Pool:ge,array:Ce,isNumber:kt,isString:Rt,isEmptyObject:Ft,getPropertyDescriptor:Kt,addon:Zt,mixin:$t,extend:te,getSuper:ee,isChildClassOf:ie,clear:ne,value:Vt,getset:Nt,get:zt,set:Ut,unregisterClass:ce,getClassName:Ht,setClassName:ue,setClassAlias:le,getClassByName:de,getClassById:_e,get _registeredClassNames(){return r({},se)},set _registeredClassNames(t){ne(se),Object.assign(se,t)},get _registeredClassIds(){return r({},re)},set _registeredClassIds(t){ne(re),Object.assign(re,t)},_getClassId:pe,getClassId:me,_setClassId:oe,_getClassById:fe,obsolete:Wt,obsoletes:jt,formatStr:Yt,shiftArguments:Jt,createMap:Gt};C.js=De;var Be=Object.freeze({__proto__:null,IDGenerator:It,Pool:ge,_getClassById:fe,_getClassId:pe,_idToClass:re,_nameToClass:se,_setClassId:oe,addon:Zt,array:Ce,clear:ne,copyAllProperties:function(t,e,i){for(var n=Object.getOwnPropertyNames(t),r=0,s=n.length;r=0&&t.length,t.length}t("bF",Be),Ie.isBitMask=function(t){return t&&Object.prototype.hasOwnProperty.call(t,"__bitmask__")},Ie.getList=function(t){return t.__bitmask__?t.__bitmask__:Ie.update(t)},Ie.update=function(t){Array.isArray(t.__bitmask__)||(t.__bitmask__=[]);var e=t.__bitmask__;for(var i in e.length=0,t){var n=t[i];Number.isInteger(n)&&e.push({name:i,value:n})}return e.sort((function(t,e){return t.value-e.value})),e},C.BitMask=Ie;var Pe=Object.prototype.hasOwnProperty;function Ee(t){return"__enums__"in t?t:(Vt(t,"__enums__",null,!0),Ee.update(t))}function Oe(t){Pe.call(t,"__enums__")}function ke(t){Oe(t);var e=t.__enums__||[];e.length=0;var i=!0;for(var n in t){var r=t[n],s=Number.isInteger(r);s||(i=!1),(s||"string"==typeof r&&t[r]!==Number.parseInt(n))&&e.push({name:n,value:r})}return i&&e.sort((function(t,e){return t.value-e.value})),t.__enums__=e,e}function Re(t){"__enums__"in t||Vt(t,"__enums__",null,!0)}Ee.update=function(t){for(var e=-1,i=Object.keys(t),n=0;n2?i-2:0),r=2;r1?e-1:0),n=1;ni){var n=e;e=i,i=n}return t=0;n--){var r=i[n];r.hasOwnProperty("__attrs__")&&r.__attrs__||ri(r,(e=i[n+1])&&e.__attrs__)}return ri(t,(e=i[0])&&e.__attrs__),t.__attrs__}function ai(t,e){var i=oi(t),n=e+ni,r={};for(var s in i)s.startsWith(n)&&(r[s.slice(n.length)]=i[s]);return r}function oi(t){return t.hasOwnProperty("__attrs__")&&t.__attrs__||si(t)}function hi(t,e,i,n){oi(t)[e+ni+i]=n}var ui=function(){function t(t,e){this.name=t,this.default=e}return t.prototype.toString=function(){return this.name},t}(),li=t("bX",new ui("Integer",0));C.Integer=li,C.CCInteger=li;var ci=t("bY",new ui("Float",0));C.Float=ci,C.CCFloat=ci;var fi=t("bZ",new ui("Boolean",!1));C.Boolean=fi,C.CCBoolean=fi;var _i=t("b_",new ui("String",""));function di(t,e){return function(i,n){var r='"'+Ht(i)+"."+n+'"',s=ai(i,n),a=s.type;if(a===li||a===ci?a="Number":a!==_i&&a!==fi||(a=""+a),a===t){if(s.hasOwnProperty("default")){var o=s.default;if(void 0!==o&&!Array.isArray(o)&&!$e(o)){var h=typeof o,u=t.toLowerCase();if(h===u)if("object"===u){if(!o||o instanceof s.ctor)return;at(3605,r,Ht(s.ctor))}else"Number"!==t&&at(3606,e,r,t);else{if("function"===h)return;t===_i.default&&null==o?at(3607,r):at(3611,e,r,h)}delete s.type}}}else at(3604,r)}}C.String=_i,C.CCString=_i;var pi=Object.freeze({__proto__:null,CCBoolean:fi,CCFloat:ci,CCInteger:li,CCString:_i,DELIMETER:ni,PrimitiveType:ui,attr:ai,createAttrs:si,createAttrsSingle:ri,getClassAttrs:oi,getObjTypeChecker_ET:function(t){return function(e,i){di("Object","type")(e,i);var n=oi(e)[i+ni+"default"],r=C.Class.getDefault(n);if(!Array.isArray(r)&&ie(t,C.ValueType)){var s=Ht(t),a=Yt('No need to specify the "type" of "%s.%s" because %s is a child class of ValueType.',Ht(e),i,s);n?X(a):at(3612,a,s,Ht(e),i,s)}}},getTypeChecker_ET:di,setClassAttr:hi}),mi={default:{},serializable:{},editorOnly:{},formerlySerializedAs:{}};function gi(t,e,i,n){if(!t.get&&!t.set&&t.hasOwnProperty("default")){var r="_N$"+e;t.get=function(){return this[r]},t.set=function(t){var e=this[r];this[r]=t,i.call(this,e)};var s={};for(var a in n[r]=s,mi){var o=mi[a];t.hasOwnProperty(a)&&(s[a]=t[a],o.canUsedInGet||delete t[a])}}}function yi(t,e,i,n){if(Array.isArray(e)){if(!(e.length>0))return ht(5508,i,n);t.type=e=e[0]}"function"==typeof e&&(e===String?t.type=C.String:e===Boolean?t.type=C.Boolean:e===Number&&(t.type=C.Float))}function vi(t,e,i){var n=t||void 0===e?{_short:!0}:{_short:!0,default:e};return i&&(n.type=i),n}function bi(t,e){if(!t||t.constructor!==Object){if(Array.isArray(t)&&t.length>0)return vi(e,[],t);if("function"==typeof t){var i=t;return vi(e,ie(i,C.ValueType)?new i:null,i)}return t instanceof ui?vi(e,void 0,t):vi(e,t)}return null}function Si(t,e){for(var i in t){var n=t[i],r=bi(n,!1);if(r&&(n=t[i]=r),n){var s=n.notify;s&&gi(n,i,s,t),"type"in n&&yi(n,n.type,e,i)}}}var wi=[];function xi(){return wi[wi.length-1]}function Ti(t,e,i){Ai(oi(t),e,i)}function Ai(t,e,i){t[""+e+ni+"type"]="Enum",t[""+e+ni+"enumList"]=Ee.getList(i)}C._RF={push:function(t,e,i,n){void 0===i&&(i=e,e=""),wi.push({uuid:e,script:i,module:t,exports:t.exports,beh:null,importMeta:n})},pop:function(){var t=wi.pop(),e=t.module,i=e.exports;if(i===t.exports){for(var n in i)return;e.exports=i=t.cls}},peek:xi};var Ci=ni,Di="__ctors__",Bi=t("c$","Enum"),Ii=t("d0","BitMask");function Mi(t,e){t.indexOf(e)<0&&t.push(e)}function Pi(t,e){Mi(t.__props__,e)}function Ei(t,e,i,n){Pi(t,i),Ui(t,n,e,i)}function Oi(t,e,i,n){var r=n.get;n.set,r&&(Ui(t,n,e,i),hi(t,i,"serializable",!1))}function ki(t){return"function"==typeof t?t():t}function Ri(t,e,i){var n=i.ctor;return Vt(n,Di,!0,!0),n.prototype,e&&(n.$super=e),ue(t,n),n}function Fi(t,e,i){var n=C.Component,r=xi();if(r&&ie(e,n)){if(ie(r.cls,n))return ht(3615),null;t=t||r.script}var s=Ri(t,e,i);if(r)if(ie(e,n)){var a=r.uuid;a&&oe(a,s),r.cls=s}else ie(r.cls,n)||(r.cls=s);return s}function Li(t,e,i,n){if(t.__props__=[],n&&n.__props__&&(t.__props__=n.__props__.slice()),i)for(var r in Si(i,e),i){var s=i[r];s.get||s.set?Oi(t,e,r,s):Ei(t,e,r,s)}var a=oi(t);t.__values__=t.__props__.filter((function(t){return!1!==a[""+t+Ci+"serializable"]}))}function Vi(t){var e=t.name,i=t.extends,n=Fi(e,i,t);e||(e=C.js.getClassName(n)),n._sealed=!0,i&&(i._sealed=!1),Li(n,e,t.properties,i);var r=t.editor;return r&&ie(i,C.Component)&&C.Component._registerEditorProps(n,r),n}function Ni(t){return null==t||null==t.hasOwnProperty?void 0:t.hasOwnProperty("__values__")}Vi._isCCClass=function(t){return null==t||null==t.hasOwnProperty?void 0:t.hasOwnProperty(Di)},Vi.fastDefine=function(t,e,i){ue(t,e);for(var n=e.__props__=e.__values__=Object.keys(i),r=oi(e),s=0;s=2&&((r||a())[s+"min"]=l[0],r[s+"max"]=l[1],l.length>2&&(r[s+"step"]=l[2])),u("step","number"),u("userData","object")}Vi.isArray=function(t){return t=ki(t),Array.isArray(t)},Vi.getDefault=ki,Vi.escapeForJS=function(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")},Vi.IDENTIFIER_RE=/^[A-Za-z_$][0-9A-Za-z_$]*$/,Vi.getNewValueTypeCode=function(t){for(var e=Ht(t),i=t.constructor,n="new "+e+"(",r=0;ri){var n=e;e=i,i=n}return ti?i:t}function tn(t){return t<0?0:t>1?1:t}function en(t,e,i){return t+(e-t)*i}function nn(t){return t*ji}function rn(t){return t*qi}function sn(){return Xi()}function an(t){Xi=t}function on(t,e){return sn()*(e-t)+t}function hn(t,e){return Hi(on(t,e))}function un(t){return(t=(9301*t+49297)%233280)/233280}function ln(t,e,i){return un(t)*(i-e)+e}function cn(t,e,i){return Hi(ln(t,e,i))}function fn(t){return R(t)}function _n(t,e){return t-Hi(t/e)*e}function dn(t,e){return t=_n(t,2*e),e-Gi(t-e)}function pn(t,e,i){return(i-t)/(e-t)}function mn(t){return Gi(t.x)>Gi(t.y)?Gi(t.x)>Gi(t.z)?t.x:t.z:Gi(t.y)>Gi(t.z)?t.y:t.z}function gn(t,e){return Gi(t)>Gi(e)?t:e}function yn(t,e){e.forEach((function(e){Object.defineProperty(t,e,{enumerable:!0})}))}var vn,bn,Sn=(vn=new Float32Array(1),bn=new Int32Array(vn.buffer),function(t){vn[0]=t;var e=bn[0],i=e>>16&32768,n=2147483647&e,r=n-(112<<23)+4096>>13;return r=n<113<<23?0:r,r=n>=143<<23?31744:r,r=n>255<<23?32256:r,bn[0]=i|r,bn[0]}),wn=function(){var t=new Float32Array(1),e=new Int32Array(t.buffer);return function(i){var n,r=32767&i,s=r<<13;return 31744!==s?(s+=112<<23,0===r?s=(1048575&s)>>1:32767===r&&(s=2147483647)):s=2139095040,n=(i>>15&1)<<31|s,e[0]=n,t[0]}}();function xn(t){return Sn(t)}function Tn(t){return wn(t)}var An=Math.abs,Cn=Math.max,Dn=Math.min,Bn=Math.PI,In=Math.sin,Mn=Math.cos,Pn=Math.atan2,En=Math.sqrt,On=Math.ceil,kn=Math.floor,Rn=Math.round;function Fn(t,e,i,n){return Object.freeze(new Vn(t,e,i,n))}var Ln,Vn=t("aU",function(t){function e(e,i,n,r){var s;return s=t.call(this)||this,"object"==typeof e?(s.x=e.x,s.y=e.y,s.z=e.z,s.w=e.w):(s.x=e||0,s.y=i||0,s.z=n||0,s.w=r||0),s}s(e,t),e.clone=function(t){return new e(t.x,t.y,t.z,t.w)},e.copy=function(t,e){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t},e.set=function(t,e,i,n,r){return t.x=e,t.y=i,t.z=n,t.w=r,t},e.fromColor=function(t,e){return t.x=e.r,t.y=e.g,t.z=e.b,t.w=e.a,t},e.angle=function(t,e){var i=t.y*e.z-t.z*e.y,n=t.z*e.x-t.x*e.z,r=t.x*e.y-t.y*e.x,s=t.x*e.x+t.y*e.y+t.z*e.z;return Pn(En(i*i+n*n+r*r),s)},e.add=function(t,e,i){return t.x=e.x+i.x,t.y=e.y+i.y,t.z=e.z+i.z,t.w=e.w+i.w,t},e.subtract=function(t,e,i){return t.x=e.x-i.x,t.y=e.y-i.y,t.z=e.z-i.z,t.w=e.w-i.w,t},e.multiply=function(t,e,i){return t.x=e.x*i.x,t.y=e.y*i.y,t.z=e.z*i.z,t.w=e.w*i.w,t},e.divide=function(t,e,i){return t.x=e.x/i.x,t.y=e.y/i.y,t.z=e.z/i.z,t.w=e.w/i.w,t},e.ceil=function(t,e){return t.x=On(e.x),t.y=On(e.y),t.z=On(e.z),t.w=On(e.w),t},e.floor=function(t,e){return t.x=kn(e.x),t.y=kn(e.y),t.z=kn(e.z),t.w=kn(e.w),t},e.min=function(t,e,i){return t.x=Dn(e.x,i.x),t.y=Dn(e.y,i.y),t.z=Dn(e.z,i.z),t.w=Dn(e.w,i.w),t},e.max=function(t,e,i){return t.x=Cn(e.x,i.x),t.y=Cn(e.y,i.y),t.z=Cn(e.z,i.z),t.w=Cn(e.w,i.w),t},e.round=function(t,e){return t.x=Rn(e.x),t.y=Rn(e.y),t.z=Rn(e.z),t.w=Rn(e.w),t},e.multiplyScalar=function(t,e,i){return t.x=e.x*i,t.y=e.y*i,t.z=e.z*i,t.w=e.w*i,t},e.scaleAndAdd=function(t,e,i,n){return t.x=e.x+i.x*n,t.y=e.y+i.y*n,t.z=e.z+i.z*n,t.w=e.w+i.w*n,t},e.distance=function(t,e){var i=e.x-t.x,n=e.y-t.y,r=e.z-t.z,s=e.w-t.w;return En(i*i+n*n+r*r+s*s)},e.squaredDistance=function(t,e){var i=e.x-t.x,n=e.y-t.y,r=e.z-t.z,s=e.w-t.w;return i*i+n*n+r*r+s*s},e.len=function(t){var e=t.x,i=t.y,n=t.z,r=t.w;return En(e*e+i*i+n*n+r*r)},e.lengthSqr=function(t){var e=t.x,i=t.y,n=t.z,r=t.w;return e*e+i*i+n*n+r*r},e.negate=function(t,e){return t.x=-e.x,t.y=-e.y,t.z=-e.z,t.w=-e.w,t},e.inverse=function(t,e){return t.x=1/e.x,t.y=1/e.y,t.z=1/e.z,t.w=1/e.w,t},e.inverseSafe=function(t,e){var i=e.x,n=e.y,r=e.z,s=e.w;return An(i)0?(a=1/En(a),t.x=i*a,t.y=n*a,t.z=r*a,t.w=s*a):(t.x=0,t.y=0,t.z=0,t.w=0),t},e.dot=function(t,e){return t.x*e.x+t.y*e.y+t.z*e.z+t.w*e.w},e.lerp=function(t,e,i,n){return t.x=e.x+n*(i.x-e.x),t.y=e.y+n*(i.y-e.y),t.z=e.z+n*(i.z-e.z),t.w=e.w+n*(i.w-e.w),t},e.scale=function(t,e,i){return t.x=e.x*i,t.y=e.y*i,t.z=e.z*i,t.w=e.w*i,t},e.random=function(t,e){e=e||1;var i=2*sn()*Bn,n=2*sn()-1,r=En(1-n*n);return t.x=r*Mn(i)*e,t.y=r*In(i)*e,t.z=n*e,t.w=0,t},e.transformMat4=function(t,e,i){var n=e.x,r=e.y,s=e.z,a=e.w;return t.x=i.m00*n+i.m04*r+i.m08*s+i.m12*a,t.y=i.m01*n+i.m05*r+i.m09*s+i.m13*a,t.z=i.m02*n+i.m06*r+i.m10*s+i.m14*a,t.w=i.m03*n+i.m07*r+i.m11*s+i.m15*a,t},e.transformAffine=function(t,e,i){var n=e.x,r=e.y,s=e.z,a=e.w;return t.x=i.m00*n+i.m04*r+i.m08*s+i.m12*a,t.y=i.m01*n+i.m05*r+i.m09*s+i.m13*a,t.z=i.m02*n+i.m06*r+i.m10*s+i.m14*a,t.w=e.w,t},e.transformQuat=function(t,e,i){var n=e.x,r=e.y,s=e.z,a=i.x,o=i.y,h=i.z,u=i.w,l=u*n+o*s-h*r,c=u*r+h*n-a*s,f=u*s+a*r-o*n,_=-a*n-o*r-h*s;return t.x=l*u+_*-a+c*-h-f*-o,t.y=c*u+_*-o+f*-a-l*-h,t.z=f*u+_*-h+l*-o-c*-a,t.w=e.w,t},e.toArray=function(t,e,i){return void 0===i&&(i=0),t[i+0]=e.x,t[i+1]=e.y,t[i+2]=e.z,t[i+3]=e.w,t},e.fromArray=function(t,e,i){return void 0===i&&(i=0),t.x=e[i+0],t.y=e[i+1],t.z=e[i+2],t.w=e[i+3],t},e.strictEquals=function(t,e){return t.x===e.x&&t.y===e.y&&t.z===e.z&&t.w===e.w},e.equals=function(t,e,i){void 0===i&&(i=Ki);var n=1/0;return!(An(t.x)===n||An(t.y)===n||An(t.z)===n||An(t.w)===n||An(e.x)===n||An(e.y)===n||An(e.z)===n||An(e.w)===n)&&An(t.x-e.x)<=i*Cn(1,An(t.x),An(e.x))&&An(t.y-e.y)<=i*Cn(1,An(t.y),An(e.y))&&An(t.z-e.z)<=i*Cn(1,An(t.z),An(e.z))&&An(t.w-e.w)<=i*Cn(1,An(t.w),An(e.w))};var i=e.prototype;return i.clone=function(){return new e(this.x,this.y,this.z,this.w)},i.set=function(t,e,i,n){return"object"==typeof t?(this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w):(this.x=t||0,this.y=e||0,this.z=i||0,this.w=n||0),this},i.equals=function(t,e){void 0===e&&(e=Ki);var i=this;return An(i.x-t.x)<=e*Cn(1,An(i.x),An(t.x))&&An(i.y-t.y)<=e*Cn(1,An(i.y),An(t.y))&&An(i.z-t.z)<=e*Cn(1,An(i.z),An(t.z))&&An(i.w-t.w)<=e*Cn(1,An(i.w),An(t.w))},i.equals4f=function(t,e,i,n,r){void 0===r&&(r=Ki);var s=this;return An(s.x-t)<=r*Cn(1,An(s.x),An(t))&&An(s.y-e)<=r*Cn(1,An(s.y),An(e))&&An(s.z-i)<=r*Cn(1,An(s.z),An(i))&&An(s.w-n)<=r*Cn(1,An(s.w),An(n))},i.strictEquals=function(t){return this.x===t.x&&this.y===t.y&&this.z===t.z&&this.w===t.w},i.strictEquals4f=function(t,e,i,n){return this.x===t&&this.y===e&&this.z===i&&this.w===n},i.lerp=function(t,e){var i=this,n=i.x,r=i.y,s=i.z,a=i.w;return i.x=n+e*(t.x-n),i.y=r+e*(t.y-r),i.z=s+e*(t.z-s),i.w=a+e*(t.w-a),i},i.toString=function(){return"("+this.x+", "+this.y+", "+this.z+", "+this.w+")"},i.clampf=function(t,e){var i=this;return i.x=$i(i.x,t.x,e.x),i.y=$i(i.y,t.y,e.y),i.z=$i(i.z,t.z,e.z),i.w=$i(i.w,t.w,e.w),i},i.add=function(t){var e=this;return e.x+=t.x,e.y+=t.y,e.z+=t.z,e.w+=t.w,e},i.add4f=function(t,e,i,n){var r=this;return r.x+=t,r.y+=e,r.z+=i,r.w+=n,r},i.subtract=function(t){var e=this;return e.x-=t.x,e.y-=t.y,e.z-=t.z,e.w-=t.w,e},i.subtract4f=function(t,e,i,n){var r=this;return r.x-=t,r.y-=e,r.z-=i,r.w-=n,r},i.multiplyScalar=function(t){var e=this;return e.x*=t,e.y*=t,e.z*=t,e.w*=t,e},i.multiply=function(t){var e=this;return e.x*=t.x,e.y*=t.y,e.z*=t.z,e.w*=t.w,e},i.multiply4f=function(t,e,i,n){var r=this;return r.x*=t,r.y*=e,r.z*=i,r.w*=n,r},i.divide=function(t){var e=this;return e.x/=t.x,e.y/=t.y,e.z/=t.z,e.w/=t.w,e},i.divide4f=function(t,e,i,n){var r=this;return r.x/=t,r.y/=e,r.z/=i,r.w/=n,r},i.negative=function(){var t=this;return t.x=-t.x,t.y=-t.y,t.z=-t.z,t.w=-t.w,t},i.dot=function(t){var e=this;return e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w},i.cross=function(t){var e=this,i=e.x,n=e.y,r=e.z,s=t.x,a=t.y,o=t.z;return e.x=n*o-r*a,e.y=r*s-i*o,e.z=i*a-n*s,e},i.length=function(){var t=this,e=t.x,i=t.y,n=t.z,r=t.w;return En(e*e+i*i+n*n+r*r)},i.lengthSqr=function(){var t=this,e=t.x,i=t.y,n=t.z,r=t.w;return e*e+i*i+n*n+r*r},i.normalize=function(){var t=this,e=t.x,i=t.y,n=t.z,r=t.w,s=e*e+i*i+n*n+r*r;return s>0&&(s=1/En(s),t.x=e*s,t.y=i*s,t.z=n*s,t.w=r*s),t},i.scale=function(t){var e=this;return e.x*=t,e.y*=t,e.z*=t,e.w*=t,e},i.transformMat4=function(t){var e=this,i=e.x,n=e.y,r=e.z,s=e.w;return e.x=t.m00*i+t.m04*n+t.m08*r+t.m12*s,e.y=t.m01*i+t.m05*n+t.m09*r+t.m13*s,e.z=t.m02*i+t.m06*n+t.m10*r+t.m14*s,e.w=t.m03*i+t.m07*n+t.m11*r+t.m15*s,e},e}(Fe));function Nn(t,e,i,n){return new Vn(t,e,i,n)}Vn.ZERO=Fn(0,0,0,0),Vn.ONE=Fn(1,1,1,1),Vn.NEG_ONE=Fn(-1,-1,-1,-1),Vn.UNIT_X=Fn(1,0,0,0),Vn.UNIT_Y=Fn(0,1,0,0),Vn.UNIT_Z=Fn(0,0,1,0),Vn.UNIT_W=Fn(0,0,0,1),Vi.fastDefine("cc.Vec4",Vn,{x:0,y:0,z:0,w:0}),C.Vec4=Vn,C.v4=Nn;var zn=Math.abs,Un=Math.max,Gn=Math.min,Hn=Math.PI,Wn=Math.acos,jn=Math.sin,qn=Math.cos,Xn=Math.sqrt,Yn=Math.ceil,Jn=Math.floor,Kn=Math.round;function Qn(t,e,i){return Object.freeze(new ir(t,e,i))}var Zn,$n,tr,er,ir=t("aS",function(t){function e(e,i,n){var r;return r=t.call(this)||this,"object"==typeof e?(r.x=e.x,r.y=e.y,r.z=e.z):(r.x=e||0,r.y=i||0,r.z=n||0),r}s(e,t),e.zero=function(t){return t.x=0,t.y=0,t.z=0,t},e.clone=function(t){return new e(t.x,t.y,t.z)},e.copy=function(t,e){return t.x=e.x,t.y=e.y,t.z=e.z,t},e.set=function(t,e,i,n){return t.x=e,t.y=i,t.z=n,t},e.add=function(t,e,i){return t.x=e.x+i.x,t.y=e.y+i.y,t.z=e.z+i.z,t},e.subtract=function(t,e,i){return t.x=e.x-i.x,t.y=e.y-i.y,t.z=e.z-i.z,t},e.multiply=function(t,e,i){return t.x=e.x*i.x,t.y=e.y*i.y,t.z=e.z*i.z,t},e.divide=function(t,e,i){return t.x=e.x/i.x,t.y=e.y/i.y,t.z=e.z/i.z,t},e.ceil=function(t,e){return t.x=Yn(e.x),t.y=Yn(e.y),t.z=Yn(e.z),t},e.floor=function(t,e){return t.x=Jn(e.x),t.y=Jn(e.y),t.z=Jn(e.z),t},e.min=function(t,e,i){return t.x=Gn(e.x,i.x),t.y=Gn(e.y,i.y),t.z=Gn(e.z,i.z),t},e.max=function(t,e,i){return t.x=Un(e.x,i.x),t.y=Un(e.y,i.y),t.z=Un(e.z,i.z),t},e.round=function(t,e){return t.x=Kn(e.x),t.y=Kn(e.y),t.z=Kn(e.z),t},e.multiplyScalar=function(t,e,i){return t.x=e.x*i,t.y=e.y*i,t.z=e.z*i,t},e.scaleAndAdd=function(t,e,i,n){return t.x=e.x+i.x*n,t.y=e.y+i.y*n,t.z=e.z+i.z*n,t},e.distance=function(t,e){var i=e.x-t.x,n=e.y-t.y,r=e.z-t.z;return Xn(i*i+n*n+r*r)},e.squaredDistance=function(t,e){var i=e.x-t.x,n=e.y-t.y,r=e.z-t.z;return i*i+n*n+r*r},e.len=function(t){var e=t.x,i=t.y,n=t.z;return Xn(e*e+i*i+n*n)},e.lengthSqr=function(t){var e=t.x,i=t.y,n=t.z;return e*e+i*i+n*n},e.negate=function(t,e){return t.x=-e.x,t.y=-e.y,t.z=-e.z,t},e.invert=function(t,e){return t.x=1/e.x,t.y=1/e.y,t.z=1/e.z,t},e.invertSafe=function(t,e){var i=e.x,n=e.y,r=e.z;return zn(i)0?(s=1/Xn(s),t.x=i*s,t.y=n*s,t.z=r*s):(t.x=0,t.y=0,t.z=0),t},e.dot=function(t,e){return t.x*e.x+t.y*e.y+t.z*e.z},e.cross=function(t,e,i){var n=e.x,r=e.y,s=e.z,a=i.x,o=i.y,h=i.z;return t.x=r*h-s*o,t.y=s*a-n*h,t.z=n*o-r*a,t},e.lerp=function(t,e,i,n){return t.x=e.x+n*(i.x-e.x),t.y=e.y+n*(i.y-e.y),t.z=e.z+n*(i.z-e.z),t},e.random=function(t,e){e=e||1;var i=2*sn()*Hn,n=2*sn()-1,r=Xn(1-n*n);return t.x=r*qn(i)*e,t.y=r*jn(i)*e,t.z=n*e,t},e.transformMat4=function(t,e,i){var n=e.x,r=e.y,s=e.z,a=i.m03*n+i.m07*r+i.m11*s+i.m15;return a=a?1/a:1,t.x=(i.m00*n+i.m04*r+i.m08*s+i.m12)*a,t.y=(i.m01*n+i.m05*r+i.m09*s+i.m13)*a,t.z=(i.m02*n+i.m06*r+i.m10*s+i.m14)*a,t},e.transformMat4Normal=function(t,e,i){var n=e.x,r=e.y,s=e.z,a=i.m03*n+i.m07*r+i.m11*s;return a=a?1/a:1,t.x=(i.m00*n+i.m04*r+i.m08*s)*a,t.y=(i.m01*n+i.m05*r+i.m09*s)*a,t.z=(i.m02*n+i.m06*r+i.m10*s)*a,t},e.transformMat3=function(t,e,i){var n=e.x,r=e.y,s=e.z;return t.x=n*i.m00+r*i.m03+s*i.m06,t.y=n*i.m01+r*i.m04+s*i.m07,t.z=n*i.m02+r*i.m05+s*i.m08,t},e.transformAffine=function(t,e,i){var n=e.x,r=e.y,s=e.z;return t.x=i.m00*n+i.m04*r+i.m08*s+i.m12,t.y=i.m01*n+i.m05*r+i.m09*s+i.m13,t.z=i.m02*n+i.m06*r+i.m10*s+i.m14,t},e.transformQuat=function(t,e,i){var n=i.w*e.x+i.y*e.z-i.z*e.y,r=i.w*e.y+i.z*e.x-i.x*e.z,s=i.w*e.z+i.x*e.y-i.y*e.x,a=-i.x*e.x-i.y*e.y-i.z*e.z;return t.x=n*i.w+a*-i.x+r*-i.z-s*-i.y,t.y=r*i.w+a*-i.y+s*-i.x-n*-i.z,t.z=s*i.w+a*-i.z+n*-i.y-r*-i.x,t},e.transformRTS=function(t,e,i,n,r){var s=e.x*r.x,a=e.y*r.y,o=e.z*r.z,h=i.w*s+i.y*o-i.z*a,u=i.w*a+i.z*s-i.x*o,l=i.w*o+i.x*a-i.y*s,c=-i.x*s-i.y*a-i.z*o;return t.x=h*i.w+c*-i.x+u*-i.z-l*-i.y+n.x,t.y=u*i.w+c*-i.y+l*-i.x-h*-i.z+n.y,t.z=l*i.w+c*-i.z+h*-i.y-u*-i.x+n.z,t},e.transformInverseRTS=function(t,e,i,n,r){var s=e.x-n.x,a=e.y-n.y,o=e.z-n.z,h=i.w*s-i.y*o+i.z*a,u=i.w*a-i.z*s+i.x*o,l=i.w*o-i.x*a+i.y*s,c=i.x*s+i.y*a+i.z*o;return t.x=(h*i.w+c*i.x+u*i.z-l*i.y)/r.x,t.y=(u*i.w+c*i.y+l*i.x-h*i.z)/r.y,t.z=(l*i.w+c*i.z+h*i.y-u*i.x)/r.z,t},e.rotateX=function(t,e,i,n){var r=e.x-i.x,s=e.y-i.y,a=e.z-i.z,o=qn(n),h=jn(n),u=r,l=s*o-a*h,c=s*h+a*o;return t.x=u+i.x,t.y=l+i.y,t.z=c+i.z,t},e.rotateY=function(t,e,i,n){var r=e.x-i.x,s=e.y-i.y,a=e.z-i.z,o=qn(n),h=jn(n),u=a*h+r*o,l=s,c=a*o-r*h;return t.x=u+i.x,t.y=l+i.y,t.z=c+i.z,t},e.rotateZ=function(t,e,i,n){var r=e.x-i.x,s=e.y-i.y,a=e.z-i.z,o=qn(n),h=jn(n),u=r*o-s*h,l=r*h+s*o,c=a;return t.x=u+i.x,t.y=l+i.y,t.z=c+i.z,t},e.rotateN=function(t,e,i,n,r){var s=e.x-i.x,a=e.y-i.y,o=e.z-i.z,h=n.x,u=n.y,l=n.z,c=qn(r),f=jn(r),_=s*(h*h*(1-c)+c)+a*(h*u*(1-c)-l*f)+o*(h*l*(1-c)+u*f),d=s*(h*u*(1-c)+l*f)+a*(u*u*(1-c)+c)+o*(u*l*(1-c)-h*f),p=s*(h*l*(1-c)-u*f)+a*(u*l*(1-c)+h*f)+o*(l*l*(1-c)+c);return t.x=_+i.x,t.y=d+i.y,t.z=p+i.z,t},e.toArray=function(t,e,i){return void 0===i&&(i=0),t[i+0]=e.x,t[i+1]=e.y,t[i+2]=e.z,t},e.fromArray=function(t,e,i){return void 0===i&&(i=0),t.x=e[i+0],t.y=e[i+1],t.z=e[i+2],t},e.strictEquals=function(t,e){return t.x===e.x&&t.y===e.y&&t.z===e.z},e.equals=function(t,e,i){void 0===i&&(i=Ki);var n=t.x,r=t.y,s=t.z,a=e.x,o=e.y,h=e.z;return zn(n-a)<=i*Un(1,zn(n),zn(a))&&zn(r-o)<=i*Un(1,zn(r),zn(o))&&zn(s-h)<=i*Un(1,zn(s),zn(h))},e.angle=function(t,e){var i=t.x*t.x+t.y*t.y+t.z*t.z,n=e.x*e.x+e.y*e.y+e.z*e.z;if(0===i||0===n)return 0;var r=(t.x*e.x+t.y*e.y+t.z*e.z)/Xn(i*n);return r=$i(r,-1,1),Wn(r)},e.projectOnPlane=function(t,i,n){return e.subtract(t,i,e.project(t,i,n))},e.project=function(t,i,n){var r=e.lengthSqr(n);return r<1e-6?e.set(t,0,0,0):e.multiplyScalar(t,n,e.dot(i,n)/r)},e.moveTowards=function(t,e,i,n){var r=i.x-e.x,s=i.y-e.y,a=i.z-e.z,o=r*r+s*s+a*a;if(0===o||n>=0&&o0&&(r=1/Xn(r),t.x=e*r,t.y=i*r,t.z=n*r),t},i.transformMat4=function(t){var e=this,i=e.x,n=e.y,r=e.z,s=t.m03*i+t.m07*n+t.m11*r+t.m15;return s=s?1/s:1,e.x=(t.m00*i+t.m04*n+t.m08*r+t.m12)*s,e.y=(t.m01*i+t.m05*n+t.m09*r+t.m13)*s,e.z=(t.m02*i+t.m06*n+t.m10*r+t.m14)*s,e},i.toVec2=function(){return new C.Vec2(this.x,this.y)},e}(Fe));function nr(t,e,i){return new ir(t,e,i)}Ln=ir,ir.UNIT_X=Qn(1,0,0),ir.UNIT_Y=Qn(0,1,0),ir.UNIT_Z=Qn(0,0,1),ir.RIGHT=Qn(1,0,0),ir.UP=Qn(0,1,0),ir.FORWARD=Qn(0,0,-1),ir.ZERO=Qn(0,0,0),ir.ONE=Qn(1,1,1),ir.NEG_ONE=Qn(-1,-1,-1),ir.slerp=(Zn=new Ln,$n=new Ln,tr=new Ln,function(t,e,i,n){var r=1e-5,s=Ln.len(e),a=Ln.len(i);if(s.99999)return Ln.lerp(t,e,i,n);if(h<-.99999){var u=Ln.multiplyScalar(Zn,e,1/s),l=Ln.generateOrthogonal($n,u);return sr(tr,u,l,Hn*n),Ln.multiplyScalar(t,tr,o),t}var c=h,f=Wn(c)*n,_=Ln.multiplyScalar(Zn,e,1/s),d=Ln.multiplyScalar($n,i,1/a);return Ln.scaleAndAdd(tr,d,_,-c),Ln.normalize(tr,tr),Ln.multiplyScalar(tr,tr,jn(f)),Ln.scaleAndAdd(tr,tr,_,qn(f)),Ln.multiplyScalar(t,tr,o),t}),ir.signedAngle=(er=new Ln,function(t,e,i){var n=Ln.angle(t,e),r=Ln.cross(er,t,e);return Ln.dot(r,i)<0?-n:n}),Vi.fastDefine("cc.Vec3",ir,{x:0,y:0,z:0}),C.Vec3=ir;var rr,sr=(rr={x:0,y:0,z:0,w:0},function(t,e,i,n){var r=.5*n,s=jn(r);return rr.x=s*i.x,rr.y=s*i.y,rr.z=s*i.z,rr.w=qn(r),ir.transformQuat(t,e,rr),t});C.v3=nr;var ar=1/255,or=Math.abs,hr=Math.max;function ur(t,e,i,n){return Object.freeze(new cr(t,e,i,n))}var lr,cr=t("b3",function(t){function e(e,i,n,r){var s;return(s=t.call(this)||this)._data=new Uint8ClampedArray(4),"string"==typeof e?s.fromHEX(e):void 0!==i?s.set(e,i,n,r):s.set(e),s}s(e,t),e.clone=function(t){var i=new e;return i.r=t.r,i.g=t.g,i.b=t.b,i.a=t.a,i},e.copy=function(t,e){return t.r=e.r,t.g=e.g,t.b=e.b,t.a=e.a,t},e.set=function(t,e,i,n,r){return t.r=e,t.g=i,t.b=n,t.a=r,t},e.toVec4=function(t,e){var i=t._data;return(e=void 0!==e?e:new Vn).x=i[0]*ar,e.y=i[1]*ar,e.z=i[2]*ar,e.w=i[3]*ar,e},e.fromVec4=function(t,i){var n=(i=void 0===i?new e:i)._data;return n[0]=t.x/ar,n[1]=t.y/ar,n[2]=t.z/ar,n[3]=t.w/ar,i},e.fromHEX=function(t,e){var i;return"string"==typeof e?(6===(e="#"===e[0]?e.substring(1):e).length?e+="FF":3===e.length?e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]+"FF":4===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]),i=Number("0x"+e)):(e<16777216&&(e=255+(e<<8)),i=e),t.r=i>>>24,t.g=(16711680&i)>>>16,t.b=(65280&i)>>>8,t.a=255&i,t},e.add=function(t,e,i){return t.r=e.r+i.r,t.g=e.g+i.g,t.b=e.b+i.b,t.a=e.a+i.a,t},e.subtract=function(t,e,i){return t.r=e.r-i.r,t.g=e.g-i.g,t.b=e.b-i.b,t.a=e.a-i.a,t},e.multiply=function(t,e,i){return t.r=e.r*i.r,t.g=e.g*i.g,t.b=e.b*i.b,t.a=e.a*i.a,t},e.divide=function(t,e,i){return t.r=e.r/i.r,t.g=e.g/i.g,t.b=e.b/i.b,t.a=e.a/i.a,t},e.scale=function(t,e,i){return t.r=e.r*i,t.g=e.g*i,t.b=e.b*i,t.a=e.a*i,t},e.lerp=function(t,e,i,n){var r=e.r,s=e.g,a=e.b,o=e.a;return t.r=r+(i.r-r)*n,t.g=s+(i.g-s)*n,t.b=a+(i.b-a)*n,t.a=o+(i.a-o)*n,t},e.toArray=function(t,i,n){void 0===n&&(n=0);var r=i instanceof e||i.a>1?1/255:1;return t[n+0]=i.r*r,t[n+1]=i.g*r,t[n+2]=i.b*r,t[n+3]=i.a*r,t},e.fromArray=function(t,e,i){return void 0===i&&(i=0),e.r=255*t[i+0],e.g=255*t[i+1],e.b=255*t[i+2],e.a=255*t[i+3],e},e.fromUint32=function(t,e){return e>>>=0,t.r=255&e,t.g=e>>8&255,t.b=e>>16&255,t.a=e>>24&255,t},e.toUint32=function(t){return(t.a<<24|t.b<<16|t.g<<8|t.r)>>>0},e.strictEquals=function(t,e){return t.r===e.r&&t.g===e.g&&t.b===e.b&&t.a===e.a},e.equals=function(t,e,i){return void 0===i&&(i=Ki),!(or(t.r)===1/0||or(t.g)===1/0||or(t.b)===1/0||or(t.a)===1/0)&&or(t.r-e.r)<=i*hr(1,or(t.r),or(e.r))&&or(t.g-e.g)<=i*hr(1,or(t.g),or(e.g))&&or(t.b-e.b)<=i*hr(1,or(t.b),or(e.b))&&or(t.a-e.a)<=i*hr(1,or(t.a),or(e.a))},e.hex=function(t){return(255*t.r<<24|255*t.g<<16|255*t.b<<8|255*t.a)>>>0};var i=e.prototype;return i.clone=function(){var t=new e;return t._data.set(this._data),t},i.equals=function(t){var e=t,i=this._data;return t&&i[0]===e.r&&i[1]===e.g&&i[2]===e.b&&i[3]===e.a},i.lerp=function(t,i){return e.lerp(this,this,t,i),this},i.toString=function(){return"rgba("+this.r.toFixed()+", "+this.g.toFixed()+", "+this.b.toFixed()+", "+this.a.toFixed()+")"},i.toCSS=function(t){return void 0===t&&(t="rgba"),"rgba"===t?"rgba("+this.r+","+this.g+","+this.b+","+(this.a*ar).toFixed(2)+")":"rgb"===t?"rgb("+this.r+","+this.g+","+this.b+")":"#"+this.toHEX(t)},i.fromHEX=function(t){var e;return"string"==typeof t?(6===(t="#"===t[0]?t.substring(1):t).length?t+="FF":3===t.length?t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]+"FF":4===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]),e=Number("0x"+t)):(t<16777216&&(t=255+(t<<8)),e=t),this.r=e>>>24,this.g=(16711680&e)>>>16,this.b=(65280&e)>>>8,this.a=255&e,this},i.toHEX=function(t){void 0===t&&(t="#rrggbb");var e=this._data,i="0",n=[(e[0]<16?i:"")+e[0].toString(16),(e[1]<16?i:"")+e[1].toString(16),(e[2]<16?i:"")+e[2].toString(16)];return"#rgb"===t?(n[0]=n[0][0],n[1]=n[1][0],n[2]=n[2][0]):"#rrggbbaa"===t&&n.push((e[3]<16?i:"")+e[3].toString(16)),n.join("")},i.toRGBValue=function(){return this._data[2]<<16|this._data[1]<<8|this._data[0]},i.fromHSV=function(t,e,i){var n=0,r=0,s=0;if(0===e)n=r=s=i;else if(0===i)n=r=s=0;else{1===t&&(t=0),t*=6;var a=Math.floor(t),o=t-a,h=i*(1-e),u=i*(1-e*o),l=i*(1-e*(1-o));switch(a){default:case 0:n=i,r=l,s=h;break;case 1:n=u,r=i,s=h;break;case 2:n=h,r=i,s=l;break;case 3:n=h,r=u,s=i;break;case 4:n=l,r=h,s=i;break;case 5:n=i,r=h,s=u}}var c=this._data;return c[0]=255*n,c[1]=255*r,c[2]=255*s,this},i.toHSV=function(){var t=this._data[0]*ar,e=this._data[1]*ar,i=this._data[2]*ar,n={h:0,s:0,v:0},r=Math.max(t,e,i),s=Math.min(t,e,i),a=0;return n.v=r,n.s=r?(r-s)/r:0,n.s?(a=r-s,n.h=t===r?(e-i)/a:e===r?2+(i-t)/a:4+(t-e)/a,n.h/=6,n.h<0&&(n.h+=1)):n.h=0,n},i.set=function(t,e,i,n){var r=this._data;if("object"==typeof t){var s,a,o,h,u=t;u._data?r.set(u._data):(r[0]=null!==(s=u.r)&&void 0!==s?s:0,r[1]=null!==(a=u.g)&&void 0!==a?a:0,r[2]=null!==(o=u.b)&&void 0!==o?o:0,r[3]=null!==(h=u.a)&&void 0!==h?h:255)}else r[0]=null!=t?t:0,r[1]=null!=e?e:0,r[2]=null!=i?i:0,r[3]=null!=n?n:255;return this},i.multiply=function(t){var e=this._data;return e[0]*=t.r/255,e[1]*=t.g/255,e[2]*=t.b/255,e[3]*=t.a/255,this},i.getModifiableProperties=function(){return["r","g","b","a"]},n(e,[{key:"r",get:function(){return this._data[0]},set:function(t){this._data[0]=t}},{key:"g",get:function(){return this._data[1]},set:function(t){this._data[1]=t}},{key:"b",get:function(){return this._data[2]},set:function(t){this._data[2]=t}},{key:"a",get:function(){return this._data[3]},set:function(t){this._data[3]=t}},{key:"x",get:function(){return this._data[0]*ar},set:function(t){this._data[0]=255*t}},{key:"y",get:function(){return this._data[1]*ar},set:function(t){this._data[1]=255*t}},{key:"z",get:function(){return this._data[2]*ar},set:function(t){this._data[2]=255*t}},{key:"w",get:function(){return this._data[3]*ar},set:function(t){this._data[3]=255*t}}]),e}(Fe));function fr(t,e,i,n){return new cr(t,e,i,n)}function _r(t,e,i){if(e>i){var n=e;e=i,i=n}return ti?i:t}function dr(t){var e=t.clone();return e.x=Math.floor(t.x),e.y=Math.floor(t.y),e.z=Math.floor(t.z),e}function pr(t){var e=Math.max(Math.max(t.x,t.y),t.z),i=128;e>1e-4&&(i=Math.log(e)/Math.log(1.1),i=$i((i=Math.ceil(i))+128,0,255));var n=1/Math.pow(1.1,i-128),r=_r(t.multiplyScalar(n),new ir(0,0,0),new ir(1,1,1));r.multiplyScalar(255);var s,a,o=dr(r).add((s=r.subtract(dr(r)))<(a=new ir(.5,.5,.5))?a:s);return new Vn(o.x/255,o.y/255,o.z/255,i/255)}cr.WHITE=ur(255,255,255,255),cr.GRAY=ur(127,127,127,255),cr.BLACK=ur(0,0,0,255),cr.TRANSPARENT=ur(0,0,0,0),cr.RED=ur(255,0,0,255),cr.GREEN=ur(0,255,0,255),cr.BLUE=ur(0,0,255,255),cr.CYAN=ur(0,255,255,255),cr.MAGENTA=ur(255,0,255,255),cr.YELLOW=ur(255,255,0,255),Vi.fastDefine("cc.Color",cr,{r:0,g:0,b:0,a:255}),C.Color=cr,C.color=fr;var mr=Math.abs,gr=Math.max,yr=t("aY",function(t){function e(e,i,n,r,s,a,o,h,u){var l;void 0===e&&(e=1),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=1),void 0===a&&(a=0),void 0===o&&(o=0),void 0===h&&(h=0),void 0===u&&(u=1);var c=f(l=t.call(this)||this);return"object"==typeof e?(c.m00=e.m00,c.m01=e.m01,c.m02=e.m02,c.m03=e.m03,c.m04=e.m04,c.m05=e.m05,c.m06=e.m06,c.m07=e.m07,c.m08=e.m08):(c.m00=e,c.m01=i,c.m02=n,c.m03=r,c.m04=s,c.m05=a,c.m06=o,c.m07=h,c.m08=u),l}s(e,t),e.clone=function(t){return new e(t.m00,t.m01,t.m02,t.m03,t.m04,t.m05,t.m06,t.m07,t.m08)},e.copy=function(t,e){return t.m00=e.m00,t.m01=e.m01,t.m02=e.m02,t.m03=e.m03,t.m04=e.m04,t.m05=e.m05,t.m06=e.m06,t.m07=e.m07,t.m08=e.m08,t},e.set=function(t,e,i,n,r,s,a,o,h,u){return t.m00=e,t.m01=i,t.m02=n,t.m03=r,t.m04=s,t.m05=a,t.m06=o,t.m07=h,t.m08=u,t},e.identity=function(t){return t.m00=1,t.m01=0,t.m02=0,t.m03=0,t.m04=1,t.m05=0,t.m06=0,t.m07=0,t.m08=1,t},e.transpose=function(t,e){if(t===e){var i=e.m01,n=e.m02,r=e.m05;t.m01=e.m03,t.m02=e.m06,t.m03=i,t.m05=e.m07,t.m06=n,t.m07=r}else t.m00=e.m00,t.m01=e.m03,t.m02=e.m06,t.m03=e.m01,t.m04=e.m04,t.m05=e.m07,t.m06=e.m02,t.m07=e.m05,t.m08=e.m08;return t},e.invert=function(t,i){var n=i.m00,r=i.m01,s=i.m02,a=i.m03,o=i.m04,h=i.m05,u=i.m06,l=i.m07,c=i.m08,f=c*o-h*l,_=-c*a+h*u,d=l*a-o*u,p=n*f+r*_+s*d;return 0===p?(e.set(t,0,0,0,0,0,0,0,0,0),t):(p=1/p,t.m00=f*p,t.m01=(-c*r+s*l)*p,t.m02=(h*r-s*o)*p,t.m03=_*p,t.m04=(c*n-s*u)*p,t.m05=(-h*n+s*a)*p,t.m06=d*p,t.m07=(-l*n+r*u)*p,t.m08=(o*n-r*a)*p,t)},e.determinant=function(t){var e=t.m00,i=t.m01,n=t.m02,r=t.m03,s=t.m04,a=t.m05,o=t.m06,h=t.m07,u=t.m08;return e*(u*s-a*h)+i*(-u*r+a*o)+n*(h*r-s*o)},e.multiply=function(t,e,i){var n=e.m00,r=e.m01,s=e.m02,a=e.m03,o=e.m04,h=e.m05,u=e.m06,l=e.m07,c=e.m08,f=i.m00,_=i.m01,d=i.m02,p=i.m03,m=i.m04,g=i.m05,y=i.m06,v=i.m07,b=i.m08;return t.m00=f*n+_*a+d*u,t.m01=f*r+_*o+d*l,t.m02=f*s+_*h+d*c,t.m03=p*n+m*a+g*u,t.m04=p*r+m*o+g*l,t.m05=p*s+m*h+g*c,t.m06=y*n+v*a+b*u,t.m07=y*r+v*o+b*l,t.m08=y*s+v*h+b*c,t},e.multiplyMat4=function(t,e,i){var n=e.m00,r=e.m01,s=e.m02,a=e.m03,o=e.m04,h=e.m05,u=e.m06,l=e.m07,c=e.m08,f=i.m00,_=i.m01,d=i.m02,p=i.m04,m=i.m05,g=i.m06,y=i.m08,v=i.m09,b=i.m10;return t.m00=f*n+_*a+d*u,t.m01=f*r+_*o+d*l,t.m02=f*s+_*h+d*c,t.m03=p*n+m*a+g*u,t.m04=p*r+m*o+g*l,t.m05=p*s+m*h+g*c,t.m06=y*n+v*a+b*u,t.m07=y*r+v*o+b*l,t.m08=y*s+v*h+b*c,t},e.transform=function(t,e,i){this.translate(t,e,i)},e.translate=function(t,e,i){var n=e.m00,r=e.m01,s=e.m02,a=e.m03,o=e.m04,h=e.m05,u=e.m06,l=e.m07,c=e.m08,f=i.x,_=i.y;return t.m00=n,t.m01=r,t.m02=s,t.m03=a,t.m04=o,t.m05=h,t.m06=f*n+_*a+u,t.m07=f*r+_*o+l,t.m08=f*s+_*h+c,t},e.scale=function(t,e,i){var n=i.x,r=i.y;return t.m00=n*e.m00,t.m01=n*e.m01,t.m02=n*e.m02,t.m03=r*e.m03,t.m04=r*e.m04,t.m05=r*e.m05,t.m06=e.m06,t.m07=e.m07,t.m08=e.m08,t},e.rotate=function(t,e,i){var n=e.m00,r=e.m01,s=e.m02,a=e.m03,o=e.m04,h=e.m05,u=e.m06,l=e.m07,c=e.m08,f=Math.sin(i),_=Math.cos(i);return t.m00=_*n+f*a,t.m01=_*r+f*o,t.m02=_*s+f*h,t.m03=_*a-f*n,t.m04=_*o-f*r,t.m05=_*h-f*s,t.m06=u,t.m07=l,t.m08=c,t},e.fromMat4=function(t,e){return t.m00=e.m00,t.m01=e.m01,t.m02=e.m02,t.m03=e.m04,t.m04=e.m05,t.m05=e.m06,t.m06=e.m08,t.m07=e.m09,t.m08=e.m10,t},e.fromViewUp=function(t,i,n){return ir.lengthSqr(i)-.999?(e.x=Math.asin(-o),e.y=Math.atan2(a,h),e.z=Math.atan2(n,s),!0):(e.x=Yi,e.y=Math.atan2(r,i),e.z=0,!1):(e.x=-Yi,e.y=Math.atan2(-r,i),e.z=0,!1)};var i=e.prototype;return i.clone=function(){return new e(this)},i.set=function(t,e,i,n,r,s,a,o,h){void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=1),void 0===s&&(s=0),void 0===a&&(a=0),void 0===o&&(o=0),void 0===h&&(h=1);var u=this;return"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=e,u.m02=i,u.m03=n,u.m04=r,u.m05=s,u.m06=a,u.m07=o,u.m08=h),u},i.equals=function(t,i){return void 0===i&&(i=Ki),e.equals(this,t,i)},i.strictEquals=function(t){return e.strictEquals(this,t)},i.toString=function(){var t=this;return"[\n"+t.m00+", "+t.m01+", "+t.m02+",\n"+t.m03+", "+t.m04+", "+t.m05+",\n"+t.m06+", "+t.m07+", "+t.m08+"\n]"},i.identity=function(){return e.identity(this)},i.transpose=function(){var t=this,e=t.m01,i=t.m02,n=t.m05;return t.m01=t.m03,t.m02=t.m06,t.m03=e,t.m05=t.m07,t.m06=i,t.m07=n,t},i.invert=function(){return e.invert(this,this)},i.determinant=function(){return e.determinant(this)},i.add=function(t){var e=this;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},i.subtract=function(t){var e=this;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},i.multiply=function(t){return e.multiply(this,this,t)},i.multiplyScalar=function(t){var e=this;return e.m00*=t,e.m01*=t,e.m02*=t,e.m03*=t,e.m04*=t,e.m05*=t,e.m06*=t,e.m07*=t,e.m08*=t,e},i.scale=function(t){var e=t.x,i=t.y,n=this;return n.m00*=e,n.m01*=e,n.m02*=e,n.m03*=i,n.m04*=i,n.m05*=i,n},i.rotate=function(t){var e=this,i=e.m00,n=e.m01,r=e.m02,s=e.m03,a=e.m04,o=e.m05,h=e.m06,u=e.m07,l=e.m08,c=Math.sin(t),f=Math.cos(t);return e.m00=f*i+c*s,e.m01=f*n+c*a,e.m02=f*r+c*o,e.m03=f*s-c*i,e.m04=f*a-c*n,e.m05=f*o-c*r,e.m06=h,e.m07=u,e.m08=l,e},i.fromQuat=function(t){var e=t.x,i=t.y,n=t.z,r=t.w,s=e+e,a=i+i,o=n+n,h=e*s,u=i*s,l=i*a,c=n*s,f=n*a,_=n*o,d=r*s,p=r*a,m=r*o,g=this;return g.m00=1-l-_,g.m03=u-m,g.m06=c+p,g.m01=u+m,g.m04=1-h-_,g.m07=f-d,g.m02=c-p,g.m05=f+d,g.m08=1-h-l,g},e}(Fe));lr=yr,yr.IDENTITY=Object.freeze(new lr);var vr,br=new ir,Sr=new ir;Vi.fastDefine("cc.Mat3",yr,{m00:1,m01:0,m02:0,m03:0,m04:1,m05:0,m06:0,m07:0,m08:1}),C.Mat3=yr;var wr=Math.abs,Tr=Math.max,Ar=Math.min,Cr=Math.PI,Dr=Math.acos,Br=Math.sin,Ir=Math.cos,Mr=Math.sqrt,Pr=Math.atan2,Er=Math.asin,Or=Math.sign,kr=t("aW",function(t){function e(e,i,n,r){var s;return s=t.call(this)||this,"object"==typeof e?(s.x=e.x,s.y=e.y,s.z=e.z,s.w=e.w):(s.x=e||0,s.y=i||0,s.z=n||0,s.w=null!=r?r:1),s}s(e,t),e.clone=function(t){return new e(t.x,t.y,t.z,t.w)},e.copy=function(t,e){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t},e.set=function(t,e,i,n,r){return t.x=e,t.y=i,t.z=n,t.w=r,t},e.identity=function(t){return t.x=0,t.y=0,t.z=0,t.w=1,t},e.rotationTo=function(t,i,n){var r=ir.dot(i,n);return r<-.999999?(ir.cross(Vr,ir.UNIT_X,i),Vr.length()<1e-6&&ir.cross(Vr,ir.UNIT_Y,i),ir.normalize(Vr,Vr),e.fromAxisAngle(t,Vr,Cr),t):r>.999999?(t.x=0,t.y=0,t.z=0,t.w=1,t):(ir.cross(Vr,i,n),t.x=Vr.x,t.y=Vr.y,t.z=Vr.z,t.w=1+r,e.normalize(t,t))},e.getAxisAngle=function(t,e){var i=2*Dr(e.w),n=Br(i/2);return 0!==n?(t.x=e.x/n,t.y=e.y/n,t.z=e.z/n):(t.x=1,t.y=0,t.z=0),i},e.multiply=function(t,e,i){var n=e.x*i.w+e.w*i.x+e.y*i.z-e.z*i.y,r=e.y*i.w+e.w*i.y+e.z*i.x-e.x*i.z,s=e.z*i.w+e.w*i.z+e.x*i.y-e.y*i.x,a=e.w*i.w-e.x*i.x-e.y*i.y-e.z*i.z;return t.x=n,t.y=r,t.z=s,t.w=a,t},e.multiplyScalar=function(t,e,i){return t.x=e.x*i,t.y=e.y*i,t.z=e.z*i,t.w=e.w*i,t},e.scaleAndAdd=function(t,e,i,n){return t.x=e.x+i.x*n,t.y=e.y+i.y*n,t.z=e.z+i.z*n,t.w=e.w+i.w*n,t},e.rotateX=function(t,e,i){var n=Br(i*=.5),r=Ir(i),s=e.x,a=e.y,o=e.z,h=e.w;return t.x=s*r+h*n,t.y=a*r+o*n,t.z=o*r-a*n,t.w=h*r-s*n,t},e.rotateY=function(t,e,i){var n=Br(i*=.5),r=Ir(i),s=e.x,a=e.y,o=e.z,h=e.w;return t.x=s*r-o*n,t.y=a*r+h*n,t.z=o*r+s*n,t.w=h*r-a*n,t},e.rotateZ=function(t,e,i){var n=Br(i*=.5),r=Ir(i),s=e.x,a=e.y,o=e.z,h=e.w;return t.x=s*r+a*n,t.y=a*r-s*n,t.z=o*r+h*n,t.w=h*r-o*n,t},e.rotateAround=function(t,i,n,r){return e.invert(Fr,i),ir.transformQuat(Vr,n,Fr),e.fromAxisAngle(Fr,Vr,r),e.multiply(t,i,Fr),t},e.rotateAroundLocal=function(t,i,n,r){return e.fromAxisAngle(Fr,n,r),e.multiply(t,i,Fr),t},e.calculateW=function(t,e){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=Mr(wr(1-e.x*e.x-e.y*e.y-e.z*e.z)),t},e.dot=function(t,e){return t.x*e.x+t.y*e.y+t.z*e.z+t.w*e.w},e.lerp=function(t,e,i,n){return t.x=e.x+n*(i.x-e.x),t.y=e.y+n*(i.y-e.y),t.z=e.z+n*(i.z-e.z),t.w=e.w+n*(i.w-e.w),t},e.slerp=function(t,e,i,n){var r=0,s=0,a=i.x,o=i.y,h=i.z,u=i.w,l=e.x*i.x+e.y*i.y+e.z*i.z+e.w*i.w;if(l<0&&(l=-l,a=-a,o=-o,h=-h,u=-u),1-l>1e-6){var c=Dr(l),f=Br(c);r=Br((1-n)*c)/f,s=Br(n*c)/f}else r=1-n,s=n;return t.x=r*e.x+s*a,t.y=r*e.y+s*o,t.z=r*e.z+s*h,t.w=r*e.w+s*u,t},e.sqlerp=function(t,i,n,r,s,a){return e.slerp(Fr,i,s,a),e.slerp(Lr,n,r,a),e.slerp(t,Fr,Lr,2*a*(1-a)),t},e.invert=function(t,e){var i=e.x*e.x+e.y*e.y+e.z*e.z+e.w*e.w,n=i?1/i:0;return t.x=-e.x*n,t.y=-e.y*n,t.z=-e.z*n,t.w=e.w*n,t},e.conjugate=function(t,e){return t.x=-e.x,t.y=-e.y,t.z=-e.z,t.w=e.w,t},e.len=function(t){return Mr(t.x*t.x+t.y*t.y+t.z*t.z+t.w*t.w)},e.lengthSqr=function(t){return t.x*t.x+t.y*t.y+t.z*t.z+t.w*t.w},e.normalize=function(t,e){var i=e.x*e.x+e.y*e.y+e.z*e.z+e.w*e.w;return i>0?(i=1/Mr(i),t.x=e.x*i,t.y=e.y*i,t.z=e.z*i,t.w=e.w*i):(t.x=0,t.y=0,t.z=0,t.w=0),t},e.fromAxes=function(t,i,n,r){return yr.set(Nr,i.x,i.y,i.z,n.x,n.y,n.z,r.x,r.y,r.z),e.normalize(t,e.fromMat3(t,Nr))},e.fromViewUp=function(t,i,n){return yr.fromViewUp(Nr,i,n),e.normalize(t,e.fromMat3(t,Nr))},e.fromAxisAngle=function(t,e,i){var n=Br(i*=.5);return t.x=n*e.x,t.y=n*e.y,t.z=n*e.z,t.w=Ir(i),t},e.fromMat3=function(t,e){var i=e.m00,n=e.m01,r=e.m02,s=e.m03,a=e.m04,o=e.m05,h=e.m06,u=e.m07,l=e.m08,c=i-a-l,f=a-i-l,_=l-i-a,d=0,p=i+a+l;c>p&&(p=c,d=1),f>p&&(p=f,d=2),_>p&&(p=_,d=3);var m=.5*Mr(p+1),g=.25/m;switch(d){case 0:t.w=m,t.x=(o-u)*g,t.y=(h-r)*g,t.z=(n-s)*g;break;case 1:t.w=(o-u)*g,t.x=m,t.y=(n+s)*g,t.z=(h+r)*g;break;case 2:t.w=(h-r)*g,t.x=(n+s)*g,t.y=m,t.z=(o+u)*g;break;case 3:t.w=(n-s)*g,t.x=(h+r)*g,t.y=(o+u)*g,t.z=m;break;default:t.w=1,t.x=0,t.y=0,t.z=0}return t},e.fromEuler=function(t,e,i,n){i*=zr,n*=zr;var r=Br(e*=zr),s=Ir(e),a=Br(i),o=Ir(i),h=Br(n),u=Ir(n);return t.x=r*o*u+s*a*h,t.y=s*a*u+r*o*h,t.z=s*o*h-r*a*u,t.w=s*o*u-r*a*h,t},e.fromAngleZ=function(t,e){return e*=zr,t.x=t.y=0,t.z=Br(e),t.w=Ir(e),t},e.toAxisX=function(t,e){var i=2*e.y,n=2*e.z;return t.x=1-i*e.y-n*e.z,t.y=i*e.x+n*e.w,t.z=n*e.x-i*e.w,t},e.toAxisY=function(t,e){var i=2*e.x,n=2*e.y,r=2*e.z;return t.x=n*e.x-r*e.w,t.y=1-i*e.x-r*e.z,t.z=r*e.y+i*e.w,t},e.toAxisZ=function(t,e){var i=2*e.x,n=2*e.y,r=2*e.z;return t.x=r*e.x+n*e.w,t.y=r*e.y-i*e.w,t.z=1-i*e.x-n*e.y,t},e.toEuler=function(t,e,i){var n=e.x,r=e.y,s=e.z,a=e.w,o=0,h=0,u=0,l=n*r+s*a;if(l>.499999)o=0,h=rn(2*Pr(n,a)),u=90;else if(l<-.499999)o=0,h=-rn(2*Pr(n,a)),u=-90;else{var c=r*r,f=s*s;o=rn(Pr(2*n*a-2*r*s,1-n*n*2-2*f)),h=rn(Pr(2*r*a-2*n*s,1-2*c-2*f)),u=rn(Er(2*l)),i&&(o=-180*Or(o+1e-6)+o,h=-180*Or(h+1e-6)+h,u=180*Or(u+1e-6)-u)}return t.x=o,t.y=h,t.z=u,t},e.toEulerInYXZOrder=function(t,e){yr.fromQuat(Nr,e),yr.toEuler(Nr,t),t.x=rn(t.x),t.y=rn(t.y),t.z=rn(t.z)},e.toArray=function(t,e,i){return void 0===i&&(i=0),t[i+0]=e.x,t[i+1]=e.y,t[i+2]=e.z,t[i+3]=e.w,t},e.fromArray=function(t,e,i){return void 0===i&&(i=0),t.x=e[i+0],t.y=e[i+1],t.z=e[i+2],t.w=e[i+3],t},e.strictEquals=function(t,e){return t.x===e.x&&t.y===e.y&&t.z===e.z&&t.w===e.w},e.equals=function(t,e,i){return void 0===i&&(i=Ki),wr(t.x-e.x)<=i*Tr(1,wr(t.x),wr(e.x))&&wr(t.y-e.y)<=i*Tr(1,wr(t.y),wr(e.y))&&wr(t.z-e.z)<=i*Tr(1,wr(t.z),wr(e.z))&&wr(t.w-e.w)<=i*Tr(1,wr(t.w),wr(e.w))},e.angle=function(t,i){var n=Ar(wr(e.dot(t,i)),1);return 2*Dr(n)},e.rotateTowards=function(t,i,n,r){var s=e.angle(i,n);if(0===s)return t.x=n.x,t.y=n.y,t.z=n.z,t.w=n.w,t;var a=Ar(r/rn(s),1);return e.slerp(t,i,n,a)};var i=e.prototype;return i.clone=function(){return new e(this.x,this.y,this.z,this.w)},i.set=function(t,e,i,n){return"object"==typeof t?(this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w):(this.x=t||0,this.y=e||0,this.z=i||0,this.w=null!=n?n:1),this},i.equals=function(t,i){return void 0===i&&(i=Ki),e.equals(this,t,i)},i.strictEquals=function(t){return t&&this.x===t.x&&this.y===t.y&&this.z===t.z&&this.w===t.w},i.getEulerAngles=function(t){return e.toEuler(t,this)},i.lerp=function(t,e){var i=this;return i.x+=e*(t.x-i.x),i.y+=e*(t.y-i.y),i.z+=e*(t.z-i.z),i.w+=e*(t.w-i.w),i},i.slerp=function(t,i){return e.slerp(this,this,t,i)},i.length=function(){var t=this,e=t.x,i=t.y,n=t.z,r=t.w;return Mr(e*e+i*i+n*n+r*r)},i.lengthSqr=function(){var t=this,e=t.x,i=t.y,n=t.z,r=t.w;return e*e+i*i+n*n+r*r},i.toString=function(){return"("+this.x+", "+this.y+", "+this.z+", "+this.w+")"},e}(Fe));vr=kr,kr.IDENTITY=Object.freeze(new vr);var Rr,Fr=new kr,Lr=new kr,Vr=new ir,Nr=new yr,zr=.5*Cr/180;function Ur(t,e,i,n){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=1),new kr(t,e,i,n)}Vi.fastDefine("cc.Quat",kr,{x:0,y:0,z:0,w:1}),C.Quat=kr,C.quat=Ur;var Gr=Object.freeze,Hr=t("b5",Gr([Gr([1,0,0,1]),Gr([0,1,-1,0]),Gr([-1,0,0,-1]),Gr([0,-1,1,0])])),Wr=Math.abs,jr=Math.max,qr=Math.sqrt,Xr=Math.sin,Yr=Math.cos,Jr=Math.tan,Kr=t("aZ",function(t){function e(e,i,n,r,s,a,o,h,u,l,c,_,d,p,m,g){var y;void 0===e&&(e=1),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=0),void 0===a&&(a=1),void 0===o&&(o=0),void 0===h&&(h=0),void 0===u&&(u=0),void 0===l&&(l=0),void 0===c&&(c=1),void 0===_&&(_=0),void 0===d&&(d=0),void 0===p&&(p=0),void 0===m&&(m=0),void 0===g&&(g=1);var v=f(y=t.call(this)||this);return"object"==typeof e?(v.m00=e.m00,y.m01=e.m01,y.m02=e.m02,y.m03=e.m03,v.m04=e.m04,y.m05=e.m05,y.m06=e.m06,y.m07=e.m07,v.m08=e.m08,y.m09=e.m09,y.m10=e.m10,y.m11=e.m11,v.m12=e.m12,y.m13=e.m13,y.m14=e.m14,y.m15=e.m15):(v.m00=e,y.m01=i,y.m02=n,y.m03=r,v.m04=s,y.m05=a,y.m06=o,y.m07=h,v.m08=u,y.m09=l,y.m10=c,y.m11=_,v.m12=d,y.m13=p,y.m14=m,y.m15=g),y}s(e,t),e.clone=function(t){return new e(t.m00,t.m01,t.m02,t.m03,t.m04,t.m05,t.m06,t.m07,t.m08,t.m09,t.m10,t.m11,t.m12,t.m13,t.m14,t.m15)},e.copy=function(t,e){return t.m00=e.m00,t.m01=e.m01,t.m02=e.m02,t.m03=e.m03,t.m04=e.m04,t.m05=e.m05,t.m06=e.m06,t.m07=e.m07,t.m08=e.m08,t.m09=e.m09,t.m10=e.m10,t.m11=e.m11,t.m12=e.m12,t.m13=e.m13,t.m14=e.m14,t.m15=e.m15,t},e.set=function(t,e,i,n,r,s,a,o,h,u,l,c,f,_,d,p,m){return t.m00=e,t.m01=i,t.m02=n,t.m03=r,t.m04=s,t.m05=a,t.m06=o,t.m07=h,t.m08=u,t.m09=l,t.m10=c,t.m11=f,t.m12=_,t.m13=d,t.m14=p,t.m15=m,t},e.identity=function(t){return t.m00=1,t.m01=0,t.m02=0,t.m03=0,t.m04=0,t.m05=1,t.m06=0,t.m07=0,t.m08=0,t.m09=0,t.m10=1,t.m11=0,t.m12=0,t.m13=0,t.m14=0,t.m15=1,t},e.zero=function(t){return t.m00=0,t.m01=0,t.m02=0,t.m03=0,t.m04=0,t.m05=0,t.m06=0,t.m07=0,t.m08=0,t.m09=0,t.m10=0,t.m11=0,t.m12=0,t.m13=0,t.m14=0,t.m15=0,t},e.transpose=function(t,e){if(t===e){var i=e.m01,n=e.m02,r=e.m03,s=e.m06,a=e.m07,o=e.m11;t.m01=e.m04,t.m02=e.m08,t.m03=e.m12,t.m04=i,t.m06=e.m09,t.m07=e.m13,t.m08=n,t.m09=s,t.m11=e.m14,t.m12=r,t.m13=a,t.m14=o}else t.m00=e.m00,t.m01=e.m04,t.m02=e.m08,t.m03=e.m12,t.m04=e.m01,t.m05=e.m05,t.m06=e.m09,t.m07=e.m13,t.m08=e.m02,t.m09=e.m06,t.m10=e.m10,t.m11=e.m14,t.m12=e.m03,t.m13=e.m07,t.m14=e.m11,t.m15=e.m15;return t},e.invert=function(t,i){var n=i.m00,r=i.m01,s=i.m02,a=i.m03,o=i.m04,h=i.m05,u=i.m06,l=i.m07,c=i.m08,f=i.m09,_=i.m10,d=i.m11,p=i.m12,m=i.m13,g=i.m14,y=i.m15,v=n*h-r*o,b=n*u-s*o,S=n*l-a*o,w=r*u-s*h,x=r*l-a*h,T=s*l-a*u,A=c*m-f*p,C=c*g-_*p,D=c*y-d*p,B=f*g-_*m,I=f*y-d*m,M=_*y-d*g,P=v*M-b*I+S*B+w*D-x*C+T*A;return 0===P?e.zero(t):(P=1/P,t.m00=(h*M-u*I+l*B)*P,t.m01=(s*I-r*M-a*B)*P,t.m02=(m*T-g*x+y*w)*P,t.m03=(_*x-f*T-d*w)*P,t.m04=(u*D-o*M-l*C)*P,t.m05=(n*M-s*D+a*C)*P,t.m06=(g*S-p*T-y*b)*P,t.m07=(c*T-_*S+d*b)*P,t.m08=(o*I-h*D+l*A)*P,t.m09=(r*D-n*I-a*A)*P,t.m10=(p*x-m*S+y*v)*P,t.m11=(f*S-c*x-d*v)*P,t.m12=(h*C-o*B-u*A)*P,t.m13=(n*B-r*C+s*A)*P,t.m14=(m*b-p*w-g*v)*P,t.m15=(c*w-f*b+_*v)*P,t)},e.determinant=function(t){var e=t.m00,i=t.m01,n=t.m02,r=t.m03,s=t.m04,a=t.m05,o=t.m06,h=t.m07,u=t.m08,l=t.m09,c=t.m10,f=t.m11,_=t.m12,d=t.m13,p=t.m14,m=t.m15;return(e*a-i*s)*(c*m-f*p)-(e*o-n*s)*(l*m-f*d)+(e*h-r*s)*(l*p-c*d)+(i*o-n*a)*(u*m-f*_)-(i*h-r*a)*(u*p-c*_)+(n*h-r*o)*(u*d-l*_)},e.multiply=function(t,e,i){var n=e.m00,r=e.m01,s=e.m02,a=e.m03,o=e.m04,h=e.m05,u=e.m06,l=e.m07,c=e.m08,f=e.m09,_=e.m10,d=e.m11,p=e.m12,m=e.m13,g=e.m14,y=e.m15,v=i.m00,b=i.m01,S=i.m02,w=i.m03;return t.m00=v*n+b*o+S*c+w*p,t.m01=v*r+b*h+S*f+w*m,t.m02=v*s+b*u+S*_+w*g,t.m03=v*a+b*l+S*d+w*y,v=i.m04,b=i.m05,S=i.m06,w=i.m07,t.m04=v*n+b*o+S*c+w*p,t.m05=v*r+b*h+S*f+w*m,t.m06=v*s+b*u+S*_+w*g,t.m07=v*a+b*l+S*d+w*y,v=i.m08,b=i.m09,S=i.m10,w=i.m11,t.m08=v*n+b*o+S*c+w*p,t.m09=v*r+b*h+S*f+w*m,t.m10=v*s+b*u+S*_+w*g,t.m11=v*a+b*l+S*d+w*y,v=i.m12,b=i.m13,S=i.m14,w=i.m15,t.m12=v*n+b*o+S*c+w*p,t.m13=v*r+b*h+S*f+w*m,t.m14=v*s+b*u+S*_+w*g,t.m15=v*a+b*l+S*d+w*y,t},e.transform=function(t,e,i){var n=i.x,r=i.y,s=i.z;if(e===t)t.m12=e.m00*n+e.m04*r+e.m08*s+e.m12,t.m13=e.m01*n+e.m05*r+e.m09*s+e.m13,t.m14=e.m02*n+e.m06*r+e.m10*s+e.m14,t.m15=e.m03*n+e.m07*r+e.m11*s+e.m15;else{var a=e.m00,o=e.m01,h=e.m02,u=e.m03,l=e.m04,c=e.m05,f=e.m06,_=e.m07,d=e.m08,p=e.m09,m=e.m10,g=e.m11;t.m00=a,t.m01=o,t.m02=h,t.m03=u,t.m04=l,t.m05=c,t.m06=f,t.m07=_,t.m08=d,t.m09=p,t.m10=m,t.m11=g,t.m12=a*n+l*r+d*s+e.m12,t.m13=o*n+c*r+p*s+e.m13,t.m14=h*n+f*r+m*s+e.m14,t.m15=u*n+_*r+g*s+e.m15}return t},e.translate=function(t,e,i){return e===t?(t.m12+=i.x,t.m13+=i.y,t.m14+=i.z):(t.m00=e.m00,t.m01=e.m01,t.m02=e.m02,t.m03=e.m03,t.m04=e.m04,t.m05=e.m05,t.m06=e.m06,t.m07=e.m07,t.m08=e.m08,t.m09=e.m09,t.m10=e.m10,t.m11=e.m11,t.m12=e.m12+i.x,t.m13=e.m13+i.y,t.m14=e.m14+i.z,t.m15=e.m15),t},e.scale=function(t,e,i){var n=i.x,r=i.y,s=i.z;return t.m00=e.m00*n,t.m01=e.m01*n,t.m02=e.m02*n,t.m03=e.m03*n,t.m04=e.m04*r,t.m05=e.m05*r,t.m06=e.m06*r,t.m07=e.m07*r,t.m08=e.m08*s,t.m09=e.m09*s,t.m10=e.m10*s,t.m11=e.m11*s,t.m12=e.m12,t.m13=e.m13,t.m14=e.m14,t.m15=e.m15,t},e.rotate=function(t,e,i,n){var r=n.x,s=n.y,a=n.z,o=qr(r*r+s*s+a*a);if(Wr(o)0?(n=2*qr(i+1),t.w=.25*n,t.x=(e.m06-e.m09)/n,t.y=(e.m08-e.m02)/n,t.z=(e.m01-e.m04)/n):e.m00>e.m05&&e.m00>e.m10?(n=2*qr(1+e.m00-e.m05-e.m10),t.w=(e.m06-e.m09)/n,t.x=.25*n,t.y=(e.m01+e.m04)/n,t.z=(e.m08+e.m02)/n):e.m05>e.m10?(n=2*qr(1+e.m05-e.m00-e.m10),t.w=(e.m08-e.m02)/n,t.x=(e.m01+e.m04)/n,t.y=.25*n,t.z=(e.m06+e.m09)/n):(n=2*qr(1+e.m10-e.m00-e.m05),t.w=(e.m01-e.m04)/n,t.x=(e.m08+e.m02)/n,t.y=(e.m06+e.m09)/n,t.z=.25*n),t},e.toRTS=function(t,i,n,r){e.toSRT(t,i,n,r)},e.toSRT=function(t,e,i,n){i&&ir.set(i,t.m12,t.m13,t.m14);var r=ir.set(Qr,t.m00,t.m01,t.m02).length(),s=ir.set(Qr,t.m04,t.m05,t.m06).length(),a=ir.set(Qr,t.m08,t.m09,t.m10).length();if(n&&(n.x=r,n.y=s,n.z=a),0!==r&&0!==s&&0!==a){Zr.m00=t.m00/r,Zr.m01=t.m01/r,Zr.m02=t.m02/r,Zr.m03=t.m04/s,Zr.m04=t.m05/s,Zr.m05=t.m06/s,Zr.m06=t.m08/a,Zr.m07=t.m09/a,Zr.m08=t.m10/a;var o=yr.determinant(Zr);n&&o<0&&(n.x*=-1),e&&(o<0&&(Zr.m00*=-1,Zr.m01*=-1,Zr.m02*=-1),kr.fromMat3(e,Zr))}else e&&kr.identity(e)},e.toEuler=function(t,e){return yr.set(Zr,t.m00,t.m01,t.m02,t.m04,t.m05,t.m06,t.m08,t.m09,t.m10),yr.toEuler(Zr,e)},e.fromRTS=function(t,i,n,r){return e.fromSRT(t,i,n,r)},e.fromSRT=function(t,e,i,n){var r=e.x,s=e.y,a=e.z,o=e.w,h=r+r,u=s+s,l=a+a,c=r*h,f=r*u,_=r*l,d=s*u,p=s*l,m=a*l,g=o*h,y=o*u,v=o*l,b=n.x,S=n.y,w=n.z;return t.m00=(1-(d+m))*b,t.m01=(f+v)*b,t.m02=(_-y)*b,t.m03=0,t.m04=(f-v)*S,t.m05=(1-(c+m))*S,t.m06=(p+g)*S,t.m07=0,t.m08=(_+y)*w,t.m09=(p-g)*w,t.m10=(1-(c+d))*w,t.m11=0,t.m12=i.x,t.m13=i.y,t.m14=i.z,t.m15=1,t},e.fromRTSOrigin=function(t,i,n,r,s){return e.fromSRTOrigin(t,i,n,r,s)},e.fromSRTOrigin=function(t,e,i,n,r){var s=e.x,a=e.y,o=e.z,h=e.w,u=s+s,l=a+a,c=o+o,f=s*u,_=s*l,d=s*c,p=a*l,m=a*c,g=o*c,y=h*u,v=h*l,b=h*c,S=n.x,w=n.y,x=n.z,T=r.x,A=r.y,C=r.z;return t.m00=(1-(p+g))*S,t.m01=(_+b)*S,t.m02=(d-v)*S,t.m03=0,t.m04=(_-b)*w,t.m05=(1-(f+g))*w,t.m06=(m+y)*w,t.m07=0,t.m08=(d+v)*x,t.m09=(m-y)*x,t.m10=(1-(f+p))*x,t.m11=0,t.m12=i.x+T-(t.m00*T+t.m04*A+t.m08*C),t.m13=i.y+A-(t.m01*T+t.m05*A+t.m09*C),t.m14=i.z+C-(t.m02*T+t.m06*A+t.m10*C),t.m15=1,t},e.fromQuat=function(t,e){var i=e.x,n=e.y,r=e.z,s=e.w,a=i+i,o=n+n,h=r+r,u=i*a,l=n*a,c=n*o,f=r*a,_=r*o,d=r*h,p=s*a,m=s*o,g=s*h;return t.m00=1-c-d,t.m01=l+g,t.m02=f-m,t.m03=0,t.m04=l-g,t.m05=1-u-d,t.m06=_+p,t.m07=0,t.m08=f+m,t.m09=_-p,t.m10=1-u-c,t.m11=0,t.m12=0,t.m13=0,t.m14=0,t.m15=1,t},e.frustum=function(t,e,i,n,r,s,a){var o=1/(i-e),h=1/(r-n),u=1/(s-a);return t.m00=2*s*o,t.m01=0,t.m02=0,t.m03=0,t.m04=0,t.m05=2*s*h,t.m06=0,t.m07=0,t.m08=(i+e)*o,t.m09=(r+n)*h,t.m10=(a+s)*u,t.m11=-1,t.m12=0,t.m13=0,t.m14=a*s*2*u,t.m15=0,t},e.perspective=function(t,e,i,n,r,s,a,o,h){void 0===s&&(s=!0),void 0===a&&(a=-1),void 0===o&&(o=1),void 0===h&&(h=0);var u=1/Jr(e/2),l=1/(n-r),c=s?u/i:u,f=(s?u:u*i)*o,_=Hr[h];return t.m00=c*_[0],t.m01=c*_[1],t.m02=0,t.m03=0,t.m04=f*_[2],t.m05=f*_[3],t.m06=0,t.m07=0,t.m08=0,t.m09=0,t.m10=(r-a*n)*l,t.m11=-1,t.m12=0,t.m13=0,t.m14=r*n*l*(1-a),t.m15=0,t},e.ortho=function(t,e,i,n,r,s,a,o,h,u){void 0===o&&(o=-1),void 0===h&&(h=1),void 0===u&&(u=0);var l=1/(e-i),c=1/(n-r)*h,f=1/(s-a),_=-2*l,d=-2*c,p=(e+i)*l,m=(r+n)*c,g=Hr[u];return t.m00=_*g[0],t.m01=_*g[1],t.m02=0,t.m03=0,t.m04=d*g[2],t.m05=d*g[3],t.m06=0,t.m07=0,t.m08=0,t.m09=0,t.m10=f*(1-o),t.m11=0,t.m12=p*g[0]+m*g[2],t.m13=p*g[1]+m*g[3],t.m14=(s-o*a)*f,t.m15=1,t},e.lookAt=function(t,e,i,n){var r=e.x,s=e.y,a=e.z,o=n.x,h=n.y,u=n.z,l=r-i.x,c=s-i.y,f=a-i.z,_=1/qr(l*l+c*c+f*f),d=h*(f*=_)-u*(c*=_),p=u*(l*=_)-o*f,m=o*c-h*l,g=c*(m*=_=1/qr(d*d+p*p+m*m))-f*(p*=_),y=f*(d*=_)-l*m,v=l*p-c*d;return t.m00=d,t.m01=g,t.m02=l,t.m03=0,t.m04=p,t.m05=y,t.m06=c,t.m07=0,t.m08=m,t.m09=v,t.m10=f,t.m11=0,t.m12=-(d*r+p*s+m*a),t.m13=-(g*r+y*s+v*a),t.m14=-(l*r+c*s+f*a),t.m15=1,t},e.inverseTranspose=function(t,e){var i=e.m00,n=e.m01,r=e.m02,s=e.m03,a=e.m04,o=e.m05,h=e.m06,u=e.m07,l=e.m08,c=e.m09,f=e.m10,_=e.m11,d=e.m12,p=e.m13,m=e.m14,g=e.m15,y=i*o-n*a,v=i*h-r*a,b=i*u-s*a,S=n*h-r*o,w=n*u-s*o,x=r*u-s*h,T=l*p-c*d,A=l*m-f*d,C=l*g-_*d,D=c*m-f*p,B=c*g-_*p,I=f*g-_*m,M=y*I-v*B+b*D+S*C-w*A+x*T;return M?(M=1/M,t.m00=(o*I-h*B+u*D)*M,t.m01=(h*C-a*I-u*A)*M,t.m02=(a*B-o*C+u*T)*M,t.m03=0,t.m04=(r*B-n*I-s*D)*M,t.m05=(i*I-r*C+s*A)*M,t.m06=(n*C-i*B-s*T)*M,t.m07=0,t.m08=(p*x-m*w+g*S)*M,t.m09=(m*b-d*x-g*v)*M,t.m10=(d*w-p*b+g*y)*M,t.m11=0,t.m12=0,t.m13=0,t.m14=0,t.m15=1,t):null},e.toArray=function(t,e,i){return void 0===i&&(i=0),t[i+0]=e.m00,t[i+1]=e.m01,t[i+2]=e.m02,t[i+3]=e.m03,t[i+4]=e.m04,t[i+5]=e.m05,t[i+6]=e.m06,t[i+7]=e.m07,t[i+8]=e.m08,t[i+9]=e.m09,t[i+10]=e.m10,t[i+11]=e.m11,t[i+12]=e.m12,t[i+13]=e.m13,t[i+14]=e.m14,t[i+15]=e.m15,t},e.fromArray=function(t,e,i){return void 0===i&&(i=0),t.m00=e[i+0],t.m01=e[i+1],t.m02=e[i+2],t.m03=e[i+3],t.m04=e[i+4],t.m05=e[i+5],t.m06=e[i+6],t.m07=e[i+7],t.m08=e[i+8],t.m09=e[i+9],t.m10=e[i+10],t.m11=e[i+11],t.m12=e[i+12],t.m13=e[i+13],t.m14=e[i+14],t.m15=e[i+15],t},e.add=function(t,e,i){return t.m00=e.m00+i.m00,t.m01=e.m01+i.m01,t.m02=e.m02+i.m02,t.m03=e.m03+i.m03,t.m04=e.m04+i.m04,t.m05=e.m05+i.m05,t.m06=e.m06+i.m06,t.m07=e.m07+i.m07,t.m08=e.m08+i.m08,t.m09=e.m09+i.m09,t.m10=e.m10+i.m10,t.m11=e.m11+i.m11,t.m12=e.m12+i.m12,t.m13=e.m13+i.m13,t.m14=e.m14+i.m14,t.m15=e.m15+i.m15,t},e.subtract=function(t,e,i){return t.m00=e.m00-i.m00,t.m01=e.m01-i.m01,t.m02=e.m02-i.m02,t.m03=e.m03-i.m03,t.m04=e.m04-i.m04,t.m05=e.m05-i.m05,t.m06=e.m06-i.m06,t.m07=e.m07-i.m07,t.m08=e.m08-i.m08,t.m09=e.m09-i.m09,t.m10=e.m10-i.m10,t.m11=e.m11-i.m11,t.m12=e.m12-i.m12,t.m13=e.m13-i.m13,t.m14=e.m14-i.m14,t.m15=e.m15-i.m15,t},e.multiplyScalar=function(t,e,i){return t.m00=e.m00*i,t.m01=e.m01*i,t.m02=e.m02*i,t.m03=e.m03*i,t.m04=e.m04*i,t.m05=e.m05*i,t.m06=e.m06*i,t.m07=e.m07*i,t.m08=e.m08*i,t.m09=e.m09*i,t.m10=e.m10*i,t.m11=e.m11*i,t.m12=e.m12*i,t.m13=e.m13*i,t.m14=e.m14*i,t.m15=e.m15*i,t},e.multiplyScalarAndAdd=function(t,e,i,n){return t.m00=e.m00+i.m00*n,t.m01=e.m01+i.m01*n,t.m02=e.m02+i.m02*n,t.m03=e.m03+i.m03*n,t.m04=e.m04+i.m04*n,t.m05=e.m05+i.m05*n,t.m06=e.m06+i.m06*n,t.m07=e.m07+i.m07*n,t.m08=e.m08+i.m08*n,t.m09=e.m09+i.m09*n,t.m10=e.m10+i.m10*n,t.m11=e.m11+i.m11*n,t.m12=e.m12+i.m12*n,t.m13=e.m13+i.m13*n,t.m14=e.m14+i.m14*n,t.m15=e.m15+i.m15*n,t},e.strictEquals=function(t,e){return t.m00===e.m00&&t.m01===e.m01&&t.m02===e.m02&&t.m03===e.m03&&t.m04===e.m04&&t.m05===e.m05&&t.m06===e.m06&&t.m07===e.m07&&t.m08===e.m08&&t.m09===e.m09&&t.m10===e.m10&&t.m11===e.m11&&t.m12===e.m12&&t.m13===e.m13&&t.m14===e.m14&&t.m15===e.m15},e.equals=function(t,e,i){return void 0===i&&(i=Ki),Wr(t.m00-e.m00)<=i*jr(1,Wr(t.m00),Wr(e.m00))&&Wr(t.m01-e.m01)<=i*jr(1,Wr(t.m01),Wr(e.m01))&&Wr(t.m02-e.m02)<=i*jr(1,Wr(t.m02),Wr(e.m02))&&Wr(t.m03-e.m03)<=i*jr(1,Wr(t.m03),Wr(e.m03))&&Wr(t.m04-e.m04)<=i*jr(1,Wr(t.m04),Wr(e.m04))&&Wr(t.m05-e.m05)<=i*jr(1,Wr(t.m05),Wr(e.m05))&&Wr(t.m06-e.m06)<=i*jr(1,Wr(t.m06),Wr(e.m06))&&Wr(t.m07-e.m07)<=i*jr(1,Wr(t.m07),Wr(e.m07))&&Wr(t.m08-e.m08)<=i*jr(1,Wr(t.m08),Wr(e.m08))&&Wr(t.m09-e.m09)<=i*jr(1,Wr(t.m09),Wr(e.m09))&&Wr(t.m10-e.m10)<=i*jr(1,Wr(t.m10),Wr(e.m10))&&Wr(t.m11-e.m11)<=i*jr(1,Wr(t.m11),Wr(e.m11))&&Wr(t.m12-e.m12)<=i*jr(1,Wr(t.m12),Wr(e.m12))&&Wr(t.m13-e.m13)<=i*jr(1,Wr(t.m13),Wr(e.m13))&&Wr(t.m14-e.m14)<=i*jr(1,Wr(t.m14),Wr(e.m14))&&Wr(t.m15-e.m15)<=i*jr(1,Wr(t.m15),Wr(e.m15))};var i=e.prototype;return i.clone=function(){return new e(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)},i.set=function(t,e,i,n,r,s,a,o,h,u,l,c,f,_,d,p){void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=1),void 0===a&&(a=0),void 0===o&&(o=0),void 0===h&&(h=0),void 0===u&&(u=0),void 0===l&&(l=1),void 0===c&&(c=0),void 0===f&&(f=0),void 0===_&&(_=0),void 0===d&&(d=0),void 0===p&&(p=1);var m=this;return"object"==typeof t?(m.m01=t.m01,m.m02=t.m02,m.m03=t.m03,m.m04=t.m04,m.m05=t.m05,m.m06=t.m06,m.m07=t.m07,m.m08=t.m08,m.m09=t.m09,m.m10=t.m10,m.m11=t.m11,m.m12=t.m12,m.m13=t.m13,m.m14=t.m14,m.m15=t.m15,m.m00=t.m00):(m.m01=e,m.m02=i,m.m03=n,m.m04=r,m.m05=s,m.m06=a,m.m07=o,m.m08=h,m.m09=u,m.m10=l,m.m11=c,m.m12=f,m.m13=_,m.m14=d,m.m15=p,m.m00=t),m},i.equals=function(t,e){void 0===e&&(e=Ki);var i=1/0,n=this,r=n.m00,s=n.m01,a=n.m02,o=n.m03,h=n.m04,u=n.m05,l=n.m06,c=n.m07,f=n.m08,_=n.m09,d=n.m10,p=n.m11,m=n.m12,g=n.m13,y=n.m14,v=n.m15;return!(Wr(r)===i||Wr(s)===i||Wr(a)===i||Wr(o)===i||Wr(h)===i||Wr(u)===i||Wr(l)===i||Wr(c)===i||Wr(f)===i||Wr(_)===i||Wr(d)===i||Wr(p)===i||Wr(m)===i||Wr(g)===i||Wr(y)===i||Wr(v)===i)&&Wr(r-t.m00)<=e*jr(1,Wr(r),Wr(t.m00))&&Wr(s-t.m01)<=e*jr(1,Wr(s),Wr(t.m01))&&Wr(a-t.m02)<=e*jr(1,Wr(a),Wr(t.m02))&&Wr(o-t.m03)<=e*jr(1,Wr(o),Wr(t.m03))&&Wr(h-t.m04)<=e*jr(1,Wr(h),Wr(t.m04))&&Wr(u-t.m05)<=e*jr(1,Wr(u),Wr(t.m05))&&Wr(l-t.m06)<=e*jr(1,Wr(l),Wr(t.m06))&&Wr(c-t.m07)<=e*jr(1,Wr(c),Wr(t.m07))&&Wr(f-t.m08)<=e*jr(1,Wr(f),Wr(t.m08))&&Wr(_-t.m09)<=e*jr(1,Wr(_),Wr(t.m09))&&Wr(d-t.m10)<=e*jr(1,Wr(d),Wr(t.m10))&&Wr(p-t.m11)<=e*jr(1,Wr(p),Wr(t.m11))&&Wr(m-t.m12)<=e*jr(1,Wr(m),Wr(t.m12))&&Wr(g-t.m13)<=e*jr(1,Wr(g),Wr(t.m13))&&Wr(y-t.m14)<=e*jr(1,Wr(y),Wr(t.m14))&&Wr(v-t.m15)<=e*jr(1,Wr(v),Wr(t.m15))},i.strictEquals=function(t){var e=this;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},i.toString=function(){var t=this;return"[\n"+t.m00+", "+t.m01+", "+t.m02+", "+t.m03+",\n"+t.m04+", "+t.m05+", "+t.m06+", "+t.m07+",\n"+t.m08+", "+t.m09+", "+t.m10+", "+t.m11+",\n"+t.m12+", "+t.m13+", "+t.m14+", "+t.m15+"\n]"},i.identity=function(){return e.identity(this)},i.zero=function(){return e.zero(this)},i.transpose=function(){var t=this,e=t.m01,i=t.m02,n=t.m03,r=t.m06,s=t.m07,a=t.m11;return t.m01=t.m04,t.m02=t.m08,t.m03=t.m12,t.m04=e,t.m06=t.m09,t.m07=t.m13,t.m08=i,t.m09=r,t.m11=t.m14,t.m12=n,t.m13=s,t.m14=a,t},i.invert=function(){var t=this,e=t.m00,i=t.m01,n=t.m02,r=t.m03,s=t.m04,a=t.m05,o=t.m06,h=t.m07,u=t.m08,l=t.m09,c=t.m10,f=t.m11,_=t.m12,d=t.m13,p=t.m14,m=t.m15,g=e*a-i*s,y=e*o-n*s,v=e*h-r*s,b=i*o-n*a,S=i*h-r*a,w=n*h-r*o,x=u*d-l*_,T=u*p-c*_,A=u*m-f*_,C=l*p-c*d,D=l*m-f*d,B=c*m-f*p,I=g*B-y*D+v*C+b*A-S*T+w*x;return 0===I?(t.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),t):(I=1/I,t.m00=(a*B-o*D+h*C)*I,t.m01=(n*D-i*B-r*C)*I,t.m02=(d*w-p*S+m*b)*I,t.m03=(c*S-l*w-f*b)*I,t.m04=(o*A-s*B-h*T)*I,t.m05=(e*B-n*A+r*T)*I,t.m06=(p*v-_*w-m*y)*I,t.m07=(u*w-c*v+f*y)*I,t.m08=(s*D-a*A+h*x)*I,t.m09=(i*A-e*D-r*x)*I,t.m10=(_*S-d*v+m*g)*I,t.m11=(l*v-u*S-f*g)*I,t.m12=(a*T-s*C-o*x)*I,t.m13=(e*C-i*T+n*x)*I,t.m14=(d*y-_*b-p*g)*I,t.m15=(u*b-l*y+c*g)*I,t)},i.determinant=function(){var t=this,e=t.m00,i=t.m01,n=t.m02,r=t.m03,s=t.m04,a=t.m05,o=t.m06,h=t.m07,u=t.m08,l=t.m09,c=t.m10,f=t.m11,_=t.m12,d=t.m13,p=t.m14,m=t.m15;return(e*a-i*s)*(c*m-f*p)-(e*o-n*s)*(l*m-f*d)+(e*h-r*s)*(l*p-c*d)+(i*o-n*a)*(u*m-f*_)-(i*h-r*a)*(u*p-c*_)+(n*h-r*o)*(u*d-l*_)},i.add=function(t){var e=this;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},i.subtract=function(t){var e=this;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},i.multiply=function(t){return e.multiply(this,this,t)},i.multiplyScalar=function(t){var e=this;return e.m00*=t,e.m01*=t,e.m02*=t,e.m03*=t,e.m04*=t,e.m05*=t,e.m06*=t,e.m07*=t,e.m08*=t,e.m09*=t,e.m10*=t,e.m11*=t,e.m12*=t,e.m13*=t,e.m14*=t,e.m15*=t,e},i.translate=function(t){return this.m12+=t.x,this.m13+=t.y,this.m14+=t.z,this},i.transform=function(t){var e=t.x,i=t.y,n=t.z,r=this,s=r.m00,a=r.m01,o=r.m02,h=r.m03,u=r.m04,l=r.m05,c=r.m06,f=r.m07,_=r.m08,d=r.m09,p=r.m10,m=r.m11;return r.m12=s*e+u*i+_*n+r.m12,r.m13=a*e+l*i+d*n+r.m13,r.m14=o*e+c*i+p*n+r.m14,r.m15=h*e+f*i+m*n+r.m15,r},i.scale=function(t){var e=t.x,i=t.y,n=t.z,r=this;return r.m00*=e,r.m01*=e,r.m02*=e,r.m03*=e,r.m04*=i,r.m05*=i,r.m06*=i,r.m07*=i,r.m08*=n,r.m09*=n,r.m10*=n,r.m11*=n,r},i.rotate=function(t,e){var i=e.x,n=e.y,r=e.z,s=qr(i*i+n*n+r*r);if(Wr(s)0?(r=1/os(r),t.x=i*r,t.y=n*r):(t.x=0,t.y=0),t},e.dot=function(t,e){return t.x*e.x+t.y*e.y},e.cross=function(t,e,i){return t instanceof ir?(t.x=t.y=0,t.z=e.x*i.y-e.y*i.x,t):t.x*e.y-t.y*e.x},e.lerp=function(t,e,i,n){var r=e.x,s=e.y;return t.x=r+n*(i.x-r),t.y=s+n*(i.y-s),t},e.random=function(t,e){e=e||1;var i=2*sn()*ns;return t.x=as(i)*e,t.y=ss(i)*e,t},e.transformMat3=function(t,e,i){var n=e.x,r=e.y;return t.x=i.m00*n+i.m03*r+i.m06,t.y=i.m01*n+i.m04*r+i.m07,t},e.transformMat4=function(t,e,i){var n=e.x,r=e.y;return t.x=i.m00*n+i.m04*r+i.m12,t.y=i.m01*n+i.m05*r+i.m13,t},e.str=function(t){return"Vec2("+t.x+", "+t.y+")"},e.toArray=function(t,e,i){return void 0===i&&(i=0),t[i+0]=e.x,t[i+1]=e.y,t},e.fromArray=function(t,e,i){return void 0===i&&(i=0),t.x=e[i+0],t.y=e[i+1],t},e.strictEquals=function(t,e){return t.x===e.x&&t.y===e.y},e.equals=function(t,e,i){return void 0===i&&(i=Ki),ts(t.x-e.x)<=i*es(1,ts(t.x),ts(e.x))&&ts(t.y-e.y)<=i*es(1,ts(t.y),ts(e.y))},e.angle=function(t,e){var i=t.x*t.x+t.y*t.y,n=e.x*e.x+e.y*e.y;if(0===i||0===n)return 0;var r=(t.x*e.x+t.y*e.y)/os(i*n);return r=$i(r,-1,1),rs(r)};var i=e.prototype;return i.clone=function(){return new e(this.x,this.y)},i.set=function(t,e){return"object"==typeof t?(this.x=t.x,this.y=t.y):(this.x=t||0,this.y=e||0),this},i.equals=function(t,i){return void 0===i&&(i=Ki),e.equals(this,t,i)},i.equals2f=function(t,e,i){return void 0===i&&(i=Ki),ts(this.x-t)<=i*es(1,ts(this.x),ts(t))&&ts(this.y-e)<=i*es(1,ts(this.y),ts(e))},i.strictEquals=function(t){return t&&this.x===t.x&&this.y===t.y},i.strictEquals2f=function(t,e){return this.x===t&&this.y===e},i.toString=function(){return"("+this.x+", "+this.y+")"},i.lerp=function(t,e){var i=this.x,n=this.y;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this},i.clampf=function(t,e){return this.x=$i(this.x,t.x,e.x),this.y=$i(this.y,t.y,e.y),this},i.add=function(t){return this.x+=t.x,this.y+=t.y,this},i.add2f=function(t,e){return this.x+=t,this.y+=e,this},i.subtract=function(t){return this.x-=t.x,this.y-=t.y,this},i.subtract2f=function(t,e){return this.x-=t,this.y-=e,this},i.multiplyScalar=function(t){return"object"==typeof t&&at(16359),this.x*=t,this.y*=t,this},i.multiply=function(t){return"object"!=typeof t&&at(16360),this.x*=t.x,this.y*=t.y,this},i.multiply2f=function(t,e){return this.x*=t,this.y*=e,this},i.divide=function(t){return this.x/=t.x,this.y/=t.y,this},i.divide2f=function(t,e){return this.x/=t,this.y/=e,this},i.negative=function(){return this.x=-this.x,this.y=-this.y,this},i.dot=function(t){return this.x*t.x+this.y*t.y},i.cross=function(t){return this.x*t.y-this.y*t.x},i.length=function(){return os(this.x*this.x+this.y*this.y)},i.lengthSqr=function(){return this.x*this.x+this.y*this.y},i.normalize=function(){var t=this,e=t.x,i=t.y,n=e*e+i*i;return n>0&&(n=1/os(n),t.x*=n,t.y*=n),t},i.angle=function(t){var e=this.lengthSqr(),i=t.lengthSqr();if(0===e||0===i)return 0;var n=this.dot(t)/os(e*i);return n=$i(n,-1,1),rs(n)},i.signAngle=function(t){var e=this.cross(t),i=this.dot(t);return hs(e,i)},i.rotate=function(t){var e=this.x,i=this.y,n=ss(t),r=as(t);return this.x=r*e-n*i,this.y=n*e+r*i,this},i.project=function(t){var e=this.dot(t)/t.dot(t);return this.x=t.x*e,this.y=t.y*e,this},i.transformMat4=function(t){var e=this.x,i=this.y;return this.x=t.m00*e+t.m04*i+t.m12,this.y=t.m01*e+t.m05*i+t.m13,this},i.toVec3=function(){return new ir(this.x,this.y,0)},e}(Fe));function ps(t,e){return new ds(t,e)}ds.ZERO=fs(0,0),ds.ONE=fs(1,1),ds.NEG_ONE=fs(-1,-1),ds.UNIT_X=fs(1,0),ds.UNIT_Y=fs(0,1),Vi.fastDefine("cc.Vec2",ds,{x:0,y:0}),C.Vec2=ds,C.v2=ps,pt(ds,"Vec2",[{name:"sub",newName:"subtract",target:ds,targetName:"Vec2"},{name:"mul",newName:"multiply",target:ds,targetName:"Vec2"},{name:"div",newName:"divide",target:ds,targetName:"Vec2"},{name:"dist",newName:"distance",target:ds,targetName:"Vec2"},{name:"sqrDist",newName:"squaredDistance",target:ds,targetName:"Vec2"},{name:"mag",newName:"len",target:ds,targetName:"Vec2"},{name:"sqrMag",newName:"lengthSqr",target:ds,targetName:"Vec2"},{name:"scale",newName:"multiplyScalar",target:ds,targetName:"Vec2"},{name:"exactEquals",newName:"strictEquals",target:ds,targetName:"Vec2"}]),pt(ds.prototype,"Vec2",[{name:"mag",newName:"length",target:ds.prototype,targetName:"Vec2"},{name:"magSqr",newName:"lengthSqr",target:ds.prototype,targetName:"Vec2"},{name:"scale",newName:"multiplyScalar",target:ds.prototype,targetName:"Vec2"},{name:"exactEquals",newName:"strictEquals",target:ds.prototype,targetName:"Vec2"}]),pt(ir,"Vec3",[{name:"sub",newName:"subtract",target:ir,targetName:"Vec3"},{name:"mul",newName:"multiply",target:ir,targetName:"Vec3"},{name:"div",newName:"divide",target:ir,targetName:"Vec3"},{name:"dist",newName:"distance",target:ir,targetName:"Vec3"},{name:"sqrDist",newName:"squaredDistance",target:ir,targetName:"Vec3"},{name:"mag",newName:"len",target:ir,targetName:"Vec3"},{name:"sqrMag",newName:"lengthSqr",target:ir,targetName:"Vec3"},{name:"scale",newName:"multiplyScalar",target:ir,targetName:"Vec3"},{name:"exactEquals",newName:"strictEquals",target:ir,targetName:"Vec3"}]),pt(ir.prototype,"Vec3",[{name:"mag",newName:"length",target:ir.prototype,targetName:"Vec3"},{name:"magSqr",newName:"lengthSqr",target:ir.prototype,targetName:"Vec3"},{name:"scale",newName:"multiplyScalar",target:ir.prototype,targetName:"Vec3"},{name:"exactEquals",newName:"strictEquals",target:ir.prototype,targetName:"Vec3"}]),pt(Vn,"Vec4",[{name:"sub",newName:"subtract",target:Vn,targetName:"Vec4"},{name:"mul",newName:"multiply",target:Vn,targetName:"Vec4"},{name:"div",newName:"divide",target:Vn,targetName:"Vec4"},{name:"dist",newName:"distance",target:Vn,targetName:"Vec4"},{name:"sqrDist",newName:"squaredDistance",target:Vn,targetName:"Vec4"},{name:"mag",newName:"len",target:Vn,targetName:"Vec4"},{name:"sqrMag",newName:"lengthSqr",target:Vn,targetName:"Vec4"},{name:"scale",newName:"multiplyScalar",target:Vn,targetName:"Vec4"},{name:"exactEquals",newName:"strictEquals",target:Vn,targetName:"Vec4"}]),pt(Vn.prototype,"Vec4",[{name:"mag",newName:"length",target:Vn.prototype,targetName:"Vec4"},{name:"magSqr",newName:"lengthSqr",target:Vn.prototype,targetName:"Vec4"},{name:"scale",newName:"multiplyScalar",target:Vn.prototype,targetName:"Vec4"},{name:"exactEquals",newName:"strictEquals",target:Vn.prototype,targetName:"Vec4"}]),pt(kr,"Quat",[{name:"mag",newName:"len",target:kr,targetName:"Quat"},{name:"mul",newName:"multiply",target:kr,targetName:"Quat"},{name:"sqrMag",newName:"lengthSqr",target:kr,targetName:"Quat"},{name:"scale",newName:"multiplyScalar",target:kr,targetName:"Quat"},{name:"exactEquals",newName:"strictEquals",target:kr,targetName:"Quat"}]),pt(kr.prototype,"Quat",[{name:"scale",newName:"multiplyScalar",target:kr.prototype,targetName:"Quat"},{name:"exactEquals",newName:"strictEquals",target:kr.prototype,targetName:"Quat"}]),pt(cr,"Color",[{name:"sub",newName:"subtract",target:cr,targetName:"Color"},{name:"mul",newName:"multiply",target:cr,targetName:"Color"},{name:"div",newName:"divide",target:cr,targetName:"Color"},{name:"exactEquals",newName:"strictEquals",target:cr,targetName:"Color"},{name:"fromHex",newName:"fromHEX",customFunction:function(){for(var t=arguments.length,e=new Array(t),i=0;i=t.x&&e.y<=t.y&&e.y+e.height>=t.y},i.containsRect=function(t){var e=this;return e.x<=t.x&&e.x+e.width>=t.x+t.width&&e.y<=t.y&&e.y+e.height>=t.y+t.height},i.transformMat4=function(t){var e=this,i=e.x,n=e.y,r=i+e.width,s=n+e.height,a=t.m00*i+t.m04*n+t.m12,o=t.m01*i+t.m05*n+t.m13,h=t.m00*r+t.m04*n+t.m12,u=t.m01*r+t.m05*n+t.m13,l=t.m00*i+t.m04*s+t.m12,c=t.m01*i+t.m05*s+t.m13,f=t.m00*r+t.m04*s+t.m12,_=t.m01*r+t.m05*s+t.m13,d=vs(a,h,l,f),p=ys(a,h,l,f),m=vs(o,u,c,_),g=ys(o,u,c,_);return e.x=d,e.y=m,e.width=p-d,e.height=g-m,e},i.transformMat4ToPoints=function(t,e,i,n,r){var s=this,a=s.x,o=s.y,h=a+s.width,u=o+s.height;e.x=t.m00*a+t.m04*o+t.m12,e.y=t.m01*a+t.m05*o+t.m13,r.x=t.m00*h+t.m04*o+t.m12,r.y=t.m01*h+t.m05*o+t.m13,i.x=t.m00*a+t.m04*u+t.m12,i.y=t.m01*a+t.m05*u+t.m13,n.x=t.m00*h+t.m04*u+t.m12,n.y=t.m01*h+t.m05*u+t.m13},n(e,[{key:"xMin",get:function(){return this.x},set:function(t){this.width+=this.x-t,this.x=t}},{key:"yMin",get:function(){return this.y},set:function(t){this.height+=this.y-t,this.y=t}},{key:"xMax",get:function(){return this.x+this.width},set:function(t){this.width=t-this.x}},{key:"yMax",get:function(){return this.y+this.height},set:function(t){this.height=t-this.y}},{key:"center",get:function(){return new ds(this.x+.5*this.width,this.y+.5*this.height)},set:function(t){this.x=t.x-.5*this.width,this.y=t.y-.5*this.height}},{key:"origin",get:function(){return new ds(this.x,this.y)},set:function(t){this.x=t.x,this.y=t.y}},{key:"size",get:function(){return new ms(this.width,this.height)},set:function(t){this.width=t.width,this.height=t.height}},{key:"z",get:function(){return this.width},set:function(t){this.width=t}},{key:"w",get:function(){return this.height},set:function(t){this.height=t}}]),e}(Fe));function Ss(t,e,i,n){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),new bs(t,e,i,n)}Vi.fastDefine("cc.Rect",bs,{x:0,y:0,width:0,height:0}),C.Rect=bs,C.rect=Ss;var ws=t("bw",Float64Array),xs=t("bx",function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.createFloatArray=function(t){return new ws(t)},n(e,[{key:"array",get:function(){return this._array}}]),e}(Fe)),Ts=Object.freeze({__proto__:null,Color:cr,EPSILON:Ki,HALF_PI:Yi,MATH_FLOAT_ARRAY:ws,Mat3:yr,Mat4:Kr,MathBase:xs,Quat:kr,Rect:bs,Size:ms,TWO_PI:Ji,Vec2:ds,Vec3:ir,Vec4:Vn,absMax:gn,absMaxComponent:mn,approx:Zi,bits:L,clamp:$i,clamp01:tn,color:fr,enumerableProps:yn,equals:Qi,floatToHalf:xn,halfToFloat:Tn,inverseLerp:pn,lerp:en,mat4:$r,nextPow2:fn,pingPong:dn,preTransforms:Hr,pseudoRandom:un,pseudoRandomRange:ln,pseudoRandomRangeInt:cn,quat:Ur,random:sn,randomRange:on,randomRangeInt:hn,rect:Ss,repeat:_n,setRandGenerator:an,size:gs,toDegree:rn,toRadian:nn,v2:ps,v3:nr,v4:Nn});t("aK",Ts);var As=new ir,Cs=new ir,Ds=new ir,Bs=new ir,Is=new ir,Ms=new ir,Ps=new Array(3),Es=new Array(3);function Os(t,e){return ir.dot(e.n,t)-e.d}function ks(t,e,i){return ir.copy(t,e),ir.subtract(Is,i.center,i.halfExtents),ir.add(Ms,i.center,i.halfExtents),t.x=t.xMs.x?Ms.x:t.x,t.y=t.y>Ms.y?Ms.y:t.y,t.z=t.z>Ms.z?Ms.z:t.z,t}function Rs(t,e,i){ir.set(As,i.orientation.m00,i.orientation.m01,i.orientation.m02),ir.set(Cs,i.orientation.m03,i.orientation.m04,i.orientation.m05),ir.set(Ds,i.orientation.m06,i.orientation.m07,i.orientation.m08),Ps[0]=As,Ps[1]=Cs,Ps[2]=Ds,Es[0]=i.halfExtents.x,Es[1]=i.halfExtents.y,Es[2]=i.halfExtents.z,ir.subtract(Bs,e,i.center),ir.set(t,i.center.x,i.center.y,i.center.z);for(var n=0;n<3;n++){var r=ir.dot(Bs,Ps[n]);r>Es[n]&&(r=Es[n]),r<-Es[n]&&(r=-Es[n]),t.x+=r*Ps[n].x,t.y+=r*Ps[n].y,t.z+=r*Ps[n].z}return t}var Fs=Object.freeze({__proto__:null,point_plane:Os,pt_point_aabb:ks,pt_point_line:function(t,e,i,n){ir.subtract(As,i,n);var r=As.clone(),s=ir.lengthSqr(r);if(0===s)ir.copy(t,i);else{ir.subtract(As,e,i);var a=ir.dot(As,r)/s;a<0?ir.copy(t,i):a>1?ir.copy(t,n):ir.scaleAndAdd(t,i,r,a)}},pt_point_obb:Rs,pt_point_plane:function(t,e,i){var n=Os(e,i);return ir.subtract(t,e,ir.multiplyScalar(t,i.n,n))}}),Ls=function(){function t(t,e,i,n,r,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=-1),this.s=void 0,this.e=void 0,this._type=void 0,this._type=2,this.s=new ir(t,e,i),this.e=new ir(n,r,s)}return t.create=function(e,i,n,r,s,a){return new t(e,i,n,r,s,a)},t.clone=function(e){return new t(e.s.x,e.s.y,e.s.z,e.e.x,e.e.y,e.e.z)},t.copy=function(t,e){return ir.copy(t.s,e.s),ir.copy(t.e,e.e),t},t.fromPoints=function(t,e,i){return ir.copy(t.s,e),ir.copy(t.e,i),t},t.set=function(t,e,i,n,r,s,a){return t.s.x=e,t.s.y=i,t.s.z=n,t.e.x=r,t.e.y=s,t.e.z=a,t},t.len=function(t){return ir.distance(t.s,t.e)},t.prototype.length=function(){return ir.distance(this.s,this.e)},n(t,[{key:"type",get:function(){return this._type}}]),t}(),Vs=function(){function t(t,e,i,n,r,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=-1),this._type=1,this.o=new ir(t,e,i),this.d=new ir(n,r,s)}return t.create=function(e,i,n,r,s,a){return void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=0),void 0===a&&(a=1),new t(e,i,n,r,s,a)},t.clone=function(e){return new t(e.o.x,e.o.y,e.o.z,e.d.x,e.d.y,e.d.z)},t.copy=function(t,e){return ir.copy(t.o,e.o),ir.copy(t.d,e.d),t},t.fromPoints=function(t,e,i){return ir.copy(t.o,e),ir.normalize(t.d,ir.subtract(t.d,i,e)),t},t.set=function(t,e,i,n,r,s,a){return t.o.x=e,t.o.y=i,t.o.z=n,t.d.x=r,t.d.y=s,t.d.z=a,t},t.prototype.computeHit=function(t,e){ir.normalize(t,this.d),ir.scaleAndAdd(t,this.o,t,e)},n(t,[{key:"type",get:function(){return this._type}}]),t}(),Ns=new ir,zs=new ir,Us=new ir,Gs=new ir;function Hs(t){return Math.max(Math.max(t.x,t.y),t.z)}var Ws,js,qs,Xs,Ys,Js=function(){function t(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=1),this._type=4,this._center=new ir(t,e,i),this._radius=n}t.create=function(e,i,n,r){return new t(e,i,n,r)},t.clone=function(e){return new t(e.center.x,e.center.y,e.center.z,e.radius)},t.copy=function(t,e){return ir.copy(t.center,e.center),t.radius=e.radius,t},t.fromPoints=function(t,e,i){return ir.multiplyScalar(t.center,ir.add(Ns,e,i),.5),t.radius=.5*ir.subtract(Ns,i,e).length(),t},t.set=function(t,e,i,n,r){return t.center.x=e,t.center.y=i,t.center.z=n,t.radius=r,t};var e=t.prototype;return e.destroy=function(){},e.clone=function(){return t.clone(this)},e.copy=function(e){return t.copy(this,e)},e.getBoundary=function(t,e){ir.set(t,this.center.x-this.radius,this.center.y-this.radius,this.center.z-this.radius),ir.set(e,this.center.x+this.radius,this.center.y+this.radius,this.center.z+this.radius)},e.transform=function(t,e,i,n,r){ir.transformMat4(r.center,this.center,t),r.radius=this.radius*Hs(n)},e.translateAndRotate=function(t,e,i){ir.transformMat4(i.center,this.center,t)},e.setScale=function(t,e){e.radius=this.radius*Hs(t)},e.mergePoint=function(t){this.radius<0&&(this.center.set(t),this.radius=0),ir.subtract(zs,t,this.center);var e=zs.length();if(e>this.radius){var i=.5*(e-this.radius);this.radius+=i,ir.multiplyScalar(zs,zs,i/e),ir.add(this.center,this.center,zs)}},e.mergePoints=function(t){var e=t.length;if(!(e<1)){this.radius=-1;for(var i=0;i-Number.EPSILON))return 0;var r=1/n;Qs(Xs,t.o,e.a);var s=Zs(Xs,qs)*r;if(s<0||s>1)return 0;ta(Ys,Xs,Ws);var a=Zs(t.d,Ys)*r;if(a<0||s+a>1)return 0;var o=Zs(js,Ys)*r;return o<0?0:o}),la=function(){var t=nr();return function(e,i){var n=i.radius,r=i.center,s=e.o,a=e.d,o=n*n;Qs(t,r,s);var h=t.lengthSqr(),u=Zs(t,a),l=o-(h-u*u);if(l<0)return 0;var c=Math.sqrt(l),f=hp?0:d>0?d:p}var _a=function(){var t=nr(),e=nr(),i=nr(),n=nr(),r=nr(),s=nr(),a=nr(),o=new Array(3),h=new Array(3),u=new Array(3),l=new Array(6);return function(c,f){var _=f.halfExtents,d=f.orientation;o[0]=_.x,o[1]=_.y,o[2]=_.z,t=f.center,e=c.o,i=c.d,$s(n,d.m00,d.m01,d.m02),$s(r,d.m03,d.m04,d.m05),$s(s,d.m06,d.m07,d.m08),Qs(a,t,e),h[0]=Zs(n,i),h[1]=Zs(r,i),h[2]=Zs(s,i),u[0]=Zs(n,a),u[1]=Zs(r,a),u[2]=Zs(s,a);for(var p=0;p<3;++p){if(0===h[p]){if(-u[p]-o[p]>0||-u[p]+o[p]<0)return 0;h[p]=1e-7}l[2*p+0]=(u[p]+o[p])/h[p],l[2*p+1]=(u[p]-o[p])/h[p]}var m=sa(sa(aa(l[0],l[1]),aa(l[2],l[3])),aa(l[4],l[5])),g=aa(aa(sa(l[0],l[1]),sa(l[2],l[3])),sa(l[4],l[5]));return g<0||m>g?0:m>0?m:g}}(),da=function(){var t=nr(),e=nr(),i=nr(),n=nr(),r=nr(),s=nr(),a=nr(),o=new Js;return function(h,u){var l=u.ellipseCenter0,c=u.ellipseCenter1,f=Qs(e,c,l);if(f.length()=0&&B<=1?T:B<0?(o.radius=u.radius,o.center.set(u.ellipseCenter0),Za.raySphere(h,o)):B>1?(o.radius=u.radius,o.center.set(u.ellipseCenter1),Za.raySphere(h,o)):0}}(),pa=function(){var t=nr();return function(e,i){Qs(t,e.e,e.s);var n=-Os(e.s,i)/Zs(t,i.n);return n<0||n>1?0:n}}(),ma=function(){var t=nr(),e=nr(),i=nr(),n=nr(),r=nr(),s=nr();return function(a,o,h){Qs(t,o.b,o.a),Qs(e,o.c,o.a),Qs(i,a.s,a.e),ta(r,t,e);var u=Zs(i,r);if(u<=0)return 0;Qs(n,a.s,o.a);var l=Zs(n,r);if(l<0||l>u)return 0;ta(s,i,n);var c=Zs(e,s);if(c<0||c>u)return 0;var f=-Zs(t,s);if(f<0||c+f>u)return 0;if(h){var _=1/u,d=1-(c*=_)-(f*=_);$s(h,o.a.x*d+o.b.x*c+o.c.x*f,o.a.y*d+o.b.y*c+o.c.y*f,o.a.z*d+o.b.z*c+o.c.z*f)}return 1}}(),ga=new Vs;function ya(t,e){ga.o.set(t.s),Qs(ga.d,t.e,t.s),ga.d.normalize();var i=ca(ga,e);return i<=t.length()?i:0}function va(t,e){ga.o.set(t.s),Qs(ga.d,t.e,t.s),ga.d.normalize();var i=_a(ga,e);return i<=t.length()?i:0}function ba(t,e){ga.o.set(t.s),Qs(ga.d,t.e,t.s),ga.d.normalize();var i=la(ga,e);return i<=t.length()?i:0}var Sa,wa,xa,Ta,Aa=(Sa=nr(),wa=nr(),xa=nr(),Ta=nr(),function(t,e){return Qs(Sa,t.center,t.halfExtents),na(wa,t.center,t.halfExtents),Qs(xa,e.center,e.halfExtents),na(Ta,e.center,e.halfExtents),Sa.x<=Ta.x&&wa.x>=xa.x&&Sa.y<=Ta.y&&wa.y>=xa.y&&Sa.z<=Ta.z&&wa.z>=xa.z});function Ca(t,e,i){$s(i[0],t.x,e.y,e.z),$s(i[1],t.x,e.y,t.z),$s(i[2],t.x,t.y,e.z),$s(i[3],t.x,t.y,t.z),$s(i[4],e.x,e.y,e.z),$s(i[5],e.x,e.y,t.z),$s(i[6],e.x,t.y,e.z),$s(i[7],e.x,t.y,t.z)}function Da(t,e,i,n,r,s){$s(s[0],t.x+i.x*e.x+n.x*e.y+r.x*e.z,t.y+i.y*e.x+n.y*e.y+r.y*e.z,t.z+i.z*e.x+n.z*e.y+r.z*e.z),$s(s[1],t.x-i.x*e.x+n.x*e.y+r.x*e.z,t.y-i.y*e.x+n.y*e.y+r.y*e.z,t.z-i.z*e.x+n.z*e.y+r.z*e.z),$s(s[2],t.x+i.x*e.x-n.x*e.y+r.x*e.z,t.y+i.y*e.x-n.y*e.y+r.y*e.z,t.z+i.z*e.x-n.z*e.y+r.z*e.z),$s(s[3],t.x+i.x*e.x+n.x*e.y-r.x*e.z,t.y+i.y*e.x+n.y*e.y-r.y*e.z,t.z+i.z*e.x+n.z*e.y-r.z*e.z),$s(s[4],t.x-i.x*e.x-n.x*e.y-r.x*e.z,t.y-i.y*e.x-n.y*e.y-r.y*e.z,t.z-i.z*e.x-n.z*e.y-r.z*e.z),$s(s[5],t.x+i.x*e.x-n.x*e.y-r.x*e.z,t.y+i.y*e.x-n.y*e.y-r.y*e.z,t.z+i.z*e.x-n.z*e.y-r.z*e.z),$s(s[6],t.x-i.x*e.x+n.x*e.y-r.x*e.z,t.y-i.y*e.x+n.y*e.y-r.y*e.z,t.z-i.z*e.x+n.z*e.y-r.z*e.z),$s(s[7],t.x-i.x*e.x-n.x*e.y+r.x*e.z,t.y-i.y*e.x-n.y*e.y+r.y*e.z,t.z-i.z*e.x-n.z*e.y+r.z*e.z)}function Ba(t,e){for(var i=Zs(e,t[0]),n=i,r=1;r<8;++r){var s=Zs(e,t[r]);i=sn?s:n}return[i,n]}var Ia,Ma,Pa,Ea,Oa,ka=function(){for(var t=new Array(15),e=0;e<15;e++)t[e]=nr();for(var i=new Array(8),n=new Array(8),r=0;r<8;r++)i[r]=nr(),n[r]=nr();var s=nr(),a=nr();return function(e,r){var o=r.orientation;$s(t[0],1,0,0),$s(t[1],0,1,0),$s(t[2],0,0,1),$s(t[3],o.m00,o.m01,o.m02),$s(t[4],o.m03,o.m04,o.m05),$s(t[5],o.m06,o.m07,o.m08);for(var h=0;h<3;++h)ta(t[6+3*h],t[h],t[3]),ta(t[7+3*h],t[h],t[4]),ta(t[7+3*h],t[h],t[5]);Qs(s,e.center,e.halfExtents),na(a,e.center,e.halfExtents),Ca(s,a,i),Da(r.center,r.halfExtents,t[3],t[4],t[5],n);for(var u=0;u<15;++u){var l=Ba(i,t[u]),c=Ba(n,t[u]);if(c[0]>l[1]||l[0]>c[1])return 0}return 1}}(),Ra=function(t,e){var i=t.halfExtents,n=e.n,r=i.x*oa(n.x)+i.y*oa(n.y)+i.z*oa(n.z),s=Zs(n,t.center);return s+re.d?0:1},Fa=function(t,e){for(var i=e.planes,n=0;na.x?e++:t[c].x<-a.x&&i++;if(e===s.length||i===s.length)return 0;e=0,i=0;for(var f=0;fa.y?e++:t[f].y<-a.y&&i++;if(e===s.length||i===s.length)return 0;e=0,i=0;for(var _=0;_a.z?e++:t[_].z<-a.z&&i++;return e===s.length||i===s.length?0:1}}(),Va=(Ia=nr(),Ma=new yr,function(t,e){return Qs(Ia,e,t.center),ir.transformMat3(Ia,Ia,yr.transpose(Ma,t.orientation)),i=Ia,n=t.halfExtents,oa(i.x)s?0:1}),za=function(t,e){for(var i=e.planes,n=0;nh.x?i++:e<-h.x&&n++;if(i===u.length||n===u.length)return 0;i=0,n=0;for(var m=0;mh.y?i++:e<-h.y&&n++;if(i===u.length||n===u.length)return 0;i=0,n=0;for(var g=0;gh.z?i++:e<-h.z&&n++;return i===u.length||n===u.length?0:1}}(),Ga=function(){for(var t=new Array(15),e=0;e<15;e++)t[e]=nr();for(var i=new Array(8),n=new Array(8),r=0;r<8;r++)i[r]=nr(),n[r]=nr();return function(e,r){var s=e.orientation,a=r.orientation;$s(t[0],s.m00,s.m01,s.m02),$s(t[1],s.m03,s.m04,s.m05),$s(t[2],s.m06,s.m07,s.m08),$s(t[3],a.m00,a.m01,a.m02),$s(t[4],a.m03,a.m04,a.m05),$s(t[5],a.m06,a.m07,a.m08);for(var o=0;o<3;++o)ta(t[6+3*o],t[o],t[3]),ta(t[7+3*o],t[o],t[4]),ta(t[8+3*o],t[o],t[5]);Da(e.center,e.halfExtents,t[0],t[1],t[2],i),Da(r.center,r.halfExtents,t[3],t[4],t[5],n);for(var h=0;h<15;++h){var u=Ba(i,t[h]),l=Ba(n,t[h]);if(l[0]>u[1]||u[0]>l[1])return 0}return 1}}(),Ha=function(){for(var t=new Js,e=nr(),i=nr(),n=nr(),r=new Array(8),s=0;s<8;s++)r[s]=nr();for(var a=new Array(8),o=0;o<8;o++)a[o]=nr();return function(s,o){var h=o.ellipseCenter0,u=o.ellipseCenter1,l=o.radius;if(0===Ks(h,u))return t.radius=o.radius,t.center.set(h),Za.sphereOBB(t,s);var c=s.orientation;e.x=c.m00,e.y=c.m01,e.z=c.m02,i.x=c.m03,i.y=c.m04,i.z=c.m05,n.x=c.m06,n.y=c.m07,n.z=c.m08,Da(s.center,s.halfExtents,e,i,n,r);var f=a,_=ia(f[0],e),d=ia(f[1],i),p=ia(f[2],n);Qs(f[3],o.center,s.center).normalize();var m=Qs(f[4],h,u);m.normalize(),ta(f[5],_,m),ta(f[6],d,m),ta(f[7],p,m);for(var g=0;g<8;++g){var y=Ba(r,f[g]),v=Zs(f[g],h),b=Zs(f[g],u),S=sa(v,b)+l;if(aa(v,b)-l>y[1]||y[0]>S)return 0}return 1}}(),Wa=function(t,e){var i=Zs(e.n,t.center),n=t.radius*e.n.length();return i+ne.d?0:1},ja=function(t,e){for(var i=e.planes,n=0;no)){na(Ea,s,ea(Ea,a,r));for(var u=0;u<6;u++)if(u!==i&&u!==i+Oa[i]){var l=e.planes[u];if(Zs(l.n,Ea)1?Ks(a,s)x&&(h=x,u=S+y,T=v)),u<0?(u=0,-b<0?h=0:-b>g?h=x:(h=-b,x=g)):u>T&&(u=T,-b+y<0?h=0:-b+y>g?h=x:(h=-b+y,x=g));var A=oa(h)0&&(t.d=e.d/i),t},t.prototype.transform=function(t){Kr.invert(eo,t),Kr.transpose(eo,eo),Vn.set(io,this.n.x,this.n.y,this.n.z,-this.d),Vn.transformMat4(io,io,eo),ir.set(this.n,io.x,io.y,io.z),this.d=-io.w},n(t,[{key:"type",get:function(){return this._type}},{key:"x",get:function(){return this.n.x},set:function(t){this.n.x=t}},{key:"y",get:function(){return this.n.y},set:function(t){this.n.y=t}},{key:"z",get:function(){return this.n.z},set:function(t){this.n.z=t}},{key:"w",get:function(){return this.d},set:function(t){this.d=t}}]),t}(),ro=function(){function t(t,e,i,n,r,s,a,o,h){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=1),void 0===r&&(r=0),void 0===s&&(s=0),void 0===a&&(a=0),void 0===o&&(o=1),void 0===h&&(h=0),this._type=64,this.a=new ir(t,e,i),this.b=new ir(n,r,s),this.c=new ir(a,o,h)}return t.create=function(e,i,n,r,s,a,o,h,u){return void 0===e&&(e=1),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=0),void 0===a&&(a=0),void 0===o&&(o=0),void 0===h&&(h=0),void 0===u&&(u=1),new t(e,i,n,r,s,a,o,h,u)},t.clone=function(e){return new t(e.a.x,e.a.y,e.a.z,e.b.x,e.b.y,e.b.z,e.c.x,e.c.y,e.c.z)},t.copy=function(t,e){return ir.copy(t.a,e.a),ir.copy(t.b,e.b),ir.copy(t.c,e.c),t},t.fromPoints=function(t,e,i,n){return ir.copy(t.a,e),ir.copy(t.b,i),ir.copy(t.c,n),t},t.set=function(t,e,i,n,r,s,a,o,h,u){return t.a.x=e,t.a.y=i,t.a.z=n,t.b.x=r,t.b.y=s,t.b.z=a,t.c.x=o,t.c.y=h,t.c.z=u,t},n(t,[{key:"type",get:function(){return this._type}}]),t}();Dt({replaceProperty:{since:"3.6.0",removed:!1},removeProperty:{since:"3.6.0",removed:!1},markAsWarning:{since:"3.6.0",removed:!1},setDefaultLogTimes:{since:"3.6.0",removed:!1}});var so=function(){function t(){this._poolHandle=-1,oo.addContainer(this)}return t.prototype.destroy=function(){oo.removeContainer(this)},t}(),ao=function(){function t(){this._pools=[],this._lastShrinkPassed=0,this.shrinkTimeSpan=5}var e=t.prototype;return e.addContainer=function(t){-1===t._poolHandle&&(t._poolHandle=this._pools.length,this._pools.push(t))},e.removeContainer=function(t){-1!==t._poolHandle&&(this._pools[this._pools.length-1]._poolHandle=t._poolHandle,be(this._pools,t._poolHandle),t._poolHandle=-1)},e.tryShrink=function(){for(var t=0;tthis.shrinkTimeSpan&&(this.tryShrink(),this._lastShrinkPassed-=this.shrinkTimeSpan)},t}(),oo=new ao,ho=t("by",function(t){function e(e,i,n,r){var s;(s=t.call(this)||this)._freePool=[],s._ctor=e,s._dtor=n||null,s._elementsPerBatch=Math.max(i,1),s._shrinkThreshold=r?P(r,1):s._elementsPerBatch,s._nextAvail=s._elementsPerBatch-1;for(var a=0;a>1>=this._shrinkThreshold?t>>1:Math.floor((t-this._shrinkThreshold+1)/2),this._dtor)for(var i=this._nextAvail-e+1;i<=this._nextAvail;++i)this._dtor(this._freePool[i]);this._nextAvail-=e,this._freePool.length=this._nextAvail+1}},i.destroy=function(){var e=arguments.length>0?arguments[0]:null;e&&at(14100);var i=e||this._dtor;if(i)for(var n=0;n<=this._nextAvail;n++)i(this._freePool[n]);this._freePool.length=0,this._nextAvail=-1,t.prototype.destroy.call(this)},e}(so)),uo=t("bz",function(t){function e(e,i,n){var r;(r=t.call(this)||this)._count=0,r._fn=e,r._dtor=n||null,r._data=new Array(i),r._initSize=i;for(var s=0;sthis._data.length)for(var e=this._data.length;e=this._data.length&&this.resize(this._data.length<<1),this._data[this._count++]},i.destroy=function(){if(this._dtor)for(var e=0;e>2>this._count){var t=Math.max(this._initSize,this._data.length>>1);if(this._dtor)for(var e=t;e=this._count)){var e=this._count-1,i=this._data[t];this._data[t]=this._data[e],this._data[e]=i,this._count-=1}},n(e,[{key:"length",get:function(){return this._count}},{key:"data",get:function(){return this._data}}]),e}(so)),lo=t("bA",function(t){function e(e,i){var n;return(n=t.call(this)||this).length=0,n._initSize=0,n.array=new Array(e),n._initSize=e,n._compareFn=i,n}s(e,t);var i=e.prototype;return i.push=function(t){this.array[this.length++]=t},i.pop=function(){return this.array[--this.length]},i.get=function(t){return this.array[t]},i.clear=function(){this.length=0},i.destroy=function(){this.length=0,this.array.length=0,t.prototype.destroy.call(this)},i.tryShrink=function(){this.array.length>>2>this.length&&(this.array.length=Math.max(this._initSize,this.array.length>>1))},i.sort=function(){this.array.length=this.length,this.array.sort(this._compareFn)},i.concat=function(t){for(var e=0;e=this.length||t<0)){var e=--this.length;this.array[t]=this.array[e]}},i.indexOf=function(t){for(var e=0,i=this.length;e=0;--t)this.callbackInfos[t]||So(this.callbackInfos,t);this.containCanceled=!1},e.clear=function(){this.cancelAll(),this.callbackInfos.length=0,this.isInvoking=!1,this.containCanceled=!1},t}(),Co=new ho((function(){return new Ao}),16),Do=t("d4",function(){function t(){this._callbackTable=Gt(!0),this._offCallback=void 0}var e=t.prototype;return e.on=function(t,e,i,n){if(!this.hasEventListener(t,e,i)){var r=this._callbackTable[t];r||(r=this._callbackTable[t]=Co.alloc());var s=To.alloc();s.set(e,i,n),r.callbackInfos.push(s)}return e},e.hasEventListener=function(t,e,i){var n=this._callbackTable&&this._callbackTable[t];if(!n)return!1;var r=n.callbackInfos;if(!e){if(n.isInvoking){for(var s=0;s0}for(var a=0;a1)&&(h=!0,u="",l=0);var f=Oo.UNKNOWN;-1!==r.appVersion.indexOf("Win")?f=Oo.WINDOWS:h?f=Oo.IOS:-1!==r.appVersion.indexOf("Mac")?f=Oo.OSX:-1!==r.appVersion.indexOf("X11")&&-1===r.appVersion.indexOf("Linux")?f=Oo.LINUX:o?f=Oo.ANDROID:-1===r.appVersion.indexOf("Linux")&&-1===s.indexOf("ubuntu")||(f=Oo.LINUX),i.os=f,i.osVersion=u,i.osMainVersion=l,i.browserType=Mo.UNKNOWN;var _=/wechat|weixin|micromessenger/i.exec(s)||/mqqbrowser|micromessenger|qqbrowser|sogou|qzone|liebao|maxthon|ucbs|360 aphone|360browser|baiduboxapp|baidubrowser|maxthon|mxbrowser|miuibrowser/i.exec(s)||/qq|qqbrowser|ucbrowser|ubrowser|edge|HuaweiBrowser/i.exec(s)||/chrome|safari|firefox|trident|opera|opr\/|oupeng/i.exec(s),d=_?_[0].toLowerCase():Oo.UNKNOWN;("safari"===d&&o||"qq"===d&&/android.*applewebkit/i.test(s))&&(d=Mo.ANDROID);var p={micromessenger:Mo.WECHAT,wechat:Mo.WECHAT,weixin:Mo.WECHAT,trident:Mo.IE,edge:Mo.EDGE,"360 aphone":Mo.BROWSER_360,mxbrowser:Mo.MAXTHON,"opr/":Mo.OPERA,ubrowser:Mo.UC,huaweibrowser:Mo.HUAWEI};i.browserType=p[d]||d,i.browserVersion="";var m=/(mqqbrowser|micromessenger|qqbrowser|sogou|qzone|liebao|maxthon|uc|ucbs|360 aphone|360|baiduboxapp|baidu|maxthon|mxbrowser|miui(?:.hybrid)?)(mobile)?(browser)?\/?([\d.]+)/i.exec(s);m||(m=/(qq|chrome|safari|firefox|trident|opera|opr\/|oupeng)(mobile)?(browser)?\/?([\d.]+)/i.exec(s)),i.browserVersion=m?m[4]:"",i.isXR=!1;var g,y=document.createElement("canvas");y.getContext("2d");try{g=y.toDataURL("image/webp").startsWith("data:image/webp")}catch(t){g=!1}if(i.os===Oo.IOS){var v,b=null==(v=/ applewebkit\/(\d+)/.exec(s))?void 0:v[1];"string"==typeof b&&Number.parseInt(b)>=604&&(g=!0)}else if(i.browserType===Mo.SAFARI){var x,T=null==(x=/ version\/(\d+)/.exec(s))?void 0:x[1];"string"==typeof T&&Number.parseInt(T)>=14&&(g=!0)}var A=void 0!==document.documentElement.ontouchstart||void 0!==document.ontouchstart||S,C=void 0!==document.documentElement.onmouseup||S,D=void 0!==navigator.xr,B=function(){if((i.os===Oo.IOS||i.os===Oo.OSX)&&/(OS 15_4)|(Version\/15.4)/.test(window.navigator.userAgent))return!1;try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){var t=new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0]));if(t instanceof WebAssembly.Module)return new WebAssembly.Instance(t)instanceof WebAssembly.Instance}}catch(t){return!1}return!1}();return i._featureMap=((e={})[Ro.WEBP]=g,e[Ro.IMAGE_BITMAP]=!1,e[Ro.WEB_VIEW]=!0,e[Ro.VIDEO_PLAYER]=!0,e[Ro.SAFE_AREA]=!1,e[Ro.HPE]=!1,e[Ro.INPUT_TOUCH]=A,e[Ro.EVENT_KEYBOARD]=void 0!==document.documentElement.onkeyup||S,e[Ro.EVENT_MOUSE]=C,e[Ro.EVENT_TOUCH]=A||C,e[Ro.EVENT_ACCELEROMETER]=void 0!==window.DeviceMotionEvent||void 0!==window.DeviceOrientationEvent,e[Ro.EVENT_GAMEPAD]=void 0!==navigator.getGamepads||void 0!==navigator.webkitGetGamepads||D,e[Ro.EVENT_HANDLE]=w,e[Ro.EVENT_HMD]=D,e[Ro.EVENT_HANDHELD]=D,e[Ro.WASM]=B,e),i._initPromise.push(i._supportsImageBitmapPromise()),i._registerEvent(),i}s(e,t);var i=e.prototype;return i._supportsImageBitmapPromise=function(){var t=this;if("undefined"!=typeof createImageBitmap&&"undefined"!=typeof Blob){var e=document.createElement("canvas");e.width=e.height=2;var i=createImageBitmap(e);if(i instanceof Promise)return i.then((function(e){e&&e.close&&(t._setFeature(Ro.IMAGE_BITMAP,!0),e.close())}))}return Promise.resolve()},i._registerEvent=function(){var t,e=this;t=void 0!==document.hidden?"hidden":void 0!==document.mozHidden?"mozHidden":void 0!==document.msHidden?"msHidden":void 0!==document.webkitHidden?"webkitHidden":"hidden";var i=!1,n=function(){i||(i=!0,e.emit("hide"))},r=function(t,n,r,s,a){i&&(i=!1,e.emit("show",t,n,r,s,a))};if(t)for(var s=["visibilitychange","mozvisibilitychange","msvisibilitychange","webkitvisibilitychange","qbrowserVisibilityChange"],a=0;a-1&&(window.onfocus=r),"onpageshow"in window&&"onpagehide"in window&&(window.addEventListener("pagehide",n),window.addEventListener("pageshow",r),document.addEventListener("pagehide",n),document.addEventListener("pageshow",r))},i._setFeature=function(t,e){return this._featureMap[t]=e},i.init=function(){return Promise.all(this._initPromise)},i.hasFeature=function(t){return this._featureMap[t]},i.getBatteryLevel=function(){return this._battery?this._battery.level:1},i.triggerGC=function(){},i.openURL=function(t){window.open(t)},i.now=function(){return Date.now?Date.now():+new Date},i.restartJSVM=function(){},i.exit=function(){window.close()},i.close=function(){this.emit("close")},e}(Io),Vo=new Lo,No=/(\.[^./?\\]*)(\?.*)?$/,zo=/((.*)(\/|\\|\\\\))?(.*?\..*$)?/,Uo=/[^./]+\/\.\.\//;function Go(){for(var t="",e=arguments.length,i=new Array(e),n=0;n0&&(t=t.substring(0,i));var n=/(\/|\\)([^/\\]+)$/g.exec(t.replace(/(\/|\\)$/,""));if(!n)return t;var r=n[2];return e&&t.substring(t.length-e.length).toLowerCase()===e.toLowerCase()?r.substring(0,r.length-e.length):r}function qo(t){var e=zo.exec(t);return e?e[2]:""}function Xo(t,e){e=e||"";var i=t.indexOf("?"),n="";return i>0&&(n=t.substring(i),t=t.substring(0,i)),(i=t.lastIndexOf("."))<0?t+e+n:t.substring(0,i)+e+n}function Yo(t,e,i){if(0===e.indexOf("."))return Xo(t,e);var n=t.indexOf("?"),r="",s=i?Ho(t):"";return n>0&&(r=t.substring(n),t=t.substring(0,n)),n=(n=t.lastIndexOf("/"))<=0?0:n+1,t.substring(0,n)+e+s+r}function Jo(t){var e=t=String(t);do{e=t,t=t.replace(Uo,"")}while(e.length!==t.length);return t}function Ko(t){return t.replace(/[/\\]$/,"")}function Qo(){return Vo.os===Oo.WINDOWS?"\\":"/"}t("bH",Object.freeze({__proto__:null,_normalize:Jo,basename:jo,changeBasename:Yo,changeExtname:Xo,dirname:qo,extname:Ho,getSeperator:Qo,join:Go,mainFileName:Wo,stripSep:Ko}));var Zo=new ir;function $o(t,e,i,n){n||(n=new ir),t.convertToUINode(e,i,n);var r=i.position;return n.add(r),n}function th(t,e,i){return i||(i=new ir),t.worldToScreen(e,i),i.x/=C.view.getScaleX(),i.y/=C.view.getScaleY(),i}var eh=t("bR",{WorldNode3DToLocalNodeUI:$o,WorldNode3DToWorldNodeUI:th});C.pipelineUtils=eh,pt(C.pipelineUtils,"cc.pipelineUtils",[{name:"WorldNode3DToLocalNodeUI",newName:"convertToUINode",targetName:"cc.Camera.prototype",customFunction:function(){for(var t=arguments.length,e=new Array(t),i=0;iwindow.innerHeight;this.isFrameRotated=Vo.isMobile&&(e&&t===Ne.PORTRAIT||!e&&t===Ne.LANDSCAPE)},e._updateContainer=function(){if(this._gameContainer){if(this.isProportionalToFrame){if(!this._gameFrame)return void at(9201);var t,e,i=C.view.getDesignResolutionSize(),n=this._gameFrame,r=n.clientWidth,s=n.clientHeight,a=i.width,o=i.height,h=r/a,u=s/o,l=this._gameContainer.style;h0&&at(1400,"screen.requestFullScreen(element, onFullScreenChange?, onFullScreenError?)","screen.requestFullScreen(): Promise"),sh.requestFullScreen().then((function(){null==e||e.call(document)})).catch((function(t){J(t),null==i||i.call(document)}))},e.exitFullScreen=function(){return sh.exitFullScreen()},e.autoFullScreen=function(t,e){var i;null==(i=this.requestFullScreen(t,e))||i.catch((function(t){Y(t)}))},e.disableAutoFullScreen=function(){},e.on=function(t,e,i){sh.on(t,e,i)},e.once=function(t,e,i){sh.once(t,e,i)},e.off=function(t,e,i){sh.off(t,e,i)},n(t,[{key:"devicePixelRatio",get:function(){return sh.devicePixelRatio}},{key:"windowSize",get:function(){return sh.windowSize},set:function(t){sh.windowSize=t}},{key:"resolution",get:function(){return sh.resolution}},{key:"supportsFullScreen",get:function(){return sh.supportFullScreen}}]),t}(),oh=t("cm",new ah);C.screen=oh;var hh=t("cn",{Feature:Ro,hasFeature:function(t){return Vo.hasFeature(t)},NetworkType:Eo,Language:Po,OS:Oo,Platform:ko,BrowserType:Mo,isNative:Vo.isNative,isBrowser:Vo.isBrowser,isMobile:Vo.isMobile,isLittleEndian:Vo.isLittleEndian,platform:Vo.platform,language:Vo.language,languageCode:Vo.nativeLanguage,os:Vo.os,osVersion:Vo.osVersion,osMainVersion:Vo.osMainVersion,browserType:Vo.browserType,browserVersion:Vo.browserVersion,isXR:Vo.isXR,windowPixelResolution:oh.windowSize,capabilities:{canvas:!0,opengl:!0,webp:Vo.hasFeature(Ro.WEBP),imageBitmap:Vo.hasFeature(Ro.IMAGE_BITMAP),touches:Vo.hasFeature(Ro.INPUT_TOUCH),mouse:Vo.hasFeature(Ro.EVENT_MOUSE),keyboard:Vo.hasFeature(Ro.EVENT_KEYBOARD),accelerometer:Vo.hasFeature(Ro.EVENT_ACCELEROMETER)},localStorage:{},getNetworkType:function(){return Vo.networkType},getBatteryLevel:function(){return Vo.getBatteryLevel()},garbageCollect:function(){Vo.triggerGC()},isObjectValid:function(t){return null!=t},__isWebIOS14OrIPadOS14Env:!1,dump:function(){var t="";t+="isMobile : "+this.isMobile+"\r\n",t+="language : "+this.language+"\r\n",t+="browserType : "+this.browserType+"\r\n",t+="browserVersion : "+this.browserVersion+"\r\n",t+="supports webp: "+hh.hasFeature(Ro.WEBP)+"\r\n",t+="supports bitmap: "+hh.hasFeature(Ro.IMAGE_BITMAP)+"\r\n",t+="supports touches: "+hh.hasFeature(Ro.INPUT_TOUCH)+"\r\n",t+="supports mouse: "+hh.hasFeature(Ro.EVENT_MOUSE)+"\r\n",t+="supports keyboard: "+hh.hasFeature(Ro.EVENT_KEYBOARD)+"\r\n",t+="supports accelerometer: "+hh.hasFeature(Ro.EVENT_ACCELEROMETER)+"\r\n",t+="os : "+this.os+"\r\n",t+="osVersion : "+this.osVersion+"\r\n",t+="platform : "+this.platform+"\r\n",X(t+="Using "+(C.game.renderType===C.game.RENDER_TYPE_WEBGL?"WEBGL":"CANVAS")+" renderer.\r\n")},openURL:function(t){Vo.openURL(t)},init:function(){var t=this;return Promise.resolve().then((function(){return Vo.init()})).then((function(){try{var e=hh.localStorage=window.localStorage;e.setItem("storage",""),e.removeItem("storage"),e=null}catch(e){var i=function(){at(5200)};t.localStorage={getItem:i,setItem:i,clear:i,removeItem:i,key:i,length:0}}t.__isWebIOS14OrIPadOS14Env=(hh.os===Oo.IOS||hh.os===Oo.OSX)&&Vo.isBrowser&&/(OS 14)|(Version\/14)/.test(window.navigator.userAgent)}))},now:function(){return Vo.now()},restartVM:function(){Vo.restartJSVM()},getSafeAreaRect:function(t){void 0===t&&(t=!0);var e=C.view,i=sh.safeAreaEdge;t&&(sh.orientation===Ue.ORIENTATION_PORTRAIT?i.topch.x&&(ch.x=t.x),t.y>ch.y&&(ch.y=t.y),t.z>ch.z&&(ch.z=t.z),ir.add(fh,lh,ch),this.center.set(ir.multiplyScalar(fh,fh,.5)),this.halfExtents.set(ch.x-fh.x,ch.y-fh.y,ch.z-fh.z)},e.mergePoints=function(t){if(!(t.length<1))for(var e=0;e>>1;n<=r;s=n+r>>>1){var a=t[s];if(a>e+i)r=s-1;else{if(!(a=t._times.length)return{done:!0,value:void 0};var i=[t._times[e],t._values[e]];return++e,{done:!1,value:i}}}},e.keyframes=function(){return this},e.times=function(){return this._times},e.values=function(){return this._values},e.getKeyframeTime=function(t){return this._times[t]},e.getKeyframeValue=function(t){return this._values[t]},e.addKeyFrame=function(t,e){return this._insertNewKeyframe(t,e)},e.removeKeyframe=function(t){this._times.splice(t,1),this._values.splice(t,1)},e.indexOfKeyframe=function(t){return kh(this._times,t)},e.updateTime=function(t,e){var i=this._values[t];this.removeKeyframe(t),this._insertNewKeyframe(e,i)},e.assignSorted=function(t,e){if(void 0!==e)this.setKeyframes(t.slice(),e.slice());else{var i=Array.from(t);this.setKeyframes(i.map((function(t){return t[0]})),i.map((function(t){return t[1]})))}},e.clear=function(){this._times.length=0,this._values.length=0},e.searchKeyframe=function(t){return kh(this._times,t)},e.setKeyframes=function(t,e){t.length,e.length,Fh(t),this._times=t,this._values=e},e._insertNewKeyframe=function(t,e){var i=this._times,n=this._values,r=i.length,s=kh(i,t);if(s>=0)return s;var a=~s;return 0===a?(i.unshift(t),n.unshift(e)):a===r?(i.push(t),n.push(e)):(i.splice(a-1,0,t),n.splice(a-1,0,e)),a},n(t,[{key:"keyFramesCount",get:function(){return this._times.length}},{key:"rangeMin",get:function(){return this._times[0]}},{key:"rangeMax",get:function(){return this._times[this._values.length-1]}}]),t}();function Fh(t){return t.every((function(t,e,i){return 0===e||t>i[e-1]||Zi(t,i[e-1],1e-6)}))}function Lh(t,e,i,n,r){var s=i/n,a=e/n,o=s*s,h=1/3*(-1/3*o+a),u=.5*(2/27*s*o-1/3*s*a+t/n),l=h*h*h,c=u*u+l,f=0;if(Nh(c)){if(Nh(u))return r[0]=0,1;var _=Math.cbrt(-u);return r[0]=2*_,r[1]=-_,2}if(c<0){var d=1/3*Math.acos(-u/Math.sqrt(-l)),p=2*Math.sqrt(-h);r[0]=p*Math.cos(d),r[1]=-p*Math.cos(d+Math.PI/3),r[2]=-p*Math.cos(d-Math.PI/3),f=3}else{var m=Math.sqrt(c),g=Math.cbrt(m-u),y=-Math.cbrt(m+u);r[0]=g+y,f=1}for(var v=1/3*s,b=0;b-1e-9&&t>3},n=i.storageUnit,r=qu(i.elementType),s=new(Xu(n))(t,this._byteOffset,this._unitCount),a=new Array(this._length),o=0;o=1?1:t*t*(3-2*t)}function Ml(t){return t<=0?0:t>=1?1:t*t*t*(t*(6*t-15)+10)}C._decorator=Wu;var Pl=Ul($u,tl),El=Ul(il,nl),Ol=Ul(sl,al),kl=Ul(hl,ul),Rl=Ul(cl,fl),Fl=Ul(dl,pl),Ll=Ul(gl,yl),Vl=Ul(bl,Sl),Nl=Ul(xl,Tl),zl=Ul(Cl,Dl);function Ul(t,e){return function(i){return i<.5?e(2*i)/2:t(2*i-1)/2+.5}}var Gl,Hl=Object.freeze({__proto__:null,backIn:xl,backInOut:Al,backOut:Tl,backOutIn:Nl,bounceIn:Cl,bounceInOut:Bl,bounceOut:Dl,bounceOutIn:zl,circIn:gl,circInOut:vl,circOut:yl,circOutIn:Ll,constant:Qu,cubicIn:il,cubicInOut:rl,cubicOut:nl,cubicOutIn:El,elasticIn:bl,elasticInOut:wl,elasticOut:Sl,elasticOutIn:Vl,expoIn:dl,expoInOut:ml,expoOut:pl,expoOutIn:Fl,fade:Ml,linear:Zu,quadIn:$u,quadInOut:el,quadOut:tl,quadOutIn:Pl,quartIn:sl,quartInOut:ol,quartOut:al,quartOutIn:Ol,quintIn:hl,quintInOut:ll,quintOut:ul,quintOutIn:kl,sineIn:cl,sineInOut:_l,sineOut:fl,sineOutIn:Rl,smooth:Il});t("cG",Hl),t("d3",{LINEAR:0,CONSTANT:1,QUAD_IN:2,QUAD_OUT:3,QUAD_IN_OUT:4,QUAD_OUT_IN:5,CUBIC_IN:6,CUBIC_OUT:7,CUBIC_IN_OUT:8,CUBIC_OUT_IN:9,QUART_IN:10,QUART_OUT:11,QUART_IN_OUT:12,QUART_OUT_IN:13,QUINT_IN:14,QUINT_OUT:15,QUINT_IN_OUT:16,QUINT_OUT_IN:17,SINE_IN:18,SINE_OUT:19,SINE_IN_OUT:20,SINE_OUT_IN:21,EXPO_IN:22,EXPO_OUT:23,EXPO_IN_OUT:24,EXPO_OUT_IN:25,CIRC_IN:26,CIRC_OUT:27,CIRC_IN_OUT:28,CIRC_OUT_IN:29,ELASTIC_IN:30,ELASTIC_OUT:31,ELASTIC_IN_OUT:32,ELASTIC_OUT_IN:33,BACK_IN:34,BACK_OUT:35,BACK_IN_OUT:36,BACK_OUT_IN:37,BOUNCE_IN:38,BOUNCE_OUT:39,BOUNCE_IN_OUT:40,BOUNCE_OUT_IN:41,SMOOTH:42,FADE:43});var Wl,jl=((Gl={})[1]=Qu,Gl[0]=Zu,Gl[2]=$u,Gl[3]=tl,Gl[4]=el,Gl[5]=Pl,Gl[6]=il,Gl[7]=nl,Gl[8]=rl,Gl[9]=El,Gl[10]=sl,Gl[11]=al,Gl[12]=ol,Gl[13]=Ol,Gl[14]=hl,Gl[15]=ul,Gl[16]=ll,Gl[17]=kl,Gl[18]=cl,Gl[19]=fl,Gl[20]=_l,Gl[21]=Rl,Gl[22]=dl,Gl[23]=pl,Gl[24]=ml,Gl[25]=Fl,Gl[26]=gl,Gl[27]=yl,Gl[28]=vl,Gl[29]=Ll,Gl[30]=bl,Gl[31]=Sl,Gl[32]=wl,Gl[33]=Vl,Gl[34]=xl,Gl[35]=Tl,Gl[36]=Al,Gl[37]=Nl,Gl[38]=Cl,Gl[39]=Dl,Gl[40]=Bl,Gl[41]=zl,Gl[42]=Il,Gl[43]=Ml,Gl);function ql(t){return jl[t]}O(255),O(65280);var Xl,Yl,Jl,Kl=function(t){function e(){var e;return(e=t.call(this)||this).value=0,e.rightTangent=0,e.rightTangentWeight=0,e.leftTangent=0,e.leftTangentWeight=0,e._flags=0,e}return s(e,t),n(e,[{key:"interpolationMode",get:function(){return 255&this._flags},set:function(t){this._flags&=-256,this._flags|=0|t}},{key:"tangentWeightMode",get:function(){return(65280&this._flags)>>8},set:function(t){this._flags&=-65281,this._flags|=t<<8}},{key:"easingMethod",get:function(){return(16711680&this._flags)>>16},set:function(t){this._flags&=-16711681,this._flags|=t<<16}}]),e}(Hu);function Ql(t){var e=new Kl;if("number"==typeof t)e.value=t;else{var i=t.interpolationMode,n=t.tangentWeightMode,r=t.value,s=t.rightTangent,a=t.rightTangentWeight,o=t.leftTangent,h=t.leftTangentWeight,u=t.easingMethod,l=t[co];e.value=null!=r?r:e.value,e.rightTangent=null!=s?s:e.rightTangent,e.rightTangentWeight=null!=a?a:e.rightTangentWeight,e.leftTangent=null!=o?o:e.leftTangent,e.leftTangentWeight=null!=h?h:e.leftTangentWeight,e.interpolationMode=null!=i?i:e.interpolationMode,e.tangentWeightMode=null!=n?n:e.tangentWeightMode,e.easingMethod=null!=u?u:e.easingMethod,l&&(e[co]=l)}return e}Vi.fastDefine("cc.RealKeyframeValue",Kl,((Wl={interpolationMode:0,tangentWeightMode:0,value:0,rightTangent:0,rightTangentWeight:0,leftTangent:0,leftTangentWeight:0,easingMethod:0})[co]=void 0,Wl)),Vi.Attr.setClassAttr(Kl,co,"editorOnly",!0),(Xl=Kl,null!==(Jl=(Yl=Xl)[hu])&&void 0!==Jl?Jl:Yl[hu]={}).uniquelyReferenced=!0;var Zl=t("cr",function(t){function e(){var e;return(e=t.call(this)||this).preExtrapolation=1,e.postExtrapolation=1,e}s(e,t);var i=e.prototype;return i.evaluate=function(t){var e=this._times,i=this._values,n=e.length;if(0===n)return 0;var r=e[0],s=e[n-1];if(ts){var h=this.postExtrapolation,u=i[n-1];if(1===h||n<2)return u.value;switch(h){case 0:return Tc(s,u.value,e[n-2],i[n-2].value,t);case 2:t=wc(t,r,s);break;case 3:t=xc(t,r,s);break;default:return u.value}}var l=kh(e,t);if(l>=0)return i[l].value;var c=~l,f=c-1,_=e[f],d=i[f],p=e[c];return Ac(_,d,p,i[c],(t-_)/(p-_))},i.addKeyFrame=function(e,i){return t.prototype.addKeyFrame.call(this,e,Ql(i))},i.assignSorted=function(t,e){if(void 0!==e)this.setKeyframes(t.slice(),e.map((function(t){return Ql(t)})));else{var i=Array.from(t);this.setKeyframes(i.map((function(t){return t[0]})),i.map((function(t){return Ql(t[1])})))}},i.isConstant=function(t){if(this._values.length<=1)return!0;var e=this._values[0].value;return this._values.every((function(i){return Zi(i.value,e,t)}))},i[Ju]=function(t,e){if(e.toCCON){var i=this._times,n=this._values,r=i.length,s=new DataView(new ArrayBuffer(0+ec+ec+ic+nc*r+vc*r)),a=0;s.setUint8(a,this.preExtrapolation),a+=ec,s.setUint8(a,this.postExtrapolation),a+=ec,s.setUint32(a,r,!0),a+=ic,i.forEach((function(t,e){return s.setFloat32(a+nc*e,t,!0)})),a+=nc*r;for(var o,h=p(n);!(o=h()).done;){var u=o.value;a=bc(s,u,a)}var l=new Uint8Array(s.buffer,0,a);t.writeProperty("bytes",l);var c=n.map((function(t){return t[co]}));c.some((function(t){return void 0!==t}))&&t.writeProperty("keyframeValueEditorExtras",c)}else t.writeThis()},i[Ku]=function(t,e){if(e.fromCCON){var i=t.readProperty("bytes"),n=new DataView(i.buffer,i.byteOffset,i.byteLength),r=0;this.preExtrapolation=n.getUint8(r),r+=ec,this.postExtrapolation=n.getUint8(r),r+=ec;var s=n.getUint32(r,!0);r+=ic;var a=Array.from({length:s},(function(t,e){return n.getFloat32(r+nc*e,!0)}));r+=nc*s;for(var o=new Array(s),h=0;h>$l;return e.easingMethod=s,n}function wc(t,e,i){return e+_n(t-e,i-e)}function xc(t,e,i){return e+dn(t-e,i-e)}function Tc(t,e,i,n,r){return e+(n-e)/(i-t)*(r-t)}function Ac(t,e,i,n,r){var s=i-t;switch(e.interpolationMode){default:case 1:return e.value;case 0:var a=0===e.easingMethod?r:ql(e.easingMethod)(r);return en(e.value,n.value,a);case 2:var o=1/3,h=e.rightTangent,u=e.rightTangentWeight,l=!!(2&e.tangentWeightMode),c=n.leftTangent,f=n.leftTangentWeight,_=!!(1&n.tangentWeightMode);if(l||_){var d=0;if(l)d=u;else{var p=s,m=s*h;d=Math.sqrt(p*p+m*m)*o}var g=Math.atan(h),y=Math.cos(g)*d+t,v=Math.sin(g)*d+e.value,b=0;if(_)b=f;else{var S=s,w=s*c;b=Math.sqrt(S*S+w*w)*o}var x=Math.atan(c),T=(y-t)/s,A=(-Math.cos(x)*b+i-t)/s,C=v,D=-Math.sin(x)*b+n.value,B=[0,0,0],I=Dc(B,Lh(0-r,3*T,3*A-6*T,3*(T-A)+1,B),r);return Cc(e.value,C,D,n.value,I)}var M=e.value+o*h*s,P=n.value-o*c*s;return Cc(e.value,M,P,n.value,r)}}function Cc(t,e,i,n,r){var s=1-r;return s*s*s*t+3*s*s*r*e+3*s*r*r*i+r*r*r*n}function Dc(t,e,i){var n=i;if(1===e)n=t[0];else{n=-1/0;for(var r=0;r=0&&s<=1&&s>n&&(n=s)}n===-1/0&&(n=0)}return n}function Bc(t,e,i,n,r){var s=1-r;return s*(s*(t+(3*e-t)*r)+3*i*r*r)+n*r*r*r}C.bezier=Bc;var Ic,Mc,Pc,Ec,Oc,kc,Rc,Fc,Lc,Vc=Math.cos,Nc=Math.acos,zc=Math.max,Uc=2*Math.PI,Gc=Math.sqrt;function Hc(t){return t<0?-Math.pow(-t,1/3):Math.pow(t,1/3)}function Wc(t,e){var i,n,r,s,a=e-0,o=e-t[0],h=3*a,u=3*o,l=3*(e-t[2]),c=1/(-a+u-l+(e-1)),f=1/3,_=(h-6*o+l)*c,d=_*f,p=(-h+u)*c,m=(3*p-_*_)*f,g=m*f,y=(2*_*_*_-9*_*p+a*c*27)/27,v=y/2,b=v*v+g*g*g;if(b<0){var S=-m*f,w=Gc(S*S*S),x=-y/(2*w),T=Nc(x<-1?-1:x>1?1:x),A=2*Hc(w);return n=A*Vc(T*f)-d,r=A*Vc((T+Uc)*f)-d,s=A*Vc((T+2*Uc)*f)-d,n>=0&&n<=1?r>=0&&r<=1?s>=0&&s<=1?zc(n,r,s):zc(n,r):s>=0&&s<=1?zc(n,s):n:r>=0&&r<=1?s>=0&&s<=1?zc(r,s):r:s}if(0===b)return r=-(i=v<0?Hc(-v):-Hc(v))-d,(n=2*i-d)>=0&&n<=1?r>=0&&r<=1?zc(n,r):n:r;var C=Gc(b);return(i=Hc(-v+C))-Hc(v+C)-d}function jc(t,e){var i=Wc(t,e),n=t[1];return((1-i)*(n+(t[3]-n)*i)*3+i*i)*i}C.bezierByTime=jc,t("cw",{SLERP:0,CONSTANT:1});var qc=Kh("cc.QuatKeyframeValue")(Ic=_u((Mc=function(t){var e=void 0===t?{}:t,i=e.value,n=e.interpolationMode,r=e.easingMethod;this.interpolationMode=Pc&&Pc(),this.value=Ec&&Ec(),this.easingMethod=Oc&&Oc(),this.value=i?kr.clone(i):this.value,this.interpolationMode=null!=n?n:this.interpolationMode,this.easingMethod=null!=r?r:this.easingMethod},Pc=zh(Mc.prototype,"interpolationMode",[uu],(function(){return 0})),Ec=zh(Mc.prototype,"value",[uu],(function(){return kr.clone(kr.IDENTITY)})),Oc=zh(Mc.prototype,"easingMethod",[uu],(function(){return 0})),Ic=Mc))||Ic)||Ic;function Xc(t){return new qc(t)}var Yc,Jc=t("cv",Kh("cc.QuatCurve")((Rc=function(t){function e(){var e;return(e=t.call(this)||this).preExtrapolation=Fc&&Fc(),e.postExtrapolation=Lc&&Lc(),e}s(e,t);var i=e.prototype;return i.evaluate=function(t,e){var i;null!==(i=e)&&void 0!==i||(e=new kr);var n=this._times,r=this._values,s=this.postExtrapolation,a=this.preExtrapolation,o=n.length;if(0===o)return e;var h=n[0],u=n[o-1];if(tu){var c=r[o-1];switch(s){case 2:t=h+_n(t-h,u-h);break;case 3:t=h+dn(t-h,u-h);break;default:return kr.copy(e,c.value)}}var f=kh(n,t);if(f>=0)return kr.copy(e,r[f].value);var _=~f,d=_-1,p=n[d],m=r[d],g=n[_],y=r[_],v=(t-p)/(g-p);switch(m.interpolationMode){default:case 1:return kr.copy(e,m.value);case 0:var b=m.easingMethod,S=0===b?v:Array.isArray(b)?jc(b,v):ql(b)(v);return kr.slerp(e,m.value,y.value,S)}},i.addKeyFrame=function(e,i){var n=new qc(i);return t.prototype.addKeyFrame.call(this,e,n)},i.assignSorted=function(t,e){if(void 0!==e)this.setKeyframes(t.slice(),e.map((function(t){return Xc(t)})));else{var i=Array.from(t);this.setKeyframes(i.map((function(t){return t[0]})),i.map((function(t){return Xc(t[1])})))}},i[Ju]=function(t,e){if(e.toCCON){var i=this._times,n=this._values,r=!0;n.forEach((function(t,e,i){var n=i[0];r&&t.interpolationMode!==n.interpolationMode&&(r=!1)}));var s=i.length,a=tf*(r?1:s),o=n.reduce((function(t,e){var i=e.easingMethod;return t+(Array.isArray(i)?ef+4*rf:ef)}),0),h=0,u=new DataView(new ArrayBuffer(h+=Kc+Qc+Zc*s+4*$c*s+o+a+0)),l=0,c=0;r&&(c|=1),u.setUint32(l,c,!0),l+=Kc,u.setUint32(l,s,!0),l+=Qc,i.forEach((function(t,e){return u.setFloat32(l+Zc*e,t,!0)})),l+=Zc*s,n.forEach((function(t,e){var i=t.value,n=i.x,r=i.y,s=i.z,a=i.w,o=l+4*$c*e;u.setFloat32(o+0*$c,n,!0),u.setFloat32(o+1*$c,r,!0),u.setFloat32(o+2*$c,s,!0),u.setFloat32(o+3*$c,a,!0)})),l+=4*$c*s,n.forEach((function(t){var e=t.easingMethod;Array.isArray(e)?(u.setUint8(l,nf),++l,u.setFloat32(l+0*rf,e[0],!0),u.setFloat32(l+1*rf,e[1],!0),u.setFloat32(l+2*rf,e[2],!0),u.setFloat32(l+3*rf,e[3],!0),l+=4*rf):(u.setUint8(l,e),++l)}));var f=l;l+=a;var _=f;n.forEach((function(t){var e=t.interpolationMode;u.setUint8(_,e),r||(_+=tf)}));var d=new Uint8Array(u.buffer);t.writeProperty("bytes",d)}else t.writeThis()},i[Ku]=function(t,e){if(e.fromCCON){var i=t.readProperty("bytes"),n=new DataView(i.buffer,i.byteOffset,i.byteLength),r=0,s=n.getUint32(r,!0);r+=Kc;var a=1&s,o=n.getUint32(r,!0);r+=Qc;var h=Array.from({length:o},(function(t,e){return n.getFloat32(r+Zc*e,!0)})),u=r+=Zc*o;r+=4*$c*o;var l=Array.from({length:o},(function(t,e){var i=u+4*$c*e,s=n.getFloat32(i+0*$c,!0),a=n.getFloat32(i+1*$c,!0),o=n.getFloat32(i+2*$c,!0),h=n.getFloat32(i+3*$c,!0),l=n.getUint8(r);++r;var c=Xc({value:{x:s,y:a,z:o,w:h}});return l!==nf?c.easingMethod=l:(c.easingMethod=[n.getFloat32(r+0*rf,!0),n.getFloat32(r+1*rf,!0),n.getFloat32(r+2*rf,!0),n.getFloat32(r+3*rf,!0)],r+=4*rf),c}));if(a){var c=n.getUint8(r);++r;for(var f=0;f=0)return this._values[e];var i=$i(~e-1,0,this._values.length-1);return this._values[i]},e}(Rh))||Yc),af={Blend:0,Fixed:1};Ee(af);var of=t("cy",(function(){this.color=cr.WHITE.clone(),this.time=0}));Vi.fastDefine("cc.ColorKey",of,{color:cr.WHITE.clone(),time:0}),Vi.Attr.setClassAttr(of,"color","visible",!0),Vi.Attr.setClassAttr(of,"time","visible",!0);var hf=t("cz",(function(){this.alpha=1,this.time=0}));Vi.fastDefine("cc.AlphaKey",hf,{alpha:1,time:0}),Vi.Attr.setClassAttr(hf,"alpha","visible",!0),Vi.Attr.setClassAttr(hf,"time","visible",!0);var uf=t("cA",function(){function t(){this.colorKeys=[],this.alphaKeys=[],this.mode=0}var e=t.prototype;return e.setKeys=function(t,e){this.colorKeys=t,this.alphaKeys=e},e.sortKeys=function(){this.colorKeys.length>1&&this.colorKeys.sort((function(t,e){return t.time-e.time})),this.alphaKeys.length>1&&this.alphaKeys.sort((function(t,e){return t.time-e.time}))},e.evaluate=function(t){return this.evaluateFast(new cr,t)},e.evaluateFast=function(t,e){return this.getRGB(t,e),t.a=this.getAlpha(e),t},e.randomColor=function(){return this.getRandomColor(new cr)},e.getRandomColor=function(t){var e=this.colorKeys[Math.trunc(sn()*this.colorKeys.length)],i=this.alphaKeys[Math.trunc(sn()*this.alphaKeys.length)];return t.set(e.color),t.a=i.alpha,t},e.getRGB=function(t,e){var i=this.colorKeys,n=i.length;if(n>1){e=_n(e,1+Ki);for(var r=1;r=s&&ei[h].time&&cr.lerp(t,i[h].color,cr.BLACK,(e-i[h].time)/(1-i[h].time))}else 1===n?cr.copy(t,i[0].color):cr.copy(t,cr.WHITE);return t},e.getAlpha=function(t){var e=this.alphaKeys,i=e.length;if(i>1){t=_n(t,1+Ki);for(var n=1;n=r&&te[o].time?en(e[o].alpha,0,(t-e[o].time)/(1-e[o].time)):255}return 1===i?e[0].alpha:255},t}());uf.Mode=af,Vi.fastDefine("cc.Gradient",uf,{colorKeys:[],alphaKeys:[],mode:0}),Vi.Attr.setClassAttr(uf,"colorKeys","visible",!0),Vi.Attr.setClassAttr(uf,"alphaKeys","visible",!0),Vi.Attr.setClassAttr(uf,"mode","visible",!0);var lf=function(){this.time=0,this.value=0,this.inTangent=0,this.outTangent=0};Vi.fastDefine("cc.Keyframe",lf,{time:0,value:0,inTangent:0,outTangent:0});var cf=function(){function t(){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 t.prototype.evaluate=function(t){return ff(t-this.time,this.coefficient)},t}();function ff(t,e){return t*(t*(t*e[0]+e[1])+e[2])+e[3]}var _f=function(){function t(t){if(void 0===t&&(t=null),this._curve=void 0,this.cachedKey=void 0,t instanceof Zl)this._curve=t;else{var e=new Zl;this._curve=e,e.preExtrapolation=2,e.postExtrapolation=1,t?e.assignSorted(t.map((function(t){return[t.time,{interpolationMode:2,value:t.value,leftTangent:t.inTangent,rightTangent:t.outTangent}]}))):e.assignSorted([[0,{interpolationMode:2,value:1}],[1,{interpolationMode:2,value:1}]])}this.cachedKey=new cf}var e=t.prototype;return e.addKey=function(t){t?this._curve.addKeyFrame(t.time,{interpolationMode:2,value:t.value,leftTangent:t.inTangent,rightTangent:t.outTangent}):this._curve.clear()},e.evaluate_slow=function(t){return this._curve.evaluate(t)},e.evaluate=function(t){var e=this.cachedKey,i=this._curve,n=i.keyFramesCount-1,r=t,s=t<0?i.preExtrapolation:i.postExtrapolation,a=i.getKeyframeTime(0),o=i.getKeyframeTime(n);switch(s){case 2:r=_n(t-a,o-a)+a;break;case 3:r=dn(t-a,o-a)+a;break;default:r=$i(t,a,o)}if(r>=e.time&&ri.getKeyframeTime(r))for(var s=0;s<3;s++){var a=r+s;if(a+1e)return a}else for(var o=0;o<3;o++){var h=r-o;if(h>=0&&i.getKeyframeTime(h-1)<=e)return h-1}for(var u,l=0,c=n;c-l>1;)u=Math.floor((l+c)/2),i.getKeyframeTime(u)>=e?c=u:l=u;return l},n(t,[{key:"_internalCurve",get:function(){return this._curve}},{key:"keyFrames",get:function(){return Array.from(this._curve.keyframes()).map((function(t){var e=t[0],i=t[1],n=new lf;return n.time=e,n.value=i.value,n.inTangent=i.leftTangent,n.outTangent=i.rightTangent,n}))},set:function(t){this._curve.assignSorted(t.map((function(t){return[t.time,{interpolationMode:2,value:t.value,leftTangent:t.inTangent,rightTangent:t.outTangent}]})))}},{key:"preWrapMode",get:function(){return pf(this._curve.preExtrapolation)},set:function(t){this._curve.preExtrapolation=df(t)}},{key:"postWrapMode",get:function(){return pf(this._curve.postExtrapolation)},set:function(t){this._curve.postExtrapolation=df(t)}}]),t}();function df(t){switch(t){default:case 0:case 1:case 8:return 1;case 22:return 3;case 2:return 2}}function pf(t){switch(t){default:case 0:case 1:return 8;case 3:return 22;case 2:return 2}}function mf(){var t=new Zl;return t.assignSorted([[0,{interpolationMode:2,value:1}],[1,{interpolationMode:2,value:1}]]),t}_f.defaultKF=[{time:0,value:1,inTangent:0,outTangent:0},{time:1,value:1,inTangent:0,outTangent:0}],Vi.fastDefine("cc.AnimationCurve",_f,{_curve:null});var gf=ir.multiplyScalar,yf=ir.add,vf=4294967295,bf=nr(),Sf=nr(),wf=nr(),xf=nr(),Tf=function(){function t(t,e){void 0===t&&(t=2),void 0===e&&(e=[]),this._type=void 0,this._knots=[],this._type=1024,this._mode=t;for(var i=0;i=this._knots.length?this._knots.push(i):this._knots.splice(t,0,i)},e.removeKnot=function(t){Me(this._knots,t),this._knots.splice(t,1)},e.setKnot=function(t,e){Me(this._knots,t),this._knots[t].set(e)},e.getKnot=function(t){return Me(this._knots,t),this._knots[t]},e.getPoint=function(e,i){void 0===i&&(i=vf),e=$i(e,0,1);var n=this.getSegments();if(0===n)return nr();if(i===vf){var r=1/n;i=Math.floor(e/r),e=e%r/r}var s=this._knots;if(i>=n)return nr(s[s.length-1]);switch(this._mode){case 0:return t.calcLinear(s[i],s[i+1],e);case 1:var a=4*i;return t.calcBezier(s[a],s[a+1],s[a+2],s[a+3],e);case 2:var o=i>0?s[i-1]:s[i],h=i+2e.priority?-1:0};var e=t.prototype;return e.init=function(){},e.update=function(){},e.postUpdate=function(){},e.destroy=function(){},n(t,[{key:"priority",get:function(){return this._priority},set:function(t){this._priority=t}},{key:"id",get:function(){return this._id},set:function(t){this._id=t}}]),t}());Ff.Priority=Ee({LOW:0,MEDIUM:100,HIGH:200,SCHEDULER:2147483648});var Lf=new It("Scheduler"),Vf=function(){function t(t,e,i,n){this.target=void 0,this.priority=void 0,this.paused=void 0,this.markedForDeletion=void 0,this.target=t,this.priority=e,this.paused=i,this.markedForDeletion=n}return t.get=function(e,i,n,r){var s=t._listEntries.pop();return s?(s.target=e,s.priority=i,s.paused=n,s.markedForDeletion=r):s=new t(e,i,n,r),s},t.put=function(e){t._listEntries.length<20&&(e.target=null,t._listEntries.push(e))},t}();Vf._listEntries=[];var Nf=function(){function t(t,e,i,n){this.list=void 0,this.entry=void 0,this.target=void 0,this.callback=void 0,this.list=t,this.entry=e,this.target=i,this.callback=n}return t.get=function(e,i,n,r){var s=t._hashUpdateEntries.pop();return s?(s.list=e,s.entry=i,s.target=n,s.callback=r):s=new t(e,i,n,r),s},t.put=function(e){t._hashUpdateEntries.length<20&&(e.list=e.entry=e.target=e.callback=null,t._hashUpdateEntries.push(e))},t}();Nf._hashUpdateEntries=[];var zf=function(){function t(t,e,i,n,r,s){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=t,this.target=e,this.timerIndex=i,this.currentTimer=n,this.currentTimerSalvaged=r,this.paused=s}return t.get=function(e,i,n,r,s,a){var o=t._hashTimerEntries.pop();return o?(o.timers=e,o.target=i,o.timerIndex=n,o.currentTimer=r,o.currentTimerSalvaged=s,o.paused=a):o=new t(e,i,n,r,s,a),o},t.put=function(e){t._hashTimerEntries.length<20&&(e.timers=e.target=e.currentTimer=null,t._hashTimerEntries.push(e))},t}();zf._hashTimerEntries=[];var Uf=function(){function t(){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}t.get=function(){return t._timers.pop()||new t},t.put=function(e){t._timers.length<20&&!e._lock&&(e._scheduler=e._target=e._callback=null,t._timers.push(e))};var e=t.prototype;return e.initWithCallback=function(t,e,i,n,r,s){return this._lock=!1,this._scheduler=t,this._target=i,this._callback=e,this._timesExecuted=0,this._elapsed=-1,this._interval=n,this._delay=s,this._useDelay=this._delay>0,this._repeat=r,this._runForever=this._repeat===C.macro.REPEAT_FOREVER,!0},e.getInterval=function(){return this._interval},e.setInterval=function(t){this._interval=t},e.update=function(t){-1===this._elapsed?(this._elapsed=0,this._timesExecuted=0):(this._elapsed+=t,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()))},e.getCallback=function(){return this._callback},e.trigger=function(){this._target&&this._callback&&(this._lock=!0,this._callback.call(this._target,this._elapsed),this._lock=!1)},e.cancel=function(){this._scheduler&&this._callback&&this._target&&this._scheduler.unscheduleForTimer(this,this._target)},t}();Uf._timers=[];var Gf=t("cq",function(t){function e(){var e;return(e=t.call(this)||this)._timeScale=void 0,e._updatesNegList=void 0,e._updates0List=void 0,e._updatesPosList=void 0,e._hashForUpdates=void 0,e._hashForTimers=void 0,e._currentTarget=void 0,e._currentTargetSalvaged=void 0,e._updateHashLocked=void 0,e._arrayForTimers=void 0,e._timeScale=1,e._updatesNegList=[],e._updates0List=[],e._updatesPosList=[],e._hashForUpdates=Gt(!0),e._hashForTimers=Gt(!0),e._currentTarget=null,e._currentTargetSalvaged=!1,e._updateHashLocked=!1,e._arrayForTimers=[],e}s(e,t),e.enableForTarget=function(t){var e=!1;(t.uuid||t.id)&&(e=!0),e||(t.id=Lf.getNewId())};var i=e.prototype;return i.setTimeScale=function(t){this._timeScale=t},i.getTimeScale=function(){return this._timeScale},i.update=function(t){var e,i,n,r,s;for(this._updateHashLocked=!0,1!==this._timeScale&&(t*=this._timeScale),e=0,n=(i=this._updatesNegList).length;e=s&&n.timerIndex--,void(0===r.length&&(this._currentTarget===n?this._currentTargetSalvaged=!0:this._removeHashElement(n)))}}}else ht(1510)}},i.unscheduleForTimer=function(t,e){var i=e.uuid||e.id,n=this._hashForTimers[i],r=n.timers;if(r&&0!==r.length)for(var s=r.length-1;s>=0;s--){var a=r[s];if(a===t)return r.splice(s,1),Uf.put(a),n.timerIndex>=s&&n.timerIndex--,void(0===r.length&&(this._currentTargetSalvaged=!0))}},i.unscheduleUpdate=function(t){if(t){var e=t.uuid||t.id;if(e){var i=this._hashForUpdates[e];null!=i&&i.entry&&(this._updateHashLocked?i.entry.markedForDeletion=!0:this._removeUpdateFromHash(i.entry))}else ht(1510)}},i.unscheduleAllForTarget=function(t){if(t){var e=t.uuid||t.id;if(e){var i=this._hashForTimers[e];if(null!=i&&i.timers){var n=i.timers;i.currentTimer&&n.indexOf(i.currentTimer)>-1&&!i.currentTimerSalvaged&&(i.currentTimerSalvaged=!0);for(var r=0,s=n.length;r=0;e--)(i=r[e]).target&&this.unscheduleAllForTarget(i.target);var s=0;if(t<0)for(e=0;e=t&&this.unscheduleUpdate(n.target),s===this._updatesNegList.length&&e++}if(t<=0)for(e=0;e=t&&this.unscheduleUpdate(n.target),s===this._updatesPosList.length&&e++}},i.isScheduled=function(t,e){lt(Boolean(t),1508),lt(Boolean(e),1509);var i=e.uuid||e.id;if(!i)return ht(1510),!1;var n=this._hashForTimers[i];if(!n)return!1;if(null==n.timers)return!1;for(var r=n.timers,s=0;s=t&&(r.paused=!0,s.push(r.target))}if(t<=0)for(i=0;i=t&&(r.paused=!0,s.push(r.target))}return s},i.resumeTargets=function(t){if(t)for(var e=0;e=4;){var a=255&s.call(t,r)|(255&s.call(t,++r))<<8|(255&s.call(t,++r))<<16|(255&s.call(t,++r))<<24;a=1540483477*(65535&a)+((1540483477*(a>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^(a=1540483477*(65535&(a^=a>>>24))+((1540483477*(a>>>16)&65535)<<16)),i-=4,++r}switch(i){case 3:n^=(255&s.call(t,r+2))<<16;case 2:n^=(255&s.call(t,r+1))<<8;case 1:n=1540483477*(65535&(n^=255&s.call(t,r)))+((1540483477*(n>>>16)&65535)<<16)}return n=1540483477*(65535&(n^=n>>>13))+((1540483477*(n>>>16)&65535)<<16),(n^=n>>>15)>>>0}function Xf(t,e,i){if(Me(t,e),Me(t,i),e===i)return t;var n=t[e];if(e0&&!(t&t-1)}var ap=Math.ceil;function op(t,e,i,n){if(!ip[t].isCompressed)return e*i*n*ip[t].size;switch(t){case 56:case 57:case 58:case 59:case 72:case 73:case 74:case 75:case 79:case 80:case 85:case 86:case 88:return ap(e/4)*ap(i/4)*8*n;case 60:case 61:case 62:case 63:case 64:case 65:case 69:case 68:case 70:case 71:case 77:case 76:case 81:case 82:case 89:case 103:return ap(e/4)*ap(i/4)*16*n;case 66:case 67:return ap(e/4)*ap(i/4)*32*n;case 83:case 84:case 87:return ap(e/8)*ap(i/4)*8*n;case 90:case 104:return ap(e/5)*ap(i/4)*16*n;case 91:case 105:return ap(e/5)*ap(i/5)*16*n;case 92:case 106:return ap(e/6)*ap(i/5)*16*n;case 93:case 107:return ap(e/6)*ap(i/6)*16*n;case 94:case 108:return ap(e/8)*ap(i/5)*16*n;case 95:case 109:return ap(e/8)*ap(i/6)*16*n;case 96:case 110:return ap(e/8)*ap(i/8)*16*n;case 97:case 111:return ap(e/10)*ap(i/5)*16*n;case 98:case 112:return ap(e/10)*ap(i/6)*16*n;case 99:case 113:return ap(e/10)*ap(i/8)*16*n;case 100:case 114:return ap(e/10)*ap(i/10)*16*n;case 101:case 115:return ap(e/12)*ap(i/10)*16*n;case 102:case 116:return ap(e/12)*ap(i/12)*16*n;default:return 0}}function hp(t,e,i,n,r){for(var s=0,a=0;a>1,1),i=Math.max(i>>1,1);return s}var up=[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 lp(t){return up[t]||0}function cp(t){if(t.isCompressed)return Uint8Array;var e=t.size/t.count;switch(t.type){case 1:case 3:switch(e){case 1:default:return Uint8Array;case 2:return Uint16Array;case 4:return Uint32Array}case 2:case 4:switch(e){case 1:default:return Int8Array;case 2:return Int16Array;case 4:return Int32Array}case 6:return 2===e?Uint16Array:Float32Array}return Float32Array}function fp(t){switch(t){case 56:case 57:case 58:case 59:case 60:case 61:case 62:case 63:case 64:case 65:case 69:case 68:case 70:case 71:case 66:case 67:case 72:case 73:case 74:case 75:case 79:case 80:case 77:case 76:case 81:case 82:case 85:case 86:case 88:case 89:case 103:return{width:4,height:4};case 83:case 84:case 87:return{width:8,height:4};case 90:case 104:return{width:5,height:4};case 91:case 105:return{width:5,height:5};case 92:case 106:return{width:6,height:5};case 93:case 107:return{width:6,height:6};case 94:case 108:return{width:8,height:5};case 95:case 109:return{width:8,height:6};case 96:case 110:return{width:8,height:8};case 97:case 111:return{width:10,height:5};case 98:case 112:return{width:10,height:6};case 99:case 113:return{width:10,height:8};case 100:case 114:return{width:10,height:10};case 101:case 115:return{width:12,height:10};case 102:case 116:return{width:12,height:12};default:return{width:1,height:1}}}function _p(t,e){return ap(t/e)*e}var dp=Object.freeze({__proto__:null,API:i_,AccessFlagBit:M_,Address:S_,Attribute:Cd,AttributeName:Zd,BarrierType:W_,BindingMappingInfo:ad,BlendFactor:T_,BlendOp:A_,BufferBarrierInfo:Ld,BufferFlagBit:l_,BufferInfo:ud,BufferTextureCopy:id,BufferUsageBit:u_,BufferViewInfo:ld,ClearFlagBit:H_,Color:rd,ColorAttachment:Id,ColorMask:C_,CommandBufferInfo:Wd,CommandBufferType:G_,ComparisonFunc:w_,CullMode:F_,DESCRIPTOR_BUFFER_TYPE:np,DESCRIPTOR_DYNAMIC_TYPE:10,DESCRIPTOR_SAMPLER_TYPE:rp,DESCRIPTOR_STORAGE_BUFFER_TYPE:12,DRAW_INFO_SIZE:28,DepthStencilAttachment:Md,DescriptorSetInfo:Ud,DescriptorSetLayoutBinding:Nd,DescriptorSetLayoutInfo:zd,DescriptorType:N_,DeviceCaps:X_,DeviceInfo:hd,DeviceOptions:Y_,DispatchInfo:fd,DrawInfo:cd,DynamicStateFlagBit:L_,DynamicStates:Kd,DynamicStencilStates:Jd,Extent:Q_,Feature:r_,Filter:b_,Format:s_,FormatFeatureBit:g_,FormatInfo:Xd,FormatInfos:ip,FormatSize:op,FormatSurfaceSize:hp,FormatType:a_,FramebufferInfo:Vd,GFXObject:Qd,GeneralBarrierInfo:Rd,GetTypeSize:lp,IndirectBuffer:_d,InputAssemblerInfo:Bd,InputState:Hd,IsPowerOf2:sp,LoadOp:B_,MarkerInfo:sd,MemoryAccessBit:c_,MemoryStatus:Yd,MemoryUsageBit:f_,ObjectType:t_,Offset:J_,PassType:j_,PipelineBindPoint:E_,PipelineLayoutInfo:Gd,PolygonMode:k_,PrimitiveMode:O_,QueryPoolInfo:qd,QueryType:U_,QueueInfo:jd,QueueType:z_,Rect:K_,RenderPassInfo:Od,ResolveMode:P_,ResourceRange:kd,SampleCount:y_,SampleType:o_,SamplerInfo:md,ShadeModel:R_,ShaderInfo:Dd,ShaderStage:Ad,ShaderStageFlagBit:D_,Size:q_,Status:e_,StencilFace:V_,StencilOp:x_,StoreOp:I_,SubpassDependency:Ed,SubpassInfo:Pd,SurfaceTransform:n_,SwapchainInfo:od,TextureBarrierInfo:Fd,TextureBlit:ed,TextureCopy:td,TextureFlagBit:m_,TextureInfo:dd,TextureSubresLayers:Z_,TextureSubresRange:$_,TextureType:__,TextureUsageBit:p_,TextureViewInfo:pd,Type:h_,Uniform:gd,UniformBlock:yd,UniformInputAttachment:Td,UniformSampler:bd,UniformSamplerTexture:vd,UniformStorageBuffer:xd,UniformStorageImage:wd,UniformTexture:Sd,ViewDimension:d_,Viewport:nd,VsyncMode:v_,alignTo:_p,formatAlignment:fp,getTypedArrayConstructor:cp}),pp=function(t){function e(){var e;return(e=t.call(this,2)||this)._usage=0,e._memUsage=0,e._size=0,e._stride=1,e._count=0,e._flags=0,e._isBufferView=!1,e}return s(e,t),n(e,[{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}}]),e}(Qd),mp=function(t){function e(){var e;return(e=t.call(this,13)||this)._queue=null,e._type=0,e._numDrawCalls=0,e._numInstances=0,e._numTris=0,e}return s(e,t),n(e,[{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}}]),e}(Qd),gp=function(){function t(){this._gfxAPI=0,this._renderer="",this._vendor="",this._features=new Array(10),this._formatFeatures=new Array(117),this._queue=null,this._cmdBuff=null,this._numDrawCalls=0,this._numInstances=0,this._numTris=0,this._memoryStatus=new Yd,this._caps=new X_,this._bindingMappingInfo=new ad,this._samplers=new Map,this._generalBarrierss=new Map,this._textureBarriers=new Map,this._bufferBarriers=new Map,this._swapchainFormat=35}var e=t.prototype;return e.hasFeature=function(t){return this._features[t]},e.getFormatFeatures=function(t){return this._formatFeatures[t]},e.enableAutoBarrier=function(){},e.getMaxSampleCount=function(){return 1},n(t,[{key:"gfxAPI",get:function(){return this._gfxAPI}},{key:"queue",get:function(){return this._queue}},{key:"commandBuffer",get:function(){return this._cmdBuff}},{key:"swapchainFormat",get:function(){return this._swapchainFormat}},{key:"renderer",get:function(){return this._renderer}},{key:"vendor",get:function(){return this._vendor}},{key:"numDrawCalls",get:function(){return this._numDrawCalls}},{key:"numInstances",get:function(){return this._numInstances}},{key:"numTris",get:function(){return this._numTris}},{key:"memoryStatus",get:function(){return this._memoryStatus}},{key:"capabilities",get:function(){return this._caps}},{key:"bindingMappingInfo",get:function(){return this._bindingMappingInfo}}]),t}();gp.canvas=void 0;var yp=function(){function t(t){this._texture2D=null,this._texture3D=null,this._textureCube=null,this._texture2DArray=null;var e=t.capabilities,i=new Uint8Array(64);if(i.fill(255),e.maxTextureSize>=2){this._texture2D=t.createTexture(new dd(1,12,35,2,2,0));var n=new id(0,0,0,new J_(0,0,0),new Q_(2,2,1));t.copyBuffersToTexture([i],this._texture2D,[n])}if(e.maxTextureSize>=2){this._textureCube=t.createTexture(new dd(3,12,35,2,2,0,6));var r=new id(0,0,0,new J_(0,0,0),new Q_(2,2,1));t.copyBuffersToTexture([i],this._textureCube,[r]),r.texSubres.baseArrayLayer=1,t.copyBuffersToTexture([i],this._textureCube,[r]),r.texSubres.baseArrayLayer=2,t.copyBuffersToTexture([i],this._textureCube,[r]),r.texSubres.baseArrayLayer=3,t.copyBuffersToTexture([i],this._textureCube,[r]),r.texSubres.baseArrayLayer=4,t.copyBuffersToTexture([i],this._textureCube,[r]),r.texSubres.baseArrayLayer=5,t.copyBuffersToTexture([i],this._textureCube,[r])}if(e.max3DTextureSize>=2){this._texture3D=t.createTexture(new dd(2,12,35,2,2,0,1,1,1,2));var s=new id(0,0,0,new J_(0,0,0),new Q_(2,2,2),new Z_(0,0,1));t.copyBuffersToTexture([i],this._texture3D,[s])}if(e.maxArrayTextureLayers>=2){this._texture2DArray=t.createTexture(new dd(5,12,35,2,2,0,2));var a=new id(0,0,0,new J_(0,0,0),new Q_(2,2,1),new Z_(0,0,1));t.copyBuffersToTexture([i],this._texture2DArray,[a]),a.texSubres.baseArrayLayer=1,t.copyBuffersToTexture([i],this._texture2DArray,[a])}}return t.prototype.getTexture=function(t){switch(t){case 1:return this._texture2D;case 2:return this._texture3D;case 3:return this._textureCube;case 5:return this._texture2DArray;default:return null}},t}(),vp=function(t){function e(){var e;return(e=t.call(this,1)||this)._transform=0,e._colorTexture=null,e._depthStencilTexture=null,e}return s(e,t),n(e,[{key:"colorTexture",get:function(){return this._colorTexture}},{key:"depthStencilTexture",get:function(){return this._depthStencilTexture}},{key:"surfaceTransform",get:function(){return this._transform}},{key:"width",get:function(){return this._colorTexture.width}},{key:"height",get:function(){return this._colorTexture.height}}]),e}(Qd),bp=function(t){function e(){var e;return(e=t.call(this,5)||this)._renderPass=null,e._colorTextures=[],e._depthStencilTexture=null,e._width=0,e._height=0,e}return s(e,t),n(e,[{key:"renderPass",get:function(){return this._renderPass}},{key:"colorTextures",get:function(){return this._colorTextures}},{key:"depthStencilTexture",get:function(){return this._depthStencilTexture}},{key:"width",get:function(){var t,e;return this.colorTextures.length>0?null!==(t=null==(e=this.colorTextures[0])?void 0:e.width)&&void 0!==t?t:this._width:this.depthStencilTexture?this.depthStencilTexture.width:this._width}},{key:"height",get:function(){var t,e;return this.colorTextures.length>0?null!==(t=null==(e=this.colorTextures[0])?void 0:e.height)&&void 0!==t?t:this._height:this.depthStencilTexture?this.depthStencilTexture.height:this._height}},{key:"needRebuild",get:function(){return!1}}]),e}(Qd),Sp=function(t){function e(){var e;return(e=t.call(this,12)||this)._attributes=[],e._attributesHash=0,e._vertexBuffers=[],e._indexBuffer=null,e._indirectBuffer=null,e._drawInfo=new cd,e}s(e,t);var i=e.prototype;return i.getVertexBuffer=function(t){return void 0===t&&(t=0),t=0){var o=this._colorInfos[i.depthStencil];t+="ds,"+o.format+","+o.sampleCount}}else{t+="ca";for(var h=0;h>2&3,e.mipFilter=t>>4&3,e.addressU=t>>6&3,e.addressV=t>>8&3,e.addressW=t>>10&3,e.maxAnisotropy=t>>12&31,e.cmpFunc=t>>17&7,e},n(e,[{key:"info",get:function(){return this._info}},{key:"hash",get:function(){return this._hash}}]),e}(Qd),kp=function(t){function e(){var e;return(e=t.call(this,7)||this)._name="",e._stages=[],e._attributes=[],e._blocks=[],e._samplers=[],e}return s(e,t),n(e,[{key:"name",get:function(){return this._name}},{key:"attributes",get:function(){return this._attributes}},{key:"blocks",get:function(){return this._blocks}},{key:"samplers",get:function(){return this._samplers}},{key:"stages",get:function(){return this._stages}}]),e}(Qd),Rp=function(t){function e(){var e;return(e=t.call(this,3)||this)._info=new dd,e._viewInfo=new pd,e._isPowerOf2=!1,e._isTextureView=!1,e._size=0,e}return s(e,t),e.getLevelCount=function(t,e){return Math.floor(Math.log2(Math.max(t,e)))},n(e,[{key:"type",get:function(){return this._info.type}},{key:"usage",get:function(){return this._info.usage}},{key:"format",get:function(){return this._info.format}},{key:"width",get:function(){return this._info.width}},{key:"height",get:function(){return this._info.height}},{key:"depth",get:function(){return this._info.depth}},{key:"layerCount",get:function(){return this._info.layerCount}},{key:"levelCount",get:function(){return this._info.levelCount}},{key:"samples",get:function(){return this._info.samples}},{key:"flags",get:function(){return this._info.flags}},{key:"size",get:function(){return this._size}},{key:"info",get:function(){return this._info}},{key:"viewInfo",get:function(){return this._viewInfo}},{key:"isTextureView",get:function(){return this._isTextureView}}]),e}(Qd),Fp=function(t){function e(e,i){var n;return(n=t.call(this,16)||this)._info=new Rd,n._hash=0,n._info.copy(e),n._hash=i,n}return s(e,t),e.computeHash=function(t){return qf(t.prevAccesses+" "+t.nextAccesses+" "+t.type,666)},n(e,[{key:"info",get:function(){return this._info}},{key:"hash",get:function(){return this._hash}}]),e}(Qd),Lp=function(t){function e(e,i){var n;return(n=t.call(this,17)||this)._info=new Fd,n._hash=0,n._info.copy(e),n._hash=i,n}return s(e,t),e.computeHash=function(t){var e=t.prevAccesses+" "+t.nextAccesses;return e+=t.type,e+=t.range.mipLevel,e+=t.range.levelCount,e+=t.range.firstSlice,e+=t.range.numSlices,e+=t.range.basePlane,e+=t.range.planeCount,e+=t.discardContents,e+=t.srcQueue?t.srcQueue.type:0,qf(e+=t.dstQueue?t.dstQueue.type:0,666)},n(e,[{key:"info",get:function(){return this._info}},{key:"hash",get:function(){return this._hash}}]),e}(Qd),Vp=function(t){function e(e,i){var n;return(n=t.call(this,18)||this)._info=new Ld,n._hash=0,n._info.copy(e),n._hash=i,n}return s(e,t),e.computeHash=function(t){var e=t.prevAccesses+" "+t.nextAccesses;return e+=t.type,e+=t.offset,e+=t.size,e+=t.discardContents,e+=t.srcQueue?t.srcQueue.type:0,qf(e+=t.dstQueue?t.dstQueue.type:0,666)},n(e,[{key:"info",get:function(){return this._info}},{key:"hash",get:function(){return this._hash}}]),e}(Qd),Np={Device:gp,Swapchain:vp,Buffer:pp,Texture:Rp,Sampler:Op,Shader:kp,InputAssembler:Sp,RenderPass:Ep,Framebuffer:bp,DescriptorSet:wp,DescriptorSetLayout:xp,PipelineLayout:Tp,PipelineState:Mp,CommandBuffer:mp,Queue:Pp,GeneralBarrier:Fp,TextureBarrier:Lp,BufferBarrier:Vp,RasterizerState:Ap,BlendState:Bp,BlendTarget:Dp,DepthStencilState:Cp,PipelineStateInfo:Ip};Object.assign(Np,dp),A.gfx=Np;var zp={GFXDevice:!0,GFXBuffer:!0,GFXTexture:!0,GFXSampler:!0,GFXShader:!0,GFXInputAssembler:!0,GFXRenderPass:!0,GFXFramebuffer:!0,GFXPipelineState:!0,GFXCommandBuffer:!0,GFXQueue:!0,GFXObjectType:!0,GFXObject:!1,GFXAttributeName:!0,GFXType:!0,GFXFormat:!0,GFXBufferUsageBit:!0,GFXMemoryUsageBit:!0,GFXBufferFlagBit:!0,GFXBufferAccessBit:"MemoryAccessBit",GFXPrimitiveMode:!0,GFXPolygonMode:!0,GFXShadeModel:!0,GFXCullMode:!0,GFXComparisonFunc:!0,GFXStencilOp:!0,GFXBlendOp:!0,GFXBlendFactor:!0,GFXColorMask:!0,GFXFilter:!0,GFXAddress:!0,GFXTextureType:!0,GFXTextureUsageBit:!0,GFXSampleCount:!0,GFXTextureFlagBit:!0,GFXShaderStageFlagBit:!0,GFXDescriptorType:!0,GFXCommandBufferType:!0,GFXLoadOp:!0,GFXStoreOp:!0,GFXPipelineBindPoint:!0,GFXDynamicStateFlagBit:!0,GFXStencilFace:!0,GFXQueueType:!0,GFXRect:!0,GFXViewport:!0,GFXColor:!0,GFXClearFlag:!0,GFXOffset:!0,GFXExtent:!0,GFXTextureSubres:"TextureSubresLayers",GFXTextureCopy:!0,GFXBufferTextureCopy:!0,GFXFormatType:!0,GFXFormatInfo:!0,GFXMemoryStatus:!0,GFXFormatInfos:!0,GFXFormatSize:!0,GFXFormatSurfaceSize:!0,GFXGetTypeSize:!0,getTypedArrayConstructor:!1};for(var Up in zp){var Gp=zp[Up];!0===Gp?Gp=Up.slice(3):!1===Gp&&(Gp=Up),pt(A,"cc",[{name:Up,newName:Gp,target:A.gfx,targetName:"cc.gfx"}])}mt(A,"cc",[{name:"GFX_MAX_VERTEX_ATTRIBUTES"},{name:"GFX_MAX_TEXTURE_UNITS"},{name:"GFX_MAX_ATTACHMENTS"},{name:"GFX_MAX_BUFFER_BINDINGS"},{name:"GFXTextureLayout"}]),mt(r_,"Feature",[{name:"COLOR_FLOAT",suggest:"Please use device.getFormatFeatures() instead, like: \nlet isSupported = device.getFormatFeatures(Format.R32F) & FormatFeatureBit.RENDER_TARGET;"},{name:"COLOR_HALF_FLOAT",suggest:"Please use device.getFormatFeatures() instead, like: \nlet isSupported = device.getFormatFeatures(Format.R16F) & FormatFeatureBit.RENDER_TARGET;"},{name:"TEXTURE_FLOAT",suggest:"Please use device.getFormatFeatures() instead, like: \nlet isSupported = (device.getFormatFeatures(Format.R32F) & (FormatFeatureBit.RENDER_TARGET | FormatFeatureBit.SAMPLED_TEXTURE)) === (FormatFeatureBit.RENDER_TARGET | FormatFeatureBit.SAMPLED_TEXTURE);"},{name:"TEXTURE_HALF_FLOAT",suggest:"Please use device.getFormatFeatures() instead, like: \nlet isSupported = (device.getFormatFeatures(Format.R16F) & (FormatFeatureBit.RENDER_TARGET | FormatFeatureBit.SAMPLED_TEXTURE)) === (FormatFeatureBit.RENDER_TARGET | FormatFeatureBit.SAMPLED_TEXTURE);"},{name:"TEXTURE_FLOAT_LINEAR",suggest:"Please use device.getFormatFeatures() instead, like: \nlet isSupported = device.getFormatFeatures(Format.R32F) & FormatFeatureBit.LINEAR_FILTER;"},{name:"TEXTURE_HALF_FLOAT_LINEAR",suggest:"Please use device.getFormatFeatures() instead, like: \nlet isSupported = device.getFormatFeatures(Format.R16F) & FormatFeatureBit.LINEAR_FILTER;"},{name:"FORMAT_R11G11B10F",suggest:"Please use device.getFormatFeatures() instead, like: \nlet isSupported = device.getFormatFeatures(Format.R11G11B10F) !== FormatFeatureBit.NONE;"},{name:"FORMAT_SRGB",suggest:"Please use device.getFormatFeatures() instead, like: \nlet isSupported = device.getFormatFeatures(Format.SRGB8) !== FormatFeatureBit.NONE;"},{name:"FORMAT_ETC1",suggest:"Please use device.getFormatFeatures() instead, like: \nlet isSupported = device.getFormatFeatures(Format.ETC_RGB8) !== FormatFeatureBit.NONE;"},{name:"FORMAT_ETC2",suggest:"Please use device.getFormatFeatures() instead, like: \nlet isSupported = device.getFormatFeatures(Format.ETC2_RGB8) !== FormatFeatureBit.NONE;"},{name:"FORMAT_DXT",suggest:"Please use device.getFormatFeatures() instead, like: \nlet isSupported = device.getFormatFeatures(Format.BC1) !== FormatFeatureBit.NONE;"},{name:"FORMAT_PVRTC",suggest:"Please use device.getFormatFeatures() instead, like: \nlet isSupported = device.getFormatFeatures(Format.PVRTC_RGB2) !== FormatFeatureBit.NONE;"},{name:"FORMAT_ASTC",suggest:"Please use device.getFormatFeatures() instead, like: \nlet isSupported = device.getFormatFeatures(Format.ASTC_RGBA_4x4) !== FormatFeatureBit.NONE;"},{name:"FORMAT_RGB8",suggest:"Please use device.getFormatFeatures() instead, like: \nlet isSupported = device.getFormatFeatures(Format.RGB8) !== FormatFeatureBit.NONE;"}]),mt(Id.prototype,"ColorAttachment",[{name:"beginAccesses",suggest:"Please assign to ColorAttachment.barrier instead"},{name:"endAccesses",suggest:"Please assign to ColorAttachment.barrier instead"}]),mt(Md.prototype,"DepthStencilAttachment",[{name:"beginAccesses",suggest:"Please assign to DepthStencilAttachment.barrier instead"},{name:"endAccesses",suggest:"Please assign to DepthStencilAttachment.barrier instead"}]),pt(gp.prototype,"Device",[{name:"getGlobalBarrier",newName:"getGeneralBarrier"}]);var Hp=function(){function t(){this.initialized=!1,this._gfxDevice=void 0,this._canvas=null,this._swapchain=void 0,this._renderType=-1,this._deviceInitialized=!1}var e=t.prototype;return e._tryInitializeWebGPUDevice=function(t,e){var i=this;return this._deviceInitialized?Promise.resolve(!0):t?(this._gfxDevice=new t,new Promise((function(t,n){i._gfxDevice.initialize(e).then((function(e){i._deviceInitialized=e,t(e)})).catch((function(t){n(t)}))}))):Promise.resolve(!1)},e._tryInitializeDeviceSync=function(t,e){return!!this._deviceInitialized||(t&&(this._gfxDevice=new t,this._deviceInitialized=this._gfxDevice.initialize(e)),this._deviceInitialized)},e.init=function(t,e){var i=this;if(this.initialized)return!0;var n=ze.querySettings(Ve.Category.RENDERING,"renderMode");this._canvas=t,this._canvas&&(this._canvas.oncontextmenu=function(){return!1}),this._renderType=this._determineRenderType(n),this._deviceInitialized=!1;var r=new hd(e);if(1===this._renderType||2===this._renderType){var s=!!globalThis.WebGL2RenderingContext;if(globalThis.navigator.userAgent.toLowerCase(),hh.browserType===Mo.UC&&(s=!1),gp.canvas=t,2===this._renderType&&A.WebGPUDevice)return new Promise((function(t,e){i._tryInitializeWebGPUDevice(A.WebGPUDevice,r).then((function(e){i._initSwapchain(),t(e)})).catch((function(t){e(t)}))}));s&&A.WebGL2Device&&this._tryInitializeDeviceSync(A.WebGL2Device,r),A.WebGLDevice&&this._tryInitializeDeviceSync(A.WebGLDevice,r),A.EmptyDevice&&this._tryInitializeDeviceSync(A.EmptyDevice,r),this._initSwapchain()}else 4===this._renderType&&A.EmptyDevice&&(this._tryInitializeDeviceSync(A.EmptyDevice,r),this._initSwapchain());return!!this._gfxDevice||(ht(16337),this._renderType=-1,!1)},e._initSwapchain=function(){var t=new od(1,this._canvas),e=oh.windowSize;t.width=e.width,t.height=e.height,this._swapchain=this._gfxDevice.createSwapchain(t)},e._supportWebGPU=function(){return"gpu"in globalThis.navigator},e._determineRenderType=function(t){("number"!=typeof t||t>4||t<0)&&(t=0);var e=0,i=!1;if(1===t?(e=0,i=!0):0===t||4===t?(e=this._supportWebGPU()?2:1,i=!0):2===t?(e=1,i=!0):3===t&&(e=4,i=!0),!i)throw new Error(ft(3820,t));return e},n(t,[{key:"gfxDevice",get:function(){return this._gfxDevice}},{key:"swapchain",get:function(){return this._swapchain}}]),t}(),Wp=new Hp;t("aH",Object.freeze({__proto__:null,API:i_,AccessFlagBit:M_,Address:S_,Attribute:Cd,AttributeName:Zd,BarrierType:W_,BindingMappingInfo:ad,BlendFactor:T_,BlendOp:A_,BlendState:Bp,BlendTarget:Dp,Buffer:pp,BufferBarrierInfo:Ld,BufferFlagBit:l_,BufferInfo:ud,BufferTextureCopy:id,BufferUsageBit:u_,BufferViewInfo:ld,ClearFlagBit:H_,Color:rd,ColorAttachment:Id,ColorMask:C_,CommandBuffer:mp,CommandBufferInfo:Wd,CommandBufferType:G_,ComparisonFunc:w_,CullMode:F_,DESCRIPTOR_BUFFER_TYPE:np,DESCRIPTOR_DYNAMIC_TYPE:10,DESCRIPTOR_SAMPLER_TYPE:rp,DESCRIPTOR_STORAGE_BUFFER_TYPE:12,DRAW_INFO_SIZE:28,DefaultResource:yp,DepthStencilAttachment:Md,DepthStencilState:Cp,DescriptorSet:wp,DescriptorSetInfo:Ud,DescriptorSetLayout:xp,DescriptorSetLayoutBinding:Nd,DescriptorSetLayoutInfo:zd,DescriptorType:N_,Device:gp,DeviceCaps:X_,DeviceInfo:hd,DeviceManager:Hp,DeviceOptions:Y_,DispatchInfo:fd,DrawInfo:cd,DynamicStateFlagBit:L_,DynamicStates:Kd,DynamicStencilStates:Jd,Extent:Q_,Feature:r_,Filter:b_,Format:s_,FormatFeatureBit:g_,FormatInfo:Xd,FormatInfos:ip,FormatSize:op,FormatSurfaceSize:hp,FormatType:a_,Framebuffer:bp,FramebufferInfo:Vd,GFXObject:Qd,GeneralBarrier:Fp,GeneralBarrierInfo:Rd,GetTypeSize:lp,IndirectBuffer:_d,InputAssembler:Sp,InputAssemblerInfo:Bd,InputState:Hd,IsPowerOf2:sp,LegacyRenderMode:{AUTO:0,CANVAS:1,WEBGL:2,HEADLESS:3,WEBGPU:4},LoadOp:B_,MarkerInfo:sd,MemoryAccessBit:c_,MemoryStatus:Yd,MemoryUsageBit:f_,ObjectType:t_,Offset:J_,PassType:j_,PipelineBindPoint:E_,PipelineLayout:Tp,PipelineLayoutInfo:Gd,PipelineState:Mp,PipelineStateInfo:Ip,PolygonMode:k_,PrimitiveMode:O_,QueryPoolInfo:qd,QueryType:U_,Queue:Pp,QueueInfo:jd,QueueType:z_,RasterizerState:Ap,Rect:K_,RenderPass:Ep,RenderPassInfo:Od,RenderType:{UNKNOWN:-1,CANVAS:0,WEBGL:1,WEBGPU:2,OPENGL:3,HEADLESS:4},ResolveMode:P_,ResourceRange:kd,SampleCount:y_,SampleType:o_,Sampler:Op,SamplerInfo:md,ShadeModel:R_,Shader:kp,ShaderInfo:Dd,ShaderStage:Ad,ShaderStageFlagBit:D_,Size:q_,Status:e_,StencilFace:V_,StencilOp:x_,StoreOp:I_,SubpassDependency:Ed,SubpassInfo:Pd,SurfaceTransform:n_,Swapchain:vp,SwapchainInfo:od,Texture:Rp,TextureBarrier:Lp,TextureBarrierInfo:Fd,TextureBlit:ed,TextureCopy:td,TextureFlagBit:m_,TextureInfo:dd,TextureSubresLayers:Z_,TextureSubresRange:$_,TextureType:__,TextureUsageBit:p_,TextureViewInfo:pd,Type:h_,Uniform:gd,UniformBlock:yd,UniformInputAttachment:Td,UniformSampler:bd,UniformSamplerTexture:vd,UniformStorageBuffer:xd,UniformStorageImage:wd,UniformTexture:Sd,ViewDimension:d_,Viewport:nd,VsyncMode:v_,alignTo:_p,deviceManager:Wp,formatAlignment:fp,getTypedArrayConstructor:cp}));var jp=new Vn;function qp(t,e,i,n){var r=i.chunk,s=i.data,a=r.vb,o=i.vertexCount,h=t.worldMatrix,u=h.m00,l=h.m01,c=h.m02,f=h.m03,_=h.m04,d=h.m05,p=h.m06,m=h.m07,g=h.m12,y=h.m13,v=h.m14,b=h.m15;jp.set(n.r/255,n.g/255,n.b/255,n.a/255);for(var S=0,w=0;w>>0;else if(n.size/n.count==4)for(var c=o+3;c>2}}var Yp=function(){function t(t){this._map=null,this._count=0,t?(this._map=t,this._count=Object.keys(t).length):(this._map=Gt(!0),this._count=0)}var e=t.prototype;return e.add=function(t,e){return t in this._map||this._count++,this._map[t]=e},e.get=function(t){return this._map[t]},e.has=function(t){return t in this._map},e.remove=function(t){var e=this._map[t];return t in this._map&&(delete this._map[t],this._count--),e},e.clear=function(){0!==this._count&&(this._map=Gt(!0),this._count=0)},e.forEach=function(t){for(var e in this._map)t(this._map[e],e)},e.find=function(t){for(var e in this._map)if(t(this._map[e],e))return this._map[e];return null},e.destroy=function(){this._map=null},n(t,[{key:"map",get:function(){return this._map}},{key:"count",get:function(){return this._count}}]),t}(),Jp=function(){function t(e,i){this.id=t._pipelineId++,this.name="",this.pipes=[],this.name=e;for(var n=0,r=i.length;nthis.pipes.length?(at(4921),this):(this.pipes.splice(e,0,t),this)},e.append=function(t){return this.pipes.push(t),this},e.remove=function(t){return this.pipes.splice(t,1),this},e.sync=function(t){var e=this.pipes;if(0===e.length)return null;t.isFinished=!1;for(var i=0,n=e.length;i>2],hm[um[n++]]=am[(3&r)<<2|s>>4],hm[um[n++]]=am[15&s]}return t.replace(e,hm.join(""))}var cm=/.*[/\\][0-9a-fA-F]{2}[/\\]([0-9a-fA-F-@]{8,}).*/;function fm(t){var e=cm.exec(t);return e?e[1]:""}function _m(t,e){(e=e||Object.create(null)).__isNative__=e.isNative,e.nativeExt&&(e.ext=e.nativeExt);var i=$p.find((function(e){return!!e.getAssetInfo(t)}));return i&&(e.bundle=i.name),mm(t,e)}function dm(t){return!!t&&(t instanceof A.SceneAsset||t instanceof A.Scene)}function pm(t){return t&&(46===t.charCodeAt(0)&&47===t.charCodeAt(1)?t=t.slice(2):47===t.charCodeAt(0)&&(t=t.slice(1))),t}function mm(t,e){var i=sm.create({input:t,options:e}),n=[];try{for(var r,s=p(im.sync(i));!(r=s()).done;){var a=r.value,o=a.url;a.recycle(),n.push(o)}}catch(t){for(var h,u=p(i.output);!(h=u()).done;)h.value.recycle();J(t.message,t.stack)}return i.recycle(),n.length>1?n:n[0]}var gm,ym,vm,bm,Sm,wm,xm=Object.freeze({__proto__:null,decodeUuid:lm,getUrlWithUuid:_m,getUuidFromURL:fm,isScene:dm,normalize:pm,transform:mm}),Tm=uu,Am=tu,Cm=t("d_",Kh("cc.Asset")((ym=function(t){function e(e){var i;return(i=t.call(this,e)||this).loaded=!0,i._native=vm&&vm(),i._nativeUrl="",i._file=null,i._ref=0,Object.defineProperty(f(i),"_uuid",{value:"",writable:!0}),i}s(e,t),e.deserialize=function(t){return A.deserialize(t)};var i=e.prototype;return i.toString=function(){return this.nativeUrl},i.serialize=function(){},i._setRawAsset=function(t,e){void 0===e&&(e=!0),this._native=!1!==e?t||"":"/"+t},i.addRef=function(){return this._ref++,this},i.decRef=function(t){return void 0===t&&(t=!0),this._ref>0&&this._ref--,t&&A.assetManager.getReleaseManager().tryRelease(this),this},i.onLoaded=function(){},i.initDefault=function(t){t&&(this._uuid=t),this.isDefault=!0},i.validate=function(){return!0},i.destroy=function(){return Q(ft(12101,this._uuid)),t.prototype.destroy.call(this)},n(e,[{key:"nativeUrl",get:function(){if(!this._nativeUrl){if(!this._native)return"";var t=this._native;if(47===t.charCodeAt(0))return t.slice(1);46===t.charCodeAt(0)?this._nativeUrl=_m(this._uuid,{nativeExt:t,isNative:!0}):this._nativeUrl=_m(this._uuid,{__nativeName__:t,nativeExt:Ho(t),isNative:!0})}return this._nativeUrl}},{key:"uuid",get:function(){return this._uuid}},{key:"_nativeAsset",get:function(){return this._file},set:function(t){this._file=t}},{key:"nativeAsset",get:function(){return this._file}},{key:"_nativeDep",get:function(){if(this._native)return{__isNative__:!0,uuid:this._uuid,ext:this._native}}},{key:"refCount",get:function(){return this._ref}}]),e}(Bo(mo)),vm=zh(ym.prototype,"_native",[Tm],(function(){return""})),v(ym.prototype,"_nativeAsset",[Am],Object.getOwnPropertyDescriptor(ym.prototype,"_nativeAsset"),ym.prototype),gm=ym))||gm);Cm.prototype.createNode=null,A.Asset=Cm;var Dm=1346981187,Bm=Ee({PVR:0,PKM:1,ASTC:2});function Im(t,e){return 4===t?89:5===t?4===e?90:91:6===t?5===e?92:93:8===t?5===e?94:6===e?95:96:10===t?5===e?97:6===e?98:8===e?99:100:10===e?101:102}function Mm(t,e){return t[e]<<8|t[e+1]}function Pm(t){return!!(hh.hasFeature(hh.Feature.IMAGE_BITMAP)&&t instanceof ImageBitmap)}var Em,Om,km,Rm,Fm,Lm,Vm,Nm,zm,Um,Gm,Hm=t("e4",Kh("cc.ImageAsset")((wm=function(t){s(i,t),i.mergeCompressedTextureMips=function(t){var e=new Uint8Array(0);try{for(var i,n=8+4*t.length,r=0,s=p(t);!(i=s()).done;)r+=i.value.byteLength;r+=n,e=new Uint8Array(r);var a=new DataView(e.buffer,e.byteOffset,e.byteLength);a.setUint32(0,Dm,!0),a.setUint32(4,t.length,!0);for(var o=n,h=0;h0){var u=new Uint8Array(s,o,h),l=new Uint8Array(r._data.byteLength+u.byteLength);l.set(r._data),l.set(u,r._data.byteLength),r._data=l,r.mipmapLevelDataSize[e]=h}else r._data=new Uint8Array(s,o);r.width=e>0?r.width:a[7],r.height=e>0?r.height:a[6]}else{if(559044176!==a[11])throw new Error("Invalid magic number in PVR header");var c=i+a[0],f=n-a.byteLength;if(n>0){var _=new Uint8Array(s,c,f),d=new Uint8Array(r._data.byteLength+_.byteLength);d.set(r._data),d.set(_,r._data.byteLength),r._data=d,r.mipmapLevelDataSize[e]=f}else r._data=new Uint8Array(s,c);r.width=e>0?r.width:a[1],r.height=e>0?r.height:a[2]}},i.parsePKMTexture=function(t,e,i,n,r){var s=t instanceof ArrayBuffer?t:t.buffer,a=new Uint8Array(s,i,16),o=Mm(a,6);if(0!==o&&1!==o&&3!==o)throw new Error("Invalid magic number in ETC header");var h=i+16,u=n-16;if(n>0){var l=new Uint8Array(s,h,u),c=new Uint8Array(r._data.byteLength+l.byteLength);c.set(r._data),c.set(l,r._data.byteLength),r._data=c,r.mipmapLevelDataSize[e]=u}else r._data=new Uint8Array(s,h);r.width=e>0?r.width:Mm(a,12),r.height=e>0?r.height:Mm(a,14)},i.parseASTCTexture=function(t,e,i,n,r){var s=t instanceof ArrayBuffer?t:t.buffer,a=new Uint8Array(s,i,16);if(1554098963!==a[0]+(a[1]<<8)+(a[2]<<16)+(a[3]<<24))throw new Error("Invalid magic number in ASTC header");var o=a[4],h=a[5],u=a[6];if((o<3||o>6||h<3||h>6||u<3||u>6)&&(o<4||7===o||9===o||11===o||o>12||h<4||7===h||9===h||11===h||h>12||1!==u))throw new Error("Invalid block number in ASTC header");var l=Im(o,h),c=i+16,f=n-16;if(n>0){var _=new Uint8Array(s,c,f),d=new Uint8Array(r._data.byteLength+_.byteLength);d.set(r._data),d.set(_,r._data.byteLength),r._data=d,r.mipmapLevelDataSize[e]=f}else r._data=new Uint8Array(s,c);r.width=e>0?r.width:a[7]+(a[8]<<8)+(a[9]<<16),r.height=e>0?r.height:a[10]+(a[11]<<8)+(a[12]<<16),r.format=l};var e=i.prototype;function i(e){var i;return(i=t.call(this)||this)._nativeData=void 0,i._exportedExts=void 0,i._format=35,i._width=0,i._height=0,i._nativeData={_data:null,width:0,height:0,format:0,_compressed:!1,mipmapLevelDataSize:[]},void 0!==e&&i.reset(e),i}return e.extractMipmap0=function(){if(this.mipmapLevelDataSize&&this.mipmapLevelDataSize.length>0){var t=this.mipmapLevelDataSize[0],e=this.data,n=new i({_data:new Uint8Array(e.buffer,0,t),_compressed:!0,width:this.width,height:this.height,format:this.format,mipmapLevelDataSize:[]});return n._uuid=""+this._uuid,n}return this},e.extractMipmaps=function(){var t=[];if(this.mipmapLevelDataSize&&this.mipmapLevelDataSize.length>0)for(var e,n=this.mipmapLevelDataSize,r=this.data,s=0,a=this.height,o=this.width,h=p(n);!(e=h()).done;){var u=e.value,l=new i({_data:new Uint8Array(r.buffer,s,u),_compressed:!0,width:o,height:a,format:this.format,mipmapLevelDataSize:[]});s+=u,l._uuid=""+this._uuid,o=Math.max(o>>1,1),a=Math.max(a>>1,1),t.push(l)}else t.push(this);return t},e.reset=function(t){Pm(t)||t instanceof HTMLElement?this._nativeData=t:(this._nativeData=t,this._format=t.format)},e.destroy=function(){if(this.data&&this.data instanceof HTMLImageElement)this.data.src="",this._setRawAsset("");else if(Pm(this.data)){var e;null==(e=this.data)||e.close()}return t.prototype.destroy.call(this)},e._serialize=function(){},e._deserialize=function(t){var e="";"string"==typeof t?e=t:(this._width=t.w,this._height=t.h,e=t.fmt);for(var n,r=Wp.gfxDevice,s=e.split("_"),a=Number.MAX_VALUE,o=this._format,h="",u=Ue.SUPPORT_TEXTURE_FORMATS,l=p(s);!(n=l()).done;){var c=n.value.split("@"),f=parseInt(c[0],void 0),_=i.extnames[f]||c[0],d=u.indexOf(_);if(-1!==d&&d=72&&this._format<=102||this._format>=1024&&this._format<=1026}},{key:"mipmapLevelDataSize",get:function(){return this._nativeData.mipmapLevelDataSize}},{key:"url",get:function(){return this.nativeUrl}}]),i}(Cm),wm.extnames=[".png",".jpg",".jpeg",".bmp",".webp",".pvr",".pkm",".astc"],wm._sharedPlaceHolderCanvas=null,v((Sm=wm).prototype,"_nativeAsset",[Gu],Object.getOwnPropertyDescriptor(Sm.prototype,"_nativeAsset"),Sm.prototype),bm=Sm))||bm);A.ImageAsset=Hm,Re(s_);var Wm,jm,qm,Xm=new It("Tex"),Ym=Kh("cc.TextureBase")((Gm=function(t){function e(e){var i;return(i=t.call(this,e)||this)._format=km&&km(),i._minFilter=Rm&&Rm(),i._magFilter=Fm&&Fm(),i._mipFilter=Lm&&Lm(),i._wrapS=Vm&&Vm(),i._wrapT=Nm&&Nm(),i._wrapR=zm&&zm(),i._anisotropy=Um&&Um(),i._width=1,i._height=1,i._samplerInfo=new md,i._gfxSampler=null,i._gfxDevice=null,i._textureHash=0,i._id=Xm.getNewId(),i._gfxDevice=i._getGFXDevice(),i._textureHash=qf(i._id,666),i}s(e,t);var i=e.prototype;return i.getId=function(){return this._id},i.getPixelFormat=function(){return this._format},i.getAnisotropy=function(){return this._anisotropy},i.setWrapMode=function(t,e,i){void 0===i&&(i=t),this._wrapS=t,this._samplerInfo.addressU=t,this._wrapT=e,this._samplerInfo.addressV=e,this._wrapR=i,this._samplerInfo.addressW=i,this._gfxDevice&&(this._gfxSampler=this._gfxDevice.getSampler(this._samplerInfo))},i.setFilters=function(t,e){this._minFilter=t,this._samplerInfo.minFilter=t,this._magFilter=e,this._samplerInfo.magFilter=e,this._gfxDevice&&(this._gfxSampler=this._gfxDevice.getSampler(this._samplerInfo))},i.setMipFilter=function(t){this._mipFilter=t,this._samplerInfo.mipFilter=t,this._gfxDevice&&(this._gfxSampler=this._gfxDevice.getSampler(this._samplerInfo))},i.setAnisotropy=function(t){t=Math.min(t,16),this._anisotropy=t,this._samplerInfo.maxAnisotropy=t,this._gfxDevice&&(this._gfxSampler=this._gfxDevice.getSampler(this._samplerInfo))},i.destroy=function(){var e,i=t.prototype.destroy.call(this);return i&&null!=(e=A.director.root)&&e.batcher2D&&A.director.root.batcher2D._releaseDescriptorSetCache(this._textureHash),i},i.getHash=function(){return this._textureHash},i.getGFXTexture=function(){return null},i.getSamplerInfo=function(){return this._samplerInfo},i.getGFXSampler=function(){return this._gfxSampler||(this._gfxDevice?this._gfxSampler=this._gfxDevice.getSampler(this._samplerInfo):ht(9302)),this._gfxSampler},i._serialize=function(){return""},i._deserialize=function(t){var e=t.split(",");e.unshift(""),e.length>=5&&(this.setFilters(parseInt(e[1]),parseInt(e[2])),this.setWrapMode(parseInt(e[3]),parseInt(e[4]))),e.length>=7&&(this.setMipFilter(parseInt(e[5])),this.setAnisotropy(parseInt(e[6])))},i._getGFXDevice=function(){return Wp.gfxDevice},i._getGFXFormat=function(){return this._getGFXPixelFormat(this._format)},i._setGFXFormat=function(t){this._format=void 0===t?35:t},i._getGFXPixelFormat=function(t){return 1026===t?t=72:1025===t?t=85:1024===t&&(t=83),t},n(e,[{key:"isCompressed",get:function(){return this._format>=72&&this._format<=102||this._format>=1024&&this._format<=1026}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}}]),e}(Cm),Gm.PixelFormat={RGB565:47,RGB5A1:49,RGBA4444:50,RGB888:24,RGB32F:32,RGBA8888:35,BGRA8888:36,RGBA32F:44,A8:1,I8:2,AI8:3,RGB_PVRTC_2BPPV1:83,RGBA_PVRTC_2BPPV1:84,RGB_A_PVRTC_2BPPV1:1024,RGB_PVRTC_4BPPV1:85,RGBA_PVRTC_4BPPV1:86,RGB_A_PVRTC_4BPPV1:1025,RGB_ETC1:72,RGBA_ETC1:1026,RGB_ETC2:73,RGBA_ETC2:77,RGBA_ASTC_4x4:89,RGBA_ASTC_5x4:90,RGBA_ASTC_5x5:91,RGBA_ASTC_6x5:92,RGBA_ASTC_6x6:93,RGBA_ASTC_8x5:94,RGBA_ASTC_8x6:95,RGBA_ASTC_8x8:96,RGBA_ASTC_10x5:97,RGBA_ASTC_10x6:98,RGBA_ASTC_10x8:99,RGBA_ASTC_10x10:100,RGBA_ASTC_12x10:101,RGBA_ASTC_12x12:102},Gm.WrapMode={REPEAT:0,CLAMP_TO_EDGE:2,MIRRORED_REPEAT:1,CLAMP_TO_BORDER:3},Gm.Filter={NONE:0,LINEAR:2,NEAREST:1},km=zh((Om=Gm).prototype,"_format",[uu],(function(){return 35})),Rm=zh(Om.prototype,"_minFilter",[uu],(function(){return 2})),Fm=zh(Om.prototype,"_magFilter",[uu],(function(){return 2})),Lm=zh(Om.prototype,"_mipFilter",[uu],(function(){return 0})),Vm=zh(Om.prototype,"_wrapS",[uu],(function(){return 0})),Nm=zh(Om.prototype,"_wrapT",[uu],(function(){return 0})),zm=zh(Om.prototype,"_wrapR",[uu],(function(){return 0})),Um=zh(Om.prototype,"_anisotropy",[uu],(function(){return 0})),Em=Om))||Em;A.TextureBase=Ym;var Jm=t("ea",Kh("cc.Script")(Wm=function(t){function e(e){return t.call(this,e)||this}return s(e,t),e}(Cm))||Wm);A._Script=Jm;var Km=t("eb",Kh("cc.JavaScript")(jm=function(t){function e(e){return t.call(this,e)||this}return s(e,t),e}(Jm))||jm);A._JavaScript=Km;var Qm,Zm,$m,tg,eg,ig,ng,rg=t("ec",Kh("cc.TypeScript")(qm=function(t){function e(e){return t.call(this,e)||this}return s(e,t),e}(Jm))||qm);A._TypeScript=rg;var sg,ag,og,hg,ug,lg,cg,fg,_g,dg,pg,mg=t("ds",Kh("cc.ClickEvent")((Zm=function(){function t(){this.target=$m&&$m(),this.component=tg&&tg(),this._componentId=eg&&eg(),this.handler=ig&&ig(),this.customEventData=ng&&ng()}t.emitEvents=function(e){for(var i=arguments.length,n=new Array(i>1?i-1:0),r=1;r=0,1620),i=Number.isNaN(i)?C.macro.REPEAT_FOREVER:i,n=n||0;var r=C.director.getScheduler(),s=r.isTargetPaused(this);r.schedule(t,this,e,i,n,s)},i.scheduleOnce=function(t,e){void 0===e&&(e=0),this.schedule(t,0,0,e)},i.unschedule=function(t){t&&C.director.getScheduler().unschedule(t,this)},i.unscheduleAllCallbacks=function(){C.director.getScheduler().unscheduleAllForTarget(this)},n(e,[{key:"name",get:function(){if(this._name)return this._name;var t=Ht(this),e=t.lastIndexOf(".");return e>=0&&(t=t.slice(e+1)),this.node?this.node.name+"<"+t+">":t},set:function(t){this._name=t}},{key:"uuid",get:function(){return this._id}},{key:"__scriptAsset",get:function(){return null}},{key:"enabled",get:function(){return this._enabled},set:function(t){if(this._enabled!==t&&(this._enabled=t,this.node.activeInHierarchy)){var e=C.director._compScheduler;t?e.enableComp(this):e.disableComp(this)}}},{key:"enabledInHierarchy",get:function(){return this._enabled&&this.node&&this.node.activeInHierarchy}},{key:"_isOnLoadCalled",get:function(){return 16384&this._objFlags}},{key:"internalUpdate",get:function(){return this.update}},{key:"internalLateUpdate",get:function(){return this.lateUpdate}},{key:"internalPreload",get:function(){return this.__preload}},{key:"internalOnLoad",get:function(){return this.onLoad}},{key:"internalStart",get:function(){return this.start}},{key:"internalOnEnable",get:function(){return this.onEnable}},{key:"internalOnDisable",get:function(){return this.onDisable}},{key:"internalOnDestroy",get:function(){return this.onDestroy}}]),e}(mo),fg.EventHandler=mg,fg._executionOrder=0,fg._requireComponent=null,fg.system=null,v((hg=fg).prototype,"__scriptAsset",[ag],Object.getOwnPropertyDescriptor(hg.prototype,"__scriptAsset"),hg.prototype),ug=zh(hg.prototype,"node",[uu],(function(){return null})),lg=zh(hg.prototype,"_enabled",[uu],(function(){return!0})),cg=zh(hg.prototype,"__prefab",[uu],(function(){return null})),og=hg))||og));Vt(yg,"_registerEditorProps",(function(t,e){var i=e.requireComponent;i&&(Array.isArray(i)&&(i=i.filter(Boolean)),t._requireComponent=i);var n=e.executionOrder;n&&"number"==typeof n&&(t._executionOrder=n)})),C.Component=yg;var vg=t("dQ",Kh("cc.MissingScript")((dg=function(t){function e(){var e;return(e=t.call(this)||this)._$erialized=pg&&pg(),e}return s(e,t),e.safeFindClass=function(t){var e=_e(t);if(e)return e;A.deserialize.reportMissingClass(t)},e.prototype.onLoad=function(){at(4600,this.node.name)},e}(yg),pg=zh(dg.prototype,"_$erialized",[uu,cu],(function(){return null})),_g=dg))||_g);A._MissingScript=vg;try{var bg=vg.__values__;0!==bg.length&&"_$erialized"===bg[bg.length-1]||(ht(16338),ht(16339,bg.join(", ")))}catch(Es){ht(16340,""+Es)}var Sg=function(){function t(t,e){this._document=t,this._chunks=e}return n(t,[{key:"document",get:function(){return this._document}},{key:"chunks",get:function(){return this._chunks}}]),t}();function wg(t){var e=t;return{chunks:e.chunks,document:e.document}}function xg(t){if(t.length<16)throw new Ag(ft(13102));var e=new DataView(t.buffer,t.byteOffset,t.byteLength);if(1313817411!==e.getUint32(0,!0))throw new Ag(ft(13100));var i=e.getUint32(4,!0);if(1!==i)throw new Ag(ft(13101,i));if(e.getUint32(8,!0)!==e.byteLength)throw new Ag(ft(13102));var n=12,r=e.getUint32(n,!0);n+=4;var s=new Uint8Array(e.buffer,n+e.byteOffset,r);n+=r;var a,o=Tg(s);try{a=JSON.parse(o)}catch(t){throw new Ag(t)}for(var h=[];n0&&(t.chunks.length,this._mainBinChunk=t.chunks[0])):e=t,this._serializedData=e,this._context={fromCCON:i};var n=Array.isArray(e)?e[0]:e;return this.deserializedData=this._deserializeObject(n,0),this._serializedData=void 0,this._mainBinChunk=void 0,this._context=void 0,this.deserializedData},e._deserializeObject=function(t,e,i,n){switch(t.__type__){case"TypedArray":return this._deserializeTypedArrayView(t);case"TypedArrayRef":return this._deserializeTypedArrayViewRef(t);default:return t.__type__?this._deserializeTypeTaggedObject(t,e,i,n):Array.isArray(t)?this._deserializeArray(t):this._deserializePlainObject(t)}},e._deserializeTypedArrayView=function(t){return globalThis[t.ctor].from(t.array)},e._deserializeTypedArrayViewRef=function(t){var e=t.offset,i=t.length,n=t.ctor;return new globalThis[n](this._mainBinChunk.buffer,this._mainBinChunk.byteOffset+e,i)},e._deserializeArray=function(t){for(var e,i=new Array(t.length),n=0;n=0&&(r.deserializedList[e]=i),i}(a);return this._deserializeInto(t,o,a),o},e._deserializeInto=function(t,e,i,n){void 0===n&&(n=!1),n||!e[Ku]?e._deserialize?e._deserialize(t.content,this):A.Class._isCCClass(i)?this._deserializeFireClass(e,t,i):this._deserializeFastDefinedObject(e,t,i):this._runCustomizedDeserialize(t,e,i)},e._runCustomizedDeserialize=function(t,e,i){var n=this,r={readProperty:function(e){var i=t[e];return"object"==typeof i&&i?n._deserializeObjectField(i):i},readThis:function(){n._deserializeInto(t,e,i,!0)},readSuper:function(){var r=ee(i);r&&n._deserializeInto(t,e,r)}};e[Ku](r,this._context)},e._deserializeFireClass=function(t,e,i){var n;if(i.hasOwnProperty("__deserialize__"))n=i.__deserialize__;else{n=Dg(0,i);try{if(i===vg){var r=i.__values__;0!==r.length&&"_$erialized"===r[r.length-1]||(ht(16341),ht(16342,r.join(", ")));var s=n;n=function(t,e,i,n){s(t,e,i,n),e._$erialized||ht(16343,JSON.stringify(i))}}}catch(t){ht(16344,""+t)}Vt(i,"__deserialize__",n,!0)}n(this,t,e,i)},e._deserializeAndAssignField=function(t,e,i){var n=e.__id__;if("number"==typeof n){var r=this.deserializedList[n];if(r)t[i]=r;else{var s,a=this._serializedData[n];t[i]=this._deserializeObject(a,n,void 0,i),null==(s=this._onDereferenced)||s.call(this,this.deserializedList,n,t,i)}}else{var o=e.__uuid__;if(o){var h=e.__expectedType__;this.result.push(t,i,o,h)}else t[i]=this._deserializeObject(e,-1)}return!1},e._deserializeObjectField=function(t){var e=t.__id__;if("number"==typeof e){var i=this.deserializedList[e];if(i)return i;var n=this._serializedData[e];return this._deserializeObject(n,e,void 0,void 0)}if(t.__uuid__)throw t.__expectedType__,new Error("Asset reference field serialization is currently not supported in custom serialization.");return this._deserializeObject(t,-1)},e._fillPlainObject=function(t,e){for(var i in e)if(e.hasOwnProperty(i)){var n=e[i];"object"!=typeof n?"__type__"!==i&&(t[i]=n):n?this._deserializeAndAssignField(t,n,i)&&(t[i]=null):t[i]=null}},e._deserializeFastDefinedObject=function(t,e,i){if(i===A.Vec2)return t.x=e.x||0,void(t.y=e.y||0);if(i===A.Vec3)return t.x=e.x||0,t.y=e.y||0,void(t.z=e.z||0);if(i!==A.Color){if(i===A.Size)return t.width=e.width||0,void(t.height=e.height||0);for(var n=Vi.Attr.getClassAttrs(i),r=i.__values__,s=0;s=0?a[i[h]]=o:a[~h]=o}for(;r=0?u[i[c]]=l:u[~c]=l}}function Jg(t,e){for(var i=t[4][e[qg]],n=i[jg],r=new(0,n[Gg]),s=n[Hg],a=n[Wg],o=i[i.length-1],h=jg+1;h=0?e[i]=t[5][n]:t[7][3*~n]=e}function Zg(t){return function(e,i,n,r){for(var s=0;s=0){var c=o[u];e[a]=Kg(t,c,l)}else(0,ey[u=~u])(t,e,a,l)}return r}function ny(t,e,i){return t||i(e),Object}function ry(t,e,i,n,r,s,a){var o=t(e);if(!o){if(r)return void(i[n]=function(e,i,n){return function(){var r=t(n)||ny(s,n,a);return e[i]=r,new r}}(i,n,e));o=ny(s,e,a)}i[n]=o}function sy(t,e,i,n){for(var r=i||_e,s=t[3],a=0;a=0?i[u]:~u,s[o]=u);var l=a[o];"number"==typeof l&&(a[o]=n[l])}}function hy(t){if(Array.isArray(t)){var e=t[0];return"number"==typeof e||e instanceof cy}return!1}function uy(t,e,i){var n;e.init(t),null!==(n=i)&&void 0!==n||(i={});var r=t[0],s=!1;if("object"==typeof r&&(s=r.preprocessed,r=r.version),r>=1,n++;return n}function Ty(t){return t&&!(t&t-1)}function Ay(t,e,i){return!(6===t.gfxAPI)||Ty(e)&&Ty(i)}var Cy,Dy,By,Iy,My,Py=Kh("cc.SimpleTexture")(by=function(t){function e(e){var i;return(i=t.call(this,e)||this)._gfxTexture=null,i._gfxTextureView=null,i._mipmapLevel=1,i._textureWidth=0,i._textureHeight=0,i._baseLevel=0,i._maxLevel=1e3,i}s(e,t);var i=e.prototype;return i.getGFXTexture=function(){return this._gfxTextureView},i.destroy=function(){return this._tryDestroyTextureView(),this._tryDestroyTexture(),t.prototype.destroy.call(this)},i.updateImage=function(){this.updateMipmaps(0)},i.updateMipmaps=function(){},i.uploadData=function(t,e,i){if(void 0===e&&(e=0),void 0===i&&(i=0),this._gfxTexture&&!(this._mipmapLevel<=e)){var n=this._getGFXDevice();if(n){var r=wy[0];r.texExtent.width=this._textureWidth>>e,r.texExtent.height=this._textureHeight>>e,r.texSubres.mipLevel=e,r.texSubres.baseArrayLayer=i,ArrayBuffer.isView(t)?n.copyBuffersToTexture([t],this._gfxTexture,wy):n.copyTexImagesToTexture([t],this._gfxTexture,wy)}}},i._assignImage=function(t,e,i){var n=t.data;if(n&&(this.uploadData(n,e,i),this._checkTextureLoaded(),Ue.CLEANUP_IMAGE_CACHE)){var r=Sy.getDeps(this._uuid),s=r.indexOf(t._uuid);-1!==s&&(be(r,s),t.decRef())}},i._checkTextureLoaded=function(){this._textureReady()},i._textureReady=function(){this.loaded=!0,this.emit("load")},i._setMipmapLevel=function(t){this._mipmapLevel=t<1?1:t},i._setMipRange=function(t,e){this._baseLevel=t<1?0:t,this._maxLevel=e<1?0:e},i.setMipRange=function(t,e){lt(t<=e,3124),this._setMipRange(t,e);var i=this._getGFXDevice();if(i){var n=this._createTextureView(i);this._tryDestroyTextureView(),this._gfxTextureView=n}},i._getGfxTextureCreateInfo=function(){return null},i._getGfxTextureViewCreateInfo=function(){return null},i._tryReset=function(){if(this._tryDestroyTextureView(),this._tryDestroyTexture(),0!==this._mipmapLevel){var t=this._getGFXDevice();t&&(this._createTexture(t),this._gfxTextureView=this._createTextureView(t))}},i.isUsingOfflineMipmaps=function(){return!1},i._createTexture=function(t){if(0!==this._width&&0!==this._height){var e=0;0!==this._mipFilter&&Ay(t,this._width,this._height)&&(this._mipmapLevel=xy(this._width,this._height),this.isUsingOfflineMipmaps()||this.isCompressed||(e=1));var i=this._getGfxTextureCreateInfo({usage:22,format:this._getGFXFormat(),levelCount:this._mipmapLevel,flags:e});if(i){var n=t.createTexture(i);this._textureWidth=i.width,this._textureHeight=i.height,this._gfxTexture=n}}},i._createTextureView=function(t){if(!this._gfxTexture)return null;var e=this._maxLevel0){var i=this._generatedMipmaps[0];this.reset({width:i.width,height:i.height,format:i.format,mipmapLevel:this._generatedMipmaps.length,baseLevel:this._baseLevel,maxLevel:this._maxLevel}),this._generatedMipmaps.forEach((function(t,i){e._assignImage(t,i)}))}else this.reset({width:0,height:0,mipmapLevel:this._generatedMipmaps.length,baseLevel:this._baseLevel,maxLevel:this._maxLevel})},i.initialize=function(){this.mipmaps=this._mipmaps},i.onLoaded=function(){this.initialize()},i.reset=function(t){this._width=t.width,this._height=t.height,this._setGFXFormat(t.format);var e=void 0===t.mipmapLevel?1:t.mipmapLevel;this._setMipmapLevel(e);var i=void 0===t.baseLevel?0:t.baseLevel,n=void 0===t.maxLevel?1e3:t.maxLevel;this._setMipRange(i,n),this._tryReset()},i.create=function(t,e,i,n,r,s){void 0===i&&(i=35),void 0===n&&(n=1),void 0===r&&(r=0),void 0===s&&(s=1e3),this.reset({width:t,height:e,format:i,mipmapLevel:n,baseLevel:r,maxLevel:s})},i.toString=function(){return 0!==this._mipmaps.length?this._mipmaps[0].url:""},i.updateMipmaps=function(t,e){if(void 0===t&&(t=0),void 0===e&&(e=void 0),!(t>=this._generatedMipmaps.length))for(var i=Math.min(void 0===e?this._generatedMipmaps.length:e,this._generatedMipmaps.length-t),n=0;n"},i.releaseTexture=function(){this.destroy()},i._serialize=function(){return null},i._deserialize=function(e,i){var n=e;t.prototype._deserialize.call(this,n.base,i),this._mipmaps=new Array(n.mipmaps.length);for(var r=0;r1)for(var n=0;nthis._width&&(this._x=2,this._y=this._nextY),this._y+o+2>this._nextY&&(this._nextY=this._y+o+2),this._nextY>this._height)return null;var h=this._texture,u=i.image;A.internal.dynamicAtlasManager.textureBleeding&&((a<=8||o<=8)&&(Oy(h,u,this._x-1,this._y-1),Oy(h,u,this._x-1,this._y+1),Oy(h,u,this._x+1,this._y-1),Oy(h,u,this._x+1,this._y+1)),Oy(h,u,this._x-1,this._y),Oy(h,u,this._x+1,this._y),Oy(h,u,this._x,this._y-1),Oy(h,u,this._x,this._y+1)),Oy(h,u,this._x,this._y),this._innerTextureInfos[i.getId()]={x:this._x,y:this._y,texture:i},this._count++,r+=this._x,s+=this._y,this._x+=a+2}var l={x:r,y:s,texture:this._texture};return this._innerSpriteFrames.push(t),l},e.removeSpriteFrame=function(t){we(this._innerSpriteFrames,t)},e.deleteInnerTexture=function(t){t&&this._innerTextureInfos[t.getId()]&&(delete this._innerTextureInfos[t.getId()],this._count--)},e.isEmpty=function(){return this._count<=0},e.reset=function(){this._x=2,this._y=2,this._nextY=2;for(var t=this._innerSpriteFrames,e=0,i=t.length;e19||i<0)at(16365);else{var n=1<19||e<0)at(16366);else{var i=1<31||e<0?(at(16368),""):t.Enum[1<0)for(var n=0;n=0;--n)if((e=r[n]).eventProcessor.capturingTarget&&(t.currentTarget=e,e.eventProcessor.capturingTarget.emit(t.type,t,r),t.propagationStopped))return void iv.free(r);if(t.eventPhase=2,t.currentTarget=i,this.capturingTarget&&this.capturingTarget.emit(t.type,t),!t.propagationImmediateStopped&&this.bubblingTarget&&this.bubblingTarget.emit(t.type,t),!t.propagationStopped&&t.bubbles)for(r.length=0,this.getBubblingTargets(t.type,r),t.eventPhase=3,n=0;n0?n:null}return null},e._attachMask=function(){this.maskList=this._searchComponentsInParent(t._maskComp)},e._isTouchEvent=function(t){return-1!==sv.indexOf(t)},e._isMouseEvent=function(t){return-1!==av.indexOf(t)},e._hasTouchListeners=function(){for(var t=0;t=0;--a){var o=i[a];Kr.fromSRT(Cv,o.rotation,o.position,o.scale),Kr.multiply(e,e,Cv)}s=!0}else e.set(t._mat);return Dv.length=0,s}function Mv(t,e){if(t.isSkewEnabled()&&(0!==t.x||0!==t.y))if(t.rotational){var i=-t.x*Bv,n=t.y*Bv,r=Math.cos(i),s=Math.sin(i),a=Math.cos(n),o=Math.sin(n),h=e.m00,u=e.m01,l=e.m04,c=e.m05;e.m00=a*h-s*u,e.m01=o*h+r*u,e.m04=a*l-s*c,e.m05=o*l+r*c}else{var f=Math.tan(t.x*Bv),_=Math.tan(t.y*Bv),d=e.m00,p=e.m01,m=e.m04,g=e.m05;e.m00=d+m*_,e.m01=p+g*_,e.m04=m+d*f,e.m05=g+p*f}}var Pv=128,Ev="transform-changed",Ov="active-changed",kv=new It("Node");function Rv(t){return t?"string"==typeof t?de(t):t:(ht(3804),null)}var Fv,Lv,Vv,Nv,zv,Uv,Gv,Hv=nr(),Wv=nr(),jv=Ur(),qv=Ur(),Xv=Ur(),Yv=new yr,Jv=$r(),Kv=$r(),Qv=[],Zv=Symbol("ReserveContentsForAllSyncablePrefab"),$v=0,tb=0,eb=t("dn",(uv=Kh("cc.Node"),lv=Ou(ir),cv=Ou(Uy),uv((Av=function(t){s(i,t);var e=i.prototype;function i(e){var i;return void 0===e&&(e="New Node"),(i=t.call(this,e)||this)._parent=dv&&dv(),i._children=pv&&pv(),i._active=mv&&mv(),i._components=gv&&gv(),i._prefab=yv&&yv(),i._scene=null,i._activeInHierarchy=!1,i._id=kv.getNewId(),i._eventProcessor=new hv(f(i)),i._eventMask=0,i._siblingIndex=0,i._originalSceneId="",i._uiProps=new Vy(f(i)),i._static=!1,i._lpos=vv&&vv(),i._lrot=bv&&bv(),i._lscale=Sv&&Sv(),i._mobility=wv&&wv(),i._layer=xv&&xv(),i._euler=Tv&&Tv(),i._transformFlags=15,i._eulerDirty=!1,i._flagChangeVersion=0,i._hasChangedFlags=0,i._pos=new ir,i._rot=new kr,i._scale=new ir(1,1,1),i._mat=new Kr,i}return e._setActiveInHierarchy=function(t){this._activeInHierarchy=t},i._setScene=function(t){t._updateScene()},i._incSkewCompCount=function(){++tb},i._decSkewCompCount=function(){--tb},i._findComponent=function(t,e){var i=e,n=t._components;if(i._sealed)for(var r=0;r0&&(s=i._findChildComponent(r._children,e)))return s}return null},i._findChildComponents=function(t,e,n){for(var r=0;r0&&i._findChildComponents(s._children,e,n)}},e.getWritableComponents=function(){return this._components},e._updateScene=function(){null==this._parent?ht(1640,this.name,this.uuid):this._scene=this._parent._scene},e.attr=function(t){$t(this,t)},e.getParent=function(){return this._parent},e.modifyParent=function(t){this._parent=t},e.setParent=function(t,e){if(void 0===e&&(e=!1),e&&this.updateWorldTransform(),this._parent!==t){var i=this._parent,n=t;if(this._parent=n,this._siblingIndex=0,this._onSetParent(i,e),this.emit&&this.emit("parent-changed",i),i&&!(i._objFlags&Pv)){var r=i._children.indexOf(this);i._children.splice(r,1),i._updateSiblingIndex(),i.emit&&i.emit("child-removed",this)}n&&(n._children.push(this),this._siblingIndex=n._children.length-1,n.emit&&n.emit("child-added",this)),this._onHierarchyChanged(i)}},e.getChildByUuid=function(t){if(!t)return X("Invalid uuid"),null;for(var e=this._children,i=0,n=e.length;i=0?t:e.length+t;var i=e.indexOf(this);t!==i&&(e.splice(i,1),t0?(h=s,r=s._children,a=0,o[n]=r[a],n++):(o[n]=s,n++,u=!0);o.length=0,i._stackId--},e.removeFromParent=function(){this._parent&&this._parent.removeChild(this)},e.removeChild=function(t){this._children.indexOf(t)>-1&&(t.parent=null)},e.removeAllChildren=function(){for(var t=this._children,e=t.length-1;e>=0;e--){var i=t[e];i&&(i.parent=null)}this._children.length=0},e.isChildOf=function(t){var e=this;do{if(e===t)return!0;e=e._parent}while(e);return!1},e.getComponent=function(t){var e=Rv(t);return e?i._findComponent(this,e):null},e.getComponents=function(t){var e=Rv(t),n=[];return e&&i._findComponents(this,e,n),n},e.getComponentInChildren=function(t){var e=Rv(t);return e?i._findChildComponent(this._children,e):null},e.getComponentsInChildren=function(t){var e=Rv(t),n=[];return e&&(i._findComponents(this,e,n),i._findChildComponents(this._children,e,n)),n},e.addComponent=function(t){var e;if("string"==typeof t){if(!(e=de(t)))throw A._RF.peek()&&ht(3808,t),TypeError(ft(3807,t))}else{if(!t)throw TypeError(ft(3804));e=t}if("function"!=typeof e)throw TypeError(ft(3809));if(!ie(e,A.Component))throw TypeError(ft(3810));var i=e._requireComponent;if(i)if(Array.isArray(i))for(var n=0;n0){if(t){var a=Iv(t,Kv);Kr.fromSRT(Jv,n._lrot,n._lpos,n._lscale);var o=a?Kv:t._mat;Kr.multiply(n._mat,o,Jv)}Iv(r,Kv)&&(s=Kv)}Kr.multiply(Jv,Kr.invert(Jv,s),n._mat),Kr.toSRT(Jv,n._lrot,n._lpos,n._lscale)}else ir.copy(n._lpos,n._pos),kr.copy(n._lrot,n._rot),ir.copy(n._lscale,n._scale);n._eulerDirty=!0}n.invalidateChildren(7)},e._onHierarchyChanged=function(t){this.eventProcessor.reattach(),this._onHierarchyChangedBase(t)},e._onBatchCreated=function(t){2&this._eventMask&&(this._activeInHierarchy||this.emit(Ov,this,!1)),this.hasChangedFlags=7,this._children.forEach((function(e,i){e._siblingIndex=i,e._onBatchCreated(t)}))},e._onBeforeSerialize=function(){this.eulerAngles},e._onPostActivated=function(t){var e=this;2&e._eventMask&&e.emit(Ov,e,t);var i=this._eventProcessor;if(i.isEnabled===t&&hv.callbacksInvoker.emit(2),i.setEnabled(t),t){e.invalidateChildren(7);var n=e._uiProps&&e._uiProps.uiComp;n&&(n.setNodeDirty(),n.setTextureDirty(),n._markForUpdateRenderData())}},e.translate=function(t,e){var i=e||0;if(0===i)ir.transformQuat(Hv,t,this._lrot),this._lpos.x+=Hv.x,this._lpos.y+=Hv.y,this._lpos.z+=Hv.z;else if(1===i)if(this._parent){kr.invert(jv,this._parent.worldRotation),ir.transformQuat(Hv,t,jv);var n=this.worldScale;this._lpos.x+=Hv.x/n.x,this._lpos.y+=Hv.y/n.y,this._lpos.z+=Hv.z/n.z}else this._lpos.x+=t.x,this._lpos.y+=t.y,this._lpos.z+=t.z;this.invalidateChildren(1),1&this._eventMask&&this.emit(Ev,1)},e.rotate=function(t,e){var i=e||0;if(kr.normalize(jv,t),0===i)kr.multiply(this._lrot,this._lrot,jv);else if(1===i){var n=this.worldRotation;kr.multiply(qv,jv,n),kr.invert(jv,n),kr.multiply(qv,jv,qv),kr.multiply(this._lrot,this._lrot,qv)}this._eulerDirty=!0,this.invalidateChildren(2),1&this._eventMask&&this.emit(Ev,2)},e.lookAt=function(t,e){this.getWorldPosition(Hv),ir.subtract(Hv,Hv,t),ir.normalize(Hv,Hv),kr.fromViewUp(jv,Hv,e),this.setWorldRotation(jv)},e.invalidateChildren=function(t){var e,i,n=0,r=0,s=0,a=0,o=1|t;for(Qv[0]=this;n>=0;){if(a=(e=Qv[n--]).hasChangedFlags,e.isValid&&(e._transformFlags&a&t)!==t)for(e._transformFlags|=t,e.hasChangedFlags=a|t,s=(i=e._children).length,r=0;r0&&(u=Iv(n,Kv),((h=t._uiProps._uiSkewComp)||u)&&(Kr.multiply(Kv,Kv,Jv),h&&Mv(h,Jv),l=Kv)),Kr.multiply(e,n._mat,Jv);var c=2&s?t._rot:null;Kr.toSRT(l,c,i,t._scale),u&&ir.transformMat4(i,t._lpos,n._mat)}}else a&&(ir.copy(i,t._lpos),e.m12=i.x,e.m13=i.y,e.m14=i.z),o&&(2&s&&kr.copy(t._rot,t._lrot),4&s&&ir.copy(t._scale,t._lscale),Kr.fromSRT(e,t._rot,t._pos,t._scale),tb>0&&(h=t._uiProps._uiSkewComp)&&Mv(h,e));t._transformFlags=0,n=t}}},e.setPosition=function(t,e,i){var n=this._lpos;void 0===e?ir.copy(n,t):(void 0===i&&(i=n.z),ir.set(n,t,e,i)),this.invalidateChildren(1),1&this._eventMask&&this.emit(Ev,1)},e.getPosition=function(t){return t?ir.set(t,this._lpos.x,this._lpos.y,this._lpos.z):ir.copy(new ir,this._lpos)},e.setRotation=function(t,e,i,n){void 0===e?kr.copy(this._lrot,t):kr.set(this._lrot,t,e,i,n),this._eulerDirty=!0,this.invalidateChildren(2),1&this._eventMask&&this.emit(Ev,2)},e.setRotationFromEuler=function(t,e,i){if(void 0===e)ir.copy(this._euler,t),kr.fromEuler(this._lrot,t.x,t.y,t.z);else{var n=void 0===i?this._euler.z:i;ir.set(this._euler,t,e,n),kr.fromEuler(this._lrot,t,e,n)}this._eulerDirty=!1,this.invalidateChildren(2),1&this._eventMask&&this.emit(Ev,2)},e.getRotation=function(t){return t?kr.set(t,this._lrot.x,this._lrot.y,this._lrot.z,this._lrot.w):kr.copy(new kr,this._lrot)},e.setScale=function(t,e,i){var n=this._lscale;void 0===e?ir.copy(n,t):(void 0===i&&(i=n.z),ir.set(n,t,e,i)),this.invalidateChildren(4),1&this._eventMask&&this.emit(Ev,4)},e.getScale=function(t){return t?ir.set(t,this._lscale.x,this._lscale.y,this._lscale.z):ir.copy(new ir,this._lscale)},e.inverseTransformPoint=function(t,e){ir.copy(t,e);for(var i=this,n=0;i._parent;)Qv[n++]=i,i=i._parent;for(;n>=0;)ir.transformInverseRTS(t,t,i._lrot,i._lpos,i._lscale),i=Qv[--n];return t},e.setWorldPosition=function(t,e,i){var n=this._pos;void 0===e?ir.copy(n,t):ir.set(n,t,e,i);var r=this._parent,s=this._lpos;r?(r.updateWorldTransform(),ir.transformMat4(s,n,Kr.invert(Jv,r._mat))):ir.copy(s,n),this.invalidateChildren(1),1&this._eventMask&&this.emit(Ev,1)},e.getWorldPosition=function(t){return this.updateWorldTransform(),t?ir.copy(t,this._pos):ir.copy(new ir,this._pos)},e.setWorldRotation=function(t,e,i,n){var r=this._rot;void 0===e?kr.copy(r,t):kr.set(r,t,e,i,n),this._parent?(this._parent.updateWorldTransform(),kr.multiply(this._lrot,kr.conjugate(this._lrot,this._parent._rot),r)):kr.copy(this._lrot,r),this._eulerDirty=!0,this.invalidateChildren(2),1&this._eventMask&&this.emit(Ev,2)},e.setWorldRotationFromEuler=function(t,e,i){kr.fromEuler(jv,t,e,i),this.setWorldRotation(jv)},e.getWorldRotation=function(t){return this.updateWorldTransform(),t?kr.copy(t,this._rot):kr.copy(new kr,this._rot)},e.setWorldScale=function(t,e,i){var n=this,r=n._parent;r&&n.updateWorldTransform();var s=n._scale;void 0===e?ir.copy(s,t):ir.set(s,t,e,i);var a=0;if(r){var o=n._mat;n._uiProps._uiSkewComp&&(Kr.fromSRT(Jv,n._lrot,n._lpos,n._lscale),Kr.multiply(o,r._mat,Jv));var h=ir.set(Wv,o.m00,o.m01,o.m02).length(),u=ir.set(Wv,o.m04,o.m05,o.m06).length(),l=ir.set(Wv,o.m08,o.m09,o.m10).length();0===h?(Hv.x=s.x,o.m00=1,a=2):Hv.x=s.x/h,0===u?(Hv.y=s.y,o.m05=1,a=2):Hv.y=s.y/u,0===l?(Hv.z=s.z,o.m10=1,a=2):Hv.z=s.z/l,Kr.scale(Jv,o,Hv),Kr.multiply(Kv,Kr.invert(Kv,r._mat),Jv),yr.fromQuat(Yv,kr.conjugate(Xv,n._lrot)),yr.multiplyMat4(Yv,Yv,Kv);var c=n._lscale;c.x=ir.set(Hv,Yv.m00,Yv.m01,Yv.m02).length(),c.y=ir.set(Hv,Yv.m03,Yv.m04,Yv.m05).length(),c.z=ir.set(Hv,Yv.m06,Yv.m07,Yv.m08).length(),0!==c.x&&0!==c.y&&0!==c.z||(a=2)}else ir.copy(n._lscale,s);n.invalidateChildren(4|a),1&n._eventMask&&n.emit(Ev,4|a)},e.getWorldScale=function(t){return this.updateWorldTransform(),t?ir.copy(t,this._scale):ir.copy(new ir,this._scale)},e.getWorldMatrix=function(t){this.updateWorldTransform();var e=t||new Kr;return Kr.copy(e,this._mat)},e.getWorldRS=function(t){this.updateWorldTransform();var e=t||new Kr;return Kr.copy(e,this._mat),e.m12=0,e.m13=0,e.m14=0,e},e.getWorldRT=function(t){this.updateWorldTransform();var e=t||new Kr;return Kr.fromRT(e,this._rot,this._pos)},e.setRTS=function(t,e,i){var n=0;t&&(n|=2,void 0!==t.w?(kr.copy(this._lrot,t),this._eulerDirty=!0):(ir.copy(this._euler,t),kr.fromEuler(this._lrot,t.x,t.y,t.z),this._eulerDirty=!1)),e&&(ir.copy(this._lpos,e),n|=1),i&&(ir.copy(this._lscale,i),n|=4),n&&(this.invalidateChildren(n),1&this._eventMask&&this.emit(Ev,n))},e.isTransformDirty=function(){return 0!==this._transformFlags},e.pauseSystemEvents=function(t){this._eventProcessor.setEnabled(!1,t)},e.resumeSystemEvents=function(t){this._eventProcessor.setEnabled(!0,t)},i.resetHasChangedFlags=function(){$v+=1},i.clearNodeArray=function(){i.ClearFrame0},set:function(t){t?this._objFlags|=64:this._objFlags&=-65}},{key:"name",get:function(){return this._name},set:function(t){this._name=t}},{key:"uuid",get:function(){return this._id}},{key:"children",get:function(){return this._children}},{key:"active",get:function(){return this._active},set:function(t){if(t=!!t,this._active!==t){this._active=t;var e=this._parent;e&&e._activeInHierarchy&&A.director._nodeActivator.activateNode(this,t)}}},{key:"activeInHierarchy",get:function(){return this._activeInHierarchy}},{key:"parent",get:function(){return this._parent},set:function(t){this.setParent(t)}},{key:"scene",get:function(){return this._scene}},{key:"eventProcessor",get:function(){return this._eventProcessor}},{key:"prefab",get:function(){return this._prefab}},{key:"id",set:function(t){this._id=t}},{key:"siblingIndex",get:function(){return this._siblingIndex},set:function(t){this._siblingIndex=t}},{key:"position",get:function(){return this._lpos},set:function(t){this.setPosition(t)}},{key:"x",get:function(){return this._lpos.x},set:function(t){this.setPosition(t,this._lpos.y,this._lpos.z)}},{key:"y",get:function(){return this._lpos.y},set:function(t){this.setPosition(this._lpos.x,t,this._lpos.z)}},{key:"z",get:function(){return this._lpos.z},set:function(t){this.setPosition(this._lpos.x,this._lpos.y,t)}},{key:"worldPosition",get:function(){return this.updateWorldTransform(),this._pos},set:function(t){this.setWorldPosition(t)}},{key:"worldPositionX",get:function(){return this.updateWorldTransform(),this._pos.x},set:function(t){this.setWorldPosition(t,this._pos.y,this._pos.z)}},{key:"worldPositionY",get:function(){return this.updateWorldTransform(),this._pos.y},set:function(t){this.setWorldPosition(this._pos.x,t,this._pos.z)}},{key:"worldPositionZ",get:function(){return this.updateWorldTransform(),this._pos.z},set:function(t){this.setWorldPosition(this._pos.x,this._pos.y,t)}},{key:"rotation",get:function(){return this._lrot},set:function(t){this.setRotation(t)}},{key:"eulerAngles",get:function(){return this._eulerDirty&&(kr.toEuler(this._euler,this._lrot),this._eulerDirty=!1),this._euler},set:function(t){this.setRotationFromEuler(t.x,t.y,t.z)}},{key:"angle",get:function(){return this.eulerAngles.z},set:function(t){ir.set(this._euler,0,0,t),kr.fromAngleZ(this._lrot,t),this._eulerDirty=!1,this.invalidateChildren(2),1&this._eventMask&&this.emit(Ev,2)}},{key:"worldRotation",get:function(){return this.updateWorldTransform(),this._rot},set:function(t){this.setWorldRotation(t)}},{key:"scale",get:function(){return this._lscale},set:function(t){this.setScale(t)}},{key:"worldScale",get:function(){return this.updateWorldTransform(),this._scale},set:function(t){this.setWorldScale(t)}},{key:"matrix",set:function(t){Kr.toSRT(t,this._lrot,this._lpos,this._lscale),this.invalidateChildren(7),this._eulerDirty=!0,1&this._eventMask&&this.emit(Ev,7)}},{key:"worldMatrix",get:function(){return this.updateWorldTransform(),this._mat}},{key:"forward",get:function(){return ir.transformQuat(new ir,ir.FORWARD,this.worldRotation)},set:function(t){var e=t.length();ir.multiplyScalar(Hv,t,-1/e),kr.fromViewUp(jv,Hv),this.setWorldRotation(jv)}},{key:"up",get:function(){return ir.transformQuat(new ir,ir.UP,this.worldRotation)}},{key:"right",get:function(){return ir.transformQuat(new ir,ir.RIGHT,this.worldRotation)}},{key:"mobility",get:function(){return this._mobility},set:function(t){this._mobility!==t&&(this._mobility=t,this.emit("mobility-changed"))}},{key:"layer",get:function(){return this._layer},set:function(t){var e=this;if(e._layer!==t){e._layer=t;var i=e._uiProps&&e._uiProps.uiComp;i&&(i.setNodeDirty(),i._markForUpdateRenderData()),e.emit("layer-changed",e._layer)}}},{key:"flagChangedVersion",get:function(){return this._flagChangeVersion}},{key:"hasChangedFlags",get:function(){return this._flagChangeVersion===$v?this._hasChangedFlags:0},set:function(t){this._flagChangeVersion=$v,this._hasChangedFlags=t}}]),i}(mo),Av.idGenerator=kv,Av._stacks=[[]],Av._stackId=0,Av.EventType=Gy,Av.NodeSpace=Ny,Av.TransformDirtyBit=zy,Av.TransformBit=zy,Av.reserveContentsForAllSyncablePrefabTag=Zv,Av.ClearFrame=0,Av.ClearRound=1e3,v((_v=Av).prototype,"_persistNode",[tu],Object.getOwnPropertyDescriptor(_v.prototype,"_persistNode"),_v.prototype),dv=zh(_v.prototype,"_parent",[uu],(function(){return null})),pv=zh(_v.prototype,"_children",[uu],(function(){return[]})),mv=zh(_v.prototype,"_active",[uu],(function(){return!0})),gv=zh(_v.prototype,"_components",[uu],(function(){return[]})),yv=zh(_v.prototype,"_prefab",[uu],(function(){return null})),vv=zh(_v.prototype,"_lpos",[uu],(function(){return new ir})),bv=zh(_v.prototype,"_lrot",[uu],(function(){return new kr})),Sv=zh(_v.prototype,"_lscale",[uu],(function(){return new ir(1,1,1)})),wv=zh(_v.prototype,"_mobility",[uu],(function(){return Uy.Static})),xv=zh(_v.prototype,"_layer",[uu],(function(){return Ly.Enum.DEFAULT})),Tv=zh(_v.prototype,"_euler",[uu],(function(){return new ir})),v(_v.prototype,"eulerAngles",[lv],Object.getOwnPropertyDescriptor(_v.prototype,"eulerAngles"),_v.prototype),v(_v.prototype,"mobility",[cv],Object.getOwnPropertyDescriptor(_v.prototype,"mobility"),_v.prototype),fv=_v))||fv));A.Node=eb;var ib=t("e6",Kh("cc.TextureCube")((Gv=function(t){function e(e){var i;return(i=t.call(this,e)||this).isRGBE=Vv&&Vv(),i._mipmapAtlas=Nv&&Nv(),i._mipmapMode=zv&&zv(),i._mipmaps=Uv&&Uv(),i._generatedMipmaps=[],i}s(e,t);var i=e.prototype;return i._setMipmapParams=function(t){var e=this;if(this._generatedMipmaps=t,this._setMipmapLevel(this._generatedMipmaps.length),this._generatedMipmaps.length>0){var i=this._generatedMipmaps[0].front;this.reset({width:i.width,height:i.height,format:i.format,mipmapLevel:this._generatedMipmaps.length,baseLevel:this._baseLevel,maxLevel:this._maxLevel}),this._generatedMipmaps.forEach((function(t,i){nb(t,(function(t,n){e._assignImage(t,i,n)}))}))}else this.reset({width:0,height:0,mipmapLevel:this._generatedMipmaps.length,baseLevel:this._baseLevel,maxLevel:this._maxLevel})},i.isUsingOfflineMipmaps=function(){return 2===this._mipmapMode},e.fromTexture2DArray=function(t,i){for(var n=[],r=t.length/6,s=0;s=this._generatedMipmaps.length))for(var n=Math.min(void 0===e?this._generatedMipmaps.length:e,this._generatedMipmaps.length-t),r=function(){var e=t+s;nb(i._generatedMipmaps[e],(function(t,n){i._assignImage(t,e,n)}))},s=0;s1&&t.forEach((function(t){var i={front:t.front.extractMipmap0(),back:t.back.extractMipmap0(),left:t.left.extractMipmap0(),right:t.right.extractMipmap0(),top:t.top.extractMipmap0(),bottom:t.bottom.extractMipmap0()};e.push(i)}));this._setMipmapParams(e)}},{key:"mipmapAtlas",get:function(){return this._mipmapAtlas},set:function(t){var e=this;if(this._mipmapAtlas=t,this._mipmapAtlas){var i=this._mipmapAtlas.atlas.front;if(i.data){var n=this._mipmapAtlas.atlas,r=this._mipmapAtlas.layout,s=r[0],a=Object.assign(B.document.createElement("canvas"),{width:i.width,height:i.height}).getContext("2d");this.reset({width:s.width,height:s.height,format:i.format,mipmapLevel:r.length});for(var o=function(){var t=r[h];nb(n,(function(n,r){a.clearRect(0,0,i.width,i.height);var s=n.data;a.drawImage(s,0,0);var o=a.getImageData(t.left,t.top,t.width,t.height),h=new Hm({_data:o.data,_compressed:n.isCompressed,width:o.width,height:o.height,format:n.format});e._assignImage(h,t.level,r)}))},h=0;h>>26},ZS=function(t){return(t&YS)>>>20},$S=function(t){return(t&JS)>>>12},tw=function(t){return 4095&t},ew=function(t,e){return 67108863&t|e<<26&XS},iw=((VS={})[0]=function(t,e,i){return void 0===i&&(i=0),at(12010,i)},VS[5]=function(t,e,i){return void 0===i&&(i=0),t[i]},VS[6]=function(t,e,i){return void 0===i&&(i=0),ds.fromArray(e,t,i)},VS[7]=function(t,e,i){return void 0===i&&(i=0),ir.fromArray(e,t,i)},VS[8]=function(t,e,i){return void 0===i&&(i=0),Vn.fromArray(e,t,i)},VS[13]=function(t,e,i){return void 0===i&&(i=0),t[i]},VS[14]=function(t,e,i){return void 0===i&&(i=0),ds.fromArray(e,t,i)},VS[15]=function(t,e,i){return void 0===i&&(i=0),ir.fromArray(e,t,i)},VS[16]=function(t,e,i){return void 0===i&&(i=0),Vn.fromArray(e,t,i)},VS[21]=function(t,e,i){return void 0===i&&(i=0),yr.fromArray(e,t,i)},VS[25]=function(t,e,i){return void 0===i&&(i=0),Kr.fromArray(e,t,i)},VS),nw=((NS={})[0]=function(t,e,i){return void 0===i&&(i=0),at(12010,i)},NS[5]=function(t,e,i){return void 0===i&&(i=0),t[i]=e},NS[6]=function(t,e,i){return void 0===i&&(i=0),ds.toArray(t,e,i)},NS[7]=function(t,e,i){return void 0===i&&(i=0),ir.toArray(t,e,i)},NS[8]=function(t,e,i){return void 0===i&&(i=0),Vn.toArray(t,e,i)},NS[13]=function(t,e,i){return void 0===i&&(i=0),t[i]=e},NS[14]=function(t,e,i){return void 0===i&&(i=0),ds.toArray(t,e,i)},NS[15]=function(t,e,i){return void 0===i&&(i=0),ir.toArray(t,e,i)},NS[16]=function(t,e,i){return void 0===i&&(i=0),Vn.toArray(t,e,i)},NS[21]=function(t,e,i){return void 0===i&&(i=0),yr.toArray(t,e,i)},NS[25]=function(t,e,i){return void 0===i&&(i=0),Kr.toArray(t,e,i)},NS),rw=((zS={})[5]=function(t){return"number"==typeof t},zS[13]=function(t){return"number"==typeof t},zS[6]=function(t){return!!(t instanceof ds)},zS[14]=function(t){return!!(t instanceof ds)},zS[7]=function(t){return!!(t instanceof ir)},zS[15]=function(t){return!!(t instanceof ir)},zS[8]=function(t){return!!(t instanceof Vn)},zS[16]=function(t){return!!(t instanceof Vn||t instanceof cr||t instanceof kr)},zS[21]=function(t){return!!(t instanceof yr)},zS[25]=function(t){return!!(t instanceof Kr)},zS),sw=[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 aw(t){switch(t){case 1:case 5:case 9:case 13:return sw[0];case 2:case 6:case 10:case 14:return sw[1];case 4:case 8:case 12:case 16:return sw[2];case 25:return sw[3];case 28:return"default-texture";case 31:return"default-cube-texture";case 29:return"default-array-texture";case 30:return"default-3d-texture"}return sw[0]}function ow(t){switch(t){case 28:return"-texture";case 31:return"-cube-texture";case 29:return"-array-texture";case 30:return"-3d-texture";default:return"-unknown"}}function hw(t,e){for(var i=Object.entries(e),n=!1,r=0;r>2)*o.count}for(var h=0;h31&&(t.uber=!0),t.constantMacros="",t.builtins.statistics)t.constantMacros+="#define "+r+" "+t.builtins.statistics[r]+"\n"}function bw(t){var e=Object.keys(t).reduce((function(e,i){return e.reduce((function(e,n){for(var s=t[i],a=0;a0&&this.shaders.length>0},e}(Cm),Ew._effects={},Ew._layoutValid=!0,Bw=zh((Dw=Ew).prototype,"techniques",[uu],(function(){return[]})),Iw=zh(Dw.prototype,"shaders",[uu],(function(){return[]})),Mw=zh(Dw.prototype,"combinations",[uu],(function(){return[]})),Pw=zh(Dw.prototype,"hideInEditor",[uu,cu],(function(){return!1})),Cw=Dw))||Cw);A.EffectAsset=Rw;var Fw=function(t,e){return!(t.length>e.length)||47===t.charCodeAt(e.length)},Lw=function(t){var e=t.uuids,i=t.paths,n=t.types,r=t.deps,s=t.paths=Object.create(null);if(!1===t.debug){for(var a=0,o=e.length;a0&&Ww(t)>0)){Kp.remove(i);for(var n=Sy.getDeps(i),r=0,s=n.length;rthis._maxInterval?this._maxInterval:e;t-this._lastDate>1e3*i&&(this._totalNumThisPeriod=0,this._lastDate=t)},t._handleQueue=function(t,e){for(this._checkNextPeriod=!1,this._updateTime();this._queue.length>0&&this._totalNum0&&(Ze(this._handleQueue.bind(this),t,e),this._checkNextPeriod=!0)},n(e,[{key:"remoteServerAddress",get:function(){return this._remoteServerAddress}},{key:"handlers",get:function(){return this._downloaders}}],[{key:"instance",get:function(){return e._instance||(e._instance=new e),e._instance}}]),e}();wx._instance=void 0;var xx,Tx,Ax,Cx,Dx,Bx,Ix=wx.instance,Mx=wx.instance,Px=t("e3",Kh("cc.JsonAsset")((Tx=function(t){function e(e){var i;return(i=t.call(this,e)||this).json=Ax&&Ax(),i}return s(e,t),e}(Cm),Ax=zh(Tx.prototype,"json",[uu],(function(){return null})),xx=Tx))||xx);A.JsonAsset=Px;var Ex,Ox,kx=t("e2",Kh("cc.TextAsset")((Dx=function(t){function e(e){var i;return(i=t.call(this,e)||this).text=Bx&&Bx(),i}return s(e,t),e.prototype.toString=function(){return this.text},e}(Cm),Bx=zh(Dx.prototype,"text",[uu],(function(){return""})),Cx=Dx))||Cx);A.TextAsset=kx;var Rx=t("d$",Kh("cc.BufferAsset")((Ox=function(t){function e(e){var i;return(i=t.call(this,e)||this)._buffer=null,i}s(e,t);var i=e.prototype;return i.buffer=function(){return this._buffer,this._buffer},i.validate=function(){return!!this._buffer},n(e,[{key:"_nativeAsset",get:function(){return this._buffer},set:function(t){t instanceof ArrayBuffer?this._buffer=t:this._buffer=t.buffer}}]),e}(Cm),v(Ox.prototype,"_nativeAsset",[Gu],Object.getOwnPropertyDescriptor(Ox.prototype,"_nativeAsset"),Ox.prototype),Ex=Ox))||Ex);function Fx(t,e,i,n){var r=null,s=null;try{(r=new Hm)._nativeUrl=t,r._nativeAsset=e}catch(t){s=t}n(s,r)}function Lx(t,e,i,n){var r=new Px;r.json=e,n(null,r)}function Vx(t,e,i,n){var r=new kx;r.text=e,n(null,r)}function Nx(t,e,i,n){var r=new Rx;r._nativeUrl=t,r._nativeAsset=e,n(null,r)}function zx(t,e,i,n){var r=new Cm;r._nativeUrl=t,r._nativeAsset=e,n(null,r)}function Ux(t,i,n,r){var s=$p.get(i.name);s||(s="resources"===i.name?ox:new ax,i.base=i.base||t+"/",s.init(i)),e.import("virtual:///prerequisite-imports/"+s.name).then((function(){r(null,s)})).catch(r)}A.BufferAsset=Rx;var Gx=function(){function t(){this._creating=new Yp,this._producers={".png":Fx,".jpg":Fx,".bmp":Fx,".jpeg":Fx,".gif":Fx,".ico":Fx,".tiff":Fx,".webp":Fx,".image":Fx,".pvr":Fx,".pkm":Fx,".astc":Fx,".txt":Vx,".xml":Vx,".vsh":Vx,".fsh":Vx,".atlas":Vx,".tmx":Vx,".tsx":Vx,".fnt":Vx,".json":Lx,".ExportJson":Lx,".binary":Nx,".bin":Nx,".dbbin":Nx,".skel":Nx,bundle:Ux,default:zx}}var e=t.prototype;return e.register=function(t,e){"object"==typeof t?$t(this._producers,t):this._producers[t]=e},e.create=function(t,e,i,n,r){var s=this,a=this._producers[i]||this._producers.default,o=Kp.get(t);if(n.reloadAsset||!o){var h=this._creating.get(t);h?h.push(r):(this._creating.add(t,[r]),a(t,e,n,(function(e,i){!e&&i instanceof Cm&&(i._uuid=t,Zw(t,i,n.cacheAsset));for(var r=s._creating.remove(t),a=0,o=r.length;a0){var a=sm.create({input:s,progress:r,options:n,onProgress:t.onProgress,onError:sm.prototype.recycle,onComplete:function(n){var r;n||((r=t.output).push.apply(r,a.output),a.recycle()),i&&Xx(t),e(n)}});em.async(a)}else i&&Xx(t),e()}))}function Xx(t){for(var e=t.output,i=0,n=e.length;i0&&(this.downloader.maxConcurrency=r),this._files.clear(),this._parsed.clear(),this._releaseManager.init(),this.assets.clear(),this.bundles.clear(),this.packManager.init(),this.downloader.init(e,i,n),this.parser.init(),this.dependUtil.init();var s=t.importBase||hT(uT,"importBase")||"";s&&s.endsWith("/")&&(s=s.substring(0,s.length-1));var a=t.nativeBase||hT(uT,"nativeBase")||"";a&&a.endsWith("/")&&(a=a.substring(0,a.length-1)),this.generalImportBase=s,this.generalNativeBase=a,this._projectBundles=hT(uT,"projectBundles")||[];var o=hT(uT,"assetsOverrides")||{};for(var h in o)this.assetsOverrideMap.set(h,o[h])},e.getBundle=function(t){return $p.get(t)||null},e.removeBundle=function(t){t._destroy(),$p.remove(t.name)},e.loadAny=function(t,e,i,n){var r=ix(e,i,n),s=r.options,a=r.onProgress,o=r.onComplete;s.preset=s.preset||"default",t=Array.isArray(t)?t.slice():t;var h=sm.create({input:t,onProgress:a,onComplete:sx(o),options:s});tm.async(h)},e.preloadAny=function(t,e,i,n){var r=ix(e,i,n),s=r.options,a=r.onProgress,o=r.onComplete;s.preset=s.preset||"preload",t=Array.isArray(t)?t.slice():t;var h=sm.create({input:t,onProgress:a,onComplete:sx(o),options:s});em.async(h)},e.loadRemote=function(t,e,i){var n=ix(e,void 0,i),r=n.options,s=n.onComplete;r.reloadAsset||!this.assets.has(t)?(r.__isNative__=!0,r.preset=r.preset||"remote",this.loadAny({url:t},r,null,(function(e,i){e?(J(e.message,e.stack),s&&s(e,i)):Hx.create(t,i,r.ext||Ho(t),r,(function(t,e){s&&s(t,e)}))}))):sx(s)(null,this.assets.get(t))},e.loadBundle=function(t,e,i){var n=ix(e,void 0,i),r=n.options,s=n.onComplete,a=jo(t);this.bundles.has(a)?sx(s)(null,this.getBundle(a)):(r.preset=r.preset||"bundle",r.ext="bundle",r.__isNative__=!0,this.loadAny({url:t},r,null,(function(e,i){e?(J(e.message,e.stack),s&&s(e,i)):Hx.create(t,i,"bundle",r,(function(t,e){s&&s(t,e)}))})))},e.releaseAsset=function(t){qw.tryRelease(t,!0)},e.releaseUnusedAssets=function(){Kp.forEach((function(t){qw.tryRelease(t)}))},e.releaseAll=function(){Kp.forEach((function(t){qw.tryRelease(t,!0)}))},e.loadWithJson=function(){throw new Error("Only valid in Editor")},n(t,[{key:"files",get:function(){return this._files}},{key:"main",get:function(){return $p.get("main")||null}},{key:"resources",get:function(){return $p.get("resources")||null}}],[{key:"instance",get:function(){return this._instance||(this._instance=new t),this._instance}}]),t}());cT._instance=void 0,cT.Pipeline=Jp,cT.Task=sm,cT.Cache=Yp,cT.RequestItem=nT,cT.Bundle=ax,cT.BuiltinBundleName={INTERNAL:"internal",RESOURCES:"resources",MAIN:"main",START_SCENE:"start-scene"},cT.CacheManager=function(){this.cacheDir=void 0,this.cacheEnabled=void 0,this.autoClear=void 0,this.cacheInterval=void 0,this.deleteInterval=void 0,this.cachedFiles=void 0},cT.Downloader=wx,cT.Parser=Qx,cT.DependUtil=vy;var fT=t("ed",A.assetManager=cT.instance);A.AssetManager=cT;var _T,dT,pT=t("ek",function(){function t(){this._resources={},this._materialsToBeCompiled=[]}var e=t.prototype;return e.init=function(){for(var t=this._resources,e=new Uint8Array(16),i=new Uint8Array(16),n=new Uint8Array(16),r=new Uint8Array(16),s=new Uint8Array(16),a=0,o=0;o<4;o++)e[a]=0,e[a+1]=0,e[a+2]=0,e[a+3]=255,i[a]=0,i[a+1]=0,i[a+2]=0,i[a+3]=0,n[a]=119,n[a+1]=119,n[a+2]=119,n[a+3]=255,r[a]=255,r[a+1]=255,r[a+2]=255,r[a+3]=255,s[a]=127,s[a+1]=127,s[a+2]=255,s[a+3]=255,a+=4;var h=new Uint8Array(1024);a=0;for(var u=0;u<256;u++)h[a]=221,h[a+1]=221,h[a+2]=221,h[a+3]=255,a+=4;a=0;for(var l=0;l<8;l++){for(var c=0;c<8;c++)h[a]=85,h[a+1]=85,h[a+2]=85,h[a+3]=255,a+=4;a+=32}a+=32;for(var f=0;f<8;f++){for(var _=0;_<8;_++)h[a]=85,h[a+1]=85,h[a+2]=85,h[a+3]=255,a+=4;a+=32}var d={width:2,height:2,_data:e,_compressed:!1,format:35},p={width:2,height:2,_data:i,_compressed:!1,format:35},m={width:2,height:2,_data:n,_compressed:!1,format:35},g={width:2,height:2,_data:r,_compressed:!1,format:35},y={width:2,height:2,_data:s,_compressed:!1,format:35},v={width:16,height:16,_data:h,_compressed:!1,format:35},b=new Hm(d),S=new Ey;S._uuid="black-texture",S.image=b,t[S._uuid]=S;var w=new Hm(p),x=new Ey;x._uuid="empty-texture",x.image=w,t[x._uuid]=x;var T=new ib;T._uuid="black-cube-texture",T.setMipFilter(1),T.image={front:new Hm(d),back:new Hm(d),left:new Hm(d),right:new Hm(d),top:new Hm(d),bottom:new Hm(d)},t[T._uuid]=T;var C=new Hm(m),D=new Ey;D._uuid="grey-texture",D.image=C,t[D._uuid]=D;var B=new ib;B._uuid="grey-cube-texture",B.setMipFilter(1),B.image={front:new Hm(m),back:new Hm(m),left:new Hm(m),right:new Hm(m),top:new Hm(m),bottom:new Hm(m)},t[B._uuid]=B;var I=new Hm(g),M=new Ey;M._uuid="white-texture",M.image=I,t[M._uuid]=M;var P=new ib;P._uuid="white-cube-texture",P.setMipFilter(1),P.image={front:new Hm(g),back:new Hm(g),left:new Hm(g),right:new Hm(g),top:new Hm(g),bottom:new Hm(g)},t[P._uuid]=P;var E=new Hm(y),O=new Ey;O._uuid="normal-texture",O.image=E,t[O._uuid]=O;var k=new Hm(v),R=new Ey;R._uuid="default-texture",R.image=k,t[R._uuid]=R;var F=new ib;if(F.setMipFilter(1),F._uuid="default-cube-texture",F.image={front:new Hm(v),back:new Hm(v),left:new Hm(v),right:new Hm(v),top:new Hm(v),bottom:new Hm(v)},t[F._uuid]=F,A.SpriteFrame){var L=new A.SpriteFrame,V=b,N=new Ey;N.image=V,L.texture=N,L._uuid="default-spriteframe",t[L._uuid]=L}},e.addAsset=function(t,e){this._resources[t]=e},e.get=function(t){return this._resources[t]},e.loadBuiltinAssets=function(){var t=this,e=ze.querySettings("engine","builtinAssets");if(!e)return Promise.resolve();var i=this._resources;return new Promise((function(n,r){fT.loadBundle("internal",(function(s){s?r(s):fT.loadAny(e,(function(e,s){e?r(e):(s.forEach((function(e){i[e.name]=e,qw.addIgnoredAsset(e),e instanceof A.Material&&t._materialsToBeCompiled.push(e)})),n())}))}))}))},e.compileBuiltinMaterial=function(){for(var t=0;t=1024)&&m.lightingMap.objectID===o.objectID&&m.useReflectionProbeType===l&&m.reflectionProbeCubemap.objectID===h.objectID&&m.reflectionProbePlanarMap.objectID===u.objectID&&m.stride===r){if(m.count>=m.capacity){m.capacity<<=1;var g=m.stride*m.capacity,y=m.data;m.data=new Uint8Array(g),m.data.set(y),m.vb.resize(g)}return m.shader=c,m.descriptorSet=f,m.data.set(n.buffer,m.stride*m.count++),void(this.hasPendingModels=!0)}}for(var v=this._device.createBuffer(new ud(10,3,32*r,r)),b=new Uint8Array(32*r),S=s.vertexBuffers.slice(),w=s.attributes.slice(),x=s.indexBuffer,T=0;T>2,s=this._getBlockView(n,i),a=tw(t),o=0;o>2)*s,l=0;l+h.length<=u;l+=h.length)a.set(h,r+l);this._rootBufferDirty=!0}},e.resetTexture=function(t,e){var i=this.getHandle(t);if(i){var n,r=QS(i),s=ZS(i),a=this._properties[t],o=a&&a.value,h=(n="string"==typeof o?mT.get(""+o+ow(r)):o||mT.get(aw(r)))&&n.getGFXTexture(),u=a&&void 0!==a.samplerHash?Op.unpackFromHash(a.samplerHash):n&&n.getSamplerInfo(),l=this._device.getSampler(u);this._descriptorSet.bindSampler(s,l,e||0),this._descriptorSet.bindTexture(s,h,e||0)}},e.resetUBOs=function(){for(var t=0;t>2)*r.count,u=0;u+o.length<=h;u+=o.length)s.set(o,i+u);i+=h}this._rootBufferDirty=!0},e.resetTextures=function(){var t=this;if(A.rendering)this._shaderInfo.descriptors[1].samplerTextures.forEach((function(e){for(var i=0;i=0;--e){var i=t[e];if(i.window.swapchain)return void(VT=i)}VT=null}function zT(t,e,i,n,r){if(!qS()&&n&&n.enabled&&r===VT){var s=n.subModels[0],a=s.inputAssembler,o=s.passes,h=s.shaders,u=s.descriptorSet;CT.width=DT.width=r.window.width,CT.height=DT.height=r.window.height;var l=AT.getOrCreatePipelineState(t,o[0],h[0],e,a);i.setViewport(CT),i.setScissor(DT),i.bindPipelineState(l),i.bindDescriptorSet(1,o[0].descriptorSet),i.bindDescriptorSet(2,u),i.bindInputAssembler(a),i.draw(a)}}var UT=new Vn,GT=t("e8",(IT=Kh("cc.Material"),MT=Ou(Rw),IT((ET=function(t){function e(e){var i;return(i=t.call(this,e)||this)._effectAsset=OT&&OT(),i._techIdx=kT&&kT(),i._defines=RT&&RT(),i._states=FT&&FT(),i._props=LT&<(),i._passes=[],i._hash=0,i}s(e,t),e.getHash=function(t){for(var e,i=0,n=p(t.passes);!(e=n()).done;)i^=e.value.hash;return i};var i=e.prototype;return i.initialize=function(t){this._passes.length?at(12005):(this._defines||(this._defines=[]),this._states||(this._states=[]),this._props||(this._props=[]),this._fillInfo(t),this._update())},i.reset=function(t){this.initialize(t)},i.destroy=function(){return this._doDestroy(),t.prototype.destroy.call(this)},i.recompileShaders=function(){at(16370,this.name)},i.overridePipelineStates=function(){at(16371,this.name)},i.onLoaded=function(){this._update()},i.resetUniforms=function(t){void 0===t&&(t=!0),this._props.length=this._passes.length;for(var e=0;e=this._passes.length&&at(16372,i);var h=this._passes[i];this._uploadProperty(h,t,e)&&(this._props[h.propertyIndex][t]=e,n=!0)}n||at(16373,t)},i.getProperty=function(t,e){if(void 0===e)for(var i=this._props,n=i.length,r=0;r=this._passes.length)return at(16372,e),null;var a=this._props[this._passes[e].propertyIndex];if(t in a)return a[t]}return null},i.copy=function(t,e){this._techIdx=t._techIdx,this._props.length=t._props.length;for(var i=0;i0},n(e,[{key:"effectAsset",get:function(){return this._effectAsset}},{key:"effectName",get:function(){return this._effectAsset?this._effectAsset.name:""}},{key:"technique",get:function(){return this._techIdx}},{key:"passes",get:function(){return this._passes}},{key:"hash",get:function(){return this._hash}},{key:"parent",get:function(){return null}},{key:"owner",get:function(){return null}}]),e}(Cm),OT=zh(ET.prototype,"_effectAsset",[MT],(function(){return null})),kT=zh(ET.prototype,"_techIdx",[uu],(function(){return 0})),RT=zh(ET.prototype,"_defines",[uu],(function(){return[]})),FT=zh(ET.prototype,"_states",[uu],(function(){return[]})),LT=zh(ET.prototype,"_props",[uu],(function(){return[]})),PT=ET))||PT));A.Material=GT;var HT=Ee({Low_256x256:256,Medium_512x512:512,High_1024x1024:1024,Ultra_2048x2048:2048}),WT=Ee({Planar:0,ShadowMap:1}),jT=Ee({HARD:0,SOFT:1,SOFT_2X:2,SOFT_4X:3}),qT=Ee({LEVEL_1:1,LEVEL_2:2,LEVEL_3:3,LEVEL_4:4}),XT=Ee({NONE:1,RemoveDuplicates:2,DisableRotationFix:3}),YT=WT.ShadowMap+1,JT=function(){function t(){this.fixedSphere=new Js(0,0,0,.01),this.maxReceived=4,this._matLight=new Kr,this._material=null,this._instancingMaterial=null,this._enabled=!1,this._type=YT,this._distance=0,this._planeBias=1,this._normal=new ir(0,1,0),this._shadowColor=new cr(0,0,0,76),this._size=new ds(1024,1024),this._shadowMapDirty=!1}var e=t.prototype;return e.getPlanarShader=function(t){this._material||(this._material=new GT,this._material.initialize({effectName:"pipeline/planar-shadow"}));var e=this._material.passes;return e.length>0?e[0].getShaderVariant(t):null},e.initialize=function(t){this._enabled=t.enabled,this._type=this.enabled?t.type:YT,this.normal=t.planeDirection,this.distance=t.planeHeight,this.planeBias=t.planeBias,this.shadowColor=t.shadowColor,this.maxReceived=t.maxReceived,t.shadowMapSize!==this._size.x&&(this.size.set(t.shadowMapSize,t.shadowMapSize),this._shadowMapDirty=!0)},e.activate=function(){if(this._enabled)if(this.type===WT.Planar)this._updatePlanarInfo();else{var t=A.director.root;t.pipeline.macros.CC_SHADOW_TYPE=2,t.onGlobalPipelineStateChanged()}else{var e=A.director.root;e.pipeline.macros.CC_SHADOW_TYPE=0,e.onGlobalPipelineStateChanged()}},e._updatePlanarInfo=function(){this._material||(this._material=new GT,this._material.initialize({effectName:"pipeline/planar-shadow"}));var t=A.director.root;t.pipeline.macros.CC_SHADOW_TYPE=1,t.onGlobalPipelineStateChanged()},e.destroy=function(){this._material&&this._material.destroy(),this._instancingMaterial&&this._instancingMaterial.destroy(),this.fixedSphere.destroy()},n(t,[{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled=t,this.activate()}},{key:"type",get:function(){return this._type},set:function(t){this._type=this.enabled?t:YT,this.activate()}},{key:"normal",get:function(){return this._normal},set:function(t){ir.copy(this._normal,t)}},{key:"distance",get:function(){return this._distance},set:function(t){this._distance=t}},{key:"planeBias",get:function(){return this._planeBias},set:function(t){this._planeBias=t}},{key:"shadowColor",get:function(){return this._shadowColor},set:function(t){this._shadowColor=t}},{key:"size",get:function(){return this._size},set:function(t){this._size.set(t)}},{key:"shadowMapDirty",get:function(){return this._shadowMapDirty},set:function(t){this._shadowMapDirty=t}},{key:"matLight",get:function(){return this._matLight}},{key:"material",get:function(){return this._material}},{key:"instancingMaterial",get:function(){return this._instancingMaterial}}]),t}();JT.MAX_FAR=2e3,JT.COEFFICIENT_OF_EXPANSION=2*Math.sqrt(3),A.Shadows=JT;var KT=function(t){function e(e,i){var n;(n=t.call(this,e.root)||this)._dontNotify=!1,n._parent=e,n._owner=i,n._doInit(n._parent,!0),n._shaderInfo.blocks.forEach((function(t){var e=n._blocks[t.binding],i=n._parent.blocks[t.binding];e.set(i)})),n._rootBufferDirty=!0;var r=n._parent,s=n._descriptorSet;return n._shaderInfo.samplerTextures.forEach((function(t){for(var e=0;e0)for(var h=0;h=0&&s.node.getWritableComponents().splice(a,1)}}}function xI(t,e,i){if(!(e.length<=0))for(var n=null,r=0;r0){var h=o.pop();if(!h)continue;for(var u=0;u0){var g=p.pop();if(!g)return;for(var y=0;yMath.abs(e)?t:-e},e}(NI),WI=function(t){function e(e){var i;return(i=t.call(this)||this).up=e.up,i.down=e.down,i.left=e.left,i.right=e.right,i.xAxis=new HI({positive:i.right,negative:i.left}),i.yAxis=new HI({positive:i.up,negative:i.down}),i}return s(e,t),e.prototype.getValue=function(){return new ds(this.xAxis.getValue(),this.yAxis.getValue())},e}(zI);!function(t){function e(e){var i;return(i=t.call(this)||this).up=e.up,i.down=e.down,i.left=e.left,i.right=e.right,i.forward=e.forward,i.backward=e.backward,i.xAxis=new HI({positive:i.right,negative:i.left}),i.yAxis=new HI({positive:i.up,negative:i.down}),i.zAxis=new HI({positive:i.forward,negative:i.backward}),i}s(e,t),e.prototype.getValue=function(){return new ir(this.xAxis.getValue(),this.yAxis.getValue(),this.zAxis.getValue())}}(UI);var jI,qI=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.prototype.getValue=function(){return t.prototype.getValue.call(this)},e}(NI),XI=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e}(WI),YI=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e}(WI),JI=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.prototype.getValue=function(){return t.prototype.getValue.call(this)},e}(GI),KI=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.prototype.getValue=function(){return t.prototype.getValue.call(this)},e}(UI),QI=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.prototype.getValue=function(){return t.prototype.getValue.call(this)},e}(NI),ZI="left",$I="right",tM=[];!function(t){t[t.HAND_LEFT=1]="HAND_LEFT",t[t.HAND_RIGHT=4]="HAND_RIGHT",t[t.AIM_LEFT=2]="AIM_LEFT",t[t.AIM_RIGHT=5]="AIM_RIGHT"}(jI||(jI={}));var eM,iM,nM,rM,sM,aM=function(){function t(t){var e;this._deviceId=-1,this._connected=!1,this._webPoseState=((e={})[jI.HAND_LEFT]={position:ir.ZERO,orientation:kr.IDENTITY},e[jI.HAND_RIGHT]={position:ir.ZERO,orientation:kr.IDENTITY},e[jI.AIM_LEFT]={position:ir.ZERO,orientation:kr.IDENTITY},e[jI.AIM_RIGHT]={position:ir.ZERO,orientation:kr.IDENTITY},e),this._deviceId=t,this._initInputSource()}t._init=function(){Vo.hasFeature(Ro.EVENT_GAMEPAD)&&t._registerEvent()},t._on=function(e,i,n){t._eventTarget.on(e,i,n)},t._removeInputDevice=function(e){var i=t.all.findIndex((function(t){return t.deviceId===e}));-1!==i&&be(t.all,i)},t._getOrCreateInputDevice=function(e,i){var n=t.all.find((function(t){return t.deviceId===e}));return n||(n=new t(e),t.all.push(n)),n._connected=i,n},t._ensureDirectorDefined=function(e){t._intervalId=setInterval((function(){C.director&&C.Director&&(clearInterval(t._intervalId),t._intervalId=-1,e())}),50)},t._updateGamepadCnt=function(){for(var e=0,i=0,n=t._cachedWebGamepads.length;i.01){a=t._getOrCreateInputDevice(r.index,!0);break}}if(a){e.push(a);continue}for(var c=s.axes,f=0;f.01){a=t._getOrCreateInputDevice(r.index,!0);break}}if(a){e.push(a);continue}}}}t._cachedWebGamepads=i}}},t._scanGamepads=function(){tM.length=0,t._scanWebGamepads(tM),t._scanWebXRGamepads(tM);for(var e=0;e0?{negative:0,positive:e}:t<0?{negative:e,positive:0}:{negative:0,positive:0}},e._updateWebPoseState=function(t){t.code!==jI.HAND_LEFT&&t.code!==jI.AIM_LEFT&&t.code!==jI.HAND_RIGHT&&t.code!==jI.AIM_RIGHT||(this._webPoseState[t.code]={position:new ir(t.position.x,t.position.y,t.position.z),orientation:new kr(t.orientation.x,t.orientation.y,t.orientation.z,t.orientation.w)})},e._initInputSource=function(){var e=this;this._buttonNorth=new qI,this._buttonNorth.getValue=function(){if(-1===e.deviceId){var i,n=null==(i=t._getWebXRGamepadMap())?void 0:i.get(ZI);return n&&n.buttons.length>5?n.buttons[5].value:0}var r=t._getWebGamepad(e.deviceId);return r?r.buttons[3].value:0},this._buttonEast=new qI,this._buttonEast.getValue=function(){if(-1===e.deviceId){var i,n=null==(i=t._getWebXRGamepadMap())?void 0:i.get($I);return n&&n.buttons.length>5?n.buttons[5].value:0}var r=t._getWebGamepad(e.deviceId);return r?r.buttons[1].value:0},this._buttonWest=new qI,this._buttonWest.getValue=function(){if(-1===e.deviceId){var i,n=null==(i=t._getWebXRGamepadMap())?void 0:i.get(ZI);return n&&n.buttons.length>4?n.buttons[4].value:0}var r=t._getWebGamepad(e.deviceId);return r?r.buttons[2].value:0},this._buttonSouth=new qI,this._buttonSouth.getValue=function(){if(-1===e.deviceId){var i,n=null==(i=t._getWebXRGamepadMap())?void 0:i.get($I);return n&&n.buttons.length>4?n.buttons[4].value:0}var r=t._getWebGamepad(e.deviceId);return r?r.buttons[0].value:0},this._buttonL1=new qI,this._buttonL1.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[4].value:0},this._buttonL2=new qI,this._buttonL2.getValue=function(){if(-1===e.deviceId){var i,n=null==(i=t._getWebXRGamepadMap())?void 0:i.get(ZI);return n&&n.buttons.length>0?n.buttons[0].value:0}var r=t._getWebGamepad(e.deviceId);return r?r.buttons[6].value:0},this._buttonL3=new qI,this._buttonL3.getValue=function(){if(-1===e.deviceId){var i,n=null==(i=t._getWebXRGamepadMap())?void 0:i.get(ZI);if(n){if(n.buttons.length>3&&0!==n.buttons[3].value)return n.buttons[3].value;if(n.buttons.length>2&&0!==n.buttons[2].value)return n.buttons[2].value}return 0}var r=t._getWebGamepad(e.deviceId);return r?r.buttons[10].value:0},this._buttonR1=new qI,this._buttonR1.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[5].value:0},this._buttonR2=new qI,this._buttonR2.getValue=function(){if(-1===e.deviceId){var i,n=null==(i=t._getWebXRGamepadMap())?void 0:i.get($I);return n&&n.buttons.length>0?n.buttons[0].value:0}var r=t._getWebGamepad(e.deviceId);return r?r.buttons[7].value:0},this._buttonR3=new qI,this._buttonR3.getValue=function(){if(-1===e.deviceId){var i,n=null==(i=t._getWebXRGamepadMap())?void 0:i.get($I);if(n){if(n.buttons.length>3&&0!==n.buttons[3].value)return n.buttons[3].value;if(n.buttons.length>2&&0!==n.buttons[2].value)return n.buttons[2].value}return 0}var r=t._getWebGamepad(e.deviceId);return r?r.buttons[11].value:0},this._buttonShare=new qI,this._buttonShare.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[8].value:0},this._buttonOptions=new qI,this._buttonOptions.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[9].value:0};var i=new qI;i.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[12].value:0};var n=new qI;n.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[13].value:0};var r=new qI;r.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[14].value:0};var s=new qI;s.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[15].value:0},this._dpad=new XI({up:i,down:n,left:r,right:s});var a=new qI;a.getValue=function(){if(-1===e.deviceId)return 0;var i=t._getWebGamepad(e.deviceId);return i?e._axisToButtons(i.axes[1]).negative:0};var o=new qI;o.getValue=function(){if(-1===e.deviceId)return 0;var i=t._getWebGamepad(e.deviceId);return i?e._axisToButtons(i.axes[1]).positive:0};var h=new qI;h.getValue=function(){if(-1===e.deviceId)return 0;var i=t._getWebGamepad(e.deviceId);return i?e._axisToButtons(i.axes[0]).negative:0};var u=new qI;u.getValue=function(){if(-1===e.deviceId)return 0;var i=t._getWebGamepad(e.deviceId);return i?e._axisToButtons(i.axes[0]).positive:0},this._leftStick=new YI({up:a,down:o,left:h,right:u});var l=new qI;l.getValue=function(){if(-1===e.deviceId)return 0;var i=t._getWebGamepad(e.deviceId);return i?e._axisToButtons(i.axes[3]).negative:0};var c=new qI;c.getValue=function(){if(-1===e.deviceId)return 0;var i=t._getWebGamepad(e.deviceId);return i?e._axisToButtons(i.axes[3]).positive:0};var f=new qI;f.getValue=function(){if(-1===e.deviceId)return 0;var i=t._getWebGamepad(e.deviceId);return i?e._axisToButtons(i.axes[2]).negative:0};var _=new qI;_.getValue=function(){if(-1===e.deviceId)return 0;var i=t._getWebGamepad(e.deviceId);return i?e._axisToButtons(i.axes[2]).positive:0},this._rightStick=new YI({up:l,down:c,left:f,right:_}),this._buttonStart=new qI,this._buttonStart.getValue=function(){return 0},this._gripLeft=new qI,this._gripLeft.getValue=function(){return e.deviceId,0},this._gripRight=new qI,this._gripRight.getValue=function(){if(-1===e.deviceId){var i,n=null==(i=t._getWebXRGamepadMap())?void 0:i.get($I);if(n&&n.buttons.length>1)return n.buttons[1].value}return 0},this._handLeftPosition=new KI,this._handLeftPosition.getValue=function(){return e._webPoseState[jI.HAND_LEFT].position},this._handLeftOrientation=new JI,this._handLeftOrientation.getValue=function(){return e._webPoseState[jI.HAND_LEFT].orientation},this._handRightPosition=new KI,this._handRightPosition.getValue=function(){return e._webPoseState[jI.HAND_RIGHT].position},this._handRightOrientation=new JI,this._handRightOrientation.getValue=function(){return e._webPoseState[jI.HAND_RIGHT].orientation},this._aimLeftPosition=new KI,this._aimLeftPosition.getValue=function(){return e._webPoseState[jI.AIM_LEFT].position},this._aimLeftOrientation=new JI,this._aimLeftOrientation.getValue=function(){return e._webPoseState[jI.AIM_LEFT].orientation},this._aimRightPosition=new KI,this._aimRightPosition.getValue=function(){return e._webPoseState[jI.AIM_RIGHT].position},this._aimRightOrientation=new JI,this._aimRightOrientation.getValue=function(){return e._webPoseState[jI.AIM_RIGHT].orientation}},n(t,[{key:"buttonNorth",get:function(){return this._buttonNorth}},{key:"buttonEast",get:function(){return this._buttonEast}},{key:"buttonWest",get:function(){return this._buttonWest}},{key:"buttonSouth",get:function(){return this._buttonSouth}},{key:"buttonL1",get:function(){return this._buttonL1}},{key:"buttonL2",get:function(){return this._buttonL2}},{key:"buttonL3",get:function(){return this._buttonL3}},{key:"buttonR1",get:function(){return this._buttonR1}},{key:"buttonR2",get:function(){return this._buttonR2}},{key:"buttonR3",get:function(){return this._buttonR3}},{key:"buttonShare",get:function(){return this._buttonShare}},{key:"buttonOptions",get:function(){return this._buttonOptions}},{key:"dpad",get:function(){return this._dpad}},{key:"leftStick",get:function(){return this._leftStick}},{key:"rightStick",get:function(){return this._rightStick}},{key:"buttonStart",get:function(){return this._buttonStart}},{key:"gripLeft",get:function(){return this._gripLeft}},{key:"gripRight",get:function(){return this._gripRight}},{key:"handLeftPosition",get:function(){return this._handLeftPosition}},{key:"handLeftOrientation",get:function(){return this._handLeftOrientation}},{key:"handRightPosition",get:function(){return this._handRightPosition}},{key:"handRightOrientation",get:function(){return this._handRightOrientation}},{key:"aimLeftPosition",get:function(){return this._aimLeftPosition}},{key:"aimLeftOrientation",get:function(){return this._aimLeftOrientation}},{key:"aimRightPosition",get:function(){return this._aimRightPosition}},{key:"aimRightOrientation",get:function(){return this._aimRightOrientation}},{key:"deviceId",get:function(){return this._deviceId}},{key:"connected",get:function(){return this._connected}}]),t}();aM.all=[],aM.xr=null,aM._eventTarget=new Io,aM._cachedWebGamepads=[],aM._cachedWebXRGamepadMap=null,aM._intervalId=-1,aM._totalGamepadCnt=0,function(t){t[t.BUTTON_EAST=0]="BUTTON_EAST",t[t.BUTTON_SOUTH=1]="BUTTON_SOUTH",t[t.BUTTON_WEST=2]="BUTTON_WEST",t[t.BUTTON_NORTH=3]="BUTTON_NORTH",t[t.BUTTON_TRIGGER_LEFT=4]="BUTTON_TRIGGER_LEFT",t[t.BUTTON_TRIGGER_RIGHT=5]="BUTTON_TRIGGER_RIGHT",t[t.TRIGGER_LEFT=6]="TRIGGER_LEFT",t[t.TRIGGER_RIGHT=7]="TRIGGER_RIGHT",t[t.GRIP_LEFT=8]="GRIP_LEFT",t[t.GRIP_RIGHT=9]="GRIP_RIGHT",t[t.BUTTON_LEFT_STICK=10]="BUTTON_LEFT_STICK",t[t.LEFT_STICK_UP=11]="LEFT_STICK_UP",t[t.LEFT_STICK_DOWN=12]="LEFT_STICK_DOWN",t[t.LEFT_STICK_LEFT=13]="LEFT_STICK_LEFT",t[t.LEFT_STICK_RIGHT=14]="LEFT_STICK_RIGHT",t[t.BUTTON_RIGHT_STICK=15]="BUTTON_RIGHT_STICK",t[t.RIGHT_STICK_UP=16]="RIGHT_STICK_UP",t[t.RIGHT_STICK_DOWN=17]="RIGHT_STICK_DOWN",t[t.RIGHT_STICK_LEFT=18]="RIGHT_STICK_LEFT",t[t.RIGHT_STICK_RIGHT=19]="RIGHT_STICK_RIGHT",t[t.ROKID_MENU=20]="ROKID_MENU",t[t.ROKID_START=21]="ROKID_START"}(eM||(eM={})),function(t){t[t.KET_CLICK=0]="KET_CLICK",t[t.KET_STICK=1]="KET_STICK",t[t.KET_GRAB=2]="KET_GRAB",t[t.KET_TOUCH=3]="KET_TOUCH"}(iM||(iM={})),function(t){t[t.UNDEFINE=0]="UNDEFINE",t[t.A=1]="A",t[t.B=2]="B",t[t.X=3]="X",t[t.Y=4]="Y",t[t.L1=5]="L1",t[t.R1=6]="R1",t[t.MINUS=7]="MINUS",t[t.PLUS=8]="PLUS",t[t.L3=9]="L3",t[t.R3=10]="R3",t[t.MENU=11]="MENU",t[t.START=12]="START",t[t.TRIGGER_LEFT=13]="TRIGGER_LEFT",t[t.TRIGGER_RIGHT=14]="TRIGGER_RIGHT"}(nM||(nM={})),function(t){t[t.UNDEFINE=0]="UNDEFINE",t[t.X=1]="X",t[t.Y=2]="Y",t[t.LEFT_STICK_X=3]="LEFT_STICK_X",t[t.LEFT_STICK_Y=4]="LEFT_STICK_Y",t[t.RIGHT_STICK_X=5]="RIGHT_STICK_X",t[t.RIGHT_STICK_Y=6]="RIGHT_STICK_Y",t[t.L2=7]="L2",t[t.R2=8]="R2",t[t.LEFT_GRIP=9]="LEFT_GRIP",t[t.RIGHT_GRIP=10]="RIGHT_GRIP"}(rM||(rM={})),function(t){t[t.UNDEFINE=0]="UNDEFINE",t[t.A=1]="A",t[t.B=2]="B",t[t.X=3]="X",t[t.Y=4]="Y",t[t.LEFT_TRIGGER=5]="LEFT_TRIGGER",t[t.RIGHT_TRIGGER=6]="RIGHT_TRIGGER",t[t.LEFT_THUMBSTICK=7]="LEFT_THUMBSTICK",t[t.RIGHT_THUMBSTICK=8]="RIGHT_THUMBSTICK"}(sM||(sM={}));var oM,hM={1:eM.BUTTON_EAST,2:eM.BUTTON_SOUTH,3:eM.BUTTON_NORTH,4:eM.BUTTON_WEST,9:eM.BUTTON_LEFT_STICK,10:eM.BUTTON_RIGHT_STICK,11:eM.ROKID_MENU,12:eM.ROKID_START,13:eM.BUTTON_TRIGGER_LEFT,14:eM.BUTTON_TRIGGER_RIGHT},uM=function(){function t(){var t,e,i=this;this._eventTarget=new Io,this._nativeButtonState=((t={})[eM.BUTTON_SOUTH]=0,t[eM.BUTTON_EAST]=0,t[eM.BUTTON_WEST]=0,t[eM.BUTTON_NORTH]=0,t[eM.BUTTON_TRIGGER_LEFT]=0,t[eM.BUTTON_TRIGGER_RIGHT]=0,t[eM.TRIGGER_LEFT]=0,t[eM.TRIGGER_RIGHT]=0,t[eM.GRIP_LEFT]=0,t[eM.GRIP_RIGHT]=0,t[eM.LEFT_STICK_UP]=0,t[eM.LEFT_STICK_DOWN]=0,t[eM.LEFT_STICK_LEFT]=0,t[eM.LEFT_STICK_RIGHT]=0,t[eM.RIGHT_STICK_UP]=0,t[eM.RIGHT_STICK_DOWN]=0,t[eM.RIGHT_STICK_LEFT]=0,t[eM.RIGHT_STICK_RIGHT]=0,t[eM.BUTTON_LEFT_STICK]=0,t[eM.BUTTON_RIGHT_STICK]=0,t[eM.ROKID_MENU]=0,t[eM.ROKID_START]=0,t),this._nativeTouchState=((e={})[sM.UNDEFINE]=0,e[sM.A]=0,e[sM.B]=0,e[sM.X]=0,e[sM.Y]=0,e[sM.LEFT_TRIGGER]=0,e[sM.RIGHT_TRIGGER]=0,e[sM.LEFT_THUMBSTICK]=0,e[sM.RIGHT_THUMBSTICK]=0,e),this._initInputSource(),window.addEventListener("xr-remote-input",(function(t){var e=t,n=e.detail.keyEventType,r=e.detail.stickAxisCode,s=e.detail.stickAxisValue,a=e.detail.stickKeyCode,o=e.detail.isButtonPressed,h=e.detail.touchCode,u=e.detail.touchValue;if(n===iM.KET_CLICK){var l=hM[a];i._nativeButtonState[l]=o?1:0}else if(n===iM.KET_STICK||n===iM.KET_GRAB){var c,f,_;switch(r){case rM.LEFT_STICK_X:c=eM.LEFT_STICK_LEFT,f=eM.LEFT_STICK_RIGHT,_=i._axisToButtons(s);break;case rM.LEFT_STICK_Y:c=eM.LEFT_STICK_DOWN,f=eM.LEFT_STICK_UP,_=i._axisToButtons(s);break;case rM.RIGHT_STICK_X:c=eM.RIGHT_STICK_LEFT,f=eM.RIGHT_STICK_RIGHT,_=i._axisToButtons(s);break;case rM.RIGHT_STICK_Y:c=eM.RIGHT_STICK_DOWN,f=eM.RIGHT_STICK_UP,_=i._axisToButtons(s);break;case rM.L2:i._nativeButtonState[eM.TRIGGER_LEFT]=s;break;case rM.R2:i._nativeButtonState[eM.TRIGGER_RIGHT]=s;break;case rM.LEFT_GRIP:i._nativeButtonState[eM.GRIP_LEFT]=s;break;case rM.RIGHT_GRIP:i._nativeButtonState[eM.GRIP_RIGHT]=s}c&&f&&_&&(i._nativeButtonState[c]=_.negative,i._nativeButtonState[f]=_.positive)}else if(n===iM.KET_TOUCH)switch(h){case sM.A:case sM.B:case sM.X:case sM.Y:case sM.LEFT_TRIGGER:case sM.RIGHT_TRIGGER:case sM.LEFT_THUMBSTICK:case sM.RIGHT_THUMBSTICK:i._nativeTouchState[h]=u}i._eventTarget.emit("handle-input",new Ky("handle-input",i))}))}var e=t.prototype;return e._axisToButtons=function(t){var e=Math.abs(t);return t>0?{negative:0,positive:e}:t<0?{negative:e,positive:0}:{negative:0,positive:0}},e._on=function(t,e,i){this._eventTarget.on(t,e,i)},e._initInputSource=function(){var t=this;this._buttonNorth=new qI,this._buttonNorth.getValue=function(){return t._nativeButtonState[eM.BUTTON_NORTH]},this._buttonEast=new qI,this._buttonEast.getValue=function(){return t._nativeButtonState[eM.BUTTON_EAST]},this._buttonWest=new qI,this._buttonWest.getValue=function(){return t._nativeButtonState[eM.BUTTON_WEST]},this._buttonSouth=new qI,this._buttonSouth.getValue=function(){return t._nativeButtonState[eM.BUTTON_SOUTH]},this._buttonTriggerLeft=new qI,this._buttonTriggerLeft.getValue=function(){return t._nativeButtonState[eM.BUTTON_TRIGGER_LEFT]},this._buttonTriggerRight=new qI,this._buttonTriggerRight.getValue=function(){return t._nativeButtonState[eM.BUTTON_TRIGGER_RIGHT]},this._triggerLeft=new qI,this._triggerLeft.getValue=function(){return t._nativeButtonState[eM.TRIGGER_LEFT]},this._triggerRight=new qI,this._triggerRight.getValue=function(){return t._nativeButtonState[eM.TRIGGER_RIGHT]},this._gripLeft=new qI,this._gripLeft.getValue=function(){return t._nativeButtonState[eM.GRIP_LEFT]},this._gripRight=new qI,this._gripRight.getValue=function(){return t._nativeButtonState[eM.GRIP_RIGHT]},this._buttonLeftStick=new qI,this._buttonLeftStick.getValue=function(){return t._nativeButtonState[eM.BUTTON_LEFT_STICK]};var e=new qI;e.getValue=function(){return t._nativeButtonState[eM.LEFT_STICK_UP]};var i=new qI;i.getValue=function(){return t._nativeButtonState[eM.LEFT_STICK_DOWN]};var n=new qI;n.getValue=function(){return t._nativeButtonState[eM.LEFT_STICK_LEFT]};var r=new qI;r.getValue=function(){return t._nativeButtonState[eM.LEFT_STICK_RIGHT]},this._leftStick=new YI({up:e,down:i,left:n,right:r}),this._buttonRightStick=new qI,this._buttonRightStick.getValue=function(){return t._nativeButtonState[eM.BUTTON_RIGHT_STICK]};var s=new qI;s.getValue=function(){return t._nativeButtonState[eM.RIGHT_STICK_UP]};var a=new qI;a.getValue=function(){return t._nativeButtonState[eM.RIGHT_STICK_DOWN]};var o=new qI;o.getValue=function(){return t._nativeButtonState[eM.RIGHT_STICK_LEFT]};var h=new qI;h.getValue=function(){return t._nativeButtonState[eM.RIGHT_STICK_RIGHT]},this._rightStick=new YI({up:s,down:a,left:o,right:h}),this._buttonOptions=new qI,this._buttonOptions.getValue=function(){return t._nativeButtonState[eM.ROKID_MENU]},this._buttonStart=new qI,this._buttonStart.getValue=function(){return t._nativeButtonState[eM.ROKID_START]},this._handLeftPosition=new KI,this._handLeftPosition.getValue=function(){return ir.ZERO},this._handLeftOrientation=new JI,this._handLeftOrientation.getValue=function(){return kr.IDENTITY},this._handRightPosition=new KI,this._handRightPosition.getValue=function(){return ir.ZERO},this._handRightOrientation=new JI,this._handRightOrientation.getValue=function(){return kr.IDENTITY},this._aimLeftPosition=new KI,this._aimLeftPosition.getValue=function(){return ir.ZERO},this._aimLeftOrientation=new JI,this._aimLeftOrientation.getValue=function(){return kr.IDENTITY},this._aimRightPosition=new KI,this._aimRightPosition.getValue=function(){return ir.ZERO},this._aimRightOrientation=new JI,this._aimRightOrientation.getValue=function(){return kr.IDENTITY},this._touchButtonA=new QI,this._touchButtonA.getValue=function(){return t._nativeTouchState[sM.A]},this._touchButtonB=new QI,this._touchButtonB.getValue=function(){return t._nativeTouchState[sM.B]},this._touchButtonX=new QI,this._touchButtonX.getValue=function(){return t._nativeTouchState[sM.X]},this._touchButtonY=new QI,this._touchButtonY.getValue=function(){return t._nativeTouchState[sM.Y]},this._touchButtonTriggerLeft=new QI,this._touchButtonTriggerLeft.getValue=function(){return t._nativeTouchState[sM.LEFT_TRIGGER]},this._touchButtonTriggerRight=new QI,this._touchButtonTriggerRight.getValue=function(){return t._nativeTouchState[sM.RIGHT_TRIGGER]},this._touchButtonThumbStickLeft=new QI,this._touchButtonThumbStickLeft.getValue=function(){return t._nativeTouchState[sM.LEFT_THUMBSTICK]},this._touchButtonThumbStickRight=new QI,this._touchButtonThumbStickRight.getValue=function(){return t._nativeTouchState[sM.RIGHT_THUMBSTICK]}},n(t,[{key:"buttonNorth",get:function(){return this._buttonNorth}},{key:"buttonEast",get:function(){return this._buttonEast}},{key:"buttonWest",get:function(){return this._buttonWest}},{key:"buttonSouth",get:function(){return this._buttonSouth}},{key:"buttonTriggerLeft",get:function(){return this._buttonTriggerLeft}},{key:"buttonTriggerRight",get:function(){return this._buttonTriggerRight}},{key:"triggerLeft",get:function(){return this._triggerLeft}},{key:"triggerRight",get:function(){return this._triggerRight}},{key:"gripLeft",get:function(){return this._gripLeft}},{key:"gripRight",get:function(){return this._gripRight}},{key:"leftStick",get:function(){return this._leftStick}},{key:"rightStick",get:function(){return this._rightStick}},{key:"buttonLeftStick",get:function(){return this._buttonLeftStick}},{key:"buttonRightStick",get:function(){return this._buttonRightStick}},{key:"buttonOptions",get:function(){return this._buttonOptions}},{key:"buttonStart",get:function(){return this._buttonStart}},{key:"handLeftPosition",get:function(){return this._handLeftPosition}},{key:"handLeftOrientation",get:function(){return this._handLeftOrientation}},{key:"handRightPosition",get:function(){return this._handRightPosition}},{key:"handRightOrientation",get:function(){return this._handRightOrientation}},{key:"aimLeftPosition",get:function(){return this._aimLeftPosition}},{key:"aimLeftOrientation",get:function(){return this._aimLeftOrientation}},{key:"aimRightPosition",get:function(){return this._aimRightPosition}},{key:"aimRightOrientation",get:function(){return this._aimRightOrientation}},{key:"touchButtonA",get:function(){return this._touchButtonA}},{key:"touchButtonB",get:function(){return this._touchButtonB}},{key:"touchButtonX",get:function(){return this._touchButtonX}},{key:"touchButtonY",get:function(){return this._touchButtonY}},{key:"touchButtonTriggerLeft",get:function(){return this._touchButtonTriggerLeft}},{key:"touchButtonTriggerRight",get:function(){return this._touchButtonTriggerRight}},{key:"touchButtonThumbStickLeft",get:function(){return this._touchButtonThumbStickLeft}},{key:"touchButtonThumbStickRight",get:function(){return this._touchButtonThumbStickRight}}]),t}();!function(t){t[t.VIEW_LEFT=0]="VIEW_LEFT",t[t.VIEW_RIGHT=3]="VIEW_RIGHT",t[t.HEAD_MIDDLE=6]="HEAD_MIDDLE"}(oM||(oM={}));var lM,cM=function(){function t(){var t;this._eventTarget=new Io,this._intervalId=-1,this._webPoseState=((t={})[oM.VIEW_LEFT]={position:ir.ZERO,orientation:kr.IDENTITY},t[oM.VIEW_RIGHT]={position:ir.ZERO,orientation:kr.IDENTITY},t[oM.HEAD_MIDDLE]={position:ir.ZERO,orientation:kr.IDENTITY},t),this._initInputSource(),this._registerEvent()}var e=t.prototype;return e._ensureDirectorDefined=function(){var t=this;return new Promise((function(e){t._intervalId=setInterval((function(){C.director&&C.Director&&(clearInterval(t._intervalId),t._intervalId=-1,e())}),50)}))},e._registerEvent=function(){var t=this;this._ensureDirectorDefined().then((function(){C.director.on(C.Director.EVENT_BEGIN_FRAME,t._scanHmd,t)})).catch((function(){}))},e._scanHmd=function(){var t,e=null==(t=globalThis.__globalXR)?void 0:t.webxrHmdPoseInfos;if(e){for(var i=0;iUe.TOUCH_TIMEOUT&&(it(2302,t.getID()),e.releaseTouch(t.getID()))})),i>=this._touchMap.size},t}()),yM=function(){function t(){this._canvas=void 0,this._eventTarget=new Io,Vo.hasFeature(Ro.INPUT_TOUCH)&&(this._canvas=document.getElementById("GameCanvas"),this._canvas||Y("failed to access canvas"),this._registerEvent())}var e=t.prototype;return e._registerEvent=function(){var t,e,i,n;null==(t=this._canvas)||t.addEventListener("touchstart",this._createCallback("touch-start")),null==(e=this._canvas)||e.addEventListener("touchmove",this._createCallback("touch-move")),null==(i=this._canvas)||i.addEventListener("touchend",this._createCallback("touch-end")),null==(n=this._canvas)||n.addEventListener("touchcancel",this._createCallback("touch-cancel"))},e._createCallback=function(t){var e=this;return function(i){for(var n,r=e._getCanvasRect(),s=[],a=i.changedTouches.length,o=0;o0){var f=new Yy(s,!1,t,gM.getAllTouches());e._eventTarget.emit(t,f)}}},e._getCanvasRect=function(){var t=this._canvas,e=null==t?void 0:t.getBoundingClientRect();return e?new bs(e.x,e.y,e.width,e.height):new bs(0,0,0,0)},e._getLocation=function(t,e){var i=t.clientX-e.x,n=e.y+e.height-t.clientY;if(sh.isFrameRotated){var r=i;i=e.height-n,n=r}var s=sh.devicePixelRatio;return new ds(i*=s,n*=s)},e.on=function(t,e,i){this._eventTarget.on(t,e,i)},e.dispatchEventsInCache=function(){},t}(),vM=function(){function t(t){this.priority=0,this._inputEventTarget=t}var e=t.prototype;return e.onThrowException=function(){},e.dispatchEvent=function(t){return this._inputEventTarget.emit(t.type,t),!0},t}(),bM=((lM={})["mouse-down"]="touch-start",lM["mouse-move"]="touch-move",lM["mouse-up"]="touch-end",lM),SM=t("eB",function(){function t(){this._eventTarget=new Io,this._touchInput=new yM,this._mouseInput=new pM,this._keyboardInput=new dM,this._accelerometerInput=new LI,this._eventKeyboardList=[],this._eventAccelerationList=[],this._eventGamepadList=[],this._eventHandleList=[],this._eventHMDList=[],this._eventHandheldList=[],this._needSimulateTouchMoveEvent=!1,this._eventDispatcherList=[],this._handleInput=new uM,this._hmdInput=new cM,this._handheldInput=new fM,this._registerEvent(),this._inputEventDispatcher=new vM(this._eventTarget),this._registerEventDispatcher(this._inputEventDispatcher),aM._init()}var e=t.prototype;return e._dispatchMouseDownEvent=function(t){var e,i;null==(e=(i=this._mouseInput).dispatchMouseDownEvent)||e.call(i,t)},e._dispatchMouseMoveEvent=function(t){var e,i;null==(e=(i=this._mouseInput).dispatchMouseMoveEvent)||e.call(i,t)},e._dispatchMouseUpEvent=function(t){var e,i;null==(e=(i=this._mouseInput).dispatchMouseUpEvent)||e.call(i,t)},e._dispatchMouseScrollEvent=function(t){var e,i;null==(e=(i=this._mouseInput).dispatchScrollEvent)||e.call(i,t)},e._dispatchKeyboardDownEvent=function(t){var e,i;null==(e=(i=this._keyboardInput).dispatchKeyboardDownEvent)||e.call(i,t)},e._dispatchKeyboardUpEvent=function(t){var e,i;null==(e=(i=this._keyboardInput).dispatchKeyboardUpEvent)||e.call(i,t)},e.on=function(t,e,i){return this._eventTarget.on(t,e,i),e},e.once=function(t,e,i){return this._eventTarget.once(t,e,i),e},e.off=function(t,e,i){this._eventTarget.off(t,e,i)},e.getTouch=function(t){return gM.getTouch(t)},e.getAllTouches=function(){return gM.getAllTouches()},e.getTouchCount=function(){return gM.getTouchCount()},e.setAccelerometerEnabled=function(t){t?this._accelerometerInput.start():this._accelerometerInput.stop()},e.setAccelerometerInterval=function(t){this._accelerometerInput.setInterval(t)},e._simulateEventTouch=function(t){var e=bM[t.type],i=gM.getOrCreateTouch(0,t.getLocationX(),t.getLocationY());if(i){var n=[i],r=new Yy(n,!1,e,"touch-end"===e?[]:n);r.windowId=t.windowId,"touch-end"===e&&gM.releaseTouch(0),this._dispatchEventTouch(r)}},e._registerEventDispatcher=function(t){this._eventDispatcherList.push(t),this._eventDispatcherList.sort((function(t,e){return e.priority-t.priority}))},e._emitEvent=function(t){for(var e=this._eventDispatcherList.length,i=0;i8?ht(12004,8):(this._passes=t,this._flushPassInfo(),this._descriptorSet&&(this._descriptorSet.destroy(),zM.layout=t[0].localSetLayout,this._descriptorSet=this._device.createDescriptorSet(zM)))}},{key:"shaders",get:function(){return this._shaders}},{key:"subMesh",get:function(){return this._subMesh},set:function(t){this._inputAssembler.destroy(),this._inputAssembler=this._device.createInputAssembler(t.iaInfo),this._subMesh=t}},{key:"priority",get:function(){return this._priority},set:function(t){this._priority=t}},{key:"inputAssembler",get:function(){return this._inputAssembler}},{key:"descriptorSet",get:function(){return this._descriptorSet}},{key:"worldBoundDescriptorSet",get:function(){return this._worldBoundDescriptorSet}},{key:"patches",get:function(){return this._patches}},{key:"instancedAttributeBlock",get:function(){return this._instancedAttributeBlock}},{key:"instancedWorldMatrixIndex",get:function(){return this._instancedWorldMatrixIndex},set:function(t){this._instancedWorldMatrixIndex=t}},{key:"instancedSHIndex",get:function(){return this._instancedSHIndex},set:function(t){this._instancedSHIndex=t}},{key:"useReflectionProbeType",get:function(){return this._useReflectionProbeType},set:function(t){this._useReflectionProbeType=t}}]),t}(),GM=new Kr,HM=[{name:"CC_RECEIVE_SHADOW",value:!0}],WM=[{name:"CC_USE_LIGHTMAP",value:1}],jM=[{name:"CC_USE_LIGHTMAP",value:2}],qM=[{name:"CC_LIGHT_MAP_VERSION",value:2}],XM=[{name:"CC_USE_LIGHT_PROBE",value:!0}],YM=new md(2,2,0,2,2,2),JM=new md(2,2,2,2,2,2),KM=function(){function t(){this.type=0,this.scene=null,this.isDynamicBatching=!1,this._worldBounds=null,this._modelBounds=null,this._subModels=[],this._node=null,this._transform=null,this._inited=!1,this._descriptorSetCount=1,this._updateStamp=-1,this._localDataUpdated=!0,this._localData=new Float32Array(56),this._localBuffer=null,this._localSHData=null,this._localSHBuffer=null,this._lightmap=null,this._lightmapUVParam=Nn(),this._tetrahedronIndex=-1,this._lastWorldBoundCenter=nr(1/0,1/0,1/0),this._useLightProbe=!1,this._worldBoundBuffer=null,this._receiveShadow=!1,this._castShadow=!1,this._receiveDirLight=!0,this._shadowBias=0,this._shadowNormalBias=0,this._reflectionProbeId=-1,this._reflectionProbeBlendId=-1,this._reflectionProbeBlendWeight=0,this._enabled=!0,this._visFlags=Ly.Enum.NONE,this._priority=0,this._bakeToReflectionProbe=!0,this._reflectionProbeType=0,this._device=Wp.gfxDevice}var e=t.prototype;return e.initialize=function(){this._inited||(this._receiveShadow=!0,this.castShadow=!1,this.enabled=!0,this.visFlags=Ly.Enum.NONE,this._inited=!0,this._bakeToReflectionProbe=!0,this._reflectionProbeType=0)},e.destroy=function(){for(var t=this._subModels,e=0;e=0?h.updateInstancedWorldMatrix(s,u):a=!0}(a||r)&&this._localBuffer&&(Kr.toArray(this._localData,s,0),Kr.invert(GM,s),Kr.transpose(GM,GM),Kr.toArray(this._localData,GM,16),this._localBuffer.update(this._localData))}},e.invalidateLocalData=function(){this._localDataUpdated=!0},e.showTetrahedron=function(){return this.isLightProbeAvailable()},e.isLightProbeAvailable=function(){if(!this._useLightProbe)return!1;var t=rb().lightProbes;return!(!t||t.empty()||!this._worldBounds)},e.updateSHBuffer=function(){if(this._localSHData){for(var t=this._subModels,e=!1,i=0;i=0?n.updateInstancedSH(this._localSHData,r):e=!0}e&&this._localSHBuffer&&this._localSHBuffer.update(this._localSHData)}},e.clearSHUBOs=function(){if(this._localSHData){for(var t=0;t<28;t++)this._localSHData[t]=0;this.updateSHBuffer()}},e.updateSHUBOs=function(){if(this.isLightProbeAvailable()){var t=this._worldBounds.center;if(!t.equals(this._lastWorldBoundCenter,Ki)){var e=[],i=new Vn,n=A.director.root.pipeline.pipelineSceneData.lightProbes;if(this._lastWorldBoundCenter.set(t),this._tetrahedronIndex=n.data.getInterpolationWeights(t,this._tetrahedronIndex,i),n.data.getInterpolationSHCoefficients(this._tetrahedronIndex,i,e)&&this._localSHData){var r=A.internal.SH;r.reduceRinging(e,n.reduceRinging),r.updateUBOData(this._localSHData,0,e),this.updateSHBuffer()}}}},e.createBoundingShape=function(t,e){t&&e&&(this._modelBounds||(this._modelBounds=gh.create()),this._worldBounds||(this._worldBounds=gh.create()),gh.fromPoints(this._modelBounds,t,e),this._worldBounds.copy(this._modelBounds))},e._createSubModel=function(){return new UM},e.initSubModel=function(t,e,i){this.initialize(),null==this._subModels[t]?this._subModels[t]=this._createSubModel():this._subModels[t].destroy(),this._subModels[t].initialize(e,i.passes,this.getMacroPatches(t)),this._updateAttributesAndBinding(t)},e.setSubModelMesh=function(t,e){this._subModels[t]&&(this._subModels[t].subMesh=e)},e.setSubModelMaterial=function(t,e){this._subModels[t]&&(this._subModels[t].passes=e.passes,this._updateAttributesAndBinding(t))},e.onGlobalPipelineStateChanged=function(){for(var t=this._subModels,e=0;e1?JM:YM),r=this._subModels,s=0;s15e3&&(e=15e3);var i=e*e,n=(.860117757+.000154118254*e+1.28641212e-7*i)/(1+.000842420235*e+7.08145163e-7*i),r=(.317398726+422806245e-13*e+4.20481691e-8*i)/(1-289741816e-13*e+1.61456053e-7*i),s=2*n-8*r+4,a=3*n/s,o=2*r/s,h=1/o*a,u=1/o*(1-a-o);t.x=3.2404542*h-1.5371385+-.4985314*u,t.y=-.969266*h+1.8760108+.041556*u,t.z=.0556434*h-.2040259+1.0572252*u}var tP,eP={DIRECTIONAL:0,SPHERE:1,SPOT:2,POINT:3,RANGED_DIRECTIONAL:4,UNKNOWN:5},iP=function(t){return 4*Math.PI*Math.PI*t*t},nP=function(){function t(){this._baked=!1,this._color=nr(1,1,1),this._colorTemp=6550,this._colorTempRGB=nr(1,1,1),this._finalColor=nr(1,1,1),this._scene=null,this._node=null,this._name=null,this._useColorTemperature=!1,this._type=5,this._visibility=US}var e=t.prototype;return e.initialize=function(){this.color=nr(1,1,1),this.colorTemperature=6550},e.attachToScene=function(t){this._scene=t},e.detachFromScene=function(){this._scene=null},e.destroy=function(){this._name=null,this._node=null},e.update=function(){},n(t,[{key:"baked",get:function(){return this._baked},set:function(t){this._baked=t}},{key:"color",get:function(){return this._color},set:function(t){this._color.set(t),this._useColorTemperature&&ir.multiply(this._finalColor,this._color,this._colorTempRGB)}},{key:"useColorTemperature",get:function(){return this._useColorTemperature},set:function(t){this._useColorTemperature=t,t&&ir.multiply(this._finalColor,this._color,this._colorTempRGB)}},{key:"colorTemperature",get:function(){return this._colorTemp},set:function(t){this._colorTemp=t,$M(this._colorTempRGB,this._colorTemp),this._useColorTemperature&&ir.multiply(this._finalColor,this._color,this._colorTempRGB)}},{key:"colorTemperatureRGB",get:function(){return this._colorTempRGB}},{key:"finalColor",get:function(){return this._finalColor}},{key:"visibility",get:function(){return this._visibility},set:function(t){this._visibility=t}},{key:"node",get:function(){return this._node},set:function(t){this._node=t,this._node&&(this._node.hasChangedFlags|=2)}},{key:"type",get:function(){return this._type}},{key:"name",get:function(){return this._name},set:function(t){this._name=t}},{key:"scene",get:function(){return this._scene}}]),t}(),rP=new ir(0,0,-1),sP=new ir,aP=function(t){function e(){var e;return(e=t.call(this)||this)._dir=new ir(1,-1,-1),e._illuminanceHDR=vb.SUN_ILLUM,e._illuminanceLDR=1,e._shadowEnabled=!1,e._shadowPcf=jT.HARD,e._shadowBias=1e-5,e._shadowNormalBias=0,e._shadowSaturation=1,e._shadowDistance=50,e._shadowInvisibleOcclusionRange=200,e._csmLevel=qT.LEVEL_4,e._csmNeedUpdate=!1,e._csmLayerLambda=.75,e._csmOptimizationMode=XT.DisableRotationFix,e._csmLayersTransition=!1,e._csmTransitionRange=.05,e._shadowFixedArea=!1,e._shadowNear=.1,e._shadowFar=10,e._shadowOrthoSize=5,e._type=0,e}s(e,t);var i=e.prototype;return i.initialize=function(){t.prototype.initialize.call(this),this.illuminance=vb.SUN_ILLUM,this.direction=new ir(1,-1,-1)},i.update=function(){this._node&&this._node.hasChangedFlags&&(this.direction=ir.transformQuat(sP,rP,this._node.worldRotation))},i.activate=function(){var t=A.director.root,e=t.pipeline;this._shadowEnabled?(this._shadowFixedArea||!e.pipelineSceneData.csmSupported?e.macros.CC_DIR_LIGHT_SHADOW_TYPE=1:this.csmLevel>1&&e.pipelineSceneData.csmSupported?(e.macros.CC_DIR_LIGHT_SHADOW_TYPE=2,e.macros.CC_CASCADED_LAYERS_TRANSITION=this._csmLayersTransition):e.macros.CC_DIR_LIGHT_SHADOW_TYPE=1,e.macros.CC_DIR_SHADOW_PCF_TYPE=this._shadowPcf):e.macros.CC_DIR_LIGHT_SHADOW_TYPE=0,t.onGlobalPipelineStateChanged()},n(e,[{key:"direction",get:function(){return this._dir},set:function(t){ir.normalize(this._dir,t)}},{key:"illuminance",get:function(){return rb().isHDR?this._illuminanceHDR:this._illuminanceLDR},set:function(t){rb().isHDR?this.illuminanceHDR=t:this.illuminanceLDR=t}},{key:"illuminanceHDR",get:function(){return this._illuminanceHDR},set:function(t){this._illuminanceHDR=t}},{key:"illuminanceLDR",get:function(){return this._illuminanceLDR},set:function(t){this._illuminanceLDR=t}},{key:"shadowEnabled",get:function(){return this._shadowEnabled},set:function(t){this._shadowEnabled=t,this.activate()}},{key:"shadowPcf",get:function(){return this._shadowPcf},set:function(t){this._shadowPcf=t,this.activate()}},{key:"shadowBias",get:function(){return this._shadowBias},set:function(t){this._shadowBias=t}},{key:"shadowNormalBias",get:function(){return this._shadowNormalBias},set:function(t){this._shadowNormalBias=t}},{key:"shadowSaturation",get:function(){return this._shadowSaturation},set:function(t){this._shadowSaturation=t}},{key:"shadowDistance",get:function(){return this._shadowDistance},set:function(t){this._shadowDistance=Math.min(t,JT.MAX_FAR)}},{key:"shadowInvisibleOcclusionRange",get:function(){return this._shadowInvisibleOcclusionRange},set:function(t){this._shadowInvisibleOcclusionRange=Math.min(t,JT.MAX_FAR)}},{key:"csmLevel",get:function(){return this._csmLevel},set:function(t){this._csmLevel=t,this.activate()}},{key:"csmNeedUpdate",get:function(){return this._csmNeedUpdate},set:function(t){this._csmNeedUpdate=t}},{key:"csmLayerLambda",get:function(){return this._csmLayerLambda},set:function(t){this._csmLayerLambda=t}},{key:"csmOptimizationMode",get:function(){return this._csmOptimizationMode},set:function(t){this._csmOptimizationMode=t}},{key:"shadowFixedArea",get:function(){return this._shadowFixedArea},set:function(t){this._shadowFixedArea=t,this.activate()}},{key:"shadowNear",get:function(){return this._shadowNear},set:function(t){this._shadowNear=t}},{key:"shadowFar",get:function(){return this._shadowFar},set:function(t){this._shadowFar=Math.min(t,JT.MAX_FAR)}},{key:"shadowOrthoSize",get:function(){return this._shadowOrthoSize},set:function(t){this._shadowOrthoSize=t}},{key:"csmLayersTransition",get:function(){return this._csmLayersTransition},set:function(t){this._csmLayersTransition=t,this.activate()}},{key:"csmTransitionRange",get:function(){return this._csmTransitionRange},set:function(t){this._csmTransitionRange=t}}]),e}(nP),oP=function(t){function e(){var e;return(e=t.call(this)||this)._needUpdate=!1,e._size=.15,e._range=1,e._luminanceHDR=0,e._luminanceLDR=0,e._pos=new ir,e._aabb=gh.create(),e._type=1,e}s(e,t);var i=e.prototype;return i.initialize=function(){t.prototype.initialize.call(this),this.size=.15,this.range=1,this.luminanceHDR=1700/iP(.15),this.luminanceLDR=1},i.update=function(){if(this._node&&(this._node.hasChangedFlags||this._needUpdate)){this._node.getWorldPosition(this._pos);var t=this._range;gh.set(this._aabb,this._pos.x,this._pos.y,this._pos.z,t,t,t),this._needUpdate=!1}},n(e,[{key:"position",get:function(){return this._pos}},{key:"size",get:function(){return this._size},set:function(t){this._size=t}},{key:"range",get:function(){return this._range},set:function(t){this._range=t,this._needUpdate=!0}},{key:"luminance",get:function(){return rb().isHDR?this._luminanceHDR:this._luminanceLDR},set:function(t){rb().isHDR?this.luminanceHDR=t:this.luminanceLDR=t}},{key:"luminanceHDR",get:function(){return this._luminanceHDR},set:function(t){this._luminanceHDR=t}},{key:"luminanceLDR",set:function(t){this._luminanceLDR=t}},{key:"aabb",get:function(){return this._aabb}}]),e}(nP),hP=new ir(0,0,-1),uP=new kr,lP=new Kr,cP=new Kr,fP=new Kr,_P=new Kr,dP=function(t){function e(){var e;return(e=t.call(this)||this)._dir=new ir(1,-1,-1),e._range=5,e._spotAngle=Math.cos(Math.PI/6),e._angleAttenuationStrength=0,e._pos=new ir,e._aabb=gh.create(),e._frustum=Dh.create(),e._angle=0,e._needUpdate=!1,e._size=.15,e._luminanceHDR=0,e._luminanceLDR=0,e._shadowEnabled=!1,e._shadowPcf=jT.HARD,e._shadowBias=1e-5,e._shadowNormalBias=0,e._type=2,e}s(e,t);var i=e.prototype;return i.initialize=function(){t.prototype.initialize.call(this),this.size=.15,this.luminanceHDR=1700/iP(.15),this.luminanceLDR=1,this.range=Math.cos(Math.PI/6),this._dir.set(new ir(1,-1,-1))},i.update=function(){this._node&&(this._node.hasChangedFlags||this._needUpdate)&&(this._node.getWorldPosition(this._pos),ir.transformQuat(this._dir,hP,this._node.getWorldRotation(uP)),ir.normalize(this._dir,this._dir),gh.set(this._aabb,this._pos.x,this._pos.y,this._pos.z,this._range,this._range,this._range),this._node.getWorldRT(lP),Kr.invert(lP,lP),Kr.perspective(cP,this._angle,1,.001,this._range),Kr.multiply(fP,cP,lP),this._frustum.update(fP,_P),this._needUpdate=!1)},n(e,[{key:"position",get:function(){return this._pos}},{key:"size",get:function(){return this._size},set:function(t){this._size=t}},{key:"range",get:function(){return this._range},set:function(t){this._range=t,this._needUpdate=!0}},{key:"luminance",get:function(){return rb().isHDR?this._luminanceHDR:this._luminanceLDR},set:function(t){rb().isHDR?this.luminanceHDR=t:this.luminanceLDR=t}},{key:"luminanceHDR",get:function(){return this._luminanceHDR},set:function(t){this._luminanceHDR=t}},{key:"luminanceLDR",get:function(){return this._luminanceLDR},set:function(t){this._luminanceLDR=t}},{key:"direction",get:function(){return this._dir}},{key:"spotAngle",get:function(){return this._spotAngle},set:function(t){this._angle=t,this._spotAngle=Math.cos(.5*t),this._needUpdate=!0}},{key:"angleAttenuationStrength",get:function(){return this._angleAttenuationStrength},set:function(t){this._angleAttenuationStrength=t,this._needUpdate=!0}},{key:"angle",get:function(){return this._angle}},{key:"aabb",get:function(){return this._aabb}},{key:"frustum",get:function(){return this._frustum}},{key:"shadowEnabled",get:function(){return this._shadowEnabled},set:function(t){this._shadowEnabled=t}},{key:"shadowPcf",get:function(){return this._shadowPcf},set:function(t){this._shadowPcf=t}},{key:"shadowBias",get:function(){return this._shadowBias},set:function(t){this._shadowBias=t}},{key:"shadowNormalBias",get:function(){return this._shadowNormalBias},set:function(t){this._shadowNormalBias=t}}]),e}(nP),pP=function(t){function e(){var e;return(e=t.call(this)||this)._needUpdate=!1,e._range=1,e._luminanceHDR=0,e._luminanceLDR=0,e._pos=nr(),e._aabb=gh.create(),e._type=3,e}s(e,t);var i=e.prototype;return i.initialize=function(){t.prototype.initialize.call(this),this.range=1,this.luminanceHDR=1700/iP(1),this.luminanceLDR=1},i.update=function(){if(this._node&&(this._node.hasChangedFlags||this._needUpdate)){this._node.getWorldPosition(this._pos);var t=this._range;gh.set(this._aabb,this._pos.x,this._pos.y,this._pos.z,t,t,t),this._needUpdate=!1}},n(e,[{key:"position",get:function(){return this._pos}},{key:"range",get:function(){return this._range},set:function(t){this._range=t,this._needUpdate=!0}},{key:"luminance",get:function(){return rb().isHDR?this._luminanceHDR:this._luminanceLDR},set:function(t){rb().isHDR?this.luminanceHDR=t:this.luminanceLDR=t}},{key:"luminanceHDR",get:function(){return this._luminanceHDR},set:function(t){this._luminanceHDR=t}},{key:"luminanceLDR",set:function(t){this._luminanceLDR=t}},{key:"aabb",get:function(){return this._aabb}}]),e}(nP),mP=new ir(0,0,-1),gP=function(t){function e(){var e;return(e=t.call(this)||this)._dir=new ir(0,0,-1),e._pos=new ir(0,0,0),e._scale=new ir(1,1,1),e._right=new ir(1,0,0),e._illuminanceHDR=vb.SUN_ILLUM,e._illuminanceLDR=1,e._type=4,e}s(e,t);var i=e.prototype;return i.initialize=function(){t.prototype.initialize.call(this),this.illuminance=vb.SUN_ILLUM},i.update=function(){this._node&&this._node.hasChangedFlags&&(this._node.getWorldPosition(this._pos),this._node.getWorldScale(this._scale),ir.transformQuat(this._dir,mP,this._node.worldRotation),ir.transformQuat(this._right,ir.RIGHT,this._node.worldRotation))},n(e,[{key:"direction",get:function(){return this._dir}},{key:"right",get:function(){return this._right}},{key:"position",get:function(){return this._pos}},{key:"scale",get:function(){return this._scale}},{key:"illuminance",get:function(){return rb().isHDR?this._illuminanceHDR:this._illuminanceLDR},set:function(t){rb().isHDR?this.illuminanceHDR=t:this.illuminanceLDR=t}},{key:"illuminanceHDR",get:function(){return this._illuminanceHDR},set:function(t){this._illuminanceHDR=t}},{key:"illuminanceLDR",get:function(){return this._illuminanceLDR},set:function(t){this._illuminanceLDR=t}}]),e}(nP),yP=new Id;yP.format=35;var vP=new Md;vP.format=55;var bP=new Od([yP],vP),SP={width:1,height:1,renderPassInfo:bP},wP=t("e9",Kh("cc.RenderTexture")(tP=function(t){function e(e){var i;return(i=t.call(this,e)||this)._window=null,i}s(e,t);var i=e.prototype;return i.initialize=function(t){this._name=t.name||"",this._width=t.width,this._height=t.height,this._initWindow(t)},i.reset=function(t){this.initialize(t)},i.destroy=function(){if(this._window){var e=A.director.root;null==e||e.destroyWindow(this._window),this._window=null}return t.prototype.destroy.call(this)},i.resize=function(t,e){this._width=Math.floor($i(t,1,2048)),this._height=Math.floor($i(e,1,2048)),this._window&&this._window.resize(this._width,this._height),this.emit("resize",this._window)},i._serialize=function(){return{}},i._deserialize=function(e,i){var n=e;this._width=n.w,this._height=n.h,this._name=n.n,t.prototype._deserialize.call(this,n.base,i)},i.getGFXTexture=function(){return this._window&&this._window.framebuffer.colorTextures[0]},i.onLoaded=function(){this._initWindow()},i._initWindow=function(t){var e=A.director.root;SP.title=this._name,SP.width=this._width,SP.height=this._height,SP.renderPassInfo=t&&t.passInfo?t.passInfo:bP,SP.externalResLow=t&&t.externalResLow?t.externalResLow:0,SP.externalResHigh=t&&t.externalResHigh?t.externalResHigh:0,SP.externalFlag=t&&t.externalFlag?t.externalFlag:0,SP.renderPassInfo.colorAttachments.forEach((function(t){t.format=e.device.swapchainFormat})),yP.barrier=Wp.gfxDevice.getGeneralBarrier(new Rd(128,128)),this._window?(this._window.destroy(),this._window.initialize(Wp.gfxDevice,SP)):this._window=e.createWindow(SP)},i.initDefault=function(e){t.prototype.initDefault.call(this,e),this._width=this._height=1,this._initWindow()},i.validate=function(){return this.width>=1&&this.width<=2048&&this.height>=1&&this.height<=2048},i.readPixels=function(t,e,i,n,r){t=t||0,e=e||0,i=i||this.width,n=n||this.height;var s=this.getGFXTexture();if(!s)return ht(7606),null;var a=4*i*n;if(void 0===r)r=new Uint8Array(a);else if(r.length=0&&this._models.splice(e,1)},e.clearModels=function(){this._models.length=0},n(t,[{key:"models",get:function(){return this._models}}]),t}(),PP=function(){function t(){this.scene=void 0,this.node=null,this.enabled=!0,this._localBoundaryCenter=nr(0,0,0),this._objectSize=1,this._lodDataArray=[],this._lockedLODLevelVec=[],this._isLockLevelChanged=!1,this._device=Wp.gfxDevice}var e=t.prototype;return e.attachToScene=function(t){this.scene=t},e.detachFromScene=function(){this.scene=null},e.lockLODLevels=function(t){if(t.length!==this._lockedLODLevelVec.length)this._isLockLevelChanged=!0;else for(var e=t.length,i=0;i=this.lodDataArray[n].screenUsagePercentage){i=n;break}return i},e.getScreenUsagePercentage=function(t){return this.node?(1===t.projectionType&&(e=ir.len(this.localBoundaryCenter.transformMat4(this.node.worldMatrix).subtract(t.node.worldPosition))),this.distanceToScreenUsagePercentage(t,e,this.getWorldSpaceSize())):0;var e},e.distanceToScreenUsagePercentage=function(t,e,i){return 1===t.projectionType?i*t.matProj.m05/(2*e):i*t.matProj.m05*.5},e.getWorldSpaceSize=function(){var t=this.node.scale;return Math.max(Math.abs(t.x),Math.abs(t.y),Math.abs(t.z))*this.objectSize},n(t,[{key:"localBoundaryCenter",get:function(){return this._localBoundaryCenter.clone()},set:function(t){this._localBoundaryCenter.set(t)}},{key:"lodCount",get:function(){return this._lodDataArray.length}},{key:"objectSize",get:function(){return this._objectSize},set:function(t){this._objectSize=t}},{key:"lodDataArray",get:function(){return this._lodDataArray}}]),t}(),EP=Object.freeze({__proto__:null,Ambient:vb,CSMLevel:qT,CSMOptimizationMode:XT,Camera:NM,CameraAperture:BM,CameraFOVAxis:CM,CameraISO:IM,CameraProjection:DM,CameraShutter:MM,CameraType:{DEFAULT:-1,LEFT_EYE:0,RIGHT_EYE:1,MAIN:2},CameraUsage:{EDITOR:0,GAME_VIEW:1,SCENE_VIEW:2,PREVIEW:3,GAME:100},ColorTemperatureToRGB:$M,DirectionalLight:aP,EnvironmentLightingType:tA,FOG_TYPE_NONE:rA,Fog:sA,FogType:nA,LODData:MP,LODGroup:PP,Light:nP,LightType:eP,Model:KM,ModelType:{DEFAULT:0,SKINNING:1,BAKED_SKINNING:2,BATCH_2D:3,PARTICLE_BATCH:4,LINE:5},Octree:QM,PCFType:jT,PointLight:pP,PostSettings:ID,ProbeClearFlag:AP,ProbeType:CP,RangedDirectionalLight:gP,ReflectionProbe:IP,SKYBOX_FLAG:8,ShadowSize:HT,ShadowType:WT,Shadows:JT,Skin:ZM,SkyBoxFlagValue:{VALUE:8},Skybox:eA,SphereLight:oP,SpotLight:dP,SubModel:UM,ToneMappingType:BD,TrackingType:{NO_TRACKING:0,POSITION_AND_ROTATION:1,POSITION:2,ROTATION:3},nt2lm:iP}),OP=function(){function t(t){this._name="",this._cameras=[],this._models=[],this._lodGroups=[],this._batches=[],this._directionalLights=[],this._sphereLights=[],this._spotLights=[],this._pointLights=[],this._rangedDirLights=[],this._mainLight=null,this._modelId=0,this._lodStateCache=null,this._root=t}t.registerCreateFunc=function(e){e._createSceneFun=function(e){return new t(e)}};var e=t.prototype;return e.initialize=function(t){return this._name=t.name,this._lodStateCache=new RP(this),!0},e.update=function(t){var e=this._mainLight;e&&e.update();for(var i=this._sphereLights,n=0;n=0&&(this._lodGroups.splice(e,1),t.detachFromScene(),this._lodStateCache.removeLodGroup(t))},e.removeLODGroups=function(){var t=this;this._lodGroups.forEach((function(e){t._lodStateCache.removeLodGroup(e)})),this._lodGroups.length=0},e.onGlobalPipelineStateChanged=function(){this._models.forEach((function(t){t.onGlobalPipelineStateChanged()}))},e.generateModelId=function(){return this._modelId++},n(t,[{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:"pointLights",get:function(){return this._pointLights}},{key:"rangedDirLights",get:function(){return this._rangedDirLights}},{key:"models",get:function(){return this._models}},{key:"batches",get:function(){return this._batches}},{key:"lodGroups",get:function(){return this._lodGroups}}]),t}(),kP=function(){this.usedLevel=-1,this.lastUsedLevel=-1,this.transformDirty=!0},RP=function(){function t(t){this._renderScene=null,this._modelsInLODGroup=new Map,this._lodStateInCamera=new Map,this._newAddedLodGroupVec=[],this._levelModels=new Map,this._renderScene=t}var e=t.prototype;return e.addCamera=function(t){for(var e=this._renderScene.lodGroups,i=0;i0){if(i.node.hasChangedFlags>0)for(var s,a=p(t._lodStateInCamera);!(s=a()).done;){var o=s.value,h=o[1].get(i);h||(h=new kP,o[1].set(i,h)),h.transformDirty=!0}if(i.isLockLevelChanged()){i.resetLockChangeFlag();var u=t._levelModels.get(i);u&&(u.forEach((function(e){e.forEach((function(e){var i=t._modelsInLODGroup.get(e);i&&i.clear()}))})),r.forEach((function(e){var i=u.get(e);i&&i.forEach((function(e){var i=t._modelsInLODGroup.get(e);if(i&&e.node&&e.node.active)for(var n,r=p(t._lodStateInCamera);!(n=r()).done;){var s=n.value;i.set(s[0],!0)}}))})))}return 0}for(var l,c=!1,f=p(t._lodStateInCamera);!(l=f()).done;){var _=l.value,d=_[1].get(i);d||(d=new kP,_[1].set(i,d));var m=_[0].node.hasChangedFlags,g=i.node.hasChangedFlags;if(m>0||g>0||d.transformDirty){d.transformDirty&&(d.transformDirty=!1);var y=i.getVisibleLODLevel(_[0]);y!==d.usedLevel&&(d.lastUsedLevel=d.usedLevel,d.usedLevel=y,c=!0)}}var v=t._levelModels.get(i);if(!v)return 0;i.isLockLevelChanged()?(i.resetLockChangeFlag(),v.forEach((function(e){e.forEach((function(e){var i=t._modelsInLODGroup.get(e);i&&i.clear()}))})),c=!0):c&&t._lodStateInCamera.forEach((function(e){var n=e.get(i);if(n&&n.usedLevel!==n.lastUsedLevel){var r=v.get(n.lastUsedLevel);r&&r.forEach((function(e){var i=t._modelsInLODGroup.get(e);i&&i.clear()}))}})),c&&t._lodStateInCamera.forEach((function(e,n){var r=e.get(i);if(r){var s=r.usedLevel,a=v.get(s);a&&a.forEach((function(e){var i=t._modelsInLODGroup.get(e);i&&e.node&&e.node.active&&i.set(n,!0)}))}}))}},n=0;n1&&(this._fps=this._frameCount,this._frameCount=0,this._fpsTime=0),this._frameMoveBegin(),this._frameMoveProcess(),this._frameMoveEnd()},e.createWindow=function(t){var e=this._createWindowFun(this);return e.initialize(this.device,t),this._windows.push(e),e},e.destroyWindow=function(t){for(var e=0;e0){this._device.acquire([Wp.swapchain]);var r=this._scenes,s=t.getTotalFrames();this._batcher&&(this._batcher.update(),this._batcher.uploadBuffers());for(var a=0;a0){t.emit(e.EVENT_BEFORE_COMMIT),i.sort((function(t,e){return t.priority-e.priority}));for(var n=0;n0&&(this._fixedFPS=t)}},{key:"dataPoolManager",get:function(){return this._dataPoolMgr}},{key:"useDeferredPipeline",get:function(){return this._useDeferredPipeline}},{key:"cameraList",get:function(){return this._cameraList}}]),t}());A.Root=zP,Vi.Attr.setClassAttr(mg,"target","type","Object"),Vi.Attr.setClassAttr(mg,"target","ctor",eb),pt(eb.prototype,"Node",[{name:"childrenCount",newName:"children.length",customGetter:function(){return this.children.length}}]),pt(eb.prototype,"Node",[{name:"width",targetName:"node.getComponent(UITransform)",customGetter:function(){return this._getUITransformComp().width},customSetter:function(t){this._getUITransformComp().width=t}},{name:"height",targetName:"node.getComponent(UITransform)",customGetter:function(){return this._getUITransformComp().height},customSetter:function(t){this._getUITransformComp().height=t}},{name:"anchorX",targetName:"node.getComponent(UITransform)",customGetter:function(){return this._getUITransformComp().anchorX},customSetter:function(t){this._getUITransformComp().anchorX=t}},{name:"anchorY",targetName:"node.getComponent(UITransform)",customGetter:function(){return this._getUITransformComp().anchorY},customSetter:function(t){this._getUITransformComp().anchorY=t}},{name:"getAnchorPoint",targetName:"node.getComponent(UITransform)",customFunction:function(t){return t||(t=new ds),t.set(this._getUITransformComp().anchorPoint),t}},{name:"setAnchorPoint",targetName:"node.getComponent(UITransform)",customFunction:function(t,e){this._getUITransformComp().setAnchorPoint(t,e)}},{name:"getContentSize",targetName:"node.getComponent(UITransform)",customFunction:function(t){return t||(t=new ms),t.set(this._getUITransformComp().contentSize),t}},{name:"setContentSize",targetName:"node.getComponent(UITransform)",customFunction:function(t,e){"number"==typeof t?this._getUITransformComp().setContentSize(t,e):this._getUITransformComp().setContentSize(t)}}]),mt(hI.prototype,"SceneGlobals.prototype",[{name:"aspect"},{name:"selfShadow"},{name:"linear"},{name:"packing"},{name:"autoAdapt"},{name:"fixedArea"},{name:"pcf"},{name:"bias"},{name:"normalBias"},{name:"near"},{name:"far"},{name:"shadowDistance"},{name:"invisibleOcclusionRange"},{name:"orthoSize"},{name:"saturation"}]),pt(hI.prototype,"SceneGlobals.prototype",[{name:"distance",newName:"planeHeight"},{name:"normal",newName:"planeDirection"},{name:"size",newName:"shadowMapSize"}]),mt(eb.prototype,"Node.prototype",[{name:"addLayer"},{name:"removeLayer"}]),pt(Vy.prototype,"NodeUIProperties",[{name:"opacityDirty",newName:"colorDirty"}]),mt(Ly,"Layers",[{name:"All"},{name:"RaycastMask"},{name:"check"}]),pt(Ly,"Layers",[{name:"Default",newName:"DEFAULT",target:Ly.Enum,targetName:"Layers.Enum"},{name:"Always",newName:"ALWAYS",target:Ly.Enum,targetName:"Layers.Enum"},{name:"IgnoreRaycast",newName:"IGNORE_RAYCAST",target:Ly.Enum,targetName:"Layers.Enum"},{name:"Gizmos",newName:"GIZMOS",target:Ly.Enum,targetName:"Layers.Enum"},{name:"Editor",newName:"EDITOR",target:Ly.Enum,targetName:"Layers.Enum"},{name:"UI",newName:"UI_3D",target:Ly.Enum,targetName:"Layers.Enum"},{name:"UI2D",newName:"UI_2D",target:Ly.Enum,targetName:"Layers.Enum"},{name:"SceneGizmo",newName:"SCENE_GIZMO",target:Ly.Enum,targetName:"Layers.Enum"},{name:"makeInclusiveMask",newName:"makeMaskInclude",target:Ly,targetName:"Layers"},{name:"makeExclusiveMask",newName:"makeMaskExclude",target:Ly,targetName:"Layers"}]),mt(Ly.Enum,"Layers.Enum",[{name:"ALWAYS"}]),mt(Ly.BitMask,"Layers.BitMask",[{name:"ALWAYS"}]);var UP=t("dM",Kh("cc.PrivateNode")(TP=function(t){function e(e){var i;return at(12003,(i=t.call(this,e)||this).name),i.hideFlags|=1032,i}return s(e,t),e}(eb))||TP);function GP(t,e){if(!e){var i=C.director.getScene();if(!i)return null;e=i}return e.getChildByPath(t)}pt($y,"SystemEventType",["MOUSE_ENTER","MOUSE_LEAVE","TRANSFORM_CHANGED","SCENE_CHANGED_FOR_PERSISTS","SIZE_CHANGED","ANCHOR_CHANGED","COLOR_CHANGED","CHILD_ADDED","CHILD_REMOVED","PARENT_CHANGED","NODE_DESTROYED","LAYER_CHANGED","SIBLING_ORDER_CHANGED"].map((function(t){return{name:t,target:eb.EventType,targetName:"Node.EventType"}}))),pt(eb.EventType,"Node.EventType",[{name:"DEVICEMOTION",target:xM.EventType,targetName:"SystemEvent.EventType"},{name:"KEY_DOWN",target:xM.EventType,targetName:"SystemEvent.EventType"},{name:"KEY_UP",target:xM.EventType,targetName:"SystemEvent.EventType"}]),C.PrivateNode=UP,Dt({BaseNode:{newName:"Node",since:"3.7.0",removed:!1}}),C.find=GP;var HP=be,WP=65536,jP=2048;function qP(t,e){for(var i=e.constructor._executionOrder,n=e._id,r=0,s=t.length-1,a=s>>>1;r<=s;a=r+s>>>1){var o=t[a],h=o.constructor._executionOrder;if(h>i)s=a-1;else if(hn)s=a-1;else{if(!(u0&&(t.array.sort(JP),this._invoke(t),t.array.length=0),this._invoke(this._zero),this._zero.array.length=0;var e=this._pos;e.array.length>0&&(e.array.sort(JP),this._invoke(e),e.array.length=0)},e}(YP),QP=function(t){function e(e){return t.call(this,e)||this}s(e,t);var i=e.prototype;return i.add=function(t){var e=t.constructor._executionOrder;if(0===e)this._zero.array.push(t);else{var i=e<0?this._neg.array:this._pos.array,n=qP(i,t);n<0&&i.splice(~n,0,t)}},i.remove=function(t){var e=t.constructor._executionOrder;if(0===e)this._zero.fastRemove(t);else{var i=e<0?this._neg:this._pos,n=qP(i.array,t);n>=0&&i.removeAt(n)}},i.invoke=function(t){this._neg.array.length>0&&this._invoke(this._neg,t),this._invoke(this._zero,t),this._pos.array.length>0&&this._invoke(this._pos,t)},e}(YP);function ZP(t,e,i){var n="var a=it.array;for(it.i=0;it.i=0?HP(this._deferredComps,e):(!t.internalStart||t._objFlags&WP||this.startInvoker.remove(t),t.internalUpdate&&this.updateInvoker.remove(t),t.internalLateUpdate&&this.lateUpdateInvoker.remove(t))},e.enableComp=function(t,e){if(!(t._objFlags&jP)){if(t.internalOnEnable){if(e)return void e.add(t);if(t.internalOnEnable(),!t.node.activeInHierarchy)return}this._onEnabled(t)}},e.disableComp=function(t){t._objFlags&jP&&(t.internalOnDisable&&t.internalOnDisable(),this._onDisabled(t))},e.startPhase=function(){this._updating=!0,this.startInvoker.invoke(),this._startForNewComps()},e.updatePhase=function(t){this.updateInvoker.invoke(t)},e.lateUpdatePhase=function(t){this.lateUpdateInvoker.invoke(t),this._updating=!1,this._startForNewComps()},e._startForNewComps=function(){this._deferredComps.length>0&&(this._deferredSchedule(),this.startInvoker.invoke())},e._scheduleImmediate=function(t){"function"!=typeof t.internalStart||t._objFlags&WP||this.startInvoker.add(t),"function"==typeof t.internalUpdate&&this.updateInvoker.add(t),"function"==typeof t.internalLateUpdate&&this.lateUpdateInvoker.add(t)},e._deferredSchedule=function(){for(var t=this._deferredComps,e=0,i=t.length;e1)t.push("t="+this._targetExp+";"),e="t";else{if(1!==this._exps.length)return;e=this._targetExp}for(var i=0;i0&&(i=mE+this.globalVariables.join(",")+";");var n=Zf(["return (function(R){",i||[],this.codeArray,"return o;","})"]);this.result=Function("O","F",n)(this.objs,this.funcs);for(var r=0,s=this.objsToClear_iN$t.length;r=e.OptimizationPolicyThreshold)?(t=this._doInstantiate(),this.data._instantiate(t)):t=this.data._instantiate(),++this._instantiatedTimes,t},i.initDefault=function(e){t.prototype.initDefault.call(this,e),this.data=new eb,this.data.name="(Missing Node)";var i=new C._PrefabInfo;i.asset=this,i.root=this.data,this.data._prefab=i},i.validate=function(){return!!this.data},i.onLoaded=function(){var t=this.data;CI(t),TI(t)},e}(Cm),ME.OptimizationPolicy=OE,ME.OptimizationPolicyThreshold=3,DE=zh((CE=ME).prototype,"data",[uu],(function(){return null})),BE=zh(CE.prototype,"optimizationPolicy",[uu],(function(){return OE.AUTO})),IE=zh(CE.prototype,"persistent",[uu],(function(){return!1})),AE=CE))||AE);Vt(kE,"_utils",kI),C.Prefab=kE,Wt(C,"cc._Prefab","Prefab");var RE=function(){function t(){this._allRenderers=[],this._dirtyRenderers=[],this._dirtyVersion=0}var e=t.prototype;return e.addRenderer=function(t){-1===t._internalId&&(t._internalId=this._allRenderers.length,this._allRenderers.push(t))},e.removeRenderer=function(t){if(-1!==t._internalId){var e=t._internalId;this._allRenderers[this._allRenderers.length-1]._internalId=e,be(this._allRenderers,e),t._internalId=-1,t._dirtyVersion===this._dirtyVersion&&(we(this._dirtyRenderers,t),t._dirtyVersion=-1)}},e.markDirtyRenderer=function(t){t._dirtyVersion!==this._dirtyVersion&&-1!==t._internalId&&(this._dirtyRenderers.push(t),t._dirtyVersion=this._dirtyVersion)},e.updateAllDirtyRenderers=function(){for(var t=this._dirtyRenderers,e=0;e1){var u=Object.create(null);e.forEach((function(t){u[t._uuid]=t})),r={isCompleted:NE,_map:u}}else r=e[0]}i&&i(t,r)}))},e.getXMLHttpRequest=function(){return new XMLHttpRequest},e.getItem=function(t){return fT.assets.has(t)?{content:fT.assets.get(t)}:null},e.loadRes=function(t,e,i,n){var r=this._parseLoadResArgs(e,i,n),s=r.type,a=r.onProgress,o=r.onComplete,h=Ho(t);h&&!ox.getInfoWithPath(t,s)&&(t=t.slice(0,-h.length)),ox.load(t,s,a,o)},e.loadResArray=function(t,e,i,n){var r=this._parseLoadResArgs(e,i,n),s=r.type,a=r.onProgress,o=r.onComplete;t.forEach((function(e,i){var n=Ho(e);n&&!ox.getInfoWithPath(e,s)&&(t[i]=e.slice(0,-n.length))})),ox.load(t,s,a,o)},e.loadResDir=function(t,e,i,n){var r=this._parseLoadResArgs(e,i,n),s=r.type,a=r.onProgress,o=r.onComplete;ox.loadDir(t,s,a,(function(e,i){var n=[];e||(n=ox.getDirWithPath(t,s).map((function(t){return t.path}))),o&&o(e,i,n)}))},e.getRes=function(t,e){return Kp.has(t)?Kp.get(t):ox.get(t,e)},e.getResCount=function(){return Kp.count},e.getDependsRecursively=function(t){if(!t)return[];var e="string"==typeof t?t:t._uuid;return Sy.getDepsRecursively(e).concat([e])},e.addDownloadHandlers=function(t){var e=Object.create(null),i=function(){var i=t[n];e["."+n]=function(t,e,n){i({url:t},n)}};for(var n in t)i();Mx.register(e)},e.addLoadHandlers=function(t){var e=Object.create(null),i=function(){var i=t[n];e["."+n]=function(t,e,n){i({content:t},n)}};for(var n in t)i();Zx.register(e)},e.release=function(t){if(Array.isArray(t))for(var e=0;eg.x?t[b]:g.x,g.y=t[b+1]>g.y?t[b+1]:g.y,y.x=t[b]g.x?t[b]:g.x,g.y=t[b+1]>g.y?t[b+1]:g.y,g.z=t[b+2]>g.z?t[b+2]:g.z,y.x=t[b]1&&t.csmOptimizationMode===XT.RemoveDuplicates)if(this._level>=h-1)wO=this._castLightViewBoundingBox.halfExtents.z,SO=this._castLightViewBoundingBox.center.z;else{var u=Math.abs(this._castLightViewBoundingBox.center.z-SO)+wO;this._castLightViewBoundingBox.halfExtents.z=Math.max(this._castLightViewBoundingBox.center.z,u)}var l=this._castLightViewBoundingBox.halfExtents.z;this._shadowCameraFar=2*l+r;var c=this._castLightViewBoundingBox.center;if(bO.set(c.x,c.y,c.z+l+r),ir.transformMat4(bO,bO,oO),Kr.fromRT(oO,t.node.rotation,bO),Kr.invert(hO,oO),!i){var f=.5*s,_=.5*a;Kr.ortho(uO,-f,f,-_,_,.1,this._shadowCameraFar,n.capabilities.clipSpaceMinZ,n.capabilities.clipSpaceSignY),Kr.multiply(cO,uO,o),ir.transformMat4(dO,bO,cO);var d=2/e;pO.set(d,d);var p=dO.x%pO.x,m=dO.y%pO.y;mO.set(dO.x-p,dO.y-m,dO.z),Kr.invert(fO,cO),ir.transformMat4(gO,mO,fO),Kr.fromRT(oO,t.node.rotation,gO),Kr.invert(hO,oO),Kr.multiply(lO,uO,hO),Kr.copy(this._matShadowView,hO),Kr.copy(this._matShadowProj,uO),Kr.copy(this._matShadowViewProj,lO)}Dh.createOrtho(this._validFrustum,s,a,.1,this._shadowCameraFar,oO)},n(t,[{key:"level",get:function(){return this._level}},{key:"shadowObjects",get:function(){return this._shadowObjects}},{key:"shadowCameraFar",get:function(){return this._shadowCameraFar},set:function(t){this._shadowCameraFar=t}},{key:"matShadowView",get:function(){return this._matShadowView},set:function(t){this._matShadowView=t}},{key:"matShadowProj",get:function(){return this._matShadowProj},set:function(t){this._matShadowProj=t}},{key:"matShadowViewProj",get:function(){return this._matShadowViewProj},set:function(t){this._matShadowViewProj=t}},{key:"validFrustum",get:function(){return this._validFrustum}},{key:"splitFrustum",get:function(){return this._splitFrustum}},{key:"lightViewFrustum",get:function(){return this._lightViewFrustum}},{key:"castLightViewBoundingBox",get:function(){return this._castLightViewBoundingBox}}]),t}(),TO=function(t){function e(e){var i;return(i=t.call(this,e)||this)._splitCameraNear=0,i._splitCameraFar=0,i._csmAtlas=new Vn,i._calculateAtlas(e),i}s(e,t);var i=e.prototype;return i.destroy=function(){t.prototype.destroy.call(this)},i._calculateAtlas=function(t){var e=A.director.root.device.capabilities.clipSpaceSignY,i=t%2-.5,n=(.5-Math.floor(t/2))*e;this._csmAtlas.set(.5,.5,i,n)},n(e,[{key:"splitCameraNear",get:function(){return this._splitCameraNear},set:function(t){this._splitCameraNear=t}},{key:"splitCameraFar",get:function(){return this._splitCameraFar},set:function(t){this._splitCameraFar=t}},{key:"csmAtlas",get:function(){return this._csmAtlas},set:function(t){this._csmAtlas=t}}]),e}(xO),AO=function(){function t(){this._castShadowObjects=[],this._layerObjects=new lo(64),this._layers=[],this._levelCount=0,this._specialLayer=new xO(1),this._shadowDistance=0;for(var t=0;t1?.5*i.size.x:i.size.x;if(!(r<0)){this._getCameraWorldMatrix(aO,t);for(var s=n-1;s>=0;s--){var a=this._layers[s],o=a.splitCameraNear,h=a.splitCameraFar;a.calculateSplitFrustum(t,aO,o,h),a.createMatrix(e,r,!1)}n===qT.LEVEL_1?(this._specialLayer.shadowCameraFar=this._layers[0].shadowCameraFar,Kr.copy(this._specialLayer.matShadowView,this._layers[0].matShadowView),Kr.copy(this._specialLayer.matShadowProj,this._layers[0].matShadowProj),Kr.copy(this._specialLayer.matShadowViewProj,this._layers[0].matShadowViewProj),this._specialLayer.copyToValidFrustum(this._layers[0].validFrustum)):(this._specialLayer.calculateSplitFrustum(t,aO,.1,e.shadowDistance),this._specialLayer.createMatrix(e,r,!0))}},e._getCameraWorldMatrix=function(t,e){if(e.node){var i=e.node,n=i.worldPosition,r=i.worldRotation;Kr.fromRT(t,r,n)}},n(t,[{key:"castShadowObjects",get:function(){return this._castShadowObjects}},{key:"layerObjects",get:function(){return this._layerObjects}},{key:"layers",get:function(){return this._layers}},{key:"specialLayer",get:function(){return this._specialLayer}}]),t}(),CO=t("df",function(){function t(){this.fog=new sA,this.ambient=new vb,this.skybox=new eA,this.shadows=new JT,this.csmLayers=new AO,this.octree=new QM,this.skin=new ZM,this.postSettings=new ID,this.lightProbes=A.internal.LightProbes?new A.internal.LightProbes:null,this.validPunctualLights=[],this.renderObjects=[],this.shadowFrameBufferMap=new Map,this._geometryRendererMaterials=[],this._geometryRendererPasses=[],this._geometryRendererShaders=[],this._occlusionQueryVertexBuffer=null,this._occlusionQueryIndicesBuffer=null,this._occlusionQueryInputAssembler=null,this._occlusionQueryMaterial=null,this._occlusionQueryShader=null,this._isHDR=!0,this._shadingScale=1,this._csmSupported=!0,this._standardSkinMeshRenderer=null,this._standardSkinModel=null,this._skinMaterialModel=null,this._shadingScale=1}var e=t.prototype;return e.activate=function(t){return this._device=t,this.initGeometryRendererMaterials(),this.initOcclusionQuery(),!0},e.initGeometryRendererMaterials=function(){for(var t=0,e=this._geometryRendererMaterials,i=0;i<6;i++){e[i]=new GT,e[i]._uuid="geometry-renderer-material-"+i,e[i].initialize({effectName:"internal/builtin-geometry-renderer",technique:i});for(var n=e[i].passes,r=0;r0&&(this._occlusionQueryShader=t.passes[0].getShaderVariant())}},e.getOcclusionQueryPass=function(){return this._occlusionQueryMaterial&&this._occlusionQueryMaterial.passes.length>0?this._occlusionQueryMaterial.passes[0]:null},e.updatePipelineSceneData=function(){},e.destroy=function(){var t,e,i;this.shadows.destroy(),this.csmLayers.destroy(),this.validPunctualLights.length=0,null==(t=this._occlusionQueryInputAssembler)||t.destroy(),this._occlusionQueryInputAssembler=null,null==(e=this._occlusionQueryVertexBuffer)||e.destroy(),this._occlusionQueryVertexBuffer=null,null==(i=this._occlusionQueryIndicesBuffer)||i.destroy(),this._occlusionQueryIndicesBuffer=null,this._standardSkinMeshRenderer=null,this._standardSkinModel=null,this._skinMaterialModel=null},e._createOcclusionQueryIA=function(){var t=this._device,e=new Float32Array([-1,-1,-1,1,-1,-1,-1,1,-1,1,1,-1,-1,-1,1,1,-1,1,-1,1,1,1,1,1]);this._occlusionQueryVertexBuffer=t.createBuffer(new ud(10,1,96,12)),this._occlusionQueryVertexBuffer.update(e);var i=new Uint16Array([0,2,1,1,2,3,4,5,6,5,7,6,1,3,7,1,7,5,0,4,6,0,6,2,0,1,5,0,5,4,2,6,7,2,7,3]);this._occlusionQueryIndicesBuffer=t.createBuffer(new ud(6,1,72,2)),this._occlusionQueryIndicesBuffer.update(i);var n=[new Cd("a_position",32)],r=new Bd(n,[this._occlusionQueryVertexBuffer],this._occlusionQueryIndicesBuffer);return t.createInputAssembler(r)},n(t,[{key:"isHDR",get:function(){return this._isHDR},set:function(t){this._isHDR=t}},{key:"shadingScale",get:function(){return this._shadingScale},set:function(t){this._shadingScale=t}},{key:"csmSupported",get:function(){return this._csmSupported},set:function(t){this._csmSupported=t}},{key:"standardSkinModel",get:function(){return this._standardSkinModel},set:function(t){this._standardSkinModel=t}},{key:"standardSkinMeshRenderer",get:function(){return this._standardSkinMeshRenderer},set:function(t){this._standardSkinMeshRenderer&&this._standardSkinMeshRenderer!==t&&this._standardSkinMeshRenderer.clearGlobalStandardSkinObjectFlag(),this._standardSkinMeshRenderer=t,this.standardSkinModel=t?t.model:null}},{key:"skinMaterialModel",get:function(){return this._skinMaterialModel},set:function(t){this._skinMaterialModel=t}},{key:"geometryRendererPasses",get:function(){return this._geometryRendererPasses}},{key:"geometryRendererShaders",get:function(){return this._geometryRendererShaders}}]),t}()),DO=gs(),BO=((nO={})[Ue.ORIENTATION_AUTO]=Ne.AUTO,nO[Ue.ORIENTATION_LANDSCAPE]=Ne.LANDSCAPE,nO[Ue.ORIENTATION_PORTRAIT]=Ne.PORTRAIT,nO),IO=t("h8",function(t){function e(){var e;(e=t.call(this)||this)._designResolutionSize=gs(0,0),e._scaleX=1,e._scaleY=1,e._viewportRect=Ss(),e._visibleRect=Ss(),e._autoFullScreen=!1,e._retinaEnabled=!1,e._resizeCallback=null;var i=MO,n=PO;return e._rpExactFit=new NO(i.EQUAL_TO_FRAME,n.EXACT_FIT),e._rpShowAll=new NO(i.EQUAL_TO_FRAME,n.SHOW_ALL),e._rpNoBorder=new NO(i.EQUAL_TO_FRAME,n.NO_BORDER),e._rpFixedHeight=new NO(i.EQUAL_TO_FRAME,n.FIXED_HEIGHT),e._rpFixedWidth=new NO(i.EQUAL_TO_FRAME,n.FIXED_WIDTH),e._resolutionPolicy=e._rpShowAll,e}s(e,t);var i=e.prototype;return i.init=function(){var t=oh.windowSize,e=t.width,i=t.height;this._designResolutionSize.width=e,this._designResolutionSize.height=i,this._viewportRect.width=e,this._viewportRect.height=i,this._visibleRect.width=e,this._visibleRect.height=i,DO.width=this._visibleRect.width,DO.height=this._visibleRect.height,uh.init(this._visibleRect),this.resizeWithBrowserSize(!0);var n=ze.querySettings("screen","designResolution");n&&this.setDesignResolutionSize(Number(n.width),Number(n.height),n.policy||NO.FIXED_HEIGHT),oh.on("window-resize",this._updateAdaptResult,this),oh.on("fullscreen-change",this._updateAdaptResult,this)},i.resizeWithBrowserSize=function(t){sh.handleResizeEvent=t},i.setResizeCallback=function(t){"function"!=typeof t&&null!=t||(this._resizeCallback=t)},i.setOrientation=function(t){sh.orientation=BO[t]},i.adjustViewportMeta=function(){},i.enableRetina=function(t){this._retinaEnabled=!!t},i.isRetinaEnabled=function(){return this._retinaEnabled},i.enableAutoFullScreen=function(t){t!==this._autoFullScreen&&(this._autoFullScreen=t,t&&oh.requestFullScreen().catch((function(){})))},i.isAutoFullScreenEnabled=function(){return this._autoFullScreen},i.setCanvasSize=function(t,e){sh.resolutionScale=1;var i=sh.devicePixelRatio,n=new ms(t*i,e*i);oh.windowSize=n},i.getCanvasSize=function(){return oh.windowSize},i.getFrameSize=function(){var t=sh.devicePixelRatio,e=oh.windowSize;return e.width/=t,e.height/=t,e},i.setFrameSize=function(t,e){var i=sh.devicePixelRatio;oh.windowSize=new ms(t*i,e*i)},i.getVisibleSize=function(){return new ms(this._visibleRect.width,this._visibleRect.height)},i.getVisibleSizeInPixel=function(){return new ms(this._visibleRect.width*this._scaleX,this._visibleRect.height*this._scaleY)},i.getVisibleOrigin=function(){return new ds(this._visibleRect.x,this._visibleRect.y)},i.getVisibleOriginInPixel=function(){return new ds(this._visibleRect.x*this._scaleX,this._visibleRect.y*this._scaleY)},i.getResolutionPolicy=function(){return this._resolutionPolicy},i._updateResolutionPolicy=function(t){if(t instanceof NO)this._resolutionPolicy=t;else{var e=NO;t===e.EXACT_FIT&&(this._resolutionPolicy=this._rpExactFit),t===e.SHOW_ALL&&(this._resolutionPolicy=this._rpShowAll),t===e.NO_BORDER&&(this._resolutionPolicy=this._rpNoBorder),t===e.FIXED_HEIGHT&&(this._resolutionPolicy=this._rpFixedHeight),t===e.FIXED_WIDTH&&(this._resolutionPolicy=this._rpFixedWidth)}},i.setResolutionPolicy=function(t){this._updateResolutionPolicy(t);var e=zO.getDesignResolutionSize();zO.setDesignResolutionSize(e.width,e.height,t)},i.setDesignResolutionSize=function(t,e,i){if(t>0&&e>0){this._updateResolutionPolicy(i);var n=this._resolutionPolicy;n&&n.preApply(this),this._designResolutionSize.width=t,this._designResolutionSize.height=e;var r=n.apply(this,this._designResolutionSize);if(r.scale&&2===r.scale.length&&(this._scaleX=r.scale[0],this._scaleY=r.scale[1]),r.viewport){var s=this._viewportRect,a=this._visibleRect,o=r.viewport;s.x=o.x,s.y=o.y,s.width=o.width,s.height=o.height,a.x=0,a.y=0,a.width=o.width/this._scaleX,a.height=o.height/this._scaleY}n.postApply(this),DO.width=this._visibleRect.width,DO.height=this._visibleRect.height,uh.init(this._visibleRect),this.emit("design-resolution-changed")}else ht(2200)},i.getDesignResolutionSize=function(){return new ms(this._designResolutionSize.width,this._designResolutionSize.height)},i.setRealPixelResolution=function(t,e,i){document.documentElement.style.width=t+"px",document.body.style.width=t+"px",document.body.style.left="0px",document.body.style.top="0px",this.setDesignResolutionSize(t,e,i)},i.getViewportRect=function(){return this._viewportRect},i.getScaleX=function(){return this._scaleX},i.getScaleY=function(){return this._scaleY},i.getDevicePixelRatio=function(){return sh.devicePixelRatio},i.convertToLocationInView=function(t,e,i,n){void 0===n&&(n=new ds);var r=sh.devicePixelRatio*(t-i.left),s=sh.devicePixelRatio*(i.top+i.height-e);return sh.isFrameRotated?(n.x=oh.windowSize.width-s,n.y=r):(n.x=r,n.y=s),n},i._convertToUISpace=function(t){var e=this._viewportRect;t.x=(t.x-e.x)/this._scaleX,t.y=(t.y-e.y)/this._scaleY},i._updateAdaptResult=function(t,e,i){A.director.root.resize(t,e,void 0===i||0===i?1:i);var n=this._designResolutionSize,r=n.width,s=n.height;t>0&&e>0?this.setDesignResolutionSize(r,s,this._resolutionPolicy):K(!1,"_updateAdaptResult Invalid size."),this.emit("canvas-resize"),this._resizeCallback&&this._resizeCallback()},e}(Bo(Ff)));IO.instance=void 0;var MO=function(){function t(){this.name="ContainerStrategy"}var e=t.prototype;return e.preApply=function(){},e.apply=function(){},e.postApply=function(){},e._setupCanvas=function(){var t=A.game.canvas;if(t){var e=oh.windowSize;t.width!==e.width&&(t.width=e.width),t.height!==e.height&&(t.height=e.height)}},t}();MO.EQUAL_TO_FRAME=void 0,MO.PROPORTION_TO_FRAME=void 0;var PO=function(){function t(){this.name="ContentStrategy",this._result={scale:[1,1],viewport:null},this._strategy=NO.UNKNOWN}var e=t.prototype;return e.preApply=function(){},e.apply=function(){return{scale:[1,1]}},e.postApply=function(){},e._buildResult=function(t,e,i,n,r,s){Math.abs(t-i)<2&&(i=t),Math.abs(e-n)<2&&(n=e);var a=new bs(Math.round((t-i)/2),Math.round((e-n)/2),i,n),o=this._result;return o.scale=[r,s],o.viewport=a,o},n(t,[{key:"strategy",get:function(){return this._strategy}}]),t}(),EO=function(t){function e(){var e;return(e=t.call(this)||this).name="EqualToFrame",e}return s(e,t),e.prototype.apply=function(){sh.isProportionalToFrame=!1,this._setupCanvas()},e}(MO),OO=function(t){function e(){var e;return(e=t.call(this)||this).name="ProportionalToFrame",e}return s(e,t),e.prototype.apply=function(){sh.isProportionalToFrame=!0,this._setupCanvas()},e}(MO);MO.EQUAL_TO_FRAME=new EO,MO.PROPORTION_TO_FRAME=new OO;var kO=function(t){function e(){var e;return(e=t.call(this)||this).name="ExactFit",e._strategy=NO.EXACT_FIT,e}return s(e,t),e.prototype.apply=function(t,e){var i=oh.windowSize,n=i.width,r=i.height,s=n/e.width,a=r/e.height;return this._buildResult(n,r,n,r,s,a)},e}(PO),RO=function(t){function e(){var e;return(e=t.call(this)||this).name="ShowAll",e._strategy=NO.SHOW_ALL,e}return s(e,t),e.prototype.apply=function(t,e){var i,n,r=oh.windowSize,s=r.width,a=r.height,o=e.width,h=e.height,u=s/o,l=a/h,c=0;return ue){var r=n;n=i,i=r}this.scaleSize=t/e>16/9?e/n:t/i},t.update=function(t){var e=this.settings,i=this.device,n=this.swapchain,r=i.capabilities;Kr.ortho(this.projection,-1,1,-1,1,-1,1,r.clipSpaceMinZ,r.clipSpaceSignY,n.surfaceTransform);var s=n.width,a=n.height;this.initScale(),this._curTime+=1e3*t;var o=nl(tn(this._curTime/e.totalTime)),h=1,u=1,l=this.bgImage;if("custom"===e.background.type){e.policy===NO.FIXED_WIDTH?(h=s,u=s/l.width*l.height):e.policy===NO.FIXED_HEIGHT?(h=a/l.height*l.width,u=a):e.policy===NO.SHOW_ALL?l.width/this.bgHeight>s/a?(h=s,u=s/l.width*l.height):(h=a/l.height*l.width,u=a):e.policy===NO.NO_BORDER?l.width/l.height>s/a?(h=a/l.height*l.width,u=a):(h=s,u=s/l.width*l.height):(h=s,u=a);var c=this.bgMat;GO(c,"resolution",UO.set(s,a),0),GO(c,"scale",UO.set(h,u),0),GO(c,"translate",UO.set(.5*s,.5*a),0),GO(c,"percent",1),GO(c,"u_projection",this.projection),c.passes[0].update()}var f=a*this.logoYTrans;if("none"!==this.settings.logo.type){u=.185*a*e.displayRatio,h=this.logoWidth*(.185*a/this.logoHeight)*e.displayRatio;var _=this.logoMat;GO(_,"resolution",UO.set(s,a),0),GO(_,"scale",UO.set(h,u),0),GO(_,"translate",UO.set(s*this.logoXTrans,f),0),GO(_,"percent",o),GO(_,"u_projection",this.projection),_.passes[0].update()}if("default"===this.settings.logo.type&&this.watermarkMat){var d=this.watermarkTexture.width,p=this.watermarkTexture.height;h=d,u=p;var m=f-(.5*this.logoHeight*e.displayRatio+this.textYExtraTrans)*this.scaleSize-.5*p,g=this.watermarkMat;GO(g,"resolution",UO.set(s,a),0),GO(g,"scale",UO.set(h,u),0),GO(g,"translate",UO.set(s*this.textXTrans,m),0),GO(g,"percent",o),GO(g,"u_projection",this.projection),g.passes[0].update()}this.frame()},t.initBG=function(){var t=this.device;this.bgMat=new GT,this.bgMat.initialize({effectName:"util/splash-screen"});var e=new md;e.addressU=2,e.addressV=2,e.addressW=2,this.sampler=t.getSampler(e),this.bgTexture=t.createTexture(new dd(1,6,35,this.bgImage.width,this.bgImage.height));var i=this.bgMat.passes[0],n=i.getBinding("mainTexture");i.bindTexture(n,this.bgTexture),this.shader=i.getShaderVariant();var r=i.descriptorSet;r.bindSampler(n,this.sampler),r.update();var s=new id,a=s.texExtent;a.width=this.bgImage.width,a.height=this.bgImage.height,a.depth=1,t.copyTexImagesToTexture([this.bgImage],this.bgTexture,[s])},t.initLogo=function(){var t=this.device;this.logoMat=new GT,this.logoMat.initialize({effectName:"util/splash-screen"});var e=new md;e.addressU=2,e.addressV=2,e.addressW=2,this.sampler=t.getSampler(e),this.logoTexture=t.createTexture(new dd(1,6,35,this.logoImage.width,this.logoImage.height));var i=this.logoMat.passes[0],n=i.getBinding("mainTexture");i.bindTexture(n,this.logoTexture),this.shader=i.getShaderVariant();var r=i.descriptorSet;r.bindSampler(n,this.sampler),r.update();var s=new id,a=s.texExtent;a.width=this.logoImage.width,a.height=this.logoImage.height,a.depth=1,t.copyTexImagesToTexture([this.logoImage],this.logoTexture,[s]);var o=this.logoImage.width/this.logoImage.height;o<1?(this.logoWidth=this.logoWidthTemp,this.logoHeight=this.logoWidthTemp/o):(this.logoWidth=this.logoHeightTemp*o,this.logoHeight=this.logoHeightTemp)},t.initWaterMark=function(){var t=B.document.createElement("canvas");t.height=this.textHeight*this.scaleSize,t.style.width=""+t.width,t.style.height=""+t.height;var e="Created with Cocos",i=t.getContext("2d");i.font=this.textSize*this.scaleSize+"px Arial",i.textBaseline="top",i.textAlign="center",i.fillStyle="#707070";var n=i.measureText(e).width+10;t.width=n,i.font=this.textSize*this.scaleSize+"px Arial",i.textBaseline="top",i.textAlign="center",i.fillStyle="#707070",i.fillText(e,t.width/2,0);var r=new id,s=r.texExtent;s.width=t.width,s.height=t.height,s.depth=1,this.watermarkTexture=this.device.createTexture(new dd(1,6,35,t.width,t.height)),this.device.copyTexImagesToTexture([t],this.watermarkTexture,[r]),this.watermarkMat=new GT,this.watermarkMat.initialize({effectName:"util/splash-screen"});var a=this.watermarkMat.passes[0],o=a.getBinding("mainTexture");a.bindTexture(o,this.watermarkTexture),a.descriptorSet.update()},t.frame=function(){var t=this.device,e=this.swapchain;this.projection;var i=this.bgMat,n=this.logoMat,r=this.watermarkMat,s=this.settings,a=this.quadAssmebler;if(t.capabilities,!hh.isXR||xr.entry.isRenderAllowable())for(var o=hh.isXR?2:1,h=0;h=this.settings.totalTime}},{key:"curTime",get:function(){return this._curTime},set:function(t){this._curTime=t}}],[{key:"instance",get:function(){return e._ins}}]),e}();HO._ins=null,A.internal.SplashScreen=HO;var WO=new(function(){function t(){this._data=null}return t.prototype.init=function(t){var e=this;return void 0===t&&(t=""),C.rendering&&C.rendering.enableEffectImport&&t?new Promise((function(i,n){var r=new XMLHttpRequest;r.open("GET",t),r.responseType="arraybuffer",r.onload=function(){e._data=r.response,i()},r.onerror=function(){n(new Error("request effect settings failed!"))},r.send(null)})):Promise.resolve()},n(t,[{key:"data",get:function(){return this._data}}]),t}());C.effectSettings=WO;var jO=ze.querySettings.bind(ze),qO=t("dV",function(t){function i(){var e;return(e=t.call(this)||this).frame=null,e.container=null,e.canvas=null,e.renderType=-1,e.eventTargetOn=t.prototype.on,e.eventTargetOnce=t.prototype.once,e.config={},e.onStart=null,e.frameTime=1e3/60,e._isCloning=!1,e._inited=!1,e._engineInited=!1,e._rendererInitialized=!1,e._paused=!0,e._pausedByEngine=!1,e._frameRate=60,e._pacer=null,e._initTime=0,e._startTime=0,e._deltaTime=0,e._useFixedDeltaTime=!1,e._shouldLoadLaunchScene=!0,e.onPreBaseInitDelegate=new Fo,e.onPostBaseInitDelegate=new Fo,e.onPreInfrastructureInitDelegate=new Fo,e.onPostInfrastructureInitDelegate=new Fo,e.onPreSubsystemInitDelegate=new Fo,e.onPostSubsystemInitDelegate=new Fo,e.onPreProjectInitDelegate=new Fo,e.onPostProjectInitDelegate=new Fo,e}s(i,t);var r=i.prototype;return r.setFrameRate=function(t){this.frameRate=t},r.getFrameRate=function(){return this.frameRate},r.step=function(){YE.tick(this._calculateDT(!0))},r.pauseByEngine=function(){this._paused||(this._pausedByEngine=!0,this.pause())},r.resumeByEngine=function(){this._pausedByEngine&&(this.resume(),this._pausedByEngine=!1)},r.pause=function(){var t;this._paused||(this._paused=!0,null==(t=this._pacer)||t.stop(),this.emit(i.EVENT_PAUSE))},r.resume=function(){var t;this._paused&&(wM._clearEvents(),this._paused=!1,null==(t=this._pacer)||t.start(),this.emit(i.EVENT_RESUME))},r.isPaused=function(){return this._paused},r.restart=function(){var t=this;return new Promise((function(t){YE.once("director_end_frame",(function(){return t()}))})).then((function(){YE.reset(),A.Object._deferredDestroy(),t.pause(),t.resume(),t._shouldLoadLaunchScene=!0})).then((function(){return HO.createInstance().init()})).then((function(){t._safeEmit(i.EVENT_RESTART)}))},r.end=function(){Vo.close()},r.on=function(t,e,i,n){return this.canRegisterEvent(t)&&e.call(i),this.eventTargetOn(t,e,i,n)},r.once=function(t,e,i){return this.canRegisterEvent(t)?e.call(i):this.eventTargetOnce(t,e,i)},r.canRegisterEvent=function(t){return this._engineInited&&t===i.EVENT_ENGINE_INITED||this._inited&&t===i.EVENT_GAME_INITED||this._rendererInitialized&&t===i.EVENT_RENDERER_INITED},r.init=function(t){var n=this;return this._compatibleWithOldParams(t),Promise.resolve().then((function(){return n.emit(i.EVENT_PRE_BASE_INIT),n.onPreBaseInitDelegate.dispatch()})).then((function(){Z(t.debugMode||0)})).then((function(){return hh.init()})).then((function(){n._initEvents()})).then((function(){return ze.init(t.settingsPath,t.overrideSettings)})).then((function(){return n.emit(i.EVENT_POST_BASE_INIT),n.onPostBaseInitDelegate.dispatch()})).then((function(){return n.emit(i.EVENT_PRE_INFRASTRUCTURE_INIT),n.onPreInfrastructureInitDelegate.dispatch()})).then((function(){Ue.init(),n._initXR();var t={frame:document.querySelector("#GameDiv"),container:document.querySelector("#Cocos3dGameContainer"),canvas:document.querySelector("#GameCanvas")};return n.canvas=t.canvas,n.frame=t.frame,n.container=t.container,oh.init(),Jf.init(),Wp.init(n.canvas,Cb)})).then((function(){if(jO("rendering","customPipeline")){if(!A.rendering)return void ht(12109);Ue.CUSTOM_PIPELINE_NAME||(Ue.CUSTOM_PIPELINE_NAME="Builtin")}else A.rendering=void 0;fT.init(),mT.init(),Ly.init(),n.initPacer()})).then((function(){return n.emit(i.EVENT_POST_INFRASTRUCTURE_INIT),n.onPostInfrastructureInitDelegate.dispatch()})).then((function(){return n.emit(i.EVENT_PRE_SUBSYSTEM_INIT),n.onPreSubsystemInitDelegate.dispatch()})).then((function(){return WO.init(jO("rendering","effectSettingsPath"))})).then((function(){if(A.rendering&&A.rendering.enableEffectImport)if(3!==jO("rendering","renderMode")){var t=WO.data;null!==t?A.rendering.init(Wp.gfxDevice,t):ht(1102)}else A.rendering.init(Wp.gfxDevice,null)})).then((function(){var t=jO("scripting","scriptPackages");return t?Promise.all(t.map((function(t){return e.import(t)}))):Promise.resolve([])})).then((function(){return YE.init(),mT.loadBuiltinAssets()})).then((function(){return n.emit(i.EVENT_POST_SUBSYSTEM_INIT),n.onPostSubsystemInitDelegate.dispatch()})).then((function(){X("Cocos Creator v"+D),n.emit(i.EVENT_ENGINE_INITED),n._engineInited=!0})).then((function(){return n.emit(i.EVENT_PRE_PROJECT_INIT),n.onPreProjectInitDelegate.dispatch()})).then((function(){var t=jO("plugins","jsList"),e=Promise.resolve();return t&&t.forEach((function(t){e=e.then((function(){return e="src/"+t,new Promise((function(t,i){var n;function r(t){t.filename===e&&(n=t.error)}window.addEventListener("error",r);var s=document.createElement("script");s.charset="utf-8",s.async=!0,s.crossOrigin="anonymous",s.addEventListener("error",(function(){window.removeEventListener("error",r),i(Error("Error loading "+e))})),s.addEventListener("load",(function(){window.removeEventListener("error",r),document.head.removeChild(s),n?i(n):t()})),s.src=e.replace("#","%23"),document.head.appendChild(s)}));var e}))})),e})).then((function(){return n._loadProjectBundles()})).then((function(){return n._loadCCEScripts()})).then((function(){return n._setupRenderPipeline()})).then((function(){return n._loadPreloadAssets()})).then((function(){return mT.compileBuiltinMaterial(),HO.createInstance().init()})).then((function(){return n.emit(i.EVENT_POST_PROJECT_INIT),n.onPostProjectInitDelegate.dispatch()})).then((function(){n._inited=!0,n._safeEmit(i.EVENT_GAME_INITED)}))},r._initXR=function(){},r._compatibleWithOldParams=function(t){var e=t.overrideSettings=t.overrideSettings||{};"showFPS"in t&&(e.profiling=e.profiling||{},e.profiling.showFPS=t.showFPS),"frameRate"in t&&(e.screen=e.screen||{},e.screen.frameRate=t.frameRate),"renderMode"in t&&(e.rendering=e.rendering||{},e.rendering.renderMode=t.renderMode),"renderPipeline"in t&&(e.rendering=e.rendering||{},e.rendering.renderPipeline=t.renderPipeline),"assetOptions"in t&&(e.assets=e.assets||{},Object.assign(e.assets,t.assetOptions)),"customJointTextureLayouts"in t&&(e.animation=e.animation||{},e.animation.customJointTextureLayouts=t.customJointTextureLayouts),"physics"in t&&(e.physics=e.physics||{},Object.assign(e.physics,t.physics)),"orientation"in t&&(e.screen=e.screen||{},e.screen.orientation=t.orientation),"exactFitScreen"in t&&(e.screen=e.screen||{},e.screen.exactFitScreen=t.exactFitScreen)},r._loadPreloadAssets=function(){var t=jO("assets","preloadAssets");return t?Promise.all(t.map((function(t){return new Promise((function(e,i){fT.loadAny(t,(function(t){t?i(t):e()}))}))}))):Promise.resolve([])},r._loadCCEScripts=function(){return new Promise((function(t){t()}))},r._loadProjectBundles=function(){var t=jO("assets","preloadBundles");return t?Promise.all(t.map((function(t){var e=t.bundle,i=t.version;return new Promise((function(t,n){var r={};i&&(r.version=i),fT.loadBundle(e,r,(function(e){e?n(e):t()}))}))}))):Promise.resolve([])},r.run=function(t){t&&(this.onStart=t),this._inited&&this.resume()},r._calculateDT=function(t){if(this._useFixedDeltaTime=t,t)return this._startTime=performance.now(),this.frameTime/1e3;var e=performance.now();return this._deltaTime=e>this._startTime?(e-this._startTime)/1e3:0,this._deltaTime>i.DEBUG_DT_THRESHOLD&&(this._deltaTime=this.frameTime/1e3),this._startTime=e,this._deltaTime},r._updateCallback=function(){var t=this;if(this._inited)if(HO.instance&&!HO.instance.isFinished)HO.instance.update(this._calculateDT(!1));else if(this._shouldLoadLaunchScene){HO.releaseInstance(),this._shouldLoadLaunchScene=!1;var e,i=jO("launch","launchScene");i?YE.loadScene(i,(function(){it(1103,i),t._initTime=performance.now(),YE.startAnimation(),null==t.onStart||t.onStart()})):(this._initTime=performance.now(),YE.startAnimation(),null==(e=this.onStart)||e.call(this))}else YE.tick(this._calculateDT(!1))},r.initPacer=function(){var t,e=null!==(t=jO("screen","frameRate"))&&void 0!==t?t:60;K("number"==typeof e),this._pacer=new KE,this._pacer.onTick=this._updateCallback.bind(this),this.frameRate=e},r._initEvents=function(){Vo.on("show",this._onShow,this),Vo.on("hide",this._onHide,this),Vo.on("close",this._onClose,this)},r._onHide=function(){this.emit(i.EVENT_HIDE),this.pauseByEngine()},r._onShow=function(){this.emit(i.EVENT_SHOW),this.resumeByEngine()},r._onClose=function(){this.emit(i.EVENT_CLOSE),Vo.exit()},r.addPersistRootNode=function(t){YE.addPersistRootNode(t)},r.removePersistRootNode=function(t){YE.removePersistRootNode(t)},r.isPersistRootNode=function(t){return YE.isPersistRootNode(t)},r._setupRenderPipeline=function(){var t=jO("rendering","customPipeline");return this._setRenderPipeline(!!t)},r._setRenderPipeline=function(t){YE.root.setRenderPipeline(t)?(this._rendererInitialized=!0,this._safeEmit(i.EVENT_RENDERER_INITED)):ht(1222)},r._safeEmit=function(t){this.emit(t)},n(i,[{key:"inited",get:function(){return this._inited}},{key:"frameRate",get:function(){return this._frameRate},set:function(t){"number"!=typeof t&&(t=parseInt(t,10),Number.isNaN(t)&&(t=60)),this._frameRate=t,this.frameTime=1e3/t,this._pacer&&(this._pacer.targetFrameRate=this._frameRate)}},{key:"deltaTime",get:function(){return this._useFixedDeltaTime?this.frameTime/1e3:this._deltaTime}},{key:"totalTime",get:function(){return performance.now()-this._initTime}},{key:"frameStartTime",get:function(){return this._startTime}}]),i}(Io));qO.EVENT_HIDE="game_on_hide",qO.EVENT_SHOW="game_on_show",qO.EVENT_LOW_MEMORY="game_on_low_memory",qO.EVENT_GAME_INITED="game_inited",qO.EVENT_ENGINE_INITED="engine_inited",qO.EVENT_RENDERER_INITED="renderer_inited",qO.EVENT_PRE_BASE_INIT="pre_base_init",qO.EVENT_POST_BASE_INIT="post_base_init",qO.EVENT_PRE_INFRASTRUCTURE_INIT="pre_infrastructure_init",qO.EVENT_POST_INFRASTRUCTURE_INIT="post_infrastructure_init",qO.EVENT_PRE_SUBSYSTEM_INIT="pre_subsystem_init",qO.EVENT_POST_SUBSYSTEM_INIT="post_subsystem_init",qO.EVENT_PRE_PROJECT_INIT="pre_project_init",qO.EVENT_POST_PROJECT_INIT="post_project_init",qO.EVENT_RESTART="game_on_restart",qO.EVENT_PAUSE="game_on_pause",qO.EVENT_RESUME="game_on_resume",qO.EVENT_CLOSE="game_on_close",qO.RENDER_TYPE_CANVAS=0,qO.RENDER_TYPE_WEBGL=1,qO.RENDER_TYPE_OPENGL=2,qO.RENDER_TYPE_HEADLESS=3,qO.DEBUG_DT_THRESHOLD=1,A.Game=qO;var XO=t("dW",A.game=new qO);gt(XE.prototype,"director",[{name:"calculateDeltaTime"},{name:"getDeltaTime",suggest:"Use game.deltaTime instead"},{name:"getTotalTime",suggest:"Use game.totalTime instead"},{name:"getCurrentTime",suggest:"Use game.frameStartTime instead"}]),mt(XE.prototype,"director",[{name:"setAnimationInterval",suggest:"please use game.frameRate instead"},{name:"getAnimationInterval",suggest:"please use game.frameRate instead"},{name:"getRunningScene",suggest:"please use getScene instead"},{name:"setDepthTest",suggest:"please use camera API instead"},{name:"setClearColor",suggest:"please use camera API instead"},{name:"getWinSize",suggest:"please use view.getVisibleSize instead"},{name:"getWinSizeInPixels"},{name:"purgeCachedData",suggest:"please use assetManager.releaseAll instead"},{name:"convertToGL"},{name:"convertToUI"}]),pt(YE,"director",[{name:"_getSceneUuid",targetName:"assetManager.main",newName:"getSceneInfo",customFunction:function(t){var e;return fT.main?null==(e=fT.main.getSceneInfo(t))?void 0:e.uuid:""}}]),gt(XO,"game",[{name:"collisionMatrix"},{name:"groupList"}]),pt(XO,"game",[{name:"_sceneInfos",targetName:"assetManager.main",newName:"getSceneInfo",customGetter:function(){var t=[];return fT.main&&fT.main.config.scenes.forEach((function(e){t.push(e)})),t}}]);var YO=t("a4",function(t){function e(){var e;return(e=t.call(this)||this)._atlases=[],e._atlasIndex=-1,e._maxAtlasCount=5,e._textureSize=2048,e._maxFrameSize=512,e._textureBleeding=!0,e._enabled=!1,e}s(e,t);var i=e.prototype;return i.newAtlas=function(){var t=this._atlases[++this._atlasIndex];return!t&&this._atlasIndex=this._maxAtlasCount||!t||t.original)return null;if(!t.packable)return null;var e=t.texture.getSamplerInfo();if(2!==e.minFilter||2!==e.magFilter||0!==e.mipFilter)return null;var i=this._atlases[this._atlasIndex];i||(i=this.newAtlas());var n=i?i.insertSpriteFrame(t):null;return!n&&this._atlasIndex=0;e--)this._atlases[e].removeSpriteFrame(t);var i=t.original._texture;this.deleteAtlasTexture(i)}},i.deleteAtlasTexture=function(t){if(t)for(var e=this._atlases.length-1;e>=0;e--)this._atlases[e].deleteInnerTexture(t),this._atlases[e].isEmpty()&&(this._atlases[e].destroy(),this._atlases.splice(e,1),this._atlasIndex--)},i.packToDynamicAtlas=function(t,e){if(this._enabled&&e&&!e.original&&e.packable&&e.texture&&e.texture.width>0&&e.texture.height>0){var i=this.insertSpriteFrame(e);i&&e._setDynamicAtlasFrame(i)}},n(e,[{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled!==t&&(t?(this.reset(),YE.on("director_before_scene_launch",this.beforeSceneLoad,this)):(this.reset(),YE.off("director_before_scene_launch",this.beforeSceneLoad,this)),this._enabled=t)}},{key:"maxAtlasCount",get:function(){return this._maxAtlasCount},set:function(t){this._maxAtlasCount=t}},{key:"atlasCount",get:function(){return this._atlases.length}},{key:"textureBleeding",get:function(){return this._textureBleeding},set:function(t){this._textureBleeding=t}},{key:"textureSize",get:function(){return this._textureSize},set:function(t){this._textureSize=t}},{key:"maxFrameSize",get:function(){return this._maxFrameSize},set:function(t){this._maxFrameSize=t}}]),e}(Ff));YO.instance=void 0;var JO=t("a5",YO.instance=new YO);YE.registerSystem("dynamicAtlasManager",JO,0),A.internal.dynamicAtlasManager=JO;var KO={positions:"a_position",normals:"a_normal",uvs:"a_texCoord",colors:"a_color"},QO=function(){function t(){this._arrayBufferOrPaddings=[],this._length=0}var e=t.prototype;return e.setNextAlignment=function(t){if(0!==t){var e=this._length%t;if(0!==e){var i=t-e;this._arrayBufferOrPaddings.push(i),this._length+=i}}},e.addBuffer=function(t){var e=this._length;return this._arrayBufferOrPaddings.push(t),this._length+=t.byteLength,e},e.getLength=function(){return this._length},e.getCombined=function(){var t=new Uint8Array(this._length),e=0;return this._arrayBufferOrPaddings.forEach((function(i){"number"==typeof i?e+=i:(t.set(new Uint8Array(i),e),e+=i.byteLength)})),t.buffer},t}();function ZO(t,e){return new $O(t,e)}var $O=function(){function t(t,e){if(this._subMeshRenderings=[],this._mesh=t,this._mesh.struct.morph){var i=this._mesh.struct.primitives.length;this._subMeshRenderings=new Array(i).fill(null);for(var n=0;n60?this._subMeshRenderings[n]=new ek(this._mesh,n,this._mesh.struct.morph,e):this._subMeshRenderings[n]=new tk(this._mesh,n,this._mesh.struct.morph,e))}}}return t.prototype.createInstance=function(){for(var t=this,e=this._mesh.struct.primitives.length,i=new Array(e),n=0;n>1;return{width:1<<(1&e?i+1:i),height:1<_&&(_=t[u]),t[u]>=1;for(c=n<<16|u,l=o;l>>=1){case 0:var n=this.input,a=this.a,u=this.c,l=this.b,c=n.length,f=e,d=u.length,p=e;switch(this.d=this.f=0,a+1>=c&&t(Error("invalid uncompressed block header: LEN")),f=n[a++]|n[a++]<<8,a+1>=c&&t(Error("invalid uncompressed block header: NLEN")),f===~(n[a++]|n[a++]<<8)&&t(Error("invalid uncompressed block header: length verify")),a+f>n.length&&t(Error("input buffer is broken")),this.e){case o:for(;l+f>u.length;){if(f-=p=d-l,r)u.set(n.subarray(a,a+p),l),l+=p,a+=p;else for(;p--;)u[l++]=n[a++];this.b=l,u=E(this),l=this.b}break;case h:for(;l+f>u.length;)u=O(this,{m:2});break;default:t(Error("invalid inflate mode"))}if(r)u.set(n.subarray(a,a+f),l),l+=f,a+=f;else for(;f--;)u[l++]=n[a++];this.a=a,this.b=l,this.c=u;break;case 1:switch(this.e){case h:P(this,A,D);break;case o:M(this,A,D);break;default:t(Error("invalid inflate mode"))}break;case 2:var m,g,y,v,b=B(this,5)+257,S=B(this,5)+1,w=B(this,4)+4,x=new(r?Uint8Array:Array)(_.length),T=e,C=e,k=e,R=e,F=e;for(F=0;FY&&(this.c.length=Y),X=this.c),this.buffer=X;default:t(Error("invalid inflate mode"))}};var l,c,f=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],_=r?new Uint16Array(f):f,d=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],p=r?new Uint16Array(d):d,m=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0],g=r?new Uint8Array(m):m,y=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],v=r?new Uint16Array(y):y,b=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],S=r?new Uint8Array(b):b,w=new(r?Uint8Array:Array)(288);for(l=0,c=w.length;l=l?8:255>=l?9:279>=l?7:8;var x,T,A=s(w),C=new(r?Uint8Array:Array)(30);for(x=0,T=C.length;x>3)>=a.length&&t(Error("input buffer is broken"));s>>i,e.d=s-i,e.a=o,n}function I(e,i){for(var n,r,s=e.f,a=e.d,o=e.input,h=e.a,u=o.length,l=i[0],c=i[1];a=u);)s|=o[h++]<>>16)>a&&t(Error("invalid code length: "+r)),e.f=s>>r,e.d=a-r,e.a=h,65535&n}function M(t,e,i){var n=t.c,r=t.b;t.l=e;for(var s,a,o,h,u=n.length-258;256!==(s=I(t,e));)if(256>s)r>=u&&(t.b=r,n=E(t),r=t.b),n[r++]=s;else for(h=p[a=s-257],0=u&&(t.b=r,n=E(t),r=t.b);h--;)n[r]=n[r++-o];for(;8<=t.d;)t.d-=8,t.a--;t.b=r}function P(t,e,i){var n=t.c,r=t.b;t.l=e;for(var s,a,o,h,u=n.length;256!==(s=I(t,e));)if(256>s)r>=u&&(u=(n=O(t)).length),n[r++]=s;else for(h=p[a=s-257],0u&&(u=(n=O(t)).length);h--;)n[r]=n[r++-o];for(;8<=t.d;)t.d-=8,t.a--;t.b=r}function E(t){var e,i,n=new(r?Uint8Array:Array)(t.b-32768),s=t.b-32768,a=t.c;if(r)n.set(a.subarray(32768,n.length));else for(e=0,i=n.length;ee;++e)a[e]=a[s+e];return t.b=32768,a}function O(t,e){var i,n,s,a=t.input.length/t.a+1|0,o=t.input,h=t.c;return e&&("number"==typeof e.m&&(a=e.m),"number"==typeof e.r&&(a+=e.r)),n=2>a?(s=(o.length-t.a)/t.l[2]/2*258|0)>>0;var r=e;if("string"==typeof r){var s,a,o=r.split("");for(s=0,a=o.length;s>>0;r=o}for(var h,u=1,l=0,c=r.length,f=0;0>>0&&t(Error("invalid adler-32 checksum"))}return e};var R=8;n("Zlib.Inflate",k),n("Zlib.Inflate.prototype.decompress",k.prototype.i);var F,L,V,N,z={ADAPTIVE:u.p,BLOCK:u.q};if(Object.keys)F=Object.keys(z);else for(L in F=[],V=0,z)F[V++]=L;for(V=0,N=F.length;V=65536){at(10001,k,65536);continue}E>>=1,O>>=1}I=x.createBuffer(new ud(4,1,O,E)),A.push(I),M=new(Dk(P.stride))(w,P.offset,P.count),P.stride!==E&&(M=Dk(E).from(M)),I.update(M)}var R=B.vertexBundelIndices.map((function(t){return T[t]})),F=[];if(B.vertexBundelIndices.length>0)for(var L=B.vertexBundelIndices[0],V=this._struct.vertexBundles[L].attributes,N=0;N=this._struct.primitives.length)at(14201);else{var i=[];if(e.positions.length>0&&i.push(e.positions),e.normals&&e.normals.length>0&&i.push(e.normals),e.uvs&&e.uvs.length>0&&i.push(e.uvs),e.tangents&&e.tangents.length>0&&i.push(e.tangents),e.colors&&e.colors.length>0&&i.push(e.colors),e.customAttributes)for(var n=0;n0&&(p.set(m),g.update(m,d)),c.view.count=_,h.vertexCount=_}if(a.indexView){var y=a.indexView,v=y.stride,b=2===v?e.indices16.length:e.indices32.length,S=b*v,w=new Uint8Array(this._data.buffer,y.offset,S),x=2===v?new Uint8Array(e.indices16.buffer,e.indices16.byteOffset,S):new Uint8Array(e.indices32.buffer,e.indices32.byteOffset,S),T=o.indexBuffer;s.maxSubMeshIndices,S>0&&(w.set(x),T.update(x,S)),y.count=b,h.indexCount=b}if(e.minPos&&e.maxPos){var A=nr(e.minPos.x,e.minPos.y,e.minPos.z),C=nr(e.maxPos.x,e.maxPos.y,e.maxPos.z);r.bounds[t]||(r.bounds[t]=new gh),wk(r.bounds[t],A,C);var D=nr(),B=nr();r.bounds.forEach((function(t){t&&(t.getBoundary(D,B),Tk(A,D,A),xk(C,B,C))})),this._struct.minPosition=nr(A.x,A.y,A.z),this._struct.maxPosition=nr(C.x,C.y,C.z)}o.invalidateGeometricInfo()}else at(14200)},i.destroy=function(){return this.destroyRenderingMesh(),t.prototype.destroy.call(this)},i.destroyRenderingMesh=function(){if(this._renderingSubMeshes){for(var t=0;t=n.length)){Ck(Ik,Bk,n[d]),i[d]=!0;var p=e[d];Tk(p.center,p.center,Ik),xk(p.halfExtents,p.halfExtents,Ik)}}}}for(var m=0;m=this._struct.primitives.length)return null;var e=this._struct.primitives[t];if(!e.indexView)return null;var i=e.indexView.stride;return new(1===i?Uint8Array:2===i?Uint16Array:Uint32Array)(this._data.buffer,e.indexView.offset,e.indexView.count)},i.copyIndices=function(t,e){if(t>=this._struct.primitives.length)return!1;var i=this._struct.primitives[t];if(!i.indexView)return!1;for(var n=i.indexView.count,r=1===i.indexView.stride?6:2===i.indexView.stride?9:12,s=Rk(new DataView(this._data.buffer),r),a=0;a=this._struct.primitives.length))for(var n=this._struct.primitives[t].vertexBundelIndices,r=0;r0){n=null,t.attributes&&(n=t.attributes.find((function(t){return"a_position"===t.name}))||null),n||(n=zk[0]),r.push(n);var u=ip[n.format];o=Math.max(o,Math.floor(h.length/u.count)),a.push({offset:s,data:h,attribute:n}),s+=u.size}if(t.normals&&t.normals.length>0){n=null,t.attributes&&(n=t.attributes.find((function(t){return"a_normal"===t.name}))||null),n||(n=zk[1]);var l=ip[n.format];r.push(n),o=Math.max(o,Math.floor(t.normals.length/l.count)),a.push({offset:s,data:t.normals,attribute:n}),s+=l.size}if(t.uvs&&t.uvs.length>0){n=null,t.attributes&&(n=t.attributes.find((function(t){return"a_texCoord"===t.name}))||null),n||(n=zk[2]);var c=ip[n.format];r.push(n),o=Math.max(o,Math.floor(t.uvs.length/c.count)),a.push({offset:s,data:t.uvs,attribute:n}),s+=c.size}if(t.tangents&&t.tangents.length>0){n=null,t.attributes&&(n=t.attributes.find((function(t){return"a_tangent"===t.name}))||null),n||(n=zk[3]);var f=ip[n.format];r.push(n),o=Math.max(o,Math.floor(t.tangents.length/f.count)),a.push({offset:s,data:t.tangents,attribute:n}),s+=f.size}if(t.colors&&t.colors.length>0){n=null,t.attributes&&(n=t.attributes.find((function(t){return"a_color"===t.name}))||null),n||(n=zk[4]);var _=ip[n.format];r.push(n),o=Math.max(o,Math.floor(t.colors.length/_.count)),a.push({offset:s,data:t.colors,attribute:n}),s+=_.size}if(t.customAttributes)for(var d=0;d0){var i=t%e;if(0!==i)return e-i}return 0}function Wk(t,e,i,n){n=n||{maxSubMeshes:1,maxSubMeshVertices:1024,maxSubMeshIndices:1024};var r=[],s=0;if(e.positions.length>0&&r.push(new Cd("a_position",32,!1,s++,!1,0)),e.normals&&e.normals.length>0&&r.push(new Cd("a_normal",32,!1,s++,!1,0)),e.uvs&&e.uvs.length>0&&r.push(new Cd("a_texCoord",21,!1,s++,!1,0)),e.tangents&&e.tangents.length>0&&r.push(new Cd("a_tangent",44,!1,s++,!1,0)),e.colors&&e.colors.length>0&&r.push(new Cd("a_color",44,!1,s++,!1,0)),e.customAttributes)for(var a=0;a0?w=2:e.indices32&&e.indices32.length>0&&(w=4),w>0){c+=Hk(c,w);var x=n.maxSubMeshIndices*w,T={offset:c,length:x,count:0,stride:w};d.indexView=T,c+=x}l.push(d)}var A={info:{maxSubMeshes:n.maxSubMeshes,maxSubMeshVertices:n.maxSubMeshVertices,maxSubMeshIndices:n.maxSubMeshIndices},bounds:[]};A.bounds.length=n.maxSubMeshes;var C={struct:{vertexBundles:u,primitives:l,dynamic:A},data:new Uint8Array(c)};return i||(i=new Pk),i.reset(C),i.initialize(),i.updateSubMesh(t,e),i}var jk,qk,Xk=function(){function t(){}return t.createMesh=function(t,e,i){return Gk(t,e,i)},t.createDynamicMesh=function(t,e,i,n){return Wk(t,e,i,n)},t.decodeMesh=function(t){return Lk(t)},t.inflateMesh=function(t){return Vk(t)},t}(),Yk=Object.freeze({__proto__:null,MeshUtils:Xk,createMesh:Gk,find:GP,mapBuffer:iO,readBuffer:eO,readMesh:function(t,e){void 0===e&&(e=0);var i={positions:[]},n=new DataView(t.data.buffer,t.data.byteOffset,t.data.byteLength),r=t.struct,s=r.primitives[e];s.vertexBundelIndices.forEach((function(t){var e=r.vertexBundles[t],s=e.view.offset,a=e.view,o=a.length,h=a.stride;e.attributes.forEach((function(t){var e=KO[t.name];e&&(i[e]=(i[e]||[]).concat(eO(n,t.format,s,o,h))),s+=ip[t.format].size}))}));var a=s.indexView;return i.indices=eO(n,s_["R"+8*a.stride+"UI"],a.offset,a.length),i},toPPM:function(t,e,i){return"P3 "+e+" "+i+" 255\n"+t.filter((function(t,e){return e%4<3})).toString()+"\n"},writeBuffer:tO});t("a8",Yk);var Jk,Kk,Qk,Zk=nr(),$k=$r(),tR=ir.transformMat4,eR=ir.toArray,iR=[{u:0,v:0},{u:0,v:0},{u:0,v:0},{u:0,v:0}],nR=(t("b",{UV_UPDATED:"uv_updated"}),t("c",Kh("cc.SpriteFrame")((qk=function(t){function e(e){var i;return(i=t.call(this,e)||this).vertices=null,i.uv=[],i.unbiasUV=[],i.uvSliced=[],i._rect=Ss(),i._trimmedBorder=Nn(),i._offset=ps(),i._originalSize=gs(),i._rotated=!1,i._capInsets=[0,0,0,0],i._atlasUuid="",i._texture=void 0,i._isFlipUVY=!1,i._isFlipUVX=!1,i._original=null,i._packable=!0,i._pixelsToUnit=100,i._pivot=ps(.5,.5),i._meshType=0,i._extrude=0,i._customOutLine=[],i._mesh=null,i._minPos=nr(),i._maxPos=nr(),i}s(e,t),e.createWithImage=function(t){var i=t instanceof Hm?t:new Hm(t),n=new Ey;n.image=i;var r=new e;return r.texture=n,r};var i=e.prototype;return i.textureLoaded=function(){return!!this.texture},i.isRotated=function(){return this._rotated},i.setRotated=function(t){this.rotated=t},i.getRect=function(t){return t?(t.set(this._rect),t):this._rect.clone()},i.setRect=function(t){this.rect=t},i.getOriginalSize=function(t){return t?(t.set(this._originalSize),t):this._originalSize.clone()},i.setOriginalSize=function(t){this.originalSize=t},i.getOffset=function(t){return t?(t.set(this._offset),t):this._offset.clone()},i.setOffset=function(t){this.offset=t},i.getGFXTexture=function(){return this._texture.getGFXTexture()},i.getGFXSampler=function(){return this._texture.getGFXSampler()},i.getHash=function(){return this._texture.getHash()},i.getSamplerInfo=function(){return this._texture.getSamplerInfo()},i.reset=function(t,e){void 0===e&&(e=!1);var i=this,n=!1;if(e&&(i._originalSize.set(0,0),i._rect.set(0,0,0,0),i._offset.set(0,0),i._capInsets=[0,0,0,0],i._rotated=!1,n=!0),t){t.texture&&(i._rect.set(0,0,t.texture.width,t.texture.height),i._refreshTexture(t.texture),i.checkRect(i._texture)),t.originalSize&&i._originalSize.set(t.originalSize),t.rect&&i._rect.set(t.rect),t.offset&&i._offset.set(t.offset);var r=i._capInsets;void 0!==t.borderTop&&(r[1]=t.borderTop),void 0!==t.borderBottom&&(r[3]=t.borderBottom),void 0!==t.borderLeft&&(r[0]=t.borderLeft),void 0!==t.borderRight&&(r[2]=t.borderRight),void 0!==t.isRotate&&(i._rotated=!!t.isRotate),void 0!==t.isFlipUv&&(i._isFlipUVY=!!t.isFlipUv),n=!0}n&&i.texture&&i._calculateUV(),i._calcTrimmedBorder()},i.checkRect=function(t){var e=this._rect,i=e.x,n=e.y;return this._rotated?(i+=e.height,n+=e.width):(i+=e.width,n+=e.height),i>t.width?(ht(3300,this.name+"/"+t.name,i,t.width),!1):!(n>t.height&&(ht(3301,this.name+"/"+t.name,n,t.height),1))},i._calcTrimmedBorder=function(){var t=this,e=t._originalSize.width,i=t._originalSize.height,n=.5*(e-t._rect.width),r=.5*(i-t._rect.height),s=t._offset,a=t._trimmedBorder;a.x=s.x+n,a.y=s.x-n,a.z=s.y+r,a.w=s.y-r},i.ensureMeshData=function(){this._mesh||(this._initVertices(),this._createMesh())},i.destroy=function(){return this._packable&&JO&&JO.deleteAtlasSpriteFrame(this),t.prototype.destroy.call(this)},i._calculateSlicedUV=function(){var t=this,e=t._rect,i=t.texture,n=t._capInsets,r=i.width,s=i.height,a=n[0],o=n[2],h=e.width-a-o,u=n[1],l=n[3],c=e.height-u-l,f=t.uvSliced;if(f.length=0,t._rotated){iR[0].u=e.x/r,iR[1].u=(e.x+l)/r,iR[2].u=(e.x+l+c)/r,iR[3].u=(e.x+e.height)/r,iR[3].v=e.y/s,iR[2].v=(e.y+a)/s,iR[1].v=(e.y+a+h)/s,iR[0].v=(e.y+e.width)/s;for(var _=0;_<4;++_)for(var d=iR[_],p=0;p<4;++p){var m=iR[3-p];f.push({u:d.u,v:m.v})}}else{iR[0].u=e.x/r,iR[1].u=(e.x+a)/r,iR[2].u=(e.x+a+h)/r,iR[3].u=(e.x+e.width)/r,iR[3].v=e.y/s,iR[2].v=(e.y+u)/s,iR[1].v=(e.y+u+c)/s,iR[0].v=(e.y+e.height)/s;for(var g=0;g<4;++g)for(var y=iR[g],v=0;v<4;++v){var b=iR[v];f.push({u:b.u,v:y.v})}}this.emit("uv_updated",this)},i._calculateUV=function(){var t=Ae,e=this,i=e._rect,n=e.uv,r=e.unbiasUV,s=e.texture,a=s.width,o=s.height;if(e._rotated){var h=0===a?0:i.x/a,u=0===a?1:(i.x+i.height)/a,l=0===o?0:i.y/o,c=0===o?1:(i.y+i.width)/o;e._isFlipUVX&&e._isFlipUVY?t(n,u,c,u,l,h,c,h,l):e._isFlipUVX?t(n,u,l,u,c,h,l,h,c):e._isFlipUVY?t(n,h,c,h,l,u,c,u,l):t(n,h,l,h,c,u,l,u,c);var f=0===a?0:i.x/a,_=0===a?1:(i.x+i.height)/a,d=0===o?0:i.y/o,p=0===o?1:(i.y+i.width)/o;e._isFlipUVX&&e._isFlipUVY?t(r,_,p,_,d,f,p,f,d):e._isFlipUVX?t(r,_,d,_,p,f,d,f,p):e._isFlipUVY?t(r,f,p,f,d,_,p,_,d):t(r,f,d,f,p,_,d,_,p)}else{var m=0===a?0:i.x/a,g=0===a?1:(i.x+i.width)/a,y=0===o?1:(i.y+i.height)/o,v=0===o?0:i.y/o;e._isFlipUVX&&e._isFlipUVY?t(n,g,v,m,v,g,y,m,y):e._isFlipUVX?t(n,g,y,m,y,g,v,m,v):e._isFlipUVY?t(n,m,v,g,v,m,y,g,y):t(n,m,y,g,y,m,v,g,v);var b=0===a?0:i.x/a,S=0===a?1:(i.x+i.width)/a,w=0===o?1:(i.y+i.height)/o,x=0===o?0:i.y/o;e._isFlipUVX&&e._isFlipUVY?t(r,S,x,b,x,S,w,b,w):e._isFlipUVX?t(r,S,w,b,w,S,x,b,x):e._isFlipUVY?t(r,b,x,S,x,b,w,S,w):t(r,b,w,S,w,b,x,S,x)}e._calculateSlicedUV()},i._setDynamicAtlasFrame=function(t){t&&(this._original={_texture:this._texture,_x:this._rect.x,_y:this._rect.y},this._texture=t.texture,this._rect.x=t.x,this._rect.y=t.y,this._calculateUV())},i._resetDynamicAtlasFrame=function(){this._original&&(this._rect.x=this._original._x,this._rect.y=this._original._y,this._texture=this._original._texture,this._original=null,this._calculateUV())},i._checkPackable=function(){var t=JO;if(t){var e=this._texture;if(e instanceof Ey&&!e.isCompressed){var i=this.width,n=this.height;if(!e.image||i>t.maxFrameSize||n>t.maxFrameSize)this._packable=!1;else{var r=B.HTMLCanvasElement;e.image&&e.image instanceof r&&(this._packable=!0)}}else this._packable=!1}},i._serialize=function(){return null},i._deserialize=function(t){var e=this,i=t,n=i.rect;n&&(e._rect=new bs(n.x,n.y,n.width,n.height));var r=i.offset;i.offset&&(e._offset=ps(r.x,r.y));var s=i.originalSize;i.originalSize&&(e._originalSize=gs(s.width,s.height)),e._rotated=!!i.rotated,e._name=i.name,e._packable=!!i.packable,e._pixelsToUnit=i.pixelsToUnit;var a=i.pivot;a&&(e._pivot=ps(a.x,a.y)),e._meshType=i.meshType;var o=i.capInsets;if(o){var h=e._capInsets;h[0]=o[0],h[1]=o[1],h[2]=o[2],h[3]=o[3]}var u=i.vertices;if(u){e.vertices||(e.vertices={rawPosition:[],positions:[],indexes:u.indexes,uv:u.uv,nuv:u.nuv,minPos:nr(u.minPos.x,u.minPos.y,u.minPos.z),maxPos:nr(u.maxPos.x,u.maxPos.y,u.maxPos.z)}),e.vertices.rawPosition.length=0;for(var l=u.rawPosition,c=0;c0){var e=this.spriteFrames[t[0]];return e&&e.texture}return null},i.getSpriteFrame=function(t){var e=this.spriteFrames[t];return e?(e.name||(e.name=t),e):null},i.getSpriteFrames=function(){var t=[],e=this.spriteFrames;for(var i in e)t.push(e[i]);return t},i._serialize=function(){return null},i._deserialize=function(t,e){var i=t;this._name=i.name;var n=i.spriteFrames;this.spriteFrames=Gt();for(var r=0;r=this.limit){var n=this.tail;delete this.datas[n.key],this.count--,this.tail=n.prev,this.tail.next=null,n.prev=null,n.next=null,mR.put(n)}this.moveToHead(i)},e.remove=function(t){t.prev?t.prev.next=t.next:this.head=t.next,t.next?t.next.prev=t.prev:this.tail=t.prev,delete this.datas[t.key],this.count--},e.get=function(t){var e=this.datas[t];return e?(this.remove(e),this.moveToHead(e),e.value):null},e.clear=function(){this.count=0,this.datas={},this.head=null,this.tail=null},e.has=function(t){return!!this.datas[t]},e.delete=function(t){var e=this.datas[t];this.remove(e)},t}()),yR=new gR(100),vR=/([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûа-яА-ЯЁё]+|\S)/,bR=/^[!,.:;'}\]%\?>、‘“》?。,!]/,SR="[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁёáàảạãăắằẳẵặâấầẩẫậéèẻẽẹêếềểễệiíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵđÁÀẢẠÃĂẮẰẲẴẶÂẤẦẨẪẬÉÈẺẼẸÊẾỀỂỄỆIÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴĐ]",wR=new RegExp("("+SR+"+|\\S)$"),xR=new RegExp(SR+"+$"),TR=new RegExp("^"+SR);function AR(t){return/^[\u4E00-\u9FFF\u3400-\u4DFF]+$/.test(t)||/[\u3000-\u303F]|[\u3040-\u309F]|[\u30A0-\u30FF]|[\uFF00-\uFFEF]|[\u4E00-\u9FAF]|[\u2605-\u2606]|[\u2190-\u2195]|\u203B/g.test(t)||/^[\u1100-\u11FF]|[\u3130-\u318F]|[\uA960-\uA97F]|[\uAC00-\uD7AF]|[\uD7B0-\uD7FF]+$/.test(t)}function CR(t){var e=t.charCodeAt(0);return e>=9&&e<=13||32===e||133===e||160===e||5760===e||e>=8192&&e<=8202||8232===e||8233===e||8239===e||8287===e||12288===e}function DR(t,e,i){var n=(i||t.font)+"🎮"+e,r=yR.get(n);if(null!==r)return r;var s=t.measureText(e),a=s&&s.width||0;return yR.put(n,a),a}function BR(t){for(var e=t.length,i=0,n=0,r=0;r=55296&&n<=56319&&(n=t.charCodeAt(r+1))>=56320&&n<=57343?((r+2>=e||8205!==t.charCodeAt(r+2))&&i++,r++):i++);return i}function IR(t,e){for(var i=t.length,n=0,r=0,s=0,a=0,o=0;o=55296&&a<=56319&&(n++,(a=t.charCodeAt(o+1))>=56320&&a<=57343)){if(n++,o+2>=i||8205!==t.charCodeAt(o+2)){if(e===r)return t.slice(s,s+n);s+=n,r++,n=0}o++}else{if(e===r)return t.charAt(o);s=o+1,r++,n=0}else n++;return""}function MR(t,e){var i=IR(t,e);if(1===i.length)return""+i.charCodeAt(0);for(var n="",r=0;r=t.length)return t.length;for(var i=e,n=t[i];i>=0&&("‍"===n&&(n=t[--i]),n>="\udc00"&&n<="\udfff"&&i-1>=0&&(n=t[--i]),n>="\ud800"&&n<="\udbff")&&i-1>=0&&"‍"===t[i-1];)n=t[--i];return i}function ER(t,e){for(var i=e,n=e,r=t[n];n="\ud800"&&r<="\udbff"&&(i++,r=t[++n])),r>="\ud800"&&r<="\udbff")i++,r=t[++n];else{if(!(r>="\udc00"&&r<="\udfff"))break;if(r=t[++n],!(nn?r=n:r+=1}return t.substring(n,r)}function kR(t){return TR.exec(t)}function RR(t){return xR.exec(t)}function FR(t,e,i,n){var r=[];if(0===t.length||i<0)return r.push(""),r;for(var s=t;e>i&&s.length>1;){for(var a=s.length*(i/e)|0,o=OR(s,a),h=e-n(o),u=o,l=0,c=0;h>i&&c++<100;)a*=i/h,h=e-n(o=OR(s,a|=0));for(c=0;o&&h<=i&&c++<100;){var f=vR.exec(o);u=o,h=e-n(o=OR(s,a+=l=f?f[0].length:1))}0==(a-=l)?(a=1,u=OR(s,1)):1===a&&s[0]>="\ud800"&&s[0]<="\udbff"&&(a=2,u=OR(s,2));var _=OR(s,0,a),d=void 0;bR.test(u||o)&&(0==(a-=(d=wR.exec(_))?d[0].length:0)&&(a=1),u=OR(s,a),_=OR(s,0,a)),TR.test(u)&&(d=xR.exec(_))&&_!==d[0]&&(u=OR(s,a-=d[0].length),_=OR(s,0,a)),(0===r.length||(_=_.trim()).length>0)&&r.push(_),e=n(s=u||o)}return(0===r.length||(s=s.trim()).length>0)&&r.push(s),r}var LR,VR=B.document,NR=null,zR=-1,UR="BES bswy:->@123丁ぁᄁ",GR=Object.create(null),HR=[],WR=3e3,jR=function(){if(void 0===LR)if("FontFace"in B){var t=/Gecko.*Firefox\/(\d+)/.exec(B.navigator.userAgent),e=/OS X.*Version\/10\..*Safari/.exec(B.navigator.userAgent)&&/Apple/.exec(B.navigator.vendor);LR=t?parseInt(t[1],10)>42:!e}else LR=!1;return LR};function qR(){for(var t=!0,e=Date.now(),i=HR.length-1;i>=0;i--){var n=HR[i],r=n.fontFamilyName;if(e-n.startTime>WR)at(4933,r),n.onComplete(null,r),HR.splice(i,1);else{var s=n.refWidth,a="40px "+r;NR.font=a,s!==DR(NR,UR,a)?(HR.splice(i,1),n.onComplete(null,r)):t=!1}}t&&(clearInterval(zR),zR=-1)}function XR(t,e,i){var n=new Promise((function(i,n){!function r(){Date.now()-t>=WR?n():VR.fonts.load("40px "+e).then((function(t){t.length>=1?i():setTimeout(r,100)}),(function(){n()}))}()})),r=null,s=new Promise((function(t,e){r=setTimeout(e,WR)}));Promise.race([s,n]).then((function(){r&&(clearTimeout(r),r=null),i(null,e)}),(function(){at(4933,e),i(null,e)}))}function YR(t,e,i){var n=JR(t);if(GR[n])i(null,n);else{if(!NR){var r=VR.createElement("canvas");r.width=100,r.height=100,NR=r.getContext("2d")}var s="40px "+n,a=VR.createElement("style");a.type="text/css";var o="";Number.isNaN(n)?o+="@font-face { font-family:"+n+"; src:":o+='@font-face { font-family:"'+n+'"; src:',o+='url("'+t+'");',a.textContent=o+"}",VR.body.appendChild(a);var h=VR.createElement("div"),u=h.style;if(u.fontFamily=n,h.innerHTML=".",u.position="absolute",u.left="-100px",u.top="-100px",VR.body.appendChild(h),jR())XR(Date.now(),n,i);else{var l={fontFamilyName:n,refWidth:DR(NR,UR,s),onComplete:i,startTime:Date.now()};HR.push(l),-1===zR&&(zR=setInterval(qR,100))}GR[n]=a}}function JR(t){var e=t.lastIndexOf(".ttf");if(-1===e)return t;var i,n=t.lastIndexOf("/");return-1!==(i=-1===n?t.substring(0,e)+"_LABEL":t.substring(n+1,e)+"_LABEL").indexOf(" ")&&(i='"'+i+'"'),i}function KR(t,e,i,n){var r=new lR;r._nativeUrl=t,r._nativeAsset=e,n(null,r)}Mx.register({".font":YR,".eot":YR,".ttf":YR,".woff":YR,".svg":YR,".ttc":YR}),Hx.register({".font":KR,".eot":KR,".ttf":KR,".woff":KR,".svg":KR,".ttc":KR});var QR,ZR,$R,tF,eF,iF,nF,rF,sF,aF=/^(click)(\s)*=|(param)(\s)*=/,oF=/(\s)*src(\s)*=|(\s)*height(\s)*=|(\s)*width(\s)*=|(\s)*align(\s)*=|(\s)*offset(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/,hF=t("z",function(){function t(){this._specialSymbolArray=[],this._stack=[],this._resultObjectArray=[],this._specialSymbolArray.push([/</g,"<"]),this._specialSymbolArray.push([/>/g,">"]),this._specialSymbolArray.push([/&/g,"&"]),this._specialSymbolArray.push([/"/g,'"']),this._specialSymbolArray.push([/'/g,"'"])}var e=t.prototype;return e.parse=function(t){this._resultObjectArray.length=0,this._stack.length=0;for(var e=0,i=t.length;e",e),r=-1;if(n>=0&&(r=t.lastIndexOf("<",n))",r+1)),r<0)this._stack.pop(),this._processResult(t.substring(e)),e=i;else{var s=t.substring(e,r),a=t.substring(r+1,n);""===a&&(s=t.substring(e,n+1)),this._processResult(s),-1===n?n=r:"/"===t.charAt(r+1)?this._stack.pop():this._addToStack(a),e=n+1}}return this._resultObjectArray},e._attributeToObject=function(t){t=t.trim();var e={},i=/^(color|size)(\s)*=/.exec(t),n="",r=0,s="";if(i){if(n=i[0],""===(t=t.substring(n.length).trim()))return e;switch(r=t.indexOf(" "),n[0]){case"c":e.color=r>-1?t.substring(0,r).trim():t;break;case"s":e.size=parseInt(t)}return r>-1&&(s=t.substring(r+1).trim(),e.event=this._processEventHandler(s)),e}if((i=/^(br(\s)*\/)/.exec(t))&&i[0].length>0&&(n=i[0].trim()).startsWith("br")&&"/"===n[n.length-1])return e.isNewLine=!0,this._resultObjectArray.push({text:"",style:{isNewLine:!0}}),e;var a="",o=-1;if((i=/^(img(\s)*src(\s)*=[^>]+\/)/.exec(t))&&i[0].length>0&&(n=i[0].trim()).startsWith("img")&&"/"===n[n.length-1]){var h;i=oF.exec(t);for(var u=!1;i;){var l=(n=(t=t.substring(t.indexOf(i[0]))).substring(0,i[0].length)).length;if(n=(n=n.replace(/[^a-zA-Z]/g,"").trim()).toLowerCase(),a=t.substring(l).trim(),o="src"===n?this.getRightQuotationIndex(a):-1,h=(r=a.indexOf(" ",o+1>=a.length?-1:o+1))>-1?a.substring(0,r):a,t=a.substring(r).trim(),h.endsWith("/")&&(h=h.slice(0,-1)),"src"===n){switch(h.charCodeAt(0)){case 34:case 39:u=!0,h=h.slice(1,-1)}e.isImage=!0,e.src=h}else if("height"===n)e.imageHeight=parseInt(h);else if("width"===n)e.imageWidth=parseInt(h);else if("align"===n){switch(h.charCodeAt(0)){case 34:case 39:h=h.slice(1,-1)}e.imageAlign=h.toLowerCase()}else"offset"===n?e.imageOffset=h:"click"===n&&(e.event=this._processEventHandler(n+"="+h));e.event&&"param"===n&&(e.event[n]=h.replace(/^"|"$/g,"")),i=oF.exec(t)}return u&&e.isImage&&this._resultObjectArray.push({text:"",style:e}),{}}if(i=/^(outline(\s)*[^>]*)/.exec(t)){var c={color:"#ffffff",width:1};if(t=i[0].substring(7).trim()){var f,_=/(\s)*color(\s)*=|(\s)*width(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/;for(i=_.exec(t);i;)n=(t=t.substring(t.indexOf(i[0]))).substring(0,i[0].length),f=(r=(a=t.substring(n.length).trim()).indexOf(" "))>-1?a.substring(0,r):a,n=(n=n.replace(/[^a-zA-Z]/g,"").trim()).toLowerCase(),t=a.substring(r).trim(),"click"===n?e.event=this._processEventHandler(n+"="+f):"color"===n?c.color=f:"width"===n&&(c.width=parseInt(f)),e.event&&"param"===n&&(e.event[n]=f.replace(/^"|"$/g,"")),i=_.exec(t)}e.outline=c}if((i=/^(on|u|b|i)(\s)*/.exec(t))&&i[0].length>0){switch(n=i[0],t=t.substring(n.length).trim(),n[0]){case"u":e.underline=!0;break;case"i":e.italic=!0;break;case"b":e.bold=!0}if(""===t)return e;e.event=this._processEventHandler(t)}return e},e.getRightQuotationIndex=function(t){var e=-1,i=-1,n=t.indexOf("'"),r=t.indexOf('"'),s=r>-1&&(r-1&&(n=t.length?-1:e+1)):s&&(e=r,i=t.indexOf('"',e+1>=t.length?-1:e+1)),i},e._processEventHandler=function(t){for(var e={},i=0,n=!1,r=aF.exec(t);r;){var s=r[0],a="";if(n=!1,'"'===(t=t.substring(s.length).trim()).charAt(0))(i=t.indexOf('"',1))>-1&&(a=t.substring(1,i).trim(),n=!0),i++;else if("'"===t.charAt(0))(i=t.indexOf("'",1))>-1&&(a=t.substring(1,i).trim(),n=!0),i++;else{var o=/(\S)+/.exec(t);i=(a=o?o[0]:"").length}n&&(e[s=s.substring(0,s.length-1).trim()]=a),t=t.substring(i).trim(),r=aF.exec(t)}return e},e._addToStack=function(t){var e=this._attributeToObject(t);if(0===this._stack.length)this._stack.push(e);else{if(e.isNewLine||e.isImage)return;var i=this._stack[this._stack.length-1];for(var n in i)e[n]||(e[n]=i[n]);this._stack.push(e)}},e._processResult=function(t){0!==t.length&&(t=this._escapeSpecialSymbol(t),this._stack.length>0?this._resultObjectArray.push({text:t,style:this._stack[this._stack.length-1]}):this._resultObjectArray.push({text:t}))},e._escapeSpecialSymbol=function(t){for(var e,i=p(this._specialSymbolArray);!(e=i()).done;){var n=e.value,r=n[0],s=n[1];t=t.replace(r,s)}return t},t}()),uF=function(){this.u=0,this.v=0,this.w=0,this.h=0,this.offsetX=0,this.offsetY=0,this.valid=!1,this.xAdvance=0},lF=function(){function t(t){this.letterDefinitions={},this._texture=null,this.texture=t}var e=t.prototype;return e.addLetterDefinitions=function(t,e){this.letterDefinitions[t]=e},e.cloneLetterDefinition=function(){var t={};for(var e in this.letterDefinitions){var i=new uF;$t(i,this.letterDefinitions[e]),t[e]=i}return t},e.getTexture=function(){return this._texture},e.getLetter=function(t){return this.letterDefinitions[t]},e.getLetterDefinitionForChar=function(t){var e=MR(t,0),i=null;return Object.prototype.hasOwnProperty.call(this.letterDefinitions,e)&&(i=this.letterDefinitions[e]),i},e.clear=function(){this.letterDefinitions={}},n(t,[{key:"texture",get:function(){return this._texture},set:function(t){var e=this._texture;e!==t&&(e&&(e.decRef(!1),e.refCount<=0&&e.destroy()),t&&t.addRef(),this._texture=t)}}]),t}(),cF=t("B",(QR=Kh("cc.BitmapFont"),ZR=Ou(nR),QR((tF=function(t){function e(){var e;return(e=t.call(this)||this).fntDataStr=eF&&eF(),e.spriteFrame=iF&&iF(),e.fontSize=nF&&nF(),e.fntConfig=rF&&rF(),e}return s(e,t),e.prototype.onLoaded=function(){var t=this.spriteFrame;!this.fontDefDictionary&&t&&(this.fontDefDictionary=new lF(t.texture));var e=this.fntConfig;if(e){var i=e.fontDefDictionary;for(var n in i){var r=i[n],s=new uF,a=r.rect;s.offsetX=r.xOffset,s.offsetY=r.yOffset,s.w=a.width,s.h=a.height,s.u=a.x,s.v=a.y,s.valid=!0,s.xAdvance=r.xAdvance,this.fontDefDictionary.addLetterDefinitions(n,s)}}else at(16376)},e}(uR),eF=zh(tF.prototype,"fntDataStr",[uu],(function(){return""})),iF=zh(tF.prototype,"spriteFrame",[ZR],(function(){return null})),nF=zh(tF.prototype,"fontSize",[uu],(function(){return-1})),rF=zh(tF.prototype,"fntConfig",[uu],(function(){return null})),$R=tF))||$R));A.BitmapFont=cF;var fF,_F=t("L",Kh("cc.LabelAtlas")(sF=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e}(cF))||sF);A.LabelAtlas=_F;var dF=function(){function t(){this.pool=[]}t.getInstance=function(){return fF||(fF=new t),fF};var e=t.prototype;return e.get=function(){var t=this.pool.pop();if(!t){var e=B.document.createElement("canvas"),i=e.getContext("2d");t={canvas:e,context:i}}return t},e.put=function(t){this.pool.length>=Ue.MAX_LABEL_CANVAS_POOL_SIZE||this.pool.push(t)},t}(),pF=cr.WHITE.clone(),mF="rgba(255, 255, 255, "+(1/255).toFixed(3)+")",gF=pR(),yF=function(){function t(t,e){this.image=null,this.data=null,this.canvas=null,this.context=null,this.width=0,this.height=0,this.offsetY=0,this.char=t,this.labelInfo=e,this.hash=""+MR(t,0)+e.hash}var e=t.prototype;return e.updateRenderData=function(){this._updateProperties(),this._updateTexture()},e.destroy=function(){this.image=null,dF.getInstance().put(this.data),this.data=null},e._updateProperties=function(){if(this.data=dF.getInstance().get(),this.canvas=this.data.canvas,this.context=this.data.context,this.context){var t=this.labelInfo.fontScale;this.context.font=this.labelInfo.fontDesc;var e=DR(this.context,this.char,this.labelInfo.fontDesc),i=2*this.labelInfo.margin+2;this.width=parseFloat(e.toFixed(2))*t+i,this.height=(1+fR)*this.labelInfo.fontSize*t+i,this.offsetY=-this.labelInfo.fontSize*fR*t/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 Hm),this.image.reset(this.canvas)},e._updateTexture=function(){if(this.context&&this.canvas){var t=this.context,e=this.labelInfo,i=this.canvas.width,n=this.canvas.height,r=e.fontScale;t.textAlign="center",t.textBaseline="alphabetic",t.clearRect(0,0,i,n),t.fillStyle=mF,t.fillRect(0,0,i,n),t.font=e.fontDesc.replace(/(\d+)(\.\d+)?(px|em|rem|pt)/g,(function(t,e,i,n){return(+e*r+(+i||0)*r).toString()+n}));var s=e.fontSize*r,a=i/2,o=n/2+s*dR+s*gF,h=e.color;if(t.lineJoin="round",t.fillStyle="rgba("+h.r+", "+h.g+", "+h.b+", 1)",e.isOutlined){var u=e.out||pF;t.strokeStyle="rgba("+u.r+", "+u.g+", "+u.b+", "+u.a/255+")",t.lineWidth=2*e.margin*r,t.strokeText(this.char,a,o)}t.fillText(this.char,a,o)}},t}(),vF=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.initWithSize=function(t,e,i){void 0===i&&(i=35),this.reset({width:t,height:e,format:i})},i.drawTextureAt=function(t,e,i){var n=this.getGFXTexture();if(t&&n){var r=this._getGFXDevice();if(r){var s=new id;s.texOffset.x=e,s.texOffset.y=i,s.texExtent.width=t.width,s.texExtent.height=t.height,r.copyTexImagesToTexture([t.data],n,[s])}else at(16363)}},e}(Ey),bF=function(){function t(t,e){this._x=0,this._y=0,this._nextY=0,this._width=0,this._height=0,this._halfBleed=0,this._dirty=!1;var i=new vF;i.initWithSize(t,e),this.fontDefDictionary=new lF(i),this._halfBleed=1,this._width=t,this._height=e,YE.on("director_before_scene_launch",this.beforeSceneLoad,this)}var e=t.prototype;return e.insertLetterTexture=function(t){var e=t.image,i=YE.root.device;if(!e||!this.fontDefDictionary||!i)return null;var n=e.width,r=e.height;if(this._x+n+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 at(12100),null;if(!this.fontDefDictionary.texture)return null;this.fontDefDictionary.texture.drawTextureAt(e,this._x,this._y),this._dirty=!0;var s=new uF;return s.u=this._x+this._halfBleed,s.v=this._y+this._halfBleed,s.valid=!0,s.w=t.width-2,s.h=t.height-2,s.xAdvance=s.w,s.offsetY=t.offsetY,this._x+=n+0,this.fontDefDictionary.addLetterDefinitions(t.hash,s),s},e.update=function(){this._dirty&&(this._dirty=!1)},e.reset=function(){this._x=0,this._y=0,this._nextY=0,this.fontDefDictionary.clear()},e.destroy=function(){this.reset();var t=this.fontDefDictionary;t&&t.texture&&(t.texture=null)},e.getTexture=function(){return this.fontDefDictionary.getTexture()},e.beforeSceneLoad=function(){this.clearAllCache()},e.clearAllCache=function(){this.destroy();var t=new vF;t.initWithSize(this._width,this._height),this.fontDefDictionary.texture=t},e.getLetter=function(t){return this.fontDefDictionary.letterDefinitions[t]},e.getLetterDefinitionForChar=function(t,e){var i=MR(t,0)+e.hash,n=this.fontDefDictionary.letterDefinitions[i];if(!n){var r=new yF(t,e);r.updateRenderData(),n=this.insertLetterTexture(r),r.destroy()}return n},n(t,[{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}}]),t}(),SF={fontAtlas:null,fontSize:0,lineHeight:0,hAlign:0,vAlign:0,hash:"",fontFamily:"",fontDesc:"Arial",color:cr.WHITE.clone(),isOutlined:!1,out:cr.WHITE.clone(),margin:0,fontScale:1};function wF(t){var e=t.color.toHEX(),i="";return t.isOutlined&&t.margin>0&&(i=i+t.margin+t.out.toHEX()),""+t.fontSize+t.fontFamily+e+i}var xF="a_position",TF="a_color",AF="a_texCoord",CF="a_color2",DF=[new Cd(xF,32)],BF=[new Cd(xF,32),new Cd(TF,44)],IF=[new Cd(xF,32),new Cd(AF,21),new Cd(TF,44)],MF=[new Cd(xF,32),new Cd(AF,21),new Cd(TF,35,!0)],PF=[new Cd(xF,32),new Cd(AF,21),new Cd(TF,44),new Cd(CF,44)],EF=[new Cd(xF,32),new Cd(AF,21),new Cd(TF,35,!0),new Cd(CF,35,!0)];function OF(t){for(var e=0,i=0;i>2,this._initVDataCount,this._floatsPerVertex,ft(9005),this.vData&&this.iData||(this.vData=new Float32Array(this._initVDataCount),this.iData=new Uint16Array(this._initIDataCount)),this._iaPool.push(this.createNewIA(t))},t.reset=function(){this._nextFreeIAHandle=0,this.dirty=!1},t.destroy=function(){this.reset(),this._attributes=null,this._iaInfo=null,this.vData=null,this.iData=null;for(var t=0;tthis._initVDataCount||n>this._initIDataCount)},t.uploadBuffers=function(){if(0!==this.byteOffset&&this._dirty){var t=hh.__isWebIOS14OrIPadOS14Env,e=t?this._nextFreeIAHandle:1;if(t&&e/this._iaPool.length<.5){for(var i=e/.5,n=this._iaPool.length-1;n>=i;n--){var r=this._iaPool[n];r.vertexBuffers[0]&&r.vertexBuffers[0].destroy(),r.indexBuffer&&r.indexBuffer.destroy(),r.ia.destroy()}this._iaPool.length=i}for(var s=this.byteOffset,a=this.indexOffset,o=0;o>2),l=new Uint16Array(this.iData.buffer,0,a),c=h.vertexBuffers[0];s>c.size&&c.resize(s),c.update(u),2*a>h.indexBuffer.size&&h.indexBuffer.resize(2*a),h.indexBuffer.update(l)}this.dirty=!1}},t.createNewIA=function(t){var e,i,n;if(hh.__isWebIOS14OrIPadOS14Env||!this._iaPool[0]){var r=this._vertexFormatBytes=4*this._floatsPerVertex,s=t.createBuffer(new ud(10,3,r,r));n=t.createBuffer(new ud(6,3,2,2)),i=[s],this._iaInfo=new Bd(this._attributes,i,n),e=t.createInputAssembler(this._iaInfo)}else e=t.createInputAssembler(this._iaInfo),i=this._iaInfo.vertexBuffers,n=this._iaInfo.indexBuffer;return{ia:e,vertexBuffers:i,indexBuffer:n}},n(e,[{key:"attributes",get:function(){return this._attributes}},{key:"vertexFormatBytes",get:function(){return this._vertexFormatBytes}},{key:"byteOffset",get:function(){return this._byteOffset},set:function(t){this._byteOffset=t}},{key:"vertexOffset",get:function(){return this._vertexOffset},set:function(t){this._vertexOffset=t}},{key:"indexOffset",get:function(){return this._indexOffset},set:function(t){this._indexOffset=t}},{key:"dirty",get:function(){return this._dirty},set:function(t){this._dirty=t}},{key:"floatsPerVertex",get:function(){return this._floatsPerVertex},set:function(t){this._floatsPerVertex=t}},{key:"vData",get:function(){return this._vData},set:function(t){this._vData=t}},{key:"iData",get:function(){return this._iData},set:function(t){this._iData=t}},{key:"nativeObj",get:function(){return this._nativeObj}},{key:"sharedBuffer",get:function(){return this._sharedBuffer}}]),e}()),FF=function(){function t(t,e){this._buffers=[],this._device=t,this._attributes=e,this._floatsPerVertex=kF(e)>>2,this._vertexFormatBytes=4*this._floatsPerVertex}var e=t.prototype;return e.initialize=function(){},e.reset=function(){},e.request=function(){},e.appendBuffers=function(){},e.uploadBuffers=function(){},e.destroy=function(){this._attributes.length=0},n(t,[{key:"attributes",get:function(){return this._attributes}},{key:"vertexFormatBytes",get:function(){return this._vertexFormatBytes}},{key:"floatsPerVertex",get:function(){return this._floatsPerVertex}}]),t}(),LF=new ho((function(){return{offset:0,length:0}}),32),VF=function(){function t(t,e,i,n,r,s){this.vertexAccessor=t,this.bufferId=e,this.meshBuffer=i,this.vertexOffset=n,this.vb=r,this.indexCount=s,this._ib=new Uint16Array(s),t.getMeshBuffer(e)}return t.prototype.setIndexBuffer=function(){},n(t,[{key:"ib",get:function(){return this._ib}}]),t}(),NF=function(t){function e(i,n,r,s){var a;return(a=t.call(this,i,n)||this)._freeLists=[],a._vCount=0,a._iCount=0,a._id=0,a._vCount=r||Math.floor(1024*Ue.BATCHER2D_MEM_INCREMENT/a._vertexFormatBytes),a._iCount=s||a._vCount*e.IB_SCALE,a._id=e.generateID(),a._allocateBuffer(),a}s(e,t);var i=e.prototype;return i.destroy=function(){for(var e=0;ethis._vCount||e>this._iCount)return ht(9004,i),null;for(var n,r=null,s=0,a=-1,o=null,h=0;h=i){o=n[u],s=h,a=u;break}if(o)break}if(o||(s=this._allocateBuffer(),(r=this._buffers[s])&&(a=0,o=this._freeLists[s][a])),o){var l=o.offset/this.vertexFormatBytes,c=new Float32Array(r.vData.buffer,o.offset,i>>2).fill(0);return this._allocateChunkFromEntry(s,a,o,i),new VF(this,s,r,l,c,e)}return null},i.recycleChunk=function(t){var e=this._freeLists[t.bufferId],i=this._buffers[t.bufferId],n=t.vertexOffset*this.vertexFormatBytes,r=t.vb.byteLength;if(0!==r){for(var s=!1,a=0,o=null,h=e[a];h&&h.offset=0,9004,t,i.offset,i.length),0===r?(this._freeLists[t].splice(e,1),LF.free(i)):(i.offset+=n,i.length=r)},i._allocateBuffer=function(){lt(this._buffers.length===this._freeLists.length,9003);var t=new RF,e=this._vCount*this._floatsPerVertex;t.initialize(this._device,this._attributes,e,this._iCount),this._buffers.push(t);var i=LF.alloc();i.offset=0,i.length=t.vData.byteLength;var n=[i];return this._freeLists.push(n),YE.root.batcher2D.syncMeshBuffersToNative(this.id,this._buffers),this._buffers.length-1},e.generateID=function(){return e.ID_COUNT++},n(e,[{key:"id",get:function(){return this._id}}]),e}(FF);NF.IB_SCALE=4,NF.ID_COUNT=0;var zF,UF,GF,HF,WF,jF,qF,XF,YF,JF,KF,QF=function(){function t(t){this._accId=-1,this._bufferId=-1,this._vertexOffset=0,this._indexOffset=0,this._vb=null,this._ib=null,this._vData=null,this._iData=null,this._vertDirty=!1,this._vbCount=0,this._ibCount=0,this._dataHash=0,this._isMeshBuffer=!1,this._material=null,this._texture=null,this._sampler=null,this._stride=0,this._useLocal=!1,this._model=null,this._drawInfoType=0,this._subNode=null,this._render2dBuffer=null,this.init(t);var e=this._nativeObj.getAttrSharedBufferForJS(),i=0;this._uint8SharedBuffer=new Uint8Array(e,i,4),i+=4,this._uint16SharedBuffer=new Uint16Array(e,i,2),i+=4,this._uint32SharedBuffer=new Uint32Array(e,i,5)}var e=t.prototype;return e.init=function(){},e.clear=function(){this._bufferId=0,this._vertexOffset=0,this._indexOffset=0,this._vertDirty=!1},e.setAccId=function(t){this._accId=t},e.setBufferId=function(t){this._bufferId=t},e.setAccAndBuffer=function(t,e){this._bufferId=e,this._accId=t},e.setVertexOffset=function(t){this._vertexOffset=t},e.setIndexOffset=function(t){this._indexOffset=t},e.setVB=function(){},e.setIB=function(){},e.setVData=function(){},e.setIData=function(){},e.setVBCount=function(t){this._vbCount=t},e.setIBCount=function(){},e.setVertDirty=function(t){this._vertDirty=t},e.setDataHash=function(t){this._dataHash=t},e.setIsMeshBuffer=function(t){this._isMeshBuffer=t},e.setVertexPositionInWorld=function(){},e.setMaterial=function(t){this._material=t},e.setTexture=function(t){this._texture=t},e.setSampler=function(t){this._sampler=t},e.setModel=function(){},e.setDrawInfoType=function(t){this._drawInfoType=t},e.setSubNode=function(t){this._subNode=t},e.setStride=function(t){this._stride=t},e.initRender2dBuffer=function(){},e.fillRender2dBuffer=function(){},n(t,[{key:"nativeObj",get:function(){return this._nativeObj}},{key:"render2dBuffer",get:function(){return this._render2dBuffer}}]),t}(),ZF=kF(IF)>>2,$F=t("t",function(){function t(t){void 0===t&&(t=IF),this.chunk=null,this._renderDrawInfo=null,this._material=null,this._dataHash=0,this._isMeshBuffer=!1,this._vc=0,this._ic=0,this._floatStride=0,this._vertexFormat=IF,this._drawInfoType=0,this._multiOwner=!1,this._batcher=null,this._floatStride=t===IF?ZF:kF(t)>>2,this._vertexFormat=t}var e=t.prototype;return e.isValid=function(){return this._ic>0&&this.chunk.vertexAccessor},e.initRenderDrawInfo=function(){},e.removeRenderDrawInfo=function(){},e.setRenderDrawInfoAttributes=function(){},n(t,[{key:"vertexCount",get:function(){return this._vc}},{key:"indexCount",get:function(){return this._ic}},{key:"stride",get:function(){return this._floatStride<<2}},{key:"floatStride",get:function(){return this._floatStride}},{key:"vertexFormat",get:function(){return this._vertexFormat}},{key:"drawInfoType",get:function(){return this._drawInfoType},set:function(t){this._drawInfoType=t}},{key:"renderDrawInfo",get:function(){return this._renderDrawInfo}},{key:"material",get:function(){return this._material},set:function(t){this._material=t}},{key:"dataHash",get:function(){return this._dataHash},set:function(t){this._dataHash=t}},{key:"multiOwner",get:function(){return this._multiOwner},set:function(t){this._multiOwner=t}},{key:"batcher",get:function(){return this._batcher||(this._batcher=YE.root.batcher2D),this._batcher}}]),t}()),tL=t("u",function(t){function e(e,i){var n;return void 0===e&&(e=IF),void 0===i&&(i=null),(n=t.call(this,e)||this)._vertDirty=!0,n._textureHash=0,n.indices=null,n.layer=0,n.nodeDirty=!0,n.passDirty=!0,n.textureDirty=!0,n.hashDirty=!0,n._data=[],n._frame=null,n._accessor=null,n.vertexRow=1,n.vertexCol=1,i||(i=n.batcher.switchBufferAccessor(n._vertexFormat)),n._accessor=i,n}s(e,t),e.add=function(t,i){void 0===t&&(t=IF),void 0===i&&(i=null);var n=new e(t,i);return i||(i=YE.root.batcher2D.switchBufferAccessor(n._vertexFormat)),n._accessor=i,n},e.remove=function(t){t.clear(),t._accessor=null};var i=e.prototype;return i.resize=function(t,e){t===this._vc&&e===this._ic&&this.chunk||(this._vc=t,this._ic=e,this.chunk&&(this._accessor.recycleChunk(this.chunk),this.chunk=null),this.chunk=this._accessor.allocateChunk(t,e),this.updateHash())},i.setRenderDrawInfoAttributes=function(){},i.fillDrawInfoAttributes=function(){},i.syncRender2dBuffer=function(){},i.resizeAndCopy=function(t,e){if(t!==this._vc||e!==this._ic||!this.chunk){this._vc=t,this._ic=e;var i=this.chunk;this.chunk=this._accessor.allocateChunk(t,e),i&&(this.chunk.vb.set(i.vb),this._accessor.recycleChunk(i)),this.updateHash()}},i.getMeshBuffer=function(){return this.chunk&&this._accessor?this._accessor.getMeshBuffer(this.chunk.bufferId):null},i.updateNode=function(t){this.layer=t.node.layer,this.nodeDirty=!1,this.hashDirty=!0},i.updatePass=function(t){this.material=t.getRenderMaterial(0),this.passDirty=!1,this.hashDirty=!0},i.updateTexture=function(t){this.frame=t,this.textureHash=t.getHash(),this.textureDirty=!1,this.hashDirty=!0},i.updateHash=function(){var t=""+(this.chunk?this.chunk.bufferId:-1)+this.layer+" "+this.textureHash;this.dataHash=qf(t,666),this.hashDirty=!1},i.updateRenderData=function(t,e){if(this.passDirty&&(this.material=t.getRenderMaterial(0),this.passDirty=!1,this.hashDirty=!0),this.nodeDirty){var i=t.node.scene?t._getRenderScene():null;this.layer=t.node.layer,null!==i&&(this.nodeDirty=!1),this.hashDirty=!0}this.textureDirty&&(this.frame=e,this.textureHash=e.getHash(),this.textureDirty=!1,this.hashDirty=!0),this.hashDirty&&this.updateHash()},i.clear=function(){this.resize(0,0),this._data.length=0,this.indices=null,this.vertDirty=!0,this.material=null,this.nodeDirty=!0,this.passDirty=!0,this.textureDirty=!0,this.hashDirty=!0,this.layer=0,this.frame=null,this.textureHash=0,this.dataHash=0},e.createStaticVBAccessor=function(t,e,i){var n=YE.root.device;return new NF(n,t,e,i)},n(e,[{key:"dataLength",get:function(){return this._data.length},set:function(t){var e=this._data;if(e.length!==t){for(var i=e.length;i>2,i._vertexFormat=t,i},e.remove=function(t){t.clear()};var i=e.prototype;return i.request=function(t,e){var i=this._byteLength+t*this.stride;return!!this.reserve(t,e)&&(this._vc+=t,this._ic+=e,this._byteLength=i,this.vertexRange=this._vc,this.indexRange=this._ic,!0)},i.reserve=function(t,e){var i=this._byteLength+t*this.stride,n=this.indexCount+e;if(t+this.vertexCount>65535)return!1;var r=this.vData.byteLength,s=this.iData.length,a=this.vData.length,o=this.iData.length;if(i>r||n>s){for(;r=0&&e>=0&&i<=this.vData.byteLength&&this.iData.length,this._vc=t,this._ic=e,this._byteLength=i,this.updateRange(0,t,0,e)},i.updateRange=function(t,e,i,n){e>=0&&n>=0&&e<=this._vc&&this._ic,this.vertexStart=t,this.indexStart=i,this.vertexRange=e,this.indexRange=n},i.requestIA=function(t){this._initIAInfo(t);var e=this._iaPool.add();return e.firstIndex=this.indexStart,e.indexCount=this.indexRange,e},i.uploadBuffers=function(){if(0!==this._byteLength&&this._vertexBuffers[0]&&this._indexBuffer){var t=this._ic,e=new Float32Array(this.vData.buffer,0,this._byteLength>>2),i=new Uint16Array(this.iData.buffer,0,t),n=this._vertexBuffers[0];this._byteLength>n.size&&n.resize(this._byteLength),n.update(e);var r=t<<1;r>this._indexBuffer.size&&this._indexBuffer.resize(r),this._indexBuffer.update(i)}},i.freeIAPool=function(){this._iaPool&&this._iaPool.reset()},i.reset=function(){this._vc=0,this._ic=0,this._byteLength=0,this.vertexStart=0,this.vertexRange=0,this.indexStart=0,this.indexRange=0,this.lastFilledIndex=0,this.lastFilledVertex=0,this.material=null,this.freeIAPool()},i.clear=function(){this.reset(),this._iaPool&&this._iaPool.destroy(),this._vertexBuffers[0]&&(this._vertexBuffers[0].destroy(),this._vertexBuffers=[]),this._iaInfo=null,this.vData=new Float32Array(256*this.stride),this.iData=new Uint16Array(1536)},i._initIAInfo=function(t){var e=this;if(!this._iaInfo){var i=this.stride,n=this._vertexBuffers;n.length||n.push(t.createBuffer(new ud(10,1,i,i))),this._indexBuffer||(this._indexBuffer=t.createBuffer(new ud(6,1,2,2))),this._iaInfo=new Bd(this._vertexFormat,n,this._indexBuffer),this._iaPool=new uo((function(){return t.createInputAssembler(e._iaInfo)}),1,(function(t){t.destroy()}))}},i._reallocBuffer=function(t,e){var i=this.vData;this.vData=new Float32Array(t),i&&this.vData.set(i,0);var n=this.iData;this.iData=new Uint16Array(e),n&&this.iData.set(n,0)},i.setRenderDrawInfoAttributes=function(){},i.particleInitRenderDrawInfo=function(){},n(e,[{key:"formatByte",get:function(){return this.stride},set:function(){}},{key:"floatStride",get:function(){return this._floatStride}},{key:"vDataOffset",get:function(){return this._byteLength>>>2}}]),e}($F)),iL=new ds,nL=new ds,rL=new ir,sL=new Kr,aL=new Kr,oL=new Kr,hL=new Kr(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),uL=new bs,lL=t("e",Kh("cc.UITransform")(zF=Zh(110)(zF=$h((WF=function(t){function e(){var e;return(e=t.call(this)||this)._priority=0,e._contentSize=GF&&GF(),e._anchorPoint=HF&&HF(),e}s(e,t);var i=e.prototype;return i.__preload=function(){this.node._uiProps.uiTransformComp=this},i.onLoad=function(){this.node.parent&&e.insertChangeMap(this.node.parent)},i.onEnable=function(){this.node.on("parent-changed",this._parentChanged,this),this._markRenderDataDirty()},i.onDisable=function(){this.node.off("parent-changed",this._parentChanged,this)},i.onDestroy=function(){this.node._uiProps.uiTransformComp=null},i.setContentSize=function(t,e){var i,n,r=this._contentSize;if(void 0===e){if(Zi(t.width,r.width,Ki)&&Zi(t.height,r.height,Ki))return;i=t.width,n=t.height}else{if(Zi(t,r.width,Ki)&&Zi(e,r.height,Ki))return;i=t,n=e}r.width=i,r.height=n,this.node.emit("size-changed"),this._markRenderDataDirty()},i.setAnchorPoint=function(t,e){var i=this._anchorPoint;if(void 0===e){if(t.x===i.x&&t.y===i.y)return;i.x=t.x,i.y=t.y}else{if(t===i.x&&e===i.y)return;i.x=t,i.y=e}this.node.emit("anchor-changed",this._anchorPoint),this._markRenderDataDirty()},i.isHit=function(t){for(var e=this._contentSize.width,i=this._contentSize.height,n=iL,r=nL,s=this._getRenderScene().cameras,a=0;a=0&&r.y>=0&&r.x<=e&&r.y<=i&&(c=this._maskTest(n)),c)return!0}}}return!1},i.hitTest=function(t,e){void 0===e&&(e=0);for(var i=this._contentSize.width,n=this._contentSize.height,r=rL,s=iL,a=nL,o=this._getRenderScene().cameras,h=0;h=0&&a.y>=0&&a.x<=i&&a.y<=n&&(l=this._maskTest(s)),l)return!0}}return!1},i._maskTest=function(t){var e,i,n=null==(e=this.node)||null==(i=e.eventProcessor)?void 0:i.maskList;if(n)for(var r=this.node,s=n.length,a=0,o=0;r&&oh.index){n.length=o;break}}return!0},i.convertToNodeSpaceAR=function(t,e){return this.node.getWorldMatrix(oL),Kr.invert(sL,oL),e||(e=new ir),ir.transformMat4(e,t,sL)},i.convertToWorldSpaceAR=function(t,e){return this.node.getWorldMatrix(oL),e||(e=new ir),ir.transformMat4(e,t,oL)},i.getBoundingBox=function(){var t=new bs;return this._selfBoundingBox(t),Kr.fromSRT(aL,this.node.rotation,this.node.position,this.node.scale),t.transformMat4(aL),t},i.getBoundingBoxToWorld=function(){for(var t=new bs,i=this.node.children,n=0;n=this._materials.length?null:this._materials[t]},i.setSharedMaterial=function(t,e){if(t&&t instanceof QT&&ht(12012),this._materials[e]!==t){this._materials[e]=t;var i=this._materialInstances[e];i&&(i.destroy(),this._materialInstances[e]=null),this._onMaterialModified(e,this._materials[e])}},i.getMaterialInstance=function(t){if(!this._materials[t])return null;if(!this._materialInstances[t]){xL.parent=this._materials[t],xL.owner=this,xL.subModelIdx=t;var e=new QT(xL);xL.parent=null,xL.owner=null,xL.subModelIdx=0,this.setMaterialInstance(e,t)}return this._materialInstances[t]},i.setMaterialInstance=function(t,e){if("number"==typeof t){at(12007);var i=t;t=e,e=i}var n=this._materialInstances[e];t&&t.parent?t!==n&&(this._materialInstances[e]=t,this._onMaterialModified(e,t)):(t!==this._materials[e]||n)&&this.setSharedMaterial(t,e)},i.getRenderMaterial=function(t){return this._materialInstances[t]||this._materials[t]},i._onMaterialModified=function(){},i._onRebuildPSO=function(){},i._clearMaterials=function(){},n(e,[{key:"sharedMaterial",get:function(){return this.getSharedMaterial(0)}},{key:"sharedMaterials",get:function(){return this._materials},set:function(t){for(var e=0;e0},i._postCanRender=function(){},i.updateMaterial=function(){if(this._customMaterial)this.getSharedMaterial(0)!==this._customMaterial&&this.setSharedMaterial(this._customMaterial,0);else{var t=this._updateBuiltinMaterial();this.setSharedMaterial(t,0),2!==this.stencilStage&&6!==this.stencilStage||this.getMaterialInstance(0).recompileShaders({USE_ALPHA_TEST:!0}),this._updateBlendFunc()}},i._updateColor=function(){this.node._uiProps.colorDirty=!0,this.setEntityColorDirty(!0),this.setEntityColor(this._color),this.setEntityOpacity(this.node._uiProps.localOpacity);var t=this._assembler;if(t){t.updateColor&&t.updateColor(this);var e=this._renderFlag;if(this._renderFlag=this._canRender(),this.setEntityEnabled(this._renderFlag),e!==this._renderFlag){var i=this.renderData;i&&(i.vertDirty=!0)}}},e.setEntityColorDirtyRecursively=function(t,i){var n=t._uiProps.uiComp;n&&n.color&&(n._renderEntity.colorDirty=i);for(var r=0;r>16,t|=t>>8,t|=t>>4,t|=t>>2,t|=t>>1,++t}function rN(t,e){return Math.ceil(t/e)*e}var sN=function(){function t(t){this._format=0,this._formatSize=0,this._chunks=[],this._chunkCount=0,this._handles=[],this._region0=new id,this._region1=new id,this._region2=new id,this._roundUpFn=null,this._bufferViewCtor=Uint8Array,this._channels=4,this._alignment=1,this._device=t}var e=t.prototype;return e.initialize=function(t){var e=ip[t.format];this._format=t.format,this._formatSize=e.size,this._channels=e.count,this._bufferViewCtor=cp(e),this._roundUpFn=t.roundUpFn||null,this._alignment=t.alignment||1,t.inOrderFree&&(this.alloc=this._McDonaldAlloc)},e.destroy=function(){for(var t=0;t=0));++r);if(n>=0){var s=this._chunks[i];s.start+=t;var a={chunkIdx:i,start:n,end:n+t,texture:s.texture};return this._handles.push(a),a}var o=Math.sqrt(t/this._formatSize),h=this._roundUpFn&&this._roundUpFn(o,this._formatSize)||Math.max(1024,nN(o)),u=this._chunks[this.createChunk(h)];u.start+=t;var l={chunkIdx:this._chunkCount-1,start:0,end:t,texture:u.texture};return this._handles.push(l),l},e.free=function(t){for(var e=0;e0&&(this._region0.texOffset.x=a,this._region0.texOffset.y=o,this._region0.texExtent.width=h,this._region0.texExtent.height=1,i.push(new this._bufferViewCtor(e,u*this._formatSize,h*this._channels)),n.push(this._region0),a=0,o+=1,s-=h,u+=h),s>0&&(this._region1.texOffset.x=a,this._region1.texOffset.y=o,s>t.texture.width?(this._region1.texExtent.width=t.texture.width,this._region1.texExtent.height=Math.floor(s/t.texture.width),h=this._region1.texExtent.width*this._region1.texExtent.height):(h=s,this._region1.texExtent.width=h,this._region1.texExtent.height=1),i.push(new this._bufferViewCtor(e,u*this._formatSize,h*this._channels)),n.push(this._region1),a=0,o+=this._region1.texExtent.height,s-=h,u+=h),s>0&&(this._region2.texOffset.x=a,this._region2.texOffset.y=o,this._region2.texExtent.width=s,this._region2.texExtent.height=1,i.push(new this._bufferViewCtor(e,u*this._formatSize,s*this._channels)),n.push(this._region2)),this._device.copyBuffersToTexture(i,t.texture,n)},e._findAvailableSpace=function(t,e){var i=this._chunks[e],n=!1,r=i.start;if(r+t<=i.size)n=!0;else{r=0;for(var s=this._handles.filter((function(t){return t.chunkIdx===e})).sort((function(t,e){return t.start-e.start})),a=0;ai.end?r+t<=i.size?n=!0:t<=i.end&&(i.start=r=0,n=!0):r===i.end&&(i.start=r=0,i.end=i.size,t<=i.end&&(n=!0)),n){i.start+=t;var s={chunkIdx:e,start:r,end:r+t,texture:i.texture};return this._handles.push(s),s}}var a=Math.sqrt(t/this._formatSize),o=this._roundUpFn&&this._roundUpFn(a,this._formatSize)||Math.max(1024,nN(a)),h=this._chunks[this.createChunk(o)];h.start+=t;var u={chunkIdx:this._chunkCount,start:0,end:t,texture:h.texture};return this._handles.push(u),u},t}();mt(OP.prototype,"RenderScene.prototype",[{name:"raycastUI2DNode"},{name:"raycastUINode"}]),mt(OP.prototype,"RenderScene.prototype",[{name:"raycastAll",suggest:"using intersect.rayModel in geometry"},{name:"raycastAllModels",suggest:"using intersect.rayModel in geometry"},{name:"raycastSingleModel",suggest:"using intersect.rayModel in geometry"},{name:"raycastAllCanvas",suggest:"using intersect.rayAABB in geometry"},{name:"rayResultCanvas"},{name:"rayResultModels"},{name:"rayResultAll"},{name:"rayResultSingleModel"}]),mt(KM.prototype,"Model.prototype",[{name:"isInstancingEnabled"},{name:"instancedAttributes"}]);var aN={};mt(aN,"CameraVisFlags",[{name:"GENERAL"}]),pt(aN,"CameraVisFlags",[{name:"PROFILER",newName:"PROFILER",target:Ly.BitMask,targetName:"PROFILER"},{name:"GIZMOS",newName:"GIZMOS",target:Ly.BitMask,targetName:"GIZMOS"},{name:"EDITOR",newName:"EDITOR",target:Ly.BitMask,targetName:"EDITOR"},{name:"UI",newName:"UI",target:Ly.BitMask,targetName:"UI_3D"},{name:"UI2D",newName:"UI2D",target:Ly.BitMask,targetName:"UI_2D"}]),C.CameraVisFlags=aN;var oN={};mt(oN,"VisibilityFlags",[{name:"GENERAL"}]),pt(oN,"VisibilityFlags",[{name:"ALWALS",newName:"ALWALS",target:Ly.Enum,targetName:"ALWALS"},{name:"PROFILER",newName:"PROFILER",target:Ly.Enum,targetName:"PROFILER"},{name:"GIZMOS",newName:"GIZMOS",target:Ly.Enum,targetName:"GIZMOS"},{name:"EDITOR",newName:"EDITOR",target:Ly.Enum,targetName:"EDITOR"},{name:"UI",newName:"UI",target:Ly.Enum,targetName:"UI_3D"},{name:"UI2D",newName:"UI2D",target:Ly.Enum,targetName:"UI_2D"}]),C.VisibilityFlags=oN,pt(wT.prototype,"Pass.prototype",[{name:"getBindingTypeFromHandle",newName:"getDescriptorTypeFromHandle"}]),mt(NM.prototype,"Camera.prototype",[{name:"getSplitFrustum"},{name:"setMatView"},{name:"setMatViewInv"},{name:"setMatProjInv"},{name:"setMatViewProjInv"},{name:"setMatProj"},{name:"setMatViewProj"},{name:"getMatViewInv"}]),mt(JT.prototype,"Shadows.prototype",[{name:"aspect"},{name:"selfShadow"},{name:"linear"},{name:"packing"},{name:"autoAdapt"},{name:"fixedArea"},{name:"pcf"},{name:"bias"},{name:"normalBias"},{name:"near"},{name:"far"},{name:"shadowDistance"},{name:"invisibleOcclusionRange"},{name:"orthoSize"},{name:"saturation"}]),mt(dP.prototype,"SpotLight.prototype",[{name:"aspect"}]),pt(UM.prototype,"SubModel.prototype",[{name:"subMeshData",newName:"subMesh"}]),mt(UM.prototype,"SubModel.prototype",[{name:"getSubModel",suggest:"Use `subModels[i]` instead"},{name:"subModelNum",suggest:"Use `subModels.length` instead"}]);var hN=Object.freeze({__proto__:null,BatchingSchemes:{NONE:0,INSTANCING:1},CameraVisFlags:aN,MaterialInstance:QT,Pass:wT,PassInstance:KT,PassStage:{DEFAULT:1,FORWARD:2,SHADOWCAST:4},RenderQueue:{OPAQUE:0,TRANSPARENT:1,OVERLAY:2},RenderScene:OP,RenderWindow:VP,TextureBufferPool:sN,VisibilityFlags:oN,createIA:function(t,e){if(!e.positions)return ht(16306),null;for(var i=[],n=e.positions.length/3,r=0;r=2*cN)l=2*cN;else for(;l<0;)l+=2*cN;else if(mN(l)>=2*cN)l=2*-cN;else for(;l>0;)l-=2*cN;for(h=0|_N(1,fN(mN(l)/(.5*cN)+.5,5)),c=mN(4/3*(1-dN(o=l/h/2))/pN(o)),a||(c=-c),w=0;w<=h;w++)d=e+(f=dN(u=r+l*(w/h)))*n,p=i+(_=pN(u))*n,m=-_*n*c,g=f*n*c,0===w?t.moveTo(d,p):t.bezierCurveTo(y+b,v+S,d-m,p-g,d,p),y=d,v=p,b=m,S=g}function bN(t,e,i,n,r){t.moveTo(e-n,i),t.bezierCurveTo(e-n,i+r*yN,e-n*yN,i+r,e,i+r),t.bezierCurveTo(e+n*yN,i+r,e+n,i+r*yN,e+n,i),t.bezierCurveTo(e+n,i-r*yN,e+n*yN,i-r,e,i-r),t.bezierCurveTo(e-n*yN,i-r,e-n,i-r*yN,e-n,i),t.close()}function SN(t,e,i,n,r,s){if(s<.1)t.rect(e,i,n,r);else{var a=fN(s,.5*mN(n))*gN(n),o=fN(s,.5*mN(r))*gN(r);t.moveTo(e,i+o),t.lineTo(e,i+r-o),t.bezierCurveTo(e,i+r-o*(1-yN),e+a*(1-yN),i+r,e+a,i+r),t.lineTo(e+n-a,i+r),t.bezierCurveTo(e+n-a*(1-yN),i+r,e+n,i+r-o*(1-yN),e+n,i+r-o),t.lineTo(e+n,i+o),t.bezierCurveTo(e+n,i+o*(1-yN),e+n-a*(1-yN),i,e+n-a,i),t.lineTo(e+a,i),t.bezierCurveTo(e+a*(1-yN),i,e,i+o*(1-yN),e,i+o),t.close()}}function wN(t,e,i,n,r,s,a,o,h,u,l){var c,f,_,d,p,m,g,y,v,b,S,w,x,T,A,C;u>10||(p=.5*(s+o),m=.5*(a+h),g=.5*((c=.5*(e+n))+(_=.5*(n+s))),y=.5*((f=.5*(i+r))+(d=.5*(r+a))),((A=mN((n-o)*(T=h-i)-(r-h)*(x=o-e)))+(C=mN((s-o)*T-(a-h)*x)))*(A+C)0){for(var i=0;ii)for(var n=i;n=0&&s.y>=0&&s.x<=n&&s.y<=r;else if(1===this.type){var h=n/2,u=r/2,l=s.x-.5*n,c=s.y-.5*r;o=l*l/(h*h)+c*c/(u*u)<1}return this._inverted&&(o=!o),o},i._nodeStateChange=function(){this._updateGraphics()},i._changeRenderType=function(){3!==this._type?this._createGraphics():this._createSprite()},i._createSprite=function(){if(!this._sprite){var t=this._sprite=this.node.getComponent(GV);if(!t){var e=this.node;t=this._sprite=e.addComponent(GV)}}this._sprite.stencilStage=this.inverted?6:2,this._sprite.updateMaterial()},i._createGraphics=function(){if(!this._graphics){var t=this._graphics=this.node.getComponent(ZN);if(!t){var e=this.node;t=this._graphics=e.addComponent(ZN)}t.lineWidth=1;var i=cr.WHITE.clone();i.a=0,t.fillColor=i}this._graphics.stencilStage=this.inverted?6:2},i._updateGraphics=function(){if(this._graphics&&(0===this._type||1===this._type)){var t=this.node._getUITransformComp(),e=this._graphics;e.clear();var i=t.contentSize,n=i.width,r=i.height,s=t.anchorPoint,a=-n*s.x,o=-r*s.y;if(0===this._type)e.rect(a,o,n,r);else if(1===this._type){for(var h=nz(new ir(a+n/2,o+r/2,0),new ir(n/2,r/2,0),this._segments),u=0;up?0:d>0?d:p}A.Canvas=dU,mt(t("U",Kh("cc.UIComponent")(cU=Qh(lL)(cU=Zh(110)(cU=$h(cU=function(t){function e(){var e;return(e=t.call(this)||this)._lastParent=null,e.stencilStage=0,e}s(e,t);var i=e.prototype;return i.__preload=function(){this.node._uiProps.uiComp=this},i.onEnable=function(){},i.onDisable=function(){},i.onDestroy=function(){var t=this.node._uiProps;t.uiComp===this&&(t.uiComp=null)},i.postUpdateAssembler=function(){},i.markForUpdateRenderData=function(){},i.setNodeDirty=function(){},i.setTextureDirty=function(){},e}(yg))||cU)||cU)||cU)||cU).prototype,"UIComponent",[{name:"_visibility"},{name:"setVisibility"}]),pt(dU.prototype,"Canvas.prototype",[{name:"camera",newName:"cameraComponent.camera",customGetter:function(){var t;return null==(t=this._cameraComponent)?void 0:t.camera}},{name:"clearFlag",newName:"cameraComponent.clearFlags",customGetter:function(){return this._cameraComponent?this._cameraComponent.clearFlags:0},customSetter:function(t){this._cameraComponent&&(this._cameraComponent.clearFlags=t)}},{name:"color",newName:"cameraComponent.clearColor",customGetter:function(){return this._cameraComponent?this._cameraComponent.clearColor:cr.BLACK},customSetter:function(t){this._cameraComponent&&(this._cameraComponent.clearColor=t)}},{name:"priority",newName:"cameraComponent.priority",customGetter:function(){return this._cameraComponent?this._cameraComponent.priority:0},customSetter:function(t){this._cameraComponent&&(this._cameraComponent.priority=t)}},{name:"targetTexture",newName:"cameraComponent.targetTexture",customGetter:function(){return this._cameraComponent?this._cameraComponent.targetTexture:null},customSetter:function(t){this._cameraComponent&&(this._cameraComponent.targetTexture=t)}},{name:"visibility",newName:"cameraComponent.visibility",customGetter:function(){return this._cameraComponent?this._cameraComponent.visibility:0}}]),gt(lL.prototype,"UITransform.prototype",[{name:"priority",suggest:"Please use setSiblingIndex to change index of the current node in its parent's children array."}]),A.UITransformComponent=lL,le(lL,"cc.UITransformComponent"),le(BL,"cc.RenderComponent"),A.CanvasComponent=dU,le(dU,"cc.CanvasComponent"),A.internal.Renderable2D=BL,le(BL,"cc.Renderable2D");var mU,gU,yU,vU,bU,SU,wU,xU,TU=(mU=ro.create(),gU={distance:1/0,doubleSided:!1,mode:2},yU=0,vU=function(t,e,i,n,r,s){1===t?(yU>e||0===yU)&&(yU=e,s&&(0===s.length?s.push({distance:e,vertexIndex0:i/3,vertexIndex1:n/3,vertexIndex2:r/3}):(s[0].distance=e,s[0].vertexIndex0=i/3,s[0].vertexIndex1=n/3,s[0].vertexIndex2=r/3))):(yU=e,s&&s.push({distance:e,vertexIndex0:i/3,vertexIndex1:n/3,vertexIndex2:r/3}))},bU=function(t,e,i,n,r){if(7===i)for(var s=e.length,a=0;ar.distance)&&(vU(r.mode,l,o,h,u,r.result),2===r.mode))return l}else if(8===i)for(var c=e.length-2,f=0,_=0;_r.distance)&&(vU(r.mode,g,d,p,m,r.result),2===r.mode))return g}else if(9===i){var y=e.length-1,v=3*e[0];ir.set(mU.a,t[v],t[v+1],t[v+2]);for(var b=1;br.distance)&&(vU(r.mode,x,v,S,w,r.result),2===r.mode))return x}}return yU},function(t,e,i){if(yU=0,0===e.geometricInfo.positions.length)return yU;var n=void 0===i?gU:i;if(pU(t,e.geometricInfo.boundingBox.min,e.geometricInfo.boundingBox.max)){var r=e.primitiveMode,s=e.geometricInfo,a=s.positions,o=s.indices;bU(a,o,r,t,n)}return yU}),AU=function(){var t=0,e={distance:1/0,doubleSided:!1,mode:2};return function(i,n,r){t=0;var s=void 0===r?e:r,a=n.renderingSubMeshes.length,o=n.struct.minPosition,h=n.struct.maxPosition;if(o&&h&&!pU(i,o,h))return t;for(var u=0;uc)&&(t=c,s.subIndices&&(s.subIndices[0]=u));else if(t=c,s.subIndices&&s.subIndices.push(u),2===s.mode)return c}return t&&1===s.mode&&(s.result&&(s.result[0].distance=t,s.result.length=1),s.subIndices&&(s.subIndices.length=1)),t}}(),CU=function(){var t=0,e={distance:1/0,doubleSided:!1,mode:2},i=new Vs,n=new Kr;return function(r,s,a){t=0;var o=void 0===a?e:a,h=s.worldBounds;if(h&&!Za.rayAABB(r,h))return t;Vs.copy(i,r),s.node&&(Kr.invert(n,s.node.getWorldMatrix(n)),ir.transformMat4(i.o,r.o,n),ir.transformMat4Normal(i.d,r.d,n));for(var u=s.subModels,l=0;lf)&&(t=f,o.subIndices&&(o.subIndices[0]=l));else if(t=f,o.subIndices&&o.subIndices.push(l),2===o.mode)return f}return t&&1===o.mode&&(o.result&&(o.result[0].distance=t,o.result.length=1),o.subIndices&&(o.subIndices.length=1)),t}}();Za.rayModel=CU,Za.raySubMesh=TU,Za.rayMesh=AU,gT("specular-pass");var DU,BU,IU,MU,PU,EU,OU,kU,RU,FU,LU,VU,NU,zU,UU,GU,HU=t("dO",Kh("cc.ModelRenderer")((wU=function(t){function e(){var e;return(e=t.call(this)||this)._visFlags=xU&&xU(),e._models=[],e._priority=0,e}s(e,t);var i=e.prototype;return i._collectModels=function(){return this._models},i.onEnable=function(){this._updatePriority()},i._attachToScene=function(){},i._detachFromScene=function(){},i._onVisibilityChange=function(){},i._updatePriority=function(){if(this._models.length>0)for(var t=0;tc;){if((s/=2)<1){s*=2;break}a=a.substring(r,s),o=n.substring(s),this._calculateSize(h,e,a)}for(var f=1e3,_=1;f&&r0&&(_=d[0].length),s+=_,a=n.substring(r,s),o=n.substring(s),this._calculateSize(h,e,a),f--}for(;f&&a.length>=2&&h.x>c;)s-=_,a=n.substring(r,s),this._calculateSize(h,e,a),_=1,f--;if(a.length>=2){var p=RR(a);p&&p.length>0&&a!==p[0]&&(s-=p[0].length,a=n.substring(r,s))}if(i.push(a),r=s,s+=a.length,a=n.substring(r,s),o=n.substring(s),this._calculateSize(u,e,o),this._calculateSize(h,e,a),f--,u.x<2048&&h.x=0;e--){var i=t[e];if(i.name===yG||i.name===vG){i.parent=null;var n=TG(i.name);n.node=i,i.name===yG?(n.comp=i.getComponent(LV),wG.put(n)):(n.comp=i.getComponent(GV),xG.put(n)),this._labelChildrenNum--}}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},i._activateChildren=function(t){for(var e=this.node.children.length-1;e>=0;e--){var i=this.node.children[e];i.name!==yG&&i.name!==vG||(i.active=t)}},i._addLabelSegment=function(t,e){var i;if(0===this._labelSegmentsCache.length)i=this._createFontLabel(t);else{var n=(i=this._labelSegmentsCache.pop()).node.getComponent(LV);n&&(n.string=t)}var r=i.comp;return r.verticalAlign!==this._verticalAlign&&(r.verticalAlign=this._verticalAlign),i.styleIndex=e,i.lineCount=this._lineCount,i.node._getUITransformComp().setAnchorPoint(0,0),i.node.layer=this.node.layer,this.node.insertChild(i.node,this._labelChildrenNum++),this._applyTextAttribute(i),this._segments.push(i),i},i._updateRichTextWithMaxWidth=function(t,e,i){var n=e;if(this._lineOffsetX>0&&n+this._lineOffsetX>this._maxWidth)for(var r=0;this._lineOffsetX<=this._maxWidth;){var s=this._getFirstWordLen(t,r,t.length),a=t.substr(r,s),o=this._measureText(i,a);if(!(this._lineOffsetX+o<=this._maxWidth)){if(r>0){var h=t.substr(0,r);this._addLabelSegment(h,i),t=t.substr(r,t.length),n=this._measureText(i,t)}this._updateLineInfo();break}this._lineOffsetX+=o,r+=s}if(n>this._maxWidth)for(var u=FR(t,n,this._maxWidth,this._measureText(i)),l=0;l1&&l0?(o*=a=l/h,h*=a):(o*=a=this._lineHeight/h,h*=a),u>0&&(o=u),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._getUITransformComp().setContentSize(o,h),r.lineCount=this._lineCount,r.clickHandler="",r.clickParam="";var c=e.event;c&&(r.clickHandler=c.click,r.clickParam=c.param)}else at(4400)}},i._updateTextDefaultColor=function(){for(var t=0;t0){var u=this._measureText(n,h);this._updateRichTextWithMaxWidth(h,u,n),a.length>1&&othis._labelWidth&&(this._labelWidth=this._lineOffsetX),a.length>1&&o0&&(this._labelWidth=this._maxWidth),this._labelHeight=(this._lineCount+fR)*this._lineHeight,this.node._getUITransformComp().setContentSize(this._labelWidth,this._labelHeight),this._updateRichTextPosition(),this._layoutDirty=!1}},i._getFirstWordLen=function(t,e,i){var n=IR(t,e);if(AR(n)||CR(n))return 1;for(var r=1,s=e+1;se&&(t=0,e=h);var u=this._labelWidth*(.5*this._horizontalAlign-r);switch(this._horizontalAlign){case 0:break;case 1:u-=this._linesWidth[h-1]/2;break;case 2:u-=this._linesWidth[h-1]}var l=o.node.position;if(o.node.setPosition(t+u,this._lineHeight*(i-h)-this._labelHeight*s,l.z),h===e&&(t+=o.node._getUITransformComp().width),o.node.getComponent(GV)){var c=o.node.position.clone(),f=this._lineHeight,_=this._lineHeight*(1+fR);switch(o.node._getUITransformComp().anchorY){case 1:c.y+=f+(_-f)/2;break;case.5:c.y+=_/2;break;default:c.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)&&(c.y+=p)}else if(2===d.length){var m=parseFloat(d[0]),g=parseFloat(d[1]);Number.isInteger(m)&&(c.x+=m),Number.isInteger(g)&&(c.y+=g)}}o.node.position=c}var y=o.node.getComponent(LV);if(y&&y.enableOutline){var v=o.node.position.clone();v.y-=y.outlineWidth,o.node.position=v}}},i._convertLiteralColorValue=function(t){var e=t.toUpperCase();return cr[e]?cr[e]:(new cr).fromHEX(t)},i._applyTextAttribute=function(t){var e=t.node.getComponent(LV);if(e){this._resetLabelState(e);var i,n=t.styleIndex;if(this._textArray[n]&&(i=this._textArray[n].style),i){if(i.color?e.color=this._convertLiteralColorValue(i.color):e.color=this._fontColor,e.isBold=!!i.bold,e.isItalic=!!i.italic,e.isUnderline=!!i.underline,i.outline){var r=t.node.getComponent(LV);r||(r=t.node.addComponent(LV)),r.enableOutline=!0,r.outlineColor=this._convertLiteralColorValue(i.outline.color),r.outlineWidth=i.outline.width}e.fontSize=i.size||this._fontSize,t.clickHandler="",t.clickParam="";var s=i.event;s&&(t.clickHandler=s.click||"",t.clickParam=s.param||"")}e.cacheMode=this._cacheMode,this._font instanceof uR&&!this._isSystemFontUsed?e.font=this._font:e.fontFamily=this._fontFamily,e.useSystemFont=this._isSystemFontUsed,e.lineHeight=this._lineHeight,e.updateRenderData(!0)}},i._applyLayer=function(){var t=this;this._segments.forEach((function(e){e.node.layer=t.node.layer}))},i._resetLabelState=function(t){t.fontSize=this._fontSize,t.color=this._fontColor,t.isBold=!1,t.isItalic=!1,t.isUnderline=!1},n(e,[{key:"string",get:function(){return this._string},set:function(t){this._string!==t&&(this._string=t,this._updateRichTextStatus())}},{key:"horizontalAlign",get:function(){return this._horizontalAlign},set:function(t){this.horizontalAlign!==t&&(this._horizontalAlign=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"verticalAlign",get:function(){return this._verticalAlign},set:function(t){this._verticalAlign!==t&&(this._verticalAlign=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"fontSize",get:function(){return this._fontSize},set:function(t){this._fontSize!==t&&(this._fontSize=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"fontColor",get:function(){return this._fontColor},set:function(t){this._fontColor!==t&&(this._fontColor=t,this._updateTextDefaultColor())}},{key:"fontFamily",get:function(){return this._fontFamily},set:function(t){this._fontFamily!==t&&(this._fontFamily=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"font",get:function(){return this._font},set:function(t){this._font!==t&&(this._font=t,this._layoutDirty=!0,this._font?(this.useSystemFont=!1,this._onTTFLoaded()):this.useSystemFont=!0,this._updateRichTextStatus())}},{key:"useSystemFont",get:function(){return this._isSystemFontUsed},set:function(t){this._isSystemFontUsed!==t&&(this._isSystemFontUsed=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"cacheMode",get:function(){return this._cacheMode},set:function(t){this._cacheMode!==t&&(this._cacheMode=t,this._updateRichTextStatus())}},{key:"maxWidth",get:function(){return this._maxWidth},set:function(t){this._maxWidth!==t&&(this._maxWidth=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"lineHeight",get:function(){return this._lineHeight},set:function(t){this._lineHeight!==t&&(this._lineHeight=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"imageAtlas",get:function(){return this._imageAtlas},set:function(t){this._imageAtlas!==t&&(this._imageAtlas=t,this._layoutDirty=!0,this._updateRichTextStatus())}},{key:"handleTouchEvent",get:function(){return this._handleTouchEvent},set:function(t){this._handleTouchEvent!==t&&(this._handleTouchEvent=t,this.enabledInHierarchy&&(this.handleTouchEvent?this._addEventListeners():this._removeEventListeners()))}}]),e}(yg),mG.HorizontalAlign=_V,mG.VerticalAlign=dV,v((eG=mG).prototype,"horizontalAlign",[YU],Object.getOwnPropertyDescriptor(eG.prototype,"horizontalAlign"),eG.prototype),v(eG.prototype,"verticalAlign",[JU],Object.getOwnPropertyDescriptor(eG.prototype,"verticalAlign"),eG.prototype),v(eG.prototype,"fontColor",[KU],Object.getOwnPropertyDescriptor(eG.prototype,"fontColor"),eG.prototype),v(eG.prototype,"font",[QU],Object.getOwnPropertyDescriptor(eG.prototype,"font"),eG.prototype),v(eG.prototype,"cacheMode",[ZU],Object.getOwnPropertyDescriptor(eG.prototype,"cacheMode"),eG.prototype),v(eG.prototype,"imageAtlas",[$U],Object.getOwnPropertyDescriptor(eG.prototype,"imageAtlas"),eG.prototype),iG=zh(eG.prototype,"_lineHeight",[uu],(function(){return 40})),nG=zh(eG.prototype,"_string",[uu],(function(){return"RichText"})),rG=zh(eG.prototype,"_horizontalAlign",[uu],(function(){return 0})),sG=zh(eG.prototype,"_verticalAlign",[uu],(function(){return 0})),aG=zh(eG.prototype,"_fontSize",[uu],(function(){return 40})),oG=zh(eG.prototype,"_fontColor",[uu],(function(){return cr.WHITE.clone()})),hG=zh(eG.prototype,"_maxWidth",[uu],(function(){return 0})),uG=zh(eG.prototype,"_fontFamily",[uu],(function(){return"Arial"})),lG=zh(eG.prototype,"_font",[uu],(function(){return null})),cG=zh(eG.prototype,"_isSystemFontUsed",[uu],(function(){return!0})),fG=zh(eG.prototype,"_userDefinedFont",[uu],(function(){return null})),_G=zh(eG.prototype,"_cacheMode",[uu],(function(){return 0})),dG=zh(eG.prototype,"_imageAtlas",[uu],(function(){return null})),pG=zh(eG.prototype,"_handleTouchEvent",[uu],(function(){return!0})),tG=eG))||tG)||tG));A.RichText=CG,A.MaskComponent=cz,le(cz,"cc.MaskComponent"),A.LabelComponent=LV,le(LV,"cc.LabelComponent"),A.LabelOutlineComponent=jV,le(jV,"cc.LabelOutlineComponent"),A.RichTextComponent=CG,le(CG,"cc.RichTextComponent"),A.SpriteComponent=GV,le(GV,"cc.SpriteComponent"),A.UIModelComponent=WV,le(WV,"cc.UIModelComponent"),A.GraphicsComponent=ZN,le(ZN,"cc.GraphicsComponent"),le(tN,"cc.UIStaticBatchComponent"),le(iN,"cc.UIOpacityComponent"),pt(cz.prototype,"Mask",[{name:"graphics",newName:"subComp",target:cz.prototype,targetName:"Mask"}]),pt(rz,"MaskType",[{name:"RECT",newName:"GRAPHICS_RECT",target:rz,targetName:"MaskType"},{name:"ELLIPSE",newName:"GRAPHICS_ELLIPSE",target:rz,targetName:"MaskType"},{name:"IMAGE_STENCIL",newName:"SPRITE_STENCIL",target:rz,targetName:"MaskType"}]),gt(jV.prototype,"LabelOutline",[{name:"width",suggest:"Please use Label.outlineWidth instead."},{name:"color",suggest:"Please use Label.outlineColor instead."}]),gt(eN.prototype,"LabelShadow",[{name:"color",suggest:"Please use Label.shadowColor instead."},{name:"offset",suggest:"Please use Label.shadowOffset instead."},{name:"blur",suggest:"Please use Label.shadowBlur instead."}]);var DG=["left","center","right"],BG=2048,IG=pR(),MG=(1/255).toFixed(3),PG=function(){this.char="",this.valid=!0,this.x=0,this.y=0,this.line=0,this.hash=""},EG=function(){function t(){this._context=null,this._canvas=null,this._canvasData=null,this._lettersInfo=[],this._tmpRect=new bs,this._maxFontSize=100,this._fontScale=1;var t=this._canvasData=dF.getInstance().get();this._canvas=t.canvas,this._context=t.context}var e=t.prototype;return e.destroy=function(){dF.getInstance().put(this._canvasData),this._canvasData=null,this._canvas=null,this._context=null,this._lettersInfo.length=0},e.processingString=function(t,e,i,n,r,s){if(t)e.fntConfig?this._fontScale=1:this._fontScale=this._getStyleFontScale(e.originFontSize,e.fontScale),SF.fontScale=this._fontScale,this._setupBMFontOverflowMetrics(i,n),this._updateFontScale(e),this._computeHorizontalKerningForText(e,i,r),this._alignText(e,i,n,r);else{var a=0;for(this._fontScale=this._getStyleFontScale(e.fontSize,e.fontScale),this._updatePaddingRect(e,n),this._calculateLabelFont(e,i,n,r);(n.canvasSize.width>BG||n.canvasSize.height>BG)&&a<=3;){if(++a>3)this._fontScale=1;else{var o=Math.max(n.canvasSize.width,n.canvasSize.height),h=BG/o;this._fontScale*=h,this._fontScale=Math.max(1,this._fontScale)}this._updatePaddingRect(e,n),this._calculateLabelFont(e,i,n,r)}}s&&(s=n.parsedString)},e.generateRenderInfo=function(t,e,i,n,r,s,a){t?(this._computeAlignmentOffset(e,i,n),this.generateVertexData(t,e,i,n,r,s,a)):(this._updateLabelDimensions(e,i,n),this._updateTexture(e,i,n,r),this.generateVertexData(t,e,i,n,r,s,a))},e.setCanvasUsed=function(t,e){this._canvas=t,this._context=e},e._getStyleFontScale=function(t,e){var i=e,n=this._maxFontSize;return i*t>n&&td?f:d}var p=f,m=(s.length+fR)*this._getLineHeight(e.lineHeight,t.actualFontSize,t.fontSize);o.width=p+u.width*c,o.height=m+u.height*c,h.width=(p+l.width*c)/c,h.height=(m+l.height*c)/c;break;case 2:this._calculateShrinkFont(r,t,e,i),this._calculateWrapText(r,t,e,i),o.width=h.width*c,o.height=h.height*c;break;case 1:this._calculateWrapText(r,t,e,i),o.width=h.width*c,o.height=h.height*c;break;case 3:this._calculateWrapText(r,t,e,i);var g=(i.parsedString.length+fR)*this._getLineHeight(e.lineHeight,t.actualFontSize,t.fontSize);o.width=h.width*c,o.height=g+u.height*c,h.height=(g+l.height*c)/c}}},e._getFontDesc=function(t,e,i,n){var r=t.toString()+"px ";return r+=e,i&&(r="bold "+r),n&&(r="italic "+r),r},e._getLineHeight=function(t,e,i){return 0===t?e:t*e/i},e._calculateShrinkFont=function(t,e,i,n){if(this._context){var r=this._getFontDesc(e.actualFontSize,e.fontFamily,e.isBold,e.isItalic);this._context.font=r;var s=this._calculateParagraphLength(t,this._context,r),a=0,o=0,h=0,u=e.actualFontSize,l=n.canvasSize,c=n.nodeContentSize,f=n.canvasPadding,_=this._fontScale;if(i.wrapping){var d=c.width*_,p=c.height*_;if(d<0||p<0)return;o=p+1;for(var m=0,g=0|e.actualFontSize+1,y=0;m>1)<=0){it(4003);break}u=y,r=this._getFontDesc(u,e.fontFamily,e.isBold,e.isItalic),this._context.font=r;var v=this._getLineHeight(i.lineHeight,u,e.fontSize);for(o=0,a=0;ap?g=y-1:m=y}0===m?it(4003):(u=m,r=this._getFontDesc(u,e.fontFamily,e.isBold,e.isItalic),this._context.font=r)}else{for(o=t.length*this._getLineHeight(i.lineHeight,u,e.fontSize),a=0;a1&&i.hasShadow,h=this._measureText(this._context,i.fontDesc),u=0,l=0,c=0;c0&&this._isVerticalClamp(t,e,i,n,this)&&this._shrinkLabelToContentSize(t,e,i,n,this._isVerticalClamp),t.fontSize>0&&this._isHorizontalNeedShrink(e,i)&&this._shrinkLabelToContentSize(t,e,i,n,this._isHorizontalClamp)),this._parsedString(i,n)},e._parsedString=function(t,e){for(var i=[],n="",r=0,s=0,a=BR(e);r0&&h>0&&C+d.w*t.bmfontScale>e.maxLineWidth&&!CR(m)){e.linesWidth.push(c),c=0,o++,h=0,u-=e.lineHeight*this._getFontScale(t,e)+0,w=!0;break}x.x=C,x.y=u-d.offsetY*t.bmfontScale,this._recordLetterInfo(x,m,A,o),A+1x.y-d.h*t.bmfontScale&&(v=x.y-d.h*t.bmfontScale)}else this._recordPlaceholderInfo(A,m),null!=t.fntConfig?it(16354,t.fntConfig.atlasName,m):it(16355,t.fontFamily,m);else this._recordPlaceholderInfo(A,m)}w||(h=S,fv&&(_=v),l<(c=b)&&(l=c),p+=g)}else e.linesWidth.push(c),c=0,o++,h=0,u-=e.lineHeight*this._getFontScale(t,e)+0,this._recordPlaceholderInfo(p,m),p++}e.linesWidth.push(c),e.numberOfLines=o+1,e.textDesiredHeight=e.numberOfLines*e.lineHeight*this._getFontScale(t,e),e.numberOfLines>1&&(e.textDesiredHeight+=0*(e.numberOfLines-1));var D=i.nodeContentSize;return D.width=e.textWidthTemp,D.height=e.textHeightTemp,e.textWidthTemp<=0&&(D.width=parseFloat(l.toFixed(2))+2*SF.margin),e.textHeightTemp<=0&&(D.height=parseFloat(e.textDesiredHeight.toFixed(2))+2*SF.margin),e.tailoredTopY=D.height,e.tailoredBottomY=0,f>0&&(e.tailoredTopY=D.height+f),_<-e.textDesiredHeight&&(e.tailoredBottomY=e.textDesiredHeight+_),!0},e._recordPlaceholderInfo=function(t,e){var i=this._lettersInfo;if(t>=i.length){var n=new PG;i.push(n)}i[t].char=e,i[t].hash=""+MR(e,0)+SF.hash,i[t].valid=!1},e._recordLetterInfo=function(t,e,i,n){var r=this._lettersInfo;if(i>=r.length){var s=new PG;r.push(s)}var a=""+MR(e,0)+SF.hash;r[i].line=n,r[i].char=e,r[i].hash=a,r[i].valid=SF.fontAtlas.getLetter(a).valid,r[i].x=t.x,r[i].y=t.y},e._getFirstWordLen=function(t,e,i,n,r){var s=IR(i,n);if(AR(s)||"\n"===s||CR(s))return 1;var a=SF.fontAtlas,o=1,h=a.getLetterDefinitionForChar(s,SF);if(!h)return o;for(var u=h.xAdvance*t.bmfontScale+e.spacingX,l=n+1;le.maxLineWidth&&!CR(s)&&e.maxLineWidth>0)return o;if(u+=h.xAdvance*t.bmfontScale+e.spacingX,"\n"===s||CR(s)||AR(s))break;o++}return o},e._computeAlignmentOffset=function(t,e,i){var n=i.nodeContentSize;switch(e.linesOffsetX.length=0,e.letterOffsetY=0,e.horizontalAlign){case 0:for(var r=0;ri.nodeContentSize.height},e._isHorizontalClamp=function(t,e,i,n,r){for(var s=!1,a=0,o=BR(n);a0){var f=i.nodeContentSize;if(e.wrapping){if(e.linesWidth[c]>f.width&&(l>f.width||l<0)){s=!0;break}}else if(l>f.width){s=!0;break}}}}return s},e._isHorizontalNeedShrink=function(t,e){for(var i=0,n=t.linesWidth.length;ie.nodeContentSize.width)return!0;return!1},e._shrinkLabelToContentSize=function(t,e,i,n,r){for(var s=0,a=0|t.actualFontSize,o=0;s>1;if(h<=0)break;t.bmfontScale=h/(t.originFontSize*this._fontScale),this._multilineTextWrap(t,e,i,n,this._getFirstWordLen),this._computeAlignmentOffset(t,e,i),r(t,e,i,n,this)?a=o-1:s=o}s>=0&&this._scaleFontSizeDown(t,e,i,n,s)},e._scaleFontSizeDown=function(t,e,i,n,r){var s=!0;r||(r=.1,s=!1),t.actualFontSize=r,s&&(this._updateFontScale(t),this._multilineTextWrap(t,e,i,n,this._getFirstWordLen))},e._updateQuads=function(t,e,i,n,r,s){for(var a=SF.fontAtlas,o=t.spriteFrame?t.spriteFrame.texture:a.getTexture(),h=i.nodeContentSize,u=n.uiTransAnchorX*h.width,l=n.uiTransAnchorY*h.height,c=0,f=BR(r);c0){if(m>e.tailoredTopY){var g=m-e.tailoredTopY;p.y+=g,p.height-=g,m-=g}m-p.height*t.bmfontScale0&&this._isHorizontalClamped(e,i,v,y)&&1===e.overFlow&&(p.width=0),p.height>0&&p.width>0){var b=this._determineRect(t),S=_.x+e.linesOffsetX[_.line],w=n.quadCount;n.quadCount+=4,this.updateQuatCount(n),s(t,i,n,w,o,p,b,S-u,m-l)}}else at(16353)}}return!0},e._isHorizontalClamped=function(t,e,i,n){var r=e.nodeContentSize,s=t.linesWidth[n],a=i>r.width||i<0;return t.wrapping?s>r.width&&a:a},e._determineRect=function(t){var e=t.spriteFrame;if(!e)return!1;var i=e.isRotated(),n=e.getOriginalSize(),r=e.getRect(),s=e.getOffset(),a=s.x+(n.width-r.width)/2,o=s.y-(n.height-r.height)/2,h=this._tmpRect;if(i){var u=h.x;h.x=r.x+r.height-h.y-h.height-o,h.y=u+r.y-a,h.y<0&&(h.height+=o)}else h.x+=r.x-a,h.y+=r.y+o;return i},t}();EG.instance=void 0,EG.instance=new EG;var OG=new bF(64,64),kG=new lF(null),RG=null,FG=null,LG=null,VG=null,NG=null,zG=function(){function t(){}var e=t.prototype;return e.updateProcessingData=function(t,e,i,n,r,s){t.fontSize=r.fontSize,t.actualFontSize=r.fontSize,t.originFontSize=LG?LG.fontSize:r.fontSize,e.horizontalAlign=r.horizontalAlign,e.verticalAlign=r.verticalAlign,e.spacingX=r.spacingX;var a=r.overflow;e.overFlow=a,e.lineHeight=r.lineHeight,i.nodeContentSize.width=s.width,i.nodeContentSize.height=s.height,0===a?(e.wrapping=!1,i.nodeContentSize.width+=2*SF.margin,i.nodeContentSize.height+=2*SF.margin):3===a?(e.wrapping=!0,i.nodeContentSize.height+=2*SF.margin):e.wrapping=r.enableWrapText,n.uiTransAnchorX=s.anchorX,n.uiTransAnchorY=s.anchorY,SF.lineHeight=r.lineHeight,SF.fontSize=r.fontSize,t.spriteFrame=VG,t.fntConfig=LG,t.fontFamily=SF.fontFamily,t.color.set(r.color)},e.updateRenderData=function(t){if(t.renderData&&RG!==t){if(t.renderData.vertDirty){FG=(RG=t).node._getUITransformComp();var e=t.renderData,i=EG.instance,n=t.textStyle,r=t.textLayout,s=t.textLayoutData,a=t.textRenderData;n.fontScale=zO.getScaleX(),this._updateFontFamily(t),this.updateProcessingData(n,r,s,a,t,FG),this._updateLabelInfo(t),n.fontDesc=SF.fontDesc,i.processingString(!0,n,r,s,t.string),a.quadCount=0,i.generateRenderInfo(!0,n,r,s,a,t.string,this.generateVertexData),e.dataLength!==a.quadCount&&(this.resetRenderData(t),e.dataLength=a.quadCount,e.resize(e.dataLength,e.dataLength/2*3));for(var o=e.data,h=0,u=a.quadCount;h0?(SF.isOutlined=!0,SF.margin=t.outlineWidth,SF.out=t.outlineColor.clone(),SF.out.a=t.outlineColor.a*t.color.a/255):(SF.isOutlined=!1,SF.margin=0)},i._getFontFamily=function(t){var e="Arial";return t.useSystemFont?e=t.fontFamily||"Arial":t.font&&(e=t.font._nativeAsset||"Arial"),e},i._updateLabelInfo=function(t){SF.fontDesc=this._getFontDesc(),SF.color.set(t.color),SF.hash=wF(SF)},i._getFontDesc=function(){return SF.fontSize.toString()+"px "+SF.fontFamily},e}(zG),qG=new cr(255,255,255,255),XG=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.createData=function(t){var e=t.requestRenderData();return e.resize(0,0),e},i.fillBuffers=function(t){if(t.renderData){var e=t.node;qG.a=255*e._uiProps.opacity,qp(e,0,t.renderData,qG)}},i.updateColor=function(){},e}(jG),YG=new XG;LV.Overflow;var JG=function(){function t(){}var e=t.prototype;return e.updateProcessingData=function(t,e,i,n,r,s){t.isSystemFontUsed=r.useSystemFont,t.fontSize=r.fontSize,i.nodeContentSize.width=i.canvasSize.width=s.width,i.nodeContentSize.height=i.canvasSize.height=s.height,e.lineHeight=r.lineHeight,e.overFlow=r.overflow,0===r.overflow?e.wrapping=!1:3===r.overflow?e.wrapping=!0:e.wrapping=r.enableWrapText,t.isBold=r.isBold,t.isItalic=r.isItalic,t.isUnderline=r.isUnderline,t.underlineHeight=r.underlineHeight,r.enableOutline&&r.outlineWidth>0?(t.isOutlined=!0,t.outlineColor.set(r.outlineColor),t.outlineWidth=r.outlineWidth):t.isOutlined=!1,r.enableShadow&&(r.shadowBlur>0||!Zi(r.shadowOffset.x,0)||!Zi(r.shadowOffset.y,0))?(t.hasShadow=!0,t.shadowColor.set(r.shadowColor),t.shadowBlur=r.shadowBlur,t.shadowOffsetX=r.shadowOffset.x,t.shadowOffsetY=r.shadowOffset.y):t.hasShadow=!1,t.color.set(r.color),n.texture=r.spriteFrame,n.uiTransAnchorX=s.anchorX,n.uiTransAnchorY=s.anchorY,e.horizontalAlign=r.horizontalAlign,e.verticalAlign=r.verticalAlign},e.getAssemblerData=function(){var t=LV._canvasPool.get();return t.canvas.width=t.canvas.height=1,t},e.resetAssemblerData=function(t){t&&LV._canvasPool.put(t)},e.updateRenderData=function(t){if(t.renderData){if(t.renderData.vertDirty){var e=t.node._getUITransformComp(),i=EG.instance,n=t.textStyle,r=t.textLayout,s=t.textLayoutData,a=t.textRenderData;n.fontScale=zO.getScaleX(),this.updateProcessingData(n,r,s,a,t,e),i.setCanvasUsed(t.assemblerData.canvas,t.assemblerData.context),n.fontFamily=this._updateFontFamily(t),this._resetDynamicAtlas(t),i.processingString(!1,n,r,s,t.string),i.generateRenderInfo(!1,n,r,s,a,t.string,this.generateVertexData);var o=t.renderData;o.textureDirty=!0,this._calDynamicAtlas(t,s),t.actualFontSize=n.actualFontSize,e.setContentSize(s.nodeContentSize);var h=o.data;h[0]=a.vertexBuffer[0],h[1]=a.vertexBuffer[1],h[2]=a.vertexBuffer[2],h[3]=a.vertexBuffer[3],this.updateUVs(t),t.renderData.vertDirty=!1,t.contentWidth=s.nodeContentSize.width}t.spriteFrame&&t.renderData.updateRenderData(t,t.spriteFrame)}},e.generateVertexData=function(t,e,i){var n=i.vertexBuffer,r=e.nodeContentSize.width,s=e.nodeContentSize.height,a=i.uiTransAnchorX*r,o=i.uiTransAnchorY*s;n[0].x=-a,n[0].y=-o,n[1].x=r-a,n[1].y=-o,n[2].x=-a,n[2].y=s-o,n[3].x=r-a,n[3].y=s-o},e.updateVertexData=function(){},e.updateUVs=function(){},e._updateFontFamily=function(t){return t.useSystemFont?t.fontFamily||"Arial":t.font&&t.font._nativeAsset||"Arial"},e._calDynamicAtlas=function(t,e){if(!(1!==t.cacheMode||e.canvasSize.width<=0||e.canvasSize.height<=0)){var i=t.ttfSpriteFrame;JO.packToDynamicAtlas(t,i)}},e._resetDynamicAtlas=function(t){if(1===t.cacheMode){var e=t.ttfSpriteFrame;JO.deleteAtlasSpriteFrame(e),e._resetDynamicAtlasFrame()}},t}(),KG=cr.WHITE.clone(),QG=Uint16Array.from([0,1,2,1,3,2]),ZG=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.createData=function(t){var e=t.requestRenderData();e.dataLength=4,e.resize(4,6),t.textRenderData.quadCount=4;for(var i=e.chunk.vb,n=e.floatStride,r=[{u:0,v:1},{u:1,v:1},{u:0,v:0},{u:1,v:0}],s=3,a=0,o=e.dataLength;a1?1:r)<0?0:r;var s=(n=(n=n>1?1:n)<0?0:n)+(r=(r-=n)<0?0:r);s=s>1?1:s,this.updateUVs(t,n,s),this.updateVertexData(t,n,s),i.updateRenderData(t,e)}},e.updateUVs=function(t,e,i){var n=t.spriteFrame,r=t.renderData,s=r.chunk.vb,a=n.width,o=n.height,h=n.rect,u=0,l=0,c=0,f=0,_=0,d=0,p=0,m=0,g=0,y=0;n.isRotated()?(u=h.x/a,l=(h.y+h.width)/o,c=_=u,p=g=(h.x+h.height)/a,d=y=l,f=m=h.y/o):(u=h.x/a,l=(h.y+h.height)/o,c=p=u,_=g=(h.x+h.width)/a,f=d=l,m=y=h.y/o);var v=r.floatStride,b=3;switch(t.fillType){case 0:s[b]=c+(_-c)*e,s[b+1]=f+(d-f)*e,s[b+=v]=c+(_-c)*i,s[b+1]=f+(d-f)*i,s[b+=v]=p+(g-p)*e,s[b+1]=m+(y-m)*e,s[b+=v]=p+(g-p)*i,s[b+1]=m+(y-m)*i;break;case 1:s[b]=c+(p-c)*e,s[b+1]=f+(m-f)*e,s[b+=v]=_+(g-_)*e,s[b+1]=d+(y-d)*e,s[b+=v]=c+(p-c)*i,s[b+1]=f+(m-f)*i,s[b+=v]=_+(g-_)*i,s[b+1]=d+(y-d)*i;break;default:ht(2626)}},e.updateVertexData=function(t,e,i){var n=t.renderData.data,r=t.node._getUITransformComp(),s=r.width,a=r.height,o=r.anchorX*s,h=r.anchorY*a,u=-o,l=-h,c=s-o,f=a-h,_=0;switch(t.fillType){case 0:_=u+(c-u)*i,u+=(c-u)*e,c=_;break;case 1:_=l+(f-l)*i,l+=(f-l)*e,f=_;break;default:ht(2626)}n[0].x=u,n[0].y=l,n[1].x=c,n[1].y=l,n[2].x=u,n[2].y=f,n[3].x=c,n[3].y=f},e.createData=function(t){var e=t.requestRenderData();return e.dataLength=4,e.resize(4,6),e.chunk.setIndexBuffer(iH),e.data.forEach((function(t){t.z=0})),e},e.updateWorldVertexData=function(t,e){t.node.getWorldMatrix(eH);for(var i=t.renderData.floatStride,n=t.renderData.data,r=e.vb,s=0,a=0;a<4;a++){var o=n[a],h=o.x,u=o.y,l=eH.m03*h+eH.m07*u+eH.m15;l=l?1/l:1,r[s=a*i]=(eH.m00*h+eH.m04*u+eH.m12)*l,r[s+1]=(eH.m01*h+eH.m05*u+eH.m13)*l,r[s+2]=(eH.m02*h+eH.m06*u+eH.m14)*l}},e.fillBuffers=function(t){var e=t.renderData,i=e.chunk;(t._flagChangedVersion!==t.node.flagChangedVersion||e.vertDirty)&&(this.updateWorldVertexData(t,i),e.vertDirty=!1,t._flagChangedVersion=t.node.flagChangedVersion),i.bufferId;var n=i.vertexOffset,r=i.meshBuffer,s=i.meshBuffer.iData,a=r.indexOffset;s[a++]=n,s[a++]=n+1,s[a++]=n+2,s[a++]=n+2,s[a++]=n+1,s[a++]=n+3,r.indexOffset+=6},e.updateColor=function(t){for(var e=t.renderData,i=e.chunk.vb,n=e.floatStride,r=5,s=t.color,a=s.r/255,o=s.g/255,h=s.b/255,u=t.node._uiProps.opacity,l=0;l<4;l++)i[r]=a,i[r+1]=o,i[r+2]=h,i[r+3]=u,r+=n},t}(),rH=new nH,sH=2*Math.PI,aH=1e-6,oH=new Kr,hH=[new ds,new ds,new ds,new ds],uH=new Array(4),lH=new Array(8),cH=[new ds,new ds,new ds,new ds],fH=[new ds,new ds,new ds,new ds],_H=new ds,dH=[new ds,new ds,new ds,new ds],pH=null;function mH(t,e,i,n,r,s,a){var o=Math.sin(s);o=Math.abs(o)>aH?o:0;var h=Math.cos(s),u=0,l=0;if(0!==(h=Math.abs(h)>aH?h:0)){if(u=o/h,(t-r.x)*h>0){var c=r.y+u*(t-r.x);a[0].x=t,a[0].y=c}if((e-r.x)*h>0){var f=r.y+u*(e-r.x);a[2].x=e,a[2].y=f}}if(0!==o){if(l=h/o,(n-r.y)*o>0){var _=r.x+l*(n-r.y);a[3].x=_,a[3].y=n}if((i-r.y)*o>0){var d=r.x+l*(i-r.y);a[1].x=d,a[1].y=i}}}function gH(t){var e=t.node._getUITransformComp(),i=e.width,n=e.height,r=e.anchorX*i,s=e.anchorY*n,a=-r,o=-s,h=i-r,u=n-s,l=uH;l[0]=a,l[1]=o,l[2]=h,l[3]=u;var c=t.fillCenter,f=_H.x=Math.min(Math.max(0,c.x),1)*(h-a)+a,_=_H.y=Math.min(Math.max(0,c.y),1)*(u-o)+o;hH[0].x=hH[3].x=a,hH[1].x=hH[2].x=h,hH[0].y=hH[1].y=o,hH[2].y=hH[3].y=u,dH.forEach((function(t){ds.set(t,0,0)})),f!==l[0]&&ds.set(dH[0],3,0),f!==l[2]&&ds.set(dH[2],1,2),_!==l[1]&&ds.set(dH[1],0,1),_!==l[3]&&ds.set(dH[3],2,3)}function yH(t){var e=t.width,i=t.height,n=t.getRect(),r=0,s=0,a=0,o=0,h=lH;t.isRotated()?(r=n.x/e,s=(n.x+n.height)/e,a=n.y/i,o=(n.y+n.width)/i,h[0]=h[2]=r,h[4]=h[6]=s,h[3]=h[7]=o,h[1]=h[5]=a):(r=n.x/e,s=(n.x+n.width)/e,a=n.y/i,o=(n.y+n.height)/i,h[0]=h[4]=r,h[2]=h[6]=s,h[1]=h[3]=o,h[5]=h[7]=a)}function vH(t,e){var i=e.x-t.x,n=e.y-t.y;if(0===i&&0===n)return 0;if(0===i)return n>0?.5*Math.PI:1.5*Math.PI;var r=Math.atan(n/i);return i<0&&(r+=Math.PI),r}function bH(t,e,i,n,r){var s=uH,a=s[0],o=s[1],h=s[2],u=s[3];t[e].x=i.x,t[e].y=i.y,t[e+1].x=n.x,t[e+1].y=n.y,t[e+2].x=r.x,t[e+2].y=r.y,SH((i.x-a)/(h-a),(i.y-o)/(u-o),t,e),SH((n.x-a)/(h-a),(n.y-o)/(u-o),t,e+1),SH((r.x-a)/(h-a),(r.y-o)/(u-o),t,e+2)}function SH(t,e,i,n){var r=lH,s=r[0]+(r[2]-r[0])*t,a=r[4]+(r[6]-r[4])*t,o=r[1]+(r[3]-r[1])*t,h=r[5]+(r[7]-r[5])*t,u=i[n];u.u=s+(a-s)*e,u.v=o+(h-o)*e}for(var wH=function(){function t(){}var e=t.prototype;return e.createData=function(t){return t.requestRenderData()},e.updateRenderData=function(t){var e=t.spriteFrame;JO.packToDynamicAtlas(t,e),this.updateUVs(t);var i=t.renderData;if(i&&e){if(!i.vertDirty)return;var n=i.data,r=t.fillStart,s=t.fillRange;for(s<0&&(r+=s,s=-s);r>=1;)r-=1;for(;r<0;)r+=1;var a=(r*=sH)+(s*=sH);gH(t),yH(e),mH(uH[0],uH[2],uH[1],uH[3],_H,r,cH),mH(uH[0],uH[2],uH[1],uH[3],_H,r+s,fH);for(var o=0,h=0;h<4;++h){var u=dH[h];if(u)if(s>=sH)i.dataLength=o+3,bH(n,o,_H,hH[u.x],hH[u.y]),o+=3;else{var l=vH(_H,hH[u.x]),c=vH(_H,hH[u.y]);c=a||(l>=r?(i.dataLength=o+3,bH(n,o,_H,hH[u.x],c>=a?fH[h]:hH[u.y]),o+=3):c>r&&(c<=a?(i.dataLength=o+3,bH(n,o,_H,cH[h],hH[u.y]),o+=3):(i.dataLength=o+3,bH(n,o,_H,cH[h],fH[h]),o+=3))),l+=sH,c+=sH}}0===o&&(i.dataLength=0),i.resize(o,o),i.updateRenderData(t,e)}},e.createQuadIndices=function(t){pH=null,pH=new Uint16Array(t);for(var e=0,i=0;i1?1:p,m=Number.isNaN(m)||m>1?1:m,_=_<0?0:_,d=d<0?0:d,DH[0].x=-a,DH[0].y=-o,DH[1].x=u*p-a,DH[1].y=f*m-o,DH[2].x=DH[1].x+_,DH[2].y=DH[1].y+d,DH[3].x=r-a,DH[3].y=s-o;for(var g=0;g<4;g++)for(var y=0;y<4;y++){var v=4*g+y;v0||t.insetBottom>0||t.insetLeft>0||t.insetRight>0)?2:0}var HH=function(){function t(){}var e=t.prototype;return e.createData=function(t){return t.requestRenderData()},e.updateRenderData=function(t){var e=t.renderData;if(e){var i=t.spriteFrame;if(i&&e&&e.vertDirty){var n=t.node._getUITransformComp(),r=Math.abs(n.width),s=Math.abs(n.height),a=i.getRect(),o=i.insetLeft,h=i.insetRight,u=a.width-o-h,l=i.insetTop,c=i.insetBottom,f=a.height-l-c,_=r-o-h,d=s-l-c;_=_>0?_:0,d=d>0?d:0;var p=0===u?_:_/u,m=0===f?d:d/f,g=GH(i),y=Math.ceil(m+g),v=Math.ceil(p+g);e.dataLength=4*y*v,this.updateVerts(t,_,d,y,v),e.vertexCount!==y*v*4&&(t.renderEntity.colorDirty=!0),e.resize(y*v*4,y*v*6),e.updateRenderData(t,i)}}},e.createQuadIndices=function(t){if(t%6==0){var e=t/6;UH=new Uint16Array(t);for(var i=0,n=0;n1?1:s.width/(m+g),x=s.height/(v+b)>1?1:s.height/(v+b);o=y>0?Math.floor(1e3*e)/1e3%y==0?y:e%y:e,h=S>0?Math.floor(1e3*i)/1e3%S==0?S:i%S:i,zH.length=0,NH=Math.max(n+1,r+1);for(var T=0;T=r?f-d:C*y-d,zH[C].y=C>=n?_-p:C*S-p;else for(var D=0;D1&&D0?m*w-d+y*(D-1):m+e-d:D===r-1?zH[D].x=m*w-d+o+y*(D-2):D>=r&&(zH[D].x=Math.min(m+e+g,f)-d),0===D?zH[D].y=-p:1===D?zH[D].y=b*x-p:D>1&&D0?b*x-p+S*(D-1):b+i-p:D===n-1?zH[D].y=b*x-p+h+S*(D-2):D>=n&&(zH[D].y=Math.min(b+i+v,_)-p);for(var B=0,I=0,M=0,P=0,E=0;ES?i>=(A>0?H:H+1)*S?1:z%1:z;for(var W=0;Wy?e>=(A>0?W:W+1)*y?1:N%1:N,R?(0===A?(U[0]=OH.u,U[1]=OH.u,U[2]=OH.u+(kH.u-OH.u)*V,G[0]=MH.v,G[1]=MH.v+(PH.v-MH.v)*L,G[2]=MH.v):(0===H?(U[0]=IH.u,U[1]=IH.u,U[2]=OH.u):H0){var h=a.claimedTouchIdList.indexOf(n.getID());if(-1!==h){if(a._handleEventTouch(t),"touch-end"!==t.type&&"touch-cancel"!==t.type||(ve(a.claimedTouchIdList,h),t.preventSwallow||this._removeClaimedTouch(s+1,n.getID())),r=!1,!t.preventSwallow)break;t.preventSwallow=!1}}}return--this._inDispatchCount<=0&&this._updatePointerEventProcessorList(),r},e._removeClaimedTouch=function(t,e){for(var i=this._pointerEventProcessorList,n=i.length,r=t;re)for(;e0){for(var t=this._meshDataArray.length,e=0;e0){Xp(r.renderData,a);var h=r.renderData.getMeshBuffer();h&&h.setDirty()}if(i.length>0&&!t._static)for(var u=0;u0&&(this.autoMergeBatches(this._currComponent),this.resetRenderStates(),qH.sharedManager.exitMask())),e+=1}},e._screenSort=function(t,e){return t.node.siblingIndex-e.node.siblingIndex},e._releaseDescriptorSetCache=function(t){this._descriptorSetCache.releaseDescriptorSetCache(t)},e._createClearModel=function(){if(!this._maskClearModel){this._maskClearMtl=mT.get("default-clear-stencil"),this._maskClearModel=A.director.root.createModel(KM);var t=kF(DF),e=Wp.gfxDevice,i=e.createBuffer(new ud(10,1,4*t,t)),n=new Float32Array([-1,-1,0,1,-1,0,-1,1,0,1,1,0]);i.update(n);var r=e.createBuffer(new ud(6,1,12,2)),s=new Uint16Array([0,1,2,2,1,3]);r.update(s),this._maskModelMesh=new sO([i],DF,7,r),this._maskModelMesh.subMeshIdx=0,this._maskClearModel.initSubModel(0,this._maskModelMesh,this._maskClearMtl)}},e._insertMaskBatch=function(t){this.autoMergeBatches(this._currComponent),this.resetRenderStates(),this._createClearModel(),this._maskClearModel.node=this._maskClearModel.transform=t.node;var e=qH.sharedManager;e.pushMask(1);var i=e.clear(t),n=null,r=0,s=this._maskClearMtl;s&&(n=e.getStencilStage(i,s),r=e.getStencilHash(i));var a=this._maskClearModel,o=A.director.getTotalFrames();a&&(a.updateTransform(o),a.updateUBOs(o));for(var h=0;h=0;a--){var o=i[a],h=t[o];t.splice(o,1),this._localCachePool.free(h)}}},e.reset=function(){for(var t=this._localDescriptorSetCache,e=t.length,i=0;i>>0},t.getLayerIndex=function(t){void 0===t&&(t=0);var e=0;return this.indexMap.has(t)?e=this.indexMap.get(t):ht(2105),e},t.getLayerIndexByName=function(t){var e=this.getLayerByName(t);return this.getLayerIndex(e)},t.getLayerName=function(t){void 0===t&&(t=0);var e="";return this.nameMap.has(t)?e=this.nameMap.get(t):ht(2105),e},t.getLayerByName=function(t){for(var e=this.nameMap.size,i=this.nameMap.keys(),n=0,r=0;r=i.length||i[e].length===t.length&&(i[e]=t.slice(0),this._uploadSubMeshShapesWeights(e))},e.setWeight=function(t,e,i){var n=this._subMeshShapesWeights;if(!(e>=n.length)){var r=n[e];i>=r.length||(r[i]=t,this._uploadSubMeshShapesWeights(e))}},e.setInstancedAttribute=function(t,e){if(this.model)for(var i=this.model.subModels,n=0;n0&&this.bindposes.length>0},n(e,[{key:"joints",get:function(){return this._joints},set:function(t){this._joints=t}},{key:"bindposes",get:function(){return this._bindposes},set:function(t){this._bindposes=t}},{key:"inverseBindposes",get:function(){if(!this._invBindposes){this._invBindposes=[];for(var t=0;tqT.LEVEL_1},set:function(t){this._csmLevel=t?qT.LEVEL_4:qT.LEVEL_1,this._light&&(this._light.csmLevel=this._csmLevel,this._light.csmNeedUpdate=!0)}},{key:"csmLayerLambda",get:function(){return this._csmLayerLambda},set:function(t){this._csmLayerLambda=t,this._light&&(this._light.csmLayerLambda=this._csmLayerLambda,this._light.csmNeedUpdate=!0)}},{key:"csmOptimizationMode",get:function(){return this._csmOptimizationMode},set:function(t){this._csmOptimizationMode=t,this._light&&(this._light.csmOptimizationMode=this._csmOptimizationMode)}},{key:"shadowFixedArea",get:function(){return this._shadowFixedArea},set:function(t){this._shadowFixedArea=t,this._light&&(this._light.shadowFixedArea=this._shadowFixedArea)}},{key:"shadowNear",get:function(){return this._shadowNear},set:function(t){this._shadowNear=t,this._light&&(this._light.shadowNear=this._shadowNear)}},{key:"shadowFar",get:function(){return this._shadowFar},set:function(t){this._shadowFar=Math.min(t,JT.MAX_FAR),this._light&&(this._light.shadowFar=this._shadowFar)}},{key:"shadowOrthoSize",get:function(){return this._shadowOrthoSize},set:function(t){this._shadowOrthoSize=t,this._light&&(this._light.shadowOrthoSize=this._shadowOrthoSize)}},{key:"csmAdvancedOptions",get:function(){return this._csmAdvancedOptions},set:function(t){this._csmAdvancedOptions=t}},{key:"csmLayersTransition",get:function(){return this._csmLayersTransition},set:function(t){this._csmLayersTransition=t,this._light&&(this._light.csmLayersTransition=t)}},{key:"csmTransitionRange",get:function(){return this._csmTransitionRange},set:function(t){this._csmTransitionRange=t,this._light&&(this._light.csmTransitionRange=t)}}]),e}(YX),wq=zh(Sq.prototype,"_illuminanceHDR",[JX,Fj],(function(){return 65e3})),xq=zh(Sq.prototype,"_illuminanceLDR",[KX],(function(){return 65e3*NM.standardExposureValue})),Tq=zh(Sq.prototype,"_shadowEnabled",[KX],(function(){return!1})),Aq=zh(Sq.prototype,"_shadowPcf",[KX],(function(){return jT.HARD})),Cq=zh(Sq.prototype,"_shadowBias",[KX],(function(){return 1e-5})),Dq=zh(Sq.prototype,"_shadowNormalBias",[KX],(function(){return 0})),Bq=zh(Sq.prototype,"_shadowSaturation",[KX],(function(){return 1})),Iq=zh(Sq.prototype,"_shadowDistance",[KX],(function(){return 50})),Mq=zh(Sq.prototype,"_shadowInvisibleOcclusionRange",[KX],(function(){return 200})),Pq=zh(Sq.prototype,"_csmLevel",[KX],(function(){return qT.LEVEL_4})),Eq=zh(Sq.prototype,"_csmLayerLambda",[KX],(function(){return.75})),Oq=zh(Sq.prototype,"_csmOptimizationMode",[KX],(function(){return XT.RemoveDuplicates})),kq=zh(Sq.prototype,"_csmAdvancedOptions",[KX],(function(){return!1})),Rq=zh(Sq.prototype,"_csmLayersTransition",[KX],(function(){return!1})),Fq=zh(Sq.prototype,"_csmTransitionRange",[KX],(function(){return.05})),Lq=zh(Sq.prototype,"_shadowFixedArea",[KX],(function(){return!1})),Vq=zh(Sq.prototype,"_shadowNear",[KX],(function(){return.1})),Nq=zh(Sq.prototype,"_shadowFar",[KX],(function(){return 10})),zq=zh(Sq.prototype,"_shadowOrthoSize",[KX],(function(){return 5})),v(Sq.prototype,"illuminance",[Lj],Object.getOwnPropertyDescriptor(Sq.prototype,"illuminance"),Sq.prototype),v(Sq.prototype,"shadowEnabled",[Vj,Nj],Object.getOwnPropertyDescriptor(Sq.prototype,"shadowEnabled"),Sq.prototype),v(Sq.prototype,"shadowPcf",[zj,Uj],Object.getOwnPropertyDescriptor(Sq.prototype,"shadowPcf"),Sq.prototype),v(Sq.prototype,"shadowBias",[Gj,Hj],Object.getOwnPropertyDescriptor(Sq.prototype,"shadowBias"),Sq.prototype),v(Sq.prototype,"shadowNormalBias",[Wj,jj],Object.getOwnPropertyDescriptor(Sq.prototype,"shadowNormalBias"),Sq.prototype),v(Sq.prototype,"shadowSaturation",[qj,Xj],Object.getOwnPropertyDescriptor(Sq.prototype,"shadowSaturation"),Sq.prototype),v(Sq.prototype,"shadowDistance",[Yj,Jj],Object.getOwnPropertyDescriptor(Sq.prototype,"shadowDistance"),Sq.prototype),v(Sq.prototype,"shadowInvisibleOcclusionRange",[Kj,Qj],Object.getOwnPropertyDescriptor(Sq.prototype,"shadowInvisibleOcclusionRange"),Sq.prototype),v(Sq.prototype,"csmLevel",[Zj,$j],Object.getOwnPropertyDescriptor(Sq.prototype,"csmLevel"),Sq.prototype),v(Sq.prototype,"enableCSM",[tq,eq],Object.getOwnPropertyDescriptor(Sq.prototype,"enableCSM"),Sq.prototype),v(Sq.prototype,"csmLayerLambda",[iq,nq],Object.getOwnPropertyDescriptor(Sq.prototype,"csmLayerLambda"),Sq.prototype),v(Sq.prototype,"csmOptimizationMode",[rq,sq],Object.getOwnPropertyDescriptor(Sq.prototype,"csmOptimizationMode"),Sq.prototype),v(Sq.prototype,"shadowFixedArea",[aq,oq],Object.getOwnPropertyDescriptor(Sq.prototype,"shadowFixedArea"),Sq.prototype),v(Sq.prototype,"shadowNear",[hq,uq],Object.getOwnPropertyDescriptor(Sq.prototype,"shadowNear"),Sq.prototype),v(Sq.prototype,"shadowFar",[lq,cq],Object.getOwnPropertyDescriptor(Sq.prototype,"shadowFar"),Sq.prototype),v(Sq.prototype,"shadowOrthoSize",[fq,_q],Object.getOwnPropertyDescriptor(Sq.prototype,"shadowOrthoSize"),Sq.prototype),v(Sq.prototype,"csmAdvancedOptions",[dq,pq],Object.getOwnPropertyDescriptor(Sq.prototype,"csmAdvancedOptions"),Sq.prototype),v(Sq.prototype,"csmLayersTransition",[mq,gq],Object.getOwnPropertyDescriptor(Sq.prototype,"csmLayersTransition"),Sq.prototype),v(Sq.prototype,"csmTransitionRange",[yq,vq],Object.getOwnPropertyDescriptor(Sq.prototype,"csmTransitionRange"),Sq.prototype),bq=Sq))||bq)),tY=t("af",(Uq=Kh("cc.SphereLight"),Gq=lu("_luminance"),Hq=Ou(li),Wq=Ou(li),jq=Ou(qX),qq=Ou(ci),Xq=Ou(ci),Uq((Jq=function(t){function e(){var e;return(e=t.call(this)||this)._size=Kq&&Kq(),e._luminanceHDR=Qq&&Qq(),e._luminanceLDR=Zq&&Zq(),e._term=$q&&$q(),e._range=tX&&tX(),e._lightType=oP,e}return s(e,t),e.prototype._createLight=function(){t.prototype._createLight.call(this),this._type=1,this.size=this._size,this.range=this._range,this._light&&(this._light.luminanceHDR=this._luminanceHDR,this._light.luminanceLDR=this._luminanceLDR)},n(e,[{key:"luminousFlux",get:function(){return rb().isHDR?this._luminanceHDR*iP(this._size):this._luminanceLDR},set:function(t){var e=0;rb().isHDR?(this._luminanceHDR=t/iP(this._size),e=this._luminanceHDR):(this._luminanceLDR=t,e=this._luminanceLDR),this._light&&(this._light.luminance=e)}},{key:"luminance",get:function(){return rb().isHDR?this._luminanceHDR:this._luminanceLDR},set:function(t){rb().isHDR?(this._luminanceHDR=t,this._light&&(this._light.luminanceHDR=this._luminanceHDR)):(this._luminanceLDR=t,this._light&&(this._light.luminanceLDR=this._luminanceLDR))}},{key:"term",get:function(){return this._term},set:function(t){this._term=t}},{key:"size",get:function(){return this._size},set:function(t){this._size=t,this._light&&(this._light.size=t)}},{key:"range",get:function(){return this._range},set:function(t){this._range=t,this._light&&(this._light.range=t)}}]),e}(YX),Kq=zh(Jq.prototype,"_size",[uu],(function(){return.15})),Qq=zh(Jq.prototype,"_luminanceHDR",[uu,Gq],(function(){return 1700/iP(.15)})),Zq=zh(Jq.prototype,"_luminanceLDR",[uu],(function(){return 1700/iP(.15)*NM.standardExposureValue*NM.standardLightMeterScale})),$q=zh(Jq.prototype,"_term",[uu],(function(){return qX.LUMINOUS_FLUX})),tX=zh(Jq.prototype,"_range",[uu],(function(){return 1})),v(Jq.prototype,"luminousFlux",[Hq],Object.getOwnPropertyDescriptor(Jq.prototype,"luminousFlux"),Jq.prototype),v(Jq.prototype,"luminance",[Wq],Object.getOwnPropertyDescriptor(Jq.prototype,"luminance"),Jq.prototype),v(Jq.prototype,"term",[jq],Object.getOwnPropertyDescriptor(Jq.prototype,"term"),Jq.prototype),v(Jq.prototype,"size",[qq],Object.getOwnPropertyDescriptor(Jq.prototype,"size"),Jq.prototype),v(Jq.prototype,"range",[Xq],Object.getOwnPropertyDescriptor(Jq.prototype,"range"),Jq.prototype),Yq=Jq))||Yq)),eY=Ou,iY=uu,nY=lu,rY=tu,sY=t("ag",(eX=Kh("cc.SpotLight"),iX=nY("_luminance"),nX=eY(qX),rX=eY(ci),sX=rY({group:{name:"DynamicShadowSettings",displayOrder:1}}),aX=eY(fi),oX=rY({group:{name:"DynamicShadowSettings",displayOrder:2}}),hX=eY(jT),uX=rY({group:{name:"DynamicShadowSettings",displayOrder:3}}),lX=eY(ci),cX=rY({group:{name:"DynamicShadowSettings",displayOrder:4}}),fX=eY(ci),eX((dX=function(t){function e(){var e;return(e=t.call(this)||this)._size=pX&&pX(),e._luminanceHDR=mX&&mX(),e._luminanceLDR=gX&&gX(),e._term=yX&&yX(),e._range=vX&&vX(),e._spotAngle=bX&&bX(),e._angleAttenuationStrength=SX&&SX(),e._shadowEnabled=wX&&wX(),e._shadowPcf=xX&&xX(),e._shadowBias=TX&&TX(),e._shadowNormalBias=AX&&AX(),e._lightType=dP,e}return s(e,t),e.prototype._createLight=function(){if(t.prototype._createLight.call(this),this._type=2,this.size=this._size,this.range=this._range,this.spotAngle=this._spotAngle,this.angleAttenuationStrength=this._angleAttenuationStrength,this._light){var e=this._light;e.luminanceHDR=this._luminanceHDR,e.luminanceLDR=this._luminanceLDR,e.shadowEnabled=this._shadowEnabled,e.shadowPcf=this._shadowPcf,e.shadowBias=this._shadowBias,e.shadowNormalBias=this._shadowNormalBias}},n(e,[{key:"luminousFlux",get:function(){return rb().isHDR?this._luminanceHDR*iP(this._size):this._luminanceLDR},set:function(t){var e=0;rb().isHDR?(this._luminanceHDR=t/iP(this._size),e=this._luminanceHDR):(this._luminanceLDR=t,e=this._luminanceLDR),this._light&&(this._light.luminance=e)}},{key:"luminance",get:function(){return rb().isHDR?this._luminanceHDR:this._luminanceLDR},set:function(t){rb().isHDR?(this._luminanceHDR=t,this._light&&(this._light.luminanceHDR=this._luminanceHDR)):(this._luminanceLDR=t,this._light&&(this._light.luminanceLDR=this._luminanceLDR))}},{key:"term",get:function(){return this._term},set:function(t){this._term=t}},{key:"size",get:function(){return this._size},set:function(t){this._size=t,this._light&&(this._light.size=t)}},{key:"range",get:function(){return this._range},set:function(t){this._range=t,this._light&&(this._light.range=t)}},{key:"spotAngle",get:function(){return this._spotAngle},set:function(t){this._spotAngle=t,this._light&&(this._light.spotAngle=nn(t))}},{key:"angleAttenuationStrength",get:function(){return this._angleAttenuationStrength},set:function(t){this._angleAttenuationStrength=t,this._light&&(this._light.angleAttenuationStrength=t)}},{key:"shadowEnabled",get:function(){return this._shadowEnabled},set:function(t){this._shadowEnabled=t,this._light&&(this._light.shadowEnabled=t)}},{key:"shadowPcf",get:function(){return this._shadowPcf},set:function(t){this._shadowPcf=t,this._light&&(this._light.shadowPcf=t)}},{key:"shadowBias",get:function(){return this._shadowBias},set:function(t){this._shadowBias=t,this._light&&(this._light.shadowBias=t)}},{key:"shadowNormalBias",get:function(){return this._shadowNormalBias},set:function(t){this._shadowNormalBias=t,this._light&&(this._light.shadowNormalBias=t)}}]),e}(YX),pX=zh(dX.prototype,"_size",[iY],(function(){return.15})),mX=zh(dX.prototype,"_luminanceHDR",[iY,iX],(function(){return 1700/iP(.15)})),gX=zh(dX.prototype,"_luminanceLDR",[iY],(function(){return 1700/iP(.15)*NM.standardExposureValue*NM.standardLightMeterScale})),yX=zh(dX.prototype,"_term",[iY],(function(){return qX.LUMINOUS_FLUX})),vX=zh(dX.prototype,"_range",[iY],(function(){return 1})),bX=zh(dX.prototype,"_spotAngle",[iY],(function(){return 60})),SX=zh(dX.prototype,"_angleAttenuationStrength",[iY],(function(){return 0})),wX=zh(dX.prototype,"_shadowEnabled",[iY],(function(){return!1})),xX=zh(dX.prototype,"_shadowPcf",[iY],(function(){return jT.HARD})),TX=zh(dX.prototype,"_shadowBias",[iY],(function(){return 1e-5})),AX=zh(dX.prototype,"_shadowNormalBias",[iY],(function(){return 0})),v(dX.prototype,"term",[nX],Object.getOwnPropertyDescriptor(dX.prototype,"term"),dX.prototype),v(dX.prototype,"size",[rX],Object.getOwnPropertyDescriptor(dX.prototype,"size"),dX.prototype),v(dX.prototype,"shadowEnabled",[sX,aX],Object.getOwnPropertyDescriptor(dX.prototype,"shadowEnabled"),dX.prototype),v(dX.prototype,"shadowPcf",[oX,hX],Object.getOwnPropertyDescriptor(dX.prototype,"shadowPcf"),dX.prototype),v(dX.prototype,"shadowBias",[uX,lX],Object.getOwnPropertyDescriptor(dX.prototype,"shadowBias"),dX.prototype),v(dX.prototype,"shadowNormalBias",[cX,fX],Object.getOwnPropertyDescriptor(dX.prototype,"shadowNormalBias"),dX.prototype),_X=dX))||_X));t("ah",(CX=Kh("cc.PointLight"),DX=lu("_luminance"),BX=Ou(li),IX=Ou(li),MX=Ou(qX),PX=Ou(ci),CX((OX=function(t){function e(){var e;return(e=t.call(this)||this)._luminanceHDR=kX&&kX(),e._luminanceLDR=RX&&RX(),e._term=FX&&FX(),e._range=LX&&LX(),e._lightType=pP,e}return s(e,t),e.prototype._createLight=function(){t.prototype._createLight.call(this),this._type=3,this.range=this._range,this._light&&(this._light.luminanceHDR=this._luminanceHDR,this._light.luminanceLDR=this._luminanceLDR)},n(e,[{key:"luminousFlux",get:function(){return rb().isHDR?this._luminanceHDR*iP(1):this._luminanceLDR},set:function(t){var e=0;rb().isHDR?(this._luminanceHDR=t/iP(1),e=this._luminanceHDR):(this._luminanceLDR=t,e=this._luminanceLDR),this._light&&(this._light.luminance=e)}},{key:"luminance",get:function(){return rb().isHDR?this._luminanceHDR:this._luminanceLDR},set:function(t){rb().isHDR?(this._luminanceHDR=t,this._light&&(this._light.luminanceHDR=this._luminanceHDR)):(this._luminanceLDR=t,this._light&&(this._light.luminanceLDR=this._luminanceLDR))}},{key:"term",get:function(){return this._term},set:function(t){this._term=t}},{key:"range",get:function(){return this._range},set:function(t){this._range=t,this._light&&(this._light.range=t)}}]),e}(YX),kX=zh(OX.prototype,"_luminanceHDR",[uu,DX],(function(){return 1700/iP(.15)})),RX=zh(OX.prototype,"_luminanceLDR",[uu],(function(){return 1700/iP(.15)*NM.standardExposureValue*NM.standardLightMeterScale})),FX=zh(OX.prototype,"_term",[uu],(function(){return qX.LUMINOUS_FLUX})),LX=zh(OX.prototype,"_range",[uu],(function(){return 1})),v(OX.prototype,"luminousFlux",[BX],Object.getOwnPropertyDescriptor(OX.prototype,"luminousFlux"),OX.prototype),v(OX.prototype,"luminance",[IX],Object.getOwnPropertyDescriptor(OX.prototype,"luminance"),OX.prototype),v(OX.prototype,"term",[MX],Object.getOwnPropertyDescriptor(OX.prototype,"term"),OX.prototype),v(OX.prototype,"range",[PX],Object.getOwnPropertyDescriptor(OX.prototype,"range"),OX.prototype),EX=OX))||EX)),t("ai",(VX=Kh("cc.RangedDirectionalLight"),NX=lu("_illuminance"),zX=Ou(li),VX((GX=function(t){function e(){var e;return(e=t.call(this)||this)._illuminanceHDR=HX&&HX(),e._illuminanceLDR=WX&&WX(),e._lightType=gP,e}return s(e,t),e.prototype._createLight=function(){t.prototype._createLight.call(this),this._type=4,this._light&&(this._light.illuminanceHDR=this._illuminanceHDR,this._light.illuminanceLDR=this._illuminanceLDR)},n(e,[{key:"illuminance",get:function(){return rb().isHDR?this._illuminanceHDR:this._illuminanceLDR},set:function(t){rb().isHDR?(this._illuminanceHDR=t,this._light&&(this._light.illuminanceHDR=this._illuminanceHDR)):(this._illuminanceLDR=t,this._light&&(this._light.illuminanceLDR=this._illuminanceLDR))}}]),e}(YX),HX=zh(GX.prototype,"_illuminanceHDR",[tu,NX],(function(){return 65e3})),WX=zh(GX.prototype,"_illuminanceLDR",[uu],(function(){return 65e3*NM.standardExposureValue})),v(GX.prototype,"illuminance",[zX],Object.getOwnPropertyDescriptor(GX.prototype,"illuminance"),GX.prototype),UX=GX))||UX)),A.LightComponent=YX,le(YX,"cc.LightComponent"),A.DirectionalLightComponent=$X,le($X,"cc.DirectionalLightComponent"),A.SphereLightComponent=tY,le(tY,"cc.SphereLightComponent"),A.SpotLightComponent=sY,le(sY,"cc.SpotLightComponent"),pt(sY.prototype,"SpotLight.prototype",[{name:"luminousPower",newName:"luminousFlux",customGetter:function(){return this.luminousFlux},customSetter:function(t){this.luminousFlux=t}}]),pt(tY.prototype,"SphereLight.prototype",[{name:"luminousPower",newName:"luminousFlux",customGetter:function(){return this.luminousFlux},customSetter:function(t){this.luminousFlux=t}}]),pt(YX.PhotometricTerm,"Light.PhotometricTerm",[{name:"LUMINOUS_POWER",newName:"LUMINOUS_FLUX"}]);var aY=Symbol("BakeNodeCurves"),oY=t("g2",function(){function t(){}return t.getOrExtract=function(e){var i=t.pool.get(e);if(!i||i.samples!==e.sample){i&&A.director.root.dataPoolManager.releaseAnimationClip(e);var n=Math.ceil(e.sample*e.duration)+1,r=e.sample;i=e[aY](0,r,n),t.pool.set(e,i)}return i},t.destroy=function(e){t.pool.delete(e)},t}());oY.pool=new Map;var hY=new Kr;function uY(t,e,i){for(Kr.identity(i);t!==e;)Kr.fromRTS(hY,t.rotation,t.position,t.scale),Kr.multiply(i,hY,i),t=t.parent;return i}var lY=new md(1,1,0,2,2,2),cY=function(t,e,i){t[e+0]=i.m00,t[e+1]=i.m01,t[e+2]=i.m02,t[e+3]=i.m12,t[e+4]=i.m04,t[e+5]=i.m05,t[e+6]=i.m06,t[e+7]=i.m13,t[e+8]=i.m08,t[e+9]=i.m09,t[e+10]=i.m10,t[e+11]=i.m14};function fY(t){return 2&t.getFormatFeatures(44)?44:35}function _Y(t,e){var i=4/Math.sqrt(e);return 12*Math.ceil(Math.max(480*i,t)/12)}new kr,new kr,new ir,new kr,new ir;var dY=new ir,pY=new ir,mY=new ir,gY=new ir,yY=new Kr,vY=new Kr,bY=new gh,SY=Number.MAX_SAFE_INTEGER,wY=function(){function t(t){this._device=void 0,this._pool=void 0,this._textureBuffers=new Map,this._formatSize=void 0,this._pixelsPerJoint=void 0,this._customPool=void 0,this._chunkIdxMap=new Map,this._device=t;var e=fY(this._device);this._formatSize=ip[e].size,this._pixelsPerJoint=48/this._formatSize,this._pool=new sN(t),this._pool.initialize({format:e,roundUpFn:_Y}),this._customPool=new sN(t),this._customPool.initialize({format:e,roundUpFn:_Y})}var e=t.prototype;return e.clear=function(){this._pool.destroy(),this._textureBuffers.clear()},e.registerCustomTextureLayouts=function(t){for(var e=0;e0&&t.refCount--,!t.refCount&&t.readyToBeDeleted){var e=t.skeletonHash^t.clipHash;(void 0!==this._chunkIdxMap.get(e)?this._customPool:this._pool).free(t.handle),this._textureBuffers.get(e)===t&&this._textureBuffers.delete(e)}},e.releaseSkeleton=function(t){for(var e=this._textureBuffers.values(),i=e.next();!i.done;){var n=i.value;n.skeletonHash===t.hash&&(n.readyToBeDeleted=!0,n.refCount?this._textureBuffers.delete(n.skeletonHash^n.clipHash):this.releaseHandle(n)),i=e.next()}},e.releaseAnimationClip=function(t){for(var e=this._textureBuffers.values(),i=e.next();!i.done;){var n=i.value;n.clipHash===t.hash&&(n.readyToBeDeleted=!0,n.refCount?this._textureBuffers.delete(n.skeletonHash^n.clipHash):this.releaseHandle(n)),i=e.next()}},e._createAnimInfos=function(t,e,i){for(var n=[],r=t.joints,s=t.bindposes,a=r.length,o=oY.getOrExtract(e),h=0;h0;){t=TY[--i],TY[i]=null;var r=t.node;Kr.fromRTS(t.local,r.rotation,r.position,r.scale),n=Kr.multiply(t.world,n,t.local)}return n}function DY(t,e){for(var i,n=null,r=0;t!==e;){var s=t.uuid;if(AY.has(s)){n=AY.get(s);break}n={node:t,local:new Kr,world:new Kr,stamp:-1,parent:null},AY.set(s,n),TY[r++]=n,t=t.parent,n=null}for(;r>0;)i=TY[--r],TY[r]=null,i.parent=n,n=i;return n}function BY(t){for(var e=AY.get(t.uuid)||null;e;)AY.delete(e.node.uuid),e=e.parent}var IY=[{name:"CC_USE_SKINNING",value:!0},{name:"CC_USE_REAL_TIME_JOINT_TEXTURE",value:!1}],MY=[{name:"CC_USE_SKINNING",value:!0},{name:"CC_USE_REAL_TIME_JOINT_TEXTURE",value:!0}];function PY(t,e,i,n){for(var r=0;r=0&&(e.push(r),t.push(a))}}var EY=new ir,OY=new ir,kY=new ir,RY=new ir,FY=new Kr,LY=new gh,VY=function(){this._format=44,this._textures=[],this._buffers=[]};VY.WIDTH=256,VY.HEIGHT=3;var NY,zY,UY,GY,HY,WY,jY,qY,XY,YY,JY,KY,QY,ZY,$Y,tJ,eJ,iJ,nJ,rJ,sJ,aJ,oJ,hJ,uJ,lJ,cJ,fJ,_J,dJ,pJ,mJ,gJ=function(t){function e(){var e;return(e=t.call(this)||this)._buffers=[],e._dataArray=[],e._joints=[],e._bufferIndices=null,e._realTimeJointTexture=new VY,e._realTimeTextureMode=!1,e.type=1,e}s(e,t);var i=e.prototype;return i.destroy=function(){if(this.bindSkeleton(),this._buffers.length){for(var e=0;e=0?a.instancedAttributeBlock.views[r][0]=i.data[0]:n=!0}return n&&i.dirty&&(i.buffer.update(i.data),i.dirty=!1),!0},i.getMacroPatches=function(e){var i=t.prototype.getMacroPatches.call(this,e);return i?i.concat(yJ):yJ},i.uploadAnimation=function(t){if(this._skeleton&&this._mesh&&this.uploadedAnim!==t){this.uploadedAnim=t;var e=this._dataPoolManager,i=null;t?(i=e.jointTexturePool.getSequencePoseTexture(this._skeleton,t,this._mesh,this.transform),this._jointsMedium.boundsInfo=i&&i.bounds.get(this._mesh.hash),this._modelBounds=null):(i=e.jointTexturePool.getDefaultPoseTexture(this._skeleton,this._mesh,this.transform),this._jointsMedium.boundsInfo=null,this._modelBounds=i&&i.bounds.get(this._mesh.hash)[0]),this._applyJointTexture(i)}},i._applyJointTexture=function(t){void 0===t&&(t=null);var e=this._jointsMedium.texture;if(e&&e!==t&&this._dataPoolManager.jointTexturePool.releaseHandle(e),this._jointsMedium.texture=t,t){var i=this._jointsMedium,n=i.buffer,r=i.jointTextureInfo;r[0]=t.handle.texture.width,r[1]=this._skeleton.joints.length,r[2]=t.pixelOffset+.1,r[3]=1/r[0],this.updateInstancedJointTextureInfo(),n&&n.update(r);for(var s=t.handle.texture,a=0;a=0&&s.length>0){var a=s[n];a[0]=i.data[0],a[1]=e[1],a[2]=e[2]}}},e}(KW),bJ=t("aj",(NY=Kh("cc.SkinnedMeshRenderer"),zY=Zh(100),UY=Ou(kj),GY=Ou(eb),HY=Ou(kj),WY=Ou(eb),NY(jY=zY((qY=function(t){function e(){var e;return(e=t.call(this)||this)._skeleton=XY&&XY(),e._skinningRoot=YY&&YY(),e._clip=null,e.associatedAnimation=null,e._modelType=vJ,e}s(e,t);var i=e.prototype;return i.onLoad=function(){t.prototype.onLoad.call(this),this._tryBindAnimation()},i.onDestroy=function(){this.associatedAnimation&&(this.associatedAnimation.notifySkinnedMeshRemoved(this),this.associatedAnimation),t.prototype.onDestroy.call(this)},i.uploadAnimation=function(t){this._clip=t,this.model&&this.model.uploadAnimation&&this.model.uploadAnimation(t)},i.setUseBakedAnimation=function(t,e){void 0===t&&(t=!0),void 0===e&&(e=!1);var i=t?vJ:gJ;(e||this._modelType!==i)&&(this._modelType=i,this._model&&(A.director.root.destroyModel(this._model),this._model=null,this._models.length=0,this._updateModels(),this._updateCastShadow(),this._updateReceiveShadow(),this._updateUseLightProbe(),this.enabledInHierarchy&&this._attachToScene()))},i.setSharedMaterial=function(e,i){t.prototype.setSharedMaterial.call(this,e,i),this._modelType===gJ&&this.getMaterialInstance(i)},i._updateModelParams=function(){this._update(),t.prototype._updateModelParams.call(this)},i._tryBindAnimation=function(){var t=this._skinningRoot;if(t){for(var e=!1,i=this.node;i;i=i.parent)if(i===t){e=!0;break}if(e){var n=t.getComponent("cc.SkeletalAnimation");n&&n.enabledInHierarchy?n.notifySkinnedMeshAdded(this):this.setUseBakedAnimation(!1)}}},i._update=function(){this.model&&(this.model.bindSkeleton(this._skeleton,this._skinningRoot,this._mesh),this.model.uploadAnimation&&this.model.uploadAnimation(this._clip))},n(e,[{key:"skeleton",get:function(){return this._skeleton},set:function(t){t!==this._skeleton&&(this._skeleton=t,this._update())}},{key:"skinningRoot",get:function(){return this._skinningRoot},set:function(t){t!==this._skinningRoot&&(this._skinningRoot=t,this._tryBindAnimation(),this._update())}},{key:"model",get:function(){return this._model}}]),e}(mj),XY=zh(qY.prototype,"_skeleton",[UY],(function(){return null})),YY=zh(qY.prototype,"_skinningRoot",[GY],(function(){return null})),v(qY.prototype,"skeleton",[HY],Object.getOwnPropertyDescriptor(qY.prototype,"skeleton"),qY.prototype),v(qY.prototype,"skinningRoot",[WY],Object.getOwnPropertyDescriptor(qY.prototype,"skinningRoot"),qY.prototype),jY=qY))||jY)||jY)),SJ=new Cd("a_batch_id",11),wJ=new Cd("a_batch_uv",21),xJ=ip[SJ.format].size+ip[wJ.format].size,TJ=t("al",(JY=Kh("cc.SkinnedMeshUnit"),KY=Ou(Pk),QY=Ou(kj),ZY=Ou(GT),$Y=Ou(bJ),JY((eJ=function(){function t(){this.mesh=iJ&&iJ(),this.skeleton=nJ&&nJ(),this.material=rJ&&rJ(),this._localTransform=sJ&&sJ(),this._offset=aJ&&aJ(),this._size=oJ&&oJ()}return n(t,[{key:"offset",get:function(){return this._offset},set:function(t){ds.copy(this._offset,t)}},{key:"size",get:function(){return this._size},set:function(t){ds.copy(this._size,t)}},{key:"copyFrom",get:function(){return null},set:function(t){t&&(this.mesh=t.mesh,this.skeleton=t.skeleton,this.material=t.getSharedMaterial(0),t.skinningRoot&&uY(t.node,t.skinningRoot,this._localTransform))}}]),t}(),iJ=zh(eJ.prototype,"mesh",[KY],(function(){return null})),nJ=zh(eJ.prototype,"skeleton",[QY],(function(){return null})),rJ=zh(eJ.prototype,"material",[ZY],(function(){return null})),sJ=zh(eJ.prototype,"_localTransform",[uu],(function(){return new Kr})),aJ=zh(eJ.prototype,"_offset",[uu],(function(){return new ds(0,0)})),oJ=zh(eJ.prototype,"_size",[uu],(function(){return new ds(1,1)})),v(eJ.prototype,"copyFrom",[$Y],Object.getOwnPropertyDescriptor(eJ.prototype,"copyFrom"),eJ.prototype),tJ=eJ))||tJ)),AJ=new Kr;new Kr;var CJ,DJ,BJ,IJ,MJ,PJ,EJ,OJ,kJ,RJ,FJ,LJ,VJ,NJ,zJ,UJ,GJ,HJ=new ir,WJ=t("ak",(hJ=Kh("cc.SkinnedMeshBatchRenderer"),uJ=Zh(100),lJ=Ou([_i]),cJ=Ou([TJ]),hJ(fJ=uJ((_J=function(t){function e(){var e;return(e=t.call(this)||this).atlasSize=dJ&&dJ(),e.batchableTextureNames=pJ&&pJ(),e.units=mJ&&mJ(),e._textures={},e._batchMaterial=null,e}s(e,t);var i=e.prototype;return i.onLoad=function(){t.prototype.onLoad.call(this),this.cook()},i.onDestroy=function(){for(var e in this._textures)this._textures[e].destroy();this._textures={},this._mesh&&(this._mesh.destroy(),this._mesh=null),t.prototype.onDestroy.call(this)},i._onMaterialModified=function(e){this.cookMaterials(),t.prototype._onMaterialModified.call(this,e,this.getMaterialInstance(e))},i.cook=function(){this.cookMaterials(),this.cookSkeletons(),this.cookMeshes()},i.cookMaterials=function(){var t=this;this._batchMaterial||(this._batchMaterial=this.getSharedMaterial(0));var e=this.getMaterialInstance(0);if(e&&this._batchMaterial&&this._batchMaterial.effectAsset){e.copy(this._batchMaterial),this.resizeAtlases();for(var i=e.effectAsset.techniques[e.technique],n=function(n){var r=i.passes[n];if(!r.properties)return 1;var s=function(i){if(r.properties[i].type>=26){var s=null;t.batchableTextureNames.find((function(t){return t===i}))?((s=t._textures[i])||(s=t.createTexture(i)),t.cookTextures(s,i,n)):t.units.some((function(t){return s=t.material&&t.material.getProperty(i,n)})),s&&e.setProperty(i,s,n)}else{for(var a=[],o=0;o=0)return 1;t.push(i),e.push(Kr.multiply(new Kr,r.bindposes[a]||Kr.IDENTITY,AJ))},a=0;at[i]?1:t[e]0&&_.copyBuffersToTexture(s,f,a),n.length>0&&_.copyTexImagesToTexture(n,f,r)},i.createTexture=function(t){var e=new Ey;return e.setFilters(2,2),e.setMipFilter(1),e.reset({width:this.atlasSize,height:this.atlasSize,format:35}),this._textures[t]=e,e},i.resizeAtlases=function(){for(var t in this._textures)this._textures[t].reset({width:this.atlasSize,height:this.atlasSize,format:35})},i._createUnitMesh=function(t,e){for(var i=JSON.parse(JSON.stringify(e.struct)),n={},r=0;rthis._renderers.length)&&(t=this._renderers.length),this._renderers.splice(t,0,e);var i=!1;return e.model&&(i=!0,this._LODData.addModel(e.model)),this._modelAddedCallback&&i&&this._modelAddedCallback(),e},e.deleteRenderer=function(t){var e,i=this._renderers.splice(t,1),n=i.length>0?null==(e=i[0])?void 0:e.model:null;return n&&this._LODData.eraseModel(n),i[0]},e.getRenderer=function(t){return this._renderers[t]||null},e.setRenderer=function(t,e){t<0||t>=this.rendererCount?J("setRenderer to LOD error, index out of range"):(this.deleteRenderer(t),this.insertRenderer(t,e))},n(t,[{key:"screenUsagePercentage",get:function(){return this._screenUsagePercentage},set:function(t){this._screenUsagePercentage=t,this._LODData.screenUsagePercentage=t}},{key:"renderers",get:function(){return this._renderers},set:function(t){if(t!==this._renderers){var e=!1;this._renderers.length=0,this._LODData.clearModels();for(var i=0;ithis.lodCount)&&(t=this.lodCount),i||(i=new qJ),i.modelAddedCallback=this.onLodModelAddedCallback.bind(this),!e){var n=this.getLOD(t-1),r=this.getLOD(t);if(n&&r)e=(n.screenUsagePercentage+r.screenUsagePercentage)/2;else if(n&&!r)(e=n.screenUsagePercentage/2)>.01&&(e=.01);else if(r&&!n){e=r.screenUsagePercentage;var s=this.getLOD(t+1);r.screenUsagePercentage=(e+(s?s.screenUsagePercentage:0))/2}else e=jJ[0]}return i.screenUsagePercentage=e,this._LODs.splice(t,0,i),this._lodGroup.insertLOD(t,i.lodData),this._updateDataToScene(),this.node&&this._emitChangeNode(this.node),i},i.eraseLOD=function(t){if(t<0||t>=this.lodCount)return Y("eraseLOD error, index out of range"),null;var e=this._LODs[t];return e?(this._LODs.splice(t,1),this._lodGroup.eraseLOD(t),this._updateDataToScene(),this._emitChangeNode(this.node),e):(Y("eraseLOD error, LOD not exist at specified index."),null)},i.getLOD=function(t){return t<0||t>=this.lodCount?(Y("getLOD error, index out of range"),null):this._LODs[t]},i.setLOD=function(t,e){t<0||t>=this.lodCount?Y("setLOD error, index out of range"):(this._LODs[t]=e,e.modelAddedCallback=this.onLodModelAddedCallback.bind(this),this.lodGroup.updateLOD(t,e.lodData),this._updateDataToScene())},i.recalculateBounds=function(){for(var t=new ir,e=new ir,i=null,n=new ir,r=0;r0&&this._lodGroup.lodCount<1&&this._LODs.forEach((function(e,i){e.lodData.screenUsagePercentage=e.screenUsagePercentage;var n=e.renderers;if(null!==n&&n.length>0)for(var r=0;r1?e[1]:null},e._getModelsByProbe=function(t){var e=[],i=this._useCubeModels;1===t.probeType&&(i=this._usePlanarModels);for(var n,r=p(i.entries());!(n=r()).done;){var s=n.value;s[1]===t&&e.push(s[0])}return e},e._removeDependentModels=function(t){for(var e,i=p(this._useCubeModels.keys());!(e=i()).done;){var n=e.value,r=this._useCubeModels.get(n);void 0!==r&&r===t&&(this._useCubeModels.delete(n),this.selectReflectionProbe(n))}for(var s,a=p(this._usePlanarModels.keys());!(s=a()).done;){var o=s.value,h=this._usePlanarModels.get(o);void 0!==h&&h===t&&(this._usePlanarModels.delete(o),this.selectPlanarReflectionProbe(o))}},e._updateCubemapOfModel=function(t,e){var i=t.node;if(i){var n=i.getComponent(mj);if(n&&(n.updateProbeCubemap(e?e.cubemap:null),n.updateReflectionProbeId(e&&e.cubemap?e.getProbeId():-1),e&&(n.updateReflectionProbeDataMap(this._dataTexture),this._isUsedBlending(t)))){var r=this._getBlendProbe(t);this._updateBlendProbeInfo(t,e,r)}}},e._updatePlanarMapOfModel=function(t,e,i){var n=t.node.getComponent(mj);n&&(n.updateProbePlanarMap(e),i?(n.updateReflectionProbeId(i.getProbeId()),n.updateReflectionProbeDataMap(this._dataTexture)):n.updateReflectionProbeId(-1))},e._isUsedBlending=function(t){return 3===t.reflectionProbeType||4===t.reflectionProbeType},e._updateBlendProbeInfo=function(t,e,i){var n=t.node;if(n){var r=n.getComponent(mj);r&&(r.updateReflectionProbeBlendId(-1),4===t.reflectionProbeType&&r.updateReflectionProbeBlendWeight(this._calculateBlendWeight(t,e,i)))}},e._updateBlendCubemap=function(t,e){var i=t.node;if(i&&this._isUsedBlending(t)){var n=i.getComponent(mj);n&&n.updateProbeBlendCubemap(e.cubemap)}},e._calculateBlendWeight=function(t,e,i){if(i){var n=ir.distance(t.node.worldPosition,e.node.worldPosition),r=ir.distance(t.node.worldPosition,i.node.worldPosition);return 1-r/(n+r)}return 3===t.reflectionProbeType?0:4===t.reflectionProbeType?this._calculateBlendOfSkybox(t.worldBounds,e.boundingBox):0},e._calculateBlendOfSkybox=function(t,e){if(!t)return 1;var i=new ir,n=new ir,r=new ir,s=new ir;if(ir.subtract(i,t.center,t.halfExtents),ir.add(n,t.center,t.halfExtents),ir.subtract(r,e.center,e.halfExtents),ir.add(s,e.center,e.halfExtents),i.x<=s.x&&n.x>=r.x&&i.y<=s.y&&n.y>=r.y&&i.z<=s.z&&n.z>=r.z){var a=new ir;ir.multiplyScalar(a,t.halfExtents,2);var o=i.x+a.x<=s.x&&n.x+a.x>=r.x,h=i.x-a.x<=s.x&&n.x-a.x>=r.x,u=i.y+a.y<=s.y&&n.y+a.y>=r.y,l=i.y-a.y<=s.y&&n.y-a.y>=r.y,c=i.z+a.z<=s.z&&n.z+a.z>=r.z,f=i.z-a.z<=s.z&&n.z-a.z>=r.z,_=[];if(!o){var d=n.x-s.x;_.push(d/a.x)}if(!h){var p=Math.abs(i.x-r.x);_.push(p/a.x)}if(!u){var m=n.y-s.y;_.push(m/a.y)}if(!l){var g=Math.abs(i.y-r.y);_.push(g/a.y)}if(!c){var y=n.z-s.z;_.push(y/a.z)}if(!f){var v=Math.abs(i.z-r.z);_.push(v/a.z)}return _.length>0?(_.sort((function(t,e){return e-t})),_[0]):0}return 1},n(t,[{key:"updateForRuntime",get:function(){return this._updateForRuntime},set:function(t){this._updateForRuntime=t}}]),t}());function JJ(t){return void 0===(t=t||{}).includeNormal&&(t.includeNormal=!0),void 0===t.includeUV&&(t.includeUV=!0),t}YJ.probeManager=void 0,YJ.probeManager=new YJ,A.internal.reflectionProbeManager=YJ.probeManager;var KJ=new ir,QJ=new ir,ZJ=new ir,$J=new ir,tK=new ir,eK=new ir,iK=new ir,nK=new ir,rK=new ir,sK=new ir,aK=new ir,oK=new ir,hK=new ir(0,0,0),uK=new ir(0,0,0);function lK(t,e,i,n){void 0===t&&(t=.5),void 0===e&&(e=.5),void 0===i&&(i=2),void 0===n&&(n={});var r=.5*i,s=n.radialSegments||32,a=n.heightSegments||1,o=void 0===n.capped||n.capped,h=n.arc||2*Math.PI,u=0;o&&(t>0&&u++,e>0&&u++);var l=(s+1)*(a+1);o&&(l+=(s+1)*u+s*u);var c=s*a*6;o&&(c+=s*u*3);var f=new Array(c),_=new Array(3*l),d=new Array(3*l),p=new Array(2*l),m=Math.max(t,e),g=new ir(-m,-r,-m),y=new ir(m,r,m),v=Math.sqrt(m*m+r*r),b=0,S=0;return function(){for(var n=[],o=t-e,u=o*o/i*Math.sign(o),l=0;l<=a;l++){for(var c=[],m=l/a,g=m*o+e,y=0;y<=s;++y){var v=y/s,w=v*h,x=Math.sin(w),T=Math.cos(w);_[3*b]=g*x,_[3*b+1]=m*i-r,_[3*b+2]=g*T,ir.normalize(hK,ir.set(uK,x,-u,T)),d[3*b]=hK.x,d[3*b+1]=hK.y,d[3*b+2]=hK.z,p[2*b]=2*(1-v)%1,p[2*b+1]=m,c.push(b),++b}n.push(c)}for(var A=0;A0&&w(!1),t>0&&w(!0)),{positions:_,normals:d,uvs:p,indices:f,minPos:g,maxPos:y,boundingRadius:v};function w(i){for(var n=i?t:e,a=i?1:-1,o=b,u=1;u<=s;++u)_[3*b]=0,_[3*b+1]=r*a,_[3*b+2]=0,d[3*b]=0,d[3*b+1]=a,d[3*b+2]=0,p[2*b]=.5,p[2*b+1]=.5,++b;for(var l=b,c=0;c<=s;++c){var m=c/s*h,g=Math.cos(m),y=Math.sin(m);_[3*b]=n*y,_[3*b+1]=r*a,_[3*b+2]=n*g,d[3*b]=0,d[3*b+1]=a,d[3*b+2]=0,p[2*b]=.5-.5*y*a,p[2*b+1]=.5+.5*g,++b}for(var v=0;v0&&(n[n.length-1]=1),{positions:i,indices:n,minPos:{x:1,y:1,z:0},maxPos:{x:-1,y:-1,z:0},boundingRadius:1,primitiveMode:9}},cone:function(t,e,i){return void 0===t&&(t=.5),void 0===e&&(e=1),void 0===i&&(i={}),lK(0,t,e,i)},cylinder:lK,invWinding:function(t){for(var e=[],i=0;io?o<<16|a:a<<16|o;void 0===n[h]&&(n[h]=0,i.push(a,o))}return i},wireframed:function(t){var e=t.indices;if(!e)return t;if(t.primitiveMode&&7!==t.primitiveMode)return t;for(var i=[[0,1],[1,2],[2,0]],n=[],r={},s=0;sh?h<<16|o:o<<16|h;void 0===r[u]&&(r[u]=0,n.push(o,h))}return t.indices=n,t.primitiveMode=1,t}});t("f_",wK);var xK=new ir;function TK(t){return t.x=Math.abs(t.x),t.y=Math.abs(t.y),t.z=Math.abs(t.z),t}var AK,CK,DK,BK,IK,MK,PK,EK,OK,kK,RK,FK,LK,VK,NK,zK,UK,GK,HK,WK,jK,qK,XK,YK=Object.freeze({__proto__:null,CharacterTriggerEventObject:{type:"onControllerTriggerEnter",collider:null,characterController:null,impl:null},CollisionEventObject:{type:"onCollisionEnter",selfCollider:null,otherCollider:null,contacts:[],impl:null},TriggerEventObject:{type:"onTriggerEnter",selfCollider:null,otherCollider:null,impl:null},VEC3_0:xK,absolute:TK,cylinder:lK,getWrap:function(t){return t.__cc_wrapper__},maxComponent:function(t){return Math.max(t.x,Math.max(t.y,t.z))},setWrap:function(t,e){t.__cc_wrapper__=e},shrinkPositions:function(t){var e=[],i={};if(t.length>=3){e[0]=t[0],e[1]=t[1],e[2]=t[2];for(var n=t.length,r=3;r0&&(this._delayTime-=t,this._delayTime>0)||(this._currentFramePlayed?this.time+=t*this._speed:this._currentFramePlayed=!0,this._process())},i.sample=function(){var t=this.getWrappedInfo(this.time,this._wrappedInfo);return this._sampleCurves(t.time),this._sampleEvents(t),this._sampleEmbeddedPlayers(t),t},i.onPlay=function(){var t;this.setTime(this._getPlaybackStart()),this._delayTime=this._delay,this._onReplayOrResume(),this.emit("play",this),null==(t=this._clipEmbeddedPlayerEval)||t.notifyHostPlay(this.current)},i.onStop=function(){var t;this.isPaused||this._onPauseOrStop(),this.emit("stop",this),null==(t=this._clipEmbeddedPlayerEval)||t.notifyHostStop()},i.onResume=function(){var t;this._onReplayOrResume(),this.emit("resume",this),null==(t=this._clipEmbeddedPlayerEval)||t.notifyHostPlay(this.current)},i.onPause=function(){var t;this._onPauseOrStop(),this.emit("pause",this),null==(t=this._clipEmbeddedPlayerEval)||t.notifyHostPause(this.current)},i._sampleCurves=function(t){var e=this._poseOutput,i=this._clipEval;e&&(e.weight=this.weight),i&&i.evaluate(t)},i._process=function(){this._useSimpleProcess?this.simpleProcess():this.process()},i.process=function(){var t,e=this.sample();this._allowLastFrame&&(t=this._lastWrapInfo?this._lastWrapInfo:this._lastWrapInfo=new hQ(e),this.repeatCount>1&&(0|e.iterations)>(0|t.iterations)&&this.emit("lastframe",this),t.set(e)),e.stopped&&(this.stop(),this.emit("finished",this))},i.simpleProcess=function(){var t=this._playbackRange.min,e=this._playbackDuration,i=0,n=0;if(0!==e&&((i=this.time%e)<0&&(i+=e),n=(t+i)*this._invDuration),this._sampleCurves(t+i),this._clipEventEval||this._clipEmbeddedPlayerEval){var r=this.getWrappedInfo(this.time,this._wrappedInfo);this._sampleEvents(r),this._sampleEmbeddedPlayers(r)}this._allowLastFrame&&(Number.isNaN(this._lastIterations)&&(this._lastIterations=n),(this.time>0&&this._lastIterations>n||this.time<0&&this._lastIterations0&&(t-=1),1&t&&(i=!i)),36&~e||(i=!i),i},i.getWrappedInfo=function(t,e){e=e||new hQ;var i=this._playbackRange.min,n=this._playbackDuration,r=this.repeatCount;if(0===n)return e.time=0,e.ratio=0,e.direction=1,e.stopped=!!Number.isFinite(r),e.iterations=0,e;var s=!1,a=(t-=i)>0?t/n:-t/n;if(a>=r){a=r,s=!0;var o=r-(0|r);0===o&&(o=1),t=o*n*(t>0?1:-1)}if(t>n){var h=t%n;t=0===h?n:h}else t<0&&0!=(t%=n)&&(t+=n);var u=!1,l=4&this._wrapMode;l&&(u=this._needReverse(a));var c=u?-1:1;return this.speed<0&&(c*=-1),l&&u&&(t=n-t),e.time=i+t,e.ratio=e.time/this.duration,e.direction=c,e.stopped=s,e.iterations=a,e},i._getPlaybackStart=function(){return this._playbackRange.min},i._sampleEvents=function(t){var e;null==(e=this._clipEventEval)||e.sample(t.ratio,t.direction,t.iterations)},i._sampleEmbeddedPlayers=function(t){var e;null==(e=this._clipEmbeddedPlayerEval)||e.evaluate(t.time,Math.trunc(t.iterations))},i._emit=function(t,e){this._target&&this._target.isValid&&this._target.emit(t,t,e)},i._onReplayOrResume=function(){lQ().addAnimation(this)},i._onPauseOrStop=function(){lQ().removeAnimation(this)},n(e,[{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(t){var e;this._wrapMode=t,this.time=0,this.repeatCount=2&t?1/0:1,null==(e=this._clipEventEval)||e.setWrapMode(t)}},{key:"repeatCount",get:function(){return this._repeatCount},set:function(t){this._repeatCount=t;var e=4&this._wrapMode,i=!(36&~this.wrapMode);this._useSimpleProcess=t===1/0&&!e&&!i}},{key:"delay",get:function(){return this._delay},set:function(t){this._delayTime=this._delay=t}},{key:"playbackRange",get:function(){return this._playbackRange},set:function(t){t.max,t.min,this._playbackRange.min=Math.max(t.min,0),this._playbackRange.max=Math.min(t.max,this.duration),this._playbackDuration=this._playbackRange.max-this._playbackRange.min,this.setTime(0)}},{key:"speed",get:function(){return this._speed},set:function(t){var e;this._speed=t,null==(e=this._clipEmbeddedPlayerEval)||e.notifyHostSpeedChanged(t)}},{key:"current",get:function(){return this.getWrappedInfo(this.time).time}},{key:"ratio",get:function(){return 0===this.duration?0:this.current/this.duration}},{key:"weight",get:function(){return this._weight},set:function(t){this._weight=t,this._poseOutput&&(this._poseOutput.weight=t)}},{key:"curveLoaded",get:function(){return this._curveLoaded}}]),e}(aQ));A.AnimationState=pQ,Kh(iQ+"EmbeddedAnimationClipPlayable")((fQ=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;re){var i;(i=this._channels).push.apply(i,Array.from({length:t-e},(function(){return new eZ(new Zl)})))}}}]),e}(tZ),$Q=zh(ZQ.prototype,"_channels",[rZ],(function(){return[]})),ZQ));var sZ,aZ,oZ,hZ,uZ,lZ,cZ,fZ,_Z,dZ,pZ,mZ,gZ,yZ=function(){function t(t){this._curves=t,this._result=new Array(t.length).fill(0)}return t.prototype.evaluate=function(t){for(var e=this._result,i=e.length,n=0;n=t.passes.length)at(3941,t.name,e);else{var r=t.passes[e],s=r.getHandle(i);if(s){if(QS(s)<26){var a=void 0===n?s:r.getHandle(i,n,13);return a?bZ(r,i)?{set:function(t){r.setUniformArray(a,t)}}:{set:function(t){r.setUniform(a,t)}}:void at(3943,t.name,e,i,n)}var o=ZS(s),h=r.properties[i],u=h&&h.value?""+h.value+ow(h.type):aw(h.type),l=mT.get(u);return l||(Y("Illegal texture default value: "+u+"."),l=mT.get("default-texture")),{set:function(t){t||(t=l);var e=t.getGFXTexture();e&&e.width&&e.height&&(r.bindTexture(o,e),t instanceof Ym&&r.bindSampler(o,Wp.gfxDevice.getSampler(t.getSamplerInfo())))}}}at(3942,t.name,e,i)}}else at(3940,t)},t}(),oZ=zh(aZ.prototype,"passIndex",[uu],(function(){return 0})),hZ=zh(aZ.prototype,"uniformName",[uu],(function(){return""})),uZ=v(aZ.prototype,"channelIndex",[Mu],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){}}),sZ=aZ))||sZ;function bZ(t,e){for(var i,n=p(t.shaderInfo.blocks);!(i=n()).done;)for(var r,s=p(i.value.members);!(r=s()).done;){var a=r.value;if(a.name===e)return a.count>1}return!1}var SZ,wZ,xZ,TZ,AZ,CZ=Kh("cc.animation.MorphWeightValueProxy")((cZ=function(){function t(){this.subMeshIndex=fZ&&fZ(),this.shapeIndex=_Z&&_Z()}return t.prototype.forTarget=function(t){var e=this;return{set:function(i){t.setWeight(i,e.subMeshIndex,e.shapeIndex)}}},t}(),fZ=zh(cZ.prototype,"subMeshIndex",[uu],(function(){return 0})),_Z=zh(cZ.prototype,"shapeIndex",[uu],(function(){return 0})),lZ=cZ))||lZ,DZ=Kh("cc.animation.MorphWeightsValueProxy")((pZ=function(){function t(){this.subMeshIndex=mZ&&mZ()}return t.prototype.forTarget=function(t){var e=this;return{set:function(i){t.setWeights(i,e.subMeshIndex)}}},t}(),mZ=zh(pZ.prototype,"subMeshIndex",[uu],(function(){return 0})),dZ=pZ))||dZ,BZ=Kh("cc.animation.MorphWeightsAllValueProxy")(gZ=function(){function t(){}return t.prototype.forTarget=function(t){return{set:function(e){for(var i,n,r=null!==(i=null==(n=t.mesh)?void 0:n.struct.primitives.length)&&void 0!==i?i:0,s=0;s2?i-2:0),r=2;r>1},set:function(t){this._flags&=-7,this._flags|=t<<1}}]),t}(),y$=zh(g$.prototype,"_flags",[uu],(function(){return 0})),m$=g$))||m$,M$=function(t){function e(e,i){var n;return(n=t.call(this,2)||this).resetMode=0,n._value=void 0,n.resetMode=i,n._value=e,n}s(e,t);var i=e.prototype;return i.getValue=function(){return this._value},i.setValue=function(t){this._value=t},e}(C$),P$=Kh("cc.animation.Vec3Variable")((b$=function(){function t(){this._value=S$&&S$()}return t.prototype[A$]=function(){return new E$(this.value)},n(t,[{key:"type",get:function(){return 4}},{key:"value",get:function(){return this._value},set:function(t){ir.copy(this._value,t)}}]),t}(),S$=zh(b$.prototype,"_value",[uu],(function(){return new ir})),v$=b$))||v$,E$=function(t){function e(e){var i;return(i=t.call(this,4)||this)._value=new ir,ir.copy(i._value,e),i}s(e,t);var i=e.prototype;return i.getValue=function(){return this._value},i.setValue=function(t){ir.copy(this._value,t)},e}(C$),O$=Kh("cc.animation.QuatVariable")((x$=function(){function t(){this._value=T$&&T$()}return t.prototype[A$]=function(){return new k$(this._value)},n(t,[{key:"type",get:function(){return 5}},{key:"value",get:function(){return this._value},set:function(t){kr.copy(this._value,t)}}]),t}(),T$=zh(x$.prototype,"_value",[uu],(function(){return new kr})),w$=x$))||w$,k$=function(t){function e(e){var i;return(i=t.call(this,5)||this)._value=new kr,kr.copy(i._value,e),i}s(e,t);var i=e.prototype;return i.getValue=function(){return this._value},i.setValue=function(t){kr.copy(this._value,t)},e}(C$);function R$(t,e){var i;switch(t){case 0:case 3:case 1:i=new D$(t);break;case 2:i=new I$;break;case 4:i=new P$;break;case 5:i=new O$;break;default:throw new Error("Unknown variable type "+t)}return void 0!==e&&(i.value=e),i}var F$,L$,V$,N$,z$,U$,G$=function(t){function e(e){var i;return(i=t.call(this,e+" transition is invalid")||this).name="TransitionRejectError",i}return s(e,t),e}(l(Error)),H$=function(t){function e(e){return t.call(this,"Graph variable "+e+" is not defined")||this}return s(e,t),e}(l(Error)),W$=function(t){function e(e,i,n){return t.call(this,"Expect graph variable "+e+" to have type '"+i+"' instead of received '"+(null!=n?n:typeof n)+"'")||this}return s(e,t),e}(l(Error)),j$=1,q$=-4192741,X$=[];function Y$(t){return"function"==typeof t._instantiate}function J$(t){var e;if(vo(t)){if(Y$(t))return A.game._isCloning=!0,e=t._instantiate(null,!0),A.game._isCloning=!1,e;if(t instanceof A.Asset)throw new TypeError(ft(6903))}return A.game._isCloning=!0,e=K$(t),A.game._isCloning=!1,e}function K$(t,e){var i;Z$(t,i=t._iN$t?t._iN$t:t.constructor?new(0,t.constructor):Object.create(null),e);for(var n=0,r=X$.length;n=0&&this._bindings.splice(e,1)},i.moveArrayElementBindingForward=function(t,e,i){for(var n=this._bindings,r=[],s=0;s=e&&(r.push(a),n.splice(s,1))}for(var l=0,c=r;l=0?this._bindings[e]:void 0},i._findBindingIndex=function(t){return this._bindings.findIndex((function(e){return R0(e.inputPath,t)}))},i._emplaceBinding=function(t){var e=this._bindings.findIndex((function(e){return R0(e.inputPath,t.inputPath)}));e>=0?this._bindings[e]=t:this._bindings.push(t)},e}(Hu),D0=zh(C0.prototype,"_bindings",[uu],(function(){return[]})),A0=C0))||A0;function R0(t,e){var i=t[0],n=t[1],r=e[0],s=e[1];return i===r&&n===s}var F0=Kh(iQ+"PoseGraphNodeInputBinding")((I0=function(){function t(t,e,i){this._inputPath=M0&&M0(),this._producer=P0&&P0(),this._outputIndex=E0&&E0(),this._inputPath=t,this._producer=e,void 0!==i&&(this._outputIndex=i)}return n(t,[{key:"inputPath",get:function(){return this._inputPath}},{key:"producer",get:function(){return this._producer}},{key:"outputIndex",get:function(){return this._outputIndex}}]),t}(),M0=zh(I0.prototype,"_inputPath",[uu],null),P0=zh(I0.prototype,"_producer",[uu],null),E0=zh(I0.prototype,"_outputIndex",[uu],(function(){return 0})),B0=I0))||B0,L0=function(t){function e(e){return t.call(this,"Can not add the specified "+e.toString()+" since it has already been added into another graph.")||this}return s(e,t),e}(l(Error)),V0=function(t){function e(e){return t.call(this,"Can not perform specified operation on "+e.toString()+" since it has not been added in to graph.")||this}return s(e,t),e}(l(Error)),N0=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e}(Hu),z0=new WeakMap;function U0(t){var e=z0.get(t);if(e)return e;var i={};return z0.set(t,i),i}function G0(t){return function(e){if(ie(e,N0)||(J("This kind of decorator should only be applied to pose graph node classes."),0)){var i=U0(e);t(i)}}}var H0=function(t){return G0((function(e){var i;Object.assign(null!==(i=e.appearance)&&void 0!==i?i:e.appearance={},t)}))};var W0=["arraySyncGroup"],j0=function(){function t(){this._classInputMap=new WeakMap}var e=t.prototype;return e.setPropertyNodeInputRecord=function(t,e,i){var n=this._classInputMap.get(t);n||(n={properties:{}},this._classInputMap.set(t,n)),i.arraySyncGroup;var r=c(i,W0),s=i.arraySyncGroup;if(s){var a,o;n.arraySyncGroups||(n.arraySyncGroups={});var h=null!==(o=(a=n.arraySyncGroups)[s])&&void 0!==o?o:a[s]={members:[]};h.members.includes(e)||h.members.push(e),r.arraySyncGroup=h}n.properties[e]=Object.freeze(r)},e.getInputKeys=function(t){var e=this,i=[];return function n(r){if(r){n(ee(r));var s=e._classInputMap.get(r);if(s)for(var a=function(){var e=h[o][0];if(i.findIndex((function(t){var i=t[0];return e===i}))>=0)return 1;var n=t[e];if(Array.isArray(n))for(var r=0;r=a.length)return;var o,h,u=null!==(o=null==(h=s.getArrayElementDisplayName)?void 0:h.call(t,r))&&void 0!==o?o:s.displayName;return{type:s.type,displayName:u,deletable:!(s.arraySyncGroup&&s.arraySyncGroupFollower),insertPoint:!0}}return{type:s.type,displayName:s.displayName}}},e.hasInput=function(t,e){var i=e[0],n=e[1],r=void 0===n?-1:n;if(!this._getPropertyNodeInputRecord(t.constructor,i))return!1;var s=t[i];return!Array.isArray(s)||!(r<0||r>=s.length)},e.getInputInsertInfos=function(t){for(var e={},i=t.constructor;i;i=ee(i)){var n=this._classInputMap.get(i);if(n)for(var r in n.properties){var s=n.properties[r],a=t[r];if(Array.isArray(a)){if(s.arraySyncGroup&&s.arraySyncGroupFollower)continue;e[r]={displayName:r}}}}return e},e.deleteInput=function(t,e,i){var n=i[0],r=i[1],s=void 0===r?-1:r,a=this._getPropertyNodeInputRecord(e.constructor,n);if(a){var o=e[n];if(Array.isArray(o)&&!(s<0||s>=o.length)){var h=a.arraySyncGroup;h?this._deleteInputInArraySyncGroup(t,e,h,o.length,s):X0(t,e,i)}}},e.insertInput=function(t,e,i){var n=i,r=this._getPropertyNodeInputRecord(e.constructor,n);if(r){var s=e[n];if(Array.isArray(s)){var a=s.length,o=r.arraySyncGroup;o?this._insertInputInArraySyncGroup(t,e,o,s.length,a):q0(t,e,[n,a],Y0(r.type))}}},e._getPropertyNodeInputRecord=function(t,e){if(t){var i=this._classInputMap.get(t);if(i){var n=i.properties[e];if(n)return n}return this._getPropertyNodeInputRecord(ee(t),e)}},e._insertInputInArraySyncGroup=function(t,e,i,n,r){for(var s=0;s=o.length||(n.deleteBinding(i),o.splice(a,1),n.moveArrayElementBindingForward(r,a+1,!0)))}function Y0(t){switch(t){default:case 0:case 1:return 0;case 2:return!1;case 5:return null;case 3:return new ir;case 4:return new kr}}var J0,K0=new j0;Re({NO:0,LOCAL:1,COMPONENT:2});var Q0,Z0,$0,t1,e1,i1,n1=Kh(iQ+"PoseNode")(J0=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;rr)for(var h=r+1;h<=s;++h){var u=n[h],l=a.indexOf(u);a[o]=u,o=l}else if(r>s)for(var c=r-1;c>=s;--c){var f=n[c],_=a.indexOf(f);a[o]=f,o=_}a[o]=t,Xf(n,r,s)}},e.copyTo=function(t){for(var e,i=t._states.filter((function(e){switch(e){case t._entryState:case t._exitState:case t._anyState:return!0;default:return!1}})),n=p(i);!(e=n()).done;){var r=e.value;t.remove(r)}for(var s,a=new Map,o=p(this._states);!(s=o()).done;){var h=s.value;switch(h){case this._entryState:a.set(h,t._entryState);break;case this._exitState:a.set(h,t._exitState);break;case this._anyState:a.set(h,t._anyState);break;default:if(h instanceof S0||h instanceof D2||h instanceof b2||h instanceof w2){if(h instanceof b2&&!t._allowEmptyStates)continue;var u=J$(h);t._addState(u),a.set(h,u)}}}for(var l,c=p(this._transitions);!(l=c()).done;){var f=l.value;if(t._allowEmptyStates||!(f.from instanceof b2||f.to instanceof b2)){var _=a.get(f.from),d=a.get(f.to),m=t.connect(_,d);m.conditions=f.conditions.map((function(t){return t.clone()})),f.copyTo(m)}}},e.clone=function(){var t=new i(this._allowEmptyStates);return this.copyTo(t),t},e._addState=function(t){return this._states.push(t),t},n(i,[{key:"allowEmptyStates",get:function(){return this._allowEmptyStates}},{key:"entryState",get:function(){return this._entryState}},{key:"exitState",get:function(){return this._exitState}},{key:"anyState",get:function(){return this._anyState}}]),i}(Hu),W1=zh(H1.prototype,"_states",[uu],(function(){return[]})),j1=zh(H1.prototype,"_transitions",[uu],(function(){return[]})),q1=zh(H1.prototype,"_entryState",[uu],null),X1=zh(H1.prototype,"_exitState",[uu],null),Y1=zh(H1.prototype,"_anyState",[uu],null),G1=H1))||G1,D2=Kh("cc.animation.SubStateMachine")((K1=function(t){function e(e){var i;return(i=t.call(this)||this)._stateMachine=Q1&&Q1(),i._stateMachine=new C2(e),i}return s(e,t),e.prototype.copyTo=function(e){t.prototype.copyTo.call(this,e),this._stateMachine.copyTo(e._stateMachine)},n(e,[{key:"stateMachine",get:function(){return this._stateMachine}}]),e}(u0),Q1=zh(K1.prototype,"_stateMachine",[uu],null),J1=K1))||J1,B2=Kh(iQ+"PoseGraphStash")(($1=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r1e-6){n=!1;break}this._findRatio=n?L2:kh}return t.prototype.sample=function(t){return this._findRatio(this.ratios,t)},t}());A.RatioSampler=O2;var k2=t("ax",function(){function t(e,i){this.types=void 0,this.type=null,this._values=[],this._lerp=void 0,this._duration=void 0,this._array=void 0,this._duration=i,this._values=e.values;var n=function(e){return"string"==typeof e?e:Array.isArray(e)?e[0]===e[1]&&e[2]===e[3]?t.Linear:t.Bezier(e):t.Linear};if(void 0!==e.easingMethod)this.type=n(e.easingMethod);else if(Array.isArray(e.easingMethods))this.types=e.easingMethods.map(n);else if(void 0!==e.easingMethods){this.types=new Array(this._values.length).fill(null);for(var r=0,s=Object.keys(e.easingMethods);r=e.ratios.length))return t.valueBetween(i,n-1,e.ratios[n-1],n,e.ratios[n]);n=e.ratios.length-1}return t.valueAt(n)}function F2(t,e){if("string"==typeof e){var i=Hl[e];i?t=i(t):ht(3906,e)}else Array.isArray(e)&&(t=jc(e,t));return t}function L2(t,e){var i=t.length-1;if(0===i)return 0;var n=t[0];if(er)return i;var s=(e=(e-n)/(r-n))/(1/i),a=0|s,o=1e-6;return s-a=0)i=r;else{var s=~r,a=s-1;i=a;var o=t[s],h=t[a];n=(e-h)/(o-h)}return{index:i,ratio:n}}!function(){function t(){this._reset()}var e=t.prototype;e.calculate=function(t,e,i){if(this._reset(),!(e>i)){var n=t.length;if(n){var r=t[0],s=t[n-1],a=0,o=0;if(e=s)a=n-1,o=0;else{var h=k3(t,e);a=h.index,o=h.ratio}var u=0,l=0;if(i=s)u=n-1,l=0;else{var c=k3(t,i);u=c.index,l=c.ratio}var f=!o,_=!l;a!==u||o!==l?(f||(this.preLerpIndex=a,this.preLerpRatio=o),this.directKeyframesBegin=f?a:a+1,this.directKeyframesEnd=u+1,_||(this.postLerpIndex=u,this.postLerpRatio=l)):f?(this.directKeyframesBegin=a,this.directKeyframesEnd=a+1):(this.preLerpIndex=a,this.preLerpRatio=o)}}},e._reset=function(){this.preLerpIndex=-1,this.preLerpRatio=0,this.directKeyframesBegin=0,this.directKeyframesEnd=0,this.postLerpIndex=-1,this.postLerpRatio=0},n(t,[{key:"keyframesCount",get:function(){var t=this.preLerpIndex,e=this.directKeyframesBegin;return 0+(t<0?0:1)+(this.directKeyframesEnd-e)+(this.postLerpIndex<0?0:1)}}])}();var R3=function(){function t(t,e){this._nodeEvaluations=void 0,this._nodeEvaluations=t.map((function(t){return t.createEvaluator(e)}))}return t.prototype.evaluate=function(t){this._nodeEvaluations.forEach((function(e){e.evaluate(t)}))},t}(),F3=function(){function t(t,e,i,n,r){this._position=null,this._rotation=null,this._scale=null,e&&(this._position=K3(e.times,e.values,ir,t,"position",r)),i&&(this._rotation=K3(i.times,i.values,kr,t,"rotation",r)),n&&(this._scale=K3(n.times,n.values,ir,t,"scale",r))}return t.prototype.evaluate=function(t){if(this._position){var e=this._position.evaluator.evaluate(t);this._position.runtimeBinding.setValue(e)}if(this._rotation){var i=this._rotation.evaluator.evaluate(t);this._rotation.runtimeBinding.setValue(i)}if(this._scale){var n=this._scale.evaluator.evaluate(t);this._scale.runtimeBinding.setValue(n)}},t}(),L3=function(){function t(t,e,i){this._times=void 0,this._inputSampleResultCache={just:!1,index:-1,nextIndex:-1,ratio:0},this._values=void 0,this._prevValue=void 0,this._nextValue=void 0,this._resultValue=void 0,this._times=t,this._values=e,this._prevValue=new i,this._nextValue=new i,this._resultValue=new i}return t.prototype.evaluate=function(t){var e=this._times,i=this._values,n=this._resultValue;if(0===e.length)return n;var r=z3(e,t,this._inputSampleResultCache);return r.just?i.get(r.index,n):i.lerp(r.index,r.nextIndex,r.ratio,this._prevValue,this._nextValue,n),n},t}(),V3=function(){function t(t,e){this._nodeEvaluations=void 0,this._nodeEvaluations=t.map((function(t){return t.createEvaluatorForAnimationGraph(e)})).filter((function(t){return!!t}))}var e=t.prototype;return e.destroy=function(){for(var t=this._nodeEvaluations,e=t.length,i=0;is)i.just=!0,i.index=n-1;else{var a=kh(t,e);if(a>=0)i.just=!0,i.index=a;else{var o=~a,h=o-1,u=t[h],l=t[o],c=(e-t[h])/(l-u);i.just=!1,i.index=h,i.nextIndex=o,i.ratio=c}}return i}var U3={uint8:Uint8Array,uint16:Uint16Array};function G3(t){switch(t.BYTES_PER_ELEMENT){default:case 4:return 0;case 8:return 1}}var H3,W3,j3,q3,X3=T3(iQ+"QuantizedFloatArray")((g3=function(){function t(t,e,i,n){void 0===n&&(n=0),this.originalPrecision=y3&&y3(),this.min=v3&&v3(),this.extent=b3&&b3(),this.values=S3&&S3(),this.originalPrecision=t,this.values=e,this.extent=i,this.min=n}return t.prototype.toHashString=function(){var t=this.originalPrecision,e=this.min,i=this.extent,n=this.values;return t+" "+B3(e)+" "+B3(i)+" "+n.join(" ")},n(t,[{key:"quantizationType",get:function(){switch(this.values.BYTES_PER_ELEMENT){default:case 1:return"uint8";case 2:return"uint16"}}}]),t}(),y3=zh(g3.prototype,"originalPrecision",[A3],null),v3=zh(g3.prototype,"min",[A3],null),b3=zh(g3.prototype,"extent",[A3],null),S3=zh(g3.prototype,"values",[A3],null),m3=g3))||m3;function Y3(t,e){var i=U3[e],n=1<=0){var f=u.substring(0,c),_=h[f];_&&(l.parent=_)}}for(var d=this._createEvalWithBinder(void 0,(function(t){var e=t.parseTrsPath();if(e){var i=h[e.node];if(i)return L5(i,e.property)}}),void 0),p=0;p=0&&this._embeddedPlayers.splice(e,1)},i[A5]=function(){this._embeddedPlayers.length=0},i.getAuxiliaryCurveNames_experimental=function(){return this._auxiliaryCurveEntries.map((function(t){return t.name}))},i.hasAuxiliaryCurve_experimental=function(t){return!!this._findAuxiliaryCurveEntry(t)},i.addAuxiliaryCurve_experimental=function(t){var e=this._findAuxiliaryCurveEntry(t);return e||((e=new y5).name=t,this._auxiliaryCurveEntries.push(e)),e.curve},i.getAuxiliaryCurve_experimental=function(t){return this._findAuxiliaryCurveEntry(t).curve},i.renameAuxiliaryCurve_experimental=function(t,e){var i=this._findAuxiliaryCurveEntry(t);i&&(i.name=e)},i.removeAuxiliaryCurve_experimental=function(t){xe(this._auxiliaryCurveEntries,(function(e){return e.name===t}))},i._trySyncLegacyData=function(){this._legacyDataDirty&&(this._legacyDataDirty=!1,this.syncLegacyData())},i._createEvalWithBinder=function(t,e,i){this._legacyDataDirty&&(this._legacyDataDirty=!1,this.syncLegacyData());var n,r=[];i&&(n=this._createRootMotionEvaluation(t,i,r));for(var s,a=[],o=this._tracks,h=o.length,u=0;u=c&&t<=f?o?e!==u&&(h.stop(),h.play(),a.entered=!0):(h.play(),a.entered=!0):o&&(h.stop(),a.entered=!1),a.lastIterations=e,a.entered){var _=t-c;a.instantiatedPlayer.setTime(_)}}}},e.notifyHostSpeedChanged=function(t){for(var e=this._embeddedPlayers,i=this._embeddedPlayerEvaluationInfos,n=e.length,r=0;r0?(22&~s?h=n:e*=-1,o++):1===e&&h===n-1&&ra)break}h+=e,this._doFire(h,!0)}while(h!==r&&h>-1&&h=e.length||this._ignoreIndex===t))for(var i=e[t],n=i.events.length,r=0;r0?t/e:-t/e;if(o>=n){o=n,a=!0;var h=n-(0|n);0===h&&(h=1),t=h*e*(t>0?1:-1)}if(t>e){var u=t%e;t=0===u?e:u}else t<0&&0!=(t%=e)&&(t+=e);var l=!1,c=4&i;c&&(l=H5(i,o));var f=l?-1:1;return c&&l&&(t=e-t),s.time=t,s.ratio=s.time/e,s.direction=f,s.stopped=a,s.iterations=o,s}function H5(t,e){var i=!1;return 22&~t||(e-(0|e)==0&&e>0&&(e-=1),1&e&&(i=!i)),36&~t||(i=!i),i}var W5=new ir,j5=new ir,q5=new kr;new kr;var X5,Y5,J5=function(){function t(){this._position=new ir,this._rotation=new kr,this._scale=ir.clone(ir.ONE)}return t.clone=function(e){var i=new t;return t.copy(i,e),i},t.setIdentity=function(t){return ir.copy(t._position,ir.ZERO),kr.copy(t._rotation,kr.IDENTITY),ir.copy(t._scale,ir.ONE),t},t.copy=function(t,e){return ir.copy(t._position,e._position),kr.copy(t._rotation,e._rotation),ir.copy(t._scale,e._scale),t},t.equals=function(t,e,i){return ir.equals(t._position,e._position,i)&&kr.equals(t._rotation,e._rotation,i)&&ir.equals(t._scale,e._scale,i)},t.strictEquals=function(t,e){return ir.strictEquals(t._position,e._position)&&kr.strictEquals(t._rotation,e._rotation)&&ir.strictEquals(t._scale,e._scale)},t.lerp=function(e,i,n,r){return 0===r?t.copy(e,i):1===r?t.copy(e,n):(ir.lerp(e._position,i._position,n._position,r),kr.slerp(e._rotation,i._rotation,n._rotation,r),ir.lerp(e._scale,i._scale,n._scale,r),e)},t.multiply=function(t,e,i){var n=kr.multiply(q5,e._rotation,i._rotation),r=ir.multiply(W5,i._scale,e._scale),s=ir.multiply(j5,i._position,e._scale);return ir.transformQuat(s,s,e._rotation),ir.add(s,s,e._position),ir.copy(t._position,s),kr.copy(t._rotation,n),ir.copy(t._scale,r),t},t.invert=function(t,e){var i=t._rotation,n=t._scale,r=t._position;return kr.invert(i,e._rotation),K5(n,e._scale,Ki),ir.negate(r,e._position),ir.multiply(r,r,n),ir.transformQuat(r,r,i),t},t.fromMatrix=function(t,e){return Kr.toSRT(e,t._rotation,t._position,t._scale),t},t.toMatrix=function(t,e){return Kr.fromSRT(t,e._rotation,e._position,e._scale)},n(t,[{key:"position",get:function(){return this._position},set:function(t){ir.copy(this._position,t)}},{key:"rotation",get:function(){return this._rotation},set:function(t){kr.copy(this._rotation,t)}},{key:"scale",get:function(){return this._scale},set:function(t){ir.copy(this._scale,t)}}]),t}();function K5(t,e,i){var n=e.x,r=e.y,s=e.z;return ir.set(t,Math.abs(n)<=i?0:1/n,Math.abs(r)<=i?0:1/r,Math.abs(s)<=i?0:1/s)}function Q5(t,e,i){return ir.subtract(t.position,e.position,i.position),e4(t.rotation,i.rotation,e.rotation),ir.subtract(t.scale,e.scale,i.scale),t}V5=J5,J5.IDENTITY=Object.freeze(new V5),J5.ZERO=Object.freeze(function(){var t=new V5;return ir.copy(t._position,ir.ZERO),kr.set(t._rotation,0,0,0,0),ir.copy(t._scale,ir.ZERO),t}()),J5.calculateRelative=(X5=new kr,Y5=new ir,function(t,e,i){var n=kr.invert(X5,i._rotation),r=K5(Y5,i._scale,Ki),s=ir.subtract(j5,e._position,i._position);return ir.transformQuat(s,s,n),ir.multiply(s,s,r),ir.copy(t._position,s),kr.multiply(t._rotation,n,e._rotation),ir.multiply(t._scale,e._scale,r),t});var Z5,$5,t4=(Z5=new kr,function(t,e,i,n){ir.scaleAndAdd(t.position,e.position,i.position,n);var r=kr.slerp(Z5,kr.IDENTITY,i.rotation,n);return kr.multiply(t.rotation,r,e.rotation),ir.scaleAndAdd(t.scale,e.scale,i.scale,n),t}),e4=($5=new kr,function(t,e,i){var n=kr.invert($5,e);return kr.multiply(t,i,n)}),i4=Object.freeze(function(){var t=new J5;return t.position=ir.ZERO,t.rotation=kr.IDENTITY,t.scale=ir.ZERO,t}()),n4=function(){function t(t,e){this.transforms=void 0,this.auxiliaryCurves=void 0,this._poseTransformSpace=0,this.transforms=t,this.auxiliaryCurves=e}return t._create=function(e,i){return new t(e,i)},t}(),r4=function(){function t(t){this._involvedTransforms=new Uint16Array(t)}return n(t,[{key:"involvedTransforms",get:function(){return this._involvedTransforms}}]),t}();function s4(t,e,i,n){void 0===n&&(n=void 0),a4(t.transforms,e.transforms,i,n),c4(t.auxiliaryCurves,e.auxiliaryCurves,i)}function a4(t,e,i,n){void 0===n&&(n=void 0);var r=t.length;if(t.length,0!==i)if(1!==i)if(n)for(var s=0;s=r)return{done:!0,value:void 0};var o=i[s];e=null==o?void 0:o.getClipStatuses(t*n[s]),++s}}}},e.__evaluatePort=function(t,e,i){for(var n=this._childEvaluators.length,r=0,s=null,a=0;a5?h-5:0),l=5;l=e[e.length-1])t[t.length-1]=1;else{for(var n=0,r=1;ri){n=r;break}var s=e[n-1],a=e[n],o=a-s;t[n-1]=(a-i)/o,t[n]=(i-s)/o}}var I6,M6,P6=Kh,E6=uu,O6=P6(iQ+"AnimationBlend1DItem")((t6=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r=0?t[n]=1:t.fill(1/e.length)}else{for(var r=-1,s=-1,a=-1,o=Number.NEGATIVE_INFINITY,h=Number.NEGATIVE_INFINITY,u=i.x,l=i.y,c=0;c0?d>=h&&(h=d,r=c):d>=o&&(o=d,s=c)}}var p=0;if(r<0||s<0)p=1;else{var m=(T=e[r],A=e[s],C=i,D=M6,(B=ds.cross(T,A))?(D.wA=ds.cross(C,A)/B,D.wB=ds.cross(C,T)/-B):(D.wA=0,D.wB=0),D),g=m.wA,y=m.wB,v=0,b=0,S=g+y;S>1?(v=g/S,b=y/S):S<0?(v=0,b=0,p=1):(v=g,b=y,p=1-S),t[r]=v,t[s]=b}if(p>0)if(a>=0)t[a]=p;else for(var w=p/t.length,x=0;x0&&t.forEach((function(e,i){return t[i]=e/a}))}var N6,z6,U6,G6,H6,W6,j6,q6,X6,Y6,J6=function(t,e,i,n,r){ds.subtract(n,i,t),ds.subtract(r,e,t)},K6=function(){function t(e){for(var i=t._ANGLE_MULTIPLIER,n=e.length,r=this._exampleMagnitudes=new Array(n).fill(0),s=this._exampleDirections=e.map((function(t,e){var i=ds.copy(new ds,t),n=ds.len(i);return r[e]=n,Zi(n,0,1e-5)||ds.multiplyScalar(i,i,1/n),i})),a=this._precomputedVIJs=new Float32Array(3*n*n),o=0;o0)for(var R=0;R=s)){this.setTransform(e,t);for(var a=e+1;a=0&&this._pages.length,this._pages[t].buffer},e.pushPage=function(t){var e=t[X8];this._pages.length,e===this._pages.length&&this._pushNewPage(),this._pages.length;var i=this._pages[e];return++i.useCount,++t[X8],i},e.popPage=function(t){var e=t[X8]-1,i=this._pages[e];i.useCount,--i.useCount,--t[X8],0===i.useCount&&(this._pages.length,this._pages.pop())},e.createAllocator=function(t){var e=new Z8(this,t);return++this._allocatorCount,e},e.destroyAllocator=function(t){for(var e=t[X8],i=0;ii[e-1]}))}var e=t.prototype;return e.createAllocator=function(t){var e=t,i=this._selectStackPageSize(e),n=this._stacks.get(i);return n||(n=new K8(this,i),this._stacks.set(i,n)),n.createAllocator(e)},e[Y8]=function(t){for(var e,i=p(this._stacks);!(e=i()).done;){var n=e.value,r=n[0];if(n[1]===t){this._stacks.delete(r);break}}},e._selectStackPageSize=function(t){var e=kh(this._thresholds,t),i=t;return e>=0?i=this._thresholds[e]:(e=~e)===this._thresholds.length||(e>=0&&this._thresholds.length,i=this._thresholds[e]),i},n(t,[{key:"isEmpty",get:function(){return 0===this._stacks.size}}]),t}(),t7=function(){function t(t,e){this._poses=[],this._allocatedCount=0,this._memoryAllocator=void 0,this._transformCount=t,this._auxiliaryCurveCount=e;var i=e7(t,e,1);this._memoryAllocator=i7.createAllocator(i)}var e=t.prototype;return e.destroy=function(){this._allocatedCount;for(var t=0;t>m7},set:function(t){this._id&=p7,this._id|=t<=n)return null;r>=0&&e.length;var s=null!==(t=e[r])&&void 0!==t?t:e[r]=this._createPose(r);return s[f7].poseIndex=r,this._idleFlags&=~(1<=0&&e.length,e[i],this._idleFlags|=1<=0){var n=e[i];return++n.refCount,n.handle}for(var r=0,s=function(t){var i=e.findIndex((function(e){return e.node===t}));if(i>=0)return r=i+1,1},a=t.parent;a&&!s(a);a=a.parent);for(var o=r;o=0){var n=e[i];return++n.refCount,n.handle}var r=e.length,s=new A7(new L7(this,r),t);return e.push(s),s.handle},e.createEvaluationContext=function(){return this._bindStarted,new R7(this.transformCount,this.auxiliaryCurveCount,this._parentTable.slice(),this._origin)},e.resetPoseStashAllocator=function(t){this._bindStarted,t._reset(this.transformCount,this.auxiliaryCurveCount)},e.createTransformFilter=function(t){for(var e,i=this._origin,n=[],r=p(this._transformRecords);!(e=r()).done;){var s=e.value,a=s.node,o=s.handle,h=u(i,a);if(void 0===h)J(a.getPathInHierarchy()+" is not a child of "+i.getPathInHierarchy());else if(t.isExcluded(h))continue;n.push(o.index)}return n.sort(),new r4(n);function u(t,e){for(var i=[],n=e;n;n=n.parent){if(n===t)return i.join("/");i.unshift(n.name)}}},e.fetchDefaultTransforms=function(t){var e=this._transformRecords.length;t.length;for(var i=0;i=0&&this._transformRecords.length;var e=this._transformRecords[t];e.refCount,--e.refCount},e._destroyAuxiliaryCurveHandle=function(t){t>=0&&this._auxiliaryCurveRecords.length;var e=this._auxiliaryCurveRecords[t];e.refCount,--e.refCount},e.startBind=function(){this._bindStarted=!0,this._transformCountBeforeBind=this._transformRecords.length,this._auxiliaryCurveCountBeforeBind=this._auxiliaryCurveRecords.length},e.endBind=function(){var t=this._transformRecords,e=this._auxiliaryCurveRecords,i=0;if(C7(t),t.length!==this._transformCountBeforeBind){i|=1;for(var n=t.length,r=0;r=0?n:-1}else{var r=t.findIndex((function(t){return t.node===i}));u[f]=r}},f=0;f0}));if(t.length,e!==t.length){for(var i=0;i=0;--i){var n=this._parentTable[i];if(!(n<0)){var r=e.getTransform(i,O7),s=e.getTransform(n,k7);J5.calculateRelative(r,r,s),e.setTransform(i,r)}}t._poseTransformSpace=0},e._convertPoseSpaceTransformToTargetSpace=function(t,e,i,n){var r=i._poseTransformSpace;switch(e){default:break;case 0:1===r?J5.multiply(t,this._getComponentToWorldTransform(),t):J5.multiply(t,this._getLocalToWorldTransform(k7,i,n),t);break;case 1:1===r||J5.multiply(t,this._getLocalToComponentTransform(k7,i,n),t);break;case 2:if(1===r){var s=this._parentTable[n];if(s>=0){var a=i.transforms.getTransform(s,k7),o=J5.invert(a,a);J5.multiply(t,o,t)}}break;case 3:var h=i.transforms.getTransform(n,k7),u=J5.invert(h,h);J5.multiply(t,u,t)}return t},e._convertTransformToPoseTransformSpace=function(t,e,i,n){var r=i._poseTransformSpace;switch(e){default:break;case 0:if(1===r){var s=J5.invert(k7,this._getComponentToWorldTransform());J5.multiply(t,s,t)}else{var a=this._getLocalToWorldTransform(k7,i,n),o=J5.invert(a,a);J5.multiply(t,o,t)}break;case 1:if(1===r);else{var h=this._getLocalToComponentTransform(k7,i,n),u=J5.invert(h,h);J5.multiply(t,u,t)}break;case 2:if(1===r){var l=this._parentTable[n];if(l>=0){var c=i.transforms.getTransform(l,k7);J5.multiply(t,c,t)}}break;case 3:var f=i.transforms.getTransform(n,k7);J5.multiply(t,f,t)}return t},e._getComponentToWorldTransform=function(){var t=this._cacheComponentToWorldTransform,e=this._componentNode;return t.position=e.worldPosition,t.rotation=e.worldRotation,t.scale=e.worldScale,t},e._getLocalToComponentTransform=function(t,e,i){var n=this._parentTable;J5.setIdentity(t);for(var r=n[i];r>=0;r=n[r]){var s=e.transforms.getTransform(r,O7);J5.multiply(t,s,t)}return t},e._getLocalToWorldTransform=function(t,e,i){return this._getLocalToComponentTransform(t,e,i),J5.multiply(t,this._getComponentToWorldTransform(),t),t},n(t,[{key:"allocatedPoseCount",get:function(){return this._poseAllocator.allocatedCount}},{key:"parentTable",get:function(){return this._parentTable}},{key:"_stackSize_debugging",get:function(){return this._poseAllocator.allocatedCount}}]),t}(),F7=function(){function t(t,e){this.index=-1,this._host=void 0,this._host=t,this.index=e}return t.prototype.destroy=function(){this._host._destroyTransformHandle(this.index)},t}(),L7=function(){function t(t,e){this.index=-1,this._host=void 0,this._host=t,this.index=e}return t.prototype.destroy=function(){this._host._destroyAuxiliaryCurveHandle(this.index)},t}(),V7=function(){function t(){this._context={deltaTime:0,indicativeWeight:0}}var e=t.prototype;return e.generate=function(t,e){return this._context.deltaTime=t,this._context.indicativeWeight=e,this._context},e.forkSubWeight=function(t,e){this._context.deltaTime=t.deltaTime,this._context.indicativeWeight=t.indicativeWeight*e},t}(),N7=function(){function t(){this._allocator=null}var e=t.prototype;return e._reset=function(t,e){this._allocator=new _7(t,e)},e.allocatePose=function(){return this._allocator,this._allocator.allocatePose()},e.destroyPose=function(t){return this._allocator,this._allocator.destroyPose(t)},n(t,[{key:"allocatedPoseCount",get:function(){return this._allocator,this._allocator.allocatedCount}}]),t}(),z7=uu;Kh(iQ+"UnaryCondition")((M7=function(){function t(){this.operator=B7&&B7(),this.operand=I7&&I7()}var e=t.prototype;return e.clone=function(){var e=new t;return e.operator=this.operator,e.operand=this.operand.clone(),e},e[P2]=function(t){var e=this.operator,i=this.operand,n=new Y7(e,!1),r=T6(t,i,1,n.setOperand,n);return n.reset(r),n},t}(),M7.Operator={TRUTHY:0,FALSY:1},B7=zh((D7=M7).prototype,"operator",[z7],(function(){return 0})),I7=zh(D7.prototype,"operand",[z7],(function(){return new x6})),D7));var U7,G7,H7,W7,j7,q7,X7,Y7=function(){function t(t,e){this._operator=t,this._operand=e,this._eval()}var e=t.prototype;return e.reset=function(t){this.setOperand(t)},e.setOperand=function(t){this._operand=t,this._eval()},e.eval=function(){return this._result},e._eval=function(){var t=this._operand;switch(this._operator){default:case 0:this._result=!!t;break;case 1:this._result=!t}},t}(),J7=function(){},K7=function(){for(var t=arguments.length,e=new Array(t),i=0;ir;case 5:return n>=r}},t}(),k9=uu,R9=Kh(iQ+"TriggerCondition")((d9=function(){function t(){this.trigger=p9&&p9()}var e=t.prototype;return e.clone=function(){var e=new t;return e.trigger=this.trigger,e},e[P2]=function(t){var e=new F9(!1),i=t.getVar(this.trigger);return A6(i,this.trigger)&&(D6(i.type,this.trigger),e.setTrigger(i.bind(e.setTrigger,e))),e},t}(),p9=zh(d9.prototype,"trigger",[k9],(function(){return""})),_9=d9))||_9,F9=function(){function t(t){this._triggered=!1,this._triggered=t}var e=t.prototype;return e.setTrigger=function(t){this._triggered=t},e.eval=function(){return this._triggered},t}(),L9=Kh(iQ+"StateMachineComponent")(m9=function(){function t(){}var e=t.prototype;return e.onMotionStateEnter=function(){},e.onMotionStateExit=function(){},e.onMotionStateUpdate=function(){},e.onStateMachineEnter=function(){},e.onStateMachineExit=function(){},t}())||m9,V9=Kh(iQ+"MotionSyncInfo")((y9=function(){this.group=v9&&v9()},v9=zh(y9.prototype,"group",[uu],(function(){return""})),g9=y9))||g9,N9=1e-5,z9=(b9=Kh(iQ+"PoseNodePlayMotion"),S9=G0((function(t){t.category="i18n:ENGINE.animation_graph.pose_graph_node_sub_categories.pose_nodes/"})),w9=function(t){return G0((function(e){e.factory=t}))}((E9=function(t){var e=new z9;return e.motion=t,e},{listEntries:function(){return[{arg:{type:"clip-motion"},menu:"i18n:ENGINE.animation_graph.pose_graph_node_sub_menus.play_or_sample_clip_motion"},{arg:{type:"animation-blend-1d"},menu:"i18n:ENGINE.animation_graph.pose_graph_node_sub_menus.play_or_sample_animation_blend_1d"},{arg:{type:"animation-blend-2d"},menu:"i18n:ENGINE.animation_graph.pose_graph_node_sub_menus.play_or_sample_animation_blend_2d"}]},create:function(t){var e=null;switch(t.type){case"clip-motion":e=new l6;break;case"animation-blend-1d":e=new k6;break;case"animation-blend-2d":e=new h8}return E9(e)}})),x9=H0({themeColor:"#227F9B"}),T9=s1({type:0}),A9=s1({type:0}),b9(C9=S9(C9=w9(C9=x9((D9=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;rN9&&(r=e*this.speedMultiplier/n),i?i.notifyUpdate(r,t.indicativeWeight):this._workspace.normalizedTime+=r,this._workspace.lastIndicativeWeight=t.indicativeWeight}},i.doEvaluate=function(t){if(this._workspace){var e=this._runtimeSyncRecord?this._runtimeSyncRecord.getSyncedEnterTime():this._workspace.normalizedTime;return this._workspace.motionEvalPort.evaluate(e,t)}return t.pushDefaultedPose()},n(e,[{key:"lastIndicativeWeight",get:function(){var t,e;return null!==(t=null==(e=this._workspace)?void 0:e.lastIndicativeWeight)&&void 0!==t?t:0}},{key:"elapsedMotionTime",get:function(){var t,e;return null!==(t=null==(e=this._workspace)?void 0:e.normalizedTime)&&void 0!==t?t:0}}]),e}(n1),B9=zh(D9.prototype,"motion",[uu],(function(){return new l6})),I9=zh(D9.prototype,"syncInfo",[uu],(function(){return new V9})),M9=v(D9.prototype,"startTime",[uu,T9],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),P9=v(D9.prototype,"speedMultiplier",[uu,A9],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),C9=D9))||C9)||C9)||C9)||C9),U9=function(t,e){this.normalizedTime=0,this.lastIndicativeWeight=0,this.motionEval=t,this.motionEvalPort=e};function G9(t){return t instanceof n1||t instanceof r1}var H9=function(){function t(t,e){this._rootPoseNode=t,this._countingPlayMotionNodes=e}var e=t.prototype;return e.bind=function(t){var e;null==(e=this._rootPoseNode)||e.bind(t)},e.settle=function(t){var e;null==(e=this._rootPoseNode)||e.settle(t)},e.reenter=function(){var t;null==(t=this._rootPoseNode)||t.reenter()},e.update=function(t){var e;null==(e=this._rootPoseNode)||e.update(t)},e.evaluate=function(t){var e,i;return null!==(e=null==(i=this._rootPoseNode)?void 0:i.evaluate(t,1))&&void 0!==e?e:null},e.countMotionTime=function(){var t=this._countingPlayMotionNodes;if(!t)return 0;for(var e=0,i=Number.NEGATIVE_INFINITY,n=0;ni&&(i=a,e=s)}return e},t}();function W9(t,e,i){void 0===i&&(i=!1);var n=t.outputNode,r=t.getShell(n).getBindings();if(r.length,0===r.length)return new H9(void 0,i?[]:void 0);var s=r[0];s.outputIndex,s.producer;var a=new Map,o=j9(t,s.producer,a,e);return new H9(o,i?Array.from(a.values()).filter((function(t){return t instanceof z9})):void 0)}function j9(t,e,i,n){var r=t.getShell(e),s=i.get(e);if(s)return s;var a=J$(e);"__callOnAfterDeserializeRecursive"in a&&a.__callOnAfterDeserializeRecursive(),a instanceof r1&&a.link(n);for(var o,h=a,u=[],l=p(r.getBindings());!(o=l()).done;){var c=o.value,f=c.producer,_=c.outputIndex,d=c.inputPath;if(G9(f)){var m=j9(t,f,i,n);if(m instanceof n1)Y9(h,d,m,_);else{var g=Z9(h,d,m,_);g&&u.push(g)}}else Y("There's a input bound to a node with unrecognized type.")}var y,v=new q9(u);return h instanceof n1?(h._setDependencyEvaluation(v),y=h):y=new X9(h,v),i.set(e,y),y}var q9=function(){function t(t){this._bindingEvaluations=void 0,this._bindingEvaluations=t}return t.prototype.evaluate=function(){for(var t,e=p(this._bindingEvaluations);!(t=e()).done;)t.value.evaluate()},t}(),X9=function(){function t(t,e){this._outputs=void 0,this._node=t,this._dependency=e,this._outputs=new Array(t.outputCount)}var e=t.prototype;return e.getDefaultOutput=function(){return this.getOutput(0)},e.getOutput=function(t){return this._outputs[t]},e.evaluate=function(){var t=this._node;this._dependency.evaluate(),t.selfEvaluate(this._outputs)},n(t,[{key:"node",get:function(){return this._node}},{key:"outputCount",get:function(){return this._outputs.length}}]),t}();function Y9(t,e,i,n){var r=e[0],s=e[1],a=void 0===s?-1:s;if(r in t)if(0===n){var o=t[r];if(a<0)return null!==o?void Y("Invalid binding: consumer node's input "+r+" should be leaved as evaluation before evaluation."):void(t[r]=i);Array.isArray(o)?a>=o.length?Y("Invalid binding: consumer node's input "+r+" have length "+o.length+" but the binding specified "+a):null===o[a]?o[a]=i:Y("Invalid binding: consumer node's input "+r+"["+a+"] should be leaved as null before evaluation"):Y("Invalid binding: consumer node's input "+r+" should be an array.")}else Y("Node "+i.toString()+" does not have specified output "+n+".");else Y("Invalid binding: consumer node has no property "+r)}var J9,K9=function(){function t(t,e,i,n){this._consumerNode=t,this._consumerPropertyKey=e,this._producerRecord=i,this._producerOutputIndex=n}return t.prototype.evaluate=function(){this._producerRecord.evaluate(),this._consumerNode[this._consumerPropertyKey]=this._producerRecord.getOutput(this._producerOutputIndex)},t}(),Q9=function(){function t(t,e,i,n,r){this._consumerNode=t,this._consumerPropertyKey=e,this._consumerElementIndex=i,this._producerRecord=n,this._producerOutputIndex=r}return t.prototype.evaluate=function(){this._producerRecord.evaluate(),this._consumerNode[this._consumerPropertyKey][this._consumerElementIndex]=this._producerRecord.getOutput(this._producerOutputIndex)},t}();function Z9(t,e,i,n){var r=e[0],s=e[1],a=void 0===s?-1:s;if(r in t){var o=t[r];if(a<0)return new K9(t,r,i,n);if(Array.isArray(o)){if(!(a>=o.length))return new Q9(t,r,a,i,n);Y("Invalid binding: consumer node's input "+r+" have length "+o.length+" but the binding specified "+a)}else Y("Invalid binding: consumer node's input "+r+" should be an array.")}else Y("Invalid binding: consumer node has no property "+r)}var $9=function(){function t(t,e,i){this.passthroughWeight=1,this._motionStates=[],this._proceduralPoseStates=[],this._topLevelEntry=void 0,this._topLevelExit=void 0,this._currentNode=void 0,this._pendingTransitionPath=[],this._activatedTransitions=[],this._activatedTransitionPool=Stt.createPool(4),this._updateContextGenerator=new V7,this._conditionEvaluationContext=new btt,this._additive=!1,this._additive=i.additive,this.name=e,this._controller=i.controller;var n=this._addStateMachine(t,null,i,e),r=n.entry,s=n.exit;this._topLevelEntry=r,this._topLevelExit=s,this._currentNode=r,r.increaseActiveReference(),this._resetTrigger=i.triggerResetter}var e=t.prototype;return e.settle=function(t){for(var e=this._proceduralPoseStates,i=e.length,n=0;n=16){at(14e3,16,"");break}var r=this._matchNextTransition(i);if(!r)break;var s=r.to,a=i;if(i=s,ttt(s)){if(s===a)break;this._activateTransition(t,r),t.length=0}else t.push(r)}t.length=0},e._resetStateTickFlagsAndWeights=function(){var t=this._currentNode,e=this._activatedTransitions;t.resetTickFlagsAndWeight();for(var i=0;i=0;--i){var s=e[i],a=0===i?this._currentNode:e[i-1].destination;if(s.update(t,a),s.done){this._dropActivatedTransitions(r);break}var o=s.normalizedElapsedTime*n;s.destination.increaseAbsoluteWeight(o),n*=1-s.normalizedElapsedTime,r=i-1}this._currentNode.increaseAbsoluteWeight(n)},e._dropActivatedTransitions=function(t){var e=this._activatedTransitions,i=this._activatedTransitionPool;t>=0&&e.length;var n=t+1,r=e[t],s=r.destination;r.path.length;var a=r.path[r.path.length-1];a.endEventBinding&&this._emit(a.endEventBinding),this._callExitMethods(this._currentNode);for(var o=0;o<=t;++o){var h=e[o];o!==t&&h.destination.decreaseActiveReference();for(var u=o===t?h.path.length-1:h.path.length,l=0;l=0?e:1+e}var ctt,ftt,_tt,dtt,ptt,mtt,gtt=function(t){function e(e,i){var n;return(n=t.call(this,e)||this).kind=void 0,n.kind=i,n}return s(e,t),e}(ntt),ytt=function(t){function e(e){var i;return(i=t.call(this,e)||this).kind=4,i}return s(e,t),e}(ntt),vtt=function(t){function e(e,i){var n;(n=t.call(this,e)||this).kind=5,n.elapsedTime=0,n.statusCache={progress:0},n._instantiatedPoseGraph=void 0,n._statusCache={progress:0},n._elapsedTime=0;var r=W9(e.graph,i,!0);return r.bind(i),n._instantiatedPoseGraph=r,n._statusCache.progress=0,n}s(e,t);var i=e.prototype;return i.settle=function(t){this._instantiatedPoseGraph.settle(t)},i.reenter=function(){this._statusCache.progress=0,this._instantiatedPoseGraph.reenter()},i.update=function(t){this._elapsedTime+=t.deltaTime,this._instantiatedPoseGraph.update(t)},i.evaluate=function(t){var e;return null!==(e=this._instantiatedPoseGraph.evaluate(t))&&void 0!==e?e:null},i.getStatus=function(){return this._statusCache.progress=ltt(this._elapsedTime),this._statusCache},i.countMotionTime=function(){return this._instantiatedPoseGraph.countMotionTime()},e}(rtt),btt=function(){function t(){this.sourceStateWeight=0,this._sourceState=void 0}var e=t.prototype;return e.set=function(t){this._sourceState=t,ttt(t)?(t.activeReferenceCount,this.sourceStateWeight=t.absoluteWeight):this.sourceStateWeight=0},e.unset=function(){this._sourceState=void 0,this.sourceStateWeight=0},n(t,[{key:"sourceStateMotionTimeNormalized",get:function(){var t=this._sourceState;switch(t&&(3===t.kind||5===t.kind)&&t.activeReferenceCount,t.kind){case 3:return t.normalizedTime;case 5:return t.countMotionTime();default:return 0}}}]),t}(),Stt=function(){function t(){this.normalizedElapsedTime=0,this.path=[],this._durationMultiplier=1}var e=t.prototype;return e.getAbsoluteDuration=function(t){return this._getAbsoluteDurationUnscaled(t)*this._durationMultiplier},e.update=function(t,e){if(ttt(e)){var i=this.getAbsoluteDuration(e);if(i<=0)this.normalizedElapsedTime=1;else{var n=this.normalizedElapsedTime*i,r=i-n,s=tn((n+Math.min(r,t))/i);this.normalizedElapsedTime=s}}else this.normalizedElapsedTime=1},t.createPool=function(e){return new ho((function(){return new t}),e,void 0)},e.reset=function(t,e){var i=e.to;ttt(i),this.normalizedElapsedTime=0,this.destination=i,this.path=[].concat(t,[e]);var n=i.activeReferenceCount;if(i.increaseActiveReference(),0===n)if(3===i.kind){var r=this.path[0],s=r.destinationStart,a=r.relativeDestinationStart?s:0===i.duration?0:s/i.duration;i.reenter(a)}else 5===i.kind&&i.reenter();i.activeReferenceCount,this._durationMultiplier=1-i.absoluteWeight},e._getAbsoluteDurationUnscaled=function(t){this.path.length;var e=this.path[0],i=e.duration;return e.normalizedDuration?(3===t.kind?t.duration:1)*i:i},n(t,[{key:"done",get:function(){return Zi(this.normalizedElapsedTime,1,1e-6)}}]),t}(),wtt=function(){function t(){this._groups=[]}var e=t.prototype;return e.register=function(t){var e=t.group,i=this._groups.find((function(t){return t.name===e}));return i||(i=new xtt(e),this._groups.push(i)),i.addMember()},e.sync=function(){for(var t,e=p(this._groups);!(t=e()).done;)t.value.sync()},t}(),xtt=function(){function t(t){this._lastLeader=void 0,this._records=[],this.name=t}var e=t.prototype;return e.addMember=function(){var t=new Ttt;return this._records.push(t),t},e.sync=function(){var t=this._records,e=t.length,i=this._lastLeader;if(this._lastLeader=void 0,!t.every((function(t){return!t.active}))){t.sort((function(t,e){var i=t.active?t.weight:-1;return(e.active?e.weight:-1)-i}));var n=0,r=t[0].weight;if(t[n]!==i)for(var s=0;s=0&&this._layerRecords.length,this._layerRecords[t].weight},i.setLayerWeight=function(t,e){t>=0&&this._layerRecords.length,this._layerRecords[t].weight=e},i.getLayerTopLevelStateMachineEvaluation=function(t){return this._layerRecords[t].stateMachineEvaluation},i.overrideClips=function(t){for(var e=this._layerRecords,i=e.length,n=0;n0||delete e[t])},e.apply=function(t){var e,i,n,r=this._transformApplyFlags,s=this._properties,a=s.position,o=s.scale,h=s.rotation,u=s.eulerAngles;r&&(a&&1&r&&(e=a.result),o&&4&r&&(i=o.result),u&&8&r&&(n=u.result),h&&2&r&&(n=h.result),(n||e||i)&&t.setRTS(n,e,i),this._transformApplyFlags=0)},n(t,[{key:"empty",get:function(){var t=this._properties;return!(t.position||t.rotation||t.eulerAngles||t.scale)}}]),t}(),Gtt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.apply=function(e){var i=this._properties,n=i.position,r=i.scale,s=i.rotation,a=i.eulerAngles;n&&n.accumulatedWeight&&(this._transformApplyFlags|=1,n.accumulatedWeight<1&&n.blend(e.position,1-n.accumulatedWeight)),r&&r.accumulatedWeight&&(this._transformApplyFlags|=4,r.accumulatedWeight<1&&r.blend(e.scale,1-r.accumulatedWeight)),a&&a.accumulatedWeight&&(this._transformApplyFlags|=8,a.accumulatedWeight<1&&a.blend(e.eulerAngles,1-a.accumulatedWeight)),s&&s.accumulatedWeight&&(this._transformApplyFlags|=2,s.accumulatedWeight<1&&s.blend(e.rotation,1-s.accumulatedWeight)),t.prototype.apply.call(this,e),null==n||n.reset(),null==r||r.reset(),null==s||s.reset(),null==a||a.reset()},i._createVec3BlendState=function(){return new Ntt},i._createQuatBlendState=function(){return new ztt},e}(Utt),Htt=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.prototype.createNodeBlendState=function(){return new Gtt},e}(Ltt);function Wtt(t,e,i,n,r){var s=i+r;if(1!==r||i){if(s){var a=r/s;ir.lerp(t,t,n,a)}}else ir.copy(t,n);return s}function jtt(t,e,i,n,r){var s=i+r;if(1!==r||i){if(s){var a=r/s;kr.slerp(t,e,n,a)}}else kr.copy(t,n);return s}var qtt=t("aB",Kh((Ftt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r=0?this._crossFades.fastRemoveAt(e):ht(3907)},i.update=function(t){var e=this._delayEvents,i=this._crossFades,n=this._sockets,r=i.array;for(i.i=0;i.i=0?this._anims.fastRemoveAt(e):ht(3907)},i.pushDelayEvent=function(t,e,i){this._delayEvents.push({fn:t,thisArg:e,args:i})},i.addSockets=function(t,e){for(var i=this,n=function(){var n=e[r];if(i._sockets.find((function(t){return t.target===n.target})))return 1;var s=t.getChildByPath(n.path),a=n.target&&s&&DY(s,t);a&&i._sockets.push({target:n.target,transform:a})},r=0;r=h.easeDuration){a=o+1,h.easeTime=h.easeDuration;break}}if(a!==i.length){for(var c=a;c=0||(this._clips.push(t),this.createState(t)))}}]),e}(Bo(yg)),net.EventType=cQ,v(($tt=net).prototype,"clips",[Jtt],Object.getOwnPropertyDescriptor($tt.prototype,"clips"),$tt.prototype),v($tt.prototype,"defaultClip",[Ktt],Object.getOwnPropertyDescriptor($tt.prototype,"defaultClip"),$tt.prototype),tet=zh($tt.prototype,"playOnLoad",[uu],(function(){return!1})),eet=zh($tt.prototype,"_clips",[Qtt],(function(){return[]})),iet=zh($tt.prototype,"_defaultClip",[uu],(function(){return null})),Ztt=$tt))||Ztt)||Ztt));function uet(t,e){return t===e||!!t&&!!e&&t._uuid===e._uuid&&t._uuid}A.Animation=het,A.AnimationComponent=het,le(het,"cc.AnimationComponent"),function(t){t.PLAYED="play",t.PAUSED="pause",t.STOPPED="stop",t.SEEKED="seeked",t.ENDED="ended",t.INTERRUPTION_BEGIN="interruptionBegin",t.INTERRUPTION_END="interruptionEnd",t.USER_GESTURE="on_gesture"}(ret||(ret={})),function(t){t[t.DOM_AUDIO=0]="DOM_AUDIO",t[t.WEB_AUDIO=1]="WEB_AUDIO",t[t.MINIGAME_AUDIO=2]="MINIGAME_AUDIO",t[t.NATIVE_AUDIO=3]="NATIVE_AUDIO",t[t.UNKNOWN_AUDIO=4]="UNKNOWN_AUDIO"}(set||(set={})),function(t){t[t.INIT=0]="INIT",t[t.PLAYING=1]="PLAYING",t[t.PAUSED=2]="PAUSED",t[t.STOPPED=3]="STOPPED",t[t.INTERRUPTED=4]="INTERRUPTED"}(aet||(aet={}));var cet=t("aG",function(){function t(){this._bufferView=void 0,this._normalizeFactor=1;for(var t=arguments.length,e=new Array(t),i=0;i=0;s--){var a=i[s];if("stop"===a.op){n.push(a);break}if("seek"===a.op)r||(n.push(a),r=!0);else{if(r){n.push(a);break}0===n.length&&n.push(a)}}t._operationQueue=n.reverse()}var _et,det=0;function pet(t,e){var i;e.invoking||(e.invoking=!0,(i=e.func).call.apply(i,[t].concat(e.args)).then((function(){e.invoking=!1,t._operationQueue.shift(),t._eventTarget.emit(e.id.toString()),t._eventTarget.off(e.id.toString()),fet(t);var i=t._operationQueue[0];i&&pet(t,i)})).catch((function(){})))}function met(t,e,i){var n=i.value;i.value=function(){for(var t=this,i=arguments.length,r=new Array(i),s=0;s=this.duration&&(this._startTime=this._now(),this._startOffset=0),e%this.duration},e.start=function(){this._isPaused=!1,this._startTime=this._now()},e.pause=function(){this._isPaused||(this._isPaused=!0,this._startOffset=this._calculateCurrentTime())},e.stop=function(){this._isPaused=!0,this._startOffset=0},e.seek=function(t){this._startTime=this._now(),this._startOffset=$i(t,0,this.duration)},n(t,[{key:"duration",get:function(){return this._nativeAudio.duration}},{key:"currentTime",get:function(){return this._isPaused?this._startOffset:this._calculateCurrentTime()}}]),t}(),Tet=function(){function t(){this._audioBufferDataMap={}}var e=t.prototype;return e.addCache=function(t,e){this._audioBufferDataMap[t]?at(5204,t):this._audioBufferDataMap[t]={usedCount:1,audioBuffer:e}},e.retainCache=function(t){var e=this._audioBufferDataMap[t];e?e.usedCount++:at(5203,t)},e.getCache=function(t){var e=this._audioBufferDataMap[t];return null==e?void 0:e.audioBuffer},e.tryReleasingCache=function(t){var e=this._audioBufferDataMap[t];e?--e.usedCount<=0&&delete this._audioBufferDataMap[t]:at(5203,t)},t}(),Aet=new Tet,Cet=window.AudioContext||window.webkitAudioContext||window.mozAudioContext,Det="on-context-running",Bet=function(){function t(){var t=this;this._eventTarget=void 0,this._context=void 0,this._isRunning=!1,this._context=new(window.AudioContext||window.webkitAudioContext||window.mozAudioContext),this._eventTarget=new Io,this._context.onstatechange=function(){"running"===t._context.state?(t._isRunning=!0,t._eventTarget.emit(Det)):t._isRunning=!1}}var e=t.prototype;return e.onceRunning=function(t,e){this._eventTarget.once(Det,t,e)},e.offRunning=function(t,e){this._eventTarget.off(Det,t,e)},e.decodeAudioData=function(t){var e=this;return new Promise((function(i,n){var r=e._context.decodeAudioData(t,(function(t){i(t)}),(function(t){console.error("failed to load Web Audio",t)}));null==r||r.catch(n)}))},e.runContext=function(){var t=this;return new Promise((function(e){if(t.isRunning)e();else{var i=t._context;if(i.resume){if("suspended"===i.state)i.resume().catch((function(t){Y("runContext error",t)}));else if("running"===i.state)return void e();var n=document.getElementById("GameCanvas"),r=function t(){i.resume().then((function(){null==n||n.removeEventListener("touchend",t,{capture:!0}),null==n||n.removeEventListener("mouseup",t,{capture:!0}),e()})).catch((function(t){Y("onGesture resume error",t)}))};null==n||n.addEventListener("touchend",r,{capture:!0}),null==n||n.addEventListener("mouseup",r,{capture:!0})}else e()}}))},e.createBufferSource=function(t,e){var i=this._context.createBufferSource();return void 0!==t&&(i.buffer=t),void 0!==e&&(i.loop=e),i},e.createGain=function(t){void 0===t&&(t=1);var e=this._context.createGain();return this.setGainValue(e,t),e},e.setGainValue=function(t,e){if(t.gain.setTargetAtTime)try{t.gain.setTargetAtTime(e,this._context.currentTime,0)}catch(i){t.gain.setTargetAtTime(e,this._context.currentTime,.01)}else t.gain.value=e},e.connectContext=function(t){this._context&&t.connect(this._context.destination)},n(t,[{key:"isRunning",get:function(){return this._isRunning}},{key:"currentTime",get:function(){return this._context.currentTime}}]),t}();Bet.support=!!Cet,Bet.support&&(vet=new Bet);var Iet,Met,Pet,Eet,Oet=function(){function t(t,e,i){this._duration=void 0,this._bufferSourceNode=void 0,this._onPlayCb=void 0,this._currentTimer=0,this._url=void 0,this._onEndCb=void 0,this._duration=t.duration,this._url=i,this._bufferSourceNode=vet.createBufferSource(t,!1);var n=vet.createGain(e);this._bufferSourceNode.connect(n),vet.connectContext(n)}var e=t.prototype;return e.play=function(){var t=this;this._bufferSourceNode.start(),vet.runContext().then((function(){null==t.onPlay||t.onPlay(),t._currentTimer=window.setTimeout((function(){Aet.tryReleasingCache(t._url),null==t.onEnd||t.onEnd()}),1e3*t._duration)})).catch((function(t){Y("play error",t)}))},e.stop=function(){clearTimeout(this._currentTimer),Aet.tryReleasingCache(this._url),this._bufferSourceNode.stop(),this._bufferSourceNode.disconnect(),this._bufferSourceNode.buffer=null},n(t,[{key:"onPlay",get:function(){return this._onPlayCb},set:function(t){this._onPlayCb=t}},{key:"onEnd",get:function(){return this._onEndCb},set:function(t){this._onEndCb=t}}]),t}(),ket=(yet=function(){function t(t,e){this._src=void 0,this._audioBuffer=void 0,this._sourceNode=void 0,this._gainNode=void 0,this._currentTimer=0,this._volume=1,this._loop=!1,this._state=aet.INIT,this._audioTimer=void 0,this._runningCallback=void 0,this._eventTarget=new Io,this._operationQueue=[],this._audioBuffer=t,this._audioTimer=new xet(t),this._gainNode=vet.createGain(),vet.connectContext(this._gainNode),this._src=e,XO.on(qO.EVENT_PAUSE,this._onInterruptedBegin,this),XO.on(qO.EVENT_RESUME,this._onInterruptedEnd,this)}var e=t.prototype;return e.destroy=function(){window.clearTimeout(this._currentTimer),this._audioTimer.destroy(),this._audioBuffer&&(this._audioBuffer=null),Aet.tryReleasingCache(this._src),XO.off(qO.EVENT_PAUSE,this._onInterruptedBegin,this),XO.off(qO.EVENT_RESUME,this._onInterruptedEnd,this),this.offRunning()},t.load=function(e){return new Promise((function(i,n){t.loadNative(e).then((function(n){i(new t(n,e))})).catch(n)}))},t.loadNative=function(t){return new Promise((function(e,i){var n=Aet.getCache(t);if(n)return Aet.retainCache(t),void e(n);var r=new XMLHttpRequest,s="load audio failed: "+t+", status: ";r.open("GET",t,!0),r.responseType="arraybuffer",r.onload=function(){200===r.status||0===r.status?vet.decodeAudioData(r.response).then((function(i){Aet.addCache(t,i),e(i)})).catch((function(e){Y("loadNative error",t,e)})):i(new Error(""+s+r.status+"(no response)"))},r.onerror=function(){i(new Error(""+s+r.status+"(error)"))},r.ontimeout=function(){i(new Error(""+s+r.status+"(time out)"))},r.onabort=function(){i(new Error(""+s+r.status+"(abort)"))},r.send(null)}))},t.loadOneShotAudio=function(e,i){return new Promise((function(n,r){t.loadNative(e).then((function(t){var r=new Oet(t,i,e);n(r)})).catch(r)}))},e.getPCMData=function(t){return new cet(this._audioBuffer.getChannelData(t),1)},e._onInterruptedBegin=function(){var t=this;this._state===aet.PLAYING&&this.pause().then((function(){t._state=aet.INTERRUPTED,t._eventTarget.emit(ret.INTERRUPTION_BEGIN)})).catch((function(t){Y("_onInterruptedBegin error",t)}))},e._onInterruptedEnd=function(){var t=this;this._state===aet.INTERRUPTED&&this.play().then((function(){t._eventTarget.emit(ret.INTERRUPTION_END)})).catch((function(t){Y("_onInterruptedEnd error",t)}))},e.offRunning=function(){this._runningCallback&&(vet.offRunning(this._runningCallback),this._runningCallback=void 0)},e.seek=function(t){var e=this;return new Promise((function(i){e.offRunning(),e._audioTimer.seek(t),e._state===aet.PLAYING?e._doPlay().then(i).catch((function(t){Y("seek error",t)})):i()}))},e.play=function(){return this.offRunning(),this._doPlay()},e._doPlay=function(){var t=this;return new Promise((function(e){vet.isRunning?(t._startSourceNode(),e()):(t.offRunning(),t._runningCallback=function(){t._startSourceNode(),e()},vet.onceRunning(t._runningCallback),vet.runContext().catch((function(t){Y("doPlay error",t)})))}))},e._startSourceNode=function(){var t=this;this._stopSourceNode(),this._sourceNode=vet.createBufferSource(this._audioBuffer,this.loop),this._sourceNode.connect(this._gainNode),this._sourceNode.loop=this._loop,this._sourceNode.start(0,this._audioTimer.currentTime),this._state=aet.PLAYING,this._audioTimer.start(),window.clearTimeout(this._currentTimer),this._currentTimer=window.setTimeout((function e(){t.loop?t._currentTimer=window.setTimeout(e,1e3*t._audioBuffer.duration):(t._audioTimer.stop(),t._eventTarget.emit(ret.ENDED),t._state=aet.INIT)}),1e3*(this._audioBuffer.duration-this._audioTimer.currentTime))},e._stopSourceNode=function(){try{this._sourceNode&&(this._sourceNode.stop(),this._sourceNode.disconnect(),this._sourceNode.buffer=null,this._sourceNode=void 0)}catch(t){}},e.pause=function(){return this.offRunning(),this._state===aet.PLAYING&&this._sourceNode?(this._audioTimer.pause(),this._state=aet.PAUSED,window.clearTimeout(this._currentTimer),this._stopSourceNode(),Promise.resolve()):Promise.resolve()},e.stop=function(){return this.offRunning(),this._sourceNode?(this._audioTimer.stop(),this._state=aet.STOPPED,window.clearTimeout(this._currentTimer),this._stopSourceNode(),Promise.resolve()):(this._audioTimer.stop(),this._state=aet.STOPPED,Promise.resolve())},e.onInterruptionBegin=function(t){this._eventTarget.on(ret.INTERRUPTION_BEGIN,t)},e.offInterruptionBegin=function(t){this._eventTarget.off(ret.INTERRUPTION_BEGIN,t)},e.onInterruptionEnd=function(t){this._eventTarget.on(ret.INTERRUPTION_END,t)},e.offInterruptionEnd=function(t){this._eventTarget.off(ret.INTERRUPTION_END,t)},e.onEnded=function(t){this._eventTarget.on(ret.ENDED,t)},e.offEnded=function(t){this._eventTarget.off(ret.ENDED,t)},n(t,[{key:"sampleRate",get:function(){return this._audioBuffer.sampleRate}},{key:"src",get:function(){return this._src}},{key:"type",get:function(){return set.WEB_AUDIO}},{key:"state",get:function(){return this._state}},{key:"loop",get:function(){return this._loop},set:function(t){this._loop=t,this._sourceNode&&(this._sourceNode.loop=t)}},{key:"volume",get:function(){return this._volume},set:function(t){t=tn(t),this._volume=t,vet.setGainValue(this._gainNode,t)}},{key:"duration",get:function(){return this._audioBuffer.duration}},{key:"currentTime",get:function(){return this._audioTimer.currentTime}}]),t}(),v(yet.prototype,"seek",[met],Object.getOwnPropertyDescriptor(yet.prototype,"seek"),yet.prototype),v(yet.prototype,"play",[met],Object.getOwnPropertyDescriptor(yet.prototype,"play"),yet.prototype),v(yet.prototype,"pause",[met],Object.getOwnPropertyDescriptor(yet.prototype,"pause"),yet.prototype),v(yet.prototype,"stop",[met],Object.getOwnPropertyDescriptor(yet.prototype,"stop"),yet.prototype),yet),Ret=function(){function t(t){this._audio=void 0,this._audio=t}var e=t.prototype;return e.play=function(){this._audio.play()},e.stop=function(){this._audio.stop()},n(t,[{key:"onPlay",get:function(){return this._audio.onPlay},set:function(t){this._audio.onPlay=t}},{key:"onEnd",get:function(){return this._audio.onEnd},set:function(t){this._audio.onEnd=t}}]),t}(),Fet=function(){function t(t){this._player=void 0,this._player=t}t.load=function(e,i){return new Promise((function(n,r){(null==i?void 0:i.audioLoadMode)!==set.DOM_AUDIO&&Bet.support?ket.load(e).then((function(e){n(new t(e))})).catch(r):(Bet.support||at(5201),wet.load(e).then((function(e){n(new t(e))})).catch(r))}))};var e=t.prototype;return e.destroy=function(){this._player.destroy()},t.loadNative=function(t,e){return(null==e?void 0:e.audioLoadMode)!==set.DOM_AUDIO&&Bet.support?ket.loadNative(t):(Bet.support||at(5201),wet.loadNative(t))},t.loadOneShotAudio=function(t,e,i){return new Promise((function(n,r){(null==i?void 0:i.audioLoadMode)!==set.DOM_AUDIO&&Bet.support?ket.loadOneShotAudio(t,e).then((function(t){n(new Ret(t))})).catch(r):(Bet.support||at(5201),wet.loadOneShotAudio(t,e).then((function(t){n(new Ret(t))})).catch(r))}))},e.getPCMData=function(t){return this._player.getPCMData(t)},e.seek=function(t){return this._player.seek(t)},e.play=function(){return this._player.play()},e.pause=function(){return this._player.pause()},e.stop=function(){return this._player.stop()},e.onInterruptionBegin=function(t){this._player.onInterruptionBegin(t)},e.offInterruptionBegin=function(t){this._player.offInterruptionBegin(t)},e.onInterruptionEnd=function(t){this._player.onInterruptionEnd(t)},e.offInterruptionEnd=function(t){this._player.offInterruptionEnd(t)},e.onEnded=function(t){this._player.onEnded(t)},e.offEnded=function(t){this._player.offEnded(t)},n(t,[{key:"src",get:function(){return this._player.src}},{key:"type",get:function(){return this._player.type}},{key:"state",get:function(){return this._player.state}},{key:"loop",get:function(){return this._player.loop},set:function(t){this._player.loop=t}},{key:"volume",get:function(){return this._player.volume},set:function(t){this._player.volume=t}},{key:"duration",get:function(){return this._player.duration}},{key:"currentTime",get:function(){return this._player.currentTime}},{key:"sampleRate",get:function(){return this._player.sampleRate}}]),t}();Fet.maxAudioChannel=24;var Let=t("aF",Kh("cc.AudioClip")((Eet=function(t){function e(e){var i;return(i=t.call(this,e)||this)._duration=Pet&&Pet(),i._loadMode=set.UNKNOWN_AUDIO,i._meta=null,i._player=null,i}s(e,t);var i=e.prototype;return i.destroy=function(){var e,i=t.prototype.destroy.call(this);return null==(e=this._player)||e.destroy(),this._player=null,this._meta&&(this._meta.player=null),i},i.validate=function(){return!!this._meta},i.getDuration=function(){return this._duration?this._duration:this._meta?this._meta.duration:0},i.getCurrentTime=function(){return this._player?this._player.currentTime:0},i.getVolume=function(){return this._player?this._player.volume:0},i.getLoop=function(){return!!this._player&&this._player.loop},i.setCurrentTime=function(t){var e;null==(e=this._player)||e.seek(t).catch((function(){}))},i.setVolume=function(t){this._player&&(this._player.volume=t)},i.setLoop=function(t){this._player&&(this._player.loop=t)},i.play=function(){var t;null==(t=this._player)||t.play().catch((function(){}))},i.pause=function(){var t;null==(t=this._player)||t.pause().catch((function(){}))},i.stop=function(){var t;null==(t=this._player)||t.stop().catch((function(){}))},i.playOneShot=function(t){void 0===t&&(t=1),this._nativeAsset&&Fet.loadOneShotAudio(this._nativeAsset.url,t).then((function(t){t.play()})).catch((function(){}))},n(e,[{key:"duration",set:function(t){this._duration=t}},{key:"_nativeAsset",get:function(){return this._meta},set:function(t){this._meta=t,t?(this._loadMode=t.type,this._player=t.player):(this._meta=null,this._loadMode=set.UNKNOWN_AUDIO,this._duration=0)}},{key:"_nativeDep",get:function(){return{uuid:this._uuid,audioLoadMode:this.loadMode,ext:this._native,__isNative__:!0}}},{key:"loadMode",get:function(){return this._loadMode}},{key:"state",get:function(){return this._player?this._player.state:aet.INIT}}]),e}(Cm),Eet.AudioType=set,Pet=zh((Met=Eet).prototype,"_duration",[uu],(function(){return 0})),v(Met.prototype,"_nativeDep",[Gu],Object.getOwnPropertyDescriptor(Met.prototype,"_nativeDep"),Met.prototype),Iet=Met))||Iet);function Vet(t,e,i){Fet.load(t,{audioLoadMode:e.audioLoadMode}).then((function(e){var n={player:e,url:t,duration:e.duration,type:e.type};i(null,n)})).catch((function(t){i(t)}))}function Net(t,e,i,n){var r=new Let;r._nativeUrl=t,r._nativeAsset=e,r.duration=e.duration,n(null,r)}A.AudioClip=Let,Mx.register({".mp3":Vet,".ogg":Vet,".wav":Vet,".m4a":Vet}),Hx.register({".mp3":Net,".ogg":Net,".wav":Net,".m4a":Net});var zet,Uet,Get,Het,Wet,jet,qet,Xet,Yet,Jet,Ket=new(function(){function t(){this._oneShotAudioInfoList=[],this._audioPlayerInfoList=[]}var e=t.prototype;return e._findIndex=function(t,e){return t.findIndex((function(t){return t.audio===e}))},e._tryAddPlaying=function(t,e){var i=this._findIndex(t,e);if(i>-1)return t[i].playTime=performance.now(),!1;var n={audio:e,playTime:performance.now()};return t.push(n),!0},e.addPlaying=function(t){t instanceof Fet?this._tryAddPlaying(this._audioPlayerInfoList,t):this._tryAddPlaying(this._oneShotAudioInfoList,t)},e._tryRemovePlaying=function(t,e){var i=this._findIndex(t,e);return-1!==i&&(be(t,i),!0)},e.removePlaying=function(t){t instanceof Fet?this._tryRemovePlaying(this._audioPlayerInfoList,t):this._tryRemovePlaying(this._oneShotAudioInfoList,t)},e.discardOnePlayingIfNeeded=function(){var t;this._audioPlayerInfoList.length+this._oneShotAudioInfoList.length0?this._oneShotAudioInfoList.forEach((function(e){(!t||e.playTime0){for(var i=0,n=this._objects;i0){for(var r=0;ri&&(r.length=i),t._maxCountMap[n]=i;else for(var n in t._defaultMaxCount=i,t._poolsMap){var r;(r=t._poolsMap[n]).length>i&&(r.length=i),n in t._maxCountMap&&(t._maxCountMap[n]=i)}},t.clearPool=function(e){if(void 0===e&&(e=null),null!==e){var i=String(e);null!==(r=i in t._poolsMap?t._poolsMap[i]:null)&&r.length>0&&(r.length=0)}else for(var n in t._poolsMap){var r;(r=t._poolsMap[n]).length=0}},t.borrowObject=function(e){var i=String(e),n=i in t._poolsMap?t._poolsMap[i]:null;if(null!==n&&n.length>0){var r=n.pop();return r._isInPool=!1,r}var s=new e;return s._onClear(),s},t.prototype.returnToPool=function(){this._onClear(),t._returnObject(this)},t._hashCode=0,t._defaultMaxCount=3e3,t._maxCountMap={},t._poolsMap={},t}();t.BaseObject=e}(rit),function(t){var e=function(){function t(t,e,i,n,r,s){void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=1),void 0===r&&(r=0),void 0===s&&(s=0),this.a=t,this.b=e,this.c=i,this.d=n,this.tx=r,this.ty=s}return t.prototype.toString=function(){return"[object dragonBones.Matrix] a:"+this.a+" b:"+this.b+" c:"+this.c+" d:"+this.d+" tx:"+this.tx+" ty:"+this.ty},t.prototype.copyFrom=function(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this},t.prototype.copyFromArray=function(t,e){return void 0===e&&(e=0),this.a=t[e],this.b=t[e+1],this.c=t[e+2],this.d=t[e+3],this.tx=t[e+4],this.ty=t[e+5],this},t.prototype.identity=function(){return this.a=this.d=1,this.b=this.c=0,this.tx=this.ty=0,this},t.prototype.concat=function(t){var e=this.a*t.a,i=0,n=0,r=this.d*t.d,s=this.tx*t.a+t.tx,a=this.ty*t.d+t.ty;return 0===this.b&&0===this.c||(e+=this.b*t.c,i+=this.b*t.d,n+=this.c*t.a,r+=this.c*t.b),0===t.b&&0===t.c||(i+=this.a*t.b,n+=this.d*t.c,s+=this.ty*t.c,a+=this.tx*t.b),this.a=e,this.b=i,this.c=n,this.d=r,this.tx=s,this.ty=a,this},t.prototype.invert=function(){var t=this.a,e=this.b,i=this.c,n=this.d,r=this.tx,s=this.ty;if(0===e&&0===i)return this.b=this.c=0,0===t||0===n?this.a=this.b=this.tx=this.ty=0:(t=this.a=1/t,n=this.d=1/n,this.tx=-t*r,this.ty=-n*s),this;var a=t*n-e*i;if(0===a)return this.a=this.d=1,this.b=this.c=0,this.tx=this.ty=0,this;a=1/a;var o=this.a=n*a;return e=this.b=-e*a,i=this.c=-i*a,n=this.d=t*a,this.tx=-(o*r+i*s),this.ty=-(e*r+n*s),this},t.prototype.transformPoint=function(t,e,i,n){void 0===n&&(n=!1),i.x=this.a*t+this.c*e,i.y=this.b*t+this.d*e,n||(i.x+=this.tx,i.y+=this.ty)},t.prototype.transformRectangle=function(t,e){void 0===e&&(e=!1);var i=this.a,n=this.b,r=this.c,s=this.d,a=e?0:this.tx,o=e?0:this.ty,h=t.x,u=t.y,l=h+t.width,c=u+t.height,f=i*h+r*u+a,_=n*h+s*u+o,d=i*l+r*u+a,p=n*l+s*u+o,m=i*l+r*c+a,g=n*l+s*c+o,y=i*h+r*c+a,v=n*h+s*c+o,b=0;f>d&&(b=f,f=d,d=b),m>y&&(b=m,m=y,y=b),t.x=Math.floor(fy?d:y)-t.x),_>p&&(b=_,_=p,p=b),g>v&&(b=g,g=v,v=b),t.y=Math.floor(_v?p:v)-t.y)},t}();t.Matrix=e}(rit),function(t){var e=function(){function t(t,e,i,n,r,s){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=1),void 0===s&&(s=1),this.x=t,this.y=e,this.skew=i,this.rotation=n,this.scaleX=r,this.scaleY=s}return t.normalizeRadian=function(t){return(t=(t+Math.PI)%(2*Math.PI))+(t>0?-Math.PI:Math.PI)},t.prototype.toString=function(){return"[object dragonBones.Transform] x:"+this.x+" y:"+this.y+" skewX:"+180*this.skew/Math.PI+" skewY:"+180*this.rotation/Math.PI+" scaleX:"+this.scaleX+" scaleY:"+this.scaleY},t.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.skew=t.skew,this.rotation=t.rotation,this.scaleX=t.scaleX,this.scaleY=t.scaleY,this},t.prototype.identity=function(){return this.x=this.y=0,this.skew=this.rotation=0,this.scaleX=this.scaleY=1,this},t.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this.skew+=t.skew,this.rotation+=t.rotation,this.scaleX*=t.scaleX,this.scaleY*=t.scaleY,this},t.prototype.minus=function(t){return this.x-=t.x,this.y-=t.y,this.skew-=t.skew,this.rotation-=t.rotation,this.scaleX/=t.scaleX,this.scaleY/=t.scaleY,this},t.prototype.fromMatrix=function(e){var i=this.scaleX,n=this.scaleY,r=t.PI_Q;this.x=e.tx,this.y=e.ty,this.rotation=Math.atan(e.b/e.a);var s=Math.atan(-e.c/e.d);return this.scaleX=this.rotation>-r&&this.rotation-r&&s=0&&this.scaleX<0&&(this.scaleX=-this.scaleX,this.rotation=this.rotation-Math.PI),n>=0&&this.scaleY<0&&(this.scaleY=-this.scaleY,s-=Math.PI),this.skew=s-this.rotation,this},t.prototype.toMatrix=function(t){return 0===this.rotation?(t.a=1,t.b=0):(t.a=Math.cos(this.rotation),t.b=Math.sin(this.rotation)),0===this.skew?(t.c=-t.b,t.d=t.a):(t.c=-Math.sin(this.skew+this.rotation),t.d=Math.cos(this.skew+this.rotation)),1!==this.scaleX&&(t.a*=this.scaleX,t.b*=this.scaleX),1!==this.scaleY&&(t.c*=this.scaleY,t.d*=this.scaleY),t.tx=this.x,t.ty=this.y,this},t.PI=Math.PI,t.PI_D=2*Math.PI,t.PI_H=Math.PI/2,t.PI_Q=Math.PI/4,t.RAD_DEG=180/Math.PI,t.DEG_RAD=Math.PI/180,t}();t.Transform=e}(rit),function(t){var e=function(){function t(t,e,i,n,r,s,a,o){void 0===t&&(t=1),void 0===e&&(e=1),void 0===i&&(i=1),void 0===n&&(n=1),void 0===r&&(r=0),void 0===s&&(s=0),void 0===a&&(a=0),void 0===o&&(o=0),this.alphaMultiplier=t,this.redMultiplier=e,this.greenMultiplier=i,this.blueMultiplier=n,this.alphaOffset=r,this.redOffset=s,this.greenOffset=a,this.blueOffset=o}return t.prototype.copyFrom=function(t){this.alphaMultiplier=t.alphaMultiplier,this.redMultiplier=t.redMultiplier,this.greenMultiplier=t.greenMultiplier,this.blueMultiplier=t.blueMultiplier,this.alphaOffset=t.alphaOffset,this.redOffset=t.redOffset,this.greenOffset=t.greenOffset,this.blueOffset=t.blueOffset},t.prototype.identity=function(){this.alphaMultiplier=this.redMultiplier=this.greenMultiplier=this.blueMultiplier=1,this.alphaOffset=this.redOffset=this.greenOffset=this.blueOffset=0},t}();t.ColorTransform=e}(rit),function(t){var e=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.x=t,this.y=e}return t.prototype.copyFrom=function(t){this.x=t.x,this.y=t.y},t.prototype.clear=function(){this.x=this.y=0},t}();t.Point=e}(rit),function(t){var e=function(){function t(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.x=t,this.y=e,this.width=i,this.height=n}return t.prototype.copyFrom=function(t){this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height},t.prototype.clear=function(){this.x=this.y=0,this.width=this.height=0},t}();t.Rectangle=e}(rit),function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.ints=[],e.floats=[],e.strings=[],e}return nit(e,t),e.toString=function(){return"[class dragonBones.UserData]"},e.prototype._onClear=function(){this.ints.length=0,this.floats.length=0,this.strings.length=0},e.prototype.addInt=function(t){this.ints.push(t)},e.prototype.addFloat=function(t){this.floats.push(t)},e.prototype.addString=function(t){this.strings.push(t)},e.prototype.getInt=function(t){return void 0===t&&(t=0),t>=0&&t=0&&t=0&&t=t&&(i=0),!(this.sortedBones.indexOf(r)>=0)){var s=!1;for(var a in this.constraints){var o=this.constraints[a];if(o.root===r&&this.sortedBones.indexOf(o.target)<0){s=!0;break}}s||null!==r.parent&&this.sortedBones.indexOf(r.parent)<0||(this.sortedBones.push(r),n++)}}}},i.prototype.cacheFrames=function(t){if(!(this.cacheFrameRate>0))for(var e in this.cacheFrameRate=t,this.animations)this.animations[e].cacheFrames(this.cacheFrameRate)},i.prototype.setCacheFrame=function(t,e){var i=this.parent.cachedFrames,n=i.length;return i.length+=10,i[n]=t.a,i[n+1]=t.b,i[n+2]=t.c,i[n+3]=t.d,i[n+4]=t.tx,i[n+5]=t.ty,i[n+6]=e.rotation,i[n+7]=e.skew,i[n+8]=e.scaleX,i[n+9]=e.scaleY,n},i.prototype.getCacheFrame=function(t,e,i){var n=this.parent.cachedFrames;t.a=n[i],t.b=n[i+1],t.c=n[i+2],t.d=n[i+3],t.tx=n[i+4],t.ty=n[i+5],e.rotation=n[i+6],e.skew=n[i+7],e.scaleX=n[i+8],e.scaleY=n[i+9],e.x=t.tx,e.y=t.ty},i.prototype.addBone=function(t){t.name in this.bones?console.warn("Same bone: "+t.name):(this.bones[t.name]=t,this.sortedBones.push(t))},i.prototype.addSlot=function(t){t.name in this.slots?console.warn("Same slot: "+t.name):(this.slots[t.name]=t,this.sortedSlots.push(t))},i.prototype.addConstraint=function(t){t.name in this.constraints?console.warn("Same constraint: "+t.name):this.constraints[t.name]=t},i.prototype.addSkin=function(t){t.name in this.skins?console.warn("Same skin: "+t.name):(t.parent=this,this.skins[t.name]=t,null===this.defaultSkin&&(this.defaultSkin=t),"default"===t.name&&(this.defaultSkin=t))},i.prototype.addAnimation=function(t){t.name in this.animations?console.warn("Same animation: "+t.name):(t.parent=this,this.animations[t.name]=t,this.animationNames.push(t.name),null===this.defaultAnimation&&(this.defaultAnimation=t))},i.prototype.addAction=function(t,e){e?this.defaultActions.push(t):this.actions.push(t)},i.prototype.getBone=function(t){return t in this.bones?this.bones[t]:null},i.prototype.getSlot=function(t){return t in this.slots?this.slots[t]:null},i.prototype.getConstraint=function(t){return t in this.constraints?this.constraints[t]:null},i.prototype.getSkin=function(t){return t in this.skins?this.skins[t]:null},i.prototype.getMesh=function(t,e,i){var n=this.getSkin(t);return null===n?null:n.getDisplay(e,i)},i.prototype.getAnimation=function(t){return t in this.animations?this.animations[t]:null},i}(t.BaseObject);t.ArmatureData=e;var i=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.transform=new t.Transform,i.userData=null,i}return nit(i,e),i.toString=function(){return"[class dragonBones.BoneData]"},i.prototype._onClear=function(){null!==this.userData&&this.userData.returnToPool(),this.inheritTranslation=!1,this.inheritRotation=!1,this.inheritScale=!1,this.inheritReflection=!1,this.type=0,this.length=0,this.name="",this.transform.identity(),this.userData=null,this.parent=null},i}(t.BaseObject);t.BoneData=i;var n=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.vertices=[],e}return nit(e,t),e.toString=function(){return"[class dragonBones.SurfaceData]"},e.prototype._onClear=function(){t.prototype._onClear.call(this),this.type=1,this.segmentX=0,this.segmentY=0,this.vertices.length=0},e}(i);t.SurfaceData=n;var r=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.color=null,t.userData=null,t}return nit(i,e),i.createColor=function(){return new t.ColorTransform},i.toString=function(){return"[class dragonBones.SlotData]"},i.prototype._onClear=function(){null!==this.userData&&this.userData.returnToPool(),this.blendMode=0,this.displayIndex=0,this.zOrder=0,this.name="",this.color=null,this.userData=null,this.parent=null},i.DEFAULT_COLOR=new t.ColorTransform,i}(t.BaseObject);t.SlotData=r}(rit),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return nit(e,t),e.prototype._onClear=function(){this.order=0,this.name="",this.type=0,this.target=null,this.root=null,this.bone=null},e}(t.BaseObject);t.ConstraintData=e;var i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return nit(e,t),e.toString=function(){return"[class dragonBones.IKConstraintData]"},e.prototype._onClear=function(){t.prototype._onClear.call(this),this.scaleEnabled=!1,this.bendPositive=!1,this.weight=1},e}(e);t.IKConstraintData=i;var n=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.bones=[],e}return nit(e,t),e.toString=function(){return"[class dragonBones.PathConstraintData]"},e.prototype._onClear=function(){t.prototype._onClear.call(this),this.pathSlot=null,this.pathDisplayData=null,this.bones.length=0,this.positionMode=0,this.spacingMode=1,this.rotateMode=1,this.position=0,this.spacing=0,this.rotateOffset=0,this.rotateMix=0,this.translateMix=0},e.prototype.AddBone=function(t){this.bones.push(t)},e}(e);t.PathConstraintData=n}(rit),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return nit(e,t),e.toString=function(){return"[class dragonBones.CanvasData]"},e.prototype._onClear=function(){this.hasBackground=!1,this.color=0,this.x=0,this.y=0,this.width=0,this.height=0},e}(t.BaseObject);t.CanvasData=e}(rit),function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.displays={},e}return nit(e,t),e.toString=function(){return"[class dragonBones.SkinData]"},e.prototype._onClear=function(){for(var t in this.displays){for(var e=0,i=this.displays[t];er&&(a|=2),es&&(a|=8),a},e.rectangleIntersectsSegment=function(t,i,n,r,s,a,o,h,u,l,c){void 0===u&&(u=null),void 0===l&&(l=null),void 0===c&&(c=null);var f=t>s&&ta&&is&&na&&r=-i&&t<=i){var n=.5*this.height;if(e>=-n&&e<=n)return!0}return!1},e.prototype.intersectsSegment=function(t,i,n,r,s,a,o){void 0===s&&(s=null),void 0===a&&(a=null),void 0===o&&(o=null);var h=.5*this.width,u=.5*this.height;return e.rectangleIntersectsSegment(t,i,n,r,-h,-u,h,u,s,a,o)},e}(e);t.RectangleBoundingBoxData=i;var n=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return nit(e,t),e.toString=function(){return"[class dragonBones.EllipseData]"},e.ellipseIntersectsSegment=function(t,e,i,n,r,s,a,o,h,u,l){void 0===h&&(h=null),void 0===u&&(u=null),void 0===l&&(l=null);var c=a/o,f=c*c,_=i-t,d=(n*=c)-(e*=c),p=Math.sqrt(_*_+d*d),m=_/p,g=d/p,y=(r-t)*m+(s-e)*g,v=a*a,b=v-(t*t+e*e)+y*y,S=0;if(b>=0){var w=Math.sqrt(b),x=y-w,T=y+w,A=x<0?-1:x<=p?0:1,C=T<0?-1:T<=p?0:1,D=A*C;if(D<0)return-1;0===D&&(-1===A?(S=2,i=t+T*m,n=(e+T*g)/c,null!==h&&(h.x=i,h.y=n),null!==u&&(u.x=i,u.y=n),null!==l&&(l.x=Math.atan2(n/v*f,i/v),l.y=l.x+Math.PI)):1===C?(S=1,t+=x*m,e=(e+x*g)/c,null!==h&&(h.x=t,h.y=e),null!==u&&(u.x=t,u.y=e),null!==l&&(l.x=Math.atan2(e/v*f,t/v),l.y=l.x+Math.PI)):(S=3,null!==h&&(h.x=t+x*m,h.y=(e+x*g)/c,null!==l&&(l.x=Math.atan2(h.y/v*f,h.x/v))),null!==u&&(u.x=t+T*m,u.y=(e+T*g)/c,null!==l&&(l.y=Math.atan2(u.y/v*f,u.x/v)))))}return S},e.prototype._onClear=function(){t.prototype._onClear.call(this),this.type=1},e.prototype.containsPoint=function(t,e){var i=.5*this.width;if(t>=-i&&t<=i){var n=.5*this.height;if(e>=-n&&e<=n)return e*=i/n,Math.sqrt(t*t+e*e)<=i}return!1},e.prototype.intersectsSegment=function(t,i,n,r,s,a,o){return void 0===s&&(s=null),void 0===a&&(a=null),void 0===o&&(o=null),e.ellipseIntersectsSegment(t,i,n,r,0,0,.5*this.width,.5*this.height,s,a,o)},e}(e);t.EllipseBoundingBoxData=n;var r=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.vertices=[],e}return nit(e,t),e.toString=function(){return"[class dragonBones.PolygonBoundingBoxData]"},e.polygonIntersectsSegment=function(t,e,i,n,r,s,a,o){void 0===s&&(s=null),void 0===a&&(a=null),void 0===o&&(o=null),t===i&&(t=i+1e-6),e===n&&(e=n+1e-6);for(var h=r.length,u=t-i,l=e-n,c=t*n-e*i,f=0,_=r[h-2],d=r[h-1],p=0,m=0,g=0,y=0,v=0,b=0,S=0;S=_&&B<=w||B>=w&&B<=_)&&(0===u||B>=t&&B<=i||B>=i&&B<=t)){var I=(c*A-l*C)/D;if((I>=d&&I<=x||I>=x&&I<=d)&&(0===l||I>=e&&I<=n||I>=n&&I<=e)){if(null===a){g=B,y=I,v=B,b=I,f++,null!==o&&(o.x=Math.atan2(x-d,w-_)-.5*Math.PI,o.y=o.x);break}var M=B-t;M<0&&(M=-M),0===f?(p=M,m=M,g=B,y=I,v=B,b=I,null!==o&&(o.x=Math.atan2(x-d,w-_)-.5*Math.PI,o.y=o.x)):(Mm&&(m=M,v=B,b=I,null!==o&&(o.y=Math.atan2(x-d,w-_)-.5*Math.PI))),f++}}_=w,d=x}return 1===f?(null!==s&&(s.x=g,s.y=y),null!==a&&(a.x=g,a.y=y),null!==o&&(o.y=o.x+Math.PI)):f>1&&(f++,null!==s&&(s.x=g,s.y=y),null!==a&&(a.x=v,a.y=b)),f},e.prototype._onClear=function(){t.prototype._onClear.call(this),this.type=2,this.x=0,this.y=0,this.vertices.length=0},e.prototype.containsPoint=function(t,e){var i=!1;if(t>=this.x&&t<=this.width&&e>=this.y&&e<=this.height)for(var n=0,r=this.vertices.length,s=r-2;n=e||a=e){var h=this.vertices[s],u=this.vertices[n];(e-o)*(h-u)/(a-o)+u0)){this.cacheFrameRate=Math.max(Math.ceil(t*this.scale),1);var e=Math.ceil(this.cacheFrameRate*this.duration)+1;this.cachedFrames.length=e;for(var i=0,n=this.cacheFrames.length;i=0},e.prototype.addBoneMask=function(t,e,i){void 0===i&&(i=!0);var n=t.getBone(e);if(null!==n&&(this.boneMask.indexOf(e)<0&&this.boneMask.push(e),i))for(var r=0,s=t.getBones();r=0&&this.boneMask.splice(n,1),i){var r=t.getBone(e);if(null!==r)if(this.boneMask.length>0)for(var s=0,a=t.getBones();s=0&&r.contains(o)&&this.boneMask.splice(h,1)}else for(var u=0,l=t.getBones();ue._zOrder?1:-1},i.prototype._onClear=function(){null!==this._clock&&this._clock.remove(this);for(var t=0,e=this._bones;t=s)){var o=i[a],h=this.getSlot(o.name);null!==h&&h._setZorder(r)}}this._slotsDirty=!0,this._zOrderDirty=!n}},i.prototype._addBone=function(t){this._bones.indexOf(t)<0&&this._bones.push(t)},i.prototype._addSlot=function(t){this._slots.indexOf(t)<0&&this._slots.push(t)},i.prototype._addConstraint=function(t){this._constraints.indexOf(t)<0&&this._constraints.push(t)},i.prototype._bufferAction=function(t,e){this._actions.indexOf(t)<0&&(e?this._actions.push(t):this._actions.unshift(t))},i.prototype.dispose=function(){null!==this._armatureData&&(this._lockUpdate=!0,this._dragonBones.bufferObject(this))},i.prototype.init=function(e,i,n,r){null===this._armatureData&&(this._armatureData=e,this._animation=t.BaseObject.borrowObject(t.Animation),this._proxy=i,this._display=n,this._dragonBones=r,this._proxy.dbInit(this),this._animation.init(this),this._animation.animations=this._armatureData.animations)},i.prototype.advanceTime=function(t){if(!this._lockUpdate)if(null!==this._armatureData)if(null!==this._armatureData.parent){var e=this._cacheFrameIndex;if(this._animation.advanceTime(t),this._slotsDirty&&(this._slotsDirty=!1,this._slots.sort(i._onSortSlots)),this._cacheFrameIndex<0||this._cacheFrameIndex!==e){var n=0,r=0;for(n=0,r=this._bones.length;n0){this._lockUpdate=!0;for(var s=0,a=this._actions;s0){if(null!==(a=this.getBone(t))&&(a.invalidUpdate(),e))for(var i=0,n=this._slots;i0){if(null===r&&null===s){m=b;break}var S;null!==r&&((S=o?r.y-e:r.x-t)<0&&(S=-S),(null===m||Su)&&(u=S,f=s.x,_=s.y,g=b,null!==a&&(p=a.y)))}}return null!==m&&null!==r&&(r.x=l,r.y=c,null!==a&&(a.x=d)),null!==g&&null!==s&&(s.x=f,s.y=_,null!==a&&(a.y=p)),m},i.prototype.getBone=function(t){for(var e=0,i=this._bones;e=0&&null!==this._cachedFrameIndices){var e=this._cachedFrameIndices[t];if(e>=0&&this._cachedFrameIndex===e)this._transformDirty=!1;else if(e>=0)this._transformDirty=!0,this._cachedFrameIndex=e;else{if(this._hasConstraint)for(var i=0,n=this._armature._constraints;i=0?(this._transformDirty=!1,this._cachedFrameIndices[t]=this._cachedFrameIndex):(this._transformDirty=!0,this._cachedFrameIndex=-1)}}else{if(this._hasConstraint)for(var r=0,s=this._armature._constraints;r=0;this._localDirty&&this._updateGlobalTransformMatrix(o),o&&null!==this._cachedFrameIndices&&(this._cachedFrameIndex=this._cachedFrameIndices[t]=this._armature._armatureData.setCacheFrame(this.globalTransformMatrix,this.global))}else this._armature._armatureData.getCacheFrame(this.globalTransformMatrix,this.global,this._cachedFrameIndex);else this._childrenTransformDirty&&(this._childrenTransformDirty=!1);this._localDirty=!0},i.prototype.updateByConstraint=function(){this._localDirty&&(this._localDirty=!1,(this._transformDirty||null!==this._parent&&this._parent._childrenTransformDirty)&&this._updateGlobalTransformMatrix(!0),this._transformDirty=!0)},i.prototype.invalidUpdate=function(){this._transformDirty=!0},i.prototype.contains=function(t){if(t===this)return!1;for(var e=t;e!==this&&null!==e;)e=e.parent;return e===this},Object.defineProperty(i.prototype,"boneData",{get:function(){return this._boneData},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"visible",{get:function(){return this._visible},set:function(t){if(this._visible!==t){this._visible=t;for(var e=0,i=this._armature.getSlots();e=s)return this.globalTransformMatrix;if(d=7*(2*(o*(h+1)+2*o+h+_)+((r=i>this._kX*(t+s)+m)?1:0)),this._matrixCahce[d]>0)y.copyFromArray(g,d+1);else{var v=_*(u+2),b=this._hullCache[4],S=this._hullCache[5],w=this._hullCache[2]-(h-_)*b,x=this._hullCache[3]-(h-_)*S,T=this._vertices;r?this._getAffineTransform(-200,m+c,800,c,T[v+u+2],T[v+u+3],w+b,x+S,T[v],T[v+1],e._helpTransform,y,!0):this._getAffineTransform(-1e3,m,800,c,w,x,T[v],T[v+1],w+b,x+S,e._helpTransform,y,!1),g[d]=1,g[d+1]=y.a,g[d+2]=y.b,g[d+3]=y.c,g[d+4]=y.d,g[d+5]=y.tx,g[d+6]=y.ty}}else if(t>=s){if(i<-200||i>=s)return this.globalTransformMatrix;d=7*(2*(o*(h+1)+o+_)+((r=i>this._kX*(t-n)+m)?1:0)),this._matrixCahce[d]>0?y.copyFromArray(g,d+1):(v=(_+1)*(u+2)-2,b=this._hullCache[4],S=this._hullCache[5],w=this._hullCache[0]+_*b,x=this._hullCache[1]+_*S,T=this._vertices,r?this._getAffineTransform(n,m+c,800,c,w+b,x+S,T[v+u+2],T[v+u+3],w,x,e._helpTransform,y,!0):this._getAffineTransform(s,m,800,c,T[v],T[v+1],w,x,T[v+u+2],T[v+u+3],e._helpTransform,y,!1),g[d]=1,g[d+1]=y.a,g[d+2]=y.b,g[d+3]=y.c,g[d+4]=y.d,g[d+5]=y.tx,g[d+6]=y.ty)}else if(i<-200){if(t<-200||t>=s)return this.globalTransformMatrix;d=7*(o*(h+1)+2*f+((r=i>this._kY*(t-p-l)-n)?1:0)),this._matrixCahce[d]>0?y.copyFromArray(g,d+1):(v=2*f,b=this._hullCache[10],S=this._hullCache[11],w=this._hullCache[8]+f*b,x=this._hullCache[9]+f*S,T=this._vertices,r?this._getAffineTransform(p+l,-200,l,800,T[v+2],T[v+3],T[v],T[v+1],w+b,x+S,e._helpTransform,y,!0):this._getAffineTransform(p,-1e3,l,800,w,x,w+b,x+S,T[v],T[v+1],e._helpTransform,y,!1),g[d]=1,g[d+1]=y.a,g[d+2]=y.b,g[d+3]=y.c,g[d+4]=y.d,g[d+5]=y.tx,g[d+6]=y.ty)}else if(i>=s){if(t<-200||t>=s)return this.globalTransformMatrix;d=7*(2*(o*(h+1)+o+h+_)+((r=i>this._kY*(t-p-l)+s)?1:0)),this._matrixCahce[d]>0?y.copyFromArray(g,d+1):(v=h*(u+2)+2*f,b=this._hullCache[10],S=this._hullCache[11],w=this._hullCache[6]-(o-f)*b,x=this._hullCache[7]-(o-f)*S,T=this._vertices,r?this._getAffineTransform(p+l,n,l,800,w+b,x+S,w,x,T[v+2],T[v+3],e._helpTransform,y,!0):this._getAffineTransform(p,s,l,800,T[v],T[v+1],T[v+2],T[v+3],w,x,e._helpTransform,y,!1),g[d]=1,g[d+1]=y.a,g[d+2]=y.b,g[d+3]=y.c,g[d+4]=y.d,g[d+5]=y.tx,g[d+6]=y.ty)}else d=7*(2*(o*_+f)+((r=i>this._k*(t-p-l)+m)?1:0)),this._matrixCahce[d]>0?y.copyFromArray(g,d+1):(v=2*f+_*(u+2),T=this._vertices,r?this._getAffineTransform(p+l,m+c,l,c,T[v+u+4],T[v+u+5],T[v+u+2],T[v+u+3],T[v+2],T[v+3],e._helpTransform,y,!0):this._getAffineTransform(p,m,l,c,T[v],T[v+1],T[v+2],T[v+3],T[v+u+2],T[v+u+3],e._helpTransform,y,!1),g[d]=1,g[d+1]=y.a,g[d+2]=y.b,g[d+3]=y.c,g[d+4]=y.d,g[d+5]=y.tx,g[d+6]=y.ty);return y},e.prototype.init=function(e,i){if(null===this._boneData){t.prototype.init.call(this,e,i);var n=e.segmentX,r=e.segmentY,s=e.vertices.length;this._dX=400/n,this._dY=400/r,this._k=-this._dY/this._dX,this._kX=-this._dY/800,this._kY=-800/this._dX,this._vertices.length=s,this._deformVertices.length=s,this._matrixCahce.length=14*(n*r+2*n+2*r),this._hullCache.length=10;for(var a=0;a=0&&null!==this._cachedFrameIndices){var i=this._cachedFrameIndices[t];if(i>=0&&this._cachedFrameIndex===i)this._transformDirty=!1;else if(i>=0)this._transformDirty=!0,this._cachedFrameIndex=i;else{if(this._hasConstraint)for(var n=0,r=this._armature._constraints;n=0?(this._transformDirty=!1,this._cachedFrameIndices[t]=this._cachedFrameIndex):(this._transformDirty=!0,this._cachedFrameIndex=-1)}}else{if(this._hasConstraint)for(var s=0,a=this._armature._constraints;s=0;this._localDirty&&this._updateGlobalTransformMatrix(l),l&&null!==this._cachedFrameIndices&&(this._cachedFrameIndex=this._cachedFrameIndices[t]=this._armature._armatureData.setCacheFrame(this.globalTransformMatrix,this.global))}else this._armature._armatureData.getCacheFrame(this.globalTransformMatrix,this.global,this._cachedFrameIndex);var c=2*this.global.x,f=2*this.global.y,_=e._helpPoint;this.globalTransformMatrix.transformPoint(1e3,-200,_),this._hullCache[0]=_.x,this._hullCache[1]=_.y,this._hullCache[2]=c-_.x,this._hullCache[3]=f-_.y,this.globalTransformMatrix.transformPoint(0,this._dY,_,!0),this._hullCache[4]=_.x,this._hullCache[5]=_.y,this.globalTransformMatrix.transformPoint(200,1e3,_),this._hullCache[6]=_.x,this._hullCache[7]=_.y,this._hullCache[8]=c-_.x,this._hullCache[9]=f-_.y,this.globalTransformMatrix.transformPoint(this._dX,0,_,!0),this._hullCache[10]=_.x,this._hullCache[11]=_.y}else this._childrenTransformDirty&&(this._childrenTransformDirty=!1);this._localDirty=!0},e}(t.Bone);t.Surface=e}(rit),function(t){var e=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i._localMatrix=new t.Matrix,i._colorTransform=new t.ColorTransform,i._displayDatas=[],i._displayList=[],i._deformVertices=null,i._rawDisplay=null,i._meshDisplay=null,i}return nit(i,e),i.prototype._onClear=function(){e.prototype._onClear.call(this);for(var i=[],n=0,r=this._displayList;n=0&&(null!==this._rawDisplayDatas&&(s=this._displayIndex=0&&this._displayIndex=0&&null!==this._rawDisplayDatas){var a=this._displayIndex0)for(var o=0,h=s;o0){this._displayList.length!==e.length&&(this._displayList.length=e.length);for(var i=0,n=e.length;i0&&(this._displayList.length=0);return this._displayIndex>=0&&this._displayIndex=0&&null!==this._cachedFrameIndices){var e=this._cachedFrameIndices[t];e>=0&&this._cachedFrameIndex===e?this._transformDirty=!1:e>=0?(this._transformDirty=!0,this._cachedFrameIndex=e):this._transformDirty||this._parent._childrenTransformDirty?(this._transformDirty=!0,this._cachedFrameIndex=-1):this._cachedFrameIndex>=0?(this._transformDirty=!1,this._cachedFrameIndices[t]=this._cachedFrameIndex):(this._transformDirty=!0,this._cachedFrameIndex=-1)}else(this._transformDirty||this._parent._childrenTransformDirty)&&(t=-1,this._transformDirty=!0,this._cachedFrameIndex=-1);if(null!==this._display){if(this._visibleDirty&&(this._visibleDirty=!1,this._updateVisible()),this._blendModeDirty&&(this._blendModeDirty=!1,this._updateBlendMode()),this._colorDirty&&(this._colorDirty=!1,this._updateColor()),null!==this._deformVertices&&null!==this._deformVertices.verticesData&&this._display===this._meshDisplay){var i=null!==this._deformVertices.verticesData.weight,n=0!==this._parent._boneData.type;if((this._deformVertices.verticesDirty||i&&this._deformVertices.isBonesUpdate()||n&&this._parent._childrenTransformDirty)&&(this._deformVertices.verticesDirty=!1,this._updateMesh()),i||n)return}if(this._transformDirty){if(this._transformDirty=!1,this._cachedFrameIndex<0){var r=t>=0;this._updateGlobalTransformMatrix(r),r&&null!==this._cachedFrameIndices&&(this._cachedFrameIndex=this._cachedFrameIndices[t]=this._armature._armatureData.setCacheFrame(this.globalTransformMatrix,this.global))}else this._isFromCache=!0,this._armature._armatureData.getCacheFrame(this.globalTransformMatrix,this.global,this._cachedFrameIndex);this._updateTransform()}}},i.prototype.updateTransformAndMatrix=function(){this._transformDirty&&(this._transformDirty=!1,this._updateGlobalTransformMatrix(!1))},i.prototype.replaceDisplayData=function(t,e){if(void 0===e&&(e=-1),e<0&&(e=this._displayIndex<0?0:this._displayIndex),this._displayDatas.length<=e){this._displayDatas.length=e+1;for(var i=0,n=this._displayDatas.length;i0&&(1===h||2===h?null!==s?(this.globalTransformMatrix.transformPoint(s.x,s.y,s),null!==a&&(a.x=s.x,a.y=s.y)):null!==a&&this.globalTransformMatrix.transformPoint(a.x,a.y,a):(null!==s&&this.globalTransformMatrix.transformPoint(s.x,s.y,s),null!==a&&this.globalTransformMatrix.transformPoint(a.x,a.y,a)),null!==o&&(this.globalTransformMatrix.transformPoint(Math.cos(o.x),Math.sin(o.x),i._helpPoint,!0),o.x=Math.atan2(i._helpPoint.y,i._helpPoint.x),this.globalTransformMatrix.transformPoint(Math.cos(o.y),Math.sin(o.y),i._helpPoint,!0),o.y=Math.atan2(i._helpPoint.y,i._helpPoint.x))),h},i.prototype.invalidUpdate=function(){this._displayDirty=!0,this._transformDirty=!0},Object.defineProperty(i.prototype,"visible",{get:function(){return this._visible},set:function(t){this._visible!==t&&(this._visible=t,this._updateVisible())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"displayIndex",{get:function(){return this._displayIndex},set:function(t){this._setDisplayIndex(t)&&this.update(-1)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"name",{get:function(){return this._slotData.name},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"displayList",{get:function(){return this._displayList.concat()},set:function(e){var i=this._displayList.concat(),n=new Array;this._setDisplayList(e)&&this.update(-1);for(var r=0,s=i;rd)continue}for(;;W++){var L=p[W];if(!(F>L)){0===W?F/=L:F=(F-(z=p[W-1]))/(L-z);break}}if(W!==f){f=W;var V=6*W;for(T=u[V],A=u[V+1],C=u[V+2],D=u[V+3],B=u[V+4],I=u[V+5],b=2*(m=.03*(T-2*C+B))+(y=.006*(3*(C-B)-T+(M=u[V+6]))),S=2*(g=.03*(A-2*D+I))+(v=.006*(3*(D-I)-A+(P=u[V+7]))),w=.3*(C-T)+m+.16666667*y,x=.3*(D-A)+g+.16666667*v,k=Math.sqrt(w*w+x*x),O[0]=k,V=1;V<8;V++)w+=b,x+=S,b+=y,S+=v,k+=Math.sqrt(w*w+x*x),O[V]=k;w+=b,x+=S,k+=Math.sqrt(w*w+x*x),O[8]=k,w+=b+y,x+=S+v,k+=Math.sqrt(w*w+x*x),O[9]=k,R=0}for(F*=k;;R++){var N=O[R];if(!(F>N)){var z;0===R?F/=N:F=R+(F-(z=O[R-1]))/(N-z);break}}this.addCurvePosition(.1*F,T,A,C,D,B,I,M,P,a,H,i)}}else{var U=t.curveLengths;if(d=U[c-=h?1:2],n&&(_*=d),r)for(var G=0;Gd)continue}for(var j=0;;W++){var q=U[W];if(!(_>q)){if(0===W)j=_/q;else{var X=U[W-1];j=(_-X)/(q-X)}break}}W!==f&&(f=W,h&&W===c?(this._computeVertices(l-4,4,0,u),this._computeVertices(0,4,4,u)):this._computeVertices(6*W+2,8,0,u)),this.addCurvePosition(j,u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],a,H,i)}}},i.prototype.addCurvePosition=function(t,e,i,n,r,s,a,o,h,u,l,c){if(0===t)return u[l]=e,u[l+1]=i,void(u[l+2]=0);if(1===t)return u[l]=o,u[l+1]=h,void(u[l+2]=0);var f=1-t,_=f*f,d=t*t,p=_*f,m=_*t*3,g=f*d*3,y=t*d,v=p*e+m*n+g*s+y*o,b=p*i+m*r+g*a+y*h;u[l]=v,u[l+1]=b,u[l+2]=c?Math.atan2(b-(p*i+m*r+g*a),v-(p*e+m*n+g*s)):0},i.prototype.init=function(t,e){this._constraintData=t,this._armature=e;var i=t;this.pathOffset=i.pathDisplayData.vertices.offset,this.position=i.position,this.spacing=i.spacing,this.rotateOffset=i.rotateOffset,this.rotateMix=i.rotateMix,this.translateMix=i.translateMix,this._root=this._armature.getBone(i.root.name),this._target=this._armature.getBone(i.target.name),this._pathSlot=this._armature.getSlot(i.pathSlot.name);for(var n=0,r=i.bones.length;n0?t.Transform.DEG_RAD:-t.Transform.DEG_RAD));for(var B=this.rotateMix,I=this.translateMix,M=(g=0,3);g<_;g++,M+=3){var P,E;(P=u[g]).updateByConstraint(),(E=P.globalTransformMatrix).tx+=(C-E.tx)*I,E.ty+=(D-E.ty)*I;var O=(b=T[M])-C,k=(S=T[M+1])-D;if(c){var R=this._boneLengths[g],F=(Math.sqrt(O*O+k*k)/R-1)*B+1;E.a*=F,E.b*=F}if(C=b,D=S,B>0){var L=E.a,V=E.b,N=E.c,z=E.d,U=void 0,G=void 0,H=void 0;if(U=f?T[M-1]:Math.atan2(k,O),U-=Math.atan2(V,L),x){G=Math.cos(U),H=Math.sin(U);var W=P._boneData.length;C+=(W*(G*L-H*V)-O)*B,D+=(W*(H*L+G*V)-k)*B}else U+=A;U>t.Transform.PI?U-=t.Transform.PI_D:U<-t.Transform.PI&&(U+=t.Transform.PI_D),U*=B,G=Math.cos(U),H=Math.sin(U),E.a=G*L-H*V,E.b=H*L+G*V,E.c=G*N-H*z,E.d=H*N+G*z}P.global.fromMatrix(E)}this.dirty=!1}}},i.prototype.invalidUpdate=function(){},i}(e);t.PathConstraint=n}(rit),function(t){var e=function(){function t(t){void 0===t&&(t=0),this.time=0,this.timeScale=1,this._systemTime=0,this._animatebles=[],this._clock=null,this.time=t,this._systemTime=.001*(new Date).getTime()}return t.prototype.advanceTime=function(t){t!=t&&(t=0);var e=.001*Date.now();if(t<0&&(t=e-this._systemTime),this._systemTime=e,1!==this.timeScale&&(t*=this.timeScale),0!==t){t<0?this.time-=t:this.time+=t;for(var i=0,n=0,r=this._animatebles.length;i0&&(this._animatebles[i-n]=s,this._animatebles[i]=null),s.advanceTime(t)):n++}if(n>0){for(r=this._animatebles.length;i=0&&(this._animatebles[e]=null,t.clock=null)},t.prototype.clear=function(){for(var t=0,e=this._animatebles;t0&&d._subFadeState>0)this._armature._dragonBones.bufferObject(d),this._animationStates.length=0,this._lastAnimationState=null;else{var i=d._animationData,n=i.cacheFrameRate;if(this._animationDirty&&n>0){this._animationDirty=!1;for(var r=0,s=this._armature.getBones();r0){var c=l[0];if(null!==c&&c.parent===this._armature.armatureData.defaultSkin){u._cachedFrameIndices=i.getSlotCachedFrameIndices(u.name);continue}}u._cachedFrameIndices=null}}d.advanceTime(t,n)}else if(e>1){for(var f=0,_=0;f0&&d._subFadeState>0?(_++,this._armature._dragonBones.bufferObject(d),this._animationDirty=!0,this._lastAnimationState===d&&(this._lastAnimationState=null)):(_>0&&(this._animationStates[f-_]=d),d.advanceTime(t,0)),f===e-1&&_>0&&(this._animationStates.length-=_,null===this._lastAnimationState&&this._animationStates.length>0&&(this._lastAnimationState=this._animationStates[this._animationStates.length-1]))}this._armature._cacheFrameIndex=-1}else this._armature._cacheFrameIndex=-1},i.prototype.reset=function(){for(var t=0,e=this._animationStates;t1?(e.position<0?(e.position%=n.duration,e.position=n.duration-e.position):e.position===n.duration?e.position-=1e-6:e.position>n.duration&&(e.position%=n.duration),e.duration>0&&e.position+e.duration>n.duration&&(e.duration=n.duration-e.position),e.playTimes<0&&(e.playTimes=n.playTimes)):(e.playTimes=1,e.position=0,e.duration>0&&(e.duration=0)),0===e.duration&&(e.duration=-1),this._fadeOut(e);var o=t.BaseObject.borrowObject(t.AnimationState);if(o.init(this._armature,n,e),this._animationDirty=!0,this._armature._cacheFrameIndex=-1,this._animationStates.length>0){for(var h=!1,u=0,l=this._animationStates.length;uthis._animationStates[u].layer){h=!0,this._animationStates.splice(u,0,o);break}if(u!==l-1&&o.layer>this._animationStates[u+1].layer){h=!0,this._animationStates.splice(u+1,0,o);break}}h||this._animationStates.push(o)}else this._animationStates.push(o);for(var c=0,f=this._armature.getSlots();c0)this.playConfig(this._animationConfig);else if(null===this._lastAnimationState){var i=this._armature.armatureData.defaultAnimation;null!==i&&(this._animationConfig.animation=i.name,this.playConfig(this._animationConfig))}else this._lastAnimationState.isPlaying||this._lastAnimationState.isCompleted?(this._animationConfig.animation=this._lastAnimationState.name,this.playConfig(this._animationConfig)):this._lastAnimationState.play();return this._lastAnimationState},i.prototype.fadeIn=function(t,e,i,n,r,s){return void 0===e&&(e=-1),void 0===i&&(i=-1),void 0===n&&(n=0),void 0===r&&(r=null),void 0===s&&(s=3),this._animationConfig.clear(),this._animationConfig.fadeOutMode=s,this._animationConfig.playTimes=i,this._animationConfig.layer=n,this._animationConfig.fadeInTime=e,this._animationConfig.animation=t,this._animationConfig.group=null!==r?r:"",this.playConfig(this._animationConfig)},i.prototype.gotoAndPlayByTime=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=-1),this._animationConfig.clear(),this._animationConfig.resetToPose=!0,this._animationConfig.playTimes=i,this._animationConfig.position=e,this._animationConfig.fadeInTime=0,this._animationConfig.animation=t,this.playConfig(this._animationConfig)},i.prototype.gotoAndPlayByFrame=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=-1),this._animationConfig.clear(),this._animationConfig.resetToPose=!0,this._animationConfig.playTimes=i,this._animationConfig.fadeInTime=0,this._animationConfig.animation=t;var n=t in this._animations?this._animations[t]:null;return null!==n&&(this._animationConfig.position=n.duration*e/n.frameCount),this.playConfig(this._animationConfig)},i.prototype.gotoAndPlayByProgress=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=-1),this._animationConfig.clear(),this._animationConfig.resetToPose=!0,this._animationConfig.playTimes=i,this._animationConfig.fadeInTime=0,this._animationConfig.animation=t;var n=t in this._animations?this._animations[t]:null;return null!==n&&(this._animationConfig.position=n.duration*(e>0?e:0)),this.playConfig(this._animationConfig)},i.prototype.gotoAndStopByTime=function(t,e){void 0===e&&(e=0);var i=this.gotoAndPlayByTime(t,e,1);return null!==i&&i.stop(),i},i.prototype.gotoAndStopByFrame=function(t,e){void 0===e&&(e=0);var i=this.gotoAndPlayByFrame(t,e,1);return null!==i&&i.stop(),i},i.prototype.gotoAndStopByProgress=function(t,e){void 0===e&&(e=0);var i=this.gotoAndPlayByProgress(t,e,1);return null!==i&&i.stop(),i},i.prototype.getState=function(t){for(var e=this._animationStates.length;e--;){var i=this._animationStates[e];if(i.name===t)return i}return null},i.prototype.hasAnimation=function(t){return t in this._animations},i.prototype.getStates=function(){return this._animationStates},Object.defineProperty(i.prototype,"isPlaying",{get:function(){for(var t=0,e=this._animationStates;t0},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"lastAnimationName",{get:function(){return null!==this._lastAnimationState?this._lastAnimationState.name:""},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"animationNames",{get:function(){return this._animationNames},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"animations",{get:function(){return this._animations},set:function(t){if(this._animations!==t){for(var e in this._animationNames.length=0,this._animations)delete this._animations[e];for(var e in t)this._animationNames.push(e),this._animations[e]=t[e]}},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"animationConfig",{get:function(){return this._animationConfig.clear(),this._animationConfig},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"lastAnimationState",{get:function(){return this._lastAnimationState},enumerable:!0,configurable:!0}),i.prototype.gotoAndPlay=function(t,e,i,n,r,s,a){void 0===e&&(e=-1),void 0===i&&(i=-1),void 0===n&&(n=-1),void 0===r&&(r=0),void 0===s&&(s=null),void 0===a&&(a=3),console.warn("Deprecated."),this._animationConfig.clear(),this._animationConfig.resetToPose=!0,this._animationConfig.fadeOutMode=a,this._animationConfig.playTimes=n,this._animationConfig.layer=r,this._animationConfig.fadeInTime=e,this._animationConfig.animation=t,this._animationConfig.group=null!==s?s:"";var o=this._animations[t];return o&&i>0&&(this._animationConfig.timeScale=o.duration/i),this.playConfig(this._animationConfig)},i.prototype.gotoAndStop=function(t,e){return void 0===e&&(e=0),console.warn("Deprecated."),this.gotoAndStopByTime(t,e)},Object.defineProperty(i.prototype,"animationList",{get:function(){return console.warn("Deprecated."),this._animationNames},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"animationDataList",{get:function(){console.warn("Deprecated.");for(var t=[],e=0,i=this._animationNames.length;e0;if(this._subFadeState<0){this._subFadeState=0;var r=n?t.EventObject.FADE_OUT:t.EventObject.FADE_IN;this._armature.eventDispatcher.hasDBEventListener(r)&&((i=t.BaseObject.borrowObject(t.EventObject)).type=r,i.armature=this._armature,i.animationState=this,this._armature._dragonBones.bufferEvent(i))}(e<0&&(e=-e),this._fadeTime+=e,this._fadeTime>=this.fadeTotalTime?(this._subFadeState=1,this._fadeProgress=n?0:1):this._fadeTime>0?this._fadeProgress=n?1-this._fadeTime/this.fadeTotalTime:this._fadeTime/this.fadeTotalTime:this._fadeProgress=n?1:0,this._subFadeState>0)&&(n||(this._playheadState|=1,this._fadeState=0),r=n?t.EventObject.FADE_OUT_COMPLETE:t.EventObject.FADE_IN_COMPLETE,this._armature.eventDispatcher.hasDBEventListener(r)&&((i=t.BaseObject.borrowObject(t.EventObject)).type=r,i.armature=this._armature,i.animationState=this,this._armature._dragonBones.bufferEvent(i)))},r.prototype.init=function(e,i,n){if(null===this._armature){if(this._armature=e,this._animationData=i,this.resetToPose=n.resetToPose,this.additiveBlending=n.additiveBlending,this.displayControl=n.displayControl,this.actionEnabled=n.actionEnabled,this.layer=n.layer,this.playTimes=n.playTimes,this.timeScale=n.timeScale,this.fadeTotalTime=n.fadeInTime,this.autoFadeOutTime=n.autoFadeOutTime,this.weight=n.weight,this.name=n.name.length>0?n.name:n.animation,this.group=n.group,n.pauseFadeIn?this._playheadState=2:this._playheadState=3,n.duration<0?(this._position=0,this._duration=this._animationData.duration,0!==n.position?this.timeScale>=0?this._time=n.position:this._time=n.position-this._duration:this._time=0):(this._position=n.position,this._duration=n.duration,this._time=0),this.timeScale<0&&0===this._time&&(this._time=-1e-6),this.fadeTotalTime<=0&&(this._fadeProgress=.999999),n.boneMask.length>0){this._boneMask.length=n.boneMask.length;for(var r=0,s=this._boneMask.length;r0,r=!0,s=!0,a=this._time;if(this._weightResult=this.weight*this._fadeProgress,null!==this._parent&&(this._weightResult*=this._parent._weightResult/this._parent._fadeProgress),this._actionTimeline.playState<=0&&this._actionTimeline.update(a),n){var o=2*i;this._actionTimeline.currentTime=Math.floor(this._actionTimeline.currentTime*o)/o}if(null!==this._zOrderTimeline&&this._zOrderTimeline.playState<=0&&this._zOrderTimeline.update(a),n){var h=Math.floor(this._actionTimeline.currentTime*i);this._armature._cacheFrameIndex===h?(r=!1,s=!1):(this._armature._cacheFrameIndex=h,this._animationData.cachedFrames[h]?s=!1:this._animationData.cachedFrames[h]=!0)}if(r){if(s)for(var u=0,l=this._boneTimelines.length;u0&&(this._subFadeState=0,this._poseTimelines.length>0)){for(var _=0,d=this._poseTimelines;_0&&this.autoFadeOutTime>=0&&this.fadeOut(this.autoFadeOutTime)}}},r.prototype.play=function(){this._playheadState=3},r.prototype.stop=function(){this._playheadState&=1},r.prototype.fadeOut=function(t,e){if(void 0===e&&(e=!0),t<0&&(t=0),e&&(this._playheadState&=2),this._fadeState>0){if(t>this.fadeTotalTime-this._fadeTime)return}else{this._fadeState=1,this._subFadeState=-1,(t<=0||this._fadeProgress<=0)&&(this._fadeProgress=1e-6);for(var i=0,n=this._boneTimelines;i1e-6?t/this._fadeProgress:0,this._fadeTime=this.fadeTotalTime*(1-this._fadeProgress)},r.prototype.containsBoneMask=function(t){return 0===this._boneMask.length||this._boneMask.indexOf(t)>=0},r.prototype.addBoneMask=function(t,e){void 0===e&&(e=!0);var i=this._armature.getBone(t);if(null!==i){if(this._boneMask.indexOf(t)<0&&this._boneMask.push(t),e)for(var n=0,r=this._armature.getBones();n=0&&this._boneMask.splice(i,1),e){var n=this._armature.getBone(t);if(null!==n){var r=this._armature.getBones();if(this._boneMask.length>0)for(var s=0,a=r;s=0&&n.contains(o)&&this._boneMask.splice(h,1)}else for(var u=0,l=r;u0},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isFadeComplete",{get:function(){return 0===this._fadeState},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isPlaying",{get:function(){return!!(2&this._playheadState)&&this._actionTimeline.playState<=0},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isCompleted",{get:function(){return this._actionTimeline.playState>0},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"currentPlayTimes",{get:function(){return this._actionTimeline.currentPlayTimes},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"totalTime",{get:function(){return this._duration},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"currentTime",{get:function(){return this._actionTimeline.currentTime},set:function(t){var e=this._actionTimeline.currentPlayTimes-(this._actionTimeline.playState>0?1:0);if((t<0||this._duration0&&e===this.playTimes-1&&t===this._duration&&(t=this._duration-1e-6),this._time!==t){this._time=t,this._actionTimeline.setCurrentTime(this._time),null!==this._zOrderTimeline&&(this._zOrderTimeline.playState=-1);for(var i=0,n=this._boneTimelines;i0))return 0;if(this.layer!==e){if(this.layerWeight>=this.leftWeight)return this.leftWeight=0,0;this.layer=e,this.leftWeight-=this.layerWeight,this.layerWeight=0}return t*=this.leftWeight,this.layerWeight+=t,this.blendWeight=t,2}return this.dirty=!0,this.layer=e,this.layerWeight=t,this.leftWeight=1,this.blendWeight=t,1},t.prototype.clear=function(){this.dirty=!1,this.layer=0,this.leftWeight=0,this.layerWeight=0,this.blendWeight=0},t}();t.BlendState=n}(rit),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return nit(e,t),e.prototype._onClear=function(){this.playState=-1,this.currentPlayTimes=-1,this.currentTime=-1,this._tweenState=0,this._frameRate=0,this._frameValueOffset=0,this._frameCount=0,this._frameOffset=0,this._frameIndex=-1,this._frameRateR=0,this._position=0,this._duration=0,this._timeScale=1,this._timeOffset=0,this._dragonBonesData=null,this._animationData=null,this._timelineData=null,this._armature=null,this._animationState=null,this._actionTimeline=null,this._frameArray=null,this._frameIntArray=null,this._frameFloatArray=null,this._timelineArray=null,this._frameIndices=null},e.prototype._setCurrentTime=function(t){var e=this.playState,i=this.currentPlayTimes,n=this.currentTime;if(null!==this._actionTimeline&&this._frameCount<=1)this.playState=this._actionTimeline.playState>=0?1:-1,this.currentPlayTimes=1,this.currentTime=this._actionTimeline.currentTime;else if(null===this._actionTimeline||1!==this._timeScale||0!==this._timeOffset){var r=this._animationState.playTimes,s=r*this._duration;t*=this._timeScale,0!==this._timeOffset&&(t+=this._timeOffset*this._animationData.duration),r>0&&(t>=s||t<=-s)?(this.playState<=0&&3===this._animationState._playheadState&&(this.playState=1),this.currentPlayTimes=r,this.currentTime=t<0?0:this._duration+1e-6):(0!==this.playState&&3===this._animationState._playheadState&&(this.playState=0),t<0?(t=-t,this.currentPlayTimes=Math.floor(t/this._duration),this.currentTime=this._duration-t%this._duration):(this.currentPlayTimes=Math.floor(t/this._duration),this.currentTime=t%this._duration)),this.currentTime+=this._position}else this.playState=this._actionTimeline.playState,this.currentPlayTimes=this._actionTimeline.currentPlayTimes,this.currentTime=this._actionTimeline.currentTime;return(this.currentPlayTimes!==i||this.currentTime!==n)&&((e<0&&this.playState!==e||this.playState<=0&&this.currentPlayTimes!==i)&&(this._frameIndex=-1),!0)},e.prototype.init=function(t,e,i){this._armature=t,this._animationState=e,this._timelineData=i,this._actionTimeline=this._animationState._actionTimeline,this===this._actionTimeline&&(this._actionTimeline=null),this._animationData=this._animationState._animationData,this._frameRate=this._animationData.parent.frameRate,this._frameRateR=1/this._frameRate,this._position=this._animationState._position,this._duration=this._animationState._duration,this._dragonBonesData=this._animationData.parent.parent,null!==this._timelineData&&(this._frameIntArray=this._dragonBonesData.frameIntArray,this._frameFloatArray=this._dragonBonesData.frameFloatArray,this._frameArray=this._dragonBonesData.frameArray,this._timelineArray=this._dragonBonesData.timelineArray,this._frameIndices=this._dragonBonesData.frameIndices,this._frameCount=this._timelineArray[this._timelineData.offset+2],this._frameValueOffset=this._timelineArray[this._timelineData.offset+4],this._timeScale=100/this._timelineArray[this._timelineData.offset+0],this._timeOffset=.01*this._timelineArray[this._timelineData.offset+1])},e.prototype.fadeOut=function(){},e.prototype.update=function(t){if(this._setCurrentTime(t)){if(this._frameCount>1){var e=Math.floor(this.currentTime*this._frameRate),i=this._frameIndices[this._timelineData.frameIndicesOffset+e];this._frameIndex!==i&&(this._frameIndex=i,this._frameOffset=this._animationData.frameOffset+this._timelineArray[this._timelineData.offset+5+this._frameIndex],this._onArriveAtFrame())}else this._frameIndex<0&&(this._frameIndex=0,null!==this._timelineData&&(this._frameOffset=this._animationData.frameOffset+this._timelineArray[this._timelineData.offset+5]),this._onArriveAtFrame());0!==this._tweenState&&this._onUpdateFrame()}},e}(t.BaseObject);t.TimelineState=e;var i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return nit(e,t),e._getEasingValue=function(t,e,i){var n=e;switch(t){case 3:n=Math.pow(e,2);break;case 4:n=1-Math.pow(1-e,2);break;case 5:n=.5*(1-Math.cos(e*Math.PI))}return(n-e)*i+e},e._getEasingCurveValue=function(t,e,i,n){if(t<=0)return 0;if(t>=1)return 1;var r=i+1,s=Math.floor(t*r),a=0===s?0:e[n+s-1];return 1e-4*(a+((s===r-1?1e4:e[n+s])-a)*(t*r-s))},e.prototype._onClear=function(){t.prototype._onClear.call(this),this._tweenType=0,this._curveCount=0,this._framePosition=0,this._frameDurationR=0,this._tweenProgress=0,this._tweenEasing=0},e.prototype._onArriveAtFrame=function(){if(this._frameCount>1&&(this._frameIndex!==this._frameCount-1||0===this._animationState.playTimes||this._animationState.currentPlayTimes0?1/e:0}else this._tweenState=1},e.prototype._onUpdateFrame=function(){2===this._tweenState?(this._tweenProgress=(this.currentTime-this._framePosition)*this._frameDurationR,2===this._tweenType?this._tweenProgress=e._getEasingCurveValue(this._tweenProgress,this._frameArray,this._curveCount,this._frameOffset+3):1!==this._tweenType&&(this._tweenProgress=e._getEasingValue(this._tweenType,this._tweenProgress,this._tweenEasing))):this._tweenProgress=0},e}(e);t.TweenTimelineState=i;var n=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return nit(e,t),e.prototype._onClear=function(){t.prototype._onClear.call(this),this.bone=null,this.bonePose=null},e.prototype.blend=function(t){var e=this.bone._blendState.blendWeight,i=this.bone.animationPose,n=this.bonePose.result;2===t?(i.x+=n.x*e,i.y+=n.y*e,i.rotation+=n.rotation*e,i.skew+=n.skew*e,i.scaleX+=(n.scaleX-1)*e,i.scaleY+=(n.scaleY-1)*e):1!==e?(i.x=n.x*e,i.y=n.y*e,i.rotation=n.rotation*e,i.skew=n.skew*e,i.scaleX=(n.scaleX-1)*e+1,i.scaleY=(n.scaleY-1)*e+1):(i.x=n.x,i.y=n.y,i.rotation=n.rotation,i.skew=n.skew,i.scaleX=n.scaleX,i.scaleY=n.scaleY),0===this._animationState._fadeState&&0===this._animationState._subFadeState||(this.bone._transformDirty=!0)},e}(i);t.BoneTimelineState=n;var r=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return nit(e,t),e.prototype._onClear=function(){t.prototype._onClear.call(this),this.slot=null},e}(i);t.SlotTimelineState=r;var s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return nit(e,t),e.prototype._onClear=function(){t.prototype._onClear.call(this),this.constraint=null},e}(i);t.ConstraintTimelineState=s}(rit),function(t){var e=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return nit(i,e),i.toString=function(){return"[class dragonBones.ActionTimelineState]"},i.prototype._onCrossFrame=function(e){var i=this._armature.eventDispatcher;if(this._animationState.actionEnabled)for(var n=this._animationData.frameOffset+this._timelineArray[this._timelineData.offset+5+e],r=this._frameArray[n+1],s=this._animationData.parent.actions,a=0;a0&&s.hasDBEventListener(t.EventObject.COMPLETE)&&((u=t.BaseObject.borrowObject(t.EventObject)).type=t.EventObject.COMPLETE,u.armature=this._armature,u.animationState=this._animationState)),this._frameCount>1){var l=this._timelineData,c=Math.floor(this.currentTime*this._frameRate),f=this._frameIndices[l.frameIndicesOffset+c];if(this._frameIndex!==f){var _=this._frameIndex;if(this._frameIndex=f,null!==this._timelineArray)if(this._frameOffset=this._animationData.frameOffset+this._timelineArray[l.offset+5+this._frameIndex],o){if(_<0){var d=Math.floor(r*this._frameRate);_=this._frameIndices[l.frameIndicesOffset+d],this.currentPlayTimes===n&&_===f&&(_=-1)}for(;_>=0;){var p=this._animationData.frameOffset+this._timelineArray[l.offset+5+_],m=this._frameArray[p]/this._frameRate;if(this._position<=m&&m<=this._position+this._duration&&this._onCrossFrame(_),null!==h&&0===_&&(this._armature._dragonBones.bufferEvent(h),h=null),_>0?_--:_=this._frameCount-1,_===f)break}}else for(_<0&&(d=Math.floor(r*this._frameRate),_=this._frameIndices[l.frameIndicesOffset+d],p=this._animationData.frameOffset+this._timelineArray[l.offset+5+_],m=this._frameArray[p]/this._frameRate,this.currentPlayTimes===n&&(r<=m?_>0?_--:_=this._frameCount-1:_===f&&(_=-1)));_>=0&&(_=0&&(this._frameArray[this._frameOffset+1]>0?this._armature._sortZOrder(this._frameArray,this._frameOffset+2):this._armature._sortZOrder(null,0))},e.prototype._onUpdateFrame=function(){},e}(t.TimelineState);t.ZOrderTimelineState=i;var n=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return nit(i,e),i.toString=function(){return"[class dragonBones.BoneAllTimelineState]"},i.prototype._onArriveAtFrame=function(){if(e.prototype._onArriveAtFrame.call(this),null!==this._timelineData){var t=this._animationData.frameFloatOffset+this._frameValueOffset+6*this._frameIndex,i=this._armature._armatureData.scale,n=this._frameFloatArray,r=this.bonePose.current,s=this.bonePose.delta;r.x=n[t++]*i,r.y=n[t++]*i,r.rotation=n[t++],r.skew=n[t++],r.scaleX=n[t++],r.scaleY=n[t++],2===this._tweenState?(this._frameIndex===this._frameCount-1&&(t=this._animationData.frameFloatOffset+this._frameValueOffset),s.x=n[t++]*i-r.x,s.y=n[t++]*i-r.y,s.rotation=n[t++]-r.rotation,s.skew=n[t++]-r.skew,s.scaleX=n[t++]-r.scaleX,s.scaleY=n[t++]-r.scaleY):(s.x=0,s.y=0,s.rotation=0,s.skew=0,s.scaleX=0,s.scaleY=0)}else r=this.bonePose.current,s=this.bonePose.delta,r.x=0,r.y=0,r.rotation=0,r.skew=0,r.scaleX=1,r.scaleY=1,s.x=0,s.y=0,s.rotation=0,s.skew=0,s.scaleX=0,s.scaleY=0},i.prototype._onUpdateFrame=function(){e.prototype._onUpdateFrame.call(this);var t=this.bonePose.current,i=this.bonePose.delta,n=this.bonePose.result;this.bone._transformDirty=!0,2!==this._tweenState&&(this._tweenState=0),n.x=t.x+i.x*this._tweenProgress,n.y=t.y+i.y*this._tweenProgress,n.rotation=t.rotation+i.rotation*this._tweenProgress,n.skew=t.skew+i.skew*this._tweenProgress,n.scaleX=t.scaleX+i.scaleX*this._tweenProgress,n.scaleY=t.scaleY+i.scaleY*this._tweenProgress},i.prototype.fadeOut=function(){var e=this.bonePose.result;e.rotation=t.Transform.normalizeRadian(e.rotation),e.skew=t.Transform.normalizeRadian(e.skew)},i}(t.BoneTimelineState);t.BoneAllTimelineState=n;var r=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return nit(e,t),e.toString=function(){return"[class dragonBones.BoneTranslateTimelineState]"},e.prototype._onArriveAtFrame=function(){if(t.prototype._onArriveAtFrame.call(this),null!==this._timelineData){var e=this._animationData.frameFloatOffset+this._frameValueOffset+2*this._frameIndex,i=this._armature._armatureData.scale,n=this._frameFloatArray,r=this.bonePose.current,s=this.bonePose.delta;r.x=n[e++]*i,r.y=n[e++]*i,2===this._tweenState?(this._frameIndex===this._frameCount-1&&(e=this._animationData.frameFloatOffset+this._frameValueOffset),s.x=n[e++]*i-r.x,s.y=n[e++]*i-r.y):(s.x=0,s.y=0)}else r=this.bonePose.current,s=this.bonePose.delta,r.x=0,r.y=0,s.x=0,s.y=0},e.prototype._onUpdateFrame=function(){t.prototype._onUpdateFrame.call(this);var e=this.bonePose.current,i=this.bonePose.delta,n=this.bonePose.result;this.bone._transformDirty=!0,2!==this._tweenState&&(this._tweenState=0),n.x=e.x+i.x*this._tweenProgress,n.y=e.y+i.y*this._tweenProgress},e}(t.BoneTimelineState);t.BoneTranslateTimelineState=r;var s=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return nit(i,e),i.toString=function(){return"[class dragonBones.BoneRotateTimelineState]"},i.prototype._onArriveAtFrame=function(){if(e.prototype._onArriveAtFrame.call(this),null!==this._timelineData){var i=this._animationData.frameFloatOffset+this._frameValueOffset+2*this._frameIndex,n=this._frameFloatArray,r=this.bonePose.current,s=this.bonePose.delta;r.rotation=n[i++],r.skew=n[i++],2===this._tweenState?(this._frameIndex===this._frameCount-1?(i=this._animationData.frameFloatOffset+this._frameValueOffset,s.rotation=t.Transform.normalizeRadian(n[i++]-r.rotation)):s.rotation=n[i++]-r.rotation,s.skew=n[i++]-r.skew):(s.rotation=0,s.skew=0)}else r=this.bonePose.current,s=this.bonePose.delta,r.rotation=0,r.skew=0,s.rotation=0,s.skew=0},i.prototype._onUpdateFrame=function(){e.prototype._onUpdateFrame.call(this);var t=this.bonePose.current,i=this.bonePose.delta,n=this.bonePose.result;this.bone._transformDirty=!0,2!==this._tweenState&&(this._tweenState=0),n.rotation=t.rotation+i.rotation*this._tweenProgress,n.skew=t.skew+i.skew*this._tweenProgress},i.prototype.fadeOut=function(){var e=this.bonePose.result;e.rotation=t.Transform.normalizeRadian(e.rotation),e.skew=t.Transform.normalizeRadian(e.skew)},i}(t.BoneTimelineState);t.BoneRotateTimelineState=s;var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return nit(e,t),e.toString=function(){return"[class dragonBones.BoneScaleTimelineState]"},e.prototype._onArriveAtFrame=function(){if(t.prototype._onArriveAtFrame.call(this),null!==this._timelineData){var e=this._animationData.frameFloatOffset+this._frameValueOffset+2*this._frameIndex,i=this._frameFloatArray,n=this.bonePose.current,r=this.bonePose.delta;n.scaleX=i[e++],n.scaleY=i[e++],2===this._tweenState?(this._frameIndex===this._frameCount-1&&(e=this._animationData.frameFloatOffset+this._frameValueOffset),r.scaleX=i[e++]-n.scaleX,r.scaleY=i[e++]-n.scaleY):(r.scaleX=0,r.scaleY=0)}else n=this.bonePose.current,r=this.bonePose.delta,n.scaleX=1,n.scaleY=1,r.scaleX=0,r.scaleY=0},e.prototype._onUpdateFrame=function(){t.prototype._onUpdateFrame.call(this);var e=this.bonePose.current,i=this.bonePose.delta,n=this.bonePose.result;this.bone._transformDirty=!0,2!==this._tweenState&&(this._tweenState=0),n.scaleX=e.scaleX+i.scaleX*this._tweenProgress,n.scaleY=e.scaleY+i.scaleY*this._tweenProgress},e}(t.BoneTimelineState);t.BoneScaleTimelineState=a;var o=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._current=[],e._delta=[],e._result=[],e}return nit(e,t),e.toString=function(){return"[class dragonBones.SurfaceTimelineState]"},e.prototype._onClear=function(){t.prototype._onClear.call(this),this.surface=null,this._frameFloatOffset=0,this._valueCount=0,this._deformCount=0,this._valueOffset=0,this._current.length=0,this._delta.length=0,this._result.length=0},e.prototype._onArriveAtFrame=function(){if(t.prototype._onArriveAtFrame.call(this),null!==this._timelineData){var e=this._animationData.frameFloatOffset+this._frameValueOffset+this._frameIndex*this._valueCount,i=this._armature._armatureData.scale,n=this._frameFloatArray;if(2===this._tweenState){var r=e+this._valueCount;this._frameIndex===this._frameCount-1&&(r=this._animationData.frameFloatOffset+this._frameValueOffset);for(var s=0;s=0){var t=null!==this._timelineData?this._frameArray[this._frameOffset+1]:this.slot._slotData.displayIndex;this.slot.displayIndex!==t&&this.slot._setDisplayIndex(t,!0)}},e}(t.SlotTimelineState);t.SlotDislayTimelineState=h;var u=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._current=[0,0,0,0,0,0,0,0],e._delta=[0,0,0,0,0,0,0,0],e._result=[0,0,0,0,0,0,0,0],e}return nit(e,t),e.toString=function(){return"[class dragonBones.SlotColorTimelineState]"},e.prototype._onClear=function(){t.prototype._onClear.call(this),this._dirty=!1},e.prototype._onArriveAtFrame=function(){if(t.prototype._onArriveAtFrame.call(this),null!==this._timelineData){var e=this._dragonBonesData.intArray,i=this._frameIntArray,n=this._animationData.frameIntOffset+this._frameValueOffset+1*this._frameIndex,r=i[n];r<0&&(r+=65536),this._current[0]=e[r++],this._current[1]=e[r++],this._current[2]=e[r++],this._current[3]=e[r++],this._current[4]=e[r++],this._current[5]=e[r++],this._current[6]=e[r++],this._current[7]=e[r++],2===this._tweenState&&((r=this._frameIndex===this._frameCount-1?i[this._animationData.frameIntOffset+this._frameValueOffset]:i[n+1])<0&&(r+=65536),this._delta[0]=e[r++]-this._current[0],this._delta[1]=e[r++]-this._current[1],this._delta[2]=e[r++]-this._current[2],this._delta[3]=e[r++]-this._current[3],this._delta[4]=e[r++]-this._current[4],this._delta[5]=e[r++]-this._current[5],this._delta[6]=e[r++]-this._current[6],this._delta[7]=e[r++]-this._current[7])}else{var s=this.slot._slotData.color;this._current[0]=100*s.alphaMultiplier,this._current[1]=100*s.redMultiplier,this._current[2]=100*s.greenMultiplier,this._current[3]=100*s.blueMultiplier,this._current[4]=s.alphaOffset,this._current[5]=s.redOffset,this._current[6]=s.greenOffset,this._current[7]=s.blueOffset}},e.prototype._onUpdateFrame=function(){t.prototype._onUpdateFrame.call(this),this._dirty=!0,2!==this._tweenState&&(this._tweenState=0),this._result[0]=.01*(this._current[0]+this._delta[0]*this._tweenProgress),this._result[1]=.01*(this._current[1]+this._delta[1]*this._tweenProgress),this._result[2]=.01*(this._current[2]+this._delta[2]*this._tweenProgress),this._result[3]=.01*(this._current[3]+this._delta[3]*this._tweenProgress),this._result[4]=this._current[4]+this._delta[4]*this._tweenProgress,this._result[5]=this._current[5]+this._delta[5]*this._tweenProgress,this._result[6]=this._current[6]+this._delta[6]*this._tweenProgress,this._result[7]=this._current[7]+this._delta[7]*this._tweenProgress},e.prototype.fadeOut=function(){this._tweenState=0,this._dirty=!1},e.prototype.update=function(e){if(t.prototype.update.call(this,e),0!==this._tweenState||this._dirty){var i=this.slot._colorTransform;if(0!==this._animationState._fadeState||0!==this._animationState._subFadeState){if(i.alphaMultiplier!==this._result[0]||i.redMultiplier!==this._result[1]||i.greenMultiplier!==this._result[2]||i.blueMultiplier!==this._result[3]||i.alphaOffset!==this._result[4]||i.redOffset!==this._result[5]||i.greenOffset!==this._result[6]||i.blueOffset!==this._result[7]){var n=Math.pow(this._animationState._fadeProgress,4);i.alphaMultiplier+=(this._result[0]-i.alphaMultiplier)*n,i.redMultiplier+=(this._result[1]-i.redMultiplier)*n,i.greenMultiplier+=(this._result[2]-i.greenMultiplier)*n,i.blueMultiplier+=(this._result[3]-i.blueMultiplier)*n,i.alphaOffset+=(this._result[4]-i.alphaOffset)*n,i.redOffset+=(this._result[5]-i.redOffset)*n,i.greenOffset+=(this._result[6]-i.greenOffset)*n,i.blueOffset+=(this._result[7]-i.blueOffset)*n,this.slot._colorDirty=!0}}else this._dirty&&(this._dirty=!1,i.alphaMultiplier===this._result[0]&&i.redMultiplier===this._result[1]&&i.greenMultiplier===this._result[2]&&i.blueMultiplier===this._result[3]&&i.alphaOffset===this._result[4]&&i.redOffset===this._result[5]&&i.greenOffset===this._result[6]&&i.blueOffset===this._result[7]||(i.alphaMultiplier=this._result[0],i.redMultiplier=this._result[1],i.greenMultiplier=this._result[2],i.blueMultiplier=this._result[3],i.alphaOffset=this._result[4],i.redOffset=this._result[5],i.greenOffset=this._result[6],i.blueOffset=this._result[7],this.slot._colorDirty=!0))}},e}(t.SlotTimelineState);t.SlotColorTimelineState=u;var l=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._current=[],e._delta=[],e._result=[],e}return nit(e,t),e.toString=function(){return"[class dragonBones.DeformTimelineState]"},e.prototype._onClear=function(){t.prototype._onClear.call(this),this.vertexOffset=0,this._dirty=!1,this._frameFloatOffset=0,this._valueCount=0,this._deformCount=0,this._valueOffset=0,this._current.length=0,this._delta.length=0,this._result.length=0},e.prototype._onArriveAtFrame=function(){if(t.prototype._onArriveAtFrame.call(this),null!==this._timelineData){var e=this._animationData.frameFloatOffset+this._frameValueOffset+this._frameIndex*this._valueCount,i=this._armature._armatureData.scale,n=this._frameFloatArray;if(2===this._tweenState){var r=e+this._valueCount;this._frameIndex===this._frameCount-1&&(r=this._animationData.frameFloatOffset+this._frameValueOffset);for(var s=0;s=0&&(this._floats[2]=this._floats[0]+this._floats[1]*this._tweenProgress),this._floats[5]=this._floats[3]+this._floats[4]*this._tweenProgress},e.prototype.blend=function(t){var e=this.animationState,i=e._blendState.blendWeight;2===t?(e.weight+=this._floats[5]*i,e.currentTime+=this._floats[2]*i):(e.weight=this._floats[5]*i,e.currentTime=this._floats[2]*i)},e}(t.TweenTimelineState);t.AnimationTimelineState=f}(rit),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return nit(e,t),e.actionDataToInstance=function(t,i,n){0===t.type?i.type=e.FRAME_EVENT:i.type=10===t.type?e.FRAME_EVENT:e.SOUND_EVENT,i.name=t.name,i.armature=n,i.actionData=t,i.data=t.data,null!==t.bone&&(i.bone=n.getBone(t.bone.name)),null!==t.slot&&(i.slot=n.getSlot(t.slot.name))},e.toString=function(){return"[class dragonBones.EventObject]"},e.prototype._onClear=function(){this.time=0,this.type="",this.name="",this.armature=null,this.bone=null,this.slot=null,this.animationState=null,this.actionData=null,this.data=null},e.START="start",e.LOOP_COMPLETE="loopComplete",e.COMPLETE="complete",e.FADE_IN="fadeIn",e.FADE_IN_COMPLETE="fadeInComplete",e.FADE_OUT="fadeOut",e.FADE_OUT_COMPLETE="fadeOutComplete",e.FRAME_EVENT="frameEvent",e.SOUND_EVENT="soundEvent",e}(t.BaseObject);t.EventObject=e}(rit),function(t){var e=function(){function e(){}return e._getArmatureType=function(t){switch(t.toLowerCase()){case"stage":return 2;case"armature":default:return 0;case"movieclip":return 1}},e._getBoneType=function(t){switch(t.toLowerCase()){case"bone":default:return 0;case"surface":return 1}},e._getDisplayType=function(t){switch(t.toLowerCase()){case"image":default:return 0;case"mesh":return 2;case"armature":return 1;case"boundingbox":return 3;case"path":return 4}},e._getBoundingBoxType=function(t){switch(t.toLowerCase()){case"rectangle":default:return 0;case"ellipse":return 1;case"polygon":return 2}},e._getActionType=function(t){switch(t.toLowerCase()){case"play":default:return 0;case"frame":return 10;case"sound":return 11}},e._getBlendMode=function(t){switch(t.toLowerCase()){case"normal":default:return 0;case"add":return 1;case"alpha":return 2;case"darken":return 3;case"difference":return 4;case"erase":return 5;case"hardlight":return 6;case"invert":return 7;case"layer":return 8;case"lighten":return 9;case"multiply":return 10;case"overlay":return 11;case"screen":return 12;case"subtract":return 13}},e._getPositionMode=function(t){switch(t.toLocaleLowerCase()){case"percent":default:return 1;case"fixed":return 0}},e._getSpacingMode=function(t){switch(t.toLocaleLowerCase()){case"length":default:return 0;case"percent":return 2;case"fixed":return 1}},e._getRotateMode=function(t){switch(t.toLocaleLowerCase()){case"tangent":default:return 0;case"chain":return 1;case"chainscale":return 2}},e.parseDragonBonesData=function(e){return console.warn("Deprecated."),e instanceof ArrayBuffer?t.BinaryDataParser.getInstance().parseDragonBonesData(e):t.ObjectDataParser.getInstance().parseDragonBonesData(e)},e.parseTextureAtlasData=function(i,n){void 0===n&&(n=1),console.warn("已废弃");for(var r={},s=i[e.SUB_TEXTURE],a=0,o=s.length;a255)return encodeURI(r);return r}return String(r)}return n},n.prototype._getCurvePoint=function(t,e,i,n,r,s,a,o,h,u){var l=1-h,c=l*l,f=h*h,_=l*c,d=3*h*c,p=3*l*f,m=h*f;u.x=_*t+d*i+p*r+m*a,u.y=_*e+d*n+p*s+m*o},n.prototype._samplingEasingCurve=function(t,e){for(var i=t.length,n=-2,r=0,s=e.length;r=0&&n+61e-4;){var y=.5*(g+m);this._getCurvePoint(h,u,l,c,f,_,d,p,y,this._helpPoint),a-this._helpPoint.x>0?m=y:g=y}e[r]=this._helpPoint.y}},n.prototype._parseActionDataInFrame=function(e,i,n,r){t.DataParser.EVENT in e&&this._mergeActionFrame(e[t.DataParser.EVENT],i,10,n,r),t.DataParser.SOUND in e&&this._mergeActionFrame(e[t.DataParser.SOUND],i,11,n,r),t.DataParser.ACTION in e&&this._mergeActionFrame(e[t.DataParser.ACTION],i,0,n,r),t.DataParser.EVENTS in e&&this._mergeActionFrame(e[t.DataParser.EVENTS],i,10,n,r),t.DataParser.ACTIONS in e&&this._mergeActionFrame(e[t.DataParser.ACTIONS],i,0,n,r)},n.prototype._mergeActionFrame=function(e,n,r,s,a){for(var o=t.DragonBones.webAssembly?this._armature.actions.size():this._armature.actions.length,h=this._parseActionData(e,r,s,a),u=0,l=null,c=0,f=h;cn)break;u++}null===l&&((l=new i).frameStart=n,this._actionFrames.splice(u+1,0,l));for(var g=0;g0){var _=r.getBone(c);null!==_?f.parent=_:(c in this._cacheBones||(this._cacheBones[c]=[]),this._cacheBones[c].push(f))}if(f.name in this._cacheBones){for(var d=0,p=this._cacheBones[f.name];d0&&null!==i.parent?(s.root=i.parent,s.bone=i):(s.root=i,s.bone=null),s},n.prototype._parsePathConstraint=function(e){var i=this._armature.getSlot(n._getString(e,t.DataParser.TARGET,""));if(null===i)return null;var r=this._armature.defaultSkin;if(null===r)return null;var s=r.getDisplay(i.name,n._getString(e,t.DataParser.TARGET_DISPLAY,i.name));if(null===s||!(s instanceof t.PathDisplayData))return null;var a=e[t.DataParser.BONES];if(null===a||0===a.length)return null;var o=t.BaseObject.borrowObject(t.PathConstraintData);o.name=n._getString(e,t.DataParser.NAME,""),o.type=1,o.pathSlot=i,o.pathDisplayData=s,o.target=i.parent,o.positionMode=t.DataParser._getPositionMode(n._getString(e,t.DataParser.POSITION_MODE,"")),o.spacingMode=t.DataParser._getSpacingMode(n._getString(e,t.DataParser.SPACING_MODE,"")),o.rotateMode=t.DataParser._getRotateMode(n._getString(e,t.DataParser.ROTATE_MODE,"")),o.position=n._getNumber(e,t.DataParser.POSITION,0),o.spacing=n._getNumber(e,t.DataParser.SPACING,0),o.rotateOffset=n._getNumber(e,t.DataParser.ROTATE_OFFSET,0),o.rotateMix=n._getNumber(e,t.DataParser.ROTATE_MIX,1),o.translateMix=n._getNumber(e,t.DataParser.TRANSLATE_MIX,1);for(var h=0,u=a;h0?r:i,this._parsePivot(e,o);break;case 1:var h=a=t.BaseObject.borrowObject(t.ArmatureDisplayData);if(h.name=i,h.path=r.length>0?r:i,h.inheritAnimation=!0,t.DataParser.ACTIONS in e)for(var u=0,l=this._parseActionData(e[t.DataParser.ACTIONS],0,null,null);u0?r:i,p.vertices.data=this._data,t.DataParser.SHARE in e?(this._cacheRawMeshes.push(e),this._cacheMeshes.push(p)):this._parseMesh(e,p),t.DataParser.GLUE_WEIGHTS in e&&t.DataParser.GLUE_MESHES in e&&(this._cacheRawMeshes.push(e),this._cacheMeshes.push(p));break;case 3:var m=this._parseBoundingBox(e);if(null!==m){var g=a=t.BaseObject.borrowObject(t.BoundingBoxDisplayData);g.name=i,g.path=r.length>0?r:i,g.boundingBox=m}break;case 4:var y=e[t.DataParser.LENGTHS],v=a=t.BaseObject.borrowObject(t.PathDisplayData);v.closed=n._getBoolean(e,t.DataParser.CLOSED,!1),v.constantSpeed=n._getBoolean(e,t.DataParser.CONSTANT_SPEED,!1),v.name=i,v.path=r.length>0?r:i,v.vertices.data=this._data,v.curveLengths.length=y.length;for(var b=0,S=y.length;bi.width&&(i.width=h),ui.height&&(i.height=u))}i.width-=i.x,i.height-=i.y}else console.warn("Data error.\n Please reexport DragonBones Data to fixed the bug.");return i},n.prototype._parseAnimation=function(e){var i=t.BaseObject.borrowObject(t.AnimationData);if(i.frameCount=Math.max(n._getNumber(e,t.DataParser.DURATION,1),1),i.playTimes=n._getNumber(e,t.DataParser.PLAY_TIMES,1),i.duration=i.frameCount/this._armature.frameRate,i.fadeInTime=n._getNumber(e,t.DataParser.FADE_IN_TIME,0),i.scale=n._getNumber(e,t.DataParser.SCALE,1),i.name=n._getString(e,t.DataParser.NAME,t.DataParser.DEFAULT_NAME),0===i.name.length&&(i.name=t.DataParser.DEFAULT_NAME),i.frameIntOffset=this._frameIntArray.length,i.frameFloatOffset=this._frameFloatArray.length,i.frameOffset=this._frameArray.length,this._animation=i,t.DataParser.FRAME in e){var r=e[t.DataParser.FRAME],s=r.length;if(s>0)for(var a=0,o=0;a0&&(this._animation.actionTimeline=this._parseTimeline(null,this._actionFrames,"",0,!1,!1,0,this._parseActionFrame),this._actionFrames.length=0),this._animation=null,i},n.prototype._parseTimeline=function(e,r,s,a,o,h,u,l){if(null!==e&&s.length>0&&s in e&&(r=e[s]),null===r)return null;var c=r.length;if(0===c)return null;var f=this._frameIntArray.length,_=this._frameFloatArray.length,d=t.BaseObject.borrowObject(t.TimelineData),p=this._timelineArray.length;if(this._timelineArray.length+=5+c,null!==e?(this._timelineArray[p+0]=Math.round(100*n._getNumber(e,t.DataParser.SCALE,1)),this._timelineArray[p+1]=Math.round(100*n._getNumber(e,t.DataParser.OFFSET,0))):(this._timelineArray[p+0]=100,this._timelineArray[p+1]=0),this._timelineArray[p+2]=c,this._timelineArray[p+3]=u,this._timelineArray[p+4]=o?f-this._animation.frameIntOffset:h?_-this._animation.frameFloatOffset:0,this._timeline=d,d.type=a,d.offset=p,1===c)d.frameIndicesOffset=-1,this._timelineArray[p+5+0]=l.call(this,r[0],0,0)-this._animation.frameOffset;else{var m=this._animation.frameCount+1,g=this._data.frameIndices,y=0;t.DragonBones.webAssembly?(y=g.size(),g.resize(y+m,0)):(y=g.length,g.length+=m),d.frameIndicesOffset=y;for(var v=0,b=0,S=0,w=0;v0)if(t.DataParser.CURVE in e){var a=r+1;this._helpArray.length=a,this._samplingEasingCurve(e[t.DataParser.CURVE],this._helpArray),this._frameArray.length+=2+this._helpArray.length,this._frameArray[s+1]=2,this._frameArray[s+2]=a;for(var o=0;o0){for(var a=this._armature.sortedSlots.length,o=new Array(a-s.length/2),h=new Array(a),u=0;u0?s>=this._prevRotation:s<=this._prevRotation)&&(this._prevClockwise=this._prevClockwise>0?this._prevClockwise-1:this._prevClockwise+1),s=this._prevRotation+s-this._prevRotation+t.Transform.PI_D*this._prevClockwise)),this._prevClockwise=n._getNumber(e,t.DataParser.TWEEN_ROTATE,0),this._prevRotation=s;var a=this._parseTweenFrame(e,i,r),o=this._frameFloatArray.length;return this._frameFloatArray.length+=6,this._frameFloatArray[o++]=this._helpTransform.x,this._frameFloatArray[o++]=this._helpTransform.y,this._frameFloatArray[o++]=s,this._frameFloatArray[o++]=this._helpTransform.skew,this._frameFloatArray[o++]=this._helpTransform.scaleX,this._frameFloatArray[o++]=this._helpTransform.scaleY,this._parseActionDataInFrame(e,i,this._bone,this._slot),a},n.prototype._parseBoneTranslateFrame=function(e,i,r){var s=this._parseTweenFrame(e,i,r),a=this._frameFloatArray.length;return this._frameFloatArray.length+=2,this._frameFloatArray[a++]=n._getNumber(e,t.DataParser.X,0),this._frameFloatArray[a++]=n._getNumber(e,t.DataParser.Y,0),s},n.prototype._parseBoneRotateFrame=function(e,i,r){var s=n._getNumber(e,t.DataParser.ROTATE,0)*t.Transform.DEG_RAD;0!==i&&(0===this._prevClockwise?s=this._prevRotation+t.Transform.normalizeRadian(s-this._prevRotation):((this._prevClockwise>0?s>=this._prevRotation:s<=this._prevRotation)&&(this._prevClockwise=this._prevClockwise>0?this._prevClockwise-1:this._prevClockwise+1),s=this._prevRotation+s-this._prevRotation+t.Transform.PI_D*this._prevClockwise)),this._prevClockwise=n._getNumber(e,t.DataParser.CLOCK_WISE,0),this._prevRotation=s;var a=this._parseTweenFrame(e,i,r),o=this._frameFloatArray.length;return this._frameFloatArray.length+=2,this._frameFloatArray[o++]=s,this._frameFloatArray[o++]=n._getNumber(e,t.DataParser.SKEW,0)*t.Transform.DEG_RAD,a},n.prototype._parseBoneScaleFrame=function(e,i,r){var s=this._parseTweenFrame(e,i,r),a=this._frameFloatArray.length;return this._frameFloatArray.length+=2,this._frameFloatArray[a++]=n._getNumber(e,t.DataParser.X,1),this._frameFloatArray[a++]=n._getNumber(e,t.DataParser.Y,1),s},n.prototype._parseSurfaceFrame=function(e,i,r){var s=this._frameFloatArray.length,a=this._parseTweenFrame(e,i,r),o=e[t.DataParser.VERTICES],h=n._getNumber(e,t.DataParser.OFFSET,0),u=this._surface.vertices.length/2,l=0,c=0;this._frameFloatArray.length+=2*u;for(var f=0;f<2*u;f+=2)l=f=o.length?0:o[f-h],c=f+1=o.length?0:o[f+1-h],this._frameFloatArray[s+f]=l,this._frameFloatArray[s+f+1]=c;if(0===i){var _=this._frameIntArray.length;this._frameIntArray.length+=5,this._frameIntArray[_+0]=0,this._frameIntArray[_+1]=this._frameFloatArray.length-s,this._frameIntArray[_+2]=this._frameFloatArray.length-s,this._frameIntArray[_+3]=0,this._frameIntArray[_+4]=s-this._animation.frameFloatOffset,this._timelineArray[this._timeline.offset+3]=_-this._animation.frameIntOffset}return a},n.prototype._parseSlotDisplayFrame=function(e,i,r){var s=this._parseFrame(e,i,r);return this._frameArray.length+=1,t.DataParser.VALUE in e?this._frameArray[s+1]=n._getNumber(e,t.DataParser.VALUE,0):this._frameArray[s+1]=n._getNumber(e,t.DataParser.DISPLAY_INDEX,0),this._parseActionDataInFrame(e,i,this._slot.parent,this._slot),s},n.prototype._parseSlotColorFrame=function(e,i,n){var r=this._parseTweenFrame(e,i,n),s=-1;if(t.DataParser.VALUE in e||t.DataParser.COLOR in e){var a=t.DataParser.VALUE in e?e[t.DataParser.VALUE]:e[t.DataParser.COLOR];for(var o in a){this._parseColorTransform(a,this._helpColorTransform),s=this._intArray.length,this._intArray.length+=8,this._intArray[s++]=Math.round(100*this._helpColorTransform.alphaMultiplier),this._intArray[s++]=Math.round(100*this._helpColorTransform.redMultiplier),this._intArray[s++]=Math.round(100*this._helpColorTransform.greenMultiplier),this._intArray[s++]=Math.round(100*this._helpColorTransform.blueMultiplier),this._intArray[s++]=Math.round(this._helpColorTransform.alphaOffset),this._intArray[s++]=Math.round(this._helpColorTransform.redOffset),this._intArray[s++]=Math.round(this._helpColorTransform.greenOffset),this._intArray[s++]=Math.round(this._helpColorTransform.blueOffset),s-=8;break}}s<0&&(this._defaultColorOffset<0&&(this._defaultColorOffset=s=this._intArray.length,this._intArray.length+=8,this._intArray[s++]=100,this._intArray[s++]=100,this._intArray[s++]=100,this._intArray[s++]=100,this._intArray[s++]=0,this._intArray[s++]=0,this._intArray[s++]=0,this._intArray[s++]=0),s=this._defaultColorOffset);var h=this._frameIntArray.length;return this._frameIntArray.length+=1,this._frameIntArray[h]=s,r},n.prototype._parseSlotFFDFrame=function(e,i,r){var s=this._frameFloatArray.length,a=this._parseTweenFrame(e,i,r),o=t.DataParser.VERTICES in e?e[t.DataParser.VERTICES]:null,h=n._getNumber(e,t.DataParser.OFFSET,0),u=this._intArray[this._mesh.vertices.offset+0],l=this._mesh.parent.name+"_"+this._slot.name+"_"+this._mesh.name,c=this._mesh.vertices.weight,f=0,_=0,d=0,p=0;if(null!==c){var m=this._weightSlotPose[l];this._helpMatrixA.copyFromArray(m,0),this._frameFloatArray.length+=2*c.count,d=c.offset+2+c.bones.length}else this._frameFloatArray.length+=2*u;for(var g=0;g<2*u;g+=2)if(null===o?(f=0,_=0):(f=g=o.length?0:o[g-h],_=g+1=o.length?0:o[g+1-h]),null!==c){var y=this._weightBonePoses[l],v=this._intArray[d++];this._helpMatrixA.transformPoint(f,_,this._helpPoint,!0),f=this._helpPoint.x,_=this._helpPoint.y;for(var b=0;b=0||t.DataParser.DATA_VERSIONS.indexOf(s)>=0){var a=t.BaseObject.borrowObject(t.DragonBonesData);if(a.version=r,a.name=n._getString(e,t.DataParser.NAME,""),a.frameRate=n._getNumber(e,t.DataParser.FRAME_RATE,24),0===a.frameRate&&(a.frameRate=24),t.DataParser.ARMATURE in e){this._data=a,this._parseArray(e);for(var o=0,h=e[t.DataParser.ARMATURE];o0&&(a.stage=a.getArmature(a.armatureNames[0])),this._data=null}return t.DataParser.TEXTURE_ATLAS in e&&(this._rawTextureAtlases=e[t.DataParser.TEXTURE_ATLAS]),a}return console.assert(!1,"Nonsupport data version: "+r+"\nPlease convert DragonBones data to support version.\nRead more: https://github.com/DragonBones/Tools/"),null},n.prototype.parseTextureAtlasData=function(e,i,r){if(void 0===r&&(r=1),console.assert(void 0!==e),null===e){if(null===this._rawTextureAtlases||0===this._rawTextureAtlases.length)return!1;var s=this._rawTextureAtlases[this._rawTextureAtlasIndex++];return this.parseTextureAtlasData(s,i,r),this._rawTextureAtlasIndex>=this._rawTextureAtlases.length&&(this._rawTextureAtlasIndex=0,this._rawTextureAtlases=null),!0}if(i.width=n._getNumber(e,t.DataParser.WIDTH,0),i.height=n._getNumber(e,t.DataParser.HEIGHT,0),i.scale=1===r?1/n._getNumber(e,t.DataParser.SCALE,1):r,i.name=n._getString(e,t.DataParser.NAME,""),i.imagePath=n._getString(e,t.DataParser.IMAGE_PATH,""),t.DataParser.SUB_TEXTURE in e)for(var a=e[t.DataParser.SUB_TEXTURE],o=0,h=a.length;o0&&f>0&&(l.frame=t.TextureData.createRectangle(),l.frame.x=n._getNumber(u,t.DataParser.FRAME_X,0),l.frame.y=n._getNumber(u,t.DataParser.FRAME_Y,0),l.frame.width=c,l.frame.height=f),i.addTexture(l)}return!0},n.getInstance=function(){return null===n._objectDataParserInstance&&(n._objectDataParserInstance=new n),n._objectDataParserInstance},n._objectDataParserInstance=null,n}(t.DataParser);t.ObjectDataParser=e;var i=function(){this.frameStart=0,this.actions=[]};t.ActionFrame=i}(rit),function(t){var e=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return nit(i,e),i.prototype._inRange=function(t,e,i){return e<=t&&t<=i},i.prototype._decodeUTF8=function(t){for(var e,i=0,n="",r=0,s=0,a=0,o=0;t.length>i;){var h=t[i++];if(-1===h)e=0!==s?65533:-1;else if(0===s)this._inRange(h,0,127)?e=h:(this._inRange(h,194,223)?(s=1,o=128,r=h-192):this._inRange(h,224,239)?(s=2,o=2048,r=h-224):this._inRange(h,240,244)&&(s=3,o=65536,r=h-240),r*=Math.pow(64,s),e=null);else if(this._inRange(h,128,191))if(a+=1,r+=(h-128)*Math.pow(64,s-a),a!==s)e=null;else{var u=r,l=o;r=0,s=0,a=0,o=0,e=this._inRange(u,l,1114111)&&!this._inRange(u,55296,57343)?u:h}else r=0,s=0,a=0,o=0,i--,e=h;null!==e&&-1!==e&&(e<=65535?e>0&&(n+=String.fromCharCode(e)):(e-=65536,n+=String.fromCharCode(55296+(e>>10&1023)),n+=String.fromCharCode(56320+(1023&e))))}return n},i.prototype._getUTF16Key=function(t){for(var e=0,i=t.length;e255)return encodeURI(t);return t},i.prototype._parseBinaryTimeline=function(e,i,n){void 0===n&&(n=null);var r=null!==n?n:t.BaseObject.borrowObject(t.TimelineData);r.type=e,r.offset=i,this._timeline=r;var s=this._timelineArrayBuffer[r.offset+2];if(1===s)r.frameIndicesOffset=-1;else{var a=0,o=this._animation.frameCount+1,h=this._data.frameIndices;t.DragonBones.webAssembly?(a=h.size(),h.resize(a+o,0)):(a=h.length,h.length+=o),r.frameIndicesOffset=a;for(var u=0,l=0,c=0,f=0;u=0){var r=t.BaseObject.borrowObject(t.WeightData),s=this._intArrayBuffer[i.offset+0],a=this._intArrayBuffer[n+0];r.offset=n;for(var o=0;o0&&e in this._dragonBonesDataMap&&(a=(s=this._dragonBonesDataMap[e]).getArmature(i)),null===a&&(0===e.length||this.autoSearch))for(var o in this._dragonBonesDataMap)if(s=this._dragonBonesDataMap[o],(0===e.length||s.autoSearch)&&null!==(a=s.getArmature(i))){e=o;break}if(null!==a){if(t.dataName=e,t.textureAtlasName=r,t.data=s,t.armature=a,t.skin=null,n.length>0&&(t.skin=a.getSkin(n),null===t.skin&&this.autoSearch))for(var o in this._dragonBonesDataMap){var h=this._dragonBonesDataMap[o].getArmature(n);if(null!==h){t.skin=h.defaultSkin;break}}return null===t.skin&&(t.skin=a.defaultSkin),!0}return!1},e.prototype._buildBones=function(e,i){for(var n=0,r=e.armature.sortedBones;n0&&(o.texture=this._getTextureData(e.textureAtlasName,i.path)),null===o.texture&&(o.texture=this._getTextureData(s,i.path)),a=null!==n&&2===n.type&&this._isSupportMesh()?r.meshDisplay:r.rawDisplay;break;case 2:var h=i;null!==e&&e.textureAtlasName.length>0&&(h.texture=this._getTextureData(e.textureAtlasName,h.path)),null===h.texture&&(h.texture=this._getTextureData(s,h.path)),a=this._isSupportMesh()?r.meshDisplay:r.rawDisplay;break;case 1:var u=i,l=this._buildChildArmature(e,r,i);if(null!==l){if(l.inheritAnimation=u.inheritAnimation,!l.inheritAnimation){var c=u.actions.length>0?u.actions:l.armatureData.defaultActions;if(c.length>0)for(var f=0,_=c;f<_.length;f++){var d=_[f],p=t.BaseObject.borrowObject(t.EventObject);t.EventObject.actionDataToInstance(d,p,r.armature),p.slot=r,r.armature._bufferAction(p,!1)}else l.animation.play()}u.armature=l.armatureData}a=l}return a},e.prototype.parseDragonBonesData=function(t,i,n){void 0===i&&(i=null),void 0===n&&(n=1);for(var r=t instanceof ArrayBuffer?e._binaryParser:this._dataParser,s=r.parseDragonBonesData(t,n);;){var a=this._buildTextureAtlasData(null,null);if(!r.parseTextureAtlasData(null,a,n)){a.returnToPool();break}this.addTextureAtlasData(a,i)}return null!==s&&this.addDragonBonesData(s,i),s},e.prototype.parseTextureAtlasData=function(t,e,i,n){void 0===i&&(i=null),void 0===n&&(n=1);var r=this._buildTextureAtlasData(null,null);return this._dataParser.parseTextureAtlasData(t,r,n),this._buildTextureAtlasData(r,e||null),this.addTextureAtlasData(r,i),r},e.prototype.updateTextureAtlasData=function(t,e){var i=this.getTextureAtlasData(t);if(null!==i)for(var n=0,r=i.length;n=0)){var l=i.getDisplays(u.name);if(l||(null!==a&&i!==a&&(l=a.getDisplays(u.name)),l)){var c=t.DragonBones.webAssembly?l.size():l.length,f=u.displayList;f.length=c;for(var _=0,d=c;_0&&n.inheritDeform,a=this._localVertices;if(r){var o=n.data,h=o.intArray,u=o.floatArray,l=h[n.offset+Lnt.MeshVertexCount],c=h[r.offset+Lnt.WeigthFloatOffset];c<0&&(c+=65536);for(var f=0,_=r.offset+Lnt.WeigthBoneIndices+i.length,d=c,p=0,m=0;f=0;o--)if(s>=e[o]._zOrder){e.splice(o+1,0,r),a=!0;break}a||e.unshift(r)}this._slots=e},i._buildArmature=function(t){var e=yit.borrowObject(tnt);e._skinData=t.skin,e._animation=yit.borrowObject(unt),e._animation._armature=e,e._animation.animations=t.armature.animations,e._isChildArmature=!1;var i=new Knt;return e.init(t.armature,i,i,this._dragonBones),e},i._buildSlot=function(t,e,i){var n=yit.borrowObject(Jnt),r=n;return n.init(e,i,r,r),n},i.getDragonBonesDataByUUID=function(t){for(var e in this._dragonBonesDataMap)if(-1!==e.indexOf(t))return this._dragonBonesDataMap[e];return null},i.removeDragonBonesDataByUUID=function(t,e){for(var i in void 0===e&&(e=!0),this._dragonBonesDataMap)-1!==i.indexOf(t)&&(e&&this._dragonBones.bufferObject(this._dragonBonesDataMap[i]),delete this._dragonBonesDataMap[i])},e}(Rnt),lit._factory=null,uit=lit))||uit,Znt=1/60,$nt=[],trt=[],ert=0,irt=0,nrt=0,rrt=null,srt=null,art=0,ort=0,hrt=0,urt=0,lrt=0,crt=function(){function t(){this.maxVertexCount=0,this.maxIndexCount=0,this._privateMode=!1,this._inited=!1,this._invalid=!0,this._enableCacheAttachedInfo=!1,this.frames=[],this.totalTime=0,this.isCompleted=!1,this._frameIdx=-1,this._armatureInfo=null,this._animationName=null,this._tempSegments=null,this._tempColors=null,this._tempBoneInfos=null}var e=t.prototype;return e.init=function(t,e){this._inited=!0,this._armatureInfo=t,this._animationName=e},e.clear=function(){this._inited=!1;for(var t=0,e=this.frames.length;t0&&(r[urt-1].vfOffset=nrt),r.length=urt,s.length=ert;var a=hrt-1;if(a>=0)if(ort>0){var o=n[a];o.indexCount=ort,o.vfCount=9*art,o.vertexCount=art,n.length=hrt}else n.length=hrt-1;if(0!==n.length){var h,u=i.vertices,l=nrt/5,c=9*l;(!u||u.length>8&255)/255,u[f+7]=(h>>16&255)/255,u[f+8]=(h>>24&255)/255,f+=9;var d=i.indices;(!d||d.lengththis.maxVertexCount?l:this.maxVertexCount,this.maxIndexCount=d.length>this.maxIndexCount?d.length:this.maxIndexCount}},e._traverseArmature=function(t,e){var i,n,r,s,a,o,h,u,l,c=this._tempColors,f=this._tempSegments,_=this._tempBoneInfos,d=t._slots,p=t._bones;if(this._enableCacheAttachedInfo)for(var m=0,g=p.length;m=0&&(ort>0?((l=f[u]).indexCount=ort,l.vertexCount=art,l.vfCount=9*art):hrt--),f[hrt]={tex:h,blendMode:r._blendMode,indexCount:0,vertexCount:0,vfCount:0},hrt++,ort=0,art=0),o=(a.a*e<<24>>>0)+(a.b<<16)+(a.g<<8)+a.r,lrt!==o&&(lrt=o,urt>0&&(c[urt-1].vfOffset=nrt),c[urt++]={r:a.r,g:a.g,b:a.b,a:a.a*e,vfOffset:0}),i=r._localVertices,n=r._indices,s=r._worldMatrix;for(var x=0,T=i.length;x":0},r=i.animations,s=0;for(var a in r)r.hasOwnProperty(a)&&(n[a]=s+1,s++);return Ee(n)}return null},i.destroy=function(){return this._clear(),t.prototype.destroy.call(this)},i._clear=function(){this._factory&&(frt.sharedCache.resetArmature(this._uuid),this._factory.removeDragonBonesDataByUUID(this._uuid,!0))},n(e,[{key:"dragonBonesJson",get:function(){return this._dragonBonesJson},set:function(t){this._dragonBonesJson=t,this._dragonBonesJsonData=JSON.parse(t),this.reset()}}]),e}(Cm),mit=zh(pit.prototype,"_dragonBonesJson",[Srt],(function(){return""})),dit=pit))||dit;A.internal.DragonBonesAsset=wrt;var xrt,Trt=uu,Art=Ou,Crt=(_rt=Kh("dragonBones.DragonBonesAtlasAsset"),drt=Art(Ey),_rt((mrt=function(t){function e(){var e;return(e=t.call(this)||this)._atlasJson=grt&&grt(),e._texture=yrt&&yrt(),e._atlasJsonData=vrt&&vrt(),e._factory=null,e._textureAtlasData=brt&&brt(),e._clear(),e}s(e,t);var i=e.prototype;return i.createNode=function(t){var e=new eb(this.name);return e.addComponent("dragonBones.ArmatureDisplay").dragonAtlasAsset=this,t(null,e)},i.init=function(t){this._factory=t,this._atlasJsonData||(this._atlasJsonData=JSON.parse(this.atlasJson));var e=this._atlasJsonData;this._uuid=this._uuid||e.name,this._textureAtlasData?t.addTextureAtlasData(this._textureAtlasData,this._uuid):this._textureAtlasData=t.parseTextureAtlasData(e,this.texture,this._uuid)},i.destroy=function(){return this._clear(),t.prototype.destroy.call(this)},i._clear=function(){this._factory&&(frt.sharedCache.resetArmature(this._uuid),this._factory.removeTextureAtlasData(this._uuid,!0),this._factory.removeDragonBonesDataByUUID(this._uuid,!0)),this._textureAtlasData=null},n(e,[{key:"atlasJson",get:function(){return this._atlasJson},set:function(t){this._atlasJson=t,this._atlasJsonData=JSON.parse(this.atlasJson),this._clear()}},{key:"texture",get:function(){return this._texture},set:function(t){this._texture=t,this._clear()}}]),e}(Cm),grt=zh(mrt.prototype,"_atlasJson",[Trt],(function(){return""})),yrt=zh(mrt.prototype,"_texture",[Trt,drt],(function(){return null})),vrt=zh(mrt.prototype,"_atlasJsonData",[Trt],(function(){return{}})),brt=zh(mrt.prototype,"_textureAtlasData",[Trt],(function(){return null})),prt=mrt))||prt);A.internal.DragonBonesAtlasAsset=Crt;var Drt,Brt,Irt,Mrt,Prt,Ert,Ort,krt,Rrt,Frt,Lrt,Vrt,Nrt,zrt,Urt,Grt,Hrt,Wrt,jrt,qrt,Xrt,Yrt,Jrt,Krt,Qrt,Zrt,$rt,tst,est,ist,nst=new Kr,rst=Kh("dragonBones.AttachUtil")(xrt=function(){function t(){this._inited=!1,this._armature=null,this._armatureNode=null,this._armatureDisplay=null}var e=t.prototype;return e.init=function(t){this._inited=!0,this._armature=t._armature,this._armatureNode=t.node,this._armatureDisplay=t},e.reset=function(){this._inited=!1,this._armature=null,this._armatureNode=null,this._armatureDisplay=null},e._syncAttachedNode=function(){if(this._inited){this._armatureNode.worldMatrix;var t=null,e=this._armatureDisplay.isAnimationCached();if(!e||!this._armatureDisplay||(t=this._armatureDisplay._curFrame&&this._armatureDisplay._curFrame.boneInfos))for(var i,n,r,s=this._armatureDisplay.sockets,a=this._armatureDisplay.socketNodes,o=this._armature.getBones(),h=s.length-1;h>=0;h--){var u=s[h],l=u.target;if(l)if(l.isValid){var c=e?t[u.boneIndex]:o[u.boneIndex];c&&(i=l,n=c.globalTransformMatrix,r=void 0,(r=nst).m00=n.a,r.m01=n.b,r.m04=-n.c,r.m05=-n.d,r.m12=n.tx,r.m13=n.ty,i.matrix=nst)}else a.delete(u.path),s.splice(h,1)}}},t}())||xrt,sst=function(t){function e(){var e;return(e=t.call(this)||this)._armatures=new Set,e}s(e,t),e.getInstance=function(){return e._instance||(e._instance=new e,YE.registerSystem(e.ID,e._instance,200)),e._instance};var i=e.prototype;return i.add=function(t){t&&(this._armatures.has(t)||this._armatures.add(t))},i.remove=function(t){t&&this._armatures.has(t)&&this._armatures.delete(t)},i.postUpdate=function(t){this._armatures&&this._armatures.forEach((function(e){e.updateAnimation(t),e.syncAttachedNode()}))},i.prepareRenderData=function(){this._armatures&&this._armatures.forEach((function(t){t._markForUpdateRenderData()}))},e}(Ff);sst.ID="ARMATURE",sst._instance=void 0,A.internal.ArmatureSystem=sst;var ast={default:-1};Re(ast);var ost={"":0};Re(ost);var hst={REALTIME:0};Re(hst);var ust={REALTIME:0,SHARED_CACHE:1,PRIVATE_CACHE:2};Re(ust);var lst=Kh,cst=uu,fst=Ou,_st=Gu,dst=(Drt=lst("dragonBones.ArmatureDisplay.DragonBoneSocket"),Brt=fst(eb),Drt((Mrt=function(t,e){void 0===t&&(t=""),void 0===e&&(e=null),this.path=Prt&&Prt(),this.target=Ert&&Ert(),this.boneIndex=null,this.path=t,this.target=e},Prt=zh(Mrt.prototype,"path",[cst],(function(){return""})),Ert=zh(Mrt.prototype,"target",[Brt,cst],(function(){return null})),Irt=Mrt))||Irt);le(dst,"dragonBones.ArmatureDisplay.DragonBoneSocket");var pst=(Ort=lst("dragonBones.ArmatureDisplay"),krt=fst(wrt),Rrt=fst(Crt),Frt=fst(ast),Lrt=fst(ost),Vrt=fst([dst]),Nrt=fst(GT),Ort((ist=function(t){s(i,t);var e=i.prototype;function i(){var e;return(e=t.call(this)||this).playTimes=Grt&&Grt(),e.premultipliedAlpha=Hrt&&Hrt(),e._armature=null,e.attachUtil=void 0,e._defaultArmatureIndexValue=Wrt&&Wrt(),e._dragonAsset=jrt&&jrt(),e._dragonAtlasAsset=qrt&&qrt(),e._armatureName=Xrt&&Xrt(),e._animationName=Yrt&&Yrt(),e._animationIndexValue=Jrt&&Jrt(),e._preCacheMode=-1,e._cacheMode=0,e._defaultCacheModeValue=Krt&&Krt(),e._timeScale=Qrt&&Qrt(),e._playTimes=Zrt&&Zrt(),e._debugBones=$rt&&$rt(),e._enableBatch=tst&&tst(),e._debugDraw=null,e._armatureKey="",e._accTime=0,e._playCount=0,e._frameCache=null,e._curFrame=null,e._playing=!1,e._armatureCache=null,e._eventTarget=void 0,e._factory=null,e._displayProxy=null,e._drawIdx=0,e._drawList=new uo((function(){return{material:null,texture:null,indexOffset:0,indexCount:0}}),1),e.maxVertexCount=0,e.maxIndexCount=0,e._materialCache={},e._enumArmatures=Ee({}),e._enumAnimations=Ee({}),e._socketNodes=new Map,e._cachedSockets=new Map,e._sockets=est&&est(),e._inited=void 0,e._drawInfoList=[],e._cacheModeEnum=void 0,e._eventTarget=new Io,e._inited=!1,e.attachUtil=new rst,e.initFactory(),Ti(f(e),"_animationIndex",e._enumAnimations),Ti(f(e),"_defaultArmatureIndex",e._enumArmatures),e._useVertexOpacity=!0,e}return e.requestDrawInfo=function(t){return this._drawInfoList[t]||(this._drawInfoList[t]=new QF),this._drawInfoList[t]},e.initFactory=function(){this._factory=Qnt.getInstance()},e.onLoad=function(){t.prototype.onLoad.call(this)},e._requestDrawData=function(t,e,i,n){var r=this._drawList.add();return r.material=t,r.texture=e,r.indexOffset=i,r.indexCount=n,r},e.destroyRenderData=function(){this._drawList.reset(),t.prototype.destroyRenderData.call(this)},e.getMaterialTemplate=function(){return null!==this.customMaterial?this.customMaterial:(this.material||this.updateMaterial(),this.material)},e.getMaterialForBlend=function(t,e){var i=t+"/"+e,n=this._materialCache[i];if(n)return n;var r=this.getMaterialTemplate();return(n=new QT({parent:r,subModelIdx:0,owner:this})).recompileShaders({TWO_COLORED:!1,USE_LOCAL:!1}),this._materialCache[i]=n,n.overridePipelineStates({blendState:{targets:[{blendSrc:t,blendDst:e}]}}),n},e._updateBuiltinMaterial=function(){return mT.get("default-spine-material")},e.updateMaterial=function(){var t;t=this._customMaterial?this._customMaterial:this._updateBuiltinMaterial(),this.setSharedMaterial(t,0),this._cleanMaterialCache()},e._render=function(t){var e=0;if(this.renderData&&this._drawList){for(var i=this.renderData,n=i.chunk,r=n.vertexAccessor,s=i.getMeshBuffer(),a=s.indexOffset,o=0;othis.maxVertexCount?e.maxVertexCount:this.maxVertexCount,this.maxIndexCount=e.maxIndexCount>this.maxIndexCount?e.maxIndexCount:this.maxIndexCount,this.renderData.resize(this.maxVertexCount,this.maxIndexCount),(!this.renderData.indices||this.maxIndexCount>this.renderData.indices.length)&&(this.renderData.indices=new Uint16Array(this.maxIndexCount)))),e.isCompleted&&r>=i.length){if(this._playCount++,this.playTimes>0&&this._playCount>=this.playTimes)return this._curFrame=i[i.length-1],this._accTime=0,this._playing=!1,this._playCount=0,this._emitCacheCompleteEvent(),void this.attachUtil._syncAttachedNode();this._accTime=0,r=0,this._emitCacheCompleteEvent()}this._curFrame=i[r],this.attachUtil._syncAttachedNode()}else e.isInvalid()&&(e.updateToFrame(),this._curFrame=i[i.length-1],this.renderData&&(this.renderData.vertexCountthis.maxVertexCount?e.maxVertexCount:this.maxVertexCount,this.maxIndexCount=e.maxIndexCount>this.maxIndexCount?e.maxIndexCount:this.maxIndexCount,this.renderData.resize(this.maxVertexCount,this.maxIndexCount),(!this.renderData.indices||this.maxIndexCount>this.renderData.indices.length)&&(this.renderData.indices=new Uint16Array(this.maxIndexCount))))}}},e.onDestroy=function(){this._materialInstances=this._materialInstances.filter((function(t){return!!t})),this._inited=!1,2===this._cacheMode?(this._armatureCache.dispose(),this._armatureCache=null,this._armature=null):1===this._cacheMode?(this._armatureCache=null,this._armature=null):this._armature&&(this._armature.dispose(),this._armature=null),this._drawList.destroy(),t.prototype.onDestroy.call(this)},e._updateDebugDraw=function(){if(this.debugBones){if(!this._debugDraw){var t,e=new eb("DEBUG_DRAW_NODE");e.hideFlags|=1032;try{(t=e.addComponent("cc.Graphics")).lineWidth=1,t.strokeColor=new cr(255,0,0,255),this._debugDraw=t,this._debugDraw.node.parent=this.node}catch(t){ht(4501,t.message),e.destroy(),e=null}}}else this._debugDraw&&(this._debugDraw.node.parent=null);this._markForUpdateRenderData()},e._updateBatch=function(){this._cleanMaterialCache(),this._markForUpdateRenderData()},e._buildArmature=function(){if(this.dragonAsset&&this.dragonAtlasAsset&&this.armatureName){this._armature&&(2===this._preCacheMode?this._armatureCache.dispose():0===this._preCacheMode&&this._armature.dispose(),this._armatureCache=null,this._armature=null,this._displayProxy=null,this._frameCache=null,this._curFrame=null,this._playing=!1,this._preCacheMode=-1),1===this._cacheMode?this._armatureCache=frt.sharedCache:2===this._cacheMode&&(this._armatureCache=new frt,this._armatureCache.enablePrivateMode());var t=this.dragonAtlasAsset._uuid;if(this._armatureKey=this.dragonAsset.init(this._factory,t),this.isAnimationCached()&&(this._armature=this._armatureCache.getArmatureCache(this.armatureName,this._armatureKey,t),this._armature||(this._cacheMode=0)),this._preCacheMode=this._cacheMode,0===this._cacheMode){if(this._displayProxy=this._factory.buildArmatureDisplay(this.armatureName,this._armatureKey,"",t),!this._displayProxy)return;this._displayProxy._ccNode=this.node,this._displayProxy._ccComponent=this,this._displayProxy.setEventTarget(this._eventTarget),this._armature=this._displayProxy._armature,this._armature.animation.timeScale=this.timeScale}if(0!==this._cacheMode&&this.debugBones&&Y("Debug bones is invalid in cached mode"),this._armature){var e=this._armature.armatureData.aabb;this.node._getUITransformComp().setContentSize(e.width,e.height)}this.attachUtil.init(this),this.animationName&&this.playAnimation(this.animationName,this.playTimes),this._flushAssembler()}},e.querySockets=function(){return this._armature?(0===this._cachedSockets.size&&this._indexBoneSockets(),Array.from(this._cachedSockets.keys()).sort()):[]},e.querySocketPathByName=function(t){for(var e,i=[],n=p(this._cachedSockets.keys());!(e=n()).done;){var r=e.value;r.endsWith(t)&&i.push(r)}return i},e._parseDragonAtlasAsset=function(){this.dragonAtlasAsset&&this.dragonAtlasAsset.init(this._factory)},e._refresh=function(){this._buildArmature(),this._indexBoneSockets(),this._markForUpdateRenderData()},e._updateCacheModeEnum=function(){this._cacheModeEnum=Ee({}),this._armature?Object.assign(this._cacheModeEnum,ust):Object.assign(this._cacheModeEnum,hst),Ti(this,"_defaultCacheMode",this._cacheModeEnum)},e._updateAnimEnum=function(){var t;t=this.dragonAsset?this.dragonAsset.getAnimsEnum(this.armatureName):ost,this._enumAnimations=Ee({}),Object.assign(this._enumAnimations,t||ost),Ee.update(this._enumAnimations),Ti(this,"_animationIndex",this._enumAnimations)},e._updateArmatureEnum=function(){var t;t=this.dragonAsset?this.dragonAsset.getArmatureEnum():ast,this._enumArmatures=Ee({}),Object.assign(this._enumArmatures,t||ast),Ee.update(this._enumArmatures),Ti(this,"_defaultArmatureIndex",this._enumArmatures)},e._indexBoneSockets=function(){if(this._armature){this._cachedSockets.clear();var t=this._cachedSockets,e=function t(e,i,n){if(n.has(e))return n.get(e);var r=i[e];if(!r.parent)return n.set(e,r.name),r.path=r.name,r.name;var s=t(r.parent._boneIndex,i,n)+"/"+r.name;return n.set(e,s),r.path=s,s};!function i(n,r){for(var s=r.getBones(),a=new Map,o=0;o0&&this._frameCache.enableCacheAttachedInfo(),this._frameCache.updateToFrame(0),this._playing=!0,this._curFrame=this._frameCache.frames[0])}else if(this._armature)return this._armature.animation.play(t,this.playTimes);return this._markForUpdateRenderData(),null},e.updateAnimationCache=function(t){this.isAnimationCached()&&this._armatureCache.updateAnimationCache(this._armatureKey,t)},e.invalidAnimationCache=function(){this.isAnimationCached()&&this._armatureCache.invalidAnimationCache(this._armatureKey)},e.getArmatureNames=function(){var t=this._factory.getDragonBonesData(this._armatureKey);return t&&t.armatureNames||[]},e.getAnimationNames=function(t){var e=[],i=this._factory.getDragonBonesData(this._armatureKey);if(i){var n=i.getArmature(t);if(n)for(var r in n.animations)n.animations.hasOwnProperty(r)&&e.push(r)}return e},e.on=function(t,e,i){this.addEventListener(t,e,i)},e.off=function(t,e,i){this.removeEventListener(t,e,i)},e.once=function(t,e,i){this._eventTarget.once(t,e,i)},e.addEventListener=function(t,e,i){this._eventTarget.on(t,e,i)},e.removeEventListener=function(t,e,i){this._eventTarget.off(t,e,i)},e.buildArmature=function(t,e){return this._factory.createArmatureNode(this,t,e)},e.armature=function(){return this._armature},e._flushAssembler=function(){var t=i.Assembler.getAssembler(this);this._assembler!==t&&(this._assembler=t),this._armature&&this._assembler&&(this._renderData=this._assembler.createData(this),this._renderData&&(this.maxVertexCount=this._renderData.vertexCount,this.maxIndexCount=this._renderData.indexCount),this._markForUpdateRenderData(),this._updateColor())},e._updateSocketBindings=function(){if(this._armature){this._socketNodes.clear();for(var t=0,e=this._sockets.length;t0&&this._frameCache&&this._frameCache.enableCacheAttachedInfo()}},{key:"socketNodes",get:function(){return this._socketNodes}},{key:"drawList",get:function(){return this._drawList}},{key:"customMaterial",get:function(){return this._customMaterial},set:function(t){this._customMaterial=t,this.updateMaterial(),this._markForUpdateRenderData()}}]),i}(BL),ist.AnimationCacheMode=ust,v((Urt=ist).prototype,"dragonAsset",[krt],Object.getOwnPropertyDescriptor(Urt.prototype,"dragonAsset"),Urt.prototype),v(Urt.prototype,"dragonAtlasAsset",[Rrt],Object.getOwnPropertyDescriptor(Urt.prototype,"dragonAtlasAsset"),Urt.prototype),v(Urt.prototype,"_defaultArmatureIndex",[Frt],Object.getOwnPropertyDescriptor(Urt.prototype,"_defaultArmatureIndex"),Urt.prototype),v(Urt.prototype,"_animationIndex",[Lrt],Object.getOwnPropertyDescriptor(Urt.prototype,"_animationIndex"),Urt.prototype),v(Urt.prototype,"timeScale",[cst],Object.getOwnPropertyDescriptor(Urt.prototype,"timeScale"),Urt.prototype),Grt=zh(Urt.prototype,"playTimes",[cst],(function(){return-1})),Hrt=zh(Urt.prototype,"premultipliedAlpha",[cst],(function(){return!1})),v(Urt.prototype,"sockets",[Vrt],Object.getOwnPropertyDescriptor(Urt.prototype,"sockets"),Urt.prototype),Wrt=zh(Urt.prototype,"_defaultArmatureIndexValue",[cst],(function(){return-1})),jrt=zh(Urt.prototype,"_dragonAsset",[cst],(function(){return null})),qrt=zh(Urt.prototype,"_dragonAtlasAsset",[cst],(function(){return null})),Xrt=zh(Urt.prototype,"_armatureName",[cst],(function(){return""})),Yrt=zh(Urt.prototype,"_animationName",[cst],(function(){return""})),Jrt=zh(Urt.prototype,"_animationIndexValue",[cst],(function(){return 0})),Krt=zh(Urt.prototype,"_defaultCacheModeValue",[cst],(function(){return 0})),Qrt=zh(Urt.prototype,"_timeScale",[cst],(function(){return 1})),Zrt=zh(Urt.prototype,"_playTimes",[cst],(function(){return-1})),$rt=zh(Urt.prototype,"_debugBones",[cst],(function(){return!1})),tst=zh(Urt.prototype,"_enableBatch",[cst],(function(){return!1})),est=zh(Urt.prototype,"_sockets",[cst],(function(){return[]})),v(Urt.prototype,"customMaterial",[_st,Nrt],Object.getOwnPropertyDescriptor(Urt.prototype,"customMaterial"),Urt.prototype),zrt=Urt))||zrt);A.internal.ArmatureDisplay=pst;var mst,gst,yst,vst,bst,Sst,wst,xst,Tst,Ast,Cst,Dst=new cr(255,0,0,255),Bst=new cr(0,0,255,255),Ist=new cr(0,255,0,255),Mst=0,Pst=0,Est=0,Ost=0,kst=0,Rst=0,Fst=0,Lst=0,Vst=0,Nst=new Float32Array(4),zst=new ir(0,0,0),Ust=new Kr,Gst=null,Hst=null;function Wst(t,e){if(!t)return null;var i,n;switch(e){case 1:i=bst?1:2,n=1;break;case 10:i=7,n=4;break;case 12:i=1,n=8;break;default:i=bst?1:2,n=4}return Ast.getMaterialForBlend(i,n)}function jst(t,e){var i=t.a*e*vst,n=bst?i/255:1,r=t.r*mst*n/255,s=t.g*gst*n/255,a=t.b*yst*n/255;Nst[0]=r,Nst[1]=s,Nst[2]=a,Nst[3]=bst?1:i/255}var qst=null,Xst=function(){function t(){this.accessor=qst,this.vCount=32767}var e=t.prototype;return e.ensureAccessor=function(){if(!qst){var t=YE.root.device,e=YE.root.batcher2D,i=IF;this.accessor=qst=new NF(t,i,this.vCount),e.registerBufferAccessor(Number.parseInt("DRAGONBONES",36),qst)}return this.accessor},e.createData=function(t){var e=t.renderData;if(!e){this.ensureAccessor();for(var i=t._armature._slots,n=0,r=0,s=0;s0&&(Ast._requestDrawData(Gst,Hst,Vst,d),Vst=Rst),Hst=_,Gst=r}jst(o,e),Ust.set(h._worldMatrix),s=h._localVertices,Pst=s.length/4,Mst=9*Pst,a=h._indices,kst=a.length;var p=!1;if(Est+Pst>Fst&&(Fst=Est+Pst,p=!0),Rst+kst>Lst&&(Lst=Rst+kst,p=!0),p){var m=xst,g=n.chunk.vertexOffset;n.resizeAndCopy(Fst,Lst>n.indexCount?Lst:n.indexCount),Tst=n.chunk.vb,Lst>xst.length&&(xst=n.indices=new Uint16Array(Lst));for(var y=n.chunk.vertexOffset-g,v=0;v0&&(Ast._requestDrawData(Gst,Hst,Vst,u),Vst=Rst),Ast.maxIndexCount0&&(Ast._requestDrawData(Gst,Hst,Vst,b),Vst=Rst),Gst=n,Hst=v.tex}Pst=v.vertexCount,kst=v.indexCount,a=d.chunk.vertexOffset;for(var S=Rst,w=Rst+kst;S=_&&(jst(f=c[l++],1),_=f.vfOffset),p.set(Nst,B+5);o+=u,Est+=Pst,Rst+=kst,Pst=0,kst=0}}var M=Rst-Vst;Hst&&M>0&&Ast._requestDrawData(Gst,Hst,Vst,M)}}}function Qst(t){var e=t._armature;if(e&&null!==t.renderData){Sst=!0,bst=t.premultipliedAlpha,t.drawList.reset(),Ast=t,t.node,wst=t.renderData,Ast=t,Cst=0,Gst=null;var i=t.color;mst=i.r/255,gst=i.g/255,yst=i.b/255,vst=t.node._uiProps.opacity,4294967295!==cr.toUint32(i)&&(Cst|=1);var n=t.node.getWorldMatrix();if(Mst=0,Est=0,Ost=0,kst=0,Rst=0,Vst=0,Fst=Ast.maxVertexCount,Lst=Ast.maxIndexCount,t.isAnimationCached())Kst(t._curFrame,n);else{Jst(e,1,n);var r=t._debugDraw;if(t.debugBones&&r){r.clear(),r.lineWidth=5,r.strokeColor=Dst,r.fillColor=Bst;for(var s=e.getBones(),a=0,o=s.length;a0&&(t.extensions.useVAO&&n.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),n.glVAO=null),Dat.gpuInputAssembler=null,n.glArrayBuffer!==e.glBuffer&&(i.bindBuffer(34962,e.glBuffer),n.glArrayBuffer=e.glBuffer),i.bufferData(34962,e.size,r),i.bindBuffer(34962,null),n.glArrayBuffer=null))}else if(4&e.usage){e.glTarget=34963;var a=i.createBuffer();a&&(e.glBuffer=a,e.size>0&&(t.extensions.useVAO&&n.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),n.glVAO=null),Dat.gpuInputAssembler=null,n.glElementArrayBuffer!==e.glBuffer&&(i.bindBuffer(34963,e.glBuffer),n.glElementArrayBuffer=e.glBuffer),i.bufferData(34963,e.size,r),i.bindBuffer(34963,null),n.glElementArrayBuffer=null))}else 16&e.usage?(e.glTarget=0,e.buffer&&(e.vf32=new Float32Array(e.buffer.buffer))):(64&e.usage||2&e.usage||1&e.usage||ht(16315),e.glTarget=0)}function gat(t,e){var i=t.gl,n=t.stateCache;if(e.glBuffer){switch(e.glTarget){case 34962:t.extensions.useVAO&&n.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),n.glVAO=null),Dat.gpuInputAssembler=null,i.bindBuffer(34962,null),n.glArrayBuffer=null;break;case 34963:t.extensions.useVAO&&n.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),n.glVAO=null),Dat.gpuInputAssembler=null,i.bindBuffer(34963,null),n.glElementArrayBuffer=null}i.deleteBuffer(e.glBuffer),e.glBuffer=null}}function yat(t,e,i,n,r){if(16&e.usage)ArrayBuffer.isView(i)?e.vf32.set(i,n/4):e.vf32.set(new Float32Array(i),n/4);else if(64&e.usage){e.indirects.clearDraws();for(var s=i.drawInfos,a=0;at.capabilities.maxTextureSize&&ht(9100,a,t.capabilities.maxTextureSize),t.textureExclusive[e.format]||t.extensions.WEBGL_depth_texture||!ip[e.format].hasDepth){if(e.glTexture=i.createTexture(),e.size>0){var o=n.glTexUnits[n.texUnit];if(o.glTexture!==e.glTexture&&(i.bindTexture(3553,e.glTexture),o.glTexture=e.glTexture),ip[e.format].isCompressed)for(var h=0;h>1),s=iat(1,s>>1)}else for(var c=0;c>1),s=iat(1,s>>1);e.isPowerOf2?(e.glWrapS=10497,e.glWrapT=10497):(e.glWrapS=33071,e.glWrapT=33071),e.glMinFilter=9729,e.glMagFilter=9729,i.texParameteri(e.glTarget,10242,e.glWrapS),i.texParameteri(e.glTarget,10243,e.glWrapT),i.texParameteri(e.glTarget,10241,e.glMinFilter),i.texParameteri(e.glTarget,10240,e.glMagFilter)}}else e.glInternalFmt=sat(e.format),e.glRenderbuffer=i.createRenderbuffer(),e.size>0&&(n.glRenderbuffer!==e.glRenderbuffer&&(i.bindRenderbuffer(36161,e.glRenderbuffer),n.glRenderbuffer=e.glRenderbuffer),i.renderbufferStorage(36161,e.glInternalFmt,r,s));break;case 3:e.glTarget=34067;var f=iat(r,s);if(f>t.capabilities.maxCubeMapTextureSize&&ht(9100,f,t.capabilities.maxTextureSize),e.glTexture=i.createTexture(),e.size>0){var _=n.glTexUnits[n.texUnit];if(_.glTexture!==e.glTexture&&(i.bindTexture(34067,e.glTexture),_.glTexture=e.glTexture),ip[e.format].isCompressed)for(var d=0;d<6;++d){r=e.width,s=e.height;for(var p=0;p>1),s=iat(1,s>>1)}}else for(var y=0;y<6;++y){r=e.width,s=e.height;for(var v=0;v>1),s=iat(1,s>>1)}e.isPowerOf2?(e.glWrapS=10497,e.glWrapT=10497):(e.glWrapS=33071,e.glWrapT=33071),e.glMinFilter=9729,e.glMagFilter=9729,i.texParameteri(e.glTarget,10242,e.glWrapS),i.texParameteri(e.glTarget,10243,e.glWrapT),i.texParameteri(e.glTarget,10241,e.glMinFilter),i.texParameteri(e.glTarget,10240,e.glMagFilter)}break;default:ht(16317),e.type=1,e.glTarget=3553}}function bat(t,e){var i=t.gl,n=t.stateCache;if(e.glTexture){var r=n.glTexUnits,s=n.texUnit;i.deleteTexture(e.glTexture);for(var a=0;at.capabilities.maxTextureSize&&ht(9100,a,t.capabilities.maxTextureSize),e.glRenderbuffer)n.glRenderbuffer!==e.glRenderbuffer&&(i.bindRenderbuffer(36161,e.glRenderbuffer),n.glRenderbuffer=e.glRenderbuffer),i.renderbufferStorage(36161,e.glInternalFmt,r,s);else if(e.glTexture){var o=n.glTexUnits[n.texUnit];if(o.glTexture!==e.glTexture&&(i.bindTexture(3553,e.glTexture),o.glTexture=e.glTexture),ip[e.format].isCompressed)for(var h=0;h>1),s=iat(1,s>>1)}else for(var c=0;c>1),s=iat(1,s>>1)}break;case 3:e.glTarget=34067;var f=iat(r,s);f>t.capabilities.maxCubeMapTextureSize&&ht(9100,f,t.capabilities.maxTextureSize);var _=n.glTexUnits[n.texUnit];if(_.glTexture!==e.glTexture&&(i.bindTexture(34067,e.glTexture),_.glTexture=e.glTexture),ip[e.format].isCompressed)for(var d=0;d<6;++d){r=e.width,s=e.height;for(var p=0;p>1),s=iat(1,s>>1)}}else for(var y=0;y<6;++y){r=e.width,s=e.height;for(var v=0;v>1),s=iat(1,s>>1)}break;default:ht(16317),e.type=1,e.glTarget=3553}}}function wat(t,e){for(var i=0;i0){e.glBlocks=new Array(e.blocks.length);for(var x=0;x0){e.glSamplerTextures=new Array(e.samplerTextures.length);for(var k=0;k=0&&D.gpuDescriptors[B],M=null,P=0;if(I&&I.gpuBuffer){var E=I.gpuBuffer,O=T[C.set],k=O&&O[C.binding];k>=0&&(P=r[k]),"vf32"in E?M=E.vf32:(P+=E.offset,M=E.gpuBuffer.vf32),P>>=2}if(M)for(var R=C.glActiveUniforms.length,F=0;F=0&&Pt.gpuDescriptors[Et],kt=Mt.units.length,Rt=0;Rt0){var Lt=Ot.gpuTexture,Vt=l.glTexUnits[Ft];Vt.glTexture!==Lt.glTexture&&(l.texUnit!==Ft&&(u.activeTexture(33984+Ft),l.texUnit=Ft),Lt.glTexture?u.bindTexture(Lt.glTarget,Lt.glTexture):u.bindTexture(Lt.glTarget,t.nullTex2D.gpuTexture.glTexture),Vt.glTexture=Lt.glTexture);var Nt=Ot.gpuSampler;Lt.isPowerOf2?(a=Nt.glWrapS,o=Nt.glWrapT):(a=33071,o=33071),h=Lt.isPowerOf2?Lt.mipLevel<=1&&(9985===Nt.glMinFilter||9987===Nt.glMinFilter)?9729:Nt.glMinFilter:9729===Nt.glMinFilter||9985===Nt.glMinFilter||9987===Nt.glMinFilter?9729:9728,Lt.glWrapS!==a&&(l.texUnit!==Ft&&(u.activeTexture(33984+Ft),l.texUnit=Ft),u.texParameteri(Lt.glTarget,10242,a),Lt.glWrapS=a),Lt.glWrapT!==o&&(l.texUnit!==Ft&&(u.activeTexture(33984+Ft),l.texUnit=Ft),u.texParameteri(Lt.glTarget,10243,o),Lt.glWrapT=o),Lt.glMinFilter!==h&&(l.texUnit!==Ft&&(u.activeTexture(33984+Ft),l.texUnit=Ft),u.texParameteri(Lt.glTarget,10241,h),Lt.glMinFilter=h),Lt.glMagFilter!==Nt.glMagFilter&&(l.texUnit!==Ft&&(u.activeTexture(33984+Ft),l.texUnit=Ft),u.texParameteri(Lt.glTarget,10240,Nt.glMagFilter),Lt.glMagFilter=Nt.glMagFilter)}Ot=Pt.gpuDescriptors[++Et]}}}if(i&&_&&(d||Dat.gpuInputAssembler!==i)){Dat.gpuInputAssembler=i;var zt=t.extensions.ANGLE_instanced_arrays;if(t.extensions.useVAO){var Ut=t.extensions.OES_vertex_array_object,Gt=i.glVAOs.get(_.glProgram);if(!Gt){var Ht;Gt=Ut.createVertexArrayOES(),i.glVAOs.set(_.glProgram,Gt),Ut.bindVertexArrayOES(Gt),u.bindBuffer(34962,null),u.bindBuffer(34963,null),l.glArrayBuffer=null,l.glElementArrayBuffer=null;for(var Wt=_.glInputs.length,jt=0;jt=0&&(u.enableVertexAttribArray(ue),l.glEnabledAttribLocs[ue]=!0),l.glCurrentAttribLocs[ue]=!0,u.vertexAttribPointer(ue,re.count,re.glType,re.isNormalized,re.stride,le),zt&&zt.vertexAttribDivisorANGLE(ue,re.isInstanced?1:0)}}}var ce=i.gpuIndexBuffer;ce&&l.glElementArrayBuffer!==ce.glBuffer&&(u.bindBuffer(34963,ce.glBuffer),l.glElementArrayBuffer=ce.glBuffer);for(var fe=0;fe0){var _=e.firstIndex*h.stride;r.drawElementsInstancedANGLE(o,e.indexCount,a.glIndexType,_,e.instanceCount)}}else e.vertexCount>0&&r.drawArraysInstancedANGLE(o,e.firstVertex,e.vertexCount,e.instanceCount);else if(h){if(e.indexCount>0){var d=e.firstIndex*h.stride;i.drawElements(o,e.indexCount,a.glIndexType,d)}}else e.vertexCount>0&&i.drawArrays(o,e.firstVertex,e.vertexCount)}}function Eat(t,e,i,n){var r=t.gl,s=t.stateCache,a=s.glTexUnits[s.texUnit];a.glTexture!==i.glTexture&&(r.bindTexture(i.glTarget,i.glTexture),a.glTexture=i.glTexture);var o=0,h=0;switch(i.glTarget){case 3553:for(var u=0;u0?A:_.width,p.height=g.buffTexHeight>0?g.buffTexHeight:_.height;var C=S+d.x===i.width>>y?S:_.width,D=w+d.y===i.height>>y?w:_.height,B=void 0,I=e[o++];if(p.width===_.width&&p.height===_.height){var M=op(i.format,C,D,1)/l.BYTES_PER_ELEMENT;lt(Number.isInteger(M),9101),B=new l(I.buffer,I.byteOffset+g.buffOffset,M)}else B=kat(I,i.format,g.buffOffset,p,_);c?36196===i.glInternalFmt||t.extensions.noCompressedTexSubImage2D?r.compressedTexImage2D(3553,y,i.glInternalFmt,C,D,0,B):r.compressedTexSubImage2D(3553,y,d.x,d.y,C,D,i.glFormat,B):r.texSubImage2D(3553,y,d.x,d.y,C,D,i.glFormat,i.glType,B)}break;case 34067:for(var P=0;P0?E.buffStride:_.width,p.height=E.buffTexHeight>0?E.buffTexHeight:_.height;var U=L+d.x===i.width>>O?L:_.width,G=V+d.y===i.height>>O?V:_.height,H=F.baseArrayLayer+F.layerCount;for(h=F.baseArrayLayer;h0,this.instancedDraw=!!e.instanceCount,this.drawCount=Math.max(t+1,this.drawCount),this.drawByIndex?(this.counts[t]=e.indexCount,this.offsets[t]=e.firstIndex):(this.counts[t]=e.vertexCount,this.offsets[t]=e.firstVertex),this.instances[t]=Math.max(1,e.instanceCount)},e._ensureCapacity=function(t){if(!(this._capacity>t)){this._capacity=R(t);var e=Nat(this._capacity),i=Nat(this._capacity),n=Nat(this._capacity);this.byteOffsets=Nat(this._capacity),e.set(this.counts),i.set(this.offsets),n.set(this.instances),this.counts=e,this.offsets=i,this.instances=n}},t}(),Uat=function(){function t(){this._gpuShader=null,this._gpuDescriptorSetLayout=null,this._gpuPipelineLayout=null,this._gpuPipelineState=null,this._gpuVertexBuffer=null,this._gpuInputAssembler=null,this._gpuPointSampler=null,this._gpuLinearSampler=null,this._gpuDescriptorSet=null,this._gpuUniformBuffer=null,this._drawInfo=null,this._glFramebuffer=null,this._uniformBuffer=null;var t=Vat.instance.bindingMappingInfo.maxBlockCounts[0];this._gpuShader={name:"Blit Pass",blocks:[new yd(0,0,"BlitParams",[new gd("tilingOffsetSrc",16,1),new gd("tilingOffsetDst",16,1)],1)],samplerTextures:[new vd(0,t,"textureSrc",28,1)],subpassInputs:[],gpuStages:[{type:1,source:"\nprecision mediump float;\nattribute vec2 a_position;\nattribute vec2 a_texCoord;\nuniform vec4 tilingOffsetSrc;\nuniform vec4 tilingOffsetDst;\nvarying vec2 v_texCoord;\nvoid main() {\n v_texCoord = a_texCoord * tilingOffsetSrc.xy + tilingOffsetSrc.zw;\n gl_Position = vec4((a_position + 1.0) * tilingOffsetDst.xy - 1.0 + tilingOffsetDst.zw * 2.0, 0, 1);\n}",glShader:null},{type:16,source:"\nprecision mediump float;\nuniform sampler2D textureSrc;\nvarying vec2 v_texCoord;\nvoid main() {\n gl_FragColor = texture2D(textureSrc, v_texCoord);\n}",glShader:null}],glProgram:null,glInputs:[],glUniforms:[],glBlocks:[],glSamplerTextures:[]},xat(Vat.instance,this._gpuShader),this._gpuDescriptorSetLayout={bindings:[new Nd(0,1,1,1),new Nd(t,16,1,16)],dynamicBindings:[],descriptorIndices:[],descriptorCount:t+1};for(var e=0;e0&&(this._uniformBuffer=new Uint8Array(this._size)),this._gpuBuffer={usage:this._usage,memUsage:this._memUsage,size:this._size,stride:this._stride,buffer:null,vf32:null,indirects:new zat,glTarget:0,glBuffer:null},16&this._usage&&(this._gpuBuffer.buffer=this._uniformBuffer),mat(Vat.instance,this._gpuBuffer),Vat.instance.memoryStatus.bufferSize+=this._size},i.destroy=function(){this._gpuBuffer&&(gat(Vat.instance,this._gpuBuffer),Vat.instance.memoryStatus.bufferSize-=this._size,this._gpuBuffer=null),this._gpuBufferView&&(this._gpuBufferView=null)},i.resize=function(t){if(this._isBufferView)at(16379);else{var e,i,n,r,s,a=this._size;a!==t&&(this._size=t,this._count=this._size/this._stride,this._uniformBuffer&&(this._uniformBuffer=new Uint8Array(t)),this._gpuBuffer&&(this._uniformBuffer&&(this._gpuBuffer.buffer=this._uniformBuffer),this._gpuBuffer.size=t,t>0&&(e=Vat.instance,i=this._gpuBuffer,n=e.gl,r=e.stateCache,s=2&i.memUsage?35048:35044,8&i.usage?(e.extensions.useVAO&&r.glVAO&&(e.extensions.OES_vertex_array_object.bindVertexArrayOES(null),r.glVAO=null),Dat.gpuInputAssembler=null,r.glArrayBuffer!==i.glBuffer&&n.bindBuffer(34962,i.glBuffer),i.buffer?n.bufferData(34962,i.buffer,s):n.bufferData(34962,i.size,s),n.bindBuffer(34962,null),r.glArrayBuffer=null):4&i.usage?(e.extensions.useVAO&&r.glVAO&&(e.extensions.OES_vertex_array_object.bindVertexArrayOES(null),r.glVAO=null),Dat.gpuInputAssembler=null,r.glElementArrayBuffer!==i.glBuffer&&n.bindBuffer(34963,i.glBuffer),i.buffer?n.bufferData(34963,i.buffer,s):n.bufferData(34963,i.size,s),n.bindBuffer(34963,null),r.glElementArrayBuffer=null):16&i.usage?i.buffer&&(i.vf32=new Float32Array(i.buffer.buffer)):(64&i.usage||2&i.usage||1&i.usage||ht(16315),i.glTarget=0),Vat.instance.memoryStatus.bufferSize-=a,Vat.instance.memoryStatus.bufferSize+=t)))}},i.update=function(t,e){var i;this._isBufferView?at(16380):(i=void 0!==e?e:64&this._usage?0:t.byteLength,yat(Vat.instance,this._gpuBuffer,t,0,i))},n(e,[{key:"gpuBuffer",get:function(){return this._gpuBuffer}},{key:"gpuBufferView",get:function(){return this._gpuBufferView}}]),e}(pp),Hat=function(t){function e(){var e;return(e=t.call(this)||this)._isInRenderPass=!1,e._curGPUPipelineState=null,e._curGPUInputAssembler=null,e._curGPUDescriptorSets=[],e._curDynamicOffsets=Array(8).fill(0),e._curDynamicStates=new Kd,e._isStateInvalied=!1,e}s(e,t);var i=e.prototype;return i.initialize=function(t){this._type=t.type,this._queue=t.queue;for(var e=Vat.instance.bindingMappings.blockOffsets.length,i=0;i0?this.gpuColorTextures[0].width:this.gpuDepthStencilTexture?this.gpuDepthStencilTexture.width:u},set width(t){u=t},get height(){return this.gpuColorTextures.length>0?this.gpuColorTextures[0].height:this.gpuDepthStencilTexture?this.gpuDepthStencilTexture.height:l},set height(t){l=t},lodLevel:r},wat(Vat.instance,this._gpuFramebuffer),this._gpuFramebuffer.gpuColorTextures.forEach((function(t){return i._gpuColorTextures.push(t.glTexture)})),this._gpuDepthStencilTexture=null==(e=this._gpuFramebuffer.gpuDepthStencilTexture)?void 0:e.glTexture,this._width=this._gpuFramebuffer.width,this._height=this._gpuFramebuffer.height},e.destroy=function(){var t,e,i,n;this._gpuFramebuffer&&(t=Vat.instance,e=this._gpuFramebuffer,i=t.gl,n=t.stateCache,e.glFramebuffer&&(i.deleteFramebuffer(e.glFramebuffer),n.glFramebuffer===e.glFramebuffer&&(i.bindFramebuffer(36160,null),n.glFramebuffer=null),e.glFramebuffer=null),this._gpuFramebuffer=null,this._gpuColorTextures.length=0,this._gpuDepthStencilTexture=null)},n(i,[{key:"needRebuild",get:function(){var t=this._gpuFramebuffer;if(t){for(var e,i=0;ii&&(i=s.binding)}this._bindingIndices=Array(i+1).fill(-1);for(var a=this._descriptorIndices=Array(i+1).fill(-1),o=0;o1&&(s.levelCount=Math.min(s.levelCount,e.getLevelCount(t,i)));var a=n._size;s.width=t,s.height=i,n._size=hp(s.format,n.width,n.height,n.depth,s.levelCount)*s.layerCount;var o=n._gpuTexture;!n._isTextureView&&o&&(o.width=t,o.height=i,o.size=n._size,o.isSwapchainTexture||(Sat(r,o),r.memoryStatus.textureSize-=a,r.memoryStatus.textureSize+=n._size))}},i.initAsSwapchainTexture=function(t){var e=new dd;e.format=t.format,e.usage=ip[t.format].hasDepth?32:16,e.width=t.width,e.height=t.height,this.initialize(e,!0)},n(e,[{key:"gpuTexture",get:function(){return this._gpuTexture}},{key:"lodLevel",get:function(){return this._lodLevel}}]),e}(Rp),rot="webglcontextlost";function sot(t){t.activeTexture(33984),t.pixelStorei(3333,1),t.pixelStorei(3317,1),t.pixelStorei(37440,!1),t.bindFramebuffer(36160,null),t.enable(3089),t.enable(2884),t.cullFace(1029),t.frontFace(2305),t.disable(32823),t.polygonOffset(0,0),t.enable(2929),t.depthMask(!0),t.depthFunc(513),t.depthRange(0,1),t.stencilFuncSeparate(1028,519,1,65535),t.stencilOpSeparate(1028,7680,7680,7680),t.stencilMaskSeparate(1028,65535),t.stencilFuncSeparate(1029,519,1,65535),t.stencilOpSeparate(1029,7680,7680,7680),t.stencilMaskSeparate(1029,65535),t.disable(2960),t.disable(32926),t.disable(3042),t.blendEquationSeparate(32774,32774),t.blendFuncSeparate(1,0,1,0),t.colorMask(!0,!0,!0,!0),t.blendColor(0,0,0,0)}function aot(t,e){for(var i=["","WEBKIT_","MOZ_"],n=0;n0)for(s=e;s=e;s-=n)a=kot(s,t[s],t[s+1],a);return a&&Bot(a,a.next)&&(Rot(a),a=a.next),a}function mot(t,e){if(void 0===e&&(e=null),!t)return t;e||(e=t);var i=t,n=!1;do{if(n=!1,i.steiner||!Bot(i,i.next)&&0!==Dot(i.prev,i,i.next))i=i.next;else{if(Rot(i),(i=e=i.prev)===i.next)return null;n=!0}}while(n||i!==e);return e}function got(t,e,i,n,r,s,a){if(void 0===a&&(a=0),t){!a&&s&&wot(t,n,r,s);for(var o=t,h=null,u=null;t.prev!==t.next;)if(h=t.prev,u=t.next,s?vot(t,n,r,s):yot(t))e.push(h.i/i),e.push(t.i/i),e.push(u.i/i),Rot(t),t=u.next,o=u.next;else if((t=u)===o){a?1===a?got(t=bot(t,e,i),e,i,n,r,s,2):2===a&&Sot(t,e,i,n,r,s):got(mot(t),e,i,n,r,s,1);break}}}function yot(t){var e=t.prev,i=t,n=t.next;if(Dot(e,i,n)>=0)return!1;for(var r=t.next.next;r!==t.prev;){if(Aot(e.x,e.y,i.x,i.y,n.x,n.y,r.x,r.y)&&Dot(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function vot(t,e,i,n){var r=t.prev,s=t,a=t.next;if(Dot(r,s,a)>=0)return!1;for(var o=r.xs.x?r.x>a.x?r.x:a.x:s.x>a.x?s.x:a.x,l=r.y>s.y?r.y>a.y?r.y:a.y:s.y>a.y?s.y:a.y,c=Tot(o,h,e,i,n),f=Tot(u,l,e,i,n),_=t.nextZ;_&&_.z<=f;){if(_!==t.prev&&_!==t.next&&Aot(r.x,r.y,s.x,s.y,a.x,a.y,_.x,_.y)&&Dot(_.prev,_,_.next)>=0)return!1;_=_.nextZ}for(_=t.prevZ;_&&_.z>=c;){if(_!==t.prev&&_!==t.next&&Aot(r.x,r.y,s.x,s.y,a.x,a.y,_.x,_.y)&&Dot(_.prev,_,_.next)>=0)return!1;_=_.prevZ}return!0}function bot(t,e,i){var n=t;do{var r=n.prev,s=n.next.next;!Bot(r,s)&&Iot(r,n,n.next,s)&&Pot(r,s)&&Pot(s,r)&&(e.push(r.i/i),e.push(n.i/i),e.push(s.i/i),Rot(n),Rot(n.next),n=t=s),n=n.next}while(n!==t);return n}function Sot(t,e,i,n,r,s){var a=t;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&Cot(a,o)){var h=Oot(a,o);return a=mot(a,a.next),h=mot(h,h.next),got(a,e,i,n,r,s),void got(h,e,i,n,r,s)}o=o.next}a=a.next}while(a!==t)}function wot(t,e,i,n){var r=t;do{null===r.z&&(r.z=Tot(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,xot(r)}function xot(t){var e=0,i=null,n=null,r=null,s=null,a=0,o=0,h=0,u=1;do{for(i=t,t=null,s=null,a=0;i;){for(a++,n=i,o=0,e=0;e0||h>0&&n;)0===o?(r=n,n=n.nextZ,h--):0!==h&&n?i.z<=n.z?(r=i,i=i.nextZ,o--):(r=n,n=n.nextZ,h--):(r=i,i=i.nextZ,o--),s?s.nextZ=r:t=r,r.prevZ=s,s=r;i=n}s.nextZ=null,u*=2}while(a>1);return t}function Tot(t,e,i,n,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)/r)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)/r)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Aot(t,e,i,n,r,s,a,o){return(r-a)*(e-o)-(t-a)*(s-o)>=0&&(t-a)*(n-o)-(i-a)*(e-o)>=0&&(i-a)*(s-o)-(r-a)*(n-o)>=0}function Cot(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!Mot(t,e)&&Pot(t,e)&&Pot(e,t)&&Eot(t,e)}function Dot(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Bot(t,e){return t.x===e.x&&t.y===e.y}function Iot(t,e,i,n){return!!(Bot(t,e)&&Bot(i,n)||Bot(t,n)&&Bot(i,e))||Dot(t,e,i)>0!=Dot(t,e,n)>0&&Dot(i,n,t)>0!=Dot(i,n,e)>0}function Mot(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&Iot(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}function Pot(t,e){return Dot(t.prev,t,t.next)<0?Dot(t,e,t.next)>=0&&Dot(t,t.prev,e)>=0:Dot(t,e,t.prev)<0||Dot(t,t.next,e)<0}function Eot(t,e){var i=t,n=!1,r=(t.x+e.x)/2,s=(t.y+e.y)/2;do{i.y>s!=i.next.y>s&&r<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}function Oot(t,e){var i=new dot(t.i,t.x,t.y),n=new dot(e.i,e.x,e.y),r=t.next,s=e.prev;return t.next=e,e.prev=t,i.next=r,r.prev=i,n.next=i,i.prev=n,s.next=n,n.prev=s,n}function kot(t,e,i,n){var r=new dot(t,e,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Rot(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Fot(t,e,i,n){for(var r=0,s=e,a=i-n;s80*i){a=h=t[0],o=u=t[1];for(var _=i;_h&&(h=l),c>u&&(u=c);f=Math.max(h-a,u-o)}return got(r,s,i,a,o,f),s}for(var Vot=Math.PI,Not=Math.min,zot=Math.max,Uot=Math.ceil,Got=Math.acos,Hot=Math.cos,Wot=Math.sin,jot=Math.atan2,qot=null,Xot=null,Yot=new cr,Jot=[],Kot=0;Kot<4;Kot++)Jot.push(new ir);function Qot(t,e,i){var n=2*Got(t/(t+i));return zot(2,Uot(e/n))}function Zot(t,e,i){return ti?i:t}var $ot=function(){function t(){}var e=t.prototype;return e.updateRenderData=function(){},e.getRenderData=function(t,e){if(!Xot)return null;var i=Xot.getRenderDataList(),n=i[Xot.dataOffset];if(!n)return null;var r=n,s=r?r.vertexStart+e:0;return(s>65535||3*s>131070)&&(++Xot.dataOffset,Xot.dataOffset0&&(r=1/e);for(var s=t.paths,a=t.pathOffset,o=t.pathLength;a1e-6){var b=1/d;b>600&&(b=600),f.dmx*=b,f.dmy*=b}f.dx*c.dy-c.dx*f.dy>0&&(f.flags|=2),d*(p=zot(11,Not(c.len,f.len)*r))*p<1&&(f.flags|=8),1&f.flags&&(d*n*n<1||0===i||1===i)&&(f.flags|=4),12&f.flags&&h.bevel++,c=f,f=u[_+1]}}},e._flattenPaths=function(t){for(var e=t.paths,i=t.pathOffset,n=t.pathLength;i2&&a.equals(o)&&(r.closed=!0,s.pop(),a=s[s.length-1]);for(var h=0,u=s.length;hm&&(g-=2*Vot),this._vSet(f,_,1),this._vSet(u-s*n,e.y-a*n,-1);for(var y=Zot(Uot((m-g)/Vot)*r,2,r),v=0;v=0&&o<=1&&h>=0&&h<=1)return!0}return!1}ZN.Assembler=eht,A.UI.graphicsAssembler=eht;var nht=new ds,rht=new ds,sht=new ds,aht=new ds;function oht(t,e,i){for(var n=i.length,r=0;rr!=c>r&&n<(l-h)*(r-u)/(c-u)+h&&(i=!i)}return i}function uht(t,e,i,n){var r,s=i.x-e.x,a=i.y-e.y,o=s*s+a*a,h=((t.x-e.x)*s+(t.y-e.y)*a)/o;return r=n?o?h<0?e:h>1?i:nht.set(e.x+h*s,e.y+h*a):e:nht.set(e.x+h*s,e.y+h*a),s=t.x-r.x,a=t.y-r.y,Math.sqrt(s*s+a*a)}var lht=t("eI",(function(){}));lht.lineLine=iht,lht.lineRect=function(t,e,i){var n=nht.set(i.x,i.y),r=rht.set(i.x,i.yMax),s=sht.set(i.xMax,i.yMax),a=aht.set(i.xMax,i.y);return!!(iht(t,e,n,r)||iht(t,e,r,s)||iht(t,e,s,a)||iht(t,e,a,n))},lht.linePolygon=oht,lht.rectRect=function(t,e){var i=t.x,n=t.y,r=t.x+t.width,s=t.y+t.height,a=e.x,o=e.y,h=e.x+e.width,u=e.y+e.height;return i<=h&&r>=a&&n<=u&&s>=o},lht.rectPolygon=function(t,e){var i=nht.set(t.x,t.y),n=rht.set(t.x,t.yMax),r=sht.set(t.xMax,t.yMax),s=aht.set(t.xMax,t.y);if(oht(i,n,e))return!0;if(oht(n,r,e))return!0;if(oht(r,s,e))return!0;if(oht(s,i,e))return!0;for(var a=0,o=e.length;as+o&&(u=s+o),ra+h&&(l=a+h);var c=n-u,f=r-l;return Math.sqrt(c*c+f*f)<=i},lht.polygonPolygon=function(t,e){var i,n;for(i=0,n=t.length;i=0){var s=t._probes,a=s[this.vertex0].position,o=s[this.vertex1].position,h=s[this.vertex2].position,u=s[this.vertex3].position;this.sphere.init(a,o,h,u)}}var e=t.prototype;return e.isInCircumSphere=function(t){return ir.squaredDistance(t,this.sphere.center)=0},e.isOuterCell=function(){return this.vertex3<0},t}(),Fht=zh(Rht.prototype,"invalid",[Yht],(function(){return!1})),Lht=zh(Rht.prototype,"vertex0",[Yht],(function(){return-1})),Vht=zh(Rht.prototype,"vertex1",[Yht],(function(){return-1})),Nht=zh(Rht.prototype,"vertex2",[Yht],(function(){return-1})),zht=zh(Rht.prototype,"vertex3",[Yht],(function(){return-1})),Uht=zh(Rht.prototype,"neighbours",[Yht],(function(){return[-1,-1,-1,-1]})),Ght=zh(Rht.prototype,"matrix",[Yht],(function(){return new yr})),Hht=zh(Rht.prototype,"offset",[Yht],(function(){return new ir(0,0,0)})),Wht=zh(Rht.prototype,"sphere",[Yht],(function(){return new aut})),kht=Rht))||kht),hut=t("eO",function(){function t(t){this._probes=[],this._tetrahedrons=[],this._triangles=[],this._edges=[],this._probes=t}var e=t.prototype;return e.build=function(){return this.reset(),this.tetrahedralize(),this.computeAdjacency(),this.computeMatrices(),this._tetrahedrons},e.reset=function(){this._tetrahedrons.length=0,this._triangles.length=0,this._edges.length=0},e.tetrahedralize=function(){for(var t=this._probes.length,e=this.initTetrahedron(),i=0;i0&&ir.negate(t,t),ir.add(l.normal,l.normal,t),ir.add(c.normal,c.normal,t),ir.add(f.normal,f.normal,t);var p=this._triangles[h].vertex0,m=d>0?this._triangles[h].vertex2:this._triangles[h].vertex1,g=d>0?this._triangles[h].vertex1:this._triangles[h].vertex2,y=new out(this,p,m,g);y.neighbours[3]=this._triangles[h].tetrahedron,this._tetrahedrons[this._triangles[h].tetrahedron].neighbours[this._triangles[h].index]=this._tetrahedrons.length,this._tetrahedrons.push(y)}}for(var v=0,b=r;b=0?this.computeTetrahedronMatrix(e):this.computeOuterCellMatrix(e)}},e.computeTetrahedronMatrix=function(t){var e=this._probes[t.vertex0].position,i=this._probes[t.vertex1].position,n=this._probes[t.vertex2].position,r=this._probes[t.vertex3].position;t.matrix.set(e.x-r.x,i.x-r.x,n.x-r.x,e.y-r.y,i.y-r.y,n.y-r.y,e.z-r.z,i.z-r.z,n.z-r.z),t.matrix.invert(),t.matrix.transpose()},e.computeOuterCellMatrix=function(t){var e=[],i=[];e[0]=this._probes[t.vertex0].normal,e[1]=this._probes[t.vertex1].normal,e[2]=this._probes[t.vertex2].normal,i[0]=this._probes[t.vertex0].position,i[1]=this._probes[t.vertex1].position,i[2]=this._probes[t.vertex2].position,ir.subtract(Qht,i[0],i[2]),ir.subtract(Zht,e[0],e[2]),ir.subtract($ht,i[1],i[2]),ir.subtract(tut,e[1],e[2]),eut.set(i[2]),ir.negate(iut,e[2]);var n=[];n[0]=Zht.y*tut.z-Zht.z*tut.y,n[3]=-Zht.x*tut.z+Zht.z*tut.x,n[6]=Zht.x*tut.y-Zht.y*tut.x,n[9]=Qht.x*tut.y*iut.z-Qht.y*tut.x*iut.z+Zht.x*$ht.y*iut.z-Zht.y*$ht.x*iut.z+Qht.z*tut.x*iut.y-Qht.z*tut.y*iut.x+Zht.z*$ht.x*iut.y-Zht.z*$ht.y*iut.x-Qht.x*tut.z*iut.y+Qht.y*tut.z*iut.x-Zht.x*$ht.z*iut.y+Zht.y*$ht.z*iut.x,n[9]-=eut.x*n[0]+eut.y*n[3]+eut.z*n[6],n[1]=Zht.y*$ht.z+Qht.y*tut.z-Zht.z*$ht.y-Qht.z*tut.y,n[4]=-Qht.x*tut.z-Zht.x*$ht.z+Qht.z*tut.x+Zht.z*$ht.x,n[7]=Qht.x*tut.y-Qht.y*tut.x+Zht.x*$ht.y-Zht.y*$ht.x,n[10]=Qht.x*$ht.y*iut.z-Qht.y*$ht.x*iut.z-Qht.x*$ht.z*iut.y+Qht.y*$ht.z*iut.x+Qht.z*$ht.x*iut.y-Qht.z*$ht.y*iut.x,n[10]-=eut.x*n[1]+eut.y*n[4]+eut.z*n[7],n[2]=-Qht.z*$ht.y+Qht.y*$ht.z,n[5]=-Qht.x*$ht.z+Qht.z*$ht.x,n[8]=Qht.x*$ht.y-Qht.y*$ht.x,n[11]=0,n[11]-=eut.x*n[2]+eut.y*n[5]+eut.z*n[8];var r=Zht.x*tut.y*iut.z-Zht.y*tut.x*iut.z+Zht.z*tut.x*iut.y-Zht.z*tut.y*iut.x+Zht.y*tut.z*iut.x-Zht.x*tut.z*iut.y;if(Math.abs(r)>Ki)for(var s=0;s<12;s++)n[s]/=r;else t.vertex3=-2;t.matrix.set(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8]),t.offset.set(n[9],n[10],n[11])},t}()),uut=t("eP",function(){function t(){}return t.uniformSampleSphere=function(t,e){var i=1-2*t,n=Math.sqrt(Math.max(0,1-i*i)),r=2*Math.PI*e,s=n*Math.cos(r),a=n*Math.sin(r);return new ir(s,a,i)},t.uniformSampleSphereAll=function(t){for(var e=Math.floor(Math.sqrt(t)),i=e,n=[],r=1/e,s=1/i,a=0;a0&&(t.length,e.length);for(var i=this.getBasisCount(),n=t.length,r=1/(uut.uniformSpherePdf()*n),s=[],a=0;a0){var h=Math.sqrt(o);n.push(Math.cbrt(-a+h)+Math.cbrt(-a-h))}else if(o<0){var u=Math.acos(-a*Math.sqrt(-s)/(s*s))/3;n.push(2*Math.sqrt(-s)*Math.cos(u)),n.push(2*Math.sqrt(-s)*Math.cos(u+2*Math.PI/3)),n.push(2*Math.sqrt(-s)*Math.cos(u+4*Math.PI/3))}else if(0===a)n.push(0);else{var l=Math.cbrt(a);n.push(l),n.push(-2*l)}for(var c=0;c=0)return n[c]+r;return 0},t}(),vut=new ir(0,0,0),but=new ir(0,0,0),Sut=new ir(0,0,0),wut=new ir(0,0,0),xut=new ir(0,0,0),Tut=new ir(0,0,0),Aut=new ir(0,0,0),Cut=new ir(0,0,0),Dut=new ir(0,0,0),But=new ir(0,0,0),Iut=new ir(0,0,0),Mut=new ir(0,0,0),Put=new ir(0,0,0),Eut=new ir(0,0,0),Out=new ir(0,0,0),kut=t("eR",(cut=Kh("cc.LightProbesData"),fut=Ou([nut]),_ut=Ou([out]),cut((put=function(){function t(){this._probes=mut&&mut(),this._tetrahedrons=gut&&gut()}var e=t.prototype;return e.empty=function(){return 0===this._probes.length||0===this._tetrahedrons.length},e.reset=function(){this._probes.length=0,this._tetrahedrons.length=0},e.updateProbes=function(t){this._probes.length=t.length;for(var e=this._probes.length,i=0;i=0)for(var h=this._probes[r.vertex3].coefficients,u=0;u=n)&&(e=0);for(var r=-1,s=-1,a=0;a=0&&i.y>=0&&i.z>=0&&i.w>=0)break;if(r===(s=i.x=0?this.getTetrahedronBarycentricCoord(t,e,i):this.getOuterCellBarycentricCoord(t,e,i)},e.getTetrahedronBarycentricCoord=function(t,e,i){var n=new ir(0,0,0);ir.subtract(n,t,this._probes[e.vertex3].position),ir.transformMat3(n,n,e.matrix),i.set(n.x,n.y,n.z,1-n.x-n.y-n.z)},e.getOuterCellBarycentricCoord=function(e,i,n){var r=this._probes[i.vertex0].position,s=this._probes[i.vertex1].position,a=this._probes[i.vertex2].position;ir.subtract(But,s,r),ir.subtract(Iut,a,r),ir.cross(Dut,But,Iut),ir.subtract(Mut,e,r);var o=ir.dot(Mut,Dut);if(o<0)n.set(0,0,0,-1);else{var h=new ir(0,0,0);ir.transformMat3(h,e,i.matrix),ir.add(h,h,i.offset),o=-1===i.vertex3?yut.getCubicUniqueRoot(h.x,h.y,h.z):yut.getQuadraticUniqueRoot(h.x,h.y,h.z),ir.scaleAndAdd(Put,r,this._probes[i.vertex0].normal,o),ir.scaleAndAdd(Eut,s,this._probes[i.vertex1].normal,o),ir.scaleAndAdd(Out,a,this._probes[i.vertex2].normal,o);var u=t.getTriangleBarycentricCoord(Put,Eut,Out,e);n.set(u.x,u.y,u.z,0)}},n(t,[{key:"probes",get:function(){return this._probes}},{key:"tetrahedrons",get:function(){return this._tetrahedrons}}]),t}(),mut=zh(put.prototype,"_probes",[uu,fut],(function(){return[]})),gut=zh(put.prototype,"_tetrahedrons",[uu,_ut],(function(){return[]})),dut=put))||dut));A.internal.LightProbesData=kut;var Rut,Fut,Lut,Vut,Nut,zut,Uut,Gut,Hut,Wut,jut,qut,Xut,Yut,Jut,Kut=t("eS",function(){function t(){this._giScale=1,this._giSamples=1024,this._bounces=2,this._reduceRinging=0,this._showProbe=!0,this._showWireframe=!0,this._showConvex=!1,this._data=null,this._lightProbeSphereVolume=1}var e=t.prototype;return e.initialize=function(t){this._giScale=t.giScale,this._giSamples=t.giSamples,this._bounces=t.bounces,this._reduceRinging=t.reduceRinging,this._showProbe=t.showProbe,this._showWireframe=t.showWireframe,this._showConvex=t.showConvex,this._data=t.data,this._lightProbeSphereVolume=t.lightProbeSphereVolume},e.empty=function(){return!this._data||this._data.empty()},n(t,[{key:"giScale",get:function(){return this._giScale},set:function(t){this._giScale=t}},{key:"giSamples",get:function(){return this._giSamples},set:function(t){this._giSamples=t}},{key:"bounces",get:function(){return this._bounces},set:function(t){this._bounces=t}},{key:"reduceRinging",get:function(){return this._reduceRinging},set:function(t){this._reduceRinging=t}},{key:"showProbe",get:function(){return this._showProbe},set:function(t){this._showProbe=t}},{key:"showWireframe",get:function(){return this._showWireframe},set:function(t){this._showWireframe=t}},{key:"showConvex",get:function(){return this._showConvex},set:function(t){this._showConvex=t}},{key:"data",get:function(){return this._data},set:function(t){this._data=t}},{key:"lightProbeSphereVolume",get:function(){return this._lightProbeSphereVolume},set:function(t){this._lightProbeSphereVolume=t}}]),t}());A.internal.LightProbes=Kut,t("eT",(Rut=Kh("cc.LightProbeGroup"),Fut=Ou([ir]),Lut=Ou(jht),Vut=Ou(li),Nut=Ou(li),zut=Ou(li),Rut(Uut=$h((Gut=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r=n.length&&(t=n.length-1),t<0&&(t=0),this._techIndex=t,this.updateTechnique()}}]),i}(yg),ilt=zh(elt.prototype,"_texture",[Zut],(function(){return null})),v(elt.prototype,"texture",[$ut],Object.getOwnPropertyDescriptor(elt.prototype,"texture"),elt.prototype),nlt=zh(elt.prototype,"_height",[uu],(function(){return 0})),rlt=zh(elt.prototype,"_width",[uu],(function(){return 0})),slt=zh(elt.prototype,"_rotation",[uu],(function(){return 0})),alt=zh(elt.prototype,"_techIndex",[uu],(function(){return 0})),tlt=elt))||tlt)),Clt=[new Cd("a_position",32),new Cd("a_texCoord",44),new Cd("a_texCoord1",32),new Cd("a_color",35,!0)],Dlt=new ir,Blt=new ir,Ilt=function(t){function e(){var e;return(e=t.call(this)||this)._capacity=void 0,e._vertSize=0,e._vBuffer=null,e._vertAttrsFloatCount=0,e._vdataF32=null,e._vdataUint32=null,e._subMeshData=null,e._vertCount=0,e._indexCount=0,e._material=null,e._iaVertCount=0,e._iaIndexCount=0,e.type=5,e._capacity=100,e}s(e,t);var i=e.prototype;return i.setCapacity=function(t){this._capacity=t,this.createBuffer()},i.createBuffer=function(){this._vertSize=0;for(var t=0,e=Clt;t1){var n=0;ir.subtract(Dlt,t[1],t[0]),this._vdataF32[n++]=t[0].x,this._vdataF32[n++]=t[0].y,this._vdataF32[n++]=t[0].z,this._vdataF32[n++]=0,this._vdataF32[n++]=e.evaluate(0,1),this._vdataF32[n++]=0,this._vdataF32[n++]=0,this._vdataF32[n++]=Dlt.x,this._vdataF32[n++]=Dlt.y,this._vdataF32[n++]=Dlt.z,this._vdataUint32[n++]=cr.toUint32(i.evaluate(0,1)),this._vdataF32[n++]=t[0].x,this._vdataF32[n++]=t[0].y,this._vdataF32[n++]=t[0].z,this._vdataF32[n++]=1,this._vdataF32[n++]=e.evaluate(0,1),this._vdataF32[n++]=0,this._vdataF32[n++]=1,this._vdataF32[n++]=Dlt.x,this._vdataF32[n++]=Dlt.y,this._vdataF32[n++]=Dlt.z,this._vdataUint32[n++]=cr.toUint32(i.evaluate(0,1));for(var r=1;r0&&this._models[0]&&this._detachFromScene()},i._attachToScene=function(){if(t.prototype._attachToScene.call(this),this._models.length>0&&this._models[0]&&this.node&&this.node.scene){var e=this._models[0];e.scene&&this._detachFromScene(),this._getRenderScene().addModel(e)}},i._detachFromScene=function(){if(t.prototype._detachFromScene.call(this),this._models.length>0&&this._models[0]){var e=this._models[0];e.scene&&e.scene.removeModel(e)}},i._onMaterialModified=function(e,i){t.prototype._onMaterialModified.call(this,e,i);var n=this.getMaterialInstance(0);n&&(gct[mct]=this.worldSpace,n.recompileShaders(gct),this._models[0]&&this._models[0].updateMaterial(n))},n(e,[{key:"texture",get:function(){return this._texture},set:function(t){this._texture=t,this.material&&this.material.setProperty("mainTexture",t)}},{key:"lineMaterial",get:function(){return this.getSharedMaterial(0)},set:function(t){this.setSharedMaterial(t,0)}},{key:"sharedMaterials",get:function(){return t.prototype.sharedMaterials},set:function(t){this.sharedMaterials=t}},{key:"worldSpace",get:function(){return this._worldSpace},set:function(t){this._worldSpace=t;var e=this.getMaterialInstance(0);e&&(gct[mct]=this.worldSpace,e.recompileShaders(gct),this._models[0]&&this._models[0].setSubModelMaterial(0,e))}},{key:"positions",get:function(){return this._positions},set:function(t){this._positions=t,this._models[0]&&this._models[0].addLineVertexData(this._positions,this.width,this.color)}},{key:"width",get:function(){return this._width},set:function(t){this._width=t,this._models[0]&&this._models[0].addLineVertexData(this._positions,this._width,this._color)}},{key:"color",get:function(){return this._color},set:function(t){this._color=t,this._models[0]&&this._models[0].addLineVertexData(this._positions,this._width,this._color)}},{key:"tile",get:function(){return this._tile},set:function(t){this._tile.set(t),this.material&&(this._tile_offset.x=this._tile.x,this._tile_offset.y=this._tile.y,this.material.setProperty("mainTiling_Offset",this._tile_offset))}},{key:"offset",get:function(){return this._offset},set:function(t){this._offset.set(t),this.material&&(this._tile_offset.z=this._offset.x,this._tile_offset.w=this._offset.y,this.material.setProperty("mainTiling_Offset",this._tile_offset))}}]),e}(HU),ect=zh(tct.prototype,"_texture",[Wlt],(function(){return null})),v(tct.prototype,"texture",[jlt],Object.getOwnPropertyDescriptor(tct.prototype,"texture"),tct.prototype),ict=zh(tct.prototype,"_material",[uu],(function(){return null})),v(tct.prototype,"lineMaterial",[qlt],Object.getOwnPropertyDescriptor(tct.prototype,"lineMaterial"),tct.prototype),v(tct.prototype,"sharedMaterials",[Gu,uu],Object.getOwnPropertyDescriptor(tct.prototype,"sharedMaterials"),tct.prototype),nct=zh(tct.prototype,"_worldSpace",[uu],(function(){return!1})),rct=zh(tct.prototype,"_positions",[Xlt],(function(){return[]})),v(tct.prototype,"positions",[Ylt],Object.getOwnPropertyDescriptor(tct.prototype,"positions"),tct.prototype),v(tct.prototype,"width",[Jlt],Object.getOwnPropertyDescriptor(tct.prototype,"width"),tct.prototype),sct=zh(tct.prototype,"_width",[uu],(function(){return new Olt})),v(tct.prototype,"color",[Klt],Object.getOwnPropertyDescriptor(tct.prototype,"color"),tct.prototype),act=zh(tct.prototype,"_color",[uu],(function(){return new fct})),oct=zh(tct.prototype,"_tile",[uu],(function(){return new ds(1,1)})),v(tct.prototype,"tile",[Qlt],Object.getOwnPropertyDescriptor(tct.prototype,"tile"),tct.prototype),hct=zh(tct.prototype,"_offset",[uu],(function(){return new ds(0,0)})),v(tct.prototype,"offset",[Zlt],Object.getOwnPropertyDescriptor(tct.prototype,"offset"),tct.prototype),$lt=tct))||$lt)),vct=function(){function t(t){this.particleSystem=void 0,this.position=void 0,this.velocity=void 0,this.animatedVelocity=void 0,this.ultimateVelocity=void 0,this.angularVelocity=void 0,this.axisOfRotation=void 0,this.rotation=void 0,this.startEuler=void 0,this.startRotation=void 0,this.startRotated=void 0,this.deltaQuat=void 0,this.deltaMat=void 0,this.localMat=void 0,this.startSize=void 0,this.size=void 0,this.startColor=void 0,this.color=void 0,this.randomSeed=void 0,this.remainingLifetime=void 0,this.loopCount=void 0,this.lastLoop=void 0,this.trailDelay=void 0,this.startLifetime=void 0,this.emitAccumulator0=void 0,this.emitAccumulator1=void 0,this.frameIndex=void 0,this.startRow=void 0,this.particleSystem=t,this.position=new ir(0,0,0),this.velocity=new ir(0,0,0),this.animatedVelocity=new ir(0,0,0),this.ultimateVelocity=new ir(0,0,0),this.angularVelocity=new ir(0,0,0),this.axisOfRotation=new ir(0,0,0),this.rotation=new ir(0,0,0),this.startEuler=new ir(0,0,0),this.startRotation=new kr,this.startRotated=!1,this.deltaQuat=new kr,this.deltaMat=new Kr,this.localMat=new Kr,this.startSize=new ir(0,0,0),this.size=new ir(0,0,0),this.startColor=cr.WHITE.clone(),this.color=cr.WHITE.clone(),this.randomSeed=0,this.remainingLifetime=0,this.loopCount=0,this.lastLoop=0,this.trailDelay=0,this.startLifetime=0,this.emitAccumulator0=0,this.emitAccumulator1=0,this.frameIndex=0,this.startRow=0}return t.prototype.reset=function(){this.rotation.set(0,0,0),this.startEuler.set(0,0,0),this.startRotation.set(0,0,0,1),this.startRotated=!1,this.deltaQuat.set(0,0,0,1),this.deltaMat.identity(),this.localMat.identity()},t}();vct.INDENTIFY_NEG_QUAT=10,vct.R2D=180/Math.PI;var bct,Sct,wct,xct,Tct,Act,Cct="noiseModule",Dct=["sizeModule","colorModule","forceModule","velocityModule","limitModule","rotationModule","textureModule","noiseModule"],Bct=["_colorOverLifetimeModule","_shapeModule","_sizeOvertimeModule","_velocityOvertimeModule","_forceOvertimeModule","_limitVelocityOvertimeModule","_rotationOvertimeModule","_textureAnimationModule","_noiseModule","_trailModule"],Ict=function(){function t(){this.target=null,this.needUpdate=!1,this.needAnimate=!0,this.name=void 0}var e=t.prototype;return e.bindTarget=function(t){this.target=t},e.update=function(){},t}(),Mct=new ir(0,0,-1);function Pct(t,e,i,n){return e!==t?(0===t||Kr.invert(i,i),Kr.getRotation(n,i),!0):(kr.set(n,0,0,0,1),!1)}function Ect(t,e){ds.set(t,Math.cos(e),Math.sin(e))}function Oct(t){var e=on(-1,1),i=on(0,2*Math.PI),n=Math.sqrt(1-e*e),r=n*Math.cos(i),s=n*Math.sin(i);ir.set(t,r,s,e)}function kct(t,e,i){Oct(t),ir.multiplyScalar(t,t,e+(i-e)*sn())}function Rct(t,e,i,n){Ect(t,n),t.z=0,ir.multiplyScalar(t,t,e+(i-e)*sn())}function Fct(t){for(var e=0;ee){var s=r-r*i;r=s>e?s:e}return r*n}var Hft,Wft,jft,qft,Xft,Yft,Jft,Kft,Qft,Zft,$ft,t_t,e_t,i_t,n_t,r_t,s_t,a_t,o_t,h_t,u_t,l_t,c_t,f_t,__t,d_t,p_t,m_t,g_t,y_t,v_t,b_t,S_t,w_t,x_t,T_t,A_t,C_t,D_t,B_t,I_t,M_t,P_t,E_t,O_t,k_t,R_t,F_t,L_t,V_t,N_t,z_t,U_t,G_t,H_t,W_t,j_t,q_t,X_t,Y_t,J_t,K_t,Q_t,Z_t,$_t,tdt,edt,idt,ndt,rdt,sdt,adt,odt,hdt,udt,ldt,cdt,fdt,_dt,ddt,pdt,mdt,gdt,ydt,vdt,bdt,Sdt=125292,wdt=(Tft=Kh("cc.RotationOvertimeModule"),Aft=Ou(Olt),Cft=Ou(Olt),Dft=Ou(Olt),Tft((Ift=function(t){function e(){var e;return(e=t.call(this)||this)._enable=Mft&&Mft(),e._separateAxes=Pft&&Pft(),e.x=Eft&&Eft(),e.y=Oft&&Oft(),e.z=kft&&kft(),e.name="rotationModule",e._startMat=new Kr,e._matRot=new Kr,e._quatRot=new kr,e._otherEuler=new ir,e}s(e,t);var i=e.prototype;return i._processRotation=function(t){var e=t.particleSystem.processor.getInfo().renderMode;4!==e&&1===e&&this._quatRot.set(0,0,0,1),kr.normalize(this._quatRot,this._quatRot),this._quatRot.w<0&&(this._quatRot.x+=vct.INDENTIFY_NEG_QUAT)},i.animate=function(t,e){var i=1-t.remainingLifetime/t.startLifetime,n=Vct(this.z)?un(t.randomSeed+Sdt):0,r=t.particleSystem.processor.getInfo().renderMode;if(this._separateAxes&&3!==r&&2!==r){var s=Vct(this.x)?un(t.randomSeed+Sdt):0,a=Vct(this.y)?un(t.randomSeed+Sdt):0;kr.fromEuler(t.deltaQuat,this.x.evaluate(i,s)*e*vct.R2D,this.y.evaluate(i,a)*e*vct.R2D,this.z.evaluate(i,n)*e*vct.R2D)}else kr.fromEuler(t.deltaQuat,0,0,this.z.evaluate(i,n)*e*vct.R2D);t.deltaMat=Kr.fromQuat(t.deltaMat,t.deltaQuat),t.localMat=t.localMat.multiply(t.deltaMat),t.startRotated||(4!==r&&(1===r?t.startEuler.set(0,0,0):0!==r&&t.startEuler.set(0,0,t.startEuler.z)),kr.fromEuler(t.startRotation,t.startEuler.x*vct.R2D,t.startEuler.y*vct.R2D,t.startEuler.z*vct.R2D),t.startRotated=!0),this._startMat=Kr.fromQuat(this._startMat,t.startRotation),this._matRot=this._startMat.multiply(t.localMat),Kr.getRotation(this._quatRot,this._matRot),this._processRotation(t,vct.R2D),t.rotation.set(this._quatRot.x,this._quatRot.y,this._quatRot.z)},n(e,[{key:"enable",get:function(){return this._enable},set:function(t){this._enable!==t&&(this._enable=t,this.target&&this.target.enableModule(this.name,t,this))}},{key:"separateAxes",get:function(){return this._separateAxes},set:function(t){this._separateAxes=t}}]),e}(Ict),Mft=zh(Ift.prototype,"_enable",[uu],(function(){return!1})),Pft=zh(Ift.prototype,"_separateAxes",[uu],(function(){return!1})),Eft=zh(Ift.prototype,"x",[Aft,uu],(function(){return new Olt})),Oft=zh(Ift.prototype,"y",[Cft,uu],(function(){return new Olt})),kft=zh(Ift.prototype,"z",[Dft,uu],(function(){return new Olt})),Bft=Ift))||Bft),xdt=39825,Tdt=(Hft=Kh("cc.SizeOvertimeModule"),Wft=Ou(Olt),jft=Ou(Olt),qft=Ou(Olt),Xft=Ou(Olt),Hft((Jft=function(t){function e(){var e;return(e=t.call(this)||this)._enable=Kft&&Kft(),e.separateAxes=Qft&&Qft(),e.size=Zft&&Zft(),e.x=$ft&&$ft(),e.y=t_t&&t_t(),e.z=e_t&&e_t(),e.name="sizeModule",e}return s(e,t),e.prototype.animate=function(t){if(this.separateAxes){var e=1-t.remainingLifetime/t.startLifetime,i=Vct(this.x)?un(t.randomSeed+xdt):0,n=Vct(this.y)?un(t.randomSeed+xdt):0,r=Vct(this.z)?un(t.randomSeed+xdt):0;t.size.x=t.startSize.x*this.x.evaluate(e,i),t.size.y=t.startSize.y*this.y.evaluate(e,n),t.size.z=t.startSize.z*this.z.evaluate(e,r)}else{var s=Vct(this.size)?un(t.randomSeed+xdt):0;ir.multiplyScalar(t.size,t.startSize,this.size.evaluate(1-t.remainingLifetime/t.startLifetime,s))}},n(e,[{key:"enable",get:function(){return this._enable},set:function(t){this._enable!==t&&(this._enable=t,this.target&&this.target.enableModule(this.name,t,this))}}]),e}(Ict),Kft=zh(Jft.prototype,"_enable",[uu],(function(){return!1})),Qft=zh(Jft.prototype,"separateAxes",[uu],(function(){return!1})),Zft=zh(Jft.prototype,"size",[Wft,uu],(function(){return new Olt})),$ft=zh(Jft.prototype,"x",[jft,uu],(function(){return new Olt})),t_t=zh(Jft.prototype,"y",[qft,uu],(function(){return new Olt})),e_t=zh(Jft.prototype,"z",[Xft,uu],(function(){return new Olt})),Yft=Jft))||Yft),Adt=Ee({Grid:0}),Cdt=Ee({WholeSheet:0,SingleRow:1}),Ddt=(i_t=Kh("cc.TextureAnimationModule"),n_t=lu("numTilesX"),r_t=lu("numTilesY"),s_t=Ou(Adt),a_t=Ou(Adt),o_t=Ou(Cdt),h_t=Ou(Olt),u_t=Ou(Olt),i_t((c_t=function(t){function e(){var e;return(e=t.call(this)||this)._enable=f_t&&f_t(),e._numTilesX=__t&&__t(),e._numTilesY=d_t&&d_t(),e._mode=p_t&&p_t(),e.animation=m_t&&m_t(),e.frameOverTime=g_t&&g_t(),e.startFrame=y_t&&y_t(),e.cycleCount=v_t&&v_t(),e._flipU=b_t&&b_t(),e._flipV=S_t&&S_t(),e._uvChannelMask=w_t&&w_t(),e.randomRow=x_t&&x_t(),e.rowIndex=T_t&&T_t(),e.name="textureModule",e}s(e,t);var i=e.prototype;return i.init=function(t){t.startRow=Math.floor(sn()*this.numTilesY)},i.animate=function(t){var e=1-t.remainingLifetime/t.startLifetime,i=Vct(this.startFrame)?un(t.randomSeed+90794):0,n=Vct(this.frameOverTime)?un(t.randomSeed+90794):0,r=this.startFrame.evaluate(e,i)/(this.numTilesX*this.numTilesY);if(this.animation===Cdt.WholeSheet)t.frameIndex=_n(this.cycleCount*(this.frameOverTime.evaluate(e,n)+r),1);else if(this.animation===Cdt.SingleRow){var s=1/this.numTilesY;if(this.randomRow){var a=_n(this.cycleCount*(this.frameOverTime.evaluate(e,n)+r),1),o=t.startRow*s,h=o+s;t.frameIndex=en(o,h,a)}else{var u=this.rowIndex*s,l=u+s;t.frameIndex=en(u,l,_n(this.cycleCount*(this.frameOverTime.evaluate(e,n)+r),1))}}},n(e,[{key:"enable",get:function(){return this._enable},set:function(t){this._enable!==t&&(this._enable=t,this.target&&(this.target.updateMaterialParams(),this.target.enableModule(this.name,t,this)))}},{key:"mode",get:function(){return this._mode},set:function(t){t!==Adt.Grid&&J("particle texture animation's sprites is not supported!")}},{key:"numTilesX",get:function(){return this._numTilesX},set:function(t){this._numTilesX!==t&&(this._numTilesX=t,this.target.updateMaterialParams())}},{key:"numTilesY",get:function(){return this._numTilesY},set:function(t){this._numTilesY!==t&&(this._numTilesY=t,this.target.updateMaterialParams())}},{key:"flipU",get:function(){return this._flipU},set:function(){J("particle texture animation's flipU is not supported!")}},{key:"flipV",get:function(){return this._flipV},set:function(){J("particle texture animation's flipV is not supported!")}},{key:"uvChannelMask",get:function(){return this._uvChannelMask},set:function(){J("particle texture animation's uvChannelMask is not supported!")}}]),e}(Ict),f_t=zh(c_t.prototype,"_enable",[uu],(function(){return!1})),__t=zh(c_t.prototype,"_numTilesX",[n_t],(function(){return 0})),d_t=zh(c_t.prototype,"_numTilesY",[r_t],(function(){return 0})),p_t=zh(c_t.prototype,"_mode",[s_t],(function(){return Adt.Grid})),v(c_t.prototype,"mode",[a_t],Object.getOwnPropertyDescriptor(c_t.prototype,"mode"),c_t.prototype),m_t=zh(c_t.prototype,"animation",[o_t,uu],(function(){return Cdt.WholeSheet})),g_t=zh(c_t.prototype,"frameOverTime",[h_t,uu],(function(){return new Olt})),y_t=zh(c_t.prototype,"startFrame",[u_t,uu],(function(){return new Olt})),v_t=zh(c_t.prototype,"cycleCount",[uu],(function(){return 0})),b_t=zh(c_t.prototype,"_flipU",[uu],(function(){return 0})),S_t=zh(c_t.prototype,"_flipV",[uu],(function(){return 0})),w_t=zh(c_t.prototype,"_uvChannelMask",[uu],(function(){return-1})),x_t=zh(c_t.prototype,"randomRow",[uu],(function(){return!1})),T_t=zh(c_t.prototype,"rowIndex",[uu],(function(){return 0})),l_t=c_t))||l_t),Bdt=197866,Idt=new ir,Mdt=(A_t=Kh("cc.VelocityOvertimeModule"),C_t=Ou(Olt),D_t=Ou(Olt),B_t=Ou(Olt),I_t=Ou(Olt),M_t=Ou(Uct),A_t((E_t=function(t){function e(){var e;return(e=t.call(this)||this)._enable=O_t&&O_t(),e.x=k_t&&k_t(),e.y=R_t&&R_t(),e.z=F_t&&F_t(),e.speedModifier=L_t&&L_t(),e.space=V_t&&V_t(),e.rotation=void 0,e.needTransform=void 0,e.name="velocityModule",e.rotation=new kr,e.speedModifier.constant=1,e.needTransform=!1,e.needUpdate=!0,e}s(e,t);var i=e.prototype;return i.update=function(t,e){this.needTransform=Pct(t,this.space,e,this.rotation)},i.animate=function(t){var e=1-t.remainingLifetime/t.startLifetime,i=Vct(this.x)?un(t.randomSeed^Bdt):0,n=Vct(this.y)?un(156497^t.randomSeed):0,r=Vct(this.z)?un(984136^t.randomSeed):0,s=Vct(this.speedModifier)?un(t.randomSeed+Bdt):0,a=ir.set(Idt,this.x.evaluate(e,i),this.y.evaluate(e,n),this.z.evaluate(e,r));this.needTransform&&ir.transformQuat(a,a,this.rotation),ir.add(t.animatedVelocity,t.animatedVelocity,a),ir.add(t.ultimateVelocity,t.velocity,t.animatedVelocity),ir.multiplyScalar(t.ultimateVelocity,t.ultimateVelocity,this.speedModifier.evaluate(1-t.remainingLifetime/t.startLifetime,s))},n(e,[{key:"enable",get:function(){return this._enable},set:function(t){this._enable!==t&&(this._enable=t,this.target&&this.target.enableModule(this.name,t,this))}}]),e}(Ict),O_t=zh(E_t.prototype,"_enable",[uu],(function(){return!1})),k_t=zh(E_t.prototype,"x",[C_t,uu],(function(){return new Olt})),R_t=zh(E_t.prototype,"y",[D_t,uu],(function(){return new Olt})),F_t=zh(E_t.prototype,"z",[B_t,uu],(function(){return new Olt})),L_t=zh(E_t.prototype,"speedModifier",[I_t,uu],(function(){return new Olt})),V_t=zh(E_t.prototype,"space",[M_t,uu],(function(){return 1})),P_t=E_t))||P_t),Pdt=t("e$",(N_t=Kh("cc.Burst"),z_t=Ou(Olt),N_t((G_t=function(){function t(){this._time=H_t&&H_t(),this._repeatCount=W_t&&W_t(),this.repeatInterval=j_t&&j_t(),this.count=q_t&&q_t(),this._remainingCount=0,this._curTime=0}var e=t.prototype;return e.update=function(t,e){if(0===this._remainingCount&&(this._remainingCount=this._repeatCount,this._curTime=this._time),this._remainingCount>0){var i=_n(t.time-t.startDelay.evaluate(0,1),t.duration)-e;i=i>0?i:0;var n=_n(t.time-t.startDelay.evaluate(0,1),t.duration);this._curTime>=i&&this._curTime0&&(t.position.x+=on(-this.randomPositionAmount,this.randomPositionAmount),t.position.y+=on(-this.randomPositionAmount,this.randomPositionAmount),t.position.z+=on(-this.randomPositionAmount,this.randomPositionAmount)),ir.transformQuat(t.velocity,t.velocity,this.quat),ir.transformMat4(t.position,t.position,this.mat),this.sphericalDirectionAmount>0){var e=ir.normalize(Edt,t.position);ir.lerp(t.velocity,t.velocity,e,this.sphericalDirectionAmount)}this.lastTime=this.particleSystem.time},e.constructMat=function(){kr.fromEuler(this.quat,this._rotation.x,this._rotation.y,this._rotation.z),Kr.fromRTS(this.mat,this.quat,this._position,this._scale)},e.generateArcAngle=function(){if(0===this.arcMode)return on(0,this._arc);var t=this.totalAngle+2*Math.PI*this.arcSpeed.evaluate(this.particleSystem.time,1)*(this.particleSystem.time-this.lastTime);switch(this.totalAngle=t,0!==this.arcSpread&&(t=Math.floor(t/(this._arc*this.arcSpread))*this._arc*this.arcSpread),this.arcMode){case 1:default:return _n(t,this._arc);case 2:return dn(t,this._arc)}},n(t,[{key:"position",get:function(){return this._position},set:function(t){this._position=t,this.constructMat()}},{key:"rotation",get:function(){return this._rotation},set:function(t){this._rotation=t,this.constructMat()}},{key:"scale",get:function(){return this._scale},set:function(t){this._scale=t,this.constructMat()}},{key:"arc",get:function(){return rn(this._arc)},set:function(t){this._arc=nn(t)}},{key:"angle",get:function(){return Math.round(100*rn(this._angle))/100},set:function(t){this._angle=nn(t)}},{key:"enable",get:function(){return this._enable},set:function(t){this._enable=t}},{key:"shapeType",get:function(){return this._shapeType},set:function(t){switch(this._shapeType=t,this._shapeType){case 0:0===this.emitFrom&&(this.emitFrom=3);break;case 2:1===this.emitFrom&&(this.emitFrom=0);break;case 3:case 4:0!==this.emitFrom&&1!==this.emitFrom||(this.emitFrom=3)}}}]),t}(),idt=zh(edt.prototype,"_enable",[uu],(function(){return!1})),ndt=zh(edt.prototype,"_shapeType",[Y_t,J_t],(function(){return 2})),v(edt.prototype,"shapeType",[K_t],Object.getOwnPropertyDescriptor(edt.prototype,"shapeType"),edt.prototype),rdt=zh(edt.prototype,"emitFrom",[Q_t,uu],(function(){return 3})),sdt=zh(edt.prototype,"alignToDirection",[uu],(function(){return!1})),adt=zh(edt.prototype,"randomDirectionAmount",[uu],(function(){return 0})),odt=zh(edt.prototype,"sphericalDirectionAmount",[uu],(function(){return 0})),hdt=zh(edt.prototype,"randomPositionAmount",[uu],(function(){return 0})),udt=zh(edt.prototype,"radius",[uu],(function(){return 1})),ldt=zh(edt.prototype,"radiusThickness",[uu],(function(){return 1})),cdt=zh(edt.prototype,"arcMode",[Z_t,uu],(function(){return 0})),fdt=zh(edt.prototype,"arcSpread",[uu],(function(){return 0})),_dt=zh(edt.prototype,"arcSpeed",[$_t,uu],(function(){return new Olt})),ddt=zh(edt.prototype,"length",[uu],(function(){return 5})),pdt=zh(edt.prototype,"boxThickness",[uu],(function(){return new ir(0,0,0)})),mdt=zh(edt.prototype,"_position",[uu],(function(){return new ir(0,0,0)})),gdt=zh(edt.prototype,"_rotation",[uu],(function(){return new ir(0,0,0)})),ydt=zh(edt.prototype,"_scale",[uu],(function(){return new ir(1,1,1)})),vdt=zh(edt.prototype,"_arc",[uu],(function(){return nn(360)})),bdt=zh(edt.prototype,"_angle",[uu],(function(){return nn(25)})),tdt=edt))||tdt);function Fdt(t,e,i,n,r){switch(t){case 3:kct(n,e*(1-i),e),ir.normalize(r,n);break;case 2:Oct(n),ir.multiplyScalar(n,n,e),ir.normalize(r,n);break;default:Y(t+" is not supported for sphere emitter.")}}function Ldt(t,e,i,n,r){switch(t){case 3:kct(n,e*(1-i),e),n.z>0&&(n.z*=-1),ir.normalize(r,n);break;case 2:Oct(n),ir.multiplyScalar(n,n,e),n.z>0&&(n.z*=-1),ir.normalize(r,n);break;default:Y(t+" is not supported for hemisphere emitter.")}}function Vdt(t,e,i,n,r,s,a,o){switch(t){case 0:Rct(a,e*(1-i),e,n),ds.multiplyScalar(o,a,Math.sin(r)),o.z=-Math.cos(r)*e,ir.normalize(o,o),a.z=0;break;case 2:Ect(a,n),ds.multiplyScalar(o,a,Math.sin(r)),o.z=-Math.cos(r),ir.normalize(o,o),ds.multiplyScalar(a,a,e),a.z=0;break;case 3:Rct(a,e*(1-i),e,n),ds.multiplyScalar(o,a,Math.sin(r)),o.z=-Math.cos(r)*e,ir.normalize(o,o),a.z=0,ir.add(a,a,ir.multiplyScalar(Edt,o,s*sn()/-o.z));break;default:Y(t+" is not supported for cone emitter.")}}function Ndt(t,e,i,n){switch(t){case 3:r=i,s=kdt,ir.set(r,on(-s.x,s.x),on(-s.y,s.y),on(-s.z,s.z));break;case 2:Odt[0]=on(-.5,.5),Odt[1]=on(-.5,.5),Odt[2]=.5*Lct(),Fct(Odt),Udt(Odt,e),ir.set(i,Odt[0],Odt[1],Odt[2]);break;case 1:Odt[0]=on(-.5,.5),Odt[1]=.5*Lct(),Odt[2]=.5*Lct(),Fct(Odt),Udt(Odt,e),ir.set(i,Odt[0],Odt[1],Odt[2]);break;default:Y(t+" is not supported for box emitter.")}var r,s;ir.copy(n,Mct)}function zdt(t,e,i,n,r){Rct(n,t*(1-e),t,i),ir.normalize(r,n)}function Udt(t,e){e.x>0&&(t[0]+=.5*on(-e.x,e.x),t[0]=$i(t[0],-.5,.5)),e.y>0&&(t[1]+=.5*on(-e.y,e.y),t[1]=$i(t[1],-.5,.5)),e.z>0&&(t[2]+=.5*on(-e.z,e.z),t[2]=$i(t[2],-.5,.5))}var Gdt=[0,0,1,0,0,1,1,1],Hdt=[0,0,0,1,0,0,0,1,0,1,1,0],Wdt=function(t){function e(){var e;return(e=t.call(this)||this)._capacity=void 0,e._bufferSize=void 0,e._vertAttrs=void 0,e._vertAttribSize=void 0,e._vBuffer=void 0,e._vertAttrsFloatCount=void 0,e._vdataF32=void 0,e._vdataUint32=void 0,e._subMeshData=void 0,e._mesh=void 0,e._vertCount=0,e._indexCount=0,e._startTimeOffset=0,e._lifeTimeOffset=0,e._material=null,e._vertAttribSizeStatic=void 0,e._vertStaticAttrsFloatCount=void 0,e._insBuffers=void 0,e._insIndices=void 0,e._useInstance=void 0,e._iaVertCount=0,e._iaIndexCount=0,e.type=4,e._capacity=0,e._bufferSize=16,e._vertAttrs=null,e._vertAttribSize=0,e._vBuffer=null,e._vertAttrsFloatCount=0,e._vdataF32=null,e._vdataUint32=null,e._vertAttribSizeStatic=0,e._vertStaticAttrsFloatCount=0,e._insBuffers=[],e._insIndices=null,Wp.gfxDevice.hasFeature(1)?e._useInstance=!0:e._useInstance=!1,e._subMeshData=null,e._mesh=null,e}s(e,t);var i=e.prototype;return i.setCapacity=function(t){var e=this._capacity!==t;this._capacity=t,this._bufferSize=Math.max(this._capacity,16),this._subMeshData&&e&&this.rebuild()},i.setVertexAttributes=function(t,e){if(this._useInstance)this.setVertexAttributesIns(t,e);else{if(this._mesh===t&&this._vertAttrs===e)return;this._mesh=t,this._vertAttrs=e,this._vertAttribSize=0;for(var i,n=p(this._vertAttrs);!(i=n()).done;){var r=i.value;r.offset=this._vertAttribSize,this._vertAttribSize+=ip[r.format].size}this._vertAttrsFloatCount=this._vertAttribSize/4,this.rebuild()}},i.setVertexAttributesIns=function(t,e){if(this._mesh!==t||this._vertAttrs!==e){this._mesh=t,this._vertAttrs=e,this._vertAttribSize=0,this._vertAttribSizeStatic=0;for(var i,n=p(this._vertAttrs);!(i=n()).done;){var r=i.value;0===r.stream?(r.offset=this._vertAttribSize,this._vertAttribSize+=ip[r.format].size):1===r.stream&&(r.offset=this._vertAttribSizeStatic,this._vertAttribSizeStatic+=ip[r.format].size)}this._vertAttrsFloatCount=this._vertAttribSize/4,this._vertStaticAttrsFloatCount=this._vertAttribSizeStatic/4,this.rebuild()}},i.createSubMeshData=function(){this.destroySubMeshData(),this._vertCount=4,this._indexCount=6,this._mesh&&(this._vertCount=this._mesh.struct.vertexBundles[this._mesh.struct.primitives[0].vertexBundelIndices[0]].view.count,this._indexCount=this._mesh.struct.primitives[0].indexView.count);var t=this._device.createBuffer(new ud(10,3,this._vertAttribSize*this._bufferSize*this._vertCount,this._vertAttribSize)),e=new ArrayBuffer(this._vertAttribSize*this._bufferSize*this._vertCount);if(this._mesh&&this._capacity>0){var i=this._vertAttrs[this._vertAttrs.findIndex((function(t){return"a_texCoord"===t.name}))].offset;this._mesh.copyAttribute(0,"a_texCoord",e,this._vertAttribSize,i);var n=this._vertAttrs.findIndex((function(t){return"a_texCoord3"===t.name}));if(i=this._vertAttrs[n++].offset,this._mesh.copyAttribute(0,"a_position",e,this._vertAttribSize,i),i=this._vertAttrs[n++].offset,this._mesh.copyAttribute(0,"a_normal",e,this._vertAttribSize,i),i=this._vertAttrs[n++].offset,!this._mesh.copyAttribute(0,"a_color",e,this._vertAttribSize,i))for(var r=new Uint32Array(e),s=0;s0){this._mesh.copyIndices(0,h);for(var u=1;u=this._particleSystem.capacity?null:this._particles.add()},i.getDefaultTrailMaterial=function(){return this._defaultTrailMat},i.setNewParticle=function(){},i._initModuleList=function(){var t=this;Zdt.forEach((function(e){if(t._particleSystem){var i=t._particleSystem[e];i&&i.enable&&(i.needUpdate&&t._updateList.set(i.name,i),i.needAnimate&&t._animateList.set(i.name,i))}})),this._runAnimateList.length=0;for(var e=0,i=Dct.length;e0,this._particles.length},i.getNoisePreview=function(t,e,i){var n=this;this._runAnimateList.forEach((function(r){r.name===Cct&&r.getNoisePreview(t,n._particleSystem,e,i)}))},i.updateRenderData=function(){for(var t=0,e=0;e=(null==(t=this._particleSystem)?void 0:t.capacity)?null:this._tempParticle},i.setNewParticle=function(t){this._particleSystem&&(this._model.addGPUParticleVertexData(t,this._particleNum,this._particleSystem.time),this._particleNum++)},i.getDefaultMaterial=function(){return this._defaultMat},i.updateRotation=function(t){t&&this.doUpdateRotation(t)},i.doUpdateRotation=function(t){if(4===this._renderInfo.renderMode||2!==this._alignSpace){var e;if(1===this._alignSpace)null==(e=this._particleSystem)||e.node.getRotation(Apt);else if(0===this._alignSpace){var i;null==(i=this._particleSystem)||i.node.getWorldRotation(Apt)}else if(2===this._alignSpace){var n,r;Apt.set(0,0,0,1);var s=null==(n=this._particleSystem)||null==(r=n.node.scene.renderScene)?void 0:r.cameras;if(void 0!==s&&this._particleSystem)for(var a=0;a<(null==s?void 0:s.length);++a){var o=s[a];if((o.visibility&this._particleSystem.node.layer)===this._particleSystem.node.layer){kr.fromViewUp(Apt,o.forward);break}}}else Apt.set(0,0,0,1);t.setUniform(this._uNodeRotHandle,Apt)}},i.updateScale=function(t){t&&this.doUpdateScale(t)},i.doUpdateScale=function(t){var e,i=this._node_scale;switch(null==(e=this._particleSystem)?void 0:e.scaleSpace){case 1:this._particleSystem.node.getScale(i);break;case 0:this._particleSystem.node.getWorldScale(i)}t.setUniform(t.getHandle("scale"),Spt.set(i.x,i.y,i.z))},i.updateParticles=function(t){return this._particleSystem?(this._particleNum=this._model.updateGPUParticles(this._particleNum,this._particleSystem.time,t),this.updateShaderUniform(t),this._model.enabled=this._particleNum>0,this._particleNum):this._particleNum},i.updateRenderData=function(){},i.beforeRender=function(){this._model.updateIA(this._particleNum)},i.updateAlignSpace=function(t){this._alignSpace=t},i.updateShaderUniform=function(t){if(this._particleSystem){var e=this._particleSystem.getMaterialInstance(0)||this._defaultMat;if(e){var i=e.passes[0];xpt.x=this._particleSystem.time,xpt.y=t,i.setUniform(this._uTimeHandle,xpt),this._particleSystem.node.getWorldRotation(Tpt),i.setUniform(this._uRotHandle,Tpt),this.doUpdateRotation(i)}}},i.initShaderUniform=function(t){var e,i,n,r,s,a,o=t.passes[0];this._uTimeHandle=o.getHandle("u_timeDelta"),this._uRotHandle=o.getHandle("u_worldRot"),this._uNodeRotHandle=o.getHandle("nodeRotation"),this.doUpdateScale(o),o.setUniform(o.getHandle("frameTile_velLenScale"),this._unifrom_velLenScale),xpt.x=Xpt,xpt.y=.03125,o.setUniform(o.getHandle("u_sampleInfo"),xpt);var h=!1,u=null==(e=this._particleSystem)?void 0:e._forceOvertimeModule;if(h=!!u&&u.enable,this._defines.FORCE_OVER_TIME_MODULE_ENABLE=h,h){var l=Ult(this._forceTexture,this._forceData,Xpt,u.x,u.y,u.z);this._forceTexture=l.texture,this._forceData=l.texdata;var c=o.getHandle("force_over_time_tex0"),f=ZS(c);o.bindSampler(f,this._forceTexture.getGFXSampler()),o.bindTexture(f,this._forceTexture.getGFXTexture());var _=o.getHandle("u_force_space");o.setUniform(_,u.space);var d=o.getHandle("u_force_mode");o.setUniform(d,this._forceTexture.height)}var p=null==(i=this._particleSystem)?void 0:i._velocityOvertimeModule;if(h=!!p&&p.enable,this._defines.VELOCITY_OVER_TIME_MODULE_ENABLE=h,h){var m=Glt(this._velocityTexture,this._velocityData,Xpt,p.x,p.y,p.z,p.speedModifier);this._velocityTexture=m.texture,this._velocityData=m.texdata;var g=o.getHandle("velocity_over_time_tex0"),y=ZS(g);o.bindSampler(y,this._velocityTexture.getGFXSampler()),o.bindTexture(y,this._velocityTexture.getGFXTexture());var v=o.getHandle("u_velocity_space");o.setUniform(v,p.space);var b=o.getHandle("u_velocity_mode");o.setUniform(b,this._velocityTexture.height)}var S=null==(n=this._particleSystem)?void 0:n._colorOverLifetimeModule;if(h=!!S&&S.enable,this._defines.COLOR_OVER_TIME_MODULE_ENABLE=h,h){var w=pct(this._colorTexture,this._colorData,Xpt,S.color);this._colorTexture=w.texture,this._colorData=w.texdata;var x=o.getHandle("color_over_time_tex0"),T=ZS(x);o.bindSampler(T,this._colorTexture.getGFXSampler()),o.bindTexture(T,this._colorTexture.getGFXTexture());var A=o.getHandle("u_color_mode");o.setUniform(A,this._colorTexture.height)}var C,D=null==(r=this._particleSystem)?void 0:r._rotationOvertimeModule;if(h=!!D&&D.enable,this._defines.ROTATION_OVER_TIME_MODULE_ENABLE=h,h&&(C=D.separateAxes?Ult(this._rotationTexture,this._rotationData,Xpt,D.x,D.y,D.z):Vlt(this._rotationTexture,this._rotationData,Xpt,D.z),this._rotationTexture=C.texture,this._rotationData=C.texdata,this._rotationTexture)){var B=o.getHandle("rotation_over_time_tex0"),I=ZS(B);o.bindSampler(I,this._rotationTexture.getGFXSampler()),o.bindTexture(I,this._rotationTexture.getGFXTexture());var M=o.getHandle("u_rotation_mode");o.setUniform(M,this._rotationTexture.height)}var P,E=null==(s=this._particleSystem)?void 0:s._sizeOvertimeModule;if(h=!!E&&E.enable,this._defines.SIZE_OVER_TIME_MODULE_ENABLE=h,h&&(P=E.separateAxes?Ult(this._sizeTexture,this._sizeData,Xpt,E.x,E.y,E.z,!0):Nlt(this._sizeTexture,this._sizeData,Xpt,E.size),this._sizeTexture=P.texture,this._sizeData=P.texdata,this._sizeTexture)){var O=o.getHandle("size_over_time_tex0"),k=ZS(O);o.bindSampler(k,this._sizeTexture.getGFXSampler()),o.bindTexture(k,this._sizeTexture.getGFXTexture());var R=o.getHandle("u_size_mode");o.setUniform(R,this._sizeTexture.height)}var F=null==(a=this._particleSystem)?void 0:a._textureAnimationModule;if(h=!!F&&F.enable,this._defines.TEXTURE_ANIMATION_MODULE_ENABLE=h,h){var L=zlt(this._animTexture,this._animData,Xpt,F.startFrame,F.frameOverTime);this._animTexture=L.texture,this._animData=L.texdata;var V=o.getHandle("texture_animation_tex0"),N=ZS(V);o.bindSampler(N,this._animTexture.getGFXSampler()),o.bindTexture(N,this._animTexture.getGFXTexture());var z=o.getHandle("u_anim_info");xpt.x=this._animTexture.height,xpt.y=F.numTilesX*F.numTilesY,xpt.z=F.cycleCount,o.setUniform(z,xpt)}this._defines.USE_VK_SHADER=4===Wp.gfxDevice.gfxAPI,this._defines.CC_INSTANCE_PARTICLE=this._useInstance},i.getParticleCount=function(){return this._particleNum},i.onMaterialModified=function(){this._inited&&this.updateMaterialParams()},i.onRebuildPSO=function(t,e){this._model&&0===t&&this._model.setSubModelMaterial(0,e)},i.updateVertexAttrib=function(){if(4===this._renderInfo.renderMode&&this._renderInfo.mesh){var t=this._renderInfo.mesh.readAttributeFormat(0,"a_color");if(t){for(var e=35,i=0;i=8&&3&t.getFormatFeatures(44))||(A.warn("Maybe the device has restrictions on vertex textures or does not support float textures."),!1)}var cmt,fmt,_mt,dmt,pmt,mmt,gmt,ymt,vmt,bmt,Smt,wmt,xmt,Tmt,Amt,Cmt,Dmt,Bmt,Imt,Mmt,Pmt,Emt,Omt,kmt,Rmt,Fmt,Lmt,Vmt,Nmt,zmt,Umt,Gmt,Hmt,Wmt,jmt,qmt,Xmt,Ymt,Jmt,Kmt,Qmt,Zmt,$mt,tgt,egt,igt,ngt,rgt,sgt,agt,ogt,hgt,ugt,lgt,cgt,fgt,_gt,dgt,pgt,mgt,ggt,ygt,vgt,bgt,Sgt,wgt,xgt,Tgt,Agt,Cgt,Dgt,Bgt,Igt,Mgt,Pgt,Egt,Ogt,kgt,Rgt,Fgt,Lgt,Vgt,Ngt,zgt,Ugt,Ggt,Hgt,Wgt,jgt,qgt,Xgt,Ygt,Jgt,Kgt,Qgt,Zgt,$gt,tyt,eyt,iyt,nyt,ryt,syt,ayt,oyt,hyt,uyt,lyt,cyt,fyt,_yt,dyt,pyt,myt,gyt,yyt,vyt,byt,Syt,wyt,xyt,Tyt,Ayt,Cyt,Dyt,Byt,Iyt,Myt,Pyt,Eyt,Oyt,kyt,Ryt,Fyt,Lyt,Vyt,Nyt,zyt,Uyt,Gyt,Hyt,Wyt,jyt,qyt,Xyt,Yyt=(Cpt=Kh("cc.ParticleSystemRenderer"),Dpt=Ou(Wct),Bpt=Ou(Wct),Ipt=Ou(Pk),Mpt=Ou(GT),Ppt=Ou(GT),Ept=Ou(GT),Opt=Ou(GT),kpt=Ou(Hct),Cpt((qpt=function(){function t(){this._renderMode=Lpt&&Lpt(),this._velocityScale=Vpt&&Vpt(),this._lengthScale=Npt&&Npt(),this._mesh=zpt&&zpt(),this._cpuMaterial=Upt&&Upt(),this._gpuMaterial=Gpt&&Gpt(),this._mainTexture=Hpt&&Hpt(),this._useGPU=Wpt&&Wpt(),this._alignSpace=jpt&&jpt(),this._particleSystem=null}var e=t.prototype;return e.create=function(t){null===this._particleSystem?this._particleSystem=t:this._particleSystem!==t&&ht(6033)},e.onInit=function(t){this.create(t);var e=this._useGPU&&lmt();this._particleSystem.processor?ht(6034):(this._particleSystem.processor=e?new umt(this):new bpt(this),this._particleSystem.processor.updateAlignSpace(this.alignSpace),this._particleSystem.processor.onInit(t)),e?this.gpuMaterial=this.particleMaterial:(this.particleMaterial&&-1!==this.particleMaterial.effectName.indexOf("particle-gpu")&&(this.particleMaterial=null,at(6035)),this.cpuMaterial=this.particleMaterial)},e._switchProcessor=function(){if(this._particleSystem){this._particleSystem.processor&&(this._particleSystem.processor.detachFromScene(),this._particleSystem.processor.clear(),this._particleSystem.processor=null);var t=this._useGPU&&lmt();this.particleMaterial=t?this.gpuMaterial:this.cpuMaterial,this._particleSystem.processor=t?new umt(this):new bpt(this),this._particleSystem.processor.updateAlignSpace(this.alignSpace),this._particleSystem.processor.onInit(this._particleSystem),this._particleSystem.processor.onEnable(),this._particleSystem.bindModule()}},n(t,[{key:"renderMode",get:function(){return this._renderMode},set:function(t){this._renderMode!==t&&(this._renderMode=t,this._particleSystem&&this._particleSystem.processor.updateRenderMode())}},{key:"velocityScale",get:function(){return this._velocityScale},set:function(t){this._velocityScale=t,this._particleSystem&&this._particleSystem.processor.updateMaterialParams()}},{key:"lengthScale",get:function(){return this._lengthScale},set:function(t){this._lengthScale=t,this._particleSystem&&this._particleSystem.processor.updateMaterialParams()}},{key:"mesh",get:function(){return this._mesh},set:function(t){this._mesh=t,this._particleSystem&&this._particleSystem.processor.setVertexAttributes()}},{key:"particleMaterial",get:function(){return this._particleSystem?this._particleSystem.getSharedMaterial(0):null},set:function(t){this._particleSystem&&this._particleSystem.setSharedMaterial(t,0)}},{key:"cpuMaterial",get:function(){return this._cpuMaterial},set:function(t){if(t){var e=t.effectName;if(-1===e.indexOf("particle")||-1!==e.indexOf("particle-gpu"))return void at(6035)}this._cpuMaterial=t,this.particleMaterial=this._cpuMaterial}},{key:"gpuMaterial",get:function(){return this._gpuMaterial},set:function(t){t&&-1===t.effectName.indexOf("particle-gpu")?at(6035):(this._gpuMaterial=t,this.particleMaterial=this._gpuMaterial)}},{key:"trailMaterial",get:function(){return this._particleSystem?this._particleSystem.getSharedMaterial(1):null},set:function(t){this._particleSystem&&this._particleSystem.setSharedMaterial(t,1)}},{key:"mainTexture",get:function(){return this._mainTexture},set:function(t){this._mainTexture=t}},{key:"useGPU",get:function(){return this._useGPU},set:function(t){this._useGPU!==t&&(lmt()?this._useGPU=t:this._useGPU=!1,this._switchProcessor())}},{key:"alignSpace",get:function(){return this._alignSpace},set:function(t){this._alignSpace=t,this._particleSystem.processor.updateAlignSpace(this._alignSpace)}}]),t}(),qpt.AlignmentSpace=Hct,v((Fpt=qpt).prototype,"renderMode",[Dpt],Object.getOwnPropertyDescriptor(Fpt.prototype,"renderMode"),Fpt.prototype),Lpt=zh(Fpt.prototype,"_renderMode",[Bpt,uu],(function(){return 0})),Vpt=zh(Fpt.prototype,"_velocityScale",[uu],(function(){return 1})),Npt=zh(Fpt.prototype,"_lengthScale",[uu],(function(){return 1})),zpt=zh(Fpt.prototype,"_mesh",[uu],(function(){return null})),v(Fpt.prototype,"mesh",[Ipt],Object.getOwnPropertyDescriptor(Fpt.prototype,"mesh"),Fpt.prototype),v(Fpt.prototype,"particleMaterial",[Mpt],Object.getOwnPropertyDescriptor(Fpt.prototype,"particleMaterial"),Fpt.prototype),v(Fpt.prototype,"cpuMaterial",[Ppt],Object.getOwnPropertyDescriptor(Fpt.prototype,"cpuMaterial"),Fpt.prototype),Upt=zh(Fpt.prototype,"_cpuMaterial",[uu],(function(){return null})),v(Fpt.prototype,"gpuMaterial",[Ept],Object.getOwnPropertyDescriptor(Fpt.prototype,"gpuMaterial"),Fpt.prototype),Gpt=zh(Fpt.prototype,"_gpuMaterial",[uu],(function(){return null})),v(Fpt.prototype,"trailMaterial",[Opt],Object.getOwnPropertyDescriptor(Fpt.prototype,"trailMaterial"),Fpt.prototype),Hpt=zh(Fpt.prototype,"_mainTexture",[uu],(function(){return null})),Wpt=zh(Fpt.prototype,"_useGPU",[uu],(function(){return!1})),v(Fpt.prototype,"alignSpace",[kpt],Object.getOwnPropertyDescriptor(Fpt.prototype,"alignSpace"),Fpt.prototype),jpt=zh(Fpt.prototype,"_alignSpace",[uu],(function(){return 2})),Rpt=Fpt))||Rpt),Jyt=Math.cos(nn(100)),Kyt={position:new ir,velocity:new ir},Qyt=new kr,Zyt=new ir,$yt=new ir,tvt=new cr,evt=function(){function t(t){for(this.start=void 0,this.end=void 0,this.trailElements=void 0,this.start=-1,this.end=-1,this.trailElements=[];t--;)this.trailElements.push({position:new ir,lifetime:0,width:0,velocity:new ir,direction:0,color:new cr})}var e=t.prototype;return e.getElement=function(t){return-1===this.start?null:(t<0&&(t=(t+this.trailElements.length)%this.trailElements.length),t>=this.trailElements.length&&(t%=this.trailElements.length),this.trailElements[t])},e.addElement=function(){if(0===this.trailElements.length)return null;if(-1===this.start)return this.start=0,this.end=1,this.trailElements[0];this.start===this.end&&(this.trailElements.splice(this.end,0,{position:new ir,lifetime:0,width:0,velocity:new ir,direction:0,color:new cr}),this.start++,this.start%=this.trailElements.length);var t=this.end++;return this.end%=this.trailElements.length,this.trailElements[t]},e.iterateElement=function(t,e,i,n){for(var r=this.start>=this.end?this.end+this.trailElements.length:this.end,s=this.start;st.lastLoop)t.trailDelay>1?(t.lastLoop=t.loopCount,t.trailDelay=0):t.trailDelay++;else{var i=this._particleTrail.get(t);if(!i)return i=this._trailSegments.alloc(),void this._particleTrail.set(t,i);var n=i.getElement(i.end-1);if(this._needTransform?ir.transformMat4(Zyt,t.position,this._psTransform):ir.copy(Zyt,t.position),!(n&&(i.iterateElement(this,this._updateTrailElement,t,e),ir.squaredDistance(n.position,Zyt)2){var a=i.getElement(i.end-2),o=i.getElement(i.end-3);ir.subtract(Zyt,o.position,a.position),ir.subtract($yt,n.position,a.position),ir.subtract(a.velocity,$yt,Zyt),ir.equals(ir.ZERO,a.velocity)&&ir.copy(a.velocity,Zyt),ir.normalize(a.velocity,a.velocity),this._checkDirectionReverse(a,o)}this.colorFromParticle?n.color.set(t.color):n.color.set(this.colorOvertime.evaluate(0,1))}}},t.removeParticle=function(t){var e=this._particleTrail.get(t);e&&this._trailSegments&&(e.clear(),this._trailSegments.free(e),this._particleTrail.delete(t))},t.updateRenderData=function(){this.vbOffset=0,this.ibOffset=0;for(var t,e=p(this._particleTrail.keys());!(t=e()).done;){var i=t.value,n=this._particleTrail.get(i);if(-1!==n.start){var r=4*this.vbOffset/this._vertSize,s=n.start>=n.end?n.end+n.trailElements.length:n.end,a=s-n.start,o=1/a,h=n.trailElements[n.start];this._fillVertexBuffer(h,this.colorOverTrail.evaluate(1,1),r,1,0,4);for(var u=n.start+1;u2){var v=n.getElement(n.end-1),b=n.getElement(n.end-2);ir.subtract(Zyt,b.position,v.position),ir.subtract($yt,Kyt.position,v.position),ir.normalize(Zyt,Zyt),ir.normalize($yt,$yt),ir.subtract(v.velocity,$yt,Zyt),ir.normalize(v.velocity,v.velocity),this._checkDirectionReverse(v,b),this.vbOffset-=this._vertSize/4*2,this.ibOffset-=6,this._fillVertexBuffer(v,this.colorOverTrail.evaluate(o,1),r,o,a-1,5),ir.subtract(Kyt.velocity,Kyt.position,v.position),ir.normalize(Kyt.velocity,Kyt.velocity),this._checkDirectionReverse(Kyt,v)}this.widthFromParticle?Kyt.width=i.size.x*this.widthRatio.evaluate(0,1):Kyt.width=this.widthRatio.evaluate(0,1),Kyt.color=i.color,ir.equals(Kyt.velocity,ir.ZERO)?this.ibOffset-=3:this._fillVertexBuffer(Kyt,this.colorOverTrail.evaluate(0,1),r,0,a,1)}}this._trailModel&&(this._trailModel.enabled=this.ibOffset>0)},t.updateIA=function(t){var e=this._trailModel&&this._trailModel.subModels;if(e&&e.length>0){var i=e[0];i.inputAssembler.vertexBuffers[0].update(this._vbF32),i.inputAssembler.indexBuffer.update(this._iBuffer),i.inputAssembler.firstIndex=0,i.inputAssembler.indexCount=t,i.inputAssembler.vertexCount=this._iaVertCount}},t.beforeRender=function(){this.updateIA(this.ibOffset)},t._createModel=function(){this._trailModel||(this._trailModel=A.director.root.createModel(KM))},t.rebuild=function(){var t=this,e=YE.root.device,i=e.createBuffer(new ud(10,3,t._vertSize*(t._trailNum+1)*2,t._vertSize)),n=new ArrayBuffer(t._vertSize*(t._trailNum+1)*2);t._vbF32=new Float32Array(n),t._vbUint32=new Uint32Array(n),i.update(n);var r=e.createBuffer(new ud(6,3,12*Math.max(1,t._trailNum),2));t._iBuffer=new Uint16Array(6*Math.max(1,t._trailNum)),r.update(t._iBuffer),t._iaVertCount=2*(t._trailNum+1),t._iaIndexCount=6*t._trailNum,t._subMeshData=new sO([i],t._vertAttrs,7,r);var s=t._trailModel;s&&t._material&&(s.node=s.transform=t._particleSystem.node,s.visFlags=t._particleSystem.visibility,s.initSubModel(0,t._subMeshData,t._material),s.enabled=!0)},t._updateTrailElement=function(t,e,i,n){return e.lifetime+=n,t.colorFromParticle?(e.color.set(i.color),e.color.multiply(t.colorOvertime.evaluate(1-i.remainingLifetime/i.startLifetime,1))):e.color.set(t.colorOvertime.evaluate(1-i.remainingLifetime/i.startLifetime,1)),t.widthFromParticle?e.width=i.size.x*t.widthRatio.evaluate(e.lifetime/t._trailLifetime,1):e.width=t.widthRatio.evaluate(e.lifetime/t._trailLifetime,1),e.lifetime>t._trailLifetime},t._fillVertexBuffer=function(t,e,i,n,r,s){this._vbF32[this.vbOffset++]=t.position.x,this._vbF32[this.vbOffset++]=t.position.y,this._vbF32[this.vbOffset++]=t.position.z,this._vbF32[this.vbOffset++]=t.direction,this._vbF32[this.vbOffset++]=t.width,this._vbF32[this.vbOffset++]=n,this._vbF32[this.vbOffset++]=0,this._vbF32[this.vbOffset++]=t.velocity.x,this._vbF32[this.vbOffset++]=t.velocity.y,this._vbF32[this.vbOffset++]=t.velocity.z,tvt.set(t.color),tvt.multiply(e),this._vbUint32[this.vbOffset++]=cr.toUint32(tvt),this._vbF32[this.vbOffset++]=t.position.x,this._vbF32[this.vbOffset++]=t.position.y,this._vbF32[this.vbOffset++]=t.position.z,this._vbF32[this.vbOffset++]=1-t.direction,this._vbF32[this.vbOffset++]=t.width,this._vbF32[this.vbOffset++]=n,this._vbF32[this.vbOffset++]=1,this._vbF32[this.vbOffset++]=t.velocity.x,this._vbF32[this.vbOffset++]=t.velocity.y,this._vbF32[this.vbOffset++]=t.velocity.z,this._vbUint32[this.vbOffset++]=cr.toUint32(tvt),1&s&&(this._iBuffer[this.ibOffset++]=i+2*r,this._iBuffer[this.ibOffset++]=i+2*r-1,this._iBuffer[this.ibOffset++]=i+2*r+1),4&s&&(this._iBuffer[this.ibOffset++]=i+2*r,this._iBuffer[this.ibOffset++]=i+2*r+1,this._iBuffer[this.ibOffset++]=i+2*r+2)},t._checkDirectionReverse=function(t,e){ir.dot(t.velocity,e.velocity)0&&!n._isCulled&&(null!=(e=r.getModel())&&e.scene||r.attachToScene(),s&&s.enable&&(null!=(i=s.getModel())&&i.scene||s._attachToScene()),n._needAttach=!1);!n.renderer.useGPU&&s&&s.enable&&(s.inited||(s.clear(),s.destroy(),s.onInit(this),s.enable=!1,s.enable=!0))},i.beforeRender=function(){var t,e,i=this,n=i.processor,r=i.trailModule;i.getParticleCount()<=0?null!=(e=n.getModel())&&e.scene&&(n.detachFromScene(),r&&r.enable&&r._detachFromScene(),i._needAttach=!1):null!=(t=n.getModel())&&t.scene||(i._needAttach=!0),i._isPlaying&&(n.updateRenderData(),n.beforeRender(),r&&r.enable&&(r.updateRenderData(),r.beforeRender()))},i._onVisibilityChange=function(t){this.processor.model&&(this.processor.model.visFlags=t)},i.emit=function(t,e){var i=this,n=i.node,r=i._time%i.duration/i.duration;i._needRefresh&&(n.invalidateChildren(1),i._needRefresh=!1),0===i._simulationSpace&&(n.getWorldMatrix(fvt),n.getWorldRotation(_vt));for(var s=0;si){if(e._time>e.duration+i&&(e.loop||(e._isEmitting=!1)),!e._isEmitting)return;if(e._emitRateTimeCounter+=e.rateOverTime.evaluate(e._time/e.duration,1)*t,e._emitRateTimeCounter>1){var n=Math.floor(e._emitRateTimeCounter);e._emitRateTimeCounter-=n,e.emit(n,t)}var r=e.rateOverDistance.evaluate(e._time/e.duration,1);if(r>0){ir.copy(e._oldWPos,e._curWPos),e.node.getWorldPosition(e._curWPos);var s=ir.distance(e._curWPos,e._oldWPos);e._emitRateDistanceCounter+=s*r}if(e._emitRateDistanceCounter>1){var a=Math.floor(e._emitRateDistanceCounter);e._emitRateDistanceCounter-=a,e.emit(a,t)}for(var o,h=p(e.bursts);!(o=h()).done;)o.value.update(e,t)}},i._resetPosition=function(){this.node.getWorldPosition(this._oldWPos),ir.copy(this._curWPos,this._oldWPos)},i.addSubEmitter=function(t){this._subEmitters.push(t)},i.removeSubEmitter=function(t){this._subEmitters.splice(this._subEmitters.indexOf(t),1)},i.addBurst=function(t){this.bursts.push(t)},i.removeBurst=function(t){var e=this.bursts.indexOf(t);e>-1&&this.bursts.splice(e,1)},i.getBoundingX=function(){return this._aabbHalfX},i.getBoundingY=function(){return this._aabbHalfY},i.getBoundingZ=function(){return this._aabbHalfZ},i.setBoundingX=function(t){this._boundingBox&&this._culler&&(this._boundingBox.halfExtents.x=t,this._culler.setBoundingBoxSize(this._boundingBox.halfExtents),this._aabbHalfX=t)},i.setBoundingY=function(t){this._boundingBox&&this._culler&&(this._boundingBox.halfExtents.y=t,this._culler.setBoundingBoxSize(this._boundingBox.halfExtents),this._aabbHalfY=t)},i.setBoundingZ=function(t){this._boundingBox&&this._culler&&(this._boundingBox.halfExtents.z=t,this._culler.setBoundingBoxSize(this._boundingBox.halfExtents),this._aabbHalfZ=t)},i._onBeforeSerialize=function(t){var e=this;return this.dataCulling?t.filter((function(t){return!Bct.includes(t)||e[t]&&e[t].enable})):t},i.getNoisePreview=function(t,e){var i=[];return this.processor&&this.processor.getNoisePreview(i,t,e),i},n(e,[{key:"capacity",get:function(){return this._capacity},set:function(t){this._capacity=Math.floor(t>0?t:0),this.processor&&this.processor.model&&this.processor.model.setCapacity(this._capacity)}},{key:"prewarm",get:function(){return this._prewarm},set:function(t){!0===t&&this.loop,this._prewarm=t}},{key:"simulationSpace",get:function(){return this._simulationSpace},set:function(t){t!==this._simulationSpace&&(this._simulationSpace=t,this.processor&&(this.processor.updateMaterialParams(),this.processor.updateTrailMaterial()))}},{key:"renderCulling",get:function(){return this._renderCulling},set:function(t){this._renderCulling=t,t&&(this._boundingBox||(this._boundingBox=new gh,this._calculateBounding(!1)))}},{key:"cullingMode",get:function(){return this._cullingMode},set:function(t){this._cullingMode=t}},{key:"aabbHalfX",get:function(){return this.getBoundingX()||0},set:function(t){this.setBoundingX(t)}},{key:"aabbHalfY",get:function(){return this.getBoundingY()||0},set:function(t){this.setBoundingY(t)}},{key:"aabbHalfZ",get:function(){return this.getBoundingZ()||0},set:function(t){this.setBoundingZ(t)}},{key:"dataCulling",get:function(){return this._dataCulling},set:function(t){this._dataCulling=t}},{key:"sharedMaterials",get:function(){return dvt.get.call(this)},set:function(t){dvt.set.call(this,t)}},{key:"colorOverLifetimeModule",get:function(){return this._colorOverLifetimeModule},set:function(t){t&&(this._colorOverLifetimeModule=t)}},{key:"shapeModule",get:function(){return this._shapeModule},set:function(t){t&&(this._shapeModule=t)}},{key:"sizeOvertimeModule",get:function(){return this._sizeOvertimeModule},set:function(t){t&&(this._sizeOvertimeModule=t)}},{key:"velocityOvertimeModule",get:function(){return this._velocityOvertimeModule},set:function(t){t&&(this._velocityOvertimeModule=t)}},{key:"forceOvertimeModule",get:function(){return this._forceOvertimeModule},set:function(t){t&&(this._forceOvertimeModule=t)}},{key:"limitVelocityOvertimeModule",get:function(){return this._limitVelocityOvertimeModule},set:function(t){t&&(this._limitVelocityOvertimeModule=t)}},{key:"rotationOvertimeModule",get:function(){return this._rotationOvertimeModule},set:function(t){t&&(this._rotationOvertimeModule=t)}},{key:"textureAnimationModule",get:function(){return this._textureAnimationModule},set:function(t){t&&(this._textureAnimationModule=t)}},{key:"noiseModule",get:function(){return this._noiseModule},set:function(t){t&&(this._noiseModule=t)}},{key:"trailModule",get:function(){return this._trailModule},set:function(t){t&&(this._trailModule=t)}},{key:"isPlaying",get:function(){return this._isPlaying}},{key:"isPaused",get:function(){return this._isPaused}},{key:"isStopped",get:function(){return this._isStopped}},{key:"isEmitting",get:function(){return this._isEmitting}},{key:"time",get:function(){return this._time}}]),e}(HU),Xyt.CullingMode=Gct,ayt=zh((syt=Xyt).prototype,"startColor",[_gt,uu],(function(){return new fct})),oyt=zh(syt.prototype,"scaleSpace",[dgt,uu],(function(){return 1})),hyt=zh(syt.prototype,"startSize3D",[uu],(function(){return!1})),uyt=zh(syt.prototype,"startSizeX",[pgt,mgt],(function(){return new Olt})),lyt=zh(syt.prototype,"startSizeY",[ggt,uu],(function(){return new Olt})),cyt=zh(syt.prototype,"startSizeZ",[ygt,uu],(function(){return new Olt})),fyt=zh(syt.prototype,"startSpeed",[vgt,uu],(function(){return new Olt})),_yt=zh(syt.prototype,"startRotation3D",[uu],(function(){return!1})),dyt=zh(syt.prototype,"startRotationX",[bgt,uu],(function(){return new Olt})),pyt=zh(syt.prototype,"startRotationY",[Sgt,uu],(function(){return new Olt})),myt=zh(syt.prototype,"startRotationZ",[wgt,xgt],(function(){return new Olt})),gyt=zh(syt.prototype,"startDelay",[Tgt,uu],(function(){return new Olt})),yyt=zh(syt.prototype,"startLifetime",[Agt,uu],(function(){return new Olt})),vyt=zh(syt.prototype,"duration",[uu],(function(){return 5})),byt=zh(syt.prototype,"loop",[uu],(function(){return!0})),v(syt.prototype,"simulationSpace",[Cgt,uu],Object.getOwnPropertyDescriptor(syt.prototype,"simulationSpace"),syt.prototype),Syt=zh(syt.prototype,"simulationSpeed",[uu],(function(){return 1})),wyt=zh(syt.prototype,"playOnAwake",[uu],(function(){return!0})),xyt=zh(syt.prototype,"gravityModifier",[Dgt,uu],(function(){return new Olt})),Tyt=zh(syt.prototype,"rateOverTime",[Bgt,uu],(function(){return new Olt})),Ayt=zh(syt.prototype,"rateOverDistance",[Igt,uu],(function(){return new Olt})),Cyt=zh(syt.prototype,"bursts",[Mgt,uu],(function(){return[]})),v(syt.prototype,"renderCulling",[Pgt],Object.getOwnPropertyDescriptor(syt.prototype,"renderCulling"),syt.prototype),Dyt=zh(syt.prototype,"_renderCulling",[uu],(function(){return!1})),v(syt.prototype,"cullingMode",[Egt],Object.getOwnPropertyDescriptor(syt.prototype,"cullingMode"),syt.prototype),Byt=zh(syt.prototype,"_cullingMode",[uu],(function(){return 0})),v(syt.prototype,"aabbHalfX",[Ogt],Object.getOwnPropertyDescriptor(syt.prototype,"aabbHalfX"),syt.prototype),Iyt=zh(syt.prototype,"_aabbHalfX",[uu],(function(){return 0})),v(syt.prototype,"aabbHalfY",[kgt],Object.getOwnPropertyDescriptor(syt.prototype,"aabbHalfY"),syt.prototype),Myt=zh(syt.prototype,"_aabbHalfY",[uu],(function(){return 0})),v(syt.prototype,"aabbHalfZ",[Rgt],Object.getOwnPropertyDescriptor(syt.prototype,"aabbHalfZ"),syt.prototype),Pyt=zh(syt.prototype,"_aabbHalfZ",[uu],(function(){return 0})),Eyt=zh(syt.prototype,"_dataCulling",[uu,Fgt],(function(){return!1})),v(syt.prototype,"sharedMaterials",[Gu,uu],Object.getOwnPropertyDescriptor(syt.prototype,"sharedMaterials"),syt.prototype),Oyt=zh(syt.prototype,"_colorOverLifetimeModule",[Lgt],(function(){return null})),v(syt.prototype,"colorOverLifetimeModule",[Vgt],Object.getOwnPropertyDescriptor(syt.prototype,"colorOverLifetimeModule"),syt.prototype),kyt=zh(syt.prototype,"_shapeModule",[Ngt],(function(){return null})),v(syt.prototype,"shapeModule",[zgt],Object.getOwnPropertyDescriptor(syt.prototype,"shapeModule"),syt.prototype),Ryt=zh(syt.prototype,"_sizeOvertimeModule",[Ugt],(function(){return null})),v(syt.prototype,"sizeOvertimeModule",[Ggt],Object.getOwnPropertyDescriptor(syt.prototype,"sizeOvertimeModule"),syt.prototype),Fyt=zh(syt.prototype,"_velocityOvertimeModule",[Hgt],(function(){return null})),v(syt.prototype,"velocityOvertimeModule",[Wgt],Object.getOwnPropertyDescriptor(syt.prototype,"velocityOvertimeModule"),syt.prototype),Lyt=zh(syt.prototype,"_forceOvertimeModule",[jgt],(function(){return null})),v(syt.prototype,"forceOvertimeModule",[qgt],Object.getOwnPropertyDescriptor(syt.prototype,"forceOvertimeModule"),syt.prototype),Vyt=zh(syt.prototype,"_limitVelocityOvertimeModule",[Xgt],(function(){return null})),v(syt.prototype,"limitVelocityOvertimeModule",[Ygt],Object.getOwnPropertyDescriptor(syt.prototype,"limitVelocityOvertimeModule"),syt.prototype),Nyt=zh(syt.prototype,"_rotationOvertimeModule",[Jgt],(function(){return null})),v(syt.prototype,"rotationOvertimeModule",[Kgt],Object.getOwnPropertyDescriptor(syt.prototype,"rotationOvertimeModule"),syt.prototype),zyt=zh(syt.prototype,"_textureAnimationModule",[Qgt],(function(){return null})),v(syt.prototype,"textureAnimationModule",[Zgt],Object.getOwnPropertyDescriptor(syt.prototype,"textureAnimationModule"),syt.prototype),Uyt=zh(syt.prototype,"_noiseModule",[$gt],(function(){return null})),v(syt.prototype,"noiseModule",[tyt],Object.getOwnPropertyDescriptor(syt.prototype,"noiseModule"),syt.prototype),Gyt=zh(syt.prototype,"_trailModule",[eyt],(function(){return null})),v(syt.prototype,"trailModule",[iyt],Object.getOwnPropertyDescriptor(syt.prototype,"trailModule"),syt.prototype),Hyt=zh(syt.prototype,"renderer",[nyt,uu],(function(){return new Yyt})),Wyt=zh(syt.prototype,"_prewarm",[uu],(function(){return!1})),jyt=zh(syt.prototype,"_capacity",[uu],(function(){return 100})),qyt=zh(syt.prototype,"_simulationSpace",[uu],(function(){return 1})),ryt=syt))||ryt)||ryt)),mvt=t("eY",function(){function t(){}return t.instantiate=function(t){this.registeredSceneEvent||(YE.on("director_before_scene_launch",this.onSceneUnload,this),this.registeredSceneEvent=!0);var e=t._uuid;if(!this.particleSystemPool.has(e)){var i=new ho((function(){return J$(t)||new eb}),1,(function(t){return t.destroy()}));this.particleSystemPool.set(e,i)}return this.particleSystemPool.get(e).alloc()},t.destroy=function(t){var e,i,n=null==(e=t.prefab)||null==(i=e.asset)?void 0:i.uuid;n&&this.particleSystemPool.has(n)&&(this.stop(t),this.particleSystemPool.get(n).free(t))},t.play=function(t){for(var e,i=p(t.getComponentsInChildren(pvt));!(e=i()).done;)e.value.play()},t.stop=function(t){for(var e,i=p(t.getComponentsInChildren(pvt));!(e=i()).done;)e.value.stop()},t.onSceneUnload=function(){this.particleSystemPool.forEach((function(t){return t.destroy()})),this.particleSystemPool.clear()},t}());mvt.particleSystemPool=new Map,mvt.registeredSceneEvent=!1,mt(Pdt.prototype,"Burst.prototype",[{name:"minCount"},{name:"maxCount"}]),pt(pvt.prototype,"ParticleSystem.prototype",[{name:"enableCulling",newName:"dataCulling"}]),A.ParticleSystemComponent=pvt,le(pvt,"cc.ParticleSystemComponent"),A.BillboardComponent=Alt,le(Alt,"cc.BillboardComponent"),A.LineComponent=yct,le(yct,"cc.LineComponent"),A.ParticleUtils=mvt;var gvt=Ee({GRAVITY:0,RADIUS:1}),yvt=Ee({FREE:0,RELATIVE:1,GROUPED:2}),vvt=new ds,bvt=new ds,Svt=new ds,wvt=new ds,xvt=new Vn,Tvt=OF(IF);function Avt(t){for(var e=0,i=t;i;)e+=i.eulerAngles.z,i=i.parent;return e}var Cvt,Dvt,Bvt,Ivt=function(){this.pos=new ds(0,0),this.startPos=new ds(0,0),this.color=new cr(0,0,0,255),this.deltaColor={r:0,g:0,b:0,a:255},this.size=0,this.deltaSize=0,this.rotation=0,this.deltaRotation=0,this.timeToLive=0,this.drawPos=new ds(0,0),this.aspectRatio=1,this.dir=new ds(0,0),this.radialAccel=0,this.tangentialAccel=0,this.angle=0,this.degreesPerSecond=0,this.radius=0,this.deltaRadius=0},Mvt=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.prototype.get=function(){return this._get()||new Ivt},e}(ge),Pvt=new Mvt((function(t){t.pos.set(ds.ZERO),t.startPos.set(ds.ZERO),t.color.set(0,0,0,255),t.deltaColor.r=t.deltaColor.g=t.deltaColor.b=0,t.deltaColor.a=255,t.size=0,t.deltaSize=0,t.rotation=0,t.deltaRotation=0,t.timeToLive=0,t.drawPos.set(ds.ZERO),t.aspectRatio=1,t.dir.set(ds.ZERO),t.radialAccel=0,t.tangentialAccel=0,t.angle=0,t.degreesPerSecond=0,t.radius=0,t.deltaRadius=0}),1024),Evt=function(){function t(t){this.particles=[],this.active=!1,this.uvFilled=0,this.finished=!1,this.renderData=null,this.readyToPlay=!0,this.elapsed=0,this.emitCounter=0,this._worldRotation=0,this.sys=t,this.particles=[],this.active=!1,this.readyToPlay=!0,this.finished=!1,this.elapsed=0,this.emitCounter=0,this.uvFilled=0,this._worldRotation=0}var e=t.prototype;return e.stop=function(){this.active=!1,this.readyToPlay=!1,this.elapsed=this.sys.duration,this.emitCounter=0},e.reset=function(){this.active=!0,this.readyToPlay=!0,this.elapsed=0,this.emitCounter=0,this.finished=!1;for(var t=this.particles,e=0;e1?h=o/u:o=h*u;var l=o/2,c=h/2;if(t.rotation){var f=-l,_=-c,d=l,p=c,m=-nn(t.rotation),g=Math.cos(m),y=Math.sin(m);r[n]=f*g-_*y+s,r[n+1]=f*y+_*g+a,r[n+2]=0,r[n+9]=d*g-_*y+s,r[n+10]=d*y+_*g+a,r[n+11]=0,r[n+18]=f*g-p*y+s,r[n+19]=f*y+p*g+a,r[n+20]=0,r[n+27]=d*g-p*y+s,r[n+28]=d*y+p*g+a,r[n+29]=0}else r[n]=s-l,r[n+1]=a-c,r[n+2]=0,r[n+9]=s+l,r[n+10]=a-c,r[n+11]=0,r[n+18]=s-l,r[n+19]=a+c,r[n+20]=0,r[n+27]=s+l,r[n+28]=a+c,r[n+29]=0;var v=t.color;xvt.x=v.r/255,xvt.y=v.g/255,xvt.z=v.b/255,xvt.w=v.a/255,Vn.toArray(r,xvt,n+5),Vn.toArray(r,xvt,n+14),Vn.toArray(r,xvt,n+23),Vn.toArray(r,xvt,n+32)},e.step=function(t){var e=this.sys.assembler,i=this.sys,n=i.node,r=this.particles;if(t=t>e.maxParticleDeltaTime?e.maxParticleDeltaTime:t,n.updateWorldTransform(),i.positionType===yvt.FREE){this._worldRotation=Avt(n);var s=n.worldMatrix;vvt.x=s.m12,vvt.y=s.m13}else i.positionType===yvt.RELATIVE?(this._worldRotation=n.eulerAngles.z,vvt.x=n.position.x,vvt.y=n.position.y):this._worldRotation=0;if(this.active&&i.emissionRate){var a=1/i.emissionRate;for(r.lengtha;)this.emitParticle(vvt),this.emitCounter-=a;this.elapsed+=t,-1!==i.duration&&i.durationthis.uvFilled&&this.updateUVs();for(var u=0;u0){if(i.emitterMode===gvt.GRAVITY){var c=wvt,f=bvt,_=Svt;(l.pos.x||l.pos.y)&&(f.set(l.pos),f.normalize()),_.set(f),f.multiplyScalar(l.radialAccel);var d=_.x;_.x=-_.y,_.y=d,_.multiplyScalar(l.tangentialAccel),c.set(f),c.add(_),c.add(i.gravity),c.multiplyScalar(t),l.dir.add(c),c.set(l.dir),c.multiplyScalar(t),l.pos.add(c)}else l.angle+=l.degreesPerSecond*t,l.radius+=l.deltaRadius*t,l.pos.x=-Math.cos(l.angle)*l.radius,l.pos.y=-Math.sin(l.angle)*l.radius;l.color.r+=l.deltaColor.r*t,l.color.g+=l.deltaColor.g*t,l.color.b+=l.deltaColor.b*t,l.color.a+=l.deltaColor.a*t,l.size+=l.deltaSize*t,l.size<0&&(l.size=0),l.rotation+=l.deltaRotation*t;var p=bvt;p.set(l.pos),i.positionType!==yvt.GROUPED&&p.add(l.startPos);var m=Tvt*u*4;this.updateParticleBuffer(l,p,o,m),++u}else{var g=r[u];u!==r.length-1&&(r[u]=r[r.length-1]),Pvt.put(g),r.length--,o.resize(o.vertexCount-4,o.indexCount-6)}}o.material=this.sys.getRenderMaterial(0),o.frame=this.sys._renderSpriteFrame,o.setRenderDrawInfoAttributes(),0!==r.length||this.active||this.readyToPlay||(this.finished=!0,i._finishedSimulation())}},e.requestData=function(t,e){if(this.renderData){var i=this.renderData.indexCount;this.renderData.request(t,e);for(var n=this.renderData.indexCount/6,r=this.renderData.iData,s=i;s=0?hr;r>=0?++h:--h)t.push(n[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:this.transparency.indexed=this.read(r);var u=255-this.transparency.indexed.length;if(u>0)for(var l=0;u>=0?lu;u>=0?++l:--l)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(r)[0];break;case 2:this.transparency.rgb=this.read(r)}break;case"tEXt":var c=this.read(r),f=c.indexOf(0),_=String.fromCharCode.apply(String,c.slice(0,f));this.text[_]=String.fromCharCode.apply(String,c.slice(f+1));break;case"IEND":i&&this.animation.frames.push(i),this.colors=function(){switch(e.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3;default:return}}.call(this);var d=this.colorType;this.hasAlphaChannel=4===d||6===d;var p=this.colors+(this.hasAlphaChannel?1:0);return this.pixelBitlength=this.bits*p,this.colorSpace=function(){switch(e.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB";default:return}}.call(this),void(this.imgData instanceof Uint8Array||(this.imgData=new Uint8Array(this.imgData)));default:this.pos+=r}if(this.pos+=4,this.pos>n.length)throw new Error(ft(6017))}}var e=t.prototype;return e.read=function(t){var e=0,i=[];for(e=0;t>=0?et;t>=0?++e:--e)i.push(this.data[this.pos++]);return i},e.readUInt32=function(){var t=this.data;return t[this.pos++]<<24|t[this.pos++]<<16|t[this.pos++]<<8|t[this.pos++]},e.readUInt16=function(){return this.data[this.pos++]<<8|this.data[this.pos++]},e.decodePixels=function(t){if(null==t&&(t=this.imgData),0===t.length)return new Uint8Array(0);t=new gk.Inflate(t,{index:0,verify:!1}).decompress();for(var e=this.pixelBitlength/8,i=e*this.width,n=new Uint8Array(i*this.height),r=t.length,s=0,a=0,o=0,h=0,u=0,l=0,c=0,f=0,_=0,d=0,p=0,m=0,g=0,y=0,v=0,b=0,S=0,w=0,x=0;a>>8*(4-s)):r.push(n);else for(var a=0;a=8?-1!==["RATIONAL","SRATIONAL"].indexOf(e)?(r.push(this.getUint32(n+o)),r.push(this.getUint32(n+o+4))):it(8e3):r.push(this.getBytes(s,n+o))}return"ASCII"===e&&r.forEach((function(t,e,i){i[e]=String.fromCharCode(t)})),r},e.getBytes=function(t,e){if(t<=0)it(8001);else{if(t<=1)return this.getUint8(e);if(t<=2)return this.getUint16(e);if(t<=3)return this.getUint32(e)>>>8;if(t<=4)return this.getUint32(e);it(8002)}return 0},e.getBits=function(t,e,i){i=i||0;var n=e+Math.floor(i/8),r=i+t,s=32-t,a=0,o=0;return r<=0?it(6023):r<=8?(a=24+i,o=this.getUint8(n)):r<=16?(a=16+i,o=this.getUint16(n)):r<=32?(a=i,o=this.getUint32(n)):it(6022),{bits:o<>>s,byteOffset:n+Math.floor(r/8),bitOffset:r%8}},e.parseFileDirectory=function(t){var e=this.getUint16(t),i={},n=0,r=0;for(n=t+2,r=0;r=0&&R<=127?g=R+1:R>=-127&&R<=-1?y=1-R:A=!0}else{for(var F=this.getUint8(b+w),L=0;L0)for(var a=0;a>4,i=(15&r)<<4|(s=zvt[t.charCodeAt(h++)])>>2,n=(3&s)<<6|(a=zvt[t.charCodeAt(h++)]),o.push(String.fromCharCode(e)),64!==s&&o.push(String.fromCharCode(i)),64!==a&&o.push(String.fromCharCode(n));return o.join("")},decodeAsArray:function(t,e){var i,n,r,s=this.decode(t),a=[];for(i=0,r=s.length/e;i=0;--n)a[i]+=s.charCodeAt(i*e+n)<<8*n;return a}},Wvt=function(t){this.data=t,this.debug=!1,this.gpflags=void 0,this.files=0,this.unzipped=[],this.buf32k=new Array(32768),this.bIdx=0,this.modeZIP=!1,this.bytepos=0,this.bb=1,this.bits=0,this.nameBuf=[],this.fileout=void 0,this.literalTree=new Array(Wvt.LITERALS),this.distanceTree=new Array(32),this.treepos=0,this.Places=null,this.len=0,this.fpos=new Array(17),this.fpos[0]=0,this.flens=void 0,this.fmax=void 0};Wvt.gunzip=function(t){return t.constructor===Array||t.constructor,new Wvt(t).gunzip()[0][0]},Wvt.HufNode=function(){this.b0=0,this.b1=0,this.jump=null,this.jumppos=-1},Wvt.LITERALS=288,Wvt.NAMEMAX=256,Wvt.bitReverse=[0,128,64,192,32,160,96,224,16,144,80,208,48,176,112,240,8,136,72,200,40,168,104,232,24,152,88,216,56,184,120,248,4,132,68,196,36,164,100,228,20,148,84,212,52,180,116,244,12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252,2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242,10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250,6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246,14,142,78,206,46,174,110,238,30,158,94,222,62,190,126,254,1,129,65,193,33,161,97,225,17,145,81,209,49,177,113,241,9,137,73,201,41,169,105,233,25,153,89,217,57,185,121,249,5,133,69,197,37,165,101,229,21,149,85,213,53,181,117,245,13,141,77,205,45,173,109,237,29,157,93,221,61,189,125,253,3,131,67,195,35,163,99,227,19,147,83,211,51,179,115,243,11,139,75,203,43,171,107,235,27,155,91,219,59,187,123,251,7,135,71,199,39,167,103,231,23,151,87,215,55,183,119,247,15,143,79,207,47,175,111,239,31,159,95,223,63,191,127,255],Wvt.cplens=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],Wvt.cplext=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,99,99],Wvt.cpdist=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],Wvt.cpdext=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Wvt.border=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Wvt.prototype.gunzip=function(){return this.outputArr=[],this.nextFile(),this.unzipped},Wvt.prototype.readByte=function(){return this.bits+=8,this.bytepos>=1,0===this.bb&&(this.bb=this.readByte(),t=1&this.bb,this.bb=this.bb>>1|128),t},Wvt.prototype.readBits=function(t){for(var e=0,i=t;i--;)e=e<<1|this.readBit();return t&&(e=Wvt.bitReverse[e]>>8-t),e},Wvt.prototype.flushBuffer=function(){this.bIdx=0},Wvt.prototype.addBuffer=function(t){this.buf32k[this.bIdx++]=t,this.outputArr.push(String.fromCharCode(t)),32768===this.bIdx&&(this.bIdx=0)},Wvt.prototype.IsPat=function(){for(;;){if(this.fpos[this.len]>=this.fmax)return-1;if(this.flens[this.fpos[this.len]]===this.len)return this.fpos[this.len]++;this.fpos[this.len]++}},Wvt.prototype.Rec=function(){var t,e=this.Places[this.treepos];if(17===this.len)return-1;if(this.treepos++,this.len++,(t=this.IsPat())>=0)e.b0=t;else if(e.b0=32768,this.Rec())return-1;if((t=this.IsPat())>=0)e.b1=t,e.jump=null;else if(e.b1=32768,e.jump=this.Places[this.treepos],e.jumppos=this.treepos,this.Rec())return-1;return this.len--,0},Wvt.prototype.CreateTree=function(t,e,i){var n;for(this.Places=t,this.treepos=0,this.flens=i,this.fmax=e,n=0;n<17;n++)this.fpos[n]=0;return this.len=0,this.Rec()?-1:0},Wvt.prototype.DecodeValue=function(t){for(var e,i,n=0,r=t[n];;)if(this.readBit()){if(!(32768&r.b1))return r.b1;for(r=r.jump,e=t.length,i=0;i>1)>23?(a=a<<1|this.readBit())>199?a=(a-=128)<<1|this.readBit():(a-=48)>143&&(a+=136):a+=256,a<256)this.addBuffer(a);else{if(256===a)break;for(a-=257,d=this.readBits(Wvt.cplext[a])+Wvt.cplens[a],a=Wvt.bitReverse[this.readBits(5)]>>3,Wvt.cpdext[a]>8?(p=this.readBits(8),p|=this.readBits(Wvt.cpdext[a]-8)<<8):p=this.readBits(Wvt.cpdext[a]),p+=Wvt.cpdist[a],a=0;ao)return this.flushBuffer(),1;for(f=i?c[i-1]:0;a--;)c[i++]=f}else{if(i+(a=17===a?3+this.readBits(3):11+this.readBits(7))>o)return this.flushBuffer(),1;for(;a--;)c[i++]=0}for(d=this.literalTree.length,i=0;i=256){var d,p;if(0==(a-=256))break;for(a--,d=this.readBits(Wvt.cplext[a])+Wvt.cplens[a],a=this.DecodeValue(this.distanceTree),Wvt.cpdext[a]>8?(p=this.readBits(8),p|=this.readBits(Wvt.cpdext[a]-8)<<8):p=this.readBits(Wvt.cpdext[a]),p+=Wvt.cpdist[a];d--;)s=this.buf32k[this.bIdx-p&32767],this.addBuffer(s)}else this.addBuffer(a)}}while(!t);return this.flushBuffer(),this.byteAlign(),0},Wvt.prototype.unzipFile=function(t){var e;for(this.gunzip(),e=0;e=0;--n)a[i]+=s.charCodeAt(i*e+n)<<8*n;return a},Hbt.unzipAsArray=function(t,e){e=e||1;var i,n,r,s=this.unzip(t),a=[];for(i=0,r=s.length/e;i=0;--n)a[i]+=s.charCodeAt(i*e+n)<<8*n;return a};var jbt,qbt,Xbt,Ybt,Jbt,Kbt,Qbt,Zbt,$bt,tSt,eSt,iSt=parseInt,nSt=parseFloat,rSt=t("f0",(jvt=Kh("cc.ParticleSystem2D"),qvt=Ou(kvt),Xvt=Ou(nR),Yvt=Ou(yvt),Jvt=Ou(gvt),Kvt=lu("preview"),jvt((Gbt=function(t){function e(){var e;return(e=t.call(this)||this).duration=$vt&&$vt(),e.emissionRate=tbt&&tbt(),e.life=ebt&&ebt(),e.lifeVar=ibt&&ibt(),e.angle=nbt&&nbt(),e.angleVar=rbt&&rbt(),e.startSize=sbt&&sbt(),e.startSizeVar=abt&&abt(),e.endSize=obt&&obt(),e.endSizeVar=hbt&&hbt(),e.startSpin=ubt&&ubt(),e.startSpinVar=lbt&&lbt(),e.endSpin=cbt&&cbt(),e.endSpinVar=fbt&&fbt(),e.sourcePos=_bt&&_bt(),e.posVar=dbt&&dbt(),e.emitterMode=pbt&&pbt(),e.gravity=mbt&&mbt(),e.speed=gbt&&gbt(),e.speedVar=ybt&&ybt(),e.tangentialAccel=vbt&&vbt(),e.tangentialAccelVar=bbt&&bbt(),e.radialAccel=Sbt&&Sbt(),e.radialAccelVar=wbt&&wbt(),e.rotationIsDir=xbt&&xbt(),e.startRadius=Tbt&&Tbt(),e.startRadiusVar=Abt&&Abt(),e.endRadius=Cbt&&Cbt(),e.endRadiusVar=Dbt&&Dbt(),e.rotatePerS=Bbt&&Bbt(),e.rotatePerSVar=Ibt&&Ibt(),e.aspectRatio=1,e.playOnLoad=Mbt&&Mbt(),e.autoRemoveOnFinish=Pbt&&Pbt(),e._preview=Ebt&&Ebt(),e._custom=Obt&&Obt(),e._file=kbt&&kbt(),e._spriteFrame=Rbt&&Rbt(),e._totalParticles=Fbt&&Fbt(),e._startColor=Lbt&&Lbt(),e._startColorVar=Vbt&&Vbt(),e._endColor=Nbt&&Nbt(),e._endColorVar=zbt&&zbt(),e._positionType=Ubt&&Ubt(),e._stopped=!0,e._useFile=void 0,e.initProperties(),e._useFile=!1,e}s(e,t);var i=e.prototype;return i.onEnable=function(){t.prototype.onEnable.call(this),this._updateMaterial(),this._updatePositionType()},i.onDestroy=function(){t.prototype.onDestroy.call(this),this.autoRemoveOnFinish&&(this.autoRemoveOnFinish=!1),this._simulator.uvFilled=0,this.destroyRenderData()},i.initProperties=function(){this._previewTimer=null,this._focused=!1,this.aspectRatio=1,this._simulator=new Evt(this)},i.onFocusInEditor=function(){this._focused=!0;for(var t=Wbt(this.node),e=0;e=this.totalParticles},i._applyFile=function(){var t=this._file;if(t){if(!t)return void ht(6029);if(!this.isValid)return;this._plistFile=t.nativeUrl,this._custom||(this._spriteFrame!==t.spriteFrame&&(this.spriteFrame=t.spriteFrame),this._initWithDictionary(t._nativeAsset)),this._spriteFrame?!this._renderSpriteFrame&&this._spriteFrame&&this._applySpriteFrame():t.spriteFrame?this.spriteFrame=t.spriteFrame:this._custom&&this._initTextureWithDictionary(t._nativeAsset)}},i._initTextureWithDictionary=function(t){var e,i=this;if(t.spriteFrameUuid){var n=t.spriteFrameUuid;fT.loadAny(n,(function(e,n){e?(t.spriteFrameUuid=void 0,i._initTextureWithDictionary(t),J(e)):i.spriteFrame=n}))}else{var r=Yo(this._plistFile,t.textureFileName||"");if(t.textureFileName)fT.loadRemote(r,(function(e,n){e?(t.textureFileName=void 0,i._initTextureWithDictionary(t),J(e)):i.spriteFrame=n?nR.createWithImage(n):nR.createWithImage(mT.get("white-texture"))}));else if(t.textureImageData){var s=t.textureImageData;if(!(s&&s.length>0))return!1;var a=r;this.file&&(a+="-"+this.file.uuid);var o=fT.assets.get(a);if(!o){var h=Hbt.unzipBase64AsArray(s,1);if(!h)return at(6030,this._file.name),!1;var u=(e=h).length>8&&137===e[0]&&80===e[1]&&78===e[2]&&71===e[3]&&13===e[4]&&10===e[5]&&26===e[6]&&10===e[7]?1:e.length>2&&(73===e[0]&&73===e[1]||77===e[0]&&77===e[1]||255===e[0]&&216===e[1])?2:10;if(2!==u&&1!==u)return at(6031,this._file.name),!1;var l=B.document.createElement("canvas");1===u?new Rvt(h).render(l):(Nvt.parseTIFF(h,l),Nvt.reset()),o=new Hm(l),fT.assets.add(a,o)}o||at(6032,this._file.name),this.spriteFrame=o?nR.createWithImage(o):nR.createWithImage(mT.get("white-texture"))}}return!0},i._initWithDictionary=function(t){this._useFile=!0,this.totalParticles=iSt(t.maxParticles||0),this.life=nSt(t.particleLifespan||0),this.lifeVar=nSt(t.particleLifespanVariance||0);var e=t.emissionRate;this.emissionRate=e||Math.min(this.totalParticles/this.life,Number.MAX_VALUE),this.duration=nSt(t.duration||0),this._srcBlendFactor=iSt(t.blendFuncSource||2),this._dstBlendFactor=iSt(t.blendFuncDestination||4);var i=this._startColor;i.r=255*nSt(t.startColorRed||0),i.g=255*nSt(t.startColorGreen||0),i.b=255*nSt(t.startColorBlue||0),i.a=255*nSt(t.startColorAlpha||0);var n=this._startColorVar;n.r=255*nSt(t.startColorVarianceRed||0),n.g=255*nSt(t.startColorVarianceGreen||0),n.b=255*nSt(t.startColorVarianceBlue||0),n.a=255*nSt(t.startColorVarianceAlpha||0);var r=this._endColor;r.r=255*nSt(t.finishColorRed||0),r.g=255*nSt(t.finishColorGreen||0),r.b=255*nSt(t.finishColorBlue||0),r.a=255*nSt(t.finishColorAlpha||0);var s=this._endColorVar;if(s.r=255*nSt(t.finishColorVarianceRed||0),s.g=255*nSt(t.finishColorVarianceGreen||0),s.b=255*nSt(t.finishColorVarianceBlue||0),s.a=255*nSt(t.finishColorVarianceAlpha||0),this.startSize=nSt(t.startParticleSize||0),this.startSizeVar=nSt(t.startParticleSizeVariance||0),this.endSize=nSt(t.finishParticleSize||0),this.endSizeVar=nSt(t.finishParticleSizeVariance||0),this.positionType=nSt(void 0!==t.positionType?t.positionType:yvt.FREE),this.sourcePos.set(0,0),this.posVar.set(nSt(t.sourcePositionVariancex||0),nSt(t.sourcePositionVariancey||0)),this.angle=nSt(t.angle||0),this.angleVar=nSt(t.angleVariance||0),this.startSpin=nSt(t.rotationStart||0),this.startSpinVar=nSt(t.rotationStartVariance||0),this.endSpin=nSt(t.rotationEnd||0),this.endSpinVar=nSt(t.rotationEndVariance||0),this.emitterMode=iSt(t.emitterType||gvt.GRAVITY),this.emitterMode===gvt.GRAVITY){this.gravity.set(nSt(t.gravityx||0),nSt(t.gravityy||0)),this.speed=nSt(t.speed||0),this.speedVar=nSt(t.speedVariance||0),this.radialAccel=nSt(t.radialAcceleration||0),this.radialAccelVar=nSt(t.radialAccelVariance||0),this.tangentialAccel=nSt(t.tangentialAcceleration||0),this.tangentialAccelVar=nSt(t.tangentialAccelVariance||0);var a=t.rotationIsDir||"";null!==a?(a=a.toString().toLowerCase(),this.rotationIsDir="true"===a||"1"===a):this.rotationIsDir=!1}else{if(this.emitterMode!==gvt.RADIUS)return at(6009),!1;this.startRadius=nSt(t.maxRadius||0),this.startRadiusVar=nSt(t.maxRadiusVariance||0),this.endRadius=nSt(t.minRadius||0),this.endRadiusVar=nSt(t.minRadiusVariance||0),this.rotatePerS=nSt(t.rotatePerSecond||0),this.rotatePerSVar=nSt(t.rotatePerSecondVariance||0)}return this._initTextureWithDictionary(t),!0},i._syncAspect=function(){if(this._renderSpriteFrame){var t=this._renderSpriteFrame.rect;this.aspectRatio=t.width/t.height}},i._applySpriteFrame=function(){this._renderSpriteFrame=this._renderSpriteFrame||this._spriteFrame,this._renderSpriteFrame?this._renderSpriteFrame.texture&&(this._simulator&&this._simulator.updateUVs(!0),this._syncAspect(),this._updateMaterial(),this._stopped=!1,this._markForUpdateRenderData()):this.resetSystem()},i._getTexture=function(){return this._renderSpriteFrame&&this._renderSpriteFrame.texture},i._updateMaterial=function(){if(this._customMaterial){this.setSharedMaterial(this._customMaterial,0);var t=this.getRenderMaterial(0).passes[0].blendState.targets[0];this._dstBlendFactor=t.blendDst,this._srcBlendFactor=t.blendSrc}var e=this.getMaterialInstance(0);e&&e.recompileShaders({USE_LOCAL:this._positionType!==yvt.FREE}),e&&e.passes.length>0&&this._updateBlendFunc()},i._finishedSimulation=function(){this.resetSystem(),this.stopSystem(),this._markForUpdateRenderData(),this.autoRemoveOnFinish&&this._stopped&&this.node.destroy()},i._canRender=function(){return t.prototype._canRender.call(this)&&!this._stopped&&null!==this._renderSpriteFrame&&void 0!==this._renderSpriteFrame},i._render=function(t){this._positionType===yvt.RELATIVE?t.commitComp(this,this._simulator.renderData,this._renderSpriteFrame,this._assembler,this.node.parent):this.positionType===yvt.GROUPED?t.commitComp(this,this._simulator.renderData,this._renderSpriteFrame,this._assembler,this.node):t.commitComp(this,this._simulator.renderData,this._renderSpriteFrame,this._assembler,null)},i._updatePositionType=function(){this._positionType===yvt.RELATIVE?(this._renderEntity.setRenderTransform(this.node.parent),this._renderEntity.setUseLocal(!0)):this.positionType===yvt.GROUPED?(this._renderEntity.setRenderTransform(this.node),this._renderEntity.setUseLocal(!0)):(this._renderEntity.setRenderTransform(null),this._renderEntity.setUseLocal(!1))},n(e,[{key:"custom",get:function(){return this._custom},set:function(t){this._custom!==t&&(this._custom=t,this._applyFile(),this._updateMaterial())}},{key:"file",get:function(){return this._file},set:function(t){this._file!==t&&(this._file=t,t?this._applyFile():this.custom=!0)}},{key:"spriteFrame",get:function(){return this._spriteFrame},set:function(t){this._renderSpriteFrame!==t&&(this._renderSpriteFrame=t,t&&!t._uuid||(this._spriteFrame=t),this._applySpriteFrame())}},{key:"particleCount",get:function(){return this._simulator.particles.length}},{key:"totalParticles",get:function(){return this._totalParticles},set:function(t){this._totalParticles!==t&&(this._totalParticles=t)}},{key:"startColor",get:function(){return this._startColor},set:function(t){this._startColor.r=t.r,this._startColor.g=t.g,this._startColor.b=t.b,this._startColor.a=t.a}},{key:"startColorVar",get:function(){return this._startColorVar},set:function(t){this._startColorVar.r=t.r,this._startColorVar.g=t.g,this._startColorVar.b=t.b,this._startColorVar.a=t.a}},{key:"color",get:function(){return this._color},set:function(){}},{key:"endColor",get:function(){return this._endColor},set:function(t){this._endColor.r=t.r,this._endColor.g=t.g,this._endColor.b=t.b,this._endColor.a=t.a}},{key:"endColorVar",get:function(){return this._endColorVar},set:function(t){this._endColorVar.r=t.r,this._endColorVar.g=t.g,this._endColorVar.b=t.b,this._endColorVar.a=t.a}},{key:"positionType",get:function(){return this._positionType},set:function(t){this._positionType=t,this._updateMaterial(),this._updatePositionType()}},{key:"preview",get:function(){return this._preview},set:function(t){t?this._startPreview():this._stopPreview(),this._preview=t}},{key:"stopped",get:function(){return this._stopped}},{key:"active",get:function(){return this._simulator.active}},{key:"assembler",get:function(){return this._assembler}}]),e}(BL),Gbt.EmitterMode=gvt,Gbt.PositionType=yvt,Gbt.DURATION_INFINITY=-1,Gbt.START_SIZE_EQUAL_TO_END_SIZE=-1,Gbt.START_RADIUS_EQUAL_TO_END_RADIUS=-1,v((Zvt=Gbt).prototype,"file",[qvt],Object.getOwnPropertyDescriptor(Zvt.prototype,"file"),Zvt.prototype),v(Zvt.prototype,"spriteFrame",[Xvt],Object.getOwnPropertyDescriptor(Zvt.prototype,"spriteFrame"),Zvt.prototype),$vt=zh(Zvt.prototype,"duration",[uu],(function(){return-1})),tbt=zh(Zvt.prototype,"emissionRate",[uu],(function(){return 10})),ebt=zh(Zvt.prototype,"life",[uu],(function(){return 1})),ibt=zh(Zvt.prototype,"lifeVar",[uu],(function(){return 0})),v(Zvt.prototype,"color",[Gu],Object.getOwnPropertyDescriptor(Zvt.prototype,"color"),Zvt.prototype),nbt=zh(Zvt.prototype,"angle",[uu],(function(){return 90})),rbt=zh(Zvt.prototype,"angleVar",[uu],(function(){return 20})),sbt=zh(Zvt.prototype,"startSize",[uu],(function(){return 50})),abt=zh(Zvt.prototype,"startSizeVar",[uu],(function(){return 0})),obt=zh(Zvt.prototype,"endSize",[uu],(function(){return 0})),hbt=zh(Zvt.prototype,"endSizeVar",[uu],(function(){return 0})),ubt=zh(Zvt.prototype,"startSpin",[uu],(function(){return 0})),lbt=zh(Zvt.prototype,"startSpinVar",[uu],(function(){return 0})),cbt=zh(Zvt.prototype,"endSpin",[uu],(function(){return 0})),fbt=zh(Zvt.prototype,"endSpinVar",[uu],(function(){return 0})),_bt=zh(Zvt.prototype,"sourcePos",[uu],(function(){return ds.ZERO.clone()})),dbt=zh(Zvt.prototype,"posVar",[uu],(function(){return ds.ZERO.clone()})),v(Zvt.prototype,"positionType",[Yvt],Object.getOwnPropertyDescriptor(Zvt.prototype,"positionType"),Zvt.prototype),pbt=zh(Zvt.prototype,"emitterMode",[uu,Jvt],(function(){return gvt.GRAVITY})),mbt=zh(Zvt.prototype,"gravity",[uu],(function(){return ds.ZERO.clone()})),gbt=zh(Zvt.prototype,"speed",[uu],(function(){return 180})),ybt=zh(Zvt.prototype,"speedVar",[uu],(function(){return 50})),vbt=zh(Zvt.prototype,"tangentialAccel",[uu],(function(){return 80})),bbt=zh(Zvt.prototype,"tangentialAccelVar",[uu],(function(){return 0})),Sbt=zh(Zvt.prototype,"radialAccel",[uu],(function(){return 0})),wbt=zh(Zvt.prototype,"radialAccelVar",[uu],(function(){return 0})),xbt=zh(Zvt.prototype,"rotationIsDir",[uu],(function(){return!1})),Tbt=zh(Zvt.prototype,"startRadius",[uu],(function(){return 0})),Abt=zh(Zvt.prototype,"startRadiusVar",[uu],(function(){return 0})),Cbt=zh(Zvt.prototype,"endRadius",[uu],(function(){return 0})),Dbt=zh(Zvt.prototype,"endRadiusVar",[uu],(function(){return 0})),Bbt=zh(Zvt.prototype,"rotatePerS",[uu],(function(){return 0})),Ibt=zh(Zvt.prototype,"rotatePerSVar",[uu],(function(){return 0})),Mbt=zh(Zvt.prototype,"playOnLoad",[uu],(function(){return!0})),Pbt=zh(Zvt.prototype,"autoRemoveOnFinish",[uu],(function(){return!1})),Ebt=zh(Zvt.prototype,"_preview",[Kvt],(function(){return!0})),Obt=zh(Zvt.prototype,"_custom",[uu],(function(){return!1})),kbt=zh(Zvt.prototype,"_file",[uu],(function(){return null})),Rbt=zh(Zvt.prototype,"_spriteFrame",[uu],(function(){return null})),Fbt=zh(Zvt.prototype,"_totalParticles",[uu],(function(){return 150})),Lbt=zh(Zvt.prototype,"_startColor",[uu],(function(){return new cr(255,255,255,255)})),Vbt=zh(Zvt.prototype,"_startColorVar",[uu],(function(){return new cr(0,0,0,0)})),Nbt=zh(Zvt.prototype,"_endColor",[uu],(function(){return new cr(255,255,255,0)})),zbt=zh(Zvt.prototype,"_endColorVar",[uu],(function(){return new cr(0,0,0,0)})),Ubt=zh(Zvt.prototype,"_positionType",[uu],(function(){return yvt.FREE})),Qvt=Zvt))||Qvt)),sSt=function(){function t(t,e){this.point=new ds,this.dir=new ds,this.distance=0,this.time=0,t&&this.point.set(t),e&&this.dir.set(e)}var e=t.prototype;return e.setPoint=function(t,e){this.point.x=t,this.point.y=e},e.setDir=function(t,e){this.dir.x=t,this.dir.y=e},t}(),aSt=t("f1",(jbt=Kh("cc.MotionStreak"),qbt=Ou(Ey),jbt((eSt=function(t){function e(){var e;return(e=t.call(this)||this)._preview=Jbt&&Jbt(),e._fadeTime=Kbt&&Kbt(),e._minSeg=Qbt&&Qbt(),e._stroke=Zbt&&Zbt(),e._texture=$bt&&$bt(),e._fastMode=tSt&&tSt(),e._points=[],e}s(e,t);var i=e.prototype;return i.onEnable=function(){t.prototype.onEnable.call(this),this.reset()},i._flushAssembler=function(){var t=e.Assembler.getAssembler(this);this._assembler!==t&&(this._assembler=t),this._renderData||this._assembler&&this._assembler.createData&&(this._renderData=this._assembler.createData(this),this._renderData.material=this.material,this._updateColor())},i.onFocusInEditor=function(){this._preview&&this.reset()},i.onLostFocusInEditor=function(){this._preview&&this.reset()},i.reset=function(){this._points.length=0,this._renderData&&this._renderData.clear()},i.lateUpdate=function(t){this._assembler&&this._assembler.update&&this._assembler.update(this,t)},i._render=function(t){t.commitComp(this,this._renderData,this._texture,this._assembler,null)},n(e,[{key:"preview",get:function(){return this._preview},set:function(t){this._preview=t,this.reset()}},{key:"fadeTime",get:function(){return this._fadeTime},set:function(t){this._fadeTime=t,this.reset()}},{key:"minSeg",get:function(){return this._minSeg},set:function(t){this._minSeg=t}},{key:"stroke",get:function(){return this._stroke},set:function(t){this._stroke=t}},{key:"texture",get:function(){return this._texture},set:function(t){this._texture!==t&&(this._texture=t)}},{key:"fastMode",get:function(){return this._fastMode},set:function(t){this._fastMode=t}},{key:"points",get:function(){return this._points}}]),e}(BL),eSt.Point=sSt,v((Ybt=eSt).prototype,"texture",[qbt],Object.getOwnPropertyDescriptor(Ybt.prototype,"texture"),Ybt.prototype),Jbt=zh(Ybt.prototype,"_preview",[uu],(function(){return!1})),Kbt=zh(Ybt.prototype,"_fadeTime",[uu],(function(){return 1})),Qbt=zh(Ybt.prototype,"_minSeg",[uu],(function(){return 1})),Zbt=zh(Ybt.prototype,"_stroke",[uu],(function(){return 64})),$bt=zh(Ybt.prototype,"_texture",[uu],(function(){return null})),tSt=zh(Ybt.prototype,"_fastMode",[uu],(function(){return!1})),Xbt=Ybt))||Xbt)),oSt=new ds,hSt=new ds,uSt=null;function lSt(t,e){return t.x=-e.y,t.y=e.x,t}var cSt=function(){function t(){}var e=t.prototype;return e.createData=function(t){var e=t.requestRenderData();return e.dataLength=4,e.resize(16,42),e},e.update=function(t,e){var i,n=t.stroke/2,r=t.node.worldMatrix,s=r.m12,a=r.m13,o=t.points;if(o.length>1){var h=o[0],u=h.point.x-s,l=h.point.y-a;u*u+l*l=0;x--){var T=o[x],A=T.point,C=T.dir;if(T.time-=e,T.time<0)o.splice(x,1);else{var D=T.time/S,B=o[x-1];if(!w){if(!B){o.splice(x,1);continue}A.x=B.point.x-C.x*D,A.y=B.point.y-C.y*D}w=!0,lSt(oSt,C);var I=D*y,M=f;b[M].x=A.x+oSt.x*n,b[M].y=A.y+oSt.y*n,b[M].u=1,b[M].v=D,b[M].color.set(p,m,g,I),b[M+=1].x=A.x-oSt.x*n,b[M].y=A.y-oSt.y*n,b[M].u=0,b[M].v=D,b[M].color.set(p,m,g,I),f+=2}}c=f<=2?0:3*(f-2),_.resize(f,c)}},e.updateWorldVertexAllData=function(t){for(var e=t.renderData,i=e.floatStride,n=e.data,r=e.chunk.vb,s=0;se?t:e}function k(t,e,i){return ti?i:t}var R=isFinite;function F(t){return t*t}function L(t){return 1/Math.sqrt(t)}var V=Math.sqrt,N=Math.pow;var z=Math.cos,U=Math.sin,G=Math.acos,H=Math.asin,W=Math.atan2;var j=function(){function t(){for(var t=arguments.length,e=new Array(t),i=0;i=r){var e=1/t;this.x*=e,this.y*=e}return t},e.SelfNormalize=function(){var t=this.Length();if(t>=r){var e=1/t;this.x*=e,this.y*=e}return this},e.SelfRotate=function(t){var e=Math.cos(t),i=Math.sin(t),n=this.x;return this.x=e*n-i*this.y,this.y=i*n+e*this.y,this},e.SelfRotateCosSin=function(t,e){var i=this.x;return this.x=t*i-e*this.y,this.y=e*i+t*this.y,this},e.IsValid=function(){return isFinite(this.x)&&isFinite(this.y)},e.SelfCrossVS=function(t){var e=this.x;return this.x=t*this.y,this.y=-t*e,this},e.SelfCrossSV=function(t){var e=this.x;return this.x=-t*this.y,this.y=t*e,this},e.SelfMinV=function(t){return this.x=E(this.x,t.x),this.y=E(this.y,t.y),this},e.SelfMaxV=function(t){return this.x=O(this.x,t.x),this.y=O(this.y,t.y),this},e.SelfAbs=function(){return this.x=P(this.x),this.y=P(this.y),this},e.SelfNeg=function(){return this.x=-this.x,this.y=-this.y,this},e.SelfSkew=function(){var t=this.x;return this.x=-this.y,this.y=t,this},t.MakeArray=function(e){return C(e,(function(){return new t}))},t.AbsV=function(t,e){return e.x=P(t.x),e.y=P(t.y),e},t.MinV=function(t,e,i){return i.x=E(t.x,e.x),i.y=E(t.y,e.y),i},t.MaxV=function(t,e,i){return i.x=O(t.x,e.x),i.y=O(t.y,e.y),i},t.ClampV=function(t,e,i,n){return n.x=k(t.x,e.x,i.x),n.y=k(t.y,e.y,i.y),n},t.RotateV=function(t,e,i){var n=t.x,r=t.y,s=Math.cos(e),a=Math.sin(e);return i.x=s*n-a*r,i.y=a*n+s*r,i},t.DotVV=function(t,e){return t.x*e.x+t.y*e.y},t.CrossVV=function(t,e){return t.x*e.y-t.y*e.x},t.CrossVS=function(t,e,i){var n=t.x;return i.x=e*t.y,i.y=-e*n,i},t.CrossVOne=function(t,e){var i=t.x;return e.x=t.y,e.y=-i,e},t.CrossSV=function(t,e,i){var n=e.x;return i.x=-t*e.y,i.y=t*n,i},t.CrossOneV=function(t,e){var i=t.x;return e.x=-t.y,e.y=i,e},t.AddVV=function(t,e,i){return i.x=t.x+e.x,i.y=t.y+e.y,i},t.SubVV=function(t,e,i){return i.x=t.x-e.x,i.y=t.y-e.y,i},t.MulSV=function(t,e,i){return i.x=e.x*t,i.y=e.y*t,i},t.MulVS=function(t,e,i){return i.x=t.x*e,i.y=t.y*e,i},t.AddVMulSV=function(t,e,i,n){return n.x=t.x+e*i.x,n.y=t.y+e*i.y,n},t.SubVMulSV=function(t,e,i,n){return n.x=t.x-e*i.x,n.y=t.y-e*i.y,n},t.AddVCrossSV=function(t,e,i,n){var r=i.x;return n.x=t.x-e*i.y,n.y=t.y+e*r,n},t.MidVV=function(t,e,i){return i.x=.5*(t.x+e.x),i.y=.5*(t.y+e.y),i},t.ExtVV=function(t,e,i){return i.x=.5*(e.x-t.x),i.y=.5*(e.y-t.y),i},t.IsEqualToV=function(t,e){return t.x===e.x&&t.y===e.y},t.DistanceVV=function(t,e){var i=t.x-e.x,n=t.y-e.y;return Math.sqrt(i*i+n*n)},t.DistanceSquaredVV=function(t,e){var i=t.x-e.x,n=t.y-e.y;return i*i+n*n},t.NegV=function(t,e){return e.x=-t.x,e.y=-t.y,e},n(t,[{key:"x",get:function(){return this.data[0]},set:function(t){this.data[0]=t}},{key:"y",get:function(){return this.data[1]},set:function(t){this.data[1]=t}}]),t}();j.ZERO=new j(0,0),j.UNITX=new j(1,0),j.UNITY=new j(0,1),j.s_t0=new j,j.s_t1=new j,j.s_t2=new j,j.s_t3=new j;var q=new j(0,0),X=function(){function t(){for(var t=arguments.length,e=new Array(t),i=0;ithis.m_count&&(this.m_min_count=this.m_count)},t}(),rt=function(){function t(t){this.m_stack=[],this.m_count=0,this.m_stack=C(t,(function(){return null})),this.m_count=0}var e=t.prototype;return e.Reset=function(){return this.m_count=0,this},e.Push=function(t){this.m_stack[this.m_count]=t,this.m_count++},e.Pop=function(){this.m_count--;var t=this.m_stack[this.m_count];if(this.m_stack[this.m_count]=null,null===t)throw new Error;return t},e.GetCount=function(){return this.m_count},t}(),st=function(){function t(){this.m_buffer=j.MakeArray(2),this.m_vertices=this.m_buffer,this.m_count=0,this.m_radius=0}var e=t.prototype;return e.Copy=function(t){return t.m_vertices===t.m_buffer?(this.m_vertices=this.m_buffer,this.m_buffer[0].Copy(t.m_buffer[0]),this.m_buffer[1].Copy(t.m_buffer[1])):this.m_vertices=t.m_vertices,this.m_count=t.m_count,this.m_radius=t.m_radius,this},e.Reset=function(){return this.m_vertices=this.m_buffer,this.m_count=0,this.m_radius=0,this},e.SetShape=function(t,e){t.SetupDistanceProxy(this,e)},e.SetVerticesRadius=function(t,e,i){this.m_vertices=t,this.m_count=e,this.m_radius=i},e.GetSupport=function(t){for(var e=0,i=j.DotVV(this.m_vertices[0],t),n=1;ni&&(e=n,i=r)}return e},e.GetSupportVertex=function(t){for(var e=0,i=j.DotVV(this.m_vertices[0],t),n=1;ni&&(e=n,i=r)}return this.m_vertices[e]},e.GetVertexCount=function(){return this.m_count},e.GetVertex=function(t){return this.m_vertices[t]},t}(),at=function(){function t(){this.metric=0,this.count=0,this.indexA=[0,0,0],this.indexB=[0,0,0]}return t.prototype.Reset=function(){return this.metric=0,this.count=0,this},t}(),ot=function(){function t(){this.proxyA=new st,this.proxyB=new st,this.transformA=new Q,this.transformB=new Q,this.useRadii=!1}return t.prototype.Reset=function(){return this.proxyA.Reset(),this.proxyB.Reset(),this.transformA.SetIdentity(),this.transformB.SetIdentity(),this.useRadii=!1,this},t}(),ht=function(){function t(){this.pointA=new j,this.pointB=new j,this.distance=0,this.iterations=0}return t.prototype.Reset=function(){return this.pointA.SetZero(),this.pointB.SetZero(),this.distance=0,this.iterations=0,this},t}();t.b2_gjkCalls=0,t.b2_gjkIters=0,t.b2_gjkMaxIters=0;var ut=function(){function t(){this.wA=new j,this.wB=new j,this.w=new j,this.a=0,this.indexA=0,this.indexB=0}return t.prototype.Copy=function(t){return this.wA.Copy(t.wA),this.wB.Copy(t.wB),this.w.Copy(t.w),this.a=t.a,this.indexA=t.indexA,this.indexB=t.indexB,this},t}(),lt=function(){function t(){this.m_v1=new ut,this.m_v2=new ut,this.m_v3=new ut,this.m_vertices=[],this.m_count=0,this.m_vertices[0]=this.m_v1,this.m_vertices[1]=this.m_v2,this.m_vertices[2]=this.m_v3}var e=t.prototype;return e.ReadCache=function(t,e,i,n,s){this.m_count=t.count;for(var a=this.m_vertices,o=0;o1){var c=t.metric,f=this.GetMetric();(f<.5*c||2*c0?j.CrossOneV(e,t):j.CrossVOne(e,t);default:return t.SetZero()}},e.GetClosestPoint=function(t){switch(this.m_count){case 0:case 3:default:return t.SetZero();case 1:return t.Copy(this.m_v1.w);case 2:return t.Set(this.m_v1.a*this.m_v1.w.x+this.m_v2.a*this.m_v2.w.x,this.m_v1.a*this.m_v1.w.y+this.m_v2.a*this.m_v2.w.y)}},e.GetWitnessPoints=function(t,e){switch(this.m_count){case 0:break;case 1:t.Copy(this.m_v1.wA),e.Copy(this.m_v1.wB);break;case 2:t.x=this.m_v1.a*this.m_v1.wA.x+this.m_v2.a*this.m_v2.wA.x,t.y=this.m_v1.a*this.m_v1.wA.y+this.m_v2.a*this.m_v2.wA.y,e.x=this.m_v1.a*this.m_v1.wB.x+this.m_v2.a*this.m_v2.wB.x,e.y=this.m_v1.a*this.m_v1.wB.y+this.m_v2.a*this.m_v2.wB.y;break;case 3:e.x=t.x=this.m_v1.a*this.m_v1.wA.x+this.m_v2.a*this.m_v2.wA.x+this.m_v3.a*this.m_v3.wA.x,e.y=t.y=this.m_v1.a*this.m_v1.wA.y+this.m_v2.a*this.m_v2.wA.y+this.m_v3.a*this.m_v3.wA.y}},e.GetMetric=function(){switch(this.m_count){case 0:case 1:default:return 0;case 2:return j.DistanceVV(this.m_v1.w,this.m_v2.w);case 3:return j.CrossVV(j.SubVV(this.m_v2.w,this.m_v1.w,j.s_t0),j.SubVV(this.m_v3.w,this.m_v1.w,j.s_t1))}},e.Solve2=function(){var e=this.m_v1.w,i=this.m_v2.w,n=j.SubVV(i,e,t.s_e12),r=-j.DotVV(e,n);if(r<=0)return this.m_v1.a=1,void(this.m_count=1);var s=j.DotVV(i,n);if(s<=0)return this.m_v2.a=1,this.m_count=1,void this.m_v1.Copy(this.m_v2);var a=1/(s+r);this.m_v1.a=s*a,this.m_v2.a=r*a,this.m_count=2},e.Solve3=function(){var e=this.m_v1.w,i=this.m_v2.w,n=this.m_v3.w,r=j.SubVV(i,e,t.s_e12),s=j.DotVV(e,r),a=j.DotVV(i,r),o=-s,h=j.SubVV(n,e,t.s_e13),u=j.DotVV(e,h),l=j.DotVV(n,h),c=-u,f=j.SubVV(n,i,t.s_e23),_=j.DotVV(i,f),d=j.DotVV(n,f),p=-_,m=j.CrossVV(r,h),g=m*j.CrossVV(i,n),y=m*j.CrossVV(n,e),v=m*j.CrossVV(e,i);if(o<=0&&c<=0)return this.m_v1.a=1,void(this.m_count=1);if(a>0&&o>0&&v<=0){var b=1/(a+o);return this.m_v1.a=a*b,this.m_v2.a=o*b,void(this.m_count=2)}if(l>0&&c>0&&y<=0){var S=1/(l+c);return this.m_v1.a=l*S,this.m_v3.a=c*S,this.m_count=2,void this.m_v2.Copy(this.m_v3)}if(a<=0&&p<=0)return this.m_v2.a=1,this.m_count=1,void this.m_v1.Copy(this.m_v2);if(l<=0&&d<=0)return this.m_v3.a=1,this.m_count=1,void this.m_v1.Copy(this.m_v3);if(d>0&&p>0&&g<=0){var w=1/(d+p);return this.m_v2.a=d*w,this.m_v3.a=p*w,this.m_count=2,void this.m_v1.Copy(this.m_v3)}var x=1/(g+y+v);this.m_v1.a=g*x,this.m_v2.a=y*x,this.m_v3.a=v*x,this.m_count=3},t}();lt.s_e12=new j,lt.s_e13=new j,lt.s_e23=new j;var ct=new lt,ft=[0,0,0],_t=[0,0,0],dt=new j,pt=new j,mt=new j,gt=new j,yt=new j;function vt(e,i,n){++t.b2_gjkCalls;var s=n.proxyA,o=n.proxyB,h=n.transformA,u=n.transformB,l=ct;l.ReadCache(i,s,h,o,u);for(var c=l.m_vertices,f=ft,_=_t,d=0,p=0;p<20;){d=l.m_count;for(var m=0;mS+w&&e.distance>r){e.distance-=S+w;var x=j.SubVV(e.pointB,e.pointA,mt);x.Normalize(),e.pointA.SelfMulAdd(S,x),e.pointB.SelfMulSub(w,x)}else{var T=j.MidVV(e.pointA,e.pointB,dt);e.pointA.Copy(T),e.pointB.Copy(T),e.distance=0}}}var bt,St=new j,wt=new lt,xt=new j,Tt=new j,At=new j,Ct=new j,Dt=new j,Bt=new j;(bt=t.b2ContactFeatureType||(t.b2ContactFeatureType={}))[bt.e_vertex=0]="e_vertex",bt[bt.e_face=1]="e_face";var It,Mt=function(){function t(){this._key=0,this._key_invalid=!1,this._indexA=0,this._indexB=0,this._typeA=0,this._typeB=0}return n(t,[{key:"key",get:function(){return this._key_invalid&&(this._key_invalid=!1,this._key=this._indexA|this._indexB<<8|this._typeA<<16|this._typeB<<24),this._key},set:function(t){this._key=t,this._key_invalid=!1,this._indexA=255&this._key,this._indexB=this._key>>8&255,this._typeA=this._key>>16&255,this._typeB=this._key>>24&255}},{key:"indexA",get:function(){return this._indexA},set:function(t){this._indexA=t,this._key_invalid=!0}},{key:"indexB",get:function(){return this._indexB},set:function(t){this._indexB=t,this._key_invalid=!0}},{key:"typeA",get:function(){return this._typeA},set:function(t){this._typeA=t,this._key_invalid=!0}},{key:"typeB",get:function(){return this._typeB},set:function(t){this._typeB=t,this._key_invalid=!0}}]),t}(),Pt=function(){function t(){this.cf=new Mt}var e=t.prototype;return e.Copy=function(t){return this.key=t.key,this},e.Clone=function(){return(new t).Copy(this)},n(t,[{key:"key",get:function(){return this.cf.key},set:function(t){this.cf.key=t}}]),t}(),Et=function(){function t(){this.localPoint=new j,this.normalImpulse=0,this.tangentImpulse=0,this.id=new Pt}t.MakeArray=function(e){return C(e,(function(){return new t}))};var e=t.prototype;return e.Reset=function(){this.localPoint.SetZero(),this.normalImpulse=0,this.tangentImpulse=0,this.id.key=0},e.Copy=function(t){return this.localPoint.Copy(t.localPoint),this.normalImpulse=t.normalImpulse,this.tangentImpulse=t.tangentImpulse,this.id.Copy(t.id),this},t}();(It=t.b2ManifoldType||(t.b2ManifoldType={}))[It.e_unknown=-1]="e_unknown",It[It.e_circles=0]="e_circles",It[It.e_faceA=1]="e_faceA",It[It.e_faceB=2]="e_faceB";var Ot,kt=function(){function e(){this.points=Et.MakeArray(2),this.localNormal=new j,this.localPoint=new j,this.type=t.b2ManifoldType.e_unknown,this.pointCount=0}var i=e.prototype;return i.Reset=function(){for(var e=0;e<2;++e)this.points[e].Reset();this.localNormal.SetZero(),this.localPoint.SetZero(),this.type=t.b2ManifoldType.e_unknown,this.pointCount=0},i.Copy=function(t){this.pointCount=t.pointCount;for(var e=0;e<2;++e)this.points[e].Copy(t.points[e]);return this.localNormal.Copy(t.localNormal),this.localPoint.Copy(t.localPoint),this.type=t.type,this},i.Clone=function(){return(new e).Copy(this)},e}(),Rt=function(){function e(){this.normal=new j,this.points=j.MakeArray(2),this.separations=D(2)}return e.prototype.Initialize=function(i,n,r,s,o){if(0!==i.pointCount)switch(i.type){case t.b2ManifoldType.e_circles:this.normal.Set(1,0);var h=Q.MulXV(n,i.localPoint,e.Initialize_s_pointA),u=Q.MulXV(s,i.points[0].localPoint,e.Initialize_s_pointB);j.DistanceSquaredVV(h,u)>a&&j.SubVV(u,h,this.normal).SelfNormalize();var l=j.AddVMulSV(h,r,this.normal,e.Initialize_s_cA),c=j.SubVMulSV(u,o,this.normal,e.Initialize_s_cB);j.MidVV(l,c,this.points[0]),this.separations[0]=j.DotVV(j.SubVV(c,l,j.s_t0),this.normal);break;case t.b2ManifoldType.e_faceA:K.MulRV(n.q,i.localNormal,this.normal);for(var f=Q.MulXV(n,i.localPoint,e.Initialize_s_planePoint),_=0;_p){var g=d;d=p,p=g,m=1}if(d>n&&(f.x=m,f.y=0,n=d),n>(s=E(s,p)))return!1}if(cb){var w=v;v=b,b=w,S=1}if(v>n&&(f.x=0,f.y=S,n=v),n>(s=E(s,b)))return!1}return!(n<0||e.maxFraction0;){var n=i.Pop();if(null!==n&&n.aabb.TestOverlap(t))if(n.IsLeaf()){if(!e(n))return}else i.Push(n.child1),i.Push(n.child2)}},e.QueryPoint=function(t,e){var i=this.m_stack.Reset();for(i.Push(this.m_root);i.GetCount()>0;){var n=i.Pop();if(null!==n&&n.aabb.TestContain(t))if(n.IsLeaf()){if(!e(n))return}else i.Push(n.child1),i.Push(n.child2)}},e.RayCast=function(e,i){var n=e.p1,r=e.p2,s=j.SubVV(r,n,t.s_r);s.Normalize();var a=j.CrossOneV(s,t.s_v),o=j.AbsV(a,t.s_abs_v),h=e.maxFraction,u=t.s_segmentAABB,l=n.x+h*(r.x-n.x),c=n.y+h*(r.y-n.y);u.lowerBound.x=E(n.x,l),u.lowerBound.y=E(n.y,c),u.upperBound.x=O(n.x,l),u.upperBound.y=O(n.y,c);var f=this.m_stack.Reset();for(f.Push(this.m_root);f.GetCount()>0;){var _=f.Pop();if(null!==_&&zt(_.aabb,u)){var d=_.aabb.GetCenter(),p=_.aabb.GetExtents();if(!(P(j.DotVV(a,j.SubVV(n,d,j.s_t0)))-j.DotVV(o,p)>0))if(_.IsLeaf()){var m=t.s_subInput;m.p1.Copy(e.p1),m.p2.Copy(e.p2),m.maxFraction=h;var g=i(m,_);if(0===g)return;g>0&&(h=g,l=n.x+h*(r.x-n.x),c=n.y+h*(r.y-n.y),u.lowerBound.x=E(n.x,l),u.lowerBound.y=E(n.y,c),u.upperBound.x=O(n.x,l),u.upperBound.y=O(n.y,c))}else f.Push(_.child1),f.Push(_.child2)}}},e.AllocateNode=function(){if(null!==this.m_freeList){var e=this.m_freeList;return this.m_freeList=e.parent,e.parent=null,e.child1=null,e.child2=null,e.height=0,e}return new Xt(t.s_node_id++)},e.FreeNode=function(t){t.parent=this.m_freeList,t.child1=null,t.child2=null,t.height=-1,t.Reset(),this.m_freeList=t},e.CreateProxy=function(t,e){var i=this.AllocateNode();return i.aabb.lowerBound.x=t.lowerBound.x-.1,i.aabb.lowerBound.y=t.lowerBound.y-.1,i.aabb.upperBound.x=t.upperBound.x+.1,i.aabb.upperBound.y=t.upperBound.y+.1,i.userData=e,i.height=0,this.InsertLeaf(i),i},e.DestroyProxy=function(t){this.RemoveLeaf(t),this.FreeNode(t)},e.MoveProxy=function(t,e,i){if(t.aabb.Contains(e))return!1;this.RemoveLeaf(t);t.aabb.lowerBound.x=e.lowerBound.x-.1,t.aabb.lowerBound.y=e.lowerBound.y-.1,t.aabb.upperBound.x=e.upperBound.x+.1,t.aabb.upperBound.y=e.upperBound.y+.1;var n=2*i.x,r=2*i.y;return n<0?t.aabb.lowerBound.x+=n:t.aabb.upperBound.x+=n,r<0?t.aabb.lowerBound.y+=r:t.aabb.upperBound.y+=r,this.InsertLeaf(t),!0},e.InsertLeaf=function(e){if(++this.m_insertionCount,null===this.m_root)return this.m_root=e,void(this.m_root.parent=null);for(var i=e.aabb,n=this.m_root;!n.IsLeaf();){var r=qt(n.child1),s=qt(n.child2),a=n.aabb.GetPerimeter(),o=t.s_combinedAABB;o.Combine2(n.aabb,i);var h=o.GetPerimeter(),u=2*h,l=2*(h-a),c=void 0,f=t.s_aabb,_=void 0;r.IsLeaf()?(f.Combine2(i,r.aabb),c=f.GetPerimeter()+l):(f.Combine2(i,r.aabb),_=r.aabb.GetPerimeter(),c=f.GetPerimeter()-_+l);var d=void 0;if(s.IsLeaf()?(f.Combine2(i,s.aabb),d=f.GetPerimeter()+l):(f.Combine2(i,s.aabb),_=s.aabb.GetPerimeter(),d=f.GetPerimeter()-_+l),u1){var r=qt(i.child1),s=qt(i.child2);return i.child1=t,i.parent=t.parent,t.parent=i,null!==i.parent?i.parent.child1===t?i.parent.child1=i:i.parent.child2=i:this.m_root=i,r.height>s.height?(i.child2=r,t.child2=s,s.parent=t,t.aabb.Combine2(e.aabb,s.aabb),i.aabb.Combine2(t.aabb,r.aabb),t.height=1+O(e.height,s.height),i.height=1+O(t.height,r.height)):(i.child2=s,t.child2=r,r.parent=t,t.aabb.Combine2(e.aabb,r.aabb),i.aabb.Combine2(t.aabb,s.aabb),t.height=1+O(e.height,r.height),i.height=1+O(t.height,s.height)),i}if(n<-1){var a=qt(e.child1),o=qt(e.child2);return e.child1=t,e.parent=t.parent,t.parent=e,null!==e.parent?e.parent.child1===t?e.parent.child1=e:e.parent.child2=e:this.m_root=e,a.height>o.height?(e.child2=a,t.child1=o,o.parent=t,t.aabb.Combine2(i.aabb,o.aabb),e.aabb.Combine2(t.aabb,a.aabb),t.height=1+O(i.height,o.height),e.height=1+O(t.height,a.height)):(e.child2=o,t.child1=a,a.parent=t,t.aabb.Combine2(i.aabb,a.aabb),e.aabb.Combine2(t.aabb,o.aabb),t.height=1+O(i.height,a.height),e.height=1+O(t.height,o.height)),e}return t},e.GetHeight=function(){return null===this.m_root?0:this.m_root.height},t.GetAreaNode=function(e){if(null===e)return 0;if(e.IsLeaf())return 0;var i=e.aabb.GetPerimeter();return(i+=t.GetAreaNode(e.child1))+t.GetAreaNode(e.child2)},e.GetAreaRatio=function(){if(null===this.m_root)return 0;var e=this.m_root.aabb.GetPerimeter();return t.GetAreaNode(this.m_root)/e},t.ComputeHeightNode=function(e){return null===e||e.IsLeaf()?0:1+O(t.ComputeHeightNode(e.child1),t.ComputeHeightNode(e.child2))},e.ComputeHeight=function(){return t.ComputeHeightNode(this.m_root)},e.ValidateStructure=function(t){if(null!==t&&(this.m_root,!t.IsLeaf())){var e=qt(t.child1),i=qt(t.child2);this.ValidateStructure(e),this.ValidateStructure(i)}},e.ValidateMetrics=function(e){if(null!==e&&!e.IsLeaf()){var i=qt(e.child1),n=qt(e.child2);t.s_aabb.Combine2(i.aabb,n.aabb),this.ValidateMetrics(i),this.ValidateMetrics(n)}},e.Validate=function(){},t.GetMaxBalanceNode=function(t,e){if(null===t)return e;if(t.height<=1)return e;var i=qt(t.child1),n=qt(t.child2);return O(e,P(n.height-i.height))},e.GetMaxBalance=function(){return t.GetMaxBalanceNode(this.m_root,0)},e.RebuildBottomUp=function(){this.Validate()},t.ShiftOriginNode=function(e,i){if(null!==e&&!(e.height<=1)){var n=e.child1,r=e.child2;t.ShiftOriginNode(n,i),t.ShiftOriginNode(r,i),e.aabb.lowerBound.SelfSub(i),e.aabb.upperBound.SelfSub(i)}},e.ShiftOrigin=function(e){t.ShiftOriginNode(this.m_root,e)},t}();function Jt(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function Kt(t,e){return t=i)break;Jt(t,h,i)}}if(0===a)break;r=i,i=s[--a]}return t}Yt.s_r=new j,Yt.s_v=new j,Yt.s_abs_v=new j,Yt.s_segmentAABB=new Nt,Yt.s_subInput=new Lt,Yt.s_combinedAABB=new Nt,Yt.s_aabb=new Nt,Yt.s_node_id=0;var Zt=function(t,e){this.proxyA=t,this.proxyB=e},$t=function(){function t(){this.m_tree=new Yt,this.m_proxyCount=0,this.m_moveCount=0,this.m_moveBuffer=[],this.m_pairCount=0,this.m_pairBuffer=[]}var e=t.prototype;return e.CreateProxy=function(t,e){var i=this.m_tree.CreateProxy(t,e);return++this.m_proxyCount,this.BufferMove(i),i},e.DestroyProxy=function(t){this.UnBufferMove(t),--this.m_proxyCount,this.m_tree.DestroyProxy(t)},e.MoveProxy=function(t,e,i){this.m_tree.MoveProxy(t,e,i)&&this.BufferMove(t)},e.TouchProxy=function(t){this.BufferMove(t)},e.GetProxyCount=function(){return this.m_proxyCount},e.UpdatePairs=function(t){var e=this;this.m_pairCount=0;for(var i=function(){var t=e.m_moveBuffer[n];if(null===t)return 1;var i=t.aabb;e.m_tree.Query(i,(function(i){if(i.m_id===t.m_id)return!0;var n,r;if(i.m_idf+_){e.state=t.b2TOIOutputState.e_separated,e.t=u,w=!0;break}if(D>f-_){d=x;break}var B=S.Evaluate(A[0],C[0],d);if(Bf?(M=k,B=R):(E=k,D=R),50===I)break}if(t.b2_toiMaxRootIters=O(t.b2_toiMaxRootIters,I),++T===a)break}if(++p,++t.b2_toiIters,w)break;if(20===p){e.state=t.b2TOIOutputState.e_failed,e.t=d;break}}t.b2_toiMaxIters=O(t.b2_toiMaxIters,p);var F=n.GetMilliseconds();t.b2_toiMaxTime=O(t.b2_toiMaxTime,F),t.b2_toiTime+=F}var xe=new j,Te=new j;function Ae(e,i,n,r,s){e.pointCount=0;var a=Q.MulXV(n,i.m_p,xe),o=Q.MulXV(s,r.m_p,Te),h=j.DistanceSquaredVV(a,o),u=i.m_radius+r.m_radius;h>u*u||(e.type=t.b2ManifoldType.e_circles,e.localPoint.Copy(i.m_p),e.localNormal.SetZero(),e.pointCount=1,e.points[0].localPoint.Copy(r.m_p),e.points[0].id.key=0)}var Ce=new j,De=new j,Be=new j;function Ie(e,i,n,s,a){e.pointCount=0;for(var o=Q.MulXV(a,s.m_p,Ce),h=Q.MulTXV(n,o,De),u=0,l=-1e37,c=i.m_radius+s.m_radius,f=i.m_count,_=i.m_vertices,d=i.m_normals,p=0;pc)return;m>l&&(l=m,u=p)}var g=u,y=(g+1)%f,v=_[g],b=_[y];if(lc*c)return;e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,j.SubVV(h,v,e.localNormal).SelfNormalize(),e.localPoint.Copy(v),e.points[0].localPoint.Copy(s.m_p),e.points[0].id.key=0}else if(w<=0){if(j.DistanceSquaredVV(h,b)>c*c)return;e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,j.SubVV(h,b,e.localNormal).SelfNormalize(),e.localPoint.Copy(b),e.points[0].localPoint.Copy(s.m_p),e.points[0].id.key=0}else{var x=j.MidVV(v,b,Be);if(j.DotVV(j.SubVV(h,x,j.s_t1),d[g])>c)return;e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,e.localNormal.Copy(d[g]).SelfNormalize(),e.localPoint.Copy(x),e.points[0].localPoint.Copy(s.m_p),e.points[0].id.key=0}}var Me=new j,Pe=new j,Ee=new j,Oe=new j;function ke(t,e,n,r,s){for(var a=t.m_vertices,o=t.m_normals,h=r.m_count,u=r.m_vertices,l=K.MulRV(e.q,o[n],Me),c=K.MulTRV(s.q,l,Pe),f=0,_=i,d=0;dl&&(l=f,u=c)}var _=ke(e,i,u,n,r),d=(u+s-1)%s,p=ke(e,i,d,n,r),m=(u+1)%s,g=ke(e,i,m,n,r),y=0,v=0,b=0;if(p>_&&p>g)b=-1,y=d,v=p;else{if(!(g>_))return t[0]=u,_;b=1,y=m,v=g}for(;(_=ke(e,i,u=-1===b?(y+s-1)%s:(y+1)%s,n,r))>v;)y=u,v=_;return t[0]=y,v}var Ve=new j;function Ne(e,n,r,s,a,o){for(var h=n.m_normals,u=a.m_count,l=a.m_vertices,c=a.m_normals,f=K.MulTRV(o.q,K.MulRV(r.q,h[s],j.s_t0),Ve),_=0,d=i,p=0;pa)){var u=We;u[0]=0;var l=Le(u,r,s,i,n);if(!(l>a)){var c,f,_,d,p=0,m=0;l>.98*h+.001?(c=r,f=i,_=s,d=n,p=u[0],e.type=t.b2ManifoldType.e_faceB,m=1):(c=i,f=r,_=n,d=s,p=o[0],e.type=t.b2ManifoldType.e_faceA,m=0);var g=ze;Ne(g,c,_,p,f,d);var y=c.m_count,v=c.m_vertices,b=p,S=(p+1)%y,w=v[b],x=v[S],T=j.SubVV(x,w,je);T.Normalize();var A=j.CrossVOne(T,qe),C=j.MidVV(w,x,Xe),D=K.MulRV(_.q,T,Je),B=j.CrossVOne(D,Ye),I=Q.MulXV(_,w,Qe),M=Q.MulXV(_,x,Ze),P=j.DotVV(B,I),E=-j.DotVV(D,I)+a,O=j.DotVV(D,M)+a,k=Ue,R=Ge;if(!(Ut(k,g,j.NegV(D,Ke),E,b)<2||Ut(R,k,D,O,S)<2)){e.localNormal.Copy(A),e.localPoint.Copy(C);for(var F=0,L=0;L<2;++L){var V=R[L];if(j.DotVV(B,V.v)-P<=a){var N=e.points[F];if(Q.MulTXV(d,V.v,N.localPoint),N.id.Copy(V.id),m){var z=N.id.cf;N.id.cf.indexA=z.indexB,N.id.cf.indexB=z.indexA,N.id.cf.typeA=z.typeB,N.id.cf.typeB=z.typeA}++F}}e.pointCount=F}}}}var ti,ei=new j,ii=new j,ni=new j,ri=new j,si=new j,ai=new j,oi=new j,hi=new Pt;function ui(e,i,n,r,s){e.pointCount=0;var a=Q.MulTXV(n,Q.MulXV(s,r.m_p,j.s_t0),ei),o=i.m_vertex1,h=i.m_vertex2,u=j.SubVV(h,o,ii),l=j.DotVV(u,j.SubVV(h,a,j.s_t0)),c=j.DotVV(u,j.SubVV(a,o,j.s_t0)),f=i.m_radius+r.m_radius,_=hi;if(_.cf.indexB=0,_.cf.typeB=t.b2ContactFeatureType.e_vertex,c<=0){var d=o,p=j.SubVV(a,d,ni);if(j.DotVV(p,p)>f*f)return;if(i.m_hasVertex0){var m=i.m_vertex0,g=o,y=j.SubVV(g,m,ri);if(j.DotVV(y,j.SubVV(g,a,j.s_t0))>0)return}return _.cf.indexA=0,_.cf.typeA=t.b2ContactFeatureType.e_vertex,e.pointCount=1,e.type=t.b2ManifoldType.e_circles,e.localNormal.SetZero(),e.localPoint.Copy(d),e.points[0].id.Copy(_),void e.points[0].localPoint.Copy(r.m_p)}if(l<=0){var v=h,b=j.SubVV(a,v,ni);if(j.DotVV(b,b)>f*f)return;if(i.m_hasVertex3){var S=i.m_vertex3,w=h,x=j.SubVV(S,w,si);if(j.DotVV(x,j.SubVV(a,w,j.s_t0))>0)return}return _.cf.indexA=1,_.cf.typeA=t.b2ContactFeatureType.e_vertex,e.pointCount=1,e.type=t.b2ManifoldType.e_circles,e.localNormal.SetZero(),e.localPoint.Copy(v),e.points[0].id.Copy(_),void e.points[0].localPoint.Copy(r.m_p)}var T=j.DotVV(u,u),A=ai;A.x=1/T*(l*o.x+c*h.x),A.y=1/T*(l*o.y+c*h.y);var C=j.SubVV(a,A,ni);if(!(j.DotVV(C,C)>f*f)){var D=oi.Set(-u.y,u.x);j.DotVV(D,j.SubVV(a,o,j.s_t0))<0&&D.Set(-D.x,-D.y),D.Normalize(),_.cf.indexA=0,_.cf.typeA=t.b2ContactFeatureType.e_face,e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,e.localNormal.Copy(D),e.localPoint.Copy(o),e.points[0].id.Copy(_),e.points[0].localPoint.Copy(r.m_p)}}!function(t){t[t.e_unknown=0]="e_unknown",t[t.e_edgeA=1]="e_edgeA",t[t.e_edgeB=2]="e_edgeB"}(ti||(ti={}));var li,ci=function(){this.type=ti.e_unknown,this.index=0,this.separation=0},fi=function(){this.vertices=[],this.normals=[],this.count=0};!function(t){t[t.e_isolated=0]="e_isolated",t[t.e_concave=1]="e_concave",t[t.e_convex=2]="e_convex"}(li||(li={}));var _i=function(){function e(){this.m_polygonB=new fi,this.m_xf=new Q,this.m_centroidB=new j,this.m_v0=new j,this.m_v1=new j,this.m_v2=new j,this.m_v3=new j,this.m_normal0=new j,this.m_normal1=new j,this.m_normal2=new j,this.m_normal=new j,this.m_type1=li.e_isolated,this.m_type2=li.e_isolated,this.m_lowerLimit=new j,this.m_upperLimit=new j,this.m_radius=0,this.m_front=!1}var n=e.prototype;return n.Collide=function(i,n,r,s,a){Q.MulTXX(r,a,this.m_xf),Q.MulXV(this.m_xf,s.m_centroid,this.m_centroidB),this.m_v0.Copy(n.m_vertex0),this.m_v1.Copy(n.m_vertex1),this.m_v2.Copy(n.m_vertex2),this.m_v3.Copy(n.m_vertex3);var o=n.m_hasVertex0,h=n.m_hasVertex3,u=j.SubVV(this.m_v2,this.m_v1,e.s_edge1);u.Normalize(),this.m_normal1.Set(u.y,-u.x);var l=j.DotVV(this.m_normal1,j.SubVV(this.m_centroidB,this.m_v1,j.s_t0)),c=0,f=0,_=!1,d=!1;if(o){var p=j.SubVV(this.m_v1,this.m_v0,e.s_edge0);p.Normalize(),this.m_normal0.Set(p.y,-p.x),_=j.CrossVV(p,u)>=0,c=j.DotVV(this.m_normal0,j.SubVV(this.m_centroidB,this.m_v0,j.s_t0))}if(h){var m=j.SubVV(this.m_v3,this.m_v2,e.s_edge2);m.Normalize(),this.m_normal2.Set(m.y,-m.x),d=j.CrossVV(u,m)>0,f=j.DotVV(this.m_normal2,j.SubVV(this.m_centroidB,this.m_v2,j.s_t0))}o&&h?_&&d?(this.m_front=c>=0||l>=0||f>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal0),this.m_upperLimit.Copy(this.m_normal2)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1).SelfNeg())):_?(this.m_front=c>=0||l>=0&&f>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal0),this.m_upperLimit.Copy(this.m_normal1)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal2).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1).SelfNeg())):d?(this.m_front=f>=0||c>=0&&l>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal2)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal0).SelfNeg())):(this.m_front=c>=0&&l>=0&&f>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal1)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal2).SelfNeg(),this.m_upperLimit.Copy(this.m_normal0).SelfNeg())):o?_?(this.m_front=c>=0||l>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal0),this.m_upperLimit.Copy(this.m_normal1).SelfNeg()):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal1).SelfNeg())):(this.m_front=c>=0&&l>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal1).SelfNeg()):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal0).SelfNeg())):h?d?(this.m_front=l>=0||f>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal2)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1))):(this.m_front=l>=0&&f>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal2).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1))):(this.m_front=l>=0,this.m_front?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1).SelfNeg()):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal1))),this.m_polygonB.count=s.m_count;for(var g=0;gthis.m_radius)){var v=this.ComputePolygonSeparation(e.s_polygonAxis);if(!(v.type!==ti.e_unknown&&v.separation>this.m_radius)){var b;b=v.type===ti.e_unknown?y:v.separation>.98*y.separation+.001?v:y;var S=e.s_ie,w=e.s_rf;if(b.type===ti.e_edgeA){i.type=t.b2ManifoldType.e_faceA;for(var x=0,T=j.DotVV(this.m_normal,this.m_polygonB.normals[0]),A=1;Athis.m_radius)return i.type=ti.e_edgeB,i.index=r,i.separation=a,i;if(j.DotVV(s,n)>=0){if(j.DotVV(j.SubVV(s,this.m_upperLimit,j.s_t0),this.m_normal)<-.03490658503988889)continue}else if(j.DotVV(j.SubVV(s,this.m_lowerLimit,j.s_t0),this.m_normal)<-.03490658503988889)continue;a>i.separation&&(i.type=ti.e_edgeB,i.index=r,i.separation=a)}return i},e}();_i.s_edge1=new j,_i.s_edge0=new j,_i.s_edge2=new j,_i.s_ie=Ft.MakeArray(2),_i.s_rf=new function(){this.i1=0,this.i2=0,this.v1=new j,this.v2=new j,this.normal=new j,this.sideNormal1=new j,this.sideOffset1=0,this.sideNormal2=new j,this.sideOffset2=0},_i.s_clipPoints1=Ft.MakeArray(2),_i.s_clipPoints2=Ft.MakeArray(2),_i.s_edgeAxis=new ci,_i.s_polygonAxis=new ci,_i.s_n=new j,_i.s_perp=new j;var di=new _i;function pi(t,e,i,n,r){di.Collide(t,e,i,n,r)}var mi,gi=function(){this.mass=0,this.center=new j(0,0),this.I=0};(mi=t.b2ShapeType||(t.b2ShapeType={}))[mi.e_unknown=-1]="e_unknown",mi[mi.e_circleShape=0]="e_circleShape",mi[mi.e_edgeShape=1]="e_edgeShape",mi[mi.e_polygonShape=2]="e_polygonShape",mi[mi.e_chainShape=3]="e_chainShape",mi[mi.e_shapeTypeCount=4]="e_shapeTypeCount";var yi=function(){function e(e,i){this.m_type=t.b2ShapeType.e_unknown,this.m_radius=0,this.m_type=e,this.m_radius=i}var i=e.prototype;return i.Copy=function(t){return this.m_radius=t.m_radius,this},i.GetType=function(){return this.m_type},e}(),vi=function(e){function i(i){var n;return void 0===i&&(i=0),(n=e.call(this,t.b2ShapeType.e_circleShape,i)||this).m_p=new j,n}s(i,e);var n=i.prototype;return n.Set=function(t,e){return void 0===e&&(e=this.m_radius),this.m_p.Copy(t),this.m_radius=e,this},n.Clone=function(){return(new i).Copy(this)},n.Copy=function(t){return e.prototype.Copy.call(this,t),this.m_p.Copy(t.m_p),this},n.GetChildCount=function(){return 1},n.TestPoint=function(t,e){var n=Q.MulXV(t,this.m_p,i.TestPoint_s_center),r=j.SubVV(e,n,i.TestPoint_s_d);return j.DotVV(r,r)<=F(this.m_radius)},n.ComputeDistance=function(t,e,n){var r=Q.MulXV(t,this.m_p,i.ComputeDistance_s_center);return j.SubVV(e,r,n),n.Normalize()-this.m_radius},n.RayCast=function(t,e,n){var s=Q.MulXV(n,this.m_p,i.RayCast_s_position),a=j.SubVV(e.p1,s,i.RayCast_s_s),o=j.DotVV(a,a)-F(this.m_radius),h=j.SubVV(e.p2,e.p1,i.RayCast_s_r),u=j.DotVV(a,h),l=j.DotVV(h,h),c=u*u-l*o;if(c<0||lthis.m_radius)return n.Copy(s),o*this.m_radius*this.m_radius;var h=this.m_radius*this.m_radius,u=a*a,l=h*(H(a/this.m_radius)+o/2)+a*V(h-u),c=-2/3*N(h-u,1.5)/l;return n.x=s.x+t.x*c,n.y=s.y+t.y*c,l},n.Dump=function(t){t(" const shape: b2CircleShape = new b2CircleShape();\n"),t(" shape.m_radius = %.15f;\n",this.m_radius),t(" shape.m_p.Set(%.15f, %.15f);\n",this.m_p.x,this.m_p.y)},i}(yi);vi.TestPoint_s_center=new j,vi.TestPoint_s_d=new j,vi.ComputeDistance_s_center=new j,vi.RayCast_s_position=new j,vi.RayCast_s_s=new j,vi.RayCast_s_r=new j,vi.ComputeAABB_s_p=new j;var bi=function(e){function i(){var i;return(i=e.call(this,t.b2ShapeType.e_polygonShape,f)||this).m_centroid=new j(0,0),i.m_vertices=[],i.m_normals=[],i.m_count=0,i}s(i,e);var n=i.prototype;return n.Clone=function(){return(new i).Copy(this)},n.Copy=function(t){e.prototype.Copy.call(this,t),this.m_centroid.Copy(t.m_centroid),this.m_count=t.m_count,this.m_vertices=j.MakeArray(this.m_count),this.m_normals=j.MakeArray(this.m_count);for(var i=0;il||f===l&&r[c].yy.LengthSquared()&&(m=g)}else m=g;if(++d,p=m,m===u)break}this.m_count=d,this.m_vertices=j.MakeArray(this.m_count),this.m_normals=j.MakeArray(this.m_count);for(var S=0;S0)return!1;return!0},n.ComputeDistance=function(t,e,n){for(var r=Q.MulTXV(t,e,i.ComputeDistance_s_pLocal),s=-1e37,a=i.ComputeDistance_s_normalForMaxDistance.Copy(r),o=0;os&&(s=h,a.Copy(this.m_normals[o]))}if(s>0){for(var u=i.ComputeDistance_s_minDistance.Copy(a),l=s*s,c=0;c_&&(u.Copy(f),l=_)}return K.MulRV(t.q,u,n),n.Normalize(),Math.sqrt(l)}return K.MulRV(t.q,a,n),s},n.RayCast=function(t,e,n){for(var r=Q.MulTXV(n,e.p1,i.RayCast_s_p1),s=Q.MulTXV(n,e.p2,i.RayCast_s_p2),a=j.SubVV(s,r,i.RayCast_s_d),o=0,h=e.maxFraction,u=-1,l=0;l0&&c=0&&(t.fraction=o,K.MulRV(n.q,this.m_normals[u],t.normal),!0)},n.ComputeAABB=function(t,e){for(var n=Q.MulXV(e,this.m_vertices[0],t.lowerBound),r=t.upperBound.Copy(n),s=0;s0&&(_?c||(u=f-1,h++):c&&(l=f-1,h++)),c=_}switch(h){case 0:if(c){var d=i.ComputeSubmergedArea_s_md;return this.ComputeMass(d,1),Q.MulXV(n,d.center,r),d.mass}return 0;case 1:-1===u?u=this.m_count-1:l=this.m_count-1}for(var p,m=(u+1)%this.m_count,g=(l+1)%this.m_count,y=(0-o[u])/(o[m]-o[u]),v=(0-o[l])/(o[g]-o[l]),b=i.ComputeSubmergedArea_s_intoVec.Set(this.m_vertices[u].x*(1-y)+this.m_vertices[m].x*y,this.m_vertices[u].y*(1-y)+this.m_vertices[m].y*y),S=i.ComputeSubmergedArea_s_outoVec.Set(this.m_vertices[l].x*(1-v)+this.m_vertices[g].x*v,this.m_vertices[l].y*(1-v)+this.m_vertices[g].y*v),w=0,x=i.ComputeSubmergedArea_s_center.SetZero(),T=this.m_vertices[m],A=m;A!==g;){p=(A=(A+1)%this.m_count)===g?S:this.m_vertices[A];var C=.5*((T.x-b.x)*(p.y-b.y)-(T.y-b.y)*(p.x-b.x));w+=C,x.x+=C*(b.x+T.x+p.x)/3,x.y+=C*(b.y+T.y+p.y)/3,T=p}return x.SelfMul(1/w),Q.MulXV(n,x,r),w},n.Dump=function(t){t(" const shape: b2PolygonShape = new b2PolygonShape();\n"),t(" const vs: b2Vec2[] = [];\n");for(var e=0;e0){var u=j.DotVV(o,o);h>u?j.SubVV(e,s,a):a.SelfMulSub(h/u,o)}return n.Copy(a),n.Normalize()},n.RayCast=function(t,e,n){var r=Q.MulTXV(n,e.p1,i.RayCast_s_p1),s=Q.MulTXV(n,e.p2,i.RayCast_s_p2),a=j.SubVV(s,r,i.RayCast_s_d),o=this.m_vertex1,h=this.m_vertex2,u=j.SubVV(h,o,i.RayCast_s_e),l=t.normal.Set(u.y,-u.x).SelfNormalize(),c=j.DotVV(l,j.SubVV(o,r,j.s_t0)),f=j.DotVV(l,a);if(0===f)return!1;var _=c/f;if(_<0||e.maxFraction<_)return!1;var d=j.AddVMulSV(r,_,a,i.RayCast_s_q),p=j.SubVV(h,o,i.RayCast_s_r),m=j.DotVV(p,p);if(0===m)return!1;var g=j.DotVV(j.SubVV(d,o,j.s_t0),p)/m;return!(g<0||10&&t.normal.SelfNeg(),0))},n.ComputeAABB=function(t,e){var n=Q.MulXV(e,this.m_vertex1,i.ComputeAABB_s_v1),r=Q.MulXV(e,this.m_vertex2,i.ComputeAABB_s_v2);j.MinV(n,r,t.lowerBound),j.MaxV(n,r,t.upperBound);var s=this.m_radius;t.lowerBound.SelfSubXY(s,s),t.upperBound.SelfAddXY(s,s)},n.ComputeMass=function(t){t.mass=0,j.MidVV(this.m_vertex1,this.m_vertex2,t.center),t.I=0},n.SetupDistanceProxy=function(t){t.m_vertices=t.m_buffer,t.m_vertices[0].Copy(this.m_vertex1),t.m_vertices[1].Copy(this.m_vertex2),t.m_count=2,t.m_radius=this.m_radius},n.ComputeSubmergedArea=function(t,e,i,n){return n.SetZero(),0},n.Dump=function(t){t(" const shape: b2EdgeShape = new b2EdgeShape();\n"),t(" shape.m_radius = %.15f;\n",this.m_radius),t(" shape.m_vertex0.Set(%.15f, %.15f);\n",this.m_vertex0.x,this.m_vertex0.y),t(" shape.m_vertex1.Set(%.15f, %.15f);\n",this.m_vertex1.x,this.m_vertex1.y),t(" shape.m_vertex2.Set(%.15f, %.15f);\n",this.m_vertex2.x,this.m_vertex2.y),t(" shape.m_vertex3.Set(%.15f, %.15f);\n",this.m_vertex3.x,this.m_vertex3.y),t(" shape.m_hasVertex0 = %s;\n",this.m_hasVertex0),t(" shape.m_hasVertex3 = %s;\n",this.m_hasVertex3)},i}(yi);Si.ComputeDistance_s_v1=new j,Si.ComputeDistance_s_v2=new j,Si.ComputeDistance_s_d=new j,Si.ComputeDistance_s_s=new j,Si.RayCast_s_p1=new j,Si.RayCast_s_p2=new j,Si.RayCast_s_d=new j,Si.RayCast_s_e=new j,Si.RayCast_s_q=new j,Si.RayCast_s_r=new j,Si.ComputeAABB_s_v1=new j,Si.ComputeAABB_s_v2=new j;var wi=function(e){function i(){var i;return(i=e.call(this,t.b2ShapeType.e_chainShape,f)||this).m_vertices=[],i.m_count=0,i.m_prevVertex=new j,i.m_nextVertex=new j,i.m_hasPrevVertex=!1,i.m_hasNextVertex=!1,i}s(i,e);var n=i.prototype;return n.CreateLoop=function(){for(var t=arguments.length,e=new Array(t),i=0;i0?(t.m_vertex0.Copy(this.m_vertices[e-1]),t.m_hasVertex0=!0):(t.m_vertex0.Copy(this.m_prevVertex),t.m_hasVertex0=this.m_hasPrevVertex),e0&&this.ResetMassData(),this.m_world.m_newFixture=!0,e},n.CreateFixtureShapeDensity=function(t,e){void 0===e&&(e=0);var n=i.CreateFixtureShapeDensity_s_def;return n.shape=t,n.density=e,this.CreateFixtureDef(n)},n.DestroyFixture=function(t){if(this.m_world.IsLocked())throw new Error;for(var e=this.m_fixtureList,i=null;null!==e;){if(e===t){i?i.m_next=t.m_next:this.m_fixtureList=t.m_next;break}i=e,e=e.m_next}for(var n=this.m_contactList;n;){var r=n.contact;n=n.next;var s=r.GetFixtureA(),a=r.GetFixtureB();t!==s&&t!==a||this.m_world.m_contactManager.Destroy(r)}this.m_activeFlag&&t.DestroyProxies(),t.m_next=null,t.Reset(),--this.m_fixtureCount,this.ResetMassData()},n.SetTransformVec=function(t,e){this.SetTransformXY(t.x,t.y,e)},n.SetTransformXY=function(t,e,i){if(this.m_world.IsLocked())throw new Error;this.m_xf.q.SetAngle(i),this.m_xf.p.Set(t,e),this.m_xf0.Copy(this.m_xf),Q.MulXV(this.m_xf,this.m_sweep.localCenter,this.m_sweep.c),this.m_sweep.a=i,this.m_sweep.c0.Copy(this.m_sweep.c),this.m_sweep.a0=i;for(var n=this.m_fixtureList;n;n=n.m_next)n.SynchronizeProxies(this.m_xf,this.m_xf,j.ZERO);this.m_world.m_contactManager.FindNewContacts()},n.SetTransform=function(t){this.SetTransformVec(t.p,t.GetAngle())},n.GetTransform=function(){return this.m_xf},n.GetPosition=function(){return this.m_xf.p},n.SetPosition=function(t){this.SetTransformVec(t,this.GetAngle())},n.SetPositionXY=function(t,e){this.SetTransformXY(t,e,this.GetAngle())},n.GetAngle=function(){return this.m_sweep.a},n.SetAngle=function(t){this.SetTransformVec(this.GetPosition(),t)},n.GetWorldCenter=function(){return this.m_sweep.c},n.GetLocalCenter=function(){return this.m_sweep.localCenter},n.SetLinearVelocity=function(e){this.m_type!==t.b2BodyType.b2_staticBody&&(j.DotVV(e,e)>0&&this.SetAwake(!0),this.m_linearVelocity.Copy(e))},n.GetLinearVelocity=function(){return this.m_linearVelocity},n.SetAngularVelocity=function(e){this.m_type!==t.b2BodyType.b2_staticBody&&(e*e>0&&this.SetAwake(!0),this.m_angularVelocity=e)},n.GetAngularVelocity=function(){return this.m_angularVelocity},n.GetDefinition=function(t){return t.type=this.GetType(),t.allowSleep=this.m_autoSleepFlag,t.angle=this.GetAngle(),t.angularDamping=this.m_angularDamping,t.gravityScale=this.m_gravityScale,t.angularVelocity=this.m_angularVelocity,t.fixedRotation=this.m_fixedRotationFlag,t.bullet=this.m_bulletFlag,t.awake=this.m_awakeFlag,t.linearDamping=this.m_linearDamping,t.linearVelocity.Copy(this.GetLinearVelocity()),t.position.Copy(this.GetPosition()),t.userData=this.GetUserData(),t},n.ApplyForce=function(e,i,n){void 0===n&&(n=!0),this.m_type===t.b2BodyType.b2_dynamicBody&&(n&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_force.x+=e.x,this.m_force.y+=e.y,this.m_torque+=(i.x-this.m_sweep.c.x)*e.y-(i.y-this.m_sweep.c.y)*e.x))},n.ApplyForceToCenter=function(e,i){void 0===i&&(i=!0),this.m_type===t.b2BodyType.b2_dynamicBody&&(i&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_force.x+=e.x,this.m_force.y+=e.y))},n.ApplyTorque=function(e,i){void 0===i&&(i=!0),this.m_type===t.b2BodyType.b2_dynamicBody&&(i&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_torque+=e))},n.ApplyLinearImpulse=function(e,i,n){void 0===n&&(n=!0),this.m_type===t.b2BodyType.b2_dynamicBody&&(n&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_linearVelocity.x+=this.m_invMass*e.x,this.m_linearVelocity.y+=this.m_invMass*e.y,this.m_angularVelocity+=this.m_invI*((i.x-this.m_sweep.c.x)*e.y-(i.y-this.m_sweep.c.y)*e.x)))},n.ApplyLinearImpulseToCenter=function(e,i){void 0===i&&(i=!0),this.m_type===t.b2BodyType.b2_dynamicBody&&(i&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_linearVelocity.x+=this.m_invMass*e.x,this.m_linearVelocity.y+=this.m_invMass*e.y))},n.ApplyAngularImpulse=function(e,i){void 0===i&&(i=!0),this.m_type===t.b2BodyType.b2_dynamicBody&&(i&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_angularVelocity+=this.m_invI*e))},n.GetMass=function(){return this.m_mass},n.GetInertia=function(){return this.m_I+this.m_mass*j.DotVV(this.m_sweep.localCenter,this.m_sweep.localCenter)},n.GetMassData=function(t){return t.mass=this.m_mass,t.I=this.m_I+this.m_mass*j.DotVV(this.m_sweep.localCenter,this.m_sweep.localCenter),t.center.Copy(this.m_sweep.localCenter),t},n.SetMassData=function(e){if(this.m_world.IsLocked())throw new Error;if(this.m_type===t.b2BodyType.b2_dynamicBody){this.m_invMass=0,this.m_I=0,this.m_invI=0,this.m_mass=e.mass,this.m_mass<=0&&(this.m_mass=1),this.m_invMass=1/this.m_mass,e.I>0&&!this.m_fixedRotationFlag&&(this.m_I=e.I-this.m_mass*j.DotVV(e.center,e.center),this.m_invI=1/this.m_I);var n=i.SetMassData_s_oldCenter.Copy(this.m_sweep.c);this.m_sweep.localCenter.Copy(e.center),Q.MulXV(this.m_xf,this.m_sweep.localCenter,this.m_sweep.c),this.m_sweep.c0.Copy(this.m_sweep.c),j.AddVCrossSV(this.m_linearVelocity,this.m_angularVelocity,j.SubVV(this.m_sweep.c,n,j.s_t0),this.m_linearVelocity)}},n.ResetMassData=function(){if(this.m_mass=0,this.m_invMass=0,this.m_I=0,this.m_invI=0,this.m_sweep.localCenter.SetZero(),this.m_type===t.b2BodyType.b2_staticBody||this.m_type===t.b2BodyType.b2_kinematicBody)return this.m_sweep.c0.Copy(this.m_xf.p),this.m_sweep.c.Copy(this.m_xf.p),void(this.m_sweep.a0=this.m_sweep.a);for(var e=i.ResetMassData_s_localCenter.SetZero(),n=this.m_fixtureList;n;n=n.m_next)if(0!==n.m_density){var r=n.GetMassData(i.ResetMassData_s_massData);this.m_mass+=r.mass,e.x+=r.center.x*r.mass,e.y+=r.center.y*r.mass,this.m_I+=r.I}this.m_mass>0?(this.m_invMass=1/this.m_mass,e.x*=this.m_invMass,e.y*=this.m_invMass):(this.m_mass=1,this.m_invMass=1),this.m_I>0&&!this.m_fixedRotationFlag?(this.m_I-=this.m_mass*j.DotVV(e,e),this.m_invI=1/this.m_I):(this.m_I=0,this.m_invI=0);var s=i.ResetMassData_s_oldCenter.Copy(this.m_sweep.c);this.m_sweep.localCenter.Copy(e),Q.MulXV(this.m_xf,this.m_sweep.localCenter,this.m_sweep.c),this.m_sweep.c0.Copy(this.m_sweep.c),j.AddVCrossSV(this.m_linearVelocity,this.m_angularVelocity,j.SubVV(this.m_sweep.c,s,j.s_t0),this.m_linearVelocity)},n.GetWorldPoint=function(t,e){return Q.MulXV(this.m_xf,t,e)},n.GetWorldVector=function(t,e){return K.MulRV(this.m_xf.q,t,e)},n.GetLocalPoint=function(t,e){return Q.MulTXV(this.m_xf,t,e)},n.GetLocalVector=function(t,e){return K.MulTRV(this.m_xf.q,t,e)},n.GetLinearVelocityFromWorldPoint=function(t,e){return j.AddVCrossSV(this.m_linearVelocity,this.m_angularVelocity,j.SubVV(t,this.m_sweep.c,j.s_t0),e)},n.GetLinearVelocityFromLocalPoint=function(t,e){return this.GetLinearVelocityFromWorldPoint(this.GetWorldPoint(t,e),e)},n.GetLinearDamping=function(){return this.m_linearDamping},n.SetLinearDamping=function(t){this.m_linearDamping=t},n.GetAngularDamping=function(){return this.m_angularDamping},n.SetAngularDamping=function(t){this.m_angularDamping=t},n.GetGravityScale=function(){return this.m_gravityScale},n.SetGravityScale=function(t){this.m_gravityScale=t},n.SetType=function(e){if(this.m_world.IsLocked())throw new Error;if(this.m_type!==e){this.m_type=e,this.ResetMassData(),this.m_type===t.b2BodyType.b2_staticBody&&(this.m_linearVelocity.SetZero(),this.m_angularVelocity=0,this.m_sweep.a0=this.m_sweep.a,this.m_sweep.c0.Copy(this.m_sweep.c),this.SynchronizeFixtures()),this.SetAwake(!0),this.m_force.SetZero(),this.m_torque=0;for(var i=this.m_contactList;i;){var n=i;i=i.next,this.m_world.m_contactManager.Destroy(n.contact)}this.m_contactList=null;for(var r=this.m_fixtureList;r;r=r.m_next)r.TouchProxies()}},n.GetType=function(){return this.m_type},n.SetBullet=function(t){this.m_bulletFlag=t},n.IsBullet=function(){return this.m_bulletFlag},n.SetSleepingAllowed=function(t){this.m_autoSleepFlag=t,t||this.SetAwake(!0)},n.IsSleepingAllowed=function(){return this.m_autoSleepFlag},n.SetAwake=function(t){t?(this.m_awakeFlag=!0,this.m_sleepTime=0):(this.m_awakeFlag=!1,this.m_sleepTime=0,this.m_linearVelocity.SetZero(),this.m_angularVelocity=0,this.m_force.SetZero(),this.m_torque=0)},n.IsAwake=function(){return this.m_awakeFlag},n.SetActive=function(t){if(this.m_world.IsLocked())throw new Error;if(t!==this.IsActive())if(this.m_activeFlag=t,t)for(var e=this.m_fixtureList;e;e=e.m_next)e.CreateProxies();else{for(var i=this.m_fixtureList;i;i=i.m_next)i.DestroyProxies();for(var n=this.m_contactList;n;){var r=n;n=n.next,this.m_world.m_contactManager.Destroy(r.contact)}this.m_contactList=null}},n.IsActive=function(){return this.m_activeFlag},n.SetFixedRotation=function(t){this.m_fixedRotationFlag!==t&&(this.m_fixedRotationFlag=t,this.m_angularVelocity=0,this.ResetMassData())},n.IsFixedRotation=function(){return this.m_fixedRotationFlag},n.GetFixtureList=function(){return this.m_fixtureList},n.GetJointList=function(){return this.m_jointList},n.GetContactList=function(){return this.m_contactList},n.GetNext=function(){return this.m_next},n.GetUserData=function(){return this.m_userData},n.SetUserData=function(t){this.m_userData=t},n.GetWorld=function(){return this.m_world},n.Dump=function(e){var i=this.m_islandIndex;e("{\n"),e(" const bd: b2BodyDef = new b2BodyDef();\n");var n="";switch(this.m_type){case t.b2BodyType.b2_staticBody:n="b2BodyType.b2_staticBody";break;case t.b2BodyType.b2_kinematicBody:n="b2BodyType.b2_kinematicBody";break;case t.b2BodyType.b2_dynamicBody:n="b2BodyType.b2_dynamicBody"}e(" bd.type = %s;\n",n),e(" bd.position.Set(%.15f, %.15f);\n",this.m_xf.p.x,this.m_xf.p.y),e(" bd.angle = %.15f;\n",this.m_sweep.a),e(" bd.linearVelocity.Set(%.15f, %.15f);\n",this.m_linearVelocity.x,this.m_linearVelocity.y),e(" bd.angularVelocity = %.15f;\n",this.m_angularVelocity),e(" bd.linearDamping = %.15f;\n",this.m_linearDamping),e(" bd.angularDamping = %.15f;\n",this.m_angularDamping),e(" bd.allowSleep = %s;\n",this.m_autoSleepFlag?"true":"false"),e(" bd.awake = %s;\n",this.m_awakeFlag?"true":"false"),e(" bd.fixedRotation = %s;\n",this.m_fixedRotationFlag?"true":"false"),e(" bd.bullet = %s;\n",this.m_bulletFlag?"true":"false"),e(" bd.active = %s;\n",this.m_activeFlag?"true":"false"),e(" bd.gravityScale = %.15f;\n",this.m_gravityScale),e("\n"),e(" bodies[%d] = this.m_world.CreateBody(bd);\n",this.m_islandIndex),e("\n");for(var r=this.m_fixtureList;r;r=r.m_next)e(" {\n"),r.Dump(e,i),e(" }\n");e("}\n")},n.SynchronizeFixtures=function(){var t=i.SynchronizeFixtures_s_xf1;t.q.SetAngle(this.m_sweep.a0),K.MulRV(t.q,this.m_sweep.localCenter,t.p),j.SubVV(this.m_sweep.c0,t.p,t.p);for(var e=j.SubVV(this.m_sweep.c,this.m_sweep.c0,i.SynchronizeFixtures_s_displacement),n=this.m_fixtureList;n;n=n.m_next)n.SynchronizeProxies(t,this.m_xf,e)},n.SynchronizeTransform=function(){this.m_xf.q.SetAngle(this.m_sweep.a),K.MulRV(this.m_xf.q,this.m_sweep.localCenter,this.m_xf.p),j.SubVV(this.m_sweep.c,this.m_xf.p,this.m_xf.p)},n.ShouldCollide=function(e){return(this.m_type!==t.b2BodyType.b2_staticBody||e.m_type!==t.b2BodyType.b2_staticBody)&&this.ShouldCollideConnected(e)},n.ShouldCollideConnected=function(t){for(var e=this.m_jointList;e;e=e.next)if(e.other===t&&!e.joint.m_collideConnected)return!1;return!0},n.Advance=function(t){this.m_sweep.Advance(t),this.m_sweep.c.Copy(this.m_sweep.c0),this.m_sweep.a=this.m_sweep.a0,this.m_xf.q.SetAngle(this.m_sweep.a),K.MulRV(this.m_xf.q,this.m_sweep.localCenter,this.m_xf.p),j.SubVV(this.m_sweep.c,this.m_xf.p,this.m_xf.p)},n.GetControllerList=function(){return this.m_controllerList},n.GetControllerCount=function(){return this.m_controllerCount},i}();Mi.CreateFixtureShapeDensity_s_def=new Ti,Mi.SetMassData_s_oldCenter=new j,Mi.ResetMassData_s_localCenter=new j,Mi.ResetMassData_s_oldCenter=new j,Mi.ResetMassData_s_massData=new gi,Mi.SynchronizeFixtures_s_xf1=new Q,Mi.SynchronizeFixtures_s_displacement=new j,(Ii=t.b2JointType||(t.b2JointType={}))[Ii.e_unknownJoint=0]="e_unknownJoint",Ii[Ii.e_revoluteJoint=1]="e_revoluteJoint",Ii[Ii.e_prismaticJoint=2]="e_prismaticJoint",Ii[Ii.e_distanceJoint=3]="e_distanceJoint",Ii[Ii.e_pulleyJoint=4]="e_pulleyJoint",Ii[Ii.e_mouseJoint=5]="e_mouseJoint",Ii[Ii.e_gearJoint=6]="e_gearJoint",Ii[Ii.e_wheelJoint=7]="e_wheelJoint",Ii[Ii.e_weldJoint=8]="e_weldJoint",Ii[Ii.e_frictionJoint=9]="e_frictionJoint",Ii[Ii.e_ropeJoint=10]="e_ropeJoint",Ii[Ii.e_motorJoint=11]="e_motorJoint",Ii[Ii.e_areaJoint=12]="e_areaJoint",(Bi=t.b2LimitState||(t.b2LimitState={}))[Bi.e_inactiveLimit=0]="e_inactiveLimit",Bi[Bi.e_atLowerLimit=1]="e_atLowerLimit",Bi[Bi.e_atUpperLimit=2]="e_atUpperLimit",Bi[Bi.e_equalLimits=3]="e_equalLimits";var Pi=function(){function t(){this.linear=new j,this.angularA=0,this.angularB=0}var e=t.prototype;return e.SetZero=function(){return this.linear.SetZero(),this.angularA=0,this.angularB=0,this},e.Set=function(t,e,i){return this.linear.Copy(t),this.angularA=e,this.angularB=i,this},t}(),Ei=function(){function t(t){this._other=null,this.prev=null,this.next=null,this.joint=t}return t.prototype.Reset=function(){this._other=null,this.prev=null,this.next=null},n(t,[{key:"other",get:function(){if(null===this._other)throw new Error;return this._other},set:function(t){if(null!==this._other)throw new Error;this._other=t}}]),t}(),Oi=function(e){this.type=t.b2JointType.e_unknownJoint,this.userData=null,this.collideConnected=!1,this.type=e},ki=function(){function i(i){this.m_type=t.b2JointType.e_unknownJoint,this.m_prev=null,this.m_next=null,this.m_edgeA=new Ei(this),this.m_edgeB=new Ei(this),this.m_index=0,this.m_islandFlag=!1,this.m_collideConnected=!1,this.m_userData=null,this.m_type=i.type,this.m_edgeA.other=i.bodyB,this.m_edgeB.other=i.bodyA,this.m_bodyA=i.bodyA,this.m_bodyB=i.bodyB,this.m_collideConnected=e(i.collideConnected,!1),this.m_userData=e(i.userData,null)}var n=i.prototype;return n.GetType=function(){return this.m_type},n.GetBodyA=function(){return this.m_bodyA},n.GetBodyB=function(){return this.m_bodyB},n.GetNext=function(){return this.m_next},n.GetUserData=function(){return this.m_userData},n.SetUserData=function(t){this.m_userData=t},n.IsActive=function(){return this.m_bodyA.IsActive()&&this.m_bodyB.IsActive()},n.GetCollideConnected=function(){return this.m_collideConnected},n.Dump=function(t){t("// Dump is not supported for this joint type.\n")},n.ShiftOrigin=function(){},i}(),Ri=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_distanceJoint)||this).localAnchorA=new j,i.localAnchorB=new j,i.length=1,i.frequencyHz=0,i.dampingRatio=0,i}return s(i,e),i.prototype.Initialize=function(t,e,i,n){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(i,this.localAnchorA),this.bodyB.GetLocalPoint(n,this.localAnchorB),this.length=j.DistanceVV(i,n),this.frequencyHz=0,this.dampingRatio=0},i}(Oi),Fi=function(t){function i(i){var n;return(n=t.call(this,i)||this).m_frequencyHz=0,n.m_dampingRatio=0,n.m_bias=0,n.m_localAnchorA=new j,n.m_localAnchorB=new j,n.m_gamma=0,n.m_impulse=0,n.m_length=0,n.m_indexA=0,n.m_indexB=0,n.m_u=new j,n.m_rA=new j,n.m_rB=new j,n.m_localCenterA=new j,n.m_localCenterB=new j,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_mass=0,n.m_qA=new K,n.m_qB=new K,n.m_lalcA=new j,n.m_lalcB=new j,n.m_frequencyHz=e(i.frequencyHz,0),n.m_dampingRatio=e(i.dampingRatio,0),n.m_localAnchorA.Copy(i.localAnchorA),n.m_localAnchorB.Copy(i.localAnchorB),n.m_length=i.length,n}s(i,t);var n=i.prototype;return n.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},n.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},n.GetReactionForce=function(t,e){return e.x=t*this.m_impulse*this.m_u.x,e.y=t*this.m_impulse*this.m_u.y,e},n.GetReactionTorque=function(){return 0},n.GetLocalAnchorA=function(){return this.m_localAnchorA},n.GetLocalAnchorB=function(){return this.m_localAnchorB},n.SetLength=function(t){this.m_length=t},n.Length=function(){return this.m_length},n.SetFrequency=function(t){this.m_frequencyHz=t},n.GetFrequency=function(){return this.m_frequencyHz},n.SetDampingRatio=function(t){this.m_dampingRatio=t},n.GetDampingRatio=function(){return this.m_dampingRatio},n.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2DistanceJointDef = new b2DistanceJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.length = %.15f;\n",this.m_length),t(" jd.frequencyHz = %.15f;\n",this.m_frequencyHz),t(" jd.dampingRatio = %.15f;\n",this.m_dampingRatio),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},n.InitVelocityConstraints=function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,r=t.velocities[this.m_indexA].v,s=t.velocities[this.m_indexA].w,a=t.positions[this.m_indexB].c,h=t.positions[this.m_indexB].a,u=t.velocities[this.m_indexB].v,c=t.velocities[this.m_indexB].w,f=this.m_qA.SetAngle(n),_=this.m_qB.SetAngle(h);j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA),K.MulRV(f,this.m_lalcA,this.m_rA),j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),K.MulRV(_,this.m_lalcB,this.m_rB),this.m_u.x=a.x+this.m_rB.x-e.x-this.m_rA.x,this.m_u.y=a.y+this.m_rB.y-e.y-this.m_rA.y;var d=this.m_u.Length();d>l?this.m_u.SelfMul(1/d):this.m_u.SetZero();var p=j.CrossVV(this.m_rA,this.m_u),m=j.CrossVV(this.m_rB,this.m_u),g=this.m_invMassA+this.m_invIA*p*p+this.m_invMassB+this.m_invIB*m*m;if(this.m_mass=0!==g?1/g:0,this.m_frequencyHz>0){var y=d-this.m_length,v=2*o*this.m_frequencyHz,b=2*this.m_mass*this.m_dampingRatio*v,S=this.m_mass*v*v,w=t.step.dt;this.m_gamma=w*(b+w*S),this.m_gamma=0!==this.m_gamma?1/this.m_gamma:0,this.m_bias=y*w*S*this.m_gamma,g+=this.m_gamma,this.m_mass=0!==g?1/g:0}else this.m_gamma=0,this.m_bias=0;if(t.step.warmStarting){this.m_impulse*=t.step.dtRatio;var x=j.MulSV(this.m_impulse,this.m_u,i.InitVelocityConstraints_s_P);r.SelfMulSub(this.m_invMassA,x),s-=this.m_invIA*j.CrossVV(this.m_rA,x),u.SelfMulAdd(this.m_invMassB,x),c+=this.m_invIB*j.CrossVV(this.m_rB,x)}else this.m_impulse=0;t.velocities[this.m_indexA].w=s,t.velocities[this.m_indexB].w=c},n.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexA].v,n=t.velocities[this.m_indexA].w,r=t.velocities[this.m_indexB].v,s=t.velocities[this.m_indexB].w,a=j.AddVCrossSV(e,n,this.m_rA,i.SolveVelocityConstraints_s_vpA),o=j.AddVCrossSV(r,s,this.m_rB,i.SolveVelocityConstraints_s_vpB),h=j.DotVV(this.m_u,j.SubVV(o,a,j.s_t0)),u=-this.m_mass*(h+this.m_bias+this.m_gamma*this.m_impulse);this.m_impulse+=u;var l=j.MulSV(u,this.m_u,i.SolveVelocityConstraints_s_P);e.SelfMulSub(this.m_invMassA,l),n-=this.m_invIA*j.CrossVV(this.m_rA,l),r.SelfMulAdd(this.m_invMassB,l),s+=this.m_invIB*j.CrossVV(this.m_rB,l),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=s},n.SolvePositionConstraints=function(t){if(this.m_frequencyHz>0)return!0;var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,r=t.positions[this.m_indexB].c,s=t.positions[this.m_indexB].a,a=this.m_qA.SetAngle(n),o=this.m_qB.SetAngle(s),h=K.MulRV(a,this.m_lalcA,this.m_rA),u=K.MulRV(o,this.m_lalcB,this.m_rB),c=this.m_u;c.x=r.x+u.x-e.x-h.x,c.y=r.y+u.y-e.y-h.y;var f=this.m_u.Normalize()-this.m_length;f=k(f,-.2,_);var d=-this.m_mass*f,p=j.MulSV(d,c,i.SolvePositionConstraints_s_P);return e.SelfMulSub(this.m_invMassA,p),n-=this.m_invIA*j.CrossVV(h,p),r.SelfMulAdd(this.m_invMassB,p),s+=this.m_invIB*j.CrossVV(u,p),t.positions[this.m_indexA].a=n,t.positions[this.m_indexB].a=s,P(f)F(_)&&v.SelfMul(_/V(b)),b>F(l)&&(d=!1),g.x+=v.x,g.y+=v.y}return d},i}(ki),Ni=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_frictionJoint)||this).localAnchorA=new j,i.localAnchorB=new j,i.maxForce=0,i.maxTorque=0,i}return s(i,e),i.prototype.Initialize=function(t,e,i){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(i,this.localAnchorA),this.bodyB.GetLocalPoint(i,this.localAnchorB)},i}(Oi),zi=function(t){function i(i){var n;return(n=t.call(this,i)||this).m_localAnchorA=new j,n.m_localAnchorB=new j,n.m_linearImpulse=new j,n.m_angularImpulse=0,n.m_maxForce=0,n.m_maxTorque=0,n.m_indexA=0,n.m_indexB=0,n.m_rA=new j,n.m_rB=new j,n.m_localCenterA=new j,n.m_localCenterB=new j,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_linearMass=new Y,n.m_angularMass=0,n.m_qA=new K,n.m_qB=new K,n.m_lalcA=new j,n.m_lalcB=new j,n.m_K=new Y,n.m_localAnchorA.Copy(i.localAnchorA),n.m_localAnchorB.Copy(i.localAnchorB),n.m_linearImpulse.SetZero(),n.m_maxForce=e(i.maxForce,0),n.m_maxTorque=e(i.maxTorque,0),n.m_linearMass.SetZero(),n}s(i,t);var n=i.prototype;return n.InitVelocityConstraints=function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].a,i=t.velocities[this.m_indexA].v,n=t.velocities[this.m_indexA].w,r=t.positions[this.m_indexB].a,s=t.velocities[this.m_indexB].v,a=t.velocities[this.m_indexB].w,o=this.m_qA.SetAngle(e),h=this.m_qB.SetAngle(r);j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var u=K.MulRV(o,this.m_lalcA,this.m_rA);j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var l=K.MulRV(h,this.m_lalcB,this.m_rB),c=this.m_invMassA,f=this.m_invMassB,_=this.m_invIA,d=this.m_invIB,p=this.m_K;if(p.ex.x=c+f+_*u.y*u.y+d*l.y*l.y,p.ex.y=-_*u.x*u.y-d*l.x*l.y,p.ey.x=p.ex.y,p.ey.y=c+f+_*u.x*u.x+d*l.x*l.x,p.GetInverse(this.m_linearMass),this.m_angularMass=_+d,this.m_angularMass>0&&(this.m_angularMass=1/this.m_angularMass),t.step.warmStarting){this.m_linearImpulse.SelfMul(t.step.dtRatio),this.m_angularImpulse*=t.step.dtRatio;var m=this.m_linearImpulse;i.SelfMulSub(c,m),n-=_*(j.CrossVV(this.m_rA,m)+this.m_angularImpulse),s.SelfMulAdd(f,m),a+=d*(j.CrossVV(this.m_rB,m)+this.m_angularImpulse)}else this.m_linearImpulse.SetZero(),this.m_angularImpulse=0;t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=a},n.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexA].v,n=t.velocities[this.m_indexA].w,r=t.velocities[this.m_indexB].v,s=t.velocities[this.m_indexB].w,a=this.m_invMassA,o=this.m_invMassB,h=this.m_invIA,u=this.m_invIB,l=t.step.dt,c=s-n,f=-this.m_angularMass*c,_=this.m_angularImpulse,d=l*this.m_maxTorque;this.m_angularImpulse=k(this.m_angularImpulse+f,-d,d),n-=h*(f=this.m_angularImpulse-_),s+=u*f;var p=j.SubVV(j.AddVCrossSV(r,s,this.m_rB,j.s_t0),j.AddVCrossSV(e,n,this.m_rA,j.s_t1),i.SolveVelocityConstraints_s_Cdot_v2),m=Y.MulMV(this.m_linearMass,p,i.SolveVelocityConstraints_s_impulseV).SelfNeg(),g=i.SolveVelocityConstraints_s_oldImpulseV.Copy(this.m_linearImpulse);this.m_linearImpulse.SelfAdd(m);var y=l*this.m_maxForce;this.m_linearImpulse.LengthSquared()>y*y&&(this.m_linearImpulse.Normalize(),this.m_linearImpulse.SelfMul(y)),j.SubVV(this.m_linearImpulse,g,m),e.SelfMulSub(a,m),n-=h*j.CrossVV(this.m_rA,m),r.SelfMulAdd(o,m),s+=u*j.CrossVV(this.m_rB,m),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=s},n.SolvePositionConstraints=function(){return!0},n.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},n.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},n.GetReactionForce=function(t,e){return e.x=t*this.m_linearImpulse.x,e.y=t*this.m_linearImpulse.y,e},n.GetReactionTorque=function(t){return t*this.m_angularImpulse},n.GetLocalAnchorA=function(){return this.m_localAnchorA},n.GetLocalAnchorB=function(){return this.m_localAnchorB},n.SetMaxForce=function(t){this.m_maxForce=t},n.GetMaxForce=function(){return this.m_maxForce},n.SetMaxTorque=function(t){this.m_maxTorque=t},n.GetMaxTorque=function(){return this.m_maxTorque},n.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2FrictionJointDef = new b2FrictionJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.maxForce = %.15f;\n",this.m_maxForce),t(" jd.maxTorque = %.15f;\n",this.m_maxTorque),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},i}(ki);zi.SolveVelocityConstraints_s_Cdot_v2=new j,zi.SolveVelocityConstraints_s_impulseV=new j,zi.SolveVelocityConstraints_s_oldImpulseV=new j;var Ui=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_gearJoint)||this).ratio=1,i}return s(i,e),i}(Oi),Gi=function(i){function n(n){var r,s,a;(r=i.call(this,n)||this).m_typeA=t.b2JointType.e_unknownJoint,r.m_typeB=t.b2JointType.e_unknownJoint,r.m_localAnchorA=new j,r.m_localAnchorB=new j,r.m_localAnchorC=new j,r.m_localAnchorD=new j,r.m_localAxisC=new j,r.m_localAxisD=new j,r.m_referenceAngleA=0,r.m_referenceAngleB=0,r.m_constant=0,r.m_ratio=0,r.m_impulse=0,r.m_indexA=0,r.m_indexB=0,r.m_indexC=0,r.m_indexD=0,r.m_lcA=new j,r.m_lcB=new j,r.m_lcC=new j,r.m_lcD=new j,r.m_mA=0,r.m_mB=0,r.m_mC=0,r.m_mD=0,r.m_iA=0,r.m_iB=0,r.m_iC=0,r.m_iD=0,r.m_JvAC=new j,r.m_JvBD=new j,r.m_JwA=0,r.m_JwB=0,r.m_JwC=0,r.m_JwD=0,r.m_mass=0,r.m_qA=new K,r.m_qB=new K,r.m_qC=new K,r.m_qD=new K,r.m_lalcA=new j,r.m_lalcB=new j,r.m_lalcC=new j,r.m_lalcD=new j,r.m_joint1=n.joint1,r.m_joint2=n.joint2,r.m_typeA=r.m_joint1.GetType(),r.m_typeB=r.m_joint2.GetType(),r.m_bodyC=r.m_joint1.GetBodyA(),r.m_bodyA=r.m_joint1.GetBodyB();var o=r.m_bodyA.m_xf,h=r.m_bodyA.m_sweep.a,u=r.m_bodyC.m_xf,l=r.m_bodyC.m_sweep.a;if(r.m_typeA===t.b2JointType.e_revoluteJoint){var c=n.joint1;r.m_localAnchorC.Copy(c.m_localAnchorA),r.m_localAnchorA.Copy(c.m_localAnchorB),r.m_referenceAngleA=c.m_referenceAngle,r.m_localAxisC.SetZero(),s=h-l-r.m_referenceAngleA}else{var f=n.joint1;r.m_localAnchorC.Copy(f.m_localAnchorA),r.m_localAnchorA.Copy(f.m_localAnchorB),r.m_referenceAngleA=f.m_referenceAngle,r.m_localAxisC.Copy(f.m_localXAxisA);var _=r.m_localAnchorC,d=K.MulTRV(u.q,j.AddVV(K.MulRV(o.q,r.m_localAnchorA,j.s_t0),j.SubVV(o.p,u.p,j.s_t1),j.s_t0),j.s_t0);s=j.DotVV(j.SubVV(d,_,j.s_t0),r.m_localAxisC)}r.m_bodyD=r.m_joint2.GetBodyA(),r.m_bodyB=r.m_joint2.GetBodyB();var p=r.m_bodyB.m_xf,m=r.m_bodyB.m_sweep.a,g=r.m_bodyD.m_xf,y=r.m_bodyD.m_sweep.a;if(r.m_typeB===t.b2JointType.e_revoluteJoint){var v=n.joint2;r.m_localAnchorD.Copy(v.m_localAnchorA),r.m_localAnchorB.Copy(v.m_localAnchorB),r.m_referenceAngleB=v.m_referenceAngle,r.m_localAxisD.SetZero(),a=m-y-r.m_referenceAngleB}else{var b=n.joint2;r.m_localAnchorD.Copy(b.m_localAnchorA),r.m_localAnchorB.Copy(b.m_localAnchorB),r.m_referenceAngleB=b.m_referenceAngle,r.m_localAxisD.Copy(b.m_localXAxisA);var S=r.m_localAnchorD,w=K.MulTRV(g.q,j.AddVV(K.MulRV(p.q,r.m_localAnchorB,j.s_t0),j.SubVV(p.p,g.p,j.s_t1),j.s_t0),j.s_t0);a=j.DotVV(j.SubVV(w,S,j.s_t0),r.m_localAxisD)}return r.m_ratio=e(n.ratio,1),r.m_constant=s+r.m_ratio*a,r.m_impulse=0,r}s(n,i);var r=n.prototype;return r.InitVelocityConstraints=function(e){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_indexC=this.m_bodyC.m_islandIndex,this.m_indexD=this.m_bodyD.m_islandIndex,this.m_lcA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_lcB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_lcC.Copy(this.m_bodyC.m_sweep.localCenter),this.m_lcD.Copy(this.m_bodyD.m_sweep.localCenter),this.m_mA=this.m_bodyA.m_invMass,this.m_mB=this.m_bodyB.m_invMass,this.m_mC=this.m_bodyC.m_invMass,this.m_mD=this.m_bodyD.m_invMass,this.m_iA=this.m_bodyA.m_invI,this.m_iB=this.m_bodyB.m_invI,this.m_iC=this.m_bodyC.m_invI,this.m_iD=this.m_bodyD.m_invI;var i=e.positions[this.m_indexA].a,r=e.velocities[this.m_indexA].v,s=e.velocities[this.m_indexA].w,a=e.positions[this.m_indexB].a,o=e.velocities[this.m_indexB].v,h=e.velocities[this.m_indexB].w,u=e.positions[this.m_indexC].a,l=e.velocities[this.m_indexC].v,c=e.velocities[this.m_indexC].w,f=e.positions[this.m_indexD].a,_=e.velocities[this.m_indexD].v,d=e.velocities[this.m_indexD].w,p=this.m_qA.SetAngle(i),m=this.m_qB.SetAngle(a),g=this.m_qC.SetAngle(u),y=this.m_qD.SetAngle(f);if(this.m_mass=0,this.m_typeA===t.b2JointType.e_revoluteJoint)this.m_JvAC.SetZero(),this.m_JwA=1,this.m_JwC=1,this.m_mass+=this.m_iA+this.m_iC;else{var v=K.MulRV(g,this.m_localAxisC,n.InitVelocityConstraints_s_u);j.SubVV(this.m_localAnchorC,this.m_lcC,this.m_lalcC);var b=K.MulRV(g,this.m_lalcC,n.InitVelocityConstraints_s_rC);j.SubVV(this.m_localAnchorA,this.m_lcA,this.m_lalcA);var S=K.MulRV(p,this.m_lalcA,n.InitVelocityConstraints_s_rA);this.m_JvAC.Copy(v),this.m_JwC=j.CrossVV(b,v),this.m_JwA=j.CrossVV(S,v),this.m_mass+=this.m_mC+this.m_mA+this.m_iC*this.m_JwC*this.m_JwC+this.m_iA*this.m_JwA*this.m_JwA}if(this.m_typeB===t.b2JointType.e_revoluteJoint)this.m_JvBD.SetZero(),this.m_JwB=this.m_ratio,this.m_JwD=this.m_ratio,this.m_mass+=this.m_ratio*this.m_ratio*(this.m_iB+this.m_iD);else{var w=K.MulRV(y,this.m_localAxisD,n.InitVelocityConstraints_s_u);j.SubVV(this.m_localAnchorD,this.m_lcD,this.m_lalcD);var x=K.MulRV(y,this.m_lalcD,n.InitVelocityConstraints_s_rD);j.SubVV(this.m_localAnchorB,this.m_lcB,this.m_lalcB);var T=K.MulRV(m,this.m_lalcB,n.InitVelocityConstraints_s_rB);j.MulSV(this.m_ratio,w,this.m_JvBD),this.m_JwD=this.m_ratio*j.CrossVV(x,w),this.m_JwB=this.m_ratio*j.CrossVV(T,w),this.m_mass+=this.m_ratio*this.m_ratio*(this.m_mD+this.m_mB)+this.m_iD*this.m_JwD*this.m_JwD+this.m_iB*this.m_JwB*this.m_JwB}this.m_mass=this.m_mass>0?1/this.m_mass:0,e.step.warmStarting?(r.SelfMulAdd(this.m_mA*this.m_impulse,this.m_JvAC),s+=this.m_iA*this.m_impulse*this.m_JwA,o.SelfMulAdd(this.m_mB*this.m_impulse,this.m_JvBD),h+=this.m_iB*this.m_impulse*this.m_JwB,l.SelfMulSub(this.m_mC*this.m_impulse,this.m_JvAC),c-=this.m_iC*this.m_impulse*this.m_JwC,_.SelfMulSub(this.m_mD*this.m_impulse,this.m_JvBD),d-=this.m_iD*this.m_impulse*this.m_JwD):this.m_impulse=0,e.velocities[this.m_indexA].w=s,e.velocities[this.m_indexB].w=h,e.velocities[this.m_indexC].w=c,e.velocities[this.m_indexD].w=d},r.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexA].v,i=t.velocities[this.m_indexA].w,n=t.velocities[this.m_indexB].v,r=t.velocities[this.m_indexB].w,s=t.velocities[this.m_indexC].v,a=t.velocities[this.m_indexC].w,o=t.velocities[this.m_indexD].v,h=t.velocities[this.m_indexD].w,u=j.DotVV(this.m_JvAC,j.SubVV(e,s,j.s_t0))+j.DotVV(this.m_JvBD,j.SubVV(n,o,j.s_t0));u+=this.m_JwA*i-this.m_JwC*a+(this.m_JwB*r-this.m_JwD*h);var l=-this.m_mass*u;this.m_impulse+=l,e.SelfMulAdd(this.m_mA*l,this.m_JvAC),i+=this.m_iA*l*this.m_JwA,n.SelfMulAdd(this.m_mB*l,this.m_JvBD),r+=this.m_iB*l*this.m_JwB,s.SelfMulSub(this.m_mC*l,this.m_JvAC),a-=this.m_iC*l*this.m_JwC,o.SelfMulSub(this.m_mD*l,this.m_JvBD),h-=this.m_iD*l*this.m_JwD,t.velocities[this.m_indexA].w=i,t.velocities[this.m_indexB].w=r,t.velocities[this.m_indexC].w=a,t.velocities[this.m_indexD].w=h},r.SolvePositionConstraints=function(e){var i,r,s,a,o,h,u=e.positions[this.m_indexA].c,l=e.positions[this.m_indexA].a,c=e.positions[this.m_indexB].c,f=e.positions[this.m_indexB].a,_=e.positions[this.m_indexC].c,d=e.positions[this.m_indexC].a,p=e.positions[this.m_indexD].c,m=e.positions[this.m_indexD].a,g=this.m_qA.SetAngle(l),y=this.m_qB.SetAngle(f),v=this.m_qC.SetAngle(d),b=this.m_qD.SetAngle(m),S=this.m_JvAC,w=this.m_JvBD,x=0;if(this.m_typeA===t.b2JointType.e_revoluteJoint)S.SetZero(),s=1,o=1,x+=this.m_iA+this.m_iC,i=l-d-this.m_referenceAngleA;else{var T=K.MulRV(v,this.m_localAxisC,n.SolvePositionConstraints_s_u),A=K.MulRV(v,this.m_lalcC,n.SolvePositionConstraints_s_rC),C=K.MulRV(g,this.m_lalcA,n.SolvePositionConstraints_s_rA);S.Copy(T),o=j.CrossVV(A,T),s=j.CrossVV(C,T),x+=this.m_mC+this.m_mA+this.m_iC*o*o+this.m_iA*s*s;var D=this.m_lalcC,B=K.MulTRV(v,j.AddVV(C,j.SubVV(u,_,j.s_t0),j.s_t0),j.s_t0);i=j.DotVV(j.SubVV(B,D,j.s_t0),this.m_localAxisC)}if(this.m_typeB===t.b2JointType.e_revoluteJoint)w.SetZero(),a=this.m_ratio,h=this.m_ratio,x+=this.m_ratio*this.m_ratio*(this.m_iB+this.m_iD),r=f-m-this.m_referenceAngleB;else{var I=K.MulRV(b,this.m_localAxisD,n.SolvePositionConstraints_s_u),M=K.MulRV(b,this.m_lalcD,n.SolvePositionConstraints_s_rD),P=K.MulRV(y,this.m_lalcB,n.SolvePositionConstraints_s_rB);j.MulSV(this.m_ratio,I,w),h=this.m_ratio*j.CrossVV(M,I),a=this.m_ratio*j.CrossVV(P,I),x+=this.m_ratio*this.m_ratio*(this.m_mD+this.m_mB)+this.m_iD*h*h+this.m_iB*a*a;var E=this.m_lalcD,O=K.MulTRV(b,j.AddVV(P,j.SubVV(c,p,j.s_t0),j.s_t0),j.s_t0);r=j.DotVV(j.SubVV(O,E,j.s_t0),this.m_localAxisD)}var k=i+this.m_ratio*r-this.m_constant,R=0;return x>0&&(R=-k/x),u.SelfMulAdd(this.m_mA*R,S),l+=this.m_iA*R*s,c.SelfMulAdd(this.m_mB*R,w),f+=this.m_iB*R*a,_.SelfMulSub(this.m_mC*R,S),d-=this.m_iC*R*o,p.SelfMulSub(this.m_mD*R,w),m-=this.m_iD*R*h,e.positions[this.m_indexA].a=l,e.positions[this.m_indexB].a=f,e.positions[this.m_indexC].a=d,e.positions[this.m_indexD].a=m,!0},r.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},r.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},r.GetReactionForce=function(t,e){return j.MulSV(t*this.m_impulse,this.m_JvAC,e)},r.GetReactionTorque=function(t){return t*this.m_impulse*this.m_JwA},r.GetJoint1=function(){return this.m_joint1},r.GetJoint2=function(){return this.m_joint2},r.GetRatio=function(){return this.m_ratio},r.SetRatio=function(t){this.m_ratio=t},r.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex,n=this.m_joint1.m_index,r=this.m_joint2.m_index;t(" const jd: b2GearJointDef = new b2GearJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.joint1 = joints[%d];\n",n),t(" jd.joint2 = joints[%d];\n",r),t(" jd.ratio = %.15f;\n",this.m_ratio),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},n}(ki);Gi.InitVelocityConstraints_s_u=new j,Gi.InitVelocityConstraints_s_rA=new j,Gi.InitVelocityConstraints_s_rB=new j,Gi.InitVelocityConstraints_s_rC=new j,Gi.InitVelocityConstraints_s_rD=new j,Gi.SolvePositionConstraints_s_u=new j,Gi.SolvePositionConstraints_s_rA=new j,Gi.SolvePositionConstraints_s_rB=new j,Gi.SolvePositionConstraints_s_rC=new j,Gi.SolvePositionConstraints_s_rD=new j;var Hi=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_motorJoint)||this).linearOffset=new j(0,0),i.angularOffset=0,i.maxForce=1,i.maxTorque=1,i.correctionFactor=.3,i}return s(i,e),i.prototype.Initialize=function(t,e){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(this.bodyB.GetPosition(),this.linearOffset);var i=this.bodyA.GetAngle(),n=this.bodyB.GetAngle();this.angularOffset=n-i},i}(Oi),Wi=function(t){function i(i){var n;return(n=t.call(this,i)||this).m_linearOffset=new j,n.m_angularOffset=0,n.m_linearImpulse=new j,n.m_angularImpulse=0,n.m_maxForce=0,n.m_maxTorque=0,n.m_correctionFactor=.3,n.m_indexA=0,n.m_indexB=0,n.m_rA=new j,n.m_rB=new j,n.m_localCenterA=new j,n.m_localCenterB=new j,n.m_linearError=new j,n.m_angularError=0,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_linearMass=new Y,n.m_angularMass=0,n.m_qA=new K,n.m_qB=new K,n.m_K=new Y,n.m_linearOffset.Copy(e(i.linearOffset,j.ZERO)),n.m_linearImpulse.SetZero(),n.m_maxForce=e(i.maxForce,0),n.m_maxTorque=e(i.maxTorque,0),n.m_correctionFactor=e(i.correctionFactor,.3),n}s(i,t);var n=i.prototype;return n.GetAnchorA=function(t){var e=this.m_bodyA.GetPosition();return t.x=e.x,t.y=e.y,t},n.GetAnchorB=function(t){var e=this.m_bodyB.GetPosition();return t.x=e.x,t.y=e.y,t},n.GetReactionForce=function(t,e){return j.MulSV(t,this.m_linearImpulse,e)},n.GetReactionTorque=function(t){return t*this.m_angularImpulse},n.SetLinearOffset=function(t){j.IsEqualToV(t,this.m_linearOffset)||(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_linearOffset.Copy(t))},n.GetLinearOffset=function(){return this.m_linearOffset},n.SetAngularOffset=function(t){t!==this.m_angularOffset&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_angularOffset=t)},n.GetAngularOffset=function(){return this.m_angularOffset},n.SetMaxForce=function(t){this.m_maxForce=t},n.GetMaxForce=function(){return this.m_maxForce},n.SetMaxTorque=function(t){this.m_maxTorque=t},n.GetMaxTorque=function(){return this.m_maxTorque},n.InitVelocityConstraints=function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].c,i=t.positions[this.m_indexA].a,n=t.velocities[this.m_indexA].v,r=t.velocities[this.m_indexA].w,s=t.positions[this.m_indexB].c,a=t.positions[this.m_indexB].a,o=t.velocities[this.m_indexB].v,h=t.velocities[this.m_indexB].w,u=this.m_qA.SetAngle(i),l=this.m_qB.SetAngle(a),c=K.MulRV(u,j.SubVV(this.m_linearOffset,this.m_localCenterA,j.s_t0),this.m_rA),f=K.MulRV(l,j.NegV(this.m_localCenterB,j.s_t0),this.m_rB),_=this.m_invMassA,d=this.m_invMassB,p=this.m_invIA,m=this.m_invIB,g=this.m_K;if(g.ex.x=_+d+p*c.y*c.y+m*f.y*f.y,g.ex.y=-p*c.x*c.y-m*f.x*f.y,g.ey.x=g.ex.y,g.ey.y=_+d+p*c.x*c.x+m*f.x*f.x,g.GetInverse(this.m_linearMass),this.m_angularMass=p+m,this.m_angularMass>0&&(this.m_angularMass=1/this.m_angularMass),j.SubVV(j.AddVV(s,f,j.s_t0),j.AddVV(e,c,j.s_t1),this.m_linearError),this.m_angularError=a-i-this.m_angularOffset,t.step.warmStarting){this.m_linearImpulse.SelfMul(t.step.dtRatio),this.m_angularImpulse*=t.step.dtRatio;var y=this.m_linearImpulse;n.SelfMulSub(_,y),r-=p*(j.CrossVV(c,y)+this.m_angularImpulse),o.SelfMulAdd(d,y),h+=m*(j.CrossVV(f,y)+this.m_angularImpulse)}else this.m_linearImpulse.SetZero(),this.m_angularImpulse=0;t.velocities[this.m_indexA].w=r,t.velocities[this.m_indexB].w=h},n.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexA].v,n=t.velocities[this.m_indexA].w,r=t.velocities[this.m_indexB].v,s=t.velocities[this.m_indexB].w,a=this.m_invMassA,o=this.m_invMassB,h=this.m_invIA,u=this.m_invIB,l=t.step.dt,c=t.step.inv_dt,f=s-n+c*this.m_correctionFactor*this.m_angularError,_=-this.m_angularMass*f,d=this.m_angularImpulse,p=l*this.m_maxTorque;this.m_angularImpulse=k(this.m_angularImpulse+_,-p,p),n-=h*(_=this.m_angularImpulse-d),s+=u*_;var m=this.m_rA,g=this.m_rB,y=j.AddVV(j.SubVV(j.AddVV(r,j.CrossSV(s,g,j.s_t0),j.s_t0),j.AddVV(e,j.CrossSV(n,m,j.s_t1),j.s_t1),j.s_t2),j.MulSV(c*this.m_correctionFactor,this.m_linearError,j.s_t3),i.SolveVelocityConstraints_s_Cdot_v2),v=Y.MulMV(this.m_linearMass,y,i.SolveVelocityConstraints_s_impulse_v2).SelfNeg(),b=i.SolveVelocityConstraints_s_oldImpulse_v2.Copy(this.m_linearImpulse);this.m_linearImpulse.SelfAdd(v);var S=l*this.m_maxForce;this.m_linearImpulse.LengthSquared()>S*S&&(this.m_linearImpulse.Normalize(),this.m_linearImpulse.SelfMul(S)),j.SubVV(this.m_linearImpulse,b,v),e.SelfMulSub(a,v),n-=h*j.CrossVV(m,v),r.SelfMulAdd(o,v),s+=u*j.CrossVV(g,v),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=s},n.SolvePositionConstraints=function(){return!0},n.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2MotorJointDef = new b2MotorJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.linearOffset.Set(%.15f, %.15f);\n",this.m_linearOffset.x,this.m_linearOffset.y),t(" jd.angularOffset = %.15f;\n",this.m_angularOffset),t(" jd.maxForce = %.15f;\n",this.m_maxForce),t(" jd.maxTorque = %.15f;\n",this.m_maxTorque),t(" jd.correctionFactor = %.15f;\n",this.m_correctionFactor),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},i}(ki);Wi.SolveVelocityConstraints_s_Cdot_v2=new j,Wi.SolveVelocityConstraints_s_impulse_v2=new j,Wi.SolveVelocityConstraints_s_oldImpulse_v2=new j;var ji=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_mouseJoint)||this).target=new j,i.maxForce=0,i.frequencyHz=5,i.dampingRatio=.7,i}return s(i,e),i}(Oi),qi=function(t){function i(i){var n;return(n=t.call(this,i)||this).m_localAnchorB=new j,n.m_targetA=new j,n.m_frequencyHz=0,n.m_dampingRatio=0,n.m_beta=0,n.m_impulse=new j,n.m_maxForce=0,n.m_gamma=0,n.m_indexA=0,n.m_indexB=0,n.m_rB=new j,n.m_localCenterB=new j,n.m_invMassB=0,n.m_invIB=0,n.m_mass=new Y,n.m_C=new j,n.m_qB=new K,n.m_lalcB=new j,n.m_K=new Y,n.m_targetA.Copy(e(i.target,j.ZERO)),Q.MulTXV(n.m_bodyB.GetTransform(),n.m_targetA,n.m_localAnchorB),n.m_maxForce=e(i.maxForce,0),n.m_impulse.SetZero(),n.m_frequencyHz=e(i.frequencyHz,0),n.m_dampingRatio=e(i.dampingRatio,0),n.m_beta=0,n.m_gamma=0,n}s(i,t);var n=i.prototype;return n.SetTarget=function(t){this.m_bodyB.IsAwake()||this.m_bodyB.SetAwake(!0),this.m_targetA.Copy(t)},n.GetTarget=function(){return this.m_targetA},n.SetMaxForce=function(t){this.m_maxForce=t},n.GetMaxForce=function(){return this.m_maxForce},n.SetFrequency=function(t){this.m_frequencyHz=t},n.GetFrequency=function(){return this.m_frequencyHz},n.SetDampingRatio=function(t){this.m_dampingRatio=t},n.GetDampingRatio=function(){return this.m_dampingRatio},n.InitVelocityConstraints=function(t){this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexB].c,i=t.positions[this.m_indexB].a,n=t.velocities[this.m_indexB].v,r=t.velocities[this.m_indexB].w,s=this.m_qB.SetAngle(i),a=this.m_bodyB.GetMass(),h=2*o*this.m_frequencyHz,u=2*a*this.m_dampingRatio*h,l=a*h*h,c=t.step.dt;this.m_gamma=c*(u+c*l),0!==this.m_gamma&&(this.m_gamma=1/this.m_gamma),this.m_beta=c*l*this.m_gamma,j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),K.MulRV(s,this.m_lalcB,this.m_rB);var f=this.m_K;f.ex.x=this.m_invMassB+this.m_invIB*this.m_rB.y*this.m_rB.y+this.m_gamma,f.ex.y=-this.m_invIB*this.m_rB.x*this.m_rB.y,f.ey.x=f.ex.y,f.ey.y=this.m_invMassB+this.m_invIB*this.m_rB.x*this.m_rB.x+this.m_gamma,f.GetInverse(this.m_mass),this.m_C.x=e.x+this.m_rB.x-this.m_targetA.x,this.m_C.y=e.y+this.m_rB.y-this.m_targetA.y,this.m_C.SelfMul(this.m_beta),r*=.98,t.step.warmStarting?(this.m_impulse.SelfMul(t.step.dtRatio),n.x+=this.m_invMassB*this.m_impulse.x,n.y+=this.m_invMassB*this.m_impulse.y,r+=this.m_invIB*j.CrossVV(this.m_rB,this.m_impulse)):this.m_impulse.SetZero(),t.velocities[this.m_indexB].w=r},n.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexB].v,n=t.velocities[this.m_indexB].w,r=j.AddVCrossSV(e,n,this.m_rB,i.SolveVelocityConstraints_s_Cdot),s=Y.MulMV(this.m_mass,j.AddVV(r,j.AddVV(this.m_C,j.MulSV(this.m_gamma,this.m_impulse,j.s_t0),j.s_t0),j.s_t0).SelfNeg(),i.SolveVelocityConstraints_s_impulse),a=i.SolveVelocityConstraints_s_oldImpulse.Copy(this.m_impulse);this.m_impulse.SelfAdd(s);var o=t.step.dt*this.m_maxForce;this.m_impulse.LengthSquared()>o*o&&this.m_impulse.SelfMul(o/this.m_impulse.Length()),j.SubVV(this.m_impulse,a,s),e.SelfMulAdd(this.m_invMassB,s),n+=this.m_invIB*j.CrossVV(this.m_rB,s),t.velocities[this.m_indexB].w=n},n.SolvePositionConstraints=function(){return!0},n.GetAnchorA=function(t){return t.x=this.m_targetA.x,t.y=this.m_targetA.y,t},n.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},n.GetReactionForce=function(t,e){return j.MulSV(t,this.m_impulse,e)},n.GetReactionTorque=function(){return 0},n.Dump=function(t){t("Mouse joint dumping is not supported.\n")},n.ShiftOrigin=function(t){this.m_targetA.SelfSub(t)},i}(ki);qi.SolveVelocityConstraints_s_Cdot=new j,qi.SolveVelocityConstraints_s_impulse=new j,qi.SolveVelocityConstraints_s_oldImpulse=new j;var Xi=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_prismaticJoint)||this).localAnchorA=new j,i.localAnchorB=new j,i.localAxisA=new j(1,0),i.referenceAngle=0,i.enableLimit=!1,i.lowerTranslation=0,i.upperTranslation=0,i.enableMotor=!1,i.maxMotorForce=0,i.motorSpeed=0,i}return s(i,e),i.prototype.Initialize=function(t,e,i,n){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(i,this.localAnchorA),this.bodyB.GetLocalPoint(i,this.localAnchorB),this.bodyA.GetLocalVector(n,this.localAxisA),this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()},i}(Oi),Yi=function(i){function n(n){var r;return(r=i.call(this,n)||this).m_localAnchorA=new j,r.m_localAnchorB=new j,r.m_localXAxisA=new j,r.m_localYAxisA=new j,r.m_referenceAngle=0,r.m_impulse=new X(0,0,0),r.m_motorImpulse=0,r.m_lowerTranslation=0,r.m_upperTranslation=0,r.m_maxMotorForce=0,r.m_motorSpeed=0,r.m_enableLimit=!1,r.m_enableMotor=!1,r.m_limitState=t.b2LimitState.e_inactiveLimit,r.m_indexA=0,r.m_indexB=0,r.m_localCenterA=new j,r.m_localCenterB=new j,r.m_invMassA=0,r.m_invMassB=0,r.m_invIA=0,r.m_invIB=0,r.m_axis=new j(0,0),r.m_perp=new j(0,0),r.m_s1=0,r.m_s2=0,r.m_a1=0,r.m_a2=0,r.m_K=new J,r.m_K3=new J,r.m_K2=new Y,r.m_motorMass=0,r.m_qA=new K,r.m_qB=new K,r.m_lalcA=new j,r.m_lalcB=new j,r.m_rA=new j,r.m_rB=new j,r.m_localAnchorA.Copy(e(n.localAnchorA,j.ZERO)),r.m_localAnchorB.Copy(e(n.localAnchorB,j.ZERO)),r.m_localXAxisA.Copy(e(n.localAxisA,new j(1,0))).SelfNormalize(),j.CrossOneV(r.m_localXAxisA,r.m_localYAxisA),r.m_referenceAngle=e(n.referenceAngle,0),r.m_lowerTranslation=e(n.lowerTranslation,0),r.m_upperTranslation=e(n.upperTranslation,0),r.m_maxMotorForce=e(n.maxMotorForce,0),r.m_motorSpeed=e(n.motorSpeed,0),r.m_enableLimit=e(n.enableLimit,!1),r.m_enableMotor=e(n.enableMotor,!1),r}s(n,i);var r=n.prototype;return r.InitVelocityConstraints=function(e){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var i=e.positions[this.m_indexA].c,r=e.positions[this.m_indexA].a,s=e.velocities[this.m_indexA].v,a=e.velocities[this.m_indexA].w,o=e.positions[this.m_indexB].c,h=e.positions[this.m_indexB].a,u=e.velocities[this.m_indexB].v,l=e.velocities[this.m_indexB].w,c=this.m_qA.SetAngle(r),f=this.m_qB.SetAngle(h);j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var _=K.MulRV(c,this.m_lalcA,this.m_rA);j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var d=K.MulRV(f,this.m_lalcB,this.m_rB),p=j.AddVV(j.SubVV(o,i,j.s_t0),j.SubVV(d,_,j.s_t1),n.InitVelocityConstraints_s_d),m=this.m_invMassA,g=this.m_invMassB,y=this.m_invIA,v=this.m_invIB;if(K.MulRV(c,this.m_localXAxisA,this.m_axis),this.m_a1=j.CrossVV(j.AddVV(p,_,j.s_t0),this.m_axis),this.m_a2=j.CrossVV(d,this.m_axis),this.m_motorMass=m+g+y*this.m_a1*this.m_a1+v*this.m_a2*this.m_a2,this.m_motorMass>0&&(this.m_motorMass=1/this.m_motorMass),K.MulRV(c,this.m_localYAxisA,this.m_perp),this.m_s1=j.CrossVV(j.AddVV(p,_,j.s_t0),this.m_perp),this.m_s2=j.CrossVV(d,this.m_perp),this.m_K.ex.x=m+g+y*this.m_s1*this.m_s1+v*this.m_s2*this.m_s2,this.m_K.ex.y=y*this.m_s1+v*this.m_s2,this.m_K.ex.z=y*this.m_s1*this.m_a1+v*this.m_s2*this.m_a2,this.m_K.ey.x=this.m_K.ex.y,this.m_K.ey.y=y+v,0===this.m_K.ey.y&&(this.m_K.ey.y=1),this.m_K.ey.z=y*this.m_a1+v*this.m_a2,this.m_K.ez.x=this.m_K.ex.z,this.m_K.ez.y=this.m_K.ey.z,this.m_K.ez.z=m+g+y*this.m_a1*this.m_a1+v*this.m_a2*this.m_a2,this.m_enableLimit){var b=j.DotVV(this.m_axis,p);P(this.m_upperTranslation-this.m_lowerTranslation)<.016?this.m_limitState=t.b2LimitState.e_equalLimits:b<=this.m_lowerTranslation?this.m_limitState!==t.b2LimitState.e_atLowerLimit&&(this.m_limitState=t.b2LimitState.e_atLowerLimit,this.m_impulse.z=0):b>=this.m_upperTranslation?this.m_limitState!==t.b2LimitState.e_atUpperLimit&&(this.m_limitState=t.b2LimitState.e_atUpperLimit,this.m_impulse.z=0):(this.m_limitState=t.b2LimitState.e_inactiveLimit,this.m_impulse.z=0)}else this.m_limitState=t.b2LimitState.e_inactiveLimit,this.m_impulse.z=0;if(this.m_enableMotor||(this.m_motorImpulse=0),e.step.warmStarting){this.m_impulse.SelfMul(e.step.dtRatio),this.m_motorImpulse*=e.step.dtRatio;var S=j.AddVV(j.MulSV(this.m_impulse.x,this.m_perp,j.s_t0),j.MulSV(this.m_motorImpulse+this.m_impulse.z,this.m_axis,j.s_t1),n.InitVelocityConstraints_s_P),w=this.m_impulse.x*this.m_s1+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a1,x=this.m_impulse.x*this.m_s2+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a2;s.SelfMulSub(m,S),a-=y*w,u.SelfMulAdd(g,S),l+=v*x}else this.m_impulse.SetZero(),this.m_motorImpulse=0;e.velocities[this.m_indexA].w=a,e.velocities[this.m_indexB].w=l},r.SolveVelocityConstraints=function(e){var i=e.velocities[this.m_indexA].v,r=e.velocities[this.m_indexA].w,s=e.velocities[this.m_indexB].v,a=e.velocities[this.m_indexB].w,o=this.m_invMassA,h=this.m_invMassB,u=this.m_invIA,l=this.m_invIB;if(this.m_enableMotor&&this.m_limitState!==t.b2LimitState.e_equalLimits){var c=j.DotVV(this.m_axis,j.SubVV(s,i,j.s_t0))+this.m_a2*a-this.m_a1*r,f=this.m_motorMass*(this.m_motorSpeed-c),_=this.m_motorImpulse,d=e.step.dt*this.m_maxMotorForce;this.m_motorImpulse=k(this.m_motorImpulse+f,-d,d),f=this.m_motorImpulse-_;var p=j.MulSV(f,this.m_axis,n.SolveVelocityConstraints_s_P),m=f*this.m_a1,g=f*this.m_a2;i.SelfMulSub(o,p),r-=u*m,s.SelfMulAdd(h,p),a+=l*g}var y=j.DotVV(this.m_perp,j.SubVV(s,i,j.s_t0))+this.m_s2*a-this.m_s1*r,v=a-r;if(this.m_enableLimit&&this.m_limitState!==t.b2LimitState.e_inactiveLimit){var b=j.DotVV(this.m_axis,j.SubVV(s,i,j.s_t0))+this.m_a2*a-this.m_a1*r,S=n.SolveVelocityConstraints_s_f1.Copy(this.m_impulse),w=this.m_K.Solve33(-y,-v,-b,n.SolveVelocityConstraints_s_df3);this.m_impulse.SelfAdd(w),this.m_limitState===t.b2LimitState.e_atLowerLimit?this.m_impulse.z=O(this.m_impulse.z,0):this.m_limitState===t.b2LimitState.e_atUpperLimit&&(this.m_impulse.z=E(this.m_impulse.z,0));var x=-y-(this.m_impulse.z-S.z)*this.m_K.ez.x,T=-v-(this.m_impulse.z-S.z)*this.m_K.ez.y,A=this.m_K.Solve22(x,T,n.SolveVelocityConstraints_s_f2r);A.x+=S.x,A.y+=S.y,this.m_impulse.x=A.x,this.m_impulse.y=A.y,w.x=this.m_impulse.x-S.x,w.y=this.m_impulse.y-S.y,w.z=this.m_impulse.z-S.z;var C=j.AddVV(j.MulSV(w.x,this.m_perp,j.s_t0),j.MulSV(w.z,this.m_axis,j.s_t1),n.SolveVelocityConstraints_s_P),D=w.x*this.m_s1+w.y+w.z*this.m_a1,B=w.x*this.m_s2+w.y+w.z*this.m_a2;i.SelfMulSub(o,C),r-=u*D,s.SelfMulAdd(h,C),a+=l*B}else{var I=this.m_K.Solve22(-y,-v,n.SolveVelocityConstraints_s_df2);this.m_impulse.x+=I.x,this.m_impulse.y+=I.y;var M=j.MulSV(I.x,this.m_perp,n.SolveVelocityConstraints_s_P),P=I.x*this.m_s1+I.y,R=I.x*this.m_s2+I.y;i.SelfMulSub(o,M),r-=u*P,s.SelfMulAdd(h,M),a+=l*R}e.velocities[this.m_indexA].w=r,e.velocities[this.m_indexB].w=a},r.SolvePositionConstraints=function(t){var e=t.positions[this.m_indexA].c,i=t.positions[this.m_indexA].a,r=t.positions[this.m_indexB].c,s=t.positions[this.m_indexB].a,a=this.m_qA.SetAngle(i),o=this.m_qB.SetAngle(s),h=this.m_invMassA,u=this.m_invMassB,f=this.m_invIA,d=this.m_invIB,p=K.MulRV(a,this.m_lalcA,this.m_rA),m=K.MulRV(o,this.m_lalcB,this.m_rB),g=j.SubVV(j.AddVV(r,m,j.s_t0),j.AddVV(e,p,j.s_t1),n.SolvePositionConstraints_s_d),y=K.MulRV(a,this.m_localXAxisA,this.m_axis),v=j.CrossVV(j.AddVV(g,p,j.s_t0),y),b=j.CrossVV(m,y),S=K.MulRV(a,this.m_localYAxisA,this.m_perp),w=j.CrossVV(j.AddVV(g,p,j.s_t0),S),x=j.CrossVV(m,S),T=n.SolvePositionConstraints_s_impulse,A=j.DotVV(S,g),C=s-i-this.m_referenceAngle,D=P(A),B=P(C),I=!1,M=0;if(this.m_enableLimit){var E=j.DotVV(y,g);P(this.m_upperTranslation-this.m_lowerTranslation)<.016?(M=k(E,-.2,_),D=O(D,P(E)),I=!0):E<=this.m_lowerTranslation?(M=k(E-this.m_lowerTranslation+l,-.2,0),D=O(D,this.m_lowerTranslation-E),I=!0):E>=this.m_upperTranslation&&(M=k(E-this.m_upperTranslation-l,0,_),D=O(D,E-this.m_upperTranslation),I=!0)}if(I){var R=h+u+f*w*w+d*x*x,F=f*w+d*x,L=f*w*v+d*x*b,V=f+d;0===V&&(V=1);var N=f*v+d*b,z=h+u+f*v*v+d*b*b,U=this.m_K3;U.ex.SetXYZ(R,F,L),U.ey.SetXYZ(F,V,N),U.ez.SetXYZ(L,N,z),T=U.Solve33(-A,-C,-M,T)}else{var G=h+u+f*w*w+d*x*x,H=f*w+d*x,W=f+d;0===W&&(W=1);var q=this.m_K2;q.ex.Set(G,H),q.ey.Set(H,W);var X=q.Solve(-A,-C,n.SolvePositionConstraints_s_impulse1);T.x=X.x,T.y=X.y,T.z=0}var Y=j.AddVV(j.MulSV(T.x,S,j.s_t0),j.MulSV(T.z,y,j.s_t1),n.SolvePositionConstraints_s_P),J=T.x*w+T.y+T.z*v,Q=T.x*x+T.y+T.z*b;return e.SelfMulSub(h,Y),i-=f*J,r.SelfMulAdd(u,Y),s+=d*Q,t.positions[this.m_indexA].a=i,t.positions[this.m_indexB].a=s,D<=l&&B<=c},r.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},r.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},r.GetReactionForce=function(t,e){return e.x=t*(this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.x),e.y=t*(this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.y),e},r.GetReactionTorque=function(t){return t*this.m_impulse.y},r.GetLocalAnchorA=function(){return this.m_localAnchorA},r.GetLocalAnchorB=function(){return this.m_localAnchorB},r.GetLocalAxisA=function(){return this.m_localXAxisA},r.GetReferenceAngle=function(){return this.m_referenceAngle},r.GetJointTranslation=function(){var t=this.m_bodyA.GetWorldPoint(this.m_localAnchorA,n.GetJointTranslation_s_pA),e=this.m_bodyB.GetWorldPoint(this.m_localAnchorB,n.GetJointTranslation_s_pB),i=j.SubVV(e,t,n.GetJointTranslation_s_d),r=this.m_bodyA.GetWorldVector(this.m_localXAxisA,n.GetJointTranslation_s_axis);return j.DotVV(i,r)},r.GetJointSpeed=function(){var t=this.m_bodyA,e=this.m_bodyB;j.SubVV(this.m_localAnchorA,t.m_sweep.localCenter,this.m_lalcA);var i=K.MulRV(t.m_xf.q,this.m_lalcA,this.m_rA);j.SubVV(this.m_localAnchorB,e.m_sweep.localCenter,this.m_lalcB);var n=K.MulRV(e.m_xf.q,this.m_lalcB,this.m_rB),r=j.AddVV(t.m_sweep.c,i,j.s_t0),s=j.AddVV(e.m_sweep.c,n,j.s_t1),a=j.SubVV(s,r,j.s_t2),o=t.GetWorldVector(this.m_localXAxisA,this.m_axis),h=t.m_linearVelocity,u=e.m_linearVelocity,l=t.m_angularVelocity,c=e.m_angularVelocity;return j.DotVV(a,j.CrossSV(l,o,j.s_t0))+j.DotVV(o,j.SubVV(j.AddVCrossSV(u,c,n,j.s_t0),j.AddVCrossSV(h,l,i,j.s_t1),j.s_t0))},r.IsLimitEnabled=function(){return this.m_enableLimit},r.EnableLimit=function(t){t!==this.m_enableLimit&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableLimit=t,this.m_impulse.z=0)},r.GetLowerLimit=function(){return this.m_lowerTranslation},r.GetUpperLimit=function(){return this.m_upperTranslation},r.SetLimits=function(t,e){t===this.m_lowerTranslation&&e===this.m_upperTranslation||(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_lowerTranslation=t,this.m_upperTranslation=e,this.m_impulse.z=0)},r.IsMotorEnabled=function(){return this.m_enableMotor},r.EnableMotor=function(t){t!==this.m_enableMotor&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableMotor=t)},r.SetMotorSpeed=function(t){t!==this.m_motorSpeed&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_motorSpeed=t)},r.GetMotorSpeed=function(){return this.m_motorSpeed},r.SetMaxMotorForce=function(t){t!==this.m_maxMotorForce&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_maxMotorForce=t)},r.GetMaxMotorForce=function(){return this.m_maxMotorForce},r.GetMotorForce=function(t){return t*this.m_motorImpulse},r.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2PrismaticJointDef = new b2PrismaticJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.localAxisA.Set(%.15f, %.15f);\n",this.m_localXAxisA.x,this.m_localXAxisA.y),t(" jd.referenceAngle = %.15f;\n",this.m_referenceAngle),t(" jd.enableLimit = %s;\n",this.m_enableLimit?"true":"false"),t(" jd.lowerTranslation = %.15f;\n",this.m_lowerTranslation),t(" jd.upperTranslation = %.15f;\n",this.m_upperTranslation),t(" jd.enableMotor = %s;\n",this.m_enableMotor?"true":"false"),t(" jd.motorSpeed = %.15f;\n",this.m_motorSpeed),t(" jd.maxMotorForce = %.15f;\n",this.m_maxMotorForce),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},n}(ki);Yi.InitVelocityConstraints_s_d=new j,Yi.InitVelocityConstraints_s_P=new j,Yi.SolveVelocityConstraints_s_P=new j,Yi.SolveVelocityConstraints_s_f2r=new j,Yi.SolveVelocityConstraints_s_f1=new X,Yi.SolveVelocityConstraints_s_df3=new X,Yi.SolveVelocityConstraints_s_df2=new j,Yi.SolvePositionConstraints_s_d=new j,Yi.SolvePositionConstraints_s_impulse=new X,Yi.SolvePositionConstraints_s_impulse1=new j,Yi.SolvePositionConstraints_s_P=new j,Yi.GetJointTranslation_s_pA=new j,Yi.GetJointTranslation_s_pB=new j,Yi.GetJointTranslation_s_d=new j,Yi.GetJointTranslation_s_axis=new j;var Ji=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_pulleyJoint)||this).groundAnchorA=new j(-1,1),i.groundAnchorB=new j(1,1),i.localAnchorA=new j(-1,0),i.localAnchorB=new j(1,0),i.lengthA=0,i.lengthB=0,i.ratio=1,i.collideConnected=!0,i}return s(i,e),i.prototype.Initialize=function(t,e,i,n,r,s,a){this.bodyA=t,this.bodyB=e,this.groundAnchorA.Copy(i),this.groundAnchorB.Copy(n),this.bodyA.GetLocalPoint(r,this.localAnchorA),this.bodyB.GetLocalPoint(s,this.localAnchorB),this.lengthA=j.DistanceVV(r,i),this.lengthB=j.DistanceVV(s,n),this.ratio=a},i}(Oi),Ki=function(t){function i(i){var n;return(n=t.call(this,i)||this).m_groundAnchorA=new j,n.m_groundAnchorB=new j,n.m_lengthA=0,n.m_lengthB=0,n.m_localAnchorA=new j,n.m_localAnchorB=new j,n.m_constant=0,n.m_ratio=0,n.m_impulse=0,n.m_indexA=0,n.m_indexB=0,n.m_uA=new j,n.m_uB=new j,n.m_rA=new j,n.m_rB=new j,n.m_localCenterA=new j,n.m_localCenterB=new j,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_mass=0,n.m_qA=new K,n.m_qB=new K,n.m_lalcA=new j,n.m_lalcB=new j,n.m_groundAnchorA.Copy(e(i.groundAnchorA,new j(-1,1))),n.m_groundAnchorB.Copy(e(i.groundAnchorB,new j(1,0))),n.m_localAnchorA.Copy(e(i.localAnchorA,new j(-1,0))),n.m_localAnchorB.Copy(e(i.localAnchorB,new j(1,0))),n.m_lengthA=e(i.lengthA,0),n.m_lengthB=e(i.lengthB,0),n.m_ratio=e(i.ratio,1),n.m_constant=e(i.lengthA,0)+n.m_ratio*e(i.lengthB,0),n.m_impulse=0,n}s(i,t);var n=i.prototype;return n.InitVelocityConstraints=function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,r=t.velocities[this.m_indexA].v,s=t.velocities[this.m_indexA].w,a=t.positions[this.m_indexB].c,o=t.positions[this.m_indexB].a,h=t.velocities[this.m_indexB].v,u=t.velocities[this.m_indexB].w,l=this.m_qA.SetAngle(n),c=this.m_qB.SetAngle(o);j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA),K.MulRV(l,this.m_lalcA,this.m_rA),j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),K.MulRV(c,this.m_lalcB,this.m_rB),this.m_uA.Copy(e).SelfAdd(this.m_rA).SelfSub(this.m_groundAnchorA),this.m_uB.Copy(a).SelfAdd(this.m_rB).SelfSub(this.m_groundAnchorB);var f=this.m_uA.Length(),_=this.m_uB.Length();f>.08?this.m_uA.SelfMul(1/f):this.m_uA.SetZero(),_>.08?this.m_uB.SelfMul(1/_):this.m_uB.SetZero();var d=j.CrossVV(this.m_rA,this.m_uA),p=j.CrossVV(this.m_rB,this.m_uB),m=this.m_invMassA+this.m_invIA*d*d,g=this.m_invMassB+this.m_invIB*p*p;if(this.m_mass=m+this.m_ratio*this.m_ratio*g,this.m_mass>0&&(this.m_mass=1/this.m_mass),t.step.warmStarting){this.m_impulse*=t.step.dtRatio;var y=j.MulSV(-this.m_impulse,this.m_uA,i.InitVelocityConstraints_s_PA),v=j.MulSV(-this.m_ratio*this.m_impulse,this.m_uB,i.InitVelocityConstraints_s_PB);r.SelfMulAdd(this.m_invMassA,y),s+=this.m_invIA*j.CrossVV(this.m_rA,y),h.SelfMulAdd(this.m_invMassB,v),u+=this.m_invIB*j.CrossVV(this.m_rB,v)}else this.m_impulse=0;t.velocities[this.m_indexA].w=s,t.velocities[this.m_indexB].w=u},n.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexA].v,n=t.velocities[this.m_indexA].w,r=t.velocities[this.m_indexB].v,s=t.velocities[this.m_indexB].w,a=j.AddVCrossSV(e,n,this.m_rA,i.SolveVelocityConstraints_s_vpA),o=j.AddVCrossSV(r,s,this.m_rB,i.SolveVelocityConstraints_s_vpB),h=-j.DotVV(this.m_uA,a)-this.m_ratio*j.DotVV(this.m_uB,o),u=-this.m_mass*h;this.m_impulse+=u;var l=j.MulSV(-u,this.m_uA,i.SolveVelocityConstraints_s_PA),c=j.MulSV(-this.m_ratio*u,this.m_uB,i.SolveVelocityConstraints_s_PB);e.SelfMulAdd(this.m_invMassA,l),n+=this.m_invIA*j.CrossVV(this.m_rA,l),r.SelfMulAdd(this.m_invMassB,c),s+=this.m_invIB*j.CrossVV(this.m_rB,c),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=s},n.SolvePositionConstraints=function(t){var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,r=t.positions[this.m_indexB].c,s=t.positions[this.m_indexB].a,a=this.m_qA.SetAngle(n),o=this.m_qB.SetAngle(s);j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var h=K.MulRV(a,this.m_lalcA,this.m_rA);j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var u=K.MulRV(o,this.m_lalcB,this.m_rB),c=this.m_uA.Copy(e).SelfAdd(h).SelfSub(this.m_groundAnchorA),f=this.m_uB.Copy(r).SelfAdd(u).SelfSub(this.m_groundAnchorB),_=c.Length(),d=f.Length();_>.08?c.SelfMul(1/_):c.SetZero(),d>.08?f.SelfMul(1/d):f.SetZero();var p=j.CrossVV(h,c),m=j.CrossVV(u,f),g=this.m_invMassA+this.m_invIA*p*p,y=this.m_invMassB+this.m_invIB*m*m,v=g+this.m_ratio*this.m_ratio*y;v>0&&(v=1/v);var b=this.m_constant-_-this.m_ratio*d,S=P(b),w=-v*b,x=j.MulSV(-w,c,i.SolvePositionConstraints_s_PA),T=j.MulSV(-this.m_ratio*w,f,i.SolvePositionConstraints_s_PB);return e.SelfMulAdd(this.m_invMassA,x),n+=this.m_invIA*j.CrossVV(h,x),r.SelfMulAdd(this.m_invMassB,T),s+=this.m_invIB*j.CrossVV(u,T),t.positions[this.m_indexA].a=n,t.positions[this.m_indexB].a=s,S0&&(this.m_motorMass=1/this.m_motorMass),this.m_enableMotor&&!m||(this.m_motorImpulse=0),this.m_enableLimit&&!m){var g=a-i-this.m_referenceAngle;P(this.m_upperAngle-this.m_lowerAngle)<2*c?this.m_limitState=t.b2LimitState.e_equalLimits:g<=this.m_lowerAngle?(this.m_limitState!==t.b2LimitState.e_atLowerLimit&&(this.m_impulse.z=0),this.m_limitState=t.b2LimitState.e_atLowerLimit):g>=this.m_upperAngle?(this.m_limitState!==t.b2LimitState.e_atUpperLimit&&(this.m_impulse.z=0),this.m_limitState=t.b2LimitState.e_atUpperLimit):(this.m_limitState=t.b2LimitState.e_inactiveLimit,this.m_impulse.z=0)}else this.m_limitState=t.b2LimitState.e_inactiveLimit;if(e.step.warmStarting){this.m_impulse.SelfMul(e.step.dtRatio),this.m_motorImpulse*=e.step.dtRatio;var y=n.InitVelocityConstraints_s_P.Set(this.m_impulse.x,this.m_impulse.y);r.SelfMulSub(f,y),s-=d*(j.CrossVV(this.m_rA,y)+this.m_motorImpulse+this.m_impulse.z),o.SelfMulAdd(_,y),h+=p*(j.CrossVV(this.m_rB,y)+this.m_motorImpulse+this.m_impulse.z)}else this.m_impulse.SetZero(),this.m_motorImpulse=0;e.velocities[this.m_indexA].w=s,e.velocities[this.m_indexB].w=h},r.SolveVelocityConstraints=function(e){var i=e.velocities[this.m_indexA].v,r=e.velocities[this.m_indexA].w,s=e.velocities[this.m_indexB].v,a=e.velocities[this.m_indexB].w,o=this.m_invMassA,h=this.m_invMassB,u=this.m_invIA,l=this.m_invIB,c=u+l===0;if(this.m_enableMotor&&this.m_limitState!==t.b2LimitState.e_equalLimits&&!c){var f=a-r-this.m_motorSpeed,_=-this.m_motorMass*f,d=this.m_motorImpulse,p=e.step.dt*this.m_maxMotorTorque;this.m_motorImpulse=k(this.m_motorImpulse+_,-p,p),r-=u*(_=this.m_motorImpulse-d),a+=l*_}if(this.m_enableLimit&&this.m_limitState!==t.b2LimitState.e_inactiveLimit&&!c){var m=j.SubVV(j.AddVCrossSV(s,a,this.m_rB,j.s_t0),j.AddVCrossSV(i,r,this.m_rA,j.s_t1),n.SolveVelocityConstraints_s_Cdot1),g=a-r,y=this.m_mass.Solve33(m.x,m.y,g,n.SolveVelocityConstraints_s_impulse_v3).SelfNeg();if(this.m_limitState===t.b2LimitState.e_equalLimits)this.m_impulse.SelfAdd(y);else if(this.m_limitState===t.b2LimitState.e_atLowerLimit)if(this.m_impulse.z+y.z<0){var v=-m.x+this.m_impulse.z*this.m_mass.ez.x,b=-m.y+this.m_impulse.z*this.m_mass.ez.y,S=this.m_mass.Solve22(v,b,n.SolveVelocityConstraints_s_reduced_v2);y.x=S.x,y.y=S.y,y.z=-this.m_impulse.z,this.m_impulse.x+=S.x,this.m_impulse.y+=S.y,this.m_impulse.z=0}else this.m_impulse.SelfAdd(y);else if(this.m_limitState===t.b2LimitState.e_atUpperLimit)if(this.m_impulse.z+y.z>0){var w=-m.x+this.m_impulse.z*this.m_mass.ez.x,x=-m.y+this.m_impulse.z*this.m_mass.ez.y,T=this.m_mass.Solve22(w,x,n.SolveVelocityConstraints_s_reduced_v2);y.x=T.x,y.y=T.y,y.z=-this.m_impulse.z,this.m_impulse.x+=T.x,this.m_impulse.y+=T.y,this.m_impulse.z=0}else this.m_impulse.SelfAdd(y);var A=n.SolveVelocityConstraints_s_P.Set(y.x,y.y);i.SelfMulSub(o,A),r-=u*(j.CrossVV(this.m_rA,A)+y.z),s.SelfMulAdd(h,A),a+=l*(j.CrossVV(this.m_rB,A)+y.z)}else{var C=j.SubVV(j.AddVCrossSV(s,a,this.m_rB,j.s_t0),j.AddVCrossSV(i,r,this.m_rA,j.s_t1),n.SolveVelocityConstraints_s_Cdot_v2),D=this.m_mass.Solve22(-C.x,-C.y,n.SolveVelocityConstraints_s_impulse_v2);this.m_impulse.x+=D.x,this.m_impulse.y+=D.y,i.SelfMulSub(o,D),r-=u*j.CrossVV(this.m_rA,D),s.SelfMulAdd(h,D),a+=l*j.CrossVV(this.m_rB,D)}e.velocities[this.m_indexA].w=r,e.velocities[this.m_indexB].w=a},r.SolvePositionConstraints=function(e){var i,r=e.positions[this.m_indexA].c,s=e.positions[this.m_indexA].a,a=e.positions[this.m_indexB].c,o=e.positions[this.m_indexB].a,h=this.m_qA.SetAngle(s),u=this.m_qB.SetAngle(o),f=0,_=this.m_invIA+this.m_invIB===0;if(this.m_enableLimit&&this.m_limitState!==t.b2LimitState.e_inactiveLimit&&!_){var p=o-s-this.m_referenceAngle,m=0;if(this.m_limitState===t.b2LimitState.e_equalLimits){var g=k(p-this.m_lowerAngle,-.13962634015955555,d);m=-this.m_motorMass*g,f=P(g)}else if(this.m_limitState===t.b2LimitState.e_atLowerLimit){var y=p-this.m_lowerAngle;f=-y,y=k(y+c,-.13962634015955555,0),m=-this.m_motorMass*y}else if(this.m_limitState===t.b2LimitState.e_atUpperLimit){var v=p-this.m_upperAngle;f=v,v=k(v-c,0,d),m=-this.m_motorMass*v}s-=this.m_invIA*m,o+=this.m_invIB*m}h.SetAngle(s),u.SetAngle(o),j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var b=K.MulRV(h,this.m_lalcA,this.m_rA);j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var S=K.MulRV(u,this.m_lalcB,this.m_rB),w=j.SubVV(j.AddVV(a,S,j.s_t0),j.AddVV(r,b,j.s_t1),n.SolvePositionConstraints_s_C_v2);i=w.Length();var x=this.m_invMassA,T=this.m_invMassB,A=this.m_invIA,C=this.m_invIB,D=this.m_K;D.ex.x=x+T+A*b.y*b.y+C*S.y*S.y,D.ex.y=-A*b.x*b.y-C*S.x*S.y,D.ey.x=D.ex.y,D.ey.y=x+T+A*b.x*b.x+C*S.x*S.x;var B=D.Solve(w.x,w.y,n.SolvePositionConstraints_s_impulse).SelfNeg();return r.SelfMulSub(x,B),s-=A*j.CrossVV(b,B),a.SelfMulAdd(T,B),o+=C*j.CrossVV(S,B),e.positions[this.m_indexA].a=s,e.positions[this.m_indexB].a=o,i<=l&&f<=c},r.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},r.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},r.GetReactionForce=function(t,e){return e.x=t*this.m_impulse.x,e.y=t*this.m_impulse.y,e},r.GetReactionTorque=function(t){return t*this.m_impulse.z},r.GetLocalAnchorA=function(){return this.m_localAnchorA},r.GetLocalAnchorB=function(){return this.m_localAnchorB},r.GetReferenceAngle=function(){return this.m_referenceAngle},r.GetJointAngle=function(){return this.m_bodyB.m_sweep.a-this.m_bodyA.m_sweep.a-this.m_referenceAngle},r.GetJointSpeed=function(){return this.m_bodyB.m_angularVelocity-this.m_bodyA.m_angularVelocity},r.IsMotorEnabled=function(){return this.m_enableMotor},r.EnableMotor=function(t){t!==this.m_enableMotor&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableMotor=t)},r.GetMotorTorque=function(t){return t*this.m_motorImpulse},r.GetMotorSpeed=function(){return this.m_motorSpeed},r.SetMaxMotorTorque=function(t){t!==this.m_maxMotorTorque&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_maxMotorTorque=t)},r.GetMaxMotorTorque=function(){return this.m_maxMotorTorque},r.IsLimitEnabled=function(){return this.m_enableLimit},r.EnableLimit=function(t){t!==this.m_enableLimit&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableLimit=t,this.m_impulse.z=0)},r.GetLowerLimit=function(){return this.m_lowerAngle},r.GetUpperLimit=function(){return this.m_upperAngle},r.SetLimits=function(t,e){t===this.m_lowerAngle&&e===this.m_upperAngle||(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_impulse.z=0,this.m_lowerAngle=t,this.m_upperAngle=e)},r.SetMotorSpeed=function(t){t!==this.m_motorSpeed&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_motorSpeed=t)},r.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2RevoluteJointDef = new b2RevoluteJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.referenceAngle = %.15f;\n",this.m_referenceAngle),t(" jd.enableLimit = %s;\n",this.m_enableLimit?"true":"false"),t(" jd.lowerAngle = %.15f;\n",this.m_lowerAngle),t(" jd.upperAngle = %.15f;\n",this.m_upperAngle),t(" jd.enableMotor = %s;\n",this.m_enableMotor?"true":"false"),t(" jd.motorSpeed = %.15f;\n",this.m_motorSpeed),t(" jd.maxMotorTorque = %.15f;\n",this.m_maxMotorTorque),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},n}(ki);Zi.InitVelocityConstraints_s_P=new j,Zi.SolveVelocityConstraints_s_P=new j,Zi.SolveVelocityConstraints_s_Cdot_v2=new j,Zi.SolveVelocityConstraints_s_Cdot1=new j,Zi.SolveVelocityConstraints_s_impulse_v3=new X,Zi.SolveVelocityConstraints_s_reduced_v2=new j,Zi.SolveVelocityConstraints_s_impulse_v2=new j,Zi.SolvePositionConstraints_s_C_v2=new j,Zi.SolvePositionConstraints_s_impulse=new j;var $i=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_ropeJoint)||this).localAnchorA=new j(-1,0),i.localAnchorB=new j(1,0),i.maxLength=0,i}return s(i,e),i}(Oi),tn=function(i){function n(n){var r;return(r=i.call(this,n)||this).m_localAnchorA=new j,r.m_localAnchorB=new j,r.m_maxLength=0,r.m_length=0,r.m_impulse=0,r.m_indexA=0,r.m_indexB=0,r.m_u=new j,r.m_rA=new j,r.m_rB=new j,r.m_localCenterA=new j,r.m_localCenterB=new j,r.m_invMassA=0,r.m_invMassB=0,r.m_invIA=0,r.m_invIB=0,r.m_mass=0,r.m_state=t.b2LimitState.e_inactiveLimit,r.m_qA=new K,r.m_qB=new K,r.m_lalcA=new j,r.m_lalcB=new j,r.m_localAnchorA.Copy(e(n.localAnchorA,new j(-1,0))),r.m_localAnchorB.Copy(e(n.localAnchorB,new j(1,0))),r.m_maxLength=e(n.maxLength,0),r}s(n,i);var r=n.prototype;return r.InitVelocityConstraints=function(e){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var i=e.positions[this.m_indexA].c,r=e.positions[this.m_indexA].a,s=e.velocities[this.m_indexA].v,a=e.velocities[this.m_indexA].w,o=e.positions[this.m_indexB].c,h=e.positions[this.m_indexB].a,u=e.velocities[this.m_indexB].v,c=e.velocities[this.m_indexB].w,f=this.m_qA.SetAngle(r),_=this.m_qB.SetAngle(h);j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA),K.MulRV(f,this.m_lalcA,this.m_rA),j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),K.MulRV(_,this.m_lalcB,this.m_rB),this.m_u.Copy(o).SelfAdd(this.m_rB).SelfSub(i).SelfSub(this.m_rA),this.m_length=this.m_u.Length();var d=this.m_length-this.m_maxLength;if(this.m_state=d>0?t.b2LimitState.e_atUpperLimit:t.b2LimitState.e_inactiveLimit,!(this.m_length>l))return this.m_u.SetZero(),this.m_mass=0,void(this.m_impulse=0);this.m_u.SelfMul(1/this.m_length);var p=j.CrossVV(this.m_rA,this.m_u),m=j.CrossVV(this.m_rB,this.m_u),g=this.m_invMassA+this.m_invIA*p*p+this.m_invMassB+this.m_invIB*m*m;if(this.m_mass=0!==g?1/g:0,e.step.warmStarting){this.m_impulse*=e.step.dtRatio;var y=j.MulSV(this.m_impulse,this.m_u,n.InitVelocityConstraints_s_P);s.SelfMulSub(this.m_invMassA,y),a-=this.m_invIA*j.CrossVV(this.m_rA,y),u.SelfMulAdd(this.m_invMassB,y),c+=this.m_invIB*j.CrossVV(this.m_rB,y)}else this.m_impulse=0;e.velocities[this.m_indexA].w=a,e.velocities[this.m_indexB].w=c},r.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexA].v,i=t.velocities[this.m_indexA].w,r=t.velocities[this.m_indexB].v,s=t.velocities[this.m_indexB].w,a=j.AddVCrossSV(e,i,this.m_rA,n.SolveVelocityConstraints_s_vpA),o=j.AddVCrossSV(r,s,this.m_rB,n.SolveVelocityConstraints_s_vpB),h=this.m_length-this.m_maxLength,u=j.DotVV(this.m_u,j.SubVV(o,a,j.s_t0));h<0&&(u+=t.step.inv_dt*h);var l=-this.m_mass*u,c=this.m_impulse;this.m_impulse=E(0,this.m_impulse+l),l=this.m_impulse-c;var f=j.MulSV(l,this.m_u,n.SolveVelocityConstraints_s_P);e.SelfMulSub(this.m_invMassA,f),i-=this.m_invIA*j.CrossVV(this.m_rA,f),r.SelfMulAdd(this.m_invMassB,f),s+=this.m_invIB*j.CrossVV(this.m_rB,f),t.velocities[this.m_indexA].w=i,t.velocities[this.m_indexB].w=s},r.SolvePositionConstraints=function(t){var e=t.positions[this.m_indexA].c,i=t.positions[this.m_indexA].a,r=t.positions[this.m_indexB].c,s=t.positions[this.m_indexB].a,a=this.m_qA.SetAngle(i),o=this.m_qB.SetAngle(s);j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var h=K.MulRV(a,this.m_lalcA,this.m_rA);j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var u=K.MulRV(o,this.m_lalcB,this.m_rB),c=this.m_u.Copy(r).SelfAdd(u).SelfSub(e).SelfSub(h),f=c.Normalize(),d=f-this.m_maxLength;d=k(d,0,_);var p=-this.m_mass*d,m=j.MulSV(p,c,n.SolvePositionConstraints_s_P);return e.SelfMulSub(this.m_invMassA,m),i-=this.m_invIA*j.CrossVV(h,m),r.SelfMulAdd(this.m_invMassB,m),s+=this.m_invIB*j.CrossVV(u,m),t.positions[this.m_indexA].a=i,t.positions[this.m_indexB].a=s,f-this.m_maxLength0){p.GetInverse22(this.m_mass);var m=_+d,g=m>0?1/m:0,y=s-e-this.m_referenceAngle,v=2*o*this.m_frequencyHz,b=2*g*this.m_dampingRatio*v,S=g*v*v,w=t.step.dt;this.m_gamma=w*(b+w*S),this.m_gamma=0!==this.m_gamma?1/this.m_gamma:0,this.m_bias=y*w*S*this.m_gamma,m+=this.m_gamma,this.m_mass.ez.z=0!==m?1/m:0}else p.GetSymInverse33(this.m_mass),this.m_gamma=0,this.m_bias=0;if(t.step.warmStarting){this.m_impulse.SelfMul(t.step.dtRatio);var x=i.InitVelocityConstraints_s_P.Set(this.m_impulse.x,this.m_impulse.y);n.SelfMulSub(c,x),r-=_*(j.CrossVV(this.m_rA,x)+this.m_impulse.z),a.SelfMulAdd(f,x),h+=d*(j.CrossVV(this.m_rB,x)+this.m_impulse.z)}else this.m_impulse.SetZero();t.velocities[this.m_indexA].w=r,t.velocities[this.m_indexB].w=h},n.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexA].v,n=t.velocities[this.m_indexA].w,r=t.velocities[this.m_indexB].v,s=t.velocities[this.m_indexB].w,a=this.m_invMassA,o=this.m_invMassB,h=this.m_invIA,u=this.m_invIB;if(this.m_frequencyHz>0){var l=s-n,c=-this.m_mass.ez.z*(l+this.m_bias+this.m_gamma*this.m_impulse.z);this.m_impulse.z+=c,n-=h*c,s+=u*c;var f=j.SubVV(j.AddVCrossSV(r,s,this.m_rB,j.s_t0),j.AddVCrossSV(e,n,this.m_rA,j.s_t1),i.SolveVelocityConstraints_s_Cdot1),_=J.MulM33XY(this.m_mass,f.x,f.y,i.SolveVelocityConstraints_s_impulse1).SelfNeg();this.m_impulse.x+=_.x,this.m_impulse.y+=_.y;var d=_;e.SelfMulSub(a,d),n-=h*j.CrossVV(this.m_rA,d),r.SelfMulAdd(o,d),s+=u*j.CrossVV(this.m_rB,d)}else{var p=j.SubVV(j.AddVCrossSV(r,s,this.m_rB,j.s_t0),j.AddVCrossSV(e,n,this.m_rA,j.s_t1),i.SolveVelocityConstraints_s_Cdot1),m=s-n,g=J.MulM33XYZ(this.m_mass,p.x,p.y,m,i.SolveVelocityConstraints_s_impulse).SelfNeg();this.m_impulse.SelfAdd(g);var y=i.SolveVelocityConstraints_s_P.Set(g.x,g.y);e.SelfMulSub(a,y),n-=h*(j.CrossVV(this.m_rA,y)+g.z),r.SelfMulAdd(o,y),s+=u*(j.CrossVV(this.m_rB,y)+g.z)}t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=s},n.SolvePositionConstraints=function(t){var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,r=t.positions[this.m_indexB].c,s=t.positions[this.m_indexB].a,a=this.m_qA.SetAngle(n),o=this.m_qB.SetAngle(s),h=this.m_invMassA,u=this.m_invMassB,f=this.m_invIA,_=this.m_invIB;j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var d=K.MulRV(a,this.m_lalcA,this.m_rA);j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var p,m,g=K.MulRV(o,this.m_lalcB,this.m_rB),y=this.m_K;if(y.ex.x=h+u+d.y*d.y*f+g.y*g.y*_,y.ey.x=-d.y*d.x*f-g.y*g.x*_,y.ez.x=-d.y*f-g.y*_,y.ex.y=y.ey.x,y.ey.y=h+u+d.x*d.x*f+g.x*g.x*_,y.ez.y=d.x*f+g.x*_,y.ex.z=y.ez.x,y.ey.z=y.ez.y,y.ez.z=f+_,this.m_frequencyHz>0){var v=j.SubVV(j.AddVV(r,g,j.s_t0),j.AddVV(e,d,j.s_t1),i.SolvePositionConstraints_s_C1);p=v.Length(),m=0;var b=y.Solve22(v.x,v.y,i.SolvePositionConstraints_s_P).SelfNeg();e.SelfMulSub(h,b),n-=f*j.CrossVV(d,b),r.SelfMulAdd(u,b),s+=_*j.CrossVV(g,b)}else{var S=j.SubVV(j.AddVV(r,g,j.s_t0),j.AddVV(e,d,j.s_t1),i.SolvePositionConstraints_s_C1),w=s-n-this.m_referenceAngle;p=S.Length(),m=P(w);var x=y.Solve33(S.x,S.y,w,i.SolvePositionConstraints_s_impulse).SelfNeg(),T=i.SolvePositionConstraints_s_P.Set(x.x,x.y);e.SelfMulSub(h,T),n-=f*(j.CrossVV(this.m_rA,T)+x.z),r.SelfMulAdd(u,T),s+=_*(j.CrossVV(this.m_rB,T)+x.z)}return t.positions[this.m_indexA].a=n,t.positions[this.m_indexB].a=s,p<=l&&m<=c},n.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},n.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},n.GetReactionForce=function(t,e){return e.x=t*this.m_impulse.x,e.y=t*this.m_impulse.y,e},n.GetReactionTorque=function(t){return t*this.m_impulse.z},n.GetLocalAnchorA=function(){return this.m_localAnchorA},n.GetLocalAnchorB=function(){return this.m_localAnchorB},n.GetReferenceAngle=function(){return this.m_referenceAngle},n.SetFrequency=function(t){this.m_frequencyHz=t},n.GetFrequency=function(){return this.m_frequencyHz},n.SetDampingRatio=function(t){this.m_dampingRatio=t},n.GetDampingRatio=function(){return this.m_dampingRatio},n.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2WeldJointDef = new b2WeldJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.referenceAngle = %.15f;\n",this.m_referenceAngle),t(" jd.frequencyHz = %.15f;\n",this.m_frequencyHz),t(" jd.dampingRatio = %.15f;\n",this.m_dampingRatio),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},i}(ki);nn.InitVelocityConstraints_s_P=new j,nn.SolveVelocityConstraints_s_Cdot1=new j,nn.SolveVelocityConstraints_s_impulse1=new j,nn.SolveVelocityConstraints_s_impulse=new X,nn.SolveVelocityConstraints_s_P=new j,nn.SolvePositionConstraints_s_C1=new j,nn.SolvePositionConstraints_s_P=new j,nn.SolvePositionConstraints_s_impulse=new X;var rn=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_wheelJoint)||this).localAnchorA=new j(0,0),i.localAnchorB=new j(0,0),i.localAxisA=new j(1,0),i.enableMotor=!1,i.maxMotorTorque=0,i.motorSpeed=0,i.frequencyHz=2,i.dampingRatio=.7,i}return s(i,e),i.prototype.Initialize=function(t,e,i,n){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(i,this.localAnchorA),this.bodyB.GetLocalPoint(i,this.localAnchorB),this.bodyA.GetLocalVector(n,this.localAxisA)},i}(Oi),sn=function(t){function i(i){var n;return(n=t.call(this,i)||this).m_frequencyHz=0,n.m_dampingRatio=0,n.m_localAnchorA=new j,n.m_localAnchorB=new j,n.m_localXAxisA=new j,n.m_localYAxisA=new j,n.m_impulse=0,n.m_motorImpulse=0,n.m_springImpulse=0,n.m_maxMotorTorque=0,n.m_motorSpeed=0,n.m_enableMotor=!1,n.m_indexA=0,n.m_indexB=0,n.m_localCenterA=new j,n.m_localCenterB=new j,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_ax=new j,n.m_ay=new j,n.m_sAx=0,n.m_sBx=0,n.m_sAy=0,n.m_sBy=0,n.m_mass=0,n.m_motorMass=0,n.m_springMass=0,n.m_bias=0,n.m_gamma=0,n.m_qA=new K,n.m_qB=new K,n.m_lalcA=new j,n.m_lalcB=new j,n.m_rA=new j,n.m_rB=new j,n.m_frequencyHz=e(i.frequencyHz,2),n.m_dampingRatio=e(i.dampingRatio,.7),n.m_localAnchorA.Copy(e(i.localAnchorA,j.ZERO)),n.m_localAnchorB.Copy(e(i.localAnchorB,j.ZERO)),n.m_localXAxisA.Copy(e(i.localAxisA,j.UNITX)),j.CrossOneV(n.m_localXAxisA,n.m_localYAxisA),n.m_maxMotorTorque=e(i.maxMotorTorque,0),n.m_motorSpeed=e(i.motorSpeed,0),n.m_enableMotor=e(i.enableMotor,!1),n.m_ax.SetZero(),n.m_ay.SetZero(),n}s(i,t);var n=i.prototype;return n.GetMotorSpeed=function(){return this.m_motorSpeed},n.GetMaxMotorTorque=function(){return this.m_maxMotorTorque},n.SetSpringFrequencyHz=function(t){this.m_frequencyHz=t},n.GetSpringFrequencyHz=function(){return this.m_frequencyHz},n.SetSpringDampingRatio=function(t){this.m_dampingRatio=t},n.GetSpringDampingRatio=function(){return this.m_dampingRatio},n.InitVelocityConstraints=function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=this.m_invMassA,n=this.m_invMassB,r=this.m_invIA,s=this.m_invIB,a=t.positions[this.m_indexA].c,h=t.positions[this.m_indexA].a,u=t.velocities[this.m_indexA].v,l=t.velocities[this.m_indexA].w,c=t.positions[this.m_indexB].c,f=t.positions[this.m_indexB].a,_=t.velocities[this.m_indexB].v,d=t.velocities[this.m_indexB].w,p=this.m_qA.SetAngle(h),m=this.m_qB.SetAngle(f);j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var g=K.MulRV(p,this.m_lalcA,this.m_rA);j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var y=K.MulRV(m,this.m_lalcB,this.m_rB),v=j.SubVV(j.AddVV(c,y,j.s_t0),j.AddVV(a,g,j.s_t1),i.InitVelocityConstraints_s_d);if(K.MulRV(p,this.m_localYAxisA,this.m_ay),this.m_sAy=j.CrossVV(j.AddVV(v,g,j.s_t0),this.m_ay),this.m_sBy=j.CrossVV(y,this.m_ay),this.m_mass=e+n+r*this.m_sAy*this.m_sAy+s*this.m_sBy*this.m_sBy,this.m_mass>0&&(this.m_mass=1/this.m_mass),this.m_springMass=0,this.m_bias=0,this.m_gamma=0,this.m_frequencyHz>0){K.MulRV(p,this.m_localXAxisA,this.m_ax),this.m_sAx=j.CrossVV(j.AddVV(v,g,j.s_t0),this.m_ax),this.m_sBx=j.CrossVV(y,this.m_ax);var b=e+n+r*this.m_sAx*this.m_sAx+s*this.m_sBx*this.m_sBx;if(b>0){this.m_springMass=1/b;var S=j.DotVV(v,this.m_ax),w=2*o*this.m_frequencyHz,x=2*this.m_springMass*this.m_dampingRatio*w,T=this.m_springMass*w*w,A=t.step.dt;this.m_gamma=A*(x+A*T),this.m_gamma>0&&(this.m_gamma=1/this.m_gamma),this.m_bias=S*A*T*this.m_gamma,this.m_springMass=b+this.m_gamma,this.m_springMass>0&&(this.m_springMass=1/this.m_springMass)}}else this.m_springImpulse=0;if(this.m_enableMotor?(this.m_motorMass=r+s,this.m_motorMass>0&&(this.m_motorMass=1/this.m_motorMass)):(this.m_motorMass=0,this.m_motorImpulse=0),t.step.warmStarting){this.m_impulse*=t.step.dtRatio,this.m_springImpulse*=t.step.dtRatio,this.m_motorImpulse*=t.step.dtRatio;var C=j.AddVV(j.MulSV(this.m_impulse,this.m_ay,j.s_t0),j.MulSV(this.m_springImpulse,this.m_ax,j.s_t1),i.InitVelocityConstraints_s_P),D=this.m_impulse*this.m_sAy+this.m_springImpulse*this.m_sAx+this.m_motorImpulse,B=this.m_impulse*this.m_sBy+this.m_springImpulse*this.m_sBx+this.m_motorImpulse;u.SelfMulSub(this.m_invMassA,C),l-=this.m_invIA*D,_.SelfMulAdd(this.m_invMassB,C),d+=this.m_invIB*B}else this.m_impulse=0,this.m_springImpulse=0,this.m_motorImpulse=0;t.velocities[this.m_indexA].w=l,t.velocities[this.m_indexB].w=d},n.SolveVelocityConstraints=function(t){var e=this.m_invMassA,n=this.m_invMassB,r=this.m_invIA,s=this.m_invIB,a=t.velocities[this.m_indexA].v,o=t.velocities[this.m_indexA].w,h=t.velocities[this.m_indexB].v,u=t.velocities[this.m_indexB].w,l=j.DotVV(this.m_ax,j.SubVV(h,a,j.s_t0))+this.m_sBx*u-this.m_sAx*o,c=-this.m_springMass*(l+this.m_bias+this.m_gamma*this.m_springImpulse);this.m_springImpulse+=c;var f=j.MulSV(c,this.m_ax,i.SolveVelocityConstraints_s_P),_=c*this.m_sAx,d=c*this.m_sBx;a.SelfMulSub(e,f),o-=r*_,h.SelfMulAdd(n,f);var p=(u+=s*d)-o-this.m_motorSpeed,m=-this.m_motorMass*p,g=this.m_motorImpulse,y=t.step.dt*this.m_maxMotorTorque;this.m_motorImpulse=k(this.m_motorImpulse+m,-y,y),o-=r*(m=this.m_motorImpulse-g),u+=s*m;var v=j.DotVV(this.m_ay,j.SubVV(h,a,j.s_t0))+this.m_sBy*u-this.m_sAy*o,b=-this.m_mass*v;this.m_impulse+=b;var S=j.MulSV(b,this.m_ay,i.SolveVelocityConstraints_s_P),w=b*this.m_sAy,x=b*this.m_sBy;a.SelfMulSub(e,S),o-=r*w,h.SelfMulAdd(n,S),u+=s*x,t.velocities[this.m_indexA].w=o,t.velocities[this.m_indexB].w=u},n.SolvePositionConstraints=function(t){var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,r=t.positions[this.m_indexB].c,s=t.positions[this.m_indexB].a,a=this.m_qA.SetAngle(n),o=this.m_qB.SetAngle(s);j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var h=K.MulRV(a,this.m_lalcA,this.m_rA);j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var u,c=K.MulRV(o,this.m_lalcB,this.m_rB),f=j.AddVV(j.SubVV(r,e,j.s_t0),j.SubVV(c,h,j.s_t1),i.SolvePositionConstraints_s_d),_=K.MulRV(a,this.m_localYAxisA,this.m_ay),d=j.CrossVV(j.AddVV(f,h,j.s_t0),_),p=j.CrossVV(c,_),m=j.DotVV(f,this.m_ay),g=this.m_invMassA+this.m_invMassB+this.m_invIA*this.m_sAy*this.m_sAy+this.m_invIB*this.m_sBy*this.m_sBy;u=0!==g?-m/g:0;var y=j.MulSV(u,_,i.SolvePositionConstraints_s_P),v=u*d,b=u*p;return e.SelfMulSub(this.m_invMassA,y),n-=this.m_invIA*v,r.SelfMulAdd(this.m_invMassB,y),s+=this.m_invIB*b,t.positions[this.m_indexA].a=n,t.positions[this.m_indexB].a=s,P(m)<=l},n.GetDefinition=function(t){return t},n.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},n.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},n.GetReactionForce=function(t,e){return e.x=t*(this.m_impulse*this.m_ay.x+this.m_springImpulse*this.m_ax.x),e.y=t*(this.m_impulse*this.m_ay.y+this.m_springImpulse*this.m_ax.y),e},n.GetReactionTorque=function(t){return t*this.m_motorImpulse},n.GetLocalAnchorA=function(){return this.m_localAnchorA},n.GetLocalAnchorB=function(){return this.m_localAnchorB},n.GetLocalAxisA=function(){return this.m_localXAxisA},n.GetJointTranslation=function(){return this.GetPrismaticJointTranslation()},n.GetJointLinearSpeed=function(){return this.GetPrismaticJointSpeed()},n.GetJointAngle=function(){return this.GetRevoluteJointAngle()},n.GetJointAngularSpeed=function(){return this.GetRevoluteJointSpeed()},n.GetPrismaticJointTranslation=function(){var t=this.m_bodyA,e=this.m_bodyB,i=t.GetWorldPoint(this.m_localAnchorA,new j),n=e.GetWorldPoint(this.m_localAnchorB,new j),r=j.SubVV(n,i,new j),s=t.GetWorldVector(this.m_localXAxisA,new j);return j.DotVV(r,s)},n.GetPrismaticJointSpeed=function(){var t=this.m_bodyA,e=this.m_bodyB;j.SubVV(this.m_localAnchorA,t.m_sweep.localCenter,this.m_lalcA);var i=K.MulRV(t.m_xf.q,this.m_lalcA,this.m_rA);j.SubVV(this.m_localAnchorB,e.m_sweep.localCenter,this.m_lalcB);var n=K.MulRV(e.m_xf.q,this.m_lalcB,this.m_rB),r=j.AddVV(t.m_sweep.c,i,j.s_t0),s=j.AddVV(e.m_sweep.c,n,j.s_t1),a=j.SubVV(s,r,j.s_t2),o=t.GetWorldVector(this.m_localXAxisA,new j),h=t.m_linearVelocity,u=e.m_linearVelocity,l=t.m_angularVelocity,c=e.m_angularVelocity;return j.DotVV(a,j.CrossSV(l,o,j.s_t0))+j.DotVV(o,j.SubVV(j.AddVCrossSV(u,c,n,j.s_t0),j.AddVCrossSV(h,l,i,j.s_t1),j.s_t0))},n.GetRevoluteJointAngle=function(){return this.m_bodyB.m_sweep.a-this.m_bodyA.m_sweep.a},n.GetRevoluteJointSpeed=function(){var t=this.m_bodyA.m_angularVelocity;return this.m_bodyB.m_angularVelocity-t},n.IsMotorEnabled=function(){return this.m_enableMotor},n.EnableMotor=function(t){t!==this.m_enableMotor&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableMotor=t)},n.SetMotorSpeed=function(t){t!==this.m_motorSpeed&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_motorSpeed=t)},n.SetMaxMotorTorque=function(t){t!==this.m_maxMotorTorque&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_maxMotorTorque=t)},n.GetMotorTorque=function(t){return t*this.m_motorImpulse},n.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2WheelJointDef = new b2WheelJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.localAxisA.Set(%.15f, %.15f);\n",this.m_localXAxisA.x,this.m_localXAxisA.y),t(" jd.enableMotor = %s;\n",this.m_enableMotor?"true":"false"),t(" jd.motorSpeed = %.15f;\n",this.m_motorSpeed),t(" jd.maxMotorTorque = %.15f;\n",this.m_maxMotorTorque),t(" jd.frequencyHz = %.15f;\n",this.m_frequencyHz),t(" jd.dampingRatio = %.15f;\n",this.m_dampingRatio),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},i}(ki);function an(t,e){return V(t*e)}function on(t,e){return t>e?t:e}sn.InitVelocityConstraints_s_d=new j,sn.InitVelocityConstraints_s_P=new j,sn.SolveVelocityConstraints_s_P=new j,sn.SolvePositionConstraints_s_d=new j,sn.SolvePositionConstraints_s_P=new j;var hn=function(){function t(t){this._other=null,this.prev=null,this.next=null,this.contact=t}return t.prototype.Reset=function(){this._other=null,this.prev=null,this.next=null},n(t,[{key:"other",get:function(){if(null===this._other)throw new Error;return this._other},set:function(t){if(null!==this._other)throw new Error;this._other=t}}]),t}(),un=function(){function t(){this.m_islandFlag=!1,this.m_touchingFlag=!1,this.m_enabledFlag=!1,this.m_filterFlag=!1,this.m_bulletHitFlag=!1,this.m_toiFlag=!1,this.m_prev=null,this.m_next=null,this.m_nodeA=new hn(this),this.m_nodeB=new hn(this),this.m_indexA=0,this.m_indexB=0,this.m_manifold=new kt,this.m_toiCount=0,this.m_toi=0,this.m_friction=0,this.m_restitution=0,this.m_tangentSpeed=0,this.m_oldManifold=new kt}var e=t.prototype;return e.GetManifold=function(){return this.m_manifold},e.GetWorldManifold=function(t){var e=this.m_fixtureA.GetBody(),i=this.m_fixtureB.GetBody(),n=this.GetShapeA(),r=this.GetShapeB();t.Initialize(this.m_manifold,e.GetTransform(),n.m_radius,i.GetTransform(),r.m_radius)},e.IsTouching=function(){return this.m_touchingFlag},e.SetEnabled=function(t){this.m_enabledFlag=t},e.IsEnabled=function(){return this.m_enabledFlag},e.GetNext=function(){return this.m_next},e.GetFixtureA=function(){return this.m_fixtureA},e.GetChildIndexA=function(){return this.m_indexA},e.GetShapeA=function(){return this.m_fixtureA.GetShape()},e.GetFixtureB=function(){return this.m_fixtureB},e.GetChildIndexB=function(){return this.m_indexB},e.GetShapeB=function(){return this.m_fixtureB.GetShape()},e.FlagForFiltering=function(){this.m_filterFlag=!0},e.SetFriction=function(t){this.m_friction=t},e.GetFriction=function(){return this.m_friction},e.ResetFriction=function(){this.m_friction=an(this.m_fixtureA.m_friction,this.m_fixtureB.m_friction)},e.SetRestitution=function(t){this.m_restitution=t},e.GetRestitution=function(){return this.m_restitution},e.ResetRestitution=function(){this.m_restitution=on(this.m_fixtureA.m_restitution,this.m_fixtureB.m_restitution)},e.SetTangentSpeed=function(t){this.m_tangentSpeed=t},e.GetTangentSpeed=function(){return this.m_tangentSpeed},e.Reset=function(t,e,i,n){this.m_islandFlag=!1,this.m_touchingFlag=!1,this.m_enabledFlag=!0,this.m_filterFlag=!1,this.m_bulletHitFlag=!1,this.m_toiFlag=!1,this.m_fixtureA=t,this.m_fixtureB=i,this.m_indexA=e,this.m_indexB=n,this.m_manifold.pointCount=0,this.m_prev=null,this.m_next=null,this.m_nodeA.Reset(),this.m_nodeB.Reset(),this.m_toiCount=0,this.m_friction=an(this.m_fixtureA.m_friction,this.m_fixtureB.m_friction),this.m_restitution=on(this.m_fixtureA.m_restitution,this.m_fixtureB.m_restitution)},e.Update=function(t){var e=this.m_oldManifold;this.m_oldManifold=this.m_manifold,this.m_manifold=e,this.m_enabledFlag=!0;var i=!1,n=this.m_touchingFlag,r=this.m_fixtureA.IsSensor(),s=this.m_fixtureB.IsSensor(),a=r||s,o=this.m_fixtureA.GetBody(),h=this.m_fixtureB.GetBody(),u=o.GetTransform(),l=h.GetTransform();if(a){var c=this.GetShapeA(),f=this.GetShapeB();i=jt(c,this.m_indexA,f,this.m_indexB,u,l),this.m_manifold.pointCount=0}else{this.Evaluate(this.m_manifold,u,l),i=this.m_manifold.pointCount>0;for(var _=0;_0:!!(s.maskBits&a.categoryBits)&&!!(s.categoryBits&a.maskBits)},i.ShouldCollideFixtureParticle=function(){return!0},i.ShouldCollideParticleParticle=function(){return!0},e}();bn.b2_defaultFilter=new bn;var Sn=function(){this.normalImpulses=D(2),this.tangentImpulses=D(2),this.count=0},wn=function(){function t(){}var e=t.prototype;return e.BeginContact=function(){},e.EndContact=function(){},e.BeginContactFixtureParticle=function(){},e.EndContactFixtureParticle=function(){},e.BeginContactParticleParticle=function(){},e.EndContactParticleParticle=function(){},e.PreSolve=function(){},e.PostSolve=function(){},t}();wn.b2_defaultListener=new wn;var xn=function(){function t(){}var e=t.prototype;return e.ReportFixture=function(){return!0},e.ReportParticle=function(){return!1},e.ShouldQueryParticleSystem=function(){return!0},t}(),Tn=function(){function t(){}var e=t.prototype;return e.ReportFixture=function(t,e,i,n){return n},e.ReportParticle=function(){return 0},e.ShouldQueryParticleSystem=function(){return!0},t}(),An=function(){function e(){this.m_broadPhase=new $t,this.m_contactList=null,this.m_contactCount=0,this.m_contactFilter=bn.b2_defaultFilter,this.m_contactListener=wn.b2_defaultListener,this.m_contactFactory=new yn}var i=e.prototype;return i.AddPair=function(t,e){var i=t.fixture,n=e.fixture,r=t.childIndex,s=e.childIndex,a=i.GetBody(),o=n.GetBody();if(a!==o){for(var h=o.GetContactList();h;){if(h.other===a){var u=h.contact.GetFixtureA(),l=h.contact.GetFixtureB(),c=h.contact.GetChildIndexA(),f=h.contact.GetChildIndexB();if(u===i&&l===n&&c===r&&f===s)return;if(u===n&&l===i&&c===s&&f===r)return}h=h.next}if(!this.m_contactFilter||this.m_contactFilter.ShouldCollide(i,n)){var _=this.m_contactFactory.Create(i,r,n,s);null!==_&&(i=_.GetFixtureA(),n=_.GetFixtureB(),r=_.GetChildIndexA(),s=_.GetChildIndexB(),a=i.m_body,o=n.m_body,_.m_prev=null,_.m_next=this.m_contactList,null!==this.m_contactList&&(this.m_contactList.m_prev=_),this.m_contactList=_,_.m_nodeA.other=o,_.m_nodeA.prev=null,_.m_nodeA.next=a.m_contactList,null!==a.m_contactList&&(a.m_contactList.prev=_.m_nodeA),a.m_contactList=_.m_nodeA,_.m_nodeB.other=a,_.m_nodeB.prev=null,_.m_nodeB.next=o.m_contactList,null!==o.m_contactList&&(o.m_contactList.prev=_.m_nodeB),o.m_contactList=_.m_nodeB,i.IsSensor()||n.IsSensor()||(a.SetAwake(!0),o.SetAwake(!0)),++this.m_contactCount)}}},i.FindNewContacts=function(){var t=this;this.m_broadPhase.UpdatePairs((function(e,i){t.AddPair(e,i)}))},i.Destroy=function(t){var e=t.GetFixtureA(),i=t.GetFixtureB(),n=e.GetBody(),r=i.GetBody();this.m_contactListener&&t.IsTouching()&&this.m_contactListener.EndContact(t),t.m_prev&&(t.m_prev.m_next=t.m_next),t.m_next&&(t.m_next.m_prev=t.m_prev),t===this.m_contactList&&(this.m_contactList=t.m_next),t.m_nodeA.prev&&(t.m_nodeA.prev.next=t.m_nodeA.next),t.m_nodeA.next&&(t.m_nodeA.next.prev=t.m_nodeA.prev),t.m_nodeA===n.m_contactList&&(n.m_contactList=t.m_nodeA.next),t.m_nodeB.prev&&(t.m_nodeB.prev.next=t.m_nodeB.next),t.m_nodeB.next&&(t.m_nodeB.next.prev=t.m_nodeB.prev),t.m_nodeB===r.m_contactList&&(r.m_contactList=t.m_nodeB.next),t.m_manifold.pointCount>0&&!e.IsSensor()&&!i.IsSensor()&&(e.GetBody().SetAwake(!0),i.GetBody().SetAwake(!0)),this.m_contactFactory.Destroy(t),--this.m_contactCount},i.Collide=function(){for(var e=this.m_contactList;e;){var i=e.GetFixtureA(),n=e.GetFixtureB(),r=e.GetChildIndexA(),s=e.GetChildIndexB(),a=i.GetBody(),o=n.GetBody();if(e.m_filterFlag){if(this.m_contactFilter&&!this.m_contactFilter.ShouldCollide(i,n)){var h=e;e=h.m_next,this.Destroy(h);continue}e.m_filterFlag=!1}var u=a.IsAwake()&&a.m_type!==t.b2BodyType.b2_staticBody,l=o.IsAwake()&&o.m_type!==t.b2BodyType.b2_staticBody;if(u||l){var c=i.m_proxies[r].treeNode,f=n.m_proxies[s].treeNode;if(zt(c.aabb,f.aabb))e.Update(this.m_contactListener),e=e.m_next;else{var _=e;e=_.m_next,this.Destroy(_)}}else e=e.m_next}},e}(),Cn=function(){function t(){this.step=0,this.collide=0,this.solve=0,this.solveInit=0,this.solveVelocity=0,this.solvePosition=0,this.broadphase=0,this.solveTOI=0}return t.prototype.Reset=function(){return this.step=0,this.collide=0,this.solve=0,this.solveInit=0,this.solveVelocity=0,this.solvePosition=0,this.broadphase=0,this.solveTOI=0,this},t}(),Dn=function(){function t(){this.dt=0,this.inv_dt=0,this.dtRatio=0,this.velocityIterations=0,this.positionIterations=0,this.particleIterations=0,this.warmStarting=!1}return t.prototype.Copy=function(t){return this.dt=t.dt,this.inv_dt=t.inv_dt,this.dtRatio=t.dtRatio,this.positionIterations=t.positionIterations,this.velocityIterations=t.velocityIterations,this.particleIterations=t.particleIterations,this.warmStarting=t.warmStarting,this},t}(),Bn=function(){function t(){this.c=new j,this.a=0}return t.MakeArray=function(e){return C(e,(function(){return new t}))},t}(),In=function(){function t(){this.v=new j,this.w=0}return t.MakeArray=function(e){return C(e,(function(){return new t}))},t}(),Mn=function(){this.step=new Dn},Pn=!1,En=function(){function t(){this.rA=new j,this.rB=new j,this.normalImpulse=0,this.tangentImpulse=0,this.normalMass=0,this.tangentMass=0,this.velocityBias=0}return t.MakeArray=function(e){return C(e,(function(){return new t}))},t}(),On=function(){function t(){this.points=En.MakeArray(2),this.normal=new j,this.tangent=new j,this.normalMass=new Y,this.K=new Y,this.indexA=0,this.indexB=0,this.invMassA=0,this.invMassB=0,this.invIA=0,this.invIB=0,this.friction=0,this.restitution=0,this.tangentSpeed=0,this.pointCount=0,this.contactIndex=0}return t.MakeArray=function(e){return C(e,(function(){return new t}))},t}(),kn=function(){function e(){this.localPoints=j.MakeArray(2),this.localNormal=new j,this.localPoint=new j,this.indexA=0,this.indexB=0,this.invMassA=0,this.invMassB=0,this.localCenterA=new j,this.localCenterB=new j,this.invIA=0,this.invIB=0,this.type=t.b2ManifoldType.e_unknown,this.radiusA=0,this.radiusB=0,this.pointCount=0}return e.MakeArray=function(t){return C(t,(function(){return new e}))},e}(),Rn=function(){this.step=new Dn,this.count=0},Fn=function(){function e(){this.normal=new j,this.point=new j,this.separation=0}return e.prototype.Initialize=function(i,n,r,s){var a=e.Initialize_s_pointA,o=e.Initialize_s_pointB,h=e.Initialize_s_planePoint,u=e.Initialize_s_clipPoint;switch(i.type){case t.b2ManifoldType.e_circles:Q.MulXV(n,i.localPoint,a),Q.MulXV(r,i.localPoints[0],o),j.SubVV(o,a,this.normal).SelfNormalize(),j.MidVV(a,o,this.point),this.separation=j.DotVV(j.SubVV(o,a,j.s_t0),this.normal)-i.radiusA-i.radiusB;break;case t.b2ManifoldType.e_faceA:K.MulRV(n.q,i.localNormal,this.normal),Q.MulXV(n,i.localPoint,h),Q.MulXV(r,i.localPoints[s],u),this.separation=j.DotVV(j.SubVV(u,h,j.s_t0),this.normal)-i.radiusA-i.radiusB,this.point.Copy(u);break;case t.b2ManifoldType.e_faceB:K.MulRV(r.q,i.localNormal,this.normal),Q.MulXV(r,i.localPoint,h),Q.MulXV(n,i.localPoints[s],u),this.separation=j.DotVV(j.SubVV(u,h,j.s_t0),this.normal)-i.radiusA-i.radiusB,this.point.Copy(u),this.normal.SelfNeg()}},e}();Fn.Initialize_s_pointA=new j,Fn.Initialize_s_pointB=new j,Fn.Initialize_s_planePoint=new j,Fn.Initialize_s_clipPoint=new j;var Ln=function(){function t(){this.m_step=new Dn,this.m_positionConstraints=kn.MakeArray(1024),this.m_velocityConstraints=On.MakeArray(1024),this.m_count=0}var e=t.prototype;return e.Initialize=function(t){if(this.m_step.Copy(t.step),this.m_count=t.count,this.m_positionConstraints.length0?1/P:0;var E=s.tangent,O=j.CrossVV(B.rA,E),k=j.CrossVV(B.rB,E),R=f+_+d*O*O+p*k*k;B.tangentMass=R>0?1/R:0,B.velocityBias=0;var F=j.DotVV(s.normal,j.SubVV(j.AddVCrossSV(T,A,B.rB,j.s_t0),j.AddVCrossSV(b,S,B.rA,j.s_t1),j.s_t0));F<-1&&(B.velocityBias+=-s.restitution*F)}s.pointCount}},e.WarmStart=function(){for(var e=t.WarmStart_s_P,i=0;i0?-B/P:0;j.MulSV(O,A,a),b.SelfMulSub(d,a),S-=p*j.CrossVV(r,a),w.SelfMulAdd(g,a),x+=y*j.CrossVV(s,a)}this.m_positions[c].a=S,this.m_positions[f].a=x}return o>-.024},e.SolveTOIPositionConstraints=function(e,i){for(var n=t.SolveTOIPositionConstraints_s_xfA,r=t.SolveTOIPositionConstraints_s_xfB,s=t.SolveTOIPositionConstraints_s_psm,a=t.SolveTOIPositionConstraints_s_rA,o=t.SolveTOIPositionConstraints_s_rB,h=t.SolveTOIPositionConstraints_s_P,u=0,c=0;c0?-M/R:0;j.MulSV(F,D,h),w.SelfMulSub(y,h),x-=v*j.CrossVV(a,h),T.SelfMulAdd(b,h),A+=S*j.CrossVV(o,h)}this.m_positions[_].a=x,this.m_positions[d].a=A}return u>=-.012},t}();Ln.InitializeVelocityConstraints_s_xfA=new Q,Ln.InitializeVelocityConstraints_s_xfB=new Q,Ln.InitializeVelocityConstraints_s_worldManifold=new Rt,Ln.WarmStart_s_P=new j,Ln.SolveVelocityConstraints_s_dv=new j,Ln.SolveVelocityConstraints_s_dv1=new j,Ln.SolveVelocityConstraints_s_dv2=new j,Ln.SolveVelocityConstraints_s_P=new j,Ln.SolveVelocityConstraints_s_a=new j,Ln.SolveVelocityConstraints_s_b=new j,Ln.SolveVelocityConstraints_s_x=new j,Ln.SolveVelocityConstraints_s_d=new j,Ln.SolveVelocityConstraints_s_P1=new j,Ln.SolveVelocityConstraints_s_P2=new j,Ln.SolveVelocityConstraints_s_P1P2=new j,Ln.SolvePositionConstraints_s_xfA=new Q,Ln.SolvePositionConstraints_s_xfB=new Q,Ln.SolvePositionConstraints_s_psm=new Fn,Ln.SolvePositionConstraints_s_rA=new j,Ln.SolvePositionConstraints_s_rB=new j,Ln.SolvePositionConstraints_s_P=new j,Ln.SolveTOIPositionConstraints_s_xfA=new Q,Ln.SolveTOIPositionConstraints_s_xfB=new Q,Ln.SolveTOIPositionConstraints_s_psm=new Fn,Ln.SolveTOIPositionConstraints_s_rA=new j,Ln.SolveTOIPositionConstraints_s_rB=new j,Ln.SolveTOIPositionConstraints_s_P=new j;var Vn,Nn=function(){function e(){this.m_bodies=[],this.m_contacts=[],this.m_joints=[],this.m_positions=Bn.MakeArray(1024),this.m_velocities=In.MakeArray(1024),this.m_bodyCount=0,this.m_jointCount=0,this.m_contactCount=0,this.m_bodyCapacity=0,this.m_contactCapacity=0,this.m_jointCapacity=0}var n=e.prototype;return n.Initialize=function(t,e,i,n){if(this.m_bodyCapacity=t,this.m_contactCapacity=e,this.m_jointCapacity=i,this.m_bodyCount=0,this.m_contactCount=0,this.m_jointCount=0,this.m_listener=n,this.m_positions.length4){var B=2/D.Length();A.SelfMul(B)}var I=h*C;I*I>g&&(C*=m/P(I)),x.x+=h*A.x,x.y+=h*A.y,T+=h*C,this.m_positions[w].a=T,this.m_velocities[w].w=C}o.Reset();for(var M=!1,O=0;O.0012184696791469947||j.DotVV(G.m_linearVelocity,G.m_linearVelocity)>1e-4?(G.m_sleepTime=0,z=0):(G.m_sleepTime+=h,z=E(z,G.m_sleepTime)))}if(z>=.5&&M)for(var H=0;H4){var v=2/y.Length();d.SelfMul(v)}var b=l*p;b*b>g&&(p*=m/P(b)),f.SelfMulAdd(l,d),_+=l*p,this.m_positions[c].a=_,this.m_velocities[c].w=p;var S=this.m_bodies[c];S.m_sweep.c.Copy(f),S.m_sweep.a=_,S.m_linearVelocity.Copy(d),S.m_angularVelocity=p,S.SynchronizeTransform()}this.Report(o.m_velocityConstraints)},n.Report=function(t){if(null!==this.m_listener)for(var i=0;i0){var r=1/this.m_mass;this.m_center.SelfMul(r),this.m_linearVelocity.SelfMul(r)}this.m_inertia=0,this.m_angularVelocity=0;for(var s=this.m_firstIndex;s0&&(this.m_angularVelocity*=1/this.m_inertia),this.m_timestamp=this.m_system.m_timestamp}},e}();jn.GetLinearVelocityFromWorldPoint_s_t0=new j;var qn=function(){function t(t){this.m_buffer=[],this.m_front=0,this.m_back=0,this.m_buffer.fill(null,0,t)}var e=t.prototype;return e.Push=function(t){if(this.m_back>=this.m_capacity){for(var e=this.m_front;e=0&&f>=0&&c0&&h.Push(new Jn(d-1,p,m-1,g)),p>0&&h.Push(new Jn(d,p-1,m-this.m_countX,g)),dL*L+V*V&&(this.m_diagram[P]=k,I>0&&h.Push(new Jn(I-1,M,P-1,k)),M>0&&h.Push(new Jn(I,M-1,P-this.m_countX,k)),I=i)break;Kn(t,h,i)}}if(0===a)break;r=i,i=s[--a]}return t}function $n(t,e,i,n){return void 0===i&&(i=t.length-e),void 0===n&&(n=Qn),Zn(t,e,i,n)}function tr(t,e,i){void 0===i&&(i=t.length);for(var n=0,r=0;r0;){var a=Math.floor(s/2),o=e+a;r(t[o],n)?(e=++o,s-=a+1):s=a}return e}function ir(t,e,i,n,r){for(var s=i-e;s>0;){var a=Math.floor(s/2),o=e+a;r(n,t[o])?s=a:(e=++o,s-=a+1)}return e}function nr(t,e,i,n){for(var r=i;e!==r;)Kn(t,e++,r++),r===n?r=i:e===i&&(i=r)}function rr(t,e,i,n){if(e===i)return i;for(var r=e;++e!==i;)n(t[r],t[e])||Kn(t,++r,e);return++r}var sr=function(){function t(t){this.data=[],this.count=0,this.capacity=0,this.allocator=t}var e=t.prototype;return e.Append=function(){return this.count>=this.capacity&&this.Grow(),this.count++},e.Reserve=function(t){if(!(this.capacity>=t)){for(var e=this.capacity;e=0;)this.ReportFixtureAndParticle(t,i,s);return!0},i.ReportParticle=function(){return!1},i.ReportFixtureAndParticle=function(){},e}(xn),or=function(){function t(){this.indexA=0,this.indexB=0,this.weight=0,this.normal=new j,this.flags=0}var e=t.prototype;return e.SetIndices=function(t,e){this.indexA=t,this.indexB=e},e.SetWeight=function(t){this.weight=t},e.SetNormal=function(t){this.normal.Copy(t)},e.SetFlags=function(t){this.flags=t},e.GetIndexA=function(){return this.indexA},e.GetIndexB=function(){return this.indexB},e.GetWeight=function(){return this.weight},e.GetNormal=function(){return this.normal},e.GetFlags=function(){return this.flags},e.IsEqual=function(t){return this.indexA===t.indexA&&this.indexB===t.indexB&&this.flags===t.flags&&this.weight===t.weight&&this.normal.x===t.normal.x&&this.normal.y===t.normal.y},e.IsNotEqual=function(t){return!this.IsEqual(t)},e.ApproximatelyEqual=function(t){return this.indexA===t.indexA&&this.indexB===t.indexB&&this.flags===t.flags&&P(this.weight-t.weight)<.01&&j.DistanceSquaredVV(this.normal,t.normal)<1e-4},t}(),hr=function(){this.index=0,this.weight=0,this.normal=new j,this.mass=0},ur=function(){this.indexA=0,this.indexB=0,this.flags=0,this.strength=0,this.distance=0},lr=function(){this.indexA=0,this.indexB=0,this.indexC=0,this.flags=0,this.strength=0,this.pa=new j(0,0),this.pb=new j(0,0),this.pc=new j(0,0),this.ka=0,this.kb=0,this.kc=0,this.s=0},cr=function(){function t(){this.strictContactCheck=!1,this.density=1,this.gravityScale=1,this.radius=1,this.maxCount=0,this.pressureStrength=.005,this.dampingStrength=1,this.elasticStrength=.25,this.springStrength=.25,this.viscousStrength=.25,this.surfaceTensionPressureStrength=.2,this.surfaceTensionNormalStrength=.2,this.repulsiveStrength=1,this.powderStrength=.5,this.ejectionStrength=.5,this.staticPressureStrength=.2,this.staticPressureRelaxation=.2,this.staticPressureIterations=8,this.colorMixingStrength=.5,this.destroyByAge=!0,this.lifetimeGranularity=1/60}var e=t.prototype;return e.Copy=function(t){return this.strictContactCheck=t.strictContactCheck,this.density=t.density,this.gravityScale=t.gravityScale,this.radius=t.radius,this.maxCount=t.maxCount,this.pressureStrength=t.pressureStrength,this.dampingStrength=t.dampingStrength,this.elasticStrength=t.elasticStrength,this.springStrength=t.springStrength,this.viscousStrength=t.viscousStrength,this.surfaceTensionPressureStrength=t.surfaceTensionPressureStrength,this.surfaceTensionNormalStrength=t.surfaceTensionNormalStrength,this.repulsiveStrength=t.repulsiveStrength,this.powderStrength=t.powderStrength,this.ejectionStrength=t.ejectionStrength,this.staticPressureStrength=t.staticPressureStrength,this.staticPressureRelaxation=t.staticPressureRelaxation,this.staticPressureIterations=t.staticPressureIterations,this.colorMixingStrength=t.colorMixingStrength,this.destroyByAge=t.destroyByAge,this.lifetimeGranularity=t.lifetimeGranularity,this},e.Clone=function(){return(new t).Copy(this)},t}(),fr=function(){function n(t,e){this.m_paused=!1,this.m_timestamp=0,this.m_allParticleFlags=0,this.m_needsUpdateAllParticleFlags=!1,this.m_allGroupFlags=0,this.m_needsUpdateAllGroupFlags=!1,this.m_hasForce=!1,this.m_iterationIndex=0,this.m_inverseDensity=0,this.m_particleDiameter=0,this.m_inverseDiameter=0,this.m_squaredDiameter=0,this.m_count=0,this.m_internalAllocatedCapacity=0,this.m_handleIndexBuffer=new _r,this.m_flagsBuffer=new _r,this.m_positionBuffer=new _r,this.m_velocityBuffer=new _r,this.m_forceBuffer=[],this.m_weightBuffer=[],this.m_staticPressureBuffer=[],this.m_accumulationBuffer=[],this.m_accumulation2Buffer=[],this.m_depthBuffer=[],this.m_colorBuffer=new _r,this.m_groupBuffer=[],this.m_userDataBuffer=new _r,this.m_stuckThreshold=0,this.m_lastBodyContactStepBuffer=new _r,this.m_bodyContactCountBuffer=new _r,this.m_consecutiveContactStepsBuffer=new _r,this.m_stuckParticleBuffer=new sr((function(){return 0})),this.m_proxyBuffer=new sr((function(){return new dr})),this.m_contactBuffer=new sr((function(){return new or})),this.m_bodyContactBuffer=new sr((function(){return new hr})),this.m_pairBuffer=new sr((function(){return new ur})),this.m_triadBuffer=new sr((function(){return new lr})),this.m_expirationTimeBuffer=new _r,this.m_indexByExpirationTimeBuffer=new _r,this.m_timeElapsed=0,this.m_expirationTimeBufferRequiresSorting=!1,this.m_groupCount=0,this.m_groupList=null,this.m_def=new cr,this.m_prev=null,this.m_next=null,this.UpdateBodyContacts_callback=null,this.SolveCollision_callback=null,this.SetStrictContactCheck(t.strictContactCheck),this.SetDensity(t.density),this.SetGravityScale(t.gravityScale),this.SetRadius(t.radius),this.SetMaxParticleCount(t.maxCount),this.m_def=t.Clone(),this.m_world=e,this.SetDestructionByAge(this.m_def.destroyByAge)}n.computeTag=function(t,e){return(e+n.yOffset>>>0<>>0)>>>0},n.computeRelativeTag=function(t,e,i){return t+(i<>>0};var r=n.prototype;return r.Drop=function(){for(;this.m_groupList;)this.DestroyParticleGroup(this.m_groupList);this.FreeUserOverridableBuffer(this.m_handleIndexBuffer),this.FreeUserOverridableBuffer(this.m_flagsBuffer),this.FreeUserOverridableBuffer(this.m_lastBodyContactStepBuffer),this.FreeUserOverridableBuffer(this.m_bodyContactCountBuffer),this.FreeUserOverridableBuffer(this.m_consecutiveContactStepsBuffer),this.FreeUserOverridableBuffer(this.m_positionBuffer),this.FreeUserOverridableBuffer(this.m_velocityBuffer),this.FreeUserOverridableBuffer(this.m_colorBuffer),this.FreeUserOverridableBuffer(this.m_userDataBuffer),this.FreeUserOverridableBuffer(this.m_expirationTimeBuffer),this.FreeUserOverridableBuffer(this.m_indexByExpirationTimeBuffer),this.FreeBuffer(this.m_forceBuffer,this.m_internalAllocatedCapacity),this.FreeBuffer(this.m_weightBuffer,this.m_internalAllocatedCapacity),this.FreeBuffer(this.m_staticPressureBuffer,this.m_internalAllocatedCapacity),this.FreeBuffer(this.m_accumulationBuffer,this.m_internalAllocatedCapacity),this.FreeBuffer(this.m_accumulation2Buffer,this.m_internalAllocatedCapacity),this.FreeBuffer(this.m_depthBuffer,this.m_internalAllocatedCapacity),this.FreeBuffer(this.m_groupBuffer,this.m_internalAllocatedCapacity)},r.CreateParticle=function(t){if(this.m_world.IsLocked())throw new Error;if(this.m_count>=this.m_internalAllocatedCapacity){var i=this.m_count?2*this.m_count:S;this.ReallocateInternalAllocatedBuffers(i)}if(this.m_count>=this.m_internalAllocatedCapacity){if(!this.m_def.destroyByAge)return y;this.DestroyOldestParticle(0,!1),this.SolveZombie()}var n=this.m_count++;this.m_flagsBuffer.data[n]=0,this.m_lastBodyContactStepBuffer.data&&(this.m_lastBodyContactStepBuffer.data[n]=0),this.m_bodyContactCountBuffer.data&&(this.m_bodyContactCountBuffer.data[n]=0),this.m_consecutiveContactStepsBuffer.data&&(this.m_consecutiveContactStepsBuffer.data[n]=0),this.m_positionBuffer.data[n]=(this.m_positionBuffer.data[n]||new j).Copy(e(t.position,j.ZERO)),this.m_velocityBuffer.data[n]=(this.m_velocityBuffer.data[n]||new j).Copy(e(t.velocity,j.ZERO)),this.m_weightBuffer[n]=0,this.m_forceBuffer[n]=(this.m_forceBuffer[n]||new j).SetZero(),this.m_staticPressureBuffer&&(this.m_staticPressureBuffer[n]=0),this.m_depthBuffer&&(this.m_depthBuffer[n]=0);var r=(new tt).Copy(e(t.color,tt.ZERO));!this.m_colorBuffer.data&&r.IsZero()||(this.m_colorBuffer.data=this.RequestBuffer(this.m_colorBuffer.data),this.m_colorBuffer.data[n]=(this.m_colorBuffer.data[n]||new tt).Copy(r)),(this.m_userDataBuffer.data||t.userData)&&(this.m_userDataBuffer.data=this.RequestBuffer(this.m_userDataBuffer.data),this.m_userDataBuffer.data[n]=t.userData),this.m_handleIndexBuffer.data&&(this.m_handleIndexBuffer.data[n]=null);var s=this.m_proxyBuffer.data[this.m_proxyBuffer.Append()],a=e(t.lifetime,0),o=a>0;(this.m_expirationTimeBuffer.data||o)&&(this.SetParticleLifetime(n,o?a:this.ExpirationTimeToLifetime(-this.GetQuantizedTimeElapsed())),this.m_indexByExpirationTimeBuffer.data[n]=n),s.index=n;var h=e(t.group,null);return this.m_groupBuffer[n]=h,h&&(h.m_firstIndex0?n:r,e)},r.DestroyParticlesInShape=function(t,e,i){void 0===i&&(i=!1);var r=n.DestroyParticlesInShape_s_aabb;if(this.m_world.IsLocked())throw new Error;var s=new Sr(this,t,e,i),a=r;return t.ComputeAABB(a,e,0),this.m_world.QueryAABB(s,a),s.Destroyed()},r.CreateParticleGroup=function(t){var i=n.CreateParticleGroup_s_transform;if(this.m_world.IsLocked())throw new Error;var r=i;r.SetPositionAngle(e(t.position,j.ZERO),e(t.angle,0));var s=this.m_count;if(t.shape&&this.CreateParticlesWithShapeForGroup(t.shape,t,r),t.shapes&&this.CreateParticlesWithShapesForGroup(t.shapes,e(t.shapeCount,t.shapes.length),t,r),t.positionData)for(var a=e(t.particleCount,t.positionData.length),o=0;o0&&(this.m_lastBodyContactStepBuffer.data=this.RequestBuffer(this.m_lastBodyContactStepBuffer.data),this.m_bodyContactCountBuffer.data=this.RequestBuffer(this.m_bodyContactCountBuffer.data),this.m_consecutiveContactStepsBuffer.data=this.RequestBuffer(this.m_consecutiveContactStepsBuffer.data))},r.GetStuckCandidates=function(){return this.m_stuckParticleBuffer.Data()},r.GetStuckCandidateCount=function(){return this.m_stuckParticleBuffer.GetCount()},r.ComputeCollisionEnergy=function(){for(var t=n.ComputeCollisionEnergy_s_v,e=this.m_velocityBuffer.data,i=0,r=0;r0?this.GetQuantizedTimeElapsed()+s:s;a!==this.m_expirationTimeBuffer.data[t]&&(this.m_expirationTimeBuffer.data[t]=a,this.m_expirationTimeBufferRequiresSorting=!0)},r.GetParticleLifetime=function(t){return this.ExpirationTimeToLifetime(this.GetExpirationTimeBuffer()[t])},r.SetDestructionByAge=function(t){t&&this.GetExpirationTimeBuffer(),this.m_def.destroyByAge=t},r.GetDestructionByAge=function(){return this.m_def.destroyByAge},r.GetExpirationTimeBuffer=function(){return this.m_expirationTimeBuffer.data=this.RequestBuffer(this.m_expirationTimeBuffer.data),this.m_expirationTimeBuffer.data},r.ExpirationTimeToLifetime=function(t){return(t>0?t-this.GetQuantizedTimeElapsed():t)*this.m_def.lifetimeGranularity},r.GetIndexByExpirationTimeBuffer=function(){return this.GetParticleCount()?this.SetParticleLifetime(0,this.GetParticleLifetime(0)):this.m_indexByExpirationTimeBuffer.data=this.RequestBuffer(this.m_indexByExpirationTimeBuffer.data),this.m_indexByExpirationTimeBuffer.data},r.ParticleApplyLinearImpulse=function(t,e){this.ApplyLinearImpulse(t,t+1,e)},r.ApplyLinearImpulse=function(t,e,i){for(var n=this.m_velocityBuffer.data,r=(e-t)*this.GetParticleMass(),s=(new j).Copy(i).SelfMul(1/r),a=t;a=0;){var m=j.SubVV(e,u[c],s),g=j.DotVV(m,_),y=g*g-d*(j.DotVV(m,m)-this.m_squaredDiameter);if(y>=0){var v=V(y),b=(-g-v)/d;if(b>f)continue;if(b<0&&((b=(-g+v)/d)<0||b>f))continue;var S=j.AddVMulSV(m,b,_,o);if(S.Normalize(),(f=E(f,t.ReportParticle(this,c,j.AddVMulSV(e,b,_,h),S,b)))<=0)break}}}},r.ComputeAABB=function(t){var e=this.GetParticleCount();t.lowerBound.x=1e37,t.lowerBound.y=1e37,t.upperBound.x=-1e37,t.upperBound.y=-1e37;for(var i=this.m_positionBuffer.data,n=0;ne?e:t}if(t=e(t,this.m_def.maxCount),t=e(t,this.m_flagsBuffer.userSuppliedCapacity),t=e(t,this.m_positionBuffer.userSuppliedCapacity),t=e(t,this.m_velocityBuffer.userSuppliedCapacity),t=e(t,this.m_colorBuffer.userSuppliedCapacity),t=e(t,this.m_userDataBuffer.userSuppliedCapacity),this.m_internalAllocatedCapacity0;this.m_lastBodyContactStepBuffer.data=this.ReallocateBuffer4(this.m_lastBodyContactStepBuffer,this.m_internalAllocatedCapacity,t,i),this.m_bodyContactCountBuffer.data=this.ReallocateBuffer4(this.m_bodyContactCountBuffer,this.m_internalAllocatedCapacity,t,i),this.m_consecutiveContactStepsBuffer.data=this.ReallocateBuffer4(this.m_consecutiveContactStepsBuffer,this.m_internalAllocatedCapacity,t,i),this.m_positionBuffer.data=this.ReallocateBuffer4(this.m_positionBuffer,this.m_internalAllocatedCapacity,t,!1),this.m_velocityBuffer.data=this.ReallocateBuffer4(this.m_velocityBuffer,this.m_internalAllocatedCapacity,t,!1),this.m_forceBuffer=this.ReallocateBuffer5(this.m_forceBuffer,0,this.m_internalAllocatedCapacity,t,!1),this.m_weightBuffer=this.ReallocateBuffer5(this.m_weightBuffer,0,this.m_internalAllocatedCapacity,t,!1),this.m_staticPressureBuffer=this.ReallocateBuffer5(this.m_staticPressureBuffer,0,this.m_internalAllocatedCapacity,t,!0),this.m_accumulationBuffer=this.ReallocateBuffer5(this.m_accumulationBuffer,0,this.m_internalAllocatedCapacity,t,!1),this.m_accumulation2Buffer=this.ReallocateBuffer5(this.m_accumulation2Buffer,0,this.m_internalAllocatedCapacity,t,!0),this.m_depthBuffer=this.ReallocateBuffer5(this.m_depthBuffer,0,this.m_internalAllocatedCapacity,t,!0),this.m_colorBuffer.data=this.ReallocateBuffer4(this.m_colorBuffer,this.m_internalAllocatedCapacity,t,!0),this.m_groupBuffer=this.ReallocateBuffer5(this.m_groupBuffer,0,this.m_internalAllocatedCapacity,t,!1),this.m_userDataBuffer.data=this.ReallocateBuffer4(this.m_userDataBuffer,this.m_internalAllocatedCapacity,t,!0),this.m_expirationTimeBuffer.data=this.ReallocateBuffer4(this.m_expirationTimeBuffer,this.m_internalAllocatedCapacity,t,!0),this.m_indexByExpirationTimeBuffer.data=this.ReallocateBuffer4(this.m_indexByExpirationTimeBuffer,this.m_internalAllocatedCapacity,t,!1),this.m_internalAllocatedCapacity=t}},r.CreateParticleForGroup=function(t,i,n){var r=new zn;r.flags=e(t.flags,0),Q.MulXV(i,n,r.position),j.AddVV(e(t.linearVelocity,j.ZERO),j.CrossSV(e(t.angularVelocity,0),j.SubVV(r.position,e(t.position,j.ZERO),j.s_t0),j.s_t0),r.velocity),r.color.Copy(e(t.color,tt.ZERO)),r.lifetime=e(t.lifetime,0),r.userData=t.userData,this.CreateParticle(r)},r.CreateParticlesStrokeShapeForGroup=function(i,r,s){var a=n.CreateParticlesStrokeShapeForGroup_s_edge,o=n.CreateParticlesStrokeShapeForGroup_s_d,h=n.CreateParticlesStrokeShapeForGroup_s_p,u=e(r.stride,0);0===u&&(u=this.GetParticleStride());for(var l=0,c=i.GetChildCount(),f=0;f=e&&_=e&&dy||j.DotVV(m,m)>y||j.DotVV(g,g)>y)return;var v=A.m_groupBuffer[t],b=A.m_groupBuffer[e],S=A.m_groupBuffer[i],w=A.m_triadBuffer.data[A.m_triadBuffer.Append()];w.indexA=t,w.indexB=e,w.indexC=i,w.flags=u|l|c,w.strength=E(E(v?v.m_strength:1,b?b.m_strength:1),S?S.m_strength:1);var x=(f.x+_.x+d.x)/3,T=(f.y+_.y+d.y)/3;w.pa.x=f.x-x,w.pa.y=f.y-T,w.pb.x=_.x-x,w.pb.y=_.y-T,w.pc.x=d.x-x,w.pc.y=d.y-T,w.ka=-j.DotVV(g,p),w.kb=-j.DotVV(p,m),w.kc=-j.DotVV(m,g),w.s=j.CrossVV(f,_)+j.CrossVV(_,d)+j.CrossVV(d,f)}})),$n(this.m_triadBuffer.data,0,this.m_triadBuffer.count,n.CompareTriadIndices),this.m_triadBuffer.Unique(n.MatchTriadIndices)}},r.UpdatePairsAndTriadsWithReactiveParticles=function(){var e=new Tr(this.m_flagsBuffer);this.UpdatePairsAndTriads(0,this.m_count,e);for(var i=0;iO&&(this.m_depthBuffer[B]=O,A=!0),E>k&&(this.m_depthBuffer[I]=k,A=!0)}if(!A)break}for(var R=0;R0)for(var i=this.GetParticleCount(),r=0;rthis.m_lastBodyContactStepBuffer.data[r]+1&&(this.m_consecutiveContactStepsBuffer.data[r]=0);this.m_bodyContactBuffer.SetCount(0),this.m_stuckParticleBuffer.SetCount(0);var s=t;this.ComputeAABB(s),null===this.UpdateBodyContacts_callback&&(this.UpdateBodyContacts_callback=new Ar(this));var a=this.UpdateBodyContacts_callback;a.m_contactFilter=this.GetFixtureContactFilter(),this.m_world.QueryAABB(a,s),this.m_def.strictContactCheck&&this.RemoveSpuriousBodyContacts(),this.NotifyBodyContactListenerPostContact(e)},r.Solve=function(e){var i=n.Solve_s_subStep;if(0!==this.m_count&&(this.m_expirationTimeBuffer.data&&this.SolveLifetimes(e),this.m_allParticleFlags&t.b2ParticleFlag.b2_zombieParticle&&this.SolveZombie(),this.m_needsUpdateAllParticleFlags&&this.UpdateAllParticleFlags(),this.m_needsUpdateAllGroupFlags&&this.UpdateAllGroupFlags(),!this.m_paused))for(this.m_iterationIndex=0;this.m_iterationIndexi&&r.SelfMul(V(i/s))}},r.SolveGravity=function(t){for(var e=n.SolveGravity_s_gravity,i=this.m_velocityBuffer.data,r=j.MulSV(t.dt*this.m_def.gravityScale,this.m_world.GetGravity(),e),s=0;s=0;){var R=p[k],F=this.m_groupBuffer[k];if(D!==F&&B!==F){var L=this.GetLinearVelocity(F,k,R,h),N=j.SubVV(R,T,u),z=j.SubVV(L,I,l),U=j.CrossVV(E,z),G=j.CrossVV(P,z)-j.CrossVV(N,E),H=j.CrossVV(P,N),W=void 0,q=void 0,X=c,Y=f;if(0===U){if(0===G)continue;if(!((q=-H/G)>=0&&q=0&&W<=1))continue}else{var J=G*G-4*H*U;if(J<0)continue;var K=V(J),Q=(-G-K)/(2*U),Z=(-G+K)/(2*U);if(Q>Z){var $=Q;Q=Z,Z=$}if(q=Q,j.AddVMulSV(P,q,E,X),j.AddVMulSV(N,q,z,Y),W=j.DotVV(X,Y)/j.DotVV(X,X),!(q>=0&&q=0&&W<=1)){if(!((q=Z)>=0&&q=0&&W<=1))continue}}var tt=_;tt.x=I.x+W*E.x-L.x,tt.y=I.y+W*E.y-L.y;var et=j.MulSV(v,tt,d);if(F&&this.IsRigidGroup(F)){var it=F.GetMass(),nt=F.GetInertia();it>0&&F.m_linearVelocity.SelfMulAdd(1/it,et),nt>0&&(F.m_angularVelocity+=j.CrossVV(j.SubVV(R,F.GetCenter(),j.s_t0),et)/nt)}else m[k].SelfAdd(tt);this.ParticleApplyForce(k,et.SelfMul(-e.inv_dt))}}}}},r.SolveStaticPressure=function(e){this.m_staticPressureBuffer=this.RequestBuffer(this.m_staticPressureBuffer);for(var i=this.GetCriticalPressure(e),n=this.m_def.staticPressureStrength*i,r=b*i,s=this.m_def.staticPressureRelaxation,a=0;ao){var _=l.body,d=l.mass,p=r[c],m=l.normal,g=j.MulSV(a*d*(f-o),m,i);s[c].SelfMulSub(h,g),_.ApplyLinearImpulse(g,p,!0)}}}for(var y=0;yo){var S=v.indexA,w=v.indexB,x=v.normal,T=j.MulSV(a*(b-o),x,i);s[S].SelfSub(T),s[w].SelfAdd(T)}}}},r.SolveSolid=function(t){var e=n.SolveSolid_s_f,i=this.m_velocityBuffer.data;this.m_depthBuffer=this.RequestBuffer(this.m_depthBuffer);for(var r=t.inv_dt*this.m_def.ejectionStrength,s=0;s=0?(C=E(C,M),D=O(D,M+1)):B=!0}Cr:s})),this.m_expirationTimeBufferRequiresSorting=!1);for(var s=r-1;s>=0;--s){var a=n[s],o=i[a];if(ee.weight:t.index3)return!0;var o=t.Copy(n.normal);o.SelfMul(r.m_particleDiameter*(1-n.weight));var h=j.AddVV(r.m_positionBuffer.data[n.index],o,e);if(!n.fixture.TestPoint(h)){for(var u=n.fixture.GetShape().GetChildCount(),c=0;cthis.m_stuckThreshold&&(this.m_stuckParticleBuffer.data[this.m_stuckParticleBuffer.Append()]=t)),this.m_lastBodyContactStepBuffer.data[t]=this.m_timestamp)},r.ValidateParticleIndex=function(t){return t>=0&&t0?1/n:0,e[0]=r>0?1/r:0,i[0]=j.CrossVV(j.SubVV(a,s,j.s_t0),o)},r.InitDampingParameterWithRigidGroupOrParticle=function(e,i,n,r,s,a,o,h){if(s&&r)this.InitDampingParameter(e,i,n,s.GetMass(),s.GetInertia(),s.GetCenter(),o,h);else{var u=this.m_flagsBuffer.data[a];this.InitDampingParameter(e,i,n,u&t.b2ParticleFlag.b2_wallParticle?0:this.GetParticleMass(),0,o,o,h)}},r.ComputeDampingImpulse=function(t,e,i,n,r,s,a){var o=t+e*i*i+n+r*s*s;return o>0?a/o:0},r.ApplyDamping=function(t,e,i,n,r,s,a,o){r&&n?(r.m_linearVelocity.SelfMulAdd(a*t,o),r.m_angularVelocity+=a*i*e):this.m_velocityBuffer.data[s].SelfMulAdd(a*t,o)},n}();fr.xTruncBits=12,fr.yTruncBits=12,fr.tagBits=32,fr.yOffset=1<>>0,this.m_xUpper=(i&fr.xMask)>>>0,this.m_yLower=(e&fr.yMask)>>>0,this.m_yUpper=(i&fr.yMask)>>>0,this.m_first=n,this.m_last=r}return t.prototype.GetNext=function(){for(;this.m_first>>0;if(t>=this.m_xLower&&t<=this.m_xUpper)return this.m_system.m_proxyBuffer.data[this.m_first++].index;this.m_first++}return y},t}(),mr=function(){this.next=null,this.count=0,this.index=0},gr=function(){function t(){}var e=t.prototype;return e.Allocate=function(t,e){return e},e.Clear=function(){},e.GetCount=function(){return 0},e.Invalidate=function(){},e.GetValidBuffer=function(){return[]},e.GetBuffer=function(){return[]},e.SetCount=function(){},t}(),yr=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.Initialize=function(){},i.Find=function(){return y},e}(gr),vr=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.Initialize=function(){},i.Find=function(){return y},e}(gr),br=function(){function t(){}var e=t.prototype;return e.IsNecessary=function(){return!0},e.ShouldCreatePair=function(){return!0},e.ShouldCreateTriad=function(){return!0},t}(),Sr=function(t){function e(e,i,n,r){var s;return(s=t.call(this)||this).m_callDestructionListener=!1,s.m_destroyed=0,s.m_system=e,s.m_shape=i,s.m_xf=n,s.m_callDestructionListener=r,s.m_destroyed=0,s}s(e,t);var i=e.prototype;return i.ReportFixture=function(){return!1},i.ReportParticle=function(t,e){return t===this.m_system&&(this.m_shape.TestPoint(this.m_xf,this.m_system.m_positionBuffer.data[e])&&(this.m_system.DestroyParticle(e,this.m_callDestructionListener),this.m_destroyed++),!0)},i.Destroyed=function(){return this.m_destroyed},e}(xn),wr=function(t){function e(e){var i;return(i=t.call(this)||this).m_threshold=0,i.m_threshold=e,i}s(e,t);var i=e.prototype;return i.ShouldCreatePair=function(t,e){return t0?1/f:0,p=_>0?1/_:0,m=this.m_system.m_flagsBuffer.data[r]&t.b2ParticleFlag.b2_wallParticle?0:this.m_system.GetParticleInvMass(),g=j.SubVV(o,c,a),y=j.CrossVV(g,h),v=m+d+p*y*y,b=this.m_system.m_bodyContactBuffer.data[this.m_system.m_bodyContactBuffer.Append()];b.index=r,b.body=l,b.fixture=e,b.weight=1-u*this.m_system.m_inverseDiameter,b.normal.Copy(h.SelfNeg()),b.mass=v>0?1/v:0,this.m_system.DetectStuckParticle(r)}},i}(ar);Ar.ReportFixtureAndParticle_s_n=new j,Ar.ReportFixtureAndParticle_s_rp=new j;var Cr=function(e){function i(t,i){var n;return(n=e.call(this,t)||this).m_step=i,n}s(i,e);var n=i.prototype;return n.ReportFixtureAndParticle=function(e,n,r){var s=i.ReportFixtureAndParticle_s_p1,a=i.ReportFixtureAndParticle_s_output,o=i.ReportFixtureAndParticle_s_input,h=i.ReportFixtureAndParticle_s_p,u=i.ReportFixtureAndParticle_s_v,c=i.ReportFixtureAndParticle_s_f,f=e.GetBody(),_=this.m_system.m_positionBuffer.data[r],d=this.m_system.m_velocityBuffer.data[r],p=a,m=o;if(0===this.m_system.m_iterationIndex){var g=Q.MulTXV(f.m_xf0,_,s);e.GetShape().GetType()===t.b2ShapeType.e_circleShape&&(g.SelfSub(f.GetLocalCenter()),K.MulRV(f.m_xf0.q,g,g),K.MulTRV(f.m_xf.q,g,g),g.SelfAdd(f.GetLocalCenter())),Q.MulXV(f.m_xf,g,m.p1)}else m.p1.Copy(_);if(j.AddVMulSV(_,this.m_step.dt,d,m.p2),m.maxFraction=1,e.RayCast(p,m,n)){var y=p.normal,v=h;v.x=(1-p.fraction)*m.p1.x+p.fraction*m.p2.x+l*y.x,v.y=(1-p.fraction)*m.p1.y+p.fraction*m.p2.y+l*y.y;var b=u;b.x=this.m_step.inv_dt*(v.x-_.x),b.y=this.m_step.inv_dt*(v.y-_.y),this.m_system.m_velocityBuffer.data[r].Copy(b);var S=c;S.x=this.m_step.inv_dt*this.m_system.GetParticleMass()*(d.x-b.x),S.y=this.m_step.inv_dt*this.m_system.GetParticleMass()*(d.y-b.y),this.m_system.ParticleApplyForce(r,S)}},n.ReportParticle=function(){return!1},i}(ar);Cr.ReportFixtureAndParticle_s_p1=new j,Cr.ReportFixtureAndParticle_s_output=new Vt,Cr.ReportFixtureAndParticle_s_input=new Lt,Cr.ReportFixtureAndParticle_s_p=new j,Cr.ReportFixtureAndParticle_s_v=new j,Cr.ReportFixtureAndParticle_s_f=new j;var Dr=function(){function e(t){this.m_newFixture=!1,this.m_locked=!1,this.m_clearForces=!0,this.m_contactManager=new An,this.m_bodyList=null,this.m_jointList=null,this.m_particleSystemList=null,this.m_bodyCount=0,this.m_jointCount=0,this.m_gravity=new j,this.m_allowSleep=!0,this.m_destructionListener=null,this.m_debugDraw=null,this.m_inv_dt0=0,this.m_warmStarting=!0,this.m_continuousPhysics=!0,this.m_subStepping=!1,this.m_stepComplete=!0,this.m_profile=new Cn,this.m_island=new Nn,this.s_stack=[],this.m_controllerList=null,this.m_controllerCount=0,this.m_gravity.Copy(t)}var n=e.prototype;return n.SetDestructionListener=function(t){this.m_destructionListener=t},n.SetContactFilter=function(t){this.m_contactManager.m_contactFilter=t},n.SetContactListener=function(t){this.m_contactManager.m_contactListener=t},n.SetDebugDraw=function(t){this.m_debugDraw=t},n.CreateBody=function(t){if(void 0===t&&(t={}),this.IsLocked())throw new Error;var e=new Mi(t,this);return e.m_prev=null,e.m_next=this.m_bodyList,this.m_bodyList&&(this.m_bodyList.m_prev=e),this.m_bodyList=e,++this.m_bodyCount,e},n.DestroyBody=function(t){if(this.IsLocked())throw new Error;for(var e=t.m_jointList;e;){var i=e;e=e.next,this.m_destructionListener&&this.m_destructionListener.SayGoodbyeJoint(i.joint),this.DestroyJoint(i.joint),t.m_jointList=e}t.m_jointList=null;for(var n=t.m_controllerList;n;){var r=n;n=n.nextController,r.controller.RemoveBody(t)}for(var s=t.m_contactList;s;){var a=s;s=s.next,this.m_contactManager.Destroy(a.contact)}t.m_contactList=null;for(var o=t.m_fixtureList;o;){var h=o;o=o.m_next,this.m_destructionListener&&this.m_destructionListener.SayGoodbyeFixture(h),h.DestroyProxies(),h.Reset(),t.m_fixtureList=o,t.m_fixtureCount-=1}t.m_fixtureList=null,t.m_fixtureCount=0,t.m_prev&&(t.m_prev.m_next=t.m_next),t.m_next&&(t.m_next.m_prev=t.m_prev),t===this.m_bodyList&&(this.m_bodyList=t.m_next),--this.m_bodyCount},e._Joint_Create=function(e){switch(e.type){case t.b2JointType.e_distanceJoint:return new Fi(e);case t.b2JointType.e_mouseJoint:return new qi(e);case t.b2JointType.e_prismaticJoint:return new Yi(e);case t.b2JointType.e_revoluteJoint:return new Zi(e);case t.b2JointType.e_pulleyJoint:return new Ki(e);case t.b2JointType.e_gearJoint:return new Gi(e);case t.b2JointType.e_wheelJoint:return new sn(e);case t.b2JointType.e_weldJoint:return new nn(e);case t.b2JointType.e_frictionJoint:return new zi(e);case t.b2JointType.e_ropeJoint:return new tn(e);case t.b2JointType.e_motorJoint:return new Wi(e);case t.b2JointType.e_areaJoint:return new Vi(e)}throw new Error},e._Joint_Destroy=function(){},n.CreateJoint=function(t){if(this.IsLocked())throw new Error;var i=e._Joint_Create(t);i.m_prev=null,i.m_next=this.m_jointList,this.m_jointList&&(this.m_jointList.m_prev=i),this.m_jointList=i,++this.m_jointCount,i.m_edgeA.prev=null,i.m_edgeA.next=i.m_bodyA.m_jointList,i.m_bodyA.m_jointList&&(i.m_bodyA.m_jointList.prev=i.m_edgeA),i.m_bodyA.m_jointList=i.m_edgeA,i.m_edgeB.prev=null,i.m_edgeB.next=i.m_bodyB.m_jointList,i.m_bodyB.m_jointList&&(i.m_bodyB.m_jointList.prev=i.m_edgeB),i.m_bodyB.m_jointList=i.m_edgeB;var n=i.m_bodyA,r=i.m_bodyB;if(!i.m_collideConnected)for(var s=r.GetContactList();s;)s.other===n&&s.contact.FlagForFiltering(),s=s.next;return i},n.DestroyJoint=function(t){if(this.IsLocked())throw new Error;t.m_prev&&(t.m_prev.m_next=t.m_next),t.m_next&&(t.m_next.m_prev=t.m_prev),t===this.m_jointList&&(this.m_jointList=t.m_next);var i=t.m_bodyA,n=t.m_bodyB,r=t.m_collideConnected;if(i.SetAwake(!0),n.SetAwake(!0),t.m_edgeA.prev&&(t.m_edgeA.prev.next=t.m_edgeA.next),t.m_edgeA.next&&(t.m_edgeA.next.prev=t.m_edgeA.prev),t.m_edgeA===i.m_jointList&&(i.m_jointList=t.m_edgeA.next),t.m_edgeA.Reset(),t.m_edgeB.prev&&(t.m_edgeB.prev.next=t.m_edgeB.next),t.m_edgeB.next&&(t.m_edgeB.next.prev=t.m_edgeB.prev),t.m_edgeB===n.m_jointList&&(n.m_jointList=t.m_edgeB.next),t.m_edgeB.Reset(),e._Joint_Destroy(t),--this.m_jointCount,!r)for(var s=n.GetContactList();s;)s.other===i&&s.contact.FlagForFiltering(),s=s.next},n.CreateParticleSystem=function(t){if(this.IsLocked())throw new Error;var e=new fr(t,this);return e.m_prev=null,e.m_next=this.m_particleSystemList,this.m_particleSystemList&&(this.m_particleSystemList.m_prev=e),this.m_particleSystemList=e,e},n.DestroyParticleSystem=function(t){if(this.IsLocked())throw new Error;t.m_prev&&(t.m_prev.m_next=t.m_next),t.m_next&&(t.m_next.m_prev=t.m_prev),t===this.m_particleSystemList&&(this.m_particleSystemList=t.m_next)},n.CalculateReasonableParticleIterations=function(t){if(null===this.m_particleSystemList)return 1;return Un(this.m_gravity.Length(),function(t){for(var e=i,n=t.GetParticleSystemList();null!==n;n=n.m_next)e=E(e,n.GetRadius());return e}(this),t)},n.Step=function(t,i,n,r){void 0===r&&(r=this.CalculateReasonableParticleIterations(t));var s=e.Step_s_stepTimer.Reset();this.m_newFixture&&(this.m_contactManager.FindNewContacts(),this.m_newFixture=!1),this.m_locked=!0;var a=e.Step_s_step;a.dt=t,a.velocityIterations=i,a.positionIterations=n,a.particleIterations=r,a.inv_dt=t>0?1/t:0,a.dtRatio=this.m_inv_dt0*t,a.warmStarting=this.m_warmStarting;var o=e.Step_s_timer.Reset();if(this.m_contactManager.Collide(),this.m_profile.collide=o.GetMilliseconds(),this.m_stepComplete&&a.dt>0){for(var h=e.Step_s_timer.Reset(),u=this.m_particleSystemList;u;u=u.m_next)u.Solve(a);this.Solve(a),this.m_profile.solve=h.GetMilliseconds()}if(this.m_continuousPhysics&&a.dt>0){var l=e.Step_s_timer.Reset();this.SolveTOI(a),this.m_profile.solveTOI=l.GetMilliseconds()}a.dt>0&&(this.m_inv_dt0=a.inv_dt),this.m_clearForces&&this.ClearForces(),this.m_locked=!1,this.m_profile.step=s.GetMilliseconds()},n.ClearForces=function(){for(var t=this.m_bodyList;t;t=t.m_next)t.m_force.SetZero(),t.m_torque=0},n.DrawParticleSystem=function(t){if(null!==this.m_debugDraw){var e=t.GetParticleCount();if(e){var i=t.GetRadius(),n=t.GetPositionBuffer();if(t.m_colorBuffer.data){var r=t.GetColorBuffer();this.m_debugDraw.DrawParticles(n,i,r,e)}else this.m_debugDraw.DrawParticles(n,i,null,e)}}},n.DrawDebugData=function(){if(null!==this.m_debugDraw){var i=this.m_debugDraw.GetFlags(),n=e.DrawDebugData_s_color.SetRGB(0,0,0);if(i&t.b2DrawFlags.e_shapeBit)for(var r=this.m_bodyList;r;r=r.m_next){var s=r.m_xf;this.m_debugDraw.PushTransform(s);for(var a=r.GetFixtureList();a;a=a.m_next)r.IsActive()?r.GetType()===t.b2BodyType.b2_staticBody?(n.SetRGB(.5,.9,.5),this.DrawShape(a,n)):r.GetType()===t.b2BodyType.b2_kinematicBody?(n.SetRGB(.5,.5,.9),this.DrawShape(a,n)):r.IsAwake()?(n.SetRGB(.9,.7,.7),this.DrawShape(a,n)):(n.SetRGB(.6,.6,.6),this.DrawShape(a,n)):(n.SetRGB(.5,.5,.3),this.DrawShape(a,n));this.m_debugDraw.PopTransform(s)}if(i&t.b2DrawFlags.e_particleBit)for(var o=this.m_particleSystemList;o;o=o.m_next)this.DrawParticleSystem(o);if(i&t.b2DrawFlags.e_jointBit)for(var h=this.m_jointList;h;h=h.m_next)this.DrawJoint(h);if(i&t.b2DrawFlags.e_aabbBit){n.SetRGB(.9,.3,.9);for(var u=e.DrawDebugData_s_vs,l=this.m_bodyList;l;l=l.m_next)if(l.IsActive())for(var c=l.GetFixtureList();c;c=c.m_next)for(var f=0;f0;){var c=h[--l];if(!c)throw new Error;if(r.AddBody(c),c.m_awakeFlag=!0,c.GetType()!==t.b2BodyType.b2_staticBody){for(var f=c.m_contactList;f;f=f.next){var _=f.contact;if(!_.m_islandFlag&&_.IsEnabled()&&_.IsTouching()){var d=_.m_fixtureA.m_isSensor,p=_.m_fixtureB.m_isSensor;if(!d&&!p){r.AddContact(_),_.m_islandFlag=!0;var m=f.other;m.m_islandFlag||(h[l++]=m,m.m_islandFlag=!0)}}}for(var g=c.m_jointList;g;g=g.next)if(!g.joint.m_islandFlag){var y=g.other;y.IsActive()&&(r.AddJoint(g.joint),g.joint.m_islandFlag=!0,y.m_islandFlag||(h[l++]=y,y.m_islandFlag=!0))}}}var v=new Cn;r.Solve(v,e,this.m_gravity,this.m_allowSleep),this.m_profile.solveInit+=v.solveInit,this.m_profile.solveVelocity+=v.solveVelocity,this.m_profile.solvePosition+=v.solvePosition;for(var b=0;b8)){var u=1;if(h.m_toiFlag)u=h.m_toi;else{var l=h.GetFixtureA(),c=h.GetFixtureB();if(l.IsSensor()||c.IsSensor())continue;var f=l.GetBody(),_=c.GetBody(),d=f.m_type,p=_.m_type,m=f.IsAwake()&&d!==t.b2BodyType.b2_staticBody,g=_.IsAwake()&&p!==t.b2BodyType.b2_staticBody;if(!m&&!g)continue;var y=f.IsBullet()||d!==t.b2BodyType.b2_dynamicBody,v=_.IsBullet()||p!==t.b2BodyType.b2_dynamicBody;if(!y&&!v)continue;var b=f.m_sweep.alpha0;f.m_sweep.alpha0<_.m_sweep.alpha0?(b=_.m_sweep.alpha0,f.m_sweep.Advance(b)):_.m_sweep.alpha0this.maxTimestep&&this.maxTimestep>0&&(i=this.maxTimestep);for(var n=this.m_bodyList;n;n=n.nextBody){var s=n.body;if(s.IsAwake()){var a=s.GetWorldVector(Y.MulMV(this.T,s.GetLocalVector(s.GetLinearVelocity(),j.s_t0),j.s_t1),e.Step_s_damping);s.SetLinearVelocity(j.AddVV(s.GetLinearVelocity(),j.MulSV(i,a,j.s_t0),j.s_t1))}}}},i.Draw=function(){},i.SetAxisAligned=function(t,e){this.T.ex.x=-t,this.T.ex.y=0,this.T.ey.x=0,this.T.ey.y=-e,this.maxTimestep=t>0||e>0?1/O(t,e):0},e}(Ir);kr.Step_s_damping=new j;var Rr=function(){function t(){this.m_count=0,this.m_ps=[],this.m_p0s=[],this.m_vs=[],this.m_ims=[],this.m_Ls=[],this.m_as=[],this.m_gravity=new j,this.m_damping=0,this.m_k2=1,this.m_k3=.1}var e=t.prototype;return e.GetVertexCount=function(){return this.m_count},e.GetVertices=function(){return this.m_ps},e.Initialize=function(t){this.m_count=t.count,this.m_ps=j.MakeArray(this.m_count),this.m_p0s=j.MakeArray(this.m_count),this.m_vs=j.MakeArray(this.m_count),this.m_ims=D(this.m_count);for(var e=0;e0?1/i:0}var n=this.m_count-1,r=this.m_count-2;this.m_Ls=D(n),this.m_as=D(r);for(var s=0;s0&&this.m_vs[n].SelfMulAdd(t,this.m_gravity),this.m_vs[n].SelfMul(i),this.m_ps[n].SelfMulAdd(t,this.m_vs[n]);for(var r=0;ro;)x=(m-=2*o)-this.m_as[i];for(;x<-3.14159265359;)x=(m+=2*o)-this.m_as[i];var T=-this.m_k3*w*x;n.SelfMulAdd(a*T,v),r.SelfMulAdd(h*T,b),s.SelfMulAdd(u*T,S)}}}},e.Draw=function(t){for(var e=new tt(.4,.5,.7),i=0;i1?e-1:0),n=1;n0&&!(t&t-1)},t.b2IsValid=R,t.b2Island=Nn,t.b2Jacobian=Pi,t.b2Joint=ki,t.b2JointDef=Oi,t.b2JointEdge=Ei,t.b2Log=function(){},t.b2MakeArray=C,t.b2MakeNullArray=function(t){for(var e=new Array(t),i=0;i>1&2147483647,t|=t>>2&1073741823,t|=t>>4&268435455,1+((t|=t>>8&16777215)|t>>16&65535)},t.b2Pair=Zt,t.b2PairLessThan=te,t.b2ParseInt=function(t){return parseInt(t,10)},t.b2ParseUInt=function(t){return Math.abs(parseInt(t,10))},t.b2ParticleBodyContact=hr,t.b2ParticleContact=or,t.b2ParticleDef=zn,t.b2ParticleGroup=jn,t.b2ParticleGroupDef=Wn,t.b2ParticleHandle=Hn,t.b2ParticlePair=ur,t.b2ParticlePairSet=vr,t.b2ParticleSystem=fr,t.b2ParticleSystemDef=cr,t.b2ParticleSystem_CompositeShape=xr,t.b2ParticleSystem_ConnectionFilter=br,t.b2ParticleSystem_DestroyParticlesInShapeCallback=Sr,t.b2ParticleSystem_FixedSetAllocator=gr,t.b2ParticleSystem_FixtureParticle=function(t,e){this.second=y,this.first=t,this.second=e},t.b2ParticleSystem_FixtureParticleSet=yr,t.b2ParticleSystem_InsideBoundsEnumerator=pr,t.b2ParticleSystem_JoinParticleGroupsFilter=wr,t.b2ParticleSystem_ParticleListNode=mr,t.b2ParticleSystem_ParticlePair=function(t,e){this.first=y,this.second=y,this.first=t,this.second=e},t.b2ParticleSystem_Proxy=dr,t.b2ParticleSystem_ReactiveFilter=Tr,t.b2ParticleSystem_SolveCollisionCallback=Cr,t.b2ParticleSystem_UpdateBodyContactsCallback=Ar,t.b2ParticleSystem_UserOverridableBuffer=_r,t.b2ParticleTriad=lr,t.b2PolygonAndCircleContact=fn,t.b2PolygonContact=cn,t.b2PolygonShape=bi,t.b2Position=Bn,t.b2PositionSolverManifold=Fn,t.b2Pow=N,t.b2PrismaticJoint=Yi,t.b2PrismaticJointDef=Xi,t.b2Profile=Cn,t.b2PulleyJoint=Ki,t.b2PulleyJointDef=Ji,t.b2QueryCallback=xn,t.b2RadToDeg=function(t){return t*I},t.b2Random=function(){return 2*Math.random()-1},t.b2RandomRange=function(t,e){return(e-t)*Math.random()+t},t.b2RayCastCallback=Tn,t.b2RayCastInput=Lt,t.b2RayCastOutput=Vt,t.b2RevoluteJoint=Zi,t.b2RevoluteJointDef=Qi,t.b2Rope=Rr,t.b2RopeDef=function(){this.vertices=[],this.count=0,this.masses=[],this.gravity=new j(0,0),this.damping=.1,this.k2=.9,this.k3=.1},t.b2RopeJoint=tn,t.b2RopeJointDef=$i,t.b2Rot=K,t.b2SeparationFunction=fe,t.b2Shape=yi,t.b2ShapeCast=function(t,e){t.iterations=0,t.lambda=1,t.normal.SetZero(),t.point.SetZero();var i=e.proxyA,n=e.proxyB,r=O(i.m_radius,f)+O(n.m_radius,f),s=e.transformA,a=e.transformB,o=e.translationB,h=St.Set(0,0),u=0,l=wt;l.m_count=0;for(var c=l.m_vertices,_=i.GetSupport(K.MulTRV(s.q,j.NegV(o,j.s_t1),j.s_t0)),d=Q.MulXV(s,i.GetVertex(_),xt),p=n.GetSupport(K.MulTRV(a.q,o,j.s_t0)),m=Q.MulXV(a,n.GetVertex(p),Tt),g=j.SubVV(d,m,At),y=O(f,r-f),v=0;v<20&&P(g.Length()-y)>.004;){t.iterations+=1,_=i.GetSupport(K.MulTRV(s.q,j.NegV(g,j.s_t1),j.s_t0)),d=Q.MulXV(s,i.GetVertex(_),xt),p=n.GetSupport(K.MulTRV(a.q,g,j.s_t0)),m=Q.MulXV(a,n.GetVertex(p),Tt);var b=j.SubVV(d,m,Ct);g.Normalize();var S=j.DotVV(g,b),w=j.DotVV(g,o);if(S-y>u*w){if(w<=0)return!1;if((u=(S-y)/w)>1)return!1;h.Copy(g).SelfNeg(),l.m_count=0}var x=c[l.m_count];switch(x.indexA=p,x.wA.Copy(m).SelfMulAdd(u,o),x.indexB=_,x.wB.Copy(d),x.w.Copy(x.wB).SelfSub(x.wA),x.a=1,l.m_count+=1,l.m_count){case 1:break;case 2:l.Solve2();break;case 3:l.Solve3()}if(3===l.m_count)return!1;l.GetClosestPoint(g),++v}var T=Dt,A=Bt;return l.GetWitnessPoints(T,A),g.LengthSquared()>0&&(h.Copy(g).SelfNeg(),h.Normalize()),t.normal.Copy(h),t.lambda=u,t.iterations=v,!0},t.b2ShapeCastInput=function(){this.proxyA=new st,this.proxyB=new st,this.transformA=new Q,this.transformB=new Q,this.translationB=new j},t.b2ShapeCastOutput=function(){this.point=new j,this.normal=new j,this.lambda=0,this.iterations=0},t.b2Simplex=lt,t.b2SimplexCache=at,t.b2SimplexVertex=ut,t.b2Sin=U,t.b2SolverData=Mn,t.b2Sq=F,t.b2Sqrt=V,t.b2StackAllocator=function(){},t.b2Swap=function(t,e){var i=t[0];t[0]=e[0],e[0]=i},t.b2Sweep=$,t.b2TOIInput=ue,t.b2TOIOutput=ce,t.b2TensorDampingController=kr,t.b2TestOverlapAABB=zt,t.b2TestOverlapShape=jt,t.b2TimeOfImpact=we,t.b2TimeStep=Dn,t.b2Timer=it,t.b2Transform=Q,t.b2TreeNode=Xt,t.b2Vec2=j,t.b2Vec2_zero=q,t.b2Vec3=X,t.b2Velocity=In,t.b2VelocityConstraintPoint=En,t.b2Version=T,t.b2WeldJoint=nn,t.b2WeldJointDef=en,t.b2WheelJoint=sn,t.b2WheelJointDef=rn,t.b2World=Dr,t.b2WorldManifold=Rt,t.b2_180_over_pi=I,t.b2_aabbExtension=h,t.b2_aabbMultiplier=2,t.b2_angularSleepTolerance=x,t.b2_angularSlop=c,t.b2_barrierCollisionTime=2.5,t.b2_baumgarte=.2,t.b2_branch="master",t.b2_commit="fbf51801d80fc389d43dc46524520e89043b6faf",t.b2_epsilon=r,t.b2_epsilon_sq=a,t.b2_gjk_reset=function(){t.b2_gjkCalls=0,t.b2_gjkIters=0,t.b2_gjkMaxIters=0},t.b2_invalidParticleIndex=y,t.b2_linearSleepTolerance=w,t.b2_linearSlop=l,t.b2_maxAngularCorrection=d,t.b2_maxFloat=i,t.b2_maxLinearCorrection=_,t.b2_maxManifoldPoints=2,t.b2_maxParticleForce=.5,t.b2_maxParticleIndex=2147483647,t.b2_maxParticlePressure=b,t.b2_maxPolygonVertices=8,t.b2_maxRotation=m,t.b2_maxRotationSquared=g,t.b2_maxSubSteps=8,t.b2_maxTOIContacts=32,t.b2_maxTranslation=2,t.b2_maxTranslationSquared=4,t.b2_maxTriadDistance=2,t.b2_maxTriadDistanceSquared=4,t.b2_minParticleSystemBufferCapacity=S,t.b2_minParticleWeight=1,t.b2_minPulleyLength=2,t.b2_particleStride=v,t.b2_pi=o,t.b2_pi_over_180=B,t.b2_polygonRadius=f,t.b2_timeToSleep=.5,t.b2_toiBaumgarte=.75,t.b2_toi_reset=function(){t.b2_toiTime=0,t.b2_toiMaxTime=0,t.b2_toiCalls=0,t.b2_toiIters=0,t.b2_toiMaxIters=0,t.b2_toiRootIters=0,t.b2_toiMaxRootIters=0},t.b2_two_pi=M,t.b2_velocityThreshold=1,t.b2_version=A,t.g_blockSolve=Pn,Object.defineProperty(t,"__esModule",{value:!0})}(DSt);var BSt=DSt;CSt(BSt);var ISt=BSt,MSt={};for(var PSt in ISt)-1===PSt.indexOf("b2_")&&(MSt[PSt.replace("b2","")]=ISt[PSt]);var ESt=CSt(MSt),OSt=t("f7",{Static:0,Kinematic:1,Dynamic:2,Animated:3});Ee(OSt),Ee(t("f8",{None:0,BOX:1,CIRCLE:2,POLYGON:3})),Ee(t("f9",{None:0,DISTANCE:1,SPRING:2,WHEEL:3,MOUSE:4,FIXED:5,SLIDER:6,RELATIVE:7,HINGE:8}));var kSt=t("fa",{DEFAULT:1});Ee(kSt),t("fb",kSt),t("fc",{Closest:0,Any:1,AllClosest:2,All:3});var RSt=t("fd",{None:"none-contact",BEGIN_CONTACT:"begin-contact",END_CONTACT:"end-contact",PRE_SOLVE:"pre-solve",POST_SOLVE:"post-solve"}),FSt=(t("fe",{None:0,Shape:1,Joint:2,Aabb:4,Pair:8,CenterOfMass:16,Particle:32,Controller:64,All:63}),t("ff",32)),LSt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r=3?1:n):-1},i.getFixtures=function(){return this._fixtures},i.getPoints=function(){return this._points},i.getNormals=function(){return this._normals},i.getFractions=function(){return this._fractions},e}(ESt.RayCastCallback);function zSt(t,e){var i=e.length;return e[t<0?i- -t%i:t%i]}function USt(t,e,i){for(var n=[];e0}function qSt(t,e,i){return twt(t,e,i)>=0}function XSt(t,e,i){return twt(t,e,i)<=0}function YSt(t,e){var i=e.x-t.x,n=e.y-t.y;return i*i+n*n}function JSt(t){KSt(t)||t.reverse()}function KSt(t){return t.length<3||QSt(t)>0}function QSt(t){var e,i=0;for(e=0;e0&&_<1&&d>0&&d<1&&(r.x=s+_*(o-s),r.y=a+_*(h-a),!0))}function twt(t,e,i){return t.x*(e.y-i.y)+e.x*(i.y-t.y)+i.x*(t.y-e.y)}var ewt=Object.freeze({__proto__:null,ConvexPartition:function t(e){JSt(e);for(var i,n,r,s=[],a=0,o=0,h=0,u=new ds,l=new ds,c=0,f=0,_=0;_m&&(g=y,m=v)}n=USt(_,g,e),r=USt(g,_,e)}return(s=s.concat(t(n))).concat(t(r))}s.push(e);for(var b=s.length-1;b>=0;b--)0==s[b].length&&s.splice(b,0);return s},ForceCounterClockWise:JSt,IsCounterClockWise:KSt});function iwt(t){hwt(t);for(var e=!0,i=0,n=t.length;i0||rwt(c,l,a[(o+2)%h])>0)){for(var m=[],g=(o+1)%h;g!==o;g=(g+1)%h)m.push(a[g]);m.push(u,c),a=m,h=m.length,o=-1,s.splice(f,1)}}r.push(a)}return r}var nwt=function(){this.isActive=!1,this.isConvex=!1,this.isEar=!1,this.point=null,this.angleCos=0,this.shouldUpdate=!1,this.index=0,this.prev=null,this.next=null};function rwt(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function swt(t,e,i){return rwt(t,e,i)<0}function awt(t,e){return t.x===e.x&&t.y===e.y}function owt(t){for(var e=0,i=0,n=t.length;i0}function hwt(t){owt(t)&&t.reverse()}function uwt(t,e){if(t.shouldUpdate){t.shouldUpdate=!1;var i=t.prev.point,n=t.point,r=t.next.point;t.isConvex=swt(i,n,r);var s=i.x-n.x,a=i.y-n.y,o=Math.sqrt(s*s+a*a);s/=o,a/=o;var h=r.x-n.x,u=r.y-n.y,l=Math.sqrt(h*h+u*u);if(h/=l,u/=l,t.angleCos=s*h+a*u,t.isConvex){t.isEar=!0;for(var c=0,f=e.length;c0&&m>0&&g>0){t.isEar=!1;break}if(0===p&&m>=0&&g>=0&&(rwt(i,_.prev.point,n)>0||rwt(i,_.next.point,n)>0)){t.isEar=!1;break}if(0===m&&p>=0&&g>=0&&(rwt(n,_.prev.point,r)>0||rwt(n,_.next.point,r)>0)){t.isEar=!1;break}if(0===g&&p>=0&&m>=0&&(rwt(r,_.prev.point,i)>0||rwt(r,_.next.point,i)>0)){t.isEar=!1;break}}}}}else t.isEar=!1}}function lwt(t){for(var e=t,i=t;;)if(awt(e.point,e.next.point)||0===rwt(e.prev.point,e.point,e.next.point)){if(e.prev.next=e.next,e.next.prev=e.prev,e.prev.shouldUpdate=!0,e.next.shouldUpdate=!0,e===e.next)break;i=e.prev,e=e.next}else if((e=e.next)===i)break}function cwt(t){if(hwt(t),t.length<4)return[t];for(var e=t.length,i=[],n=[],r=0;ru.angleCos&&(u=c):u=c)}if(!u){for(var f=0;f1e-5)return it(9644),null}}break}if(n.push([u.prev.point,u.point,u.next.point]),u.isActive=!1,u.prev.next=u.next,u.next.prev=u.prev,u.prev.shouldUpdate=!0,u.next.shouldUpdate=!0,lwt(u.next),h===e-4)break;for(var g=0;g1e-5&&n.push([b,S,w])}}return n}var fwt=Object.freeze({__proto__:null,ConvexPartition:iwt}),_wt=function(t){if(1===t){for(var e=this,i=function(t){var i="_"+(1<e;)this.physicsWorld.step(e,i,n),this._accumulator-=e;for(var s=this._delayEvents,a=0,o=s.length;a0){for(var a=r.getPoints(),o=r.getNormals(),h=r.getFractions(),u=[],l=0,c=s.length;lMath.PI&&(r-=Ji);var s=(this._animatedAngle-r)*n;this._animatedAngle<-Yi&&r>Yi&&(s=(this._animatedAngle+Ji-r)*n),this._animatedAngle>Yi&&r<-Yi&&(s=(this._animatedAngle-Ji-r)*n),e.SetAngularVelocity(s)}},e.syncSceneToPhysics=function(){var t=this._rigidBody.node.hasChangedFlags;t&&this.nodeTransformChanged(t)},e.syncPositionToPhysics=function(t){void 0===t&&(t=!1);var e=this._body;if(e){var i,n=this._rigidBody.node.worldPosition,r=this._rigidBody.type;(i=3===r?e.GetLinearVelocity():e.GetPosition()).x=n.x/FSt,i.y=n.y/FSt,3===r&&t?this._animatedPos.set(i.x,i.y):e.SetTransformVec(i,e.GetAngle())}},e.syncRotationToPhysics=function(t){void 0===t&&(t=!1);var e=this._body;if(e){var i=this._rigidBody.node.worldRotation,n=sCt;kr.toEulerInYXZOrder(n,i);var r=nn(n.z);3===this._rigidBody.type&&t?this._animatedAngle=r:e.SetTransformVec(e.GetPosition(),r)}},e.resetVelocity=function(){var t=this._body;if(t){var e=t.m_linearVelocity;e.Set(0,0),t.SetLinearVelocity(e),t.SetAngularVelocity(0)}},e.setType=function(t){pwt.instance.physicsWorld._updateBodyType(this),this._body.SetType(t)},e.setLinearDamping=function(t){this._body.SetLinearDamping(t)},e.setAngularDamping=function(t){this._body.SetAngularDamping(t)},e.setGravityScale=function(t){this._body.SetGravityScale(t)},e.setFixedRotation=function(t){this._body.SetFixedRotation(t)},e.setAllowSleep=function(t){this._body.SetSleepingAllowed(t)},e.isActive=function(){return this._body.IsActive()},e.setActive=function(t){this._body.m_world.IsLocked()||this._body.SetActive(t)},e.wakeUp=function(){this._body.SetAwake(!0)},e.sleep=function(){this._body.SetAwake(!1)},e.getMass=function(){return this._body.GetMass()},e.setLinearVelocity=function(t){this._body.SetLinearVelocity(t)},e.getLinearVelocity=function(t){var e=this._body.GetLinearVelocity();return t.x=e.x,t.y=e.y,t},e.getLinearVelocityFromWorldPoint=function(t,e){return aCt.Set(t.x/FSt,t.y/FSt),this._body.GetLinearVelocityFromWorldPoint(aCt,e),e.x*=FSt,e.y*=FSt,e},e.setAngularVelocity=function(t){this._body.SetAngularVelocity(t)},e.getAngularVelocity=function(){return this._body.GetAngularVelocity()},e.getLocalVector=function(t,e){return e=e||new ds,aCt.Set(t.x/FSt,t.y/FSt),this._body.GetLocalVector(aCt,e),e.x*=FSt,e.y*=FSt,e},e.getWorldVector=function(t,e){return aCt.Set(t.x/FSt,t.y/FSt),this._body.GetWorldVector(aCt,e),e.x*=FSt,e.y*=FSt,e},e.getLocalPoint=function(t,e){return e=e||new ds,aCt.Set(t.x/FSt,t.y/FSt),this._body.GetLocalPoint(aCt,e),e.x*=FSt,e.y*=FSt,e},e.getWorldPoint=function(t,e){return e=e||new ds,aCt.Set(t.x/FSt,t.y/FSt),this._body.GetWorldPoint(aCt,e),e.x*=FSt,e.y*=FSt,e},e.getLocalCenter=function(t){t=t||new ds;var e=this._body.GetLocalCenter();return t.x=e.x*FSt,t.y=e.y*FSt,t},e.getWorldCenter=function(t){t=t||new ds;var e=this._body.GetWorldCenter();return t.x=e.x*FSt,t.y=e.y*FSt,t},e.getInertia=function(){return this._body.GetInertia()},e.applyForce=function(t,e,i){this._body&&(aCt.Set(e.x/FSt,e.y/FSt),this._body.ApplyForce(t,aCt,i))},e.applyForceToCenter=function(t,e){this._body&&this._body.ApplyForceToCenter(t,e)},e.applyTorque=function(t,e){this._body&&this._body.ApplyTorque(t,e)},e.applyLinearImpulse=function(t,e,i){this._body&&(aCt.Set(e.x/FSt,e.y/FSt),this._body.ApplyLinearImpulse(t,aCt,i))},e.applyLinearImpulseToCenter=function(t,e){this._body&&this._body.ApplyLinearImpulse(t,this._body.GetPosition(),e)},e.applyAngularImpulse=function(t,e){this._body&&this._body.ApplyAngularImpulse(t,e)},n(t,[{key:"impl",get:function(){return this._body}},{key:"_imp",set:function(t){this._body=t}},{key:"rigidBody",get:function(){return this._rigidBody}},{key:"isAwake",get:function(){return this._body.IsAwake()}},{key:"isSleeping",get:function(){return!this._body.IsAwake()}}]),t}(),hCt=new ESt.Filter,uCt=new ESt.Vec2,lCt=new ESt.Vec2;function cCt(t){var e=t.collider;return e.body?hCt.categoryBits=1===e.group?e.body.group:e.group:hCt.categoryBits=e.group,hCt.maskBits=pwt.instance.collisionMatrix[hCt.categoryBits],hCt}var fCt,_Ct=function(){function t(){this._shapes=[],this._fixtures=[],this._collider=null,this._body=null,this._inited=!1,this._rect=new bs}var e=t.prototype;return e.initialize=function(t){this._collider=t},e.onLoad=function(){},e.onEnable=function(){pwt.instance._callAfterStep(this,this._init)},e.onDisable=function(){pwt.instance._callAfterStep(this,this._destroy)},e.start=function(){},e.onGroupChanged=function(){var t=cCt(this);this._fixtures.forEach((function(e){e.SetFilterData(t)}))},e.apply=function(){this._destroy(),this.collider.enabledInHierarchy&&this._init()},e.getFixtureIndex=function(t){return this._fixtures.indexOf(t)},e._createShapes=function(){return[]},e._init=function(){if(!this._inited){var t=this.collider,e=t.node.worldScale,i=ir.ZERO,n=t.getComponent(MAt);n&&n.impl&&n.impl.impl?this._body=n.impl.impl:(this._body=pwt.instance.physicsWorld.groundBodyImpl,i=t.node.worldPosition);for(var r=0===e.x&&0===e.y?[]:this._createShapes(e.x,e.y,i.x,i.y),s=cCt(this),a=0;a=0;i--){var n=t[i];n.m_userData=null,pwt.instance.physicsWorld.unregisterContactFixture(n),e&&e.DestroyFixture(n)}this._body=null,this._fixtures.length=0,this._shapes.length=0,this._inited=!1}},n(t,[{key:"impl",get:function(){return this._shapes}},{key:"collider",get:function(){return this._collider}},{key:"worldAABB",get:function(){for(var t=1e7,e=t,i=t,n=-1e7,r=-1e7,s=this._fixtures,a=0;an&&(n=lCt.x),lCt.y>r&&(r=lCt.y)}e*=FSt,i*=FSt,n*=FSt,r*=FSt;var c=this._rect;return c.x=e,c.y=i,c.width=n-e,c.height=r-i,c}}]),t}(),dCt=new bs,pCt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r0&&a[0].equals(a[a.length-1])&&(a.length-=1);var o=iwt(a);if(!o)return it(16408,s.node.name),r;for(var h=s.offset,u=0;u=0&&e.allMaterials.splice(i,1),!0}return!1},i.setValues=function(t,i,n,r){var s=this._friction!==t||this._rollingFriction!==i||this._spinningFriction!==n||this._restitution!==r;this._friction=t,this._rollingFriction=i,this._spinningFriction=n,this._restitution=r,s&&this.emit(e.EVENT_UPDATE)},n(e,[{key:"friction",get:function(){return this._friction},set:function(t){Qi(this._friction,t)||(this._friction=t,this.emit(e.EVENT_UPDATE))}},{key:"rollingFriction",get:function(){return this._rollingFriction},set:function(t){Qi(this._rollingFriction,t)||(this._rollingFriction=t,this.emit(e.EVENT_UPDATE))}},{key:"spinningFriction",get:function(){return this._spinningFriction},set:function(t){Qi(this._spinningFriction,t)||(this._spinningFriction=t,this.emit(e.EVENT_UPDATE))}},{key:"restitution",get:function(){return this._restitution},set:function(t){Qi(this._restitution,t)||(this._restitution=t,this.emit(e.EVENT_UPDATE))}}]),e}(Cm),pDt.allMaterials=[],pDt.EVENT_UPDATE="event_update",pDt._idCounter=0,v((lDt=pDt).prototype,"friction",[sDt],Object.getOwnPropertyDescriptor(lDt.prototype,"friction"),lDt.prototype),v(lDt.prototype,"rollingFriction",[aDt],Object.getOwnPropertyDescriptor(lDt.prototype,"rollingFriction"),lDt.prototype),v(lDt.prototype,"spinningFriction",[oDt],Object.getOwnPropertyDescriptor(lDt.prototype,"spinningFriction"),lDt.prototype),v(lDt.prototype,"restitution",[hDt],Object.getOwnPropertyDescriptor(lDt.prototype,"restitution"),lDt.prototype),cDt=zh(lDt.prototype,"_friction",[uu],(function(){return.6})),fDt=zh(lDt.prototype,"_rollingFriction",[uu],(function(){return 0})),_Dt=zh(lDt.prototype,"_spinningFriction",[uu],(function(){return 0})),dDt=zh(lDt.prototype,"_restitution",[uu],(function(){return 0})),uDt=lDt))||uDt)),TDt=t("fD",function(){function t(){this._hitPoint=new ir,this._hitNormal=new ir,this._distance=0,this._collider=null,this._closestHitFraction=0}var e=t.prototype;return e._assign=function(t,e,i,n,r){ir.copy(this._hitPoint,t),ir.copy(this._hitNormal,n),this._distance=e,this._collider=i,r&&(this._closestHitFraction=r)},e.clone=function(){var e=new t;return ir.copy(e._hitPoint,this._hitPoint),ir.copy(e._hitNormal,this._hitNormal),e._distance=this._distance,e._collider=this._collider,e._closestHitFraction=this._closestHitFraction,e},n(t,[{key:"hitPoint",get:function(){return this._hitPoint}},{key:"distance",get:function(){return this._distance}},{key:"collider",get:function(){return this._collider}},{key:"hitNormal",get:function(){return this._hitNormal}},{key:"closestHitFraction",get:function(){return this._closestHitFraction}}]),t}()),ADt=t("fE",function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r=this._fixedTimeStep)){this.physicsWorld.syncSceneToPhysics();break}this.physicsWorld.syncSceneToPhysics(),this.physicsWorld.step(this._fixedTimeStep),this.physicsWorld.emitEvents(),this.physicsWorld.syncAfterEvents(),this._accumulator-=this._fixedTimeStep,this._subStepCount++}YE.emit("director_after_physics")}}else this.physicsWorld.syncSceneToPhysics()},e.resetConfiguration=function(t){var e=t?t.allowSleep:GDt("physics","allowSleep");"boolean"==typeof e&&(this._allowSleep=e);var i=t?t.fixedTimeStep:GDt("physics","fixedTimeStep");"number"==typeof i&&(this._fixedTimeStep=i);var n=t?t.maxSubSteps:GDt("physics","maxSubSteps");"number"==typeof n&&(this._maxSubSteps=n);var r=t?t.sleepThreshold:GDt("physics","sleepThreshold");"number"==typeof r&&(this._sleepThreshold=r);var s=t?t.autoSimulation:GDt("physics","autoSimulation");"boolean"==typeof s&&(this.autoSimulation=s);var a=t?t.gravity:GDt("physics","gravity");a&&ir.copy(this._gravity,a);var o=t?t.collisionMatrix:GDt("physics","collisionMatrix");if(o)for(var h in o)this.collisionMatrix[""+(1<>>0,this.raycastOptions.maxDistance=i,this.raycastOptions.queryTrigger=n,this.physicsWorld.raycast(t,this.raycastOptions,this.raycastResultPool,this.raycastResults))},e.raycastClosest=function(t,e,i,n){return void 0===e&&(e=4294967295),void 0===i&&(i=1e7),void 0===n&&(n=!0),!!this.physicsWorld&&(this.raycastOptions.mask=e>>>0,this.raycastOptions.maxDistance=i,this.raycastOptions.queryTrigger=n,this.physicsWorld.raycastClosest(t,this.raycastOptions,this.raycastClosestResult))},e.lineStripCast=function(t,e,i,n){if(void 0===e&&(e=4294967295),void 0===i&&(i=1e7),void 0===n&&(n=!0),t.length<2)return!1;this.lineStripCastResults=[];for(var r=0,s=new Vs,a=1;ai);++a){var o=t[a-1],h=t[a],u=new ir;ir.subtract(u,h,o);var l=ir.len(u);if(r+=l,ir.multiplyScalar(u,u,1/l),s.d=u,s.o=o,this.raycast(s,e,l,n))for(var c=0;c0},e.lineStripCastClosest=function(t,e,i,n){if(void 0===e&&(e=4294967295),void 0===i&&(i=1e7),void 0===n&&(n=!0),t.length<2)return!1;for(var r=0,s=new Vs,a=!1,o=1;oi);++o){var h=t[o-1],u=t[o],l=new ir;ir.subtract(l,u,h);var c=ir.len(l);if(r+=c,ir.multiplyScalar(l,l,1/c),s.d=l,s.o=h,a=this.raycastClosest(s,e,c,n)){var f=this.raycastClosestResult,_=new ADt;_._assign(f.hitPoint,f.distance,f.collider,f.hitNormal,o-1),this.lineStripCastClosestResult=_;break}}return a},e.sweepBox=function(t,e,i,n,r,s){return void 0===n&&(n=4294967295),void 0===r&&(r=1e7),void 0===s&&(s=!0),!!this.physicsWorld&&(this.sweepResultPool.reset(),this.sweepCastResults.length=0,this.raycastOptions.mask=n>>>0,this.raycastOptions.maxDistance=r,this.raycastOptions.queryTrigger=s,this.physicsWorld.sweepBox(t,e,i,this.raycastOptions,this.sweepResultPool,this.sweepCastResults))},e.sweepBoxClosest=function(t,e,i,n,r,s){return void 0===n&&(n=4294967295),void 0===r&&(r=1e7),void 0===s&&(s=!0),!!this.physicsWorld&&(this.raycastOptions.mask=n>>>0,this.raycastOptions.maxDistance=r,this.raycastOptions.queryTrigger=s,this.physicsWorld.sweepBoxClosest(t,e,i,this.raycastOptions,this.sweepCastClosestResult))},e.sweepSphere=function(t,e,i,n,r){return void 0===i&&(i=4294967295),void 0===n&&(n=1e7),void 0===r&&(r=!0),!!this.physicsWorld&&(this.sweepResultPool.reset(),this.sweepCastResults.length=0,this.raycastOptions.mask=i>>>0,this.raycastOptions.maxDistance=n,this.raycastOptions.queryTrigger=r,this.physicsWorld.sweepSphere(t,e,this.raycastOptions,this.sweepResultPool,this.sweepCastResults))},e.sweepSphereClosest=function(t,e,i,n,r){return void 0===i&&(i=4294967295),void 0===n&&(n=1e7),void 0===r&&(r=!0),!!this.physicsWorld&&(this.raycastOptions.mask=i>>>0,this.raycastOptions.maxDistance=n,this.raycastOptions.queryTrigger=r,this.physicsWorld.sweepSphereClosest(t,e,this.raycastOptions,this.sweepCastClosestResult))},e.sweepCapsule=function(t,e,i,n,r,s,a){return void 0===r&&(r=4294967295),void 0===s&&(s=1e7),void 0===a&&(a=!0),!!this.physicsWorld&&(this.sweepResultPool.reset(),this.sweepCastResults.length=0,this.raycastOptions.mask=r>>>0,this.raycastOptions.maxDistance=s,this.raycastOptions.queryTrigger=a,this.physicsWorld.sweepCapsule(t,e,i,n,this.raycastOptions,this.sweepResultPool,this.sweepCastResults))},e.sweepCapsuleClosest=function(t,e,i,n,r,s,a){return void 0===r&&(r=4294967295),void 0===s&&(s=1e7),void 0===a&&(a=!0),!!this.physicsWorld&&(this.raycastOptions.mask=r>>>0,this.raycastOptions.maxDistance=s,this.raycastOptions.queryTrigger=a,this.physicsWorld.sweepCapsuleClosest(t,e,i,n,this.raycastOptions,this.sweepCastClosestResult))},e._updateMaterial=function(){this.physicsWorld&&this.physicsWorld.setDefaultMaterial(this._material)},i.constructAndRegister=function(){if(!i._instance){var t=this.doConstructAndRegister();t&&XO.onPostProjectInitDelegate.add(t.initDefaultMaterial.bind(t))}},i.constructAndRegisterManually=function(){return Promise.resolve()},i.doConstructAndRegister=function(){var t;if(null!==(t=GDt("physics","enabled"))&&void 0!==t&&!t)return null;if(!i._instance){var e=new i;i._instance=e,e.resetConfiguration(),MCt(e),YE.registerSystem(i.ID,e,e.priority)}return i._instance},n(i,[{key:"enable",get:function(){return this._enable},set:function(t){this._enable=t}},{key:"allowSleep",get:function(){return this._allowSleep},set:function(t){this._allowSleep=t,this.physicsWorld&&this.physicsWorld.setAllowSleep(t)}},{key:"maxSubSteps",get:function(){return this._maxSubSteps},set:function(t){this._maxSubSteps=t}},{key:"fixedTimeStep",get:function(){return this._fixedTimeStep},set:function(t){this._fixedTimeStep=t}},{key:"gravity",get:function(){return this._gravity},set:function(t){this._gravity.set(t),this.physicsWorld&&this.physicsWorld.setGravity(t)}},{key:"sleepThreshold",get:function(){return this._sleepThreshold},set:function(t){this._sleepThreshold=t}},{key:"autoSimulation",get:function(){return this._autoSimulation},set:function(t){this._autoSimulation=t}},{key:"defaultMaterial",get:function(){return this._material}},{key:"physicsWorld",get:function(){return ICt.physicsWorld}},{key:"debugDrawFlags",get:function(){return this.physicsWorld.debugDrawFlags},set:function(t){this.physicsWorld.debugDrawFlags=t}},{key:"debugDrawConstraintSize",get:function(){return this.physicsWorld.debugDrawConstraintSize},set:function(t){this.physicsWorld.debugDrawConstraintSize=t}}],[{key:"PHYSICS_NONE",get:function(){return!ICt.id}},{key:"PHYSICS_BUILTIN",get:function(){return"builtin"===ICt.id}},{key:"PHYSICS_CANNON",get:function(){return"cannon.js"===ICt.id}},{key:"PHYSICS_BULLET",get:function(){return"bullet"===ICt.id}},{key:"PHYSICS_PHYSX",get:function(){return"physx"===ICt.id}},{key:"PhysicsGroup",get:function(){return Awt}},{key:"instance",get:function(){return i._instance}}]),i}(Ff));HDt.ID="PHYSICS",HDt._instance=null,YE.once("director_init",(function(){HDt.constructAndRegister()}));var WDt,jDt,qDt,XDt,YDt,JDt,KDt,QDt,ZDt,$Dt,tBt,eBt=t("fz",(CDt=Kh("cc.RigidBody"),DDt=Zh(-1),BDt=Ou(HDt.PhysicsGroup),IDt=Ou(mwt),CDt(MDt=$h(MDt=DDt((UDt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r2||this._direction!==t&&(this._direction=t,this._shape&&this.shape.setDirection(t))}},{key:"height",get:function(){return 2*this._radius+this._cylinderHeight},set:function(t){var e=t-2*this._radius;e<0&&(e=0),this.cylinderHeight=e}},{key:"worldHeight",get:function(){return 2*this._radius*this._getRadiusScale()+this._cylinderHeight*this._getHeightScale()}},{key:"shape",get:function(){return this._shape}}]),e}(oBt),v(dBt.prototype,"direction",[fBt],Object.getOwnPropertyDescriptor(dBt.prototype,"direction"),dBt.prototype),pBt=zh(dBt.prototype,"_radius",[uu],(function(){return.5})),mBt=zh(dBt.prototype,"_cylinderHeight",[uu],(function(){return 1})),gBt=zh(dBt.prototype,"_direction",[uu],(function(){return 1})),_Bt=dBt))||_Bt)),xIt=t("fK",(yBt=Kh("cc.CylinderCollider"),vBt=Ou(gwt),yBt((SBt=function(t){function e(){var e;return(e=t.call(this,3)||this)._radius=wBt&&wBt(),e._height=xBt&&xBt(),e._direction=TBt&&TBt(),e}return s(e,t),n(e,[{key:"radius",get:function(){return this._radius},set:function(t){this._radius!==t&&(this._radius=Math.abs(t),this._shape&&this.shape.setRadius(t))}},{key:"height",get:function(){return this._height},set:function(t){this._height!==t&&(this._height=Math.abs(t),this._shape&&this.shape.setHeight(t))}},{key:"direction",get:function(){return this._direction},set:function(t){this._direction!==t&&(t<0||t>2||(this._direction=t,this._shape&&this.shape.setDirection(t)))}},{key:"shape",get:function(){return this._shape}}]),e}(oBt),v(SBt.prototype,"direction",[vBt],Object.getOwnPropertyDescriptor(SBt.prototype,"direction"),SBt.prototype),wBt=zh(SBt.prototype,"_radius",[uu],(function(){return.5})),xBt=zh(SBt.prototype,"_height",[uu],(function(){return 2})),TBt=zh(SBt.prototype,"_direction",[uu],(function(){return 1})),bBt=SBt))||bBt)),TIt=t("fL",(ABt=Kh("cc.ConeCollider"),CBt=Ou(gwt),ABt((BBt=function(t){function e(){var e;return(e=t.call(this,4)||this)._radius=IBt&&IBt(),e._height=MBt&&MBt(),e._direction=PBt&&PBt(),e}return s(e,t),n(e,[{key:"radius",get:function(){return this._radius},set:function(t){this._radius!==t&&(this._radius=Math.abs(t),this._shape&&this.shape.setRadius(t))}},{key:"height",get:function(){return this._height},set:function(t){this._height!==t&&(t<0&&(t=0),this._height=t,this._shape&&this.shape.setHeight(t))}},{key:"direction",get:function(){return this._direction},set:function(t){this._direction!==t&&(t<0||t>2||(this._direction=t,this._shape&&this.shape.setDirection(t)))}},{key:"shape",get:function(){return this._shape}}]),e}(oBt),v(BBt.prototype,"direction",[CBt],Object.getOwnPropertyDescriptor(BBt.prototype,"direction"),BBt.prototype),IBt=zh(BBt.prototype,"_radius",[uu],(function(){return.5})),MBt=zh(BBt.prototype,"_height",[uu],(function(){return 1})),PBt=zh(BBt.prototype,"_direction",[uu],(function(){return 1})),DBt=BBt))||DBt)),AIt=t("fJ",(EBt=Kh("cc.MeshCollider"),OBt=Ou(Pk),EBt((RBt=function(t){function e(){var e;return(e=t.call(this,5)||this)._mesh=FBt&&FBt(),e._convex=LBt&&LBt(),e}return s(e,t),e.prototype.onEnable=function(){if(t.prototype.onEnable.call(this),this.node){var e=this.node.getComponent(eBt);e&&e.isValid&&1===e.type&&!this.convex&&at(9630,this.node.name)}},n(e,[{key:"mesh",get:function(){return this._mesh},set:function(t){this._mesh!==t&&(this._mesh=t,this._shape&&this.shape.setMesh(this._mesh))}},{key:"convex",get:function(){return this._convex},set:function(t){this._convex!==t&&(this._convex=t,this._shape&&this._mesh&&this.shape.setMesh(this._mesh))}},{key:"shape",get:function(){return this._shape}}]),e}(oBt),v(RBt.prototype,"mesh",[OBt],Object.getOwnPropertyDescriptor(RBt.prototype,"mesh"),RBt.prototype),FBt=zh(RBt.prototype,"_mesh",[uu],(function(){return null})),LBt=zh(RBt.prototype,"_convex",[uu],(function(){return!1})),kBt=RBt))||kBt)),CIt=t("fB",Kh("cc.ConstantForce")(VBt=Qh(eBt)(VBt=$h((NBt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;rt)){for(var e=this.buffer.byteLength;e=HIt?this.tileSize=e.readDouble():this.tileSize=e.readFloat(),this.tileSize=Math.floor(100*this.tileSize)/100,e.readIntArray(this._blockCount),this.weightMapSize=e.readInt16(),this.lightMapSize=e.readInt16();var i=e.readInt();this.heights=new Uint16Array(i);for(var n=0;n=GIt){var o=e.readInt();this.normals=new Float32Array(o);for(var h=0;h=VIt){var c=e.readInt();this.layerBuffer=new Array(c);for(var f=0;f=NIt){var _=e.readInt();this._layerBinaryInfos=new Array(_);for(var d=0;d=HIt?this._layerBinaryInfos[d].tileSize=e.readDouble():this._layerBinaryInfos[d].tileSize=e.readFloat(),this._layerBinaryInfos[d].detailMapId=e.readString(),this._version>=zIt&&(this._layerBinaryInfos[d].normalMapId=e.readString(),this._version>=HIt?(this._layerBinaryInfos[d].roughness=e.readDouble(),this._layerBinaryInfos[d].metallic=e.readDouble()):(this._layerBinaryInfos[d].roughness=e.readFloat(),this._layerBinaryInfos[d].metallic=e.readFloat()))}return!0},i._exportNativeData=function(){var t=new qIt;t.writeInt32(WIt),t.writeDouble(this.tileSize),t.writeIntArray(this._blockCount),t.writeInt16(this.weightMapSize),t.writeInt16(this.lightMapSize),t.writeInt32(this.heights.length);for(var e=0;e=0&&(be(this.ghostStruct.wrappedShapes,i),t.setCompound(0),this.ghostEnabled=!1)}else{var n=this.bodyStruct.wrappedShapes.indexOf(t);n>=0&&(this.bodyStruct.useCompound?t.setCompound(0):qCt.CollisionObject_setCollisionShape(this.body,qCt.EmptyShape_static()),qCt.CollisionObject_activate(this.body,!0),this.dirty|=1,be(this.bodyStruct.wrappedShapes,n),this.bodyEnabled=!1)}},e.addJoint=function(t,e){e?this.wrappedJoints1.indexOf(t)<0&&this.wrappedJoints1.push(t):this.wrappedJoints0.indexOf(t)<0&&this.wrappedJoints0.push(t)},e.removeJoint=function(t,e){if(e){var i=this.wrappedJoints1.indexOf(t);i>=0&&be(this.wrappedJoints1,i)}else{var n=this.wrappedJoints0.indexOf(t);n>=0&&be(this.wrappedJoints0,n)}},e.updateDirty=function(){this.dirty&&(this.bodyIndex>=0&&1&this.dirty&&this.updateBodyByReAdd(),this.ghostIndex>=0&&2&this.dirty&&this.updateGhostByReAdd(),this.dirty=0)},e.syncSceneToPhysics=function(){if(this.node.hasChangedFlags){var t=QCt.instance.BT_QUAT_0,e=qCt.CollisionObject_getWorldTransform(this.body);if(vDt(t,this.node.worldRotation),gDt(qCt.Transform_getOrigin(e),this.node.worldPosition),qCt.Transform_setRotation(e,t),4&this.node.hasChangedFlags&&this.syncBodyScale(),qCt.CollisionObject_isKinematicObject(this.body)){var i=qCt.RigidBody_getMotionState(this.body);i&&qCt.MotionState_setWorldTransform(i,e)}else this.isBodySleeping()&&qCt.CollisionObject_activate(this.body,!1)}},e.syncPhysicsToScene=function(){qCt.CollisionObject_isStaticOrKinematicObject(this.body)||this.syncPhysicsToGraphics()},e.syncPhysicsToGraphics=function(){if(!this.isBodySleeping()){var t=QCt.instance.BT_QUAT_0,e=QCt.instance.BT_TRANSFORM_0;qCt.RigidBody_getWorldTransform(this.body,e);var i=qCt.Transform_getRotationAndOrigin(e,t);if(this.node.worldRotation=bDt(bkt,t),this.node.worldPosition=yDt(vkt,i),this._ghostStruct){var n=qCt.CollisionObject_getWorldTransform(this.ghost);gDt(qCt.Transform_getOrigin(n),this.node.worldPosition),vDt(t,this.node.worldRotation),qCt.Transform_setRotation(n,t)}}},e.syncSceneToGhost=function(){if(this.node.hasChangedFlags){var t=QCt.instance.BT_QUAT_0,e=qCt.CollisionObject_getWorldTransform(this.ghost);gDt(qCt.Transform_getOrigin(e),this.node.worldPosition),vDt(t,this.node.worldRotation),qCt.Transform_setRotation(e,t),4&this.node.hasChangedFlags&&this.syncGhostScale(),qCt.CollisionObject_activate(this.ghost,!1)}},e.syncInitialBody=function(){var t=QCt.instance.BT_QUAT_0,e=qCt.CollisionObject_getWorldTransform(this.body);gDt(qCt.Transform_getOrigin(e),this.node.worldPosition),vDt(t,this.node.worldRotation),qCt.Transform_setRotation(e,t),this.syncBodyScale(),qCt.CollisionObject_activate(this.body,!1)},e.syncInitialGhost=function(){var t=QCt.instance.BT_QUAT_0,e=qCt.CollisionObject_getWorldTransform(this.ghost);gDt(qCt.Transform_getOrigin(e),this.node.worldPosition),vDt(t,this.node.worldRotation),qCt.Transform_setRotation(e,t),this.syncGhostScale(),qCt.CollisionObject_activate(this.body,!1)},e.syncBodyScale=function(){for(var t=0;t=0&&(this.wrappedWorld.removeSharedBody(this),this.bodyIndex=this.wrappedWorld.bodies.length,this.wrappedWorld.addSharedBody(this))},e.updateGhostByReAdd=function(){this.ghostIndex>=0&&(this.wrappedWorld.removeGhostObject(this),this.ghostIndex=this.wrappedWorld.ghosts.length,this.wrappedWorld.addGhostObject(this))},e.destroy=function(){if(t.sharedBodesMap.delete(this.node.uuid),this.node=null,this.wrappedWorld=null,this._bodyStruct){var e=this._bodyStruct;QCt.delWrapper(this.id,XCt.BODY_CACHE_NAME),qCt._safe_delete(e.motionState,3),qCt._safe_delete(e.compound,5),qCt._safe_delete(e.body,4),this._bodyStruct=null}if(this._ghostStruct){var i=this._ghostStruct;qCt._safe_delete(i.compound,5),qCt._safe_delete(i.ghost,4),this._ghostStruct=null}},e.isBodySleeping=function(){return qCt.CollisionObject_isSleeping(this.body)},n(t,[{key:"wrappedBody",get:function(){return this._wrappedBody}},{key:"bodyCompoundShape",get:function(){return this.bodyStruct.compound}},{key:"ghostCompoundShape",get:function(){return this.ghostStruct.compound}},{key:"body",get:function(){return this.bodyStruct.body}},{key:"ghost",get:function(){return this.ghostStruct.ghost}},{key:"collisionFilterGroup",get:function(){return this._collisionFilterGroup},set:function(t){t!==this._collisionFilterGroup&&(this._collisionFilterGroup=t,this.dirty|=1,this.dirty|=2)}},{key:"collisionFilterMask",get:function(){return this._collisionFilterMask},set:function(t){t!==this._collisionFilterMask&&(this._collisionFilterMask=t,this.dirty|=1,this.dirty|=2)}},{key:"bodyStruct",get:function(){return this._instantiateBodyStruct(),this._bodyStruct}},{key:"ghostStruct",get:function(){return this._instantiateGhostStruct(),this._ghostStruct}},{key:"bodyEnabled",set:function(t){if(t){if(this.bodyIndex<0){if(0===this.bodyStruct.wrappedShapes.length){if(!this.wrappedBody)return;if(!this.wrappedBody.rigidBody.isDynamic)return}this.bodyIndex=this.wrappedWorld.bodies.length,this.wrappedWorld.addSharedBody(this),this.syncInitialBody()}}else this.bodyIndex>=0&&(0===this.bodyStruct.wrappedShapes.length&&null==this.wrappedBody||0===this.bodyStruct.wrappedShapes.length&&null!=this.wrappedBody&&!this.wrappedBody.isEnabled||0===this.bodyStruct.wrappedShapes.length&&null!=this.wrappedBody&&!this.wrappedBody.rigidBody.enabledInHierarchy)&&(qCt.RigidBody_clearState(this.body),this.bodyIndex=-1,this.wrappedWorld.removeSharedBody(this))}},{key:"ghostEnabled",set:function(t){t?this.ghostIndex<0&&this.ghostStruct.wrappedShapes.length>0&&(this.ghostIndex=1,this.wrappedWorld.addGhostObject(this),this.syncInitialGhost()):this.ghostIndex>=0&&0===this.ghostStruct.wrappedShapes.length&&this.ghost&&(this.ghostIndex=-1,this.wrappedWorld.removeGhostObject(this))}},{key:"reference",set:function(t){t?this.ref++:this.ref--,0===this.ref&&this.destroy()}}]),t}();wkt.idCounter=0,wkt.sharedBodesMap=new Map;var xkt=ZCt,Tkt={},Akt=function(){function t(){this.id=t.idCounter++,this._isEnabled=!1,this._isTrigger=!1,this._isInitialized=!1,this._impl=0,this._compound=0,this.quat=qCt.Quat_new(0,0,0,1),this.transform=qCt.Transform_new(),this._collider=void 0,this._sharedBody=void 0}var e=t.prototype;return e.updateEventListener=function(){this._sharedBody.wrappedWorld.updateNeedEmitEvents(this.collider.needCollisionEvent||this.collider.needTriggerEvent)},e.setMaterial=function(t){var e=null==t?HDt.instance.defaultMaterial:t;if(!this._isTrigger&&this._isEnabled)if(this._compound){Tkt[e._uuid]||(Tkt[e._uuid]=qCt.ccMaterial_new());var i=Tkt[e._uuid];qCt.ccMaterial_set(i,e.restitution,e.friction,e.rollingFriction,e.spinningFriction),qCt.CollisionShape_setMaterial(this._impl,i)}else qCt.CollisionObject_setMaterial(this._sharedBody.body,e.restitution,e.friction,e.rollingFriction,e.spinningFriction)},e.setCenter=function(t){ir.copy(xkt,t),xkt.multiply(this._collider.node.worldScale),gDt(qCt.Transform_getOrigin(this.transform),xkt),this.updateCompoundTransform()},e.setAsTrigger=function(t){this._isTrigger!==t&&(this._isEnabled&&(this._sharedBody.removeShape(this,!t),this._sharedBody.addShape(this,t)),this._isTrigger=t)},e.getAABB=function(t){var e=QCt.instance.BT_TRANSFORM_0;qCt.Transform_setIdentity(e),qCt.Transform_setRotation(e,vDt(QCt.instance.BT_QUAT_0,this._collider.node.worldRotation));var i=QCt.instance.BT_V3_0,n=QCt.instance.BT_V3_1;qCt.CollisionShape_getAabb(this._impl,e,i,n),t.halfExtents.x=(qCt.Vec3_x(n)-qCt.Vec3_x(i))/2,t.halfExtents.y=(qCt.Vec3_y(n)-qCt.Vec3_y(i))/2,t.halfExtents.z=(qCt.Vec3_z(n)-qCt.Vec3_z(i))/2,ir.add(t.center,this._collider.node.worldPosition,this._collider.center)},e.getBoundingSphere=function(t){t.radius=qCt.CollisionShape_getLocalBoundingSphere(this._impl),ir.add(t.center,this._collider.node.worldPosition,this._collider.center)},e.initialize=function(t){this._collider=t,this._isInitialized=!0,this._sharedBody=HDt.instance.physicsWorld.getSharedBody(this._collider.node),this._sharedBody.reference=!0,this.onComponentSet(),this.setWrapper()},e.setWrapper=function(){QCt.isNotEmptyShape(this._impl)&&(qCt.CollisionShape_setUserPointer(this._impl,this._impl),QCt.setWrapper(this._impl,t.TYPE,this))},e.onLoad=function(){this.setCenter(this._collider.center),this.setAsTrigger(this._collider.isTrigger)},e.onEnable=function(){this._isEnabled=!0,this._sharedBody.addShape(this,this._isTrigger),this.setMaterial(this.collider.sharedMaterial)},e.onDisable=function(){this._isEnabled=!1,this._sharedBody.removeShape(this,this._isTrigger)},e.onDestroy=function(){this._sharedBody.reference=!1,this._collider=null,qCt._safe_delete(this.quat,1),qCt._safe_delete(this.transform,2),this._compound&&qCt._safe_delete(this._compound,5),QCt.isNotEmptyShape(this._impl)&&(qCt._safe_delete(this._impl,5),QCt.delWrapper(this._impl,t.TYPE))},e.updateByReAdd=function(){this._isEnabled&&(this._sharedBody.removeShape(this,this._isTrigger),this._sharedBody.addShape(this,this._isTrigger))},e.getGroup=function(){return this._sharedBody.collisionFilterGroup},e.setGroup=function(t){this._sharedBody.collisionFilterGroup=t},e.addGroup=function(t){this._sharedBody.collisionFilterGroup|=t},e.removeGroup=function(t){this._sharedBody.collisionFilterGroup&=~t},e.getMask=function(){return this._sharedBody.collisionFilterMask},e.setMask=function(t){this._sharedBody.collisionFilterMask=t},e.addMask=function(t){this._sharedBody.collisionFilterMask|=t},e.removeMask=function(t){this._sharedBody.collisionFilterMask&=~t},e.setCompound=function(t){this._compound&&qCt.CompoundShape_removeChildShape(this._compound,this._impl),t&&qCt.CompoundShape_addChildShape(t,this.transform,this._impl),this._compound=t},e.updateScale=function(){this.setCenter(this._collider.center)},e.updateCompoundTransform=function(){this._compound?qCt.CompoundShape_updateChildTransform(this._compound,this._impl,this.transform,!0):this._isEnabled&&!this._isTrigger&&this._sharedBody&&!this._sharedBody.bodyStruct.useCompound&&(this._sharedBody.dirty|=1)},e.needCompound=function(){return 8===this._collider.type||!this._collider.center.equals(ir.ZERO)},n(t,[{key:"attachedRigidBody",get:function(){return this._sharedBody.wrappedBody?this._sharedBody.wrappedBody.rigidBody:null}},{key:"impl",get:function(){return this._impl}},{key:"collider",get:function(){return this._collider}},{key:"sharedBody",get:function(){return this._sharedBody}}]),t}();Akt.TYPE="shape",Akt.idCounter=0;var Ckt=function(){function t(){this.matrix=[]}var e=t.prototype;return e.get=function(t,e){if(e>t){var i=e;e=t,t=i}return this.matrix[(t*(t+1)>>1)+e-1]},e.set=function(t,e,i){if(e>t){var n=e;e=t,t=n}this.matrix[(t*(t+1)>>1)+e-1]=i?1:0},e.reset=function(){this.matrix.length=0},e.setNumObjects=function(t){this.matrix.length=t*(t-1)>>1},t}(),Dkt=function(){function t(){this.data=void 0,this.data={keys:[]}}var e=t.prototype;return e.get=function(t,e){if(t>e){var i=e;e=t,t=i}return this.data[t+"-"+e]},e.set=function(t,e,i){if(t>e){var n=e;e=t,t=n}var r=t+"-"+e;if(null==i){var s=this.data.keys.indexOf(r);if(-1!==s)return this.data.keys.splice(s,1),delete this.data[r],i}return this.get(t,e)||this.data.keys.push(r),this.data[r]=i,this.data[r]},e.reset=function(){this.data={keys:[]}},e.getLength=function(){return this.data.keys.length},e.getKeyByIndex=function(t){return this.data.keys[t]},e.getDataByKey=function(t){return this.data[t]},t}(),Bkt=function(){function t(t){this.impl=0,this.event=void 0,this.event=t}var e=t.prototype;return e.getLocalPointOnA=function(t){this.impl&&yDt(t,qCt.ManifoldPoint_get_m_localPointA(this.impl))},e.getLocalPointOnB=function(t){this.impl&&yDt(t,qCt.ManifoldPoint_get_m_localPointB(this.impl))},e.getWorldPointOnA=function(t){this.impl&&yDt(t,qCt.ManifoldPoint_get_m_positionWorldOnA(this.impl))},e.getWorldPointOnB=function(t){this.impl&&yDt(t,qCt.ManifoldPoint_get_m_positionWorldOnB(this.impl))},e.getLocalNormalOnA=function(t){if(this.impl){var e=QCt.instance.BT_QUAT_0,i=qCt.PersistentManifold_getBody0(this.event.impl),n=qCt.CollisionObject_getWorldTransform(i);qCt.Transform_getRotation(n,e);var r=eDt;bDt(r,e),kr.conjugate(r,r),yDt(t,qCt.ManifoldPoint_get_m_normalWorldOnB(this.impl)),this.isBodyA||ir.negate(t,t),ir.transformQuat(t,t,r)}},e.getLocalNormalOnB=function(t){if(this.impl){var e=QCt.instance.BT_QUAT_0,i=qCt.PersistentManifold_getBody1(this.event.impl),n=qCt.CollisionObject_getWorldTransform(i);qCt.Transform_getRotation(n,e);var r=eDt;bDt(r,e),kr.conjugate(r,r),yDt(t,qCt.ManifoldPoint_get_m_normalWorldOnB(this.impl)),ir.transformQuat(t,t,r)}},e.getWorldNormalOnA=function(t){this.impl&&(yDt(t,qCt.ManifoldPoint_get_m_normalWorldOnB(this.impl)),this.isBodyA||ir.negate(t,t))},e.getWorldNormalOnB=function(t){this.impl&&yDt(t,qCt.ManifoldPoint_get_m_normalWorldOnB(this.impl))},n(t,[{key:"isBodyA",get:function(){return this.event.selfCollider.shape.sharedBody.body===qCt.PersistentManifold_getBody0(this.event.impl)}}]),t}(),Ikt=[],Mkt=ZCt,Pkt=$Ct,Ekt=tDt,Okt=mDt,kkt=new _kt,Rkt=function(){var t=e.prototype;function e(){this._world=void 0,this._broadphase=void 0,this._solver=void 0,this._dispatcher=void 0,this._debugDraw=void 0,this._debugLineCount=0,this._MAX_DEBUG_LINE_COUNT=16384,this._debugDrawFlags=0,this._debugConstraintSize=.3,this._needEmitEvents=!1,this._needSyncAfterEvents=!1,this._needEmitCCTEvents=!1,this.bodies=[],this.ghosts=[],this.ccts=[],this.constraints=[],this.triggerArrayMat=new Ckt,this.characterControllerArrayMat=new Ckt,this.collisionArrayMat=new Ckt,this.contactsDic=new Dkt,this.oldContactsDic=new Dkt,this.cctShapeEventDic=new Dkt,this.cctContactsDic=new Dkt,this.cctOldContactsDic=new Dkt,XCt.CACHE.world=this,this._broadphase=qCt.DbvtBroadphase_new(),this._dispatcher=qCt.CollisionDispatcher_new(),this._solver=qCt.SequentialImpulseConstraintSolver_new(),this._world=qCt.ccDiscreteDynamicsWorld_new(this._dispatcher,this._broadphase,this._solver);var t=qCt.DebugDraw.implement(ykt);this._debugDraw=t.$$.ptr,qCt.CollisionWorld_setDebugDrawer(this._world,this._debugDraw),qCt.DebugDraw_setDebugMode(this._debugDraw,0),qCt.DebugDraw_setAABBColor(this._debugDraw,0,1,1),qCt.DebugDraw_setActiveObjectColor(this._debugDraw,1,0,1),qCt.DebugDraw_setDeactiveObjectColor(this._debugDraw,1,0,1),qCt.DebugDraw_setWantsDeactivationObjectColor(this._debugDraw,1,0,1),qCt.DebugDraw_setDisabledDeactivationObjectColor(this._debugDraw,1,0,1),qCt.DebugDraw_setDisabledSimulationObjectColor(this._debugDraw,1,0,1),qCt.DebugDraw_setConstraintLimitColor(this._debugDraw,.5,.5,.5)}return t.setDefaultMaterial=function(){},t.setAllowSleep=function(t){qCt.ccDiscreteDynamicsWorld_setAllowSleep(this._world,t)},t.setGravity=function(t){qCt.DynamicsWorld_setGravity(this._world,gDt(QCt.instance.BT_V3_0,t))},t.updateNeedEmitEvents=function(t){if(this.ghosts)if(t)this._needEmitEvents=!0;else{this._needEmitEvents=!1;for(var e=0;e=0;t--){var e=this.ghosts[t];e.updateDirty(),e.syncSceneToGhost()}for(var i=this.bodies.length-1;i>=0;i--){var n=this.bodies[i];n.updateDirty(),n.syncSceneToPhysics()}for(var r=this.ccts,s=r.length-1;s>=0;s--){var a=r[s];a.updateDirty(),a.syncSceneToPhysics()}},t.syncAfterEvents=function(){this._needSyncAfterEvents&&this.syncSceneToPhysics()},t.raycast=function(t,e,i,n){t.computeHit(Mkt,e.maxDistance);var r=gDt(QCt.instance.BT_V3_0,Mkt),s=gDt(QCt.instance.BT_V3_1,t.o),a=qCt.ccAllRayCallback_static();if(qCt.ccAllRayCallback_reset(a,s,r,e.mask>>>0,e.queryTrigger),qCt.ccAllRayCallback_setFlags(a,4),qCt.CollisionWorld_rayTest(this._world,s,r,a),qCt.RayCallback_hasHit(a)){for(var o=qCt.ccAllRayCallback_getHitPointWorld(a),h=qCt.ccAllRayCallback_getHitNormalWorld(a),u=qCt.ccAllRayCallback_getCollisionShapePtrs(a),l=qCt.ccAllRayCallback_getClosestHitFraction(a),c=0,f=qCt.int_array_size(u);c>>0,e.queryTrigger),qCt.ccClosestRayCallback_setFlags(s,4),qCt.CollisionWorld_rayTest(this._world,r,n,s),qCt.RayCallback_hasHit(s)){yDt(Mkt,qCt.ccClosestRayCallback_getHitPointWorld(s)),yDt(Pkt,qCt.ccClosestRayCallback_getHitNormalWorld(s));var a=QCt.getWrapper(qCt.ccClosestRayCallback_getCollisionShapePtr(s),Akt.TYPE),o=qCt.ccClosestConvexCallback_getClosestHitFraction(s);return i._assign(Mkt,ir.distance(t.o,Mkt),a.collider,Pkt,o),!0}return!1},t.sweepBox=function(t,i,n,r,s,a){var o=QCt.instance.BT_V3_0;return gDt(o,i),e._sweepBoxGeometry||(e._sweepBoxGeometry=qCt.BoxShape_new(o)),qCt.BoxShape_setUnscaledHalfExtents(e._sweepBoxGeometry,o),this.sweep(t,e._sweepBoxGeometry,n,r,s,a)},t.sweepBoxClosest=function(t,i,n,r,s){var a=QCt.instance.BT_V3_0;return gDt(a,i),e._sweepBoxGeometry||(e._sweepBoxGeometry=qCt.BoxShape_new(a)),qCt.BoxShape_setUnscaledHalfExtents(e._sweepBoxGeometry,a),this.sweepClosest(t,e._sweepBoxGeometry,n,r,s)},t.sweepSphere=function(t,i,n,r,s){return e._sweepSphereGeometry||(e._sweepSphereGeometry=qCt.SphereShape_new(i)),qCt.SphereShape_setUnscaledRadius(e._sweepSphereGeometry,i),this.sweep(t,e._sweepSphereGeometry,kr.IDENTITY,n,r,s)},t.sweepSphereClosest=function(t,i,n,r){return e._sweepSphereGeometry||(e._sweepSphereGeometry=qCt.SphereShape_new(i)),qCt.SphereShape_setUnscaledRadius(e._sweepSphereGeometry,i),this.sweepClosest(t,e._sweepSphereGeometry,kr.IDENTITY,n,r)},t.sweepCapsule=function(t,i,n,r,s,a,o){return e._sweepCapsuleGeometry||(e._sweepCapsuleGeometry=qCt.CapsuleShape_new(i,n)),qCt.CapsuleShape_updateProp(e._sweepCapsuleGeometry,i,.5*n,1),this.sweep(t,e._sweepCapsuleGeometry,r,s,a,o)},t.sweepCapsuleClosest=function(t,i,n,r,s,a){return e._sweepCapsuleGeometry||(e._sweepCapsuleGeometry=qCt.CapsuleShape_new(i,n)),qCt.CapsuleShape_updateProp(e._sweepCapsuleGeometry,i,.5*n,1),this.sweepClosest(t,e._sweepCapsuleGeometry,r,s,a)},t.sweep=function(t,e,i,n,r,s){var a=QCt.instance.BT_TRANSFORM_0,o=QCt.instance.BT_TRANSFORM_1,h=QCt.instance.BT_QUAT_0;gDt(qCt.Transform_getOrigin(a),t.o),vDt(h,i),qCt.Transform_setRotation(a,h),t.computeHit(Mkt,n.maxDistance),gDt(qCt.Transform_getOrigin(o),Mkt),vDt(h,i),qCt.Transform_setRotation(o,h);var u=qCt.ccAllConvexCallback_static();if(qCt.ccAllConvexCallback_reset(u,a,o,n.mask>>>0,n.queryTrigger),qCt.CollisionWorld_convexSweepTest(this._world,e,a,o,u,0),qCt.ConvexCallback_hasHit(u)){for(var l=qCt.ccAllConvexCallback_getHitPointWorld(u),c=qCt.ccAllConvexCallback_getHitNormalWorld(u),f=qCt.ccAllConvexCallback_getCollisionShapePtrs(u),_=qCt.ccAllConvexCallback_getClosestHitFraction(u),d=0,p=qCt.int_array_size(f);d>>0,n.queryTrigger),qCt.CollisionWorld_convexSweepTest(this._world,e,s,a,h,0),qCt.ConvexCallback_hasHit(h)){yDt(Mkt,qCt.ccClosestConvexCallback_getHitPointWorld(h)),yDt(Pkt,qCt.ccClosestConvexCallback_getHitNormalWorld(h));var u=QCt.getWrapper(qCt.ccClosestConvexCallback_getCollisionShapePtr(h),Akt.TYPE),l=qCt.ccClosestConvexCallback_getClosestHitFraction(h);return r._assign(Mkt,ir.distance(t.o,Mkt),u.collider,Pkt,l),!0}return!1},t.getSharedBody=function(t,e){return wkt.getSharedBody(t,this,e)},t.addSharedBody=function(t){if(this.bodies.indexOf(t)<0){this.bodies.push(t);var e=t.collisionFilterGroup,i=t.collisionFilterMask;qCt.DynamicsWorld_addRigidBody(this._world,t.body,e>>>0,i>>>0)}},t.removeSharedBody=function(t){var e=this.bodies.indexOf(t);e>=0&&(be(this.bodies,e),qCt.DynamicsWorld_removeRigidBody(this._world,t.body))},t.addGhostObject=function(t){if(this.ghosts.indexOf(t)<0){this.ghosts.push(t);var e=t.collisionFilterGroup,i=t.collisionFilterMask;qCt.CollisionWorld_addCollisionObject(this._world,t.ghost,e>>>0,i>>>0)}},t.removeGhostObject=function(t){var e=this.ghosts.indexOf(t);e>=0&&(be(this.ghosts,e),qCt.CollisionWorld_removeCollisionObject(this._world,t.ghost))},t.addCCT=function(t){if(this.ccts.indexOf(t)<0){this.ccts.push(t);var e=qCt.CharacterController_getGhostObject(t.impl),i=t.getGroup(),n=t.getMask();qCt.CollisionWorld_addCollisionObject(this._world,e,i>>>0,n>>>0),qCt.DynamicsWorld_addAction(this._world,t.impl)}},t.removeCCT=function(t){var e=this.ccts.indexOf(t);if(e>=0){be(this.ccts,e);var i=qCt.CharacterController_getGhostObject(t.impl);qCt.CollisionWorld_removeCollisionObject(this._world,i),qCt.DynamicsWorld_removeAction(this._world,t.impl)}},t.addConstraint=function(t){var e=this.constraints.indexOf(t);e<0&&(this.constraints.push(t),qCt.DynamicsWorld_addConstraint(this.impl,t.impl,!t.constraint.enableCollision),t.index=e)},t.removeConstraint=function(t){var e=this.constraints.indexOf(t);e>=0&&(this.constraints.splice(e,1),qCt.DynamicsWorld_removeConstraint(this.impl,t.impl),t.index=-1)},t.emitEvents=function(){this._needSyncAfterEvents=!1,this._needEmitEvents&&(this.gatherConatactData(),this.emitCollisionAndTriggerEvent(),this.emitCCTTriggerEvent()),this._needEmitCCTEvents&&this.emitCCTCollisionEvent()},t.emitCollisionAndTriggerEvent=function(){for(var t=this.contactsDic.getLength();t--;){Ikt.push.apply(Ikt,JCt.contacts),JCt.contacts.length=0;var e=this.contactsDic.getKeyByIndex(t),i=this.contactsDic.getDataByKey(e),n=i.shape0,r=i.shape1;this.oldContactsDic.set(n.id,r.id,i);var s=n.collider,a=r.collider;if(s&&a){if(s.isTrigger||a.isTrigger)this.triggerArrayMat.get(n.id,r.id)?YCt.type="onTriggerStay":(YCt.type="onTriggerEnter",this.triggerArrayMat.set(n.id,r.id,!0)),YCt.impl=i.impl,YCt.selfCollider=s,YCt.otherCollider=a,s.emit(YCt.type,YCt),YCt.selfCollider=a,YCt.otherCollider=s,a.emit(YCt.type,YCt),this._needSyncAfterEvents=!0;else{var o=s.attachedRigidBody,h=a.attachedRigidBody;if(o&&h){if(o.isSleeping&&h.isSleeping)continue}else if(!o&&h){if(h.isSleeping)continue}else if(!h&&o&&o.isSleeping)continue;this.collisionArrayMat.get(n.id,r.id)?JCt.type="onCollisionStay":(JCt.type="onCollisionEnter",this.collisionArrayMat.set(n.id,r.id,!0));for(var u=0;u0){var c=Ikt.pop();c.impl=l,JCt.contacts.push(c)}else{var f=new Bkt(JCt);f.impl=l,JCt.contacts.push(f)}}JCt.impl=i.impl,JCt.selfCollider=s,JCt.otherCollider=a,s.emit(JCt.type,JCt),JCt.selfCollider=a,JCt.otherCollider=s,a.emit(JCt.type,JCt),this._needSyncAfterEvents=!0}null==this.oldContactsDic.get(n.id,r.id)&&this.oldContactsDic.set(n.id,r.id,i)}}for(var _=this.oldContactsDic.getLength();_--;){var d=this.oldContactsDic.getKeyByIndex(_),p=this.oldContactsDic.getDataByKey(d),m=p.shape0,g=p.shape1,y=m.collider,v=g.collider;if(y&&v){var b=y.isTrigger||v.isTrigger;null==this.contactsDic.getDataByKey(d)&&(b?this.triggerArrayMat.get(m.id,g.id)&&(YCt.type="onTriggerExit",YCt.selfCollider=y,YCt.otherCollider=v,y.emit(YCt.type,YCt),YCt.selfCollider=v,YCt.otherCollider=y,v.emit(YCt.type,YCt),this.triggerArrayMat.set(m.id,g.id,!1),this.oldContactsDic.set(m.id,g.id,null),this._needSyncAfterEvents=!0):this.collisionArrayMat.get(m.id,g.id)&&(Ikt.push.apply(Ikt,JCt.contacts),JCt.contacts.length=0,JCt.type="onCollisionExit",JCt.selfCollider=y,JCt.otherCollider=v,y.emit(JCt.type,JCt),JCt.selfCollider=v,JCt.otherCollider=y,v.emit(JCt.type,JCt),this.collisionArrayMat.set(m.id,g.id,!1),this.oldContactsDic.set(m.id,g.id,null),this._needSyncAfterEvents=!0))}}this.contactsDic.reset()},t.emitCCTTriggerEvent=function(){for(var t=this.cctContactsDic.getLength();t--;){var e=this.cctContactsDic.getKeyByIndex(t),i=this.cctContactsDic.getDataByKey(e),n=i.shape,r=i.cct;this.cctOldContactsDic.set(n.id,r.id,i);var s=n.collider,a=r.characterController;s&&a&&(s.isTrigger&&(this.characterControllerArrayMat.get(n.id,r.id)?KCt.type="onControllerTriggerStay":(KCt.type="onControllerTriggerEnter",this.characterControllerArrayMat.set(n.id,r.id,!0)),KCt.impl=i.impl,KCt.collider=s,KCt.characterController=a,s.emit(KCt.type,KCt),KCt.collider=s,KCt.characterController=a,a.emit(KCt.type,KCt),this._needSyncAfterEvents=!0),null==this.cctOldContactsDic.get(n.id,r.id)&&this.cctOldContactsDic.set(n.id,r.id,i))}for(var o=this.cctOldContactsDic.getLength();o--;){var h=this.cctOldContactsDic.getKeyByIndex(o),u=this.cctOldContactsDic.getDataByKey(h),l=u.shape,c=u.cct,f=l.collider,_=c.characterController;if(f&&_){var d=f.isTrigger;null==this.cctContactsDic.getDataByKey(h)&&d&&this.characterControllerArrayMat.get(l.id,c.id)&&(KCt.type="onControllerTriggerExit",KCt.collider=f,KCt.characterController=_,f.emit(KCt.type,KCt),KCt.collider=f,KCt.characterController=_,_.emit(KCt.type,KCt),this.characterControllerArrayMat.set(l.id,c.id,!1),this.cctOldContactsDic.set(l.id,c.id,null),this._needSyncAfterEvents=!0)}}this.cctContactsDic.reset()},t.emitCCTCollisionEvent=function(){for(var t=this.cctShapeEventDic.getLength();t--;){var e,i=this.cctShapeEventDic.getKeyByIndex(t),n=this.cctShapeEventDic.getDataByKey(i),r=n.BulletCharacterController,s=n.BulletShape,a=n.worldPos,o=n.worldNormal,h=n.motionDir,u=n.motionLength;kkt.controller=r.characterController,kkt.collider=s.collider,kkt.worldPosition.set(a.x,a.y,a.z),kkt.worldNormal.set(o.x,o.y,o.z),kkt.motionDirection.set(h.x,h.y,h.z),kkt.motionLength=u,null==(e=kkt.controller)||e.emit("onControllerColliderHit",kkt),this._needSyncAfterEvents=!0}this.cctShapeEventDic.reset()},t.gatherConatactData=function(){for(var t=qCt.Dispatcher_getNumManifolds(this._dispatcher),e=0;e0){if(this.collider.convex){var i=this._getBtTriangleMesh(e);this._impl=qCt.ConvexTriangleMeshShape_new(i)}else this.btBVHMeshShape=Nkt.getBulletBvhTriangleMeshShape(e.hash,e),this._impl=qCt.ScaledBvhTriangleMeshShape_new(this.btBVHMeshShape.bulletBvhTriangleMeshShapePtr,1,1,1);var n=QCt.instance.BT_V3_0;gDt(n,this._collider.node.worldScale),qCt.CollisionShape_setLocalScaling(this._impl,n),qCt.CollisionShape_setMargin(this._impl,.01),this.setCompound(this._compound),this.updateByReAdd(),this.setWrapper()}else this._impl=qCt.EmptyShape_static()}},i.onComponentSet=function(){this.setMesh(this.collider.mesh)},i.onDestroy=function(){this.collider.convex?this.refBtTriangleMesh&&qCt._safe_delete(this.refBtTriangleMesh,8):this.btBVHMeshShape&&(this.btBVHMeshShape.reference=!1),t.prototype.onDestroy.call(this)},i.updateScale=function(){t.prototype.updateScale.call(this);var e=QCt.instance.BT_V3_0;gDt(e,this._collider.node.worldScale),qCt.CollisionShape_setLocalScaling(this._impl,e),this.updateCompoundTransform()},i._getBtTriangleMesh=function(t){return this.refBtTriangleMesh=qCt.TriangleMesh_new(),SDt(this.refBtTriangleMesh,t),this.refBtTriangleMesh},n(e,[{key:"collider",get:function(){return this._collider}}]),e}(Akt),Ukt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.setHeight=function(){this.updateProperties(this.collider.radius,this.collider.height,this.collider.direction,this._collider.node.worldScale)},i.setDirection=function(){this.updateProperties(this.collider.radius,this.collider.height,this.collider.direction,this._collider.node.worldScale)},i.setRadius=function(){this.updateProperties(this.collider.radius,this.collider.height,this.collider.direction,this._collider.node.worldScale)},i.onComponentSet=function(){var t=QCt.instance.BT_V3_0;qCt.Vec3_set(t,.5,1,.5),this._impl=qCt.CylinderShape_new(t),this.setRadius(this.collider.radius)},i.updateScale=function(){t.prototype.updateScale.call(this),this.setRadius(this.collider.radius)},i.updateProperties=function(t,e,i,n){var r,s,a=n,o=i;1===o?(s=e*Math.abs(a.y),r=t*Math.abs(gn(a.x,a.z))):0===o?(s=e*Math.abs(a.x),r=t*Math.abs(gn(a.y,a.z))):(s=e*Math.abs(a.z),r=t*Math.abs(gn(a.x,a.y))),qCt.CylinderShape_updateProp(this._impl,r,s/2,o),this.updateCompoundTransform()},n(e,[{key:"collider",get:function(){return this._collider}}]),e}(Akt),Gkt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.setHeight=function(){this.updateProperties(this.collider.radius,this.collider.height,this.collider.direction,this._collider.node.worldScale)},i.setDirection=function(){this.updateProperties(this.collider.radius,this.collider.height,this.collider.direction,this._collider.node.worldScale)},i.setRadius=function(){this.updateProperties(this.collider.radius,this.collider.height,this.collider.direction,this._collider.node.worldScale)},i.onComponentSet=function(){this._impl=qCt.ConeShape_new(.5,1),this.setRadius(this.collider.radius)},i.updateScale=function(){t.prototype.updateScale.call(this),this.setRadius(this.collider.radius)},i.updateProperties=function(t,e,i,n){var r,s,a=n,o=i;1===o?(s=e*Math.abs(a.y),r=t*Math.abs(gn(a.x,a.z))):0===o?(s=e*Math.abs(a.x),r=t*Math.abs(gn(a.y,a.z))):(s=e*Math.abs(a.z),r=t*Math.abs(gn(a.x,a.y))),qCt.ConeShape_setRadius(this._impl,r),qCt.ConeShape_setHeight(this._impl,s),qCt.ConeShape_setConeUpIndex(this._impl,o);var h=QCt.instance.BT_V3_0;qCt.Vec3_set(h,1,1,1),qCt.CollisionShape_setLocalScaling(this._impl,h),this.updateCompoundTransform()},n(e,[{key:"impl",get:function(){return this._impl}},{key:"collider",get:function(){return this._collider}}]),e}(Akt),Hkt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;ru&&(s=u),u>a&&(a=u),r+=4}a+=.01,s-=.01,this._localOffset.set((i-1)/2*this._tileSize,(a+s)/2,(n-1)/2*this._tileSize),this._impl=qCt.TerrainShape_new(i,n,this._bufPtr,1,s,a);var l=QCt.instance.BT_V3_0;qCt.Vec3_set(l,this._tileSize,1,this._tileSize),qCt.CollisionShape_setLocalScaling(this._impl,l),this.setCompound(this._compound),this.updateByReAdd(),this.setWrapper()}else this._impl=qCt.EmptyShape_static()}},i.onComponentSet=function(){this.setTerrain(this.collider.terrain)},i.onDestroy=function(){this._bufPtr&&qCt._free(this._bufPtr),t.prototype.onDestroy.call(this)},i.setCenter=function(t){ir.copy(ZCt,t),ZCt.add(this._localOffset),gDt(qCt.Transform_getOrigin(this.transform),ZCt),this.updateCompoundTransform()},n(e,[{key:"collider",get:function(){return this._collider}}]),e}(Akt),Wkt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.setShapeType=function(){},i.setVertices=function(){},i.onComponentSet=function(){this._impl=qCt.SimplexShape_new();for(var t=this.collider.shapeType,e=this.collider.vertices,i=QCt.instance.BT_V3_0,n=0;n=0){var t=this._rigidBody.body.sharedBody;t.wrappedWorld.removeConstraint(this),t.wrappedWorld.addConstraint(this)}},e.initialize=function(t){this._com=t,this._rigidBody=t.attachedBody,this._connectedBody=t.connectedBody,this._collided=t.enableCollision,this.onComponentSet(),this.setEnableCollision(this._collided)},e.updateDebugDrawSize=function(){if(this.impl){var t=HDt.instance.physicsWorld.debugDrawConstraintSize;qCt.TypedConstraint_setDbgDrawSize(this.impl,t)}},e.onEnable=function(){var t=this._rigidBody.body.sharedBody;t.wrappedWorld.addConstraint(this),t.addJoint(this,0);var e=this._connectedBody;e&&e.body.sharedBody.addJoint(this,1)},e.onDisable=function(){var t=this._rigidBody.body.sharedBody;t.wrappedWorld.removeConstraint(this),t.removeJoint(this,0);var e=this._connectedBody;e&&e.body.sharedBody.removeJoint(this,1)},e.onDestroy=function(){qCt._safe_delete(this._impl,13),this._com=null,this._rigidBody=null,this._connectedBody=null},n(t,[{key:"impl",get:function(){return this._impl}},{key:"constraint",get:function(){return this._com}}]),t}(),Xkt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.setPivotA=function(){var t=this.constraint,e=QCt.instance.BT_V3_0;ir.multiply(ZCt,t.node.worldScale,t.pivotA),gDt(e,ZCt),qCt.P2PConstraint_setPivotA(this._impl,e),t.connectedBody||this.setPivotB(t.pivotB)},i.setPivotB=function(){var t=this.constraint,e=this._rigidBody.node,i=QCt.instance.BT_V3_0,n=t.connectedBody;n?(ir.multiply(ZCt,n.node.worldScale,t.pivotB),gDt(i,ZCt)):(ir.multiply(ZCt,e.worldScale,t.pivotA),ir.transformQuat(ZCt,ZCt,e.worldRotation),ir.add(ZCt,ZCt,e.worldPosition),gDt(i,ZCt)),qCt.P2PConstraint_setPivotB(this._impl,i)},i.onComponentSet=function(){var t=this.constraint.connectedBody,e=this._rigidBody.body.impl,i=t?t.body.impl:qCt.TypedConstraint_getFixedBody(),n=QCt.instance.BT_V3_0,r=QCt.instance.BT_V3_1;this._impl=qCt.P2PConstraint_new(e,i,n,r),this.setPivotA(this.constraint.pivotA),this.setPivotB(this.constraint.pivotB),this.updateDebugDrawSize()},i.updateScale0=function(){this.setPivotA(this.constraint.pivotA)},i.updateScale1=function(){this.setPivotB(this.constraint.pivotB)},n(e,[{key:"constraint",get:function(){return this._com}}]),e}(qkt),Ykt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.setBreakForce=function(t){qCt.TypedConstraint_setMaxImpulseThreshold(this._impl,t)},i.setBreakTorque=function(){},i.onComponentSet=function(){var t=this.constraint.connectedBody,e=this._rigidBody.body.impl,i=t?t.body.impl:qCt.TypedConstraint_getFixedBody(),n=QCt.instance.BT_TRANSFORM_0,r=QCt.instance.BT_TRANSFORM_1;this._impl=qCt.FixedConstraint_new(e,i,n,r),this.setBreakForce(this.constraint.breakForce),this.setBreakTorque(this.constraint.breakTorque),this.updateFrames(),this.updateDebugDrawSize()},i.updateFrames=function(){var t=this.constraint.connectedBody,e=this._rigidBody.body.sharedBody,i=ZCt,n=eDt,r=QCt.instance.BT_TRANSFORM_0,s=QCt.instance.BT_TRANSFORM_1,a=QCt.instance.BT_QUAT_0,o=nDt;if(Kr.fromRT(o,e.node.worldRotation,e.node.worldPosition),Kr.invert(o,o),Kr.getRotation(n,o),Kr.getTranslation(i,o),gDt(qCt.Transform_getOrigin(r),i),vDt(a,n),qCt.Transform_setRotation(r,a),t){var h=t.body.sharedBody;Kr.fromRT(o,h.node.worldRotation,h.node.worldPosition),Kr.invert(o,o),Kr.getRotation(n,o),Kr.getTranslation(i,o),gDt(qCt.Transform_getOrigin(s),i),vDt(a,n),qCt.Transform_setRotation(s,a)}else qCt.Transform_setIdentity(s);qCt.FixedConstraint_setFrames(this._impl,r,s)},i.updateScale0=function(){this.updateFrames()},i.updateScale1=function(){this.updateFrames()},n(e,[{key:"constraint",get:function(){return this._com}}]),e}(qkt),Jkt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.setPivotA=function(){this.updateFrames()},i.setPivotB=function(){this.updateFrames()},i.setAxis=function(){this.updateFrames()},i.setLimitEnabled=function(){this.constraint.limitEnabled?qCt.HingeConstraint_setLimit(this._impl,nn(this.constraint.lowerLimit),nn(this.constraint.upperLimit),.9,.3,1):qCt.HingeConstraint_setLimit(this._impl,1,0,.9,.3,1)},i.setLowerLimit=function(){this.constraint.limitEnabled&&qCt.HingeConstraint_setLimit(this._impl,nn(this.constraint.lowerLimit),nn(this.constraint.upperLimit),.9,.3,1)},i.setUpperLimit=function(){this.constraint.limitEnabled&&qCt.HingeConstraint_setLimit(this._impl,nn(this.constraint.lowerLimit),nn(this.constraint.upperLimit),.9,.3,1)},i.setMotorEnabled=function(t){qCt.HingeConstraint_enableMotor(this._impl,t);var e=-this.constraint.motorVelocity/60,i=wDt(this.constraint.motorForceLimit,HDt.instance.fixedTimeStep);qCt.HingeConstraint_setMotorVelocity(this._impl,e),qCt.HingeConstraint_setMaxMotorImpulse(this._impl,i)},i.setMotorVelocity=function(t){if(this.constraint.motorEnabled){var e=-t/60;qCt.HingeConstraint_setMotorVelocity(this._impl,e)}},i.setMotorForceLimit=function(t){if(this.constraint.motorEnabled){var e=wDt(t,HDt.instance.fixedTimeStep);qCt.HingeConstraint_setMaxMotorImpulse(this._impl,e)}},i.onComponentSet=function(){var t=this.constraint.connectedBody,e=this._rigidBody.body.impl,i=t?t.body.impl:qCt.TypedConstraint_getFixedBody(),n=QCt.instance.BT_TRANSFORM_0,r=QCt.instance.BT_TRANSFORM_1;this._impl=qCt.HingeConstraint_new(e,i,n,r),this.setLimitEnabled(this.constraint.limitEnabled),this.setLowerLimit(this.constraint.lowerLimit),this.setUpperLimit(this.constraint.upperLimit),this.setMotorEnabled(this.constraint.motorEnabled),this.setMotorVelocity(this.constraint.motorVelocity),this.setMotorForceLimit(this.constraint.motorForceLimit),this.updateFrames(),this.updateDebugDrawSize()},i.updateFrames=function(){var t=this.constraint,e=t.node,i=ZCt,n=eDt,r=iDt,s=QCt.instance.BT_TRANSFORM_0;ir.multiply(i,e.worldScale,t.pivotA),gDt(qCt.Transform_getOrigin(s),i);var a=QCt.instance.BT_QUAT_0;ir.normalize(i,t.axis),kr.rotationTo(r,ir.UNIT_Z,i),vDt(a,r),qCt.Transform_setRotation(s,a);var o=QCt.instance.BT_TRANSFORM_1,h=this.constraint.connectedBody;h?(ir.multiply(i,h.node.worldScale,t.pivotB),kr.multiply(r,e.worldRotation,r),kr.invert(n,h.node.worldRotation),kr.multiply(r,n,r)):(ir.multiply(i,e.worldScale,t.pivotA),ir.transformQuat(i,i,e.worldRotation),ir.add(i,i,e.worldPosition),kr.multiply(r,e.worldRotation,r)),gDt(qCt.Transform_getOrigin(o),i),vDt(a,r),qCt.Transform_setRotation(o,a),qCt.HingeConstraint_setFrames(this._impl,s,o)},i.updateScale0=function(){this.updateFrames()},i.updateScale1=function(){this.updateFrames()},n(e,[{key:"constraint",get:function(){return this._com}}]),e}(qkt),Kkt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i._setLimit=function(t,e,i,n){switch(t){case 2:qCt.Generic6DofSpring2Constraint_setLimit(this._impl,e,0,0);break;case 1:qCt.Generic6DofSpring2Constraint_setLimit(this._impl,e,i,n);break;case 0:qCt.Generic6DofSpring2Constraint_setLimit(this._impl,e,1,0)}},i.setConstraintMode=function(t,e){var i=this.constraint.linearLimitSettings,n=this.constraint.angularLimitSettings,r=[0,0,0],s=[0,0,0],a=0,o=0;switch(t){case 0:case 1:case 2:ir.toArray(r,i.lower),ir.toArray(s,i.upper),o=r[t],a=s[t];break;case 3:o=-(a=.5*nn(n.twistExtent));break;case 4:o=-(a=.5*nn(n.swingExtent1));break;case 5:o=-(a=.5*nn(n.swingExtent2));break;default:J("idx should be in [0, 5], but give "+t)}this._setLimit(e,t,o,a)},i.setLinearLimit=function(t,e,i){var n=0,r=this.constraint.linearLimitSettings;switch(t){case 0:n=r.xMotion;break;case 1:n=r.yMotion;break;case 2:n=r.zMotion}this._setLimit(n,t,e,i)},i.setAngularExtent=function(t,e,i){var n=this.constraint.angularLimitSettings;this._setLimit(n.twistMotion,3,.5*-nn(t),.5*nn(t)),this._setLimit(n.swingMotion1,4,.5*-nn(e),.5*nn(e)),this._setLimit(n.swingMotion2,5,.5*-nn(i),.5*nn(i))},i.setSwingSoftConstraint=function(t){qCt.Generic6DofSpring2Constraint_enableSpring(this._impl,4,t),qCt.Generic6DofSpring2Constraint_enableSpring(this._impl,5,t)},i.setTwistSoftConstraint=function(t){qCt.Generic6DofSpring2Constraint_enableSpring(this._impl,3,t)},i.setLinearSoftConstraint=function(t){qCt.Generic6DofSpring2Constraint_enableSpring(this._impl,0,t),qCt.Generic6DofSpring2Constraint_enableSpring(this._impl,1,t),qCt.Generic6DofSpring2Constraint_enableSpring(this._impl,2,t)},i.setLinearStiffness=function(t){qCt.Generic6DofSpring2Constraint_setStiffness(this._impl,0,t),qCt.Generic6DofSpring2Constraint_setStiffness(this._impl,1,t),qCt.Generic6DofSpring2Constraint_setStiffness(this._impl,2,t)},i.setLinearDamping=function(t){qCt.Generic6DofSpring2Constraint_setDamping(this._impl,0,t),qCt.Generic6DofSpring2Constraint_setDamping(this._impl,1,t),qCt.Generic6DofSpring2Constraint_setDamping(this._impl,2,t)},i.setLinearRestitution=function(t){qCt.Generic6DofSpring2Constraint_setBounce(this._impl,0,t),qCt.Generic6DofSpring2Constraint_setBounce(this._impl,1,t),qCt.Generic6DofSpring2Constraint_setBounce(this._impl,2,t)},i.setSwingStiffness=function(t){qCt.Generic6DofSpring2Constraint_setStiffness(this._impl,4,t),qCt.Generic6DofSpring2Constraint_setStiffness(this._impl,5,t)},i.setSwingDamping=function(t){qCt.Generic6DofSpring2Constraint_setDamping(this._impl,4,t),qCt.Generic6DofSpring2Constraint_setDamping(this._impl,5,t)},i.setSwingRestitution=function(t){qCt.Generic6DofSpring2Constraint_setBounce(this._impl,4,t),qCt.Generic6DofSpring2Constraint_setBounce(this._impl,5,t)},i.setTwistStiffness=function(t){qCt.Generic6DofSpring2Constraint_setStiffness(this._impl,3,t)},i.setTwistDamping=function(t){qCt.Generic6DofSpring2Constraint_setDamping(this._impl,3,t)},i.setTwistRestitution=function(t){qCt.Generic6DofSpring2Constraint_setBounce(this._impl,3,t)},i.setDriverMode=function(t,e){0===e?qCt.Generic6DofSpring2Constraint_enableMotor(this._impl,t,!1):1===e?(qCt.Generic6DofSpring2Constraint_enableMotor(this._impl,t,!0),qCt.Generic6DofSpring2Constraint_setServo(this._impl,t,!0)):2===e&&(qCt.Generic6DofSpring2Constraint_enableMotor(this._impl,t,!0),qCt.Generic6DofSpring2Constraint_setServo(this._impl,t,!1))},i._updateMotorTargetAndVelocity=function(t){var e=0,i=0,n=0,r=0,s=this.constraint.linearDriverSettings,a=this.constraint.angularDriverSettings;switch(t){case 0:i=0,e=s.xDrive,n=s.targetPosition.x,r=-s.targetVelocity.x;break;case 1:i=1,e=s.yDrive,n=s.targetPosition.y,r=-s.targetVelocity.y;break;case 2:i=2,e=s.zDrive,n=s.targetPosition.z,r=-s.targetVelocity.z;break;case 3:i=3,e=a.twistDrive,n=-nn(a.targetOrientation.x),r=-nn(a.targetVelocity.x);break;case 4:i=4,e=a.swingDrive1,n=-nn(a.targetOrientation.y),r=-nn(a.targetVelocity.y);break;case 5:i=5,e=a.swingDrive2,n=-nn(a.targetOrientation.z),r=-nn(a.targetVelocity.z)}var o=t>2?a.strength:s.strength;qCt.Generic6DofSpring2Constraint_setServoTarget(this._impl,i,n),1===e?t>2?qCt.Generic6DofSpring2Constraint_setTargetVelocity(this._impl,i,-n*o*.1):qCt.Generic6DofSpring2Constraint_setTargetVelocity(this._impl,i,n*o*.1):2===e&&qCt.Generic6DofSpring2Constraint_setTargetVelocity(this._impl,i,r)},i.setLinearMotorTarget=function(){this._updateMotorTargetAndVelocity(0),this._updateMotorTargetAndVelocity(1),this._updateMotorTargetAndVelocity(2)},i.setLinearMotorVelocity=function(){this._updateMotorTargetAndVelocity(0),this._updateMotorTargetAndVelocity(1),this._updateMotorTargetAndVelocity(2)},i.setLinearMotorForceLimit=function(t){qCt.Generic6DofSpring2Constraint_setMaxMotorForce(this._impl,0,t),qCt.Generic6DofSpring2Constraint_setMaxMotorForce(this._impl,1,t),qCt.Generic6DofSpring2Constraint_setMaxMotorForce(this._impl,2,t)},i.setAngularMotorTarget=function(){this._updateMotorTargetAndVelocity(3),this._updateMotorTargetAndVelocity(4),this._updateMotorTargetAndVelocity(5)},i.setAngularMotorVelocity=function(){this._updateMotorTargetAndVelocity(3),this._updateMotorTargetAndVelocity(4),this._updateMotorTargetAndVelocity(5)},i.setAngularMotorForceLimit=function(t){qCt.Generic6DofSpring2Constraint_setMaxMotorForce(this._impl,3,t),qCt.Generic6DofSpring2Constraint_setMaxMotorForce(this._impl,4,t),qCt.Generic6DofSpring2Constraint_setMaxMotorForce(this._impl,5,t)},i.setPivotA=function(){this.updateFrames()},i.setPivotB=function(){this.updateFrames()},i.setAutoPivotB=function(){this.updateFrames()},i.setAxis=function(){this.updateFrames()},i.setSecondaryAxis=function(){this.updateFrames()},i.setBreakForce=function(){var t=wDt(Math.max(this.constraint.breakForce,this.constraint.breakTorque),HDt.instance.fixedTimeStep);qCt.TypedConstraint_setMaxImpulseThreshold(this._impl,t)},i.setBreakTorque=function(){var t=wDt(Math.max(this.constraint.breakForce,this.constraint.breakTorque),HDt.instance.fixedTimeStep);qCt.TypedConstraint_setMaxImpulseThreshold(this._impl,t)},i.onComponentSet=function(){var t=this.constraint.connectedBody,e=this._rigidBody.body.impl,i=t&&t.body.impl||qCt.TypedConstraint_getFixedBody(),n=QCt.instance.BT_TRANSFORM_0,r=QCt.instance.BT_TRANSFORM_1;this._impl=qCt.Generic6DofSpring2Constraint_new(e,i,n,r,3);var s=this.constraint.linearLimitSettings,a=this.constraint.angularLimitSettings;this.setConstraintMode(0,s.xMotion),this.setConstraintMode(1,s.yMotion),this.setConstraintMode(2,s.zMotion),this.setConstraintMode(3,a.twistMotion),this.setConstraintMode(4,a.swingMotion1),this.setConstraintMode(5,a.swingMotion2),this.setLinearSoftConstraint(s.enableSoftConstraint),this.setLinearStiffness(s.stiffness),this.setLinearDamping(s.damping),this.setLinearRestitution(s.restitution),this.setSwingSoftConstraint(a.enableSoftConstraintSwing),this.setSwingRestitution(a.swingRestitution),this.setSwingStiffness(a.swingStiffness),this.setSwingDamping(a.swingDamping),this.setTwistSoftConstraint(a.enableSoftConstraintTwist),this.setTwistRestitution(a.twistRestitution),this.setTwistStiffness(a.twistStiffness),this.setTwistDamping(a.twistDamping);var o=this.constraint.linearDriverSettings,h=this.constraint.angularDriverSettings;this.setDriverMode(0,o.xDrive),this.setDriverMode(1,o.yDrive),this.setDriverMode(2,o.zDrive),this.setDriverMode(3,h.twistDrive),this.setDriverMode(4,h.swingDrive1),this.setDriverMode(5,h.swingDrive2),this.setLinearMotorTarget(o.targetPosition),this.setLinearMotorVelocity(o.targetVelocity),this.setLinearMotorForceLimit(o.strength),this.setAngularMotorTarget(h.targetOrientation),this.setAngularMotorVelocity(h.targetVelocity),this.setAngularMotorForceLimit(h.strength),this.setBreakForce(this.constraint.breakForce),this.setBreakTorque(this.constraint.breakTorque),this.updateFrames(),this.updateDebugDrawSize()},i.updateFrames=function(){var t=this.constraint,e=t.node,i=ZCt,n=eDt,r=iDt,s=QCt.instance.BT_TRANSFORM_0;ir.multiply(i,e.worldScale,t.pivotA),gDt(qCt.Transform_getOrigin(s),i);var a=QCt.instance.BT_QUAT_0,o=t.axis,h=t.secondaryAxis,u=ir.cross($Ct,o,h);Kr.set(nDt,o.x,o.y,o.z,0,h.x,h.y,h.z,0,u.x,u.y,u.z,0,0,0,0,1).getRotation(n),vDt(a,n),qCt.Transform_setRotation(s,a);var l=QCt.instance.BT_TRANSFORM_1,c=this.constraint.connectedBody;c?(kr.multiply(n,e.worldRotation,n),kr.invert(r,c.node.worldRotation),kr.multiply(n,r,n),t.autoPivotB?(ir.multiply(i,t.node.worldScale,t.pivotA),ir.transformQuat(i,i,e.worldRotation),ir.add(i,i,t.node.worldPosition),ir.subtract(i,i,c.node.worldPosition),ir.transformQuat(i,i,r)):ir.multiply(i,c.node.worldScale,t.pivotB)):(ir.multiply(i,e.worldScale,t.pivotA),ir.transformQuat(i,i,e.worldRotation),ir.add(i,i,e.worldPosition),kr.multiply(n,e.worldRotation,n)),gDt(qCt.Transform_getOrigin(l),i),vDt(a,n),qCt.Transform_setRotation(l,a),qCt.Generic6DofSpring2Constraint_setFrames(this._impl,s,l)},i.updateScale0=function(){this.updateFrames()},i.updateScale1=function(){this.updateFrames()},n(e,[{key:"constraint",get:function(){return this._com}}]),e}(qkt),Qkt=new ir(0,0,0),Zkt=new ir(0,0,0);new ir(0,0,0);var $kt=function(){function t(){this.wrappedWorld=void 0,this._isEnabled=!1,this._impl=0,this._comp=null,this._btCollisionFlags=0,this._word3=0,this._dirty=!1,this._collisionFilterGroup=1,this._collisionFilterMask=-1,this.id=t.idCounter++,this.wrappedWorld=HDt.instance.physicsWorld}var e=t.prototype;return e.onComponentSet=function(){},e.updateScale=function(){},e.initialize=function(t){this._comp=t;var e=this._comp.group,i=HDt.instance.collisionMatrix[e];return this._collisionFilterGroup=e,this._collisionFilterMask=i,this.onComponentSet(),0!==this._impl||(J("[Physics]: Initialize BulletCharacterController failed"),!1)},e.setWrapper=function(){QCt.setWrapper(this._impl,XCt.CCT_CACHE_NAME,this);var t=qCt.CharacterController_getCollisionShape(this.impl);QCt.setWrapper(t,XCt.CCT_CACHE_NAME,this)},e.onEnable=function(){this._isEnabled=!0,this._impl||this.onComponentSet(),this.setDetectCollisions(!1),this.setOverlapRecovery(!0),HDt.instance.physicsWorld.addCCT(this),this.setWrapper()},e.onDisable=function(){this._isEnabled=!1,this.wrappedWorld.removeCCT(this),this.onDestroy()},e.onDestroy=function(){qCt._safe_delete(this._impl,6),QCt.delWrapper(this._impl,XCt.CCT_CACHE_NAME),this._impl=0},e.onLoad=function(){},e.getPosition=function(t){this._impl&&yDt(t,qCt.CharacterController_getPosition(this.impl))},e.setPosition=function(t){this._impl&&(gDt(qCt.CharacterController_getPosition(this.impl),t),this.syncPhysicsToScene())},e.setContactOffset=function(t){this._impl&&qCt.CharacterController_setContactOffset(this._impl,t)},e.setStepOffset=function(t){this._impl&&qCt.CharacterController_setStepOffset(this._impl,t)},e.setSlopeLimit=function(t){this._impl&&qCt.CharacterController_setSlopeLimit(this._impl,ei(t))},e.setDetectCollisions=function(t){this._impl&&qCt.CharacterController_setCollision(this.impl,t)},e.setOverlapRecovery=function(t){this._impl&&qCt.CharacterController_setOverlapRecovery(this.impl,t)},e.onGround=function(){return(4&this._btCollisionFlags)>0},e.syncSceneToPhysics=function(){var t=this.characterController.node;t.hasChangedFlags&&(4&t.hasChangedFlags&&this.syncScale(),1&t.hasChangedFlags&&(ir.add(Qkt,t.worldPosition,this.scaledCenter),this.setPosition(Qkt)))},e.syncPhysicsToScene=function(){this.getPosition(Qkt),Qkt.subtract(this.scaledCenter),this._comp.node.setWorldPosition(Qkt)},e.syncScale=function(){this.updateScale()},e.move=function(t,e,i){if(this._isEnabled){var n=QCt.instance.BT_V3_0;qCt.Vec3_set(n,t.x,t.y,t.z),this._btCollisionFlags=qCt.CharacterController_move(this.impl,n,e,i)}},e.setGroup=function(t){t!==this._collisionFilterGroup&&(this._collisionFilterGroup=t,this._dirty=!0)},e.getGroup=function(){return this._collisionFilterGroup},e.addGroup=function(t){this._collisionFilterGroup|=t,this._dirty=!0},e.removeGroup=function(t){this._collisionFilterGroup&=~t,this._dirty=!0},e.setMask=function(t){t!==this._collisionFilterMask&&(this._collisionFilterMask=t,this._dirty=!0)},e.getMask=function(){return this._collisionFilterMask},e.addMask=function(t){this._collisionFilterMask|=t,this._dirty=!0},e.removeMask=function(t){this._collisionFilterMask&=~t,this._dirty=!0},e.updateEventListener=function(){this.wrappedWorld.updateNeedEmitCCTEvents(this.characterController.needCollisionEvent)},e.updateDirty=function(){this._dirty&&(HDt.instance.physicsWorld.removeCCT(this),HDt.instance.physicsWorld.addCCT(this),this._dirty=!1)},e.onShapeHitExt=function(t){var e=qCt.ControllerShapeHit_getHitShape(t),i=HDt.instance.physicsWorld;i.cctShapeEventDic.get(this.impl,e);var n=new ir;yDt(n,qCt.ControllerHit_getHitWorldPos(t));var r=new ir;yDt(r,qCt.ControllerHit_getHitWorldNormal(t));var s=new ir;yDt(s,qCt.ControllerHit_getHitMotionDir(t));var a=qCt.ControllerHit_getHitMotionLength(t),o=QCt.getWrapper(e,Akt.TYPE);o&&i.cctShapeEventDic.set(this.impl,e,{BulletCharacterController:this,BulletShape:o,worldPos:n,worldNormal:r,motionDir:s,motionLength:a})},n(t,[{key:"isEnabled",get:function(){return this._isEnabled}},{key:"impl",get:function(){return this._impl}},{key:"characterController",get:function(){return this._comp}},{key:"scaledCenter",get:function(){return ir.multiply(Zkt,this._comp.center,this._comp.node.worldScale),Zkt}}]),t}();$kt.idCounter=0;var tRt,eRt,iRt,nRt,rRt,sRt,aRt,oRt=new ir(0,0,0),hRt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.onComponentSet=function(){this.component.node.getWorldPosition(oRt),oRt.add(this.scaledCenter);var t=QCt.instance.BT_V3_0;qCt.Vec3_set(t,oRt.x,oRt.y,oRt.z);var e=ir.UNIT_Y,i=QCt.instance.BT_V3_1;qCt.Vec3_set(i,e.x,e.y,e.z);var n=qCt.ControllerHitReport.implement(ykt).$$.ptr,r=HDt.instance.physicsWorld,s=qCt.CapsuleCharacterControllerDesc_new(ei(this.component.slopeLimit),this.component.stepOffset,this.component.skinWidth,i,t,n,this.component.radius,this.component.height);this._impl=qCt.CapsuleCharacterController_new(r.impl,s,0),this.updateScale()},i.setRadius=function(){this.updateScale()},i.setHeight=function(){this.updateScale()},i.updateScale=function(){this.updateGeometry()},i.updateGeometry=function(){var t=this.component.node.worldScale,e=this.component.radius*gn(t.x,t.z),i=this.component.height*Math.abs(t.y);qCt.CapsuleCharacterController_setRadius(this.impl,e),qCt.CapsuleCharacterController_setHeight(this.impl,i),this._dirty=!0},n(e,[{key:"component",get:function(){return this._comp}}]),e}($kt),uRt=new ir(0,0,0),lRt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.onComponentSet=function(){this.component.node.getWorldPosition(uRt),uRt.add(this.scaledCenter);var t=QCt.instance.BT_V3_0;qCt.Vec3_set(t,uRt.x,uRt.y,uRt.z);var e=ir.UNIT_Y,i=QCt.instance.BT_V3_1;qCt.Vec3_set(i,e.x,e.y,e.z);var n=qCt.ControllerHitReport.implement(ykt).$$.ptr,r=HDt.instance.physicsWorld,s=qCt.BoxCharacterControllerDesc_new(ei(this.component.slopeLimit),this.component.stepOffset,this.component.skinWidth,i,t,n,this.component.halfHeight,this.component.halfSideExtent,this.component.halfForwardExtent);this._impl=qCt.BoxCharacterController_new(r.impl,s,0),this.updateScale()},i.setHalfHeight=function(){this.updateScale()},i.setHalfSideExtent=function(){this.updateScale()},i.setHalfForwardExtent=function(){this.updateScale()},i.updateScale=function(){this.updateGeometry()},i.updateGeometry=function(){var t=this.component.node.worldScale;qCt.BoxCharacterController_setHalfSideExtent(this.impl,this.component.halfSideExtent*t.x),qCt.BoxCharacterController_setHalfHeight(this.impl,this.component.halfHeight*t.y),qCt.BoxCharacterController_setHalfForwardExtent(this.impl,this.component.halfForwardExtent*t.z),this._dirty=!0},n(e,[{key:"component",get:function(){return this._comp}}]),e}($kt);XO.once(qO.EVENT_PRE_SUBSYSTEM_INIT,(function(){ICt.register("bullet",{PhysicsWorld:Rkt,RigidBody:gkt,BoxShape:Fkt,SphereShape:Lkt,CapsuleShape:Vkt,TrimeshShape:zkt,CylinderShape:Ukt,ConeShape:Gkt,TerrainShape:Hkt,SimplexShape:Wkt,PlaneShape:jkt,PointToPointConstraint:Xkt,HingeConstraint:Jkt,FixedConstraint:Ykt,ConfigurableConstraint:Kkt,BoxCharacterController:lRt,CapsuleCharacterController:hRt})}));var cRt={BOX:0,SPHERE:1,CYLINDER:2,CONE:3,CAPSULE:4,TORUS:5,PLANE:6,QUAD:7};Ee(cRt);var fRt=t("f$",(tRt=Kh("cc.Primitive"),eRt=Ou(cRt),tRt((aRt=function(t){function e(e){var i;return void 0===e&&(e=0),(i=t.call(this)||this).type=rRt&&rRt(),i.info=sRt&&sRt(),i.type=e,i}return s(e,t),e.prototype.onLoaded=function(){Gk((0,wK[cRt[this.type].toLowerCase()])(this.info),this)},e}(Pk),aRt.PrimitiveType=cRt,rRt=zh((nRt=aRt).prototype,"type",[eRt],(function(){return 0})),sRt=zh(nRt.prototype,"info",[uu],(function(){return{}})),iRt=nRt))||iRt));A.Primitive=fRt,C.primitives=wK;var _Rt,dRt=function(){function t(t,e,i){this._total=0,this._value=0,this._averageValue=0,this._accumValue=0,this._accumSamples=0,this._id=t,this._opts=e,this._accumStart=i}var e=t.prototype;return e.sample=function(t){this._average(this._value,t)},e.human=function(){var t=this._opts,e=t.average,i=t.isInteger,n=e?this._averageValue:this._value;return i?Math.round(n):Math.round(100*n)/100},e.alarm=function(){return void 0!==this._opts.below&&this._valuethis._opts.over},e._average=function(t,e){if(void 0===e&&(e=0),this._opts.average){this._accumValue+=t,++this._accumSamples;var i=e;i-this._accumStart>=this._opts.average&&(this._averageValue=this._accumValue/this._accumSamples,this._accumValue=0,this._accumStart=i,this._accumSamples=0)}},n(t,[{key:"value",get:function(){return this._value},set:function(t){this._value=t}}]),t}(),pRt=Kh("cc.PerfCounter")(_Rt=function(t){function e(e,i,n){var r;return(r=t.call(this,e,i,n)||this)._time=n,r}s(e,t);var i=e.prototype;return i.start=function(t){void 0===t&&(t=0),this._time=t},i.end=function(t){void 0===t&&(t=0),this._value=t-this._time,this._average(this._value)},i.tick=function(){this.end(),this.start()},i.frame=function(t){var e=t,i=e-this._time;this._total++,i>(this._opts.average||1e3)&&(this._value=1e3*this._total/i,this._total=0,this._time=e,this._average(this._value))},e}(dRt))||_Rt,mRt="0123456789. ",gRt=500,yRt={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,".":10},vRt={fps:{desc:"Framerate (FPS)",below:30,average:gRt,isInteger:!0},draws:{desc:"Draw call",isInteger:!0},frame:{desc:"Frame time (ms)",min:0,max:50,average:gRt},instances:{desc:"Instance Count",isInteger:!0},tricount:{desc:"Triangle",isInteger:!0},logic:{desc:"Game Logic (ms)",min:0,max:50,average:gRt,color:"#080"},physics:{desc:"Physics (ms)",min:0,max:50,average:gRt},render:{desc:"Renderer (ms)",min:0,max:50,average:gRt,color:"#f90"},present:{desc:"Present (ms)",min:0,max:50,average:gRt,color:"#f90"},textureMemory:{desc:"GFX Texture Mem(M)"},bufferMemory:{desc:"GFX Buffer Mem(M)"}},bRt=t("g0",function(t){function e(){var e;return(e=t.call(this)||this)._profilerStats=null,e._showFPS=!1,e._rootNode=null,e._device=null,e._swapchain=null,e._meshRenderer=null,e._canvas=null,e._ctx=null,e._texture=null,e._region=new id,e._canvasArr=[],e._regionArr=[e._region],e.digitsData=null,e.offsetData=null,e.pass=null,e._canvasDone=!1,e._statsDone=!1,e._inited=!1,e._lineHeight=280/(Object.keys(vRt).length+1),e._wordHeight=0,e._eachNumWidth=0,e._totalLines=0,e.lastTime=0,e._canvas=B.document.createElement("canvas"),e._ctx=e._canvas.getContext("2d"),e._canvasArr.push(e._canvas),e}s(e,t);var i=e.prototype;return i.init=function(){ze.querySettings("profiling","showFPS")?this.showStats():this.hideStats()},i.isShowingStats=function(){return this._showFPS},i.hideStats=function(){this._showFPS&&(this._rootNode&&(this._rootNode.active=!1),YE.off("director_before_update",this.beforeUpdate,this),YE.off("director_after_update",this.afterUpdate,this),YE.off("director_before_physics",this.beforePhysics,this),YE.off("director_after_physics",this.afterPhysics,this),YE.off("director_before_draw",this.beforeDraw,this),YE.off("director_after_render",this.afterRender,this),YE.off("director_after_draw",this.afterPresent,this),this._showFPS=!1,YE.root.pipeline.profiler=null,A.game.config.showFPS=!1)},i.showStats=function(){if(!this._showFPS){if(!this._device){var t=A.director.root;this._device=Wp.gfxDevice,this._swapchain=t.mainWindow.swapchain}this.generateCanvas(),this.generateStats(),A.game.once(A.Game.EVENT_ENGINE_INITED,this.generateNode,this),A.game.on(A.Game.EVENT_RESTART,this.generateNode,this),this._rootNode&&(this._rootNode.active=!0),YE.on("director_before_update",this.beforeUpdate,this),YE.on("director_after_update",this.afterUpdate,this),YE.on("director_before_physics",this.beforePhysics,this),YE.on("director_after_physics",this.afterPhysics,this),YE.on("director_before_draw",this.beforeDraw,this),YE.on("director_after_render",this.afterRender,this),YE.on("director_after_draw",this.afterPresent,this),this._showFPS=!0,this._canvasDone=!0,this._statsDone=!0,A.game.config.showFPS=!0}},i.generateCanvas=function(){if(!this._canvasDone){var t=this._canvas,e=this._ctx;if(e&&t){t.width=280,t.height=280,t.style.width=""+t.width,t.style.height=""+t.height,e.font="23px Arial",e.textBaseline="top",e.fillStyle="#fff",this._texture=this._device.createTexture(new dd(1,6,35,280,280));var i=this._region.texExtent;i.width=280,i.height=280}}},i.generateStats=function(){if(!this._statsDone&&this._ctx&&this._canvas){this._profilerStats=null;var t=performance.now();this._ctx.textAlign="left";var e=0;for(var i in vRt){var n=vRt[i];this._ctx.fillText(n.desc,0,e*this._lineHeight),n.counter=new pRt(i,n,t),e++}this._totalLines=e,this._wordHeight=this._totalLines*this._lineHeight/this._canvas.height;for(var r=0;r<12;++r){var s=this._ctx.measureText(mRt[r]).width;this._eachNumWidth=Math.max(this._eachNumWidth,s)}for(var a=0;a<12;++a)this._ctx.fillText(mRt[a],a*this._eachNumWidth,this._totalLines*this._lineHeight);this._eachNumWidth/=this._canvas.width,this._profilerStats=vRt,this._canvasArr[0]=this._canvas,this._device.copyTexImagesToTexture(this._canvasArr,this._texture,this._regionArr)}},i.generateNode=function(){if(!this._rootNode||!this._rootNode.isValid){this._rootNode=new eb("PROFILER_NODE"),this._rootNode._objFlags=1032,XO.addPersistRootNode(this._rootNode);var t=new eb("Profiler_Root");t.parent=this._rootNode;for(var e=.4,i=e/this._totalLines,n=e/this._wordHeight,r=i/23,s=this._eachNumWidth*this._canvas.width*r,a=[0,e,0,n,e,0,n,0,0,0,0,0],o=[0,2,1,0,3,2],h=[0,0,-1,0,1,0,-1,0,1,this._wordHeight,-1,0,0,this._wordHeight,-1,0],u=0,l=0;l=0;o--){var h=8*i+o,u=a[a.length-(8-o)],l=yRt[u];void 0===l&&(l=11),n[h]=l}i++}}}},n(e,[{key:"_stats",get:function(){return at(16381),this._profilerStats}},{key:"stats",get:function(){return this._profilerStats}}]),e}(Ff)),SRt=t("g1",new bRt);YE.registerSystem("profiler",SRt,0),A.profiler=SRt;var wRt=function(){function t(t){this.jointTexturePool=void 0,this.jointAnimationInfo=void 0,this.jointTexturePool=new wY(t),this.jointAnimationInfo=new xY(t)}var e=t.prototype;return e.releaseSkeleton=function(t){this.jointTexturePool.releaseSkeleton(t)},e.releaseAnimationClip=function(t){this.jointTexturePool.releaseAnimationClip(t)},e.clear=function(){this.jointTexturePool.clear(),this.jointAnimationInfo.clear()},t}();A.internal.DataPoolManager=wRt;var xRt,TRt,ARt,CRt,DRt,BRt,IRt,MRt,PRt,ERt,ORt,kRt,RRt,FRt,LRt,VRt=new Kr,NRt=new Kr,zRt=t("g3",function(t){function e(e,i){var n;return void 0===i&&(i=""),(n=t.call(this,e,i)||this)._frames=1,n._bakedDuration=0,n._animInfo=null,n._sockets=[],n._animInfoMgr=void 0,n._parent=null,n._curvesInited=!1,n._animInfoMgr=A.director.root.dataPoolManager.jointAnimationInfo,n}s(e,t);var i=e.prototype;return i.initialize=function(e){if(!this._curveLoaded){this._parent=e.getComponent("cc.SkeletalAnimation");var i=this._parent.useBakedAnimation;this._doNotCreateEval=i,t.prototype.initialize.call(this,e),this._curvesInited=!i;var n=oY.getOrExtract(this.clip),r=n.frames,s=n.samples;this._frames=r-1,this._animInfo=this._animInfoMgr.getData(e.uuid),this._bakedDuration=this._frames/s,this.setUseBaked(i)}},i.onPlay=function(){var e=this;t.prototype.onPlay.call(this),this._parent.useBakedAnimation&&(this._animInfoMgr.switchClip(this._animInfo,this.clip),this._parent.getUsers().forEach((function(t){t.uploadAnimation(e.clip)})))},i.setUseBaked=function(e){e?(this._sampleCurves=this._sampleCurvesBaked,this.duration=this._bakedDuration):(this._sampleCurves=t.prototype._sampleCurves,this.duration=this.clip.duration,this._curvesInited||(this._curveLoaded=!1,t.prototype.initialize.call(this,this._targetNode),this._curvesInited=!0))},i.rebuildSocketCurves=function(t){if(this._sockets.length=0,this._targetNode)for(var e=this._targetNode,i=0;ii?i:t},t.cosDeg=function(t){return Math.cos(t*u)},t.sinDeg=function(t){return Math.sin(t*u)},t.signum=function(t){return t>0?1:t<0?-1:0},t.toInt=function(t){return t>0?Math.floor(t):Math.ceil(t)},t.cbrt=function(t){var e=Math.pow(Math.abs(t),1/3);return t<0?-e:e},t.randomTriangular=function(e,i){return t.randomTriangularWith(e,i,.5*(e+i))},t.randomTriangularWith=function(t,e,i){var n=Math.random(),r=e-t;return n<=(i-t)/r?t+Math.sqrt(n*r*(i-t)):e-Math.sqrt((1-n)*r*(e-i))},t}(),e.PI=r,e.PI2=s,e.radiansToDegrees=a,e.radDeg=o,e.degreesToRadians=h,e.degRad=u,e)}(jRt||(jRt={}));var XRt=jRt;function YRt(t,e){return t?e===t.length?t:e=this._maxFrameIdex&&(this.isCompleted=!0)}while(this.needToUpdate(t))},e.getFrame=function(t){var e=t%this._maxFrameIdex;return this.frames[e]},e.invalidAnimationFrames=function(){this._curIndex=-1,this._isCompleted=!1,this.frames.length=0},e.updateRenderData=function(t,e){var i=e.vCount,n=e.iCount,r=NFt/4,s=new Uint8Array(4*r*i),a=new Uint16Array(n),o=XRt.wasmUtil.wasm.HEAPU8,h=e.vPtr,u=4*i*r;s.set(o.subarray(h,h+u));var l=e.iPtr,c=2*n;new Uint8Array(a.buffer).set(o.subarray(l,l+c));var f=new UFt;f.vCount=i,f.iCount=n,f.vData=s,f.iData=a;for(var _=e.getData(),d=e.getTextures(),p=_.size(),m=0;m0)return void this._sharedCacheMap.set(t,i);this._sharedCacheMap.delete(t)}}var n=this._skeletonCache[t];if(n){var r=this._privateMode?function(t,e){e.destroy()}:function(i,n){e._animationPool[t+"#"+i]=n,n.clear()},s=n.animationsCache;for(var a in s){var o=s[a];o&&r(a,o)}n.skeleton&&XRt.wasmUtil.destroySpineSkeleton(n.skeleton),delete this._skeletonCache[t]}},e.createSkeletonInfo=function(t){var e=t.uuid,i=t.getRuntimeData();if(!this._privateMode){var n=this._sharedCacheMap.get(e);n?n+=1:n=1,this._sharedCacheMap.set(e,n)}if(this._skeletonCache[e])return this._skeletonCache[e];var r=new XRt.Skeleton(i),s=new DFt;return this._skeletonCache[e]={skeleton:r,clipper:null,state:null,listener:s,animationsCache:{},curAnimationCache:null,assetUUID:e}},e.getSkeletonInfo=function(t){var e=t.uuid;return this._skeletonCache[e]},e.getAnimationCache=function(t,e){var i=this._skeletonCache[t];return i?i.animationsCache[e]:null},e.initAnimationCache=function(t,e,i){var n=e.getRuntimeData();if(!n)return null;var r=this._skeletonCache[t];if(!r||!r.skeleton)return null;var s=r.animationsCache,a=s[i];if(!a){var o=t+"#"+i;(a=this._animationPool[o])?delete this._animationPool[o]:(a=new HFt(n))._privateMode=this._privateMode,a.init(r,i),s[i]=a}return a.init(r,i),a.setAnimation(i),a},e.destroyCachedAnimations=function(t){if(t){var e=this._animationPool;for(var i in e)i.includes(t)&&(e[i].destroy(),delete e[i]);var n=this._skeletonCache[t],r=n&&n.skeleton;r&&XRt.wasmUtil.destroySpineSkeleton(r),n&&delete this._skeletonCache[t]}else{var s=this._animationPool;for(var a in s)s[a].destroy(),delete s[a]}},t}();TFt=WFt,WFt.FrameTime=BFt,WFt.sharedCache=new TFt;var jFt=(IFt=Kh("sp.SkeletonData"),MFt=Ou([Ey]),PFt=Ou([_i]),IFt((OFt=function(t){function e(){var e;return(e=t.call(this)||this)._skeletonJson=kFt&&kFt(),e.textures=RFt&&RFt(),e.textureNames=FFt&&FFt(),e.scale=LFt&&LFt(),e._atlasText=VFt&&VFt(),e._buffer=void 0,e._skeletonCache=null,e._skinsEnum=null,e._animsEnum=null,e.reset(),e}s(e,t);var i=e.prototype;return i.createNode=function(t){var e=new eb(this.name);return e.addComponent("cc.Skeleton").skeletonData=this,t(null,e)},i.reset=function(){this._skeletonCache=null},i.resetEnums=function(){},i.getRuntimeData=function(t){if(this._skeletonCache)return this._skeletonCache;if(!(this.textures&&this.textures.length>0)&&this.textureNames&&this.textureNames.length>0)return t||J(this.name+" no textures found!"),null;var e=this.mergedUUID(),i=XRt.wasmUtil.querySpineSkeletonDataByUUID(e);if(i)this._skeletonCache=i;else{for(var n=this.textures.length,r=[],s=0;s1)return this._animsEnum;var t=this.getRuntimeData(!0);if(t){for(var e={"":0},i=t.animations,n=0;n":0};Re(BLt);var ILt=BLt,MLt=(XFt=Kh("sp.Skeleton.SpineSocket"),YFt=Ou(eb),XFt((KFt=function(t,e){void 0===t&&(t=""),void 0===e&&(e=null),this.path=QFt&&QFt(),this.target=ZFt&&ZFt(),this.path=t,this.target=e},QFt=zh(KFt.prototype,"path",[uu],(function(){return""})),ZFt=zh(KFt.prototype,"target",[YFt,uu],(function(){return null})),JFt=KFt))||JFt);le(MLt,"sp.Skeleton.SpineSocket");var PLt=($Ft=Kh("sp.Skeleton"),tLt=Ou(jFt),eLt=Ou(DLt),iLt=Ou(BLt),nLt=Ou(ALt),rLt=Ou([MLt]),sLt=Ou(GT),$Ft((wLt=function(t){function e(){var e;return(e=t.call(this)||this)._skeletonData=hLt&&hLt(),e.defaultSkin=uLt&&uLt(),e.defaultAnimation=lLt&&lLt(),e._premultipliedAlpha=cLt&&cLt(),e._timeScale=fLt&&fLt(),e._preCacheMode=_Lt&&_Lt(),e._cacheMode=dLt&&dLt(),e._sockets=pLt&&pLt(),e._useTint=mLt&&mLt(),e._debugMesh=gLt&&gLt(),e._debugBones=yLt&&yLt(),e._debugSlots=vLt&&vLt(),e._enableBatch=bLt&&bLt(),e._runtimeData=null,e._skeleton=null,e._instance=null,e._state=null,e._textures=[],e._skeletonInfo=null,e._animationName="",e._skinName="",e._drawList=new uo((function(){return{material:null,texture:null,indexOffset:0,indexCount:0}}),1),e._materialCache={},e.paused=!1,e._enumSkins=Ee({}),e._enumAnimations=Ee({}),e.attachUtil=void 0,e._socketNodes=new Map,e._cachedSockets=new Map,e._startEntry=void 0,e._endEntry=void 0,e._paused=!1,e._accTime=0,e._playCount=0,e._skeletonCache=null,e._animCache=null,e._animationQueue=[],e._headAniInfo=null,e._isAniComplete=!0,e._playTimes=0,e._curFrame=null,e._needUpdateSkeltonData=!0,e._listener=null,e._debugRenderer=null,e._startSlotIndex=void 0,e._endSlotIndex=void 0,e._customMaterialInstance=null,e._vLength=0,e._vBuffer=null,e._iLength=0,e._iBuffer=null,e._model=void 0,e._tempColor={r:0,g:0,b:0,a:0},e._eventListenerID=-1,e._slotTextures=null,e.loop=SLt&&SLt(),e._useVertexOpacity=!0,e._startEntry={animation:{name:""},trackIndex:0},e._endEntry={animation:{name:""},trackIndex:0},e._startSlotIndex=-1,e._endSlotIndex=-1,e._instance=new XRt.SkeletonInstance,e._instance.dtRate=1*e._timeScale,e._instance.isCache=e.isAnimationCached(),e.attachUtil=new TLt,e}s(e,t);var i=e.prototype;return i.__preload=function(){t.prototype.__preload.call(this),this._updateSkeletonData(),this._updateDebugDraw()},i.onRestore=function(){this.updateMaterial(),this._markForUpdateRenderData()},i.getState=function(){return this._state},i.onEnable=function(){t.prototype.onEnable.call(this),this._instance&&(this._instance.enable=!0),this._flushAssembler(),qFt.getInstance().add(this)},i.onDisable=function(){t.prototype.onDisable.call(this),this._instance&&(this._instance.enable=!1),qFt.getInstance().remove(this)},i.onDestroy=function(){var e;this._eventListenerID>0&&(DFt.removeListener(this._eventListenerID),this._eventListenerID=-1),this._drawList.destroy(),this.destroyRenderData(),this._cleanMaterialCache(),this._vBuffer=null,this._iBuffer=null,this.attachUtil.reset(),null==(e=this._slotTextures)||e.clear(),this._slotTextures=null,this._cachedSockets.clear(),this._socketNodes.clear(),this._animCache=null,qFt.getInstance().remove(this),this._instance&&(this._instance.destroy(),this._instance=null),this._destroySkeletonInfo(this._skeletonCache),this._skeletonCache=null,t.prototype.onDestroy.call(this)},i.clearAnimation=function(t){this.isAnimationCached()||(this.clearTrack(t||0),this.setToSetupPose())},i.clearAnimations=function(){this.isAnimationCached()||(this.clearTracks(),this.setToSetupPose())},i._updateSkeletonData=function(){var t=this._skeletonData;if(!t)return this._runtimeData=null,this._state=null,this._skeleton=null,this._textures=[],void this._refreshInspector();this._instance&&(this._instance.dtRate=1*this._timeScale),this._needUpdateSkeltonData=!1,this._runtimeData=t.getRuntimeData(),this._runtimeData&&(this.setSkeletonData(this._runtimeData),this._textures=t.textures,this._refreshInspector(),this.defaultSkin&&""!==this.defaultSkin?this.setSkin(this.defaultSkin):this._skinName&&""!==this._skinName&&this.setSkin(this._skinName),this.defaultAnimation?this.animation=this.defaultAnimation.toString():this._animationName?this.animation=this._animationName:this.animation="",this._updateUseTint(),this._indexBoneSockets(),this._updateSocketBindings(),this.attachUtil.init(this),this._preCacheMode=this._cacheMode)},i.setSkeletonData=function(t){var e=this._skeletonCache;if(1===this._cacheMode?this._skeletonCache=WFt.sharedCache:2===this._cacheMode?(this._skeletonCache=new WFt,this._skeletonCache.enablePrivateMode()):this._skeletonCache=null,e!==this._skeletonCache&&this._destroySkeletonInfo(e),this.isAnimationCached()){(this.debugBones||this.debugSlots)&&at(16410);var i=this._skeletonCache.getSkeletonInfo(this._skeletonData);this._skeletonInfo!==i&&(this._destroySkeletonInfo(this._skeletonCache),i||2!==this._cacheMode||(this._animCache=this._skeletonCache.initAnimationCache(this.skeletonData.uuid,this._skeletonData,this._animationName)),this._skeletonInfo=this._skeletonCache.createSkeletonInfo(this._skeletonData)),this._skeletonInfo&&(this._skeleton=this._skeletonInfo.skeleton)}else this._skeleton=this._instance.initSkeleton(t),this._state=this._instance.getAnimationState(),this._instance.setPremultipliedAlpha(this._premultipliedAlpha);this._flushAssembler()},i.setSlotsRange=function(t,e){this.isAnimationCached()?at(16411):(this._startSlotIndex=t,this._endSlotIndex=e)},i.getAttachment=function(t,e){return this._skeleton?this._skeleton.getAttachmentByName(t,e):null},i.setAttachment=function(t,e){this._skeleton&&this._skeleton.setAttachment(t,e),this.invalidAnimationCache()},i.getTextureAtlas=function(t){return t.region},i.setAnimation=function(t,e,i){if("string"!=typeof e)return it(7511),null;var n=this._skeleton;if(!n||!n.data.findAnimation(e))return it(7509,e),null;var r=null;if(void 0===i&&(i=!0),this._playTimes=i?0:1,this.isAnimationCached()){if(0!==t&&at(16412),!this._skeletonCache)return null;var s=this._skeletonCache.getAnimationCache(this._skeletonData.uuid,e);s||(s=this._skeletonCache.initAnimationCache(this.skeletonData.uuid,this._skeletonData,e))&&this._skinName&&s.setSkin(this._skinName),s&&(this._animationName=e,this._isAniComplete=!1,this._accTime=0,this._playCount=0,this._animCache=s,this._socketNodes.size>0&&this._animCache.enableCacheAttachedInfo(),this._animCache.updateToFrame(0),this._curFrame=this._animCache.frames[0])}else this._animationName=e,r=this._instance.setAnimation(t,e,i);return this._markForUpdateRenderData(),r},i.addAnimation=function(t,e,i,n){if(n=n||0,this.isAnimationCached())return 0!==t&&at(16413),this._animationQueue.push({animationName:e,loop:i,delay:n}),null;if(this._skeleton){var r,s=this._skeleton.data.findAnimation(e);return s?null==(r=this._state)?void 0:r.addAnimationWith(t,s,i,n):(it(7510,e),null)}return null},i.findAnimation=function(t){return this._skeleton?this._skeleton.data.findAnimation(t):null},i.getCurrent=function(t){if(this.isAnimationCached())at(16414);else if(this._state)return this._state.getCurrent(t);return null},i.setSkin=function(t){t&&(this._skeleton&&this._skeleton.setSkinByName(t),this._instance.setSkin(t),this.isAnimationCached()&&this._animCache&&this._animCache.setSkin(t),this._skinName=t,this.invalidAnimationCache())},i.updateAnimation=function(t){if(this._markForUpdateRenderData(),!this.paused)if(this.isAnimationCached()){if(t*=1*this._timeScale,this._isAniComplete){var e;if(0===this._animationQueue.length&&!this._headAniInfo){var i=this._animCache;if(i&&i.isInvalid()){i.updateToFrame(0);var n=i.frames;this._curFrame=n[n.length-1]}return}if(this._headAniInfo||(this._headAniInfo=this._animationQueue.shift()),this._accTime+=t,this._accTime>(null==(e=this._headAniInfo)?void 0:e.delay)){var r=this._headAniInfo;this._headAniInfo=null,this.setAnimation(0,null==r?void 0:r.animationName,null==r?void 0:r.loop)}return}this._updateCache(t)}else this._instance.updateAnimation(t)},i._updateCache=function(t){var e=this._animCache;if(e.isInited()){var i=e.frames,n=WFt.FrameTime;0===this._accTime&&0===this._playCount&&(this._startEntry.animation.name=this._animationName,this._listener&&this._listener.start&&this._listener.start(this._startEntry)),this._accTime+=t;var r=Math.floor(this._accTime/n);if(e.isCompleted||e.updateToFrame(r),this._curFrame=i[r],void 0!==this._curFrame&&this.attachUtil.updateSkeletonBones(this._curFrame.boneInfos),e.isCompleted&&r>=i.length){if(this._playCount++,this._playTimes>0&&this._playCount>=this._playTimes)return this._curFrame=i[i.length-1],this._accTime=0,this._playCount=0,this._isAniComplete=!0,void this._emitCacheCompleteEvent();this._accTime=0,r=0,this._curFrame=i[r],this._emitCacheCompleteEvent()}}},i._emitCacheCompleteEvent=function(){this._listener&&(this._endEntry.animation.name=this._animationName,this._listener.complete&&this._listener.complete(this._endEntry),this._listener.end&&this._listener.end(this._endEntry))},i.updateRenderData=function(){return this.isAnimationCached()?this._curFrame?this._curFrame.model:null:this._instance.updateRenderData()},i._flushAssembler=function(){var t=e.Assembler.getAssembler(this);this._assembler!==t&&(this._assembler=t),this._skeleton&&this._assembler&&this._assembler.createData&&(this._renderData=this._assembler.createData(this),this._markForUpdateRenderData(),this._updateColor())},i._render=function(t){var e=0;if(this.renderData&&this._drawList.length>0){for(var i=this.renderData,n=i.chunk,r=n.vertexAccessor,s=i.getMeshBuffer(),a=s.indexOffset,o=0;o":e(t[i.parent.data.index])+"/"+i.data.name},i=0,n=t.length;i0?Array.from(this._cachedSockets.keys()).sort():[]):[]},i._updateUseTint=function(){this._cleanMaterialCache(),this.destroyRenderData(),this.isAnimationCached()||this._instance.setUseTint(this._useTint);var t=this._assembler;t&&t.createData&&this._skeleton&&(this._renderData=t.createData(this),this._markForUpdateRenderData())},i._updateBatch=function(){this._cleanMaterialCache(),this._markForUpdateRenderData()},i._updateDebugDraw=function(){if(this.debugBones||this.debugSlots||this.debugMesh){if(!this._debugRenderer){var t=new eb("DEBUG_DRAW_NODE");t.layer=this.node.layer,t.hideFlags|=1032;var e=null;try{(e=t.addComponent("cc.Graphics")).lineWidth=5,e.strokeColor=new cr(255,0,0,255),this._debugRenderer=e,t.parent=this.node,this.node.on("layer-changed",this._applyLayer,this)}catch(e){ht(4501,e.message),t.destroy(),t=null}}this.isAnimationCached()?at(16418):this._instance.setDebugMode(!0)}else this._debugRenderer&&(this.node.off("layer-changed",this._applyLayer,this),this._debugRenderer.node.destroy(),this._debugRenderer=null,this.isAnimationCached()||this._instance&&this._instance.setDebugMode(!1))},i._updateUITransform=function(){var t=this.node._getUITransformComp(),e=this._runtimeData;if(!e)return t.setContentSize(100,100),t.anchorX=.5,void(t.anchorX=.5);var i=e.width,n=e.height;i&&n&&(t.setContentSize(i,n),0!==i&&(t.anchorX=Math.abs(e.x)/i),0!==n&&(t.anchorY=Math.abs(e.y)/n))},i._updateColor=function(){var t=this,e=t.node._uiProps,i=t._tempColor,n=t._color,r=t.node.parent?t.node.parent._uiProps.opacity:1,s=e.localOpacity*r*n.a/255;if(i.r!==n.r||i.g!==n.g||i.b!==n.b||i.a!==s){e.colorDirty=!0,i.r=n.r,i.g=n.g,i.b=n.b,i.a=s;var a=n.r/255,o=n.g/255,h=n.b/255;this._instance.setColor(a,o,h,s)}},i.setVertexEffectDelegate=function(t){if(this._instance)if(t){var e=null==t?void 0:t.getEffectType();if("jitter"===e){var i=null==t?void 0:t.getJitterVertexEffect();this._instance.setJitterEffect(i)}else if("swirl"===e){var n=null==t?void 0:t.getJitterVertexEffect();this._instance.setSwirlEffect(n)}}else this._instance.clearEffect()},i._ensureListener=function(){this._listener||(this._listener=new DFt,this._eventListenerID=DFt.addListener(this._listener),this._instance.setListener(this._eventListenerID))},i.setStartListener=function(t){this._ensureListener(),this._listener.start=t},i.setInterruptListener=function(t){this._ensureListener(),this._listener.interrupt=t},i.setEndListener=function(t){this._ensureListener(),this._listener.end=t},i.setDisposeListener=function(t){this._ensureListener(),this._listener.dispose=t},i.setCompleteListener=function(t){this._ensureListener(),this._listener.complete=t},i.setEventListener=function(t){this._ensureListener(),this._listener.event=t},i.setTrackStartListener=function(t,e){DFt.getListeners(t,this._instance).start=e},i.setTrackInterruptListener=function(t,e){DFt.getListeners(t,this._instance).interrupt=e},i.setTrackEndListener=function(t,e){DFt.getListeners(t,this._instance).end=e},i.setTrackDisposeListener=function(t,e){DFt.getListeners(t,this._instance).dispose=e},i.setTrackCompleteListener=function(t,e){DFt.getListeners(t,this._instance).complete=function(t){var i=Math.floor(t.trackTime/t.animationEnd);e(t,i)}},i.setTrackEventListener=function(t,e){DFt.getListeners(t,this._instance).event=e},i.getDebugShapes=function(){return this._instance.getDebugShapes()},i.setSlotTexture=function(t,e,i){if(this.isAnimationCached())J("Cached mode can't change texture of slot");else if(this.findSlot(t)){var n=e.width,r=e.height,s=i||!1;this._instance.resizeSlotRegion(t,n,r,s);var a=e.uuid;a||(a=e.getId()),this._instance.setSlotTexture(t,a),this._slotTextures||(this._slotTextures=new Map),this._slotTextures.set(a,e)}else J("No slot named:"+t)},i._destroySkeletonInfo=function(t){t&&this._skeletonInfo&&(t.destroySkeleton(this._skeletonInfo.assetUUID),this._skeletonInfo=null)},i._applyLayer=function(){this._debugRenderer&&(this._debugRenderer.node.layer=this.node.layer)},n(e,[{key:"drawList",get:function(){return this._drawList}},{key:"skeletonData",get:function(){return this._skeletonData},set:function(t){t&&t.resetEnums(),this._skeletonData!==t&&(this.destroyRenderData(),this._skeletonData=t,this.defaultSkin="",this.defaultAnimation="",this._animationName="",this._skinName="",this._updateSkeletonData(),this._updateUITransform())}},{key:"_defaultSkinIndex",get:function(){if(this.skeletonData){var t=this.skeletonData.getSkinsEnum();if(t)if(""===this.defaultSkin){if(t.hasOwnProperty(0))return this._defaultSkinIndex=0,0}else{var e=t[this.defaultSkin];if(void 0!==e)return e}}return 0},set:function(t){var e;if(this.skeletonData&&(e=this.skeletonData.getSkinsEnum()),e){var i=e[t];void 0!==i?(this.defaultSkin=String(i),this.setSkin(this.defaultSkin),this._refreshInspector(),this._markForUpdateRenderData()):J(this.name+" skin enums are invalid")}else J(this.name+" skin enums are invalid")}},{key:"_animationIndex",get:function(){var t=this.animation;if(this.skeletonData)if(t){var e=this.skeletonData.getAnimsEnum();if(e){var i=e[t];if(void 0!==i)return i}}else this._refreshInspector();return 0},set:function(t){var e;if(this.skeletonData&&(e=this.skeletonData.getAnimsEnum()),e){var i=String(e[t]);void 0!==i?(this.animation=i,this.animation=i):J(this.name+" animation enums are invalid")}else J(this.name+" animation enums are invalid")}},{key:"defaultCacheMode",get:function(){return this._cacheMode},set:function(t){this._cacheMode=t,this.setAnimationCacheMode(this._cacheMode)}},{key:"premultipliedAlpha",get:function(){return this._premultipliedAlpha},set:function(t){t!==this._premultipliedAlpha&&(this._premultipliedAlpha=t,this._instance.setPremultipliedAlpha(t),this._markForUpdateRenderData())}},{key:"timeScale",get:function(){return this._timeScale},set:function(t){t!==this._timeScale&&(this._timeScale=t,this._instance&&(this._instance.dtRate=1*this._timeScale))}},{key:"useTint",get:function(){return this._useTint},set:function(t){t!==this._useTint&&(this._useTint=t,this._updateUseTint())}},{key:"enableBatch",get:function(){return this._enableBatch},set:function(t){t!==this._enableBatch&&(this._enableBatch=t,this._updateBatch())}},{key:"sockets",get:function(){return this._sockets},set:function(t){this._sockets=t,this._updateSocketBindings(),this.attachUtil.init(this)}},{key:"debugSlots",get:function(){return this._debugSlots},set:function(t){t!==this._debugSlots&&(this._debugSlots=t,this._updateDebugDraw(),this._markForUpdateRenderData())}},{key:"debugBones",get:function(){return this._debugBones},set:function(t){t!==this._debugBones&&(this._debugBones=t,this._updateDebugDraw(),this._markForUpdateRenderData())}},{key:"debugMesh",get:function(){return this._debugMesh},set:function(t){t!==this._debugMesh&&(this._debugMesh=t,this._updateDebugDraw(),this._markForUpdateRenderData())}},{key:"socketNodes",get:function(){return this._socketNodes}},{key:"animation",get:function(){return this._animationName},set:function(t){t?this.setAnimation(0,t,this.loop):this.clearAnimation(0)}},{key:"customMaterial",get:function(){return this._customMaterial},set:function(t){this._customMaterial=t,this.updateMaterial(),this._markForUpdateRenderData()}},{key:"customMaterialInstance",get:function(){if(!this._customMaterial)return null;if(!this._customMaterialInstance){var t={parent:this._customMaterial,subModelIdx:0,owner:this};this._customMaterialInstance=new QT(t)}return this._customMaterialInstance}}]),e}(BL),wLt.SpineSocket=MLt,wLt.AnimationCacheMode=ALt,hLt=zh((oLt=wLt).prototype,"_skeletonData",[uu],(function(){return null})),uLt=zh(oLt.prototype,"defaultSkin",[uu],(function(){return""})),lLt=zh(oLt.prototype,"defaultAnimation",[uu],(function(){return""})),cLt=zh(oLt.prototype,"_premultipliedAlpha",[uu],(function(){return!0})),fLt=zh(oLt.prototype,"_timeScale",[uu],(function(){return 1})),_Lt=zh(oLt.prototype,"_preCacheMode",[uu],(function(){return-1})),dLt=zh(oLt.prototype,"_cacheMode",[uu],(function(){return 0})),pLt=zh(oLt.prototype,"_sockets",[uu],(function(){return[]})),mLt=zh(oLt.prototype,"_useTint",[uu],(function(){return!1})),gLt=zh(oLt.prototype,"_debugMesh",[uu],(function(){return!1})),yLt=zh(oLt.prototype,"_debugBones",[uu],(function(){return!1})),vLt=zh(oLt.prototype,"_debugSlots",[uu],(function(){return!1})),bLt=zh(oLt.prototype,"_enableBatch",[uu],(function(){return!1})),v(oLt.prototype,"skeletonData",[tLt],Object.getOwnPropertyDescriptor(oLt.prototype,"skeletonData"),oLt.prototype),v(oLt.prototype,"_defaultSkinIndex",[eLt],Object.getOwnPropertyDescriptor(oLt.prototype,"_defaultSkinIndex"),oLt.prototype),v(oLt.prototype,"_animationIndex",[iLt],Object.getOwnPropertyDescriptor(oLt.prototype,"_animationIndex"),oLt.prototype),v(oLt.prototype,"defaultCacheMode",[nLt],Object.getOwnPropertyDescriptor(oLt.prototype,"defaultCacheMode"),oLt.prototype),SLt=zh(oLt.prototype,"loop",[uu],(function(){return!0})),v(oLt.prototype,"sockets",[rLt],Object.getOwnPropertyDescriptor(oLt.prototype,"sockets"),oLt.prototype),v(oLt.prototype,"customMaterial",[Gu,sLt],Object.getOwnPropertyDescriptor(oLt.prototype,"customMaterial"),oLt.prototype),aLt=oLt))||aLt);C.internal.SpineSkeleton=PLt;var ELt,OLt,kLt,RLt,FLt=function(){function t(){this.name="sp.VertexEffectDelegate",this._vertexEffect=void 0,this._interpolation=void 0,this._effectType=void 0,this._vertexEffect=null,this._interpolation=null,this._effectType="none"}var e=t.prototype;return e.clear=function(){this._vertexEffect=null,this._interpolation=null,this._effectType="none"},e.initJitter=function(t,e){return this._effectType="jitter",this._vertexEffect=new XRt.JitterEffect(t,e),this._vertexEffect},e.initSwirlWithPow=function(t,e){return this._effectType="swirl",this._interpolation=new XRt.Pow(e),this._vertexEffect=new XRt.SwirlEffect(t,this._interpolation),this._vertexEffect},e.initSwirlWithPowOut=function(t,e){return this._effectType="swirl",this._interpolation=new XRt.PowOut(e),this._vertexEffect=new XRt.SwirlEffect(t,this._interpolation),this._vertexEffect},e.getJitterVertexEffect=function(){return this._vertexEffect},e.getSwirlVertexEffect=function(){return this._vertexEffect},e.getVertexEffect=function(){return this._vertexEffect},e.getEffectType=function(){return this._effectType},t}(),LLt=new cr(0,0,255,255),VLt=new cr(255,0,0,255),NLt=new cr(0,255,0,255),zLt=new cr(255,255,0,255),ULt=null,GLt=null,HLt=!1,WLt=!1,jLt=kF(MF),qLt=kF(EF),XLt=new ir(0,0,0);function YLt(t,e){var i,n;switch(t){case 1:i=HLt?1:2,n=1;break;case 2:i=7,n=4;break;case 3:i=HLt?1:2,n=8;break;default:i=HLt?1:2,n=4}return e.getMaterialForBlendAndTint(i,n,WLt?1:0)}var JLt=function(){function t(){this.vCount=32767}var e=t.prototype;return e.ensureAccessor=function(t){var e=t?GLt:ULt;if(!e){var i=YE.root.device,n=YE.root.batcher2D,r=t?EF:MF;t?(e=GLt=new NF(i,r,this.vCount),n.registerBufferAccessor(Number.parseInt("SPINETINT",36),GLt)):(e=ULt=new NF(i,r,this.vCount),n.registerBufferAccessor(Number.parseInt("SPINE",36),ULt))}return e},e.createData=function(t){var e=t.renderData;if(!e){var i=t.useTint||t.isAnimationCached(),n=this.ensureAccessor(i);e=tL.add(i?EF:MF,n)}return e},e.updateRenderData=function(t){var e;t._skeleton&&t.node.active&&null!=(e=t.skeletonData)&&e.isValid&&QLt(t)},t}(),KLt=new JLt;function QLt(t){if(t.drawList.reset(),0!==t.color.a){t._updateColor(),HLt=t.premultipliedAlpha,WLt=t.useTint||t.isAnimationCached(),t.isAnimationCached()?$Lt(t):ZLt(t);var e=t.renderData,i=WLt?GLt:ULt;t.syncAttachedNode(),(e.vertexCount>0||e.indexCount>0)&&i.getMeshBuffer(e.chunk.bufferId).setDirty()}}function ZLt(t){var e,i,n=(t.useTint?qLt:jLt)/4,r=t.updateRenderData(),s=r.vCount,a=r.iCount;if(!(s<1||a<1)){var o=t.renderData;o.vertexCount===s&&o.indexCount===a||(o.resize(s,a),o.indices=new Uint16Array(a),t._vLength=4*s*n,t._vBuffer=new Uint8Array(o.chunk.vb.buffer,o.chunk.vb.byteOffset,4*o.chunk.vb.length),t._iLength=2*a,t._iBuffer=new Uint8Array(o.indices.buffer));var h=o.chunk.vb,u=r.vPtr,l=r.iPtr,c=o.indices,f=XRt.wasmUtil.wasm.HEAPU8;null==(e=t._vBuffer)||e.set(f.subarray(u,u+t._vLength),0),null==(i=t._iBuffer)||i.set(f.subarray(l,l+t._iLength),0);for(var _=o.chunk.vertexOffset,d=0;dKi||4294967295!==cr.toUint32(o)||HLt){ELt=o.r/255,OLt=o.g/255,kLt=o.b/255,RLt=h;for(var u=0;u>t,n=0;if(t<3&&(i-=2,n=e*GVt+e),0!==i&&0!==i){var r=i*i*6;this._bodyIndexPool[t].indices=new Uint16Array(r);for(var s=0,a=new Uint16Array(r),o=n,h=o+GVt*e,u=0;u>e,o=0,h=new Uint16Array(2*a+2);h[o++]=0,h[o++]=0;for(var u=1;u>e,o=0,h=new Uint16Array(2*a+2);h[o++]=1056,h[o++]=1056;for(var u=1;u>e,o=0,h=new Uint16Array(2*a+2);h[o++]=0,h[o++]=0;for(var u=1;u>e,o=0,h=new Uint16Array(2*a+2);h[o++]=32,h[o++]=32;for(var u=1;u0&&(this._brushPass=n.passes[0],this._currentMaterial.passes.push(this._brushPass),n.passes.pop())}return e&&this._model.initSubModel(0,this._meshData,this._currentMaterial),this.setSharedMaterial(this._currentMaterial,0),this._currentMaterialLayers=i,this._model.enabled=!0,this._model.receiveShadow=t.getTerrain().receiveShadow,!0}return!1},i._updateLightingmap=function(t,e){null!=this._model&&(this._lightmap=t,this._updateReceiveDirLight(),this._model.updateLightingmap(t,e))},i._onMaterialModified=function(t,e){null!=this._model&&this._onRebuildPSO(t,e||this._getBuiltinMaterial())},i._onRebuildPSO=function(t,e){this._model&&this._model.setSubModelMaterial(t,e)},i._clearMaterials=function(){null!=this._model&&this._onMaterialModified(0,null)},i._onUpdateReceiveDirLight=function(t,e){void 0===e&&(e=!1),this._model&&(e?this._model.receiveDirLight=!1:this.node&&(t&this.node.layer)===this.node.layer||t&this._model.visFlags?this._model.receiveDirLight=!0:this._model.receiveDirLight=!1)},i._updateReceiveDirLight=function(){var t=this.node.scene;if(t&&t.renderScene){var e=t.renderScene.mainLight;if(e){var i=e.visibility;e.node&&(e.node.mobility===Uy.Static&&this._lightmap?this._onUpdateReceiveDirLight(i,!0):this._onUpdateReceiveDirLight(i))}}},i._getBuiltinMaterial=function(){return mT.get("missing-material")},e}(HU),QVt=t("gb",Kh("cc.TerrainBlockLightmapInfo")((yVt=function(){this.texture=vVt&&vVt(),this.UOff=bVt&&bVt(),this.VOff=SVt&&SVt(),this.UScale=wVt&&wVt(),this.VScale=xVt&&xVt()},vVt=zh(yVt.prototype,"texture",[uu],(function(){return null})),bVt=zh(yVt.prototype,"UOff",[uu],(function(){return 0})),SVt=zh(yVt.prototype,"VOff",[uu],(function(){return 0})),wVt=zh(yVt.prototype,"UScale",[uu],(function(){return 0})),xVt=zh(yVt.prototype,"VScale",[uu],(function(){return 0})),gVt=yVt))||gVt),ZVt=t("gc",function(){function t(t,e,i){this._terrain=void 0,this._node=void 0,this._renderable=void 0,this._index=[1,1],this._weightMap=null,this._lightmapInfo=null,this._lodLevel=0,this._lodKey=new WVt,this._errorMetrics=[0,0,0,0],this._LevelDistances=[HVt,HVt,HVt,HVt],this._bbMin=nr(),this._bbMax=nr(),this._terrain=t,this._index[0]=e,this._index[1]=i,this._lightmapInfo=t._getLightmapInfo(e,i),this._node=new eb("TerrainBlock"),this._node.setParent(this._terrain.node),this._node.hideFlags|=1032,this._node.layer=this._terrain.node.layer,this._renderable=this._node.addComponent(KVt)}var e=t.prototype;return e.build=function(){var t=YE.root.device,e=new Float32Array(PIt*MIt*MIt);this._buildVertexData(e);var i=t.createBuffer(new ud(10,1,4*PIt*MIt*MIt,4*PIt));i.update(e),this._buildBoundingBox();var n=[new Cd("a_position",32),new Cd("a_normal",32),new Cd("a_texCoord",21)];this._renderable._meshData=new sO([i],n,7,this._terrain._getSharedIndexBuffer(),null,!1),this._renderable._model=C.director.root.createModel(KM),this._renderable._model.createBoundingShape(this._bbMin,this._bbMax),this._renderable._model.node=this._renderable._model.transform=this._node,null!=this._renderable.node.scene&&(this.visible=!0),this._updateWeightMap(),this._updateMaterial(!0),this._terrain.lodEnable&&(this._updateLodBuffer(e),this._updateIndexBuffer())},e.rebuild=function(){this._updateHeight(),this._updateWeightMap(),this._renderable._invalidMaterial(),this._updateMaterial(!1)},e.destroy=function(){this.visible=!1,this._renderable._destroyModel(),null!=this._node&&this._node.isValid&&this._node.destroy(),null!=this._weightMap&&this._weightMap.destroy()},e.update=function(){this._updateMaterial(!1),this.lightmap!==this._renderable._lightmap&&this._renderable._updateLightingmap(this.lightmap,this.lightmapUVParam);var t=this._terrain.useNormalMap,e=this._terrain.usePBR,i=function(t){return null!==t?t.detailMap:null},n=function(t){var e=null!==t?t.normalMap:null;return null===e&&(e=mT.get("normal-texture")),e},r=this._renderable._currentMaterial;if(null!==r){var s=this.getMaxLayer(),a=new Vn(1,1,1,1),o=new Vn(1,1,1,1),h=new Vn(0,0,0,0);if(0===s)if(-1!==this.layers[0]){var u=this._terrain.getLayer(this.layers[0]);null!==u&&(a.x=1/u.tileSize,o.x=u.roughness,h.x=u.metallic),r.setProperty("detailMap0",i(u)),t&&r.setProperty("normalMap0",n(u))}else r.setProperty("detailMap0",mT.get("default-texture")),t&&r.setProperty("normalMap0",mT.get("normal-texture"));else if(1===s){var l=this._terrain.getLayer(this.layers[0]),c=this._terrain.getLayer(this.layers[1]);null!==l&&(a.x=1/l.tileSize,o.x=l.roughness,h.x=l.metallic),null!==c&&(a.y=1/c.tileSize,o.y=c.roughness,h.y=c.metallic),r.setProperty("weightMap",this._weightMap),r.setProperty("detailMap0",i(l)),r.setProperty("detailMap1",i(c)),t&&(r.setProperty("normalMap0",n(l)),r.setProperty("normalMap1",n(c)))}else if(2===s){var f=this._terrain.getLayer(this.layers[0]),_=this._terrain.getLayer(this.layers[1]),d=this._terrain.getLayer(this.layers[2]);null!==f&&(a.x=1/f.tileSize,o.x=f.roughness,h.x=f.metallic),null!==_&&(a.y=1/_.tileSize,o.y=_.roughness,h.y=_.metallic),null!==d&&(a.z=1/d.tileSize,o.z=d.roughness,h.z=d.metallic),r.setProperty("weightMap",this._weightMap),r.setProperty("detailMap0",i(f)),r.setProperty("detailMap1",i(_)),r.setProperty("detailMap2",i(d)),t&&(r.setProperty("normalMap0",n(f)),r.setProperty("normalMap1",n(_)),r.setProperty("normalMap2",n(d)))}else if(3===s){var p=this._terrain.getLayer(this.layers[0]),m=this._terrain.getLayer(this.layers[1]),g=this._terrain.getLayer(this.layers[2]),y=this._terrain.getLayer(this.layers[3]);null!==p&&(a.x=1/p.tileSize,o.x=p.roughness,h.x=p.metallic),null!==m&&(a.y=1/m.tileSize,o.y=m.roughness,h.y=m.metallic),null!==g&&(a.z=1/g.tileSize,o.z=g.roughness,h.z=g.metallic),null!==y&&(a.w=1/y.tileSize,o.w=y.roughness,h.w=y.metallic),r.setProperty("weightMap",this._weightMap),r.setProperty("detailMap0",i(p)),r.setProperty("detailMap1",i(m)),r.setProperty("detailMap2",i(g)),r.setProperty("detailMap3",i(y)),t&&(r.setProperty("normalMap0",n(p)),r.setProperty("normalMap1",n(m)),r.setProperty("normalMap2",n(g)),r.setProperty("normalMap3",n(y)))}r.setProperty("UVScale",a),e&&(r.setProperty("roughness",o),r.setProperty("metallic",h))}},e._buildLodInfo=function(){var t=new Float32Array(PIt*MIt*MIt);this._buildVertexData(t),this._updateLodBuffer(t),this._updateIndexBuffer()},e._updateLevel=function(t){var e=this._terrain,i=e.node,n=nr(),r=nr();ir.add(n,this._bbMin,i.worldPosition),ir.add(r,this._bbMax,i.worldPosition);var s=ir.distance(n,t),a=ir.distance(r,t),o=Math.min(s,a);for(o-=e.LodBias,this._lodLevel=0;this._lodLevel<3&&!(o<=this._LevelDistances[this._lodLevel+1]);)++this._lodLevel},e.setBrushMaterial=function(t){this._renderable._brushMaterial!==t&&(this._renderable._invalidMaterial(),this._renderable._brushMaterial=t)},e._getBrushMaterial=function(){return this._renderable?this._renderable._brushMaterial:null},e._getBrushPass=function(){return this._renderable?this._renderable._brushPass:null},e.getTerrain=function(){return this._terrain},e.getIndex=function(){return this._index},e.getRect=function(){var t=new bs;return t.x=this._index[0]*IIt,t.y=this._index[1]*IIt,t.width=IIt,t.height=IIt,t},e.setLayer=function(t,e){this.layers[t]!==e&&(this._terrain.setBlockLayer(this._index[0],this._index[1],t,e),this._renderable._invalidMaterial(),this._updateMaterial(!1))},e.getLayer=function(t){return this.layers[t]},e.getMaxLayer=function(){return this.layers[3]>=0?3:this.layers[2]>=0?2:this.layers[1]>=0?1:0},e._getMaterialDefines=function(t){var e=1;return this._terrain.node&&this._terrain.node.scene&&this._terrain.node.scene.globals.bakedWithStationaryMainLight&&(e=2),{LAYERS:t+1,CC_USE_LIGHTMAP:null!==this.lightmap?e:0,USE_NORMALMAP:this._terrain.useNormalMap?1:0,USE_PBR:this._terrain.usePBR?1:0}},e._invalidMaterial=function(){this._renderable._invalidMaterial()},e._updateMaterial=function(t){this._renderable._updateMaterial(this,t)&&(null!==this.lightmap&&this.lightmap.setWrapMode(3,3),this._renderable._updateLightingmap(this.lightmap,this.lightmapUVParam))},e._updateHeight=function(){if(null!=this._renderable._meshData){var t=new Float32Array(PIt*MIt*MIt);this._buildVertexData(t),this._renderable._meshData.vertexBuffers[0].update(t),this._buildBoundingBox(),this._renderable._model.createBoundingShape(this._bbMin,this._bbMax),this._renderable._model.updateWorldBound(),this._updateLodBuffer(t),this._updateIndexBuffer()}},e._updateWeightMap=function(){if(0!==this.getMaxLayer()){null==this._weightMap&&(this._weightMap=new Ey,this._weightMap.create(this._terrain.weightMapSize,this._terrain.weightMapSize,35),this._weightMap.setFilters(2,2),this._weightMap.setWrapMode(2,2));for(var t=new Uint8Array(this._terrain.weightMapSize*this._terrain.weightMapSize*4),e=0,i=0;i0){var e=this.getTerrain().getBlock(this._index[0]-1,this._index[1]);t.west=e._lodLevel,t.west0){var n=this.getTerrain().getBlock(this._index[0],this._index[1]-1);t.north=n._lodLevel,t.north>t,o=s-1>>t,h=0;hthis.vertexCount[0]-1||s<0||s>this.vertexCount[1]-1)return null;r=$i(r,0,this.vertexCount[0]-1),s=$i(s,0,this.vertexCount[1]-1),a=$i(a,0,this.vertexCount[0]-1),o=$i(o,0,this.vertexCount[1]-1);var l=this.getHeight(r,s),c=this.getHeight(a,s),f=this.getHeight(r,o),_=this.getHeight(a,o),d=.5*(c+f);return h+u<=1?_=d+(d-l):l=d+(d-_),(l*(1-h)+c*h)*(1-u)+(f*(1-h)+_*h)*u},i._setNormal=function(t,e,i){var n=e*this.vertexCount[0]+t;this._normals[3*n+0]=i.x,this._normals[3*n+1]=i.y,this._normals[3*n+2]=i.z},i.getNormal=function(t,e){var i=e*this.vertexCount[0]+t,n=nr();return n.x=this._normals[3*i+0],n.y=this._normals[3*i+1],n.z=this._normals[3*i+2],n},i.getNormalAt=function(t,e){var i=t/this.tileSize,n=e/this.tileSize,r=Math.floor(i),s=Math.floor(n),a=r+1,o=s+1,h=i-r,u=n-s;if(r<0||r>this.vertexCount[0]-1||s<0||s>this.vertexCount[1]-1)return null;r=$i(r,0,this.vertexCount[0]-1),s=$i(s,0,this.vertexCount[1]-1),a=$i(a,0,this.vertexCount[0]-1),o=$i(o,0,this.vertexCount[1]-1);var l=this.getNormal(r,s),c=this.getNormal(a,s),f=this.getNormal(r,o),_=this.getNormal(a,o),d=nr();ir.add(d,c,f).multiplyScalar(.5),h+u<=1?(_.set(d),_.subtract(l),_.add(d)):(l.set(d),l.subtract(_),l.add(d));var p=nr(),m=nr(),g=nr();return ir.lerp(p,l,c,h),ir.lerp(m,f,_,h),ir.lerp(g,p,m,u),g},i.setWeight=function(t,e,i){var n=e*this._weightMapSize*this._blockCount[0]+t;this._weights[4*n+0]=255*i.x,this._weights[4*n+1]=255*i.y,this._weights[4*n+2]=255*i.z,this._weights[4*n+3]=255*i.w},i.getWeight=function(t,e){var i=e*this._weightMapSize*this._blockCount[0]+t,n=new Vn;return n.x=this._weights[4*i+0]/255,n.y=this._weights[4*i+1]/255,n.z=this._weights[4*i+2]/255,n.w=this._weights[4*i+3]/255,n},i.getWeightAt=function(t,e){var i=this.weightMapSize*this.blockCount[0],n=this.weightMapSize*this.blockCount[1];if(0===i||0===n)return null;var r=t/i,s=e/n,a=Math.floor(r),o=Math.floor(s),h=a+1,u=o+1,l=r-a,c=s-o;if(a<0||a>i-1||o<0||o>n-1)return null;a=$i(a,0,i-1),o=$i(o,0,n-1),h=$i(h,0,i-1),u=$i(u,0,n-1);var f=this.getWeight(a,o),_=this.getWeight(h,o),d=this.getWeight(a,u),p=this.getWeight(h,u),m=new Vn;Vn.add(m,_,d).multiplyScalar(.5),l+c<=1?(p=new Vn,Vn.subtract(p,m,f).add(m)):(f=new Vn,Vn.subtract(f,m,p).add(m));var g=new Vn,y=new Vn,v=new Vn;return Vn.lerp(g,f,_,l),Vn.lerp(y,d,p,l),Vn.lerp(v,g,y,c),v},i.getMaxWeightLayerAt=function(t,e){var i=this.weightMapSize*this.blockCount[0],n=this.weightMapSize*this.blockCount[1];if(0===i||0===n)return null;var r=t/i,s=e/n,a=Math.floor(r),o=Math.floor(s);if(a<0||a>i-1||o<0||o>n-1)return null;var h=this.getWeight(a,o),u=Math.floor(t/this.weightMapSize),l=Math.floor(e/this.weightMapSize),c=this.getBlock(u,l),f=0;return h.y>h[f]&&-1!==c.getLayer(1)&&(f=1),h.y>h[f]&&-1!==c.getLayer(2)&&(f=2),h.z>h[f]&&-1!==c.getLayer(3)&&(f=3),f=c.getLayer(f),this.getLayer(f)},i.getBlockLayers=function(t,e){var i=(e*this._blockCount[0]+t)*DIt;return[this._layerBuffer[i],this._layerBuffer[i+1],this._layerBuffer[i+2],this._layerBuffer[i+3]]},i.getBlockLayer=function(t,e,i){var n=(e*this._blockCount[0]+t)*DIt;return this._layerBuffer[n+i]},i.setBlockLayer=function(t,e,i,n){var r=(e*this._blockCount[0]+t)*DIt;this._layerBuffer[r+i]=n},i.getBlock=function(t,e){return this._blocks[e*this._blockCount[0]+t]},i.getBlocks=function(){return this._blocks},i.rayCheck=function(t,e,i,n){void 0===n&&(n=!0);var r=t;n&&ir.subtract(r,t,this.node.worldPosition);var s=nr();s.set(e),s.multiplyScalar(i);var a=null;if(e.equals(nr(0,1,0))){var o=this.getHeightAt(r.x,r.z);null!=o&&r.y<=o&&(a=nr(r.x,o,r.z))}else if(e.equals(nr(0,-1,0))){var h=this.getHeightAt(r.x,r.z);null!=h&&r.y>=h&&(a=nr(r.x,h,r.z))}else{for(var u=0;u++<2e3;){var l=this.getHeightAt(r.x,r.z);if(null!=l&&r.y<=l)break;r.add(e)}for(;u++<2e3;){var c=this.getHeightAt(r.x,r.z);if(null!=c&&r.y<=c){a=nr(r.x,c,r.z);break}r.add(s)}}return a},i._createSharedIndexBuffer=function(){var t=Wp.gfxDevice;if(null!==this._lod){var e=t.createBuffer(new ud(6,1,2*this._lod._indexBuffer.length,2));return e.update(this._lod._indexBuffer),e}for(var i=new Uint16Array(IIt*IIt*6),n=0,r=0;r0}},{key:"info",get:function(){var t=new YVt;return t.tileSize=this.tileSize,t.blockCount[0]=this.blockCount[0],t.blockCount[1]=this.blockCount[1],t.weightMapSize=this.weightMapSize,t.lightMapSize=this.lightMapSize,t}}]),e}(yg),kVt=zh(OVt.prototype,"__asset",[AVt,uu],(function(){return null})),RVt=zh(OVt.prototype,"_effectAsset",[CVt,uu],(function(){return null})),FVt=zh(OVt.prototype,"_lightmapInfos",[DVt,uu],(function(){return[]})),LVt=zh(OVt.prototype,"_receiveShadow",[uu],(function(){return!1})),VVt=zh(OVt.prototype,"_useNormalmap",[uu],(function(){return!1})),NVt=zh(OVt.prototype,"_usePBR",[uu],(function(){return!1})),zVt=zh(OVt.prototype,"_lodEnable",[uu],(function(){return!1})),UVt=zh(OVt.prototype,"_lodBias",[BVt,uu],(function(){return 0})),v(OVt.prototype,"_asset",[IVt],Object.getOwnPropertyDescriptor(OVt.prototype,"_asset"),OVt.prototype),v(OVt.prototype,"effectAsset",[MVt],Object.getOwnPropertyDescriptor(OVt.prototype,"effectAsset"),OVt.prototype),v(OVt.prototype,"info",[PVt],Object.getOwnPropertyDescriptor(OVt.prototype,"info"),OVt.prototype),EVt=OVt))||EVt)||EVt)),{ORTHO:0,HEX:1,ISO:2});Re($Vt);var tNt={NONE:0,MAP:1,LAYER:2,OBJECTGROUP:3,OBJECT:4,TILE:5};Re(tNt);var eNt={HORIZONTAL:2147483648,VERTICAL:1073741824,DIAGONAL:536870912,FLIPPED_ALL:4026531840,FLIPPED_MASK:268435455};Re(eNt);var iNt={STAGGERAXIS_X:0,STAGGERAXIS_Y:1};Re(iNt);var nNt={STAGGERINDEX_ODD:0,STAGGERINDEX_EVEN:1};Re(nNt);var rNt={RightDown:0,RightUp:1,LeftDown:2,LeftUp:3};Re(rNt);var sNt={RECT:0,ELLIPSE:1,POLYGON:2,POLYLINE:3,IMAGE:4,TEXT:5};Re(sNt);var aNt=function(){function t(){this.name="",this.firstGid=0,this.spacing=0,this.margin=0,this.sourceImage=void 0,this.imageName=null,this.imageOffset=null,this.imageSize=new ms(0,0),this.tileOffset=new ds(0,0),this._tileSize=new ms(0,0),this.collection=!1}return t.prototype.rectForGID=function(t,e){var i=e||new bs(0,0,0,0);i.width=this._tileSize.width,i.height=this._tileSize.height;var n=t;if(n&=268435455,n-=this.firstGid,this.imageOffset)i.x=this.imageOffset.x,i.y=this.imageOffset.y;else{var r=Math.floor((this.imageSize.width-2*this.margin+this.spacing)/(this._tileSize.width+this.spacing));i.x=Math.round(n%r*(this._tileSize.width+this.spacing)+this.margin),i.y=Math.round(Math.floor(n/r)*(this._tileSize.height+this.spacing)+this.margin)}return i},t}(),oNt=function(){function t(){this.properties={},this.name="",this.objects=[],this.visible=!0,this.opacity=0,this.color=new cr(255,255,255,255),this.offset=new ds(0,0),this.draworder="topdown",this.tintColor=null}var e=t.prototype;return e.getProperties=function(){return this.properties},e.setProperties=function(t){this.properties=t},t}(),hNt=function(){function t(){this.properties={},this.name="",this.layerSize=null,this.tiles=[],this.visible=!0,this.opacity=0,this.ownTiles=!0,this.minGID=1e5,this.maxGID=0,this.offset=new ds(0,0),this.tintColor=null}var e=t.prototype;return e.getProperties=function(){return this.properties},e.setProperties=function(t){this.properties=t},t}();hNt.ATTRIB_NONE=1,hNt.ATTRIB_BASE64=2,hNt.ATTRIB_GZIP=4,hNt.ATTRIB_ZLIB=8;var uNt=function(){this.name="",this.visible=!0,this.width=0,this.height=0,this.offset=new ds(0,0),this.opacity=0,this.trans=new cr(255,255,255,255),this.sourceImage=void 0,this.tintColor=null};function lNt(t){if(t.length%4!=0)return null;for(var e=t.length/4,i=window.Uint32Array?new Uint32Array(e):[],n=0;n1,w=b[0],x=w.getAttribute("source");x=x.replace(/\\/g,"/");var T=m.getElementsByTagName("tile"),A=T&&T.length||1,C=null,D=m.getAttribute("name")||"",B=parseInt(m.getAttribute("spacing"))||0,I=parseInt(m.getAttribute("margin"))||0,M=i||parseInt(m.getAttribute("firstgid"))||0,P=new ms(0,0);P.width=parseFloat(m.getAttribute("tilewidth")),P.height=parseFloat(m.getAttribute("tileheight"));var E=m.getElementsByTagName("tileoffset")[0],O=0,k=0;E&&(O=parseFloat(E.getAttribute("x"))||0,k=parseFloat(E.getAttribute("y"))||0);for(var R=null,F=0;F0){var H=U[0],W=H.getAttribute("source");if(W=W.replace(/\\/g,"/"),R.imageName=W,R.imageSize.width=parseFloat(H.getAttribute("width"))||0,R.imageSize.height=parseFloat(H.getAttribute("height"))||0,G||(R._tileSize.width=R.imageSize.width,R._tileSize.height=R.imageSize.height),R.sourceImage=this._spriteFrameMap[W],!R.sourceImage){var j=t.getNameWithPostfix(W);if(R.imageName=j,R.sourceImage=this._spriteFrameMap[j],!R.sourceImage){var q=t.getShortName(W);R.imageName=q,R.sourceImage=this._spriteFrameMap[q],R.sourceImage||(ht(7221,W),Y("Please try asset type of "+W+" to 'sprite-frame'"))}}R.firstGid=268435455&this.parentGID}var X=(268435455&this.parentGID)>>>0;this._tileProperties.set(X,dNt(C));var K=C.getElementsByTagName("animation");if(K&&K.length>0){var Q=K[0].getElementsByTagName("frame"),Z={frames:[],dt:0,frameIdx:0};this._tileAnimations.set(X,Z);for(var $=Z.frames,tt=0;tt0){var _=f[0];l.type=5,l.wrap="1"===_.getAttribute("wrap"),l.color=_Nt(_.getAttribute("color")),l.halign=cNt(_.getAttribute("halign")),l.valign=fNt(_.getAttribute("valign")),l.pixelsize=parseInt(_.getAttribute("pixelsize"))||16,l.text=_.childNodes[0].nodeValue}var d=u.getAttribute("gid");d&&(l.gid=parseInt(d),l.type=4);var p=u.getElementsByTagName("ellipse");p&&p.length>0&&(l.type=1);var m=u.getElementsByTagName("polygon");if(m&&m.length>0){l.type=2;var g=m[0].getAttribute("points");g&&(l.points=this._parsePointsString(g))}var y=u.getElementsByTagName("polyline");if(y&&y.length>0){l.type=3;var v=y[0].getAttribute("points");v&&(l.polylinePoints=this._parsePointsString(v))}l.type||(l.type=0),e.objects.push(l)}"index"!==a&&e.objects.sort((function(t,e){return t.y-e.y}))}return e},e._parsePointsString=function(t){if(!t)return null;for(var e=[],i=t.split(" "),n=0;n1||t.imageOffset)if(i){v._name=i.name;var x=i.unbiasUV[0],T=i.rotated?i.unbiasUV[1]:i.unbiasUV[5];MNt?(v.l=x+(v.x+.5)/c,v.t=T+(v.y+.5)/f,v.r=x+(v.x+v.width-.5)/c,v.b=T+(v.y+v.height-.5)/f):(v.l=x+v.x/c,v.t=T+v.y/f,v.r=x+(v.x+v.width)/c,v.b=T+(v.y+v.height)/f),v._rect=new bs(v.x,v.y,v.width,v.height)}else v.l=v.x/c,v.t=v.y/f,v.r=(v.x+v.width)/c,v.b=(v.y+v.height)/f,v._rect=new bs(v.x,v.y,v.width,v.height);else i.rotated?(v._rotated=!0,v._name=i.name,v._rect=i.getRect(),v.l=i.unbiasUV[0],v.t=i.unbiasUV[1],v.r=i.unbiasUV[4],v.b=i.unbiasUV[3]):(v._name=i.name,v._rect=i.getRect(),v.l=i.unbiasUV[0],v.t=i.unbiasUV[5],v.r=i.unbiasUV[2],v.b=i.unbiasUV[1]);v.cx=(v.l+v.r)/2,v.cy=(v.t+v.b)/2,e.set(w,v)}}var ONt=new Kr,kNt=new ds,RNt=new ir,FNt=new ir,LNt={row:0,col:0};function VNt(t){return"subNodes"in t}for(var NNt,zNt,UNt,GNt,HNt,WNt,jNt,qNt,XNt,YNt,JNt,KNt,QNt,ZNt,$Nt,tzt,ezt,izt,nzt,rzt,szt,azt,ozt,hzt,uzt,lzt,czt,fzt,_zt,dzt,pzt,mzt,gzt=t("gH",Kh("cc.TiledUserNodeData")(CNt=function(t){function e(){var e;return(e=t.call(this)||this)._index=-1,e._row=-1,e._col=-1,e._tiledLayer=null,e}return s(e,t),e}(yg))||CNt),yzt=t("gI",Kh("cc.TiledLayer")(DNt=function(t){s(i,t);var e=i.prototype;function i(){var e;return(e=t.call(this)||this)._userNodeGrid={},e._userNodeMap={},e._userNodeDirty=!1,e.tiledTiles=[],e._viewPort={x:-1,y:-1,width:-1,height:-1},e._cullingRect={leftDown:{row:-1,col:-1},rightTop:{row:-1,col:-1}},e._cullingDirty=!0,e._rightTop={row:-1,col:-1},e._layerInfo=null,e._mapInfo=null,e._topOffset=0,e._downOffset=0,e._leftOffset=0,e._rightOffset=0,e.tiles=[],e.vertices=[],e._verticesDirty=!0,e._layerName="",e._layerSize=void 0,e._minGID=void 0,e._maxGID=void 0,e._layerOrientation=null,e._opacity=void 0,e._tintColor=void 0,e.texGrids=null,e._textures=[],e._tilesets=[],e._leftDownToCenterX=0,e._leftDownToCenterY=0,e._hasTiledNodeGrid=!1,e._hasAniGrid=!1,e._animations=null,e._enableCulling=void 0,e.colorChanged=!1,e._properties=void 0,e.renderOrder=void 0,e._staggerAxis=void 0,e._staggerIndex=void 0,e._hexSideLength=void 0,e._mapTileSize=void 0,e._odd_even=void 0,e._diffX1=void 0,e._diffY1=void 0,e._useAutomaticVertexZ=void 0,e._vertexZvalue=void 0,e._offset=void 0,e._tiledDataArray=[],e._cameraNode=void 0,e._drawInfoList=[],e._tiledDataArrayIdx=0,e}return e.requestDrawInfo=function(t){return this._drawInfoList[t]||(this._drawInfoList[t]=new QF,this._drawInfoList[t].setDrawInfoType(2)),this._drawInfoList[t]},e.hasTiledNode=function(){return this._hasTiledNodeGrid},e.hasAnimation=function(){return this._hasAniGrid},e.addUserNode=function(t){var e=t.getComponent(gzt);return e?(at(7242),!1):(e=t.addComponent(gzt),t.parent=this.node,this._userNodeMap[t.uuid]=e,e._row=-1,e._col=-1,e._tiledLayer=this,this._nodeLocalPosToLayerPos(t.getPosition(),kNt),this._positionToRowCol(kNt.x,kNt.y,LNt),this._addUserNodeToGrid(e,LNt),this._updateCullingOffsetByUserNode(t),t.on("transform-changed",this._userNodePosChange,e),t.on("size-changed",this._userNodeSizeChange,e),!0)},e.removeUserNode=function(t){var e=t.getComponent(gzt);return e?(t.off("transform-changed",this._userNodePosChange,e),t.off("size-changed",this._userNodeSizeChange,e),this._removeUserNodeFromGrid(e),delete this._userNodeMap[t.uuid],t._removeComponent(e),e.destroy(),t.removeFromParent(),!0):(at(7243),!1)},e.destroyUserNode=function(t){this.removeUserNode(t),t.destroy()},e._nodeLocalPosToLayerPos=function(t,e){e.x=t.x+this._leftDownToCenterX,e.y=t.y+this._leftDownToCenterY},e.getNodesByRowCol=function(t,e){var i=this._userNodeGrid[t];return i?i[e]:null},e.getNodesCountByRow=function(t){var e=this._userNodeGrid[t];return e?e.count:0},e._updateAllUserNode=function(){for(var t in this._userNodeGrid={},this._userNodeMap){var e=this._userNodeMap[t];this._nodeLocalPosToLayerPos(e.node.getPosition(),kNt),this._positionToRowCol(kNt.x,kNt.y,LNt),this._addUserNodeToGrid(e,LNt),this._updateCullingOffsetByUserNode(e.node)}},e._updateCullingOffsetByUserNode=function(t){var e=t._getUITransformComp().contentSize;this._topOffsetthis._rightTop.row&&(t.row=this._rightTop.row),i<0&&(t.col=0),i>this._rightTop.col&&(t.col=this._rightTop.col)},e._addUserNodeToGrid=function(t,e){var i=e.row,n=e.col,r=this._userNodeGrid[i]=this._userNodeGrid[i]||{count:0},s=r[n]=r[n]||{count:0,list:[]};t._row=i,t._col=n,t._index=s.list.length,r.count++,s.count++,s.list.push(t),this._userNodeDirty=!0,this._markForUpdateRenderData()},e.isUserNodeDirty=function(){return this._userNodeDirty},e.setUserNodeDirty=function(t){this._userNodeDirty=t},e._reinstallCamera=function(){var t=YE.root.batcher2D.getFirstRenderCamera(this.node),e=null==t?void 0:t.node;return this._cameraNode!==e&&(this._uninstallCamera(),e&&(e.on("transform-changed",this.updateCulling,this),e.on("size-changed",this.updateCulling,this),this._cameraNode=e)),t},e._uninstallCamera=function(){this._cameraNode&&(this._cameraNode.off("transform-changed",this.updateCulling,this),this._cameraNode.off("size-changed",this.updateCulling,this),delete this._cameraNode)},e.onEnable=function(){t.prototype.onEnable.call(this),this.node.on("anchor-changed",this._syncAnchorPoint,this),this.node.on("transform-changed",this.updateCulling,this),this.node.on("size-changed",this.updateCulling,this),this.node.parent.on("transform-changed",this.updateCulling,this),this.node.parent.on("size-changed",this.updateCulling,this),this._markForUpdateRenderData(),this.scheduleOnce(this.updateCulling.bind(this))},e.onDisable=function(){var e,i;t.prototype.onDisable.call(this),null==(e=this.node.parent)||e.off("size-changed",this.updateCulling,this),null==(i=this.node.parent)||i.off("transform-changed",this.updateCulling,this),this.node.off("size-changed",this.updateCulling,this),this.node.off("transform-changed",this.updateCulling,this),this.node.off("anchor-changed",this._syncAnchorPoint,this),this._uninstallCamera()},e._syncAnchorPoint=function(){var t=this.node,e=t._getUITransformComp(),i=t.getScale();this._leftDownToCenterX=e.width*e.anchorX*i.x,this._leftDownToCenterY=e.height*e.anchorY*i.y,this._cullingDirty=!0,this._markForUpdateRenderData()},e.getLayerName=function(){return this._layerName},e.setLayerName=function(t){this._layerName=t},e.getProperty=function(t){return this._properties[t]},e.getPositionAt=function(t,e){var i;switch(void 0!==e?(i=Math.floor(t),e=Math.floor(e)):(i=Math.floor(t.x),e=Math.floor(t.y)),this._layerOrientation){case 0:return this._positionForOrthoAt(i,e);case 2:return this._positionForIsoAt(i,e);case 1:return this._positionForHexAt(i,e)}return null},e.isInvalidPosition=function(t,e){return t>=this._layerSize.width||e>=this._layerSize.height||t<0||e<0},e._positionForIsoAt=function(t,e){var i=0,n=0,r=Math.floor(t)+Math.floor(e)*this._layerSize.width,s=this.tiles[r];if(s){var a=(268435455&s)>>>0,o=this.texGrids.get(a).tileset.tileOffset;i=o.x,n=o.y}return new ds(.5*this._mapTileSize.width*(this._layerSize.height+t-e-1)+i,.5*this._mapTileSize.height*(this._layerSize.width-t+this._layerSize.height-e-2)-n)},e._positionForOrthoAt=function(t,e){var i=0,n=0,r=Math.floor(t)+Math.floor(e)*this._layerSize.width,s=this.tiles[r];if(s){var a=(268435455&s)>>>0,o=this.texGrids.get(a).tileset.tileOffset;i=o.x,n=o.y}return new ds(t*this._mapTileSize.width+i,(this._layerSize.height-e-1)*this._mapTileSize.height-n)},e._positionForHexAt=function(t,e){var i,n=this._mapTileSize.width,r=this._mapTileSize.height,s=this._layerSize.height,a=Math.floor(t)+Math.floor(e)*this._layerSize.width,o=(268435455&this.tiles[a])>>>0;i=this.texGrids.get(o)?this.texGrids.get(o).tileset.tileOffset:{x:0,y:0};var h=0===this._staggerIndex?1:-1,u=0,l=0,c=0,f=0;switch(this._staggerAxis){case 1:c=0,e%2==1&&(c=n/2*h),u=t*n+c+i.x,l=(s-e-1)*(r-(r-this._hexSideLength)/2)-i.y;break;case 0:f=0,t%2==1&&(f=r/2*-h),u=t*(n-(n-this._hexSideLength)/2)+i.x,l=(s-e-1)*r+f-i.y}return new ds(u,l)},e.setTilesGIDAt=function(t,e,i,n){if(t&&0!==t.length&&!(n<=0)){i<0&&(i=0),e<0&&(e=0);for(var r=0,s=e+n,a=i;;a++)for(var o=e;o=t.length)return;this._updateTileForGID(t[r],o,a),r++}}},e.setTileGIDAt=function(t,e,i,n){var r=(268435455&t)>>>0;if(e=Math.floor(e),i=Math.floor(i),this.isInvalidPosition(e,i))throw new Error("cc.TiledLayer.setTileGIDAt(): invalid position");this.tiles&&this._tilesets&&0!==this._tilesets.length?0!==r&&r>>0,e,i)):it(7238)},e._updateTileForGID=function(t,e,i){var n=0|e+i*this._layerSize.width;if(!(n>=this.tiles.length)&&t!==this.tiles[n]){var r=(268435455&t)>>>0;this.texGrids.get(r)?(this.tiles[n]=t,this._updateVertex(e,i)):this.tiles[n]=0,this._cullingDirty=!0}},e.getTileGIDAt=function(t,e){if(this.isInvalidPosition(t,e))throw new Error("cc.TiledLayer.getTileGIDAt(): invalid position");if(!this.tiles)return it(7237),null;var i=Math.floor(t)+Math.floor(e)*this._layerSize.width;return(268435455&this.tiles[i])>>>0},e.getTileFlagsAt=function(t,e){if(this.isInvalidPosition(t,e))throw new Error("TiledLayer.getTileFlagsAt: invalid position");if(!this.tiles)return it(7240),null;var i=Math.floor(t)+Math.floor(e)*this._layerSize.width;return(4026531840&this.tiles[i])>>>0},e.setCullingDirty=function(t){this._cullingDirty=t},e.isCullingDirty=function(){return this._cullingDirty},e.updateViewPort=function(t,e,i,n){if(this._viewPort.width!==i||this._viewPort.height!==n||this._viewPort.x!==t||this._viewPort.y!==e){this._viewPort.x=t,this._viewPort.y=e,this._viewPort.width=i,this._viewPort.height=n;var r=1;2===this._layerOrientation&&(r=2);var s=this._viewPort.x-this._offset.x+this._leftDownToCenterX,a=this._viewPort.y-this._offset.y+this._leftDownToCenterY,o=s-this._leftOffset,h=a-this._downOffset,u=s+i+this._rightOffset,l=a+n+this._topOffset,c=this._cullingRect.leftDown,f=this._cullingRect.rightTop;o<0&&(o=0),h<0&&(h=0),this._positionToRowCol(o,h,LNt),LNt.row-=r,LNt.col-=r,LNt.row=LNt.row>0?LNt.row:0,LNt.col=LNt.col>0?LNt.col:0,LNt.row===c.row&&LNt.col===c.col||(c.row=LNt.row,c.col=LNt.col,this._cullingDirty=!0),u<0||l<0?(LNt.row=-1,LNt.col=-1):(this._positionToRowCol(u,l,LNt),LNt.row++,LNt.col++),LNt.row===f.row&&LNt.col===f.col||(f.row=LNt.row,f.col=LNt.col,this._cullingDirty=!0),this._cullingDirty&&this._markForUpdateRenderData()}},e._positionToRowCol=function(t,e,i){var n=this._mapTileSize.width,r=this._mapTileSize.height,s=.5*n,a=.5*r,o=0,h=0,u=0,l=0,c=this._staggerAxis;switch(this._layerOrientation){case 0:h=Math.floor(t/n),o=Math.floor(e/r);break;case 2:h=Math.floor(t/s),o=Math.floor(e/a);break;case 1:1===c?(u=(o=Math.floor(e/(r-this._diffY1)))%2==1?s*this._odd_even:0,h=Math.floor((t-u)/n)):(l=(h=Math.floor(t/(n-this._diffX1)))%2==1?a*-this._odd_even:0,o=Math.floor((e-l)/r))}return i.row=o,i.col=h,i},e.updateCulling=function(){if(this._enableCulling){this.node.updateWorldTransform(),Kr.invert(ONt,this.node.getWorldMatrix());var t=this._reinstallCamera();t&&(RNt.x=0,RNt.y=0,RNt.z=0,FNt.x=t.width,FNt.y=t.height,FNt.z=0,t.screenToWorld(RNt,RNt),t.screenToWorld(FNt,FNt),ir.transformMat4(RNt,RNt,ONt),ir.transformMat4(FNt,FNt,ONt),this.updateViewPort(RNt.x,RNt.y,FNt.x-RNt.x,FNt.y-RNt.y))}},e.getLayerOrientation=function(){return this._layerOrientation},e.getProperties=function(){return this._properties},e._updateVertex=function(t,e){var i=this.vertices,n=this._layerOrientation,r=this.tiles;if(r){var s,a,o,h,u=this._rightTop,l=this._mapTileSize.width,c=this._mapTileSize.height,f=.5*l,_=.5*c,d=this._layerSize.height,p=this._layerSize.width,m=this.texGrids,g=0,y=0;1===n&&(s=this._staggerAxis,a=this._diffX1,o=this._diffY1,h=this._odd_even);var v,b,S,w=0,x=0,T=0,A=0,C=e*p+t;v=(268435455&r[C])>>>0;var D=m.get(v);if(D){switch(this._animations.get(v)&&(this._hasAniGrid=this._hasAniGrid||!0),n){case 0:g=(w=t)*l,y=(x=d-e-1)*c;break;case 2:g=f*(w=d+t-e-1),y=_*(x=d+p-t-e-2);break;case 1:g=t*(l-a)+(1===s&&e%2==1?f*h:0),y=(d-e-1)*(c-o)+(0===s&&t%2==1?_*-h:0),w=t,x=d-e-1}var B=i[x]=i[x]||{minCol:0,maxCol:0},I=B[w]=B[w]||{left:0,bottom:0,index:0};B.minCol>w&&(B.minCol=w),B.maxCol=0&&this._textures.length>t?this._textures[t]:null},e.getTextures=function(){return this._textures},e.setTexture=function(t){this.setTextures([t])},e.setTextures=function(t){this._textures=t,this._markForUpdateRenderData()},e.getLayerSize=function(){return this._layerSize},e.getMapTileSize=function(){return this._mapTileSize},e.getTileSet=function(t){return t=t||0,this._tilesets&&t>=0&&this._tilesets.length>t?this._tilesets[t]:null},e.getTileSets=function(){return this._tilesets},e.setTileSet=function(t){this.setTileSets([t])},e.setTileSets=function(t){this._tilesets=t;var e=this._textures=[],i=this.texGrids;i.clear();for(var n=0;n0&&t[t.length-1].subNodes&&0===t[t.length-1].subNodes.length;)t.pop();if(t.length>0){var e=t[t.length-1];if(e.renderData&&0===e.renderData.vertexCount)return e}var i={renderData:null,texture:null};return this._tiledDataArray.push(i),i},e.requestSubNodesData=function(){var t=this._tiledDataArray;if(t.length>0){var e=t[t.length-1];if(VNt(e)&&0===e.subNodes.length)return e}var i={subNodes:[]};return this._tiledDataArray.push(i),i},e.destroyRenderData=function(){this._tiledDataArray.forEach((function(t){var e=t.renderData;e&&tL.remove(e)})),this._tiledDataArray.length=0,t.prototype.destroyRenderData.call(this)},e._flushAssembler=function(){var t=i.Assembler.getAssembler(this);this._assembler!==t&&(this._assembler=t,this._assembler.createData(this)),0===this._tiledDataArray.length&&(this._markForUpdateRenderData(),this._updateColor())},e._render=function(t){for(var e=0;e>>0,I=i.get(B);if(!I)continue;var M=I.tileset,P="img"+g.id;d[P]=!0;var E=this.node.getChildByName(P);g.width=g.width||I.width,g.height=g.height||I.height,E&&1024&E._objFlags&&(E.removeFromParent(),E.hideFlags|=8,E.destroy(),E=null),E||(E=new eb),this._animations.get(B)&&(this.aniObjects.push({object:g,imgNode:E,gridGID:B}),this._hasAniObj=!0);var O=M.tileOffset.x,k=M.tileOffset.y;E.active=g.visible,E.setRotationFromEuler(0,0,-g.rotation),E.setPosition(g.x-c,g.y-f),E.name=P,E.parent=this.node,E.setSiblingIndex(p),E.layer=this.node.layer;var R=E.getComponent(GV);R||(R=E.addComponent(GV));var F=E._getUITransformComp();h?(F.anchorX=.5+O/g.width,F.anchorY=k/g.height):(F.anchorX=O/g.width,F.anchorY=k/g.height),this._tintColor?(o.set(this._tintColor),o.a*=this._opacity/255,R.color.set(o)):R.color.a*=this._opacity/255,R.sizeMode=0;var L=this._premultiplyAlpha?1:2;R.srcBlendFactor!==L&&(R.srcBlendFactor=L,R.material&&R._updateBlendFunc());var V=I.spriteFrame;V=V?V.clone():new nR,(2147483648&D)>>>0&&(V.flipUVX=!V.flipUVX),(1073741824&D)>>>0&&(V.flipUVY=!V.flipUVY),V.rotated=I._rotated,V.rect=I._rect,R.spriteFrame=V,F.setContentSize(g.width,g.height),R._markForUpdateRenderData()}}this._objects=_;for(var N=this.node.children,z=/^(?:img|text)\d+$/,U=0,G=N.length;U0&&(m[d[g]]=p[g].text);var y=new BNt(i.tmxXmlStr,m,a,o,c),v=y.getTilesets();v&&0!==v.length||it(7241),this._buildWithMapInfo(y)}else this._releaseMapInfo()},i._releaseMapInfo=function(){for(var t=this._layers,e=0,i=t.length;e0)for(var w=0,x=y.length;w=o.length&&(a.frameIdx=0),h=o[a.frameIdx]),n.set(s,h.grid)}for(var u=this.getLayers(),l=0,c=u.length;l>>0&&(i=Pzt,Pzt=Ezt,Ezt=i),(2147483648&e)>>>0&&(i=Mzt,Mzt=Ezt,Ezt=i,i=Pzt,Pzt=Ozt,Ozt=i),(1073741824&e)>>>0&&(i=Mzt,Mzt=Pzt,Pzt=i,i=Ezt,Ezt=Ozt,Ozt=i)}function Hzt(){if(!(Lzt<1)&&Vzt){var t=4*Lzt,e=6*Lzt,i=Azt.requestTiledRenderData();i.renderData=tL.add(IF),i.texture=Vzt;var n=i.renderData;n.resize(t,e),n.chunk.vb.set(Tzt.subarray(0,9*t),0),Lzt=0,Vzt=null}}function Wzt(t,e,i,n,r){if(!(e.row<0||e.col<0)){Azt=r;var s=r.node.worldMatrix;kzt=0;var a,o,h,u,l,c,f,_,d,p=r.tiledTiles,m=r.texGrids,g=r.tiles,y=18,v=27,b=r.vertices,S=0,w=0,x=0,T=0,A=0,C=0,D=!0;Czt=Gzt;var B=new Float32Array(4);B[0]=r.color.r/255,B[1]=r.color.g/255,B[2]=r.color.b/255,B[3]=r.color.a/255,-1===i?(u=e.row,l=t.row):(u=t.row,l=e.row);var I=Math.abs(t.row-e.row)+1,M=Math.abs(e.col-t.col)+1;Tzt=new Float32Array(I*M*36),Lzt=0;for(var P=Tzt;(l-u)*i>=0;u+=i)for(a=b[u],C=r.getNodesCountByRow(u),D=a&&0===C,1===n?(o=D&&t.cola.maxCol?a.maxCol:e.col):(o=D&&e.col>a.maxCol?a.maxCol:e.col,h=D&&t.col=0;o+=n){if(c=a&&a[o],C>0){Hzt();var E=r.requestSubNodesData(),O=r.getNodesByRowCol(u,o);O&&O.count>0&&(E.subNodes=O.list)}c&&(S=g[c.index],(_=m.get((268435455&S)>>>0))&&(Vzt!==_.texture&&(Hzt(),Vzt=_.texture),f=_.tileset._tileSize,w=c.left-Rzt,x=c.bottom-Fzt,T=w+f.width,A=x+f.height,d=p[c.index],kzt=36*Lzt,d?d.node.active&&jzt(d.node,B,P,w,T,A,x):(wzt[0].x=w,wzt[0].y=A,wzt[1].x=w,wzt[1].y=x,wzt[2].x=T,wzt[2].y=A,wzt[3].x=T,wzt[3].y=x,wzt[0].transformMat4(s),P[kzt]=wzt[0].x,P[kzt+1]=wzt[0].y,P[kzt+2]=wzt[0].z,wzt[1].transformMat4(s),P[kzt+9]=wzt[1].x,P[kzt+9+1]=wzt[1].y,P[kzt+9+2]=wzt[1].z,wzt[2].transformMat4(s),P[kzt+y]=wzt[2].x,P[kzt+y+1]=wzt[2].y,P[kzt+y+2]=wzt[2].z,wzt[3].transformMat4(s),P[kzt+v]=wzt[3].x,P[kzt+v+1]=wzt[3].y,P[kzt+v+2]=wzt[3].z,P.set(B,kzt+5),P.set(B,kzt+9+5),P.set(B,kzt+y+5),P.set(B,kzt+v+5)),Czt(_,S),P[kzt+3]=Mzt.x,P[kzt+4]=Mzt.y,P[kzt+9+3]=Pzt.x,P[kzt+9+4]=Pzt.y,P[kzt+y+3]=Ezt.x,P[kzt+y+4]=Ezt.y,P[kzt+v+3]=Ozt.x,P[kzt+v+4]=Ozt.y,++Lzt>=Szt&&Hzt()))}Hzt()}}function jzt(t,e,i,n,r,s,a){t.updateWorldTransform(),Kr.fromRTS(Dzt,t.rotation,t.position,t.scale),ir.set(Bzt,-(n+Rzt),-(a+Fzt),0),Kr.transform(Dzt,Dzt,Bzt),Kr.multiply(Dzt,t.parent.worldMatrix,Dzt);var o=Dzt,h=o.m12,u=o.m13,l=o.m00,c=o.m01,f=o.m04,_=o.m05;1===l&&0===c&&0===f&&1===_?(i[kzt]=n+h,i[kzt+1]=s+u,i[kzt+9]=n+h,i[kzt+9+1]=a+u,i[kzt+18]=r+h,i[kzt+18+1]=s+u,i[kzt+27]=r+h,i[kzt+27+1]=a+u):(i[kzt]=n*l+s*f+h,i[kzt+1]=n*c+s*_+u,i[kzt+9]=n*l+a*f+h,i[kzt+9+1]=n*c+a*_+u,i[kzt+18]=r*l+s*f+h,i[kzt+18+1]=r*c+s*_+u,i[kzt+27]=r*l+a*f+h,i[kzt+27+1]=r*c+a*_+u),i.set(e,kzt+5),i.set(e,kzt+9+5),i.set(e,kzt+18+5),i.set(e,kzt+27+5)}var qzt=t("gL",{getAssembler:function(){return Uzt}});yzt.Assembler=qzt;var Xzt=new ir,Yzt=new ir;function Jzt(t,e){var i=null;return{value:e.length>0?e[e.length-1]:ir.ZERO,progress:function(t,e,n,r){return i.getPoint(r)},clone:function(t){return ir.clone(t)},add:function(t,e){return t.clone().add(e)},sub:function(t,e){return t.clone().subtract(e)},onStart:function(n){var r=n.start,s=n.end,a=n.relative,o=n.reversed;(i=Tf.create(t)).addKnot(r);var h=null;a&&o&&(h=Yzt,ir.subtract(h,r,e[e.length-1]));for(var u=0,l=e.length;u0&&i.addKnot(ir.copy(Xzt,h).add(c)):i.addKnot(ir.copy(Xzt,r).add(c)):i.addKnot(c)}a&&o&&i.addKnot(s)},onComplete:function(){i=null},onStop:function(){i=null},legacyProgress:!1}}var Kzt=Object.freeze({__proto__:null,bezier:function(){for(var t=arguments.length,e=new Array(t),i=0;i=n&&i.actionIndex--;break}}},e._removeActionByTag=function(t,e,i){for(var n=0,r=e.actions.length;n=0;--n){var r=e.actions[n];if(r&&r.getTag()===t){if(i&&r.getOriginalTarget()!==i)continue;this._removeActionAtIndex(n,e)}}},e.removeActionByTag=function(t,e){var i=this;-1===t&&it(1002);var n=this._hashTargets;if(e){var r=n.get(e);r&&this._removeActionByTag(t,r,e)}else n.forEach((function(e){i._removeActionByTag(t,e)}))},e.removeAllActionsByTag=function(t,e){var i=this;-1===t&&it(1002);var n=this._hashTargets;if(e){var r=n.get(e);r&&this._removeAllActionsByTag(t,r,e)}else n.forEach((function(e){i._removeAllActionsByTag(t,e)}))},e.getActionByTag=function(t,e){-1===t&&it(1004);var i=this._hashTargets.get(e);if(i){if(null!=i.actions)for(var n=0;n=t&&e.actionIndex--,0===e.actions.length&&(e.target instanceof eb&&this._unregisterNodeEvent(e.target),this._deleteHashElement(e))},e._deleteHashElement=function(t){var e=!1;if(t&&!t.lock&&this._hashTargets.get(t.target)){this._hashTargets.delete(t.target);for(var i=this._arrayTargets,n=0,r=i.length;n"},e}(eUt),nUt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.update=function(){var t=this._getWorkerTarget();if(t)for(var e=t.getComponentsInChildren(CL),i=0;i"},e}(eUt);!function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;i.update=function(){var t=this._getWorkerTarget();if(t)for(var e=t.getComponentsInChildren(CL),i=0;i"}}(eUt);var rUt=function(t){function e(e){var i;return(i=t.call(this)||this)._isNeedCleanUp=!0,void 0!==e&&i.init(e),i}s(e,t);var i=e.prototype;return i.update=function(){var t=this._getWorkerTarget();t&&(t.removeFromParent(),this._isNeedCleanUp&&t.destroy())},i.init=function(t){return this._isNeedCleanUp=t,!0},i.reverse=function(){return new e(this._isNeedCleanUp)},i.clone=function(){var t=new e(this._isNeedCleanUp);return t._id=this._id,t},i.toString=function(){return""},e}(eUt);function sUt(t){return new rUt(t)}var aUt=function(t){function e(e,i,n){var r;return(r=t.call(this)||this)._callbackThis=void 0,r._callback=void 0,r._data=void 0,r.initWithFunction(e,i,n),r}s(e,t);var i=e.prototype;return i.initWithFunction=function(t,e,i){return t&&(this._callback=t),e&&(this._callbackThis=e),void 0!==i&&(this._data=i),!0},i.execute=function(){if(this._callback){var t=this._getWorkerTarget();this._callback.call(this._callbackThis,t,this._data)}},i.update=function(){this.execute()},i.getTargetCallback=function(){return this._callbackThis},i.setTargetCallback=function(t){t!==this._callbackThis&&(this._callbackThis=t)},i.clone=function(){var t=new e;return t._id=this._id,this._callback&&t.initWithFunction(this._callback,this._callbackThis,this._data),t},i.toString=function(){return""},e}(eUt);function oUt(t,e,i){return new aUt(t,e,i)}var hUt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.clone=function(){return new e},i.reverse=function(){return this.clone()},i.update=function(){},i.step=function(){},i.isUnknownDuration=function(){return!1},i.toString=function(){return"DummyAction"},e}(tUt),uUt=function(t){function e(e){var i;return(i=t.call(this)||this).MAX_VALUE=2,i._elapsed=0,i._startTime=0,i._firstTick=!1,i._speed=1,void 0===e||Number.isNaN(e)||i.initWithDuration(e),i}s(e,t);var i=e.prototype;return i.setStartTime=function(t){t=t<0?0:t>this._duration?this._duration:t,this._startTime=t},i.getElapsed=function(){return this._elapsed},i.initWithDuration=function(t){return this._duration=0===t?Ue.FLT_EPSILON:t,this._elapsed=0,this._firstTick=!0,!0},i.isDone=function(){return this._elapsed>=this._duration&&!this.isUnknownDuration()},i._cloneDecoration=function(t){t._speed=this._speed},i.step=function(t){if(!this._paused&&0!==this._speed){t*=this._speed,this._firstTick?this._elapsed=this._startTime:this._elapsed+=t;var e=this._elapsed/(this._duration>1.192092896e-7?this._duration:1.192092896e-7);e=e<1?e:1,this.update(e>0?e:0),this.isUnknownDuration()&&!this._firstTick&&(e<1?this._elapsed-=t:this._elapsed=this._startTime+this._duration),this._firstTick&&(this._firstTick=!1,this._startTime>0&&(this._startTime=0))}},i.startWithTarget=function(e){t.prototype.startWithTarget.call(this,e),this._elapsed=0,this._firstTick=!0},i.getSpeed=function(){return this._speed},i.setSpeed=function(t){this._speed=t},i.getDurationScaled=function(){return this._duration/this._speed},e}(tUt);function lUt(t,e){var i=new cUt;return i.initWithTwoActions(t,e),i}var cUt=function(t){function e(e){var i;if((i=t.call(this)||this)._actions=[],i._split=0,i._last=0,i._reversed=!1,!e||0===e.length)return f(i);1===e.length&&e.push(new hUt);var n=e.length-1;if(n>=0&&null==e[n]&&it(1015),n>=0){for(var r=e[0],s=1;s1?i%1:i),this._last=n)}},i.reverse=function(){var t=lUt(this._actions[1].reverse(),this._actions[0].reverse());return this._cloneDecoration(t),t._reversed=!0,t},i.updateOwner=function(t){if(!(this._actions.length<2)){var i=this._actions[0],n=this._actions[1];n._owner||(n._owner=t),i instanceof e||i instanceof yUt?i.updateOwner(t):i._owner||(i._owner=t)}},i.findAction=function(t){for(var i=0,n=this._actions.length;i"},e}(uUt);function fUt(t){return new cUt(t)}var _Ut=function(t){function e(e,i){var n;return(n=t.call(this)||this)._times=0,n._total=0,n._nextDt=0,n._actionInstant=!1,n._innerAction=null,n.initWithAction(e,i),n}s(e,t);var i=e.prototype;return i.initWithAction=function(t,e){if(!t||void 0===e)return!1;var i=t.getDurationScaled()*e;return!!this.initWithDuration(i)&&(this._times=e,this._innerAction=t,t instanceof eUt&&(this._actionInstant=!0,this._times-=1),this._total=0,!0)},i.clone=function(){var t=new e;return t._id=this._id,t._speed=this._speed,this._cloneDecoration(t),this._innerAction&&t.initWithAction(this._innerAction.clone(),this._times),t},i.startWithTarget=function(e){this._total=0,this._nextDt=(this._innerAction?this._innerAction.getDurationScaled():0)/this._duration,t.prototype.startWithTarget.call(this,e),this._innerAction&&this._innerAction.startWithTarget(e)},i.stop=function(){this._innerAction&&this._innerAction.stop(),t.prototype.stop.call(this)},i.update=function(t){var e=this._innerAction,i=this._duration,n=this._times,r=this._nextDt;if(e)if(t>=r){for(;t>r&&this._total1?1:r}if(t>=1&&this._total"},e}(uUt);function dUt(t,e){return new _Ut(t,e)}var pUt=function(t){function e(e){var i;return(i=t.call(this)||this)._innerAction=null,e&&i.initWithAction(e),i}s(e,t);var i=e.prototype;return i.initWithAction=function(t){return t?(this._innerAction=t,this._duration=1/0,!0):(ht(1026),!1)},i.clone=function(){var t=new e;return t._id=this._id,t._speed=this._speed,this._cloneDecoration(t),this._innerAction&&t.initWithAction(this._innerAction.clone()),t},i.startWithTarget=function(e){t.prototype.startWithTarget.call(this,e),this._innerAction&&this._innerAction.startWithTarget(e)},i.stop=function(){this._innerAction&&this._innerAction.stop(),t.prototype.stop.call(this)},i.step=function(t){if(!this._paused&&0!==this._speed){var e=this._innerAction;e&&(t*=this._speed,e.step(t),e.isDone()&&(e.startWithTarget(this.target),e.step(e.getElapsed()-e.getDurationScaled())))}},i.update=function(){it(1007)},i.isDone=function(){return!1},i.reverse=function(){if(this._innerAction){var t=new e(this._innerAction.reverse());return this._cloneDecoration(t),t}return this},i.setInnerAction=function(t){this._innerAction!==t&&(this._innerAction=t)},i.getInnerAction=function(){return this._innerAction},i.isUnknownDuration=function(){return!!this._innerAction&&this._innerAction.isUnknownDuration()},i.toString=function(){return""},e}(uUt);function mUt(t){return new pUt(t)}function gUt(t,e){var i=new yUt;return i.initWithTwoActions(t,e),i}var yUt=function(t){function e(e){var i;if((i=t.call(this)||this)._one=null,i._two=null,i._finished=!1,!e||0===e.length)return f(i);1===e.length&&e.push(new hUt);var n=e.length-1;if(n>=0&&null==e[n]&&it(1015),n>=0){for(var r=e[0],s=1;sr?this._two=lUt(e,bUt(n-r)):n"},e}(uUt),vUt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.update=function(){},i.reverse=function(){var t=new e(this._duration);return this._cloneDecoration(t),t},i.clone=function(){var t=new e;return t._id=this._id,t._speed=this._speed,this._cloneDecoration(t),t.initWithDuration(this._duration),t},i.isUnknownDuration=function(){return!1},i.toString=function(){return""},e}(uUt);function bUt(t){return new vUt(t)}var SUt=function(t){function e(e){var i;return(i=t.call(this)||this)._other=null,e&&i.initWithAction(e),i}s(e,t);var i=e.prototype;return i.initWithAction=function(e){return e?e===this._other?(ht(1029),!1):!!t.prototype.initWithDuration.call(this,e.getDurationScaled())&&(this._other=e,!0):(ht(1028),!1)},i.clone=function(){var t=new e;return t._id=this._id,t._speed=this._speed,this._cloneDecoration(t),this._other&&t.initWithAction(this._other.clone()),t},i.startWithTarget=function(e){t.prototype.startWithTarget.call(this,e),this._other&&this._other.startWithTarget(e)},i.update=function(t){this._other&&this._other.update(1-t)},i.reverse=function(){return this._other?this._other.clone():this},i.stop=function(){this._other&&this._other.stop(),t.prototype.stop.call(this)},i.isUnknownDuration=function(){return!1},i.toString=function(){return""},e}(uUt);function wUt(t){return new SUt(t)}var xUt=function(t){function e(e,i,n){var r;return(r=t.call(this,e)||this)._cb=i,r._args=n,r}s(e,t);var i=e.prototype;return i.clone=function(){return new e(this._duration,this._cb,this._args)},i.update=function(t){this._cb.apply(this,[this.target,t].concat(this._args))},i.reverse=function(){return this.clone()},i.isUnknownDuration=function(){return!1},i.toString=function(){return""},e}(uUt),TUt=function(t){function e(e,i){var n;return(n=t.call(this)||this)._finished=!1,n._cb=e,n._args=i,n}s(e,t);var i=e.prototype;return i.clone=function(){return new e(this._cb,this._args)},i.reverse=function(){return this.clone()},i.step=function(){throw new Error("should never go here")},i.update=function(){var t=A.game.deltaTime;this._finished=this._cb.apply(this,[this.target,t].concat(this._args))},i.isDone=function(){return this._finished},i.isUnknownDuration=function(){return!this.isDone()},i.toString=function(){return""},e}(tUt);function AUt(t){var e=t.charAt(0);if(/[A-Z]/.test(e)){var i=(t=t.replace(e,e.toLowerCase())).split("-");if(2===i.length){var n=i[0];if("linear"===n)t="linear";else{var r=i[1];switch(n){case"quadratic":t="quad"+r;break;case"quartic":t="quart"+r;break;case"quintic":t="quint"+r;break;case"sinusoidal":t="sine"+r;break;case"exponential":t="expo"+r;break;case"circular":t="circ"+r;break;default:t=n+r}}}}return t}function CUt(t){var e=" [Tween:] ",i=" option is not support in v + "+D,n=t;n.delay&&Y(e+"delay"+i),n.repeat&&Y(e+"repeat"+i),n.repeatDelay&&Y(e+"repeatDelay"+i),n.interpolation&&Y(e+"interpolation"+i),n.onStop&&Y(e+"onStop"+i)}var DUt=t("gO",function(t){function e(e,i,n){var r;if((r=t.call(this)||this)._reversed=!1,null==n)n=Object.create(null);else if(CUt(n),n.easing&&"string"==typeof n.easing&&(n.easing=AUt(n.easing)),n.progress||(n.progress=r.progress),n.easing&&"string"==typeof n.easing){var s=n.easing;n.easing=Hl[s],n.easing||at(1031,s)}for(var a in r._opts=n,r._props=Object.create(null),i){var o;if(i.hasOwnProperty(a)){var h=i[a];if("function"==typeof h)h=h();else if(null==h)continue;var u=void 0,l=void 0,c=void 0;void 0!==h.value?("function"==typeof(c=h.value)&&(c=c()),void 0!==h.easing&&("string"==typeof h.easing?(u=Hl[h.easing])||at(1031,h.easing):u=h.easing),void 0!==h.progress&&(l=h.progress)):c=h;var f=Object.create(null);f.start=f.current=f.end=null,f.keys=null,f.value=c,f.easing=u,f.progress=l,f.convert=h.convert,f.clone=h.clone,f.add=h.add,f.sub=h.sub,f.legacyProgress=null===(o=h.legacyProgress)||void 0===o||o,f.toFixed=h.toFixed,f.onStart=h.onStart,f.onStop=h.onStop,f.onComplete=h.onComplete,f.valid=!0,r._props[a]=f}}return r._originProps=i,r.initWithDuration(e),r}s(e,t);var i=e.prototype;return i.clone=function(){var t=new e(this._duration,this._originProps,this._opts);return t._reversed=this._reversed,t._owner=this._owner,t._id=this._id,this._cloneDecoration(t),t},i.reverse=function(){if(!this._opts.relative)return at(16382),new e(0,{});var t=new e(this._duration,this._originProps,this._opts);return this._cloneDecoration(t),t._reversed=!this._reversed,t._owner=this._owner,t},i.startWithTarget=function(e){t.prototype.startWithTarget.call(this,e);var i=this._getWorkerTarget();if(i){var n=!!this._opts.relative,r=this._props,s=this._reversed,a=function(){var t=i[o];if(void 0===t)return 0;var e=r[o],a=e.value;if("number"==typeof t)e.start=t,e.current=t,e.end=n?s?t-a:t+a:a;else if("object"==typeof t)if(e.legacyProgress){if(null==e.start){var h=t.constructor;e.start=new h,e.current=new h,e.end=new h}var u;u=a.getModifiableProperties?a.getModifiableProperties():Object.keys(a),e.keys=u;for(var l=0,c=u.length;l0&&this._actions[this._actions.length-1].setId(t),this})),e.then=function(t){var e=t._union(!0);return e&&(e.setSpeed(t._timeScale),this._actions.push(e)),this},e.reverse=function(e,i){if(null==e&&null==i)return this.reverseTween();var n,r;if(e instanceof t?(n=e,void 0!==i&&(r=i)):"number"==typeof e&&(n=this,r=e),n){var s=t.reverseAction(n,r);s&&this._actions.push(s)}return this},e.reverseTween=function(){if(0===this._actions.length)return at(16388),this.clone(this._target);var t=this._union(!1),e=rGt(this._target);return e._timeScale=this._timeScale,t&&e.insertAction(t.reverse()),e},t.reverseAction=function(t,e){var i=t._actions;if(0===i.length)return null;var n=null,r=null;return"number"==typeof e?n=t.findAction(e,i):t&&(n=t._union(!1)),n?(r=n.reverse())._owner=t:at(16391,""+e),r},e.findAction=function(t,e){for(var i=null,n=0,r=e.length;n1){var s=n.splice(r);1===s.length?n.push(s[0]):n.push(fUt(s))}return this},e.to=function(t,e,i){var n=i||Object.create(null);n.relative=!1;var r=new DUt(t,e,n);return this._actions.push(r),this},e.by=function(t,e,i){var n=i||Object.create(null);n.relative=!0;var r=new DUt(t,e,n);return this._actions.push(r),this},e.update=function(t,e){for(var i=arguments.length,n=new Array(i>2?i-2:0),r=2;r1?e-1:0),n=1;n0&&(i=this._time/this._duration),i>=1&&(i=1),1===this._transition){var n=e._uiProps.uiComp;cr.lerp(aGt,this._fromColor,this._toColor,i),n&&(n.color=aGt)}else 3===this.transition&&(e.getScale(this._targetScale),this._targetScale.x=en(this._fromScale.x,this._toScale.x,i),this._targetScale.y=en(this._fromScale.y,this._toScale.y,i),e.setScale(this._targetScale));1===i&&(this._transitionFinished=!0)}},i._resizeNodeToTargetNode=function(){this.target&&this.target._getUITransformComp()},i._resetState=function(){this._pressed=!1,this._hovered=!1;var t=this.target;if(t){var e=this._transition;if(1===e&&this._interactable){var i=t.getComponent(BL);i&&(i.color=this._normalColor)}else 3===e&&this._originalScale&&t.setScale(this._originalScale);this._transitionFinished=!0}},i._registerNodeEvent=function(){var t=this,e=t.node;e.on("touch-start",t._onTouchBegan,t),e.on("touch-move",t._onTouchMove,t),e.on("touch-end",t._onTouchEnded,t),e.on("touch-cancel",t._onTouchCancel,t),e.on("mouse-enter",t._onMouseMoveIn,t),e.on("mouse-leave",t._onMouseMoveOut,t)},i._registerTargetEvent=function(t){t.on("transform-changed",this._onTargetTransformChanged,this)},i._unregisterNodeEvent=function(){var t=this,e=t.node;e.off("touch-start",t._onTouchBegan,t),e.off("touch-move",t._onTouchMove,t),e.off("touch-end",t._onTouchEnded,t),e.off("touch-cancel",t._onTouchCancel,t),e.off("mouse-enter",t._onMouseMoveIn,t),e.off("mouse-leave",t._onMouseMoveOut,t)},i._unregisterTargetEvent=function(t){t.off("transform-changed")},i._getTargetSprite=function(t){var e=null;return t&&(e=t.getComponent(GV)),e},i._applyTarget=function(){this.target&&(this._sprite=this._getTargetSprite(this.target),this._originalScale||(this._originalScale=new ir),ir.copy(this._originalScale,this.target.scale),this._registerTargetEvent(this.target))},i._onTargetSpriteFrameChanged=function(t){2===this._transition&&this._setCurrentStateSpriteFrame(t.spriteFrame)},i._setCurrentStateSpriteFrame=function(t){if(t)switch(this._getButtonState()){case 0:this._normalSprite=t;break;case 1:this._hoverSprite=t;break;case 2:this._pressedSprite=t;break;case 3:this._disabledSprite=t}},i._onTargetColorChanged=function(t){1===this._transition&&this._setCurrentStateColor(t)},i._setCurrentStateColor=function(t){switch(this._getButtonState()){case 0:this._normalColor=t;break;case 1:this._hoverColor=t;break;case 2:this._pressedColor=t;break;case 3:this._disabledColor=t}},i._onTargetTransformChanged=function(t){4&t&&this._originalScale&&3===this._transition&&this._transitionFinished&&ir.copy(this._originalScale,this.target.scale)},i._onTouchBegan=function(t){this._interactable&&this.enabledInHierarchy&&(this._pressed=!0,this._updateState(),t&&(t.propagationStopped=!0))},i._onTouchMove=function(t){if(this._interactable&&this.enabledInHierarchy&&this._pressed&&t){var e=t.touch;if(e){var i,n=this.node._getUITransformComp().hitTest(e.getLocation(),t.windowId);3===this._transition&&this.target&&this._originalScale?n?(ir.copy(this._fromScale,this._originalScale),ir.multiplyScalar(this._toScale,this._originalScale,this._zoomScale),this._transitionFinished=!1):(this._time=0,this._transitionFinished=!0,this.target.setScale(this._originalScale)):(i=n?2:0,this._applyTransition(i)),t&&(t.propagationStopped=!0)}}},i._onTouchEnded=function(t){this._interactable&&this.enabledInHierarchy&&(this._pressed&&(mg.emitEvents(this.clickEvents,t),this.node.emit("click",this)),this._pressed=!1,this._updateState(),t&&(t.propagationStopped=!0))},i._onTouchCancel=function(){this._interactable&&this.enabledInHierarchy&&(this._pressed=!1,this._updateState())},i._onMouseMoveIn=function(){!this._pressed&&this.interactable&&this.enabledInHierarchy&&(2!==this._transition||this._hoverSprite)&&(this._hovered||(this._hovered=!0,this._updateState()))},i._onMouseMoveOut=function(){this._hovered&&(this._hovered=!1,this._updateState())},i._updateState=function(){var t=this._getButtonState();this._applyTransition(t)},i._getButtonState=function(){var t=0;return this._interactable?this._pressed?t=2:this._hovered&&(t=1):t=3,t},i._updateColorTransition=function(t){var e,i=this._getColorByState(t),n=null==(e=this.target)?void 0:e.getComponent(BL);n&&(3===t?(n.color=i,this._transitionFinished=!0):(this._fromColor=n.color.clone(),this._toColor=i,this._time=0,this._transitionFinished=!1))},i._updateSpriteTransition=function(t){var e=this._getSpriteFrameByState(t);this._sprite&&e&&(this._sprite.spriteFrame=e)},i._updateScaleTransition=function(t){this._interactable&&(2===t?this._zoomUp():this._zoomBack())},i._zoomUp=function(){this._originalScale&&(ir.copy(this._fromScale,this._originalScale),ir.multiplyScalar(this._toScale,this._originalScale,this._zoomScale),this._time=0,this._transitionFinished=!1)},i._zoomBack=function(){this.target&&this._originalScale&&(ir.copy(this._fromScale,this.target.scale),ir.copy(this._toScale,this._originalScale),this._time=0,this._transitionFinished=!1)},i._applyTransition=function(t){var e=this._transition;1===e?this._updateColorTransition(t):2===e?this._updateSpriteTransition(t):3===e&&this._updateScaleTransition(t)},i._getSpriteFrameByState=function(t){switch(t){case 0:return this._normalSprite;case 3:return this._disabledSprite;case 1:return this.hoverSprite;case 2:return this._pressedSprite;default:return null}},i._getColorByState=function(t){switch(t){case 0:return this._normalColor;case 3:return this._disabledColor;case 1:return this._hoverColor;case 2:return this._pressedColor;default:return new cr}},i._xrHoverEnter=function(){},i._xrHoverExit=function(){},i._xrClick=function(){},i._xrUnClick=function(){},n(e,[{key:"target",get:function(){return this._target||this.node},set:function(t){this._target!==t&&(this._target&&this._unregisterTargetEvent(this._target),this._target=t,this._applyTarget())}},{key:"interactable",get:function(){return this._interactable},set:function(t){this._interactable!==t&&(this._interactable=t,this._updateState(),this._interactable||this._resetState())}},{key:"_resizeToTarget",set:function(t){t&&this._resizeNodeToTargetNode()}},{key:"transition",get:function(){return this._transition},set:function(t){this._transition!==t&&(1===this._transition?this._updateColorTransition(0):2===this._transition&&this._updateSpriteTransition(0),this._transition=t,this._updateState())}},{key:"normalColor",get:function(){return this._normalColor},set:function(t){this._normalColor!==t&&(this._normalColor.set(t),this._updateState())}},{key:"pressedColor",get:function(){return this._pressedColor},set:function(t){this._pressedColor!==t&&this._pressedColor.set(t)}},{key:"hoverColor",get:function(){return this._hoverColor},set:function(t){this._hoverColor!==t&&this._hoverColor.set(t)}},{key:"disabledColor",get:function(){return this._disabledColor},set:function(t){this._disabledColor!==t&&(this._disabledColor.set(t),this._updateState())}},{key:"duration",get:function(){return this._duration},set:function(t){this._duration!==t&&(this._duration=t)}},{key:"zoomScale",get:function(){return this._zoomScale},set:function(t){this._zoomScale!==t&&(this._zoomScale=t)}},{key:"normalSprite",get:function(){return this._normalSprite},set:function(t){if(this._normalSprite!==t){this._normalSprite=t;var e=this.node.getComponent(GV);e&&(e.spriteFrame=t),this._updateState()}}},{key:"pressedSprite",get:function(){return this._pressedSprite},set:function(t){this._pressedSprite!==t&&(this._pressedSprite=t,this._updateState())}},{key:"hoverSprite",get:function(){return this._hoverSprite},set:function(t){this._hoverSprite!==t&&(this._hoverSprite=t,this._updateState())}},{key:"disabledSprite",get:function(){return this._disabledSprite},set:function(t){this._disabledSprite!==t&&(this._disabledSprite=t,this._updateState())}}]),e}(yg),iGt.Transition=oGt,iGt.EventType=hGt,v((UUt=iGt).prototype,"target",[OUt],Object.getOwnPropertyDescriptor(UUt.prototype,"target"),UUt.prototype),v(UUt.prototype,"transition",[kUt],Object.getOwnPropertyDescriptor(UUt.prototype,"transition"),UUt.prototype),v(UUt.prototype,"normalSprite",[RUt],Object.getOwnPropertyDescriptor(UUt.prototype,"normalSprite"),UUt.prototype),v(UUt.prototype,"pressedSprite",[FUt],Object.getOwnPropertyDescriptor(UUt.prototype,"pressedSprite"),UUt.prototype),v(UUt.prototype,"hoverSprite",[LUt],Object.getOwnPropertyDescriptor(UUt.prototype,"hoverSprite"),UUt.prototype),v(UUt.prototype,"disabledSprite",[VUt],Object.getOwnPropertyDescriptor(UUt.prototype,"disabledSprite"),UUt.prototype),GUt=zh(UUt.prototype,"clickEvents",[NUt,uu],(function(){return[]})),HUt=zh(UUt.prototype,"_interactable",[uu],(function(){return!0})),WUt=zh(UUt.prototype,"_transition",[uu],(function(){return 0})),jUt=zh(UUt.prototype,"_normalColor",[uu],(function(){return cr.WHITE.clone()})),qUt=zh(UUt.prototype,"_hoverColor",[uu],(function(){return new cr(211,211,211,255)})),XUt=zh(UUt.prototype,"_pressedColor",[uu],(function(){return cr.WHITE.clone()})),YUt=zh(UUt.prototype,"_disabledColor",[uu],(function(){return new cr(124,124,124,255)})),JUt=zh(UUt.prototype,"_normalSprite",[uu],(function(){return null})),KUt=zh(UUt.prototype,"_hoverSprite",[uu],(function(){return null})),QUt=zh(UUt.prototype,"_pressedSprite",[uu],(function(){return null})),ZUt=zh(UUt.prototype,"_disabledSprite",[uu],(function(){return null})),$Ut=zh(UUt.prototype,"_duration",[uu],(function(){return.1})),tGt=zh(UUt.prototype,"_zoomScale",[uu],(function(){return 1.2})),eGt=zh(UUt.prototype,"_target",[uu],(function(){return null})),zUt=UUt))||zUt)||zUt)||zUt));C.Button=uGt;var lGt=function(){function t(){}return t.add=function(t){var e=this._tabIndexList;-1===e.indexOf(t)&&e.push(t)},t.remove=function(t){var e=this._tabIndexList,i=e.indexOf(t);-1!==i&&e.splice(i,1)},t.resort=function(){this._tabIndexList.sort((function(t,e){return t._delegate.tabIndex-e._delegate.tabIndex}))},t.next=function(t){var e=this._tabIndexList,i=e.indexOf(t);if(t.setFocus(!1),-1!==i){var n=e[i+1];n&&n._delegate.tabIndex>=0&&n.setFocus(!0)}},t}();lGt._tabIndexList=[];var cGt=function(){function t(){this._editing=!1,this._delegate=null}var e=t.prototype;return e.init=function(){},e.onEnable=function(){},e.beforeDraw=function(){},e.onDisable=function(){this._editing&&this.endEditing()},e.clear=function(){this._delegate=null},e.setTabIndex=function(){},e.setSize=function(){},e.setFocus=function(t){t?this.beginEditing():this.endEditing()},e.isFocused=function(){return this._editing},e.beginEditing=function(){},e.endEditing=function(){},t}(),fGt=B.document,_Gt=new Kr,dGt=new Kr,pGt=new ir,mGt=null,gGt=0,yGt=function(t){function e(){var e;return(e=t.call(this)||this)._delegate=null,e._inputMode=-1,e._inputFlag=-1,e._returnType=-1,e.__eventListeners={},e.__autoResize=!1,e.__orientationChanged=void 0,e._edTxt=null,e._isTextArea=!1,e._textLabelFont=null,e._textLabelFontSize=null,e._textLabelFontColor=null,e._textLabelAlign=null,e._placeholderLabelFont=null,e._placeholderLabelFontSize=null,e._placeholderLabelFontColor=null,e._placeholderLabelAlign=null,e._placeholderLineHeight=null,e._placeholderStyleSheet=null,e._domId="EditBoxId_"+ ++gGt,e._forceUpdate=!1,e}s(e,t);var i=e.prototype;return i.init=function(t){t&&(this._delegate=t,0===t.inputMode?this._createTextArea():this._createInput(),lGt.add(this),this.setTabIndex(t.tabIndex),this._initStyleSheet(),this._registerEventListeners(),this._addDomToGameContainer(),IO.instance.on("canvas-resize",this._resize,this),sh.on("window-resize",this._resize,this))},i.clear=function(){IO.instance.off("canvas-resize",this._resize,this),sh.off("window-resize",this._resize,this),this._removeEventListeners(),this._removeDomFromGameContainer(),lGt.remove(this),mGt===this&&(mGt=null),this._delegate=null},i._resize=function(){this._forceUpdate=!0},i.beforeDraw=function(){(this._delegate.node.hasChangedFlags||this._forceUpdate)&&(this._forceUpdate=!1,this._updateMatrix())},i.setTabIndex=function(t){this._edTxt.tabIndex=t,lGt.resort()},i.setSize=function(t,e){var i=this._edTxt;i&&(i.style.width=t+"px",i.style.height=e+"px")},i.beginEditing=function(){mGt&&mGt!==this&&mGt.setFocus(!1),this._editing=!0,mGt=this,this._delegate._editBoxEditingDidBegan(),this._showDom(),this._edTxt.focus()},i.endEditing=function(){this._edTxt.blur()},i._createInput=function(){this._isTextArea=!1,this._edTxt=fGt.createElement("input")},i._createTextArea=function(){this._isTextArea=!0,this._edTxt=fGt.createElement("textarea")},i._addDomToGameContainer=function(){XO.container&&this._edTxt&&(XO.container.appendChild(this._edTxt),fGt.head.appendChild(this._placeholderStyleSheet))},i._removeDomFromGameContainer=function(){Ke(XO.container,this._edTxt)&&this._edTxt&&XO.container.removeChild(this._edTxt),Ke(fGt.head,this._placeholderStyleSheet)&&fGt.head.removeChild(this._placeholderStyleSheet),this._edTxt=null,this._placeholderStyleSheet=null},i._showDom=function(){this._updateMaxLength(),this._updateInputType(),this._updateStyleSheet(),this._edTxt&&this._delegate&&(this._edTxt.style.display="",this._delegate._hideLabels()),hh.isMobile&&this._showDomOnMobile()},i._hideDom=function(){var t=this._edTxt;t&&this._delegate&&(t.style.display="none",this._delegate._showLabels()),hh.isMobile&&this._hideDomOnMobile()},i._showDomOnMobile=function(){hh.os!==Oo.ANDROID&&hh.os!==Oo.OHOS||(sh.handleResizeEvent=!1,this._adjustWindowScroll())},i._hideDomOnMobile=function(){hh.os!==Oo.ANDROID&&hh.os!==Oo.OHOS||(sh.handleResizeEvent=!0),this._scrollBackWindow()},i._isElementInViewport=function(){if(this._edTxt){var t=this._edTxt.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(B.innerHeight||fGt.documentElement.clientHeight)&&t.right<=(B.innerWidth||fGt.documentElement.clientWidth)}return!1},i._adjustWindowScroll=function(){var t=this;setTimeout((function(){B.scrollY<40&&!t._isElementInViewport()&&t._edTxt.scrollIntoView({block:"start",inline:"nearest",behavior:"smooth"})}),400)},i._scrollBackWindow=function(){setTimeout((function(){hh.browserType!==Mo.WECHAT||hh.os!==Oo.IOS?B.scrollTo(0,0):B.top&&B.top.scrollTo(0,0)}),400)},i._updateMatrix=function(){if(this._edTxt){var t=this._delegate.node,e=zO.getScaleX(),i=zO.getScaleY(),n=zO.getViewportRect(),r=sh.devicePixelRatio;t.getWorldMatrix(_Gt);var s=t._getUITransformComp();if(s&&(ir.set(pGt,-s.anchorX*s.width,-s.anchorY*s.height,pGt.z),Kr.transform(_Gt,_Gt,pGt)),t._getUITransformComp()){var a=YE.root.batcher2D.getFirstRenderCamera(t);if(a){a.node.getWorldRT(dGt);var o=dGt.m12,h=dGt.m13,u=uh.center;dGt.m12=u.x-(dGt.m00*o+dGt.m04*h),dGt.m13=u.y-(dGt.m01*o+dGt.m05*h),e/=r,i/=r,ir.set(pGt,e,i,1),Kr.scale(dGt,dGt,pGt);var l=XO.container,c=parseInt(l&&l.style.paddingLeft||"0");c+=n.x/r;var f=parseInt(l&&l.style.paddingBottom||"0");f+=n.y/r,dGt.m12+=c,dGt.m13+=f,Kr.multiply(dGt,dGt,_Gt);var _="matrix("+dGt.m00+","+-dGt.m01+","+-dGt.m04+","+dGt.m05+","+dGt.m12+","+-dGt.m13+")";this._edTxt.style.transform=_,this._edTxt.style["-webkit-transform"]=_,this._edTxt.style["transform-origin"]="0px 100% 0px",this._edTxt.style["-webkit-transform-origin"]="0px 100% 0px"}}}},i._updateInputType=function(){var t=this._delegate,e=t.inputMode,i=t.inputFlag,n=t.returnType,r=this._edTxt;if(this._inputMode!==e||this._inputFlag!==i||this._returnType!==n){if(this._inputMode=e,this._inputFlag=i,this._returnType=n,this._isTextArea){var s="none";return 4===i?s="uppercase":2===i&&(s="capitalize"),void(r.style.textTransform=s)}if(0===i)return r.type="password",void(r.style.textTransform="none");var a=r.type;1===e?a="email":2===e?a="number":5===e?a="digit":3===e?(a="tel",r.addEventListener("wheel",(function(){return!1}))):4===e?a="url":(a="text",3===n&&(a="search")),r.type=a;var o="none";4===i?o="uppercase":2===i&&(o="capitalize"),r.style.textTransform=o}},i._updateMaxLength=function(){var t=this._delegate.maxLength;t<0&&(t=65535),this._edTxt.maxLength=t},i._initStyleSheet=function(){if(this._edTxt){var t=this._edTxt;t.style.color="#000000",t.style.border="0px",t.style.background="transparent",t.style.width="100%",t.style.height="100%",t.style.outline="medium",t.style.padding="0",t.style.textTransform="none",t.style.display="none",t.style.position="absolute",t.style.bottom="0px",t.style.left="2px",t.className="cocosEditBox",t.style.fontFamily="Arial",t.id=this._domId,this._isTextArea?(t.style.resize="none",t.style.overflowY="scroll"):(t.type="text",t.style["-moz-appearance"]="textfield"),this._placeholderStyleSheet=fGt.createElement("style")}},i._updateStyleSheet=function(){var t=this._delegate,e=this._edTxt;e&&t&&(e.value=t.string,this._updateTextLabel(t.textLabel))},i._updateTextLabel=function(t){if(t){var e=t.font;e=!e||e instanceof cF?t.fontFamily:e._fontFamily;var i=t.fontSize*t.node.scale.y;if((this._textLabelFont!==e||this._textLabelFontSize!==i||this._textLabelFontColor!==t.fontColor||this._textLabelAlign!==t.horizontalAlign)&&(this._textLabelFont=e,this._textLabelFontSize=i,this._textLabelFontColor=t.fontColor,this._textLabelAlign=t.horizontalAlign,this._edTxt)){var n=this._edTxt;switch(n.style.fontSize=i+"px",n.style.color=t.color.toCSS(),n.style.fontFamily=e,t.horizontalAlign){case LV.HorizontalAlign.LEFT:n.style.textAlign="left";break;case LV.HorizontalAlign.CENTER:n.style.textAlign="center";break;case LV.HorizontalAlign.RIGHT:n.style.textAlign="right"}}}},i._updatePlaceholderLabel=function(t){if(t){var e=t.font;e=!e||e instanceof cF?t.fontFamily:t.font._fontFamily;var i=t.fontSize*t.node.scale.y;if(this._placeholderLabelFont!==e||this._placeholderLabelFontSize!==i||this._placeholderLabelFontColor!==t.fontColor||this._placeholderLabelAlign!==t.horizontalAlign||this._placeholderLineHeight!==t.fontSize){this._placeholderLabelFont=e,this._placeholderLabelFontSize=i,this._placeholderLabelFontColor=t.fontColor,this._placeholderLabelAlign=t.horizontalAlign,this._placeholderLineHeight=t.fontSize;var n=this._placeholderStyleSheet,r=t.color.toCSS(),s=t.fontSize,a="";switch(t.horizontalAlign){case LV.HorizontalAlign.LEFT:a="left";break;case LV.HorizontalAlign.CENTER:a="center";break;case LV.HorizontalAlign.RIGHT:a="right"}n.innerHTML="#"+this._domId+"::-webkit-input-placeholder{text-transform: initial;-family: "+e+";font-size: "+i+"px;color: "+r+";line-height: "+s+"px;text-align: "+a+";}#"+this._domId+"::-moz-placeholder{text-transform: initial;-family: "+e+";font-size: "+i+"px;color: "+r+";line-height: "+s+"px;text-align: "+a+";}#"+this._domId+"::-ms-input-placeholder{text-transform: initial;-family: "+e+";font-size: "+i+"px;color: "+r+";line-height: "+s+"px;text-align: "+a+";}",hh.browserType===Mo.EDGE&&(n.innerHTML+="#"+this._domId+"::-ms-clear{display: none;}")}}},i._registerEventListeners=function(){var t=this;if(this._edTxt){var e=this._edTxt,i=!1,n=this.__eventListeners;n.compositionStart=function(){i=!0},n.compositionEnd=function(){i=!1,t._delegate._editBoxTextChanged(e.value)},n.onInput=function(){if(!i){var n=t._delegate,r=n.maxLength;r>=0&&"number"!==e.type&&(e.value=e.value.slice(0,r)),n._editBoxTextChanged(e.value)}},n.onClick=function(){t._editing&&hh.isMobile&&t._adjustWindowScroll()},n.onKeydown=function(i){13===i.keyCode?(i.propagationStopped=!0,t._delegate._editBoxEditingReturn(),t._isTextArea||e.blur()):9===i.keyCode&&(i.propagationStopped=!0,i.preventDefault(),lGt.next(t))},n.onBlur=function(){hh.isMobile&&i&&n.compositionEnd(),t._editing=!1,mGt=null,t._hideDom(),t._delegate._editBoxEditingDidEnded()},e.addEventListener("compositionstart",n.compositionStart),e.addEventListener("compositionend",n.compositionEnd),e.addEventListener("input",n.onInput),e.addEventListener("keydown",n.onKeydown),e.addEventListener("blur",n.onBlur),e.addEventListener("touchstart",n.onClick)}},i._removeEventListeners=function(){if(this._edTxt){var t=this._edTxt,e=this.__eventListeners;t.removeEventListener("compositionstart",e.compositionStart),t.removeEventListener("compositionend",e.compositionEnd),t.removeEventListener("input",e.onInput),t.removeEventListener("keydown",e.onKeydown),t.removeEventListener("blur",e.onBlur),t.removeEventListener("touchstart",e.onClick),e.compositionStart=null,e.compositionEnd=null,e.onInput=null,e.onKeydown=null,e.onBlur=null,e.onClick=null}},e}(cGt),vGt={DEFAULT:0,DONE:1,SEND:2,SEARCH:3,GO:4,NEXT:5};Ee(vGt);var bGt={ANY:0,EMAIL_ADDR:1,NUMERIC:2,PHONE_NUMBER:3,URL:4,DECIMAL:5,SINGLE_LINE:6};Ee(bGt);var SGt,wGt,xGt,TGt,AGt,CGt,DGt,BGt,IGt,MGt,PGt,EGt,OGt,kGt,RGt,FGt,LGt,VGt,NGt,zGt,UGt,GGt,HGt,WGt,jGt,qGt,XGt,YGt,JGt,KGt={PASSWORD:0,SENSITIVE:1,INITIAL_CAPS_WORD:2,INITIAL_CAPS_SENTENCE:3,INITIAL_CAPS_ALL_CHARACTERS:4,DEFAULT:5};Ee(KGt);var QGt,ZGt,$Gt,tHt,eHt,iHt,nHt,rHt,sHt,aHt,oHt,hHt,uHt,lHt,cHt,fHt,_Ht,dHt,pHt,mHt,gHt,yHt,vHt,bHt,SHt,wHt,xHt,THt,AHt=t("gT",(SGt=Kh("cc.EditBox"),wGt=Zh(110),xGt=Qh(lL),TGt=Ou(LV),AGt=Ou(LV),CGt=Ou(nR),DGt=Ou(KGt),BGt=Ou(bGt),IGt=Ou(vGt),MGt=Ou([mg]),PGt=Ou([mg]),EGt=Ou([mg]),OGt=Ou([mg]),SGt(kGt=wGt(kGt=xGt((JGt=function(t){function e(){var e;return(e=t.call(this)||this).editingDidBegan=FGt&&FGt(),e.textChanged=LGt&&LGt(),e.editingDidEnded=VGt&&VGt(),e.editingReturn=NGt&&NGt(),e._impl=null,e._background=null,e._textLabel=zGt&&zGt(),e._placeholderLabel=UGt&&UGt(),e._returnType=GGt&&GGt(),e._string=HGt&&HGt(),e._tabIndex=WGt&&WGt(),e._backgroundImage=jGt&&jGt(),e._inputFlag=qGt&&qGt(),e._inputMode=XGt&&XGt(),e._maxLength=YGt&&YGt(),e._isLabelVisible=!1,e}s(e,t);var i=e.prototype;return i.__preload=function(){this._init()},i.onEnable=function(){this._registerEvent(),this._ensureBackgroundSprite(),this._impl&&this._impl.onEnable()},i._beforeDraw=function(){this._impl&&this._impl.beforeDraw()},i.onDisable=function(){this._unregisterEvent(),this._unregisterBackgroundEvent(),this._impl&&this._impl.onDisable()},i.onDestroy=function(){YE.off("director_before_draw",this._beforeDraw,this),this._impl&&this._impl.clear()},i.setFocus=function(){this._impl&&this._impl.setFocus(!0)},i.focus=function(){this._impl&&this._impl.setFocus(!0)},i.blur=function(){this._impl&&this._impl.setFocus(!1)},i.isFocused=function(){return!!this._impl&&this._impl.isFocused()},i._editBoxEditingDidBegan=function(){mg.emitEvents(this.editingDidBegan,this),this.node.emit("editing-did-began",this)},i._editBoxEditingDidEnded=function(t){mg.emitEvents(this.editingDidEnded,this),this.node.emit("editing-did-ended",this,t)},i._editBoxTextChanged=function(t){t=this._updateLabelStringStyle(t,!0),this.string=t,mg.emitEvents(this.textChanged,t,this),this.node.emit("text-changed",this)},i._editBoxEditingReturn=function(t){mg.emitEvents(this.editingReturn,this),this.node.emit("editing-return",this,t)},i._showLabels=function(){this._isLabelVisible=!0,this._updateLabels()},i._hideLabels=function(){this._isLabelVisible=!1,this._textLabel&&(this._textLabel.node.active=!1),this._placeholderLabel&&(this._placeholderLabel.node.active=!1)},i._onTouchBegan=function(t){t.propagationStopped=!0},i._onTouchCancel=function(t){t.propagationStopped=!0},i._onTouchEnded=function(t){this._impl&&this._impl.beginEditing(),t.propagationStopped=!0},i._init=function(){this._updatePlaceholderLabel(),this._updateTextLabel(),this._isLabelVisible=!0,this.node.on("size-changed",this._resizeChildNodes,this),YE.on("director_before_draw",this._beforeDraw,this),(this._impl=new e._EditBoxImpl).init(this),this._updateString(this._string),this._syncSize()},i._ensureBackgroundSprite=function(){if(!this._background){var t=this.node.getComponent(GV);t||(t=this.node.addComponent(GV)),t!==this._background&&(t.type=GV.Type.SLICED,t.spriteFrame=this._backgroundImage,this._background=t,this._registerBackgroundEvent())}},i._updateTextLabel=function(){var t=this._textLabel;if(!t){var e=this.node.getChildByName("TEXT_LABEL");e||((e=new eb("TEXT_LABEL")).layer=this.node.layer),(t=e.getComponent(LV))||(t=e.addComponent(LV)),e.parent=this.node,this._textLabel=t}0===this._inputMode?(t.verticalAlign=0,t.enableWrapText=!0):t.enableWrapText=!1,t.string=this._updateLabelStringStyle(this._string)},i._updatePlaceholderLabel=function(){var t=this._placeholderLabel;if(!t){var e=this.node.getChildByName("PLACEHOLDER_LABEL");e||((e=new eb("PLACEHOLDER_LABEL")).layer=this.node.layer),(t=e.getComponent(LV))||(t=e.addComponent(LV)),e.parent=this.node,this._placeholderLabel=t}0===this._inputMode?t.enableWrapText=!0:t.enableWrapText=!1,t.string=this.placeholder},i._syncSize=function(){var t=this.node._getUITransformComp(),e=t.contentSize;if(this._background){var i=this._background.node._getUITransformComp();i.anchorPoint=t.anchorPoint,i.setContentSize(e)}this._updateLabelPosition(e),this._impl&&this._impl.setSize(e.width,e.height)},i._updateLabels=function(){if(this._isLabelVisible){var t=this._string;this._textLabel&&(this._textLabel.node.active=""!==t),this._placeholderLabel&&(this._placeholderLabel.node.active=""===t)}},i._updateString=function(t){var e=this._textLabel;if(e){var i=t;i&&(i=this._updateLabelStringStyle(i)),e.string=i,this._updateLabels()}},i._updateLabelStringStyle=function(t,e){void 0===e&&(e=!1);var i,n=this._inputFlag;if(e||0!==n)4===n?t=t.toUpperCase():2===n?t=t.replace(/(?:^|\s)\S/g,(function(t){return t.toUpperCase()})):3===n&&(t=(i=t).charAt(0).toUpperCase()+i.slice(1));else{for(var r="",s=t.length,a=0;a=0&&t.length>=this._maxLength&&(t=t.slice(0,this._maxLength)),this._string!==t&&(this._string=t,this._updateString(t))}},{key:"placeholder",get:function(){return this._placeholderLabel?this._placeholderLabel.string:""},set:function(t){this._placeholderLabel&&(this._placeholderLabel.string=t)}},{key:"textLabel",get:function(){return this._textLabel},set:function(t){this._textLabel!==t&&(this._textLabel=t,this._textLabel&&(this._updateTextLabel(),this._updateLabels()))}},{key:"placeholderLabel",get:function(){return this._placeholderLabel},set:function(t){this._placeholderLabel!==t&&(this._placeholderLabel=t,this._placeholderLabel&&(this._updatePlaceholderLabel(),this._updateLabels()))}},{key:"backgroundImage",get:function(){return this._backgroundImage},set:function(t){this._backgroundImage!==t&&(this._backgroundImage=t,this._ensureBackgroundSprite(),this._background.spriteFrame=t)}},{key:"inputFlag",get:function(){return this._inputFlag},set:function(t){this._inputFlag!==t&&(this._inputFlag=t,this._updateString(this._string))}},{key:"inputMode",get:function(){return this._inputMode},set:function(t){this._inputMode!==t&&(this._inputMode=t,this._updateTextLabel(),this._updatePlaceholderLabel())}},{key:"returnType",get:function(){return this._returnType},set:function(t){this._returnType=t}},{key:"maxLength",get:function(){return this._maxLength},set:function(t){this._maxLength=t}},{key:"tabIndex",get:function(){return this._tabIndex},set:function(t){this._tabIndex!==t&&(this._tabIndex=t,this._impl&&this._impl.setTabIndex(t))}}]),e}(yg),JGt._EditBoxImpl=cGt,JGt.KeyboardReturnType=vGt,JGt.InputFlag=KGt,JGt.InputMode=bGt,JGt.EventType={EDITING_DID_BEGAN:"editing-did-began",EDITING_DID_ENDED:"editing-did-ended",TEXT_CHANGED:"text-changed",EDITING_RETURN:"editing-return",XR_EDITING_DID_BEGAN:"xr-editing-did-began",XR_EDITING_DID_ENDED:"xr-editing-did-ended"},v((RGt=JGt).prototype,"textLabel",[TGt],Object.getOwnPropertyDescriptor(RGt.prototype,"textLabel"),RGt.prototype),v(RGt.prototype,"placeholderLabel",[AGt],Object.getOwnPropertyDescriptor(RGt.prototype,"placeholderLabel"),RGt.prototype),v(RGt.prototype,"backgroundImage",[CGt],Object.getOwnPropertyDescriptor(RGt.prototype,"backgroundImage"),RGt.prototype),v(RGt.prototype,"inputFlag",[DGt],Object.getOwnPropertyDescriptor(RGt.prototype,"inputFlag"),RGt.prototype),v(RGt.prototype,"inputMode",[BGt],Object.getOwnPropertyDescriptor(RGt.prototype,"inputMode"),RGt.prototype),v(RGt.prototype,"returnType",[IGt],Object.getOwnPropertyDescriptor(RGt.prototype,"returnType"),RGt.prototype),FGt=zh(RGt.prototype,"editingDidBegan",[MGt,uu],(function(){return[]})),LGt=zh(RGt.prototype,"textChanged",[PGt,uu],(function(){return[]})),VGt=zh(RGt.prototype,"editingDidEnded",[EGt,uu],(function(){return[]})),NGt=zh(RGt.prototype,"editingReturn",[OGt,uu],(function(){return[]})),zGt=zh(RGt.prototype,"_textLabel",[uu],(function(){return null})),UGt=zh(RGt.prototype,"_placeholderLabel",[uu],(function(){return null})),GGt=zh(RGt.prototype,"_returnType",[uu],(function(){return 0})),HGt=zh(RGt.prototype,"_string",[uu],(function(){return""})),WGt=zh(RGt.prototype,"_tabIndex",[uu],(function(){return 0})),jGt=zh(RGt.prototype,"_backgroundImage",[uu],(function(){return null})),qGt=zh(RGt.prototype,"_inputFlag",[uu],(function(){return 5})),XGt=zh(RGt.prototype,"_inputMode",[uu],(function(){return 0})),YGt=zh(RGt.prototype,"_maxLength",[uu],(function(){return 20})),kGt=RGt))||kGt)||kGt)||kGt));"object"==typeof window&&"object"==typeof document&&(AHt._EditBoxImpl=yGt),C.internal.EditBox=AHt;var CHt={NONE:0,HORIZONTAL:1,VERTICAL:2,GRID:3};Re(CHt);var DHt={NONE:0,CONTAINER:1,CHILDREN:2};Re(DHt);var BHt={HORIZONTAL:0,VERTICAL:1};Re(BHt);var IHt={BOTTOM_TO_TOP:0,TOP_TO_BOTTOM:1};Re(IHt);var MHt={LEFT_TO_RIGHT:0,RIGHT_TO_LEFT:1};Re(MHt);var PHt={NONE:0,FIXED_ROW:1,FIXED_COL:2};Re(PHt);var EHt,OHt,kHt,RHt,FHt,LHt,VHt,NHt,zHt,UHt,GHt,HHt,WHt,jHt=new ir,qHt=t("gU",(QGt=Kh("cc.Layout"),ZGt=Zh(110),$Gt=Qh(lL),tHt=Ou(CHt),eHt=Ou(DHt),iHt=Ou(BHt),nHt=Ou(IHt),rHt=Ou(MHt),sHt=Ou(PHt),QGt(aHt=ZGt(aHt=$Gt((THt=function(t){function e(){var e;return(e=t.call(this)||this)._resizeMode=hHt&&hHt(),e._layoutType=uHt&&uHt(),e._cellSize=lHt&&lHt(),e._startAxis=cHt&&cHt(),e._paddingLeft=fHt&&fHt(),e._paddingRight=_Ht&&_Ht(),e._paddingTop=dHt&&dHt(),e._paddingBottom=pHt&&pHt(),e._spacingX=mHt&&mHt(),e._spacingY=gHt&&gHt(),e._verticalDirection=yHt&&yHt(),e._horizontalDirection=vHt&&vHt(),e._constraint=bHt&&bHt(),e._constraintNum=SHt&&SHt(),e._affectedByScale=wHt&&wHt(),e._isAlign=xHt&&xHt(),e._layoutSize=new ms(300,200),e._layoutDirty=!0,e._childrenDirty=!1,e._usefulLayoutObj=[],e._init=!1,e}s(e,t);var i=e.prototype;return i.updateLayout=function(t){void 0===t&&(t=!1),(this._layoutDirty||t)&&(this._doLayout(),this._layoutDirty=!1)},i.onEnable=function(){this._addEventListeners();var t=this.node._getUITransformComp();t.contentSize.equals(ms.ZERO)&&t.setContentSize(this._layoutSize),this._childrenChanged()},i.onDisable=function(){this._usefulLayoutObj.length=0,this._removeEventListeners()},i._checkUsefulObj=function(){this._usefulLayoutObj.length=0;for(var t=this.node.children,e=0;ef&&(_=Math.max(f,_),c=f||D,f=D),u+=a*(A*C+this._spacingX);var B=a*(1-A)*C;if(e){if(s>0)(d=v/s>0&&v%s==0)&&(c=f>D?f:c);else if(C>t-g)u>h+a*A*C&&(d=!0);else{var I=(1-this._horizontalDirection-r.x)*t,M=u+B+a*(a>0?this._paddingRight:this._paddingLeft);d=Math.abs(M)>Math.abs(I)}d&&(u=h+a*A*C,D!==f&&(c=f),l+=c+this._spacingY,c=f=D)}var P=i(S,b,l);n&&S.setPosition(u,P),u+=B}return c=Math.max(c,f),Math.max(_,l+c)+this._getPaddingV()},i._doLayoutVertically=function(t,e,i,n){var r=this.node._getUITransformComp().anchorPoint,s=this._getFixedBreakingNum(),a=1,o=this._paddingBottom;1===this._verticalDirection&&(a=-1,o=this._paddingTop);var h=(this._verticalDirection-r.y)*t+a*o,u=h-a*this._spacingY,l=0,c=0,f=0,_=0,d=!1,p=this._usefulLayoutObj.length,m=this._cellSize.height,g=this._getPaddingV();3!==this._layoutType&&2===this._resizeMode&&(m=(t-g-(p-1)*this._spacingY)/p);for(var y=this._usefulLayoutObj,v=0;vl&&(c=Math.max(l,c),f=l||C,l=C),u+=a*(A*D+this._spacingY);var B=a*(1-A)*D;if(e){if(s>0)(d=v/s>0&&v%s==0)&&(f=l>D?l:f);else if(D>t-g)u>h+a*A*D&&(d=!0);else{var I=(1-this._verticalDirection-r.y)*t,M=u+B+a*(a>0?this._paddingTop:this._paddingBottom);d=Math.abs(M)>Math.abs(I)}d&&(u=h+a*A*D,C!==l&&(f=l),_+=f+this._spacingX,f=l=C)}var P=i(S,b,_);n&&(S.getPosition(jHt),S.setPosition(P,u,jHt.z)),u+=B}return f=Math.max(f,l),Math.max(c,_+f)+this._getPaddingH()},i._doLayoutGridAxisHorizontal=function(t,e){var i=this,n=e.width,r=1,s=-t.y*e.height,a=this._paddingBottom;1===this._verticalDirection&&(r=-1,s=(1-t.y)*e.height,a=this._paddingTop);var o=function(t,e,n){return s+r*(n+(1-e.anchorY)*e.height*i._getUsedScaleValue(t.scale.y)+a)},h=0;1===this._resizeMode&&(h=this._doLayoutHorizontally(n,!0,o,!1),s=-t.y*h,1===this._verticalDirection&&(r=-1,s=(1-t.y)*h)),this._doLayoutHorizontally(n,!0,o,!0),1===this._resizeMode&&this.node._getUITransformComp().setContentSize(n,h)},i._doLayoutGridAxisVertical=function(t,e){var i=this,n=e.height,r=1,s=-t.x*e.width,a=this._paddingLeft;1===this._horizontalDirection&&(r=-1,s=(1-t.x)*e.width,a=this._paddingRight);var o=function(t,e,n){return s+r*(n+(1-e.anchorX)*e.width*i._getUsedScaleValue(t.scale.x)+a)},h=0;1===this._resizeMode&&(h=this._doLayoutVertically(n,!0,o,!1),s=-t.x*h,1===this._horizontalDirection&&(r=-1,s=(1-t.x)*h)),this._doLayoutVertically(n,!0,o,!0),1===this._resizeMode&&this.node._getUITransformComp().setContentSize(h,n)},i._doLayoutGrid=function(){var t=this.node._getUITransformComp(),e=t.anchorPoint,i=t.contentSize;0===this.startAxis?this._doLayoutGridAxisHorizontal(e,i):1===this.startAxis&&this._doLayoutGridAxisVertical(e,i)},i._getHorizontalBaseWidth=function(){var t=this._usefulLayoutObj,e=0,i=t.length;if(1===this._resizeMode){for(var n=0;n0?n:-n)),i*(e/r)},i._calculatePosition=function(t,e,i,n,r,s,a){var o=e-i;s&&(o+=Math.abs(s));var h=0;o&&(h=tn(h=r/o));var u=(n-a)*h;1===this._direction?t.set(0,u):t.set(u,0)},i._updateLength=function(t){if(this._handle){var e=this._handle.node._getUITransformComp(),i=e.contentSize,n=e.anchorPoint;n.x===cWt.x&&n.y===cWt.y||e.setAnchorPoint(cWt),0===this._direction?e.setContentSize(t,i.height):e.setContentSize(i.width,t)}},i._processAutoHide=function(t){if(this._enableAutoHide&&!(this._autoHideRemainingTime<=0)&&!this._touching&&(this._autoHideRemainingTime-=t,this._autoHideRemainingTime<=this._autoHideTime)){this._autoHideRemainingTime=Math.max(0,this._autoHideRemainingTime);var e=this._opacity*(this._autoHideRemainingTime/this._autoHideTime);this._setOpacity(e)}},n(e,[{key:"handle",get:function(){return this._handle},set:function(t){this._handle!==t&&(this._handle=t,this.onScroll(ds.ZERO))}},{key:"direction",get:function(){return this._direction},set:function(t){this._direction!==t&&(this._direction=t,this.onScroll(ds.ZERO))}},{key:"enableAutoHide",get:function(){return this._enableAutoHide},set:function(t){this._enableAutoHide!==t&&(this._enableAutoHide=t,this._enableAutoHide&&this._setOpacity(0))}},{key:"autoHideTime",get:function(){return this._autoHideTime},set:function(t){this._autoHideTime!==t&&(this._autoHideTime=t)}}]),e}(yg),aWt.Direction=dWt,v((tWt=aWt).prototype,"handle",[QHt],Object.getOwnPropertyDescriptor(tWt.prototype,"handle"),tWt.prototype),v(tWt.prototype,"direction",[ZHt],Object.getOwnPropertyDescriptor(tWt.prototype,"direction"),tWt.prototype),eWt=zh(tWt.prototype,"_scrollView",[uu],(function(){return null})),iWt=zh(tWt.prototype,"_handle",[uu],(function(){return null})),nWt=zh(tWt.prototype,"_direction",[uu],(function(){return 0})),rWt=zh(tWt.prototype,"_enableAutoHide",[uu],(function(){return!1})),sWt=zh(tWt.prototype,"_autoHideTime",[uu],(function(){return 1})),$Ht=tWt))||$Ht)||$Ht)||$Ht));C.ScrollBar=mWt;var gWt,yWt,vWt,bWt,SWt,wWt,xWt,TWt,AWt,CWt,DWt,BWt,IWt,MWt,PWt,EWt,OWt,kWt,RWt,FWt,LWt,VWt=t("g$",Kh("cc.ViewGroup")(pWt=Zh(110)(pWt=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e}(yg))||pWt)||pWt);C.ViewGroup=VWt;var NWt,zWt,UWt,GWt,HWt,WWt,jWt,qWt,XWt,YWt,JWt,KWt,QWt,ZWt=1e-4,$Wt=nr(),tjt=nr(),ejt=ps(),ijt=ps(),njt=function(){return(new Date).getMilliseconds()},rjt={"scroll-to-top":0,"scroll-to-bottom":1,"scroll-to-left":2,"scroll-to-right":3,scrolling:4,"bounce-bottom":6,"bounce-left":7,"bounce-right":8,"bounce-top":5,"scroll-ended":9,"touch-up":10,"scroll-ended-with-threshold":11,"scroll-began":12},sjt={anchor:ps(),applyToHorizontal:!1,applyToVertical:!1},ajt=function(t,e,i,n){sjt.anchor.set(t,e),sjt.applyToHorizontal=i,sjt.applyToVertical=n},ojt={NONE:"",SCROLL_TO_TOP:"scroll-to-top",SCROLL_TO_BOTTOM:"scroll-to-bottom",SCROLL_TO_LEFT:"scroll-to-left",SCROLL_TO_RIGHT:"scroll-to-right",SCROLL_BEGAN:"scroll-began",SCROLL_ENDED:"scroll-ended",BOUNCE_TOP:"bounce-top",BOUNCE_BOTTOM:"bounce-bottom",BOUNCE_LEFT:"bounce-left",BOUNCE_RIGHT:"bounce-right",SCROLLING:"scrolling",SCROLL_ENG_WITH_THRESHOLD:"scroll-ended-with-threshold",TOUCH_UP:"touch-up"},hjt=t("gX",(gWt=Kh("cc.ScrollView"),yWt=Zh(110),vWt=Qh(lL),bWt=Ou(eb),SWt=Ou(mWt),wWt=Ou(mWt),xWt=Ou([mg]),gWt(TWt=yWt(TWt=vWt((LWt=function(t){function e(){var e;return(e=t.call(this)||this).bounceDuration=CWt&&CWt(),e.brake=DWt&&DWt(),e.elastic=BWt&&BWt(),e.inertia=IWt&&IWt(),e.horizontal=MWt&&MWt(),e.vertical=PWt&&PWt(),e.cancelInnerEvents=EWt&&EWt(),e.scrollEvents=OWt&&OWt(),e._autoScrolling=!1,e._scrolling=!1,e._content=kWt&&kWt(),e._horizontalScrollBar=RWt&&RWt(),e._verticalScrollBar=FWt&&FWt(),e._topBoundary=0,e._bottomBoundary=0,e._leftBoundary=0,e._rightBoundary=0,e._touchMoveDisplacements=[],e._touchMoveTimeDeltas=[],e._touchMovePreviousTimestamp=0,e._touchMoved=!1,e._autoScrollAttenuate=!1,e._autoScrollStartPosition=new ir,e._autoScrollTargetDelta=new ir,e._autoScrollTotalTime=0,e._autoScrollAccumulatedTime=0,e._autoScrollCurrentlyOutOfBoundary=!1,e._autoScrollBraking=!1,e._autoScrollBrakingStartPosition=new ir,e._outOfBoundaryAmount=new ir,e._outOfBoundaryAmountDirty=!0,e._stopMouseWheel=!1,e._mouseWheelEventElapsedTime=0,e._isScrollEndedWithThresholdEventFired=!1,e._scrollEventEmitMask=0,e._isBouncing=!1,e._contentPos=new ir,e._deltaPos=new ir,e._deltaAmount=new ir,e._hoverIn=0,e}s(e,t);var i=e.prototype;return i.scrollToBottom=function(t,e){void 0===e&&(e=!0),this._doScroll(0,0,!1,!0,t,e)},i.scrollToTop=function(t,e){void 0===e&&(e=!0),this._doScroll(0,1,!1,!0,t,e)},i.scrollToLeft=function(t,e){void 0===e&&(e=!0),this._doScroll(0,0,!0,!1,t,e)},i.scrollToRight=function(t,e){void 0===e&&(e=!0),this._doScroll(1,0,!0,!1,t,e)},i.scrollToTopLeft=function(t,e){void 0===e&&(e=!0),this._doScroll(0,1,!0,!0,t,e)},i.scrollToTopRight=function(t,e){void 0===e&&(e=!0),this._doScroll(1,1,!0,!0,t,e)},i.scrollToBottomLeft=function(t,e){void 0===e&&(e=!0),this._doScroll(0,0,!0,!0,t,e)},i.scrollToBottomRight=function(t,e){void 0===e&&(e=!0),this._doScroll(1,0,!0,!0,t,e)},i.scrollToOffset=function(t,e,i){void 0===i&&(i=!0);var n=this.getMaxScrollOffset(),r=ps();0===n.x?r.x=0:r.x=t.x/n.x,0===n.y?r.y=1:r.y=(n.y-t.y)/n.y,this.scrollTo(r,e,i)},i.getScrollOffset=function(){var t=this._getContentTopBoundary()-this._topBoundary,e=this._getContentLeftBoundary()-this._leftBoundary;return new ds(e,t)},i.getMaxScrollOffset=function(){if(!this._content||!this.view)return ds.ZERO;var t=this._content._getUITransformComp().contentSize,e=t.width-this.view.width,i=t.height-this.view.height;return new ds(e=e>=0?e:0,i=i>=0?i:0)},i.scrollToPercentHorizontal=function(t,e,i){this._doScroll(t,0,!0,!1,e,i)},i.scrollTo=function(t,e,i){this._doScroll(t.x,t.y,!0,!0,e,i)},i.scrollToPercentVertical=function(t,e,i){this._doScroll(0,t,!1,!0,e,i)},i._doScroll=function(t,e,i,n,r,s){void 0===s&&(s=!0),ajt(t,e,i,n);var a=this._calculateMovePercentDelta(sjt);r?this._startAutoScroll(a,r,s):this._moveContent(a)},i.stopAutoScroll=function(){this._autoScrolling=!1,this._autoScrollAccumulatedTime=this._autoScrollTotalTime},i.setContentPosition=function(t){this._setContentPosition(t)},i._setContentPosition=function(t){if(this._content){var e=this._getContentPosition();Math.abs(t.x-e.x)7&&!i._touchMoved&&t.target!==i.node){var s=new Yy(t.getTouches(),t.bubbles,"touch-cancel");s.touch=t.touch,s.simulate=!0,t.target.dispatchEvent(s),i._touchMoved=!0}i._stopPropagationIfTargetIsMe(t)}}},i._onTouchEnded=function(t,e){var i=this;if(i.enabledInHierarchy&&i._content&&t&&!i._hasNestedViewGroup(t,e)){i._dispatchEvent("touch-up");var n=t.touch;i._handleReleaseLogic(n),i._touchMoved?t.propagationStopped=!0:i._stopPropagationIfTargetIsMe(t)}},i._onTouchCancelled=function(t,e){var i=this;i.enabledInHierarchy&&i._content&&(i._hasNestedViewGroup(t,e)||(t&&!t.simulate&&i._handleReleaseLogic(t.touch),i._stopPropagationIfTargetIsMe(t)))},i._calculateBoundary=function(){var t=this;if(t._content&&t.view){var e=t._content.getComponent(qHt);e&&e.enabledInHierarchy&&e.updateLayout();var i=t.view,n=i.width*i.anchorX,r=i.height*i.anchorY;t._leftBoundary=-n,t._bottomBoundary=-r,t._rightBoundary=t._leftBoundary+i.width,t._topBoundary=t._bottomBoundary+i.height,t._moveContentToTopLeft(i.contentSize)}},i._hasNestedViewGroup=function(t,e){if(!t||t.eventPhase!==Hy.CAPTURING_PHASE)return!1;if(e)for(var i=0;i0&&l>7?(l=Math.sqrt(l),i.set(t),i.multiplyScalar(l+1)):i.add(t);var c=this._calculateAutoScrollTimeByInitialSpeed(e.length());this.brake>0&&l>3&&(c*=l=3),0===this.brake&&l>1&&(c*=l),this._startAutoScroll(i,c,!0)},i._calculateAutoScrollTimeByInitialSpeed=function(t){return Math.sqrt(Math.sqrt(t/5))},i._startAutoScroll=function(t,e,i){void 0===i&&(i=!1);var n=this,r=n._flattenVectorByDirection(t);n._autoScrolling=!0,n._autoScrollTargetDelta=r,n._autoScrollAttenuate=i,ir.copy(n._autoScrollStartPosition,n._getContentPosition()),n._autoScrollTotalTime=e,n._autoScrollAccumulatedTime=0,n._autoScrollBraking=!1,n._isScrollEndedWithThresholdEventFired=!1,n._autoScrollBrakingStartPosition.set(0,0,0),n._getHowMuchOutOfBoundary().equals(ir.ZERO,ZWt)||(this._autoScrollCurrentlyOutOfBoundary=!0)},i._calculateTouchMoveVelocity=function(){var t=new ir,e=0;if((e=this._touchMoveTimeDeltas.reduce((function(t,e){return t+e}),e))<=0||e>=.5)t.set(ir.ZERO);else{var i=$Wt;i.set(0,0,0),i=this._touchMoveDisplacements.reduce((function(t,e){return t.add(e),t}),i),t.set(i.x*(1-this.brake)/e,i.y*(1-this.brake)/e,i.z)}return t},i._flattenVectorByDirection=function(t){return this.horizontal||(t.x=0),this.vertical||(t.y=0),t},i._moveContent=function(t,e){var i=this._flattenVectorByDirection(t);$Wt.set(this._getContentPosition()),$Wt.add(i),$Wt.set(Math.round(1e4*$Wt.x)*ZWt,Math.round(1e4*$Wt.y)*ZWt,$Wt.z),this._setContentPosition($Wt);var n=this._getHowMuchOutOfBoundary();ejt.set(n.x,n.y),this._updateScrollBar(ejt),this.elastic&&e&&this._startBounceBackIfNeeded()},i._getContentLeftBoundary=function(){if(!this._content)return-1;var t=this._getContentPosition(),e=this._content._getUITransformComp();return t.x-e.anchorX*e.width},i._getContentRightBoundary=function(){if(!this._content)return-1;var t=this._content._getUITransformComp();return this._getContentLeftBoundary()+t.width},i._getContentTopBoundary=function(){if(!this._content)return-1;var t=this._content._getUITransformComp();return this._getContentBottomBoundary()+t.height},i._getContentBottomBoundary=function(){if(!this._content)return-1;var t=this._getContentPosition(),e=this._content._getUITransformComp();return t.y-e.anchorY*e.height},i._getHowMuchOutOfBoundary=function(t){if(t||(t=ir.ZERO),t.equals(ir.ZERO,ZWt)&&!this._outOfBoundaryAmountDirty)return this._outOfBoundaryAmount;var e=new ir,i=this._getContentLeftBoundary(),n=this._getContentRightBoundary();i+t.x>this._leftBoundary?e.x=this._leftBoundary-(i+t.x):n+t.xthis._bottomBoundary&&(e.y=this._bottomBoundary-(s+t.y)),t.equals(ir.ZERO,ZWt)&&(this._outOfBoundaryAmount=e,this._outOfBoundaryAmountDirty=!1),this._clampDelta(e),e},i._updateScrollBar=function(t){this._horizontalScrollBar&&this._horizontalScrollBar.isValid&&this._horizontalScrollBar.onScroll(t),this._verticalScrollBar&&this._verticalScrollBar.isValid&&this._verticalScrollBar.onScroll(t)},i._onScrollBarTouchBegan=function(){this._horizontalScrollBar&&this._horizontalScrollBar.isValid&&this._horizontalScrollBar.onTouchBegan(),this._verticalScrollBar&&this._verticalScrollBar.isValid&&this._verticalScrollBar.onTouchBegan()},i._onScrollBarTouchEnded=function(){this._horizontalScrollBar&&this._horizontalScrollBar.isValid&&this._horizontalScrollBar.onTouchEnded(),this._verticalScrollBar&&this._verticalScrollBar.isValid&&this._verticalScrollBar.onTouchEnded()},i._dispatchEvent=function(t){if("scroll-ended"===t)this._scrollEventEmitMask=0;else if("scroll-to-top"===t||"scroll-to-bottom"===t||"scroll-to-left"===t||"scroll-to-right"===t){var e=1<0?c.y-h*l+n.y>=e._bottomBoundary&&(r="scroll-to-bottom"):n.y<0&&c.y-h*l+l+n.y<=e._topBoundary&&(r="scroll-to-top")),e.horizontal&&(n.x<0?c.x-o*u+u+n.x<=e._rightBoundary&&(s="scroll-to-right"):n.x>0&&c.x-o*u+n.x>=e._leftBoundary&&(s="scroll-to-left"))}e._moveContent(n,!1),(e.horizontal&&0!==n.x||e.vertical&&0!==n.y)&&(e._scrolling||(e._scrolling=!0,e._dispatchEvent("scroll-began")),e._dispatchEvent("scrolling")),""!==r&&e._dispatchEvent(r),""!==s&&e._dispatchEvent(s)},i._handlePressLogic=function(){var t=this;t._autoScrolling&&t._dispatchEvent("scroll-ended"),t._autoScrolling=!1,t._isBouncing=!1,t._touchMovePreviousTimestamp=njt(),t._touchMoveDisplacements.length=0,t._touchMoveTimeDeltas.length=0,t._onScrollBarTouchBegan()},i._clampDelta=function(t){if(this._content&&this.view){var e=this.view.contentSize,i=this._content._getUITransformComp();i.width=5;)e._touchMoveDisplacements.shift(),e._touchMoveTimeDeltas.shift();e._touchMoveDisplacements.push(i);var n=njt();e._touchMoveTimeDeltas.push((n-e._touchMovePreviousTimestamp)/1e3),e._touchMovePreviousTimestamp=n},i._startBounceBackIfNeeded=function(){var t=this;if(!t.elastic)return!1;var e=t._getHowMuchOutOfBoundary();if(t._clampDelta(e),e.equals(ir.ZERO,ZWt))return!1;var i=Math.max(t.bounceDuration,0);return t._startAutoScroll(e,i,!0),t._isBouncing||(e.y>0&&t._dispatchEvent("bounce-top"),e.y<0&&t._dispatchEvent("bounce-bottom"),e.x>0&&t._dispatchEvent("bounce-right"),e.x<0&&t._dispatchEvent("bounce-left"),t._isBouncing=!0),!0},i._processInertiaScroll=function(){if(!this._startBounceBackIfNeeded()&&this.inertia){var t=this._calculateTouchMoveVelocity();!t.equals(ir.ZERO,ZWt)&&this.brake<1&&this._startInertiaScroll(t)}this._onScrollBarTouchEnded()},i._isOutOfBoundary=function(){return!this._getHowMuchOutOfBoundary().equals(ir.ZERO,ZWt)},i._isNecessaryAutoScrollBrake=function(){var t=this;if(t._autoScrollBraking)return!0;if(t._isOutOfBoundary()){if(!t._autoScrollCurrentlyOutOfBoundary)return t._autoScrollCurrentlyOutOfBoundary=!0,t._autoScrollBraking=!0,ir.copy(t._autoScrollBrakingStartPosition,t._getContentPosition()),!0}else t._autoScrollCurrentlyOutOfBoundary=!1;return!1},i._processAutoScrolling=function(t){var e=this,i=e._isNecessaryAutoScrollBrake(),n=i?.05:1;e._autoScrollAccumulatedTime+=t*(1/n);var r,s=Math.min(1,e._autoScrollAccumulatedTime/e._autoScrollTotalTime);e._autoScrollAttenuate&&(r=s,s=(r-=1)*r*r*r*r+1);var a=e._autoScrollTargetDelta.clone();a.multiplyScalar(s);var o=e._autoScrollStartPosition.clone();o.add(a);var h=Math.abs(s-1)<=ZWt;if(Math.abs(s-1)<=e.getScrollEndedEventTiming()&&!e._isScrollEndedWithThresholdEventFired&&(e._dispatchEvent("scroll-ended-with-threshold"),e._isScrollEndedWithThresholdEventFired=!0),e.elastic){var u=o.clone();u.subtract(e._autoScrollBrakingStartPosition),i&&u.multiplyScalar(n),o.set(e._autoScrollBrakingStartPosition),o.add(u)}else{var l=o.clone();l.subtract(e.getContentPosition());var c=e._getHowMuchOutOfBoundary(l);c.equals(ir.ZERO,ZWt)||(o.add(c),h=!0)}h&&(e._autoScrolling=!1);var f=o.clone();f.subtract(e._getContentPosition()),e._clampDelta(f),e._moveContent(f,h),e._dispatchEvent("scrolling"),e._autoScrolling||(e._isBouncing=!1,e._scrolling=!1,e._dispatchEvent("scroll-ended"))},i._checkMouseWheel=function(t){var e=this;if(!e._getHowMuchOutOfBoundary().equals(ir.ZERO,ZWt))return e._processInertiaScroll(),e._scrolling&&(e._scrolling=!1,e._autoScrolling||e._dispatchEvent("scroll-ended")),e.unschedule(e._checkMouseWheel),void(e._stopMouseWheel=!1);e._mouseWheelEventElapsedTime+=t,e._mouseWheelEventElapsedTime>.1&&(e._onScrollBarTouchEnded(),e._scrolling&&(e._scrolling=!1,e._autoScrolling||e._dispatchEvent("scroll-ended")),e.unschedule(e._checkMouseWheel),e._stopMouseWheel=!1)},i._calculateMovePercentDelta=function(t){var e=t.anchor,i=t.applyToHorizontal,n=t.applyToVertical,r=this;r._calculateBoundary(),e.clampf(ds.ZERO,ds.ONE);var s=r._getContentBottomBoundary()-r._bottomBoundary;s=-s;var a=r._getContentLeftBoundary()-r._leftBoundary;a=-a;var o=new ir;if(r._content&&r.view){var h=0,u=r._content._getUITransformComp().contentSize,l=r.view.contentSize;i&&(h=u.width-l.width,o.x=a-h*e.x),n&&(h=u.height-l.height,o.y=s-h*e.y)}return o},i._moveContentToTopLeft=function(t){var e=this,i=e._getContentBottomBoundary()-e._bottomBoundary;i=-i;var n=new ir,r=0,s=e._getContentLeftBoundary()-e._leftBoundary;if(s=-s,e._content){var a=e._content._getUITransformComp().contentSize;a.height1)for(var n=i[0],r=0;r0){var i=this.node.parent&&this.node.parent._uiProps,n=i&&i.uiTransformComp,r=n?n.contentSize:uh;this.isAlignLeft&&8===t?this._left=e?this._left*r.width:this._left/r.width:this.isAlignRight&&32===t?this._right=e?this._right*r.width:this._right/r.width:this.isAlignHorizontalCenter&&16===t?this._horizontalCenter=e?this._horizontalCenter*r.width:this._horizontalCenter/r.width:this.isAlignTop&&1===t?this._top=e?this._top*r.height:this._top/r.height:this.isAlignBottom&&4===t?this._bottom=e?this._bottom*r.height:this._bottom/r.height:this.isAbsoluteVerticalCenter&&2===t&&(this._verticalCenter=this._verticalCenter/r.height),this._recursiveDirty()}},i._registerTargetEvents=function(){var t=this._target||this.node.parent;t&&t.getComponent(lL)&&(t.on("transform-changed",this._setDirtyByMode,this),t.on("size-changed",this._setDirtyByMode,this),t.on("anchor-changed",this._setDirtyByMode,this))},i._unregisterTargetEvents=function(){var t=this._target||this.node.parent;t&&(t.off("transform-changed",this._setDirtyByMode,this),t.off("size-changed",this._setDirtyByMode,this),t.off("anchor-changed",this._setDirtyByMode,this))},i._unregisterOldParentEvents=function(t){var e=this._target||t;e&&(e.off("transform-changed",this._setDirtyByMode,this),e.off("size-changed",this._setDirtyByMode,this))},i._setDirtyByMode=function(){1===this.alignMode&&this._recursiveDirty()},i._setAlign=function(t,e){if(e!==(this._alignFlags&t)>0){var i=(40&t)>0,n=this.node._getUITransformComp();e?(this._alignFlags|=t,i?(this.isAlignHorizontalCenter=!1,this.isStretchWidth&&(this._originalWidth=n.width)):(this.isAlignVerticalCenter=!1,this.isStretchHeight&&(this._originalHeight=n.height))):(i?this.isStretchWidth&&(n.width=this._originalWidth):this.isStretchHeight&&(n.height=this._originalHeight),this._alignFlags&=~t)}},i._recursiveDirty=function(){this._dirty||(this._dirty=!0)},n(e,[{key:"target",get:function(){return this._target},set:function(t){this._target!==t&&(this._unregisterTargetEvents(),this._target=t,this._registerTargetEvents(),this._validateTargetInDEV(),this._recursiveDirty())}},{key:"isAlignTop",get:function(){return(1&this._alignFlags)>0},set:function(t){this._setAlign(1,t),this._recursiveDirty()}},{key:"isAlignBottom",get:function(){return(4&this._alignFlags)>0},set:function(t){this._setAlign(4,t),this._recursiveDirty()}},{key:"isAlignLeft",get:function(){return(8&this._alignFlags)>0},set:function(t){this._setAlign(8,t),this._recursiveDirty()}},{key:"isAlignRight",get:function(){return(32&this._alignFlags)>0},set:function(t){this._setAlign(32,t),this._recursiveDirty()}},{key:"isAlignVerticalCenter",get:function(){return(2&this._alignFlags)>0},set:function(t){t?(this.isAlignTop=!1,this.isAlignBottom=!1,this._alignFlags|=2):this._alignFlags&=-3,this._recursiveDirty()}},{key:"isAlignHorizontalCenter",get:function(){return(16&this._alignFlags)>0},set:function(t){t?(this.isAlignLeft=!1,this.isAlignRight=!1,this._alignFlags|=16):this._alignFlags&=-17,this._recursiveDirty()}},{key:"isStretchWidth",get:function(){return!(40&~this._alignFlags)}},{key:"isStretchHeight",get:function(){return!(5&~this._alignFlags)}},{key:"top",get:function(){return this._top},set:function(t){this._top=t,this._recursiveDirty()}},{key:"editorTop",get:function(){return this._isAbsTop?this._top:100*this._top},set:function(t){this._top=this._isAbsTop?t:t/100,this._recursiveDirty()}},{key:"bottom",get:function(){return this._bottom},set:function(t){this._bottom=t,this._recursiveDirty()}},{key:"editorBottom",get:function(){return this._isAbsBottom?this._bottom:100*this._bottom},set:function(t){this._bottom=this._isAbsBottom?t:t/100,this._recursiveDirty()}},{key:"left",get:function(){return this._left},set:function(t){this._left=t,this._recursiveDirty()}},{key:"editorLeft",get:function(){return this._isAbsLeft?this._left:100*this._left},set:function(t){this._left=this._isAbsLeft?t:t/100,this._recursiveDirty()}},{key:"right",get:function(){return this._right},set:function(t){this._right=t,this._recursiveDirty()}},{key:"editorRight",get:function(){return this._isAbsRight?this._right:100*this._right},set:function(t){this._right=this._isAbsRight?t:t/100,this._recursiveDirty()}},{key:"horizontalCenter",get:function(){return this._horizontalCenter},set:function(t){this._horizontalCenter=t,this._recursiveDirty()}},{key:"editorHorizontalCenter",get:function(){return this._isAbsHorizontalCenter?this._horizontalCenter:100*this._horizontalCenter},set:function(t){this._horizontalCenter=this._isAbsHorizontalCenter?t:t/100,this._recursiveDirty()}},{key:"verticalCenter",get:function(){return this._verticalCenter},set:function(t){this._verticalCenter=t,this._recursiveDirty()}},{key:"editorVerticalCenter",get:function(){return this._isAbsVerticalCenter?this._verticalCenter:100*this._verticalCenter},set:function(t){this._verticalCenter=this._isAbsVerticalCenter?t:t/100,this._recursiveDirty()}},{key:"isAbsoluteTop",get:function(){return this._isAbsTop},set:function(t){this._isAbsTop!==t&&(this._isAbsTop=t,this._autoChangedValue(1,this._isAbsTop))}},{key:"isAbsoluteBottom",get:function(){return this._isAbsBottom},set:function(t){this._isAbsBottom!==t&&(this._isAbsBottom=t,this._autoChangedValue(4,this._isAbsBottom))}},{key:"isAbsoluteLeft",get:function(){return this._isAbsLeft},set:function(t){this._isAbsLeft!==t&&(this._isAbsLeft=t,this._autoChangedValue(8,this._isAbsLeft))}},{key:"isAbsoluteRight",get:function(){return this._isAbsRight},set:function(t){this._isAbsRight!==t&&(this._isAbsRight=t,this._autoChangedValue(32,this._isAbsRight))}},{key:"isAbsoluteHorizontalCenter",get:function(){return this._isAbsHorizontalCenter},set:function(t){this._isAbsHorizontalCenter!==t&&(this._isAbsHorizontalCenter=t,this._autoChangedValue(16,this._isAbsHorizontalCenter))}},{key:"isAbsoluteVerticalCenter",get:function(){return this._isAbsVerticalCenter},set:function(t){this._isAbsVerticalCenter!==t&&(this._isAbsVerticalCenter=t,this._autoChangedValue(2,this._isAbsVerticalCenter))}},{key:"alignMode",get:function(){return this._alignMode},set:function(t){this._alignMode=t,this._recursiveDirty()}},{key:"alignFlags",get:function(){return this._alignFlags},set:function(t){this._alignFlags!==t&&(this._alignFlags=t,this._recursiveDirty())}}]),e}(yg),nqt.AlignMode=hqt,v((Vjt=nqt).prototype,"target",[Rjt],Object.getOwnPropertyDescriptor(Vjt.prototype,"target"),Vjt.prototype),v(Vjt.prototype,"alignMode",[Fjt],Object.getOwnPropertyDescriptor(Vjt.prototype,"alignMode"),Vjt.prototype),Njt=zh(Vjt.prototype,"_alignFlags",[uu],(function(){return 0})),zjt=zh(Vjt.prototype,"_target",[uu],(function(){return null})),Ujt=zh(Vjt.prototype,"_left",[uu],(function(){return 0})),Gjt=zh(Vjt.prototype,"_right",[uu],(function(){return 0})),Hjt=zh(Vjt.prototype,"_top",[uu],(function(){return 0})),Wjt=zh(Vjt.prototype,"_bottom",[uu],(function(){return 0})),jjt=zh(Vjt.prototype,"_horizontalCenter",[uu],(function(){return 0})),qjt=zh(Vjt.prototype,"_verticalCenter",[uu],(function(){return 0})),Xjt=zh(Vjt.prototype,"_isAbsLeft",[uu],(function(){return!0})),Yjt=zh(Vjt.prototype,"_isAbsRight",[uu],(function(){return!0})),Jjt=zh(Vjt.prototype,"_isAbsTop",[uu],(function(){return!0})),Kjt=zh(Vjt.prototype,"_isAbsBottom",[uu],(function(){return!0})),Qjt=zh(Vjt.prototype,"_isAbsHorizontalCenter",[uu],(function(){return!0})),Zjt=zh(Vjt.prototype,"_isAbsVerticalCenter",[uu],(function(){return!0})),$jt=zh(Vjt.prototype,"_originalWidth",[uu],(function(){return 0})),tqt=zh(Vjt.prototype,"_originalHeight",[uu],(function(){return 0})),eqt=zh(Vjt.prototype,"_alignMode",[uu],(function(){return 2})),iqt=zh(Vjt.prototype,"_lockFlags",[uu,cu],(function(){return 0})),Ljt=Vjt))||Ljt)||Ljt)||Ljt));A.internal.computeInverseTransForTarget=oqt,A.internal.getReadonlyNodeSize=aqt,A.Widget=wqt;var xqt=new cr,Tqt={HORIZONTAL:0,VERTICAL:1};Re(Tqt);var Aqt,Cqt,Dqt,Bqt,Iqt,Mqt,Pqt,Eqt,Oqt,kqt,Rqt,Fqt,Lqt,Vqt,Nqt,zqt,Uqt,Gqt,Hqt,Wqt,jqt,qqt,Xqt,Yqt,Jqt=t("h2",(uqt=Kh("cc.PageViewIndicator"),lqt=Zh(110),cqt=Ou(nR),fqt=Ou(Tqt),_qt=Ou(ms),uqt(dqt=lqt((bqt=function(t){function e(){var e;return(e=t.call(this)||this).spacing=mqt&&mqt(),e._spriteFrame=gqt&&gqt(),e._direction=yqt&&yqt(),e._cellSize=vqt&&vqt(),e._layout=null,e._pageView=null,e._indicators=[],e}s(e,t);var i=e.prototype;return i.onLoad=function(){this._updateLayout()},i.setPageView=function(t){this._pageView=t,this._refresh()},i._updateLayout=function(){this._layout=this.getComponent(qHt),this._layout||(this._layout=this.addComponent(qHt));var t=this._layout;0===this.direction?(t.type=1,t.spacingX=this.spacing):1===this.direction&&(t.type=2,t.spacingY=this.spacing),t.resizeMode=1},i._createIndicator=function(){var t=new eb;t.layer=this.node.layer;var e=t.addComponent(GV);return e.spriteFrame=this.spriteFrame,e.sizeMode=0,t.parent=this.node,t._getUITransformComp().setContentSize(this._cellSize),t},i._changedState=function(){var t=this._indicators;if(0!==t.length&&this._pageView){var e=this._pageView.curPageIdx;if(!(e>=t.length)){for(var i=0;it.length)for(i=0;i0;--i){var n=t[i-1];this.node.removeChild(n),t.splice(i-1,1)}this._layout&&this._layout.enabledInHierarchy&&this._layout.updateLayout(),this._changedState()}}},n(e,[{key:"spriteFrame",get:function(){return this._spriteFrame},set:function(t){this._spriteFrame!==t&&(this._spriteFrame=t)}},{key:"direction",get:function(){return this._direction},set:function(t){this._direction!==t&&(this._direction=t)}},{key:"cellSize",get:function(){return this._cellSize},set:function(t){this._cellSize!==t&&(this._cellSize=t)}}]),e}(yg),bqt.Direction=Tqt,v((pqt=bqt).prototype,"spriteFrame",[cqt],Object.getOwnPropertyDescriptor(pqt.prototype,"spriteFrame"),pqt.prototype),v(pqt.prototype,"direction",[fqt],Object.getOwnPropertyDescriptor(pqt.prototype,"direction"),pqt.prototype),v(pqt.prototype,"cellSize",[_qt],Object.getOwnPropertyDescriptor(pqt.prototype,"cellSize"),pqt.prototype),mqt=zh(pqt.prototype,"spacing",[uu],(function(){return 0})),gqt=zh(pqt.prototype,"_spriteFrame",[uu],(function(){return null})),yqt=zh(pqt.prototype,"_direction",[uu],(function(){return 0})),vqt=zh(pqt.prototype,"_cellSize",[uu],(function(){return new ms(20,20)})),dqt=pqt))||dqt)||dqt));C.PageViewIndicator=Jqt;var Kqt=new ds,Qqt={Unified:0,Free:1};Re(Qqt);var Zqt={HORIZONTAL:0,VERTICAL:1};Re(Zqt);var $qt=t("h1",(Aqt=Kh("cc.PageView"),Cqt=Zh(110),Dqt=Ou(Qqt),Bqt=Ou(Zqt),Iqt=Ou(Jqt),Mqt=Ou(mWt),Pqt=Ou(mWt),Eqt=Ou([mg]),Oqt=Ou([mg]),Aqt(kqt=Cqt((Yqt=function(t){function e(){var e;return(e=t.call(this)||this).autoPageTurningThreshold=Fqt&&Fqt(),e.horizontal=Lqt&&Lqt(),e.vertical=Vqt&&Vqt(),e.cancelInnerEvents=Nqt&&Nqt(),e.scrollEvents=zqt&&zqt(),e.pageTurningSpeed=Uqt&&Uqt(),e.pageEvents=Gqt&&Gqt(),e._sizeMode=Hqt&&Hqt(),e._direction=Wqt&&Wqt(),e._scrollThreshold=jqt&&jqt(),e._pageTurningEventTiming=qqt&&qqt(),e._indicator=Xqt&&Xqt(),e._curPageIdx=0,e._lastPageIdx=0,e._pages=[],e._initContentPos=nr(),e._scrollCenterOffsetX=[],e._scrollCenterOffsetY=[],e._touchBeganPosition=ps(),e._touchEndPosition=ps(),e}s(e,t);var i=e.prototype;return i.onEnable=function(){t.prototype.onEnable.call(this),this.node.on("size-changed",this._updateAllPagesSize,this),this.node.on(e.EventType.SCROLL_ENG_WITH_THRESHOLD,this._dispatchPageTurningEvent,this)},i.onDisable=function(){t.prototype.onDisable.call(this),this.node.off("size-changed",this._updateAllPagesSize,this),this.node.off(e.EventType.SCROLL_ENG_WITH_THRESHOLD,this._dispatchPageTurningEvent,this)},i.onLoad=function(){this._initPages(),this.indicator&&this.indicator.setPageView(this)},i.getCurrentPageIndex=function(){return this._curPageIdx},i.setCurrentPageIndex=function(t){this.scrollToPage(t,1)},i.getPages=function(){return this._pages},i.addPage=function(t){t&&-1===this._pages.indexOf(t)&&this.content&&(t._getUITransformComp()?(this.content.addChild(t),this._pages.push(t),this._updatePageView()):it(4301))},i.insertPage=function(t,e){if(!(e<0)&&t&&-1===this._pages.indexOf(t)&&this.content)if(e>=this._pages.length)this.addPage(t);else{if(!t._getUITransformComp())return void it(4301);this._pages.splice(e,0,t),this.content.insertChild(t,e),this._updatePageView()}},i.removePage=function(t){if(t&&this.content){var e=this._pages.indexOf(t);-1!==e?this.removePageAtIndex(e):at(4300,t.name)}},i.removePageAtIndex=function(t){var e=this._pages;if(!(t<0||t>=e.length)){var i=e[t];i&&this.content&&(this.content.removeChild(i),e.splice(t,1),this._updatePageView())}},i.removeAllPages=function(){if(this.content){for(var t=this._pages,e=0,i=t.length;e=this._pages.length||(this._curPageIdx=t,this.scrollToOffset(this._moveOffsetValue(t),e,!0),this.indicator&&this.indicator._changedState())},i.getScrollEndedEventTiming=function(){return this.pageTurningEventTiming},i._updatePageView=function(){if(this.content){var t=this.content.getComponent(qHt);t&&t.enabled&&t.updateLayout();var e=this._pages.length;this._curPageIdx>=e&&(this._curPageIdx=0===e?0:e-1,this._lastPageIdx=this._curPageIdx);for(var i=this._initContentPos,n=0;n0){var i=this._pages[0]._getUITransformComp(),n=this._pages[this._pages.length-1]._getUITransformComp();0===this.direction?(e.paddingLeft=(t.width-i.width)/2,e.paddingRight=(t.width-n.width)/2):1===this.direction&&(e.paddingTop=(t.height-i.height)/2,e.paddingBottom=(t.height-n.height)/2)}e.updateLayout()}}},i._initPages=function(){if(this.content){this._initContentPos=this.content.position;for(var t=this.content.children,e=0;e=0||this._pages.push(i)}this._syncScrollDirection(),this._syncSizeMode(),this._updatePageView()}},i._dispatchPageTurningEvent=function(){this._lastPageIdx!==this._curPageIdx&&(this._lastPageIdx=this._curPageIdx,mg.emitEvents(this.pageEvents,this,"page-turning"),this.node.emit("page-turning",this))},i._isQuicklyScrollable=function(t){if(0===this.direction){if(Math.abs(t.x)>this.autoPageTurningThreshold)return!0}else if(1===this.direction&&Math.abs(t.y)>this.autoPageTurningThreshold)return!0;return!1},i._moveOffsetValue=function(t){var e=new ds;if(1===this._sizeMode)0===this.direction?e.x=this._scrollCenterOffsetX[t]:1===this.direction&&(e.y=this._scrollCenterOffsetY[t]);else{var i=this.view;if(!i)return e;0===this.direction?e.x=t*i.width:1===this.direction&&(e.y=t*i.height)}return e},i._getDragDirection=function(t){return 0===this._direction?0===t.x?0:t.x>0?1:-1:0===t.y?0:t.y<0?1:-1},i._isScrollable=function(t,e,i){if(1===this._sizeMode){var n=0,r=0;if(0===this.direction)return n=this._scrollCenterOffsetX[e],r=this._scrollCenterOffsetX[i],Math.abs(t.x)>=Math.abs(n-r)*this.scrollThreshold;if(1===this.direction)return n=this._scrollCenterOffsetY[e],r=this._scrollCenterOffsetY[i],Math.abs(t.y)>=Math.abs(n-r)*this.scrollThreshold}else{var s=this.view;if(!s)return!1;if(0===this.direction)return Math.abs(t.x)>=s.width*this.scrollThreshold;if(1===this.direction)return Math.abs(t.y)>=s.height*this.scrollThreshold}return!1},i._autoScrollToPage=function(){if(this._startBounceBackIfNeeded()){var t=this._getHowMuchOutOfBoundary();this._clampDelta(t),(t.x>0||t.y<0)&&(this._curPageIdx=0===this._pages.length?0:this._pages.length-1),(t.x<0||t.y>0)&&(this._curPageIdx=0),this.indicator&&this.indicator._changedState()}else{var e=new ds;ds.subtract(e,this._touchBeganPosition,this._touchEndPosition);var i=this._curPageIdx,n=i+this._getDragDirection(e),r=this.pageTurningSpeed*Math.abs(i-n);if(n1e-10?e:t}var n=t.node,r=n.parent;if(r){var s=rXt;s.set(0,0);var a=sXt;if(a.set(1,1),t.target&&oqt(n,r=t.target,s,a),!e)return;var o=r._uiProps&&r._getUITransformComp(),h=o?o.anchorPoint:eXt,u=n._getUITransformComp(),l=aqt(r),c=u.anchorPoint,f=n.position,_=Sqt,d=n.scale,p=0;if(e&_.LEFT){var m=-h.x*l.width;m+=s.x,m*=a.x,p=f.x-c.x*u.width*Math.abs(d.x)-m,t.isAbsoluteLeft||(p/=l.width),p/=a.x,t.left=i(t.left,p)}if(e&_.RIGHT){var g=(1-h.x)*l.width;g+=s.x,p=(g*=a.x)-(f.x+(1-c.x)*u.width*Math.abs(d.x)),t.isAbsoluteRight||(p/=l.width),p/=a.x,t.right=i(t.right,p)}if(e&_.TOP){var y=(1-h.y)*l.height;y+=s.y,p=(y*=a.y)-(f.y+(1-c.y)*u.height*Math.abs(d.y)),t.isAbsoluteTop||(p/=l.height),p/=a.y,t.top=i(t.top,p)}if(e&_.BOT){var v=-h.y*l.height;v+=s.y,v*=a.y,p=f.y-c.y*u.height*Math.abs(d.y)-v,t.isAbsoluteBottom||(p/=l.height),p/=a.y,t.bottom=i(t.bottom,p)}}},updateAlignment:function t(e){var i=e.parent;i&&eb.isNode(i)&&t(i);var n=e.getComponent(wqt);n&&i&&aXt(e,n)},AlignMode:hqt,AlignFlags:Sqt});YE.on("director_init",(function(){_Xt.init()}));var dXt,pXt,mXt,gXt,yXt,vXt,bXt,SXt,wXt,xXt,TXt,AXt,CXt=t("h3",Kh("cc.SafeArea")(uXt=Zh(110)(uXt=Qh(wqt)((lXt=function(t){function e(){var e;return(e=t.call(this)||this)._symmetric=cXt&&cXt(),e}s(e,t);var i=e.prototype;return i.onEnable=function(){this.updateArea(),sh.on("window-resize",this.updateArea,this),sh.on("orientation-change",this.updateArea,this)},i.onDisable=function(){sh.off("window-resize",this.updateArea,this),sh.off("orientation-change",this.updateArea,this)},i.updateArea=function(){var t=this.node.getComponent(wqt),e=this.node.getComponent(lL);if(t&&e){t.updateAlignment();var i=this.node.position.clone(),n=e.anchorPoint.clone();t.isAlignTop=t.isAlignBottom=t.isAlignLeft=t.isAlignRight=!0;var r=zO.getVisibleSize(),s=r.width,a=r.height,o=hh.getSafeAreaRect(this._symmetric);t.top=a-o.y-o.height,t.bottom=o.y,t.left=o.x,t.right=s-o.x-o.width,t.updateAlignment();var h=this.node.position.clone(),u=n.x-(h.x-i.x)/e.width,l=n.y-(h.y-i.y)/e.height;e.setAnchorPoint(u,l),_Xt.add(t)}},n(e,[{key:"symmetric",get:function(){return this._symmetric},set:function(t){this._symmetric=t}}]),e}(yg),cXt=zh(lXt.prototype,"_symmetric",[uu],(function(){return!0})),uXt=lXt))||uXt)||uXt)||uXt);C.SafeArea=CXt;var DXt,BXt=t("h4",(dXt=Kh("cc.UICoordinateTracker"),pXt=Zh(110),mXt=Ou(eb),gXt=Ou(iU),yXt=Ou([mg]),dXt(vXt=pXt((bXt=function(t){function e(){var e;return(e=t.call(this)||this).syncEvents=SXt&&SXt(),e._target=wXt&&wXt(),e._camera=xXt&&xXt(),e._useScale=TXt&&TXt(),e._distance=AXt&&AXt(),e._transformPos=nr(),e._viewPos=nr(),e._canMove=!0,e._lastWPos=nr(),e._lastCameraPos=nr(),e}s(e,t);var i=e.prototype;return i.onEnable=function(){this._checkCanMove()},i.update=function(){var t=this.node.worldPosition,e=this._camera;if(this._canMove&&e&&e.camera&&(!this._lastWPos.equals(t)||!this._lastCameraPos.equals(e.node.worldPosition))&&(this._lastWPos.set(t),this._lastCameraPos.set(e.node.worldPosition),e.camera.update(),e.convertToUINode(t,this._target,this._transformPos),this._useScale&&ir.transformMat4(this._viewPos,this.node.worldPosition,e.camera.matView),this.syncEvents.length>0)){var i=this._distance/Math.abs(this._viewPos.z);mg.emitEvents(this.syncEvents,this._transformPos,i)}},i._checkCanMove=function(){this._canMove=!(!this._camera||!this._target)},n(e,[{key:"target",get:function(){return this._target},set:function(t){this._target!==t&&(this._target=t,this._checkCanMove())}},{key:"camera",get:function(){return this._camera},set:function(t){this._camera!==t&&(this._camera=t,this._checkCanMove())}},{key:"useScale",get:function(){return this._useScale},set:function(t){this._useScale!==t&&(this._useScale=t)}},{key:"distance",get:function(){return this._distance},set:function(t){this._distance!==t&&(this._distance=t)}}]),e}(yg),v(bXt.prototype,"target",[mXt],Object.getOwnPropertyDescriptor(bXt.prototype,"target"),bXt.prototype),v(bXt.prototype,"camera",[gXt],Object.getOwnPropertyDescriptor(bXt.prototype,"camera"),bXt.prototype),SXt=zh(bXt.prototype,"syncEvents",[yXt,uu],(function(){return[]})),wXt=zh(bXt.prototype,"_target",[uu],(function(){return null})),xXt=zh(bXt.prototype,"_camera",[uu],(function(){return null})),TXt=zh(bXt.prototype,"_useScale",[uu],(function(){return!0})),AXt=zh(bXt.prototype,"_distance",[uu],(function(){return 1})),vXt=bXt))||vXt)||vXt)),IXt=["touch-start","touch-end","touch-move","mouse-down","mouse-move","mouse-up","mouse-enter","mouse-leave","mouse-wheel"];function MXt(t){t.propagationStopped=!0}var PXt,EXt,OXt,kXt,RXt,FXt=t("h5",Kh("cc.BlockInputEvents")(DXt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.onEnable=function(){for(var t=0;tn?n:i;e.width*=r,e.height*=r;var s=zO.getViewportRect(),a=e.getBoundingBoxToWorld(),o=zO.getVisibleSize(),h=sh.devicePixelRatio,u=(s.width*(a.x/o.width)+s.x)/h,l=(s.height*(a.y/o.height)+s.y)/h,c=s.width*(a.width/o.width)/h,f=s.height*(a.height/o.height)/h;this._openDataContext.postMessage({fromEngine:!0,type:"engine",event:"viewport",x:u,y:l,width:c,height:f})}},i._updateSubContextTexture=function(){var t=this._imageAsset;if(t&&this._openDataContext&&!(t.width<=0||t.height<=0)){var e=this._openDataContext.canvas;t.reset(e),(e.width>t.width||e.height>t.height)&&this._texture.create(e.width,e.height),this._texture.uploadData(e)}},i._registerNodeEvent=function(){this.node.on("transform-changed",this._updateSubContextView,this),this.node.on("size-changed",this._updateSubContextView,this),this.node.on("layer-changed",this._updateContentLayer,this)},i._unregisterNodeEvent=function(){this.node.off("transform-changed",this._updateSubContextView,this),this.node.off("size-changed",this._updateSubContextView,this),this.node.off("layer-changed",this._updateContentLayer,this)},i._updateContentLayer=function(){this._content.layer=this.node.layer},i.update=function(t){void 0===t?this._updateSubContextTexture():performance.now()-this._updatedTime>=this._updateInterval&&(this._updatedTime+=this._updateInterval,this._updateSubContextTexture())},i.onDestroy=function(){this._content.destroy(),this._texture.destroy(),this._sprite&&this._sprite.destroy(),this._imageAsset.destroy(),this._openDataContext=null},n(e,[{key:"designResolutionSize",get:function(){return this._designResolutionSize},set:function(){}},{key:"fps",get:function(){return this._fps},set:function(t){this._fps!==t&&(this._fps=t,this._updateInterval=1e3/t)}}]),e}(yg),OXt=zh(EXt.prototype,"_fps",[uu],(function(){return 60})),kXt=zh(EXt.prototype,"_designResolutionSize",[uu],(function(){return new ms(640,960)})),PXt=EXt))||PXt)||PXt)||PXt);C.SubContextView=LXt,Dt({ButtonComponent:{newName:"Button",since:"1.2.0",removed:!1},EditBoxComponent:{newName:"EditBox",since:"1.2.0",removed:!1},LayoutComponent:{newName:"Layout",since:"1.2.0",removed:!1},ProgressBarComponent:{newName:"ProgressBar",since:"1.2.0",removed:!1},ScrollViewComponent:{newName:"ScrollView",since:"1.2.0",removed:!1},ScrollBarComponent:{newName:"ScrollBar",since:"1.2.0",removed:!1},SliderComponent:{newName:"Slider",since:"1.2.0",removed:!1},ToggleComponent:{newName:"Toggle",since:"1.2.0",removed:!1},ToggleContainerComponent:{newName:"ToggleContainer",since:"1.2.0",removed:!1},WidgetComponent:{newName:"Widget",since:"1.2.0",removed:!1},PageViewComponent:{newName:"PageView",since:"1.2.0",removed:!1},PageViewIndicatorComponent:{newName:"PageViewIndicator",since:"1.2.0",removed:!1},SafeAreaComponent:{newName:"SafeArea",since:"1.2.0",removed:!1},UICoordinateTrackerComponent:{newName:"UICoordinateTracker",since:"1.2.0",removed:!1},BlockInputEventsComponent:{newName:"BlockInputEvents",since:"1.2.0",removed:!1}});var VXt,NXt,zXt,UXt,GXt,HXt,WXt,jXt=t("hb",Kh("cc.UIReorderComponent")(RXt=function(){at(1408,"UIReorderComponent")})||RXt);C.UIReorderComponent=jXt,C.ButtonComponent=uGt,le(uGt,"cc.ButtonComponent"),C.EditBoxComponent=AHt,le(AHt,"cc.EditBoxComponent"),C.LayoutComponent=qHt,le(qHt,"cc.LayoutComponent"),C.ProgressBarComponent=oWt,le(oWt,"cc.ProgressBarComponent"),C.ScrollViewComponent=hjt,le(hjt,"cc.ScrollViewComponent"),C.ScrollBarComponent=mWt,le(mWt,"cc.ScrollBarComponent"),C.SliderComponent=wjt,le(wjt,"cc.SliderComponent"),C.ToggleComponent=Pjt,le(Pjt,"cc.ToggleComponent"),C.ToggleContainerComponent=rqt,le(rqt,"cc.ToggleContainerComponent"),C.WidgetComponent=wqt,le(wqt,"cc.WidgetComponent"),C.PageViewComponent=$qt,le($qt,"cc.PageViewComponent"),C.PageViewIndicatorComponent=Jqt,le(Jqt,"cc.PageViewIndicatorComponent"),C.SafeAreaComponent=CXt,le(CXt,"cc.SafeAreaComponent"),le(BXt,"cc.UICoordinateTrackerComponent"),C.BlockInputEventsComponent=FXt,le(FXt,"cc.BlockInputEventsComponent"),mt(IO.prototype,"View.prototype",[{name:"isAntiAliasEnabled",suggest:"The API of Texture2d have been largely modified, no alternative"},{name:"enableAntiAlias",suggest:"The API of Texture2d have been largely modified, no alternative"}]),gt(IO.prototype,"View.prototype",[{name:"adjustViewportMeta"},{name:"enableAutoFullScreen",suggest:"use screen.requestFullScreen() instead."},{name:"isAutoFullScreenEnabled"},{name:"setCanvasSize",suggest:"setting size in CSS pixels is not recommended, please use screen.windowSize instead."},{name:"getCanvasSize",suggest:"please use screen.windowSize instead."},{name:"getFrameSize",suggest:"getting size in CSS pixels is not recommended, please use screen.windowSize instead."},{name:"setFrameSize",suggest:"setting size in CSS pixels is not recommended, please use screen.windowSize instead."},{name:"getDevicePixelRatio",suggest:"use screen.devicePixelRatio instead."},{name:"convertToLocationInView"},{name:"enableRetina"},{name:"isRetinaEnabled"},{name:"setRealPixelResolution"}]);var qXt,XXt,YXt,JXt=ps(),KXt=t("hc",(VXt=Kh("cc.UISkew"),NXt=Ou(fi),zXt=Ou(ds),VXt(UXt=$h((GXt=function(t){function e(){var e;return(e=t.call(this)||this)._skew=HXt&&HXt(),e._rotational=WXt&&WXt(),e._skewEnabled=!1,e}s(e,t);var i=e.prototype;return i.isSkewEnabled=function(){return this._skewEnabled},i.__preload=function(){this.node._uiProps._uiSkewComp=this},i.onEnable=function(){this._skewEnabled=!0,eb._incSkewCompCount(),this._syncNative(!0),this._updateNodeTransformFlags()},i.onDisable=function(){this._skewEnabled=!1,eb._decSkewCompCount(),this._syncNative(!1),this._updateNodeTransformFlags()},i.onDestroy=function(){this._skewEnabled=!1,this._syncNative(!1),this.node._uiProps._uiSkewComp=null,this._updateNodeTransformFlags()},i._syncNative=function(){},i.setSkew=function(t,e){var i=this._skew;"number"==typeof t?JXt.set(t,e):ds.copy(JXt,t),ds.equals(i,JXt)||(i.set(JXt),this._skewEnabled&&this._updateNodeTransformFlags())},i.getSkew=function(t){return t||(t=new ds),t.set(this._skew)},i._updateNodeTransformFlags=function(){var t=this.node;t.invalidateChildren(8),1&t._eventMask&&t.emit("transform-changed",8)},n(e,[{key:"rotational",get:function(){return this._rotational},set:function(t){this._rotational=t,this._skewEnabled&&this._updateNodeTransformFlags()}},{key:"x",get:function(){return this._skew.x},set:function(t){this._skew.x=t,this._skewEnabled&&this._updateNodeTransformFlags()}},{key:"y",get:function(){return this._skew.y},set:function(t){this._skew.y=t,this._skewEnabled&&this._updateNodeTransformFlags()}},{key:"skew",get:function(){return this._skew},set:function(t){this.setSkew(t)}}]),e}(yg),HXt=zh(GXt.prototype,"_skew",[uu],(function(){return ps()})),WXt=zh(GXt.prototype,"_rotational",[uu],(function(){return!1})),v(GXt.prototype,"rotational",[NXt],Object.getOwnPropertyDescriptor(GXt.prototype,"rotational"),GXt.prototype),v(GXt.prototype,"skew",[zXt],Object.getOwnPropertyDescriptor(GXt.prototype,"skew"),GXt.prototype),UXt=GXt))||UXt)||UXt));A.UISkew=KXt;var QXt=t("hd",Kh("cc.VideoClip")((XXt=function(t){function e(){var e;return(e=t.call(this)||this)._duration=YXt&&YXt(),e._video=null,e}return s(e,t),n(e,[{key:"_nativeAsset",get:function(){return this._video},set:function(t){this._video=t,this._duration=t?t.duration:0}}]),e}(Cm),YXt=zh(XXt.prototype,"_duration",[uu],(function(){return 0})),qXt=XXt))||qXt),ZXt=B.document;function $Xt(t,e,i){var n=ZXt.createElement("video"),r=ZXt.createElement("source");n.appendChild(r);var s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType="blob",s.onload=function(){200===this.status||0===this.status?(r.src=URL.createObjectURL(this.response),i(null,n)):i(new Error(s.status+"(no response)"))},s.onerror=function(){var e="load video failure - "+t;X(e),i(new Error(e))},s.send()}function tYt(t,e,i,n){var r=new QXt;r._nativeUrl=t,r._nativeAsset=e,n(null,r)}Mx.register({".mp4":$Xt,".avi":$Xt,".mov":$Xt,".mpg":$Xt,".mpeg":$Xt,".rm":$Xt,".rmvb":$Xt}),Hx.register({".mp4":tYt,".avi":tYt,".mov":tYt,".mpg":tYt,".mpeg":tYt,".rm":tYt,".rmvb":tYt});var eYt=function(){function t(t){var e=this;this._componentEventList=new Map,this._state="none",this._video=null,this._onInterruptedBegin=void 0,this._onInterruptedEnd=void 0,this._interrupted=!1,this._loaded=!1,this._loadedMeta=!1,this._ignorePause=!1,this._fullScreenOnAwake=!1,this._visible=!0,this._playing=!1,this._cachedCurrentTime=-1,this._waitingFullscreen=!1,this._waitingPlay=!1,this._keepAspectRatio=!1,this._component=null,this._uiTrans=null,this._node=null,this._stayOnBottom=!1,this._dirty=!1,this._forceUpdate=!1,this._w=0,this._h=0,this._m00=0,this._m01=0,this._m04=0,this._m05=0,this._m12=0,this._m13=0,this._component=t,this._node=t.node,this._uiTrans=t.node.getComponent(lL),this._onInterruptedBegin=function(){e.video&&"playing"===e._state&&(e.video.pause(),e._interrupted=!0)},this._onInterruptedEnd=function(){e._interrupted&&e.video&&(e.video.play(),e._interrupted=!1)},C.game.on(C.Game.EVENT_PAUSE,this._onInterruptedBegin),C.game.on(C.Game.EVENT_RESUME,this._onInterruptedEnd)}var e=t.prototype;return e.onLoadedMetadata=function(t){this._loadedMeta=!0,this._forceUpdate=!0,this._visible?this.enable():this.disable(),this.dispatchEvent("meta-loaded");var e=t.target;this._keepAspectRatio&&e&&this.syncUITransform(e.videoWidth,e.videoHeight),this.delayedFullScreen(),this.delayedPlay()},e.onCanPlay=function(){this._loaded=!0,this.dispatchEvent("ready-to-play")},e.onPlay=function(){this._playing=!0,this.dispatchEvent("playing")},e.onPlaying=function(){this.dispatchEvent("playing")},e.onPause=function(){this._playing=!1,this._ignorePause?this._ignorePause=!1:this.dispatchEvent("paused")},e.onStoped=function(){this._playing=!1,this._ignorePause=!1,this.dispatchEvent("stopped")},e.onEnded=function(){this._playing=!1,this.dispatchEvent("completed")},e.onClick=function(){this.dispatchEvent("clicked")},e.onError=function(t){this.dispatchEvent("error");var e=t.target;e&&e.error&&J("Error "+e.error.code+"; details: "+e.error.message)},e.play=function(){this._loadedMeta||this._loaded?this.canPlay():this._waitingPlay=!0},e.delayedPlay=function(){this._waitingPlay&&(this.canPlay(),this._waitingPlay=!1)},e.syncFullScreenOnAwake=function(t){this._fullScreenOnAwake=t,this._loadedMeta||this._loaded?this.canFullScreen(t):this._waitingFullscreen=!0},e.delayedFullScreen=function(){this._waitingFullscreen&&(this.canFullScreen(this._fullScreenOnAwake),this._waitingFullscreen=!1)},e.dispatchEvent=function(t){var e=this._componentEventList.get(t);e&&(this._state=t,e.call(this))},e.syncUITransform=function(t,e){var i=this._uiTrans;i&&(i.width=t,i.height=e)},e.syncCurrentTime=function(){this.video&&-1!==this._cachedCurrentTime&&this.video.currentTime!==this._cachedCurrentTime&&(this.seekTo(this._cachedCurrentTime),this._cachedCurrentTime=-1)},e.destroy=function(){this.removeVideoPlayer(),this._componentEventList.clear(),C.game.off(C.Game.EVENT_PAUSE,this._onInterruptedBegin),C.game.off(C.Game.EVENT_RESUME,this._onInterruptedEnd)},n(t,[{key:"fullScreenOnAwake",get:function(){return this._fullScreenOnAwake}},{key:"loaded",get:function(){return this._loaded}},{key:"componentEventList",get:function(){return this._componentEventList}},{key:"video",get:function(){return this._video}},{key:"state",get:function(){return this._state}},{key:"isPlaying",get:function(){return this._playing}},{key:"UICamera",get:function(){return YE.root.batcher2D.getFirstRenderCamera(this._node)}}]),t}();C.internal.VideoPlayerImpl=eYt;var iYt=B.document,nYt=-Math.pow(2,15),rYt=$r(),sYt=function(t){function e(e){var i;return(i=t.call(this,e)||this)._eventList=new Map,i._clearColorA=-1,i._clearFlag=void 0,i}s(e,t);var i=e.prototype;return i.addListener=function(t,e){this._video&&(this._eventList.set(t,e),this._video.addEventListener(t,e))},i.removeAllListeners=function(){var t=this;this._eventList.forEach((function(e,i){t._video&&t._video.removeEventListener(i,e)})),this._eventList.clear()},i.canPlay=function(){var t=this;if(this.video){var e=this.video.play();B.Promise&&e instanceof Promise&&e.catch((function(){})).then((function(){t.syncCurrentTime()}))}},i.pause=function(){this.video&&(this.video.pause(),this._cachedCurrentTime=this.video.currentTime)},i.resume=function(){this.play()},i.stop=function(){var t=this;this.video&&(this._ignorePause=!0,this.video.currentTime=0,this.video.pause(),this._cachedCurrentTime=0,setTimeout((function(){t._ignorePause=!1,t.dispatchEvent("stopped")}),0))},i.syncClip=function(t){this.removeVideoPlayer(),t&&this.createVideoPlayer(t.nativeUrl)},i.syncURL=function(t){this.removeVideoPlayer(),t&&this.createVideoPlayer(t)},i.syncPlaybackRate=function(t){hh.browserType!==Mo.UC?this.video&&(this.video.playbackRate=t):Y("playbackRate is not supported by the uc mobile browser.")},i.syncVolume=function(t){this.video&&(this.video.volume=t)},i.syncMute=function(t){this.video&&(this.video.muted=t)},i.syncLoop=function(t){this.video&&(this.video.loop=t)},i.getDuration=function(){return this.video?this.video.duration:0},i.getCurrentTime=function(){return this.video?this.video.currentTime:-1},i.seekTo=function(t){this.video&&(this.video.currentTime=t,this._cachedCurrentTime=this.video.currentTime)},i.canFullScreen=function(t){var e=this,i=this._video;if(i&&4===i.readyState)return hh.os===Oo.IOS&&hh.isBrowser?(t?i.webkitEnterFullscreen&&i.webkitEnterFullscreen():i.webkitExitFullscreen&&i.webkitExitFullscreen(),void(this._fullScreenOnAwake=i.webkitDisplayingFullscreen)):oh.supportsFullScreen?void(t?(hh.browserType===Mo.IE&&(i.style.transform=""),i.setAttribute("x5-video-player-fullscreen","true"),oh.requestFullScreen(i,(function(t){var n=hh.browserType===Mo.IE?t.msFullscreenElement:t.fullscreenElement;e._fullScreenOnAwake=n===i}),(function(){e._fullScreenOnAwake=!1}))):(i.removeAttribute("x5-video-player-fullscreen"),oh.exitFullScreen())):(this._fullScreenOnAwake=t,this._forceUpdate=!0,void this.syncMatrix())},i.syncStayOnBottom=function(t){this._video&&(this._video.style["z-index"]=t?nYt:0,this._stayOnBottom=t),this._dirty=!0},i.syncKeepAspectRatio=function(t){this._keepAspectRatio=t,t&&this._loadedMeta&&this._video&&this.syncUITransform(this._video.videoWidth,this._video.videoHeight)},i.removeVideoPlayer=function(){var t=this._video;t&&Ke(XO.container,t)&&(XO.container.removeChild(t),this.removeAllListeners()),this._cachedCurrentTime=0,this._playing=!1,this._loaded=!1,this._loadedMeta=!1,this._video=null},i.createVideoPlayer=function(t){var e=this._video=iYt.createElement("video");e.className="cocosVideo",e.style.visibility="hidden",e.style.position="absolute",e.style.bottom="0px",e.style.left="0px",e.style["transform-origin"]="0px 100% 0px",e.style["-webkit-transform-origin"]="0px 100% 0px",e.setAttribute("preload","auto"),e.setAttribute("webkit-playsinline",""),e.setAttribute("x5-playsinline",""),e.setAttribute("playsinline",""),this._bindDomEvent(),XO.container.appendChild(e);var i=iYt.createElement("source");e.appendChild(i),i.src=t},i._bindDomEvent=function(){this._video,this.addListener("loadedmetadata",this.onLoadedMetadata.bind(this)),this.addListener("canplay",this.onCanPlay.bind(this)),this.addListener("canplaythrough",this.onCanPlay.bind(this)),this.addListener("play",this.onPlay.bind(this)),this.addListener("playing",this.onPlaying.bind(this)),this.addListener("pause",this.onPause.bind(this)),this.addListener("click",this.onClick.bind(this)),this.addListener("ended",this.onEnded.bind(this)),this.addListener("error",this.onError.bind(this))},i.onCanPlay=function(e){var i=e.target;if(!this._loaded||!i)switch(i.readyState){case 1:case 4:t.prototype.onCanPlay.call(this,e)}},i.enable=function(){if(this._video){if(this._visible=!0,"visible"===this._video.style.visibility)return;this._video.style.visibility="visible"}},i.disable=function(t){if(this._video){if(!t&&this._playing&&this._video.pause(),this._visible=!1,"hidden"===this._video.style.visibility)return;this._video.style.visibility="hidden"}},i.syncMatrix=function(){if(this._video&&this._visible&&this._component){var t=this.UICamera;if(t){this._dirty&&(this._dirty=!1,this._stayOnBottom?(this._clearColorA=t.clearColor.w,this._clearFlag=t.clearFlag,t.clearColor.w=0,t.clearFlag=7):this._clearFlag&&(t.clearColor.w=this._clearColorA,t.clearFlag=this._clearFlag,this._clearColorA=-1,this._clearFlag=null)),this._component.node.getWorldMatrix(rYt),t.update(!0),t.worldMatrixToScreen(rYt,rYt,XO.canvas.width,XO.canvas.height);var e=0,i=0;if(this._fullScreenOnAwake?(e=uh.width,i=uh.height):(e=this._uiTrans.contentSize.width,i=this._uiTrans.contentSize.height),this._forceUpdate||this._m00!==rYt.m00||this._m01!==rYt.m01||this._m04!==rYt.m04||this._m05!==rYt.m05||this._m12!==rYt.m12||this._m13!==rYt.m13||this._w!==e||this._h!==i){this._m00=rYt.m00,this._m01=rYt.m01,this._m04=rYt.m04,this._m05=rYt.m05,this._m12=rYt.m12,this._m13=rYt.m13,this._w=e,this._h=i;var n=sh.devicePixelRatio,r=1/n,s=1/n,a=XO.container,o=rYt.m00*r,h=rYt.m01,u=rYt.m04,l=rYt.m05*s;this._video.style.width=this._w+"px",this._video.style.height=this._h+"px",hh.browserType!==Mo.MOBILE_QQ?this._video.style.objectFit=this._keepAspectRatio?"none":"fill":Y("keepAspectRatio is not supported by the qq mobile browser.");var c=this._w*r,f=this._h*s,_=this._uiTrans.anchorPoint,d=_.x,p=_.y,m=c*rYt.m00*d,g=f*rYt.m05*p,y=a&&a.style.paddingLeft?parseInt(a.style.paddingLeft):0,v=a&&a.style.paddingBottom?parseInt(a.style.paddingBottom):0,b="matrix("+o+","+-h+","+-u+","+l+","+(rYt.m12*r-m+y)+","+-(rYt.m13*s-g+v)+")";this._video.style.transform=b,this._video.style["-webkit-transform"]=b,hh.browserType!==Mo.IE&&(this._forceUpdate=!1)}}}},e}(eYt),aYt=function(){function t(){}return t.getImpl=function(t){return new sYt(t)},t}();C.internal.VideoPlayerImplManager=aYt;var oYt,hYt,uYt,lYt,cYt,fYt,_Yt,dYt,pYt,mYt,gYt,yYt,vYt,bYt,SYt,wYt,xYt,TYt,AYt,CYt,DYt,BYt=Ee({REMOTE:0,LOCAL:1}),IYt=t("he",(oYt=Kh("cc.VideoPlayer"),hYt=Qh(lL),uYt=Ou(QXt),lYt=Ou(BYt),cYt=Ou(QXt),fYt=Ou([mg]),oYt(_Yt=hYt((DYt=function(t){function e(){var e;return(e=t.call(this)||this)._resourceType=pYt&&pYt(),e._remoteURL=mYt&&mYt(),e._clip=gYt&&gYt(),e._playOnAwake=yYt&&yYt(),e._volume=vYt&&vYt(),e._mute=bYt&&bYt(),e._playbackRate=SYt&&SYt(),e._loop=wYt&&wYt(),e._fullScreenOnAwake=xYt&&xYt(),e._stayOnBottom=TYt&&TYt(),e._keepAspectRatio=AYt&&AYt(),e._impl=null,e._cachedCurrentTime=0,e.videoPlayerEvent=CYt&&CYt(),e}s(e,t);var i=e.prototype;return i.syncSource=function(){var t=this._impl;t&&(this._resourceType===BYt.REMOTE?t.syncURL(this._remoteURL):t.syncClip(this._clip),this._cachedCurrentTime=0,t.syncLoop(this._loop),t.syncVolume(this._volume),t.syncMute(this._mute),t.seekTo(this._cachedCurrentTime),t.syncPlaybackRate(this._playbackRate),t.syncStayOnBottom(this._stayOnBottom),t.syncKeepAspectRatio(this._keepAspectRatio),t.syncFullScreenOnAwake(this._fullScreenOnAwake))},i.__preload=function(){this._impl=aYt.getImpl(this),this.syncSource();var t=this._impl.componentEventList;t.set("meta-loaded",this.onMetaLoaded.bind(this)),t.set("ready-to-play",this.onReadyToPlay.bind(this)),t.set("playing",this.onPlaying.bind(this)),t.set("paused",this.onPaused.bind(this)),t.set("stopped",this.onStopped.bind(this)),t.set("completed",this.onCompleted.bind(this)),t.set("error",this.onError.bind(this)),t.set("clicked",this.onClicked.bind(this)),this._playOnAwake&&this._impl.loaded&&this.play()},i.onEnable=function(){this._impl&&this._impl.enable()},i.onDisable=function(){this._impl&&this._impl.disable()},i.onDestroy=function(){this._impl&&(this._impl.destroy(),this._impl=null)},i.update=function(){this._impl&&this._impl.syncMatrix()},i.onMetaLoaded=function(){mg.emitEvents(this.videoPlayerEvent,this,"meta-loaded"),this.node.emit("meta-loaded",this)},i.onReadyToPlay=function(){this._playOnAwake&&!this.isPlaying&&this.play(),mg.emitEvents(this.videoPlayerEvent,this,"ready-to-play"),this.node.emit("ready-to-play",this)},i.onPlaying=function(){mg.emitEvents(this.videoPlayerEvent,this,"playing"),this.node.emit("playing",this)},i.onPaused=function(){mg.emitEvents(this.videoPlayerEvent,this,"paused"),this.node.emit("paused",this)},i.onStopped=function(){mg.emitEvents(this.videoPlayerEvent,this,"stopped"),this.node.emit("stopped",this)},i.onCompleted=function(){mg.emitEvents(this.videoPlayerEvent,this,"completed"),this.node.emit("completed",this)},i.onError=function(){mg.emitEvents(this.videoPlayerEvent,this,"error"),this.node.emit("error",this)},i.onClicked=function(){mg.emitEvents(this.videoPlayerEvent,this,"clicked"),this.node.emit("clicked",this)},i.play=function(){this._impl&&this._impl.play()},i.resume=function(){this._impl&&this._impl.resume()},i.pause=function(){this._impl&&this._impl.pause()},i.stop=function(){this._impl&&this._impl.stop()},n(e,[{key:"resourceType",get:function(){return this._resourceType},set:function(t){this._resourceType!==t&&(this._resourceType=t,this.syncSource())}},{key:"remoteURL",get:function(){return this._remoteURL},set:function(t){this._remoteURL!==t&&(this._remoteURL=t,this.syncSource())}},{key:"clip",get:function(){return this._clip},set:function(t){this._clip!==t&&(this._clip=t,this.syncSource())}},{key:"playOnAwake",get:function(){return this._playOnAwake},set:function(t){this._playOnAwake=t}},{key:"playbackRate",get:function(){return this._playbackRate},set:function(t){this._playbackRate=t,this._impl&&this._impl.syncPlaybackRate(t)}},{key:"volume",get:function(){return this._volume},set:function(t){this._volume=t,this._impl&&this._impl.syncVolume(t)}},{key:"mute",get:function(){return this._mute},set:function(t){this._mute=t,this._impl&&this._impl.syncMute(t)}},{key:"loop",get:function(){return this._loop},set:function(t){this._loop=t,this._impl&&this._impl.syncLoop(t)}},{key:"keepAspectRatio",get:function(){return this._keepAspectRatio},set:function(t){this._keepAspectRatio!==t&&(this._keepAspectRatio=t,this._impl&&this._impl.syncKeepAspectRatio(t))}},{key:"fullScreenOnAwake",get:function(){return this._impl?(this._fullScreenOnAwake=this._impl.fullScreenOnAwake,this._fullScreenOnAwake):this._fullScreenOnAwake},set:function(t){this._fullScreenOnAwake!==t&&(this._fullScreenOnAwake=t,this._impl&&this._impl.syncFullScreenOnAwake(t))}},{key:"stayOnBottom",get:function(){return this._stayOnBottom},set:function(t){this._stayOnBottom!==t&&(this._stayOnBottom=t,this._impl&&this._impl.syncStayOnBottom(t))}},{key:"nativeVideo",get:function(){return this._impl&&this._impl.video||null}},{key:"currentTime",get:function(){return this._impl?this._impl.getCurrentTime():this._cachedCurrentTime},set:function(t){Number.isNaN(t)?Y("illegal video time! value:"+t):(t=$i(t,0,this.duration),this._cachedCurrentTime=t,this._impl&&this._impl.seekTo(t))}},{key:"duration",get:function(){return this._impl?this._impl.getDuration():0}},{key:"state",get:function(){return this._impl?this._impl.state:"none"}},{key:"isPlaying",get:function(){return!!this._impl&&this._impl.isPlaying}}]),e}(yg),DYt.EventType={NONE:"none",PLAYING:"playing",PAUSED:"paused",STOPPED:"stopped",COMPLETED:"completed",META_LOADED:"meta-loaded",READY_TO_PLAY:"ready-to-play",ERROR:"error",CLICKED:"clicked"},DYt.ResourceType=BYt,pYt=zh((dYt=DYt).prototype,"_resourceType",[uu],(function(){return BYt.LOCAL})),mYt=zh(dYt.prototype,"_remoteURL",[uu],(function(){return""})),gYt=zh(dYt.prototype,"_clip",[uYt,uu],(function(){return null})),yYt=zh(dYt.prototype,"_playOnAwake",[uu],(function(){return!0})),vYt=zh(dYt.prototype,"_volume",[uu],(function(){return 1})),bYt=zh(dYt.prototype,"_mute",[uu],(function(){return!1})),SYt=zh(dYt.prototype,"_playbackRate",[uu],(function(){return 1})),wYt=zh(dYt.prototype,"_loop",[uu],(function(){return!1})),xYt=zh(dYt.prototype,"_fullScreenOnAwake",[uu],(function(){return!1})),TYt=zh(dYt.prototype,"_stayOnBottom",[uu],(function(){return!1})),AYt=zh(dYt.prototype,"_keepAspectRatio",[uu],(function(){return!0})),v(dYt.prototype,"resourceType",[lYt],Object.getOwnPropertyDescriptor(dYt.prototype,"resourceType"),dYt.prototype),v(dYt.prototype,"clip",[cYt],Object.getOwnPropertyDescriptor(dYt.prototype,"clip"),dYt.prototype),CYt=zh(dYt.prototype,"videoPlayerEvent",[uu,fYt],(function(){return[]})),_Yt=dYt))||_Yt)||_Yt));C.internal.VideoPlayer=IYt,pt(IYt.prototype,"VideoPlayer.prototype",[{name:"onPasued",newName:"onPaused"}]);var MYt=function(){function t(t){this._componentEventList=new Map,this._state="none",this._wrapper=void 0,this._webview=null,this._loaded=!1,this._forceUpdate=!1,this._component=null,this._uiTrans=null,this._node=null,this._w=0,this._h=0,this._m00=0,this._m01=0,this._m04=0,this._m05=0,this._m12=0,this._m13=0,this._component=t,this._node=t.node,this._uiTrans=t.node.getComponent(lL),this.reset(),this.createWebView()}var e=t.prototype;return e.reset=function(){this._wrapper=null,this._webview=null,this._loaded=!1,this._w=0,this._h=0,this._m00=0,this._m01=0,this._m04=0,this._m05=0,this._m12=0,this._m13=0,this._state="none",this._forceUpdate=!1},e.dispatchEvent=function(t){var e=this._componentEventList.get(t);if(e){this._state=t;for(var i=arguments.length,n=new Array(i>1?i-1:0),r=1;r=0;h--){var u=r.array[h];if(u){var l=u.model;l&&l.enabled&&l.node&&((o&l.node.layer)===l.node.layer||o&l.visFlags)&&l.worldBounds&&l.castShadow?Za.aabbFrustum(l.worldBounds,s)&&(a.push(u),i.level>3)]+=(o.isCompositeModeEnabled(u)?1:0)*Math.pow(10,l)}r[19]+=(o.lightingWithAlbedo?1:0)*Math.pow(10,6),r[19]+=(o.csmLayerColoration?1:0)*Math.pow(10,7)}},t.updateCameraUBOView=function(t,e,i){var n,r=(i.scene?i.scene:A.director.getScene().renderScene).mainLight,s=t.pipelineSceneData,a=s.ambient,o=s.skybox,h=s.fog,u=s.shadows,l=e,c=i.exposure,f=s.isHDR;if(l[104]=s.shadingScale,l[105]=s.shadingScale,l[106]=1/l[104],l[107]=1/l[105],l[108]=c,l[109]=1/c,l[110]=f?1:0,l[111]=1/NM.standardExposureValue,r){var _=r.shadowEnabled&&u.type===WT.ShadowMap?1:0,d=r.direction;if(cJt.set(d.x,d.y,d.z,_),dJt(l,cJt,112),ir.toArray(l,r.color,116),r.useColorTemperature){var p=r.colorTemperatureRGB;l[116]*=p.x,l[117]*=p.y,l[118]*=p.z}l[119]=f?r.illuminance*c:r.illuminance}else cJt.set(0,0,1,0),dJt(l,cJt,112),dJt(l,Vn.ZERO,116);var m=a.skyColor;m.w=f?a.skyIllum*c:a.skyIllum,l[120]=m.x,l[121]=m.y,l[122]=m.z,l[123]=m.w,l[124]=a.groundAlbedo.x,l[125]=a.groundAlbedo.y,l[126]=a.groundAlbedo.z,l[127]=o.envmap?null==(n=o.envmap)?void 0:n.mipmapLevel:1,_Jt(l,i.matView,0),_Jt(l,i.node.worldMatrix,16),ir.toArray(l,i.position,96),_Jt(l,i.matProj,32),_Jt(l,i.matProjInv,48),_Jt(l,i.matViewProj,64),_Jt(l,i.matViewProjInv,80),l[99]=this.getCombineSignY(),l[100]=i.surfaceTransform,l[101]=i.cameraUsage,l[102]=Math.cos(nn(s.skybox.getRotationAngle())),l[103]=Math.sin(nn(s.skybox.getRotationAngle()));var g=h.colorArray;l[128]=g.x,l[129]=g.y,l[130]=g.z,l[131]=g.z,l[132]=h.fogStart,l[133]=h.fogEnd,l[134]=h.fogDensity,l[136]=h.fogTop,l[137]=h.fogRange,l[138]=h.fogAtten,l[140]=i.nearClip,l[141]=i.farClip,l[142]=i.getClipSpaceMinz(),l[144]=s.shadingScale*i.window.width*i.viewport.x,l[145]=s.shadingScale*i.window.height*i.viewport.y,l[146]=s.shadingScale*i.window.width*i.viewport.z,l[147]=s.shadingScale*i.window.height*i.viewport.w},t.getPCFRadius=function(t,e){var i=t.size.x;switch(e.shadowPcf){case jT.HARD:return 0;case jT.SOFT:return 1/(.5*i);case jT.SOFT_2X:return 2/(.5*i);case jT.SOFT_4X:return 3/(.5*i)}return 0},t.updatePlanarNormalAndDistance=function(t,e){ir.normalize(fJt,t.normal),e[60]=fJt.x,e[61]=fJt.y,e[62]=fJt.z,e[63]=-t.distance},t.updateShadowUBOView=function(e,i,n,r){var s=e.device,a=r.scene.mainLight,o=e.pipelineSceneData,h=o.shadows,u=o.csmLayers,l=i,c=n,f=o.csmSupported,_=jS(s)?0:1;if(a&&h.enabled){if(h.type===WT.ShadowMap){if(a.shadowEnabled){if(a.shadowFixedArea||a.csmLevel===qT.LEVEL_1||!f){var d=u.specialLayer.matShadowView,p=u.specialLayer.matShadowProj,m=u.specialLayer.matShadowViewProj,g=.1,y=0,v=0;a.shadowFixedArea?(g=a.shadowNear,y=a.shadowFar,v=0):(y=u.specialLayer.shadowCameraFar,v=1),_Jt(l,d,0),l[36]=p.m10,l[37]=p.m14,l[38]=p.m11,l[39]=p.m15,l[40]=p.m00,l[41]=p.m05,l[42]=1/p.m00,l[43]=1/p.m05,_Jt(l,m,16),lJt.set(g,y,0,1-a.shadowSaturation),dJt(l,lJt,44),lJt.set(0,_,a.shadowNormalBias,v),dJt(l,lJt,52)}else{for(var b=this.getPCFRadius(h,a),S=0;S0){var o=a;a=s,s=o}var h=0;switch(t){case 0:h=0,i[h++]=-1,i[h++]=-1,i[h++]=n,i[h++]=a,i[h++]=1,i[h++]=-1,i[h++]=r,i[h++]=a,i[h++]=-1,i[h++]=1,i[h++]=n,i[h++]=s,i[h++]=1,i[h++]=1,i[h++]=r,i[h++]=s;break;case 1:h=0,i[h++]=-1,i[h++]=-1,i[h++]=r,i[h++]=a,i[h++]=1,i[h++]=-1,i[h++]=r,i[h++]=s,i[h++]=-1,i[h++]=1,i[h++]=n,i[h++]=a,i[h++]=1,i[h++]=1,i[h++]=n,i[h++]=s;break;case 2:h=0,i[h++]=-1,i[h++]=-1,i[h++]=n,i[h++]=s,i[h++]=1,i[h++]=-1,i[h++]=r,i[h++]=s,i[h++]=-1,i[h++]=1,i[h++]=n,i[h++]=a,i[h++]=1,i[h++]=1,i[h++]=r,i[h++]=a;break;case 3:h=0,i[h++]=-1,i[h++]=-1,i[h++]=n,i[h++]=s,i[h++]=1,i[h++]=-1,i[h++]=n,i[h++]=a,i[h++]=-1,i[h++]=1,i[h++]=r,i[h++]=s,i[h++]=1,i[h++]=1,i[h++]=r,i[h++]=a}return i},i._createQuadInputAssembler=function(){var t=new QE,e=this._device.createBuffer(new ud(10,3,64,16));if(!e)return t;var i=this._device.createBuffer(new ud(6,1,6,1));if(!i)return t;var n=new Uint8Array(6);n[0]=0,n[1]=1,n[2]=2,n[3]=1,n[4]=3,n[5]=2,i.update(n);var r=new Array(2);r[0]=new Cd("a_position",21),r[1]=new Cd("a_texCoord",21);var s=this._device.createInputAssembler(new Bd(r,[e],i));return t.quadIB=i,t.quadVB=e,t.quadIA=s,t},i.updateQuadVertexData=function(t,e){var i=this._lastUsedRenderArea;if(i.x!==t.x||i.y!==t.y||i.width!==t.width||i.height!==t.height){var n=this._genQuadVertexData(0,t);this._quadVBOffscreen.update(n);var r=this._genQuadVertexData(e.swapchain&&e.swapchain.surfaceTransform||0,t);this._quadVBOnscreen.update(r),i.copy(t)}},i.destroy=function(){for(var e,i,n=0;n>1,r>>1)),t.prefilterFramebuffer=e.createFramebuffer(new Vd(t.renderPass,[t.prefiterTex])),n>>=1,r>>=1;for(var s=0;s<6;++s)t.downsampleTexs.push(e.createTexture(new dd(1,20,35,n>>1,r>>1))),t.downsampleFramebuffers[s]=e.createFramebuffer(new Vd(t.renderPass,[t.downsampleTexs[s]])),t.upsampleTexs.push(e.createTexture(new dd(1,20,35,n,r))),t.upsampleFramebuffers[s]=e.createFramebuffer(new Vd(t.renderPass,[t.upsampleTexs[s]])),n>>=1,r>>=1;t.combineTex=e.createTexture(new dd(1,20,35,this._width,this._height)),t.combineFramebuffer=e.createFramebuffer(new Vd(t.renderPass,[t.combineTex])),t.sampler=this.globalDSManager.linearSampler}},i.on=function(t,e,i,n){return this._eventProcessor.on(t,e,i,n)},i.once=function(t,e,i){return this._eventProcessor.once(t,e,i)},i.off=function(t,e,i){this._eventProcessor.off(t,e,i)},i.emit=function(t,e,i,n,r,s){this._eventProcessor.emit(t,e,i,n,r,s)},i.targetOff=function(t){this._eventProcessor.targetOff(t)},i.removeAll=function(t){this._eventProcessor.removeAll(t)},i.hasEventListener=function(t,e,i){return this._eventProcessor.hasEventListener(t,e,i)},n(e,[{key:"tag",get:function(){return this._tag}},{key:"flows",get:function(){return this._flows}},{key:"quadIAOnscreen",get:function(){return this._quadIAOnscreen}},{key:"quadIAOffscreen",get:function(){return this._quadIAOffscreen}},{key:"constantMacros",get:function(){return this._constantMacros}},{key:"macros",get:function(){return this._macros}},{key:"device",get:function(){return this._device}},{key:"globalDSManager",get:function(){return this._globalDSManager}},{key:"descriptorSetLayout",get:function(){return this._globalDSManager.descriptorSetLayout}},{key:"descriptorSet",get:function(){return this._descriptorSet}},{key:"commandBuffers",get:function(){return this._commandBuffers}},{key:"pipelineUBO",get:function(){return this._pipelineUBO}},{key:"pipelineSceneData",get:function(){return this._pipelineSceneData}},{key:"profiler",get:function(){return this._profiler},set:function(t){this._profiler=t}},{key:"geometryRenderer",get:function(){return this._geometryRenderer}},{key:"clusterEnabled",get:function(){return this._clusterEnabled},set:function(t){this._clusterEnabled=t}},{key:"bloomEnabled",get:function(){return this._bloomEnabled},set:function(t){this._bloomEnabled=t}},{key:"shadingScale",get:function(){return this._pipelineSceneData.shadingScale},set:function(t){this._pipelineSceneData.shadingScale!==t&&(this._pipelineSceneData.shadingScale=t,this.emit("attachment-scale-changed",t))}}]),e}(Cm),MJt=zh(IJt.prototype,"_tag",[uu],(function(){return 0})),PJt=zh(IJt.prototype,"_flows",[DJt,uu],(function(){return[]})),BJt=IJt))||BJt));function VJt(t,e){return t.hash-e.hash||t.depth-e.depth||t.shaderId-e.shaderId}function NJt(t,e){return t.priority-e.priority||t.hash-e.hash||e.depth-t.depth||t.shaderId-e.shaderId}A.RenderPipeline=LJt,gt(LJt.prototype,"RenderPipeline.prototype",[{name:"geometryRenderer",suggest:"please use camera.geometryRenderer instead."}]);var zJt=function(){function t(t){this._passDesc=t,this._passPool=new uo((function(){return{priority:0,hash:0,depth:0,shaderId:0,subModel:null,passIdx:0}}),64),this.queue=new lo(64,this._passDesc.sortFunc)}var e=t.prototype;return e.clear=function(){this.queue.clear(),this._passPool.reset()},e.insertRenderPass=function(t,e,i){var n=t.model.subModels[e],r=n.passes[i],s=n.shaders[i];if(r.blendState.targets[0].blend!==this._passDesc.isTransparent||!(r.phase&this._passDesc.phases))return!1;var a=r.priority<<16|n.priority<<8|i,o=this._passPool.add();return o.priority=t.model.priority,o.hash=a,o.depth=t.depth||0,o.shaderId=s.typedID,o.subModel=n,o.passIdx=i,this.queue.push(o),!0},e.sort=function(){this.queue.sort()},e.recordCommandBuffer=function(t,e,i){for(var n=0;n0)))for(var a=0;athis._lightBufferCount&&(this._firstLightBufferView.destroy(),this._lightBufferCount=fn(a.length),this._lightBuffer.resize(this._lightBufferStride*this._lightBufferCount),this._lightBufferData=new Float32Array(this._lightBufferElementCount*this._lightBufferCount),this._firstLightBufferView=Wp.gfxDevice.createBuffer(new ld(this._lightBuffer,0,80)));for(var o=0,h=0;o-1&&this.additiveInstanceQueues.splice(e,1)},i.initialize=function(e){return t.prototype.initialize.call(this,e),e.renderQueues&&(this.renderQueues=e.renderQueues),!0},i.activate=function(e,i){t.prototype.activate.call(this,e,i);for(var n=0;n0?.5*(1-Math.floor(a/2))*h.y:.5*Math.floor(a/2)*h.y,this._renderArea.width=.5*h.x,this._renderArea.height=.5*h.y}break;case 2:this._renderArea.x=0,this._renderArea.y=0,this._renderArea.width=h.x,this._renderArea.height=h.y}var c=this._shadowFrameBuffer.renderPass;s.beginRenderPass(c,this._shadowFrameBuffer,this._renderArea,oZt,t.clearDepth,t.clearStencil),s.bindDescriptorSet(0,r),this._additiveShadowQueue.recordCommandBuffer(o,c,s),s.endRenderPass(),this._isShadowMapCleared=!1}},i.activate=function(e,i){t.prototype.activate.call(this,e,i),this._additiveShadowQueue=new aZt(e),this._isShadowMapCleared=!1},e}(AJt),nZt.initInfo={name:"ShadowStage",priority:10,tag:0},iZt=nZt))||iZt),uZt=[],lZt=t("hq",Kh("ShadowFlow")((sZt=function(t){function e(){var e;return(e=t.call(this)||this)._shadowRenderPass=null,e}s(e,t);var i=e.prototype;return i.initialize=function(e){if(t.prototype.initialize.call(this,e),0===this._stages.length){var i=new hZt;i.initialize(hZt.initInfo),this._stages.push(i)}return!0},i.activate=function(e){t.prototype.activate.call(this,e);var i=jS(e.device)?0:1;e.macros.CC_SHADOWMAP_FORMAT=i;var n=6===e.device.gfxAPI?1:0;e.macros.CC_SHADOWMAP_USE_LINEAR_DEPTH=n,e.pipelineSceneData.csmSupported=e.device.capabilities.maxFragmentUniformVectors>=99,e.macros.CC_SUPPORT_CASCADED_SHADOW_MAP=e.pipelineSceneData.csmSupported,e.macros.CC_SHADOW_TYPE=0,e.macros.CC_DIR_SHADOW_PCF_TYPE=jT.HARD,e.macros.CC_DIR_LIGHT_SHADOW_TYPE=0,e.macros.CC_CASCADED_LAYERS_TRANSITION=0,e.onGlobalPipelineStateChanged()},i.render=function(t){var e=this._pipeline,i=e.pipelineSceneData.shadows,n=e.pipelineSceneData.csmLayers,r=e.pipelineSceneData.shadowFrameBufferMap,s=n.castShadowObjects,a=this._pipeline.pipelineSceneData.validPunctualLights;if(i.enabled&&i.type===WT.ShadowMap){for(var o=0,h=0;o0){this._renderQueues.forEach(HJt);for(var w=0;w0&&(this._stageDesc||(this._stageDesc=i.createDescriptorSet(new Ud(u.localSetLayout)),this._localUBO=i.createBuffer(new ud(18,1,224,224)),this._stageDesc.bindBuffer(0,this._localUBO)),this._stageDesc.update(),r.bindPipelineState(f),r.bindDescriptorSet(1,u.descriptorSet),r.bindDescriptorSet(2,this._stageDesc),r.bindInputAssembler(c),r.draw(c)),this._uiPhase.render(t,h),zT(i,h,r,e.profiler,t),r.endRenderPass()},e}(AJt),QZt.initInfo={name:"PostProcessStage",priority:19,tag:0},JZt=zh((YZt=QZt).prototype,"_postProcessMaterial",[jZt,uu],(function(){return null})),KZt=zh(YZt.prototype,"renderQueues",[qZt,uu],(function(){return[]})),XZt=YZt))||XZt)),p$t=function(t){function e(){var e;return(e=t.call(this)||this)._antiAliasing=0,e}s(e,t);var i=e.prototype;return i.updatePipelineSceneData=function(){this.updatePipelinePassInfo()},i.updateBloomPass=function(){if(this._bloomMaterial){var t=this._bloomMaterial.passes[0];t.beginChangeStatesSilently(),t.tryCompile(),t.endChangeStatesSilently();for(var e=0;e<6;++e){var i=this._bloomMaterial.passes[1+e];i.beginChangeStatesSilently(),i.tryCompile(),i.endChangeStatesSilently();var n=this._bloomMaterial.passes[7+e];n.beginChangeStatesSilently(),n.tryCompile(),n.endChangeStatesSilently()}var r=this._bloomMaterial.passes[13];r.beginChangeStatesSilently(),r.tryCompile(),r.endChangeStatesSilently()}},i.updatePostProcessPass=function(){if(this.postprocessMaterial){var t=this.postprocessMaterial.passes[0];t.beginChangeStatesSilently(),t.tryCompile(),t.endChangeStatesSilently()}},i.initPipelinePassInfo=function(){var t=new GT;t._uuid="builtin-deferred-material",t.initialize({effectName:"pipeline/deferred-lighting"});for(var e=0;e>=1,this._renderArea.height>>=1;var i=e.commandBuffers[0],n=e.pipelineSceneData.bloomMaterial.passes[0],r=e.getPipelineRenderData(),s=r.bloom,a=new Float32Array(g$t.COUNT);a[g$t.TEXTURE_SIZE_OFFSET+2]=this.threshold,i.updateBuffer(this._bloomUBO[0],a),i.beginRenderPass(s.renderPass,s.prefilterFramebuffer,this._renderArea,m$t,0,0),i.bindDescriptorSet(0,e.descriptorSet),n.descriptorSet.bindBuffer(0,this._bloomUBO[0]),n.descriptorSet.bindTexture(1,r.outputRenderTargets[0]),n.descriptorSet.bindSampler(1,s.sampler),n.descriptorSet.update(),i.bindDescriptorSet(1,n.descriptorSet);var o=t.window.swapchain?e.quadIAOffscreen:e.quadIAOnscreen,h=null,u=n.getShaderVariant();null!=n&&null!=u&&null!=o&&(h=AT.getOrCreatePipelineState(e.device,n,u,s.renderPass,o)),null!=h&&(i.bindPipelineState(h),i.bindInputAssembler(o),i.draw(o)),i.endRenderPass()},i._downsamplePass=function(t,e){e.generateRenderArea(t,this._renderArea),this._renderArea.width>>=1,this._renderArea.height>>=1;for(var i=e.commandBuffers[0],n=e.pipelineSceneData.bloomMaterial,r=e.getPipelineRenderData().bloom,s=new Float32Array(g$t.COUNT),a=0;a>=1,this._renderArea.height>>=1,i.beginRenderPass(r.renderPass,r.downsampleFramebuffers[a],this._renderArea,m$t,0,0);var o=n.passes[1+a],h=o.getShaderVariant();o.descriptorSet.bindBuffer(0,this._bloomUBO[a+1]),0===a?o.descriptorSet.bindTexture(1,r.prefiterTex):o.descriptorSet.bindTexture(1,r.downsampleTexs[a-1]),o.descriptorSet.bindSampler(1,r.sampler),o.descriptorSet.update(),i.bindDescriptorSet(1,o.descriptorSet);var u=t.window.swapchain?e.quadIAOffscreen:e.quadIAOnscreen,l=null;null!=o&&null!=h&&null!=u&&(l=AT.getOrCreatePipelineState(e.device,o,h,r.renderPass,u)),null!=l&&(i.bindPipelineState(l),i.bindInputAssembler(u),i.draw(u)),i.endRenderPass()}},i._upsamplePass=function(t,e){var i=e.getPipelineRenderData().bloom;e.generateRenderArea(t,this._renderArea),this._renderArea.width>>=this.iterations+1,this._renderArea.height>>=this.iterations+1;for(var n=e.commandBuffers[0],r=e.pipelineSceneData.bloomMaterial,s=new Float32Array(g$t.COUNT),a=0;a0&&(t.extensions.useVAO&&n.glVAO&&(i.bindVertexArray(null),n.glVAO=null),a0t.gpuInputAssembler=null,n.glArrayBuffer!==e.glBuffer&&(i.bindBuffer(34962,e.glBuffer),n.glArrayBuffer=e.glBuffer),i.bufferData(34962,e.size,r),i.bindBuffer(34962,null),n.glArrayBuffer=null))}else if(4&e.usage){e.glTarget=34963;var a=i.createBuffer();a&&(e.glBuffer=a,e.size>0&&(t.extensions.useVAO&&n.glVAO&&(i.bindVertexArray(null),n.glVAO=null),a0t.gpuInputAssembler=null,n.glElementArrayBuffer!==e.glBuffer&&(i.bindBuffer(34963,e.glBuffer),n.glElementArrayBuffer=e.glBuffer),i.bufferData(34963,e.size,r),i.bindBuffer(34963,null),n.glElementArrayBuffer=null))}else if(16&e.usage){e.glTarget=35345;var o=i.createBuffer();o&&e.size>0&&(e.glBuffer=o,n.glUniformBuffer!==e.glBuffer&&(i.bindBuffer(35345,e.glBuffer),n.glUniformBuffer=e.glBuffer),i.bufferData(35345,e.size,r),i.bindBuffer(35345,null),n.glUniformBuffer=null)}else 64&e.usage||2&e.usage||1&e.usage||ht(16315),e.glTarget=0}function X$t(t,e){var i=t.gl,n=t.getStateCache(),r=t.extensions.useVAO;if(e.glBuffer){switch(e.glTarget){case 34962:r&&n.glVAO&&(i.bindVertexArray(null),n.glVAO=null),a0t.gpuInputAssembler=null,i.bindBuffer(34962,null),n.glArrayBuffer=null;break;case 34963:r&&n.glVAO&&(i.bindVertexArray(null),n.glVAO=null),a0t.gpuInputAssembler=null,i.bindBuffer(34963,null),n.glElementArrayBuffer=null;break;case 35345:i.bindBuffer(35345,null),n.glUniformBuffer=null}i.deleteBuffer(e.glBuffer),e.glBuffer=null}}function Y$t(t,e){var i=t.gl,n=t.getStateCache(),r=2&e.memUsage?35048:35044;8&e.usage?(t.extensions.useVAO&&n.glVAO&&(i.bindVertexArray(null),n.glVAO=null),a0t.gpuInputAssembler=null,n.glArrayBuffer!==e.glBuffer&&i.bindBuffer(34962,e.glBuffer),e.buffer?i.bufferData(34962,e.buffer,r):i.bufferData(34962,e.size,r),i.bindBuffer(34962,null),n.glArrayBuffer=null):4&e.usage?(t.extensions.useVAO&&n.glVAO&&(i.bindVertexArray(null),n.glVAO=null),a0t.gpuInputAssembler=null,n.glElementArrayBuffer!==e.glBuffer&&i.bindBuffer(34963,e.glBuffer),e.buffer?i.bufferData(34963,e.buffer,r):i.bufferData(34963,e.size,r),i.bindBuffer(34963,null),n.glElementArrayBuffer=null):16&e.usage?(n.glUniformBuffer!==e.glBuffer&&i.bindBuffer(35345,e.glBuffer),i.bufferData(35345,e.size,r),i.bindBuffer(35345,null),n.glUniformBuffer=null):(64&e.usage||2&e.usage||1&e.usage||ht(16315),e.glTarget=0)}function J$t(t,e,i,n,r){if(64&e.usage){e.indirects.clearDraws();for(var s=i.drawInfos,a=0;ar.maxTextureSize&&ht(9100,u,r.maxTextureSize),1===e.samples){if(e.glTexture=i.createTexture(),e.size>0){var l=n.glTexUnits[n.texUnit];if(l.glTexture!==e.glTexture&&(i.bindTexture(3553,e.glTexture),l.glTexture=e.glTexture),ip[e.format].isCompressed)for(var c=0;c>1),a=O$t(1,a>>1)}else 128&e.flags?i.texImage2D(3553,0,e.glInternalFmt,s,a,0,e.glFormat,e.glType,null):i.texStorage2D(3553,e.mipLevel,e.glInternalFmt,s,a)}}else e.glRenderbuffer=i.createRenderbuffer(),e.size>0&&(n.glRenderbuffer!==e.glRenderbuffer&&(i.bindRenderbuffer(36161,e.glRenderbuffer),n.glRenderbuffer=e.glRenderbuffer),i.renderbufferStorageMultisample(36161,e.samples,e.glInternalFmt,e.width,e.height));break;case 5:e.glTarget=35866;var d=O$t(s,a);if(d>r.maxTextureSize&&ht(9100,d,r.maxTextureSize),h>r.maxArrayTextureLayers&&ht(9100,h,r.maxArrayTextureLayers),e.glTexture=i.createTexture(),e.size>0){var p=n.glTexUnits[n.texUnit];if(p.glTexture!==e.glTexture&&(i.bindTexture(35866,e.glTexture),p.glTexture=e.glTexture),ip[e.format].isCompressed)for(var m=0;m>1),a=O$t(1,a>>1)}else i.texStorage3D(35866,e.mipLevel,e.glInternalFmt,s,a,h)}break;case 2:e.glTarget=32879;var v=O$t(O$t(s,a),o);if(v>r.max3DTextureSize&&ht(9100,v,r.max3DTextureSize),e.glTexture=i.createTexture(),e.size>0){var b=n.glTexUnits[n.texUnit];if(b.glTexture!==e.glTexture&&(i.bindTexture(32879,e.glTexture),b.glTexture=e.glTexture),ip[e.format].isCompressed)for(var S=0;S>1),a=O$t(1,a>>1)}else i.texStorage3D(32879,e.mipLevel,e.glInternalFmt,s,a,o)}break;case 3:e.glTarget=34067;var T=O$t(s,a);if(T>r.maxCubeMapTextureSize&&ht(9100,T,r.maxTextureSize),e.glTexture=i.createTexture(),e.size>0){var A=n.glTexUnits[n.texUnit];if(A.glTexture!==e.glTexture&&(i.bindTexture(34067,e.glTexture),A.glTexture=e.glTexture),ip[e.format].isCompressed)for(var C=0;C>1),a=O$t(1,a>>1)}else i.texStorage2D(34067,e.mipLevel,e.glInternalFmt,s,a)}break;default:ht(16317),e.type=1,e.glTarget=3553}}function Q$t(t,e){var i=t.gl,n=t.getStateCache();if(e.glTexture){var r=n.glTexUnits,s=n.texUnit;i.deleteTexture(e.glTexture);for(var a=0;ar.maxTextureSize&&ht(9100,u,r.maxTextureSize),1===e.samples){var l=n.glTexUnits[n.texUnit];if(l.glTexture!==e.glTexture&&(i.bindTexture(3553,e.glTexture),l.glTexture=e.glTexture),ip[e.format].isCompressed)for(var c=0;c>1),a=O$t(1,a>>1)}else Q$t(t,e),K$t(t,e)}else e.glRenderbuffer&&(n.glRenderbuffer!==e.glRenderbuffer&&(i.bindRenderbuffer(36161,e.glRenderbuffer),n.glRenderbuffer=e.glRenderbuffer),i.renderbufferStorageMultisample(36161,e.samples,e.glInternalFmt,e.width,e.height));break;case 5:e.glTarget=35866;var d=O$t(s,a);if(d>r.maxTextureSize&&ht(9100,d,r.maxTextureSize),h>r.maxArrayTextureLayers&&ht(9100,h,r.maxArrayTextureLayers),e.glTexture=i.createTexture(),e.size>0){var p=n.glTexUnits[n.texUnit];if(p.glTexture!==e.glTexture&&(i.bindTexture(35866,e.glTexture),p.glTexture=e.glTexture),ip[e.format].isCompressed)for(var m=0;m>1),a=O$t(1,a>>1)}else i.texStorage3D(35866,e.mipLevel,e.glInternalFmt,s,a,h)}break;case 2:e.glTarget=32879;var v=O$t(O$t(s,a),o);if(v>r.max3DTextureSize&&ht(9100,v,r.max3DTextureSize),e.glTexture=i.createTexture(),e.size>0){var b=n.glTexUnits[n.texUnit];if(b.glTexture!==e.glTexture&&(i.bindTexture(32879,e.glTexture),b.glTexture=e.glTexture),ip[e.format].isCompressed)for(var S=0;S>1),a=O$t(1,a>>1)}else i.texStorage3D(32879,e.mipLevel,e.glInternalFmt,s,a,o)}break;case 3:e.type=3,e.glTarget=34067;var T=O$t(s,a);T>r.maxCubeMapTextureSize&&ht(9100,T,r.maxTextureSize);var A=n.glTexUnits[n.texUnit];if(A.glTexture!==e.glTexture&&(i.bindTexture(34067,e.glTexture),A.glTexture=e.glTexture),ip[e.format].isCompressed)for(var C=0;C<6;++C){s=e.width,a=e.height;for(var D=0;D>1),a=O$t(1,a>>1)}}else Q$t(t,e),K$t(t,e);break;default:ht(16317),e.type=1,e.glTarget=3553}}}function $$t(t,e){for(var i=t.gl,n=e.glSamplers.values().next();!n.done;){i.deleteSampler(n.value);for(var r=t.getStateCache().glSamplerUnits,s=0;s>h.baseLevel),e.height=k$t(e.height,u.height>>h.baseLevel))}var l=e.gpuDepthStencilView;if(l){var c=l.gpuTexture,f=ip[c.format].hasStencil?33306:36096;c.glTexture?r.framebufferTexture2D(36160,f,c.glTarget,c.glTexture,e.gpuDepthStencilView.baseLevel):r.framebufferRenderbuffer(36160,f,36161,c.glRenderbuffer),e.width=k$t(e.width,c.width>>l.baseLevel),e.height=k$t(e.height,c.height>>l.baseLevel)}r.drawBuffers(s);var _=r.checkFramebufferStatus(36160);if(36053!==_)switch(_){case 36054:ht(16318);break;case 36055:ht(16319);break;case 36057:ht(16320);break;case 36061:ht(16321)}i.glFramebuffer!==e.glFramebuffer&&r.bindFramebuffer(36160,i.glFramebuffer)}}function e0t(t,e){var i=t.gl,n=t.getStateCache();e.glFramebuffer&&(i.deleteFramebuffer(e.glFramebuffer),n.glFramebuffer===e.glFramebuffer&&(i.bindFramebuffer(36160,null),n.glFramebuffer=null),e.glFramebuffer=null)}function i0t(t,e){for(var i,n=t.gl,r=t.getStateCache(),s=t.capabilities,a=function(){var t=e.gpuStages[o],i=0,r="",s=1;switch(t.type){case 1:r="VertexShader",i=35633;break;case 16:r="FragmentShader",i=35632;break;default:return ht(16322),{v:void 0}}var a=n.createShader(i);if(a&&(t.glShader=a,n.shaderSource(t.glShader,"#version 300 es\n"+t.source),n.compileShader(t.glShader),!n.getShaderParameter(t.glShader,35713))){ht(16323,r,e.name),ht(16324,t.source.replace(/^|\n/g,(function(){return"\n"+s+++" "}))),J(n.getShaderInfoLog(t.glShader));for(var h=0;h0){e.glSamplerTextures=new Array(e.samplerTextures.length);for(var k=0;k=0&&D.gpuDescriptors[B];if(I&&I.gpuBuffer){var M=T[C.set],P=M&&M[C.binding],E=I.gpuBuffer.glOffset;P>=0&&(E+=r[P]),h.glBindUBOs[C.glBinding]===I.gpuBuffer.glBuffer&&h.glBindUBOOffsets[C.glBinding]===E||(E?a.bindBufferRange(35345,C.glBinding,I.gpuBuffer.glBuffer,E,I.gpuBuffer.size):a.bindBufferBase(35345,C.glBinding,I.gpuBuffer.glBuffer),h.glUniformBuffer=h.glBindUBOs[C.glBinding]=I.gpuBuffer.glBuffer,h.glBindUBOOffsets[C.glBinding]=E)}}for(var O=_.glSamplerTextures.length,k=0;k=0&&F.gpuDescriptors[L],N=0;N0){U.glTexture!==H.glTexture&&(h.texUnit!==z&&(a.activeTexture(33984+z),h.texUnit=z),H.glTexture?a.bindTexture(H.glTarget,H.glTexture):a.bindTexture(H.glTarget,t.nullTex2D.gpuTexture.glTexture),U.glTexture=H.glTexture);var q=V.gpuSampler.getGLSampler(t,W,j);h.glSamplerUnits[z]!==q&&(a.bindSampler(z,q),h.glSamplerUnits[z]=q)}V=F.gpuDescriptors[++L]}}}if(i&&_&&(d||a0t.gpuInputAssembler!==i))if(a0t.gpuInputAssembler=i,t.extensions.useVAO){var X=i.glVAOs.get(_.glProgram);if(!X){var Y;X=a.createVertexArray(),i.glVAOs.set(_.glProgram,X),a.bindVertexArray(X),a.bindBuffer(34962,null),a.bindBuffer(34963,null),h.glArrayBuffer=null,h.glElementArrayBuffer=null;for(var J=0;J<_.glInputs.length;J++){var K=_.glInputs[J];Y=null;for(var Q=0;Q=0&&(a.enableVertexAttribArray(lt),h.glEnabledAttribLocs[lt]=!0),h.glCurrentAttribLocs[lt]=!0,a.vertexAttribPointer(lt,at.count,at.glType,at.isNormalized,at.stride,ct),a.vertexAttribDivisor(lt,at.isInstanced?1:0)}}}var ft=i.gpuIndexBuffer;ft&&h.glElementArrayBuffer!==ft.glBuffer&&(a.bindBuffer(34963,ft.glBuffer),h.glElementArrayBuffer=ft.glBuffer);for(var _t=0;_t0){var c=e.firstIndex*a.stride;i.drawElementsInstanced(r,e.indexCount,n.glIndexType,c,e.instanceCount)}}else e.vertexCount>0&&i.drawArraysInstanced(r,e.firstVertex,e.vertexCount,e.instanceCount);else if(a){if(e.indexCount>0){var f=e.firstIndex*a.stride;i.drawElements(r,e.indexCount,n.glIndexType,f)}}else e.vertexCount>0&&i.drawArrays(r,e.firstVertex,e.vertexCount)}}function l0t(t,e){if(t.length>1||e.length>1)return!1;if(t[0]instanceof HTMLVideoElement){var i=t[0];return 0===e[0].texOffset.x&&0===e[0].texOffset.y&&e[0].texExtent.width===i.videoWidth&&e[0].texExtent.height===i.videoHeight}return!1}function c0t(t,e,i,n){var r=t.gl,s=t.getStateCache(),a=s.glTexUnits[s.texUnit];a.glTexture!==i.glTexture&&(r.bindTexture(i.glTarget,i.glTexture),a.glTexture=i.glTexture);var o=0,h=0;switch(i.glTarget){case 3553:if(128&i.flags||l0t(e,n))r.texImage2D(3553,n[0].texSubres.mipLevel,i.glInternalFmt,n[0].texExtent.width,n[0].texExtent.height,0,i.glFormat,i.glType,e[0]);else for(var u=0;u0?A:_.width,p.height=g.buffTexHeight>0?g.buffTexHeight:_.height;var C=S+d.x===i.width>>y?S:_.width,D=w+d.y===i.height>>y?w:_.height,B=void 0,I=e[o++];if(p.width===_.width&&p.height===_.height){var M=op(i.format,C,D,1)/l.BYTES_PER_ELEMENT;lt(Number.isInteger(M),9101),B=new l(I.buffer,I.byteOffset+g.buffOffset,M)}else B=_0t(I,i.format,g.buffOffset,p,_);c?36196!==i.glInternalFmt?r.compressedTexSubImage2D(3553,y,d.x,d.y,C,D,i.glFormat,B):r.compressedTexImage2D(3553,y,i.glInternalFmt,C,D,0,B):r.texSubImage2D(3553,y,d.x,d.y,C,D,i.glFormat,i.glType,B)}break;case 35866:for(var P=0;P0?z:_.width,p.height=E.buffTexHeight>0?E.buffTexHeight:_.height;var G=F+d.x===i.width>>O?F:_.width,H=L+d.y===i.height>>O?L:_.height,W=U.baseArrayLayer+U.layerCount;for(h=U.baseArrayLayer;h0?nt:_.width,p.height=J.buffTexHeight>0?J.buffTexHeight:_.height;var rt=$+d.x===i.width>>K?$:_.width,st=tt+d.y===i.height>>K?tt:_.height,at=void 0,ot=e[o++];if(p.width===_.width&&p.height===_.height){var ut=op(i.format,rt,st,_.depth)/l.BYTES_PER_ELEMENT;lt(Number.isInteger(ut),9101),at=new l(ot.buffer,ot.byteOffset+J.buffOffset,ut)}else at=_0t(ot,i.format,J.buffOffset,p,_);c?36196!==i.glInternalFmt?r.compressedTexSubImage3D(35866,K,d.x,d.y,d.z,rt,st,_.depth,i.glFormat,at):r.compressedTexImage3D(35866,K,i.glInternalFmt,rt,st,_.depth,0,at):r.texSubImage3D(35866,K,d.x,d.y,d.z,rt,st,_.depth,i.glFormat,i.glType,at)}break;case 34067:for(var ct=0;ct0?bt:_.width,p.height=ft.buffTexHeight>0?ft.buffTexHeight:_.height;var wt=mt+d.x===i.width>>_t?mt:_.width,xt=gt+d.y===i.height>>_t?gt:_.height,Tt=St.baseArrayLayer+St.layerCount;for(h=St.baseArrayLayer;h0,this.instancedDraw=!!e.instanceCount,this.drawCount=Math.max(t+1,this.drawCount),this.drawByIndex?(this.counts[t]=e.indexCount,this.offsets[t]=e.firstIndex):(this.counts[t]=e.vertexCount,this.offsets[t]=e.firstVertex),this.instances[t]=Math.max(1,e.instanceCount)},e._ensureCapacity=function(t){if(!(this._capacity>t)){this._capacity=fn(t);var e=new Int32Array(this._capacity),i=new Int32Array(this._capacity),n=new Int32Array(this._capacity);this.byteOffsets=new Int32Array(this._capacity),e.set(this.counts),i.set(this.offsets),n.set(this.instances),this.counts=e,this.offsets=i,this.instances=n}},t}(),v0t=function(){function t(){this._srcFramebuffer=void 0,this._dstFramebuffer=void 0;var t=g0t.instance.gl;this._srcFramebuffer=t.createFramebuffer(),this._dstFramebuffer=t.createFramebuffer()}return t.prototype.destroy=function(){var t=g0t.instance.gl;t.deleteFramebuffer(this._srcFramebuffer),t.deleteFramebuffer(this._dstFramebuffer)},n(t,[{key:"srcFramebuffer",get:function(){return this._srcFramebuffer}},{key:"dstFramebuffer",get:function(){return this._dstFramebuffer}}]),t}(),b0t=function(t){function e(){var e;return(e=t.call(this)||this)._gpuBuffer=null,e}s(e,t);var i=e.prototype;return i.getGpuBuffer=function(){return this._gpuBuffer},i.initialize=function(t){if("buffer"in t){this._isBufferView=!0;var e=t.buffer;this._usage=e.usage,this._memUsage=e.memUsage,this._size=this._stride=t.range,this._count=1,this._flags=e.flags,this._gpuBuffer={usage:this._usage,memUsage:this._memUsage,size:this._size,stride:this._stride,buffer:null,indirects:e.getGpuBuffer().indirects,glTarget:e.getGpuBuffer().glTarget,glBuffer:e.getGpuBuffer().glBuffer,glOffset:t.offset}}else this._usage=t.usage,this._memUsage=t.memUsage,this._size=t.size,this._stride=Math.max(t.stride||this._size,1),this._count=this._size/this._stride,this._flags=t.flags,this._gpuBuffer={usage:this._usage,memUsage:this._memUsage,size:this._size,stride:this._stride,buffer:null,indirects:new y0t,glTarget:0,glBuffer:null,glOffset:0},q$t(g0t.instance,this._gpuBuffer),g0t.instance.memoryStatus.bufferSize+=this._size},i.destroy=function(){this._gpuBuffer&&(this._isBufferView||(X$t(g0t.instance,this._gpuBuffer),g0t.instance.memoryStatus.bufferSize-=this._size),this._gpuBuffer=null)},i.resize=function(t){if(this._isBufferView)at(16379);else{var e=this._size;e!==t&&(this._size=t,this._count=this._size/this._stride,this._gpuBuffer&&(this._gpuBuffer.size=t,t>0&&(Y$t(g0t.instance,this._gpuBuffer),g0t.instance.memoryStatus.bufferSize-=e,g0t.instance.memoryStatus.bufferSize+=t)))}},i.update=function(t,e){var i;this._isBufferView?at(16380):(i=void 0!==e?e:64&this._usage?0:t.byteLength,J$t(g0t.instance,this._gpuBuffer,t,0,i))},e}(pp),S0t=function(t){function e(){var e;return(e=t.call(this)||this)._isInRenderPass=!1,e._curGPUPipelineState=null,e._curGPUDescriptorSets=[],e._curGPUInputAssembler=null,e._curDynamicOffsets=Array(8).fill(0),e._curDynamicStates=new Kd,e._isStateInvalid=!1,e}s(e,t);var i=e.prototype;return i.initialize=function(t){this._type=t.type,this._queue=t.queue;for(var e=g0t.instance.bindingMappings.blockOffsets.length,i=0;i0?this.gpuColorViews[0].gpuTexture.width:this.gpuDepthStencilView?this.gpuDepthStencilView.gpuTexture.width:o},set width(t){o=t},get height(){return this.gpuColorViews.length>0?this.gpuColorViews[0].gpuTexture.height:this.gpuDepthStencilView?this.gpuDepthStencilView.gpuTexture.height:h},set height(t){h=t}},t0t(g0t.instance,this._gpuFramebuffer),this._gpuFramebuffer.gpuColorViews.forEach((function(t){return i._gpuColorViews.push(t.gpuTexture.glTexture)})),this._gpuDepthStencilView=null==(e=this._gpuFramebuffer.gpuDepthStencilView)?void 0:e.gpuTexture.glTexture,this._width=this._gpuFramebuffer.width,this._height=this._gpuFramebuffer.height},i.destroy=function(){this._gpuFramebuffer&&(e0t(g0t.instance,this._gpuFramebuffer),this._gpuFramebuffer=null,this._gpuColorViews.length=0,this._gpuDepthStencilView=null)},n(e,[{key:"needRebuild",get:function(){var t=this.getGpuFramebuffer();if(t){for(var e,i=0;ii&&(i=s.binding)}this._bindingIndices=Array(i+1).fill(-1);for(var a=this._descriptorIndices=Array(i+1).fill(-1),o=0;o1&&(s.levelCount=Math.min(s.levelCount,e.getLevelCount(t,i)));var a=n._size;s.width=t,s.height=i,n._size=hp(s.format,n.width,n.height,n.depth,s.levelCount)*s.layerCount;var o=n._gpuTexture;!n._isTextureView&&o&&(o.width=t,o.height=i,o.size=n._size,o.isSwapchainTexture||(Z$t(r,o),r.memoryStatus.textureSize-=a,r.memoryStatus.textureSize+=n._size))}},i.initAsSwapchainTexture=function(t){var e=new dd;e.format=t.format,e.usage=ip[t.format].hasDepth?32:16,e.width=t.width,e.height=t.height,this.initialize(e,!0)},n(e,[{key:"gpuTexture",get:function(){return this._gpuTexture}},{key:"gpuTextureView",get:function(){return this._gpuTextureView}}]),e}(Rp),R0t="webglcontextlost";function F0t(t){t.activeTexture(33984),t.pixelStorei(3333,1),t.pixelStorei(3317,1),t.pixelStorei(37440,!1),t.bindFramebuffer(36160,null),t.enable(3089),t.enable(2884),t.cullFace(1029),t.frontFace(2305),t.polygonOffset(0,0),t.enable(2929),t.depthMask(!0),t.depthFunc(513),t.stencilFuncSeparate(1028,519,1,65535),t.stencilOpSeparate(1028,7680,7680,7680),t.stencilMaskSeparate(1028,65535),t.stencilFuncSeparate(1029,519,1,65535),t.stencilOpSeparate(1029,7680,7680,7680),t.stencilMaskSeparate(1029,65535),t.disable(2960),t.disable(32926),t.disable(3042),t.blendEquationSeparate(32774,32774),t.blendFuncSeparate(1,0,1,0),t.colorMask(!0,!0,!0,!0),t.blendColor(0,0,0,0)}function L0t(t,e){for(var i=["","WEBKIT_","MOZ_"],n=0;n