System.register([],(function(t,e){"use strict";return{execute:function(){function i(t,e){for(var i=0;it.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 d(t){var e=function(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)}(t,"string");return"symbol"==typeof e?e:String(e)}function p(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 m(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 g(t,e){const i="undefined"==typeof window?global:window;return void 0===i[t]?i[t]=e:i[t]}t({$:function(t){return NM.test(t)},J:function(){return 0},N:FM,P:kM,W:GM,X:VM,Y:UM,Z:zM,_:f,a0:function(t){return LM.test(t)},a1:jM,a2:YM,a3:qM,aB:function(t,e){for(var i=t,n="";null!==i&&i!==e;)n=i.name+"/"+n,i=i.parent;return n.slice(0,-1)},aC:Pj,aQ:Yn,aS:vn,aU:_n,aW:kn,aZ:Wn,ay:A1,az:b1,b0:Zn,b2:$n,b4:Cn,b9:Li,bB:Te,bC:Ee,bD:we,bI:function(t){t>0&&(pt=t)},bM:Tt,bN:function(t){for(var e,i=f(t);!(e=i()).done;)At(e.value)},bO:function(t){return vt||(vt="undefined"==typeof Proxy?{}:new Proxy(t,{get:function(t,e,i){return At(e),Reflect.get(t,e,i)}})),vt},bP:_a,bQ:fa,bT:Ci,bU:xi,ba:Ni,bb:Fi,bc:ki,bd:Gi,be:Vi,bf:Ui,bg:zi,bh:Hi,bi:Wi,bj:Xi,bk:ji,bl:Yi,bm:qi,bn:Ki,bo:Qi,bp:Zi,bq:Ji,br:$i,bs:tn,bt:en,bu:hn,bv:un,c:Ybt,c$:Ps,c2:function(t){return t[uo]},c5:zs,c7:X,c8:U,c9:H,cE:zl,cF:bu,cG:Vu,cS:co,cU:Wl,cX:mi,cY:gi,ca:z,cb:W,cc:J,cd:Q,ce:it,cf:tt,cg:st,ch:ot,ci:ht,cj:at,d0:Os,d3: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))}))}))},d4:j,d5:function(t,e){return Va(t,e,0)},d6:Va,d7: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},d8:function(){},d9:function(){},dU:jp,dW:fJ,da:Ae,db:Kl,dp:TI,gK:FHt,gL:kHt}),g("CC_WECHAT",!1),g("CC_BAIDU",!1),g("CC_XIAOMI",!1),g("CC_ALIPAY",!1),g("CC_BYTEDANCE",!1),g("CC_OPPO",!1),g("CC_VIVO",!1),g("CC_HUAWEI",!1),g("CC_COCOSPLAY",!1),g("CC_QTT",!1),g("CC_LINKSURE",!1);const v=!1;g("CC_EDITOR",!1);g("CC_PREVIEW",!1),g("CC_BUILD",!0),g("CC_TEST",!1),g("CC_DEBUG",!1),g("CC_DEV",!1),g("CC_MINIGAME",!1),g("CC_RUNTIME_BASED",!1),g("CC_SUPPORT_JIT",!0),g("CC_JSB",!1);var y="undefined"==typeof window?global:window,S=t("aN",{_global:y});S.internal={};var T=t("aM","3.8.4");y.CocosEngine=S.ENGINE_VERSION=T,y.cc=S;var A=void 0!==globalThis.jsb&&void 0!==jsb.window?jsb.window:globalThis;y.ccwindow=A;var b=2147483647;function E(t){return(t>0)-(t<0)}function C(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 w(t){return 16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24}function R(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 I(t){return--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,1+(t|=t>>>16)}var D=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},min:function(t,e){return e^(t^e)&-(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},popCount:w,countTrailingZeros:R,nextPow2:I,prevPow2:function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)-(t>>>1)},parity:function(t){return t^=t>>>16,t^=t>>>8,t^=t>>>4,27030>>>(t&=15)&1},reverse:function(t){return D[255&t]<<24|D[t>>>8&255]<<16|D[t>>>16&255]<<8|D[t>>>24&255]},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},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},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},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},nextCombination:function(t){var e=t|t-1;return e+1|(~e&-~e)-1>>>R(t)+1}});t("aO",B);var M=A.document,P="https://github.com/cocos/cocos-engine/blob/"+T+"/EngineErrorMap.md",O=null,L=console.log.bind(console),N=L,F=L,k=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;rnt.ERROR){var e=function(t){if(S.game.canvas){if(!O){var e=M.createElement("Div");e.setAttribute("id","logInfoDiv"),e.setAttribute("width","200");var i=S.game.canvas.height;e.setAttribute("height",""+i);var n=e.style;n.zIndex="99999",n.position="absolute",n.top=n.left="0",(O=M.createElement("textarea")).setAttribute("rows","20"),O.setAttribute("cols","30"),O.setAttribute("disabled","true");var r=O.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(O),S.game.canvas.parentNode.appendChild(e)}O.value=O.value+t+"\r\n",O.scrollTop=O.scrollHeight}};F=function(){e("ERROR : "+V.apply(void 0,arguments))},k=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",ut=function(t,e,i){null!=t&&i.forEach((function(i){var n=mt++;gt.set(n,{id:n,count:0,logTimes:void 0!==i.logTimes?i.logTimes:pt});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 _t(e,i.name,a,s,z,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 _t(e,i.name,a,s,z,n,h),i.customGetter.call(this)},set:function(t){_t(e,i.name,a,s,z,n,h),i.customSetter.call(this,t)},enumerable:!1}):u?Object.defineProperty(t,i.name,{set:function(t){_t(e,i.name,a,s,z,n,h),i.customSetter.call(this,t)},enumerable:!1}):l&&Object.defineProperty(t,i.name,{get:function(){return _t(e,i.name,a,s,z,n,h),i.customGetter.call(this)},enumerable:!1})}else Object.defineProperty(t,i.name,{get:function(){return _t(e,i.name,a,s,z,n,h),o?this[s]:r[s]},set:function(t){_t(e,i.name,a,s,z,n,h),o?this[s]=t:r[s]=t},enumerable:!1})}))}),ft=function(t,e,i,n,r){var s=gt.get(n);s&&s.logTimes>s.count&&(i("'%s' has been removed. "+r,t+"."+e),s.count++)},t("bK",lt=function(t,e,i){null!=t&&i.forEach((function(i){var n=mt++;gt.set(n,{id:n,count:0,logTimes:void 0!==i.logTimes?i.logTimes:pt});var r=i.suggest?"("+i.suggest+")":"";Object.defineProperty(t,i.name,{get:function(){return ft(e,i.name,H,n,r)},set:function(){ft(e,i.name,H,n,r)},enumerable:!1})}))}),t("bL",ct=function(){});var vt,yt,St={};function Tt(t){for(var e in t){var i=t[e];St[e]=i}}function At(t){var e=St[t];if(e){var i=e.newName,n=e.since;e.removed?i?it(16003,t,n,i):it(16002,t,n):i?tt(16001,t,n,i):tt(16e3,t,n)}}var bt=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}();yt=bt,bt.global=new yt("global");var Et=new bt("TmpCId."),Ct="undefined"==typeof Symbol?"__aliases__":Symbol("[[Aliases]]"),xt="__cid__";function wt(t){return"number"==typeof t||t instanceof Number}function Rt(t){return"string"==typeof t||t instanceof String}function It(t){for(var e in t)return!1;return!0}var Dt,Bt=(Dt={value:void 0,enumerable:!1,writable:!1,configurable:!0},function(t,e,i,n,r){Dt.value=i,Dt.writable=n,Dt.enumerable=r,Object.defineProperty(t,e,Dt),Dt.value=void 0}),Mt=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&&(console.log("Set `setter` to boolean is deprecated. Please don not use like this again."),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}}(),Pt=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}}(),Ot=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 Lt(t){var e=Object.create(null);return t&&(e["."]=1,e["/"]=1,delete e["."],delete e["/"]),e}function Nt(t){if("function"==typeof t){var e=t.prototype;if(e&&e.hasOwnProperty("__classname__")&&e.__classname__)return e.__classname__;var i="";if(t.name&&(i=t.name),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?Nt(t.constructor):""}function Ft(t,e,i,n){var r=/([^.]+)$/,s=r.exec(e)[0],a=r.exec(i)[0];function o(){return this[a]}n?Mt(t,s,o,(function(t){this[a]=t})):Pt(t,s,o)}function kt(t,e,i,n){for(var r in i)Ft(t,e+"."+r,i[r],n)}var Gt=/(%d)|(%s)/,Vt=/%s/;function Ut(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n1?e-1:0),n=1;n1?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}(),ce=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 _e(t,e){t.splice(e,1)}function fe(t,e){var i=t.length;e<0||e>=i||(t[e]=t[i-1],t.length=i-1)}function de(t,e){var i=t.indexOf(e);return i>=0&&(_e(t,i),!0)}function pe(t,e){var i=t.indexOf(e);i>=0&&(t[i]=t[t.length-1],--t.length)}function me(t,e){var i=t.findIndex(e);if(i>=0){var n=t[i];return _e(t,i),n}}function ge(t,e){return t.indexOf(e)>=0}var ve=Object.freeze({__proto__:null,MutableForwardIterator:ce,removeAt:_e,fastRemoveAt:fe,remove:de,fastRemove:pe,removeIf:me,verifyType:function(t,e){if(t&&t.length>0)for(var i,n=f(t);!(i=n()).done;)if(!(i.value instanceof e))return Q(1300),!1;return!0},removeArray:function(t,e){for(var i=0,n=e.length;i=0&&t.length,t.length}t("bF",Se),Te.isBitMask=function(t){return t&&Object.prototype.hasOwnProperty.call(t,"__bitmask__")},Te.getList=function(t){return t.__bitmask__?t.__bitmask__:Te.update(t)},Te.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},S.BitMask=Te;var be=Object.prototype.hasOwnProperty;function Ee(t){return"__enums__"in t?t:(Bt(t,"__enums__",null,!0),Ee.update(t))}function Ce(t){be.call(t,"__enums__")}function xe(t){Ce(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 we(t){"__enums__"in t||Bt(t,"__enums__",null,!0)}Ee.update=function(t){for(var e=-1,i=Object.keys(t),n=0;n2?n-2:0),s=2;s1?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__||Qe(r,(e=i[n+1])&&e.__attrs__)}return Qe(t,(e=i[0])&&e.__attrs__),t.__attrs__}function Je(t,e){var i=$e(t),n=e+Ke,r={};for(var s in i)s.startsWith(n)&&(r[s.slice(n.length)]=i[s]);return r}function $e(t){return t.hasOwnProperty("__attrs__")&&t.__attrs__||Ze(t)}function ti(t,e,i,n){$e(t)[e+Ke+i]=n}var ei=function(){function t(t,e){this.name=t,this.default=e}return t.prototype.toString=function(){return this.name},t}(),ii=t("bW",new ei("Integer",0));S.Integer=ii,S.CCInteger=ii;var ni=t("bX",new ei("Float",0));S.Float=ni,S.CCFloat=ni;var ri=t("bY",new ei("Boolean",!1));S.Boolean=ri,S.CCBoolean=ri;var si=t("bZ",new ei("String",""));function ai(t,e){return function(i,n){var r='"'+Nt(i)+"."+n+'"',s=Je(i,n),a=s.type;if(a===ii||a===ni?a="Number":a!==si&&a!==ri||(a=""+a),a===t){if(s.hasOwnProperty("default")){var o=s.default;if(void 0!==o&&!Array.isArray(o)&&!Xe(o)){var h=typeof o,u=t.toLowerCase();if(h===u)if("object"===u){if(!o||o instanceof s.ctor)return;tt(3605,r,Nt(s.ctor))}else"Number"!==t&&tt(3606,e,r,t);else{if("function"===h)return;t===si.default&&null==o?tt(3607,r):tt(3611,e,r,h)}delete s.type}}}else tt(3604,r)}}S.String=si,S.CCString=si;var oi=Object.freeze({__proto__:null,DELIMETER:Ke,createAttrsSingle:Qe,createAttrs:Ze,attr:Je,getClassAttrs:$e,setClassAttr:ti,PrimitiveType:ei,CCInteger:ii,CCFloat:ni,CCBoolean:ri,CCString:si,getTypeChecker_ET:ai,getObjTypeChecker_ET:function(t){return function(e,i){ai("Object","type")(e,i);var n=$e(e)[i+Ke+"default"],r=S.Class.getDefault(n);if(!Array.isArray(r)&&Kt(t,S.ValueType)){var s=Nt(t),a=Ut('No need to specify the "type" of "%s.%s" because %s is a child class of ValueType.',Nt(e),i,s);n?U(a):tt(3612,a,s,Nt(e),i,s)}}}}),hi={default:{},serializable:{},editorOnly:{},formerlySerializedAs:{}};function ui(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,hi){var o=hi[a];t.hasOwnProperty(a)&&(s[a]=t[a],o.canUsedInGet||delete t[a])}}}function li(t,e,i,n){if(Array.isArray(e)){if(!(e.length>0))return it(5508,i,n);t.type=e=e[0]}"function"==typeof e&&(e===String?t.type=S.String:e===Boolean?t.type=S.Boolean:e===Number&&(t.type=S.Float))}function ci(t,e,i){var n=t||void 0===e?{_short:!0}:{_short:!0,default:e};return i&&(n.type=i),n}function _i(t,e){if(!t||t.constructor!==Object){if(Array.isArray(t)&&t.length>0)return ci(e,[],t);if("function"==typeof t){var i=t;return ci(e,Kt(i,S.ValueType)?new i:null,i)}return t instanceof ei?ci(e,void 0,t):ci(e,t)}return null}var fi,di=[];function pi(){return di[di.length-1]}function mi(t,e,i){gi($e(t),e,i)}function gi(t,e,i){t[e+"$_$type"]="Enum",t[e+"$_$enumList"]=Ee.getList(i)}S._RF={push:function(t,e,i,n){void 0===i&&(i=e,e=""),di.push({uuid:e,script:i,module:t,exports:t.exports,beh:null,importMeta:n})},pop:function(){var t=di.pop(),e=t.module,i=e.exports;if(i===t.exports){for(var n in i)return;e.exports=i=t.cls}},peek:pi},function(t){t[t.STANDALONE=1]="STANDALONE",t[t.IMPLICIT_VISIBLE=2]="IMPLICIT_VISIBLE",t[t.IMPLICIT_SERIALIZABLE=4]="IMPLICIT_SERIALIZABLE"}(fi||(fi={}));var vi=Ke,yi="__ctors__",Si=t("cZ","Enum"),Ti=t("c_","BitMask");function Ai(t,e,i,n){!function(t,e){!function(t,e){t.indexOf(e)<0&&t.push(e)}(t.__props__,e)}(t,i),Ri(t,n,e,i)}function bi(t,e,i,n){var r=n.get;n.set,r&&(Ri(t,n,e,i),ti(t,i,"serializable",!1))}function Ei(t){return"function"==typeof t?t():t}function Ci(t){var e=t.name,i=t.extends,n=function(t,e,i){var n=S.Component,r=pi();if(r&&Kt(e,n)){if(Kt(r.cls,n))return it(3615),null;t=t||r.script}var s=function(t,e,i){var n=i.ctor;return Bt(n,yi,!0,!0),n.prototype,e&&(n.$super=e),ie(t,n),n}(t,e,i);if(r)if(Kt(e,n)){var a=r.uuid;a&&te(a,s),r.cls=s}else Kt(r.cls,n)||(r.cls=s);return s}(e,i,t);e||(e=S.js.getClassName(n)),n._sealed=!0,i&&(i._sealed=!1),function(t,e,i,n){if(t.__props__=[],n&&n.__props__&&(t.__props__=n.__props__.slice()),i)for(var r in function(t,e){for(var i in t){var n=t[i],r=_i(n,!1);if(r&&(n=t[i]=r),n){var s=n.notify;s&&ui(n,i,s,t),"type"in n&&li(n,n.type,e,i)}}}(i,e),i){var s=i[r];s.get||s.set?bi(t,e,r,s):Ai(t,e,r,s)}var a=$e(t);t.__values__=t.__props__.filter((function(t){return!1!==a[t+"$_$serializable"]}))}(n,e,t.properties,i);var r=t.editor;return r&&Kt(i,S.Component)&&S.Component._registerEditorProps(n,r),n}function xi(t){var e;return null==t||null===(e=t.hasOwnProperty)||void 0===e?void 0:e.call(t,"__values__")}Ci._isCCClass=function(t){var e;return null==t||null===(e=t.hasOwnProperty)||void 0===e?void 0:e.call(t,yi)},Ci.fastDefine=function(t,e,i){ie(t,e);for(var n=e.__props__=e.__values__=Object.keys(i),r=$e(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")}Ci.isArray=function(t){return t=Ei(t),Array.isArray(t)},Ci.getDefault=Ei,Ci.escapeForJS=function(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")},Ci.IDENTIFIER_RE=/^[A-Za-z_$][0-9A-Za-z_$]*$/,Ci.getNewValueTypeCode=function(t){for(var e=Nt(t),i=t.constructor,n="new "+e+"(",r=0;ri){var n=e;e=i,i=n}return ti?i:t}function ki(t){return t<0?0:t>1?1:t}function Gi(t,e,i){return t+(e-t)*i}function Vi(t){return t*Ii}function Ui(t){return t*Di}function zi(){return Bi()}function Hi(t){Bi=t}function Wi(t,e){return zi()*(e-t)+t}function Xi(t,e){return Math.floor(Wi(t,e))}function ji(t){return(t=(9301*t+49297)%233280)/233280}function Yi(t,e,i){return ji(t)*(i-e)+e}function qi(t,e,i){return Math.floor(Yi(t,e,i))}function Ki(t){return I(t)}function Qi(t,e){return t-Math.floor(t/e)*e}function Zi(t,e){return t=Qi(t,2*e),e-Math.abs(t-e)}function Ji(t,e,i){return(i-t)/(e-t)}function $i(t){return Math.abs(t.x)>Math.abs(t.y)?Math.abs(t.x)>Math.abs(t.z)?t.x:t.z:Math.abs(t.y)>Math.abs(t.z)?t.y:t.z}function tn(t,e){return Math.abs(t)>Math.abs(e)?t:e}function en(t,e){e.forEach((function(e){Object.defineProperty(t,e,{enumerable:!0})}))}var nn,rn,sn,an=(nn=new Float32Array(1),rn=new Int32Array(nn.buffer),function(t){nn[0]=t;var e=rn[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,rn[0]=i|r,rn[0]}),on=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 hn(t){return an(t)}function un(t){return on(t)}var ln,cn=t("aT",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 Math.atan2(Math.sqrt(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=Math.ceil(e.x),t.y=Math.ceil(e.y),t.z=Math.ceil(e.z),t.w=Math.ceil(e.w),t},e.floor=function(t,e){return t.x=Math.floor(e.x),t.y=Math.floor(e.y),t.z=Math.floor(e.z),t.w=Math.floor(e.w),t},e.min=function(t,e,i){return t.x=Math.min(e.x,i.x),t.y=Math.min(e.y,i.y),t.z=Math.min(e.z,i.z),t.w=Math.min(e.w,i.w),t},e.max=function(t,e,i){return t.x=Math.max(e.x,i.x),t.y=Math.max(e.y,i.y),t.z=Math.max(e.z,i.z),t.w=Math.max(e.w,i.w),t},e.round=function(t,e){return t.x=Math.round(e.x),t.y=Math.round(e.y),t.z=Math.round(e.z),t.w=Math.round(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 Math.sqrt(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 Math.sqrt(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 Math.abs(i)0?(a=1/Math.sqrt(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*zi()*Math.PI,n=2*zi()-1,r=Math.sqrt(1-n*n);return t.x=r*Math.cos(i)*e,t.y=r*Math.sin(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,_=u*s+a*r-o*n,f=-a*n-o*r-h*s;return t.x=l*u+f*-a+c*-h-_*-o,t.y=c*u+f*-o+_*-a-l*-h,t.z=_*u+f*-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){return void 0===i&&(i=Oi),!(Math.abs(t.x)===1/0||Math.abs(t.y)===1/0||Math.abs(t.z)===1/0||Math.abs(t.w)===1/0||Math.abs(e.x)===1/0||Math.abs(e.y)===1/0||Math.abs(e.z)===1/0||Math.abs(e.w)===1/0)&&Math.abs(t.x-e.x)<=i*Math.max(1,Math.abs(t.x),Math.abs(e.x))&&Math.abs(t.y-e.y)<=i*Math.max(1,Math.abs(t.y),Math.abs(e.y))&&Math.abs(t.z-e.z)<=i*Math.max(1,Math.abs(t.z),Math.abs(e.z))&&Math.abs(t.w-e.w)<=i*Math.max(1,Math.abs(t.w),Math.abs(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){return void 0===e&&(e=Oi),Math.abs(this.x-t.x)<=e*Math.max(1,Math.abs(this.x),Math.abs(t.x))&&Math.abs(this.y-t.y)<=e*Math.max(1,Math.abs(this.y),Math.abs(t.y))&&Math.abs(this.z-t.z)<=e*Math.max(1,Math.abs(this.z),Math.abs(t.z))&&Math.abs(this.w-t.w)<=e*Math.max(1,Math.abs(this.w),Math.abs(t.w))},i.equals4f=function(t,e,i,n,r){return void 0===r&&(r=Oi),Math.abs(this.x-t)<=r*Math.max(1,Math.abs(this.x),Math.abs(t))&&Math.abs(this.y-e)<=r*Math.max(1,Math.abs(this.y),Math.abs(e))&&Math.abs(this.z-i)<=r*Math.max(1,Math.abs(this.z),Math.abs(i))&&Math.abs(this.w-n)<=r*Math.max(1,Math.abs(this.w),Math.abs(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.x,n=this.y,r=this.z,s=this.w;return this.x=i+e*(t.x-i),this.y=n+e*(t.y-n),this.z=r+e*(t.z-r),this.w=s+e*(t.w-s),this},i.toString=function(){return"("+this.x.toFixed(2)+", "+this.y.toFixed(2)+", "+this.z.toFixed(2)+", "+this.w.toFixed(2)+")"},i.clampf=function(t,e){return this.x=Fi(this.x,t.x,e.x),this.y=Fi(this.y,t.y,e.y),this.z=Fi(this.z,t.z,e.z),this.w=Fi(this.w,t.w,e.w),this},i.add=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this},i.add4f=function(t,e,i,n){return this.x+=t,this.y+=e,this.z+=i,this.w+=n,this},i.subtract=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this},i.subtract4f=function(t,e,i,n){return this.x-=t,this.y-=e,this.z-=i,this.w-=n,this},i.multiplyScalar=function(t){return"object"==typeof t&&tt(16361),this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},i.multiply=function(t){return"object"!=typeof t&&tt(16362),this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this},i.multiply4f=function(t,e,i,n){return this.x*=t,this.y*=e,this.z*=i,this.w*=n,this},i.divide=function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this},i.divide4f=function(t,e,i,n){return this.x/=t,this.y/=e,this.z/=i,this.w/=n,this},i.negative=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},i.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},i.cross=function(t){var e=this.x,i=this.y,n=this.z,r=t.x,s=t.y,a=t.z;return this.x=i*a-n*s,this.y=n*r-e*a,this.z=e*s-i*r,this},i.length=function(){var t=this.x,e=this.y,i=this.z,n=this.w;return Math.sqrt(t*t+e*e+i*i+n*n)},i.lengthSqr=function(){var t=this.x,e=this.y,i=this.z,n=this.w;return t*t+e*e+i*i+n*n},i.normalize=function(){var t=this.x,e=this.y,i=this.z,n=this.w,r=t*t+e*e+i*i+n*n;return r>0&&(r=1/Math.sqrt(r),this.x=t*r,this.y=e*r,this.z=i*r,this.w=n*r),this},i.scale=function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},i.transformMat4=function(t){var e=this.x,i=this.y,n=this.z,r=this.w;return this.x=t.m00*e+t.m04*i+t.m08*n+t.m12*r,this.y=t.m01*e+t.m05*i+t.m09*n+t.m13*r,this.z=t.m02*e+t.m06*i+t.m10*n+t.m14*r,this.w=t.m03*e+t.m07*i+t.m11*n+t.m15*r,this},e}(Ie));function _n(t,e,i,n){return new cn(t,e,i,n)}sn=cn,cn.ZERO=Object.freeze(new sn(0,0,0,0)),cn.ONE=Object.freeze(new sn(1,1,1,1)),cn.NEG_ONE=Object.freeze(new sn(-1,-1,-1,-1)),cn.UNIT_X=Object.freeze(new sn(1,0,0,0)),cn.UNIT_Y=Object.freeze(new sn(0,1,0,0)),cn.UNIT_Z=Object.freeze(new sn(0,0,1,0)),cn.UNIT_W=Object.freeze(new sn(0,0,0,1)),Ci.fastDefine("cc.Vec4",cn,{x:0,y:0,z:0,w:0}),S.Vec4=cn,S.v4=_n;var fn,dn,pn,mn,gn=t("aR",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=Math.ceil(e.x),t.y=Math.ceil(e.y),t.z=Math.ceil(e.z),t},e.floor=function(t,e){return t.x=Math.floor(e.x),t.y=Math.floor(e.y),t.z=Math.floor(e.z),t},e.min=function(t,e,i){return t.x=Math.min(e.x,i.x),t.y=Math.min(e.y,i.y),t.z=Math.min(e.z,i.z),t},e.max=function(t,e,i){return t.x=Math.max(e.x,i.x),t.y=Math.max(e.y,i.y),t.z=Math.max(e.z,i.z),t},e.round=function(t,e){return t.x=Math.round(e.x),t.y=Math.round(e.y),t.z=Math.round(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 Math.sqrt(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 Math.sqrt(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 Math.abs(i)0?(s=1/Math.sqrt(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*zi()*Math.PI,n=2*zi()-1,r=Math.sqrt(1-n*n);return t.x=r*Math.cos(i)*e,t.y=r*Math.sin(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=Math.cos(n),h=Math.sin(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=Math.cos(n),h=Math.sin(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=Math.cos(n),h=Math.sin(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=Math.cos(r),_=Math.sin(r),f=s*(h*h*(1-c)+c)+a*(h*u*(1-c)-l*_)+o*(h*l*(1-c)+u*_),d=s*(h*u*(1-c)+l*_)+a*(u*u*(1-c)+c)+o*(u*l*(1-c)-h*_),p=s*(h*l*(1-c)-u*_)+a*(u*l*(1-c)+h*_)+o*(l*l*(1-c)+c);return t.x=f+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=Oi);var n=t.x,r=t.y,s=t.z,a=e.x,o=e.y,h=e.z;return Math.abs(n-a)<=i*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(r-o)<=i*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(s-h)<=i*Math.max(1,Math.abs(s),Math.abs(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)/Math.sqrt(i*n);return r=Fi(r,-1,1),Math.acos(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&&(n=1/Math.sqrt(n),this.x=t*n,this.y=e*n,this.z=i*n),this},i.transformMat4=function(t){var e=this.x,i=this.y,n=this.z,r=t.m03*e+t.m07*i+t.m11*n+t.m15;return r=r?1/r:1,this.x=(t.m00*e+t.m04*i+t.m08*n+t.m12)*r,this.y=(t.m01*e+t.m05*i+t.m09*n+t.m13)*r,this.z=(t.m02*e+t.m06*i+t.m10*n+t.m14)*r,this},i.toVec2=function(){return new S.Vec2(this.x,this.y)},e}(Ie));function vn(t,e,i){return new gn(t,e,i)}ln=gn,gn.UNIT_X=Object.freeze(new ln(1,0,0)),gn.UNIT_Y=Object.freeze(new ln(0,1,0)),gn.UNIT_Z=Object.freeze(new ln(0,0,1)),gn.RIGHT=Object.freeze(new ln(1,0,0)),gn.UP=Object.freeze(new ln(0,1,0)),gn.FORWARD=Object.freeze(new ln(0,0,-1)),gn.ZERO=Object.freeze(new ln(0,0,0)),gn.ONE=Object.freeze(new ln(1,1,1)),gn.NEG_ONE=Object.freeze(new ln(-1,-1,-1)),gn.slerp=(fn=new ln,dn=new ln,pn=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(fn,e,1/s),l=ln.generateOrthogonal(dn,u),c=Math.PI*n;return Tn(pn,u,l,c),ln.multiplyScalar(t,pn,o),t}var _=h,f=Math.acos(_)*n,d=ln.multiplyScalar(fn,e,1/s),p=ln.multiplyScalar(dn,i,1/a);return ln.scaleAndAdd(pn,p,d,-_),ln.normalize(pn,pn),ln.multiplyScalar(pn,pn,Math.sin(f)),ln.scaleAndAdd(pn,pn,d,Math.cos(f)),ln.multiplyScalar(t,pn,o),t}),gn.signedAngle=(mn=new ln,function(t,e,i){var n=ln.angle(t,e),r=ln.cross(mn,t,e);return ln.dot(r,i)<0?-n:n}),Ci.fastDefine("cc.Vec3",gn,{x:0,y:0,z:0}),S.Vec3=gn;var yn,Sn,Tn=(yn={x:0,y:0,z:0,w:0},function(t,e,i,n){var r=.5*n,s=Math.sin(r);return yn.x=s*i.x,yn.y=s*i.y,yn.z=s*i.z,yn.w=Math.cos(r),gn.transformQuat(t,e,yn),t});S.v3=vn;var An,bn=1/255,En=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){return(e=void 0!==e?e:new cn).x=t._data[0]*bn,e.y=t._data[1]*bn,e.z=t._data[2]*bn,e.w=t._data[3]*bn,e},e.fromVec4=function(t,i){return(i=void 0===i?new e:i)._data[0]=t.x/bn,i._data[1]=t.y/bn,i._data[2]=t.z/bn,i._data[3]=t.w/bn,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=Oi),!(Math.abs(t.r)===1/0||Math.abs(t.g)===1/0||Math.abs(t.b)===1/0||Math.abs(t.a)===1/0)&&Math.abs(t.r-e.r)<=i*Math.max(1,Math.abs(t.r),Math.abs(e.r))&&Math.abs(t.g-e.g)<=i*Math.max(1,Math.abs(t.g),Math.abs(e.g))&&Math.abs(t.b-e.b)<=i*Math.max(1,Math.abs(t.b),Math.abs(e.b))&&Math.abs(t.a-e.a)<=i*Math.max(1,Math.abs(t.a),Math.abs(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;return t&&this._data[0]===e.r&&this._data[1]===e.g&&this._data[2]===e.b&&this._data[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*bn).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="0",i=[(this._data[0]<16?e:"")+this._data[0].toString(16),(this._data[1]<16?e:"")+this._data[1].toString(16),(this._data[2]<16?e:"")+this._data[2].toString(16)];return"#rgb"===t?(i[0]=i[0][0],i[1]=i[1][0],i[2]=i[2][0]):"#rrggbbaa"===t&&i.push((this._data[3]<16?e:"")+this._data[3].toString(16)),i.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}}return this._data[0]=255*n,this._data[1]=255*r,this._data[2]=255*s,this},i.toHSV=function(){var t=this._data[0]*bn,e=this._data[1]*bn,i=this._data[2]*bn,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){if("object"==typeof t){var r,s,a,o,h=t;h._data?this._data.set(h._data):(this._data[0]=null!==(r=h.r)&&void 0!==r?r:0,this._data[1]=null!==(s=h.g)&&void 0!==s?s:0,this._data[2]=null!==(a=h.b)&&void 0!==a?a:0,this._data[3]=null!==(o=h.a)&&void 0!==o?o:255)}else this._data[0]=null!=t?t:0,this._data[1]=null!=e?e:0,this._data[2]=null!=i?i:0,this._data[3]=null!=n?n:255;return this},i.multiply=function(t){return this._data[0]*=t.r/255,this._data[1]*=t.g/255,this._data[2]*=t.b/255,this._data[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]*bn},set:function(t){this._data[0]=255*t}},{key:"y",get:function(){return this._data[1]*bn},set:function(t){this._data[1]=255*t}},{key:"z",get:function(){return this._data[2]*bn},set:function(t){this._data[2]=255*t}},{key:"w",get:function(){return this._data[3]*bn},set:function(t){this._data[3]=255*t}}]),e}(Ie));function Cn(t,e,i,n){return new En(t,e,i,n)}function xn(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}Sn=En,En.WHITE=Object.freeze(new Sn(255,255,255,255)),En.GRAY=Object.freeze(new Sn(127,127,127,255)),En.BLACK=Object.freeze(new Sn(0,0,0,255)),En.TRANSPARENT=Object.freeze(new Sn(0,0,0,0)),En.RED=Object.freeze(new Sn(255,0,0,255)),En.GREEN=Object.freeze(new Sn(0,255,0,255)),En.BLUE=Object.freeze(new Sn(0,0,255,255)),En.CYAN=Object.freeze(new Sn(0,255,255,255)),En.MAGENTA=Object.freeze(new Sn(255,0,255,255)),En.YELLOW=Object.freeze(new Sn(255,255,0,255)),Ci.fastDefine("cc.Color",En,{r:0,g:0,b:0,a:255}),S.Color=En,S.color=Cn;var wn=t("aX",function(t){function e(e,i,n,r,s,a,o,h,u){var l;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=1),void 0===a&&(a=0),void 0===o&&(o=0),void 0===h&&(h=0),void 0===u&&(u=1),l=t.call(this)||this,"object"==typeof e?(l.m00=e.m00,l.m01=e.m01,l.m02=e.m02,l.m03=e.m03,l.m04=e.m04,l.m05=e.m05,l.m06=e.m06,l.m07=e.m07,l.m08=e.m08):(l.m00=e,l.m01=i,l.m02=n,l.m03=r,l.m04=s,l.m05=a,l.m06=o,l.m07=h,l.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,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=l*a-o*u,_=-l*s+o*h,f=u*s-a*h,d=i*c+n*_+r*f;return 0===d?(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):(d=1/d,t.m00=c*d,t.m01=(-l*n+r*u)*d,t.m02=(o*n-r*a)*d,t.m03=_*d,t.m04=(l*i-r*h)*d,t.m05=(-o*i+r*s)*d,t.m06=f*d,t.m07=(-u*i+n*h)*d,t.m08=(a*i-n*s)*d,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,_=i.m00,f=i.m01,d=i.m02,p=i.m03,m=i.m04,g=i.m05,v=i.m06,y=i.m07,S=i.m08;return t.m00=_*n+f*a+d*u,t.m01=_*r+f*o+d*l,t.m02=_*s+f*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=v*n+y*a+S*u,t.m07=v*r+y*o+S*l,t.m08=v*s+y*h+S*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,_=i.m00,f=i.m01,d=i.m02,p=i.m04,m=i.m05,g=i.m06,v=i.m08,y=i.m09,S=i.m10;return t.m00=_*n+f*a+d*u,t.m01=_*r+f*o+d*l,t.m02=_*s+f*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=v*n+y*a+S*u,t.m07=v*r+y*o+S*l,t.m08=v*s+y*h+S*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,_=i.x,f=i.y;return t.m00=n,t.m01=r,t.m02=s,t.m03=a,t.m04=o,t.m05=h,t.m06=_*n+f*a+u,t.m07=_*r+f*o+l,t.m08=_*s+f*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,_=Math.sin(i),f=Math.cos(i);return t.m00=f*n+_*a,t.m01=f*r+_*o,t.m02=f*s+_*h,t.m03=f*a-_*n,t.m04=f*o-_*r,t.m05=f*h-_*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 gn.lengthSqr(i)-.999?(e.x=Math.asin(-o),e.y=Math.atan2(a,h),e.z=Math.atan2(n,s),!0):(e.x=Mi,e.y=Math.atan2(r,i),e.z=0,!1):(e.x=-Mi,e.y=Math.atan2(-r,i),e.z=0,!1)};var i=e.prototype;return i.clone=function(){var t=this;return new e(t.m00,t.m01,t.m02,t.m03,t.m04,t.m05,t.m06,t.m07,t.m08)},i.set=function(t,e,i,n,r,s,a,o,h){return 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),"object"==typeof t?(this.m00=t.m00,this.m01=t.m01,this.m02=t.m02,this.m03=t.m03,this.m04=t.m04,this.m05=t.m05,this.m06=t.m06,this.m07=t.m07,this.m08=t.m08):(this.m00=t,this.m01=e,this.m02=i,this.m03=n,this.m04=r,this.m05=s,this.m06=a,this.m07=o,this.m08=h),this},i.equals=function(t,e){return void 0===e&&(e=Oi),Math.abs(this.m00-t.m00)<=e*Math.max(1,Math.abs(this.m00),Math.abs(t.m00))&&Math.abs(this.m01-t.m01)<=e*Math.max(1,Math.abs(this.m01),Math.abs(t.m01))&&Math.abs(this.m02-t.m02)<=e*Math.max(1,Math.abs(this.m02),Math.abs(t.m02))&&Math.abs(this.m03-t.m03)<=e*Math.max(1,Math.abs(this.m03),Math.abs(t.m03))&&Math.abs(this.m04-t.m04)<=e*Math.max(1,Math.abs(this.m04),Math.abs(t.m04))&&Math.abs(this.m05-t.m05)<=e*Math.max(1,Math.abs(this.m05),Math.abs(t.m05))&&Math.abs(this.m06-t.m06)<=e*Math.max(1,Math.abs(this.m06),Math.abs(t.m06))&&Math.abs(this.m07-t.m07)<=e*Math.max(1,Math.abs(this.m07),Math.abs(t.m07))&&Math.abs(this.m08-t.m08)<=e*Math.max(1,Math.abs(this.m08),Math.abs(t.m08))},i.strictEquals=function(t){return this.m00===t.m00&&this.m01===t.m01&&this.m02===t.m02&&this.m03===t.m03&&this.m04===t.m04&&this.m05===t.m05&&this.m06===t.m06&&this.m07===t.m07&&this.m08===t.m08},i.toString=function(){var t=this;return"[\n"+t.m00+", "+t.m01+", "+t.m02+",\n"+t.m03+",\n"+t.m04+", "+t.m05+",\n"+t.m06+", "+t.m07+",\n"+t.m08+"\n]"},i.identity=function(){return this.m00=1,this.m01=0,this.m02=0,this.m03=0,this.m04=1,this.m05=0,this.m06=0,this.m07=0,this.m08=1,this},i.transpose=function(){var t=this.m01,e=this.m02,i=this.m05;return this.m01=this.m03,this.m02=this.m06,this.m03=t,this.m05=this.m07,this.m06=e,this.m07=i,this},i.invert=function(){var t=this.m00,e=this.m01,i=this.m02,n=this.m03,r=this.m04,s=this.m05,a=this.m06,o=this.m07,h=this.m08,u=h*r-s*o,l=-h*n+s*a,c=o*n-r*a,_=t*u+e*l+i*c;return 0===_?(this.set(0,0,0,0,0,0,0,0,0),this):(_=1/_,this.m00=u*_,this.m01=(-h*e+i*o)*_,this.m02=(s*e-i*r)*_,this.m03=l*_,this.m04=(h*t-i*a)*_,this.m05=(-s*t+i*n)*_,this.m06=c*_,this.m07=(-o*t+e*a)*_,this.m08=(r*t-e*n)*_,this)},i.determinant=function(){var t=this.m00,e=this.m01,i=this.m02,n=this.m03,r=this.m04,s=this.m05,a=this.m06,o=this.m07,h=this.m08;return t*(h*r-s*o)+e*(-h*n+s*a)+i*(o*n-r*a)},i.add=function(t){return this.m00+=t.m00,this.m01+=t.m01,this.m02+=t.m02,this.m03+=t.m03,this.m04+=t.m04,this.m05+=t.m05,this.m06+=t.m06,this.m07+=t.m07,this.m08+=t.m08,this},i.subtract=function(t){return this.m00-=t.m00,this.m01-=t.m01,this.m02-=t.m02,this.m03-=t.m03,this.m04-=t.m04,this.m05-=t.m05,this.m06-=t.m06,this.m07-=t.m07,this.m08-=t.m08,this},i.multiply=function(t){var e=this.m00,i=this.m01,n=this.m02,r=this.m03,s=this.m04,a=this.m05,o=this.m06,h=this.m07,u=this.m08,l=t.m00,c=t.m01,_=t.m02,f=t.m03,d=t.m04,p=t.m05,m=t.m06,g=t.m07,v=t.m08;return this.m00=l*e+c*r+_*o,this.m01=l*i+c*s+_*h,this.m02=l*n+c*a+_*u,this.m03=f*e+d*r+p*o,this.m04=f*i+d*s+p*h,this.m05=f*n+d*a+p*u,this.m06=m*e+g*r+v*o,this.m07=m*i+g*s+v*h,this.m08=m*n+g*a+v*u,this},i.multiplyScalar=function(t){return this.m00*=t,this.m01*=t,this.m02*=t,this.m03*=t,this.m04*=t,this.m05*=t,this.m06*=t,this.m07*=t,this.m08*=t,this},i.scale=function(t){var e=t.x,i=t.y;return this.m00*=e,this.m01*=e,this.m02*=e,this.m03*=i,this.m04*=i,this.m05*=i,this},i.rotate=function(t){var e=this.m00,i=this.m01,n=this.m02,r=this.m03,s=this.m04,a=this.m05,o=this.m06,h=this.m07,u=this.m08,l=Math.sin(t),c=Math.cos(t);return this.m00=c*e+l*r,this.m01=c*i+l*s,this.m02=c*n+l*a,this.m03=c*r-l*e,this.m04=c*s-l*i,this.m05=c*a-l*n,this.m06=o,this.m07=h,this.m08=u,this},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,_=n*a,f=n*o,d=r*s,p=r*a,m=r*o;return this.m00=1-l-f,this.m03=u-m,this.m06=c+p,this.m01=u+m,this.m04=1-h-f,this.m07=_-d,this.m02=c-p,this.m05=_+d,this.m08=1-h-l,this},e}(Ie));An=wn,wn.IDENTITY=Object.freeze(new An);var Rn,In=new gn,Dn=new gn;Ci.fastDefine("cc.Mat3",wn,{m00:1,m01:0,m02:0,m03:0,m04:1,m05:0,m06:0,m07:0,m08:1}),S.Mat3=wn;var Bn=t("aV",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=gn.dot(i,n);return r<-.999999?(gn.cross(Ln,gn.UNIT_X,i),Ln.length()<1e-6&&gn.cross(Ln,gn.UNIT_Y,i),gn.normalize(Ln,Ln),e.fromAxisAngle(t,Ln,Math.PI),t):r>.999999?(t.x=0,t.y=0,t.z=0,t.w=1,t):(gn.cross(Ln,i,n),t.x=Ln.x,t.y=Ln.y,t.z=Ln.z,t.w=1+r,e.normalize(t,t))},e.getAxisAngle=function(t,e){var i=2*Math.acos(e.w),n=Math.sin(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){i*=.5;var n=Math.sin(i),r=Math.cos(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){i*=.5;var n=Math.sin(i),r=Math.cos(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){i*=.5;var n=Math.sin(i),r=Math.cos(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(Pn,i),gn.transformQuat(Ln,n,Pn),e.fromAxisAngle(Pn,Ln,r),e.multiply(t,i,Pn),t},e.rotateAroundLocal=function(t,i,n,r){return e.fromAxisAngle(Pn,n,r),e.multiply(t,i,Pn),t},e.calculateW=function(t,e){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=Math.sqrt(Math.abs(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=Math.acos(l),_=Math.sin(c);r=Math.sin((1-n)*c)/_,s=Math.sin(n*c)/_}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(Pn,i,s,a),e.slerp(On,n,r,a),e.slerp(t,Pn,On,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 Math.sqrt(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/Math.sqrt(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 wn.set(Nn,i.x,i.y,i.z,n.x,n.y,n.z,r.x,r.y,r.z),e.normalize(t,e.fromMat3(t,Nn))},e.fromViewUp=function(t,i,n){return wn.fromViewUp(Nn,i,n),e.normalize(t,e.fromMat3(t,Nn))},e.fromAxisAngle=function(t,e,i){i*=.5;var n=Math.sin(i);return t.x=n*e.x,t.y=n*e.y,t.z=n*e.z,t.w=Math.cos(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,_=a-i-l,f=l-i-a,d=0,p=i+a+l;c>p&&(p=c,d=1),_>p&&(p=_,d=2),f>p&&(p=f,d=3);var m=.5*Math.sqrt(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){e*=Fn,i*=Fn,n*=Fn;var r=Math.sin(e),s=Math.cos(e),a=Math.sin(i),o=Math.cos(i),h=Math.sin(n),u=Math.cos(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*=Fn,t.x=t.y=0,t.z=Math.sin(e),t.w=Math.cos(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=Ui(2*Math.atan2(n,a)),u=90;else if(l<-.499999)o=0,h=-Ui(2*Math.atan2(n,a)),u=-90;else{var c=n*n,_=r*r,f=s*s;o=Ui(Math.atan2(2*n*a-2*r*s,1-2*c-2*f)),h=Ui(Math.atan2(2*r*a-2*n*s,1-2*_-2*f)),u=Ui(Math.asin(2*l)),i&&(o=-180*Math.sign(o+1e-6)+o,h=-180*Math.sign(h+1e-6)+h,u=180*Math.sign(u+1e-6)-u)}return t.x=o,t.y=h,t.z=u,t},e.toEulerInYXZOrder=function(t,e){wn.fromQuat(Nn,e),wn.toEuler(Nn,t),t.x=Ui(t.x),t.y=Ui(t.y),t.z=Ui(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=Oi),Math.abs(t.x-e.x)<=i*Math.max(1,Math.abs(t.x),Math.abs(e.x))&&Math.abs(t.y-e.y)<=i*Math.max(1,Math.abs(t.y),Math.abs(e.y))&&Math.abs(t.z-e.z)<=i*Math.max(1,Math.abs(t.z),Math.abs(e.z))&&Math.abs(t.w-e.w)<=i*Math.max(1,Math.abs(t.w),Math.abs(e.w))},e.angle=function(t,i){var n=Math.min(Math.abs(e.dot(t,i)),1);return 2*Math.acos(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=Math.min(r/Ui(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,e){return void 0===e&&(e=Oi),Math.abs(this.x-t.x)<=e*Math.max(1,Math.abs(this.x),Math.abs(t.x))&&Math.abs(this.y-t.y)<=e*Math.max(1,Math.abs(this.y),Math.abs(t.y))&&Math.abs(this.z-t.z)<=e*Math.max(1,Math.abs(this.z),Math.abs(t.z))&&Math.abs(this.w-t.w)<=e*Math.max(1,Math.abs(this.w),Math.abs(t.w))},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){return this.x+=e*(t.x-this.x),this.y+=e*(t.y-this.y),this.z+=e*(t.z-this.z),this.w+=e*(t.w-this.w),this},i.slerp=function(t,i){return e.slerp(this,this,t,i)},i.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},i.lengthSqr=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},e}(Ie));Rn=Bn,Bn.IDENTITY=Object.freeze(new Rn);var Mn,Pn=new Bn,On=new Bn,Ln=new gn,Nn=new wn,Fn=.5*Math.PI/180;function kn(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 Bn(t,e,i,n)}Ci.fastDefine("cc.Quat",Bn,{x:0,y:0,z:0,w:1}),S.Quat=Bn,S.quat=kn;var Gn=t("b5",Object.freeze([Object.freeze([1,0,0,1]),Object.freeze([0,1,-1,0]),Object.freeze([-1,0,0,-1]),Object.freeze([0,-1,1,0])])),Vn=t("aY",function(t){function e(e,i,n,r,s,a,o,h,u,l,c,_,f,d,p,m){var g;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=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===f&&(f=0),void 0===d&&(d=0),void 0===p&&(p=0),void 0===m&&(m=1),g=t.call(this)||this,"object"==typeof e?(g.m00=e.m00,g.m01=e.m01,g.m02=e.m02,g.m03=e.m03,g.m04=e.m04,g.m05=e.m05,g.m06=e.m06,g.m07=e.m07,g.m08=e.m08,g.m09=e.m09,g.m10=e.m10,g.m11=e.m11,g.m12=e.m12,g.m13=e.m13,g.m14=e.m14,g.m15=e.m15):(g.m00=e,g.m01=i,g.m02=n,g.m03=r,g.m04=s,g.m05=a,g.m06=o,g.m07=h,g.m08=u,g.m09=l,g.m10=c,g.m11=_,g.m12=f,g.m13=d,g.m14=p,g.m15=m),g}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=_,t.m12=f,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.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,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,_=e.m10,f=e.m11,d=e.m12,p=e.m13,m=e.m14,g=e.m15,v=i*o-n*a,y=i*h-r*a,S=i*u-s*a,T=n*h-r*o,A=n*u-s*o,b=r*u-s*h,E=l*p-c*d,C=l*m-_*d,x=l*g-f*d,w=c*m-_*p,R=c*g-f*p,I=_*g-f*m,D=v*I-y*R+S*w+T*x-A*C+b*E;return 0===D?(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):(D=1/D,t.m00=(o*I-h*R+u*w)*D,t.m01=(r*R-n*I-s*w)*D,t.m02=(p*b-m*A+g*T)*D,t.m03=(_*A-c*b-f*T)*D,t.m04=(h*x-a*I-u*C)*D,t.m05=(i*I-r*x+s*C)*D,t.m06=(m*S-d*b-g*y)*D,t.m07=(l*b-_*S+f*y)*D,t.m08=(a*R-o*x+u*E)*D,t.m09=(n*x-i*R-s*E)*D,t.m10=(d*A-p*S+g*v)*D,t.m11=(c*S-l*A-f*v)*D,t.m12=(o*C-a*w-h*E)*D,t.m13=(i*w-n*C+r*E)*D,t.m14=(p*y-d*T-m*v)*D,t.m15=(l*T-c*y+_*v)*D,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,_=t.m11,f=t.m12,d=t.m13,p=t.m14,m=t.m15;return(e*a-i*s)*(c*m-_*p)-(e*o-n*s)*(l*m-_*d)+(e*h-r*s)*(l*p-c*d)+(i*o-n*a)*(u*m-_*f)-(i*h-r*a)*(u*p-c*f)+(n*h-r*o)*(u*d-l*f)},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,_=e.m09,f=e.m10,d=e.m11,p=e.m12,m=e.m13,g=e.m14,v=e.m15,y=i.m00,S=i.m01,T=i.m02,A=i.m03;return t.m00=y*n+S*o+T*c+A*p,t.m01=y*r+S*h+T*_+A*m,t.m02=y*s+S*u+T*f+A*g,t.m03=y*a+S*l+T*d+A*v,y=i.m04,S=i.m05,T=i.m06,A=i.m07,t.m04=y*n+S*o+T*c+A*p,t.m05=y*r+S*h+T*_+A*m,t.m06=y*s+S*u+T*f+A*g,t.m07=y*a+S*l+T*d+A*v,y=i.m08,S=i.m09,T=i.m10,A=i.m11,t.m08=y*n+S*o+T*c+A*p,t.m09=y*r+S*h+T*_+A*m,t.m10=y*s+S*u+T*f+A*g,t.m11=y*a+S*l+T*d+A*v,y=i.m12,S=i.m13,T=i.m14,A=i.m15,t.m12=y*n+S*o+T*c+A*p,t.m13=y*r+S*h+T*_+A*m,t.m14=y*s+S*u+T*f+A*g,t.m15=y*a+S*l+T*d+A*v,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,_=e.m06,f=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=_,t.m07=f,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+_*r+m*s+e.m14,t.m15=u*n+f*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=Math.sqrt(r*r+s*s+a*a);if(Math.abs(o)0?(n=2*Math.sqrt(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*Math.sqrt(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*Math.sqrt(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*Math.sqrt(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&&gn.set(i,t.m12,t.m13,t.m14);var r=gn.set(zn,t.m00,t.m01,t.m02).length(),s=gn.set(zn,t.m04,t.m05,t.m06).length(),a=gn.set(zn,t.m08,t.m09,t.m10).length();if(n&&(n.x=r,n.y=s,n.z=a),0!==r&&0!==s&&0!==a){Hn.m00=t.m00/r,Hn.m01=t.m01/r,Hn.m02=t.m02/r,Hn.m03=t.m04/s,Hn.m04=t.m05/s,Hn.m05=t.m06/s,Hn.m06=t.m08/a,Hn.m07=t.m09/a,Hn.m08=t.m10/a;var o=wn.determinant(Hn);n&&o<0&&(n.x*=-1),e&&(o<0&&(Hn.m00*=-1,Hn.m01*=-1,Hn.m02*=-1),Bn.fromMat3(e,Hn))}else e&&Bn.identity(e)},e.toEuler=function(t,e){return wn.set(Hn,t.m00,t.m01,t.m02,t.m04,t.m05,t.m06,t.m08,t.m09,t.m10),wn.toEuler(Hn,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,_=r*u,f=r*l,d=s*u,p=s*l,m=a*l,g=o*h,v=o*u,y=o*l,S=n.x,T=n.y,A=n.z;return t.m00=(1-(d+m))*S,t.m01=(_+y)*S,t.m02=(f-v)*S,t.m03=0,t.m04=(_-y)*T,t.m05=(1-(c+m))*T,t.m06=(p+g)*T,t.m07=0,t.m08=(f+v)*A,t.m09=(p-g)*A,t.m10=(1-(c+d))*A,t.m11=0,t.m12=i.x,t.m13=i.y,t.m14=i.z,t.m15=1,t},e.fromRTSOrigin=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,_=s*u,f=s*l,d=s*c,p=a*l,m=a*c,g=o*c,v=h*u,y=h*l,S=h*c,T=n.x,A=n.y,b=n.z,E=r.x,C=r.y,x=r.z;return t.m00=(1-(p+g))*T,t.m01=(f+S)*T,t.m02=(d-y)*T,t.m03=0,t.m04=(f-S)*A,t.m05=(1-(_+g))*A,t.m06=(m+v)*A,t.m07=0,t.m08=(d+y)*b,t.m09=(m-v)*b,t.m10=(1-(_+p))*b,t.m11=0,t.m12=i.x+E-(t.m00*E+t.m04*C+t.m08*x),t.m13=i.y+C-(t.m01*E+t.m05*C+t.m09*x),t.m14=i.z+x-(t.m02*E+t.m06*C+t.m10*x),t.m15=1,t},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,_=s*u,f=s*l,d=s*c,p=a*l,m=a*c,g=o*c,v=h*u,y=h*l,S=h*c,T=n.x,A=n.y,b=n.z,E=r.x,C=r.y,x=r.z;return t.m00=(1-(p+g))*T,t.m01=(f+S)*T,t.m02=(d-y)*T,t.m03=0,t.m04=(f-S)*A,t.m05=(1-(_+g))*A,t.m06=(m+v)*A,t.m07=0,t.m08=(d+y)*b,t.m09=(m-v)*b,t.m10=(1-(_+p))*b,t.m11=0,t.m12=i.x+E-(t.m00*E+t.m04*C+t.m08*x),t.m13=i.y+C-(t.m01*E+t.m05*C+t.m09*x),t.m14=i.z+x-(t.m02*E+t.m06*C+t.m10*x),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,_=r*a,f=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=_-m,t.m03=0,t.m04=l-g,t.m05=1-u-d,t.m06=f+p,t.m07=0,t.m08=_+m,t.m09=f-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/Math.tan(e/2),l=1/(n-r),c=s?u/i:u,_=(s?u:u*i)*o,f=Gn[h];return t.m00=c*f[0],t.m01=c*f[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,_=1/(s-a),f=-2*l,d=-2*c,p=(e+i)*l,m=(r+n)*c,g=Gn[u];return t.m00=f*g[0],t.m01=f*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=_*(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)*_,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,_=a-i.z,f=1/Math.sqrt(l*l+c*c+_*_),d=h*(_*=f)-u*(c*=f),p=u*(l*=f)-o*_,m=o*c-h*l,g=c*(m*=f=1/Math.sqrt(d*d+p*p+m*m))-_*(p*=f),v=_*(d*=f)-l*m,y=l*p-c*d;return t.m00=d,t.m01=g,t.m02=l,t.m03=0,t.m04=p,t.m05=v,t.m06=c,t.m07=0,t.m08=m,t.m09=y,t.m10=_,t.m11=0,t.m12=-(d*r+p*s+m*a),t.m13=-(g*r+v*s+y*a),t.m14=-(l*r+c*s+_*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,_=e.m10,f=e.m11,d=e.m12,p=e.m13,m=e.m14,g=e.m15,v=i*o-n*a,y=i*h-r*a,S=i*u-s*a,T=n*h-r*o,A=n*u-s*o,b=r*u-s*h,E=l*p-c*d,C=l*m-_*d,x=l*g-f*d,w=c*m-_*p,R=c*g-f*p,I=_*g-f*m,D=v*I-y*R+S*w+T*x-A*C+b*E;return D?(D=1/D,t.m00=(o*I-h*R+u*w)*D,t.m01=(h*x-a*I-u*C)*D,t.m02=(a*R-o*x+u*E)*D,t.m03=0,t.m04=(r*R-n*I-s*w)*D,t.m05=(i*I-r*x+s*C)*D,t.m06=(n*x-i*R-s*E)*D,t.m07=0,t.m08=(p*b-m*A+g*T)*D,t.m09=(m*S-d*b-g*y)*D,t.m10=(d*A-p*S+g*v)*D,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=Oi),Math.abs(t.m00-e.m00)<=i*Math.max(1,Math.abs(t.m00),Math.abs(e.m00))&&Math.abs(t.m01-e.m01)<=i*Math.max(1,Math.abs(t.m01),Math.abs(e.m01))&&Math.abs(t.m02-e.m02)<=i*Math.max(1,Math.abs(t.m02),Math.abs(e.m02))&&Math.abs(t.m03-e.m03)<=i*Math.max(1,Math.abs(t.m03),Math.abs(e.m03))&&Math.abs(t.m04-e.m04)<=i*Math.max(1,Math.abs(t.m04),Math.abs(e.m04))&&Math.abs(t.m05-e.m05)<=i*Math.max(1,Math.abs(t.m05),Math.abs(e.m05))&&Math.abs(t.m06-e.m06)<=i*Math.max(1,Math.abs(t.m06),Math.abs(e.m06))&&Math.abs(t.m07-e.m07)<=i*Math.max(1,Math.abs(t.m07),Math.abs(e.m07))&&Math.abs(t.m08-e.m08)<=i*Math.max(1,Math.abs(t.m08),Math.abs(e.m08))&&Math.abs(t.m09-e.m09)<=i*Math.max(1,Math.abs(t.m09),Math.abs(e.m09))&&Math.abs(t.m10-e.m10)<=i*Math.max(1,Math.abs(t.m10),Math.abs(e.m10))&&Math.abs(t.m11-e.m11)<=i*Math.max(1,Math.abs(t.m11),Math.abs(e.m11))&&Math.abs(t.m12-e.m12)<=i*Math.max(1,Math.abs(t.m12),Math.abs(e.m12))&&Math.abs(t.m13-e.m13)<=i*Math.max(1,Math.abs(t.m13),Math.abs(e.m13))&&Math.abs(t.m14-e.m14)<=i*Math.max(1,Math.abs(t.m14),Math.abs(e.m14))&&Math.abs(t.m15-e.m15)<=i*Math.max(1,Math.abs(t.m15),Math.abs(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){return 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===_&&(_=0),void 0===f&&(f=0),void 0===d&&(d=0),void 0===p&&(p=1),"object"==typeof t?(this.m01=t.m01,this.m02=t.m02,this.m03=t.m03,this.m04=t.m04,this.m05=t.m05,this.m06=t.m06,this.m07=t.m07,this.m08=t.m08,this.m09=t.m09,this.m10=t.m10,this.m11=t.m11,this.m12=t.m12,this.m13=t.m13,this.m14=t.m14,this.m15=t.m15,this.m00=t.m00):(this.m01=e,this.m02=i,this.m03=n,this.m04=r,this.m05=s,this.m06=a,this.m07=o,this.m08=h,this.m09=u,this.m10=l,this.m11=c,this.m12=_,this.m13=f,this.m14=d,this.m15=p,this.m00=t),this},i.equals=function(t,e){return void 0===e&&(e=Oi),!(Math.abs(this.m00)===1/0||Math.abs(this.m01)===1/0||Math.abs(this.m02)===1/0||Math.abs(this.m03)===1/0||Math.abs(this.m04)===1/0||Math.abs(this.m05)===1/0||Math.abs(this.m06)===1/0||Math.abs(this.m07)===1/0||Math.abs(this.m08)===1/0||Math.abs(this.m09)===1/0||Math.abs(this.m10)===1/0||Math.abs(this.m11)===1/0||Math.abs(this.m12)===1/0||Math.abs(this.m13)===1/0||Math.abs(this.m14)===1/0||Math.abs(this.m15)===1/0)&&Math.abs(this.m00-t.m00)<=e*Math.max(1,Math.abs(this.m00),Math.abs(t.m00))&&Math.abs(this.m01-t.m01)<=e*Math.max(1,Math.abs(this.m01),Math.abs(t.m01))&&Math.abs(this.m02-t.m02)<=e*Math.max(1,Math.abs(this.m02),Math.abs(t.m02))&&Math.abs(this.m03-t.m03)<=e*Math.max(1,Math.abs(this.m03),Math.abs(t.m03))&&Math.abs(this.m04-t.m04)<=e*Math.max(1,Math.abs(this.m04),Math.abs(t.m04))&&Math.abs(this.m05-t.m05)<=e*Math.max(1,Math.abs(this.m05),Math.abs(t.m05))&&Math.abs(this.m06-t.m06)<=e*Math.max(1,Math.abs(this.m06),Math.abs(t.m06))&&Math.abs(this.m07-t.m07)<=e*Math.max(1,Math.abs(this.m07),Math.abs(t.m07))&&Math.abs(this.m08-t.m08)<=e*Math.max(1,Math.abs(this.m08),Math.abs(t.m08))&&Math.abs(this.m09-t.m09)<=e*Math.max(1,Math.abs(this.m09),Math.abs(t.m09))&&Math.abs(this.m10-t.m10)<=e*Math.max(1,Math.abs(this.m10),Math.abs(t.m10))&&Math.abs(this.m11-t.m11)<=e*Math.max(1,Math.abs(this.m11),Math.abs(t.m11))&&Math.abs(this.m12-t.m12)<=e*Math.max(1,Math.abs(this.m12),Math.abs(t.m12))&&Math.abs(this.m13-t.m13)<=e*Math.max(1,Math.abs(this.m13),Math.abs(t.m13))&&Math.abs(this.m14-t.m14)<=e*Math.max(1,Math.abs(this.m14),Math.abs(t.m14))&&Math.abs(this.m15-t.m15)<=e*Math.max(1,Math.abs(this.m15),Math.abs(t.m15))},i.strictEquals=function(t){return this.m00===t.m00&&this.m01===t.m01&&this.m02===t.m02&&this.m03===t.m03&&this.m04===t.m04&&this.m05===t.m05&&this.m06===t.m06&&this.m07===t.m07&&this.m08===t.m08&&this.m09===t.m09&&this.m10===t.m10&&this.m11===t.m11&&this.m12===t.m12&&this.m13===t.m13&&this.m14===t.m14&&this.m15===t.m15},i.toString=function(){return"[\n"+this.m00+", "+this.m01+", "+this.m02+", "+this.m03+",\n"+this.m04+", "+this.m05+", "+this.m06+", "+this.m07+",\n"+this.m08+", "+this.m09+", "+this.m10+", "+this.m11+",\n"+this.m12+", "+this.m13+", "+this.m14+", "+this.m15+"\n]"},i.identity=function(){return this.m00=1,this.m01=0,this.m02=0,this.m03=0,this.m04=0,this.m05=1,this.m06=0,this.m07=0,this.m08=0,this.m09=0,this.m10=1,this.m11=0,this.m12=0,this.m13=0,this.m14=0,this.m15=1,this},i.zero=function(){return this.m00=0,this.m01=0,this.m02=0,this.m03=0,this.m04=0,this.m05=0,this.m06=0,this.m07=0,this.m08=0,this.m09=0,this.m10=0,this.m11=0,this.m12=0,this.m13=0,this.m14=0,this.m15=0,this},i.transpose=function(){var t=this.m01,e=this.m02,i=this.m03,n=this.m06,r=this.m07,s=this.m11;return this.m01=this.m04,this.m02=this.m08,this.m03=this.m12,this.m04=t,this.m06=this.m09,this.m07=this.m13,this.m08=e,this.m09=n,this.m11=this.m14,this.m12=i,this.m13=r,this.m14=s,this},i.invert=function(){var t=this.m00,e=this.m01,i=this.m02,n=this.m03,r=this.m04,s=this.m05,a=this.m06,o=this.m07,h=this.m08,u=this.m09,l=this.m10,c=this.m11,_=this.m12,f=this.m13,d=this.m14,p=this.m15,m=t*s-e*r,g=t*a-i*r,v=t*o-n*r,y=e*a-i*s,S=e*o-n*s,T=i*o-n*a,A=h*f-u*_,b=h*d-l*_,E=h*p-c*_,C=u*d-l*f,x=u*p-c*f,w=l*p-c*d,R=m*w-g*x+v*C+y*E-S*b+T*A;return 0===R?(this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),this):(R=1/R,this.m00=(s*w-a*x+o*C)*R,this.m01=(i*x-e*w-n*C)*R,this.m02=(f*T-d*S+p*y)*R,this.m03=(l*S-u*T-c*y)*R,this.m04=(a*E-r*w-o*b)*R,this.m05=(t*w-i*E+n*b)*R,this.m06=(d*v-_*T-p*g)*R,this.m07=(h*T-l*v+c*g)*R,this.m08=(r*x-s*E+o*A)*R,this.m09=(e*E-t*x-n*A)*R,this.m10=(_*S-f*v+p*m)*R,this.m11=(u*v-h*S-c*m)*R,this.m12=(s*b-r*C-a*A)*R,this.m13=(t*C-e*b+i*A)*R,this.m14=(f*g-_*y-d*m)*R,this.m15=(h*y-u*g+l*m)*R,this)},i.determinant=function(){var t=this.m00,e=this.m01,i=this.m02,n=this.m03,r=this.m04,s=this.m05,a=this.m06,o=this.m07,h=this.m08,u=this.m09,l=this.m10,c=this.m11,_=this.m12,f=this.m13,d=this.m14,p=this.m15;return(t*s-e*r)*(l*p-c*d)-(t*a-i*r)*(u*p-c*f)+(t*o-n*r)*(u*d-l*f)+(e*a-i*s)*(h*p-c*_)-(e*o-n*s)*(h*d-l*_)+(i*o-n*a)*(h*f-u*_)},i.add=function(t){return this.m00+=t.m00,this.m01+=t.m01,this.m02+=t.m02,this.m03+=t.m03,this.m04+=t.m04,this.m05+=t.m05,this.m06+=t.m06,this.m07+=t.m07,this.m08+=t.m08,this.m09+=t.m09,this.m10+=t.m10,this.m11+=t.m11,this.m12+=t.m12,this.m13+=t.m13,this.m14+=t.m14,this.m15+=t.m15,this},i.subtract=function(t){return this.m00-=t.m00,this.m01-=t.m01,this.m02-=t.m02,this.m03-=t.m03,this.m04-=t.m04,this.m05-=t.m05,this.m06-=t.m06,this.m07-=t.m07,this.m08-=t.m08,this.m09-=t.m09,this.m10-=t.m10,this.m11-=t.m11,this.m12-=t.m12,this.m13-=t.m13,this.m14-=t.m14,this.m15-=t.m15,this},i.multiply=function(t){var e=this.m00,i=this.m01,n=this.m02,r=this.m03,s=this.m04,a=this.m05,o=this.m06,h=this.m07,u=this.m08,l=this.m09,c=this.m10,_=this.m11,f=this.m12,d=this.m13,p=this.m14,m=this.m15,g=t.m00,v=t.m01,y=t.m02,S=t.m03;return this.m00=g*e+v*s+y*u+S*f,this.m01=g*i+v*a+y*l+S*d,this.m02=g*n+v*o+y*c+S*p,this.m03=g*r+v*h+y*_+S*m,g=t.m04,v=t.m05,y=t.m06,S=t.m07,this.m04=g*e+v*s+y*u+S*f,this.m05=g*i+v*a+y*l+S*d,this.m06=g*n+v*o+y*c+S*p,this.m07=g*r+v*h+y*_+S*m,g=t.m08,v=t.m09,y=t.m10,S=t.m11,this.m08=g*e+v*s+y*u+S*f,this.m09=g*i+v*a+y*l+S*d,this.m10=g*n+v*o+y*c+S*p,this.m11=g*r+v*h+y*_+S*m,g=t.m12,v=t.m13,y=t.m14,S=t.m15,this.m12=g*e+v*s+y*u+S*f,this.m13=g*i+v*a+y*l+S*d,this.m14=g*n+v*o+y*c+S*p,this.m15=g*r+v*h+y*_+S*m,this},i.multiplyScalar=function(t){return this.m00*=t,this.m01*=t,this.m02*=t,this.m03*=t,this.m04*=t,this.m05*=t,this.m06*=t,this.m07*=t,this.m08*=t,this.m09*=t,this.m10*=t,this.m11*=t,this.m12*=t,this.m13*=t,this.m14*=t,this.m15*=t,this},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.m00,s=this.m01,a=this.m02,o=this.m03,h=this.m04,u=this.m05,l=this.m06,c=this.m07,_=this.m08,f=this.m09,d=this.m10,p=this.m11;return this.m12=r*e+h*i+_*n+this.m12,this.m13=s*e+u*i+f*n+this.m13,this.m14=a*e+l*i+d*n+this.m14,this.m15=o*e+c*i+p*n+this.m15,this},i.scale=function(t){var e=t.x,i=t.y,n=t.z;return this.m00*=e,this.m01*=e,this.m02*=e,this.m03*=e,this.m04*=i,this.m05*=i,this.m06*=i,this.m07*=i,this.m08*=n,this.m09*=n,this.m10*=n,this.m11*=n,this},i.rotate=function(t,e){var i=e.x,n=e.y,r=e.z,s=Math.sqrt(i*i+n*n+r*r);if(Math.abs(s)0?(r=1/Math.sqrt(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 gn?(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*zi()*Math.PI;return t.x=Math.cos(i)*e,t.y=Math.sin(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=Oi),Math.abs(t.x-e.x)<=i*Math.max(1,Math.abs(t.x),Math.abs(e.x))&&Math.abs(t.y-e.y)<=i*Math.max(1,Math.abs(t.y),Math.abs(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)/Math.sqrt(i*n);return r=Fi(r,-1,1),Math.acos(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,e){return void 0===e&&(e=Oi),Math.abs(this.x-t.x)<=e*Math.max(1,Math.abs(this.x),Math.abs(t.x))&&Math.abs(this.y-t.y)<=e*Math.max(1,Math.abs(this.y),Math.abs(t.y))},i.equals2f=function(t,e,i){return void 0===i&&(i=Oi),Math.abs(this.x-t)<=i*Math.max(1,Math.abs(this.x),Math.abs(t))&&Math.abs(this.y-e)<=i*Math.max(1,Math.abs(this.y),Math.abs(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.toFixed(2)+", "+this.y.toFixed(2)+")"},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=Fi(this.x,t.x,e.x),this.y=Fi(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&&tt(16359),this.x*=t,this.y*=t,this},i.multiply=function(t){return"object"!=typeof t&&tt(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 Math.sqrt(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.x,e=this.y,i=t*t+e*e;return i>0&&(i=1/Math.sqrt(i),this.x*=i,this.y*=i),this},i.angle=function(t){var e=this.lengthSqr(),i=t.lengthSqr();if(0===e||0===i)return 0;var n=this.dot(t)/Math.sqrt(e*i);return n=Fi(n,-1,1),Math.acos(n)},i.signAngle=function(t){var e=this.cross(t),i=this.dot(t);return Math.atan2(e,i)},i.rotate=function(t){var e=this.x,i=this.y,n=Math.sin(t),r=Math.cos(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 gn(this.x,this.y,0)},e}(Ie));function Yn(t,e){return new jn(t,e)}Un=jn,jn.ZERO=Object.freeze(new Un(0,0)),jn.ONE=Object.freeze(new Un(1,1)),jn.NEG_ONE=Object.freeze(new Un(-1,-1)),jn.UNIT_X=Object.freeze(new Un(1,0)),jn.UNIT_Y=Object.freeze(new Un(0,1)),Ci.fastDefine("cc.Vec2",jn,{x:0,y:0}),S.Vec2=jn,S.v2=Yn,ut(jn,"Vec2",[{name:"sub",newName:"subtract",target:jn,targetName:"Vec2"},{name:"mul",newName:"multiply",target:jn,targetName:"Vec2"},{name:"div",newName:"divide",target:jn,targetName:"Vec2"},{name:"dist",newName:"distance",target:jn,targetName:"Vec2"},{name:"sqrDist",newName:"squaredDistance",target:jn,targetName:"Vec2"},{name:"mag",newName:"len",target:jn,targetName:"Vec2"},{name:"sqrMag",newName:"lengthSqr",target:jn,targetName:"Vec2"},{name:"scale",newName:"multiplyScalar",target:jn,targetName:"Vec2"},{name:"exactEquals",newName:"strictEquals",target:jn,targetName:"Vec2"}]),ut(jn.prototype,"Vec2",[{name:"mag",newName:"length",target:jn.prototype,targetName:"Vec2"},{name:"magSqr",newName:"lengthSqr",target:jn.prototype,targetName:"Vec2"},{name:"scale",newName:"multiplyScalar",target:jn.prototype,targetName:"Vec2"},{name:"exactEquals",newName:"strictEquals",target:jn.prototype,targetName:"Vec2"}]),ut(gn,"Vec3",[{name:"sub",newName:"subtract",target:gn,targetName:"Vec3"},{name:"mul",newName:"multiply",target:gn,targetName:"Vec3"},{name:"div",newName:"divide",target:gn,targetName:"Vec3"},{name:"dist",newName:"distance",target:gn,targetName:"Vec3"},{name:"sqrDist",newName:"squaredDistance",target:gn,targetName:"Vec3"},{name:"mag",newName:"len",target:gn,targetName:"Vec3"},{name:"sqrMag",newName:"lengthSqr",target:gn,targetName:"Vec3"},{name:"scale",newName:"multiplyScalar",target:gn,targetName:"Vec3"},{name:"exactEquals",newName:"strictEquals",target:gn,targetName:"Vec3"}]),ut(gn.prototype,"Vec3",[{name:"mag",newName:"length",target:gn.prototype,targetName:"Vec3"},{name:"magSqr",newName:"lengthSqr",target:gn.prototype,targetName:"Vec3"},{name:"scale",newName:"multiplyScalar",target:gn.prototype,targetName:"Vec3"},{name:"exactEquals",newName:"strictEquals",target:gn.prototype,targetName:"Vec3"}]),ut(cn,"Vec4",[{name:"sub",newName:"subtract",target:cn,targetName:"Vec4"},{name:"mul",newName:"multiply",target:cn,targetName:"Vec4"},{name:"div",newName:"divide",target:cn,targetName:"Vec4"},{name:"dist",newName:"distance",target:cn,targetName:"Vec4"},{name:"sqrDist",newName:"squaredDistance",target:cn,targetName:"Vec4"},{name:"mag",newName:"len",target:cn,targetName:"Vec4"},{name:"sqrMag",newName:"lengthSqr",target:cn,targetName:"Vec4"},{name:"scale",newName:"multiplyScalar",target:cn,targetName:"Vec4"},{name:"exactEquals",newName:"strictEquals",target:cn,targetName:"Vec4"}]),ut(cn.prototype,"Vec4",[{name:"mag",newName:"length",target:cn.prototype,targetName:"Vec4"},{name:"magSqr",newName:"lengthSqr",target:cn.prototype,targetName:"Vec4"},{name:"scale",newName:"multiplyScalar",target:cn.prototype,targetName:"Vec4"},{name:"exactEquals",newName:"strictEquals",target:cn.prototype,targetName:"Vec4"}]),ut(Bn,"Quat",[{name:"mag",newName:"len",target:Bn,targetName:"Quat"},{name:"mul",newName:"multiply",target:Bn,targetName:"Quat"},{name:"sqrMag",newName:"lengthSqr",target:Bn,targetName:"Quat"},{name:"scale",newName:"multiplyScalar",target:Bn,targetName:"Quat"},{name:"exactEquals",newName:"strictEquals",target:Bn,targetName:"Quat"}]),ut(Bn.prototype,"Quat",[{name:"scale",newName:"multiplyScalar",target:Bn.prototype,targetName:"Quat"},{name:"exactEquals",newName:"strictEquals",target:Bn.prototype,targetName:"Quat"}]),ut(En,"Color",[{name:"sub",newName:"subtract",target:En,targetName:"Color"},{name:"mul",newName:"multiply",target:En,targetName:"Color"},{name:"div",newName:"divide",target:En,targetName:"Color"},{name:"exactEquals",newName:"strictEquals",target:En,targetName:"Color"},{name:"fromHex",newName:"fromHEX",customFunction:function(){for(var t=arguments.length,e=new Array(t),i=0;i=t.x&&this.y<=t.y&&this.y+this.height>=t.y},i.containsRect=function(t){return this.x<=t.x&&this.x+this.width>=t.x+t.width&&this.y<=t.y&&this.y+this.height>=t.y+t.height},i.transformMat4=function(t){var e=this.x,i=this.y,n=e+this.width,r=i+this.height,s=t.m00*e+t.m04*i+t.m12,a=t.m01*e+t.m05*i+t.m13,o=t.m00*n+t.m04*i+t.m12,h=t.m01*n+t.m05*i+t.m13,u=t.m00*e+t.m04*r+t.m12,l=t.m01*e+t.m05*r+t.m13,c=t.m00*n+t.m04*r+t.m12,_=t.m01*n+t.m05*r+t.m13,f=Math.min(s,o,u,c),d=Math.max(s,o,u,c),p=Math.min(a,h,l,_),m=Math.max(a,h,l,_);return this.x=f,this.y=p,this.width=d-f,this.height=m-p,this},i.transformMat4ToPoints=function(t,e,i,n,r){var s=this.x,a=this.y,o=s+this.width,h=a+this.height;e.x=t.m00*s+t.m04*a+t.m12,e.y=t.m01*s+t.m05*a+t.m13,r.x=t.m00*o+t.m04*a+t.m12,r.y=t.m01*o+t.m05*a+t.m13,i.x=t.m00*s+t.m04*h+t.m12,i.y=t.m01*s+t.m05*h+t.m13,n.x=t.m00*o+t.m04*h+t.m12,n.y=t.m01*o+t.m05*h+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 jn(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 jn(this.x,this.y)},set:function(t){this.x=t.x,this.y=t.y}},{key:"size",get:function(){return new Qn(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}(Ie));function $n(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 Jn(t,e,i,n)}Ci.fastDefine("cc.Rect",Jn,{x:0,y:0,width:0,height:0}),S.Rect=Jn,S.rect=$n;var tr=t("bw",Float64Array),er=t("bx",function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.createFloatArray=function(t){return new tr(t)},n(e,[{key:"array",get:function(){return this._array}}]),e}(Ie)),ir=Object.freeze({__proto__:null,bits:B,Vec2:jn,v2:Yn,Vec3:gn,v3:vn,Vec4:cn,v4:_n,Quat:Bn,quat:kn,Mat3:wn,Mat4:Vn,mat4:Wn,AffineTransform:Kn,Size:Qn,size:Zn,Rect:Jn,rect:$n,Color:En,color:Cn,preTransforms:Gn,HALF_PI:Mi,TWO_PI:Pi,EPSILON:Oi,equals:Li,approx:Ni,clamp:Fi,clamp01:ki,lerp:Gi,toRadian:Vi,toDegree:Ui,random:zi,setRandGenerator:Hi,randomRange:Wi,randomRangeInt:Xi,pseudoRandom:ji,pseudoRandomRange:Yi,pseudoRandomRangeInt:qi,nextPow2:Ki,repeat:Qi,pingPong:Zi,inverseLerp:Ji,absMaxComponent:$i,absMax:tn,enumerableProps:en,floatToHalf:hn,halfToFloat:un,MATH_FLOAT_ARRAY:tr,MathBase:er});t("aJ",ir);var nr=new gn,rr=new gn,sr=new gn,ar=new gn,or=new gn,hr=new gn,ur=new Array(3),lr=new Array(3);function cr(t,e){return gn.dot(e.n,t)-e.d}function _r(t,e,i){return gn.copy(t,e),gn.subtract(or,i.center,i.halfExtents),gn.add(hr,i.center,i.halfExtents),t.x=t.xhr.x?hr.x:t.x,t.y=t.y>hr.y?hr.y:t.y,t.z=t.z>hr.z?hr.z:t.z,t}function fr(t,e,i){gn.set(nr,i.orientation.m00,i.orientation.m01,i.orientation.m02),gn.set(rr,i.orientation.m03,i.orientation.m04,i.orientation.m05),gn.set(sr,i.orientation.m06,i.orientation.m07,i.orientation.m08),ur[0]=nr,ur[1]=rr,ur[2]=sr,lr[0]=i.halfExtents.x,lr[1]=i.halfExtents.y,lr[2]=i.halfExtents.z,gn.subtract(ar,e,i.center),gn.set(t,i.center.x,i.center.y,i.center.z);for(var n=0;n<3;n++){var r=gn.dot(ar,ur[n]);r>lr[n]&&(r=lr[n]),r<-lr[n]&&(r=-lr[n]),t.x+=r*ur[n].x,t.y+=r*ur[n].y,t.z+=r*ur[n].z}return t}var dr=Object.freeze({__proto__:null,point_plane:cr,pt_point_plane:function(t,e,i){var n=cr(e,i);return gn.subtract(t,e,gn.multiplyScalar(t,i.n,n))},pt_point_aabb:_r,pt_point_obb:fr,pt_point_line:function(t,e,i,n){gn.subtract(nr,i,n);var r=nr.clone(),s=gn.lengthSqr(r);if(0===s)gn.copy(t,i);else{gn.subtract(nr,e,i);var a=gn.dot(nr,r)/s;a<0?gn.copy(t,i):a>1?gn.copy(t,n):gn.scaleAndAdd(t,i,r,a)}}}),pr={SHAPE_RAY:1,SHAPE_LINE:2,SHAPE_SPHERE:4,SHAPE_AABB:8,SHAPE_OBB:16,SHAPE_PLANE:32,SHAPE_TRIANGLE:64,SHAPE_FRUSTUM:128,SHAPE_FRUSTUM_ACCURATE:256,SHAPE_CAPSULE:512,SHAPE_SPLINE:1024},mr=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=pr.SHAPE_LINE,this.s=new gn(t,e,i),this.e=new gn(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 gn.copy(t.s,e.s),gn.copy(t.e,e.e),t},t.fromPoints=function(t,e,i){return gn.copy(t.s,e),gn.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 gn.distance(t.s,t.e)},t.prototype.length=function(){return gn.distance(this.s,this.e)},n(t,[{key:"type",get:function(){return this._type}}]),t}(),gr=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=pr.SHAPE_RAY,this.o=new gn(t,e,i),this.d=new gn(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 gn.copy(t.o,e.o),gn.copy(t.d,e.d),t},t.fromPoints=function(t,e,i){return gn.copy(t.o,e),gn.normalize(t.d,gn.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){gn.normalize(t,this.d),gn.scaleAndAdd(t,this.o,t,e)},n(t,[{key:"type",get:function(){return this._type}}]),t}(),vr=new gn,yr=new gn,Sr=new gn,Tr=new gn;function Ar(t){return Math.max(Math.max(t.x,t.y),t.z)}var br,Er,Cr,wr,Rr,Ir=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=pr.SHAPE_SPHERE,this._center=new gn(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 gn.copy(t.center,e.center),t.radius=e.radius,t},t.fromPoints=function(t,e,i){return gn.multiplyScalar(t.center,gn.add(vr,e,i),.5),t.radius=.5*gn.subtract(vr,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){gn.set(t,this.center.x-this.radius,this.center.y-this.radius,this.center.z-this.radius),gn.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){gn.transformMat4(r.center,this.center,t),r.radius=this.radius*Ar(n)},e.translateAndRotate=function(t,e,i){gn.transformMat4(i.center,this.center,t)},e.setScale=function(t,e){e.radius=this.radius*Ar(t)},e.mergePoint=function(t){this.radius<0&&(this.center.set(t),this.radius=0),gn.subtract(yr,t,this.center);var e=yr.length();if(e>this.radius){var i=.5*(e-this.radius);this.radius+=i,gn.multiplyScalar(yr,yr,i/e),gn.add(this.center,this.center,yr)}},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;gn.subtract(wr,t.o,e.a);var s=gn.dot(wr,Cr)*r;if(s<0||s>1)return 0;gn.cross(Rr,wr,br);var a=gn.dot(t.d,Rr)*r;if(a<0||s+a>1)return 0;var o=gn.dot(Er,Rr)*r;return o<0?0:o}),Mr=function(){var t=new gn(0,0,0);return function(e,i){var n=i.radius,r=i.center,s=e.o,a=e.d,o=n*n;gn.subtract(t,r,s);var h=t.lengthSqr(),u=gn.dot(t,a),l=o-(h-u*u);if(l<0)return 0;var c=Math.sqrt(l),_=hp?0:d>0?d:p}(i,t,e)}}(),Or=function(){var t=new gn,e=new gn,i=new gn,n=new gn,r=new gn,s=new gn,a=new gn,o=new Array(3),h=new Array(3),u=new Array(3),l=new Array(6);return function(c,_){o[0]=_.halfExtents.x,o[1]=_.halfExtents.y,o[2]=_.halfExtents.z,t=_.center,e=c.o,i=c.d,gn.set(n,_.orientation.m00,_.orientation.m01,_.orientation.m02),gn.set(r,_.orientation.m03,_.orientation.m04,_.orientation.m05),gn.set(s,_.orientation.m06,_.orientation.m07,_.orientation.m08),gn.subtract(a,t,e),h[0]=gn.dot(n,i),h[1]=gn.dot(r,i),h[2]=gn.dot(s,i),u[0]=gn.dot(n,a),u[1]=gn.dot(r,a),u[2]=gn.dot(s,a);for(var f=0;f<3;++f){if(0===h[f]){if(-u[f]-o[f]>0||-u[f]+o[f]<0)return 0;h[f]=1e-7}l[2*f+0]=(u[f]+o[f])/h[f],l[2*f+1]=(u[f]-o[f])/h[f]}var d=Math.max(Math.max(Math.min(l[0],l[1]),Math.min(l[2],l[3])),Math.min(l[4],l[5])),p=Math.min(Math.min(Math.max(l[0],l[1]),Math.max(l[2],l[3])),Math.max(l[4],l[5]));return p<0||d>p?0:d>0?d:p}}(),Lr=function(){var t=new gn,e=new gn,i=new gn,n=new gn,r=new gn,s=new gn,a=new gn,o=new Ir;return function(h,u){var l=u.ellipseCenter0,c=u.ellipseCenter1,_=gn.subtract(e,c,l);if(_.length()=0&&R<=1?E:R<0?(o.radius=u.radius,o.center.set(u.ellipseCenter0),vs.raySphere(h,o)):R>1?(o.radius=u.radius,o.center.set(u.ellipseCenter1),vs.raySphere(h,o)):0}}(),Nr=function(){var t=new gn(0,0,0);return function(e,i){gn.subtract(t,e.e,e.s);var n=-cr(e.s,i)/gn.dot(t,i.n);return n<0||n>1?0:n}}(),Fr=function(){var t=new gn(0,0,0),e=new gn(0,0,0),i=new gn(0,0,0),n=new gn(0,0,0),r=new gn(0,0,0),s=new gn(0,0,0);return function(a,o,h){gn.subtract(t,o.b,o.a),gn.subtract(e,o.c,o.a),gn.subtract(i,a.s,a.e),gn.cross(r,t,e);var u=gn.dot(i,r);if(u<=0)return 0;gn.subtract(n,a.s,o.a);var l=gn.dot(n,r);if(l<0||l>u)return 0;gn.cross(s,i,n);var c=gn.dot(e,s);if(c<0||c>u)return 0;var _=-gn.dot(t,s);if(_<0||c+_>u)return 0;if(h){var f=1/u,d=1-(c*=f)-(_*=f);gn.set(h,o.a.x*d+o.b.x*c+o.c.x*_,o.a.y*d+o.b.y*c+o.c.y*_,o.a.z*d+o.b.z*c+o.c.z*_)}return 1}}(),kr=new gr;function Gr(t,e){kr.o.set(t.s),gn.subtract(kr.d,t.e,t.s),kr.d.normalize();var i=Pr(kr,e);return i<=t.length()?i:0}function Vr(t,e){kr.o.set(t.s),gn.subtract(kr.d,t.e,t.s),kr.d.normalize();var i=Or(kr,e);return i<=t.length()?i:0}function Ur(t,e){kr.o.set(t.s),gn.subtract(kr.d,t.e,t.s),kr.d.normalize();var i=Mr(kr,e);return i<=t.length()?i:0}var zr,Hr,Wr,Xr,jr=(zr=new gn,Hr=new gn,Wr=new gn,Xr=new gn,function(t,e){return gn.subtract(zr,t.center,t.halfExtents),gn.add(Hr,t.center,t.halfExtents),gn.subtract(Wr,e.center,e.halfExtents),gn.add(Xr,e.center,e.halfExtents),zr.x<=Xr.x&&Hr.x>=Wr.x&&zr.y<=Xr.y&&Hr.y>=Wr.y&&zr.z<=Xr.z&&Hr.z>=Wr.z});function Yr(t,e,i,n,r,s){gn.set(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),gn.set(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),gn.set(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),gn.set(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),gn.set(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),gn.set(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),gn.set(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),gn.set(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 qr(t,e){for(var i=gn.dot(e,t[0]),n=i,r=1;r<8;++r){var s=gn.dot(e,t[r]);i=sn?s:n}return[i,n]}var Kr,Qr,Zr,Jr,$r,ts=function(){for(var t=new Array(15),e=0;e<15;e++)t[e]=new gn(0,0,0);for(var i=new Array(8),n=new Array(8),r=0;r<8;r++)i[r]=new gn(0,0,0),n[r]=new gn(0,0,0);var s=new gn,a=new gn;return function(e,r){gn.set(t[0],1,0,0),gn.set(t[1],0,1,0),gn.set(t[2],0,0,1),gn.set(t[3],r.orientation.m00,r.orientation.m01,r.orientation.m02),gn.set(t[4],r.orientation.m03,r.orientation.m04,r.orientation.m05),gn.set(t[5],r.orientation.m06,r.orientation.m07,r.orientation.m08);for(var o=0;o<3;++o)gn.cross(t[6+3*o],t[o],t[3]),gn.cross(t[7+3*o],t[o],t[4]),gn.cross(t[7+3*o],t[o],t[5]);gn.subtract(s,e.center,e.halfExtents),gn.add(a,e.center,e.halfExtents),function(t,e,i){gn.set(i[0],t.x,e.y,e.z),gn.set(i[1],t.x,e.y,t.z),gn.set(i[2],t.x,t.y,e.z),gn.set(i[3],t.x,t.y,t.z),gn.set(i[4],e.x,e.y,e.z),gn.set(i[5],e.x,e.y,t.z),gn.set(i[6],e.x,t.y,e.z),gn.set(i[7],e.x,t.y,t.z)}(s,a,i),Yr(r.center,r.halfExtents,t[3],t[4],t[5],n);for(var h=0;h<15;++h){var u=qr(i,t[h]),l=qr(n,t[h]);if(l[0]>u[1]||u[0]>l[1])return 0}return 1}}(),es=function(t,e){var i=t.halfExtents.x*Math.abs(e.n.x)+t.halfExtents.y*Math.abs(e.n.y)+t.halfExtents.z*Math.abs(e.n.z),n=gn.dot(e.n,t.center);return n+ie.d?0:1},is=function(t,e){for(var i=0;in.halfExtents.x?e++:t[u].x<-n.halfExtents.x&&i++;if(e===r.vertices.length||i===r.vertices.length)return 0;e=0,i=0;for(var l=0;ln.halfExtents.y?e++:t[l].y<-n.halfExtents.y&&i++;if(e===r.vertices.length||i===r.vertices.length)return 0;e=0,i=0;for(var c=0;cn.halfExtents.z?e++:t[c].z<-n.halfExtents.z&&i++;return e===r.vertices.length||i===r.vertices.length?0:1}}(),rs=(Kr=new gn(0,0,0),Qr=new wn,function(t,e){return gn.subtract(Kr,e,t.center),gn.transformMat3(Kr,Kr,wn.transpose(Qr,t.orientation)),i=Kr,n=t.halfExtents,Math.abs(i.x)e.d?0:1}),as=function(t,e){for(var i=0;ir.halfExtents.x?i++:e<-r.halfExtents.x&&n++;if(i===a.vertices.length||n===a.vertices.length)return 0;i=0,n=0;for(var _=0;_r.halfExtents.y?i++:e<-r.halfExtents.y&&n++;if(i===a.vertices.length||n===a.vertices.length)return 0;i=0,n=0;for(var f=0;fr.halfExtents.z?i++:e<-r.halfExtents.z&&n++;return i===a.vertices.length||n===a.vertices.length?0:1}}(),hs=function(){for(var t=new Array(15),e=0;e<15;e++)t[e]=new gn(0,0,0);for(var i=new Array(8),n=new Array(8),r=0;r<8;r++)i[r]=new gn(0,0,0),n[r]=new gn(0,0,0);return function(e,r){gn.set(t[0],e.orientation.m00,e.orientation.m01,e.orientation.m02),gn.set(t[1],e.orientation.m03,e.orientation.m04,e.orientation.m05),gn.set(t[2],e.orientation.m06,e.orientation.m07,e.orientation.m08),gn.set(t[3],r.orientation.m00,r.orientation.m01,r.orientation.m02),gn.set(t[4],r.orientation.m03,r.orientation.m04,r.orientation.m05),gn.set(t[5],r.orientation.m06,r.orientation.m07,r.orientation.m08);for(var s=0;s<3;++s)gn.cross(t[6+3*s],t[s],t[3]),gn.cross(t[7+3*s],t[s],t[4]),gn.cross(t[8+3*s],t[s],t[5]);Yr(e.center,e.halfExtents,t[0],t[1],t[2],i),Yr(r.center,r.halfExtents,t[3],t[4],t[5],n);for(var a=0;a<15;++a){var o=qr(i,t[a]),h=qr(n,t[a]);if(h[0]>o[1]||o[0]>h[1])return 0}return 1}}(),us=function(){for(var t=new Ir,e=new gn,i=new gn,n=new gn,r=new Array(8),s=0;s<8;s++)r[s]=new gn;for(var a=new Array(8),o=0;o<8;o++)a[o]=new gn;return function(s,o){if(0===gn.squaredDistance(o.ellipseCenter0,o.ellipseCenter1))return t.radius=o.radius,t.center.set(o.ellipseCenter0),vs.sphereOBB(t,s);e.x=s.orientation.m00,e.y=s.orientation.m01,e.z=s.orientation.m02,i.x=s.orientation.m03,i.y=s.orientation.m04,i.z=s.orientation.m05,n.x=s.orientation.m06,n.y=s.orientation.m07,n.z=s.orientation.m08,Yr(s.center,s.halfExtents,e,i,n,r);var h=a,u=gn.copy(h[0],e),l=gn.copy(h[1],i),c=gn.copy(h[2],n);gn.subtract(h[3],o.center,s.center).normalize();var _=gn.subtract(h[4],o.ellipseCenter0,o.ellipseCenter1);_.normalize(),gn.cross(h[5],u,_),gn.cross(h[6],l,_),gn.cross(h[7],c,_);for(var f=0;f<8;++f){var d=qr(r,h[f]),p=gn.dot(h[f],o.ellipseCenter0),m=gn.dot(h[f],o.ellipseCenter1),g=Math.max(p,m),v=Math.min(p,m)-o.radius,y=g+o.radius;if(v>d[1]||d[0]>y)return 0}return 1}}(),ls=function(t,e){var i=gn.dot(e.n,t.center),n=t.radius*e.n.length();return i+ne.d?0:1},cs=function(t,e){for(var i=0;io)){gn.add(Jr,s,gn.multiplyScalar(Jr,a,r));for(var u=0;u<6;u++)if(u!==i&&u!==i+$r[i]){var l=e.planes[u];if(gn.dot(l.n,Jr)1?gn.squaredDistance(i.center,n.ellipseCenter1)y&&(h=y,u=g+d,S=p)),u<0?(u=0,-m<0?h=0:-m>f?h=y:(h=-m,y=f)):u>S&&(u=S,-m+d<0?h=0:-m+d>f?h=y:(h=-m+d,y=f));var T=Math.abs(h)0&&(t.d=e.d/i),t},t.prototype.transform=function(t){Vn.invert(Ts,t),Vn.transpose(Ts,Ts),cn.set(As,this.n.x,this.n.y,this.n.z,-this.d),cn.transformMat4(As,As,Ts),gn.set(this.n,As.x,As.y,As.z),this.d=-As.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}(),Es=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=pr.SHAPE_TRIANGLE,this.a=new gn(t,e,i),this.b=new gn(n,r,s),this.c=new gn(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 gn.copy(t.a,e.a),gn.copy(t.b,e.b),gn.copy(t.c,e.c),t},t.fromPoints=function(t,e,i,n){return gn.copy(t.a,e),gn.copy(t.b,i),gn.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}();Tt({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 Cs=function(){function t(){this._poolHandle=-1,xs.addContainer(this)}return t.prototype.destroy=function(){xs.removeContainer(this)},t}(),xs=new(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,fe(this._pools,t._poolHandle),t._poolHandle=-1)},e.tryShrink=function(){for(var t=0;tthis.shrinkTimeSpan&&(this.tryShrink(),this._lastShrinkPassed-=this.shrinkTimeSpan)},t}()),ws=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?C(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&&tt(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}(Cs)),Rs=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}(Cs)),Is=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]||Ls(this.callbackInfos,t);this.containCanceled=!1},e.clear=function(){this.cancelAll(),this.callbackInfos.length=0,this.isInvoking=!1,this.containCanceled=!1},t}(),Vs=new ws((function(){return new Gs}),16),Us=t("d2",function(){function t(){this._callbackTable=Lt(!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]=Vs.alloc());var s=ks.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)&&(l=!0,c="",_=0);var d=Ys.UNKNOWN;-1!==a.appVersion.indexOf("Win")?d=Ys.WINDOWS:l?d=Ys.IOS:-1!==a.appVersion.indexOf("Mac")?d=Ys.OSX:-1!==a.appVersion.indexOf("X11")&&-1===a.appVersion.indexOf("Linux")?d=Ys.LINUX:u?d=Ys.ANDROID:-1===a.appVersion.indexOf("Linux")&&-1===o.indexOf("ubuntu")||(d=Ys.LINUX),r.os=d,r.osVersion=c,r.osMainVersion=_,r.browserType=Ws.UNKNOWN;var p=/wechat|weixin|micromessenger/i.exec(o)||/mqqbrowser|micromessenger|qqbrowser|sogou|qzone|liebao|maxthon|ucbs|360 aphone|360browser|baiduboxapp|baidubrowser|maxthon|mxbrowser|miuibrowser/i.exec(o)||/qq|qqbrowser|ucbrowser|ubrowser|edge|HuaweiBrowser/i.exec(o)||/chrome|safari|firefox|trident|opera|opr\/|oupeng/i.exec(o),m=p?p[0].toLowerCase():Ys.UNKNOWN;("safari"===m&&u||"qq"===m&&/android.*applewebkit/i.test(o))&&(m=Ws.ANDROID);var g={micromessenger:Ws.WECHAT,wechat:Ws.WECHAT,weixin:Ws.WECHAT,trident:Ws.IE,edge:Ws.EDGE,"360 aphone":Ws.BROWSER_360,mxbrowser:Ws.MAXTHON,"opr/":Ws.OPERA,ubrowser:Ws.UC,huaweibrowser:Ws.HUAWEI};r.browserType=g[m]||m,r.browserVersion="";var y=/(mqqbrowser|micromessenger|qqbrowser|sogou|qzone|liebao|maxthon|uc|ucbs|360 aphone|360|baiduboxapp|baidu|maxthon|mxbrowser|miui(?:.hybrid)?)(mobile)?(browser)?\/?([\d.]+)/i.exec(o);y||(y=/(qq|chrome|safari|firefox|trident|opera|opr\/|oupeng)(mobile)?(browser)?\/?([\d.]+)/i.exec(o)),r.browserVersion=y?y[4]:"",r.isXR=!1;var S,T=document.createElement("canvas");T.getContext("2d");try{S=T.toDataURL("image/webp").startsWith("data:image/webp")}catch(t){S=!1}if(r.os===Ys.IOS){var A,b=null===(A=/ applewebkit\/(\d+)/.exec(o))||void 0===A?void 0:A[1];"string"==typeof b&&Number.parseInt(b)>=604&&(S=!0)}else if(r.browserType===Ws.SAFARI){var E,C=null===(E=/ version\/(\d+)/.exec(o))||void 0===E?void 0:E[1];"string"==typeof C&&Number.parseInt(C)>=14&&(S=!0)}var x=void 0!==document.documentElement.ontouchstart||void 0!==document.ontouchstart||v,w=void 0!==document.documentElement.onmouseup||v,R=void 0!==navigator.xr,I=function(){if((r.os===Ys.IOS||r.os===Ys.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 r._featureMap=((n={})[Ks.WEBP]=S,n[Ks.IMAGE_BITMAP]=!1,n[Ks.WEB_VIEW]=!0,n[Ks.VIDEO_PLAYER]=!0,n[Ks.SAFE_AREA]=!1,n[Ks.HPE]=!1,n[Ks.INPUT_TOUCH]=x,n[Ks.EVENT_KEYBOARD]=void 0!==document.documentElement.onkeyup||v,n[Ks.EVENT_MOUSE]=w,n[Ks.EVENT_TOUCH]=x||w,n[Ks.EVENT_ACCELEROMETER]=void 0!==window.DeviceMotionEvent||void 0!==window.DeviceOrientationEvent,n[Ks.EVENT_GAMEPAD]=void 0!==navigator.getGamepads||void 0!==navigator.webkitGetGamepads||R,n[Ks.EVENT_HANDLE]=false,n[Ks.EVENT_HMD]=R,n[Ks.EVENT_HANDHELD]=R,n[Ks.WASM]=I,n),r._initPromise.push(r._supportsImageBitmapPromise()),r._registerEvent(),r}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){t._setFeature(Ks.IMAGE_BITMAP,!0),null==e||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}(Hs)),Js=/(\.[^\.\/\?\\]*)(\?.*)?$/,$s=/((.*)(\/|\\|\\\\))?(.*?\..*$)?/,ta=/[^\.\/]+\/\.\.\//;function ea(){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 sa(t){var e=$s.exec(t);return e?e[2]:""}function aa(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 oa(t,e,i){if(0===e.indexOf("."))return aa(t,e);var n=t.indexOf("?"),r="",s=i?ia(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 ha(t){var e=t=String(t);do{e=t,t=t.replace(ta,"")}while(e.length!==t.length);return t}function ua(t){return t.replace(/[\/\\]$/,"")}function la(){return Zs.os===Ys.WINDOWS?"\\":"/"}t("bH",Object.freeze({__proto__:null,join:ea,extname:ia,mainFileName:na,basename:ra,dirname:sa,changeExtname:aa,changeBasename:oa,_normalize:ha,stripSep:ua,getSeperator:la}));var ca=new gn;function _a(t,e,i,n){n||(n=new gn),t.convertToUINode(e,i,n);var r=i.position;return n.add(r),n}function fa(t,e,i){return i||(i=new gn),t.worldToScreen(e,i),i.x/=S.view.getScaleX(),i.y/=S.view.getScaleY(),i}var da=t("bR",{WorldNode3DToLocalNodeUI:_a,WorldNode3DToWorldNodeUI:fa});S.pipelineUtils=da,ut(S.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=Zs.isMobile&&(e&&t===Be.PORTRAIT||!e&&t===Be.LANDSCAPE)},e._updateContainer=function(){if(this._gameContainer){if(this.isProportionalToFrame){if(!this._gameFrame)return void tt(9201);var t,e,i=S.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&&tt(1400,"screen.requestFullScreen(element, onFullScreenChange?, onFullScreenError?)","screen.requestFullScreen(): Promise"),ga.requestFullScreen().then((function(){null==e||e.call(document)})).catch((function(t){H(t),null==i||i.call(document)}))},e.exitFullScreen=function(){return ga.exitFullScreen()},e.autoFullScreen=function(t,e){var i;null===(i=this.requestFullScreen(t,e))||void 0===i||i.catch((function(t){z(t)}))},e.disableAutoFullScreen=function(){},e.on=function(t,e,i){ga.on(t,e,i)},e.once=function(t,e,i){ga.once(t,e,i)},e.off=function(t,e,i){ga.off(t,e,i)},n(t,[{key:"devicePixelRatio",get:function(){return ga.devicePixelRatio}},{key:"windowSize",get:function(){return ga.windowSize},set:function(t){ga.windowSize=t}},{key:"resolution",get:function(){return ga.resolution}},{key:"supportsFullScreen",get:function(){return ga.supportFullScreen}}]),t}(),ya=t("cl",new va);S.screen=ya;var Sa=t("cm",{Feature:Ks,hasFeature:function(t){return Zs.hasFeature(t)},NetworkType:js,Language:Xs,OS:Ys,Platform:qs,BrowserType:Ws,isNative:Zs.isNative,isBrowser:Zs.isBrowser,isMobile:Zs.isMobile,isLittleEndian:Zs.isLittleEndian,platform:Zs.platform,language:Zs.language,languageCode:Zs.nativeLanguage,os:Zs.os,osVersion:Zs.osVersion,osMainVersion:Zs.osMainVersion,browserType:Zs.browserType,browserVersion:Zs.browserVersion,isXR:Zs.isXR,windowPixelResolution:ya.windowSize,capabilities:{canvas:!0,opengl:!0,webp:Zs.hasFeature(Ks.WEBP),imageBitmap:Zs.hasFeature(Ks.IMAGE_BITMAP),touches:Zs.hasFeature(Ks.INPUT_TOUCH),mouse:Zs.hasFeature(Ks.EVENT_MOUSE),keyboard:Zs.hasFeature(Ks.EVENT_KEYBOARD),accelerometer:Zs.hasFeature(Ks.EVENT_ACCELEROMETER)},localStorage:{},getNetworkType:function(){return Zs.networkType},getBatteryLevel:function(){return Zs.getBatteryLevel()},garbageCollect:function(){Zs.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: "+Sa.hasFeature(Ks.WEBP)+"\r\n",t+="supports bitmap: "+Sa.hasFeature(Ks.IMAGE_BITMAP)+"\r\n",t+="supports touches: "+Sa.hasFeature(Ks.INPUT_TOUCH)+"\r\n",t+="supports mouse: "+Sa.hasFeature(Ks.EVENT_MOUSE)+"\r\n",t+="supports keyboard: "+Sa.hasFeature(Ks.EVENT_KEYBOARD)+"\r\n",t+="supports accelerometer: "+Sa.hasFeature(Ks.EVENT_ACCELEROMETER)+"\r\n",t+="os : "+this.os+"\r\n",t+="osVersion : "+this.osVersion+"\r\n",t+="platform : "+this.platform+"\r\n",U(t+="Using "+(S.game.renderType===S.game.RENDER_TYPE_WEBGL?"WEBGL":"CANVAS")+" renderer.\r\n")},openURL:function(t){Zs.openURL(t)},init:function(){var t=this;return Promise.resolve().then((function(){return Zs.init()})).then((function(){try{var e=Sa.localStorage=window.localStorage;e.setItem("storage",""),e.removeItem("storage"),e=null}catch(e){var i=function(){tt(5200)};t.localStorage={getItem:i,setItem:i,clear:i,removeItem:i,key:i,length:0}}t.__isWebIOS14OrIPadOS14Env=(Sa.os===Ys.IOS||Sa.os===Ys.OSX)&&Zs.isBrowser&&/(OS 14)|(Version\/14)/.test(window.navigator.userAgent)}))},now:function(){return Zs.now()},restartVM:function(){Zs.restartJSVM()},getSafeAreaRect:function(t){void 0===t&&(t=!0);var e=S.view,i=ga.safeAreaEdge;t&&(ga.orientation===Pe.ORIENTATION_PORTRAIT?i.topba.x&&(ba.x=t.x),t.y>ba.y&&(ba.y=t.y),t.z>ba.z&&(ba.z=t.z),gn.add(Ea,Aa,ba),this.center.set(gn.multiplyScalar(Ea,Ea,.5)),this.halfExtents.set(ba.x-Ea.x,ba.y-Ea.y,ba.z-Ea.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 Va(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 Va(this._times,t)},e.setKeyframes=function(t,e){t.length,e.length,function(t){t.every((function(t,e,i){return 0===e||t>i[e-1]||Ni(t,i[e-1],1e-6)}))}(t),this._times=t,this._values=e},e._insertNewKeyframe=function(t,e){var i=this._times,n=this._values,r=i.length,s=Va(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 Xa(t){return t>-1e-9&&t<1e-9}function ja(t,e,i,n){return i.slice().reverse().reduce((function(i,n){return n(t,e,i)||i}),n)}Ci.fastDefine("cc.KeyframeCurve",Wa,{_times:[],_values:[]}),t("cr",Ua),function(t){t[t.LINEAR=0]="LINEAR",t[t.CONSTANT=1]="CONSTANT",t[t.CUBIC=2]="CUBIC"}(Ua||t("cr",Ua={})),t("cs",za),function(t){t[t.LINEAR=0]="LINEAR",t[t.CLAMP=1]="CLAMP",t[t.LOOP=2]="LOOP",t[t.PING_PONG=3]="PING_PONG"}(za||t("cs",za={})),t("ct",Ha),function(t){t[t.NONE=0]="NONE",t[t.LEFT=1]="LEFT",t[t.RIGHT=2]="RIGHT",t[t.BOTH=3]="BOTH"}(Ha||t("ct",Ha={}));var Ya=function(){},qa=function(){return Ya},Ka=Qa((function(){}));function Qa(t){return function(e){return"function"==typeof e?t(e):function(i){return t(i,e)}}}function Za(t){return function(e){return function(i){!function(t,e,i){var n=$a(t);if(n){var r=to(n,"proto");to(r,"editor")[e]=i}}(i,t,e)}}}var Ja="__ccclassCache__";function $a(t){return to(t,Ja)}function to(t,e){return t[e]||(t[e]={})}var eo=Qa((function(t,e){var i=qt(t);i===Object&&(i=null);var n={name:e,extends:i,ctor:t},r=t[Ja];if(r){var s=r.proto;s&&jt(n,s),t[Ja]=void 0}return Ci(n)})),io=Za("requireComponent"),no=Za("executionOrder"),ro=Ka;function so(t,e,i){var n=null;function r(t,e,i){!function(t,e,i,n,r,s){var a,o=s&&"function"!=typeof s&&(s.get||s.set);r&&(a=_i(r,o));var h=jt(e,a||r||{});o?(s.get&&(h.get=s.get),s.set&&(h.set=s.set)):ho(t,h,i,n,s)}(function(t){return $a(t.constructor)}(t),function(t,e){var i,n,r=to($a(t.constructor),"proto"),s=to(r,"properties");return null!==(n=s[i=e])&&void 0!==n?n:s[i]={}}(t,e),t.constructor,e,n,i)}return void 0===t?so({type:void 0}):void 0===e?(n=t,r):void r(t,e,i)}function ao(t){var e;try{e=t()}catch(e){return t}return"object"!=typeof e||null===e?e:t}function oo(t,e,i){var n,r,s=$a(t.constructor),a=to(s,"proto"),o=to(a,"properties"),h=null!==(r=o[n=e])&&void 0!==r?r:o[n]={};return h.__internalFlags|=fi.STANDALONE,i&&"function"!=typeof i&&(i.get||i.set)?(i.get&&(h.get=i.get),i.set&&(h.set=i.set)):ho(s,h,t.constructor,e,i),h}function ho(t,e,i,n,r){if(void 0!==r)"function"==typeof r?e.default=ao(r):null===r||r.initializer&&(e.default=ao(r.initializer));else{var s=t.default||(t.default=function(t){var e;try{e=new t}catch(t){return{}}return e}(i));s.hasOwnProperty(n)&&(e.default=s[n])}}var uo=Symbol("cc:SerializationMetadata"),lo=t("cT",(function(t,e,i){fo(oo(t,e,i))}));function co(t){return function(e,i,n){var r=oo(e,i,n);r.formerlySerializedAs=t,fo(r)}}var _o=function(t,e,i){var n=oo(t,e,i);n.editorOnly=!0,fo(n)};function fo(t){t.__internalFlags|=fi.IMPLICIT_SERIALIZABLE}var po=Ya,mo=Ka,go=qa,vo=Ka,yo=qa,So=qa,To=qa,Ao=t("cI",Ya),bo=t("cK",qa),Eo=t("cL",qa),Co=t("cJ",qa),xo=t("cN",qa),wo=t("cO",qa),Ro=t("cP",Ya),Io=t("cM",qa),Do=t("cQ",Ya),Bo=Lo(ii),Mo=Lo(ni),Po=Lo(ri),Oo=Lo(si);function Lo(t){return so({type:t})}var No,Fo,ko,Go,Vo,Uo,zo,Ho,Wo,Xo,jo=t("cR",(function(t,e,i){oo(t,e,i).override=!0})),Yo=t("c3",(function(){})),qo=Object.freeze({__proto__:null,uniquelyReferenced:po,ccclass:eo,property:so,requireComponent:io,executionOrder:no,disallowMultiple:ro,executeInEditMode:mo,menu:go,playOnFocus:vo,inspector:yo,icon:So,help:To,type:Lo,integer:Bo,float:Mo,boolean:Po,string:Oo,editable:Ao,tooltip:Co,visible:bo,displayName:Eo,displayOrder:Io,range:xo,rangeStep:wo,slide:Ro,disallowAnimation:Do,override:jo,formerlySerializedAs:co,serializable:lo});function Ko(t,e){return(e<<3)+t}function Qo(t){return Jo[t]}function Zo(t){switch(t){case Wo.Uint8:return Uint8Array;case Wo.Uint16:return Uint16Array;case Wo.Uint32:return Uint32Array;case Wo.Int8:return Int8Array;case Wo.Int16:return Int16Array;case Wo.Int32:return Int32Array;case Wo.Float32:return Float32Array;case Wo.Float64:return Float64Array}}t("bS",qo),function(t){t[t.Uint8=0]="Uint8",t[t.Uint16=1]="Uint16",t[t.Uint32=2]="Uint32",t[t.Int8=3]="Int8",t[t.Int16=4]="Int16",t[t.Int32=5]="Int32",t[t.Float32=6]="Float32",t[t.Float64=7]="Float64"}(Wo||(Wo={})),function(t){t[t.Scalar=0]="Scalar",t[t.Vec2=1]="Vec2",t[t.Vec3=2]="Vec3",t[t.Vec4=3]="Vec4",t[t.Quat=4]="Quat",t[t.Mat4=5]="Mat4"}(Xo||(Xo={})),t("b_",eo("cc.CompactValueTypeArray")(((zo=function(){function t(){this._byteOffset=ko&&ko(),this._unitCount=Go&&Go(),this._unitElement=Vo&&Vo(),this._length=Uo&&Uo()}return t.lengthFor=function(t,e,i){return Qo(e).requiredUnits*t.length*Zo(i).BYTES_PER_ELEMENT},t.compress=function(e,i,n,r,s,a){for(var o=Qo(i),h=Zo(n),u=o.requiredUnits*e.length,l=new h(r,s,u),c=0;c>3},n=i.storageUnit,r=Qo(i.elementType),s=new(Zo(n))(t,this._byteOffset,this._unitCount),a=new Array(this._length),o=0;o=1?1:t*t*(3-2*t)}function Oh(t){return t<=0?0:t>=1?1:t*t*t*(t*(6*t-15)+10)}S._decorator=qo;var Lh=Xh(nh,rh),Nh=Xh(ah,oh),Fh=Xh(uh,lh),kh=Xh(_h,fh),Gh=Xh(ph,mh),Vh=Xh(vh,yh),Uh=Xh(Th,Ah),zh=Xh(Eh,Ch),Hh=Xh(wh,Rh),Wh=Xh(Dh,Bh);function Xh(t,e){return function(i){return i<.5?e(2*i)/2:t(2*i-1)/2+.5}}var jh,Yh,qh=Object.freeze({__proto__:null,constant:eh,linear:ih,quadIn:nh,quadOut:rh,quadInOut:sh,cubicIn:ah,cubicOut:oh,cubicInOut:hh,quartIn:uh,quartOut:lh,quartInOut:ch,quintIn:_h,quintOut:fh,quintInOut:dh,sineIn:ph,sineOut:mh,sineInOut:gh,expoIn:vh,expoOut:yh,expoInOut:Sh,circIn:Th,circOut:Ah,circInOut:bh,elasticIn:Eh,elasticOut:Ch,elasticInOut:xh,backIn:wh,backOut:Rh,backInOut:Ih,bounceIn:Dh,bounceOut:Bh,bounceInOut:Mh,smooth:Ph,fade:Oh,quadOutIn:Lh,cubicOutIn:Nh,quartOutIn:Fh,quintOutIn:kh,sineOutIn:Gh,expoOutIn:Vh,circOutIn:Uh,elasticOutIn:zh,backOutIn:Hh,bounceOutIn:Wh});t("cD",qh),t("d1",Yh),function(t){t[t.LINEAR=0]="LINEAR",t[t.CONSTANT=1]="CONSTANT",t[t.QUAD_IN=2]="QUAD_IN",t[t.QUAD_OUT=3]="QUAD_OUT",t[t.QUAD_IN_OUT=4]="QUAD_IN_OUT",t[t.QUAD_OUT_IN=5]="QUAD_OUT_IN",t[t.CUBIC_IN=6]="CUBIC_IN",t[t.CUBIC_OUT=7]="CUBIC_OUT",t[t.CUBIC_IN_OUT=8]="CUBIC_IN_OUT",t[t.CUBIC_OUT_IN=9]="CUBIC_OUT_IN",t[t.QUART_IN=10]="QUART_IN",t[t.QUART_OUT=11]="QUART_OUT",t[t.QUART_IN_OUT=12]="QUART_IN_OUT",t[t.QUART_OUT_IN=13]="QUART_OUT_IN",t[t.QUINT_IN=14]="QUINT_IN",t[t.QUINT_OUT=15]="QUINT_OUT",t[t.QUINT_IN_OUT=16]="QUINT_IN_OUT",t[t.QUINT_OUT_IN=17]="QUINT_OUT_IN",t[t.SINE_IN=18]="SINE_IN",t[t.SINE_OUT=19]="SINE_OUT",t[t.SINE_IN_OUT=20]="SINE_IN_OUT",t[t.SINE_OUT_IN=21]="SINE_OUT_IN",t[t.EXPO_IN=22]="EXPO_IN",t[t.EXPO_OUT=23]="EXPO_OUT",t[t.EXPO_IN_OUT=24]="EXPO_IN_OUT",t[t.EXPO_OUT_IN=25]="EXPO_OUT_IN",t[t.CIRC_IN=26]="CIRC_IN",t[t.CIRC_OUT=27]="CIRC_OUT",t[t.CIRC_IN_OUT=28]="CIRC_IN_OUT",t[t.CIRC_OUT_IN=29]="CIRC_OUT_IN",t[t.ELASTIC_IN=30]="ELASTIC_IN",t[t.ELASTIC_OUT=31]="ELASTIC_OUT",t[t.ELASTIC_IN_OUT=32]="ELASTIC_IN_OUT",t[t.ELASTIC_OUT_IN=33]="ELASTIC_OUT_IN",t[t.BACK_IN=34]="BACK_IN",t[t.BACK_OUT=35]="BACK_OUT",t[t.BACK_IN_OUT=36]="BACK_IN_OUT",t[t.BACK_OUT_IN=37]="BACK_OUT_IN",t[t.BOUNCE_IN=38]="BOUNCE_IN",t[t.BOUNCE_OUT=39]="BOUNCE_OUT",t[t.BOUNCE_IN_OUT=40]="BOUNCE_IN_OUT",t[t.BOUNCE_OUT_IN=41]="BOUNCE_OUT_IN",t[t.SMOOTH=42]="SMOOTH",t[t.FADE=43]="FADE"}(Yh||t("d1",Yh={}));var Kh,Qh=((jh={})[Yh.CONSTANT]=eh,jh[Yh.LINEAR]=ih,jh[Yh.QUAD_IN]=nh,jh[Yh.QUAD_OUT]=rh,jh[Yh.QUAD_IN_OUT]=sh,jh[Yh.QUAD_OUT_IN]=Lh,jh[Yh.CUBIC_IN]=ah,jh[Yh.CUBIC_OUT]=oh,jh[Yh.CUBIC_IN_OUT]=hh,jh[Yh.CUBIC_OUT_IN]=Nh,jh[Yh.QUART_IN]=uh,jh[Yh.QUART_OUT]=lh,jh[Yh.QUART_IN_OUT]=ch,jh[Yh.QUART_OUT_IN]=Fh,jh[Yh.QUINT_IN]=_h,jh[Yh.QUINT_OUT]=fh,jh[Yh.QUINT_IN_OUT]=dh,jh[Yh.QUINT_OUT_IN]=kh,jh[Yh.SINE_IN]=ph,jh[Yh.SINE_OUT]=mh,jh[Yh.SINE_IN_OUT]=gh,jh[Yh.SINE_OUT_IN]=Gh,jh[Yh.EXPO_IN]=vh,jh[Yh.EXPO_OUT]=yh,jh[Yh.EXPO_IN_OUT]=Sh,jh[Yh.EXPO_OUT_IN]=Vh,jh[Yh.CIRC_IN]=Th,jh[Yh.CIRC_OUT]=Ah,jh[Yh.CIRC_IN_OUT]=bh,jh[Yh.CIRC_OUT_IN]=Uh,jh[Yh.ELASTIC_IN]=Eh,jh[Yh.ELASTIC_OUT]=Ch,jh[Yh.ELASTIC_IN_OUT]=xh,jh[Yh.ELASTIC_OUT_IN]=zh,jh[Yh.BACK_IN]=wh,jh[Yh.BACK_OUT]=Rh,jh[Yh.BACK_IN_OUT]=Ih,jh[Yh.BACK_OUT_IN]=Hh,jh[Yh.BOUNCE_IN]=Dh,jh[Yh.BOUNCE_OUT]=Bh,jh[Yh.BOUNCE_IN_OUT]=Mh,jh[Yh.BOUNCE_OUT_IN]=Wh,jh[Yh.SMOOTH]=Ph,jh[Yh.FADE]=Oh,jh);function Zh(t){return Qh[t]}w(255),w(65280);var Jh,$h,tu,eu=Ua.LINEAR<<0|Ha.NONE<<8|Yh.LINEAR<<16,iu=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=eu,e}return s(e,t),n(e,[{key:"interpolationMode",get:function(){return(255&this._flags)>>0},set:function(t){this._flags&=-256,this._flags|=t<<0}},{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}(Yo);function nu(t){var e=new iu;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[Ds];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[Ds]=l)}return e}Ci.fastDefine("cc.RealKeyframeValue",iu,((Kh={interpolationMode:Ua.LINEAR,tangentWeightMode:Ha.NONE,value:0,rightTangent:0,rightTangentWeight:0,leftTangent:0,leftTangentWeight:0,easingMethod:Yh.LINEAR})[Ds]=void 0,Kh)),Ci.Attr.setClassAttr(iu,Ds,"editorOnly",!0),(Jh=iu,null!==(tu=($h=Jh)[uo])&&void 0!==tu?tu:$h[uo]={}).uniquelyReferenced=!0;var ru,su=t("cq",function(t){function e(){var e;return(e=t.call(this)||this).preExtrapolation=za.CLAMP,e.postExtrapolation=za.CLAMP,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(h===za.CLAMP||n<2)return u.value;switch(h){case za.LINEAR:return Tu(s,u.value,e[n-2],i[n-2].value,t);case za.LOOP:t=yu(t,r,s);break;case za.PING_PONG:t=Su(t,r,s);break;default:return u.value}}var l=Va(e,t);if(l>=0)return i[l].value;var c=~l,_=c-1,f=e[_],d=i[_],p=e[c];return function(t,e,i,n,r){var s=i-t;switch(e.interpolationMode){default:case Ua.CONSTANT:return e.value;case Ua.LINEAR:var a=e.easingMethod===Yh.LINEAR?r:Zh(e.easingMethod)(r);return Gi(e.value,n.value,a);case Ua.CUBIC:var o=1/3,h=e.rightTangent,u=e.rightTangentWeight,l=0!=(e.tangentWeightMode&Ha.RIGHT),c=n.leftTangent,_=n.leftTangentWeight,f=0!=(n.tangentWeightMode&Ha.LEFT);if(l||f){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),v=Math.cos(g)*d+t,y=Math.sin(g)*d+e.value,S=0;if(f)S=_;else{var T=s,A=s*c;S=Math.sqrt(T*T+A*A)*o}var b=Math.atan(c),E=(v-t)/s,C=(-Math.cos(b)*S+i-t)/s,x=y,w=-Math.sin(b)*S+n.value,R=[0,0,0],I=function(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,_=0;if(Xa(c)){if(Xa(u))return r[0]=0,1;var f=Math.cbrt(-u);return r[0]=2*f,r[1]=-f,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),_=3}else{var m=Math.sqrt(c),g=Math.cbrt(m-u),v=-Math.cbrt(m+u);r[0]=g+v,_=1}for(var y=1/3*s,S=0;S<_;++S)r[S]-=y;return _}(0-r,3*E,3*C-6*E,3*(E-C)+1,R),D=function(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}(R,I,r);return Au(e.value,x,w,n.value,D)}var B=e.value+o*h*s,M=n.value-o*c*s;return Au(e.value,B,M,n.value,r)}}(f,d,p,i[c],(t-f)/(p-f))},i.addKeyFrame=function(e,i){return t.prototype.addKeyFrame.call(this,e,nu(i))},i.assignSorted=function(t,e){if(void 0!==e)this.setKeyframes(t.slice(),e.map((function(t){return nu(t)})));else{var i=Array.from(t);this.setKeyframes(i.map((function(t){return t[0]})),i.map((function(t){return nu(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 Ni(i.value,e,t)}))},i[$o]=function(t,e){if(e.toCCON){var i=this._times,n=this._values,r=i.length,s=new DataView(new ArrayBuffer(0+au+au+ou+hu*r+mu*r)),a=0;s.setUint8(a,this.preExtrapolation),a+=au,s.setUint8(a,this.postExtrapolation),a+=au,s.setUint32(a,r,!0),a+=ou,i.forEach((function(t,e){return s.setFloat32(a+hu*e,t,!0)})),a+=hu*r;for(var o,h=f(n);!(o=h()).done;){var u=o.value;a=gu(s,u,a)}var l=new Uint8Array(s.buffer,0,a);t.writeProperty("bytes",l);var c=n.map((function(t){return t[Ds]}));c.some((function(t){return void 0!==t}))&&t.writeProperty("keyframeValueEditorExtras",c)}else t.writeThis()},i[th]=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+=au,this.postExtrapolation=n.getUint8(r),r+=au;var s=n.getUint32(r,!0);r+=ou;var a=Array.from({length:s},(function(t,e){return n.getFloat32(r+hu*e,!0)}));r+=hu*s;for(var o=new Array(s),h=0;h>8;return e.easingMethod=s,n}function yu(t,e,i){return e+Qi(t-e,i-e)}function Su(t,e,i){return e+Zi(t-e,i-e)}function Tu(t,e,i,n,r){return e+(n-e)/(i-t)*(r-t)}function Au(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 bu(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}S.bezier=bu;var Eu,Cu,xu,wu,Ru,Iu,Du,Bu,Mu,Pu,Ou=Math.cos,Lu=Math.acos,Nu=Math.max,Fu=2*Math.PI,ku=Math.sqrt;function Gu(t){return t<0?-Math.pow(-t,1/3):Math.pow(t,1/3)}function Vu(t,e){var i=function(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)),_=1/3,f=(h-6*o+l)*c,d=f*_,p=(-h+u)*c,m=(3*p-f*f)*_,g=m*_,v=(2*f*f*f-9*f*p+a*c*27)/27,y=v/2,S=y*y+g*g*g;if(S<0){var T=-m*_,A=ku(T*T*T),b=-v/(2*A),E=Lu(b<-1?-1:b>1?1:b),C=2*Gu(A);return n=C*Ou(E*_)-d,r=C*Ou((E+Fu)*_)-d,s=C*Ou((E+2*Fu)*_)-d,n>=0&&n<=1?r>=0&&r<=1?s>=0&&s<=1?Nu(n,r,s):Nu(n,r):s>=0&&s<=1?Nu(n,s):n:r>=0&&r<=1?s>=0&&s<=1?Nu(r,s):r:s}if(0===S)return r=-(i=y<0?Gu(-y):-Gu(y))-d,(n=2*i-d)>=0&&n<=1?r>=0&&r<=1?Nu(n,r):n:r;var x=ku(S);return(i=Gu(-y+x))-Gu(y+x)-d}(t,e),n=t[1];return((1-i)*(n+(t[3]-n)*i)*3+i*i)*i}S.bezierByTime=Vu,t("cv",Pu),function(t){t[t.SLERP=0]="SLERP",t[t.CONSTANT=1]="CONSTANT"}(Pu||t("cv",Pu={}));var Uu=eo("cc.QuatKeyframeValue")(Eu=po((Cu=function(t){var e=void 0===t?{}:t,i=e.value,n=e.interpolationMode,r=e.easingMethod;this.interpolationMode=xu&&xu(),this.value=wu&&wu(),this.easingMethod=Ru&&Ru(),this.value=i?Bn.clone(i):this.value,this.interpolationMode=null!=n?n:this.interpolationMode,this.easingMethod=null!=r?r:this.easingMethod},xu=ja(Cu.prototype,"interpolationMode",[lo],(function(){return Pu.SLERP})),wu=ja(Cu.prototype,"value",[lo],(function(){return Bn.clone(Bn.IDENTITY)})),Ru=ja(Cu.prototype,"easingMethod",[lo],(function(){return Yh.LINEAR})),Eu=Cu))||Eu)||Eu;function zu(t){return new Uu(t)}var Hu,Wu=t("cu",eo("cc.QuatCurve")((Du=function(t){function e(){var e;return(e=t.call(this)||this).preExtrapolation=Bu&&Bu(),e.postExtrapolation=Mu&&Mu(),e}s(e,t);var i=e.prototype;return i.evaluate=function(t,e){var i;null!==(i=e)&&void 0!==i||(e=new Bn);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 za.LOOP:t=h+Qi(t-h,u-h);break;case za.PING_PONG:t=h+Zi(t-h,u-h);break;case za.CLAMP:default:return Bn.copy(e,c.value)}}var _=Va(n,t);if(_>=0)return Bn.copy(e,r[_].value);var f=~_,d=f-1,p=n[d],m=r[d],g=n[f],v=r[f],y=(t-p)/(g-p);switch(m.interpolationMode){default:case Pu.CONSTANT:return Bn.copy(e,m.value);case Pu.SLERP:var S=m.easingMethod,T=S===Yh.LINEAR?y:Array.isArray(S)?Vu(S,y):Zh(S)(y);return Bn.slerp(e,m.value,v.value,T)}},i.addKeyFrame=function(e,i){var n=new Uu(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 zu(t)})));else{var i=Array.from(t);this.setKeyframes(i.map((function(t){return t[0]})),i.map((function(t){return zu(t[1])})))}},i[$o]=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=Qu*(r?1:s),o=n.reduce((function(t,e){var i=e.easingMethod;return t+(Array.isArray(i)?Zu+4*$u:Zu)}),0),h=0,u=new DataView(new ArrayBuffer(h+=ju+Yu+qu*s+4*Ku*s+o+a+0)),l=0,c=0;r&&(c|=Hu.INTERPOLATION_MODE),u.setUint32(l,c,!0),l+=ju,u.setUint32(l,s,!0),l+=Yu,i.forEach((function(t,e){return u.setFloat32(l+qu*e,t,!0)})),l+=qu*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*Ku*e;u.setFloat32(o+0*Ku,n,!0),u.setFloat32(o+1*Ku,r,!0),u.setFloat32(o+2*Ku,s,!0),u.setFloat32(o+3*Ku,a,!0)})),l+=4*Ku*s,n.forEach((function(t){var e=t.easingMethod;Array.isArray(e)?(u.setUint8(l,Ju),++l,u.setFloat32(l+0*$u,e[0],!0),u.setFloat32(l+1*$u,e[1],!0),u.setFloat32(l+2*$u,e[2],!0),u.setFloat32(l+3*$u,e[3],!0),l+=4*$u):(u.setUint8(l,e),++l)}));var _=l;l+=a;var f=_;n.forEach((function(t){var e=t.interpolationMode;u.setUint8(f,e),r||(f+=Qu)}));var d=new Uint8Array(u.buffer);t.writeProperty("bytes",d)}else t.writeThis()},i[th]=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+=ju;var a=s&Hu.INTERPOLATION_MODE,o=n.getUint32(r,!0);r+=Yu;var h=Array.from({length:o},(function(t,e){return n.getFloat32(r+qu*e,!0)})),u=r+=qu*o;r+=4*Ku*o;var l=Array.from({length:o},(function(t,e){var i=u+4*Ku*e,s=n.getFloat32(i+0*Ku,!0),a=n.getFloat32(i+1*Ku,!0),o=n.getFloat32(i+2*Ku,!0),h=n.getFloat32(i+3*Ku,!0),l=n.getUint8(r);++r;var c=zu({value:{x:s,y:a,z:o,w:h}});return l!==Ju?c.easingMethod=l:(c.easingMethod=[n.getFloat32(r+0*$u,!0),n.getFloat32(r+1*$u,!0),n.getFloat32(r+2*$u,!0),n.getFloat32(r+3*$u,!0)],r+=4*$u),c}));if(a){var c=n.getUint8(r);++r;for(var _=0;_=0)return this._values[e];var i=Fi(~e-1,0,this._values.length-1);return this._values[i]},e}(Wa))||Xu),el=Ee({Blend:0,Fixed:1}),il=t("cx",(function(){this.color=En.WHITE.clone(),this.time=0}));Ci.fastDefine("cc.ColorKey",il,{color:En.WHITE.clone(),time:0}),Ci.Attr.setClassAttr(il,"color","visible",!0),Ci.Attr.setClassAttr(il,"time","visible",!0);var nl=t("cy",(function(){this.alpha=1,this.time=0}));Ci.fastDefine("cc.AlphaKey",nl,{alpha:1,time:0}),Ci.Attr.setClassAttr(nl,"alpha","visible",!0),Ci.Attr.setClassAttr(nl,"time","visible",!0);var rl=t("cz",function(){function t(){this.colorKeys=[],this.alphaKeys=[],this.mode=el.Blend}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 En,t)},e.evaluateFast=function(t,e){return this.getRGB(t,e),t.a=this.getAlpha(e),t},e.randomColor=function(){return this.getRandomColor(new En)},e.getRandomColor=function(t){var e=this.colorKeys[Math.trunc(zi()*this.colorKeys.length)],i=this.alphaKeys[Math.trunc(zi()*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=Qi(e,1+Oi);for(var r=1;r=s&&ei[h].time&&En.lerp(t,i[h].color,En.BLACK,(e-i[h].time)/(1-i[h].time))}else 1===n?En.copy(t,i[0].color):En.copy(t,En.WHITE);return t},e.getAlpha=function(t){var e=this.alphaKeys,i=e.length;if(i>1){t=Qi(t,1+Oi);for(var n=1;n=r&&te[o].time?Gi(e[o].alpha,0,(t-e[o].time)/(1-e[o].time)):255}return 1===i?e[0].alpha:255},t}());rl.Mode=el,Ci.fastDefine("cc.Gradient",rl,{colorKeys:[],alphaKeys:[],mode:el.Blend}),Ci.Attr.setClassAttr(rl,"colorKeys","visible",!0),Ci.Attr.setClassAttr(rl,"alphaKeys","visible",!0),Ci.Attr.setClassAttr(rl,"mode","visible",!0);var sl=function(){this.time=0,this.value=0,this.inTangent=0,this.outTangent=0};Ci.fastDefine("cc.Keyframe",sl,{time:0,value:0,inTangent:0,outTangent:0});var al=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 ol(t-this.time,this.coefficient)},t}();function ol(t,e){return t*(t*(t*e[0]+e[1])+e[2])+e[3]}var hl,ul,ll=function(){function t(t){if(void 0===t&&(t=null),this._curve=void 0,this.cachedKey=void 0,t instanceof su)this._curve=t;else{var e=new su;this._curve=e,e.preExtrapolation=za.LOOP,e.postExtrapolation=za.CLAMP,t?e.assignSorted(t.map((function(t){return[t.time,{interpolationMode:Ua.CUBIC,value:t.value,leftTangent:t.inTangent,rightTangent:t.outTangent}]}))):e.assignSorted([[0,{interpolationMode:Ua.CUBIC,value:1}],[1,{interpolationMode:Ua.CUBIC,value:1}]])}this.cachedKey=new al}var e=t.prototype;return e.addKey=function(t){t?this._curve.addKeyFrame(t.time,{interpolationMode:Ua.CUBIC,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 za.LOOP:r=Qi(t-a,o-a)+a;break;case za.PING_PONG:r=Zi(t-a,o-a)+a;break;case za.CLAMP:default:r=Fi(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 sl;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:Ua.CUBIC,value:t.value,leftTangent:t.inTangent,rightTangent:t.outTangent}]})))}},{key:"preWrapMode",get:function(){return _l(this._curve.preExtrapolation)},set:function(t){this._curve.preExtrapolation=cl(t)}},{key:"postWrapMode",get:function(){return _l(this._curve.postExtrapolation)},set:function(t){this._curve.postExtrapolation=cl(t)}}]),t}();function cl(t){switch(t){default:case hl.Default:case hl.Normal:case hl.Clamp:return za.CLAMP;case hl.PingPong:return za.PING_PONG;case hl.Loop:return za.LOOP}}function _l(t){switch(t){default:case za.LINEAR:case za.CLAMP:return hl.Clamp;case za.PING_PONG:return hl.PingPong;case za.LOOP:return hl.Loop}}function fl(){var t=new su;return t.assignSorted([[0,{interpolationMode:Ua.CUBIC,value:1}],[1,{interpolationMode:Ua.CUBIC,value:1}]]),t}ll.defaultKF=[{time:0,value:1,inTangent:0,outTangent:0},{time:1,value:1,inTangent:0,outTangent:0}],Ci.fastDefine("cc.AnimationCurve",ll,{_curve:null}),function(t){t[t.Default=0]="Default",t[t.Normal=1]="Normal",t[t.Loop=2]="Loop",t[t.ShouldWrap=4]="ShouldWrap",t[t.Clamp=8]="Clamp",t[t.PingPong=22]="PingPong",t[t.Reverse=36]="Reverse"}(hl||(hl={})),function(t){t[t.LINEAR=0]="LINEAR",t[t.BEZIER=1]="BEZIER",t[t.CATMULL_ROM=2]="CATMULL_ROM"}(ul||(ul={}));var dl,pl=4294967295,ml=new gn,gl=new gn,vl=new gn,yl=new gn,Sl=function(){function t(t,e){void 0===t&&(t=ul.CATMULL_ROM),void 0===e&&(e=[]),this._type=void 0,this._mode=ul.CATMULL_ROM,this._knots=[],this._type=pr.SHAPE_SPLINE,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){t>=0&&this._knots.length,this._knots.splice(t,1)},e.setKnot=function(t,e){t>=0&&this._knots.length,this._knots[t].set(e)},e.getKnot=function(t){return t>=0&&this._knots.length,this._knots[t]},e.getPoint=function(e,i){void 0===i&&(i=pl),e=Fi(e,0,1);var n=this.getSegments();if(0===n)return new gn(0,0,0);if(i===pl){var r=1/n;i=Math.floor(e/r),e=e%r/r}if(i>=n)return new gn(this._knots[this._knots.length-1]);switch(this._mode){case ul.LINEAR:return t.calcLinear(this._knots[i],this._knots[i+1],e);case ul.BEZIER:return t.calcBezier(this._knots[4*i],this._knots[4*i+1],this._knots[4*i+2],this._knots[4*i+3],e);case ul.CATMULL_ROM:var s=i>0?this._knots[i-1]:this._knots[i],a=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}());Ml.Priority=Ee({LOW:0,MEDIUM:100,HIGH:200,SCHEDULER:1<<31>>>0});var Pl=new bt("Scheduler"),Ol=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}();Ol._listEntries=[];var Ll=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}();Ll._hashUpdateEntries=[];var Nl=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}();Nl._hashTimerEntries=[];var Fl=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===S.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}();Fl._timers=[];var kl=t("cp",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=Lt(!0),e._hashForTimers=Lt(!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=Pl.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 it(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),Fl.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 it(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){st(Boolean(t),1508),st(Boolean(e),1509);var i=e.uuid||e.id;if(!i)return it(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 Hl(){}function Wl(t,e,i){if(Ae(t,e),Ae(t,i),e===i)return t;var n=t[e];if(e0&&0==(t&t-1)}function Z_(t,e,i,n){if(!j_[t].isCompressed)return e*i*n*j_[t].size;switch(t){case ec.BC1:case ec.BC1_ALPHA:case ec.BC1_SRGB:case ec.BC1_SRGB_ALPHA:return Math.ceil(e/4)*Math.ceil(i/4)*8*n;case ec.BC2:case ec.BC2_SRGB:case ec.BC3:case ec.BC3_SRGB:case ec.BC4:case ec.BC4_SNORM:case ec.BC6H_SF16:case ec.BC6H_UF16:case ec.BC7:case ec.BC7_SRGB:return Math.ceil(e/4)*Math.ceil(i/4)*16*n;case ec.BC5:case ec.BC5_SNORM:return Math.ceil(e/4)*Math.ceil(i/4)*32*n;case ec.ETC_RGB8:case ec.ETC2_RGB8:case ec.ETC2_SRGB8:case ec.ETC2_RGB8_A1:case ec.EAC_R11:case ec.EAC_R11SN:return Math.ceil(e/4)*Math.ceil(i/4)*8*n;case ec.ETC2_RGBA8:case ec.ETC2_SRGB8_A1:case ec.EAC_RG11:case ec.EAC_RG11SN:return Math.ceil(e/4)*Math.ceil(i/4)*16*n;case ec.PVRTC_RGB2:case ec.PVRTC_RGBA2:case ec.PVRTC2_2BPP:return Math.ceil(e/8)*Math.ceil(i/4)*8*n;case ec.PVRTC_RGB4:case ec.PVRTC_RGBA4:case ec.PVRTC2_4BPP:return Math.ceil(e/4)*Math.ceil(i/4)*8*n;case ec.ASTC_RGBA_4X4:case ec.ASTC_SRGBA_4X4:return Math.ceil(e/4)*Math.ceil(i/4)*16*n;case ec.ASTC_RGBA_5X4:case ec.ASTC_SRGBA_5X4:return Math.ceil(e/5)*Math.ceil(i/4)*16*n;case ec.ASTC_RGBA_5X5:case ec.ASTC_SRGBA_5X5:return Math.ceil(e/5)*Math.ceil(i/5)*16*n;case ec.ASTC_RGBA_6X5:case ec.ASTC_SRGBA_6X5:return Math.ceil(e/6)*Math.ceil(i/5)*16*n;case ec.ASTC_RGBA_6X6:case ec.ASTC_SRGBA_6X6:return Math.ceil(e/6)*Math.ceil(i/6)*16*n;case ec.ASTC_RGBA_8X5:case ec.ASTC_SRGBA_8X5:return Math.ceil(e/8)*Math.ceil(i/5)*16*n;case ec.ASTC_RGBA_8X6:case ec.ASTC_SRGBA_8X6:return Math.ceil(e/8)*Math.ceil(i/6)*16*n;case ec.ASTC_RGBA_8X8:case ec.ASTC_SRGBA_8X8:return Math.ceil(e/8)*Math.ceil(i/8)*16*n;case ec.ASTC_RGBA_10X5:case ec.ASTC_SRGBA_10X5:return Math.ceil(e/10)*Math.ceil(i/5)*16*n;case ec.ASTC_RGBA_10X6:case ec.ASTC_SRGBA_10X6:return Math.ceil(e/10)*Math.ceil(i/6)*16*n;case ec.ASTC_RGBA_10X8:case ec.ASTC_SRGBA_10X8:return Math.ceil(e/10)*Math.ceil(i/8)*16*n;case ec.ASTC_RGBA_10X10:case ec.ASTC_SRGBA_10X10:return Math.ceil(e/10)*Math.ceil(i/10)*16*n;case ec.ASTC_RGBA_12X10:case ec.ASTC_SRGBA_12X10:return Math.ceil(e/12)*Math.ceil(i/10)*16*n;case ec.ASTC_RGBA_12X12:case ec.ASTC_SRGBA_12X12:return Math.ceil(e/12)*Math.ceil(i/12)*16*n;default:return 0}}function J_(t,e,i,n,r){for(var s=0,a=0;a>1,1),i=Math.max(i>>1,1);return s}var $_=[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 tf(t){return $_[t]||0}function ef(t){if(t.isCompressed)return Uint8Array;var e=t.size/t.count;switch(t.type){case ic.UNORM:case ic.UINT:switch(e){case 1:return Uint8Array;case 2:return Uint16Array;case 4:return Uint32Array;default:return Uint8Array}case ic.SNORM:case ic.INT:switch(e){case 1:return Int8Array;case 2:return Int16Array;case 4:return Int32Array;default:return Int8Array}case ic.FLOAT:switch(e){case 2:return Uint16Array;case 4:default:return Float32Array}}return Float32Array}function nf(t){switch(t){case ec.BC1:case ec.BC1_ALPHA:case ec.BC1_SRGB:case ec.BC1_SRGB_ALPHA:case ec.BC2:case ec.BC2_SRGB:case ec.BC3:case ec.BC3_SRGB:case ec.BC4:case ec.BC4_SNORM:case ec.BC6H_SF16:case ec.BC6H_UF16:case ec.BC7:case ec.BC7_SRGB:case ec.BC5:case ec.BC5_SNORM:case ec.ETC_RGB8:case ec.ETC2_RGB8:case ec.ETC2_SRGB8:case ec.ETC2_RGB8_A1:case ec.EAC_R11:case ec.EAC_R11SN:case ec.ETC2_RGBA8:case ec.ETC2_SRGB8_A1:case ec.EAC_RG11:case ec.EAC_RG11SN:return{width:4,height:4};case ec.PVRTC_RGB2:case ec.PVRTC_RGBA2:case ec.PVRTC2_2BPP:return{width:8,height:4};case ec.PVRTC_RGB4:case ec.PVRTC_RGBA4:case ec.PVRTC2_4BPP:return{width:4,height:4};case ec.ASTC_RGBA_4X4:case ec.ASTC_SRGBA_4X4:return{width:4,height:4};case ec.ASTC_RGBA_5X4:case ec.ASTC_SRGBA_5X4:return{width:5,height:4};case ec.ASTC_RGBA_5X5:case ec.ASTC_SRGBA_5X5:return{width:5,height:5};case ec.ASTC_RGBA_6X5:case ec.ASTC_SRGBA_6X5:return{width:6,height:5};case ec.ASTC_RGBA_6X6:case ec.ASTC_SRGBA_6X6:return{width:6,height:6};case ec.ASTC_RGBA_8X5:case ec.ASTC_SRGBA_8X5:return{width:8,height:5};case ec.ASTC_RGBA_8X6:case ec.ASTC_SRGBA_8X6:return{width:8,height:6};case ec.ASTC_RGBA_8X8:case ec.ASTC_SRGBA_8X8:return{width:8,height:8};case ec.ASTC_RGBA_10X5:case ec.ASTC_SRGBA_10X5:return{width:10,height:5};case ec.ASTC_RGBA_10X6:case ec.ASTC_SRGBA_10X6:return{width:10,height:6};case ec.ASTC_RGBA_10X8:case ec.ASTC_SRGBA_10X8:return{width:10,height:8};case ec.ASTC_RGBA_10X10:case ec.ASTC_SRGBA_10X10:return{width:10,height:10};case ec.ASTC_RGBA_12X10:case ec.ASTC_SRGBA_12X10:return{width:12,height:10};case ec.ASTC_RGBA_12X12:case ec.ASTC_SRGBA_12X12:return{width:12,height:12};default:return{width:1,height:1}}}function rf(t,e){return Math.ceil(t/e)*e}var sf=Object.freeze({__proto__:null,get ObjectType(){return Ql},get Status(){return Zl},get API(){return Jl},get SurfaceTransform(){return $l},get Feature(){return tc},get Format(){return ec},get FormatType(){return ic},get Type(){return nc},get BufferUsageBit(){return rc},get BufferFlagBit(){return sc},get MemoryAccessBit(){return ac},get MemoryUsageBit(){return oc},get TextureType(){return hc},get TextureUsageBit(){return uc},get TextureFlagBit(){return lc},get FormatFeatureBit(){return cc},get SampleCount(){return _c},get VsyncMode(){return fc},get Filter(){return dc},get Address(){return pc},get ComparisonFunc(){return mc},get StencilOp(){return gc},get BlendFactor(){return vc},get BlendOp(){return yc},get ColorMask(){return Sc},get ShaderStageFlagBit(){return Tc},get LoadOp(){return Ac},get StoreOp(){return bc},get AccessFlagBit(){return Ec},get ResolveMode(){return Cc},get PipelineBindPoint(){return xc},get PrimitiveMode(){return wc},get PolygonMode(){return Rc},get ShadeModel(){return Ic},get CullMode(){return Dc},get DynamicStateFlagBit(){return Bc},get StencilFace(){return Mc},get DescriptorType(){return Pc},get QueueType(){return Oc},get QueryType(){return Lc},get CommandBufferType(){return Nc},get ClearFlagBit(){return Fc},get BarrierType(){return kc},get PassType(){return Gc},Size:zc,DeviceCaps:Hc,DeviceOptions:Wc,Offset:Xc,Rect:jc,Extent:Yc,TextureSubresLayers:qc,TextureSubresRange:Kc,TextureCopy:Qc,TextureBlit:Zc,BufferTextureCopy:Jc,Viewport:$c,Color:t_,BindingMappingInfo:e_,SwapchainInfo:i_,DeviceInfo:n_,BufferInfo:r_,BufferViewInfo:s_,DrawInfo:a_,DispatchInfo:o_,IndirectBuffer:h_,TextureInfo:u_,TextureViewInfo:l_,SamplerInfo:c_,Uniform:__,UniformBlock:f_,UniformSamplerTexture:d_,UniformSampler:p_,UniformTexture:m_,UniformStorageImage:g_,UniformStorageBuffer:v_,UniformInputAttachment:y_,ShaderStage:S_,Attribute:T_,ShaderInfo:A_,InputAssemblerInfo:b_,ColorAttachment:E_,DepthStencilAttachment:C_,SubpassInfo:x_,SubpassDependency:w_,RenderPassInfo:R_,GeneralBarrierInfo:I_,TextureBarrierInfo:D_,BufferBarrierInfo:B_,FramebufferInfo:M_,DescriptorSetLayoutBinding:P_,DescriptorSetLayoutInfo:O_,DescriptorSetInfo:L_,PipelineLayoutInfo:N_,InputState:F_,CommandBufferInfo:k_,QueueInfo:G_,QueryPoolInfo:V_,FormatInfo:U_,MemoryStatus:z_,DynamicStencilStates:H_,DynamicStates:W_,GFXObject:X_,get AttributeName(){return Uc},FormatInfos:j_,DESCRIPTOR_BUFFER_TYPE:Y_,DESCRIPTOR_SAMPLER_TYPE:q_,DESCRIPTOR_DYNAMIC_TYPE:K_,DRAW_INFO_SIZE:28,IsPowerOf2:Q_,FormatSize:Z_,FormatSurfaceSize:J_,GetTypeSize:tf,getTypedArrayConstructor:ef,formatAlignment:nf,alignTo:rf}),af=function(t){function e(){var e;return(e=t.call(this,Ql.BUFFER)||this)._usage=rc.NONE,e._memUsage=oc.NONE,e._size=0,e._stride=1,e._count=0,e._flags=sc.NONE,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}(X_),of=function(t){function e(){var e;return(e=t.call(this,Ql.COMMAND_BUFFER)||this)._queue=null,e._type=Nc.PRIMARY,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}(X_),hf=function(){function t(){this._gfxAPI=Jl.UNKNOWN,this._renderer="",this._vendor="",this._features=new Array(tc.COUNT),this._formatFeatures=new Array(ec.COUNT),this._queue=null,this._cmdBuff=null,this._numDrawCalls=0,this._numInstances=0,this._numTris=0,this._memoryStatus=new z_,this._caps=new Hc,this._bindingMappingInfo=new e_,this._samplers=new Map,this._generalBarrierss=new Map,this._textureBarriers=new Map,this._bufferBarriers=new Map,this._swapchainFormat=ec.RGBA8}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 _c.X1},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}();hf.canvas=void 0;var uf=function(){function t(t){this._texture2D=null,this._texture3D=null,this._textureCube=null,this._texture2DArray=null;var e=new Uint8Array(64);if(e.fill(255),t.capabilities.maxTextureSize>=2){this._texture2D=t.createTexture(new u_(hc.TEX2D,uc.STORAGE|uc.SAMPLED,ec.RGBA8,2,2,lc.NONE));var i=new Jc(0,0,0,new Xc(0,0,0),new Yc(2,2,1));t.copyBuffersToTexture([e],this._texture2D,[i])}if(t.capabilities.maxTextureSize>=2){this._textureCube=t.createTexture(new u_(hc.CUBE,uc.STORAGE|uc.SAMPLED,ec.RGBA8,2,2,lc.NONE,6));var n=new Jc(0,0,0,new Xc(0,0,0),new Yc(2,2,1));t.copyBuffersToTexture([e],this._textureCube,[n]),n.texSubres.baseArrayLayer=1,t.copyBuffersToTexture([e],this._textureCube,[n]),n.texSubres.baseArrayLayer=2,t.copyBuffersToTexture([e],this._textureCube,[n]),n.texSubres.baseArrayLayer=3,t.copyBuffersToTexture([e],this._textureCube,[n]),n.texSubres.baseArrayLayer=4,t.copyBuffersToTexture([e],this._textureCube,[n]),n.texSubres.baseArrayLayer=5,t.copyBuffersToTexture([e],this._textureCube,[n])}if(t.capabilities.max3DTextureSize>=2){this._texture3D=t.createTexture(new u_(hc.TEX3D,uc.STORAGE|uc.SAMPLED,ec.RGBA8,2,2,lc.NONE,1,1,_c.X1,2));var r=new Jc(0,0,0,new Xc(0,0,0),new Yc(2,2,2),new qc(0,0,1));t.copyBuffersToTexture([e],this._texture3D,[r])}if(t.capabilities.maxArrayTextureLayers>=2){this._texture2DArray=t.createTexture(new u_(hc.TEX2D_ARRAY,uc.STORAGE|uc.SAMPLED,ec.RGBA8,2,2,lc.NONE,2));var s=new Jc(0,0,0,new Xc(0,0,0),new Yc(2,2,1),new qc(0,0,1));t.copyBuffersToTexture([e],this._texture2DArray,[s]),s.texSubres.baseArrayLayer=1,t.copyBuffersToTexture([e],this._texture2DArray,[s])}}return t.prototype.getTexture=function(t){switch(t){case hc.TEX2D:return this._texture2D;case hc.TEX3D:return this._texture3D;case hc.CUBE:return this._textureCube;case hc.TEX2D_ARRAY:return this._texture2DArray;default:return null}},t}(),lf=function(t){function e(){var e;return(e=t.call(this,Ql.SWAPCHAIN)||this)._transform=$l.IDENTITY,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}(X_),cf=function(t){function e(){var e;return(e=t.call(this,Ql.FRAMEBUFFER)||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(){return this.colorTextures.length>0?this.colorTextures[0].width:this.depthStencilTexture?this.depthStencilTexture.width:this._width}},{key:"height",get:function(){return this.colorTextures.length>0?this.colorTextures[0].height:this.depthStencilTexture?this.depthStencilTexture.height:this._height}},{key:"needRebuild",get:function(){return!1}}]),e}(X_),_f=function(t){function e(){var e;return(e=t.call(this,Ql.INPUT_ASSEMBLER)||this)._attributes=[],e._attributesHash=0,e._vertexBuffers=[],e._indexBuffer=null,e._indirectBuffer=null,e._drawInfo=new a_,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>0,e.magFilter=(3&t)>>2,e.mipFilter=(3&t)>>4,e.addressU=(3&t)>>6,e.addressV=(3&t)>>8,e.addressW=(3&t)>>10,e.maxAnisotropy=(15&t)>>12,e.cmpFunc=(7&t)>>16,e},n(e,[{key:"info",get:function(){return this._info}},{key:"hash",get:function(){return this._hash}}]),e}(X_),Cf=function(t){function e(){var e;return(e=t.call(this,Ql.SHADER)||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}(X_),xf=function(t){function e(){var e;return(e=t.call(this,Ql.TEXTURE)||this)._info=new u_,e._viewInfo=new l_,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}(X_),wf=function(t){function e(e,i){var n;return(n=t.call(this,Ql.GLOBAL_BARRIER)||this)._info=new I_,n._hash=0,n._info.copy(e),n._hash=i,n}return s(e,t),e.computeHash=function(t){return zl(t.prevAccesses+" "+t.nextAccesses+" "+t.type,666)},n(e,[{key:"info",get:function(){return this._info}},{key:"hash",get:function(){return this._hash}}]),e}(X_),Rf=function(t){function e(e,i){var n;return(n=t.call(this,Ql.TEXTURE_BARRIER)||this)._info=new D_,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.baseMipLevel,e+=t.levelCount,e+=t.baseSlice,e+=t.sliceCount,e+=t.discardContents,e+=t.srcQueue?t.srcQueue.type:0,zl(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}(X_),If=function(t){function e(e,i){var n;return(n=t.call(this,Ql.BUFFER_BARRIER)||this)._info=new B_,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,zl(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}(X_),Df={Device:hf,Swapchain:lf,Buffer:af,Texture:xf,Sampler:Ef,Shader:Cf,InputAssembler:_f,RenderPass:bf,Framebuffer:cf,DescriptorSet:ff,DescriptorSetLayout:df,PipelineLayout:pf,PipelineState:Tf,CommandBuffer:of,Queue:Af,GeneralBarrier:wf,TextureBarrier:Rf,BufferBarrier:If,RasterizerState:mf,BlendState:yf,BlendTarget:vf,DepthStencilState:gf,PipelineStateInfo:Sf};Object.assign(Df,sf),S.gfx=Df;var Bf,Mf,Pf={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 Of in Pf){var Lf=Pf[Of];!0===Lf?Lf=Of.slice(3):!1===Lf&&(Lf=Of),ut(S,"cc",[{name:Of,newName:Lf,target:S.gfx,targetName:"cc.gfx"}])}lt(S,"cc",[{name:"GFX_MAX_VERTEX_ATTRIBUTES"},{name:"GFX_MAX_TEXTURE_UNITS"},{name:"GFX_MAX_ATTACHMENTS"},{name:"GFX_MAX_BUFFER_BINDINGS"},{name:"GFXTextureLayout"}]),lt(tc,"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;"}]),lt(E_.prototype,"ColorAttachment",[{name:"beginAccesses",suggest:"Please assign to ColorAttachment.barrier instead"},{name:"endAccesses",suggest:"Please assign to ColorAttachment.barrier instead"}]),lt(C_.prototype,"DepthStencilAttachment",[{name:"beginAccesses",suggest:"Please assign to DepthStencilAttachment.barrier instead"},{name:"endAccesses",suggest:"Please assign to DepthStencilAttachment.barrier instead"}]),ut(hf.prototype,"Device",[{name:"getGlobalBarrier",newName:"getGeneralBarrier"}]),function(t){t[t.AUTO=0]="AUTO",t[t.CANVAS=1]="CANVAS",t[t.WEBGL=2]="WEBGL",t[t.HEADLESS=3]="HEADLESS",t[t.WEBGPU=4]="WEBGPU"}(Bf||(Bf={})),function(t){t[t.UNKNOWN=-1]="UNKNOWN",t[t.CANVAS=0]="CANVAS",t[t.WEBGL=1]="WEBGL",t[t.WEBGPU=2]="WEBGPU",t[t.OPENGL=3]="OPENGL",t[t.HEADLESS=4]="HEADLESS"}(Mf||(Mf={}));var Nf=function(){function t(){this.initialized=!1,this._gfxDevice=void 0,this._canvas=null,this._swapchain=void 0,this._renderType=Mf.UNKNOWN,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=Me.querySettings(De.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 n_(e);if(this._renderType===Mf.WEBGL||this._renderType===Mf.WEBGPU){var s=!!globalThis.WebGL2RenderingContext;if(globalThis.navigator.userAgent.toLowerCase(),Sa.browserType===Ws.UC&&(s=!1),hf.canvas=t,this._renderType===Mf.WEBGPU&&S.WebGPUDevice)return new Promise((function(t,e){i._tryInitializeWebGPUDevice(S.WebGPUDevice,r).then((function(e){i._initSwapchain(),t(e)})).catch((function(t){e(t)}))}));s&&S.WebGL2Device&&this._tryInitializeDeviceSync(S.WebGL2Device,r),S.WebGLDevice&&this._tryInitializeDeviceSync(S.WebGLDevice,r),S.EmptyDevice&&this._tryInitializeDeviceSync(S.EmptyDevice,r),this._initSwapchain()}else this._renderType===Mf.HEADLESS&&S.EmptyDevice&&(this._tryInitializeDeviceSync(S.EmptyDevice,r),this._initSwapchain());return!!this._gfxDevice||(it(16337),this._renderType=Mf.UNKNOWN,!1)},e._initSwapchain=function(){var t=new i_(1,this._canvas),e=ya.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>Bf.WEBGPU||tthis.pipes.length?(tt(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],nd[rd[n++]]=ed[(3&r)<<2|s>>4],nd[rd[n++]]=ed[15&s]}return t.replace(e,nd.join(""))}var ad=/.*[/\\][0-9a-fA-F]{2}[/\\]([0-9a-fA-F-@]{8,}).*/;function od(t){var e=ad.exec(t);return e?e[1]:""}function hd(t,e){(e=e||Object.create(null)).__isNative__=e.isNative,e.nativeExt&&(e.ext=e.nativeExt);var i=Yf.find((function(e){return!!e.getAssetInfo(t)}));return i&&(e.bundle=i.name),cd(t,e)}function ud(t){return!!t&&(t instanceof S.SceneAsset||t instanceof S.Scene)}function ld(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 cd(t,e){var i=td.create({input:t,options:e}),n=[];try{for(var r,s=f(Qf.sync(i));!(r=s()).done;){var a=r.value,o=a.url;a.recycle(),n.push(o)}}catch(t){for(var h,u=f(i.output);!(h=u()).done;)h.value.recycle();H(t.message,t.stack)}return i.recycle(),n.length>1?n:n[0]}var _d,fd,dd,pd=Object.freeze({__proto__:null,getUuidFromURL:od,getUrlWithUuid:hd,isScene:ud,normalize:ld,transform:cd,decodeUuid:sd}),md=lo,gd=so,vd=t("dX",eo("cc.Asset")((fd=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r0&&this._ref--,t&&S.assetManager._releaseManager.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 X(at(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=hd(this._uuid,{nativeExt:t,isNative:!0}):this._nativeUrl=hd(this._uuid,{__nativeName__:t,nativeExt:ia(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}(zs(Ms)),dd=ja(fd.prototype,"_native",[md],(function(){return""})),m(fd.prototype,"_nativeAsset",[gd],Object.getOwnPropertyDescriptor(fd.prototype,"_nativeAsset"),fd.prototype),_d=fd))||_d);vd.prototype.createNode=null,S.Asset=vd;var yd,Sd,Td,Ad,bd,Ed;!function(t){t[t.RGB565=ec.R5G6B5]="RGB565",t[t.RGB5A1=ec.RGB5A1]="RGB5A1",t[t.RGBA4444=ec.RGBA4]="RGBA4444",t[t.RGB888=ec.RGB8]="RGB888",t[t.RGB32F=ec.RGB32F]="RGB32F",t[t.RGBA8888=ec.RGBA8]="RGBA8888",t[t.BGRA8888=ec.BGRA8]="BGRA8888",t[t.RGBA32F=ec.RGBA32F]="RGBA32F",t[t.A8=ec.A8]="A8",t[t.I8=ec.L8]="I8",t[t.AI8=ec.LA8]="AI8",t[t.RGB_PVRTC_2BPPV1=ec.PVRTC_RGB2]="RGB_PVRTC_2BPPV1",t[t.RGBA_PVRTC_2BPPV1=ec.PVRTC_RGBA2]="RGBA_PVRTC_2BPPV1",t[t.RGB_A_PVRTC_2BPPV1=1024]="RGB_A_PVRTC_2BPPV1",t[t.RGB_PVRTC_4BPPV1=ec.PVRTC_RGB4]="RGB_PVRTC_4BPPV1",t[t.RGBA_PVRTC_4BPPV1=ec.PVRTC_RGBA4]="RGBA_PVRTC_4BPPV1",t[t.RGB_A_PVRTC_4BPPV1=1025]="RGB_A_PVRTC_4BPPV1",t[t.RGB_ETC1=ec.ETC_RGB8]="RGB_ETC1",t[t.RGBA_ETC1=1026]="RGBA_ETC1",t[t.RGB_ETC2=ec.ETC2_RGB8]="RGB_ETC2",t[t.RGBA_ETC2=ec.ETC2_RGBA8]="RGBA_ETC2",t[t.RGBA_ASTC_4x4=ec.ASTC_RGBA_4X4]="RGBA_ASTC_4x4",t[t.RGBA_ASTC_5x4=ec.ASTC_RGBA_5X4]="RGBA_ASTC_5x4",t[t.RGBA_ASTC_5x5=ec.ASTC_RGBA_5X5]="RGBA_ASTC_5x5",t[t.RGBA_ASTC_6x5=ec.ASTC_RGBA_6X5]="RGBA_ASTC_6x5",t[t.RGBA_ASTC_6x6=ec.ASTC_RGBA_6X6]="RGBA_ASTC_6x6",t[t.RGBA_ASTC_8x5=ec.ASTC_RGBA_8X5]="RGBA_ASTC_8x5",t[t.RGBA_ASTC_8x6=ec.ASTC_RGBA_8X6]="RGBA_ASTC_8x6",t[t.RGBA_ASTC_8x8=ec.ASTC_RGBA_8X8]="RGBA_ASTC_8x8",t[t.RGBA_ASTC_10x5=ec.ASTC_RGBA_10X5]="RGBA_ASTC_10x5",t[t.RGBA_ASTC_10x6=ec.ASTC_RGBA_10X6]="RGBA_ASTC_10x6",t[t.RGBA_ASTC_10x8=ec.ASTC_RGBA_10X8]="RGBA_ASTC_10x8",t[t.RGBA_ASTC_10x10=ec.ASTC_RGBA_10X10]="RGBA_ASTC_10x10",t[t.RGBA_ASTC_12x10=ec.ASTC_RGBA_12X10]="RGBA_ASTC_12x10",t[t.RGBA_ASTC_12x12=ec.ASTC_RGBA_12X12]="RGBA_ASTC_12x12"}(yd||(yd={})),function(t){t[t.REPEAT=pc.WRAP]="REPEAT",t[t.CLAMP_TO_EDGE=pc.CLAMP]="CLAMP_TO_EDGE",t[t.MIRRORED_REPEAT=pc.MIRROR]="MIRRORED_REPEAT",t[t.CLAMP_TO_BORDER=pc.BORDER]="CLAMP_TO_BORDER"}(Sd||(Sd={})),function(t){t[t.NONE=dc.NONE]="NONE",t[t.LINEAR=dc.LINEAR]="LINEAR",t[t.NEAREST=dc.POINT]="NEAREST"}(Td||(Td={}));var Cd=1346981187,xd=Ee({PVR:0,PKM:1,ASTC:2});function wd(t,e){return t[e]<<8|t[e+1]}function Rd(t){return!!(Sa.hasFeature(Sa.Feature.IMAGE_BITMAP)&&t instanceof ImageBitmap)}var Id,Dd,Bd,Md,Pd,Od,Ld,Nd,Fd,kd,Gd,Vd=t("e1",eo("cc.ImageAsset")(((Ed=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=f(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,Cd,!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],_=n-a.byteLength;if(n>0){var f=new Uint8Array(s,c,_),d=new Uint8Array(r._data.byteLength+f.byteLength);d.set(r._data),d.set(f,r._data.byteLength),r._data=d,r.mipmapLevelDataSize[e]=_}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=wd(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:wd(a,12),r.height=e>0?r.height:wd(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=function(t,e){return 4===t?yd.RGBA_ASTC_4x4:5===t?4===e?yd.RGBA_ASTC_5x4:yd.RGBA_ASTC_5x5:6===t?5===e?yd.RGBA_ASTC_6x5:yd.RGBA_ASTC_6x6:8===t?5===e?yd.RGBA_ASTC_8x5:6===e?yd.RGBA_ASTC_8x6:yd.RGBA_ASTC_8x8:10===t?5===e?yd.RGBA_ASTC_10x5:6===e?yd.RGBA_ASTC_10x6:8===e?yd.RGBA_ASTC_10x8:yd.RGBA_ASTC_10x10:10===e?yd.RGBA_ASTC_12x10:yd.RGBA_ASTC_12x12}(o,h),c=i+16,_=n-16;if(n>0){var f=new Uint8Array(s,c,_),d=new Uint8Array(r._data.byteLength+f.byteLength);d.set(r._data),d.set(f,r._data.byteLength),r._data=d,r.mipmapLevelDataSize[e]=_}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=yd.RGBA8888,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=f(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){Rd(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(Rd(this.data)){var e;null===(e=this.data)||void 0===e||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=Ff.gfxDevice,s=e.split("_"),a=Number.MAX_VALUE,o=this._format,h="",u=Pe.SUPPORT_TEXTURE_FORMATS,l=f(s);!(n=l()).done;){var c=n.value.split("@"),_=parseInt(c[0],void 0),d=i.extnames[_]||c[0],p=u.indexOf(d);if(-1!==p&&p=yd.RGB_ETC1&&this._format<=yd.RGBA_ASTC_12x12||this._format>=yd.RGB_A_PVRTC_2BPPV1&&this._format<=yd.RGBA_ETC1}},{key:"mipmapLevelDataSize",get:function(){return this._nativeData.mipmapLevelDataSize}},{key:"url",get:function(){return this.nativeUrl}}]),i}(vd)).extnames=[".png",".jpg",".jpeg",".bmp",".webp",".pvr",".pkm",".astc"],Ed._sharedPlaceHolderCanvas=null,m((bd=Ed).prototype,"_nativeAsset",[jo],Object.getOwnPropertyDescriptor(bd.prototype,"_nativeAsset"),bd.prototype),Ad=bd))||Ad);S.ImageAsset=Vd,we(ec);var Ud,zd,Hd,Wd=new bt("Tex"),Xd=eo("cc.TextureBase")(((Gd=function(t){function e(){var e;return(e=t.call(this)||this)._format=Bd&&Bd(),e._minFilter=Md&&Md(),e._magFilter=Pd&&Pd(),e._mipFilter=Od&&Od(),e._wrapS=Ld&&Ld(),e._wrapT=Nd&&Nd(),e._wrapR=Fd&&Fd(),e._anisotropy=kd&&kd(),e._width=1,e._height=1,e._samplerInfo=new c_,e._gfxSampler=null,e._gfxDevice=null,e._textureHash=0,e._id=Wd.getNewId(),e._gfxDevice=e._getGFXDevice(),e._textureHash=zl(e._id,666),e}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){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=S.director.root)&&void 0!==e&&e.batcher2D&&S.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):it(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 Ff.gfxDevice},i._getGFXFormat=function(){return this._getGFXPixelFormat(this._format)},i._setGFXFormat=function(t){this._format=void 0===t?yd.RGBA8888:t},i._getGFXPixelFormat=function(t){return t===yd.RGBA_ETC1?t=yd.RGB_ETC1:t===yd.RGB_A_PVRTC_4BPPV1?t=yd.RGB_PVRTC_4BPPV1:t===yd.RGB_A_PVRTC_2BPPV1&&(t=yd.RGB_PVRTC_2BPPV1),t},n(e,[{key:"isCompressed",get:function(){return this._format>=yd.RGB_ETC1&&this._format<=yd.RGBA_ASTC_12x12||this._format>=yd.RGB_A_PVRTC_2BPPV1&&this._format<=yd.RGBA_ETC1}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}}]),e}(vd)).PixelFormat=yd,Gd.WrapMode=Sd,Gd.Filter=Td,Bd=ja((Dd=Gd).prototype,"_format",[lo],(function(){return yd.RGBA8888})),Md=ja(Dd.prototype,"_minFilter",[lo],(function(){return Td.LINEAR})),Pd=ja(Dd.prototype,"_magFilter",[lo],(function(){return Td.LINEAR})),Od=ja(Dd.prototype,"_mipFilter",[lo],(function(){return Td.NONE})),Ld=ja(Dd.prototype,"_wrapS",[lo],(function(){return Sd.REPEAT})),Nd=ja(Dd.prototype,"_wrapT",[lo],(function(){return Sd.REPEAT})),Fd=ja(Dd.prototype,"_wrapR",[lo],(function(){return Sd.REPEAT})),kd=ja(Dd.prototype,"_anisotropy",[lo],(function(){return 0})),Id=Dd))||Id;S.TextureBase=Xd;var jd=t("e7",eo("cc.Script")(Ud=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e}(vd))||Ud);S._Script=jd;var Yd=t("e8",eo("cc.JavaScript")(zd=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e}(jd))||zd);S._JavaScript=Yd;var qd,Kd,Qd,Zd,Jd,$d,tp,ep=t("e9",eo("cc.TypeScript")(Hd=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e}(jd))||Hd);S._TypeScript=ep;var ip,np,rp,sp,ap,op,hp,up,lp,cp,_p,fp=t("dq",eo("cc.ClickEvent")((Kd=function(){function t(){this.target=Qd&&Qd(),this.component=Zd&&Zd(),this._componentId=Jd&&Jd(),this.handler=$d&&$d(),this.customEventData=tp&&tp()}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)?S.macro.REPEAT_FOREVER:i,n=n||0;var r=S.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&&S.director.getScheduler().unschedule(t,this)},i.unscheduleAllCallbacks=function(){S.director.getScheduler().unscheduleAllForTarget(this)},n(e,[{key:"name",get:function(){if(this._name)return this._name;var t=Nt(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=S.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 this._objFlags&pp}},{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}(Ms)).EventHandler=fp,up._executionOrder=0,up._requireComponent=null,up.system=null,m((sp=up).prototype,"__scriptAsset",[np],Object.getOwnPropertyDescriptor(sp.prototype,"__scriptAsset"),sp.prototype),ap=ja(sp.prototype,"node",[lo],(function(){return null})),op=ja(sp.prototype,"_enabled",[lo],(function(){return!0})),hp=ja(sp.prototype,"__prefab",[lo],(function(){return null})),rp=sp))||rp));Bt(mp,"_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)})),S.Component=mp;var gp=t("dO",eo("cc.MissingScript")((cp=function(t){function e(){var e;return(e=t.call(this)||this)._$erialized=_p&&_p(),e}return s(e,t),e.safeFindClass=function(t){var e=ae(t);if(e)return e;S.deserialize.reportMissingClass(t)},e.prototype.onLoad=function(){tt(4600,this.node.name)},e}(mp),_p=ja(cp.prototype,"_$erialized",[lo,_o],(function(){return null})),lp=cp))||lp);S._MissingScript=gp;try{var vp=gp.__values__;0!==vp.length&&"_$erialized"===vp[vp.length-1]||(it(16338),it(16339,vp.join(", ")))}catch(lr){it(16340,""+lr)}var yp=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 Sp(t){var e=t;return{chunks:e.chunks,document:e.document}}function Tp(t){if(t.length<16)throw new Ap(at(13102));var e=new DataView(t.buffer,t.byteOffset,t.byteLength);if(1313817411!==e.getUint32(0,!0))throw new Ap(at(13100));var i=e.getUint32(4,!0);if(1!==i)throw new Ap(at(13101,i));if(e.getUint32(8,!0)!==e.byteLength)throw new Ap(at(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=function(t){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);if("Buffer"in globalThis)return globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString();throw new Error(at(13104))}(s);try{a=JSON.parse(o)}catch(t){throw new Ap(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[th]?e._deserialize?e._deserialize(t.content,this):S.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=qt(i);r&&n._deserializeInto(t,e,r)}};e[th](r,this._context)},e._deserializeFireClass=function(t,e,i){var n;if(i.hasOwnProperty("__deserialize__"))n=i.__deserialize__;else{n=function(t,e){for(var i=Ci.Attr.getClassAttrs(e),n=e.__values__,r=["var prop;"],s=function(t){return Le.test(ue(t))}(e),a=0;a=0?e[i]=t[5][n]:t[7][3*~n]=e}function kp(t){return function(e,i,n,r){for(var s=0;s=0){var c=o[u];e[a]=Np(t,c,l)}else(0,Up[u=~u])(t,e,a,l)}return r}(s);S.game._isCloning=!1,s[7]&&function(t,e,i){for(var n=t.length-1,r=0,s=3*t[n];r=0?a[i[h]]=o:a[~h]=o}for(;r=0?u[i[c]]=l:u[~c]=l}}(s[7],a,s[2]),function(t){for(var e=t[5],i=t[2],n=t[1],r=t[8],s=t[9],a=t[10],o=0;o=0?i[u]:~u,s[o]=u);var l=a[o];"number"==typeof l&&(a[o]=n[l])}}(s),n=a[o]}else n=function(t,e,i){var n,r=(i=i||{}).classFinder||ae,s=i.createAssetRefs||Sa.platform===qs.EDITOR_CORE,a=i.customEnv,o=i.ignoreEditorOnly,h=null!==(n=i.reportMissingClass)&&void 0!==n?n:S.deserialize.reportMissingClass;e.init();var u=Dp.pool.get(e,r,h,a,o);S.game._isCloning=!0;var l=u.deserialize(t);return S.game._isCloning=!1,Dp.pool.put(u),s&&e.assignAssetsBy((function(t,e){return EditorExtends.serialize.asAsset(t,e.type)})),l}(t,e,i);return r&&Op.pool.put(e),n}Up[0]=function(t,e,i,n){e[i]=n},Up[1]=Fp,Up[2]=kp(Fp),Up[3]=kp(Gp),Up[4]=Vp,Up[5]=function(t,e,i,n){var r=n[0],s=e[i];(0,Pp[r])(s,n)},Up[6]=Gp,Up[7]=function(t,e,i,n){e[i].set(n)},Up[8]=function(t,e,i,n){var r=n[0],s=new Bp[r];(0,Pp[r])(s,n),e[i]=s},Up[9]=kp(Vp),Up[10]=function(t,e,i,n){var r=t[3][n[0]];e[i]=Np(t,r,n[1])},Up[11]=function(t,e,i,n){var r=n[0];e[i]=r;for(var s=1;s>e,r.texExtent.height=this._textureHeight>>e,r.texSubres.mipLevel=e,r.texSubres.baseArrayLayer=i,ArrayBuffer.isView(t)?n.copyBuffersToTexture([t],this._gfxTexture,im):n.copyTexImagesToTexture([t],this._gfxTexture,im)}}},i._assignImage=function(t,e,i){var n=t.data;if(n&&(this.uploadData(n,e,i),this._checkTextureLoaded(),Pe.CLEANUP_IMAGE_CACHE)){var r=em.getDeps(this._uuid),s=r.indexOf(t._uuid);-1!==s&&(fe(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){st(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=lc.NONE;this._mipFilter!==Td.NONE&&function(t,e,i){return!(t.gfxAPI===Jl.WEBGL)||nm(e)&&nm(i)}(t,this._width,this._height)&&(this._mipmapLevel=function(t,e){for(var i=Math.max(t,e),n=0;i;)i>>=1,n++;return n}(this._width,this._height),this.isUsingOfflineMipmaps()||this.isCompressed||(e=lc.GEN_MIPMAP));var i=this._getGfxTextureCreateInfo({usage:uc.SAMPLED|uc.TRANSFER_DST|uc.COLOR_ATTACHMENT,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=yd.RGBA8888),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;S.internal.dynamicAtlasManager.textureBleeding&&((a<=8||o<=8)&&(this._texture.drawTextureAt(i.image,this._x-1,this._y-1),this._texture.drawTextureAt(i.image,this._x-1,this._y+1),this._texture.drawTextureAt(i.image,this._x+1,this._y-1),this._texture.drawTextureAt(i.image,this._x+1,this._y+1)),this._texture.drawTextureAt(i.image,this._x-1,this._y),this._texture.drawTextureAt(i.image,this._x+1,this._y),this._texture.drawTextureAt(i.image,this._x,this._y-1),this._texture.drawTextureAt(i.image,this._x,this._y+1)),this._texture.drawTextureAt(i.image,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 h={x:r,y:s,texture:this._texture};return this._innerSpriteFrames.push(t),h},e.removeSpriteFrame=function(t){pe(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)tt(16365);else{var n=1<19||e<0)tt(16366);else{var i=1<31||e<0?(tt(16368),""):t.Enum[1<0&&(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?it(1640,this.name,this.uuid):this._scene=this._parent._scene},e.attr=function(t){jt(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(vm.PARENT_CHANGED,i),i&&!(i._objFlags&Fm)){var r=i._children.indexOf(this);i._children.splice(r,1),i._updateSiblingIndex(),i.emit&&i.emit(vm.CHILD_REMOVED,this)}n&&(n._children.push(this),this._siblingIndex=n._children.length-1,n.emit&&n.emit(vm.CHILD_ADDED,this)),this._onHierarchyChanged(i)}},e.getChildByUuid=function(t){if(!t)return U("Invalid uuid"),null;for(var e=this._children,i=0,n=e.length;i0?(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=Um(t);return e?i._findComponent(this,e):null},e.getComponents=function(t){var e=Um(t),n=[];return e&&i._findComponents(this,e,n),n},e.getComponentInChildren=function(t){var e=Um(t);return e?i._findChildComponent(this._children,e):null},e.getComponentsInChildren=function(t){var e=Um(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=oe(t)))throw S._RF.peek()&&it(3808,t),TypeError(at(3807,t))}else{if(!t)throw TypeError(at(3804));e=t}if("function"!=typeof e)throw TypeError(at(3809));if(!Kt(e,S.Component))throw TypeError(at(3810));var i=e._requireComponent;if(i)if(Array.isArray(i))for(var n=0;n=0;){if(a=(e=sg[n--]).hasChangedFlags,e.isValid&&(e._transformFlags&a&t)!==t)for(e._transformFlags|=t,e.hasChangedFlags=a|t,s=(i=e._children).length,r=0;r=0;)gn.transformInverseRTS(t,t,i._lrot,i._lpos,i._lscale),i=sg[--n];return t},e.setWorldPosition=function(t,e,i){var n=this._pos,r=this._parent&&(this._transformFlags&mm.POSITION)!==mm.NONE;if(void 0===e){if(!r&&n.equals(t))return;gn.copy(n,t)}else{if(gn.set(Zm,t,e,i),!r&&n.equals(Zm))return;gn.copy(n,Zm)}var s=this._parent,a=this._lpos;s?(s.updateWorldTransform(),gn.transformMat4(a,n,Vn.invert(ng,s._mat))):gn.copy(a,n),this.invalidateChildren(mm.POSITION),1&this._eventMask&&this.emit(vm.TRANSFORM_CHANGED,mm.POSITION)},e.getWorldPosition=function(t){return this.updateWorldTransform(),t?gn.copy(t,this._pos):gn.copy(new gn,this._pos)},e.setWorldRotation=function(t,e,i,n){var r=this._rot,s=this._parent&&(this._transformFlags&mm.ROTATION)!==mm.NONE;if(void 0===e){if(!s&&r.equals(t))return;Bn.copy(r,t)}else{if(Bn.set($m,t,e,i,n),!s&&r.equals($m))return;Bn.copy(r,$m)}this._parent?(this._parent.updateWorldTransform(),Bn.multiply(this._lrot,Bn.conjugate(this._lrot,this._parent._rot),r)):Bn.copy(this._lrot,r),this._eulerDirty=!0,this.invalidateChildren(mm.ROTATION),1&this._eventMask&&this.emit(vm.TRANSFORM_CHANGED,mm.ROTATION)},e.setWorldRotationFromEuler=function(t,e,i){Bn.fromEuler($m,t,e,i),this.setWorldRotation($m)},e.getWorldRotation=function(t){return this.updateWorldTransform(),t?Bn.copy(t,this._rot):Bn.copy(new Bn,this._rot)},e.setWorldScale=function(t,e,i){var n=this._scale,r=this._parent&&(this._transformFlags&mm.SCALE)!==mm.NONE,s=this._parent;if(s&&this.updateWorldTransform(),void 0===e){if(!r&&n.equals(t))return;gn.copy(n,t)}else{if(gn.set(Zm,t,e,i),!r&&n.equals(Zm))return;gn.copy(n,Zm)}s?(Zm.x=n.x/gn.set(Jm,this._mat.m00,this._mat.m01,this._mat.m02).length(),Zm.y=n.y/gn.set(Jm,this._mat.m04,this._mat.m05,this._mat.m06).length(),Zm.z=n.z/gn.set(Jm,this._mat.m08,this._mat.m09,this._mat.m10).length(),Vn.scale(ng,this._mat,Zm),Vn.multiply(rg,Vn.invert(rg,s._mat),ng),wn.fromQuat(ig,Bn.conjugate(eg,this._lrot)),wn.multiplyMat4(ig,ig,rg),this._lscale.x=gn.set(Zm,ig.m00,ig.m01,ig.m02).length(),this._lscale.y=gn.set(Zm,ig.m03,ig.m04,ig.m05).length(),this._lscale.z=gn.set(Zm,ig.m06,ig.m07,ig.m08).length()):gn.copy(this._lscale,n),this.invalidateChildren(mm.SCALE),1&this._eventMask&&this.emit(vm.TRANSFORM_CHANGED,mm.SCALE)},e.getWorldScale=function(t){return this.updateWorldTransform(),t?gn.copy(t,this._scale):gn.copy(new gn,this._scale)},e.getWorldMatrix=function(t){this.updateWorldTransform();var e=t||new Vn;return Vn.copy(e,this._mat)},e.getWorldRS=function(t){this.updateWorldTransform();var e=t||new Vn;return Vn.copy(e,this._mat),e.m12=0,e.m13=0,e.m14=0,e},e.getWorldRT=function(t){this.updateWorldTransform();var e=t||new Vn;return Vn.fromRT(e,this._rot,this._pos)},e.setRTS=function(t,e,i){var n=0;t&&(n|=mm.ROTATION,void 0!==t.w?(Bn.copy(this._lrot,t),this._eulerDirty=!0):(gn.copy(this._euler,t),Bn.fromEuler(this._lrot,t.x,t.y,t.z),this._eulerDirty=!1)),e&&(gn.copy(this._lpos,e),n|=mm.POSITION),i&&(gn.copy(this._lscale,i),n|=mm.SCALE),n&&(this.invalidateChildren(n),1&this._eventMask&&this.emit(vm.TRANSFORM_CHANGED,n))},e.isTransformDirty=function(){return this._transformFlags!==mm.NONE},e.pauseSystemEvents=function(t){this._eventProcessor.setEnabled(!1,t)},e.resumeSystemEvents=function(t){this._eventProcessor.setEnabled(!0,t)},i.resetHasChangedFlags=function(){og+=1},i.clearNodeArray=function(){i.ClearFrame0},set:function(t){t?this._objFlags|=km:this._objFlags&=~km}},{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&&S.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:"worldPosition",get:function(){return this.updateWorldTransform(),this._pos},set:function(t){this.setWorldPosition(t)}},{key:"rotation",get:function(){return this._lrot},set:function(t){this.setRotation(t)}},{key:"eulerAngles",get:function(){return this._eulerDirty&&(Bn.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){this._euler.equals(Zm.set(0,0,t))||(gn.set(this._euler,0,0,t),Bn.fromAngleZ(this._lrot,t),this._eulerDirty=!1,this.invalidateChildren(mm.ROTATION),1&this._eventMask&&this.emit(vm.TRANSFORM_CHANGED,mm.ROTATION))}},{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){Vn.toRTS(t,this._lrot,this._lpos,this._lscale),this.invalidateChildren(mm.TRS),this._eulerDirty=!0,1&this._eventMask&&this.emit(vm.TRANSFORM_CHANGED,mm.TRS)}},{key:"worldMatrix",get:function(){return this.updateWorldTransform(),this._mat}},{key:"forward",get:function(){return gn.transformQuat(new gn,gn.FORWARD,this.worldRotation)},set:function(t){var e=t.length();gn.multiplyScalar(Zm,t,-1/e),Bn.fromViewUp($m,Zm),this.setWorldRotation($m)}},{key:"up",get:function(){return gn.transformQuat(new gn,gn.UP,this.worldRotation)}},{key:"right",get:function(){return gn.transformQuat(new gn,gn.RIGHT,this.worldRotation)}},{key:"mobility",get:function(){return this._mobility},set:function(t){this._mobility!==t&&(this._mobility=t,this.emit(vm.MOBILITY_CHANGED))}},{key:"layer",get:function(){return this._layer},set:function(t){this._layer!==t&&(this._layer=t,this._uiProps&&this._uiProps.uiComp&&(this._uiProps.uiComp.setNodeDirty(),this._uiProps.uiComp.markForUpdateRenderData()),this.emit(vm.LAYER_CHANGED,this._layer))}},{key:"flagChangedVersion",get:function(){return this._flagChangeVersion}},{key:"hasChangedFlags",get:function(){return this._flagChangeVersion===og?this._hasChangedFlags:0},set:function(t){this._flagChangeVersion=og,this._hasChangedFlags=t}}]),i}(Ms)).idGenerator=Vm,Lm._stacks=[[]],Lm._stackId=0,Lm.EventType=vm,Lm.NodeSpace=pm,Lm.TransformDirtyBit=mm,Lm.TransformBit=mm,Lm.reserveContentsForAllSyncablePrefabTag=ag,Lm.ClearFrame=0,Lm.ClearRound=1e3,m((bm=Lm).prototype,"_persistNode",[so],Object.getOwnPropertyDescriptor(bm.prototype,"_persistNode"),bm.prototype),Em=ja(bm.prototype,"_parent",[lo],(function(){return null})),Cm=ja(bm.prototype,"_children",[lo],(function(){return[]})),xm=ja(bm.prototype,"_active",[lo],(function(){return!0})),wm=ja(bm.prototype,"_components",[lo],(function(){return[]})),Rm=ja(bm.prototype,"_prefab",[lo],(function(){return null})),Im=ja(bm.prototype,"_lpos",[lo],(function(){return new gn})),Dm=ja(bm.prototype,"_lrot",[lo],(function(){return new Bn})),Bm=ja(bm.prototype,"_lscale",[lo],(function(){return new gn(1,1,1)})),Mm=ja(bm.prototype,"_mobility",[lo],(function(){return Nm.Static})),Pm=ja(bm.prototype,"_layer",[lo],(function(){return dm.Enum.DEFAULT})),Om=ja(bm.prototype,"_euler",[lo],(function(){return new gn})),m(bm.prototype,"eulerAngles",[Sm],Object.getOwnPropertyDescriptor(bm.prototype,"eulerAngles"),bm.prototype),m(bm.prototype,"mobility",[Tm],Object.getOwnPropertyDescriptor(bm.prototype,"mobility"),bm.prototype),Am=bm))||Am));S.Node=hg,function(t){t[t.right=0]="right",t[t.left=1]="left",t[t.top=2]="top",t[t.bottom=3]="bottom",t[t.front=4]="front",t[t.back=5]="back"}(Km||(Km={})),function(t){t[t.NONE=0]="NONE",t[t.AUTO=1]="AUTO",t[t.BAKED_CONVOLUTION_MAP=2]="BAKED_CONVOLUTION_MAP"}(Qm||(Qm={}));var ug=t("e3",eo("cc.TextureCube")(((qm=function(t){function e(){var e;return(e=t.call(this)||this).isRGBE=Wm&&Wm(),e._mipmapAtlas=Xm&&Xm(),e._mipmapMode=jm&&jm(),e._mipmaps=Ym&&Ym(),e._generatedMipmaps=[],e}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){lg(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 this._mipmapMode===Qm.BAKED_CONVOLUTION_MAP},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;lg(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(A.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];lg(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 Vd({_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},gy=function(t){return(t&fy)>>>20},vy=function(t){return(t&dy)>>>12},yy=function(t){return 4095&t},Sy=function(t,e){return 67108863&t|e<<26&_y},Ty=((iy={})[nc.UNKNOWN]=function(t,e,i){return void 0===i&&(i=0),tt(12010,i)},iy[nc.INT]=function(t,e,i){return void 0===i&&(i=0),t[i]},iy[nc.INT2]=function(t,e,i){return void 0===i&&(i=0),jn.fromArray(e,t,i)},iy[nc.INT3]=function(t,e,i){return void 0===i&&(i=0),gn.fromArray(e,t,i)},iy[nc.INT4]=function(t,e,i){return void 0===i&&(i=0),cn.fromArray(e,t,i)},iy[nc.FLOAT]=function(t,e,i){return void 0===i&&(i=0),t[i]},iy[nc.FLOAT2]=function(t,e,i){return void 0===i&&(i=0),jn.fromArray(e,t,i)},iy[nc.FLOAT3]=function(t,e,i){return void 0===i&&(i=0),gn.fromArray(e,t,i)},iy[nc.FLOAT4]=function(t,e,i){return void 0===i&&(i=0),cn.fromArray(e,t,i)},iy[nc.MAT3]=function(t,e,i){return void 0===i&&(i=0),wn.fromArray(e,t,i)},iy[nc.MAT4]=function(t,e,i){return void 0===i&&(i=0),Vn.fromArray(e,t,i)},iy),Ay=((ny={})[nc.UNKNOWN]=function(t,e,i){return void 0===i&&(i=0),tt(12010,i)},ny[nc.INT]=function(t,e,i){return void 0===i&&(i=0),t[i]=e},ny[nc.INT2]=function(t,e,i){return void 0===i&&(i=0),jn.toArray(t,e,i)},ny[nc.INT3]=function(t,e,i){return void 0===i&&(i=0),gn.toArray(t,e,i)},ny[nc.INT4]=function(t,e,i){return void 0===i&&(i=0),cn.toArray(t,e,i)},ny[nc.FLOAT]=function(t,e,i){return void 0===i&&(i=0),t[i]=e},ny[nc.FLOAT2]=function(t,e,i){return void 0===i&&(i=0),jn.toArray(t,e,i)},ny[nc.FLOAT3]=function(t,e,i){return void 0===i&&(i=0),gn.toArray(t,e,i)},ny[nc.FLOAT4]=function(t,e,i){return void 0===i&&(i=0),cn.toArray(t,e,i)},ny[nc.MAT3]=function(t,e,i){return void 0===i&&(i=0),wn.toArray(t,e,i)},ny[nc.MAT4]=function(t,e,i){return void 0===i&&(i=0),Vn.toArray(t,e,i)},ny),by=((ry={})[nc.INT]=function(t){return"number"==typeof t},ry[nc.FLOAT]=function(t){return"number"==typeof t},ry[nc.INT2]=function(t){return!!(t instanceof jn)},ry[nc.FLOAT2]=function(t){return!!(t instanceof jn)},ry[nc.INT3]=function(t){return!!(t instanceof gn)},ry[nc.FLOAT3]=function(t){return!!(t instanceof gn)},ry[nc.INT4]=function(t){return!!(t instanceof cn)},ry[nc.FLOAT4]=function(t){return!!(t instanceof cn||t instanceof En||t instanceof Bn)},ry[nc.MAT3]=function(t){return!!(t instanceof wn)},ry[nc.MAT4]=function(t){return!!(t instanceof Vn)},ry),Ey=[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 Cy(t){switch(t){case nc.BOOL:case nc.INT:case nc.UINT:case nc.FLOAT:return Ey[0];case nc.BOOL2:case nc.INT2:case nc.UINT2:case nc.FLOAT2:return Ey[1];case nc.BOOL4:case nc.INT4:case nc.UINT4:case nc.FLOAT4:return Ey[2];case nc.MAT4:return Ey[3];case nc.SAMPLER2D:return"default-texture";case nc.SAMPLER_CUBE:return"default-cube-texture";case nc.SAMPLER2D_ARRAY:return"default-array-texture";case nc.SAMPLER3D:return"default-3d-texture"}return Ey[0]}function xy(t){switch(t){case nc.SAMPLER2D:return"-texture";case nc.SAMPLER_CUBE:return"-cube-texture";case nc.SAMPLER2D_ARRAY:return"-array-texture";case nc.SAMPLER3D:return"-3d-texture";default:return"-unknown"}}function wy(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 Vy(t){return 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}(vd))._effects={},Qy._layoutValid=!0,jy=ja((Xy=Qy).prototype,"techniques",[lo],(function(){return[]})),Yy=ja(Xy.prototype,"shaders",[lo],(function(){return[]})),qy=ja(Xy.prototype,"combinations",[lo],(function(){return[]})),Ky=ja(Xy.prototype,"hideInEditor",[lo,_o],(function(){return!1})),Wy=Xy))||Wy);S.EffectAsset=$y;var tS=function(){function t(){this.name="",this.base="",this.importBase="",this.nativeBase="",this.deps=null,this.assetInfos=new Uf,this.scenes=new Uf,this.paths=new Uf}var e=t.prototype;return e.init=function(t){var e=this;!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;ae.length)||47===t.charCodeAt(e.length)}(r,t)||!t)for(var s=0,a=i.length;s0&&function(t){var e=Object.create(null);if(e[t._uuid]=t.refCount,rS(t,e,sS,-1),sS.length=0,0!==e[t._uuid])return e[t._uuid];for(var i in e)0!==e[i]&&rS(Wf.get(i),e,sS,1);return sS.length=0,e[t._uuid]}(t)>0)){Wf.remove(i);for(var n=em.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&&(We(this._handleQueue.bind(this),t,e),this._checkNextPeriod=!0)},n(e,[{key:"remoteServerAddress",get:function(){return this._remoteServerAddress}}],[{key:"instance",get:function(){return e._instance||(e._instance=new e),e._instance}}]),e}();OS._instance=void 0;var LS,NS,FS,kS,GS,VS,US=OS.instance,zS=OS.instance,HS=t("e0",eo("cc.JsonAsset")((NS=function(t){function e(){var e;return(e=t.call(this)||this).json=FS&&FS(),e}return s(e,t),e}(vd),FS=ja(NS.prototype,"json",[lo],(function(){return null})),LS=NS))||LS);S.JsonAsset=HS;var WS,XS,jS=t("d$",eo("cc.TextAsset")((GS=function(t){function e(){var e;return(e=t.call(this)||this).text=VS&&VS(),e}return s(e,t),e.prototype.toString=function(){return this.text},e}(vd),VS=ja(GS.prototype,"text",[lo],(function(){return""})),kS=GS))||kS);S.TextAsset=jS;var YS=t("dY",eo("cc.BufferAsset")((m((XS=function(t){function e(){var e;return(e=t.call(this)||this)._buffer=null,e}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}(vd)).prototype,"_nativeAsset",[jo],Object.getOwnPropertyDescriptor(XS.prototype,"_nativeAsset"),XS.prototype),WS=XS))||WS);function qS(t,e,i,n){var r=null,s=null;try{(r=new Vd)._nativeUrl=t,r._nativeAsset=e}catch(t){s=t}n(s,r)}function KS(t,e,i,n){var r=new HS;r.json=e,n(null,r)}function QS(t,e,i,n){var r=new jS;r.text=e,n(null,r)}function ZS(t,e,i,n){var r=new YS;r._nativeUrl=t,r._nativeAsset=e,n(null,r)}function JS(t,e,i,n){var r=new vd;r._nativeUrl=t,r._nativeAsset=e,n(null,r)}function $S(t,i,n,r){var s=Yf.get(i.name);s||(s=i.name===Jf.RESOURCES?yS:new vS,i.base=i.base||t+"/",s.init(i)),e.import("virtual:///prerequisite-imports/"+s.name).then((function(){r(null,s)})).catch(r)}S.BufferAsset=YS;var tT=new(function(){function t(){this._creating=new Uf,this._producers={".png":qS,".jpg":qS,".bmp":qS,".jpeg":qS,".gif":qS,".ico":qS,".tiff":qS,".webp":qS,".image":qS,".pvr":qS,".pkm":qS,".astc":qS,".txt":QS,".xml":QS,".vsh":QS,".fsh":QS,".atlas":QS,".tmx":QS,".tsx":QS,".fnt":QS,".json":KS,".ExportJson":KS,".binary":ZS,".bin":ZS,".dbbin":ZS,".skel":ZS,bundle:$S,default:JS}}var e=t.prototype;return e.register=function(t,e){"object"==typeof t?jt(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=Wf.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 vd&&(i._uuid=t,_S(t,i,n.cacheAsset));for(var r=s._creating.remove(t),a=0,o=r.length;a0){var a=td.create({input:s,progress:r,options:n,onProgress:t.onProgress,onError:td.prototype.recycle,onComplete:function(n){var r;n||((r=t.output).push.apply(r,a.output),a.recycle()),i&&nT(t),e(n)}});Kf.async(a)}else i&&nT(t),e()}))}function nT(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||Me.querySettings(De.Category.ASSETS,"importBase")||"";s&&s.endsWith("/")&&(s=s.substr(0,s.length-1));var a=t.nativeBase||Me.querySettings(De.Category.ASSETS,"nativeBase")||"";a&&a.endsWith("/")&&(a=a.substr(0,a.length-1)),this.generalImportBase=s,this.generalNativeBase=a,this._projectBundles=Me.querySettings(De.Category.ASSETS,"projectBundles")||[];var o=Me.querySettings(De.Category.ASSETS,"assetsOverrides")||{};for(var h in o)this.assetsOverrideMap.set(h,o[h])},e.getBundle=function(t){return Yf.get(t)||null},e.removeBundle=function(t){t._destroy(),Yf.remove(t.name)},e.loadAny=function(t,e,i,n){var r=dS(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=td.create({input:t,onProgress:a,onComplete:gS(o),options:s});qf.async(h)},e.preloadAny=function(t,e,i,n){var r=dS(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=td.create({input:t,onProgress:a,onComplete:gS(o),options:s});Kf.async(h)},e.loadRemote=function(t,e,i){var n=dS(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?(H(e.message,e.stack),s&&s(e,i)):tT.create(t,i,r.ext||ia(t),r,(function(t,e){s&&s(t,e)}))}))):gS(s)(null,this.assets.get(t))},e.loadBundle=function(t,e,i){var n=dS(e,void 0,i),r=n.options,s=n.onComplete,a=ra(t);this.bundles.has(a)?gS(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?(H(e.message,e.stack),s&&s(e,i)):tT.create(t,i,"bundle",r,(function(t,e){s&&s(t,e)}))})))},e.releaseAsset=function(t){aS.tryRelease(t,!0)},e.releaseUnusedAssets=function(){Wf.forEach((function(t){aS.tryRelease(t)}))},e.releaseAll=function(){Wf.forEach((function(t){aS.tryRelease(t,!0)}))},e.loadWithJson=function(){throw new Error("Only valid in Editor")},n(t,[{key:"main",get:function(){return Yf.get(Jf.MAIN)||null}},{key:"resources",get:function(){return Yf.get(Jf.RESOURCES)||null}}],[{key:"instance",get:function(){return this._instance||(this._instance=new t),this._instance}}]),t}());gT._instance=void 0,gT.Pipeline=zf,gT.Task=td,gT.Cache=Uf,gT.RequestItem=cT,gT.Bundle=vS,gT.BuiltinBundleName=Jf,gT.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},gT.Downloader=OS,gT.Parser=aT,gT.DependUtil=$p;var vT=t("ea",S.assetManager=gT.instance);S.AssetManager=gT;var yT,ST,TT,AT=t("eh",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 _=0;_<8;_++){for(var f=0;f<8;f++)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:lm.PixelFormat.RGBA8888},p={width:2,height:2,_data:i,_compressed:!1,format:lm.PixelFormat.RGBA8888},m={width:2,height:2,_data:n,_compressed:!1,format:lm.PixelFormat.RGBA8888},g={width:2,height:2,_data:r,_compressed:!1,format:lm.PixelFormat.RGBA8888},v={width:2,height:2,_data:s,_compressed:!1,format:lm.PixelFormat.RGBA8888},y={width:16,height:16,_data:h,_compressed:!1,format:lm.PixelFormat.RGBA8888},T=new Vd(d),A=new lm;A._uuid="black-texture",A.image=T,t[A._uuid]=A;var b=new Vd(p),E=new lm;E._uuid="empty-texture",E.image=b,t[E._uuid]=E;var C=new ug;C._uuid="black-cube-texture",C.setMipFilter(ug.Filter.NEAREST),C.image={front:new Vd(d),back:new Vd(d),left:new Vd(d),right:new Vd(d),top:new Vd(d),bottom:new Vd(d)},t[C._uuid]=C;var x=new Vd(m),w=new lm;w._uuid="grey-texture",w.image=x,t[w._uuid]=w;var R=new ug;R._uuid="grey-cube-texture",R.setMipFilter(ug.Filter.NEAREST),R.image={front:new Vd(m),back:new Vd(m),left:new Vd(m),right:new Vd(m),top:new Vd(m),bottom:new Vd(m)},t[R._uuid]=R;var I=new Vd(g),D=new lm;D._uuid="white-texture",D.image=I,t[D._uuid]=D;var B=new ug;B._uuid="white-cube-texture",B.setMipFilter(ug.Filter.NEAREST),B.image={front:new Vd(g),back:new Vd(g),left:new Vd(g),right:new Vd(g),top:new Vd(g),bottom:new Vd(g)},t[B._uuid]=B;var M=new Vd(v),P=new lm;P._uuid="normal-texture",P.image=M,t[P._uuid]=P;var O=new Vd(y),L=new lm;L._uuid="default-texture",L.image=O,t[L._uuid]=L;var N=new ug;if(N.setMipFilter(ug.Filter.NEAREST),N._uuid="default-cube-texture",N.image={front:new Vd(y),back:new Vd(y),left:new Vd(y),right:new Vd(y),top:new Vd(y),bottom:new Vd(y)},t[N._uuid]=N,S.SpriteFrame){var F=new S.SpriteFrame,k=T,G=new lm;G.image=k,F.texture=G,F._uuid="default-spriteframe",t[F._uuid]=F}},e.addAsset=function(t,e){this._resources[t]=e},e.get=function(t){return this._resources[t]},e.loadBuiltinAssets=function(){var t=this,e=Me.querySettings(De.Category.ENGINE,"builtinAssets");if(!e)return Promise.resolve();var i=this._resources;return new Promise((function(n,r){vT.loadBundle(Jf.INTERNAL,(function(s){s?r(s):vT.loadAny(e,(function(e,s){e?r(e):(s.forEach((function(e){i[e.name]=e,aS.addIgnoredAsset(e),e instanceof S.Material&&t._materialsToBeCompiled.push(e)})),n())}))}))}))},e.compileBuiltinMaterial=function(){for(var t=0;t=1024)&&m.lightingMap.objectID===a.objectID&&m.useReflectionProbeType===l&&m.reflectionProbeCubemap.objectID===o.objectID&&m.reflectionProbePlanarMap.objectID===h.objectID&&m.reflectionProbeBlendCubemap.objectID===u.objectID&&m.stride===r){if(m.count>=m.capacity){m.capacity<<=1;var g=m.stride*m.capacity,v=m.data;m.data=new Uint8Array(g),m.data.set(v),m.vb.resize(g)}return m.shader=c,m.descriptorSet=_,m.data.set(n.buffer,m.stride*m.count++),void(this.hasPendingModels=!0)}}for(var y=this._device.createBuffer(new r_(rc.VERTEX|rc.TRANSFER_DST,oc.HOST|oc.DEVICE,32*r,r)),S=new Uint8Array(32*r),T=s.vertexBuffers.slice(),A=s.attributes.slice(),b=s.indexBuffer,E=0;E>2,a=this._getBlockView(r,n),o=t.getOffsetFromHandle(e),h=0;h>2)*a,c=0;c+u.length<=l;c+=u.length)o.set(u,s+c);this._rootBufferDirty=!0}},e.resetTexture=function(e,i){var n=this.getHandle(e);if(n){var r,s=t.getTypeFromHandle(n),a=t.getBindingFromHandle(n),o=this._properties[e],h=o&&o.value,u=(r="string"==typeof h?bT.get(""+h+xy(s)):h||bT.get(Cy(s)))&&r.getGFXTexture(),l=o&&void 0!==o.samplerHash?Ef.unpackFromHash(o.samplerHash):r&&r.getSamplerInfo(),c=this._device.getSampler(l);this._descriptorSet.bindSampler(a,c,i||0),this._descriptorSet.bindTexture(a,u,i||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(){if(S.rendering)for(var t,e=f(this._shaderInfo.descriptors[Og.MATERIAL].samplerTextures);!(t=e()).done;)for(var i=t.value,n=0;n=this._passes.length&&tt(16372,i);var h=this._passes[i];this._uploadProperty(h,t,e)&&(this._props[h.propertyIndex][t]=e,n=!0)}n||tt(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 tt(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}(vd),OT=ja(PT.prototype,"_effectAsset",[BT],(function(){return null})),LT=ja(PT.prototype,"_techIdx",[lo],(function(){return 0})),NT=ja(PT.prototype,"_defines",[lo],(function(){return[]})),FT=ja(PT.prototype,"_states",[lo],(function(){return[]})),kT=ja(PT.prototype,"_props",[lo],(function(){return[]})),MT=PT))||MT));S.Material=zT;var HT=Ee({Low_256x256:256,Medium_512x512:512,High_1024x1024:1024,Ultra_2048x2048:2048}),WT=Ee({Planar:0,ShadowMap:1}),XT=Ee({HARD:0,SOFT:1,SOFT_2X:2,SOFT_4X:3}),jT=Ee({LEVEL_1:1,LEVEL_2:2,LEVEL_3:3,LEVEL_4:4}),YT=Ee({NONE:1,RemoveDuplicates:2,DisableRotationFix:3}),qT=WT.ShadowMap+1,KT=function(){function t(){this.fixedSphere=new Ir(0,0,0,.01),this.maxReceived=4,this._matLight=new Vn,this._material=null,this._instancingMaterial=null,this._enabled=!1,this._type=qT,this._distance=0,this._planeBias=1,this._normal=new gn(0,1,0),this._shadowColor=new En(0,0,0,76),this._size=new jn(1024,1024),this._shadowMapDirty=!1}var e=t.prototype;return e.getPlanarShader=function(t){this._material||(this._material=new zT,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:qT,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=S.director.root;t.pipeline.macros.CC_SHADOW_TYPE=2,t.onGlobalPipelineStateChanged()}else{var e=S.director.root;e.pipeline.macros.CC_SHADOW_TYPE=0,e.onGlobalPipelineStateChanged()}},e._updatePlanarInfo=function(){this._material||(this._material=new zT,this._material.initialize({effectName:"pipeline/planar-shadow"}));var t=S.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:qT,this.activate()}},{key:"normal",get:function(){return this._normal},set:function(t){gn.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}();KT.MAX_FAR=2e3,KT.COEFFICIENT_OF_EXPANSION=2*Math.sqrt(3),S.Shadows=KT;var QT=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);for(var r=0;r0)for(var h=0;h=0&&s.node.getWritableComponents().splice(a,1)}}}function bx(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 v=0;vMath.abs(e)?t:-e},e}(tw),sw=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 rw({positive:i.right,negative:i.left}),i.yAxis=new rw({positive:i.up,negative:i.down}),i}return s(e,t),e.prototype.getValue=function(){return new jn(this.xAxis.getValue(),this.yAxis.getValue())},e}(ew);!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 rw({positive:i.right,negative:i.left}),i.yAxis=new rw({positive:i.up,negative:i.down}),i.zAxis=new rw({positive:i.forward,negative:i.backward}),i}s(e,t),e.prototype.getValue=function(){return new gn(this.xAxis.getValue(),this.yAxis.getValue(),this.zAxis.getValue())}}(iw);var aw,ow=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}(tw),hw=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e}(sw),uw=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e}(sw),lw=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}(nw),cw=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}(iw),_w=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}(tw),fw="left",dw="right",pw=[];!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"}(aw||(aw={}));var mw,gw,vw,yw,Sw,Tw=function(){function t(t){var e;this._deviceId=-1,this._connected=!1,this._webPoseState=((e={})[aw.HAND_LEFT]={position:gn.ZERO,orientation:Bn.IDENTITY},e[aw.HAND_RIGHT]={position:gn.ZERO,orientation:Bn.IDENTITY},e[aw.AIM_LEFT]={position:gn.ZERO,orientation:Bn.IDENTITY},e[aw.AIM_RIGHT]={position:gn.ZERO,orientation:Bn.IDENTITY},e),this._deviceId=t,this._initInputSource()}t._init=function(){Zs.hasFeature(Ks.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&&fe(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(){S.director&&S.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,_=0;_.01){a=t._getOrCreateInputDevice(r.index,!0);break}}if(a){e.push(a);continue}}}}t._cachedWebGamepads=i}}},t._scanGamepads=function(){pw.length=0,t._scanWebGamepads(pw),t._scanWebXRGamepads(pw);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!==aw.HAND_LEFT&&t.code!==aw.AIM_LEFT&&t.code!==aw.HAND_RIGHT&&t.code!==aw.AIM_RIGHT||(this._webPoseState[t.code]={position:new gn(t.position.x,t.position.y,t.position.z),orientation:new Bn(t.orientation.x,t.orientation.y,t.orientation.z,t.orientation.w)})},e._initInputSource=function(){var e=this;this._buttonNorth=new ow,this._buttonNorth.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(fw);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 ow,this._buttonEast.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(dw);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 ow,this._buttonWest.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(fw);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 ow,this._buttonSouth.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(dw);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 ow,this._buttonL1.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[4].value:0},this._buttonL2=new ow,this._buttonL2.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(fw);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 ow,this._buttonL3.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(fw);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 ow,this._buttonR1.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[5].value:0},this._buttonR2=new ow,this._buttonR2.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(dw);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 ow,this._buttonR3.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(dw);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 ow,this._buttonShare.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[8].value:0},this._buttonOptions=new ow,this._buttonOptions.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[9].value:0};var i=new ow;i.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[12].value:0};var n=new ow;n.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[13].value:0};var r=new ow;r.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[14].value:0};var s=new ow;s.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[15].value:0},this._dpad=new hw({up:i,down:n,left:r,right:s});var a=new ow;a.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(fw);if(n){if(n.axes.length>3&&0!==n.axes[3])return e._axisToButtons(n.axes[3]).negative;if(n.axes.length>1&&0!==n.axes[1])return e._axisToButtons(n.axes[1]).negative}return 0}var r=t._getWebGamepad(e.deviceId);return r?e._axisToButtons(r.axes[1]).negative:0};var o=new ow;o.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(fw);if(n){if(n.axes.length>3&&0!==n.axes[3])return e._axisToButtons(n.axes[3]).positive;if(n.axes.length>1&&0!==n.axes[1])return e._axisToButtons(n.axes[1]).positive}return 0}var r=t._getWebGamepad(e.deviceId);return r?e._axisToButtons(r.axes[1]).positive:0};var h=new ow;h.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(fw);if(n){if(n.axes.length>2&&0!==n.axes[2])return e._axisToButtons(n.axes[2]).negative;if(n.axes.length>0&&0!==n.axes[0])return e._axisToButtons(n.axes[0]).negative}return 0}var r=t._getWebGamepad(e.deviceId);return r?e._axisToButtons(r.axes[0]).negative:0};var u=new ow;u.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(fw);if(n){if(n.axes.length>2&&0!==n.axes[2])return e._axisToButtons(n.axes[2]).positive;if(n.axes.length>0&&0!==n.axes[0])return e._axisToButtons(n.axes[0]).positive}return 0}var r=t._getWebGamepad(e.deviceId);return r?e._axisToButtons(r.axes[0]).positive:0},this._leftStick=new uw({up:a,down:o,left:h,right:u});var l=new ow;l.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(dw);if(n){if(n.axes.length>3&&0!==n.axes[3])return e._axisToButtons(n.axes[3]).negative;if(n.axes.length>1&&0!==n.axes[1])return e._axisToButtons(n.axes[1]).negative}return 0}var r=t._getWebGamepad(e.deviceId);return r?e._axisToButtons(r.axes[3]).negative:0};var c=new ow;c.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(dw);if(n){if(n.axes.length>3&&0!==n.axes[3])return e._axisToButtons(n.axes[3]).positive;if(n.axes.length>1&&0!==n.axes[1])return e._axisToButtons(n.axes[1]).positive}return 0}var r=t._getWebGamepad(e.deviceId);return r?e._axisToButtons(r.axes[3]).positive:0};var _=new ow;_.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(dw);if(n){if(n.axes.length>2&&0!==n.axes[2])return e._axisToButtons(n.axes[2]).negative;if(n.axes.length>0&&0!==n.axes[0])return e._axisToButtons(n.axes[0]).negative}return 0}var r=t._getWebGamepad(e.deviceId);return r?e._axisToButtons(r.axes[2]).negative:0};var f=new ow;f.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(dw);if(n){if(n.axes.length>2&&0!==n.axes[2])return e._axisToButtons(n.axes[2]).positive;if(n.axes.length>0&&0!==n.axes[0])return e._axisToButtons(n.axes[0]).positive}return 0}var r=t._getWebGamepad(e.deviceId);return r?e._axisToButtons(r.axes[2]).positive:0},this._rightStick=new uw({up:l,down:c,left:_,right:f}),this._buttonStart=new ow,this._buttonStart.getValue=function(){return 0},this._gripLeft=new ow,this._gripLeft.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(fw);if(n&&n.buttons.length>1)return n.buttons[1].value}return 0},this._gripRight=new ow,this._gripRight.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(dw);if(n&&n.buttons.length>1)return n.buttons[1].value}return 0},this._handLeftPosition=new cw,this._handLeftPosition.getValue=function(){return e._webPoseState[aw.HAND_LEFT].position},this._handLeftOrientation=new lw,this._handLeftOrientation.getValue=function(){return e._webPoseState[aw.HAND_LEFT].orientation},this._handRightPosition=new cw,this._handRightPosition.getValue=function(){return e._webPoseState[aw.HAND_RIGHT].position},this._handRightOrientation=new lw,this._handRightOrientation.getValue=function(){return e._webPoseState[aw.HAND_RIGHT].orientation},this._aimLeftPosition=new cw,this._aimLeftPosition.getValue=function(){return e._webPoseState[aw.AIM_LEFT].position},this._aimLeftOrientation=new lw,this._aimLeftOrientation.getValue=function(){return e._webPoseState[aw.AIM_LEFT].orientation},this._aimRightPosition=new cw,this._aimRightPosition.getValue=function(){return e._webPoseState[aw.AIM_RIGHT].position},this._aimRightOrientation=new lw,this._aimRightOrientation.getValue=function(){return e._webPoseState[aw.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}();Tw.all=[],Tw.xr=null,Tw._eventTarget=new Hs,Tw._cachedWebGamepads=[],Tw._cachedWebXRGamepadMap=null,Tw._intervalId=-1,Tw._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"}(mw||(mw={})),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"}(gw||(gw={})),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"}(vw||(vw={})),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"}(yw||(yw={})),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"}(Sw||(Sw={}));var Aw,bw={1:mw.BUTTON_EAST,2:mw.BUTTON_SOUTH,3:mw.BUTTON_NORTH,4:mw.BUTTON_WEST,9:mw.BUTTON_LEFT_STICK,10:mw.BUTTON_RIGHT_STICK,11:mw.ROKID_MENU,12:mw.ROKID_START,13:mw.BUTTON_TRIGGER_LEFT,14:mw.BUTTON_TRIGGER_RIGHT},Ew=function(){function t(){var t,e,i=this;this._eventTarget=new Hs,this._nativeButtonState=((t={})[mw.BUTTON_SOUTH]=0,t[mw.BUTTON_EAST]=0,t[mw.BUTTON_WEST]=0,t[mw.BUTTON_NORTH]=0,t[mw.BUTTON_TRIGGER_LEFT]=0,t[mw.BUTTON_TRIGGER_RIGHT]=0,t[mw.TRIGGER_LEFT]=0,t[mw.TRIGGER_RIGHT]=0,t[mw.GRIP_LEFT]=0,t[mw.GRIP_RIGHT]=0,t[mw.LEFT_STICK_UP]=0,t[mw.LEFT_STICK_DOWN]=0,t[mw.LEFT_STICK_LEFT]=0,t[mw.LEFT_STICK_RIGHT]=0,t[mw.RIGHT_STICK_UP]=0,t[mw.RIGHT_STICK_DOWN]=0,t[mw.RIGHT_STICK_LEFT]=0,t[mw.RIGHT_STICK_RIGHT]=0,t[mw.BUTTON_LEFT_STICK]=0,t[mw.BUTTON_RIGHT_STICK]=0,t[mw.ROKID_MENU]=0,t[mw.ROKID_START]=0,t),this._nativeTouchState=((e={})[Sw.UNDEFINE]=0,e[Sw.A]=0,e[Sw.B]=0,e[Sw.X]=0,e[Sw.Y]=0,e[Sw.LEFT_TRIGGER]=0,e[Sw.RIGHT_TRIGGER]=0,e[Sw.LEFT_THUMBSTICK]=0,e[Sw.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===gw.KET_CLICK){var l=bw[a];i._nativeButtonState[l]=o?1:0}else if(n===gw.KET_STICK||n===gw.KET_GRAB){var c,_,f;switch(r){case yw.LEFT_STICK_X:c=mw.LEFT_STICK_LEFT,_=mw.LEFT_STICK_RIGHT,f=i._axisToButtons(s);break;case yw.LEFT_STICK_Y:c=mw.LEFT_STICK_DOWN,_=mw.LEFT_STICK_UP,f=i._axisToButtons(s);break;case yw.RIGHT_STICK_X:c=mw.RIGHT_STICK_LEFT,_=mw.RIGHT_STICK_RIGHT,f=i._axisToButtons(s);break;case yw.RIGHT_STICK_Y:c=mw.RIGHT_STICK_DOWN,_=mw.RIGHT_STICK_UP,f=i._axisToButtons(s);break;case yw.L2:i._nativeButtonState[mw.TRIGGER_LEFT]=s;break;case yw.R2:i._nativeButtonState[mw.TRIGGER_RIGHT]=s;break;case yw.LEFT_GRIP:i._nativeButtonState[mw.GRIP_LEFT]=s;break;case yw.RIGHT_GRIP:i._nativeButtonState[mw.GRIP_RIGHT]=s}c&&_&&f&&(i._nativeButtonState[c]=f.negative,i._nativeButtonState[_]=f.positive)}else if(n===gw.KET_TOUCH)switch(h){case Sw.A:case Sw.B:case Sw.X:case Sw.Y:case Sw.LEFT_TRIGGER:case Sw.RIGHT_TRIGGER:case Sw.LEFT_THUMBSTICK:case Sw.RIGHT_THUMBSTICK:i._nativeTouchState[h]=u}i._eventTarget.emit(kx.HANDLE_INPUT,new Yx(kx.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 ow,this._buttonNorth.getValue=function(){return t._nativeButtonState[mw.BUTTON_NORTH]},this._buttonEast=new ow,this._buttonEast.getValue=function(){return t._nativeButtonState[mw.BUTTON_EAST]},this._buttonWest=new ow,this._buttonWest.getValue=function(){return t._nativeButtonState[mw.BUTTON_WEST]},this._buttonSouth=new ow,this._buttonSouth.getValue=function(){return t._nativeButtonState[mw.BUTTON_SOUTH]},this._buttonTriggerLeft=new ow,this._buttonTriggerLeft.getValue=function(){return t._nativeButtonState[mw.BUTTON_TRIGGER_LEFT]},this._buttonTriggerRight=new ow,this._buttonTriggerRight.getValue=function(){return t._nativeButtonState[mw.BUTTON_TRIGGER_RIGHT]},this._triggerLeft=new ow,this._triggerLeft.getValue=function(){return t._nativeButtonState[mw.TRIGGER_LEFT]},this._triggerRight=new ow,this._triggerRight.getValue=function(){return t._nativeButtonState[mw.TRIGGER_RIGHT]},this._gripLeft=new ow,this._gripLeft.getValue=function(){return t._nativeButtonState[mw.GRIP_LEFT]},this._gripRight=new ow,this._gripRight.getValue=function(){return t._nativeButtonState[mw.GRIP_RIGHT]},this._buttonLeftStick=new ow,this._buttonLeftStick.getValue=function(){return t._nativeButtonState[mw.BUTTON_LEFT_STICK]};var e=new ow;e.getValue=function(){return t._nativeButtonState[mw.LEFT_STICK_UP]};var i=new ow;i.getValue=function(){return t._nativeButtonState[mw.LEFT_STICK_DOWN]};var n=new ow;n.getValue=function(){return t._nativeButtonState[mw.LEFT_STICK_LEFT]};var r=new ow;r.getValue=function(){return t._nativeButtonState[mw.LEFT_STICK_RIGHT]},this._leftStick=new uw({up:e,down:i,left:n,right:r}),this._buttonRightStick=new ow,this._buttonRightStick.getValue=function(){return t._nativeButtonState[mw.BUTTON_RIGHT_STICK]};var s=new ow;s.getValue=function(){return t._nativeButtonState[mw.RIGHT_STICK_UP]};var a=new ow;a.getValue=function(){return t._nativeButtonState[mw.RIGHT_STICK_DOWN]};var o=new ow;o.getValue=function(){return t._nativeButtonState[mw.RIGHT_STICK_LEFT]};var h=new ow;h.getValue=function(){return t._nativeButtonState[mw.RIGHT_STICK_RIGHT]},this._rightStick=new uw({up:s,down:a,left:o,right:h}),this._buttonOptions=new ow,this._buttonOptions.getValue=function(){return t._nativeButtonState[mw.ROKID_MENU]},this._buttonStart=new ow,this._buttonStart.getValue=function(){return t._nativeButtonState[mw.ROKID_START]},this._handLeftPosition=new cw,this._handLeftPosition.getValue=function(){return gn.ZERO},this._handLeftOrientation=new lw,this._handLeftOrientation.getValue=function(){return Bn.IDENTITY},this._handRightPosition=new cw,this._handRightPosition.getValue=function(){return gn.ZERO},this._handRightOrientation=new lw,this._handRightOrientation.getValue=function(){return Bn.IDENTITY},this._aimLeftPosition=new cw,this._aimLeftPosition.getValue=function(){return gn.ZERO},this._aimLeftOrientation=new lw,this._aimLeftOrientation.getValue=function(){return Bn.IDENTITY},this._aimRightPosition=new cw,this._aimRightPosition.getValue=function(){return gn.ZERO},this._aimRightOrientation=new lw,this._aimRightOrientation.getValue=function(){return Bn.IDENTITY},this._touchButtonA=new _w,this._touchButtonA.getValue=function(){return t._nativeTouchState[Sw.A]},this._touchButtonB=new _w,this._touchButtonB.getValue=function(){return t._nativeTouchState[Sw.B]},this._touchButtonX=new _w,this._touchButtonX.getValue=function(){return t._nativeTouchState[Sw.X]},this._touchButtonY=new _w,this._touchButtonY.getValue=function(){return t._nativeTouchState[Sw.Y]},this._touchButtonTriggerLeft=new _w,this._touchButtonTriggerLeft.getValue=function(){return t._nativeTouchState[Sw.LEFT_TRIGGER]},this._touchButtonTriggerRight=new _w,this._touchButtonTriggerRight.getValue=function(){return t._nativeTouchState[Sw.RIGHT_TRIGGER]},this._touchButtonThumbStickLeft=new _w,this._touchButtonThumbStickLeft.getValue=function(){return t._nativeTouchState[Sw.LEFT_THUMBSTICK]},this._touchButtonThumbStickRight=new _w,this._touchButtonThumbStickRight.getValue=function(){return t._nativeTouchState[Sw.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"}(Aw||(Aw={}));var Cw,xw,ww=function(){function t(){var t;this._eventTarget=new Hs,this._intervalId=-1,this._webPoseState=((t={})[Aw.VIEW_LEFT]={position:gn.ZERO,orientation:Bn.IDENTITY},t[Aw.VIEW_RIGHT]={position:gn.ZERO,orientation:Bn.IDENTITY},t[Aw.HEAD_MIDDLE]={position:gn.ZERO,orientation:Bn.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(){S.director&&S.Director&&(clearInterval(t._intervalId),t._intervalId=-1,e())}),50)}))},e._registerEvent=function(){var t=this;this._ensureDirectorDefined().then((function(){S.director.on(S.Director.EVENT_BEGIN_FRAME,t._scanHmd,t)})).catch((function(){}))},e._scanHmd=function(){var t,e=null===(t=globalThis.__globalXR)||void 0===t?void 0:t.webxrHmdPoseInfos;if(e){for(var i=0;iPe.TOUCH_TIMEOUT&&(U("The touches is more than MAX_TOUCHES, release touch id "+t.getID()+"."),e.releaseTouch(t.getID()))})),i>=this._touchMap.size},t}()),Ow=function(){function t(){this._canvas=void 0,this._eventTarget=new Hs,Zs.hasFeature(Ks.INPUT_TOUCH)&&(this._canvas=document.getElementById("GameCanvas"),this._canvas||z("failed to access canvas"),this._registerEvent())}var e=t.prototype;return e._registerEvent=function(){var t,e,i,n;null===(t=this._canvas)||void 0===t||t.addEventListener("touchstart",this._createCallback(kx.TOUCH_START)),null===(e=this._canvas)||void 0===e||e.addEventListener("touchmove",this._createCallback(kx.TOUCH_MOVE)),null===(i=this._canvas)||void 0===i||i.addEventListener("touchend",this._createCallback(kx.TOUCH_END)),null===(n=this._canvas)||void 0===n||n.addEventListener("touchcancel",this._createCallback(kx.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 _=new Wx(s,!1,t,Pw.getAllTouches());e._eventTarget.emit(t,_)}}},e._getCanvasRect=function(){var t=this._canvas,e=null==t?void 0:t.getBoundingClientRect();return e?new Jn(e.x,e.y,e.width,e.height):new Jn(0,0,0,0)},e._getLocation=function(t,e){if(globalThis.__globalXR&&globalThis.__globalXR.ar&&globalThis.__globalXR.ar.isWebXR())return new jn(t.clientX,t.clientY);var i=t.clientX-e.x,n=e.y+e.height-t.clientY;if(ga.isFrameRotated){var r=i;i=e.height-n,n=r}var s=ga.devicePixelRatio;return new jn(i*=s,n*=s)},e.on=function(t,e,i){this._eventTarget.on(t,e,i)},t}();!function(t){t[t.GLOBAL=0]="GLOBAL",t[t.UI=1]="UI"}(xw||(xw={}));var Lw=function(){function t(t){this.priority=xw.GLOBAL,this._inputEventTarget=t}var e=t.prototype;return e.onThrowException=function(){},e.dispatchEvent=function(t){return this._inputEventTarget.emit(t.type,t),!0},t}(),Nw=((Cw={})[kx.MOUSE_DOWN]=kx.TOUCH_START,Cw[kx.MOUSE_MOVE]=kx.TOUCH_MOVE,Cw[kx.MOUSE_UP]=kx.TOUCH_END,Cw),Fw=t("ey",function(){function t(){this._dispatchImmediately=!0,this._eventTarget=new Hs,this._touchInput=new Ow,this._mouseInput=new Bw,this._keyboardInput=new Dw,this._accelerometerInput=new Jx,this._handleInput=new Ew,this._hmdInput=new ww,this._handheldInput=new Rw,this._eventTouchList=[],this._eventMouseList=[],this._eventKeyboardList=[],this._eventAccelerationList=[],this._eventGamepadList=[],this._eventHandleList=[],this._eventHMDList=[],this._eventHandheldList=[],this._needSimulateTouchMoveEvent=!1,this._eventDispatcherList=[],this._registerEvent(),this._inputEventDispatcher=new Lw(this._eventTarget),this._registerEventDispatcher(this._inputEventDispatcher),Tw._init()}var e=t.prototype;return e._dispatchMouseDownEvent=function(t){var e,i;null===(e=(i=this._mouseInput).dispatchMouseDownEvent)||void 0===e||e.call(i,t)},e._dispatchMouseMoveEvent=function(t){var e,i;null===(e=(i=this._mouseInput).dispatchMouseMoveEvent)||void 0===e||e.call(i,t)},e._dispatchMouseUpEvent=function(t){var e,i;null===(e=(i=this._mouseInput).dispatchMouseUpEvent)||void 0===e||e.call(i,t)},e._dispatchMouseScrollEvent=function(t){var e,i;null===(e=(i=this._mouseInput).dispatchScrollEvent)||void 0===e||e.call(i,t)},e._dispatchKeyboardDownEvent=function(t){var e,i;null===(e=(i=this._keyboardInput).dispatchKeyboardDownEvent)||void 0===e||e.call(i,t)},e._dispatchKeyboardUpEvent=function(t){var e,i;null===(e=(i=this._keyboardInput).dispatchKeyboardUpEvent)||void 0===e||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 Pw.getTouch(t)},e.getAllTouches=function(){return Pw.getAllTouches()},e.getTouchCount=function(){return Pw.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=Nw[t.type],i=Pw.getOrCreateTouch(0,t.getLocationX(),t.getLocationY());if(i){var n=[i],r=new Wx(n,!1,e,e===kx.TOUCH_END?[]:n);r.windowId=t.windowId,e===kx.TOUCH_END&&Pw.releaseTouch(0),this._dispatchOrPushEventTouch(r,this._eventTouchList)}},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?it(12004,8):(this._passes=t,this._flushPassInfo(),this._descriptorSet&&(this._descriptorSet.destroy(),aR.layout=t[0].localSetLayout,this._descriptorSet=this._device.createDescriptorSet(aR)))}},{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}(),hR=new E_;hR.format=ec.RGBA8;var uR=new C_;uR.format=ec.DEPTH_STENCIL;var lR,cR,_R=new R_([hR],uR),fR={width:1,height:1,renderPassInfo:_R},dR=t("e6",eo("cc.RenderTexture")(Qw=function(t){function e(){var e;return(e=t.call(this)||this)._window=null,e}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=S.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(Fi(t,1,2048)),this._height=Math.floor(Fi(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=S.director.root;fR.title=this._name,fR.width=this._width,fR.height=this._height,fR.renderPassInfo=t&&t.passInfo?t.passInfo:_R,fR.externalResLow=t&&t.externalResLow?t.externalResLow:0,fR.externalResHigh=t&&t.externalResHigh?t.externalResHigh:0,fR.externalFlag=t&&t.externalFlag?t.externalFlag:lc.NONE,fR.renderPassInfo.colorAttachments.forEach((function(t){t.format=e.device.swapchainFormat})),hR.barrier=Ff.gfxDevice.getGeneralBarrier(new I_(Ec.FRAGMENT_SHADER_READ_TEXTURE,Ec.FRAGMENT_SHADER_READ_TEXTURE)),this._window?(this._window.destroy(),this._window.initialize(Ff.gfxDevice,fR)):this._window=e.createWindow(fR)},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 it(7606),null;var a=4*i*n;if(void 0===r)r=new Uint8Array(a);else if(r.length=0?o.updateInstancedWorldMatrix(r,h):s=!0}(s||n)&&this._localBuffer&&(Vn.toArray(this._localData,r,ev.MAT_WORLD_OFFSET),Vn.invert(yR,r),Vn.transpose(yR,yR),Vn.toArray(this._localData,yR,ev.MAT_WORLD_IT_OFFSET),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=S.director.root.pipeline.pipelineSceneData.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;t1?wR:xR),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}!function(t){t[t.DIRECTIONAL=0]="DIRECTIONAL",t[t.SPHERE=1]="SPHERE",t[t.SPOT=2]="SPOT",t[t.POINT=3]="POINT",t[t.RANGED_DIRECTIONAL=4]="RANGED_DIRECTIONAL",t[t.UNKNOWN=5]="UNKNOWN"}(CR||(CR={}));var MR,PR,OR=function(t){return 4*Math.PI*Math.PI*t*t},LR=function(){function t(){this._baked=!1,this._color=new gn(1,1,1),this._colorTemp=6550,this._colorTempRGB=new gn(1,1,1),this._finalColor=new gn(1,1,1),this._scene=null,this._node=null,this._name=null,this._useColorTemperature=!1,this._type=CR.UNKNOWN,this._visibility=sy}var e=t.prototype;return e.initialize=function(){this.color=new gn(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&&gn.multiply(this._finalColor,this._color,this._colorTempRGB)}},{key:"useColorTemperature",get:function(){return this._useColorTemperature},set:function(t){this._useColorTemperature=t,t&&gn.multiply(this._finalColor,this._color,this._colorTempRGB)}},{key:"colorTemperature",get:function(){return this._colorTemp},set:function(t){this._colorTemp=t,BR(this._colorTempRGB,this._colorTemp),this._useColorTemperature&&gn.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|=mm.ROTATION)}},{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}(),NR=new gn(0,0,-1),FR=new gn,kR=function(t){function e(){var e;return(e=t.call(this)||this)._dir=new gn(1,-1,-1),e._illuminanceHDR=wg.SUN_ILLUM,e._illuminanceLDR=1,e._shadowEnabled=!1,e._shadowPcf=XT.HARD,e._shadowBias=1e-5,e._shadowNormalBias=0,e._shadowSaturation=1,e._shadowDistance=50,e._shadowInvisibleOcclusionRange=200,e._csmLevel=jT.LEVEL_4,e._csmNeedUpdate=!1,e._csmLayerLambda=.75,e._csmOptimizationMode=YT.DisableRotationFix,e._csmLayersTransition=!1,e._csmTransitionRange=.05,e._shadowFixedArea=!1,e._shadowNear=.1,e._shadowFar=10,e._shadowOrthoSize=5,e._type=CR.DIRECTIONAL,e}s(e,t);var i=e.prototype;return i.initialize=function(){t.prototype.initialize.call(this),this.illuminance=wg.SUN_ILLUM,this.direction=new gn(1,-1,-1)},i.update=function(){this._node&&this._node.hasChangedFlags&&(this.direction=gn.transformQuat(FR,NR,this._node.worldRotation))},i.activate=function(){var t=S.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){gn.normalize(this._dir,t)}},{key:"illuminance",get:function(){return S.director.root.pipeline.pipelineSceneData.isHDR?this._illuminanceHDR:this._illuminanceLDR},set:function(t){S.director.root.pipeline.pipelineSceneData.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,KT.MAX_FAR)}},{key:"shadowInvisibleOcclusionRange",get:function(){return this._shadowInvisibleOcclusionRange},set:function(t){this._shadowInvisibleOcclusionRange=Math.min(t,KT.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,KT.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}(LR),GR=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 gn,e._aabb=Ra.create(),e._type=CR.SPHERE,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/OR(.15),this.luminanceLDR=1},i.update=function(){if(this._node&&(this._node.hasChangedFlags||this._needUpdate)){this._node.getWorldPosition(this._pos);var t=this._range;Ra.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 S.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR:this._luminanceLDR},set:function(t){S.director.root.pipeline.pipelineSceneData.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}(LR),VR=new gn(0,0,-1),UR=new Bn,zR=new Vn,HR=new Vn,WR=new Vn,XR=new Vn,jR=function(t){function e(){var e;return(e=t.call(this)||this)._dir=new gn(1,-1,-1),e._range=5,e._spotAngle=Math.cos(Math.PI/6),e._angleAttenuationStrength=0,e._pos=new gn,e._aabb=Ra.create(),e._frustum=La.create(),e._angle=0,e._needUpdate=!1,e._size=.15,e._luminanceHDR=0,e._luminanceLDR=0,e._shadowEnabled=!1,e._shadowPcf=XT.HARD,e._shadowBias=1e-5,e._shadowNormalBias=0,e._type=CR.SPOT,e}s(e,t);var i=e.prototype;return i.initialize=function(){t.prototype.initialize.call(this),this.size=.15,this.luminanceHDR=1700/OR(.15),this.luminanceLDR=1,this.range=Math.cos(Math.PI/6),this._dir.set(new gn(1,-1,-1))},i.update=function(){this._node&&(this._node.hasChangedFlags||this._needUpdate)&&(this._node.getWorldPosition(this._pos),gn.transformQuat(this._dir,VR,this._node.getWorldRotation(UR)),gn.normalize(this._dir,this._dir),Ra.set(this._aabb,this._pos.x,this._pos.y,this._pos.z,this._range,this._range,this._range),this._node.getWorldRT(zR),Vn.invert(zR,zR),Vn.perspective(HR,this._angle,1,.001,this._range),Vn.multiply(WR,HR,zR),this._frustum.update(WR,XR),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 S.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR:this._luminanceLDR},set:function(t){S.director.root.pipeline.pipelineSceneData.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}(LR),YR=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=new gn,e._aabb=Ra.create(),e._type=CR.POINT,e}s(e,t);var i=e.prototype;return i.initialize=function(){t.prototype.initialize.call(this),this.range=1,this.luminanceHDR=1700/OR(1),this.luminanceLDR=1},i.update=function(){if(this._node&&(this._node.hasChangedFlags||this._needUpdate)){this._node.getWorldPosition(this._pos);var t=this._range;Ra.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 S.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR:this._luminanceLDR},set:function(t){S.director.root.pipeline.pipelineSceneData.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}(LR),qR=new gn(0,0,-1),KR=function(t){function e(){var e;return(e=t.call(this)||this)._dir=new gn(0,0,-1),e._pos=new gn(0,0,0),e._scale=new gn(1,1,1),e._right=new gn(1,0,0),e._illuminanceHDR=wg.SUN_ILLUM,e._illuminanceLDR=1,e._type=CR.RANGED_DIRECTIONAL,e}s(e,t);var i=e.prototype;return i.initialize=function(){t.prototype.initialize.call(this),this.illuminance=wg.SUN_ILLUM},i.update=function(){this._node&&this._node.hasChangedFlags&&(this._node.getWorldPosition(this._pos),this._node.getWorldScale(this._scale),gn.transformQuat(this._dir,qR,this._node.worldRotation),gn.transformQuat(this._right,gn.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 S.director.root.pipeline.pipelineSceneData.isHDR?this._illuminanceHDR:this._illuminanceLDR},set:function(t){S.director.root.pipeline.pipelineSceneData.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}(LR),QR=function(){function t(){this.screenUsagePercentage=1,this._models=[]}var e=t.prototype;return e.addModel=function(t){this._models.splice(0,0,t)},e.eraseModel=function(t){var e=this._models.indexOf(t);e>=0&&this._models.splice(e,1)},e.clearModels=function(){this._models.length=0},n(t,[{key:"models",get:function(){return this._models}}]),t}(),ZR=function(){function t(){this.scene=void 0,this.node=null,this.enabled=!0,this._localBoundaryCenter=new gn(0,0,0),this._objectSize=1,this._lodDataArray=[],this._lockedLODLevelVec=[],this._isLockLevelChanged=!1,this._device=Ff.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?(t.projectionType===zw.PERSPECTIVE&&(e=gn.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 t.projectionType===zw.PERSPECTIVE?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}(),JR=Object.freeze({__proto__:null,get CameraFOVAxis(){return Uw},get CameraProjection(){return zw},get CameraAperture(){return Hw},get CameraISO(){return Ww},get CameraShutter(){return Xw},get CameraType(){return jw},get TrackingType(){return Yw},get CameraUsage(){return qw},SKYBOX_FLAG:nR,Camera:sR,get ModelType(){return vR},Model:RR,SubModel:oR,Ambient:wg,EnvironmentLightingType:tA,Skybox:eA,ShadowSize:HT,ShadowType:WT,PCFType:XT,CSMLevel:jT,CSMOptimizationMode:YT,Shadows:KT,FogType:nA,FOG_TYPE_NONE:rA,Fog:sA,Octree:IR,Skin:DR,ColorTemperatureToRGB:BR,get LightType(){return CR},nt2lm:OR,Light:LR,DirectionalLight:kR,SphereLight:GR,SpotLight:jR,PointLight:YR,RangedDirectionalLight:KR,get ProbeClearFlag(){return lR},get ProbeType(){return cR},ReflectionProbe:gR,LODData:QR,LODGroup:ZR,ToneMappingType:RE,PostSettings:IE}),$R=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 eI(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(){for(var t,e=f(this._lodGroups);!(t=e()).done;){var i=t.value;this._lodStateCache.removeLodGroup(i)}this._lodGroups.length=0},e.onGlobalPipelineStateChanged=function(){for(var t,e=f(this._models);!(t=e()).done;)t.value.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}(),tI=function(){this.usedLevel=-1,this.lastUsedLevel=-1,this.transformDirty=!0},eI=function(){function t(t){this._renderScene=null,this._modelsInLODGroup=new Map,this._lodStateInCamera=new Map,this._newAddedLodGroupVec=new Array,this._levelModels=new Map,this._renderScene=t}var e=t.prototype;return e.addCamera=function(t){for(var e,i=f(this._renderScene.lodGroups);!(e=i()).done;){var n=e.value.node.layer;if((t.visibility&n)===n){this._lodStateInCamera.has(t)||this._lodStateInCamera.set(t,new Map);break}}},e.removeCamera=function(t){this._lodStateInCamera.has(t)&&this._lodStateInCamera.delete(t)},e.addLodGroup=function(t){this._newAddedLodGroupVec.push(t);for(var e,i=f(this._renderScene.cameras);!(e=i()).done;){var n=e.value;if(!this._lodStateInCamera.has(n)){var r=t.node.layer;(n.visibility&r)===r&&this._lodStateInCamera.set(n,new Map)}}},e.removeLodGroup=function(t){for(var e=0;e0){if(t.node.hasChangedFlags>0)for(var n,r=f(e._lodStateInCamera);!(n=r()).done;){var s=n.value,a=s[1].get(t);a||(a=new tI,s[1].set(t,a)),a.transformDirty=!0}if(t.isLockLevelChanged()){t.resetLockChangeFlag();var o=e._levelModels.get(t);if(o){o.forEach((function(t){t.forEach((function(t){var i=e._modelsInLODGroup.get(t);i&&i.clear()}))}));for(var h,u=f(i);!(h=u()).done;){var l=h.value,_=o.get(l);_&&_.forEach((function(t){var i=e._modelsInLODGroup.get(t);if(i&&t.node&&t.node.active)for(var n,r=f(e._lodStateInCamera);!(n=r()).done;){var s=n.value;i.set(s[0],!0)}}))}}}return 0}for(var d,p=!1,m=f(e._lodStateInCamera);!(d=m()).done;){var g=d.value,v=g[1].get(t);v||(v=new tI,g[1].set(t,v));var y=g[0].node.hasChangedFlags,S=t.node.hasChangedFlags;if(y>0||S>0||v.transformDirty){v.transformDirty&&(v.transformDirty=!1);var T=t.getVisibleLODLevel(g[0]);T!==v.usedLevel&&(v.lastUsedLevel=v.usedLevel,v.usedLevel=T,p=!0)}}var A=e._levelModels.get(t);if(!A)return 0;t.isLockLevelChanged()?(t.resetLockChangeFlag(),A.forEach((function(t){t.forEach((function(t){var i=e._modelsInLODGroup.get(t);i&&i.clear()}))})),p=!0):p&&e._lodStateInCamera.forEach((function(i){var n=i.get(t);if(n&&n.usedLevel!==n.lastUsedLevel){var r=A.get(n.lastUsedLevel);r&&r.forEach((function(t){var i=e._modelsInLODGroup.get(t);i&&i.clear()}))}})),p&&e._lodStateInCamera.forEach((function(i,n){var r=i.get(t);if(r){var s=r.usedLevel,a=A.get(s);a&&a.forEach((function(t){var i=e._modelsInLODGroup.get(t);i&&t.node&&t.node.active&&i.set(n,!0)}))}}))}},d=f(this._renderScene.lodGroups);!(c=d()).done;)_()},e.isLodModelCulled=function(t,e){var i=this._modelsInLODGroup.get(e);return!!i&&!i.has(t)},e.clearCache=function(){this._levelModels.clear(),this._modelsInLODGroup.clear(),this._lodStateInCamera.clear(),this._newAddedLodGroupVec.length=0},e.isLodGroupVisibleByCamera=function(t,e){var i=t.node.layer;return(e.visibility&i)===i},t}(),iI=((MR={})[Be.PORTRAIT]=$l.IDENTITY,MR[Be.LANDSCAPE_RIGHT]=$l.ROTATE_90,MR[Be.PORTRAIT_UPSIDE_DOWN]=$l.ROTATE_180,MR[Be.LANDSCAPE_LEFT]=$l.ROTATE_270,MR),nI=0,rI=function(){var t=e.prototype;function e(){this._title="",this._width=1,this._height=1,this._swapchain=null,this._renderPass=null,this._colorTextures=[],this._depthStencilTexture=null,this._cameras=[],this._hasOnScreenAttachments=!1,this._hasOffScreenAttachments=!1,this._framebuffer=null,this._device=null,this._renderWindowId=nI++,this._isResized=!0,this._colorName="Color"+this._renderWindowId,this._depthStencilName="DepthStencil"+this._renderWindowId}return t.isRenderWindowResized=function(){return this._isResized},t.setRenderWindowResizeHandled=function(){this._isResized=!1},e.registerCreateFunc=function(t){t._createWindowFun=function(){return new e}},t.initialize=function(t,e){if(void 0!==e.title&&(this._title=e.title),void 0!==e.swapchain&&(this._swapchain=e.swapchain),this._width=e.width,this._height=e.height,this._device=t,this._renderPass=t.createRenderPass(e.renderPassInfo),e.swapchain)this._swapchain=e.swapchain,this._colorTextures.push(e.swapchain.colorTexture),this._depthStencilTexture=e.swapchain.depthStencilTexture;else{for(var i=0;i1&&(this._fps=this._frameCount,this._frameCount=0,this._fpsTime=0),null!==(e=globalThis.__globalXR)&&void 0!==e&&e.isWebXR?this._doWebXRFrameMove():(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;e=0;g--){var v=i[g];(a===sI.LEFT&&v.cameraType===jw.RIGHT_EYE||a===sI.RIGHT&&v.cameraType===jw.LEFT_EYE)&&i.splice(g,1)}this._frameMoveEnd()}}},e._frameMoveBegin=function(){for(var t=0;t0){this._device.acquire([Ff.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,this._fixedFPSFrameTime=1e3/t):this._fixedFPSFrameTime=0}},{key:"dataPoolManager",get:function(){return this._dataPoolMgr}},{key:"useDeferredPipeline",get:function(){return this._useDeferredPipeline}},{key:"cameraList",get:function(){return this._cameraList}}]),t}());S.Root=uI,Ci.Attr.setClassAttr(fp,"target","type","Object"),Ci.Attr.setClassAttr(fp,"target","ctor",hg);var lI,cI=new ws((function(){return new Array(16)}),3),_I=null,fI=new jn,dI=[vm.TOUCH_START,vm.TOUCH_MOVE,vm.TOUCH_END,vm.TOUCH_CANCEL],pI=[vm.MOUSE_DOWN,vm.MOUSE_ENTER,vm.MOUSE_MOVE,vm.MOUSE_LEAVE,vm.MOUSE_UP,vm.MOUSE_WHEEL];!function(t){t[t.ADD_POINTER_EVENT_PROCESSOR=0]="ADD_POINTER_EVENT_PROCESSOR",t[t.REMOVE_POINTER_EVENT_PROCESSOR=1]="REMOVE_POINTER_EVENT_PROCESSOR",t[t.MARK_LIST_DIRTY=2]="MARK_LIST_DIRTY"}(lI||(lI={}));var mI,gI=function(){function t(t){this.claimedTouchIdList=[],this.maskList=null,this.cachedCameraPriority=0,this.previousMouseIn=!1,this.bubblingTarget=null,this.capturingTarget=null,this.shouldHandleEventMouse=!1,this.shouldHandleEventTouch=!1,this._dispatchingTouch=null,this._isEnabled=!1,this._isMouseLeaveWindow=!1,this._node=t}var e=t.prototype;return e.setEnabled=function(e,i){if(void 0===i&&(i=!1),this._isEnabled!==e){this._isEnabled=e;var n=this.node.children;if(e&&this._attachMask(),t.callbacksInvoker.emit(lI.MARK_LIST_DIRTY),i&&n.length>0)for(var r=0;r=0;--n)if((e=r[n]).eventProcessor.capturingTarget&&(t.currentTarget=e,e.eventProcessor.capturingTarget.emit(t.type,t,r),t.propagationStopped))return void cI.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!==dI.indexOf(t)},e._isMouseEvent=function(t){return-1!==pI.indexOf(t)},e._hasTouchListeners=function(){for(var t=0;t>>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(RI),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(RI),this._invoke(e),e.array.length=0)},e}(wI),DI=function(t){function e(){return t.apply(this,arguments)||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=CI(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=CI(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}(wI);function BI(t,e,i){var n="var a=it.array;for(it.i=0;it.i=0?AI(this._deferredComps,e):(!t.internalStart||t._objFlags&bI||this.startInvoker.remove(t),t.internalUpdate&&this.updateInvoker.remove(t),t.internalLateUpdate&&this.lateUpdateInvoker.remove(t))},e.enableComp=function(t,e){if(!(t._objFlags&EI)){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&EI&&(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&bI||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=JI+this.globalVariables.join(",")+";");var n=Kl(["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 hg,this.data.name="(Missing Node)";var i=new S._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;xx(t),Ex(t)},e}(vd)).OptimizationPolicy=pD,_D.OptimizationPolicyThreshold=3,uD=ja((hD=_D).prototype,"data",[lo],(function(){return null})),lD=ja(hD.prototype,"optimizationPolicy",[lo],(function(){return pD.AUTO})),cD=ja(hD.prototype,"persistent",[lo],(function(){return!1})),oD=hD))||oD);Bt(mD,"_utils",Ox),S.Prefab=mD,Ft(S,"cc._Prefab","Prefab");var gD=new(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,fe(this._allRenderers,e),t._internalId=-1,t._dirtyVersion===this._dirtyVersion&&(pe(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:SD,_map:u}}else r=e[0]}i&&i(t,r)}))},e.getXMLHttpRequest=function(){return new XMLHttpRequest},e.getItem=function(t){return vT.assets.has(t)?{content:vT.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=ia(t);h&&!yS.getInfoWithPath(t,s)&&(t=t.slice(0,-h.length)),yS.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=ia(e);n&&!yS.getInfoWithPath(e,s)&&(t[i]=e.slice(0,-n.length))})),yS.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;yS.loadDir(t,s,a,(function(e,i){var n=[];e||(n=yS.getDirWithPath(t,s).map((function(t){return t.path}))),o&&o(e,i,n)}))},e.getRes=function(t,e){return Wf.has(t)?Wf.get(t):yS.get(t,e)},e.getResCount=function(){return Wf.count},e.getDependsRecursively=function(t){if(!t)return[];var e="string"==typeof t?t:t._uuid;return em.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();zS.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();oT.register(e)},e.release=function(t){if(Array.isArray(t))for(var e=0;ev.x?e[T]:v.x,v.y=e[T+1]>v.y?e[T+1]:v.y,y.x=e[T]v.x?e[T]:v.x,v.y=e[T+1]>v.y?e[T+1]:v.y,v.z=e[T+2]>v.z?e[T+2]:v.z,y.x=e[T]1&&t.csmOptimizationMode===YT.RemoveDuplicates)if(this._level>=h-1)eB=this._castLightViewBoundingBox.halfExtents.z,tB=this._castLightViewBoundingBox.center.z;else{var u=Math.abs(this._castLightViewBoundingBox.center.z-tB)+eB;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($D.set(c.x,c.y,c.z+l+r),gn.transformMat4($D,$D,VD),Vn.fromRT(VD,t.node.rotation,$D),Vn.invert(UD,VD),!i){var _=.5*s,f=.5*a;Vn.ortho(zD,-_,_,-f,f,.1,this._shadowCameraFar,n.capabilities.clipSpaceMinZ,n.capabilities.clipSpaceSignY),Vn.multiply(WD,zD,o),gn.transformMat4(YD,$D,WD);var d=2/e;qD.set(d,d);var p=YD.x%qD.x,m=YD.y%qD.y;KD.set(YD.x-p,YD.y-m,YD.z),Vn.invert(XD,WD),gn.transformMat4(QD,KD,XD),Vn.fromRT(VD,t.node.rotation,QD),Vn.invert(UD,VD),Vn.multiply(HD,zD,UD),Vn.copy(this._matShadowView,UD),Vn.copy(this._matShadowProj,zD),Vn.copy(this._matShadowViewProj,HD)}La.createOrtho(this._validFrustum,s,a,.1,this._shadowCameraFar,VD)},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}(),nB=function(t){function e(e){var i;return(i=t.call(this,e)||this)._splitCameraNear=0,i._splitCameraFar=0,i._csmAtlas=new cn,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=S.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}(iB),rB=function(){function t(){this._castShadowObjects=[],this._layerObjects=new Is(64),this._layers=[],this._levelCount=0,this._specialLayer=new iB(1),this._shadowDistance=0;for(var t=0;t1?.5*i.size.x:i.size.x;if(!(r<0)){this._getCameraWorldMatrix(GD,t);for(var s=n-1;s>=0;s--){var a=this._layers[s],o=a.splitCameraNear,h=a.splitCameraFar;a.calculateSplitFrustum(t,GD,o,h),a.createMatrix(e,r,!1)}n===jT.LEVEL_1?(this._specialLayer.shadowCameraFar=this._layers[0].shadowCameraFar,Vn.copy(this._specialLayer.matShadowView,this._layers[0].matShadowView),Vn.copy(this._specialLayer.matShadowProj,this._layers[0].matShadowProj),Vn.copy(this._specialLayer.matShadowViewProj,this._layers[0].matShadowViewProj),this._specialLayer.copyToValidFrustum(this._layers[0].validFrustum)):(this._specialLayer.calculateSplitFrustum(t,GD,.1,e.shadowDistance),this._specialLayer.createMatrix(e,r,!0))}},e._getCameraWorldMatrix=function(t,e){if(e.node){var i=e.node,n=i.getWorldPosition(),r=i.getWorldRotation();Vn.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}(),sB=t("dd",function(){function t(){this.fog=new sA,this.ambient=new wg,this.skybox=new eA,this.shadows=new KT,this.csmLayers=new rB,this.octree=new IR,this.skin=new DR,this.postSettings=new IE,this.lightProbes=S.internal.LightProbes?new S.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=0;e<6;e++){this._geometryRendererMaterials[e]=new zT,this._geometryRendererMaterials[e]._uuid="geometry-renderer-material-"+e,this._geometryRendererMaterials[e].initialize({effectName:"internal/builtin-geometry-renderer",technique:e});for(var i=0;i0&&(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)||void 0===t||t.destroy(),this._occlusionQueryInputAssembler=null,null===(e=this._occlusionQueryVertexBuffer)||void 0===e||e.destroy(),this._occlusionQueryVertexBuffer=null,null===(i=this._occlusionQueryIndicesBuffer)||void 0===i||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]),i=3*Float32Array.BYTES_PER_ELEMENT,n=8*i;this._occlusionQueryVertexBuffer=t.createBuffer(new r_(rc.VERTEX|rc.TRANSFER_DST,oc.DEVICE,n,i)),this._occlusionQueryVertexBuffer.update(e);var r=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]),s=Uint16Array.BYTES_PER_ELEMENT,a=36*s;this._occlusionQueryIndicesBuffer=t.createBuffer(new r_(rc.INDEX|rc.TRANSFER_DST,oc.DEVICE,a,s)),this._occlusionQueryIndicesBuffer.update(r);var o=[new T_("a_position",ec.RGB32F)],h=new b_(o,[this._occlusionQueryVertexBuffer],this._occlusionQueryIndicesBuffer);return t.createInputAssembler(h)},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}()),aB=Zn(),oB=((kD={})[Pe.ORIENTATION_AUTO]=Be.AUTO,kD[Pe.ORIENTATION_LANDSCAPE]=Be.LANDSCAPE,kD[Pe.ORIENTATION_PORTRAIT]=Be.PORTRAIT,kD),hB=t("h2",function(t){function e(){var e;(e=t.call(this)||this)._designResolutionSize=Zn(0,0),e._scaleX=1,e._scaleY=1,e._viewportRect=$n(),e._visibleRect=$n(),e._autoFullScreen=!1,e._retinaEnabled=!1,e._resizeCallback=null;var i=uB,n=lB;return e._rpExactFit=new vB(i.EQUAL_TO_FRAME,n.EXACT_FIT),e._rpShowAll=new vB(i.EQUAL_TO_FRAME,n.SHOW_ALL),e._rpNoBorder=new vB(i.EQUAL_TO_FRAME,n.NO_BORDER),e._rpFixedHeight=new vB(i.EQUAL_TO_FRAME,n.FIXED_HEIGHT),e._rpFixedWidth=new vB(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=ya.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,aB.width=this._visibleRect.width,aB.height=this._visibleRect.height,Ta&&Ta.init(this._visibleRect),this.resizeWithBrowserSize(!0);var n=Me.querySettings(De.Category.SCREEN,"designResolution");n&&this.setDesignResolutionSize(Number(n.width),Number(n.height),n.policy||vB.FIXED_HEIGHT),ya.on("window-resize",this._updateAdaptResult,this),ya.on("fullscreen-change",this._updateAdaptResult,this)},i.resizeWithBrowserSize=function(t){ga.handleResizeEvent=t},i.setResizeCallback=function(t){"function"!=typeof t&&null!=t||(this._resizeCallback=t)},i.setOrientation=function(t){ga.orientation=oB[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&&ya.requestFullScreen().catch((function(){})))},i.isAutoFullScreenEnabled=function(){return this._autoFullScreen},i.setCanvasSize=function(t,e){ga.resolutionScale=1;var i=ga.devicePixelRatio,n=new Qn(t*i,e*i);ya.windowSize=n},i.getCanvasSize=function(){return ya.windowSize},i.getFrameSize=function(){var t=ga.devicePixelRatio,e=ya.windowSize;return e.width/=t,e.height/=t,e},i.setFrameSize=function(t,e){var i=ga.devicePixelRatio;ya.windowSize=new Qn(t*i,e*i)},i.getVisibleSize=function(){return new Qn(this._visibleRect.width,this._visibleRect.height)},i.getVisibleSizeInPixel=function(){return new Qn(this._visibleRect.width*this._scaleX,this._visibleRect.height*this._scaleY)},i.getVisibleOrigin=function(){return new jn(this._visibleRect.x,this._visibleRect.y)},i.getVisibleOriginInPixel=function(){return new jn(this._visibleRect.x*this._scaleX,this._visibleRect.y*this._scaleY)},i.getResolutionPolicy=function(){return this._resolutionPolicy},i._updateResolutionPolicy=function(t){if(t instanceof vB)this._resolutionPolicy=t;else{var e=vB;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=yB.getDesignResolutionSize();yB.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),aB.width=this._visibleRect.width,aB.height=this._visibleRect.height,Ta&&Ta.init(this._visibleRect),this.emit("design-resolution-changed")}else it(2200)},i.getDesignResolutionSize=function(){return new Qn(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 ga.devicePixelRatio},i.convertToLocationInView=function(t,e,i,n){void 0===n&&(n=new jn);var r=ga.devicePixelRatio*(t-i.left),s=ga.devicePixelRatio*(i.top+i.height-e);return ga.isFrameRotated?(n.x=ya.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){var n;S.director.root.resize(t,e,void 0===i||0===i?1:i);var r=this._designResolutionSize.width,s=this._designResolutionSize.height;t>0&&e>0?this.setDesignResolutionSize(r,s,this._resolutionPolicy):W(!1,"_updateAdaptResult Invalid size."),this.emit("canvas-resize"),null===(n=this._resizeCallback)||void 0===n||n.call(this)},e}(zs(Ml)));hB.instance=void 0;var uB=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=S.game.canvas;if(t){var e=ya.windowSize;t.width!==e.width&&(t.width=e.width),t.height!==e.height&&(t.height=e.height)}},t}();uB.EQUAL_TO_FRAME=void 0,uB.PROPORTION_TO_FRAME=void 0;var lB=function(){function t(){this.name="ContentStrategy",this._result={scale:[1,1],viewport:null},this._strategy=vB.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 Jn(Math.round((t-i)/2),Math.round((e-n)/2),i,n);return this._result.scale=[r,s],this._result.viewport=a,this._result},n(t,[{key:"strategy",get:function(){return this._strategy}}]),t}(),cB=function(t){function e(){var e;return(e=t.call(this)||this).name="EqualToFrame",e}return s(e,t),e.prototype.apply=function(){ga.isProportionalToFrame=!1,this._setupCanvas()},e}(uB),_B=function(t){function e(){var e;return(e=t.call(this)||this).name="ProportionalToFrame",e}return s(e,t),e.prototype.apply=function(){ga.isProportionalToFrame=!0,this._setupCanvas()},e}(uB);uB.EQUAL_TO_FRAME=new cB,uB.PROPORTION_TO_FRAME=new _B;var fB=function(t){function e(){var e;return(e=t.call(this)||this).name="ExactFit",e._strategy=vB.EXACT_FIT,e}return s(e,t),e.prototype.apply=function(t,e){var i=ya.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}(lB),dB=function(t){function e(){var e;return(e=t.call(this)||this).name="ShowAll",e._strategy=vB.SHOW_ALL,e}return s(e,t),e.prototype.apply=function(t,e){var i,n,r=ya.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;Vn.ortho(this.projection,-1,1,-1,1,-1,1,i.capabilities.clipSpaceMinZ,i.capabilities.clipSpaceSignY,n.surfaceTransform);var r=n.width,s=n.height;this.initScale(),this._curTime+=1e3*t;var a=oh(ki(this._curTime/e.totalTime)),o=1,h=1;"custom"===this.settings.background.type&&(this.settings.policy===vB.FIXED_WIDTH?(o=r,h=r/this.bgImage.width*this.bgImage.height):this.settings.policy===vB.FIXED_HEIGHT?(o=s/this.bgImage.height*this.bgImage.width,h=s):this.settings.policy===vB.SHOW_ALL?this.bgImage.width/this.bgHeight>r/s?(o=r,h=r/this.bgImage.width*this.bgImage.height):(o=s/this.bgImage.height*this.bgImage.width,h=s):this.settings.policy===vB.NO_BORDER?this.bgImage.width/this.bgImage.height>r/s?(o=s/this.bgImage.height*this.bgImage.width,h=s):(o=r,h=r/this.bgImage.width*this.bgImage.height):(o=r,h=s),this.bgMat.setProperty("resolution",SB.set(r,s),0),this.bgMat.setProperty("scale",SB.set(o,h),0),this.bgMat.setProperty("translate",SB.set(.5*r,.5*s),0),this.bgMat.setProperty("percent",1),this.bgMat.setProperty("u_projection",this.projection),this.bgMat.passes[0].update());var u=s*this.logoYTrans;if("none"!==this.settings.logo.type&&(h=.185*s*e.displayRatio,o=this.logoWidth*(.185*s/this.logoHeight)*e.displayRatio,this.logoMat.setProperty("resolution",SB.set(r,s),0),this.logoMat.setProperty("scale",SB.set(o,h),0),this.logoMat.setProperty("translate",SB.set(r*this.logoXTrans,u),0),this.logoMat.setProperty("percent",a),this.logoMat.setProperty("u_projection",this.projection),this.logoMat.passes[0].update()),"default"===this.settings.logo.type&&this.watermarkMat){var l=this.watermarkTexture.width,c=this.watermarkTexture.height;o=l,h=c;var _=u-(.5*this.logoHeight*e.displayRatio+this.textYExtraTrans)*this.scaleSize-.5*c;this.watermarkMat.setProperty("resolution",SB.set(r,s),0),this.watermarkMat.setProperty("scale",SB.set(o,h),0),this.watermarkMat.setProperty("translate",SB.set(r*this.textXTrans,_),0),this.watermarkMat.setProperty("percent",a),this.watermarkMat.setProperty("u_projection",this.projection),this.watermarkMat.passes[0].update()}this.frame()},t.initBG=function(){var t=this.device;this.bgMat=new zT,this.bgMat.initialize({effectName:"util/splash-screen"});var e=new c_;e.addressU=pc.CLAMP,e.addressV=pc.CLAMP,e.addressW=pc.CLAMP,this.sampler=t.getSampler(e),this.bgTexture=t.createTexture(new u_(hc.TEX2D,uc.SAMPLED|uc.TRANSFER_DST,ec.RGBA8,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 Jc;s.texExtent.width=this.bgImage.width,s.texExtent.height=this.bgImage.height,s.texExtent.depth=1,t.copyTexImagesToTexture([this.bgImage],this.bgTexture,[s])},t.initLogo=function(){var t=this.device;this.logoMat=new zT,this.logoMat.initialize({effectName:"util/splash-screen"});var e=new c_;e.addressU=pc.CLAMP,e.addressV=pc.CLAMP,e.addressW=pc.CLAMP,this.sampler=t.getSampler(e),this.logoTexture=t.createTexture(new u_(hc.TEX2D,uc.SAMPLED|uc.TRANSFER_DST,ec.RGBA8,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 Jc;s.texExtent.width=this.logoImage.width,s.texExtent.height=this.logoImage.height,s.texExtent.depth=1,t.copyTexImagesToTexture([this.logoImage],this.logoTexture,[s]);var a=this.logoImage.width/this.logoImage.height;a<1?(this.logoWidth=this.logoWidthTemp,this.logoHeight=this.logoWidthTemp/a):(this.logoWidth=this.logoHeightTemp*a,this.logoHeight=this.logoHeightTemp)},t.initWaterMark=function(){var t=A.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 Jc;r.texExtent.width=t.width,r.texExtent.height=t.height,r.texExtent.depth=1,this.watermarkTexture=this.device.createTexture(new u_(hc.TEX2D,uc.SAMPLED|uc.TRANSFER_DST,ec.RGBA8,t.width,t.height)),this.device.copyTexImagesToTexture([t],this.watermarkTexture,[r]),this.watermarkMat=new zT,this.watermarkMat.initialize({effectName:"util/splash-screen"});var s=this.watermarkMat.passes[0],a=s.getBinding("mainTexture");s.bindTexture(a,this.watermarkTexture),s.descriptorSet.update()},t.frame=function(){var t=this.device,e=this.swapchain;if(!Sa.isXR||xr.entry.isRenderAllowable())for(var i=Sa.isXR?2:1,n=0;n=this.settings.totalTime}},{key:"curTime",get:function(){return this._curTime},set:function(t){this._curTime=t}}],[{key:"instance",get:function(){return e._ins||(e._ins=new e),e._ins}}]),e}();TB._ins=void 0,S.internal.SplashScreen=TB;var AB=new(function(){function t(){this._data=null}return t.prototype.init=function(t){var e=this;return void 0===t&&(t=""),S.rendering&&S.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}());S.effectSettings=AB;var bB=t("dS",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 Qs,e.onPostBaseInitDelegate=new Qs,e.onPreInfrastructureInitDelegate=new Qs,e.onPostInfrastructureInitDelegate=new Qs,e.onPreSubsystemInitDelegate=new Qs,e.onPostSubsystemInitDelegate=new Qs,e.onPreProjectInitDelegate=new Qs,e.onPostProjectInitDelegate=new Qs,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(){ID.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)||void 0===t||t.stop(),this.emit(i.EVENT_PAUSE))},r.resume=function(){var t;this._paused&&(kw._clearEvents(),this._paused=!1,null===(t=this._pacer)||void 0===t||t.start(),this.emit(i.EVENT_RESUME))},r.isPaused=function(){return this._paused},r.restart=function(){var t=this;return new Promise((function(t){ID.once(wD.EVENT_END_FRAME,(function(){return t()}))})).then((function(){ID.reset(),S.Object._deferredDestroy(),t.pause(),t.resume(),t._shouldLoadLaunchScene=!0,TB.instance.curTime=0,t._safeEmit(i.EVENT_RESTART)}))},r.end=function(){Zs.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(){j(t.debugMode||nt.NONE)})).then((function(){return Sa.init()})).then((function(){n._initEvents()})).then((function(){return Me.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(){Pe.init(),n._initXR();var t={frame:document.querySelector("#GameDiv"),container:document.querySelector("#Cocos3dGameContainer"),canvas:document.querySelector("#GameCanvas")};return t&&(n.canvas=t.canvas,n.frame=t.frame,n.container=t.container),ya.init(),jl.init(),Ff.init(n.canvas,kg)})).then((function(){if(Me.querySettings(De.Category.RENDERING,"customPipeline")){if(!S.rendering)return void it(12109);Pe.CUSTOM_PIPELINE_NAME||(Pe.CUSTOM_PIPELINE_NAME="Builtin")}else S.rendering=void 0;vT.init(),bT.init(),dm.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 AB.init(Me.querySettings(De.Category.RENDERING,"effectSettingsPath"))})).then((function(){if(S.rendering&&S.rendering.enableEffectImport)if(Me.querySettings(De.Category.RENDERING,"renderMode")!==Bf.HEADLESS){var t=AB.data;null!==t?S.rendering.init(Ff.gfxDevice,t):it(1102)}else S.rendering.init(Ff.gfxDevice,null)})).then((function(){var t=Me.querySettings(De.Category.SCRIPTING,"scriptPackages");return t?Promise.all(t.map((function(t){return e.import(t)}))):Promise.resolve([])})).then((function(){return ID.init(),bT.loadBuiltinAssets()})).then((function(){return n.emit(i.EVENT_POST_SUBSYSTEM_INIT),n.onPostSubsystemInitDelegate.dispatch()})).then((function(){U("Cocos Creator v"+T),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=Me.querySettings(De.Category.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 bT.compileBuiltinMaterial(),TB.instance.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(){var t;if(void 0===globalThis.__globalXR&&(globalThis.__globalXR={}),globalThis.__globalXR.webxrCompatible=null!==(t=Me.querySettings(De.Category.XR,"webxrCompatible"))&&void 0!==t&&t,Sa.isXR){var e,i;xr.entry=xr.XrEntry.getInstance();var n=null!==(e=Me.querySettings(De.Category.RENDERING,"msaa"))&&void 0!==e?e:1,r=null!==(i=Me.querySettings(De.Category.RENDERING,"renderingScale"))&&void 0!==i?i:1;xr.entry.setMultisamplesRTT(n),xr.entry.setRenderingScale(r)}},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=Me.querySettings(De.Category.ASSETS,"preloadAssets");return t?Promise.all(t.map((function(t){return new Promise((function(e,i){vT.loadAny(t,(function(t){t?i(t):e()}))}))}))):Promise.resolve([])},r._loadCCEScripts=function(){return new Promise((function(t){t()}))},r._loadProjectBundles=function(){var t=Me.querySettings(De.Category.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),vT.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(TB.instance.isFinished)if(this._shouldLoadLaunchScene){this._shouldLoadLaunchScene=!1;var e,i=Me.querySettings(De.Category.LAUNCH,"launchScene");i?ID.loadScene(i,(function(){var e;Q(1103,i),t._initTime=performance.now(),ID.startAnimation(),null===(e=t.onStart)||void 0===e||e.call(t)})):(this._initTime=performance.now(),ID.startAnimation(),null===(e=this.onStart)||void 0===e||e.call(this))}else ID.tick(this._calculateDT(!1));else TB.instance.update(this._calculateDT(!1))},r.initPacer=function(){var t,e=null!==(t=Me.querySettings(De.Category.SCREEN,"frameRate"))&&void 0!==t?t:60;W("number"==typeof e),this._pacer=new DD,this._pacer.onTick=this._updateCallback.bind(this),this.frameRate=e},r._initEvents=function(){Zs.on("show",this._onShow,this),Zs.on("hide",this._onHide,this),Zs.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),Zs.exit()},r.addPersistRootNode=function(t){ID.addPersistRootNode(t)},r.removePersistRootNode=function(t){ID.removePersistRootNode(t)},r.isPersistRootNode=function(t){return ID.isPersistRootNode(t)},r._setupRenderPipeline=function(){var t=Me.querySettings(De.Category.RENDERING,"customPipeline");return this._setRenderPipeline(!!t)},r._setRenderPipeline=function(t){ID.root.setRenderPipeline(t)?(this._rendererInitialized=!0,this._safeEmit(i.EVENT_RENDERER_INITED)):it(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}(Hs));bB.EVENT_HIDE="game_on_hide",bB.EVENT_SHOW="game_on_show",bB.EVENT_LOW_MEMORY="game_on_low_memory",bB.EVENT_GAME_INITED="game_inited",bB.EVENT_ENGINE_INITED="engine_inited",bB.EVENT_RENDERER_INITED="renderer_inited",bB.EVENT_PRE_BASE_INIT="pre_base_init",bB.EVENT_POST_BASE_INIT="post_base_init",bB.EVENT_PRE_INFRASTRUCTURE_INIT="pre_infrastructure_init",bB.EVENT_POST_INFRASTRUCTURE_INIT="post_infrastructure_init",bB.EVENT_PRE_SUBSYSTEM_INIT="pre_subsystem_init",bB.EVENT_POST_SUBSYSTEM_INIT="post_subsystem_init",bB.EVENT_PRE_PROJECT_INIT="pre_project_init",bB.EVENT_POST_PROJECT_INIT="post_project_init",bB.EVENT_RESTART="game_on_restart",bB.EVENT_PAUSE="game_on_pause",bB.EVENT_RESUME="game_on_resume",bB.EVENT_CLOSE="game_on_close",bB.RENDER_TYPE_CANVAS=0,bB.RENDER_TYPE_WEBGL=1,bB.RENDER_TYPE_OPENGL=2,bB.RENDER_TYPE_HEADLESS=3,bB.DEBUG_DT_THRESHOLD=1,S.Game=bB;var EB=t("dT",S.game=new bB);ct(wD.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"}]),lt(wD.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"}]),ut(ID,"director",[{name:"_getSceneUuid",targetName:"assetManager.main",newName:"getSceneInfo",customFunction:function(t){var e;return vT.main?null===(e=vT.main.getSceneInfo(t))||void 0===e?void 0:e.uuid:""}}]),ct(EB,"game",[{name:"collisionMatrix"},{name:"groupList"}]),ut(EB,"game",[{name:"_sceneInfos",targetName:"assetManager.main",newName:"getSceneInfo",customGetter:function(){var t=[];return vT.main&&vT.main.config.scenes.forEach((function(e){t.push(e)})),t}}]);var CB=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(e.minFilter!==dc.LINEAR||e.magFilter!==dc.LINEAR||e.mipFilter!==dc.NONE)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(),S.director.on(S.Director.EVENT_BEFORE_SCENE_LAUNCH,this.beforeSceneLoad,this)):(this.reset(),S.director.off(S.Director.EVENT_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}(Ml));CB.instance=void 0;var xB,wB=t("a5",CB.instance=new CB);ID.registerSystem("dynamicAtlasManager",wB,0),S.internal.dynamicAtlasManager=wB,function(t){t[t.positions=Uc.ATTR_POSITION]="positions",t[t.normals=Uc.ATTR_NORMAL]="normals",t[t.uvs=Uc.ATTR_TEX_COORD]="uvs",t[t.colors=Uc.ATTR_COLOR]="colors"}(xB||(xB={}));var RB=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}(),IB=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;nfv.MAX_MORPH_TARGET_COUNT?this._subMeshRenderings[n]=new BB(this._mesh,n,this._mesh.struct.morph,e):this._subMeshRenderings[n]=new DB(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<>>0;t=n}for(var r,s=1,a=0,o=t.length,h=0;0>>0}function o(e,i){this.index="number"==typeof i?i:0,this.i=0,this.buffer=e instanceof(s?Uint8Array:Array)?e:new(s?Uint8Array:Array)(32768),2*this.buffer.length<=this.index&&t(Error("invalid index")),this.buffer.length<=this.index&&this.f()}o.prototype.f=function(){var t,e=this.buffer,i=e.length,n=new(s?Uint8Array:Array)(i<<1);if(s)n.set(e);else for(t=0;t>>8&255]<<16|f[t>>>16&255]<<8|f[t>>>24&255])>>32-e:f[t]>>8-e),8>e+a)o=o<>e-n-1&1,8==++a&&(a=0,r[s++]=f[o],o=0,s===r.length&&(r=this.f()));r[s]=o,this.buffer=r,this.i=a,this.index=s},o.prototype.finish=function(){var t,e=this.buffer,i=this.index;return 0h;++h){for(var l=_=h,c=7,_=_>>>1;_;_>>>=1)l<<=1,l|=1&_,--c;u[h]=(l<>>0}var f=u;function d(t){this.buffer=new(s?Uint16Array:Array)(2*t),this.length=0}function p(t){var e,i,n,r,a,o,h,u,l,c=t.length,_=0,f=Number.POSITIVE_INFINITY;for(u=0;u_&&(_=t[u]),t[u]>=1;for(l=o;ls[n]);)r=s[i],s[i]=s[n],s[n]=r,r=s[i+1],s[i+1]=s[n+1],s[n+1]=r,i=n;return this.length},d.prototype.pop=function(){var t,e,i,n,r,s=this.buffer;for(e=s[0],t=s[1],this.length-=2,s[0]=s[this.length],s[1]=s[this.length+1],r=0;!((n=2*r+2)>=this.length)&&(n+2s[n]&&(n+=2),s[n]>s[r]);)i=s[r],s[r]=s[n],s[n]=i,i=s[r+1],s[r+1]=s[n+1],s[n+1]=i,r=n;return{index:t,value:e,length:this.length}};var g,v=2,y={NONE:0,r:1,j:v,N:3},S=[];for(g=0;288>g;g++)switch(i){case 143>=g:S.push([g+48,8]);break;case 255>=g:S.push([g-144+400,9]);break;case 279>=g:S.push([g-256+0,7]);break;case 287>=g:S.push([g-280+192,8]);break;default:t("invalid literal: "+g)}function T(t,e){this.length=t,this.G=e}function A(){var e=b;switch(i){case 3===e:return[257,e-3,0];case 4===e:return[258,e-4,0];case 5===e:return[259,e-5,0];case 6===e:return[260,e-6,0];case 7===e:return[261,e-7,0];case 8===e:return[262,e-8,0];case 9===e:return[263,e-9,0];case 10===e:return[264,e-10,0];case 12>=e:return[265,e-11,1];case 14>=e:return[266,e-13,1];case 16>=e:return[267,e-15,1];case 18>=e:return[268,e-17,1];case 22>=e:return[269,e-19,2];case 26>=e:return[270,e-23,2];case 30>=e:return[271,e-27,2];case 34>=e:return[272,e-31,2];case 42>=e:return[273,e-35,3];case 50>=e:return[274,e-43,3];case 58>=e:return[275,e-51,3];case 66>=e:return[276,e-59,3];case 82>=e:return[277,e-67,4];case 98>=e:return[278,e-83,4];case 114>=e:return[279,e-99,4];case 130>=e:return[280,e-115,4];case 162>=e:return[281,e-131,5];case 194>=e:return[282,e-163,5];case 226>=e:return[283,e-195,5];case 257>=e:return[284,e-227,5];case 258===e:return[285,e-258,0];default:t("invalid length: "+e)}}m.prototype.n=function(){var n,r,a,h,u=this.input;switch(this.h){case 0:for(a=0,h=u.length;a>>8&255,g[y++]=255&_,g[y++]=_>>>8&255,s)g.set(f,y),y+=f.length,g=g.subarray(0,y);else{for(p=0,m=f.length;pK)for(;0K?K:138)>K-3&&J=J?(it[Z++]=17,it[Z++]=J-3,nt[17]++):(it[Z++]=18,it[Z++]=J-11,nt[18]++),K-=J;else if(it[Z++]=et[Y],nt[et[Y]]++,3>--K)for(;0K?K:6)>K-3&&Jz;z++)j[z]=k[X[z]];for(P=19;4=b;b++)E=A(),C[b]=E[2]<<24|E[1]<<16|E[0];var x=s?new Uint32Array(C):C;function w(n,r){function a(e,n){var r,s,a,o,h=e.G,u=[],l=0;switch(r=x[e.length],u[l++]=65535&r,u[l++]=r>>16&255,u[l++]=r>>24,i){case 1===h:s=[0,h-1,0];break;case 2===h:s=[1,h-2,0];break;case 3===h:s=[2,h-3,0];break;case 4===h:s=[3,h-4,0];break;case 6>=h:s=[4,h-5,1];break;case 8>=h:s=[5,h-7,1];break;case 12>=h:s=[6,h-9,2];break;case 16>=h:s=[7,h-13,2];break;case 24>=h:s=[8,h-17,3];break;case 32>=h:s=[9,h-25,3];break;case 48>=h:s=[10,h-33,4];break;case 64>=h:s=[11,h-49,4];break;case 96>=h:s=[12,h-65,5];break;case 128>=h:s=[13,h-97,5];break;case 192>=h:s=[14,h-129,6];break;case 256>=h:s=[15,h-193,6];break;case 384>=h:s=[16,h-257,7];break;case 512>=h:s=[17,h-385,7];break;case 768>=h:s=[18,h-513,8];break;case 1024>=h:s=[19,h-769,8];break;case 1536>=h:s=[20,h-1025,9];break;case 2048>=h:s=[21,h-1537,9];break;case 3072>=h:s=[22,h-2049,10];break;case 4096>=h:s=[23,h-3073,10];break;case 6144>=h:s=[24,h-4097,11];break;case 8192>=h:s=[25,h-6145,11];break;case 12288>=h:s=[26,h-8193,12];break;case 16384>=h:s=[27,h-12289,12];break;case 24576>=h:s=[28,h-16385,13];break;case 32768>=h:s=[29,h-24577,13];break;default:t("invalid distance")}for(r=s,u[l++]=r[0],u[l++]=r[1],u[l++]=r[2],a=0,o=u.length;a=u;)S[u++]=0;for(u=0;29>=u;)A[u++]=0}for(S[256]=1,o=0,h=r.length;o=h){for(d&&a(d,-1),u=0,l=h-o;uR&&o+Rw&&(C=E,w=R),258===R)break}f=new T(w,o-C),d?d.length2*y[f-1]+S[f]&&(y[f]=2*y[f-1]+S[f]),A[f]=Array(y[f]),b[f]=Array(y[f]);for(_=0;_r[_]?(A[f][p]=m,b[f][p]=v,g+=2):(A[f][p]=r[_],b[f][p]=_,++_);E[f]=0,1===S[f]&&i(f)}for(a=T,o=0,h=n.length;o1<l&&t("undercommitted"),i=0,n=e.length;i>>=1;return o}function D(t,e){this.input=t,this.a=new(s?Uint8Array:Array)(32768),this.h=B.j;var i,n={};for(i in!e&&(e={})||"number"!=typeof e.compressionType||(this.h=e.compressionType),e)n[i]=e[i];n.outputBuffer=this.a,this.z=new m(this.input,n)}var B=y;function M(e,i){switch(this.k=[],this.l=32768,this.e=this.g=this.c=this.q=0,this.input=s?new Uint8Array(e):e,this.s=!1,this.m=O,this.B=!1,!i&&(i={})||(i.index&&(this.c=i.index),i.bufferSize&&(this.l=i.bufferSize),i.bufferType&&(this.m=i.bufferType),i.resize&&(this.B=i.resize)),this.m){case P:this.b=32768,this.a=new(s?Uint8Array:Array)(32768+this.l+258);break;case O:this.b=0,this.a=new(s?Uint8Array:Array)(this.l),this.f=this.J,this.t=this.H,this.o=this.I;break;default:t(Error("invalid inflate mode"))}}D.prototype.n=function(){var e,i,n,r,o,h,u,l=0;switch(u=this.a,e=lt){case lt:i=Math.LOG2E*Math.log(32768)-8;break;default:t(Error("invalid compression method"))}switch(n=i<<4|e,u[l++]=n,e){case lt:switch(this.h){case B.NONE:o=0;break;case B.r:o=1;break;case B.j:o=2;break;default:t(Error("unsupported compression type"))}break;default:t(Error("invalid compression method"))}return r=o<<6|0,u[l++]=r|31-(256*n+r)%31,h=a(this.input),this.z.b=l,l=(u=this.z.n()).length,s&&((u=new Uint8Array(u.buffer)).length<=l+4&&(this.a=new Uint8Array(u.length+4),this.a.set(u),u=this.a),u=u.subarray(0,l+4)),u[l++]=h>>24&255,u[l++]=h>>16&255,u[l++]=h>>8&255,u[l++]=255&h,u},r("Zlib.Deflate",D),r("Zlib.Deflate.compress",(function(t,e){return new D(t,e).n()})),r("Zlib.Deflate.CompressionType",B),r("Zlib.Deflate.CompressionType.NONE",B.NONE),r("Zlib.Deflate.CompressionType.FIXED",B.r),r("Zlib.Deflate.CompressionType.DYNAMIC",B.j);var P=0,O=1,L={D:P,C:O};M.prototype.p=function(){for(;!this.s;){var n=tt(this,3);switch(1&n&&(this.s=i),n>>>=1){case 0:var r=this.input,a=this.c,o=this.a,h=this.b,u=e,l=e,c=e,_=o.length,f=e;switch(this.e=this.g=0,(u=r[a++])===e&&t(Error("invalid uncompressed block header: LEN (first byte)")),l=u,(u=r[a++])===e&&t(Error("invalid uncompressed block header: LEN (second byte)")),l|=u<<8,(u=r[a++])===e&&t(Error("invalid uncompressed block header: NLEN (first byte)")),c=u,(u=r[a++])===e&&t(Error("invalid uncompressed block header: NLEN (second byte)")),l===~(c|=u<<8)&&t(Error("invalid uncompressed block header: length verify")),a+l>r.length&&t(Error("input buffer is broken")),this.m){case P:for(;h+l>o.length;){if(l-=f=_-h,s)o.set(r.subarray(a,a+f),h),h+=f,a+=f;else for(;f--;)o[h++]=r[a++];this.b=h,o=this.f(),h=this.b}break;case O:for(;h+l>o.length;)o=this.f({v:2});break;default:t(Error("invalid inflate mode"))}if(s)o.set(r.subarray(a,a+l),h),h+=l,a+=l;else for(;l--;)o[h++]=r[a++];this.c=a,this.b=h,this.a=o;break;case 1:this.o(Z,$);break;case 2:it(this);break;default:t(Error("unknown BTYPE: "+n))}}return this.t()};var N,F,k=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],G=s?new Uint16Array(k):k,V=[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],U=s?new Uint16Array(V):V,z=[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],H=s?new Uint8Array(z):z,W=[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],X=s?new Uint16Array(W):W,j=[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],Y=s?new Uint8Array(j):j,q=new(s?Uint8Array:Array)(288);for(N=0,F=q.length;N=N?8:255>=N?9:279>=N?7:8;var K,Q,Z=p(q),J=new(s?Uint8Array:Array)(30);for(K=0,Q=J.length;K>>n,i.e=a-n,i.c=h,r}function et(i,n){for(var r,s,a,o=i.g,h=i.e,u=i.input,l=i.c,c=n[0],_=n[1];h<_;)(r=u[l++])===e&&t(Error("input buffer is broken")),o|=r<>>16,i.g=o>>a,i.e=h-a,i.c=l,65535&s}function it(t){function e(t,e,i){var n,r,s,a;for(a=0;ar)n>=h&&(this.b=n,i=this.f(),n=this.b),i[n++]=r;else for(o=U[s=r-257],0=h&&(this.b=n,i=this.f(),n=this.b);o--;)i[n]=i[n++-a];for(;8<=this.e;)this.e-=8,this.c--;this.b=n},M.prototype.I=function(t,e){var i=this.a,n=this.b;this.u=t;for(var r,s,a,o,h=i.length;256!==(r=et(this,t));)if(256>r)n>=h&&(h=(i=this.f()).length),i[n++]=r;else for(o=U[s=r-257],0h&&(h=(i=this.f()).length);o--;)i[n]=i[n++-a];for(;8<=this.e;)this.e-=8,this.c--;this.b=n},M.prototype.f=function(){var t,e,i=new(s?Uint8Array:Array)(this.b-32768),n=this.b-32768,r=this.a;if(s)i.set(r.subarray(32768,i.length));else for(t=0,e=i.length;tt;++t)r[t]=r[n+t];return this.b=32768,r},M.prototype.J=function(t){var e,i,n,r=this.input.length/this.c+1|0,a=this.input,o=this.a;return t&&("number"==typeof t.v&&(r=t.v),"number"==typeof t.F&&(r+=t.F)),i=2>r?(n=(a.length-this.c)/this.u[2]/2*258|0)e&&(this.a.length=e),t=this.a),this.buffer=t},nt.prototype.p=function(){var e,i=this.input;return e=this.A.p(),this.c=this.A.c,this.M&&(i[this.c++]<<24|i[this.c++]<<16|i[this.c++]<<8|i[this.c++])>>>0!==a(e)&&t(Error("invalid adler-32 checksum")),e},r("Zlib.Inflate",nt),r("Zlib.Inflate.BufferType",L),L.ADAPTIVE=L.C,L.BLOCK=L.D,r("Zlib.Inflate.prototype.decompress",nt.prototype.p);var rt,st,at=new(s?Uint8Array:Array)(288);for(rt=0,st=at.length;rt=rt?8:255>=rt?9:279>=rt?7:8;p(at);var ot,ht,ut=new(s?Uint8Array:Array)(30);for(ot=0,ht=ut.length;ot=65536){tt(10001,L,65536);continue}P>>=1,O>>=1}D=E.createBuffer(new r_(rc.INDEX,oc.DEVICE,O,P)),x.push(D),B=new(YB(M.stride))(b,M.offset,M.count),M.stride!==P&&(B=YB(P).from(B)),D.update(B)}var N=I.vertexBundelIndices.map((function(t){return C[t]})),F=[];if(I.vertexBundelIndices.length>0)for(var k=I.vertexBundelIndices[0],G=this._struct.vertexBundles[k].attributes,V=0;V=this._struct.primitives.length)tt(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&&(m.set(g),v.update(g,p)),c.view.count=d,h.vertexCount=d}if(a.indexView){var y=a.indexView,S=y.stride,T=2===S?e.indices16.length:e.indices32.length,A=T*S,b=new Uint8Array(this._data.buffer,y.offset,A),E=2===S?new Uint8Array(e.indices16.buffer,e.indices16.byteOffset,A):new Uint8Array(e.indices32.buffer,e.indices32.byteOffset,A),C=o.indexBuffer;s.maxSubMeshIndices,A>0&&(b.set(E),C.update(E,A)),y.count=T,h.indexCount=T}if(e.minPos&&e.maxPos){var x=new gn(e.minPos.x,e.minPos.y,e.minPos.z),w=new gn(e.maxPos.x,e.maxPos.y,e.maxPos.z);r.bounds[t]||(r.bounds[t]=new Ra),Ra.fromPoints(r.bounds[t],x,w);for(var R,I=new gn,D=new gn,B=f(r.bounds);!(R=B()).done;){var M=R.value;M&&(M.getBoundary(I,D),gn.min(x,I,x),gn.max(w,D,w))}this._struct.minPosition=new gn(x.x,x.y,x.z),this._struct.maxPosition=new gn(w.x,w.y,w.z)}o.invalidateGeometricInfo()}else tt(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)){gn.transformMat4(KB,qB,n[d]),i[d]=!0;var p=e[d];gn.min(p.center,p.center,KB),gn.max(p.halfExtents,p.halfExtents,KB)}}}}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?ec.R8UI:2===i.indexView.stride?ec.R16UI:ec.R32UI,s=eM(new DataView(this._data.buffer),r),a=0;a=this._struct.primitives.length))for(var n,r=f(this._struct.primitives[t].vertexBundelIndices);!(n=r()).done;){var s=n.value,a=this._struct.vertexBundles[s],o=a.attributes.findIndex((function(t){return t.name===e}));if(!(o<0)){i(a,o);break}}},i._createVertexBuffers=function(t,e){return this._struct.vertexBundles.map((function(i){var n=t.createBuffer(new r_(rc.VERTEX,oc.DEVICE,i.view.length,i.view.stride)),r=new Uint8Array(e,i.view.offset,i.view.length);return n.update(r),n}))},i.initDefault=function(e){t.prototype.initDefault.call(this,e),this.reset({struct:{vertexBundles:[],primitives:[]},data:QB})},i.releaseData=function(){this._data=QB},n(e,[{key:"_nativeAsset",get:function(){return this._data.buffer},set:function(t){this._data=new Uint8Array(t)}},{key:"subMeshCount",get:function(){var t=this.renderingSubMeshes;return t?t.length:0}},{key:"minPosition",get:function(){return this.struct.minPosition}},{key:"maxPosition",get:function(){return this.struct.maxPosition}},{key:"struct",get:function(){return this._struct}},{key:"data",get:function(){return this._data}},{key:"hash",get:function(){return this._hash||(this._hash=zl(this._data,666)),this._hash}},{key:"jointBufferIndices",get:function(){return this._jointBufferIndices?this._jointBufferIndices:this._jointBufferIndices=this._struct.primitives.map((function(t){return t.jointMapIndex||0}))}},{key:"renderingSubMeshes",get:function(){return this.initialize(),this._renderingSubMeshes}},{key:"allowDataAccess",get:function(){return this._allowDataAccess},set:function(t){this._allowDataAccess=t,this._isMeshDataUploaded&&!this._allowDataAccess&&this.releaseData()}}]),e}(vd),HB=ja(zB.prototype,"_struct",[lo],(function(){return{vertexBundles:[],primitives:[]}})),WB=ja(zB.prototype,"_hash",[lo],(function(){return 0})),XB=ja(zB.prototype,"_allowDataAccess",[lo],(function(){return!0})),UB=zB))||UB);function JB(t,e){for(var i=0,n=0;n0){if(n=null,t.attributes)for(var u,l=f(t.attributes);!(u=l()).done;){var c=u.value;if(c.name===Uc.ATTR_POSITION){n=c;break}}n||(n=sM[0]),r.push(n);var _=j_[n.format];o=Math.max(o,Math.floor(h.length/_.count)),a.push({offset:s,data:h,attribute:n}),s+=_.size}if(t.normals&&t.normals.length>0){if(n=null,t.attributes)for(var d,p=f(t.attributes);!(d=p()).done;){var m=d.value;if(m.name===Uc.ATTR_NORMAL){n=m;break}}n||(n=sM[1]);var g=j_[n.format];r.push(n),o=Math.max(o,Math.floor(t.normals.length/g.count)),a.push({offset:s,data:t.normals,attribute:n}),s+=g.size}if(t.uvs&&t.uvs.length>0){if(n=null,t.attributes)for(var v,y=f(t.attributes);!(v=y()).done;){var S=v.value;if(S.name===Uc.ATTR_TEX_COORD){n=S;break}}n||(n=sM[2]);var T=j_[n.format];r.push(n),o=Math.max(o,Math.floor(t.uvs.length/T.count)),a.push({offset:s,data:t.uvs,attribute:n}),s+=T.size}if(t.tangents&&t.tangents.length>0){if(n=null,t.attributes)for(var A,b=f(t.attributes);!(A=b()).done;){var E=A.value;if(E.name===Uc.ATTR_TANGENT){n=E;break}}n||(n=sM[3]);var C=j_[n.format];r.push(n),o=Math.max(o,Math.floor(t.tangents.length/C.count)),a.push({offset:s,data:t.tangents,attribute:n}),s+=C.size}if(t.colors&&t.colors.length>0){if(n=null,t.attributes)for(var x,w=f(t.attributes);!(x=w()).done;){var R=x.value;if(R.name===Uc.ATTR_COLOR){n=R;break}}n||(n=sM[4]);var I=j_[n.format];r.push(n),o=Math.max(o,Math.floor(t.colors.length/I.count)),a.push({offset:s,data:t.colors,attribute:n}),s+=I.size}if(t.customAttributes)for(var D=0;D0){var i=t%e;if(0!==i)return e-i}return 0}var uM,lM,cM=function(){function t(){}return t.createMesh=function(t,e,i){return oM(t,e,i)},t.createDynamicMesh=function(t,e,i,n){return function(t,e,i,n){n=n||{maxSubMeshes:1,maxSubMeshVertices:1024,maxSubMeshIndices:1024};var r=[],s=0;if(e.positions.length>0&&r.push(new T_(Uc.ATTR_POSITION,ec.RGB32F,!1,s++,!1,0)),e.normals&&e.normals.length>0&&r.push(new T_(Uc.ATTR_NORMAL,ec.RGB32F,!1,s++,!1,0)),e.uvs&&e.uvs.length>0&&r.push(new T_(Uc.ATTR_TEX_COORD,ec.RG32F,!1,s++,!1,0)),e.tangents&&e.tangents.length>0&&r.push(new T_(Uc.ATTR_TANGENT,ec.RGBA32F,!1,s++,!1,0)),e.colors&&e.colors.length>0&&r.push(new T_(Uc.ATTR_COLOR,ec.RGBA32F,!1,s++,!1,0)),e.customAttributes)for(var a=0;a0?A=2:e.indices32&&e.indices32.length>0&&(A=4),A>0){c+=hM(c,A);var b=n.maxSubMeshIndices*A,E={offset:c,length:b,count:0,stride:A};p.indexView=E,c+=b}l.push(p)}var C={info:{maxSubMeshes:n.maxSubMeshes,maxSubMeshVertices:n.maxSubMeshVertices,maxSubMeshIndices:n.maxSubMeshIndices},bounds:[]};C.bounds.length=n.maxSubMeshes;var x={struct:{vertexBundles:u,primitives:l,dynamic:C},data:new Uint8Array(c)};return i||(i=new ZB),i.reset(x),i.initialize(),i.updateSubMesh(t,e),i}(t,e,i,n)},t.decodeMesh=function(t){return nM(t)},t.inflateMesh=function(t){return rM(t)},t}(),_M=Object.freeze({__proto__:null,find:TI,toPPM:function(t,e,i){return"P3 "+e+" "+i+" 255\n"+t.filter((function(t,e){return e%4<3})).toString()+"\n"},readMesh:function(t,e){void 0===e&&(e=0);for(var i,n={positions:[]},r=new DataView(t.data.buffer,t.data.byteOffset,t.data.byteLength),s=t.struct,a=s.primitives[e],o=f(a.vertexBundelIndices);!(i=o()).done;)for(var h,u=i.value,l=s.vertexBundles[u],c=l.view.offset,_=l.view,d=_.length,p=_.stride,m=f(l.attributes);!(h=m()).done;){var g=h.value,v=xB[g.name];v&&(n[v]=(n[v]||[]).concat(LD(r,g.format,c,d,p))),c+=j_[g.format].size}var y=a.indexView;return n.indices=LD(r,ec["R"+8*y.stride+"UI"],y.offset,y.length),n},createMesh:oM,MeshUtils:cM,readBuffer:LD,writeBuffer:OD,mapBuffer:ND});t("a8",_M);var fM,dM=vn(),pM=Wn();!function(t){t[t.RECT=0]="RECT",t[t.POLYGON=1]="POLYGON"}(fM||(fM={}));var mM,gM,vM,yM=[{u:0,v:0},{u:0,v:0},{u:0,v:0},{u:0,v:0}],SM=t("b",eo("cc.SpriteFrame")(((lM=function(t){function e(){var e;return(e=t.call(this)||this).vertices=null,e.uv=[],e.unbiasUV=[],e.uvSliced=[],e._rect=$n(),e._trimmedBorder=_n(),e._offset=Yn(),e._originalSize=Zn(),e._rotated=!1,e._capInsets=[0,0,0,0],e._atlasUuid="",e._texture=void 0,e._isFlipUVY=!1,e._isFlipUVX=!1,e._original=null,e._packable=!0,e._pixelsToUnit=100,e._pivot=Yn(.5,.5),e._meshType=fM.RECT,e._extrude=0,e._customOutLine=[],e._mesh=null,e._minPos=vn(),e._maxPos=vn(),e}s(e,t),e.createWithImage=function(t){var i=t instanceof Vd?t:new Vd(t),n=new lm;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=!1;e&&(this._originalSize.set(0,0),this._rect.set(0,0,0,0),this._offset.set(0,0),this._capInsets=[0,0,0,0],this._rotated=!1,i=!0),t&&(t.texture&&(this._rect.x=this._rect.y=0,this._rect.width=t.texture.width,this._rect.height=t.texture.height,this._refreshTexture(t.texture),this.checkRect(this._texture)),t.originalSize&&this._originalSize.set(t.originalSize),t.rect&&this._rect.set(t.rect),t.offset&&this._offset.set(t.offset),void 0!==t.borderTop&&(this._capInsets[1]=t.borderTop),void 0!==t.borderBottom&&(this._capInsets[3]=t.borderBottom),void 0!==t.borderLeft&&(this._capInsets[0]=t.borderLeft),void 0!==t.borderRight&&(this._capInsets[2]=t.borderRight),void 0!==t.isRotate&&(this._rotated=!!t.isRotate),void 0!==t.isFlipUv&&(this._isFlipUVY=!!t.isFlipUv),i=!0),i&&this.texture&&this._calculateUV(),this._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?(it(3300,this.name+"/"+t.name,i,t.width),!1):!(n>t.height&&(it(3301,this.name+"/"+t.name,n,t.height),1))},i._calcTrimmedBorder=function(){var t=this._originalSize.width,e=this._originalSize.height,i=.5*(t-this._rect.width),n=.5*(e-this._rect.height);this._trimmedBorder.x=this._offset.x+i,this._trimmedBorder.y=this._offset.x-i,this._trimmedBorder.z=this._offset.y+n,this._trimmedBorder.w=this._offset.y-n},i.ensureMeshData=function(){this._mesh||(this._initVertices(),this._createMesh())},i.destroy=function(){return this._packable&&wB&&wB.deleteAtlasSpriteFrame(this),t.prototype.destroy.call(this)},i._calculateSlicedUV=function(){var t=this._rect,i=this.texture,n=i.width,r=i.height,s=this._capInsets[0],a=this._capInsets[2],o=t.width-s-a,h=this._capInsets[1],u=this._capInsets[3],l=t.height-h-u,c=this.uvSliced;if(c.length=0,this._rotated){yM[0].u=t.x/n,yM[1].u=(t.x+u)/n,yM[2].u=(t.x+u+l)/n,yM[3].u=(t.x+t.height)/n,yM[3].v=t.y/r,yM[2].v=(t.y+s)/r,yM[1].v=(t.y+s+o)/r,yM[0].v=(t.y+t.width)/r;for(var _=0;_<4;++_)for(var f=yM[_],d=0;d<4;++d){var p=yM[3-d];c.push({u:f.u,v:p.v})}}else{yM[0].u=t.x/n,yM[1].u=(t.x+s)/n,yM[2].u=(t.x+s+o)/n,yM[3].u=(t.x+t.width)/n,yM[3].v=t.y/r,yM[2].v=(t.y+h)/r,yM[1].v=(t.y+h+l)/r,yM[0].v=(t.y+t.height)/r;for(var m=0;m<4;++m)for(var g=yM[m],v=0;v<4;++v){var y=yM[v];c.push({u:y.u,v:g.v})}}this.emit(e.EVENT_UV_UPDATED,this)},i._calculateUV=function(){var t=this._rect,e=this.uv,i=this.unbiasUV,n=this.texture,r=n.width,s=n.height;if(this._rotated){var a=0===r?0:t.x/r,o=0===r?1:(t.x+t.height)/r,h=0===s?0:t.y/s,u=0===s?1:(t.y+t.width)/s;this._isFlipUVX&&this._isFlipUVY?(e[0]=o,e[1]=u,e[2]=o,e[3]=h,e[4]=a,e[5]=u,e[6]=a,e[7]=h):this._isFlipUVX?(e[0]=o,e[1]=h,e[2]=o,e[3]=u,e[4]=a,e[5]=h,e[6]=a,e[7]=u):this._isFlipUVY?(e[0]=a,e[1]=u,e[2]=a,e[3]=h,e[4]=o,e[5]=u,e[6]=o,e[7]=h):(e[0]=a,e[1]=h,e[2]=a,e[3]=u,e[4]=o,e[5]=h,e[6]=o,e[7]=u);var l=0===r?0:t.x/r,c=0===r?1:(t.x+t.height)/r,_=0===s?0:t.y/s,f=0===s?1:(t.y+t.width)/s;this._isFlipUVX&&this._isFlipUVY?(i[0]=c,i[1]=f,i[2]=c,i[3]=_,i[4]=l,i[5]=f,i[6]=l,i[7]=_):this._isFlipUVX?(i[0]=c,i[1]=_,i[2]=c,i[3]=f,i[4]=l,i[5]=_,i[6]=l,i[7]=f):this._isFlipUVY?(i[0]=l,i[1]=f,i[2]=l,i[3]=_,i[4]=c,i[5]=f,i[6]=c,i[7]=_):(i[0]=l,i[1]=_,i[2]=l,i[3]=f,i[4]=c,i[5]=_,i[6]=c,i[7]=f)}else{var d=0===r?0:t.x/r,p=0===r?1:(t.x+t.width)/r,m=0===s?1:(t.y+t.height)/s,g=0===s?0:t.y/s;this._isFlipUVX&&this._isFlipUVY?(e[0]=p,e[1]=g,e[2]=d,e[3]=g,e[4]=p,e[5]=m,e[6]=d,e[7]=m):this._isFlipUVX?(e[0]=p,e[1]=m,e[2]=d,e[3]=m,e[4]=p,e[5]=g,e[6]=d,e[7]=g):this._isFlipUVY?(e[0]=d,e[1]=g,e[2]=p,e[3]=g,e[4]=d,e[5]=m,e[6]=p,e[7]=m):(e[0]=d,e[1]=m,e[2]=p,e[3]=m,e[4]=d,e[5]=g,e[6]=p,e[7]=g);var v=0===r?0:t.x/r,y=0===r?1:(t.x+t.width)/r,S=0===s?1:(t.y+t.height)/s,T=0===s?0:t.y/s;this._isFlipUVX&&this._isFlipUVY?(i[0]=y,i[1]=T,i[2]=v,i[3]=T,i[4]=y,i[5]=S,i[6]=v,i[7]=S):this._isFlipUVX?(i[0]=y,i[1]=S,i[2]=v,i[3]=S,i[4]=y,i[5]=T,i[6]=v,i[7]=T):this._isFlipUVY?(i[0]=v,i[1]=T,i[2]=y,i[3]=T,i[4]=v,i[5]=S,i[6]=y,i[7]=S):(i[0]=v,i[1]=S,i[2]=y,i[3]=S,i[4]=v,i[5]=T,i[6]=y,i[7]=T)}this._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=wB;if(t){var e=this._texture;if(e instanceof lm&&!e.isCompressed){var i=this.width,n=this.height;if(!e.image||i>t.maxFrameSize||n>t.maxFrameSize)this._packable=!1;else{var r=A.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=t,i=e.rect;i&&(this._rect=new Jn(i.x,i.y,i.width,i.height));var n=e.offset;e.offset&&(this._offset=Yn(n.x,n.y));var r=e.originalSize;e.originalSize&&(this._originalSize=Zn(r.width,r.height)),this._rotated=!!e.rotated,this._name=e.name,this._packable=!!e.packable,this._pixelsToUnit=e.pixelsToUnit;var s=e.pivot;s&&(this._pivot=Yn(s.x,s.y)),this._meshType=e.meshType;var a=e.capInsets;a&&(this._capInsets[0]=a[0],this._capInsets[1]=a[1],this._capInsets[2]=a[2],this._capInsets[3]=a[3]);var o=e.vertices;if(o){this.vertices||(this.vertices={rawPosition:[],positions:[],indexes:o.indexes,uv:o.uv,nuv:o.nuv,minPos:vn(o.minPos.x,o.minPos.y,o.minPos.z),maxPos:vn(o.maxPos.x,o.maxPos.y,o.maxPos.z)}),this.vertices.rawPosition.length=0;for(var h=o.rawPosition,u=0;u0){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(){for(var t=[],e=this.spriteFrames,i=0,n=Object.keys(e);i=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,DM.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}()))(100),MM=/([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûа-яА-ЯЁё]+|\S)/,PM=/^[!,.:;'}\]%\?>、‘“》?。,!]/,OM=/([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁёáàảạãăắằẳẵặâấầẩẫậéèẻẽẹêếềểễệiíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵđÁÀẢẠÃĂẮẰẲẴẶÂẤẦẨẪẬÉÈẺẼẸÊẾỀỂỄỆIÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴĐ]+|\S)$/,LM=/[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁёáàảạãăắằẳẵặâấầẩẫậéèẻẽẹêếềểễệiíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵđÁÀẢẠÃĂẮẰẲẴẶÂẤẦẨẪẬÉÈẺẼẸÊẾỀỂỄỆIÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴĐ]+$/,NM=/^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁёáàảạãăắằẳẵặâấầẩẫậéèẻẽẹêếềểễệiíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵđÁÀẢẠÃĂẮẰẲẴẶÂẤẦẨẪẬÉÈẺẼẸÊẾỀỂỄỆIÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴĐ]/;function FM(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 kM(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 GM(t,e,i){var n=(i||t.font)+"🎮"+e,r=BM.get(n);if(null!==r)return r;var s=t.measureText(e),a=s&&s.width||0;return BM.put(n,a),a}function VM(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 UM(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 zM(t,e){var i=UM(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 WM(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 jM(t){return NM.exec(t)}function YM(t){return LM.exec(t)}function qM(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=XM(s,a),h=e-n(o),u=o,l=0,c=0;h>i&&c++<100;)a*=i/h,h=e-n(o=XM(s,a|=0));for(c=0;o&&h<=i&&c++<100;){var _=MM.exec(o);u=o,h=e-n(o=XM(s,a+=l=_?_[0].length:1))}0==(a-=l)?(a=1,u=XM(s,1)):1===a&&s[0]>="\ud800"&&s[0]<="\udbff"&&(a=2,u=XM(s,2));var f=XM(s,0,a),d=void 0;PM.test(u||o)&&(0==(a-=(d=OM.exec(f))?d[0].length:0)&&(a=1),u=XM(s,a),f=XM(s,0,a)),NM.test(u)&&(d=LM.exec(f))&&f!==d[0]&&(u=XM(s,a-=d[0].length),f=XM(s,0,a)),(0===r.length||(f=f.trim()).length>0)&&r.push(f),e=n(s=u||o)}return(0===r.length||(s=s.trim()).length>0)&&r.push(s),r}var KM,QM=A.document,ZM=null,JM=-1,$M="BES bswy:->@123丁ぁᄁ",tP=Object.create(null),eP=[],iP=3e3;function nP(){for(var t=!0,e=Date.now(),i=eP.length-1;i>=0;i--){var n=eP[i],r=n.fontFamilyName;if(e-n.startTime>iP)tt(4933,r),n.onComplete(null,r),eP.splice(i,1);else{var s=n.refWidth,a="40px "+r;ZM.font=a,s!==GM(ZM,$M,a)?(eP.splice(i,1),n.onComplete(null,r)):t=!1}}t&&(clearInterval(JM),JM=-1)}function rP(t,e,i){var n=function(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}(t);if(tP[n])i(null,n);else{if(!ZM){var r=QM.createElement("canvas");r.width=100,r.height=100,ZM=r.getContext("2d")}var s="40px "+n,a=QM.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+"}",QM.body.appendChild(a);var h=QM.createElement("div"),u=h.style;if(u.fontFamily=n,h.innerHTML=".",u.position="absolute",u.left="-100px",u.top="-100px",QM.body.appendChild(h),function(){if(void 0===KM)if("FontFace"in A){var t=/Gecko.*Firefox\/(\d+)/.exec(A.navigator.userAgent),e=/OS X.*Version\/10\..*Safari/.exec(A.navigator.userAgent)&&/Apple/.exec(A.navigator.vendor);KM=t?parseInt(t[1],10)>42:!e}else KM=!1;return KM}())!function(t,e,i){var n=new Promise((function(i,n){!function r(){Date.now()-t>=iP?n():QM.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,iP)}));Promise.race([s,n]).then((function(){r&&(clearTimeout(r),r=null),i(null,e)}),(function(){tt(4933,e),i(null,e)}))}(Date.now(),n,i);else{var l={fontFamilyName:n,refWidth:GM(ZM,$M,s),onComplete:i,startTime:Date.now()};eP.push(l),-1===JM&&(JM=setInterval(nP,100))}tP[n]=a}}function sP(t,e,i,n){var r=new wM;r._nativeUrl=t,r._nativeAsset=e,n(null,r)}zS.register({".font":rP,".eot":rP,".ttf":rP,".woff":rP,".svg":rP,".ttc":rP}),tT.register({".font":sP,".eot":sP,".ttf":sP,".woff":sP,".svg":sP,".ttc":sP});var aP,oP,hP,uP,lP,cP,_P,fP,dP,pP=/^(click)(\s)*=|(param)(\s)*=/,mP=/(\s)*src(\s)*=|(\s)*height(\s)*=|(\s)*width(\s)*=|(\s)*align(\s)*=|(\s)*offset(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/,gP=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=mP.exec(t);for(var u=!1;i;){var l=(n=(t=t.substring(t.indexOf(i[0]))).substr(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.substr(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=mP.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("outline".length).trim()){var _,f=/(\s)*color(\s)*=|(\s)*width(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/;for(i=f.exec(t);i;)n=(t=t.substring(t.indexOf(i[0]))).substr(0,i[0].length),_=(r=(a=t.substring(n.length).trim()).indexOf(" "))>-1?a.substr(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+"="+_):"color"===n?c.color=_:"width"===n&&(c.width=parseInt(_)),e.event&&"param"===n&&(e.event[n]=_.replace(/^"|"$/g,"")),i=f.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=pP.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=pP.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=f(this._specialSymbolArray);!(e=i()).done;){var n=e.value,r=n[0],s=n[1];t=t.replace(r,s)}return t},t}()),vP=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},yP=function(){function t(t){this.letterDefinitions={},this.texture=t}var e=t.prototype;return e.addLetterDefinitions=function(t,e){this.letterDefinitions[t]=e},e.cloneLetterDefinition=function(){for(var t={},e=0,i=Object.keys(this.letterDefinitions);e=Pe.MAX_LABEL_CANVAS_POOL_SIZE||this.pool.push(t)},t}(),CP=En.WHITE.clone(),xP="rgba(255, 255, 255, "+(1/255).toFixed(3)+")",wP=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=""+zM(t,0)+e.hash}var e=t.prototype;return e.updateRenderData=function(){this._updateProperties(),this._updateTexture()},e.destroy=function(){this.image=null,EP.getInstance().put(this.data)},e._updateProperties=function(){if(this.data=EP.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=GM(this.context,this.char,this.labelInfo.fontDesc),i=2*this.labelInfo.margin+2;this.width=parseFloat(e.toFixed(2))*t+i,this.height=(1+RM)*this.labelInfo.fontSize*t+i,this.offsetY=-this.labelInfo.fontSize*RM*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 Vd),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=xP,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*IM+0*s,h=e.color;if(t.lineJoin="round",t.fillStyle="rgba("+h.r+", "+h.g+", "+h.b+", 1)",e.isOutlined){var u=e.out||CP;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}(),RP=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=yd.RGBA8888),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 Jc;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 tt(16363)}},e}(lm),IP=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 RP;i.initWithSize(t,e),this.fontDefDictionary=new yP(i),this._halfBleed=1,this._width=t,this._height=e,ID.on(wD.EVENT_BEFORE_SCENE_LAUNCH,this.beforeSceneLoad,this)}var e=t.prototype;return e.insertLetterTexture=function(t){var e=t.image,i=ID.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 tt(12100),null;if(!this.fontDefDictionary.texture)return null;this.fontDefDictionary.texture.drawTextureAt(e,this._x,this._y),this._dirty=!0;var s=new vP;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.destroy(),t.texture=null)},e.getTexture=function(){return this.fontDefDictionary.getTexture()},e.beforeSceneLoad=function(){this.clearAllCache()},e.clearAllCache=function(){this.destroy();var t=new RP;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=zM(t,0)+e.hash,n=this.fontDefDictionary.letterDefinitions[i];if(!n){var r=new wP(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}(),DP={fontAtlas:null,fontSize:0,lineHeight:0,hAlign:0,vAlign:0,hash:"",fontFamily:"",fontDesc:"Arial",color:En.WHITE.clone(),isOutlined:!1,out:En.WHITE.clone(),margin:0,fontScale:1},BP=[new T_(Uc.ATTR_POSITION,ec.RGB32F)],MP=[new T_(Uc.ATTR_POSITION,ec.RGB32F),new T_(Uc.ATTR_COLOR,ec.RGBA32F)],PP=[new T_(Uc.ATTR_POSITION,ec.RGB32F),new T_(Uc.ATTR_TEX_COORD,ec.RG32F),new T_(Uc.ATTR_COLOR,ec.RGBA32F)],OP=[new T_(Uc.ATTR_POSITION,ec.RGB32F),new T_(Uc.ATTR_TEX_COORD,ec.RG32F),new T_(Uc.ATTR_COLOR,ec.RGBA8,!0)],LP=[new T_(Uc.ATTR_POSITION,ec.RGB32F),new T_(Uc.ATTR_TEX_COORD,ec.RG32F),new T_(Uc.ATTR_COLOR,ec.RGBA32F),new T_(Uc.ATTR_COLOR2,ec.RGBA32F)],NP=[new T_(Uc.ATTR_POSITION,ec.RGB32F),new T_(Uc.ATTR_TEX_COORD,ec.RG32F),new T_(Uc.ATTR_COLOR,ec.RGBA8,!0),new T_(Uc.ATTR_COLOR2,ec.RGBA8,!0)];function FP(t){for(var e=0,i=0;i>2,this._initVDataCount,this._floatsPerVertex,at(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=Sa.__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(Sa.__isWebIOS14OrIPadOS14Env||!this._iaPool[0]){var r=this._vertexFormatBytes=this._floatsPerVertex*Float32Array.BYTES_PER_ELEMENT,s=Uint16Array.BYTES_PER_ELEMENT,a=t.createBuffer(new r_(rc.VERTEX|rc.TRANSFER_DST,oc.HOST|oc.DEVICE,r,r));n=t.createBuffer(new r_(rc.INDEX|rc.TRANSFER_DST,oc.HOST|oc.DEVICE,s,s)),i=[a],this._iaInfo=new b_(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}()),WP=function(){function t(t,e){this._buffers=[],this._device=t,this._attributes=e,this._floatsPerVertex=kP(e)>>2,this._vertexFormatBytes=this._floatsPerVertex*Float32Array.BYTES_PER_ELEMENT}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}(),XP=new ws((function(){return{offset:0,length:0}}),32),jP=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}(),YP=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*Pe.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 it(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 jP(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),XP.free(i)):(i.offset+=n,i.length=r)},i._allocateBuffer=function(){st(this._buffers.length===this._freeLists.length,9003);var t=new HP,e=this._vCount*this._floatsPerVertex;t.initialize(this._device,this._attributes,e,this._iCount),this._buffers.push(t);var i=XP.alloc();i.offset=0,i.length=t.vData.byteLength;var n=[i];return this._freeLists.push(n),ID.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}(WP);YP.IB_SCALE=4,YP.ID_COUNT=0,function(t){t[t.DrawInfoType=0]="DrawInfoType",t[t.VertDirty=1]="VertDirty",t[t.IsMeshBuffer=2]="IsMeshBuffer",t[t.Stride=3]="Stride",t[t.Count=4]="Count"}(GP||(GP={})),function(t){t[t.BufferID=0]="BufferID",t[t.AccessorID=1]="AccessorID",t[t.Count=2]="Count"}(VP||(VP={})),function(t){t[t.VertexOffset=0]="VertexOffset",t[t.IndexOffset=1]="IndexOffset",t[t.VBCount=2]="VBCount",t[t.IBCount=3]="IBCount",t[t.DataHash=4]="DataHash",t[t.Count=5]="Count"}(UP||(UP={})),function(t){t[t.COMP=0]="COMP",t[t.MODEL=1]="MODEL",t[t.MIDDLEWARE=2]="MIDDLEWARE",t[t.SUB_NODE=3]="SUB_NODE"}(zP||(zP={}));var qP,KP,QP=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=zP.COMP,this._subNode=null,this.init(t);var e=this._nativeObj.getAttrSharedBufferForJS(),i=0;this._uint8SharedBuffer=new Uint8Array(e,i,GP.Count),i+=GP.Count*Uint8Array.BYTES_PER_ELEMENT,this._uint16SharedBuffer=new Uint16Array(e,i,VP.Count),i+=VP.Count*Uint16Array.BYTES_PER_ELEMENT,this._uint32SharedBuffer=new Uint32Array(e,i,UP.Count)}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.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}();!function(t){t[t.DISABLED=0]="DISABLED",t[t.CLEAR=1]="CLEAR",t[t.ENTER_LEVEL=2]="ENTER_LEVEL",t[t.ENABLED=3]="ENABLED",t[t.EXIT_LEVEL=4]="EXIT_LEVEL",t[t.CLEAR_INVERTED=5]="CLEAR_INVERTED",t[t.ENTER_LEVEL_INVERTED=6]="ENTER_LEVEL_INVERTED"}(qP||(qP={})),function(t){t[t.stencilTest=0]="stencilTest",t[t.func=1]="func",t[t.stencilMask=2]="stencilMask",t[t.writeMask=3]="writeMask",t[t.failOp=4]="failOp",t[t.zFailOp=5]="zFailOp",t[t.passOp=6]="passOp",t[t.ref=7]="ref",t[t.count=8]="count"}(KP||(KP={}));var ZP,JP,$P,tO,eO,iO=t("S",function(){function t(){this._maskStack=[],this._stencilPattern={stencilTest:!0,func:mc.ALWAYS,stencilMask:65535,writeMask:65535,failOp:gc.KEEP,zFailOp:gc.KEEP,passOp:gc.KEEP,ref:1},this._stage=qP.DISABLED,this.stencilStateMap=new Map,this.stencilStateMapWithDepth=new Map}var e=t.prototype;return e.pushMask=function(t){this._maskStack.push(t)},e.clear=function(t){return t.stencilStage!==qP.ENTER_LEVEL?qP.CLEAR_INVERTED:qP.CLEAR},e.enableMask=function(){this.stage=qP.ENABLED},e.exitMask=function(){0!==this._maskStack.length&&(this._maskStack.pop(),0===this._maskStack.length?this.stage=qP.DISABLED:this.stage=qP.ENABLED)},e.getWriteMask=function(){return 1<>2,mO=t("t",function(){function t(t){void 0===t&&(t=PP),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=PP,this._drawInfoType=zP.COMP,this._multiOwner=!1,this._batcher=null,this._floatStride=t===PP?pO:kP(t)>>2,this._vertexFormat=t}var e=t.prototype;return e.isValid=function(){return this._ic>0&&this.chunk.vertexAccessor},e.initRenderDrawInfo=function(t,e){void 0===e&&(e=zP.COMP)},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,this._renderDrawInfo&&this._renderDrawInfo.setDrawInfoType(t)}},{key:"renderDrawInfo",get:function(){return this._renderDrawInfo}},{key:"material",get:function(){return this._material},set:function(t){this._material=t,this._renderDrawInfo&&this._renderDrawInfo.setMaterial(t)}},{key:"dataHash",get:function(){return this._dataHash},set:function(t){this._dataHash=t,this._renderDrawInfo&&this._renderDrawInfo.setDataHash(t)}},{key:"multiOwner",get:function(){return this._multiOwner},set:function(t){this._multiOwner=t}},{key:"batcher",get:function(){return this._batcher||(this._batcher=ID.root.batcher2D),this._batcher}}]),t}()),gO=t("u",function(t){function e(e,i){var n;return void 0===e&&(e=PP),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=PP),void 0===i&&(i=null);var n=new e(t,i);return i||(i=ID.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=zl(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._renderDrawInfo&&this._renderDrawInfo.setMaterial(this.material)),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._renderDrawInfo&&(this._renderDrawInfo.setTexture(this.frame?this.frame.getGFXTexture():null),this._renderDrawInfo.setSampler(this.frame?this.frame.getGFXSampler():null))),this.hashDirty&&(this.updateHash(),this._renderDrawInfo&&this._renderDrawInfo.setDataHash(this.dataHash))},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=ID.root.device;return new YP(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 r_(rc.VERTEX|rc.TRANSFER_DST,oc.DEVICE,i,i)));var r=Uint16Array.BYTES_PER_ELEMENT;this._indexBuffer||(this._indexBuffer=t.createBuffer(new r_(rc.INDEX|rc.TRANSFER_DST,oc.DEVICE,r,r))),this._iaInfo=new b_(this._vertexFormat,n,this._indexBuffer),this._iaPool=new Rs((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}(mO)),yO=new jn,SO=new jn,TO=new gn,AO=new Vn,bO=new Vn,EO=new Vn,CO=new Vn(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),xO=new Jn,wO=t("e",eo("cc.UITransform")(nO=no(110)(nO=ro(((oO=function(t){function e(){var e;return(e=t.call(this)||this)._priority=0,e._contentSize=sO&&sO(),e._anchorPoint=aO&&aO(),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(vm.PARENT_CHANGED,this._parentChanged,this),this._markRenderDataDirty()},i.onDisable=function(){this.node.off(vm.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(Ni((t=t).width,r.width,Oi)&&Ni(t.height,r.height,Oi))return;i=t.width,n=t.height}else{if(Ni(t=t,r.width,Oi)&&Ni(e,r.height,Oi))return;i=t,n=e}r.width=i,r.height=n,this.node.emit(vm.SIZE_CHANGED),this._markRenderDataDirty()},i.setAnchorPoint=function(t,e){var i=this._anchorPoint;if(void 0===e){if((t=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(vm.ANCHOR_CHANGED,this._anchorPoint),this._markRenderDataDirty()},i.isHit=function(t){for(var e=this._contentSize.width,i=this._contentSize.height,n=yO,r=SO,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=TO,s=yO,a=SO,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)||void 0===e||null===(i=e.eventProcessor)||void 0===i?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(EO),Vn.invert(AO,EO),e||(e=new gn),gn.transformMat4(e,t,AO)},i.convertToWorldSpaceAR=function(t,e){return this.node.getWorldMatrix(EO),e||(e=new gn),gn.transformMat4(e,t,EO)},i.getBoundingBox=function(){var t=new Jn;return this._selfBoundingBox(t),Vn.fromSRT(bO,this.node.rotation,this.node.position,this.node.scale),t.transformMat4(bO),t},i.getBoundingBoxToWorld=function(){for(var t=new Jn,i=this.node.children,n=0;n=this._materials.length?null:this._materials[t]},i.setSharedMaterial=function(t,e){t&&t instanceof ZT&&it(12012),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]){UO.parent=this._materials[t],UO.owner=this,UO.subModelIdx=t;var e=new ZT(UO);UO.parent=null,UO.owner=null,UO.subModelIdx=0,this.setMaterialInstance(e,t)}return this._materialInstances[t]},i.setMaterialInstance=function(t,e){if("number"==typeof t){tt(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),this.stencilStage!==qP.ENTER_LEVEL&&this.stencilStage!==qP.ENTER_LEVEL_INVERTED||this.getMaterialInstance(0).recompileShaders({USE_ALPHA_TEST:!0}),this._updateBlendFunc()}},i._updateColor=function(){if(this.node._uiProps.colorDirty=!0,this.setEntityColorDirty(!0),this.setEntityColor(this._color),this.setEntityOpacity(this.node._uiProps.localOpacity),this._assembler){this._assembler.updateColor(this);var t=this._renderFlag;if(this._renderFlag=this._canRender(),this.setEntityEnabled(this._renderFlag),t!==this._renderFlag){var e=this.renderData;e&&(e.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 VL(t,e){return Math.ceil(t/e)*e}!function(t){t[t.OPAQUE=0]="OPAQUE",t[t.TRANSPARENT=1]="TRANSPARENT",t[t.OVERLAY=2]="OVERLAY"}(LL||(LL={})),function(t){t[t.DEFAULT=1]="DEFAULT",t[t.FORWARD=2]="FORWARD",t[t.SHADOWCAST=4]="SHADOWCAST"}(NL||(NL={}));var UL,zL,HL,WL,XL,jL,YL,qL,KL,QL=function(){function t(t){this._format=ec.UNKNOWN,this._formatSize=0,this._chunks=[],this._chunkCount=0,this._handles=[],this._region0=new Jc,this._region1=new Jc,this._region2=new Jc,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=j_[t.format];this._format=t.format,this._formatSize=e.size,this._channels=e.count,this._bufferViewCtor=ef(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,GL(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,GL(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}(),ZL=function(){function t(t,e,i){this._arrayBuffers=[],this._chunkSize=i*(1<>this._entryBits,i=this._entryMask&t;return(this._hasFloat32?this._float32BufferViews:this._uint32BufferViews)[e][i]},e.getTypedArray=function(t,e){var i=(this._chunkMask&t)>>this._entryBits,n=this._entryMask&t,r=e,s=(this._dataType[e]===KL.UINT32?this._uint32BufferViews:this._float32BufferViews)[i][n],a=this._dataMembers[e];return s.subarray(r,r+a)},e.free=function(t){var e=(this._chunkMask&t)>>this._entryBits,i=this._entryMask&t;(this._hasUint32?this._uint32BufferViews:this._float32BufferViews)[e][i].fill(0),this._freeLists[e].push(i)},t}();!function(t){t[t.NODE=0]="NODE",t[t.PASS=1]="PASS",t[t.AABB=2]="AABB",t[t.RENDER2D=3]="RENDER2D"}(JL||(JL={})),function(t){t[t.POSITION=0]="POSITION",t[t.UV=3]="UV",t[t.COLOR=5]="COLOR",t[t.COUNT=9]="COUNT"}($L||($L={}));var eN,iN=((UL={})[$L.POSITION]=KL.FLOAT32,UL[$L.UV]=KL.FLOAT32,UL[$L.COLOR]=KL.UINT32,UL[$L.COUNT]=KL.NEVER,UL),nN=((zL={})[$L.POSITION]=$L.UV-$L.POSITION,zL[$L.UV]=$L.COLOR-$L.UV,zL[$L.COLOR]=$L.COUNT-$L.COLOR,zL[$L.COUNT]=1,zL),rN=new tN(JL.RENDER2D,iN,nN,$L);!function(t){t[t.DIRTY_FLAG=0]="DIRTY_FLAG",t[t.LAYER=1]="LAYER",t[t.WORLD_SCALE=2]="WORLD_SCALE",t[t.WORLD_POSITION=5]="WORLD_POSITION",t[t.WORLD_ROTATION=8]="WORLD_ROTATION",t[t.WORLD_MATRIX=12]="WORLD_MATRIX",t[t.LOCAL_SCALE=28]="LOCAL_SCALE",t[t.LOCAL_POSITION=31]="LOCAL_POSITION",t[t.LOCAL_ROTATION=34]="LOCAL_ROTATION",t[t.COUNT=38]="COUNT"}(eN||(eN={}));var sN,aN=((HL={})[eN.DIRTY_FLAG]=KL.UINT32,HL[eN.LAYER]=KL.UINT32,HL[eN.WORLD_SCALE]=KL.FLOAT32,HL[eN.WORLD_POSITION]=KL.FLOAT32,HL[eN.WORLD_ROTATION]=KL.FLOAT32,HL[eN.WORLD_MATRIX]=KL.FLOAT32,HL[eN.LOCAL_SCALE]=KL.FLOAT32,HL[eN.LOCAL_POSITION]=KL.FLOAT32,HL[eN.LOCAL_ROTATION]=KL.FLOAT32,HL[eN.COUNT]=KL.NEVER,HL),oN=((WL={})[eN.DIRTY_FLAG]=eN.LAYER-eN.DIRTY_FLAG,WL[eN.LAYER]=eN.WORLD_SCALE-eN.LAYER,WL[eN.WORLD_SCALE]=eN.WORLD_POSITION-eN.WORLD_SCALE,WL[eN.WORLD_POSITION]=eN.WORLD_ROTATION-eN.WORLD_POSITION,WL[eN.WORLD_ROTATION]=eN.WORLD_MATRIX-eN.WORLD_ROTATION,WL[eN.WORLD_MATRIX]=eN.LOCAL_SCALE-eN.WORLD_MATRIX,WL[eN.LOCAL_SCALE]=eN.LOCAL_POSITION-eN.LOCAL_SCALE,WL[eN.LOCAL_POSITION]=eN.LOCAL_ROTATION-eN.LOCAL_POSITION,WL[eN.LOCAL_ROTATION]=eN.COUNT-eN.LOCAL_ROTATION,WL[eN.COUNT]=1,WL),hN=new tN(JL.NODE,aN,oN,eN);!function(t){t[t.PRIORITY=0]="PRIORITY",t[t.STAGE=1]="STAGE",t[t.PHASE=2]="PHASE",t[t.PRIMITIVE=3]="PRIMITIVE",t[t.BATCHING_SCHEME=4]="BATCHING_SCHEME",t[t.DYNAMIC_STATE=5]="DYNAMIC_STATE",t[t.HASH=6]="HASH",t[t.COUNT=7]="COUNT"}(sN||(sN={}));var uN,lN=((XL={})[sN.PRIORITY]=KL.UINT32,XL[sN.STAGE]=KL.UINT32,XL[sN.PHASE]=KL.UINT32,XL[sN.PRIMITIVE]=KL.UINT32,XL[sN.BATCHING_SCHEME]=KL.UINT32,XL[sN.DYNAMIC_STATE]=KL.UINT32,XL[sN.HASH]=KL.UINT32,XL[sN.COUNT]=KL.NEVER,XL),cN=((jL={})[sN.PRIORITY]=sN.STAGE-sN.PRIORITY,jL[sN.STAGE]=sN.PHASE-sN.STAGE,jL[sN.PHASE]=sN.PRIMITIVE-sN.PHASE,jL[sN.PRIMITIVE]=sN.BATCHING_SCHEME-sN.PRIMITIVE,jL[sN.BATCHING_SCHEME]=sN.DYNAMIC_STATE-sN.BATCHING_SCHEME,jL[sN.DYNAMIC_STATE]=sN.HASH-sN.DYNAMIC_STATE,jL[sN.HASH]=sN.COUNT-sN.HASH,jL[sN.COUNT]=1,jL),_N=new tN(JL.PASS,lN,cN,sN);!function(t){t[t.CENTER=0]="CENTER",t[t.HALFEXTENTS=3]="HALFEXTENTS",t[t.COUNT=6]="COUNT"}(uN||(uN={}));var fN=((YL={})[uN.CENTER]=KL.FLOAT32,YL[uN.HALFEXTENTS]=KL.FLOAT32,YL[uN.COUNT]=KL.NEVER,YL),dN=((qL={})[uN.CENTER]=uN.HALFEXTENTS-uN.CENTER,qL[uN.HALFEXTENTS]=uN.COUNT-uN.HALFEXTENTS,qL[uN.COUNT]=1,qL),pN=new tN(JL.AABB,fN,dN,uN);lt($R.prototype,"RenderScene.prototype",[{name:"raycastUI2DNode"},{name:"raycastUINode"}]),lt($R.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"}]),lt(RR.prototype,"Model.prototype",[{name:"isInstancingEnabled"},{name:"instancedAttributes"}]);var mN={};lt(mN,"CameraVisFlags",[{name:"GENERAL"}]),ut(mN,"CameraVisFlags",[{name:"PROFILER",newName:"PROFILER",target:dm.BitMask,targetName:"PROFILER"},{name:"GIZMOS",newName:"GIZMOS",target:dm.BitMask,targetName:"GIZMOS"},{name:"EDITOR",newName:"EDITOR",target:dm.BitMask,targetName:"EDITOR"},{name:"UI",newName:"UI",target:dm.BitMask,targetName:"UI_3D"},{name:"UI2D",newName:"UI2D",target:dm.BitMask,targetName:"UI_2D"}]),S.CameraVisFlags=mN;var gN={};lt(gN,"VisibilityFlags",[{name:"GENERAL"}]),ut(gN,"VisibilityFlags",[{name:"ALWALS",newName:"ALWALS",target:dm.Enum,targetName:"ALWALS"},{name:"PROFILER",newName:"PROFILER",target:dm.Enum,targetName:"PROFILER"},{name:"GIZMOS",newName:"GIZMOS",target:dm.Enum,targetName:"GIZMOS"},{name:"EDITOR",newName:"EDITOR",target:dm.Enum,targetName:"EDITOR"},{name:"UI",newName:"UI",target:dm.Enum,targetName:"UI_3D"},{name:"UI2D",newName:"UI2D",target:dm.Enum,targetName:"UI_2D"}]),S.VisibilityFlags=gN,ut(IT.prototype,"Pass.prototype",[{name:"getBindingTypeFromHandle",newName:"getDescriptorTypeFromHandle"}]),lt(sR.prototype,"Camera.prototype",[{name:"getSplitFrustum"},{name:"setMatView"},{name:"setMatViewInv"},{name:"setMatProjInv"},{name:"setMatViewProjInv"},{name:"setMatProj"},{name:"setMatViewProj"},{name:"getMatViewInv"}]),lt(KT.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"}]),lt(jR.prototype,"SpotLight.prototype",[{name:"aspect"}]),ut(oR.prototype,"SubModel.prototype",[{name:"subMeshData",newName:"subMesh"}]),lt(oR.prototype,"SubModel.prototype",[{name:"getSubModel",suggest:"Use `subModels[i]` instead"},{name:"subModelNum",suggest:"Use `subModels.length` instead"}]);var vN,yN,SN,TN=function(t){if(void 0===kL[t]){var e=1<10||(p=.5*(s+o),m=.5*(a+h),g=.5*((c=.5*(e+n))+(f=.5*(n+s))),v=.5*((_=.5*(i+r))+(d=.5*(r+a))),((C=RN((n-o)*(E=h-i)-(r-h)*(b=o-e)))+(x=RN((s-o)*E-(a-h)*b)))*(C+x)=2*bN)l=2*bN;else for(;l<0;)l+=2*bN;else if(RN(l)>=2*bN)l=2*-bN;else for(;l>0;)l-=2*bN;for(h=0|CN(1,EN(RN(l)/(.5*bN)+.5,5)),c=RN(4/3*(1-xN(o=l/h/2))/wN(o)),a||(c=-c),A=0;A<=h;A++)d=e+(_=xN(u=r+l*(A/h)))*n,p=i+(f=wN(u))*n,m=-f*n*c,g=_*n*c,0===A?t.moveTo(d,p):t.bezierCurveTo(v+S,y+T,d-m,p-g,d,p),v=d,y=p,S=m,T=g}(this,t,e,i,n,r,s)},e.ellipse=function(t,e,i,n){BN(this,t,e,i,n),this._curPath.complex=!1},e.circle=function(t,e,i){BN(this,t,e,i,i),this._curPath.complex=!1},e.rect=function(t,e,i,n){this.moveTo(t,e),this.lineTo(t+i,e),this.lineTo(t+i,e+n),this.lineTo(t,e+n),this.close(),this._curPath.complex=!1},e.roundRect=function(t,e,i,n,r){!function(t,e,i,n,r,s){if(s<.1)t.rect(e,i,n,r);else{var a=EN(s,.5*RN(n))*IN(n),o=EN(s,.5*RN(r))*IN(r);t.moveTo(e,i+o),t.lineTo(e,i+r-o),t.bezierCurveTo(e,i+r-o*(1-DN),e+a*(1-DN),i+r,e+a,i+r),t.lineTo(e+n-a,i+r),t.bezierCurveTo(e+n-a*(1-DN),i+r,e+n,i+r-o*(1-DN),e+n,i+r-o),t.lineTo(e+n,i+o),t.bezierCurveTo(e+n,i+o*(1-DN),e+n-a*(1-DN),i,e+n-a,i),t.lineTo(e+a,i),t.bezierCurveTo(e+a*(1-DN),i,e,i+o*(1-DN),e,i+o),t.close()}}(this,t,e,i,n,r),this._curPath.complex=!1},e.clear=function(){this.pathLength=0,this.pathOffset=0,this.pointsOffset=0,this.dataOffset=0,this._curPath=null,this.paths.length=0,this._points.length=0;for(var t=this._renderDataList,e=0,i=t.length;e0){for(var i=0;ii)for(var n=i;n=0&&s.y>=0&&s.x<=n&&s.y<=r;else if(this.type===OF.GRAPHICS_ELLIPSE){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(){this._type!==OF.SPRITE_STENCIL?this._createGraphics():this._createSprite()},i._createSprite=function(){if(!this._sprite){var t=this._sprite=this.node.getComponent(PF);if(!t){var e=this.node;t=this._sprite=e.addComponent(PF)}}this._sprite.stencilStage=this.inverted?qP.ENTER_LEVEL_INVERTED:qP.ENTER_LEVEL,this._sprite.updateMaterial()},i._createGraphics=function(){if(!this._graphics){var t=this._graphics=this.node.getComponent(AF);if(!t){var e=this.node;t=this._graphics=e.addComponent(AF)}t.lineWidth=1;var i=En.WHITE.clone();i.a=0,t.fillColor=i}this._graphics.stencilStage=this.inverted?qP.ENTER_LEVEL_INVERTED:qP.ENTER_LEVEL},i._updateGraphics=function(){if(this._graphics&&(this._type===OF.GRAPHICS_RECT||this._type===OF.GRAPHICS_ELLIPSE)){var t=this.node._uiProps.uiTransformComp,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(this._type===OF.GRAPHICS_RECT)e.rect(a,o,n,r);else if(this._type===OF.GRAPHICS_ELLIPSE){for(var h=function(t,e,i){kF.length=0;for(var n=2*Math.PI/i,r=0;rp?0:d>0?d:p}S.Canvas=Kk,lt(t("U",eo("cc.UIComponent")(Xk=io(wO)(Xk=no(110)(Xk=ro(Xk=function(t){function e(){var e;return(e=t.call(this)||this)._lastParent=null,e.stencilStage=qP.DISABLED,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(){this.node._uiProps.uiComp===this&&(this.node._uiProps.uiComp=null)},i.postUpdateAssembler=function(){},i.markForUpdateRenderData=function(){},i.setNodeDirty=function(){},i.setTextureDirty=function(){},e}(mp))||Xk)||Xk)||Xk)||Xk).prototype,"UIComponent",[{name:"_visibility"},{name:"setVisibility"}]),ut(Kk.prototype,"Canvas.prototype",[{name:"camera",newName:"cameraComponent.camera",customGetter:function(){var t;return null===(t=this._cameraComponent)||void 0===t?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:En.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}}]),ct(wO.prototype,"UITransform.prototype",[{name:"priority",suggest:"Please use setSiblingIndex to change index of the current node in its parent's children array."}]),S.UITransformComponent=wO,ne(wO,"cc.UITransformComponent"),ne(XO,"cc.RenderComponent"),S.CanvasComponent=Kk,ne(Kk,"cc.CanvasComponent"),S.internal.Renderable2D=XO,ne(XO,"cc.Renderable2D");var Zk,Jk,$k,tG,eG,iG,nG,rG=(Zk=Es.create(),Jk={distance:1/0,doubleSided:!1,mode:dl.ANY},$k=0,tG=function(t,e,i,n,r,s){t===dl.CLOSEST?($k>e||0===$k)&&($k=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))):($k=e,s&&s.push({distance:e,vertexIndex0:i/3,vertexIndex1:n/3,vertexIndex2:r/3}))},function(t,e,i){if($k=0,0===e.geometricInfo.positions.length)return $k;var n=void 0===i?Jk:i;if(Qk(t,e.geometricInfo.boundingBox.min,e.geometricInfo.boundingBox.max)){var r=e.primitiveMode,s=e.geometricInfo;!function(t,e,i,n,r){if(i===wc.TRIANGLE_LIST)for(var s=e.length,a=0;ar.distance)&&(tG(r.mode,l,o,h,u,r.result),r.mode===dl.ANY))return l}else if(i===wc.TRIANGLE_STRIP)for(var c=e.length-2,_=0,f=0;fr.distance)&&(tG(r.mode,g,d,p,m,r.result),r.mode===dl.ANY))return g}else if(i===wc.TRIANGLE_FAN){var v=e.length-1,y=3*e[0];gn.set(Zk.a,t[y],t[y+1],t[y+2]);for(var S=1;Sr.distance)&&(tG(r.mode,b,y,T,A,r.result),r.mode===dl.ANY))return b}}}(s.positions,s.indices,r,t,n)}return $k}),sG=function(){var t=0,e={distance:1/0,doubleSided:!1,mode:dl.ANY};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&&!Qk(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),s.mode===dl.ANY)return c}return t&&s.mode===dl.CLOSEST&&(s.result&&(s.result[0].distance=t,s.result.length=1),s.subIndices&&(s.subIndices.length=1)),t}}(),aG=function(){var t=0,e={distance:1/0,doubleSided:!1,mode:dl.ANY},i=new gr,n=new Vn;return function(r,s,a){t=0;var o=void 0===a?e:a,h=s.worldBounds;if(h&&!vs.rayAABB(r,h))return t;gr.copy(i,r),s.node&&(Vn.invert(n,s.node.getWorldMatrix(n)),gn.transformMat4(i.o,r.o,n),gn.transformMat4Normal(i.d,r.d,n));for(var u=s.subModels,l=0;l_)&&(t=_,o.subIndices&&(o.subIndices[0]=l));else if(t=_,o.subIndices&&o.subIndices.push(l),o.mode===dl.ANY)return _}return t&&o.mode===dl.CLOSEST&&(o.result&&(o.result[0].distance=t,o.result.length=1),o.subIndices&&(o.subIndices.length=1)),t}}();vs.rayModel=aG,vs.raySubMesh=rG,vs.rayMesh=sG,ET("specular-pass");var oG,hG,uG,lG,cG,_G,fG,dG,pG,mG,gG,vG,yG,SG,TG,AG,bG,EG=t("dM",eo("cc.ModelRenderer")((iG=function(t){function e(){var e;return(e=t.call(this)||this)._visFlags=nG&&nG(),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 _=1e3,f=1;_&&r0&&(f=d[0].length),s+=f,a=n.substring(r,s),o=n.substring(s),this._calculateSize(h,e,a),_--}for(;_&&a.length>=2&&h.x>c;)s-=f,a=n.substring(r,s),this._calculateSize(h,e,a),f=1,_--;if(a.length>=2){var p=YM(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),_--,u.x<2048&&h.x=0;e--){var i=t[e];if(i.name===$G||i.name===tV){i.parent=null;var n=sV(i.name);n.node=i,i.name===$G?(n.comp=i.getComponent(OL),nV.put(n)):(n.comp=i.getComponent(PF),rV.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!==$G&&i.name!==tV||(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(OL);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._uiProps.uiTransformComp.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=qM(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._uiProps.uiTransformComp.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 tt(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+RM)*this._lineHeight,this.node._uiProps.uiTransformComp.setContentSize(this._labelWidth,this._labelHeight),this._updateRichTextPosition(),this._layoutDirty=!1}},i._getFirstWordLen=function(t,e,i){var n=UM(t,e);if(FM(n)||kM(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 xL.LEFT:break;case xL.CENTER:u-=this._linesWidth[h-1]/2;break;case xL.RIGHT: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._uiProps.uiTransformComp.width),o.node.getComponent(PF)){var c=o.node.position.clone(),_=this._lineHeight,f=this._lineHeight*(1+RM);switch(o.node._uiProps.uiTransformComp.anchorY){case 1:c.y+=_+(f-_)/2;break;case.5:c.y+=f/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 v=o.node.getComponent(OL);if(v&&v.enableOutline){var y=o.node.position.clone();y.y-=v.outlineWidth,o.node.position=y}}},i._convertLiteralColorValue=function(t){var e=t.toUpperCase();return En[e]?En[e]:(new En).fromHEX(t)},i._applyTextAttribute=function(t){var e=t.node.getComponent(OL);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(OL);r||(r=t.node.addComponent(OL)),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 xM&&!this._isSystemFontUsed?e.font=this._font:e.fontFamily=this._fontFamily,e.useSystemFont=this._isSystemFontUsed,e.lineHeight=this._lineHeight,e.updateRenderData(!0)}},i._applyLayer=function(){for(var t,e=f(this._segments);!(t=e()).done;)t.value.node.layer=this.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}(mp)).HorizontalAlign=xL,ZG.VerticalAlign=wL,m((NG=ZG).prototype,"horizontalAlign",[IG],Object.getOwnPropertyDescriptor(NG.prototype,"horizontalAlign"),NG.prototype),m(NG.prototype,"verticalAlign",[DG],Object.getOwnPropertyDescriptor(NG.prototype,"verticalAlign"),NG.prototype),m(NG.prototype,"fontColor",[BG],Object.getOwnPropertyDescriptor(NG.prototype,"fontColor"),NG.prototype),m(NG.prototype,"font",[MG],Object.getOwnPropertyDescriptor(NG.prototype,"font"),NG.prototype),m(NG.prototype,"cacheMode",[PG],Object.getOwnPropertyDescriptor(NG.prototype,"cacheMode"),NG.prototype),m(NG.prototype,"imageAtlas",[OG],Object.getOwnPropertyDescriptor(NG.prototype,"imageAtlas"),NG.prototype),FG=ja(NG.prototype,"_lineHeight",[lo],(function(){return 40})),kG=ja(NG.prototype,"_string",[lo],(function(){return"RichText"})),GG=ja(NG.prototype,"_horizontalAlign",[lo],(function(){return xL.LEFT})),VG=ja(NG.prototype,"_verticalAlign",[lo],(function(){return wL.TOP})),UG=ja(NG.prototype,"_fontSize",[lo],(function(){return 40})),zG=ja(NG.prototype,"_fontColor",[lo],(function(){return En.WHITE.clone()})),HG=ja(NG.prototype,"_maxWidth",[lo],(function(){return 0})),WG=ja(NG.prototype,"_fontFamily",[lo],(function(){return"Arial"})),XG=ja(NG.prototype,"_font",[lo],(function(){return null})),jG=ja(NG.prototype,"_isSystemFontUsed",[lo],(function(){return!0})),YG=ja(NG.prototype,"_userDefinedFont",[lo],(function(){return null})),qG=ja(NG.prototype,"_cacheMode",[lo],(function(){return IL.NONE})),KG=ja(NG.prototype,"_imageAtlas",[lo],(function(){return null})),QG=ja(NG.prototype,"_handleTouchEvent",[lo],(function(){return!0})),LG=NG))||LG)||LG));S.RichText=hV;var uV,lV=t("k",eo("cc.UIMeshRenderer")(oV=no(110)(oV=function(t){function e(){var e;return(e=t.call(this)||this)._modelComponent=null,e._dirtyVersion=-1,e._internalId=-1,e.stencilStage=qP.DISABLED,e._renderData=null,e._renderEntity=new dO(ZP.DYNAMIC),e}s(e,t);var i=e.prototype;return i.__preload=function(){this.node._uiProps.uiComp=this},i.onEnable=function(){gD.addRenderer(this),this.markForUpdateRenderData()},i.onDisable=function(){gD.removeRenderer(this),this.renderEntity.enabled=this._canRender()},i.onLoad=function(){this.node._uiProps.uiTransformComp||this.node.addComponent("cc.UITransform"),this._modelComponent=this.getComponent("cc.ModelRenderer"),this._modelComponent?this.renderEntity.setNode(this.node):tt(16378,this.node?this.node.name:"")},i.onDestroy=function(){this.renderEntity.setNode(null),this.node._uiProps.uiComp===this&&(this.node._uiProps.uiComp=null),this._modelComponent=this.getComponent("cc.ModelRenderer"),this._modelComponent&&(this._modelComponent._sceneGetter=null)},i._render=function(t){if(this._modelComponent){var e=this._modelComponent._collectModels();this._modelComponent._detachFromScene();for(var i=0;i0)for(s=e;s=e;s-=n)a=zV(s,t[s],t[s+1],a);return a&&kV(a,a.next)&&(HV(a),a=a.next),a}function CV(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||!kV(i,i.next)&&0!==FV(i.prev,i,i.next))i=i.next;else{if(HV(i),(i=e=i.prev)===i.next)return null;n=!0}}while(n||i!==e);return e}function xV(t,e,i,n,r,s,a){if(void 0===a&&(a=0),t){!a&&s&&function(t,e,i,n){var r=t;do{null===r.z&&(r.z=PV(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,function(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)}(r)}(t,n,r,s);for(var o=t,h=null,u=null;t.prev!==t.next;)if(h=t.prev,u=t.next,s?RV(t,n,r,s):wV(t))e.push(h.i/i),e.push(t.i/i),e.push(u.i/i),HV(t),t=u.next,o=u.next;else if((t=u)===o){a?1===a?xV(t=IV(t,e,i),e,i,n,r,s,2):2===a&&DV(t,e,i,n,r,s):xV(CV(t),e,i,n,r,s,1);break}}}function wV(t){var e=t.prev,i=t,n=t.next;if(FV(e,i,n)>=0)return!1;for(var r=t.next.next;r!==t.prev;){if(LV(e.x,e.y,i.x,i.y,n.x,n.y,r.x,r.y)&&FV(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function RV(t,e,i,n){var r=t.prev,s=t,a=t.next;if(FV(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=PV(o,h,e,i,n),_=PV(u,l,e,i,n),f=t.nextZ;f&&f.z<=_;){if(f!==t.prev&&f!==t.next&&LV(r.x,r.y,s.x,s.y,a.x,a.y,f.x,f.y)&&FV(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(f=t.prevZ;f&&f.z>=c;){if(f!==t.prev&&f!==t.next&&LV(r.x,r.y,s.x,s.y,a.x,a.y,f.x,f.y)&&FV(f.prev,f,f.next)>=0)return!1;f=f.prevZ}return!0}function IV(t,e,i){var n=t;do{var r=n.prev,s=n.next.next;!kV(r,s)&&GV(r,n,n.next,s)&&VV(r,s)&&VV(s,r)&&(e.push(r.i/i),e.push(n.i/i),e.push(s.i/i),HV(n),HV(n.next),n=t=s),n=n.next}while(n!==t);return n}function DV(t,e,i,n,r,s){var a=t;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&NV(a,o)){var h=UV(a,o);return a=CV(a,a.next),h=CV(h,h.next),xV(a,e,i,n,r,s),void xV(h,e,i,n,r,s)}o=o.next}a=a.next}while(a!==t)}function BV(t,e){return t.x-e.x}function MV(t,e){if(e=function(t,e){var i=e,n=t.x,r=t.y,s=-1/0,a=null;do{if(r<=i.y&&r>=i.next.y){var o=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(o<=n&&o>s){if(s=o,o===n){if(r===i.y)return i;if(r===i.next.y)return i.next}a=i.x=i.x&&i.x>=l&&LV(ra.x)&&VV(i,t)&&(a=i,_=h),i=i.next;return a}(t,e)){var i=UV(e,t);CV(i,i.next)}}function PV(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 OV(t){var e=t,i=t;do{e.x=0&&(t-a)*(n-o)-(i-a)*(e-o)>=0&&(i-a)*(s-o)-(r-a)*(n-o)>=0}function NV(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(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&&GV(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&VV(t,e)&&VV(e,t)&&function(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}(t,e)}function FV(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function kV(t,e){return t.x===e.x&&t.y===e.y}function GV(t,e,i,n){return!!(kV(t,e)&&kV(i,n)||kV(t,n)&&kV(i,e))||FV(t,e,i)>0!=FV(t,e,n)>0&&FV(i,n,t)>0!=FV(i,n,e)>0}function VV(t,e){return FV(t.prev,t,t.next)<0?FV(t,e,t.next)>=0&&FV(t,t.prev,e)>=0:FV(t,e,t.prev)<0||FV(t,t.next,e)<0}function UV(t,e){var i=new bV(t.i,t.x,t.y),n=new bV(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 zV(t,e,i,n){var r=new bV(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 HV(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 WV(t,e,i){i=i||3;var n=e?e.length:0,r=n?e[0]*i:t.length,s=EV(t,0,r,i,!0),a=[];if(!s)return a;var o=0,h=0,u=0,l=0,c=0,_=0,f=0;if(n&&(s=function(t,e,i,n){var r,s=[],a=0,o=null;for(a=0,r=e.length;a80*i){o=u=t[0],h=l=t[1];for(var d=i;du&&(u=c),_>l&&(l=_);f=Math.max(u-o,l-h)}return xV(s,a,i,o,h,f),a}for(var XV=Math.PI,jV=Math.min,YV=Math.max,qV=Math.ceil,KV=Math.acos,QV=Math.cos,ZV=Math.sin,JV=Math.atan2,$V=null,tU=null,eU=new En,iU=[],nU=0;nU<4;nU++)iU.push(new gn);function rU(t,e,i){return ti?i:t}var sU={useModel:!0,updateRenderData:function(){},fillBuffers:function(){},renderIA:function(){},getRenderData:function(t,e){if(!tU)return null;var i=tU.getRenderDataList(),n=i[tU.dataOffset];if(!n)return null;var r=n,s=r?r.vertexStart+e:0;return(s>65535||3*s>131070)&&(++tU.dataOffset,tU.dataOffset0&&(r=1/e);for(var s=t.paths,a=t.pathOffset,o=t.pathLength;a1e-6){var S=1/d;S>600&&(S=600),_.dmx*=S,_.dmy*=S}_.dx*c.dy-c.dx*_.dy>0&&(_.flags|=SN.PT_LEFT),d*(p=YV(11,jV(c.len,_.len)*r))*p<1&&(_.flags|=SN.PT_INNERBEVEL),_.flags&SN.PT_CORNER&&(d*n*n<1||i===yN.BEVEL||i===yN.ROUND)&&(_.flags|=SN.PT_BEVEL),0!=(_.flags&(SN.PT_BEVEL|SN.PT_INNERBEVEL))&&h.bevel++,c=_,_=u[f+1]}}},_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*XV),this._vSet(_,f,1),this._vSet(u-s*n,e.y-a*n,-1);for(var v=rU(qV((m-g)/XV)*r,2,r),y=0;yhU||n.canvasSize.height>hU)&&a<=3;){if(++a>3)this._fontScale=1;else{var o=Math.max(n.canvasSize.width,n.canvasSize.height),h=hU/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;return i*t>this._maxFontSize&&tu?o:u}var l=o,c=(s.length+RM)*this._getLineHeight(e.lineHeight,t.actualFontSize,t.fontSize);i.canvasSize.width=l+i.canvasPadding.width*this._fontScale,i.canvasSize.height=c+i.canvasPadding.height*this._fontScale,i.nodeContentSize.width=(l+i.contentSizeExtend.width*this._fontScale)/this._fontScale,i.nodeContentSize.height=(c+i.contentSizeExtend.height*this._fontScale)/this._fontScale;break;case RL.SHRINK:this._calculateShrinkFont(r,t,e,i),this._calculateWrapText(r,t,e,i),i.canvasSize.width=i.nodeContentSize.width*this._fontScale,i.canvasSize.height=i.nodeContentSize.height*this._fontScale;break;case RL.CLAMP:this._calculateWrapText(r,t,e,i),i.canvasSize.width=i.nodeContentSize.width*this._fontScale,i.canvasSize.height=i.nodeContentSize.height*this._fontScale;break;case RL.RESIZE_HEIGHT:this._calculateWrapText(r,t,e,i);var _=(i.parsedString.length+RM)*this._getLineHeight(e.lineHeight,t.actualFontSize,t.fontSize);i.canvasSize.width=i.nodeContentSize.width*this._fontScale,i.canvasSize.height=_+i.canvasPadding.height*this._fontScale,i.nodeContentSize.height=(_+i.contentSizeExtend.height*this._fontScale)/this._fontScale}}},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;if(i.wrapping){var l=n.nodeContentSize.width*this._fontScale,c=n.nodeContentSize.height*this._fontScale;if(l<0||c<0)return;o=c+1;for(var _=0,f=0|e.actualFontSize+1,d=0;_>1)<=0){Q(4003);break}u=d,r=this._getFontDesc(u,e.fontFamily,e.isBold,e.isItalic),this._context.font=r;var p=this._getLineHeight(i.lineHeight,u,e.fontSize);for(o=0,a=0;ac?f=d-1:_=d}0===_?Q(4003):(u=_,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,a=this._measureText(this._context,i.fontDesc),o=0,h=0,u=0;u0&&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=VM(e);r0&&h>0&&x+d.w*t.bmfontScale>e.maxLineWidth&&!kM(m)){e.linesWidth.push(c),c=0,o++,h=0,u-=e.lineHeight*this._getFontScale(t,e)+0,A=!0;break}b.x=x,b.y=u-d.offsetY*t.bmfontScale,this._recordLetterInfo(b,m,C,o),C+1b.y-d.h*t.bmfontScale&&(y=b.y-d.h*t.bmfontScale)}else this._recordPlaceholderInfo(C,m),null!=t.fntConfig?Q(16354,t.fntConfig.atlasName,m):Q(16355,t.fontFamily,m);else this._recordPlaceholderInfo(C,m)}A||(h=T,_y&&(f=y),l<(c=S)&&(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++}return 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)),i.nodeContentSize.width=e.textWidthTemp,i.nodeContentSize.height=e.textHeightTemp,e.textWidthTemp<=0&&(i.nodeContentSize.width=parseFloat(l.toFixed(2))+2*DP.margin),e.textHeightTemp<=0&&(i.nodeContentSize.height=parseFloat(e.textDesiredHeight.toFixed(2))+2*DP.margin),e.tailoredTopY=i.nodeContentSize.height,e.tailoredBottomY=0,_>0&&(e.tailoredTopY=i.nodeContentSize.height+_),f<-e.textDesiredHeight&&(e.tailoredBottomY=e.textDesiredHeight+f),!0},e._recordPlaceholderInfo=function(t,e){if(t>=this._lettersInfo.length){var i=new lU;this._lettersInfo.push(i)}this._lettersInfo[t].char=e,this._lettersInfo[t].hash=""+zM(e,0)+DP.hash,this._lettersInfo[t].valid=!1},e._recordLetterInfo=function(t,e,i,n){if(i>=this._lettersInfo.length){var r=new lU;this._lettersInfo.push(r)}var s=""+zM(e,0)+DP.hash;this._lettersInfo[i].line=n,this._lettersInfo[i].char=e,this._lettersInfo[i].hash=s,this._lettersInfo[i].valid=DP.fontAtlas.getLetter(s).valid,this._lettersInfo[i].x=t.x,this._lettersInfo[i].y=t.y},e._getFirstWordLen=function(t,e,i,n,r){var s=UM(i,n);if(FM(s)||"\n"===s||kM(s))return 1;var a=1,o=DP.fontAtlas.getLetterDefinitionForChar(s,DP);if(!o)return a;for(var h=o.xAdvance*t.bmfontScale+e.spacingX,u=n+1;ue.maxLineWidth&&!kM(s)&&e.maxLineWidth>0)return a;if(h+=o.xAdvance*t.bmfontScale+e.spacingX,"\n"===s||kM(s)||FM(s))break;a++}return a},e._computeAlignmentOffset=function(t,e,i){switch(e.linesOffsetX.length=0,e.letterOffsetY=0,e.horizontalAlign){case xL.LEFT:for(var n=0;ni.nodeContentSize.height},e._isHorizontalClamp=function(t,e,i,n,r){for(var s=!1,a=0,o=VM(n);a0)if(e.wrapping){if(e.linesWidth[c]>i.nodeContentSize.width&&(l>i.nodeContentSize.width||l<0)){s=!0;break}}else if(l>i.nodeContentSize.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=t.spriteFrame?t.spriteFrame.texture:DP.fontAtlas.getTexture(),o=n.uiTransAnchorX*i.nodeContentSize.width,h=n.uiTransAnchorY*i.nodeContentSize.height,u=0,l=VM(r);u0){if(f>e.tailoredTopY){var d=f-e.tailoredTopY;this._tmpRect.y+=d,this._tmpRect.height-=d,f-=d}f-this._tmpRect.height*t.bmfontScale0&&this._isHorizontalClamped(e,i,m,p)&&e.overFlow===RL.CLAMP&&(this._tmpRect.width=0),this._tmpRect.height>0&&this._tmpRect.width>0){var g=this._determineRect(t),v=c.x+e.linesOffsetX[c.line],y=n.quadCount;n.quadCount+=4,this.updateQuatCount(n),s(t,i,n,y,a,this._tmpRect,g,v-o,f-h)}}else tt(16353)}}return!0},e._isHorizontalClamped=function(t,e,i,n){var r=t.linesWidth[n],s=i>e.nodeContentSize.width||i<0;return t.wrapping?r>e.nodeContentSize.width&&s:s},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;if(i){var h=this._tmpRect.x;this._tmpRect.x=r.x+r.height-this._tmpRect.y-this._tmpRect.height-o,this._tmpRect.y=h+r.y-a,this._tmpRect.y<0&&(this._tmpRect.height+=o)}else this._tmpRect.x+=r.x-a,this._tmpRect.y+=r.y+o;return i},t}();cU.instance=void 0,cU.instance=new cU;var _U=new IP(64,64),fU=new yP(null),dU=null,pU=null,mU=null,gU=null,vU=null,yU={updateProcessingData:function(t,e,i,n,r,s){t.fontSize=r.fontSize,t.actualFontSize=r.fontSize,t.originFontSize=mU?mU.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,a===RL.NONE?(e.wrapping=!1,i.nodeContentSize.width+=2*DP.margin,i.nodeContentSize.height+=2*DP.margin):a===RL.RESIZE_HEIGHT?(e.wrapping=!0,i.nodeContentSize.height+=2*DP.margin):e.wrapping=r.enableWrapText,n.uiTransAnchorX=s.anchorX,n.uiTransAnchorY=s.anchorY,DP.lineHeight=r.lineHeight,DP.fontSize=r.fontSize,t.spriteFrame=gU,t.fntConfig=mU,t.fontFamily=DP.fontFamily,t.color.set(r.color)},updateRenderData:function(t){if(t.renderData&&dU!==t){if(t.renderData.vertDirty){pU=(dU=t).node._uiProps.uiTransformComp;var e=t.renderData,i=cU.instance,n=t.textStyle,r=t.textLayout,s=t.textLayoutData,a=t.textRenderData;n.fontScale=yB.getScaleX(),this._updateFontFamily(t),this.updateProcessingData(n,r,s,a,t,pU),this._updateLabelInfo(t),n.fontDesc=DP.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?(DP.isOutlined=!0,DP.margin=t.outlineWidth,DP.out=t.outlineColor.clone(),DP.out.a=t.outlineColor.a*t.color.a/255):(DP.isOutlined=!1,DP.margin=0)},_getFontFamily:function(t){var e="Arial";return t.useSystemFont?e=t.fontFamily||"Arial":t.font&&(e=t.font._nativeAsset||"Arial"),e},_updateLabelInfo:function(t){DP.fontDesc=this._getFontDesc(),DP.color=t.color,DP.hash=function(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}(DP)},_getFontDesc:function(){return DP.fontSize.toString()+"px "+DP.fontFamily}}),EU=new En(255,255,255,255),CU={createData:function(t){var e=t.requestRenderData();return e.resize(0,0),e},fillBuffers:function(t){if(t.renderData){var e=t.node;EU.a=255*e._uiProps.opacity,Gf(e,0,t.renderData,EU)}},updateColor:function(){}};Xt(CU,bU);var xU=OL.Overflow,wU={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,r.overflow===xU.NONE?e.wrapping=!1:r.overflow===xU.RESIZE_HEIGHT?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||!Ni(r.shadowOffset.x,0)||!Ni(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},getAssemblerData:function(){var t=OL._canvasPool.get();return t.canvas.width=t.canvas.height=1,t},resetAssemblerData:function(t){t&&OL._canvasPool.put(t)},updateRenderData:function(t){if(t.renderData){if(t.renderData.vertDirty){var e=t.node._uiProps.uiTransformComp,i=cU.instance,n=t.textStyle,r=t.textLayout,s=t.textLayoutData,a=t.textRenderData;n.fontScale=yB.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)}},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},updateVertexData:function(){},updateUVs:function(){},_updateFontFamily:function(t){return t.useSystemFont?t.fontFamily||"Arial":t.font&&t.font._nativeAsset||"Arial"},_calDynamicAtlas:function(t,e){if(!(t.cacheMode!==OL.CacheMode.BITMAP||e.canvasSize.width<=0||e.canvasSize.height<=0)){var i=t.ttfSpriteFrame;wB.packToDynamicAtlas(t,i)}},_resetDynamicAtlas:function(t){if(t.cacheMode===OL.CacheMode.BITMAP){var e=t.ttfSpriteFrame;wB.deleteAtlasSpriteFrame(e),e._resetDynamicAtlasFrame()}}},RU=En.WHITE.clone(),IU=Uint16Array.from([0,1,2,1,3,2]),DU={createData:function(t){var e=t.requestRenderData();e.dataLength=4,e.resize(4,6),t.textRenderData.quadCount=4;var i=e.chunk.vb;i[3]=i[21]=i[22]=i[31]=0,i[4]=i[12]=i[13]=i[30]=1;for(var n=5,r=0;r<4;r++)En.toArray(i,RU,n),n+=9;return e.chunk.setIndexBuffer(IU),e},fillBuffers:function(t){for(var e=t.renderData,i=e.chunk,n=e.data,r=t.node,s=i.vb,a=r.worldMatrix,o=e.floatStride,h=0,u=n.length,l=0;l1?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)}},updateUVs:function(t,e,i){var n=t.spriteFrame,r=t.renderData.chunk.vb,s=n.width,a=n.height,o=n.rect,h=0,u=0,l=0,c=0,_=0,f=0,d=0,p=0,m=0,g=0;switch(n.isRotated()?(h=o.x/s,u=(o.y+o.width)/a,l=_=h,d=m=(o.x+o.height)/s,f=g=u,c=p=o.y/a):(h=o.x/s,u=(o.y+o.height)/a,l=d=h,_=m=(o.x+o.width)/s,c=f=u,p=g=o.y/a),t.fillType){case MU.HORIZONTAL:r[3]=l+(_-l)*e,r[4]=c+(f-c)*e,r[12]=l+(_-l)*i,r[13]=c+(f-c)*i,r[21]=d+(m-d)*e,r[22]=p+(g-p)*e,r[30]=d+(m-d)*i,r[31]=p+(g-p)*i;break;case MU.VERTICAL:r[3]=l+(d-l)*e,r[4]=c+(p-c)*e,r[12]=_+(m-_)*e,r[13]=f+(g-f)*e,r[21]=l+(d-l)*i,r[22]=c+(p-c)*i,r[30]=_+(m-_)*i,r[31]=f+(g-f)*i;break;default:it(2626)}},updateVertexData:function(t,e,i){var n=t.renderData.data,r=t.node._uiProps.uiTransformComp,s=r.width,a=r.height,o=r.anchorX*s,h=r.anchorY*a,u=-o,l=-h,c=s-o,_=a-h,f=0;switch(t.fillType){case MU.HORIZONTAL:f=u+(c-u)*i,u+=(c-u)*e,c=f;break;case MU.VERTICAL:f=l+(_-l)*i,l+=(_-l)*e,_=f;break;default:it(2626)}n[0].x=u,n[0].y=l,n[1].x=c,n[1].y=l,n[2].x=u,n[2].y=_,n[3].x=c,n[3].y=_},createData:function(t){var e=t.requestRenderData();e.dataLength=4,e.resize(4,6),e.chunk.setIndexBuffer(OU);for(var i,n=f(e.data);!(i=n()).done;)i.value.z=0;return e},updateWorldVertexData:function(t,e){t.node.getWorldMatrix(PU);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=PU.m03*h+PU.m07*u+PU.m15;l=l?1/l:1,r[s=a*i]=(PU.m00*h+PU.m04*u+PU.m12)*l,r[s+1]=(PU.m01*h+PU.m05*u+PU.m13)*l,r[s+2]=(PU.m02*h+PU.m06*u+PU.m14)*l}},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},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}},NU=2*Math.PI,FU=1e-6,kU=new Vn,GU=[new jn,new jn,new jn,new jn],VU=new Array(4),UU=new Array(8),zU=[new jn,new jn,new jn,new jn],HU=[new jn,new jn,new jn,new jn],WU=new jn,XU=[new jn,new jn,new jn,new jn],jU=null;function YU(t,e,i,n,r,s,a){var o=Math.sin(s);o=Math.abs(o)>FU?o:0;var h=Math.cos(s),u=0,l=0;if(0!==(h=Math.abs(h)>FU?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 _=r.y+u*(e-r.x);a[2].x=e,a[2].y=_}}if(0!==o){if(l=h/o,(n-r.y)*o>0){var f=r.x+l*(n-r.y);a[3].x=f,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 qU(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 KU(t,e,i,n,r){var s=VU,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,QU((i.x-a)/(h-a),(i.y-o)/(u-o),t,e),QU((n.x-a)/(h-a),(n.y-o)/(u-o),t,e+1),QU((r.x-a)/(h-a),(r.y-o)/(u-o),t,e+2)}function QU(t,e,i,n){var r=UU,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 ZU={useModel:!1,createData:function(t){return t.requestRenderData()},updateRenderData:function(t){var e=t.spriteFrame;wB.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*=NU)+(s*=NU);!function(t){var e=t.node._uiProps.uiTransformComp,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=VU;l[0]=a,l[1]=o,l[2]=h,l[3]=u;var c=t.fillCenter,_=WU.x=Math.min(Math.max(0,c.x),1)*(h-a)+a,f=WU.y=Math.min(Math.max(0,c.y),1)*(u-o)+o;GU[0].x=GU[3].x=a,GU[1].x=GU[2].x=h,GU[0].y=GU[1].y=o,GU[2].y=GU[3].y=u;for(var d=0,p=XU;d=NU)i.dataLength=o+3,KU(n,o,WU,GU[u.x],GU[u.y]),o+=3;else{var l=qU(WU,GU[u.x]),c=qU(WU,GU[u.y]);c=a||(l>=r?(i.dataLength=o+3,KU(n,o,WU,GU[u.x],c>=a?HU[h]:GU[u.y]),o+=3):c>r&&(c<=a?(i.dataLength=o+3,KU(n,o,WU,zU[h],GU[u.y]),o+=3):(i.dataLength=o+3,KU(n,o,WU,zU[h],HU[h]),o+=3))),l+=NU,c+=NU}}0===o&&(i.dataLength=0),i.resize(o,o),i.updateRenderData(t,e)}},createQuadIndices:function(t){jU=null,jU=new Uint16Array(t);for(var e=0,i=0;i1?1:p,m=Number.isNaN(m)||m>1?1:m,f=f<0?0:f,d=d<0?0:d,tz[0].x=-a,tz[0].y=-o,tz[1].x=u*p-a,tz[1].y=_*m-o,tz[2].x=tz[1].x+f,tz[2].y=tz[1].y+d,tz[3].x=r-a,tz[3].y=s-o;for(var g=0;g<4;g++)for(var v=0;v<4;v++){var y=4*g+v;y0||t.insetBottom>0||t.insetLeft>0||t.insetRight>0)?2:0}var pz={createData:function(t){return t.requestRenderData()},updateRenderData:function(t){var e=t.renderData,i=t.spriteFrame;if(i&&e&&e.vertDirty){var n=t.node._uiProps.uiTransformComp,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,_=a.height-l-c,f=r-o-h,d=s-l-c;f=f>0?f:0,d=d>0?d:0;var p=0===u?f:f/u,m=0===_?d:d/_,g=dz(i),v=Math.ceil(m+g),y=Math.ceil(p+g);e.dataLength=4*v*y,this.updateVerts(t,f,d,v,y),e.vertexCount!==v*y*4&&(t.renderEntity.colorDirty=!0),e.resize(v*y*4,v*y*6),e.updateRenderData(t,i)}},createQuadIndices:function(t){if(t%6==0){var e=t/6;fz=new Uint16Array(t);for(var i=0,n=0;n1?1:o.width/(p+m),A=o.height/(v+y)>1?1:o.height/(v+y);s=g>0?Math.floor(1e3*e)/1e3%g==0?g:e%g:e,a=S>0?Math.floor(1e3*i)/1e3%S==0?S:i%S:i,_z.length=0,cz=Math.max(n+1,r+1);for(var b=0;b=r?c-f:C*g-f,_z[C].y=C>=n?_-d:C*S-d;else for(var x=0;x1&&x0?p*T-f+g*(x-1):p+e-f:x===r-1?_z[x].x=p*T-f+s+g*(x-2):x>=r&&(_z[x].x=Math.min(p+e+m,c)-f),0===x?_z[x].y=-d:1===x?_z[x].y=y*A-d:x>1&&x0?y*A-d+S*(x-1):y+i-d:x===n-1?_z[x].y=y*A-d+a+S*(x-2):x>=n&&(_z[x].y=Math.min(y+i+v,_)-d);for(var w=0,R=0,I=0,D=0,B=0;BS?i>=(E>0?z:z+1)*S?1:G%1:G;for(var H=0;Hg?e>=(E>0?H:H+1)*g?1:k%1:k,O?(0===E?(V[0]=az.u,V[1]=az.u,V[2]=az.u+(oz.u-az.u)*F,U[0]=nz.v,U[1]=nz.v+(rz.v-nz.v)*N,U[2]=nz.v):(0===z?(V[0]=iz.u,V[1]=iz.u,V[2]=az.u):z0){var h=a.claimedTouchIdList.indexOf(n.getID());if(-1!==h){if(a._handleEventTouch(t),t.type!==kx.TOUCH_END&&t.type!==kx.TOUCH_CANCEL||(_e(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){!function(t,e){for(var i,n,r,s=t.vertexFormat,a=t.chunk.vb,o=0,h=0;h>>0;else if(n.size/n.count==4)for(var c=o+3;c>2}}(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(),iO.sharedManager.exitMask())),e+=1}},e._screenSort=function(t,e){return t.node.getSiblingIndex()-e.node.getSiblingIndex()},e._releaseDescriptorSetCache=function(t){this._descriptorSetCache.releaseDescriptorSetCache(t)},e._createClearModel=function(){if(!this._maskClearModel){this._maskClearMtl=bT.get("default-clear-stencil"),this._maskClearModel=S.director.root.createModel(RR);var t=kP(BP),e=Ff.gfxDevice,i=e.createBuffer(new r_(rc.VERTEX|rc.TRANSFER_DST,oc.DEVICE,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 r_(rc.INDEX|rc.TRANSFER_DST,oc.DEVICE,6*Uint16Array.BYTES_PER_ELEMENT,Uint16Array.BYTES_PER_ELEMENT)),s=new Uint16Array([0,1,2,2,1,3]);r.update(s),this._maskModelMesh=new FD([i],BP,wc.TRIANGLE_LIST,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=iO.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=S.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):it(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):it(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;tjT.LEVEL_1},set:function(t){this._csmLevel=t?jT.LEVEL_4:jT.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,KT.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}(vj),jW=ja(XW.prototype,"_illuminanceHDR",[yj,aW],(function(){return 65e3})),YW=ja(XW.prototype,"_illuminanceLDR",[Sj],(function(){return 65e3*sR.standardExposureValue})),qW=ja(XW.prototype,"_shadowEnabled",[Sj],(function(){return!1})),KW=ja(XW.prototype,"_shadowPcf",[Sj],(function(){return XT.HARD})),QW=ja(XW.prototype,"_shadowBias",[Sj],(function(){return 1e-5})),ZW=ja(XW.prototype,"_shadowNormalBias",[Sj],(function(){return 0})),JW=ja(XW.prototype,"_shadowSaturation",[Sj],(function(){return 1})),$W=ja(XW.prototype,"_shadowDistance",[Sj],(function(){return 50})),tX=ja(XW.prototype,"_shadowInvisibleOcclusionRange",[Sj],(function(){return 200})),eX=ja(XW.prototype,"_csmLevel",[Sj],(function(){return jT.LEVEL_4})),iX=ja(XW.prototype,"_csmLayerLambda",[Sj],(function(){return.75})),nX=ja(XW.prototype,"_csmOptimizationMode",[Sj],(function(){return YT.RemoveDuplicates})),rX=ja(XW.prototype,"_csmAdvancedOptions",[Sj],(function(){return!1})),sX=ja(XW.prototype,"_csmLayersTransition",[Sj],(function(){return!1})),aX=ja(XW.prototype,"_csmTransitionRange",[Sj],(function(){return.05})),oX=ja(XW.prototype,"_shadowFixedArea",[Sj],(function(){return!1})),hX=ja(XW.prototype,"_shadowNear",[Sj],(function(){return.1})),uX=ja(XW.prototype,"_shadowFar",[Sj],(function(){return 10})),lX=ja(XW.prototype,"_shadowOrthoSize",[Sj],(function(){return 5})),m(XW.prototype,"illuminance",[oW],Object.getOwnPropertyDescriptor(XW.prototype,"illuminance"),XW.prototype),m(XW.prototype,"shadowEnabled",[hW,uW],Object.getOwnPropertyDescriptor(XW.prototype,"shadowEnabled"),XW.prototype),m(XW.prototype,"shadowPcf",[lW,cW],Object.getOwnPropertyDescriptor(XW.prototype,"shadowPcf"),XW.prototype),m(XW.prototype,"shadowBias",[_W,fW],Object.getOwnPropertyDescriptor(XW.prototype,"shadowBias"),XW.prototype),m(XW.prototype,"shadowNormalBias",[dW,pW],Object.getOwnPropertyDescriptor(XW.prototype,"shadowNormalBias"),XW.prototype),m(XW.prototype,"shadowSaturation",[mW,gW],Object.getOwnPropertyDescriptor(XW.prototype,"shadowSaturation"),XW.prototype),m(XW.prototype,"shadowDistance",[vW,yW],Object.getOwnPropertyDescriptor(XW.prototype,"shadowDistance"),XW.prototype),m(XW.prototype,"shadowInvisibleOcclusionRange",[SW,TW],Object.getOwnPropertyDescriptor(XW.prototype,"shadowInvisibleOcclusionRange"),XW.prototype),m(XW.prototype,"csmLevel",[AW,bW],Object.getOwnPropertyDescriptor(XW.prototype,"csmLevel"),XW.prototype),m(XW.prototype,"enableCSM",[EW,CW],Object.getOwnPropertyDescriptor(XW.prototype,"enableCSM"),XW.prototype),m(XW.prototype,"csmLayerLambda",[xW,wW],Object.getOwnPropertyDescriptor(XW.prototype,"csmLayerLambda"),XW.prototype),m(XW.prototype,"csmOptimizationMode",[RW,IW],Object.getOwnPropertyDescriptor(XW.prototype,"csmOptimizationMode"),XW.prototype),m(XW.prototype,"shadowFixedArea",[DW,BW],Object.getOwnPropertyDescriptor(XW.prototype,"shadowFixedArea"),XW.prototype),m(XW.prototype,"shadowNear",[MW,PW],Object.getOwnPropertyDescriptor(XW.prototype,"shadowNear"),XW.prototype),m(XW.prototype,"shadowFar",[OW,LW],Object.getOwnPropertyDescriptor(XW.prototype,"shadowFar"),XW.prototype),m(XW.prototype,"shadowOrthoSize",[NW,FW],Object.getOwnPropertyDescriptor(XW.prototype,"shadowOrthoSize"),XW.prototype),m(XW.prototype,"csmAdvancedOptions",[kW,GW],Object.getOwnPropertyDescriptor(XW.prototype,"csmAdvancedOptions"),XW.prototype),m(XW.prototype,"csmLayersTransition",[VW,UW],Object.getOwnPropertyDescriptor(XW.prototype,"csmLayersTransition"),XW.prototype),m(XW.prototype,"csmTransitionRange",[zW,HW],Object.getOwnPropertyDescriptor(XW.prototype,"csmTransitionRange"),XW.prototype),WW=XW))||WW)),Ej=t("af",(cX=eo("cc.SphereLight"),_X=co("_luminance"),fX=Lo(ii),dX=Lo(ii),pX=Lo(mj),mX=Lo(ni),gX=Lo(ni),cX((yX=function(t){function e(){var e;return(e=t.call(this)||this)._size=SX&&SX(),e._luminanceHDR=TX&&TX(),e._luminanceLDR=AX&&AX(),e._term=bX&&bX(),e._range=EX&&EX(),e._lightType=GR,e}return s(e,t),e.prototype._createLight=function(){t.prototype._createLight.call(this),this._type=CR.SPHERE,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 S.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR*OR(this._size):this._luminanceLDR},set:function(t){var e=0;S.director.root.pipeline.pipelineSceneData.isHDR?(this._luminanceHDR=t/OR(this._size),e=this._luminanceHDR):(this._luminanceLDR=t,e=this._luminanceLDR),this._light&&(this._light.luminance=e)}},{key:"luminance",get:function(){return S.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR:this._luminanceLDR},set:function(t){S.director.root.pipeline.pipelineSceneData.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}(vj),SX=ja(yX.prototype,"_size",[lo],(function(){return.15})),TX=ja(yX.prototype,"_luminanceHDR",[lo,_X],(function(){return 1700/OR(.15)})),AX=ja(yX.prototype,"_luminanceLDR",[lo],(function(){return 1700/OR(.15)*sR.standardExposureValue*sR.standardLightMeterScale})),bX=ja(yX.prototype,"_term",[lo],(function(){return mj.LUMINOUS_FLUX})),EX=ja(yX.prototype,"_range",[lo],(function(){return 1})),m(yX.prototype,"luminousFlux",[fX],Object.getOwnPropertyDescriptor(yX.prototype,"luminousFlux"),yX.prototype),m(yX.prototype,"luminance",[dX],Object.getOwnPropertyDescriptor(yX.prototype,"luminance"),yX.prototype),m(yX.prototype,"term",[pX],Object.getOwnPropertyDescriptor(yX.prototype,"term"),yX.prototype),m(yX.prototype,"size",[mX],Object.getOwnPropertyDescriptor(yX.prototype,"size"),yX.prototype),m(yX.prototype,"range",[gX],Object.getOwnPropertyDescriptor(yX.prototype,"range"),yX.prototype),vX=yX))||vX)),Cj=Lo,xj=lo,wj=co,Rj=so,Ij=t("ag",(CX=eo("cc.SpotLight"),xX=wj("_luminance"),wX=Cj(mj),RX=Cj(ni),IX=Rj({group:{name:"DynamicShadowSettings",displayOrder:1}}),DX=Cj(ri),BX=Rj({group:{name:"DynamicShadowSettings",displayOrder:2}}),MX=Cj(XT),PX=Rj({group:{name:"DynamicShadowSettings",displayOrder:3}}),OX=Cj(ni),LX=Rj({group:{name:"DynamicShadowSettings",displayOrder:4}}),NX=Cj(ni),CX((kX=function(t){function e(){var e;return(e=t.call(this)||this)._size=GX&&GX(),e._luminanceHDR=VX&&VX(),e._luminanceLDR=UX&&UX(),e._term=zX&&zX(),e._range=HX&&HX(),e._spotAngle=WX&&WX(),e._angleAttenuationStrength=XX&&XX(),e._shadowEnabled=jX&&jX(),e._shadowPcf=YX&&YX(),e._shadowBias=qX&&qX(),e._shadowNormalBias=KX&&KX(),e._lightType=jR,e}return s(e,t),e.prototype._createLight=function(){if(t.prototype._createLight.call(this),this._type=CR.SPOT,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 S.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR*OR(this._size):this._luminanceLDR},set:function(t){var e=0;S.director.root.pipeline.pipelineSceneData.isHDR?(this._luminanceHDR=t/OR(this._size),e=this._luminanceHDR):(this._luminanceLDR=t,e=this._luminanceLDR),this._light&&(this._light.luminance=e)}},{key:"luminance",get:function(){return S.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR:this._luminanceLDR},set:function(t){S.director.root.pipeline.pipelineSceneData.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=Vi(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}(vj),GX=ja(kX.prototype,"_size",[xj],(function(){return.15})),VX=ja(kX.prototype,"_luminanceHDR",[xj,xX],(function(){return 1700/OR(.15)})),UX=ja(kX.prototype,"_luminanceLDR",[xj],(function(){return 1700/OR(.15)*sR.standardExposureValue*sR.standardLightMeterScale})),zX=ja(kX.prototype,"_term",[xj],(function(){return mj.LUMINOUS_FLUX})),HX=ja(kX.prototype,"_range",[xj],(function(){return 1})),WX=ja(kX.prototype,"_spotAngle",[xj],(function(){return 60})),XX=ja(kX.prototype,"_angleAttenuationStrength",[xj],(function(){return 0})),jX=ja(kX.prototype,"_shadowEnabled",[xj],(function(){return!1})),YX=ja(kX.prototype,"_shadowPcf",[xj],(function(){return XT.HARD})),qX=ja(kX.prototype,"_shadowBias",[xj],(function(){return 1e-5})),KX=ja(kX.prototype,"_shadowNormalBias",[xj],(function(){return 0})),m(kX.prototype,"term",[wX],Object.getOwnPropertyDescriptor(kX.prototype,"term"),kX.prototype),m(kX.prototype,"size",[RX],Object.getOwnPropertyDescriptor(kX.prototype,"size"),kX.prototype),m(kX.prototype,"shadowEnabled",[IX,DX],Object.getOwnPropertyDescriptor(kX.prototype,"shadowEnabled"),kX.prototype),m(kX.prototype,"shadowPcf",[BX,MX],Object.getOwnPropertyDescriptor(kX.prototype,"shadowPcf"),kX.prototype),m(kX.prototype,"shadowBias",[PX,OX],Object.getOwnPropertyDescriptor(kX.prototype,"shadowBias"),kX.prototype),m(kX.prototype,"shadowNormalBias",[LX,NX],Object.getOwnPropertyDescriptor(kX.prototype,"shadowNormalBias"),kX.prototype),FX=kX))||FX));t("ah",(QX=eo("cc.PointLight"),ZX=co("_luminance"),JX=Lo(ii),$X=Lo(ii),tj=Lo(mj),ej=Lo(ni),QX((nj=function(t){function e(){var e;return(e=t.call(this)||this)._luminanceHDR=rj&&rj(),e._luminanceLDR=sj&&sj(),e._term=aj&&aj(),e._range=oj&&oj(),e._lightType=YR,e}return s(e,t),e.prototype._createLight=function(){t.prototype._createLight.call(this),this._type=CR.POINT,this.range=this._range,this._light&&(this._light.luminanceHDR=this._luminanceHDR,this._light.luminanceLDR=this._luminanceLDR)},n(e,[{key:"luminousFlux",get:function(){return S.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR*OR(1):this._luminanceLDR},set:function(t){var e=0;S.director.root.pipeline.pipelineSceneData.isHDR?(this._luminanceHDR=t/OR(1),e=this._luminanceHDR):(this._luminanceLDR=t,e=this._luminanceLDR),this._light&&(this._light.luminance=e)}},{key:"luminance",get:function(){return S.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR:this._luminanceLDR},set:function(t){S.director.root.pipeline.pipelineSceneData.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}(vj),rj=ja(nj.prototype,"_luminanceHDR",[lo,ZX],(function(){return 1700/OR(.15)})),sj=ja(nj.prototype,"_luminanceLDR",[lo],(function(){return 1700/OR(.15)*sR.standardExposureValue*sR.standardLightMeterScale})),aj=ja(nj.prototype,"_term",[lo],(function(){return mj.LUMINOUS_FLUX})),oj=ja(nj.prototype,"_range",[lo],(function(){return 1})),m(nj.prototype,"luminousFlux",[JX],Object.getOwnPropertyDescriptor(nj.prototype,"luminousFlux"),nj.prototype),m(nj.prototype,"luminance",[$X],Object.getOwnPropertyDescriptor(nj.prototype,"luminance"),nj.prototype),m(nj.prototype,"term",[tj],Object.getOwnPropertyDescriptor(nj.prototype,"term"),nj.prototype),m(nj.prototype,"range",[ej],Object.getOwnPropertyDescriptor(nj.prototype,"range"),nj.prototype),ij=nj))||ij)),t("ai",(hj=eo("cc.RangedDirectionalLight"),uj=co("_illuminance"),lj=Lo(ii),hj((_j=function(t){function e(){var e;return(e=t.call(this)||this)._illuminanceHDR=fj&&fj(),e._illuminanceLDR=dj&&dj(),e._lightType=KR,e}return s(e,t),e.prototype._createLight=function(){t.prototype._createLight.call(this),this._type=CR.RANGED_DIRECTIONAL,this._light&&(this._light.illuminanceHDR=this._illuminanceHDR,this._light.illuminanceLDR=this._illuminanceLDR)},n(e,[{key:"illuminance",get:function(){return S.director.root.pipeline.pipelineSceneData.isHDR?this._illuminanceHDR:this._illuminanceLDR},set:function(t){S.director.root.pipeline.pipelineSceneData.isHDR?(this._illuminanceHDR=t,this._light&&(this._light.illuminanceHDR=this._illuminanceHDR)):(this._illuminanceLDR=t,this._light&&(this._light.illuminanceLDR=this._illuminanceLDR))}}]),e}(vj),fj=ja(_j.prototype,"_illuminanceHDR",[so,uj],(function(){return 65e3})),dj=ja(_j.prototype,"_illuminanceLDR",[lo],(function(){return 65e3*sR.standardExposureValue})),m(_j.prototype,"illuminance",[lj],Object.getOwnPropertyDescriptor(_j.prototype,"illuminance"),_j.prototype),cj=_j))||cj)),S.LightComponent=vj,ne(vj,"cc.LightComponent"),S.DirectionalLightComponent=bj,ne(bj,"cc.DirectionalLightComponent"),S.SphereLightComponent=Ej,ne(Ej,"cc.SphereLightComponent"),S.SpotLightComponent=Ij,ne(Ij,"cc.SpotLightComponent"),ut(Ij.prototype,"SpotLight.prototype",[{name:"luminousPower",newName:"luminousFlux",customGetter:function(){return this.luminousFlux},customSetter:function(t){this.luminousFlux=t}}]),ut(Ej.prototype,"SphereLight.prototype",[{name:"luminousPower",newName:"luminousFlux",customGetter:function(){return this.luminousFlux},customSetter:function(t){this.luminousFlux=t}}]),ut(vj.PhotometricTerm,"Light.PhotometricTerm",[{name:"LUMINOUS_POWER",newName:"LUMINOUS_FLUX"}]);var Dj=Symbol("BakeNodeCurves"),Bj=t("fZ",function(){function t(){}return t.getOrExtract=function(e){var i=t.pool.get(e);if(!i||i.samples!==e.sample){i&&S.director.root.dataPoolManager.releaseAnimationClip(e);var n=Math.ceil(e.sample*e.duration)+1,r=e.sample;i=e[Dj](0,r,n),t.pool.set(e,i)}return i},t.destroy=function(e){t.pool.delete(e)},t}());Bj.pool=new Map;var Mj=new Vn;function Pj(t,e,i){for(Vn.identity(i);t!==e;)Vn.fromRTS(Mj,t.rotation,t.position,t.scale),Vn.multiply(i,Mj,i),t=t.parent;return i}var Oj=new c_(dc.POINT,dc.POINT,dc.NONE,pc.CLAMP,pc.CLAMP,pc.CLAMP),Lj=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 Nj(t,e){var i=4/Math.sqrt(e);return 12*Math.ceil(Math.max(480*i,t)/12)}new Bn,new Bn,new gn,new Bn,new gn;var Fj=new gn,kj=new gn,Gj=new gn,Vj=new gn,Uj=new Vn,zj=new Vn,Hj=new Ra,Wj=Number.MAX_SAFE_INTEGER,Xj=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=function(t){return t.getFormatFeatures(ec.RGBA32F)&cc.SAMPLED_TEXTURE?ec.RGBA32F:ec.RGBA8}(this._device);this._formatSize=j_[e].size,this._pixelsPerJoint=48/this._formatSize,this._pool=new QL(t),this._pool.initialize({format:e,roundUpFn:Nj}),this._customPool=new QL(t),this._customPool.initialize({format:e,roundUpFn:Nj})}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=Bj.getOrExtract(e),h=0;h0;){t=Yj[--i],Yj[i]=null;var r=t.node;Vn.fromRTS(t.local,r.rotation,r.position,r.scale),n=Vn.multiply(t.world,n,t.local)}return n}function Qj(t,e){for(var i,n=null,r=0;t!==e;){var s=t.uuid;if(qj.has(s)){n=qj.get(s);break}n={node:t,local:new Vn,world:new Vn,stamp:-1,parent:null},qj.set(s,n),Yj[r++]=n,t=t.parent,n=null}for(;r>0;)i=Yj[--r],Yj[r]=null,i.parent=n,n=i;return n}function Zj(t){for(var e=qj.get(t.uuid)||null;e;)qj.delete(e.node.uuid),e=e.parent}var Jj=[{name:"CC_USE_SKINNING",value:!0},{name:"CC_USE_REAL_TIME_JOINT_TEXTURE",value:!1}],$j=[{name:"CC_USE_SKINNING",value:!0},{name:"CC_USE_REAL_TIME_JOINT_TEXTURE",value:!0}];function tY(t,e,i,n){for(var r=0;r=0&&(e.push(r),t.push(a))}}var eY=new gn,iY=new gn,nY=new gn,rY=new gn,sY=new Vn,aY=new Ra,oY=function(){this._format=yd.RGBA32F,this._textures=[],this._buffers=[]};oY.WIDTH=256,oY.HEIGHT=3;var hY,uY,lY,cY,_Y,fY,dY,pY,mY,gY,vY,yY,SY,TY,AY,bY,EY,CY,xY,wY,RY,IY,DY,BY,MY,PY,OY,LY,NY,FY,kY,GY,VY=function(t){function e(){var e;return(e=t.call(this)||this)._buffers=[],e._dataArray=[],e._joints=[],e._bufferIndices=null,e._realTimeJointTexture=new oY,e._realTimeTextureMode=!1,e.type=vR.SKINNING,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(UY):UY},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}(TH),HY=t("aj",(hY=eo("cc.SkinnedMeshRenderer"),uY=no(100),lY=Lo(rW),cY=Lo(hg),_Y=Lo(rW),fY=Lo(hg),hY(dY=uY((pY=function(t){function e(){var e;return(e=t.call(this)||this)._skeleton=mY&&mY(),e._skinningRoot=gY&&gY(),e._clip=null,e.associatedAnimation=null,e._modelType=zY,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?zY:VY;(e||this._modelType!==i)&&(this._modelType=i,this._model&&(S.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===VY&&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}(VH),mY=ja(pY.prototype,"_skeleton",[lY],(function(){return null})),gY=ja(pY.prototype,"_skinningRoot",[cY],(function(){return null})),m(pY.prototype,"skeleton",[_Y],Object.getOwnPropertyDescriptor(pY.prototype,"skeleton"),pY.prototype),m(pY.prototype,"skinningRoot",[fY],Object.getOwnPropertyDescriptor(pY.prototype,"skinningRoot"),pY.prototype),dY=pY))||dY)||dY)),WY=new T_(Uc.ATTR_BATCH_ID,ec.R32F),XY=new T_(Uc.ATTR_BATCH_UV,ec.RG32F),jY=j_[WY.format].size+j_[XY.format].size,YY=t("al",(vY=eo("cc.SkinnedMeshUnit"),yY=Lo(ZB),SY=Lo(rW),TY=Lo(zT),AY=Lo(HY),vY((EY=function(){function t(){this.mesh=CY&&CY(),this.skeleton=xY&&xY(),this.material=wY&&wY(),this._localTransform=RY&&RY(),this._offset=IY&&IY(),this._size=DY&&DY()}return n(t,[{key:"offset",get:function(){return this._offset},set:function(t){jn.copy(this._offset,t)}},{key:"size",get:function(){return this._size},set:function(t){jn.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&&Pj(t.node,t.skinningRoot,this._localTransform))}}]),t}(),CY=ja(EY.prototype,"mesh",[yY],(function(){return null})),xY=ja(EY.prototype,"skeleton",[SY],(function(){return null})),wY=ja(EY.prototype,"material",[TY],(function(){return null})),RY=ja(EY.prototype,"_localTransform",[lo],(function(){return new Vn})),IY=ja(EY.prototype,"_offset",[lo],(function(){return new jn(0,0)})),DY=ja(EY.prototype,"_size",[lo],(function(){return new jn(1,1)})),m(EY.prototype,"copyFrom",[AY],Object.getOwnPropertyDescriptor(EY.prototype,"copyFrom"),EY.prototype),bY=EY))||bY)),qY=new Vn;new Vn;var KY,QY,ZY,JY,$Y,tq,eq,iq,nq,rq,sq,aq,oq,hq,uq,lq,cq,_q=new gn,fq=t("ak",(BY=eo("cc.SkinnedMeshBatchRenderer"),MY=no(100),PY=Lo([si]),OY=Lo([YY]),BY(LY=MY((NY=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r=nc.SAMPLER1D){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(Vn.multiply(new Vn,r.bindposes[a]||Vn.IDENTITY,qY))},a=0;at[i]?1:t[e]0&&f.copyBuffersToTexture(s,_,a),n.length>0&&f.copyTexImagesToTexture(n,_,r)},i.createTexture=function(t){var e=new lm;return e.setFilters(Td.LINEAR,Td.LINEAR),e.setMipFilter(Td.NEAREST),e.reset({width:this.atlasSize,height:this.atlasSize,format:yd.RGBA8888}),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:yd.RGBA8888})},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?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?H("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 pq),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=dq[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 z("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):(z("eraseLOD error, LOD not exist at specified index."),null)},i.getLOD=function(t){return t<0||t>=this.lodCount?(z("getLOD error, index out of range"),null):this._LODs[t]},i.setLOD=function(t,e){t<0||t>=this.lodCount?z("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 gn,e=new gn,i=null,n=new gn,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;t.probeType===cR.PLANAR&&(i=this._usePlanarModels);for(var n,r=f(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=f(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=f(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(VH);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(VH);n&&(n.updateProbePlanarMap(e),i?(n.updateReflectionProbeId(i.getProbeId()),n.updateReflectionProbeDataMap(this._dataTexture)):n.updateReflectionProbeId(-1))},e._isUsedBlending=function(t){return t.reflectionProbeType===pR.BLEND_PROBES||t.reflectionProbeType===pR.BLEND_PROBES_AND_SKYBOX},e._updateBlendProbeInfo=function(t,e,i){var n=t.node;if(n){var r=n.getComponent(VH);r&&(i?(r.updateReflectionProbeBlendId(i.getProbeId()),r.updateProbeBlendCubemap(i.cubemap),r.updateReflectionProbeBlendWeight(this._calculateBlendWeight(t,e,i))):(r.updateReflectionProbeBlendId(-1),t.reflectionProbeType===pR.BLEND_PROBES_AND_SKYBOX&&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(VH);n&&n.updateProbeBlendCubemap(e.cubemap)}},e._calculateBlendWeight=function(t,e,i){if(i){var n=gn.distance(t.node.worldPosition,e.node.worldPosition),r=gn.distance(t.node.worldPosition,i.node.worldPosition);return 1-r/(n+r)}return t.reflectionProbeType===pR.BLEND_PROBES?0:t.reflectionProbeType===pR.BLEND_PROBES_AND_SKYBOX?this._calculateBlendOfSkybox(t.worldBounds,e.boundingBox):0},e._calculateBlendOfSkybox=function(t,e){if(!t)return 1;var i=new gn,n=new gn,r=new gn,s=new gn;if(gn.subtract(i,t.center,t.halfExtents),gn.add(n,t.center,t.halfExtents),gn.subtract(r,e.center,e.halfExtents),gn.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 gn;gn.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,_=i.z-a.z<=s.z&&n.z-a.z>=r.z,f=[];if(!o){var d=n.x-s.x;f.push(d/a.x)}if(!h){var p=Math.abs(i.x-r.x);f.push(p/a.x)}if(!u){var m=n.y-s.y;f.push(m/a.y)}if(!l){var g=Math.abs(i.y-r.y);f.push(g/a.y)}if(!c){var v=n.z-s.z;f.push(v/a.z)}if(!_){var y=Math.abs(i.z-r.z);f.push(y/a.z)}return f.length>0?(f.sort((function(t,e){return e-t})),f[0]):0}return 1},n(t,[{key:"updateForRuntime",get:function(){return this._updateForRuntime},set:function(t){this._updateForRuntime=t}}]),t}());function vq(t){return void 0===(t=t||{}).includeNormal&&(t.includeNormal=!0),void 0===t.includeUV&&(t.includeUV=!0),t}gq.probeManager=void 0,gq.probeManager=new gq,S.internal.reflectionProbeManager=gq.probeManager;var yq=new gn,Sq=new gn,Tq=new gn,Aq=new gn,bq=new gn,Eq=new gn,Cq=new gn,xq=new gn,wq=new gn,Rq=new gn,Iq=new gn,Dq=new gn,Bq=new gn(0,0,0),Mq=new gn(0,0,0);function Pq(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 _=new Array(c),f=new Array(3*l),d=new Array(3*l),p=new Array(2*l),m=Math.max(t,e),g=new gn(-m,-r,-m),v=new gn(m,r,m),y=Math.sqrt(m*m+r*r),S=0,T=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,v=0;v<=s;++v){var y=v/s,A=y*h,b=Math.sin(A),E=Math.cos(A);f[3*S]=g*b,f[3*S+1]=m*i-r,f[3*S+2]=g*E,gn.normalize(Bq,gn.set(Mq,b,-u,E)),d[3*S]=Bq.x,d[3*S+1]=Bq.y,d[3*S+2]=Bq.z,p[2*S]=2*(1-y)%1,p[2*S+1]=m,c.push(S),++S}n.push(c)}for(var C=0;C0&&A(!1),t>0&&A(!0)),{positions:f,normals:d,uvs:p,indices:_,minPos:g,maxPos:v,boundingRadius:y};function A(i){for(var n=i?t:e,a=i?1:-1,o=S,u=1;u<=s;++u)f[3*S]=0,f[3*S+1]=r*a,f[3*S+2]=0,d[3*S]=0,d[3*S+1]=a,d[3*S+2]=0,p[2*S]=.5,p[2*S+1]=.5,++S;for(var l=S,c=0;c<=s;++c){var m=c/s*h,g=Math.cos(m),v=Math.sin(m);f[3*S]=n*v,f[3*S+1]=r*a,f[3*S+2]=n*g,d[3*S]=0,d[3*S+1]=a,d[3*S+2]=0,p[2*S]=.5-.5*v*a,p[2*S+1]=.5+.5*g,++S}for(var y=0;y0&&(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:wc.TRIANGLE_FAN}},translate:function(t,e){for(var i=e.x||0,n=e.y||0,r=e.z||0,s=Math.floor(t.positions.length/3),a=0;ah?h<<16|o:o<<16|h;void 0===r[u]&&(r[u]=0,n.push(o,h))}return t.indices=n,t.primitiveMode=wc.LINE_LIST,t},wireframe:function(t){for(var e=[[0,1],[1,2],[2,0]],i=[],n={},r=0;ro?o<<16|a:a<<16|o;void 0===n[h]&&(n[h]=0,i.push(a,o))}return i},invWinding:function(t){for(var e=[],i=0;i=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(wK.PLAY,this),null===(t=this._clipEmbeddedPlayerEval)||void 0===t||t.notifyHostPlay(this.current)},i.onStop=function(){var t;this.isPaused||this._onPauseOrStop(),this.emit(wK.STOP,this),null===(t=this._clipEmbeddedPlayerEval)||void 0===t||t.notifyHostStop()},i.onResume=function(){var t;this._onReplayOrResume(),this.emit(wK.RESUME,this),null===(t=this._clipEmbeddedPlayerEval)||void 0===t||t.notifyHostPlay(this.current)},i.onPause=function(){var t;this._onPauseOrStop(),this.emit(wK.PAUSE,this),null===(t=this._clipEmbeddedPlayerEval)||void 0===t||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 RK(e),this.repeatCount>1&&(0|e.iterations)>(0|t.iterations)&&this.emit(wK.LASTFRAME,this),t.set(e)),e.stopped&&(this.stop(),this.emit(wK.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)),(e&hl.Reverse)===hl.Reverse&&(i=!i),i},i.getWrappedInfo=function(t,e){e=e||new RK;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=this._wrapMode&hl.ShouldWrap;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)||void 0===e||e.sample(t.ratio,t.direction,t.iterations)},i._sampleEmbeddedPlayers=function(t){var e;null===(e=this._clipEmbeddedPlayerEval)||void 0===e||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(){DK().addAnimation(this)},i._onPauseOrStop=function(){DK().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,t&hl.Loop?this.repeatCount=1/0:this.repeatCount=1,null===(e=this._clipEventEval)||void 0===e||e.setWrapMode(t)}},{key:"repeatCount",get:function(){return this._repeatCount},set:function(t){this._repeatCount=t;var e=this._wrapMode&hl.ShouldWrap,i=(this.wrapMode&hl.Reverse)===hl.Reverse;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)||void 0===e||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}(xK));S.AnimationState=OK,eo("cc.animation.EmbeddedAnimationClipPlayable")((BK=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 SQ(new su)})))}}}]),e}(yQ),vQ=ja(gQ.prototype,"_channels",[bQ],(function(){return[]})),gQ));var EQ,CQ,xQ,wQ,RQ,IQ,DQ,BQ,MQ,PQ,OQ,LQ,NQ,FQ,kQ,GQ,VQ,UQ,zQ=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)tt(3941,t.name,e);else{var r=t.passes[e],s=r.getHandle(i);if(s){if(IT.getTypeFromHandle(s)1}return!1}(r,i)?{set:function(t){r.setUniformArray(a,t)}}:{set:function(t){r.setUniform(a,t)}}:void tt(3943,t.name,e,i,n)}var o=IT.getBindingFromHandle(s),h=r.properties[i],u=h&&h.value?""+h.value+xy(h.type):Cy(h.type),l=bT.get(u);return l||(z("Illegal texture default value: "+u+"."),l=bT.get("default-texture")),{set:function(t){t||(t=l);var e=t.getGFXTexture();e&&e.width&&e.height&&(r.bindTexture(o,e),t instanceof Xd&&r.bindSampler(o,Ff.gfxDevice.getSampler(t.getSamplerInfo())))}}}tt(3942,t.name,e,i)}}else tt(3940,t)},t}(),xQ=ja(CQ.prototype,"passIndex",[lo],(function(){return 0})),wQ=ja(CQ.prototype,"uniformName",[lo],(function(){return""})),RQ=m(CQ.prototype,"channelIndex",[Mo],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){}}),EQ=CQ))||EQ,WQ=eo("cc.animation.MorphWeightValueProxy")((DQ=function(){function t(){this.subMeshIndex=BQ&&BQ(),this.shapeIndex=MQ&&MQ()}return t.prototype.forTarget=function(t){var e=this;return{set:function(i){t.setWeight(i,e.subMeshIndex,e.shapeIndex)}}},t}(),BQ=ja(DQ.prototype,"subMeshIndex",[lo],(function(){return 0})),MQ=ja(DQ.prototype,"shapeIndex",[lo],(function(){return 0})),IQ=DQ))||IQ,XQ=eo("cc.animation.MorphWeightsValueProxy")((OQ=function(){function t(){this.subMeshIndex=LQ&&LQ()}return t.prototype.forTarget=function(t){var e=this;return{set:function(i){t.setWeights(i,e.subMeshIndex)}}},t}(),LQ=ja(OQ.prototype,"subMeshIndex",[lo],(function(){return 0})),PQ=OQ))||PQ,jQ=eo("cc.animation.MorphWeightsAllValueProxy")(NQ=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?void 0:n.struct.primitives.length)&&void 0!==i?i:0,s=0;s2?i-2:0),r=2;r>0)},set:function(t){t?this._flags|=1:this._flags&=-2}},{key:"resetMode",get:function(){return(6&this._flags)>>1},set:function(t){this._flags&=-7,this._flags|=t<<1}}]),t}(),FZ=ja(NZ.prototype,"_flags",[lo],(function(){return 0})),LZ=NZ))||LZ,iJ=function(t){function e(e,i){var n;return(n=t.call(this,dZ.TRIGGER)||this).resetMode=kZ.AFTER_CONSUMED,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}(VZ),nJ=eo("cc.animation.Vec3Variable")((WZ=function(){function t(){this._value=XZ&&XZ()}return t.prototype[GZ]=function(){return new rJ(this.value)},n(t,[{key:"type",get:function(){return dZ.VEC3_experimental}},{key:"value",get:function(){return this._value},set:function(t){gn.copy(this._value,t)}}]),t}(),XZ=ja(WZ.prototype,"_value",[lo],(function(){return new gn})),HZ=WZ))||HZ,rJ=function(t){function e(e){var i;return(i=t.call(this,dZ.VEC3_experimental)||this)._value=new gn,gn.copy(i._value,e),i}s(e,t);var i=e.prototype;return i.getValue=function(){return this._value},i.setValue=function(t){gn.copy(this._value,t)},e}(VZ),sJ=eo("cc.animation.QuatVariable")((YZ=function(){function t(){this._value=qZ&&qZ()}return t.prototype[GZ]=function(){return new aJ(this._value)},n(t,[{key:"type",get:function(){return dZ.QUAT_experimental}},{key:"value",get:function(){return this._value},set:function(t){Bn.copy(this._value,t)}}]),t}(),qZ=ja(YZ.prototype,"_value",[lo],(function(){return new Bn})),jZ=YZ))||jZ,aJ=function(t){function e(e){var i;return(i=t.call(this,dZ.QUAT_experimental)||this)._value=new Bn,Bn.copy(i._value,e),i}s(e,t);var i=e.prototype;return i.getValue=function(){return this._value},i.setValue=function(t){Bn.copy(this._value,t)},e}(VZ),oJ=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)),hJ=function(t){function e(e){return t.call(this,"Graph variable "+e+" is not defined")||this}return s(e,t),e}(l(Error)),uJ=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)),lJ=Ms.Flags.Destroyed,cJ=Ms.Flags.PersistentMask,_J=[];function fJ(t){var e;if(Ps(t)){if(function(t){return"function"==typeof t._instantiate}(t))return S.game._isCloning=!0,e=t._instantiate(null,!0),S.game._isCloning=!1,e;if(t instanceof S.Asset)throw new TypeError(at(6903))}return S.game._isCloning=!0,e=dJ(t),S.game._isCloning=!1,e}function dJ(t,e){var i;pJ(t,i=t._iN$t?t._iN$t:t.constructor?new(0,t.constructor):Object.create(null),e);for(var n=0,r=_J.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 JJ(e.inputPath,t)}))},i._emplaceBinding=function(t){var e=this._bindings.findIndex((function(e){return JJ(e.inputPath,t.inputPath)}));e>=0?this._bindings[e]=t:this._bindings.push(t)},e}(Yo),WJ=ja(HJ.prototype,"_bindings",[lo],(function(){return[]})),zJ=HJ))||zJ;function JJ(t,e){var i=t[0],n=t[1],r=e[0],s=e[1];return i===r&&n===s}var $J,t$=eo("cc.animation.PoseGraphNodeInputBinding")((jJ=function(){function t(t,e,i){this._inputPath=YJ&&YJ(),this._producer=qJ&&qJ(),this._outputIndex=KJ&&KJ(),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}(),YJ=ja(jJ.prototype,"_inputPath",[lo],null),qJ=ja(jJ.prototype,"_producer",[lo],null),KJ=ja(jJ.prototype,"_outputIndex",[lo],(function(){return 0})),XJ=jJ))||XJ,e$=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)),i$=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));!function(t){t[t.FLOAT=0]="FLOAT",t[t.INTEGER=1]="INTEGER",t[t.BOOLEAN=2]="BOOLEAN",t[t.VEC3=3]="VEC3",t[t.QUAT=4]="QUAT",t[t.POSE=5]="POSE"}($J||($J={}));var n$=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e}(Yo),r$=new WeakMap;function s$(t){return function(e){if(Kt(e,n$)||(H("This kind of decorator should only be applied to pose graph node classes."),0)){var i=function(t){var e=r$.get(t);if(e)return e;var i={};return r$.set(t,i),i}(e);t(i)}}}var a$=function(t){return s$((function(e){var i;Object.assign(null!==(i=e.appearance)&&void 0!==i?i:e.appearance={},t)}))},o$=["arraySyncGroup"];function h$(t,e,i,n){var r=t.getShell(e);if(!r)throw new i$(e);var s=i[0],a=i[1],o=void 0===a?-1:a,h=e[s];Array.isArray(h)&&(h.splice(o,0,n),r.moveArrayElementBindingForward(s,o+1,!1))}function u$(t,e,i){var n=t.getShell(e);if(!n)throw new i$(e);var r=i[0],s=i[1],a=void 0===s?-1:s,o=e[r];Array.isArray(o)&&(a<0||a>=o.length||(n.deleteBinding(i),o.splice(a,1),n.moveArrayElementBindingForward(r,a+1,!0)))}function l$(t){switch(t){default:case $J.FLOAT:case $J.INTEGER:return 0;case $J.BOOLEAN:return!1;case $J.POSE:return null;case $J.VEC3:return new gn;case $J.QUAT:return new Bn}}var c$,_$=new(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=function(t,e){if(null==t)return{};var i,n,r={},s=Object.keys(t);for(n=0;n=0||(r[i]=t[i]);return r}(i,o$),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(qt(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?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=qt(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):u$(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):h$(t,e,[n,a],l$(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(qt(t),e)}},e._insertInputInArraySyncGroup=function(t,e,i,n,r){for(var s=0;sr)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 _=n[c],f=a.indexOf(_);a[o]=_,o=f}a[o]=t,Wl(n,r,s)}},e.copyTo=function(t){for(var e,i=f(t._states.filter((function(e){switch(e){case t._entryState:case t._exitState:case t._anyState:return!0;default:return!1}})));!(e=i()).done;){var n=e.value;t.remove(n)}for(var r,s=new Map,a=f(this._states);!(r=a()).done;){var o=r.value;switch(o){case this._entryState:s.set(o,t._entryState);break;case this._exitState:s.set(o,t._exitState);break;case this._anyState:s.set(o,t._anyState);break;default:if(o instanceof kJ||o instanceof f1||o instanceof a1||o instanceof h1){if(o instanceof a1&&!t._allowEmptyStates)continue;var h=fJ(o);t._addState(h),s.set(o,h)}}}for(var u,l=f(this._transitions);!(u=l()).done;){var c=u.value;if(t._allowEmptyStates||!(c.from instanceof a1||c.to instanceof a1)){var _=s.get(c.from),d=s.get(c.to),p=t.connect(_,d);p.conditions=c.conditions.map((function(t){return t.clone()})),c.copyTo(p)}}},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}(Yo),D0=ja(I0.prototype,"_states",[lo],(function(){return[]})),B0=ja(I0.prototype,"_transitions",[lo],(function(){return[]})),M0=ja(I0.prototype,"_entryState",[lo],null),P0=ja(I0.prototype,"_exitState",[lo],null),O0=ja(I0.prototype,"_anyState",[lo],null),R0=I0))||R0,f1=eo("cc.animation.SubStateMachine")((N0=function(t){function e(e){var i;return(i=t.call(this)||this)._stateMachine=F0&&F0(),i._stateMachine=new _1(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}(xJ),F0=ja(N0.prototype,"_stateMachine",[lo],null),L0=N0))||L0,d1=eo("cc.animation.PoseGraphStash")((G0=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r1e-6){n=!1;break}this._findRatio=n?E1:Va}return t.prototype.sample=function(t){return this._findRatio(this.ratios,t)},t}());S.RatioSampler=S1;var T1=t("aw",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 b1(t,e){if("string"==typeof e){var i=qh[e];i?t=i(t):it(3906,e)}else Array.isArray(e)&&(t=Vu(e,t));return t}function E1(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=S2(t,e);a=h.index,o=h.ratio}var u=0,l=0;if(i=s)u=n-1,l=0;else{var c=S2(t,i);u=c.index,l=c.ratio}var _=!o,f=!l;a!==u||o!==l?(_||(this.preLerpIndex=a,this.preLerpRatio=o),this.directKeyframesBegin=_?a:a+1,this.directKeyframesEnd=u+1,f||(this.postLerpIndex=u,this.postLerpRatio=l)):_?(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 T2,A2=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}(),b2=function(){function t(t,e,i,n,r){this._position=null,this._rotation=null,this._scale=null,e&&(this._position=L2(e.times,e.values,gn,t,"position",r)),i&&(this._rotation=L2(i.times,i.values,Bn,t,"rotation",r)),n&&(this._scale=L2(n.times,n.values,gn,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}(),E2=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=function(t,e,i){var n=t.length,r=t[0],s=t[n-1];if(es)i.just=!0,i.index=n-1;else{var a=Va(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}(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}(),C2=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;i=0){var _=u.substring(0,c),f=h[_];f&&(l.parent=f)}}for(var d=this._createEvalWithBinder(void 0,(function(t){var e=t.parseTrsPath();if(e){var i=h[e.node];if(i)return A3(i,e.property)}}),void 0),p=0;p=0&&this._embeddedPlayers.splice(e,1)},i[l3]=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 n3).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){me(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<=_?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 f=t-c;a.instantiatedPlayer.setTime(f)}}}},e.notifyHostSpeedChanged=function(t){for(var e=this._embeddedPlayers,i=this._embeddedPlayerEvaluationInfos,n=e.length,r=0;r0?((s&hl.PingPong)===hl.PingPong?e*=-1:h=n,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=i&hl.ShouldWrap;c&&(l=function(t,e){var i=!1;return(t&hl.PingPong)===hl.PingPong&&(e-(0|e)==0&&e>0&&(e-=1),1&e&&(i=!i)),(t&hl.Reverse)===hl.Reverse&&(i=!i),i}(i,o));var _=l?-1:1;return r&&(_*=-1),c&&l&&(t=e-t),s.time=t,s.ratio=s.time/e,s.direction=_,s.stopped=a,s.iterations=o,s}(o,r,h,(h&hl.Loop)===hl.Loop?1/0:1,!1,this._wrapInfo),l=u.ratio*s,c=a.evaluate(l,e);return null===(i=this._frameEventEval)||void 0===i||i.sample(u.ratio,u.direction,u.iterations),null===(n=this._clipEmbeddedPlayerEval)||void 0===n||n.evaluate(l,Math.trunc(u.iterations)),c},e.overrideClips=function(t){var e,i=this._originalClip,n=null===(e=t.clipOverrides)||void 0===e?void 0:e.get(i);n&&this._setClip(n,t)},e.reenter=function(){var t;null===(t=this._frameEventEval)||void 0===t||t.reset()},e._setClip=function(t,e){var i;null===(i=this._clipEval)||void 0===i||i.destroy(),this._frameEventEval=null,this._clipEmbeddedPlayerEval&&(this._clipEmbeddedPlayerEval.destroy(),this._clipEmbeddedPlayerEval=null),this._clip=t,this._duration=0===t.speed?0:t.duration/t.speed,this._clipEval=function(t,e){return t.isAdditive_experimental?new _5(t,e):new c5(t,e)}(t,e),this._frameEventEval=t.createEventEvaluator(e.origin),!this._ignoreEmbeddedPlayers&&t.containsAnyEmbeddedPlayer()&&(this._clipEmbeddedPlayerEval=t.createEmbeddedPlayerEvaluator(e.origin))},n(t,[{key:"duration",get:function(){return this._duration}}]),t}(),g5=function(){function t(t){this._eval=void 0,this._eval=t}var e=t.prototype;return e.evaluate=function(t,e){return this._eval[p5](t,e)},e.reenter=function(){this._eval.reenter()},t}(),v5=eo,y5=lo,S5=v5("cc.animation.AnimationBlendItem")((H3=function(){function t(){this.motion=W3&&W3()}var e=t.prototype;return e.clone=function(){var e=new t;return this._copyTo(e),e},e._copyTo=function(t){var e,i;return t.motion=null!==(e=null===(i=this.motion)||void 0===i?void 0:i.clone())&&void 0!==e?e:null,t},t}(),W3=ja(H3.prototype,"motion",[y5],(function(){return null})),z3=H3))||z3,T5=v5("cc.animation.AnimationBlend")((j3=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r=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}}(t,this._thresholds,i)},e}(A5),F5=(D5=new jn,B5={wA:0,wB:0},function(t,e,i){if(t.length,e.length,0!==e.length)if(1!==e.length)if(jn.strictEquals(i,jn.ZERO)){var n=e.findIndex((function(t){return jn.strictEquals(t,jn.ZERO)}));n>=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=(E=e[r],C=e[s],x=i,w=B5,(R=jn.cross(E,C))?(w.wA=jn.cross(x,C)/R,w.wB=jn.cross(x,E)/-R):(w.wA=0,w.wB=0),w),g=m.wA,v=m.wB,y=0,S=0,T=g+v;T>1?(y=g/T,S=v/T):T<0?(y=0,S=0,p=1):(y=g,S=v,p=1-T),t[r]=y,t[s]=S}if(p>0)if(a>=0)t[a]=p;else for(var A=p/t.length,b=0;b0)for(var L=0;L0&&t.forEach((function(e,i){return t[i]=e/a}))}(t,e,i,q5)}(t,this._thresholds,this._value)}},e}(A5),u4=function(t){function e(e,i,n,r,s,a){var o;return(o=t.call(this,e,i,n,r,a)||this)._interpolator=void 0,o._value=new jn,o._interpolator=s,o.doEval(),o}return s(e,t),e.prototype.eval=function(t,e){var i=e[0],n=e[1];jn.set(this._value,i,n),t.fill(0),this._interpolator.interpolate(t,this._value)},e}(A5),l4=eo,c4=lo,_4=l4("cc.animation.AnimationBlendDirectItem")((e4=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),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[H4];this._pages.length,e===this._pages.length&&this._pushNewPage(),this._pages.length;var i=this._pages[e];return++i.useCount,++t[H4],i},e.popPage=function(t){var e=t[H4]-1,i=this._pages[e];i.useCount,--i.useCount,--t[H4],0===i.useCount&&(this._pages.length,this._pages.pop())},e.createAllocator=function(t){var e=new q4(this,t);return++this._allocatorCount,e},e.destroyAllocator=function(t){for(var e=t[H4],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 j4(this,i),this._stacks.set(i,n)),n.createAllocator(e)},e[W4]=function(t){for(var e,i=f(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=Va(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}(),Q4=function(){function t(t,e){this._poses=[],this._allocatedCount=0,this._memoryAllocator=void 0,this._transformCount=t,this._auxiliaryCurveCount=e;var i=Z4(t,e,1);this._memoryAllocator=$4.createAllocator(i)}var e=t.prototype;return e.destroy=function(){this._allocatedCount;for(var t=0;t>_6},set:function(t){this._id&=c6,this._id|=t<<_6}},{key:"poseIndex",get:function(){return this._id&c6},set:function(t){this._id&=~c6,this._id|=t}}]),t}(),c6=7,_6=3,f6=function(){function t(t,e,i){this._buffer=void 0,this._idleFlags=15,this._poses=void 0,this._freeCount=0,this._transformCount=t,this._metaValueCount=e,this._capacity=i;var n=(z4.BYTES_PER_ELEMENT*t+Float64Array.BYTES_PER_ELEMENT*e)*i;this._buffer=new ArrayBuffer(n),this._poses=new Array(i).fill(null),this._freeCount=i}var e=t.prototype;return e.tryAllocate=function(){var t,e=this._poses,i=this._idleFlags,n=this._capacity,r=function(t){return 0===t?1/0:Math.log2(t&-t)}(i);if(r>=n)return null;r>=0&&e.length;var s=null!==(t=e[r])&&void 0!==t?t:e[r]=this._createPose(r);return s[h6].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 T6(new O6(this,r),t);return e.push(s),s.handle},e.createEvaluationContext=function(){return this._bindStarted,new M6(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=f(this._transformRecords);!(e=r()).done;){var s=e.value,a=s.node,o=s.handle,h=u(i,a);if(void 0===h)H(a.getPathInHierarchy()+" is not a child of "+i.getPathInHierarchy());else if(t.isExcluded(h))continue;n.push(o.index)}return n.sort(),new w$(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(A6(t),t.length!==this._transformCountBeforeBind){i|=p6.TRANSFORM_COUNT;for(var n=t.length,r=0;r=0?n:-1}else{var r=t.findIndex((function(t){return t.node===i}));u[_]=r}},_=0;_0}));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,D6),s=e.getTransform(n,B6);v$.calculateRelative(r,r,s),e.setTransform(i,r)}}t._poseTransformSpace=A$.LOCAL},e._convertPoseSpaceTransformToTargetSpace=function(t,e,i,n){var r=i._poseTransformSpace;switch(e){default:break;case J4.WORLD:r===A$.COMPONENT?v$.multiply(t,this._getComponentToWorldTransform(),t):(A$.LOCAL,v$.multiply(t,this._getLocalToWorldTransform(B6,i,n),t));break;case J4.COMPONENT:r===A$.COMPONENT||(A$.LOCAL,v$.multiply(t,this._getLocalToComponentTransform(B6,i,n),t));break;case J4.PARENT:if(r===A$.COMPONENT){var s=this._parentTable[n];if(s>=0){var a=i.transforms.getTransform(s,B6),o=v$.invert(a,a);v$.multiply(t,o,t)}}else A$.LOCAL;break;case J4.LOCAL:r===A$.COMPONENT||A$.LOCAL;var h=i.transforms.getTransform(n,B6),u=v$.invert(h,h);v$.multiply(t,u,t)}return t},e._convertTransformToPoseTransformSpace=function(t,e,i,n){var r=i._poseTransformSpace;switch(e){default:break;case J4.WORLD:if(r===A$.COMPONENT){var s=v$.invert(B6,this._getComponentToWorldTransform());v$.multiply(t,s,t)}else{A$.LOCAL;var a=this._getLocalToWorldTransform(B6,i,n),o=v$.invert(a,a);v$.multiply(t,o,t)}break;case J4.COMPONENT:if(r===A$.COMPONENT);else{A$.LOCAL;var h=this._getLocalToComponentTransform(B6,i,n),u=v$.invert(h,h);v$.multiply(t,u,t)}break;case J4.PARENT:if(r===A$.COMPONENT){var l=this._parentTable[n];if(l>=0){var c=i.transforms.getTransform(l,B6);v$.multiply(t,c,t)}}break;case J4.LOCAL:r===A$.COMPONENT||A$.LOCAL;var _=i.transforms.getTransform(n,B6);v$.multiply(t,_,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;v$.setIdentity(t);for(var r=n[i];r>=0;r=n[r]){var s=e.transforms.getTransform(r,D6);v$.multiply(t,s,t)}return t},e._getLocalToWorldTransform=function(t,e,i){return this._getLocalToComponentTransform(t,e,i),v$.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}(),P6=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}(),O6=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}(),L6=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}(),N6=function(){function t(){this._allocator=null}var e=t.prototype;return e._reset=function(t,e){this._allocator=new u6(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}(),F6=eo,k6=lo;!function(t){t[t.TRUTHY=0]="TRUTHY",t[t.FALSY=1]="FALSY"}(w6||(w6={})),F6("cc.animation.UnaryCondition")(((x6=function(){function t(){this.operator=E6&&E6(),this.operand=C6&&C6()}var e=t.prototype;return e.clone=function(){var e=new t;return e.operator=this.operator,e.operand=this.operand.clone(),e},e[v1]=function(t){var e=this.operator,i=this.operand,n=new V6(e,!1),r=R5(t,i,dZ.BOOLEAN,n.setOperand,n);return n.reset(r),n},t}()).Operator=w6,E6=ja((b6=x6).prototype,"operator",[k6],(function(){return w6.TRUTHY})),C6=ja(b6.prototype,"operand",[k6],(function(){return new w5})),b6));var G6,V6=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 w6.TRUTHY:this._result=!!t;break;case w6.FALSY:this._result=!t}},t}();!function(t){t[t.FLOAT=0]="FLOAT",t[t.INTEGER=3]="INTEGER"}(G6||(G6={}));var U6,z6=function(){},H6=function(){for(var t=arguments.length,e=new Array(t),i=0;ir;case p8.GREATER_THAN_OR_EQUAL_TO:return n>=r}},t}(),V8=lo,U8=eo("cc.animation.TriggerCondition")((S8=function(){function t(){this.trigger=T8&&T8()}var e=t.prototype;return e.clone=function(){var e=new t;return e.trigger=this.trigger,e},e[v1]=function(t){var e=new z8(!1),i=t.getVar(this.trigger);return I5(i,this.trigger)&&(function(t,e){if(t!==dZ.TRIGGER)throw new uJ(e,"trigger")}(i.type,this.trigger),e.setTrigger(i.bind(e.setTrigger,e))),e},t}(),T8=ja(S8.prototype,"trigger",[V8],(function(){return""})),y8=S8))||y8,z8=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}(),H8=eo("cc.animation.StateMachineComponent")(A8=function(){function t(){}var e=t.prototype;return e.onMotionStateEnter=function(){},e.onMotionStateExit=function(){},e.onMotionStateUpdate=function(){},e.onStateMachineEnter=function(){},e.onStateMachineExit=function(){},t}())||A8,W8=eo("cc.animation.MotionSyncInfo")((E8=function(){this.group=C8&&C8()},C8=ja(E8.prototype,"group",[lo],(function(){return""})),b8=E8))||b8,X8=1e-5,j8=(x8=eo("cc.animation.PoseNodePlayMotion"),"i18n:ENGINE.animation_graph.pose_graph_node_sub_categories.pose_nodes/",w8=s$((function(t){t.category="i18n:ENGINE.animation_graph.pose_graph_node_sub_categories.pose_nodes/"})),R8=function(t){return s$((function(e){e.factory=t}))}((k8=function(t){var e=new j8;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 d5;break;case"animation-blend-1d":e=new L5;break;case"animation-blend-2d":e=new o4}return k8(e)}})),I8=a$({themeColor:"#227F9B"}),D8=X$({type:$J.FLOAT}),B8=X$({type:$J.FLOAT}),x8(M8=w8(M8=R8(M8=I8((P8=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;rX8&&(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?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?void 0:e.normalizedTime)&&void 0!==t?t:0}}]),e}(H$),O8=ja(P8.prototype,"motion",[lo],(function(){return new d5})),L8=ja(P8.prototype,"syncInfo",[lo],(function(){return new W8})),N8=m(P8.prototype,"startTime",[lo,D8],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 0}}),F8=m(P8.prototype,"speedMultiplier",[lo,B8],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){return 1}}),M8=P8))||M8)||M8)||M8)||M8),Y8=function(t,e){this.normalizedTime=0,this.lastIndicativeWeight=0,this.motionEval=t,this.motionEvalPort=e};function q8(t){return t instanceof H$||t instanceof W$}var K8=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)||void 0===e||e.bind(t)},e.settle=function(t){var e;null===(e=this._rootPoseNode)||void 0===e||e.settle(t)},e.reenter=function(){var t;null===(t=this._rootPoseNode)||void 0===t||t.reenter()},e.update=function(t){var e;null===(e=this._rootPoseNode)||void 0===e||e.update(t)},e.evaluate=function(t){var e,i;return null!==(e=null===(i=this._rootPoseNode)||void 0===i?void 0:i.evaluate(t,L$.LOCAL))&&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 Q8(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 K8(void 0,i?[]:void 0);var s=r[0];s.outputIndex,s.producer;var a=new Map,o=Z8(t,s.producer,a,e);return new K8(o,i?Array.from(a.values()).filter((function(t){return t instanceof j8})):void 0)}function Z8(t,e,i,n){var r=t.getShell(e),s=i.get(e);if(s)return s;var a=fJ(e);"__callOnAfterDeserializeRecursive"in a&&a.__callOnAfterDeserializeRecursive(),a instanceof W$&&a.link(n);for(var o,h=a,u=[],l=f(r.getBindings());!(o=l()).done;){var c=o.value,_=c.producer,d=c.outputIndex,p=c.inputPath;if(q8(_)){var m=Z8(t,_,i,n);if(m instanceof H$)t7(h,p,m,d);else{var g=r7(h,p,m,d);g&&u.push(g)}}else z("There's a input bound to a node with unrecognized type.")}var v,y=new J8(u);return h instanceof H$?(h._setDependencyEvaluation(y),v=h):v=new $8(h,y),i.set(e,v),v}var J8=function(){function t(t){this._bindingEvaluations=void 0,this._bindingEvaluations=t}return t.prototype.evaluate=function(){for(var t,e=f(this._bindingEvaluations);!(t=e()).done;)t.value.evaluate()},t}(),$8=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 t7(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 z("Invalid binding: consumer node's input "+r+" should be leaved as evaluation before evaluation."):void(t[r]=i);Array.isArray(o)?a>=o.length?z("Invalid binding: consumer node's input "+r+" have length "+o.length+" but the binding specified "+a):null===o[a]?o[a]=i:z("Invalid binding: consumer node's input "+r+"["+a+"] should be leaved as null before evaluation"):z("Invalid binding: consumer node's input "+r+" should be an array.")}else z("Node "+i.toString()+" does not have specified output "+n+".");else z("Invalid binding: consumer node has no property "+r)}var e7,i7=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}(),n7=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 r7(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 i7(t,r,i,n);if(Array.isArray(o)){if(!(a>=o.length))return new n7(t,r,a,i,n);z("Invalid binding: consumer node's input "+r+" have length "+o.length+" but the binding specified "+a)}else z("Invalid binding: consumer node's input "+r+" should be an array.")}else z("Invalid binding: consumer node has no property "+r)}var s7=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=A7.createPool(4),this._updateContextGenerator=new L6,this._conditionEvaluationContext=new T7,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){tt(14e3,16,"");break}var r=this._matchNextTransition(i);if(!r)break;var s=r.to,a=i;if(i=s,a7(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 g7,v7=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}(c7),y7=function(t){function e(e){var i;return(i=t.call(this,e)||this).kind=o7.empty,i}return s(e,t),e}(c7),S7=function(t){function e(e,i){var n;(n=t.call(this,e)||this).kind=o7.procedural,n.elapsedTime=0,n.statusCache={progress:0},n._instantiatedPoseGraph=void 0,n._statusCache={progress:0},n._elapsedTime=0;var r=Q8(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=m7(this._elapsedTime),this._statusCache},i.countMotionTime=function(){return this._instantiatedPoseGraph.countMotionTime()},e}(_7),T7=function(){function t(){this.sourceStateWeight=0,this._sourceState=void 0}var e=t.prototype;return e.set=function(t){this._sourceState=t,a7(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&&(t.kind===o7.animation||t.kind===o7.procedural)&&t.activeReferenceCount,t.kind){case o7.animation:return t.normalizedTime;case o7.procedural:return t.countMotionTime();default:return 0}}}]),t}(),A7=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(a7(e)){var i=this.getAbsoluteDuration(e);if(i<=0)this.normalizedElapsedTime=1;else{var n=this.normalizedElapsedTime*i,r=i-n,s=ki((n+Math.min(r,t))/i);this.normalizedElapsedTime=s}}else this.normalizedElapsedTime=1},t.createPool=function(e){return new ws((function(){return new t}),e,void 0)},e.reset=function(t,e){var i=e.to;a7(i),this.normalizedElapsedTime=0,this.destination=i,this.path=[].concat(t,[e]);var n=i.activeReferenceCount;if(i.increaseActiveReference(),0===n)if(i.kind===o7.animation){var r=this.path[0],s=r.destinationStart,a=r.relativeDestinationStart?s:0===i.duration?0:s/i.duration;i.reenter(a)}else i.kind===o7.procedural&&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?(t.kind===o7.animation?t.duration:1)*i:i},n(t,[{key:"done",get:function(){return Ni(this.normalizedElapsedTime,1,1e-6)}}]),t}(),b7=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 E7(e),this._groups.push(i)),i.addMember()},e.sync=function(){for(var t,e=f(this._groups);!(t=e()).done;)t.value.sync()},t}(),E7=function(){function t(t){this._lastLeader=void 0,this._records=[],this.name=t}var e=t.prototype;return e.addMember=function(){var t=new C7;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&&r&U7.POSITION&&(e=a.result),o&&r&U7.SCALE&&(i=o.result),u&&r&U7.EULER_ANGLES&&(n=u.result),h&&r&U7.ROTATION&&(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}()),K7=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.prototype.createNodeBlendState=function(){return new q7},e}(z7),Q7=t("aA",eo(((X7=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r=0?this._crossFades.fastRemoveAt(e):it(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):it(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&&Qj(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}(zs(mp))).EventType=wK,m((n9=o9).prototype,"clips",[$7],Object.getOwnPropertyDescriptor(n9.prototype,"clips"),n9.prototype),m(n9.prototype,"defaultClip",[t9],Object.getOwnPropertyDescriptor(n9.prototype,"defaultClip"),n9.prototype),r9=ja(n9.prototype,"playOnLoad",[lo],(function(){return!1})),s9=ja(n9.prototype,"_clips",[e9],(function(){return[]})),a9=ja(n9.prototype,"_defaultClip",[lo],(function(){return null})),i9=n9))||i9)||i9));function f9(t,e){return t===e||!!t&&!!e&&t._uuid===e._uuid&&t._uuid}S.Animation=_9,S.AnimationComponent=_9,ne(_9,"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"}(h9||(h9={})),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"}(u9||(u9={})),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"}(l9||(l9={}));var d9,p9=t("aF",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()}(t);var i=t._operationQueue[0];i&&g9(t,i)})).catch((function(){})))}function v9(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=Fi(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}(),C9=new(function(){function t(){this._audioBufferDataMap={}}var e=t.prototype;return e.addCache=function(t,e){this._audioBufferDataMap[t]?console.warn("Audio buffer "+t+" has been cached"):this._audioBufferDataMap[t]={usedCount:1,audioBuffer:e}},e.retainCache=function(t){var e=this._audioBufferDataMap[t];e?e.usedCount++:console.warn("Audio buffer cache "+t+" has not been added.")},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]:console.warn("Audio buffer cache "+t+" has not been added.")},t}()),x9=window.AudioContext||window.webkitAudioContext||window.mozAudioContext,w9="on-context-running",R9=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 Hs,this._context.onstatechange=function(){"running"===t._context.state?(t._isRunning=!0,t._eventTarget.emit(w9)):t._isRunning=!1}}var e=t.prototype;return e.onceRunning=function(t,e){this._eventTarget.once(w9,t,e)},e.offRunning=function(t,e){this._eventTarget.off(w9,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(i.resume().catch((function(t){z("runContext error",t)})),"running"!==i.state){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){z("onGesture resume error",t)}))};null==n||n.addEventListener("touchend",r,{capture:!0}),null==n||n.addEventListener("mouseup",r,{capture:!0})}else e();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}();R9.support=!!x9,R9.support&&(T9=new R9);var I9,D9,B9,M9,P9=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=T9.createBufferSource(t,!1);var n=T9.createGain(e);this._bufferSourceNode.connect(n),T9.connectContext(n)}var e=t.prototype;return e.play=function(){var t=this;this._bufferSourceNode.start(),T9.runContext().then((function(){var e;null===(e=t.onPlay)||void 0===e||e.call(t),t._currentTimer=window.setTimeout((function(){var e;C9.tryReleasingCache(t._url),null===(e=t.onEnd)||void 0===e||e.call(t)}),1e3*t._duration)})).catch((function(t){z("play error",t)}))},e.stop=function(){clearTimeout(this._currentTimer),C9.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}(),O9=(m((S9=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=l9.INIT,this._audioTimer=void 0,this._runningCallback=void 0,this._eventTarget=new Hs,this._operationQueue=[],this._audioBuffer=t,this._audioTimer=new E9(t),this._gainNode=T9.createGain(),T9.connectContext(this._gainNode),this._src=e,EB.on(bB.EVENT_PAUSE,this._onInterruptedBegin,this),EB.on(bB.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),C9.tryReleasingCache(this._src),EB.off(bB.EVENT_PAUSE,this._onInterruptedBegin,this),EB.off(bB.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=C9.getCache(t);if(n)return C9.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?T9.decodeAudioData(r.response).then((function(i){C9.addCache(t,i),e(i)})).catch((function(e){z("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 P9(t,i,e);n(r)})).catch(r)}))},e.getPCMData=function(t){return new p9(this._audioBuffer.getChannelData(t),1)},e._onInterruptedBegin=function(){var t=this;this._state===l9.PLAYING&&this.pause().then((function(){t._state=l9.INTERRUPTED,t._eventTarget.emit(h9.INTERRUPTION_BEGIN)})).catch((function(t){z("_onInterruptedBegin error",t)}))},e._onInterruptedEnd=function(){var t=this;this._state===l9.INTERRUPTED&&this.play().then((function(){t._eventTarget.emit(h9.INTERRUPTION_END)})).catch((function(t){z("_onInterruptedEnd error",t)}))},e.offRunning=function(){this._runningCallback&&(T9.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===l9.PLAYING?e._doPlay().then(i).catch((function(t){z("seek error",t)})):i()}))},e.play=function(){return this.offRunning(),this._doPlay()},e._doPlay=function(){var t=this;return new Promise((function(e){T9.isRunning?(t._startSourceNode(),e()):(t.offRunning(),t._runningCallback=function(){t._startSourceNode(),e()},T9.onceRunning(t._runningCallback),T9.runContext().catch((function(t){z("doPlay error",t)})))}))},e._startSourceNode=function(){var t=this;this._stopSourceNode(),this._sourceNode=T9.createBufferSource(this._audioBuffer,this.loop),this._sourceNode.connect(this._gainNode),this._sourceNode.loop=this._loop,this._sourceNode.start(0,this._audioTimer.currentTime),this._state=l9.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(h9.ENDED),t._state=l9.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===l9.PLAYING&&this._sourceNode?(this._audioTimer.pause(),this._state=l9.PAUSED,window.clearTimeout(this._currentTimer),this._stopSourceNode(),Promise.resolve()):Promise.resolve()},e.stop=function(){return this.offRunning(),this._sourceNode?(this._audioTimer.stop(),this._state=l9.STOPPED,window.clearTimeout(this._currentTimer),this._stopSourceNode(),Promise.resolve()):(this._audioTimer.stop(),this._state=l9.STOPPED,Promise.resolve())},e.onInterruptionBegin=function(t){this._eventTarget.on(h9.INTERRUPTION_BEGIN,t)},e.offInterruptionBegin=function(t){this._eventTarget.off(h9.INTERRUPTION_BEGIN,t)},e.onInterruptionEnd=function(t){this._eventTarget.on(h9.INTERRUPTION_END,t)},e.offInterruptionEnd=function(t){this._eventTarget.off(h9.INTERRUPTION_END,t)},e.onEnded=function(t){this._eventTarget.on(h9.ENDED,t)},e.offEnded=function(t){this._eventTarget.off(h9.ENDED,t)},n(t,[{key:"sampleRate",get:function(){return this._audioBuffer.sampleRate}},{key:"src",get:function(){return this._src}},{key:"type",get:function(){return u9.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=ki(t),this._volume=t,T9.setGainValue(this._gainNode,t)}},{key:"duration",get:function(){return this._audioBuffer.duration}},{key:"currentTime",get:function(){return this._audioTimer.currentTime}}]),t}()).prototype,"seek",[v9],Object.getOwnPropertyDescriptor(S9.prototype,"seek"),S9.prototype),m(S9.prototype,"play",[v9],Object.getOwnPropertyDescriptor(S9.prototype,"play"),S9.prototype),m(S9.prototype,"pause",[v9],Object.getOwnPropertyDescriptor(S9.prototype,"pause"),S9.prototype),m(S9.prototype,"stop",[v9],Object.getOwnPropertyDescriptor(S9.prototype,"stop"),S9.prototype),S9),L9=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}(),N9=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)!==u9.DOM_AUDIO&&R9.support?O9.load(e).then((function(e){n(new t(e))})).catch(r):(R9.support||tt(5201),b9.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)!==u9.DOM_AUDIO&&R9.support?O9.loadNative(t):(R9.support||tt(5201),b9.loadNative(t))},t.loadOneShotAudio=function(t,e,i){return new Promise((function(n,r){(null==i?void 0:i.audioLoadMode)!==u9.DOM_AUDIO&&R9.support?O9.loadOneShotAudio(t,e).then((function(t){n(new L9(t))})).catch(r):(R9.support||tt(5201),b9.loadOneShotAudio(t,e).then((function(t){n(new L9(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}();N9.maxAudioChannel=24;var F9=t("aE",eo("cc.AudioClip")(((M9=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r-1?(t[i].playTime=performance.now(),!1):(t.push({audio:e,playTime:performance.now()}),!0)},e.addPlaying=function(t){t instanceof N9?this._tryAddPlaying(this._audioPlayerInfoList,t):this._tryAddPlaying(this._oneShotAudioInfoList,t)},e._tryRemovePlaying=function(t,e){var i=this._findIndex(t,e);return-1!==i&&(fe(t,i),!0)},e.removePlaying=function(t){t instanceof N9?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;)n+="/",n+=i[r];return n}(this,t)},t}();function rit(t,e){e.descriptorID=t.n(),e.type=t.n(),e.count=t.n()}function sit(t,e){var i;e.type=t.n(),e.visibility=t.n(),e.offset=t.n(),e.capacity=t.n(),i=t.n(),e.descriptors.length=i;for(var n=0;n!==i;++n){var r=new Wet;rit(t,r),e.descriptors[n]=r}}function ait(t,e){e.slot=t.n(),e.capacity=t.n(),e.uniformBlockCapacity=t.n(),e.samplerTextureCapacity=t.n();var i=0;i=t.n(),e.descriptorBlocks.length=i;for(var n=0;n!==i;++n){var r=new Xet;sit(t,r),e.descriptorBlocks[n]=r}i=t.n();for(var s=0;s!==i;++s){var a=t.n(),o=new f_;utt(t,o),e.uniformBlocks.set(a,o)}i=t.n();for(var h=0;h!==i;++h){var u=t.n(),l=t.n();e.bindingMap.set(u,l)}}function oit(t,e){ait(t,e.descriptorSetLayoutData),function(t,e){var i=t.n();e.bindings.length=i;for(var n=0;n!==i;++n){var r=new P_;ltt(t,r),e.bindings[n]=r}}(t,e.descriptorSetLayoutInfo)}function hit(t,e){var i;i=t.n();for(var n=0;n!==i;++n){var r=t.n(),s=new Yet;oit(t,s),e.descriptorSets.set(r,s)}}function uit(t,e){var i;i=t.n();for(var n=0;n!==i;++n){var r=t.n(),s=t.n();e.descriptorBindings.set(r,s)}}function lit(t,e){var i=0;i=t.n();for(var n=0;n!==i;++n){var r=t.n(),s=new jet;ait(t,s),e.layoutData.set(r,s)}i=t.n();for(var a=0;a!==i;++a){var o=t.n(),h=new Ket;uit(t,h),e.bindingData.set(o,h)}}function cit(t,e){var i;i=t.n(),e.passes.length=i;for(var n=0;n!==i;++n){var r=new Qet;lit(t,r),e.passes[n]=r}}function _it(t,e){var i;i=t.n();for(var n=0;n!==i;++n){var r=t.s(),s=new Zet;cit(t,s),e.techniques.set(r,s)}}function fit(t,e){hit(t,e.layout)}function dit(t,e){var i;i=t.n();for(var n=0;n!==i;++n){var r=t.n(),s=t.n();e.descriptorVisibility.set(r,s)}}function pit(t,e){e.rootSignature=t.s();var i=0;i=t.n(),e.shaderPrograms.length=i;for(var n=0;n!==i;++n){var r=new $et;fit(t,r),e.shaderPrograms[n]=r}i=t.n();for(var s=0;s!==i;++s){var a=t.s(),o=t.n();e.shaderIndex.set(a,o)}}function mit(t,e){var i=t.n();t.n(),t.n(),t.n();for(var n=0;n!==i;++n){var r=t.n(),s=t.n(),a=t.s(),o=t.n(),h=new qet;switch(hit(t,h),r){case 0:var u=new tit;dit(t,u),e.addVertex(0,u,a,o,h,s);break;case 1:var l=new eit;pit(t,l),e.addVertex(1,l,a,o,h,s)}}var c=0;c=t.n(),e.valueNames.length=c;for(var _=0;_!==c;++_)e.valueNames[_]=t.s();c=t.n();for(var f=0;f!==c;++f){var d=t.s(),p=t.n();e.attributeIndex.set(d,p)}c=t.n();for(var m=0;m!==c;++m){var g=t.s(),v=t.n();e.constantIndex.set(g,v)}c=t.n();for(var y=0;y!==c;++y){var S=t.s(),T=t.n();e.shaderLayoutIndex.set(S,T)}c=t.n();for(var A=0;A!==c;++A){var b=t.s(),E=new Jet;_it(t,E),e.effects.set(b,E)}}var git,vit=function(){function t(t){this.colors=void 0,this.colors=new Array(t)}var e=t.prototype;return e.get=function(t){return this.colors[t]},e.put=function(t,e){this.colors[t]=e},t}();function yit(t){switch(t){case nc.BOOL:case nc.INT:case nc.UINT:case nc.FLOAT:return 1;case nc.INT2:case nc.FLOAT2:case nc.UINT2:case nc.BOOL2:return 2;case nc.FLOAT3:case nc.BOOL3:case nc.UINT3:case nc.INT3:return 3;case nc.BOOL4:case nc.FLOAT4:case nc.UINT4:case nc.INT4:case nc.MAT2:return 4;case nc.MAT2X3:case nc.MAT3X2:return 6;case nc.MAT2X4:case nc.MAT4X2:return 8;case nc.MAT3:return 9;case nc.MAT3X4:case nc.MAT4X3:return 12;case nc.MAT4:return 16;default:return 0}}function Sit(t,e){var i=Ac.CLEAR;return t&Fc.COLOR||e!==ytt.RENDER_TARGET||(i=t&nR?Ac.CLEAR:Ac.LOAD),(t&Fc.DEPTH_STENCIL)!==Fc.DEPTH_STENCIL&&e===ytt.DEPTH_STENCIL&&(t&Fc.DEPTH||(i=Ac.LOAD),t&Fc.STENCIL||(i=Ac.LOAD)),i}function Tit(t,e,i,n,r,s){void 0===n&&(n=null),void 0===r&&(r=0),void 0===s&&(s=void 0),s=s||new jc;var a=t?t.viewport:new jc(0,0,1,1),o=e,h=i;if(s.x=a.x*o,s.y=a.y*h,s.width=a.width*o,s.height=a.height*h,n)switch(n.type){case CR.DIRECTIONAL:var u=n;if(u.shadowFixedArea||u.csmLevel===jT.LEVEL_1)s.x=0,s.y=0,s.width=o,s.height=h;else{var l=S.director.root.device.capabilities.screenSpaceSignY;s.x=r%2*.5*o,s.y=l>0?.5*(1-Math.floor(r/2))*h:.5*Math.floor(r/2)*h,s.width=.5*o,s.height=.5*h}break;case CR.SPOT:s.x=0,s.y=0,s.width=o,s.height=h}return s}function Ait(t,e,i,n,r){var s="Camera"+r,a=i.renderArea(),o=a.x,h=a.y,u=i.camera,l="reflectionProbePassColor"+s,c="reflectionProbePassDS"+s;e.containsResource(l)||(e.addRenderWindow(l,ec.RGBA8,o,h,n),e.addDepthStencil(c,ec.DEPTH_STENCIL,o,h,ctt.EXTERNAL)),e.updateRenderWindow(l,n),e.updateDepthStencil(c,o,h);var _=e.addRenderPass(o,h,"default");_.name="ReflectionProbePass"+r,_.setViewport(new $c(0,0,o,h)),_.addRenderTarget(l,Sit(u.clearFlag,ytt.RENDER_TARGET),bc.STORE,new t_(u.clearColor.x,u.clearColor.y,u.clearColor.z,u.clearColor.w)),_.addDepthStencil(c,Sit(u.clearFlag,ytt.DEPTH_STENCIL),bc.STORE,u.clearDepth,u.clearStencil,u.clearFlag);var f=_.addQueue(_tt.RENDER_OPAQUE,"reflect-map"),d=new Ttt;d.probe=i,f.addSceneOfCamera(t,d,ptt.REFLECTION_PROBE|ptt.OPAQUE_OBJECT),function(t,e,i){var n=S.director.root.pipeline,r=i.pipelineSceneData,s=r.skybox;t.setMat4("cc_matView",e.matView),t.setMat4("cc_matViewInv",e.node.worldMatrix),t.setMat4("cc_matProj",e.matProj),t.setMat4("cc_matProjInv",e.matProjInv),t.setMat4("cc_matViewProj",e.matViewProj),t.setMat4("cc_matViewProjInv",e.matViewProjInv),t.setVec4("cc_cameraPos",new cn(e.position.x,e.position.y,e.position.z,n.getCombineSignY())),t.setVec4("cc_surfaceTransform",new cn(e.surfaceTransform,0,Math.cos(Vi(s.getRotationAngle())),Math.sin(Vi(s.getRotationAngle())))),t.setVec4("cc_screenScale",new cn(r.shadingScale,r.shadingScale,1/r.shadingScale,1/r.shadingScale)),t.setVec4("cc_exposure",new cn(e.exposure,1/e.exposure,r.isHDR?1:0,1/sR.standardExposureValue))}(f,u,e)}function bit(t,e,i){!function(t,e,i){i instanceof af?t.bindBuffer(e,i):i instanceof xf?t.bindTexture(e,i):i instanceof Ef&&t.bindSampler(e,i)}(t,e,i)}function Eit(t,e){for(var i,n=f(e.descriptorSetLayoutData.descriptorBlocks);!(i=n()).done;)for(var r=i.value,s=0;s!==r.descriptors.length;++s)if(t===r.descriptors[s].descriptorID)return r.offset+s;return-1}new Ra(0,0,0,.5,.5,.5),new Ra,function(t){t[t.NONE=0]="NONE",t[t.FXAA=1]="FXAA",t[t.FXAAHQ=2]="FXAAHQ"}(git||(git={})),new(function(){function t(){this.shadowEnabled=!1,this.mainLightShadowNames=new Array,this.spotLightShadowNames=new Array,this.validLights=[]}return t.prototype.reset=function(){this.shadowEnabled=!1,this.mainLightShadowNames.length=0,this.spotLightShadowNames.length=0,this.validLights.length=0},t}());var Cit=function(){function t(t,e){void 0===e&&(e=2),this.buffers=[],this.currBuffIdx=0,this.device=void 0,this.currUniform=void 0,this._root=void 0;var i=(this._root=S.director.root).device;this.device=i,this.currUniform=new Float32Array(t/4);for(var n=0;nt.length)return n;for(var r=Math.min(e.length,t.length-i),s=0;s=this.instanceBuffers.length&&this.instanceBuffers.push(new CT(t)),this.passInstances.set(t,n);var r=this.instanceBuffers[n];r.pass=t,r.instances}this.instanceBuffers[this.passInstances.get(t)].merge(e,i)},e.clear=function(){this.passInstances.clear(),this.instanceBuffers.forEach((function(t){t.clear()}))},e.sort=function(){},e.uploadBuffers=function(t){for(var e,i=f(this.passInstances.entries());!(e=i()).done;){var n=e.value;n[0];var r=n[1],s=this.instanceBuffers[r];s.hasPendingModels&&s.uploadBuffers(t)}},e.recordCommandBuffer=function(t,e,i,n,r){void 0===i&&(i=null),void 0===n&&(n=0),void 0===r&&(r=null);for(var s,a=f(this.instanceBuffers);!(s=a()).done;){var o=s.value;if(o.hasPendingModels){var h=o.instances,u=o.pass;e.bindDescriptorSet(Og.MATERIAL,u.descriptorSet);for(var l,c=null,_=f(h);!(l=_()).done;){var d=l.value;if(d.count){var p=GT.getOrCreatePipelineState(Ff.gfxDevice,u,d.shader,t,d.ia);c!==p&&(e.bindPipelineState(p),c=p),i&&e.bindDescriptorSet(Og.GLOBAL,i,[n]),r?e.bindDescriptorSet(Og.LOCAL,d.descriptorSet,r):e.bindDescriptorSet(Og.LOCAL,d.descriptorSet,o.dynamicOffsets),e.bindInputAssembler(d.ia),e.draw(d.ia)}}}}},t}(),rnt=function(){function t(t,e,i){void 0===t&&(t=4294967295),void 0===e&&(e=4294967295),void 0===i&&(i=4294967295),this.frustumCulledResultID=void 0,this.lightBoundsCulledResultID=void 0,this.renderQueueTarget=void 0,this.frustumCulledResultID=t,this.lightBoundsCulledResultID=e,this.renderQueueTarget=i}return t.prototype.update=function(t,e,i){void 0===t&&(t=4294967295),void 0===e&&(e=4294967295),void 0===i&&(i=4294967295),this.frustumCulledResultID=t,this.lightBoundsCulledResultID=e,this.renderQueueTarget=i},t}(),snt=function(){function t(){this.probeQueue=new Jit,this.opaqueQueue=new int,this.transparentQueue=new int,this.opaqueInstancingQueue=new nnt,this.transparentInstancingQueue=new nnt,this.camera=null,this.sceneFlags=ptt.NONE,this.lightByteOffset=4294967295}var e=t.prototype;return e.sort=function(){this.opaqueQueue.sortOpaqueOrCutout(),this.transparentQueue.sortTransparent(),this.opaqueInstancingQueue.sort(),this.transparentInstancingQueue.sort()},e.update=function(){this.probeQueue.clear(),this.opaqueQueue.clear(),this.transparentQueue.clear(),this.opaqueInstancingQueue.clear(),this.transparentInstancingQueue.clear(),this.camera=null,this.sceneFlags=ptt.NONE,this.lightByteOffset=4294967295},e.empty=function(){return this.opaqueQueue.empty()&&this.transparentQueue.empty()&&this.opaqueInstancingQueue.empty()&&this.transparentInstancingQueue.empty()},e.recordCommands=function(t,e,i){var n=4294967295===this.lightByteOffset?null:[this.lightByteOffset];i&(ptt.OPAQUE|ptt.MASK)&&(this.opaqueQueue.recordCommandBuffer(Ff.gfxDevice,e,t,null,0,n),this.opaqueInstancingQueue.recordCommandBuffer(e,t,null,0,n)),i&ptt.BLEND&&(this.transparentInstancingQueue.recordCommandBuffer(e,t,null,0,n),this.transparentQueue.recordCommandBuffer(Ff.gfxDevice,e,t,null,0,n))},t}(),ant=4294967295;function ont(t){switch(t){case Att.UNIFORM_BUFFER:return Pc.UNIFORM_BUFFER;case Att.DYNAMIC_UNIFORM_BUFFER:return Pc.DYNAMIC_UNIFORM_BUFFER;case Att.SAMPLER_TEXTURE:return Pc.SAMPLER_TEXTURE;case Att.SAMPLER:return Pc.SAMPLER;case Att.TEXTURE:return Pc.TEXTURE;case Att.STORAGE_BUFFER:return Pc.STORAGE_BUFFER;case Att.DYNAMIC_STORAGE_BUFFER:return Pc.DYNAMIC_STORAGE_BUFFER;case Att.STORAGE_IMAGE:return Pc.STORAGE_IMAGE;case Att.INPUT_ATTACHMENT:return Pc.INPUT_ATTACHMENT;default:return H("DescriptorType not found"),Pc.INPUT_ATTACHMENT}}function hnt(t){switch(t){case Pc.UNIFORM_BUFFER:return Att.UNIFORM_BUFFER;case Pc.DYNAMIC_UNIFORM_BUFFER:return Att.DYNAMIC_UNIFORM_BUFFER;case Pc.SAMPLER_TEXTURE:return Att.SAMPLER_TEXTURE;case Pc.SAMPLER:return Att.SAMPLER;case Pc.TEXTURE:return Att.TEXTURE;case Pc.STORAGE_BUFFER:return Att.STORAGE_BUFFER;case Pc.DYNAMIC_STORAGE_BUFFER:return Att.DYNAMIC_STORAGE_BUFFER;case Pc.STORAGE_IMAGE:return Att.STORAGE_IMAGE;case Pc.INPUT_ATTACHMENT:return Att.INPUT_ATTACHMENT;case Pc.UNKNOWN:default:return H("DescriptorTypeOrder not found"),Att.INPUT_ATTACHMENT}}function unt(t,e){return t.locateChild(t.N,e||"default")}function lnt(t,e,i){return t.locateChild(e,i)}function cnt(t,e,i){return void 0===i?t.locateChild(e,"default"):"number"==typeof i?t.locateChild(e,i.toString()):t.locateChild(e,i)}var _nt,fnt,dnt=new Map([["cc_lightPos",av.LIGHTS_PER_PASS],["cc_lightColor",av.LIGHTS_PER_PASS],["cc_lightSizeRangeAngle",av.LIGHTS_PER_PASS],["cc_lightDir",av.LIGHTS_PER_PASS],["cc_lightBoundingSizeVS",av.LIGHTS_PER_PASS]]);function pnt(t,e){var i=JSON.parse(t[0]),n=JSON.parse(e[0]);return 1e4*i.updateFrequency+1e3*i.parameterType+100*i.descriptorType+i.visibility-(1e4*n.updateFrequency+1e3*n.parameterType+100*n.descriptorType+n.visibility)}function mnt(t,e){var i=t.attributeIndex.get(e);if(void 0===i){var n=t.valueNames.length;return t.attributeIndex.set(e,n),t.valueNames.push(e),n}return i}function gnt(t,e){for(var i=0;ithis.lightBoundsCullingResults.length&&this.lightBoundsCullingResults.push(this.cullingPools.lightBoundsCullingResultRecycle.add().update()),r.resultIndex.set(a,h);var u=this.cullingPools.lightBoundsCullingKeyRecycle.add();return u.update(t,e),r.resultKeyIndex.set(a,u),h},e.getOrCreateFrustumCulling=function(t){var e=this.renderGraph.j(t),i=e.scene,n=this.frustumCullings.get(i);if(!n){var r=this.cullingPools.frustumCullingsRecycle.add();r.update(),this.frustumCullings.set(i,r),n=this.frustumCullings.get(i)}var s=Uit(e.flags&ptt.SHADOW_CASTER),a=Pnt(e,s),o=n.resultIndex.get(a);if(void 0!==o)return o;var h=this.numFrustumCulling++;this.numFrustumCulling>this.frustumCullingResults.length&&this.frustumCullingResults.push([]),n.resultIndex.set(a,h);var u=this.cullingPools.frustumCullingKeyRecycle.add();return u.update(e,s),n.resultKeyIndex.set(a,u),h},e.getOrCreateRenderQueue=function(t,e,i){var n=this.renderQueueIndex.get(t);if(void 0!==n)return this.renderQueues[n].sceneFlags|=e&this.kDrawMask,n;var r=this.numRenderQueues++;if(this.numRenderQueues>this.renderQueues.length){var s=this.cullingPools.renderQueueRecycle.add();s.update(),this.renderQueues.push(s)}var a=this.renderQueues[r];return this.renderQueueIndex.set(t,r),a.camera=i,a.sceneFlags=e&this.kAllMask,r},e.collectCullingQueries=function(t){for(var e,i=f(t.v());!(e=i()).done;){var n=e.value;if(t.h(9,n)&&t.getValid(n)){var r=t.j(n);if(r.scene){var s=this.getOrCreateFrustumCulling(n),a=this.getOrCreateLightBoundsCulling(r,s),o=t.getParent(n),h=Gnt(s,a,t.j(o).phaseID),u=this.getOrCreateRenderQueue(h,r.flags,r.camera),l=this.cullingPools.renderQueueQueryRecycle.add();l.update(s,a,u),this.renderQueueQueryIndex.set(n,l)}}}},e.uploadInstancing=function(t){for(var e=0;e!==this.numRenderQueues;++e){var i=this.renderQueues[e];i.opaqueInstancingQueue.uploadBuffers(t),i.transparentInstancingQueue.uploadBuffers(t)}},e._getPhaseIdFromScene=function(t){var e=this.renderGraph,i=e.getParent(t);return e.j(i).phaseID},e.getBuiltinShadowFrustum=function(t,e,i,n){var r=t.csmLayers,s=i.csmLevel,a=t.shadows;return a.type===WT.Planar?e.frustum:(a.enabled&&a.type===WT.ShadowMap&&i&&i.node&&r.update(t,e),i.shadowFixedArea||s===jT.LEVEL_1?r.specialLayer.validFrustum:r.layers[n].validFrustum)},e.batchFrustumCulling=function(t){for(var e,i=f(this.frustumCullings);!(e=i()).done;)for(var n,r=e.value,s=r[0],a=r[1],o=f(a.resultIndex);!(n=o()).done;){var h=n.value,u=h[0],l=h[1],c=a.resultKeyIndex.get(u),_=c.sceneData,d=_.light.light,p=_.light.level,m=c.castShadows,g=_.light.probe,v=g?g.camera:_.camera,y=this.frustumCullingResults[l];if(g)jnt(s,v,v.frustum,m,g,y);else if(d)switch(d.type){case CR.SPOT:jnt(s,v,d.frustum,m,null,y);break;case CR.DIRECTIONAL:jnt(s,v,this.getBuiltinShadowFrustum(t,v,d,p),m,null,y)}else jnt(s,v,v.frustum,m,null,y)}},e.executeSphereLightCulling=function(t,e,i){for(var n,r=t.aabb,s=f(e);!(n=s()).done;){var a=n.value,o=a.worldBounds;o&&!vs.aabbWithAABB(o,r)||i.push(a)}},e.executeSpotLightCulling=function(t,e,i){for(var n,r=t.aabb,s=t.frustum,a=f(e);!(n=a()).done;){var o=n.value,h=o.worldBounds;(!h||vs.aabbWithAABB(r,h)&&vs.aabbFrustum(h,s))&&i.push(o)}},e.executePointLightCulling=function(t,e,i){for(var n,r=t.aabb,s=f(e);!(n=s()).done;){var a=n.value,o=a.worldBounds;o&&!vs.aabbWithAABB(r,o)||i.push(a)}},e.executeRangedDirectionalLightCulling=function(t,e,i){Jnt.transform(t.node.worldMatrix,null,null,null,$nt);for(var n,r=f(e);!(n=r()).done;){var s=n.value,a=s.worldBounds;a&&!vs.aabbWithAABB($nt,a)||i.push(s)}},e.batchLightBoundsCulling=function(){for(var t,e=f(this.lightBoundsCullings);!(t=e()).done;){var i=t.value;i[0];for(var n,r=i[1],s=f(r.resultIndex);!(n=s()).done;){var a=n.value,o=a[0],h=a[1],u=r.resultKeyIndex.get(o),l=u.sceneData,c=u.frustumCullingID,_=this.frustumCullingResults[c],d=this.lightBoundsCullingResults[h];switch(l.shadingLight.type){case CR.SPHERE:var p=l.shadingLight;this.executeSphereLightCulling(p,_,d.instances);break;case CR.SPOT:var m=l.shadingLight;this.executeSpotLightCulling(m,_,d.instances);break;case CR.POINT:var g=l.shadingLight;this.executePointLightCulling(g,_,d.instances);break;case CR.RANGED_DIRECTIONAL:var v=l.shadingLight;this.executeRangedDirectionalLightCulling(v,_,d.instances);break;case CR.DIRECTIONAL:case CR.UNKNOWN:}}}},e._getModelsByCullingResults=function(t,e){return 4294967295!==t?t=n.width},e.createDeviceBuf=function(t){if(Knt.deviceBuffers.get(this.name)){if(!this.checkBuffer(this.name)){var e;null===(e=Knt.deviceBuffers.get(this.name).buffer)||void 0===e||e.destroy();var i=new srt(this.name,t);Knt.deviceBuffers.set(this.name,i)}}else{var n=new srt(this.name,t);Knt.deviceBuffers.set(this.name,n)}},e.managed=function(t){this.createDeviceTex(t)},e.managedBuffer=function(t){this.createDeviceBuf(t)},e.managedTexture=function(){},e.persistentBuffer=function(t){this.createDeviceBuf(t)},e.persistentTexture=function(t){this.createDeviceTex(t)},e.framebuffer=function(t){this.createDeviceTex(t)},e.swapchain=function(t){this.createDeviceTex(t)},e.formatView=function(){},e.subresourceView=function(){},n(t,[{key:"resName",set:function(t){this.name=t}}]),t}(),nrt=function(){function t(t){this._name=void 0,this._name=t}return n(t,[{key:"name",get:function(){return this._name}}]),t}(),rrt=function(t){function e(e,i){var n;(n=t.call(this,e)||this)._texture=null,n._swapchain=null,n._framebuffer=null,n._desc=null,n._trait=null;var r=Knt.resourceGraph,s=r.vertex(e);if(n._desc=r.getDesc(s),n._trait=r.getTraits(s),i instanceof xf)return n._texture=i,c(n);if(i instanceof cf)return n._framebuffer=i,c(n);if(i instanceof set)return n._swapchain=i.swapchain,c(n);var a=n._desc,o=hc.TEX2D;switch(a.dimension){case ftt.TEXTURE1D:o=hc.TEX1D;break;case ftt.TEXTURE2D:o=hc.TEX2D;break;case ftt.TEXTURE3D:o=hc.TEX3D}var h=uc.NONE;return a.flags&dtt.COLOR_ATTACHMENT&&(h|=uc.COLOR_ATTACHMENT),a.flags&dtt.DEPTH_STENCIL_ATTACHMENT&&(h|=uc.DEPTH_STENCIL_ATTACHMENT),a.flags&dtt.INPUT_ATTACHMENT&&(h|=uc.INPUT_ATTACHMENT),a.flags&dtt.SAMPLED&&(h|=uc.SAMPLED),a.flags&dtt.STORAGE&&(h|=uc.STORAGE),a.flags&dtt.TRANSFER_SRC&&(h|=uc.TRANSFER_SRC),a.flags&dtt.TRANSFER_DST&&(h|=uc.TRANSFER_DST),n._texture=Knt.device.createTexture(new u_(o,h,a.format,a.width,a.height)),n}return s(e,t),e.prototype.release=function(){this.framebuffer&&(this.framebuffer.destroy(),this._framebuffer=null),this.texture&&(this.texture.destroy(),this._texture=null)},n(e,[{key:"texture",get:function(){return this._texture}},{key:"framebuffer",get:function(){return this._framebuffer},set:function(t){this._framebuffer=t}},{key:"description",get:function(){return this._desc}},{key:"trait",get:function(){return this._trait}},{key:"swapchain",get:function(){return this._swapchain}}]),e}(nrt),srt=function(t){function e(e){var i;(i=t.call(this,e)||this)._buffer=void 0;var n=Knt.resourceGraph,r=n.vertex(e),s=n.getDesc(r),a=new r_;return a.size=s.width,a.memUsage=oc.DEVICE,s.flags&dtt.INDIRECT&&(a.usage|=rc.INDIRECT),s.flags&dtt.UNIFORM&&(a.usage|=rc.UNIFORM),s.flags&dtt.STORAGE&&(a.usage|=rc.STORAGE),s.flags&dtt.TRANSFER_SRC&&(a.usage|=rc.TRANSFER_SRC),s.flags&dtt.TRANSFER_DST&&(a.usage|=rc.TRANSFER_DST),i._buffer=Knt.device.createBuffer(a),i}return s(e,t),e.prototype.release=function(){this._buffer&&(this._buffer.destroy(),this._buffer=null)},n(e,[{key:"buffer",get:function(){return this._buffer}}]),e}(nrt),art=new Float32Array(4),ort=function(){function t(t,e){this._isUpdate=!1,this._isGatherLight=!1,this._blit=void 0,this._screenQuad=null,this._queue=null,this._stageDesc=void 0,this._lightVolumeBuffer=null,this._lightMeterScale=1e4,this._lightBufferData=void 0,this._blit=t,this._queue=e}var e=t.prototype;return e._createQuadInputAssembler=function(){return Knt.blit.pipelineIAData},e.createScreenQuad=function(){this._screenQuad||(this._screenQuad=this._createQuadInputAssembler())},e._gatherVolumeLights=function(t){if(t.scene){for(var e=Knt.pipeline,i=Knt.commandBuffer,n=t.scene.sphereLights,r=t.scene.spotLights,s=Ir.create(0,0,0,1),a=t.exposure,o=0,h=ov.LIGHTS_PER_PASS,u=cn.length,l=u*h,c=0;c0){var a=s;s=r,r=a}var o=0;switch(t){case $l.IDENTITY:o=0,Srt[o++]=-1,Srt[o++]=-1,Srt[o++]=i,Srt[o++]=s,Srt[o++]=1,Srt[o++]=-1,Srt[o++]=n,Srt[o++]=s,Srt[o++]=-1,Srt[o++]=1,Srt[o++]=i,Srt[o++]=r,Srt[o++]=1,Srt[o++]=1,Srt[o++]=n,Srt[o++]=r;break;case $l.ROTATE_90:o=0,Srt[o++]=-1,Srt[o++]=-1,Srt[o++]=n,Srt[o++]=s,Srt[o++]=1,Srt[o++]=-1,Srt[o++]=n,Srt[o++]=r,Srt[o++]=-1,Srt[o++]=1,Srt[o++]=i,Srt[o++]=s,Srt[o++]=1,Srt[o++]=1,Srt[o++]=i,Srt[o++]=r;break;case $l.ROTATE_180:o=0,Srt[o++]=-1,Srt[o++]=-1,Srt[o++]=i,Srt[o++]=r,Srt[o++]=1,Srt[o++]=-1,Srt[o++]=n,Srt[o++]=r,Srt[o++]=-1,Srt[o++]=1,Srt[o++]=i,Srt[o++]=s,Srt[o++]=1,Srt[o++]=1,Srt[o++]=n,Srt[o++]=s;break;case $l.ROTATE_270:o=0,Srt[o++]=-1,Srt[o++]=-1,Srt[o++]=i,Srt[o++]=r,Srt[o++]=1,Srt[o++]=-1,Srt[o++]=i,Srt[o++]=s,Srt[o++]=-1,Srt[o++]=1,Srt[o++]=n,Srt[o++]=r,Srt[o++]=1,Srt[o++]=1,Srt[o++]=n,Srt[o++]=s}return Srt},e._createQuadInputAssembler=function(){var t=new BD,e=4*Float32Array.BYTES_PER_ELEMENT,i=4*e,n=S.director.root.device,r=n.createBuffer(new r_(rc.VERTEX|rc.TRANSFER_DST,oc.DEVICE|oc.HOST,i,e));if(!r)return t;var s=Uint16Array.BYTES_PER_ELEMENT,a=6*s,o=n.createBuffer(new r_(rc.INDEX|rc.TRANSFER_DST,oc.DEVICE,a,s));if(!o)return t;var h=new Uint16Array(6);h[0]=0,h[1]=1,h[2]=2,h[3]=1,h[4]=3,h[5]=2,o.update(h.buffer);var u=new Array(2);u[0]=new T_("a_position",ec.RG32F),u[1]=new T_("a_texCoord",ec.RG32F);var l=n.createInputAssembler(new b_(u,[r],o));return t.quadIB=o,t.quadVB=r,t.quadIA=l,t},n(t,[{key:"pipelineIAData",get:function(){return this._pipelineIAData}},{key:"deferredLitsBufView",get:function(){return this._deferredLitsBufView}},{key:"lightVolumeBuffer",get:function(){return this._lightVolumeBuffer}},{key:"lightBufferData",get:function(){return this._lightBufferData}},{key:"stageDescs",get:function(){return this._stageDescs}},{key:"emptyLocalUBO",get:function(){return this._localUBO}}]),t}(),brt=function(){function t(t,e,i,n,r,s,a,o){void 0===o&&(o=null),this.device=void 0,this.pipeline=void 0,this.commandBuffer=void 0,this.pipelineSceneData=void 0,this.resourceGraph=void 0,this.devicePasses=new Map,this.deviceTextures=new Map,this.deviceBuffers=new Map,this.layoutGraph=void 0,this.root=void 0,this.pools=void 0,this.blit=void 0,this.culling=void 0,this.lightResource=new ert,this.renderGraph=void 0,this.width=void 0,this.height=void 0,this.cullCamera=void 0,this.passDescriptorSet=void 0,this.profilerDescriptorSet=void 0,this.pipeline=t,this.device=e,this.commandBuffer=e.commandBuffer,this.pipelineSceneData=t.pipelineSceneData,this.resourceGraph=i,this.renderGraph=n,this.root=S.director.root,this.layoutGraph=r,this.width=s,this.height=a,this.pools=new yrt,this.blit=new Art(this),this.culling=new trt,this.passDescriptorSet=o,this.profilerDescriptorSet=Iit("default").descriptorSet}var e=t.prototype;return e.reset=function(){this.culling.clear(),this.pools.reset(),this.cullCamera=null,this.lightResource.clear()},e.resize=function(t,e){this.width=t,this.height=e,this.blit.resize(t,e)},t}(),Ert=function(){function t(t,e,i,n,r,s){this._context=void 0,this._visitor=void 0,Knt=this._context=new brt(t,e,i,new ket,n,r,s);var a=S.rendering.programLib;Knt.lightResource.init(a,e,16)}var e=t.prototype;return e.resize=function(t,e){Knt.resize(t,e)},e._removeDeviceResource=function(){for(var t,e=Knt.pipeline.resourceUses,i=[],n=Knt.deviceTextures,r=f(n);!(t=r()).done;){var s=t.value,a=s[0];s[1];var o=Knt.resourceGraph.vertex(a),h=Knt.resourceGraph.getTraits(o);if(!e.includes(a))switch(h.residency){case ctt.MANAGED:i.push(a)}}for(var u=0,l=i;u1?hc.TEX1D_ARRAY:hc.TEX1D;case ftt.TEXTURE2D:return e>1?hc.TEX2D_ARRAY:hc.TEX2D;case ftt.TEXTURE3D:return hc.TEX3D;case ftt.BUFFER:return hc.TEX2D}return hc.TEX2D}(e,a),i,n,r,s,a,o,h,u,l)},e.updateResource=function(t,e,i,n,r,s,a,o){var h=this.resourceGraph.vertex(t),u=this.resourceGraph.getDesc(h);u.width=i,u.height=n,u.depthOrArraySize=u.dimension===ftt.TEXTURE3D?r:s,u.mipLevels=a,e!==ec.UNKNOWN&&(u.format=e),u.sampleCount=o},e.containsResource=function(t){return this._resourceGraph.contains(t)},e.addResolvePass=function(){throw new Error("Method not implemented.")},e.addComputePass=function(t){var e=Znt.createComputePass(),i=Znt.createRenderData(),n=this._renderGraph.addVertex(3,e,"Compute",t,i,!1),r=Qnt.computePassBuilder.add();return r.update(i,this._renderGraph,this._layoutGraph,this._resourceGraph,n,e,this._pipelineSceneData),S.director.root.pipeline,r},e.addUploadPass=function(t){for(var e,i=Znt.createCopyPass(),n=f(t);!(e=n()).done;){var r=e.value;i.uploadPairs.push(r)}this._renderGraph.addVertex(5,i,"UploadPass","",Znt.createRenderData(),!1)},e.addCopyPass=function(t){for(var e,i=f(t);!(e=i()).done;){var n=e.value,r=n.target,s=this.resourceGraph.find(r),a=this.resourceGraph.getDesc(s),o=this.addRenderPass(a.width,a.height,"copy-pass");o.addRenderTarget(r,Ac.CLEAR,bc.STORE,Qnt.createColor()),o.addTexture(n.source,"outputResultMap"),o.addQueue(_tt.NONE).addFullscreenQuad(this._copyPassMat,0,ptt.NONE)}},e._generateConstantMacros=function(){var t="";t+="#define CC_DEVICE_SUPPORT_FLOAT_TEXTURE "+(this._device.getFormatFeatures(ec.RGBA32F)&(cc.RENDER_TARGET|cc.SAMPLED_TEXTURE)?1:0)+"\n",t+="#define CC_DEVICE_MAX_VERTEX_UNIFORM_VECTORS "+this._device.capabilities.maxVertexUniformVectors+"\n",t+="#define CC_DEVICE_MAX_FRAGMENT_UNIFORM_VECTORS "+this._device.capabilities.maxFragmentUniformVectors+"\n",t+="#define CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT "+(this._device.hasFeature(tc.INPUT_ATTACHMENT_BENEFIT)?1:0)+"\n",t+="#define CC_PLATFORM_ANDROID_AND_WEBGL "+(Zs.os===Ys.ANDROID&&Zs.isBrowser?1:0)+"\n",t+="#define CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES "+(Pe.ENABLE_WEBGL_HIGHP_STRUCT_VALUES?1:0)+"\n",t+="#define CC_JOINT_UNIFORM_CAPACITY "+cv.JOINT_UNIFORM_CAPACITY+"\n",this._constantMacros=t,this._layoutGraph.constantMacros=this._constantMacros},e.setCustomPipelineName=function(t){this._customPipelineName=t,"Deferred"===this._customPipelineName&&(this._usesDeferredPipeline=!0)},e.getGlobalDescriptorSetData=function(){var t=this.layoutGraph.locateChild(this.layoutGraph.N,"default");return this.layoutGraph.getLayout(t).descriptorSets.get(rtt.PER_PASS)},e._initCombineSignY=function(){var t=this._device;this._combineSignY=.5*t.capabilities.screenSpaceSignY+.5<<1|.5*t.capabilities.clipSpaceSignY+.5},e.getCombineSignY=function(){return this._combineSignY},e._compileMaterial=function(){this._copyPassMat.initialize({effectName:"pipeline/copy-pass"});for(var t=0;t=t.CSM_UNIFORM_VECTORS+t.GLOBAL_UNIFORM_VECTORS,this.setMacroBool("CC_SUPPORT_CASCADED_SHADOW_MAP",this.pipelineSceneData.csmSupported),this.setMacroInt("CC_SHADOW_TYPE",0),this.setMacroInt("CC_DIR_SHADOW_PCF_TYPE",XT.HARD),this.setMacroInt("CC_DIR_LIGHT_SHADOW_TYPE",0),this.setMacroBool("CC_CASCADED_LAYERS_TRANSITION",!1),this.usesDeferredPipeline&&this.setMacroInt("CC_PIPELINE_TYPE",1),!0},e.destroy=function(){var t,e,i;return null===(t=this._globalDSManager)||void 0===t||t.globalDescriptorSet.destroy(),null===(e=this._globalDSManager)||void 0===e||e.destroy(),null===(i=this._pipelineSceneData)||void 0===i||i.destroy(),!0},e.getMacroString=function(t){var e=this._macros[t];return void 0===e?"":e},e.getMacroInt=function(t){var e=this._macros[t];return void 0===e?0:e},e.getMacroBool=function(t){var e=this._macros[t];return void 0!==e&&e},e.getSamplerInfo=function(t){if(this.containsResource(t)){var e=this._resourceGraph.vertex(t);return this._resourceGraph.getSampler(e)}return null},e.setMacroString=function(t,e){this._macros[t]=e},e.setMacroInt=function(t,e){this._macros[t]=e},e.setMacroBool=function(t,e){this._macros[t]=e},e.onGlobalPipelineStateChanged=function(){var t=S.rendering.getCustomPipeline(Pe.CUSTOM_PIPELINE_NAME);t&&("function"==typeof t.onGlobalPipelineStateChanged&&t.onGlobalPipelineStateChanged(),S.rendering.forceResizeAllWindows())},e.beginSetup=function(){this._renderGraph||(this._renderGraph=new ket),Qnt.reset()},e.endSetup=function(){this.compile()},e.addStorageBuffer=function(t,e,i,n){void 0===n&&(n=ctt.MANAGED);var r=this._resourceGraph.find(t);if(4294967295!==r)return this.updateStorageBuffer(t,i,e),r;var s=new net;return s.dimension=ftt.BUFFER,s.width=i,s.height=1,s.depthOrArraySize=1,s.mipLevels=1,s.format=e,s.flags=dtt.STORAGE,n===ctt.PERSISTENT?this._resourceGraph.addVertex(3,new het,t,s,new ret(ctt.PERSISTENT),new aet,new c_):this._resourceGraph.addVertex(1,new oet,t,s,new ret(n),new aet,new c_)},e.addRenderTarget=function(t,e,i,n,r){void 0===r&&(r=ctt.MANAGED);var s=this._resourceGraph.find(t);if(4294967295!==s)return this.updateRenderTarget(t,i,n,e),s;var a=new net;return a.dimension=ftt.TEXTURE2D,a.width=i,a.height=n,a.depthOrArraySize=1,a.mipLevels=1,a.format=e,a.sampleCount=_c.X1,a.flags=dtt.COLOR_ATTACHMENT|dtt.SAMPLED,this._resourceGraph.addVertex(0,new _et,t,a,new ret(r),new aet,new c_(dc.LINEAR,dc.LINEAR,dc.NONE,pc.CLAMP,pc.CLAMP,pc.CLAMP))},e.updateDepthStencilImpl=function(t,e,i,n,r){var s=this.resourceGraph.getDesc(t);if(s.width=e,s.height=i,r){var a=this.resourceGraph.j(t);a.swapchain=r,s.format=a.swapchain.depthStencilTexture.format}else n!==ec.UNKNOWN&&(s.format=n)},e.addDepthStencilImpl=function(t,e,i,n,r,s){var a=this._resourceGraph.find(t);if(4294967295!==a)return this.updateDepthStencilImpl(a,i,n,e,s),a;var o=new net;return o.dimension=ftt.TEXTURE2D,o.width=i,o.height=n,o.depthOrArraySize=1,o.mipLevels=1,o.format=e,o.sampleCount=_c.X1,o.flags=dtt.DEPTH_STENCIL_ATTACHMENT|dtt.SAMPLED,s?this._resourceGraph.addVertex(6,new set(s,!0),t,o,new ret(r),new aet,new c_(dc.POINT,dc.POINT,dc.NONE)):this._resourceGraph.addVertex(0,new _et,t,o,new ret(r),new aet,new c_(dc.POINT,dc.POINT,dc.NONE))},e.addDepthStencil=function(t,e,i,n,r){return void 0===r&&(r=ctt.MANAGED),this.addDepthStencilImpl(t,e,i,n,r)},e.addStorageTexture=function(t,e,i,n,r){void 0===r&&(r=ctt.MANAGED);var s=this._resourceGraph.find(t);if(4294967295!==s)return this.updateStorageTexture(t,i,n,e),s;var a=new net;return a.dimension=ftt.TEXTURE2D,a.width=i,a.height=n,a.depthOrArraySize=1,a.mipLevels=1,a.format=e,a.flags=dtt.STORAGE|dtt.SAMPLED,this._resourceGraph.addVertex(0,new _et,t,a,new ret(r),new aet,new c_(dc.POINT,dc.POINT,dc.NONE))},e.addShadingRateTexture=function(t,e,i,n){void 0===n&&(n=ctt.MANAGED);var r=this._resourceGraph.find(t);if(4294967295!==r)return this.addShadingRateTexture(t,e,i),r;var s=new net;return s.dimension=ftt.TEXTURE2D,s.width=e,s.height=i,s.depthOrArraySize=1,s.mipLevels=1,s.format=ec.R8UI,s.flags=dtt.SHADING_RATE|dtt.STORAGE|dtt.SAMPLED,this._resourceGraph.addVertex(0,new _et,t,s,new ret(n),new aet,new c_(dc.LINEAR,dc.LINEAR,dc.NONE,pc.CLAMP,pc.CLAMP,pc.CLAMP))},e.beginFrame=function(){},e.update=function(){},e.endFrame=function(){var t;null===(t=this.renderGraph)||void 0===t||t.clear()},e.compile=function(){if(!this._renderGraph)throw new Error("RenderGraph cannot be built without being created");this._compiler||(this._compiler=new Frt(this,this._renderGraph,this._resourceGraph,this._layoutGraph)),this._compiler.compile(this._renderGraph)},e.execute=function(){if(!this._renderGraph)throw new Error("Cannot run without creating rendergraph");this._executor||(this._executor=new Ert(this,this._device,this._resourceGraph,this.layoutGraph,this.width,this.height)),this._executor.resize(this.width,this.height),this._executor.execute(this._renderGraph)},e._applySize=function(t){var e=this,i=this._width,n=this._height;t.forEach((function(t){var r=t.window;i=Math.max(r.width,i),n=Math.max(r.height,n),e._cameras.includes(t)||e._cameras.push(t)})),i===this._width&&n===this._height||(this._width=i,this._height=n)},e.render=function(t){0!==t.length&&(this._applySize(t),function(t){for(var e=t.length-1;e>=0;--e)if(t[e].window.swapchain)return}(t),this.beginFrame(),this.execute(),this.endFrame())},e.addBuiltinReflectionProbePass=function(t){var e=S.internal.reflectionProbeManager;if(e){var i=e.getProbes();if(0!==i.length)for(var n=0;n>3)]+=(o.isCompositeModeEnabled(u)?1:0)*Math.pow(10,l)}h[3]+=(o.lightingWithAlbedo?1:0)*Math.pow(10,6),h[3]+=(o.csmLayerColoration?1:0)*Math.pow(10,7),Vrt.set(h[0],h[1],h[2],h[3])}t.setVec4("cc_debug_view_mode",Vrt)},n(t,[{key:"type",get:function(){return Vet.BASIC}},{key:"capabilities",get:function(){return new Het}},{key:"enableCpuLightCulling",get:function(){return!this._executor||this._executor._context.culling.enableLightCulling},set:function(t){this._executor&&(this._executor._context.culling.enableLightCulling=t)}},{key:"globalDescriptorSetData",get:function(){return this._globalDescSetData}},{key:"defaultSampler",get:function(){return this._defaultSampler}},{key:"defaultShadowTexture",get:function(){return hy(this.device)}},{key:"device",get:function(){return this._device}},{key:"lightingMode",get:function(){return this._lightingMode},set:function(t){this._lightingMode=t}},{key:"usesDeferredPipeline",get:function(){return this._usesDeferredPipeline}},{key:"macros",get:function(){return this._macros}},{key:"globalDSManager",get:function(){return this._globalDSManager}},{key:"descriptorSetLayout",get:function(){return this._globalDSManager.descriptorSetLayout}},{key:"descriptorSet",get:function(){return this._globalDSManager.globalDescriptorSet}},{key:"profilerDescriptorSet",get:function(){return this._profilerDescriptorSet}},{key:"globalDescriptorSet",get:function(){return this._globalDescriptorSet}},{key:"globalDescriptorSetInfo",get:function(){return this._globalDescriptorSetInfo}},{key:"commandBuffers",get:function(){return[this._device.commandBuffer]}},{key:"pipelineSceneData",get:function(){return this._pipelineSceneData}},{key:"constantMacros",get:function(){return this._constantMacros}},{key:"profiler",get:function(){return this._profiler},set:function(t){this._profiler=t}},{key:"geometryRenderer",get:function(){throw new Error("Method not implemented.")}},{key:"shadingScale",get:function(){return this._pipelineSceneData.shadingScale},set:function(t){this._pipelineSceneData.shadingScale=t}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"renderGraph",get:function(){return this._renderGraph}},{key:"resourceGraph",get:function(){return this._resourceGraph}},{key:"layoutGraph",get:function(){return this._layoutGraph}},{key:"resourceUses",get:function(){return this._resourceUses}}]),t}();Krt.MAX_BLOOM_FILTER_PASS_NUM=6,Krt.CSM_UNIFORM_VECTORS=61,Krt.GLOBAL_UNIFORM_VECTORS=64,function(){function t(){this.capacity=0,this.size=0,this.buffer=void 0,this.dataView=void 0,this.capacity=4096,this.buffer=new Uint8Array(this.capacity),this.dataView=new DataView(this.buffer.buffer)}var e=t.prototype;e.b=function(t){var e=this.size+1;e>this.capacity&&this.reserve(e),this.dataView.setUint8(this.size,t?1:0),this.size=e},e.n=function(t){var e=this.size+8;e>this.capacity&&this.reserve(e),this.dataView.setFloat64(this.size,t,!0),this.size=e},e.s=function(t){this.n(t.length);var e=this.size+t.length;e>this.capacity&&this.reserve(e);for(var i=0;i=t.valueNames.length?"":t.valueNames[e]}(this.layoutGraph,t)},t}(),mst=null,gst=!1;function vst(){gst=!0}var yst=[],Sst=4294967295,Tst=new nit,Ast=new pst(Tst),bst=new Map,Est=Object.freeze({__proto__:null,INVALID_ID:Sst,enableEffectImport:!0,programLib:Ast,createCustomPipeline:function(){var t=new Krt(Tst),e=Pe.CUSTOM_PIPELINE_NAME;return t.setCustomPipelineName(e),Ast.pipeline=t,t},customPipelineBuilderMap:bst,setCustomPipeline:function(t,e){bst.set(t,e),vst()},getCustomPipeline:function(t){var e=bst.get(t);return e||(e=bst.get("Forward")),e},init:function(t,e){if(e&&e.byteLength>=8){var i=new Uint8Array(e);if(new DataView(i.buffer,i.byteOffset,8).getUint32(0)===Sst){var n=new jB.Inflate(new Uint8Array(i.buffer,i.byteOffset+8)).decompress();mit(new Qrt(n.buffer,n.byteOffset),Tst)}else mit(new Qrt(i.buffer,i.byteOffset),Tst)}!function(t,e){_nt=t.createDescriptorSetLayout(new O_),fnt=t.createPipelineLayout(new N_);for(var i,n=f(e.v());!(i=n()).done;)for(var r,s=i.value,a=f(e.getLayout(s).descriptorSets);!(r=a()).done;){var o=r.value;o[0];var h=o[1];null!==h.descriptorSetLayout&&z("descriptor set layout already initialized. It will be overwritten"),Tnt(h.descriptorSetLayoutData,h.descriptorSetLayoutInfo),h.descriptorSetLayout=t.createDescriptorSetLayout(h.descriptorSetLayoutInfo)}for(var u,l=f(e.v());!(u=l()).done;){var c=u.value;if(e.h(1,c)){var _=e.getParent(c),d=c,p=e.getLayout(_),m=e.getLayout(d),g=new N_;Ant(p,rtt.PER_PASS,g),Ant(m,rtt.PER_PHASE,g),Ant(m,rtt.PER_BATCH,g),Ant(m,rtt.PER_INSTANCE,g),e.j(d).pipelineLayout=t.createPipelineLayout(g)}}}(t,Tst)},destroy:function(){!function(t){for(var e,i=f(t.v());!(e=i()).done;)for(var n,r=e.value,s=f(t.getLayout(r).descriptorSets);!(n=s()).done;){var a=n.value;a[0];var o=a[1];null!==o.descriptorSetLayout&&o.descriptorSetLayout.destroy()}fnt.destroy(),_nt.destroy()}(Tst)},getPassID:function(t){return unt(Tst,t)},getSubpassID:function(t,e){return lnt(Tst,t,e)},getPhaseID:function(t,e){return cnt(Tst,t,e)},completePhaseName:function(t){return"number"==typeof t?t.toString():"string"==typeof t?t:"default"},get UpdateFrequency(){return rtt},ParameterType:mtt,get ResourceResidency(){return ctt},get QueueHint(){return _tt},get ResourceDimension(){return ftt},get ResourceFlags(){return dtt},TaskType:{SYNC:0,ASYNC:1},get SceneFlags(){return ptt},LightingMode:vtt,AttachmentType:ytt,get AccessType(){return gtt},ClearValueType:Stt,LightInfo:Ttt,DescriptorTypeOrder:Att,Descriptor:btt,DescriptorBlock:Ett,DescriptorBlockFlattened:Ctt,DescriptorBlockIndex:xtt,ResolveFlags:wtt,ResolvePair:Rtt,CopyPair:Itt,UploadPair:Dtt,MovePair:Btt,PipelineStatistics:Mtt,RenderCommonObjectPool:Ftt,saveLightInfo:function(t,e){t.n(e.level),t.b(e.culledByLight)},loadLightInfo:function(t,e){e.level=t.n(),e.culledByLight=t.b()},saveDescriptor:ktt,loadDescriptor:Gtt,saveDescriptorBlock:function(t,e){t.n(e.descriptors.size);for(var i,n=f(e.descriptors);!(i=n()).done;){var r=i.value,s=r[0],a=r[1];t.s(s),ktt(t,a)}t.n(e.uniformBlocks.size);for(var o,h=f(e.uniformBlocks);!(o=h()).done;){var u=o.value,l=u[0],c=u[1];t.s(l),htt(t,c)}t.n(e.capacity),t.n(e.count)},loadDescriptorBlock:function(t,e){var i=0;i=t.n();for(var n=0;n!==i;++n){var r=t.s(),s=new btt;Gtt(t,s),e.descriptors.set(r,s)}i=t.n();for(var a=0;a!==i;++a){var o=t.s(),h=new f_;utt(t,h),e.uniformBlocks.set(o,h)}e.capacity=t.n(),e.count=t.n()},saveDescriptorBlockFlattened:function(t,e){t.n(e.descriptorNames.length);for(var i,n=f(e.descriptorNames);!(i=n()).done;){var r=i.value;t.s(r)}t.n(e.uniformBlockNames.length);for(var s,a=f(e.uniformBlockNames);!(s=a()).done;){var o=s.value;t.s(o)}t.n(e.descriptors.length);for(var h,u=f(e.descriptors);!(h=u()).done;)ktt(t,h.value);t.n(e.uniformBlocks.length);for(var l,c=f(e.uniformBlocks);!(l=c()).done;)htt(t,l.value);t.n(e.capacity),t.n(e.count)},loadDescriptorBlockFlattened:function(t,e){var i=0;i=t.n(),e.descriptorNames.length=i;for(var n=0;n!==i;++n)e.descriptorNames[n]=t.s();i=t.n(),e.uniformBlockNames.length=i;for(var r=0;r!==i;++r)e.uniformBlockNames[r]=t.s();i=t.n(),e.descriptors.length=i;for(var s=0;s!==i;++s){var a=new btt;Gtt(t,a),e.descriptors[s]=a}i=t.n(),e.uniformBlocks.length=i;for(var o=0;o!==i;++o){var h=new f_;utt(t,h),e.uniformBlocks[o]=h}e.capacity=t.n(),e.count=t.n()},saveDescriptorBlockIndex:function(t,e){t.n(e.updateFrequency),t.n(e.parameterType),t.n(e.descriptorType),t.n(e.visibility)},loadDescriptorBlockIndex:function(t,e){e.updateFrequency=t.n(),e.parameterType=t.n(),e.descriptorType=t.n(),e.visibility=t.n()},saveResolvePair:function(t,e){t.s(e.source),t.s(e.target),t.n(e.resolveFlags),t.n(e.mode),t.n(e.mode1)},loadResolvePair:function(t,e){e.source=t.s(),e.target=t.s(),e.resolveFlags=t.n(),e.mode=t.n(),e.mode1=t.n()},saveCopyPair:function(t,e){t.s(e.source),t.s(e.target),t.n(e.mipLevels),t.n(e.numSlices),t.n(e.sourceMostDetailedMip),t.n(e.sourceFirstSlice),t.n(e.sourcePlaneSlice),t.n(e.targetMostDetailedMip),t.n(e.targetFirstSlice),t.n(e.targetPlaneSlice)},loadCopyPair:function(t,e){e.source=t.s(),e.target=t.s(),e.mipLevels=t.n(),e.numSlices=t.n(),e.sourceMostDetailedMip=t.n(),e.sourceFirstSlice=t.n(),e.sourcePlaneSlice=t.n(),e.targetMostDetailedMip=t.n(),e.targetFirstSlice=t.n(),e.targetPlaneSlice=t.n()},saveMovePair:function(t,e){t.s(e.source),t.s(e.target),t.n(e.mipLevels),t.n(e.numSlices),t.n(e.targetMostDetailedMip),t.n(e.targetFirstSlice),t.n(e.targetPlaneSlice)},loadMovePair:function(t,e){e.source=t.s(),e.target=t.s(),e.mipLevels=t.n(),e.numSlices=t.n(),e.targetMostDetailedMip=t.n(),e.targetFirstSlice=t.n(),e.targetPlaneSlice=t.n()},savePipelineStatistics:function(t,e){t.n(e.numRenderPasses),t.n(e.numManagedTextures),t.n(e.totalManagedTextures),t.n(e.numUploadBuffers),t.n(e.numUploadBufferViews),t.n(e.numFreeUploadBuffers),t.n(e.numFreeUploadBufferViews),t.n(e.numDescriptorSets),t.n(e.numFreeDescriptorSets),t.n(e.numInstancingBuffers),t.n(e.numInstancingUniformBlocks)},loadPipelineStatistics:function(t,e){e.numRenderPasses=t.n(),e.numManagedTextures=t.n(),e.totalManagedTextures=t.n(),e.numUploadBuffers=t.n(),e.numUploadBufferViews=t.n(),e.numFreeUploadBuffers=t.n(),e.numFreeUploadBufferViews=t.n(),e.numDescriptorSets=t.n(),e.numFreeDescriptorSets=t.n(),e.numInstancingBuffers=t.n(),e.numInstancingUniformBlocks=t.n()},get PipelineType(){return Vet},get SubpassCapabilities(){return Uet},PipelineCapabilities:Het,packRGBE:function(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=Fi((i=Math.ceil(i))+128,0,255));var n=1/Math.pow(1.1,i-128),r=function(t,e,i){if(e>i){var n=e;e=i,i=n}return ti?i:t}(t.multiplyScalar(n),new gn(0,0,0),new gn(1,1,1));r.multiplyScalar(255);var s,a,o=xn(r).add((s=r.subtract(xn(r)))<(a=new gn(.5,.5,.5))?a:s);return new cn(o.x/255,o.y/255,o.z/255,i/255)},setEditorPipelineSettings:function(t){mst=t,gst=!0},getEditorPipelineSettings:function(){return mst},forceResizeAllWindows:vst,defaultWindowResize:function(t,e,i,n){t.addRenderWindow(e.colorName,ec.BGRA8,i,n,e),t.addDepthStencil(e.depthStencilName,ec.DEPTH_STENCIL,i,n);var r=e.renderWindowId,s=uy(t.device)?ec.R32F:ec.RGBA8,a=t.pipelineSceneData.shadows.size;t.addRenderTarget("ShadowMap"+r,s,a.x,a.y),t.addDepthStencil("ShadowDepth"+r,ec.DEPTH_STENCIL,a.x,a.y)},dispatchResizeEvents:function(t,e,i){if(e.windowResize){for(var n,r=f(t);!(n=r()).done;){var s=n.value;if(s.window.isRenderWindowResized()||gst){var a=Math.max(Math.floor(s.window.width),1),o=Math.max(Math.floor(s.window.height),1);e.windowResize(i,s.window,s,a,o),yst.push(s.window)}}for(var h,u=f(yst);!(h=u()).done;)h.value.setRenderWindowResizeHandled();yst.length=0,gst=!1}}});t("eC",Est),S.rendering=Est;var Cst=Object.setPrototypeOf,xst={};xst||(xst={}),function(t){var e=function(){function e(i){this._clock=new t.WorldClock,this._events=[],this._objects=[],this._eventManager=null,this._eventManager=i,console.info("DragonBones: "+e.VERSION+"\nWebsite: http://dragonbones.com/\nSource and Demo: https://github.com/DragonBones/")}return e.prototype.advanceTime=function(e){if(this._objects.length>0){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}(xst||(xst={})),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,_=i*h+r*u+a,f=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,v=i*h+r*c+a,y=n*h+s*c+o,S=0;_>d&&(S=_,_=d,d=S),m>v&&(S=m,m=v,v=S),t.x=Math.floor(_v?d:v)-t.x),f>p&&(S=f,f=p,p=S),g>y&&(S=g,g=y,y=S),t.y=Math.floor(fy?p:y)-t.y)},t}();t.Matrix=e}(xst||(xst={})),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}(xst||(xst={})),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}(xst||(xst={})),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}(xst||(xst={})),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}(xst||(xst={})),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 Cst(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 Cst(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 Cst(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 Cst(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}(xst||(xst={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Cst(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 Cst(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 Cst(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}(xst||(xst={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Cst(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}(xst||(xst={})),function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.displays={},e}return Cst(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 _=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 Cst(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,_=c*c,f=i-t,d=(n*=c)-(e*=c),p=Math.sqrt(f*f+d*d),m=f/p,g=d/p,v=(r-t)*m+(s-e)*g,y=a*a,S=y-(t*t+e*e)+v*v,T=0;if(S>=0){var A=Math.sqrt(S),b=v-A,E=v+A,C=b<0?-1:b<=p?0:1,x=E<0?-1:E<=p?0:1,w=C*x;if(w<0)return-1;0===w&&(-1===C?(T=2,i=t+E*m,n=(e+E*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/y*_,i/y),l.y=l.x+Math.PI)):1===x?(T=1,t+=b*m,e=(e+b*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/y*_,t/y),l.y=l.x+Math.PI)):(T=3,null!==h&&(h.x=t+b*m,h.y=(e+b*g)/c,null!==l&&(l.x=Math.atan2(h.y/y*_,h.x/y))),null!==u&&(u.x=t+E*m,u.y=(e+E*g)/c,null!==l&&(l.y=Math.atan2(u.y/y*_,u.x/y)))))}return T},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 Cst(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,_=0,f=r[h-2],d=r[h-1],p=0,m=0,g=0,v=0,y=0,S=0,T=0;T=f&&R<=A||R>=A&&R<=f)&&(0===u||R>=t&&R<=i||R>=i&&R<=t)){var I=(c*C-l*x)/w;if((I>=d&&I<=b||I>=b&&I<=d)&&(0===l||I>=e&&I<=n||I>=n&&I<=e)){if(null===a){g=R,v=I,y=R,S=I,_++,null!==o&&(o.x=Math.atan2(b-d,A-f)-.5*Math.PI,o.y=o.x);break}var D=R-t;D<0&&(D=-D),0===_?(p=D,m=D,g=R,v=I,y=R,S=I,null!==o&&(o.x=Math.atan2(b-d,A-f)-.5*Math.PI,o.y=o.x)):(Dm&&(m=D,y=R,S=I,null!==o&&(o.y=Math.atan2(b-d,A-f)-.5*Math.PI))),_++}}f=A,d=b}return 1===_?(null!==s&&(s.x=g,s.y=v),null!==a&&(a.x=g,a.y=v),null!==o&&(o.y=o.x+Math.PI)):_>1&&(_++,null!==s&&(s.x=g,s.y=v),null!==a&&(a.x=y,a.y=S)),_},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=S;break}var T;null!==r&&((T=o?r.y-e:r.x-t)<0&&(T=-T),(null===m||Tu)&&(u=T,_=s.x,f=s.y,g=S,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=_,s.y=f,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+f)+((r=i>this._kX*(t+s)+m)?1:0)),this._matrixCahce[d]>0)v.copyFromArray(g,d+1);else{var y=f*(u+2),S=this._hullCache[4],T=this._hullCache[5],A=this._hullCache[2]-(h-f)*S,b=this._hullCache[3]-(h-f)*T,E=this._vertices;r?this._getAffineTransform(-s,m+c,800,c,E[y+u+2],E[y+u+3],A+S,b+T,E[y],E[y+1],e._helpTransform,v,!0):this._getAffineTransform(-n,m,800,c,A,b,E[y],E[y+1],A+S,b+T,e._helpTransform,v,!1),g[d]=1,g[d+1]=v.a,g[d+2]=v.b,g[d+3]=v.c,g[d+4]=v.d,g[d+5]=v.tx,g[d+6]=v.ty}}else if(t>=s){if(i<-s||i>=s)return this.globalTransformMatrix;d=7*(2*(o*(h+1)+o+f)+((r=i>this._kX*(t-n)+m)?1:0)),this._matrixCahce[d]>0?v.copyFromArray(g,d+1):(y=(f+1)*(u+2)-2,S=this._hullCache[4],T=this._hullCache[5],A=this._hullCache[0]+f*S,b=this._hullCache[1]+f*T,E=this._vertices,r?this._getAffineTransform(n,m+c,800,c,A+S,b+T,E[y+u+2],E[y+u+3],A,b,e._helpTransform,v,!0):this._getAffineTransform(s,m,800,c,E[y],E[y+1],A,b,E[y+u+2],E[y+u+3],e._helpTransform,v,!1),g[d]=1,g[d+1]=v.a,g[d+2]=v.b,g[d+3]=v.c,g[d+4]=v.d,g[d+5]=v.tx,g[d+6]=v.ty)}else if(i<-s){if(t<-s||t>=s)return this.globalTransformMatrix;d=7*(o*(h+1)+2*_+((r=i>this._kY*(t-p-l)-n)?1:0)),this._matrixCahce[d]>0?v.copyFromArray(g,d+1):(y=2*_,S=this._hullCache[10],T=this._hullCache[11],A=this._hullCache[8]+_*S,b=this._hullCache[9]+_*T,E=this._vertices,r?this._getAffineTransform(p+l,-s,l,800,E[y+2],E[y+3],E[y],E[y+1],A+S,b+T,e._helpTransform,v,!0):this._getAffineTransform(p,-n,l,800,A,b,A+S,b+T,E[y],E[y+1],e._helpTransform,v,!1),g[d]=1,g[d+1]=v.a,g[d+2]=v.b,g[d+3]=v.c,g[d+4]=v.d,g[d+5]=v.tx,g[d+6]=v.ty)}else if(i>=s){if(t<-s||t>=s)return this.globalTransformMatrix;d=7*(2*(o*(h+1)+o+h+f)+((r=i>this._kY*(t-p-l)+s)?1:0)),this._matrixCahce[d]>0?v.copyFromArray(g,d+1):(y=h*(u+2)+2*_,S=this._hullCache[10],T=this._hullCache[11],A=this._hullCache[6]-(o-_)*S,b=this._hullCache[7]-(o-_)*T,E=this._vertices,r?this._getAffineTransform(p+l,n,l,800,A+S,b+T,A,b,E[y+2],E[y+3],e._helpTransform,v,!0):this._getAffineTransform(p,s,l,800,E[y],E[y+1],E[y+2],E[y+3],A,b,e._helpTransform,v,!1),g[d]=1,g[d+1]=v.a,g[d+2]=v.b,g[d+3]=v.c,g[d+4]=v.d,g[d+5]=v.tx,g[d+6]=v.ty)}else d=7*(2*(o*f+_)+((r=i>this._k*(t-p-l)+m)?1:0)),this._matrixCahce[d]>0?v.copyFromArray(g,d+1):(y=2*_+f*(u+2),E=this._vertices,r?this._getAffineTransform(p+l,m+c,l,c,E[y+u+4],E[y+u+5],E[y+u+2],E[y+u+3],E[y+2],E[y+3],e._helpTransform,v,!0):this._getAffineTransform(p,m,l,c,E[y],E[y+1],E[y+2],E[y+3],E[y+u+2],E[y+u+3],e._helpTransform,v,!1),g[d]=1,g[d+1]=v.a,g[d+2]=v.b,g[d+3]=v.c,g[d+4]=v.d,g[d+5]=v.tx,g[d+6]=v.ty);return v},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,_=2*this.global.y,f=e._helpPoint;this.globalTransformMatrix.transformPoint(1e3,-200,f),this._hullCache[0]=f.x,this._hullCache[1]=f.y,this._hullCache[2]=c-f.x,this._hullCache[3]=_-f.y,this.globalTransformMatrix.transformPoint(0,this._dY,f,!0),this._hullCache[4]=f.x,this._hullCache[5]=f.y,this.globalTransformMatrix.transformPoint(200,1e3,f),this._hullCache[6]=f.x,this._hullCache[7]=f.y,this._hullCache[8]=c-f.x,this._hullCache[9]=_-f.y,this.globalTransformMatrix.transformPoint(this._dX,0,f,!0),this._hullCache[10]=f.x,this._hullCache[11]=f.y}else this._childrenTransformDirty&&(this._childrenTransformDirty=!1);this._localDirty=!0},e}(t.Bone);t.Surface=e}(xst||(xst={})),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 Cst(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 F=p[W];if(!(N>F)){0===W?N/=F:N=(N-(V=p[W-1]))/(F-V);break}}if(W!==_){_=W;var k=6*W;for(E=u[k],C=u[k+1],x=u[k+2],w=u[k+3],R=u[k+4],I=u[k+5],S=2*(m=.03*(E-2*x+R))+(v=.006*(3*(x-R)-E+(D=u[k+6]))),T=2*(g=.03*(C-2*w+I))+(y=.006*(3*(w-I)-C+(B=u[k+7]))),A=.3*(x-E)+m+.16666667*v,b=.3*(w-C)+g+.16666667*y,O=Math.sqrt(A*A+b*b),P[0]=O,k=1;k<8;k++)A+=S,b+=T,S+=v,T+=y,O+=Math.sqrt(A*A+b*b),P[k]=O;A+=S,b+=T,O+=Math.sqrt(A*A+b*b),P[8]=O,A+=S+v,b+=T+y,O+=Math.sqrt(A*A+b*b),P[9]=O,L=0}for(N*=O;;L++){var G=P[L];if(!(N>G)){var V;0===L?N/=G:N=L+(N-(V=P[L-1]))/(G-V);break}}this.addCurvePosition(.1*N,E,C,x,w,R,I,D,B,a,H,i)}}else{var U=t.curveLengths;if(d=U[c-=h?1:2],n&&(f*=d),r)for(var z=0;zd)continue}for(var X=0;;W++){var j=U[W];if(!(f>j)){if(0===W)X=f/j;else{var Y=U[W-1];X=(f-Y)/(j-Y)}break}}W!==_&&(_=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(X,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 _=1-t,f=_*_,d=t*t,p=f*_,m=f*t*3,g=_*d*3,v=t*d,y=p*e+m*n+g*s+v*o,S=p*i+m*r+g*a+v*h;u[l]=y,u[l+1]=S,u[l+2]=c?Math.atan2(S-(p*i+m*r+g*a),y-(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 R=this.rotateMix,I=this.translateMix,D=(g=0,3);g0){var F=M.a,k=M.b,G=M.c,V=M.d,U=void 0,z=void 0,H=void 0;if(U=_?E[D-1]:Math.atan2(O,P),U-=Math.atan2(k,F),b){z=Math.cos(U),H=Math.sin(U);var W=B._boneData.length;x+=(W*(z*F-H*k)-P)*R,w+=(W*(H*F+z*k)-O)*R}else U+=C;U>t.Transform.PI?U-=t.Transform.PI_D:U<-t.Transform.PI&&(U+=t.Transform.PI_D),U*=R,z=Math.cos(U),H=Math.sin(U),M.a=z*F-H*k,M.b=H*F+z*k,M.c=z*G-H*V,M.d=H*G+z*V}B.global.fromMatrix(M)}this.dirty=!1}}},i.prototype.invalidUpdate=function(){},i}(e);t.PathConstraint=n}(xst||(xst={})),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 _=0,f=0;_0&&d._subFadeState>0?(f++,this._armature._dragonBones.bufferObject(d),this._animationDirty=!0,this._lastAnimationState===d&&(this._lastAnimationState=null)):(f>0&&(this._animationStates[_-f]=d),d.advanceTime(t,0)),_===e-1&&f>0&&(this._animationStates.length-=f,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,_=this._armature.getSlots();c<_.length;c++){var f=_[c].childArmature;null!==f&&f.inheritAnimation&&f.animation.hasAnimation(i)&&null===f.animation.getState(i)&&f.animation.fadeIn(i)}var d=!1;for(var p in n.animationTimelines){this._lockUpdate||(d=!0,this._lockUpdate=!0);var m=this.fadeIn(p,e.fadeInTime,1,o.layer,null,0);null!==m&&(m.resetToPose=!1,m._parent=o,m.stop())}return d&&(this._lockUpdate=!1),this._lockUpdate||(e.fadeInTime<=0&&this._armature.advanceTime(0),this._lastAnimationState=o),o},i.prototype.play=function(t,e){if(void 0===t&&(t=null),void 0===e&&(e=-1),this._animationConfig.clear(),this._animationConfig.resetToPose=!0,this._animationConfig.playTimes=e,this._animationConfig.fadeInTime=0,this._animationConfig.animation=null!==t?t:"",null!==t&&t.length>0)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 f=0,d=this._poseTimelines;f0&&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 0!=(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}(xst||(xst={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Cst(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 Cst(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 Cst(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 Cst(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 Cst(e,t),e.prototype._onClear=function(){t.prototype._onClear.call(this),this.constraint=null},e}(i);t.ConstraintTimelineState=s}(xst||(xst={})),function(t){var e=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return Cst(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),_=this._frameIndices[l.frameIndicesOffset+c];if(this._frameIndex!==_){var f=this._frameIndex;if(this._frameIndex=_,null!==this._timelineArray)if(this._frameOffset=this._animationData.frameOffset+this._timelineArray[l.offset+5+this._frameIndex],o){if(f<0){var d=Math.floor(r*this._frameRate);f=this._frameIndices[l.frameIndicesOffset+d],this.currentPlayTimes===n&&f===_&&(f=-1)}for(;f>=0;){var p=this._animationData.frameOffset+this._timelineArray[l.offset+5+f],m=this._frameArray[p]/this._frameRate;if(this._position<=m&&m<=this._position+this._duration&&this._onCrossFrame(f),null!==h&&0===f&&(this._armature._dragonBones.bufferEvent(h),h=null),f>0?f--:f=this._frameCount-1,f===_)break}}else for(f<0&&(d=Math.floor(r*this._frameRate),f=this._frameIndices[l.frameIndicesOffset+d],p=this._animationData.frameOffset+this._timelineArray[l.offset+5+f],m=this._frameArray[p]/this._frameRate,this.currentPlayTimes===n&&(r<=m?f>0?f--:f=this._frameCount-1:f===_&&(f=-1)));f>=0&&(f=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 Cst(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 Cst(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 Cst(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 Cst(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 Cst(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 Cst(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 Cst(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=_}(xst||(xst={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Cst(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}(xst||(xst={})),function(t){var e=function(){function e(){}return e._getArmatureType=function(t){switch(t.toLowerCase()){case"stage":return 2;case"armature":return 0;case"movieclip":return 1;default:return 0}},e._getBoneType=function(t){switch(t.toLowerCase()){case"bone":return 0;case"surface":return 1;default:return 0}},e._getDisplayType=function(t){switch(t.toLowerCase()){case"image":return 0;case"mesh":return 2;case"armature":return 1;case"boundingbox":return 3;case"path":return 4;default:return 0}},e._getBoundingBoxType=function(t){switch(t.toLowerCase()){case"rectangle":return 0;case"ellipse":return 1;case"polygon":return 2;default:return 0}},e._getActionType=function(t){switch(t.toLowerCase()){case"play":return 0;case"frame":return 10;case"sound":return 11;default:return 0}},e._getBlendMode=function(t){switch(t.toLowerCase()){case"normal":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;default:return 0}},e._getPositionMode=function(t){switch(t.toLocaleLowerCase()){case"percent":return 1;case"fixed":return 0;default:return 1}},e._getSpacingMode=function(t){switch(t.toLocaleLowerCase()){case"length":return 0;case"percent":return 2;case"fixed":return 1;default:return 0}},e._getRotateMode=function(t){switch(t.toLocaleLowerCase()){case"tangent":return 0;case"chain":return 1;case"chainscale":return 2;default:return 0}},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,_=h*h,f=l*c,d=3*h*c,p=3*l*_,m=h*_;u.x=f*t+d*i+p*r+m*a,u.y=f*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 v=.5*(g+m);this._getCurvePoint(h,u,l,c,_,f,d,p,v,this._helpPoint),a-this._helpPoint.x>0?m=v:g=v}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,_=h;c<_.length;c++){var f=_[c];this._armature.addAction(f,!1)}0===this._actionFrames.length&&((l=new i).frameStart=0,this._actionFrames.push(l),l=null);for(var d=0,p=this._actionFrames;dn)break;u++}null===l&&((l=new i).frameStart=n,this._actionFrames.splice(u+1,0,l));for(var g=0;g0){var f=r.getBone(c);null!==f?_.parent=f:(c in this._cacheBones||(this._cacheBones[c]=[]),this._cacheBones[c].push(_))}if(_.name in this._cacheBones){for(var d=0,p=this._cacheBones[_.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 v=e[t.DataParser.LENGTHS],y=a=t.BaseObject.borrowObject(t.PathDisplayData);y.closed=n._getBoolean(e,t.DataParser.CLOSED,!1),y.constantSpeed=n._getBoolean(e,t.DataParser.CONSTANT_SPEED,!1),y.name=i,y.path=r.length>0?r:i,y.vertices.data=this._data,y.curveLengths.length=v.length;for(var S=0,T=v.length;Si.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 _=this._frameIntArray.length,f=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?_-this._animation.frameIntOffset:h?f-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,v=0;t.DragonBones.webAssembly?(v=g.size(),g.resize(v+m,0)):(v=g.length,g.length+=m),d.frameIndicesOffset=v;for(var y=0,S=0,T=0,A=0;y0)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 _=0;_<2*u;_+=2)l=_=o.length?0:o[_-h],c=_+1=o.length?0:o[_+1-h],this._frameFloatArray[s+_]=l,this._frameFloatArray[s+_+1]=c;if(0===i){var f=this._frameIntArray.length;this._frameIntArray.length+=5,this._frameIntArray[f+0]=0,this._frameIntArray[f+1]=this._frameFloatArray.length-s,this._frameIntArray[f+2]=this._frameFloatArray.length-s,this._frameIntArray[f+3]=0,this._frameIntArray[f+4]=s-this._animation.frameFloatOffset,this._timelineArray[this._timeline.offset+3]=f-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,_=0,f=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?(_=0,f=0):(_=g=o.length?0:o[g-h],f=g+1=o.length?0:o[g+1-h]),null!==c){var v=this._weightBonePoses[l],y=this._intArray[d++];this._helpMatrixA.transformPoint(_,f,this._helpPoint,!0),_=this._helpPoint.x,f=this._helpPoint.y;for(var S=0;S=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&&_>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=_),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}(xst||(xst={})),function(t){var e=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return Cst(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,_=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 _=0,f=c;_=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,_=u.displayList;_.length=c;for(var f=0,d=c;f0&&n.inheritDeform,a=this._localVertices;if(r){var o=n.data,h=o.intArray,u=o.floatArray,l=h[n.offset+sot.MeshVertexCount],c=h[r.offset+sot.WeigthFloatOffset];c<0&&(c+=65536);for(var _=0,f=r.offset+sot.WeigthBoneIndices+i.length,d=c,p=0,m=0;_=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=Vst.borrowObject(Aat);e._skinData=t.skin,e._animation=Vst.borrowObject(Bat),e._animation._armature=e,e._animation.animations=t.armature.animations,e._isChildArmature=!1;var i=new vot;return e.init(t.armature,i,i,this._dragonBones),e},i._buildSlot=function(t,e,i){var n=Vst.borrowObject(got),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}(not))._factory=null,Bst=Mst))||Bst,Sot=1/60,Tot=[],Aot=[],bot=0,Eot=0,Cot=0,xot=null,wot=null,Rot=0,Iot=0,Dot=0,Bot=0,Mot=0,Pot=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[Bot-1].vfOffset=Cot),r.length=Bot,s.length=bot;var a=Dot-1;if(a>=0)if(Iot>0){var o=n[a];o.indexCount=Iot,o.vfCount=9*Rot,o.vertexCount=Rot,n.length=Dot}else n.length=Dot-1;if(0!==n.length){var h,u=i.vertices,l=Cot/5,c=9*l;(!u||u.length>8&255)/255,u[_+7]=(h>>16&255)/255,u[_+8]=(h>>24&255)/255,_+=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,_=this._tempSegments,f=this._tempBoneInfos,d=t._slots,p=t._bones;if(this._enableCacheAttachedInfo)for(var m=0,g=p.length;m=0&&(Iot>0?((l=_[u]).indexCount=Iot,l.vertexCount=Rot,l.vfCount=9*Rot):Dot--),_[Dot]={tex:h,blendMode:r._blendMode,indexCount:0,vertexCount:0,vfCount:0},Dot++,Iot=0,Rot=0),o=(a.a*e<<24>>>0)+(a.b<<16)+(a.g<<8)+a.r,Mot!==o&&(Mot=o,Bot>0&&(c[Bot-1].vfOffset=Cot),c[Bot++]={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 b=0,E=i.length;b":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&&(Oot.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}(vd),kst=ja(Fst.prototype,"_dragonBonesJson",[Hot],(function(){return""})),Nst=Fst))||Nst;S.internal.DragonBonesAsset=Wot;var Xot,jot=lo,Yot=Lo,qot=(Lot=eo("dragonBones.DragonBonesAtlasAsset"),Not=Yot(lm),Lot((kot=function(t){function e(){var e;return(e=t.call(this)||this)._atlasJson=Got&&Got(),e._texture=Vot&&Vot(),e._atlasJsonData=Uot&&Uot(),e._factory=null,e._textureAtlasData=zot&&zot(),e._clear(),e}s(e,t);var i=e.prototype;return i.createNode=function(t){var e=new hg(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&&(Oot.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}(vd),Got=ja(kot.prototype,"_atlasJson",[jot],(function(){return""})),Vot=ja(kot.prototype,"_texture",[jot,Not],(function(){return null})),Uot=ja(kot.prototype,"_atlasJsonData",[jot],(function(){return{}})),zot=ja(kot.prototype,"_textureAtlasData",[jot],(function(){return null})),Fot=kot))||Fot);S.internal.DragonBonesAtlasAsset=qot;var Kot,Qot,Zot,Jot,$ot,tht,eht,iht,nht,rht,sht,aht,oht,hht,uht,lht,cht,_ht,fht,dht,pht,mht,ght,vht,yht,Sht,Tht,Aht,bht,Eht,Cht,xht,wht,Rht,Iht=new Vn,Dht=eo("dragonBones.AttachUtil")(Xot=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=Iht).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=Iht)}else a.delete(u.path),s.splice(h,1)}}},t}())||Xot,Bht=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,ID.registerSystem(e.ID,e._instance,Ml.Priority.HIGH)),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}(Ml);Bht.ID="ARMATURE",Bht._instance=void 0,S.internal.ArmatureSystem=Bht,function(t){t[t.default=-1]="default"}(Cht||(Cht={})),we(Cht),function(t){t[t[""]=0]=""}(xht||(xht={})),we(xht),function(t){t[t.REALTIME=0]="REALTIME"}(wht||(wht={})),we(xht),function(t){t[t.REALTIME=0]="REALTIME",t[t.SHARED_CACHE=1]="SHARED_CACHE",t[t.PRIVATE_CACHE=2]="PRIVATE_CACHE"}(Rht||(Rht={})),we(Rht);var Mht=eo,Pht=lo,Oht=Lo,Lht=jo,Nht=(Kot=Mht("dragonBones.ArmatureDisplay.DragonBoneSocket"),Qot=Oht(hg),Kot((Jot=function(t,e){void 0===t&&(t=""),void 0===e&&(e=null),this.path=$ot&&$ot(),this.target=tht&&tht(),this.boneIndex=null,this.path=t,this.target=e},$ot=ja(Jot.prototype,"path",[Pht],(function(){return""})),tht=ja(Jot.prototype,"target",[Qot,Pht],(function(){return null})),Zot=Jot))||Zot);ne(Nht,"dragonBones.ArmatureDisplay.DragonBoneSocket");var Fht=(eht=Mht("dragonBones.ArmatureDisplay"),iht=Oht(Wot),nht=Oht(qot),rht=Oht(Cht),sht=Oht(xht),aht=Oht([Nht]),oht=Oht(zT),eht(((Eht=function(t){s(i,t);var e=i.prototype;function i(){var e;return(e=t.call(this)||this).playTimes=lht&&lht(),e.premultipliedAlpha=cht&&cht(),e._armature=null,e.attachUtil=void 0,e._defaultArmatureIndexValue=_ht&&_ht(),e._dragonAsset=fht&&fht(),e._dragonAtlasAsset=dht&&dht(),e._armatureName=pht&&pht(),e._animationName=mht&&mht(),e._animationIndexValue=ght&&ght(),e._preCacheMode=-1,e._cacheMode=Rht.REALTIME,e._defaultCacheModeValue=vht&&vht(),e._timeScale=yht&&yht(),e._playTimes=Sht&&Sht(),e._debugBones=Tht&&Tht(),e._enableBatch=Aht&&Aht(),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 Rs((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=bht&&bht(),e._inited=void 0,e._drawInfoList=[],e._cacheModeEnum=void 0,e._eventTarget=new Hs,e._inited=!1,e.attachUtil=new Dht,e.initFactory(),mi(c(e),"_animationIndex",e._enumAnimations),mi(c(e),"_defaultArmatureIndex",e._enumArmatures),e._useVertexOpacity=!0,e}return e.requestDrawInfo=function(t){return this._drawInfoList[t]||(this._drawInfoList[t]=new QP),this._drawInfoList[t]},e.initFactory=function(){this._factory=yot.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 ZT({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 bT.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,this._cacheMode===Rht.PRIVATE_CACHE?(this._armatureCache.dispose(),this._armatureCache=null,this._armature=null):this._cacheMode===Rht.SHARED_CACHE?(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=new hg("DEBUG_DRAW_NODE");t.hideFlags|=Ms.Flags.DontSave|Ms.Flags.HideInHierarchy;var e=t.addComponent(AF);e.lineWidth=1,e.strokeColor=new En(255,0,0,255),this._debugDraw=e}this._debugDraw.node.parent=this.node}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&&(this._preCacheMode===Rht.PRIVATE_CACHE?this._armatureCache.dispose():this._preCacheMode===Rht.REALTIME&&this._armature.dispose(),this._armatureCache=null,this._armature=null,this._displayProxy=null,this._frameCache=null,this._curFrame=null,this._playing=!1,this._preCacheMode=-1),this._cacheMode===Rht.SHARED_CACHE?this._armatureCache=Oot.sharedCache:this._cacheMode===Rht.PRIVATE_CACHE&&(this._armatureCache=new Oot,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=Rht.REALTIME)),this._preCacheMode=this._cacheMode,this._cacheMode===Rht.REALTIME){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(this._cacheMode!==Rht.REALTIME&&this.debugBones&&z("Debug bones is invalid in cached mode"),this._armature){var e=this._armature.armatureData.aabb;this.node._uiProps.uiTransformComp.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=f(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,Rht):Object.assign(this._cacheModeEnum,wht),mi(this,"_defaultCacheMode",this._cacheModeEnum)},e._updateAnimEnum=function(){var t;t=this.dragonAsset?this.dragonAsset.getAnimsEnum(this.armatureName):xht,this._enumAnimations=Ee({}),Object.assign(this._enumAnimations,t||xht),Ee.update(this._enumAnimations),mi(this,"_animationIndex",this._enumAnimations)},e._updateArmatureEnum=function(){var t;t=this.dragonAsset?this.dragonAsset.getArmatureEnum():Cht,this._enumArmatures=Ee({}),Object.assign(this._enumArmatures,t||Cht),Ee.update(this._enumArmatures),mi(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}(XO)).AnimationCacheMode=Rht,m((uht=Eht).prototype,"dragonAsset",[iht],Object.getOwnPropertyDescriptor(uht.prototype,"dragonAsset"),uht.prototype),m(uht.prototype,"dragonAtlasAsset",[nht],Object.getOwnPropertyDescriptor(uht.prototype,"dragonAtlasAsset"),uht.prototype),m(uht.prototype,"_defaultArmatureIndex",[rht],Object.getOwnPropertyDescriptor(uht.prototype,"_defaultArmatureIndex"),uht.prototype),m(uht.prototype,"_animationIndex",[sht],Object.getOwnPropertyDescriptor(uht.prototype,"_animationIndex"),uht.prototype),m(uht.prototype,"timeScale",[Pht],Object.getOwnPropertyDescriptor(uht.prototype,"timeScale"),uht.prototype),lht=ja(uht.prototype,"playTimes",[Pht],(function(){return-1})),cht=ja(uht.prototype,"premultipliedAlpha",[Pht],(function(){return!1})),m(uht.prototype,"sockets",[aht],Object.getOwnPropertyDescriptor(uht.prototype,"sockets"),uht.prototype),_ht=ja(uht.prototype,"_defaultArmatureIndexValue",[Pht],(function(){return Cht.default})),fht=ja(uht.prototype,"_dragonAsset",[Pht],(function(){return null})),dht=ja(uht.prototype,"_dragonAtlasAsset",[Pht],(function(){return null})),pht=ja(uht.prototype,"_armatureName",[Pht],(function(){return""})),mht=ja(uht.prototype,"_animationName",[Pht],(function(){return""})),ght=ja(uht.prototype,"_animationIndexValue",[Pht],(function(){return 0})),vht=ja(uht.prototype,"_defaultCacheModeValue",[Pht],(function(){return Rht.REALTIME})),yht=ja(uht.prototype,"_timeScale",[Pht],(function(){return 1})),Sht=ja(uht.prototype,"_playTimes",[Pht],(function(){return-1})),Tht=ja(uht.prototype,"_debugBones",[Pht],(function(){return!1})),Aht=ja(uht.prototype,"_enableBatch",[Pht],(function(){return!1})),bht=ja(uht.prototype,"_sockets",[Pht],(function(){return[]})),m(uht.prototype,"customMaterial",[Lht,oht],Object.getOwnPropertyDescriptor(uht.prototype,"customMaterial"),uht.prototype),hht=uht))||hht);S.internal.ArmatureDisplay=Fht;var kht,Ght,Vht,Uht,zht,Hht,Wht,Xht,jht,Yht,qht,Kht=new En(255,0,0,255),Qht=new En(0,0,255,255),Zht=new En(0,255,0,255),Jht=0,$ht=0,tut=0,eut=0,iut=0,nut=0,rut=0,sut=0,aut=0,out=new Float32Array(4),hut=new gn(0,0,0),uut=new Vn,lut=null,cut=null;function _ut(t,e){if(!t)return null;var i,n;switch(e){case 1:i=zht?vc.ONE:vc.SRC_ALPHA,n=vc.ONE;break;case 10:i=vc.DST_COLOR,n=vc.ONE_MINUS_SRC_ALPHA;break;case 12:i=vc.ONE,n=vc.ONE_MINUS_SRC_COLOR;break;case 0:default:i=zht?vc.ONE:vc.SRC_ALPHA,n=vc.ONE_MINUS_SRC_ALPHA}return Yht.getMaterialForBlend(i,n)}function fut(t,e){var i=t.a*e*Uht,n=zht?i/255:1,r=t.r*kht*n/255,s=t.g*Ght*n/255,a=t.b*Vht*n/255;out[0]=r,out[1]=s,out[2]=a,out[3]=zht?1:i/255}var dut=null,put={accessor:dut,vCount:32767,ensureAccessor:function(){if(!dut){var t=ID.root.device,e=ID.root.batcher2D,i=PP;this.accessor=dut=new YP(t,i,this.vCount),e.registerBufferAccessor(Number.parseInt("DRAGONBONES",36),dut)}return this.accessor},createData:function(t){var e=t.renderData;if(!e){this.ensureAccessor();for(var i=t._armature._slots,n=0,r=0,s=0;s0&&(Yht._requestDrawData(lut,cut,aut,S),aut=nut),lut=n,cut=y.tex}$ht=y.vertexCount,iut=y.indexCount,a=d.chunk.vertexOffset;for(var T=nut,A=nut+iut;T=f&&(fut(_=c[l++],1),f=_.vfOffset),p.set(out,R+5);o+=u,tut+=$ht,nut+=iut,$ht=0,iut=0}}var D=nut-aut;cut&&D>0&&Yht._requestDrawData(lut,cut,aut,D)}}}(t._curFrame,n);else{mut(e,1,n);var r=t._debugDraw;if(t.debugBones&&r){r.clear(),r.lineWidth=5,r.strokeColor=Kht,r.fillColor=Qht;for(var s=e.getBones(),a=0,o=s.length;a0&&(Yht._requestDrawData(lut,cut,aut,d),aut=nut),cut=f,lut=r}fut(o,e),uut.set(h._worldMatrix),s=h._localVertices,$ht=s.length/4,Jht=9*$ht,a=h._indices,iut=a.length;var p=!1;if(tut+$ht>rut&&(rut=tut+$ht,p=!0),nut+iut>sut&&(sut=nut+iut,p=!0),p){var m=Xht,g=n.chunk.vertexOffset;n.resizeAndCopy(rut,sut>n.indexCount?sut:n.indexCount),jht=n.chunk.vb,sut>Xht.length&&(Xht=n.indices=new Uint16Array(sut));for(var v=n.chunk.vertexOffset-g,y=0;y0&&(Yht._requestDrawData(lut,cut,aut,u),aut=nut),Yht.maxIndexCountr._maxVertices)tt(12008);else{var s=r._vertexCount*(gn.length+En.length);gn.toArray(r._vertices,t,s),s+=gn.length,En.toArray(r._vertices,i,s),s+=En.length,gn.toArray(r._vertices,e,s),s+=gn.length,En.toArray(r._vertices,i,s),r._vertexCount+=2}},e.addLine=function(t,e,i,n){void 0===n&&(n=!0);var r=this._buffers.lines[n?1:0];if(r._vertexCount+2>r._maxVertices)tt(12008);else{var s=r._vertexCount*(gn.length+En.length);gn.toArray(r._vertices,t,s),s+=gn.length,En.toArray(r._vertices,i,s),s+=En.length,gn.toArray(r._vertices,e,s),s+=gn.length,En.toArray(r._vertices,i,s),r._vertexCount+=2}},e.addTriangle=function(t,e,i,n,r,s,a){if(void 0===r&&(r=!0),void 0===s&&(s=!0),void 0===a&&(a=!1),r)return this.addLine(t,e,n,s),this.addLine(e,i,n,s),void this.addLine(i,t,n,s);var o=this._buffers.triangles[s?1:0];if(o._vertexCount+3>o._maxVertices)tt(12009);else{var h=new cn(cn.ZERO);if(!a){var u=new gn(e.x-t.x,e.y-t.y,e.z-t.z),l=new gn(i.x-t.x,i.y-t.y,i.z-t.z),c=new gn;gn.normalize(c,gn.cross(c,u,l)),h.set(c.x,c.y,c.z,1)}var _=o._vertexCount*(gn.length+cn.length+En.length);gn.toArray(o._vertices,t,_),_+=gn.length,cn.toArray(o._vertices,h,_),_+=cn.length,En.toArray(o._vertices,n,_),_+=En.length,gn.toArray(o._vertices,e,_),_+=gn.length,cn.toArray(o._vertices,h,_),_+=cn.length,En.toArray(o._vertices,n,_),_+=En.length,gn.toArray(o._vertices,i,_),_+=gn.length,cn.toArray(o._vertices,h,_),_+=cn.length,En.toArray(o._vertices,n,_),o._vertexCount+=3}},e.addQuad=function(t,e,i,n,r,s,a,o){void 0===s&&(s=!0),void 0===a&&(a=!0),void 0===o&&(o=!1),s?(this.addLine(t,e,r,a),this.addLine(e,i,r,a),this.addLine(i,n,r,a),this.addLine(n,t,r,a)):(this.addTriangle(t,e,i,r,s,a,o),this.addTriangle(t,i,n,r,s,a,o))},e.addBoundingBox=function(t,e,i,n,r,s,a){void 0===i&&(i=!0),void 0===n&&(n=!0),void 0===r&&(r=!1),void 0===s&&(s=!1),void 0===a&&(a=new Vn),Aut.set(t.center.x-t.halfExtents.x,t.center.y-t.halfExtents.y,t.center.z-t.halfExtents.z),but.set(t.center.x+t.halfExtents.x,t.center.y+t.halfExtents.y,t.center.z+t.halfExtents.z),Eut.set(Aut.x,Aut.y,Aut.z),Cut.set(but.x,Aut.y,Aut.z),xut.set(Aut.x,but.y,Aut.z),wut.set(but.x,but.y,Aut.z),Rut.set(Aut.x,Aut.y,but.z),Iut.set(but.x,Aut.y,but.z),Dut.set(Aut.x,but.y,but.z),But.set(but.x,but.y,but.z),s&&(gn.transformMat4(Eut,Eut,a),gn.transformMat4(Cut,Cut,a),gn.transformMat4(xut,xut,a),gn.transformMat4(wut,wut,a),gn.transformMat4(Rut,Rut,a),gn.transformMat4(Iut,Iut,a),gn.transformMat4(Dut,Dut,a),gn.transformMat4(But,But,a)),i?(this.addLine(Dut,But,e,n),this.addLine(But,wut,e,n),this.addLine(wut,xut,e,n),this.addLine(xut,Dut,e,n),this.addLine(Rut,Iut,e,n),this.addLine(Iut,Cut,e,n),this.addLine(Cut,Eut,e,n),this.addLine(Eut,Rut,e,n),this.addLine(Dut,Rut,e,n),this.addLine(But,Iut,e,n),this.addLine(wut,Cut,e,n),this.addLine(xut,Eut,e,n)):(this.addQuad(Rut,Iut,But,Dut,e,i,n,r),this.addQuad(Iut,Cut,wut,But,e,i,n,r),this.addQuad(Cut,Eut,xut,wut,e,i,n,r),this.addQuad(Eut,Rut,Dut,xut,e,i,n,r),this.addQuad(Dut,But,wut,xut,e,i,n,r),this.addQuad(Eut,Cut,Iut,Rut,e,i,n,r))},e.addCross=function(t,e,i,n){void 0===n&&(n=!0);var r=.5*e,s=new gn(t.x-r,t.y,t.z),a=new gn(t.x+r,t.y,t.z);this.addLine(s,a,i,n),s.set(t.x,t.y-r,t.z),a.set(t.x,t.y+r,t.z),this.addLine(s,a,i,n),s.set(t.x,t.y,t.z-r),a.set(t.x,t.y,t.z+r),this.addLine(s,a,i,n)},e.addFrustum=function(t,e,i){void 0===i&&(i=!0);var n=t.vertices;this.addLine(n[0],n[1],e,i),this.addLine(n[1],n[2],e,i),this.addLine(n[2],n[3],e,i),this.addLine(n[3],n[0],e,i),this.addLine(n[4],n[5],e,i),this.addLine(n[5],n[6],e,i),this.addLine(n[6],n[7],e,i),this.addLine(n[7],n[4],e,i),this.addLine(n[0],n[4],e,i),this.addLine(n[1],n[5],e,i),this.addLine(n[2],n[6],e,i),this.addLine(n[3],n[7],e,i)},e.addCapsule=function(t,e,i,n,r,s,a,o,h,u,l){void 0===r&&(r=32),void 0===s&&(s=8),void 0===a&&(a=!0),void 0===o&&(o=!0),void 0===h&&(h=!1),void 0===u&&(u=!1),void 0===l&&(l=Vn.IDENTITY);for(var c=2*Math.PI/r,_=Math.PI/2/s,f=new gn(t.x,t.y-i/2,t.z),d=new gn(t.x,t.y+i/2,t.z),p=new Array,m=new Array,g=0;g0&&4294967295===i)for(var c=new En(255-e.r,255-e.g,255-e.b,e.a),_=t.getKnotCount(),f=t.knots,d=0;d<_;d++){var p=f[d];a&&(p=p.clone().transformMat4(o)),this.addCross(p,n,c,s)}},e.addMesh=function(t,e,i,n,r,s){void 0===n&&(n=!0),void 0===r&&(r=!1),void 0===s&&(s=Vn.IDENTITY);for(var a=0;a0&&(t.extensions.useVAO&&n.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),n.glVAO=null),llt.gpuInputAssembler=null,t.stateCache.glArrayBuffer!==e.glBuffer&&(i.bindBuffer(i.ARRAY_BUFFER,e.glBuffer),t.stateCache.glArrayBuffer=e.glBuffer),i.bufferData(i.ARRAY_BUFFER,e.size,r),i.bindBuffer(i.ARRAY_BUFFER,null),t.stateCache.glArrayBuffer=null))}else if(e.usage&rc.INDEX){e.glTarget=i.ELEMENT_ARRAY_BUFFER;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),llt.gpuInputAssembler=null,t.stateCache.glElementArrayBuffer!==e.glBuffer&&(i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.glBuffer),t.stateCache.glElementArrayBuffer=e.glBuffer),i.bufferData(i.ELEMENT_ARRAY_BUFFER,e.size,r),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,null),t.stateCache.glElementArrayBuffer=null))}else e.usage&rc.UNIFORM?(e.glTarget=i.NONE,e.buffer&&(e.vf32=new Float32Array(e.buffer.buffer))):(e.usage&rc.INDIRECT||e.usage&rc.TRANSFER_DST||e.usage&rc.TRANSFER_SRC||it(16315),e.glTarget=i.NONE)}function rlt(t,e){var i=t.gl,n=t.stateCache;if(e.glBuffer){switch(e.glTarget){case i.ARRAY_BUFFER:t.extensions.useVAO&&n.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),t.stateCache.glVAO=null),llt.gpuInputAssembler=null,i.bindBuffer(i.ARRAY_BUFFER,null),t.stateCache.glArrayBuffer=null;break;case i.ELEMENT_ARRAY_BUFFER:t.extensions.useVAO&&n.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),t.stateCache.glVAO=null),llt.gpuInputAssembler=null,i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,null),t.stateCache.glElementArrayBuffer=null}i.deleteBuffer(e.glBuffer),e.glBuffer=null}}function slt(t,e,i,n,r){if(e.usage&rc.UNIFORM)ArrayBuffer.isView(i)?e.vf32.set(i,n/Float32Array.BYTES_PER_ELEMENT):e.vf32.set(new Float32Array(i),n/Float32Array.BYTES_PER_ELEMENT);else if(e.usage&rc.INDIRECT){e.indirects.clearDraws();for(var s=i.drawInfos,a=0;a0){e.glBlocks=new Array(e.blocks.length);for(var y=0;y0){e.glSamplerTextures=new Array(e.samplerTextures.length);for(var D=0;D=0&&E.gpuDescriptors[C],w=null,R=0;if(x&&x.gpuBuffer){var I=x.gpuBuffer,D=T[b.set],B=D&&D[b.binding];B>=0&&(R=r[B]),"vf32"in I?w=I.vf32:(R+=I.offset,w=I.gpuBuffer.vf32),R>>=2}if(w)for(var M=b.glActiveUniforms.length,P=0;P=0&&Rt.gpuDescriptors[It],Bt=wt.units.length,Mt=0;Mt0){var Ot=Dt.gpuTexture,Lt=l.glTexUnits[Pt];Lt.glTexture!==Ot.glTexture&&(l.texUnit!==Pt&&(u.activeTexture(u.TEXTURE0+Pt),l.texUnit=Pt),Ot.glTexture?u.bindTexture(Ot.glTarget,Ot.glTexture):u.bindTexture(Ot.glTarget,t.nullTex2D.gpuTexture.glTexture),Lt.glTexture=Ot.glTexture);var Nt=Dt.gpuSampler;Ot.isPowerOf2?(a=Nt.glWrapS,o=Nt.glWrapT):(a=u.CLAMP_TO_EDGE,o=u.CLAMP_TO_EDGE),h=Ot.isPowerOf2?Ot.mipLevel<=1&&(Nt.glMinFilter===u.LINEAR_MIPMAP_NEAREST||Nt.glMinFilter===u.LINEAR_MIPMAP_LINEAR)?u.LINEAR:Nt.glMinFilter:Nt.glMinFilter===u.LINEAR||Nt.glMinFilter===u.LINEAR_MIPMAP_NEAREST||Nt.glMinFilter===u.LINEAR_MIPMAP_LINEAR?u.LINEAR:u.NEAREST,Ot.glWrapS!==a&&(l.texUnit!==Pt&&(u.activeTexture(u.TEXTURE0+Pt),l.texUnit=Pt),u.texParameteri(Ot.glTarget,u.TEXTURE_WRAP_S,a),Ot.glWrapS=a),Ot.glWrapT!==o&&(l.texUnit!==Pt&&(u.activeTexture(u.TEXTURE0+Pt),l.texUnit=Pt),u.texParameteri(Ot.glTarget,u.TEXTURE_WRAP_T,o),Ot.glWrapT=o),Ot.glMinFilter!==h&&(l.texUnit!==Pt&&(u.activeTexture(u.TEXTURE0+Pt),l.texUnit=Pt),u.texParameteri(Ot.glTarget,u.TEXTURE_MIN_FILTER,h),Ot.glMinFilter=h),Ot.glMagFilter!==Nt.glMagFilter&&(l.texUnit!==Pt&&(u.activeTexture(u.TEXTURE0+Pt),l.texUnit=Pt),u.texParameteri(Ot.glTarget,u.TEXTURE_MAG_FILTER,Nt.glMagFilter),Ot.glMagFilter=Nt.glMagFilter)}Dt=Rt.gpuDescriptors[++It]}}}if(i&&c&&(_||llt.gpuInputAssembler!==i)){llt.gpuInputAssembler=i;var Ft=t.extensions.ANGLE_instanced_arrays;if(t.extensions.useVAO){var kt=t.extensions.OES_vertex_array_object,Gt=i.glVAOs.get(c.glProgram);if(!Gt){var Vt;Gt=kt.createVertexArrayOES(),i.glVAOs.set(c.glProgram,Gt),kt.bindVertexArrayOES(Gt),u.bindBuffer(u.ARRAY_BUFFER,null),u.bindBuffer(u.ELEMENT_ARRAY_BUFFER,null),l.glArrayBuffer=null,l.glElementArrayBuffer=null;for(var Ut=c.glInputs.length,zt=0;zt=0&&(u.enableVertexAttribArray(ae),l.glEnabledAttribLocs[ae]=!0),l.glCurrentAttribLocs[ae]=!0,u.vertexAttribPointer(ae,ee.count,ee.glType,ee.isNormalized,ee.stride,oe),Ft&&Ft.vertexAttribDivisorANGLE(ae,ee.isInstanced?1:0)}}}var he=i.gpuIndexBuffer;he&&l.glElementArrayBuffer!==he.glBuffer&&(u.bindBuffer(u.ELEMENT_ARRAY_BUFFER,he.glBuffer),l.glElementArrayBuffer=he.glBuffer);for(var ue=0;ue0){var f=e.firstIndex*h.stride;r.drawElementsInstancedANGLE(o,e.indexCount,a.glIndexType,f,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)}}var plt=new Array(Wut.COUNT);function mlt(t,e){plt.fill(0);for(var i=0;i0?m.buffStride:_.width,d.height=m.buffTexHeight>0?m.buffTexHeight:_.height;var v=m.texExtent.width+f.x===i.width>>g?m.texExtent.width:_.width,y=m.texExtent.height+f.y===i.height>>g?m.texExtent.height:_.height,S=void 0,T=e[a++];if(d.width===_.width&&d.height===_.height){var A=Z_(i.format,v,y,1)/u.BYTES_PER_ELEMENT;st(Number.isInteger(A),9101),S=new u(T.buffer,T.byteOffset+m.buffOffset,A)}else S=vlt(T,i.format,m.buffOffset,d,_);l?i.glInternalFmt===Lut.COMPRESSED_RGB_ETC1_WEBGL||t.extensions.noCompressedTexSubImage2D?r.compressedTexImage2D(r.TEXTURE_2D,g,i.glInternalFmt,v,y,0,S):r.compressedTexSubImage2D(r.TEXTURE_2D,g,f.x,f.y,v,y,i.glFormat,S):r.texSubImage2D(r.TEXTURE_2D,g,f.x,f.y,v,y,i.glFormat,i.glType,S)}break;case r.TEXTURE_CUBE_MAP:for(var b=0;b0?E.buffStride:_.width,d.height=E.buffTexHeight>0?E.buffTexHeight:_.height;var x=E.texExtent.width+f.x===i.width>>C?E.texExtent.width:_.width,w=E.texExtent.height+f.y===i.height>>C?E.texExtent.height:_.height,R=E.texSubres.baseArrayLayer+E.texSubres.layerCount;for(o=E.texSubres.baseArrayLayer;o0,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=Ki(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}(),Alt=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=Fut.instance.gl,e=Fut.instance.bindingMappingInfo.maxBlockCounts[0];this._gpuShader={name:"Blit Pass",blocks:[new f_(0,0,"BlitParams",[new __("tilingOffsetSrc",nc.FLOAT4,1),new __("tilingOffsetDst",nc.FLOAT4,1)],1)],samplerTextures:[new d_(0,e,"textureSrc",nc.SAMPLER2D,1)],subpassInputs:[],gpuStages:[{type:Tc.VERTEX,source:"\n precision mediump float;\n\n attribute vec2 a_position;\n attribute vec2 a_texCoord;\n \n uniform vec4 tilingOffsetSrc;\n uniform vec4 tilingOffsetDst;\n \n varying vec2 v_texCoord;\n \n void 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:Tc.FRAGMENT,source:"\n precision mediump float;\n uniform sampler2D textureSrc;\n\n varying vec2 v_texCoord;\n \n void main() {\n gl_FragColor = texture2D(textureSrc, v_texCoord);\n }",glShader:null}],glProgram:null,glInputs:[],glUniforms:[],glBlocks:[],glSamplerTextures:[]},alt(Fut.instance,this._gpuShader),this._gpuDescriptorSetLayout={bindings:[new P_(0,Pc.UNIFORM_BUFFER,1,Tc.VERTEX),new P_(e,Pc.SAMPLER_TEXTURE,1,Tc.FRAGMENT)],dynamicBindings:[],descriptorIndices:[],descriptorCount:e+1};for(var i=0;i0&&(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 Tlt,glTarget:0,glBuffer:null},this._usage&rc.UNIFORM&&(this._gpuBuffer.buffer=this._uniformBuffer),nlt(Fut.instance,this._gpuBuffer),Fut.instance.memoryStatus.bufferSize+=this._size},i.destroy=function(){this._gpuBuffer&&(rlt(Fut.instance,this._gpuBuffer),Fut.instance.memoryStatus.bufferSize-=this._size,this._gpuBuffer=null),this._gpuBufferView&&(this._gpuBufferView=null)},i.resize=function(t){if(this._isBufferView)tt(16379);else{var e=this._size;e!==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&&(function(t,e){var i=t.gl,n=t.stateCache,r=e.memUsage&oc.HOST?i.DYNAMIC_DRAW:i.STATIC_DRAW;e.usage&rc.VERTEX?(t.extensions.useVAO&&n.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),n.glVAO=null),llt.gpuInputAssembler=null,t.stateCache.glArrayBuffer!==e.glBuffer&&i.bindBuffer(i.ARRAY_BUFFER,e.glBuffer),e.buffer?i.bufferData(i.ARRAY_BUFFER,e.buffer,r):i.bufferData(i.ARRAY_BUFFER,e.size,r),i.bindBuffer(i.ARRAY_BUFFER,null),t.stateCache.glArrayBuffer=null):e.usage&rc.INDEX?(t.extensions.useVAO&&n.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),n.glVAO=null),llt.gpuInputAssembler=null,t.stateCache.glElementArrayBuffer!==e.glBuffer&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.glBuffer),e.buffer?i.bufferData(i.ELEMENT_ARRAY_BUFFER,e.buffer,r):i.bufferData(i.ELEMENT_ARRAY_BUFFER,e.size,r),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,null),t.stateCache.glElementArrayBuffer=null):e.usage&rc.UNIFORM?e.buffer&&(e.vf32=new Float32Array(e.buffer.buffer)):(e.usage&rc.INDIRECT||e.usage&rc.TRANSFER_DST||e.usage&rc.TRANSFER_SRC||it(16315),e.glTarget=i.NONE)}(Fut.instance,this._gpuBuffer),Fut.instance.memoryStatus.bufferSize-=e,Fut.instance.memoryStatus.bufferSize+=t)))}},i.update=function(t,e){var i;this._isBufferView?tt(16380):(i=void 0!==e?e:this._usage&rc.INDIRECT?0:t.byteLength,slt(Fut.instance,this._gpuBuffer,t,0,i))},n(e,[{key:"gpuBuffer",get:function(){return this._gpuBuffer}},{key:"gpuBufferView",get:function(){return this._gpuBufferView}}]),e}(af),Elt=function(){function t(t,e){this._freeIdx=0,this._frees=new Array(e),this._freeCmds=new Is(e);for(var 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},function(t,e){for(var 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;ot.capabilities.maxTextureSize&&it(9100,s,t.capabilities.maxTextureSize),t.textureExclusive[e.format]||t.extensions.WEBGL_depth_texture||!j_[e.format].hasDepth){if(e.glTexture=i.createTexture(),e.size>0){var a=t.stateCache.glTexUnits[t.stateCache.texUnit];if(a.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_2D,e.glTexture),a.glTexture=e.glTexture),j_[e.format].isCompressed)for(var o=0;o>1),r=Math.max(1,r>>1)}else for(var l=0;l>1),r=Math.max(1,r>>1);e.isPowerOf2?(e.glWrapS=i.REPEAT,e.glWrapT=i.REPEAT):(e.glWrapS=i.CLAMP_TO_EDGE,e.glWrapT=i.CLAMP_TO_EDGE),e.glMinFilter=i.LINEAR,e.glMagFilter=i.LINEAR,i.texParameteri(e.glTarget,i.TEXTURE_WRAP_S,e.glWrapS),i.texParameteri(e.glTarget,i.TEXTURE_WRAP_T,e.glWrapT),i.texParameteri(e.glTarget,i.TEXTURE_MIN_FILTER,e.glMinFilter),i.texParameteri(e.glTarget,i.TEXTURE_MAG_FILTER,e.glMagFilter)}}else e.glInternalFmt=function(t,e){switch(t){case ec.R5G6B5:return e.RGB565;case ec.RGB5A1:return e.RGB5_A1;case ec.RGBA4:return e.RGBA4;case ec.RGBA16F:return Lut.RGBA16F_EXT;case ec.RGBA32F:return Lut.RGBA32F_EXT;case ec.SRGB8_A8:return Lut.SRGB8_ALPHA8_EXT;case ec.DEPTH:return e.DEPTH_COMPONENT16;case ec.DEPTH_STENCIL:return e.DEPTH_STENCIL;default:return it(16309),e.RGBA}}(e.format,i),e.glRenderbuffer=i.createRenderbuffer(),e.size>0&&(t.stateCache.glRenderbuffer!==e.glRenderbuffer&&(i.bindRenderbuffer(i.RENDERBUFFER,e.glRenderbuffer),t.stateCache.glRenderbuffer=e.glRenderbuffer),i.renderbufferStorage(i.RENDERBUFFER,e.glInternalFmt,n,r));break;case hc.CUBE:e.glTarget=i.TEXTURE_CUBE_MAP;var c=Math.max(n,r);if(c>t.capabilities.maxCubeMapTextureSize&&it(9100,c,t.capabilities.maxTextureSize),e.glTexture=i.createTexture(),e.size>0){var _=t.stateCache.glTexUnits[t.stateCache.texUnit];if(_.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_CUBE_MAP,e.glTexture),_.glTexture=e.glTexture),j_[e.format].isCompressed)for(var f=0;f<6;++f){n=e.width,r=e.height;for(var d=0;d>1),r=Math.max(1,r>>1)}}else for(var g=0;g<6;++g){n=e.width,r=e.height;for(var v=0;v>1),r=Math.max(1,r>>1)}e.isPowerOf2?(e.glWrapS=i.REPEAT,e.glWrapT=i.REPEAT):(e.glWrapS=i.CLAMP_TO_EDGE,e.glWrapT=i.CLAMP_TO_EDGE),e.glMinFilter=i.LINEAR,e.glMagFilter=i.LINEAR,i.texParameteri(e.glTarget,i.TEXTURE_WRAP_S,e.glWrapS),i.texParameteri(e.glTarget,i.TEXTURE_WRAP_T,e.glWrapT),i.texParameteri(e.glTarget,i.TEXTURE_MIN_FILTER,e.glMinFilter),i.texParameteri(e.glTarget,i.TEXTURE_MAG_FILTER,e.glMagFilter)}break;default:it(16317),e.type=hc.TEX2D,e.glTarget=i.TEXTURE_2D}}(Fut.instance,this._gpuTexture),Fut.instance.memoryStatus.textureSize+=this._size),this._viewInfo.texture=this,this._viewInfo.type=t.type,this._viewInfo.format=t.format,this._viewInfo.baseLevel=0,this._viewInfo.levelCount=t.levelCount,this._viewInfo.baseLayer=0,this._viewInfo.layerCount=t.layerCount)},i.destroy=function(){!this._isTextureView&&this._gpuTexture&&(function(t,e){var i=t.gl;if(e.glTexture){var n=t.stateCache.glTexUnits,r=t.stateCache.texUnit;i.deleteTexture(e.glTexture);for(var s=0;s1&&(this._info.levelCount=Math.min(this._info.levelCount,e.getLevelCount(t,i)));var n=this._size;this._info.width=t,this._info.height=i,this._size=J_(this._info.format,this.width,this.height,this.depth,this._info.levelCount)*this._info.layerCount,!this._isTextureView&&this._gpuTexture&&(this._gpuTexture.width=t,this._gpuTexture.height=i,this._gpuTexture.size=this._size,this._gpuTexture.isSwapchainTexture||(function(t,e){if(e.size){var i=t.gl,n=e.width,r=e.height;switch(e.type){case hc.TEX2D:e.glTarget=i.TEXTURE_2D;var s=Math.max(n,r);if(s>t.capabilities.maxTextureSize&&it(9100,s,t.capabilities.maxTextureSize),e.glRenderbuffer)t.stateCache.glRenderbuffer!==e.glRenderbuffer&&(i.bindRenderbuffer(i.RENDERBUFFER,e.glRenderbuffer),t.stateCache.glRenderbuffer=e.glRenderbuffer),i.renderbufferStorage(i.RENDERBUFFER,e.glInternalFmt,n,r);else if(e.glTexture){var a=t.stateCache.glTexUnits[t.stateCache.texUnit];if(a.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_2D,e.glTexture),a.glTexture=e.glTexture),j_[e.format].isCompressed)for(var o=0;o>1),r=Math.max(1,r>>1)}else for(var l=0;l>1),r=Math.max(1,r>>1)}break;case hc.CUBE:e.glTarget=i.TEXTURE_CUBE_MAP;var c=Math.max(n,r);c>t.capabilities.maxCubeMapTextureSize&&it(9100,c,t.capabilities.maxTextureSize);var _=t.stateCache.glTexUnits[t.stateCache.texUnit];if(_.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_CUBE_MAP,e.glTexture),_.glTexture=e.glTexture),j_[e.format].isCompressed)for(var f=0;f<6;++f){n=e.width,r=e.height;for(var d=0;d>1),r=Math.max(1,r>>1)}}else for(var g=0;g<6;++g){n=e.width,r=e.height;for(var v=0;v>1),r=Math.max(1,r>>1)}break;default:it(16317),e.type=hc.TEX2D,e.glTarget=i.TEXTURE_2D}}}(Fut.instance,this._gpuTexture),Fut.instance.memoryStatus.textureSize-=n,Fut.instance.memoryStatus.textureSize+=this._size))}},i.initAsSwapchainTexture=function(t){var e=new u_;e.format=t.format,e.usage=j_[t.format].hasDepth?uc.DEPTH_STENCIL_ATTACHMENT:uc.COLOR_ATTACHMENT,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}(xf),Ult="webglcontextlost";function zlt(t,e){for(var i=["","WEBKIT_","MOZ_"],n=0;n=0&&o<=1&&h>=0&&h<=1)return!0}return!1}S.WebGLDevice=Xlt;var Ylt=new jn,qlt=new jn,Klt=new jn,Qlt=new jn;function Zlt(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 $lt(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:Ylt.set(e.x+h*s,e.y+h*a):e:Ylt.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 tct=t("eG",(function(){}));tct.lineLine=jlt,tct.lineRect=function(t,e,i){var n=Ylt.set(i.x,i.y),r=qlt.set(i.x,i.yMax),s=Klt.set(i.xMax,i.yMax),a=Qlt.set(i.xMax,i.y);return!!(jlt(t,e,n,r)||jlt(t,e,r,s)||jlt(t,e,s,a)||jlt(t,e,a,n))},tct.linePolygon=Zlt,tct.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},tct.rectPolygon=function(t,e){var i=Ylt.set(t.x,t.y),n=qlt.set(t.x,t.yMax),r=Klt.set(t.xMax,t.yMax),s=Qlt.set(t.xMax,t.y);if(Zlt(i,n,e))return!0;if(Zlt(n,r,e))return!0;if(Zlt(r,s,e))return!0;if(Zlt(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,_=r-l;return Math.sqrt(c*c+_*_)<=i},tct.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 gn.squaredDistance(t,this.sphere.center)=0},e.isOuterCell=function(){return this.vertex3<0},t}(),xct=ja(Cct.prototype,"invalid",[kct],(function(){return!1})),wct=ja(Cct.prototype,"vertex0",[kct],(function(){return-1})),Rct=ja(Cct.prototype,"vertex1",[kct],(function(){return-1})),Ict=ja(Cct.prototype,"vertex2",[kct],(function(){return-1})),Dct=ja(Cct.prototype,"vertex3",[kct],(function(){return-1})),Bct=ja(Cct.prototype,"neighbours",[kct],(function(){return[-1,-1,-1,-1]})),Mct=ja(Cct.prototype,"matrix",[kct],(function(){return new wn})),Pct=ja(Cct.prototype,"offset",[kct],(function(){return new gn(0,0,0)})),Oct=ja(Cct.prototype,"sphere",[kct],(function(){return new Qct})),Ect=Cct))||Ect),Jct=t("eM",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&&gn.negate(t,t),gn.add(l.normal,l.normal,t),gn.add(c.normal,c.normal,t),gn.add(_.normal,_.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,v=new Zct(this,p,m,g);v.neighbours[3]=this._triangles[h].tetrahedron,this._tetrahedrons[this._triangles[h].tetrahedron].neighbours[this._triangles[h].index]=this._tetrahedrons.length,this._tetrahedrons.push(v)}}for(var y=0,S=r;S=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,gn.subtract(Uct,i[0],i[2]),gn.subtract(zct,e[0],e[2]),gn.subtract(Hct,i[1],i[2]),gn.subtract(Wct,e[1],e[2]),Xct.set(i[2]),gn.negate(jct,e[2]);var n=[];n[0]=zct.y*Wct.z-zct.z*Wct.y,n[3]=-zct.x*Wct.z+zct.z*Wct.x,n[6]=zct.x*Wct.y-zct.y*Wct.x,n[9]=Uct.x*Wct.y*jct.z-Uct.y*Wct.x*jct.z+zct.x*Hct.y*jct.z-zct.y*Hct.x*jct.z+Uct.z*Wct.x*jct.y-Uct.z*Wct.y*jct.x+zct.z*Hct.x*jct.y-zct.z*Hct.y*jct.x-Uct.x*Wct.z*jct.y+Uct.y*Wct.z*jct.x-zct.x*Hct.z*jct.y+zct.y*Hct.z*jct.x,n[9]-=Xct.x*n[0]+Xct.y*n[3]+Xct.z*n[6],n[1]=zct.y*Hct.z+Uct.y*Wct.z-zct.z*Hct.y-Uct.z*Wct.y,n[4]=-Uct.x*Wct.z-zct.x*Hct.z+Uct.z*Wct.x+zct.z*Hct.x,n[7]=Uct.x*Wct.y-Uct.y*Wct.x+zct.x*Hct.y-zct.y*Hct.x,n[10]=Uct.x*Hct.y*jct.z-Uct.y*Hct.x*jct.z-Uct.x*Hct.z*jct.y+Uct.y*Hct.z*jct.x+Uct.z*Hct.x*jct.y-Uct.z*Hct.y*jct.x,n[10]-=Xct.x*n[1]+Xct.y*n[4]+Xct.z*n[7],n[2]=-Uct.z*Hct.y+Uct.y*Hct.z,n[5]=-Uct.x*Hct.z+Uct.z*Hct.x,n[8]=Uct.x*Hct.y-Uct.y*Hct.x,n[11]=0,n[11]-=Xct.x*n[2]+Xct.y*n[5]+Xct.z*n[8];var r=zct.x*Wct.y*jct.z-zct.y*Wct.x*jct.z+zct.z*Wct.x*jct.y-zct.z*Wct.y*jct.x+zct.y*Wct.z*jct.x-zct.x*Wct.z*jct.y;if(Math.abs(r)>Oi)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}()),$ct=t("eN",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 gn(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/($ct.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}(),u_t=new gn(0,0,0),l_t=new gn(0,0,0),c_t=new gn(0,0,0),__t=new gn(0,0,0),f_t=new gn(0,0,0),d_t=new gn(0,0,0),p_t=new gn(0,0,0),m_t=new gn(0,0,0),g_t=new gn(0,0,0),v_t=new gn(0,0,0),y_t=new gn(0,0,0),S_t=new gn(0,0,0),T_t=new gn(0,0,0),A_t=new gn(0,0,0),b_t=new gn(0,0,0),E_t=t("eP",(e_t=eo("cc.LightProbesData"),i_t=Lo([Yct]),n_t=Lo([Zct]),e_t((s_t=function(){function t(){this._probes=a_t&&a_t(),this._tetrahedrons=o_t&&o_t()}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 gn(0,0,0);gn.subtract(n,t,this._probes[e.vertex3].position),gn.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;gn.subtract(v_t,s,r),gn.subtract(y_t,a,r),gn.cross(g_t,v_t,y_t),gn.subtract(S_t,e,r);var o=gn.dot(S_t,g_t);if(o<0)n.set(0,0,0,-1);else{var h=new gn(0,0,0);gn.transformMat3(h,e,i.matrix),gn.add(h,h,i.offset),o=-1===i.vertex3?h_t.getCubicUniqueRoot(h.x,h.y,h.z):h_t.getQuadraticUniqueRoot(h.x,h.y,h.z),gn.scaleAndAdd(T_t,r,this._probes[i.vertex0].normal,o),gn.scaleAndAdd(A_t,s,this._probes[i.vertex1].normal,o),gn.scaleAndAdd(b_t,a,this._probes[i.vertex2].normal,o);var u=t.getTriangleBarycentricCoord(T_t,A_t,b_t,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}(),a_t=ja(s_t.prototype,"_probes",[lo,i_t],(function(){return[]})),o_t=ja(s_t.prototype,"_tetrahedrons",[lo,n_t],(function(){return[]})),r_t=s_t))||r_t));S.internal.LightProbesData=E_t;var C_t,x_t,w_t,R_t,I_t,D_t,B_t,M_t,P_t,O_t,L_t,N_t,F_t,k_t,G_t,V_t=t("eQ",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}());S.internal.LightProbes=V_t,t("eR",(C_t=eo("cc.LightProbeGroup"),x_t=Lo([gn]),w_t=Lo(Lct),R_t=Lo(ii),I_t=Lo(ii),D_t=Lo(ii),C_t(B_t=ro((M_t=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}(mp),j_t=ja(X_t.prototype,"_texture",[z_t],(function(){return null})),m(X_t.prototype,"texture",[H_t],Object.getOwnPropertyDescriptor(X_t.prototype,"texture"),X_t.prototype),Y_t=ja(X_t.prototype,"_height",[lo],(function(){return 0})),q_t=ja(X_t.prototype,"_width",[lo],(function(){return 0})),K_t=ja(X_t.prototype,"_rotation",[lo],(function(){return 0})),Q_t=ja(X_t.prototype,"_techIndex",[lo],(function(){return 0})),W_t=X_t))||W_t)),mft=[new T_(Uc.ATTR_POSITION,ec.RGB32F),new T_(Uc.ATTR_TEX_COORD,ec.RGBA32F),new T_(Uc.ATTR_TEX_COORD1,ec.RGB32F),new T_(Uc.ATTR_COLOR,ec.RGBA8,!0)],gft=new gn,vft=new gn,yft=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=vR.LINE,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=mft;t1){var n=0;gn.subtract(gft,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++]=gft.x,this._vdataF32[n++]=gft.y,this._vdataF32[n++]=gft.z,this._vdataUint32[n++]=En.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++]=gft.x,this._vdataF32[n++]=gft.y,this._vdataF32[n++]=gft.z,this._vdataUint32[n++]=En.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&&($ft.CC_USE_WORLD_SPACE=this.worldSpace,n.recompileShaders($ft),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&&($ft.CC_USE_WORLD_SPACE=this.worldSpace,e.recompileShaders($ft),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}(EG),Vft=ja(Gft.prototype,"_texture",[Ift],(function(){return null})),m(Gft.prototype,"texture",[Dft],Object.getOwnPropertyDescriptor(Gft.prototype,"texture"),Gft.prototype),Uft=ja(Gft.prototype,"_material",[lo],(function(){return null})),m(Gft.prototype,"lineMaterial",[Bft],Object.getOwnPropertyDescriptor(Gft.prototype,"lineMaterial"),Gft.prototype),m(Gft.prototype,"sharedMaterials",[jo,lo],Object.getOwnPropertyDescriptor(Gft.prototype,"sharedMaterials"),Gft.prototype),zft=ja(Gft.prototype,"_worldSpace",[lo],(function(){return!1})),Hft=ja(Gft.prototype,"_positions",[Mft],(function(){return[]})),m(Gft.prototype,"positions",[Pft],Object.getOwnPropertyDescriptor(Gft.prototype,"positions"),Gft.prototype),m(Gft.prototype,"width",[Oft],Object.getOwnPropertyDescriptor(Gft.prototype,"width"),Gft.prototype),Wft=ja(Gft.prototype,"_width",[lo],(function(){return new bft})),m(Gft.prototype,"color",[Lft],Object.getOwnPropertyDescriptor(Gft.prototype,"color"),Gft.prototype),Xft=ja(Gft.prototype,"_color",[lo],(function(){return new Zft})),jft=ja(Gft.prototype,"_tile",[lo],(function(){return new jn(1,1)})),m(Gft.prototype,"tile",[Nft],Object.getOwnPropertyDescriptor(Gft.prototype,"tile"),Gft.prototype),Yft=ja(Gft.prototype,"_offset",[lo],(function(){return new jn(0,0)})),m(Gft.prototype,"offset",[Fft],Object.getOwnPropertyDescriptor(Gft.prototype,"offset"),Gft.prototype),kft=Gft))||kft)),edt=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 gn(0,0,0),this.velocity=new gn(0,0,0),this.animatedVelocity=new gn(0,0,0),this.ultimateVelocity=new gn(0,0,0),this.angularVelocity=new gn(0,0,0),this.axisOfRotation=new gn(0,0,0),this.rotation=new gn(0,0,0),this.startEuler=new gn(0,0,0),this.startRotation=new Bn,this.startRotated=!1,this.deltaQuat=new Bn,this.deltaMat=new Vn,this.localMat=new Vn,this.startSize=new gn(0,0,0),this.size=new gn(0,0,0),this.startColor=En.WHITE.clone(),this.color=En.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}();edt.INDENTIFY_NEG_QUAT=10,edt.R2D=180/Math.PI;var idt,ndt,rdt,sdt,adt,odt,hdt="colorModule",udt="rotationModule",ldt="sizeModule",cdt="textureModule",_dt="noiseModule",fdt=["sizeModule","colorModule","forceModule","velocityModule","limitModule","rotationModule","textureModule","noiseModule"],ddt=["_colorOverLifetimeModule","_shapeModule","_sizeOvertimeModule","_velocityOvertimeModule","_forceOvertimeModule","_limitVelocityOvertimeModule","_rotationOvertimeModule","_textureAnimationModule","_noiseModule","_trailModule"],pdt=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}(),mdt=Ee({World:0,Local:1,Custom:2}),gdt=Ee({Pause:0,PauseAndCatchup:1,AlwaysSimulate:2}),vdt=Ee({World:0,Local:1,View:2}),ydt=Ee({Billboard:0,StrecthedBillboard:1,HorizontalBillboard:2,VerticalBillboard:3,Mesh:4}),Sdt=Ee({Box:0,Circle:1,Cone:2,Sphere:3,Hemisphere:4}),Tdt=Ee({Base:0,Edge:1,Shell:2,Volume:3}),Adt=Ee({Random:0,Loop:1,PingPong:2}),bdt=Ee({Particles:0}),Edt=Ee({Stretch:0}),Cdt=new gn(0,0,-1);function xdt(t,e,i,n){return e!==t?(t===mdt.World||Vn.invert(i,i),Vn.getRotation(n,i),!0):(Bn.set(n,0,0,0,1),!1)}function wdt(t,e){jn.set(t,Math.cos(e),Math.sin(e))}function Rdt(t){var e=Wi(-1,1),i=Wi(0,2*Math.PI),n=Math.sqrt(1-e*e),r=n*Math.cos(i),s=n*Math.sin(i);gn.set(t,r,s,e)}function Idt(t,e,i){Rdt(t),gn.multiplyScalar(t,t,e+(i-e)*zi())}function Ddt(t,e,i,n){wdt(t,n),t.z=0,gn.multiplyScalar(t,t,e+(i-e)*zi())}function Bdt(t){for(var e=0;ee){var s=r-r*i;r=s>e?s:e}return r*n}var Rpt,Ipt,Dpt,Bpt,Mpt,Ppt,Opt,Lpt,Npt,Fpt,kpt,Gpt,Vpt,Upt,zpt,Hpt,Wpt,Xpt,jpt,Ypt,qpt,Kpt,Qpt,Zpt,Jpt,$pt,tmt,emt,imt,nmt,rmt,smt,amt,omt,hmt,umt,lmt,cmt,_mt,fmt,dmt,pmt,mmt,gmt,vmt,ymt,Smt,Tmt,Amt,bmt,Emt,Cmt,xmt,wmt,Rmt,Imt,Dmt,Bmt,Mmt,Pmt,Omt,Lmt,Nmt,Fmt,kmt,Gmt,Vmt,Umt,zmt,Hmt,Wmt,Xmt,jmt,Ymt,qmt,Kmt,Qmt,Zmt,Jmt,$mt,tgt,egt,igt,ngt,rgt,sgt,agt=125292,ogt=(hpt=eo("cc.RotationOvertimeModule"),upt=Lo(bft),lpt=Lo(bft),cpt=Lo(bft),hpt((fpt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r0){var i=Qi(t.time-t.startDelay.evaluate(0,1),t.duration)-e;i=i>0?i:0;var n=Qi(t.time-t.startDelay.evaluate(0,1),t.duration);this._curTime>=i&&this._curTime0&&(n.z*=-1),gn.normalize(r,n);break;case Tdt.Shell:Rdt(n),gn.multiplyScalar(n,n,e),n.z>0&&(n.z*=-1),gn.normalize(r,n);break;default:z(t+" is not supported for hemisphere emitter.")}}(this.emitFrom,this.radius,this.radiusThickness,t.position,t.velocity);break;default:z(this.shapeType+" shapeType is not supported by ShapeModule.")}if(this.randomPositionAmount>0&&(t.position.x+=Wi(-this.randomPositionAmount,this.randomPositionAmount),t.position.y+=Wi(-this.randomPositionAmount,this.randomPositionAmount),t.position.z+=Wi(-this.randomPositionAmount,this.randomPositionAmount)),gn.transformQuat(t.velocity,t.velocity,this.quat),gn.transformMat4(t.position,t.position,this.mat),this.sphericalDirectionAmount>0){var e=gn.normalize(ggt,t.position);gn.lerp(t.velocity,t.velocity,e,this.sphericalDirectionAmount)}this.lastTime=this.particleSystem.time},e.constructMat=function(){Bn.fromEuler(this.quat,this._rotation.x,this._rotation.y,this._rotation.z),Vn.fromRTS(this.mat,this.quat,this._position,this._scale)},e.generateArcAngle=function(){if(this.arcMode===Adt.Random)return Wi(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 Adt.Loop:return Qi(t,this._arc);case Adt.PingPong:return Zi(t,this._arc);default:return Qi(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 Ui(this._arc)},set:function(t){this._arc=Vi(t)}},{key:"angle",get:function(){return Math.round(100*Ui(this._angle))/100},set:function(t){this._angle=Vi(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 Sdt.Box:this.emitFrom===Tdt.Base&&(this.emitFrom=Tdt.Volume);break;case Sdt.Cone:this.emitFrom===Tdt.Edge&&(this.emitFrom=Tdt.Base);break;case Sdt.Sphere:case Sdt.Hemisphere:this.emitFrom!==Tdt.Base&&this.emitFrom!==Tdt.Edge||(this.emitFrom=Tdt.Volume)}}}]),t}(),Umt=ja(Vmt.prototype,"_enable",[lo],(function(){return!1})),zmt=ja(Vmt.prototype,"_shapeType",[Pmt,Omt],(function(){return Sdt.Cone})),m(Vmt.prototype,"shapeType",[Lmt],Object.getOwnPropertyDescriptor(Vmt.prototype,"shapeType"),Vmt.prototype),Hmt=ja(Vmt.prototype,"emitFrom",[Nmt,lo],(function(){return Tdt.Volume})),Wmt=ja(Vmt.prototype,"alignToDirection",[lo],(function(){return!1})),Xmt=ja(Vmt.prototype,"randomDirectionAmount",[lo],(function(){return 0})),jmt=ja(Vmt.prototype,"sphericalDirectionAmount",[lo],(function(){return 0})),Ymt=ja(Vmt.prototype,"randomPositionAmount",[lo],(function(){return 0})),qmt=ja(Vmt.prototype,"radius",[lo],(function(){return 1})),Kmt=ja(Vmt.prototype,"radiusThickness",[lo],(function(){return 1})),Qmt=ja(Vmt.prototype,"arcMode",[Fmt,lo],(function(){return Adt.Random})),Zmt=ja(Vmt.prototype,"arcSpread",[lo],(function(){return 0})),Jmt=ja(Vmt.prototype,"arcSpeed",[kmt,lo],(function(){return new bft})),$mt=ja(Vmt.prototype,"length",[lo],(function(){return 5})),tgt=ja(Vmt.prototype,"boxThickness",[lo],(function(){return new gn(0,0,0)})),egt=ja(Vmt.prototype,"_position",[lo],(function(){return new gn(0,0,0)})),igt=ja(Vmt.prototype,"_rotation",[lo],(function(){return new gn(0,0,0)})),ngt=ja(Vmt.prototype,"_scale",[lo],(function(){return new gn(1,1,1)})),rgt=ja(Vmt.prototype,"_arc",[lo],(function(){return Vi(360)})),sgt=ja(Vmt.prototype,"_angle",[lo],(function(){return Vi(25)})),Gmt=Vmt))||Gmt);function Tgt(t,e){e.x>0&&(t[0]+=.5*Wi(-e.x,e.x),t[0]=Fi(t[0],-.5,.5)),e.y>0&&(t[1]+=.5*Wi(-e.y,e.y),t[1]=Fi(t[1],-.5,.5)),e.z>0&&(t[2]+=.5*Wi(-e.z,e.z),t[2]=Fi(t[2],-.5,.5))}var Agt=[0,0,1,0,0,1,1,1],bgt=[0,0,0,1,0,0,0,1,0,1,1,0],Egt=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=vR.PARTICLE_BATCH,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,Ff.gfxDevice.hasFeature(tc.INSTANCED_ARRAYS)?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=f(this._vertAttrs);!(i=n()).done;){var r=i.value;r.offset=this._vertAttribSize,this._vertAttribSize+=j_[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=f(this._vertAttrs);!(i=n()).done;){var r=i.value;0===r.stream?(r.offset=this._vertAttribSize,this._vertAttribSize+=j_[r.format].size):1===r.stream&&(r.offset=this._vertAttribSizeStatic,this._vertAttribSizeStatic+=j_[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 r_(rc.VERTEX|rc.TRANSFER_DST,oc.HOST|oc.DEVICE,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 t.name===Uc.ATTR_TEX_COORD}))].offset;this._mesh.copyAttribute(0,Uc.ATTR_TEX_COORD,e,this._vertAttribSize,i);var n=this._vertAttrs.findIndex((function(t){return t.name===Uc.ATTR_TEX_COORD3}));if(i=this._vertAttrs[n++].offset,this._mesh.copyAttribute(0,Uc.ATTR_POSITION,e,this._vertAttribSize,i),i=this._vertAttrs[n++].offset,this._mesh.copyAttribute(0,Uc.ATTR_NORMAL,e,this._vertAttribSize,i),i=this._vertAttrs[n++].offset,!this._mesh.copyAttribute(0,Uc.ATTR_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;Mgt.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=fdt.length;e0,this._particles.length},i.getNoisePreview=function(t,e,i){var n=this;this._runAnimateList.forEach((function(r){r.name===_dt&&r.getNoisePreview(t,n._particleSystem,e,i)}))},i.updateRenderData=function(){for(var t=0,e=0;e=(null===(t=this._particleSystem)||void 0===t?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(this._renderInfo.renderMode===ydt.Mesh||this._alignSpace!==vdt.View){var e;if(this._alignSpace===vdt.Local)null===(e=this._particleSystem)||void 0===e||e.node.getRotation(Ygt);else if(this._alignSpace===vdt.World){var i;null===(i=this._particleSystem)||void 0===i||i.node.getWorldRotation(Ygt)}else if(this._alignSpace===vdt.View){var n,r;Ygt.set(0,0,0,1);var s=null===(n=this._particleSystem)||void 0===n||null===(r=n.node.scene.renderScene)||void 0===r?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){Bn.fromViewUp(Ygt,o.forward);break}}}else Ygt.set(0,0,0,1);t.setUniform(this._uNodeRotHandle,Ygt)}},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?void 0:e.scaleSpace){case mdt.Local:this._particleSystem.node.getScale(i);break;case mdt.World:this._particleSystem.node.getWorldScale(i)}t.setUniform(t.getHandle("scale"),Hgt.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];Xgt.x=this._particleSystem.time,Xgt.y=t,i.setUniform(this._uTimeHandle,Xgt),this._particleSystem.node.getWorldRotation(jgt),i.setUniform(this._uRotHandle,jgt),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),Xgt.x=pvt,Xgt.y=.03125,o.setUniform(o.getHandle("u_sampleInfo"),Xgt);var h=!1,u=null===(e=this._particleSystem)||void 0===e?void 0:e._forceOvertimeModule;if(h=!!u&&u.enable,this._defines.FORCE_OVER_TIME_MODULE_ENABLE=h,h){var l=wft(this._forceTexture,this._forceData,pvt,u.x,u.y,u.z);this._forceTexture=l.texture,this._forceData=l.texdata;var c=o.getHandle("force_over_time_tex0"),_=IT.getBindingFromHandle(c);o.bindSampler(_,this._forceTexture.getGFXSampler()),o.bindTexture(_,this._forceTexture.getGFXTexture());var f=o.getHandle("u_force_space");o.setUniform(f,u.space);var d=o.getHandle("u_force_mode");o.setUniform(d,this._forceTexture.height)}var p=null===(i=this._particleSystem)||void 0===i?void 0:i._velocityOvertimeModule;if(h=!!p&&p.enable,this._defines.VELOCITY_OVER_TIME_MODULE_ENABLE=h,h){var m=function(t,e,i,n,r,s,a){var o=Math.max(Cft(n),Cft(r),Cft(s),Cft(a)),h=i*o*4;null!==e&&e.length===h||(e=new Float32Array(i*o*4));for(var u=[n,r,s,a],l=0;l=8&&t.getFormatFeatures(ec.RGBA32F)&(cc.RENDER_TARGET|cc.SAMPLED_TEXTURE))||(S.warn("Maybe the device has restrictions on vertex textures or does not support float textures."),!1)}var Bvt,Mvt,Pvt,Ovt,Lvt,Nvt,Fvt,kvt,Gvt,Vvt,Uvt,zvt,Hvt,Wvt,Xvt,jvt,Yvt,qvt,Kvt,Qvt,Zvt,Jvt,$vt,tyt,eyt,iyt,nyt,ryt,syt,ayt,oyt,hyt,uyt,lyt,cyt,_yt,fyt,dyt,pyt,myt,gyt,vyt,yyt,Syt,Tyt,Ayt,byt,Eyt,Cyt,xyt,wyt,Ryt,Iyt,Dyt,Byt,Myt,Pyt,Oyt,Lyt,Nyt,Fyt,kyt,Gyt,Vyt,Uyt,zyt,Hyt,Wyt,Xyt,jyt,Yyt,qyt,Kyt,Qyt,Zyt,Jyt,$yt,tSt,eSt,iSt,nSt,rSt,sSt,aSt,oSt,hSt,uSt,lSt,cSt,_St,fSt,dSt,pSt,mSt,gSt,vSt,ySt,SSt,TSt,ASt,bSt,ESt,CSt,xSt,wSt,RSt,ISt,DSt,BSt,MSt,PSt,OSt,LSt,NSt,FSt,kSt,GSt,VSt,USt,zSt,HSt,WSt,XSt,jSt,YSt,qSt,KSt,QSt,ZSt,JSt,$St,tTt,eTt,iTt,nTt,rTt,sTt,aTt,oTt,hTt,uTt,lTt,cTt,_Tt,fTt,dTt=(qgt=eo("cc.ParticleSystemRenderer"),Kgt=Lo(ydt),Qgt=Lo(ydt),Zgt=Lo(ZB),Jgt=Lo(zT),$gt=Lo(zT),tvt=Lo(zT),evt=Lo(zT),ivt=Lo(vdt),qgt(((dvt=function(){function t(){this._renderMode=svt&&svt(),this._velocityScale=avt&&avt(),this._lengthScale=ovt&&ovt(),this._mesh=hvt&&hvt(),this._cpuMaterial=uvt&&uvt(),this._gpuMaterial=lvt&&lvt(),this._mainTexture=cvt&&cvt(),this._useGPU=_vt&&_vt(),this._alignSpace=fvt&&fvt(),this._particleSystem=null}var e=t.prototype;return e.create=function(t){null===this._particleSystem?this._particleSystem=t:this._particleSystem!==t&&it(6033)},e.onInit=function(t){this.create(t);var e=this._useGPU&&Dvt();this._particleSystem.processor?it(6034):(this._particleSystem.processor=e?new Ivt(this):new zgt(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,tt(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&&Dvt();!t&&this.cpuMaterial&&(this.particleMaterial=this.cpuMaterial),t&&this.gpuMaterial&&(this.particleMaterial=this.gpuMaterial),this._particleSystem.processor=t?new Ivt(this):new zgt(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(null!==t){var e=t.effectName;-1!==e.indexOf("particle")&&-1===e.indexOf("particle-gpu")?(this._cpuMaterial=t,this.particleMaterial=this._cpuMaterial):tt(6035)}}},{key:"gpuMaterial",get:function(){return this._gpuMaterial},set:function(t){null!==t&&(-1!==t.effectName.indexOf("particle-gpu")?(this._gpuMaterial=t,this.particleMaterial=this._gpuMaterial):tt(6035))}},{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&&(Dvt()?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}()).AlignmentSpace=vdt,m((rvt=dvt).prototype,"renderMode",[Kgt],Object.getOwnPropertyDescriptor(rvt.prototype,"renderMode"),rvt.prototype),svt=ja(rvt.prototype,"_renderMode",[Qgt,lo],(function(){return ydt.Billboard})),avt=ja(rvt.prototype,"_velocityScale",[lo],(function(){return 1})),ovt=ja(rvt.prototype,"_lengthScale",[lo],(function(){return 1})),hvt=ja(rvt.prototype,"_mesh",[lo],(function(){return null})),m(rvt.prototype,"mesh",[Zgt],Object.getOwnPropertyDescriptor(rvt.prototype,"mesh"),rvt.prototype),m(rvt.prototype,"particleMaterial",[Jgt],Object.getOwnPropertyDescriptor(rvt.prototype,"particleMaterial"),rvt.prototype),m(rvt.prototype,"cpuMaterial",[$gt],Object.getOwnPropertyDescriptor(rvt.prototype,"cpuMaterial"),rvt.prototype),uvt=ja(rvt.prototype,"_cpuMaterial",[lo],(function(){return null})),m(rvt.prototype,"gpuMaterial",[tvt],Object.getOwnPropertyDescriptor(rvt.prototype,"gpuMaterial"),rvt.prototype),lvt=ja(rvt.prototype,"_gpuMaterial",[lo],(function(){return null})),m(rvt.prototype,"trailMaterial",[evt],Object.getOwnPropertyDescriptor(rvt.prototype,"trailMaterial"),rvt.prototype),cvt=ja(rvt.prototype,"_mainTexture",[lo],(function(){return null})),_vt=ja(rvt.prototype,"_useGPU",[lo],(function(){return!1})),m(rvt.prototype,"alignSpace",[ivt],Object.getOwnPropertyDescriptor(rvt.prototype,"alignSpace"),rvt.prototype),fvt=ja(rvt.prototype,"_alignSpace",[lo],(function(){return vdt.View})),nvt=rvt))||nvt),pTt=Math.cos(Vi(100)),mTt={position:new gn,velocity:new gn},gTt=new Bn,vTt=new gn,yTt=new gn,STt=new En,TTt=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 gn,lifetime:0,width:0,velocity:new gn,direction:0,color:new En})}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 gn,lifetime:0,width:0,velocity:new gn,direction:0,color:new En}),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?gn.transformMat4(vTt,t.position,this._psTransform):gn.copy(vTt,t.position),!(n&&(i.iterateElement(this,this._updateTrailElement,t,e),gn.squaredDistance(n.position,vTt)2){var a=i.getElement(i.end-2),o=i.getElement(i.end-3);gn.subtract(vTt,o.position,a.position),gn.subtract(yTt,n.position,a.position),gn.subtract(a.velocity,yTt,vTt),gn.equals(gn.ZERO,a.velocity)&&gn.copy(a.velocity,vTt),gn.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=f(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 p=n.getElement(n.end-1),m=n.getElement(n.end-2);gn.subtract(vTt,m.position,p.position),gn.subtract(yTt,mTt.position,p.position),gn.normalize(vTt,vTt),gn.normalize(yTt,yTt),gn.subtract(p.velocity,yTt,vTt),gn.normalize(p.velocity,p.velocity),this._checkDirectionReverse(p,m),this.vbOffset-=this._vertSize/4*2,this.ibOffset-=6,this._fillVertexBuffer(p,this.colorOverTrail.evaluate(o,1),r,o,a-1,5),gn.subtract(mTt.velocity,mTt.position,p.position),gn.normalize(mTt.velocity,mTt.velocity),this._checkDirectionReverse(mTt,p)}this.widthFromParticle?mTt.width=i.size.x*this.widthRatio.evaluate(0,1):mTt.width=this.widthRatio.evaluate(0,1),mTt.color=i.color,gn.equals(mTt.velocity,gn.ZERO)?this.ibOffset-=3:this._fillVertexBuffer(mTt,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=S.director.root.createModel(RR))},t.rebuild=function(){var t=ID.root.device,e=t.createBuffer(new r_(rc.VERTEX|rc.TRANSFER_DST,oc.HOST|oc.DEVICE,this._vertSize*(this._trailNum+1)*2,this._vertSize)),i=new ArrayBuffer(this._vertSize*(this._trailNum+1)*2);this._vbF32=new Float32Array(i),this._vbUint32=new Uint32Array(i),e.update(i);var n=t.createBuffer(new r_(rc.INDEX|rc.TRANSFER_DST,oc.HOST|oc.DEVICE,6*Math.max(1,this._trailNum)*Uint16Array.BYTES_PER_ELEMENT,Uint16Array.BYTES_PER_ELEMENT));this._iBuffer=new Uint16Array(6*Math.max(1,this._trailNum)),n.update(this._iBuffer),this._iaVertCount=2*(this._trailNum+1),this._iaIndexCount=6*this._trailNum,this._subMeshData=new FD([e],this._vertAttrs,wc.TRIANGLE_LIST,n);var r=this._trailModel;r&&this._material&&(r.node=r.transform=this._particleSystem.node,r.visFlags=this._particleSystem.visibility,r.initSubModel(0,this._subMeshData,this._material),r.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,STt.set(t.color),STt.multiply(e),this._vbUint32[this.vbOffset++]=En.toUint32(STt),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++]=En.toUint32(STt),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){gn.dot(t.velocity,e.velocity)0&&!this._isCulled&&(null!==(e=this.processor.getModel())&&void 0!==e&&e.scene||this.processor.attachToScene(),this._trailModule&&this._trailModule.enable&&(null!==(i=this._trailModule.getModel())&&void 0!==i&&i.scene||this._trailModule._attachToScene()),this._needAttach=!1);!this.renderer.useGPU&&this._trailModule&&this._trailModule.enable&&(this._trailModule.inited||(this._trailModule.clear(),this._trailModule.destroy(),this._trailModule.onInit(this),this._trailModule.enable=!1,this._trailModule.enable=!0))},i.beforeRender=function(){var t,e;this.getParticleCount()<=0?null!==(e=this.processor.getModel())&&void 0!==e&&e.scene&&(this.processor.detachFromScene(),this._trailModule&&this._trailModule.enable&&this._trailModule._detachFromScene(),this._needAttach=!1):null!==(t=this.processor.getModel())&&void 0!==t&&t.scene||(this._needAttach=!0),this._isPlaying&&(this.processor.updateRenderData(),this.processor.beforeRender(),this._trailModule&&this._trailModule.enable&&(this._trailModule.updateRenderData(),this._trailModule.beforeRender()))},i._onVisibilityChange=function(t){this.processor.model&&(this.processor.model.visFlags=t)},i.emit=function(t,e){var i=this._time%this.duration/this.duration;this._needRefresh&&(this.node.invalidateChildren(mm.POSITION),this._needRefresh=!1),this._simulationSpace===mdt.World&&(this.node.getWorldMatrix(MTt),this.node.getWorldRotation(PTt));for(var n=0;ne){if(this._time>this.duration+e&&(this.loop||(this._isEmitting=!1)),!this._isEmitting)return;if(this._emitRateTimeCounter+=this.rateOverTime.evaluate(this._time/this.duration,1)*t,this._emitRateTimeCounter>1){var i=Math.floor(this._emitRateTimeCounter);this._emitRateTimeCounter-=i,this.emit(i,t)}var n=this.rateOverDistance.evaluate(this._time/this.duration,1);if(n>0){gn.copy(this._oldWPos,this._curWPos),this.node.getWorldPosition(this._curWPos);var r=gn.distance(this._curWPos,this._oldWPos);this._emitRateDistanceCounter+=r*n}if(this._emitRateDistanceCounter>1){var s=Math.floor(this._emitRateDistanceCounter);this._emitRateDistanceCounter-=s,this.emit(s,t)}for(var a,o=f(this.bursts);!(a=o()).done;)a.value.update(this,t)}},i._resetPosition=function(){this.node.getWorldPosition(this._oldWPos),gn.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!ddt.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 Ra,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 OTt.get.call(this)},set:function(t){OTt.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}(EG)).CullingMode=gdt,xSt=ja((CSt=fTt).prototype,"startColor",[Pyt,lo],(function(){return new Zft})),wSt=ja(CSt.prototype,"scaleSpace",[Oyt,lo],(function(){return mdt.Local})),RSt=ja(CSt.prototype,"startSize3D",[lo],(function(){return!1})),ISt=ja(CSt.prototype,"startSizeX",[Lyt,Nyt],(function(){return new bft})),DSt=ja(CSt.prototype,"startSizeY",[Fyt,lo],(function(){return new bft})),BSt=ja(CSt.prototype,"startSizeZ",[kyt,lo],(function(){return new bft})),MSt=ja(CSt.prototype,"startSpeed",[Gyt,lo],(function(){return new bft})),PSt=ja(CSt.prototype,"startRotation3D",[lo],(function(){return!1})),OSt=ja(CSt.prototype,"startRotationX",[Vyt,lo],(function(){return new bft})),LSt=ja(CSt.prototype,"startRotationY",[Uyt,lo],(function(){return new bft})),NSt=ja(CSt.prototype,"startRotationZ",[zyt,Hyt],(function(){return new bft})),FSt=ja(CSt.prototype,"startDelay",[Wyt,lo],(function(){return new bft})),kSt=ja(CSt.prototype,"startLifetime",[Xyt,lo],(function(){return new bft})),GSt=ja(CSt.prototype,"duration",[lo],(function(){return 5})),VSt=ja(CSt.prototype,"loop",[lo],(function(){return!0})),m(CSt.prototype,"simulationSpace",[jyt,lo],Object.getOwnPropertyDescriptor(CSt.prototype,"simulationSpace"),CSt.prototype),USt=ja(CSt.prototype,"simulationSpeed",[lo],(function(){return 1})),zSt=ja(CSt.prototype,"playOnAwake",[lo],(function(){return!0})),HSt=ja(CSt.prototype,"gravityModifier",[Yyt,lo],(function(){return new bft})),WSt=ja(CSt.prototype,"rateOverTime",[qyt,lo],(function(){return new bft})),XSt=ja(CSt.prototype,"rateOverDistance",[Kyt,lo],(function(){return new bft})),jSt=ja(CSt.prototype,"bursts",[Qyt,lo],(function(){return[]})),m(CSt.prototype,"renderCulling",[Zyt],Object.getOwnPropertyDescriptor(CSt.prototype,"renderCulling"),CSt.prototype),YSt=ja(CSt.prototype,"_renderCulling",[lo],(function(){return!1})),m(CSt.prototype,"cullingMode",[Jyt],Object.getOwnPropertyDescriptor(CSt.prototype,"cullingMode"),CSt.prototype),qSt=ja(CSt.prototype,"_cullingMode",[lo],(function(){return gdt.Pause})),m(CSt.prototype,"aabbHalfX",[$yt],Object.getOwnPropertyDescriptor(CSt.prototype,"aabbHalfX"),CSt.prototype),KSt=ja(CSt.prototype,"_aabbHalfX",[lo],(function(){return 0})),m(CSt.prototype,"aabbHalfY",[tSt],Object.getOwnPropertyDescriptor(CSt.prototype,"aabbHalfY"),CSt.prototype),QSt=ja(CSt.prototype,"_aabbHalfY",[lo],(function(){return 0})),m(CSt.prototype,"aabbHalfZ",[eSt],Object.getOwnPropertyDescriptor(CSt.prototype,"aabbHalfZ"),CSt.prototype),ZSt=ja(CSt.prototype,"_aabbHalfZ",[lo],(function(){return 0})),JSt=ja(CSt.prototype,"_dataCulling",[lo,iSt],(function(){return!1})),m(CSt.prototype,"sharedMaterials",[jo,lo],Object.getOwnPropertyDescriptor(CSt.prototype,"sharedMaterials"),CSt.prototype),$St=ja(CSt.prototype,"_colorOverLifetimeModule",[nSt],(function(){return null})),m(CSt.prototype,"colorOverLifetimeModule",[rSt],Object.getOwnPropertyDescriptor(CSt.prototype,"colorOverLifetimeModule"),CSt.prototype),tTt=ja(CSt.prototype,"_shapeModule",[sSt],(function(){return null})),m(CSt.prototype,"shapeModule",[aSt],Object.getOwnPropertyDescriptor(CSt.prototype,"shapeModule"),CSt.prototype),eTt=ja(CSt.prototype,"_sizeOvertimeModule",[oSt],(function(){return null})),m(CSt.prototype,"sizeOvertimeModule",[hSt],Object.getOwnPropertyDescriptor(CSt.prototype,"sizeOvertimeModule"),CSt.prototype),iTt=ja(CSt.prototype,"_velocityOvertimeModule",[uSt],(function(){return null})),m(CSt.prototype,"velocityOvertimeModule",[lSt],Object.getOwnPropertyDescriptor(CSt.prototype,"velocityOvertimeModule"),CSt.prototype),nTt=ja(CSt.prototype,"_forceOvertimeModule",[cSt],(function(){return null})),m(CSt.prototype,"forceOvertimeModule",[_St],Object.getOwnPropertyDescriptor(CSt.prototype,"forceOvertimeModule"),CSt.prototype),rTt=ja(CSt.prototype,"_limitVelocityOvertimeModule",[fSt],(function(){return null})),m(CSt.prototype,"limitVelocityOvertimeModule",[dSt],Object.getOwnPropertyDescriptor(CSt.prototype,"limitVelocityOvertimeModule"),CSt.prototype),sTt=ja(CSt.prototype,"_rotationOvertimeModule",[pSt],(function(){return null})),m(CSt.prototype,"rotationOvertimeModule",[mSt],Object.getOwnPropertyDescriptor(CSt.prototype,"rotationOvertimeModule"),CSt.prototype),aTt=ja(CSt.prototype,"_textureAnimationModule",[gSt],(function(){return null})),m(CSt.prototype,"textureAnimationModule",[vSt],Object.getOwnPropertyDescriptor(CSt.prototype,"textureAnimationModule"),CSt.prototype),oTt=ja(CSt.prototype,"_noiseModule",[ySt],(function(){return null})),m(CSt.prototype,"noiseModule",[SSt],Object.getOwnPropertyDescriptor(CSt.prototype,"noiseModule"),CSt.prototype),hTt=ja(CSt.prototype,"_trailModule",[TSt],(function(){return null})),m(CSt.prototype,"trailModule",[ASt],Object.getOwnPropertyDescriptor(CSt.prototype,"trailModule"),CSt.prototype),uTt=ja(CSt.prototype,"renderer",[bSt,lo],(function(){return new dTt})),lTt=ja(CSt.prototype,"_prewarm",[lo],(function(){return!1})),cTt=ja(CSt.prototype,"_capacity",[lo],(function(){return 100})),_Tt=ja(CSt.prototype,"_simulationSpace",[lo],(function(){return mdt.Local})),ESt=CSt))||ESt)||ESt)),NTt=t("eV",function(){function t(){}return t.instantiate=function(t){this.registeredSceneEvent||(ID.on(wD.EVENT_BEFORE_SCENE_LAUNCH,this.onSceneUnload,this),this.registeredSceneEvent=!0);var e=t._uuid;if(!this.particleSystemPool.has(e)){var i=new ws((function(){return fJ(t)||new hg}),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)||void 0===e||null===(i=e.asset)||void 0===i?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=f(t.getComponentsInChildren(LTt));!(e=i()).done;)e.value.play()},t.stop=function(t){for(var e,i=f(t.getComponentsInChildren(LTt));!(e=i()).done;)e.value.stop()},t.onSceneUnload=function(){this.particleSystemPool.forEach((function(t){return t.destroy()})),this.particleSystemPool.clear()},t}());NTt.particleSystemPool=new Map,NTt.registeredSceneEvent=!1,lt(mgt.prototype,"Burst.prototype",[{name:"minCount"},{name:"maxCount"}]),ut(LTt.prototype,"ParticleSystem.prototype",[{name:"enableCulling",newName:"dataCulling"}]),S.ParticleSystemComponent=LTt,ne(LTt,"cc.ParticleSystemComponent"),S.BillboardComponent=pft,ne(pft,"cc.BillboardComponent"),S.LineComponent=tdt,ne(tdt,"cc.LineComponent"),S.ParticleUtils=NTt;var FTt,kTt,GTt,VTt=Ee({GRAVITY:0,RADIUS:1}),UTt=Ee({FREE:0,RELATIVE:1,GROUPED:2}),zTt=new jn(0,0),HTt=new jn,WTt=new jn,XTt=new jn,jTt=new jn,YTt=new cn,qTt=FP(PP),KTt=function(){this.pos=new jn(0,0),this.startPos=new jn(0,0),this.color=new En(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 jn(0,0),this.aspectRatio=1,this.dir=new jn(0,0),this.radialAccel=0,this.tangentialAccel=0,this.angle=0,this.degreesPerSecond=0,this.radius=0,this.deltaRadius=0},QTt=new(function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.prototype.get=function(){return this._get()||new KTt},e}(le))((function(t){t.pos.set(zTt),t.startPos.set(zTt),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(zTt),t.aspectRatio=1,t.dir.set(zTt),t.radialAccel=0,t.tangentialAccel=0,t.angle=0,t.degreesPerSecond=0,t.radius=0,t.deltaRadius=0}),1024),ZTt=function(){function t(t){this.particles=[],this.active=!1,this.uvFilled=0,this.finished=!1,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 _=-l,f=-c,d=l,p=c,m=-Ye(t.rotation),g=Math.cos(m),v=Math.sin(m);r[n]=_*g-f*v+s,r[n+1]=_*v+f*g+a,r[n+2]=0,r[n+9]=d*g-f*v+s,r[n+10]=d*v+f*g+a,r[n+11]=0,r[n+18]=_*g-p*v+s,r[n+19]=_*v+p*g+a,r[n+20]=0,r[n+27]=d*g-p*v+s,r[n+28]=d*v+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 y=t.color;YTt.x=y.r/255,YTt.y=y.g/255,YTt.z=y.b/255,YTt.w=y.a/255,cn.toArray(r,YTt,n+5),cn.toArray(r,YTt,n+14),cn.toArray(r,YTt,n+23),cn.toArray(r,YTt,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===UTt.FREE){this._worldRotation=function(t){for(var e=0,i=t;i;)e+=i.eulerAngles.z,i=i.parent;return e}(n);var s=n.worldMatrix;HTt.x=s.m12,HTt.y=s.m13}else i.positionType===UTt.RELATIVE?(this._worldRotation=n.eulerAngles.z,HTt.x=n.position.x,HTt.y=n.position.y):this._worldRotation=0;if(this.active&&i.emissionRate){var a=1/i.emissionRate;for(r.lengtha;)this.emitParticle(HTt),this.emitCounter-=a;this.elapsed+=t,-1!==i.duration&&i.durationthis.uvFilled&&this.updateUVs();for(var u=0;u0){if(i.emitterMode===VTt.GRAVITY){var c=jTt,_=WTt,f=XTt;(l.pos.x||l.pos.y)&&(_.set(l.pos),_.normalize()),f.set(_),_.multiplyScalar(l.radialAccel);var d=f.x;f.x=-f.y,f.y=d,f.multiplyScalar(l.tangentialAccel),c.set(_),c.add(f),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=WTt;p.set(l.pos),i.positionType!==UTt.GROUPED&&p.add(l.startPos);var m=qTt*u*4;this.updateParticleBuffer(l,p,o,m),++u}else{var g=r[u];u!==r.length-1&&(r[u]=r[r.length-1]),QTt.put(g),r.length--,o.resize(o.vertexCount-4,o.indexCount-6)}}this.renderData.material=this.sys.getRenderMaterial(0),this.renderData.frame=this.sys._renderSpriteFrame,o.setRenderDrawInfoAttributes(),0!==r.length||this.active||this.readyToPlay||(this.finished=!0,i._finishedSimulation())},e.requestData=function(t,e){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?ns;s>=0?++n:--n)t.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:this.transparency.indexed=this.read(s);var u=255-this.transparency.indexed.length;if(u>0)for(r=0;u>=0?ru;u>=0?++r:--r)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(s)[0];break;case 2:this.transparency.rgb=this.read(s)}break;case"tEXt":var l=this.read(s),c=l.indexOf(0),_=String.fromCharCode.apply(String,l.slice(0,c));this.text[_]=String.fromCharCode.apply(String,l.slice(c+1));break;case"IEND":e&&this.animation.frames.push(e),this.colors=function(){switch(i.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this);var f=this.colorType;this.hasAlphaChannel=4===f||6===f;var d=this.colors+(this.hasAlphaChannel?1:0);return this.pixelBitlength=this.bits*d,this.colorSpace=function(){switch(i.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(this.imgData instanceof Uint8Array||(this.imgData=new Uint8Array(this.imgData)));default:this.pos+=s}if(this.pos+=4,this.pos>this.data.length)throw new Error(at(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(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[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 jB.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,_=0,f=0,d=0,p=0,m=0,g=0,v=0,y=0,S=0,T=0,A=0,b=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))):Q(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)Q(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);Q(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?Q(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)):Q(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&&L<=127?g=L+1:L>=-127&&L<=-1?v=1-L:x=!0}else{for(var N=this.getUint8(S+b),F=0;F0)for(var a=0;a>4,i=(15&r)<<4|(s=rAt[t.charCodeAt(h++)])>>2,n=(3&s)<<6|(a=rAt[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}},hAt=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(hAt.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};hAt.gunzip=function(t){return t.constructor===Array||t.constructor,new hAt(t).gunzip()[0][0]},hAt.HufNode=function(){this.b0=0,this.b1=0,this.jump=null,this.jumppos=-1},hAt.LITERALS=288,hAt.NAMEMAX=256,hAt.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],hAt.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],hAt.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],hAt.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],hAt.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],hAt.border=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],hAt.prototype.gunzip=function(){return this.outputArr=[],this.nextFile(),this.unzipped},hAt.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},hAt.prototype.readBits=function(t){for(var e=0,i=t;i--;)e=e<<1|this.readBit();return t&&(e=hAt.bitReverse[e]>>8-t),e},hAt.prototype.flushBuffer=function(){this.bIdx=0},hAt.prototype.addBuffer=function(t){this.buf32k[this.bIdx++]=t,this.outputArr.push(String.fromCharCode(t)),32768===this.bIdx&&(this.bIdx=0)},hAt.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]++}},hAt.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},hAt.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},hAt.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(hAt.cplext[a])+hAt.cplens[a],a=hAt.bitReverse[this.readBits(5)]>>3,hAt.cpdext[a]>8?(p=this.readBits(8),p|=this.readBits(hAt.cpdext[a]-8)<<8):p=this.readBits(hAt.cpdext[a]),p+=hAt.cpdist[a],a=0;ao)return this.flushBuffer(),1;for(_=i?c[i-1]:0;a--;)c[i++]=_}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(hAt.cplext[a])+hAt.cplens[a],a=this.DecodeValue(this.distanceTree),hAt.cpdext[a]>8?(p=this.readBits(8),p|=this.readBits(hAt.cpdext[a]-8)<<8):p=this.readBits(hAt.cpdext[a]),p+=hAt.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},hAt.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},function(t){t[t.JPG=0]="JPG",t[t.PNG=1]="PNG",t[t.TIFF=2]="TIFF",t[t.WEBP=3]="WEBP",t[t.PVR=4]="PVR",t[t.ETC=5]="ETC",t[t.S3TC=6]="S3TC",t[t.ATITC=7]="ATITC",t[t.TGA=8]="TGA",t[t.RAWDATA=9]="RAWDATA",t[t.UNKNOWN=10]="UNKNOWN"}(obt||(obt={}));var lbt,cbt,_bt,fbt,dbt,pbt,mbt,gbt,vbt,ybt,Sbt,Tbt=t("eZ",(uAt=eo("cc.ParticleSystem2D"),lAt=Lo($Tt),cAt=Lo(SM),_At=Lo(UTt),fAt=Lo(VTt),dAt=co("preview"),uAt(((abt=function(t){function e(){var e;return(e=t.call(this)||this).duration=gAt&&gAt(),e.emissionRate=vAt&&vAt(),e.life=yAt&&yAt(),e.lifeVar=SAt&&SAt(),e.angle=TAt&&TAt(),e.angleVar=AAt&&AAt(),e.startSize=bAt&&bAt(),e.startSizeVar=EAt&&EAt(),e.endSize=CAt&&CAt(),e.endSizeVar=xAt&&xAt(),e.startSpin=wAt&&wAt(),e.startSpinVar=RAt&&RAt(),e.endSpin=IAt&&IAt(),e.endSpinVar=DAt&&DAt(),e.sourcePos=BAt&&BAt(),e.posVar=MAt&&MAt(),e.emitterMode=PAt&&PAt(),e.gravity=OAt&&OAt(),e.speed=LAt&&LAt(),e.speedVar=NAt&&NAt(),e.tangentialAccel=FAt&&FAt(),e.tangentialAccelVar=kAt&&kAt(),e.radialAccel=GAt&&GAt(),e.radialAccelVar=VAt&&VAt(),e.rotationIsDir=UAt&&UAt(),e.startRadius=zAt&&zAt(),e.startRadiusVar=HAt&&HAt(),e.endRadius=WAt&&WAt(),e.endRadiusVar=XAt&&XAt(),e.rotatePerS=jAt&&jAt(),e.rotatePerSVar=YAt&&YAt(),e.aspectRatio=1,e.playOnLoad=qAt&&qAt(),e.autoRemoveOnFinish=KAt&&KAt(),e._preview=QAt&&QAt(),e._custom=ZAt&&ZAt(),e._file=JAt&&JAt(),e._spriteFrame=$At&&$At(),e._totalParticles=tbt&&tbt(),e._startColor=ebt&&ebt(),e._startColorVar=ibt&&ibt(),e._endColor=nbt&&nbt(),e._endColorVar=rbt&&rbt(),e._positionType=sbt&&sbt(),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._simulator.renderData&&this._assembler&&this._assembler.removeData(this._simulator.renderData)},i.initProperties=function(){this._previewTimer=null,this._focused=!1,this.aspectRatio=1,this._simulator=new ZTt(this)},i.onFocusInEditor=function(){this._focused=!0;for(var t=ubt(this.node),e=0;e=this.totalParticles},i._applyFile=function(){var t=this._file;if(t){if(!t)return void it(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;vT.loadAny(n,(function(e,n){e?(t.spriteFrameUuid=void 0,i._initTextureWithDictionary(t),H(e)):i.spriteFrame=n}))}else{var r=oa(this._plistFile,t.textureFileName||"");if(t.textureFileName)vT.loadRemote(r,(function(e,n){e?(t.textureFileName=void 0,i._initTextureWithDictionary(t),H(e)):i.spriteFrame=n?SM.createWithImage(n):SM.createWithImage(bT.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=vT.assets.get(a);if(!o){var h=hbt.unzipBase64AsArray(s,1);if(!h)return tt(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]?obt.PNG:e.length>2&&(73===e[0]&&73===e[1]||77===e[0]&&77===e[1]||255===e[0]&&216===e[1])?obt.TIFF:obt.UNKNOWN;if(u!==obt.TIFF&&u!==obt.PNG)return tt(6031,this._file.name),!1;var l=A.document.createElement("canvas");u===obt.PNG?new tAt(h).render(l):(this._tiffReader||(this._tiffReader=new eAt),this._tiffReader.parseTIFF(h,l)),o=new Vd(l),vT.assets.add(a,o)}o||tt(6032,this._file.name),this.spriteFrame=o?SM.createWithImage(o):SM.createWithImage(bT.get("white-texture"))}}return!0},i._initWithDictionary=function(t){this._useFile=!0,this.totalParticles=parseInt(t.maxParticles||0),this.life=parseFloat(t.particleLifespan||0),this.lifeVar=parseFloat(t.particleLifespanVariance||0);var e=t.emissionRate;this.emissionRate=e||Math.min(this.totalParticles/this.life,Number.MAX_VALUE),this.duration=parseFloat(t.duration||0),this._srcBlendFactor=parseInt(t.blendFuncSource||vc.SRC_ALPHA),this._dstBlendFactor=parseInt(t.blendFuncDestination||vc.ONE_MINUS_SRC_ALPHA);var i=this._startColor;i.r=255*parseFloat(t.startColorRed||0),i.g=255*parseFloat(t.startColorGreen||0),i.b=255*parseFloat(t.startColorBlue||0),i.a=255*parseFloat(t.startColorAlpha||0);var n=this._startColorVar;n.r=255*parseFloat(t.startColorVarianceRed||0),n.g=255*parseFloat(t.startColorVarianceGreen||0),n.b=255*parseFloat(t.startColorVarianceBlue||0),n.a=255*parseFloat(t.startColorVarianceAlpha||0);var r=this._endColor;r.r=255*parseFloat(t.finishColorRed||0),r.g=255*parseFloat(t.finishColorGreen||0),r.b=255*parseFloat(t.finishColorBlue||0),r.a=255*parseFloat(t.finishColorAlpha||0);var s=this._endColorVar;if(s.r=255*parseFloat(t.finishColorVarianceRed||0),s.g=255*parseFloat(t.finishColorVarianceGreen||0),s.b=255*parseFloat(t.finishColorVarianceBlue||0),s.a=255*parseFloat(t.finishColorVarianceAlpha||0),this.startSize=parseFloat(t.startParticleSize||0),this.startSizeVar=parseFloat(t.startParticleSizeVariance||0),this.endSize=parseFloat(t.finishParticleSize||0),this.endSizeVar=parseFloat(t.finishParticleSizeVariance||0),this.positionType=parseFloat(void 0!==t.positionType?t.positionType:UTt.FREE),this.sourcePos.set(0,0),this.posVar.set(parseFloat(t.sourcePositionVariancex||0),parseFloat(t.sourcePositionVariancey||0)),this.angle=parseFloat(t.angle||0),this.angleVar=parseFloat(t.angleVariance||0),this.startSpin=parseFloat(t.rotationStart||0),this.startSpinVar=parseFloat(t.rotationStartVariance||0),this.endSpin=parseFloat(t.rotationEnd||0),this.endSpinVar=parseFloat(t.rotationEndVariance||0),this.emitterMode=parseInt(t.emitterType||VTt.GRAVITY),this.emitterMode===VTt.GRAVITY){this.gravity.set(parseFloat(t.gravityx||0),parseFloat(t.gravityy||0)),this.speed=parseFloat(t.speed||0),this.speedVar=parseFloat(t.speedVariance||0),this.radialAccel=parseFloat(t.radialAcceleration||0),this.radialAccelVar=parseFloat(t.radialAccelVariance||0),this.tangentialAccel=parseFloat(t.tangentialAcceleration||0),this.tangentialAccelVar=parseFloat(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!==VTt.RADIUS)return tt(6009),!1;this.startRadius=parseFloat(t.maxRadius||0),this.startRadiusVar=parseFloat(t.maxRadiusVariance||0),this.endRadius=parseFloat(t.minRadius||0),this.endRadiusVar=parseFloat(t.minRadiusVariance||0),this.rotatePerS=parseFloat(t.rotatePerSecond||0),this.rotatePerSVar=parseFloat(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!==UTt.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===UTt.RELATIVE?t.commitComp(this,this._simulator.renderData,this._renderSpriteFrame,this._assembler,this.node.parent):this.positionType===UTt.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===UTt.RELATIVE?(this._renderEntity.setRenderTransform(this.node.parent),this._renderEntity.setUseLocal(!0)):this.positionType===UTt.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}(XO)).EmitterMode=VTt,abt.PositionType=UTt,abt.DURATION_INFINITY=-1,abt.START_SIZE_EQUAL_TO_END_SIZE=-1,abt.START_RADIUS_EQUAL_TO_END_RADIUS=-1,m((mAt=abt).prototype,"file",[lAt],Object.getOwnPropertyDescriptor(mAt.prototype,"file"),mAt.prototype),m(mAt.prototype,"spriteFrame",[cAt],Object.getOwnPropertyDescriptor(mAt.prototype,"spriteFrame"),mAt.prototype),gAt=ja(mAt.prototype,"duration",[lo],(function(){return-1})),vAt=ja(mAt.prototype,"emissionRate",[lo],(function(){return 10})),yAt=ja(mAt.prototype,"life",[lo],(function(){return 1})),SAt=ja(mAt.prototype,"lifeVar",[lo],(function(){return 0})),m(mAt.prototype,"color",[jo],Object.getOwnPropertyDescriptor(mAt.prototype,"color"),mAt.prototype),TAt=ja(mAt.prototype,"angle",[lo],(function(){return 90})),AAt=ja(mAt.prototype,"angleVar",[lo],(function(){return 20})),bAt=ja(mAt.prototype,"startSize",[lo],(function(){return 50})),EAt=ja(mAt.prototype,"startSizeVar",[lo],(function(){return 0})),CAt=ja(mAt.prototype,"endSize",[lo],(function(){return 0})),xAt=ja(mAt.prototype,"endSizeVar",[lo],(function(){return 0})),wAt=ja(mAt.prototype,"startSpin",[lo],(function(){return 0})),RAt=ja(mAt.prototype,"startSpinVar",[lo],(function(){return 0})),IAt=ja(mAt.prototype,"endSpin",[lo],(function(){return 0})),DAt=ja(mAt.prototype,"endSpinVar",[lo],(function(){return 0})),BAt=ja(mAt.prototype,"sourcePos",[lo],(function(){return jn.ZERO.clone()})),MAt=ja(mAt.prototype,"posVar",[lo],(function(){return jn.ZERO.clone()})),m(mAt.prototype,"positionType",[_At],Object.getOwnPropertyDescriptor(mAt.prototype,"positionType"),mAt.prototype),PAt=ja(mAt.prototype,"emitterMode",[lo,fAt],(function(){return VTt.GRAVITY})),OAt=ja(mAt.prototype,"gravity",[lo],(function(){return jn.ZERO.clone()})),LAt=ja(mAt.prototype,"speed",[lo],(function(){return 180})),NAt=ja(mAt.prototype,"speedVar",[lo],(function(){return 50})),FAt=ja(mAt.prototype,"tangentialAccel",[lo],(function(){return 80})),kAt=ja(mAt.prototype,"tangentialAccelVar",[lo],(function(){return 0})),GAt=ja(mAt.prototype,"radialAccel",[lo],(function(){return 0})),VAt=ja(mAt.prototype,"radialAccelVar",[lo],(function(){return 0})),UAt=ja(mAt.prototype,"rotationIsDir",[lo],(function(){return!1})),zAt=ja(mAt.prototype,"startRadius",[lo],(function(){return 0})),HAt=ja(mAt.prototype,"startRadiusVar",[lo],(function(){return 0})),WAt=ja(mAt.prototype,"endRadius",[lo],(function(){return 0})),XAt=ja(mAt.prototype,"endRadiusVar",[lo],(function(){return 0})),jAt=ja(mAt.prototype,"rotatePerS",[lo],(function(){return 0})),YAt=ja(mAt.prototype,"rotatePerSVar",[lo],(function(){return 0})),qAt=ja(mAt.prototype,"playOnLoad",[lo],(function(){return!0})),KAt=ja(mAt.prototype,"autoRemoveOnFinish",[lo],(function(){return!1})),QAt=ja(mAt.prototype,"_preview",[dAt],(function(){return!0})),ZAt=ja(mAt.prototype,"_custom",[lo],(function(){return!1})),JAt=ja(mAt.prototype,"_file",[lo],(function(){return null})),$At=ja(mAt.prototype,"_spriteFrame",[lo],(function(){return null})),tbt=ja(mAt.prototype,"_totalParticles",[lo],(function(){return 150})),ebt=ja(mAt.prototype,"_startColor",[lo],(function(){return new En(255,255,255,255)})),ibt=ja(mAt.prototype,"_startColorVar",[lo],(function(){return new En(0,0,0,0)})),nbt=ja(mAt.prototype,"_endColor",[lo],(function(){return new En(255,255,255,0)})),rbt=ja(mAt.prototype,"_endColorVar",[lo],(function(){return new En(0,0,0,0)})),sbt=ja(mAt.prototype,"_positionType",[lo],(function(){return UTt.FREE})),pAt=mAt))||pAt)),Abt=function(){function t(t,e){this.point=new jn,this.dir=new jn,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}(),bbt=t("e_",(lbt=eo("cc.MotionStreak"),cbt=Lo(lm),lbt(((Sbt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r1){var h=o[0],u=h.point.x-s,l=h.point.y-a;u*u+l*l=0;b--){var E=o[b],C=E.point,x=E.dir;if(E.time-=e,E.time<0)o.splice(b,1);else{var w=E.time/T,R=o[b-1];if(!A){if(!R){o.splice(b,1);continue}C.x=R.point.x-x.x*w,C.y=R.point.y-x.y*w}A=!0,wbt(Cbt,x);var I=w*v,D=_;S[D].x=C.x+Cbt.x*n,S[D].y=C.y+Cbt.y*n,S[D].u=1,S[D].v=w,S[D].color.set(p,m,g,I),S[D+=1].x=C.x-Cbt.x*n,S[D].y=C.y-Cbt.y*n,S[D].u=0,S[D].v=w,S[D].color.set(p,m,g,I),_+=2}}c=_<=2?0:3*(_-2),f.resize(_,c)}},updateWorldVertexAllData:function(t){for(var e=t.renderData,i=e.floatStride,n=e.data,r=e.chunk.vb,s=0;se?t:e}function O(t,e,i){return ti?i:t}var L=isFinite;function N(t){return t*t}function F(t){return 1/Math.sqrt(t)}var k=Math.sqrt,G=Math.pow;var V=Math.cos,U=Math.sin,z=Math.acos,H=Math.asin,W=Math.atan2;var X=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=M(this.x,t.x),this.y=M(this.y,t.y),this},e.SelfMaxV=function(t){return this.x=P(this.x,t.x),this.y=P(this.y,t.y),this},e.SelfAbs=function(){return this.x=B(this.x),this.y=B(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 x(e,(function(){return new t}))},t.AbsV=function(t,e){return e.x=B(t.x),e.y=B(t.y),e},t.MinV=function(t,e,i){return i.x=M(t.x,e.x),i.y=M(t.y,e.y),i},t.MaxV=function(t,e,i){return i.x=P(t.x,e.x),i.y=P(t.y,e.y),i},t.ClampV=function(t,e,i,n){return n.x=O(t.x,e.x,i.x),n.y=O(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}();X.ZERO=new X(0,0),X.UNITX=new X(1,0),X.UNITY=new X(0,1),X.s_t0=new X,X.s_t1=new X,X.s_t2=new X,X.s_t3=new X;var j=new X(0,0),Y=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=x(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=X.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=X.DotVV(this.m_vertices[0],t),n=1;ni&&(e=n,i=r)}return e},e.GetSupportVertex=function(t){for(var e=0,i=X.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 Z,this.transformB=new Z,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 X,this.pointB=new X,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 X,this.wB=new X,this.w=new X,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,_=this.GetMetric();(_<.5*c||2*c<_||_0?X.CrossOneV(e,t):X.CrossVOne(e,t);default:return t.SetZero()}},e.GetClosestPoint=function(t){switch(this.m_count){case 0: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);case 3:default:return t.SetZero()}},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:return 0;case 2:return X.DistanceVV(this.m_v1.w,this.m_v2.w);case 3:return X.CrossVV(X.SubVV(this.m_v2.w,this.m_v1.w,X.s_t0),X.SubVV(this.m_v3.w,this.m_v1.w,X.s_t1));default:return 0}},e.Solve2=function(){var e=this.m_v1.w,i=this.m_v2.w,n=X.SubVV(i,e,t.s_e12),r=-X.DotVV(e,n);if(r<=0)return this.m_v1.a=1,void(this.m_count=1);var s=X.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=X.SubVV(i,e,t.s_e12),s=X.DotVV(e,r),a=X.DotVV(i,r),o=-s,h=X.SubVV(n,e,t.s_e13),u=X.DotVV(e,h),l=X.DotVV(n,h),c=-u,_=X.SubVV(n,i,t.s_e23),f=X.DotVV(i,_),d=X.DotVV(n,_),p=-f,m=X.CrossVV(r,h),g=m*X.CrossVV(i,n),v=m*X.CrossVV(n,e),y=m*X.CrossVV(e,i);if(o<=0&&c<=0)return this.m_v1.a=1,void(this.m_count=1);if(a>0&&o>0&&y<=0){var S=1/(a+o);return this.m_v1.a=a*S,this.m_v2.a=o*S,void(this.m_count=2)}if(l>0&&c>0&&v<=0){var T=1/(l+c);return this.m_v1.a=l*T,this.m_v3.a=c*T,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 A=1/(d+p);return this.m_v2.a=d*A,this.m_v3.a=p*A,this.m_count=2,void this.m_v1.Copy(this.m_v3)}var b=1/(g+v+y);this.m_v1.a=g*b,this.m_v2.a=v*b,this.m_v3.a=y*b,this.m_count=3},t}();lt.s_e12=new X,lt.s_e13=new X,lt.s_e23=new X;var ct=new lt,_t=[0,0,0],ft=[0,0,0],dt=new X,pt=new X,mt=new X,gt=new X,vt=new X;function yt(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,_=_t,f=ft,d=0,p=0;p<20;){d=l.m_count;for(var m=0;mT+A&&e.distance>r){e.distance-=T+A;var b=X.SubVV(e.pointB,e.pointA,mt);b.Normalize(),e.pointA.SelfMulAdd(T,b),e.pointB.SelfMulSub(A,b)}else{var E=X.MidVV(e.pointA,e.pointB,dt);e.pointA.Copy(E),e.pointB.Copy(E),e.distance=0}}}var St,Tt=new X,At=new lt,bt=new X,Et=new X,Ct=new X,xt=new X,wt=new X,Rt=new X;(St=t.b2ContactFeatureType||(t.b2ContactFeatureType={}))[St.e_vertex=0]="e_vertex",St[St.e_face=1]="e_face";var It,Dt=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}(),Bt=function(){function t(){this.cf=new Dt}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}(),Mt=function(){function t(){this.localPoint=new X,this.normalImpulse=0,this.tangentImpulse=0,this.id=new Bt}t.MakeArray=function(e){return x(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 Pt,Ot=function(){function e(){this.points=Mt.MakeArray(2),this.localNormal=new X,this.localPoint=new X,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}(),Lt=function(){function e(){this.normal=new X,this.points=X.MakeArray(2),this.separations=w(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=Z.MulXV(n,i.localPoint,e.Initialize_s_pointA),u=Z.MulXV(s,i.points[0].localPoint,e.Initialize_s_pointB);X.DistanceSquaredVV(h,u)>a&&X.SubVV(u,h,this.normal).SelfNormalize();var l=X.AddVMulSV(h,r,this.normal,e.Initialize_s_cA),c=X.SubVMulSV(u,o,this.normal,e.Initialize_s_cB);X.MidVV(l,c,this.points[0]),this.separations[0]=X.DotVV(X.SubVV(c,l,X.s_t0),this.normal);break;case t.b2ManifoldType.e_faceA:Q.MulRV(n.q,i.localNormal,this.normal);for(var _=Z.MulXV(n,i.localPoint,e.Initialize_s_planePoint),f=0;fp){var g=d;d=p,p=g,m=1}if(d>n&&(_.x=m,_.y=0,n=d),n>(s=M(s,p)))return!1}if(cS){var A=y;y=S,S=A,T=1}if(y>n&&(_.x=0,_.y=T,n=y),n>(s=M(s,S)))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=X.SubVV(r,n,t.s_r);s.Normalize();var a=X.CrossOneV(s,t.s_v),o=X.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=M(n.x,l),u.lowerBound.y=M(n.y,c),u.upperBound.x=P(n.x,l),u.upperBound.y=P(n.y,c);var _=this.m_stack.Reset();for(_.Push(this.m_root);_.GetCount()>0;){var f=_.Pop();if(null!==f&&Vt(f.aabb,u)){var d=f.aabb.GetCenter(),p=f.aabb.GetExtents();if(!(B(X.DotVV(a,X.SubVV(n,d,X.s_t0)))-X.DotVV(o,p)>0))if(f.IsLeaf()){var m=t.s_subInput;m.p1.Copy(e.p1),m.p2.Copy(e.p2),m.maxFraction=h;var g=i(m,f);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=M(n.x,l),u.lowerBound.y=M(n.y,c),u.upperBound.x=P(n.x,l),u.upperBound.y=P(n.y,c))}else _.Push(f.child1),_.Push(f.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 Yt(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=jt(n.child1),s=jt(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,_=t.s_aabb,f=void 0;r.IsLeaf()?(_.Combine2(i,r.aabb),c=_.GetPerimeter()+l):(_.Combine2(i,r.aabb),f=r.aabb.GetPerimeter(),c=_.GetPerimeter()-f+l);var d=void 0;if(s.IsLeaf()?(_.Combine2(i,s.aabb),d=_.GetPerimeter()+l):(_.Combine2(i,s.aabb),f=s.aabb.GetPerimeter(),d=_.GetPerimeter()-f+l),u1){var r=jt(i.child1),s=jt(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+P(e.height,s.height),i.height=1+P(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+P(e.height,r.height),i.height=1+P(t.height,s.height)),i}if(n<-1){var a=jt(e.child1),o=jt(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+P(i.height,o.height),e.height=1+P(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+P(i.height,a.height),e.height=1+P(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+P(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=jt(t.child1),i=jt(t.child2);this.ValidateStructure(e),this.ValidateStructure(i)}},e.ValidateMetrics=function(e){if(null!==e&&!e.IsLeaf()){var i=jt(e.child1),n=jt(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=jt(t.child1),n=jt(t.child2);return P(e,B(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 Kt(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function Qt(t,e){return t=i)break;Kt(t,h,i)}}if(0===a)break;r=i,i=s[--a]}}(this.m_pairBuffer,0,this.m_pairCount,$t);for(var r=0;r_+f){e.state=t.b2TOIOutputState.e_separated,e.t=u,A=!0;break}if(w>_-f){d=b;break}var R=T.Evaluate(C[0],x[0],d);if(R<_-f){e.state=t.b2TOIOutputState.e_failed,e.t=d,A=!0;break}if(R<=_+f){e.state=t.b2TOIOutputState.e_touching,e.t=d,A=!0;break}for(var I=0,D=d,M=b;;){var O;O=1&I?D+(_-R)*(M-D)/(w-R):.5*(D+M),++I,++t.b2_toiRootIters;var L=T.Evaluate(C[0],x[0],O);if(B(L-_)_?(D=O,R=L):(M=O,w=L),50===I)break}if(t.b2_toiMaxRootIters=P(t.b2_toiMaxRootIters,I),++E===a)break}if(++p,++t.b2_toiIters,A)break;if(20===p){e.state=t.b2TOIOutputState.e_failed,e.t=d;break}}t.b2_toiMaxIters=P(t.b2_toiMaxIters,p);var N=n.GetMilliseconds();t.b2_toiMaxTime=P(t.b2_toiMaxTime,N),t.b2_toiTime+=N}var Ae=new X,be=new X;function Ee(e,i,n,r,s){e.pointCount=0;var a=Z.MulXV(n,i.m_p,Ae),o=Z.MulXV(s,r.m_p,be),h=X.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 X,xe=new X,we=new X;function Re(e,n,s,a,o){e.pointCount=0;for(var h=Z.MulXV(o,a.m_p,Ce),u=Z.MulTXV(s,h,xe),l=0,c=-i,_=n.m_radius+a.m_radius,f=n.m_count,d=n.m_vertices,p=n.m_normals,m=0;m_)return;g>c&&(c=g,l=m)}var v=l,y=(v+1)%f,S=d[v],T=d[y];if(c_*_)return;e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,X.SubVV(u,S,e.localNormal).SelfNormalize(),e.localPoint.Copy(S),e.points[0].localPoint.Copy(a.m_p),e.points[0].id.key=0}else if(b<=0){if(X.DistanceSquaredVV(u,T)>_*_)return;e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,X.SubVV(u,T,e.localNormal).SelfNormalize(),e.localPoint.Copy(T),e.points[0].localPoint.Copy(a.m_p),e.points[0].id.key=0}else{var E=X.MidVV(S,T,we);if(X.DotVV(X.SubVV(u,E,X.s_t1),p[v])>_)return;e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,e.localNormal.Copy(p[v]).SelfNormalize(),e.localPoint.Copy(E),e.points[0].localPoint.Copy(a.m_p),e.points[0].id.key=0}}var Ie=new X,De=new X,Be=new X,Me=new X;function Pe(t,e,n,r,s){for(var a=t.m_vertices,o=t.m_normals,h=r.m_count,u=r.m_vertices,l=Q.MulRV(e.q,o[n],Ie),c=Q.MulTRV(s.q,l,De),_=0,f=i,d=0;dc&&(c=f,l=_)}var d=Pe(e,n,l,r,s),p=(l+a-1)%a,m=Pe(e,n,p,r,s),g=(l+1)%a,v=Pe(e,n,g,r,s),y=0,S=0,T=0;if(m>d&&m>v)T=-1,y=p,S=m;else{if(!(v>d))return t[0]=l,d;T=1,y=g,S=v}for(;(d=Pe(e,n,l=-1===T?(y+a-1)%a:(y+1)%a,r,s))>S;)y=l,S=d;return t[0]=y,S}var Fe=new X;var ke=Nt.MakeArray(2),Ge=Nt.MakeArray(2),Ve=Nt.MakeArray(2),Ue=[0],ze=[0],He=new X,We=new X,Xe=new X,je=new X,Ye=new X,qe=new X,Ke=new X,Qe=new X;function Ze(e,n,r,s,a){e.pointCount=0;var o=n.m_radius+s.m_radius,h=Ue;h[0]=0;var u=Ne(h,n,r,s,a);if(!(u>o)){var l=ze;l[0]=0;var c=Ne(l,s,a,n,r);if(!(c>o)){var _,f,d,p,m=0,g=0;c>.98*u+.001?(_=s,f=n,d=a,p=r,m=l[0],e.type=t.b2ManifoldType.e_faceB,g=1):(_=n,f=s,d=r,p=a,m=h[0],e.type=t.b2ManifoldType.e_faceA,g=0);var v=ke;!function(e,n,r,s,a,o){for(var h=n.m_normals,u=a.m_count,l=a.m_vertices,c=a.m_normals,_=Q.MulTRV(o.q,Q.MulRV(r.q,h[s],X.s_t0),Fe),f=0,d=i,p=0;p_*_)return;if(i.m_hasVertex0){var m=i.m_vertex0,g=o,v=X.SubVV(g,m,ii);if(X.DotVV(v,X.SubVV(g,a,X.s_t0))>0)return}return f.cf.indexA=0,f.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(f),void e.points[0].localPoint.Copy(r.m_p)}if(l<=0){var y=h,S=X.SubVV(a,y,ei);if(X.DotVV(S,S)>_*_)return;if(i.m_hasVertex3){var T=i.m_vertex3,A=h,b=X.SubVV(T,A,ni);if(X.DotVV(b,X.SubVV(a,A,X.s_t0))>0)return}return f.cf.indexA=1,f.cf.typeA=t.b2ContactFeatureType.e_vertex,e.pointCount=1,e.type=t.b2ManifoldType.e_circles,e.localNormal.SetZero(),e.localPoint.Copy(y),e.points[0].id.Copy(f),void e.points[0].localPoint.Copy(r.m_p)}var E=X.DotVV(u,u),C=ri;C.x=1/E*(l*o.x+c*h.x),C.y=1/E*(l*o.y+c*h.y);var x=X.SubVV(a,C,ei);if(!(X.DotVV(x,x)>_*_)){var w=si.Set(-u.y,u.x);X.DotVV(w,X.SubVV(a,o,X.s_t0))<0&&w.Set(-w.x,-w.y),w.Normalize(),f.cf.indexA=0,f.cf.typeA=t.b2ContactFeatureType.e_face,e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,e.localNormal.Copy(w),e.localPoint.Copy(o),e.points[0].id.Copy(f),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"}(Je||(Je={}));var hi,ui=function(){this.type=Je.e_unknown,this.index=0,this.separation=0},li=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"}(hi||(hi={}));var ci=function(){function e(){this.m_polygonB=new li,this.m_xf=new Z,this.m_centroidB=new X,this.m_v0=new X,this.m_v1=new X,this.m_v2=new X,this.m_v3=new X,this.m_normal0=new X,this.m_normal1=new X,this.m_normal2=new X,this.m_normal=new X,this.m_type1=hi.e_isolated,this.m_type2=hi.e_isolated,this.m_lowerLimit=new X,this.m_upperLimit=new X,this.m_radius=0,this.m_front=!1}var n=e.prototype;return n.Collide=function(i,n,r,s,a){Z.MulTXX(r,a,this.m_xf),Z.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=X.SubVV(this.m_v2,this.m_v1,e.s_edge1);u.Normalize(),this.m_normal1.Set(u.y,-u.x);var l=X.DotVV(this.m_normal1,X.SubVV(this.m_centroidB,this.m_v1,X.s_t0)),c=0,_=0,f=!1,d=!1;if(o){var p=X.SubVV(this.m_v1,this.m_v0,e.s_edge0);p.Normalize(),this.m_normal0.Set(p.y,-p.x),f=X.CrossVV(p,u)>=0,c=X.DotVV(this.m_normal0,X.SubVV(this.m_centroidB,this.m_v0,X.s_t0))}if(h){var m=X.SubVV(this.m_v3,this.m_v2,e.s_edge2);m.Normalize(),this.m_normal2.Set(m.y,-m.x),d=X.CrossVV(u,m)>0,_=X.DotVV(this.m_normal2,X.SubVV(this.m_centroidB,this.m_v2,X.s_t0))}o&&h?f&&d?(this.m_front=c>=0||l>=0||_>=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())):f?(this.m_front=c>=0||l>=0&&_>=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=_>=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&&_>=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?f?(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||_>=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&&_>=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 y=this.ComputePolygonSeparation(e.s_polygonAxis);if(!(y.type!==Je.e_unknown&&y.separation>this.m_radius)){var S;S=y.type===Je.e_unknown?v:y.separation>.98*v.separation+.001?y:v;var T=e.s_ie,A=e.s_rf;if(S.type===Je.e_edgeA){i.type=t.b2ManifoldType.e_faceA;for(var b=0,E=X.DotVV(this.m_normal,this.m_polygonB.normals[0]),C=1;Cthis.m_radius)return n.type=Je.e_edgeB,n.index=s,n.separation=o,n;if(X.DotVV(a,r)>=0){if(X.DotVV(X.SubVV(a,this.m_upperLimit,X.s_t0),this.m_normal)<-c)continue}else if(X.DotVV(X.SubVV(a,this.m_lowerLimit,X.s_t0),this.m_normal)<-c)continue;o>n.separation&&(n.type=Je.e_edgeB,n.index=s,n.separation=o)}return n},e}();ci.s_edge1=new X,ci.s_edge0=new X,ci.s_edge2=new X,ci.s_ie=Nt.MakeArray(2),ci.s_rf=new function(){this.i1=0,this.i2=0,this.v1=new X,this.v2=new X,this.normal=new X,this.sideNormal1=new X,this.sideOffset1=0,this.sideNormal2=new X,this.sideOffset2=0},ci.s_clipPoints1=Nt.MakeArray(2),ci.s_clipPoints2=Nt.MakeArray(2),ci.s_edgeAxis=new ui,ci.s_polygonAxis=new ui,ci.s_n=new X,ci.s_perp=new X;var _i=new ci;function fi(t,e,i,n,r){_i.Collide(t,e,i,n,r)}var di,pi=function(){this.mass=0,this.center=new X(0,0),this.I=0};(di=t.b2ShapeType||(t.b2ShapeType={}))[di.e_unknown=-1]="e_unknown",di[di.e_circleShape=0]="e_circleShape",di[di.e_edgeShape=1]="e_edgeShape",di[di.e_polygonShape=2]="e_polygonShape",di[di.e_chainShape=3]="e_chainShape",di[di.e_shapeTypeCount=4]="e_shapeTypeCount";var mi=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}(),gi=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 X,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=Z.MulXV(t,this.m_p,i.TestPoint_s_center),r=X.SubVV(e,n,i.TestPoint_s_d);return X.DotVV(r,r)<=N(this.m_radius)},n.ComputeDistance=function(t,e,n){var r=Z.MulXV(t,this.m_p,i.ComputeDistance_s_center);return X.SubVV(e,r,n),n.Normalize()-this.m_radius},n.RayCast=function(t,e,n){var s=Z.MulXV(n,this.m_p,i.RayCast_s_position),a=X.SubVV(e.p1,s,i.RayCast_s_s),o=X.DotVV(a,a)-N(this.m_radius),h=X.SubVV(e.p2,e.p1,i.RayCast_s_r),u=X.DotVV(a,h),l=X.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*k(h-u),c=-2/3*G(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}(mi);gi.TestPoint_s_center=new X,gi.TestPoint_s_d=new X,gi.ComputeDistance_s_center=new X,gi.RayCast_s_position=new X,gi.RayCast_s_s=new X,gi.RayCast_s_r=new X,gi.ComputeAABB_s_p=new X;var vi=function(e){function n(){var i;return(i=e.call(this,t.b2ShapeType.e_polygonShape,_)||this).m_centroid=new X(0,0),i.m_vertices=[],i.m_normals=[],i.m_count=0,i}s(n,e);var r=n.prototype;return r.Clone=function(){return(new n).Copy(this)},r.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=X.MakeArray(this.m_count),this.m_normals=X.MakeArray(this.m_count);for(var i=0;il||_===l&&r[c].yv.LengthSquared()&&(m=g)}else m=g;if(++d,p=m,m===u)break}this.m_count=d,this.m_vertices=X.MakeArray(this.m_count),this.m_normals=X.MakeArray(this.m_count);for(var T=0;T0)return!1;return!0},r.ComputeDistance=function(t,e,r){for(var s=Z.MulTXV(t,e,n.ComputeDistance_s_pLocal),a=-i,o=n.ComputeDistance_s_normalForMaxDistance.Copy(s),h=0;ha&&(a=u,o.Copy(this.m_normals[h]))}if(a>0){for(var l=n.ComputeDistance_s_minDistance.Copy(o),c=a*a,_=0;_d&&(l.Copy(f),c=d)}return Q.MulRV(t.q,l,r),r.Normalize(),Math.sqrt(c)}return Q.MulRV(t.q,o,r),a},r.RayCast=function(t,e,i){for(var r=Z.MulTXV(i,e.p1,n.RayCast_s_p1),s=Z.MulTXV(i,e.p2,n.RayCast_s_p2),a=X.SubVV(s,r,n.RayCast_s_d),o=0,h=e.maxFraction,u=-1,l=0;l0&&c=0&&(t.fraction=o,Q.MulRV(i.q,this.m_normals[u],t.normal),!0)},r.ComputeAABB=function(t,e){for(var i=Z.MulXV(e,this.m_vertices[0],t.lowerBound),r=t.upperBound.Copy(i),s=0;s0&&(f?c||(u=_-1,h++):c&&(l=_-1,h++)),c=f}switch(h){case 0:if(c){var d=n.ComputeSubmergedArea_s_md;return this.ComputeMass(d,1),Z.MulXV(i,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,v=(0-o[u])/(o[m]-o[u]),y=(0-o[l])/(o[g]-o[l]),S=n.ComputeSubmergedArea_s_intoVec.Set(this.m_vertices[u].x*(1-v)+this.m_vertices[m].x*v,this.m_vertices[u].y*(1-v)+this.m_vertices[m].y*v),T=n.ComputeSubmergedArea_s_outoVec.Set(this.m_vertices[l].x*(1-y)+this.m_vertices[g].x*y,this.m_vertices[l].y*(1-y)+this.m_vertices[g].y*y),A=0,b=n.ComputeSubmergedArea_s_center.SetZero(),E=this.m_vertices[m],C=m;C!==g;){p=(C=(C+1)%this.m_count)===g?T:this.m_vertices[C];var x=.5*((E.x-S.x)*(p.y-S.y)-(E.y-S.y)*(p.x-S.x));A+=x,b.x+=x*(S.x+E.x+p.x)/3,b.y+=x*(S.y+E.y+p.y)/3,E=p}return b.SelfMul(1/A),Z.MulXV(i,b,r),A},r.Dump=function(t){t(" const shape: b2PolygonShape = new b2PolygonShape();\n"),t(" const vs: b2Vec2[] = [];\n");for(var e=0;e0){var u=X.DotVV(o,o);h>u?X.SubVV(e,s,a):a.SelfMulSub(h/u,o)}return n.Copy(a),n.Normalize()},n.RayCast=function(t,e,n){var r=Z.MulTXV(n,e.p1,i.RayCast_s_p1),s=Z.MulTXV(n,e.p2,i.RayCast_s_p2),a=X.SubVV(s,r,i.RayCast_s_d),o=this.m_vertex1,h=this.m_vertex2,u=X.SubVV(h,o,i.RayCast_s_e),l=t.normal.Set(u.y,-u.x).SelfNormalize(),c=X.DotVV(l,X.SubVV(o,r,X.s_t0)),_=X.DotVV(l,a);if(0===_)return!1;var f=c/_;if(f<0||e.maxFraction0&&t.normal.SelfNeg(),0))},n.ComputeAABB=function(t,e){var n=Z.MulXV(e,this.m_vertex1,i.ComputeAABB_s_v1),r=Z.MulXV(e,this.m_vertex2,i.ComputeAABB_s_v2);X.MinV(n,r,t.lowerBound),X.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,X.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}(mi);yi.ComputeDistance_s_v1=new X,yi.ComputeDistance_s_v2=new X,yi.ComputeDistance_s_d=new X,yi.ComputeDistance_s_s=new X,yi.RayCast_s_p1=new X,yi.RayCast_s_p2=new X,yi.RayCast_s_d=new X,yi.RayCast_s_e=new X,yi.RayCast_s_q=new X,yi.RayCast_s_r=new X,yi.ComputeAABB_s_v1=new X,yi.ComputeAABB_s_v2=new X;var Si=function(e){function i(){var i;return(i=e.call(this,t.b2ShapeType.e_chainShape,_)||this).m_vertices=[],i.m_count=0,i.m_prevVertex=new X,i.m_nextVertex=new X,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),Z.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,X.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&&(X.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*X.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*X.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*X.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),Z.MulXV(this.m_xf,this.m_sweep.localCenter,this.m_sweep.c),this.m_sweep.c0.Copy(this.m_sweep.c),X.AddVCrossSV(this.m_linearVelocity,this.m_angularVelocity,X.SubVV(this.m_sweep.c,n,X.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*X.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),Z.MulXV(this.m_xf,this.m_sweep.localCenter,this.m_sweep.c),this.m_sweep.c0.Copy(this.m_sweep.c),X.AddVCrossSV(this.m_linearVelocity,this.m_angularVelocity,X.SubVV(this.m_sweep.c,s,X.s_t0),this.m_linearVelocity)},n.GetWorldPoint=function(t,e){return Z.MulXV(this.m_xf,t,e)},n.GetWorldVector=function(t,e){return Q.MulRV(this.m_xf.q,t,e)},n.GetLocalPoint=function(t,e){return Z.MulTXV(this.m_xf,t,e)},n.GetLocalVector=function(t,e){return Q.MulTRV(this.m_xf.q,t,e)},n.GetLinearVelocityFromWorldPoint=function(t,e){return X.AddVCrossSV(this.m_linearVelocity,this.m_angularVelocity,X.SubVV(t,this.m_sweep.c,X.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),Q.MulRV(t.q,this.m_sweep.localCenter,t.p),X.SubVV(this.m_sweep.c0,t.p,t.p);for(var e=X.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),Q.MulRV(this.m_xf.q,this.m_sweep.localCenter,this.m_xf.p),X.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),Q.MulRV(this.m_xf.q,this.m_sweep.localCenter,this.m_xf.p),X.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}();Ri.CreateFixtureShapeDensity_s_def=new Ai,Ri.SetMassData_s_oldCenter=new X,Ri.ResetMassData_s_localCenter=new X,Ri.ResetMassData_s_oldCenter=new X,Ri.ResetMassData_s_massData=new pi,Ri.SynchronizeFixtures_s_xf1=new Z,Ri.SynchronizeFixtures_s_displacement=new X,(wi=t.b2JointType||(t.b2JointType={}))[wi.e_unknownJoint=0]="e_unknownJoint",wi[wi.e_revoluteJoint=1]="e_revoluteJoint",wi[wi.e_prismaticJoint=2]="e_prismaticJoint",wi[wi.e_distanceJoint=3]="e_distanceJoint",wi[wi.e_pulleyJoint=4]="e_pulleyJoint",wi[wi.e_mouseJoint=5]="e_mouseJoint",wi[wi.e_gearJoint=6]="e_gearJoint",wi[wi.e_wheelJoint=7]="e_wheelJoint",wi[wi.e_weldJoint=8]="e_weldJoint",wi[wi.e_frictionJoint=9]="e_frictionJoint",wi[wi.e_ropeJoint=10]="e_ropeJoint",wi[wi.e_motorJoint=11]="e_motorJoint",wi[wi.e_areaJoint=12]="e_areaJoint",(xi=t.b2LimitState||(t.b2LimitState={}))[xi.e_inactiveLimit=0]="e_inactiveLimit",xi[xi.e_atLowerLimit=1]="e_atLowerLimit",xi[xi.e_atUpperLimit=2]="e_atUpperLimit",xi[xi.e_equalLimits=3]="e_equalLimits";var Ii=function(){function t(){this.linear=new X,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}(),Di=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}(),Bi=function(e){this.type=t.b2JointType.e_unknownJoint,this.userData=null,this.collideConnected=!1,this.type=e},Mi=function(){function i(i){this.m_type=t.b2JointType.e_unknownJoint,this.m_prev=null,this.m_next=null,this.m_edgeA=new Di(this),this.m_edgeB=new Di(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}(),Pi=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_distanceJoint)||this).localAnchorA=new X,i.localAnchorB=new X,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=X.DistanceVV(i,n),this.frequencyHz=0,this.dampingRatio=0},i}(Bi),Oi=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 X,n.m_localAnchorB=new X,n.m_gamma=0,n.m_impulse=0,n.m_length=0,n.m_indexA=0,n.m_indexB=0,n.m_u=new X,n.m_rA=new X,n.m_rB=new X,n.m_localCenterA=new X,n.m_localCenterB=new X,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_mass=0,n.m_qA=new Q,n.m_qB=new Q,n.m_lalcA=new X,n.m_lalcB=new X,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,_=this.m_qA.SetAngle(n),f=this.m_qB.SetAngle(h);X.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA),Q.MulRV(_,this.m_lalcA,this.m_rA),X.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),Q.MulRV(f,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=X.CrossVV(this.m_rA,this.m_u),m=X.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 v=d-this.m_length,y=2*o*this.m_frequencyHz,S=2*this.m_mass*this.m_dampingRatio*y,T=this.m_mass*y*y,A=t.step.dt;this.m_gamma=A*(S+A*T),this.m_gamma=0!==this.m_gamma?1/this.m_gamma:0,this.m_bias=v*A*T*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 b=X.MulSV(this.m_impulse,this.m_u,i.InitVelocityConstraints_s_P);r.SelfMulSub(this.m_invMassA,b),s-=this.m_invIA*X.CrossVV(this.m_rA,b),u.SelfMulAdd(this.m_invMassB,b),c+=this.m_invIB*X.CrossVV(this.m_rB,b)}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=X.AddVCrossSV(e,n,this.m_rA,i.SolveVelocityConstraints_s_vpA),o=X.AddVCrossSV(r,s,this.m_rB,i.SolveVelocityConstraints_s_vpB),h=X.DotVV(this.m_u,X.SubVV(o,a,X.s_t0)),u=-this.m_mass*(h+this.m_bias+this.m_gamma*this.m_impulse);this.m_impulse+=u;var l=X.MulSV(u,this.m_u,i.SolveVelocityConstraints_s_P);e.SelfMulSub(this.m_invMassA,l),n-=this.m_invIA*X.CrossVV(this.m_rA,l),r.SelfMulAdd(this.m_invMassB,l),s+=this.m_invIB*X.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=Q.MulRV(a,this.m_lalcA,this.m_rA),u=Q.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 _=this.m_u.Normalize()-this.m_length;_=O(_,-.2,d);var f=-this.m_mass*_,p=X.MulSV(f,c,i.SolvePositionConstraints_s_P);return e.SelfMulSub(this.m_invMassA,p),n-=this.m_invIA*X.CrossVV(h,p),r.SelfMulAdd(this.m_invMassB,p),s+=this.m_invIB*X.CrossVV(u,p),t.positions[this.m_indexA].a=n,t.positions[this.m_indexB].a=s,B(_)N(d)&&y.SelfMul(d/k(S)),S>N(l)&&(f=!1),g.x+=y.x,g.y+=y.y}return f},i}(Mi),Fi=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_frictionJoint)||this).localAnchorA=new X,i.localAnchorB=new X,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}(Bi),ki=function(t){function i(i){var n;return(n=t.call(this,i)||this).m_localAnchorA=new X,n.m_localAnchorB=new X,n.m_linearImpulse=new X,n.m_angularImpulse=0,n.m_maxForce=0,n.m_maxTorque=0,n.m_indexA=0,n.m_indexB=0,n.m_rA=new X,n.m_rB=new X,n.m_localCenterA=new X,n.m_localCenterB=new X,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_linearMass=new q,n.m_angularMass=0,n.m_qA=new Q,n.m_qB=new Q,n.m_lalcA=new X,n.m_lalcB=new X,n.m_K=new q,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);X.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var u=Q.MulRV(o,this.m_lalcA,this.m_rA);X.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var l=Q.MulRV(h,this.m_lalcB,this.m_rB),c=this.m_invMassA,_=this.m_invMassB,f=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=-f*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=f+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-=f*(X.CrossVV(this.m_rA,m)+this.m_angularImpulse),s.SelfMulAdd(_,m),a+=d*(X.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,_=-this.m_angularMass*c,f=this.m_angularImpulse,d=l*this.m_maxTorque;this.m_angularImpulse=O(this.m_angularImpulse+_,-d,d),n-=h*(_=this.m_angularImpulse-f),s+=u*_;var p=X.SubVV(X.AddVCrossSV(r,s,this.m_rB,X.s_t0),X.AddVCrossSV(e,n,this.m_rA,X.s_t1),i.SolveVelocityConstraints_s_Cdot_v2),m=q.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 v=l*this.m_maxForce;this.m_linearImpulse.LengthSquared()>v*v&&(this.m_linearImpulse.Normalize(),this.m_linearImpulse.SelfMul(v)),X.SubVV(this.m_linearImpulse,g,m),e.SelfMulSub(a,m),n-=h*X.CrossVV(this.m_rA,m),r.SelfMulAdd(o,m),s+=u*X.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}(Mi);ki.SolveVelocityConstraints_s_Cdot_v2=new X,ki.SolveVelocityConstraints_s_impulseV=new X,ki.SolveVelocityConstraints_s_oldImpulseV=new X;var Gi=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_gearJoint)||this).ratio=1,i}return s(i,e),i}(Bi),Vi=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 X,r.m_localAnchorB=new X,r.m_localAnchorC=new X,r.m_localAnchorD=new X,r.m_localAxisC=new X,r.m_localAxisD=new X,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 X,r.m_lcB=new X,r.m_lcC=new X,r.m_lcD=new X,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 X,r.m_JvBD=new X,r.m_JwA=0,r.m_JwB=0,r.m_JwC=0,r.m_JwD=0,r.m_mass=0,r.m_qA=new Q,r.m_qB=new Q,r.m_qC=new Q,r.m_qD=new Q,r.m_lalcA=new X,r.m_lalcB=new X,r.m_lalcC=new X,r.m_lalcD=new X,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 _=n.joint1;r.m_localAnchorC.Copy(_.m_localAnchorA),r.m_localAnchorA.Copy(_.m_localAnchorB),r.m_referenceAngleA=_.m_referenceAngle,r.m_localAxisC.Copy(_.m_localXAxisA);var f=r.m_localAnchorC,d=Q.MulTRV(u.q,X.AddVV(Q.MulRV(o.q,r.m_localAnchorA,X.s_t0),X.SubVV(o.p,u.p,X.s_t1),X.s_t0),X.s_t0);s=X.DotVV(X.SubVV(d,f,X.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,v=r.m_bodyD.m_sweep.a;if(r.m_typeB===t.b2JointType.e_revoluteJoint){var y=n.joint2;r.m_localAnchorD.Copy(y.m_localAnchorA),r.m_localAnchorB.Copy(y.m_localAnchorB),r.m_referenceAngleB=y.m_referenceAngle,r.m_localAxisD.SetZero(),a=m-v-r.m_referenceAngleB}else{var S=n.joint2;r.m_localAnchorD.Copy(S.m_localAnchorA),r.m_localAnchorB.Copy(S.m_localAnchorB),r.m_referenceAngleB=S.m_referenceAngle,r.m_localAxisD.Copy(S.m_localXAxisA);var T=r.m_localAnchorD,A=Q.MulTRV(g.q,X.AddVV(Q.MulRV(p.q,r.m_localAnchorB,X.s_t0),X.SubVV(p.p,g.p,X.s_t1),X.s_t0),X.s_t0);a=X.DotVV(X.SubVV(A,T,X.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,_=e.positions[this.m_indexD].a,f=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),v=this.m_qD.SetAngle(_);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 y=Q.MulRV(g,this.m_localAxisC,n.InitVelocityConstraints_s_u);X.SubVV(this.m_localAnchorC,this.m_lcC,this.m_lalcC);var S=Q.MulRV(g,this.m_lalcC,n.InitVelocityConstraints_s_rC);X.SubVV(this.m_localAnchorA,this.m_lcA,this.m_lalcA);var T=Q.MulRV(p,this.m_lalcA,n.InitVelocityConstraints_s_rA);this.m_JvAC.Copy(y),this.m_JwC=X.CrossVV(S,y),this.m_JwA=X.CrossVV(T,y),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 A=Q.MulRV(v,this.m_localAxisD,n.InitVelocityConstraints_s_u);X.SubVV(this.m_localAnchorD,this.m_lcD,this.m_lalcD);var b=Q.MulRV(v,this.m_lalcD,n.InitVelocityConstraints_s_rD);X.SubVV(this.m_localAnchorB,this.m_lcB,this.m_lalcB);var E=Q.MulRV(m,this.m_lalcB,n.InitVelocityConstraints_s_rB);X.MulSV(this.m_ratio,A,this.m_JvBD),this.m_JwD=this.m_ratio*X.CrossVV(b,A),this.m_JwB=this.m_ratio*X.CrossVV(E,A),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,f.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=X.DotVV(this.m_JvAC,X.SubVV(e,s,X.s_t0))+X.DotVV(this.m_JvBD,X.SubVV(n,o,X.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,_=e.positions[this.m_indexB].a,f=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),v=this.m_qB.SetAngle(_),y=this.m_qC.SetAngle(d),S=this.m_qD.SetAngle(m),T=this.m_JvAC,A=this.m_JvBD,b=0;if(this.m_typeA===t.b2JointType.e_revoluteJoint)T.SetZero(),s=1,o=1,b+=this.m_iA+this.m_iC,i=l-d-this.m_referenceAngleA;else{var E=Q.MulRV(y,this.m_localAxisC,n.SolvePositionConstraints_s_u),C=Q.MulRV(y,this.m_lalcC,n.SolvePositionConstraints_s_rC),x=Q.MulRV(g,this.m_lalcA,n.SolvePositionConstraints_s_rA);T.Copy(E),o=X.CrossVV(C,E),s=X.CrossVV(x,E),b+=this.m_mC+this.m_mA+this.m_iC*o*o+this.m_iA*s*s;var w=this.m_lalcC,R=Q.MulTRV(y,X.AddVV(x,X.SubVV(u,f,X.s_t0),X.s_t0),X.s_t0);i=X.DotVV(X.SubVV(R,w,X.s_t0),this.m_localAxisC)}if(this.m_typeB===t.b2JointType.e_revoluteJoint)A.SetZero(),a=this.m_ratio,h=this.m_ratio,b+=this.m_ratio*this.m_ratio*(this.m_iB+this.m_iD),r=_-m-this.m_referenceAngleB;else{var I=Q.MulRV(S,this.m_localAxisD,n.SolvePositionConstraints_s_u),D=Q.MulRV(S,this.m_lalcD,n.SolvePositionConstraints_s_rD),B=Q.MulRV(v,this.m_lalcB,n.SolvePositionConstraints_s_rB);X.MulSV(this.m_ratio,I,A),h=this.m_ratio*X.CrossVV(D,I),a=this.m_ratio*X.CrossVV(B,I),b+=this.m_ratio*this.m_ratio*(this.m_mD+this.m_mB)+this.m_iD*h*h+this.m_iB*a*a;var M=this.m_lalcD,P=Q.MulTRV(S,X.AddVV(B,X.SubVV(c,p,X.s_t0),X.s_t0),X.s_t0);r=X.DotVV(X.SubVV(P,M,X.s_t0),this.m_localAxisD)}var O=i+this.m_ratio*r-this.m_constant,L=0;return b>0&&(L=-O/b),u.SelfMulAdd(this.m_mA*L,T),l+=this.m_iA*L*s,c.SelfMulAdd(this.m_mB*L,A),_+=this.m_iB*L*a,f.SelfMulSub(this.m_mC*L,T),d-=this.m_iC*L*o,p.SelfMulSub(this.m_mD*L,A),m-=this.m_iD*L*h,e.positions[this.m_indexA].a=l,e.positions[this.m_indexB].a=_,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 X.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}(Mi);Vi.InitVelocityConstraints_s_u=new X,Vi.InitVelocityConstraints_s_rA=new X,Vi.InitVelocityConstraints_s_rB=new X,Vi.InitVelocityConstraints_s_rC=new X,Vi.InitVelocityConstraints_s_rD=new X,Vi.SolvePositionConstraints_s_u=new X,Vi.SolvePositionConstraints_s_rA=new X,Vi.SolvePositionConstraints_s_rB=new X,Vi.SolvePositionConstraints_s_rC=new X,Vi.SolvePositionConstraints_s_rD=new X;var Ui=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_motorJoint)||this).linearOffset=new X(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}(Bi),zi=function(t){function i(i){var n;return(n=t.call(this,i)||this).m_linearOffset=new X,n.m_angularOffset=0,n.m_linearImpulse=new X,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 X,n.m_rB=new X,n.m_localCenterA=new X,n.m_localCenterB=new X,n.m_linearError=new X,n.m_angularError=0,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_linearMass=new q,n.m_angularMass=0,n.m_qA=new Q,n.m_qB=new Q,n.m_K=new q,n.m_linearOffset.Copy(e(i.linearOffset,X.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 X.MulSV(t,this.m_linearImpulse,e)},n.GetReactionTorque=function(t){return t*this.m_angularImpulse},n.SetLinearOffset=function(t){X.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=Q.MulRV(u,X.SubVV(this.m_linearOffset,this.m_localCenterA,X.s_t0),this.m_rA),_=Q.MulRV(l,X.NegV(this.m_localCenterB,X.s_t0),this.m_rB),f=this.m_invMassA,d=this.m_invMassB,p=this.m_invIA,m=this.m_invIB,g=this.m_K;if(g.ex.x=f+d+p*c.y*c.y+m*_.y*_.y,g.ex.y=-p*c.x*c.y-m*_.x*_.y,g.ey.x=g.ex.y,g.ey.y=f+d+p*c.x*c.x+m*_.x*_.x,g.GetInverse(this.m_linearMass),this.m_angularMass=p+m,this.m_angularMass>0&&(this.m_angularMass=1/this.m_angularMass),X.SubVV(X.AddVV(s,_,X.s_t0),X.AddVV(e,c,X.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 v=this.m_linearImpulse;n.SelfMulSub(f,v),r-=p*(X.CrossVV(c,v)+this.m_angularImpulse),o.SelfMulAdd(d,v),h+=m*(X.CrossVV(_,v)+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,_=s-n+c*this.m_correctionFactor*this.m_angularError,f=-this.m_angularMass*_,d=this.m_angularImpulse,p=l*this.m_maxTorque;this.m_angularImpulse=O(this.m_angularImpulse+f,-p,p),n-=h*(f=this.m_angularImpulse-d),s+=u*f;var m=this.m_rA,g=this.m_rB,v=X.AddVV(X.SubVV(X.AddVV(r,X.CrossSV(s,g,X.s_t0),X.s_t0),X.AddVV(e,X.CrossSV(n,m,X.s_t1),X.s_t1),X.s_t2),X.MulSV(c*this.m_correctionFactor,this.m_linearError,X.s_t3),i.SolveVelocityConstraints_s_Cdot_v2),y=q.MulMV(this.m_linearMass,v,i.SolveVelocityConstraints_s_impulse_v2).SelfNeg(),S=i.SolveVelocityConstraints_s_oldImpulse_v2.Copy(this.m_linearImpulse);this.m_linearImpulse.SelfAdd(y);var T=l*this.m_maxForce;this.m_linearImpulse.LengthSquared()>T*T&&(this.m_linearImpulse.Normalize(),this.m_linearImpulse.SelfMul(T)),X.SubVV(this.m_linearImpulse,S,y),e.SelfMulSub(a,y),n-=h*X.CrossVV(m,y),r.SelfMulAdd(o,y),s+=u*X.CrossVV(g,y),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}(Mi);zi.SolveVelocityConstraints_s_Cdot_v2=new X,zi.SolveVelocityConstraints_s_impulse_v2=new X,zi.SolveVelocityConstraints_s_oldImpulse_v2=new X;var Hi=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_mouseJoint)||this).target=new X,i.maxForce=0,i.frequencyHz=5,i.dampingRatio=.7,i}return s(i,e),i}(Bi),Wi=function(t){function i(i){var n;return(n=t.call(this,i)||this).m_localAnchorB=new X,n.m_targetA=new X,n.m_frequencyHz=0,n.m_dampingRatio=0,n.m_beta=0,n.m_impulse=new X,n.m_maxForce=0,n.m_gamma=0,n.m_indexA=0,n.m_indexB=0,n.m_rB=new X,n.m_localCenterB=new X,n.m_invMassB=0,n.m_invIB=0,n.m_mass=new q,n.m_C=new X,n.m_qB=new Q,n.m_lalcB=new X,n.m_K=new q,n.m_targetA.Copy(e(i.target,X.ZERO)),Z.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,X.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),Q.MulRV(s,this.m_lalcB,this.m_rB);var _=this.m_K;_.ex.x=this.m_invMassB+this.m_invIB*this.m_rB.y*this.m_rB.y+this.m_gamma,_.ex.y=-this.m_invIB*this.m_rB.x*this.m_rB.y,_.ey.x=_.ex.y,_.ey.y=this.m_invMassB+this.m_invIB*this.m_rB.x*this.m_rB.x+this.m_gamma,_.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*X.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=X.AddVCrossSV(e,n,this.m_rB,i.SolveVelocityConstraints_s_Cdot),s=q.MulMV(this.m_mass,X.AddVV(r,X.AddVV(this.m_C,X.MulSV(this.m_gamma,this.m_impulse,X.s_t0),X.s_t0),X.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()),X.SubVV(this.m_impulse,a,s),e.SelfMulAdd(this.m_invMassB,s),n+=this.m_invIB*X.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 X.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}(Mi);Wi.SolveVelocityConstraints_s_Cdot=new X,Wi.SolveVelocityConstraints_s_impulse=new X,Wi.SolveVelocityConstraints_s_oldImpulse=new X;var Xi=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_prismaticJoint)||this).localAnchorA=new X,i.localAnchorB=new X,i.localAxisA=new X(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}(Bi),ji=function(i){function n(n){var r;return(r=i.call(this,n)||this).m_localAnchorA=new X,r.m_localAnchorB=new X,r.m_localXAxisA=new X,r.m_localYAxisA=new X,r.m_referenceAngle=0,r.m_impulse=new Y(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 X,r.m_localCenterB=new X,r.m_invMassA=0,r.m_invMassB=0,r.m_invIA=0,r.m_invIB=0,r.m_axis=new X(0,0),r.m_perp=new X(0,0),r.m_s1=0,r.m_s2=0,r.m_a1=0,r.m_a2=0,r.m_K=new K,r.m_K3=new K,r.m_K2=new q,r.m_motorMass=0,r.m_qA=new Q,r.m_qB=new Q,r.m_lalcA=new X,r.m_lalcB=new X,r.m_rA=new X,r.m_rB=new X,r.m_localAnchorA.Copy(e(n.localAnchorA,X.ZERO)),r.m_localAnchorB.Copy(e(n.localAnchorB,X.ZERO)),r.m_localXAxisA.Copy(e(n.localAxisA,new X(1,0))).SelfNormalize(),X.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),_=this.m_qB.SetAngle(h);X.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var f=Q.MulRV(c,this.m_lalcA,this.m_rA);X.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var d=Q.MulRV(_,this.m_lalcB,this.m_rB),p=X.AddVV(X.SubVV(o,i,X.s_t0),X.SubVV(d,f,X.s_t1),n.InitVelocityConstraints_s_d),m=this.m_invMassA,g=this.m_invMassB,v=this.m_invIA,y=this.m_invIB;if(Q.MulRV(c,this.m_localXAxisA,this.m_axis),this.m_a1=X.CrossVV(X.AddVV(p,f,X.s_t0),this.m_axis),this.m_a2=X.CrossVV(d,this.m_axis),this.m_motorMass=m+g+v*this.m_a1*this.m_a1+y*this.m_a2*this.m_a2,this.m_motorMass>0&&(this.m_motorMass=1/this.m_motorMass),Q.MulRV(c,this.m_localYAxisA,this.m_perp),this.m_s1=X.CrossVV(X.AddVV(p,f,X.s_t0),this.m_perp),this.m_s2=X.CrossVV(d,this.m_perp),this.m_K.ex.x=m+g+v*this.m_s1*this.m_s1+y*this.m_s2*this.m_s2,this.m_K.ex.y=v*this.m_s1+y*this.m_s2,this.m_K.ex.z=v*this.m_s1*this.m_a1+y*this.m_s2*this.m_a2,this.m_K.ey.x=this.m_K.ex.y,this.m_K.ey.y=v+y,0===this.m_K.ey.y&&(this.m_K.ey.y=1),this.m_K.ey.z=v*this.m_a1+y*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+v*this.m_a1*this.m_a1+y*this.m_a2*this.m_a2,this.m_enableLimit){var S=X.DotVV(this.m_axis,p);B(this.m_upperTranslation-this.m_lowerTranslation)<.016?this.m_limitState=t.b2LimitState.e_equalLimits:S<=this.m_lowerTranslation?this.m_limitState!==t.b2LimitState.e_atLowerLimit&&(this.m_limitState=t.b2LimitState.e_atLowerLimit,this.m_impulse.z=0):S>=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 T=X.AddVV(X.MulSV(this.m_impulse.x,this.m_perp,X.s_t0),X.MulSV(this.m_motorImpulse+this.m_impulse.z,this.m_axis,X.s_t1),n.InitVelocityConstraints_s_P),A=this.m_impulse.x*this.m_s1+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a1,b=this.m_impulse.x*this.m_s2+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a2;s.SelfMulSub(m,T),a-=v*A,u.SelfMulAdd(g,T),l+=y*b}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=X.DotVV(this.m_axis,X.SubVV(s,i,X.s_t0))+this.m_a2*a-this.m_a1*r,_=this.m_motorMass*(this.m_motorSpeed-c),f=this.m_motorImpulse,d=e.step.dt*this.m_maxMotorForce;this.m_motorImpulse=O(this.m_motorImpulse+_,-d,d),_=this.m_motorImpulse-f;var p=X.MulSV(_,this.m_axis,n.SolveVelocityConstraints_s_P),m=_*this.m_a1,g=_*this.m_a2;i.SelfMulSub(o,p),r-=u*m,s.SelfMulAdd(h,p),a+=l*g}var v=X.DotVV(this.m_perp,X.SubVV(s,i,X.s_t0))+this.m_s2*a-this.m_s1*r,y=a-r;if(this.m_enableLimit&&this.m_limitState!==t.b2LimitState.e_inactiveLimit){var S=X.DotVV(this.m_axis,X.SubVV(s,i,X.s_t0))+this.m_a2*a-this.m_a1*r,T=n.SolveVelocityConstraints_s_f1.Copy(this.m_impulse),A=this.m_K.Solve33(-v,-y,-S,n.SolveVelocityConstraints_s_df3);this.m_impulse.SelfAdd(A),this.m_limitState===t.b2LimitState.e_atLowerLimit?this.m_impulse.z=P(this.m_impulse.z,0):this.m_limitState===t.b2LimitState.e_atUpperLimit&&(this.m_impulse.z=M(this.m_impulse.z,0));var b=-v-(this.m_impulse.z-T.z)*this.m_K.ez.x,E=-y-(this.m_impulse.z-T.z)*this.m_K.ez.y,C=this.m_K.Solve22(b,E,n.SolveVelocityConstraints_s_f2r);C.x+=T.x,C.y+=T.y,this.m_impulse.x=C.x,this.m_impulse.y=C.y,A.x=this.m_impulse.x-T.x,A.y=this.m_impulse.y-T.y,A.z=this.m_impulse.z-T.z;var x=X.AddVV(X.MulSV(A.x,this.m_perp,X.s_t0),X.MulSV(A.z,this.m_axis,X.s_t1),n.SolveVelocityConstraints_s_P),w=A.x*this.m_s1+A.y+A.z*this.m_a1,R=A.x*this.m_s2+A.y+A.z*this.m_a2;i.SelfMulSub(o,x),r-=u*w,s.SelfMulAdd(h,x),a+=l*R}else{var I=this.m_K.Solve22(-v,-y,n.SolveVelocityConstraints_s_df2);this.m_impulse.x+=I.x,this.m_impulse.y+=I.y;var D=X.MulSV(I.x,this.m_perp,n.SolveVelocityConstraints_s_P),B=I.x*this.m_s1+I.y,L=I.x*this.m_s2+I.y;i.SelfMulSub(o,D),r-=u*B,s.SelfMulAdd(h,D),a+=l*L}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,_=this.m_invIA,f=this.m_invIB,p=Q.MulRV(a,this.m_lalcA,this.m_rA),m=Q.MulRV(o,this.m_lalcB,this.m_rB),g=X.SubVV(X.AddVV(r,m,X.s_t0),X.AddVV(e,p,X.s_t1),n.SolvePositionConstraints_s_d),v=Q.MulRV(a,this.m_localXAxisA,this.m_axis),y=X.CrossVV(X.AddVV(g,p,X.s_t0),v),S=X.CrossVV(m,v),T=Q.MulRV(a,this.m_localYAxisA,this.m_perp),A=X.CrossVV(X.AddVV(g,p,X.s_t0),T),b=X.CrossVV(m,T),E=n.SolvePositionConstraints_s_impulse,C=X.DotVV(T,g),x=s-i-this.m_referenceAngle,w=B(C),R=B(x),I=!1,D=0;if(this.m_enableLimit){var M=X.DotVV(v,g);B(this.m_upperTranslation-this.m_lowerTranslation)<.016?(D=O(M,-.2,d),w=P(w,B(M)),I=!0):M<=this.m_lowerTranslation?(D=O(M-this.m_lowerTranslation+l,-.2,0),w=P(w,this.m_lowerTranslation-M),I=!0):M>=this.m_upperTranslation&&(D=O(M-this.m_upperTranslation-l,0,d),w=P(w,M-this.m_upperTranslation),I=!0)}if(I){var L=h+u+_*A*A+f*b*b,N=_*A+f*b,F=_*A*y+f*b*S,k=_+f;0===k&&(k=1);var G=_*y+f*S,V=h+u+_*y*y+f*S*S,U=this.m_K3;U.ex.SetXYZ(L,N,F),U.ey.SetXYZ(N,k,G),U.ez.SetXYZ(F,G,V),E=U.Solve33(-C,-x,-D,E)}else{var z=h+u+_*A*A+f*b*b,H=_*A+f*b,W=_+f;0===W&&(W=1);var j=this.m_K2;j.ex.Set(z,H),j.ey.Set(H,W);var Y=j.Solve(-C,-x,n.SolvePositionConstraints_s_impulse1);E.x=Y.x,E.y=Y.y,E.z=0}var q=X.AddVV(X.MulSV(E.x,T,X.s_t0),X.MulSV(E.z,v,X.s_t1),n.SolvePositionConstraints_s_P),K=E.x*A+E.y+E.z*y,Z=E.x*b+E.y+E.z*S;return e.SelfMulSub(h,q),i-=_*K,r.SelfMulAdd(u,q),s+=f*Z,t.positions[this.m_indexA].a=i,t.positions[this.m_indexB].a=s,w<=l&&R<=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=X.SubVV(e,t,n.GetJointTranslation_s_d),r=this.m_bodyA.GetWorldVector(this.m_localXAxisA,n.GetJointTranslation_s_axis);return X.DotVV(i,r)},r.GetJointSpeed=function(){var t=this.m_bodyA,e=this.m_bodyB;X.SubVV(this.m_localAnchorA,t.m_sweep.localCenter,this.m_lalcA);var i=Q.MulRV(t.m_xf.q,this.m_lalcA,this.m_rA);X.SubVV(this.m_localAnchorB,e.m_sweep.localCenter,this.m_lalcB);var n=Q.MulRV(e.m_xf.q,this.m_lalcB,this.m_rB),r=X.AddVV(t.m_sweep.c,i,X.s_t0),s=X.AddVV(e.m_sweep.c,n,X.s_t1),a=X.SubVV(s,r,X.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 X.DotVV(a,X.CrossSV(l,o,X.s_t0))+X.DotVV(o,X.SubVV(X.AddVCrossSV(u,c,n,X.s_t0),X.AddVCrossSV(h,l,i,X.s_t1),X.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}(Mi);ji.InitVelocityConstraints_s_d=new X,ji.InitVelocityConstraints_s_P=new X,ji.SolveVelocityConstraints_s_P=new X,ji.SolveVelocityConstraints_s_f2r=new X,ji.SolveVelocityConstraints_s_f1=new Y,ji.SolveVelocityConstraints_s_df3=new Y,ji.SolveVelocityConstraints_s_df2=new X,ji.SolvePositionConstraints_s_d=new X,ji.SolvePositionConstraints_s_impulse=new Y,ji.SolvePositionConstraints_s_impulse1=new X,ji.SolvePositionConstraints_s_P=new X,ji.GetJointTranslation_s_pA=new X,ji.GetJointTranslation_s_pB=new X,ji.GetJointTranslation_s_d=new X,ji.GetJointTranslation_s_axis=new X;var Yi=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_pulleyJoint)||this).groundAnchorA=new X(-1,1),i.groundAnchorB=new X(1,1),i.localAnchorA=new X(-1,0),i.localAnchorB=new X(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=X.DistanceVV(r,i),this.lengthB=X.DistanceVV(s,n),this.ratio=a},i}(Bi),qi=function(t){function i(i){var n;return(n=t.call(this,i)||this).m_groundAnchorA=new X,n.m_groundAnchorB=new X,n.m_lengthA=0,n.m_lengthB=0,n.m_localAnchorA=new X,n.m_localAnchorB=new X,n.m_constant=0,n.m_ratio=0,n.m_impulse=0,n.m_indexA=0,n.m_indexB=0,n.m_uA=new X,n.m_uB=new X,n.m_rA=new X,n.m_rB=new X,n.m_localCenterA=new X,n.m_localCenterB=new X,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_mass=0,n.m_qA=new Q,n.m_qB=new Q,n.m_lalcA=new X,n.m_lalcB=new X,n.m_groundAnchorA.Copy(e(i.groundAnchorA,new X(-1,1))),n.m_groundAnchorB.Copy(e(i.groundAnchorB,new X(1,0))),n.m_localAnchorA.Copy(e(i.localAnchorA,new X(-1,0))),n.m_localAnchorB.Copy(e(i.localAnchorB,new X(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);X.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA),Q.MulRV(l,this.m_lalcA,this.m_rA),X.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),Q.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 _=this.m_uA.Length(),f=this.m_uB.Length();_>.08?this.m_uA.SelfMul(1/_):this.m_uA.SetZero(),f>.08?this.m_uB.SelfMul(1/f):this.m_uB.SetZero();var d=X.CrossVV(this.m_rA,this.m_uA),p=X.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 v=X.MulSV(-this.m_impulse,this.m_uA,i.InitVelocityConstraints_s_PA),y=X.MulSV(-this.m_ratio*this.m_impulse,this.m_uB,i.InitVelocityConstraints_s_PB);r.SelfMulAdd(this.m_invMassA,v),s+=this.m_invIA*X.CrossVV(this.m_rA,v),h.SelfMulAdd(this.m_invMassB,y),u+=this.m_invIB*X.CrossVV(this.m_rB,y)}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=X.AddVCrossSV(e,n,this.m_rA,i.SolveVelocityConstraints_s_vpA),o=X.AddVCrossSV(r,s,this.m_rB,i.SolveVelocityConstraints_s_vpB),h=-X.DotVV(this.m_uA,a)-this.m_ratio*X.DotVV(this.m_uB,o),u=-this.m_mass*h;this.m_impulse+=u;var l=X.MulSV(-u,this.m_uA,i.SolveVelocityConstraints_s_PA),c=X.MulSV(-this.m_ratio*u,this.m_uB,i.SolveVelocityConstraints_s_PB);e.SelfMulAdd(this.m_invMassA,l),n+=this.m_invIA*X.CrossVV(this.m_rA,l),r.SelfMulAdd(this.m_invMassB,c),s+=this.m_invIB*X.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);X.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var h=Q.MulRV(a,this.m_lalcA,this.m_rA);X.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var u=Q.MulRV(o,this.m_lalcB,this.m_rB),c=this.m_uA.Copy(e).SelfAdd(h).SelfSub(this.m_groundAnchorA),_=this.m_uB.Copy(r).SelfAdd(u).SelfSub(this.m_groundAnchorB),f=c.Length(),d=_.Length();f>.08?c.SelfMul(1/f):c.SetZero(),d>.08?_.SelfMul(1/d):_.SetZero();var p=X.CrossVV(h,c),m=X.CrossVV(u,_),g=this.m_invMassA+this.m_invIA*p*p,v=this.m_invMassB+this.m_invIB*m*m,y=g+this.m_ratio*this.m_ratio*v;y>0&&(y=1/y);var S=this.m_constant-f-this.m_ratio*d,T=B(S),A=-y*S,b=X.MulSV(-A,c,i.SolvePositionConstraints_s_PA),E=X.MulSV(-this.m_ratio*A,_,i.SolvePositionConstraints_s_PB);return e.SelfMulAdd(this.m_invMassA,b),n+=this.m_invIA*X.CrossVV(h,b),r.SelfMulAdd(this.m_invMassB,E),s+=this.m_invIB*X.CrossVV(u,E),t.positions[this.m_indexA].a=n,t.positions[this.m_indexB].a=s,T0&&(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;B(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 v=n.InitVelocityConstraints_s_P.Set(this.m_impulse.x,this.m_impulse.y);r.SelfMulSub(_,v),s-=d*(X.CrossVV(this.m_rA,v)+this.m_motorImpulse+this.m_impulse.z),o.SelfMulAdd(f,v),h+=p*(X.CrossVV(this.m_rB,v)+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 _=a-r-this.m_motorSpeed,f=-this.m_motorMass*_,d=this.m_motorImpulse,p=e.step.dt*this.m_maxMotorTorque;this.m_motorImpulse=O(this.m_motorImpulse+f,-p,p),r-=u*(f=this.m_motorImpulse-d),a+=l*f}if(this.m_enableLimit&&this.m_limitState!==t.b2LimitState.e_inactiveLimit&&!c){var m=X.SubVV(X.AddVCrossSV(s,a,this.m_rB,X.s_t0),X.AddVCrossSV(i,r,this.m_rA,X.s_t1),n.SolveVelocityConstraints_s_Cdot1),g=a-r,v=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(v);else if(this.m_limitState===t.b2LimitState.e_atLowerLimit)if(this.m_impulse.z+v.z<0){var y=-m.x+this.m_impulse.z*this.m_mass.ez.x,S=-m.y+this.m_impulse.z*this.m_mass.ez.y,T=this.m_mass.Solve22(y,S,n.SolveVelocityConstraints_s_reduced_v2);v.x=T.x,v.y=T.y,v.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(v);else if(this.m_limitState===t.b2LimitState.e_atUpperLimit)if(this.m_impulse.z+v.z>0){var A=-m.x+this.m_impulse.z*this.m_mass.ez.x,b=-m.y+this.m_impulse.z*this.m_mass.ez.y,E=this.m_mass.Solve22(A,b,n.SolveVelocityConstraints_s_reduced_v2);v.x=E.x,v.y=E.y,v.z=-this.m_impulse.z,this.m_impulse.x+=E.x,this.m_impulse.y+=E.y,this.m_impulse.z=0}else this.m_impulse.SelfAdd(v);var C=n.SolveVelocityConstraints_s_P.Set(v.x,v.y);i.SelfMulSub(o,C),r-=u*(X.CrossVV(this.m_rA,C)+v.z),s.SelfMulAdd(h,C),a+=l*(X.CrossVV(this.m_rB,C)+v.z)}else{var x=X.SubVV(X.AddVCrossSV(s,a,this.m_rB,X.s_t0),X.AddVCrossSV(i,r,this.m_rA,X.s_t1),n.SolveVelocityConstraints_s_Cdot_v2),w=this.m_mass.Solve22(-x.x,-x.y,n.SolveVelocityConstraints_s_impulse_v2);this.m_impulse.x+=w.x,this.m_impulse.y+=w.y,i.SelfMulSub(o,w),r-=u*X.CrossVV(this.m_rA,w),s.SelfMulAdd(h,w),a+=l*X.CrossVV(this.m_rB,w)}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),_=0,f=this.m_invIA+this.m_invIB===0;if(this.m_enableLimit&&this.m_limitState!==t.b2LimitState.e_inactiveLimit&&!f){var d=o-s-this.m_referenceAngle,m=0;if(this.m_limitState===t.b2LimitState.e_equalLimits){var g=O(d-this.m_lowerAngle,-.13962634015955555,p);m=-this.m_motorMass*g,_=B(g)}else if(this.m_limitState===t.b2LimitState.e_atLowerLimit){var v=d-this.m_lowerAngle;_=-v,v=O(v+c,-.13962634015955555,0),m=-this.m_motorMass*v}else if(this.m_limitState===t.b2LimitState.e_atUpperLimit){var y=d-this.m_upperAngle;_=y,y=O(y-c,0,p),m=-this.m_motorMass*y}s-=this.m_invIA*m,o+=this.m_invIB*m}h.SetAngle(s),u.SetAngle(o),X.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var S=Q.MulRV(h,this.m_lalcA,this.m_rA);X.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var T=Q.MulRV(u,this.m_lalcB,this.m_rB),A=X.SubVV(X.AddVV(a,T,X.s_t0),X.AddVV(r,S,X.s_t1),n.SolvePositionConstraints_s_C_v2);i=A.Length();var b=this.m_invMassA,E=this.m_invMassB,C=this.m_invIA,x=this.m_invIB,w=this.m_K;w.ex.x=b+E+C*S.y*S.y+x*T.y*T.y,w.ex.y=-C*S.x*S.y-x*T.x*T.y,w.ey.x=w.ex.y,w.ey.y=b+E+C*S.x*S.x+x*T.x*T.x;var R=w.Solve(A.x,A.y,n.SolvePositionConstraints_s_impulse).SelfNeg();return r.SelfMulSub(b,R),s-=C*X.CrossVV(S,R),a.SelfMulAdd(E,R),o+=x*X.CrossVV(T,R),e.positions[this.m_indexA].a=s,e.positions[this.m_indexB].a=o,i<=l&&_<=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}(Mi);Qi.InitVelocityConstraints_s_P=new X,Qi.SolveVelocityConstraints_s_P=new X,Qi.SolveVelocityConstraints_s_Cdot_v2=new X,Qi.SolveVelocityConstraints_s_Cdot1=new X,Qi.SolveVelocityConstraints_s_impulse_v3=new Y,Qi.SolveVelocityConstraints_s_reduced_v2=new X,Qi.SolveVelocityConstraints_s_impulse_v2=new X,Qi.SolvePositionConstraints_s_C_v2=new X,Qi.SolvePositionConstraints_s_impulse=new X;var Zi=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_ropeJoint)||this).localAnchorA=new X(-1,0),i.localAnchorB=new X(1,0),i.maxLength=0,i}return s(i,e),i}(Bi),Ji=function(i){function n(n){var r;return(r=i.call(this,n)||this).m_localAnchorA=new X,r.m_localAnchorB=new X,r.m_maxLength=0,r.m_length=0,r.m_impulse=0,r.m_indexA=0,r.m_indexB=0,r.m_u=new X,r.m_rA=new X,r.m_rB=new X,r.m_localCenterA=new X,r.m_localCenterB=new X,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 Q,r.m_qB=new Q,r.m_lalcA=new X,r.m_lalcB=new X,r.m_localAnchorA.Copy(e(n.localAnchorA,new X(-1,0))),r.m_localAnchorB.Copy(e(n.localAnchorB,new X(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,_=this.m_qA.SetAngle(r),f=this.m_qB.SetAngle(h);X.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA),Q.MulRV(_,this.m_lalcA,this.m_rA),X.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),Q.MulRV(f,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=X.CrossVV(this.m_rA,this.m_u),m=X.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 v=X.MulSV(this.m_impulse,this.m_u,n.InitVelocityConstraints_s_P);s.SelfMulSub(this.m_invMassA,v),a-=this.m_invIA*X.CrossVV(this.m_rA,v),u.SelfMulAdd(this.m_invMassB,v),c+=this.m_invIB*X.CrossVV(this.m_rB,v)}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=X.AddVCrossSV(e,i,this.m_rA,n.SolveVelocityConstraints_s_vpA),o=X.AddVCrossSV(r,s,this.m_rB,n.SolveVelocityConstraints_s_vpB),h=this.m_length-this.m_maxLength,u=X.DotVV(this.m_u,X.SubVV(o,a,X.s_t0));h<0&&(u+=t.step.inv_dt*h);var l=-this.m_mass*u,c=this.m_impulse;this.m_impulse=M(0,this.m_impulse+l),l=this.m_impulse-c;var _=X.MulSV(l,this.m_u,n.SolveVelocityConstraints_s_P);e.SelfMulSub(this.m_invMassA,_),i-=this.m_invIA*X.CrossVV(this.m_rA,_),r.SelfMulAdd(this.m_invMassB,_),s+=this.m_invIB*X.CrossVV(this.m_rB,_),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);X.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var h=Q.MulRV(a,this.m_lalcA,this.m_rA);X.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var u=Q.MulRV(o,this.m_lalcB,this.m_rB),c=this.m_u.Copy(r).SelfAdd(u).SelfSub(e).SelfSub(h),_=c.Normalize(),f=_-this.m_maxLength;f=O(f,0,d);var p=-this.m_mass*f,m=X.MulSV(p,c,n.SolvePositionConstraints_s_P);return e.SelfMulSub(this.m_invMassA,m),i-=this.m_invIA*X.CrossVV(h,m),r.SelfMulAdd(this.m_invMassB,m),s+=this.m_invIB*X.CrossVV(u,m),t.positions[this.m_indexA].a=i,t.positions[this.m_indexB].a=s,_-this.m_maxLength0){p.GetInverse22(this.m_mass);var m=f+d,g=m>0?1/m:0,v=s-e-this.m_referenceAngle,y=2*o*this.m_frequencyHz,S=2*g*this.m_dampingRatio*y,T=g*y*y,A=t.step.dt;this.m_gamma=A*(S+A*T),this.m_gamma=0!==this.m_gamma?1/this.m_gamma:0,this.m_bias=v*A*T*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 b=i.InitVelocityConstraints_s_P.Set(this.m_impulse.x,this.m_impulse.y);n.SelfMulSub(c,b),r-=f*(X.CrossVV(this.m_rA,b)+this.m_impulse.z),a.SelfMulAdd(_,b),h+=d*(X.CrossVV(this.m_rB,b)+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 _=X.SubVV(X.AddVCrossSV(r,s,this.m_rB,X.s_t0),X.AddVCrossSV(e,n,this.m_rA,X.s_t1),i.SolveVelocityConstraints_s_Cdot1),f=K.MulM33XY(this.m_mass,_.x,_.y,i.SolveVelocityConstraints_s_impulse1).SelfNeg();this.m_impulse.x+=f.x,this.m_impulse.y+=f.y;var d=f;e.SelfMulSub(a,d),n-=h*X.CrossVV(this.m_rA,d),r.SelfMulAdd(o,d),s+=u*X.CrossVV(this.m_rB,d)}else{var p=X.SubVV(X.AddVCrossSV(r,s,this.m_rB,X.s_t0),X.AddVCrossSV(e,n,this.m_rA,X.s_t1),i.SolveVelocityConstraints_s_Cdot1),m=s-n,g=K.MulM33XYZ(this.m_mass,p.x,p.y,m,i.SolveVelocityConstraints_s_impulse).SelfNeg();this.m_impulse.SelfAdd(g);var v=i.SolveVelocityConstraints_s_P.Set(g.x,g.y);e.SelfMulSub(a,v),n-=h*(X.CrossVV(this.m_rA,v)+g.z),r.SelfMulAdd(o,v),s+=u*(X.CrossVV(this.m_rB,v)+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,_=this.m_invIA,f=this.m_invIB;X.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var d=Q.MulRV(a,this.m_lalcA,this.m_rA);X.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var p,m,g=Q.MulRV(o,this.m_lalcB,this.m_rB),v=this.m_K;if(v.ex.x=h+u+d.y*d.y*_+g.y*g.y*f,v.ey.x=-d.y*d.x*_-g.y*g.x*f,v.ez.x=-d.y*_-g.y*f,v.ex.y=v.ey.x,v.ey.y=h+u+d.x*d.x*_+g.x*g.x*f,v.ez.y=d.x*_+g.x*f,v.ex.z=v.ez.x,v.ey.z=v.ez.y,v.ez.z=_+f,this.m_frequencyHz>0){var y=X.SubVV(X.AddVV(r,g,X.s_t0),X.AddVV(e,d,X.s_t1),i.SolvePositionConstraints_s_C1);p=y.Length(),m=0;var S=v.Solve22(y.x,y.y,i.SolvePositionConstraints_s_P).SelfNeg();e.SelfMulSub(h,S),n-=_*X.CrossVV(d,S),r.SelfMulAdd(u,S),s+=f*X.CrossVV(g,S)}else{var T=X.SubVV(X.AddVV(r,g,X.s_t0),X.AddVV(e,d,X.s_t1),i.SolvePositionConstraints_s_C1),A=s-n-this.m_referenceAngle;p=T.Length(),m=B(A);var b=v.Solve33(T.x,T.y,A,i.SolvePositionConstraints_s_impulse).SelfNeg(),E=i.SolvePositionConstraints_s_P.Set(b.x,b.y);e.SelfMulSub(h,E),n-=_*(X.CrossVV(this.m_rA,E)+b.z),r.SelfMulAdd(u,E),s+=f*(X.CrossVV(this.m_rB,E)+b.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}(Mi);tn.InitVelocityConstraints_s_P=new X,tn.SolveVelocityConstraints_s_Cdot1=new X,tn.SolveVelocityConstraints_s_impulse1=new X,tn.SolveVelocityConstraints_s_impulse=new Y,tn.SolveVelocityConstraints_s_P=new X,tn.SolvePositionConstraints_s_C1=new X,tn.SolvePositionConstraints_s_P=new X,tn.SolvePositionConstraints_s_impulse=new Y;var en=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_wheelJoint)||this).localAnchorA=new X(0,0),i.localAnchorB=new X(0,0),i.localAxisA=new X(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}(Bi),nn=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 X,n.m_localAnchorB=new X,n.m_localXAxisA=new X,n.m_localYAxisA=new X,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 X,n.m_localCenterB=new X,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_ax=new X,n.m_ay=new X,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 Q,n.m_qB=new Q,n.m_lalcA=new X,n.m_lalcB=new X,n.m_rA=new X,n.m_rB=new X,n.m_frequencyHz=e(i.frequencyHz,2),n.m_dampingRatio=e(i.dampingRatio,.7),n.m_localAnchorA.Copy(e(i.localAnchorA,X.ZERO)),n.m_localAnchorB.Copy(e(i.localAnchorB,X.ZERO)),n.m_localXAxisA.Copy(e(i.localAxisA,X.UNITX)),X.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,_=t.positions[this.m_indexB].a,f=t.velocities[this.m_indexB].v,d=t.velocities[this.m_indexB].w,p=this.m_qA.SetAngle(h),m=this.m_qB.SetAngle(_);X.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var g=Q.MulRV(p,this.m_lalcA,this.m_rA);X.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var v=Q.MulRV(m,this.m_lalcB,this.m_rB),y=X.SubVV(X.AddVV(c,v,X.s_t0),X.AddVV(a,g,X.s_t1),i.InitVelocityConstraints_s_d);if(Q.MulRV(p,this.m_localYAxisA,this.m_ay),this.m_sAy=X.CrossVV(X.AddVV(y,g,X.s_t0),this.m_ay),this.m_sBy=X.CrossVV(v,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){Q.MulRV(p,this.m_localXAxisA,this.m_ax),this.m_sAx=X.CrossVV(X.AddVV(y,g,X.s_t0),this.m_ax),this.m_sBx=X.CrossVV(v,this.m_ax);var S=e+n+r*this.m_sAx*this.m_sAx+s*this.m_sBx*this.m_sBx;if(S>0){this.m_springMass=1/S;var T=X.DotVV(y,this.m_ax),A=2*o*this.m_frequencyHz,b=2*this.m_springMass*this.m_dampingRatio*A,E=this.m_springMass*A*A,C=t.step.dt;this.m_gamma=C*(b+C*E),this.m_gamma>0&&(this.m_gamma=1/this.m_gamma),this.m_bias=T*C*E*this.m_gamma,this.m_springMass=S+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 x=X.AddVV(X.MulSV(this.m_impulse,this.m_ay,X.s_t0),X.MulSV(this.m_springImpulse,this.m_ax,X.s_t1),i.InitVelocityConstraints_s_P),w=this.m_impulse*this.m_sAy+this.m_springImpulse*this.m_sAx+this.m_motorImpulse,R=this.m_impulse*this.m_sBy+this.m_springImpulse*this.m_sBx+this.m_motorImpulse;u.SelfMulSub(this.m_invMassA,x),l-=this.m_invIA*w,f.SelfMulAdd(this.m_invMassB,x),d+=this.m_invIB*R}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=X.DotVV(this.m_ax,X.SubVV(h,a,X.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 _=X.MulSV(c,this.m_ax,i.SolveVelocityConstraints_s_P),f=c*this.m_sAx,d=c*this.m_sBx;a.SelfMulSub(e,_),o-=r*f,h.SelfMulAdd(n,_);var p=(u+=s*d)-o-this.m_motorSpeed,m=-this.m_motorMass*p,g=this.m_motorImpulse,v=t.step.dt*this.m_maxMotorTorque;this.m_motorImpulse=O(this.m_motorImpulse+m,-v,v),o-=r*(m=this.m_motorImpulse-g),u+=s*m;var y=X.DotVV(this.m_ay,X.SubVV(h,a,X.s_t0))+this.m_sBy*u-this.m_sAy*o,S=-this.m_mass*y;this.m_impulse+=S;var T=X.MulSV(S,this.m_ay,i.SolveVelocityConstraints_s_P),A=S*this.m_sAy,b=S*this.m_sBy;a.SelfMulSub(e,T),o-=r*A,h.SelfMulAdd(n,T),u+=s*b,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);X.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var h=Q.MulRV(a,this.m_lalcA,this.m_rA);X.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var u,c=Q.MulRV(o,this.m_lalcB,this.m_rB),_=X.AddVV(X.SubVV(r,e,X.s_t0),X.SubVV(c,h,X.s_t1),i.SolvePositionConstraints_s_d),f=Q.MulRV(a,this.m_localYAxisA,this.m_ay),d=X.CrossVV(X.AddVV(_,h,X.s_t0),f),p=X.CrossVV(c,f),m=X.DotVV(_,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 v=X.MulSV(u,f,i.SolvePositionConstraints_s_P),y=u*d,S=u*p;return e.SelfMulSub(this.m_invMassA,v),n-=this.m_invIA*y,r.SelfMulAdd(this.m_invMassB,v),s+=this.m_invIB*S,t.positions[this.m_indexA].a=n,t.positions[this.m_indexB].a=s,B(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 X),n=e.GetWorldPoint(this.m_localAnchorB,new X),r=X.SubVV(n,i,new X),s=t.GetWorldVector(this.m_localXAxisA,new X);return X.DotVV(r,s)},n.GetPrismaticJointSpeed=function(){var t=this.m_bodyA,e=this.m_bodyB;X.SubVV(this.m_localAnchorA,t.m_sweep.localCenter,this.m_lalcA);var i=Q.MulRV(t.m_xf.q,this.m_lalcA,this.m_rA);X.SubVV(this.m_localAnchorB,e.m_sweep.localCenter,this.m_lalcB);var n=Q.MulRV(e.m_xf.q,this.m_lalcB,this.m_rB),r=X.AddVV(t.m_sweep.c,i,X.s_t0),s=X.AddVV(e.m_sweep.c,n,X.s_t1),a=X.SubVV(s,r,X.s_t2),o=t.GetWorldVector(this.m_localXAxisA,new X),h=t.m_linearVelocity,u=e.m_linearVelocity,l=t.m_angularVelocity,c=e.m_angularVelocity;return X.DotVV(a,X.CrossSV(l,o,X.s_t0))+X.DotVV(o,X.SubVV(X.AddVCrossSV(u,c,n,X.s_t0),X.AddVCrossSV(h,l,i,X.s_t1),X.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}(Mi);function rn(t,e){return k(t*e)}function sn(t,e){return t>e?t:e}nn.InitVelocityConstraints_s_d=new X,nn.InitVelocityConstraints_s_P=new X,nn.SolveVelocityConstraints_s_P=new X,nn.SolvePositionConstraints_s_d=new X,nn.SolvePositionConstraints_s_P=new X;var an=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}(),on=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 an(this),this.m_nodeB=new an(this),this.m_indexA=0,this.m_indexB=0,this.m_manifold=new Ot,this.m_toiCount=0,this.m_toi=0,this.m_friction=0,this.m_restitution=0,this.m_tangentSpeed=0,this.m_oldManifold=new Ot}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=rn(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=sn(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=rn(this.m_fixtureA.m_friction,this.m_fixtureB.m_friction),this.m_restitution=sn(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(),_=this.GetShapeB();i=Xt(c,this.m_indexA,_,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 f=0;f0:0!=(s.maskBits&a.categoryBits)&&0!=(s.categoryBits&a.maskBits)},i.ShouldCollideFixtureParticle=function(){return!0},i.ShouldCollideParticleParticle=function(){return!0},e}();vn.b2_defaultFilter=new vn;var yn=function(){this.normalImpulses=w(2),this.tangentImpulses=w(2),this.count=0},Sn=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}();Sn.b2_defaultListener=new Sn;var Tn=function(){function t(){}var e=t.prototype;return e.ReportFixture=function(){return!0},e.ReportParticle=function(){return!1},e.ShouldQueryParticleSystem=function(){return!0},t}(),An=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}(),bn=function(){function e(){this.m_broadPhase=new Jt,this.m_contactList=null,this.m_contactCount=0,this.m_contactFilter=vn.b2_defaultFilter,this.m_contactListener=Sn.b2_defaultListener,this.m_contactFactory=new mn}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(),_=h.contact.GetChildIndexB();if(u===i&&l===n&&c===r&&_===s)return;if(u===n&&l===i&&c===s&&_===r)return}h=h.next}if(!this.m_contactFilter||this.m_contactFilter.ShouldCollide(i,n)){var f=this.m_contactFactory.Create(i,r,n,s);null!==f&&(i=f.GetFixtureA(),n=f.GetFixtureB(),r=f.GetChildIndexA(),s=f.GetChildIndexB(),a=i.m_body,o=n.m_body,f.m_prev=null,f.m_next=this.m_contactList,null!==this.m_contactList&&(this.m_contactList.m_prev=f),this.m_contactList=f,f.m_nodeA.other=o,f.m_nodeA.prev=null,f.m_nodeA.next=a.m_contactList,null!==a.m_contactList&&(a.m_contactList.prev=f.m_nodeA),a.m_contactList=f.m_nodeA,f.m_nodeB.other=a,f.m_nodeB.prev=null,f.m_nodeB.next=o.m_contactList,null!==o.m_contactList&&(o.m_contactList.prev=f.m_nodeB),o.m_contactList=f.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,_=n.m_proxies[s].treeNode;if(Vt(c.aabb,_.aabb))e.Update(this.m_contactListener),e=e.m_next;else{var f=e;e=f.m_next,this.Destroy(f)}}else e=e.m_next}},e}(),En=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}(),Cn=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}(),xn=function(){function t(){this.c=new X,this.a=0}return t.MakeArray=function(e){return x(e,(function(){return new t}))},t}(),wn=function(){function t(){this.v=new X,this.w=0}return t.MakeArray=function(e){return x(e,(function(){return new t}))},t}(),Rn=function(){this.step=new Cn},In=!1,Dn=function(){function t(){this.rA=new X,this.rB=new X,this.normalImpulse=0,this.tangentImpulse=0,this.normalMass=0,this.tangentMass=0,this.velocityBias=0}return t.MakeArray=function(e){return x(e,(function(){return new t}))},t}(),Bn=function(){function t(){this.points=Dn.MakeArray(2),this.normal=new X,this.tangent=new X,this.normalMass=new q,this.K=new q,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 x(e,(function(){return new t}))},t}(),Mn=function(){function e(){this.localPoints=X.MakeArray(2),this.localNormal=new X,this.localPoint=new X,this.indexA=0,this.indexB=0,this.invMassA=0,this.invMassB=0,this.localCenterA=new X,this.localCenterB=new X,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 x(t,(function(){return new e}))},e}(),Pn=function(){this.step=new Cn,this.count=0},On=function(){function e(){this.normal=new X,this.point=new X,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:Z.MulXV(n,i.localPoint,a),Z.MulXV(r,i.localPoints[0],o),X.SubVV(o,a,this.normal).SelfNormalize(),X.MidVV(a,o,this.point),this.separation=X.DotVV(X.SubVV(o,a,X.s_t0),this.normal)-i.radiusA-i.radiusB;break;case t.b2ManifoldType.e_faceA:Q.MulRV(n.q,i.localNormal,this.normal),Z.MulXV(n,i.localPoint,h),Z.MulXV(r,i.localPoints[s],u),this.separation=X.DotVV(X.SubVV(u,h,X.s_t0),this.normal)-i.radiusA-i.radiusB,this.point.Copy(u);break;case t.b2ManifoldType.e_faceB:Q.MulRV(r.q,i.localNormal,this.normal),Z.MulXV(r,i.localPoint,h),Z.MulXV(n,i.localPoints[s],u),this.separation=X.DotVV(X.SubVV(u,h,X.s_t0),this.normal)-i.radiusA-i.radiusB,this.point.Copy(u),this.normal.SelfNeg()}},e}();On.Initialize_s_pointA=new X,On.Initialize_s_pointB=new X,On.Initialize_s_planePoint=new X,On.Initialize_s_clipPoint=new X;var Ln=function(){function t(){this.m_step=new Cn,this.m_positionConstraints=Mn.MakeArray(1024),this.m_velocityConstraints=Bn.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/B:0;var M=s.tangent,P=X.CrossVV(R.rA,M),O=X.CrossVV(R.rB,M),L=_+f+d*P*P+p*O*O;R.tangentMass=L>0?1/L:0,R.velocityBias=0;var N=X.DotVV(s.normal,X.SubVV(X.AddVCrossSV(E,C,R.rB,X.s_t0),X.AddVCrossSV(S,T,R.rA,X.s_t1),X.s_t0));N<-1&&(R.velocityBias+=-s.restitution*N)}s.pointCount}},e.WarmStart=function(){for(var e=t.WarmStart_s_P,i=0;i0?-R/B:0;X.MulSV(P,C,a),S.SelfMulSub(d,a),T-=p*X.CrossVV(r,a),A.SelfMulAdd(g,a),b+=v*X.CrossVV(s,a)}this.m_positions[c].a=T,this.m_positions[_].a=b}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?-D/L:0;X.MulSV(N,w,h),A.SelfMulSub(v,h),b-=y*X.CrossVV(a,h),E.SelfMulAdd(S,h),C+=T*X.CrossVV(o,h)}this.m_positions[f].a=b,this.m_positions[d].a=C}return u>=-.012},t}();Ln.InitializeVelocityConstraints_s_xfA=new Z,Ln.InitializeVelocityConstraints_s_xfB=new Z,Ln.InitializeVelocityConstraints_s_worldManifold=new Lt,Ln.WarmStart_s_P=new X,Ln.SolveVelocityConstraints_s_dv=new X,Ln.SolveVelocityConstraints_s_dv1=new X,Ln.SolveVelocityConstraints_s_dv2=new X,Ln.SolveVelocityConstraints_s_P=new X,Ln.SolveVelocityConstraints_s_a=new X,Ln.SolveVelocityConstraints_s_b=new X,Ln.SolveVelocityConstraints_s_x=new X,Ln.SolveVelocityConstraints_s_d=new X,Ln.SolveVelocityConstraints_s_P1=new X,Ln.SolveVelocityConstraints_s_P2=new X,Ln.SolveVelocityConstraints_s_P1P2=new X,Ln.SolvePositionConstraints_s_xfA=new Z,Ln.SolvePositionConstraints_s_xfB=new Z,Ln.SolvePositionConstraints_s_psm=new On,Ln.SolvePositionConstraints_s_rA=new X,Ln.SolvePositionConstraints_s_rB=new X,Ln.SolvePositionConstraints_s_P=new X,Ln.SolveTOIPositionConstraints_s_xfA=new Z,Ln.SolveTOIPositionConstraints_s_xfB=new Z,Ln.SolveTOIPositionConstraints_s_psm=new On,Ln.SolveTOIPositionConstraints_s_rA=new X,Ln.SolveTOIPositionConstraints_s_rB=new X,Ln.SolveTOIPositionConstraints_s_P=new X;var Nn,Fn=function(){function e(){this.m_bodies=[],this.m_contacts=[],this.m_joints=[],this.m_positions=xn.MakeArray(1024),this.m_velocities=wn.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 R=2/w.Length();C.SelfMul(R)}var I=h*x;I*I>g&&(x*=m/B(I)),b.x+=h*C.x,b.y+=h*C.y,E+=h*x,this.m_positions[A].a=E,this.m_velocities[A].w=x}o.Reset();for(var D=!1,P=0;P.0012184696791469947||X.DotVV(z.m_linearVelocity,z.m_linearVelocity)>1e-4?(z.m_sleepTime=0,V=0):(z.m_sleepTime+=h,V=M(V,z.m_sleepTime)))}if(V>=.5&&D)for(var H=0;H4){var y=2/v.Length();d.SelfMul(y)}var S=l*p;S*S>g&&(p*=m/B(S)),_.SelfMulAdd(l,d),f+=l*p,this.m_positions[c].a=f,this.m_velocities[c].w=p;var T=this.m_bodies[c];T.m_sweep.c.Copy(_),T.m_sweep.a=f,T.m_linearVelocity.Copy(d),T.m_angularVelocity=p,T.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}();Hn.GetLinearVelocityFromWorldPoint_s_t0=new X;var Wn=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&&_0&&u.Push(new Yn(p-1,m,g-1,v)),m>0&&u.Push(new Yn(p,m-1,g-this.m_countX,v)),pk*k+G*G&&(this.m_diagram[M]=L,D>0&&u.Push(new Yn(D-1,B,M-1,L)),B>0&&u.Push(new Yn(D,B-1,M-this.m_countX,L)),D=i)break;qn(t,h,i)}}if(0===a)break;r=i,i=s[--a]}return t}function Zn(t,e,i,n){return void 0===e&&(e=0),void 0===i&&(i=t.length-e),void 0===n&&(n=Kn),Qn(t,e,i,n)}function Jn(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 tr(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 er(t,e,i,n){for(var r=i;e!==r;)qn(t,e++,r++),r===n?r=i:e===i&&(i=r)}var ir=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}(Tn),rr=function(){function t(){this.indexA=0,this.indexB=0,this.weight=0,this.normal=new X,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&&B(this.weight-t.weight)<.01&&X.DistanceSquaredVV(this.normal,t.normal)<1e-4},t}(),sr=function(){this.index=0,this.weight=0,this.normal=new X,this.mass=0},ar=function(){this.indexA=0,this.indexB=0,this.flags=0,this.strength=0,this.distance=0},or=function(){this.indexA=0,this.indexB=0,this.indexC=0,this.flags=0,this.strength=0,this.pa=new X(0,0),this.pb=new X(0,0),this.pc=new X(0,0),this.ka=0,this.kb=0,this.kc=0,this.s=0},hr=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}(),ur=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 lr,this.m_flagsBuffer=new lr,this.m_positionBuffer=new lr,this.m_velocityBuffer=new lr,this.m_forceBuffer=[],this.m_weightBuffer=[],this.m_staticPressureBuffer=[],this.m_accumulationBuffer=[],this.m_accumulation2Buffer=[],this.m_depthBuffer=[],this.m_colorBuffer=new lr,this.m_groupBuffer=[],this.m_userDataBuffer=new lr,this.m_stuckThreshold=0,this.m_lastBodyContactStepBuffer=new lr,this.m_bodyContactCountBuffer=new lr,this.m_consecutiveContactStepsBuffer=new lr,this.m_stuckParticleBuffer=new ir((function(){return 0})),this.m_proxyBuffer=new ir((function(){return new cr})),this.m_contactBuffer=new ir((function(){return new rr})),this.m_bodyContactBuffer=new ir((function(){return new sr})),this.m_pairBuffer=new ir((function(){return new ar})),this.m_triadBuffer=new ir((function(){return new or})),this.m_expirationTimeBuffer=new lr,this.m_indexByExpirationTimeBuffer=new lr,this.m_timeElapsed=0,this.m_expirationTimeBufferRequiresSorting=!1,this.m_groupCount=0,this.m_groupList=null,this.m_def=new hr,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:T;this.ReallocateInternalAllocatedBuffers(i)}if(this.m_count>=this.m_internalAllocatedCapacity){if(!this.m_def.destroyByAge)return v;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 X).Copy(e(t.position,X.ZERO)),this.m_velocityBuffer.data[n]=(this.m_velocityBuffer.data[n]||new X).Copy(e(t.velocity,X.ZERO)),this.m_weightBuffer[n]=0,this.m_forceBuffer[n]=(this.m_forceBuffer[n]||new X).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 vr(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,X.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 X).Copy(i).SelfMul(1/r),a=t;a=0;){var m=X.SubVV(e,u[c],s),g=X.DotVV(m,f),v=g*g-d*(X.DotVV(m,m)-this.m_squaredDiameter);if(v>=0){var y=k(v),S=(-g-y)/d;if(S>_)continue;if(S<0&&((S=(-g+y)/d)<0||S>_))continue;var T=X.AddVMulSV(m,S,f,o);if(T.Normalize(),(_=M(_,t.ReportParticle(this,c,X.AddVMulSV(e,S,f,h),T,S)))<=0)break}}}},r.ComputeAABB=function(t){var e=this.GetParticleCount();t.lowerBound.x=+i,t.lowerBound.y=+i,t.upperBound.x=-i,t.upperBound.y=-i;for(var n=this.m_positionBuffer.data,r=0;re?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 kn;r.flags=e(t.flags,0),Z.MulXV(i,n,r.position),X.AddVV(e(t.linearVelocity,X.ZERO),X.CrossSV(e(t.angularVelocity,0),X.SubVV(r.position,e(t.position,X.ZERO),X.s_t0),X.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(),_=0;_=e&&f=e&&dv||X.DotVV(m,m)>v||X.DotVV(g,g)>v)return;var y=C.m_groupBuffer[t],S=C.m_groupBuffer[e],T=C.m_groupBuffer[i],A=C.m_triadBuffer.data[C.m_triadBuffer.Append()];A.indexA=t,A.indexB=e,A.indexC=i,A.flags=u|l|c,A.strength=M(M(y?y.m_strength:1,S?S.m_strength:1),T?T.m_strength:1);var b=(_.x+f.x+d.x)/3,E=(_.y+f.y+d.y)/3;A.pa.x=_.x-b,A.pa.y=_.y-E,A.pb.x=f.x-b,A.pb.y=f.y-E,A.pc.x=d.x-b,A.pc.y=d.y-E,A.ka=-X.DotVV(g,p),A.kb=-X.DotVV(p,m),A.kc=-X.DotVV(m,g),A.s=X.CrossVV(_,f)+X.CrossVV(f,d)+X.CrossVV(d,_)}})),Zn(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;i>0,E=0;EP&&(this.m_depthBuffer[R]=P,C=!0),M>O&&(this.m_depthBuffer[I]=O,C=!0)}if(!C)break}for(var L=0;L0)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(k(i/s))}},r.SolveGravity=function(t){for(var e=n.SolveGravity_s_gravity,i=this.m_velocityBuffer.data,r=X.MulSV(t.dt*this.m_def.gravityScale,this.m_world.GetGravity(),e),s=0;s=0;){var L=p[O],N=this.m_groupBuffer[O];if(w!==N&&R!==N){var F=this.GetLinearVelocity(N,O,L,h),G=X.SubVV(L,E,u),V=X.SubVV(F,I,l),U=X.CrossVV(M,V),z=X.CrossVV(B,V)-X.CrossVV(G,M),H=X.CrossVV(B,G),W=void 0,j=void 0,Y=c,q=_;if(0===U){if(0===z)continue;if(!((j=-H/z)>=0&&j=0&&W<=1))continue}else{var K=z*z-4*H*U;if(K<0)continue;var Q=k(K),Z=(-z-Q)/(2*U),J=(-z+Q)/(2*U);if(Z>J){var $=Z;Z=J,J=$}if(j=Z,X.AddVMulSV(B,j,M,Y),X.AddVMulSV(G,j,V,q),W=X.DotVV(Y,q)/X.DotVV(Y,Y),!(j>=0&&j=0&&W<=1)){if(!((j=J)>=0&&j=0&&W<=1))continue}}var tt=f;tt.x=I.x+W*M.x-F.x,tt.y=I.y+W*M.y-F.y;var et=X.MulSV(y,tt,d);if(N&&this.IsRigidGroup(N)){var it=N.GetMass(),nt=N.GetInertia();it>0&&N.m_linearVelocity.SelfMulAdd(1/it,et),nt>0&&(N.m_angularVelocity+=X.CrossVV(X.SubVV(L,N.GetCenter(),X.s_t0),et)/nt)}else m[O].SelfAdd(tt);this.ParticleApplyForce(O,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=S*i,s=this.m_def.staticPressureRelaxation,a=0;ao){var f=l.body,d=l.mass,p=r[c],m=l.normal,g=X.MulSV(a*d*(_-o),m,i);s[c].SelfMulSub(h,g),f.ApplyLinearImpulse(g,p,!0)}}}for(var v=0;vo){var T=y.indexA,A=y.indexB,b=y.normal,E=X.MulSV(a*(S-o),b,i);s[T].SelfSub(E),s[A].SelfAdd(E)}}}},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?(x=M(x,D),w=P(w,D+1)):R=!0}xr: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=X.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]=X.CrossVV(X.SubVV(a,s,X.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}();ur.xTruncBits=12,ur.yTruncBits=12,ur.tagBits=32,ur.yOffset=1<>>0,this.m_xUpper=(i&ur.xMask)>>>0,this.m_yLower=(e&ur.yMask)>>>0,this.m_yUpper=(i&ur.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 v},t}(),fr=function(){this.next=null,this.count=0,this.index=0},dr=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}(),pr=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 v},e}(dr),mr=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 v},e}(dr),gr=function(){function t(){}var e=t.prototype;return e.IsNecessary=function(){return!0},e.ShouldCreatePair=function(){return!0},e.ShouldCreateTriad=function(){return!0},t}(),vr=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}(Tn),yr=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/_:0,p=f>0?1/f:0,m=this.m_system.m_flagsBuffer.data[r]&t.b2ParticleFlag.b2_wallParticle?0:this.m_system.GetParticleInvMass(),g=X.SubVV(o,c,a),v=X.CrossVV(g,h),y=m+d+p*v*v,S=this.m_system.m_bodyContactBuffer.data[this.m_system.m_bodyContactBuffer.Append()];S.index=r,S.body=l,S.fixture=e,S.weight=1-u*this.m_system.m_inverseDiameter,S.normal.Copy(h.SelfNeg()),S.mass=y>0?1/y:0,this.m_system.DetectStuckParticle(r)}},i}(nr);Ar.ReportFixtureAndParticle_s_n=new X,Ar.ReportFixtureAndParticle_s_rp=new X;var br=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,_=e.GetBody(),f=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=Z.MulTXV(_.m_xf0,f,s);e.GetShape().GetType()===t.b2ShapeType.e_circleShape&&(g.SelfSub(_.GetLocalCenter()),Q.MulRV(_.m_xf0.q,g,g),Q.MulTRV(_.m_xf.q,g,g),g.SelfAdd(_.GetLocalCenter())),Z.MulXV(_.m_xf,g,m.p1)}else m.p1.Copy(f);if(X.AddVMulSV(f,this.m_step.dt,d,m.p2),m.maxFraction=1,e.RayCast(p,m,n)){var v=p.normal,y=h;y.x=(1-p.fraction)*m.p1.x+p.fraction*m.p2.x+l*v.x,y.y=(1-p.fraction)*m.p1.y+p.fraction*m.p2.y+l*v.y;var S=u;S.x=this.m_step.inv_dt*(y.x-f.x),S.y=this.m_step.inv_dt*(y.y-f.y),this.m_system.m_velocityBuffer.data[r].Copy(S);var T=c;T.x=this.m_step.inv_dt*this.m_system.GetParticleMass()*(d.x-S.x),T.y=this.m_step.inv_dt*this.m_system.GetParticleMass()*(d.y-S.y),this.m_system.ParticleApplyForce(r,T)}},n.ReportParticle=function(){return!1},i}(nr);br.ReportFixtureAndParticle_s_p1=new X,br.ReportFixtureAndParticle_s_output=new kt,br.ReportFixtureAndParticle_s_input=new Ft,br.ReportFixtureAndParticle_s_p=new X,br.ReportFixtureAndParticle_s_v=new X,br.ReportFixtureAndParticle_s_f=new X;var Er=function(){function e(t){this.m_newFixture=!1,this.m_locked=!1,this.m_clearForces=!0,this.m_contactManager=new bn,this.m_bodyList=null,this.m_jointList=null,this.m_particleSystemList=null,this.m_bodyCount=0,this.m_jointCount=0,this.m_gravity=new X,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 En,this.m_island=new Fn,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 Ri(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 Oi(e);case t.b2JointType.e_mouseJoint:return new Wi(e);case t.b2JointType.e_prismaticJoint:return new ji(e);case t.b2JointType.e_revoluteJoint:return new Qi(e);case t.b2JointType.e_pulleyJoint:return new qi(e);case t.b2JointType.e_gearJoint:return new Vi(e);case t.b2JointType.e_wheelJoint:return new nn(e);case t.b2JointType.e_weldJoint:return new tn(e);case t.b2JointType.e_frictionJoint:return new ki(e);case t.b2JointType.e_ropeJoint:return new Ji(e);case t.b2JointType.e_motorJoint:return new zi(e);case t.b2JointType.e_areaJoint:return new Ni(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 ur(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 Gn(this.m_gravity.Length(),function(t){for(var e=i,n=t.GetParticleSystemList();null!==n;n=n.m_next)e=M(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 _=0;_0;){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 _=c.m_contactList;_;_=_.next){var f=_.contact;if(!f.m_islandFlag&&f.IsEnabled()&&f.IsTouching()){var d=f.m_fixtureA.m_isSensor,p=f.m_fixtureB.m_isSensor;if(!d&&!p){r.AddContact(f),f.m_islandFlag=!0;var m=_.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 v=g.other;v.IsActive()&&(r.AddJoint(g.joint),g.joint.m_islandFlag=!0,v.m_islandFlag||(h[l++]=v,v.m_islandFlag=!0))}}}var y=new En;r.Solve(y,e,this.m_gravity,this.m_allowSleep),this.m_profile.solveInit+=y.solveInit,this.m_profile.solveVelocity+=y.solveVelocity,this.m_profile.solvePosition+=y.solvePosition;for(var S=0;S8)){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 _=l.GetBody(),f=c.GetBody(),d=_.m_type,p=f.m_type,m=_.IsAwake()&&d!==t.b2BodyType.b2_staticBody,g=f.IsAwake()&&p!==t.b2BodyType.b2_staticBody;if(!m&&!g)continue;var v=_.IsBullet()||d!==t.b2BodyType.b2_dynamicBody,y=f.IsBullet()||p!==t.b2BodyType.b2_dynamicBody;if(!v&&!y)continue;var S=_.m_sweep.alpha0;_.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(q.MulMV(this.T,s.GetLocalVector(s.GetLinearVelocity(),X.s_t0),X.s_t1),e.Step_s_damping);s.SetLinearVelocity(X.AddVV(s.GetLinearVelocity(),X.MulSV(i,a,X.s_t0),X.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/P(t,e):0},e}(xr);Br.Step_s_damping=new X;var Mr=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 X,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=X.MakeArray(this.m_count),this.m_p0s=X.MakeArray(this.m_count),this.m_vs=X.MakeArray(this.m_count),this.m_ims=w(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=w(n),this.m_as=w(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;)b=(m-=2*o)-this.m_as[i];for(;b<-o;)b=(m+=2*o)-this.m_as[i];var E=-this.m_k3*A*b;n.SelfMulAdd(a*E,y),r.SelfMulAdd(h*E,S),s.SelfMulAdd(u*E,T)}}}},e.Draw=function(t){for(var e=new tt(.4,.5,.7),i=0;i1?e-1:0),n=1;n0&&0==(t&t-1)},t.b2IsValid=L,t.b2Island=Fn,t.b2Jacobian=Ii,t.b2Joint=Mi,t.b2JointDef=Bi,t.b2JointEdge=Di,t.b2Log=function(){},t.b2MakeArray=x,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=$t,t.b2ParseInt=function(t){return parseInt(t,10)},t.b2ParseUInt=function(t){return Math.abs(parseInt(t,10))},t.b2ParticleBodyContact=sr,t.b2ParticleContact=rr,t.b2ParticleDef=kn,t.b2ParticleGroup=Hn,t.b2ParticleGroupDef=zn,t.b2ParticleHandle=Un,t.b2ParticlePair=ar,t.b2ParticlePairSet=mr,t.b2ParticleSystem=ur,t.b2ParticleSystemDef=hr,t.b2ParticleSystem_CompositeShape=Sr,t.b2ParticleSystem_ConnectionFilter=gr,t.b2ParticleSystem_DestroyParticlesInShapeCallback=vr,t.b2ParticleSystem_FixedSetAllocator=dr,t.b2ParticleSystem_FixtureParticle=function(t,e){this.second=v,this.first=t,this.second=e},t.b2ParticleSystem_FixtureParticleSet=pr,t.b2ParticleSystem_InsideBoundsEnumerator=_r,t.b2ParticleSystem_JoinParticleGroupsFilter=yr,t.b2ParticleSystem_ParticleListNode=fr,t.b2ParticleSystem_ParticlePair=function(t,e){this.first=v,this.second=v,this.first=t,this.second=e},t.b2ParticleSystem_Proxy=cr,t.b2ParticleSystem_ReactiveFilter=Tr,t.b2ParticleSystem_SolveCollisionCallback=br,t.b2ParticleSystem_UpdateBodyContactsCallback=Ar,t.b2ParticleSystem_UserOverridableBuffer=lr,t.b2ParticleTriad=or,t.b2PolygonAndCircleContact=ln,t.b2PolygonContact=un,t.b2PolygonShape=vi,t.b2Position=xn,t.b2PositionSolverManifold=On,t.b2Pow=G,t.b2PrismaticJoint=ji,t.b2PrismaticJointDef=Xi,t.b2Profile=En,t.b2PulleyJoint=qi,t.b2PulleyJointDef=Yi,t.b2QueryCallback=Tn,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=An,t.b2RayCastInput=Ft,t.b2RayCastOutput=kt,t.b2RevoluteJoint=Qi,t.b2RevoluteJointDef=Ki,t.b2Rope=Mr,t.b2RopeDef=function(){this.vertices=[],this.count=0,this.masses=[],this.gravity=new X(0,0),this.damping=.1,this.k2=.9,this.k3=.1},t.b2RopeJoint=Ji,t.b2RopeJointDef=Zi,t.b2Rot=Q,t.b2SeparationFunction=ce,t.b2Shape=mi,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=P(i.m_radius,_)+P(n.m_radius,_),s=e.transformA,a=e.transformB,o=e.translationB,h=Tt.Set(0,0),u=0,l=At;l.m_count=0;for(var c=l.m_vertices,f=i.GetSupport(Q.MulTRV(s.q,X.NegV(o,X.s_t1),X.s_t0)),d=Z.MulXV(s,i.GetVertex(f),bt),p=n.GetSupport(Q.MulTRV(a.q,o,X.s_t0)),m=Z.MulXV(a,n.GetVertex(p),Et),g=X.SubVV(d,m,Ct),v=P(_,r-_),y=0;y<20&&B(g.Length()-v)>.004;){t.iterations+=1,f=i.GetSupport(Q.MulTRV(s.q,X.NegV(g,X.s_t1),X.s_t0)),d=Z.MulXV(s,i.GetVertex(f),bt),p=n.GetSupport(Q.MulTRV(a.q,g,X.s_t0)),m=Z.MulXV(a,n.GetVertex(p),Et);var S=X.SubVV(d,m,xt);g.Normalize();var T=X.DotVV(g,S),A=X.DotVV(g,o);if(T-v>u*A){if(A<=0)return!1;if((u=(T-v)/A)>1)return!1;h.Copy(g).SelfNeg(),l.m_count=0}var b=c[l.m_count];switch(b.indexA=p,b.wA.Copy(m).SelfMulAdd(u,o),b.indexB=f,b.wB.Copy(d),b.w.Copy(b.wB).SelfSub(b.wA),b.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),++y}var E=wt,C=Rt;return l.GetWitnessPoints(E,C),g.LengthSquared()>0&&(h.Copy(g).SelfNeg(),h.Normalize()),t.normal.Copy(h),t.lambda=u,t.iterations=y,!0},t.b2ShapeCastInput=function(){this.proxyA=new st,this.proxyB=new st,this.transformA=new Z,this.transformB=new Z,this.translationB=new X},t.b2ShapeCastOutput=function(){this.point=new X,this.normal=new X,this.lambda=0,this.iterations=0},t.b2Simplex=lt,t.b2SimplexCache=at,t.b2SimplexVertex=ut,t.b2Sin=U,t.b2SolverData=Rn,t.b2Sq=N,t.b2Sqrt=k,t.b2StackAllocator=function(){},t.b2Swap=function(t,e){var i=t[0];t[0]=e[0],e[0]=i},t.b2Sweep=$,t.b2TOIInput=he,t.b2TOIOutput=le,t.b2TensorDampingController=Br,t.b2TestOverlapAABB=Vt,t.b2TestOverlapShape=Xt,t.b2TimeOfImpact=Te,t.b2TimeStep=Cn,t.b2Timer=it,t.b2Transform=Z,t.b2TreeNode=Yt,t.b2Vec2=X,t.b2Vec2_zero=j,t.b2Vec3=Y,t.b2Velocity=wn,t.b2VelocityConstraintPoint=Dn,t.b2Version=E,t.b2WeldJoint=tn,t.b2WeldJointDef=$i,t.b2WheelJoint=nn,t.b2WheelJointDef=en,t.b2World=Er,t.b2WorldManifold=Lt,t.b2_180_over_pi=I,t.b2_aabbExtension=h,t.b2_aabbMultiplier=2,t.b2_angularSleepTolerance=b,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=v,t.b2_linearSleepTolerance=A,t.b2_linearSlop=l,t.b2_maxAngularCorrection=p,t.b2_maxFloat=i,t.b2_maxLinearCorrection=d,t.b2_maxManifoldPoints=2,t.b2_maxParticleForce=.5,t.b2_maxParticleIndex=2147483647,t.b2_maxParticlePressure=S,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=T,t.b2_minParticleWeight=1,t.b2_minPulleyLength=2,t.b2_particleStride=y,t.b2_pi=o,t.b2_pi_over_180=R,t.b2_polygonRadius=_,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=D,t.b2_velocityThreshold=1,t.b2_version=C,t.g_blockSolve=In,Object.defineProperty(t,"__esModule",{value:!0})}(e)}));(qbt=Kbt)&&qbt.__esModule&&Object.prototype.hasOwnProperty.call(qbt,"default")&&qbt.default;var Qbt={};for(var Zbt in Kbt)-1===Zbt.indexOf("b2_")&&(Qbt[Zbt.replace("b2","")]=Kbt[Zbt]);var Jbt=Qbt,$bt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r0}function oEt(t,e,i){return dEt(t,e,i)>=0}function hEt(t,e,i){return dEt(t,e,i)<=0}function uEt(t,e){var i=e.x-t.x,n=e.y-t.y;return i*i+n*n}function lEt(t){cEt(t)||t.reverse()}function cEt(t){return t.length<3||function(t){var e,i=0;for(e=0;e0}function _Et(t,e,i,n){var r,s=new jn,a=e.y-t.y,o=t.x-e.x,h=a*t.x+o*t.y,u=n.y-i.y,l=i.x-n.x,c=u*i.x+l*i.y,_=a*l-u*o;return r=_,0,Math.abs(r-0)<=1e-6||(s.x=(l*h-o*c)/_,s.y=(a*c-u*h)/_),s}function fEt(t,e,i,n,r){if(t==i||t==n||e==i||e==n)return!1;var s=t.x,a=t.y,o=e.x,h=e.y,u=i.x,l=i.y,c=n.x,_=n.y;if(Math.max(s,o)0&&f<1&&d>0&&d<1&&(r.x=s+f*(o-s),r.y=a+f*(h-a),!0))}function dEt(t,e,i){return t.x*(e.y-i.y)+e.x*(i.y-t.y)+i.x*(t.y-e.y)}var pEt=Object.freeze({__proto__:null,ConvexPartition:function t(e){lEt(e);for(var i,n,r,s,a,o,h=[],u=new jn,l=new jn,c=0,_=0,f=0;fm&&(g=v,m=y)}a=iEt(f,g,e),o=iEt(g,f,e)}return(h=h.concat(t(a))).concat(t(o))}h.push(e);for(var S=h.length-1;S>=0;S--)0==h[S].length&&h.splice(S,0);return h},ForceCounterClockWise:lEt,IsCounterClockWise:cEt});function mEt(t){TEt(t);for(var e=!0,i=0,n=t.length;iu.angleCos&&(u=c):u=c)}if(!u){for(var _=0;_1e-5)return console.log("Failed to find ear. There might be self-intersection in the polygon."),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,bEt(u.next),h===e-4)break;for(var g=0;g1e-5&&n.push([S,T,A])}}return n}(t);if(!s)return null;for(;s.length;){for(var a=s.splice(0,1)[0],o=0,h=a.length;o0||vEt(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(_,1)}}r.push(a)}return r}var gEt=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 vEt(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function yEt(t,e,i){return vEt(t,e,i)<0}function SEt(t,e){return t.x===e.x&&t.y===e.y}function TEt(t){(function(t){for(var e=0,i=0,n=t.length;i0})(t)&&t.reverse()}function AEt(t,e){if(t.shouldUpdate){t.shouldUpdate=!1;var i=t.prev.point,n=t.point,r=t.next.point;t.isConvex=yEt(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,_=e.length;c<_;++c){var f=e[c];if(f.isActive&&f!==t){var d=f.point;if(!(SEt(i,d)||SEt(n,d)||SEt(r,d))){var p=vEt(i,d,n),m=vEt(n,d,r),g=vEt(r,d,i);if(p>0&&m>0&&g>0){t.isEar=!1;break}if(0===p&&m>=0&&g>=0&&(vEt(i,f.prev.point,n)>0||vEt(i,f.next.point,n)>0)){t.isEar=!1;break}if(0===m&&p>=0&&g>=0&&(vEt(n,f.prev.point,r)>0||vEt(n,f.next.point,r)>0)){t.isEar=!1;break}if(0===g&&p>=0&&m>=0&&(vEt(r,f.prev.point,i)>0||vEt(r,f.next.point,i)>0)){t.isEar=!1;break}}}}}else t.isEar=!1}}function bEt(t){for(var e=t,i=t;;)if(SEt(e.point,e.next.point)||0===vEt(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}var EEt,CEt,xEt,wEt,REt,IEt,DEt,BEt,MEt,PEt,OEt,LEt=Object.freeze({__proto__:null,ConvexPartition:mEt});t("fS",EEt),function(t){t[t.DYNAMIC=1]="DYNAMIC",t[t.STATIC=2]="STATIC",t[t.KINEMATIC=4]="KINEMATIC"}(EEt||t("fS",EEt={})),Ee(EEt),t("fR",CEt),function(t){t[t.X_AXIS=0]="X_AXIS",t[t.Y_AXIS=1]="Y_AXIS",t[t.Z_AXIS=2]="Z_AXIS"}(CEt||t("fR",CEt={})),Ee(CEt),function(t){t[t.X=0]="X",t[t.Y=1]="Y",t[t.Z=2]="Z",t[t.SWING1=3]="SWING1",t[t.SWING2=4]="SWING2",t[t.TWIST=5]="TWIST"}(xEt||(xEt={})),Ee(xEt),function(t){t[t.VERTEX=1]="VERTEX",t[t.LINE=2]="LINE",t[t.TRIANGLE=3]="TRIANGLE",t[t.TETRAHEDRON=4]="TETRAHEDRON"}(wEt||(wEt={})),Ee(wEt),t("fT",REt),function(t){t[t.BOX=0]="BOX",t[t.SPHERE=1]="SPHERE",t[t.CAPSULE=2]="CAPSULE",t[t.CYLINDER=3]="CYLINDER",t[t.CONE=4]="CONE",t[t.MESH=5]="MESH",t[t.PLANE=6]="PLANE",t[t.SIMPLEX=7]="SIMPLEX",t[t.TERRAIN=8]="TERRAIN"}(REt||t("fT",REt={})),Ee(REt),function(t){t[t.POINT_TO_POINT=0]="POINT_TO_POINT",t[t.HINGE=1]="HINGE",t[t.FIXED=2]="FIXED",t[t.CONFIGURABLE=3]="CONFIGURABLE"}(IEt||(IEt={})),Ee(IEt),function(t){t[t.FREE=0]="FREE",t[t.LIMITED=1]="LIMITED",t[t.LOCKED=2]="LOCKED"}(DEt||(DEt={})),Ee(DEt),function(t){t[t.DISABLED=0]="DISABLED",t[t.SERVO=1]="SERVO",t[t.INDUCTION=2]="INDUCTION"}(BEt||(BEt={})),Ee(BEt),function(t){t[t.BOX=0]="BOX",t[t.CAPSULE=1]="CAPSULE"}(MEt||(MEt={})),Ee(MEt),function(t){t[t.DEFAULT=1]="DEFAULT"}(PEt||(PEt={})),Ee(PEt),t("fU",OEt),function(t){t[t.NONE=0]="NONE",t[t.WIRE_FRAME=1]="WIRE_FRAME",t[t.CONSTRAINT=2]="CONSTRAINT",t[t.AABB=4]="AABB"}(OEt||t("fU",OEt={})),Ee(OEt);var NEt=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;a=Obt.All?1:n)},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}(Jbt.RayCastCallback),Jwt=[],$wt=[new jn,new jn],tRt=new Jbt.WorldManifold,eRt={points:[],separations:[],normal:new jn},iRt=function(){this.localPoint=new jn,this.normalImpulse=0,this.tangentImpulse=0},nRt=[new iRt,new iRt],rRt={type:0,localPoint:new jn,localNormal:new jn,points:[]},sRt={normalImpulses:[],tangentImpulses:[]},aRt=function(){function t(){this.colliderA=null,this.colliderB=null,this.disabled=!1,this.disabledOnce=!1,this._impulse=null,this._inverted=!1,this._b2contact=null}t.get=function(e){var i=Jwt.pop();return i||(i=new t),i.init(e),i},t.put=function(t){var e=t.m_userData;e&&(Jwt.push(e),e.reset())};var e=t.prototype;return e._setImpulse=function(t){this._impulse=t},e.init=function(t){this.colliderA=t.m_fixtureA.m_userData.collider,this.colliderB=t.m_fixtureB.m_userData.collider,this.disabled=!1,this.disabledOnce=!1,this._impulse=null,this._inverted=!1,this._b2contact=t,t.m_userData=this},e.reset=function(){this.setTangentSpeed(0),this.resetFriction(),this.resetRestitution(),this.colliderA=null,this.colliderB=null,this.disabled=!1,this._impulse=null,this._b2contact.m_userData=null,this._b2contact=null},e.getWorldManifold=function(){var t=eRt.points,e=eRt.separations,i=eRt.normal;this._b2contact.GetWorldManifold(tRt);var n=tRt.points,r=tRt.separations,s=this._b2contact.GetManifold().pointCount;t.length=e.length=s;for(var a=0;a0){for(var a=r.getPoints(),o=r.getNormals(),h=r.getFractions(),u=[],l=0,c=s.length;lMath.PI&&(r-=Pi);var s=(this._animatedAngle-r)*n;this._animatedAngle<-Mi&&r>Mi&&(s=(this._animatedAngle+Pi-r)*n),this._animatedAngle>Mi&&r<-Mi&&(s=(this._animatedAngle-Pi-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=r===Dbt.Animated?e.GetLinearVelocity():e.GetPosition()).x=n.x/Gbt,i.y=n.y/Gbt,r===Dbt.Animated&&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=yRt;Bn.toEulerInYXZOrder(n,i);var r=Vi(n.z);this._rigidBody.type===Dbt.Animated&&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){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.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 SRt.Set(t.x/Gbt,t.y/Gbt),this._body.GetLinearVelocityFromWorldPoint(SRt,e),e.x*=Gbt,e.y*=Gbt,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 jn,SRt.Set(t.x/Gbt,t.y/Gbt),this._body.GetLocalVector(SRt,e),e.x*=Gbt,e.y*=Gbt,e},e.getWorldVector=function(t,e){return SRt.Set(t.x/Gbt,t.y/Gbt),this._body.GetWorldVector(SRt,e),e.x*=Gbt,e.y*=Gbt,e},e.getLocalPoint=function(t,e){return e=e||new jn,SRt.Set(t.x/Gbt,t.y/Gbt),this._body.GetLocalPoint(SRt,e),e.x*=Gbt,e.y*=Gbt,e},e.getWorldPoint=function(t,e){return e=e||new jn,SRt.Set(t.x/Gbt,t.y/Gbt),this._body.GetWorldPoint(SRt,e),e.x*=Gbt,e.y*=Gbt,e},e.getLocalCenter=function(t){t=t||new jn;var e=this._body.GetLocalCenter();return t.x=e.x*Gbt,t.y=e.y*Gbt,t},e.getWorldCenter=function(t){t=t||new jn;var e=this._body.GetWorldCenter();return t.x=e.x*Gbt,t.y=e.y*Gbt,t},e.getInertia=function(){return this._body.GetInertia()},e.applyForce=function(t,e,i){this._body&&(SRt.Set(e.x/Gbt,e.y/Gbt),this._body.ApplyForce(t,SRt,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&&(SRt.Set(e.x/Gbt,e.y/Gbt),this._body.ApplyLinearImpulse(t,SRt,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}(),ARt=new Jbt.Filter,bRt=new Jbt.Vec2,ERt=new Jbt.Vec2;function CRt(t){var e=t.collider;return e.body?ARt.categoryBits=e.group===PEt.DEFAULT?e.body.group:e.group:ARt.categoryBits=e.group,ARt.maskBits=uCt.instance.collisionMatrix[ARt.categoryBits],ARt}var xRt,wRt=function(){function t(){this._shapes=[],this._fixtures=[],this._collider=null,this._body=null,this._inited=!1,this._rect=new Jn}var e=t.prototype;return e.initialize=function(t){this._collider=t},e.onLoad=function(){},e.onEnable=function(){uCt.instance._callAfterStep(this,this._init)},e.onDisable=function(){uCt.instance._callAfterStep(this,this._destroy)},e.start=function(){},e.onGroupChanged=function(){var t=CRt(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=gn.ZERO,n=t.getComponent(Hwt);n&&n.impl&&n.impl.impl?this._body=n.impl.impl:(this._body=uCt.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=CRt(this),a=0;a=0;i--){var n=t[i];n.m_userData=null,uCt.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=-t,r=-t,s=this._fixtures,a=0;an&&(n=ERt.x),ERt.y>r&&(r=ERt.y)}e*=Gbt,i*=Gbt,n*=Gbt,r*=Gbt;var c=this._rect;return c.x=e,c.y=i,c.width=n-e,c.height=r-i,c}}]),t}(),RRt=new Jn,IRt=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=mEt(a);if(!o)return console.log("[Physics2D] b2PolygonShape failed to decompose polygon into convex polygons, node name: ",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){Li(this._friction,t)||(this._friction=t,this.emit(e.EVENT_UPDATE))}},{key:"rollingFriction",get:function(){return this._rollingFriction},set:function(t){Li(this._rollingFriction,t)||(this._rollingFriction=t,this.emit(e.EVENT_UPDATE))}},{key:"spinningFriction",get:function(){return this._spinningFriction},set:function(t){Li(this._spinningFriction,t)||(this._spinningFriction=t,this.emit(e.EVENT_UPDATE))}},{key:"restitution",get:function(){return this._restitution},set:function(t){Li(this._restitution,t)||(this._restitution=t,this.emit(e.EVENT_UPDATE))}}]),e}(vd)).allMaterials=[],RIt.EVENT_UPDATE="event_update",RIt._idCounter=0,m((bIt=RIt).prototype,"friction",[vIt],Object.getOwnPropertyDescriptor(bIt.prototype,"friction"),bIt.prototype),m(bIt.prototype,"rollingFriction",[yIt],Object.getOwnPropertyDescriptor(bIt.prototype,"rollingFriction"),bIt.prototype),m(bIt.prototype,"spinningFriction",[SIt],Object.getOwnPropertyDescriptor(bIt.prototype,"spinningFriction"),bIt.prototype),m(bIt.prototype,"restitution",[TIt],Object.getOwnPropertyDescriptor(bIt.prototype,"restitution"),bIt.prototype),EIt=ja(bIt.prototype,"_friction",[lo],(function(){return.6})),CIt=ja(bIt.prototype,"_rollingFriction",[lo],(function(){return 0})),xIt=ja(bIt.prototype,"_spinningFriction",[lo],(function(){return 0})),wIt=ja(bIt.prototype,"_restitution",[lo],(function(){return 0})),AIt=bIt))||AIt)),FIt=t("fy",function(){function t(){this._hitPoint=new gn,this._hitNormal=new gn,this._distance=0,this._collider=null}var e=t.prototype;return e._assign=function(t,e,i,n){gn.copy(this._hitPoint,t),gn.copy(this._hitNormal,n),this._distance=e,this._collider=i},e.clone=function(){var e=new t;return gn.copy(e._hitPoint,this._hitPoint),gn.copy(e._hitNormal,this._hitNormal),e._distance=this._distance,e._collider=this._collider,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}}]),t}()),kIt=t("fz",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++}ID.emit(wD.EVENT_AFTER_PHYSICS)}}else this.physicsWorld.syncSceneToPhysics()},e.resetConfiguration=function(t){var e=t?t.allowSleep:Me.querySettings(De.Category.PHYSICS,"allowSleep");"boolean"==typeof e&&(this._allowSleep=e);var i=t?t.fixedTimeStep:Me.querySettings(De.Category.PHYSICS,"fixedTimeStep");"number"==typeof i&&(this._fixedTimeStep=i);var n=t?t.maxSubSteps:Me.querySettings(De.Category.PHYSICS,"maxSubSteps");"number"==typeof n&&(this._maxSubSteps=n);var r=t?t.sleepThreshold:Me.querySettings(De.Category.PHYSICS,"sleepThreshold");"number"==typeof r&&(this._sleepThreshold=r);var s=t?t.autoSimulation:Me.querySettings(De.Category.PHYSICS,"autoSimulation");"boolean"==typeof s&&(this.autoSimulation=s);var a=t?t.gravity:Me.querySettings(De.Category.PHYSICS,"gravity");a&&gn.copy(this._gravity,a);var o=t?t.collisionMatrix:Me.querySettings(De.Category.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 gr,a=1;ai);++a){var o=t[a-1],h=t[a],u=new gn;gn.subtract(u,h,o);var l=gn.len(u);if(r+=l,gn.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 gr,a=!1,o=1;oi);++o){var h=t[o-1],u=t[o],l=new gn;gn.subtract(l,u,h);var c=gn.len(l);if(r+=c,gn.multiplyScalar(l,l,1/c),s.d=l,s.o=h,a=this.raycastClosest(s,e,c,n)){var _=this.raycastClosestResult,f=new kIt;f._assign(_.hitPoint,_.distance,_.collider,_.hitNormal,o-1),this.lineStripCastClosestResult=f;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(){var t;if((null===(t=Me.querySettings(De.Category.PHYSICS,"enabled"))||void 0===t||t)&&!i._instance){var e=new i;i._instance=e,e.resetConfiguration(),function(t){if(xRt||(xRt=t),WRt.runInEditor&&!WRt.physicsWorld){U("[PHYSICS]: using "+WRt.id+".");var e=WRt.physicsWorld=qRt();e.setGravity(xRt.gravity),e.setAllowSleep(xRt.allowSleep)}}(e),ID.registerSystem(i.ID,e,e.priority),EB.onPostProjectInitDelegate.add(e.initDefaultMaterial.bind(e))}},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 WRt.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!WRt.id}},{key:"PHYSICS_BUILTIN",get:function(){return"builtin"===WRt.id}},{key:"PHYSICS_CANNON",get:function(){return"cannon.js"===WRt.id}},{key:"PHYSICS_BULLET",get:function(){return"bullet"===WRt.id}},{key:"PHYSICS_PHYSX",get:function(){return"physx"===WRt.id}},{key:"PhysicsGroup",get:function(){return PEt}},{key:"instance",get:function(){return i._instance}}]),i}(Ml));eDt.ID="PHYSICS",eDt._instance=null,ID.once(wD.EVENT_INIT,(function(){eDt.constructAndRegister()}));var iDt,nDt,rDt,sDt,aDt,oDt,hDt,uDt,lDt,cDt,_Dt,fDt=t("fu",(GIt=eo("cc.RigidBody"),VIt=no(-1),UIt=Lo(eDt.PhysicsGroup),zIt=Lo(EEt),GIt(HIt=ro(HIt=VIt(((tDt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;rCEt.Z_AXIS||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}(yDt)).prototype,"direction",[EDt],Object.getOwnPropertyDescriptor(xDt.prototype,"direction"),xDt.prototype),wDt=ja(xDt.prototype,"_radius",[lo],(function(){return.5})),RDt=ja(xDt.prototype,"_cylinderHeight",[lo],(function(){return 1})),IDt=ja(xDt.prototype,"_direction",[lo],(function(){return CEt.Y_AXIS})),CDt=xDt))||CDt)),LBt=t("fF",(DDt=eo("cc.CylinderCollider"),BDt=Lo(CEt),DDt((m((PDt=function(t){function e(){var e;return(e=t.call(this,REt.CYLINDER)||this)._radius=ODt&&ODt(),e._height=LDt&&LDt(),e._direction=NDt&&NDt(),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&&(tCEt.Z_AXIS||(this._direction=t,this._shape&&this.shape.setDirection(t)))}},{key:"shape",get:function(){return this._shape}}]),e}(yDt)).prototype,"direction",[BDt],Object.getOwnPropertyDescriptor(PDt.prototype,"direction"),PDt.prototype),ODt=ja(PDt.prototype,"_radius",[lo],(function(){return.5})),LDt=ja(PDt.prototype,"_height",[lo],(function(){return 2})),NDt=ja(PDt.prototype,"_direction",[lo],(function(){return CEt.Y_AXIS})),MDt=PDt))||MDt)),NBt=t("fG",(FDt=eo("cc.ConeCollider"),kDt=Lo(CEt),FDt((m((VDt=function(t){function e(){var e;return(e=t.call(this,REt.CONE)||this)._radius=UDt&&UDt(),e._height=zDt&&zDt(),e._direction=HDt&&HDt(),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&&(tCEt.Z_AXIS||(this._direction=t,this._shape&&this.shape.setDirection(t)))}},{key:"shape",get:function(){return this._shape}}]),e}(yDt)).prototype,"direction",[kDt],Object.getOwnPropertyDescriptor(VDt.prototype,"direction"),VDt.prototype),UDt=ja(VDt.prototype,"_radius",[lo],(function(){return.5})),zDt=ja(VDt.prototype,"_height",[lo],(function(){return 1})),HDt=ja(VDt.prototype,"_direction",[lo],(function(){return CEt.Y_AXIS})),GDt=VDt))||GDt)),FBt=t("fE",(WDt=eo("cc.MeshCollider"),XDt=Lo(ZB),WDt((m((YDt=function(t){function e(){var e;return(e=t.call(this,REt.MESH)||this)._mesh=qDt&&qDt(),e._convex=KDt&&KDt(),e}return s(e,t),e.prototype.onEnable=function(){if(t.prototype.onEnable.call(this),this.node){var e=this.node.getComponent(fDt);e&&e.isValid&&e.type===EEt.DYNAMIC&&!this.convex&&tt(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}(yDt)).prototype,"mesh",[XDt],Object.getOwnPropertyDescriptor(YDt.prototype,"mesh"),YDt.prototype),qDt=ja(YDt.prototype,"_mesh",[lo],(function(){return null})),KDt=ja(YDt.prototype,"_convex",[lo],(function(){return!1})),jDt=YDt))||jDt)),kBt=t("fw",eo("cc.ConstantForce")(QDt=io(fDt)(QDt=ro((ZDt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;rt)){for(var e=this.buffer.byteLength;e=eMt?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=tMt){var o=e.readInt();this.normals=new Float32Array(o);for(var h=0;h=QBt){var c=e.readInt();this.layerBuffer=new Array(c);for(var _=0;_=ZBt){var f=e.readInt();this._layerBinaryInfos=new Array(f);for(var d=0;d=eMt?this._layerBinaryInfos[d].tileSize=e.readDouble():this._layerBinaryInfos[d].tileSize=e.readFloat(),this._layerBinaryInfos[d].detailMapId=e.readString(),this._version>=JBt&&(this._layerBinaryInfos[d].normalMapId=e.readString(),this._version>=eMt?(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 rMt;t.writeInt32(iMt),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&&(fe(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):sIt.CollisionObject_setCollisionShape(this.body,sIt.EmptyShape_static()),sIt.CollisionObject_activate(this.body,!0),this.dirty|=xNt.BODY_RE_ADD,fe(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&&fe(this.wrappedJoints1,i)}else{var n=this.wrappedJoints0.indexOf(t);n>=0&&fe(this.wrappedJoints0,n)}},e.updateDirty=function(){this.dirty&&(this.bodyIndex>=0&&this.dirty&xNt.BODY_RE_ADD&&this.updateBodyByReAdd(),this.ghostIndex>=0&&this.dirty&xNt.GHOST_RE_ADD&&this.updateGhostByReAdd(),this.dirty=0)},e.syncSceneToPhysics=function(){if(this.node.hasChangedFlags){var t=lIt.instance.BT_QUAT_0,e=sIt.CollisionObject_getWorldTransform(this.body);if(MIt(t,this.node.worldRotation),DIt(sIt.Transform_getOrigin(e),this.node.worldPosition),sIt.Transform_setRotation(e,t),this.node.hasChangedFlags&mm.SCALE&&this.syncBodyScale(),sIt.CollisionObject_isKinematicObject(this.body)){var i=sIt.RigidBody_getMotionState(this.body);i&&sIt.MotionState_setWorldTransform(i,e)}else this.isBodySleeping()&&sIt.CollisionObject_activate(this.body,!1)}},e.syncPhysicsToScene=function(){sIt.CollisionObject_isStaticOrKinematicObject(this.body)||this.syncPhysicsToGraphics()},e.syncPhysicsToGraphics=function(){if(!this.isBodySleeping()){var t=lIt.instance.BT_QUAT_0,e=lIt.instance.BT_TRANSFORM_0;sIt.RigidBody_getWorldTransform(this.body,e);var i=sIt.Transform_getRotationAndOrigin(e,t);if(this.node.worldRotation=PIt(FNt,t),this.node.worldPosition=BIt(NNt,i),this._ghostStruct){var n=sIt.CollisionObject_getWorldTransform(this.ghost);DIt(sIt.Transform_getOrigin(n),this.node.worldPosition),MIt(t,this.node.worldRotation),sIt.Transform_setRotation(n,t)}}},e.syncSceneToGhost=function(){if(this.node.hasChangedFlags){var t=lIt.instance.BT_QUAT_0,e=sIt.CollisionObject_getWorldTransform(this.ghost);DIt(sIt.Transform_getOrigin(e),this.node.worldPosition),MIt(t,this.node.worldRotation),sIt.Transform_setRotation(e,t),this.node.hasChangedFlags&mm.SCALE&&this.syncGhostScale(),sIt.CollisionObject_activate(this.ghost,!1)}},e.syncInitialBody=function(){var t=lIt.instance.BT_QUAT_0,e=sIt.CollisionObject_getWorldTransform(this.body);DIt(sIt.Transform_getOrigin(e),this.node.worldPosition),MIt(t,this.node.worldRotation),sIt.Transform_setRotation(e,t),this.syncBodyScale(),sIt.CollisionObject_activate(this.body,!1)},e.syncInitialGhost=function(){var t=lIt.instance.BT_QUAT_0,e=sIt.CollisionObject_getWorldTransform(this.ghost);DIt(sIt.Transform_getOrigin(e),this.node.worldPosition),MIt(t,this.node.worldRotation),sIt.Transform_setRotation(e,t),this.syncGhostScale(),sIt.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;lIt.delWrapper(this.id,aIt.BODY_CACHE_NAME),sIt._safe_delete(e.motionState,tIt.EBulletTypeMotionState),sIt._safe_delete(e.compound,tIt.EBulletTypeCollisionShape),sIt._safe_delete(e.body,tIt.EBulletTypeCollisionObject),this._bodyStruct=null}if(this._ghostStruct){var i=this._ghostStruct;sIt._safe_delete(i.compound,tIt.EBulletTypeCollisionShape),sIt._safe_delete(i.ghost,tIt.EBulletTypeCollisionObject),this._ghostStruct=null}},e.isBodySleeping=function(){return sIt.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|=xNt.BODY_RE_ADD,this.dirty|=xNt.GHOST_RE_ADD)}},{key:"collisionFilterMask",get:function(){return this._collisionFilterMask},set:function(t){t!==this._collisionFilterMask&&(this._collisionFilterMask=t,this.dirty|=xNt.BODY_RE_ADD,this.dirty|=xNt.GHOST_RE_ADD)}},{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)&&(sIt.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}();GNt.idCounter=0,GNt.sharedBodesMap=new Map;var VNt=cIt,UNt={},zNt=function(){function t(){this.id=t.idCounter++,this._isEnabled=!1,this._isTrigger=!1,this._isInitialized=!1,this._impl=0,this._compound=0,this.quat=sIt.Quat_new(0,0,0,1),this.transform=sIt.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?eDt.instance.defaultMaterial:t;if(!this._isTrigger&&this._isEnabled)if(this._compound){UNt[e._uuid]||(UNt[e._uuid]=sIt.ccMaterial_new());var i=UNt[e._uuid];sIt.ccMaterial_set(i,e.restitution,e.friction,e.rollingFriction,e.spinningFriction),sIt.CollisionShape_setMaterial(this._impl,i)}else sIt.CollisionObject_setMaterial(this._sharedBody.body,e.restitution,e.friction,e.rollingFriction,e.spinningFriction)},e.setCenter=function(t){gn.copy(VNt,t),VNt.multiply(this._collider.node.worldScale),DIt(sIt.Transform_getOrigin(this.transform),VNt),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=lIt.instance.BT_TRANSFORM_0;sIt.Transform_setIdentity(e),sIt.Transform_setRotation(e,MIt(lIt.instance.BT_QUAT_0,this._collider.node.worldRotation));var i=lIt.instance.BT_V3_0,n=lIt.instance.BT_V3_1;sIt.CollisionShape_getAabb(this._impl,e,i,n),t.halfExtents.x=(sIt.Vec3_x(n)-sIt.Vec3_x(i))/2,t.halfExtents.y=(sIt.Vec3_y(n)-sIt.Vec3_y(i))/2,t.halfExtents.z=(sIt.Vec3_z(n)-sIt.Vec3_z(i))/2,gn.add(t.center,this._collider.node.worldPosition,this._collider.center)},e.getBoundingSphere=function(t){t.radius=sIt.CollisionShape_getLocalBoundingSphere(this._impl),gn.add(t.center,this._collider.node.worldPosition,this._collider.center)},e.initialize=function(t){this._collider=t,this._isInitialized=!0,this._sharedBody=eDt.instance.physicsWorld.getSharedBody(this._collider.node),this._sharedBody.reference=!0,this.onComponentSet(),this.setWrapper()},e.setWrapper=function(){lIt.isNotEmptyShape(this._impl)&&(sIt.CollisionShape_setUserPointer(this._impl,this._impl),lIt.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,sIt._safe_delete(this.quat,tIt.EBulletTypeQuat),sIt._safe_delete(this.transform,tIt.EBulletTypeTransform),this._compound&&sIt._safe_delete(this._compound,tIt.EBulletTypeCollisionShape),lIt.isNotEmptyShape(this._impl)&&(sIt._safe_delete(this._impl,tIt.EBulletTypeCollisionShape),lIt.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&&sIt.CompoundShape_removeChildShape(this._compound,this._impl),t&&sIt.CompoundShape_addChildShape(t,this.transform,this._impl),this._compound=t},e.updateScale=function(){this.setCenter(this._collider.center)},e.updateCompoundTransform=function(){this._compound?sIt.CompoundShape_updateChildTransform(this._compound,this._impl,this.transform,!0):this._isEnabled&&!this._isTrigger&&this._sharedBody&&!this._sharedBody.bodyStruct.useCompound&&(this._sharedBody.dirty|=xNt.BODY_RE_ADD)},e.needCompound=function(){return this._collider.type===REt.TERRAIN||!this._collider.center.equals(gn.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}();zNt.TYPE="shape",zNt.idCounter=0;var HNt=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}(),WNt=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}(),XNt=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&&BIt(t,sIt.ManifoldPoint_get_m_localPointA(this.impl))},e.getLocalPointOnB=function(t){this.impl&&BIt(t,sIt.ManifoldPoint_get_m_localPointB(this.impl))},e.getWorldPointOnA=function(t){this.impl&&BIt(t,sIt.ManifoldPoint_get_m_positionWorldOnA(this.impl))},e.getWorldPointOnB=function(t){this.impl&&BIt(t,sIt.ManifoldPoint_get_m_positionWorldOnB(this.impl))},e.getLocalNormalOnA=function(t){if(this.impl){var e=lIt.instance.BT_QUAT_0,i=sIt.PersistentManifold_getBody0(this.event.impl),n=sIt.CollisionObject_getWorldTransform(i);sIt.Transform_getRotation(n,e);var r=dIt;PIt(r,e),Bn.conjugate(r,r),BIt(t,sIt.ManifoldPoint_get_m_normalWorldOnB(this.impl)),this.isBodyA||gn.negate(t,t),gn.transformQuat(t,t,r)}},e.getLocalNormalOnB=function(t){if(this.impl){var e=lIt.instance.BT_QUAT_0,i=sIt.PersistentManifold_getBody1(this.event.impl),n=sIt.CollisionObject_getWorldTransform(i);sIt.Transform_getRotation(n,e);var r=dIt;PIt(r,e),Bn.conjugate(r,r),BIt(t,sIt.ManifoldPoint_get_m_normalWorldOnB(this.impl)),gn.transformQuat(t,t,r)}},e.getWorldNormalOnA=function(t){this.impl&&(BIt(t,sIt.ManifoldPoint_get_m_normalWorldOnB(this.impl)),this.isBodyA||gn.negate(t,t))},e.getWorldNormalOnB=function(t){this.impl&&BIt(t,sIt.ManifoldPoint_get_m_normalWorldOnB(this.impl))},n(t,[{key:"isBodyA",get:function(){return this.event.selfCollider.shape.sharedBody.body===sIt.PersistentManifold_getBody0(this.event.impl)}}]),t}(),jNt=[],YNt=cIt,qNt=_It,KNt=fIt,QNt=IIt,ZNt=new CNt,JNt=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=OEt.NONE,this._debugConstraintSize=.3,this._needEmitEvents=!1,this._needSyncAfterEvents=!1,this._needEmitCCTEvents=!1,this.bodies=[],this.ghosts=[],this.ccts=[],this.constraints=[],this.triggerArrayMat=new HNt,this.collisionArrayMat=new HNt,this.contactsDic=new WNt,this.oldContactsDic=new WNt,this.cctShapeEventDic=new WNt,this.cctContactsDic=new WNt,this.cctOldContactsDic=new WNt,aIt.CACHE.world=this,this._broadphase=sIt.DbvtBroadphase_new(),this._dispatcher=sIt.CollisionDispatcher_new(),this._solver=sIt.SequentialImpulseConstraintSolver_new(),this._world=sIt.ccDiscreteDynamicsWorld_new(this._dispatcher,this._broadphase,this._solver);var t=sIt.DebugDraw.implement(LNt);this._debugDraw=t.$$.ptr,sIt.CollisionWorld_setDebugDrawer(this._world,this._debugDraw),sIt.DebugDraw_setDebugMode(this._debugDraw,iIt.DBG_NoDebug),sIt.DebugDraw_setAABBColor(this._debugDraw,0,1,1),sIt.DebugDraw_setActiveObjectColor(this._debugDraw,1,0,1),sIt.DebugDraw_setDeactiveObjectColor(this._debugDraw,1,0,1),sIt.DebugDraw_setWantsDeactivationObjectColor(this._debugDraw,1,0,1),sIt.DebugDraw_setDisabledDeactivationObjectColor(this._debugDraw,1,0,1),sIt.DebugDraw_setDisabledSimulationObjectColor(this._debugDraw,1,0,1),sIt.DebugDraw_setConstraintLimitColor(this._debugDraw,.5,.5,.5)}return t.setDefaultMaterial=function(){},t.setAllowSleep=function(t){sIt.ccDiscreteDynamicsWorld_setAllowSleep(this._world,t)},t.setGravity=function(t){sIt.DynamicsWorld_setGravity(this._world,DIt(lIt.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(YNt,e.maxDistance);var r=DIt(lIt.instance.BT_V3_0,YNt),s=DIt(lIt.instance.BT_V3_1,t.o),a=sIt.ccAllRayCallback_static();if(sIt.ccAllRayCallback_reset(a,s,r,e.mask>>>0,e.queryTrigger),sIt.ccAllRayCallback_setFlags(a,eIt.UseSubSimplexConvexCastRaytest),sIt.CollisionWorld_rayTest(this._world,s,r,a),sIt.RayCallback_hasHit(a)){for(var o=sIt.ccAllRayCallback_getHitPointWorld(a),h=sIt.ccAllRayCallback_getHitNormalWorld(a),u=sIt.ccAllRayCallback_getCollisionShapePtrs(a),l=0,c=sIt.int_array_size(u);l>>0,e.queryTrigger),sIt.ccClosestRayCallback_setFlags(s,eIt.UseSubSimplexConvexCastRaytest),sIt.CollisionWorld_rayTest(this._world,r,n,s),sIt.RayCallback_hasHit(s)){BIt(YNt,sIt.ccClosestRayCallback_getHitPointWorld(s)),BIt(qNt,sIt.ccClosestRayCallback_getHitNormalWorld(s));var a=lIt.getWrapper(sIt.ccClosestRayCallback_getCollisionShapePtr(s),zNt.TYPE);return i._assign(YNt,gn.distance(t.o,YNt),a.collider,qNt),!0}return!1},t.sweepBox=function(t,i,n,r,s,a){var o=lIt.instance.BT_V3_0;return DIt(o,i),e._sweepBoxGeometry||(e._sweepBoxGeometry=sIt.BoxShape_new(o)),sIt.BoxShape_setUnscaledHalfExtents(e._sweepBoxGeometry,o),this.sweep(t,e._sweepBoxGeometry,n,r,s,a)},t.sweepBoxClosest=function(t,i,n,r,s){var a=lIt.instance.BT_V3_0;return DIt(a,i),e._sweepBoxGeometry||(e._sweepBoxGeometry=sIt.BoxShape_new(a)),sIt.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=sIt.SphereShape_new(i)),sIt.SphereShape_setUnscaledRadius(e._sweepSphereGeometry,i),this.sweep(t,e._sweepSphereGeometry,Bn.IDENTITY,n,r,s)},t.sweepSphereClosest=function(t,i,n,r){return e._sweepSphereGeometry||(e._sweepSphereGeometry=sIt.SphereShape_new(i)),sIt.SphereShape_setUnscaledRadius(e._sweepSphereGeometry,i),this.sweepClosest(t,e._sweepSphereGeometry,Bn.IDENTITY,n,r)},t.sweepCapsule=function(t,i,n,r,s,a,o){return e._sweepCapsuleGeometry||(e._sweepCapsuleGeometry=sIt.CapsuleShape_new(i,n)),sIt.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=sIt.CapsuleShape_new(i,n)),sIt.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=lIt.instance.BT_TRANSFORM_0,o=lIt.instance.BT_TRANSFORM_1,h=lIt.instance.BT_QUAT_0;DIt(sIt.Transform_getOrigin(a),t.o),MIt(h,i),sIt.Transform_setRotation(a,h),t.computeHit(YNt,n.maxDistance),DIt(sIt.Transform_getOrigin(o),YNt),MIt(h,i),sIt.Transform_setRotation(o,h);var u=sIt.ccAllConvexCallback_static();if(sIt.ccAllConvexCallback_reset(u,a,o,n.mask>>>0,n.queryTrigger),sIt.CollisionWorld_convexSweepTest(this._world,e,a,o,u,0),sIt.ConvexCallback_hasHit(u)){for(var l=sIt.ccAllConvexCallback_getHitPointWorld(u),c=sIt.ccAllConvexCallback_getHitNormalWorld(u),_=sIt.ccAllConvexCallback_getCollisionShapePtrs(u),f=0,d=sIt.int_array_size(_);f>>0,n.queryTrigger),sIt.CollisionWorld_convexSweepTest(this._world,e,s,a,h,0),sIt.ConvexCallback_hasHit(h)){BIt(YNt,sIt.ccClosestConvexCallback_getHitPointWorld(h)),BIt(qNt,sIt.ccClosestConvexCallback_getHitNormalWorld(h));var u=lIt.getWrapper(sIt.ccClosestConvexCallback_getCollisionShapePtr(h),zNt.TYPE);return r._assign(YNt,gn.distance(t.o,YNt),u.collider,qNt),!0}return!1},t.getSharedBody=function(t,e){return GNt.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;sIt.DynamicsWorld_addRigidBody(this._world,t.body,e>>>0,i>>>0)}},t.removeSharedBody=function(t){var e=this.bodies.indexOf(t);e>=0&&(fe(this.bodies,e),sIt.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;sIt.CollisionWorld_addCollisionObject(this._world,t.ghost,e>>>0,i>>>0)}},t.removeGhostObject=function(t){var e=this.ghosts.indexOf(t);e>=0&&(fe(this.ghosts,e),sIt.CollisionWorld_removeCollisionObject(this._world,t.ghost))},t.addCCT=function(t){if(this.ccts.indexOf(t)<0){this.ccts.push(t);var e=sIt.CharacterController_getGhostObject(t.impl),i=t.getGroup(),n=t.getMask();sIt.CollisionWorld_addCollisionObject(this._world,e,i>>>0,n>>>0),sIt.DynamicsWorld_addAction(this._world,t.impl)}},t.removeCCT=function(t){var e=this.ccts.indexOf(t);if(e>=0){fe(this.ccts,e);var i=sIt.CharacterController_getGhostObject(t.impl);sIt.CollisionWorld_removeCollisionObject(this._world,i),sIt.DynamicsWorld_removeAction(this._world,t.impl)}},t.addConstraint=function(t){var e=this.constraints.indexOf(t);e<0&&(this.constraints.push(t),sIt.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),sIt.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--;){jNt.push.apply(jNt,hIt.contacts),hIt.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)?oIt.type="onTriggerStay":(oIt.type="onTriggerEnter",this.triggerArrayMat.set(n.id,r.id,!0)),oIt.impl=i.impl,oIt.selfCollider=s,oIt.otherCollider=a,s.emit(oIt.type,oIt),oIt.selfCollider=a,oIt.otherCollider=s,a.emit(oIt.type,oIt),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)?hIt.type="onCollisionStay":(hIt.type="onCollisionEnter",this.collisionArrayMat.set(n.id,r.id,!0));for(var u=0;u0){var c=jNt.pop();c.impl=l,hIt.contacts.push(c)}else{var _=new XNt(hIt);_.impl=l,hIt.contacts.push(_)}}hIt.impl=i.impl,hIt.selfCollider=s,hIt.otherCollider=a,s.emit(hIt.type,hIt),hIt.selfCollider=a,hIt.otherCollider=s,a.emit(hIt.type,hIt),this._needSyncAfterEvents=!0}null==this.oldContactsDic.get(n.id,r.id)&&this.oldContactsDic.set(n.id,r.id,i)}}for(var f=this.oldContactsDic.getLength();f--;){var d=this.oldContactsDic.getKeyByIndex(f),p=this.oldContactsDic.getDataByKey(d),m=p.shape0,g=p.shape1,v=m.collider,y=g.collider;if(v&&y){var S=v.isTrigger||y.isTrigger;null==this.contactsDic.getDataByKey(d)&&(S?this.triggerArrayMat.get(m.id,g.id)&&(oIt.type="onTriggerExit",oIt.selfCollider=v,oIt.otherCollider=y,v.emit(oIt.type,oIt),oIt.selfCollider=y,oIt.otherCollider=v,y.emit(oIt.type,oIt),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)&&(jNt.push.apply(jNt,hIt.contacts),hIt.contacts.length=0,hIt.type="onCollisionExit",hIt.selfCollider=v,hIt.otherCollider=y,v.emit(hIt.type,hIt),hIt.selfCollider=y,hIt.otherCollider=v,y.emit(hIt.type,hIt),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.triggerArrayMat.get(n.id,r.id)?uIt.type="onControllerTriggerStay":(uIt.type="onControllerTriggerEnter",this.triggerArrayMat.set(n.id,r.id,!0)),uIt.impl=i.impl,uIt.collider=s,uIt.characterController=a,s.emit(uIt.type,uIt),uIt.collider=s,uIt.characterController=a,a.emit(uIt.type,uIt),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,_=l.collider,f=c.characterController;if(_&&f){var d=_.isTrigger;null==this.cctContactsDic.getDataByKey(h)&&d&&this.triggerArrayMat.get(l.id,c.id)&&(uIt.type="onControllerTriggerExit",uIt.collider=_,uIt.characterController=f,_.emit(uIt.type,uIt),uIt.collider=_,uIt.characterController=f,f.emit(uIt.type,uIt),this.triggerArrayMat.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;ZNt.controller=r.characterController,ZNt.collider=s.collider,ZNt.worldPosition.set(a.x,a.y,a.z),ZNt.worldNormal.set(o.x,o.y,o.z),ZNt.motionDirection.set(h.x,h.y,h.z),ZNt.motionLength=u,null===(e=ZNt.controller)||void 0===e||e.emit("onControllerColliderHit",ZNt),this._needSyncAfterEvents=!0}this.cctShapeEventDic.reset()},t.gatherConatactData=function(){for(var t=sIt.Dispatcher_getNumManifolds(this._dispatcher),e=0;e0){if(this.collider.convex){var i=this._getBtTriangleMesh(e);this._impl=sIt.ConvexTriangleMeshShape_new(i)}else this.btBVHMeshShape=iFt.getBulletBvhTriangleMeshShape(e.hash,e),this._impl=sIt.ScaledBvhTriangleMeshShape_new(this.btBVHMeshShape.bulletBvhTriangleMeshShapePtr,1,1,1);var n=lIt.instance.BT_V3_0;DIt(n,this._collider.node.worldScale),sIt.CollisionShape_setLocalScaling(this._impl,n),sIt.CollisionShape_setMargin(this._impl,.01),this.setCompound(this._compound),this.updateByReAdd(),this.setWrapper()}else this._impl=sIt.EmptyShape_static()}},i.onComponentSet=function(){this.setMesh(this.collider.mesh)},i.onDestroy=function(){this.collider.convex?this.refBtTriangleMesh&&sIt._safe_delete(this.refBtTriangleMesh,tIt.EBulletTypeTriangleMesh):this.btBVHMeshShape&&(this.btBVHMeshShape.reference=!1),t.prototype.onDestroy.call(this)},i.updateScale=function(){t.prototype.updateScale.call(this);var e=lIt.instance.BT_V3_0;DIt(e,this._collider.node.worldScale),sIt.CollisionShape_setLocalScaling(this._impl,e),this.updateCompoundTransform()},i._getBtTriangleMesh=function(t){return this.refBtTriangleMesh=sIt.TriangleMesh_new(),OIt(this.refBtTriangleMesh,t),this.refBtTriangleMesh},n(e,[{key:"collider",get:function(){return this._collider}}]),e}(zNt),aFt=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=lIt.instance.BT_V3_0;sIt.Vec3_set(t,.5,1,.5),this._impl=sIt.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(tn(a.x,a.z))):0===o?(s=e*Math.abs(a.x),r=t*Math.abs(tn(a.y,a.z))):(s=e*Math.abs(a.z),r=t*Math.abs(tn(a.x,a.y))),sIt.CylinderShape_updateProp(this._impl,r,s/2,o),this.updateCompoundTransform()},n(e,[{key:"collider",get:function(){return this._collider}}]),e}(zNt),oFt=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=sIt.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(tn(a.x,a.z))):0===o?(s=e*Math.abs(a.x),r=t*Math.abs(tn(a.y,a.z))):(s=e*Math.abs(a.z),r=t*Math.abs(tn(a.x,a.y))),sIt.ConeShape_setRadius(this._impl,r),sIt.ConeShape_setHeight(this._impl,s),sIt.ConeShape_setConeUpIndex(this._impl,o);var h=lIt.instance.BT_V3_0;sIt.Vec3_set(h,1,1,1),sIt.CollisionShape_setLocalScaling(this._impl,h),this.updateCompoundTransform()},n(e,[{key:"impl",get:function(){return this._impl}},{key:"collider",get:function(){return this._collider}}]),e}(zNt),hFt=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=sIt.TerrainShape_new(i,n,this._bufPtr,1,s,a);var l=lIt.instance.BT_V3_0;sIt.Vec3_set(l,this._tileSize,1,this._tileSize),sIt.CollisionShape_setLocalScaling(this._impl,l),this.setCompound(this._compound),this.updateByReAdd(),this.setWrapper()}else this._impl=sIt.EmptyShape_static()}},i.onComponentSet=function(){this.setTerrain(this.collider.terrain)},i.onDestroy=function(){this._bufPtr&&sIt._free(this._bufPtr),t.prototype.onDestroy.call(this)},i.setCenter=function(t){gn.copy(cIt,t),cIt.add(this._localOffset),DIt(sIt.Transform_getOrigin(this.transform),cIt),this.updateCompoundTransform()},n(e,[{key:"collider",get:function(){return this._collider}}]),e}(zNt),uFt=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=sIt.SimplexShape_new();for(var t=this.collider.shapeType,e=this.collider.vertices,i=lIt.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=eDt.instance.physicsWorld.debugDrawConstraintSize;sIt.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(){sIt._safe_delete(this._impl,tIt.EBulletTypeTypedConstraint),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}(),_Ft=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=lIt.instance.BT_V3_0;gn.multiply(cIt,t.node.worldScale,t.pivotA),DIt(e,cIt),sIt.P2PConstraint_setPivotA(this._impl,e),t.connectedBody||this.setPivotB(t.pivotB)},i.setPivotB=function(){var t=this.constraint,e=this._rigidBody.node,i=lIt.instance.BT_V3_0,n=t.connectedBody;n?(gn.multiply(cIt,n.node.worldScale,t.pivotB),DIt(i,cIt)):(gn.multiply(cIt,e.worldScale,t.pivotA),gn.transformQuat(cIt,cIt,e.worldRotation),gn.add(cIt,cIt,e.worldPosition),DIt(i,cIt)),sIt.P2PConstraint_setPivotB(this._impl,i)},i.onComponentSet=function(){var t=this.constraint.connectedBody,e=this._rigidBody.body.impl,i=t?t.body.impl:sIt.TypedConstraint_getFixedBody(),n=lIt.instance.BT_V3_0,r=lIt.instance.BT_V3_1;this._impl=sIt.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}(cFt),fFt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.setBreakForce=function(t){sIt.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:sIt.TypedConstraint_getFixedBody(),n=lIt.instance.BT_TRANSFORM_0,r=lIt.instance.BT_TRANSFORM_1;this._impl=sIt.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=cIt,n=dIt,r=lIt.instance.BT_TRANSFORM_0,s=lIt.instance.BT_TRANSFORM_1,a=lIt.instance.BT_QUAT_0,o=mIt;if(Vn.fromRT(o,e.node.worldRotation,e.node.worldPosition),Vn.invert(o,o),Vn.getRotation(n,o),Vn.getTranslation(i,o),DIt(sIt.Transform_getOrigin(r),i),MIt(a,n),sIt.Transform_setRotation(r,a),t){var h=t.body.sharedBody;Vn.fromRT(o,h.node.worldRotation,h.node.worldPosition),Vn.invert(o,o),Vn.getRotation(n,o),Vn.getTranslation(i,o),DIt(sIt.Transform_getOrigin(s),i),MIt(a,n),sIt.Transform_setRotation(s,a)}else sIt.Transform_setIdentity(s);sIt.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}(cFt),dFt=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?sIt.HingeConstraint_setLimit(this._impl,Vi(this.constraint.lowerLimit),Vi(this.constraint.upperLimit),.9,.3,1):sIt.HingeConstraint_setLimit(this._impl,1,0,.9,.3,1)},i.setLowerLimit=function(){this.constraint.limitEnabled&&sIt.HingeConstraint_setLimit(this._impl,Vi(this.constraint.lowerLimit),Vi(this.constraint.upperLimit),.9,.3,1)},i.setUpperLimit=function(){this.constraint.limitEnabled&&sIt.HingeConstraint_setLimit(this._impl,Vi(this.constraint.lowerLimit),Vi(this.constraint.upperLimit),.9,.3,1)},i.setMotorEnabled=function(t){sIt.HingeConstraint_enableMotor(this._impl,t);var e=-this.constraint.motorVelocity/60,i=LIt(this.constraint.motorForceLimit,eDt.instance.fixedTimeStep);sIt.HingeConstraint_setMotorVelocity(this._impl,e),sIt.HingeConstraint_setMaxMotorImpulse(this._impl,i)},i.setMotorVelocity=function(t){if(this.constraint.motorEnabled){var e=-t/60;sIt.HingeConstraint_setMotorVelocity(this._impl,e)}},i.setMotorForceLimit=function(t){if(this.constraint.motorEnabled){var e=LIt(t,eDt.instance.fixedTimeStep);sIt.HingeConstraint_setMaxMotorImpulse(this._impl,e)}},i.onComponentSet=function(){var t=this.constraint.connectedBody,e=this._rigidBody.body.impl,i=t?t.body.impl:sIt.TypedConstraint_getFixedBody(),n=lIt.instance.BT_TRANSFORM_0,r=lIt.instance.BT_TRANSFORM_1;this._impl=sIt.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=cIt,n=dIt,r=pIt,s=lIt.instance.BT_TRANSFORM_0;gn.multiply(i,e.worldScale,t.pivotA),DIt(sIt.Transform_getOrigin(s),i);var a=lIt.instance.BT_QUAT_0;gn.normalize(i,t.axis),Bn.rotationTo(r,gn.UNIT_Z,i),MIt(a,r),sIt.Transform_setRotation(s,a);var o=lIt.instance.BT_TRANSFORM_1,h=this.constraint.connectedBody;h?(gn.multiply(i,h.node.worldScale,t.pivotB),Bn.multiply(r,e.worldRotation,r),Bn.invert(n,h.node.worldRotation),Bn.multiply(r,n,r)):(gn.multiply(i,e.worldScale,t.pivotA),gn.transformQuat(i,i,e.worldRotation),gn.add(i,i,e.worldPosition),Bn.multiply(r,e.worldRotation,r)),DIt(sIt.Transform_getOrigin(o),i),MIt(a,r),sIt.Transform_setRotation(o,a),sIt.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}(cFt);!function(t){t[t.RO_XYZ=0]="RO_XYZ",t[t.RO_XZY=1]="RO_XZY",t[t.RO_YXZ=2]="RO_YXZ",t[t.RO_YZX=3]="RO_YZX",t[t.RO_ZXY=4]="RO_ZXY",t[t.RO_ZYX=5]="RO_ZYX"}(nFt||(nFt={})),function(t){t[t.X=0]="X",t[t.Y=1]="Y",t[t.Z=2]="Z",t[t.TWIST=3]="TWIST",t[t.SWING1=4]="SWING1",t[t.SWING2=5]="SWING2"}(rFt||(rFt={}));var pFt=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 DEt.LOCKED:sIt.Generic6DofSpring2Constraint_setLimit(this._impl,e,0,0);break;case DEt.LIMITED:sIt.Generic6DofSpring2Constraint_setLimit(this._impl,e,i,n);break;case DEt.FREE:sIt.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:gn.toArray(r,i.lower),gn.toArray(s,i.upper),o=r[t],a=s[t];break;case 3:o=-(a=.5*Vi(n.twistExtent));break;case 4:o=-(a=.5*Vi(n.swingExtent1));break;case 5:o=-(a=.5*Vi(n.swingExtent2));break;default:H("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,rFt.TWIST,.5*-Vi(t),.5*Vi(t)),this._setLimit(n.swingMotion1,rFt.SWING1,.5*-Vi(e),.5*Vi(e)),this._setLimit(n.swingMotion2,rFt.SWING2,.5*-Vi(i),.5*Vi(i))},i.setSwingSoftConstraint=function(t){sIt.Generic6DofSpring2Constraint_enableSpring(this._impl,rFt.SWING1,t),sIt.Generic6DofSpring2Constraint_enableSpring(this._impl,rFt.SWING2,t)},i.setTwistSoftConstraint=function(t){sIt.Generic6DofSpring2Constraint_enableSpring(this._impl,rFt.TWIST,t)},i.setLinearSoftConstraint=function(t){sIt.Generic6DofSpring2Constraint_enableSpring(this._impl,rFt.X,t),sIt.Generic6DofSpring2Constraint_enableSpring(this._impl,rFt.Y,t),sIt.Generic6DofSpring2Constraint_enableSpring(this._impl,rFt.Z,t)},i.setLinearStiffness=function(t){sIt.Generic6DofSpring2Constraint_setStiffness(this._impl,rFt.X,t),sIt.Generic6DofSpring2Constraint_setStiffness(this._impl,rFt.Y,t),sIt.Generic6DofSpring2Constraint_setStiffness(this._impl,rFt.Z,t)},i.setLinearDamping=function(t){sIt.Generic6DofSpring2Constraint_setDamping(this._impl,rFt.X,t),sIt.Generic6DofSpring2Constraint_setDamping(this._impl,rFt.Y,t),sIt.Generic6DofSpring2Constraint_setDamping(this._impl,rFt.Z,t)},i.setLinearRestitution=function(t){sIt.Generic6DofSpring2Constraint_setBounce(this._impl,rFt.X,t),sIt.Generic6DofSpring2Constraint_setBounce(this._impl,rFt.Y,t),sIt.Generic6DofSpring2Constraint_setBounce(this._impl,rFt.Z,t)},i.setSwingStiffness=function(t){sIt.Generic6DofSpring2Constraint_setStiffness(this._impl,rFt.SWING1,t),sIt.Generic6DofSpring2Constraint_setStiffness(this._impl,rFt.SWING2,t)},i.setSwingDamping=function(t){sIt.Generic6DofSpring2Constraint_setDamping(this._impl,rFt.SWING1,t),sIt.Generic6DofSpring2Constraint_setDamping(this._impl,rFt.SWING2,t)},i.setSwingRestitution=function(t){sIt.Generic6DofSpring2Constraint_setBounce(this._impl,rFt.SWING1,t),sIt.Generic6DofSpring2Constraint_setBounce(this._impl,rFt.SWING2,t)},i.setTwistStiffness=function(t){sIt.Generic6DofSpring2Constraint_setStiffness(this._impl,rFt.TWIST,t)},i.setTwistDamping=function(t){sIt.Generic6DofSpring2Constraint_setDamping(this._impl,rFt.TWIST,t)},i.setTwistRestitution=function(t){sIt.Generic6DofSpring2Constraint_setBounce(this._impl,rFt.TWIST,t)},i.setDriverMode=function(t,e){e===BEt.DISABLED?sIt.Generic6DofSpring2Constraint_enableMotor(this._impl,t,!1):e===BEt.SERVO?(sIt.Generic6DofSpring2Constraint_enableMotor(this._impl,t,!0),sIt.Generic6DofSpring2Constraint_setServo(this._impl,t,!0)):e===BEt.INDUCTION&&(sIt.Generic6DofSpring2Constraint_enableMotor(this._impl,t,!0),sIt.Generic6DofSpring2Constraint_setServo(this._impl,t,!1))},i._updateMotorTargetAndVelocity=function(t){var e=BEt.DISABLED,i=0,n=0,r=0,s=this.constraint.linearDriverSettings,a=this.constraint.angularDriverSettings;switch(t){case 0:i=rFt.X,e=s.xDrive,n=s.targetPosition.x,r=-s.targetVelocity.x;break;case 1:i=rFt.Y,e=s.yDrive,n=s.targetPosition.y,r=-s.targetVelocity.y;break;case 2:i=rFt.Z,e=s.zDrive,n=s.targetPosition.z,r=-s.targetVelocity.z;break;case 3:i=rFt.TWIST,e=a.twistDrive,n=-Vi(a.targetOrientation.x),r=-Vi(a.targetVelocity.x);break;case 4:i=rFt.SWING1,e=a.swingDrive1,n=-Vi(a.targetOrientation.y),r=-Vi(a.targetVelocity.y);break;case 5:i=rFt.SWING2,e=a.swingDrive2,n=-Vi(a.targetOrientation.z),r=-Vi(a.targetVelocity.z)}var o=t>2?a.strength:s.strength;sIt.Generic6DofSpring2Constraint_setServoTarget(this._impl,i,n),e===BEt.SERVO?t>2?sIt.Generic6DofSpring2Constraint_setTargetVelocity(this._impl,i,-n*o*.1):sIt.Generic6DofSpring2Constraint_setTargetVelocity(this._impl,i,n*o*.1):e===BEt.INDUCTION&&sIt.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){sIt.Generic6DofSpring2Constraint_setMaxMotorForce(this._impl,rFt.X,t),sIt.Generic6DofSpring2Constraint_setMaxMotorForce(this._impl,rFt.Y,t),sIt.Generic6DofSpring2Constraint_setMaxMotorForce(this._impl,rFt.Z,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){sIt.Generic6DofSpring2Constraint_setMaxMotorForce(this._impl,rFt.TWIST,t),sIt.Generic6DofSpring2Constraint_setMaxMotorForce(this._impl,rFt.SWING1,t),sIt.Generic6DofSpring2Constraint_setMaxMotorForce(this._impl,rFt.SWING2,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=LIt(Math.max(this.constraint.breakForce,this.constraint.breakTorque),eDt.instance.fixedTimeStep);sIt.TypedConstraint_setMaxImpulseThreshold(this._impl,t)},i.setBreakTorque=function(){var t=LIt(Math.max(this.constraint.breakForce,this.constraint.breakTorque),eDt.instance.fixedTimeStep);sIt.TypedConstraint_setMaxImpulseThreshold(this._impl,t)},i.onComponentSet=function(){var t=this.constraint.connectedBody,e=this._rigidBody.body.impl,i=t&&t.body.impl||sIt.TypedConstraint_getFixedBody(),n=lIt.instance.BT_TRANSFORM_0,r=lIt.instance.BT_TRANSFORM_1;this._impl=sIt.Generic6DofSpring2Constraint_new(e,i,n,r,nFt.RO_YZX);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=cIt,n=dIt,r=pIt,s=lIt.instance.BT_TRANSFORM_0;gn.multiply(i,e.worldScale,t.pivotA),DIt(sIt.Transform_getOrigin(s),i);var a=lIt.instance.BT_QUAT_0,o=t.axis,h=t.secondaryAxis,u=gn.cross(_It,o,h);Vn.set(mIt,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),MIt(a,n),sIt.Transform_setRotation(s,a);var l=lIt.instance.BT_TRANSFORM_1,c=this.constraint.connectedBody;c?(Bn.multiply(n,e.worldRotation,n),Bn.invert(r,c.node.worldRotation),Bn.multiply(n,r,n),t.autoPivotB?(gn.multiply(i,t.node.worldScale,t.pivotA),gn.transformQuat(i,i,e.worldRotation),gn.add(i,i,t.node.worldPosition),gn.subtract(i,i,c.node.worldPosition),gn.transformQuat(i,i,r)):gn.multiply(i,c.node.worldScale,t.pivotB)):(gn.multiply(i,e.worldScale,t.pivotA),gn.transformQuat(i,i,e.worldRotation),gn.add(i,i,e.worldPosition),Bn.multiply(n,e.worldRotation,n)),DIt(sIt.Transform_getOrigin(l),i),MIt(a,n),sIt.Transform_setRotation(l,a),sIt.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}(cFt),mFt=new gn(0,0,0),gFt=new gn(0,0,0);new gn(0,0,0);var vFt=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=PEt.DEFAULT,this._collisionFilterMask=-1,this.id=t.idCounter++,this.wrappedWorld=eDt.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=eDt.instance.collisionMatrix[e];return this._collisionFilterGroup=e,this._collisionFilterMask=i,this.onComponentSet(),0!==this._impl||(H("[Physics]: Initialize BulletCharacterController failed"),!1)},e.setWrapper=function(){lIt.setWrapper(this._impl,aIt.CCT_CACHE_NAME,this);var t=sIt.CharacterController_getCollisionShape(this.impl);lIt.setWrapper(t,aIt.CCT_CACHE_NAME,this)},e.onEnable=function(){this._isEnabled=!0,this._impl||this.onComponentSet(),this.setDetectCollisions(!1),this.setOverlapRecovery(!0),eDt.instance.physicsWorld.addCCT(this),this.setWrapper()},e.onDisable=function(){this._isEnabled=!1,this.wrappedWorld.removeCCT(this),this.onDestroy()},e.onDestroy=function(){sIt._safe_delete(this._impl,tIt.EBulletTypeCharacterController),lIt.delWrapper(this._impl,aIt.CCT_CACHE_NAME),this._impl=0},e.onLoad=function(){},e.getPosition=function(t){this._impl&&BIt(t,sIt.CharacterController_getPosition(this.impl))},e.setPosition=function(t){this._impl&&(DIt(sIt.CharacterController_getPosition(this.impl),t),this.syncPhysicsToScene())},e.setContactOffset=function(t){this._impl&&sIt.CharacterController_setContactOffset(this._impl,t)},e.setStepOffset=function(t){this._impl&&sIt.CharacterController_setStepOffset(this._impl,t)},e.setSlopeLimit=function(t){this._impl&&sIt.CharacterController_setSlopeLimit(this._impl,Ye(t))},e.setDetectCollisions=function(t){this._impl&&sIt.CharacterController_setCollision(this.impl,t)},e.setOverlapRecovery=function(t){this._impl&&sIt.CharacterController_setOverlapRecovery(this.impl,t)},e.onGround=function(){return(4&this._btCollisionFlags)>0},e.syncSceneToPhysics=function(){var t=this.characterController.node;t.hasChangedFlags&&(t.hasChangedFlags&mm.SCALE&&this.syncScale(),t.hasChangedFlags&mm.POSITION&&(gn.add(mFt,t.worldPosition,this.scaledCenter),this.setPosition(mFt)))},e.syncPhysicsToScene=function(){this.getPosition(mFt),mFt.subtract(this.scaledCenter),this._comp.node.setWorldPosition(mFt)},e.syncScale=function(){this.updateScale()},e.move=function(t,e,i){if(this._isEnabled){var n=lIt.instance.BT_V3_0;sIt.Vec3_set(n,t.x,t.y,t.z),this._btCollisionFlags=sIt.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&&(eDt.instance.physicsWorld.removeCCT(this),eDt.instance.physicsWorld.addCCT(this),this._dirty=!1)},e.onShapeHitExt=function(t){var e=sIt.ControllerShapeHit_getHitShape(t),i=eDt.instance.physicsWorld;i.cctShapeEventDic.get(this.impl,e);var n=new gn;BIt(n,sIt.ControllerHit_getHitWorldPos(t));var r=new gn;BIt(r,sIt.ControllerHit_getHitWorldNormal(t));var s=new gn;BIt(s,sIt.ControllerHit_getHitMotionDir(t));var a=sIt.ControllerHit_getHitMotionLength(t),o=lIt.getWrapper(e,zNt.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 gn.multiply(gFt,this._comp.center,this._comp.node.worldScale),gFt}}]),t}();vFt.idCounter=0;var yFt,SFt,TFt,AFt,bFt,EFt,CFt,xFt,wFt=new gn(0,0,0),RFt=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(wFt),wFt.add(this.scaledCenter);var t=lIt.instance.BT_V3_0;sIt.Vec3_set(t,wFt.x,wFt.y,wFt.z);var e=gn.UNIT_Y,i=lIt.instance.BT_V3_1;sIt.Vec3_set(i,e.x,e.y,e.z);var n=sIt.ControllerHitReport.implement(LNt).$$.ptr,r=eDt.instance.physicsWorld,s=sIt.CapsuleCharacterControllerDesc_new(Ye(this.component.slopeLimit),this.component.stepOffset,this.component.skinWidth,i,t,n,this.component.radius,this.component.height);this._impl=sIt.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*tn(t.x,t.z),i=this.component.height*Math.abs(t.y);sIt.CapsuleCharacterController_setRadius(this.impl,e),sIt.CapsuleCharacterController_setHeight(this.impl,i),this._dirty=!0},n(e,[{key:"component",get:function(){return this._comp}}]),e}(vFt),IFt=new gn(0,0,0),DFt=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(IFt),IFt.add(this.scaledCenter);var t=lIt.instance.BT_V3_0;sIt.Vec3_set(t,IFt.x,IFt.y,IFt.z);var e=gn.UNIT_Y,i=lIt.instance.BT_V3_1;sIt.Vec3_set(i,e.x,e.y,e.z);var n=sIt.ControllerHitReport.implement(LNt).$$.ptr,r=eDt.instance.physicsWorld,s=sIt.BoxCharacterControllerDesc_new(Ye(this.component.slopeLimit),this.component.stepOffset,this.component.skinWidth,i,t,n,this.component.halfHeight,this.component.halfSideExtent,this.component.halfForwardExtent);this._impl=sIt.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;sIt.BoxCharacterController_setHalfSideExtent(this.impl,this.component.halfSideExtent*t.x),sIt.BoxCharacterController_setHalfHeight(this.impl,this.component.halfHeight*t.y),sIt.BoxCharacterController_setHalfForwardExtent(this.impl,this.component.halfForwardExtent*t.z),this._dirty=!0},n(e,[{key:"component",get:function(){return this._comp}}]),e}(vFt);EB.once(bB.EVENT_PRE_SUBSYSTEM_INIT,(function(){WRt.register("bullet",{PhysicsWorld:JNt,RigidBody:ONt,BoxShape:$Nt,SphereShape:tFt,CapsuleShape:eFt,TrimeshShape:sFt,CylinderShape:aFt,ConeShape:oFt,TerrainShape:hFt,SimplexShape:uFt,PlaneShape:lFt,PointToPointConstraint:_Ft,HingeConstraint:dFt,FixedConstraint:fFt,ConfigurableConstraint:pFt,BoxCharacterController:DFt,CapsuleCharacterController:RFt})})),function(t){t[t.BOX=0]="BOX",t[t.SPHERE=1]="SPHERE",t[t.CYLINDER=2]="CYLINDER",t[t.CONE=3]="CONE",t[t.CAPSULE=4]="CAPSULE",t[t.TORUS=5]="TORUS",t[t.PLANE=6]="PLANE",t[t.QUAD=7]="QUAD"}(xFt||(xFt={})),we(xFt);var BFt=t("fW",(yFt=eo("cc.Primitive"),SFt=Lo(xFt),yFt(((CFt=function(t){function e(e){var i;return void 0===e&&(e=xFt.BOX),(i=t.call(this)||this).type=bFt&&bFt(),i.info=EFt&&EFt(),i.type=e,i}return s(e,t),e.prototype.onLoaded=function(){oM(Hq[xFt[this.type].toLowerCase()](this.info),this)},e}(ZB)).PrimitiveType=xFt,bFt=ja((AFt=CFt).prototype,"type",[SFt],(function(){return xFt.BOX})),EFt=ja(AFt.prototype,"info",[lo],(function(){return{}})),TFt=AFt))||TFt));S.Primitive=BFt,S.primitives=Hq;var MFt,PFt=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}(),OFt=eo("cc.PerfCounter")(MFt=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}(PFt))||MFt,LFt="0123456789. ",NFt=500,FFt={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,".":10},kFt={fps:{desc:"Framerate (FPS)",below:30,average:NFt,isInteger:!0},draws:{desc:"Draw call",isInteger:!0},frame:{desc:"Frame time (ms)",min:0,max:50,average:NFt},instances:{desc:"Instance Count",isInteger:!0},tricount:{desc:"Triangle",isInteger:!0},logic:{desc:"Game Logic (ms)",min:0,max:50,average:NFt,color:"#080"},physics:{desc:"Physics (ms)",min:0,max:50,average:NFt},render:{desc:"Renderer (ms)",min:0,max:50,average:NFt,color:"#f90"},present:{desc:"Present (ms)",min:0,max:50,average:NFt,color:"#f90"},textureMemory:{desc:"GFX Texture Mem(M)"},bufferMemory:{desc:"GFX Buffer Mem(M)"}},GFt=t("fX",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 Jc,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(kFt).length+1),e._wordHeight=0,e._eachNumWidth=0,e._totalLines=0,e.lastTime=0,e._canvas=A.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(){Me.querySettings(De.Category.PROFILING,"showFPS")?this.showStats():this.hideStats()},i.isShowingStats=function(){return this._showFPS},i.hideStats=function(){this._showFPS&&(this._rootNode&&(this._rootNode.active=!1),S.director.off(S.Director.EVENT_BEFORE_UPDATE,this.beforeUpdate,this),S.director.off(S.Director.EVENT_AFTER_UPDATE,this.afterUpdate,this),S.director.off(S.Director.EVENT_BEFORE_PHYSICS,this.beforePhysics,this),S.director.off(S.Director.EVENT_AFTER_PHYSICS,this.afterPhysics,this),S.director.off(S.Director.EVENT_BEFORE_DRAW,this.beforeDraw,this),S.director.off(S.Director.EVENT_AFTER_RENDER,this.afterRender,this),S.director.off(S.Director.EVENT_AFTER_DRAW,this.afterPresent,this),this._showFPS=!1,ID.root.pipeline.profiler=null,S.game.config.showFPS=!1)},i.showStats=function(){if(!this._showFPS){if(!this._device){var t=S.director.root;this._device=Ff.gfxDevice,this._swapchain=t.mainWindow.swapchain}this.generateCanvas(),this.generateStats(),S.game.once(S.Game.EVENT_ENGINE_INITED,this.generateNode,this),S.game.on(S.Game.EVENT_RESTART,this.generateNode,this),this._rootNode&&(this._rootNode.active=!0),S.director.on(S.Director.EVENT_BEFORE_UPDATE,this.beforeUpdate,this),S.director.on(S.Director.EVENT_AFTER_UPDATE,this.afterUpdate,this),S.director.on(S.Director.EVENT_BEFORE_PHYSICS,this.beforePhysics,this),S.director.on(S.Director.EVENT_AFTER_PHYSICS,this.afterPhysics,this),S.director.on(S.Director.EVENT_BEFORE_DRAW,this.beforeDraw,this),S.director.on(S.Director.EVENT_AFTER_RENDER,this.afterRender,this),S.director.on(S.Director.EVENT_AFTER_DRAW,this.afterPresent,this),this._showFPS=!0,this._canvasDone=!0,this._statsDone=!0,S.game.config.showFPS=!0}},i.generateCanvas=function(){if(!this._canvasDone){this._ctx&&this._canvas&&(this._canvas.width=280,this._canvas.height=280,this._canvas.style.width=""+this._canvas.width,this._canvas.style.height=""+this._canvas.height,this._ctx.font="23px Arial",this._ctx.textBaseline="top",this._ctx.fillStyle="#fff",this._texture=this._device.createTexture(new u_(hc.TEX2D,uc.SAMPLED|uc.TRANSFER_DST,ec.RGBA8,280,280)),this._region.texExtent.width=280,this._region.texExtent.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 kFt){var n=kFt[i];this._ctx.fillText(n.desc,0,e*this._lineHeight),n.counter=new OFt(i,n,t),e++}this._totalLines=e,this._wordHeight=this._totalLines*this._lineHeight/this._canvas.height;for(var r=0;r=0;o--){var h=8*i+o,u=a[a.length-(8-o)],l=FFt[u];void 0===l&&(l=11),n[h]=l}i++}}}},n(e,[{key:"_stats",get:function(){return tt(16381),this._profilerStats}},{key:"stats",get:function(){return this._profilerStats}}]),e}(Ml)),VFt=t("fY",new GFt);ID.registerSystem("profiler",VFt,0),S.profiler=VFt;var UFt=function(){function t(t){this.jointTexturePool=void 0,this.jointAnimationInfo=void 0,this.jointTexturePool=new Xj(t),this.jointAnimationInfo=new jj(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}();S.internal.DataPoolManager=UFt;var zFt,HFt,WFt,XFt,jFt,YFt,qFt,KFt,QFt,ZFt,JFt,$Ft,tkt,ekt,ikt,nkt=new Vn,rkt=new Vn,skt=t("f_",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=S.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=Bj.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;i=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=Mkt/Float32Array.BYTES_PER_ELEMENT,s=new Uint8Array(Float32Array.BYTES_PER_ELEMENT*r*i),a=new Uint16Array(n),o=_kt.wasmUtil.wasm.HEAPU8,h=e.vPtr,u=i*Float32Array.BYTES_PER_ELEMENT*r;s.set(o.subarray(h,h+u));var l=e.iPtr,c=Uint16Array.BYTES_PER_ELEMENT*n;new Uint8Array(a.buffer).set(o.subarray(l,l+c));var _=new Okt;_.vCount=i,_.iCount=n,_.vData=s,_.iData=a;for(var f=e.getData(),d=f.size(),p=0;p0)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&&_kt.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 _kt.Skeleton(i),s=new Skt;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 Nkt(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&&_kt.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}();gkt=Fkt,Fkt.FrameTime=Tkt,Fkt.sharedCache=new gkt;var kkt=(Akt=eo("sp.SkeletonData"),bkt=Lo([lm]),Ekt=Lo([si]),Akt((xkt=function(t){function e(){var e;return(e=t.call(this)||this)._skeletonJson=wkt&&wkt(),e.textures=Rkt&&Rkt(),e.textureNames=Ikt&&Ikt(),e.scale=Dkt&&Dkt(),e._atlasText=Bkt&&Bkt(),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 hg(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||H(this.name+" no textures found!"),null;var e=_kt.wasmUtil.querySpineSkeletonDataByUUID(this._uuid);if(e)this._skeletonCache=e;else if(this._skeletonJson)this._skeletonCache=_kt.wasmUtil.createSpineSkeletonDataWithJson(this.skeletonJsonStr,this._atlasText),_kt.wasmUtil.registerSpineSkeletonDataWithUUID(this._skeletonCache,this._uuid);else{var i=new Uint8Array(this._nativeAsset),n=i.length,r=_kt.wasmUtil.queryStoreMemory(n);_kt.wasmUtil.wasm.HEAPU8.subarray(r,r+n).set(i),this._skeletonCache=_kt.wasmUtil.createSpineSkeletonDataWithBinary(n,this._atlasText),_kt.wasmUtil.registerSpineSkeletonDataWithUUID(this._skeletonCache,this._uuid)}return this._skeletonCache},i.getSkinsEnum=function(){if(this._skinsEnum)return this._skinsEnum;var t=this.getRuntimeData(!0);if(t){for(var e=t.skins,i={},n=0;n1)return this._animsEnum;var t=this.getRuntimeData(!0);if(t){for(var e={"":0},i=t.animations,n=0;n"]=0]=""}(vGt||(vGt={})),we(vGt),function(t){t[t.COLORED_TEXTURED=0]="COLORED_TEXTURED",t[t.TWO_COLORED=1]="TWO_COLORED"}(yGt||(yGt={}));var bGt=(Vkt=eo("sp.Skeleton.SpineSocket"),Ukt=Lo(hg),Vkt((Hkt=function(t,e){void 0===t&&(t=""),void 0===e&&(e=null),this.path=Wkt&&Wkt(),this.target=Xkt&&Xkt(),this.path=t,this.target=e},Wkt=ja(Hkt.prototype,"path",[lo],(function(){return""})),Xkt=ja(Hkt.prototype,"target",[Ukt,lo],(function(){return null})),zkt=Hkt))||zkt);ne(bGt,"sp.Skeleton.SpineSocket");var EGt=(jkt=eo("sp.Skeleton"),Ykt=Lo(kkt),qkt=Lo(gGt),Kkt=Lo(vGt),Qkt=Lo(mGt),Zkt=Lo([bGt]),Jkt=Lo(zT),jkt(((pGt=function(t){function e(){var e;return(e=t.call(this)||this)._skeletonData=eGt&&eGt(),e.defaultSkin=iGt&&iGt(),e.defaultAnimation=nGt&&nGt(),e._premultipliedAlpha=rGt&&rGt(),e._timeScale=sGt&&sGt(),e._preCacheMode=aGt&&aGt(),e._cacheMode=oGt&&oGt(),e._sockets=hGt&&hGt(),e._useTint=uGt&&uGt(),e._debugMesh=lGt&&lGt(),e._debugBones=cGt&&cGt(),e._debugSlots=_Gt&&_Gt(),e._enableBatch=fGt&&fGt(),e._runtimeData=null,e._skeleton=null,e._instance=null,e._state=null,e._textures=[],e._skeletonInfo=null,e._animationName="",e._skinName="",e._drawList=new Rs((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._slotTextures=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.loop=dGt&&dGt(),e._useVertexOpacity=!0,e._startEntry={animation:{name:""},trackIndex:0},e._endEntry={animation:{name:""},trackIndex:0},e._startSlotIndex=-1,e._endSlotIndex=-1,e._instance=new _kt.SkeletonInstance,e._instance.dtRate=1*e._timeScale,e._instance.isCache=e.isAnimationCached(),e.attachUtil=new TGt,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(),Gkt.getInstance().add(this)},i.onDisable=function(){t.prototype.onDisable.call(this),this._instance&&(this._instance.enable=!1),Gkt.getInstance().remove(this)},i.onDestroy=function(){var e;this._eventListenerID>0&&(Skt.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)||void 0===e||e.clear(),this._slotTextures=null,this._cachedSockets.clear(),this._socketNodes.clear(),this._animCache=null,Gkt.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.defaultAnimation&&(this.animation=this.defaultAnimation.toString()),this.defaultSkin&&""!==this.defaultSkin&&this.setSkin(this.defaultSkin),this._updateUseTint(),this._indexBoneSockets(),this._updateSocketBindings(),this.attachUtil.init(this),this._preCacheMode=this._cacheMode)},i.setSkeletonData=function(t){var e=this._skeletonCache;if(this._cacheMode===mGt.SHARED_CACHE?this._skeletonCache=Fkt.sharedCache:this._cacheMode===mGt.PRIVATE_CACHE?(this._skeletonCache=new Fkt,this._skeletonCache.enablePrivateMode()):this._skeletonCache=null,e!==this._skeletonCache&&this._destroySkeletonInfo(e),this.isAnimationCached()){(this.debugBones||this.debugSlots)&&z("Debug bones or slots is invalid in cached mode");var i=this._skeletonCache.getSkeletonInfo(this._skeletonData);this._skeletonInfo!==i&&(this._destroySkeletonInfo(this._skeletonCache),this._skeletonInfo=this._skeletonCache.createSkeletonInfo(this._skeletonData),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()?z("Slots visible range can not be modified in cached mode."):(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 Q(7511),null;if(!this._skeleton.data.findAnimation(e))return Q(7509,e),null;var n=null;if(void 0===i&&(i=!0),this._playTimes=i?0:1,this.isAnimationCached()){if(0!==t&&z("Track index can not greater than 0 in cached mode."),!this._skeletonCache)return null;var r,s=this._skeletonCache.getAnimationCache(this._skeletonData.uuid,e);s||null===(r=s=this._skeletonCache.initAnimationCache(this.skeletonData.uuid,this._skeletonData,e))||void 0===r||r.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,n=this._instance.setAnimation(t,e,i);return this.markForUpdateRenderData(),n},i.addAnimation=function(t,e,i,n){if(n=n||0,this.isAnimationCached())return 0!==t&&z("Track index can not greater than 0 in cached mode."),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?void 0:r.addAnimationWith(t,s,i,n):(Q(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())z("'getCurrent' interface can not be invoked in cached mode.");else if(this._state)return this._state.getCurrent(t);return null},i.setSkin=function(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?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=Fkt.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._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),this._assembler&&this._skeleton&&(this._renderData=this._assembler.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 hg("DEBUG_DRAW_NODE");t.layer=this.node.layer,t.hideFlags|=Ms.Flags.DontSave|Ms.Flags.HideInHierarchy;var e=t.addComponent(AF);e.lineWidth=5,e.strokeColor=new En(255,0,0,255),this._debugRenderer=e,t.parent=this.node,this.node.on(vm.LAYER_CHANGED,this._applyLayer,this)}this.isAnimationCached()?z("Debug bones or slots is invalid in cached mode"):this._instance.setDebugMode(!0)}else this._debugRenderer&&(this.node.off(vm.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._uiProps.uiTransformComp,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.node._uiProps.opacity;if(this._tempColor.r!==this._color.r||this._tempColor.g!==this._color.g||this._tempColor.b!==this._color.b||this._tempColor.a!==t){this.node._uiProps.colorDirty=!0,this._tempColor.r=this._color.r,this._tempColor.g=this._color.g,this._tempColor.b=this._color.b,this._tempColor.a=t;var e=this._color.r/255,i=this._color.g/255,n=this._color.b/255;this._instance.setColor(e,i,n,t)}},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 Skt,this._eventListenerID=Skt.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){Skt.getListeners(t,this._instance).start=e},i.setTrackInterruptListener=function(t,e){Skt.getListeners(t,this._instance).interrupt=e},i.setTrackEndListener=function(t,e){Skt.getListeners(t,this._instance).end=e},i.setTrackDisposeListener=function(t,e){Skt.getListeners(t,this._instance).dispose=e},i.setTrackCompleteListener=function(t,e){Skt.getListeners(t,this._instance).complete=function(t){var i=Math.floor(t.trackTime/t.animationEnd);e(t,i)}},i.setTrackEventListener=function(t,e){Skt.getListeners(t,this._instance).event=e},i.getDebugShapes=function(){return this._instance.getDebugShapes()},i.setSlotTexture=function(t,e,i){if(this.isAnimationCached())H("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),this._slotTextures||(this._slotTextures=new Map);var a=0;this._slotTextures.forEach((function(t,i){t===e&&(a=i)})),0===a&&(a=++AGt,this._slotTextures.set(a,e)),this._instance.setSlotTexture(t,a)}else H("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()):H(this.name+" skin enums are invalid")}else H(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):H(this.name+" animation enums are invalid")}else H(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()}}]),e}(XO)).SpineSocket=bGt,pGt.AnimationCacheMode=mGt,eGt=ja((tGt=pGt).prototype,"_skeletonData",[lo],(function(){return null})),iGt=ja(tGt.prototype,"defaultSkin",[lo],(function(){return""})),nGt=ja(tGt.prototype,"defaultAnimation",[lo],(function(){return""})),rGt=ja(tGt.prototype,"_premultipliedAlpha",[lo],(function(){return!0})),sGt=ja(tGt.prototype,"_timeScale",[lo],(function(){return 1})),aGt=ja(tGt.prototype,"_preCacheMode",[lo],(function(){return mGt.UNSET})),oGt=ja(tGt.prototype,"_cacheMode",[lo],(function(){return mGt.REALTIME})),hGt=ja(tGt.prototype,"_sockets",[lo],(function(){return[]})),uGt=ja(tGt.prototype,"_useTint",[lo],(function(){return!1})),lGt=ja(tGt.prototype,"_debugMesh",[lo],(function(){return!1})),cGt=ja(tGt.prototype,"_debugBones",[lo],(function(){return!1})),_Gt=ja(tGt.prototype,"_debugSlots",[lo],(function(){return!1})),fGt=ja(tGt.prototype,"_enableBatch",[lo],(function(){return!1})),m(tGt.prototype,"skeletonData",[Ykt],Object.getOwnPropertyDescriptor(tGt.prototype,"skeletonData"),tGt.prototype),m(tGt.prototype,"_defaultSkinIndex",[qkt],Object.getOwnPropertyDescriptor(tGt.prototype,"_defaultSkinIndex"),tGt.prototype),m(tGt.prototype,"_animationIndex",[Kkt],Object.getOwnPropertyDescriptor(tGt.prototype,"_animationIndex"),tGt.prototype),m(tGt.prototype,"defaultCacheMode",[Qkt],Object.getOwnPropertyDescriptor(tGt.prototype,"defaultCacheMode"),tGt.prototype),dGt=ja(tGt.prototype,"loop",[lo],(function(){return!0})),m(tGt.prototype,"sockets",[Zkt],Object.getOwnPropertyDescriptor(tGt.prototype,"sockets"),tGt.prototype),m(tGt.prototype,"customMaterial",[jo,Jkt],Object.getOwnPropertyDescriptor(tGt.prototype,"customMaterial"),tGt.prototype),$kt=tGt))||$kt);S.internal.SpineSkeleton=EGt;var CGt,xGt,wGt,RGt,IGt=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 _kt.JitterEffect(t,e),this._vertexEffect},e.initSwirlWithPow=function(t,e){return this._effectType="swirl",this._interpolation=new _kt.Pow(e),this._vertexEffect=new _kt.SwirlEffect(t,this._interpolation),this._vertexEffect},e.initSwirlWithPowOut=function(t,e){return this._effectType="swirl",this._interpolation=new _kt.PowOut(e),this._vertexEffect=new _kt.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}(),DGt=new En(0,0,255,255),BGt=new En(255,0,0,255),MGt=new En(0,255,0,255),PGt=new En(255,255,0,255),OGt=null,LGt=null,NGt=!1,FGt=!1,kGt=kP(OP),GGt=kP(NP),VGt=new gn(0,0,0);function UGt(t,e){var i,n;switch(t){case 1:i=NGt?vc.ONE:vc.SRC_ALPHA,n=vc.ONE;break;case 2:i=vc.DST_COLOR,n=vc.ONE_MINUS_SRC_ALPHA;break;case 3:i=vc.ONE,n=vc.ONE_MINUS_SRC_COLOR;break;case 0:default:i=NGt?vc.ONE:vc.SRC_ALPHA,n=vc.ONE_MINUS_SRC_ALPHA}return e.getMaterialForBlendAndTint(i,n,FGt?yGt.TWO_COLORED:yGt.COLORED_TEXTURED)}var zGt={vCount:32767,ensureAccessor:function(t){var e=t?LGt:OGt;if(!e){var i=ID.root.device,n=ID.root.batcher2D,r=t?NP:OP;t?(e=LGt=new YP(i,r,this.vCount),n.registerBufferAccessor(Number.parseInt("SPINETINT",36),LGt)):(e=OGt=new YP(i,r,this.vCount),n.registerBufferAccessor(Number.parseInt("SPINE",36),OGt))}return e},createData:function(t){var e=t.renderData;if(!e){var i=t.useTint||t.isAnimationCached(),n=this.ensureAccessor(i);e=gO.add(i?NP:OP,n)}return e},updateRenderData:function(t){var e;t._skeleton&&t.node.active&&null!==(e=t.skeletonData)&&void 0!==e&&e.isValid&&function(t){if(t.drawList.reset(),0!==t.color.a){t._updateColor(),NGt=t.premultipliedAlpha,FGt=t.useTint||t.isAnimationCached(),t.isAnimationCached()?function(t){var e=t.updateRenderData();if(e){var i=e.vCount,n=e.iCount;if(!(i<1||n<1)){var r=t.renderData;r.vertexCount===i&&r.indexCount===n||(r.resize(i,n),r.indices=new Uint16Array(n));var s=r.chunk.vb,a=new Uint8Array(s.buffer,s.byteOffset,Float32Array.BYTES_PER_ELEMENT*s.length);a.set(e.vData);var o=t.color,h=t.node._uiProps.opacity;if(1-h>Oi||4294967295!==En.toUint32(o)||NGt){CGt=o.r/255,xGt=o.g/255,wGt=o.b/255,RGt=h;for(var u=0;u0||e.indexCount>0)&&i.getMeshBuffer(e.chunk.bufferId).setDirty()}}(t)}};S.internal.SpineAssembler=zGt;var HGt,WGt,XGt={getAssembler:function(){return zGt}};EGt.Assembler=XGt,function(t){t[t.REGION=0]="REGION",t[t.BOUNDING_BOX=1]="BOUNDING_BOX",t[t.MESH=2]="MESH",t[t.SKINNED_MESH=3]="SKINNED_MESH"}(HGt||(HGt={})),we(HGt),function(t){t[t.START=0]="START",t[t.INTERRUPT=1]="INTERRUPT",t[t.END=2]="END",t[t.DISPOSE=3]="DISPOSE",t[t.COMPLETE=4]="COMPLETE",t[t.EVENT=5]="EVENT"}(WGt||(WGt={})),we(WGt),t("g1",Object.freeze({__proto__:null,spine:_kt,get ATTACHMENT_TYPE(){return HGt},get AnimationEventType(){return WGt},timeScale:1,get AnimationCacheMode(){return mGt},get DefaultSkinsEnum(){return gGt},get DefaultAnimsEnum(){return vGt},get SpineMaterialType(){return yGt},SpineSocket:bGt,Skeleton:EGt,SkeletonData:kkt,VertexEffectDelegate:IGt,simpleSpineAssembler:XGt})),t("g2",function(){function t(t,e){this.data=new Uint16Array,this.w=0,this.h=0,this.w=t,this.h=e,this.data=new Uint16Array(t*e);for(var i=0;i>t,n=0;if(t<3&&(i-=2,n=e*FVt+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+FVt*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===Nm.Static&&this._lightmap?this._onUpdateReceiveDirLight(i,!0):this._onUpdateReceiveDirLight(i))}}},i._getBuiltinMaterial=function(){return bT.get("missing-material")},e}(EG),jVt=t("g5",eo("cc.TerrainBlockLightmapInfo")((aVt=function(){this.texture=oVt&&oVt(),this.UOff=hVt&&hVt(),this.VOff=uVt&&uVt(),this.UScale=lVt&&lVt(),this.VScale=cVt&&cVt()},oVt=ja(aVt.prototype,"texture",[lo],(function(){return null})),hVt=ja(aVt.prototype,"UOff",[lo],(function(){return 0})),uVt=ja(aVt.prototype,"VOff",[lo],(function(){return 0})),lVt=ja(aVt.prototype,"UScale",[lo],(function(){return 0})),cVt=ja(aVt.prototype,"VScale",[lo],(function(){return 0})),sVt=aVt))||sVt),YVt=t("g6",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 GVt,this._errorMetrics=[0,0,0,0],this._LevelDistances=[kVt,kVt,kVt,kVt],this._bbMin=new gn,this._bbMax=new gn,this._terrain=t,this._index[0]=e,this._index[1]=i,this._lightmapInfo=t._getLightmapInfo(e,i),this._node=new hg("TerrainBlock"),this._node.setParent(this._terrain.node),this._node.hideFlags|=Ms.Flags.DontSave|Ms.Flags.HideInHierarchy,this._node.layer=this._terrain.node.layer,this._renderable=this._node.addComponent(XVt)}var e=t.prototype;return e.build=function(){var t=ID.root.device,e=new Float32Array(HBt*zBt*zBt);this._buildVertexData(e);var i=t.createBuffer(new r_(rc.VERTEX|rc.TRANSFER_DST,oc.DEVICE,HBt*Float32Array.BYTES_PER_ELEMENT*zBt*zBt,HBt*Float32Array.BYTES_PER_ELEMENT));i.update(e),this._buildBoundingBox();var n=[new T_(Uc.ATTR_POSITION,ec.RGB32F),new T_(Uc.ATTR_NORMAL,ec.RGB32F),new T_(Uc.ATTR_TEX_COORD,ec.RG32F)];this._renderable._meshData=new FD([i],n,wc.TRIANGLE_LIST,this._terrain._getSharedIndexBuffer(),null,!1),this._renderable._model=S.director.root.createModel(RR),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=bT.get("normal-texture")),e},r=this._renderable._currentMaterial;if(null!==r){var s=this.getMaxLayer(),a=new cn(1,1,1,1),o=new cn(1,1,1,1),h=new cn(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",bT.get("default-texture")),t&&r.setProperty("normalMap0",bT.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 _=this._terrain.getLayer(this.layers[0]),f=this._terrain.getLayer(this.layers[1]),d=this._terrain.getLayer(this.layers[2]);null!==_&&(a.x=1/_.tileSize,o.x=_.roughness,h.x=_.metallic),null!==f&&(a.y=1/f.tileSize,o.y=f.roughness,h.y=f.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(_)),r.setProperty("detailMap1",i(f)),r.setProperty("detailMap2",i(d)),t&&(r.setProperty("normalMap0",n(_)),r.setProperty("normalMap1",n(f)),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]),v=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!==v&&(a.w=1/v.tileSize,o.w=v.roughness,h.w=v.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(v)),t&&(r.setProperty("normalMap0",n(p)),r.setProperty("normalMap1",n(m)),r.setProperty("normalMap2",n(g)),r.setProperty("normalMap3",n(v)))}r.setProperty("UVScale",a),e&&(r.setProperty("roughness",o),r.setProperty("metallic",h))}},e._buildLodInfo=function(){var t=new Float32Array(HBt*zBt*zBt);this._buildVertexData(t),this._updateLodBuffer(t),this._updateIndexBuffer()},e._updateLevel=function(t){var e=new gn,i=new gn;gn.add(e,this._bbMin,this._terrain.node.getWorldPosition()),gn.add(i,this._bbMax,this._terrain.node.getWorldPosition());var n=gn.distance(e,t),r=gn.distance(i,t),s=Math.min(n,r);for(s-=this._terrain.LodBias,this._lodLevel=0;this._lodLevel<3&&!(s<=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 Jn;return t.x=this._index[0]*UBt,t.y=this._index[1]*UBt,t.width=UBt,t.height=UBt,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(Sd.CLAMP_TO_BORDER,Sd.CLAMP_TO_BORDER),this._renderable._updateLightingmap(this.lightmap,this.lightmapUVParam))},e._updateHeight=function(){if(null!=this._renderable._meshData){var t=new Float32Array(HBt*zBt*zBt);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 lm,this._weightMap.create(this._terrain.weightMapSize,this._terrain.weightMapSize,yd.RGBA8888),this._weightMap.setFilters(Td.LINEAR,Td.LINEAR),this._weightMap.setWrapMode(Sd.CLAMP_TO_EDGE,Sd.CLAMP_TO_EDGE));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=Fi(r,0,this.vertexCount[0]-1),s=Fi(s,0,this.vertexCount[1]-1),a=Fi(a,0,this.vertexCount[0]-1),o=Fi(o,0,this.vertexCount[1]-1);var l=this.getHeight(r,s),c=this.getHeight(a,s),_=this.getHeight(r,o),f=this.getHeight(a,o),d=.5*(c+_);return h+u<=1?f=d+(d-l):l=d+(d-f),(l*(1-h)+c*h)*(1-u)+(_*(1-h)+f*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=new gn;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=Fi(r,0,this.vertexCount[0]-1),s=Fi(s,0,this.vertexCount[1]-1),a=Fi(a,0,this.vertexCount[0]-1),o=Fi(o,0,this.vertexCount[1]-1);var l=this.getNormal(r,s),c=this.getNormal(a,s),_=this.getNormal(r,o),f=this.getNormal(a,o),d=new gn;gn.add(d,c,_).multiplyScalar(.5),h+u<=1?(f.set(d),f.subtract(l),f.add(d)):(l.set(d),l.subtract(f),l.add(d));var p=new gn,m=new gn,g=new gn;return gn.lerp(p,l,c,h),gn.lerp(m,_,f,h),gn.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 cn;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=Fi(a,0,i-1),o=Fi(o,0,n-1),h=Fi(h,0,i-1),u=Fi(u,0,n-1);var _=this.getWeight(a,o),f=this.getWeight(h,o),d=this.getWeight(a,u),p=this.getWeight(h,u),m=new cn;cn.add(m,f,d).multiplyScalar(.5),l+c<=1?(p=new cn,cn.subtract(p,m,_).add(m)):(_=new cn,cn.subtract(_,m,p).add(m));var g=new cn,v=new cn,y=new cn;return cn.lerp(g,_,f,l),cn.lerp(v,d,p,l),cn.lerp(y,g,v,c),y},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),_=0;return h.y>h[_]&&-1!==c.getLayer(1)&&(_=1),h.y>h[_]&&-1!==c.getLayer(2)&&(_=2),h.z>h[_]&&-1!==c.getLayer(3)&&(_=3),_=c.getLayer(_),this.getLayer(_)},i.getBlockLayers=function(t,e){var i=(e*this._blockCount[0]+t)*GBt;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)*GBt;return this._layerBuffer[n+i]},i.setBlockLayer=function(t,e,i,n){var r=(e*this._blockCount[0]+t)*GBt;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&&gn.subtract(r,t,this.node.getWorldPosition());var s=new gn;s.set(e),s.multiplyScalar(i);var a=null;if(e.equals(new gn(0,1,0))){var o=this.getHeightAt(r.x,r.z);null!=o&&r.y<=o&&(a=new gn(r.x,o,r.z))}else if(e.equals(new gn(0,-1,0))){var h=this.getHeightAt(r.x,r.z);null!=h&&r.y>=h&&(a=new gn(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=new gn(r.x,c,r.z);break}r.add(s)}}return a},i._createSharedIndexBuffer=function(){var t=Ff.gfxDevice;if(null!==this._lod){var e=t.createBuffer(new r_(rc.INDEX|rc.TRANSFER_DST,oc.DEVICE,Uint16Array.BYTES_PER_ELEMENT*this._lod._indexBuffer.length,Uint16Array.BYTES_PER_ELEMENT));return e.update(this._lod._indexBuffer),e}for(var i=new Uint16Array(UBt*UBt*6),n=0,r=0;r0}},{key:"info",get:function(){var t=new HVt;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}(mp),AVt=ja(TVt.prototype,"__asset",[fVt,lo],(function(){return null})),bVt=ja(TVt.prototype,"_effectAsset",[dVt,lo],(function(){return null})),EVt=ja(TVt.prototype,"_lightmapInfos",[pVt,lo],(function(){return[]})),CVt=ja(TVt.prototype,"_receiveShadow",[lo],(function(){return!1})),xVt=ja(TVt.prototype,"_useNormalmap",[lo],(function(){return!1})),wVt=ja(TVt.prototype,"_usePBR",[lo],(function(){return!1})),RVt=ja(TVt.prototype,"_lodEnable",[lo],(function(){return!1})),IVt=ja(TVt.prototype,"_lodBias",[mVt,lo],(function(){return 0})),m(TVt.prototype,"_asset",[gVt],Object.getOwnPropertyDescriptor(TVt.prototype,"_asset"),TVt.prototype),m(TVt.prototype,"effectAsset",[vVt],Object.getOwnPropertyDescriptor(TVt.prototype,"effectAsset"),TVt.prototype),m(TVt.prototype,"info",[yVt],Object.getOwnPropertyDescriptor(TVt.prototype,"info"),TVt.prototype),SVt=TVt))||SVt)||SVt)),function(t){t[t.ORTHO=0]="ORTHO",t[t.HEX=1]="HEX",t[t.ISO=2]="ISO"}(DVt||(DVt={})),we(DVt),function(t){t[t.NONE=0]="NONE",t[t.MAP=1]="MAP",t[t.LAYER=2]="LAYER",t[t.OBJECTGROUP=3]="OBJECTGROUP",t[t.OBJECT=4]="OBJECT",t[t.TILE=5]="TILE"}(BVt||(BVt={})),we(BVt),function(t){t[t.HORIZONTAL=2147483648]="HORIZONTAL",t[t.VERTICAL=1073741824]="VERTICAL",t[t.DIAGONAL=536870912]="DIAGONAL",t[t.FLIPPED_ALL=4026531840]="FLIPPED_ALL",t[t.FLIPPED_MASK=268435455]="FLIPPED_MASK"}(MVt||(MVt={})),we(MVt),function(t){t[t.STAGGERAXIS_X=0]="STAGGERAXIS_X",t[t.STAGGERAXIS_Y=1]="STAGGERAXIS_Y"}(PVt||(PVt={})),we(PVt),function(t){t[t.STAGGERINDEX_ODD=0]="STAGGERINDEX_ODD",t[t.STAGGERINDEX_EVEN=1]="STAGGERINDEX_EVEN"}(OVt||(OVt={})),we(OVt),function(t){t[t.RightDown=0]="RightDown",t[t.RightUp=1]="RightUp",t[t.LeftDown=2]="LeftDown",t[t.LeftUp=3]="LeftUp"}(LVt||(LVt={})),we(LVt),function(t){t[t.RECT=0]="RECT",t[t.ELLIPSE=1]="ELLIPSE",t[t.POLYGON=2]="POLYGON",t[t.POLYLINE=3]="POLYLINE",t[t.IMAGE=4]="IMAGE",t[t.TEXT=5]="TEXT"}(NVt||(NVt={})),we(NVt);var qVt=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 Qn(0,0),this.tileOffset=new jn(0,0),this._tileSize=new Qn(0,0),this.collection=!1}return t.prototype.rectForGID=function(t,e){var i=e||new Jn(0,0,0,0);i.width=this._tileSize.width,i.height=this._tileSize.height;var n=t;if(n&=MVt.FLIPPED_MASK,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}(),KVt=function(){function t(){this.properties={},this.name="",this.objects=[],this.visible=!0,this.opacity=0,this.color=new En(255,255,255,255),this.offset=new jn(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}(),QVt=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 jn(0,0),this.tintColor=null}var e=t.prototype;return e.getProperties=function(){return this.properties},e.setProperties=function(t){this.properties=t},t}();QVt.ATTRIB_NONE=1,QVt.ATTRIB_BASE64=2,QVt.ATTRIB_GZIP=4,QVt.ATTRIB_ZLIB=8;var ZVt=function(){this.name="",this.visible=!0,this.width=0,this.height=0,this.offset=new jn(0,0),this.opacity=0,this.trans=new En(255,255,255,255),this.sourceImage=void 0,this.tintColor=null};function JVt(t){var e=OL.HorizontalAlign;switch(t){case"center":return e.CENTER;case"right":return e.RIGHT;default:return e.LEFT}}function $Vt(t){var e=OL.VerticalAlign;switch(t){case"center":return e.CENTER;case"bottom":return e.BOTTOM;default:return e.TOP}}function tUt(t){if(!t)return new En(0,0,0,255);if(8===(t=-1!==t.indexOf("#")?t.substring(1):t).length){var e=parseInt(t.substr(0,2),16)||255,i=parseInt(t.substr(2,2),16)||0,n=parseInt(t.substr(4,2),16)||0,r=parseInt(t.substr(6,2),16)||0;return new En(i,n,r,e)}var s=parseInt(t.substr(0,2),16)||0,a=parseInt(t.substr(2,2),16)||0,o=parseInt(t.substr(4,2),16)||0;return new En(s,a,o,255)}function eUt(t,e){for(var i=[],n=t.getElementsByTagName("properties"),r=0;r1,A=S[0],b=A.getAttribute("source");b=b.replace(/\\/g,"/");var E=m.getElementsByTagName("tile"),C=E&&E.length||1,x=null,w=m.getAttribute("name")||"",R=parseInt(m.getAttribute("spacing"))||0,I=parseInt(m.getAttribute("margin"))||0,D=i||parseInt(m.getAttribute("firstgid"))||0,B=new Qn(0,0);B.width=parseFloat(m.getAttribute("tilewidth")),B.height=parseFloat(m.getAttribute("tileheight"));var M=m.getElementsByTagName("tileoffset")[0],P=0,O=0;M&&(P=parseFloat(M.getAttribute("x"))||0,O=parseFloat(M.getAttribute("y"))||0);for(var L=null,N=0;N0){var H=U[0],W=H.getAttribute("source");if(W=W.replace(/\\/g,"/"),L.imageName=W,L.imageSize.width=parseFloat(H.getAttribute("width"))||0,L.imageSize.height=parseFloat(H.getAttribute("height"))||0,z||(L._tileSize.width=L.imageSize.width,L._tileSize.height=L.imageSize.height),L.sourceImage=this._spriteFrameMap[W],!L.sourceImage){var X=t.getNameWithPostfix(W);if(L.imageName=X,L.sourceImage=this._spriteFrameMap[X],!L.sourceImage){var j=t.getShortName(W);L.imageName=j,L.sourceImage=this._spriteFrameMap[j],L.sourceImage||(it(7221,W),console.warn("Please try asset type of "+W+" to 'sprite-frame'"))}}L.firstGid=this.parentGID&MVt.FLIPPED_MASK}var Y=(MVt.FLIPPED_MASK&this.parentGID)>>>0;this._tileProperties.set(Y,eUt(x));var q=x.getElementsByTagName("animation");if(q&&q.length>0){var K=q[0].getElementsByTagName("frame"),Z={frames:[],dt:0,frameIdx:0};this._tileAnimations.set(Y,Z);for(var J=Z.frames,$=0;$0){var f=_[0];l.type=NVt.TEXT,l.wrap="1"===f.getAttribute("wrap"),l.color=tUt(f.getAttribute("color")),l.halign=JVt(f.getAttribute("halign")),l.valign=$Vt(f.getAttribute("valign")),l.pixelsize=parseInt(f.getAttribute("pixelsize"))||16,l.text=f.childNodes[0].nodeValue}var d=u.getAttribute("gid");d&&(l.gid=parseInt(d),l.type=NVt.IMAGE);var p=u.getElementsByTagName("ellipse");p&&p.length>0&&(l.type=NVt.ELLIPSE);var m=u.getElementsByTagName("polygon");if(m&&m.length>0){l.type=NVt.POLYGON;var g=m[0].getAttribute("points");g&&(l.points=this._parsePointsString(g))}var v=u.getElementsByTagName("polyline");if(v&&v.length>0){l.type=NVt.POLYLINE;var y=v[0].getAttribute("points");y&&(l.polylinePoints=this._parsePointsString(y))}l.type||(l.type=NVt.RECT),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){y._name=i.name;var b=i.unbiasUV[0],E=i.rotated?i.unbiasUV[1]:i.unbiasUV[5];y.l=b+(y.x+.5)/c,y.t=E+(y.y+.5)/_,y.r=b+(y.x+y.width-.5)/c,y.b=E+(y.y+y.height-.5)/_,y._rect=new Jn(y.x,y.y,y.width,y.height)}else y.l=y.x/c,y.t=y.y/_,y.r=(y.x+y.width)/c,y.b=(y.y+y.height)/_,y._rect=new Jn(y.x,y.y,y.width,y.height);else i.rotated?(y._rotated=!0,y._name=i.name,y._rect=i.getRect(),y.l=i.unbiasUV[0],y.t=i.unbiasUV[1],y.r=i.unbiasUV[4],y.b=i.unbiasUV[3]):(y._name=i.name,y._rect=i.getRect(),y.l=i.unbiasUV[0],y.t=i.unbiasUV[5],y.r=i.unbiasUV[2],y.b=i.unbiasUV[1]);y.cx=(y.l+y.r)/2,y.cy=(y.t+y.b)/2,e.set(A,y)}}for(var vUt,yUt,SUt,TUt,AUt,bUt,EUt,CUt,xUt,wUt,RUt,IUt,DUt,BUt,MUt,PUt,OUt,LUt,NUt,FUt,kUt,GUt,VUt,UUt,zUt,HUt,WUt,XUt,jUt,YUt,qUt,KUt,QUt=new Vn,ZUt=new jn,JUt=new gn,$Ut=new gn,tzt={row:0,col:0},ezt=t("gB",eo("cc.TiledUserNodeData")(fUt=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}(mp))||fUt),izt=t("gC",eo("cc.TiledLayer")(dUt=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 QP,this._drawInfoList[t].setDrawInfoType(zP.MIDDLEWARE)),this._drawInfoList[t]},e.hasTiledNode=function(){return this._hasTiledNodeGrid},e.hasAnimation=function(){return this._hasAniGrid},e.addUserNode=function(t){var e=t.getComponent(ezt);return e?(z("CCTiledLayer:addUserNode node has been added"),!1):(e=t.addComponent(ezt),t.parent=this.node,this._userNodeMap[t.uuid]=e,e._row=-1,e._col=-1,e._tiledLayer=this,this._nodeLocalPosToLayerPos(t.getPosition(),ZUt),this._positionToRowCol(ZUt.x,ZUt.y,tzt),this._addUserNodeToGrid(e,tzt),this._updateCullingOffsetByUserNode(t),t.on(vm.TRANSFORM_CHANGED,this._userNodePosChange,e),t.on(vm.SIZE_CHANGED,this._userNodeSizeChange,e),!0)},e.removeUserNode=function(t){var e=t.getComponent(ezt);return e?(t.off(vm.TRANSFORM_CHANGED,this._userNodePosChange,e),t.off(vm.SIZE_CHANGED,this._userNodeSizeChange,e),this._removeUserNodeFromGrid(e),delete this._userNodeMap[t.uuid],t._removeComponent(e),e.destroy(),t.removeFromParent(),!0):(z("CCTiledLayer:removeUserNode node is not exist"),!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(),ZUt),this._positionToRowCol(ZUt.x,ZUt.y,tzt),this._addUserNodeToGrid(e,tzt),this._updateCullingOffsetByUserNode(e.node)}},e._updateCullingOffsetByUserNode=function(t){var e=t._uiProps.uiTransformComp.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=ID.root.batcher2D.getFirstRenderCamera(this.node),e=null==t?void 0:t.node;return this._cameraNode!==e&&(this._uninstallCamera(),e&&(e.on(vm.TRANSFORM_CHANGED,this.updateCulling,this),e.on(vm.SIZE_CHANGED,this.updateCulling,this),this._cameraNode=e)),t},e._uninstallCamera=function(){this._cameraNode&&(this._cameraNode.off(vm.TRANSFORM_CHANGED,this.updateCulling,this),this._cameraNode.off(vm.SIZE_CHANGED,this.updateCulling,this),delete this._cameraNode)},e.onEnable=function(){t.prototype.onEnable.call(this),this.node.on(vm.ANCHOR_CHANGED,this._syncAnchorPoint,this),this.node.on(vm.TRANSFORM_CHANGED,this.updateCulling,this),this.node.on(vm.SIZE_CHANGED,this.updateCulling,this),this.node.parent.on(vm.TRANSFORM_CHANGED,this.updateCulling,this),this.node.parent.on(vm.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)||void 0===e||e.off(vm.SIZE_CHANGED,this.updateCulling,this),null===(i=this.node.parent)||void 0===i||i.off(vm.TRANSFORM_CHANGED,this.updateCulling,this),this.node.off(vm.SIZE_CHANGED,this.updateCulling,this),this.node.off(vm.TRANSFORM_CHANGED,this.updateCulling,this),this.node.off(vm.ANCHOR_CHANGED,this._syncAnchorPoint,this),this._uninstallCamera()},e._syncAnchorPoint=function(){var t=this.node,e=t._uiProps.uiTransformComp,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 DVt.ORTHO:return this._positionForOrthoAt(i,e);case DVt.ISO:return this._positionForIsoAt(i,e);case DVt.HEX: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=(s&MVt.FLIPPED_MASK)>>>0,o=this.texGrids.get(a).tileset.tileOffset;i=o.x,n=o.y}return new jn(.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=(s&MVt.FLIPPED_MASK)>>>0,o=this.texGrids.get(a).tileset.tileOffset;i=o.x,n=o.y}return new jn(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=(this.tiles[a]&MVt.FLIPPED_MASK)>>>0;i=this.texGrids.get(o)?this.texGrids.get(o).tileset.tileOffset:{x:0,y:0};var h=this._staggerIndex===OVt.STAGGERINDEX_ODD?1:-1,u=0,l=0,c=0,_=0;switch(this._staggerAxis){case PVt.STAGGERAXIS_Y: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 PVt.STAGGERAXIS_X:_=0,t%2==1&&(_=r/2*-h),u=t*(n-(n-this._hexSideLength)/2)+i.x,l=(s-e-1)*r+_-i.y}return new jn(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=(t&MVt.FLIPPED_MASK)>>>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)):Q(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=(t&MVt.FLIPPED_MASK)>>>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 Q(7237),null;var i=Math.floor(t)+Math.floor(e)*this._layerSize.width;return(this.tiles[i]&MVt.FLIPPED_MASK)>>>0},e.getTileFlagsAt=function(t,e){if(this.isInvalidPosition(t,e))throw new Error("TiledLayer.getTileFlagsAt: invalid position");if(!this.tiles)return Q(7240),null;var i=Math.floor(t)+Math.floor(e)*this._layerSize.width;return(this.tiles[i]&MVt.FLIPPED_ALL)>>>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;this._layerOrientation===DVt.ISO&&(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,_=this._cullingRect.rightTop;o<0&&(o=0),h<0&&(h=0),this._positionToRowCol(o,h,tzt),tzt.row-=r,tzt.col-=r,tzt.row=tzt.row>0?tzt.row:0,tzt.col=tzt.col>0?tzt.col:0,tzt.row===c.row&&tzt.col===c.col||(c.row=tzt.row,c.col=tzt.col,this._cullingDirty=!0),u<0||l<0?(tzt.row=-1,tzt.col=-1):(this._positionToRowCol(u,l,tzt),tzt.row++,tzt.col++),tzt.row===_.row&&tzt.col===_.col||(_.row=tzt.row,_.col=tzt.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 DVt.ORTHO:h=Math.floor(t/n),o=Math.floor(e/r);break;case DVt.ISO:h=Math.floor(t/s),o=Math.floor(e/a);break;case DVt.HEX:c===PVt.STAGGERAXIS_Y?(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(),Vn.invert(QUt,this.node.getWorldMatrix());var t=this._reinstallCamera();t&&(JUt.x=0,JUt.y=0,JUt.z=0,$Ut.x=t.width,$Ut.y=t.height,$Ut.z=0,t.screenToWorld(JUt,JUt),t.screenToWorld($Ut,$Ut),gn.transformMat4(JUt,JUt,QUt),gn.transformMat4($Ut,$Ut,QUt),this.updateViewPort(JUt.x,JUt.y,$Ut.x-JUt.x,$Ut.y-JUt.y))}},e.getLayerOrientation=function(){return this._layerOrientation},e.getProperties=function(){return this._properties},e._updateVertex=function(t,e){var i=MVt.FLIPPED_MASK,n=this.vertices,r=this._layerOrientation,s=this.tiles;if(s){var a,o,h,u,l=this._rightTop,c=this._mapTileSize.width,_=this._mapTileSize.height,f=.5*c,d=.5*_,p=this._layerSize.height,m=this._layerSize.width,g=this.texGrids,v=0,y=0;r===DVt.HEX&&(a=this._staggerAxis,o=this._diffX1,h=this._diffY1,u=this._odd_even);var S,T,A,b=0,E=0,C=0,x=0,w=e*m+t;S=(s[w]&i)>>>0;var R=g.get(S);if(R){switch(this._animations.get(S)&&(this._hasAniGrid=this._hasAniGrid||!0),r){case DVt.ORTHO:v=(b=t)*c,y=(E=p-e-1)*_;break;case DVt.ISO:v=f*(b=p+t-e-1),y=d*(E=p+m-t-e-2);break;case DVt.HEX:v=t*(c-o)+(a===PVt.STAGGERAXIS_Y&&e%2==1?f*u:0),y=(p-e-1)*(_-h)+(a===PVt.STAGGERAXIS_X&&t%2==1?d*-u:0),b=t,E=p-e-1}var I=n[E]=n[E]||{minCol:0,maxCol:0},D=I[b]=I[b]||{left:0,bottom:0,index:0};I.minCol>b&&(I.minCol=b),I.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&&t[t.length-1].subNodes&&0===t[t.length-1].subNodes.length)return t[t.length-1];var e={subNodes:[]};return this._tiledDataArray.push(e),e},e.destroyRenderData=function(){this._tiledDataArray.forEach((function(t){var e=t.renderData;e&&gO.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,M=i.get(B);if(!M)continue;var P=M.tileset,O="img"+S.id;g[O]=!0;var L=this.node.getChildByName(O);S.width=S.width||M.width,S.height=S.height||M.height,L&&L._objFlags&Ms.Flags.HideInHierarchy&&(L.removeFromParent(),L.hideFlags|=Ms.Flags.DontSave,L.destroy(),L=null),L||(L=new hg),this._animations.get(B)&&(this.aniObjects.push({object:S,imgNode:L,gridGID:B}),this._hasAniObj=!0);var N=P.tileOffset.x,F=P.tileOffset.y;L.active=S.visible,L.setRotationFromEuler(0,0,-S.rotation),L.setPosition(S.x-d,S.y-p),L.name=O,L.parent=this.node,L.setSiblingIndex(v),L.layer=this.node.layer;var k=L.getComponent(PF);k||(k=L.addComponent(PF));var G=L._uiProps.uiTransformComp;c?(G.anchorX=.5+N/S.width,G.anchorY=F/S.height):(G.anchorX=N/S.width,G.anchorY=F/S.height),this._tintColor?(l.set(this._tintColor),l.a*=this._opacity/255,k.color.set(l)):k.color.a*=this._opacity/255,k.sizeMode=PF.SizeMode.CUSTOM;var V=this._premultiplyAlpha?vc.ONE:vc.SRC_ALPHA;k.srcBlendFactor!==V&&(k.srcBlendFactor=V,k.material&&k._updateBlendFunc());var U=M.spriteFrame;U=U?U.clone():new SM,(D&r)>>>0&&(U.flipUVX=!U.flipUVX),(D&s)>>>0&&(U.flipUVY=!U.flipUVY),U.rotated=M._rotated,U.rect=M._rect,k.spriteFrame=U,G.setContentSize(S.width,S.height),k.markForUpdateRenderData()}}this._objects=m;for(var z=this.node.children,H=/^(?:img|text)\d+$/,W=0,X=z.length;W0&&(m[d[g]]=p[g].text);var v=new pUt(i.tmxXmlStr,m,a,o,c),y=v.getTilesets();y&&0!==y.length||Q(7241),this._buildWithMapInfo(v)}else this._releaseMapInfo()},i._releaseMapInfo=function(){for(var t=this._layers,e=0,i=t.length;e0)for(var A=0,b=v.length;A=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=mzt,mzt=i),(e&MVt.HORIZONTAL)>>>0&&(i=dzt,dzt=mzt,mzt=i,i=pzt,pzt=gzt,gzt=i),(e&MVt.VERTICAL)>>>0&&(i=dzt,dzt=pzt,pzt=i,i=mzt,mzt=gzt,gzt=i)}function xzt(){if(!(Tzt<1)&&Azt){var t=4*Tzt,e=6*Tzt,i=uzt.requestTiledRenderData();i.renderData=gO.add(PP),i.texture=Azt;var n=i.renderData;n.resize(t,e),n.chunk.vb.set(hzt.subarray(0,9*t),0),Tzt=0,Azt=null}}function wzt(t,e,i,n,r){if(!(e.row<0||e.col<0)){uzt=r;var s=r.node.worldMatrix;vzt=0;var a,o,h,u,l,c,_,f,d,p=r.tiledTiles,m=r.texGrids,g=r.tiles,v=18,y=27,S=r.vertices,T=0,A=0,b=0,E=0,C=0,x=0,w=!0;lzt=Czt;var R=new Float32Array(4);R[0]=r.color.r/255,R[1]=r.color.g/255,R[2]=r.color.b/255,R[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,D=Math.abs(e.col-t.col)+1;hzt=new Float32Array(I*D*36),Tzt=0;for(var B=hzt;(l-u)*i>=0;u+=i)for(a=S[u],x=r.getNodesCountByRow(u),w=a&&0===x,1===n?(o=w&&t.cola.maxCol?a.maxCol:e.col):(o=w&&e.col>a.maxCol?a.maxCol:e.col,h=w&&t.col=0;o+=n){if(c=a&&a[o],x>0){xzt();var M=r.requestSubNodesData(),P=r.getNodesByRowCol(u,o);P&&P.count>0&&(M.subNodes=P.list)}c&&(T=g[c.index],(f=m.get((T&MVt.FLIPPED_MASK)>>>0))&&(Azt!==f.texture&&(xzt(),Azt=f.texture),_=f.tileset._tileSize,A=c.left-yzt,b=c.bottom-Szt,E=A+_.width,C=b+_.height,d=p[c.index],vzt=36*Tzt,d?d.node.active&&Rzt(d.node,R,B,A,E,C,b,!1):(azt[0].x=A,azt[0].y=C,azt[1].x=A,azt[1].y=b,azt[2].x=E,azt[2].y=C,azt[3].x=E,azt[3].y=b,azt[0].transformMat4(s),B[vzt]=azt[0].x,B[vzt+1]=azt[0].y,B[vzt+2]=azt[0].z,azt[1].transformMat4(s),B[vzt+9]=azt[1].x,B[vzt+9+1]=azt[1].y,B[vzt+9+2]=azt[1].z,azt[2].transformMat4(s),B[vzt+v]=azt[2].x,B[vzt+v+1]=azt[2].y,B[vzt+v+2]=azt[2].z,azt[3].transformMat4(s),B[vzt+y]=azt[3].x,B[vzt+y+1]=azt[3].y,B[vzt+y+2]=azt[3].z,B.set(R,vzt+5),B.set(R,vzt+9+5),B.set(R,vzt+v+5),B.set(R,vzt+y+5)),lzt(f,T),B[vzt+3]=dzt.x,B[vzt+4]=dzt.y,B[vzt+9+3]=pzt.x,B[vzt+9+4]=pzt.y,B[vzt+v+3]=mzt.x,B[vzt+v+4]=mzt.y,B[vzt+y+3]=gzt.x,B[vzt+y+4]=gzt.y,++Tzt>=szt&&xzt()))}xzt()}}function Rzt(t,e,i,n,r,s,a,o){var h=18,u=27;t.updateWorldTransform(),Vn.fromRTS(czt,t.rotation,t.position,t.scale),gn.set(_zt,-(n+yzt),-(a+Szt),0),Vn.transform(czt,czt,_zt),Vn.multiply(czt,t.parent.worldMatrix,czt);var l=czt,c=l.m12,_=l.m13,f=l.m00,d=l.m01,p=l.m04,m=l.m05,g=1===f&&0===d&&0===p&&1===m;if(o){var v=(n+r)/2,y=(s+a)/2;g?(i[vzt]=v+c,i[vzt+1]=s+_,i[vzt+9]=n+c,i[vzt+9+1]=y+_,i[vzt+h]=r+c,i[vzt+h+1]=y+_,i[vzt+u]=v+c,i[vzt+u+1]=a+_):(i[vzt]=v*f+s*p+c,i[vzt+1]=v*d+s*m+_,i[vzt+9]=n*f+y*p+c,i[vzt+9+1]=n*d+y*m+_,i[vzt+h]=r*f+y*p+c,i[vzt+h+1]=r*d+y*m+_,i[vzt+u]=v*f+a*p+c,i[vzt+u+1]=v*d+a*m+_)}else g?(i[vzt]=n+c,i[vzt+1]=s+_,i[vzt+9]=n+c,i[vzt+9+1]=a+_,i[vzt+h]=r+c,i[vzt+h+1]=s+_,i[vzt+u]=r+c,i[vzt+u+1]=a+_):(i[vzt]=n*f+s*p+c,i[vzt+1]=n*d+s*m+_,i[vzt+9]=n*f+a*p+c,i[vzt+9+1]=n*d+a*m+_,i[vzt+h]=r*f+s*p+c,i[vzt+h+1]=r*d+s*m+_,i[vzt+u]=r*f+a*p+c,i[vzt+u+1]=r*d+a*m+_);i.set(e,vzt+5),i.set(e,vzt+9+5),i.set(e,vzt+h+5),i.set(e,vzt+u+5)}var Izt=t("gF",{getAssembler:function(){return Ezt}});izt.Assembler=Izt;var Dzt=new gn,Bzt=new gn;function Mzt(t,e){var i=null;return{value:e.length>0?e[e.length-1]:gn.ZERO,progress:function(t,e,n,r){return i.getPoint(r)},clone:function(t){return gn.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=Sl.create(t)).addKnot(r);var h=null;a&&o&&(h=Bzt,gn.subtract(h,r,e[e.length-1]));for(var u=0,l=e.length;u0&&i.addKnot(gn.copy(Dzt,h).add(c)):i.addKnot(gn.copy(Dzt,r).add(c)):i.addKnot(c)}a&&o&&i.addKnot(s)},onComplete:function(){i=null},onStop:function(){i=null},legacyProgress:!1}}t("gG",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;t===Pzt.TAG_INVALID&&Q(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;t===Pzt.TAG_INVALID&&Q(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){t===Pzt.TAG_INVALID&&Q(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 hg&&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;nthis._duration?this._duration:t,this._startTime=t},i.getElapsed=function(){return this._elapsed},i.initWithDuration=function(t){return this._duration=0===t?Pe.FLT_EPSILON:t,this._elapsed=0,this._firstTick=!0,!0},i.isDone=function(){return this._elapsed>=this._duration},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&&(this._elapsed-=t),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}(Ozt),jzt=function(t){function e(i){var n;if((n=t.call(this)||this)._actions=[],n._split=0,n._last=0,n._reversed=!1,!i||0===i.length)return c(n);1===i.length&&i.push(new Wzt);var r=i.length-1;if(r>=0&&null==i[r]&&Q(1015),r>=0){for(var s,a=i[0],o=1;o1?i%1:i),this._last=n)}},i.reverse=function(){var t=e._actionOneTwo(this._actions[1].reverse(),this._actions[0].reverse());return this._cloneDecoration(t),t._reversed=!0,t},i.updateWorkerTarget=function(t){if(!(this._actions.length<2)){this._actions[1].workerTarget=t;var i=this._actions[0];i instanceof e||i instanceof Zzt?i.updateWorkerTarget(t):i.workerTarget=t}},i.findAction=function(t){for(var i=0,n=this._actions.length;i=r){for(;t>r&&this._total1?1:r}if(t>=1&&this._total=0&&null==i[r]&&Q(1015),r>=0){for(var s,a=i[0],o=1;or?this._two=jzt._actionOneTwo(e,$zt(n-r)):n0&&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 tt(16388),this.clone(this._target);var t=this._union(!1),e=FHt(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()).workerTarget=t._target:tt(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(Yzt(s))}return this},e.to=function(t,e,i){var n=i||Object.create(null);n.relative=!1;var r=new OHt(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 OHt(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),this._transition===GHt.COLOR){var n=e._uiProps.uiComp;En.lerp(zHt,this._fromColor,this._toColor,i),n&&(n.color=zHt)}else this.transition===GHt.SCALE&&(e.getScale(this._targetScale),this._targetScale.x=Gi(this._fromScale.x,this._toScale.x,i),this._targetScale.y=Gi(this._fromScale.y,this._toScale.y,i),e.setScale(this._targetScale));1===i&&(this._transitionFinished=!0)}},i._resizeNodeToTargetNode=function(){this.target&&this.target._uiProps.uiTransformComp},i._resetState=function(){this._pressed=!1,this._hovered=!1;var t=this.target;if(t){var e=this._transition;if(e===GHt.COLOR&&this._interactable){var i=t.getComponent(XO);i&&(i.color=this._normalColor)}else e===GHt.SCALE&&this._originalScale&&t.setScale(this._originalScale);this._transitionFinished=!0}},i._registerNodeEvent=function(){this.node.on(vm.TOUCH_START,this._onTouchBegan,this),this.node.on(vm.TOUCH_MOVE,this._onTouchMove,this),this.node.on(vm.TOUCH_END,this._onTouchEnded,this),this.node.on(vm.TOUCH_CANCEL,this._onTouchCancel,this),this.node.on(vm.MOUSE_ENTER,this._onMouseMoveIn,this),this.node.on(vm.MOUSE_LEAVE,this._onMouseMoveOut,this),this.node.on(eHt.XRUI_HOVER_ENTERED,this._xrHoverEnter,this),this.node.on(eHt.XRUI_HOVER_EXITED,this._xrHoverExit,this),this.node.on(eHt.XRUI_CLICK,this._xrClick,this),this.node.on(eHt.XRUI_UNCLICK,this._xrUnClick,this)},i._registerTargetEvent=function(t){t.on(vm.TRANSFORM_CHANGED,this._onTargetTransformChanged,this)},i._unregisterNodeEvent=function(){this.node.off(vm.TOUCH_START,this._onTouchBegan,this),this.node.off(vm.TOUCH_MOVE,this._onTouchMove,this),this.node.off(vm.TOUCH_END,this._onTouchEnded,this),this.node.off(vm.TOUCH_CANCEL,this._onTouchCancel,this),this.node.off(vm.MOUSE_ENTER,this._onMouseMoveIn,this),this.node.off(vm.MOUSE_LEAVE,this._onMouseMoveOut,this),this.node.off(eHt.XRUI_HOVER_ENTERED,this._xrHoverEnter,this),this.node.off(eHt.XRUI_HOVER_EXITED,this._xrHoverExit,this),this.node.off(eHt.XRUI_CLICK,this._xrClick,this),this.node.off(eHt.XRUI_UNCLICK,this._xrUnClick,this)},i._unregisterTargetEvent=function(t){t.off(vm.TRANSFORM_CHANGED)},i._getTargetSprite=function(t){var e=null;return t&&(e=t.getComponent(PF)),e},i._applyTarget=function(){this.target&&(this._sprite=this._getTargetSprite(this.target),this._originalScale||(this._originalScale=new gn),gn.copy(this._originalScale,this.target.scale),this._registerTargetEvent(this.target))},i._onTargetSpriteFrameChanged=function(t){this._transition===GHt.SPRITE&&this._setCurrentStateSpriteFrame(t.spriteFrame)},i._setCurrentStateSpriteFrame=function(t){if(t)switch(this._getButtonState()){case VHt.NORMAL:this._normalSprite=t;break;case VHt.HOVER:this._hoverSprite=t;break;case VHt.PRESSED:this._pressedSprite=t;break;case VHt.DISABLED:this._disabledSprite=t}},i._onTargetColorChanged=function(t){this._transition===GHt.COLOR&&this._setCurrentStateColor(t)},i._setCurrentStateColor=function(t){switch(this._getButtonState()){case VHt.NORMAL:this._normalColor=t;break;case VHt.HOVER:this._hoverColor=t;break;case VHt.PRESSED:this._pressedColor=t;break;case VHt.DISABLED:this._disabledColor=t}},i._onTargetTransformChanged=function(t){t&mm.SCALE&&this._originalScale&&this._transition===GHt.SCALE&&this._transitionFinished&&gn.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._uiProps.uiTransformComp.hitTest(e.getLocation(),t.windowId);this._transition===GHt.SCALE&&this.target&&this._originalScale?n?(gn.copy(this._fromScale,this._originalScale),gn.multiplyScalar(this._toScale,this._originalScale,this._zoomScale),this._transitionFinished=!1):(this._time=0,this._transitionFinished=!0,this.target.setScale(this._originalScale)):(i=n?VHt.PRESSED:VHt.NORMAL,this._applyTransition(i)),t&&(t.propagationStopped=!0)}}},i._onTouchEnded=function(t){this._interactable&&this.enabledInHierarchy&&(this._pressed&&(fp.emitEvents(this.clickEvents,t),this.node.emit(UHt.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&&(this._transition!==GHt.SPRITE||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=VHt.NORMAL;return this._interactable?this._pressed?t=VHt.PRESSED:this._hovered&&(t=VHt.HOVER):t=VHt.DISABLED,t},i._updateColorTransition=function(t){var e,i=this._getColorByState(t),n=null===(e=this.target)||void 0===e?void 0:e.getComponent(XO);n&&(t===VHt.DISABLED?(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&&(t===VHt.PRESSED?this._zoomUp():this._zoomBack())},i._zoomUp=function(){this._originalScale&&(gn.copy(this._fromScale,this._originalScale),gn.multiplyScalar(this._toScale,this._originalScale,this._zoomScale),this._time=0,this._transitionFinished=!1)},i._zoomBack=function(){this.target&&this._originalScale&&(gn.copy(this._fromScale,this.target.scale),gn.copy(this._toScale,this._originalScale),this._time=0,this._transitionFinished=!1)},i._applyTransition=function(t){var e=this._transition;e===GHt.COLOR?this._updateColorTransition(t):e===GHt.SPRITE?this._updateSpriteTransition(t):e===GHt.SCALE&&this._updateScaleTransition(t)},i._getSpriteFrameByState=function(t){switch(t){case VHt.NORMAL:return this._normalSprite;case VHt.DISABLED:return this._disabledSprite;case VHt.HOVER:return this.hoverSprite;case VHt.PRESSED:return this._pressedSprite;default:return null}},i._getColorByState=function(t){switch(t){case VHt.NORMAL:return this._normalColor;case VHt.DISABLED:return this._disabledColor;case VHt.HOVER:return this._hoverColor;case VHt.PRESSED:return this._pressedColor;default:return new En}},i._xrHoverEnter=function(){this._onMouseMoveIn(),this._updateState()},i._xrHoverExit=function(){this._onMouseMoveOut(),this._pressed&&(this._pressed=!1,this._updateState())},i._xrClick=function(){this._interactable&&this.enabledInHierarchy&&(this._pressed=!0,this._updateState())},i._xrUnClick=function(){this._interactable&&this.enabledInHierarchy&&(this._pressed&&(fp.emitEvents(this.clickEvents,this),this.node.emit(UHt.CLICK,this)),this._pressed=!1,this._updateState())},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&&(this._transition===GHt.COLOR?this._updateColorTransition(VHt.NORMAL):this._transition===GHt.SPRITE&&this._updateSpriteTransition(VHt.NORMAL),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(PF);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}(mp)).Transition=GHt,IHt.EventType=UHt,m((dHt=IHt).prototype,"target",[aHt],Object.getOwnPropertyDescriptor(dHt.prototype,"target"),dHt.prototype),m(dHt.prototype,"transition",[oHt],Object.getOwnPropertyDescriptor(dHt.prototype,"transition"),dHt.prototype),m(dHt.prototype,"normalSprite",[hHt],Object.getOwnPropertyDescriptor(dHt.prototype,"normalSprite"),dHt.prototype),m(dHt.prototype,"pressedSprite",[uHt],Object.getOwnPropertyDescriptor(dHt.prototype,"pressedSprite"),dHt.prototype),m(dHt.prototype,"hoverSprite",[lHt],Object.getOwnPropertyDescriptor(dHt.prototype,"hoverSprite"),dHt.prototype),m(dHt.prototype,"disabledSprite",[cHt],Object.getOwnPropertyDescriptor(dHt.prototype,"disabledSprite"),dHt.prototype),pHt=ja(dHt.prototype,"clickEvents",[_Ht,lo],(function(){return[]})),mHt=ja(dHt.prototype,"_interactable",[lo],(function(){return!0})),gHt=ja(dHt.prototype,"_transition",[lo],(function(){return GHt.NONE})),vHt=ja(dHt.prototype,"_normalColor",[lo],(function(){return En.WHITE.clone()})),yHt=ja(dHt.prototype,"_hoverColor",[lo],(function(){return new En(211,211,211,255)})),SHt=ja(dHt.prototype,"_pressedColor",[lo],(function(){return En.WHITE.clone()})),THt=ja(dHt.prototype,"_disabledColor",[lo],(function(){return new En(124,124,124,255)})),AHt=ja(dHt.prototype,"_normalSprite",[lo],(function(){return null})),bHt=ja(dHt.prototype,"_hoverSprite",[lo],(function(){return null})),EHt=ja(dHt.prototype,"_pressedSprite",[lo],(function(){return null})),CHt=ja(dHt.prototype,"_disabledSprite",[lo],(function(){return null})),xHt=ja(dHt.prototype,"_duration",[lo],(function(){return.1})),wHt=ja(dHt.prototype,"_zoomScale",[lo],(function(){return 1.2})),RHt=ja(dHt.prototype,"_target",[lo],(function(){return null})),fHt=dHt))||fHt)||fHt)||fHt));S.Button=HHt;var WHt,XHt,jHt,YHt=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}();YHt._tabIndexList=[],function(t){t[t.DEFAULT=0]="DEFAULT",t[t.DONE=1]="DONE",t[t.SEND=2]="SEND",t[t.SEARCH=3]="SEARCH",t[t.GO=4]="GO",t[t.NEXT=5]="NEXT"}(WHt||(WHt={})),Ee(WHt),function(t){t[t.ANY=0]="ANY",t[t.EMAIL_ADDR=1]="EMAIL_ADDR",t[t.NUMERIC=2]="NUMERIC",t[t.PHONE_NUMBER=3]="PHONE_NUMBER",t[t.URL=4]="URL",t[t.DECIMAL=5]="DECIMAL",t[t.SINGLE_LINE=6]="SINGLE_LINE"}(XHt||(XHt={})),Ee(XHt),function(t){t[t.PASSWORD=0]="PASSWORD",t[t.SENSITIVE=1]="SENSITIVE",t[t.INITIAL_CAPS_WORD=2]="INITIAL_CAPS_WORD",t[t.INITIAL_CAPS_SENTENCE=3]="INITIAL_CAPS_SENTENCE",t[t.INITIAL_CAPS_ALL_CHARACTERS=4]="INITIAL_CAPS_ALL_CHARACTERS",t[t.DEFAULT=5]="DEFAULT"}(jHt||(jHt={})),Ee(jHt);var qHt,KHt,QHt,ZHt,JHt,$Ht,tWt,eWt,iWt,nWt,rWt,sWt,aWt,oWt,hWt,uWt,lWt,cWt,_Wt,fWt,dWt,pWt,mWt,gWt,vWt,yWt,SWt,TWt,AWt,bWt,EWt=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}(),CWt=A.document,xWt=new Vn,wWt=new Vn,RWt=new gn,IWt=null,DWt=0,BWt=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_"+ ++DWt,e._forceUpdate=!1,e}s(e,t);var i=e.prototype;return i.init=function(t){t&&(this._delegate=t,t.inputMode===XHt.ANY?this._createTextArea():this._createInput(),YHt.add(this),this.setTabIndex(t.tabIndex),this._initStyleSheet(),this._registerEventListeners(),this._addDomToGameContainer(),hB.instance.on("canvas-resize",this._resize,this),ga.on("window-resize",this._resize,this))},i.clear=function(){hB.instance.off("canvas-resize",this._resize,this),ga.off("window-resize",this._resize,this),this._removeEventListeners(),this._removeDomFromGameContainer(),YHt.remove(this),IWt===this&&(IWt=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,YHt.resort()},i.setSize=function(t,e){var i=this._edTxt;i&&(i.style.width=t+"px",i.style.height=e+"px")},i.beginEditing=function(){IWt&&IWt!==this&&IWt.setFocus(!1),this._editing=!0,IWt=this,this._delegate._editBoxEditingDidBegan(),this._showDom(),this._edTxt.focus()},i.endEditing=function(){this._edTxt.blur()},i._createInput=function(){this._isTextArea=!1,this._edTxt=CWt.createElement("input")},i._createTextArea=function(){this._isTextArea=!0,this._edTxt=CWt.createElement("textarea")},i._addDomToGameContainer=function(){EB.container&&this._edTxt&&(EB.container.appendChild(this._edTxt),CWt.head.appendChild(this._placeholderStyleSheet))},i._removeDomFromGameContainer=function(){ze(EB.container,this._edTxt)&&this._edTxt&&EB.container.removeChild(this._edTxt),ze(CWt.head,this._placeholderStyleSheet)&&CWt.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()),Sa.isMobile&&this._showDomOnMobile()},i._hideDom=function(){var t=this._edTxt;t&&this._delegate&&(t.style.display="none",this._delegate._showLabels()),Sa.isMobile&&this._hideDomOnMobile()},i._showDomOnMobile=function(){Sa.os!==Ys.ANDROID&&Sa.os!==Ys.OHOS||(ga.handleResizeEvent=!1,this._adjustWindowScroll())},i._hideDomOnMobile=function(){Sa.os!==Ys.ANDROID&&Sa.os!==Ys.OHOS||(ga.handleResizeEvent=!0),this._scrollBackWindow()},i._isElementInViewport=function(){if(this._edTxt){var t=this._edTxt.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(A.innerHeight||CWt.documentElement.clientHeight)&&t.right<=(A.innerWidth||CWt.documentElement.clientWidth)}return!1},i._adjustWindowScroll=function(){var t=this;setTimeout((function(){A.scrollY<40&&!t._isElementInViewport()&&t._edTxt.scrollIntoView({block:"start",inline:"nearest",behavior:"smooth"})}),400)},i._scrollBackWindow=function(){setTimeout((function(){Sa.browserType!==Ws.WECHAT||Sa.os!==Ys.IOS?A.scrollTo(0,0):A.top&&A.top.scrollTo(0,0)}),400)},i._updateMatrix=function(){if(this._edTxt){var t=this._delegate.node,e=yB.getScaleX(),i=yB.getScaleY(),n=yB.getViewportRect(),r=ga.devicePixelRatio;t.getWorldMatrix(xWt);var s=t._uiProps.uiTransformComp;if(s&&(gn.set(RWt,-s.anchorX*s.width,-s.anchorY*s.height,RWt.z),Vn.transform(xWt,xWt,RWt)),t._uiProps.uiTransformComp){var a=ID.root.batcher2D.getFirstRenderCamera(t);if(a){a.node.getWorldRT(wWt);var o=wWt.m12,h=wWt.m13,u=Ta.center;wWt.m12=u.x-(wWt.m00*o+wWt.m04*h),wWt.m13=u.y-(wWt.m01*o+wWt.m05*h),e/=r,i/=r,gn.set(RWt,e,i,1),Vn.scale(wWt,wWt,RWt);var l=EB.container,c=parseInt(l&&l.style.paddingLeft||"0");c+=n.x/r;var _=parseInt(l&&l.style.paddingBottom||"0");_+=n.y/r,wWt.m12+=c,wWt.m13+=_,Vn.multiply(wWt,wWt,xWt);var f="matrix("+wWt.m00+","+-wWt.m01+","+-wWt.m04+","+wWt.m05+","+wWt.m12+","+-wWt.m13+")";this._edTxt.style.transform=f,this._edTxt.style["-webkit-transform"]=f,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 i===jHt.INITIAL_CAPS_ALL_CHARACTERS?s="uppercase":i===jHt.INITIAL_CAPS_WORD&&(s="capitalize"),void(r.style.textTransform=s)}if(r=r,i===jHt.PASSWORD)return r.type="password",void(r.style.textTransform="none");var a=r.type;e===XHt.EMAIL_ADDR?a="email":e===XHt.NUMERIC?a="number":e===XHt.DECIMAL?a="digit":e===XHt.PHONE_NUMBER?(a="tel",r.addEventListener("wheel",(function(){return!1}))):e===XHt.URL?a="url":(a="text",n===WHt.SEARCH&&(a="search")),r.type=a;var o="none";i===jHt.INITIAL_CAPS_ALL_CHARACTERS?o="uppercase":i===jHt.INITIAL_CAPS_WORD&&(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=t).type="text",t.style["-moz-appearance"]="textfield"),this._placeholderStyleSheet=CWt.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 SP?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 OL.HorizontalAlign.LEFT:n.style.textAlign="left";break;case OL.HorizontalAlign.CENTER:n.style.textAlign="center";break;case OL.HorizontalAlign.RIGHT:n.style.textAlign="right"}}}},i._updatePlaceholderLabel=function(t){if(t){var e=t.font;e=!e||e instanceof SP?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 OL.HorizontalAlign.LEFT:a="left";break;case OL.HorizontalAlign.CENTER:a="center";break;case OL.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+";}",Sa.browserType===Ws.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&&(e.value=e.value.slice(0,r)),n._editBoxTextChanged(e.value)}},n.onClick=function(){t._editing&&Sa.isMobile&&t._adjustWindowScroll()},n.onKeydown=function(i){i.keyCode===Xx.ENTER?(i.propagationStopped=!0,t._delegate._editBoxEditingReturn(),t._isTextArea||e.blur()):i.keyCode===Xx.TAB&&(i.propagationStopped=!0,i.preventDefault(),YHt.next(t))},n.onBlur=function(){Sa.isMobile&&i&&n.compositionEnd(),t._editing=!1,IWt=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}(EWt);!function(t){t.EDITING_DID_BEGAN="editing-did-began",t.EDITING_DID_ENDED="editing-did-ended",t.TEXT_CHANGED="text-changed",t.EDITING_RETURN="editing-return",t.XR_EDITING_DID_BEGAN="xr-editing-did-began",t.XR_EDITING_DID_ENDED="xr-editing-did-ended"}(bWt||(bWt={}));var MWt,PWt,OWt,LWt,NWt,FWt,kWt,GWt,VWt,UWt,zWt,HWt,WWt,XWt,jWt,YWt,qWt,KWt,QWt,ZWt,JWt,$Wt,tXt,eXt,iXt,nXt,rXt,sXt,aXt,oXt,hXt,uXt,lXt,cXt,_Xt=t("gN",(qHt=eo("cc.EditBox"),KHt=no(110),QHt=io(wO),ZHt=Lo(OL),JHt=Lo(OL),$Ht=Lo(SM),tWt=Lo(jHt),eWt=Lo(XHt),iWt=Lo(WHt),nWt=Lo([fp]),rWt=Lo([fp]),sWt=Lo([fp]),aWt=Lo([fp]),qHt(oWt=KHt(oWt=QHt(((AWt=function(t){function e(){var e;return(e=t.call(this)||this).editingDidBegan=uWt&&uWt(),e.textChanged=lWt&&lWt(),e.editingDidEnded=cWt&&cWt(),e.editingReturn=_Wt&&_Wt(),e._impl=null,e._background=null,e._textLabel=fWt&&fWt(),e._placeholderLabel=dWt&&dWt(),e._returnType=pWt&&pWt(),e._string=mWt&&mWt(),e._tabIndex=gWt&&gWt(),e._backgroundImage=vWt&&vWt(),e._inputFlag=yWt&&yWt(),e._inputMode=SWt&&SWt(),e._maxLength=TWt&&TWt(),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(){ID.off(wD.EVENT_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(){fp.emitEvents(this.editingDidBegan,this),this.node.emit(bWt.EDITING_DID_BEGAN,this)},i._editBoxEditingDidEnded=function(t){fp.emitEvents(this.editingDidEnded,this),this.node.emit(bWt.EDITING_DID_ENDED,this,t)},i._editBoxTextChanged=function(t){t=this._updateLabelStringStyle(t,!0),this.string=t,fp.emitEvents(this.textChanged,t,this),this.node.emit(bWt.TEXT_CHANGED,this)},i._editBoxEditingReturn=function(t){fp.emitEvents(this.editingReturn,this),this.node.emit(bWt.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(vm.SIZE_CHANGED,this._resizeChildNodes,this),ID.on(wD.EVENT_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(PF);t||(t=this.node.addComponent(PF)),t!==this._background&&(t.type=PF.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 hg("TEXT_LABEL")).layer=this.node.layer),(t=e.getComponent(OL))||(t=e.addComponent(OL)),e.parent=this.node,this._textLabel=t}this._inputMode===XHt.ANY?(t.verticalAlign=wL.TOP,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 hg("PLACEHOLDER_LABEL")).layer=this.node.layer),(t=e.getComponent(OL))||(t=e.addComponent(OL)),e.parent=this.node,this._placeholderLabel=t}this._inputMode===XHt.ANY?t.enableWrapText=!0:t.enableWrapText=!1,t.string=this.placeholder},i._syncSize=function(){var t=this.node._uiProps.uiTransformComp,e=t.contentSize;if(this._background){var i=this._background.node._uiProps.uiTransformComp;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||n!==jHt.PASSWORD)n===jHt.INITIAL_CAPS_ALL_CHARACTERS?t=t.toUpperCase():n===jHt.INITIAL_CAPS_WORD?t=t.replace(/(?:^|\s)\S/g,(function(t){return t.toUpperCase()})):n===jHt.INITIAL_CAPS_SENTENCE&&(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}(mp))._EditBoxImpl=EWt,AWt.KeyboardReturnType=WHt,AWt.InputFlag=jHt,AWt.InputMode=XHt,AWt.EventType=bWt,m((hWt=AWt).prototype,"textLabel",[ZHt],Object.getOwnPropertyDescriptor(hWt.prototype,"textLabel"),hWt.prototype),m(hWt.prototype,"placeholderLabel",[JHt],Object.getOwnPropertyDescriptor(hWt.prototype,"placeholderLabel"),hWt.prototype),m(hWt.prototype,"backgroundImage",[$Ht],Object.getOwnPropertyDescriptor(hWt.prototype,"backgroundImage"),hWt.prototype),m(hWt.prototype,"inputFlag",[tWt],Object.getOwnPropertyDescriptor(hWt.prototype,"inputFlag"),hWt.prototype),m(hWt.prototype,"inputMode",[eWt],Object.getOwnPropertyDescriptor(hWt.prototype,"inputMode"),hWt.prototype),m(hWt.prototype,"returnType",[iWt],Object.getOwnPropertyDescriptor(hWt.prototype,"returnType"),hWt.prototype),uWt=ja(hWt.prototype,"editingDidBegan",[nWt,lo],(function(){return[]})),lWt=ja(hWt.prototype,"textChanged",[rWt,lo],(function(){return[]})),cWt=ja(hWt.prototype,"editingDidEnded",[sWt,lo],(function(){return[]})),_Wt=ja(hWt.prototype,"editingReturn",[aWt,lo],(function(){return[]})),fWt=ja(hWt.prototype,"_textLabel",[lo],(function(){return null})),dWt=ja(hWt.prototype,"_placeholderLabel",[lo],(function(){return null})),pWt=ja(hWt.prototype,"_returnType",[lo],(function(){return WHt.DEFAULT})),mWt=ja(hWt.prototype,"_string",[lo],(function(){return""})),gWt=ja(hWt.prototype,"_tabIndex",[lo],(function(){return 0})),vWt=ja(hWt.prototype,"_backgroundImage",[lo],(function(){return null})),yWt=ja(hWt.prototype,"_inputFlag",[lo],(function(){return jHt.DEFAULT})),SWt=ja(hWt.prototype,"_inputMode",[lo],(function(){return XHt.ANY})),TWt=ja(hWt.prototype,"_maxLength",[lo],(function(){return 20})),oWt=hWt))||oWt)||oWt)||oWt));"object"==typeof window&&"object"==typeof document&&(_Xt._EditBoxImpl=BWt),S.internal.EditBox=_Xt,function(t){t[t.NONE=0]="NONE",t[t.HORIZONTAL=1]="HORIZONTAL",t[t.VERTICAL=2]="VERTICAL",t[t.GRID=3]="GRID"}(aXt||(aXt={})),we(aXt),function(t){t[t.NONE=0]="NONE",t[t.CONTAINER=1]="CONTAINER",t[t.CHILDREN=2]="CHILDREN"}(oXt||(oXt={})),we(oXt),function(t){t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL"}(hXt||(hXt={})),we(hXt),function(t){t[t.BOTTOM_TO_TOP=0]="BOTTOM_TO_TOP",t[t.TOP_TO_BOTTOM=1]="TOP_TO_BOTTOM"}(uXt||(uXt={})),we(uXt),function(t){t[t.LEFT_TO_RIGHT=0]="LEFT_TO_RIGHT",t[t.RIGHT_TO_LEFT=1]="RIGHT_TO_LEFT"}(lXt||(lXt={})),we(lXt),function(t){t[t.NONE=0]="NONE",t[t.FIXED_ROW=1]="FIXED_ROW",t[t.FIXED_COL=2]="FIXED_COL"}(cXt||(cXt={})),we(cXt);var fXt,dXt,pXt,mXt,gXt,vXt,yXt,SXt,TXt,AXt,bXt,EXt,CXt,xXt,wXt=new gn,RXt=t("gO",(MWt=eo("cc.Layout"),PWt=no(110),OWt=io(wO),LWt=Lo(aXt),NWt=Lo(oXt),FWt=Lo(hXt),kWt=Lo(uXt),GWt=Lo(lXt),VWt=Lo(cXt),MWt(UWt=PWt(UWt=OWt(((sXt=function(t){function e(){var e;return(e=t.call(this)||this)._resizeMode=HWt&&HWt(),e._layoutType=WWt&&WWt(),e._cellSize=XWt&&XWt(),e._startAxis=jWt&&jWt(),e._paddingLeft=YWt&&YWt(),e._paddingRight=qWt&&qWt(),e._paddingTop=KWt&&KWt(),e._paddingBottom=QWt&&QWt(),e._spacingX=ZWt&&ZWt(),e._spacingY=JWt&&JWt(),e._verticalDirection=$Wt&&$Wt(),e._horizontalDirection=tXt&&tXt(),e._constraint=eXt&&eXt(),e._constraintNum=iXt&&iXt(),e._affectedByScale=nXt&&nXt(),e._isAlign=rXt&&rXt(),e._layoutSize=new Qn(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._uiProps.uiTransformComp;t.contentSize.equals(Qn.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;e_&&(f=Math.max(_,f),c=_||w,_=w),u+=a*(C*x+this._spacingX);var R=a*(1-C)*x;if(e){if(s>0)(d=y/s>0&&y%s==0)&&(c=_>w?_:c);else if(x>t-g)u>h+a*C*x&&(d=!0);else{var I=(1-this._horizontalDirection-r.x)*t,D=u+R+a*(a>0?this._paddingRight:this._paddingLeft);d=Math.abs(D)>Math.abs(I)}d&&(u=h+a*C*x,w!==_&&(c=_),l+=c+this._spacingY,c=_=w)}var B=i(T,S,l);n&&T.setPosition(u,B),u+=R}return c=Math.max(c,_),Math.max(f,l+c)+this._getPaddingV()},i._doLayoutVertically=function(t,e,i,n){var r=this.node._uiProps.uiTransformComp.anchorPoint,s=this._getFixedBreakingNum(),a=1,o=this._paddingBottom;this._verticalDirection===uXt.TOP_TO_BOTTOM&&(a=-1,o=this._paddingTop);var h=(this._verticalDirection-r.y)*t+a*o,u=h-a*this._spacingY,l=0,c=0,_=0,f=0,d=!1,p=this._usefulLayoutObj.length,m=this._cellSize.height,g=this._getPaddingV();this._layoutType!==aXt.GRID&&this._resizeMode===oXt.CHILDREN&&(m=(t-g-(p-1)*this._spacingY)/p);for(var v=this._usefulLayoutObj,y=0;yl&&(c=Math.max(l,c),_=l||x,l=x),u+=a*(C*w+this._spacingY);var R=a*(1-C)*w;if(e){if(s>0)(d=y/s>0&&y%s==0)&&(_=l>w?l:_);else if(w>t-g)u>h+a*C*w&&(d=!0);else{var I=(1-this._verticalDirection-r.y)*t,D=u+R+a*(a>0?this._paddingTop:this._paddingBottom);d=Math.abs(D)>Math.abs(I)}d&&(u=h+a*C*w,x!==l&&(_=l),f+=_+this._spacingX,_=l=x)}var B=i(T,S,f);n&&(T.getPosition(wXt),T.setPosition(B,u,wXt.z)),u+=R}return _=Math.max(_,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;this._verticalDirection===uXt.TOP_TO_BOTTOM&&(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;this._resizeMode===oXt.CONTAINER&&(h=this._doLayoutHorizontally(n,!0,o,!1),s=-t.y*h,this._verticalDirection===uXt.TOP_TO_BOTTOM&&(r=-1,s=(1-t.y)*h)),this._doLayoutHorizontally(n,!0,o,!0),this._resizeMode===oXt.CONTAINER&&this.node._uiProps.uiTransformComp.setContentSize(n,h)},i._doLayoutGridAxisVertical=function(t,e){var i=this,n=e.height,r=1,s=-t.x*e.width,a=this._paddingLeft;this._horizontalDirection===lXt.RIGHT_TO_LEFT&&(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;this._resizeMode===oXt.CONTAINER&&(h=this._doLayoutVertically(n,!0,o,!1),s=-t.x*h,this._horizontalDirection===lXt.RIGHT_TO_LEFT&&(r=-1,s=(1-t.x)*h)),this._doLayoutVertically(n,!0,o,!0),this._resizeMode===oXt.CONTAINER&&this.node._uiProps.uiTransformComp.setContentSize(h,n)},i._doLayoutGrid=function(){var t=this.node._uiProps.uiTransformComp,e=t.anchorPoint,i=t.contentSize;this.startAxis===hXt.HORIZONTAL?this._doLayoutGridAxisHorizontal(e,i):this.startAxis===hXt.VERTICAL&&this._doLayoutGridAxisVertical(e,i)},i._getHorizontalBaseWidth=function(){var t=this._usefulLayoutObj,e=0,i=t.length;if(this._resizeMode===oXt.CONTAINER){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=ki(h=r/o));var u=(n-a)*h;this._direction===HXt.VERTICAL?t.set(0,u):t.set(u,0)},i._updateLength=function(t){if(this._handle){var e=this._handle.node._uiProps.uiTransformComp,i=e.contentSize,n=e.anchorPoint;n.x===YXt.x&&n.y===YXt.y||e.setAnchorPoint(YXt),this._direction===HXt.HORIZONTAL?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(jn.ZERO))}},{key:"direction",get:function(){return this._direction},set:function(t){this._direction!==t&&(this._direction=t,this.onScroll(jn.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}(mp)).Direction=HXt,m((LXt=UXt).prototype,"handle",[MXt],Object.getOwnPropertyDescriptor(LXt.prototype,"handle"),LXt.prototype),m(LXt.prototype,"direction",[PXt],Object.getOwnPropertyDescriptor(LXt.prototype,"direction"),LXt.prototype),NXt=ja(LXt.prototype,"_scrollView",[lo],(function(){return null})),FXt=ja(LXt.prototype,"_handle",[lo],(function(){return null})),kXt=ja(LXt.prototype,"_direction",[lo],(function(){return HXt.HORIZONTAL})),GXt=ja(LXt.prototype,"_enableAutoHide",[lo],(function(){return!1})),VXt=ja(LXt.prototype,"_autoHideTime",[lo],(function(){return 1})),OXt=LXt))||OXt)||OXt)||OXt));S.ScrollBar=ZXt;var JXt,$Xt,tjt,ejt,ijt,njt,rjt,sjt,ajt,ojt,hjt,ujt,ljt,cjt,_jt,fjt,djt,pjt,mjt,gjt,vjt,yjt=t("gV",eo("cc.ViewGroup")(QXt=no(110)(QXt=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e}(mp))||QXt)||QXt);S.ViewGroup=yjt;var Sjt,Tjt,Ajt=1e-4,bjt=new gn,Ejt=new gn,Cjt=new jn,xjt=new jn,wjt=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};!function(t){t.NONE="",t.SCROLL_TO_TOP="scroll-to-top",t.SCROLL_TO_BOTTOM="scroll-to-bottom",t.SCROLL_TO_LEFT="scroll-to-left",t.SCROLL_TO_RIGHT="scroll-to-right",t.SCROLL_BEGAN="scroll-began",t.SCROLL_ENDED="scroll-ended",t.BOUNCE_TOP="bounce-top",t.BOUNCE_BOTTOM="bounce-bottom",t.BOUNCE_LEFT="bounce-left",t.BOUNCE_RIGHT="bounce-right",t.SCROLLING="scrolling",t.SCROLL_ENG_WITH_THRESHOLD="scroll-ended-with-threshold",t.TOUCH_UP="touch-up"}(Sjt||(Sjt={})),function(t){t[t.NONE=0]="NONE",t[t.LEFT=1]="LEFT",t[t.RIGHT=2]="RIGHT"}(Tjt||(Tjt={}));var Ijt,Djt,Bjt,Mjt,Pjt,Ojt,Ljt,Njt,Fjt,kjt,Gjt,Vjt,Ujt,zjt=t("gR",(JXt=eo("cc.ScrollView"),$Xt=no(110),tjt=io(wO),ejt=Lo(hg),ijt=Lo(ZXt),njt=Lo(ZXt),rjt=Lo([fp]),JXt(sjt=$Xt(sjt=tjt(((vjt=function(t){function e(){var e;return(e=t.call(this)||this).bounceDuration=ojt&&ojt(),e.brake=hjt&&hjt(),e.elastic=ujt&&ujt(),e.inertia=ljt&&ljt(),e.horizontal=cjt&&cjt(),e.vertical=_jt&&_jt(),e.cancelInnerEvents=fjt&&fjt(),e.scrollEvents=djt&&djt(),e._autoScrolling=!1,e._scrolling=!1,e._content=pjt&&pjt(),e._horizontalScrollBar=mjt&&mjt(),e._verticalScrollBar=gjt&&gjt(),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 gn,e._autoScrollTargetDelta=new gn,e._autoScrollTotalTime=0,e._autoScrollAccumulatedTime=0,e._autoScrollCurrentlyOutOfBoundary=!1,e._autoScrollBraking=!1,e._autoScrollBrakingStartPosition=new gn,e._outOfBoundaryAmount=new gn,e._outOfBoundaryAmountDirty=!0,e._stopMouseWheel=!1,e._mouseWheelEventElapsedTime=0,e._isScrollEndedWithThresholdEventFired=!1,e._scrollEventEmitMask=0,e._isBouncing=!1,e._contentPos=new gn,e._deltaPos=new gn,e._deltaAmount=new gn,e._hoverIn=Tjt.NONE,e}s(e,t);var i=e.prototype;return i.scrollToBottom=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new jn(0,0),applyToHorizontal:!1,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i,!0)},i.scrollToTop=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new jn(0,1),applyToHorizontal:!1,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},i.scrollToLeft=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new jn(0,0),applyToHorizontal:!0,applyToVertical:!1});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},i.scrollToRight=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new jn(1,0),applyToHorizontal:!0,applyToVertical:!1});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},i.scrollToTopLeft=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new jn(0,1),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},i.scrollToTopRight=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new jn(1,1),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},i.scrollToBottomLeft=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new jn(0,0),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},i.scrollToBottomRight=function(t,e){void 0===e&&(e=!0);var i=this._calculateMovePercentDelta({anchor:new jn(1,0),applyToHorizontal:!0,applyToVertical:!0});t?this._startAutoScroll(i,t,!1!==e):this._moveContent(i)},i.scrollToOffset=function(t,e,i){void 0===i&&(i=!0);var n=this.getMaxScrollOffset(),r=new jn(0,0);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 jn(e,t)},i.getMaxScrollOffset=function(){if(!this._content||!this.view)return jn.ZERO;var t=this._content._uiProps.uiTransformComp.contentSize,e=t.width-this.view.width,i=t.height-this.view.height;return new jn(e=e>=0?e:0,i=i>=0?i:0)},i.scrollToPercentHorizontal=function(t,e,i){var n=this._calculateMovePercentDelta({anchor:new jn(t,0),applyToHorizontal:!0,applyToVertical:!1});e?this._startAutoScroll(n,e,!1!==i):this._moveContent(n)},i.scrollTo=function(t,e,i){var n=this._calculateMovePercentDelta({anchor:new jn(t),applyToHorizontal:!0,applyToVertical:!0});e?this._startAutoScroll(n,e,i):this._moveContent(n)},i.scrollToPercentVertical=function(t,e,i){var n=this._calculateMovePercentDelta({anchor:new jn(0,t),applyToHorizontal:!1,applyToVertical:!0});e?this._startAutoScroll(n,e,i):this._moveContent(n)},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&&!this._touchMoved&&t.target!==this.node){var r=new Wx(t.getTouches(),t.bubbles,Fx.TOUCH_CANCEL);r.touch=t.touch,r.simulate=!0,t.target.dispatchEvent(r),this._touchMoved=!0}this._stopPropagationIfTargetIsMe(t)}}},i._onTouchEnded=function(t,e){if(this.enabledInHierarchy&&this._content&&t&&!this._hasNestedViewGroup(t,e)){this._dispatchEvent(Sjt.TOUCH_UP);var i=t.touch;this._handleReleaseLogic(i),this._touchMoved?t.propagationStopped=!0:this._stopPropagationIfTargetIsMe(t)}},i._onTouchCancelled=function(t,e){if(this.enabledInHierarchy&&this._content&&!this._hasNestedViewGroup(t,e)){if(t&&!t.simulate){var i=t.touch;this._handleReleaseLogic(i)}this._stopPropagationIfTargetIsMe(t)}},i._calculateBoundary=function(){if(this._content&&this.view){var t=this._content.getComponent(RXt);t&&t.enabledInHierarchy&&t.updateLayout();var e=this.view,i=e.width*e.anchorX,n=e.height*e.anchorY;this._leftBoundary=-i,this._bottomBoundary=-n,this._rightBoundary=this._leftBoundary+e.width,this._topBoundary=this._bottomBoundary+e.height,this._moveContentToTopLeft(e.contentSize)}},i._hasNestedViewGroup=function(t,e){if(!t||t.eventPhase!==Gx.CAPTURING_PHASE)return!1;if(e)for(var i,n=f(e);!(i=n()).done;){var r=i.value;if(this.node===r)return!(!t.target||!t.target.getComponent(yjt));if(r.getComponent(yjt))return!0}return!1},i._startInertiaScroll=function(t){var e=new gn(t);e.multiplyScalar(.7),this._startAttenuatingAutoScroll(e,t)},i._calculateAttenuatedFactor=function(t){return this.brake<=0?1-this.brake:(1-this.brake)*(1/(1+14e-6*t+t*t*8e-9))},i._startAttenuatingAutoScroll=function(t,e){var i=t.clone();if(i.normalize(),this._content&&this.view){var n=this._content._uiProps.uiTransformComp.contentSize,r=this.view.contentSize,s=n.width-r.width,a=n.height-r.height,o=this._calculateAttenuatedFactor(s),h=this._calculateAttenuatedFactor(a);i.x=i.x*s*(1-this.brake)*o,i.y=i.y*a*h*(1-this.brake),i.z=0}var u=t.length(),l=i.length()/u;if(i.add(t),this.brake>0&&l>7){l=Math.sqrt(l);var c=t.clone();c.multiplyScalar(l),i.set(c),i.add(t)}var _=this._calculateAutoScrollTimeByInitialSpeed(e.length());this.brake>0&&l>3&&(_*=l=3),0===this.brake&&l>1&&(_*=l),this._startAutoScroll(i,_,!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._flattenVectorByDirection(t);this._autoScrolling=!0,this._autoScrollTargetDelta=n,this._autoScrollAttenuate=i,gn.copy(this._autoScrollStartPosition,this._getContentPosition()),this._autoScrollTotalTime=e,this._autoScrollAccumulatedTime=0,this._autoScrollBraking=!1,this._isScrollEndedWithThresholdEventFired=!1,this._autoScrollBrakingStartPosition.set(0,0,0),this._getHowMuchOutOfBoundary().equals(gn.ZERO,Ajt)||(this._autoScrollCurrentlyOutOfBoundary=!0)},i._calculateTouchMoveVelocity=function(){var t=new gn,e=0;if((e=this._touchMoveTimeDeltas.reduce((function(t,e){return t+e}),e))<=0||e>=.5)t.set(gn.ZERO);else{var i=new gn;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){var e=t;return e.x=this.horizontal?e.x:0,e.y=this.vertical?e.y:0,e},i._moveContent=function(t,e){var i=this._flattenVectorByDirection(t);bjt.set(this._getContentPosition()),bjt.add(i),bjt.set(Math.round(1e4*bjt.x)*Ajt,Math.round(1e4*bjt.y)*Ajt,bjt.z),this._setContentPosition(bjt);var n=this._getHowMuchOutOfBoundary();Cjt.set(n.x,n.y),this._updateScrollBar(Cjt),this.elastic&&e&&this._startBounceBackIfNeeded()},i._getContentLeftBoundary=function(){if(!this._content)return-1;var t=this._getContentPosition(),e=this._content._uiProps.uiTransformComp;return t.x-e.anchorX*e.width},i._getContentRightBoundary=function(){if(!this._content)return-1;var t=this._content._uiProps.uiTransformComp;return this._getContentLeftBoundary()+t.width},i._getContentTopBoundary=function(){if(!this._content)return-1;var t=this._content._uiProps.uiTransformComp;return this._getContentBottomBoundary()+t.height},i._getContentBottomBoundary=function(){if(!this._content)return-1;var t=this._getContentPosition(),e=this._content._uiProps.uiTransformComp;return t.y-e.anchorY*e.height},i._getHowMuchOutOfBoundary=function(t){if((t=t||new gn).equals(gn.ZERO,Ajt)&&!this._outOfBoundaryAmountDirty)return this._outOfBoundaryAmount;var e=new gn,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(gn.ZERO,Ajt)&&(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(t===Sjt.SCROLL_ENDED)this._scrollEventEmitMask=0;else if(t===Sjt.SCROLL_TO_TOP||t===Sjt.SCROLL_TO_BOTTOM||t===Sjt.SCROLL_TO_LEFT||t===Sjt.SCROLL_TO_RIGHT){var e=1<0?l.y-o*u+i.y>=this._bottomBoundary&&(n=Sjt.SCROLL_TO_BOTTOM):i.y<0&&l.y-o*u+u+i.y<=this._topBoundary&&(n=Sjt.SCROLL_TO_TOP)),this.horizontal&&(i.x<0?l.x-a*h+h+i.x<=this._rightBoundary&&(r=Sjt.SCROLL_TO_RIGHT):i.x>0&&l.x-a*h+i.x>=this._leftBoundary&&(r=Sjt.SCROLL_TO_LEFT))}this._moveContent(i,!1),(this.horizontal&&0!==i.x||this.vertical&&0!==i.y)&&(this._scrolling||(this._scrolling=!0,this._dispatchEvent(Sjt.SCROLL_BEGAN)),this._dispatchEvent(Sjt.SCROLLING)),n!==Sjt.NONE&&this._dispatchEvent(n),r!==Sjt.NONE&&this._dispatchEvent(r)},i._handlePressLogic=function(){this._autoScrolling&&this._dispatchEvent(Sjt.SCROLL_ENDED),this._autoScrolling=!1,this._isBouncing=!1,this._touchMovePreviousTimestamp=wjt(),this._touchMoveDisplacements.length=0,this._touchMoveTimeDeltas.length=0,this._onScrollBarTouchBegan()},i._clampDelta=function(t){if(this._content&&this.view){var e=this.view.contentSize,i=this._content._uiProps.uiTransformComp;i.width=5;)this._touchMoveDisplacements.shift(),this._touchMoveTimeDeltas.shift();this._touchMoveDisplacements.push(e);var i=wjt();this._touchMoveTimeDeltas.push((i-this._touchMovePreviousTimestamp)/1e3),this._touchMovePreviousTimestamp=i},i._startBounceBackIfNeeded=function(){if(!this.elastic)return!1;var t=this._getHowMuchOutOfBoundary();if(this._clampDelta(t),t.equals(gn.ZERO,Ajt))return!1;var e=Math.max(this.bounceDuration,0);return this._startAutoScroll(t,e,!0),this._isBouncing||(t.y>0&&this._dispatchEvent(Sjt.BOUNCE_TOP),t.y<0&&this._dispatchEvent(Sjt.BOUNCE_BOTTOM),t.x>0&&this._dispatchEvent(Sjt.BOUNCE_RIGHT),t.x<0&&this._dispatchEvent(Sjt.BOUNCE_LEFT),this._isBouncing=!0),!0},i._processInertiaScroll=function(){if(!this._startBounceBackIfNeeded()&&this.inertia){var t=this._calculateTouchMoveVelocity();!t.equals(bjt,Ajt)&&this.brake<1&&this._startInertiaScroll(t)}this._onScrollBarTouchEnded()},i._isOutOfBoundary=function(){return!this._getHowMuchOutOfBoundary().equals(gn.ZERO,Ajt)},i._isNecessaryAutoScrollBrake=function(){if(this._autoScrollBraking)return!0;if(this._isOutOfBoundary()){if(!this._autoScrollCurrentlyOutOfBoundary)return this._autoScrollCurrentlyOutOfBoundary=!0,this._autoScrollBraking=!0,gn.copy(this._autoScrollBrakingStartPosition,this._getContentPosition()),!0}else this._autoScrollCurrentlyOutOfBoundary=!1;return!1},i._processAutoScrolling=function(t){var e=this._isNecessaryAutoScrollBrake(),i=e?.05:1;this._autoScrollAccumulatedTime+=t*(1/i);var n,r=Math.min(1,this._autoScrollAccumulatedTime/this._autoScrollTotalTime);this._autoScrollAttenuate&&(n=r,r=(n-=1)*n*n*n*n+1);var s=this._autoScrollTargetDelta.clone();s.multiplyScalar(r);var a=this._autoScrollStartPosition.clone();a.add(s);var o=Math.abs(r-1)<=Ajt;if(Math.abs(r-1)<=this.getScrollEndedEventTiming()&&!this._isScrollEndedWithThresholdEventFired&&(this._dispatchEvent(Sjt.SCROLL_ENG_WITH_THRESHOLD),this._isScrollEndedWithThresholdEventFired=!0),this.elastic){var h=a.clone();h.subtract(this._autoScrollBrakingStartPosition),e&&h.multiplyScalar(i),a.set(this._autoScrollBrakingStartPosition),a.add(h)}else{var u=a.clone();u.subtract(this.getContentPosition());var l=this._getHowMuchOutOfBoundary(u);l.equals(gn.ZERO,Ajt)||(a.add(l),o=!0)}o&&(this._autoScrolling=!1);var c=a.clone();c.subtract(this._getContentPosition()),this._clampDelta(c),this._moveContent(c,o),this._dispatchEvent(Sjt.SCROLLING),this._autoScrolling||(this._isBouncing=!1,this._scrolling=!1,this._dispatchEvent(Sjt.SCROLL_ENDED))},i._checkMouseWheel=function(t){if(!this._getHowMuchOutOfBoundary().equals(gn.ZERO,Ajt))return this._processInertiaScroll(),this._scrolling&&(this._scrolling=!1,this._autoScrolling||this._dispatchEvent(Sjt.SCROLL_ENDED)),this.unschedule(this._checkMouseWheel),void(this._stopMouseWheel=!1);this._mouseWheelEventElapsedTime+=t,this._mouseWheelEventElapsedTime>.1&&(this._onScrollBarTouchEnded(),this._scrolling&&(this._scrolling=!1,this._autoScrolling||this._dispatchEvent(Sjt.SCROLL_ENDED)),this.unschedule(this._checkMouseWheel),this._stopMouseWheel=!1)},i._calculateMovePercentDelta=function(t){var e=t.anchor,i=t.applyToHorizontal,n=t.applyToVertical;this._calculateBoundary(),e.clampf(jn.ZERO,jn.ONE);var r=this._getContentBottomBoundary()-this._bottomBoundary;r=-r;var s=this._getContentLeftBoundary()-this._leftBoundary;s=-s;var a=new gn;if(this._content&&this.view){var o=0,h=this._content._uiProps.uiTransformComp.contentSize,u=this.view.contentSize;i&&(o=h.width-u.width,a.x=s-o*e.x),n&&(o=h.height-u.height,a.y=r-o*e.y)}return a},i._moveContentToTopLeft=function(t){var e=this._getContentBottomBoundary()-this._bottomBoundary;e=-e;var i=new gn,n=0,r=this._getContentLeftBoundary()-this._leftBoundary;if(r=-r,this._content){var s=this._content._uiProps.uiTransformComp.contentSize;s.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:Ta;this.isAlignLeft&&t===UYt.LEFT?this._left=e?this._left*r.width:this._left/r.width:this.isAlignRight&&t===UYt.RIGHT?this._right=e?this._right*r.width:this._right/r.width:this.isAlignHorizontalCenter&&t===UYt.CENTER?this._horizontalCenter=e?this._horizontalCenter*r.width:this._horizontalCenter/r.width:this.isAlignTop&&t===UYt.TOP?this._top=e?this._top*r.height:this._top/r.height:this.isAlignBottom&&t===UYt.BOT?this._bottom=e?this._bottom*r.height:this._bottom/r.height:this.isAbsoluteVerticalCenter&&t===UYt.MID&&(this._verticalCenter=this._verticalCenter/r.height),this._recursiveDirty()}},i._registerTargetEvents=function(){var t=this._target||this.node.parent;t&&t.getComponent(wO)&&(t.on(vm.TRANSFORM_CHANGED,this._setDirtyByMode,this),t.on(vm.SIZE_CHANGED,this._setDirtyByMode,this),t.on(vm.ANCHOR_CHANGED,this._setDirtyByMode,this))},i._unregisterTargetEvents=function(){var t=this._target||this.node.parent;t&&(t.off(vm.TRANSFORM_CHANGED,this._setDirtyByMode,this),t.off(vm.SIZE_CHANGED,this._setDirtyByMode,this),t.off(vm.ANCHOR_CHANGED,this._setDirtyByMode,this))},i._unregisterOldParentEvents=function(t){var e=this._target||t;e&&(e.off(vm.TRANSFORM_CHANGED,this._setDirtyByMode,this),e.off(vm.SIZE_CHANGED,this._setDirtyByMode,this))},i._setDirtyByMode=function(){this.alignMode===VYt.ALWAYS&&this._recursiveDirty()},i._setAlign=function(t,e){if(e!==(this._alignFlags&t)>0){var i=(t&rqt)>0,n=this.node._uiProps.uiTransformComp;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(this._alignFlags&UYt.TOP)>0},set:function(t){this._setAlign(UYt.TOP,t),this._recursiveDirty()}},{key:"isAlignBottom",get:function(){return(this._alignFlags&UYt.BOT)>0},set:function(t){this._setAlign(UYt.BOT,t),this._recursiveDirty()}},{key:"isAlignLeft",get:function(){return(this._alignFlags&UYt.LEFT)>0},set:function(t){this._setAlign(UYt.LEFT,t),this._recursiveDirty()}},{key:"isAlignRight",get:function(){return(this._alignFlags&UYt.RIGHT)>0},set:function(t){this._setAlign(UYt.RIGHT,t),this._recursiveDirty()}},{key:"isAlignVerticalCenter",get:function(){return(this._alignFlags&UYt.MID)>0},set:function(t){t?(this.isAlignTop=!1,this.isAlignBottom=!1,this._alignFlags|=UYt.MID):this._alignFlags&=~UYt.MID,this._recursiveDirty()}},{key:"isAlignHorizontalCenter",get:function(){return(this._alignFlags&UYt.CENTER)>0},set:function(t){t?(this.isAlignLeft=!1,this.isAlignRight=!1,this._alignFlags|=UYt.CENTER):this._alignFlags&=~UYt.CENTER,this._recursiveDirty()}},{key:"isStretchWidth",get:function(){return(this._alignFlags&rqt)===rqt}},{key:"isStretchHeight",get:function(){return(this._alignFlags&nqt)===nqt}},{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(UYt.TOP,this._isAbsTop))}},{key:"isAbsoluteBottom",get:function(){return this._isAbsBottom},set:function(t){this._isAbsBottom!==t&&(this._isAbsBottom=t,this._autoChangedValue(UYt.BOT,this._isAbsBottom))}},{key:"isAbsoluteLeft",get:function(){return this._isAbsLeft},set:function(t){this._isAbsLeft!==t&&(this._isAbsLeft=t,this._autoChangedValue(UYt.LEFT,this._isAbsLeft))}},{key:"isAbsoluteRight",get:function(){return this._isAbsRight},set:function(t){this._isAbsRight!==t&&(this._isAbsRight=t,this._autoChangedValue(UYt.RIGHT,this._isAbsRight))}},{key:"isAbsoluteHorizontalCenter",get:function(){return this._isAbsHorizontalCenter},set:function(t){this._isAbsHorizontalCenter!==t&&(this._isAbsHorizontalCenter=t,this._autoChangedValue(UYt.CENTER,this._isAbsHorizontalCenter))}},{key:"isAbsoluteVerticalCenter",get:function(){return this._isAbsVerticalCenter},set:function(t){this._isAbsVerticalCenter!==t&&(this._isAbsVerticalCenter=t,this._autoChangedValue(UYt.MID,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}(mp)).AlignMode=VYt,m((yYt=kYt).prototype,"target",[mYt],Object.getOwnPropertyDescriptor(yYt.prototype,"target"),yYt.prototype),m(yYt.prototype,"alignMode",[gYt],Object.getOwnPropertyDescriptor(yYt.prototype,"alignMode"),yYt.prototype),SYt=ja(yYt.prototype,"_alignFlags",[lo],(function(){return 0})),TYt=ja(yYt.prototype,"_target",[lo],(function(){return null})),AYt=ja(yYt.prototype,"_left",[lo],(function(){return 0})),bYt=ja(yYt.prototype,"_right",[lo],(function(){return 0})),EYt=ja(yYt.prototype,"_top",[lo],(function(){return 0})),CYt=ja(yYt.prototype,"_bottom",[lo],(function(){return 0})),xYt=ja(yYt.prototype,"_horizontalCenter",[lo],(function(){return 0})),wYt=ja(yYt.prototype,"_verticalCenter",[lo],(function(){return 0})),RYt=ja(yYt.prototype,"_isAbsLeft",[lo],(function(){return!0})),IYt=ja(yYt.prototype,"_isAbsRight",[lo],(function(){return!0})),DYt=ja(yYt.prototype,"_isAbsTop",[lo],(function(){return!0})),BYt=ja(yYt.prototype,"_isAbsBottom",[lo],(function(){return!0})),MYt=ja(yYt.prototype,"_isAbsHorizontalCenter",[lo],(function(){return!0})),PYt=ja(yYt.prototype,"_isAbsVerticalCenter",[lo],(function(){return!0})),OYt=ja(yYt.prototype,"_originalWidth",[lo],(function(){return 0})),LYt=ja(yYt.prototype,"_originalHeight",[lo],(function(){return 0})),NYt=ja(yYt.prototype,"_alignMode",[lo],(function(){return VYt.ON_WINDOW_RESIZE})),FYt=ja(yYt.prototype,"_lockFlags",[lo,_o],(function(){return 0})),vYt=yYt))||vYt)||vYt)||vYt));S.internal.computeInverseTransForTarget=WYt,S.internal.getReadonlyNodeSize=HYt,S.Widget=sqt;var aqt,oqt=new En;!function(t){t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL"}(aqt||(aqt={})),we(aqt);var hqt,uqt,lqt,cqt,_qt,fqt,dqt,pqt,mqt,gqt,vqt,yqt,Sqt,Tqt,Aqt,bqt,Eqt,Cqt,xqt,wqt,Rqt,Iqt,Dqt,Bqt,Mqt=t("gY",(XYt=eo("cc.PageViewIndicator"),jYt=no(110),YYt=Lo(SM),qYt=Lo(aqt),KYt=Lo(Qn),XYt(QYt=jYt(((iqt=function(t){function e(){var e;return(e=t.call(this)||this).spacing=JYt&&JYt(),e._spriteFrame=$Yt&&$Yt(),e._direction=tqt&&tqt(),e._cellSize=eqt&&eqt(),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(RXt),this._layout||(this._layout=this.addComponent(RXt));var t=this._layout;this.direction===aqt.HORIZONTAL?(t.type=RXt.Type.HORIZONTAL,t.spacingX=this.spacing):this.direction===aqt.VERTICAL&&(t.type=RXt.Type.VERTICAL,t.spacingY=this.spacing),t.resizeMode=RXt.ResizeMode.CONTAINER},i._createIndicator=function(){var t=new hg;t.layer=this.node.layer;var e=t.addComponent(PF);return e.spriteFrame=this.spriteFrame,e.sizeMode=PF.SizeMode.CUSTOM,t.parent=this.node,t._uiProps.uiTransformComp.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}(mp)).Direction=aqt,m((ZYt=iqt).prototype,"spriteFrame",[YYt],Object.getOwnPropertyDescriptor(ZYt.prototype,"spriteFrame"),ZYt.prototype),m(ZYt.prototype,"direction",[qYt],Object.getOwnPropertyDescriptor(ZYt.prototype,"direction"),ZYt.prototype),m(ZYt.prototype,"cellSize",[KYt],Object.getOwnPropertyDescriptor(ZYt.prototype,"cellSize"),ZYt.prototype),JYt=ja(ZYt.prototype,"spacing",[lo],(function(){return 0})),$Yt=ja(ZYt.prototype,"_spriteFrame",[lo],(function(){return null})),tqt=ja(ZYt.prototype,"_direction",[lo],(function(){return aqt.HORIZONTAL})),eqt=ja(ZYt.prototype,"_cellSize",[lo],(function(){return new Qn(20,20)})),QYt=ZYt))||QYt)||QYt));S.PageViewIndicator=Mqt;var Pqt,Oqt,Lqt,Nqt=new jn;!function(t){t[t.Unified=0]="Unified",t[t.Free=1]="Free"}(Pqt||(Pqt={})),we(Pqt),function(t){t[t.Horizontal=0]="Horizontal",t[t.Vertical=1]="Vertical"}(Oqt||(Oqt={})),we(Oqt),function(t){t.PAGE_TURNING="page-turning"}(Lqt||(Lqt={}));var Fqt=t("gX",(hqt=eo("cc.PageView"),uqt=no(110),lqt=Lo(Pqt),cqt=Lo(Oqt),_qt=Lo(Mqt),fqt=Lo(ZXt),dqt=Lo(ZXt),pqt=Lo([fp]),mqt=Lo([fp]),hqt(gqt=uqt(((Bqt=function(t){function e(){var e;return(e=t.call(this)||this).autoPageTurningThreshold=yqt&&yqt(),e.horizontal=Sqt&&Sqt(),e.vertical=Tqt&&Tqt(),e.cancelInnerEvents=Aqt&&Aqt(),e.scrollEvents=bqt&&bqt(),e.pageTurningSpeed=Eqt&&Eqt(),e.pageEvents=Cqt&&Cqt(),e._sizeMode=xqt&&xqt(),e._direction=wqt&&wqt(),e._scrollThreshold=Rqt&&Rqt(),e._pageTurningEventTiming=Iqt&&Iqt(),e._indicator=Dqt&&Dqt(),e._curPageIdx=0,e._lastPageIdx=0,e._pages=[],e._initContentPos=vn(),e._scrollCenterOffsetX=[],e._scrollCenterOffsetY=[],e._touchBeganPosition=Yn(),e._touchEndPosition=Yn(),e}s(e,t);var i=e.prototype;return i.onEnable=function(){t.prototype.onEnable.call(this),this.node.on(vm.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(vm.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._uiProps.uiTransformComp?(this.content.addChild(t),this._pages.push(t),this._updatePageView()):Q(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._uiProps.uiTransformComp)return void Q(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):tt(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(RXt);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]._uiProps.uiTransformComp,n=this._pages[this._pages.length-1]._uiProps.uiTransformComp;this.direction===Oqt.Horizontal?(e.paddingLeft=(t.width-i.width)/2,e.paddingRight=(t.width-n.width)/2):this.direction===Oqt.Vertical&&(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,fp.emitEvents(this.pageEvents,this,Lqt.PAGE_TURNING),this.node.emit(Lqt.PAGE_TURNING,this))},i._isQuicklyScrollable=function(t){if(this.direction===Oqt.Horizontal){if(Math.abs(t.x)>this.autoPageTurningThreshold)return!0}else if(this.direction===Oqt.Vertical&&Math.abs(t.y)>this.autoPageTurningThreshold)return!0;return!1},i._moveOffsetValue=function(t){var e=new jn;if(this._sizeMode===Pqt.Free)this.direction===Oqt.Horizontal?e.x=this._scrollCenterOffsetX[t]:this.direction===Oqt.Vertical&&(e.y=this._scrollCenterOffsetY[t]);else{var i=this.view;if(!i)return e;this.direction===Oqt.Horizontal?e.x=t*i.width:this.direction===Oqt.Vertical&&(e.y=t*i.height)}return e},i._getDragDirection=function(t){return this._direction===Oqt.Horizontal?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(this._sizeMode===Pqt.Free){var n=0,r=0;if(this.direction===Oqt.Horizontal)return n=this._scrollCenterOffsetX[e],r=this._scrollCenterOffsetX[i],Math.abs(t.x)>=Math.abs(n-r)*this.scrollThreshold;if(this.direction===Oqt.Vertical)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(this.direction===Oqt.Horizontal)return Math.abs(t.x)>=s.width*this.scrollThreshold;if(this.direction===Oqt.Vertical)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 jn;jn.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=zqt;s.set(0,0);var a=Hqt;if(a.set(1,1),t.target&&WYt(n,r=t.target,s,a),!e)return;var o=r._uiProps&&r._uiProps.uiTransformComp,h=o?o.anchorPoint:Gqt,u=n._uiProps.uiTransformComp,l=HYt(r),c=u.anchorPoint,_=n.position,f=UYt,d=n.scale,p=0;if(e&f.LEFT){var m=-h.x*l.width;m+=s.x,m*=a.x,p=_.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&f.RIGHT){var g=(1-h.x)*l.width;g+=s.x,p=(g*=a.x)-(_.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&f.TOP){var v=(1-h.y)*l.height;v+=s.y,p=(v*=a.y)-(_.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&f.BOT){var y=-h.y*l.height;y+=s.y,y*=a.y,p=_.y-c.y*u.height*Math.abs(d.y)-y,t.isAbsoluteBottom||(p/=l.height),p/=a.y,t.bottom=i(t.bottom,p)}}},updateAlignment:function t(e){var i=e.parent;i&&hg.isNode(i)&&t(i);var n=e.getComponent(sqt);n&&i&&Wqt(e,n)},AlignMode:VYt,AlignFlags:UYt});ID.on(wD.EVENT_INIT,(function(){Zqt.init()}));var Jqt,$qt,tKt,eKt,iKt,nKt,rKt,sKt,aKt,oKt,hKt,uKt,lKt=t("gZ",eo("cc.SafeArea")(Yqt=no(110)(Yqt=io(sqt)((qqt=function(t){function e(){var e;return(e=t.call(this)||this)._symmetric=Kqt&&Kqt(),e}s(e,t);var i=e.prototype;return i.onEnable=function(){this.updateArea(),ga.on("window-resize",this.updateArea,this),ga.on("orientation-change",this.updateArea,this)},i.onDisable=function(){ga.off("window-resize",this.updateArea,this),ga.off("orientation-change",this.updateArea,this)},i.updateArea=function(){var t=this.node.getComponent(sqt),e=this.node.getComponent(wO);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=yB.getVisibleSize(),s=r.width,a=r.height,o=Sa.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),Zqt.add(t)}},n(e,[{key:"symmetric",get:function(){return this._symmetric},set:function(t){this._symmetric=t}}]),e}(mp),Kqt=ja(qqt.prototype,"_symmetric",[lo],(function(){return!0})),Yqt=qqt))||Yqt)||Yqt)||Yqt);S.SafeArea=lKt;var cKt,_Kt=t("g_",(Jqt=eo("cc.UICoordinateTracker"),$qt=no(110),tKt=Lo(hg),eKt=Lo(Nk),iKt=Lo([fp]),Jqt(nKt=$qt((m((rKt=function(t){function e(){var e;return(e=t.call(this)||this).syncEvents=sKt&&sKt(),e._target=aKt&&aKt(),e._camera=oKt&&oKt(),e._useScale=hKt&&hKt(),e._distance=uKt&&uKt(),e._transformPos=vn(),e._viewPos=vn(),e._canMove=!0,e._lastWPos=vn(),e._lastCameraPos=vn(),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&&gn.transformMat4(this._viewPos,this.node.worldPosition,e.camera.matView),this.syncEvents.length>0)){var i=this._distance/Math.abs(this._viewPos.z);fp.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}(mp)).prototype,"target",[tKt],Object.getOwnPropertyDescriptor(rKt.prototype,"target"),rKt.prototype),m(rKt.prototype,"camera",[eKt],Object.getOwnPropertyDescriptor(rKt.prototype,"camera"),rKt.prototype),sKt=ja(rKt.prototype,"syncEvents",[iKt,lo],(function(){return[]})),aKt=ja(rKt.prototype,"_target",[lo],(function(){return null})),oKt=ja(rKt.prototype,"_camera",[lo],(function(){return null})),hKt=ja(rKt.prototype,"_useScale",[lo],(function(){return!0})),uKt=ja(rKt.prototype,"_distance",[lo],(function(){return 1})),nKt=rKt))||nKt)||nKt)),fKt=[vm.TOUCH_START,vm.TOUCH_END,vm.TOUCH_MOVE,vm.MOUSE_DOWN,vm.MOUSE_MOVE,vm.MOUSE_UP,vm.MOUSE_ENTER,vm.MOUSE_LEAVE,vm.MOUSE_WHEEL];function dKt(t){t.propagationStopped=!0}var pKt,mKt,gKt,vKt,yKt,SKt=t("g$",eo("cc.BlockInputEvents")(cKt=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=yB.getViewportRect(),a=e.getBoundingBoxToWorld(),o=yB.getVisibleSize(),h=ga.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,_=s.height*(a.height/o.height)/h;this._openDataContext.postMessage({fromEngine:!0,type:"engine",event:"viewport",x:u,y:l,width:c,height:_})}},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(vm.TRANSFORM_CHANGED,this._updateSubContextView,this),this.node.on(vm.SIZE_CHANGED,this._updateSubContextView,this),this.node.on(vm.LAYER_CHANGED,this._updateContentLayer,this)},i._unregisterNodeEvent=function(){this.node.off(vm.TRANSFORM_CHANGED,this._updateSubContextView,this),this.node.off(vm.SIZE_CHANGED,this._updateSubContextView,this),this.node.off(vm.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}(mp),gKt=ja(mKt.prototype,"_fps",[lo],(function(){return 60})),vKt=ja(mKt.prototype,"_designResolutionSize",[lo],(function(){return new Qn(640,960)})),pKt=mKt))||pKt)||pKt)||pKt);S.SubContextView=TKt,Tt({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 AKt,bKt,EKt,CKt=t("h5",eo("cc.UIReorderComponent")(yKt=function(){tt(1408,"UIReorderComponent")})||yKt);S.UIReorderComponent=CKt,S.ButtonComponent=HHt,ne(HHt,"cc.ButtonComponent"),S.EditBoxComponent=_Xt,ne(_Xt,"cc.EditBoxComponent"),S.LayoutComponent=RXt,ne(RXt,"cc.LayoutComponent"),S.ProgressBarComponent=zXt,ne(zXt,"cc.ProgressBarComponent"),S.ScrollViewComponent=zjt,ne(zjt,"cc.ScrollViewComponent"),S.ScrollBarComponent=ZXt,ne(ZXt,"cc.ScrollBarComponent"),S.SliderComponent=nYt,ne(nYt,"cc.SliderComponent"),S.ToggleComponent=_Yt,ne(_Yt,"cc.ToggleComponent"),S.ToggleContainerComponent=GYt,ne(GYt,"cc.ToggleContainerComponent"),S.WidgetComponent=sqt,ne(sqt,"cc.WidgetComponent"),S.PageViewComponent=Fqt,ne(Fqt,"cc.PageViewComponent"),S.PageViewIndicatorComponent=Mqt,ne(Mqt,"cc.PageViewIndicatorComponent"),S.SafeAreaComponent=lKt,ne(lKt,"cc.SafeAreaComponent"),ne(_Kt,"cc.UICoordinateTrackerComponent"),S.BlockInputEventsComponent=SKt,ne(SKt,"cc.BlockInputEventsComponent"),lt(hB.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"}]),ct(hB.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 xKt=t("h6",eo("cc.VideoClip")((bKt=function(t){function e(){var e;return(e=t.call(this)||this)._duration=EKt&&EKt(),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}(vd),EKt=ja(bKt.prototype,"_duration",[lo],(function(){return 0})),AKt=bKt))||AKt),wKt=A.document;function RKt(t,e,i){var n=wKt.createElement("video"),r=wKt.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;U(e),i(new Error(e))},s.send()}function IKt(t,e,i,n){var r=new xKt;r._nativeUrl=t,r._nativeAsset=e,n(null,r)}zS.register({".mp4":RKt,".avi":RKt,".mov":RKt,".mpg":RKt,".mpeg":RKt,".rm":RKt,".rmvb":RKt}),tT.register({".mp4":IKt,".avi":IKt,".mov":IKt,".mpg":IKt,".mpeg":IKt,".rm":IKt,".rmvb":IKt});var DKt,BKt,MKt=Ee({REMOTE:0,LOCAL:1});!function(t){t.NONE="none",t.PLAYING="playing",t.PAUSED="paused",t.STOPPED="stopped",t.COMPLETED="completed",t.META_LOADED="meta-loaded",t.READY_TO_PLAY="ready-to-play",t.ERROR="error",t.CLICKED="clicked"}(DKt||(DKt={})),function(t){t[t.HAVE_NOTHING=0]="HAVE_NOTHING",t[t.HAVE_METADATA=1]="HAVE_METADATA",t[t.HAVE_CURRENT_DATA=2]="HAVE_CURRENT_DATA",t[t.HAVE_FUTURE_DATA=3]="HAVE_FUTURE_DATA",t[t.HAVE_ENOUGH_DATA=4]="HAVE_ENOUGH_DATA"}(BKt||(BKt={}));var PKt=function(){function t(t){var e=this;this._componentEventList=new Map,this._state=DKt.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(wO),this._onInterruptedBegin=function(){e.video&&e._state===DKt.PLAYING&&(e.video.pause(),e._interrupted=!0)},this._onInterruptedEnd=function(){e._interrupted&&e.video&&(e.video.play(),e._interrupted=!1)},S.game.on(S.Game.EVENT_PAUSE,this._onInterruptedBegin),S.game.on(S.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(DKt.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(DKt.READY_TO_PLAY)},e.onPlay=function(){this._playing=!0,this.dispatchEvent(DKt.PLAYING)},e.onPlaying=function(){this.dispatchEvent(DKt.PLAYING)},e.onPause=function(){this._playing=!1,this._ignorePause?this._ignorePause=!1:this.dispatchEvent(DKt.PAUSED)},e.onStoped=function(){this._playing=!1,this._ignorePause=!1,this.dispatchEvent(DKt.STOPPED)},e.onEnded=function(){this._playing=!1,this.dispatchEvent(DKt.COMPLETED)},e.onClick=function(){this.dispatchEvent(DKt.CLICKED)},e.onError=function(t){this.dispatchEvent(DKt.ERROR);var e=t.target;e&&e.error&&H("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){this._uiTrans&&(this._uiTrans.width=t,this._uiTrans.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(),S.game.off(S.Game.EVENT_PAUSE,this._onInterruptedBegin),S.game.off(S.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 ID.root.batcher2D.getFirstRenderCamera(this._node)}}]),t}();S.internal.VideoPlayerImpl=PKt;var OKt,LKt,NKt,FKt,kKt,GKt,VKt,UKt,zKt,HKt,WKt,XKt,jKt,YKt,qKt,KKt,QKt,ZKt,JKt,$Kt,tQt,eQt=A.document,iQt=-Math.pow(2,15),nQt=Wn(),rQt=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();A.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(DKt.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){Sa.browserType!==Ws.UC?this.video&&(this.video.playbackRate=t):z("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&&i.readyState===BKt.HAVE_ENOUGH_DATA)return Sa.os===Ys.IOS&&Sa.isBrowser?(t?i.webkitEnterFullscreen&&i.webkitEnterFullscreen():i.webkitExitFullscreen&&i.webkitExitFullscreen(),void(this._fullScreenOnAwake=i.webkitDisplayingFullscreen)):ya.supportsFullScreen?void(t?(Sa.browserType===Ws.IE&&(i.style.transform=""),i.setAttribute("x5-video-player-fullscreen","true"),ya.requestFullScreen(i,(function(t){var n=Sa.browserType===Ws.IE?t.msFullscreenElement:t.fullscreenElement;e._fullScreenOnAwake=n===i}),(function(){e._fullScreenOnAwake=!1}))):(i.removeAttribute("x5-video-player-fullscreen"),ya.exitFullScreen())):(this._fullScreenOnAwake=t,this._forceUpdate=!0,void this.syncMatrix())},i.syncStayOnBottom=function(t){this._video&&(this._video.style["z-index"]=t?iQt: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&&ze(EB.container,t)&&(EB.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=eQt.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(),EB.container.appendChild(e);var i=eQt.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 BKt.HAVE_METADATA:case BKt.HAVE_ENOUGH_DATA: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&&!ya.fullScreen()){this._dirty&&(this._dirty=!1,this._stayOnBottom?(this._clearColorA=t.clearColor.w,this._clearFlag=t.clearFlag,t.clearColor.w=0,t.clearFlag=Fc.ALL):this._clearFlag&&(t.clearColor.w=this._clearColorA,t.clearFlag=this._clearFlag,this._clearColorA=-1,this._clearFlag=null)),this._component.node.getWorldMatrix(nQt),t.update(!0),t.worldMatrixToScreen(nQt,nQt,EB.canvas.width,EB.canvas.height);var e=0,i=0;if(this._fullScreenOnAwake?(e=Ta.width,i=Ta.height):(e=this._uiTrans.contentSize.width,i=this._uiTrans.contentSize.height),this._forceUpdate||this._m00!==nQt.m00||this._m01!==nQt.m01||this._m04!==nQt.m04||this._m05!==nQt.m05||this._m12!==nQt.m12||this._m13!==nQt.m13||this._w!==e||this._h!==i){this._m00=nQt.m00,this._m01=nQt.m01,this._m04=nQt.m04,this._m05=nQt.m05,this._m12=nQt.m12,this._m13=nQt.m13,this._w=e,this._h=i;var n=ga.devicePixelRatio,r=1/n,s=1/n,a=EB.container,o=nQt.m00*r,h=nQt.m01,u=nQt.m04,l=nQt.m05*s;this._video.style.width=this._w+"px",this._video.style.height=this._h+"px",Sa.browserType!==Ws.MOBILE_QQ?this._video.style.objectFit=this._keepAspectRatio?"none":"fill":z("keepAspectRatio is not supported by the qq mobile browser.");var c=this._w*r,_=this._h*s,f=this._uiTrans.anchorPoint,d=f.x,p=f.y,m=c*nQt.m00*d,g=_*nQt.m05*p,v=a&&a.style.paddingLeft?parseInt(a.style.paddingLeft):0,y=a&&a.style.paddingBottom?parseInt(a.style.paddingBottom):0,S="matrix("+o+","+-h+","+-u+","+l+","+(nQt.m12*r-m+v)+","+-(nQt.m13*s-g+y)+")";this._video.style.transform=S,this._video.style["-webkit-transform"]=S,Sa.browserType!==Ws.IE&&(this._forceUpdate=!1)}}}},e}(PKt),sQt=function(){function t(){}return t.getImpl=function(t){return new rQt(t)},t}();S.internal.VideoPlayerImplManager=sQt;var aQt,oQt=t("h7",(OKt=eo("cc.VideoPlayer"),LKt=io(wO),NKt=Lo(xKt),FKt=Lo(MKt),kKt=Lo(xKt),GKt=Lo([fp]),OKt(VKt=LKt(((tQt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r1?i-1:0),r=1;rt.capabilities.maxTextureSize&&it(9100,o,t.capabilities.maxTextureSize),e.samples===_c.X1){if(e.glTexture=i.createTexture(),e.size>0){var h=t.stateCache.glTexUnits[t.stateCache.texUnit];if(h.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_2D,e.glTexture),h.glTexture=e.glTexture),j_[e.format].isCompressed)for(var u=0;u>1),r=Math.max(1,r>>1)}else e.flags&lc.MUTABLE_STORAGE?i.texImage2D(i.TEXTURE_2D,0,e.glInternalFmt,n,r,0,e.glFormat,e.glType,null):i.texStorage2D(i.TEXTURE_2D,e.mipLevel,e.glInternalFmt,n,r)}}else e.glRenderbuffer=i.createRenderbuffer(),e.size>0&&(t.stateCache.glRenderbuffer!==e.glRenderbuffer&&(i.bindRenderbuffer(i.RENDERBUFFER,e.glRenderbuffer),t.stateCache.glRenderbuffer=e.glRenderbuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,e.samples,e.glInternalFmt,e.width,e.height));break;case hc.TEX2D_ARRAY:e.glTarget=i.TEXTURE_2D_ARRAY;var _=Math.max(n,r);if(_>t.capabilities.maxTextureSize&&it(9100,_,t.capabilities.maxTextureSize),a>t.capabilities.maxArrayTextureLayers&&it(9100,a,t.capabilities.maxArrayTextureLayers),e.glTexture=i.createTexture(),e.size>0){var f=t.stateCache.glTexUnits[t.stateCache.texUnit];if(f.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_2D_ARRAY,e.glTexture),f.glTexture=e.glTexture),j_[e.format].isCompressed)for(var d=0;d>1),r=Math.max(1,r>>1)}else i.texStorage3D(i.TEXTURE_2D_ARRAY,e.mipLevel,e.glInternalFmt,n,r,a)}break;case hc.TEX3D:e.glTarget=i.TEXTURE_3D;var g=Math.max(Math.max(n,r),s);if(g>t.capabilities.max3DTextureSize&&it(9100,g,t.capabilities.max3DTextureSize),e.glTexture=i.createTexture(),e.size>0){var v=t.stateCache.glTexUnits[t.stateCache.texUnit];if(v.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_3D,e.glTexture),v.glTexture=e.glTexture),j_[e.format].isCompressed)for(var y=0;y>1),r=Math.max(1,r>>1)}else i.texStorage3D(i.TEXTURE_3D,e.mipLevel,e.glInternalFmt,n,r,s)}break;case hc.CUBE:e.glTarget=i.TEXTURE_CUBE_MAP;var A=Math.max(n,r);if(A>t.capabilities.maxCubeMapTextureSize&&it(9100,A,t.capabilities.maxTextureSize),e.glTexture=i.createTexture(),e.size>0){var b=t.stateCache.glTexUnits[t.stateCache.texUnit];if(b.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_CUBE_MAP,e.glTexture),b.glTexture=e.glTexture),j_[e.format].isCompressed)for(var E=0;E>1),r=Math.max(1,r>>1)}else i.texStorage2D(i.TEXTURE_CUBE_MAP,e.mipLevel,e.glInternalFmt,n,r)}break;default:it(16317),e.type=hc.TEX2D,e.glTarget=i.TEXTURE_2D}}function YQt(t,e){var i=t.gl;if(e.glTexture){var n=t.stateCache.glTexUnits,r=t.stateCache.texUnit;i.deleteTexture(e.glTexture);for(var s=0;s=0&&T.gpuDescriptors[A];if(b&&b.gpuBuffer){var E=v[S.set],C=E&&E[S.binding],x=b.gpuBuffer.glOffset;C>=0&&(x+=r[C]),o.glBindUBOs[S.glBinding]===b.gpuBuffer.glBuffer&&o.glBindUBOOffsets[S.glBinding]===x||(x?a.bindBufferRange(a.UNIFORM_BUFFER,S.glBinding,b.gpuBuffer.glBuffer,x,b.gpuBuffer.size):a.bindBufferBase(a.UNIFORM_BUFFER,S.glBinding,b.gpuBuffer.glBuffer),o.glUniformBuffer=o.glBindUBOs[S.glBinding]=b.gpuBuffer.glBuffer,o.glBindUBOOffsets[S.glBinding]=x)}}for(var w=h.glSamplerTextures.length,R=0;R=0&&D.gpuDescriptors[B],P=0;P0){L.glTexture!==F.glTexture&&(o.texUnit!==O&&(a.activeTexture(a.TEXTURE0+O),o.texUnit=O),F.glTexture?a.bindTexture(F.glTarget,F.glTexture):a.bindTexture(F.glTarget,t.nullTex2D.gpuTexture.glTexture),L.glTexture=F.glTexture);var V=M.gpuSampler.getGLSampler(t,k,G);o.glSamplerUnits[O]!==V&&(a.bindSampler(O,V),o.glSamplerUnits[O]=V)}M=D.gpuDescriptors[++B]}}}if(i&&h&&(u||qQt.gpuInputAssembler!==i))if(qQt.gpuInputAssembler=i,t.extensions.useVAO){var U=i.glVAOs.get(h.glProgram);if(!U){var z;U=a.createVertexArray(),i.glVAOs.set(h.glProgram,U),a.bindVertexArray(U),a.bindBuffer(a.ARRAY_BUFFER,null),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,null),o.glArrayBuffer=null,o.glElementArrayBuffer=null;for(var H=0;H=0&&(a.enableVertexAttribArray(rt),o.glEnabledAttribLocs[rt]=!0),o.glCurrentAttribLocs[rt]=!0,a.vertexAttribPointer(rt,tt.count,tt.glType,tt.isNormalized,tt.stride,st),a.vertexAttribDivisor(rt,tt.isInstanced?1:0)}}}var at=i.gpuIndexBuffer;at&&o.glElementArrayBuffer!==at.glBuffer&&(a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,at.glBuffer),o.glElementArrayBuffer=at.glBuffer);for(var ot=0;ot0){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 _=e.firstIndex*a.stride;i.drawElements(r,e.indexCount,n.glIndexType,_)}}else e.vertexCount>0&&i.drawArrays(r,e.firstVertex,e.vertexCount)}}var JQt=new Array(MQt.COUNT);function $Qt(t,e){JQt.fill(0);for(var i=0;i0?m.buffStride:_.width,d.height=m.buffTexHeight>0?m.buffTexHeight:_.height;var v=m.texExtent.width+f.x===i.width>>g?m.texExtent.width:_.width,y=m.texExtent.height+f.y===i.height>>g?m.texExtent.height:_.height,S=void 0,T=e[a++];if(d.width===_.width&&d.height===_.height){var A=Z_(i.format,v,y,1)/u.BYTES_PER_ELEMENT;st(Number.isInteger(A),9101),S=new u(T.buffer,T.byteOffset+m.buffOffset,A)}else S=eZt(T,i.format,m.buffOffset,d,_);l?i.glInternalFmt!==AQt.COMPRESSED_RGB_ETC1_WEBGL?r.compressedTexSubImage2D(r.TEXTURE_2D,g,f.x,f.y,v,y,i.glFormat,S):r.compressedTexImage2D(r.TEXTURE_2D,g,i.glInternalFmt,v,y,0,S):r.texSubImage2D(r.TEXTURE_2D,g,f.x,f.y,v,y,i.glFormat,i.glType,S)}break;case r.TEXTURE_2D_ARRAY:for(var b=0;b0?E.buffStride:_.width,d.height=E.buffTexHeight>0?E.buffTexHeight:_.height;var x=E.texExtent.width+f.x===i.width>>C?E.texExtent.width:_.width,w=E.texExtent.height+f.y===i.height>>C?E.texExtent.height:_.height,R=E.texSubres.baseArrayLayer+E.texSubres.layerCount;for(o=E.texSubres.baseArrayLayer;o0?P.buffStride:_.width,d.height=P.buffTexHeight>0?P.buffTexHeight:_.height;var L=P.texExtent.width+f.x===i.width>>O?P.texExtent.width:_.width,N=P.texExtent.height+f.y===i.height>>O?P.texExtent.height:_.height,F=void 0,k=e[a++];if(d.width===_.width&&d.height===_.height){var G=Z_(i.format,L,N,_.depth)/u.BYTES_PER_ELEMENT;st(Number.isInteger(G),9101),F=new u(k.buffer,k.byteOffset+P.buffOffset,G)}else F=eZt(k,i.format,P.buffOffset,d,_);l?i.glInternalFmt!==AQt.COMPRESSED_RGB_ETC1_WEBGL?r.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,O,f.x,f.y,f.z,L,N,_.depth,i.glFormat,F):r.compressedTexImage3D(r.TEXTURE_2D_ARRAY,O,i.glInternalFmt,L,N,_.depth,0,F):r.texSubImage3D(r.TEXTURE_2D_ARRAY,O,f.x,f.y,f.z,L,N,_.depth,i.glFormat,i.glType,F)}break;case r.TEXTURE_CUBE_MAP:for(var V=0;V0?U.buffStride:_.width,d.height=U.buffTexHeight>0?U.buffTexHeight:_.height;var H=U.texExtent.width+f.x===i.width>>z?U.texExtent.width:_.width,W=U.texExtent.height+f.y===i.height>>z?U.texExtent.height:_.height,X=U.texSubres.baseArrayLayer+U.texSubres.layerCount;for(o=U.texSubres.baseArrayLayer;o0,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=Ki(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}(),sZt=function(){function t(){this._srcFramebuffer=void 0,this._dstFramebuffer=void 0;var t=EQt.instance.gl;this._srcFramebuffer=t.createFramebuffer(),this._dstFramebuffer=t.createFramebuffer()}return t.prototype.destroy=function(){var t=EQt.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}(),aZt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r0&&(t.extensions.useVAO&&n.glVAO&&(i.bindVertexArray(null),n.glVAO=null),qQt.gpuInputAssembler=null,t.stateCache.glArrayBuffer!==e.glBuffer&&(i.bindBuffer(i.ARRAY_BUFFER,e.glBuffer),t.stateCache.glArrayBuffer=e.glBuffer),i.bufferData(i.ARRAY_BUFFER,e.size,r),i.bindBuffer(i.ARRAY_BUFFER,null),t.stateCache.glArrayBuffer=null))}else if(e.usage&rc.INDEX){e.glTarget=i.ELEMENT_ARRAY_BUFFER;var a=i.createBuffer();a&&(e.glBuffer=a,e.size>0&&(t.extensions.useVAO&&n.glVAO&&(i.bindVertexArray(null),n.glVAO=null),qQt.gpuInputAssembler=null,t.stateCache.glElementArrayBuffer!==e.glBuffer&&(i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.glBuffer),t.stateCache.glElementArrayBuffer=e.glBuffer),i.bufferData(i.ELEMENT_ARRAY_BUFFER,e.size,r),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,null),t.stateCache.glElementArrayBuffer=null))}else if(e.usage&rc.UNIFORM){e.glTarget=i.UNIFORM_BUFFER;var o=i.createBuffer();o&&e.size>0&&(e.glBuffer=o,t.stateCache.glUniformBuffer!==e.glBuffer&&(i.bindBuffer(i.UNIFORM_BUFFER,e.glBuffer),t.stateCache.glUniformBuffer=e.glBuffer),i.bufferData(i.UNIFORM_BUFFER,e.size,r),i.bindBuffer(i.UNIFORM_BUFFER,null),t.stateCache.glUniformBuffer=null)}else e.usage&rc.INDIRECT||e.usage&rc.TRANSFER_DST||e.usage&rc.TRANSFER_SRC||it(16315),e.glTarget=i.NONE}(EQt.instance,this._gpuBuffer),EQt.instance.memoryStatus.bufferSize+=this._size},i.destroy=function(){this._gpuBuffer&&(this._isBufferView||(function(t,e){var i=t.gl,n=t.stateCache;if(e.glBuffer){switch(e.glTarget){case i.ARRAY_BUFFER:t.extensions.useVAO&&n.glVAO&&(i.bindVertexArray(null),t.stateCache.glVAO=null),qQt.gpuInputAssembler=null,i.bindBuffer(i.ARRAY_BUFFER,null),t.stateCache.glArrayBuffer=null;break;case i.ELEMENT_ARRAY_BUFFER:t.extensions.useVAO&&n.glVAO&&(i.bindVertexArray(null),t.stateCache.glVAO=null),qQt.gpuInputAssembler=null,i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,null),t.stateCache.glElementArrayBuffer=null;break;case i.UNIFORM_BUFFER:i.bindBuffer(i.UNIFORM_BUFFER,null),t.stateCache.glUniformBuffer=null}i.deleteBuffer(e.glBuffer),e.glBuffer=null}}(EQt.instance,this._gpuBuffer),EQt.instance.memoryStatus.bufferSize-=this._size),this._gpuBuffer=null)},i.resize=function(t){if(this._isBufferView)tt(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&&(function(t,e){var i=t.gl,n=t.stateCache,r=e.memUsage&oc.HOST?i.DYNAMIC_DRAW:i.STATIC_DRAW;e.usage&rc.VERTEX?(t.extensions.useVAO&&n.glVAO&&(i.bindVertexArray(null),n.glVAO=null),qQt.gpuInputAssembler=null,n.glArrayBuffer!==e.glBuffer&&i.bindBuffer(i.ARRAY_BUFFER,e.glBuffer),e.buffer?i.bufferData(i.ARRAY_BUFFER,e.buffer,r):i.bufferData(i.ARRAY_BUFFER,e.size,r),i.bindBuffer(i.ARRAY_BUFFER,null),n.glArrayBuffer=null):e.usage&rc.INDEX?(t.extensions.useVAO&&n.glVAO&&(i.bindVertexArray(null),n.glVAO=null),qQt.gpuInputAssembler=null,t.stateCache.glElementArrayBuffer!==e.glBuffer&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.glBuffer),e.buffer?i.bufferData(i.ELEMENT_ARRAY_BUFFER,e.buffer,r):i.bufferData(i.ELEMENT_ARRAY_BUFFER,e.size,r),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,null),t.stateCache.glElementArrayBuffer=null):e.usage&rc.UNIFORM?(t.stateCache.glUniformBuffer!==e.glBuffer&&i.bindBuffer(i.UNIFORM_BUFFER,e.glBuffer),i.bufferData(i.UNIFORM_BUFFER,e.size,r),i.bindBuffer(i.UNIFORM_BUFFER,null),t.stateCache.glUniformBuffer=null):(e.usage&rc.INDIRECT||e.usage&rc.TRANSFER_DST||e.usage&rc.TRANSFER_SRC||it(16315),e.glTarget=i.NONE)}(EQt.instance,this._gpuBuffer),EQt.instance.memoryStatus.bufferSize-=e,EQt.instance.memoryStatus.bufferSize+=t)))}},i.update=function(t,e){var i;this._isBufferView?tt(16380):(i=void 0!==e?e:this._usage&rc.INDIRECT?0:t.byteLength,XQt(EQt.instance,this._gpuBuffer,t,0,i))},n(e,[{key:"gpuBuffer",get:function(){return this._gpuBuffer}}]),e}(af),oZt=function(){function t(t,e){this._frees=void 0,this._freeIdx=0,this._freeCmds=void 0,this._frees=new Array(e),this._freeCmds=new Is(e);for(var 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}},function(t,e){for(var i=0;i>o.baseLevel),e.height=Math.min(e.height,h.height>>o.baseLevel))}var u=e.gpuDepthStencilView;if(u){var l=u.gpuTexture,c=j_[l.format].hasStencil?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;l.glTexture?n.framebufferTexture2D(n.FRAMEBUFFER,c,l.glTarget,l.glTexture,e.gpuDepthStencilView.baseLevel):n.framebufferRenderbuffer(n.FRAMEBUFFER,c,n.RENDERBUFFER,l.glRenderbuffer),e.width=Math.min(e.width,l.width>>u.baseLevel),e.height=Math.min(e.height,l.height>>u.baseLevel)}n.drawBuffers(r);var _=n.checkFramebufferStatus(n.FRAMEBUFFER);if(_!==n.FRAMEBUFFER_COMPLETE)switch(_){case n.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:it(16318);break;case n.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:it(16319);break;case n.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:it(16320);break;case n.FRAMEBUFFER_UNSUPPORTED:it(16321)}t.stateCache.glFramebuffer!==e.glFramebuffer&&n.bindFramebuffer(n.FRAMEBUFFER,t.stateCache.glFramebuffer)}}(EQt.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?void 0:e.gpuTexture.glTexture,this._width=this._gpuFramebuffer.width,this._height=this._gpuFramebuffer.height},i.destroy=function(){var t,e;this._gpuFramebuffer&&(t=EQt.instance,(e=this._gpuFramebuffer).glFramebuffer&&(t.gl.deleteFramebuffer(e.glFramebuffer),t.stateCache.glFramebuffer===e.glFramebuffer&&(t.gl.bindFramebuffer(t.gl.FRAMEBUFFER,null),t.stateCache.glFramebuffer=null),e.glFramebuffer=null),this._gpuFramebuffer=null,this._gpuColorViews.length=0,this._gpuDepthStencilView=null)},n(e,[{key:"gpuFramebuffer",get:function(){return this._gpuFramebuffer}},{key:"needRebuild",get:function(){if(this.gpuFramebuffer){for(var t,e=0;ei&&(i=s.binding)}this._bindingIndices=Array(i+1).fill(-1);for(var a=this._descriptorIndices=Array(i+1).fill(-1),o=0;o0){e.glSamplerTextures=new Array(e.samplerTextures.length);for(var M=0;M1&&(this._info.levelCount=Math.min(this._info.levelCount,e.getLevelCount(t,i)));var n=this._size;this._info.width=t,this._info.height=i,this._size=J_(this._info.format,this.width,this.height,this.depth,this._info.levelCount)*this._info.layerCount,!this._isTextureView&&this._gpuTexture&&(this._gpuTexture.width=t,this._gpuTexture.height=i,this._gpuTexture.size=this._size,this._gpuTexture.isSwapchainTexture||(function(t,e){if(e.size){var i=t.gl,n=e.width,r=e.height,s=e.depth,a=e.arrayLayer;switch(e.type){case hc.TEX2D:e.glTarget=i.TEXTURE_2D;var o=Math.max(n,r);if(o>t.capabilities.maxTextureSize&&it(9100,o,t.capabilities.maxTextureSize),e.samples===_c.X1){var h=t.stateCache.glTexUnits[t.stateCache.texUnit];if(h.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_2D,e.glTexture),h.glTexture=e.glTexture),j_[e.format].isCompressed)for(var u=0;u>1),r=Math.max(1,r>>1)}else YQt(t,e),jQt(t,e)}else e.glRenderbuffer&&(t.stateCache.glRenderbuffer!==e.glRenderbuffer&&(i.bindRenderbuffer(i.RENDERBUFFER,e.glRenderbuffer),t.stateCache.glRenderbuffer=e.glRenderbuffer),i.renderbufferStorageMultisample(i.RENDERBUFFER,e.samples,e.glInternalFmt,e.width,e.height));break;case hc.TEX2D_ARRAY:e.glTarget=i.TEXTURE_2D_ARRAY;var _=Math.max(n,r);if(_>t.capabilities.maxTextureSize&&it(9100,_,t.capabilities.maxTextureSize),a>t.capabilities.maxArrayTextureLayers&&it(9100,a,t.capabilities.maxArrayTextureLayers),e.glTexture=i.createTexture(),e.size>0){var f=t.stateCache.glTexUnits[t.stateCache.texUnit];if(f.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_2D_ARRAY,e.glTexture),f.glTexture=e.glTexture),j_[e.format].isCompressed)for(var d=0;d>1),r=Math.max(1,r>>1)}else i.texStorage3D(i.TEXTURE_2D_ARRAY,e.mipLevel,e.glInternalFmt,n,r,a)}break;case hc.TEX3D:e.glTarget=i.TEXTURE_3D;var g=Math.max(Math.max(n,r),s);if(g>t.capabilities.max3DTextureSize&&it(9100,g,t.capabilities.max3DTextureSize),e.glTexture=i.createTexture(),e.size>0){var v=t.stateCache.glTexUnits[t.stateCache.texUnit];if(v.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_3D,e.glTexture),v.glTexture=e.glTexture),j_[e.format].isCompressed)for(var y=0;y>1),r=Math.max(1,r>>1)}else i.texStorage3D(i.TEXTURE_3D,e.mipLevel,e.glInternalFmt,n,r,s)}break;case hc.CUBE:e.type=hc.CUBE,e.glTarget=i.TEXTURE_CUBE_MAP;var A=Math.max(n,r);A>t.capabilities.maxCubeMapTextureSize&&it(9100,A,t.capabilities.maxTextureSize);var b=t.stateCache.glTexUnits[t.stateCache.texUnit];if(b.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_CUBE_MAP,e.glTexture),b.glTexture=e.glTexture),j_[e.format].isCompressed)for(var E=0;E<6;++E){n=e.width,r=e.height;for(var C=0;C>1),r=Math.max(1,r>>1)}}else YQt(t,e),jQt(t,e);break;default:it(16317),e.type=hc.TEX2D,e.glTarget=i.TEXTURE_2D}}}(EQt.instance,this._gpuTexture),EQt.instance.memoryStatus.textureSize-=n,EQt.instance.memoryStatus.textureSize+=this._size))}},i.initAsSwapchainTexture=function(t){var e=new u_;e.format=t.format,e.usage=j_[t.format].hasDepth?uc.DEPTH_STENCIL_ATTACHMENT:uc.COLOR_ATTACHMENT,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}(xf),bZt="webglcontextlost";function EZt(t,e){for(var i=["","WEBKIT_","MOZ_"],n=0;n1||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}(e,n))r.texImage2D(r.TEXTURE_2D,n[0].texSubres.mipLevel,i.glInternalFmt,n[0].texExtent.width,n[0].texExtent.height,0,i.glFormat,i.glType,e[0]);else for(var h=0;h