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 f(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,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 m(t,e){const i="undefined"==typeof window?global:window;return void 0===i[t]?i[t]=e:i[t]}t({$:ZF,E:function(){return 0},K:XF,N:qF,P:YF,W:function(t){return jF.test(t)},X:function(t){return WF.test(t)},Y:JF,Z:QF,_:d,aM:Nn,aO:an,aQ:en,aS:xn,aV:On,aY:Gn,a_:zn,au:x2,av:R2,ax:function(t,e){for(var i=t,n="";null!==i&&i!==e;)n=i.name+"/"+n,i=i.parent;return n.slice(0,-1)},ay:DQ,b0:fn,b5:Ci,b6:wi,b7:xi,b8:Ri,b9:Ii,bE:function(t){t>0&&(ut=t)},bI:pt,bJ:function(t){for(var e,i=d(t);!(e=i()).done;)mt(e.value)},bK:function(t){return _t||(_t="undefined"==typeof Proxy?{}:new Proxy(t,{get:function(t,e,i){return mt(e),Reflect.get(t,e,i)}})),_t},bL:yl,bM:vl,bP:pi,bQ:mi,b_:function(t){return t[eo]},ba:Bi,bb:Di,bc:Pi,bd:Oi,be:Mi,bf:Li,bg:Ni,bh:Fi,bi:ki,bj:Vi,bk:Gi,bl:Ui,bm:zi,bn:Hi,bo:Wi,bp:ji,bq:Qi,br:Zi,bx:pe,by:ge,bz:Se,c:ttt,c$:z,c1:Yu,c3:U,c4:F,c5:V,c6:k,c7:G,c8:X,c9:J,cA:Sh,cB:Fh,cN:no,cP:function(t,e,i){if(me(t,e),me(t,i),e===i)return t;var n=t[e];if(e>>1;n<=r;s=n+r>>>1){var o=t[s];if(i(o,e)<0)r=s-1;else{if(!(i(o,e)>0))return s;n=s+1}}return~n},d3:function(){},d4:function(){},d5:me,d6:Fl,dC:aL,dd:hM,e5:Mp,e7:g8,fW:_pt,fX:dpt}),m("CC_WECHAT",!1),m("CC_BAIDU",!1),m("CC_XIAOMI",!1),m("CC_ALIPAY",!1),m("CC_BYTEDANCE",!1),m("CC_OPPO",!1),m("CC_VIVO",!1),m("CC_HUAWEI",!1),m("CC_COCOSPLAY",!1),m("CC_QTT",!1),m("CC_LINKSURE",!1);const g=!1;m("CC_EDITOR",!1);m("CC_PREVIEW",!1),m("CC_BUILD",!0),m("CC_TEST",!1),m("CC_DEBUG",!1),m("CC_DEV",!1),m("CC_MINIGAME",!1),m("CC_RUNTIME_BASED",!1),m("CC_SUPPORT_JIT",!0),m("CC_JSB",!1);var y="undefined"==typeof window?global:window,v=t("aJ",{_global:y});v.internal={};var S=t("aI","3.8.2");y.CocosEngine=v.ENGINE_VERSION=S,y.cc=v;var T=void 0!==globalThis.jsb&&void 0!==jsb.window?jsb.window:globalThis;function A(t){var e,i;return e=(t>65535)<<4,e|=i=((t>>>=e)>255)<<3,e|=i=((t>>>=i)>15)<<2,(e|=i=((t>>>=i)>3)<<1)|(t>>>=i)>>1}function b(t){return 16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24}function E(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 C(t){return--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,1+(t|=t>>>16)}y.ccwindow=T;var w=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<0)-(t<0)},abs:function(t){var e=t>>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:b,countTrailingZeros:E,nextPow2:C,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 w[255&t]<<24|w[t>>>8&255]<<16|w[t>>>16&255]<<8|w[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>>>E(t)+1}});t("aK",x);var R=T.document,I="https://github.com/cocos-creator/engine/blob/develop/EngineErrorMap.md",B=null,D=console.log.bind(console),P=D,O=D,M=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;rQ.ERROR){var e=function(t){if(v.game.canvas){if(!B){var e=R.createElement("Div");e.setAttribute("id","logInfoDiv"),e.setAttribute("width","200"),e.setAttribute("height",v.game.canvas.height);var i=e.style;i.zIndex="99999",i.position="absolute",i.top=i.left="0",(B=R.createElement("textarea")).setAttribute("rows","20"),B.setAttribute("cols","30"),B.setAttribute("disabled","true");var n=B.style;n.backgroundColor="transparent",n.borderBottom="1px solid #cccccc",n.borderTopWidth=n.borderLeftWidth=n.borderRightWidth="0px",n.borderTopStyle=n.borderLeftStyle=n.borderRightStyle="none",n.padding="0px",n.margin="0px",e.appendChild(B),v.game.canvas.parentNode.appendChild(e)}B.value=B.value+t+"\r\n",B.scrollTop=B.scrollHeight}};O=function(){e("ERROR : "+N.apply(void 0,arguments))},M=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;n2?i-2:0),r=2;r1?e-1:0),n=1;na.count&&(r("'%s' is deprecated, please use '%s' instead. "+o,t+"."+e,i+"."+n),a.count++)},t("bF",nt=function(t,e,i){null!=t&&i.forEach((function(i){var n=lt++;ct.set(n,{id:n,count:0,logTimes:void 0!==i.logTimes?i.logTimes:ut});var r=null!=i.target?i.target:t,s=null!=i.newName?i.newName:i.name,o=null!=i.targetName?i.targetName:e,a=r===t,h=i.suggest?"("+i.suggest+")":"";if(null!=i.customFunction)t[i.name]=function(){var t;return ot(e,i.name,o,s,k,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 ot(e,i.name,o,s,k,n,h),i.customGetter.call(this)},set:function(t){ot(e,i.name,o,s,k,n,h),i.customSetter.call(this,t)},enumerable:!1}):u?Object.defineProperty(t,i.name,{set:function(t){ot(e,i.name,o,s,k,n,h),i.customSetter.call(this,t)},enumerable:!1}):l&&Object.defineProperty(t,i.name,{get:function(){return ot(e,i.name,o,s,k,n,h),i.customGetter.call(this)},enumerable:!1})}else Object.defineProperty(t,i.name,{get:function(){return ot(e,i.name,o,s,k,n,h),a?this[s]:r[s]},set:function(t){ot(e,i.name,o,s,k,n,h),a?this[s]=t:r[s]=t},enumerable:!1})}))}),at=function(t,e,i,n,r){var s=ct.get(n);s&&s.logTimes>s.count&&(i("'%s' has been removed. "+r,t+"."+e),s.count++)},t("bG",rt=function(t,e,i){null!=t&&i.forEach((function(i){var n=lt++;ct.set(n,{id:n,count:0,logTimes:void 0!==i.logTimes?i.logTimes:ut});var r=i.suggest?"("+i.suggest+")":"";Object.defineProperty(t,i.name,{get:function(){return at(e,i.name,V,n,r)},set:function(){at(e,i.name,V,n,r)},enumerable:!1})}))}),t("bH",st=function(){});var _t,dt,ft={};function pt(t){for(var e in t){var i=t[e];ft[e]=i}}function mt(t){var e=ft[t];if(e){var i=e.newName,n=e.since;e.removed?i?J(16003,t,n,i):J(16002,t,n):i?Y(16001,t,n,i):Y(16e3,t,n)}}var gt=function(){function t(t){this.id=void 0,this.prefix=void 0,this.id=0|998*Math.random(),this.prefix=t?t+".":""}return t.prototype.getNewId=function(){return this.prefix+(++this.id).toString()},t}();dt=gt,gt.global=new dt("global");var yt=new gt("TmpCId."),vt="undefined"==typeof Symbol?"__aliases__":Symbol("[[Aliases]]"),St="__cid__";function Tt(t){return"number"==typeof t||t instanceof Number}function At(t){return"string"==typeof t||t instanceof String}function bt(t){for(var e in t)return!1;return!0}var Et,Ct=(Et={value:void 0,enumerable:!1,writable:!1,configurable:!0},function(t,e,i,n,r){Et.value=i,Et.writable=n,Et.enumerable=r,Object.defineProperty(t,e,Et),Et.value=void 0}),wt=function(){var t={get:void 0,set:void 0,enumerable:!1};return function(e,i,n,r,s,o){void 0===s&&(s=!1),void 0===o&&(o=!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=o,Object.defineProperty(e,i,t),t.get=void 0,t.set=void 0}}(),xt=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}}(),Rt=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 It(t){var e=Object.create(null);return t&&(e["."]=1,e["/"]=1,delete e["."],delete e["/"]),e}function Bt(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?Bt(t.constructor):""}function Dt(t,e,i,n){var r=/([^.]+)$/,s=r.exec(e)[0],o=r.exec(i)[0];function a(){return this[o]}n?wt(t,s,a,(function(t){this[o]=t})):xt(t,s,a)}function Pt(t,e,i,n){for(var r in i)Dt(t,e+"."+r,i[r],n)}var Ot=/(%d)|(%s)/,Mt=/%s/;function Lt(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}(),se=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 oe(t,e){t.splice(e,1)}function ae(t,e){var i=t.length;e<0||e>=i||(t[e]=t[i-1],t.length=i-1)}function he(t,e){var i=t.indexOf(e);return i>=0&&(oe(t,i),!0)}function ue(t,e){var i=t.indexOf(e);i>=0&&(t[i]=t[t.length-1],--t.length)}function le(t,e){var i=t.findIndex(e);if(i>=0){var n=t[i];return oe(t,i),n}}function ce(t,e){return t.indexOf(e)>=0}var _e=Object.freeze({__proto__:null,removeAt:oe,fastRemoveAt:ae,remove:he,fastRemove:ue,removeIf:le,verifyType:function(t,e){if(t&&t.length>0)for(var i,n=d(t);!(i=n()).done;)if(!(i.value instanceof e))return X(1300),!1;return!0},removeArray:function(t,e){for(var i=0,n=e.length;i=0&&t.length,t.length}function ge(t){return"__enums__"in t?t:(Ct(t,"__enums__",null,!0),ge.update(t))}function ye(t){t.hasOwnProperty("__enums__")}function ve(t){ye(t);var e=t.__enums__||[];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})),t.__enums__=e,e}function Se(t){"__enums__"in t||Ct(t,"__enums__",null,!0)}t("bB",fe),pe.isBitMask=function(t){return t&&t.hasOwnProperty("__bitmask__")},pe.getList=function(t){return t.__bitmask__?t.__bitmask__:pe.update(t)},pe.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},v.BitMask=pe,ge.update=function(t){for(var e=-1,i=Object.keys(t),n=0;n2?n-2:0),s=2;si){var n=e;e=i,i=n}return t=0;n--){var r=i[n];r.hasOwnProperty("__attrs__")&&r.__attrs__||Ue(r,(e=i[n+1])&&e.__attrs__)}return Ue(t,(e=i[0])&&e.__attrs__),t.__attrs__}function He(t,e){var i=We(t),n=e+Ge,r={};for(var s in i)s.startsWith(n)&&(r[s.slice(n.length)]=i[s]);return r}function We(t){return t.hasOwnProperty("__attrs__")&&t.__attrs__||ze(t)}function je(t,e,i,n){We(t)[e+Ge+i]=n}var Xe=function(){function t(t,e){this.name=void 0,this.default=void 0,this.name=t,this.default=e}return t.prototype.toString=function(){return this.name},t}(),qe=t("bS",new Xe("Integer",0));v.Integer=qe,v.CCInteger=qe;var Ye=t("bT",new Xe("Float",0));v.Float=Ye,v.CCFloat=Ye;var Ke=t("bU",new Xe("Boolean",!1));v.Boolean=Ke,v.CCBoolean=Ke;var Je=t("bV",new Xe("String",""));function Qe(t,e){return function(i,n){var r='"'+Bt(i)+"."+n+'"',s=He(i,n),o=s.type;if(o===qe||o===Ye?o="Number":o!==Je&&o!==Ke||(o=""+o),o===t){if(s.hasOwnProperty("default")){var a=s.default;if(void 0!==a&&!Array.isArray(a)&&!Ne(a)){var h=typeof a,u=t.toLowerCase();if(h===u)if("object"===u){if(!a||a instanceof s.ctor)return;Y(3605,r,Bt(s.ctor))}else"Number"!==t&&Y(3606,e,r,t);else{if("function"===h)return;t===Je.default&&null==a?Y(3607,r):Y(3611,e,r,h)}delete s.type}}}else Y(3604,r)}}v.String=Je,v.CCString=Je;var Ze=Object.freeze({__proto__:null,DELIMETER:Ge,createAttrsSingle:Ue,createAttrs:ze,attr:He,getClassAttrs:We,setClassAttr:je,PrimitiveType:Xe,CCInteger:qe,CCFloat:Ye,CCBoolean:Ke,CCString:Je,getTypeChecker_ET:Qe,getObjTypeChecker_ET:function(t){return function(e,i){Qe("Object","type")(e,i);var n=We(e)[i+Ge+"default"],r=v.Class.getDefault(n);if(!Array.isArray(r)&&Ht(t,v.ValueType)){var s=Bt(t),o=Lt('No need to specify the "type" of "%s.%s" because %s is a child class of ValueType.',Bt(e),i,s);n?F(o):Y(3612,o,s,Bt(e),i,s)}}}}),$e={default:{},serializable:{},editorOnly:{},formerlySerializedAs:{}};function ti(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 o in n[r]=s,$e){var a=$e[o];t.hasOwnProperty(o)&&(s[o]=t[o],a.canUsedInGet||delete t[o])}}}function ei(t,e,i,n){if(Array.isArray(e)){if(!(e.length>0))return J(5508,i,n);t.type=e=e[0]}"function"==typeof e&&(e===String?t.type=v.String:e===Boolean?t.type=v.Boolean:e===Number&&(t.type=v.Float))}function ii(t,e,i){var n=t||void 0===e?{_short:!0}:{_short:!0,default:e};return i&&(n.type=i),n}function ni(t,e){if(!t||t.constructor!==Object){if(Array.isArray(t)&&t.length>0)return ii(e,[],t);if("function"==typeof t){var i=t;return ii(e,Ht(i,v.ValueType)?new i:null,i)}return t instanceof Xe?ii(e,void 0,t):ii(e,t)}return null}var ri,si=[];function oi(){return si[si.length-1]}function ai(t,e,i){t[e+"$_$type"]="Enum",t[e+"$_$enumList"]=ge.getList(i)}v._RF={push:function(t,e,i,n){void 0===i&&(i=e,e=""),si.push({uuid:e,script:i,module:t,exports:t.exports,beh:null,importMeta:n})},pop:function(){var t=si.pop(),e=t.module,i=e.exports;if(i===t.exports){for(var n in i)return;e.exports=i=t.cls}},peek:oi},function(t){t[t.STANDALONE=1]="STANDALONE",t[t.IMPLICIT_VISIBLE=2]="IMPLICIT_VISIBLE",t[t.IMPLICIT_SERIALIZABLE=4]="IMPLICIT_SERIALIZABLE"}(ri||(ri={}));var hi=Ge,ui="__ctors__",li=t("cU","Enum"),ci=t("cV","BitMask");function _i(t,e,i,n){!function(t,e){!function(t,e){t.indexOf(e)<0&&t.push(e)}(t.__props__,e)}(t,i),yi(t,n,e,i)}function di(t,e,i,n){var r=n.get;n.set,r&&(yi(t,n,e,i),je(t,i,"serializable",!1))}function fi(t){return"function"==typeof t?t():t}function pi(t){var e=t.name,i=t.extends,n=function(t,e,i){var n=v.Component,r=oi();if(r&&Ht(e,n)){if(Ht(r.cls,n))return J(3615),null;t=t||r.script}var s=function(t,e,i){var n=i.ctor;return Ct(n,ui,!0,!0),n.prototype,e&&(n.$super=e),Jt(t,n),n}(t,e,i);if(r)if(Ht(e,n)){var o=r.uuid;o&&Yt(o,s),r.cls=s}else Ht(r.cls,n)||(r.cls=s);return s}(e,i,t);e||(e=v.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=ni(n,!1);if(r&&(n=t[i]=r),n){var s=n.notify;s&&ti(n,i,s,t),"type"in n&&ei(n,n.type,e,i)}}}(i,e),i){var s=i[r];s.get||s.set?di(t,e,r,s):_i(t,e,r,s)}var o=We(t);t.__values__=t.__props__.filter((function(t){return!1!==o[t+"$_$serializable"]}))}(n,e,t.properties,i);var r=t.editor;return r&&Ht(i,v.Component)&&v.Component._registerEditorProps(n,r),n}function mi(t){var e;return null==t||null===(e=t.hasOwnProperty)||void 0===e?void 0:e.call(t,"__values__")}pi._isCCClass=function(t){var e;return null==t||null===(e=t.hasOwnProperty)||void 0===e?void 0:e.call(t,ui)},pi.fastDefine=function(t,e,i){Jt(t,e);for(var n=e.__props__=e.__values__=Object.keys(i),r=We(e),s=0;s=2&&((r||o())[s+"min"]=l[0],r[s+"max"]=l[1],l.length>2&&(r[s+"step"]=l[2])),u("min","number"),u("max","number"),u("step","number")}pi.isArray=function(t){return t=fi(t),Array.isArray(t)},pi.getDefault=fi,pi.escapeForJS=function(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")},pi.IDENTIFIER_RE=/^[A-Za-z_$][0-9A-Za-z_$]*$/,pi.getNewValueTypeCode=function(t){for(var e=Bt(t),i=t.constructor,n="new "+e+"(",r=0;ri){var n=e;e=i,i=n}return ti?i:t}function Ri(t){return t<0?0:t>1?1:t}function Ii(t,e,i){return t+(e-t)*i}function Bi(t){return t*vi}function Di(t){return t*Si}function Pi(){return Ti()}function Oi(t){Ti=t}function Mi(t,e){return Pi()*(e-t)+t}function Li(t,e){return Math.floor(Mi(t,e))}function Ni(t){return(t=(9301*t+49297)%233280)/233280}function Fi(t,e,i){return Ni(t)*(i-e)+e}function ki(t,e,i){return Math.floor(Fi(t,e,i))}function Vi(t){return C(t)}function Gi(t,e){return t-Math.floor(t/e)*e}function Ui(t,e){return t=Gi(t,2*e),e-Math.abs(t-e)}function zi(t,e,i){return(i-t)/(e-t)}function Hi(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 Wi(t,e){return Math.abs(t)>Math.abs(e)?t:e}function ji(t,e){e.forEach((function(e){Object.defineProperty(t,e,{enumerable:!0})}))}var Xi,qi,Yi,Ki=(Xi=new Float32Array(1),qi=new Int32Array(Xi.buffer),function(t){Xi[0]=t;var e=qi[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,qi[0]=i|r,qi[0]}),Ji=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 Qi(t){return Ki(t)}function Zi(t){return Ji(t)}var $i,tn=t("aP",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?(o=1/Math.sqrt(o),t.x=i*o,t.y=n*o,t.z=r*o,t.w=s*o):(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*Pi()*Math.PI,n=2*Pi()-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,o=e.w;return t.x=i.m00*n+i.m04*r+i.m08*s+i.m12*o,t.y=i.m01*n+i.m05*r+i.m09*s+i.m13*o,t.z=i.m02*n+i.m06*r+i.m10*s+i.m14*o,t.w=i.m03*n+i.m07*r+i.m11*s+i.m15*o,t},e.transformAffine=function(t,e,i){var n=e.x,r=e.y,s=e.z,o=e.w;return t.x=i.m00*n+i.m04*r+i.m08*s+i.m12*o,t.y=i.m01*n+i.m05*r+i.m09*s+i.m13*o,t.z=i.m02*n+i.m06*r+i.m10*s+i.m14*o,t.w=e.w,t},e.transformQuat=function(t,e,i){var n=e.x,r=e.y,s=e.z,o=i.x,a=i.y,h=i.z,u=i.w,l=u*n+a*s-h*r,c=u*r+h*n-o*s,_=u*s+o*r-a*n,d=-o*n-a*r-h*s;return t.x=l*u+d*-o+c*-h-_*-a,t.y=c*u+d*-a+_*-o-l*-h,t.z=_*u+d*-h+l*-a-c*-o,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=Ei),!(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=Ei),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=Ei),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=xi(this.x,t.x,e.x),this.y=xi(this.y,t.y,e.y),this.z=xi(this.z,t.z,e.z),this.w=xi(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&&console.warn("should use Vec4.multiply for vector * vector operation"),this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},i.multiply=function(t){return"object"!=typeof t&&console.warn("should use Vec4.scale for vector * scalar operation"),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,o=t.z;return this.x=i*o-n*s,this.y=n*r-e*o,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}(Ae));function en(t,e,i,n){return new tn(t,e,i,n)}Yi=tn,tn.ZERO=Object.freeze(new Yi(0,0,0,0)),tn.ONE=Object.freeze(new Yi(1,1,1,1)),tn.NEG_ONE=Object.freeze(new Yi(-1,-1,-1,-1)),tn.UNIT_X=Object.freeze(new Yi(1,0,0,0)),tn.UNIT_Y=Object.freeze(new Yi(0,1,0,0)),tn.UNIT_Z=Object.freeze(new Yi(0,0,1,0)),tn.UNIT_W=Object.freeze(new Yi(0,0,0,1)),pi.fastDefine("cc.Vec4",tn,{x:0,y:0,z:0,w:0}),v.Vec4=tn,v.v4=en;var nn,rn,sn,on=t("aN",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,o=i.x,a=i.y,h=i.z;return t.x=r*h-s*a,t.y=s*o-n*h,t.z=n*a-r*o,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*Pi()*Math.PI,n=2*Pi()-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,o=i.m03*n+i.m07*r+i.m11*s+i.m15;return o=o?1/o:1,t.x=(i.m00*n+i.m04*r+i.m08*s+i.m12)*o,t.y=(i.m01*n+i.m05*r+i.m09*s+i.m13)*o,t.z=(i.m02*n+i.m06*r+i.m10*s+i.m14)*o,t},e.transformMat4Normal=function(t,e,i){var n=e.x,r=e.y,s=e.z,o=i.m03*n+i.m07*r+i.m11*s;return o=o?1/o:1,t.x=(i.m00*n+i.m04*r+i.m08*s)*o,t.y=(i.m01*n+i.m05*r+i.m09*s)*o,t.z=(i.m02*n+i.m06*r+i.m10*s)*o,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,o=-i.x*e.x-i.y*e.y-i.z*e.z;return t.x=n*i.w+o*-i.x+r*-i.z-s*-i.y,t.y=r*i.w+o*-i.y+s*-i.x-n*-i.z,t.z=s*i.w+o*-i.z+n*-i.y-r*-i.x,t},e.transformRTS=function(t,e,i,n,r){var s=e.x*r.x,o=e.y*r.y,a=e.z*r.z,h=i.w*s+i.y*a-i.z*o,u=i.w*o+i.z*s-i.x*a,l=i.w*a+i.x*o-i.y*s,c=-i.x*s-i.y*o-i.z*a;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,o=e.y-n.y,a=e.z-n.z,h=i.w*s-i.y*a+i.z*o,u=i.w*o-i.z*s+i.x*a,l=i.w*a-i.x*o+i.y*s,c=i.x*s+i.y*o+i.z*a;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,o=e.z-i.z,a=Math.cos(n),h=Math.sin(n),u=r,l=s*a-o*h,c=s*h+o*a;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,o=e.z-i.z,a=Math.cos(n),h=Math.sin(n),u=o*h+r*a,l=s,c=o*a-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,o=e.z-i.z,a=Math.cos(n),h=Math.sin(n),u=r*a-s*h,l=r*h+s*a,c=o;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,o=e.y-i.y,a=e.z-i.z,h=n.x,u=n.y,l=n.z,c=Math.cos(r),_=Math.sin(r),d=s*(h*h*(1-c)+c)+o*(h*u*(1-c)-h*_)+a*(h*l*(1-c)+u*_),f=s*(h*u*(1-c)+l*_)+o*(u*u*(1-c)+c)+a*(u*l*(1-c)-h*_),p=s*(h*l*(1-c)-u*_)+o*(u*l*(1-c)+h*_)+a*(l*l*(1-c)+c);return t.x=d+i.x,t.y=f+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=Ei);var n=t.x,r=t.y,s=t.z,o=e.x,a=e.y,h=e.z;return Math.abs(n-o)<=i*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(r-a)<=i*Math.max(1,Math.abs(r),Math.abs(a))&&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=xi(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,o=i.z-e.z,a=r*r+s*s+o*o;if(0===a||n>=0&&a0&&(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},e}(Ae));function an(t,e,i){return new on(t,e,i)}$i=on,on.UNIT_X=Object.freeze(new $i(1,0,0)),on.UNIT_Y=Object.freeze(new $i(0,1,0)),on.UNIT_Z=Object.freeze(new $i(0,0,1)),on.RIGHT=Object.freeze(new $i(1,0,0)),on.UP=Object.freeze(new $i(0,1,0)),on.FORWARD=Object.freeze(new $i(0,0,-1)),on.ZERO=Object.freeze(new $i(0,0,0)),on.ONE=Object.freeze(new $i(1,1,1)),on.NEG_ONE=Object.freeze(new $i(-1,-1,-1)),on.slerp=(nn=new $i,rn=new $i,sn=new $i,function(t,e,i,n){var r=1e-5,s=$i.len(e),o=$i.len(i);if(s.99999)return $i.lerp(t,e,i,n);if(h<-.99999){var u=$i.multiplyScalar(nn,e,1/s),l=$i.generateOrthogonal(rn,u),c=Math.PI*n;return ln(sn,u,l,c),$i.multiplyScalar(t,sn,a),t}var _=h,d=Math.acos(_)*n,f=$i.multiplyScalar(nn,e,1/s),p=$i.multiplyScalar(rn,i,1/o);return $i.scaleAndAdd(sn,p,f,-_),$i.normalize(sn,sn),$i.multiplyScalar(sn,sn,Math.sin(d)),$i.scaleAndAdd(sn,sn,f,Math.cos(d)),$i.multiplyScalar(t,sn,a),t}),pi.fastDefine("cc.Vec3",on,{x:0,y:0,z:0}),v.Vec3=on;var hn,un,ln=(hn={x:0,y:0,z:0,w:0},function(t,e,i,n){var r=.5*n,s=Math.sin(r);return hn.x=s*i.x,hn.y=s*i.y,hn.z=s*i.z,hn.w=Math.cos(r),on.transformQuat(t,e,hn),t});v.v3=an;var cn,_n=1/255,dn=t("a$",function(t){function e(e,i,n,r){var s;return(s=t.call(this)||this)._val=0,"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 t._val?i._val=t._val:i._val=(t.a<<24>>>0)+(t.b<<16)+(t.g<<8)+t.r,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 tn).x=t.r*_n,e.y=t.g*_n,e.z=t.b*_n,e.w=t.a*_n,e},e.fromVec4=function(t,i){return(i=void 0===i?new e:i).r=Math.floor(t.x/_n),i.g=Math.floor(t.y/_n),i.b=Math.floor(t.z/_n),i.a=Math.floor(t.w/_n),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._val=(t.a<<24>>>0)+(t.b<<16)+(t.g<<8)+t.r,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,o=e.b,a=e.a;return r+=(i.r-r)*n,s+=(i.g-s)*n,o+=(i.b-o)*n,a+=(i.a-a)*n,t._val=Math.floor((a<<24>>>0)+(o<<16)+(s<<8)+r),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 t._val=e,t},e.toUint32=function(t){return t._val},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=Ei),!(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._val=this._val,t},i.equals=function(t){return t&&this._val===t._val},i.lerp=function(t,e){var i=this.r,n=this.g,r=this.b,s=this.a;return i+=(t.r-i)*e,n+=(t.g-n)*e,r+=(t.b-r)*e,s+=(t.a-s)*e,this._val=Math.floor((s<<24>>>0)+(r<<16)+(n<<8)+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*_n).toFixed(2)+")":"rgb"===t?"rgb("+this.r+","+this.g+","+this.b+")":"#"+this.toHEX(t)},i.fromHEX=function(t){t=0===t.indexOf("#")?t.substring(1):t;var e=parseInt(t.substr(0,2),16)||0,i=parseInt(t.substr(2,2),16)||0,n=parseInt(t.substr(4,2),16)||0,r=parseInt(t.substr(6,2),16);return r=Number.isNaN(r)?255:r,this._val=(r<<24>>>0)+(n<<16)+(i<<8)+(0|e),this},i.toHEX=function(t){void 0===t&&(t="#rrggbb");var e="0",i=[(this.r<16?e:"")+this.r.toString(16),(this.g<16?e:"")+this.g.toString(16),(this.b<16?e:"")+this.b.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.a<16?e:"")+this.a.toString(16)),i.join("")},i.toRGBValue=function(){return 16777215&this._val},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 o=Math.floor(t),a=t-o,h=i*(1-e),u=i*(1-e*a),l=i*(1-e*(1-a));switch(o){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 n*=255,r*=255,s*=255,this._val=(this.a<<24>>>0)+(s<<16)+(r<<8)+(0|n),this},i.toHSV=function(){var t=this.r*_n,e=this.g*_n,i=this.b*_n,n={h:0,s:0,v:0},r=Math.max(t,e,i),s=Math.min(t,e,i),o=0;return n.v=r,n.s=r?(r-s)/r:0,n.s?(o=r-s,n.h=t===r?(e-i)/o:e===r?2+(i-t)/o:4+(t-e)/o,n.h/=6,n.h<0&&(n.h+=1)):n.h=0,n},i.set=function(t,e,i,n){return"object"==typeof t?null!=t._val?this._val=t._val:(e=t.g||0,i=t.b||0,n="number"==typeof t.a?t.a:255,t=t.r||0,this._val=(n<<24>>>0)+(i<<16)+(e<<8)+(0|t)):(t=t||0,e=e||0,i=i||0,n="number"==typeof n?n:255,this._val=(n<<24>>>0)+(i<<16)+(e<<8)+(0|t)),this},i.multiply=function(t){var e=(255&this._val)*t.r>>8,i=(65280&this._val)*t.g>>8,n=(16711680&this._val)*t.b>>8,r=((4278190080&this._val)>>>8)*t.a;return this._val=4278190080&r|16711680&n|65280&i|255&e,this},i._set_r_unsafe=function(t){return this._val=(4294967040&this._val|t)>>>0,this},i._set_g_unsafe=function(t){return this._val=(4294902015&this._val|t<<8)>>>0,this},i._set_b_unsafe=function(t){return this._val=(4278255615&this._val|t<<16)>>>0,this},i._set_a_unsafe=function(t){return this._val=(16777215&this._val|t<<24)>>>0,this},n(e,[{key:"r",get:function(){return 255&this._val},set:function(t){t=~~xi(t,0,255),this._val=(4294967040&this._val|t)>>>0}},{key:"g",get:function(){return(65280&this._val)>>8},set:function(t){t=~~xi(t,0,255),this._val=(4294902015&this._val|t<<8)>>>0}},{key:"b",get:function(){return(16711680&this._val)>>16},set:function(t){t=~~xi(t,0,255),this._val=(4278255615&this._val|t<<16)>>>0}},{key:"a",get:function(){return(4278190080&this._val)>>>24},set:function(t){t=~~xi(t,0,255),this._val=(16777215&this._val|t<<24)>>>0}},{key:"x",get:function(){return this.r*_n},set:function(t){this.r=255*t}},{key:"y",get:function(){return this.g*_n},set:function(t){this.g=255*t}},{key:"z",get:function(){return this.b*_n},set:function(t){this.b=255*t}},{key:"w",get:function(){return this.a*_n},set:function(t){this.a=255*t}}]),e}(Ae));function fn(t,e,i,n){return new dn(t,e,i,n)}function pn(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}un=dn,dn.WHITE=Object.freeze(new un(255,255,255,255)),dn.GRAY=Object.freeze(new un(127,127,127,255)),dn.BLACK=Object.freeze(new un(0,0,0,255)),dn.TRANSPARENT=Object.freeze(new un(0,0,0,0)),dn.RED=Object.freeze(new un(255,0,0,255)),dn.GREEN=Object.freeze(new un(0,255,0,255)),dn.BLUE=Object.freeze(new un(0,0,255,255)),dn.CYAN=Object.freeze(new un(0,255,255,255)),dn.MAGENTA=Object.freeze(new un(255,0,255,255)),dn.YELLOW=Object.freeze(new un(255,255,0,255)),pi.fastDefine("cc.Color",dn,{r:0,g:0,b:0,a:255}),v.Color=dn,v.color=fn;var mn=t("aT",function(t){function e(e,i,n,r,s,o,a,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===o&&(o=0),void 0===a&&(a=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=o,l.m06=a,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,o,a,h,u){return t.m00=e,t.m01=i,t.m02=n,t.m03=r,t.m04=s,t.m05=o,t.m06=a,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,o=e.m04,a=e.m05,h=e.m06,u=e.m07,l=e.m08,c=l*o-a*u,_=-l*s+a*h,d=u*s-o*h,f=i*c+n*_+r*d;return 0===f?(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):(f=1/f,t.m00=c*f,t.m01=(-l*n+r*u)*f,t.m02=(a*n-r*o)*f,t.m03=_*f,t.m04=(l*i-r*h)*f,t.m05=(-a*i+r*s)*f,t.m06=d*f,t.m07=(-u*i+n*h)*f,t.m08=(o*i-n*s)*f,t)},e.determinant=function(t){var e=t.m00,i=t.m01,n=t.m02,r=t.m03,s=t.m04,o=t.m05,a=t.m06,h=t.m07,u=t.m08;return e*(u*s-o*h)+i*(-u*r+o*a)+n*(h*r-s*a)},e.multiply=function(t,e,i){var n=e.m00,r=e.m01,s=e.m02,o=e.m03,a=e.m04,h=e.m05,u=e.m06,l=e.m07,c=e.m08,_=i.m00,d=i.m01,f=i.m02,p=i.m03,m=i.m04,g=i.m05,y=i.m06,v=i.m07,S=i.m08;return t.m00=_*n+d*o+f*u,t.m01=_*r+d*a+f*l,t.m02=_*s+d*h+f*c,t.m03=p*n+m*o+g*u,t.m04=p*r+m*a+g*l,t.m05=p*s+m*h+g*c,t.m06=y*n+v*o+S*u,t.m07=y*r+v*a+S*l,t.m08=y*s+v*h+S*c,t},e.multiplyMat4=function(t,e,i){var n=e.m00,r=e.m01,s=e.m02,o=e.m03,a=e.m04,h=e.m05,u=e.m06,l=e.m07,c=e.m08,_=i.m00,d=i.m01,f=i.m02,p=i.m04,m=i.m05,g=i.m06,y=i.m08,v=i.m09,S=i.m10;return t.m00=_*n+d*o+f*u,t.m01=_*r+d*a+f*l,t.m02=_*s+d*h+f*c,t.m03=p*n+m*o+g*u,t.m04=p*r+m*a+g*l,t.m05=p*s+m*h+g*c,t.m06=y*n+v*o+S*u,t.m07=y*r+v*a+S*l,t.m08=y*s+v*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,o=e.m03,a=e.m04,h=e.m05,u=e.m06,l=e.m07,c=e.m08,_=i.x,d=i.y;return t.m00=n,t.m01=r,t.m02=s,t.m03=o,t.m04=a,t.m05=h,t.m06=_*n+d*o+u,t.m07=_*r+d*a+l,t.m08=_*s+d*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,o=e.m03,a=e.m04,h=e.m05,u=e.m06,l=e.m07,c=e.m08,_=Math.sin(i),d=Math.cos(i);return t.m00=d*n+_*o,t.m01=d*r+_*a,t.m02=d*s+_*h,t.m03=d*o-_*n,t.m04=d*a-_*r,t.m05=d*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 on.lengthSqr(i)-.999?(e.x=Math.asin(-a),e.y=Math.atan2(o,h),e.z=Math.atan2(n,s),!0):(e.x=Ai,e.y=Math.atan2(r,i),e.z=0,!1):(e.x=-Ai,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,o,a,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===o&&(o=0),void 0===a&&(a=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=o,this.m07=a,this.m08=h),this},i.equals=function(t,e){return void 0===e&&(e=Ei),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,o=this.m06,a=this.m07,h=this.m08,u=h*r-s*a,l=-h*n+s*o,c=a*n-r*o,_=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*a)*_,this.m02=(s*e-i*r)*_,this.m03=l*_,this.m04=(h*t-i*o)*_,this.m05=(-s*t+i*n)*_,this.m06=c*_,this.m07=(-a*t+e*o)*_,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,o=this.m06,a=this.m07,h=this.m08;return t*(h*r-s*a)+e*(-h*n+s*o)+i*(a*n-r*o)},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,o=this.m05,a=this.m06,h=this.m07,u=this.m08,l=t.m00,c=t.m01,_=t.m02,d=t.m03,f=t.m04,p=t.m05,m=t.m06,g=t.m07,y=t.m08;return this.m00=l*e+c*r+_*a,this.m01=l*i+c*s+_*h,this.m02=l*n+c*o+_*u,this.m03=d*e+f*r+p*a,this.m04=d*i+f*s+p*h,this.m05=d*n+f*o+p*u,this.m06=m*e+g*r+y*a,this.m07=m*i+g*s+y*h,this.m08=m*n+g*o+y*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.m00,this.m01=e*this.m01,this.m02=e*this.m02,this.m03=i*this.m03,this.m04=i*this.m04,this.m05=i*this.m05,this.m06=this.m06,this.m07=this.m07,this.m08=this.m08,this},i.rotate=function(t){var e=this.m00,i=this.m01,n=this.m02,r=this.m03,s=this.m04,o=this.m05,a=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*o,this.m03=c*r-l*e,this.m04=c*s-l*i,this.m05=c*o-l*n,this.m06=a,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,o=i+i,a=n+n,h=e*s,u=i*s,l=i*o,c=n*s,_=n*o,d=n*a,f=r*s,p=r*o,m=r*a;return this.m00=1-l-d,this.m03=u-m,this.m06=c+p,this.m01=u+m,this.m04=1-h-d,this.m07=_-f,this.m02=c-p,this.m05=_+f,this.m08=1-h-l,this},e}(Ae));cn=mn,mn.IDENTITY=Object.freeze(new cn);var gn,yn=new on,vn=new on;pi.fastDefine("cc.Mat3",mn,{m00:1,m01:0,m02:0,m03:0,m04:1,m05:0,m06:0,m07:0,m08:1}),v.Mat3=mn;var Sn=t("aR",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=on.dot(i,n);return r<-.999999?(on.cross(En,on.UNIT_X,i),En.length()<1e-6&&on.cross(En,on.UNIT_Y,i),on.normalize(En,En),e.fromAxisAngle(t,En,Math.PI),t):r>.999999?(t.x=0,t.y=0,t.z=0,t.w=1,t):(on.cross(En,i,n),t.x=En.x,t.y=En.y,t.z=En.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,o=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=o,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,o=e.y,a=e.z,h=e.w;return t.x=s*r+h*n,t.y=o*r+a*n,t.z=a*r-o*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,o=e.y,a=e.z,h=e.w;return t.x=s*r-a*n,t.y=o*r+h*n,t.z=a*r+s*n,t.w=h*r-o*n,t},e.rotateZ=function(t,e,i){i*=.5;var n=Math.sin(i),r=Math.cos(i),s=e.x,o=e.y,a=e.z,h=e.w;return t.x=s*r+o*n,t.y=o*r-s*n,t.z=a*r+h*n,t.w=h*r-a*n,t},e.rotateAround=function(t,i,n,r){return e.invert(An,i),on.transformQuat(En,n,An),e.fromAxisAngle(An,En,r),e.multiply(t,i,An),t},e.rotateAroundLocal=function(t,i,n,r){return e.fromAxisAngle(An,n,r),e.multiply(t,i,An),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,o=i.x,a=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,o=-o,a=-a,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*o,t.y=r*e.y+s*a,t.z=r*e.z+s*h,t.w=r*e.w+s*u,t},e.sqlerp=function(t,i,n,r,s,o){return e.slerp(An,i,s,o),e.slerp(bn,n,r,o),e.slerp(t,An,bn,2*o*(1-o)),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 mn.set(Cn,i.x,i.y,i.z,n.x,n.y,n.z,r.x,r.y,r.z),e.normalize(t,e.fromMat3(t,Cn))},e.fromViewUp=function(t,i,n){return mn.fromViewUp(Cn,i,n),e.normalize(t,e.fromMat3(t,Cn))},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,o=e.m04,a=e.m05,h=e.m06,u=e.m07,l=e.m08,c=i-o-l,_=o-i-l,d=l-i-o,f=0,p=i+o+l;c>p&&(p=c,f=1),_>p&&(p=_,f=2),d>p&&(p=d,f=3);var m=.5*Math.sqrt(p+1),g=.25/m;switch(f){case 0:t.w=m,t.x=(a-u)*g,t.y=(h-r)*g,t.z=(n-s)*g;break;case 1:t.w=(a-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=(a+u)*g;break;case 3:t.w=(n-s)*g,t.x=(h+r)*g,t.y=(a+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*=wn,i*=wn,n*=wn;var r=Math.sin(e),s=Math.cos(e),o=Math.sin(i),a=Math.cos(i),h=Math.sin(n),u=Math.cos(n);return t.x=r*a*u+s*o*h,t.y=s*o*u+r*a*h,t.z=s*a*h-r*o*u,t.w=s*a*u-r*o*h,t},e.fromAngleZ=function(t,e){return e*=wn,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,o=e.w,a=0,h=0,u=0,l=n*r+s*o;if(l>.499999)a=0,h=Di(2*Math.atan2(n,o)),u=90;else if(l<-.499999)a=0,h=-Di(2*Math.atan2(n,o)),u=-90;else{var c=n*n,_=r*r,d=s*s;a=Di(Math.atan2(2*n*o-2*r*s,1-2*c-2*d)),h=Di(Math.atan2(2*r*o-2*n*s,1-2*_-2*d)),u=Di(Math.asin(2*l)),i&&(a=-180*Math.sign(a+1e-6)+a,h=-180*Math.sign(h+1e-6)+h,u=180*Math.sign(u+1e-6)-u)}return t.x=a,t.y=h,t.z=u,t},e.toEulerInYXZOrder=function(t,e){mn.fromQuat(Cn,e),mn.toEuler(Cn,t),t.x=Di(t.x),t.y=Di(t.y),t.z=Di(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=Ei),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 o=Math.min(r/Di(s),1);return e.slerp(t,i,n,o)};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=Ei),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}(Ae));gn=Sn,Sn.IDENTITY=Object.freeze(new gn);var Tn,An=new Sn,bn=new Sn,En=new on,Cn=new mn,wn=.5*Math.PI/180;function xn(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 Sn(t,e,i,n)}pi.fastDefine("cc.Quat",Sn,{x:0,y:0,z:0,w:1}),v.Quat=Sn,v.quat=xn;var Rn=t("b1",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])])),In=t("aU",function(t){function e(e,i,n,r,s,o,a,h,u,l,c,_,d,f,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===o&&(o=1),void 0===a&&(a=0),void 0===h&&(h=0),void 0===u&&(u=0),void 0===l&&(l=0),void 0===c&&(c=1),void 0===_&&(_=0),void 0===d&&(d=0),void 0===f&&(f=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=o,g.m06=a,g.m07=h,g.m08=u,g.m09=l,g.m10=c,g.m11=_,g.m12=d,g.m13=f,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,o,a,h,u,l,c,_,d,f,p,m){return t.m00=e,t.m01=i,t.m02=n,t.m03=r,t.m04=s,t.m05=o,t.m06=a,t.m07=h,t.m08=u,t.m09=l,t.m10=c,t.m11=_,t.m12=d,t.m13=f,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,o=e.m07,a=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=o,t.m14=a}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,o=e.m04,a=e.m05,h=e.m06,u=e.m07,l=e.m08,c=e.m09,_=e.m10,d=e.m11,f=e.m12,p=e.m13,m=e.m14,g=e.m15,y=i*a-n*o,v=i*h-r*o,S=i*u-s*o,T=n*h-r*a,A=n*u-s*a,b=r*u-s*h,E=l*p-c*f,C=l*m-_*f,w=l*g-d*f,x=c*m-_*p,R=c*g-d*p,I=_*g-d*m,B=y*I-v*R+S*x+T*w-A*C+b*E;return 0===B?(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):(B=1/B,t.m00=(a*I-h*R+u*x)*B,t.m01=(r*R-n*I-s*x)*B,t.m02=(p*b-m*A+g*T)*B,t.m03=(_*A-c*b-d*T)*B,t.m04=(h*w-o*I-u*C)*B,t.m05=(i*I-r*w+s*C)*B,t.m06=(m*S-f*b-g*v)*B,t.m07=(l*b-_*S+d*v)*B,t.m08=(o*R-a*w+u*E)*B,t.m09=(n*w-i*R-s*E)*B,t.m10=(f*A-p*S+g*y)*B,t.m11=(c*S-l*A-d*y)*B,t.m12=(a*C-o*x-h*E)*B,t.m13=(i*x-n*C+r*E)*B,t.m14=(p*v-f*T-m*y)*B,t.m15=(l*T-c*v+_*y)*B,t)},e.determinant=function(t){var e=t.m00,i=t.m01,n=t.m02,r=t.m03,s=t.m04,o=t.m05,a=t.m06,h=t.m07,u=t.m08,l=t.m09,c=t.m10,_=t.m11,d=t.m12,f=t.m13,p=t.m14,m=t.m15;return(e*o-i*s)*(c*m-_*p)-(e*a-n*s)*(l*m-_*f)+(e*h-r*s)*(l*p-c*f)+(i*a-n*o)*(u*m-_*d)-(i*h-r*o)*(u*p-c*d)+(n*h-r*a)*(u*f-l*d)},e.multiply=function(t,e,i){var n=e.m00,r=e.m01,s=e.m02,o=e.m03,a=e.m04,h=e.m05,u=e.m06,l=e.m07,c=e.m08,_=e.m09,d=e.m10,f=e.m11,p=e.m12,m=e.m13,g=e.m14,y=e.m15,v=i.m00,S=i.m01,T=i.m02,A=i.m03;return t.m00=v*n+S*a+T*c+A*p,t.m01=v*r+S*h+T*_+A*m,t.m02=v*s+S*u+T*d+A*g,t.m03=v*o+S*l+T*f+A*y,v=i.m04,S=i.m05,T=i.m06,A=i.m07,t.m04=v*n+S*a+T*c+A*p,t.m05=v*r+S*h+T*_+A*m,t.m06=v*s+S*u+T*d+A*g,t.m07=v*o+S*l+T*f+A*y,v=i.m08,S=i.m09,T=i.m10,A=i.m11,t.m08=v*n+S*a+T*c+A*p,t.m09=v*r+S*h+T*_+A*m,t.m10=v*s+S*u+T*d+A*g,t.m11=v*o+S*l+T*f+A*y,v=i.m12,S=i.m13,T=i.m14,A=i.m15,t.m12=v*n+S*a+T*c+A*p,t.m13=v*r+S*h+T*_+A*m,t.m14=v*s+S*u+T*d+A*g,t.m15=v*o+S*l+T*f+A*y,t},e.transform=function(t,e,i){var n=i.x,r=i.y,s=i.z;if(e===t)t.m12=e.m00*n+e.m04*r+e.m08*s+e.m12,t.m13=e.m01*n+e.m05*r+e.m09*s+e.m13,t.m14=e.m02*n+e.m06*r+e.m10*s+e.m14,t.m15=e.m03*n+e.m07*r+e.m11*s+e.m15;else{var o=e.m00,a=e.m01,h=e.m02,u=e.m03,l=e.m04,c=e.m05,_=e.m06,d=e.m07,f=e.m08,p=e.m09,m=e.m10,g=e.m11;t.m00=o,t.m01=a,t.m02=h,t.m03=u,t.m04=l,t.m05=c,t.m06=_,t.m07=d,t.m08=f,t.m09=p,t.m10=m,t.m11=g,t.m12=o*n+l*r+f*s+e.m12,t.m13=a*n+c*r+p*s+e.m13,t.m14=h*n+_*r+m*s+e.m14,t.m15=u*n+d*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,o=n.z,a=Math.sqrt(r*r+s*s+o*o);if(Math.abs(a)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,e,i,n){var r=on.set(Dn,t.m00,t.m01,t.m02).length(),s=on.set(Dn,t.m04,t.m05,t.m06).length(),o=on.set(Dn,t.m08,t.m09,t.m10).length();Pn.m00=t.m00/r,Pn.m01=t.m01/r,Pn.m02=t.m02/r,Pn.m03=t.m04/s,Pn.m04=t.m05/s,Pn.m05=t.m06/s,Pn.m06=t.m08/o,Pn.m07=t.m09/o,Pn.m08=t.m10/o;var a=mn.determinant(Pn);n&&(on.set(n,r,s,o),a<0&&(n.x*=-1)),i&&on.set(i,t.m12,t.m13,t.m14),e&&(a<0&&(Pn.m00*=-1,Pn.m01*=-1,Pn.m02*=-1),Sn.fromMat3(e,Pn))},e.toSRT=function(t,e,i,n){var r=on.set(Dn,t.m00,t.m01,t.m02).length(),s=on.set(Dn,t.m04,t.m05,t.m06).length(),o=on.set(Dn,t.m08,t.m09,t.m10).length();n&&(n.x=r,n.y=s,n.z=o),i&&on.set(i,t.m12,t.m13,t.m14),e&&(Pn.m00=t.m00/r,Pn.m01=t.m01/r,Pn.m02=t.m02/r,Pn.m03=t.m04/s,Pn.m04=t.m05/s,Pn.m05=t.m06/s,Pn.m06=t.m08/o,Pn.m07=t.m09/o,Pn.m08=t.m10/o,mn.determinant(Pn)<0&&(n&&(n.x*=-1),Pn.m00*=-1,Pn.m01*=-1,Pn.m02*=-1),Sn.fromMat3(e,Pn))},e.toEuler=function(t,e){return mn.set(Pn,t.m00,t.m01,t.m02,t.m04,t.m05,t.m06,t.m08,t.m09,t.m10),mn.toEuler(Pn,e)},e.fromRTS=function(t,e,i,n){var r=e.x,s=e.y,o=e.z,a=e.w,h=r+r,u=s+s,l=o+o,c=r*h,_=r*u,d=r*l,f=s*u,p=s*l,m=o*l,g=a*h,y=a*u,v=a*l,S=n.x,T=n.y,A=n.z;return t.m00=(1-(f+m))*S,t.m01=(_+v)*S,t.m02=(d-y)*S,t.m03=0,t.m04=(_-v)*T,t.m05=(1-(c+m))*T,t.m06=(p+g)*T,t.m07=0,t.m08=(d+y)*A,t.m09=(p-g)*A,t.m10=(1-(c+f))*A,t.m11=0,t.m12=i.x,t.m13=i.y,t.m14=i.z,t.m15=1,t},e.fromSRT=function(t,e,i,n){var r=e.x,s=e.y,o=e.z,a=e.w,h=r+r,u=s+s,l=o+o,c=r*h,_=r*u,d=r*l,f=s*u,p=s*l,m=o*l,g=a*h,y=a*u,v=a*l,S=n.x,T=n.y,A=n.z;return t.m00=(1-(f+m))*S,t.m01=(_+v)*S,t.m02=(d-y)*S,t.m03=0,t.m04=(_-v)*T,t.m05=(1-(c+m))*T,t.m06=(p+g)*T,t.m07=0,t.m08=(d+y)*A,t.m09=(p-g)*A,t.m10=(1-(c+f))*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,o=e.y,a=e.z,h=e.w,u=s+s,l=o+o,c=a+a,_=s*u,d=s*l,f=s*c,p=o*l,m=o*c,g=a*c,y=h*u,v=h*l,S=h*c,T=n.x,A=n.y,b=n.z,E=r.x,C=r.y,w=r.z;return t.m00=(1-(p+g))*T,t.m01=(d+S)*T,t.m02=(f-v)*T,t.m03=0,t.m04=(d-S)*A,t.m05=(1-(_+g))*A,t.m06=(m+y)*A,t.m07=0,t.m08=(f+v)*b,t.m09=(m-y)*b,t.m10=(1-(_+p))*b,t.m11=0,t.m12=i.x+E-(t.m00*E+t.m04*C+t.m08*w),t.m13=i.y+C-(t.m01*E+t.m05*C+t.m09*w),t.m14=i.z+w-(t.m02*E+t.m06*C+t.m10*w),t.m15=1,t},e.fromSRTOrigin=function(t,e,i,n,r){var s=e.x,o=e.y,a=e.z,h=e.w,u=s+s,l=o+o,c=a+a,_=s*u,d=s*l,f=s*c,p=o*l,m=o*c,g=a*c,y=h*u,v=h*l,S=h*c,T=n.x,A=n.y,b=n.z,E=r.x,C=r.y,w=r.z;return t.m00=(1-(p+g))*T,t.m01=(d+S)*T,t.m02=(f-v)*T,t.m03=0,t.m04=(d-S)*A,t.m05=(1-(_+g))*A,t.m06=(m+y)*A,t.m07=0,t.m08=(f+v)*b,t.m09=(m-y)*b,t.m10=(1-(_+p))*b,t.m11=0,t.m12=i.x+E-(t.m00*E+t.m04*C+t.m08*w),t.m13=i.y+C-(t.m01*E+t.m05*C+t.m09*w),t.m14=i.z+w-(t.m02*E+t.m06*C+t.m10*w),t.m15=1,t},e.fromQuat=function(t,e){var i=e.x,n=e.y,r=e.z,s=e.w,o=i+i,a=n+n,h=r+r,u=i*o,l=n*o,c=n*a,_=r*o,d=r*a,f=r*h,p=s*o,m=s*a,g=s*h;return t.m00=1-c-f,t.m01=l+g,t.m02=_-m,t.m03=0,t.m04=l-g,t.m05=1-u-f,t.m06=d+p,t.m07=0,t.m08=_+m,t.m09=d-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,o){var a=1/(i-e),h=1/(r-n),u=1/(s-o);return t.m00=2*s*a,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)*a,t.m09=(r+n)*h,t.m10=(o+s)*u,t.m11=-1,t.m12=0,t.m13=0,t.m14=o*s*2*u,t.m15=0,t},e.perspective=function(t,e,i,n,r,s,o,a,h){void 0===s&&(s=!0),void 0===o&&(o=-1),void 0===a&&(a=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)*a,d=Rn[h];return t.m00=c*d[0],t.m01=c*d[1],t.m02=0,t.m03=0,t.m04=_*d[2],t.m05=_*d[3],t.m06=0,t.m07=0,t.m08=0,t.m09=0,t.m10=(r-o*n)*l,t.m11=-1,t.m12=0,t.m13=0,t.m14=r*n*l*(1-o),t.m15=0,t},e.ortho=function(t,e,i,n,r,s,o,a,h,u){void 0===a&&(a=-1),void 0===h&&(h=1),void 0===u&&(u=0);var l=1/(e-i),c=1/(n-r)*h,_=1/(s-o),d=-2*l,f=-2*c,p=(e+i)*l,m=(r+n)*c,g=Rn[u];return t.m00=d*g[0],t.m01=d*g[1],t.m02=0,t.m03=0,t.m04=f*g[2],t.m05=f*g[3],t.m06=0,t.m07=0,t.m08=0,t.m09=0,t.m10=_*(1-a),t.m11=0,t.m12=p*g[0]+m*g[2],t.m13=p*g[1]+m*g[3],t.m14=(s-a*o)*_,t.m15=1,t},e.lookAt=function(t,e,i,n){var r=e.x,s=e.y,o=e.z,a=n.x,h=n.y,u=n.z,l=r-i.x,c=s-i.y,_=o-i.z,d=1/Math.sqrt(l*l+c*c+_*_),f=h*(_*=d)-u*(c*=d),p=u*(l*=d)-a*_,m=a*c-h*l,g=c*(m*=d=1/Math.sqrt(f*f+p*p+m*m))-_*(p*=d),y=_*(f*=d)-l*m,v=l*p-c*f;return t.m00=f,t.m01=g,t.m02=l,t.m03=0,t.m04=p,t.m05=y,t.m06=c,t.m07=0,t.m08=m,t.m09=v,t.m10=_,t.m11=0,t.m12=-(f*r+p*s+m*o),t.m13=-(g*r+y*s+v*o),t.m14=-(l*r+c*s+_*o),t.m15=1,t},e.inverseTranspose=function(t,e){var i=e.m00,n=e.m01,r=e.m02,s=e.m03,o=e.m04,a=e.m05,h=e.m06,u=e.m07,l=e.m08,c=e.m09,_=e.m10,d=e.m11,f=e.m12,p=e.m13,m=e.m14,g=e.m15,y=i*a-n*o,v=i*h-r*o,S=i*u-s*o,T=n*h-r*a,A=n*u-s*a,b=r*u-s*h,E=l*p-c*f,C=l*m-_*f,w=l*g-d*f,x=c*m-_*p,R=c*g-d*p,I=_*g-d*m,B=y*I-v*R+S*x+T*w-A*C+b*E;return B?(B=1/B,t.m00=(a*I-h*R+u*x)*B,t.m01=(h*w-o*I-u*C)*B,t.m02=(o*R-a*w+u*E)*B,t.m03=0,t.m04=(r*R-n*I-s*x)*B,t.m05=(i*I-r*w+s*C)*B,t.m06=(n*w-i*R-s*E)*B,t.m07=0,t.m08=(p*b-m*A+g*T)*B,t.m09=(m*S-f*b-g*v)*B,t.m10=(f*A-p*S+g*y)*B,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=Ei),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,o,a,h,u,l,c,_,d,f,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===o&&(o=0),void 0===a&&(a=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===d&&(d=0),void 0===f&&(f=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=o,this.m07=a,this.m08=h,this.m09=u,this.m10=l,this.m11=c,this.m12=_,this.m13=d,this.m14=f,this.m15=p,this.m00=t),this},i.equals=function(t,e){return void 0===e&&(e=Ei),!(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,o=this.m06,a=this.m07,h=this.m08,u=this.m09,l=this.m10,c=this.m11,_=this.m12,d=this.m13,f=this.m14,p=this.m15,m=t*s-e*r,g=t*o-i*r,y=t*a-n*r,v=e*o-i*s,S=e*a-n*s,T=i*a-n*o,A=h*d-u*_,b=h*f-l*_,E=h*p-c*_,C=u*f-l*d,w=u*p-c*d,x=l*p-c*f,R=m*x-g*w+y*C+v*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*x-o*w+a*C)*R,this.m01=(i*w-e*x-n*C)*R,this.m02=(d*T-f*S+p*v)*R,this.m03=(l*S-u*T-c*v)*R,this.m04=(o*E-r*x-a*b)*R,this.m05=(t*x-i*E+n*b)*R,this.m06=(f*y-_*T-p*g)*R,this.m07=(h*T-l*y+c*g)*R,this.m08=(r*w-s*E+a*A)*R,this.m09=(e*E-t*w-n*A)*R,this.m10=(_*S-d*y+p*m)*R,this.m11=(u*y-h*S-c*m)*R,this.m12=(s*b-r*C-o*A)*R,this.m13=(t*C-e*b+i*A)*R,this.m14=(d*g-_*v-f*m)*R,this.m15=(h*v-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,o=this.m06,a=this.m07,h=this.m08,u=this.m09,l=this.m10,c=this.m11,_=this.m12,d=this.m13,f=this.m14,p=this.m15;return(t*s-e*r)*(l*p-c*f)-(t*o-i*r)*(u*p-c*d)+(t*a-n*r)*(u*f-l*d)+(e*o-i*s)*(h*p-c*_)-(e*a-n*s)*(h*f-l*_)+(i*a-n*o)*(h*d-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,o=this.m05,a=this.m06,h=this.m07,u=this.m08,l=this.m09,c=this.m10,_=this.m11,d=this.m12,f=this.m13,p=this.m14,m=this.m15,g=t.m00,y=t.m01,v=t.m02,S=t.m03;return this.m00=g*e+y*s+v*u+S*d,this.m01=g*i+y*o+v*l+S*f,this.m02=g*n+y*a+v*c+S*p,this.m03=g*r+y*h+v*_+S*m,g=t.m04,y=t.m05,v=t.m06,S=t.m07,this.m04=g*e+y*s+v*u+S*d,this.m05=g*i+y*o+v*l+S*f,this.m06=g*n+y*a+v*c+S*p,this.m07=g*r+y*h+v*_+S*m,g=t.m08,y=t.m09,v=t.m10,S=t.m11,this.m08=g*e+y*s+v*u+S*d,this.m09=g*i+y*o+v*l+S*f,this.m10=g*n+y*a+v*c+S*p,this.m11=g*r+y*h+v*_+S*m,g=t.m12,y=t.m13,v=t.m14,S=t.m15,this.m12=g*e+y*s+v*u+S*d,this.m13=g*i+y*o+v*l+S*f,this.m14=g*n+y*a+v*c+S*p,this.m15=g*r+y*h+v*_+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,o=this.m02,a=this.m03,h=this.m04,u=this.m05,l=this.m06,c=this.m07,_=this.m08,d=this.m09,f=this.m10,p=this.m11;return this.m12=r*e+h*i+_*n+this.m12,this.m13=s*e+u*i+d*n+this.m13,this.m14=o*e+l*i+f*n+this.m14,this.m15=a*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 on?(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*Pi()*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=Ei),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=xi(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=Ei),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=Ei),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=xi(this.x,t.x,e.x),this.y=xi(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&&console.warn("should use Vec2.multiply for vector * vector operation"),this.x*=t,this.y*=t,this},i.multiply=function(t){return"object"!=typeof t&&console.warn("should use Vec2.scale for vector * scalar operation"),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=xi(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},e}(Ae));function Nn(t,e){return new Ln(t,e)}Bn=Ln,Ln.ZERO=Object.freeze(new Bn(0,0)),Ln.ONE=Object.freeze(new Bn(1,1)),Ln.NEG_ONE=Object.freeze(new Bn(-1,-1)),Ln.UNIT_X=Object.freeze(new Bn(1,0)),Ln.UNIT_Y=Object.freeze(new Bn(0,1)),pi.fastDefine("cc.Vec2",Ln,{x:0,y:0}),v.Vec2=Ln,v.v2=Nn,nt(Ln,"Vec2",[{name:"sub",newName:"subtract",target:Ln,targetName:"Vec2"},{name:"mul",newName:"multiply",target:Ln,targetName:"Vec2"},{name:"div",newName:"divide",target:Ln,targetName:"Vec2"},{name:"dist",newName:"distance",target:Ln,targetName:"Vec2"},{name:"sqrDist",newName:"squaredDistance",target:Ln,targetName:"Vec2"},{name:"mag",newName:"len",target:Ln,targetName:"Vec2"},{name:"sqrMag",newName:"lengthSqr",target:Ln,targetName:"Vec2"},{name:"scale",newName:"multiplyScalar",target:Ln,targetName:"Vec2"},{name:"exactEquals",newName:"strictEquals",target:Ln,targetName:"Vec2"}]),nt(Ln.prototype,"Vec2",[{name:"mag",newName:"length",target:Ln.prototype,targetName:"Vec2"},{name:"magSqr",newName:"lengthSqr",target:Ln.prototype,targetName:"Vec2"},{name:"scale",newName:"multiplyScalar",target:Ln.prototype,targetName:"Vec2"},{name:"exactEquals",newName:"strictEquals",target:Ln.prototype,targetName:"Vec2"}]),nt(on,"Vec3",[{name:"sub",newName:"subtract",target:on,targetName:"Vec3"},{name:"mul",newName:"multiply",target:on,targetName:"Vec3"},{name:"div",newName:"divide",target:on,targetName:"Vec3"},{name:"dist",newName:"distance",target:on,targetName:"Vec3"},{name:"sqrDist",newName:"squaredDistance",target:on,targetName:"Vec3"},{name:"mag",newName:"len",target:on,targetName:"Vec3"},{name:"sqrMag",newName:"lengthSqr",target:on,targetName:"Vec3"},{name:"scale",newName:"multiplyScalar",target:on,targetName:"Vec3"},{name:"exactEquals",newName:"strictEquals",target:on,targetName:"Vec3"}]),nt(on.prototype,"Vec3",[{name:"mag",newName:"length",target:on.prototype,targetName:"Vec3"},{name:"magSqr",newName:"lengthSqr",target:on.prototype,targetName:"Vec3"},{name:"scale",newName:"multiplyScalar",target:on.prototype,targetName:"Vec3"},{name:"exactEquals",newName:"strictEquals",target:on.prototype,targetName:"Vec3"}]),nt(tn,"Vec4",[{name:"sub",newName:"subtract",target:tn,targetName:"Vec4"},{name:"mul",newName:"multiply",target:tn,targetName:"Vec4"},{name:"div",newName:"divide",target:tn,targetName:"Vec4"},{name:"dist",newName:"distance",target:tn,targetName:"Vec4"},{name:"sqrDist",newName:"squaredDistance",target:tn,targetName:"Vec4"},{name:"mag",newName:"len",target:tn,targetName:"Vec4"},{name:"sqrMag",newName:"lengthSqr",target:tn,targetName:"Vec4"},{name:"scale",newName:"multiplyScalar",target:tn,targetName:"Vec4"},{name:"exactEquals",newName:"strictEquals",target:tn,targetName:"Vec4"}]),nt(tn.prototype,"Vec4",[{name:"mag",newName:"length",target:tn.prototype,targetName:"Vec4"},{name:"magSqr",newName:"lengthSqr",target:tn.prototype,targetName:"Vec4"},{name:"scale",newName:"multiplyScalar",target:tn.prototype,targetName:"Vec4"},{name:"exactEquals",newName:"strictEquals",target:tn.prototype,targetName:"Vec4"}]),nt(Sn,"Quat",[{name:"mag",newName:"len",target:Sn,targetName:"Quat"},{name:"mul",newName:"multiply",target:Sn,targetName:"Quat"},{name:"sqrMag",newName:"lengthSqr",target:Sn,targetName:"Quat"},{name:"scale",newName:"multiplyScalar",target:Sn,targetName:"Quat"},{name:"exactEquals",newName:"strictEquals",target:Sn,targetName:"Quat"}]),nt(Sn.prototype,"Quat",[{name:"scale",newName:"multiplyScalar",target:Sn.prototype,targetName:"Quat"},{name:"exactEquals",newName:"strictEquals",target:Sn.prototype,targetName:"Quat"}]),nt(dn,"Color",[{name:"sub",newName:"subtract",target:dn,targetName:"Color"},{name:"mul",newName:"multiply",target:dn,targetName:"Color"},{name:"div",newName:"divide",target:dn,targetName:"Color"},{name:"exactEquals",newName:"strictEquals",target:dn,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,o=t.m01*e+t.m05*i+t.m13,a=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,d=Math.min(s,a,u,c),f=Math.max(s,a,u,c),p=Math.min(o,h,l,_),m=Math.max(o,h,l,_);return this.x=d,this.y=p,this.width=f-d,this.height=m-p,this},i.transformMat4ToPoints=function(t,e,i,n,r){var s=this.x,o=this.y,a=s+this.width,h=o+this.height;e.x=t.m00*s+t.m04*o+t.m12,e.y=t.m01*s+t.m05*o+t.m13,r.x=t.m00*a+t.m04*o+t.m12,r.y=t.m01*a+t.m05*o+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*a+t.m04*h+t.m12,n.y=t.m01*a+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 Ln(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 Ln(this.x,this.y)},set:function(t){this.x=t.x,this.y=t.y}},{key:"size",get:function(){return new Vn(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}(Ae));function zn(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 Un(t,e,i,n)}pi.fastDefine("cc.Rect",Un,{x:0,y:0,width:0,height:0}),v.Rect=Un,v.rect=zn;var Hn=t("bs",Float64Array),Wn=t("bt",function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.createFloatArray=function(t){return new Hn(t)},n(e,[{key:"array",get:function(){return this._array}}]),e}(Ae)),jn=Object.freeze({__proto__:null,bits:x,Vec2:Ln,v2:Nn,Vec3:on,v3:an,Vec4:tn,v4:en,Quat:Sn,quat:xn,Mat3:mn,Mat4:In,mat4:On,AffineTransform:kn,Size:Vn,size:Gn,Rect:Un,rect:zn,Color:dn,color:fn,preTransforms:Rn,HALF_PI:Ai,TWO_PI:bi,EPSILON:Ei,equals:Ci,approx:wi,clamp:xi,clamp01:Ri,lerp:Ii,toRadian:Bi,toDegree:Di,random:Pi,setRandGenerator:Oi,randomRange:Mi,randomRangeInt:Li,pseudoRandom:Ni,pseudoRandomRange:Fi,pseudoRandomRangeInt:ki,nextPow2:Vi,repeat:Gi,pingPong:Ui,inverseLerp:zi,absMaxComponent:Hi,absMax:Wi,enumerableProps:ji,floatToHalf:Qi,halfToFloat:Zi,MATH_FLOAT_ARRAY:Hn,MathBase:Wn});t("aF",jn);var Xn=new on,qn=new on,Yn=new on,Kn=new on,Jn=new on,Qn=new on,Zn=new Array(3),$n=new Array(3);function tr(t,e){return on.dot(e.n,t)-e.d}function er(t,e,i){return on.copy(t,e),on.subtract(Jn,i.center,i.halfExtents),on.add(Qn,i.center,i.halfExtents),t.x=t.xQn.x?Qn.x:t.x,t.y=t.y>Qn.y?Qn.y:t.y,t.z=t.z>Qn.z?Qn.z:t.z,t}function ir(t,e,i){on.set(Xn,i.orientation.m00,i.orientation.m01,i.orientation.m02),on.set(qn,i.orientation.m03,i.orientation.m04,i.orientation.m05),on.set(Yn,i.orientation.m06,i.orientation.m07,i.orientation.m08),Zn[0]=Xn,Zn[1]=qn,Zn[2]=Yn,$n[0]=i.halfExtents.x,$n[1]=i.halfExtents.y,$n[2]=i.halfExtents.z,on.subtract(Kn,e,i.center),on.set(t,i.center.x,i.center.y,i.center.z);for(var n=0;n<3;n++){var r=on.dot(Kn,Zn[n]);r>$n[n]&&(r=$n[n]),r<-$n[n]&&(r=-$n[n]),t.x+=r*Zn[n].x,t.y+=r*Zn[n].y,t.z+=r*Zn[n].z}return t}var nr=Object.freeze({__proto__:null,point_plane:tr,pt_point_plane:function(t,e,i){var n=tr(e,i);return on.subtract(t,e,on.multiplyScalar(t,i.n,n))},pt_point_aabb:er,pt_point_obb:ir,pt_point_line:function(t,e,i,n){on.subtract(Xn,i,n);var r=Xn.clone(),s=on.lengthSqr(r);if(0===s)on.copy(t,i);else{on.subtract(Xn,e,i);var o=on.dot(Xn,r)/s;o<0?on.copy(t,i):o>1?on.copy(t,n):on.scaleAndAdd(t,i,r,o)}}}),rr={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},sr=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=rr.SHAPE_LINE,this.s=new on(t,e,i),this.e=new on(n,r,s)}return t.create=function(e,i,n,r,s,o){return new t(e,i,n,r,s,o)},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 on.copy(t.s,e.s),on.copy(t.e,e.e),t},t.fromPoints=function(t,e,i){return on.copy(t.s,e),on.copy(t.e,i),t},t.set=function(t,e,i,n,r,s,o){return t.s.x=e,t.s.y=i,t.s.z=n,t.e.x=r,t.e.y=s,t.e.z=o,t},t.len=function(t){return on.distance(t.s,t.e)},t.prototype.length=function(){return on.distance(this.s,this.e)},n(t,[{key:"type",get:function(){return this._type}}]),t}(),or=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.o=void 0,this.d=void 0,this._type=void 0,this._type=rr.SHAPE_RAY,this.o=new on(t,e,i),this.d=new on(n,r,s)}return t.create=function(e,i,n,r,s,o){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===o&&(o=1),new t(e,i,n,r,s,o)},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 on.copy(t.o,e.o),on.copy(t.d,e.d),t},t.fromPoints=function(t,e,i){return on.copy(t.o,e),on.normalize(t.d,on.subtract(t.d,i,e)),t},t.set=function(t,e,i,n,r,s,o){return t.o.x=e,t.o.y=i,t.o.z=n,t.d.x=r,t.d.y=s,t.d.z=o,t},t.prototype.computeHit=function(t,e){on.normalize(t,this.d),on.scaleAndAdd(t,this.o,t,e)},n(t,[{key:"type",get:function(){return this._type}}]),t}(),ar=new on,hr=new on,ur=new on,lr=new on;function cr(t){return Math.max(Math.max(t.x,t.y),t.z)}var _r,dr,fr,pr,mr,gr=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._center=new on(0,0,0),this._radius=0,this._type=void 0,this._type=rr.SHAPE_SPHERE,this._center=new on(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 on.copy(t.center,e.center),t.radius=e.radius,t},t.fromPoints=function(t,e,i){return on.multiplyScalar(t.center,on.add(ar,e,i),.5),t.radius=.5*on.subtract(ar,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){on.set(t,this.center.x-this.radius,this.center.y-this.radius,this.center.z-this.radius),on.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){on.transformMat4(r.center,this.center,t),r.radius=this.radius*cr(n)},e.translateAndRotate=function(t,e,i){on.transformMat4(i.center,this.center,t)},e.setScale=function(t,e){e.radius=this.radius*cr(t)},e.mergePoint=function(t){this.radius<0&&(this.center.set(t),this.radius=0),on.subtract(hr,t,this.center);var e=hr.length();if(e>this.radius){var i=.5*(e-this.radius);this.radius+=i,on.multiplyScalar(hr,hr,i/e),on.add(this.center,this.center,hr)}},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;on.subtract(pr,t.o,e.a);var s=on.dot(pr,fr)*r;if(s<0||s>1)return 0;on.cross(mr,pr,_r);var o=on.dot(t.d,mr)*r;if(o<0||s+o>1)return 0;var a=on.dot(dr,mr)*r;return a<0?0:a}),Sr=function(){var t=new on(0,0,0);return function(e,i){var n=i.radius,r=i.center,s=e.o,o=e.d,a=n*n;on.subtract(t,r,s);var h=t.lengthSqr(),u=on.dot(t,o),l=a-(h-u*u);if(l<0)return 0;var c=Math.sqrt(l),_=hp?0:f>0?f:p}(i,t,e)}}(),Ar=function(){var t=new on,e=new on,i=new on,n=new on,r=new on,s=new on,o=new on,a=new Array(3),h=new Array(3),u=new Array(3),l=new Array(6);return function(c,_){a[0]=_.halfExtents.x,a[1]=_.halfExtents.y,a[2]=_.halfExtents.z,t=_.center,e=c.o,i=c.d,on.set(n,_.orientation.m00,_.orientation.m01,_.orientation.m02),on.set(r,_.orientation.m03,_.orientation.m04,_.orientation.m05),on.set(s,_.orientation.m06,_.orientation.m07,_.orientation.m08),on.subtract(o,t,e),h[0]=on.dot(n,i),h[1]=on.dot(r,i),h[2]=on.dot(s,i),u[0]=on.dot(n,o),u[1]=on.dot(r,o),u[2]=on.dot(s,o);for(var d=0;d<3;++d){if(0===h[d]){if(-u[d]-a[d]>0||-u[d]+a[d]<0)return 0;h[d]=1e-7}l[2*d+0]=(u[d]+a[d])/h[d],l[2*d+1]=(u[d]-a[d])/h[d]}var f=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||f>p?0:f>0?f:p}}(),br=function(){var t=new on,e=new on,i=new on,n=new on,r=new on,s=new on,o=new on,a=new gr;return function(h,u){var l=u.ellipseCenter0,c=u.ellipseCenter1,_=on.subtract(e,c,l);if(_.length()=0&&R<=1?E:R<0?(a.radius=u.radius,a.center.set(u.ellipseCenter0),as.raySphere(h,a)):R>1?(a.radius=u.radius,a.center.set(u.ellipseCenter1),as.raySphere(h,a)):0}}(),Er=function(){var t=new on(0,0,0);return function(e,i){on.subtract(t,e.e,e.s);var n=-tr(e.s,i)/on.dot(t,i.n);return n<0||n>1?0:n}}(),Cr=function(){var t=new on(0,0,0),e=new on(0,0,0),i=new on(0,0,0),n=new on(0,0,0),r=new on(0,0,0),s=new on(0,0,0);return function(o,a,h){on.subtract(t,a.b,a.a),on.subtract(e,a.c,a.a),on.subtract(i,o.s,o.e),on.cross(r,t,e);var u=on.dot(i,r);if(u<=0)return 0;on.subtract(n,o.s,a.a);var l=on.dot(n,r);if(l<0||l>u)return 0;on.cross(s,i,n);var c=on.dot(e,s);if(c<0||c>u)return 0;var _=-on.dot(t,s);if(_<0||c+_>u)return 0;if(h){var d=1/u,f=1-(c*=d)-(_*=d);on.set(h,a.a.x*f+a.b.x*c+a.c.x*_,a.a.y*f+a.b.y*c+a.c.y*_,a.a.z*f+a.b.z*c+a.c.z*_)}return 1}}(),wr=new or;function Rr(t,e){wr.o.set(t.s),on.subtract(wr.d,t.e,t.s),wr.d.normalize();var i=Tr(wr,e);return i<=t.length()?i:0}function Ir(t,e){wr.o.set(t.s),on.subtract(wr.d,t.e,t.s),wr.d.normalize();var i=Ar(wr,e);return i<=t.length()?i:0}function Br(t,e){wr.o.set(t.s),on.subtract(wr.d,t.e,t.s),wr.d.normalize();var i=Sr(wr,e);return i<=t.length()?i:0}var Dr,Pr,Or,Mr,Lr=(Dr=new on,Pr=new on,Or=new on,Mr=new on,function(t,e){return on.subtract(Dr,t.center,t.halfExtents),on.add(Pr,t.center,t.halfExtents),on.subtract(Or,e.center,e.halfExtents),on.add(Mr,e.center,e.halfExtents),Dr.x<=Mr.x&&Pr.x>=Or.x&&Dr.y<=Mr.y&&Pr.y>=Or.y&&Dr.z<=Mr.z&&Pr.z>=Or.z});function Nr(t,e,i,n,r,s){on.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),on.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),on.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),on.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),on.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),on.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),on.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),on.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 Fr(t,e){for(var i=on.dot(e,t[0]),n=i,r=1;r<8;++r){var s=on.dot(e,t[r]);i=sn?s:n}return[i,n]}var kr,Vr,Gr,Ur,zr,Hr=function(){for(var t=new Array(15),e=0;e<15;e++)t[e]=new on(0,0,0);for(var i=new Array(8),n=new Array(8),r=0;r<8;r++)i[r]=new on(0,0,0),n[r]=new on(0,0,0);var s=new on,o=new on;return function(e,r){on.set(t[0],1,0,0),on.set(t[1],0,1,0),on.set(t[2],0,0,1),on.set(t[3],r.orientation.m00,r.orientation.m01,r.orientation.m02),on.set(t[4],r.orientation.m03,r.orientation.m04,r.orientation.m05),on.set(t[5],r.orientation.m06,r.orientation.m07,r.orientation.m08);for(var a=0;a<3;++a)on.cross(t[6+3*a],t[a],t[3]),on.cross(t[7+3*a],t[a],t[4]),on.cross(t[7+3*a],t[a],t[5]);on.subtract(s,e.center,e.halfExtents),on.add(o,e.center,e.halfExtents),function(t,e,i){on.set(i[0],t.x,e.y,e.z),on.set(i[1],t.x,e.y,t.z),on.set(i[2],t.x,t.y,e.z),on.set(i[3],t.x,t.y,t.z),on.set(i[4],e.x,e.y,e.z),on.set(i[5],e.x,e.y,t.z),on.set(i[6],e.x,t.y,e.z),on.set(i[7],e.x,t.y,t.z)}(s,o,i),Nr(r.center,r.halfExtents,t[3],t[4],t[5],n);for(var h=0;h<15;++h){var u=Fr(i,t[h]),l=Fr(n,t[h]);if(l[0]>u[1]||u[0]>l[1])return 0}return 1}}(),Wr=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=on.dot(e.n,t.center);return n+ie.d?0:1},jr=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}}(),qr=(kr=new on(0,0,0),Vr=new mn,function(t,e){return on.subtract(kr,e,t.center),on.transformMat3(kr,kr,mn.transpose(Vr,t.orientation)),i=kr,n=t.halfExtents,Math.abs(i.x)e.d?0:1}),Kr=function(t,e){for(var i=0;ir.halfExtents.x?i++:e<-r.halfExtents.x&&n++;if(i===o.vertices.length||n===o.vertices.length)return 0;i=0,n=0;for(var _=0;_r.halfExtents.y?i++:e<-r.halfExtents.y&&n++;if(i===o.vertices.length||n===o.vertices.length)return 0;i=0,n=0;for(var d=0;dr.halfExtents.z?i++:e<-r.halfExtents.z&&n++;return i===o.vertices.length||n===o.vertices.length?0:1}}(),Qr=function(){for(var t=new Array(15),e=0;e<15;e++)t[e]=new on(0,0,0);for(var i=new Array(8),n=new Array(8),r=0;r<8;r++)i[r]=new on(0,0,0),n[r]=new on(0,0,0);return function(e,r){on.set(t[0],e.orientation.m00,e.orientation.m01,e.orientation.m02),on.set(t[1],e.orientation.m03,e.orientation.m04,e.orientation.m05),on.set(t[2],e.orientation.m06,e.orientation.m07,e.orientation.m08),on.set(t[3],r.orientation.m00,r.orientation.m01,r.orientation.m02),on.set(t[4],r.orientation.m03,r.orientation.m04,r.orientation.m05),on.set(t[5],r.orientation.m06,r.orientation.m07,r.orientation.m08);for(var s=0;s<3;++s)on.cross(t[6+3*s],t[s],t[3]),on.cross(t[7+3*s],t[s],t[4]),on.cross(t[8+3*s],t[s],t[5]);Nr(e.center,e.halfExtents,t[0],t[1],t[2],i),Nr(r.center,r.halfExtents,t[3],t[4],t[5],n);for(var o=0;o<15;++o){var a=Fr(i,t[o]),h=Fr(n,t[o]);if(h[0]>a[1]||a[0]>h[1])return 0}return 1}}(),Zr=function(){for(var t=new gr,e=new on,i=new on,n=new on,r=new Array(8),s=0;s<8;s++)r[s]=new on;for(var o=new Array(8),a=0;a<8;a++)o[a]=new on;return function(s,a){if(0===on.squaredDistance(a.ellipseCenter0,a.ellipseCenter1))return t.radius=a.radius,t.center.set(a.ellipseCenter0),as.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,Nr(s.center,s.halfExtents,e,i,n,r);var h=o,u=on.copy(h[0],e),l=on.copy(h[1],i),c=on.copy(h[2],n);on.subtract(h[3],a.center,s.center).normalize();var _=on.subtract(h[4],a.ellipseCenter0,a.ellipseCenter1);_.normalize(),on.cross(h[5],u,_),on.cross(h[6],l,_),on.cross(h[7],c,_);for(var d=0;d<8;++d){var f=Fr(r,h[d]),p=on.dot(h[d],a.ellipseCenter0),m=on.dot(h[d],a.ellipseCenter1),g=Math.max(p,m),y=Math.min(p,m)-a.radius,v=g+a.radius;if(y>f[1]||f[0]>v)return 0}return 1}}(),$r=function(t,e){var i=on.dot(e.n,t.center),n=t.radius*e.n.length();return i+ne.d?0:1},ts=function(t,e){for(var i=0;ia)){on.add(Ur,s,on.multiplyScalar(Ur,o,r));for(var u=0;u<6;u++)if(u!==i&&u!==i+zr[i]){var l=e.planes[u];if(on.dot(l.n,Ur)1?on.squaredDistance(i.center,n.ellipseCenter1)v&&(h=v,u=g+f,S=p)),u<0?(u=0,-m<0?h=0:-m>d?h=v:(h=-m,v=d)):u>S&&(u=S,-m+f<0?h=0:-m+f>d?h=v:(h=-m+f,v=d));var T=Math.abs(h)0&&(t.d=e.d/i),t},t.prototype.transform=function(t){In.invert(ls,t),In.transpose(ls,ls),tn.set(cs,this.n.x,this.n.y,this.n.z,-this.d),tn.transformMat4(cs,cs,ls),on.set(this.n,cs.x,cs.y,cs.z),this.d=-cs.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}(),ds=function(){function t(t,e,i,n,r,s,o,a,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===o&&(o=0),void 0===a&&(a=1),void 0===h&&(h=0),this.a=void 0,this.b=void 0,this.c=void 0,this._type=void 0,this._type=rr.SHAPE_TRIANGLE,this.a=new on(t,e,i),this.b=new on(n,r,s),this.c=new on(o,a,h)}return t.create=function(e,i,n,r,s,o,a,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===o&&(o=0),void 0===a&&(a=0),void 0===h&&(h=0),void 0===u&&(u=1),new t(e,i,n,r,s,o,a,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 on.copy(t.a,e.a),on.copy(t.b,e.b),on.copy(t.c,e.c),t},t.fromPoints=function(t,e,i,n){return on.copy(t.a,e),on.copy(t.b,i),on.copy(t.c,n),t},t.set=function(t,e,i,n,r,s,o,a,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=o,t.c.x=a,t.c.y=h,t.c.z=u,t},n(t,[{key:"type",get:function(){return this._type}}]),t}(),fs=new on,ps=new on,ms=new on,gs=new on,ys=new mn,vs=function(t,e,i){ys.m00=Math.abs(i.m00),ys.m01=Math.abs(i.m01),ys.m02=Math.abs(i.m02),ys.m03=Math.abs(i.m04),ys.m04=Math.abs(i.m05),ys.m05=Math.abs(i.m06),ys.m06=Math.abs(i.m08),ys.m07=Math.abs(i.m09),ys.m08=Math.abs(i.m10),on.transformMat3(t,e,ys)},Ss=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=1),void 0===r&&(r=1),void 0===s&&(s=1),this.center=void 0,this.halfExtents=void 0,this._type=void 0,this._type=rr.SHAPE_AABB,this.center=new on(t,e,i),this.halfExtents=new on(n,r,s)}t.create=function(e,i,n,r,s,o){return new t(e,i,n,r,s,o)},t.clone=function(e){return new t(e.center.x,e.center.y,e.center.z,e.halfExtents.x,e.halfExtents.y,e.halfExtents.z)},t.copy=function(t,e){return on.copy(t.center,e.center),on.copy(t.halfExtents,e.halfExtents),t},t.fromPoints=function(t,e,i){return on.add(fs,i,e),on.subtract(ps,i,e),on.multiplyScalar(t.center,fs,.5),on.multiplyScalar(t.halfExtents,ps,.5),t},t.set=function(t,e,i,n,r,s,o){return t.center.set(e,i,n),t.halfExtents.set(r,s,o),t},t.merge=function(e,i,n){return on.subtract(fs,i.center,i.halfExtents),on.subtract(ps,n.center,n.halfExtents),on.add(ms,i.center,i.halfExtents),on.add(gs,n.center,n.halfExtents),on.max(gs,ms,gs),on.min(ms,fs,ps),t.fromPoints(e,ms,gs)},t.toBoundingSphere=function(t,e){return t.center.set(e.center),t.radius=e.halfExtents.length(),t},t.transform=function(t,e,i){return on.transformMat4(t.center,e.center,i),vs(t.halfExtents,e.halfExtents,i),t};var e=t.prototype;return e.getBoundary=function(t,e){on.subtract(t,this.center,this.halfExtents),on.add(e,this.center,this.halfExtents)},e.transform=function(t,e,i,n,r){on.transformMat4(r.center,this.center,t),vs(r.halfExtents,this.halfExtents,t)},e.clone=function(){return t.clone(this)},e.copy=function(e){return t.copy(this,e)},e.mergePoint=function(t){this.getBoundary(fs,ps),t.xps.x&&(ps.x=t.x),t.y>ps.y&&(ps.y=t.y),t.z>ps.z&&(ps.z=t.z),on.add(ms,fs,ps),this.center.set(on.multiplyScalar(ms,ms,.5)),this.halfExtents.set(ps.x-ms.x,ps.y-ms.y,ps.z-ms.z)},e.mergePoints=function(t){if(!(t.length<1))for(var e=0;e>>1;n<=r;s=n+r>>>1){var o=t[s];if(o>e+i)r=s-1;else{if(!(o=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 Ps(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 Ps(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]||wi(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=Ps(i,t);if(s>=0)return s;var o=~s;return 0===o?(i.unshift(t),n.unshift(e)):o===r?(i.push(t),n.push(e)):(i.splice(o-1,0,t),n.splice(o-1,0,e)),o},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 Fs(t){return t>-1e-9&&t<1e-9}function ks(t,e,i,n){return i.slice().reverse().reduce((function(i,n){return n(t,e,i)||i}),n)}pi.fastDefine("cc.KeyframeCurve",Ns,{_times:[],_values:[]}),t("cm",Os),function(t){t[t.LINEAR=0]="LINEAR",t[t.CONSTANT=1]="CONSTANT",t[t.CUBIC=2]="CUBIC"}(Os||t("cm",Os={})),t("cn",Ms),function(t){t[t.LINEAR=0]="LINEAR",t[t.CLAMP=1]="CLAMP",t[t.LOOP=2]="LOOP",t[t.PING_PONG=3]="PING_PONG"}(Ms||t("cn",Ms={})),t("co",Ls),function(t){t[t.NONE=0]="NONE",t[t.LEFT=1]="LEFT",t[t.RIGHT=2]="RIGHT",t[t.BOTH=3]="BOTH"}(Ls||t("co",Ls={}));var Vs=function(){},Gs=function(){return Vs},Us=zs((function(){}));function zs(t){return function(e){return"function"==typeof e?t(e):function(i){return t(i,e)}}}function Hs(t){return function(e){return function(i){!function(t,e,i){var n=js(t);if(n){var r=Xs(n,"proto");Xs(r,"editor")[e]=i}}(i,t,e)}}}var Ws="__ccclassCache__";function js(t){return Xs(t,Ws)}function Xs(t,e){return t[e]||(t[e]={})}var qs=zs((function(t,e){var i=zt(t);i===Object&&(i=null);var n={name:e,extends:i,ctor:t},r=t[Ws];if(r){var s=r.proto;s&&Gt(n,s),t[Ws]=void 0}return pi(n)})),Ys=Hs("requireComponent"),Ks=Hs("executionOrder"),Js=Us;function Qs(t,e,i){var n=null;function r(t,e,i){!function(t,e,i,n,r,s){var o,a=s&&"function"!=typeof s&&(s.get||s.set);r&&(o=ni(r,a));var h=Gt(e,o||r||{});a?(s.get&&(h.get=s.get),s.set&&(h.set=s.set)):to(t,h,i,n,s)}(function(t){return js(t.constructor)}(t),function(t,e){var i,n,r=Xs(js(t.constructor),"proto"),s=Xs(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?Qs({type:void 0}):void 0===e?(n=t,r):void r(t,e,i)}function Zs(t){var e;try{e=t()}catch(e){return t}return"object"!=typeof e||null===e?e:t}function $s(t,e,i){var n,r,s=js(t.constructor),o=Xs(s,"proto"),a=Xs(o,"properties"),h=null!==(r=a[n=e])&&void 0!==r?r:a[n]={};return h.__internalFlags|=ri.STANDALONE,i&&"function"!=typeof i&&(i.get||i.set)?(i.get&&(h.get=i.get),i.set&&(h.set=i.set)):to(s,h,t.constructor,e,i),h}function to(t,e,i,n,r){if(void 0!==r)"function"==typeof r?e.default=Zs(r):null===r||r.initializer&&(e.default=Zs(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 eo=Symbol("cc:SerializationMetadata"),io=t("cO",(function(t,e,i){so($s(t,e,i))}));function no(t){return function(e,i,n){var r=$s(e,i,n);r.formerlySerializedAs=t,so(r)}}var ro=function(t,e,i){var n=$s(t,e,i);n.editorOnly=!0,so(n)};function so(t){t.__internalFlags|=ri.IMPLICIT_SERIALIZABLE}var oo=Vs,ao=Us,ho=Gs,uo=Us,lo=Gs,co=Gs,_o=Gs,fo=t("cD",Vs),po=t("cF",Gs),mo=t("cG",Gs),go=t("cE",Gs),yo=t("cI",Gs),vo=t("cJ",Gs),So=t("cK",Vs),To=t("cH",Gs),Ao=t("cL",Vs),bo=xo(qe),Eo=xo(Ye),Co=xo(Ke),wo=xo(Je);function xo(t){return Qs({type:t})}var Ro=t("cM",(function(t,e,i){$s(t,e,i).override=!0})),Io=t("bX","__editorExtras__"),Bo=t("b$",(function(){})),Do=Object.freeze({__proto__:null,uniquelyReferenced:oo,ccclass:qs,property:Qs,requireComponent:Ys,executionOrder:Ks,disallowMultiple:Js,executeInEditMode:ao,menu:ho,playOnFocus:uo,inspector:lo,icon:co,help:_o,type:xo,integer:bo,float:Eo,boolean:Co,string:wo,editable:fo,tooltip:go,visible:po,displayName:mo,displayOrder:To,range:yo,rangeStep:vo,slide:So,disallowAnimation:Ao,override:Ro,formerlySerializedAs:no,serializable:io});t("bO",Do);var Po,Oo,Mo,Lo,No,Fo,ko,Vo,Go,Uo,zo=[],Ho=t("bR",function(){function t(t){void 0===t&&(t=""),this._objFlags=void 0,this._name=void 0,this._name=t,this._objFlags=0}t._deferredDestroy=function(){for(var t=zo.length,e=0;e>3},n=i.storageUnit,r=qo(i.elementType),s=new(Yo(n))(t,this._byteOffset,this._unitCount),o=new Array(this._length),a=0;a=1?1:t*t*(3-2*t)}function Da(t){return t<=0?0:t>=1?1:t*t*t*(t*(6*t-15)+10)}v._decorator=Do;var Pa=za(ta,ea),Oa=za(na,ra),Ma=za(oa,aa),La=za(ua,la),Na=za(_a,da),Fa=za(pa,ma),ka=za(ya,va),Va=za(Ta,Aa),Ga=za(Ea,Ca),Ua=za(xa,Ra);function za(t,e){return function(i){return i<.5?e(2*i)/2:t(2*i-1)/2+.5}}var Ha,Wa,ja=Object.freeze({__proto__:null,constant:Zo,linear:$o,quadIn:ta,quadOut:ea,quadInOut:ia,cubicIn:na,cubicOut:ra,cubicInOut:sa,quartIn:oa,quartOut:aa,quartInOut:ha,quintIn:ua,quintOut:la,quintInOut:ca,sineIn:_a,sineOut:da,sineInOut:fa,expoIn:pa,expoOut:ma,expoInOut:ga,circIn:ya,circOut:va,circInOut:Sa,elasticIn:Ta,elasticOut:Aa,elasticInOut:ba,backIn:Ea,backOut:Ca,backInOut:wa,bounceIn:xa,bounceOut:Ra,bounceInOut:Ia,smooth:Ba,fade:Da,quadOutIn:Pa,cubicOutIn:Oa,quartOutIn:Ma,quintOutIn:La,sineOutIn:Na,expoOutIn:Fa,circOutIn:ka,elasticOutIn:Va,backOutIn:Ga,bounceOutIn:Ua});t("cy",ja),t("cY",Wa),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"}(Wa||t("cY",Wa={}));var Xa,qa=((Ha={})[Wa.CONSTANT]=Zo,Ha[Wa.LINEAR]=$o,Ha[Wa.QUAD_IN]=ta,Ha[Wa.QUAD_OUT]=ea,Ha[Wa.QUAD_IN_OUT]=ia,Ha[Wa.QUAD_OUT_IN]=Pa,Ha[Wa.CUBIC_IN]=na,Ha[Wa.CUBIC_OUT]=ra,Ha[Wa.CUBIC_IN_OUT]=sa,Ha[Wa.CUBIC_OUT_IN]=Oa,Ha[Wa.QUART_IN]=oa,Ha[Wa.QUART_OUT]=aa,Ha[Wa.QUART_IN_OUT]=ha,Ha[Wa.QUART_OUT_IN]=Ma,Ha[Wa.QUINT_IN]=ua,Ha[Wa.QUINT_OUT]=la,Ha[Wa.QUINT_IN_OUT]=ca,Ha[Wa.QUINT_OUT_IN]=La,Ha[Wa.SINE_IN]=_a,Ha[Wa.SINE_OUT]=da,Ha[Wa.SINE_IN_OUT]=fa,Ha[Wa.SINE_OUT_IN]=Na,Ha[Wa.EXPO_IN]=pa,Ha[Wa.EXPO_OUT]=ma,Ha[Wa.EXPO_IN_OUT]=ga,Ha[Wa.EXPO_OUT_IN]=Fa,Ha[Wa.CIRC_IN]=ya,Ha[Wa.CIRC_OUT]=va,Ha[Wa.CIRC_IN_OUT]=Sa,Ha[Wa.CIRC_OUT_IN]=ka,Ha[Wa.ELASTIC_IN]=Ta,Ha[Wa.ELASTIC_OUT]=Aa,Ha[Wa.ELASTIC_IN_OUT]=ba,Ha[Wa.ELASTIC_OUT_IN]=Va,Ha[Wa.BACK_IN]=Ea,Ha[Wa.BACK_OUT]=Ca,Ha[Wa.BACK_IN_OUT]=wa,Ha[Wa.BACK_OUT_IN]=Ga,Ha[Wa.BOUNCE_IN]=xa,Ha[Wa.BOUNCE_OUT]=Ra,Ha[Wa.BOUNCE_IN_OUT]=Ia,Ha[Wa.BOUNCE_OUT_IN]=Ua,Ha[Wa.SMOOTH]=Ba,Ha[Wa.FADE]=Da,Ha);function Ya(t){return qa[t]}b(255),b(65280);var Ka,Ja,Qa,Za=Os.LINEAR<<0|Ls.NONE<<8|Wa.LINEAR<<16,$a=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r>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}(Bo);function th(t){var e=new $a;if("number"==typeof t)e.value=t;else{var i=t.interpolationMode,n=t.tangentWeightMode,r=t.value,s=t.rightTangent,o=t.rightTangentWeight,a=t.leftTangent,h=t.leftTangentWeight,u=t.easingMethod,l=t[Io];e.value=null!=r?r:e.value,e.rightTangent=null!=s?s:e.rightTangent,e.rightTangentWeight=null!=o?o:e.rightTangentWeight,e.leftTangent=null!=a?a: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[Io]=l)}return e}pi.fastDefine("cc.RealKeyframeValue",$a,((Xa={interpolationMode:Os.LINEAR,tangentWeightMode:Ls.NONE,value:0,rightTangent:0,rightTangentWeight:0,leftTangent:0,leftTangentWeight:0,easingMethod:Wa.LINEAR})[Io]=void 0,Xa)),pi.Attr.setClassAttr($a,Io,"editorOnly",!0),(Ka=$a,null!==(Qa=(Ja=Ka)[eo])&&void 0!==Qa?Qa:Ja[eo]={}).uniquelyReferenced=!0;var eh,ih=t("cl",function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;rs){var h=this.postExtrapolation,u=i[n-1];if(h===Ms.CLAMP||n<2)return u.value;switch(h){case Ms.LINEAR:return yh(s,u.value,e[n-2],i[n-2].value,t);case Ms.LOOP:t=mh(t,r,s);break;case Ms.PING_PONG:t=gh(t,r,s);break;default:return u.value}}var l=Ps(e,t);if(l>=0)return i[l].value;var c=~l,_=c-1,d=e[_],f=i[_],p=e[c];return function(t,e,i,n,r){var s=i-t;switch(e.interpolationMode){default:case Os.CONSTANT:return e.value;case Os.LINEAR:var o=e.easingMethod===Wa.LINEAR?r:Ya(e.easingMethod)(r);return Ii(e.value,n.value,o);case Os.CUBIC:var a=1/3,h=e.rightTangent,u=e.rightTangentWeight,l=0!=(e.tangentWeightMode&Ls.RIGHT),c=n.leftTangent,_=n.leftTangentWeight,d=0!=(n.tangentWeightMode&Ls.LEFT);if(l||d){var f=0;if(l)f=u;else{var p=s,m=s*h;f=Math.sqrt(p*p+m*m)*a}var g=Math.atan(h),y=Math.cos(g)*f+t,v=Math.sin(g)*f+e.value,S=0;if(d)S=_;else{var T=s,A=s*c;S=Math.sqrt(T*T+A*A)*a}var b=Math.atan(c),E=(y-t)/s,C=(-Math.cos(b)*S+i-t)/s,w=v,x=-Math.sin(b)*S+n.value,R=[0,0,0],I=function(t,e,i,n,r){var s=i/n,o=e/n,a=s*s,h=1/3*(-1/3*a+o),u=.5*(2/27*s*a-1/3*s*o+t/n),l=h*h*h,c=u*u+l,_=0;if(Fs(c)){if(Fs(u))return r[0]=0,1;var d=Math.cbrt(-u);return r[0]=2*d,r[1]=-d,2}if(c<0){var f=1/3*Math.acos(-u/Math.sqrt(-l)),p=2*Math.sqrt(-h);r[0]=p*Math.cos(f),r[1]=-p*Math.cos(f+Math.PI/3),r[2]=-p*Math.cos(f-Math.PI/3),_=3}else{var m=Math.sqrt(c),g=Math.cbrt(m-u),y=-Math.cbrt(m+u);r[0]=g+y,_=1}for(var v=1/3*s,S=0;S<_;++S)r[S]-=v;return _}(0-r,3*E,3*C-6*E,3*(E-C)+1,R),B=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 vh(e.value,w,x,n.value,B)}var D=e.value+a*h*s,P=n.value-a*c*s;return vh(e.value,D,P,n.value,r)}}(d,f,p,i[c],(t-d)/(p-d))},i.addKeyFrame=function(e,i){return t.prototype.addKeyFrame.call(this,e,th(i))},i.assignSorted=function(t,e){if(void 0!==e)this.setKeyframes(t.slice(),e.map((function(t){return th(t)})));else{var i=Array.from(t);this.setKeyframes(i.map((function(t){return t[0]})),i.map((function(t){return th(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 wi(i.value,e,t)}))},i[Jo]=function(t,e){if(e.toCCON){var i=this._times,n=this._values,r=i.length,s=new DataView(new ArrayBuffer(0+nh+nh+rh+sh*r+dh*r)),o=0;s.setUint8(o,this.preExtrapolation),o+=nh,s.setUint8(o,this.postExtrapolation),o+=nh,s.setUint32(o,r,!0),o+=rh,i.forEach((function(t,e){return s.setFloat32(o+sh*e,t,!0)})),o+=sh*r;for(var a,h=d(n);!(a=h()).done;){var u=a.value;o=fh(s,u,o)}var l=new Uint8Array(s.buffer,0,o);t.writeProperty("bytes",l);var c=n.map((function(t){return t[Io]}));c.some((function(t){return void 0!==t}))&&t.writeProperty("keyframeValueEditorExtras",c)}else t.writeThis()},i[Qo]=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+=nh,this.postExtrapolation=n.getUint8(r),r+=nh;var s=n.getUint32(r,!0);r+=rh;var o=Array.from({length:s},(function(t,e){return n.getFloat32(r+sh*e,!0)}));r+=sh*s;for(var a=new Array(s),h=0;h>8;return e.easingMethod=s,n}function mh(t,e,i){return e+Gi(t-e,i-e)}function gh(t,e,i){return e+Ui(t-e,i-e)}function yh(t,e,i,n,r){return e+(n-e)/(i-t)*(r-t)}function vh(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 Sh(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}v.bezier=Sh;var Th,Ah,bh,Eh,Ch,wh,xh,Rh,Ih,Bh,Dh=Math.cos,Ph=Math.acos,Oh=Math.max,Mh=2*Math.PI,Lh=Math.sqrt;function Nh(t){return t<0?-Math.pow(-t,1/3):Math.pow(t,1/3)}function Fh(t,e){var i=function(t,e){var i,n,r,s,o=e-0,a=e-t[0],h=3*o,u=3*a,l=3*(e-t[2]),c=1/(-o+u-l+(e-1)),_=1/3,d=(h-6*a+l)*c,f=d*_,p=(-h+u)*c,m=(3*p-d*d)*_,g=m*_,y=(2*d*d*d-9*d*p+o*c*27)/27,v=y/2,S=v*v+g*g*g;if(S<0){var T=-m*_,A=Lh(T*T*T),b=-y/(2*A),E=Ph(b<-1?-1:b>1?1:b),C=2*Nh(A);return n=C*Dh(E*_)-f,r=C*Dh((E+Mh)*_)-f,s=C*Dh((E+2*Mh)*_)-f,n>=0&&n<=1?r>=0&&r<=1?s>=0&&s<=1?Oh(n,r,s):Oh(n,r):s>=0&&s<=1?Oh(n,s):n:r>=0&&r<=1?s>=0&&s<=1?Oh(r,s):r:s}if(0===S)return r=-(i=v<0?Nh(-v):-Nh(v))-f,(n=2*i-f)>=0&&n<=1?r>=0&&r<=1?Oh(n,r):n:r;var w=Lh(S);return(i=Nh(-v+w))-Nh(v+w)-f}(t,e),n=t[1];return((1-i)*(n+(t[3]-n)*i)*3+i*i)*i}v.bezierByTime=Fh,t("cq",Bh),function(t){t[t.SLERP=0]="SLERP",t[t.CONSTANT=1]="CONSTANT"}(Bh||t("cq",Bh={}));var kh=qs("cc.QuatKeyframeValue")(Th=oo((Ah=function(t){var e=void 0===t?{}:t,i=e.value,n=e.interpolationMode,r=e.easingMethod;this.interpolationMode=bh&&bh(),this.value=Eh&&Eh(),this.easingMethod=Ch&&Ch(),this.value=i?Sn.clone(i):this.value,this.interpolationMode=null!=n?n:this.interpolationMode,this.easingMethod=null!=r?r:this.easingMethod},bh=ks(Ah.prototype,"interpolationMode",[io],(function(){return Bh.SLERP})),Eh=ks(Ah.prototype,"value",[io],(function(){return Sn.clone(Sn.IDENTITY)})),Ch=ks(Ah.prototype,"easingMethod",[io],(function(){return Wa.LINEAR})),Th=Ah))||Th)||Th;function Vh(t){return new kh(t)}var Gh,Uh=t("cp",qs("cc.QuatCurve")((xh=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;ru){var c=r[a-1];switch(s){case Ms.LOOP:t=h+Gi(t-h,u-h);break;case Ms.PING_PONG:t=h+Ui(t-h,u-h);break;case Ms.CLAMP:default:return Sn.copy(e,c.value)}}var _=Ps(n,t);if(_>=0)return Sn.copy(e,r[_].value);var d=~_,f=d-1,p=n[f],m=r[f],g=n[d],y=r[d],v=(t-p)/(g-p);switch(m.interpolationMode){default:case Bh.CONSTANT:return Sn.copy(e,m.value);case Bh.SLERP:var S=m.easingMethod,T=S===Wa.LINEAR?v:Array.isArray(S)?Fh(S,v):Ya(S)(v);return Sn.slerp(e,m.value,y.value,T)}},i.addKeyFrame=function(e,i){var n=new kh(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 Vh(t)})));else{var i=Array.from(t);this.setKeyframes(i.map((function(t){return t[0]})),i.map((function(t){return Vh(t[1])})))}},i[Jo]=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,o=qh*(r?1:s),a=n.reduce((function(t,e){var i=e.easingMethod;return t+(Array.isArray(i)?Yh+4*Jh:Yh)}),0),h=0,u=new DataView(new ArrayBuffer(h+=Hh+Wh+jh*s+4*Xh*s+a+o+0)),l=0,c=0;r&&(c|=Gh.INTERPOLATION_MODE),u.setUint32(l,c,!0),l+=Hh,u.setUint32(l,s,!0),l+=Wh,i.forEach((function(t,e){return u.setFloat32(l+jh*e,t,!0)})),l+=jh*s,n.forEach((function(t,e){var i=t.value,n=i.x,r=i.y,s=i.z,o=i.w,a=l+4*Xh*e;u.setFloat32(a+0*Xh,n,!0),u.setFloat32(a+1*Xh,r,!0),u.setFloat32(a+2*Xh,s,!0),u.setFloat32(a+3*Xh,o,!0)})),l+=4*Xh*s,n.forEach((function(t){var e=t.easingMethod;Array.isArray(e)?(u.setUint8(l,Kh),++l,u.setFloat32(l+0*Jh,e[0],!0),u.setFloat32(l+1*Jh,e[1],!0),u.setFloat32(l+2*Jh,e[2],!0),u.setFloat32(l+3*Jh,e[3],!0),l+=4*Jh):(u.setUint8(l,e),++l)}));var _=l;l+=o;var d=_;n.forEach((function(t){var e=t.interpolationMode;u.setUint8(d,e),r||(d+=qh)}));var f=new Uint8Array(u.buffer);t.writeProperty("bytes",f)}else t.writeThis()},i[Qo]=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+=Hh;var o=s&Gh.INTERPOLATION_MODE,a=n.getUint32(r,!0);r+=Wh;var h=Array.from({length:a},(function(t,e){return n.getFloat32(r+jh*e,!0)})),u=r+=jh*a;r+=4*Xh*a;var l=Array.from({length:a},(function(t,e){var i=u+4*Xh*e,s=n.getFloat32(i+0*Xh,!0),o=n.getFloat32(i+1*Xh,!0),a=n.getFloat32(i+2*Xh,!0),h=n.getFloat32(i+3*Xh,!0),l=n.getUint8(r);++r;var c=Vh({value:{x:s,y:o,z:a,w:h}});return l!==Kh?c.easingMethod=l:(c.easingMethod=[n.getFloat32(r+0*Jh,!0),n.getFloat32(r+1*Jh,!0),n.getFloat32(r+2*Jh,!0),n.getFloat32(r+3*Jh,!0)],r+=4*Jh),c}));if(o){var c=n.getUint8(r);++r;for(var _=0;_=0)return this._values[e];var i=xi(~e-1,0,this._values.length-1);return this._values[i]},e}(Ns))||zh),Zh=ge({Blend:0,Fixed:1}),$h=t("cs",(function(){this.color=dn.WHITE.clone(),this.time=0}));pi.fastDefine("cc.ColorKey",$h,{color:dn.WHITE.clone(),time:0}),pi.Attr.setClassAttr($h,"color","visible",!0),pi.Attr.setClassAttr($h,"time","visible",!0);var tu=t("ct",(function(){this.alpha=1,this.time=0}));pi.fastDefine("cc.AlphaKey",tu,{alpha:1,time:0}),pi.Attr.setClassAttr(tu,"alpha","visible",!0),pi.Attr.setClassAttr(tu,"time","visible",!0);var eu=t("cu",function(){function t(){this.colorKeys=[],this.alphaKeys=[],this.mode=Zh.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 dn,t)},e.evaluateFast=function(t,e){return this.getRGB(t,e),t._set_a_unsafe(this.getAlpha(e)),t},e.randomColor=function(){return this.getRandomColor(new dn)},e.getRandomColor=function(t){var e=this.colorKeys[Math.trunc(Pi()*this.colorKeys.length)],i=this.alphaKeys[Math.trunc(Pi()*this.alphaKeys.length)];return t.set(e.color),t._set_a_unsafe(i.alpha),t},e.getRGB=function(t,e){var i=this.colorKeys,n=i.length;if(n>1){e=Gi(e,1+Ei);for(var r=1;r=s&&ei[h].time&&dn.lerp(t,i[h].color,dn.BLACK,(e-i[h].time)/(1-i[h].time))}else 1===n?dn.copy(t,i[0].color):dn.copy(t,dn.WHITE);return t},e.getAlpha=function(t){var e=this.alphaKeys,i=e.length;if(i>1){t=Gi(t,1+Ei);for(var n=1;n=r&&te[a].time?Ii(e[a].alpha,0,(t-e[a].time)/(1-e[a].time)):255}return 1===i?e[0].alpha:255},t}());eu.Mode=Zh,pi.fastDefine("cc.Gradient",eu,{colorKeys:[],alphaKeys:[],mode:Zh.Blend}),pi.Attr.setClassAttr(eu,"colorKeys","visible",!0),pi.Attr.setClassAttr(eu,"alphaKeys","visible",!0),pi.Attr.setClassAttr(eu,"mode","visible",!0);var iu=function(){this.time=0,this.value=0,this.inTangent=0,this.outTangent=0};pi.fastDefine("cc.Keyframe",iu,{time:0,value:0,inTangent:0,outTangent:0});var nu=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 ru(t-this.time,this.coefficient)},t}();function ru(t,e){return t*(t*(t*e[0]+e[1])+e[2])+e[3]}var su,ou,au=function(){function t(t){if(void 0===t&&(t=null),this._curve=void 0,this.cachedKey=void 0,t instanceof ih)this._curve=t;else{var e=new ih;this._curve=e,e.preExtrapolation=Ms.LOOP,e.postExtrapolation=Ms.CLAMP,t?e.assignSorted(t.map((function(t){return[t.time,{interpolationMode:Os.CUBIC,value:t.value,leftTangent:t.inTangent,rightTangent:t.outTangent}]}))):e.assignSorted([[0,{interpolationMode:Os.CUBIC,value:1}],[1,{interpolationMode:Os.CUBIC,value:1}]])}this.cachedKey=new nu}var e=t.prototype;return e.addKey=function(t){t?this._curve.addKeyFrame(t.time,{interpolationMode:Os.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,o=i.getKeyframeTime(0),a=i.getKeyframeTime(n);switch(s){case Ms.LOOP:r=Gi(t-o,a-o)+o;break;case Ms.PING_PONG:r=Ui(t-o,a-o)+o;break;case Ms.CLAMP:default:r=xi(t,o,a)}if(r>=e.time&&ri.getKeyframeTime(r))for(var s=0;s<3;s++){var o=r+s;if(o+1e)return o}else for(var a=0;a<3;a++){var h=r-a;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 iu;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:Os.CUBIC,value:t.value,leftTangent:t.inTangent,rightTangent:t.outTangent}]})))}},{key:"preWrapMode",get:function(){return uu(this._curve.preExtrapolation)},set:function(t){this._curve.preExtrapolation=hu(t)}},{key:"postWrapMode",get:function(){return uu(this._curve.postExtrapolation)},set:function(t){this._curve.postExtrapolation=hu(t)}}]),t}();function hu(t){switch(t){default:case su.Default:case su.Normal:case su.Clamp:return Ms.CLAMP;case su.PingPong:return Ms.PING_PONG;case su.Loop:return Ms.LOOP}}function uu(t){switch(t){default:case Ms.LINEAR:case Ms.CLAMP:return su.Clamp;case Ms.PING_PONG:return su.PingPong;case Ms.LOOP:return su.Loop}}au.defaultKF=[{time:0,value:1,inTangent:0,outTangent:0},{time:1,value:1,inTangent:0,outTangent:0}],pi.fastDefine("cc.AnimationCurve",au,{_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"}(su||(su={})),function(t){t[t.LINEAR=0]="LINEAR",t[t.BEZIER=1]="BEZIER",t[t.CATMULL_ROM=2]="CATMULL_ROM"}(ou||(ou={}));var lu,cu=4294967295,_u=new on,du=new on,fu=new on,pu=new on,mu=function(){function t(t,e){void 0===t&&(t=ou.CATMULL_ROM),void 0===e&&(e=[]),this._type=void 0,this._mode=ou.CATMULL_ROM,this._knots=[],this._type=rr.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=cu),e=xi(e,0,1);var n=this.getSegments();if(0===n)return new on(0,0,0);if(i===cu){var r=1/n;i=Math.floor(e/r),e=e%r/r}if(i>=n)return new on(this._knots[this._knots.length-1]);switch(this._mode){case ou.LINEAR:return t.calcLinear(this._knots[i],this._knots[i+1],e);case ou.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 ou.CATMULL_ROM:var s=i>0?this._knots[i-1]:this._knots[i],o=i+2this.shrinkTimeSpan&&(this.tryShrink(),this._lastShrinkPassed-=this.shrinkTimeSpan)},t}()),Bu=t("bu",function(t){function e(e,i,n){var r;(r=t.call(this)||this)._ctor=void 0,r._elementsPerBatch=void 0,r._nextAvail=void 0,r._freePool=[],r._dtor=void 0,r._ctor=e,r._dtor=n||null,r._elementsPerBatch=Math.max(i,1),r._nextAvail=r._elementsPerBatch-1;for(var s=0;s>1>this._elementsPerBatch){if(this._dtor)for(var t=this._nextAvail>>1;t<=this._nextAvail;t++)this._dtor(this._freePool[t]);this._freePool.length=this._nextAvail>>1,this._nextAvail=this._freePool.length-1}},i.destroy=function(){var e=arguments.length>0?arguments[0]:null;e&&Y(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}(Ru)),Du=t("bv",function(t){function e(e,i,n){var r;(r=t.call(this)||this)._fn=void 0,r._dtor=null,r._count=0,r._data=void 0,r._initSize=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}(Ru)),Pu=t("bw",function(t){function e(e,i){var n;return(n=t.call(this)||this).array=void 0,n.length=0,n._compareFn=void 0,n._initSize=0,n.array=new Array(e),n._initSize=e,n.length=0,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;ee.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}());Ou.Priority=ge({LOW:0,MEDIUM:100,HIGH:200,SCHEDULER:1<<31>>>0});var Mu=new gt("Scheduler"),Lu=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}();Lu._listEntries=[];var Nu=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}();Nu._hashUpdateEntries=[];var Fu=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,o){var a=t._hashTimerEntries.pop();return a?(a.timers=e,a.target=i,a.timerIndex=n,a.currentTimer=r,a.currentTimerSalvaged=s,a.paused=o):a=new t(e,i,n,r,s,o),a},t.put=function(e){t._hashTimerEntries.length<20&&(e.timers=e.target=e.currentTimer=null,t._hashTimerEntries.push(e))},t}();Fu._hashTimerEntries=[];var ku=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._elapsed=-1,this._interval=n,this._delay=s,this._useDelay=this._delay>0,this._repeat=r,this._runForever=this._repeat===v.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.unschedule(this._callback,this._target)},t}();ku._timers=[];var Vu=t("ck",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=It(!0),e._hashForTimers=It(!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=Mu.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 J(1510)}},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 J(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){$(Boolean(t),1508),$(Boolean(e),1509);var i=e.uuid||e.id;if(!i)return J(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=0;--t)this.callbackInfos[t]||Uu(this.callbackInfos,t);this.containCanceled=!1},e.clear=function(){this.cancelAll(),this.callbackInfos.length=0,this.isInvoking=!1,this.containCanceled=!1},t}(),Xu=new Bu((function(){return new ju}),16),qu=t("cZ",function(){function t(){this._callbackTable=It(!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]=Xu.alloc());var s=Wu.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 o=0;o1)&&(l=!0,c="",_=0);var f=$u.UNKNOWN;-1!==o.appVersion.indexOf("Win")?f=$u.WINDOWS:l?f=$u.IOS:-1!==o.appVersion.indexOf("Mac")?f=$u.OSX:-1!==o.appVersion.indexOf("X11")&&-1===o.appVersion.indexOf("Linux")?f=$u.LINUX:u?f=$u.ANDROID:-1===o.appVersion.indexOf("Linux")&&-1===a.indexOf("ubuntu")||(f=$u.LINUX),r.os=f,r.osVersion=c,r.osMainVersion=_,r.browserType=Ju.UNKNOWN;var p=/wechat|weixin|micromessenger/i.exec(a)||/mqqbrowser|micromessenger|qqbrowser|sogou|qzone|liebao|maxthon|ucbs|360 aphone|360browser|baiduboxapp|baidubrowser|maxthon|mxbrowser|miuibrowser/i.exec(a)||/qq|qqbrowser|ucbrowser|ubrowser|edge|HuaweiBrowser/i.exec(a)||/chrome|safari|firefox|trident|opera|opr\/|oupeng/i.exec(a),m=p?p[0].toLowerCase():$u.UNKNOWN;("safari"===m&&u||"qq"===m&&/android.*applewebkit/i.test(a))&&(m=Ju.ANDROID);var y={micromessenger:Ju.WECHAT,wechat:Ju.WECHAT,weixin:Ju.WECHAT,trident:Ju.IE,edge:Ju.EDGE,"360 aphone":Ju.BROWSER_360,mxbrowser:Ju.MAXTHON,"opr/":Ju.OPERA,ubrowser:Ju.UC,huaweibrowser:Ju.HUAWEI};r.browserType=y[m]||m,r.browserVersion="";var v=/(mqqbrowser|micromessenger|qqbrowser|sogou|qzone|liebao|maxthon|uc|ucbs|360 aphone|360|baiduboxapp|baidu|maxthon|mxbrowser|miui(?:.hybrid)?)(mobile)?(browser)?\/?([\d.]+)/i.exec(a);v||(v=/(qq|chrome|safari|firefox|trident|opera|opr\/|oupeng)(mobile)?(browser)?\/?([\d.]+)/i.exec(a)),r.browserVersion=v?v[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.browserType===Ju.SAFARI){var A,b=null===(A=/ version\/(\d+)/.exec(a))||void 0===A?void 0:A[1];"string"==typeof b&&Number.parseInt(b)>=14&&(S=!0)}var E=void 0!==document.documentElement.ontouchstart||void 0!==document.ontouchstart||g,C=void 0!==document.documentElement.onmouseup||g,w=void 0!==navigator.xr,x=function(){if((r.os===$u.IOS||r.os===$u.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={})[el.WEBP]=S,n[el.IMAGE_BITMAP]=!1,n[el.WEB_VIEW]=!0,n[el.VIDEO_PLAYER]=!0,n[el.SAFE_AREA]=!1,n[el.HPE]=!1,n[el.INPUT_TOUCH]=E,n[el.EVENT_KEYBOARD]=void 0!==document.documentElement.onkeyup||g,n[el.EVENT_MOUSE]=C,n[el.EVENT_TOUCH]=E||C,n[el.EVENT_ACCELEROMETER]=void 0!==window.DeviceMotionEvent||void 0!==window.DeviceOrientationEvent,n[el.EVENT_GAMEPAD]=void 0!==navigator.getGamepads||void 0!==navigator.webkitGetGamepads||w,n[el.EVENT_HANDLE]=false,n[el.EVENT_HMD]=w,n[el.EVENT_HANDHELD]=w,n[el.WASM]=x,n),r._initPromise=[],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(el.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,o){i&&(i=!1,e.emit("show",t,n,r,s,o))};if(t)for(var s=["visibilitychange","mozvisibilitychange","msvisibilitychange","webkitvisibilitychange","qbrowserVisibilityChange"],o=0;o-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}(Ku)),rl=/(\.[^\.\/\?\\]*)(\?.*)?$/,sl=/((.*)(\/|\\|\\\\))?(.*?\..*$)?/,ol=/[^\.\/]+\/\.\.\//;function al(){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 cl(t){var e=sl.exec(t);return e?e[2]:""}function _l(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 dl(t,e,i){if(0===e.indexOf("."))return _l(t,e);var n=t.indexOf("?"),r="",s=i?hl(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 fl(t){var e=t=String(t);do{e=t,t=t.replace(ol,"")}while(e.length!==t.length);return t}function pl(t){return t.replace(/[\/\\]$/,"")}function ml(){return nl.os===$u.WINDOWS?"\\":"/"}t("bD",Object.freeze({__proto__:null,join:al,extname:hl,mainFileName:ul,basename:ll,dirname:cl,changeExtname:_l,changeBasename:dl,_normalize:fl,stripSep:pl,getSeperator:ml}));var gl=new on;function yl(t,e,i,n){n||(n=new on),t.convertToUINode(e,i,n);var r=i.position;return n.add(r),n}function vl(t,e,i){return i||(i=new on),t.worldToScreen(e,i),i.x/=v.view.getScaleX(),i.y/=v.view.getScaleY(),i}var Sl,Tl=t("bN",{WorldNode3DToLocalNodeUI:yl,WorldNode3DToWorldNodeUI:vl});v.pipelineUtils=Tl,nt(v.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=nl.isMobile&&(e&&t===Sl.PORTRAIT||!e&&t===Sl.LANDSCAPE)},i._updateContainer=function(){if(this._gameContainer){if(this.isProportionalToFrame){if(!this._gameFrame)return void Y(9201);var t,e,i=v.view.getDesignResolutionSize(),n=this._gameFrame,r=n.clientWidth,s=n.clientHeight,o=i.width,a=i.height,h=r/o,u=s/a,l=this._gameContainer.style;h0&&Y(1400,"screen.requestFullScreen(element, onFullScreenChange?, onFullScreenError?)","screen.requestFullScreen(): Promise"),El.requestFullScreen().then((function(){null==e||e.call(document)})).catch((function(t){V(t),null==i||i.call(document)}))},e.exitFullScreen=function(){return El.exitFullScreen()},e.autoFullScreen=function(t,e){var i;null===(i=this.requestFullScreen(t,e))||void 0===i||i.catch((function(t){k(t)}))},e.disableAutoFullScreen=function(){},e.on=function(t,e,i){El.on(t,e,i)},e.once=function(t,e,i){El.once(t,e,i)},e.off=function(t,e,i){El.off(t,e,i)},n(t,[{key:"devicePixelRatio",get:function(){return El.devicePixelRatio}},{key:"windowSize",get:function(){return El.windowSize},set:function(t){El.windowSize=t}},{key:"resolution",get:function(){return El.resolution}},{key:"supportsFullScreen",get:function(){return El.supportFullScreen}}]),t}(),wl=t("cg",new Cl);v.screen=wl;var xl=t("ch",{Feature:el,hasFeature:function(t){return nl.hasFeature(t)},NetworkType:Zu,Language:Qu,OS:$u,Platform:tl,BrowserType:Ju,isNative:nl.isNative,isBrowser:nl.isBrowser,isMobile:nl.isMobile,isLittleEndian:nl.isLittleEndian,platform:nl.platform,language:nl.language,languageCode:nl.nativeLanguage,os:nl.os,osVersion:nl.osVersion,osMainVersion:nl.osMainVersion,browserType:nl.browserType,browserVersion:nl.browserVersion,isXR:nl.isXR,windowPixelResolution:wl.windowSize,capabilities:{canvas:!0,opengl:!0,webp:nl.hasFeature(el.WEBP),imageBitmap:nl.hasFeature(el.IMAGE_BITMAP),touches:nl.hasFeature(el.INPUT_TOUCH),mouse:nl.hasFeature(el.EVENT_MOUSE),keyboard:nl.hasFeature(el.EVENT_KEYBOARD),accelerometer:nl.hasFeature(el.EVENT_ACCELEROMETER)},localStorage:{},getNetworkType:function(){return nl.networkType},getBatteryLevel:function(){return nl.getBatteryLevel()},garbageCollect:function(){nl.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: "+xl.hasFeature(el.WEBP)+"\r\n",t+="supports bitmap: "+xl.hasFeature(el.IMAGE_BITMAP)+"\r\n",t+="supports touches: "+xl.hasFeature(el.INPUT_TOUCH)+"\r\n",t+="supports mouse: "+xl.hasFeature(el.EVENT_MOUSE)+"\r\n",t+="supports keyboard: "+xl.hasFeature(el.EVENT_KEYBOARD)+"\r\n",t+="supports accelerometer: "+xl.hasFeature(el.EVENT_ACCELEROMETER)+"\r\n",t+="os : "+this.os+"\r\n",t+="osVersion : "+this.osVersion+"\r\n",t+="platform : "+this.platform+"\r\n",F(t+="Using "+(v.game.renderType===v.game.RENDER_TYPE_WEBGL?"WEBGL":"CANVAS")+" renderer.\r\n")},openURL:function(t){nl.openURL(t)},init:function(){var t=this;return Promise.resolve().then((function(){return nl.init()})).then((function(){try{var e=xl.localStorage=window.localStorage;e.setItem("storage",""),e.removeItem("storage"),e=null}catch(e){var i=function(){Y(5200)};t.localStorage={getItem:i,setItem:i,clear:i,removeItem:i,key:i,length:0}}t.__isWebIOS14OrIPadOS14Env=(xl.os===$u.IOS||xl.os===$u.OSX)&&nl.isBrowser&&/(OS 14)|(Version\/14)/.test(window.navigator.userAgent)}))},now:function(){return nl.now()},restartVM:function(){nl.restartJSVM()},getSafeAreaRect:function(){var t=v.view,e=El.safeAreaEdge,i=El.windowSize,n=new Ln(e.left,e.bottom),r=new Ln(i.width-e.right,i.height-e.top);t._convertToUISpace(n),t._convertToUISpace(r);var s=n.x,o=n.y,a=r.x-n.x,h=r.y-n.y;return new Un(s,o,a,h)}});v.sys=xl,st(v,"cc",[{name:"winSize",suggest:"please use view.getVisibleSize() instead."}]),st(xl,"sys",[{name:"capabilities",suggest:"please use sys.hasFeature() method instead."}]),nt(xl,"sys",["UNKNOWN","ENGLISH","CHINESE","FRENCH","ITALIAN","GERMAN","SPANISH","DUTCH","RUSSIAN","KOREAN","JAPANESE","HUNGARIAN","PORTUGUESE","ARABIC","NORWEGIAN","POLISH","TURKISH","UKRAINIAN","ROMANIAN","BULGARIAN"].map((function(t){return{name:"LANGUAGE_"+t,newName:t,target:xl.Language,targetName:"sys.Language"}}))),nt(xl,"sys",["UNKNOWN","IOS","ANDROID","WINDOWS","LINUX","OSX"].map((function(t){return{name:"OS_"+t,newName:t,target:xl.OS,targetName:"sys.OS"}}))),nt(xl,"sys",["UNKNOWN","WECHAT","ANDROID","IE","EDGE","QQ","MOBILE_QQ","UC","UCBS","BAIDU_APP","BAIDU","MAXTHON","OPERA","OUPENG","MIUI","FIREFOX","SAFARI","CHROME","LIEBAO","QZONE","SOUGOU","HUAWEI"].map((function(t){return{name:"BROWSER_TYPE_"+t,newName:t,target:xl.BrowserType,targetName:"sys.BrowserType"}}))),nt(xl,"sys",[{name:"BROWSER_TYPE_360",newName:"BROWSER_360",target:xl.BrowserType,targetName:"sys.BrowserType"}]),nt(xl,"sys",["UNKNOWN","EDITOR_PAGE","EDITOR_CORE","MOBILE_BROWSER","DESKTOP_BROWSER","WIN32","MACOS","IOS","ANDROID","OHOS","WECHAT_GAME","BAIDU_MINI_GAME","XIAOMI_QUICK_GAME","ALIPAY_MINI_GAME","BYTEDANCE_MINI_GAME","OPPO_MINI_GAME","VIVO_MINI_GAME","HUAWEI_QUICK_GAME","COCOSPLAY","LINKSURE_MINI_GAME","QTT_MINI_GAME"].map((function(t){return{name:t,target:xl.Platform,targetName:"sys.Platform"}}))),nt(xl,"sys",[{name:"IPHONE",newName:"IOS",target:xl.Platform,targetName:"sys.Platform"},{name:"IPAD",newName:"IOS",target:xl.Platform,targetName:"sys.Platform"}]),rt(xl,"sys",["LINUX","BLACKBERRY","NACL","EMSCRIPTEN","TIZEN","WINRT","WP8","QQ_PLAY","FB_PLAYABLE_ADS"].map((function(t){return{name:t}}))),nt(xl,"sys",[{name:"windowPixelResolution",target:wl,targetName:"screen",newName:"windowSize"}]),st(wl,"screen",[{name:"autoFullScreen",suggest:"please use screen.requestFullScreen() instead."},{name:"disableAutoFullScreen"}]);var Rl=t("cj",{topLeft:v.v2(0,0),topRight:v.v2(0,0),top:v.v2(0,0),bottomLeft:v.v2(0,0),bottomRight:v.v2(0,0),bottom:v.v2(0,0),center:v.v2(0,0),left:v.v2(0,0),right:v.v2(0,0),width:0,height:0,init:function(t){var e=this.width=t.width,i=this.height=t.height,n=t.x,r=t.y,s=r+i,o=n+e;this.topLeft.x=n,this.topLeft.y=s,this.topRight.x=o,this.topRight.y=s,this.top.x=n+e/2,this.top.y=s,this.bottomLeft.x=n,this.bottomLeft.y=r,this.bottomRight.x=o,this.bottomRight.y=r,this.bottom.x=n+e/2,this.bottom.y=r,this.center.x=n+e/2,this.center.y=r+i/2,this.left.x=n,this.left.y=r+i/2,this.right.x=o,this.right.y=r+i/2}});v.visibleRect=Rl;var Il=String.prototype.charCodeAt;function Bl(t){return this[t]}function Dl(t,e){for(var i=t.length,n=e^i,r=0,s="string"==typeof t?Il:Bl;i>=4;){var o=255&s.call(t,r)|(255&s.call(t,++r))<<8|(255&s.call(t,++r))<<16|(255&s.call(t,++r))<<24;o=1540483477*(65535&o)+((1540483477*(o>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^(o=1540483477*(65535&(o^=o>>>24))+((1540483477*(o>>>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 Pl(){}v.easing=ja,Pl.prototype.once=function(t,e,i){return this.on(t,e,i,!0)},Pl.prototype.targetOff=function(t){this.removeAll(t)},t("cC",Object.freeze({__proto__:null,syncNodeValues:function(t){var e=t._lpos;t.setPositionForJS(e.x,e.y,e.z);var i=t._lscale;t.setScaleForJS(i.x,i.y,i.z);var n=t._lrot;t.setRotationForJS(n.x,n.y,n.z,n.w);var r=t._euler;t.setRotationFromEulerForJS(r.x,r.y,r.z)},updateChildrenForDeserialize:function t(e){if(e){var i=e.children;if(i){var n=i.length;if(n){e._setChildren(i);for(var r=0;r0&&0==(t&t-1)}function V_(t,e,i,n){if(!M_[t].isCompressed)return e*i*n*M_[t].size;switch(t){case Hl.BC1:case Hl.BC1_ALPHA:case Hl.BC1_SRGB:case Hl.BC1_SRGB_ALPHA:return Math.ceil(e/4)*Math.ceil(i/4)*8*n;case Hl.BC2:case Hl.BC2_SRGB:case Hl.BC3:case Hl.BC3_SRGB:case Hl.BC4:case Hl.BC4_SNORM:case Hl.BC6H_SF16:case Hl.BC6H_UF16:case Hl.BC7:case Hl.BC7_SRGB:return Math.ceil(e/4)*Math.ceil(i/4)*16*n;case Hl.BC5:case Hl.BC5_SNORM:return Math.ceil(e/4)*Math.ceil(i/4)*32*n;case Hl.ETC_RGB8:case Hl.ETC2_RGB8:case Hl.ETC2_SRGB8:case Hl.ETC2_RGB8_A1:case Hl.EAC_R11:case Hl.EAC_R11SN:return Math.ceil(e/4)*Math.ceil(i/4)*8*n;case Hl.ETC2_RGBA8:case Hl.ETC2_SRGB8_A1:case Hl.EAC_RG11:case Hl.EAC_RG11SN:return Math.ceil(e/4)*Math.ceil(i/4)*16*n;case Hl.PVRTC_RGB2:case Hl.PVRTC_RGBA2:case Hl.PVRTC2_2BPP:return Math.ceil(e/8)*Math.ceil(i/4)*8*n;case Hl.PVRTC_RGB4:case Hl.PVRTC_RGBA4:case Hl.PVRTC2_4BPP:return Math.ceil(e/4)*Math.ceil(i/4)*8*n;case Hl.ASTC_RGBA_4X4:case Hl.ASTC_SRGBA_4X4:return Math.ceil(e/4)*Math.ceil(i/4)*16*n;case Hl.ASTC_RGBA_5X4:case Hl.ASTC_SRGBA_5X4:return Math.ceil(e/5)*Math.ceil(i/4)*16*n;case Hl.ASTC_RGBA_5X5:case Hl.ASTC_SRGBA_5X5:return Math.ceil(e/5)*Math.ceil(i/5)*16*n;case Hl.ASTC_RGBA_6X5:case Hl.ASTC_SRGBA_6X5:return Math.ceil(e/6)*Math.ceil(i/5)*16*n;case Hl.ASTC_RGBA_6X6:case Hl.ASTC_SRGBA_6X6:return Math.ceil(e/6)*Math.ceil(i/6)*16*n;case Hl.ASTC_RGBA_8X5:case Hl.ASTC_SRGBA_8X5:return Math.ceil(e/8)*Math.ceil(i/5)*16*n;case Hl.ASTC_RGBA_8X6:case Hl.ASTC_SRGBA_8X6:return Math.ceil(e/8)*Math.ceil(i/6)*16*n;case Hl.ASTC_RGBA_8X8:case Hl.ASTC_SRGBA_8X8:return Math.ceil(e/8)*Math.ceil(i/8)*16*n;case Hl.ASTC_RGBA_10X5:case Hl.ASTC_SRGBA_10X5:return Math.ceil(e/10)*Math.ceil(i/5)*16*n;case Hl.ASTC_RGBA_10X6:case Hl.ASTC_SRGBA_10X6:return Math.ceil(e/10)*Math.ceil(i/6)*16*n;case Hl.ASTC_RGBA_10X8:case Hl.ASTC_SRGBA_10X8:return Math.ceil(e/10)*Math.ceil(i/8)*16*n;case Hl.ASTC_RGBA_10X10:case Hl.ASTC_SRGBA_10X10:return Math.ceil(e/10)*Math.ceil(i/10)*16*n;case Hl.ASTC_RGBA_12X10:case Hl.ASTC_SRGBA_12X10:return Math.ceil(e/12)*Math.ceil(i/10)*16*n;case Hl.ASTC_RGBA_12X12:case Hl.ASTC_SRGBA_12X12:return Math.ceil(e/12)*Math.ceil(i/12)*16*n;default:return 0}}function G_(t,e,i,n,r){for(var s=0,o=0;o>1,1),i=Math.max(i>>1,1);return s}var U_=[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 z_(t){return U_[t]||0}function H_(t){if(t.isCompressed)return Uint8Array;var e=t.size/t.count;switch(t.type){case Wl.UNORM:case Wl.UINT:switch(e){case 1:return Uint8Array;case 2:return Uint16Array;case 4:return Uint32Array;default:return Uint8Array}case Wl.SNORM:case Wl.INT:switch(e){case 1:return Int8Array;case 2:return Int16Array;case 4:return Int32Array;default:return Int8Array}case Wl.FLOAT:switch(e){case 2:return Uint16Array;case 4:default:return Float32Array}}return Float32Array}function W_(t){switch(t){case Hl.BC1:case Hl.BC1_ALPHA:case Hl.BC1_SRGB:case Hl.BC1_SRGB_ALPHA:case Hl.BC2:case Hl.BC2_SRGB:case Hl.BC3:case Hl.BC3_SRGB:case Hl.BC4:case Hl.BC4_SNORM:case Hl.BC6H_SF16:case Hl.BC6H_UF16:case Hl.BC7:case Hl.BC7_SRGB:case Hl.BC5:case Hl.BC5_SNORM:case Hl.ETC_RGB8:case Hl.ETC2_RGB8:case Hl.ETC2_SRGB8:case Hl.ETC2_RGB8_A1:case Hl.EAC_R11:case Hl.EAC_R11SN:case Hl.ETC2_RGBA8:case Hl.ETC2_SRGB8_A1:case Hl.EAC_RG11:case Hl.EAC_RG11SN:return{width:4,height:4};case Hl.PVRTC_RGB2:case Hl.PVRTC_RGBA2:case Hl.PVRTC2_2BPP:return{width:8,height:4};case Hl.PVRTC_RGB4:case Hl.PVRTC_RGBA4:case Hl.PVRTC2_4BPP:return{width:4,height:4};case Hl.ASTC_RGBA_4X4:case Hl.ASTC_SRGBA_4X4:return{width:4,height:4};case Hl.ASTC_RGBA_5X4:case Hl.ASTC_SRGBA_5X4:return{width:5,height:4};case Hl.ASTC_RGBA_5X5:case Hl.ASTC_SRGBA_5X5:return{width:5,height:5};case Hl.ASTC_RGBA_6X5:case Hl.ASTC_SRGBA_6X5:return{width:6,height:5};case Hl.ASTC_RGBA_6X6:case Hl.ASTC_SRGBA_6X6:return{width:6,height:6};case Hl.ASTC_RGBA_8X5:case Hl.ASTC_SRGBA_8X5:return{width:8,height:5};case Hl.ASTC_RGBA_8X6:case Hl.ASTC_SRGBA_8X6:return{width:8,height:6};case Hl.ASTC_RGBA_8X8:case Hl.ASTC_SRGBA_8X8:return{width:8,height:8};case Hl.ASTC_RGBA_10X5:case Hl.ASTC_SRGBA_10X5:return{width:10,height:5};case Hl.ASTC_RGBA_10X6:case Hl.ASTC_SRGBA_10X6:return{width:10,height:6};case Hl.ASTC_RGBA_10X8:case Hl.ASTC_SRGBA_10X8:return{width:10,height:8};case Hl.ASTC_RGBA_10X10:case Hl.ASTC_SRGBA_10X10:return{width:10,height:10};case Hl.ASTC_RGBA_12X10:case Hl.ASTC_SRGBA_12X10:return{width:12,height:10};case Hl.ASTC_RGBA_12X12:case Hl.ASTC_SRGBA_12X12:return{width:12,height:12};default:return{width:1,height:1}}}function j_(t,e){return Math.ceil(t/e)*e}var X_=Object.freeze({__proto__:null,get ObjectType(){return kl},get Status(){return Vl},get API(){return Gl},get SurfaceTransform(){return Ul},get Feature(){return zl},get Format(){return Hl},get FormatType(){return Wl},get Type(){return jl},get BufferUsageBit(){return Xl},get BufferFlagBit(){return ql},get MemoryAccessBit(){return Yl},get MemoryUsageBit(){return Kl},get TextureType(){return Jl},get TextureUsageBit(){return Ql},get TextureFlagBit(){return Zl},get FormatFeatureBit(){return $l},get SampleCount(){return tc},get VsyncMode(){return ec},get Filter(){return ic},get Address(){return nc},get ComparisonFunc(){return rc},get StencilOp(){return sc},get BlendFactor(){return oc},get BlendOp(){return ac},get ColorMask(){return hc},get ShaderStageFlagBit(){return uc},get LoadOp(){return lc},get StoreOp(){return cc},get AccessFlagBit(){return _c},get ResolveMode(){return dc},get PipelineBindPoint(){return fc},get PrimitiveMode(){return pc},get PolygonMode(){return mc},get ShadeModel(){return gc},get CullMode(){return yc},get DynamicStateFlagBit(){return vc},get StencilFace(){return Sc},get DescriptorType(){return Tc},get QueueType(){return Ac},get QueryType(){return bc},get CommandBufferType(){return Ec},get ClearFlagBit(){return Cc},get BarrierType(){return wc},get PassType(){return xc},Size:Bc,DeviceCaps:Dc,DeviceOptions:Pc,Offset:Oc,Rect:Mc,Extent:Lc,TextureSubresLayers:Nc,TextureSubresRange:Fc,TextureCopy:kc,TextureBlit:Vc,BufferTextureCopy:Gc,Viewport:Uc,Color:zc,BindingMappingInfo:Hc,SwapchainInfo:Wc,DeviceInfo:jc,BufferInfo:Xc,BufferViewInfo:qc,DrawInfo:Yc,DispatchInfo:Kc,IndirectBuffer:Jc,TextureInfo:Qc,TextureViewInfo:Zc,SamplerInfo:$c,Uniform:t_,UniformBlock:e_,UniformSamplerTexture:i_,UniformSampler:n_,UniformTexture:r_,UniformStorageImage:s_,UniformStorageBuffer:o_,UniformInputAttachment:a_,ShaderStage:h_,Attribute:u_,ShaderInfo:l_,InputAssemblerInfo:c_,ColorAttachment:__,DepthStencilAttachment:d_,SubpassInfo:f_,SubpassDependency:p_,RenderPassInfo:m_,GeneralBarrierInfo:g_,TextureBarrierInfo:y_,BufferBarrierInfo:v_,FramebufferInfo:S_,DescriptorSetLayoutBinding:T_,DescriptorSetLayoutInfo:A_,DescriptorSetInfo:b_,PipelineLayoutInfo:E_,InputState:C_,CommandBufferInfo:w_,QueueInfo:x_,QueryPoolInfo:R_,FormatInfo:I_,MemoryStatus:B_,DynamicStencilStates:D_,DynamicStates:P_,GFXObject:O_,get AttributeName(){return Ic},FormatInfos:M_,DESCRIPTOR_BUFFER_TYPE:L_,DESCRIPTOR_SAMPLER_TYPE:N_,DESCRIPTOR_DYNAMIC_TYPE:F_,DRAW_INFO_SIZE:28,IsPowerOf2:k_,FormatSize:V_,FormatSurfaceSize:G_,GetTypeSize:z_,getTypedArrayConstructor:H_,formatAlignment:W_,alignTo:j_}),q_=function(t){function e(){var e;return(e=t.call(this,kl.BUFFER)||this)._usage=Xl.NONE,e._memUsage=Kl.NONE,e._size=0,e._stride=1,e._count=0,e._flags=ql.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}(O_),Y_=function(t){function e(){var e;return(e=t.call(this,kl.COMMAND_BUFFER)||this)._queue=null,e._type=Ec.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}(O_),K_=function(){function t(){this._gfxAPI=Gl.UNKNOWN,this._renderer="",this._vendor="",this._features=new Array(zl.COUNT),this._formatFeatures=new Array(Hl.COUNT),this._queue=null,this._cmdBuff=null,this._numDrawCalls=0,this._numInstances=0,this._numTris=0,this._memoryStatus=new B_,this._caps=new Dc,this._bindingMappingInfo=new Hc,this._samplers=new Map,this._generalBarrierss=new Map,this._textureBarriers=new Map,this._bufferBarriers=new Map}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 tc.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:"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}();K_.canvas=void 0;var J_=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 Qc(Jl.TEX2D,Ql.STORAGE|Ql.SAMPLED,Hl.RGBA8,2,2,Zl.NONE));var i=new Gc(0,0,0,new Oc(0,0,0),new Lc(2,2,1));t.copyBuffersToTexture([e],this._texture2D,[i])}if(t.capabilities.maxTextureSize>=2){this._textureCube=t.createTexture(new Qc(Jl.CUBE,Ql.STORAGE|Ql.SAMPLED,Hl.RGBA8,2,2,Zl.NONE,6));var n=new Gc(0,0,0,new Oc(0,0,0),new Lc(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 Qc(Jl.TEX3D,Ql.STORAGE|Ql.SAMPLED,Hl.RGBA8,2,2,Zl.NONE,1,1,tc.X1,2));var r=new Gc(0,0,0,new Oc(0,0,0),new Lc(2,2,2),new Nc(0,0,1));t.copyBuffersToTexture([e],this._texture3D,[r])}if(t.capabilities.maxArrayTextureLayers>=2){this._texture2DArray=t.createTexture(new Qc(Jl.TEX2D_ARRAY,Ql.STORAGE|Ql.SAMPLED,Hl.RGBA8,2,2,Zl.NONE,2));var s=new Gc(0,0,0,new Oc(0,0,0),new Lc(2,2,1),new Nc(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 Jl.TEX2D:return this._texture2D;case Jl.TEX3D:return this._texture3D;case Jl.CUBE:return this._textureCube;case Jl.TEX2D_ARRAY:return this._texture2DArray;default:return null}},t}(),Q_=function(t){function e(){var e;return(e=t.call(this,kl.SWAPCHAIN)||this)._transform=Ul.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}(O_),Z_=function(t){function e(){var e;return(e=t.call(this,kl.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}}]),e}(O_),$_=function(t){function e(){var e;return(e=t.call(this,kl.INPUT_ASSEMBLER)||this)._attributes=[],e._attributesHash=0,e._vertexBuffers=[],e._indexBuffer=null,e._indirectBuffer=null,e._drawInfo=new Yc,e}s(e,t);var i=e.prototype;return i.getVertexBuffer=function(t){return void 0===t&&(t=0),t=0){var a=this._colorInfos[i.depthStencil];t+="ds,"+a.format+","+a.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}(O_),_d=function(t){function e(){var e;return(e=t.call(this,kl.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}(O_),dd=function(t){function e(){var e;return(e=t.call(this,kl.TEXTURE)||this)._info=new Qc,e._viewInfo=new Zc,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}(O_),fd=function(t){function e(e,i){var n;return(n=t.call(this,kl.GLOBAL_BARRIER)||this)._info=new g_,n._hash=0,n._info.copy(e),n._hash=i,n}return s(e,t),e.computeHash=function(t){return Dl(t.prevAccesses+" "+t.nextAccesses+" "+t.type,666)},n(e,[{key:"info",get:function(){return this._info}},{key:"hash",get:function(){return this._hash}}]),e}(O_),pd=function(t){function e(e,i){var n;return(n=t.call(this,kl.TEXTURE_BARRIER)||this)._info=new y_,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,Dl(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}(O_),md=function(t){function e(e,i){var n;return(n=t.call(this,kl.BUFFER_BARRIER)||this)._info=new v_,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,Dl(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}(O_),gd={Device:K_,Swapchain:Q_,Buffer:q_,Texture:dd,Sampler:cd,Shader:_d,InputAssembler:$_,RenderPass:ld,Framebuffer:Z_,DescriptorSet:td,DescriptorSetLayout:ed,PipelineLayout:id,PipelineState:hd,CommandBuffer:Y_,Queue:ud,GeneralBarrier:fd,TextureBarrier:pd,BufferBarrier:md,RasterizerState:nd,BlendState:od,BlendTarget:sd,DepthStencilState:rd,PipelineStateInfo:ad};Object.assign(gd,X_),v.gfx=gd;var yd,vd,Sd={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 Td in Sd){var Ad=Sd[Td];!0===Ad?Ad=Td.slice(3):!1===Ad&&(Ad=Td),nt(v,"cc",[{name:Td,newName:Ad,target:v.gfx,targetName:"cc.gfx"}])}rt(v,"cc",[{name:"GFX_MAX_VERTEX_ATTRIBUTES"},{name:"GFX_MAX_TEXTURE_UNITS"},{name:"GFX_MAX_ATTACHMENTS"},{name:"GFX_MAX_BUFFER_BINDINGS"},{name:"GFXTextureLayout"}]),rt(zl,"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;"}]),rt(__.prototype,"ColorAttachment",[{name:"beginAccesses",suggest:"Please assign to ColorAttachment.barrier instead"},{name:"endAccesses",suggest:"Please assign to ColorAttachment.barrier instead"}]),rt(d_.prototype,"DepthStencilAttachment",[{name:"beginAccesses",suggest:"Please assign to DepthStencilAttachment.barrier instead"},{name:"endAccesses",suggest:"Please assign to DepthStencilAttachment.barrier instead"}]),nt(K_.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"}(yd||(yd={})),function(t){t[t.UNKNOWN=-1]="UNKNOWN",t[t.CANVAS=0]="CANVAS",t[t.WEBGL=1]="WEBGL",t[t.OPENGL=2]="OPENGL",t[t.HEADLESS=3]="HEADLESS"}(vd||(vd={}));var bd=function(){function t(){this.initialized=!1,this._gfxDevice=void 0,this._canvas=null,this._swapchain=void 0,this._renderType=vd.UNKNOWN}var e=t.prototype;return e.init=function(t,e){if(!this.initialized){var i=Ee.querySettings(be.Category.RENDERING,"renderMode");if(this._canvas=t,this._renderType=this._determineRenderType(i),this._renderType===vd.WEBGL){var n=new jc(e),r=!!globalThis.WebGL2RenderingContext;globalThis.navigator.userAgent.toLowerCase(),xl.browserType===Ju.UC&&(r=!1);var s=[];r&&v.WebGL2Device&&s.push(v.WebGL2Device),v.WebGLDevice&&s.push(v.WebGLDevice),v.EmptyDevice&&s.push(v.EmptyDevice),K_.canvas=t;for(var o=0;ovd.HEADLESS||tthis.pipes.length?(Y(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],Wd[jd[n++]]=zd[(3&r)<<2|s>>4],Wd[jd[n++]]=zd[15&s]}return t.replace(e,Wd.join(""))}var qd=/.*[/\\][0-9a-fA-F]{2}[/\\]([0-9a-fA-F-@]{8,}).*/;function Yd(t){var e=qd.exec(t);return e?e[1]:""}function Kd(t,e){(e=e||Object.create(null)).__isNative__=e.isNative,e.nativeExt&&(e.ext=e.nativeExt);var i=Md.find((function(e){return!!e.getAssetInfo(t)}));return i&&(e.bundle=i.name),Zd(t,e)}function Jd(t){return!!t&&(t instanceof v.SceneAsset||t instanceof v.Scene)}function Qd(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 Zd(t,e){var i=Ud.create({input:t,options:e}),n=[];try{for(var r,s=d(Fd.sync(i));!(r=s()).done;){var o=r.value,a=o.url;o.recycle(),n.push(a)}}catch(t){for(var h,u=d(i.output);!(h=u()).done;)h.value.recycle();V(t.message,t.stack)}return i.recycle(),n.length>1?n:n[0]}var $d,tf,ef,nf=Object.freeze({__proto__:null,getUuidFromURL:Yd,getUrlWithUuid:Kd,isScene:Jd,normalize:Qd,transform:Zd,decodeUuid:Xd}),rf=io,sf=Qs,of=t("e8",qs("cc.Asset")((tf=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r0&&this._ref--,t&&v.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 U(tt(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=Kd(this._uuid,{nativeExt:t,isNative:!0}):this._nativeUrl=Kd(this._uuid,{__nativeName__:t,nativeExt:hl(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}(Yu(Ho)),ef=ks(tf.prototype,"_native",[rf],(function(){return""})),p(tf.prototype,"_nativeAsset",[sf],Object.getOwnPropertyDescriptor(tf.prototype,"_nativeAsset"),tf.prototype),$d=tf))||$d);of.prototype.createNode=null,v.Asset=of;var af,hf,uf,lf,cf,_f;!function(t){t[t.RGB565=Hl.R5G6B5]="RGB565",t[t.RGB5A1=Hl.RGB5A1]="RGB5A1",t[t.RGBA4444=Hl.RGBA4]="RGBA4444",t[t.RGB888=Hl.RGB8]="RGB888",t[t.RGB32F=Hl.RGB32F]="RGB32F",t[t.RGBA8888=Hl.RGBA8]="RGBA8888",t[t.RGBA32F=Hl.RGBA32F]="RGBA32F",t[t.A8=Hl.A8]="A8",t[t.I8=Hl.L8]="I8",t[t.AI8=Hl.LA8]="AI8",t[t.RGB_PVRTC_2BPPV1=Hl.PVRTC_RGB2]="RGB_PVRTC_2BPPV1",t[t.RGBA_PVRTC_2BPPV1=Hl.PVRTC_RGBA2]="RGBA_PVRTC_2BPPV1",t[t.RGB_A_PVRTC_2BPPV1=1024]="RGB_A_PVRTC_2BPPV1",t[t.RGB_PVRTC_4BPPV1=Hl.PVRTC_RGB4]="RGB_PVRTC_4BPPV1",t[t.RGBA_PVRTC_4BPPV1=Hl.PVRTC_RGBA4]="RGBA_PVRTC_4BPPV1",t[t.RGB_A_PVRTC_4BPPV1=1025]="RGB_A_PVRTC_4BPPV1",t[t.RGB_ETC1=Hl.ETC_RGB8]="RGB_ETC1",t[t.RGBA_ETC1=1026]="RGBA_ETC1",t[t.RGB_ETC2=Hl.ETC2_RGB8]="RGB_ETC2",t[t.RGBA_ETC2=Hl.ETC2_RGBA8]="RGBA_ETC2",t[t.RGBA_ASTC_4x4=Hl.ASTC_RGBA_4X4]="RGBA_ASTC_4x4",t[t.RGBA_ASTC_5x4=Hl.ASTC_RGBA_5X4]="RGBA_ASTC_5x4",t[t.RGBA_ASTC_5x5=Hl.ASTC_RGBA_5X5]="RGBA_ASTC_5x5",t[t.RGBA_ASTC_6x5=Hl.ASTC_RGBA_6X5]="RGBA_ASTC_6x5",t[t.RGBA_ASTC_6x6=Hl.ASTC_RGBA_6X6]="RGBA_ASTC_6x6",t[t.RGBA_ASTC_8x5=Hl.ASTC_RGBA_8X5]="RGBA_ASTC_8x5",t[t.RGBA_ASTC_8x6=Hl.ASTC_RGBA_8X6]="RGBA_ASTC_8x6",t[t.RGBA_ASTC_8x8=Hl.ASTC_RGBA_8X8]="RGBA_ASTC_8x8",t[t.RGBA_ASTC_10x5=Hl.ASTC_RGBA_10X5]="RGBA_ASTC_10x5",t[t.RGBA_ASTC_10x6=Hl.ASTC_RGBA_10X6]="RGBA_ASTC_10x6",t[t.RGBA_ASTC_10x8=Hl.ASTC_RGBA_10X8]="RGBA_ASTC_10x8",t[t.RGBA_ASTC_10x10=Hl.ASTC_RGBA_10X10]="RGBA_ASTC_10x10",t[t.RGBA_ASTC_12x10=Hl.ASTC_RGBA_12X10]="RGBA_ASTC_12x10",t[t.RGBA_ASTC_12x12=Hl.ASTC_RGBA_12X12]="RGBA_ASTC_12x12"}(af||(af={})),function(t){t[t.REPEAT=nc.WRAP]="REPEAT",t[t.CLAMP_TO_EDGE=nc.CLAMP]="CLAMP_TO_EDGE",t[t.MIRRORED_REPEAT=nc.MIRROR]="MIRRORED_REPEAT",t[t.CLAMP_TO_BORDER=nc.BORDER]="CLAMP_TO_BORDER"}(hf||(hf={})),function(t){t[t.NONE=ic.NONE]="NONE",t[t.LINEAR=ic.LINEAR]="LINEAR",t[t.NEAREST=ic.POINT]="NEAREST"}(uf||(uf={}));var df=1346981187,ff=ge({PVR:0,PKM:1,ASTC:2});function pf(t,e){return t[e]<<8|t[e+1]}function mf(t){return!!(xl.hasFeature(xl.Feature.IMAGE_BITMAP)&&t instanceof ImageBitmap)}var gf,yf,vf,Sf,Tf,Af,bf,Ef,Cf,wf,xf,Rf=t("ee",qs("cc.ImageAsset")(((_f=function(t){s(i,t),i.mergeCompressedTextureMips=function(t){var e=new Uint8Array(0),i=null;try{for(var n,r=8+4*t.length,s=0,o=d(t);!(n=o()).done;)s+=n.value.byteLength;s+=r,e=new Uint8Array(s);var a=new DataView(e.buffer,e.byteOffset,e.byteLength);a.setUint32(0,df,!0),a.setUint32(4,t.length,!0);for(var h=r,u=0;u0){var u=new Uint8Array(s,a,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,a);r.width=e>0?r.width:o[7],r.height=e>0?r.height:o[6]}else{if(559044176!==o[11])throw new Error("Invalid magic number in PVR header");var c=i+o[0],_=n-o.byteLength;if(n>0){var d=new Uint8Array(s,c,_),f=new Uint8Array(r._data.byteLength+d.byteLength);f.set(r._data),f.set(d,r._data.byteLength),r._data=f,r.mipmapLevelDataSize[e]=_}else r._data=new Uint8Array(s,c);r.width=e>0?r.width:o[1],r.height=e>0?r.height:o[2]}},i.parsePKMTexture=function(t,e,i,n,r){var s=t instanceof ArrayBuffer?t:t.buffer,o=new Uint8Array(s,i,16),a=pf(o,6);if(0!==a&&1!==a&&3!==a)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:pf(o,12),r.height=e>0?r.height:pf(o,14)},i.parseASTCTexture=function(t,e,i,n,r){var s=t instanceof ArrayBuffer?t:t.buffer,o=new Uint8Array(s,i,16);if(1554098963!==o[0]+(o[1]<<8)+(o[2]<<16)+(o[3]<<24))throw new Error("Invalid magic number in ASTC header");var a=o[4],h=o[5],u=o[6];if((a<3||a>6||h<3||h>6||u<3||u>6)&&(a<4||7===a||9===a||11===a||a>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?af.RGBA_ASTC_4x4:5===t?4===e?af.RGBA_ASTC_5x4:af.RGBA_ASTC_5x5:6===t?5===e?af.RGBA_ASTC_6x5:af.RGBA_ASTC_6x6:8===t?5===e?af.RGBA_ASTC_8x5:6===e?af.RGBA_ASTC_8x6:af.RGBA_ASTC_8x8:10===t?5===e?af.RGBA_ASTC_10x5:6===e?af.RGBA_ASTC_10x6:8===e?af.RGBA_ASTC_10x8:af.RGBA_ASTC_10x10:10===e?af.RGBA_ASTC_12x10:af.RGBA_ASTC_12x12}(a,h),c=i+16,_=n-16;if(n>0){var d=new Uint8Array(s,c,_),f=new Uint8Array(r._data.byteLength+d.byteLength);f.set(r._data),f.set(d,r._data.byteLength),r._data=f,r.mipmapLevelDataSize[e]=_}else r._data=new Uint8Array(s,c);r.width=e>0?r.width:o[7]+(o[8]<<8)+(o[9]<<16),r.height=e>0?r.height:o[10]+(o[11]<<8)+(o[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=af.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,o=this.height,a=this.width,h=d(n);!(e=h()).done;){var u=e.value,l=new i({_data:new Uint8Array(r.buffer,s,u),_compressed:!0,width:a,height:o,format:this.format,mipmapLevelDataSize:[]});s+=u,l._uuid=""+this._uuid,a=Math.max(a>>1,1),o=Math.max(o>>1,1),t.push(l)}else t.push(this);return t},e.reset=function(t){mf(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(mf(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=Ed.gfxDevice,s=e.split("_"),o=Number.MAX_VALUE,a=this._format,h="",u=Ce.SUPPORT_TEXTURE_FORMATS,l=d(s);!(n=l()).done;){var c=n.value.split("@"),_=parseInt(c[0],void 0),f=i.extnames[_]||c[0],p=u.indexOf(f);if(-1!==p&&p=af.RGB_ETC1&&this._format<=af.RGBA_ASTC_12x12||this._format>=af.RGB_A_PVRTC_2BPPV1&&this._format<=af.RGBA_ETC1}},{key:"mipmapLevelDataSize",get:function(){return this._nativeData.mipmapLevelDataSize}},{key:"url",get:function(){return this.nativeUrl}}]),i}(of)).extnames=[".png",".jpg",".jpeg",".bmp",".webp",".pvr",".pkm",".astc"],_f._sharedPlaceHolderCanvas=null,p((cf=_f).prototype,"_nativeAsset",[Ro],Object.getOwnPropertyDescriptor(cf.prototype,"_nativeAsset"),cf.prototype),lf=cf))||lf);v.ImageAsset=Rf,Se(Hl);var If,Bf,Df,Pf=new gt("Tex"),Of=qs("cc.TextureBase")(((xf=function(t){function e(){var e;return(e=t.call(this)||this)._format=vf&&vf(),e._minFilter=Sf&&Sf(),e._magFilter=Tf&&Tf(),e._mipFilter=Af&&Af(),e._wrapS=bf&&bf(),e._wrapT=Ef&&Ef(),e._wrapR=Cf&&Cf(),e._anisotropy=wf&&wf(),e._width=1,e._height=1,e._id=void 0,e._samplerInfo=new $c,e._gfxSampler=null,e._gfxDevice=null,e._textureHash=0,e._id=Pf.getNewId(),e._gfxDevice=e._getGFXDevice(),e._textureHash=Dl(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=v.director.root)&&void 0!==e&&e.batcher2D&&v.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):J(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 Ed.gfxDevice},i._getGFXFormat=function(){return this._getGFXPixelFormat(this._format)},i._setGFXFormat=function(t){this._format=void 0===t?af.RGBA8888:t},i._getGFXPixelFormat=function(t){return t===af.RGBA_ETC1?t=af.RGB_ETC1:t===af.RGB_A_PVRTC_4BPPV1?t=af.RGB_PVRTC_4BPPV1:t===af.RGB_A_PVRTC_2BPPV1&&(t=af.RGB_PVRTC_2BPPV1),t},n(e,[{key:"isCompressed",get:function(){return this._format>=af.RGB_ETC1&&this._format<=af.RGBA_ASTC_12x12||this._format>=af.RGB_A_PVRTC_2BPPV1&&this._format<=af.RGBA_ETC1}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}}]),e}(of)).PixelFormat=af,xf.WrapMode=hf,xf.Filter=uf,vf=ks((yf=xf).prototype,"_format",[io],(function(){return af.RGBA8888})),Sf=ks(yf.prototype,"_minFilter",[io],(function(){return uf.LINEAR})),Tf=ks(yf.prototype,"_magFilter",[io],(function(){return uf.LINEAR})),Af=ks(yf.prototype,"_mipFilter",[io],(function(){return uf.NONE})),bf=ks(yf.prototype,"_wrapS",[io],(function(){return hf.REPEAT})),Ef=ks(yf.prototype,"_wrapT",[io],(function(){return hf.REPEAT})),Cf=ks(yf.prototype,"_wrapR",[io],(function(){return hf.REPEAT})),wf=ks(yf.prototype,"_anisotropy",[io],(function(){return 0})),gf=yf))||gf;v.TextureBase=Of;var Mf=t("ek",qs("cc.Script")(If=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e}(of))||If);v._Script=Mf;var Lf=t("el",qs("cc.JavaScript")(Bf=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e}(Mf))||Bf);v._JavaScript=Lf;var Nf,Ff,kf,Vf,Gf,Uf,zf,Hf=t("em",qs("cc.TypeScript")(Df=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e}(Mf))||Df);v._TypeScript=Hf;var Wf,jf,Xf,qf,Yf,Kf,Jf,Qf,Zf,$f,tp,ep=t("dD",qs("cc.ClickEvent")((Ff=function(){function t(){this.target=kf&&kf(),this.component=Vf&&Vf(),this._componentId=Gf&&Gf(),this.handler=Uf&&Uf(),this.customEventData=zf&&zf()}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)?v.macro.REPEAT_FOREVER:i,n=n||0;var r=v.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&&v.director.getScheduler().unschedule(t,this)},i.unscheduleAllCallbacks=function(){v.director.getScheduler().unscheduleAllForTarget(this)},n(e,[{key:"name",get:function(){if(this._name)return this._name;var t=Bt(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=v.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&np}},{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}(Ho)).EventHandler=ep,Qf._executionOrder=0,Qf._requireComponent=null,Qf.system=null,p((qf=Qf).prototype,"__scriptAsset",[jf],Object.getOwnPropertyDescriptor(qf.prototype,"__scriptAsset"),qf.prototype),Yf=ks(qf.prototype,"node",[io],(function(){return null})),Kf=ks(qf.prototype,"_enabled",[io],(function(){return!0})),Jf=ks(qf.prototype,"__prefab",[io],(function(){return null})),Xf=qf))||Xf));Ct(rp,"_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)})),v.Component=rp;var sp=t("d$",qs("cc.MissingScript")(($f=function(t){function e(){var e;return(e=t.call(this)||this)._$erialized=tp&&tp(),e}return s(e,t),e.safeFindClass=function(t){var e=te(t);if(e)return e;v.deserialize.reportMissingClass(t)},e.prototype.onLoad=function(){Y(4600,this.node.name)},e}(rp),tp=ks($f.prototype,"_$erialized",[io,ro],(function(){return null})),Zf=$f))||Zf);v._MissingScript=sp;try{var op=sp.__values__;0!==op.length&&"_$erialized"===op[op.length-1]||(V("The '_$erialized' prop in MissingScript is missing. Please contact jare."),V(" Error props: ['"+op+"']"))}catch($n){V("Error when checking MissingScript 5, "+$n)}var ap=function(){function t(t,e){this._document=void 0,this._chunks=void 0,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 hp(t){var e=t;return{chunks:e.chunks,document:e.document}}function up(t){if(t.length<16)throw new lp(tt(13102));var e=new DataView(t.buffer,t.byteOffset,t.byteLength);if(1313817411!==e.getUint32(0,!0))throw new lp(tt(13100));var i=e.getUint32(4,!0);if(1!==i)throw new lp(tt(13101,i));if(e.getUint32(8,!0)!==e.byteLength)throw new lp(tt(13102));var n=12,r=e.getUint32(n,!0);n+=4;var s=new Uint8Array(e.buffer,n+e.byteOffset,r);n+=r;var o,a=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(tt(13104))}(s);try{o=JSON.parse(a)}catch(t){throw new lp(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}(o);return this._deserializeInto(t,a,o),a},e._deserializeInto=function(t,e,i,n){void 0===n&&(n=!1),n||!e[Qo]?e._deserialize?e._deserialize(t.content,this):v.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=zt(i);r&&n._deserializeInto(t,e,r)}};e[Qo](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=pi.Attr.getClassAttrs(e),n=e.__values__,r=["var prop;"],s=function(t){return we.test(ne(t))}(e),o=0;o=0?e[i]=t[5][n]:t[7][3*~n]=e}function wp(t){return function(e,i,n,r){for(var s=0;s=0){var c=a[u];e[o]=Ep(t,c,l)}else(0,Ip[u=~u])(t,e,o,l)}return r}(s);v.game._isCloning=!1,s[7]&&function(t,e,i){for(var n=t.length-1,r=0,s=3*t[n];r=0?o[i[h]]=a:o[~h]=a}for(;r=0?u[i[c]]=l:u[~c]=l}}(s[7],o,s[2]),function(t){for(var e=t[5],i=t[2],n=t[1],r=t[8],s=t[9],o=t[10],a=0;a=0?i[u]:~u,s[a]=u);var l=o[a];"number"==typeof l&&(o[a]=n[l])}}(s),n=o[a]}else n=function(t,e,i){var n,r=(i=i||{}).classFinder||te,s=i.createAssetRefs||xl.platform===tl.EDITOR_CORE,o=i.customEnv,a=i.ignoreEditorOnly,h=null!==(n=i.reportMissingClass)&&void 0!==n?n:v.deserialize.reportMissingClass;e.init();var u=yp.pool.get(e,r,h,o,a);v.game._isCloning=!0;var l=u.deserialize(t);return v.game._isCloning=!1,yp.pool.put(u),s&&e.assignAssetsBy((function(t,e){return EditorExtends.serialize.asAsset(t,e.type)})),l}(t,e,i);return r&&Ap.pool.put(e),n}Ip[0]=function(t,e,i,n){e[i]=n},Ip[1]=Cp,Ip[2]=wp(Cp),Ip[3]=wp(xp),Ip[4]=Rp,Ip[5]=function(t,e,i,n){var r=n[0],s=e[i];(0,Tp[r])(s,n)},Ip[6]=xp,Ip[7]=function(t,e,i,n){e[i].set(n)},Ip[8]=function(t,e,i,n){var r=n[0],s=new vp[r];(0,Tp[r])(s,n),e[i]=s},Ip[9]=wp(Rp),Ip[10]=function(t,e,i,n){var r=t[3][n[0]];e[i]=Ep(t,r,n[1])},Ip[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,Wp):n.copyTexImagesToTexture([t],this._gfxTexture,Wp)}}},i._assignImage=function(t,e,i){var n=t.data;if(n&&(this.uploadData(n,e,i),this._checkTextureLoaded(),Ce.CLEANUP_IMAGE_CACHE)){var r=Hp.getDeps(this._uuid),s=r.indexOf(t._uuid);-1!==s&&(ae(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){$(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=Zl.NONE;this._mipFilter!==uf.NONE&&function(t,e,i){return!(t.gfxAPI===Gl.WEBGL)||jp(e)&&jp(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=Zl.GEN_MIPMAP));var i=this._getGfxTextureCreateInfo({usage:Ql.SAMPLED|Ql.TRANSFER_DST|Ql.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=af.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),!(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+a+2>this._nexty&&(this._nexty=this._y+a+2),this._nexty>this._height)return null;v.internal.dynamicAtlasManager.textureBleeding&&((o<=8||a<=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+=o+2}var h={x:r,y:s,texture:this._texture};return this._innerSpriteFrames.push(t),h},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)console.warn("maximum layers reached.");else{var n=1<19||e<0)console.warn("do not change buildin layers.");else{var i=1<31||e<0?(console.warn("Unable to access unknown layer."),""):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?V("Node %s(%s) has not attached to a scene.",this.name,this.uuid):this._scene=this._parent._scene},e.attr=function(t){Gt(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(om.PARENT_CHANGED,i),i&&!(i._objFlags&Cm)){var r=i._children.indexOf(this);i._children.splice(r,1),i._updateSiblingIndex(),i.emit&&i.emit(om.CHILD_REMOVED,this)}n&&(n._children.push(this),this._siblingIndex=n._children.length-1,n.emit&&n.emit(om.CHILD_ADDED,this)),this._onHierarchyChanged(i)}},e.getChildByUuid=function(t){if(!t)return F("Invalid uuid"),null;for(var e=this._children,i=0,n=e.length;i0?(h=s,r=s._children,o=0,a[n]=r[o],n++):(a[n]=s,n++,u=!0);a.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=Im(t);return e?i._findComponent(this,e):null},e.getComponents=function(t){var e=Im(t),n=[];return e&&i._findComponents(this,e,n),n},e.getComponentInChildren=function(t){var e=Im(t);return e?i._findChildComponent(this._children,e):null},e.getComponentsInChildren=function(t){var e=Im(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=ee(t)))throw v._RF.peek()&&J(3808,t),TypeError(tt(3807,t))}else{if(!t)throw TypeError(tt(3804));e=t}if("function"!=typeof e)throw TypeError(tt(3809));if(!Ht(e,v.Component))throw TypeError(tt(3810));var i=e._requireComponent;if(i)if(Array.isArray(i))for(var n=0;n=0;){if(o=(e=qm[n--]).hasChangedFlags,e.isValid&&(e._transformFlags&o&t)!==t)for(e._transformFlags|=t,e.hasChangedFlags=o|t,s=(i=e._children).length,r=0;r=0;)on.transformInverseRTS(t,t,i._lrot,i._lpos,i._lscale),i=qm[--n];return t},e.setWorldPosition=function(t,e,i){void 0===e||void 0===i?on.copy(this._pos,t):on.set(this._pos,t,e,i);var n=this._parent,r=this._lpos;n?(n.updateWorldTransform(),on.transformMat4(r,this._pos,In.invert(jm,n._mat))):on.copy(r,this._pos),this.invalidateChildren(rm.POSITION),1&this._eventMask&&this.emit(om.TRANSFORM_CHANGED,rm.POSITION)},e.getWorldPosition=function(t){return this.updateWorldTransform(),t?on.copy(t,this._pos):on.copy(new on,this._pos)},e.setWorldRotation=function(t,e,i,n){void 0===e||void 0===i||void 0===n?Sn.copy(this._rot,t):Sn.set(this._rot,t,e,i,n),this._parent?(this._parent.updateWorldTransform(),Sn.multiply(this._lrot,Sn.conjugate(this._lrot,this._parent._rot),this._rot)):Sn.copy(this._lrot,this._rot),this._eulerDirty=!0,this.invalidateChildren(rm.ROTATION),1&this._eventMask&&this.emit(om.TRANSFORM_CHANGED,rm.ROTATION)},e.setWorldRotationFromEuler=function(t,e,i){Sn.fromEuler(this._rot,t,e,i),this._parent?(this._parent.updateWorldTransform(),Sn.multiply(this._lrot,Sn.conjugate(this._lrot,this._parent._rot),this._rot)):Sn.copy(this._lrot,this._rot),this._eulerDirty=!0,this.invalidateChildren(rm.ROTATION),1&this._eventMask&&this.emit(om.TRANSFORM_CHANGED,rm.ROTATION)},e.getWorldRotation=function(t){return this.updateWorldTransform(),t?Sn.copy(t,this._rot):Sn.copy(new Sn,this._rot)},e.setWorldScale=function(t,e,i){var n=this._parent;n&&this.updateWorldTransform(),void 0===e||void 0===i?on.copy(this._scale,t):on.set(this._scale,t,e,i),n?(Bm.x=this._scale.x/on.set(Dm,this._mat.m00,this._mat.m01,this._mat.m02).length(),Bm.y=this._scale.y/on.set(Dm,this._mat.m04,this._mat.m05,this._mat.m06).length(),Bm.z=this._scale.z/on.set(Dm,this._mat.m08,this._mat.m09,this._mat.m10).length(),In.scale(jm,this._mat,Bm),In.multiply(Xm,In.invert(Xm,n._mat),jm),mn.fromQuat(Lm,Sn.conjugate(Mm,this._lrot)),mn.multiplyMat4(Lm,Lm,Xm),this._lscale.x=on.set(Bm,Lm.m00,Lm.m01,Lm.m02).length(),this._lscale.y=on.set(Bm,Lm.m03,Lm.m04,Lm.m05).length(),this._lscale.z=on.set(Bm,Lm.m06,Lm.m07,Lm.m08).length()):on.copy(this._lscale,this._scale),this.invalidateChildren(rm.SCALE),1&this._eventMask&&this.emit(om.TRANSFORM_CHANGED,rm.SCALE)},e.getWorldScale=function(t){return this.updateWorldTransform(),t?on.copy(t,this._scale):on.copy(new on,this._scale)},e.getWorldMatrix=function(t){this.updateWorldTransform();var e=t||new In;return In.copy(e,this._mat)},e.getWorldRS=function(t){this.updateWorldTransform();var e=t||new In;return In.copy(e,this._mat),e.m12=0,e.m13=0,e.m14=0,e},e.getWorldRT=function(t){this.updateWorldTransform();var e=t||new In;return In.fromRT(e,this._rot,this._pos)},e.setRTS=function(t,e,i){var n=0;t&&(n|=rm.ROTATION,void 0!==t.w?(Sn.copy(this._lrot,t),this._eulerDirty=!0):(on.copy(this._euler,t),Sn.fromEuler(this._lrot,t.x,t.y,t.z),this._eulerDirty=!1)),e&&(on.copy(this._lpos,e),n|=rm.POSITION),i&&(on.copy(this._lscale,i),n|=rm.SCALE),n&&(this.invalidateChildren(n),1&this._eventMask&&this.emit(om.TRANSFORM_CHANGED,n))},e.isTransformDirty=function(){return this._transformFlags!==rm.NONE},e.pauseSystemEvents=function(t){this._eventProcessor.setEnabled(!1,t)},e.resumeSystemEvents=function(t){this._eventProcessor.setEnabled(!0,t)},i.resetHasChangedFlags=function(){Km+=1},i.clearNodeArray=function(){i.ClearFrame0},set:function(t){t?this._objFlags|=wm:this._objFlags&=~wm}},{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&&v.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&&(Sn.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._euler.z},set:function(t){on.set(this._euler,0,0,t),Sn.fromAngleZ(this._lrot,t),this._eulerDirty=!1,this.invalidateChildren(rm.ROTATION),1&this._eventMask&&this.emit(om.TRANSFORM_CHANGED,rm.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){In.toRTS(t,this._lrot,this._lpos,this._lscale),this.invalidateChildren(rm.TRS),this._eulerDirty=!0,1&this._eventMask&&this.emit(om.TRANSFORM_CHANGED,rm.TRS)}},{key:"worldMatrix",get:function(){return this.updateWorldTransform(),this._mat}},{key:"forward",get:function(){return on.transformQuat(new on,on.FORWARD,this.worldRotation)},set:function(t){var e=t.length();on.multiplyScalar(Bm,t,-1/e),Sn.fromViewUp(Pm,Bm),this.setWorldRotation(Pm)}},{key:"up",get:function(){return on.transformQuat(new on,on.UP,this.worldRotation)}},{key:"right",get:function(){return on.transformQuat(new on,on.RIGHT,this.worldRotation)}},{key:"mobility",get:function(){return this._mobility},set:function(t){this._mobility=t,this.emit(om.MOBILITY_CHANGED)}},{key:"layer",get:function(){return this._layer},set:function(t){this._layer=t,this._uiProps&&this._uiProps.uiComp&&(this._uiProps.uiComp.setNodeDirty(),this._uiProps.uiComp.markForUpdateRenderData()),this.emit(om.LAYER_CHANGED,this._layer)}},{key:"flagChangedVersion",get:function(){return this._flagChangeVersion}},{key:"hasChangedFlags",get:function(){return this._flagChangeVersion===Km?this._hasChangedFlags:0},set:function(t){this._flagChangeVersion=Km,this._hasChangedFlags=t}}]),i}(Ho)).idGenerator=Rm,bm._stacks=[[]],bm._stackId=0,bm.EventType=om,bm.NodeSpace=nm,bm.TransformDirtyBit=rm,bm.TransformBit=rm,bm.reserveContentsForAllSyncablePrefabTag=Ym,bm.ClearFrame=0,bm.ClearRound=1e3,p((cm=bm).prototype,"_persistNode",[Qs],Object.getOwnPropertyDescriptor(cm.prototype,"_persistNode"),cm.prototype),_m=ks(cm.prototype,"_parent",[io],(function(){return null})),dm=ks(cm.prototype,"_children",[io],(function(){return[]})),fm=ks(cm.prototype,"_active",[io],(function(){return!0})),pm=ks(cm.prototype,"_components",[io],(function(){return[]})),mm=ks(cm.prototype,"_prefab",[io],(function(){return null})),gm=ks(cm.prototype,"_lpos",[io],(function(){return new on})),ym=ks(cm.prototype,"_lrot",[io],(function(){return new Sn})),vm=ks(cm.prototype,"_lscale",[io],(function(){return new on(1,1,1)})),Sm=ks(cm.prototype,"_mobility",[io],(function(){return Em.Static})),Tm=ks(cm.prototype,"_layer",[io],(function(){return im.Enum.DEFAULT})),Am=ks(cm.prototype,"_euler",[io],(function(){return new on})),p(cm.prototype,"eulerAngles",[hm],Object.getOwnPropertyDescriptor(cm.prototype,"eulerAngles"),cm.prototype),p(cm.prototype,"mobility",[um],Object.getOwnPropertyDescriptor(cm.prototype,"mobility"),cm.prototype),lm=cm))||lm));v.Node=Jm,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"}(Hm||(Hm={})),function(t){t[t.NONE=0]="NONE",t[t.AUTO=1]="AUTO",t[t.BAKED_CONVOLUTION_MAP=2]="BAKED_CONVOLUTION_MAP"}(Wm||(Wm={}));var Qm=t("eg",qs("cc.TextureCube")(((zm=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r0){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){Zm(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===Wm.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;Zm(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],o=Object.assign(T.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 a=function(){var t=r[h];Zm(n,(function(n,r){o.clearRect(0,0,i.width,i.height);var s=n.data;o.drawImage(s,0,0);var a=o.getImageData(t.left,t.top,t.width,t.height),h=new Rf({_data:a.data,_compressed:n.isCompressed,width:a.width,height:a.height,format:n.format});e._assignImage(h,t.level,r)}))},h=0;h>>26},ov=function(t){return(t&iv)>>>20},av=function(t){return(t&nv)>>>12},hv=function(t){return 4095&t},uv=function(t,e){return 67108863&t|e<<26&ev},lv=((Xy={})[jl.UNKNOWN]=function(t,e,i){return void 0===i&&(i=0),Y(12010,i)},Xy[jl.INT]=function(t,e,i){return void 0===i&&(i=0),t[i]},Xy[jl.INT2]=function(t,e,i){return void 0===i&&(i=0),Ln.fromArray(e,t,i)},Xy[jl.INT3]=function(t,e,i){return void 0===i&&(i=0),on.fromArray(e,t,i)},Xy[jl.INT4]=function(t,e,i){return void 0===i&&(i=0),tn.fromArray(e,t,i)},Xy[jl.FLOAT]=function(t,e,i){return void 0===i&&(i=0),t[i]},Xy[jl.FLOAT2]=function(t,e,i){return void 0===i&&(i=0),Ln.fromArray(e,t,i)},Xy[jl.FLOAT3]=function(t,e,i){return void 0===i&&(i=0),on.fromArray(e,t,i)},Xy[jl.FLOAT4]=function(t,e,i){return void 0===i&&(i=0),tn.fromArray(e,t,i)},Xy[jl.MAT3]=function(t,e,i){return void 0===i&&(i=0),mn.fromArray(e,t,i)},Xy[jl.MAT4]=function(t,e,i){return void 0===i&&(i=0),In.fromArray(e,t,i)},Xy),cv=((qy={})[jl.UNKNOWN]=function(t,e,i){return void 0===i&&(i=0),Y(12010,i)},qy[jl.INT]=function(t,e,i){return void 0===i&&(i=0),t[i]=e},qy[jl.INT2]=function(t,e,i){return void 0===i&&(i=0),Ln.toArray(t,e,i)},qy[jl.INT3]=function(t,e,i){return void 0===i&&(i=0),on.toArray(t,e,i)},qy[jl.INT4]=function(t,e,i){return void 0===i&&(i=0),tn.toArray(t,e,i)},qy[jl.FLOAT]=function(t,e,i){return void 0===i&&(i=0),t[i]=e},qy[jl.FLOAT2]=function(t,e,i){return void 0===i&&(i=0),Ln.toArray(t,e,i)},qy[jl.FLOAT3]=function(t,e,i){return void 0===i&&(i=0),on.toArray(t,e,i)},qy[jl.FLOAT4]=function(t,e,i){return void 0===i&&(i=0),tn.toArray(t,e,i)},qy[jl.MAT3]=function(t,e,i){return void 0===i&&(i=0),mn.toArray(t,e,i)},qy[jl.MAT4]=function(t,e,i){return void 0===i&&(i=0),In.toArray(t,e,i)},qy),_v=((Yy={})[jl.INT]=function(t){return"number"==typeof t},Yy[jl.FLOAT]=function(t){return"number"==typeof t},Yy[jl.INT2]=function(t){return!!(t instanceof Ln)},Yy[jl.FLOAT2]=function(t){return!!(t instanceof Ln)},Yy[jl.INT3]=function(t){return!!(t instanceof on)},Yy[jl.FLOAT3]=function(t){return!!(t instanceof on)},Yy[jl.INT4]=function(t){return!!(t instanceof tn)},Yy[jl.FLOAT4]=function(t){return!!(t instanceof tn||t instanceof dn||t instanceof Sn)},Yy[jl.MAT3]=function(t){return!!(t instanceof mn)},Yy[jl.MAT4]=function(t){return!!(t instanceof In)},Yy),dv=[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 fv(t){switch(t){case jl.BOOL:case jl.INT:case jl.UINT:case jl.FLOAT:return dv[0];case jl.BOOL2:case jl.INT2:case jl.UINT2:case jl.FLOAT2:return dv[1];case jl.BOOL4:case jl.INT4:case jl.UINT4:case jl.FLOAT4:return dv[2];case jl.MAT4:return dv[3];case jl.SAMPLER2D:return"default-texture";case jl.SAMPLER_CUBE:return"default-cube-texture";case jl.SAMPLER2D_ARRAY:return"default-array-texture";case jl.SAMPLER3D:return"default-3d-texture"}return dv[0]}function pv(t){switch(t){case jl.SAMPLER2D:return"-texture";case jl.SAMPLER_CUBE:return"-cube-texture";case jl.SAMPLER2D_ARRAY:return"-array-texture";case jl.SAMPLER3D:return"-3d-texture";default:return"-unknown"}}function mv(t,e){for(var i=Object.entries(e),n=!1,r=0;r31&&(t.uber=!0),t.constantMacros="",t.builtins.statistics)t.constantMacros+="#define "+r+" "+t.builtins.statistics[r]+"\n"}(i),this._templates[t.name]=i,!this._templateInfos[i.hash]){var n={};n.samplerStartBinding=i.blocks.length,n.shaderInfo=new l_,n.blockSizes=[],n.bindings=[];for(var s=0;s>2)*a.count}for(var h=0;h0&&this.shaders.length>0},e}(of))._effects={},Dv._layoutValid=!0,xv=ks((wv=Dv).prototype,"techniques",[io],(function(){return[]})),Rv=ks(wv.prototype,"shaders",[io],(function(){return[]})),Iv=ks(wv.prototype,"combinations",[io],(function(){return[]})),Bv=ks(wv.prototype,"hideInEditor",[io,ro],(function(){return!1})),Cv=wv))||Cv);v.EffectAsset=Mv;var Lv=function(){function t(){this.name="",this.base="",this.importBase="",this.nativeBase="",this.deps=null,this.assetInfos=new Rd,this.scenes=new Rd,this.paths=new Rd}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 o=0,a=e.length;oe.length)||47===t.charCodeAt(e.length)}(r,t)||!t)for(var s=0,o=i.length;s0&&function(t){var e=Object.create(null);if(e[t._uuid]=t.refCount,Vv(t,e,Gv,-1),Gv.length=0,0!==e[t._uuid])return e[t._uuid];for(var i in e)0!==e[i]&&Vv(Dd.get(i),e,Gv,1);return Gv.length=0,e[t._uuid]}(t)>0)){Dd.remove(i);for(var n=Hp.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&&(Le(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}();pS._instance=void 0;var mS,gS,yS,vS,SS,TS,AS=pS.instance,bS=pS.instance,ES=t("ed",qs("cc.JsonAsset")((gS=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r0){var o=Ud.create({input:s,progress:r,options:n,onProgress:t.onProgress,onError:Ud.prototype.recycle,onComplete:function(n){var r;n||((r=t.output).push.apply(r,o.output),o.recycle()),i&&kS(t),e(n)}});Nd.async(o)}else i&&kS(t),e()}))}function kS(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||Ee.querySettings(be.Category.ASSETS,"importBase")||"";s&&s.endsWith("/")&&(s=s.substr(0,s.length-1));var o=t.nativeBase||Ee.querySettings(be.Category.ASSETS,"nativeBase")||"";o&&o.endsWith("/")&&(o=o.substr(0,o.length-1)),this.generalImportBase=s,this.generalNativeBase=o,this._projectBundles=Ee.querySettings(be.Category.ASSETS,"projectBundles")||[];var a=Ee.querySettings(be.Category.ASSETS,"assetsOverrides")||{};for(var h in a)this.assetsOverrideMap.set(h,a[h])},e.getBundle=function(t){return Md.get(t)||null},e.removeBundle=function(t){t._destroy(),Md.remove(t.name)},e.loadAny=function(t,e,i,n){var r=Kv(e,i,n),s=r.options,o=r.onProgress,a=r.onComplete;s.preset=s.preset||"default",t=Array.isArray(t)?t.slice():t;var h=Ud.create({input:t,onProgress:o,onComplete:Zv(a),options:s});Ld.async(h)},e.preloadAny=function(t,e,i,n){var r=Kv(e,i,n),s=r.options,o=r.onProgress,a=r.onComplete;s.preset=s.preset||"preload",t=Array.isArray(t)?t.slice():t;var h=Ud.create({input:t,onProgress:o,onComplete:Zv(a),options:s});Nd.async(h)},e.loadRemote=function(t,e,i){var n=Kv(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?(V(e.message,e.stack),s&&s(e,i)):LS.create(t,i,r.ext||hl(t),r,(function(t,e){s&&s(t,e)}))}))):Zv(s)(null,this.assets.get(t))},e.loadBundle=function(t,e,i){var n=Kv(e,void 0,i),r=n.options,s=n.onComplete,o=ll(t);this.bundles.has(o)?Zv(s)(null,this.getBundle(o)):(r.preset=r.preset||"bundle",r.ext="bundle",r.__isNative__=!0,this.loadAny({url:t},r,null,(function(e,i){e?(V(e.message,e.stack),s&&s(e,i)):LS.create(t,i,"bundle",r,(function(t,e){s&&s(t,e)}))})))},e.releaseAsset=function(t){Uv.tryRelease(t,!0)},e.releaseUnusedAssets=function(){Dd.forEach((function(t){Uv.tryRelease(t)}))},e.releaseAll=function(){Dd.forEach((function(t){Uv.tryRelease(t,!0)}))},e.loadWithJson=function(){throw new Error("Only valid in Editor")},n(t,[{key:"main",get:function(){return Md.get(Vd.MAIN)||null}},{key:"resources",get:function(){return Md.get(Vd.RESOURCES)||null}}],[{key:"instance",get:function(){return this._instance||(this._instance=new t),this._instance}}]),t}());QS._instance=void 0,QS.Pipeline=Id,QS.Task=Ud,QS.Cache=Rd,QS.RequestItem=jS,QS.Bundle=$v,QS.BuiltinBundleName=Vd,QS.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},QS.Downloader=pS,QS.Parser=GS,QS.DependUtil=Up;var ZS=t("en",v.assetManager=QS.instance);v.AssetManager=QS;var $S,tT,eT,iT=t("eu",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),o=0,a=0;a<4;a++)e[o]=0,e[o+1]=0,e[o+2]=0,e[o+3]=255,i[o]=0,i[o+1]=0,i[o+2]=0,i[o+3]=0,n[o]=119,n[o+1]=119,n[o+2]=119,n[o+3]=255,r[o]=255,r[o+1]=255,r[o+2]=255,r[o+3]=255,s[o]=127,s[o+1]=127,s[o+2]=255,s[o+3]=255,o+=4;var h=new Uint8Array(1024);o=0;for(var u=0;u<256;u++)h[o]=221,h[o+1]=221,h[o+2]=221,h[o+3]=255,o+=4;o=0;for(var l=0;l<8;l++){for(var c=0;c<8;c++)h[o]=85,h[o+1]=85,h[o+2]=85,h[o+3]=255,o+=4;o+=32}o+=32;for(var _=0;_<8;_++){for(var d=0;d<8;d++)h[o]=85,h[o+1]=85,h[o+2]=85,h[o+3]=255,o+=4;o+=32}var f={width:2,height:2,_data:e,_compressed:!1,format:Zp.PixelFormat.RGBA8888},p={width:2,height:2,_data:i,_compressed:!1,format:Zp.PixelFormat.RGBA8888},m={width:2,height:2,_data:n,_compressed:!1,format:Zp.PixelFormat.RGBA8888},g={width:2,height:2,_data:r,_compressed:!1,format:Zp.PixelFormat.RGBA8888},y={width:2,height:2,_data:s,_compressed:!1,format:Zp.PixelFormat.RGBA8888},S={width:16,height:16,_data:h,_compressed:!1,format:Zp.PixelFormat.RGBA8888},T=new Rf(f),A=new Zp;A._uuid="black-texture",A.image=T,t[A._uuid]=A;var b=new Rf(p),E=new Zp;E._uuid="empty-texture",E.image=b,t[E._uuid]=E;var C=new Qm;C._uuid="black-cube-texture",C.setMipFilter(Qm.Filter.NEAREST),C.image={front:new Rf(f),back:new Rf(f),left:new Rf(f),right:new Rf(f),top:new Rf(f),bottom:new Rf(f)},t[C._uuid]=C;var w=new Rf(m),x=new Zp;x._uuid="grey-texture",x.image=w,t[x._uuid]=x;var R=new Qm;R._uuid="grey-cube-texture",R.setMipFilter(Qm.Filter.NEAREST),R.image={front:new Rf(m),back:new Rf(m),left:new Rf(m),right:new Rf(m),top:new Rf(m),bottom:new Rf(m)},t[R._uuid]=R;var I=new Rf(g),B=new Zp;B._uuid="white-texture",B.image=I,t[B._uuid]=B;var D=new Qm;D._uuid="white-cube-texture",D.setMipFilter(Qm.Filter.NEAREST),D.image={front:new Rf(g),back:new Rf(g),left:new Rf(g),right:new Rf(g),top:new Rf(g),bottom:new Rf(g)},t[D._uuid]=D;var P=new Rf(y),O=new Zp;O._uuid="normal-texture",O.image=P,t[O._uuid]=O;var M=new Rf(S),L=new Zp;L._uuid="default-texture",L.image=M,t[L._uuid]=L;var N=new Qm;if(N.setMipFilter(Qm.Filter.NEAREST),N._uuid="default-cube-texture",N.image={front:new Rf(S),back:new Rf(S),left:new Rf(S),right:new Rf(S),top:new Rf(S),bottom:new Rf(S)},t[N._uuid]=N,v.SpriteFrame){var F=new v.SpriteFrame,k=T,V=new Zp;V.image=k,F.texture=V,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=Ee.querySettings(be.Category.ENGINE,"builtinAssets");if(!e)return Promise.resolve();var i=this._resources;return new Promise((function(n,r){ZS.loadBundle(Vd.INTERNAL,(function(s){s?r(s):ZS.loadAny(e,(function(e,s){e?r(e):(s.forEach((function(e){i[e.name]=e,Uv.addIgnoredAsset(e),e instanceof v.Material&&t._materialsToBeCompiled.push(e)})),n())}))}))}))},e.compileBuiltinMaterial=function(){for(var t=0;t=1024)&&m.lightingMap.objectID===o.objectID&&m.useReflectionProbeType===l&&m.reflectionProbeCubemap.objectID===a.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,y=m.data;m.data=new Uint8Array(g),m.data.set(y),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 v=this._device.createBuffer(new Xc(Xl.VERTEX|Xl.TRANSFER_DST,Kl.HOST|Kl.DEVICE,32*r,r)),S=new Uint8Array(32*r),T=s.vertexBuffers.slice(),A=s.attributes.slice(),b=s.indexBuffer,E=0;E>2,o=this._getBlockView(r,n),a=t.getOffsetFromHandle(e),h=0;h>2)*o,c=0;c+u.length<=l;c+=u.length)a.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),o=t.getBindingFromHandle(n),a=this._properties[e],h=a&&a.value,u=(r="string"==typeof h?nT.get(""+h+pv(s)):h||nT.get(fv(s)))&&r.getGFXTexture(),l=a&&void 0!==a.samplerHash?cd.unpackFromHash(a.samplerHash):r&&r.getSamplerInfo(),c=this._device.getSampler(l);this._descriptorSet.bindSampler(o,c,i||0),this._descriptorSet.bindTexture(o,u,i||0)}},e.resetUBOs=function(){for(var t=0;t>2)*r.count,u=0;u+a.length<=h;u+=a.length)s.set(a,i+u);i+=h}this._rootBufferDirty=!0},e.resetTextures=function(){if(v.rendering)for(var t,e=d(this._shaderInfo.descriptors[Cg.MATERIAL].samplerTextures);!(t=e()).done;)for(var i=t.value,n=0;n=this._passes.length)return void console.warn("illegal pass index: "+i+".");var h=this._passes[i];this._uploadProperty(h,t,e)&&(this._props[h.propertyIndex][t]=e,n=!0)}n||console.warn("illegal property name: "+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 console.warn("illegal pass index: "+e+"."),null;var o=this._props[this._passes[e].propertyIndex];if(t in o)return o[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}(of),yT=ks(gT.prototype,"_effectAsset",[pT],(function(){return null})),vT=ks(gT.prototype,"_techIdx",[io],(function(){return 0})),ST=ks(gT.prototype,"_defines",[io],(function(){return[]})),TT=ks(gT.prototype,"_states",[io],(function(){return[]})),AT=ks(gT.prototype,"_props",[io],(function(){return[]})),mT=gT))||mT));v.Material=xT;var RT=ge({Low_256x256:256,Medium_512x512:512,High_1024x1024:1024,Ultra_2048x2048:2048}),IT=ge({Planar:0,ShadowMap:1}),BT=ge({HARD:0,SOFT:1,SOFT_2X:2,SOFT_4X:3}),DT=ge({LEVEL_1:1,LEVEL_2:2,LEVEL_3:3,LEVEL_4:4}),PT=ge({NONE:1,RemoveDuplicates:2,DisableRotationFix:3}),OT=IT.ShadowMap+1,MT=function(){function t(){this.fixedSphere=new gr(0,0,0,.01),this.maxReceived=4,this._matLight=new In,this._material=null,this._instancingMaterial=null,this._enabled=!1,this._type=OT,this._distance=0,this._planeBias=1,this._normal=new on(0,1,0),this._shadowColor=new dn(0,0,0,76),this._size=new Ln(1024,1024),this._shadowMapDirty=!1}var e=t.prototype;return e.getPlanarShader=function(t){this._material||(this._material=new xT,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:OT,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===IT.Planar)this._updatePlanarInfo();else{var t=v.director.root;t.pipeline.macros.CC_SHADOW_TYPE=2,t.onGlobalPipelineStateChanged()}else{var e=v.director.root;e.pipeline.macros.CC_SHADOW_TYPE=0,e.onGlobalPipelineStateChanged()}},e._updatePlanarInfo=function(){this._material||(this._material=new xT,this._material.initialize({effectName:"pipeline/planar-shadow"}));var t=v.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:OT,this.activate()}},{key:"normal",get:function(){return this._normal},set:function(t){on.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}();MT.MAX_FAR=2e3,MT.COEFFICIENT_OF_EXPANSION=2*Math.sqrt(3),v.Shadows=MT;var LT=function(t){function e(e,i){var n;(n=t.call(this,e.root)||this)._parent=void 0,n._owner=void 0,n._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(o,1)}}}function hw(t,e,i){if(!(e.length<=0))for(var n=null,r=0;r0){var h=a.pop();if(!h)continue;for(var u=0;u0){var g=p.pop();if(!g)return;for(var y=0;yMath.abs(e)?t:-e},e}(Vw),Ww=function(t){function e(e){var i;return(i=t.call(this)||this).up=void 0,i.down=void 0,i.left=void 0,i.right=void 0,i.xAxis=void 0,i.yAxis=void 0,i.up=e.up,i.down=e.down,i.left=e.left,i.right=e.right,i.xAxis=new Hw({positive:i.right,negative:i.left}),i.yAxis=new Hw({positive:i.up,negative:i.down}),i}return s(e,t),e.prototype.getValue=function(){return new Ln(this.xAxis.getValue(),this.yAxis.getValue())},e}(Gw);!function(t){function e(e){var i;return(i=t.call(this)||this).up=void 0,i.down=void 0,i.left=void 0,i.right=void 0,i.forward=void 0,i.backward=void 0,i.xAxis=void 0,i.yAxis=void 0,i.zAxis=void 0,i.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 Hw({positive:i.right,negative:i.left}),i.yAxis=new Hw({positive:i.up,negative:i.down}),i.zAxis=new Hw({positive:i.forward,negative:i.backward}),i}s(e,t),e.prototype.getValue=function(){return new on(this.xAxis.getValue(),this.yAxis.getValue(),this.zAxis.getValue())}}(Uw);var jw,Xw=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}(Vw),qw=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e}(Ww),Yw=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e}(Ww),Kw=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}(zw),Jw=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}(Uw),Qw=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}(Vw),Zw="left",$w="right",tx=[];!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"}(jw||(jw={}));var ex,ix,nx,rx,sx,ox=function(){function t(t){var e;this._buttonNorth=void 0,this._buttonEast=void 0,this._buttonWest=void 0,this._buttonSouth=void 0,this._buttonL1=void 0,this._buttonL2=void 0,this._buttonL3=void 0,this._buttonR1=void 0,this._buttonR2=void 0,this._buttonR3=void 0,this._buttonShare=void 0,this._buttonOptions=void 0,this._dpad=void 0,this._leftStick=void 0,this._rightStick=void 0,this._buttonStart=void 0,this._gripLeft=void 0,this._gripRight=void 0,this._handLeftPosition=void 0,this._handLeftOrientation=void 0,this._handRightPosition=void 0,this._handRightOrientation=void 0,this._aimLeftPosition=void 0,this._aimLeftOrientation=void 0,this._aimRightPosition=void 0,this._aimRightOrientation=void 0,this._deviceId=-1,this._connected=!1,this._webPoseState=((e={})[jw.HAND_LEFT]={position:on.ZERO,orientation:Sn.IDENTITY},e[jw.HAND_RIGHT]={position:on.ZERO,orientation:Sn.IDENTITY},e[jw.AIM_LEFT]={position:on.ZERO,orientation:Sn.IDENTITY},e[jw.AIM_RIGHT]={position:on.ZERO,orientation:Sn.IDENTITY},e),this._deviceId=t,this._initInputSource()}t._init=function(){nl.hasFeature(el.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&&ae(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(){v.director&&v.Director&&(clearInterval(t._intervalId),t._intervalId=-1,e())}),50)},t._updateGamepadCnt=function(){for(var e=0,i=0,n=t._cachedWebGamepads.length;i.01){o=t._getOrCreateInputDevice(r.index,!0);break}}if(o){e.push(o);continue}for(var c=s.axes,_=0;_.01){o=t._getOrCreateInputDevice(r.index,!0);break}}if(o){e.push(o);continue}}}}t._cachedWebGamepads=i}}},t._scanGamepads=function(){tx.length=0,t._scanWebGamepads(tx),t._scanWebXRGamepads(tx);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!==jw.HAND_LEFT&&t.code!==jw.AIM_LEFT&&t.code!==jw.HAND_RIGHT&&t.code!==jw.AIM_RIGHT||(this._webPoseState[t.code]={position:new on(t.position.x,t.position.y,t.position.z),orientation:new Sn(t.orientation.x,t.orientation.y,t.orientation.z,t.orientation.w)})},e._initInputSource=function(){var e=this;this._buttonNorth=new Xw,this._buttonNorth.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(Zw);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 Xw,this._buttonEast.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get($w);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 Xw,this._buttonWest.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(Zw);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 Xw,this._buttonSouth.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get($w);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 Xw,this._buttonL1.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[4].value:0},this._buttonL2=new Xw,this._buttonL2.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(Zw);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 Xw,this._buttonL3.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(Zw);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 Xw,this._buttonR1.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[5].value:0},this._buttonR2=new Xw,this._buttonR2.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get($w);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 Xw,this._buttonR3.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get($w);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 Xw,this._buttonShare.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[8].value:0},this._buttonOptions=new Xw,this._buttonOptions.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[9].value:0};var i=new Xw;i.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[12].value:0};var n=new Xw;n.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[13].value:0};var r=new Xw;r.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[14].value:0};var s=new Xw;s.getValue=function(){var i=t._getWebGamepad(e.deviceId);return i?i.buttons[15].value:0},this._dpad=new qw({up:i,down:n,left:r,right:s});var o=new Xw;o.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(Zw);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 a=new Xw;a.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(Zw);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 Xw;h.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(Zw);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 Xw;u.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(Zw);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 Yw({up:o,down:a,left:h,right:u});var l=new Xw;l.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get($w);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 Xw;c.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get($w);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 Xw;_.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get($w);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 d=new Xw;d.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get($w);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 Yw({up:l,down:c,left:_,right:d}),this._buttonStart=new Xw,this._buttonStart.getValue=function(){return 0},this._gripLeft=new Xw,this._gripLeft.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get(Zw);if(n&&n.buttons.length>1)return n.buttons[1].value}return 0},this._gripRight=new Xw,this._gripRight.getValue=function(){if(-1===e.deviceId){var i,n=null===(i=t._getWebXRGamepadMap())||void 0===i?void 0:i.get($w);if(n&&n.buttons.length>1)return n.buttons[1].value}return 0},this._handLeftPosition=new Jw,this._handLeftPosition.getValue=function(){return e._webPoseState[jw.HAND_LEFT].position},this._handLeftOrientation=new Kw,this._handLeftOrientation.getValue=function(){return e._webPoseState[jw.HAND_LEFT].orientation},this._handRightPosition=new Jw,this._handRightPosition.getValue=function(){return e._webPoseState[jw.HAND_RIGHT].position},this._handRightOrientation=new Kw,this._handRightOrientation.getValue=function(){return e._webPoseState[jw.HAND_RIGHT].orientation},this._aimLeftPosition=new Jw,this._aimLeftPosition.getValue=function(){return e._webPoseState[jw.AIM_LEFT].position},this._aimLeftOrientation=new Kw,this._aimLeftOrientation.getValue=function(){return e._webPoseState[jw.AIM_LEFT].orientation},this._aimRightPosition=new Jw,this._aimRightPosition.getValue=function(){return e._webPoseState[jw.AIM_RIGHT].position},this._aimRightOrientation=new Kw,this._aimRightOrientation.getValue=function(){return e._webPoseState[jw.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}();ox.all=[],ox.xr=null,ox._eventTarget=new Ku,ox._cachedWebGamepads=[],ox._cachedWebXRGamepadMap=null,ox._intervalId=-1,ox._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"}(ex||(ex={})),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"}(ix||(ix={})),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"}(nx||(nx={})),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"}(rx||(rx={})),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"}(sx||(sx={}));var ax,hx={1:ex.BUTTON_EAST,2:ex.BUTTON_SOUTH,3:ex.BUTTON_NORTH,4:ex.BUTTON_WEST,9:ex.BUTTON_LEFT_STICK,10:ex.BUTTON_RIGHT_STICK,11:ex.ROKID_MENU,12:ex.ROKID_START,13:ex.BUTTON_TRIGGER_LEFT,14:ex.BUTTON_TRIGGER_RIGHT},ux=function(){function t(){var t,e,i=this;this._eventTarget=new Ku,this._buttonNorth=void 0,this._buttonEast=void 0,this._buttonWest=void 0,this._buttonSouth=void 0,this._buttonTriggerLeft=void 0,this._buttonTriggerRight=void 0,this._triggerLeft=void 0,this._triggerRight=void 0,this._gripLeft=void 0,this._gripRight=void 0,this._leftStick=void 0,this._rightStick=void 0,this._buttonLeftStick=void 0,this._buttonRightStick=void 0,this._buttonOptions=void 0,this._buttonStart=void 0,this._handLeftPosition=void 0,this._handLeftOrientation=void 0,this._handRightPosition=void 0,this._handRightOrientation=void 0,this._aimLeftPosition=void 0,this._aimLeftOrientation=void 0,this._aimRightPosition=void 0,this._aimRightOrientation=void 0,this._touchButtonA=void 0,this._touchButtonB=void 0,this._touchButtonX=void 0,this._touchButtonY=void 0,this._touchButtonTriggerLeft=void 0,this._touchButtonTriggerRight=void 0,this._touchButtonThumbStickLeft=void 0,this._touchButtonThumbStickRight=void 0,this._nativeButtonState=((t={})[ex.BUTTON_SOUTH]=0,t[ex.BUTTON_EAST]=0,t[ex.BUTTON_WEST]=0,t[ex.BUTTON_NORTH]=0,t[ex.BUTTON_TRIGGER_LEFT]=0,t[ex.BUTTON_TRIGGER_RIGHT]=0,t[ex.TRIGGER_LEFT]=0,t[ex.TRIGGER_RIGHT]=0,t[ex.GRIP_LEFT]=0,t[ex.GRIP_RIGHT]=0,t[ex.LEFT_STICK_UP]=0,t[ex.LEFT_STICK_DOWN]=0,t[ex.LEFT_STICK_LEFT]=0,t[ex.LEFT_STICK_RIGHT]=0,t[ex.RIGHT_STICK_UP]=0,t[ex.RIGHT_STICK_DOWN]=0,t[ex.RIGHT_STICK_LEFT]=0,t[ex.RIGHT_STICK_RIGHT]=0,t[ex.BUTTON_LEFT_STICK]=0,t[ex.BUTTON_RIGHT_STICK]=0,t[ex.ROKID_MENU]=0,t[ex.ROKID_START]=0,t),this._nativeTouchState=((e={})[sx.UNDEFINE]=0,e[sx.A]=0,e[sx.B]=0,e[sx.X]=0,e[sx.Y]=0,e[sx.LEFT_TRIGGER]=0,e[sx.RIGHT_TRIGGER]=0,e[sx.LEFT_THUMBSTICK]=0,e[sx.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,o=e.detail.stickKeyCode,a=e.detail.isButtonPressed,h=e.detail.touchCode,u=e.detail.touchValue;if(n===ix.KET_CLICK){var l=hx[o];i._nativeButtonState[l]=a?1:0}else if(n===ix.KET_STICK||n===ix.KET_GRAB){var c,_,d;switch(r){case rx.LEFT_STICK_X:c=ex.LEFT_STICK_LEFT,_=ex.LEFT_STICK_RIGHT,d=i._axisToButtons(s);break;case rx.LEFT_STICK_Y:c=ex.LEFT_STICK_DOWN,_=ex.LEFT_STICK_UP,d=i._axisToButtons(s);break;case rx.RIGHT_STICK_X:c=ex.RIGHT_STICK_LEFT,_=ex.RIGHT_STICK_RIGHT,d=i._axisToButtons(s);break;case rx.RIGHT_STICK_Y:c=ex.RIGHT_STICK_DOWN,_=ex.RIGHT_STICK_UP,d=i._axisToButtons(s);break;case rx.L2:i._nativeButtonState[ex.TRIGGER_LEFT]=s;break;case rx.R2:i._nativeButtonState[ex.TRIGGER_RIGHT]=s;break;case rx.LEFT_GRIP:i._nativeButtonState[ex.GRIP_LEFT]=s;break;case rx.RIGHT_GRIP:i._nativeButtonState[ex.GRIP_RIGHT]=s}c&&_&&d&&(i._nativeButtonState[c]=d.negative,i._nativeButtonState[_]=d.positive)}else if(n===ix.KET_TOUCH)switch(h){case sx.A:case sx.B:case sx.X:case sx.Y:case sx.LEFT_TRIGGER:case sx.RIGHT_TRIGGER:case sx.LEFT_THUMBSTICK:case sx.RIGHT_THUMBSTICK:i._nativeTouchState[h]=u}i._eventTarget.emit(bw.HANDLE_INPUT,new Pw(bw.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 Xw,this._buttonNorth.getValue=function(){return t._nativeButtonState[ex.BUTTON_NORTH]},this._buttonEast=new Xw,this._buttonEast.getValue=function(){return t._nativeButtonState[ex.BUTTON_EAST]},this._buttonWest=new Xw,this._buttonWest.getValue=function(){return t._nativeButtonState[ex.BUTTON_WEST]},this._buttonSouth=new Xw,this._buttonSouth.getValue=function(){return t._nativeButtonState[ex.BUTTON_SOUTH]},this._buttonTriggerLeft=new Xw,this._buttonTriggerLeft.getValue=function(){return t._nativeButtonState[ex.BUTTON_TRIGGER_LEFT]},this._buttonTriggerRight=new Xw,this._buttonTriggerRight.getValue=function(){return t._nativeButtonState[ex.BUTTON_TRIGGER_RIGHT]},this._triggerLeft=new Xw,this._triggerLeft.getValue=function(){return t._nativeButtonState[ex.TRIGGER_LEFT]},this._triggerRight=new Xw,this._triggerRight.getValue=function(){return t._nativeButtonState[ex.TRIGGER_RIGHT]},this._gripLeft=new Xw,this._gripLeft.getValue=function(){return t._nativeButtonState[ex.GRIP_LEFT]},this._gripRight=new Xw,this._gripRight.getValue=function(){return t._nativeButtonState[ex.GRIP_RIGHT]},this._buttonLeftStick=new Xw,this._buttonLeftStick.getValue=function(){return t._nativeButtonState[ex.BUTTON_LEFT_STICK]};var e=new Xw;e.getValue=function(){return t._nativeButtonState[ex.LEFT_STICK_UP]};var i=new Xw;i.getValue=function(){return t._nativeButtonState[ex.LEFT_STICK_DOWN]};var n=new Xw;n.getValue=function(){return t._nativeButtonState[ex.LEFT_STICK_LEFT]};var r=new Xw;r.getValue=function(){return t._nativeButtonState[ex.LEFT_STICK_RIGHT]},this._leftStick=new Yw({up:e,down:i,left:n,right:r}),this._buttonRightStick=new Xw,this._buttonRightStick.getValue=function(){return t._nativeButtonState[ex.BUTTON_RIGHT_STICK]};var s=new Xw;s.getValue=function(){return t._nativeButtonState[ex.RIGHT_STICK_UP]};var o=new Xw;o.getValue=function(){return t._nativeButtonState[ex.RIGHT_STICK_DOWN]};var a=new Xw;a.getValue=function(){return t._nativeButtonState[ex.RIGHT_STICK_LEFT]};var h=new Xw;h.getValue=function(){return t._nativeButtonState[ex.RIGHT_STICK_RIGHT]},this._rightStick=new Yw({up:s,down:o,left:a,right:h}),this._buttonOptions=new Xw,this._buttonOptions.getValue=function(){return t._nativeButtonState[ex.ROKID_MENU]},this._buttonStart=new Xw,this._buttonStart.getValue=function(){return t._nativeButtonState[ex.ROKID_START]},this._handLeftPosition=new Jw,this._handLeftPosition.getValue=function(){return on.ZERO},this._handLeftOrientation=new Kw,this._handLeftOrientation.getValue=function(){return Sn.IDENTITY},this._handRightPosition=new Jw,this._handRightPosition.getValue=function(){return on.ZERO},this._handRightOrientation=new Kw,this._handRightOrientation.getValue=function(){return Sn.IDENTITY},this._aimLeftPosition=new Jw,this._aimLeftPosition.getValue=function(){return on.ZERO},this._aimLeftOrientation=new Kw,this._aimLeftOrientation.getValue=function(){return Sn.IDENTITY},this._aimRightPosition=new Jw,this._aimRightPosition.getValue=function(){return on.ZERO},this._aimRightOrientation=new Kw,this._aimRightOrientation.getValue=function(){return Sn.IDENTITY},this._touchButtonA=new Qw,this._touchButtonA.getValue=function(){return t._nativeTouchState[sx.A]},this._touchButtonB=new Qw,this._touchButtonB.getValue=function(){return t._nativeTouchState[sx.B]},this._touchButtonX=new Qw,this._touchButtonX.getValue=function(){return t._nativeTouchState[sx.X]},this._touchButtonY=new Qw,this._touchButtonY.getValue=function(){return t._nativeTouchState[sx.Y]},this._touchButtonTriggerLeft=new Qw,this._touchButtonTriggerLeft.getValue=function(){return t._nativeTouchState[sx.LEFT_TRIGGER]},this._touchButtonTriggerRight=new Qw,this._touchButtonTriggerRight.getValue=function(){return t._nativeTouchState[sx.RIGHT_TRIGGER]},this._touchButtonThumbStickLeft=new Qw,this._touchButtonThumbStickLeft.getValue=function(){return t._nativeTouchState[sx.LEFT_THUMBSTICK]},this._touchButtonThumbStickRight=new Qw,this._touchButtonThumbStickRight.getValue=function(){return t._nativeTouchState[sx.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"}(ax||(ax={}));var lx,cx,_x=function(){function t(){var t;this._eventTarget=new Ku,this._intervalId=-1,this._viewLeftPosition=void 0,this._viewLeftOrientation=void 0,this._viewRightPosition=void 0,this._viewRightOrientation=void 0,this._headMiddlePosition=void 0,this._headMiddleOrientation=void 0,this._webPoseState=((t={})[ax.VIEW_LEFT]={position:on.ZERO,orientation:Sn.IDENTITY},t[ax.VIEW_RIGHT]={position:on.ZERO,orientation:Sn.IDENTITY},t[ax.HEAD_MIDDLE]={position:on.ZERO,orientation:Sn.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(){v.director&&v.Director&&(clearInterval(t._intervalId),t._intervalId=-1,e())}),50)}))},e._registerEvent=function(){var t=this;this._ensureDirectorDefined().then((function(){v.director.on(v.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;iCe.TOUCH_TIMEOUT&&(F("The touches is more than MAX_TOUCHES, release touch id "+t.getID()+"."),e.releaseTouch(t.getID()))})),i>=this._touchMap.size},t}()),vx=function(){function t(){this._canvas=void 0,this._eventTarget=new Ku,nl.hasFeature(el.INPUT_TOUCH)&&(this._canvas=document.getElementById("GameCanvas"),this._canvas||k("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(bw.TOUCH_START)),null===(e=this._canvas)||void 0===e||e.addEventListener("touchmove",this._createCallback(bw.TOUCH_MOVE)),null===(i=this._canvas)||void 0===i||i.addEventListener("touchend",this._createCallback(bw.TOUCH_END)),null===(n=this._canvas)||void 0===n||n.addEventListener("touchcancel",this._createCallback(bw.TOUCH_CANCEL))},e._createCallback=function(t){var e=this;return function(i){for(var n,r=e._getCanvasRect(),s=[],o=i.changedTouches.length,a=0;a0){var _=new Iw(s,!1,t,Ce.ENABLE_MULTI_TOUCH?yx.getAllTouches():s);e._eventTarget.emit(t,_)}}},e._getCanvasRect=function(){var t=this._canvas,e=null==t?void 0:t.getBoundingClientRect();return e?new Un(e.x,e.y,e.width,e.height):new Un(0,0,0,0)},e._getLocation=function(t,e){if(globalThis.__globalXR&&globalThis.__globalXR.ar&&globalThis.__globalXR.ar.isWebXR())return new Ln(t.clientX,t.clientY);var i=t.clientX-e.x,n=e.y+e.height-t.clientY;if(El.isFrameRotated){var r=i;i=e.height-n,n=r}var s=El.devicePixelRatio;return new Ln(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"}(cx||(cx={}));var Sx=function(){function t(t){this.priority=cx.GLOBAL,this._inputEventTarget=void 0,this._inputEventTarget=t}return t.prototype.dispatchEvent=function(t){return this._inputEventTarget.emit(t.type,t),!0},t}(),Tx=((lx={})[bw.MOUSE_DOWN]=bw.TOUCH_START,lx[bw.MOUSE_MOVE]=bw.TOUCH_MOVE,lx[bw.MOUSE_UP]=bw.TOUCH_END,lx),Ax=t("eL",function(){function t(){this._dispatchImmediately=!0,this._eventTarget=new Ku,this._touchInput=new vx,this._mouseInput=new mx,this._keyboardInput=new px,this._accelerometerInput=new Fw,this._handleInput=new ux,this._hmdInput=new _x,this._handheldInput=new dx,this._eventTouchList=[],this._eventMouseList=[],this._eventKeyboardList=[],this._eventAccelerationList=[],this._eventGamepadList=[],this._eventHandleList=[],this._eventHMDList=[],this._eventHandheldList=[],this._needSimulateTouchMoveEvent=!1,this._inputEventDispatcher=void 0,this._eventDispatcherList=[],this._registerEvent(),this._inputEventDispatcher=new Sx(this._eventTarget),this._registerEventDispatcher(this._inputEventDispatcher),ox._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 yx.getTouch(t)},e.getAllTouches=function(){return yx.getAllTouches()},e.getTouchCount=function(){return yx.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=Tx[t.type],i=yx.getOrCreateTouch(0,t.getLocationX(),t.getLocationY());if(i){var n=[i],r=new Iw(n,!1,e,e===bw.TOUCH_END?[]:n);r.windowId=t.windowId,e===bw.TOUCH_END&&yx.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;i=1&&this.width<=2048&&this.height>=1&&this.height<=2048},i.readPixels=function(t,e,i,n,r){void 0===t&&(t=0),void 0===e&&(e=0),i=i||this.width,n=n||this.height;var s=this.getGFXTexture();if(!s)return J(7606),null;var o=4*i*n;if(void 0===r)r=new Uint8Array(o);else if(r.length15e3&&(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,o=3*n/s,a=2*r/s,h=1/a*o,u=1/a*(1-o-a);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"}(sR||(sR={}));var uR,lR,cR,_R,dR,fR,pR,mR,gR,yR,vR,SR,TR=function(t){return 4*Math.PI*Math.PI*t*t},AR=function(){function t(){this._baked=!1,this._color=new on(1,1,1),this._colorTemp=6550,this._colorTempRGB=new on(1,1,1),this._finalColor=new on(1,1,1),this._scene=null,this._node=null,this._name=null,this._useColorTemperature=!1,this._type=sR.UNKNOWN,this._visibility=Ky}var e=t.prototype;return e.initialize=function(){this.color=new on(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&&on.multiply(this._finalColor,this._color,this._colorTempRGB)}},{key:"useColorTemperature",get:function(){return this._useColorTemperature},set:function(t){this._useColorTemperature=t,t&&on.multiply(this._finalColor,this._color,this._colorTempRGB)}},{key:"colorTemperature",get:function(){return this._colorTemp},set:function(t){this._colorTemp=t,hR(this._colorTempRGB,this._colorTemp),this._useColorTemperature&&on.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|=rm.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}();!function(t){t[t.PER_INSTANCE=0]="PER_INSTANCE",t[t.PER_BATCH=1]="PER_BATCH",t[t.PER_PHASE=2]="PER_PHASE",t[t.PER_PASS=3]="PER_PASS",t[t.COUNT=4]="COUNT"}(uR||(uR={})),function(t){t[t.CONSTANTS=0]="CONSTANTS",t[t.CBV=1]="CBV",t[t.UAV=2]="UAV",t[t.SRV=3]="SRV",t[t.TABLE=4]="TABLE",t[t.SSV=5]="SSV"}(lR||(lR={})),function(t){t[t.MANAGED=0]="MANAGED",t[t.MEMORYLESS=1]="MEMORYLESS",t[t.PERSISTENT=2]="PERSISTENT",t[t.EXTERNAL=3]="EXTERNAL",t[t.BACKBUFFER=4]="BACKBUFFER"}(cR||(cR={})),function(t){t[t.NONE=0]="NONE",t[t.OPAQUE=1]="OPAQUE",t[t.MASK=2]="MASK",t[t.BLEND=3]="BLEND",t[t.RENDER_OPAQUE=1]="RENDER_OPAQUE",t[t.RENDER_CUTOUT=2]="RENDER_CUTOUT",t[t.RENDER_TRANSPARENT=3]="RENDER_TRANSPARENT"}(_R||(_R={})),function(t){t[t.BUFFER=0]="BUFFER",t[t.TEXTURE1D=1]="TEXTURE1D",t[t.TEXTURE2D=2]="TEXTURE2D",t[t.TEXTURE3D=3]="TEXTURE3D"}(dR||(dR={})),function(t){t[t.NONE=0]="NONE",t[t.UNIFORM=1]="UNIFORM",t[t.INDIRECT=2]="INDIRECT",t[t.STORAGE=4]="STORAGE",t[t.SAMPLED=8]="SAMPLED",t[t.COLOR_ATTACHMENT=16]="COLOR_ATTACHMENT",t[t.DEPTH_STENCIL_ATTACHMENT=32]="DEPTH_STENCIL_ATTACHMENT",t[t.INPUT_ATTACHMENT=64]="INPUT_ATTACHMENT",t[t.SHADING_RATE=128]="SHADING_RATE",t[t.TRANSFER_SRC=256]="TRANSFER_SRC",t[t.TRANSFER_DST=512]="TRANSFER_DST"}(fR||(fR={})),function(t){t[t.SYNC=0]="SYNC",t[t.ASYNC=1]="ASYNC"}(pR||(pR={})),function(t){t[t.NONE=0]="NONE",t[t.OPAQUE=1]="OPAQUE",t[t.MASK=2]="MASK",t[t.BLEND=4]="BLEND",t[t.OPAQUE_OBJECT=1]="OPAQUE_OBJECT",t[t.CUTOUT_OBJECT=2]="CUTOUT_OBJECT",t[t.TRANSPARENT_OBJECT=4]="TRANSPARENT_OBJECT",t[t.SHADOW_CASTER=8]="SHADOW_CASTER",t[t.UI=16]="UI",t[t.DEFAULT_LIGHTING=32]="DEFAULT_LIGHTING",t[t.VOLUMETRIC_LIGHTING=64]="VOLUMETRIC_LIGHTING",t[t.CLUSTERED_LIGHTING=128]="CLUSTERED_LIGHTING",t[t.PLANAR_SHADOW=256]="PLANAR_SHADOW",t[t.GEOMETRY=512]="GEOMETRY",t[t.PROFILER=1024]="PROFILER",t[t.DRAW_INSTANCING=2048]="DRAW_INSTANCING",t[t.DRAW_NON_INSTANCING=4096]="DRAW_NON_INSTANCING",t[t.REFLECTION_PROBE=8192]="REFLECTION_PROBE",t[t.GPU_DRIVEN=16384]="GPU_DRIVEN",t[t.NON_BUILTIN=32768]="NON_BUILTIN",t[t.ALL=4294967295]="ALL"}(mR||(mR={})),function(t){t[t.NONE=0]="NONE",t[t.DEFAULT=1]="DEFAULT",t[t.CLUSTERED=2]="CLUSTERED"}(gR||(gR={})),function(t){t[t.RENDER_TARGET=0]="RENDER_TARGET",t[t.DEPTH_STENCIL=1]="DEPTH_STENCIL",t[t.SHADING_RATE=2]="SHADING_RATE"}(yR||(yR={})),function(t){t[t.READ=0]="READ",t[t.READ_WRITE=1]="READ_WRITE",t[t.WRITE=2]="WRITE"}(vR||(vR={})),function(t){t[t.NONE=0]="NONE",t[t.FLOAT_TYPE=1]="FLOAT_TYPE",t[t.INT_TYPE=2]="INT_TYPE"}(SR||(SR={}));var bR,ER,CR=function(){function t(t,e,i,n){void 0===t&&(t=null),void 0===e&&(e=0),void 0===i&&(i=!1),void 0===n&&(n=null),this.light=void 0,this.probe=void 0,this.level=void 0,this.culledByLight=void 0,this.light=t,this.probe=n,this.level=e,this.culledByLight=i}return t.prototype.reset=function(t,e,i,n){void 0===t&&(t=null),void 0===e&&(e=0),void 0===i&&(i=!1),void 0===n&&(n=null),this.light=t,this.probe=n,this.level=e,this.culledByLight=i},t}();!function(t){t[t.UNIFORM_BUFFER=0]="UNIFORM_BUFFER",t[t.DYNAMIC_UNIFORM_BUFFER=1]="DYNAMIC_UNIFORM_BUFFER",t[t.SAMPLER_TEXTURE=2]="SAMPLER_TEXTURE",t[t.SAMPLER=3]="SAMPLER",t[t.TEXTURE=4]="TEXTURE",t[t.STORAGE_BUFFER=5]="STORAGE_BUFFER",t[t.DYNAMIC_STORAGE_BUFFER=6]="DYNAMIC_STORAGE_BUFFER",t[t.STORAGE_IMAGE=7]="STORAGE_IMAGE",t[t.INPUT_ATTACHMENT=8]="INPUT_ATTACHMENT"}(bR||(bR={})),function(t){t[t.NONE=0]="NONE",t[t.COLOR=1]="COLOR",t[t.DEPTH=2]="DEPTH",t[t.STENCIL=4]="STENCIL"}(ER||(ER={}));var wR,xR=function(){function t(t,e,i,n,r,s,o){void 0===t&&(t=new Uint8Array(0)),void 0===e&&(e=""),void 0===i&&(i=4294967295),void 0===n&&(n=4294967295),void 0===r&&(r=0),void 0===s&&(s=0),void 0===o&&(o=0),this.source=void 0,this.target=void 0,this.mipLevels=void 0,this.numSlices=void 0,this.targetMostDetailedMip=void 0,this.targetFirstSlice=void 0,this.targetPlaneSlice=void 0,this.source=t,this.target=e,this.mipLevels=i,this.numSlices=n,this.targetMostDetailedMip=r,this.targetFirstSlice=s,this.targetPlaneSlice=o}return t.prototype.reset=function(t,e,i,n,r,s){void 0===t&&(t=""),void 0===e&&(e=4294967295),void 0===i&&(i=4294967295),void 0===n&&(n=0),void 0===r&&(r=0),void 0===s&&(s=0),this.target=t,this.mipLevels=e,this.numSlices=i,this.targetMostDetailedMip=n,this.targetFirstSlice=r,this.targetPlaneSlice=s},t}();rt(Of.prototype,"TextureBase.prototype",[{name:"hasPremultipliedAlpha"},{name:"setPremultiplyAlpha"},{name:"setFlipY"}]),nt(rR.prototype,"RenderTexture.prototype",[{name:"getGFXWindow",customFunction:function(){return this.window}}]);var RR=((wR={})[Wl.UNORM]="Uint",wR[Wl.SNORM]="Int",wR[Wl.UINT]="Uint",wR[Wl.INT]="Int",wR[Wl.UFLOAT]="Float",wR[Wl.FLOAT]="Float",wR.default="Uint",wR);function IR(t){return""+(RR[t.type]||RR.default)+t.size/t.count*8}function BR(t,e,i,n,r){void 0===i&&(i=Hl.R32F),void 0===n&&(n=0),void 0===r&&(r=0);var s=M_[i];r||(r=s.size);for(var o="set"+IR(s),a=s.size/s.count,h=Math.floor(e.length/s.count),u=xl.isLittleEndian,l=0;ly.x?e[T]:y.x,y.y=e[T+1]>y.y?e[T+1]:y.y,v.x=e[T]y.x?e[T]:y.x,y.y=e[T+1]>y.y?e[T+1]:y.y,y.z=e[T+2]>y.z?e[T+2]:y.z,v.x=e[T]0?.5*(1-Math.floor(r/2))*h:.5*Math.floor(r/2)*h,s.width=.5*a,s.height=.5*h}break;case sR.SPOT:s.x=0,s.y=0,s.width=a,s.height=h}return s}var HR=function(){function t(t){void 0===t&&(t=MR.NONE),this.antiAliasing=MR.NONE,this.antiAliasing=t,this._init()}return t.prototype._init=function(){this.postMaterial=new xT,this.postMaterial.name="builtin-post-process-material",this.postMaterial.initialize({effectName:"pipeline/post-process",defines:{ANTIALIAS_TYPE:this.antiAliasing}});for(var t=0;t0?Math.abs(this._kernel[r].w-this._kernel[r-1].w):0)+(r<24?Math.abs(this._kernel[r].w-this._kernel[r+1].w):0))/2;ZR.set(0),this._profile(ZR,this._kernel[r].w),ZR.multiplyScalar(s),this._kernel[r].x=ZR.x,this._kernel[r].y=ZR.y,this._kernel[r].z=ZR.z}tI.set(this._kernel[12]);for(var o=12;o>0;o--)eI.set(this._kernel[o-1]),this._kernel[o].set(eI);this._kernel[0].set(tI),ZR.set(0);for(var a=0;a<25;a++)ZR.add3f(this._kernel[a].x,this._kernel[a].y,this._kernel[a].z);for(var h=0;h<25;h++)this._kernel[h].x/=ZR.x,this._kernel[h].y/=ZR.y,this._kernel[h].z/=ZR.z;this._kernel[0].x=1*(1-t.x)+t.x*this._kernel[0].x,this._kernel[0].y=1*(1-t.y)+t.y*this._kernel[0].y,this._kernel[0].z=1*(1-t.z)+t.z*this._kernel[0].z;for(var u=1;u<25;u++)this._kernel[u].x*=t.x,this._kernel[u].y*=t.y,this._kernel[u].z*=t.z},t._updateBlurPass=function(){if(this.ssssBlurMaterial){var t=this.ssssBlurMaterial.passes[0];t.beginChangeStatesSilently(),t.tryCompile(),t.endChangeStatesSilently();var e=this.ssssBlurMaterial.passes[1];e.beginChangeStatesSilently(),e.tryCompile(),e.endChangeStatesSilently();var i=this.ssssBlurMaterial.passes[2];i.beginChangeStatesSilently(),i.tryCompile(),i.endChangeStatesSilently()}},t._init=function(){if(!this.ssssBlurMaterial){this.ssssBlurMaterial=new xT,this.ssssBlurMaterial._uuid="builtin-ssssBlur-material",this.ssssBlurMaterial.initialize({effectName:"pipeline/ssss-blur"});for(var t=0;t>3)]+=(a.isCompositeModeEnabled(u)?1:0)*Math.pow(10,l)}r[Bg.DEBUG_VIEW_MODE_OFFSET+3]+=(a.lightingWithAlbedo?1:0)*Math.pow(10,6),r[Bg.DEBUG_VIEW_MODE_OFFSET+3]+=(a.csmLayerColoration?1:0)*Math.pow(10,7)}},t.updateCameraUBOView=function(t,e,i){var n,r=(i.scene?i.scene:v.director.getScene().renderScene).mainLight,s=t.pipelineSceneData,o=s.ambient,a=s.skybox,h=s.fog,u=s.shadows,l=e,c=i.exposure,_=s.isHDR;if(l[Dg.SCREEN_SCALE_OFFSET]=s.shadingScale,l[Dg.SCREEN_SCALE_OFFSET+1]=s.shadingScale,l[Dg.SCREEN_SCALE_OFFSET+2]=1/l[Dg.SCREEN_SCALE_OFFSET],l[Dg.SCREEN_SCALE_OFFSET+3]=1/l[Dg.SCREEN_SCALE_OFFSET+1],l[Dg.EXPOSURE_OFFSET]=c,l[Dg.EXPOSURE_OFFSET+1]=1/c,l[Dg.EXPOSURE_OFFSET+2]=_?1:0,l[Dg.EXPOSURE_OFFSET+3]=1/Hx.standardExposureValue,r){var d=r.shadowEnabled&&u.type===IT.ShadowMap?1:0,f=r.direction;if(gI.set(f.x,f.y,f.z,d),tn.toArray(l,gI,Dg.MAIN_LIT_DIR_OFFSET),on.toArray(l,r.color,Dg.MAIN_LIT_COLOR_OFFSET),r.useColorTemperature){var p=r.colorTemperatureRGB;l[Dg.MAIN_LIT_COLOR_OFFSET]*=p.x,l[Dg.MAIN_LIT_COLOR_OFFSET+1]*=p.y,l[Dg.MAIN_LIT_COLOR_OFFSET+2]*=p.z}l[Dg.MAIN_LIT_COLOR_OFFSET+3]=_?r.illuminance*c:r.illuminance}else gI.set(0,0,1,0),tn.toArray(l,gI,Dg.MAIN_LIT_DIR_OFFSET),tn.toArray(l,tn.ZERO,Dg.MAIN_LIT_COLOR_OFFSET);var m=o.skyColor;m.w=_?o.skyIllum*c:o.skyIllum,l[Dg.AMBIENT_SKY_OFFSET+0]=m.x,l[Dg.AMBIENT_SKY_OFFSET+1]=m.y,l[Dg.AMBIENT_SKY_OFFSET+2]=m.z,l[Dg.AMBIENT_SKY_OFFSET+3]=m.w,l[Dg.AMBIENT_GROUND_OFFSET+0]=o.groundAlbedo.x,l[Dg.AMBIENT_GROUND_OFFSET+1]=o.groundAlbedo.y,l[Dg.AMBIENT_GROUND_OFFSET+2]=o.groundAlbedo.z,l[Dg.AMBIENT_GROUND_OFFSET+3]=a.envmap?null===(n=a.envmap)||void 0===n?void 0:n.mipmapLevel:1,In.toArray(l,i.matView,Dg.MAT_VIEW_OFFSET),In.toArray(l,i.node.worldMatrix,Dg.MAT_VIEW_INV_OFFSET),on.toArray(l,i.position,Dg.CAMERA_POS_OFFSET),In.toArray(l,i.matProj,Dg.MAT_PROJ_OFFSET),In.toArray(l,i.matProjInv,Dg.MAT_PROJ_INV_OFFSET),In.toArray(l,i.matViewProj,Dg.MAT_VIEW_PROJ_OFFSET),In.toArray(l,i.matViewProjInv,Dg.MAT_VIEW_PROJ_INV_OFFSET),l[Dg.CAMERA_POS_OFFSET+3]=this.getCombineSignY(),l[Dg.SURFACE_TRANSFORM_OFFSET]=i.surfaceTransform,l[Dg.SURFACE_TRANSFORM_OFFSET+1]=i.cameraUsage,l[Dg.SURFACE_TRANSFORM_OFFSET+2]=Math.cos(Bi(s.skybox.getRotationAngle())),l[Dg.SURFACE_TRANSFORM_OFFSET+3]=Math.sin(Bi(s.skybox.getRotationAngle()));var g=h.colorArray;l[Dg.GLOBAL_FOG_COLOR_OFFSET]=g.x,l[Dg.GLOBAL_FOG_COLOR_OFFSET+1]=g.y,l[Dg.GLOBAL_FOG_COLOR_OFFSET+2]=g.z,l[Dg.GLOBAL_FOG_COLOR_OFFSET+3]=g.z,l[Dg.GLOBAL_FOG_BASE_OFFSET]=h.fogStart,l[Dg.GLOBAL_FOG_BASE_OFFSET+1]=h.fogEnd,l[Dg.GLOBAL_FOG_BASE_OFFSET+2]=h.fogDensity,l[Dg.GLOBAL_FOG_ADD_OFFSET]=h.fogTop,l[Dg.GLOBAL_FOG_ADD_OFFSET+1]=h.fogRange,l[Dg.GLOBAL_FOG_ADD_OFFSET+2]=h.fogAtten,l[Dg.NEAR_FAR_OFFSET]=i.nearClip,l[Dg.NEAR_FAR_OFFSET+1]=i.farClip,l[Dg.NEAR_FAR_OFFSET+2]=i.getClipSpaceMinz(),l[Dg.VIEW_PORT_OFFSET]=s.shadingScale*i.window.width*i.viewport.x,l[Dg.VIEW_PORT_OFFSET+1]=s.shadingScale*i.window.height*i.viewport.y,l[Dg.VIEW_PORT_OFFSET+2]=s.shadingScale*i.window.width*i.viewport.z,l[Dg.VIEW_PORT_OFFSET+3]=s.shadingScale*i.window.height*i.viewport.w},t.getPCFRadius=function(t,e){var i=t.size.x;switch(e.shadowPcf){case BT.HARD:return 0;case BT.SOFT:return 1/(.5*i);case BT.SOFT_2X:return 2/(.5*i);case BT.SOFT_4X:return 3/(.5*i)}return 0},t.updatePlanarNormalAndDistance=function(t,e){on.normalize(yI,t.normal),e[Pg.PLANAR_NORMAL_DISTANCE_INFO_OFFSET+0]=yI.x,e[Pg.PLANAR_NORMAL_DISTANCE_INFO_OFFSET+1]=yI.y,e[Pg.PLANAR_NORMAL_DISTANCE_INFO_OFFSET+2]=yI.z,e[Pg.PLANAR_NORMAL_DISTANCE_INFO_OFFSET+3]=-t.distance},t.updateShadowUBOView=function(e,i,n,r){var s=e.device,o=r.scene.mainLight,a=e.pipelineSceneData,h=a.shadows,u=a.csmLayers,l=i,c=n,_=a.csmSupported,d=Zy(s)?0:1;if(o&&h.enabled){if(h.type===IT.ShadowMap){if(o.shadowEnabled){if(o.shadowFixedArea||o.csmLevel===DT.LEVEL_1||!_){var f=u.specialLayer.matShadowView,p=u.specialLayer.matShadowProj,m=u.specialLayer.matShadowViewProj,g=.1,y=0,v=0;o.shadowFixedArea?(g=o.shadowNear,y=o.shadowFar,v=0):(y=u.specialLayer.shadowCameraFar,v=1),In.toArray(l,f,Pg.MAT_LIGHT_VIEW_OFFSET),l[Pg.SHADOW_PROJ_DEPTH_INFO_OFFSET+0]=p.m10,l[Pg.SHADOW_PROJ_DEPTH_INFO_OFFSET+1]=p.m14,l[Pg.SHADOW_PROJ_DEPTH_INFO_OFFSET+2]=p.m11,l[Pg.SHADOW_PROJ_DEPTH_INFO_OFFSET+3]=p.m15,l[Pg.SHADOW_PROJ_INFO_OFFSET+0]=p.m00,l[Pg.SHADOW_PROJ_INFO_OFFSET+1]=p.m05,l[Pg.SHADOW_PROJ_INFO_OFFSET+2]=1/p.m00,l[Pg.SHADOW_PROJ_INFO_OFFSET+3]=1/p.m05,In.toArray(l,m,Pg.MAT_LIGHT_VIEW_PROJ_OFFSET),mI.set(g,y,0,1-o.shadowSaturation),tn.toArray(l,mI,Pg.SHADOW_NEAR_FAR_LINEAR_SATURATION_INFO_OFFSET),mI.set(sR.DIRECTIONAL,d,o.shadowNormalBias,v),tn.toArray(l,mI,Pg.SHADOW_LIGHT_PACKING_NBIAS_NULL_INFO_OFFSET)}else{for(var S=this.getPCFRadius(h,o),T=0;T=0;--e){var i=t[e];if(i.window.swapchain)return void(bT=i)}bT=null}(t);for(var e=0;e0){var a=o;o=s,s=a}var h=0;switch(t){case Ul.IDENTITY:h=0,i[h++]=-1,i[h++]=-1,i[h++]=n,i[h++]=o,i[h++]=1,i[h++]=-1,i[h++]=r,i[h++]=o,i[h++]=-1,i[h++]=1,i[h++]=n,i[h++]=s,i[h++]=1,i[h++]=1,i[h++]=r,i[h++]=s;break;case Ul.ROTATE_90:h=0,i[h++]=-1,i[h++]=-1,i[h++]=r,i[h++]=o,i[h++]=1,i[h++]=-1,i[h++]=r,i[h++]=s,i[h++]=-1,i[h++]=1,i[h++]=n,i[h++]=o,i[h++]=1,i[h++]=1,i[h++]=n,i[h++]=s;break;case Ul.ROTATE_180:h=0,i[h++]=-1,i[h++]=-1,i[h++]=n,i[h++]=s,i[h++]=1,i[h++]=-1,i[h++]=r,i[h++]=s,i[h++]=-1,i[h++]=1,i[h++]=n,i[h++]=o,i[h++]=1,i[h++]=1,i[h++]=r,i[h++]=o;break;case Ul.ROTATE_270:h=0,i[h++]=-1,i[h++]=-1,i[h++]=n,i[h++]=s,i[h++]=1,i[h++]=-1,i[h++]=n,i[h++]=o,i[h++]=-1,i[h++]=1,i[h++]=r,i[h++]=s,i[h++]=1,i[h++]=1,i[h++]=r,i[h++]=o}return i},i._createQuadInputAssembler=function(){var t=new gD,e=4*Float32Array.BYTES_PER_ELEMENT,i=4*e,n=this._device.createBuffer(new Xc(Xl.VERTEX|Xl.TRANSFER_DST,Kl.DEVICE|Kl.HOST,i,e));if(!n)return t;var r=Uint8Array.BYTES_PER_ELEMENT,s=6*r,o=this._device.createBuffer(new Xc(Xl.INDEX|Xl.TRANSFER_DST,Kl.DEVICE,s,r));if(!o)return t;var a=new Uint8Array(6);a[0]=0,a[1]=1,a[2]=2,a[3]=1,a[4]=3,a[5]=2,o.update(a);var h=new Array(2);h[0]=new u_("a_position",Hl.RG32F),h[1]=new u_("a_texCoord",Hl.RG32F);var u=this._device.createInputAssembler(new c_(h,[n],o));return t.quadIB=o,t.quadVB=n,t.quadIA=u,t},i.updateQuadVertexData=function(t,e){var i=this._lastUsedRenderArea;if(i.x!==t.x||i.y!==t.y||i.width!==t.width||i.height!==t.height){var n=this._genQuadVertexData(Ul.IDENTITY,t);this._quadVBOffscreen.update(n);var r=this._genQuadVertexData(e.swapchain&&e.swapchain.surfaceTransform||Ul.IDENTITY,t);this._quadVBOnscreen.update(r),i.copy(t)}},i.destroy=function(){for(var e,i,n=0;n>1,r>>1)),t.prefilterFramebuffer=e.createFramebuffer(new S_(t.renderPass,[t.prefiterTex])),n>>=1,r>>=1;for(var s=0;s<6;++s)t.downsampleTexs.push(e.createTexture(new Qc(Jl.TEX2D,Ql.COLOR_ATTACHMENT|Ql.SAMPLED,Hl.RGBA8,n>>1,r>>1))),t.downsampleFramebuffers[s]=e.createFramebuffer(new S_(t.renderPass,[t.downsampleTexs[s]])),t.upsampleTexs.push(e.createTexture(new Qc(Jl.TEX2D,Ql.COLOR_ATTACHMENT|Ql.SAMPLED,Hl.RGBA8,n,r))),t.upsampleFramebuffers[s]=e.createFramebuffer(new S_(t.renderPass,[t.upsampleTexs[s]])),n>>=1,r>>=1;t.combineTex=e.createTexture(new Qc(Jl.TEX2D,Ql.COLOR_ATTACHMENT|Ql.SAMPLED,Hl.RGBA8,this._width,this._height)),t.combineFramebuffer=e.createFramebuffer(new S_(t.renderPass,[t.combineTex])),t.sampler=this.globalDSManager.linearSampler}},i.on=function(t,e,i,n){return this._eventProcessor.on(t,e,i,n)},i.once=function(t,e,i){return this._eventProcessor.once(t,e,i)},i.off=function(t,e,i){this._eventProcessor.off(t,e,i)},i.emit=function(t,e,i,n,r,s){this._eventProcessor.emit(t,e,i,n,r,s)},i.targetOff=function(t){this._eventProcessor.targetOff(t)},i.removeAll=function(t){this._eventProcessor.removeAll(t)},i.hasEventListener=function(t,e,i){return this._eventProcessor.hasEventListener(t,e,i)},n(e,[{key:"tag",get:function(){return this._tag}},{key:"flows",get:function(){return this._flows}},{key:"quadIAOnscreen",get:function(){return this._quadIAOnscreen}},{key:"quadIAOffscreen",get:function(){return this._quadIAOffscreen}},{key:"constantMacros",get:function(){return this._constantMacros}},{key:"macros",get:function(){return this._macros}},{key:"device",get:function(){return this._device}},{key:"globalDSManager",get:function(){return this._globalDSManager}},{key:"descriptorSetLayout",get:function(){return this._globalDSManager.descriptorSetLayout}},{key:"descriptorSet",get:function(){return this._descriptorSet}},{key:"commandBuffers",get:function(){return this._commandBuffers}},{key:"pipelineUBO",get:function(){return this._pipelineUBO}},{key:"pipelineSceneData",get:function(){return this._pipelineSceneData}},{key:"profiler",get:function(){return this._profiler},set:function(t){this._profiler=t}},{key:"geometryRenderer",get:function(){return this._geometryRenderer}},{key:"clusterEnabled",get:function(){return this._clusterEnabled},set:function(t){this._clusterEnabled=t}},{key:"bloomEnabled",get:function(){return this._bloomEnabled},set:function(t){this._bloomEnabled=t}},{key:"shadingScale",get:function(){return this._pipelineSceneData.shadingScale},set:function(t){this._pipelineSceneData.shadingScale!==t&&(this._pipelineSceneData.shadingScale=t,this.emit(II.ATTACHMENT_SCALE_CAHNGED,t))}}]),e}(of),LI=ks(MI.prototype,"_tag",[io],(function(){return 0})),NI=ks(MI.prototype,"_flows",[PI,io],(function(){return[]})),OI=MI))||OI));v.RenderPipeline=yD,function(t){t[t.BLOOM=18]="BLOOM",t[t.POST_PROCESS=19]="POST_PROCESS",t[t.UI=20]="UI"}(FI||(FI={})),function(t){t[t.AR=5]="AR",t[t.FORWARD=10]="FORWARD"}(kI||(kI={})),function(t){t[t.SHADOW=0]="SHADOW",t[t.FORWARD=1]="FORWARD",t[t.UI=10]="UI"}(VI||(VI={})),function(t){t[t.GBUFFER=10]="GBUFFER",t[t.LIGHTING=15]="LIGHTING",t[t.TRANSPARENT=18]="TRANSPARENT"}(GI||(GI={})),function(t){t[t.SHADOW=0]="SHADOW",t[t.MAIN=1]="MAIN",t[t.UI=10]="UI"}(UI||(UI={})),Se(Jl),Se(Ql),Se(cc),Se(lc),Se(_c),Se(Hl),function(t){t[t.SCENE=0]="SCENE",t[t.POSTPROCESS=1]="POSTPROCESS",t[t.UI=2]="UI"}(_D||(_D={})),Se(_D),zI=qs("RenderTextureDesc"),HI=xo(Jl),WI=xo(Ql),jI=xo(Hl),zI((XI=function(){this.name=qI&&qI(),this.type=YI&&YI(),this.usage=KI&&KI(),this.format=JI&&JI(),this.width=QI&&QI(),this.height=ZI&&ZI()},qI=ks(XI.prototype,"name",[io],(function(){return""})),YI=ks(XI.prototype,"type",[HI],(function(){return Jl.TEX2D})),KI=ks(XI.prototype,"usage",[WI],(function(){return Ql.COLOR_ATTACHMENT})),JI=ks(XI.prototype,"format",[jI],(function(){return Hl.UNKNOWN})),QI=ks(XI.prototype,"width",[io],(function(){return-1})),ZI=ks(XI.prototype,"height",[io],(function(){return-1})),XI));var vD=($I=qs("RenderTextureConfig"),tB=xo(rR),$I((iB=function(){this.name=nB&&nB(),this.texture=rB&&rB()},nB=ks(iB.prototype,"name",[io],(function(){return""})),rB=ks(iB.prototype,"texture",[tB],(function(){return null})),eB=iB))||eB);sB=qs("MaterialConfig"),oB=xo(xT),sB((aB=function(){this.name=hB&&hB(),this.material=uB&&uB()},hB=ks(aB.prototype,"name",[io],(function(){return""})),uB=ks(aB.prototype,"material",[oB],(function(){return null})),aB)),lB=qs("FrameBufferDesc"),cB=xo([Je]),_B=xo(rR),lB((dB=function(){this.name=fB&&fB(),this.renderPass=pB&&pB(),this.colorTextures=mB&&mB(),this.depthStencilTexture=gB&&gB(),this.texture=yB&&yB()},fB=ks(dB.prototype,"name",[io],(function(){return""})),pB=ks(dB.prototype,"renderPass",[io],(function(){return 0})),mB=ks(dB.prototype,"colorTextures",[cB],(function(){return[]})),gB=ks(dB.prototype,"depthStencilTexture",[io],(function(){return""})),yB=ks(dB.prototype,"texture",[_B],(function(){return null})),dB));var SD,TD=(vB=qs("ColorDesc"),SB=xo(Hl),TB=xo(lc),AB=xo(cc),bB=xo(_c),EB=xo(_c),vB((wB=function(){this.format=xB&&xB(),this.loadOp=RB&&RB(),this.storeOp=IB&&IB(),this.sampleCount=BB&&BB(),this.beginAccesses=DB&&DB(),this.endAccesses=PB&&PB()},xB=ks(wB.prototype,"format",[SB],(function(){return Hl.UNKNOWN})),RB=ks(wB.prototype,"loadOp",[TB],(function(){return lc.CLEAR})),IB=ks(wB.prototype,"storeOp",[AB],(function(){return cc.STORE})),BB=ks(wB.prototype,"sampleCount",[io],(function(){return 1})),DB=ks(wB.prototype,"beginAccesses",[bB],(function(){return _c.NONE})),PB=ks(wB.prototype,"endAccesses",[EB],(function(){return _c.COLOR_ATTACHMENT_WRITE})),CB=wB))||CB),AD=(OB=qs("DepthStencilDesc"),MB=xo(Hl),LB=xo(lc),NB=xo(cc),FB=xo(lc),kB=xo(cc),VB=xo(_c),GB=xo(_c),OB((zB=function(){this.format=HB&&HB(),this.depthLoadOp=WB&&WB(),this.depthStoreOp=jB&&jB(),this.stencilLoadOp=XB&&XB(),this.stencilStoreOp=qB&&qB(),this.sampleCount=YB&&YB(),this.beginAccesses=KB&&KB(),this.endAccesses=JB&&JB()},HB=ks(zB.prototype,"format",[MB],(function(){return Hl.UNKNOWN})),WB=ks(zB.prototype,"depthLoadOp",[LB],(function(){return lc.CLEAR})),jB=ks(zB.prototype,"depthStoreOp",[NB],(function(){return cc.STORE})),XB=ks(zB.prototype,"stencilLoadOp",[FB],(function(){return lc.CLEAR})),qB=ks(zB.prototype,"stencilStoreOp",[kB],(function(){return cc.STORE})),YB=ks(zB.prototype,"sampleCount",[io],(function(){return 1})),KB=ks(zB.prototype,"beginAccesses",[VB],(function(){return _c.NONE})),JB=ks(zB.prototype,"endAccesses",[GB],(function(){return _c.DEPTH_STENCIL_ATTACHMENT_WRITE})),UB=zB))||UB);QB=qs("RenderPassDesc"),ZB=xo([TD]),$B=xo(AD),QB((tD=function(){this.index=eD&&eD(),this.colorAttachments=iD&&iD(),this.depthStencilAttachment=nD&&nD()},eD=ks(tD.prototype,"index",[io],(function(){return-1})),iD=ks(tD.prototype,"colorAttachments",[ZB],(function(){return[]})),nD=ks(tD.prototype,"depthStencilAttachment",[$B],(function(){return new AD})),tD)),function(t){t[t.FRONT_TO_BACK=0]="FRONT_TO_BACK",t[t.BACK_TO_FRONT=1]="BACK_TO_FRONT"}(SD||(SD={})),Se(SD);var bD=(rD=qs("RenderQueueDesc"),sD=xo(SD),oD=xo([Je]),rD((hD=function(){this.isTransparent=uD&&uD(),this.sortMode=lD&&lD(),this.stages=cD&&cD()},uD=ks(hD.prototype,"isTransparent",[io],(function(){return!1})),lD=ks(hD.prototype,"sortMode",[sD],(function(){return SD.FRONT_TO_BACK})),cD=ks(hD.prototype,"stages",[oD],(function(){return[]})),aD=hD))||aD);function ED(t,e){return t.hash-e.hash||t.depth-e.depth||t.shaderId-e.shaderId}function CD(t,e){return t.priority-e.priority||t.hash-e.hash||e.depth-t.depth||t.shaderId-e.shaderId}var wD=function(){function t(t){this.queue=void 0,this._passDesc=void 0,this._passPool=void 0,this._passDesc=t,this._passPool=new Du((function(){return{priority:0,hash:0,depth:0,shaderId:0,subModel:null,passIdx:0}}),64),this.queue=new Pu(64,this._passDesc.sortFunc)}var e=t.prototype;return e.clear=function(){this.queue.clear(),this._passPool.reset()},e.insertRenderPass=function(t,e,i){var n=t.model.subModels[e],r=n.passes[i],s=n.shaders[i];if(r.blendState.targets[0].blend!==this._passDesc.isTransparent||!(r.phase&this._passDesc.phases))return!1;var o=0|r.priority<<16|n.priority<<8|i,a=this._passPool.add();return a.priority=t.model.priority,a.hash=o,a.depth=t.depth||0,a.shaderId=s.typedID,a.subModel=n,a.passIdx=i,this.queue.push(a),!0},e.sort=function(){this.queue.sort()},e.recordCommandBuffer=function(t,e,i){for(var n=0;n0){this._renderQueues.forEach(ID);for(var A=0;A0&&(this._stageDesc||(this._stageDesc=i.createDescriptorSet(new b_(u.localSetLayout)),this._localUBO=i.createBuffer(new Xc(Xl.UNIFORM|Xl.TRANSFER_DST,Kl.DEVICE,Xg.SIZE,Xg.SIZE)),this._stageDesc.bindBuffer(Xg.BINDING,this._localUBO)),this._stageDesc.update(),r.bindPipelineState(_),r.bindDescriptorSet(Cg.MATERIAL,u.descriptorSet),r.bindDescriptorSet(Cg.LOCAL,this._stageDesc),r.bindInputAssembler(c),r.draw(c)),this._uiPhase.render(t,h),CT(i,h,r,e.profiler,t),r.endRenderPass()},e}(RI)).initInfo={name:"PostProcessStage",priority:FI.POST_PROCESS,tag:0},eP=ks((tP=nP).prototype,"_postProcessMaterial",[QD,io],(function(){return null})),iP=ks(tP.prototype,"renderQueues",[ZD,io],(function(){return[]})),$D=tP))||$D)),fP=function(){function t(){this._enabled=!1,this._minPos=new on(0,0,0),this._maxPos=new on(0,0,0),this._depth=0}return t.prototype.initialize=function(t){this._enabled=t.enabled,this._minPos=t.minPos,this._maxPos=t.maxPos,this._depth=t.depth},n(t,[{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled=t}},{key:"minPos",get:function(){return this._minPos},set:function(t){this._minPos=t}},{key:"maxPos",get:function(){return this._maxPos},set:function(t){this._maxPos=t}},{key:"depth",get:function(){return this._depth},set:function(t){this._depth=t}}]),t}(),pP=new In,mP=new In,gP=new In,yP=new In,vP=new In,SP=new In,TP=new In,AP=new on(0,0,0),bP=new on,EP=new Ln,CP=new on,wP=new on,xP=new on(1e7,1e7,1e7),RP=new on(-1e7,-1e7,-1e7),IP=new on,BP=0,DP=0,PP=function(){function t(t){this._shadowObjects=[],this._shadowCameraFar=0,this._level=void 0,this._matShadowView=new In,this._matShadowProj=new In,this._matShadowViewProj=new In,this._validFrustum=new xs,this._splitFrustum=new xs,this._lightViewFrustum=new xs,this._castLightViewBoundingBox=new Ss,this._level=t,this._validFrustum.accurate=!0,this._splitFrustum.accurate=!0,this._lightViewFrustum.accurate=!0}var e=t.prototype;return e.copyToValidFrustum=function(t){xs.copy(this._validFrustum,t)},e.calculateValidFrustumOrtho=function(t,e,i,n,r){xs.createOrtho(this._validFrustum,t,e,i,n,r)},e.calculateSplitFrustum=function(t,e,i,n){this._splitFrustum.split(i,n,t.aspect,t.fov,e)},e.destroy=function(){this._shadowObjects.length=0},e.createMatrix=function(t,e,i){var n=v.director.root.device,r=t.shadowInvisibleOcclusionRange;xs.copy(this._lightViewFrustum,this._splitFrustum),In.fromRT(mP,t.node.rotation,AP),In.invert(gP,mP);var s,o,a=gP.clone();this._lightViewFrustum.transform(gP),Ss.fromPoints(this._castLightViewBoundingBox,xP,RP),this._castLightViewBoundingBox.mergeFrustum(this._lightViewFrustum),t.csmOptimizationMode===PT.DisableRotationFix?(s=2*this._castLightViewBoundingBox.halfExtents.x,o=2*this._castLightViewBoundingBox.halfExtents.y):s=o=on.distance(this._lightViewFrustum.vertices[0],this._lightViewFrustum.vertices[6]);var h=v.director.root.pipeline.pipelineSceneData.csmSupported?t.csmLevel:1;if(h>1&&t.csmOptimizationMode===PT.RemoveDuplicates)if(this._level>=h-1)DP=this._castLightViewBoundingBox.halfExtents.z,BP=this._castLightViewBoundingBox.center.z;else{var u=Math.abs(this._castLightViewBoundingBox.center.z-BP)+DP;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(IP.set(c.x,c.y,c.z+l+r),on.transformMat4(IP,IP,mP),In.fromRT(mP,t.node.rotation,IP),In.invert(gP,mP),!i){var _=.5*s,d=.5*o;In.ortho(yP,-_,_,-d,d,.1,this._shadowCameraFar,n.capabilities.clipSpaceMinZ,n.capabilities.clipSpaceSignY),In.multiply(SP,yP,a),on.transformMat4(bP,IP,SP);var f=2/e;EP.set(f,f);var p=bP.x%EP.x,m=bP.y%EP.y;CP.set(bP.x-p,bP.y-m,bP.z),In.invert(TP,SP),on.transformMat4(wP,CP,TP),In.fromRT(mP,t.node.rotation,wP),In.invert(gP,mP),In.multiply(vP,yP,gP),In.copy(this._matShadowView,gP),In.copy(this._matShadowProj,yP),In.copy(this._matShadowViewProj,vP)}xs.createOrtho(this._validFrustum,s,o,.1,this._shadowCameraFar,mP)},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}(),OP=function(t){function e(e){var i;return(i=t.call(this,e)||this)._splitCameraNear=0,i._splitCameraFar=0,i._csmAtlas=new tn,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=v.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}(PP),MP=function(){function t(){this._castShadowObjects=[],this._layerObjects=new Pu(64),this._layers=[],this._levelCount=0,this._specialLayer=new PP(1),this._shadowDistance=0;for(var t=0;t1?.5*i.size.x:i.size.x;if(!(r<0)){this._getCameraWorldMatrix(pP,t);for(var s=n-1;s>=0;s--){var o=this._layers[s],a=o.splitCameraNear,h=o.splitCameraFar;o.calculateSplitFrustum(t,pP,a,h),o.createMatrix(e,r,!1)}n===DT.LEVEL_1?(this._specialLayer.shadowCameraFar=this._layers[0].shadowCameraFar,In.copy(this._specialLayer.matShadowView,this._layers[0].matShadowView),In.copy(this._specialLayer.matShadowProj,this._layers[0].matShadowProj),In.copy(this._specialLayer.matShadowViewProj,this._layers[0].matShadowViewProj),this._specialLayer.copyToValidFrustum(this._layers[0].validFrustum)):(this._specialLayer.calculateSplitFrustum(t,pP,.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();In.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}(),LP=function(){function t(){this._enabled=!0,this._blurRadius=.01,this._sssIntensity=3}return t.prototype.initialize=function(t){this._enabled=t.enabled,this._blurRadius=t.blurRadius,this._sssIntensity=t.sssIntensity},n(t,[{key:"enabled",get:function(){return this._enabled},set:function(t){this._enabled=t}},{key:"blurRadius",get:function(){return this._blurRadius},set:function(t){this._blurRadius=t}},{key:"sssIntensity",get:function(){return this._sssIntensity},set:function(t){this._sssIntensity=t}}]),t}(),NP=t("db",function(){function t(){this.fog=new WT,this.ambient=new dg,this.skybox=new GT,this.shadows=new MT,this.csmLayers=new MP,this.octree=new fP,this.skin=new LP,this.postSettings=new fE,this.lightProbes=v.internal.LightProbes?new v.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 xT,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 Xc(Xl.VERTEX|Xl.TRANSFER_DST,Kl.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,o=36*s;this._occlusionQueryIndicesBuffer=t.createBuffer(new Xc(Xl.INDEX|Xl.TRANSFER_DST,Kl.DEVICE,o,s)),this._occlusionQueryIndicesBuffer.update(r);var a=[new u_("a_position",Hl.RGB32F)],h=new c_(a,[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}());!function(t){t[t.NONE=0]="NONE",t[t.FXAA=1]="FXAA"}(rP||(rP={}));var FP,kP,VP,GP,UP,zP,HP,WP=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r>=1,this._renderArea.height>>=1;var i=e.commandBuffers[0],n=e.pipelineSceneData.bloomMaterial.passes[0],r=e.getPipelineRenderData(),s=r.bloom,o=new Float32Array(XP.COUNT);o[XP.TEXTURE_SIZE_OFFSET+2]=this.threshold,i.updateBuffer(this._bloomUBO[0],o),i.beginRenderPass(s.renderPass,s.prefilterFramebuffer,this._renderArea,jP,0,0),i.bindDescriptorSet(Cg.GLOBAL,e.descriptorSet),n.descriptorSet.bindBuffer(0,this._bloomUBO[0]),n.descriptorSet.bindTexture(1,r.outputRenderTargets[0]),n.descriptorSet.bindSampler(1,s.sampler),n.descriptorSet.update(),i.bindDescriptorSet(Cg.MATERIAL,n.descriptorSet);var a=t.window.swapchain?e.quadIAOffscreen:e.quadIAOnscreen,h=null,u=n.getShaderVariant();null!=n&&null!=u&&null!=a&&(h=lT.getOrCreatePipelineState(e.device,n,u,s.renderPass,a)),null!=h&&(i.bindPipelineState(h),i.bindInputAssembler(a),i.draw(a)),i.endRenderPass()},i._downsamplePass=function(t,e){e.generateRenderArea(t,this._renderArea),this._renderArea.width>>=1,this._renderArea.height>>=1;for(var i=e.commandBuffers[0],n=e.pipelineSceneData.bloomMaterial,r=e.getPipelineRenderData().bloom,s=new Float32Array(XP.COUNT),o=0;o>=1,this._renderArea.height>>=1,i.beginRenderPass(r.renderPass,r.downsampleFramebuffers[o],this._renderArea,jP,0,0);var a=n.passes[1+o],h=a.getShaderVariant();a.descriptorSet.bindBuffer(0,this._bloomUBO[o+1]),0===o?a.descriptorSet.bindTexture(1,r.prefiterTex):a.descriptorSet.bindTexture(1,r.downsampleTexs[o-1]),a.descriptorSet.bindSampler(1,r.sampler),a.descriptorSet.update(),i.bindDescriptorSet(Cg.MATERIAL,a.descriptorSet);var u=t.window.swapchain?e.quadIAOffscreen:e.quadIAOnscreen,l=null;null!=a&&null!=h&&null!=u&&(l=lT.getOrCreatePipelineState(e.device,a,h,r.renderPass,u)),null!=l&&(i.bindPipelineState(l),i.bindInputAssembler(u),i.draw(u)),i.endRenderPass()}},i._upsamplePass=function(t,e){var i=e.getPipelineRenderData().bloom;e.generateRenderArea(t,this._renderArea),this._renderArea.width>>=this.iterations+1,this._renderArea.height>>=this.iterations+1;for(var n=e.commandBuffers[0],r=e.pipelineSceneData.bloomMaterial,s=new Float32Array(XP.COUNT),o=0;o=0;h--){var u=r.array[h];if(u){var l=u.model;l&&l.enabled&&l.node&&((a&l.node.layer)===l.node.layer||a&l.visFlags)&&l.worldBounds&&l.castShadow?as.aabbFrustum(l.worldBounds,s)&&(o.push(u),i.level0?.5*(1-Math.floor(o/2))*h.y:.5*Math.floor(o/2)*h.y,this._renderArea.width=.5*h.x,this._renderArea.height=.5*h.y}break;case sR.SPOT:this._renderArea.x=0,this._renderArea.y=0,this._renderArea.width=h.x,this._renderArea.height=h.y}var c=this._shadowFrameBuffer.renderPass;s.beginRenderPass(c,this._shadowFrameBuffer,this._renderArea,uO,t.clearDepth,t.clearStencil),s.bindDescriptorSet(Cg.GLOBAL,r),this._additiveShadowQueue.recordCommandBuffer(a,c,s),s.endRenderPass(),this._isShadowMapCleared=!1}},i.activate=function(e,i){t.prototype.activate.call(this,e,i),this._additiveShadowQueue=new hO(e),this._isShadowMapCleared=!1},e}(RI)).initInfo={name:"ShadowStage",priority:kI.FORWARD,tag:0},$P=tO))||$P),cO=[],_O=t("dm",qs("ShadowFlow")(((iO=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r=(Bg.COUNT+Dg.COUNT+Pg.COUNT+Og.COUNT)/4,e.macros.CC_SUPPORT_CASCADED_SHADOW_MAP=e.pipelineSceneData.csmSupported,e.macros.CC_SHADOW_TYPE=0,e.macros.CC_DIR_SHADOW_PCF_TYPE=BT.HARD,e.macros.CC_DIR_LIGHT_SHADOW_TYPE=0,e.macros.CC_CASCADED_LAYERS_TRANSITION=0,e.onGlobalPipelineStateChanged()},i.render=function(t){var e=this._pipeline,i=e.pipelineSceneData.shadows,n=e.pipelineSceneData.csmLayers,r=e.pipelineSceneData.shadowFrameBufferMap,s=n.castShadowObjects,o=this._pipeline.pipelineSceneData.validPunctualLights;if(i.enabled&&i.type===IT.ShadowMap){for(var a=0,h=0;a0)))for(var o=0;othis._lightBufferCount&&(this._firstLightBufferView.destroy(),this._lightBufferCount=Vi(o.length),this._lightBuffer.resize(this._lightBufferStride*this._lightBufferCount),this._lightBufferData=new Float32Array(this._lightBufferElementCount*this._lightBufferCount),this._firstLightBufferView=Ed.gfxDevice.createBuffer(new qc(this._lightBuffer,0,Qg.SIZE)));for(var a=0,h=0;a-1&&this.additiveInstanceQueues.splice(e,1)},i.initialize=function(e){return t.prototype.initialize.call(this,e),e.renderQueues&&(this.renderQueues=e.renderQueues),!0},i.activate=function(e,i){t.prototype.activate.call(this,e,i);for(var n=0;n1e-4&&(i=Math.log(e)/Math.log(1.1),i=xi((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 on(0,0,0),new on(1,1,1));r.multiplyScalar(255);var s,o,a=pn(r).add((s=r.subtract(pn(r)))<(o=new on(.5,.5,.5))?o:s);return new tn(a.x/255,a.y/255,a.z/255,i/255)}(this._rgbeColor);sM[0].x=r.x,sM[0].y=r.y,sM[0].z=r.z,sM[0].w=r.w}var s=e.device;i.beginRenderPass(n,this._frameBuffer,this._renderArea,sM,this._probe.camera.clearDepth,this._probe.camera.clearStencil),i.bindDescriptorSet(Cg.GLOBAL,e.descriptorSet),this._probeRenderQueue.recordCommandBuffer(s,n,i),i.endRenderPass(),e.pipelineUBO.updateCameraUBO(t)},i.activate=function(e,i){t.prototype.activate.call(this,e,i),this._probeRenderQueue=new rM(e)},e}(RI)).initInfo={name:"ReflectionProbeStage",priority:kI.FORWARD,tag:0},KO=JO))||KO),aM=t("du",qs("ReflectionProbeFlow")(((ZO=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.initialize=function(e){if(t.prototype.initialize.call(this,e),0===this._stages.length){var i=new oM;i.initialize(oM.initInfo),this._stages.push(i)}return!0},i.activate=function(e){t.prototype.activate.call(this,e)},i.render=function(t){if(v.internal.reflectionProbeManager)for(var e=v.internal.reflectionProbeManager.getProbes(),i=0;i8?J(12004,8):(this._passes=t,this._flushPassInfo(),this._descriptorSet&&(this._descriptorSet.destroy(),cM.layout=t[0].localSetLayout,this._descriptorSet=this._device.createDescriptorSet(cM)))}},{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}();t("am",uM),function(t){t[t.NONE=0]="NONE",t[t.BAKED_CUBEMAP=1]="BAKED_CUBEMAP",t[t.PLANAR_REFLECTION=2]="PLANAR_REFLECTION",t[t.BLEND_PROBES=3]="BLEND_PROBES",t[t.BLEND_PROBES_AND_SKYBOX=4]="BLEND_PROBES_AND_SKYBOX"}(uM||t("am",uM={}));var dM,fM=new In,pM=[{name:"CC_RECEIVE_SHADOW",value:!0}],mM=[{name:"CC_USE_LIGHTMAP",value:1}],gM=[{name:"CC_USE_LIGHTMAP",value:2}],yM=[{name:"CC_LIGHT_MAP_VERSION",value:2}],vM=[{name:"CC_USE_LIGHT_PROBE",value:!0}];!function(t){t[t.DEFAULT=0]="DEFAULT",t[t.SKINNING=1]="SKINNING",t[t.BAKED_SKINNING=2]="BAKED_SKINNING",t[t.BATCH_2D=3]="BATCH_2D",t[t.PARTICLE_BATCH=4]="PARTICLE_BATCH",t[t.LINE=5]="LINE"}(dM||(dM={}));var SM,TM,AM,bM,EM=new $c(ic.LINEAR,ic.LINEAR,ic.NONE,nc.CLAMP,nc.CLAMP,nc.CLAMP),CM=new $c(ic.LINEAR,ic.LINEAR,ic.LINEAR,nc.CLAMP,nc.CLAMP,nc.CLAMP),wM=function(){function t(){this.type=dM.DEFAULT,this.scene=null,this.isDynamicBatching=!1,this._worldBounds=null,this._modelBounds=null,this._subModels=[],this._node=null,this._transform=null,this._device=void 0,this._inited=!1,this._descriptorSetCount=1,this._updateStamp=-1,this._localDataUpdated=!0,this._localData=new Float32Array(Xg.COUNT),this._localBuffer=null,this._localSHData=null,this._localSHBuffer=null,this._lightmap=null,this._lightmapUVParam=new tn,this._tetrahedronIndex=-1,this._lastWorldBoundCenter=new on(1/0,1/0,1/0),this._useLightProbe=!1,this._worldBoundBuffer=null,this._receiveShadow=!1,this._castShadow=!1,this._receiveDirLight=!0,this._shadowBias=0,this._shadowNormalBias=0,this._reflectionProbeId=-1,this._reflectionProbeBlendId=-1,this._reflectionProbeBlendWeight=0,this._enabled=!0,this._visFlags=im.Enum.NONE,this._priority=0,this._bakeToReflectionProbe=!0,this._reflectionProbeType=uM.NONE,this._device=Ed.gfxDevice}var e=t.prototype;return e.initialize=function(){this._inited||(this._receiveShadow=!0,this.castShadow=!1,this.enabled=!0,this.visFlags=im.Enum.NONE,this._inited=!0,this._bakeToReflectionProbe=!0,this._reflectionProbeType=uM.NONE)},e.destroy=function(){for(var t=this._subModels,e=0;e=0?a.updateInstancedWorldMatrix(r,h):s=!0}(s||n)&&this._localBuffer&&(In.toArray(this._localData,r,Xg.MAT_WORLD_OFFSET),In.invert(fM,r),In.transpose(fM,fM),In.toArray(this._localData,fM,Xg.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=v.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?CM:EM),r=this._subModels,s=0;s1&&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){on.normalize(this._dir,t)}},{key:"illuminance",get:function(){return v.director.root.pipeline.pipelineSceneData.isHDR?this._illuminanceHDR:this._illuminanceLDR},set:function(t){v.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,MT.MAX_FAR)}},{key:"shadowInvisibleOcclusionRange",get:function(){return this._shadowInvisibleOcclusionRange},set:function(t){this._shadowInvisibleOcclusionRange=Math.min(t,MT.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,MT.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}(AR),BM=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=void 0,e._aabb=void 0,e._aabb=Ss.create(),e._pos=new on,e._type=sR.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/TR(.15),this.luminanceLDR=1},i.update=function(){if(this._node&&(this._node.hasChangedFlags||this._needUpdate)){this._node.getWorldPosition(this._pos);var t=this._range;Ss.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 v.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR:this._luminanceLDR},set:function(t){v.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}(AR),DM=new on(0,0,-1),PM=new Sn,OM=new In,MM=new In,LM=new In,NM=new In,FM=function(t){function e(){var e;return(e=t.call(this)||this)._dir=new on(1,-1,-1),e._range=5,e._spotAngle=Math.cos(Math.PI/6),e._pos=void 0,e._aabb=void 0,e._frustum=void 0,e._angle=0,e._needUpdate=!1,e._size=.15,e._luminanceHDR=0,e._luminanceLDR=0,e._shadowEnabled=!1,e._shadowPcf=BT.HARD,e._shadowBias=1e-5,e._shadowNormalBias=0,e._aabb=Ss.create(),e._frustum=xs.create(),e._pos=new on,e._type=sR.SPOT,e}s(e,t);var i=e.prototype;return i.initialize=function(){t.prototype.initialize.call(this),this.size=.15,this.luminanceHDR=1700/TR(.15),this.luminanceLDR=1,this.range=Math.cos(Math.PI/6),this._dir.set(new on(1,-1,-1))},i.update=function(){this._node&&(this._node.hasChangedFlags||this._needUpdate)&&(this._node.getWorldPosition(this._pos),on.transformQuat(this._dir,DM,this._node.getWorldRotation(PM)),on.normalize(this._dir,this._dir),Ss.set(this._aabb,this._pos.x,this._pos.y,this._pos.z,this._range,this._range,this._range),this._node.getWorldRT(OM),In.invert(OM,OM),In.perspective(MM,this._angle,1,.001,this._range),In.multiply(LM,MM,OM),this._frustum.update(LM,NM),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 v.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR:this._luminanceLDR},set:function(t){v.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:"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}(AR),kM=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=void 0,e._aabb=void 0,e._aabb=Ss.create(),e._pos=new on,e._type=sR.POINT,e}s(e,t);var i=e.prototype;return i.initialize=function(){t.prototype.initialize.call(this),this.range=1,this.luminanceHDR=1700/TR(1),this.luminanceLDR=1},i.update=function(){if(this._node&&(this._node.hasChangedFlags||this._needUpdate)){this._node.getWorldPosition(this._pos);var t=this._range;Ss.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 v.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR:this._luminanceLDR},set:function(t){v.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}(AR),VM=new on(0,0,-1),GM=function(t){function e(){var e;return(e=t.call(this)||this)._dir=new on(0,0,-1),e._pos=new on(0,0,0),e._scale=new on(1,1,1),e._right=new on(1,0,0),e._illuminanceHDR=dg.SUN_ILLUM,e._illuminanceLDR=1,e._type=sR.RANGED_DIRECTIONAL,e}s(e,t);var i=e.prototype;return i.initialize=function(){t.prototype.initialize.call(this),this.illuminance=dg.SUN_ILLUM},i.update=function(){this._node&&this._node.hasChangedFlags&&(this._node.getWorldPosition(this._pos),this._node.getWorldScale(this._scale),on.transformQuat(this._dir,VM,this._node.worldRotation),on.transformQuat(this._right,on.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 v.director.root.pipeline.pipelineSceneData.isHDR?this._illuminanceHDR:this._illuminanceLDR},set:function(t){v.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}(AR),UM=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}(),zM=function(){function t(){this.scene=void 0,this.node=null,this._device=void 0,this.enabled=!0,this._localBoundaryCenter=new on(0,0,0),this._objectSize=1,this._lodDataArray=[],this._lockedLODLevelVec=[],this._isLockLevelChanged=!1,this._device=Ed.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===wx.PERSPECTIVE&&(e=on.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===wx.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}(),HM=Object.freeze({__proto__:null,get CameraFOVAxis(){return Cx},get CameraProjection(){return wx},get CameraAperture(){return xx},get CameraISO(){return Rx},get CameraShutter(){return Ix},get CameraType(){return Bx},get TrackingType(){return Dx},get CameraUsage(){return Px},SKYBOX_FLAG:Ux,Camera:Hx,get ModelType(){return dM},Model:wM,SubModel:_M,Ambient:dg,EnvironmentLightingType:VT,Skybox:GT,ShadowSize:RT,ShadowType:IT,PCFType:BT,CSMLevel:DT,CSMOptimizationMode:PT,Shadows:MT,FogType:zT,FOG_TYPE_NONE:HT,Fog:WT,Octree:fP,Skin:LP,ColorTemperatureToRGB:hR,get LightType(){return sR},nt2lm:TR,Light:AR,DirectionalLight:IM,SphereLight:BM,SpotLight:FM,PointLight:kM,RangedDirectionalLight:GM,get ProbeClearFlag(){return tR},get ProbeType(){return eR},ReflectionProbe:aR,LODData:UM,LODGroup:zM,ToneMappingType:dE,PostSettings:fE}),WM=function(){function t(t){this._root=void 0,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 XM(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=d(this._lodGroups);!(t=e()).done;){var i=t.value;this._lodStateCache.removeLodGroup(i)}this._lodGroups.length=0},e.onGlobalPipelineStateChanged=function(){for(var t,e=d(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}(),jM=function(){this.usedLevel=-1,this.lastUsedLevel=-1,this.transformDirty=!0},XM=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=d(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=d(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=d(e._lodStateInCamera);!(n=r()).done;){var s=n.value,o=s[1].get(t);o||(o=new jM,s[1].set(t,o)),o.transformDirty=!0}if(t.isLockLevelChanged()){t.resetLockChangeFlag();var a=e._levelModels.get(t);if(a){a.forEach((function(t){t.forEach((function(t){var i=e._modelsInLODGroup.get(t);i&&i.clear()}))}));for(var h,u=d(i);!(h=u()).done;){var l=h.value,_=a.get(l);_&&_.forEach((function(t){var i=e._modelsInLODGroup.get(t);if(i&&t.node&&t.node.active)for(var n,r=d(e._lodStateInCamera);!(n=r()).done;){var s=n.value;i.set(s[0],!0)}}))}}}return 0}for(var f,p=!1,m=d(e._lodStateInCamera);!(f=m()).done;){var g=f.value,y=g[1].get(t);y||(y=new jM,g[1].set(t,y));var v=g[0].node.hasChangedFlags,S=t.node.hasChangedFlags;if(v>0||S>0||y.transformDirty){y.transformDirty&&(y.transformDirty=!1);var T=t.getVisibleLODLevel(g[0]);T!==y.usedLevel&&(y.lastUsedLevel=y.usedLevel,y.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,o=A.get(s);o&&o.forEach((function(t){var i=e._modelsInLODGroup.get(t);i&&t.node&&t.node.active&&i.set(n,!0)}))}}))}},f=d(this._renderScene.lodGroups);!(c=f()).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}(),qM=((SM={})[Sl.PORTRAIT]=Ul.IDENTITY,SM[Sl.LANDSCAPE_RIGHT]=Ul.ROTATE_90,SM[Sl.PORTRAIT_UPSIDE_DOWN]=Ul.ROTATE_180,SM[Sl.LANDSCAPE_LEFT]=Ul.ROTATE_270,SM),YM=function(){function t(){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}t.registerCreateFunc=function(e){e._createWindowFun=function(){return new t}};var e=t.prototype;return e.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 y=i[g];(o===TM.LEFT&&y.cameraType===Bx.RIGHT_EYE||o===TM.RIGHT&&y.cameraType===Bx.LEFT_EYE)&&i.splice(g,1)}this._frameMoveEnd()}}},e._frameMoveBegin=function(){for(var t=0;t0){this._device.acquire([Ed.swapchain]);var r=this._scenes,s=t.getTotalFrames();this._batcher&&(this._batcher.update(),this._batcher.uploadBuffers());for(var o=0;o0){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}());v.Root=KM,pi.Attr.setClassAttr(ep,"target","type","Object"),pi.Attr.setClassAttr(ep,"target","ctor",Jm);var JM,QM=new Array(16),ZM=null,$M=new Ln,tL=[om.TOUCH_START,om.TOUCH_MOVE,om.TOUCH_END,om.TOUCH_CANCEL],eL=[om.MOUSE_DOWN,om.MOUSE_ENTER,om.MOUSE_MOVE,om.MOUSE_LEAVE,om.MOUSE_UP,om.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"}(JM||(JM={}));var iL,nL=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._node=void 0,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(JM.MARK_LIST_DIRTY),i&&n.length>0)for(var r=0;r=0;--n)if((e=QM[n]).eventProcessor.capturingTarget&&(t.currentTarget=e,e.eventProcessor.capturingTarget.emit(t.type,t,QM),t.propagationStopped))return void(QM.length=0);if(QM.length=0,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(this.getBubblingTargets(t.type,QM),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!==tL.indexOf(t)},e._isMouseEvent=function(t){return-1!==eL.indexOf(t)},e._hasTouchListeners=function(){for(var t=0;t>>1;r<=s;o=r+s>>>1){var a=t[o],h=a.constructor._executionOrder;if(h>i)s=o-1;else if(hn)s=o-1;else{if(!(u0&&(t.array.sort(fL),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(fL),this._invoke(e),e.array.length=0)},e}(dL),mL=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=cL(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=cL(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}(dL);function gL(t,e,i){var n="var a=it.array;for(it.i=0;it.i=0?hL(this._deferredComps,e):(!t.internalStart||t._objFlags&uL||this.startInvoker.remove(t),t.internalUpdate&&this.updateInvoker.remove(t),t.internalLateUpdate&&this.lateUpdateInvoker.remove(t))},e.enableComp=function(t,e){if(!(t._objFlags&lL)){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&lL&&(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&uL||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=kL+this.globalVariables.join(",")+";");var n=Fl(["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 Jm,this.data.name="(Missing Node)";var i=new v._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;cw(t),uw(t)},e}(of)).OptimizationPolicy=eN,ZL.OptimizationPolicyThreshold=3,KL=ks((YL=ZL).prototype,"data",[io],(function(){return null})),JL=ks(YL.prototype,"optimizationPolicy",[io],(function(){return eN.AUTO})),QL=ks(YL.prototype,"persistent",[io],(function(){return!1})),qL=YL))||qL);Ct(iN,"_utils",vw),v.Prefab=iN,Dt(v,"cc._Prefab","Prefab");var nN=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,ae(this._allRenderers,e),t._internalId=-1,t._dirtyVersion===this._dirtyVersion&&(ue(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.length,e=this._dirtyRenderers,i=0;i1){var u=Object.create(null);e.forEach((function(t){u[t._uuid]=t})),r={isCompleted:oN,_map:u}}else r=e[0]}i&&i(t,r)}))},e.getXMLHttpRequest=function(){return new XMLHttpRequest},e.getItem=function(t){return ZS.assets.has(t)?{content:ZS.assets.get(t)}:null},e.loadRes=function(t,e,i,n){var r=this._parseLoadResArgs(e,i,n),s=r.type,o=r.onProgress,a=r.onComplete,h=hl(t);h&&!tS.getInfoWithPath(t,s)&&(t=t.slice(0,-h.length)),tS.load(t,s,o,a)},e.loadResArray=function(t,e,i,n){var r=this._parseLoadResArgs(e,i,n),s=r.type,o=r.onProgress,a=r.onComplete;t.forEach((function(e,i){var n=hl(e);n&&!tS.getInfoWithPath(e,s)&&(t[i]=e.slice(0,-n.length))})),tS.load(t,s,o,a)},e.loadResDir=function(t,e,i,n){var r=this._parseLoadResArgs(e,i,n),s=r.type,o=r.onProgress,a=r.onComplete;tS.loadDir(t,s,o,(function(e,i){var n=[];e||(n=tS.getDirWithPath(t,s).map((function(t){return t.path}))),a&&a(e,i,n)}))},e.getRes=function(t,e){return Dd.has(t)?Dd.get(t):tS.get(t,e)},e.getResCount=function(){return Dd.count},e.getDependsRecursively=function(t){if(!t)return[];var e="string"==typeof t?t:t._uuid;return Hp.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();bS.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();US.register(e)},e.release=function(t){if(Array.isArray(t))for(var e=0;e2e3&&(t._startTime=performance.now(),t._frameCount=0)},this._frameTime=1e3/this._targetFrameRate,this._rAF=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame,this._cAF=window.cancelAnimationFrame||window.cancelRequestAnimationFrame||window.msCancelRequestAnimationFrame||window.mozCancelRequestAnimationFrame||window.oCancelRequestAnimationFrame||window.webkitCancelRequestAnimationFrame||window.msCancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.ocancelAnimationFrame}var e=t.prototype;return e.start=function(){var t,e=this;if(!this._isPlaying){var i=void 0===this._rAF||(null===(t=globalThis.__globalXR)||void 0===t?void 0:t.isWebXR);this._startTime=performance.now(),this._stHandle=this._stTime((function t(){i&&(e._startTime=performance.now()),e._isPlaying&&(e._stHandle=e._stTime(t)),e._onTick&&e._onTick()})),this._isPlaying=!0,this._frameCount=0}},e.stop=function(){this._isPlaying&&(this._ctTime(this._stHandle),this._stHandle=0,this._isPlaying=!1,this._frameCount=0)},e._stTime=function(t){var e;if(void 0===this._rAF||null!==(e=globalThis.__globalXR)&&void 0!==e&&e.isWebXR){var i=performance.now(),n=Math.max(0,i-this._startTime),r=Math.max(0,this._frameTime-n);return setTimeout(t,r)}return this._callback=t,this._rAF.call(window,this._handleRAF)},e._ctTime=function(t){var e;void 0===this._cAF||null!==(e=globalThis.__globalXR)&&void 0!==e&&e.isWebXR?clearTimeout(t):t&&this._cAF.call(window,t)},n(t,[{key:"targetFrameRate",get:function(){return this._targetFrameRate},set:function(t){this._targetFrameRate!==t&&(this._targetFrameRate=t,this._frameTime=1e3/this._targetFrameRate,this._isPlaying&&(this.stop(),this.start()))}},{key:"onTick",get:function(){return this._onTick},set:function(t){this._onTick=t}}]),t}();st(yD.prototype,"RenderPipeline.prototype",[{name:"geometryRenderer",suggest:"please use camera.geometryRenderer instead."}]);var mN=new Ln,gN=function(){var t=e.prototype;function e(){this.settings=void 0,this._curTime=0,this.device=void 0,this.swapchain=void 0,this.shader=void 0,this.sampler=void 0,this.cmdBuff=void 0,this.quadAssmebler=void 0,this.vertexBuffers=void 0,this.indicesBuffers=void 0,this.renderArea=void 0,this.clearColors=void 0,this.projection=void 0,this.isMobile=!1,this.bgMat=void 0,this.bgImage=void 0,this.bgTexture=void 0,this.logoMat=void 0,this.logoImage=void 0,this.logoTexture=void 0,this.watermarkMat=void 0,this.watermarkTexture=void 0,this.bgWidth=1920,this.bgHeight=1080,this.bgRatio=16/9,this.logoWidthTemp=140,this.logoHeightTemp=200,this.logoWidth=0,this.logoHeight=0,this.logoXTrans=.5,this.logoYTrans=1/6+2.5/6,this.textSize=24,this.textHeight=24,this.textXTrans=.5,this.textYExtraTrans=32,this.textExpandSize=4,this.scaleSize=1}return t.init=function(){var t,e,i,n,r,s,o=this;if(this.settings={displayRatio:null!==(t=Ee.querySettings(be.Category.SPLASH_SCREEN,"displayRatio"))&&void 0!==t?t:.4,totalTime:null!==(e=Ee.querySettings(be.Category.SPLASH_SCREEN,"totalTime"))&&void 0!==e?e:3e3,watermarkLocation:null!==(i=Ee.querySettings(be.Category.SPLASH_SCREEN,"watermarkLocation"))&&void 0!==i?i:"default",autoFit:null===(n=Ee.querySettings(be.Category.SPLASH_SCREEN,"autoFit"))||void 0===n||n,logo:null!==(r=Ee.querySettings(be.Category.SPLASH_SCREEN,"logo"))&&void 0!==r?r:void 0,background:null!==(s=Ee.querySettings(be.Category.SPLASH_SCREEN,"background"))&&void 0!==s?s:void 0},this._curTime=0,!(this.settings.totalTime<=0||void 0===this.settings.logo||void 0===this.settings.background)){this.device=v.director.root.device,this.swapchain=v.director.root.mainWindow.swapchain,this.preInit(),this.initLayout(),"default"===this.settings.logo.type&&this.initWaterMark();var a=Promise.resolve(),h=Promise.resolve();return"custom"===this.settings.background.type&&(a=new Promise((function(t,e){o.bgImage=new T.Image,o.bgImage.onload=function(){o.initBG(),t()},o.bgImage.onerror=function(){e()},o.bgImage.src=o.settings.background.base64}))),"none"!==this.settings.logo.type&&(h=new Promise((function(t,e){o.logoImage=new T.Image,o.logoImage.onload=function(){o.initLogo(),t()},o.logoImage.onerror=function(){e()},o.logoImage.src=o.settings.logo.base64}))),Promise.all([a,h])}return this.settings.totalTime=0,Promise.resolve([])},t.preInit=function(){var t,e=null===(t=this.settings.background)||void 0===t?void 0:t.color;this.clearColors=e?[new zc(e.x,e.y,e.z,e.w)]:[new zc(0,0,0,1)];var i=this.device,n=this.swapchain;this.renderArea=new Mc(0,0,n.width,n.height),this.cmdBuff=i.commandBuffer;var r=new Float32Array([.5,.5,1,0,-.5,.5,0,0,.5,-.5,1,1,-.5,-.5,0,1]),s=4*Float32Array.BYTES_PER_ELEMENT,o=4*s;this.vertexBuffers=i.createBuffer(new Xc(Xl.VERTEX|Xl.TRANSFER_DST,Kl.DEVICE,o,s)),this.vertexBuffers.update(r);var a=new Uint16Array([0,1,2,1,3,2]),h=Uint16Array.BYTES_PER_ELEMENT,u=6*h;this.indicesBuffers=i.createBuffer(new Xc(Xl.INDEX|Xl.TRANSFER_DST,Kl.DEVICE,u,h)),this.indicesBuffers.update(a);var l=[new u_("a_position",Hl.RG32F),new u_("a_texCoord",Hl.RG32F)],c=new c_(l,[this.vertexBuffers],this.indicesBuffers);this.quadAssmebler=i.createInputAssembler(c),this.projection=new In,In.ortho(this.projection,-1,1,-1,1,-1,1,i.capabilities.clipSpaceMinZ,i.capabilities.clipSpaceSignY,n.surfaceTransform),this.isMobile=xl.isMobile},t.initLayout=function(){this.isMobile?(this.bgWidth=812,this.bgHeight=375,this.logoWidthTemp=70,this.logoHeightTemp=100,this.textSize=12,this.textHeight=this.textSize+this.textExpandSize,this.textXTrans=.5,this.textYExtraTrans=16):(this.bgWidth=1920,this.bgHeight=1080,this.logoWidthTemp=140,this.logoHeightTemp=200,this.textSize=24,this.textHeight=this.textSize+this.textExpandSize,this.textXTrans=.5,this.textYExtraTrans=32),this.logoXTrans=.5,this.logoYTrans=1/6+2.5/6,this.initScale()},t.initScale=function(){var t=this.swapchain.width,e=this.swapchain.height,i=this.isMobile?375:1080,n=this.isMobile?812:1920;if(t>e){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;In.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 o=ra(Ri(this._curTime/e.totalTime)),a=1,h=1;"custom"===this.settings.background.type&&(r=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}();gN._ins=void 0,v.internal.SplashScreen=gN;var yN=new(function(){function t(){this._data=null}return t.prototype.init=function(t){var e=this;return void 0===t&&(t=""),v.rendering&&v.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}());v.effectSettings=yN;var vN=t("e3",function(t){function i(){for(var e,i=arguments.length,n=new Array(i),r=0;rthis._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(gN.instance.isFinished)if(this._shouldLoadLaunchScene){this._shouldLoadLaunchScene=!1;var e,i=Ee.querySettings(be.Category.LAUNCH,"launchScene");i?fN.loadScene(i,(function(){var e;X(1103,i),t._initTime=performance.now(),fN.startAnimation(),null===(e=t.onStart)||void 0===e||e.call(t)})):(this._initTime=performance.now(),fN.startAnimation(),null===(e=this.onStart)||void 0===e||e.call(this))}else fN.tick(this._calculateDT(!1));else gN.instance.update(this._calculateDT(!1))},r.initPacer=function(){var t,e=null!==(t=Ee.querySettings(be.Category.SCREEN,"frameRate"))&&void 0!==t?t:60;G("number"==typeof e),this._pacer=new pN,this._pacer.onTick=this._updateCallback.bind(this),this.frameRate=e},r._initEvents=function(){nl.on("show",this._onShow,this),nl.on("hide",this._onHide,this),nl.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),nl.exit()},r.addPersistRootNode=function(t){fN.addPersistRootNode(t)},r.removePersistRootNode=function(t){fN.removePersistRootNode(t)},r.isPersistRootNode=function(t){return fN.isPersistRootNode(t)},r._setupRenderPipeline=function(){var t=this,e=Ee.querySettings(be.Category.RENDERING,"renderPipeline");return e?new Promise((function(t,i){ZS.loadAny(e,(function(e,n){return!e&&n instanceof yD?t(n):i(e)}))})).then((function(e){t._setRenderPipeline(e)})).catch((function(i){k(i),k("Failed load render pipeline: "+e+", engine failed to initialize, will fallback to default pipeline"),t._setRenderPipeline()})):this._setRenderPipeline()},r._setRenderPipeline=function(t){fN.root.setRenderPipeline(t)||this._setRenderPipeline(),this._rendererInitialized=!0,this._safeEmit(i.EVENT_RENDERER_INITED)},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}(Ku));vN.EVENT_HIDE="game_on_hide",vN.EVENT_SHOW="game_on_show",vN.EVENT_LOW_MEMORY="game_on_low_memory",vN.EVENT_GAME_INITED="game_inited",vN.EVENT_ENGINE_INITED="engine_inited",vN.EVENT_RENDERER_INITED="renderer_inited",vN.EVENT_PRE_BASE_INIT="pre_base_init",vN.EVENT_POST_BASE_INIT="post_base_init",vN.EVENT_PRE_INFRASTRUCTURE_INIT="pre_infrastructure_init",vN.EVENT_POST_INFRASTRUCTURE_INIT="post_infrastructure_init",vN.EVENT_PRE_SUBSYSTEM_INIT="pre_subsystem_init",vN.EVENT_POST_SUBSYSTEM_INIT="post_subsystem_init",vN.EVENT_PRE_PROJECT_INIT="pre_project_init",vN.EVENT_POST_PROJECT_INIT="post_project_init",vN.EVENT_RESTART="game_on_restart",vN.EVENT_PAUSE="game_on_pause",vN.EVENT_RESUME="game_on_resume",vN.EVENT_CLOSE="game_on_close",vN.RENDER_TYPE_CANVAS=0,vN.RENDER_TYPE_WEBGL=1,vN.RENDER_TYPE_OPENGL=2,vN.RENDER_TYPE_HEADLESS=3,vN.DEBUG_DT_THRESHOLD=1,v.Game=vN;var SN=t("e4",v.game=new vN);st(dN.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"}]),rt(dN.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"}]),nt(fN,"director",[{name:"_getSceneUuid",targetName:"assetManager.main",newName:"getSceneInfo",customFunction:function(t){var e;return ZS.main?null===(e=ZS.main.getSceneInfo(t))||void 0===e?void 0:e.uuid:""}}]),st(SN,"game",[{name:"collisionMatrix"},{name:"groupList"}]),nt(SN,"game",[{name:"_sceneInfos",targetName:"assetManager.main",newName:"getSceneInfo",customGetter:function(){var t=[];return ZS.main&&ZS.main.config.scenes.forEach((function(e){t.push(e)})),t}}]);var TN=t("a0",function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r=0;e--)ue(this._atlases[e]._innerSpriteFrames,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(),v.director.on(v.Director.EVENT_BEFORE_SCENE_LAUNCH,this.beforeSceneLoad,this)):(this.reset(),v.director.off(v.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}(Ou));TN.instance=void 0;var AN,bN=t("a1",TN.instance=new TN);fN.registerSystem("dynamicAtlasManager",bN,0),v.internal.dynamicAtlasManager=bN,function(t){t[t.positions=Ic.ATTR_POSITION]="positions",t[t.normals=Ic.ATTR_NORMAL]="normals",t[t.uvs=Ic.ATTR_TEX_COORD]="uvs",t[t.colors=Ic.ATTR_COLOR]="colors"}(AN||(AN={}));var EN=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}(),CN=function(){function t(t,e){if(this._mesh=void 0,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;nry.MAX_MORPH_TARGET_COUNT?this._subMeshRenderings[n]=new xN(this._mesh,n,this._mesh.struct.morph,e):this._subMeshRenderings[n]=new wN(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,o=0,a=t.length,h=0;0>>0}function a(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()}a.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|d[t>>>16&255]<<8|d[t>>>24&255])>>32-e:d[t]>>8-e),8>e+o)a=a<>e-n-1&1,8==++o&&(o=0,r[s++]=d[a],a=0,s===r.length&&(r=this.f()));r[s]=a,this.buffer=r,this.i=o,this.index=s},a.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 d=u;function f(t){this.buffer=new(s?Uint16Array:Array)(2*t),this.length=0}function p(t){var e,i,n,r,o,a,h,u,l,c=t.length,_=0,d=Number.POSITIVE_INFINITY;for(u=0;u_&&(_=t[u]),t[u]>=1;for(l=a;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},f.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,y=2,v={NONE:0,r:1,j:y,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,o,h,u=this.input;switch(this.h){case 0:for(o=0,h=u.length;o>>8&255,g[v++]=255&_,g[v++]=_>>>8&255,s)g.set(d,v),v+=d.length,g=g.subarray(0,v);else{for(p=0,m=d.length;pK)for(;0K?K:138)>K-3&&Z=Z?(it[Q++]=17,it[Q++]=Z-3,nt[17]++):(it[Q++]=18,it[Q++]=Z-11,nt[18]++),K-=Z;else if(it[Q++]=et[q],nt[et[q]]++,3>--K)for(;0K?K:6)>K-3&&Zz;z++)X[z]=k[j[z]];for(O=19;4=b;b++)E=A(),C[b]=E[2]<<24|E[1]<<16|E[0];var w=s?new Uint32Array(C):C;function x(n,r){function o(e,n){var r,s,o,a,h=e.G,u=[],l=0;switch(r=w[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],o=0,a=u.length;o=u;)S[u++]=0;for(u=0;29>=u;)A[u++]=0}for(S[256]=1,a=0,h=r.length;a=h){for(f&&o(f,-1),u=0,l=h-a;uR&&a+Rx&&(C=E,x=R),258===R)break}d=new T(x,a-C),f?f.length2*v[d-1]+S[d]&&(v[d]=2*v[d-1]+S[d]),A[d]=Array(v[d]),b[d]=Array(v[d]);for(_=0;_r[_]?(A[d][p]=m,b[d][p]=y,g+=2):(A[d][p]=r[_],b[d][p]=_,++_);E[d]=0,1===S[d]&&i(d)}for(o=T,a=0,h=n.length;a1<l&&t("undercommitted"),i=0,n=e.length;i>>=1;return a}function B(t,e){this.input=t,this.a=new(s?Uint8Array:Array)(32768),this.h=D.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 D=v;function P(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=M,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 O:this.b=32768,this.a=new(s?Uint8Array:Array)(32768+this.l+258);break;case M: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"))}}B.prototype.n=function(){var e,i,n,r,a,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 D.NONE:a=0;break;case D.r:a=1;break;case D.j:a=2;break;default:t(Error("unsupported compression type"))}break;default:t(Error("invalid compression method"))}return r=a<<6|0,u[l++]=r|31-(256*n+r)%31,h=o(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",B),r("Zlib.Deflate.compress",(function(t,e){return new B(t,e).n()})),r("Zlib.Deflate.CompressionType",D),r("Zlib.Deflate.CompressionType.NONE",D.NONE),r("Zlib.Deflate.CompressionType.FIXED",D.r),r("Zlib.Deflate.CompressionType.DYNAMIC",D.j);var O=0,M=1,L={D:O,C:M};P.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,o=this.c,a=this.a,h=this.b,u=e,l=e,c=e,_=a.length,d=e;switch(this.e=this.g=0,(u=r[o++])===e&&t(Error("invalid uncompressed block header: LEN (first byte)")),l=u,(u=r[o++])===e&&t(Error("invalid uncompressed block header: LEN (second byte)")),l|=u<<8,(u=r[o++])===e&&t(Error("invalid uncompressed block header: NLEN (first byte)")),c=u,(u=r[o++])===e&&t(Error("invalid uncompressed block header: NLEN (second byte)")),l===~(c|=u<<8)&&t(Error("invalid uncompressed block header: length verify")),o+l>r.length&&t(Error("input buffer is broken")),this.m){case O:for(;h+l>a.length;){if(l-=d=_-h,s)a.set(r.subarray(o,o+d),h),h+=d,o+=d;else for(;d--;)a[h++]=r[o++];this.b=h,a=this.f(),h=this.b}break;case M:for(;h+l>a.length;)a=this.f({v:2});break;default:t(Error("invalid inflate mode"))}if(s)a.set(r.subarray(o,o+l),h),h+=l,o+=l;else for(;l--;)a[h++]=r[o++];this.c=o,this.b=h,this.a=a;break;case 1:this.o(Q,$);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],V=s?new Uint16Array(k):k,G=[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(G):G,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],j=s?new Uint16Array(W):W,X=[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],q=s?new Uint8Array(X):X,Y=new(s?Uint8Array:Array)(288);for(N=0,F=Y.length;N=N?8:255>=N?9:279>=N?7:8;var K,J,Q=p(Y),Z=new(s?Uint8Array:Array)(30);for(K=0,J=Z.length;K>>n,i.e=o-n,i.c=h,r}function et(i,n){for(var r,s,o,a=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")),a|=r<>>16,i.g=a>>o,i.e=h-o,i.c=l,65535&s}function it(t){function e(t,e,i){var n,r,s,o;for(o=0;or)n>=h&&(this.b=n,i=this.f(),n=this.b),i[n++]=r;else for(a=U[s=r-257],0=h&&(this.b=n,i=this.f(),n=this.b);a--;)i[n]=i[n++-o];for(;8<=this.e;)this.e-=8,this.c--;this.b=n},P.prototype.I=function(t,e){var i=this.a,n=this.b;this.u=t;for(var r,s,o,a,h=i.length;256!==(r=et(this,t));)if(256>r)n>=h&&(h=(i=this.f()).length),i[n++]=r;else for(a=U[s=r-257],0h&&(h=(i=this.f()).length);a--;)i[n]=i[n++-o];for(;8<=this.e;)this.e-=8,this.c--;this.b=n},P.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},P.prototype.J=function(t){var e,i,n,r=this.input.length/this.c+1|0,o=this.input,a=this.a;return t&&("number"==typeof t.v&&(r=t.v),"number"==typeof t.F&&(r+=t.F)),i=2>r?(n=(o.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!==o(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,ot=new(s?Uint8Array:Array)(288);for(rt=0,st=ot.length;rt=rt?8:255>=rt?9:279>=rt?7:8;p(ot);var at,ht,ut=new(s?Uint8Array:Array)(30);for(at=0,ht=ut.length;at=65536){Y(10001,L,65536);continue}O>>=1,M>>=1}B=E.createBuffer(new Xc(Xl.INDEX,Kl.DEVICE,M,O)),w.push(B),D=new(zN(P.stride))(b,P.offset,P.count),P.stride!==O&&(D=zN(O).from(D)),B.update(D)}var N=I.vertexBundelIndices.map((function(t){return C[t]})),F=[];if(I.vertexBundelIndices.length>0)for(var k=I.vertexBundelIndices[0],V=this._struct.vertexBundles[k].attributes,G=0;G=this._struct.primitives.length)Y(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),y.update(g,p)),c.view.count=f,h.vertexCount=f}if(o.indexView){var v=o.indexView,S=v.stride,T=2===S?e.indices16.length:e.indices32.length,A=T*S,b=new Uint8Array(this._data.buffer,v.offset,A),E=2===S?new Uint8Array(e.indices16.buffer,e.indices16.byteOffset,A):new Uint8Array(e.indices32.buffer,e.indices32.byteOffset,A),C=a.indexBuffer;s.maxSubMeshIndices,A>0&&(b.set(E),C.update(E,A)),v.count=T,h.indexCount=T}if(e.minPos&&e.maxPos){var w=new on(e.minPos.x,e.minPos.y,e.minPos.z),x=new on(e.maxPos.x,e.maxPos.y,e.maxPos.z);r.bounds[t]||(r.bounds[t]=new Ss),Ss.fromPoints(r.bounds[t],w,x);for(var R,I=new on,B=new on,D=d(r.bounds);!(R=D()).done;){var P=R.value;P&&(P.getBoundary(I,B),on.min(w,I,w),on.max(x,B,x))}this._struct.minPosition=new on(w.x,w.y,w.z),this._struct.maxPosition=new on(x.x,x.y,x.z)}a.invalidateGeometricInfo()}else Y(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)){on.transformMat4(WN,HN,n[f]),i[f]=!0;var p=e[f];on.min(p.center,p.center,WN),on.max(p.halfExtents,p.halfExtents,WN)}}}}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?Hl.R8UI:2===i.indexView.stride?Hl.R16UI:Hl.R32UI,s=JN(new DataView(this._data.buffer),r),o=0;o=this._struct.primitives.length))for(var n,r=d(this._struct.primitives[t].vertexBundelIndices);!(n=r()).done;){var s=n.value,o=this._struct.vertexBundles[s],a=o.attributes.findIndex((function(t){return t.name===e}));if(!(a<0)){i(o,a);break}}},i._createVertexBuffers=function(t,e){return this._struct.vertexBundles.map((function(i){var n=t.createBuffer(new Xc(Xl.VERTEX,Kl.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:jN})},i.releaseData=function(){this._data=jN},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=Dl(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}(of),kN=ks(FN.prototype,"_struct",[io],(function(){return{vertexBundles:[],primitives:[]}})),VN=ks(FN.prototype,"_hash",[io],(function(){return 0})),GN=ks(FN.prototype,"_allowDataAccess",[io],(function(){return!0})),NN=FN))||NN);function qN(t,e){for(var i=0,n=0;n0){if(n=null,t.attributes)for(var u,l=d(t.attributes);!(u=l()).done;){var c=u.value;if(c.name===Ic.ATTR_POSITION){n=c;break}}n||(n=tF[0]),r.push(n);var _=M_[n.format];a=Math.max(a,Math.floor(h.length/_.count)),o.push({offset:s,data:h,attribute:n}),s+=_.size}if(t.normals&&t.normals.length>0){if(n=null,t.attributes)for(var f,p=d(t.attributes);!(f=p()).done;){var m=f.value;if(m.name===Ic.ATTR_NORMAL){n=m;break}}n||(n=tF[1]);var g=M_[n.format];r.push(n),a=Math.max(a,Math.floor(t.normals.length/g.count)),o.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 y,v=d(t.attributes);!(y=v()).done;){var S=y.value;if(S.name===Ic.ATTR_TEX_COORD){n=S;break}}n||(n=tF[2]);var T=M_[n.format];r.push(n),a=Math.max(a,Math.floor(t.uvs.length/T.count)),o.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=d(t.attributes);!(A=b()).done;){var E=A.value;if(E.name===Ic.ATTR_TANGENT){n=E;break}}n||(n=tF[3]);var C=M_[n.format];r.push(n),a=Math.max(a,Math.floor(t.tangents.length/C.count)),o.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 w,x=d(t.attributes);!(w=x()).done;){var R=w.value;if(R.name===Ic.ATTR_COLOR){n=R;break}}n||(n=tF[4]);var I=M_[n.format];r.push(n),a=Math.max(a,Math.floor(t.colors.length/I.count)),o.push({offset:s,data:t.colors,attribute:n}),s+=I.size}if(t.customAttributes)for(var B=0;B0){var i=t%e;if(0!==i)return e-i}return 0}var rF,sF,oF=function(){function t(){}return t.createMesh=function(t,e,i){return iF(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 u_(Ic.ATTR_POSITION,Hl.RGB32F,!1,s++,!1,0)),e.normals&&e.normals.length>0&&r.push(new u_(Ic.ATTR_NORMAL,Hl.RGB32F,!1,s++,!1,0)),e.uvs&&e.uvs.length>0&&r.push(new u_(Ic.ATTR_TEX_COORD,Hl.RG32F,!1,s++,!1,0)),e.tangents&&e.tangents.length>0&&r.push(new u_(Ic.ATTR_TANGENT,Hl.RGBA32F,!1,s++,!1,0)),e.colors&&e.colors.length>0&&r.push(new u_(Ic.ATTR_COLOR,Hl.RGBA32F,!1,s++,!1,0)),e.customAttributes)for(var o=0;o0?A=2:e.indices32&&e.indices32.length>0&&(A=4),A>0){c+=nF(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 w={struct:{vertexBundles:u,primitives:l,dynamic:C},data:new Uint8Array(c)};return i||(i=new XN),i.reset(w),i.initialize(),i.updateSubMesh(t,e),i}(t,e,i,n)},t.decodeMesh=function(t){return ZN(t)},t.inflateMesh=function(t){return $N(t)},t}(),aF=Object.freeze({__proto__:null,find:aL,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,o=s.primitives[e],a=d(o.vertexBundelIndices);!(i=a()).done;)for(var h,u=i.value,l=s.vertexBundles[u],c=l.view.offset,_=l.view,f=_.length,p=_.stride,m=d(l.attributes);!(h=m()).done;){var g=h.value,y=AN[g.name];y&&(n[y]=(n[y]||[]).concat(DR(r,g.format,c,f,p))),c+=M_[g.format].size}var v=o.indexView;return n.indices=DR(r,Hl["R"+8*v.stride+"UI"],v.offset,v.length),n},createMesh:iF,MeshUtils:oF,readBuffer:DR,writeBuffer:BR,mapBuffer:PR});t("a4",aF);var hF,uF=new on,lF=new In;!function(t){t[t.RECT=0]="RECT",t[t.POLYGON=1]="POLYGON"}(hF||(hF={}));var cF,_F,dF,fF=[{u:0,v:0},{u:0,v:0},{u:0,v:0},{u:0,v:0}],pF=t("b",qs("cc.SpriteFrame")(((sF=function(t){function e(){var e;return(e=t.call(this)||this).vertices=null,e.uv=[],e.unbiasUV=[],e.uvSliced=[],e._rect=new Un,e._trimmedBorder=new tn,e._offset=new Ln,e._originalSize=new Vn,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=new Ln(.5,.5),e._meshType=hF.RECT,e._extrude=0,e._customOutLine=[],e._minPos=new on,e._maxPos=new on,e}s(e,t),e.createWithImage=function(t){var i=t instanceof Rf?t:new Rf(t),n=new Zp;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?(J(3300,this.name+"/"+t.name,i,t.width),!1):!(n>t.height&&(J(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&&bN&&bN.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],o=this._capInsets[2],a=t.width-s-o,h=this._capInsets[1],u=this._capInsets[3],l=t.height-h-u,c=this.uvSliced;if(c.length=0,this._rotated){fF[0].u=t.x/n,fF[1].u=(t.x+u)/n,fF[2].u=(t.x+u+l)/n,fF[3].u=(t.x+t.height)/n,fF[3].v=t.y/r,fF[2].v=(t.y+s)/r,fF[1].v=(t.y+s+a)/r,fF[0].v=(t.y+t.width)/r;for(var _=0;_<4;++_)for(var d=fF[_],f=0;f<4;++f){var p=fF[3-f];c.push({u:d.u,v:p.v})}}else{fF[0].u=t.x/n,fF[1].u=(t.x+s)/n,fF[2].u=(t.x+s+a)/n,fF[3].u=(t.x+t.width)/n,fF[3].v=t.y/r,fF[2].v=(t.y+h)/r,fF[1].v=(t.y+h+l)/r,fF[0].v=(t.y+t.height)/r;for(var m=0;m<4;++m)for(var g=fF[m],y=0;y<4;++y){var v=fF[y];c.push({u:v.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 o=0===r?0:t.x/r,a=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]=a,e[1]=u,e[2]=a,e[3]=h,e[4]=o,e[5]=u,e[6]=o,e[7]=h):this._isFlipUVX?(e[0]=a,e[1]=h,e[2]=a,e[3]=u,e[4]=o,e[5]=h,e[6]=o,e[7]=u):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):(e[0]=o,e[1]=h,e[2]=o,e[3]=u,e[4]=a,e[5]=h,e[6]=a,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,d=0===s?1:(t.y+t.width)/s;this._isFlipUVX&&this._isFlipUVY?(i[0]=c,i[1]=d,i[2]=c,i[3]=_,i[4]=l,i[5]=d,i[6]=l,i[7]=_):this._isFlipUVX?(i[0]=c,i[1]=_,i[2]=c,i[3]=d,i[4]=l,i[5]=_,i[6]=l,i[7]=d):this._isFlipUVY?(i[0]=l,i[1]=d,i[2]=l,i[3]=_,i[4]=c,i[5]=d,i[6]=c,i[7]=_):(i[0]=l,i[1]=_,i[2]=l,i[3]=d,i[4]=c,i[5]=_,i[6]=c,i[7]=d)}else{var f=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]=f,e[3]=g,e[4]=p,e[5]=m,e[6]=f,e[7]=m):this._isFlipUVX?(e[0]=p,e[1]=m,e[2]=f,e[3]=m,e[4]=p,e[5]=g,e[6]=f,e[7]=g):this._isFlipUVY?(e[0]=f,e[1]=g,e[2]=p,e[3]=g,e[4]=f,e[5]=m,e[6]=p,e[7]=m):(e[0]=f,e[1]=m,e[2]=p,e[3]=m,e[4]=f,e[5]=g,e[6]=p,e[7]=g);var y=0===r?0:t.x/r,v=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]=v,i[1]=T,i[2]=y,i[3]=T,i[4]=v,i[5]=S,i[6]=y,i[7]=S):this._isFlipUVX?(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._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):(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._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=bN;if(t){var e=this._texture;if(e instanceof Zp&&!e.isCompressed){var i=this.width,n=this.height;if(!e.image||i>t.maxFrameSize||n>t.maxFrameSize)this._packable=!1;else{var r=T.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 Un(i.x,i.y,i.width,i.height));var n=e.offset;e.offset&&(this._offset=new Ln(n.x,n.y));var r=e.originalSize;e.originalSize&&(this._originalSize=new Vn(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=new Ln(s.x,s.y)),this._meshType=e.meshType;var o=e.capInsets;o&&(this._capInsets[0]=o[0],this._capInsets[1]=o[1],this._capInsets[2]=o[2],this._capInsets[3]=o[3]);var a=e.vertices;if(a){this.vertices||(this.vertices={rawPosition:[],positions:[],indexes:a.indexes,uv:a.uv,nuv:a.nuv,minPos:new on(a.minPos.x,a.minPos.y,a.minPos.z),maxPos:new on(a.maxPos.x,a.maxPos.y,a.maxPos.z)}),this.vertices.rawPosition.length=0;for(var h=a.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,kF.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),UF=/([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûа-яА-ЯЁё]+|\S)/,zF=/^[!,.:;'}\]%\?>、‘“》?。,!]/,HF=/([a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁёáàảạãăắằẳẵặâấầẩẫậéèẻẽẹêếềểễệiíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵđÁÀẢẠÃĂẮẰẲẴẶÂẤẦẨẪẬÉÈẺẼẸÊẾỀỂỄỆIÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴĐ]+|\S)$/,WF=/[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁёáàảạãăắằẳẵặâấầẩẫậéèẻẽẹêếềểễệiíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵđÁÀẢẠÃĂẮẰẲẴẶÂẤẦẨẪẬÉÈẺẼẸÊẾỀỂỄỆIÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴĐ]+$/,jF=/^[a-zA-Z0-9ÄÖÜäöüßéèçàùêâîôûаíìÍÌïÁÀáàÉÈÒÓòóŐőÙÚŰúűñÑæÆœŒÃÂãÔõěščřžýáíéóúůťďňĚŠČŘŽÁÍÉÓÚŤżźśóńłęćąŻŹŚÓŃŁĘĆĄ-яА-ЯЁёáàảạãăắằẳẵặâấầẩẫậéèẻẽẹêếềểễệiíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵđÁÀẢẠÃĂẮẰẲẴẶÂẤẦẨẪẬÉÈẺẼẸÊẾỀỂỄỆIÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴĐ]/;function XF(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 qF(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 YF(t,e,i){var n=(i||t.font)+"🎮"+e,r=GF.get(n);if(null!==r)return r;var s=t.measureText(e),o=s&&s.width||0;return GF.put(n,o),o}function KF(t,e,i){var n=e,r=i,s=t[e];if(s>="\udc00"&&s<="\udfff"&&n--,void 0!==i)if(i-1!==e){var o=t[i-1];o>="\ud800"&&o<="\udbff"&&r--}else s>="\ud800"&&s<="\udbff"&&r++;return t.substring(n,r)}function JF(t){return jF.exec(t)}function QF(t){return WF.exec(t)}function ZF(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 o=s.length*(i/e)|0,a=KF(s,o),h=e-n(a),u=a,l=0,c=0;h>i&&c++<100;)o*=i/h,h=e-n(a=KF(s,o|=0));for(c=0;a&&h<=i&&c++<100;){var _=UF.exec(a);u=a,h=e-n(a=KF(s,o+=l=_?_[0].length:1))}0==(o-=l)?(o=1,u=KF(s,1)):1===o&&s[0]>="\ud800"&&s[0]<="\udbff"&&(o=2,u=KF(s,2));var d=KF(s,0,o),f=void 0;zF.test(u||a)&&(0==(o-=(f=HF.exec(d))?f[0].length:0)&&(o=1),u=KF(s,o),d=KF(s,0,o)),jF.test(u)&&(f=WF.exec(d))&&d!==f[0]&&(u=KF(s,o-=f[0].length),d=KF(s,0,o)),(0===r.length||(d=d.trim()).length>0)&&r.push(d),e=n(s=u||a)}return(0===r.length||(s=s.trim()).length>0)&&r.push(s),r}var $F,tk=function(){function t(){this.pool=[]}t.getInstance=function(){return VF||(VF=new t),VF};var e=t.prototype;return e.get=function(){var t=this.pool.pop();if(!t){var e=T.document.createElement("canvas"),i=e.getContext("2d");t={canvas:e,context:i}}return t},e.put=function(t){this.pool.length>=Ce.MAX_LABEL_CANVAS_POOL_SIZE||this.pool.push(t)},t}(),ek=dn.WHITE.clone(),ik=function(){this.u=0,this.v=0,this.w=0,this.h=0,this.texture=null,this.offsetX=0,this.offsetY=0,this.valid=!1,this.xAdvance=0},nk="rgba(255, 255, 255, "+(1/255).toFixed(3)+")",rk=function(){function t(t,e){this.image=null,this.labelInfo=void 0,this.char=void 0,this.data=null,this.canvas=null,this.context=null,this.width=0,this.height=0,this.offsetY=0,this.hash=void 0,this.char=t,this.labelInfo=e,this.hash=""+t.charCodeAt(0)+e.hash}var e=t.prototype;return e.updateRenderData=function(){this._updateProperties(),this._updateTexture()},e.destroy=function(){this.image=null,tk.getInstance().put(this.data)},e._updateProperties=function(){if(this.data=tk.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=YF(this.context,this.char,this.labelInfo.fontDesc),i=2*this.labelInfo.margin+2;this.width=parseFloat(e.toFixed(2))*t+i,this.height=(1+NF)*this.labelInfo.fontSize*t+i,this.offsetY=-this.labelInfo.fontSize*NF*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 Rf),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=nk,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,o=i/2,a=n/2+s*FF+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||ek;t.strokeStyle="rgba("+u.r+", "+u.g+", "+u.b+", "+u.a/255+")",t.lineWidth=2*e.margin*r,t.strokeText(this.char,o,a)}t.fillText(this.char,o,a)}},t}(),sk=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=af.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 Gc;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 console.warn("Unable to get device")}},e}(Zp),ok=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 sk;i.initWithSize(t,e),this.fontDefDictionary=new OF(i),this._halfBleed=1,this._width=t,this._height=e,fN.on(dN.EVENT_BEFORE_SCENE_LAUNCH,this.beforeSceneLoad,this)}var e=t.prototype;return e.insertLetterTexture=function(t){var e=t.image,i=fN.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 Y(12100),null;this.fontDefDictionary.texture.drawTextureAt(e,this._x,this._y),this._dirty=!0;var s=new ik;return s.u=this._x+this._halfBleed,s.v=this._y+this._halfBleed,s.texture=this.fontDefDictionary.texture,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(),this.fontDefDictionary&&(this.fontDefDictionary.texture.destroy(),this.fontDefDictionary.texture=null)},e.getTexture=function(){return this.fontDefDictionary.getTexture()},e.beforeSceneLoad=function(){this.clearAllCache()},e.clearAllCache=function(){this.destroy();var t=new sk;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=t.charCodeAt(0)+e.hash,n=this.fontDefDictionary.letterDefinitions[i];if(!n){var r=new rk(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}(),ak={fontAtlas:null,fontSize:0,lineHeight:0,hAlign:0,vAlign:0,hash:"",fontFamily:"",fontDesc:"Arial",color:dn.WHITE.clone(),isOutlined:!1,out:dn.WHITE.clone(),margin:0,fontScale:1},hk=[new u_(Ic.ATTR_POSITION,Hl.RGB32F)],uk=[new u_(Ic.ATTR_POSITION,Hl.RGB32F),new u_(Ic.ATTR_COLOR,Hl.RGBA32F)],lk=[new u_(Ic.ATTR_POSITION,Hl.RGB32F),new u_(Ic.ATTR_TEX_COORD,Hl.RG32F),new u_(Ic.ATTR_COLOR,Hl.RGBA32F)],ck=[new u_(Ic.ATTR_POSITION,Hl.RGB32F),new u_(Ic.ATTR_TEX_COORD,Hl.RG32F),new u_(Ic.ATTR_COLOR,Hl.RGBA8,!0)],_k=[new u_(Ic.ATTR_POSITION,Hl.RGB32F),new u_(Ic.ATTR_TEX_COORD,Hl.RG32F),new u_(Ic.ATTR_COLOR,Hl.RGBA32F),new u_(Ic.ATTR_COLOR2,Hl.RGBA32F)],dk=[new u_(Ic.ATTR_POSITION,Hl.RGB32F),new u_(Ic.ATTR_TEX_COORD,Hl.RG32F),new u_(Ic.ATTR_COLOR,Hl.RGBA8,!0),new u_(Ic.ATTR_COLOR2,Hl.RGBA8,!0)];function fk(t){for(var e=0,i=0;i>2,this._initVDataCount,this._floatsPerVertex,tt(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=xl.__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,o=this.indexOffset,a=0;a>2),l=new Uint16Array(this.iData.buffer,0,o),c=h.vertexBuffers[0];s>c.size&&c.resize(s),c.update(u),2*o>h.indexBuffer.size&&h.indexBuffer.resize(2*o),h.indexBuffer.update(l)}this.dirty=!1}},t.createNewIA=function(t){var e,i,n;if(xl.__isWebIOS14OrIPadOS14Env||!this._iaPool[0]){var r=this._vertexFormatBytes=this._floatsPerVertex*Float32Array.BYTES_PER_ELEMENT,s=Uint16Array.BYTES_PER_ELEMENT,o=t.createBuffer(new Xc(Xl.VERTEX|Xl.TRANSFER_DST,Kl.HOST|Kl.DEVICE,r,r));n=t.createBuffer(new Xc(Xl.INDEX|Xl.TRANSFER_DST,Kl.HOST|Kl.DEVICE,s,s)),i=[o],this._iaInfo=new c_(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}()),bk=function(){function t(t,e){this._device=null,this._attributes=null,this._vertexFormatBytes=void 0,this._floatsPerVertex=void 0,this._buffers=[],this._device=t,this._attributes=e,this._floatsPerVertex=pk(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}(),Ek=new Bu((function(){return{offset:0,length:0}}),32),Ck=function(){function t(t,e,i,n,r,s){this._ib=void 0,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}(),wk=function(t){function e(i,n,r,s){var o;return(o=t.call(this,i,n)||this)._freeLists=[],o._vCount=0,o._iCount=0,o._id=0,o._vCount=r||Math.floor(1024*Ce.BATCHER2D_MEM_INCREMENT/o._vertexFormatBytes),o._iCount=s||o._vCount*e.IB_SCALE,o._id=e.generateID(),o._allocateBuffer(),o}s(e,t);var i=e.prototype;return i.destroy=function(){for(var e=0;e=n){a=i[u],s=h,o=u;break}if(a)break}if(a||(s=this._allocateBuffer(),(r=this._buffers[s])&&r.checkCapacity(t,e)&&(o=0,a=this._freeLists[s][o])),a){var l=a.offset/this.vertexFormatBytes,c=new Float32Array(r.vData.buffer,a.offset,n>>2).fill(0);return this._allocateChunkFromEntry(s,o,a,n),new Ck(this,s,r,l,c,e)}return J(9004,n),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,o=0,a=null,h=e[o];h&&h.offset=0,9004,t,i.offset,i.length),0===r?(this._freeLists[t].splice(e,1),Ek.free(i)):(i.offset+=n,i.length=r)},i._allocateBuffer=function(){$(this._buffers.length===this._freeLists.length,9003);var t=new Ak,e=this._vCount*this._floatsPerVertex;t.initialize(this._device,this._attributes,e,this._iCount),this._buffers.push(t);var i=Ek.alloc();i.offset=0,i.length=t.vData.byteLength;var n=[i];return this._freeLists.push(n),fN.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}(bk);wk.IB_SCALE=4,wk.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"}(mk||(mk={})),function(t){t[t.BufferID=0]="BufferID",t[t.AccessorID=1]="AccessorID",t[t.Count=2]="Count"}(gk||(gk={})),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"}(yk||(yk={})),function(t){t[t.COMP=0]="COMP",t[t.MODEL=1]="MODEL",t[t.MIDDLEWARE=2]="MIDDLEWARE",t[t.SUB_NODE=3]="SUB_NODE"}(vk||(vk={})),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=vk.COMP,this._subNode=null,this._uint8SharedBuffer=void 0,this._uint16SharedBuffer=void 0,this._uint32SharedBuffer=void 0,this.init(t);var e=this._nativeObj.getAttrSharedBufferForJS(),i=0;this._uint8SharedBuffer=new Uint8Array(e,i,mk.Count),i+=mk.Count*Uint8Array.BYTES_PER_ELEMENT,this._uint16SharedBuffer=new Uint16Array(e,i,gk.Count),i+=gk.Count*Uint16Array.BYTES_PER_ELEMENT,this._uint32SharedBuffer=new Uint32Array(e,i,yk.Count)}var e=t.prototype;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}}])}(),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"}(Sk||(Sk={})),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"}(Tk||(Tk={}));var xk,Rk,Ik,Bk,Dk,Pk=t("S",function(){function t(){this._maskStack=[],this._stencilPattern={stencilTest:!0,func:rc.ALWAYS,stencilMask:65535,writeMask:65535,failOp:sc.KEEP,zFailOp:sc.KEEP,passOp:sc.KEEP,ref:1},this._stage=Sk.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!==Sk.ENTER_LEVEL?Sk.CLEAR_INVERTED:Sk.CLEAR},e.enableMask=function(){this.stage=Sk.ENABLED},e.exitMask=function(){0!==this._maskStack.length&&(this._maskStack.pop(),0===this._maskStack.length?this.stage=Sk.DISABLED:this.stage=Sk.ENABLED)},e.getWriteMask=function(){return 1<>2,Xk=t("t",function(){function t(t){void 0===t&&(t=lk),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=lk,this._drawInfoType=vk.COMP,this._multiOwner=!1,this._batcher=null,this._floatStride=t===lk?jk:pk(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=vk.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=fN.root.batcher2D),this._batcher}}]),t}()),qk=t("u",function(t){function e(e,i){var n;return void 0===e&&(e=lk),(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=lk);var n=new e(t,i);return i||(i=fN.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=Dl(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=fN.root.device;return new wk(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,o=this.vData.length,a=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 Xc(Xl.VERTEX|Xl.TRANSFER_DST,Kl.DEVICE,i,i)));var r=Uint16Array.BYTES_PER_ELEMENT;this._indexBuffer||(this._indexBuffer=t.createBuffer(new Xc(Xl.INDEX|Xl.TRANSFER_DST,Kl.DEVICE,r,r))),this._iaInfo=new c_(this._vertexFormat,n,this._indexBuffer),this._iaPool=new Du((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}(Xk)),Kk=new Ln,Jk=new Ln,Qk=new on,Zk=new In,$k=new In,tV=new In,eV=new In(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),iV=new Un,nV=t("e",qs("cc.UITransform")(Ok=Ks(110)(Ok=Js(((Fk=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r=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=Qk,s=Kk,o=Jk,a=this._getRenderScene().cameras,h=0;h=0&&o.y>=0&&o.x<=i&&o.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,o=0,a=0;r&&ah.index){n.length=a;break}}return!0},i.convertToNodeSpaceAR=function(t,e){return this.node.getWorldMatrix(tV),In.invert(Zk,tV),e||(e=new on),on.transformMat4(e,t,Zk)},i.convertToWorldSpaceAR=function(t,e){return this.node.getWorldMatrix(tV),e||(e=new on),on.transformMat4(e,t,tV)},i.getBoundingBox=function(){var t=new Un;return this._selfBoundingBox(t),In.fromSRT($k,this.node.rotation,this.node.position,this.node.scale),t.transformMat4($k),t},i.getBoundingBoxToWorld=function(){for(var t=new Un,i=this.node.children,n=0;n=this._materials.length?null:this._materials[t]},i.setSharedMaterial=function(t,e){t&&t instanceof NT&&J(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]){gV.parent=this._materials[t],gV.owner=this,gV.subModelIdx=t;var e=new NT(gV);gV.parent=null,gV.owner=null,gV.subModelIdx=0,this.setMaterialInstance(e,t)}return this._materialInstances[t]},i.setMaterialInstance=function(t,e){if("number"==typeof t){Y(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!==Sk.ENTER_LEVEL&&this.stencilStage!==Sk.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 mG(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"}(cG||(cG={})),function(t){t[t.DEFAULT=1]="DEFAULT",t[t.FORWARD=2]="FORWARD",t[t.SHADOWCAST=4]="SHADOWCAST"}(_G||(_G={}));var gG,yG,vG,SG,TG,AG,bG,EG,CG,wG=function(){function t(t){this._device=void 0,this._format=Hl.UNKNOWN,this._formatSize=0,this._chunks=[],this._chunkCount=0,this._handles=[],this._region0=new Gc,this._region1=new Gc,this._region2=new Gc,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=M_[t.format];this._format=t.format,this._formatSize=e.size,this._channels=e.count,this._bufferViewCtor=H_(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 o={chunkIdx:i,start:n,end:n+t,texture:s.texture};return this._handles.push(o),o}var a=Math.sqrt(t/this._formatSize),h=this._roundUpFn&&this._roundUpFn(a,this._formatSize)||Math.max(1024,pG(a)),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=o,this._region0.texOffset.y=a,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),o=0,a+=1,s-=h,u+=h),s>0&&(this._region1.texOffset.x=o,this._region1.texOffset.y=a,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),o=0,a+=this._region1.texExtent.height,s-=h,u+=h),s>0&&(this._region2.texOffset.x=o,this._region2.texOffset.y=a,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})),o=0;oi.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 o=Math.sqrt(t/this._formatSize),a=this._roundUpFn&&this._roundUpFn(o,this._formatSize)||Math.max(1024,pG(o)),h=this._chunks[this.createChunk(a)];h.start+=t;var u={chunkIdx:this._chunkCount,start:0,end:t,texture:h.texture};return this._handles.push(u),u},t}(),xG=function(){function t(t,e,i){this._arrayBuffers=[],this._chunkSize=void 0,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]===CG.UINT32?this._uint32BufferViews:this._float32BufferViews)[i][n],o=this._dataMembers[e];return s.subarray(r,r+o)},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"}(RG||(RG={})),function(t){t[t.POSITION=0]="POSITION",t[t.UV=3]="UV",t[t.COLOR=5]="COLOR",t[t.COUNT=9]="COUNT"}(IG||(IG={}));var DG,PG=((gG={})[IG.POSITION]=CG.FLOAT32,gG[IG.UV]=CG.FLOAT32,gG[IG.COLOR]=CG.UINT32,gG[IG.COUNT]=CG.NEVER,gG),OG=((yG={})[IG.POSITION]=IG.UV-IG.POSITION,yG[IG.UV]=IG.COLOR-IG.UV,yG[IG.COLOR]=IG.COUNT-IG.COLOR,yG[IG.COUNT]=1,yG),MG=new BG(RG.RENDER2D,PG,OG,IG);!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"}(DG||(DG={}));var LG,NG=((vG={})[DG.DIRTY_FLAG]=CG.UINT32,vG[DG.LAYER]=CG.UINT32,vG[DG.WORLD_SCALE]=CG.FLOAT32,vG[DG.WORLD_POSITION]=CG.FLOAT32,vG[DG.WORLD_ROTATION]=CG.FLOAT32,vG[DG.WORLD_MATRIX]=CG.FLOAT32,vG[DG.LOCAL_SCALE]=CG.FLOAT32,vG[DG.LOCAL_POSITION]=CG.FLOAT32,vG[DG.LOCAL_ROTATION]=CG.FLOAT32,vG[DG.COUNT]=CG.NEVER,vG),FG=((SG={})[DG.DIRTY_FLAG]=DG.LAYER-DG.DIRTY_FLAG,SG[DG.LAYER]=DG.WORLD_SCALE-DG.LAYER,SG[DG.WORLD_SCALE]=DG.WORLD_POSITION-DG.WORLD_SCALE,SG[DG.WORLD_POSITION]=DG.WORLD_ROTATION-DG.WORLD_POSITION,SG[DG.WORLD_ROTATION]=DG.WORLD_MATRIX-DG.WORLD_ROTATION,SG[DG.WORLD_MATRIX]=DG.LOCAL_SCALE-DG.WORLD_MATRIX,SG[DG.LOCAL_SCALE]=DG.LOCAL_POSITION-DG.LOCAL_SCALE,SG[DG.LOCAL_POSITION]=DG.LOCAL_ROTATION-DG.LOCAL_POSITION,SG[DG.LOCAL_ROTATION]=DG.COUNT-DG.LOCAL_ROTATION,SG[DG.COUNT]=1,SG),kG=new BG(RG.NODE,NG,FG,DG);!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"}(LG||(LG={}));var VG,GG=((TG={})[LG.PRIORITY]=CG.UINT32,TG[LG.STAGE]=CG.UINT32,TG[LG.PHASE]=CG.UINT32,TG[LG.PRIMITIVE]=CG.UINT32,TG[LG.BATCHING_SCHEME]=CG.UINT32,TG[LG.DYNAMIC_STATE]=CG.UINT32,TG[LG.HASH]=CG.UINT32,TG[LG.COUNT]=CG.NEVER,TG),UG=((AG={})[LG.PRIORITY]=LG.STAGE-LG.PRIORITY,AG[LG.STAGE]=LG.PHASE-LG.STAGE,AG[LG.PHASE]=LG.PRIMITIVE-LG.PHASE,AG[LG.PRIMITIVE]=LG.BATCHING_SCHEME-LG.PRIMITIVE,AG[LG.BATCHING_SCHEME]=LG.DYNAMIC_STATE-LG.BATCHING_SCHEME,AG[LG.DYNAMIC_STATE]=LG.HASH-LG.DYNAMIC_STATE,AG[LG.HASH]=LG.COUNT-LG.HASH,AG[LG.COUNT]=1,AG),zG=new BG(RG.PASS,GG,UG,LG);!function(t){t[t.CENTER=0]="CENTER",t[t.HALFEXTENTS=3]="HALFEXTENTS",t[t.COUNT=6]="COUNT"}(VG||(VG={}));var HG=((bG={})[VG.CENTER]=CG.FLOAT32,bG[VG.HALFEXTENTS]=CG.FLOAT32,bG[VG.COUNT]=CG.NEVER,bG),WG=((EG={})[VG.CENTER]=VG.HALFEXTENTS-VG.CENTER,EG[VG.HALFEXTENTS]=VG.COUNT-VG.HALFEXTENTS,EG[VG.COUNT]=1,EG),jG=new BG(RG.AABB,HG,WG,VG);rt(WM.prototype,"RenderScene.prototype",[{name:"raycastUI2DNode"},{name:"raycastUINode"}]),rt(WM.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"}]),rt(wM.prototype,"Model.prototype",[{name:"isInstancingEnabled"},{name:"instancedAttributes"}]);var XG={};rt(XG,"CameraVisFlags",[{name:"GENERAL"}]),nt(XG,"CameraVisFlags",[{name:"PROFILER",newName:"PROFILER",target:im.BitMask,targetName:"PROFILER"},{name:"GIZMOS",newName:"GIZMOS",target:im.BitMask,targetName:"GIZMOS"},{name:"EDITOR",newName:"EDITOR",target:im.BitMask,targetName:"EDITOR"},{name:"UI",newName:"UI",target:im.BitMask,targetName:"UI_3D"},{name:"UI2D",newName:"UI2D",target:im.BitMask,targetName:"UI_2D"}]),v.CameraVisFlags=XG;var qG={};rt(qG,"VisibilityFlags",[{name:"GENERAL"}]),nt(qG,"VisibilityFlags",[{name:"ALWALS",newName:"ALWALS",target:im.Enum,targetName:"ALWALS"},{name:"PROFILER",newName:"PROFILER",target:im.Enum,targetName:"PROFILER"},{name:"GIZMOS",newName:"GIZMOS",target:im.Enum,targetName:"GIZMOS"},{name:"EDITOR",newName:"EDITOR",target:im.Enum,targetName:"EDITOR"},{name:"UI",newName:"UI",target:im.Enum,targetName:"UI_3D"},{name:"UI2D",newName:"UI2D",target:im.Enum,targetName:"UI_2D"}]),v.VisibilityFlags=qG,nt(uT.prototype,"Pass.prototype",[{name:"getBindingTypeFromHandle",newName:"getDescriptorTypeFromHandle"}]),rt(Hx.prototype,"Camera.prototype",[{name:"getSplitFrustum"},{name:"setMatView"},{name:"setMatViewInv"},{name:"setMatProjInv"},{name:"setMatViewProjInv"},{name:"setMatProj"},{name:"setMatViewProj"},{name:"getMatViewInv"}]),rt(MT.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"}]),rt(FM.prototype,"SpotLight.prototype",[{name:"aspect"}]),nt(_M.prototype,"SubModel.prototype",[{name:"subMeshData",newName:"subMesh"}]),rt(_M.prototype,"SubModel.prototype",[{name:"getSubModel",suggest:"Use `subModels[i]` instead"},{name:"subModelNum",suggest:"Use `subModels.length` instead"}]);var YG,KG,JG,QG=function(t){if(void 0===fG[t]){var e=1<10||(p=.5*(s+a),m=.5*(o+h),g=.5*((c=.5*(e+n))+(d=.5*(n+s))),y=.5*((_=.5*(i+r))+(f=.5*(r+o))),((C=rU((n-a)*(E=h-i)-(r-h)*(b=a-e)))+(w=rU((s-a)*E-(o-h)*b)))*(C+w)=2*$G)l=2*$G;else for(;l<0;)l+=2*$G;else if(rU(l)>=2*$G)l=2*-$G;else for(;l>0;)l-=2*$G;for(h=0|eU(1,tU(rU(l)/(.5*$G)+.5,5)),c=rU(4/3*(1-iU(a=l/h/2))/nU(a)),o||(c=-c),A=0;A<=h;A++)f=e+(_=iU(u=r+l*(A/h)))*n,p=i+(d=nU(u))*n,m=-d*n*c,g=_*n*c,0===A?t.moveTo(f,p):t.bezierCurveTo(y+S,v+T,f-m,p-g,f,p),y=f,v=p,S=m,T=g}(this,t,e,i,n,r,s)},e.ellipse=function(t,e,i,n){aU(this,t,e,i,n),this._curPath.complex=!1},e.circle=function(t,e,i){aU(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 o=tU(s,.5*rU(n))*sU(n),a=tU(s,.5*rU(r))*sU(r);t.moveTo(e,i+a),t.lineTo(e,i+r-a),t.bezierCurveTo(e,i+r-a*(1-oU),e+o*(1-oU),i+r,e+o,i+r),t.lineTo(e+n-o,i+r),t.bezierCurveTo(e+n-o*(1-oU),i+r,e+n,i+r-a*(1-oU),e+n,i+r-a),t.lineTo(e+n,i+a),t.bezierCurveTo(e+n,i+a*(1-oU),e+n-o*(1-oU),i,e+n-o,i),t.lineTo(e+o,i),t.bezierCurveTo(e+o*(1-oU),i,e,i+a*(1-oU),e,i+a),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===lz.GRAPHICS_ELLIPSE){var h=n/2,u=r/2,l=s.x-.5*n,c=s.y-.5*r;a=l*l/(h*h)+c*c/(u*u)<1}return this._inverted&&(a=!a),a},i._nodeStateChange=function(){this._updateGraphics()},i._changeRenderType=function(){this._type!==lz.SPRITE_STENCIL?this._createGraphics():this._createSprite()},i._createSprite=function(){if(!this._sprite){var t=this._sprite=this.node.getComponent(uz);if(!t){var e=this.node;t=this._sprite=e.addComponent(uz)}}this._sprite.stencilStage=this.inverted?Sk.ENTER_LEVEL_INVERTED:Sk.ENTER_LEVEL,this._sprite.updateMaterial()},i._createGraphics=function(){if(!this._graphics){var t=this._graphics=this.node.getComponent(ZU);if(!t){var e=this.node;t=this._graphics=e.addComponent(ZU)}t.lineWidth=1;var i=dn.WHITE.clone();i.a=0,t.fillColor=i}this._graphics.stencilStage=this.inverted?Sk.ENTER_LEVEL_INVERTED:Sk.ENTER_LEVEL},i._updateGraphics=function(){if(this._graphics&&(this._type===lz.GRAPHICS_RECT||this._type===lz.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,o=-n*s.x,a=-r*s.y;if(this._type===lz.GRAPHICS_RECT)e.rect(o,a,n,r);else if(this._type===lz.GRAPHICS_ELLIPSE){for(var h=function(t,e,i){fz.length=0;for(var n=2*Math.PI/i,r=0;r"]),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),o=t.substring(r+1,n);""===o&&(s=t.substring(e,n+1)),this._processResult(s),-1===n?n=r:"/"===t.charAt(r+1)?this._stack.pop():this._addToStack(o),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 o="",a=-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=Ez.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(),o=t.substring(l).trim(),a="src"===n?this.getRightQuotationIndex(o):-1,h=(r=o.indexOf(" ",a+1>=o.length?-1:a+1))>-1?o.substr(0,r):o,t=o.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=Ez.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 _,d=/(\s)*color(\s)*=|(\s)*width(\s)*=|(\s)*click(\s)*=|(\s)*param(\s)*=/;for(i=d.exec(t);i;)n=(t=t.substring(t.indexOf(i[0]))).substr(0,i[0].length),_=(r=(o=t.substring(n.length).trim()).indexOf(" "))>-1?o.substr(0,r):o,n=(n=n.replace(/[^a-zA-Z]/g,"").trim()).toLowerCase(),t=o.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=d.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=bz.exec(t);r;){var s=r[0],o="";if(n=!1,'"'===(t=t.substring(s.length).trim()).charAt(0))(i=t.indexOf('"',1))>-1&&(o=t.substring(1,i).trim(),n=!0),i++;else if("'"===t.charAt(0))(i=t.indexOf("'",1))>-1&&(o=t.substring(1,i).trim(),n=!0),i++;else{var a=/(\S)+/.exec(t);i=(o=a?a[0]:"").length}n&&(e[s=s.substring(0,s.length-1).trim()]=o),t=t.substring(i).trim(),r=bz.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=d(this._specialSymbolArray);!(e=i()).done;){var n=e.value,r=n[0],s=n[1];t=t.replace(r,s)}return t},t}()),wz=t("m",qs("cc.LabelOutline")(mz=Ks(110)(mz=Ys(lG)(mz=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.onEnable=function(){this.node.getComponent(lG).enableOutline=!0},i.onDisable=function(){this.node.getComponent(lG).enableOutline=!1},n(e,[{key:"color",get:function(){return this.node.getComponent(lG).outlineColor},set:function(t){this.node.getComponent(lG).outlineColor=t}},{key:"width",get:function(){return this.node.getComponent(lG).outlineWidth},set:function(t){this.node.getComponent(lG).outlineWidth=t}}]),e}(rp))||mz)||mz)||mz);v.LabelOutline=wz,pt({RenderComponent:{newName:"UIRenderer",since:"1.2.0",removed:!0},UITransformComponent:{newName:"UITransform",since:"1.2.0",removed:!1},CanvasComponent:{newName:"Canvas",since:"1.2.0",removed:!1}}),pt({UIRenderable:{newName:"UIRenderer",since:"3.0.0",removed:!0}}),pt({Renderable2D:{newName:"UIRenderer",since:"3.6.0",removed:!1}});var xz,Rz,Iz,Bz,Dz,Pz,Oz,Mz,Lz,Nz,Fz,kz,Vz,Gz,Uz,zz,Hz,Wz,jz,Xz,qz,Yz,Kz,Jz,Qz,Zz,$z,tH,eH,iH,nH,rH,sH,oH,aH,hH,uH=qs("cc.PostProcess")(gz=Js(((Az=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r0&&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,o=this._visibleRect,a=r.viewport;s.x=a.x,s.y=a.y,s.width=a.width,s.height=a.height,o.x=0,o.y=0,o.width=a.width/this._scaleX,o.height=a.height/this._scaleY}n.postApply(this),yH.width=this._visibleRect.width,yH.height=this._visibleRect.height,Rl&&Rl.init(this._visibleRect),this.emit("design-resolution-changed")}else J(2200)},i.getDesignResolutionSize=function(){return new Vn(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 El.devicePixelRatio},i.convertToLocationInView=function(t,e,i,n){void 0===n&&(n=new Ln);var r=El.devicePixelRatio*(t-i.left),s=El.devicePixelRatio*(i.top+i.height-e);return El.isFrameRotated?(n.x=wl.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;v.director.root.resize(t,e,void 0===i||0===i?1:i);var r=this._designResolutionSize.width,s=this._designResolutionSize.height;t>0&&this.setDesignResolutionSize(r,s,this._resolutionPolicy),this.emit("canvas-resize"),null===(n=this._resizeCallback)||void 0===n||n.call(this)},e}(Yu(Ou)));SH.instance=void 0;var TH=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=v.game.canvas;if(t){var e=wl.windowSize;t.width!==e.width&&(t.width=e.width),t.height!==e.height&&(t.height=e.height)}},t}();TH.EQUAL_TO_FRAME=void 0,TH.PROPORTION_TO_FRAME=void 0;var AH=function(){function t(){this.name="ContentStrategy",this._result=void 0,this._result={scale:[1,1],viewport:null}}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 o=new Un(Math.round((t-i)/2),Math.round((e-n)/2),i,n);return this._result.scale=[r,s],this._result.viewport=o,this._result},t}();AH.EXACT_FIT=void 0,AH.SHOW_ALL=void 0,AH.NO_BORDER=void 0,AH.FIXED_HEIGHT=void 0,AH.FIXED_WIDTH=void 0,function(){var t=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;rp?0:f>0?f:p}v.Canvas=kH,rt(t("U",qs("cc.UIComponent")(MH=Ys(nV)(MH=Ks(110)(MH=Js(MH=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;re||0===zH)&&(zH=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))):(zH=e,s&&s.push({distance:e,vertexIndex0:i/3,vertexIndex1:n/3,vertexIndex2:r/3}))},function(t,e,i){if(zH=0,0===e.geometricInfo.positions.length)return zH;var n=void 0===i?UH:i;if(VH(t,e.geometricInfo.boundingBox.min,e.geometricInfo.boundingBox.max)){var r=e.primitiveMode,s=e.geometricInfo;!function(t,e,i,n,r){if(i===pc.TRIANGLE_LIST)for(var s=e.length,o=0;or.distance)&&(HH(r.mode,l,a,h,u,r.result),r.mode===lu.ANY))return l}else if(i===pc.TRIANGLE_STRIP)for(var c=e.length-2,_=0,d=0;dr.distance)&&(HH(r.mode,g,f,p,m,r.result),r.mode===lu.ANY))return g}else if(i===pc.TRIANGLE_FAN){var y=e.length-1,v=3*e[0];on.set(GH.a,t[v],t[v+1],t[v+2]);for(var S=1;Sr.distance)&&(HH(r.mode,b,v,T,A,r.result),r.mode===lu.ANY))return b}}}(s.positions,s.indices,r,t,n)}return zH}),YH=function(){var t=0,e={distance:1/0,doubleSided:!1,mode:lu.ANY};return function(i,n,r){t=0;var s=void 0===r?e:r,o=n.renderingSubMeshes.length,a=n.struct.minPosition,h=n.struct.maxPosition;if(a&&h&&!VH(i,a,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===lu.ANY)return c}return t&&s.mode===lu.CLOSEST&&(s.result&&(s.result[0].distance=t,s.result.length=1),s.subIndices&&(s.subIndices.length=1)),t}}(),KH=function(){var t=0,e={distance:1/0,doubleSided:!1,mode:lu.ANY},i=new or,n=new In;return function(r,s,o){t=0;var a=void 0===o?e:o,h=s.worldBounds;if(h&&!as.rayAABB(r,h))return t;or.copy(i,r),s.node&&(In.invert(n,s.node.getWorldMatrix(n)),on.transformMat4(i.o,r.o,n),on.transformMat4Normal(i.d,r.d,n));for(var u=s.subModels,l=0;l_)&&(t=_,a.subIndices&&(a.subIndices[0]=l));else if(t=_,a.subIndices&&a.subIndices.push(l),a.mode===lu.ANY)return _}return t&&a.mode===lu.CLOSEST&&(a.result&&(a.result[0].distance=t,a.result.length=1),a.subIndices&&(a.subIndices.length=1)),t}}();as.rayModel=KH,as.raySubMesh=qH,as.rayMesh=YH,rT("specular-pass");var JH,QH,ZH,$H,tW,eW,iW,nW,rW,sW,oW,aW,hW,uW,lW,cW,_W,dW=t("dZ",qs("cc.ModelRenderer")((jH=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r0)for(var t=0;tc;){if((s/=2)<1){s*=2;break}o=o.substring(r,s),a=n.substring(s),this._calculateSize(h,e,o)}for(var _=1e3,d=1;_&&r0&&(d=f[0].length),s+=d,o=n.substring(r,s),a=n.substring(s),this._calculateSize(h,e,o),_--}for(;_&&o.length>=2&&h.x>c;)s-=d,o=n.substring(r,s),this._calculateSize(h,e,o),d=1,_--;if(o.length>=2){var p=QF(o);p&&p.length>0&&o!==p[0]&&(s-=p[0].length,o=n.substring(r,s))}if(i.push(o),r=s,s+=o.length,o=n.substring(r,s),a=n.substring(s),this._calculateSize(u,e,a),this._calculateSize(h,e,o),_--,u.x<2048&&h.x=0;e--){var i=t[e];if(i.name===zW||i.name===HW){i.parent=null;var n=YW(i.name);n.node=i,i.name===zW?(n.comp=i.getComponent(lG),XW.put(n)):(n.comp=i.getComponent(uz),qW.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!==zW&&i.name!==HW||(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(lG);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),o=t.substr(r,s),a=this._measureText(i,o);if(!(this._lineOffsetX+a<=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+=a,r+=s}if(n>this._maxWidth)for(var u=ZF(t,n,this._maxWidth,this._measureText(i)),l=0;l1&&l0?(a*=o=l/h,h*=o):(a*=o=this._lineHeight/h,h*=o),u>0&&(a=u),this._maxWidth>0?(this._lineOffsetX+a>this._maxWidth&&this._updateLineInfo(),this._lineOffsetX+=a):(this._lineOffsetX+=a,this._lineOffsetX>this._labelWidth&&(this._labelWidth=this._lineOffsetX)),r.node._uiProps.uiTransformComp.setContentSize(a,h),r.lineCount=this._lineCount,r.clickHandler="",r.clickParam="";var c=e.event;c&&(r.clickHandler=c.click,r.clickParam=c.param)}else Y(4400)}},i._updateTextDefaultColor=function(){for(var t=0;t0){var u=this._measureText(n,h);this._updateRichTextWithMaxWidth(h,u,n),o.length>1&&athis._labelWidth&&(this._labelWidth=this._lineOffsetX),o.length>1&&a0&&(this._labelWidth=this._maxWidth),this._labelHeight=(this._lineCount+NF)*this._lineHeight,this.node._uiProps.uiTransformComp.setContentSize(this._labelWidth,this._labelHeight),this._updateRichTextPosition(),this._layoutDirty=!1}},i._getFirstWordLen=function(t,e,i){var n=t.charAt(e);if(XF(n)||qF(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 iG.LEFT:break;case iG.CENTER:u-=this._linesWidth[h-1]/2;break;case iG.RIGHT:u-=this._linesWidth[h-1]}var l=a.node.position;if(a.node.setPosition(t+u,this._lineHeight*(i-h)-this._labelHeight*s,l.z),h===e&&(t+=a.node._uiProps.uiTransformComp.width),a.node.getComponent(uz)){var c=a.node.position.clone(),_=this._lineHeight,d=this._lineHeight*(1+NF);switch(a.node._uiProps.uiTransformComp.anchorY){case 1:c.y+=_+(d-_)/2;break;case.5:c.y+=d/2;break;default:c.y+=(d-_)/2}if(a.imageOffset){var f=a.imageOffset.split(",");if(1===f.length&&f[0]){var p=parseFloat(f[0]);Number.isInteger(p)&&(c.y+=p)}else if(2===f.length){var m=parseFloat(f[0]),g=parseFloat(f[1]);Number.isInteger(m)&&(c.x+=m),Number.isInteger(g)&&(c.y+=g)}}a.node.position=c}var y=a.node.getComponent(wz);if(y){var v=a.node.position.clone();v.y-=y.width,a.node.position=v}}},i._convertLiteralColorValue=function(t){var e=t.toUpperCase();return dn[e]?dn[e]:(new dn).fromHEX(t)},i._applyTextAttribute=function(t){var e=t.node.getComponent(lG);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(wz);r||(r=t.node.addComponent(wz)),r.color=this._convertLiteralColorValue(i.outline.color),r.width=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 TF&&!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=d(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}(rp)).HorizontalAlign=iG,GW.VerticalAlign=nG,p((CW=GW).prototype,"horizontalAlign",[yW],Object.getOwnPropertyDescriptor(CW.prototype,"horizontalAlign"),CW.prototype),p(CW.prototype,"verticalAlign",[vW],Object.getOwnPropertyDescriptor(CW.prototype,"verticalAlign"),CW.prototype),p(CW.prototype,"fontColor",[SW],Object.getOwnPropertyDescriptor(CW.prototype,"fontColor"),CW.prototype),p(CW.prototype,"font",[TW],Object.getOwnPropertyDescriptor(CW.prototype,"font"),CW.prototype),p(CW.prototype,"cacheMode",[AW],Object.getOwnPropertyDescriptor(CW.prototype,"cacheMode"),CW.prototype),p(CW.prototype,"imageAtlas",[bW],Object.getOwnPropertyDescriptor(CW.prototype,"imageAtlas"),CW.prototype),wW=ks(CW.prototype,"_lineHeight",[io],(function(){return 40})),xW=ks(CW.prototype,"_string",[io],(function(){return"RichText"})),RW=ks(CW.prototype,"_horizontalAlign",[io],(function(){return iG.LEFT})),IW=ks(CW.prototype,"_verticalAlign",[io],(function(){return nG.TOP})),BW=ks(CW.prototype,"_fontSize",[io],(function(){return 40})),DW=ks(CW.prototype,"_fontColor",[io],(function(){return dn.WHITE.clone()})),PW=ks(CW.prototype,"_maxWidth",[io],(function(){return 0})),OW=ks(CW.prototype,"_fontFamily",[io],(function(){return"Arial"})),MW=ks(CW.prototype,"_font",[io],(function(){return null})),LW=ks(CW.prototype,"_isSystemFontUsed",[io],(function(){return!0})),NW=ks(CW.prototype,"_userDefinedFont",[io],(function(){return null})),FW=ks(CW.prototype,"_cacheMode",[io],(function(){return sG.NONE})),kW=ks(CW.prototype,"_imageAtlas",[io],(function(){return null})),VW=ks(CW.prototype,"_handleTouchEvent",[io],(function(){return!0})),EW=CW))||EW)||EW));v.RichText=QW;var ZW=t("k",qs("cc.UIMeshRenderer")(JW=Ks(110)(JW=function(t){function e(){var e;return(e=t.call(this)||this)._modelComponent=null,e._dirtyVersion=-1,e._internalId=-1,e.stencilStage=Sk.DISABLED,e._renderData=null,e._renderEntity=new Wk(xk.DYNAMIC),e}s(e,t);var i=e.prototype;return i.__preload=function(){this.node._uiProps.uiComp=this},i.onEnable=function(){nN.addRenderer(this),this.markForUpdateRenderData()},i.onDisable=function(){nN.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):k("node '"+(this.node&&this.node.name)+"' doesn't have any renderable component")},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)o=Ij(s,t[s],t[s+1],o);return o&&Cj(o,o.next)&&(Bj(o),o=o.next),o}function _j(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||!Cj(i,i.next)&&0!==Ej(i.prev,i,i.next))i=i.next;else{if(Bj(i),(i=e=i.prev)===i.next)return null;n=!0}}while(n||i!==e);return e}function dj(t,e,i,n,r,s,o){if(void 0===o&&(o=0),t){!o&&s&&function(t,e,i,n){var r=t;do{null===r.z&&(r.z=Sj(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,o=0,a=0,h=0,u=1;do{for(i=t,t=null,s=null,o=0;i;){for(o++,n=i,a=0,e=0;e0||h>0&&n;)0===a?(r=n,n=n.nextZ,h--):0!==h&&n?i.z<=n.z?(r=i,i=i.nextZ,a--):(r=n,n=n.nextZ,h--):(r=i,i=i.nextZ,a--),s?s.nextZ=r:t=r,r.prevZ=s,s=r;i=n}s.nextZ=null,u*=2}while(o>1)}(r)}(t,n,r,s);for(var a=t,h=null,u=null;t.prev!==t.next;)if(h=t.prev,u=t.next,s?pj(t,n,r,s):fj(t))e.push(h.i/i),e.push(t.i/i),e.push(u.i/i),Bj(t),t=u.next,a=u.next;else if((t=u)===a){o?1===o?dj(t=mj(t,e,i),e,i,n,r,s,2):2===o&&gj(t,e,i,n,r,s):dj(_j(t),e,i,n,r,s,1);break}}}function fj(t){var e=t.prev,i=t,n=t.next;if(Ej(e,i,n)>=0)return!1;for(var r=t.next.next;r!==t.prev;){if(Aj(e.x,e.y,i.x,i.y,n.x,n.y,r.x,r.y)&&Ej(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function pj(t,e,i,n){var r=t.prev,s=t,o=t.next;if(Ej(r,s,o)>=0)return!1;for(var a=r.xs.x?r.x>o.x?r.x:o.x:s.x>o.x?s.x:o.x,l=r.y>s.y?r.y>o.y?r.y:o.y:s.y>o.y?s.y:o.y,c=Sj(a,h,e,i,n),_=Sj(u,l,e,i,n),d=t.nextZ;d&&d.z<=_;){if(d!==t.prev&&d!==t.next&&Aj(r.x,r.y,s.x,s.y,o.x,o.y,d.x,d.y)&&Ej(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(d=t.prevZ;d&&d.z>=c;){if(d!==t.prev&&d!==t.next&&Aj(r.x,r.y,s.x,s.y,o.x,o.y,d.x,d.y)&&Ej(d.prev,d,d.next)>=0)return!1;d=d.prevZ}return!0}function mj(t,e,i){var n=t;do{var r=n.prev,s=n.next.next;!Cj(r,s)&&wj(r,n,n.next,s)&&xj(r,s)&&xj(s,r)&&(e.push(r.i/i),e.push(n.i/i),e.push(s.i/i),Bj(n),Bj(n.next),n=t=s),n=n.next}while(n!==t);return n}function gj(t,e,i,n,r,s){var o=t;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&bj(o,a)){var h=Rj(o,a);return o=_j(o,o.next),h=_j(h,h.next),dj(o,e,i,n,r,s),void dj(h,e,i,n,r,s)}a=a.next}o=o.next}while(o!==t)}function yj(t,e){return t.x-e.x}function vj(t,e){if(e=function(t,e){var i=e,n=t.x,r=t.y,s=-1/0,o=null;do{if(r<=i.y&&r>=i.next.y){var a=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(a<=n&&a>s){if(s=a,a===n){if(r===i.y)return i;if(r===i.next.y)return i.next}o=i.x=i.x&&i.x>=l&&Aj(ro.x)&&xj(i,t)&&(o=i,_=h),i=i.next;return o}(t,e)){var i=Rj(e,t);_j(i,i.next)}}function Sj(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 Tj(t){var e=t,i=t;do{e.x=0&&(t-o)*(n-a)-(i-o)*(e-a)>=0&&(i-o)*(s-a)-(r-o)*(n-a)>=0}function bj(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&&wj(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&xj(t,e)&&xj(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 Ej(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Cj(t,e){return t.x===e.x&&t.y===e.y}function wj(t,e,i,n){return!!(Cj(t,e)&&Cj(i,n)||Cj(t,n)&&Cj(i,e))||Ej(t,e,i)>0!=Ej(t,e,n)>0&&Ej(i,n,t)>0!=Ej(i,n,e)>0}function xj(t,e){return Ej(t.prev,t,t.next)<0?Ej(t,e,t.next)>=0&&Ej(t,t.prev,e)>=0:Ej(t,e,t.prev)<0||Ej(t,t.next,e)<0}function Rj(t,e){var i=new lj(t.i,t.x,t.y),n=new lj(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 Ij(t,e,i,n){var r=new lj(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 Bj(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 Dj(t,e,i){i=i||3;var n=e?e.length:0,r=n?e[0]*i:t.length,s=cj(t,0,r,i,!0),o=[];if(!s)return o;var a=0,h=0,u=0,l=0,c=0,_=0,d=0;if(n&&(s=function(t,e,i,n){var r,s=[],o=0,a=null;for(o=0,r=e.length;o80*i){a=u=t[0],h=l=t[1];for(var f=i;fu&&(u=c),_>l&&(l=_);d=Math.max(u-a,l-h)}return dj(s,o,i,a,h,d),o}for(var Pj=Math.PI,Oj=Math.min,Mj=Math.max,Lj=Math.ceil,Nj=Math.acos,Fj=Math.cos,kj=Math.sin,Vj=Math.atan2,Gj=null,Uj=null,zj=new dn,Hj=[],Wj=0;Wj<4;Wj++)Hj.push(new on);function jj(t,e,i){return ti?i:t}var Xj={useModel:!0,updateRenderData:function(){},fillBuffers:function(){},renderIA:function(){},getRenderData:function(t,e){if(!Uj)return null;var i=Uj.getRenderDataList(),n=i[Uj.dataOffset];if(!n)return null;var r=n,s=r?r.vertexStart+e:0;return(s>65535||3*s>131070)&&(++Uj.dataOffset,Uj.dataOffset0&&(r=1/e);for(var s=t.paths,o=t.pathOffset,a=t.pathLength;o1e-6){var S=1/f;S>600&&(S=600),_.dmx*=S,_.dmy*=S}_.dx*c.dy-c.dx*_.dy>0&&(_.flags|=JG.PT_LEFT),f*(p=Mj(11,Oj(c.len,_.len)*r))*p<1&&(_.flags|=JG.PT_INNERBEVEL),_.flags&JG.PT_CORNER&&(f*n*n<1||i===KG.BEVEL||i===KG.ROUND)&&(_.flags|=JG.PT_BEVEL),0!=(_.flags&(JG.PT_BEVEL|JG.PT_INNERBEVEL))&&h.bevel++,c=_,_=u[d+1]}}},_flattenPaths:function(t){for(var e=t.paths,i=t.pathOffset,n=t.pathLength;i2&&o.equals(a)&&(r.closed=!0,s.pop(),o=s[s.length-1]);for(var h=0,u=s.length;hm&&(g-=2*Pj),this._vSet(_,d,1),this._vSet(u-s*n,e.y-o*n,-1);for(var y=jj(Lj((m-g)/Pj)*r,2,r),v=0;vKj||n.canvasSize.height>Kj)&&o<=3;){if(++o>3)this._fontScale=1;else{var a=Math.max(n.canvasSize.width,n.canvasSize.height),h=Kj/a;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,o){t?(this._computeAlignmentOffset(e,i,n),this.generateVertexData(t,e,i,n,r,s,o)):(this._updateLabelDimensions(e,i,n),this._updateTexture(e,i,n,r),this.generateVertexData(t,e,i,n,r,s,o))},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?a:u}var l=a,c=(s.length+NF)*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 rG.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 rG.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 rG.RESIZE_HEIGHT:this._calculateWrapText(r,t,e,i);var _=(i.parsedString.length+NF)*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),o=0,a=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;a=c+1;for(var _=0,d=0|e.actualFontSize+1,f=0;_>1)<=0){X(4003);break}u=f,r=this._getFontDesc(u,e.fontFamily,e.isBold,e.isItalic),this._context.font=r;var p=this._getLineHeight(i.lineHeight,u,e.fontSize);for(a=0,o=0;oc?d=f-1:_=f}0===_?X(4003):(u=_,r=this._getFontDesc(u,e.fontFamily,e.isBold,e.isItalic),this._context.font=r)}else{for(a=t.length*this._getLineHeight(i.lineHeight,u,e.fontSize),o=0;o1&&i.hasShadow,o=this._measureText(this._context,i.fontDesc),a=0,h=0;i.hasShadow&&this._setupShadow(i),i.isOutlined&&this._setupOutline(i);for(var 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,o=e.length;r0&&h>0&&w+f.w*t.bmfontScale>e.maxLineWidth&&!qF(m)){e.linesWidth.push(c),c=0,a++,h=0,u-=e.lineHeight*this._getFontScale(t,e)+0,A=!0;break}b.x=w,b.y=u-f.offsetY*t.bmfontScale,this._recordLetterInfo(b,m,C,a),C+1b.y-f.h*t.bmfontScale&&(v=b.y-f.h*t.bmfontScale)}else this._recordPlaceholderInfo(C,m),null!=t.fntConfig?F("Can't find letter definition in texture atlas "+t.fntConfig.atlasName+" for letter:"+m):F("Can't find letter definition in font family "+t.fontFamily+" for letter:"+m);else this._recordPlaceholderInfo(C,m)}A||(h=T,_v&&(d=v),l<(c=S)&&(l=c),p+=g)}else e.linesWidth.push(c),c=0,a++,h=0,u-=e.lineHeight*this._getFontScale(t,e)+0,this._recordPlaceholderInfo(p,m),p++}return e.linesWidth.push(c),e.numberOfLines=a+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*ak.margin),e.textHeightTemp<=0&&(i.nodeContentSize.height=parseFloat(e.textDesiredHeight.toFixed(2))+2*ak.margin),e.tailoredTopY=i.nodeContentSize.height,e.tailoredBottomY=0,_>0&&(e.tailoredTopY=i.nodeContentSize.height+_),d<-e.textDesiredHeight&&(e.tailoredBottomY=e.textDesiredHeight+d),!0},e._recordPlaceholderInfo=function(t,e){if(t>=this._lettersInfo.length){var i=new Qj;this._lettersInfo.push(i)}this._lettersInfo[t].char=e,this._lettersInfo[t].hash=""+e.charCodeAt(0)+ak.hash,this._lettersInfo[t].valid=!1},e._recordLetterInfo=function(t,e,i,n){if(i>=this._lettersInfo.length){var r=new Qj;this._lettersInfo.push(r)}var s=""+e.charCodeAt(0)+ak.hash;this._lettersInfo[i].line=n,this._lettersInfo[i].char=e,this._lettersInfo[i].hash=s,this._lettersInfo[i].valid=ak.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=i.charAt(n);if(XF(s)||"\n"===s||qF(s))return 1;var o=1,a=ak.fontAtlas.getLetterDefinitionForChar(s,ak);if(!a)return o;for(var h=a.xAdvance*t.bmfontScale+e.spacingX,u=n+1;ue.maxLineWidth&&!qF(s)&&e.maxLineWidth>0)return o;if(h+=a.xAdvance*t.bmfontScale+e.spacingX,"\n"===s||qF(s)||XF(s))break;o++}return o},e._computeAlignmentOffset=function(t,e,i){switch(e.linesOffsetX.length=0,e.letterOffsetY=0,e.horizontalAlign){case iG.LEFT:for(var n=0;ni.nodeContentSize.height},e._isHorizontalClamp=function(t,e,i,n,r){for(var s=!1,o=0,a=n.length;o0)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,o=0|t.actualFontSize,a=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)?o=a-1:s=a}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 o=t.spriteFrame?t.spriteFrame.texture:ak.fontAtlas.getTexture(),a=n.uiTransAnchorX*i.nodeContentSize.width,h=n.uiTransAnchorY*i.nodeContentSize.height,u=0,l=r.length;u0){if(d>e.tailoredTopY){var f=d-e.tailoredTopY;this._tmpRect.y+=f,this._tmpRect.height-=f,d-=f}d-this._tmpRect.height*t.bmfontScale0&&this._isHorizontalClamped(e,i,m,p)&&e.overFlow===rG.CLAMP&&(this._tmpRect.width=0),this._tmpRect.height>0&&this._tmpRect.width>0){var g=this._determineRect(t),y=c.x+e.linesOffsetX[c.line],v=n.quadCount;n.quadCount+=4,this.updateQuatCount(n),s(t,i,n,v,o,this._tmpRect,g,y-a,d-h)}}else k("Can't find letter in this bitmap-font")}}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(),o=s.x+(n.width-r.width)/2,a=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-a,this._tmpRect.y=h+r.y-o,this._tmpRect.y<0&&(this._tmpRect.height+=a)}else this._tmpRect.x+=r.x-o,this._tmpRect.y+=r.y+a;return i},t}();Zj.instance=void 0,Zj.instance=new Zj;var $j,tX=new ok(64,64),eX=new OF(null),iX=null,nX=null,rX=null,sX=null,oX={updateProcessingData:function(t,e,i,n,r,s){t.fontSize=r.fontSize,t.actualFontSize=r.fontSize,t.originFontSize=rX?rX.fontSize:r.fontSize,e.horizontalAlign=r.horizontalAlign,e.verticalAlign=r.verticalAlign,e.spacingX=r.spacingX;var o=r.overflow;e.overFlow=o,e.lineHeight=r.lineHeight,i.nodeContentSize.width=s.width,i.nodeContentSize.height=s.height,o===rG.NONE?(e.wrapping=!1,i.nodeContentSize.width+=2*ak.margin,i.nodeContentSize.height+=2*ak.margin):o===rG.RESIZE_HEIGHT?(e.wrapping=!0,i.nodeContentSize.height+=2*ak.margin):e.wrapping=r.enableWrapText,n.uiTransAnchorX=s.anchorX,n.uiTransAnchorY=s.anchorY,ak.lineHeight=r.lineHeight,ak.fontSize=r.fontSize,t.spriteFrame=sX,t.fntConfig=rX,t.fontFamily=ak.fontFamily,t.color.set(r.color)},updateRenderData:function(t){if(t.renderData&&iX!==t){if(t.renderData.vertDirty){nX=(iX=t).node._uiProps.uiTransformComp;var e=t.renderData,i=Zj.instance,n=t.textStyle,r=t.textLayout,s=t.textLayoutData,o=t.textRenderData;n.fontScale=CH.getScaleX(),this._updateFontFamily(t),this.updateProcessingData(n,r,s,o,t,nX),this._updateLabelInfo(t),n.fontDesc=ak.fontDesc,i.processingString(!0,n,r,s,t.string),this.resetRenderData(t),o.quadCount=0,i.generateRenderInfo(!0,n,r,s,o,t.string,this.generateVertexData),e.dataLength=o.quadCount,e.resize(e.dataLength,e.dataLength/2*3);for(var a=e.data,h=0,u=o.quadCount;h0?(ak.isOutlined=!0,ak.margin=t.outlineWidth,ak.out=t.outlineColor.clone(),ak.out.a=t.outlineColor.a*t.color.a/255):(ak.isOutlined=!1,ak.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){ak.fontDesc=this._getFontDesc(),ak.color=t.color,ak.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}(ak)},_getFontDesc:function(){return ak.fontSize.toString()+"px "+ak.fontFamily}}),cX=new dn(255,255,255,255),_X={createData:function(t){var e=t.requestRenderData();return e.resize(0,0),e},fillBuffers:function(t){if(t.renderData){var e=t.node;cX.a=255*e._uiProps.opacity,wd(e,0,t.renderData,cX)}},updateColor:function(){}};Vt(_X,lX);var dX=lG.Overflow,fX={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===dX.NONE?e.wrapping=!1:r.overflow===dX.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||!wi(r.shadowOffset.x,0)||!wi(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=lG._canvasPool.get();return t.canvas.width=t.canvas.height=1,t},resetAssemblerData:function(t){t&&lG._canvasPool.put(t)},updateRenderData:function(t){if(t.renderData){if(t.renderData.vertDirty){var e=t.node._uiProps.uiTransformComp,i=Zj.instance,n=t.textStyle,r=t.textLayout,s=t.textLayoutData,o=t.textRenderData;n.fontScale=CH.getScaleX(),this.updateProcessingData(n,r,s,o,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,o,t.string,this.generateVertexData);var a=t.renderData;a.textureDirty=!0,this._calDynamicAtlas(t,s),t.actualFontSize=n.actualFontSize,e.setContentSize(s.nodeContentSize);var h=a.data;h[0]=o.vertexBuffer[0],h[1]=o.vertexBuffer[1],h[2]=o.vertexBuffer[2],h[3]=o.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,o=i.uiTransAnchorX*r,a=i.uiTransAnchorY*s;n[0].x=-o,n[0].y=-a,n[1].x=r-o,n[1].y=-a,n[2].x=-o,n[2].y=s-a,n[3].x=r-o,n[3].y=s-a},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!==lG.CacheMode.BITMAP||e.canvasSize.width<=0||e.canvasSize.height<=0)){var i=t.ttfSpriteFrame;bN.packToDynamicAtlas(t,i)}},_resetDynamicAtlas:function(t){if(t.cacheMode===lG.CacheMode.BITMAP){var e=t.ttfSpriteFrame;bN.deleteAtlasSpriteFrame(e),e._resetDynamicAtlasFrame()}}},pX=dn.WHITE.clone(),mX=Uint16Array.from([0,1,2,1,3,2]),gX={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++)dn.toArray(i,pX,n),n+=9;return e.chunk.setIndexBuffer(mX),e},fillBuffers:function(t){for(var e=t.renderData,i=e.chunk,n=e.data,r=t.node,s=i.vb,o=r.worldMatrix,a=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,o=n.height,a=n.rect,h=0,u=0,l=0,c=0,_=0,d=0,f=0,p=0,m=0,g=0;switch(n.isRotated()?(h=a.x/s,u=(a.y+a.width)/o,l=_=h,f=m=(a.x+a.height)/s,d=g=u,c=p=a.y/o):(h=a.x/s,u=(a.y+a.height)/o,l=f=h,_=m=(a.x+a.width)/s,c=d=u,p=g=a.y/o),t.fillType){case vX.HORIZONTAL:r[3]=l+(_-l)*e,r[4]=c+(d-c)*e,r[12]=l+(_-l)*i,r[13]=c+(d-c)*i,r[21]=f+(m-f)*e,r[22]=p+(g-p)*e,r[30]=f+(m-f)*i,r[31]=p+(g-p)*i;break;case vX.VERTICAL:r[3]=l+(f-l)*e,r[4]=c+(p-c)*e,r[12]=_+(m-_)*e,r[13]=d+(g-d)*e,r[21]=l+(f-l)*i,r[22]=c+(p-c)*i,r[30]=_+(m-_)*i,r[31]=d+(g-d)*i;break;default:J(2626)}},updateVertexData:function(t,e,i){var n=t.renderData.data,r=t.node._uiProps.uiTransformComp,s=r.width,o=r.height,a=r.anchorX*s,h=r.anchorY*o,u=-a,l=-h,c=s-a,_=o-h,d=0;switch(t.fillType){case vX.HORIZONTAL:d=u+(c-u)*i,u+=(c-u)*e,c=d;break;case vX.VERTICAL:d=l+(_-l)*i,l+=(_-l)*e,_=d;break;default:J(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(TX);for(var i,n=d(e.data);!(i=n()).done;)i.value.z=0;return e},updateWorldVertexData:function(t,e){t.node.getWorldMatrix(SX);for(var i=t.renderData.floatStride,n=t.renderData.data,r=e.vb,s=0,o=0;o<4;o++){var a=n[o],h=a.x,u=a.y,l=SX.m03*h+SX.m07*u+SX.m15;l=l?1/l:1,r[s=o*i]=(SX.m00*h+SX.m04*u+SX.m12)*l,r[s+1]=(SX.m01*h+SX.m05*u+SX.m13)*l,r[s+2]=(SX.m02*h+SX.m06*u+SX.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,o=r.indexOffset;s[o++]=n,s[o++]=n+1,s[o++]=n+2,s[o++]=n+2,s[o++]=n+1,s[o++]=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,o=s.r/255,a=s.g/255,h=s.b/255,u=t.node._uiProps.opacity,l=0;l<4;l++)i[r]=o,i[r+1]=a,i[r+2]=h,i[r+3]=u,r+=n}},bX=2*Math.PI,EX=1e-6,CX=new In,wX=[new Ln,new Ln,new Ln,new Ln],xX=new Array(4),RX=new Array(8),IX=[new Ln,new Ln,new Ln,new Ln],BX=[new Ln,new Ln,new Ln,new Ln],DX=new Ln,PX=[new Ln,new Ln,new Ln,new Ln],OX=null;function MX(t,e,i,n,r,s,o){var a=Math.sin(s);a=Math.abs(a)>EX?a:0;var h=Math.cos(s),u=0,l=0;if(0!==(h=Math.abs(h)>EX?h:0)){if(u=a/h,(t-r.x)*h>0){var c=r.y+u*(t-r.x);o[0].x=t,o[0].y=c}if((e-r.x)*h>0){var _=r.y+u*(e-r.x);o[2].x=e,o[2].y=_}}if(0!==a){if(l=h/a,(n-r.y)*a>0){var d=r.x+l*(n-r.y);o[3].x=d,o[3].y=n}if((i-r.y)*a>0){var f=r.x+l*(i-r.y);o[1].x=f,o[1].y=i}}}function LX(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 NX(t,e,i,n,r){var s=xX,o=s[0],a=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,FX((i.x-o)/(h-o),(i.y-a)/(u-a),t,e),FX((n.x-o)/(h-o),(n.y-a)/(u-a),t,e+1),FX((r.x-o)/(h-o),(r.y-a)/(u-a),t,e+2)}function FX(t,e,i,n){var r=RX,s=r[0]+(r[2]-r[0])*t,o=r[4]+(r[6]-r[4])*t,a=r[1]+(r[3]-r[1])*t,h=r[5]+(r[7]-r[5])*t,u=i[n];u.u=s+(o-s)*e,u.v=a+(h-a)*e}for(var kX={useModel:!1,createData:function(t){return t.requestRenderData()},updateRenderData:function(t){var e=t.spriteFrame;bN.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 o=(r*=bX)+(s*=bX);!function(t){var e=t.node._uiProps.uiTransformComp,i=e.width,n=e.height,r=e.anchorX*i,s=e.anchorY*n,o=-r,a=-s,h=i-r,u=n-s,l=xX;l[0]=o,l[1]=a,l[2]=h,l[3]=u;var c=t.fillCenter,_=DX.x=Math.min(Math.max(0,c.x),1)*(h-o)+o,d=DX.y=Math.min(Math.max(0,c.y),1)*(u-a)+a;wX[0].x=wX[3].x=o,wX[1].x=wX[2].x=h,wX[0].y=wX[1].y=a,wX[2].y=wX[3].y=u;for(var f=0,p=PX;f=bX)i.dataLength=a+3,NX(n,a,DX,wX[u.x],wX[u.y]),a+=3;else{var l=LX(DX,wX[u.x]),c=LX(DX,wX[u.y]);c=o||(l>=r?(i.dataLength=a+3,NX(n,a,DX,wX[u.x],c>=o?BX[h]:wX[u.y]),a+=3):c>r&&(c<=o?(i.dataLength=a+3,NX(n,a,DX,IX[h],wX[u.y]),a+=3):(i.dataLength=a+3,NX(n,a,DX,IX[h],BX[h]),a+=3))),l+=bX,c+=bX}}0===a&&(i.dataLength=0),i.resize(a,a),i.updateRenderData(t,e)}},createQuadIndices:function(t){OX=null,OX=new Uint16Array(t);for(var e=0,i=0;i1?1:p,m=Number.isNaN(m)||m>1?1:m,d=d<0?0:d,f=f<0?0:f,zX[0].x=-o,zX[0].y=-a,zX[1].x=u*p-o,zX[1].y=_*m-a,zX[2].x=zX[1].x+d,zX[2].y=zX[1].y+f,zX[3].x=r-o,zX[3].y=s-a;for(var g=0;g<4;g++)for(var y=0;y<4;y++){var v=4*g+y;v0||t.insetBottom>0||t.insetLeft>0||t.insetRight>0)?2:0}var nq={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),o=i.getRect(),a=i.insetLeft,h=i.insetRight,u=o.width-a-h,l=i.insetTop,c=i.insetBottom,_=o.height-l-c,d=r-a-h,f=s-l-c;d=d>0?d:0,f=f>0?f:0;var p=0===u?d:d/u,m=0===_?f:f/_,g=iq(i),y=Math.ceil(m+g),v=Math.ceil(p+g);e.dataLength=4*y*v,this.updateVerts(t,d,f,y,v),e.vertexCount!==y*v*4&&(t.renderEntity.colorDirty=!0),e.resize(y*v*4,y*v*6),e.updateRenderData(t,i)}},createQuadIndices:function(t){if(t%6==0){var e=t/6;eq=null,eq=new Uint16Array(t);for(var i=0,n=0;n1?1:a.width/(p+m),A=a.height/(y+v)>1?1:a.height/(y+v);s=g>0?Math.floor(1e3*e)/1e3%g==0?g:e%g:e,o=S>0?Math.floor(1e3*i)/1e3%S==0?S:i%S:i,tq.length=0,$X=Math.max(n+1,r+1);for(var b=0;b<$X;b++)tq.push({x:0,y:0,z:0,u:0,v:0,color:new dn});var E=iq(u);if(0===E)for(var C=0;C<$X;C++)tq[C].x=C>=r?c-d:C*g-d,tq[C].y=C>=n?_-f:C*S-f;else for(var w=0;w<$X;w++)0===w?tq[w].x=-d:1===w?tq[w].x=p*T-d:w>1&&w0?p*T-d+g*(w-1):p+e-d:w===r-1?tq[w].x=p*T-d+s+g*(w-2):w>=r&&(tq[w].x=Math.min(p+e+m,c)-d),0===w?tq[w].y=-f:1===w?tq[w].y=v*A-f:w>1&&w0?v*A-f+S*(w-1):v+i-f:w===n-1?tq[w].y=v*A-f+o+S*(w-2):w>=n&&(tq[w].y=Math.min(v+i+y,_)-f);for(var x=0,R=0,I=0,B=0,D=0;DS?i>=(E>0?z:z+1)*S?1:V%1:V;for(var H=0;Hg?e>=(E>0?H:H+1)*g?1:k%1:k,M?(0===E?(G[0]=YX.u,G[1]=YX.u,G[2]=YX.u+(KX.u-YX.u)*F,U[0]=jX.v,U[1]=jX.v+(XX.v-jX.v)*N,U[2]=jX.v):(0===z?(G[0]=WX.u,G[1]=WX.u,G[2]=YX.u):z0){var h=o.claimedTouchIdList.indexOf(n.getID());if(-1!==h){if(o._handleEventTouch(t),t.type!==bw.TOUCH_END&&t.type!==bw.TOUCH_CANCEL||oe(o.claimedTouchIdList,h),r=!1,!t.preventSwallow)break;t.preventSwallow=!1}}}return--this._inDispatchCount<=0&&this._updatePointerEventProcessorList(),r},e._updatePointerEventProcessorList=function(){for(var t=this._processorListToAdd,e=t.length,i=0;ie)for(;e0){for(var t=this._meshDataArray.length,e=0;e0){!function(t,e){for(var i,n,r,s=t.vertexFormat,o=t.chunk.vb,a=0,h=0;h>>0;else if(n.size/n.count==4)for(var c=a+3;c>2}}(r.renderData,o);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(),Pk.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=nT.get("default-clear-stencil"),this._maskClearModel=v.director.root.createModel(wM);var t=pk(hk),e=Ed.gfxDevice,i=e.createBuffer(new Xc(Xl.VERTEX|Xl.TRANSFER_DST,Kl.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 Xc(Xl.INDEX|Xl.TRANSFER_DST,Kl.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 OR([i],hk,pc.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=Pk.sharedManager;e.pushMask(1);var i,n=e.clear(t),r=0,s=this._maskClearMtl;s&&(i=e.getStencilStage(n,s),r=e.getStencilHash(n));var o=this._maskClearModel,a=v.director.getTotalFrames();o&&(o.updateTransform(a),o.updateUBOs(a));for(var h=0;h=0;o--){var a=i[o],h=t[a];t.splice(a,1),this._localCachePool.free(h)}}},e.reset=function(){for(var t=this._localDescriptorSetCache,e=t.length,i=0;i@123丁ぁᄁ",vq=Object.create(null),Sq=[],Tq=3e3;function Aq(){for(var t=!0,e=Date.now(),i=Sq.length-1;i>=0;i--){var n=Sq[i],r=n.fontFamilyName;if(e-n.startTime>Tq)Y(4933,r),n.onComplete(null,r),Sq.splice(i,1);else{var s=n.refWidth,o="40px "+r;mq.font=o,s!==YF(mq,yq,o)?(Sq.splice(i,1),n.onComplete(null,r)):t=!1}}t&&(clearInterval(gq),gq=-1)}function bq(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(vq[n])i(null,n);else{if(!mq){var r=pq.createElement("canvas");r.width=100,r.height=100,mq=r.getContext("2d")}var s="40px "+n,o=pq.createElement("style");o.type="text/css";var a="";Number.isNaN(n)?a+="@font-face { font-family:"+n+"; src:":a+='@font-face { font-family:"'+n+'"; src:',a+='url("'+t+'");',o.textContent=a+"}",pq.body.appendChild(o);var h=pq.createElement("div"),u=h.style;if(u.fontFamily=n,h.innerHTML=".",u.position="absolute",u.left="-100px",u.top="-100px",pq.body.appendChild(h),function(){if(void 0===fq)if("FontFace"in T){var t=/Gecko.*Firefox\/(\d+)/.exec(T.navigator.userAgent),e=/OS X.*Version\/10\..*Safari/.exec(T.navigator.userAgent)&&/Apple/.exec(T.navigator.vendor);fq=t?parseInt(t[1],10)>42:!e}else fq=!1;return fq}())!function(t,e,i){var n=new Promise((function(i,n){!function r(){Date.now()-t>=Tq?n():pq.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,Tq)}));Promise.race([s,n]).then((function(){r&&(clearTimeout(r),r=null),i(null,e)}),(function(){Y(4933,e),i(null,e)}))}(Date.now(),n,i);else{var l={fontFamilyName:n,refWidth:YF(mq,yq,s),onComplete:i,startTime:Date.now()};Sq.push(l),-1===gq&&(gq=setInterval(Aq,100))}vq[n]=o}}function Eq(t,e,i,n){var r=new BF;r._nativeUrl=t,r._nativeAsset=e,n(null,r)}bS.register({".font":bq,".eot":bq,".ttf":bq,".woff":bq,".svg":bq,".ttc":bq}),LS.register({".font":Eq,".eot":Eq,".ttf":Eq,".woff":Eq,".svg":Eq,".ttc":Eq}),v.UI={MeshBuffer:Ak,spriteAssembler:oq,graphicsAssembler:qj,labelAssembler:yX,RenderData:qk,MeshRenderData:Yk},SN.on(vN.EVENT_POST_SUBSYSTEM_INIT,(function(){Dq.init()}));var Cq,wq,xq,Rq,Iq,Bq,Dq=t("a2",function(){function t(){}return t.getSortingPriority=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),(t+32768<<16|e+32768)>>>0},t.getLayerIndex=function(t){void 0===t&&(t=0);var e=0;return this.indexMap.has(t)?e=this.indexMap.get(t):J(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):J(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;tDT.LEVEL_1},set:function(t){this._csmLevel=t?DT.LEVEL_4:DT.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,MT.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}(mQ),jK=ks(WK.prototype,"_illuminanceHDR",[gQ,sK],(function(){return 65e3})),XK=ks(WK.prototype,"_illuminanceLDR",[yQ],(function(){return 65e3*Hx.standardExposureValue})),qK=ks(WK.prototype,"_shadowEnabled",[yQ],(function(){return!1})),YK=ks(WK.prototype,"_shadowPcf",[yQ],(function(){return BT.HARD})),KK=ks(WK.prototype,"_shadowBias",[yQ],(function(){return 1e-5})),JK=ks(WK.prototype,"_shadowNormalBias",[yQ],(function(){return 0})),QK=ks(WK.prototype,"_shadowSaturation",[yQ],(function(){return 1})),ZK=ks(WK.prototype,"_shadowDistance",[yQ],(function(){return 50})),$K=ks(WK.prototype,"_shadowInvisibleOcclusionRange",[yQ],(function(){return 200})),tJ=ks(WK.prototype,"_csmLevel",[yQ],(function(){return DT.LEVEL_4})),eJ=ks(WK.prototype,"_csmLayerLambda",[yQ],(function(){return.75})),iJ=ks(WK.prototype,"_csmOptimizationMode",[yQ],(function(){return PT.RemoveDuplicates})),nJ=ks(WK.prototype,"_csmAdvancedOptions",[yQ],(function(){return!1})),rJ=ks(WK.prototype,"_csmLayersTransition",[yQ],(function(){return!1})),sJ=ks(WK.prototype,"_csmTransitionRange",[yQ],(function(){return.05})),oJ=ks(WK.prototype,"_shadowFixedArea",[yQ],(function(){return!1})),aJ=ks(WK.prototype,"_shadowNear",[yQ],(function(){return.1})),hJ=ks(WK.prototype,"_shadowFar",[yQ],(function(){return 10})),uJ=ks(WK.prototype,"_shadowOrthoSize",[yQ],(function(){return 5})),p(WK.prototype,"illuminance",[oK],Object.getOwnPropertyDescriptor(WK.prototype,"illuminance"),WK.prototype),p(WK.prototype,"shadowEnabled",[aK,hK],Object.getOwnPropertyDescriptor(WK.prototype,"shadowEnabled"),WK.prototype),p(WK.prototype,"shadowPcf",[uK,lK],Object.getOwnPropertyDescriptor(WK.prototype,"shadowPcf"),WK.prototype),p(WK.prototype,"shadowBias",[cK,_K],Object.getOwnPropertyDescriptor(WK.prototype,"shadowBias"),WK.prototype),p(WK.prototype,"shadowNormalBias",[dK,fK],Object.getOwnPropertyDescriptor(WK.prototype,"shadowNormalBias"),WK.prototype),p(WK.prototype,"shadowSaturation",[pK,mK],Object.getOwnPropertyDescriptor(WK.prototype,"shadowSaturation"),WK.prototype),p(WK.prototype,"shadowDistance",[gK,yK],Object.getOwnPropertyDescriptor(WK.prototype,"shadowDistance"),WK.prototype),p(WK.prototype,"shadowInvisibleOcclusionRange",[vK,SK],Object.getOwnPropertyDescriptor(WK.prototype,"shadowInvisibleOcclusionRange"),WK.prototype),p(WK.prototype,"csmLevel",[TK,AK],Object.getOwnPropertyDescriptor(WK.prototype,"csmLevel"),WK.prototype),p(WK.prototype,"enableCSM",[bK,EK],Object.getOwnPropertyDescriptor(WK.prototype,"enableCSM"),WK.prototype),p(WK.prototype,"csmLayerLambda",[CK,wK],Object.getOwnPropertyDescriptor(WK.prototype,"csmLayerLambda"),WK.prototype),p(WK.prototype,"csmOptimizationMode",[xK,RK],Object.getOwnPropertyDescriptor(WK.prototype,"csmOptimizationMode"),WK.prototype),p(WK.prototype,"shadowFixedArea",[IK,BK],Object.getOwnPropertyDescriptor(WK.prototype,"shadowFixedArea"),WK.prototype),p(WK.prototype,"shadowNear",[DK,PK],Object.getOwnPropertyDescriptor(WK.prototype,"shadowNear"),WK.prototype),p(WK.prototype,"shadowFar",[OK,MK],Object.getOwnPropertyDescriptor(WK.prototype,"shadowFar"),WK.prototype),p(WK.prototype,"shadowOrthoSize",[LK,NK],Object.getOwnPropertyDescriptor(WK.prototype,"shadowOrthoSize"),WK.prototype),p(WK.prototype,"csmAdvancedOptions",[FK,kK],Object.getOwnPropertyDescriptor(WK.prototype,"csmAdvancedOptions"),WK.prototype),p(WK.prototype,"csmLayersTransition",[VK,GK],Object.getOwnPropertyDescriptor(WK.prototype,"csmLayersTransition"),WK.prototype),p(WK.prototype,"csmTransitionRange",[UK,zK],Object.getOwnPropertyDescriptor(WK.prototype,"csmTransitionRange"),WK.prototype),HK=WK))||HK)),AQ=t("ab",(lJ=qs("cc.SphereLight"),cJ=no("_luminance"),_J=xo(qe),dJ=xo(qe),fJ=xo(fQ),pJ=xo(Ye),mJ=xo(Ye),lJ((yJ=function(t){function e(){var e;return(e=t.call(this)||this)._size=vJ&&vJ(),e._luminanceHDR=SJ&&SJ(),e._luminanceLDR=TJ&&TJ(),e._term=AJ&&AJ(),e._range=bJ&&bJ(),e._lightType=BM,e}return s(e,t),e.prototype._createLight=function(){t.prototype._createLight.call(this),this._type=sR.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 v.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR*TR(this._size):this._luminanceLDR},set:function(t){var e=0;v.director.root.pipeline.pipelineSceneData.isHDR?(this._luminanceHDR=t/TR(this._size),e=this._luminanceHDR):(this._luminanceLDR=t,e=this._luminanceLDR),this._light&&(this._light.luminance=e)}},{key:"luminance",get:function(){return v.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR:this._luminanceLDR},set:function(t){v.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}(mQ),vJ=ks(yJ.prototype,"_size",[io],(function(){return.15})),SJ=ks(yJ.prototype,"_luminanceHDR",[io,cJ],(function(){return 1700/TR(.15)})),TJ=ks(yJ.prototype,"_luminanceLDR",[io],(function(){return 1700/TR(.15)*Hx.standardExposureValue*Hx.standardLightMeterScale})),AJ=ks(yJ.prototype,"_term",[io],(function(){return fQ.LUMINOUS_FLUX})),bJ=ks(yJ.prototype,"_range",[io],(function(){return 1})),p(yJ.prototype,"luminousFlux",[_J],Object.getOwnPropertyDescriptor(yJ.prototype,"luminousFlux"),yJ.prototype),p(yJ.prototype,"luminance",[dJ],Object.getOwnPropertyDescriptor(yJ.prototype,"luminance"),yJ.prototype),p(yJ.prototype,"term",[fJ],Object.getOwnPropertyDescriptor(yJ.prototype,"term"),yJ.prototype),p(yJ.prototype,"size",[pJ],Object.getOwnPropertyDescriptor(yJ.prototype,"size"),yJ.prototype),p(yJ.prototype,"range",[mJ],Object.getOwnPropertyDescriptor(yJ.prototype,"range"),yJ.prototype),gJ=yJ))||gJ)),bQ=xo,EQ=io,CQ=no,wQ=Qs,xQ=t("ac",(EJ=qs("cc.SpotLight"),CJ=CQ("_luminance"),wJ=bQ(fQ),xJ=bQ(Ye),RJ=wQ({group:{name:"DynamicShadowSettings",displayOrder:1}}),IJ=bQ(Ke),BJ=wQ({group:{name:"DynamicShadowSettings",displayOrder:2}}),DJ=bQ(BT),PJ=wQ({group:{name:"DynamicShadowSettings",displayOrder:3}}),OJ=bQ(Ye),MJ=wQ({group:{name:"DynamicShadowSettings",displayOrder:4}}),LJ=bQ(Ye),EJ((FJ=function(t){function e(){var e;return(e=t.call(this)||this)._size=kJ&&kJ(),e._luminanceHDR=VJ&&VJ(),e._luminanceLDR=GJ&&GJ(),e._term=UJ&&UJ(),e._range=zJ&&zJ(),e._spotAngle=HJ&&HJ(),e._shadowEnabled=WJ&&WJ(),e._shadowPcf=jJ&&jJ(),e._shadowBias=XJ&&XJ(),e._shadowNormalBias=qJ&&qJ(),e._lightType=FM,e}return s(e,t),e.prototype._createLight=function(){if(t.prototype._createLight.call(this),this._type=sR.SPOT,this.size=this._size,this.range=this._range,this.spotAngle=this._spotAngle,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 v.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR*TR(this._size):this._luminanceLDR},set:function(t){var e=0;v.director.root.pipeline.pipelineSceneData.isHDR?(this._luminanceHDR=t/TR(this._size),e=this._luminanceHDR):(this._luminanceLDR=t,e=this._luminanceLDR),this._light&&(this._light.luminance=e)}},{key:"luminance",get:function(){return v.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR:this._luminanceLDR},set:function(t){v.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=Bi(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}(mQ),kJ=ks(FJ.prototype,"_size",[EQ],(function(){return.15})),VJ=ks(FJ.prototype,"_luminanceHDR",[EQ,CJ],(function(){return 1700/TR(.15)})),GJ=ks(FJ.prototype,"_luminanceLDR",[EQ],(function(){return 1700/TR(.15)*Hx.standardExposureValue*Hx.standardLightMeterScale})),UJ=ks(FJ.prototype,"_term",[EQ],(function(){return fQ.LUMINOUS_FLUX})),zJ=ks(FJ.prototype,"_range",[EQ],(function(){return 1})),HJ=ks(FJ.prototype,"_spotAngle",[EQ],(function(){return 60})),WJ=ks(FJ.prototype,"_shadowEnabled",[EQ],(function(){return!1})),jJ=ks(FJ.prototype,"_shadowPcf",[EQ],(function(){return BT.HARD})),XJ=ks(FJ.prototype,"_shadowBias",[EQ],(function(){return 1e-5})),qJ=ks(FJ.prototype,"_shadowNormalBias",[EQ],(function(){return 0})),p(FJ.prototype,"term",[wJ],Object.getOwnPropertyDescriptor(FJ.prototype,"term"),FJ.prototype),p(FJ.prototype,"size",[xJ],Object.getOwnPropertyDescriptor(FJ.prototype,"size"),FJ.prototype),p(FJ.prototype,"shadowEnabled",[RJ,IJ],Object.getOwnPropertyDescriptor(FJ.prototype,"shadowEnabled"),FJ.prototype),p(FJ.prototype,"shadowPcf",[BJ,DJ],Object.getOwnPropertyDescriptor(FJ.prototype,"shadowPcf"),FJ.prototype),p(FJ.prototype,"shadowBias",[PJ,OJ],Object.getOwnPropertyDescriptor(FJ.prototype,"shadowBias"),FJ.prototype),p(FJ.prototype,"shadowNormalBias",[MJ,LJ],Object.getOwnPropertyDescriptor(FJ.prototype,"shadowNormalBias"),FJ.prototype),NJ=FJ))||NJ));t("ad",(YJ=qs("cc.PointLight"),KJ=no("_luminance"),JJ=xo(qe),QJ=xo(qe),ZJ=xo(fQ),$J=xo(Ye),YJ((eQ=function(t){function e(){var e;return(e=t.call(this)||this)._luminanceHDR=iQ&&iQ(),e._luminanceLDR=nQ&&nQ(),e._term=rQ&&rQ(),e._range=sQ&&sQ(),e._lightType=kM,e}return s(e,t),e.prototype._createLight=function(){t.prototype._createLight.call(this),this._type=sR.POINT,this.range=this._range,this._light&&(this._light.luminanceHDR=this._luminanceHDR,this._light.luminanceLDR=this._luminanceLDR)},n(e,[{key:"luminousFlux",get:function(){return v.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR*TR(1):this._luminanceLDR},set:function(t){var e=0;v.director.root.pipeline.pipelineSceneData.isHDR?(this._luminanceHDR=t/TR(1),e=this._luminanceHDR):(this._luminanceLDR=t,e=this._luminanceLDR),this._light&&(this._light.luminance=e)}},{key:"luminance",get:function(){return v.director.root.pipeline.pipelineSceneData.isHDR?this._luminanceHDR:this._luminanceLDR},set:function(t){v.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}(mQ),iQ=ks(eQ.prototype,"_luminanceHDR",[io,KJ],(function(){return 1700/TR(.15)})),nQ=ks(eQ.prototype,"_luminanceLDR",[io],(function(){return 1700/TR(.15)*Hx.standardExposureValue*Hx.standardLightMeterScale})),rQ=ks(eQ.prototype,"_term",[io],(function(){return fQ.LUMINOUS_FLUX})),sQ=ks(eQ.prototype,"_range",[io],(function(){return 1})),p(eQ.prototype,"luminousFlux",[JJ],Object.getOwnPropertyDescriptor(eQ.prototype,"luminousFlux"),eQ.prototype),p(eQ.prototype,"luminance",[QJ],Object.getOwnPropertyDescriptor(eQ.prototype,"luminance"),eQ.prototype),p(eQ.prototype,"term",[ZJ],Object.getOwnPropertyDescriptor(eQ.prototype,"term"),eQ.prototype),p(eQ.prototype,"range",[$J],Object.getOwnPropertyDescriptor(eQ.prototype,"range"),eQ.prototype),tQ=eQ))||tQ)),t("ae",(oQ=qs("cc.RangedDirectionalLight"),aQ=no("_illuminance"),hQ=xo(qe),oQ((lQ=function(t){function e(){var e;return(e=t.call(this)||this)._illuminanceHDR=cQ&&cQ(),e._illuminanceLDR=_Q&&_Q(),e._lightType=GM,e}return s(e,t),e.prototype._createLight=function(){t.prototype._createLight.call(this),this._type=sR.RANGED_DIRECTIONAL,this._light&&(this._light.illuminanceHDR=this._illuminanceHDR,this._light.illuminanceLDR=this._illuminanceLDR)},n(e,[{key:"illuminance",get:function(){return v.director.root.pipeline.pipelineSceneData.isHDR?this._illuminanceHDR:this._illuminanceLDR},set:function(t){v.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}(mQ),cQ=ks(lQ.prototype,"_illuminanceHDR",[Qs,aQ],(function(){return 65e3})),_Q=ks(lQ.prototype,"_illuminanceLDR",[io],(function(){return 65e3*Hx.standardExposureValue})),p(lQ.prototype,"illuminance",[hQ],Object.getOwnPropertyDescriptor(lQ.prototype,"illuminance"),lQ.prototype),uQ=lQ))||uQ)),v.LightComponent=mQ,Qt(mQ,"cc.LightComponent"),v.DirectionalLightComponent=TQ,Qt(TQ,"cc.DirectionalLightComponent"),v.SphereLightComponent=AQ,Qt(AQ,"cc.SphereLightComponent"),v.SpotLightComponent=xQ,Qt(xQ,"cc.SpotLightComponent"),nt(xQ.prototype,"SpotLight.prototype",[{name:"luminousPower",newName:"luminousFlux",customGetter:function(){return this.luminousFlux},customSetter:function(t){this.luminousFlux=t}}]),nt(AQ.prototype,"SphereLight.prototype",[{name:"luminousPower",newName:"luminousFlux",customGetter:function(){return this.luminousFlux},customSetter:function(t){this.luminousFlux=t}}]),nt(mQ.PhotometricTerm,"Light.PhotometricTerm",[{name:"LUMINOUS_POWER",newName:"LUMINOUS_FLUX"}]);var RQ=Symbol("BakeNodeCurves"),IQ=t("fR",function(){function t(){}return t.getOrExtract=function(e){var i=t.pool.get(e);if(!i||i.samples!==e.sample){i&&v.director.root.dataPoolManager.releaseAnimationClip(e);var n=Math.ceil(e.sample*e.duration)+1,r=e.sample;i=e[RQ](0,r,n),t.pool.set(e,i)}return i},t.destroy=function(e){t.pool.delete(e)},t}());IQ.pool=new Map;var BQ=new In;function DQ(t,e,i){for(In.identity(i);t!==e;)In.fromRTS(BQ,t.rotation,t.position,t.scale),In.multiply(i,BQ,i),t=t.parent;return i}var PQ=new $c(ic.POINT,ic.POINT,ic.NONE,nc.CLAMP,nc.CLAMP,nc.CLAMP),OQ=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 MQ(t,e){var i=4/Math.sqrt(e);return 12*Math.ceil(Math.max(480*i,t)/12)}new Sn,new Sn,new on,new Sn,new on;var LQ=new on,NQ=new on,FQ=new on,kQ=new on,VQ=new In,GQ=new In,UQ=new Ss,zQ=Number.MAX_SAFE_INTEGER,HQ=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(Hl.RGBA32F)&$l.SAMPLED_TEXTURE?Hl.RGBA32F:Hl.RGBA8}(this._device);this._formatSize=M_[e].size,this._pixelsPerJoint=48/this._formatSize,this._pool=new wG(t),this._pool.initialize({format:e,roundUpFn:MQ}),this._customPool=new wG(t),this._customPool.initialize({format:e,roundUpFn:MQ})}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,o=r.length,a=IQ.getOrExtract(e),h=0;h0;){t=jQ[--i],jQ[i]=null;var r=t.node;In.fromRTS(t.local,r.rotation,r.position,r.scale),n=In.multiply(t.world,n,t.local)}return n}function YQ(t,e){for(var i,n=null,r=0;t!==e;){var s=t.uuid;if(XQ.has(s)){n=XQ.get(s);break}n={node:t,local:new In,world:new In,stamp:-1,parent:null},XQ.set(s,n),jQ[r++]=n,t=t.parent,n=null}for(;r>0;)i=jQ[--r],jQ[r]=null,i.parent=n,n=i;return n}function KQ(t){for(var e=XQ.get(t.uuid)||null;e;)XQ.delete(e.node.uuid),e=e.parent}var JQ=[{name:"CC_USE_SKINNING",value:!0},{name:"CC_USE_REAL_TIME_JOINT_TEXTURE",value:!1}],QQ=[{name:"CC_USE_SKINNING",value:!0},{name:"CC_USE_REAL_TIME_JOINT_TEXTURE",value:!0}];function ZQ(t,e,i,n){for(var r=0;r=0&&(e.push(r),t.push(o))}}var $Q=new on,tZ=new on,eZ=new on,iZ=new on,nZ=new In,rZ=new Ss,sZ=function(){this._format=af.RGBA32F,this._textures=[],this._buffers=[]};sZ.WIDTH=256,sZ.HEIGHT=3;var oZ,aZ,hZ,uZ,lZ,cZ,_Z,dZ,fZ,pZ,mZ,gZ,yZ,vZ,SZ,TZ,AZ,bZ,EZ,CZ,wZ,xZ,RZ,IZ,BZ,DZ,PZ,OZ,MZ,LZ,NZ,FZ,kZ=function(t){function e(){var e;return(e=t.call(this)||this)._buffers=[],e._dataArray=[],e._joints=[],e._bufferIndices=null,e._realTimeJointTexture=new sZ,e._realTimeTextureMode=!1,e.type=dM.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?o.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(VZ):VZ},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,o=0;o=0&&s.length>0){var o=s[n];o[0]=i.data[0],o[1]=e[1],o[2]=e[2]}}},e}(SY),UZ=t("af",(oZ=qs("cc.SkinnedMeshRenderer"),aZ=Ks(100),hZ=xo(nK),uZ=xo(Jm),lZ=xo(nK),cZ=xo(Jm),oZ(_Z=aZ((dZ=function(t){function e(){var e;return(e=t.call(this)||this)._skeleton=fZ&&fZ(),e._skinningRoot=pZ&&pZ(),e._clip=null,e.associatedAnimation=null,e._modelType=GZ,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?GZ:kZ;(e||this._modelType!==i)&&(this._modelType=i,this._model&&(v.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===kZ&&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}(VY),fZ=ks(dZ.prototype,"_skeleton",[hZ],(function(){return null})),pZ=ks(dZ.prototype,"_skinningRoot",[uZ],(function(){return null})),p(dZ.prototype,"skeleton",[lZ],Object.getOwnPropertyDescriptor(dZ.prototype,"skeleton"),dZ.prototype),p(dZ.prototype,"skinningRoot",[cZ],Object.getOwnPropertyDescriptor(dZ.prototype,"skinningRoot"),dZ.prototype),_Z=dZ))||_Z)||_Z)),zZ=new u_(Ic.ATTR_BATCH_ID,Hl.R32F),HZ=new u_(Ic.ATTR_BATCH_UV,Hl.RG32F),WZ=M_[zZ.format].size+M_[HZ.format].size,jZ=t("ah",(mZ=qs("cc.SkinnedMeshUnit"),gZ=xo(XN),yZ=xo(nK),vZ=xo(xT),SZ=xo(UZ),mZ((AZ=function(){function t(){this.mesh=bZ&&bZ(),this.skeleton=EZ&&EZ(),this.material=CZ&&CZ(),this._localTransform=wZ&&wZ(),this._offset=xZ&&xZ(),this._size=RZ&&RZ()}return n(t,[{key:"offset",get:function(){return this._offset},set:function(t){Ln.copy(this._offset,t)}},{key:"size",get:function(){return this._size},set:function(t){Ln.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&&DQ(t.node,t.skinningRoot,this._localTransform))}}]),t}(),bZ=ks(AZ.prototype,"mesh",[gZ],(function(){return null})),EZ=ks(AZ.prototype,"skeleton",[yZ],(function(){return null})),CZ=ks(AZ.prototype,"material",[vZ],(function(){return null})),wZ=ks(AZ.prototype,"_localTransform",[io],(function(){return new In})),xZ=ks(AZ.prototype,"_offset",[io],(function(){return new Ln(0,0)})),RZ=ks(AZ.prototype,"_size",[io],(function(){return new Ln(1,1)})),p(AZ.prototype,"copyFrom",[SZ],Object.getOwnPropertyDescriptor(AZ.prototype,"copyFrom"),AZ.prototype),TZ=AZ))||TZ)),XZ=new In;new In;var qZ,YZ,KZ,JZ,QZ,ZZ,$Z,t$,e$,i$,n$,r$,s$,o$,a$,h$,u$,l$=new on,c$=t("ag",(IZ=qs("cc.SkinnedMeshBatchRenderer"),BZ=Ks(100),DZ=xo([Je]),PZ=xo([jZ]),IZ(OZ=BZ((MZ=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r=jl.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 o=[],a=0;a=0)return 1;t.push(i),e.push(In.multiply(new In,r.bindposes[o]||In.IDENTITY,XZ))},o=0;ot[i]?1:t[e]0&&d.copyBuffersToTexture(s,_,o),n.length>0&&d.copyTexImagesToTexture(n,_,r)},i.createTexture=function(t){var e=new Zp;return e.setFilters(uf.LINEAR,uf.LINEAR),e.setMipFilter(uf.NEAREST),e.reset({width:this.atlasSize,height:this.atlasSize,format:af.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:af.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?console.error("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 d$),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=_$[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 console.warn("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):(console.warn("eraseLOD error, LOD not exist at specified index."),null)},i.getLOD=function(t){return t<0||t>=this.lodCount?(console.warn("getLOD error, index out of range"),null):this._LODs[t]},i.setLOD=function(t,e){t<0||t>=this.lodCount?console.warn("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 on,e=new on,i=null,n=new on,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===eR.PLANAR&&(i=this._usePlanarModels);for(var n,r=d(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=d(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,o=d(this._usePlanarModels.keys());!(s=o()).done;){var a=s.value,h=this._usePlanarModels.get(a);void 0!==h&&h===t&&(this._usePlanarModels.delete(a),this.selectPlanarReflectionProbe(a))}},e._updateCubemapOfModel=function(t,e){var i=t.node;if(i){var n=i.getComponent(VY);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(VY);n&&(n.updateProbePlanarMap(e),i?(n.updateReflectionProbeId(i.getProbeId()),n.updateReflectionProbeDataMap(this._dataTexture)):n.updateReflectionProbeId(-1))},e._isUsedBlending=function(t){return t.reflectionProbeType===uM.BLEND_PROBES||t.reflectionProbeType===uM.BLEND_PROBES_AND_SKYBOX},e._updateBlendProbeInfo=function(t,e,i){var n=t.node;if(n){var r=n.getComponent(VY);r&&(i?(r.updateReflectionProbeBlendId(i.getProbeId()),r.updateProbeBlendCubemap(i.cubemap),r.updateReflectionProbeBlendWeight(this._calculateBlendWeight(t,e,i))):(r.updateReflectionProbeBlendId(-1),t.reflectionProbeType===uM.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(VY);n&&n.updateProbeBlendCubemap(e.cubemap)}},e._calculateBlendWeight=function(t,e,i){if(i){var n=on.distance(t.node.worldPosition,e.node.worldPosition),r=on.distance(t.node.worldPosition,i.node.worldPosition);return 1-r/(n+r)}return t.reflectionProbeType===uM.BLEND_PROBES?0:t.reflectionProbeType===uM.BLEND_PROBES_AND_SKYBOX?this._calculateBlendOfSkybox(t.worldBounds,e.boundingBox):0},e._calculateBlendOfSkybox=function(t,e){if(!t)return 1;var i=new on,n=new on,r=new on,s=new on;if(on.subtract(i,t.center,t.halfExtents),on.add(n,t.center,t.halfExtents),on.subtract(r,e.center,e.halfExtents),on.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 o=new on;on.multiplyScalar(o,t.halfExtents,2);var a=i.x+o.x<=s.x&&n.x+o.x>=r.x,h=i.x-o.x<=s.x&&n.x-o.x>=r.x,u=i.y+o.y<=s.y&&n.y+o.y>=r.y,l=i.y-o.y<=s.y&&n.y-o.y>=r.y,c=i.z+o.z<=s.z&&n.z+o.z>=r.z,_=i.z-o.z<=s.z&&n.z-o.z>=r.z,d=[];if(!a){var f=n.x-s.x;d.push(f/o.x)}if(!h){var p=Math.abs(i.x-r.x);d.push(p/o.x)}if(!u){var m=n.y-s.y;d.push(m/o.y)}if(!l){var g=Math.abs(i.y-r.y);d.push(g/o.y)}if(!c){var y=n.z-s.z;d.push(y/o.z)}if(!_){var v=Math.abs(i.z-r.z);d.push(v/o.z)}return d.length>0?(d.sort((function(t,e){return e-t})),d[0]):0}return 1},n(t,[{key:"updateForRuntime",get:function(){return this._updateForRuntime},set:function(t){this._updateForRuntime=t}}]),t}());function m$(t){return void 0===(t=t||{}).includeNormal&&(t.includeNormal=!0),void 0===t.includeUV&&(t.includeUV=!0),t}p$.probeManager=void 0,p$.probeManager=new p$,v.internal.reflectionProbeManager=p$.probeManager;var g$=new on,y$=new on,v$=new on,S$=new on,T$=new on,A$=new on,b$=new on,E$=new on,C$=new on,w$=new on,x$=new on,R$=new on,I$=new on(0,0,0),B$=new on(0,0,0);function D$(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,o=n.heightSegments||1,a=void 0===n.capped||n.capped,h=n.arc||2*Math.PI,u=0;a||(t>0&&u++,e>0&&u++);var l=(s+1)*(o+1);a&&(l+=(s+1)*u+s*u);var c=s*o*6;a&&(c+=s*u*3);var _=new Array(c),d=new Array(3*l),f=new Array(3*l),p=new Array(2*l),m=Math.max(t,e),g=new on(-m,-r,-m),y=new on(m,r,m),v=Math.sqrt(m*m+r*r),S=0,T=0;return function(){for(var n=[],a=t-e,u=a*a/i*Math.sign(a),l=0;l<=o;l++){for(var c=[],m=l/o,g=m*a+e,y=0;y<=s;++y){var v=y/s,A=v*h,b=Math.sin(A),E=Math.cos(A);d[3*S]=g*b,d[3*S+1]=m*i-r,d[3*S+2]=g*E,on.normalize(I$,on.set(B$,b,-u,E)),f[3*S]=I$.x,f[3*S+1]=I$.y,f[3*S+2]=I$.z,p[2*S]=2*(1-v)%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:d,normals:f,uvs:p,indices:_,minPos:g,maxPos:y,boundingRadius:v};function A(i){for(var n=i?t:e,o=i?1:-1,a=S,u=1;u<=s;++u)d[3*S]=0,d[3*S+1]=r*o,d[3*S+2]=0,f[3*S]=0,f[3*S+1]=o,f[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),y=Math.sin(m);d[3*S]=n*y,d[3*S+1]=r*o,d[3*S+2]=n*g,f[3*S]=0,f[3*S+1]=o,f[3*S+2]=0,p[2*S]=.5-.5*y*o,p[2*S+1]=.5+.5*g,++S}for(var v=0;v0&&(n[n.length-1]=1),{positions:i,indices:n,minPos:{x:1,y:1,z:0},maxPos:{x:-1,y:-1,z:0},boundingRadius:1,primitiveMode:pc.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),o=0;oh?h<<16|a:a<<16|h;void 0===r[u]&&(r[u]=0,n.push(a,h))}return t.indices=n,t.primitiveMode=pc.LINE_LIST,t},wireframe:function(t){for(var e=[[0,1],[1,2],[2,0]],i=[],n={},r=0;ra?a<<16|o:o<<16|a;void 0===n[h]&&(n[h]=0,i.push(o,a))}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(C0.PLAY,this),null===(t=this._clipEmbeddedPlayerEval)||void 0===t||t.notifyHostPlay(this.current)},i.onStop=function(){var t;this.isPaused||this._onPauseOrStop(),this.emit(C0.STOP,this),null===(t=this._clipEmbeddedPlayerEval)||void 0===t||t.notifyHostStop()},i.onResume=function(){var t;this._onReplayOrResume(),this.emit(C0.RESUME,this),null===(t=this._clipEmbeddedPlayerEval)||void 0===t||t.notifyHostPlay(this.current)},i.onPause=function(){var t;this._onPauseOrStop(),this.emit(C0.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 w0(e),this.repeatCount>1&&(0|e.iterations)>(0|t.iterations)&&this.emit(C0.LASTFRAME,this),t.set(e)),e.stopped&&(this.stop(),this.emit(C0.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&su.Reverse)===su.Reverse&&(i=!i),i},i.getWrappedInfo=function(t,e){e=e||new w0;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,o=(t-=i)>0?t/n:-t/n;if(o>=r){o=r,s=!0;var a=r-(0|r);0===a&&(a=1),t=a*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&su.ShouldWrap;l&&(u=this._needReverse(o));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=o,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(){R0().addAnimation(this)},i._onPauseOrStop=function(){R0().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&su.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&su.ShouldWrap,i=(this.wrapMode&su.Reverse)===su.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}(E0));v.AnimationState=P0,qs("cc.animation.EmbeddedAnimationClipPlayable")((I0=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 g1(new ih)})))}}}]),e}(m1),h1=ks(a1.prototype,"_channels",[S1],(function(){return[]})),a1));var T1,A1,b1,E1,C1,w1,x1,R1,I1,B1,D1,P1,O1,M1,L1,N1,F1,k1,V1=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)Y(3941,t.name,e);else{var r=t.passes[e],s=r.getHandle(i);if(s){if(uT.getTypeFromHandle(s)1}return!1}(r,i)?{set:function(t){r.setUniformArray(o,t)}}:{set:function(t){r.setUniform(o,t)}}:void Y(3943,t.name,e,i,n)}var a=uT.getBindingFromHandle(s),h=r.properties[i],u=h&&h.value?""+h.value+pv(h.type):fv(h.type),l=nT.get(u);return l||(k("Illegal texture default value: "+u+"."),l=nT.get("default-texture")),{set:function(t){t||(t=l);var e=t.getGFXTexture();e&&e.width&&e.height&&(r.bindTexture(a,e),t instanceof Of&&r.bindSampler(a,Ed.gfxDevice.getSampler(t.getSamplerInfo())))}}}Y(3942,t.name,e,i)}}else Y(3940,t)},t}(),b1=ks(A1.prototype,"passIndex",[io],(function(){return 0})),E1=ks(A1.prototype,"uniformName",[io],(function(){return""})),C1=p(A1.prototype,"channelIndex",[Eo],{configurable:!0,enumerable:!0,writable:!0,initializer:function(){}}),T1=A1))||T1,U1=qs("cc.animation.MorphWeightValueProxy")((x1=function(){function t(){this.subMeshIndex=R1&&R1(),this.shapeIndex=I1&&I1()}return t.prototype.forTarget=function(t){var e=this;return{set:function(i){t.setWeight(i,e.subMeshIndex,e.shapeIndex)}}},t}(),R1=ks(x1.prototype,"subMeshIndex",[io],(function(){return 0})),I1=ks(x1.prototype,"shapeIndex",[io],(function(){return 0})),w1=x1))||w1,z1=qs("cc.animation.MorphWeightsValueProxy")((D1=function(){function t(){this.subMeshIndex=P1&&P1()}return t.prototype.forTarget=function(t){var e=this;return{set:function(i){t.setWeights(i,e.subMeshIndex)}}},t}(),P1=ks(D1.prototype,"subMeshIndex",[io],(function(){return 0})),B1=D1))||B1,H1=qs("cc.animation.MorphWeightsAllValueProxy")(O1=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;s1e-6){n=!1;break}this._findRatio=n?I2:Ps}return t.prototype.sample=function(t){return this._findRatio(this.ratios,t)},t}());v.RatioSampler=C2;var w2=t("as",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 R2(t,e){if("string"==typeof e){var i=ja[e];i?t=i(t):J(3906,e)}else Array.isArray(e)&&(t=Fh(e,t));return t}function I2(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),o=0|s,a=1e-6;return s-o=0)i=r;else{var s=~r,o=s-1;i=o;var a=t[s],h=t[o];n=(e-h)/(a-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],o=0,a=0;if(e=s)o=n-1,a=0;else{var h=C3(t,e);o=h.index,a=h.ratio}var u=0,l=0;if(i=s)u=n-1,l=0;else{var c=C3(t,i);u=c.index,l=c.ratio}var _=!a,d=!l;o!==u||a!==l?(_||(this.preLerpIndex=o,this.preLerpRatio=a),this.directKeyframesBegin=_?o:o+1,this.directKeyframesEnd=u+1,d||(this.postLerpIndex=u,this.postLerpRatio=l)):_?(this.directKeyframesBegin=o,this.directKeyframesEnd=o+1):(this.preLerpIndex=o,this.preLerpRatio=a)}}},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 w3,x3=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}(),R3=function(){function t(t,e,i,n,r){this._position=null,this._rotation=null,this._scale=null,e&&(this._position=G3(e.times,e.values,on,t,"position",r)),i&&(this._rotation=G3(i.times,i.values,Sn,t,"rotation",r)),n&&(this._scale=G3(n.times,n.values,on,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}(),I3=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 o=Ps(t,e);if(o>=0)i.just=!0,i.index=o;else{var a=~o,h=a-1,u=t[h],l=t[a],c=(e-t[h])/(l-u);i.just=!1,i.index=h,i.nextIndex=a,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}(),B3=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),d=h[_];d&&(l.parent=d)}}for(var f=this._createEvalWithBinder(void 0,(function(t){var e=t.parseTrsPath();if(e){var i=h[e.node];if(i)return R5(i,e.property)}}),void 0),p=0;p=0&&this._embeddedPlayers.splice(e,1)},i[m5]=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 h5).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){le(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,o=[],a=this._tracks,h=a.length,u=0;u=c&&t<=_?a?e!==u&&(h.stop(),h.play(),o.entered=!0):(h.play(),o.entered=!0):a&&(h.stop(),o.entered=!1),o.lastIterations=e,o.entered){var d=t-c;o.instantiatedPlayer.setTime(d)}}}},e.notifyHostSpeedChanged=function(t){for(var e=this._embeddedPlayers,i=this._embeddedPlayerEvaluationInfos,n=e.length,r=0;r0?((s&su.PingPong)===su.PingPong?e*=-1:h=n,a++):1===e&&h===n-1&&ro)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||delete e[t])},e.apply=function(t){var e,i,n,r=this._transformApplyFlags,s=this._properties,o=s.position,a=s.scale,h=s.rotation,u=s.eulerAngles;r&&(o&&r&P5.POSITION&&(e=o.result),a&&r&P5.SCALE&&(i=a.result),u&&r&P5.EULER_ANGLES&&(n=u.result),h&&r&P5.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}()),G5=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e.prototype.createNodeBlendState=function(){return new V5},e}(O5),U5=t("aw",qs(((N5=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r=0?this._crossFades.fastRemoveAt(e):J(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):J(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),o=n.target&&s&&YQ(s,t);o&&i._sockets.push({target:n.target,transform:o})},r=0;r=h.easeDuration){o=a+1,h.easeTime=h.easeDuration;break}}if(o!==i.length){for(var c=o;c=0||(this._clips.push(t),this.createState(t)))}}]),e}(Yu(rp))).EventType=C0,p((Y5=Z5).prototype,"clips",[W5],Object.getOwnPropertyDescriptor(Y5.prototype,"clips"),Y5.prototype),p(Y5.prototype,"defaultClip",[j5],Object.getOwnPropertyDescriptor(Y5.prototype,"defaultClip"),Y5.prototype),K5=ks(Y5.prototype,"playOnLoad",[io],(function(){return!1})),J5=ks(Y5.prototype,"_clips",[X5],(function(){return[]})),Q5=ks(Y5.prototype,"_defaultClip",[io],(function(){return null})),q5=Y5))||q5)||q5));function r4(t,e){return t===e||!!t&&!!e&&t._uuid===e._uuid&&t._uuid}v.Animation=n4,v.AnimationComponent=n4,Qt(n4,"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"}($5||($5={})),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"}(t4||(t4={})),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"}(e4||(e4={}));var s4,o4=t("aB",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 o=i[s];if("stop"===o.op){n.push(o);break}if("seek"===o.op)r||(n.push(o),r=!0);else{if(r){n.push(o);break}0===n.length&&n.push(o)}}t._operationQueue=n.reverse()}(t);var i=t._operationQueue[0];i&&h4(t,i)})).catch((function(){})))}function u4(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=xi(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}(),m4=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}()),g4=window.AudioContext||window.webkitAudioContext||window.mozAudioContext,y4="on-context-running",v4=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 Ku,this._context.onstatechange=function(){"running"===t._context.state?(t._isRunning=!0,t._eventTarget.emit(y4)):t._isRunning=!1}}var e=t.prototype;return e.onceRunning=function(t,e){this._eventTarget.once(y4,t,e)},e.offRunning=function(t,e){this._eventTarget.off(y4,t,e)},e.decodeAudioData=function(t){var e=this;return new Promise((function(i){var n=e._context.decodeAudioData(t,(function(t){i(t)}),(function(t){console.error("failed to load Web Audio",t)}));null==n||n.catch((function(t){k("decodeAudioData error",t)}))}))},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){k("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){k("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}();v4.support=!!g4,v4.support&&(_4=new v4);var S4,T4,A4,b4,E4=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=_4.createBufferSource(t,!1);var n=_4.createGain(e);this._bufferSourceNode.connect(n),_4.connectContext(n)}var e=t.prototype;return e.play=function(){var t=this;this._bufferSourceNode.start(),_4.runContext().then((function(){var e;null===(e=t.onPlay)||void 0===e||e.call(t),t._currentTimer=window.setTimeout((function(){var e;m4.tryReleasingCache(t._url),null===(e=t.onEnd)||void 0===e||e.call(t)}),1e3*t._duration)})).catch((function(t){k("play error",t)}))},e.stop=function(){clearTimeout(this._currentTimer),m4.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}(),C4=(p((c4=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=e4.INIT,this._audioTimer=void 0,this._runningCallback=void 0,this._eventTarget=new Ku,this._operationQueue=[],this._audioBuffer=t,this._audioTimer=new p4(t),this._gainNode=_4.createGain(),_4.connectContext(this._gainNode),this._src=e,SN.on(vN.EVENT_PAUSE,this._onInterruptedBegin,this),SN.on(vN.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),m4.tryReleasingCache(this._src),SN.off(vN.EVENT_PAUSE,this._onInterruptedBegin,this),SN.off(vN.EVENT_RESUME,this._onInterruptedEnd,this),this.offRunning()},t.load=function(e){return new Promise((function(i){t.loadNative(e).then((function(n){i(new t(n,e))})).catch((function(t){k("load error",e,t)}))}))},t.loadNative=function(t){return new Promise((function(e,i){var n=m4.getCache(t);if(n)return m4.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?_4.decodeAudioData(r.response).then((function(i){m4.addCache(t,i),e(i)})).catch((function(e){k("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 E4(t,i,e);n(r)})).catch(r)}))},e.getPCMData=function(t){return new o4(this._audioBuffer.getChannelData(t),1)},e._onInterruptedBegin=function(){var t=this;this._state===e4.PLAYING&&this.pause().then((function(){t._state=e4.INTERRUPTED,t._eventTarget.emit($5.INTERRUPTION_BEGIN)})).catch((function(t){k("_onInterruptedBegin error",t)}))},e._onInterruptedEnd=function(){var t=this;this._state===e4.INTERRUPTED&&this.play().then((function(){t._eventTarget.emit($5.INTERRUPTION_END)})).catch((function(t){k("_onInterruptedEnd error",t)}))},e.offRunning=function(){this._runningCallback&&(_4.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===e4.PLAYING?e._doPlay().then(i).catch((function(t){k("seek error",t)})):i()}))},e.play=function(){return this.offRunning(),this._doPlay()},e._doPlay=function(){var t=this;return new Promise((function(e){_4.isRunning?(t._startSourceNode(),e()):(t.offRunning(),t._runningCallback=function(){t._startSourceNode(),e()},_4.onceRunning(t._runningCallback),_4.runContext().catch((function(t){k("doPlay error",t)})))}))},e._startSourceNode=function(){var t=this;this._stopSourceNode(),this._sourceNode=_4.createBufferSource(this._audioBuffer,this.loop),this._sourceNode.connect(this._gainNode),this._sourceNode.loop=this._loop,this._sourceNode.start(0,this._audioTimer.currentTime),this._state=e4.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($5.ENDED),t._state=e4.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===e4.PLAYING&&this._sourceNode?(this._audioTimer.pause(),this._state=e4.PAUSED,window.clearTimeout(this._currentTimer),this._stopSourceNode(),Promise.resolve()):Promise.resolve()},e.stop=function(){return this.offRunning(),this._sourceNode?(this._audioTimer.stop(),this._state=e4.STOPPED,window.clearTimeout(this._currentTimer),this._stopSourceNode(),Promise.resolve()):(this._audioTimer.stop(),this._state=e4.STOPPED,Promise.resolve())},e.onInterruptionBegin=function(t){this._eventTarget.on($5.INTERRUPTION_BEGIN,t)},e.offInterruptionBegin=function(t){this._eventTarget.off($5.INTERRUPTION_BEGIN,t)},e.onInterruptionEnd=function(t){this._eventTarget.on($5.INTERRUPTION_END,t)},e.offInterruptionEnd=function(t){this._eventTarget.off($5.INTERRUPTION_END,t)},e.onEnded=function(t){this._eventTarget.on($5.ENDED,t)},e.offEnded=function(t){this._eventTarget.off($5.ENDED,t)},n(t,[{key:"sampleRate",get:function(){return this._audioBuffer.sampleRate}},{key:"src",get:function(){return this._src}},{key:"type",get:function(){return t4.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=Ri(t),this._volume=t,_4.setGainValue(this._gainNode,t)}},{key:"duration",get:function(){return this._audioBuffer.duration}},{key:"currentTime",get:function(){return this._audioTimer.currentTime}}]),t}()).prototype,"seek",[u4],Object.getOwnPropertyDescriptor(c4.prototype,"seek"),c4.prototype),p(c4.prototype,"play",[u4],Object.getOwnPropertyDescriptor(c4.prototype,"play"),c4.prototype),p(c4.prototype,"pause",[u4],Object.getOwnPropertyDescriptor(c4.prototype,"pause"),c4.prototype),p(c4.prototype,"stop",[u4],Object.getOwnPropertyDescriptor(c4.prototype,"stop"),c4.prototype),c4),w4=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}(),x4=function(){function t(t){this._player=void 0,this._player=t}t.load=function(e,i){return new Promise((function(n){(null==i?void 0:i.audioLoadMode)!==t4.DOM_AUDIO&&v4.support?C4.load(e).then((function(e){n(new t(e))})).catch((function(){})):(v4.support||Y(5201),f4.load(e).then((function(e){n(new t(e))})).catch((function(){})))}))};var e=t.prototype;return e.destroy=function(){this._player.destroy()},t.loadNative=function(t,e){return(null==e?void 0:e.audioLoadMode)!==t4.DOM_AUDIO&&v4.support?C4.loadNative(t):(v4.support||Y(5201),f4.loadNative(t))},t.loadOneShotAudio=function(t,e,i){return new Promise((function(n,r){(null==i?void 0:i.audioLoadMode)!==t4.DOM_AUDIO&&v4.support?C4.loadOneShotAudio(t,e).then((function(t){n(new w4(t))})).catch(r):(v4.support||Y(5201),f4.loadOneShotAudio(t,e).then((function(t){n(new w4(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}();x4.maxAudioChannel=24;var R4=t("aA",qs("cc.AudioClip")(((b4=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 x4?this._tryAddPlaying(this._audioPlayerInfoList,t):this._tryAddPlaying(this._oneShotAudioInfoList,t)},e._tryRemovePlaying=function(t,e){var i=this._findIndex(t,e);return-1!==i&&(ae(t,i),!0)},e.removePlaying=function(t){t instanceof x4?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&&(t.extensions.useVAO&&n.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),n.glVAO=null),t6.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&Xl.INDEX){e.glTarget=i.ELEMENT_ARRAY_BUFFER;var o=i.createBuffer();o&&(e.glBuffer=o,e.size>0&&(t.extensions.useVAO&&n.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),n.glVAO=null),t6.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&Xl.UNIFORM?(e.glTarget=i.NONE,e.buffer&&(e.vf32=new Float32Array(e.buffer.buffer))):(e.usage&Xl.INDIRECT||e.usage&Xl.TRANSFER_DST||e.usage&Xl.TRANSFER_SRC||V("Unsupported BufferType, create buffer failed."),e.glTarget=i.NONE)}function Y8(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),t6.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),t6.gpuInputAssembler=null,i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,null),t.stateCache.glElementArrayBuffer=null}i.deleteBuffer(e.glBuffer),e.glBuffer=null}}function K8(t,e,i,n,r){if(e.usage&Xl.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&Xl.INDIRECT){e.indirects.clearDraws();for(var s=i.drawInfos,o=0;o0){e.glBlocks=new Array(e.blocks.length);for(var S=0;S0){e.glSamplerTextures=new Array(e.samplerTextures.length);for(var B=0;B=0&&E.gpuDescriptors[C],x=null,R=0;if(w&&w.gpuBuffer){var I=w.gpuBuffer,B=T[b.set],D=B&&B[b.binding];D>=0&&(R=r[D]),"vf32"in I?x=I.vf32:(R+=I.offset,x=I.gpuBuffer.vf32),R>>=2}if(x)for(var P=b.glActiveUniforms.length,O=0;O=0&&Rt.gpuDescriptors[It],Dt=xt.units.length,Pt=0;Pt0){var Mt=Bt.gpuTexture,Lt=l.glTexUnits[Ot];Lt.glTexture!==Mt.glTexture&&(l.texUnit!==Ot&&(u.activeTexture(u.TEXTURE0+Ot),l.texUnit=Ot),Mt.glTexture?u.bindTexture(Mt.glTarget,Mt.glTexture):u.bindTexture(Mt.glTarget,t.nullTex2D.gpuTexture.glTexture),Lt.glTexture=Mt.glTexture);var Nt=Bt.gpuSampler;Mt.isPowerOf2?(o=Nt.glWrapS,a=Nt.glWrapT):(o=u.CLAMP_TO_EDGE,a=u.CLAMP_TO_EDGE),h=Mt.isPowerOf2?Mt.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,Mt.glWrapS!==o&&(l.texUnit!==Ot&&(u.activeTexture(u.TEXTURE0+Ot),l.texUnit=Ot),u.texParameteri(Mt.glTarget,u.TEXTURE_WRAP_S,o),Mt.glWrapS=o),Mt.glWrapT!==a&&(l.texUnit!==Ot&&(u.activeTexture(u.TEXTURE0+Ot),l.texUnit=Ot),u.texParameteri(Mt.glTarget,u.TEXTURE_WRAP_T,a),Mt.glWrapT=a),Mt.glMinFilter!==h&&(l.texUnit!==Ot&&(u.activeTexture(u.TEXTURE0+Ot),l.texUnit=Ot),u.texParameteri(Mt.glTarget,u.TEXTURE_MIN_FILTER,h),Mt.glMinFilter=h),Mt.glMagFilter!==Nt.glMagFilter&&(l.texUnit!==Ot&&(u.activeTexture(u.TEXTURE0+Ot),l.texUnit=Ot),u.texParameteri(Mt.glTarget,u.TEXTURE_MAG_FILTER,Nt.glMagFilter),Mt.glMagFilter=Nt.glMagFilter)}Bt=Rt.gpuDescriptors[++It]}}}if(i&&c&&(_||t6.gpuInputAssembler!==i)){t6.gpuInputAssembler=i;var Ft=t.extensions.ANGLE_instanced_arrays;if(t.extensions.useVAO){var kt=t.extensions.OES_vertex_array_object,Vt=i.glVAOs.get(c.glProgram);if(!Vt){var Gt;Vt=kt.createVertexArrayOES(),i.glVAOs.set(c.glProgram,Vt),kt.bindVertexArrayOES(Vt),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(oe),l.glEnabledAttribLocs[oe]=!0),l.glCurrentAttribLocs[oe]=!0,u.vertexAttribPointer(oe,ee.count,ee.glType,ee.isNormalized,ee.stride,ae),Ft&&Ft.vertexAttribDivisorANGLE(oe,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 d=e.firstIndex*h.stride;r.drawElementsInstancedANGLE(a,e.indexCount,o.glIndexType,d,e.instanceCount)}}else e.vertexCount>0&&r.drawArraysInstancedANGLE(a,e.firstVertex,e.vertexCount,e.instanceCount);else if(h){if(e.indexCount>0){var f=e.firstIndex*h.stride;i.drawElements(a,e.indexCount,o.glIndexType,f)}}else e.vertexCount>0&&i.drawArrays(a,e.firstVertex,e.vertexCount)}}var s6=new Array(M8.COUNT);function o6(t,e){s6.fill(0);for(var i=0;i0?m.buffStride:_.width,f.height=m.buffTexHeight>0?m.buffTexHeight:_.height;var y=m.texExtent.width+d.x===i.width>>g?m.texExtent.width:_.width,v=m.texExtent.height+d.y===i.height>>g?m.texExtent.height:_.height,S=void 0,T=e[o++];if(f.width===_.width&&f.height===_.height){var A=V_(i.format,y,v,1)/u.BYTES_PER_ELEMENT;$(Number.isInteger(A),9101),S=new u(T.buffer,T.byteOffset+m.buffOffset,A)}else S=h6(T,i.format,m.buffOffset,f,_);l?i.glInternalFmt===C8.COMPRESSED_RGB_ETC1_WEBGL||t.extensions.noCompressedTexSubImage2D?r.compressedTexImage2D(r.TEXTURE_2D,g,i.glInternalFmt,y,v,0,S):r.compressedTexSubImage2D(r.TEXTURE_2D,g,d.x,d.y,y,v,i.glFormat,S):r.texSubImage2D(r.TEXTURE_2D,g,d.x,d.y,y,v,i.glFormat,i.glType,S)}break;case r.TEXTURE_CUBE_MAP:for(var b=0;b0?E.buffStride:_.width,f.height=E.buffTexHeight>0?E.buffTexHeight:_.height;var w=E.texExtent.width+d.x===i.width>>C?E.texExtent.width:_.width,x=E.texExtent.height+d.y===i.height>>C?E.texExtent.height:_.height,R=E.texSubres.baseArrayLayer+E.texSubres.layerCount;for(a=E.texSubres.baseArrayLayer;a0,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=Vi(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}(),_6=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=x8.instance.gl,e=x8.instance.bindingMappingInfo.maxBlockCounts[0];this._gpuShader={name:"Blit Pass",blocks:[new e_(0,0,"BlitParams",[new t_("tilingOffsetSrc",jl.FLOAT4,1),new t_("tilingOffsetDst",jl.FLOAT4,1)],1)],samplerTextures:[new i_(0,e,"textureSrc",jl.SAMPLER2D,1)],subpassInputs:[],gpuStages:[{type:uc.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:uc.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:[]},J8(x8.instance,this._gpuShader),this._gpuDescriptorSetLayout={bindings:[new T_(0,Tc.UNIFORM_BUFFER,1,uc.VERTEX),new T_(e,Tc.SAMPLER_TEXTURE,1,uc.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 c6,glTarget:0,glBuffer:null},this._usage&Xl.UNIFORM&&(this._gpuBuffer.buffer=this._uniformBuffer),q8(x8.instance,this._gpuBuffer),x8.instance.memoryStatus.bufferSize+=this._size},i.destroy=function(){this._gpuBuffer&&(Y8(x8.instance,this._gpuBuffer),x8.instance.memoryStatus.bufferSize-=this._size,this._gpuBuffer=null),this._gpuBufferView&&(this._gpuBufferView=null)},i.resize=function(t){if(this._isBufferView)console.warn("cannot resize buffer views!");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&Kl.HOST?i.DYNAMIC_DRAW:i.STATIC_DRAW;e.usage&Xl.VERTEX?(t.extensions.useVAO&&n.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),n.glVAO=null),t6.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&Xl.INDEX?(t.extensions.useVAO&&n.glVAO&&(t.extensions.OES_vertex_array_object.bindVertexArrayOES(null),n.glVAO=null),t6.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&Xl.UNIFORM?e.buffer&&(e.vf32=new Float32Array(e.buffer.buffer)):(e.usage&Xl.INDIRECT||e.usage&Xl.TRANSFER_DST||e.usage&Xl.TRANSFER_SRC||V("Unsupported BufferType, create buffer failed."),e.glTarget=i.NONE)}(x8.instance,this._gpuBuffer),x8.instance.memoryStatus.bufferSize-=e,x8.instance.memoryStatus.bufferSize+=t)))}},i.update=function(t,e){var i;this._isBufferView?console.warn("cannot update through buffer views!"):(i=void 0!==e?e:this._usage&Xl.INDIRECT?0:t.byteLength,K8(x8.instance,this._gpuBuffer,t,0,i))},n(e,[{key:"gpuBuffer",get:function(){return this._gpuBuffer}},{key:"gpuBufferView",get:function(){return this._gpuBufferView}}]),e}(q_),f6=function(){function t(t,e){this._frees=void 0,this._freeIdx=0,this._freeCmds=void 0,this._frees=new Array(e),this._freeCmds=new Pu(e);for(var i=0;i0?this.gpuColorTextures[0].width:this.gpuDepthStencilTexture?this.gpuDepthStencilTexture.width:o},set width(t){o=t},get height(){return this.gpuColorTextures.length>0?this.gpuColorTextures[0].height:this.gpuDepthStencilTexture?this.gpuDepthStencilTexture.height:a},set height(t){a=t},lodLevel:e},function(t,e){for(var i=0;ii&&(i=s.binding)}this._bindingIndices=Array(i+1).fill(-1);for(var o=this._descriptorIndices=Array(i+1).fill(-1),a=0;at.capabilities.maxTextureSize&&J(9100,s,t.capabilities.maxTextureSize),t.textureExclusive[e.format]||t.extensions.WEBGL_depth_texture||!M_[e.format].hasDepth){if(e.glTexture=i.createTexture(),e.size>0){var o=t.stateCache.glTexUnits[t.stateCache.texUnit];if(o.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_2D,e.glTexture),o.glTexture=e.glTexture),M_[e.format].isCompressed)for(var a=0;a>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 Hl.R5G6B5:return e.RGB565;case Hl.RGB5A1:return e.RGB5_A1;case Hl.RGBA4:return e.RGBA4;case Hl.RGBA16F:return C8.RGBA16F_EXT;case Hl.RGBA32F:return C8.RGBA32F_EXT;case Hl.SRGB8_A8:return C8.SRGB8_ALPHA8_EXT;case Hl.DEPTH:return e.DEPTH_COMPONENT16;case Hl.DEPTH_STENCIL:return e.DEPTH_STENCIL;default:return V("Unsupported Format, convert to WebGL internal format failed."),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 Jl.CUBE:e.glTarget=i.TEXTURE_CUBE_MAP;var c=Math.max(n,r);if(c>t.capabilities.maxCubeMapTextureSize&&J(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),M_[e.format].isCompressed)for(var d=0;d<6;++d){n=e.width,r=e.height;for(var f=0;f>1),r=Math.max(1,r>>1)}}else for(var g=0;g<6;++g){n=e.width,r=e.height;for(var y=0;y>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:V("Unsupported TextureType, create texture failed."),e.type=Jl.TEX2D,e.glTarget=i.TEXTURE_2D}}(x8.instance,this._gpuTexture),x8.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=G_(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 Jl.TEX2D:e.glTarget=i.TEXTURE_2D;var s=Math.max(n,r);if(s>t.capabilities.maxTextureSize&&J(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 o=t.stateCache.glTexUnits[t.stateCache.texUnit];if(o.glTexture!==e.glTexture&&(i.bindTexture(i.TEXTURE_2D,e.glTexture),o.glTexture=e.glTexture),M_[e.format].isCompressed)for(var a=0;a>1),r=Math.max(1,r>>1)}else for(var l=0;l>1),r=Math.max(1,r>>1)}break;case Jl.CUBE:e.glTarget=i.TEXTURE_CUBE_MAP;var c=Math.max(n,r);c>t.capabilities.maxCubeMapTextureSize&&J(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),M_[e.format].isCompressed)for(var d=0;d<6;++d){n=e.width,r=e.height;for(var f=0;f>1),r=Math.max(1,r>>1)}}else for(var g=0;g<6;++g){n=e.width,r=e.height;for(var y=0;y>1),r=Math.max(1,r>>1)}break;default:V("Unsupported TextureType, create texture failed."),e.type=Jl.TEX2D,e.glTarget=i.TEXTURE_2D}}}(x8.instance,this._gpuTexture),x8.instance.memoryStatus.textureSize-=n,x8.instance.memoryStatus.textureSize+=this._size))}},i.initAsSwapchainTexture=function(t){var e=new Qc;e.format=t.format,e.usage=M_[t.format].hasDepth?Ql.DEPTH_STENCIL_ATTACHMENT:Ql.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}(dd),D6="webglcontextlost";function P6(t,e){for(var i=["","WEBKIT_","MOZ_"],n=0;n=0&&a<=1&&h>=0&&h<=1)return!0}return!1}v.WebGLDevice=L6;var F6=new Ln,k6=new Ln,V6=new Ln,G6=new Ln;function U6(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 H6(t,e,i,n){var r,s=i.x-e.x,o=i.y-e.y,a=s*s+o*o,h=((t.x-e.x)*s+(t.y-e.y)*o)/a;return r=n?a?h<0?e:h>1?i:F6.set(e.x+h*s,e.y+h*o):e:F6.set(e.x+h*s,e.y+h*o),s=t.x-r.x,o=t.y-r.y,Math.sqrt(s*s+o*o)}var W6=t("eQ",(function(){}));W6.lineLine=N6,W6.lineRect=function(t,e,i){var n=F6.set(i.x,i.y),r=k6.set(i.x,i.yMax),s=V6.set(i.xMax,i.yMax),o=G6.set(i.xMax,i.y);return!!(N6(t,e,n,r)||N6(t,e,r,s)||N6(t,e,s,o)||N6(t,e,o,n))},W6.linePolygon=U6,W6.rectRect=function(t,e){var i=t.x,n=t.y,r=t.x+t.width,s=t.y+t.height,o=e.x,a=e.y,h=e.x+e.width,u=e.y+e.height;return i<=h&&r>=o&&n<=u&&s>=a},W6.rectPolygon=function(t,e){var i=F6.set(t.x,t.y),n=k6.set(t.x,t.yMax),r=V6.set(t.xMax,t.yMax),s=G6.set(t.xMax,t.y);if(U6(i,n,e))return!0;if(U6(n,r,e))return!0;if(U6(r,s,e))return!0;if(U6(s,i,e))return!0;for(var o=0,a=e.length;os+a&&(u=s+a),ro+h&&(l=o+h);var c=n-u,_=r-l;return Math.sqrt(c*c+_*_)<=i},W6.polygonPolygon=function(t,e){var i,n;for(i=0,n=t.length;i1?h=a/u:a=h*u;var l=a/2,c=h/2;if(t.rotation){var _=-l,d=-c,f=l,p=c,m=-ke(t.rotation),g=Math.cos(m),y=Math.sin(m);r[n]=_*g-d*y+s,r[n+1]=_*y+d*g+o,r[n+2]=0,r[n+9]=f*g-d*y+s,r[n+10]=f*y+d*g+o,r[n+11]=0,r[n+18]=_*g-p*y+s,r[n+19]=_*y+p*g+o,r[n+20]=0,r[n+27]=f*g-p*y+s,r[n+28]=f*y+p*g+o,r[n+29]=0}else r[n]=s-l,r[n+1]=o-c,r[n+2]=0,r[n+9]=s+l,r[n+10]=o-c,r[n+11]=0,r[n+18]=s-l,r[n+19]=o+c,r[n+20]=0,r[n+27]=s+l,r[n+28]=o+c,r[n+29]=0;dn.toArray(r,t.color,n+5),dn.toArray(r,t.color,n+14),dn.toArray(r,t.color,n+23),dn.toArray(r,t.color,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===K6.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;Q6.x=s.m12,Q6.y=s.m13}else i.positionType===K6.RELATIVE?(this._worldRotation=n.eulerAngles.z,Q6.x=n.position.x,Q6.y=n.position.y):this._worldRotation=0;if(this.active&&i.emissionRate){var o=1/i.emissionRate;for(r.lengtho;)this.emitParticle(Q6),this.emitCounter-=o;this.elapsed+=t,-1!==i.duration&&i.durationthis.uvFilled&&this.updateUVs();for(var u=0;u0){if(i.emitterMode===Y6.GRAVITY){var c=t7,_=Z6,d=$6;(l.pos.x||l.pos.y)&&(_.set(l.pos),_.normalize()),d.set(_),_.multiplyScalar(l.radialAccel);var f=d.x;d.x=-d.y,d.y=f,d.multiplyScalar(l.tangentialAccel),c.set(_),c.add(d),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=Z6;p.set(l.pos),i.positionType!==K6.GROUPED&&p.add(l.startPos);var m=e7*u*4;this.updateParticleBuffer(l,p,a,m),++u}else{var g=r[u];u!==r.length-1&&(r[u]=r[r.length-1]),n7.put(g),r.length--,a.resize(a.vertexCount-4,a.indexCount-6)}}this.renderData.material=this.sys.getRenderMaterial(0),this.renderData.frame=this.sys._renderSpriteFrame,a.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 d=this.colorType;this.hasAlphaChannel=4===d||6===d;var f=this.colors+(this.hasAlphaChannel?1:0);return this.pixelBitlength=this.bits*f,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(tt(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 UN.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,o=0,a=0,h=0,u=0,l=0,c=0,_=0,d=0,f=0,p=0,m=0,g=0,y=0,v=0,S=0,T=0,A=0,b=0;o>>8*(4-s)):r.push(n);else for(var o=0;o=8?-1!==["RATIONAL","SRATIONAL"].indexOf(e)?(r.push(this.getUint32(n+a)),r.push(this.getUint32(n+a+4))):X(8e3):r.push(this.getBytes(s,n+a))}return"ASCII"===e&&r.forEach((function(t,e,i){i[e]=String.fromCharCode(t)})),r},e.getBytes=function(t,e){if(t<=0)X(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);X(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,o=0,a=0;return r<=0?X(6023):r<=8?(o=24+i,a=this.getUint8(n)):r<=16?(o=16+i,a=this.getUint16(n)):r<=32?(o=i,a=this.getUint32(n)):X(6022),{bits:a<>>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?y=1-L:w=!0}else{for(var N=this.getUint8(S+b),F=0;F0)for(var o=0;o>4,i=(15&r)<<4|(s=c7[t.charCodeAt(h++)])>>2,n=(3&s)<<6|(o=c7[t.charCodeAt(h++)]),a.push(String.fromCharCode(e)),64!==s&&a.push(String.fromCharCode(i)),64!==o&&a.push(String.fromCharCode(n));return a.join("")},decodeAsArray:function(t,e){var i,n,r,s=this.decode(t),o=[];for(i=0,r=s.length/e;i=0;--n)o[i]+=s.charCodeAt(i*e+n)<<8*n;return o}},p7=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(p7.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};p7.gunzip=function(t){return t.constructor===Array||t.constructor,new p7(t).gunzip()[0][0]},p7.HufNode=function(){this.b0=0,this.b1=0,this.jump=null,this.jumppos=-1},p7.LITERALS=288,p7.NAMEMAX=256,p7.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],p7.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],p7.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],p7.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],p7.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],p7.border=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],p7.prototype.gunzip=function(){return this.outputArr=[],this.nextFile(),this.unzipped},p7.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},p7.prototype.readBits=function(t){for(var e=0,i=t;i--;)e=e<<1|this.readBit();return t&&(e=p7.bitReverse[e]>>8-t),e},p7.prototype.flushBuffer=function(){this.bIdx=0},p7.prototype.addBuffer=function(t){this.buf32k[this.bIdx++]=t,this.outputArr.push(String.fromCharCode(t)),32768===this.bIdx&&(this.bIdx=0)},p7.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]++}},p7.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},p7.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},p7.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?(o=o<<1|this.readBit())>199?o=(o-=128)<<1|this.readBit():(o-=48)>143&&(o+=136):o+=256,o<256)this.addBuffer(o);else{if(256===o)break;for(o-=257,f=this.readBits(p7.cplext[o])+p7.cplens[o],o=p7.bitReverse[this.readBits(5)]>>3,p7.cpdext[o]>8?(p=this.readBits(8),p|=this.readBits(p7.cpdext[o]-8)<<8):p=this.readBits(p7.cpdext[o]),p+=p7.cpdist[o],o=0;oa)return this.flushBuffer(),1;for(_=i?c[i-1]:0;o--;)c[i++]=_}else{if(i+(o=17===o?3+this.readBits(3):11+this.readBits(7))>a)return this.flushBuffer(),1;for(;o--;)c[i++]=0}for(f=this.literalTree.length,i=0;i=256){var f,p;if(0==(o-=256))break;for(o--,f=this.readBits(p7.cplext[o])+p7.cplens[o],o=this.DecodeValue(this.distanceTree),p7.cpdext[o]>8?(p=this.readBits(8),p|=this.readBits(p7.cpdext[o]-8)<<8):p=this.readBits(p7.cpdext[o]),p+=p7.cpdist[o];f--;)s=this.buf32k[this.bIdx-p&32767],this.addBuffer(s)}else this.addBuffer(o)}}while(!t);return this.flushBuffer(),this.byteAlign(),0},p7.prototype.unzipFile=function(t){var e;for(this.gunzip(),e=0;e=0;--n)o[i]+=s.charCodeAt(i*e+n)<<8*n;return o},p9.unzipAsArray=function(t,e){e=e||1;var i,n,r,s=this.unzip(t),o=[];for(i=0,r=s.length/e;i=0;--n)o[i]+=s.charCodeAt(i*e+n)<<8*n;return o},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"}(f9||(f9={}));var g9,y9,v9,S9,T9,A9,b9,E9,C9,w9,x9,R9=t("eR",(m7=qs("cc.ParticleSystem2D"),g7=xo(o7),y7=xo(pF),v7=xo(K6),S7=xo(Y6),T7=no("preview"),m7(((d9=function(t){function e(){var e;return(e=t.call(this)||this).duration=E7&&E7(),e.emissionRate=C7&&C7(),e.life=w7&&w7(),e.lifeVar=x7&&x7(),e.angle=R7&&R7(),e.angleVar=I7&&I7(),e.startSize=B7&&B7(),e.startSizeVar=D7&&D7(),e.endSize=P7&&P7(),e.endSizeVar=O7&&O7(),e.startSpin=M7&&M7(),e.startSpinVar=L7&&L7(),e.endSpin=N7&&N7(),e.endSpinVar=F7&&F7(),e.sourcePos=k7&&k7(),e.posVar=V7&&V7(),e.emitterMode=G7&&G7(),e.gravity=U7&&U7(),e.speed=z7&&z7(),e.speedVar=H7&&H7(),e.tangentialAccel=W7&&W7(),e.tangentialAccelVar=j7&&j7(),e.radialAccel=X7&&X7(),e.radialAccelVar=q7&&q7(),e.rotationIsDir=Y7&&Y7(),e.startRadius=K7&&K7(),e.startRadiusVar=J7&&J7(),e.endRadius=Q7&&Q7(),e.endRadiusVar=Z7&&Z7(),e.rotatePerS=$7&&$7(),e.rotatePerSVar=t9&&t9(),e.aspectRatio=1,e.playOnLoad=e9&&e9(),e.autoRemoveOnFinish=i9&&i9(),e._preview=n9&&n9(),e._custom=r9&&r9(),e._file=s9&&s9(),e._spriteFrame=o9&&o9(),e._totalParticles=a9&&a9(),e._startColor=h9&&h9(),e._startColorVar=u9&&u9(),e._endColor=l9&&l9(),e._endColorVar=c9&&c9(),e._positionType=_9&&_9(),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 r7(this)},i.onFocusInEditor=function(){this._focused=!0;for(var t=m9(this.node),e=0;e=this.totalParticles},i._applyFile=function(){var t=this._file;if(t){if(!t)return void J(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;ZS.loadAny(n,(function(e,n){e?(t.spriteFrameUuid=void 0,i._initTextureWithDictionary(t),V(e)):i.spriteFrame=n}))}else{var r=dl(this._plistFile,t.textureFileName||"");if(t.textureFileName)ZS.loadRemote(r,(function(e,n){e?(t.textureFileName=void 0,i._initTextureWithDictionary(t),V(e)):i.spriteFrame=n?pF.createWithImage(n):pF.createWithImage(nT.get("white-texture"))}));else if(t.textureImageData){var s=t.textureImageData;if(!(s&&s.length>0))return!1;var o=r;this.file&&(o+="-"+this.file.uuid);var a=ZS.assets.get(o);if(!a){var h=p9.unzipBase64AsArray(s,1);if(!h)return Y(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]?f9.PNG:e.length>2&&(73===e[0]&&73===e[1]||77===e[0]&&77===e[1]||255===e[0]&&216===e[1])?f9.TIFF:f9.UNKNOWN;if(u!==f9.TIFF&&u!==f9.PNG)return Y(6031,this._file.name),!1;var l=T.document.createElement("canvas");u===f9.PNG?new a7(h).render(l):(this._tiffReader||(this._tiffReader=new h7),this._tiffReader.parseTIFF(h,l)),a=new Rf(l),ZS.assets.add(o,a)}a||Y(6032,this._file.name),this.spriteFrame=a?pF.createWithImage(a):pF.createWithImage(nT.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||oc.SRC_ALPHA),this._dstBlendFactor=parseInt(t.blendFuncDestination||oc.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:K6.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||Y6.GRAVITY),this.emitterMode===Y6.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 o=t.rotationIsDir||"";null!==o?(o=o.toString().toLowerCase(),this.rotationIsDir="true"===o||"1"===o):this.rotationIsDir=!1}else{if(this.emitterMode!==Y6.RADIUS)return Y(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!==K6.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===K6.RELATIVE?t.commitComp(this,this._simulator.renderData,this._renderSpriteFrame,this._assembler,this.node.parent):this.positionType===K6.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===K6.RELATIVE?(this._renderEntity.setRenderTransform(this.node.parent),this._renderEntity.setUseLocal(!0)):this.positionType===K6.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}(TV)).EmitterMode=Y6,d9.PositionType=K6,d9.DURATION_INFINITY=-1,d9.START_SIZE_EQUAL_TO_END_SIZE=-1,d9.START_RADIUS_EQUAL_TO_END_RADIUS=-1,p((b7=d9).prototype,"file",[g7],Object.getOwnPropertyDescriptor(b7.prototype,"file"),b7.prototype),p(b7.prototype,"spriteFrame",[y7],Object.getOwnPropertyDescriptor(b7.prototype,"spriteFrame"),b7.prototype),E7=ks(b7.prototype,"duration",[io],(function(){return-1})),C7=ks(b7.prototype,"emissionRate",[io],(function(){return 10})),w7=ks(b7.prototype,"life",[io],(function(){return 1})),x7=ks(b7.prototype,"lifeVar",[io],(function(){return 0})),p(b7.prototype,"color",[Ro],Object.getOwnPropertyDescriptor(b7.prototype,"color"),b7.prototype),R7=ks(b7.prototype,"angle",[io],(function(){return 90})),I7=ks(b7.prototype,"angleVar",[io],(function(){return 20})),B7=ks(b7.prototype,"startSize",[io],(function(){return 50})),D7=ks(b7.prototype,"startSizeVar",[io],(function(){return 0})),P7=ks(b7.prototype,"endSize",[io],(function(){return 0})),O7=ks(b7.prototype,"endSizeVar",[io],(function(){return 0})),M7=ks(b7.prototype,"startSpin",[io],(function(){return 0})),L7=ks(b7.prototype,"startSpinVar",[io],(function(){return 0})),N7=ks(b7.prototype,"endSpin",[io],(function(){return 0})),F7=ks(b7.prototype,"endSpinVar",[io],(function(){return 0})),k7=ks(b7.prototype,"sourcePos",[io],(function(){return Ln.ZERO.clone()})),V7=ks(b7.prototype,"posVar",[io],(function(){return Ln.ZERO.clone()})),p(b7.prototype,"positionType",[v7],Object.getOwnPropertyDescriptor(b7.prototype,"positionType"),b7.prototype),G7=ks(b7.prototype,"emitterMode",[io,S7],(function(){return Y6.GRAVITY})),U7=ks(b7.prototype,"gravity",[io],(function(){return Ln.ZERO.clone()})),z7=ks(b7.prototype,"speed",[io],(function(){return 180})),H7=ks(b7.prototype,"speedVar",[io],(function(){return 50})),W7=ks(b7.prototype,"tangentialAccel",[io],(function(){return 80})),j7=ks(b7.prototype,"tangentialAccelVar",[io],(function(){return 0})),X7=ks(b7.prototype,"radialAccel",[io],(function(){return 0})),q7=ks(b7.prototype,"radialAccelVar",[io],(function(){return 0})),Y7=ks(b7.prototype,"rotationIsDir",[io],(function(){return!1})),K7=ks(b7.prototype,"startRadius",[io],(function(){return 0})),J7=ks(b7.prototype,"startRadiusVar",[io],(function(){return 0})),Q7=ks(b7.prototype,"endRadius",[io],(function(){return 0})),Z7=ks(b7.prototype,"endRadiusVar",[io],(function(){return 0})),$7=ks(b7.prototype,"rotatePerS",[io],(function(){return 0})),t9=ks(b7.prototype,"rotatePerSVar",[io],(function(){return 0})),e9=ks(b7.prototype,"playOnLoad",[io],(function(){return!0})),i9=ks(b7.prototype,"autoRemoveOnFinish",[io],(function(){return!1})),n9=ks(b7.prototype,"_preview",[T7],(function(){return!0})),r9=ks(b7.prototype,"_custom",[io],(function(){return!1})),s9=ks(b7.prototype,"_file",[io],(function(){return null})),o9=ks(b7.prototype,"_spriteFrame",[io],(function(){return null})),a9=ks(b7.prototype,"_totalParticles",[io],(function(){return 150})),h9=ks(b7.prototype,"_startColor",[io],(function(){return new dn(255,255,255,255)})),u9=ks(b7.prototype,"_startColorVar",[io],(function(){return new dn(0,0,0,0)})),l9=ks(b7.prototype,"_endColor",[io],(function(){return new dn(255,255,255,0)})),c9=ks(b7.prototype,"_endColorVar",[io],(function(){return new dn(0,0,0,0)})),_9=ks(b7.prototype,"_positionType",[io],(function(){return K6.FREE})),A7=b7))||A7)),I9=function(){function t(t,e){this.point=new Ln,this.dir=new Ln,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}(),B9=t("eS",(g9=qs("cc.MotionStreak"),y9=xo(Zp),g9(((x9=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r1){var h=a[0],u=h.point.x-s,l=h.point.y-o;u*u+l*l=0;b--){var E=a[b],C=E.point,w=E.dir;if(E.time-=e,E.time<0)a.splice(b,1);else{var x=E.time/T,R=a[b-1];if(!A){if(!R){a.splice(b,1);continue}C.x=R.point.x-w.x*x,C.y=R.point.y-w.y*x}A=!0,M9(P9,w);var I=(x*y<<24>>>0)+(g<<16)+(m<<8)+p,B=_;S[B].x=C.x+P9.x*n,S[B].y=C.y+P9.y*n,S[B].u=1,S[B].v=x,S[B].color._val=I,S[B+=1].x=C.x-P9.x*n,S[B].y=C.y-P9.y*n,S[B].u=0,S[B].v=x,S[B].color._val=I,_+=2}}c=_<=2?0:3*(_-2),d.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 M(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,V=Math.pow;var G=Math.cos,U=Math.sin,z=Math.acos,H=Math.asin,W=Math.atan2;var j=function(){function t(){for(var t=arguments.length,e=new Array(t),i=0;i=r){var e=1/t;this.x*=e,this.y*=e}return t},e.SelfNormalize=function(){var t=this.Length();if(t>=r){var e=1/t;this.x*=e,this.y*=e}return this},e.SelfRotate=function(t){var e=Math.cos(t),i=Math.sin(t),n=this.x;return this.x=e*n-i*this.y,this.y=i*n+e*this.y,this},e.SelfRotateCosSin=function(t,e){var i=this.x;return this.x=t*i-e*this.y,this.y=e*i+t*this.y,this},e.IsValid=function(){return isFinite(this.x)&&isFinite(this.y)},e.SelfCrossVS=function(t){var e=this.x;return this.x=t*this.y,this.y=-t*e,this},e.SelfCrossSV=function(t){var e=this.x;return this.x=-t*this.y,this.y=t*e,this},e.SelfMinV=function(t){return this.x=P(this.x,t.x),this.y=P(this.y,t.y),this},e.SelfMaxV=function(t){return this.x=O(this.x,t.x),this.y=O(this.y,t.y),this},e.SelfAbs=function(){return this.x=D(this.x),this.y=D(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 w(e,(function(){return new t}))},t.AbsV=function(t,e){return e.x=D(t.x),e.y=D(t.y),e},t.MinV=function(t,e,i){return i.x=P(t.x,e.x),i.y=P(t.y,e.y),i},t.MaxV=function(t,e,i){return i.x=O(t.x,e.x),i.y=O(t.y,e.y),i},t.ClampV=function(t,e,i,n){return n.x=M(t.x,e.x,i.x),n.y=M(t.y,e.y,i.y),n},t.RotateV=function(t,e,i){var n=t.x,r=t.y,s=Math.cos(e),o=Math.sin(e);return i.x=s*n-o*r,i.y=o*n+s*r,i},t.DotVV=function(t,e){return t.x*e.x+t.y*e.y},t.CrossVV=function(t,e){return t.x*e.y-t.y*e.x},t.CrossVS=function(t,e,i){var n=t.x;return i.x=e*t.y,i.y=-e*n,i},t.CrossVOne=function(t,e){var i=t.x;return e.x=t.y,e.y=-i,e},t.CrossSV=function(t,e,i){var n=e.x;return i.x=-t*e.y,i.y=t*n,i},t.CrossOneV=function(t,e){var i=t.x;return e.x=-t.y,e.y=i,e},t.AddVV=function(t,e,i){return i.x=t.x+e.x,i.y=t.y+e.y,i},t.SubVV=function(t,e,i){return i.x=t.x-e.x,i.y=t.y-e.y,i},t.MulSV=function(t,e,i){return i.x=e.x*t,i.y=e.y*t,i},t.MulVS=function(t,e,i){return i.x=t.x*e,i.y=t.y*e,i},t.AddVMulSV=function(t,e,i,n){return n.x=t.x+e*i.x,n.y=t.y+e*i.y,n},t.SubVMulSV=function(t,e,i,n){return n.x=t.x-e*i.x,n.y=t.y-e*i.y,n},t.AddVCrossSV=function(t,e,i,n){var r=i.x;return n.x=t.x-e*i.y,n.y=t.y+e*r,n},t.MidVV=function(t,e,i){return i.x=.5*(t.x+e.x),i.y=.5*(t.y+e.y),i},t.ExtVV=function(t,e,i){return i.x=.5*(e.x-t.x),i.y=.5*(e.y-t.y),i},t.IsEqualToV=function(t,e){return t.x===e.x&&t.y===e.y},t.DistanceVV=function(t,e){var i=t.x-e.x,n=t.y-e.y;return Math.sqrt(i*i+n*n)},t.DistanceSquaredVV=function(t,e){var i=t.x-e.x,n=t.y-e.y;return i*i+n*n},t.NegV=function(t,e){return e.x=-t.x,e.y=-t.y,e},n(t,[{key:"x",get:function(){return this.data[0]},set:function(t){this.data[0]=t}},{key:"y",get:function(){return this.data[1]},set:function(t){this.data[1]=t}}]),t}();j.ZERO=new j(0,0),j.UNITX=new j(1,0),j.UNITY=new j(0,1),j.s_t0=new j,j.s_t1=new j,j.s_t2=new j,j.s_t3=new j;var X=new j(0,0),q=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=w(t,(function(){return null})),this.m_count=0}var e=t.prototype;return e.Reset=function(){return this.m_count=0,this},e.Push=function(t){this.m_stack[this.m_count]=t,this.m_count++},e.Pop=function(){this.m_count--;var t=this.m_stack[this.m_count];if(this.m_stack[this.m_count]=null,null===t)throw new Error;return t},e.GetCount=function(){return this.m_count},t}(),st=function(){function t(){this.m_buffer=j.MakeArray(2),this.m_vertices=this.m_buffer,this.m_count=0,this.m_radius=0}var e=t.prototype;return e.Copy=function(t){return t.m_vertices===t.m_buffer?(this.m_vertices=this.m_buffer,this.m_buffer[0].Copy(t.m_buffer[0]),this.m_buffer[1].Copy(t.m_buffer[1])):this.m_vertices=t.m_vertices,this.m_count=t.m_count,this.m_radius=t.m_radius,this},e.Reset=function(){return this.m_vertices=this.m_buffer,this.m_count=0,this.m_radius=0,this},e.SetShape=function(t,e){t.SetupDistanceProxy(this,e)},e.SetVerticesRadius=function(t,e,i){this.m_vertices=t,this.m_count=e,this.m_radius=i},e.GetSupport=function(t){for(var e=0,i=j.DotVV(this.m_vertices[0],t),n=1;ni&&(e=n,i=r)}return e},e.GetSupportVertex=function(t){for(var e=0,i=j.DotVV(this.m_vertices[0],t),n=1;ni&&(e=n,i=r)}return this.m_vertices[e]},e.GetVertexCount=function(){return this.m_count},e.GetVertex=function(t){return this.m_vertices[t]},t}(),ot=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}(),at=function(){function t(){this.proxyA=new st,this.proxyB=new st,this.transformA=new Q,this.transformB=new Q,this.useRadii=!1}return t.prototype.Reset=function(){return this.proxyA.Reset(),this.proxyB.Reset(),this.transformA.SetIdentity(),this.transformB.SetIdentity(),this.useRadii=!1,this},t}(),ht=function(){function t(){this.pointA=new j,this.pointB=new j,this.distance=0,this.iterations=0}return t.prototype.Reset=function(){return this.pointA.SetZero(),this.pointB.SetZero(),this.distance=0,this.iterations=0,this},t}();t.b2_gjkCalls=0,t.b2_gjkIters=0,t.b2_gjkMaxIters=0;var ut=function(){function t(){this.wA=new j,this.wB=new j,this.w=new j,this.a=0,this.indexA=0,this.indexB=0}return t.prototype.Copy=function(t){return this.wA.Copy(t.wA),this.wB.Copy(t.wB),this.w.Copy(t.w),this.a=t.a,this.indexA=t.indexA,this.indexB=t.indexB,this},t}(),lt=function(){function t(){this.m_v1=new ut,this.m_v2=new ut,this.m_v3=new ut,this.m_vertices=[],this.m_count=0,this.m_vertices[0]=this.m_v1,this.m_vertices[1]=this.m_v2,this.m_vertices[2]=this.m_v3}var e=t.prototype;return e.ReadCache=function(t,e,i,n,s){this.m_count=t.count;for(var o=this.m_vertices,a=0;a1){var c=t.metric,_=this.GetMetric();(_<.5*c||2*c<_||_0?j.CrossOneV(e,t):j.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 j.DistanceVV(this.m_v1.w,this.m_v2.w);case 3:return j.CrossVV(j.SubVV(this.m_v2.w,this.m_v1.w,j.s_t0),j.SubVV(this.m_v3.w,this.m_v1.w,j.s_t1));default:return 0}},e.Solve2=function(){var e=this.m_v1.w,i=this.m_v2.w,n=j.SubVV(i,e,t.s_e12),r=-j.DotVV(e,n);if(r<=0)return this.m_v1.a=1,void(this.m_count=1);var s=j.DotVV(i,n);if(s<=0)return this.m_v2.a=1,this.m_count=1,void this.m_v1.Copy(this.m_v2);var o=1/(s+r);this.m_v1.a=s*o,this.m_v2.a=r*o,this.m_count=2},e.Solve3=function(){var e=this.m_v1.w,i=this.m_v2.w,n=this.m_v3.w,r=j.SubVV(i,e,t.s_e12),s=j.DotVV(e,r),o=j.DotVV(i,r),a=-s,h=j.SubVV(n,e,t.s_e13),u=j.DotVV(e,h),l=j.DotVV(n,h),c=-u,_=j.SubVV(n,i,t.s_e23),d=j.DotVV(i,_),f=j.DotVV(n,_),p=-d,m=j.CrossVV(r,h),g=m*j.CrossVV(i,n),y=m*j.CrossVV(n,e),v=m*j.CrossVV(e,i);if(a<=0&&c<=0)return this.m_v1.a=1,void(this.m_count=1);if(o>0&&a>0&&v<=0){var S=1/(o+a);return this.m_v1.a=o*S,this.m_v2.a=a*S,void(this.m_count=2)}if(l>0&&c>0&&y<=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(o<=0&&p<=0)return this.m_v2.a=1,this.m_count=1,void this.m_v1.Copy(this.m_v2);if(l<=0&&f<=0)return this.m_v3.a=1,this.m_count=1,void this.m_v1.Copy(this.m_v3);if(f>0&&p>0&&g<=0){var A=1/(f+p);return this.m_v2.a=f*A,this.m_v3.a=p*A,this.m_count=2,void this.m_v1.Copy(this.m_v3)}var b=1/(g+y+v);this.m_v1.a=g*b,this.m_v2.a=y*b,this.m_v3.a=v*b,this.m_count=3},t}();lt.s_e12=new j,lt.s_e13=new j,lt.s_e23=new j;var ct=new lt,_t=[0,0,0],dt=[0,0,0],ft=new j,pt=new j,mt=new j,gt=new j,yt=new j;function vt(e,i,n){++t.b2_gjkCalls;var s=n.proxyA,a=n.proxyB,h=n.transformA,u=n.transformB,l=ct;l.ReadCache(i,s,h,a,u);for(var c=l.m_vertices,_=_t,d=dt,f=0,p=0;p<20;){f=l.m_count;for(var m=0;mT+A&&e.distance>r){e.distance-=T+A;var b=j.SubVV(e.pointB,e.pointA,mt);b.Normalize(),e.pointA.SelfMulAdd(T,b),e.pointB.SelfMulSub(A,b)}else{var E=j.MidVV(e.pointA,e.pointB,ft);e.pointA.Copy(E),e.pointB.Copy(E),e.distance=0}}}var St,Tt=new j,At=new lt,bt=new j,Et=new j,Ct=new j,wt=new j,xt=new j,Rt=new j;(St=t.b2ContactFeatureType||(t.b2ContactFeatureType={}))[St.e_vertex=0]="e_vertex",St[St.e_face=1]="e_face";var It,Bt=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}(),Dt=function(){function t(){this.cf=new Bt}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}(),Pt=function(){function t(){this.localPoint=new j,this.normalImpulse=0,this.tangentImpulse=0,this.id=new Dt}t.MakeArray=function(e){return w(e,(function(){return new t}))};var e=t.prototype;return e.Reset=function(){this.localPoint.SetZero(),this.normalImpulse=0,this.tangentImpulse=0,this.id.key=0},e.Copy=function(t){return this.localPoint.Copy(t.localPoint),this.normalImpulse=t.normalImpulse,this.tangentImpulse=t.tangentImpulse,this.id.Copy(t.id),this},t}();(It=t.b2ManifoldType||(t.b2ManifoldType={}))[It.e_unknown=-1]="e_unknown",It[It.e_circles=0]="e_circles",It[It.e_faceA=1]="e_faceA",It[It.e_faceB=2]="e_faceB";var Ot,Mt=function(){function e(){this.points=Pt.MakeArray(2),this.localNormal=new j,this.localPoint=new j,this.type=t.b2ManifoldType.e_unknown,this.pointCount=0}var i=e.prototype;return i.Reset=function(){for(var e=0;e<2;++e)this.points[e].Reset();this.localNormal.SetZero(),this.localPoint.SetZero(),this.type=t.b2ManifoldType.e_unknown,this.pointCount=0},i.Copy=function(t){this.pointCount=t.pointCount;for(var e=0;e<2;++e)this.points[e].Copy(t.points[e]);return this.localNormal.Copy(t.localNormal),this.localPoint.Copy(t.localPoint),this.type=t.type,this},i.Clone=function(){return(new e).Copy(this)},e}(),Lt=function(){function e(){this.normal=new j,this.points=j.MakeArray(2),this.separations=x(2)}return e.prototype.Initialize=function(i,n,r,s,a){if(0!==i.pointCount)switch(i.type){case t.b2ManifoldType.e_circles:this.normal.Set(1,0);var h=Q.MulXV(n,i.localPoint,e.Initialize_s_pointA),u=Q.MulXV(s,i.points[0].localPoint,e.Initialize_s_pointB);j.DistanceSquaredVV(h,u)>o&&j.SubVV(u,h,this.normal).SelfNormalize();var l=j.AddVMulSV(h,r,this.normal,e.Initialize_s_cA),c=j.SubVMulSV(u,a,this.normal,e.Initialize_s_cB);j.MidVV(l,c,this.points[0]),this.separations[0]=j.DotVV(j.SubVV(c,l,j.s_t0),this.normal);break;case t.b2ManifoldType.e_faceA:J.MulRV(n.q,i.localNormal,this.normal);for(var _=Q.MulXV(n,i.localPoint,e.Initialize_s_planePoint),d=0;dp){var g=f;f=p,p=g,m=1}if(f>n&&(_.x=m,_.y=0,n=f),n>(s=P(s,p)))return!1}if(cS){var A=v;v=S,S=A,T=1}if(v>n&&(_.x=0,_.y=T,n=v),n>(s=P(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=j.SubVV(r,n,t.s_r);s.Normalize();var o=j.CrossOneV(s,t.s_v),a=j.AbsV(o,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=P(n.x,l),u.lowerBound.y=P(n.y,c),u.upperBound.x=O(n.x,l),u.upperBound.y=O(n.y,c);var _=this.m_stack.Reset();for(_.Push(this.m_root);_.GetCount()>0;){var d=_.Pop();if(null!==d&&Gt(d.aabb,u)){var f=d.aabb.GetCenter(),p=d.aabb.GetExtents();if(!(D(j.DotVV(o,j.SubVV(n,f,j.s_t0)))-j.DotVV(a,p)>0))if(d.IsLeaf()){var m=t.s_subInput;m.p1.Copy(e.p1),m.p2.Copy(e.p2),m.maxFraction=h;var g=i(m,d);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=P(n.x,l),u.lowerBound.y=P(n.y,c),u.upperBound.x=O(n.x,l),u.upperBound.y=O(n.y,c))}else _.Push(d.child1),_.Push(d.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 qt(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=Xt(n.child1),s=Xt(n.child2),o=n.aabb.GetPerimeter(),a=t.s_combinedAABB;a.Combine2(n.aabb,i);var h=a.GetPerimeter(),u=2*h,l=2*(h-o),c=void 0,_=t.s_aabb,d=void 0;r.IsLeaf()?(_.Combine2(i,r.aabb),c=_.GetPerimeter()+l):(_.Combine2(i,r.aabb),d=r.aabb.GetPerimeter(),c=_.GetPerimeter()-d+l);var f=void 0;if(s.IsLeaf()?(_.Combine2(i,s.aabb),f=_.GetPerimeter()+l):(_.Combine2(i,s.aabb),d=s.aabb.GetPerimeter(),f=_.GetPerimeter()-d+l),u1){var r=Xt(i.child1),s=Xt(i.child2);return i.child1=t,i.parent=t.parent,t.parent=i,null!==i.parent?i.parent.child1===t?i.parent.child1=i:i.parent.child2=i:this.m_root=i,r.height>s.height?(i.child2=r,t.child2=s,s.parent=t,t.aabb.Combine2(e.aabb,s.aabb),i.aabb.Combine2(t.aabb,r.aabb),t.height=1+O(e.height,s.height),i.height=1+O(t.height,r.height)):(i.child2=s,t.child2=r,r.parent=t,t.aabb.Combine2(e.aabb,r.aabb),i.aabb.Combine2(t.aabb,s.aabb),t.height=1+O(e.height,r.height),i.height=1+O(t.height,s.height)),i}if(n<-1){var o=Xt(e.child1),a=Xt(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,o.height>a.height?(e.child2=o,t.child1=a,a.parent=t,t.aabb.Combine2(i.aabb,a.aabb),e.aabb.Combine2(t.aabb,o.aabb),t.height=1+O(i.height,a.height),e.height=1+O(t.height,o.height)):(e.child2=a,t.child1=o,o.parent=t,t.aabb.Combine2(i.aabb,o.aabb),e.aabb.Combine2(t.aabb,a.aabb),t.height=1+O(i.height,o.height),e.height=1+O(t.height,a.height)),e}return t},e.GetHeight=function(){return null===this.m_root?0:this.m_root.height},t.GetAreaNode=function(e){if(null===e)return 0;if(e.IsLeaf())return 0;var i=e.aabb.GetPerimeter();return(i+=t.GetAreaNode(e.child1))+t.GetAreaNode(e.child2)},e.GetAreaRatio=function(){if(null===this.m_root)return 0;var e=this.m_root.aabb.GetPerimeter();return t.GetAreaNode(this.m_root)/e},t.ComputeHeightNode=function(e){return null===e||e.IsLeaf()?0:1+O(t.ComputeHeightNode(e.child1),t.ComputeHeightNode(e.child2))},e.ComputeHeight=function(){return t.ComputeHeightNode(this.m_root)},e.ValidateStructure=function(t){if(null!==t&&(this.m_root,!t.IsLeaf())){var e=Xt(t.child1),i=Xt(t.child2);this.ValidateStructure(e),this.ValidateStructure(i)}},e.ValidateMetrics=function(e){if(null!==e&&!e.IsLeaf()){var i=Xt(e.child1),n=Xt(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=Xt(t.child1),n=Xt(t.child2);return O(e,D(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 Jt(t,e){return t=i)break;Kt(t,h,i)}}if(0===o)break;r=i,i=s[--o]}}(this.m_pairBuffer,0,this.m_pairCount,$t);for(var r=0;r_+d){e.state=t.b2TOIOutputState.e_separated,e.t=u,A=!0;break}if(x>_-d){f=b;break}var R=T.Evaluate(C[0],w[0],f);if(R<_-d){e.state=t.b2TOIOutputState.e_failed,e.t=f,A=!0;break}if(R<=_+d){e.state=t.b2TOIOutputState.e_touching,e.t=f,A=!0;break}for(var I=0,B=f,P=b;;){var M;M=1&I?B+(_-R)*(P-B)/(x-R):.5*(B+P),++I,++t.b2_toiRootIters;var L=T.Evaluate(C[0],w[0],M);if(D(L-_)_?(B=M,R=L):(P=M,x=L),50===I)break}if(t.b2_toiMaxRootIters=O(t.b2_toiMaxRootIters,I),++E===o)break}if(++p,++t.b2_toiIters,A)break;if(20===p){e.state=t.b2TOIOutputState.e_failed,e.t=f;break}}t.b2_toiMaxIters=O(t.b2_toiMaxIters,p);var N=n.GetMilliseconds();t.b2_toiMaxTime=O(t.b2_toiMaxTime,N),t.b2_toiTime+=N}var Ae=new j,be=new j;function Ee(e,i,n,r,s){e.pointCount=0;var o=Q.MulXV(n,i.m_p,Ae),a=Q.MulXV(s,r.m_p,be),h=j.DistanceSquaredVV(o,a),u=i.m_radius+r.m_radius;h>u*u||(e.type=t.b2ManifoldType.e_circles,e.localPoint.Copy(i.m_p),e.localNormal.SetZero(),e.pointCount=1,e.points[0].localPoint.Copy(r.m_p),e.points[0].id.key=0)}var Ce=new j,we=new j,xe=new j;function Re(e,n,s,o,a){e.pointCount=0;for(var h=Q.MulXV(a,o.m_p,Ce),u=Q.MulTXV(s,h,we),l=0,c=-i,_=n.m_radius+o.m_radius,d=n.m_count,f=n.m_vertices,p=n.m_normals,m=0;m_)return;g>c&&(c=g,l=m)}var y=l,v=(y+1)%d,S=f[y],T=f[v];if(c_*_)return;e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,j.SubVV(u,S,e.localNormal).SelfNormalize(),e.localPoint.Copy(S),e.points[0].localPoint.Copy(o.m_p),e.points[0].id.key=0}else if(b<=0){if(j.DistanceSquaredVV(u,T)>_*_)return;e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,j.SubVV(u,T,e.localNormal).SelfNormalize(),e.localPoint.Copy(T),e.points[0].localPoint.Copy(o.m_p),e.points[0].id.key=0}else{var E=j.MidVV(S,T,xe);if(j.DotVV(j.SubVV(u,E,j.s_t1),p[y])>_)return;e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,e.localNormal.Copy(p[y]).SelfNormalize(),e.localPoint.Copy(E),e.points[0].localPoint.Copy(o.m_p),e.points[0].id.key=0}}var Ie=new j,Be=new j,De=new j,Pe=new j;function Oe(t,e,n,r,s){for(var o=t.m_vertices,a=t.m_normals,h=r.m_count,u=r.m_vertices,l=J.MulRV(e.q,a[n],Ie),c=J.MulTRV(s.q,l,Be),_=0,d=i,f=0;fc&&(c=d,l=_)}var f=Oe(e,n,l,r,s),p=(l+o-1)%o,m=Oe(e,n,p,r,s),g=(l+1)%o,y=Oe(e,n,g,r,s),v=0,S=0,T=0;if(m>f&&m>y)T=-1,v=p,S=m;else{if(!(y>f))return t[0]=l,f;T=1,v=g,S=y}for(;(f=Oe(e,n,l=-1===T?(v+o-1)%o:(v+1)%o,r,s))>S;)v=l,S=f;return t[0]=v,S}var Fe=new j;var ke=Nt.MakeArray(2),Ve=Nt.MakeArray(2),Ge=Nt.MakeArray(2),Ue=[0],ze=[0],He=new j,We=new j,je=new j,Xe=new j,qe=new j,Ye=new j,Ke=new j,Je=new j;function Qe(e,n,r,s,o){e.pointCount=0;var a=n.m_radius+s.m_radius,h=Ue;h[0]=0;var u=Ne(h,n,r,s,o);if(!(u>a)){var l=ze;l[0]=0;var c=Ne(l,s,o,n,r);if(!(c>a)){var _,d,f,p,m=0,g=0;c>.98*u+.001?(_=s,d=n,f=o,p=r,m=l[0],e.type=t.b2ManifoldType.e_faceB,g=1):(_=n,d=s,f=r,p=o,m=h[0],e.type=t.b2ManifoldType.e_faceA,g=0);var y=ke;!function(e,n,r,s,o,a){for(var h=n.m_normals,u=o.m_count,l=o.m_vertices,c=o.m_normals,_=J.MulTRV(a.q,J.MulRV(r.q,h[s],j.s_t0),Fe),d=0,f=i,p=0;p_*_)return;if(i.m_hasVertex0){var m=i.m_vertex0,g=a,y=j.SubVV(g,m,ii);if(j.DotVV(y,j.SubVV(g,o,j.s_t0))>0)return}return d.cf.indexA=0,d.cf.typeA=t.b2ContactFeatureType.e_vertex,e.pointCount=1,e.type=t.b2ManifoldType.e_circles,e.localNormal.SetZero(),e.localPoint.Copy(f),e.points[0].id.Copy(d),void e.points[0].localPoint.Copy(r.m_p)}if(l<=0){var v=h,S=j.SubVV(o,v,ei);if(j.DotVV(S,S)>_*_)return;if(i.m_hasVertex3){var T=i.m_vertex3,A=h,b=j.SubVV(T,A,ni);if(j.DotVV(b,j.SubVV(o,A,j.s_t0))>0)return}return d.cf.indexA=1,d.cf.typeA=t.b2ContactFeatureType.e_vertex,e.pointCount=1,e.type=t.b2ManifoldType.e_circles,e.localNormal.SetZero(),e.localPoint.Copy(v),e.points[0].id.Copy(d),void e.points[0].localPoint.Copy(r.m_p)}var E=j.DotVV(u,u),C=ri;C.x=1/E*(l*a.x+c*h.x),C.y=1/E*(l*a.y+c*h.y);var w=j.SubVV(o,C,ei);if(!(j.DotVV(w,w)>_*_)){var x=si.Set(-u.y,u.x);j.DotVV(x,j.SubVV(o,a,j.s_t0))<0&&x.Set(-x.x,-x.y),x.Normalize(),d.cf.indexA=0,d.cf.typeA=t.b2ContactFeatureType.e_face,e.pointCount=1,e.type=t.b2ManifoldType.e_faceA,e.localNormal.Copy(x),e.localPoint.Copy(a),e.points[0].id.Copy(d),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"}(Ze||(Ze={}));var hi,ui=function(){this.type=Ze.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 Q,this.m_centroidB=new j,this.m_v0=new j,this.m_v1=new j,this.m_v2=new j,this.m_v3=new j,this.m_normal0=new j,this.m_normal1=new j,this.m_normal2=new j,this.m_normal=new j,this.m_type1=hi.e_isolated,this.m_type2=hi.e_isolated,this.m_lowerLimit=new j,this.m_upperLimit=new j,this.m_radius=0,this.m_front=!1}var n=e.prototype;return n.Collide=function(i,n,r,s,o){Q.MulTXX(r,o,this.m_xf),Q.MulXV(this.m_xf,s.m_centroid,this.m_centroidB),this.m_v0.Copy(n.m_vertex0),this.m_v1.Copy(n.m_vertex1),this.m_v2.Copy(n.m_vertex2),this.m_v3.Copy(n.m_vertex3);var a=n.m_hasVertex0,h=n.m_hasVertex3,u=j.SubVV(this.m_v2,this.m_v1,e.s_edge1);u.Normalize(),this.m_normal1.Set(u.y,-u.x);var l=j.DotVV(this.m_normal1,j.SubVV(this.m_centroidB,this.m_v1,j.s_t0)),c=0,_=0,d=!1,f=!1;if(a){var p=j.SubVV(this.m_v1,this.m_v0,e.s_edge0);p.Normalize(),this.m_normal0.Set(p.y,-p.x),d=j.CrossVV(p,u)>=0,c=j.DotVV(this.m_normal0,j.SubVV(this.m_centroidB,this.m_v0,j.s_t0))}if(h){var m=j.SubVV(this.m_v3,this.m_v2,e.s_edge2);m.Normalize(),this.m_normal2.Set(m.y,-m.x),f=j.CrossVV(u,m)>0,_=j.DotVV(this.m_normal2,j.SubVV(this.m_centroidB,this.m_v2,j.s_t0))}a&&h?d&&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_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())):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_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())):f?(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())):a?d?(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?f?(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 v=this.ComputePolygonSeparation(e.s_polygonAxis);if(!(v.type!==Ze.e_unknown&&v.separation>this.m_radius)){var S;S=v.type===Ze.e_unknown?y:v.separation>.98*y.separation+.001?v:y;var T=e.s_ie,A=e.s_rf;if(S.type===Ze.e_edgeA){i.type=t.b2ManifoldType.e_faceA;for(var b=0,E=j.DotVV(this.m_normal,this.m_polygonB.normals[0]),C=1;Cthis.m_radius)return n.type=Ze.e_edgeB,n.index=s,n.separation=a,n;if(j.DotVV(o,r)>=0){if(j.DotVV(j.SubVV(o,this.m_upperLimit,j.s_t0),this.m_normal)<-c)continue}else if(j.DotVV(j.SubVV(o,this.m_lowerLimit,j.s_t0),this.m_normal)<-c)continue;a>n.separation&&(n.type=Ze.e_edgeB,n.index=s,n.separation=a)}return n},e}();ci.s_edge1=new j,ci.s_edge0=new j,ci.s_edge2=new j,ci.s_ie=Nt.MakeArray(2),ci.s_rf=new function(){this.i1=0,this.i2=0,this.v1=new j,this.v2=new j,this.normal=new j,this.sideNormal1=new j,this.sideOffset1=0,this.sideNormal2=new j,this.sideOffset2=0},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 j,ci.s_perp=new j;var _i=new ci;function di(t,e,i,n,r){_i.Collide(t,e,i,n,r)}var fi,pi=function(){this.mass=0,this.center=new j(0,0),this.I=0};(fi=t.b2ShapeType||(t.b2ShapeType={}))[fi.e_unknown=-1]="e_unknown",fi[fi.e_circleShape=0]="e_circleShape",fi[fi.e_edgeShape=1]="e_edgeShape",fi[fi.e_polygonShape=2]="e_polygonShape",fi[fi.e_chainShape=3]="e_chainShape",fi[fi.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 j,n}s(i,e);var n=i.prototype;return n.Set=function(t,e){return void 0===e&&(e=this.m_radius),this.m_p.Copy(t),this.m_radius=e,this},n.Clone=function(){return(new i).Copy(this)},n.Copy=function(t){return e.prototype.Copy.call(this,t),this.m_p.Copy(t.m_p),this},n.GetChildCount=function(){return 1},n.TestPoint=function(t,e){var n=Q.MulXV(t,this.m_p,i.TestPoint_s_center),r=j.SubVV(e,n,i.TestPoint_s_d);return j.DotVV(r,r)<=N(this.m_radius)},n.ComputeDistance=function(t,e,n){var r=Q.MulXV(t,this.m_p,i.ComputeDistance_s_center);return j.SubVV(e,r,n),n.Normalize()-this.m_radius},n.RayCast=function(t,e,n){var s=Q.MulXV(n,this.m_p,i.RayCast_s_position),o=j.SubVV(e.p1,s,i.RayCast_s_s),a=j.DotVV(o,o)-N(this.m_radius),h=j.SubVV(e.p2,e.p1,i.RayCast_s_r),u=j.DotVV(o,h),l=j.DotVV(h,h),c=u*u-l*a;if(c<0||lthis.m_radius)return n.Copy(s),a*this.m_radius*this.m_radius;var h=this.m_radius*this.m_radius,u=o*o,l=h*(H(o/this.m_radius)+a/2)+o*k(h-u),c=-2/3*V(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 j,gi.TestPoint_s_d=new j,gi.ComputeDistance_s_center=new j,gi.RayCast_s_position=new j,gi.RayCast_s_s=new j,gi.RayCast_s_r=new j,gi.ComputeAABB_s_p=new j;var yi=function(e){function n(){var i;return(i=e.call(this,t.b2ShapeType.e_polygonShape,_)||this).m_centroid=new j(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=j.MakeArray(this.m_count),this.m_normals=j.MakeArray(this.m_count);for(var i=0;il||_===l&&r[c].yy.LengthSquared()&&(m=g)}else m=g;if(++f,p=m,m===u)break}this.m_count=f,this.m_vertices=j.MakeArray(this.m_count),this.m_normals=j.MakeArray(this.m_count);for(var T=0;T0)return!1;return!0},r.ComputeDistance=function(t,e,r){for(var s=Q.MulTXV(t,e,n.ComputeDistance_s_pLocal),o=-i,a=n.ComputeDistance_s_normalForMaxDistance.Copy(s),h=0;ho&&(o=u,a.Copy(this.m_normals[h]))}if(o>0){for(var l=n.ComputeDistance_s_minDistance.Copy(a),c=o*o,_=0;_f&&(l.Copy(d),c=f)}return J.MulRV(t.q,l,r),r.Normalize(),Math.sqrt(c)}return J.MulRV(t.q,a,r),o},r.RayCast=function(t,e,i){for(var r=Q.MulTXV(i,e.p1,n.RayCast_s_p1),s=Q.MulTXV(i,e.p2,n.RayCast_s_p2),o=j.SubVV(s,r,n.RayCast_s_d),a=0,h=e.maxFraction,u=-1,l=0;l0&&c=0&&(t.fraction=a,J.MulRV(i.q,this.m_normals[u],t.normal),!0)},r.ComputeAABB=function(t,e){for(var i=Q.MulXV(e,this.m_vertices[0],t.lowerBound),r=t.upperBound.Copy(i),s=0;s0&&(d?c||(u=_-1,h++):c&&(l=_-1,h++)),c=d}switch(h){case 0:if(c){var f=n.ComputeSubmergedArea_s_md;return this.ComputeMass(f,1),Q.MulXV(i,f.center,r),f.mass}return 0;case 1:-1===u?u=this.m_count-1:l=this.m_count-1}for(var p,m=(u+1)%this.m_count,g=(l+1)%this.m_count,y=(0-a[u])/(a[m]-a[u]),v=(0-a[l])/(a[g]-a[l]),S=n.ComputeSubmergedArea_s_intoVec.Set(this.m_vertices[u].x*(1-y)+this.m_vertices[m].x*y,this.m_vertices[u].y*(1-y)+this.m_vertices[m].y*y),T=n.ComputeSubmergedArea_s_outoVec.Set(this.m_vertices[l].x*(1-v)+this.m_vertices[g].x*v,this.m_vertices[l].y*(1-v)+this.m_vertices[g].y*v),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 w=.5*((E.x-S.x)*(p.y-S.y)-(E.y-S.y)*(p.x-S.x));A+=w,b.x+=w*(S.x+E.x+p.x)/3,b.y+=w*(S.y+E.y+p.y)/3,E=p}return b.SelfMul(1/A),Q.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=j.DotVV(a,a);h>u?j.SubVV(e,s,o):o.SelfMulSub(h/u,a)}return n.Copy(o),n.Normalize()},n.RayCast=function(t,e,n){var r=Q.MulTXV(n,e.p1,i.RayCast_s_p1),s=Q.MulTXV(n,e.p2,i.RayCast_s_p2),o=j.SubVV(s,r,i.RayCast_s_d),a=this.m_vertex1,h=this.m_vertex2,u=j.SubVV(h,a,i.RayCast_s_e),l=t.normal.Set(u.y,-u.x).SelfNormalize(),c=j.DotVV(l,j.SubVV(a,r,j.s_t0)),_=j.DotVV(l,o);if(0===_)return!1;var d=c/_;if(d<0||e.maxFraction0&&t.normal.SelfNeg(),0))},n.ComputeAABB=function(t,e){var n=Q.MulXV(e,this.m_vertex1,i.ComputeAABB_s_v1),r=Q.MulXV(e,this.m_vertex2,i.ComputeAABB_s_v2);j.MinV(n,r,t.lowerBound),j.MaxV(n,r,t.upperBound);var s=this.m_radius;t.lowerBound.SelfSubXY(s,s),t.upperBound.SelfAddXY(s,s)},n.ComputeMass=function(t){t.mass=0,j.MidVV(this.m_vertex1,this.m_vertex2,t.center),t.I=0},n.SetupDistanceProxy=function(t){t.m_vertices=t.m_buffer,t.m_vertices[0].Copy(this.m_vertex1),t.m_vertices[1].Copy(this.m_vertex2),t.m_count=2,t.m_radius=this.m_radius},n.ComputeSubmergedArea=function(t,e,i,n){return n.SetZero(),0},n.Dump=function(t){t(" const shape: b2EdgeShape = new b2EdgeShape();\n"),t(" shape.m_radius = %.15f;\n",this.m_radius),t(" shape.m_vertex0.Set(%.15f, %.15f);\n",this.m_vertex0.x,this.m_vertex0.y),t(" shape.m_vertex1.Set(%.15f, %.15f);\n",this.m_vertex1.x,this.m_vertex1.y),t(" shape.m_vertex2.Set(%.15f, %.15f);\n",this.m_vertex2.x,this.m_vertex2.y),t(" shape.m_vertex3.Set(%.15f, %.15f);\n",this.m_vertex3.x,this.m_vertex3.y),t(" shape.m_hasVertex0 = %s;\n",this.m_hasVertex0),t(" shape.m_hasVertex3 = %s;\n",this.m_hasVertex3)},i}(mi);vi.ComputeDistance_s_v1=new j,vi.ComputeDistance_s_v2=new j,vi.ComputeDistance_s_d=new j,vi.ComputeDistance_s_s=new j,vi.RayCast_s_p1=new j,vi.RayCast_s_p2=new j,vi.RayCast_s_d=new j,vi.RayCast_s_e=new j,vi.RayCast_s_q=new j,vi.RayCast_s_r=new j,vi.ComputeAABB_s_v1=new j,vi.ComputeAABB_s_v2=new j;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 j,i.m_nextVertex=new j,i.m_hasPrevVertex=!1,i.m_hasNextVertex=!1,i}s(i,e);var n=i.prototype;return n.CreateLoop=function(){for(var t=arguments.length,e=new Array(t),i=0;i0?(t.m_vertex0.Copy(this.m_vertices[e-1]),t.m_hasVertex0=!0):(t.m_vertex0.Copy(this.m_prevVertex),t.m_hasVertex0=this.m_hasPrevVertex),e0&&this.ResetMassData(),this.m_world.m_newFixture=!0,e},n.CreateFixtureShapeDensity=function(t,e){void 0===e&&(e=0);var n=i.CreateFixtureShapeDensity_s_def;return n.shape=t,n.density=e,this.CreateFixtureDef(n)},n.DestroyFixture=function(t){if(this.m_world.IsLocked())throw new Error;for(var e=this.m_fixtureList,i=null;null!==e;){if(e===t){i?i.m_next=t.m_next:this.m_fixtureList=t.m_next;break}i=e,e=e.m_next}for(var n=this.m_contactList;n;){var r=n.contact;n=n.next;var s=r.GetFixtureA(),o=r.GetFixtureB();t!==s&&t!==o||this.m_world.m_contactManager.Destroy(r)}this.m_activeFlag&&t.DestroyProxies(),t.m_next=null,t.Reset(),--this.m_fixtureCount,this.ResetMassData()},n.SetTransformVec=function(t,e){this.SetTransformXY(t.x,t.y,e)},n.SetTransformXY=function(t,e,i){if(this.m_world.IsLocked())throw new Error;this.m_xf.q.SetAngle(i),this.m_xf.p.Set(t,e),this.m_xf0.Copy(this.m_xf),Q.MulXV(this.m_xf,this.m_sweep.localCenter,this.m_sweep.c),this.m_sweep.a=i,this.m_sweep.c0.Copy(this.m_sweep.c),this.m_sweep.a0=i;for(var n=this.m_fixtureList;n;n=n.m_next)n.SynchronizeProxies(this.m_xf,this.m_xf,j.ZERO);this.m_world.m_contactManager.FindNewContacts()},n.SetTransform=function(t){this.SetTransformVec(t.p,t.GetAngle())},n.GetTransform=function(){return this.m_xf},n.GetPosition=function(){return this.m_xf.p},n.SetPosition=function(t){this.SetTransformVec(t,this.GetAngle())},n.SetPositionXY=function(t,e){this.SetTransformXY(t,e,this.GetAngle())},n.GetAngle=function(){return this.m_sweep.a},n.SetAngle=function(t){this.SetTransformVec(this.GetPosition(),t)},n.GetWorldCenter=function(){return this.m_sweep.c},n.GetLocalCenter=function(){return this.m_sweep.localCenter},n.SetLinearVelocity=function(e){this.m_type!==t.b2BodyType.b2_staticBody&&(j.DotVV(e,e)>0&&this.SetAwake(!0),this.m_linearVelocity.Copy(e))},n.GetLinearVelocity=function(){return this.m_linearVelocity},n.SetAngularVelocity=function(e){this.m_type!==t.b2BodyType.b2_staticBody&&(e*e>0&&this.SetAwake(!0),this.m_angularVelocity=e)},n.GetAngularVelocity=function(){return this.m_angularVelocity},n.GetDefinition=function(t){return t.type=this.GetType(),t.allowSleep=this.m_autoSleepFlag,t.angle=this.GetAngle(),t.angularDamping=this.m_angularDamping,t.gravityScale=this.m_gravityScale,t.angularVelocity=this.m_angularVelocity,t.fixedRotation=this.m_fixedRotationFlag,t.bullet=this.m_bulletFlag,t.awake=this.m_awakeFlag,t.linearDamping=this.m_linearDamping,t.linearVelocity.Copy(this.GetLinearVelocity()),t.position.Copy(this.GetPosition()),t.userData=this.GetUserData(),t},n.ApplyForce=function(e,i,n){void 0===n&&(n=!0),this.m_type===t.b2BodyType.b2_dynamicBody&&(n&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_force.x+=e.x,this.m_force.y+=e.y,this.m_torque+=(i.x-this.m_sweep.c.x)*e.y-(i.y-this.m_sweep.c.y)*e.x))},n.ApplyForceToCenter=function(e,i){void 0===i&&(i=!0),this.m_type===t.b2BodyType.b2_dynamicBody&&(i&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_force.x+=e.x,this.m_force.y+=e.y))},n.ApplyTorque=function(e,i){void 0===i&&(i=!0),this.m_type===t.b2BodyType.b2_dynamicBody&&(i&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_torque+=e))},n.ApplyLinearImpulse=function(e,i,n){void 0===n&&(n=!0),this.m_type===t.b2BodyType.b2_dynamicBody&&(n&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_linearVelocity.x+=this.m_invMass*e.x,this.m_linearVelocity.y+=this.m_invMass*e.y,this.m_angularVelocity+=this.m_invI*((i.x-this.m_sweep.c.x)*e.y-(i.y-this.m_sweep.c.y)*e.x)))},n.ApplyLinearImpulseToCenter=function(e,i){void 0===i&&(i=!0),this.m_type===t.b2BodyType.b2_dynamicBody&&(i&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_linearVelocity.x+=this.m_invMass*e.x,this.m_linearVelocity.y+=this.m_invMass*e.y))},n.ApplyAngularImpulse=function(e,i){void 0===i&&(i=!0),this.m_type===t.b2BodyType.b2_dynamicBody&&(i&&!this.m_awakeFlag&&this.SetAwake(!0),this.m_awakeFlag&&(this.m_angularVelocity+=this.m_invI*e))},n.GetMass=function(){return this.m_mass},n.GetInertia=function(){return this.m_I+this.m_mass*j.DotVV(this.m_sweep.localCenter,this.m_sweep.localCenter)},n.GetMassData=function(t){return t.mass=this.m_mass,t.I=this.m_I+this.m_mass*j.DotVV(this.m_sweep.localCenter,this.m_sweep.localCenter),t.center.Copy(this.m_sweep.localCenter),t},n.SetMassData=function(e){if(this.m_world.IsLocked())throw new Error;if(this.m_type===t.b2BodyType.b2_dynamicBody){this.m_invMass=0,this.m_I=0,this.m_invI=0,this.m_mass=e.mass,this.m_mass<=0&&(this.m_mass=1),this.m_invMass=1/this.m_mass,e.I>0&&!this.m_fixedRotationFlag&&(this.m_I=e.I-this.m_mass*j.DotVV(e.center,e.center),this.m_invI=1/this.m_I);var n=i.SetMassData_s_oldCenter.Copy(this.m_sweep.c);this.m_sweep.localCenter.Copy(e.center),Q.MulXV(this.m_xf,this.m_sweep.localCenter,this.m_sweep.c),this.m_sweep.c0.Copy(this.m_sweep.c),j.AddVCrossSV(this.m_linearVelocity,this.m_angularVelocity,j.SubVV(this.m_sweep.c,n,j.s_t0),this.m_linearVelocity)}},n.ResetMassData=function(){if(this.m_mass=0,this.m_invMass=0,this.m_I=0,this.m_invI=0,this.m_sweep.localCenter.SetZero(),this.m_type===t.b2BodyType.b2_staticBody||this.m_type===t.b2BodyType.b2_kinematicBody)return this.m_sweep.c0.Copy(this.m_xf.p),this.m_sweep.c.Copy(this.m_xf.p),void(this.m_sweep.a0=this.m_sweep.a);for(var e=i.ResetMassData_s_localCenter.SetZero(),n=this.m_fixtureList;n;n=n.m_next)if(0!==n.m_density){var r=n.GetMassData(i.ResetMassData_s_massData);this.m_mass+=r.mass,e.x+=r.center.x*r.mass,e.y+=r.center.y*r.mass,this.m_I+=r.I}this.m_mass>0?(this.m_invMass=1/this.m_mass,e.x*=this.m_invMass,e.y*=this.m_invMass):(this.m_mass=1,this.m_invMass=1),this.m_I>0&&!this.m_fixedRotationFlag?(this.m_I-=this.m_mass*j.DotVV(e,e),this.m_invI=1/this.m_I):(this.m_I=0,this.m_invI=0);var s=i.ResetMassData_s_oldCenter.Copy(this.m_sweep.c);this.m_sweep.localCenter.Copy(e),Q.MulXV(this.m_xf,this.m_sweep.localCenter,this.m_sweep.c),this.m_sweep.c0.Copy(this.m_sweep.c),j.AddVCrossSV(this.m_linearVelocity,this.m_angularVelocity,j.SubVV(this.m_sweep.c,s,j.s_t0),this.m_linearVelocity)},n.GetWorldPoint=function(t,e){return Q.MulXV(this.m_xf,t,e)},n.GetWorldVector=function(t,e){return J.MulRV(this.m_xf.q,t,e)},n.GetLocalPoint=function(t,e){return Q.MulTXV(this.m_xf,t,e)},n.GetLocalVector=function(t,e){return J.MulTRV(this.m_xf.q,t,e)},n.GetLinearVelocityFromWorldPoint=function(t,e){return j.AddVCrossSV(this.m_linearVelocity,this.m_angularVelocity,j.SubVV(t,this.m_sweep.c,j.s_t0),e)},n.GetLinearVelocityFromLocalPoint=function(t,e){return this.GetLinearVelocityFromWorldPoint(this.GetWorldPoint(t,e),e)},n.GetLinearDamping=function(){return this.m_linearDamping},n.SetLinearDamping=function(t){this.m_linearDamping=t},n.GetAngularDamping=function(){return this.m_angularDamping},n.SetAngularDamping=function(t){this.m_angularDamping=t},n.GetGravityScale=function(){return this.m_gravityScale},n.SetGravityScale=function(t){this.m_gravityScale=t},n.SetType=function(e){if(this.m_world.IsLocked())throw new Error;if(this.m_type!==e){this.m_type=e,this.ResetMassData(),this.m_type===t.b2BodyType.b2_staticBody&&(this.m_linearVelocity.SetZero(),this.m_angularVelocity=0,this.m_sweep.a0=this.m_sweep.a,this.m_sweep.c0.Copy(this.m_sweep.c),this.SynchronizeFixtures()),this.SetAwake(!0),this.m_force.SetZero(),this.m_torque=0;for(var i=this.m_contactList;i;){var n=i;i=i.next,this.m_world.m_contactManager.Destroy(n.contact)}this.m_contactList=null;for(var r=this.m_fixtureList;r;r=r.m_next)r.TouchProxies()}},n.GetType=function(){return this.m_type},n.SetBullet=function(t){this.m_bulletFlag=t},n.IsBullet=function(){return this.m_bulletFlag},n.SetSleepingAllowed=function(t){this.m_autoSleepFlag=t,t||this.SetAwake(!0)},n.IsSleepingAllowed=function(){return this.m_autoSleepFlag},n.SetAwake=function(t){t?(this.m_awakeFlag=!0,this.m_sleepTime=0):(this.m_awakeFlag=!1,this.m_sleepTime=0,this.m_linearVelocity.SetZero(),this.m_angularVelocity=0,this.m_force.SetZero(),this.m_torque=0)},n.IsAwake=function(){return this.m_awakeFlag},n.SetActive=function(t){if(this.m_world.IsLocked())throw new Error;if(t!==this.IsActive())if(this.m_activeFlag=t,t)for(var e=this.m_fixtureList;e;e=e.m_next)e.CreateProxies();else{for(var i=this.m_fixtureList;i;i=i.m_next)i.DestroyProxies();for(var n=this.m_contactList;n;){var r=n;n=n.next,this.m_world.m_contactManager.Destroy(r.contact)}this.m_contactList=null}},n.IsActive=function(){return this.m_activeFlag},n.SetFixedRotation=function(t){this.m_fixedRotationFlag!==t&&(this.m_fixedRotationFlag=t,this.m_angularVelocity=0,this.ResetMassData())},n.IsFixedRotation=function(){return this.m_fixedRotationFlag},n.GetFixtureList=function(){return this.m_fixtureList},n.GetJointList=function(){return this.m_jointList},n.GetContactList=function(){return this.m_contactList},n.GetNext=function(){return this.m_next},n.GetUserData=function(){return this.m_userData},n.SetUserData=function(t){this.m_userData=t},n.GetWorld=function(){return this.m_world},n.Dump=function(e){var i=this.m_islandIndex;e("{\n"),e(" const bd: b2BodyDef = new b2BodyDef();\n");var n="";switch(this.m_type){case t.b2BodyType.b2_staticBody:n="b2BodyType.b2_staticBody";break;case t.b2BodyType.b2_kinematicBody:n="b2BodyType.b2_kinematicBody";break;case t.b2BodyType.b2_dynamicBody:n="b2BodyType.b2_dynamicBody"}e(" bd.type = %s;\n",n),e(" bd.position.Set(%.15f, %.15f);\n",this.m_xf.p.x,this.m_xf.p.y),e(" bd.angle = %.15f;\n",this.m_sweep.a),e(" bd.linearVelocity.Set(%.15f, %.15f);\n",this.m_linearVelocity.x,this.m_linearVelocity.y),e(" bd.angularVelocity = %.15f;\n",this.m_angularVelocity),e(" bd.linearDamping = %.15f;\n",this.m_linearDamping),e(" bd.angularDamping = %.15f;\n",this.m_angularDamping),e(" bd.allowSleep = %s;\n",this.m_autoSleepFlag?"true":"false"),e(" bd.awake = %s;\n",this.m_awakeFlag?"true":"false"),e(" bd.fixedRotation = %s;\n",this.m_fixedRotationFlag?"true":"false"),e(" bd.bullet = %s;\n",this.m_bulletFlag?"true":"false"),e(" bd.active = %s;\n",this.m_activeFlag?"true":"false"),e(" bd.gravityScale = %.15f;\n",this.m_gravityScale),e("\n"),e(" bodies[%d] = this.m_world.CreateBody(bd);\n",this.m_islandIndex),e("\n");for(var r=this.m_fixtureList;r;r=r.m_next)e(" {\n"),r.Dump(e,i),e(" }\n");e("}\n")},n.SynchronizeFixtures=function(){var t=i.SynchronizeFixtures_s_xf1;t.q.SetAngle(this.m_sweep.a0),J.MulRV(t.q,this.m_sweep.localCenter,t.p),j.SubVV(this.m_sweep.c0,t.p,t.p);for(var e=j.SubVV(this.m_sweep.c,this.m_sweep.c0,i.SynchronizeFixtures_s_displacement),n=this.m_fixtureList;n;n=n.m_next)n.SynchronizeProxies(t,this.m_xf,e)},n.SynchronizeTransform=function(){this.m_xf.q.SetAngle(this.m_sweep.a),J.MulRV(this.m_xf.q,this.m_sweep.localCenter,this.m_xf.p),j.SubVV(this.m_sweep.c,this.m_xf.p,this.m_xf.p)},n.ShouldCollide=function(e){return(this.m_type!==t.b2BodyType.b2_staticBody||e.m_type!==t.b2BodyType.b2_staticBody)&&this.ShouldCollideConnected(e)},n.ShouldCollideConnected=function(t){for(var e=this.m_jointList;e;e=e.next)if(e.other===t&&!e.joint.m_collideConnected)return!1;return!0},n.Advance=function(t){this.m_sweep.Advance(t),this.m_sweep.c.Copy(this.m_sweep.c0),this.m_sweep.a=this.m_sweep.a0,this.m_xf.q.SetAngle(this.m_sweep.a),J.MulRV(this.m_xf.q,this.m_sweep.localCenter,this.m_xf.p),j.SubVV(this.m_sweep.c,this.m_xf.p,this.m_xf.p)},n.GetControllerList=function(){return this.m_controllerList},n.GetControllerCount=function(){return this.m_controllerCount},i}();Ri.CreateFixtureShapeDensity_s_def=new Ai,Ri.SetMassData_s_oldCenter=new j,Ri.ResetMassData_s_localCenter=new j,Ri.ResetMassData_s_oldCenter=new j,Ri.ResetMassData_s_massData=new pi,Ri.SynchronizeFixtures_s_xf1=new Q,Ri.SynchronizeFixtures_s_displacement=new j,(xi=t.b2JointType||(t.b2JointType={}))[xi.e_unknownJoint=0]="e_unknownJoint",xi[xi.e_revoluteJoint=1]="e_revoluteJoint",xi[xi.e_prismaticJoint=2]="e_prismaticJoint",xi[xi.e_distanceJoint=3]="e_distanceJoint",xi[xi.e_pulleyJoint=4]="e_pulleyJoint",xi[xi.e_mouseJoint=5]="e_mouseJoint",xi[xi.e_gearJoint=6]="e_gearJoint",xi[xi.e_wheelJoint=7]="e_wheelJoint",xi[xi.e_weldJoint=8]="e_weldJoint",xi[xi.e_frictionJoint=9]="e_frictionJoint",xi[xi.e_ropeJoint=10]="e_ropeJoint",xi[xi.e_motorJoint=11]="e_motorJoint",xi[xi.e_areaJoint=12]="e_areaJoint",(wi=t.b2LimitState||(t.b2LimitState={}))[wi.e_inactiveLimit=0]="e_inactiveLimit",wi[wi.e_atLowerLimit=1]="e_atLowerLimit",wi[wi.e_atUpperLimit=2]="e_atUpperLimit",wi[wi.e_equalLimits=3]="e_equalLimits";var Ii=function(){function t(){this.linear=new j,this.angularA=0,this.angularB=0}var e=t.prototype;return e.SetZero=function(){return this.linear.SetZero(),this.angularA=0,this.angularB=0,this},e.Set=function(t,e,i){return this.linear.Copy(t),this.angularA=e,this.angularB=i,this},t}(),Bi=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}(),Di=function(e){this.type=t.b2JointType.e_unknownJoint,this.userData=null,this.collideConnected=!1,this.type=e},Pi=function(){function i(i){this.m_type=t.b2JointType.e_unknownJoint,this.m_prev=null,this.m_next=null,this.m_edgeA=new Bi(this),this.m_edgeB=new Bi(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}(),Oi=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_distanceJoint)||this).localAnchorA=new j,i.localAnchorB=new j,i.length=1,i.frequencyHz=0,i.dampingRatio=0,i}return s(i,e),i.prototype.Initialize=function(t,e,i,n){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(i,this.localAnchorA),this.bodyB.GetLocalPoint(n,this.localAnchorB),this.length=j.DistanceVV(i,n),this.frequencyHz=0,this.dampingRatio=0},i}(Di),Mi=function(t){function i(i){var n;return(n=t.call(this,i)||this).m_frequencyHz=0,n.m_dampingRatio=0,n.m_bias=0,n.m_localAnchorA=new j,n.m_localAnchorB=new j,n.m_gamma=0,n.m_impulse=0,n.m_length=0,n.m_indexA=0,n.m_indexB=0,n.m_u=new j,n.m_rA=new j,n.m_rB=new j,n.m_localCenterA=new j,n.m_localCenterB=new j,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_mass=0,n.m_qA=new J,n.m_qB=new J,n.m_lalcA=new j,n.m_lalcB=new j,n.m_frequencyHz=e(i.frequencyHz,0),n.m_dampingRatio=e(i.dampingRatio,0),n.m_localAnchorA.Copy(i.localAnchorA),n.m_localAnchorB.Copy(i.localAnchorB),n.m_length=i.length,n}s(i,t);var n=i.prototype;return n.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},n.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},n.GetReactionForce=function(t,e){return e.x=t*this.m_impulse*this.m_u.x,e.y=t*this.m_impulse*this.m_u.y,e},n.GetReactionTorque=function(){return 0},n.GetLocalAnchorA=function(){return this.m_localAnchorA},n.GetLocalAnchorB=function(){return this.m_localAnchorB},n.SetLength=function(t){this.m_length=t},n.Length=function(){return this.m_length},n.SetFrequency=function(t){this.m_frequencyHz=t},n.GetFrequency=function(){return this.m_frequencyHz},n.SetDampingRatio=function(t){this.m_dampingRatio=t},n.GetDampingRatio=function(){return this.m_dampingRatio},n.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2DistanceJointDef = new b2DistanceJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.length = %.15f;\n",this.m_length),t(" jd.frequencyHz = %.15f;\n",this.m_frequencyHz),t(" jd.dampingRatio = %.15f;\n",this.m_dampingRatio),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},n.InitVelocityConstraints=function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,r=t.velocities[this.m_indexA].v,s=t.velocities[this.m_indexA].w,o=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),d=this.m_qB.SetAngle(h);j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA),J.MulRV(_,this.m_lalcA,this.m_rA),j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),J.MulRV(d,this.m_lalcB,this.m_rB),this.m_u.x=o.x+this.m_rB.x-e.x-this.m_rA.x,this.m_u.y=o.y+this.m_rB.y-e.y-this.m_rA.y;var f=this.m_u.Length();f>l?this.m_u.SelfMul(1/f):this.m_u.SetZero();var p=j.CrossVV(this.m_rA,this.m_u),m=j.CrossVV(this.m_rB,this.m_u),g=this.m_invMassA+this.m_invIA*p*p+this.m_invMassB+this.m_invIB*m*m;if(this.m_mass=0!==g?1/g:0,this.m_frequencyHz>0){var y=f-this.m_length,v=2*a*this.m_frequencyHz,S=2*this.m_mass*this.m_dampingRatio*v,T=this.m_mass*v*v,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=y*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=j.MulSV(this.m_impulse,this.m_u,i.InitVelocityConstraints_s_P);r.SelfMulSub(this.m_invMassA,b),s-=this.m_invIA*j.CrossVV(this.m_rA,b),u.SelfMulAdd(this.m_invMassB,b),c+=this.m_invIB*j.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,o=j.AddVCrossSV(e,n,this.m_rA,i.SolveVelocityConstraints_s_vpA),a=j.AddVCrossSV(r,s,this.m_rB,i.SolveVelocityConstraints_s_vpB),h=j.DotVV(this.m_u,j.SubVV(a,o,j.s_t0)),u=-this.m_mass*(h+this.m_bias+this.m_gamma*this.m_impulse);this.m_impulse+=u;var l=j.MulSV(u,this.m_u,i.SolveVelocityConstraints_s_P);e.SelfMulSub(this.m_invMassA,l),n-=this.m_invIA*j.CrossVV(this.m_rA,l),r.SelfMulAdd(this.m_invMassB,l),s+=this.m_invIB*j.CrossVV(this.m_rB,l),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=s},n.SolvePositionConstraints=function(t){if(this.m_frequencyHz>0)return!0;var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,r=t.positions[this.m_indexB].c,s=t.positions[this.m_indexB].a,o=this.m_qA.SetAngle(n),a=this.m_qB.SetAngle(s),h=J.MulRV(o,this.m_lalcA,this.m_rA),u=J.MulRV(a,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;_=M(_,-.2,f);var d=-this.m_mass*_,p=j.MulSV(d,c,i.SolvePositionConstraints_s_P);return e.SelfMulSub(this.m_invMassA,p),n-=this.m_invIA*j.CrossVV(h,p),r.SelfMulAdd(this.m_invMassB,p),s+=this.m_invIB*j.CrossVV(u,p),t.positions[this.m_indexA].a=n,t.positions[this.m_indexB].a=s,D(_)N(f)&&v.SelfMul(f/k(S)),S>N(l)&&(d=!1),g.x+=v.x,g.y+=v.y}return d},i}(Pi),Fi=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_frictionJoint)||this).localAnchorA=new j,i.localAnchorB=new j,i.maxForce=0,i.maxTorque=0,i}return s(i,e),i.prototype.Initialize=function(t,e,i){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(i,this.localAnchorA),this.bodyB.GetLocalPoint(i,this.localAnchorB)},i}(Di),ki=function(t){function i(i){var n;return(n=t.call(this,i)||this).m_localAnchorA=new j,n.m_localAnchorB=new j,n.m_linearImpulse=new j,n.m_angularImpulse=0,n.m_maxForce=0,n.m_maxTorque=0,n.m_indexA=0,n.m_indexB=0,n.m_rA=new j,n.m_rB=new j,n.m_localCenterA=new j,n.m_localCenterB=new j,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_linearMass=new Y,n.m_angularMass=0,n.m_qA=new J,n.m_qB=new J,n.m_lalcA=new j,n.m_lalcB=new j,n.m_K=new Y,n.m_localAnchorA.Copy(i.localAnchorA),n.m_localAnchorB.Copy(i.localAnchorB),n.m_linearImpulse.SetZero(),n.m_maxForce=e(i.maxForce,0),n.m_maxTorque=e(i.maxTorque,0),n.m_linearMass.SetZero(),n}s(i,t);var n=i.prototype;return n.InitVelocityConstraints=function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].a,i=t.velocities[this.m_indexA].v,n=t.velocities[this.m_indexA].w,r=t.positions[this.m_indexB].a,s=t.velocities[this.m_indexB].v,o=t.velocities[this.m_indexB].w,a=this.m_qA.SetAngle(e),h=this.m_qB.SetAngle(r);j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var u=J.MulRV(a,this.m_lalcA,this.m_rA);j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var l=J.MulRV(h,this.m_lalcB,this.m_rB),c=this.m_invMassA,_=this.m_invMassB,d=this.m_invIA,f=this.m_invIB,p=this.m_K;if(p.ex.x=c+_+d*u.y*u.y+f*l.y*l.y,p.ex.y=-d*u.x*u.y-f*l.x*l.y,p.ey.x=p.ex.y,p.ey.y=c+_+d*u.x*u.x+f*l.x*l.x,p.GetInverse(this.m_linearMass),this.m_angularMass=d+f,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-=d*(j.CrossVV(this.m_rA,m)+this.m_angularImpulse),s.SelfMulAdd(_,m),o+=f*(j.CrossVV(this.m_rB,m)+this.m_angularImpulse)}else this.m_linearImpulse.SetZero(),this.m_angularImpulse=0;t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=o},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,o=this.m_invMassA,a=this.m_invMassB,h=this.m_invIA,u=this.m_invIB,l=t.step.dt,c=s-n,_=-this.m_angularMass*c,d=this.m_angularImpulse,f=l*this.m_maxTorque;this.m_angularImpulse=M(this.m_angularImpulse+_,-f,f),n-=h*(_=this.m_angularImpulse-d),s+=u*_;var p=j.SubVV(j.AddVCrossSV(r,s,this.m_rB,j.s_t0),j.AddVCrossSV(e,n,this.m_rA,j.s_t1),i.SolveVelocityConstraints_s_Cdot_v2),m=Y.MulMV(this.m_linearMass,p,i.SolveVelocityConstraints_s_impulseV).SelfNeg(),g=i.SolveVelocityConstraints_s_oldImpulseV.Copy(this.m_linearImpulse);this.m_linearImpulse.SelfAdd(m);var y=l*this.m_maxForce;this.m_linearImpulse.LengthSquared()>y*y&&(this.m_linearImpulse.Normalize(),this.m_linearImpulse.SelfMul(y)),j.SubVV(this.m_linearImpulse,g,m),e.SelfMulSub(o,m),n-=h*j.CrossVV(this.m_rA,m),r.SelfMulAdd(a,m),s+=u*j.CrossVV(this.m_rB,m),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=s},n.SolvePositionConstraints=function(){return!0},n.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},n.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},n.GetReactionForce=function(t,e){return e.x=t*this.m_linearImpulse.x,e.y=t*this.m_linearImpulse.y,e},n.GetReactionTorque=function(t){return t*this.m_angularImpulse},n.GetLocalAnchorA=function(){return this.m_localAnchorA},n.GetLocalAnchorB=function(){return this.m_localAnchorB},n.SetMaxForce=function(t){this.m_maxForce=t},n.GetMaxForce=function(){return this.m_maxForce},n.SetMaxTorque=function(t){this.m_maxTorque=t},n.GetMaxTorque=function(){return this.m_maxTorque},n.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2FrictionJointDef = new b2FrictionJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.maxForce = %.15f;\n",this.m_maxForce),t(" jd.maxTorque = %.15f;\n",this.m_maxTorque),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},i}(Pi);ki.SolveVelocityConstraints_s_Cdot_v2=new j,ki.SolveVelocityConstraints_s_impulseV=new j,ki.SolveVelocityConstraints_s_oldImpulseV=new j;var Vi=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_gearJoint)||this).ratio=1,i}return s(i,e),i}(Di),Gi=function(i){function n(n){var r,s,o;(r=i.call(this,n)||this).m_typeA=t.b2JointType.e_unknownJoint,r.m_typeB=t.b2JointType.e_unknownJoint,r.m_localAnchorA=new j,r.m_localAnchorB=new j,r.m_localAnchorC=new j,r.m_localAnchorD=new j,r.m_localAxisC=new j,r.m_localAxisD=new j,r.m_referenceAngleA=0,r.m_referenceAngleB=0,r.m_constant=0,r.m_ratio=0,r.m_impulse=0,r.m_indexA=0,r.m_indexB=0,r.m_indexC=0,r.m_indexD=0,r.m_lcA=new j,r.m_lcB=new j,r.m_lcC=new j,r.m_lcD=new j,r.m_mA=0,r.m_mB=0,r.m_mC=0,r.m_mD=0,r.m_iA=0,r.m_iB=0,r.m_iC=0,r.m_iD=0,r.m_JvAC=new j,r.m_JvBD=new j,r.m_JwA=0,r.m_JwB=0,r.m_JwC=0,r.m_JwD=0,r.m_mass=0,r.m_qA=new J,r.m_qB=new J,r.m_qC=new J,r.m_qD=new J,r.m_lalcA=new j,r.m_lalcB=new j,r.m_lalcC=new j,r.m_lalcD=new j,r.m_joint1=n.joint1,r.m_joint2=n.joint2,r.m_typeA=r.m_joint1.GetType(),r.m_typeB=r.m_joint2.GetType(),r.m_bodyC=r.m_joint1.GetBodyA(),r.m_bodyA=r.m_joint1.GetBodyB();var a=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 d=r.m_localAnchorC,f=J.MulTRV(u.q,j.AddVV(J.MulRV(a.q,r.m_localAnchorA,j.s_t0),j.SubVV(a.p,u.p,j.s_t1),j.s_t0),j.s_t0);s=j.DotVV(j.SubVV(f,d,j.s_t0),r.m_localAxisC)}r.m_bodyD=r.m_joint2.GetBodyA(),r.m_bodyB=r.m_joint2.GetBodyB();var p=r.m_bodyB.m_xf,m=r.m_bodyB.m_sweep.a,g=r.m_bodyD.m_xf,y=r.m_bodyD.m_sweep.a;if(r.m_typeB===t.b2JointType.e_revoluteJoint){var v=n.joint2;r.m_localAnchorD.Copy(v.m_localAnchorA),r.m_localAnchorB.Copy(v.m_localAnchorB),r.m_referenceAngleB=v.m_referenceAngle,r.m_localAxisD.SetZero(),o=m-y-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=J.MulTRV(g.q,j.AddVV(J.MulRV(p.q,r.m_localAnchorB,j.s_t0),j.SubVV(p.p,g.p,j.s_t1),j.s_t0),j.s_t0);o=j.DotVV(j.SubVV(A,T,j.s_t0),r.m_localAxisD)}return r.m_ratio=e(n.ratio,1),r.m_constant=s+r.m_ratio*o,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,o=e.positions[this.m_indexB].a,a=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,d=e.velocities[this.m_indexD].v,f=e.velocities[this.m_indexD].w,p=this.m_qA.SetAngle(i),m=this.m_qB.SetAngle(o),g=this.m_qC.SetAngle(u),y=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 v=J.MulRV(g,this.m_localAxisC,n.InitVelocityConstraints_s_u);j.SubVV(this.m_localAnchorC,this.m_lcC,this.m_lalcC);var S=J.MulRV(g,this.m_lalcC,n.InitVelocityConstraints_s_rC);j.SubVV(this.m_localAnchorA,this.m_lcA,this.m_lalcA);var T=J.MulRV(p,this.m_lalcA,n.InitVelocityConstraints_s_rA);this.m_JvAC.Copy(v),this.m_JwC=j.CrossVV(S,v),this.m_JwA=j.CrossVV(T,v),this.m_mass+=this.m_mC+this.m_mA+this.m_iC*this.m_JwC*this.m_JwC+this.m_iA*this.m_JwA*this.m_JwA}if(this.m_typeB===t.b2JointType.e_revoluteJoint)this.m_JvBD.SetZero(),this.m_JwB=this.m_ratio,this.m_JwD=this.m_ratio,this.m_mass+=this.m_ratio*this.m_ratio*(this.m_iB+this.m_iD);else{var A=J.MulRV(y,this.m_localAxisD,n.InitVelocityConstraints_s_u);j.SubVV(this.m_localAnchorD,this.m_lcD,this.m_lalcD);var b=J.MulRV(y,this.m_lalcD,n.InitVelocityConstraints_s_rD);j.SubVV(this.m_localAnchorB,this.m_lcB,this.m_lalcB);var E=J.MulRV(m,this.m_lalcB,n.InitVelocityConstraints_s_rB);j.MulSV(this.m_ratio,A,this.m_JvBD),this.m_JwD=this.m_ratio*j.CrossVV(b,A),this.m_JwB=this.m_ratio*j.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,a.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,d.SelfMulSub(this.m_mD*this.m_impulse,this.m_JvBD),f-=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=f},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,o=t.velocities[this.m_indexC].w,a=t.velocities[this.m_indexD].v,h=t.velocities[this.m_indexD].w,u=j.DotVV(this.m_JvAC,j.SubVV(e,s,j.s_t0))+j.DotVV(this.m_JvBD,j.SubVV(n,a,j.s_t0));u+=this.m_JwA*i-this.m_JwC*o+(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),o-=this.m_iC*l*this.m_JwC,a.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=o,t.velocities[this.m_indexD].w=h},r.SolvePositionConstraints=function(e){var i,r,s,o,a,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,d=e.positions[this.m_indexC].c,f=e.positions[this.m_indexC].a,p=e.positions[this.m_indexD].c,m=e.positions[this.m_indexD].a,g=this.m_qA.SetAngle(l),y=this.m_qB.SetAngle(_),v=this.m_qC.SetAngle(f),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,a=1,b+=this.m_iA+this.m_iC,i=l-f-this.m_referenceAngleA;else{var E=J.MulRV(v,this.m_localAxisC,n.SolvePositionConstraints_s_u),C=J.MulRV(v,this.m_lalcC,n.SolvePositionConstraints_s_rC),w=J.MulRV(g,this.m_lalcA,n.SolvePositionConstraints_s_rA);T.Copy(E),a=j.CrossVV(C,E),s=j.CrossVV(w,E),b+=this.m_mC+this.m_mA+this.m_iC*a*a+this.m_iA*s*s;var x=this.m_lalcC,R=J.MulTRV(v,j.AddVV(w,j.SubVV(u,d,j.s_t0),j.s_t0),j.s_t0);i=j.DotVV(j.SubVV(R,x,j.s_t0),this.m_localAxisC)}if(this.m_typeB===t.b2JointType.e_revoluteJoint)A.SetZero(),o=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=J.MulRV(S,this.m_localAxisD,n.SolvePositionConstraints_s_u),B=J.MulRV(S,this.m_lalcD,n.SolvePositionConstraints_s_rD),D=J.MulRV(y,this.m_lalcB,n.SolvePositionConstraints_s_rB);j.MulSV(this.m_ratio,I,A),h=this.m_ratio*j.CrossVV(B,I),o=this.m_ratio*j.CrossVV(D,I),b+=this.m_ratio*this.m_ratio*(this.m_mD+this.m_mB)+this.m_iD*h*h+this.m_iB*o*o;var P=this.m_lalcD,O=J.MulTRV(S,j.AddVV(D,j.SubVV(c,p,j.s_t0),j.s_t0),j.s_t0);r=j.DotVV(j.SubVV(O,P,j.s_t0),this.m_localAxisD)}var M=i+this.m_ratio*r-this.m_constant,L=0;return b>0&&(L=-M/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*o,d.SelfMulSub(this.m_mC*L,T),f-=this.m_iC*L*a,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=f,e.positions[this.m_indexD].a=m,!0},r.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},r.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},r.GetReactionForce=function(t,e){return j.MulSV(t*this.m_impulse,this.m_JvAC,e)},r.GetReactionTorque=function(t){return t*this.m_impulse*this.m_JwA},r.GetJoint1=function(){return this.m_joint1},r.GetJoint2=function(){return this.m_joint2},r.GetRatio=function(){return this.m_ratio},r.SetRatio=function(t){this.m_ratio=t},r.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex,n=this.m_joint1.m_index,r=this.m_joint2.m_index;t(" const jd: b2GearJointDef = new b2GearJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.joint1 = joints[%d];\n",n),t(" jd.joint2 = joints[%d];\n",r),t(" jd.ratio = %.15f;\n",this.m_ratio),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},n}(Pi);Gi.InitVelocityConstraints_s_u=new j,Gi.InitVelocityConstraints_s_rA=new j,Gi.InitVelocityConstraints_s_rB=new j,Gi.InitVelocityConstraints_s_rC=new j,Gi.InitVelocityConstraints_s_rD=new j,Gi.SolvePositionConstraints_s_u=new j,Gi.SolvePositionConstraints_s_rA=new j,Gi.SolvePositionConstraints_s_rB=new j,Gi.SolvePositionConstraints_s_rC=new j,Gi.SolvePositionConstraints_s_rD=new j;var Ui=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_motorJoint)||this).linearOffset=new j(0,0),i.angularOffset=0,i.maxForce=1,i.maxTorque=1,i.correctionFactor=.3,i}return s(i,e),i.prototype.Initialize=function(t,e){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(this.bodyB.GetPosition(),this.linearOffset);var i=this.bodyA.GetAngle(),n=this.bodyB.GetAngle();this.angularOffset=n-i},i}(Di),zi=function(t){function i(i){var n;return(n=t.call(this,i)||this).m_linearOffset=new j,n.m_angularOffset=0,n.m_linearImpulse=new j,n.m_angularImpulse=0,n.m_maxForce=0,n.m_maxTorque=0,n.m_correctionFactor=.3,n.m_indexA=0,n.m_indexB=0,n.m_rA=new j,n.m_rB=new j,n.m_localCenterA=new j,n.m_localCenterB=new j,n.m_linearError=new j,n.m_angularError=0,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_linearMass=new Y,n.m_angularMass=0,n.m_qA=new J,n.m_qB=new J,n.m_K=new Y,n.m_linearOffset.Copy(e(i.linearOffset,j.ZERO)),n.m_linearImpulse.SetZero(),n.m_maxForce=e(i.maxForce,0),n.m_maxTorque=e(i.maxTorque,0),n.m_correctionFactor=e(i.correctionFactor,.3),n}s(i,t);var n=i.prototype;return n.GetAnchorA=function(t){var e=this.m_bodyA.GetPosition();return t.x=e.x,t.y=e.y,t},n.GetAnchorB=function(t){var e=this.m_bodyB.GetPosition();return t.x=e.x,t.y=e.y,t},n.GetReactionForce=function(t,e){return j.MulSV(t,this.m_linearImpulse,e)},n.GetReactionTorque=function(t){return t*this.m_angularImpulse},n.SetLinearOffset=function(t){j.IsEqualToV(t,this.m_linearOffset)||(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_linearOffset.Copy(t))},n.GetLinearOffset=function(){return this.m_linearOffset},n.SetAngularOffset=function(t){t!==this.m_angularOffset&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_angularOffset=t)},n.GetAngularOffset=function(){return this.m_angularOffset},n.SetMaxForce=function(t){this.m_maxForce=t},n.GetMaxForce=function(){return this.m_maxForce},n.SetMaxTorque=function(t){this.m_maxTorque=t},n.GetMaxTorque=function(){return this.m_maxTorque},n.InitVelocityConstraints=function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].c,i=t.positions[this.m_indexA].a,n=t.velocities[this.m_indexA].v,r=t.velocities[this.m_indexA].w,s=t.positions[this.m_indexB].c,o=t.positions[this.m_indexB].a,a=t.velocities[this.m_indexB].v,h=t.velocities[this.m_indexB].w,u=this.m_qA.SetAngle(i),l=this.m_qB.SetAngle(o),c=J.MulRV(u,j.SubVV(this.m_linearOffset,this.m_localCenterA,j.s_t0),this.m_rA),_=J.MulRV(l,j.NegV(this.m_localCenterB,j.s_t0),this.m_rB),d=this.m_invMassA,f=this.m_invMassB,p=this.m_invIA,m=this.m_invIB,g=this.m_K;if(g.ex.x=d+f+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=d+f+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),j.SubVV(j.AddVV(s,_,j.s_t0),j.AddVV(e,c,j.s_t1),this.m_linearError),this.m_angularError=o-i-this.m_angularOffset,t.step.warmStarting){this.m_linearImpulse.SelfMul(t.step.dtRatio),this.m_angularImpulse*=t.step.dtRatio;var y=this.m_linearImpulse;n.SelfMulSub(d,y),r-=p*(j.CrossVV(c,y)+this.m_angularImpulse),a.SelfMulAdd(f,y),h+=m*(j.CrossVV(_,y)+this.m_angularImpulse)}else this.m_linearImpulse.SetZero(),this.m_angularImpulse=0;t.velocities[this.m_indexA].w=r,t.velocities[this.m_indexB].w=h},n.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexA].v,n=t.velocities[this.m_indexA].w,r=t.velocities[this.m_indexB].v,s=t.velocities[this.m_indexB].w,o=this.m_invMassA,a=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,d=-this.m_angularMass*_,f=this.m_angularImpulse,p=l*this.m_maxTorque;this.m_angularImpulse=M(this.m_angularImpulse+d,-p,p),n-=h*(d=this.m_angularImpulse-f),s+=u*d;var m=this.m_rA,g=this.m_rB,y=j.AddVV(j.SubVV(j.AddVV(r,j.CrossSV(s,g,j.s_t0),j.s_t0),j.AddVV(e,j.CrossSV(n,m,j.s_t1),j.s_t1),j.s_t2),j.MulSV(c*this.m_correctionFactor,this.m_linearError,j.s_t3),i.SolveVelocityConstraints_s_Cdot_v2),v=Y.MulMV(this.m_linearMass,y,i.SolveVelocityConstraints_s_impulse_v2).SelfNeg(),S=i.SolveVelocityConstraints_s_oldImpulse_v2.Copy(this.m_linearImpulse);this.m_linearImpulse.SelfAdd(v);var T=l*this.m_maxForce;this.m_linearImpulse.LengthSquared()>T*T&&(this.m_linearImpulse.Normalize(),this.m_linearImpulse.SelfMul(T)),j.SubVV(this.m_linearImpulse,S,v),e.SelfMulSub(o,v),n-=h*j.CrossVV(m,v),r.SelfMulAdd(a,v),s+=u*j.CrossVV(g,v),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=s},n.SolvePositionConstraints=function(){return!0},n.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2MotorJointDef = new b2MotorJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.linearOffset.Set(%.15f, %.15f);\n",this.m_linearOffset.x,this.m_linearOffset.y),t(" jd.angularOffset = %.15f;\n",this.m_angularOffset),t(" jd.maxForce = %.15f;\n",this.m_maxForce),t(" jd.maxTorque = %.15f;\n",this.m_maxTorque),t(" jd.correctionFactor = %.15f;\n",this.m_correctionFactor),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},i}(Pi);zi.SolveVelocityConstraints_s_Cdot_v2=new j,zi.SolveVelocityConstraints_s_impulse_v2=new j,zi.SolveVelocityConstraints_s_oldImpulse_v2=new j;var Hi=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_mouseJoint)||this).target=new j,i.maxForce=0,i.frequencyHz=5,i.dampingRatio=.7,i}return s(i,e),i}(Di),Wi=function(t){function i(i){var n;return(n=t.call(this,i)||this).m_localAnchorB=new j,n.m_targetA=new j,n.m_frequencyHz=0,n.m_dampingRatio=0,n.m_beta=0,n.m_impulse=new j,n.m_maxForce=0,n.m_gamma=0,n.m_indexA=0,n.m_indexB=0,n.m_rB=new j,n.m_localCenterB=new j,n.m_invMassB=0,n.m_invIB=0,n.m_mass=new Y,n.m_C=new j,n.m_qB=new J,n.m_lalcB=new j,n.m_K=new Y,n.m_targetA.Copy(e(i.target,j.ZERO)),Q.MulTXV(n.m_bodyB.GetTransform(),n.m_targetA,n.m_localAnchorB),n.m_maxForce=e(i.maxForce,0),n.m_impulse.SetZero(),n.m_frequencyHz=e(i.frequencyHz,0),n.m_dampingRatio=e(i.dampingRatio,0),n.m_beta=0,n.m_gamma=0,n}s(i,t);var n=i.prototype;return n.SetTarget=function(t){this.m_bodyB.IsAwake()||this.m_bodyB.SetAwake(!0),this.m_targetA.Copy(t)},n.GetTarget=function(){return this.m_targetA},n.SetMaxForce=function(t){this.m_maxForce=t},n.GetMaxForce=function(){return this.m_maxForce},n.SetFrequency=function(t){this.m_frequencyHz=t},n.GetFrequency=function(){return this.m_frequencyHz},n.SetDampingRatio=function(t){this.m_dampingRatio=t},n.GetDampingRatio=function(){return this.m_dampingRatio},n.InitVelocityConstraints=function(t){this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexB].c,i=t.positions[this.m_indexB].a,n=t.velocities[this.m_indexB].v,r=t.velocities[this.m_indexB].w,s=this.m_qB.SetAngle(i),o=this.m_bodyB.GetMass(),h=2*a*this.m_frequencyHz,u=2*o*this.m_dampingRatio*h,l=o*h*h,c=t.step.dt;this.m_gamma=c*(u+c*l),0!==this.m_gamma&&(this.m_gamma=1/this.m_gamma),this.m_beta=c*l*this.m_gamma,j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),J.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*j.CrossVV(this.m_rB,this.m_impulse)):this.m_impulse.SetZero(),t.velocities[this.m_indexB].w=r},n.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexB].v,n=t.velocities[this.m_indexB].w,r=j.AddVCrossSV(e,n,this.m_rB,i.SolveVelocityConstraints_s_Cdot),s=Y.MulMV(this.m_mass,j.AddVV(r,j.AddVV(this.m_C,j.MulSV(this.m_gamma,this.m_impulse,j.s_t0),j.s_t0),j.s_t0).SelfNeg(),i.SolveVelocityConstraints_s_impulse),o=i.SolveVelocityConstraints_s_oldImpulse.Copy(this.m_impulse);this.m_impulse.SelfAdd(s);var a=t.step.dt*this.m_maxForce;this.m_impulse.LengthSquared()>a*a&&this.m_impulse.SelfMul(a/this.m_impulse.Length()),j.SubVV(this.m_impulse,o,s),e.SelfMulAdd(this.m_invMassB,s),n+=this.m_invIB*j.CrossVV(this.m_rB,s),t.velocities[this.m_indexB].w=n},n.SolvePositionConstraints=function(){return!0},n.GetAnchorA=function(t){return t.x=this.m_targetA.x,t.y=this.m_targetA.y,t},n.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},n.GetReactionForce=function(t,e){return j.MulSV(t,this.m_impulse,e)},n.GetReactionTorque=function(){return 0},n.Dump=function(t){t("Mouse joint dumping is not supported.\n")},n.ShiftOrigin=function(t){this.m_targetA.SelfSub(t)},i}(Pi);Wi.SolveVelocityConstraints_s_Cdot=new j,Wi.SolveVelocityConstraints_s_impulse=new j,Wi.SolveVelocityConstraints_s_oldImpulse=new j;var ji=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_prismaticJoint)||this).localAnchorA=new j,i.localAnchorB=new j,i.localAxisA=new j(1,0),i.referenceAngle=0,i.enableLimit=!1,i.lowerTranslation=0,i.upperTranslation=0,i.enableMotor=!1,i.maxMotorForce=0,i.motorSpeed=0,i}return s(i,e),i.prototype.Initialize=function(t,e,i,n){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(i,this.localAnchorA),this.bodyB.GetLocalPoint(i,this.localAnchorB),this.bodyA.GetLocalVector(n,this.localAxisA),this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()},i}(Di),Xi=function(i){function n(n){var r;return(r=i.call(this,n)||this).m_localAnchorA=new j,r.m_localAnchorB=new j,r.m_localXAxisA=new j,r.m_localYAxisA=new j,r.m_referenceAngle=0,r.m_impulse=new q(0,0,0),r.m_motorImpulse=0,r.m_lowerTranslation=0,r.m_upperTranslation=0,r.m_maxMotorForce=0,r.m_motorSpeed=0,r.m_enableLimit=!1,r.m_enableMotor=!1,r.m_limitState=t.b2LimitState.e_inactiveLimit,r.m_indexA=0,r.m_indexB=0,r.m_localCenterA=new j,r.m_localCenterB=new j,r.m_invMassA=0,r.m_invMassB=0,r.m_invIA=0,r.m_invIB=0,r.m_axis=new j(0,0),r.m_perp=new j(0,0),r.m_s1=0,r.m_s2=0,r.m_a1=0,r.m_a2=0,r.m_K=new K,r.m_K3=new K,r.m_K2=new Y,r.m_motorMass=0,r.m_qA=new J,r.m_qB=new J,r.m_lalcA=new j,r.m_lalcB=new j,r.m_rA=new j,r.m_rB=new j,r.m_localAnchorA.Copy(e(n.localAnchorA,j.ZERO)),r.m_localAnchorB.Copy(e(n.localAnchorB,j.ZERO)),r.m_localXAxisA.Copy(e(n.localAxisA,new j(1,0))).SelfNormalize(),j.CrossOneV(r.m_localXAxisA,r.m_localYAxisA),r.m_referenceAngle=e(n.referenceAngle,0),r.m_lowerTranslation=e(n.lowerTranslation,0),r.m_upperTranslation=e(n.upperTranslation,0),r.m_maxMotorForce=e(n.maxMotorForce,0),r.m_motorSpeed=e(n.motorSpeed,0),r.m_enableLimit=e(n.enableLimit,!1),r.m_enableMotor=e(n.enableMotor,!1),r}s(n,i);var r=n.prototype;return r.InitVelocityConstraints=function(e){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var i=e.positions[this.m_indexA].c,r=e.positions[this.m_indexA].a,s=e.velocities[this.m_indexA].v,o=e.velocities[this.m_indexA].w,a=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);j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var d=J.MulRV(c,this.m_lalcA,this.m_rA);j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var f=J.MulRV(_,this.m_lalcB,this.m_rB),p=j.AddVV(j.SubVV(a,i,j.s_t0),j.SubVV(f,d,j.s_t1),n.InitVelocityConstraints_s_d),m=this.m_invMassA,g=this.m_invMassB,y=this.m_invIA,v=this.m_invIB;if(J.MulRV(c,this.m_localXAxisA,this.m_axis),this.m_a1=j.CrossVV(j.AddVV(p,d,j.s_t0),this.m_axis),this.m_a2=j.CrossVV(f,this.m_axis),this.m_motorMass=m+g+y*this.m_a1*this.m_a1+v*this.m_a2*this.m_a2,this.m_motorMass>0&&(this.m_motorMass=1/this.m_motorMass),J.MulRV(c,this.m_localYAxisA,this.m_perp),this.m_s1=j.CrossVV(j.AddVV(p,d,j.s_t0),this.m_perp),this.m_s2=j.CrossVV(f,this.m_perp),this.m_K.ex.x=m+g+y*this.m_s1*this.m_s1+v*this.m_s2*this.m_s2,this.m_K.ex.y=y*this.m_s1+v*this.m_s2,this.m_K.ex.z=y*this.m_s1*this.m_a1+v*this.m_s2*this.m_a2,this.m_K.ey.x=this.m_K.ex.y,this.m_K.ey.y=y+v,0===this.m_K.ey.y&&(this.m_K.ey.y=1),this.m_K.ey.z=y*this.m_a1+v*this.m_a2,this.m_K.ez.x=this.m_K.ex.z,this.m_K.ez.y=this.m_K.ey.z,this.m_K.ez.z=m+g+y*this.m_a1*this.m_a1+v*this.m_a2*this.m_a2,this.m_enableLimit){var S=j.DotVV(this.m_axis,p);D(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=j.AddVV(j.MulSV(this.m_impulse.x,this.m_perp,j.s_t0),j.MulSV(this.m_motorImpulse+this.m_impulse.z,this.m_axis,j.s_t1),n.InitVelocityConstraints_s_P),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),o-=y*A,u.SelfMulAdd(g,T),l+=v*b}else this.m_impulse.SetZero(),this.m_motorImpulse=0;e.velocities[this.m_indexA].w=o,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,o=e.velocities[this.m_indexB].w,a=this.m_invMassA,h=this.m_invMassB,u=this.m_invIA,l=this.m_invIB;if(this.m_enableMotor&&this.m_limitState!==t.b2LimitState.e_equalLimits){var c=j.DotVV(this.m_axis,j.SubVV(s,i,j.s_t0))+this.m_a2*o-this.m_a1*r,_=this.m_motorMass*(this.m_motorSpeed-c),d=this.m_motorImpulse,f=e.step.dt*this.m_maxMotorForce;this.m_motorImpulse=M(this.m_motorImpulse+_,-f,f),_=this.m_motorImpulse-d;var p=j.MulSV(_,this.m_axis,n.SolveVelocityConstraints_s_P),m=_*this.m_a1,g=_*this.m_a2;i.SelfMulSub(a,p),r-=u*m,s.SelfMulAdd(h,p),o+=l*g}var y=j.DotVV(this.m_perp,j.SubVV(s,i,j.s_t0))+this.m_s2*o-this.m_s1*r,v=o-r;if(this.m_enableLimit&&this.m_limitState!==t.b2LimitState.e_inactiveLimit){var S=j.DotVV(this.m_axis,j.SubVV(s,i,j.s_t0))+this.m_a2*o-this.m_a1*r,T=n.SolveVelocityConstraints_s_f1.Copy(this.m_impulse),A=this.m_K.Solve33(-y,-v,-S,n.SolveVelocityConstraints_s_df3);this.m_impulse.SelfAdd(A),this.m_limitState===t.b2LimitState.e_atLowerLimit?this.m_impulse.z=O(this.m_impulse.z,0):this.m_limitState===t.b2LimitState.e_atUpperLimit&&(this.m_impulse.z=P(this.m_impulse.z,0));var b=-y-(this.m_impulse.z-T.z)*this.m_K.ez.x,E=-v-(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 w=j.AddVV(j.MulSV(A.x,this.m_perp,j.s_t0),j.MulSV(A.z,this.m_axis,j.s_t1),n.SolveVelocityConstraints_s_P),x=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(a,w),r-=u*x,s.SelfMulAdd(h,w),o+=l*R}else{var I=this.m_K.Solve22(-y,-v,n.SolveVelocityConstraints_s_df2);this.m_impulse.x+=I.x,this.m_impulse.y+=I.y;var B=j.MulSV(I.x,this.m_perp,n.SolveVelocityConstraints_s_P),D=I.x*this.m_s1+I.y,L=I.x*this.m_s2+I.y;i.SelfMulSub(a,B),r-=u*D,s.SelfMulAdd(h,B),o+=l*L}e.velocities[this.m_indexA].w=r,e.velocities[this.m_indexB].w=o},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,o=this.m_qA.SetAngle(i),a=this.m_qB.SetAngle(s),h=this.m_invMassA,u=this.m_invMassB,_=this.m_invIA,d=this.m_invIB,p=J.MulRV(o,this.m_lalcA,this.m_rA),m=J.MulRV(a,this.m_lalcB,this.m_rB),g=j.SubVV(j.AddVV(r,m,j.s_t0),j.AddVV(e,p,j.s_t1),n.SolvePositionConstraints_s_d),y=J.MulRV(o,this.m_localXAxisA,this.m_axis),v=j.CrossVV(j.AddVV(g,p,j.s_t0),y),S=j.CrossVV(m,y),T=J.MulRV(o,this.m_localYAxisA,this.m_perp),A=j.CrossVV(j.AddVV(g,p,j.s_t0),T),b=j.CrossVV(m,T),E=n.SolvePositionConstraints_s_impulse,C=j.DotVV(T,g),w=s-i-this.m_referenceAngle,x=D(C),R=D(w),I=!1,B=0;if(this.m_enableLimit){var P=j.DotVV(y,g);D(this.m_upperTranslation-this.m_lowerTranslation)<.016?(B=M(P,-.2,f),x=O(x,D(P)),I=!0):P<=this.m_lowerTranslation?(B=M(P-this.m_lowerTranslation+l,-.2,0),x=O(x,this.m_lowerTranslation-P),I=!0):P>=this.m_upperTranslation&&(B=M(P-this.m_upperTranslation-l,0,f),x=O(x,P-this.m_upperTranslation),I=!0)}if(I){var L=h+u+_*A*A+d*b*b,N=_*A+d*b,F=_*A*v+d*b*S,k=_+d;0===k&&(k=1);var V=_*v+d*S,G=h+u+_*v*v+d*S*S,U=this.m_K3;U.ex.SetXYZ(L,N,F),U.ey.SetXYZ(N,k,V),U.ez.SetXYZ(F,V,G),E=U.Solve33(-C,-w,-B,E)}else{var z=h+u+_*A*A+d*b*b,H=_*A+d*b,W=_+d;0===W&&(W=1);var X=this.m_K2;X.ex.Set(z,H),X.ey.Set(H,W);var q=X.Solve(-C,-w,n.SolvePositionConstraints_s_impulse1);E.x=q.x,E.y=q.y,E.z=0}var Y=j.AddVV(j.MulSV(E.x,T,j.s_t0),j.MulSV(E.z,y,j.s_t1),n.SolvePositionConstraints_s_P),K=E.x*A+E.y+E.z*v,Q=E.x*b+E.y+E.z*S;return e.SelfMulSub(h,Y),i-=_*K,r.SelfMulAdd(u,Y),s+=d*Q,t.positions[this.m_indexA].a=i,t.positions[this.m_indexB].a=s,x<=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=j.SubVV(e,t,n.GetJointTranslation_s_d),r=this.m_bodyA.GetWorldVector(this.m_localXAxisA,n.GetJointTranslation_s_axis);return j.DotVV(i,r)},r.GetJointSpeed=function(){var t=this.m_bodyA,e=this.m_bodyB;j.SubVV(this.m_localAnchorA,t.m_sweep.localCenter,this.m_lalcA);var i=J.MulRV(t.m_xf.q,this.m_lalcA,this.m_rA);j.SubVV(this.m_localAnchorB,e.m_sweep.localCenter,this.m_lalcB);var n=J.MulRV(e.m_xf.q,this.m_lalcB,this.m_rB),r=j.AddVV(t.m_sweep.c,i,j.s_t0),s=j.AddVV(e.m_sweep.c,n,j.s_t1),o=j.SubVV(s,r,j.s_t2),a=t.GetWorldVector(this.m_localXAxisA,this.m_axis),h=t.m_linearVelocity,u=e.m_linearVelocity,l=t.m_angularVelocity,c=e.m_angularVelocity;return j.DotVV(o,j.CrossSV(l,a,j.s_t0))+j.DotVV(a,j.SubVV(j.AddVCrossSV(u,c,n,j.s_t0),j.AddVCrossSV(h,l,i,j.s_t1),j.s_t0))},r.IsLimitEnabled=function(){return this.m_enableLimit},r.EnableLimit=function(t){t!==this.m_enableLimit&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableLimit=t,this.m_impulse.z=0)},r.GetLowerLimit=function(){return this.m_lowerTranslation},r.GetUpperLimit=function(){return this.m_upperTranslation},r.SetLimits=function(t,e){t===this.m_lowerTranslation&&e===this.m_upperTranslation||(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_lowerTranslation=t,this.m_upperTranslation=e,this.m_impulse.z=0)},r.IsMotorEnabled=function(){return this.m_enableMotor},r.EnableMotor=function(t){t!==this.m_enableMotor&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableMotor=t)},r.SetMotorSpeed=function(t){t!==this.m_motorSpeed&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_motorSpeed=t)},r.GetMotorSpeed=function(){return this.m_motorSpeed},r.SetMaxMotorForce=function(t){t!==this.m_maxMotorForce&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_maxMotorForce=t)},r.GetMaxMotorForce=function(){return this.m_maxMotorForce},r.GetMotorForce=function(t){return t*this.m_motorImpulse},r.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2PrismaticJointDef = new b2PrismaticJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.localAxisA.Set(%.15f, %.15f);\n",this.m_localXAxisA.x,this.m_localXAxisA.y),t(" jd.referenceAngle = %.15f;\n",this.m_referenceAngle),t(" jd.enableLimit = %s;\n",this.m_enableLimit?"true":"false"),t(" jd.lowerTranslation = %.15f;\n",this.m_lowerTranslation),t(" jd.upperTranslation = %.15f;\n",this.m_upperTranslation),t(" jd.enableMotor = %s;\n",this.m_enableMotor?"true":"false"),t(" jd.motorSpeed = %.15f;\n",this.m_motorSpeed),t(" jd.maxMotorForce = %.15f;\n",this.m_maxMotorForce),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},n}(Pi);Xi.InitVelocityConstraints_s_d=new j,Xi.InitVelocityConstraints_s_P=new j,Xi.SolveVelocityConstraints_s_P=new j,Xi.SolveVelocityConstraints_s_f2r=new j,Xi.SolveVelocityConstraints_s_f1=new q,Xi.SolveVelocityConstraints_s_df3=new q,Xi.SolveVelocityConstraints_s_df2=new j,Xi.SolvePositionConstraints_s_d=new j,Xi.SolvePositionConstraints_s_impulse=new q,Xi.SolvePositionConstraints_s_impulse1=new j,Xi.SolvePositionConstraints_s_P=new j,Xi.GetJointTranslation_s_pA=new j,Xi.GetJointTranslation_s_pB=new j,Xi.GetJointTranslation_s_d=new j,Xi.GetJointTranslation_s_axis=new j;var qi=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_pulleyJoint)||this).groundAnchorA=new j(-1,1),i.groundAnchorB=new j(1,1),i.localAnchorA=new j(-1,0),i.localAnchorB=new j(1,0),i.lengthA=0,i.lengthB=0,i.ratio=1,i.collideConnected=!0,i}return s(i,e),i.prototype.Initialize=function(t,e,i,n,r,s,o){this.bodyA=t,this.bodyB=e,this.groundAnchorA.Copy(i),this.groundAnchorB.Copy(n),this.bodyA.GetLocalPoint(r,this.localAnchorA),this.bodyB.GetLocalPoint(s,this.localAnchorB),this.lengthA=j.DistanceVV(r,i),this.lengthB=j.DistanceVV(s,n),this.ratio=o},i}(Di),Yi=function(t){function i(i){var n;return(n=t.call(this,i)||this).m_groundAnchorA=new j,n.m_groundAnchorB=new j,n.m_lengthA=0,n.m_lengthB=0,n.m_localAnchorA=new j,n.m_localAnchorB=new j,n.m_constant=0,n.m_ratio=0,n.m_impulse=0,n.m_indexA=0,n.m_indexB=0,n.m_uA=new j,n.m_uB=new j,n.m_rA=new j,n.m_rB=new j,n.m_localCenterA=new j,n.m_localCenterB=new j,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_mass=0,n.m_qA=new J,n.m_qB=new J,n.m_lalcA=new j,n.m_lalcB=new j,n.m_groundAnchorA.Copy(e(i.groundAnchorA,new j(-1,1))),n.m_groundAnchorB.Copy(e(i.groundAnchorB,new j(1,0))),n.m_localAnchorA.Copy(e(i.localAnchorA,new j(-1,0))),n.m_localAnchorB.Copy(e(i.localAnchorB,new j(1,0))),n.m_lengthA=e(i.lengthA,0),n.m_lengthB=e(i.lengthB,0),n.m_ratio=e(i.ratio,1),n.m_constant=e(i.lengthA,0)+n.m_ratio*e(i.lengthB,0),n.m_impulse=0,n}s(i,t);var n=i.prototype;return n.InitVelocityConstraints=function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,r=t.velocities[this.m_indexA].v,s=t.velocities[this.m_indexA].w,o=t.positions[this.m_indexB].c,a=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(a);j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA),J.MulRV(l,this.m_lalcA,this.m_rA),j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),J.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(o).SelfAdd(this.m_rB).SelfSub(this.m_groundAnchorB);var _=this.m_uA.Length(),d=this.m_uB.Length();_>.08?this.m_uA.SelfMul(1/_):this.m_uA.SetZero(),d>.08?this.m_uB.SelfMul(1/d):this.m_uB.SetZero();var f=j.CrossVV(this.m_rA,this.m_uA),p=j.CrossVV(this.m_rB,this.m_uB),m=this.m_invMassA+this.m_invIA*f*f,g=this.m_invMassB+this.m_invIB*p*p;if(this.m_mass=m+this.m_ratio*this.m_ratio*g,this.m_mass>0&&(this.m_mass=1/this.m_mass),t.step.warmStarting){this.m_impulse*=t.step.dtRatio;var y=j.MulSV(-this.m_impulse,this.m_uA,i.InitVelocityConstraints_s_PA),v=j.MulSV(-this.m_ratio*this.m_impulse,this.m_uB,i.InitVelocityConstraints_s_PB);r.SelfMulAdd(this.m_invMassA,y),s+=this.m_invIA*j.CrossVV(this.m_rA,y),h.SelfMulAdd(this.m_invMassB,v),u+=this.m_invIB*j.CrossVV(this.m_rB,v)}else this.m_impulse=0;t.velocities[this.m_indexA].w=s,t.velocities[this.m_indexB].w=u},n.SolveVelocityConstraints=function(t){var e=t.velocities[this.m_indexA].v,n=t.velocities[this.m_indexA].w,r=t.velocities[this.m_indexB].v,s=t.velocities[this.m_indexB].w,o=j.AddVCrossSV(e,n,this.m_rA,i.SolveVelocityConstraints_s_vpA),a=j.AddVCrossSV(r,s,this.m_rB,i.SolveVelocityConstraints_s_vpB),h=-j.DotVV(this.m_uA,o)-this.m_ratio*j.DotVV(this.m_uB,a),u=-this.m_mass*h;this.m_impulse+=u;var l=j.MulSV(-u,this.m_uA,i.SolveVelocityConstraints_s_PA),c=j.MulSV(-this.m_ratio*u,this.m_uB,i.SolveVelocityConstraints_s_PB);e.SelfMulAdd(this.m_invMassA,l),n+=this.m_invIA*j.CrossVV(this.m_rA,l),r.SelfMulAdd(this.m_invMassB,c),s+=this.m_invIB*j.CrossVV(this.m_rB,c),t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=s},n.SolvePositionConstraints=function(t){var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,r=t.positions[this.m_indexB].c,s=t.positions[this.m_indexB].a,o=this.m_qA.SetAngle(n),a=this.m_qB.SetAngle(s);j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var h=J.MulRV(o,this.m_lalcA,this.m_rA);j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var u=J.MulRV(a,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),d=c.Length(),f=_.Length();d>.08?c.SelfMul(1/d):c.SetZero(),f>.08?_.SelfMul(1/f):_.SetZero();var p=j.CrossVV(h,c),m=j.CrossVV(u,_),g=this.m_invMassA+this.m_invIA*p*p,y=this.m_invMassB+this.m_invIB*m*m,v=g+this.m_ratio*this.m_ratio*y;v>0&&(v=1/v);var S=this.m_constant-d-this.m_ratio*f,T=D(S),A=-v*S,b=j.MulSV(-A,c,i.SolvePositionConstraints_s_PA),E=j.MulSV(-this.m_ratio*A,_,i.SolvePositionConstraints_s_PB);return e.SelfMulAdd(this.m_invMassA,b),n+=this.m_invIA*j.CrossVV(h,b),r.SelfMulAdd(this.m_invMassB,E),s+=this.m_invIB*j.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=o-i-this.m_referenceAngle;D(this.m_upperAngle-this.m_lowerAngle)<2*c?this.m_limitState=t.b2LimitState.e_equalLimits:g<=this.m_lowerAngle?(this.m_limitState!==t.b2LimitState.e_atLowerLimit&&(this.m_impulse.z=0),this.m_limitState=t.b2LimitState.e_atLowerLimit):g>=this.m_upperAngle?(this.m_limitState!==t.b2LimitState.e_atUpperLimit&&(this.m_impulse.z=0),this.m_limitState=t.b2LimitState.e_atUpperLimit):(this.m_limitState=t.b2LimitState.e_inactiveLimit,this.m_impulse.z=0)}else this.m_limitState=t.b2LimitState.e_inactiveLimit;if(e.step.warmStarting){this.m_impulse.SelfMul(e.step.dtRatio),this.m_motorImpulse*=e.step.dtRatio;var y=n.InitVelocityConstraints_s_P.Set(this.m_impulse.x,this.m_impulse.y);r.SelfMulSub(_,y),s-=f*(j.CrossVV(this.m_rA,y)+this.m_motorImpulse+this.m_impulse.z),a.SelfMulAdd(d,y),h+=p*(j.CrossVV(this.m_rB,y)+this.m_motorImpulse+this.m_impulse.z)}else this.m_impulse.SetZero(),this.m_motorImpulse=0;e.velocities[this.m_indexA].w=s,e.velocities[this.m_indexB].w=h},r.SolveVelocityConstraints=function(e){var i=e.velocities[this.m_indexA].v,r=e.velocities[this.m_indexA].w,s=e.velocities[this.m_indexB].v,o=e.velocities[this.m_indexB].w,a=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 _=o-r-this.m_motorSpeed,d=-this.m_motorMass*_,f=this.m_motorImpulse,p=e.step.dt*this.m_maxMotorTorque;this.m_motorImpulse=M(this.m_motorImpulse+d,-p,p),r-=u*(d=this.m_motorImpulse-f),o+=l*d}if(this.m_enableLimit&&this.m_limitState!==t.b2LimitState.e_inactiveLimit&&!c){var m=j.SubVV(j.AddVCrossSV(s,o,this.m_rB,j.s_t0),j.AddVCrossSV(i,r,this.m_rA,j.s_t1),n.SolveVelocityConstraints_s_Cdot1),g=o-r,y=this.m_mass.Solve33(m.x,m.y,g,n.SolveVelocityConstraints_s_impulse_v3).SelfNeg();if(this.m_limitState===t.b2LimitState.e_equalLimits)this.m_impulse.SelfAdd(y);else if(this.m_limitState===t.b2LimitState.e_atLowerLimit)if(this.m_impulse.z+y.z<0){var v=-m.x+this.m_impulse.z*this.m_mass.ez.x,S=-m.y+this.m_impulse.z*this.m_mass.ez.y,T=this.m_mass.Solve22(v,S,n.SolveVelocityConstraints_s_reduced_v2);y.x=T.x,y.y=T.y,y.z=-this.m_impulse.z,this.m_impulse.x+=T.x,this.m_impulse.y+=T.y,this.m_impulse.z=0}else this.m_impulse.SelfAdd(y);else if(this.m_limitState===t.b2LimitState.e_atUpperLimit)if(this.m_impulse.z+y.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);y.x=E.x,y.y=E.y,y.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(y);var C=n.SolveVelocityConstraints_s_P.Set(y.x,y.y);i.SelfMulSub(a,C),r-=u*(j.CrossVV(this.m_rA,C)+y.z),s.SelfMulAdd(h,C),o+=l*(j.CrossVV(this.m_rB,C)+y.z)}else{var w=j.SubVV(j.AddVCrossSV(s,o,this.m_rB,j.s_t0),j.AddVCrossSV(i,r,this.m_rA,j.s_t1),n.SolveVelocityConstraints_s_Cdot_v2),x=this.m_mass.Solve22(-w.x,-w.y,n.SolveVelocityConstraints_s_impulse_v2);this.m_impulse.x+=x.x,this.m_impulse.y+=x.y,i.SelfMulSub(a,x),r-=u*j.CrossVV(this.m_rA,x),s.SelfMulAdd(h,x),o+=l*j.CrossVV(this.m_rB,x)}e.velocities[this.m_indexA].w=r,e.velocities[this.m_indexB].w=o},r.SolvePositionConstraints=function(e){var i,r=e.positions[this.m_indexA].c,s=e.positions[this.m_indexA].a,o=e.positions[this.m_indexB].c,a=e.positions[this.m_indexB].a,h=this.m_qA.SetAngle(s),u=this.m_qB.SetAngle(a),_=0,d=this.m_invIA+this.m_invIB===0;if(this.m_enableLimit&&this.m_limitState!==t.b2LimitState.e_inactiveLimit&&!d){var f=a-s-this.m_referenceAngle,m=0;if(this.m_limitState===t.b2LimitState.e_equalLimits){var g=M(f-this.m_lowerAngle,-.13962634015955555,p);m=-this.m_motorMass*g,_=D(g)}else if(this.m_limitState===t.b2LimitState.e_atLowerLimit){var y=f-this.m_lowerAngle;_=-y,y=M(y+c,-.13962634015955555,0),m=-this.m_motorMass*y}else if(this.m_limitState===t.b2LimitState.e_atUpperLimit){var v=f-this.m_upperAngle;_=v,v=M(v-c,0,p),m=-this.m_motorMass*v}s-=this.m_invIA*m,a+=this.m_invIB*m}h.SetAngle(s),u.SetAngle(a),j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var S=J.MulRV(h,this.m_lalcA,this.m_rA);j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var T=J.MulRV(u,this.m_lalcB,this.m_rB),A=j.SubVV(j.AddVV(o,T,j.s_t0),j.AddVV(r,S,j.s_t1),n.SolvePositionConstraints_s_C_v2);i=A.Length();var b=this.m_invMassA,E=this.m_invMassB,C=this.m_invIA,w=this.m_invIB,x=this.m_K;x.ex.x=b+E+C*S.y*S.y+w*T.y*T.y,x.ex.y=-C*S.x*S.y-w*T.x*T.y,x.ey.x=x.ex.y,x.ey.y=b+E+C*S.x*S.x+w*T.x*T.x;var R=x.Solve(A.x,A.y,n.SolvePositionConstraints_s_impulse).SelfNeg();return r.SelfMulSub(b,R),s-=C*j.CrossVV(S,R),o.SelfMulAdd(E,R),a+=w*j.CrossVV(T,R),e.positions[this.m_indexA].a=s,e.positions[this.m_indexB].a=a,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}(Pi);Ji.InitVelocityConstraints_s_P=new j,Ji.SolveVelocityConstraints_s_P=new j,Ji.SolveVelocityConstraints_s_Cdot_v2=new j,Ji.SolveVelocityConstraints_s_Cdot1=new j,Ji.SolveVelocityConstraints_s_impulse_v3=new q,Ji.SolveVelocityConstraints_s_reduced_v2=new j,Ji.SolveVelocityConstraints_s_impulse_v2=new j,Ji.SolvePositionConstraints_s_C_v2=new j,Ji.SolvePositionConstraints_s_impulse=new j;var Qi=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_ropeJoint)||this).localAnchorA=new j(-1,0),i.localAnchorB=new j(1,0),i.maxLength=0,i}return s(i,e),i}(Di),Zi=function(i){function n(n){var r;return(r=i.call(this,n)||this).m_localAnchorA=new j,r.m_localAnchorB=new j,r.m_maxLength=0,r.m_length=0,r.m_impulse=0,r.m_indexA=0,r.m_indexB=0,r.m_u=new j,r.m_rA=new j,r.m_rB=new j,r.m_localCenterA=new j,r.m_localCenterB=new j,r.m_invMassA=0,r.m_invMassB=0,r.m_invIA=0,r.m_invIB=0,r.m_mass=0,r.m_state=t.b2LimitState.e_inactiveLimit,r.m_qA=new J,r.m_qB=new J,r.m_lalcA=new j,r.m_lalcB=new j,r.m_localAnchorA.Copy(e(n.localAnchorA,new j(-1,0))),r.m_localAnchorB.Copy(e(n.localAnchorB,new j(1,0))),r.m_maxLength=e(n.maxLength,0),r}s(n,i);var r=n.prototype;return r.InitVelocityConstraints=function(e){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var i=e.positions[this.m_indexA].c,r=e.positions[this.m_indexA].a,s=e.velocities[this.m_indexA].v,o=e.velocities[this.m_indexA].w,a=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),d=this.m_qB.SetAngle(h);j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA),J.MulRV(_,this.m_lalcA,this.m_rA),j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB),J.MulRV(d,this.m_lalcB,this.m_rB),this.m_u.Copy(a).SelfAdd(this.m_rB).SelfSub(i).SelfSub(this.m_rA),this.m_length=this.m_u.Length();var f=this.m_length-this.m_maxLength;if(this.m_state=f>0?t.b2LimitState.e_atUpperLimit:t.b2LimitState.e_inactiveLimit,!(this.m_length>l))return this.m_u.SetZero(),this.m_mass=0,void(this.m_impulse=0);this.m_u.SelfMul(1/this.m_length);var p=j.CrossVV(this.m_rA,this.m_u),m=j.CrossVV(this.m_rB,this.m_u),g=this.m_invMassA+this.m_invIA*p*p+this.m_invMassB+this.m_invIB*m*m;if(this.m_mass=0!==g?1/g:0,e.step.warmStarting){this.m_impulse*=e.step.dtRatio;var y=j.MulSV(this.m_impulse,this.m_u,n.InitVelocityConstraints_s_P);s.SelfMulSub(this.m_invMassA,y),o-=this.m_invIA*j.CrossVV(this.m_rA,y),u.SelfMulAdd(this.m_invMassB,y),c+=this.m_invIB*j.CrossVV(this.m_rB,y)}else this.m_impulse=0;e.velocities[this.m_indexA].w=o,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,o=j.AddVCrossSV(e,i,this.m_rA,n.SolveVelocityConstraints_s_vpA),a=j.AddVCrossSV(r,s,this.m_rB,n.SolveVelocityConstraints_s_vpB),h=this.m_length-this.m_maxLength,u=j.DotVV(this.m_u,j.SubVV(a,o,j.s_t0));h<0&&(u+=t.step.inv_dt*h);var l=-this.m_mass*u,c=this.m_impulse;this.m_impulse=P(0,this.m_impulse+l),l=this.m_impulse-c;var _=j.MulSV(l,this.m_u,n.SolveVelocityConstraints_s_P);e.SelfMulSub(this.m_invMassA,_),i-=this.m_invIA*j.CrossVV(this.m_rA,_),r.SelfMulAdd(this.m_invMassB,_),s+=this.m_invIB*j.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,o=this.m_qA.SetAngle(i),a=this.m_qB.SetAngle(s);j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var h=J.MulRV(o,this.m_lalcA,this.m_rA);j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var u=J.MulRV(a,this.m_lalcB,this.m_rB),c=this.m_u.Copy(r).SelfAdd(u).SelfSub(e).SelfSub(h),_=c.Normalize(),d=_-this.m_maxLength;d=M(d,0,f);var p=-this.m_mass*d,m=j.MulSV(p,c,n.SolvePositionConstraints_s_P);return e.SelfMulSub(this.m_invMassA,m),i-=this.m_invIA*j.CrossVV(h,m),r.SelfMulAdd(this.m_invMassB,m),s+=this.m_invIB*j.CrossVV(u,m),t.positions[this.m_indexA].a=i,t.positions[this.m_indexB].a=s,_-this.m_maxLength0){p.GetInverse22(this.m_mass);var m=d+f,g=m>0?1/m:0,y=s-e-this.m_referenceAngle,v=2*a*this.m_frequencyHz,S=2*g*this.m_dampingRatio*v,T=g*v*v,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=y*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-=d*(j.CrossVV(this.m_rA,b)+this.m_impulse.z),o.SelfMulAdd(_,b),h+=f*(j.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,o=this.m_invMassA,a=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 _=j.SubVV(j.AddVCrossSV(r,s,this.m_rB,j.s_t0),j.AddVCrossSV(e,n,this.m_rA,j.s_t1),i.SolveVelocityConstraints_s_Cdot1),d=K.MulM33XY(this.m_mass,_.x,_.y,i.SolveVelocityConstraints_s_impulse1).SelfNeg();this.m_impulse.x+=d.x,this.m_impulse.y+=d.y;var f=d;e.SelfMulSub(o,f),n-=h*j.CrossVV(this.m_rA,f),r.SelfMulAdd(a,f),s+=u*j.CrossVV(this.m_rB,f)}else{var p=j.SubVV(j.AddVCrossSV(r,s,this.m_rB,j.s_t0),j.AddVCrossSV(e,n,this.m_rA,j.s_t1),i.SolveVelocityConstraints_s_Cdot1),m=s-n,g=K.MulM33XYZ(this.m_mass,p.x,p.y,m,i.SolveVelocityConstraints_s_impulse).SelfNeg();this.m_impulse.SelfAdd(g);var y=i.SolveVelocityConstraints_s_P.Set(g.x,g.y);e.SelfMulSub(o,y),n-=h*(j.CrossVV(this.m_rA,y)+g.z),r.SelfMulAdd(a,y),s+=u*(j.CrossVV(this.m_rB,y)+g.z)}t.velocities[this.m_indexA].w=n,t.velocities[this.m_indexB].w=s},n.SolvePositionConstraints=function(t){var e=t.positions[this.m_indexA].c,n=t.positions[this.m_indexA].a,r=t.positions[this.m_indexB].c,s=t.positions[this.m_indexB].a,o=this.m_qA.SetAngle(n),a=this.m_qB.SetAngle(s),h=this.m_invMassA,u=this.m_invMassB,_=this.m_invIA,d=this.m_invIB;j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var f=J.MulRV(o,this.m_lalcA,this.m_rA);j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var p,m,g=J.MulRV(a,this.m_lalcB,this.m_rB),y=this.m_K;if(y.ex.x=h+u+f.y*f.y*_+g.y*g.y*d,y.ey.x=-f.y*f.x*_-g.y*g.x*d,y.ez.x=-f.y*_-g.y*d,y.ex.y=y.ey.x,y.ey.y=h+u+f.x*f.x*_+g.x*g.x*d,y.ez.y=f.x*_+g.x*d,y.ex.z=y.ez.x,y.ey.z=y.ez.y,y.ez.z=_+d,this.m_frequencyHz>0){var v=j.SubVV(j.AddVV(r,g,j.s_t0),j.AddVV(e,f,j.s_t1),i.SolvePositionConstraints_s_C1);p=v.Length(),m=0;var S=y.Solve22(v.x,v.y,i.SolvePositionConstraints_s_P).SelfNeg();e.SelfMulSub(h,S),n-=_*j.CrossVV(f,S),r.SelfMulAdd(u,S),s+=d*j.CrossVV(g,S)}else{var T=j.SubVV(j.AddVV(r,g,j.s_t0),j.AddVV(e,f,j.s_t1),i.SolvePositionConstraints_s_C1),A=s-n-this.m_referenceAngle;p=T.Length(),m=D(A);var b=y.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-=_*(j.CrossVV(this.m_rA,E)+b.z),r.SelfMulAdd(u,E),s+=d*(j.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}(Pi);tn.InitVelocityConstraints_s_P=new j,tn.SolveVelocityConstraints_s_Cdot1=new j,tn.SolveVelocityConstraints_s_impulse1=new j,tn.SolveVelocityConstraints_s_impulse=new q,tn.SolveVelocityConstraints_s_P=new j,tn.SolvePositionConstraints_s_C1=new j,tn.SolvePositionConstraints_s_P=new j,tn.SolvePositionConstraints_s_impulse=new q;var en=function(e){function i(){var i;return(i=e.call(this,t.b2JointType.e_wheelJoint)||this).localAnchorA=new j(0,0),i.localAnchorB=new j(0,0),i.localAxisA=new j(1,0),i.enableMotor=!1,i.maxMotorTorque=0,i.motorSpeed=0,i.frequencyHz=2,i.dampingRatio=.7,i}return s(i,e),i.prototype.Initialize=function(t,e,i,n){this.bodyA=t,this.bodyB=e,this.bodyA.GetLocalPoint(i,this.localAnchorA),this.bodyB.GetLocalPoint(i,this.localAnchorB),this.bodyA.GetLocalVector(n,this.localAxisA)},i}(Di),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 j,n.m_localAnchorB=new j,n.m_localXAxisA=new j,n.m_localYAxisA=new j,n.m_impulse=0,n.m_motorImpulse=0,n.m_springImpulse=0,n.m_maxMotorTorque=0,n.m_motorSpeed=0,n.m_enableMotor=!1,n.m_indexA=0,n.m_indexB=0,n.m_localCenterA=new j,n.m_localCenterB=new j,n.m_invMassA=0,n.m_invMassB=0,n.m_invIA=0,n.m_invIB=0,n.m_ax=new j,n.m_ay=new j,n.m_sAx=0,n.m_sBx=0,n.m_sAy=0,n.m_sBy=0,n.m_mass=0,n.m_motorMass=0,n.m_springMass=0,n.m_bias=0,n.m_gamma=0,n.m_qA=new J,n.m_qB=new J,n.m_lalcA=new j,n.m_lalcB=new j,n.m_rA=new j,n.m_rB=new j,n.m_frequencyHz=e(i.frequencyHz,2),n.m_dampingRatio=e(i.dampingRatio,.7),n.m_localAnchorA.Copy(e(i.localAnchorA,j.ZERO)),n.m_localAnchorB.Copy(e(i.localAnchorB,j.ZERO)),n.m_localXAxisA.Copy(e(i.localAxisA,j.UNITX)),j.CrossOneV(n.m_localXAxisA,n.m_localYAxisA),n.m_maxMotorTorque=e(i.maxMotorTorque,0),n.m_motorSpeed=e(i.motorSpeed,0),n.m_enableMotor=e(i.enableMotor,!1),n.m_ax.SetZero(),n.m_ay.SetZero(),n}s(i,t);var n=i.prototype;return n.GetMotorSpeed=function(){return this.m_motorSpeed},n.GetMaxMotorTorque=function(){return this.m_maxMotorTorque},n.SetSpringFrequencyHz=function(t){this.m_frequencyHz=t},n.GetSpringFrequencyHz=function(){return this.m_frequencyHz},n.SetSpringDampingRatio=function(t){this.m_dampingRatio=t},n.GetSpringDampingRatio=function(){return this.m_dampingRatio},n.InitVelocityConstraints=function(t){this.m_indexA=this.m_bodyA.m_islandIndex,this.m_indexB=this.m_bodyB.m_islandIndex,this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter),this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter),this.m_invMassA=this.m_bodyA.m_invMass,this.m_invMassB=this.m_bodyB.m_invMass,this.m_invIA=this.m_bodyA.m_invI,this.m_invIB=this.m_bodyB.m_invI;var e=this.m_invMassA,n=this.m_invMassB,r=this.m_invIA,s=this.m_invIB,o=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,d=t.velocities[this.m_indexB].v,f=t.velocities[this.m_indexB].w,p=this.m_qA.SetAngle(h),m=this.m_qB.SetAngle(_);j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var g=J.MulRV(p,this.m_lalcA,this.m_rA);j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var y=J.MulRV(m,this.m_lalcB,this.m_rB),v=j.SubVV(j.AddVV(c,y,j.s_t0),j.AddVV(o,g,j.s_t1),i.InitVelocityConstraints_s_d);if(J.MulRV(p,this.m_localYAxisA,this.m_ay),this.m_sAy=j.CrossVV(j.AddVV(v,g,j.s_t0),this.m_ay),this.m_sBy=j.CrossVV(y,this.m_ay),this.m_mass=e+n+r*this.m_sAy*this.m_sAy+s*this.m_sBy*this.m_sBy,this.m_mass>0&&(this.m_mass=1/this.m_mass),this.m_springMass=0,this.m_bias=0,this.m_gamma=0,this.m_frequencyHz>0){J.MulRV(p,this.m_localXAxisA,this.m_ax),this.m_sAx=j.CrossVV(j.AddVV(v,g,j.s_t0),this.m_ax),this.m_sBx=j.CrossVV(y,this.m_ax);var 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=j.DotVV(v,this.m_ax),A=2*a*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 w=j.AddVV(j.MulSV(this.m_impulse,this.m_ay,j.s_t0),j.MulSV(this.m_springImpulse,this.m_ax,j.s_t1),i.InitVelocityConstraints_s_P),x=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,w),l-=this.m_invIA*x,d.SelfMulAdd(this.m_invMassB,w),f+=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=f},n.SolveVelocityConstraints=function(t){var e=this.m_invMassA,n=this.m_invMassB,r=this.m_invIA,s=this.m_invIB,o=t.velocities[this.m_indexA].v,a=t.velocities[this.m_indexA].w,h=t.velocities[this.m_indexB].v,u=t.velocities[this.m_indexB].w,l=j.DotVV(this.m_ax,j.SubVV(h,o,j.s_t0))+this.m_sBx*u-this.m_sAx*a,c=-this.m_springMass*(l+this.m_bias+this.m_gamma*this.m_springImpulse);this.m_springImpulse+=c;var _=j.MulSV(c,this.m_ax,i.SolveVelocityConstraints_s_P),d=c*this.m_sAx,f=c*this.m_sBx;o.SelfMulSub(e,_),a-=r*d,h.SelfMulAdd(n,_);var p=(u+=s*f)-a-this.m_motorSpeed,m=-this.m_motorMass*p,g=this.m_motorImpulse,y=t.step.dt*this.m_maxMotorTorque;this.m_motorImpulse=M(this.m_motorImpulse+m,-y,y),a-=r*(m=this.m_motorImpulse-g),u+=s*m;var v=j.DotVV(this.m_ay,j.SubVV(h,o,j.s_t0))+this.m_sBy*u-this.m_sAy*a,S=-this.m_mass*v;this.m_impulse+=S;var T=j.MulSV(S,this.m_ay,i.SolveVelocityConstraints_s_P),A=S*this.m_sAy,b=S*this.m_sBy;o.SelfMulSub(e,T),a-=r*A,h.SelfMulAdd(n,T),u+=s*b,t.velocities[this.m_indexA].w=a,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,o=this.m_qA.SetAngle(n),a=this.m_qB.SetAngle(s);j.SubVV(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var h=J.MulRV(o,this.m_lalcA,this.m_rA);j.SubVV(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var u,c=J.MulRV(a,this.m_lalcB,this.m_rB),_=j.AddVV(j.SubVV(r,e,j.s_t0),j.SubVV(c,h,j.s_t1),i.SolvePositionConstraints_s_d),d=J.MulRV(o,this.m_localYAxisA,this.m_ay),f=j.CrossVV(j.AddVV(_,h,j.s_t0),d),p=j.CrossVV(c,d),m=j.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 y=j.MulSV(u,d,i.SolvePositionConstraints_s_P),v=u*f,S=u*p;return e.SelfMulSub(this.m_invMassA,y),n-=this.m_invIA*v,r.SelfMulAdd(this.m_invMassB,y),s+=this.m_invIB*S,t.positions[this.m_indexA].a=n,t.positions[this.m_indexB].a=s,D(m)<=l},n.GetDefinition=function(t){return t},n.GetAnchorA=function(t){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,t)},n.GetAnchorB=function(t){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,t)},n.GetReactionForce=function(t,e){return e.x=t*(this.m_impulse*this.m_ay.x+this.m_springImpulse*this.m_ax.x),e.y=t*(this.m_impulse*this.m_ay.y+this.m_springImpulse*this.m_ax.y),e},n.GetReactionTorque=function(t){return t*this.m_motorImpulse},n.GetLocalAnchorA=function(){return this.m_localAnchorA},n.GetLocalAnchorB=function(){return this.m_localAnchorB},n.GetLocalAxisA=function(){return this.m_localXAxisA},n.GetJointTranslation=function(){return this.GetPrismaticJointTranslation()},n.GetJointLinearSpeed=function(){return this.GetPrismaticJointSpeed()},n.GetJointAngle=function(){return this.GetRevoluteJointAngle()},n.GetJointAngularSpeed=function(){return this.GetRevoluteJointSpeed()},n.GetPrismaticJointTranslation=function(){var t=this.m_bodyA,e=this.m_bodyB,i=t.GetWorldPoint(this.m_localAnchorA,new j),n=e.GetWorldPoint(this.m_localAnchorB,new j),r=j.SubVV(n,i,new j),s=t.GetWorldVector(this.m_localXAxisA,new j);return j.DotVV(r,s)},n.GetPrismaticJointSpeed=function(){var t=this.m_bodyA,e=this.m_bodyB;j.SubVV(this.m_localAnchorA,t.m_sweep.localCenter,this.m_lalcA);var i=J.MulRV(t.m_xf.q,this.m_lalcA,this.m_rA);j.SubVV(this.m_localAnchorB,e.m_sweep.localCenter,this.m_lalcB);var n=J.MulRV(e.m_xf.q,this.m_lalcB,this.m_rB),r=j.AddVV(t.m_sweep.c,i,j.s_t0),s=j.AddVV(e.m_sweep.c,n,j.s_t1),o=j.SubVV(s,r,j.s_t2),a=t.GetWorldVector(this.m_localXAxisA,new j),h=t.m_linearVelocity,u=e.m_linearVelocity,l=t.m_angularVelocity,c=e.m_angularVelocity;return j.DotVV(o,j.CrossSV(l,a,j.s_t0))+j.DotVV(a,j.SubVV(j.AddVCrossSV(u,c,n,j.s_t0),j.AddVCrossSV(h,l,i,j.s_t1),j.s_t0))},n.GetRevoluteJointAngle=function(){return this.m_bodyB.m_sweep.a-this.m_bodyA.m_sweep.a},n.GetRevoluteJointSpeed=function(){var t=this.m_bodyA.m_angularVelocity;return this.m_bodyB.m_angularVelocity-t},n.IsMotorEnabled=function(){return this.m_enableMotor},n.EnableMotor=function(t){t!==this.m_enableMotor&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableMotor=t)},n.SetMotorSpeed=function(t){t!==this.m_motorSpeed&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_motorSpeed=t)},n.SetMaxMotorTorque=function(t){t!==this.m_maxMotorTorque&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_maxMotorTorque=t)},n.GetMotorTorque=function(t){return t*this.m_motorImpulse},n.Dump=function(t){var e=this.m_bodyA.m_islandIndex,i=this.m_bodyB.m_islandIndex;t(" const jd: b2WheelJointDef = new b2WheelJointDef();\n"),t(" jd.bodyA = bodies[%d];\n",e),t(" jd.bodyB = bodies[%d];\n",i),t(" jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false"),t(" jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y),t(" jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y),t(" jd.localAxisA.Set(%.15f, %.15f);\n",this.m_localXAxisA.x,this.m_localXAxisA.y),t(" jd.enableMotor = %s;\n",this.m_enableMotor?"true":"false"),t(" jd.motorSpeed = %.15f;\n",this.m_motorSpeed),t(" jd.maxMotorTorque = %.15f;\n",this.m_maxMotorTorque),t(" jd.frequencyHz = %.15f;\n",this.m_frequencyHz),t(" jd.dampingRatio = %.15f;\n",this.m_dampingRatio),t(" joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)},i}(Pi);function rn(t,e){return k(t*e)}function sn(t,e){return t>e?t:e}nn.InitVelocityConstraints_s_d=new j,nn.InitVelocityConstraints_s_P=new j,nn.SolveVelocityConstraints_s_P=new j,nn.SolvePositionConstraints_s_d=new j,nn.SolvePositionConstraints_s_P=new j;var on=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}(),an=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 on(this),this.m_nodeB=new on(this),this.m_indexA=0,this.m_indexB=0,this.m_manifold=new Mt,this.m_toiCount=0,this.m_toi=0,this.m_friction=0,this.m_restitution=0,this.m_tangentSpeed=0,this.m_oldManifold=new Mt}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(),o=r||s,a=this.m_fixtureA.GetBody(),h=this.m_fixtureB.GetBody(),u=a.GetTransform(),l=h.GetTransform();if(o){var c=this.GetShapeA(),_=this.GetShapeB();i=jt(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 d=0;d0:0!=(s.maskBits&o.categoryBits)&&0!=(s.categoryBits&o.maskBits)},i.ShouldCollideFixtureParticle=function(){return!0},i.ShouldCollideParticleParticle=function(){return!0},e}();yn.b2_defaultFilter=new yn;var vn=function(){this.normalImpulses=x(2),this.tangentImpulses=x(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 Zt,this.m_contactList=null,this.m_contactCount=0,this.m_contactFilter=yn.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,o=i.GetBody(),a=n.GetBody();if(o!==a){for(var h=a.GetContactList();h;){if(h.other===o){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 d=this.m_contactFactory.Create(i,r,n,s);null!==d&&(i=d.GetFixtureA(),n=d.GetFixtureB(),r=d.GetChildIndexA(),s=d.GetChildIndexB(),o=i.m_body,a=n.m_body,d.m_prev=null,d.m_next=this.m_contactList,null!==this.m_contactList&&(this.m_contactList.m_prev=d),this.m_contactList=d,d.m_nodeA.other=a,d.m_nodeA.prev=null,d.m_nodeA.next=o.m_contactList,null!==o.m_contactList&&(o.m_contactList.prev=d.m_nodeA),o.m_contactList=d.m_nodeA,d.m_nodeB.other=o,d.m_nodeB.prev=null,d.m_nodeB.next=a.m_contactList,null!==a.m_contactList&&(a.m_contactList.prev=d.m_nodeB),a.m_contactList=d.m_nodeB,i.IsSensor()||n.IsSensor()||(o.SetAwake(!0),a.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(),o=i.GetBody(),a=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=o.IsAwake()&&o.m_type!==t.b2BodyType.b2_staticBody,l=a.IsAwake()&&a.m_type!==t.b2BodyType.b2_staticBody;if(u||l){var c=i.m_proxies[r].treeNode,_=n.m_proxies[s].treeNode;if(Gt(c.aabb,_.aabb))e.Update(this.m_contactListener),e=e.m_next;else{var d=e;e=d.m_next,this.Destroy(d)}}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}(),wn=function(){function t(){this.c=new j,this.a=0}return t.MakeArray=function(e){return w(e,(function(){return new t}))},t}(),xn=function(){function t(){this.v=new j,this.w=0}return t.MakeArray=function(e){return w(e,(function(){return new t}))},t}(),Rn=function(){this.step=new Cn},In=!1,Bn=function(){function t(){this.rA=new j,this.rB=new j,this.normalImpulse=0,this.tangentImpulse=0,this.normalMass=0,this.tangentMass=0,this.velocityBias=0}return t.MakeArray=function(e){return w(e,(function(){return new t}))},t}(),Dn=function(){function t(){this.points=Bn.MakeArray(2),this.normal=new j,this.tangent=new j,this.normalMass=new Y,this.K=new Y,this.indexA=0,this.indexB=0,this.invMassA=0,this.invMassB=0,this.invIA=0,this.invIB=0,this.friction=0,this.restitution=0,this.tangentSpeed=0,this.pointCount=0,this.contactIndex=0}return t.MakeArray=function(e){return w(e,(function(){return new t}))},t}(),Pn=function(){function e(){this.localPoints=j.MakeArray(2),this.localNormal=new j,this.localPoint=new j,this.indexA=0,this.indexB=0,this.invMassA=0,this.invMassB=0,this.localCenterA=new j,this.localCenterB=new j,this.invIA=0,this.invIB=0,this.type=t.b2ManifoldType.e_unknown,this.radiusA=0,this.radiusB=0,this.pointCount=0}return e.MakeArray=function(t){return w(t,(function(){return new e}))},e}(),On=function(){this.step=new Cn,this.count=0},Mn=function(){function e(){this.normal=new j,this.point=new j,this.separation=0}return e.prototype.Initialize=function(i,n,r,s){var o=e.Initialize_s_pointA,a=e.Initialize_s_pointB,h=e.Initialize_s_planePoint,u=e.Initialize_s_clipPoint;switch(i.type){case t.b2ManifoldType.e_circles:Q.MulXV(n,i.localPoint,o),Q.MulXV(r,i.localPoints[0],a),j.SubVV(a,o,this.normal).SelfNormalize(),j.MidVV(o,a,this.point),this.separation=j.DotVV(j.SubVV(a,o,j.s_t0),this.normal)-i.radiusA-i.radiusB;break;case t.b2ManifoldType.e_faceA:J.MulRV(n.q,i.localNormal,this.normal),Q.MulXV(n,i.localPoint,h),Q.MulXV(r,i.localPoints[s],u),this.separation=j.DotVV(j.SubVV(u,h,j.s_t0),this.normal)-i.radiusA-i.radiusB,this.point.Copy(u);break;case t.b2ManifoldType.e_faceB:J.MulRV(r.q,i.localNormal,this.normal),Q.MulXV(r,i.localPoint,h),Q.MulXV(n,i.localPoints[s],u),this.separation=j.DotVV(j.SubVV(u,h,j.s_t0),this.normal)-i.radiusA-i.radiusB,this.point.Copy(u),this.normal.SelfNeg()}},e}();Mn.Initialize_s_pointA=new j,Mn.Initialize_s_pointB=new j,Mn.Initialize_s_planePoint=new j,Mn.Initialize_s_clipPoint=new j;var Ln=function(){function t(){this.m_step=new Cn,this.m_positionConstraints=Pn.MakeArray(1024),this.m_velocityConstraints=Dn.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/D:0;var P=s.tangent,O=j.CrossVV(R.rA,P),M=j.CrossVV(R.rB,P),L=_+d+f*O*O+p*M*M;R.tangentMass=L>0?1/L:0,R.velocityBias=0;var N=j.DotVV(s.normal,j.SubVV(j.AddVCrossSV(E,C,R.rB,j.s_t0),j.AddVCrossSV(S,T,R.rA,j.s_t1),j.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/D:0;j.MulSV(O,C,o),S.SelfMulSub(f,o),T-=p*j.CrossVV(r,o),A.SelfMulAdd(g,o),b+=y*j.CrossVV(s,o)}this.m_positions[c].a=T,this.m_positions[_].a=b}return a>-.024},e.SolveTOIPositionConstraints=function(e,i){for(var n=t.SolveTOIPositionConstraints_s_xfA,r=t.SolveTOIPositionConstraints_s_xfB,s=t.SolveTOIPositionConstraints_s_psm,o=t.SolveTOIPositionConstraints_s_rA,a=t.SolveTOIPositionConstraints_s_rB,h=t.SolveTOIPositionConstraints_s_P,u=0,c=0;c0?-B/L:0;j.MulSV(N,x,h),A.SelfMulSub(y,h),b-=v*j.CrossVV(o,h),E.SelfMulAdd(S,h),C+=T*j.CrossVV(a,h)}this.m_positions[d].a=b,this.m_positions[f].a=C}return u>=-.012},t}();Ln.InitializeVelocityConstraints_s_xfA=new Q,Ln.InitializeVelocityConstraints_s_xfB=new Q,Ln.InitializeVelocityConstraints_s_worldManifold=new Lt,Ln.WarmStart_s_P=new j,Ln.SolveVelocityConstraints_s_dv=new j,Ln.SolveVelocityConstraints_s_dv1=new j,Ln.SolveVelocityConstraints_s_dv2=new j,Ln.SolveVelocityConstraints_s_P=new j,Ln.SolveVelocityConstraints_s_a=new j,Ln.SolveVelocityConstraints_s_b=new j,Ln.SolveVelocityConstraints_s_x=new j,Ln.SolveVelocityConstraints_s_d=new j,Ln.SolveVelocityConstraints_s_P1=new j,Ln.SolveVelocityConstraints_s_P2=new j,Ln.SolveVelocityConstraints_s_P1P2=new j,Ln.SolvePositionConstraints_s_xfA=new Q,Ln.SolvePositionConstraints_s_xfB=new Q,Ln.SolvePositionConstraints_s_psm=new Mn,Ln.SolvePositionConstraints_s_rA=new j,Ln.SolvePositionConstraints_s_rB=new j,Ln.SolvePositionConstraints_s_P=new j,Ln.SolveTOIPositionConstraints_s_xfA=new Q,Ln.SolveTOIPositionConstraints_s_xfB=new Q,Ln.SolveTOIPositionConstraints_s_psm=new Mn,Ln.SolveTOIPositionConstraints_s_rA=new j,Ln.SolveTOIPositionConstraints_s_rB=new j,Ln.SolveTOIPositionConstraints_s_P=new j;var Nn,Fn=function(){function e(){this.m_bodies=[],this.m_contacts=[],this.m_joints=[],this.m_positions=wn.MakeArray(1024),this.m_velocities=xn.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/x.Length();C.SelfMul(R)}var I=h*w;I*I>g&&(w*=m/D(I)),b.x+=h*C.x,b.y+=h*C.y,E+=h*w,this.m_positions[A].a=E,this.m_velocities[A].w=w}a.Reset();for(var B=!1,O=0;O.0012184696791469947||j.DotVV(z.m_linearVelocity,z.m_linearVelocity)>1e-4?(z.m_sleepTime=0,G=0):(z.m_sleepTime+=h,G=P(G,z.m_sleepTime)))}if(G>=.5&&B)for(var H=0;H4){var v=2/y.Length();f.SelfMul(v)}var S=l*p;S*S>g&&(p*=m/D(S)),_.SelfMulAdd(l,f),d+=l*p,this.m_positions[c].a=d,this.m_velocities[c].w=p;var T=this.m_bodies[c];T.m_sweep.c.Copy(_),T.m_sweep.a=d,T.m_linearVelocity.Copy(f),T.m_angularVelocity=p,T.SynchronizeTransform()}this.Report(a.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 j;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&&d>=0&&_0&&u.Push(new qn(p-1,m,g-1,y)),m>0&&u.Push(new qn(p,m-1,g-this.m_countX,y)),pk*k+V*V&&(this.m_diagram[P]=L,B>0&&u.Push(new qn(B-1,D,P-1,L)),D>0&&u.Push(new qn(B,D-1,P-this.m_countX,L)),B=i)break;Yn(t,h,i)}}if(0===o)break;r=i,i=s[--o]}return t}function Qn(t,e,i,n){return void 0===e&&(e=0),void 0===i&&(i=t.length-e),void 0===n&&(n=Kn),Jn(t,e,i,n)}function Zn(t,e,i){void 0===i&&(i=t.length);for(var n=0,r=0;r0;){var o=Math.floor(s/2),a=e+o;r(t[a],n)?(e=++a,s-=o+1):s=o}return e}function tr(t,e,i,n,r){for(var s=i-e;s>0;){var o=Math.floor(s/2),a=e+o;r(n,t[a])?s=o:(e=++a,s-=o+1)}return e}function er(t,e,i,n){for(var r=i;e!==r;)Yn(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 j,this.flags=0}var e=t.prototype;return e.SetIndices=function(t,e){this.indexA=t,this.indexB=e},e.SetWeight=function(t){this.weight=t},e.SetNormal=function(t){this.normal.Copy(t)},e.SetFlags=function(t){this.flags=t},e.GetIndexA=function(){return this.indexA},e.GetIndexB=function(){return this.indexB},e.GetWeight=function(){return this.weight},e.GetNormal=function(){return this.normal},e.GetFlags=function(){return this.flags},e.IsEqual=function(t){return this.indexA===t.indexA&&this.indexB===t.indexB&&this.flags===t.flags&&this.weight===t.weight&&this.normal.x===t.normal.x&&this.normal.y===t.normal.y},e.IsNotEqual=function(t){return!this.IsEqual(t)},e.ApproximatelyEqual=function(t){return this.indexA===t.indexA&&this.indexB===t.indexB&&this.flags===t.flags&&D(this.weight-t.weight)<.01&&j.DistanceSquaredVV(this.normal,t.normal)<1e-4},t}(),sr=function(){this.index=0,this.weight=0,this.normal=new j,this.mass=0},or=function(){this.indexA=0,this.indexB=0,this.flags=0,this.strength=0,this.distance=0},ar=function(){this.indexA=0,this.indexB=0,this.indexC=0,this.flags=0,this.strength=0,this.pa=new j(0,0),this.pb=new j(0,0),this.pc=new j(0,0),this.ka=0,this.kb=0,this.kc=0,this.s=0},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 or})),this.m_triadBuffer=new ir((function(){return new ar})),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 y;this.DestroyOldestParticle(0,!1),this.SolveZombie()}var n=this.m_count++;this.m_flagsBuffer.data[n]=0,this.m_lastBodyContactStepBuffer.data&&(this.m_lastBodyContactStepBuffer.data[n]=0),this.m_bodyContactCountBuffer.data&&(this.m_bodyContactCountBuffer.data[n]=0),this.m_consecutiveContactStepsBuffer.data&&(this.m_consecutiveContactStepsBuffer.data[n]=0),this.m_positionBuffer.data[n]=(this.m_positionBuffer.data[n]||new j).Copy(e(t.position,j.ZERO)),this.m_velocityBuffer.data[n]=(this.m_velocityBuffer.data[n]||new j).Copy(e(t.velocity,j.ZERO)),this.m_weightBuffer[n]=0,this.m_forceBuffer[n]=(this.m_forceBuffer[n]||new j).SetZero(),this.m_staticPressureBuffer&&(this.m_staticPressureBuffer[n]=0),this.m_depthBuffer&&(this.m_depthBuffer[n]=0);var r=(new tt).Copy(e(t.color,tt.ZERO));!this.m_colorBuffer.data&&r.IsZero()||(this.m_colorBuffer.data=this.RequestBuffer(this.m_colorBuffer.data),this.m_colorBuffer.data[n]=(this.m_colorBuffer.data[n]||new tt).Copy(r)),(this.m_userDataBuffer.data||t.userData)&&(this.m_userDataBuffer.data=this.RequestBuffer(this.m_userDataBuffer.data),this.m_userDataBuffer.data[n]=t.userData),this.m_handleIndexBuffer.data&&(this.m_handleIndexBuffer.data[n]=null);var s=this.m_proxyBuffer.data[this.m_proxyBuffer.Append()],o=e(t.lifetime,0),a=o>0;(this.m_expirationTimeBuffer.data||a)&&(this.SetParticleLifetime(n,a?o: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 yr(this,t,e,i),o=r;return t.ComputeAABB(o,e,0),this.m_world.QueryAABB(s,o),s.Destroyed()},r.CreateParticleGroup=function(t){var i=n.CreateParticleGroup_s_transform;if(this.m_world.IsLocked())throw new Error;var r=i;r.SetPositionAngle(e(t.position,j.ZERO),e(t.angle,0));var s=this.m_count;if(t.shape&&this.CreateParticlesWithShapeForGroup(t.shape,t,r),t.shapes&&this.CreateParticlesWithShapesForGroup(t.shapes,e(t.shapeCount,t.shapes.length),t,r),t.positionData)for(var o=e(t.particleCount,t.positionData.length),a=0;a0&&(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;o!==this.m_expirationTimeBuffer.data[t]&&(this.m_expirationTimeBuffer.data[t]=o,this.m_expirationTimeBufferRequiresSorting=!0)},r.GetParticleLifetime=function(t){return this.ExpirationTimeToLifetime(this.GetExpirationTimeBuffer()[t])},r.SetDestructionByAge=function(t){t&&this.GetExpirationTimeBuffer(),this.m_def.destroyByAge=t},r.GetDestructionByAge=function(){return this.m_def.destroyByAge},r.GetExpirationTimeBuffer=function(){return this.m_expirationTimeBuffer.data=this.RequestBuffer(this.m_expirationTimeBuffer.data),this.m_expirationTimeBuffer.data},r.ExpirationTimeToLifetime=function(t){return(t>0?t-this.GetQuantizedTimeElapsed():t)*this.m_def.lifetimeGranularity},r.GetIndexByExpirationTimeBuffer=function(){return this.GetParticleCount()?this.SetParticleLifetime(0,this.GetParticleLifetime(0)):this.m_indexByExpirationTimeBuffer.data=this.RequestBuffer(this.m_indexByExpirationTimeBuffer.data),this.m_indexByExpirationTimeBuffer.data},r.ParticleApplyLinearImpulse=function(t,e){this.ApplyLinearImpulse(t,t+1,e)},r.ApplyLinearImpulse=function(t,e,i){for(var n=this.m_velocityBuffer.data,r=(e-t)*this.GetParticleMass(),s=(new j).Copy(i).SelfMul(1/r),o=t;o=0;){var m=j.SubVV(e,u[c],s),g=j.DotVV(m,d),y=g*g-f*(j.DotVV(m,m)-this.m_squaredDiameter);if(y>=0){var v=k(y),S=(-g-v)/f;if(S>_)continue;if(S<0&&((S=(-g+v)/f)<0||S>_))continue;var T=j.AddVMulSV(m,S,d,a);if(T.Normalize(),(_=P(_,t.ReportParticle(this,c,j.AddVMulSV(e,S,d,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),Q.MulXV(i,n,r.position),j.AddVV(e(t.linearVelocity,j.ZERO),j.CrossSV(e(t.angularVelocity,0),j.SubVV(r.position,e(t.position,j.ZERO),j.s_t0),j.s_t0),r.velocity),r.color.Copy(e(t.color,tt.ZERO)),r.lifetime=e(t.lifetime,0),r.userData=t.userData,this.CreateParticle(r)},r.CreateParticlesStrokeShapeForGroup=function(i,r,s){var o=n.CreateParticlesStrokeShapeForGroup_s_edge,a=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&&d=e&&fy||j.DotVV(m,m)>y||j.DotVV(g,g)>y)return;var v=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=P(P(v?v.m_strength:1,S?S.m_strength:1),T?T.m_strength:1);var b=(_.x+d.x+f.x)/3,E=(_.y+d.y+f.y)/3;A.pa.x=_.x-b,A.pa.y=_.y-E,A.pb.x=d.x-b,A.pb.y=d.y-E,A.pc.x=f.x-b,A.pc.y=f.y-E,A.ka=-j.DotVV(g,p),A.kb=-j.DotVV(p,m),A.kc=-j.DotVV(m,g),A.s=j.CrossVV(_,d)+j.CrossVV(d,f)+j.CrossVV(f,_)}})),Qn(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;EO&&(this.m_depthBuffer[R]=O,C=!0),P>M&&(this.m_depthBuffer[I]=M,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 o=this.UpdateBodyContacts_callback;o.m_contactFilter=this.GetFixtureContactFilter(),this.m_world.QueryAABB(o,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=j.MulSV(t.dt*this.m_def.gravityScale,this.m_world.GetGravity(),e),s=0;s=0;){var L=p[M],N=this.m_groupBuffer[M];if(x!==N&&R!==N){var F=this.GetLinearVelocity(N,M,L,h),V=j.SubVV(L,E,u),G=j.SubVV(F,I,l),U=j.CrossVV(P,G),z=j.CrossVV(D,G)-j.CrossVV(V,P),H=j.CrossVV(D,V),W=void 0,X=void 0,q=c,Y=_;if(0===U){if(0===z)continue;if(!((X=-H/z)>=0&&X=0&&W<=1))continue}else{var K=z*z-4*H*U;if(K<0)continue;var J=k(K),Q=(-z-J)/(2*U),Z=(-z+J)/(2*U);if(Q>Z){var $=Q;Q=Z,Z=$}if(X=Q,j.AddVMulSV(D,X,P,q),j.AddVMulSV(V,X,G,Y),W=j.DotVV(q,Y)/j.DotVV(q,q),!(X>=0&&X=0&&W<=1)){if(!((X=Z)>=0&&X=0&&W<=1))continue}}var tt=d;tt.x=I.x+W*P.x-F.x,tt.y=I.y+W*P.y-F.y;var et=j.MulSV(v,tt,f);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+=j.CrossVV(j.SubVV(L,N.GetCenter(),j.s_t0),et)/nt)}else m[M].SelfAdd(tt);this.ParticleApplyForce(M,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,o=0;oa){var d=l.body,f=l.mass,p=r[c],m=l.normal,g=j.MulSV(o*f*(_-a),m,i);s[c].SelfMulSub(h,g),d.ApplyLinearImpulse(g,p,!0)}}}for(var y=0;ya){var T=v.indexA,A=v.indexB,b=v.normal,E=j.MulSV(o*(S-a),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?(w=P(w,B),x=O(x,B+1)):R=!0}wr:s})),this.m_expirationTimeBufferRequiresSorting=!1);for(var s=r-1;s>=0;--s){var o=n[s],a=i[o];if(ee.weight:t.index3)return!0;var a=t.Copy(n.normal);a.SelfMul(r.m_particleDiameter*(1-n.weight));var h=j.AddVV(r.m_positionBuffer.data[n.index],a,e);if(!n.fixture.TestPoint(h)){for(var u=n.fixture.GetShape().GetChildCount(),c=0;cthis.m_stuckThreshold&&(this.m_stuckParticleBuffer.data[this.m_stuckParticleBuffer.Append()]=t)),this.m_lastBodyContactStepBuffer.data[t]=this.m_timestamp)},r.ValidateParticleIndex=function(t){return t>=0&&t0?1/n:0,e[0]=r>0?1/r:0,i[0]=j.CrossVV(j.SubVV(o,s,j.s_t0),a)},r.InitDampingParameterWithRigidGroupOrParticle=function(e,i,n,r,s,o,a,h){if(s&&r)this.InitDampingParameter(e,i,n,s.GetMass(),s.GetInertia(),s.GetCenter(),a,h);else{var u=this.m_flagsBuffer.data[o];this.InitDampingParameter(e,i,n,u&t.b2ParticleFlag.b2_wallParticle?0:this.GetParticleMass(),0,a,a,h)}},r.ComputeDampingImpulse=function(t,e,i,n,r,s,o){var a=t+e*i*i+n+r*s*s;return a>0?o/a:0},r.ApplyDamping=function(t,e,i,n,r,s,o,a){r&&n?(r.m_linearVelocity.SelfMulAdd(o*t,a),r.m_angularVelocity+=o*i*e):this.m_velocityBuffer.data[s].SelfMulAdd(o*t,a)},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 y},t}(),dr=function(){this.next=null,this.count=0,this.index=0},fr=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 y},e}(fr),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 y},e}(fr),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}(),yr=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),vr=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=d>0?1/d:0,m=this.m_system.m_flagsBuffer.data[r]&t.b2ParticleFlag.b2_wallParticle?0:this.m_system.GetParticleInvMass(),g=j.SubVV(a,c,o),y=j.CrossVV(g,h),v=m+f+p*y*y,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=v>0?1/v:0,this.m_system.DetectStuckParticle(r)}},i}(nr);Ar.ReportFixtureAndParticle_s_n=new j,Ar.ReportFixtureAndParticle_s_rp=new j;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,o=i.ReportFixtureAndParticle_s_output,a=i.ReportFixtureAndParticle_s_input,h=i.ReportFixtureAndParticle_s_p,u=i.ReportFixtureAndParticle_s_v,c=i.ReportFixtureAndParticle_s_f,_=e.GetBody(),d=this.m_system.m_positionBuffer.data[r],f=this.m_system.m_velocityBuffer.data[r],p=o,m=a;if(0===this.m_system.m_iterationIndex){var g=Q.MulTXV(_.m_xf0,d,s);e.GetShape().GetType()===t.b2ShapeType.e_circleShape&&(g.SelfSub(_.GetLocalCenter()),J.MulRV(_.m_xf0.q,g,g),J.MulTRV(_.m_xf.q,g,g),g.SelfAdd(_.GetLocalCenter())),Q.MulXV(_.m_xf,g,m.p1)}else m.p1.Copy(d);if(j.AddVMulSV(d,this.m_step.dt,f,m.p2),m.maxFraction=1,e.RayCast(p,m,n)){var y=p.normal,v=h;v.x=(1-p.fraction)*m.p1.x+p.fraction*m.p2.x+l*y.x,v.y=(1-p.fraction)*m.p1.y+p.fraction*m.p2.y+l*y.y;var S=u;S.x=this.m_step.inv_dt*(v.x-d.x),S.y=this.m_step.inv_dt*(v.y-d.y),this.m_system.m_velocityBuffer.data[r].Copy(S);var T=c;T.x=this.m_step.inv_dt*this.m_system.GetParticleMass()*(f.x-S.x),T.y=this.m_step.inv_dt*this.m_system.GetParticleMass()*(f.y-S.y),this.m_system.ParticleApplyForce(r,T)}},n.ReportParticle=function(){return!1},i}(nr);br.ReportFixtureAndParticle_s_p1=new j,br.ReportFixtureAndParticle_s_output=new kt,br.ReportFixtureAndParticle_s_input=new Ft,br.ReportFixtureAndParticle_s_p=new j,br.ReportFixtureAndParticle_s_v=new j,br.ReportFixtureAndParticle_s_f=new j;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 j,this.m_allowSleep=!0,this.m_destructionListener=null,this.m_debugDraw=null,this.m_inv_dt0=0,this.m_warmStarting=!0,this.m_continuousPhysics=!0,this.m_subStepping=!1,this.m_stepComplete=!0,this.m_profile=new 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 o=s;s=s.next,this.m_contactManager.Destroy(o.contact)}t.m_contactList=null;for(var a=t.m_fixtureList;a;){var h=a;a=a.m_next,this.m_destructionListener&&this.m_destructionListener.SayGoodbyeFixture(h),h.DestroyProxies(),h.Reset(),t.m_fixtureList=a,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 Mi(e);case t.b2JointType.e_mouseJoint:return new Wi(e);case t.b2JointType.e_prismaticJoint:return new Xi(e);case t.b2JointType.e_revoluteJoint:return new Ji(e);case t.b2JointType.e_pulleyJoint:return new Yi(e);case t.b2JointType.e_gearJoint:return new Gi(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 Zi(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 Vn(this.m_gravity.Length(),function(t){for(var e=i,n=t.GetParticleSystemList();null!==n;n=n.m_next)e=P(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 o=e.Step_s_step;o.dt=t,o.velocityIterations=i,o.positionIterations=n,o.particleIterations=r,o.inv_dt=t>0?1/t:0,o.dtRatio=this.m_inv_dt0*t,o.warmStarting=this.m_warmStarting;var a=e.Step_s_timer.Reset();if(this.m_contactManager.Collide(),this.m_profile.collide=a.GetMilliseconds(),this.m_stepComplete&&o.dt>0){for(var h=e.Step_s_timer.Reset(),u=this.m_particleSystemList;u;u=u.m_next)u.Solve(o);this.Solve(o),this.m_profile.solve=h.GetMilliseconds()}if(this.m_continuousPhysics&&o.dt>0){var l=e.Step_s_timer.Reset();this.SolveTOI(o),this.m_profile.solveTOI=l.GetMilliseconds()}o.dt>0&&(this.m_inv_dt0=o.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 o=r.GetFixtureList();o;o=o.m_next)r.IsActive()?r.GetType()===t.b2BodyType.b2_staticBody?(n.SetRGB(.5,.9,.5),this.DrawShape(o,n)):r.GetType()===t.b2BodyType.b2_kinematicBody?(n.SetRGB(.5,.5,.9),this.DrawShape(o,n)):r.IsAwake()?(n.SetRGB(.9,.7,.7),this.DrawShape(o,n)):(n.SetRGB(.6,.6,.6),this.DrawShape(o,n)):(n.SetRGB(.5,.5,.3),this.DrawShape(o,n));this.m_debugDraw.PopTransform(s)}if(i&t.b2DrawFlags.e_particleBit)for(var a=this.m_particleSystemList;a;a=a.m_next)this.DrawParticleSystem(a);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 d=_.contact;if(!d.m_islandFlag&&d.IsEnabled()&&d.IsTouching()){var f=d.m_fixtureA.m_isSensor,p=d.m_fixtureB.m_isSensor;if(!f&&!p){r.AddContact(d),d.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 y=g.other;y.IsActive()&&(r.AddJoint(g.joint),g.joint.m_islandFlag=!0,y.m_islandFlag||(h[l++]=y,y.m_islandFlag=!0))}}}var v=new En;r.Solve(v,e,this.m_gravity,this.m_allowSleep),this.m_profile.solveInit+=v.solveInit,this.m_profile.solveVelocity+=v.solveVelocity,this.m_profile.solvePosition+=v.solvePosition;for(var 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(),d=c.GetBody(),f=_.m_type,p=d.m_type,m=_.IsAwake()&&f!==t.b2BodyType.b2_staticBody,g=d.IsAwake()&&p!==t.b2BodyType.b2_staticBody;if(!m&&!g)continue;var y=_.IsBullet()||f!==t.b2BodyType.b2_dynamicBody,v=d.IsBullet()||p!==t.b2BodyType.b2_dynamicBody;if(!y&&!v)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 o=s.GetWorldVector(Y.MulMV(this.T,s.GetLocalVector(s.GetLinearVelocity(),j.s_t0),j.s_t1),e.Step_s_damping);s.SetLinearVelocity(j.AddVV(s.GetLinearVelocity(),j.MulSV(i,o,j.s_t0),j.s_t1))}}}},i.Draw=function(){},i.SetAxisAligned=function(t,e){this.T.ex.x=-t,this.T.ex.y=0,this.T.ey.x=0,this.T.ey.y=-e,this.maxTimestep=t>0||e>0?1/O(t,e):0},e}(wr);Dr.Step_s_damping=new j;var Pr=function(){function t(){this.m_count=0,this.m_ps=[],this.m_p0s=[],this.m_vs=[],this.m_ims=[],this.m_Ls=[],this.m_as=[],this.m_gravity=new j,this.m_damping=0,this.m_k2=1,this.m_k3=.1}var e=t.prototype;return e.GetVertexCount=function(){return this.m_count},e.GetVertices=function(){return this.m_ps},e.Initialize=function(t){this.m_count=t.count,this.m_ps=j.MakeArray(this.m_count),this.m_p0s=j.MakeArray(this.m_count),this.m_vs=j.MakeArray(this.m_count),this.m_ims=x(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=x(n),this.m_as=x(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;ra;)b=(m-=2*a)-this.m_as[i];for(;b<-a;)b=(m+=2*a)-this.m_as[i];var E=-this.m_k3*A*b;n.SelfMulAdd(o*E,v),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=Pi,t.b2JointDef=Di,t.b2JointEdge=Bi,t.b2Log=function(){},t.b2MakeArray=w,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=Qt,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=or,t.b2ParticlePairSet=mr,t.b2ParticleSystem=ur,t.b2ParticleSystemDef=hr,t.b2ParticleSystem_CompositeShape=Sr,t.b2ParticleSystem_ConnectionFilter=gr,t.b2ParticleSystem_DestroyParticlesInShapeCallback=yr,t.b2ParticleSystem_FixedSetAllocator=fr,t.b2ParticleSystem_FixtureParticle=function(t,e){this.second=y,this.first=t,this.second=e},t.b2ParticleSystem_FixtureParticleSet=pr,t.b2ParticleSystem_InsideBoundsEnumerator=_r,t.b2ParticleSystem_JoinParticleGroupsFilter=vr,t.b2ParticleSystem_ParticleListNode=dr,t.b2ParticleSystem_ParticlePair=function(t,e){this.first=y,this.second=y,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=ar,t.b2PolygonAndCircleContact=ln,t.b2PolygonContact=un,t.b2PolygonShape=yi,t.b2Position=wn,t.b2PositionSolverManifold=Mn,t.b2Pow=V,t.b2PrismaticJoint=Xi,t.b2PrismaticJointDef=ji,t.b2Profile=En,t.b2PulleyJoint=Yi,t.b2PulleyJointDef=qi,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=Ji,t.b2RevoluteJointDef=Ki,t.b2Rope=Pr,t.b2RopeDef=function(){this.vertices=[],this.count=0,this.masses=[],this.gravity=new j(0,0),this.damping=.1,this.k2=.9,this.k3=.1},t.b2RopeJoint=Zi,t.b2RopeJointDef=Qi,t.b2Rot=J,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=O(i.m_radius,_)+O(n.m_radius,_),s=e.transformA,o=e.transformB,a=e.translationB,h=Tt.Set(0,0),u=0,l=At;l.m_count=0;for(var c=l.m_vertices,d=i.GetSupport(J.MulTRV(s.q,j.NegV(a,j.s_t1),j.s_t0)),f=Q.MulXV(s,i.GetVertex(d),bt),p=n.GetSupport(J.MulTRV(o.q,a,j.s_t0)),m=Q.MulXV(o,n.GetVertex(p),Et),g=j.SubVV(f,m,Ct),y=O(_,r-_),v=0;v<20&&D(g.Length()-y)>.004;){t.iterations+=1,d=i.GetSupport(J.MulTRV(s.q,j.NegV(g,j.s_t1),j.s_t0)),f=Q.MulXV(s,i.GetVertex(d),bt),p=n.GetSupport(J.MulTRV(o.q,g,j.s_t0)),m=Q.MulXV(o,n.GetVertex(p),Et);var S=j.SubVV(f,m,wt);g.Normalize();var T=j.DotVV(g,S),A=j.DotVV(g,a);if(T-y>u*A){if(A<=0)return!1;if((u=(T-y)/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,a),b.indexB=d,b.wB.Copy(f),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),++v}var E=xt,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=v,!0},t.b2ShapeCastInput=function(){this.proxyA=new st,this.proxyB=new st,this.transformA=new Q,this.transformB=new Q,this.translationB=new j},t.b2ShapeCastOutput=function(){this.point=new j,this.normal=new j,this.lambda=0,this.iterations=0},t.b2Simplex=lt,t.b2SimplexCache=ot,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=Dr,t.b2TestOverlapAABB=Gt,t.b2TestOverlapShape=jt,t.b2TimeOfImpact=Te,t.b2TimeStep=Cn,t.b2Timer=it,t.b2Transform=Q,t.b2TreeNode=qt,t.b2Vec2=j,t.b2Vec2_zero=X,t.b2Vec3=q,t.b2Velocity=xn,t.b2VelocityConstraintPoint=Bn,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=o,t.b2_gjk_reset=function(){t.b2_gjkCalls=0,t.b2_gjkIters=0,t.b2_gjkMaxIters=0},t.b2_invalidParticleIndex=y,t.b2_linearSleepTolerance=A,t.b2_linearSlop=l,t.b2_maxAngularCorrection=p,t.b2_maxFloat=i,t.b2_maxLinearCorrection=f,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=v,t.b2_pi=a,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=B,t.b2_velocityThreshold=1,t.b2_version=C,t.g_blockSolve=In,Object.defineProperty(t,"__esModule",{value:!0})}(e)}));(ett=itt)&&ett.__esModule&&Object.prototype.hasOwnProperty.call(ett,"default")&&ett.default;var ntt={};for(var rtt in itt)-1===rtt.indexOf("b2_")&&(ntt[rtt.replace("b2","")]=itt[rtt]);var stt=ntt,ott=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r0}function ftt(t,e,i){return Ttt(t,e,i)>=0}function ptt(t,e,i){return Ttt(t,e,i)<=0}function mtt(t,e){var i=e.x-t.x,n=e.y-t.y;return i*i+n*n}function gtt(t){ytt(t)||t.reverse()}function ytt(t){return t.length<3||function(t){var e,i=0;for(e=0;e0}function vtt(t,e,i,n){var r,s=new Ln,o=e.y-t.y,a=t.x-e.x,h=o*t.x+a*t.y,u=n.y-i.y,l=i.x-n.x,c=u*i.x+l*i.y,_=o*l-u*a;return r=_,0,Math.abs(r-0)<=1e-6||(s.x=(l*h-a*c)/_,s.y=(o*c-u*h)/_),s}function Stt(t,e,i,n,r){if(t==i||t==n||e==i||e==n)return!1;var s=t.x,o=t.y,a=e.x,h=e.y,u=i.x,l=i.y,c=n.x,_=n.y;if(Math.max(s,a)0&&d<1&&f>0&&f<1&&(r.x=s+d*(a-s),r.y=o+d*(h-o),!0))}function Ttt(t,e,i){return t.x*(e.y-i.y)+e.x*(i.y-t.y)+i.x*(t.y-e.y)}var Att=Object.freeze({__proto__:null,ConvexPartition:function t(e){gtt(e);for(var i,n,r,s,o,a,h=[],u=new Ln,l=new Ln,c=0,_=0,d=0;dm&&(g=y,m=v)}o=utt(d,g,e),a=utt(g,d,e)}return(h=h.concat(t(o))).concat(t(a))}h.push(e);for(var S=h.length-1;S>=0;S--)0==h[S].length&&h.splice(S,0);return h},ForceCounterClockWise:gtt,IsCounterClockWise:ytt});function btt(t){Rtt(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,Btt(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 o=s.splice(0,1)[0],a=0,h=o.length;a0||Ctt(c,l,o[(a+2)%h])>0)){for(var m=[],g=(a+1)%h;g!==a;g=(g+1)%h)m.push(o[g]);m.push(u,c),o=m,h=m.length,a=-1,s.splice(_,1)}}r.push(o)}return r}var Ett=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 Ctt(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function wtt(t,e,i){return Ctt(t,e,i)<0}function xtt(t,e){return t.x===e.x&&t.y===e.y}function Rtt(t){(function(t){for(var e=0,i=0,n=t.length;i0})(t)&&t.reverse()}function Itt(t,e){if(t.shouldUpdate){t.shouldUpdate=!1;var i=t.prev.point,n=t.point,r=t.next.point;t.isConvex=wtt(i,n,r);var s=i.x-n.x,o=i.y-n.y,a=Math.sqrt(s*s+o*o);s/=a,o/=a;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+o*u,t.isConvex){t.isEar=!0;for(var c=0,_=e.length;c<_;++c){var d=e[c];if(d.isActive&&d!==t){var f=d.point;if(!(xtt(i,f)||xtt(n,f)||xtt(r,f))){var p=Ctt(i,f,n),m=Ctt(n,f,r),g=Ctt(r,f,i);if(p>0&&m>0&&g>0){t.isEar=!1;break}if(0===p&&m>=0&&g>=0&&(Ctt(i,d.prev.point,n)>0||Ctt(i,d.next.point,n)>0)){t.isEar=!1;break}if(0===m&&p>=0&&g>=0&&(Ctt(n,d.prev.point,r)>0||Ctt(n,d.next.point,r)>0)){t.isEar=!1;break}if(0===g&&p>=0&&m>=0&&(Ctt(r,d.prev.point,i)>0||Ctt(r,d.next.point,i)>0)){t.isEar=!1;break}}}}}else t.isEar=!1}}function Btt(t){for(var e=t,i=t;;)if(xtt(e.point,e.next.point)||0===Ctt(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 Dtt,Ptt,Ott,Mtt,Ltt,Ntt,Ftt,ktt,Vtt,Gtt,Utt,ztt=Object.freeze({__proto__:null,ConvexPartition:btt});t("fK",Dtt),function(t){t[t.DYNAMIC=1]="DYNAMIC",t[t.STATIC=2]="STATIC",t[t.KINEMATIC=4]="KINEMATIC"}(Dtt||t("fK",Dtt={})),ge(Dtt),t("fJ",Ptt),function(t){t[t.X_AXIS=0]="X_AXIS",t[t.Y_AXIS=1]="Y_AXIS",t[t.Z_AXIS=2]="Z_AXIS"}(Ptt||t("fJ",Ptt={})),ge(Ptt),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"}(Ott||(Ott={})),ge(Ott),function(t){t[t.VERTEX=1]="VERTEX",t[t.LINE=2]="LINE",t[t.TRIANGLE=3]="TRIANGLE",t[t.TETRAHEDRON=4]="TETRAHEDRON"}(Mtt||(Mtt={})),ge(Mtt),t("fL",Ltt),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"}(Ltt||t("fL",Ltt={})),ge(Ltt),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"}(Ntt||(Ntt={})),ge(Ntt),function(t){t[t.FREE=0]="FREE",t[t.LIMITED=1]="LIMITED",t[t.LOCKED=2]="LOCKED"}(Ftt||(Ftt={})),ge(Ftt),function(t){t[t.DISABLED=0]="DISABLED",t[t.SERVO=1]="SERVO",t[t.INDUCTION=2]="INDUCTION"}(ktt||(ktt={})),ge(ktt),function(t){t[t.BOX=0]="BOX",t[t.CAPSULE=1]="CAPSULE"}(Vtt||(Vtt={})),ge(Vtt),function(t){t[t.DEFAULT=1]="DEFAULT"}(Gtt||(Gtt={})),ge(Gtt),t("fM",Utt),function(t){t[t.NONE=0]="NONE",t[t.WIRE_FRAME=1]="WIRE_FRAME",t[t.CONSTRAINT=2]="CONSTRAINT",t[t.AABB=4]="AABB"}(Utt||t("fM",Utt={})),ge(Utt);var Htt=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,o=0,a=s.length;o=U9.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}(stt.RayCastCallback),art=[],hrt=[new Ln,new Ln],urt=new stt.WorldManifold,lrt={points:[],separations:[],normal:new Ln},crt=function(){this.localPoint=new Ln,this.normalImpulse=0,this.tangentImpulse=0},_rt=[new crt,new crt],drt={type:0,localPoint:new Ln,localNormal:new Ln,points:[]},frt={normalImpulses:[],tangentImpulses:[]},prt=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=art.pop();return i||(i=new t),i.init(e),i},t.put=function(t){var e=t.m_userData;e&&(art.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=lrt.points,e=lrt.separations,i=lrt.normal;this._b2contact.GetWorldManifold(urt);var n=urt.points,r=urt.separations,s=this._b2contact.GetManifold().pointCount;t.length=e.length=s;for(var o=0;o0){for(var o=r.getPoints(),a=r.getNormals(),h=r.getFractions(),u=[],l=0,c=s.length;lMath.PI&&(r-=bi);var s=(this._animatedAngle-r)*n;this._animatedAngle<-Ai&&r>Ai&&(s=(this._animatedAngle+bi-r)*n),this._animatedAngle>Ai&&r<-Ai&&(s=(this._animatedAngle-bi-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===F9.Animated?e.GetLinearVelocity():e.GetPosition()).x=n.x/X9,i.y=n.y/X9,r===F9.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=Rrt;Sn.toEulerInYXZOrder(n,i);var r=Bi(n.z);this._rigidBody.type===F9.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 Irt.Set(t.x/X9,t.y/X9),this._body.GetLinearVelocityFromWorldPoint(Irt,e),e.x*=X9,e.y*=X9,e},e.setAngularVelocity=function(t){this._body.SetAngularVelocity(t)},e.getAngularVelocity=function(){return Di(this._body.GetAngularVelocity())},e.getLocalVector=function(t,e){return e=e||new Ln,Irt.Set(t.x/X9,t.y/X9),this._body.GetLocalVector(Irt,e),e.x*=X9,e.y*=X9,e},e.getWorldVector=function(t,e){return Irt.Set(t.x/X9,t.y/X9),this._body.GetWorldVector(Irt,e),e.x*=X9,e.y*=X9,e},e.getLocalPoint=function(t,e){return e=e||new Ln,Irt.Set(t.x/X9,t.y/X9),this._body.GetLocalPoint(Irt,e),e.x*=X9,e.y*=X9,e},e.getWorldPoint=function(t,e){return e=e||new Ln,Irt.Set(t.x/X9,t.y/X9),this._body.GetWorldPoint(Irt,e),e.x*=X9,e.y*=X9,e},e.getLocalCenter=function(t){t=t||new Ln;var e=this._body.GetLocalCenter();return t.x=e.x*X9,t.y=e.y*X9,t},e.getWorldCenter=function(t){t=t||new Ln;var e=this._body.GetWorldCenter();return t.x=e.x*X9,t.y=e.y*X9,t},e.getInertia=function(){return this._body.GetInertia()},e.applyForce=function(t,e,i){this._body&&(Irt.Set(e.x/X9,e.y/X9),this._body.ApplyForce(t,Irt,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&&(Irt.Set(e.x/X9,e.y/X9),this._body.ApplyLinearImpulse(t,Irt,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}(),Drt=new stt.Filter,Prt=new stt.Vec2,Ort=new stt.Vec2;function Mrt(t){var e=t.collider;return e.body?Drt.categoryBits=e.group===Gtt.DEFAULT?e.body.group:e.group:Drt.categoryBits=e.group,Drt.maskBits=get.instance.collisionMatrix[Drt.categoryBits],Drt}var Lrt,Nrt=function(){function t(){this._shapes=[],this._fixtures=[],this._collider=null,this._body=null,this._inited=!1,this._rect=new Un}var e=t.prototype;return e.initialize=function(t){this._collider=t},e.onLoad=function(){},e.onEnable=function(){get.instance._callAfterStep(this,this._init)},e.onDisable=function(){get.instance._callAfterStep(this,this._destroy)},e.start=function(){},e.onGroupChanged=function(){var t=Mrt(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=on.ZERO,n=t.getComponent(Znt);n&&n.impl&&n.impl.impl?this._body=n.impl.impl:(this._body=get.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=Mrt(this),o=0;o=0;i--){var n=t[i];n.m_userData=null,get.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,o=0;on&&(n=Ort.x),Ort.y>r&&(r=Ort.y)}e*=X9,i*=X9,n*=X9,r*=X9;var c=this._rect;return c.x=e,c.y=i,c.width=n-e,c.height=r-i,c}}]),t}(),Frt=new Un,krt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r0&&o[0].equals(o[o.length-1])&&(o.length-=1);var a=btt(o);if(!a)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){Ci(this._friction,t)||(this._friction=t,this.emit(e.EVENT_UPDATE))}},{key:"rollingFriction",get:function(){return this._rollingFriction},set:function(t){Ci(this._rollingFriction,t)||(this._rollingFriction=t,this.emit(e.EVENT_UPDATE))}},{key:"spinningFriction",get:function(){return this._spinningFriction},set:function(t){Ci(this._spinningFriction,t)||(this._spinningFriction=t,this.emit(e.EVENT_UPDATE))}},{key:"restitution",get:function(){return this._restitution},set:function(t){Ci(this._restitution,t)||(this._restitution=t,this.emit(e.EVENT_UPDATE))}}]),e}(of)).allMaterials=[],Fst.EVENT_UPDATE="event_update",Fst._idCounter=0,p((Pst=Fst).prototype,"friction",[xst],Object.getOwnPropertyDescriptor(Pst.prototype,"friction"),Pst.prototype),p(Pst.prototype,"rollingFriction",[Rst],Object.getOwnPropertyDescriptor(Pst.prototype,"rollingFriction"),Pst.prototype),p(Pst.prototype,"spinningFriction",[Ist],Object.getOwnPropertyDescriptor(Pst.prototype,"spinningFriction"),Pst.prototype),p(Pst.prototype,"restitution",[Bst],Object.getOwnPropertyDescriptor(Pst.prototype,"restitution"),Pst.prototype),Ost=ks(Pst.prototype,"_friction",[io],(function(){return.6})),Mst=ks(Pst.prototype,"_rollingFriction",[io],(function(){return 0})),Lst=ks(Pst.prototype,"_spinningFriction",[io],(function(){return 0})),Nst=ks(Pst.prototype,"_restitution",[io],(function(){return 0})),Dst=Pst))||Dst)),Xst=t("fq",function(){function t(){this._hitPoint=new on,this._hitNormal=new on,this._distance=0,this._collider=null}var e=t.prototype;return e._assign=function(t,e,i,n){on.copy(this._hitPoint,t),on.copy(this._hitNormal,n),this._distance=e,this._collider=i},e.clone=function(){var e=new t;return on.copy(e._hitPoint,this._hitPoint),on.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}()),qst=t("fr",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++}fN.emit(dN.EVENT_AFTER_PHYSICS)}}else this.physicsWorld.syncSceneToPhysics()},e.resetConfiguration=function(t){var e=t?t.allowSleep:Ee.querySettings(be.Category.PHYSICS,"allowSleep");"boolean"==typeof e&&(this._allowSleep=e);var i=t?t.fixedTimeStep:Ee.querySettings(be.Category.PHYSICS,"fixedTimeStep");"number"==typeof i&&(this._fixedTimeStep=i);var n=t?t.maxSubSteps:Ee.querySettings(be.Category.PHYSICS,"maxSubSteps");"number"==typeof n&&(this._maxSubSteps=n);var r=t?t.sleepThreshold:Ee.querySettings(be.Category.PHYSICS,"sleepThreshold");"number"==typeof r&&(this._sleepThreshold=r);var s=t?t.autoSimulation:Ee.querySettings(be.Category.PHYSICS,"autoSimulation");"boolean"==typeof s&&(this.autoSimulation=s);var o=t?t.gravity:Ee.querySettings(be.Category.PHYSICS,"gravity");o&&on.copy(this._gravity,o);var a=t?t.collisionMatrix:Ee.querySettings(be.Category.PHYSICS,"collisionMatrix");if(a)for(var h in a)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 or,o=1;oi);++o){var a=t[o-1],h=t[o],u=new on;on.subtract(u,h,a);var l=on.len(u);if(r+=l,on.multiplyScalar(u,u,1/l),s.d=u,s.o=a,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 or,o=!1,a=1;ai);++a){var h=t[a-1],u=t[a],l=new on;on.subtract(l,u,h);var c=on.len(l);if(r+=c,on.multiplyScalar(l,l,1/c),s.d=l,s.o=h,o=this.raycastClosest(s,e,c,n)){var _=this.raycastClosestResult,d=new qst;d._assign(_.hitPoint,_.distance,_.collider,_.hitNormal,a-1),this.lineStripCastClosestResult=d;break}}return o},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,o){return void 0===r&&(r=4294967295),void 0===s&&(s=1e7),void 0===o&&(o=!0),!!this.physicsWorld&&(this.sweepResultPool.reset(),this.sweepCastResults.length=0,this.raycastOptions.mask=r>>>0,this.raycastOptions.maxDistance=s,this.raycastOptions.queryTrigger=o,this.physicsWorld.sweepCapsule(t,e,i,n,this.raycastOptions,this.sweepResultPool,this.sweepCastResults))},e.sweepCapsuleClosest=function(t,e,i,n,r,s,o){return void 0===r&&(r=4294967295),void 0===s&&(s=1e7),void 0===o&&(o=!0),!!this.physicsWorld&&(this.raycastOptions.mask=r>>>0,this.raycastOptions.maxDistance=s,this.raycastOptions.queryTrigger=o,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=Ee.querySettings(be.Category.PHYSICS,"enabled"))||void 0===t||t)&&!i._instance){var e=new i;i._instance=e,e.resetConfiguration(),function(t){if(Lrt||(Lrt=t),$rt.runInEditor&&!$rt.physicsWorld){F("[PHYSICS]: using "+$rt.id+".");var e=$rt.physicsWorld=nst();e.setGravity(Lrt.gravity),e.setAllowSleep(Lrt.allowSleep)}}(e),fN.registerSystem(i.ID,e,e.priority),SN.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 $rt.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!$rt.id}},{key:"PHYSICS_BUILTIN",get:function(){return"builtin"===$rt.id}},{key:"PHYSICS_CANNON",get:function(){return"cannon.js"===$rt.id}},{key:"PHYSICS_BULLET",get:function(){return"bullet"===$rt.id}},{key:"PHYSICS_PHYSX",get:function(){return"physx"===$rt.id}},{key:"PhysicsGroup",get:function(){return Gtt}},{key:"instance",get:function(){return i._instance}}]),i}(Ou));lot.ID="PHYSICS",lot._instance=null,fN.once(dN.EVENT_INIT,(function(){lot.constructAndRegister()}));var cot,_ot,dot,fot,pot,mot,got,yot,vot,Sot,Tot,Aot=t("fm",(Yst=qs("cc.RigidBody"),Kst=Ks(-1),Jst=xo(lot.PhysicsGroup),Qst=xo(Dtt),Yst(Zst=Js(Zst=Kst(((uot=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;rPtt.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}(Rot)).prototype,"direction",[Oot],Object.getOwnPropertyDescriptor(Lot.prototype,"direction"),Lot.prototype),Not=ks(Lot.prototype,"_radius",[io],(function(){return.5})),Fot=ks(Lot.prototype,"_cylinderHeight",[io],(function(){return 1})),kot=ks(Lot.prototype,"_direction",[io],(function(){return Ptt.Y_AXIS})),Mot=Lot))||Mot)),Cat=t("fx",(Vot=qs("cc.CylinderCollider"),Got=xo(Ptt),Vot((p((zot=function(t){function e(){var e;return(e=t.call(this,Ltt.CYLINDER)||this)._radius=Hot&&Hot(),e._height=Wot&&Wot(),e._direction=jot&&jot(),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&&(tPtt.Z_AXIS||(this._direction=t,this._shape&&this.shape.setDirection(t)))}},{key:"shape",get:function(){return this._shape}}]),e}(Rot)).prototype,"direction",[Got],Object.getOwnPropertyDescriptor(zot.prototype,"direction"),zot.prototype),Hot=ks(zot.prototype,"_radius",[io],(function(){return.5})),Wot=ks(zot.prototype,"_height",[io],(function(){return 2})),jot=ks(zot.prototype,"_direction",[io],(function(){return Ptt.Y_AXIS})),Uot=zot))||Uot)),wat=t("fy",(Xot=qs("cc.ConeCollider"),qot=xo(Ptt),Xot((p((Kot=function(t){function e(){var e;return(e=t.call(this,Ltt.CONE)||this)._radius=Jot&&Jot(),e._height=Qot&&Qot(),e._direction=Zot&&Zot(),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&&(tPtt.Z_AXIS||(this._direction=t,this._shape&&this.shape.setDirection(t)))}},{key:"shape",get:function(){return this._shape}}]),e}(Rot)).prototype,"direction",[qot],Object.getOwnPropertyDescriptor(Kot.prototype,"direction"),Kot.prototype),Jot=ks(Kot.prototype,"_radius",[io],(function(){return.5})),Qot=ks(Kot.prototype,"_height",[io],(function(){return 1})),Zot=ks(Kot.prototype,"_direction",[io],(function(){return Ptt.Y_AXIS})),Yot=Kot))||Yot)),xat=t("fw",($ot=qs("cc.MeshCollider"),tat=xo(XN),$ot((p((iat=function(t){function e(){var e;return(e=t.call(this,Ltt.MESH)||this)._mesh=nat&&nat(),e._convex=rat&&rat(),e}return s(e,t),e.prototype.onEnable=function(){if(t.prototype.onEnable.call(this),this.node){var e=this.node.getComponent(Aot);e&&e.isValid&&e.type===Dtt.DYNAMIC&&!this.convex&&Y(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}(Rot)).prototype,"mesh",[tat],Object.getOwnPropertyDescriptor(iat.prototype,"mesh"),iat.prototype),nat=ks(iat.prototype,"_mesh",[io],(function(){return null})),rat=ks(iat.prototype,"_convex",[io],(function(){return!1})),eat=iat))||eat)),Rat=t("fo",qs("cc.ConstantForce")(sat=Ys(Aot)(sat=Js((oat=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;rt)){for(var e=this.buffer.byteLength;e=Lat?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=Mat){var a=e.readInt();this.normals=new Float32Array(a);for(var h=0;h=Dat){var c=e.readInt();this.layerBuffer=new Array(c);for(var _=0;_=Pat){var d=e.readInt();this._layerBinaryInfos=new Array(d);for(var f=0;f=Lat?this._layerBinaryInfos[f].tileSize=e.readDouble():this._layerBinaryInfos[f].tileSize=e.readFloat(),this._layerBinaryInfos[f].detailMapId=e.readString(),this._version>=Oat&&(this._layerBinaryInfos[f].normalMapId=e.readString(),this._version>=Lat?(this._layerBinaryInfos[f].roughness=e.readDouble(),this._layerBinaryInfos[f].metallic=e.readDouble()):(this._layerBinaryInfos[f].roughness=e.readFloat(),this._layerBinaryInfos[f].metallic=e.readFloat()))}return!0},i._exportNativeData=function(){var t=new kat;t.writeInt32(Nat),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&&(ae(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):fst.CollisionObject_setCollisionShape(this.body,fst.EmptyShape_static()),fst.CollisionObject_activate(this.body,!0),this.dirty|=b_t.BODY_RE_ADD,ae(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&&ae(this.wrappedJoints1,i)}else{var n=this.wrappedJoints0.indexOf(t);n>=0&&ae(this.wrappedJoints0,n)}},e.updateDirty=function(){this.dirty&&(this.bodyIndex>=0&&this.dirty&b_t.BODY_RE_ADD&&this.updateBodyByReAdd(),this.ghostIndex>=0&&this.dirty&b_t.GHOST_RE_ADD&&this.updateGhostByReAdd(),this.dirty=0)},e.syncSceneToPhysics=function(){if(this.node.hasChangedFlags){var t=vst.instance.BT_QUAT_0,e=fst.CollisionObject_getWorldTransform(this.body);if(Ust(t,this.node.worldRotation),Vst(fst.Transform_getOrigin(e),this.node.worldPosition),fst.Transform_setRotation(e,t),this.node.hasChangedFlags&rm.SCALE&&this.syncBodyScale(),fst.CollisionObject_isKinematicObject(this.body)){var i=fst.RigidBody_getMotionState(this.body);i&&fst.MotionState_setWorldTransform(i,e)}else this.isBodySleeping()&&fst.CollisionObject_activate(this.body,!1)}},e.syncPhysicsToScene=function(){fst.CollisionObject_isStaticOrKinematicObject(this.body)||this.syncPhysicsToGraphics()},e.syncPhysicsToGraphics=function(){if(!this.isBodySleeping()){var t=vst.instance.BT_QUAT_0,e=vst.instance.BT_TRANSFORM_0;fst.RigidBody_getWorldTransform(this.body,e);var i=fst.Transform_getRotationAndOrigin(e,t);if(this.node.worldRotation=zst(M_t,t),this.node.worldPosition=Gst(O_t,i),this._ghostStruct){var n=fst.CollisionObject_getWorldTransform(this.ghost);Vst(fst.Transform_getOrigin(n),this.node.worldPosition),Ust(t,this.node.worldRotation),fst.Transform_setRotation(n,t)}}},e.syncSceneToGhost=function(){if(this.node.hasChangedFlags){var t=vst.instance.BT_QUAT_0,e=fst.CollisionObject_getWorldTransform(this.ghost);Vst(fst.Transform_getOrigin(e),this.node.worldPosition),Ust(t,this.node.worldRotation),fst.Transform_setRotation(e,t),this.node.hasChangedFlags&rm.SCALE&&this.syncGhostScale(),fst.CollisionObject_activate(this.ghost,!1)}},e.syncInitialBody=function(){var t=vst.instance.BT_QUAT_0,e=fst.CollisionObject_getWorldTransform(this.body);Vst(fst.Transform_getOrigin(e),this.node.worldPosition),Ust(t,this.node.worldRotation),fst.Transform_setRotation(e,t),this.syncBodyScale(),fst.CollisionObject_activate(this.body,!1)},e.syncInitialGhost=function(){var t=vst.instance.BT_QUAT_0,e=fst.CollisionObject_getWorldTransform(this.ghost);Vst(fst.Transform_getOrigin(e),this.node.worldPosition),Ust(t,this.node.worldRotation),fst.Transform_setRotation(e,t),this.syncGhostScale(),fst.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;vst.delWrapper(e.body,pst.BODY_CACHE_NAME),fst._safe_delete(e.motionState,ust.EBulletTypeMotionState),fst._safe_delete(e.compound,ust.EBulletTypeCollisionShape),fst._safe_delete(e.body,ust.EBulletTypeCollisionObject),this._bodyStruct=null}if(this._ghostStruct){var i=this._ghostStruct;fst._safe_delete(i.compound,ust.EBulletTypeCollisionShape),fst._safe_delete(i.ghost,ust.EBulletTypeCollisionObject),this._ghostStruct=null}},e.isBodySleeping=function(){return fst.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|=b_t.BODY_RE_ADD,this.dirty|=b_t.GHOST_RE_ADD)}},{key:"collisionFilterMask",get:function(){return this._collisionFilterMask},set:function(t){t!==this._collisionFilterMask&&(this._collisionFilterMask=t,this.dirty|=b_t.BODY_RE_ADD,this.dirty|=b_t.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)&&(fst.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}();N_t.idCounter=0,N_t.sharedBodesMap=new Map;var F_t=Sst,k_t={},V_t=function(){function t(){this.id=t.idCounter++,this._isEnabled=!1,this._isTrigger=!1,this._isInitialized=!1,this._impl=0,this._compound=0,this.quat=fst.Quat_new(0,0,0,1),this.transform=fst.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?lot.instance.defaultMaterial:t;if(!this._isTrigger&&this._isEnabled)if(this._compound){k_t[e._uuid]||(k_t[e._uuid]=fst.ccMaterial_new());var i=k_t[e._uuid];fst.ccMaterial_set(i,e.restitution,e.friction,e.rollingFriction,e.spinningFriction),fst.CollisionShape_setMaterial(this._impl,i)}else fst.CollisionObject_setMaterial(this._sharedBody.body,e.restitution,e.friction,e.rollingFriction,e.spinningFriction)},e.setCenter=function(t){on.copy(F_t,t),F_t.multiply(this._collider.node.worldScale),Vst(fst.Transform_getOrigin(this.transform),F_t),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=vst.instance.BT_TRANSFORM_0;fst.Transform_setIdentity(e),fst.Transform_setRotation(e,Ust(vst.instance.BT_QUAT_0,this._collider.node.worldRotation));var i=vst.instance.BT_V3_0,n=vst.instance.BT_V3_1;fst.CollisionShape_getAabb(this._impl,e,i,n),t.halfExtents.x=(fst.Vec3_x(n)-fst.Vec3_x(i))/2,t.halfExtents.y=(fst.Vec3_y(n)-fst.Vec3_y(i))/2,t.halfExtents.z=(fst.Vec3_z(n)-fst.Vec3_z(i))/2,on.add(t.center,this._collider.node.worldPosition,this._collider.center)},e.getBoundingSphere=function(t){t.radius=fst.CollisionShape_getLocalBoundingSphere(this._impl),on.add(t.center,this._collider.node.worldPosition,this._collider.center)},e.initialize=function(t){this._collider=t,this._isInitialized=!0,this._sharedBody=lot.instance.physicsWorld.getSharedBody(this._collider.node),this._sharedBody.reference=!0,this.onComponentSet(),this.setWrapper()},e.setWrapper=function(){vst.isNotEmptyShape(this._impl)&&(fst.CollisionShape_setUserPointer(this._impl,this._impl),vst.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,fst._safe_delete(this.quat,ust.EBulletTypeQuat),fst._safe_delete(this.transform,ust.EBulletTypeTransform),this._compound&&fst._safe_delete(this._compound,ust.EBulletTypeCollisionShape),vst.isNotEmptyShape(this._impl)&&(fst._safe_delete(this._impl,ust.EBulletTypeCollisionShape),vst.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&&fst.CompoundShape_removeChildShape(this._compound,this._impl),t&&fst.CompoundShape_addChildShape(t,this.transform,this._impl),this._compound=t},e.updateScale=function(){this.setCenter(this._collider.center)},e.updateCompoundTransform=function(){this._compound?fst.CompoundShape_updateChildTransform(this._compound,this._impl,this.transform,!0):this._isEnabled&&!this._isTrigger&&this._sharedBody&&!this._sharedBody.bodyStruct.useCompound&&(this._sharedBody.dirty|=b_t.BODY_RE_ADD)},e.needCompound=function(){return this._collider.type===Ltt.TERRAIN||!this._collider.center.equals(on.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}();V_t.TYPE="shape",V_t.idCounter=0;var G_t=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}(),U_t=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}(),z_t=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&&Gst(t,fst.ManifoldPoint_get_m_localPointA(this.impl))},e.getLocalPointOnB=function(t){this.impl&&Gst(t,fst.ManifoldPoint_get_m_localPointB(this.impl))},e.getWorldPointOnA=function(t){this.impl&&Gst(t,fst.ManifoldPoint_get_m_positionWorldOnA(this.impl))},e.getWorldPointOnB=function(t){this.impl&&Gst(t,fst.ManifoldPoint_get_m_positionWorldOnB(this.impl))},e.getLocalNormalOnA=function(t){if(this.impl){var e=vst.instance.BT_QUAT_0,i=fst.PersistentManifold_getBody0(this.event.impl),n=fst.CollisionObject_getWorldTransform(i);fst.Transform_getRotation(n,e);var r=bst;zst(r,e),Sn.conjugate(r,r),Gst(t,fst.ManifoldPoint_get_m_normalWorldOnB(this.impl)),this.isBodyA||on.negate(t,t),on.transformQuat(t,t,r)}},e.getLocalNormalOnB=function(t){if(this.impl){var e=vst.instance.BT_QUAT_0,i=fst.PersistentManifold_getBody1(this.event.impl),n=fst.CollisionObject_getWorldTransform(i);fst.Transform_getRotation(n,e);var r=bst;zst(r,e),Sn.conjugate(r,r),Gst(t,fst.ManifoldPoint_get_m_normalWorldOnB(this.impl)),on.transformQuat(t,t,r)}},e.getWorldNormalOnA=function(t){this.impl&&(Gst(t,fst.ManifoldPoint_get_m_normalWorldOnB(this.impl)),this.isBodyA||on.negate(t,t))},e.getWorldNormalOnB=function(t){this.impl&&Gst(t,fst.ManifoldPoint_get_m_normalWorldOnB(this.impl))},n(t,[{key:"isBodyA",get:function(){return this.event.selfCollider.shape.sharedBody.body===fst.PersistentManifold_getBody0(this.event.impl)}}]),t}(),H_t=[],W_t=Sst,j_t=Tst,X_t=Ast,q_t=kst,Y_t=new A_t,K_t=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=Utt.NONE,this._debugConstraintSize=.3,this._needEmitEvents=!1,this._needSyncAfterEvents=!1,this._needEmitCCTEvents=!1,this.bodies=[],this.ghosts=[],this.ccts=[],this.constraints=[],this.triggerArrayMat=new G_t,this.collisionArrayMat=new G_t,this.contactsDic=new U_t,this.oldContactsDic=new U_t,this.cctShapeEventDic=new U_t,this.cctContactsDic=new U_t,this.cctOldContactsDic=new U_t,pst.CACHE.world=this,this._broadphase=fst.DbvtBroadphase_new(),this._dispatcher=fst.CollisionDispatcher_new(),this._solver=fst.SequentialImpulseConstraintSolver_new(),this._world=fst.ccDiscreteDynamicsWorld_new(this._dispatcher,this._broadphase,this._solver);var t=fst.DebugDraw.implement(P_t);this._debugDraw=t.$$.ptr,fst.CollisionWorld_setDebugDrawer(this._world,this._debugDraw),fst.DebugDraw_setDebugMode(this._debugDraw,cst.DBG_NoDebug),fst.DebugDraw_setAABBColor(this._debugDraw,0,1,1),fst.DebugDraw_setActiveObjectColor(this._debugDraw,1,0,1),fst.DebugDraw_setDeactiveObjectColor(this._debugDraw,1,0,1),fst.DebugDraw_setWantsDeactivationObjectColor(this._debugDraw,1,0,1),fst.DebugDraw_setDisabledDeactivationObjectColor(this._debugDraw,1,0,1),fst.DebugDraw_setDisabledSimulationObjectColor(this._debugDraw,1,0,1),fst.DebugDraw_setConstraintLimitColor(this._debugDraw,.5,.5,.5)}return t.setDefaultMaterial=function(){},t.setAllowSleep=function(t){fst.ccDiscreteDynamicsWorld_setAllowSleep(this._world,t)},t.setGravity=function(t){fst.DynamicsWorld_setGravity(this._world,Vst(vst.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 o=r[s];o.updateDirty(),o.syncSceneToPhysics()}},t.syncAfterEvents=function(){this._needSyncAfterEvents&&this.syncSceneToPhysics()},t.raycast=function(t,e,i,n){t.computeHit(W_t,e.maxDistance);var r=Vst(vst.instance.BT_V3_0,W_t),s=Vst(vst.instance.BT_V3_1,t.o),o=fst.ccAllRayCallback_static();if(fst.ccAllRayCallback_reset(o,s,r,e.mask>>>0,e.queryTrigger),fst.ccAllRayCallback_setFlags(o,lst.UseSubSimplexConvexCastRaytest),fst.CollisionWorld_rayTest(this._world,s,r,o),fst.RayCallback_hasHit(o)){for(var a=fst.ccAllRayCallback_getHitPointWorld(o),h=fst.ccAllRayCallback_getHitNormalWorld(o),u=fst.ccAllRayCallback_getCollisionShapePtrs(o),l=0,c=fst.int_array_size(u);l>>0,e.queryTrigger),fst.ccClosestRayCallback_setFlags(s,lst.UseSubSimplexConvexCastRaytest),fst.CollisionWorld_rayTest(this._world,r,n,s),fst.RayCallback_hasHit(s)){Gst(W_t,fst.ccClosestRayCallback_getHitPointWorld(s)),Gst(j_t,fst.ccClosestRayCallback_getHitNormalWorld(s));var o=vst.getWrapper(fst.ccClosestRayCallback_getCollisionShapePtr(s),V_t.TYPE);return i._assign(W_t,on.distance(t.o,W_t),o.collider,j_t),!0}return!1},t.sweepBox=function(t,i,n,r,s,o){var a=vst.instance.BT_V3_0;return Vst(a,i),e._sweepBoxGeometry||(e._sweepBoxGeometry=fst.BoxShape_new(a)),fst.BoxShape_setUnscaledHalfExtents(e._sweepBoxGeometry,a),this.sweep(t,e._sweepBoxGeometry,n,r,s,o)},t.sweepBoxClosest=function(t,i,n,r,s){var o=vst.instance.BT_V3_0;return Vst(o,i),e._sweepBoxGeometry||(e._sweepBoxGeometry=fst.BoxShape_new(o)),fst.BoxShape_setUnscaledHalfExtents(e._sweepBoxGeometry,o),this.sweepClosest(t,e._sweepBoxGeometry,n,r,s)},t.sweepSphere=function(t,i,n,r,s){return e._sweepSphereGeometry||(e._sweepSphereGeometry=fst.SphereShape_new(i)),fst.SphereShape_setUnscaledRadius(e._sweepSphereGeometry,i),this.sweep(t,e._sweepSphereGeometry,Sn.IDENTITY,n,r,s)},t.sweepSphereClosest=function(t,i,n,r){return e._sweepSphereGeometry||(e._sweepSphereGeometry=fst.SphereShape_new(i)),fst.SphereShape_setUnscaledRadius(e._sweepSphereGeometry,i),this.sweepClosest(t,e._sweepSphereGeometry,Sn.IDENTITY,n,r)},t.sweepCapsule=function(t,i,n,r,s,o,a){return e._sweepCapsuleGeometry||(e._sweepCapsuleGeometry=fst.CapsuleShape_new(i,n)),fst.CapsuleShape_updateProp(e._sweepCapsuleGeometry,i,.5*n,1),this.sweep(t,e._sweepCapsuleGeometry,r,s,o,a)},t.sweepCapsuleClosest=function(t,i,n,r,s,o){return e._sweepCapsuleGeometry||(e._sweepCapsuleGeometry=fst.CapsuleShape_new(i,n)),fst.CapsuleShape_updateProp(e._sweepCapsuleGeometry,i,.5*n,1),this.sweepClosest(t,e._sweepCapsuleGeometry,r,s,o)},t.sweep=function(t,e,i,n,r,s){var o=vst.instance.BT_TRANSFORM_0,a=vst.instance.BT_TRANSFORM_1,h=vst.instance.BT_QUAT_0;Vst(fst.Transform_getOrigin(o),t.o),Ust(h,i),fst.Transform_setRotation(o,h),t.computeHit(W_t,n.maxDistance),Vst(fst.Transform_getOrigin(a),W_t),Ust(h,i),fst.Transform_setRotation(a,h);var u=fst.ccAllConvexCallback_static();if(fst.ccAllConvexCallback_reset(u,o,a,n.mask>>>0,n.queryTrigger),fst.CollisionWorld_convexSweepTest(this._world,e,o,a,u,0),fst.ConvexCallback_hasHit(u)){for(var l=fst.ccAllConvexCallback_getHitPointWorld(u),c=fst.ccAllConvexCallback_getHitNormalWorld(u),_=fst.ccAllConvexCallback_getCollisionShapePtrs(u),d=0,f=fst.int_array_size(_);d>>0,n.queryTrigger),fst.CollisionWorld_convexSweepTest(this._world,e,s,o,h,0),fst.ConvexCallback_hasHit(h)){Gst(W_t,fst.ccClosestConvexCallback_getHitPointWorld(h)),Gst(j_t,fst.ccClosestConvexCallback_getHitNormalWorld(h));var u=vst.getWrapper(fst.ccClosestConvexCallback_getCollisionShapePtr(h),V_t.TYPE);return r._assign(W_t,on.distance(t.o,W_t),u.collider,j_t),!0}return!1},t.getSharedBody=function(t,e){return N_t.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;fst.DynamicsWorld_addRigidBody(this._world,t.body,e>>>0,i>>>0)}},t.removeSharedBody=function(t){var e=this.bodies.indexOf(t);e>=0&&(ae(this.bodies,e),fst.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;fst.CollisionWorld_addCollisionObject(this._world,t.ghost,e>>>0,i>>>0)}},t.removeGhostObject=function(t){var e=this.ghosts.indexOf(t);e>=0&&(ae(this.ghosts,e),fst.CollisionWorld_removeCollisionObject(this._world,t.ghost))},t.addCCT=function(t){if(this.ccts.indexOf(t)<0){this.ccts.push(t);var e=fst.CharacterController_getGhostObject(t.impl),i=t.getGroup(),n=t.getMask();fst.CollisionWorld_addCollisionObject(this._world,e,i>>>0,n>>>0),fst.DynamicsWorld_addAction(this._world,t.impl)}},t.removeCCT=function(t){var e=this.ccts.indexOf(t);if(e>=0){ae(this.ccts,e);var i=fst.CharacterController_getGhostObject(t.impl);fst.CollisionWorld_removeCollisionObject(this._world,i),fst.DynamicsWorld_removeAction(this._world,t.impl)}},t.addConstraint=function(t){var e=this.constraints.indexOf(t);e<0&&(this.constraints.push(t),fst.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),fst.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--;){H_t.push.apply(H_t,gst.contacts),gst.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,o=r.collider;if(s&&o){if(s.isTrigger||o.isTrigger)this.triggerArrayMat.get(n.id,r.id)?mst.type="onTriggerStay":(mst.type="onTriggerEnter",this.triggerArrayMat.set(n.id,r.id,!0)),mst.impl=i.impl,mst.selfCollider=s,mst.otherCollider=o,s.emit(mst.type,mst),mst.selfCollider=o,mst.otherCollider=s,o.emit(mst.type,mst),this._needSyncAfterEvents=!0;else{var a=s.attachedRigidBody,h=o.attachedRigidBody;if(a&&h){if(a.isSleeping&&h.isSleeping)continue}else if(!a&&h){if(h.isSleeping)continue}else if(!h&&a&&a.isSleeping)continue;this.collisionArrayMat.get(n.id,r.id)?gst.type="onCollisionStay":(gst.type="onCollisionEnter",this.collisionArrayMat.set(n.id,r.id,!0));for(var u=0;u0){var c=H_t.pop();c.impl=l,gst.contacts.push(c)}else{var _=new z_t(gst);_.impl=l,gst.contacts.push(_)}}gst.impl=i.impl,gst.selfCollider=s,gst.otherCollider=o,s.emit(gst.type,gst),gst.selfCollider=o,gst.otherCollider=s,o.emit(gst.type,gst),this._needSyncAfterEvents=!0}null==this.oldContactsDic.get(n.id,r.id)&&this.oldContactsDic.set(n.id,r.id,i)}}for(var d=this.oldContactsDic.getLength();d--;){var f=this.oldContactsDic.getKeyByIndex(d),p=this.oldContactsDic.getDataByKey(f),m=p.shape0,g=p.shape1,y=m.collider,v=g.collider;if(y&&v){var S=y.isTrigger||v.isTrigger;null==this.contactsDic.getDataByKey(f)&&(S?this.triggerArrayMat.get(m.id,g.id)&&(mst.type="onTriggerExit",mst.selfCollider=y,mst.otherCollider=v,y.emit(mst.type,mst),mst.selfCollider=v,mst.otherCollider=y,v.emit(mst.type,mst),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)&&(H_t.push.apply(H_t,gst.contacts),gst.contacts.length=0,gst.type="onCollisionExit",gst.selfCollider=y,gst.otherCollider=v,y.emit(gst.type,gst),gst.selfCollider=v,gst.otherCollider=y,v.emit(gst.type,gst),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,o=r.characterController;s&&o&&(s.isTrigger&&(this.triggerArrayMat.get(n.id,r.id)?yst.type="onControllerTriggerStay":(yst.type="onControllerTriggerEnter",this.triggerArrayMat.set(n.id,r.id,!0)),yst.impl=i.impl,yst.collider=s,yst.characterController=o,s.emit(yst.type,yst),yst.collider=s,yst.characterController=o,o.emit(yst.type,yst),this._needSyncAfterEvents=!0),null==this.cctOldContactsDic.get(n.id,r.id)&&this.cctOldContactsDic.set(n.id,r.id,i))}for(var a=this.cctOldContactsDic.getLength();a--;){var h=this.cctOldContactsDic.getKeyByIndex(a),u=this.cctOldContactsDic.getDataByKey(h),l=u.shape,c=u.cct,_=l.collider,d=c.characterController;if(_&&d){var f=_.isTrigger;null==this.cctContactsDic.getDataByKey(h)&&f&&this.triggerArrayMat.get(l.id,c.id)&&(yst.type="onControllerTriggerExit",yst.collider=_,yst.characterController=d,_.emit(yst.type,yst),yst.collider=_,yst.characterController=d,d.emit(yst.type,yst),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,o=n.worldPos,a=n.worldNormal,h=n.motionDir,u=n.motionLength;Y_t.controller=r.characterController,Y_t.collider=s.collider,Y_t.worldPosition.set(o.x,o.y,o.z),Y_t.worldNormal.set(a.x,a.y,a.z),Y_t.motionDirection.set(h.x,h.y,h.z),Y_t.motionLength=u,null===(e=Y_t.controller)||void 0===e||e.emit("onControllerColliderHit",Y_t),this._needSyncAfterEvents=!0}this.cctShapeEventDic.reset()},t.gatherConatactData=function(){for(var t=fst.Dispatcher_getNumManifolds(this._dispatcher),e=0;e0){if(this.collider.convex){var i=this._getBtTriangleMesh(e);this._impl=fst.ConvexTriangleMeshShape_new(i)}else this.btBVHMeshShape=$_t.getBulletBvhTriangleMeshShape(e.hash,e),this._impl=fst.ScaledBvhTriangleMeshShape_new(this.btBVHMeshShape.bulletBvhTriangleMeshShapePtr,1,1,1);var n=vst.instance.BT_V3_0;Vst(n,this._collider.node.worldScale),fst.CollisionShape_setLocalScaling(this._impl,n),fst.CollisionShape_setMargin(this._impl,.01),this.setCompound(this._compound),this.updateByReAdd(),this.setWrapper()}else this._impl=fst.EmptyShape_static()}},i.onComponentSet=function(){this.setMesh(this.collider.mesh)},i.onDestroy=function(){this.collider.convex?this.refBtTriangleMesh&&fst._safe_delete(this.refBtTriangleMesh,ust.EBulletTypeTriangleMesh):this.btBVHMeshShape&&(this.btBVHMeshShape.reference=!1),t.prototype.onDestroy.call(this)},i.updateScale=function(){t.prototype.updateScale.call(this);var e=vst.instance.BT_V3_0;Vst(e,this._collider.node.worldScale),fst.CollisionShape_setLocalScaling(this._impl,e),this.updateCompoundTransform()},i._getBtTriangleMesh=function(t){return this.refBtTriangleMesh=fst.TriangleMesh_new(),Hst(this.refBtTriangleMesh,t),this.refBtTriangleMesh},n(e,[{key:"collider",get:function(){return this._collider}}]),e}(V_t),ndt=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=vst.instance.BT_V3_0;fst.Vec3_set(t,.5,1,.5),this._impl=fst.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,o=n,a=i;1===a?(s=e*Math.abs(o.y),r=t*Math.abs(Wi(o.x,o.z))):0===a?(s=e*Math.abs(o.x),r=t*Math.abs(Wi(o.y,o.z))):(s=e*Math.abs(o.z),r=t*Math.abs(Wi(o.x,o.y))),fst.CylinderShape_updateProp(this._impl,r,s/2,a),this.updateCompoundTransform()},n(e,[{key:"collider",get:function(){return this._collider}}]),e}(V_t),rdt=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=fst.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,o=n,a=i;1===a?(s=e*Math.abs(o.y),r=t*Math.abs(Wi(o.x,o.z))):0===a?(s=e*Math.abs(o.x),r=t*Math.abs(Wi(o.y,o.z))):(s=e*Math.abs(o.z),r=t*Math.abs(Wi(o.x,o.y))),fst.ConeShape_setRadius(this._impl,r),fst.ConeShape_setHeight(this._impl,s),fst.ConeShape_setConeUpIndex(this._impl,a);var h=vst.instance.BT_V3_0;fst.Vec3_set(h,1,1,1),fst.CollisionShape_setLocalScaling(this._impl,h),this.updateCompoundTransform()},n(e,[{key:"impl",get:function(){return this._impl}},{key:"collider",get:function(){return this._collider}}]),e}(V_t),sdt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;ru&&(s=u),u>o&&(o=u),r+=4}o+=.01,s-=.01,this._localOffset.set((i-1)/2*this._tileSize,(o+s)/2,(n-1)/2*this._tileSize),this._impl=fst.TerrainShape_new(i,n,this._bufPtr,1,s,o);var l=vst.instance.BT_V3_0;fst.Vec3_set(l,this._tileSize,1,this._tileSize),fst.CollisionShape_setLocalScaling(this._impl,l),this.setCompound(this._compound),this.updateByReAdd(),this.setWrapper()}else this._impl=fst.EmptyShape_static()}},i.onComponentSet=function(){this.setTerrain(this.collider.terrain)},i.onDestroy=function(){this._bufPtr&&fst._free(this._bufPtr),t.prototype.onDestroy.call(this)},i.setCenter=function(t){on.copy(Sst,t),Sst.add(this._localOffset),Vst(fst.Transform_getOrigin(this.transform),Sst),this.updateCompoundTransform()},n(e,[{key:"collider",get:function(){return this._collider}}]),e}(V_t),odt=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=fst.SimplexShape_new();for(var t=this.collider.shapeType,e=this.collider.vertices,i=vst.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=lot.instance.physicsWorld.debugDrawConstraintSize;fst.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(){fst._safe_delete(this._impl,ust.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}(),udt=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=vst.instance.BT_V3_0;on.multiply(Sst,t.node.worldScale,t.pivotA),Vst(e,Sst),fst.P2PConstraint_setPivotA(this._impl,e),t.connectedBody||this.setPivotB(t.pivotB)},i.setPivotB=function(){var t=this.constraint,e=this._rigidBody.node,i=vst.instance.BT_V3_0,n=t.connectedBody;n?(on.multiply(Sst,n.node.worldScale,t.pivotB),Vst(i,Sst)):(on.multiply(Sst,e.worldScale,t.pivotA),on.transformQuat(Sst,Sst,e.worldRotation),on.add(Sst,Sst,e.worldPosition),Vst(i,Sst)),fst.P2PConstraint_setPivotB(this._impl,i)},i.onComponentSet=function(){var t=this.constraint.connectedBody,e=this._rigidBody.body.impl,i=t?t.body.impl:fst.TypedConstraint_getFixedBody(),n=vst.instance.BT_V3_0,r=vst.instance.BT_V3_1;this._impl=fst.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}(hdt),ldt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.setBreakForce=function(t){fst.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:fst.TypedConstraint_getFixedBody(),n=vst.instance.BT_TRANSFORM_0,r=vst.instance.BT_TRANSFORM_1;this._impl=fst.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=Sst,n=bst,r=vst.instance.BT_TRANSFORM_0,s=vst.instance.BT_TRANSFORM_1,o=vst.instance.BT_QUAT_0,a=Cst;if(In.fromRT(a,e.node.worldRotation,e.node.worldPosition),In.invert(a,a),In.getRotation(n,a),In.getTranslation(i,a),Vst(fst.Transform_getOrigin(r),i),Ust(o,n),fst.Transform_setRotation(r,o),t){var h=t.body.sharedBody;In.fromRT(a,h.node.worldRotation,h.node.worldPosition),In.invert(a,a),In.getRotation(n,a),In.getTranslation(i,a),Vst(fst.Transform_getOrigin(s),i),Ust(o,n),fst.Transform_setRotation(s,o)}else fst.Transform_setIdentity(s);fst.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}(hdt),cdt=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?fst.HingeConstraint_setLimit(this._impl,Bi(this.constraint.lowerLimit),Bi(this.constraint.upperLimit),.9,.3,1):fst.HingeConstraint_setLimit(this._impl,1,0,.9,.3,1)},i.setLowerLimit=function(){this.constraint.limitEnabled&&fst.HingeConstraint_setLimit(this._impl,Bi(this.constraint.lowerLimit),Bi(this.constraint.upperLimit),.9,.3,1)},i.setUpperLimit=function(){this.constraint.limitEnabled&&fst.HingeConstraint_setLimit(this._impl,Bi(this.constraint.lowerLimit),Bi(this.constraint.upperLimit),.9,.3,1)},i.setMotorEnabled=function(t){fst.HingeConstraint_enableMotor(this._impl,t);var e=-this.constraint.motorVelocity/60,i=Wst(this.constraint.motorForceLimit,lot.instance.fixedTimeStep);fst.HingeConstraint_setMotorVelocity(this._impl,e),fst.HingeConstraint_setMaxMotorImpulse(this._impl,i)},i.setMotorVelocity=function(t){if(this.constraint.motorEnabled){var e=-t/60;fst.HingeConstraint_setMotorVelocity(this._impl,e)}},i.setMotorForceLimit=function(t){if(this.constraint.motorEnabled){var e=Wst(t,lot.instance.fixedTimeStep);fst.HingeConstraint_setMaxMotorImpulse(this._impl,e)}},i.onComponentSet=function(){var t=this.constraint.connectedBody,e=this._rigidBody.body.impl,i=t?t.body.impl:fst.TypedConstraint_getFixedBody(),n=vst.instance.BT_TRANSFORM_0,r=vst.instance.BT_TRANSFORM_1;this._impl=fst.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=Sst,n=bst,r=Est,s=vst.instance.BT_TRANSFORM_0;on.multiply(i,e.worldScale,t.pivotA),Vst(fst.Transform_getOrigin(s),i);var o=vst.instance.BT_QUAT_0;on.normalize(i,t.axis),Sn.rotationTo(r,on.UNIT_Z,i),Ust(o,r),fst.Transform_setRotation(s,o);var a=vst.instance.BT_TRANSFORM_1,h=this.constraint.connectedBody;h?(on.multiply(i,h.node.worldScale,t.pivotB),Sn.multiply(r,e.worldRotation,r),Sn.invert(n,h.node.worldRotation),Sn.multiply(r,n,r)):(on.multiply(i,e.worldScale,t.pivotA),on.transformQuat(i,i,e.worldRotation),on.add(i,i,e.worldPosition),Sn.multiply(r,e.worldRotation,r)),Vst(fst.Transform_getOrigin(a),i),Ust(o,r),fst.Transform_setRotation(a,o),fst.HingeConstraint_setFrames(this._impl,s,a)},i.updateScale0=function(){this.updateFrames()},i.updateScale1=function(){this.updateFrames()},n(e,[{key:"constraint",get:function(){return this._com}}]),e}(hdt);!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"}(tdt||(tdt={})),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"}(edt||(edt={}));var _dt=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 Ftt.LOCKED:fst.Generic6DofSpring2Constraint_setLimit(this._impl,e,0,0);break;case Ftt.LIMITED:fst.Generic6DofSpring2Constraint_setLimit(this._impl,e,i,n);break;case Ftt.FREE:fst.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],o=0,a=0;switch(t){case 0:case 1:case 2:on.toArray(r,i.lower),on.toArray(s,i.upper),a=r[t],o=s[t];break;case 3:a=-(o=.5*Bi(n.twistExtent));break;case 4:a=-(o=.5*Bi(n.swingExtent1));break;case 5:a=-(o=.5*Bi(n.swingExtent2));break;default:V("idx should be in [0, 5], but give "+t)}this._setLimit(e,t,a,o)},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,edt.TWIST,.5*-Bi(t),.5*Bi(t)),this._setLimit(n.swingMotion1,edt.SWING1,.5*-Bi(e),.5*Bi(e)),this._setLimit(n.swingMotion2,edt.SWING2,.5*-Bi(i),.5*Bi(i))},i.setSwingSoftConstraint=function(t){fst.Generic6DofSpring2Constraint_enableSpring(this._impl,edt.SWING1,t),fst.Generic6DofSpring2Constraint_enableSpring(this._impl,edt.SWING2,t)},i.setTwistSoftConstraint=function(t){fst.Generic6DofSpring2Constraint_enableSpring(this._impl,edt.TWIST,t)},i.setLinearSoftConstraint=function(t){fst.Generic6DofSpring2Constraint_enableSpring(this._impl,edt.X,t),fst.Generic6DofSpring2Constraint_enableSpring(this._impl,edt.Y,t),fst.Generic6DofSpring2Constraint_enableSpring(this._impl,edt.Z,t)},i.setLinearStiffness=function(t){fst.Generic6DofSpring2Constraint_setStiffness(this._impl,edt.X,t),fst.Generic6DofSpring2Constraint_setStiffness(this._impl,edt.Y,t),fst.Generic6DofSpring2Constraint_setStiffness(this._impl,edt.Z,t)},i.setLinearDamping=function(t){fst.Generic6DofSpring2Constraint_setDamping(this._impl,edt.X,t),fst.Generic6DofSpring2Constraint_setDamping(this._impl,edt.Y,t),fst.Generic6DofSpring2Constraint_setDamping(this._impl,edt.Z,t)},i.setLinearRestitution=function(t){fst.Generic6DofSpring2Constraint_setBounce(this._impl,edt.X,t),fst.Generic6DofSpring2Constraint_setBounce(this._impl,edt.Y,t),fst.Generic6DofSpring2Constraint_setBounce(this._impl,edt.Z,t)},i.setSwingStiffness=function(t){fst.Generic6DofSpring2Constraint_setStiffness(this._impl,edt.SWING1,t),fst.Generic6DofSpring2Constraint_setStiffness(this._impl,edt.SWING2,t)},i.setSwingDamping=function(t){fst.Generic6DofSpring2Constraint_setDamping(this._impl,edt.SWING1,t),fst.Generic6DofSpring2Constraint_setDamping(this._impl,edt.SWING2,t)},i.setSwingRestitution=function(t){fst.Generic6DofSpring2Constraint_setBounce(this._impl,edt.SWING1,t),fst.Generic6DofSpring2Constraint_setBounce(this._impl,edt.SWING2,t)},i.setTwistStiffness=function(t){fst.Generic6DofSpring2Constraint_setStiffness(this._impl,edt.TWIST,t)},i.setTwistDamping=function(t){fst.Generic6DofSpring2Constraint_setDamping(this._impl,edt.TWIST,t)},i.setTwistRestitution=function(t){fst.Generic6DofSpring2Constraint_setBounce(this._impl,edt.TWIST,t)},i.setDriverMode=function(t,e){e===ktt.DISABLED?fst.Generic6DofSpring2Constraint_enableMotor(this._impl,t,!1):e===ktt.SERVO?(fst.Generic6DofSpring2Constraint_enableMotor(this._impl,t,!0),fst.Generic6DofSpring2Constraint_setServo(this._impl,t,!0)):e===ktt.INDUCTION&&(fst.Generic6DofSpring2Constraint_enableMotor(this._impl,t,!0),fst.Generic6DofSpring2Constraint_setServo(this._impl,t,!1))},i._updateMotorTargetAndVelocity=function(t){var e=ktt.DISABLED,i=0,n=0,r=0,s=this.constraint.linearDriverSettings,o=this.constraint.angularDriverSettings;switch(t){case 0:i=edt.X,e=s.xDrive,n=s.targetPosition.x,r=-s.targetVelocity.x;break;case 1:i=edt.Y,e=s.yDrive,n=s.targetPosition.y,r=-s.targetVelocity.y;break;case 2:i=edt.Z,e=s.zDrive,n=s.targetPosition.z,r=-s.targetVelocity.z;break;case 3:i=edt.TWIST,e=o.twistDrive,n=-Bi(o.targetOrientation.x),r=-Bi(o.targetVelocity.x);break;case 4:i=edt.SWING1,e=o.swingDrive1,n=-Bi(o.targetOrientation.y),r=-Bi(o.targetVelocity.y);break;case 5:i=edt.SWING2,e=o.swingDrive2,n=-Bi(o.targetOrientation.z),r=-Bi(o.targetVelocity.z)}var a=t>2?o.strength:s.strength;fst.Generic6DofSpring2Constraint_setServoTarget(this._impl,i,n),e===ktt.SERVO?t>2?fst.Generic6DofSpring2Constraint_setTargetVelocity(this._impl,i,-n*a*.1):fst.Generic6DofSpring2Constraint_setTargetVelocity(this._impl,i,n*a*.1):e===ktt.INDUCTION&&fst.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){fst.Generic6DofSpring2Constraint_setMaxMotorForce(this._impl,edt.X,t),fst.Generic6DofSpring2Constraint_setMaxMotorForce(this._impl,edt.Y,t),fst.Generic6DofSpring2Constraint_setMaxMotorForce(this._impl,edt.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){fst.Generic6DofSpring2Constraint_setMaxMotorForce(this._impl,edt.TWIST,t),fst.Generic6DofSpring2Constraint_setMaxMotorForce(this._impl,edt.SWING1,t),fst.Generic6DofSpring2Constraint_setMaxMotorForce(this._impl,edt.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=Wst(Math.max(this.constraint.breakForce,this.constraint.breakTorque),lot.instance.fixedTimeStep);fst.TypedConstraint_setMaxImpulseThreshold(this._impl,t)},i.setBreakTorque=function(){var t=Wst(Math.max(this.constraint.breakForce,this.constraint.breakTorque),lot.instance.fixedTimeStep);fst.TypedConstraint_setMaxImpulseThreshold(this._impl,t)},i.onComponentSet=function(){var t=this.constraint.connectedBody,e=this._rigidBody.body.impl,i=t&&t.body.impl||fst.TypedConstraint_getFixedBody(),n=vst.instance.BT_TRANSFORM_0,r=vst.instance.BT_TRANSFORM_1;this._impl=fst.Generic6DofSpring2Constraint_new(e,i,n,r,tdt.RO_YZX);var s=this.constraint.linearLimitSettings,o=this.constraint.angularLimitSettings;this.setConstraintMode(0,s.xMotion),this.setConstraintMode(1,s.yMotion),this.setConstraintMode(2,s.zMotion),this.setConstraintMode(3,o.twistMotion),this.setConstraintMode(4,o.swingMotion1),this.setConstraintMode(5,o.swingMotion2),this.setLinearSoftConstraint(s.enableSoftConstraint),this.setLinearStiffness(s.stiffness),this.setLinearDamping(s.damping),this.setLinearRestitution(s.restitution),this.setSwingSoftConstraint(o.enableSoftConstraintSwing),this.setSwingRestitution(o.swingRestitution),this.setSwingStiffness(o.swingStiffness),this.setSwingDamping(o.swingDamping),this.setTwistSoftConstraint(o.enableSoftConstraintTwist),this.setTwistRestitution(o.twistRestitution),this.setTwistStiffness(o.twistStiffness),this.setTwistDamping(o.twistDamping);var a=this.constraint.linearDriverSettings,h=this.constraint.angularDriverSettings;this.setDriverMode(0,a.xDrive),this.setDriverMode(1,a.yDrive),this.setDriverMode(2,a.zDrive),this.setDriverMode(3,h.twistDrive),this.setDriverMode(4,h.swingDrive1),this.setDriverMode(5,h.swingDrive2),this.setLinearMotorTarget(a.targetPosition),this.setLinearMotorVelocity(a.targetVelocity),this.setLinearMotorForceLimit(a.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=Sst,n=bst,r=Est,s=vst.instance.BT_TRANSFORM_0;on.multiply(i,e.worldScale,t.pivotA),Vst(fst.Transform_getOrigin(s),i);var o=vst.instance.BT_QUAT_0,a=t.axis,h=t.secondaryAxis,u=on.cross(Tst,a,h);In.set(Cst,a.x,a.y,a.z,0,h.x,h.y,h.z,0,u.x,u.y,u.z,0,0,0,0,1).getRotation(n),Ust(o,n),fst.Transform_setRotation(s,o);var l=vst.instance.BT_TRANSFORM_1,c=this.constraint.connectedBody;c?(Sn.multiply(n,e.worldRotation,n),Sn.invert(r,c.node.worldRotation),Sn.multiply(n,r,n),t.autoPivotB?(on.multiply(i,t.node.worldScale,t.pivotA),on.transformQuat(i,i,e.worldRotation),on.add(i,i,t.node.worldPosition),on.subtract(i,i,c.node.worldPosition),on.transformQuat(i,i,r)):on.multiply(i,c.node.worldScale,t.pivotB)):(on.multiply(i,e.worldScale,t.pivotA),on.transformQuat(i,i,e.worldRotation),on.add(i,i,e.worldPosition),Sn.multiply(n,e.worldRotation,n)),Vst(fst.Transform_getOrigin(l),i),Ust(o,n),fst.Transform_setRotation(l,o),fst.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}(hdt),ddt=new on(0,0,0),fdt=new on(0,0,0);new on(0,0,0);var pdt=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=Gtt.DEFAULT,this._collisionFilterMask=-1,this.id=t.idCounter++,this.wrappedWorld=lot.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=lot.instance.collisionMatrix[e];return this._collisionFilterGroup=e,this._collisionFilterMask=i,this.onComponentSet(),0!==this._impl||(V("[Physics]: Initialize BulletCharacterController failed"),!1)},e.setWrapper=function(){vst.setWrapper(this._impl,pst.CCT_CACHE_NAME,this);var t=fst.CharacterController_getCollisionShape(this.impl);vst.setWrapper(t,pst.CCT_CACHE_NAME,this)},e.onEnable=function(){this._isEnabled=!0,this._impl||this.onComponentSet(),this.setDetectCollisions(!1),this.setOverlapRecovery(!0),lot.instance.physicsWorld.addCCT(this),this.setWrapper()},e.onDisable=function(){this._isEnabled=!1,this.wrappedWorld.removeCCT(this),this.onDestroy()},e.onDestroy=function(){fst._safe_delete(this._impl,ust.EBulletTypeCharacterController),vst.delWrapper(this._impl,pst.CCT_CACHE_NAME),this._impl=0},e.onLoad=function(){},e.getPosition=function(t){this._impl&&Gst(t,fst.CharacterController_getPosition(this.impl))},e.setPosition=function(t){this._impl&&(Vst(fst.CharacterController_getPosition(this.impl),t),this.syncPhysicsToScene())},e.setContactOffset=function(t){this._impl&&fst.CharacterController_setContactOffset(this._impl,t)},e.setStepOffset=function(t){this._impl&&fst.CharacterController_setStepOffset(this._impl,t)},e.setSlopeLimit=function(t){this._impl&&fst.CharacterController_setSlopeLimit(this._impl,ke(t))},e.setDetectCollisions=function(t){this._impl&&fst.CharacterController_setCollision(this.impl,t)},e.setOverlapRecovery=function(t){this._impl&&fst.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&rm.SCALE&&this.syncScale(),t.hasChangedFlags&rm.POSITION&&(on.add(ddt,t.worldPosition,this.scaledCenter),this.setPosition(ddt)))},e.syncPhysicsToScene=function(){this.getPosition(ddt),ddt.subtract(this.scaledCenter),this._comp.node.setWorldPosition(ddt)},e.syncScale=function(){this.updateScale()},e.move=function(t,e,i){if(this._isEnabled){var n=vst.instance.BT_V3_0;fst.Vec3_set(n,t.x,t.y,t.z),this._btCollisionFlags=fst.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&&(lot.instance.physicsWorld.removeCCT(this),lot.instance.physicsWorld.addCCT(this),this._dirty=!1)},e.onShapeHitExt=function(t){var e=fst.ControllerShapeHit_getHitShape(t),i=lot.instance.physicsWorld;i.cctShapeEventDic.get(this.impl,e);var n=new on;Gst(n,fst.ControllerHit_getHitWorldPos(t));var r=new on;Gst(r,fst.ControllerHit_getHitWorldNormal(t));var s=new on;Gst(s,fst.ControllerHit_getHitMotionDir(t));var o=fst.ControllerHit_getHitMotionLength(t),a=vst.getWrapper(e,V_t.TYPE);a&&i.cctShapeEventDic.set(this.impl,e,{BulletCharacterController:this,BulletShape:a,worldPos:n,worldNormal:r,motionDir:s,motionLength:o})},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 on.multiply(fdt,this._comp.center,this._comp.node.worldScale),fdt}}]),t}();pdt.idCounter=0;var mdt,gdt,ydt,vdt,Sdt,Tdt,Adt,bdt,Edt=new on(0,0,0),Cdt=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(Edt),Edt.add(this.scaledCenter);var t=vst.instance.BT_V3_0;fst.Vec3_set(t,Edt.x,Edt.y,Edt.z);var e=on.UNIT_Y,i=vst.instance.BT_V3_1;fst.Vec3_set(i,e.x,e.y,e.z);var n=fst.ControllerHitReport.implement(P_t).$$.ptr,r=lot.instance.physicsWorld,s=fst.CapsuleCharacterControllerDesc_new(ke(this.component.slopeLimit),this.component.stepOffset,this.component.skinWidth,i,t,n,this.component.radius,this.component.height);this._impl=fst.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*Wi(t.x,t.z),i=this.component.height*Math.abs(t.y);fst.CapsuleCharacterController_setRadius(this.impl,e),fst.CapsuleCharacterController_setHeight(this.impl,i),this._dirty=!0},n(e,[{key:"component",get:function(){return this._comp}}]),e}(pdt),wdt=new on(0,0,0),xdt=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(wdt),wdt.add(this.scaledCenter);var t=vst.instance.BT_V3_0;fst.Vec3_set(t,wdt.x,wdt.y,wdt.z);var e=on.UNIT_Y,i=vst.instance.BT_V3_1;fst.Vec3_set(i,e.x,e.y,e.z);var n=fst.ControllerHitReport.implement(P_t).$$.ptr,r=lot.instance.physicsWorld,s=fst.BoxCharacterControllerDesc_new(ke(this.component.slopeLimit),this.component.stepOffset,this.component.skinWidth,i,t,n,this.component.halfHeight,this.component.halfSideExtent,this.component.halfForwardExtent);this._impl=fst.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;fst.BoxCharacterController_setHalfSideExtent(this.impl,this.component.halfSideExtent*t.x),fst.BoxCharacterController_setHalfHeight(this.impl,this.component.halfHeight*t.y),fst.BoxCharacterController_setHalfForwardExtent(this.impl,this.component.halfForwardExtent*t.z),this._dirty=!0},n(e,[{key:"component",get:function(){return this._comp}}]),e}(pdt);SN.once(vN.EVENT_PRE_SUBSYSTEM_INIT,(function(){$rt.register("bullet",{PhysicsWorld:K_t,RigidBody:D_t,BoxShape:J_t,SphereShape:Q_t,CapsuleShape:Z_t,TrimeshShape:idt,CylinderShape:ndt,ConeShape:rdt,TerrainShape:sdt,SimplexShape:odt,PlaneShape:adt,PointToPointConstraint:udt,HingeConstraint:cdt,FixedConstraint:ldt,ConfigurableConstraint:_dt,BoxCharacterController:xdt,CapsuleCharacterController:Cdt})})),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"}(bdt||(bdt={})),Se(bdt);var Rdt=t("fO",(mdt=qs("cc.Primitive"),gdt=xo(bdt),mdt(((Adt=function(t){function e(e){var i;return void 0===e&&(e=bdt.BOX),(i=t.call(this)||this).type=Sdt&&Sdt(),i.info=Tdt&&Tdt(),i.type=e,i}return s(e,t),e.prototype.onLoaded=function(){iF(U$[bdt[this.type].toLowerCase()](this.info),this)},e}(XN)).PrimitiveType=bdt,Sdt=ks((vdt=Adt).prototype,"type",[gdt],(function(){return bdt.BOX})),Tdt=ks(vdt.prototype,"info",[io],(function(){return{}})),ydt=vdt))||ydt));v.Primitive=Rdt,v.primitives=U$;var Idt,Bdt=function(){function t(t,e,i){this._opts=void 0,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 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}(),Ddt=qs("cc.PerfCounter")(Idt=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}(Bdt))||Idt,Pdt="0123456789. ",Odt=500,Mdt={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,".":10},Ldt={fps:{desc:"Framerate (FPS)",below:30,average:Odt,isInteger:!0},draws:{desc:"Draw call",isInteger:!0},frame:{desc:"Frame time (ms)",min:0,max:50,average:Odt},instances:{desc:"Instance Count",isInteger:!0},tricount:{desc:"Triangle",isInteger:!0},logic:{desc:"Game Logic (ms)",min:0,max:50,average:Odt,color:"#080"},physics:{desc:"Physics (ms)",min:0,max:50,average:Odt},render:{desc:"Renderer (ms)",min:0,max:50,average:Odt,color:"#f90"},present:{desc:"Present (ms)",min:0,max:50,average:Odt,color:"#f90"},textureMemory:{desc:"GFX Texture Mem(M)"},bufferMemory:{desc:"GFX Buffer Mem(M)"}},Ndt=t("fP",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 Gc,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(Ldt).length+1),e._wordHeight=0,e._eachNumWidth=0,e._totalLines=0,e.lastTime=0,e._canvas=T.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(){Ee.querySettings(be.Category.PROFILING,"showFPS")?this.showStats():this.hideStats()},i.isShowingStats=function(){return this._showFPS},i.hideStats=function(){this._showFPS&&(this._rootNode&&(this._rootNode.active=!1),v.director.off(v.Director.EVENT_BEFORE_UPDATE,this.beforeUpdate,this),v.director.off(v.Director.EVENT_AFTER_UPDATE,this.afterUpdate,this),v.director.off(v.Director.EVENT_BEFORE_PHYSICS,this.beforePhysics,this),v.director.off(v.Director.EVENT_AFTER_PHYSICS,this.afterPhysics,this),v.director.off(v.Director.EVENT_BEFORE_DRAW,this.beforeDraw,this),v.director.off(v.Director.EVENT_AFTER_RENDER,this.afterRender,this),v.director.off(v.Director.EVENT_AFTER_DRAW,this.afterPresent,this),this._showFPS=!1,fN.root.pipeline.profiler=null,v.game.config.showFPS=!1)},i.showStats=function(){if(!this._showFPS){if(!this._device){var t=v.director.root;this._device=Ed.gfxDevice,this._swapchain=t.mainWindow.swapchain}this.generateCanvas(),this.generateStats(),v.game.once(v.Game.EVENT_ENGINE_INITED,this.generateNode,this),v.game.on(v.Game.EVENT_RESTART,this.generateNode,this),this._rootNode&&(this._rootNode.active=!0),v.director.on(v.Director.EVENT_BEFORE_UPDATE,this.beforeUpdate,this),v.director.on(v.Director.EVENT_AFTER_UPDATE,this.afterUpdate,this),v.director.on(v.Director.EVENT_BEFORE_PHYSICS,this.beforePhysics,this),v.director.on(v.Director.EVENT_AFTER_PHYSICS,this.afterPhysics,this),v.director.on(v.Director.EVENT_BEFORE_DRAW,this.beforeDraw,this),v.director.on(v.Director.EVENT_AFTER_RENDER,this.afterRender,this),v.director.on(v.Director.EVENT_AFTER_DRAW,this.afterPresent,this),this._showFPS=!0,this._canvasDone=!0,this._statsDone=!0,v.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 Qc(Jl.TEX2D,Ql.SAMPLED|Ql.TRANSFER_DST,Hl.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 Ldt){var n=Ldt[i];this._ctx.fillText(n.desc,0,e*this._lineHeight),n.counter=new Ddt(i,n,t),e++}this._totalLines=e,this._wordHeight=this._totalLines*this._lineHeight/this._canvas.height;for(var r=0;r=0;a--){var h=8*i+a,u=o[o.length-(8-a)],l=Mdt[u];void 0===l&&(l=11),n[h]=l}i++}}}},n(e,[{key:"_stats",get:function(){return k("Profiler._stats is deprecated, please use Profiler.stats instead."),this._profilerStats}},{key:"stats",get:function(){return this._profilerStats}}]),e}(Ou)),Fdt=t("fQ",new Ndt);fN.registerSystem("profiler",Fdt,0),v.profiler=Fdt;var kdt=function(){function t(t){this.jointTexturePool=void 0,this.jointAnimationInfo=void 0,this.jointTexturePool=new HQ(t),this.jointAnimationInfo=new WQ(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}();v.internal.DataPoolManager=kdt;var Vdt,Gdt,Udt,zdt,Hdt,Wdt,jdt,Xdt,qdt,Ydt,Kdt,Jdt,Qdt,Zdt,$dt,tft=new In,eft=new In,ift=t("fS",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=v.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=IQ.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=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===hft.TAG_INVALID&&X(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===hft.TAG_INVALID&&X(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===hft.TAG_INVALID&&X(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&&this._deleteHashElement(e)},e._deleteHashElement=function(t){var e=!1;if(t&&!t.lock&&this._hashTargets.get(t.target)){this._hashTargets.delete(t.target);for(var i=this._arrayTargets,n=0,r=i.length;n=this._duration},i._cloneDecoration=function(t){t._repeatForever=this._repeatForever,t._speed=this._speed,t._timesForRepeat=this._timesForRepeat,t._easeList=this._easeList,t._speedMethod=this._speedMethod,t._repeatMethod=this._repeatMethod},i._reverseEaseList=function(t){if(this._easeList){t._easeList=[];for(var e=0;e1.192092896e-7?this._duration:1.192092896e-7);e=e<1?e:1,this.update(e>0?e:0),this._repeatMethod&&this._timesForRepeat>1&&this.isDone()&&(this._repeatForever||this._timesForRepeat--,this.startWithTarget(this.target),this.step(this._elapsed-this._duration))},i.startWithTarget=function(t){hft.prototype.startWithTarget.call(this,t),this._elapsed=0,this._firstTick=!0},i.reverse=function(){return X(1010),this},i.setAmplitudeRate=function(){X(1011)},i.getAmplitudeRate=function(){return X(1012),0},i.speed=function(t){return t<=0?(X(1013),this):(this._speedMethod=!0,this._speed*=t,this)},i.getSpeed=function(){return this._speed},i.setSpeed=function(t){return this._speed=t,this},i.repeat=function(t){return t=Math.round(t),Number.isNaN(t)||t<1?(X(1014),this):(this._repeatMethod=!0,this._timesForRepeat*=t,this)},i.repeatForever=function(){return this._repeatMethod=!0,this._timesForRepeat=this.MAX_VALUE,this._repeatForever=!0,this},e}(uft),bft=function(t){function e(i){var n;(n=t.call(this)||this)._actions=[],n._split=0,n._last=0,n._reversed=!1;var r=i instanceof Array?i:arguments;if(1===r.length)return J(1019),c(n);var s=r.length-1;if(s>=0&&null==r[s]&&X(1015),s>=0){for(var o,a=r[0],h=1;h1?e%1:e),this._last=n)},i.reverse=function(){var t=e._actionOneTwo(this._actions[1].reverse(),this._actions[0].reverse());return this._cloneDecoration(t),this._reverseEaseList(t),t._reversed=!0,t},e}(Aft);function Eft(t){var e=t instanceof Array?t:arguments;if(1===e.length)return e[0];var i=e.length-1;i>=0&&null==e[i]&&X(1015);var n=null;if(i>=0){n=e[0];for(var r=1;r<=i;r++)e[r]&&(n=bft._actionOneTwo(n,e[r]))}return n}vft=bft,bft._actionOneTwo=function(t,e){var i=new vft;return i.initWithTwoActions(t,e),i};var Cft=function(t){function e(e,i){var n;return(n=t.call(this)||this)._times=0,n._total=0,n._nextDt=0,n._actionInstant=!1,n._innerAction=null,void 0!==i&&n.initWithAction(e,i),n}s(e,t);var i=e.prototype;return i.initWithAction=function(t,e){var i=t._duration*e;return!!this.initWithDuration(i)&&(this._times=e,this._innerAction=t,t instanceof fft&&(this._actionInstant=!0,this._times-=1),this._total=0,!0)},i.clone=function(){var t=new e;return this._cloneDecoration(t),t.initWithAction(this._innerAction.clone(),this._times),t},i.startWithTarget=function(t){this._total=0,this._nextDt=this._innerAction._duration/this._duration,Aft.prototype.startWithTarget.call(this,t),this._innerAction.startWithTarget(t)},i.stop=function(){this._innerAction.stop(),hft.prototype.stop.call(this)},i.update=function(t){t=this._computeEaseTime(t);var e=this._innerAction,i=this._duration,n=this._times,r=this._nextDt;if(t>=r){for(;t>r&&this._total1?1:r;t>=1&&this._total=0&&null==r[s]&&X(1015),s>=0){for(var o,a=r[0],h=1;hr?this._two=bft._actionOneTwo(e,Bft(n-r)):n0&&null==e[e.length-1]&&X(1015);for(var i=e[0],n=1;n0&&(i=this._time/this._duration),i>=1&&(i=1),this._transition===fpt.COLOR){var n=e._uiProps.uiComp;dn.lerp(gpt,this._fromColor,this._toColor,i),n&&(n.color=gpt)}else this.transition===fpt.SCALE&&(e.getScale(this._targetScale),this._targetScale.x=Ii(this._fromScale.x,this._toScale.x,i),this._targetScale.y=Ii(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===fpt.COLOR&&this._interactable){var i=t.getComponent(TV);i&&(i.color=this._normalColor)}else e===fpt.SCALE&&this._originalScale&&t.setScale(this._originalScale);this._transitionFinished=!0}},i._registerNodeEvent=function(){this.node.on(om.TOUCH_START,this._onTouchBegan,this),this.node.on(om.TOUCH_MOVE,this._onTouchMove,this),this.node.on(om.TOUCH_END,this._onTouchEnded,this),this.node.on(om.TOUCH_CANCEL,this._onTouchCancel,this),this.node.on(om.MOUSE_ENTER,this._onMouseMoveIn,this),this.node.on(om.MOUSE_LEAVE,this._onMouseMoveOut,this),this.node.on(Pft.XRUI_HOVER_ENTERED,this._xrHoverEnter,this),this.node.on(Pft.XRUI_HOVER_EXITED,this._xrHoverExit,this),this.node.on(Pft.XRUI_CLICK,this._xrClick,this),this.node.on(Pft.XRUI_UNCLICK,this._xrUnClick,this)},i._registerTargetEvent=function(t){t.on(om.TRANSFORM_CHANGED,this._onTargetTransformChanged,this)},i._unregisterNodeEvent=function(){this.node.off(om.TOUCH_START,this._onTouchBegan,this),this.node.off(om.TOUCH_MOVE,this._onTouchMove,this),this.node.off(om.TOUCH_END,this._onTouchEnded,this),this.node.off(om.TOUCH_CANCEL,this._onTouchCancel,this),this.node.off(om.MOUSE_ENTER,this._onMouseMoveIn,this),this.node.off(om.MOUSE_LEAVE,this._onMouseMoveOut,this),this.node.off(Pft.XRUI_HOVER_ENTERED,this._xrHoverEnter,this),this.node.off(Pft.XRUI_HOVER_EXITED,this._xrHoverExit,this),this.node.off(Pft.XRUI_CLICK,this._xrClick,this),this.node.off(Pft.XRUI_UNCLICK,this._xrUnClick,this)},i._unregisterTargetEvent=function(t){t.off(om.TRANSFORM_CHANGED)},i._getTargetSprite=function(t){var e=null;return t&&(e=t.getComponent(uz)),e},i._applyTarget=function(){this.target&&(this._sprite=this._getTargetSprite(this.target),this._originalScale||(this._originalScale=new on),on.copy(this._originalScale,this.target.getScale()),this._registerTargetEvent(this.target))},i._onTargetSpriteFrameChanged=function(t){this._transition===fpt.SPRITE&&this._setCurrentStateSpriteFrame(t.spriteFrame)},i._setCurrentStateSpriteFrame=function(t){if(t)switch(this._getButtonState()){case ppt.NORMAL:this._normalSprite=t;break;case ppt.HOVER:this._hoverSprite=t;break;case ppt.PRESSED:this._pressedSprite=t;break;case ppt.DISABLED:this._disabledSprite=t}},i._onTargetColorChanged=function(t){this._transition===fpt.COLOR&&this._setCurrentStateColor(t)},i._setCurrentStateColor=function(t){switch(this._getButtonState()){case ppt.NORMAL:this._normalColor=t;break;case ppt.HOVER:this._hoverColor=t;break;case ppt.PRESSED:this._pressedColor=t;break;case ppt.DISABLED:this._disabledColor=t}},i._onTargetTransformChanged=function(t){t&rm.SCALE&&this._originalScale&&this._transition===fpt.SCALE&&this._transitionFinished&&on.copy(this._originalScale,this.target.getScale())},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===fpt.SCALE&&this.target&&this._originalScale?n?(on.copy(this._fromScale,this._originalScale),on.multiplyScalar(this._toScale,this._originalScale,this._zoomScale),this._transitionFinished=!1):(this._time=0,this._transitionFinished=!0,this.target.setScale(this._originalScale)):(i=n?ppt.PRESSED:ppt.NORMAL,this._applyTransition(i)),t&&(t.propagationStopped=!0)}}},i._onTouchEnded=function(t){this._interactable&&this.enabledInHierarchy&&(this._pressed&&(ep.emitEvents(this.clickEvents,t),this.node.emit(mpt.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!==fpt.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=ppt.NORMAL;return this._interactable?this._pressed?t=ppt.PRESSED:this._hovered&&(t=ppt.HOVER):t=ppt.DISABLED,t.toString()},i._updateColorTransition=function(t){var e,i=this[t+"Color"],n=null===(e=this.target)||void 0===e?void 0:e.getComponent(TV);n&&(t===ppt.DISABLED.toString()?n.color=i:(this._fromColor=n.color.clone(),this._toColor=i,this._time=0,this._transitionFinished=!1))},i._updateSpriteTransition=function(t){var e=this[t+"Sprite"];this._sprite&&e&&(this._sprite.spriteFrame=e)},i._updateScaleTransition=function(t){this._interactable&&(t===ppt.PRESSED.toString()?this._zoomUp():this._zoomBack())},i._zoomUp=function(){this._originalScale&&(on.copy(this._fromScale,this._originalScale),on.multiplyScalar(this._toScale,this._originalScale,this._zoomScale),this._time=0,this._transitionFinished=!1)},i._zoomBack=function(){this.target&&this._originalScale&&(on.copy(this._fromScale,this.target.getScale()),on.copy(this._toScale,this._originalScale),this._time=0,this._transitionFinished=!1)},i._applyTransition=function(t){var e=this._transition;e===fpt.COLOR?this._updateColorTransition(t):e===fpt.SPRITE?this._updateSpriteTransition(t):e===fpt.SCALE&&this._updateScaleTransition(t)},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&&(ep.emitEvents(this.clickEvents,this),this.node.emit(mpt.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===fpt.COLOR?this._updateColorTransition(ppt.NORMAL):this._transition===fpt.SPRITE&&this._updateSpriteTransition(ppt.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(uz);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}(rp)).Transition=fpt,opt.EventType=mpt,p((jft=opt).prototype,"target",[Fft],Object.getOwnPropertyDescriptor(jft.prototype,"target"),jft.prototype),p(jft.prototype,"transition",[kft],Object.getOwnPropertyDescriptor(jft.prototype,"transition"),jft.prototype),p(jft.prototype,"normalSprite",[Vft],Object.getOwnPropertyDescriptor(jft.prototype,"normalSprite"),jft.prototype),p(jft.prototype,"pressedSprite",[Gft],Object.getOwnPropertyDescriptor(jft.prototype,"pressedSprite"),jft.prototype),p(jft.prototype,"hoverSprite",[Uft],Object.getOwnPropertyDescriptor(jft.prototype,"hoverSprite"),jft.prototype),p(jft.prototype,"disabledSprite",[zft],Object.getOwnPropertyDescriptor(jft.prototype,"disabledSprite"),jft.prototype),Xft=ks(jft.prototype,"clickEvents",[Hft,io],(function(){return[]})),qft=ks(jft.prototype,"_interactable",[io],(function(){return!0})),Yft=ks(jft.prototype,"_transition",[io],(function(){return fpt.NONE})),Kft=ks(jft.prototype,"_normalColor",[io],(function(){return dn.WHITE.clone()})),Jft=ks(jft.prototype,"_hoverColor",[io],(function(){return new dn(211,211,211,255)})),Qft=ks(jft.prototype,"_pressedColor",[io],(function(){return dn.WHITE.clone()})),Zft=ks(jft.prototype,"_disabledColor",[io],(function(){return new dn(124,124,124,255)})),$ft=ks(jft.prototype,"_normalSprite",[io],(function(){return null})),tpt=ks(jft.prototype,"_hoverSprite",[io],(function(){return null})),ept=ks(jft.prototype,"_pressedSprite",[io],(function(){return null})),ipt=ks(jft.prototype,"_disabledSprite",[io],(function(){return null})),npt=ks(jft.prototype,"_duration",[io],(function(){return.1})),rpt=ks(jft.prototype,"_zoomScale",[io],(function(){return 1.2})),spt=ks(jft.prototype,"_target",[io],(function(){return null})),Wft=jft))||Wft)||Wft)||Wft));v.Button=ypt;var vpt,Spt,Tpt,Apt=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}();Apt._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"}(vpt||(vpt={})),ge(vpt),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"}(Spt||(Spt={})),ge(Spt),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"}(Tpt||(Tpt={})),ge(Tpt);var bpt,Ept,Cpt,wpt,xpt,Rpt,Ipt,Bpt,Dpt,Ppt,Opt,Mpt,Lpt,Npt,Fpt,kpt,Vpt,Gpt,Upt,zpt,Hpt,Wpt,jpt,Xpt,qpt,Ypt,Kpt,Jpt,Qpt,Zpt,$pt=function(){function t(){this._editing=!1,this._delegate=null}var e=t.prototype;return e.init=function(){},e.onEnable=function(){},e.update=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}(),tmt=T.document,emt=new In,imt=new In,nmt=new on,rmt=null,smt=0,omt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r=0&&t.left>=0&&t.bottom<=(T.innerHeight||tmt.documentElement.clientHeight)&&t.right<=(T.innerWidth||tmt.documentElement.clientWidth)}return!1},i._adjustWindowScroll=function(){var t=this;setTimeout((function(){T.scrollY<40&&!t._isElementInViewport()&&t._edTxt.scrollIntoView({block:"start",inline:"nearest",behavior:"smooth"})}),400)},i._scrollBackWindow=function(){setTimeout((function(){xl.browserType!==Ju.WECHAT||xl.os!==$u.IOS?T.scrollTo(0,0):T.top&&T.top.scrollTo(0,0)}),400)},i._updateMatrix=function(){if(this._edTxt){var t=this._delegate.node,e=CH.getScaleX(),i=CH.getScaleY(),n=CH.getViewportRect(),r=El.devicePixelRatio;t.getWorldMatrix(emt);var s=t._uiProps.uiTransformComp;if(s&&(on.set(nmt,-s.anchorX*s.width,-s.anchorY*s.height,nmt.z),In.transform(emt,emt,nmt)),t._uiProps.uiTransformComp){var o=fN.root.batcher2D.getFirstRenderCamera(t);if(o){o.node.getWorldRT(imt);var a=imt.m12,h=imt.m13,u=Rl.center;imt.m12=u.x-(imt.m00*a+imt.m04*h),imt.m13=u.y-(imt.m01*a+imt.m05*h),e/=r,i/=r,on.set(nmt,e,i,1),In.scale(imt,imt,nmt);var l=SN.container,c=parseInt(l&&l.style.paddingLeft||"0");c+=n.x/r;var _=parseInt(l&&l.style.paddingBottom||"0");_+=n.y/r,imt.m12+=c,imt.m13+=_,In.multiply(imt,imt,emt);var d="matrix("+imt.m00+","+-imt.m01+","+-imt.m04+","+imt.m05+","+imt.m12+","+-imt.m13+")";this._edTxt.style.transform=d,this._edTxt.style["-webkit-transform"]=d,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===Tpt.INITIAL_CAPS_ALL_CHARACTERS?s="uppercase":i===Tpt.INITIAL_CAPS_WORD&&(s="capitalize"),void(r.style.textTransform=s)}if(r=r,i===Tpt.PASSWORD)return r.type="password",void(r.style.textTransform="none");var o=r.type;e===Spt.EMAIL_ADDR?o="email":e===Spt.NUMERIC?o="number":e===Spt.DECIMAL?o="digit":e===Spt.PHONE_NUMBER?(o="tel",r.addEventListener("wheel",(function(){return!1}))):e===Spt.URL?o="url":(o="text",n===vpt.SEARCH&&(o="search")),r.type=o;var a="none";i===Tpt.INITIAL_CAPS_ALL_CHARACTERS?a="uppercase":i===Tpt.INITIAL_CAPS_WORD&&(a="capitalize"),r.style.textTransform=a}},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=tmt.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 MF?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 lG.HorizontalAlign.LEFT:n.style.textAlign="left";break;case lG.HorizontalAlign.CENTER:n.style.textAlign="center";break;case lG.HorizontalAlign.RIGHT:n.style.textAlign="right"}}}},i._updatePlaceholderLabel=function(t){if(t){var e=t.font;e=!e||e instanceof MF?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,o="";switch(t.horizontalAlign){case lG.HorizontalAlign.LEFT:o="left";break;case lG.HorizontalAlign.CENTER:o="center";break;case lG.HorizontalAlign.RIGHT:o="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: "+o+";}#"+this._domId+"::-moz-placeholder{text-transform: initial;-family: "+e+";font-size: "+i+"px;color: "+r+";line-height: "+s+"px;text-align: "+o+";}#"+this._domId+"::-ms-input-placeholder{text-transform: initial;-family: "+e+";font-size: "+i+"px;color: "+r+";line-height: "+s+"px;text-align: "+o+";}",xl.browserType===Ju.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&&xl.isMobile&&t._adjustWindowScroll()},n.onKeydown=function(i){i.keyCode===Bw.ENTER?(i.propagationStopped=!0,t._delegate._editBoxEditingReturn(),t._isTextArea||e.blur()):i.keyCode===Bw.TAB&&(i.propagationStopped=!0,i.preventDefault(),Apt.next(t))},n.onBlur=function(){xl.isMobile&&i&&n.compositionEnd(),t._editing=!1,rmt=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}($pt);!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"}(Zpt||(Zpt={}));var amt,hmt,umt,lmt,cmt,_mt,dmt,fmt,pmt,mmt,gmt,ymt,vmt,Smt,Tmt,Amt,bmt,Emt,Cmt,wmt,xmt,Rmt,Imt,Bmt,Dmt,Pmt,Omt,Mmt,Lmt,Nmt,Fmt,kmt,Vmt,Gmt,Umt=t("f$",(bpt=qs("cc.EditBox"),Ept=Ks(110),Cpt=Ys(nV),wpt=xo(lG),xpt=xo(lG),Rpt=xo(pF),Ipt=xo(Tpt),Bpt=xo(Spt),Dpt=xo(vpt),Ppt=xo([ep]),Opt=xo([ep]),Mpt=xo([ep]),Lpt=xo([ep]),bpt(Npt=Ept(Npt=Cpt(((Qpt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r=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}(rp))._EditBoxImpl=$pt,Qpt.KeyboardReturnType=vpt,Qpt.InputFlag=Tpt,Qpt.InputMode=Spt,Qpt.EventType=Zpt,p((Fpt=Qpt).prototype,"textLabel",[wpt],Object.getOwnPropertyDescriptor(Fpt.prototype,"textLabel"),Fpt.prototype),p(Fpt.prototype,"placeholderLabel",[xpt],Object.getOwnPropertyDescriptor(Fpt.prototype,"placeholderLabel"),Fpt.prototype),p(Fpt.prototype,"backgroundImage",[Rpt],Object.getOwnPropertyDescriptor(Fpt.prototype,"backgroundImage"),Fpt.prototype),p(Fpt.prototype,"inputFlag",[Ipt],Object.getOwnPropertyDescriptor(Fpt.prototype,"inputFlag"),Fpt.prototype),p(Fpt.prototype,"inputMode",[Bpt],Object.getOwnPropertyDescriptor(Fpt.prototype,"inputMode"),Fpt.prototype),p(Fpt.prototype,"returnType",[Dpt],Object.getOwnPropertyDescriptor(Fpt.prototype,"returnType"),Fpt.prototype),kpt=ks(Fpt.prototype,"editingDidBegan",[Ppt,io],(function(){return[]})),Vpt=ks(Fpt.prototype,"textChanged",[Opt,io],(function(){return[]})),Gpt=ks(Fpt.prototype,"editingDidEnded",[Mpt,io],(function(){return[]})),Upt=ks(Fpt.prototype,"editingReturn",[Lpt,io],(function(){return[]})),zpt=ks(Fpt.prototype,"_textLabel",[io],(function(){return null})),Hpt=ks(Fpt.prototype,"_placeholderLabel",[io],(function(){return null})),Wpt=ks(Fpt.prototype,"_returnType",[io],(function(){return vpt.DEFAULT})),jpt=ks(Fpt.prototype,"_string",[io],(function(){return""})),Xpt=ks(Fpt.prototype,"_tabIndex",[io],(function(){return 0})),qpt=ks(Fpt.prototype,"_backgroundImage",[io],(function(){return null})),Ypt=ks(Fpt.prototype,"_inputFlag",[io],(function(){return Tpt.DEFAULT})),Kpt=ks(Fpt.prototype,"_inputMode",[io],(function(){return Spt.ANY})),Jpt=ks(Fpt.prototype,"_maxLength",[io],(function(){return 20})),Npt=Fpt))||Npt)||Npt)||Npt));"object"==typeof window&&"object"==typeof document&&(Umt._EditBoxImpl=omt),v.internal.EditBox=Umt,function(t){t[t.NONE=0]="NONE",t[t.HORIZONTAL=1]="HORIZONTAL",t[t.VERTICAL=2]="VERTICAL",t[t.GRID=3]="GRID"}(Lmt||(Lmt={})),Se(Lmt),function(t){t[t.NONE=0]="NONE",t[t.CONTAINER=1]="CONTAINER",t[t.CHILDREN=2]="CHILDREN"}(Nmt||(Nmt={})),Se(Nmt),function(t){t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL"}(Fmt||(Fmt={})),Se(Fmt),function(t){t[t.BOTTOM_TO_TOP=0]="BOTTOM_TO_TOP",t[t.TOP_TO_BOTTOM=1]="TOP_TO_BOTTOM"}(kmt||(kmt={})),Se(kmt),function(t){t[t.LEFT_TO_RIGHT=0]="LEFT_TO_RIGHT",t[t.RIGHT_TO_LEFT=1]="RIGHT_TO_LEFT"}(Vmt||(Vmt={})),Se(Vmt),function(t){t[t.NONE=0]="NONE",t[t.FIXED_ROW=1]="FIXED_ROW",t[t.FIXED_COL=2]="FIXED_COL"}(Gmt||(Gmt={})),Se(Gmt);var zmt,Hmt,Wmt,jmt,Xmt,qmt,Ymt,Kmt,Jmt,Qmt,Zmt,$mt,tgt,egt,igt=new on,ngt=t("g0",(amt=qs("cc.Layout"),hmt=Ks(110),umt=Ys(nV),lmt=xo(Lmt),cmt=xo(Nmt),_mt=xo(Fmt),dmt=xo(kmt),fmt=xo(Vmt),pmt=xo(Gmt),amt(mmt=hmt(mmt=umt(((Mmt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r_&&(d=Math.max(_,d),c=_||x,_=x),u+=o*(C*w+this._spacingX);var R=o*(1-C)*w;if(e){if(s>0)(f=v/s>0&&v%s==0)&&(c=_>x?_:c);else if(w>t-g)u>h+o*C*w&&(f=!0);else{var I=(1-this._horizontalDirection-r.x)*t,B=u+R+o*(o>0?this._paddingRight:this._paddingLeft);f=Math.abs(B)>Math.abs(I)}f&&(u=h+o*C*w,x!==_&&(c=_),l+=c+this._spacingY,c=_=x)}var D=i(T,S,l);n&&T.setPosition(u,D),u+=R}return c=Math.max(c,_),Math.max(d,l+c)+this._getPaddingV()},i._doLayoutVertically=function(t,e,i,n){var r=this.node._uiProps.uiTransformComp.anchorPoint,s=this._getFixedBreakingNum(),o=1,a=this._paddingBottom;this._verticalDirection===kmt.TOP_TO_BOTTOM&&(o=-1,a=this._paddingTop);var h=(this._verticalDirection-r.y)*t+o*a,u=h-o*this._spacingY,l=0,c=0,_=0,d=0,f=!1,p=this._usefulLayoutObj.length,m=this._cellSize.height,g=this._getPaddingV();this._layoutType!==Lmt.GRID&&this._resizeMode===Nmt.CHILDREN&&(m=(t-g-(p-1)*this._spacingY)/p);for(var y=this._usefulLayoutObj,v=0;vl&&(c=Math.max(l,c),_=l||w,l=w),u+=o*(C*x+this._spacingY);var R=o*(1-C)*x;if(e){if(s>0)(f=v/s>0&&v%s==0)&&(_=l>x?l:_);else if(x>t-g)u>h+o*C*x&&(f=!0);else{var I=(1-this._verticalDirection-r.y)*t,B=u+R+o*(o>0?this._paddingTop:this._paddingBottom);f=Math.abs(B)>Math.abs(I)}f&&(u=h+o*C*x,w!==l&&(_=l),d+=_+this._spacingX,_=l=w)}var D=i(T,S,d);n&&(T.getPosition(igt),T.setPosition(D,u,igt.z)),u+=R}return _=Math.max(_,l),Math.max(c,d+_)+this._getPaddingH()},i._doLayoutGridAxisHorizontal=function(t,e){var i=this,n=e.width,r=1,s=-t.y*e.height,o=this._paddingBottom;this._verticalDirection===kmt.TOP_TO_BOTTOM&&(r=-1,s=(1-t.y)*e.height,o=this._paddingTop);var a=function(t,e,n){return s+r*(n+(1-e.anchorY)*e.height*i._getUsedScaleValue(t.scale.y)+o)},h=0;this._resizeMode===Nmt.CONTAINER&&(h=this._doLayoutHorizontally(n,!0,a,!1),s=-t.y*h,this._verticalDirection===kmt.TOP_TO_BOTTOM&&(r=-1,s=(1-t.y)*h)),this._doLayoutHorizontally(n,!0,a,!0),this._resizeMode===Nmt.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,o=this._paddingLeft;this._horizontalDirection===Vmt.RIGHT_TO_LEFT&&(r=-1,s=(1-t.x)*e.width,o=this._paddingRight);var a=function(t,e,n){return s+r*(n+(1-e.anchorX)*e.width*i._getUsedScaleValue(t.scale.x)+o)},h=0;this._resizeMode===Nmt.CONTAINER&&(h=this._doLayoutVertically(n,!0,a,!1),s=-t.x*h,this._horizontalDirection===Vmt.RIGHT_TO_LEFT&&(r=-1,s=(1-t.x)*h)),this._doLayoutVertically(n,!0,a,!0),this._resizeMode===Nmt.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===Fmt.HORIZONTAL?this._doLayoutGridAxisHorizontal(e,i):this.startAxis===Fmt.VERTICAL&&this._doLayoutGridAxisVertical(e,i)},i._getHorizontalBaseWidth=function(){var t=this._usefulLayoutObj,e=0,i=t.length;if(this._resizeMode===Nmt.CONTAINER){for(var n=0;n0?n:-n)),i*(e/r)},i._calculatePosition=function(t,e,i,n,r,s,o){var a=e-i;s&&(a+=Math.abs(s));var h=0;a&&(h=Ri(h=r/a));var u=(n-o)*h;this._direction===ygt.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===Agt.x&&n.y===Agt.y||e.setAnchorPoint(Agt),this._direction===ygt.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(Ln.ZERO))}},{key:"direction",get:function(){return this._direction},set:function(t){this._direction!==t&&(this._direction=t,this.onScroll(Ln.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}(rp)).Direction=ygt,p((lgt=mgt).prototype,"handle",[agt],Object.getOwnPropertyDescriptor(lgt.prototype,"handle"),lgt.prototype),p(lgt.prototype,"direction",[hgt],Object.getOwnPropertyDescriptor(lgt.prototype,"direction"),lgt.prototype),cgt=ks(lgt.prototype,"_scrollView",[io],(function(){return null})),_gt=ks(lgt.prototype,"_handle",[io],(function(){return null})),dgt=ks(lgt.prototype,"_direction",[io],(function(){return ygt.HORIZONTAL})),fgt=ks(lgt.prototype,"_enableAutoHide",[io],(function(){return!1})),pgt=ks(lgt.prototype,"_autoHideTime",[io],(function(){return 1})),ugt=lgt))||ugt)||ugt)||ugt));v.ScrollBar=wgt;var xgt,Rgt,Igt,Bgt,Dgt,Pgt,Ogt,Mgt,Lgt,Ngt,Fgt,kgt,Vgt,Ggt,Ugt,zgt,Hgt,Wgt,jgt,Xgt,qgt,Ygt=t("g7",qs("cc.ViewGroup")(Cgt=Ks(110)(Cgt=function(t){function e(){return t.apply(this,arguments)||this}return s(e,t),e}(rp))||Cgt)||Cgt);v.ViewGroup=Ygt;var Kgt,Jgt,Qgt=1e-4,Zgt=new on,$gt=new on,tyt=new Ln,eyt=new Ln,iyt=function(){return(new Date).getMilliseconds()},nyt={"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"}(Kgt||(Kgt={})),function(t){t[t.NONE=0]="NONE",t[t.LEFT=1]="LEFT",t[t.RIGHT=2]="RIGHT"}(Jgt||(Jgt={}));var ryt,syt,oyt,ayt,hyt,uyt,lyt,cyt,_yt,dyt,fyt,pyt,myt,gyt=t("g3",(xgt=qs("cc.ScrollView"),Rgt=Ks(110),Igt=Ys(nV),Bgt=xo(Jm),Dgt=xo(wgt),Pgt=xo(wgt),Ogt=xo([ep]),xgt(Mgt=Rgt(Mgt=Igt(((qgt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r=0?e:0,i=i>=0?i:0)},i.scrollToPercentHorizontal=function(t,e,i){var n=this._calculateMovePercentDelta({anchor:new Ln(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 Ln(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 Ln(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 Iw(t.getTouches(),t.bubbles,Aw.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(Kgt.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(ngt);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!==Ew.CAPTURING_PHASE)return!1;if(e)for(var i,n=d(e);!(i=n()).done;){var r=i.value;if(this.node===r)return!(!t.target||!t.target.getComponent(Ygt));if(r.getComponent(Ygt))return!0}return!1},i._startInertiaScroll=function(t){var e=new on(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,o=n.height-r.height,a=this._calculateAttenuatedFactor(s),h=this._calculateAttenuatedFactor(o);i.x=i.x*s*(1-this.brake)*a,i.y=i.y*o*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,on.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(on.ZERO,Qgt)||(this._autoScrollCurrentlyOutOfBoundary=!0)},i._calculateTouchMoveVelocity=function(){var t=new on,e=0;if((e=this._touchMoveTimeDeltas.reduce((function(t,e){return t+e}),e))<=0||e>=.5)t.set(on.ZERO);else{var i=new on;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);Zgt.set(this._getContentPosition()),Zgt.add(i),Zgt.set(Math.round(1e4*Zgt.x)*Qgt,Math.round(1e4*Zgt.y)*Qgt,Zgt.z),this._setContentPosition(Zgt);var n=this._getHowMuchOutOfBoundary();tyt.set(n.x,n.y),this._updateScrollBar(tyt),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 on).equals(on.ZERO,Qgt)&&!this._outOfBoundaryAmountDirty)return this._outOfBoundaryAmount;var e=new on,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(on.ZERO,Qgt)&&(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===Kgt.SCROLL_ENDED)this._scrollEventEmitMask=0;else if(t===Kgt.SCROLL_TO_TOP||t===Kgt.SCROLL_TO_BOTTOM||t===Kgt.SCROLL_TO_LEFT||t===Kgt.SCROLL_TO_RIGHT){var e=1<0?l.y-a*u+i.y>=this._bottomBoundary&&(n=Kgt.SCROLL_TO_BOTTOM):i.y<0&&l.y-a*u+u+i.y<=this._topBoundary&&(n=Kgt.SCROLL_TO_TOP)),this.horizontal&&(i.x<0?l.x-o*h+h+i.x<=this._rightBoundary&&(r=Kgt.SCROLL_TO_RIGHT):i.x>0&&l.x-o*h+i.x>=this._leftBoundary&&(r=Kgt.SCROLL_TO_LEFT))}this._moveContent(i,!1),(this.horizontal&&0!==i.x||this.vertical&&0!==i.y)&&(this._scrolling||(this._scrolling=!0,this._dispatchEvent(Kgt.SCROLL_BEGAN)),this._dispatchEvent(Kgt.SCROLLING)),n!==Kgt.NONE&&this._dispatchEvent(n),r!==Kgt.NONE&&this._dispatchEvent(r)},i._handlePressLogic=function(){this._autoScrolling&&this._dispatchEvent(Kgt.SCROLL_ENDED),this._autoScrolling=!1,this._isBouncing=!1,this._touchMovePreviousTimestamp=iyt(),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=iyt();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(on.ZERO,Qgt))return!1;var e=Math.max(this.bounceDuration,0);return this._startAutoScroll(t,e,!0),this._isBouncing||(t.y>0&&this._dispatchEvent(Kgt.BOUNCE_TOP),t.y<0&&this._dispatchEvent(Kgt.BOUNCE_BOTTOM),t.x>0&&this._dispatchEvent(Kgt.BOUNCE_RIGHT),t.x<0&&this._dispatchEvent(Kgt.BOUNCE_LEFT),this._isBouncing=!0),!0},i._processInertiaScroll=function(){if(!this._startBounceBackIfNeeded()&&this.inertia){var t=this._calculateTouchMoveVelocity();!t.equals(Zgt,Qgt)&&this.brake<1&&this._startInertiaScroll(t)}this._onScrollBarTouchEnded()},i._isOutOfBoundary=function(){return!this._getHowMuchOutOfBoundary().equals(on.ZERO,Qgt)},i._isNecessaryAutoScrollBrake=function(){if(this._autoScrollBraking)return!0;if(this._isOutOfBoundary()){if(!this._autoScrollCurrentlyOutOfBoundary)return this._autoScrollCurrentlyOutOfBoundary=!0,this._autoScrollBraking=!0,on.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 o=this._autoScrollStartPosition.clone();o.add(s);var a=Math.abs(r-1)<=Qgt;if(Math.abs(r-1)<=this.getScrollEndedEventTiming()&&!this._isScrollEndedWithThresholdEventFired&&(this._dispatchEvent(Kgt.SCROLL_ENG_WITH_THRESHOLD),this._isScrollEndedWithThresholdEventFired=!0),this.elastic){var h=o.clone();h.subtract(this._autoScrollBrakingStartPosition),e&&h.multiplyScalar(i),o.set(this._autoScrollBrakingStartPosition),o.add(h)}else{var u=o.clone();u.subtract(this.getContentPosition());var l=this._getHowMuchOutOfBoundary(u);l.equals(on.ZERO,Qgt)||(o.add(l),a=!0)}a&&(this._autoScrolling=!1);var c=o.clone();c.subtract(this._getContentPosition()),this._clampDelta(c),this._moveContent(c,a),this._dispatchEvent(Kgt.SCROLLING),this._autoScrolling||(this._isBouncing=!1,this._scrolling=!1,this._dispatchEvent(Kgt.SCROLL_ENDED))},i._checkMouseWheel=function(t){if(!this._getHowMuchOutOfBoundary().equals(on.ZERO,Qgt))return this._processInertiaScroll(),this._scrolling&&(this._scrolling=!1,this._autoScrolling||this._dispatchEvent(Kgt.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(Kgt.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(Ln.ZERO,Ln.ONE);var r=this._getContentBottomBoundary()-this._bottomBoundary;r=-r;var s=this._getContentLeftBoundary()-this._leftBoundary;s=-s;var o=new on;if(this._content&&this.view){var a=0,h=this._content._uiProps.uiTransformComp.contentSize,u=this.view.contentSize;i&&(a=h.width-u.width,o.x=s-a*e.x),n&&(a=h.height-u.height,o.y=r-a*e.y)}return o},i._moveContentToTopLeft=function(t){var e=this._getContentBottomBoundary()-this._bottomBoundary;e=-e;var i=new on,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:Rl;this.isAlignLeft&&t===mvt.LEFT?this._left=e?this._left*r.width:this._left/r.width:this.isAlignRight&&t===mvt.RIGHT?this._right=e?this._right*r.width:this._right/r.width:this.isAlignHorizontalCenter&&t===mvt.CENTER?this._horizontalCenter=e?this._horizontalCenter*r.width:this._horizontalCenter/r.width:this.isAlignTop&&t===mvt.TOP?this._top=e?this._top*r.height:this._top/r.height:this.isAlignBottom&&t===mvt.BOT?this._bottom=e?this._bottom*r.height:this._bottom/r.height:this.isAbsoluteVerticalCenter&&t===mvt.MID&&(this._verticalCenter=this._verticalCenter/r.height),this._recursiveDirty()}},i._registerTargetEvents=function(){var t=this._target||this.node.parent;t&&t.getComponent(nV)&&(t.on(om.TRANSFORM_CHANGED,this._setDirtyByMode,this),t.on(om.SIZE_CHANGED,this._setDirtyByMode,this),t.on(om.ANCHOR_CHANGED,this._setDirtyByMode,this))},i._unregisterTargetEvents=function(){var t=this._target||this.node.parent;t&&(t.off(om.TRANSFORM_CHANGED,this._setDirtyByMode,this),t.off(om.SIZE_CHANGED,this._setDirtyByMode,this),t.off(om.ANCHOR_CHANGED,this._setDirtyByMode,this))},i._unregisterOldParentEvents=function(t){var e=this._target||t;e&&(e.off(om.TRANSFORM_CHANGED,this._setDirtyByMode,this),e.off(om.SIZE_CHANGED,this._setDirtyByMode,this))},i._setDirtyByMode=function(){this.alignMode===pvt.ALWAYS&&this._recursiveDirty()},i._setAlign=function(t,e){if(e!==(this._alignFlags&t)>0){var i=(t&Ovt)>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&mvt.TOP)>0},set:function(t){this._setAlign(mvt.TOP,t),this._recursiveDirty()}},{key:"isAlignBottom",get:function(){return(this._alignFlags&mvt.BOT)>0},set:function(t){this._setAlign(mvt.BOT,t),this._recursiveDirty()}},{key:"isAlignLeft",get:function(){return(this._alignFlags&mvt.LEFT)>0},set:function(t){this._setAlign(mvt.LEFT,t),this._recursiveDirty()}},{key:"isAlignRight",get:function(){return(this._alignFlags&mvt.RIGHT)>0},set:function(t){this._setAlign(mvt.RIGHT,t),this._recursiveDirty()}},{key:"isAlignVerticalCenter",get:function(){return(this._alignFlags&mvt.MID)>0},set:function(t){t?(this.isAlignTop=!1,this.isAlignBottom=!1,this._alignFlags|=mvt.MID):this._alignFlags&=~mvt.MID,this._recursiveDirty()}},{key:"isAlignHorizontalCenter",get:function(){return(this._alignFlags&mvt.CENTER)>0},set:function(t){t?(this.isAlignLeft=!1,this.isAlignRight=!1,this._alignFlags|=mvt.CENTER):this._alignFlags&=~mvt.CENTER,this._recursiveDirty()}},{key:"isStretchWidth",get:function(){return(this._alignFlags&Ovt)===Ovt}},{key:"isStretchHeight",get:function(){return(this._alignFlags&Pvt)===Pvt}},{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(mvt.TOP,this._isAbsTop))}},{key:"isAbsoluteBottom",get:function(){return this._isAbsBottom},set:function(t){this._isAbsBottom!==t&&(this._isAbsBottom=t,this._autoChangedValue(mvt.BOT,this._isAbsBottom))}},{key:"isAbsoluteLeft",get:function(){return this._isAbsLeft},set:function(t){this._isAbsLeft!==t&&(this._isAbsLeft=t,this._autoChangedValue(mvt.LEFT,this._isAbsLeft))}},{key:"isAbsoluteRight",get:function(){return this._isAbsRight},set:function(t){this._isAbsRight!==t&&(this._isAbsRight=t,this._autoChangedValue(mvt.RIGHT,this._isAbsRight))}},{key:"isAbsoluteHorizontalCenter",get:function(){return this._isAbsHorizontalCenter},set:function(t){this._isAbsHorizontalCenter!==t&&(this._isAbsHorizontalCenter=t,this._autoChangedValue(mvt.CENTER,this._isAbsHorizontalCenter))}},{key:"isAbsoluteVerticalCenter",get:function(){return this._isAbsVerticalCenter},set:function(t){this._isAbsVerticalCenter!==t&&(this._isAbsVerticalCenter=t,this._autoChangedValue(mvt.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}(rp)).AlignMode=pvt,p((Yyt=dvt).prototype,"target",[jyt],Object.getOwnPropertyDescriptor(Yyt.prototype,"target"),Yyt.prototype),p(Yyt.prototype,"alignMode",[Xyt],Object.getOwnPropertyDescriptor(Yyt.prototype,"alignMode"),Yyt.prototype),Kyt=ks(Yyt.prototype,"_alignFlags",[io],(function(){return 0})),Jyt=ks(Yyt.prototype,"_target",[io],(function(){return null})),Qyt=ks(Yyt.prototype,"_left",[io],(function(){return 0})),Zyt=ks(Yyt.prototype,"_right",[io],(function(){return 0})),$yt=ks(Yyt.prototype,"_top",[io],(function(){return 0})),tvt=ks(Yyt.prototype,"_bottom",[io],(function(){return 0})),evt=ks(Yyt.prototype,"_horizontalCenter",[io],(function(){return 0})),ivt=ks(Yyt.prototype,"_verticalCenter",[io],(function(){return 0})),nvt=ks(Yyt.prototype,"_isAbsLeft",[io],(function(){return!0})),rvt=ks(Yyt.prototype,"_isAbsRight",[io],(function(){return!0})),svt=ks(Yyt.prototype,"_isAbsTop",[io],(function(){return!0})),ovt=ks(Yyt.prototype,"_isAbsBottom",[io],(function(){return!0})),avt=ks(Yyt.prototype,"_isAbsHorizontalCenter",[io],(function(){return!0})),hvt=ks(Yyt.prototype,"_isAbsVerticalCenter",[io],(function(){return!0})),uvt=ks(Yyt.prototype,"_originalWidth",[io],(function(){return 0})),lvt=ks(Yyt.prototype,"_originalHeight",[io],(function(){return 0})),cvt=ks(Yyt.prototype,"_alignMode",[io],(function(){return pvt.ON_WINDOW_RESIZE})),_vt=ks(Yyt.prototype,"_lockFlags",[io,ro],(function(){return 0})),qyt=Yyt))||qyt)||qyt)||qyt));v.internal.computeInverseTransForTarget=vvt,v.internal.getReadonlyNodeSize=yvt,v.Widget=Mvt;var Lvt,Nvt=new dn;!function(t){t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL"}(Lvt||(Lvt={})),Se(Lvt);var Fvt,kvt,Vvt,Gvt,Uvt,zvt,Hvt,Wvt,jvt,Xvt,qvt,Yvt,Kvt,Jvt,Qvt,Zvt,$vt,tSt,eSt,iSt,nSt,rSt,sSt,oSt,aSt=t("ga",(Svt=qs("cc.PageViewIndicator"),Tvt=Ks(110),Avt=xo(pF),bvt=xo(Lvt),Evt=xo(Vn),Svt(Cvt=Tvt(((Dvt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r=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}(rp)).Direction=Lvt,p((wvt=Dvt).prototype,"spriteFrame",[Avt],Object.getOwnPropertyDescriptor(wvt.prototype,"spriteFrame"),wvt.prototype),p(wvt.prototype,"direction",[bvt],Object.getOwnPropertyDescriptor(wvt.prototype,"direction"),wvt.prototype),p(wvt.prototype,"cellSize",[Evt],Object.getOwnPropertyDescriptor(wvt.prototype,"cellSize"),wvt.prototype),xvt=ks(wvt.prototype,"spacing",[io],(function(){return 0})),Rvt=ks(wvt.prototype,"_spriteFrame",[io],(function(){return null})),Ivt=ks(wvt.prototype,"_direction",[io],(function(){return Lvt.HORIZONTAL})),Bvt=ks(wvt.prototype,"_cellSize",[io],(function(){return new Vn(20,20)})),Cvt=wvt))||Cvt)||Cvt));v.PageViewIndicator=aSt;var hSt,uSt,lSt,cSt=new Ln;!function(t){t[t.Unified=0]="Unified",t[t.Free=1]="Free"}(hSt||(hSt={})),Se(hSt),function(t){t[t.Horizontal=0]="Horizontal",t[t.Vertical=1]="Vertical"}(uSt||(uSt={})),Se(uSt),function(t){t.PAGE_TURNING="page-turning"}(lSt||(lSt={}));var _St=t("g9",(Fvt=qs("cc.PageView"),kvt=Ks(110),Vvt=xo(hSt),Gvt=xo(uSt),Uvt=xo(aSt),zvt=xo(wgt),Hvt=xo(wgt),Wvt=xo([ep]),jvt=xo([ep]),Fvt(Xvt=kvt(((oSt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r=this._pages.length)this.addPage(t);else{if(!t._uiProps.uiTransformComp)return void X(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):Y(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(ngt);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===uSt.Horizontal?(e.paddingLeft=(t.width-i.width)/2,e.paddingRight=(t.width-n.width)/2):this.direction===uSt.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,ep.emitEvents(this.pageEvents,this,lSt.PAGE_TURNING),this.node.emit(lSt.PAGE_TURNING,this))},i._isQuicklyScrollable=function(t){if(this.direction===uSt.Horizontal){if(Math.abs(t.x)>this.autoPageTurningThreshold)return!0}else if(this.direction===uSt.Vertical&&Math.abs(t.y)>this.autoPageTurningThreshold)return!0;return!1},i._moveOffsetValue=function(t){var e=new Ln;if(this._sizeMode===hSt.Free)this.direction===uSt.Horizontal?e.x=this._scrollCenterOffsetX[t]:this.direction===uSt.Vertical&&(e.y=this._scrollCenterOffsetY[t]);else{var i=this.view;if(!i)return e;this.direction===uSt.Horizontal?e.x=t*i.width:this.direction===uSt.Vertical&&(e.y=t*i.height)}return e},i._getDragDirection=function(t){return this._direction===uSt.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===hSt.Free){var n=0,r=0;if(this.direction===uSt.Horizontal)return n=this._scrollCenterOffsetX[e],r=this._scrollCenterOffsetX[i],Math.abs(t.x)>=Math.abs(n-r)*this.scrollThreshold;if(this.direction===uSt.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===uSt.Horizontal)return Math.abs(t.x)>=s.width*this.scrollThreshold;if(this.direction===uSt.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 Ln;Ln.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=gSt;s.set(0,0);var o=ySt;if(o.set(1,1),t.target&&vvt(n,r=t.target,s,o),!e)return;var a=r._uiProps&&r._uiProps.uiTransformComp,h=a?a.anchorPoint:fSt,u=n._uiProps.uiTransformComp,l=yvt(r),c=u.anchorPoint,_=n.getPosition(),d=mvt,f=n.getScale(),p=0;if(e&d.LEFT){var m=-h.x*l.width;m+=s.x,m*=o.x,p=_.x-c.x*u.width*Math.abs(f.x)-m,t.isAbsoluteLeft||(p/=l.width),p/=o.x,t.left=i(t.left,p)}if(e&d.RIGHT){var g=(1-h.x)*l.width;g+=s.x,p=(g*=o.x)-(_.x+(1-c.x)*u.width*Math.abs(f.x)),t.isAbsoluteRight||(p/=l.width),p/=o.x,t.right=i(t.right,p)}if(e&d.TOP){var y=(1-h.y)*l.height;y+=s.y,p=(y*=o.y)-(_.y+(1-c.y)*u.height*Math.abs(f.y)),t.isAbsoluteTop||(p/=l.height),p/=o.y,t.top=i(t.top,p)}if(e&d.BOT){var v=-h.y*l.height;v+=s.y,v*=o.y,p=_.y-c.y*u.height*Math.abs(f.y)-v,t.isAbsoluteBottom||(p/=l.height),p/=o.y,t.bottom=i(t.bottom,p)}}},updateAlignment:function t(e){var i=e.parent;i&&Jm.isNode(i)&&t(i);var n=e.getComponent(Mvt);n&&i&&vSt(e,n)},AlignMode:pvt,AlignFlags:mvt});fN.on(dN.EVENT_INIT,(function(){ESt.init()}));var CSt,wSt,xSt,RSt,ISt,BSt,DSt,PSt,OSt,MSt,LSt,NSt,FSt=t("gb",qs("cc.SafeArea")(ASt=Ks(110)(ASt=Ys(Mvt)(ASt=function(t){function e(){return t.apply(this,arguments)||this}s(e,t);var i=e.prototype;return i.onEnable=function(){this.updateArea(),El.on("window-resize",this.updateArea,this),El.on("orientation-change",this.updateArea,this)},i.onDisable=function(){El.off("window-resize",this.updateArea,this),El.off("orientation-change",this.updateArea,this)},i.updateArea=function(){var t=this.node.getComponent(Mvt),e=this.node.getComponent(nV);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=CH.getVisibleSize(),s=r.width,o=r.height,a=xl.getSafeAreaRect();t.top=o-a.y-a.height,t.bottom=a.y,t.left=a.x,t.right=s-a.x-a.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),ESt.add(t)}},e}(rp))||ASt)||ASt)||ASt);v.SafeArea=FSt;var kSt,VSt=t("gc",(CSt=qs("cc.UICoordinateTracker"),wSt=Ks(110),xSt=xo(Jm),RSt=xo(gH),ISt=xo([ep]),CSt(BSt=wSt((p((DSt=function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r0)){var i=this._distance/Math.abs(this._viewPos.z);ep.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}(rp)).prototype,"target",[xSt],Object.getOwnPropertyDescriptor(DSt.prototype,"target"),DSt.prototype),p(DSt.prototype,"camera",[RSt],Object.getOwnPropertyDescriptor(DSt.prototype,"camera"),DSt.prototype),PSt=ks(DSt.prototype,"syncEvents",[ISt,io],(function(){return[]})),OSt=ks(DSt.prototype,"_target",[io],(function(){return null})),MSt=ks(DSt.prototype,"_camera",[io],(function(){return null})),LSt=ks(DSt.prototype,"_useScale",[io],(function(){return!0})),NSt=ks(DSt.prototype,"_distance",[io],(function(){return 1})),BSt=DSt))||BSt)||BSt)),GSt=[om.TOUCH_START,om.TOUCH_END,om.TOUCH_MOVE,om.MOUSE_DOWN,om.MOUSE_MOVE,om.MOUSE_UP,om.MOUSE_ENTER,om.MOUSE_LEAVE,om.MOUSE_WHEEL];function USt(t){t.propagationStopped=!0}var zSt,HSt,WSt,jSt,XSt,qSt=t("gd",qs("cc.BlockInputEvents")(kSt=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=CH.getViewportRect(),o=e.getBoundingBoxToWorld(),a=CH.getVisibleSize(),h=El.devicePixelRatio,u=(s.width*(o.x/a.width)+s.x)/h,l=(s.height*(o.y/a.height)+s.y)/h,c=s.width*(o.width/a.width)/h,_=s.height*(o.height/a.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(om.TRANSFORM_CHANGED,this._updateSubContextView,this),this.node.on(om.SIZE_CHANGED,this._updateSubContextView,this),this.node.on(om.LAYER_CHANGED,this._updateContentLayer,this)},i._unregisterNodeEvent=function(){this.node.off(om.TRANSFORM_CHANGED,this._updateSubContextView,this),this.node.off(om.SIZE_CHANGED,this._updateSubContextView,this),this.node.off(om.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}(rp),WSt=ks(HSt.prototype,"_fps",[io],(function(){return 60})),jSt=ks(HSt.prototype,"_designResolutionSize",[io],(function(){return new Vn(640,960)})),zSt=HSt))||zSt)||zSt)||zSt);v.SubContextView=YSt,pt({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 KSt=t("gj",qs("cc.UIReorderComponent")(XSt=function(){Y(1408,"UIReorderComponent")})||XSt);v.UIReorderComponent=KSt,v.ButtonComponent=ypt,Qt(ypt,"cc.ButtonComponent"),v.EditBoxComponent=Umt,Qt(Umt,"cc.EditBoxComponent"),v.LayoutComponent=ngt,Qt(ngt,"cc.LayoutComponent"),v.ProgressBarComponent=ggt,Qt(ggt,"cc.ProgressBarComponent"),v.ScrollViewComponent=gyt,Qt(gyt,"cc.ScrollViewComponent"),v.ScrollBarComponent=wgt,Qt(wgt,"cc.ScrollBarComponent"),v.SliderComponent=Pyt,Qt(Pyt,"cc.SliderComponent"),v.ToggleComponent=Uyt,Qt(Uyt,"cc.ToggleComponent"),v.ToggleContainerComponent=fvt,Qt(fvt,"cc.ToggleContainerComponent"),v.WidgetComponent=Mvt,Qt(Mvt,"cc.WidgetComponent"),v.PageViewComponent=_St,Qt(_St,"cc.PageViewComponent"),v.PageViewIndicatorComponent=aSt,Qt(aSt,"cc.PageViewIndicatorComponent"),v.SafeAreaComponent=FSt,Qt(FSt,"cc.SafeAreaComponent"),Qt(VSt,"cc.UICoordinateTrackerComponent"),v.BlockInputEventsComponent=qSt,Qt(qSt,"cc.BlockInputEventsComponent"),rt(SH.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"}]),st(SH.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"}])}}}));