@galacean/effects 2.5.0-alpha.5 → 2.5.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/alipay.js +1 -1
- package/dist/alipay.mjs +1 -1
- package/dist/douyin.js +1 -1
- package/dist/douyin.mjs +1 -1
- package/dist/index.js +4 -4
- package/dist/index.min.js +2 -2
- package/dist/index.mjs +4 -4
- package/dist/weapp.js +1 -1
- package/dist/weapp.mjs +1 -1
- package/package.json +3 -3
package/dist/alipay.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{crypto as t,screen as e,document as i,window as r,navigator as n,atob as s,Blob as a,WebGL2RenderingContext as o,WebGLRenderingContext as u,XMLHttpRequest as h,HTMLImageElement as c,URL as l,Image as f,performance as d,HTMLCanvasElement as p,HTMLVideoElement as m,location as v,TextDecoder as y,cancelAnimationFrame as g,requestAnimationFrame as x,Event as b}from"@galacean/appx-adapter/alipay";function T(t,e,i,r,n,s,a){try{var o=t[s](a),u=o.value}catch(t){return void i(t)}o.done?e(u):Promise.resolve(u).then(r,n)}function E(t){return function(){var e=this,i=arguments;return new Promise((function(r,n){var s=t.apply(e,i);function a(t){T(s,r,n,a,o,"next",t)}function o(t){T(s,r,n,a,o,"throw",t)}a(void 0)}))}}function _(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,r=new Array(e);i<e;i++)r[i]=t[i];return r}function w(t,e){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(i)return(i=i.call(t)).next.bind(i);if(Array.isArray(t)||(i=function(t,e){if(t){if("string"==typeof t)return _(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(i):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?_(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){i&&(t=i);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}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 A(t,e){return null!=e&&"undefined"!=typeof Symbol&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](t):A(t,e)}function C(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t}function S(t,e,i,r){var n,s=arguments.length,a=s<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,r);else for(var o=t.length-1;o>=0;o--)(n=t[o])&&(a=(s<3?n(a):s>3?n(e,i,a):n(e,i))||a);return s>3&&a&&Object.defineProperty(e,i,a),a}function O(t,e){var i,r,n,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=o(0),a.throw=o(1),a.return=o(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function o(o){return function(u){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;a&&(a=0,o[0]&&(s=0)),s;)try{if(i=1,r&&(n=2&o[0]?r.return:o[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,o[1])).done)return n;switch(r=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{i=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}}var R;"function"==typeof SuppressedError&&SuppressedError;var M=new Uint8Array(16);function I(){if(!R&&!(R=void 0!==t&&t.getRandomValues&&t.getRandomValues.bind(t)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return R(M)}for(var P=[],L=0;L<256;++L)P.push((L+256).toString(16).slice(1));var F,V={randomUUID:void 0!==t&&t.randomUUID&&t.randomUUID.bind(t)};function N(t,e,i){if(V.randomUUID&&!e&&!t)return V.randomUUID();var r=(t=t||{}).random||(t.rng||I)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){i=i||0;for(var n=0;n<16;++n)e[i+n]=r[n];return e}return function(t,e){return void 0===e&&(e=0),P[t[e+0]]+P[t[e+1]]+P[t[e+2]]+P[t[e+3]]+"-"+P[t[e+4]]+P[t[e+5]]+"-"+P[t[e+6]]+P[t[e+7]]+"-"+P[t[e+8]]+P[t[e+9]]+"-"+P[t[e+10]]+P[t[e+11]]+P[t[e+12]]+P[t[e+13]]+P[t[e+14]]+P[t[e+15]]}(r)}function D(t,e){return t.includes(e)||t.push(e),t}function k(t,e){var i=t.indexOf(e);return i>-1&&t.splice(i,1),t}function z(t,e,i,r){if(void 0===r&&(r=!1),!t.includes(e)&&(t.push(e),1!==t.length)){var n=t.length-1;if(n){var s=t[n];if(r)for(;t[n-1][i]<s[i]&&(t[n]=t[n-1],0!=--n););else for(;t[n-1][i]>s[i]&&(t[n]=t[n-1],0!=--n););t[n]=s}}}function U(t,e,i,r){if(void 0===r&&(r=1),t.buffer.byteLength<t.BYTES_PER_ELEMENT*e){var n=Math.ceil(e*r);Number.isNaN(i)||(n=Math.min(n,i));var s=new ArrayBuffer(t.BYTES_PER_ELEMENT*n),a=new t.constructor(s);return a.set(t),a}return t}function B(t,e){var i=[0,0,0,0];if(yt(t)){t=t.replace(/[\s\t\r\n]/g,"");var r=/rgba?\(([.\d]+),([.\d]+),([.\d]+),?([.\d]+)?\)/.exec(t);if(r){var n=+r[4];i=[+r[1],+r[2],+r[3],isNaN(n)?255:255*n]}else/^#[a-f\d]{3}$/i.test(t)?i=[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16),255]:(r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t))&&(i=[parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16),255])}else A(t,Array)&&(i=[t[0],t[1],t[2],isNaN(t[3])?255:t[3]]);if(e)for(var s=0;s<4;s++)i[s]/=255;return i}function G(t,e,i){if(t.length){for(var r,n=1;n<=t.length-1;n++){var s=t[n-1],a=t[n];if(s.stop<=e&&e<=a.stop){r=X(s.color,a.color,(e-s.stop)/(a.stop-s.stop));break}}return r||(r=t[t.length-1].color),i?r.map((function(t){return t/255})):r}return[0,0,0,0]}function j(t){var e=[];if(A(t,Array)?t.forEach((function(t){var i=t[0],r=t[1],n=t[2],s=t[3],a=t[4];e.push({stop:H(i),color:[r,n,s,a]})})):Object.keys(t).forEach((function(i){var r=B(t[i]);e.push({stop:H(i),color:r})})),(e=e.sort((function(t,e){return t.stop-e.stop}))).length){0!==e[0].stop&&e.unshift({stop:0,color:e[0].color.slice()});var i=e[e.length-1];1!==i.stop&&e.push({stop:1,color:i.color.slice()})}return e}function X(t,e,i,r){var n=[],s=1-i;if(r)for(var a=0;a<4;a++)n[a]=t[a]*s+e[a]*i;else{for(var o=0;o<3;o++)n[o]=Math.round(Math.sqrt(t[o]*t[o]*s+e[o]*e[o]*i));n[3]=Math.round(t[3]*s+e[3]*i)}return n}function H(t){var e=/^(-)?([\d+.]+)%$/.exec(t);return e?+e[2]/100*(e[1]?-1:1):+t}function Y(){if("object"==typeof e&&"object"==typeof i){var t=Math.max(i.documentElement.clientWidth,r.innerWidth||0),n=e.width/t;return Math.min(2*n,2)}return 1}function W(){return!!n.platform&&/iPad|iPhone|iPod/.test(n.platform)}function Z(){var t=n.userAgent.toLowerCase().match(/cpu (iphone )?os (.*?) like mac os/);return t?parseInt(t[2],10):0}function q(){return/\b[Aa]ndroid\b/.test(n.userAgent)}function K(){return/\bOpenHarmony\b/.test(n.userAgent)}function Q(){return q()||K()||/\b(iPad|iPhone|iPod)\b/.test(n.userAgent)}function J(){return $()||tt()}function $(){var t;return"undefined"!=typeof my&&"web"===(null==(t=my)?void 0:t.renderTarget)}function tt(){return"miniprogram"===r.__wxjs_environment}function et(t){yt(t)&&(t=B(t));for(var e=t,i={width:1,height:1,data:new Uint8Array(4)},r=i.data,n=0;n<4;n++)r[n]=e[n];return i}function it(t){var e=128,i={width:e,height:1,data:new Uint8Array(512)},r=i.data,n=j(t);if(n.length){r.set(n[0].color,0);for(var s=1;s<127;s++){for(var a=s/e,o=void 0,u=void 0,h=0;h<n.length&&(o=n[h],u=n[h+1],!(o.stop<=a&&u.stop>a));h++);var c=X(o.color,u.color,(a-o.stop)/(u.stop-o.stop));r.set(c,4*s)}r.set(n[n.length-1].color,508)}return i}function rt(t,e){void 0===e&&(e=2);var i=t.length;if(i<=1||1===e)return t;if(i<=30){for(var r=1;r<i;r++)st(t,r,e);return t}return at(t,e)}function nt(t,e,i){return void 0===i&&(i=2),t.includes(e)?t:(t.push(e),1===t.length||1!==i&&st(t,t.length-1,i),t)}function st(t,e,i){var r=t[e];if(2!==i)for(;e>=1&&t[e-1].priority<r.priority&&(t[e]=t[e-1],0!=--e););else for(;e>=1&&t[e-1].priority>r.priority&&(t[e]=t[e-1],0!=--e););t[e]=r}function at(t,e,i,r){if(void 0===i&&(i=0),void 0===r&&(r=t.length-1),i>=r)return t;for(var n,s=t[i],a=i,o=r;a<o;){if(2===e){for(;t[o].priority>s.priority&&o>=a;)o--;for(;t[a].priority<=s.priority&&a<o;)a++}else{for(;t[o].priority<s.priority&&o>=a;)o--;for(;t[a].priority>=s.priority&&a<o;)a++}var u;u=[t[o],t[a]],t[a]=u[0],t[o]=u[1]}return n=[t[a],t[i]],t[i]=n[0],t[a]=n[1],at(t,e,i,a-1),at(t,e,o+1,r),t}function ot(t,e){if(void 0===e&&(e="item doesn't exist"),null==t)throw new Error(e)}function ut(t,e){if(void 0===e&&(e="asserts failed"),!t)throw new Error(e)}function ht(t){return/^[^\d.][\w-]*$/.test(t)}!function(t){t[t.none=1]="none",t[t.ascending=2]="ascending",t[t.descending=3]="descending"}(F||(F={}));var ct,lt=function(){var t=this;this.promise=new Promise((function(e,i){t.resolve=e,t.reject=i}))},ft="[Galacean Effects]";function dt(t){return["%c"+ft,"color: #AA0100",""+t]}var pt,mt={error:function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;r<e;r++)i[r-1]=arguments[r];var n;(n=console).error.apply(n,[].concat(dt(t),[i])),null==ct||ct("error",t,i)},info:function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;r<e;r++)i[r-1]=arguments[r];var n;(n=console).debug.apply(n,[].concat(dt(t))),null==ct||ct("info",t,i)},warn:function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;r<e;r++)i[r-1]=arguments[r];var n;(n=console).warn.apply(n,[].concat(dt(t))),null==ct||ct("warn",t,i)},register:function(t){t&&xt(t)&&(ct=t)}};function vt(){}function yt(t){return"string"==typeof t}!function(t){t[t.destroy=0]="destroy",t[t.keep=1]="keep",t[t.force=0]="force"}(pt||(pt={}));var gt=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function xt(t){return"[object Function]"===Object.prototype.toString.call(t)}function bt(t){return"[object Object]"===Object.prototype.toString.call(t)}function Tt(t){var e;return"object"==typeof t&&null!==t&&"CANVAS"===(null==(e=t.tagName)?void 0:e.toUpperCase())}function Et(t,e){return t+Math.random()*(e-t)}function _t(){throw new Error("Destroyed item cannot be used again.")}function wt(){return N().replace(/-/g,"")}function At(t,e,i){void 0===e&&(e="base64File"),void 0===i&&(i="");for(var r=t.split(",")[1]||t,n=s(r),o=[],u=0;u<n.length;u+=512){for(var h=n.slice(u,u+512),c=new Array(h.length),l=0;l<h.length;l++)c[l]=h.charCodeAt(l);var f=new Uint8Array(c);o.push(f)}var d=new a(o,{type:i});return new File([d],e,{type:i})}function Ct(t,e){e.forEach((function(e){Object.getOwnPropertyNames(e.prototype).forEach((function(i){var r=Object.getOwnPropertyDescriptor(e.prototype,i);if(!r)throw new Error("Cannot find property descriptor of class "+e);Object.defineProperty(t.prototype,i,r)}))}))}var St={},Ot=[],Rt={};function Mt(t,e,i){Rt[t]&&mt.error("Duplicate registration for plugin "+t+"."),Rt[t]=i,St[t]=e,D(Ot,t)}function It(t){delete Rt[t],delete St[t],k(Ot,t)}var Pt=function(){function t(t){var e={},i=[];Ot.forEach((function(t){var r=St[t];i.includes(r)||(i.push(r),e[t]=r)}));for(var r,n=w(t);!(r=n()).done;){var s=r.value;if(!St[s])throw new Error("The plugin '"+s+"' not found."+Ft(s))}this.plugins=Object.keys(e).map((function(t){var e=new(0,St[t]);return e.name=t,e})).sort((function(t,e){return t.order-e.order}))}var e=t.prototype;return e.initializeComposition=function(t,e){this.plugins.forEach((function(i){return i.onCompositionConstructed(t,e)}))},e.destroyComposition=function(t){this.plugins.forEach((function(e){return e.onCompositionDestroyed(t)}))},e.resetComposition=function(t,e){this.plugins.forEach((function(i){return i.onCompositionReset(t,e)}))},e.processRawJSON=function(t,e){var i=this;return E((function(){return O(this,(function(r){return[2,i.callStatic("processRawJSON",t,e)]}))}))()},e.processAssets=function(t,e){var i=this;return E((function(){return O(this,(function(r){return[2,i.callStatic("processAssets",t,e)]}))}))()},e.precompile=function(t,e){for(var i,r=w(this.plugins);!(i=r()).done;){i.value.precompile(t,e)}},e.loadResources=function(t,e){var i=this;return E((function(){return O(this,(function(r){return[2,i.callStatic("prepareResource",t,e)]}))}))()},e.callStatic=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;r<e;r++)i[r-1]=arguments[r];var n=this;return E((function(){var e,r,s,a,o,u,h;return O(this,(function(c){for(e=[],r=n.plugins,s=0;s<r.length;s++)a=r[s],o=St[a.name],t in o&&e.push(Promise.resolve(null==(h=o[t])?void 0:(u=h).call.apply(u,[].concat([o],i))));return[2,Promise.all(e)]}))}))()},t}(),Lt={"alipay-downgrade":"@galacean/effects-plugin-alipay-downgrade",downgrade:"@galacean/effects-plugin-downgrade","editor-gizmo":"@galacean/effects-plugin-editor-gizmo",model:"@galacean/effects-plugin-model",video:"@galacean/effects-plugin-multimedia",audio:"@galacean/effects-plugin-multimedia","orientation-transformer":"@galacean/effects-plugin-orientation-transformer","rich-text":"@galacean/effects-plugin-rich-text",spine:"@galacean/effects-plugin-spine"};function Ft(t){var e=Lt[t];return e?"\n请按如下命令进行操作(Please follow the commands below to proceed):\n1、使用 npm 安装插件(Install Plugin):npm i "+e+"@latest --save\n2、导入插件(Import Plugin):import '"+e+"'":""}var Vt,Nt,Dt,kt,zt,Ut,Bt,Gt,jt,Xt,Ht,Yt,Wt,Zt,qt=function(){function t(){this.order=100,this.name=""}var e=t.prototype;return e.precompile=function(t,e){},e.onCompositionConstructed=function(t,e){},e.onCompositionItemLifeBegin=function(t,e){},e.onCompositionItemLifeEnd=function(t,e){},e.onCompositionItemRemoved=function(t,e){},e.onCompositionReset=function(t,e){},e.onCompositionWillReset=function(t,e){},e.onCompositionDestroyed=function(t){},e.onCompositionUpdate=function(t,e){},e.prepareRenderFrame=function(t,e){return!1},e.postProcessFrame=function(t,e){},t}();function Kt(t,e){return Kt=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Kt(t,e)}function Qt(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Kt(t,e)}!function(t){t["1_0"]="1.0",t["1_1"]="1.1",t["1_2"]="1.2",t["1_3"]="1.3",t["1_5"]="1.5",t["1_8"]="1.8",t["2_0"]="2.0",t["2_1"]="2.1",t["2_2"]="2.2",t["2_3"]="2.3",t["2_4"]="2.4",t["3_0"]="3.0",t["3_1"]="3.1",t["3_2"]="3.2",t["3_3"]="3.3",t.LATEST="3.3"}(Vt||(Vt={})),function(t){t.S="S",t.APlus="A+",t.A="A",t.BPlus="B+",t.B="B"}(Nt||(Nt={})),function(t){t[t.ALPHA=0]="ALPHA",t[t.ADD=1]="ADD",t[t.MULTIPLY=2]="MULTIPLY",t[t.BRIGHTNESS=3]="BRIGHTNESS",t[t.SUBTRACTION=4]="SUBTRACTION",t[t.STRONG_LIGHT=5]="STRONG_LIGHT",t[t.WEAK_LIGHT=6]="WEAK_LIGHT",t[t.SUPERPOSITION=7]="SUPERPOSITION"}(Dt||(Dt={})),function(t){t[t.DOUBLE=1032]="DOUBLE",t[t.FRONT=1028]="FRONT",t[t.BACK=1029]="BACK"}(kt||(kt={})),function(t){t[t.OBSCURED=2]="OBSCURED",t[t.REVERSE_OBSCURED=3]="REVERSE_OBSCURED"}(zt||(zt={})),function(t){t[t.NONE=0]="NONE",t[t.SPHERE=1]="SPHERE",t[t.CONE=2]="CONE",t[t.HEMISPHERE=3]="HEMISPHERE",t[t.CIRCLE=4]="CIRCLE",t[t.DONUT=5]="DONUT",t[t.RECTANGLE=6]="RECTANGLE",t[t.RECTANGLE_EDGE=7]="RECTANGLE_EDGE",t[t.EDGE=8]="EDGE",t[t.TEXTURE=9]="TEXTURE"}(Ut||(Ut={})),function(t){t[t.GYROSCOPE=0]="GYROSCOPE",t[t.SPINE=1]="SPINE"}(Bt||(Bt={})),function(t){t[t.CLICK=0]="CLICK",t[t.MESSAGE=1]="MESSAGE",t[t.DRAG=2]="DRAG"}(Gt||(Gt={})),function(t){t[t.NONE=0]="NONE",t[t.NOTIFY=1]="NOTIFY",t[t.RESUME_PLAYER=2]="RESUME_PLAYER",t[t.REMOVE=3]="REMOVE",t[t.PAUSE=4]="PAUSE"}(jt||(jt={})),function(t){t.base="0",t.sprite="1",t.particle="2",t.null="3",t.interact="4",t.plugin="5",t.camera="6",t.composition="7",t.spine="spine",t.mesh="mesh",t.tree="tree",t.text="text",t.light="light",t.skybox="skybox",t.effect="effect",t.shape="shape",t.postProcessVolume="postProcessVolume",t.node="node",t.video="video",t.audio="audio",t.richtext="richtext"}(Xt||(Xt={})),function(t){t[t.BILLBOARD=0]="BILLBOARD",t[t.MESH=1]="MESH",t[t.VERTICAL_BILLBOARD=2]="VERTICAL_BILLBOARD",t[t.HORIZONTAL_BILLBOARD=3]="HORIZONTAL_BILLBOARD"}(Ht||(Ht={})),function(t){t[t.PARTICLE_ORIGIN_CENTER=0]="PARTICLE_ORIGIN_CENTER",t[t.PARTICLE_ORIGIN_LEFT_TOP=1]="PARTICLE_ORIGIN_LEFT_TOP",t[t.PARTICLE_ORIGIN_LEFT_CENTER=2]="PARTICLE_ORIGIN_LEFT_CENTER",t[t.PARTICLE_ORIGIN_LEFT_BOTTOM=3]="PARTICLE_ORIGIN_LEFT_BOTTOM",t[t.PARTICLE_ORIGIN_CENTER_TOP=4]="PARTICLE_ORIGIN_CENTER_TOP",t[t.PARTICLE_ORIGIN_CENTER_BOTTOM=5]="PARTICLE_ORIGIN_CENTER_BOTTOM",t[t.PARTICLE_ORIGIN_RIGHT_TOP=6]="PARTICLE_ORIGIN_RIGHT_TOP",t[t.PARTICLE_ORIGIN_RIGHT_CENTER=7]="PARTICLE_ORIGIN_RIGHT_CENTER",t[t.PARTICLE_ORIGIN_RIGHT_BOTTOM=8]="PARTICLE_ORIGIN_RIGHT_BOTTOM"}(Yt||(Yt={})),function(t){t.Opaque="Opaque",t.Transparent="Transparent"}(Wt||(Wt={})),function(t){t.Both="Both",t.Back="Back",t.Front="Front"}(Zt||(Zt={}));var Jt,$t,te,ee,ie,re,ne,se,ae,oe,ue,he,ce,le,fe,de,pe,me=1,ve=3,ye=0;!function(t){t[t.portrait=1]="portrait",t[t.landscape=0]="landscape"}(Jt||(Jt={})),function(t){t[t.CONSTANT=0]="CONSTANT",t[t.CONSTANT_VEC2=1]="CONSTANT_VEC2",t[t.CONSTANT_VEC3=2]="CONSTANT_VEC3",t[t.CONSTANT_VEC4=3]="CONSTANT_VEC4",t[t.RANDOM=4]="RANDOM",t[t.LINE=5]="LINE",t[t.CURVE=6]="CURVE",t[t.BEZIER_PATH=7]="BEZIER_PATH",t[t.RGBA_COLOR=8]="RGBA_COLOR",t[t.GRADIENT_COLOR=9]="GRADIENT_COLOR",t[t.SHAPE_POINTS=10]="SHAPE_POINTS",t[t.SHAPE_SPLITS=11]="SHAPE_SPLITS",t[t.LINEAR_PATH=12]="LINEAR_PATH",t[t.COLORS=13]="COLORS",t[t.BINARY=20]="BINARY",t[t.BEZIER_CURVE=21]="BEZIER_CURVE",t[t.BEZIER_CURVE_PATH=22]="BEZIER_CURVE_PATH",t[t.BEZIER_CURVE_QUAT=23]="BEZIER_CURVE_QUAT",t[t.COLOR_CURVE=24]="COLOR_CURVE",t[t.VECTOR4_CURVE=25]="VECTOR4_CURVE",t[t.VECTOR2_CURVE=26]="VECTOR2_CURVE"}($t||($t={})),function(t){t[t.AUTO=0]="AUTO",t[t.EASE=1]="EASE",t[t.EASE_IN=2]="EASE_IN",t[t.EASE_OUT=3]="EASE_OUT",t[t.LINE=4]="LINE",t[t.HOLD=5]="HOLD",t[t.LINE_OUT=6]="LINE_OUT"}(te||(te={})),function(t){t[t.destroy=0]="destroy",t[t.restart=5]="restart",t[t.forward=2]="forward",t[t.freeze=4]="freeze"}(ee||(ee={})),function(t){t[t.none=0]="none",t[t.removeParticle=1]="removeParticle"}(ie||(ie={})),function(t){t[t.RANDOM=0]="RANDOM",t[t.UNIDIRECTIONAL_CYCLE=1]="UNIDIRECTIONAL_CYCLE",t[t.BIDIRECTIONAL_CYCLE=2]="BIDIRECTIONAL_CYCLE",t[t.UNIFORM_BURST=3]="UNIFORM_BURST"}(re||(re={})),function(t){t.point="point",t.spot="spot",t.directional="directional",t.ambient="ambient"}(ne||(ne={})),function(t){t[t.box=2]="box",t[t.sphere=3]="sphere"}(se||(se={})),function(t){t.orthographic="orthographic",t.perspective="perspective"}(ae||(ae={})),function(t){t.unlit="unlit",t.pbr="pbr",t.hair="hair"}(oe||(oe={})),function(t){t[t.opaque=100]="opaque",t[t.masked=101]="masked",t[t.translucent=102]="translucent",t[t.additive=103]="additive"}(ue||(ue={})),function(t){t.none="none",t.uv="uv",t.normal="normal",t.basecolor="basecolor",t.alpha="alpha",t.metallic="metallic",t.roughness="roughness",t.ao="ao",t.emissive="emissive",t.diffuse="diffuse"}(he||(he={})),function(t){t[t.display=0]="display",t[t.clip=1]="clip",t[t.ellipsis=2]="ellipsis"}(ce||(ce={})),function(t){t[t.top=0]="top",t[t.middle=1]="middle",t[t.bottom=2]="bottom"}(le||(le={})),function(t){t[t.left=0]="left",t[t.middle=1]="middle",t[t.right=2]="right"}(fe||(fe={})),function(t){t.normal="normal",t.bold="bold",t.lighter="lighter"}(de||(de={})),function(t){t.normal="normal",t.italic="italic",t.oblique="oblique"}(pe||(pe={}));var ge,xe,be,Te,Ee,_e,we,Ae,Ce,Se,Oe={WhiteTexture:"whitetexture00000000000000000000",TransparentTexture:"transparenttexture00000000000000000000",PBRShader:"pbr00000000000000000000000000000",UnlitShader:"unlit000000000000000000000000000"};!function(t){t[t.Custom=0]="Custom",t[t.Rectangle=1]="Rectangle",t[t.Ellipse=2]="Ellipse",t[t.Polygon=3]="Polygon",t[t.Star=4]="Star"}(ge||(ge={})),function(t){t[t.Butt=0]="Butt",t[t.Round=1]="Round",t[t.Square=2]="Square"}(xe||(xe={})),function(t){t[t.Round=0]="Round",t[t.Bevel=1]="Bevel",t[t.Miter=2]="Miter"}(be||(be={})),function(t){t.video="video",t.image="image"}(Te||(Te={})),function(t){t.video="video",t.audio="audio"}(Ee||(Ee={})),function(t){t.VFXItemData="VFXItemData",t.Material="Material",t.Shader="Shader",t.Geometry="Geometry",t.Texture="Texture",t.Image="Image",t.AnimationClip="AnimationClip",t.BinaryAsset="BinaryAsset",t.TrackAsset="TrackAsset",t.TimelineAsset="TimelineAsset",t.ObjectBindingTrack="ObjectBindingTrack",t.TransformTrack="TransformTrack",t.SpriteColorTrack="SpriteColorTrack",t.ActivationTrack="ActivationTrack",t.SubCompositionTrack="SubCompositionTrack",t.FloatPropertyTrack="FloatPropertyTrack",t.ColorPropertyTrack="ColorPropertyTrack",t.Vector2PropertyTrack="Vector2PropertyTrack",t.Vector4PropertyTrack="Vector4PropertyTrack",t.TransformPlayableAsset="TransformPlayableAsset",t.SpriteColorPlayableAsset="SpriteColorPlayableAsset",t.ActivationPlayableAsset="ActivationPlayableAsset",t.SubCompositionPlayableAsset="SubCompositionPlayableAsset",t.FloatPropertyPlayableAsset="FloatPropertyPlayableAsset",t.ColorPropertyPlayableAsset="ColorPropertyPlayableAsset",t.Vector2PropertyPlayableAsset="Vector2PropertyPlayableAsset",t.Vector4PropertyPlayableAsset="Vector4PropertyPlayableAsset",t.MeshComponent="MeshComponent",t.SkyboxComponent="SkyboxComponent",t.LightComponent="LightComponent",t.CameraComponent="CameraComponent",t.ModelPluginComponent="ModelPluginComponent",t.TreeComponent="TreeComponent",t.AnimationComponent="AnimationComponent",t.SpineComponent="SpineComponent",t.VideoComponent="VideoComponent",t.AudioComponent="AudioComponent",t.RichTextComponent="RichTextComponent",t.OrientationComponent="OrientationComponent",t.ShapeComponent="ShapeComponent",t.SpriteComponent="SpriteComponent",t.ParticleSystem="ParticleSystem",t.InteractComponent="InteractComponent",t.CameraController="CameraController",t.PostProcessVolume="PostProcessVolume",t.EffectComponent="EffectComponent",t.TextComponent="TextComponent",t.TimelineClip="TimelineClip"}(_e||(_e={})),function(t){t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN"}(we||(we={})),function(t){t[t.Float16=0]="Float16",t[t.Float32=1]="Float32",t[t.Int8=2]="Int8",t[t.Int16=3]="Int16",t[t.Int32=4]="Int32",t[t.UInt8=5]="UInt8",t[t.UInt16=6]="UInt16",t[t.UInt32=7]="UInt32"}(Ae||(Ae={})),function(t){t[t.None=-1]="None",t[t.UInt8=0]="UInt8",t[t.UInt16=1]="UInt16",t[t.UInt32=2]="UInt32"}(Ce||(Ce={})),function(t){t.Position="POSITION",t.Uv="TEXCOORD0",t.Uv2="TEXCOORD1",t.Normal="NORMAL",t.Tangent="TANGENT",t.Color="COLOR",t.Joints="JOINTS",t.Weights="WEIGHTS",t.PositionBS0="POSITION_BS0",t.PositionBS1="POSITION_BS1",t.PositionBS2="POSITION_BS2",t.PositionBS3="POSITION_BS3",t.PositionBS4="POSITION_BS4",t.PositionBS5="POSITION_BS5",t.PositionBS6="POSITION_BS6",t.PositionBS7="POSITION_BS7",t.NormalBS0="NORMAL_BS0",t.NormalBS1="NORMAL_BS1",t.NormalBS2="NORMAL_BS2",t.NormalBS3="NORMAL_BS3",t.TangentBS0="TANGENT_BS0",t.TangentBS1="TANGENT_BS1",t.TangentBS2="TANGENT_BS2",t.TangentBS3="TANGENT_BS3"}(Se||(Se={}));var Re=Vt.LATEST,Me=Object.freeze({__proto__:null,LATEST_VERSION:Re,get RenderLevel(){return Nt},get BlendingMode(){return Dt},get SideMode(){return kt},get ObscuredMode(){return zt},get ParticleEmitterShapeType(){return Ut},get PluginType(){return Bt},get InteractType(){return Gt},get InteractBehavior(){return jt},get ItemType(){return Xt},get RenderMode(){return Ht},get ParticleOrigin(){return Yt},get RenderType(){return Wt},get RenderFace(){return Zt},get CameraClipMode(){return Jt},END_BEHAVIOR_DESTROY:0,END_BEHAVIOR_PAUSE:me,END_BEHAVIOR_FORWARD:2,END_BEHAVIOR_PAUSE_AND_DESTROY:ve,END_BEHAVIOR_FREEZE:4,END_BEHAVIOR_RESTART:5,END_BEHAVIOR_DESTROY_CHILDREN:6,CAMERA_CLIP_MODE_VERTICAL:1,CAMERA_CLIP_MODE_NORMAL:ye,MESSAGE_ITEM_PHRASE_BEGIN:2,MESSAGE_ITEM_PHRASE_END:1,get ValueType(){return $t},get BezierKeyframeType(){return te},get JSONSceneVersion(){return Vt},get EndBehavior(){return ee},get ParticleInteractionBehavior(){return ie},get ShapeArcMode(){return re},get LightType(){return ne},get ModelBoundingType(){return se},get CameraType(){return ae},get MaterialType(){return oe},get MaterialBlending(){return ue},get RenderMode3D(){return he},get TextOverflow(){return ce},get TextBaseline(){return le},get TextAlignment(){return fe},get TextWeight(){return de},get FontStyle(){return pe},BuiltinObjectGUID:Oe,get ShapePrimitiveType(){return ge},get LineCap(){return xe},get LineJoin(){return be},get BackgroundType(){return Te},get MultimediaType(){return Ee},get DataType(){return _e},get GeometryType(){return we},get VertexFormatType(){return Ae},get IndexFormatType(){return Ce},get VertexBufferSemantic(){return Se}});function Ie(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function Pe(t,e,i){return e&&Ie(t.prototype,e),i&&Ie(t,i),t}var Le=new Map,Fe=new Map,Ve={};function Ne(t){return function(e,i){Ve[t]&&console.warn("Class "+t+" is already registered."),Ve[t]=e}}function De(t,e){return function(t,e){return function(i,r){var n=function(t){var e=t.constructor;Le.get(e)||Le.set(e,{});return Le.get(e)}(i);n&&(n[r]||(n[r]={type:t,sourceName:e}))}}(t,e)}function ke(t){var e=t.constructor;if(Fe.get(e))return Fe.get(e);var i={};Fe.set(e,i);for(var r=t,n=e;n;){var s=Le.get(n);for(var a in s)i[a]=s[a];var o=Object.getPrototypeOf(r);if((n=Object.getPrototypeOf(o).constructor)===Object)break;r=o}return i}var ze=function(){function t(t){this.engine=t,this.guid=wt(),this.defination={},this.engine.addInstance(this)}var e=t.prototype;return e.getInstanceId=function(){return this.guid},e.setInstanceId=function(t){this.engine.removeInstance(this.guid),this.guid=t,this.engine.addInstance(this)},e.toData=function(){},e.fromData=function(t){},e.dispose=function(){},t.is=function(e){return A(e,t)&&"guid"in e},t}(),Ue=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).isAwakeCalled=!1,e.isStartCalled=!1,e.isEnableCalled=!1,e._enabled=!0,e}Qt(e,t);var i=e.prototype;return i.onAwake=function(){},i.onEnable=function(){},i.onDisable=function(){},i.onStart=function(){},i.onUpdate=function(t){},i.onLateUpdate=function(t){},i.onDestroy=function(){},i.enable=function(){this.item.composition&&(this.item.composition.sceneTicking.addComponent(this),this.isEnableCalled=!0),this.onEnable()},i.disable=function(){this.onDisable(),this.item.composition&&(this.isEnableCalled=!1,this.item.composition.sceneTicking.removeComponent(this))},i.setVFXItem=function(t){this.item=t,t.isDuringPlay&&(this.isAwakeCalled||(this.onAwake(),this.isAwakeCalled=!0),t.isActive&&this.enabled&&(this.start(),this.enable()))},i.fromData=function(e){t.prototype.fromData.call(this,e)},i.dispose=function(){this.isEnableCalled&&this.disable(),this.isAwakeCalled&&(this.isAwakeCalled=!1,this.onDestroy()),this.item&&k(this.item.components,this)},i.start=function(){this.isStartCalled||(this.isStartCalled=!0,this.onStart())},Pe(e,[{key:"transform",get:function(){return this.item.transform}},{key:"isActiveAndEnabled",get:function(){return this.item.isActive&&this.enabled}},{key:"enabled",get:function(){return this._enabled},set:function(t){this.enabled!==t&&(this._enabled=t,t?this.isActiveAndEnabled&&(this.enable(),this.isStartCalled||(this.onStart(),this.isStartCalled=!0)):this.isEnableCalled&&this.disable())}}]),e}(ze);S([De()],Ue.prototype,"item",void 0),S([De()],Ue.prototype,"_enabled",void 0);var Be=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.setVFXItem=function(e){t.prototype.setVFXItem.call(this,e)},i.dispose=function(){t.prototype.dispose.call(this)},e}(Ue),Ge=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).materials=[],e._priority=0,e}Qt(e,t);var i=e.prototype;return i.render=function(t){},i.onEnable=function(){var t;null==(t=this.item.composition)||t.renderFrame.addMeshToDefaultRenderPass(this)},i.onDisable=function(){var t;null==(t=this.item.composition)||t.renderFrame.removeMeshFromDefaultRenderPass(this)},Pe(e,[{key:"priority",get:function(){return this._priority},set:function(t){this._priority=t}},{key:"material",get:function(){return this.materials[0]},set:function(t){0===this.materials.length?this.materials.push(t):this.materials[0]=t}}]),e}(Ue);S([De()],Ge.prototype,"materials",void 0),S([De()],Ge.prototype,"_priority",void 0);var je=2*Math.PI,Xe=Math.PI/180,He=180/Math.PI,Ye=1e-6;function We(t,e){return Math.abs(t-e)<Ye||t===1/0&&e===1/0||t===-1/0&&e===-1/0}var Ze=function(t,e,i){return(1-i)*t+i*e};function qe(t,e,i){var r=isNaN(e)?-1/0:e,n=isNaN(i)?1/0:i,s=Math.min(r,n),a=Math.max(r,n);return Math.min(Math.max(t,s),a)}var Ke=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.x=t,this.y=e}var e=t.prototype;return e.set=function(t,e){return this.x=t,this.y=e,this},e.setZero=function(){return this.x=0,this.y=0,this},e.setFromNumber=function(t){return this.x=t,this.y=t,this},e.setFromArray=function(t,e){var i,r;return void 0===e&&(e=0),this.x=null!=(i=t[e])?i:0,this.y=null!=(r=t[e+1])?r:0,this},e.copyFrom=function(t){return this.x=t.x,this.y=t.y,this},e.clone=function(){return new t(this.x,this.y)},e.setElement=function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:console.error("index is out of range: "+t)}return this},e.getElement=function(t){switch(t){case 0:return this.x;case 1:return this.y;default:console.error("index is out of range: "+t)}return 0},e.add=function(t){return"number"==typeof t?(this.x+=t,this.y+=t):A(t,Array)?(this.x+=t[0],this.y+=t[1]):(this.x+=t.x,this.y+=t.y),this},e.addVectors=function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},e.subtract=function(t){return"number"==typeof t?(this.x-=t,this.y-=t):A(t,Array)?(this.x-=t[0],this.y-=t[1]):(this.x-=t.x,this.y-=t.y),this},e.subtractVectors=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},e.multiply=function(t){return"number"==typeof t?(this.x*=t,this.y*=t):A(t,Array)?(this.x*=t[0],this.y*=t[1]):(this.x*=t.x,this.y*=t.y),this},e.multiplyVectors=function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this},e.divide=function(t){return"number"==typeof t?(this.x/=t,this.y/=t):A(t,Array)?(this.x/=t[0],this.y/=t[1]):(this.x/=t.x,this.y/=t.y),this},e.scale=function(t){return this.x*=t,this.y*=t,this},e.sum=function(){return this.x+this.y},e.min=function(t){return"number"==typeof t?(this.x=Math.min(this.x,t),this.y=Math.min(this.y,t)):(this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y)),this},e.max=function(t){return"number"==typeof t?(this.x=Math.max(this.x,t),this.y=Math.max(this.y,t)):(this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y)),this},e.clamp=function(t,e){return this.max(t).min(e)},e.floor=function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},e.ceil=function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},e.round=function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},e.abs=function(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this},e.negate=function(){return this.x=-this.x,this.y=-this.y,this},e.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},e.lengthSquared=function(){return this.x*this.x+this.y*this.y},e.normalize=function(){return this.divide(this.length()||1)},e.setLength=function(t){return this.normalize().multiply(t)},e.lerp=function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},e.lerpVectors=function(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this},e.dot=function(t){return this.x*t.x+this.y*t.y},e.cross=function(t){return this.x*t.y-this.y*t.x},e.distance=function(t){var e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)},e.distanceSquared=function(t){var e=this.x-t.x,i=this.y-t.y;return e*e+i*i},e.equals=function(t){return this.x===t.x&&this.y===t.y},e.isZero=function(){var t=Ye,e=this.x,i=this.y;return Math.abs(e)<=t&&Math.abs(i)<=t},e.toArray=function(){return[this.x,this.y]},e.fill=function(t,e){void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y},e.random=function(){return this.x=Math.random(),this.y=Math.random(),this},t.fromNumber=function(e){return(new t).setFromNumber(e)},t.fromArray=function(e,i){return void 0===i&&(i=0),(new t).setFromArray(e,i)},t}();Ke.ONE=new Ke(1,1),Ke.ZERO=new Ke(0,0);var Qe=function(){function t(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this.x=t,this.y=e,this.z=i}var e=t.prototype;return e.set=function(t,e,i){return this.x=t,this.y=e,this.z=i,this},e.setZero=function(){return this.x=0,this.y=0,this.z=0,this},e.setFromNumber=function(t){return this.x=t,this.y=t,this.z=t,this},e.setFromArray=function(t,e){var i,r,n;return void 0===e&&(e=0),this.x=null!=(i=t[e])?i:0,this.y=null!=(r=t[e+1])?r:0,this.z=null!=(n=t[e+2])?n:0,this},e.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},e.clone=function(){return new t(this.x,this.y,this.z)},e.setElement=function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:console.error("index is out of range: "+t)}return this},e.getElement=function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:console.error("index is out of range: "+t)}return 0},e.add=function(t){return"number"==typeof t?(this.x+=t,this.y+=t,this.z+=t):A(t,Array)?(this.x+=t[0],this.y+=t[1],this.z+=t[2]):(this.x+=t.x,this.y+=t.y,this.z+=t.z),this},e.addVectors=function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},e.addScaledVector=function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},e.subtract=function(t){return"number"==typeof t?(this.x-=t,this.y-=t,this.z-=t):A(t,Array)?(this.x-=t[0],this.y-=t[1],this.z-=t[2]):(this.x-=t.x,this.y-=t.y,this.z-=t.z),this},e.subtractVectors=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},e.multiply=function(t){return"number"==typeof t?(this.x*=t,this.y*=t,this.z*=t):A(t,Array)?(this.x*=t[0],this.y*=t[1],this.z*=t[2]):(this.x*=t.x,this.y*=t.y,this.z*=t.z),this},e.multiplyVectors=function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},e.divide=function(t){return"number"==typeof t?(this.x/=t,this.y/=t,this.z/=t):A(t,Array)?(this.x/=t[0],this.y/=t[1],this.z/=t[2]):(this.x/=t.x,this.y/=t.y,this.z/=t.z),this},e.scale=function(t){return this.x*=t,this.y*=t,this.z*=t,this},e.sum=function(){return this.x+this.y+this.z},e.min=function(t){return"number"==typeof t?(this.x=Math.min(this.x,t),this.y=Math.min(this.y,t),this.z=Math.min(this.z,t)):(this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z)),this},e.max=function(t){return"number"==typeof t?(this.x=Math.max(this.x,t),this.y=Math.max(this.y,t),this.z=Math.max(this.z,t)):(this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z)),this},e.clamp=function(t,e){return this.max(t).min(e)},e.floor=function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},e.ceil=function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},e.round=function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},e.abs=function(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this.z=Math.abs(this.z),this},e.negate=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},e.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},e.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z},e.normalize=function(){return this.divide(this.length()||1)},e.setLength=function(t){return this.normalize().multiply(t)},e.lerp=function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},e.lerpVectors=function(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this},e.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z},e.cross=function(t){return this.crossVectors(this,t)},e.crossVectors=function(t,e){var i=t.x,r=t.y,n=t.z,s=e.x,a=e.y,o=e.z;return this.x=r*o-n*a,this.y=n*s-i*o,this.z=i*a-r*s,this},e.reflect=function(t){return this.subtract(t.clone().multiply(2*this.dot(t)))},e.distance=function(t){return Math.sqrt(this.distanceSquared(t))},e.distanceSquared=function(t){var e=this.x-t.x,i=this.y-t.y,r=this.z-t.z;return e*e+i*i+r*r},e.equals=function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},e.isZero=function(){var t=Ye,e=this,i=e.x,r=e.y,n=e.z;return Math.abs(i)<=t&&Math.abs(r)<=t&&Math.abs(n)<=t},e.toArray=function(){return[this.x,this.y,this.z]},e.toVector2=function(){return new Ke(this.x,this.y)},e.fill=function(t,e){void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z},e.random=function(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this},e.applyEuler=function(t,e){return t.rotateVector3(this,e)},e.applyQuaternion=function(t,e){return t.rotateVector3(this,e)},e.applyMatrix=function(t,e){return t.transformPoint(this,e)},e.applyNormalMatrix=function(t,e){return t.transformNormal(this,e)},e.applyProjectionMatrix=function(t,e){return t.projectPoint(this,e)},t.fromNumber=function(e){return(new t).setFromNumber(e)},t.fromArray=function(e,i){return void 0===i&&(i=0),(new t).setFromArray(e,i)},t}();Qe.X=new Qe(1,0,0),Qe.Y=new Qe(0,1,0),Qe.Z=new Qe(0,0,1),Qe.ONE=new Qe(1,1,1),Qe.ZERO=new Qe(0,0,0);var Je=function(){function t(t,e,i,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=0),this.x=t,this.y=e,this.z=i,this.w=r}var e=t.prototype;return e.set=function(t,e,i,r){return this.x=t,this.y=e,this.z=i,this.w=r,this},e.setZero=function(){return this.x=0,this.y=0,this.z=0,this.w=0,this},e.setFromNumber=function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},e.setFromArray=function(t,e){var i,r,n,s;return void 0===e&&(e=0),this.x=null!=(i=t[e])?i:0,this.y=null!=(r=t[e+1])?r:0,this.z=null!=(n=t[e+2])?n:0,this.w=null!=(s=t[e+3])?s:0,this},e.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},e.clone=function(){return new t(this.x,this.y,this.z,this.w)},e.setElement=function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:console.error("index is out of range: "+t)}return this},e.getElement=function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:console.error("index is out of range: "+t)}return 0},e.add=function(t){return"number"==typeof t?(this.x+=t,this.y+=t,this.z+=t,this.w+=t):A(t,Array)?(this.x+=t[0],this.y+=t[1],this.z+=t[2],this.w+=t[3]):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w),this},e.addVectors=function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this},e.addScaledVector=function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this},e.subtract=function(t){return"number"==typeof t?(this.x-=t,this.y-=t,this.z-=t,this.w-=t):A(t,Array)?(this.x-=t[0],this.y-=t[1],this.z-=t[2],this.w-=t[3]):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w),this},e.subtractVectors=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},e.multiply=function(t){return"number"==typeof t?(this.x*=t,this.y*=t,this.z*=t,this.w*=t):A(t,Array)?(this.x*=t[0],this.y*=t[1],this.z*=t[2],this.w*=t[3]):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w),this},e.multiplyVectors=function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this.w=t.w*e.w,this},e.divide=function(t){return"number"==typeof t?(this.x/=t,this.y/=t,this.z/=t,this.w/=t):A(t,Array)?(this.x/=t[0],this.y/=t[1],this.z/=t[2],this.w/=t[3]):(this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w),this},e.scale=function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},e.sum=function(){return this.x+this.y+this.z+this.w},e.min=function(t){return"number"==typeof t?(this.x=Math.min(this.x,t),this.y=Math.min(this.y,t),this.z=Math.min(this.z,t),this.w=Math.min(this.w,t)):(this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w)),this},e.max=function(t){return"number"==typeof t?(this.x=Math.max(this.x,t),this.y=Math.max(this.y,t),this.z=Math.max(this.z,t),this.w=Math.max(this.w,t)):(this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w)),this},e.clamp=function(t,e){return this.max(t).min(e)},e.floor=function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},e.ceil=function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},e.round=function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},e.abs=function(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this.z=Math.abs(this.z),this.w=Math.abs(this.w),this},e.negate=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},e.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},e.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},e.normalize=function(){return this.divide(this.length()||1)},e.setLength=function(t){return this.normalize().multiply(t)},e.lerp=function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this},e.lerpVectors=function(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this.w=t.w+(e.w-t.w)*i,this},e.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},e.equals=function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},e.isZero=function(){var t=Ye,e=this,i=e.x,r=e.y,n=e.z,s=e.w;return Math.abs(i)<=t&&Math.abs(r)<=t&&Math.abs(n)<=t&&Math.abs(s)<=t},e.toArray=function(){return[this.x,this.y,this.z,this.w]},e.toVector3=function(){return new Qe(this.x,this.y,this.z)},e.fill=function(t,e){void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w},e.random=function(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this},e.applyMatrix=function(t,e){return t.transformVector4(this,e)},t.fromNumber=function(e){return(new t).setFromNumber(e)},t.fromArray=function(e,i){return void 0===i&&(i=0),(new t).setFromArray(e,i)},t}();Je.ONE=new Je(1,1,1,1),Je.ZERO=new Je(0,0,0,0);var $e=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).meshCollider=new ro,e.getHitTestParams=function(t){var i=e.transform.getWorldMatrix();e.meshCollider.setGeometry(e.geometry,i);var r=e.meshCollider.getBoundingBoxData();if(r)return{type:r.type,triangles:r.area}},e}Qt(e,t);var i=e.prototype;return i.render=function(t){t.renderingData.currentFrame.globalUniforms&&t.setGlobalMatrix("effects_ObjectToWorld",this.transform.getWorldMatrix());for(var e=0;e<this.materials.length;e++)t.drawGeometry(this.geometry,this.materials[e],e)},i.getBoundingBox=function(){var t=this.transform.getWorldMatrix();return this.meshCollider.setGeometry(this.geometry,t),this.meshCollider.getBoundingBox()},e}(Ge);S([De()],$e.prototype,"geometry",void 0);var ti=function(t){function e(e){var i;return(i=t.call(this,e)||this).name="EffectComponent",i}Qt(e,t);var i=e.prototype;return i.onStart=function(){this.item.getHitTestParams=this.getHitTestParams},i.onUpdate=function(t){var e,i=this.item.time,r=null!=(e=this.material.getVector4("_Time"))?e:new Je;this.material.setVector4("_Time",r.set(i/20,i,2*i,3*i))},i.fromData=function(e){t.prototype.fromData.call(this,e),this.material=this.materials[0]},e}($e);ti=S([Ne(_e.EffectComponent)],ti);var ei=function(t){function e(e){var i;return(i=t.call(this,e)||this).bloom={threshold:0,intensity:0,active:!1},i.vignette={intensity:0,smoothness:0,roundness:0,active:!1},i.tonemapping={active:!1},i.colorAdjustments={brightness:0,saturation:0,contrast:0,active:!1},i}return Qt(e,t),e.prototype.onStart=function(){var t=this.item.composition;t&&(t.renderFrame.globalVolume=this)},e}(Ue);S([De()],ei.prototype,"bloom",void 0),S([De()],ei.prototype,"vignette",void 0),S([De()],ei.prototype,"tonemapping",void 0),S([De()],ei.prototype,"colorAdjustments",void 0),ei=S([Ne(_e.PostProcessVolume)],ei);var ii=function(){function t(t,e,i,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=0),this.r=t,this.g=e,this.b=i,this.a=r}var e=t.prototype;return e.set=function(t,e,i,r){return this.r=t,this.g=e,this.b=i,this.a=r,this},e.setZero=function(){return this.r=0,this.g=0,this.b=0,this.a=0,this},e.setFromNumber=function(t){return this.r=t,this.g=t,this.b=t,this.a=t,this},e.setFromVector4=function(t){return this.r=t.x,this.g=t.y,this.b=t.z,this.a=t.w,this},e.setFromArray=function(t,e){var i,r,n,s;return void 0===e&&(e=0),this.r=null!=(i=t[e])?i:0,this.g=null!=(r=t[e+1])?r:0,this.b=null!=(n=t[e+2])?n:0,this.a=null!=(s=t[e+3])?s:0,this},e.setFromHSV=function(t,e,i,r){void 0===r&&(r=1);var n=i*e,s=t/60,a=n*(1-Math.abs(s%2-1)),o=0,u=0,h=0;s>=0&&s<=1?(o=n,u=a):s>=1&&s<=2?(o=a,u=n):s>=2&&s<=3?(u=n,h=a):s>=3&&s<=4?(u=a,h=n):s>=4&&s<=5?(o=a,h=n):s>=5&&s<=6&&(o=n,h=a);var c=i-n;return this.set(o+c,u+c,h+c,r)},e.setFromHexString=function(t){if("#"!==t.substring(0,1)||9!==t.length&&7!==t.length)return this;var e=parseInt(t.substring(1,3),16)/255,i=parseInt(t.substring(3,5),16)/255,r=parseInt(t.substring(5,7),16)/255,n=9===t.length?parseInt(t.substring(7,9),16)/255:1;return this.set(e,i,r,n)},e.copyFrom=function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this},e.clone=function(){return new t(this.r,this.g,this.b,this.a)},e.setElement=function(t,e){switch(t){case 0:this.r=e;break;case 1:this.g=e;break;case 2:this.b=e;break;case 3:this.a=e;break;default:console.error("index is out of range: "+t)}return this},e.getElement=function(t){switch(t){case 0:return this.r;case 1:return this.g;case 2:return this.b;case 3:return this.a;default:console.error("index is out of range: "+t)}return 0},e.add=function(t){return"number"==typeof t?(this.r+=t,this.g+=t,this.b+=t,this.a+=t):A(t,Array)?(this.r+=t[0],this.g+=t[1],this.b+=t[2],this.a+=t[3]):(this.r+=t.r,this.g+=t.g,this.b+=t.b,this.a+=t.a),this},e.subtract=function(t){return"number"==typeof t?(this.r-=t,this.g-=t,this.b-=t,this.a-=t):A(t,Array)?(this.r-=t[0],this.g-=t[1],this.b-=t[2],this.a-=t[3]):(this.r-=t.r,this.g-=t.g,this.b-=t.b,this.a-=t.a),this},e.multiply=function(t){return"number"==typeof t?(this.r*=t,this.g*=t,this.b*=t,this.a*=t):A(t,Array)?(this.r*=t[0],this.g*=t[1],this.b*=t[2],this.a*=t[3]):(this.r*=t.r,this.g*=t.g,this.b*=t.b,this.a*=t.a),this},e.divide=function(t){return"number"==typeof t?(this.r/=t,this.g/=t,this.b/=t,this.a/=t):A(t,Array)?(this.r/=t[0],this.g/=t[1],this.b/=t[2],this.a/=t[3]):(this.r/=t.r,this.g/=t.g,this.b/=t.b,this.a/=t.a),this},e.scale=function(t){return this.r*=t,this.g*=t,this.b*=t,this.a*=t,this},e.min=function(t){return"number"==typeof t?(this.r=Math.min(this.r,t),this.g=Math.min(this.g,t),this.b=Math.min(this.b,t),this.a=Math.min(this.a,t)):(this.r=Math.min(this.r,t.r),this.g=Math.min(this.g,t.g),this.b=Math.min(this.b,t.b),this.a=Math.min(this.a,t.a)),this},e.max=function(t){return"number"==typeof t?(this.r=Math.max(this.r,t),this.g=Math.max(this.g,t),this.b=Math.max(this.b,t),this.a=Math.max(this.a,t)):(this.r=Math.max(this.r,t.r),this.g=Math.max(this.g,t.g),this.b=Math.max(this.b,t.b),this.a=Math.max(this.a,t.a)),this},e.clamp=function(t,e){return this.max(t).min(e)},e.lerp=function(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this.a+=(t.a-this.a)*e,this},e.luminance=function(){return.3*this.r+.59*this.g+.11*this.b},e.equals=function(t){return t.r===this.r&&t.g===this.g&&t.b===this.b&&t.a===this.a},e.toLinear=function(){return this.r=t.gammaToLinear(this.r),this.g=t.gammaToLinear(this.g),this.b=t.gammaToLinear(this.b),this},e.toGamma=function(){return this.r=t.linearToGamma(this.r),this.g=t.linearToGamma(this.g),this.b=t.linearToGamma(this.b),this},e.toArray=function(){return[this.r,this.g,this.b,this.a]},e.toVector4=function(){return new Je(this.r,this.g,this.b,this.a)},e.toHSV=function(){var e=this,i=e.r,r=e.g,n=e.b,s=e.a,a=Math.max(i,r,n),o=Math.min(i,r,n),u=a-o,h=0,c=0;return 0!==a&&(c=u/a),a!=o&&(a==i?(h=(r-n)/u,r<n&&(h+=6)):a==r?h=(n-i)/u+2:a==n&&(h=(i-r)/u+4),h*=60),new t(h,c,a,s)},e.toHexString=function(e){void 0===e&&(e=!0);var i=t.ToHex(Math.round(255*this.r)),r=t.ToHex(Math.round(255*this.g)),n=t.ToHex(Math.round(255*this.b)),s=t.ToHex(Math.round(255*this.a));return e?"#"+i+r+n+s:"#"+i+r+n},e.fill=function(t,e){void 0===e&&(e=0),t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t[e+3]=this.a},t.fromNumber=function(e){return(new t).setFromNumber(e)},t.fromArray=function(e,i){return void 0===i&&(i=0),(new t).setFromArray(e,i)},t.fromHexString=function(e){return(new t).setFromHexString(e)},t.fromHSV=function(e,i,r,n){return void 0===n&&(n=1),(new t).setFromHSV(e,i,r,n)},t.gammaToLinear=function(t){return t<=0?0:t<=.04045?t/12.92:t<1?Math.pow((t+.055)/1.055,2.4):Math.pow(t,2.4)},t.linearToGamma=function(t){return t<=0?0:t<.0031308?12.92*t:t<1?1.055*Math.pow(t,.41666)-.055:Math.pow(t,.41666)},t.ToHex=function(t){var e=t.toString(16);return t<=15?("0"+e).toUpperCase():e.toUpperCase()},t}();ii.BLACK=new ii(0,0,0,1),ii.BLUE=new ii(0,0,1,1),ii.CLEAR=new ii(0,0,0,0),ii.CYAN=new ii(0,1,1,1),ii.GRAY=new ii(.5,.5,.5,1),ii.GREEN=new ii(0,1,0,1),ii.MAGENTA=new ii(1,0,1,1),ii.RED=new ii(1,0,0,1),ii.WHITE=new ii(1,1,1,1),ii.YELLOW=new ii(1,.92,.016,1);var ri=function(){function t(t,e,i,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=1),this.x=t,this.y=e,this.z=i,this.w=r}var e=t.prototype;return e.set=function(t,e,i,r){return this.x=t,this.y=e,this.z=i,this.w=r,this},e.setFromEuler=function(t){return t.toQuaternion(this),this},e.setFromAxisAngle=function(e,i){var r=i/2,n=Math.sin(r),s=t.tempVec0;return s.copyFrom(e).normalize(),this.x=s.x*n,this.y=s.y*n,this.z=s.z*n,this.w=Math.cos(r),this},e.setFromVector4=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},e.setFromArray=function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this},e.setFromRotationMatrix=function(t){var e=t.elements,i=e[0],r=e[4],n=e[8],s=e[1],a=e[5],o=e[9],u=e[2],h=e[6],c=e[10],l=i+a+c;if(l>0){var f=.5/Math.sqrt(l+1);this.w=.25/f,this.x=(h-o)*f,this.y=(n-u)*f,this.z=(s-r)*f}else if(i>a&&i>c){var d=2*Math.sqrt(1+i-a-c);this.w=(h-o)/d,this.x=.25*d,this.y=(r+s)/d,this.z=(n+u)/d,this.negate()}else if(a>c){var p=2*Math.sqrt(1+a-i-c);this.w=(n-u)/p,this.x=(r+s)/p,this.y=.25*p,this.z=(o+h)/p,this.negate()}else{var m=2*Math.sqrt(1+c-i-a);this.w=(s-r)/m,this.x=(n+u)/m,this.y=(o+h)/m,this.z=.25*m,this.negate()}return this},e.setFromUnitVectors=function(t,e){var i=t.dot(e)+1;return i<Number.EPSILON?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this.x=-t.y,this.y=t.x,this.z=0,this.w=i):(this.x=0,this.y=-t.z,this.z=t.y,this.w=i)):(this.x=t.y*e.z-t.z*e.y,this.y=t.z*e.x-t.x*e.z,this.z=t.x*e.y-t.y*e.x,this.w=i),this.normalize()},e.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},e.clone=function(){return new t(this.x,this.y,this.z,this.w)},e.angleTo=function(t){return 2*Math.acos(Math.abs(qe(this.dot(t),-1,1)))},e.rotateTowards=function(t,e){var i=this.angleTo(t);if(0===i)return this;var r=Math.min(1,e/i);return this.slerp(t,r),this},e.identity=function(){return this.set(0,0,0,1)},e.invert=function(){return this.conjugate()},e.negate=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},e.conjugate=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},e.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},e.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},e.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},e.normalize=function(){var t=this.length();return 0===t?(this.x=0,this.y=0,this.z=0,this.w=1):(t=1/t,this.x=this.x*t,this.y=this.y*t,this.z=this.z*t,this.w=this.w*t),this},e.multiply=function(t){return this.multiplyQuaternions(this,t)},e.premultiply=function(t){return this.multiplyQuaternions(t,this)},e.multiplyQuaternions=function(t,e){var i=t.x,r=t.y,n=t.z,s=t.w,a=e.x,o=e.y,u=e.z,h=e.w;return this.x=i*h+s*a+r*u-n*o,this.y=r*h+s*o+n*a-i*u,this.z=n*h+s*u+i*o-r*a,this.w=s*h-i*a-r*o-n*u,this},e.slerp=function(t,e){if(0===e)return this;if(1===e)return this.copyFrom(t);var i=this,r=i.x,n=i.y,s=i.z,a=i.w,o=a*t.w+r*t.x+n*t.y+s*t.z;if(o<0?(this.w=-t.w,this.x=-t.x,this.y=-t.y,this.z=-t.z,o=-o):this.copyFrom(t),o>=1)return this.w=a,this.x=r,this.y=n,this.z=s,this;var u=1-o*o;if(u<=Number.EPSILON){var h=1-e;return this.w=h*a+e*this.w,this.x=h*r+e*this.x,this.y=h*n+e*this.y,this.z=h*s+e*this.z,this.normalize(),this}var c=Math.sqrt(u),l=Math.atan2(c,o),f=Math.sin((1-e)*l)/c,d=Math.sin(e*l)/c;return this.w=a*f+this.w*d,this.x=r*f+this.x*d,this.y=n*f+this.y*d,this.z=s*f+this.z*d,this},e.slerpQuaternions=function(t,e,i){this.copyFrom(t).slerp(e,i)},e.rotateVector3=function(t,e){var i=this,r=i.x,n=i.y,s=i.z,a=i.w,o=t.x,u=t.y,h=t.z,c=a*o+n*h-s*u,l=a*u+s*o-r*h,f=a*h+r*u-n*o,d=-r*o-n*u-s*h,p=null!=e?e:t;return p.x=c*a+d*-r+l*-s-f*-n,p.y=l*a+d*-n+f*-r-c*-s,p.z=f*a+d*-s+c*-n-l*-r,p},e.equals=function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},e.toArray=function(){return[this.x,this.y,this.z,this.w]},e.toVector4=function(t){return t.set(this.x,this.y,this.z,this.w)},e.toEuler=function(t){return t.setFromQuaternion(this)},e.toMatrix4=function(t){return t.compose(Qe.ZERO,this,Qe.ONE)},t.fromEuler=function(e){return(new t).setFromEuler(e)},t.fromAxisAngle=function(e,i){return(new t).setFromAxisAngle(e,i)},t.fromVector4=function(e){return(new t).setFromVector4(e)},t.fromArray=function(e,i){return void 0===i&&(i=0),(new t).setFromArray(e,i)},t.fromRotationMatrix=function(e){return(new t).setFromRotationMatrix(e)},t.fromUnitVectors=function(e,i){return(new t).setFromUnitVectors(e,i)},t}();ri.tempVec0=new Qe;var ni=function(){function t(t,e,i,r,n,s,a,o,u,h,c,l,f,d,p,m){void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=0),void 0===s&&(s=1),void 0===a&&(a=0),void 0===o&&(o=0),void 0===u&&(u=0),void 0===h&&(h=0),void 0===c&&(c=1),void 0===l&&(l=0),void 0===f&&(f=0),void 0===d&&(d=0),void 0===p&&(p=0),void 0===m&&(m=1),this.elements=[t,e,i,r,n,s,a,o,u,h,c,l,f,d,p,m]}var e=t.prototype;return e.set=function(t,e,i,r,n,s,a,o,u,h,c,l,f,d,p,m){var v=this.elements;return v[0]=t,v[1]=e,v[2]=i,v[3]=r,v[4]=n,v[5]=s,v[6]=a,v[7]=o,v[8]=u,v[9]=h,v[10]=c,v[11]=l,v[12]=f,v[13]=d,v[14]=p,v[15]=m,this},e.setFromRowMajorData=function(t,e,i,r,n,s,a,o,u,h,c,l,f,d,p,m){var v=this.elements;return v[0]=t,v[4]=e,v[8]=i,v[12]=r,v[1]=n,v[5]=s,v[9]=a,v[13]=o,v[2]=u,v[6]=h,v[10]=c,v[14]=l,v[3]=f,v[7]=d,v[11]=p,v[15]=m,this},e.setFromColumnVectors=function(t,e,i,r){return this.set(t.x,t.y,t.z,t.w,e.x,e.y,e.z,e.w,i.x,i.y,i.z,i.w,r.x,r.y,r.z,r.w)},e.setFromMatrix3=function(t){var e=t.elements;return this.set(e[0],e[1],e[2],0,e[3],e[4],e[5],0,e[6],e[7],e[8],0,0,0,0,1),this},e.setFromArray=function(t,e){void 0===e&&(e=0);for(var i=0;i<16;i++)this.elements[i]=t[e+i];return this},e.setFromScale=function(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1)},e.setFromTranslation=function(t,e,i){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,t,e,i,1)},e.setFromRotationX=function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,i,0,0,-i,e,0,0,0,0,1)},e.setFromRotationY=function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(e,0,-i,0,0,1,0,0,i,0,e,0,0,0,0,1)},e.setFromRotationZ=function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(e,i,0,0,-i,e,0,0,0,0,1,0,0,0,0,1)},e.setFromRotationAxis=function(e,i){var r=t.tempVec0;r.copyFrom(e).normalize();var n=Math.cos(i),s=Math.sin(i),a=1-n,o=r.x,u=r.y,h=r.z,c=a*o,l=a*u;return this.set(c*o+n,c*u+s*h,c*h-s*u,0,c*u-s*h,l*u+n,l*h+s*o,0,c*h+s*u,l*h-s*o,a*h*h+n,0,0,0,0,1)},e.setFromEuler=function(t){return t.toMatrix4(this),this},e.setFromQuaternion=function(t){return this.compose(Qe.ZERO,t,Qe.ONE)},e.setFromShear=function(t,e,i){return this.set(1,t,t,0,e,1,e,0,i,i,1,0,0,0,0,1)},e.setFromBasis=function(t,e,i){return this.set(t.x,t.y,t.z,0,e.x,e.y,e.z,0,i.x,i.y,i.z,0,0,0,0,1)},e.setZero=function(){for(var t=0;t<16;t++)this.elements[t]=0;return this},e.identity=function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},e.isIdentity=function(){var t=this.elements;return 1===t[0]&&0===t[4]&&0===t[8]&&0===t[12]&&0===t[1]&&1===t[5]&&0===t[9]&&0===t[13]&&0===t[2]&&0===t[6]&&1===t[10]&&0===t[14]&&0===t[3]&&0===t[7]&&0===t[11]&&1===t[15]},e.clone=function(){var e=this.elements;return new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])},e.copyFrom=function(t){return this.elements=[].concat(t.elements),this},e.getColumnVector=function(t,e){return e.set(this.elements[4*t],this.elements[4*t+1],this.elements[4*t+2],this.elements[4*t+3])},e.lookAt=function(e,i,r){var n=t.tempVec0,s=t.tempVec1,a=t.tempVec2;a.subtractVectors(e,i),a.normalize(),n.crossVectors(r,a),n.normalize(),s.crossVectors(a,n);var o=this.elements;return o[0]=n.x,o[1]=s.x,o[2]=a.x,o[3]=0,o[4]=n.y,o[5]=s.y,o[6]=a.y,o[7]=0,o[8]=n.z,o[9]=s.z,o[10]=a.z,o[11]=0,o[12]=-n.dot(e),o[13]=-s.dot(e),o[14]=-a.dot(e),o[15]=1,this},e.addScaledMatrix=function(t,e){for(var i=this.elements,r=t.elements,n=0;n<16;n++)i[n]+=r[n]*e;return this},e.multiply=function(t){if("number"==typeof t){for(var e=0;e<16;e++)this.elements[e]*=t;return this}return this.multiplyMatrices(this,t)},e.premultiply=function(t){return this.multiplyMatrices(t,this)},e.multiplyMatrices=function(t,e){var i=t.elements,r=e.elements,n=this.elements,s=i[0],a=i[4],o=i[8],u=i[12],h=i[1],c=i[5],l=i[9],f=i[13],d=i[2],p=i[6],m=i[10],v=i[14],y=i[3],g=i[7],x=i[11],b=i[15],T=r[0],E=r[4],_=r[8],w=r[12],A=r[1],C=r[5],S=r[9],O=r[13],R=r[2],M=r[6],I=r[10],P=r[14],L=r[3],F=r[7],V=r[11],N=r[15];return n[0]=s*T+a*A+o*R+u*L,n[4]=s*E+a*C+o*M+u*F,n[8]=s*_+a*S+o*I+u*V,n[12]=s*w+a*O+o*P+u*N,n[1]=h*T+c*A+l*R+f*L,n[5]=h*E+c*C+l*M+f*F,n[9]=h*_+c*S+l*I+f*V,n[13]=h*w+c*O+l*P+f*N,n[2]=d*T+p*A+m*R+v*L,n[6]=d*E+p*C+m*M+v*F,n[10]=d*_+p*S+m*I+v*V,n[14]=d*w+p*O+m*P+v*N,n[3]=y*T+g*A+x*R+b*L,n[7]=y*E+g*C+x*M+b*F,n[11]=y*_+g*S+x*I+b*V,n[15]=y*w+g*O+x*P+b*N,this},e.multiplyScalar=function(t){var e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this},e.determinant=function(){var t=this.elements,e=t[0],i=t[4],r=t[8],n=t[12],s=t[1],a=t[5],o=t[9],u=t[13],h=t[2],c=t[6],l=t[10],f=t[14];return t[3]*(+n*o*c-r*u*c-n*a*l+i*u*l+r*a*f-i*o*f)+t[7]*(+e*o*f-e*u*l+n*s*l-r*s*f+r*u*h-n*o*h)+t[11]*(+e*u*c-e*a*f-n*s*c+i*s*f+n*a*h-i*u*h)+t[15]*(-r*a*h-e*o*c+e*a*l+r*s*c-i*s*l+i*o*h)},e.transpose=function(){var t,e=this.elements;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this},e.invert=function(){var t=this.elements,e=t[0],i=t[1],r=t[2],n=t[3],s=t[4],a=t[5],o=t[6],u=t[7],h=t[8],c=t[9],l=t[10],f=t[11],d=t[12],p=t[13],m=t[14],v=t[15],y=c*m*u-p*l*u+p*o*f-a*m*f-c*o*v+a*l*v,g=d*l*u-h*m*u-d*o*f+s*m*f+h*o*v-s*l*v,x=h*p*u-d*c*u+d*a*f-s*p*f-h*a*v+s*c*v,b=d*c*o-h*p*o-d*a*l+s*p*l+h*a*m-s*c*m,T=e*y+i*g+r*x+n*b;if(0===T)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);var E=1/T;return t[0]=y*E,t[1]=(p*l*n-c*m*n-p*r*f+i*m*f+c*r*v-i*l*v)*E,t[2]=(a*m*n-p*o*n+p*r*u-i*m*u-a*r*v+i*o*v)*E,t[3]=(c*o*n-a*l*n-c*r*u+i*l*u+a*r*f-i*o*f)*E,t[4]=g*E,t[5]=(h*m*n-d*l*n+d*r*f-e*m*f-h*r*v+e*l*v)*E,t[6]=(d*o*n-s*m*n-d*r*u+e*m*u+s*r*v-e*o*v)*E,t[7]=(s*l*n-h*o*n+h*r*u-e*l*u-s*r*f+e*o*f)*E,t[8]=x*E,t[9]=(d*c*n-h*p*n-d*i*f+e*p*f+h*i*v-e*c*v)*E,t[10]=(s*p*n-d*a*n+d*i*u-e*p*u-s*i*v+e*a*v)*E,t[11]=(h*a*n-s*c*n-h*i*u+e*c*u+s*i*f-e*a*f)*E,t[12]=b*E,t[13]=(h*p*r-d*c*r+d*i*l-e*p*l-h*i*m+e*c*m)*E,t[14]=(d*a*r-s*p*r-d*i*o+e*p*o+s*i*m-e*a*m)*E,t[15]=(s*c*r-h*a*r+h*i*o-e*c*o-s*i*l+e*a*l)*E,this},e.extractBasis=function(t,e,i){var r=this.elements;return t.set(r[0],r[1],r[2]),e.set(r[4],r[5],r[6]),i.set(r[8],r[9],r[10]),this},e.compose=function(t,e,i,r){void 0===r&&(r=Qe.ZERO);var n=this.elements,s=e.x,a=e.y,o=e.z,u=e.w,h=-r.x,c=-r.y,l=-r.z,f=s+s,d=a+a,p=o+o,m=s*f,v=s*d,y=s*p,g=a*d,x=a*p,b=o*p,T=u*f,E=u*d,_=u*p,w=i.x,A=i.y,C=i.z;return n[0]=(1-(g+b))*w,n[1]=(v+_)*w,n[2]=(y-E)*w,n[3]=0,n[4]=(v-_)*A,n[5]=(1-(m+b))*A,n[6]=(x+T)*A,n[7]=0,n[8]=(y+E)*C,n[9]=(x-T)*C,n[10]=(1-(m+g))*C,n[11]=0,n[12]=h*n[0]+c*n[4]+l*n[8]-h+t.x,n[13]=h*n[1]+c*n[5]+l*n[9]-c+t.y,n[14]=h*n[2]+c*n[6]+l*n[10]-l+t.z,this},e.decompose=function(e,i,r){var n=t.tempVec0,s=this.elements,a=n.set(s[0],s[1],s[2]).length(),o=n.set(s[4],s[5],s[6]).length(),u=n.set(s[8],s[9],s[10]).length();this.determinant()<0&&(a=-a),e.x=s[12],e.y=s[13],e.z=s[14];var h=t.tempMat0;h.copyFrom(this);var c=1/a,l=1/o,f=1/u;return h.elements[0]*=c,h.elements[1]*=c,h.elements[2]*=c,h.elements[4]*=l,h.elements[5]*=l,h.elements[6]*=l,h.elements[8]*=f,h.elements[9]*=f,h.elements[10]*=f,i.setFromRotationMatrix(h),r.x=a,r.y=o,r.z=u,this},e.getTranslation=function(t){var e=this.elements;return t.set(e[12],e[13],e[14])},e.getScale=function(t){var e=this.elements;return t.set(Math.hypot(e[0],e[1],e[2]),Math.hypot(e[4],e[5],e[6]),Math.hypot(e[8],e[9],e[10]))},e.getTransform=function(){var t=new Qe,e=new ri,i=new Qe;return this.decompose(t,e,i),{translation:t,rotation:e,scale:i}},e.orthographic=function(t,e,i,r,n,s){var a=1/(e-t),o=1/(i-r),u=1/(s-n),h=-(e+t)*a,c=-(i+r)*o,l=-(s+n)*u;a*=2,o*=2,u*=-2;var f=this.elements;return f[0]=a,f[1]=0,f[2]=0,f[3]=0,f[4]=0,f[5]=o,f[6]=0,f[7]=0,f[8]=0,f[9]=0,f[10]=u,f[11]=0,f[12]=h,f[13]=c,f[14]=l,f[15]=1,this},e.perspective=function(t,e,i,r,n){var s=1/Math.tan(.5*t),a=1/(i-r),o=this.elements;return o[0]=n?s:s/e,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=n?s*e:s,o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=(r+i)*a,o[11]=-1,o[12]=0,o[13]=0,o[14]=2*r*i*a,o[15]=0,null!==r&&r!==1/0||(o[10]=-1,o[14]=-2*i),this},e.projectPoint=function(t,e){var i=t.x,r=t.y,n=t.z,s=this.elements,a=null!=e?e:t;a.x=s[0]*i+s[4]*r+s[8]*n+s[12],a.y=s[1]*i+s[5]*r+s[9]*n+s[13],a.z=s[2]*i+s[6]*r+s[10]*n+s[14];var o=s[3]*i+s[7]*r+s[11]*n+s[15];return a.multiply(1/o)},e.transformPoint=function(t,e){var i=t.x,r=t.y,n=t.z,s=this.elements,a=null!=e?e:t;return a.x=s[0]*i+s[4]*r+s[8]*n+s[12],a.y=s[1]*i+s[5]*r+s[9]*n+s[13],a.z=s[2]*i+s[6]*r+s[10]*n+s[14],a},e.transformNormal=function(t,e){var i=t.x,r=t.y,n=t.z,s=this.elements,a=null!=e?e:t;return a.x=s[0]*i+s[4]*r+s[8]*n,a.y=s[1]*i+s[5]*r+s[9]*n,a.z=s[2]*i+s[6]*r+s[10]*n,a.normalize()},e.transformVector4=function(t,e){var i=t.x,r=t.y,n=t.z,s=t.w,a=this.elements,o=null!=e?e:t;return o.x=a[0]*i+a[4]*r+a[8]*n+a[12]*s,o.y=a[1]*i+a[5]*r+a[9]*n+a[13]*s,o.z=a[2]*i+a[6]*r+a[10]*n+a[14]*s,o.w=a[3]*i+a[7]*r+a[11]*n+a[15]*s,o},e.equals=function(t){for(var e=this.elements,i=t.elements,r=0;r<16;r++)if(!We(e[r],i[r]))return!1;return!0},e.toArray=function(){return[].concat(this.elements)},e.fill=function(t,e){void 0===e&&(e=0);var i=this.elements;t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15]},t.fromIdentity=function(){return new t(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},t.fromLookAt=function(e,i,r){return(new t).lookAt(e,i,r)},t.fromPerspective=function(e,i,r,n,s){return(new t).perspective(e,i,r,n,s)},t.fromColumnVectors=function(e,i,r,n){return(new t).setFromColumnVectors(e,i,r,n)},t.fromMatrix3=function(e){return(new t).setFromMatrix3(e)},t.fromArray=function(e,i){return void 0===i&&(i=0),(new t).setFromArray(e,i)},t.fromScale=function(e,i,r){return(new t).setFromScale(e,i,r)},t.fromTranslation=function(e,i,r){return(new t).setFromTranslation(e,i,r)},t.fromRotationX=function(e){return(new t).setFromRotationX(e)},t.fromRotationY=function(e){return(new t).setFromRotationY(e)},t.fromRotationZ=function(e){return(new t).setFromRotationZ(e)},t.fromRotationAxis=function(e,i){return(new t).setFromRotationAxis(e,i)},t.fromEuler=function(e){return(new t).setFromEuler(e)},t.fromQuaternion=function(e){return(new t).setFromQuaternion(e)},t.fromShear=function(e,i,r){return(new t).setFromShear(e,i,r)},t.fromBasis=function(e,i,r){return(new t).setFromBasis(e,i,r)},t.fromRowMajorData=function(e,i,r,n,s,a,o,u,h,c,l,f,d,p,m,v){return new t(e,s,h,d,i,a,c,p,r,o,l,m,n,u,f,v)},t}();function si(t,e,i){var r;if(void 0===e&&(e="webgl"),"webgl2"===e&&((r=t.getContext("webgl2",i))||console.debug("WebGL2 context retrieval failed, falling back to WebGL context.")),r&&"webgl"!==e||(r=t.getContext("webgl",i)),!r)throw new Error("This browser does not support WebGL or the WebGL version is incorrect. Please check your WebGL version.");return r}function ai(t){var e=t.getExtension("EXT_disjoint_timer_query_webgl2");if(e){var i=t.createQuery(),n=E((function(){return O(this,(function(s){return[2,new Promise((function(s,a){if(i){var o=t.getQueryParameter(i,t.QUERY_RESULT_AVAILABLE),u=t.getParameter(e.GPU_DISJOINT_EXT);if(o&&!u){var h=t.getQueryParameter(i,t.QUERY_RESULT);s(h/1e3/1e3)}(o||u)&&(t.deleteQuery(i),i=null),null!==o&&i&&r.setTimeout((function(){n().then(s).catch}),1)}}))]}))}));if(!i)return;return{begin:function(){i&&t.beginQuery(e.TIME_ELAPSED_EXT,i)},end:function(){t.endQuery(e.TIME_ELAPSED_EXT)},getTime:n}}}ni.IDENTITY=new ni(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),ni.ZERO=new ni(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),ni.tempVec0=new Qe,ni.tempVec1=new Qe,ni.tempVec2=new Qe,ni.tempMat0=new ni;var oi,ui,hi,ci,li=[],fi={};function di(){"function"==typeof o?mi(o):void 0!==u?(mi(u),mi(u.prototype)):li.push("iOS16 lockdown mode, WebGL Constants not in global"),li.length||"HALF_FLOAT"in fi||(fi.HALF_FLOAT=5131)}function pi(t){return void 0!==o&&"WebGL2RenderingContext"===t.constructor.name}function mi(t){for(var e in t)/^[A-Z_]/.test(e)&&(fi[e]=t[e])}function vi(t){switch(t){case Ae.Float32:return u.FLOAT;case Ae.Int16:return u.SHORT;case Ae.Int8:return u.BYTE;case Ae.UInt16:return u.UNSIGNED_SHORT;case Ae.UInt8:return u.UNSIGNED_BYTE;default:return u.FLOAT}}function yi(t){switch(t){case u.FLOAT:return Ae.Float32;case u.SHORT:return Ae.Int16;case u.BYTE:return Ae.Int8;case u.UNSIGNED_SHORT:return Ae.UInt16;case u.UNSIGNED_BYTE:return Ae.UInt8;default:return Ae.Float32}}function gi(t,e){return null==t?e:t}function xi(t){switch(t){case Dt.ALPHA:case Dt.ADD:case Dt.SUBTRACTION:case Dt.STRONG_LIGHT:case Dt.WEAK_LIGHT:return 1;case Dt.SUPERPOSITION:return 2;case Dt.BRIGHTNESS:return 3;case Dt.MULTIPLY:return 0;default:return 1}}function bi(t,e){switch(e){case void 0:case Dt.ALPHA:t.blendFunction=[fi.ONE,fi.ONE_MINUS_SRC_ALPHA,fi.ONE,fi.ONE_MINUS_SRC_ALPHA];break;case Dt.ADD:t.blendFunction=[fi.ONE,fi.ONE,fi.ONE,fi.ONE];break;case Dt.SUBTRACTION:t.blendFunction=[fi.ONE,fi.ONE,fi.ZERO,fi.ONE],t.blendEquation=[fi.FUNC_REVERSE_SUBTRACT,fi.FUNC_REVERSE_SUBTRACT];break;case Dt.SUPERPOSITION:t.blendFunction=[fi.ONE,fi.ONE,fi.ONE,fi.ONE];break;case Dt.MULTIPLY:t.blendFunction=[fi.DST_COLOR,fi.ONE_MINUS_SRC_ALPHA,fi.DST_COLOR,fi.ONE_MINUS_SRC_ALPHA];break;case Dt.BRIGHTNESS:t.blendFunction=[fi.ONE,fi.ONE_MINUS_SRC_ALPHA,fi.ONE,fi.ONE_MINUS_SRC_ALPHA];break;case Dt.STRONG_LIGHT:t.blendFunction=[fi.DST_COLOR,fi.DST_ALPHA,fi.ZERO,fi.ONE];break;case Dt.WEAK_LIGHT:t.blendFunction=[fi.DST_COLOR,fi.ZERO,fi.ZERO,fi.ONE];break;default:console.warn("BlendMode "+e+" not in specification, please set blend params separately.")}}function Ti(t,e){e===kt.DOUBLE?t.culling=!1:(t.culling=!0,t.frontFace=fi.CW,t.cullFace=e===kt.BACK?fi.BACK:fi.FRONT)}function Ei(t,e){switch(e){case void 0:t.stencilTest=!1;break;case ui.MASK:t.stencilTest=!0,t.stencilFunc=[fi.ALWAYS,fi.ALWAYS],t.stencilOpZPass=[fi.REPLACE,fi.REPLACE];break;case ui.OBSCURED:t.stencilTest=!0,t.stencilFunc=[fi.EQUAL,fi.EQUAL];break;case ui.REVERSE_OBSCURED:t.stencilTest=!0,t.stencilFunc=[fi.NOTEQUAL,fi.NOTEQUAL];break;case ui.NONE:t.stencilTest=!1;break;default:console.warn("MaskMode "+e+" not in specification, please set stencil params seperately.")}}function _i(){return _i=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},_i.apply(this,arguments)}li.length||di(),function(t){t[t.vertex=0]="vertex",t[t.fragment=1]="fragment"}(oi||(oi={})),function(t){t[t.NONE=0]="NONE",t[t.MASK=1]="MASK",t[t.OBSCURED=2]="OBSCURED",t[t.REVERSE_OBSCURED=3]="REVERSE_OBSCURED"}(ui||(ui={})),function(t){t[t.whatever=0]="whatever",t[t.clear=2]="clear"}(hi||(hi={})),function(t){t[t.none=0]="none",t[t.data=1]="data",t[t.image=2]="image",t[t.compressed=3]="compressed",t[t.video=4]="video",t[t.canvas=5]="canvas",t[t.framebuffer=6]="framebuffer",t[t.mipmaps=7]="mipmaps"}(ci||(ci={}));var wi=function(){function t(){this.callbacks={}}var e=t.prototype;return e.downloadJSON=function(t,e,i){this.download(t,"json",e,i)},e.downloadBinary=function(t,e,i){this.download(t,"arraybuffer",e,i)},e.downloadBlob=function(t,e,i){this.download(t,"blob",e,i)},e.download=function(t,e,i,r){var n=this;if(void 0===e&&(e="json"),!this.start(t,i,r)){var s=new h,a=function(){n.finish(t,s.status,s.response)};s.responseType=e,s.addEventListener("load",(function(){200==s.status?n.finish(t,200,s.response):a()})),s.addEventListener("error",a),s.open("GET",t,!0),s.send()}},e.start=function(t,e,i){var r=this.callbacks[t];try{if(r)return!0;this.callbacks[t]=r=[]}finally{r.push(e,i)}},e.finish=function(t,e,i){var r=this.callbacks[t];delete this.callbacks[t];for(var n=200==e?[i]:[e,i],s=n.length-1,a=r.length;s<a;s+=2)r[s].apply(null,n)},t}(),Ai=!1,Ci=!1;function Si(t,e){return Oi.apply(this,arguments)}function Oi(){return(Oi=E((function(t,e){return O(this,(function(i){switch(i.label){case 0:return!Ai&&e?[3,2]:[4,Ii(t)];case 1:return[2,{image:i.sent(),url:t}];case 2:return i.trys.push([2,4,,6]),[4,Ii(e)];case 3:return[2,{image:i.sent(),url:e}];case 4:return i.sent(),Ai=!0,[4,Ii(t)];case 5:return[2,{image:i.sent(),url:t}];case 6:return[2]}}))}))).apply(this,arguments)}function Ri(t,e){return Mi.apply(this,arguments)}function Mi(){return(Mi=E((function(t,e){return O(this,(function(i){switch(i.label){case 0:return!Ci&&e?[3,2]:[4,Ii(t)];case 1:return[2,{image:i.sent(),url:t}];case 2:return i.trys.push([2,4,,6]),[4,Ii(e)];case 3:return[2,{image:i.sent(),url:e}];case 4:return i.sent(),Ci=!0,[4,Ii(t)];case 5:return[2,{image:i.sent(),url:t}];case 6:return[2]}}))}))).apply(this,arguments)}function Ii(t){return Pi.apply(this,arguments)}function Pi(){return(Pi=E((function(t){var e,i;return O(this,(function(r){if(e="",A(t,c)){if(t.complete)return[2,t];e=t.src}else A(t,a)?(e=l.createObjectURL(t),i=!0):"string"==typeof t&&(e=t);if(!e)throw new Error("Invalid url type: "+JSON.stringify(t)+".");return[2,new Promise((function(t,r){var n=new f;/^data:/.test(e)||(n.crossOrigin="*"),n.onload=function(){return n.onload=null,i&&l.revokeObjectURL(e),t(n)},n.onerror=function(t){return n.onerror=null,i&&l.revokeObjectURL(e),r("Load image fail: "+e+", reason: "+JSON.stringify(t))},n.src=e}))]}))}))).apply(this,arguments)}function Li(t){return Fi.apply(this,arguments)}function Fi(){return(Fi=E((function(t){return O(this,(function(e){return[2,new Promise((function(e,i){(new wi).downloadBinary(t,e,(function(e,r){i("Couldn't load bins "+t+": status "+e+", "+r)}))}))]}))}))).apply(this,arguments)}function Vi(t){return Ni.apply(this,arguments)}function Ni(){return(Ni=E((function(t){return O(this,(function(e){return[2,new Promise((function(e,i){(new wi).downloadBlob(t,e,(function(e,r){i("Couldn't load blob "+t+": status "+e+", "+r)}))}))]}))}))).apply(this,arguments)}function Di(t){return ki.apply(this,arguments)}function ki(){return(ki=E((function(t){var e;return O(this,(function(r){return e=i.createElement("video"),"string"==typeof t?e.src=t:e.srcObject=t,e.crossOrigin="anonymous",e.muted=!0,q()&&e.setAttribute("renderer","standard"),e.setAttribute("playsinline","playsinline"),[2,new Promise((function(t,i){var r=e.play();r?r.then((function(){return t(e)})):e.addEventListener("loadeddata",(function i(){t(e),e.removeEventListener("loadeddata",i)}),!0),e.addEventListener("error",(function(t){i("Load video fail.")}))}))]}))}))).apply(this,arguments)}function zi(t,e){return Ui.apply(this,arguments)}function Ui(){return(Ui=E((function(t,e){return O(this,(function(i){switch(i.label){case 0:if(!Array.isArray(t))return[3,5];i.label=1;case 1:return i.trys.push([1,3,,5]),[4,e(t[0])];case 2:return[2,i.sent()];case 3:return i.sent(),[4,e(t[1])];case 4:return[2,i.sent()];case 5:return[2,e(t)]}}))}))).apply(this,arguments)}function Bi(t,e,i){return Gi.apply(this,arguments)}function Gi(){return(Gi=E((function(t,e,i,r){var n,s,a,o,u,h,c,l,f;return O(this,(function(d){switch(d.label){case 0:return void 0===r&&(r=[]),34067!==t.target?[3,2]:(n=t.mipmaps,s=t.target,a=n.map((function(t){return Promise.all(t.map((function(t){return t.id?i[t.id]:ji(t,e)})))})),[4,Promise.all(a)]);case 1:return o=d.sent(),[2,_i({keepImageSource:!1},t,{mipmaps:o,sourceFrom:{target:s,type:ci.mipmaps}})];case 2:return u=t.mipmaps,h=t.target,c=u.map((function(t){return ji(t,e)})),[4,Promise.all(c)];case 3:return l=d.sent(),f=r[u[0][1][0]].url,[2,_i({keepImageSource:!1},t,{mipmaps:l,sourceType:ci.mipmaps,sourceFrom:{target:h,bin:f,type:ci.mipmaps,mipmaps:u.map((function(t){return[t[1][1],t[1][2]]}))}})];case 4:return[2]}}))}))).apply(this,arguments)}function ji(t,e){return Xi.apply(this,arguments)}function Xi(){return Xi=E((function(t,e){var i,r,n,s,o;return O(this,(function(u){if(i=t[1],r=i[0],n=i[1],s=i[2],!(o=e[r]))throw new Error("Invalid bin pointer: "+JSON.stringify(t)+".");return[2,Ii(new a([new Uint8Array(o,n,s)]))]}))})),Xi.apply(this,arguments)}var Hi=1,Yi=function(t){function e(e){var i;return(i=t.call(this,e)||this).destroyed=!1,i.id="Tex"+Hi++,i}Qt(e,t);var i=e.prototype;return i.getWidth=function(){return this.width||0},i.getHeight=function(){return this.height||0},i.uploadCurrentVideoFrame=function(){},i.offloadData=function(){},i.reloadData=function(){},i.initialize=function(){},i.assembleOptions=function(t){var e=t.target,i=void 0===e?fi.TEXTURE_2D:e,r=t.format,n=void 0===r?fi.RGBA:r;return t.sourceType||(t.sourceType="image"in t?ci.image:"data"in t?ci.data:"video"in t?ci.video:0),_i({minFilter:fi.NEAREST,magFilter:fi.NEAREST,wrapS:fi.CLAMP_TO_EDGE,wrapT:fi.CLAMP_TO_EDGE,target:i,format:fi.RGBA,internalFormat:n,type:fi.UNSIGNED_BYTE},t)},e.fromImage=function(t,i,r){return E((function(){var n,s;return O(this,(function(a){switch(a.label){case 0:return[4,Ii(t)];case 1:return n=a.sent(),(s=e.create(i,_i({sourceType:ci.image,image:n,target:fi.TEXTURE_2D,id:wt(),flipY:!0},r))).initialize(),[2,s]}}))}))()},e.fromVideo=function(t,i,r){return E((function(){var n,s;return O(this,(function(a){switch(a.label){case 0:return[4,Di(t)];case 1:return n=a.sent(),(s=e.create(i,_i({sourceType:ci.video,video:n,id:wt(),flipY:!0},r))).initialize(),[2,s]}}))}))()},Pe(e,[{key:"isDestroyed",get:function(){return this.destroyed}}]),e}(ze);function Wi(t,e,i,r){var n,s,a=e.length/i/r;return s=n=4===a||0===a?fi.RGBA:3===a?fi.RGB:2===a?fi.LUMINANCE_ALPHA:fi.LUMINANCE,Yi.createWithData(t,{data:e,width:i,height:r},{type:fi.HALF_FLOAT,format:n,internalFormat:s,wrapS:fi.CLAMP_TO_EDGE,wrapT:fi.CLAMP_TO_EDGE})}var Zi={type:fi.UNSIGNED_BYTE,format:fi.RGBA,internalFormat:fi.RGBA,wrapS:fi.MIRRORED_REPEAT,wrapT:fi.MIRRORED_REPEAT,minFilter:fi.NEAREST,magFilter:fi.NEAREST};function qi(t){return Yi.create(t,_i({id:Oe.WhiteTexture,data:{width:1,height:1,data:new Uint8Array([255,255,255,255])},sourceType:ci.data},Zi))}function Ki(t){return Yi.create(t,_i({id:Oe.TransparentTexture,data:{width:1,height:1,data:new Uint8Array([0,0,0,0])},sourceType:ci.data},Zi))}var Qi=function(){function t(t,e,i){void 0===i&&(i=0),this.arrayBuffer=t,this.baseOffset=i;var r=new Uint8Array(this.arrayBuffer,this.baseOffset,12);if(171!==r[0]||75!==r[1]||84!==r[2]||88!==r[3]||32!==r[4]||49!==r[5]||49!==r[6]||187!==r[7]||13!==r[8]||10!==r[9]||26!==r[10]||10!==r[11])throw new Error("Texture missing KTX identifier.");var n=Uint32Array.BYTES_PER_ELEMENT,s=new DataView(this.arrayBuffer,this.baseOffset+12,13*n),a=67305985===s.getUint32(0,!0);this.glType=s.getUint32(1*n,a),this.glTypeSize=s.getUint32(2*n,a),this.glFormat=s.getUint32(3*n,a),this.glInternalFormat=s.getUint32(4*n,a),this.glBaseInternalFormat=s.getUint32(5*n,a),this.pixelWidth=s.getUint32(6*n,a),this.pixelHeight=s.getUint32(7*n,a),this.pixelDepth=s.getUint32(8*n,a),this.numberOfArrayElements=s.getUint32(9*n,a),this.numberOfFaces=s.getUint32(10*n,a),this.numberOfMipmapLevels=s.getUint32(11*n,a),this.bytesOfKeyValueData=s.getUint32(12*n,a),this.numberOfMipmapLevels=Math.max(1,this.numberOfMipmapLevels),0!==this.pixelHeight&&0===this.pixelDepth?0===this.numberOfArrayElements?this.numberOfFaces===e?0===this.glType?this.loadType=0:this.loadType=2:mt.warn("Number of faces expected "+e+", but found "+this.numberOfFaces+"."):mt.warn("Texture arrays not currently supported."):mt.warn("Only 2D textures currently supported.")}return t.prototype.mipmaps=function(t){for(var e=[],i=64+this.bytesOfKeyValueData,r=this.pixelWidth,n=this.pixelHeight,s=t?this.numberOfMipmapLevels:1,a=0;a<s;a++){for(var o=new Int32Array(this.arrayBuffer,this.baseOffset+i,1)[0],u=0;u<this.numberOfFaces;u++){var h=new Uint8Array(this.arrayBuffer,this.baseOffset+i+4,o);e.push({data:h,width:r,height:n}),i+=o+4,i+=3-(o+3)%4}r=Math.max(1,.5*r),n=Math.max(1,.5*n)}return e},t}();function Ji(t){var e=new Qi(t,1),i=e.numberOfMipmapLevels,r=e.pixelWidth,n=e.pixelHeight,s=e.glType,a=e.numberOfFaces,o=e.glInternalFormat,u=e.glFormat,h=i>=Math.floor(Math.log2(Math.max(r,n))+1);return{sourceType:ci.compressed,type:s,target:6===a?fi.TEXTURE_CUBE_MAP:fi.TEXTURE_2D,internalFormat:o,format:u,mipmaps:e.mipmaps(h)}}var $i,tr=function(){function t(){this.reloadPending={}}var e=t.prototype;return e.reload=function(t){var e=this;return E((function(){var i,r;return O(this,(function(n){switch(n.label){case 0:return i=t.id,e.reloadPending[i]?[2]:t.sourceFrom?(e.reloadPending[i]=!0,[4,e.loadSource(t.sourceFrom)]):[3,2];case 1:return r=n.sent(),t.updateSource(r),e.reloadPending[i]=!1,[3,3];case 2:throw new Error("No source from.");case 3:return[2]}}))}))()},e.canOffloadTexture=function(t){if(t){var e=t.type;if(e===ci.compressed||e===ci.image){var i=t.target,r=t.map,n=t.url;return i===fi.TEXTURE_CUBE_MAP?"object"==typeof r&&!!r:yt(n)&&n.length>0}if(e===ci.mipmaps){var s=t.bin,a=t.mipmaps,o=t.target,u=t.maps,h=t.urls;return s?a.length>0:o===fi.TEXTURE_CUBE_MAP?u.every((function(t){return"object"==typeof t&&t})):h.every((function(t){return yt(t)&&t.length>0}))}}return!1},e.loadSource=function(t,e){var i=this;return E((function(){var r,n,s,a,o,u,h,c,l,f,d,p,m,v,y,g,x;return O(this,(function(b){switch(b.label){case 0:return r=t.type,n=t.target,s=t.map,a=t.url,o=t.bin,u=t.mipmaps,h=t.urls,c=t.maps,n!==fi.TEXTURE_CUBE_MAP||r===ci.mipmaps?[3,2]:[4,i.loadCubeMap(s)];case 1:return l=b.sent(),[2,_i({},e,{cube:l,target:fi.TEXTURE_CUBE_MAP,sourceType:ci.image,sourceFrom:{type:ci.image,map:_i({},s),target:fi.TEXTURE_CUBE_MAP}})];case 2:return r!==ci.image?[3,4]:[4,Ii(a)];case 3:return f=b.sent(),[2,_i({},e,{image:f,sourceType:ci.image,sourceFrom:{type:r,url:a,target:fi.TEXTURE_2D}})];case 4:return r!==ci.video?[3,6]:[4,Di(a)];case 5:return d=b.sent(),[2,_i({},e,{video:d,sourceType:ci.video})];case 6:return r!==ci.compressed?[3,8]:[4,Li(a)];case 7:return[2,_i({},Ji(b.sent()),e,{sourceFrom:{url:a,type:ci.compressed}})];case 8:return r!==ci.mipmaps?[3,17]:o?[4,Li(o)]:[3,13];case 9:return p=b.sent(),m=null!=n?n:fi.TEXTURE_2D,v=m===fi.TEXTURE_2D?u.slice():u.map((function(t){return t.slice()})),n!==fi.TEXTURE_CUBE_MAP?[3,11]:[4,Promise.all(u.map((function(t){return i.loadMipmapImages(t,p)})))];case 10:return y=b.sent(),[3,12];case 11:y=i.loadMipmapImages(u,p),b.label=12;case 12:return[2,_i({},e,{mipmaps:y,target:m,sourceType:ci.mipmaps,sourceFrom:{bin:o,mipmaps:v,target:m,type:ci.mipmaps}})];case 13:return n!==fi.TEXTURE_2D&&n?[3,15]:[4,Promise.all(h.map((function(t){return Ii(t)})))];case 14:return g=b.sent(),[2,_i({},e,{mipmaps:g,target:fi.TEXTURE_2D,sourceType:ci.mipmaps,sourceFrom:{type:r,urls:h.slice(),target:fi.TEXTURE_2D}})];case 15:return n!==fi.TEXTURE_CUBE_MAP?[3,17]:[4,Promise.all(c.map((function(t){return i.loadCubeMap(t)})))];case 16:return x=b.sent(),[2,_i({},e,{mipmaps:x,target:fi.TEXTURE_CUBE_MAP,sourceType:ci.mipmaps,sourceFrom:{type:r,maps:c.map((function(t){return _i({},t)})),target:fi.TEXTURE_CUBE_MAP}})];case 17:throw new Error("Invalid resource type: "+r+".")}}))}))()},e.loadMipmapImages=function(t,e){return E((function(){return O(this,(function(i){return[2,Promise.all(t.map((function(t){return Ii(new a([new Uint8Array(e,t[0],t[1])]))})))]}))}))()},e.loadCubeMap=function(t){return E((function(){return O(this,(function(e){return[2,Promise.all(t.map((function(t){return Ii(t)})))]}))}))()},t}();function er(){return $i||($i=new tr),$i}function ir(t){$i=t}var rr,nr=function(){function t(t){this.destroyed=!1;var e=t.name,i=void 0===e?"defaultDataBlock":e;this.name=i}var e=t.prototype;return e.setUniformValues=function(t){var e=this;Object.keys(t).forEach((function(i){e.setUniformValue(i,t[i])}))},e.invalidAllFlags=function(){},e.updateUniformSubData=function(t,e,i){},t}();function sr(t){return"object"==typeof t&&t&&void 0===t.length&&A(t,Yi)}function ar(t){return t&&void 0!==t.length&&sr(t[0])}!function(t){t[t.normal=0]="normal",t[t.transformFeedback=1]="transformFeedback"}(rr||(rr={}));var or,ur,hr=1,cr=function(t){function e(e,i){var r;if((r=t.call(this,e)||this).stringTags={},r.enabledMacros={},r.destroyed=!1,r.initialized=!1,r.shaderDirty=!0,i){var n=i.name,s=void 0===n?"Material"+hr++:n,a=i.renderType,o=void 0===a?0:a,u=i.shader,h=i.uniformSemantics;r.name=s,r.renderType=o,r.shaderSource=u,r.props=i,r.uniformSemantics=_i({},h)}else r.name="Material"+hr++,r.renderType=0;return r}Qt(e,t);var i=e.prototype;return i.initialize=function(){},i.createShaderVariant=function(){},i.use=function(t,e){},Pe(e,[{key:"shader",get:function(){return this._shader},set:function(t){this._shader!==t&&(this._shader=t,this.shaderDirty=!0)}},{key:"mainTexture",get:function(){return this.getTexture("_MainTex")},set:function(t){this.setTexture("_MainTex",t)}},{key:"color",get:function(){return this.getColor("_Color")},set:function(t){this.setColor("_Color",t)}},{key:"blending",set:function(t){}},{key:"blendFunction",set:function(t){}},{key:"blendEquation",set:function(t){}},{key:"depthTest",set:function(t){}},{key:"depthMask",set:function(t){}},{key:"stencilTest",set:function(t){}},{key:"stencilRef",set:function(t){}},{key:"stencilFunc",set:function(t){}},{key:"stencilOpZPass",set:function(t){}},{key:"culling",set:function(t){}},{key:"frontFace",set:function(t){}},{key:"cullFace",set:function(t){}},{key:"blendColor",set:function(t){}},{key:"depthRange",set:function(t){}},{key:"depthFunc",set:function(t){}},{key:"polygonOffsetFill",set:function(t){}},{key:"polygonOffset",set:function(t){}},{key:"sampleAlphaToCoverage",set:function(t){}},{key:"stencilMask",set:function(t){}},{key:"stencilOpFail",set:function(t){}},{key:"stencilOpZFail",set:function(t){}}]),e}(ze),lr=function(){function t(t){this.engine=t,this.alphaMaskEnabled=!1,this.maskMode=ui.NONE,this.maskable=null,this.stencilClearAction={stencilAction:hi.clear}}var e=t.prototype;return e.getRefValue=function(){return 1},e.getMaskMode=function(t){var e=t.isMask,i=void 0!==e&&e,r=t.inverted,n=void 0!==r&&r,s=t.reference,a=t.alphaMaskEnabled,o=void 0!==a&&a;return this.alphaMaskEnabled=o,i?this.maskMode=ui.MASK:(this.maskMode=n?ui.REVERSE_OBSCURED:ui.OBSCURED,s&&(this.maskable=this.engine.findObject(s))),this.maskMode},e.drawStencilMask=function(t){this.maskable&&(t.clear(this.stencilClearAction),this.maskable.drawStencilMask(t))},t}();!function(t){t[t.noShader=0]="noShader",t[t.success=1]="success",t[t.fail=2]="fail",t[t.compiling=3]="compiling"}(or||(or={})),function(t){t.GLSL1="100",t.GLSL3="300 es"}(ur||(ur={}));var fr=function(t){function e(e,i){var r;return(r=t.call(this,e)||this).source=i,r}return Qt(e,t),e}(ze),dr=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.createVariant=function(t){var e=[];if(t)for(var i,r=w(Object.keys(t));!(i=r()).done;){var n=i.value;e.push([n,t[n]])}var s=this.engine.getShaderLibrary().createShader(this.shaderData,e);return s.shader=this,s},i.fromData=function(e){t.prototype.fromData.call(this,e),this.shaderData=e},e}(ze);dr=S([Ne(_e.Shader)],dr);var pr="effects-internal-copy",mr="effects-internal-copy-mesh",vr="\nprecision highp float;\nattribute vec2 aPos;\nvarying vec2 vTex;\nvoid main(){\n gl_Position = vec4(aPos,0.,1.0);\n vTex = (aPos + vec2(1.0))/2.;\n}",yr="precision mediump float;\nvarying vec2 vTex;\n\n#ifdef DEPTH_TEXTURE\nuniform sampler2D uDepth;\n#extension GL_EXT_frag_depth : enable\n#endif\nvoid main(){\n #ifdef DEPTH_TEXTURE\n gl_FragDepthEXT = texture2D(uDepth,vTex).r;\n #endif\n}\n";function gr(t,e){return{name:pr,vertex:vr,fragment:yr,glslVersion:2===t?ur.GLSL3:ur.GLSL1,macros:[["DEPTH_TEXTURE",!!e]],cacheId:mr+ +e}}var xr,br,Tr={format:fi.RGBA,type:fi.UNSIGNED_BYTE,minFilter:fi.LINEAR,magFilter:fi.LINEAR,wrapS:fi.CLAMP_TO_EDGE,wrapT:fi.CLAMP_TO_EDGE},Er=Symbol("dispose"),_r=function(){function t(t){this.textureCache={},this.textureRef={},this.engine=t}var e=t.prototype;return e.requestColorAttachmentTexture=function(t){var e=this,i=t.width,r=t.height,n=t.name,s={sourceType:ci.framebuffer,data:{width:i,height:r},name:n},a=[n];Object.getOwnPropertyNames(Tr).forEach((function(e){var i,r=null!=(i=t[e])?i:Tr[e];s[e]=r,a.push(e,r)}));var o=a.join(":"),u=this.textureCache[o];if(u)this.textureRef[o]++;else{var h=this.engine;ot(h),u=Yi.create(h,s),this.textureCache[o]=u,this.textureRef[o]=1,u[Er]=u.dispose,u.dispose=function(){return e.removeTexture(o)}}return u},e.removeTexture=function(t){var e=this.textureRef[t];if(e<=1){e<0&&console.error("Ref count < 0.");var i=this.textureCache[t];i&&(i[Er](),i.dispose=i[Er]),delete this.textureCache[t],delete this.textureRef[t]}else this.textureRef[t]=e-1},e.dispose=function(){var t=this;Object.keys(this.textureCache).forEach((function(e){var i=t.textureCache[e];i[Er](),i.dispose=i[Er]})),this.textureCache={},this.textureRef={},this.engine=void 0},t}(),wr=function(){function t(t){void 0===t&&(t={}),this.semantics=_i({},t)}var e=t.prototype;return e.toObject=function(){return _i({},this.semantics)},e.setSemantic=function(t,e){void 0===e?delete this.semantics[t]:this.semantics[t]=e},e.getSemanticValue=function(t,e){var i=this.semantics[t];return xt(i)?i(e):i},e.hasSemanticValue=function(t){return t in this.semantics},e.dispose=function(){var t=this;Object.keys(this.semantics).forEach((function(e){delete t.semantics[e]}))},t}(),Ar=((xr={})[fi.FLOAT]=Float32Array.BYTES_PER_ELEMENT,xr[fi.INT]=Int32Array.BYTES_PER_ELEMENT,xr[fi.SHORT]=Int16Array.BYTES_PER_ELEMENT,xr[fi.BYTE]=Int8Array.BYTES_PER_ELEMENT,xr),Cr=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).name="",e.subMeshes=[],e}Qt(e,t);var i=e.prototype;return i.initialize=function(){},i.flush=function(){},e}(ze);function Sr(t){return t===fi.INT?new Int32Array(0):t===fi.SHORT?new Int16Array(0):new Float32Array(0)}!function(t){t[t.XYZ=0]="XYZ",t[t.XZY=1]="XZY",t[t.YXZ=2]="YXZ",t[t.YZX=3]="YZX",t[t.ZXY=4]="ZXY",t[t.ZYX=5]="ZYX"}(br||(br={}));var Or=function(){function t(e,i,r,n){void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=t.DEFAULT_ORDER),this.x=e,this.y=i,this.z=r,this.order=n}var e=t.prototype;return e.set=function(t,e,i,r){return void 0===r&&(r=this.order),this.x=t,this.y=e,this.z=i,this.order=r,this},e.setZero=function(t){return void 0===t&&(t=this.order),this.set(0,0,0,t)},e.setFromRotationMatrix4=function(t,e){void 0===e&&(e=this.order);var i=t.elements,r=i[0],n=i[4],s=i[8],a=i[1],o=i[5],u=i[9],h=i[2],c=i[6],l=i[10];switch(e){case br.XYZ:this.y=Math.asin(qe(s,-1,1)),Math.abs(s)<.9999999?(this.x=Math.atan2(-u,l),this.z=Math.atan2(-n,r)):(this.x=Math.atan2(c,o),this.z=0);break;case br.YXZ:this.x=Math.asin(-qe(u,-1,1)),Math.abs(u)<.9999999?(this.y=Math.atan2(s,l),this.z=Math.atan2(a,o)):(this.y=Math.atan2(-h,r),this.z=0);break;case br.ZXY:this.x=Math.asin(qe(c,-1,1)),Math.abs(c)<.9999999?(this.y=Math.atan2(-h,l),this.z=Math.atan2(-n,o)):(this.y=0,this.z=Math.atan2(a,r));break;case br.ZYX:this.y=Math.asin(-qe(h,-1,1)),Math.abs(h)<.9999999?(this.x=Math.atan2(c,l),this.z=Math.atan2(a,r)):(this.x=0,this.z=Math.atan2(-n,o));break;case br.YZX:this.z=Math.asin(qe(a,-1,1)),Math.abs(a)<.9999999?(this.x=Math.atan2(-u,o),this.y=Math.atan2(-h,r)):(this.x=0,this.y=Math.atan2(s,l));break;case br.XZY:this.z=Math.asin(-qe(n,-1,1)),Math.abs(n)<.9999999?(this.x=Math.atan2(c,o),this.y=Math.atan2(s,r)):(this.x=Math.atan2(-u,l),this.y=0);break;default:console.error("setFromRotationMatrix: unknown order: "+e)}return this.x*=He,this.y*=He,this.z*=He,this.order=e,this},e.setFromQuaternion=function(e,i){void 0===i&&(i=this.order);var r=t.tempMat0;return r.setFromQuaternion(e),this.setFromRotationMatrix4(r,i)},e.setFromVector3=function(t,e){return void 0===e&&(e=this.order),this.set(t.x,t.y,t.z,e)},e.setFromArray=function(t,e,i){var r,n,s,a;return void 0===e&&(e=0),void 0===i&&(i=this.order),this.x=null!=(r=t[e])?r:0,this.y=null!=(n=t[e+1])?n:0,this.z=null!=(s=t[e+2])?s:0,this.order=null!=(a=t[e+3])?a:i,this},e.clone=function(){return new t(this.x,this.y,this.z,this.order)},e.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.order=t.order,this},e.add=function(t){return this.order!=t.order?(console.error("add euler with different order"),this):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},e.addEulers=function(t,e){return t.order!=e.order?(console.error("add euler with different order"),this):(this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.order=t.order,this)},e.negate=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},e.reorder=function(t){var e=new ri;return e.setFromEuler(this),this.setFromQuaternion(e,t)},e.rotateVector3=function(e,i){return t.tempQuat0.setFromEuler(this).rotateVector3(e,i)},e.equals=function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.order===this.order},e.toVector3=function(t){return t.set(this.x,this.y,this.z)},e.toArray=function(){return[this.x,this.y,this.z]},e.toQuaternion=function(t){var e=this,i=e.x,r=e.y,n=e.z,s=e.order,a=Math.cos(i*Xe*.5),o=Math.cos(r*Xe*.5),u=Math.cos(n*Xe*.5),h=Math.sin(i*Xe*.5),c=Math.sin(r*Xe*.5),l=Math.sin(n*Xe*.5);switch(s){case br.XYZ:t.set(h*o*u+a*c*l,a*c*u-h*o*l,a*o*l+h*c*u,a*o*u-h*c*l);break;case br.YXZ:t.set(h*o*u+a*c*l,a*c*u-h*o*l,a*o*l-h*c*u,a*o*u+h*c*l);break;case br.ZXY:t.set(h*o*u-a*c*l,a*c*u+h*o*l,a*o*l+h*c*u,a*o*u-h*c*l);break;case br.ZYX:t.set(h*o*u-a*c*l,a*c*u+h*o*l,a*o*l-h*c*u,a*o*u+h*c*l);break;case br.YZX:t.set(h*o*u+a*c*l,a*c*u+h*o*l,a*o*l-h*c*u,a*o*u-h*c*l);break;case br.XZY:t.set(h*o*u-a*c*l,a*c*u-h*o*l,a*o*l+h*c*u,a*o*u+h*c*l);break;default:console.error("unknown euler order: "+s)}return t},e.toMatrix4=function(t){var e=t.elements,i=this,r=i.x,n=i.y,s=i.z,a=i.order,o=Math.cos(r*Xe),u=Math.sin(r*Xe),h=Math.cos(n*Xe),c=Math.sin(n*Xe),l=Math.cos(s*Xe),f=Math.sin(s*Xe);if(a===br.XYZ){var d=o*l,p=o*f,m=u*l,v=u*f;e[0]=h*l,e[4]=-h*f,e[8]=c,e[1]=p+m*c,e[5]=d-v*c,e[9]=-u*h,e[2]=v-d*c,e[6]=m+p*c,e[10]=o*h}else if(a===br.YXZ){var y=h*l,g=h*f,x=c*l,b=c*f;e[0]=y+b*u,e[4]=x*u-g,e[8]=o*c,e[1]=o*f,e[5]=o*l,e[9]=-u,e[2]=g*u-x,e[6]=b+y*u,e[10]=o*h}else if(a===br.ZXY){var T=h*l,E=h*f,_=c*l,w=c*f;e[0]=T-w*u,e[4]=-o*f,e[8]=_+E*u,e[1]=E+_*u,e[5]=o*l,e[9]=w-T*u,e[2]=-o*c,e[6]=u,e[10]=o*h}else if(a===br.ZYX){var A=o*l,C=o*f,S=u*l,O=u*f;e[0]=h*l,e[4]=S*c-C,e[8]=A*c+O,e[1]=h*f,e[5]=O*c+A,e[9]=C*c-S,e[2]=-c,e[6]=u*h,e[10]=o*h}else if(a===br.YZX){var R=o*h,M=o*c,I=u*h,P=u*c;e[0]=h*l,e[4]=P-R*f,e[8]=I*f+M,e[1]=f,e[5]=o*l,e[9]=-u*l,e[2]=-c*l,e[6]=M*f+I,e[10]=R-P*f}else if(a===br.XZY){var L=o*h,F=o*c,V=u*h,N=u*c;e[0]=h*l,e[4]=-f,e[8]=c*l,e[1]=L*f+N,e[5]=o*l,e[9]=F*f-V,e[2]=V*f-F,e[6]=u*l,e[10]=N*f+L}else console.error("toMatrix4: Invalid order "+a);return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,t},t.fromRotationMatrix4=function(e,i){return void 0===i&&(i=t.DEFAULT_ORDER),(new t).setFromRotationMatrix4(e,i)},t.fromQuaternion=function(e,i){return void 0===i&&(i=t.DEFAULT_ORDER),(new t).setFromQuaternion(e,i)},t.fromVector3=function(e,i){return void 0===i&&(i=t.DEFAULT_ORDER),(new t).setFromVector3(e,i)},t.fromArray=function(e,i,r){return void 0===i&&(i=0),void 0===r&&(r=t.DEFAULT_ORDER),(new t).setFromArray(e,i,r)},t}();Or.DEFAULT_ORDER=br.ZYX,Or.tempQuat0=new ri,Or.tempMat0=new ni;var Rr=function(){function t(t,e,i,r,n,s,a,o,u){void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=1),void 0===s&&(s=0),void 0===a&&(a=0),void 0===o&&(o=0),void 0===u&&(u=1),this.elements=[t,e,i,r,n,s,a,o,u]}var e=t.prototype;return e.set=function(t,e,i,r,n,s,a,o,u){var h=this.elements;return h[0]=t,h[3]=r,h[6]=a,h[1]=e,h[4]=n,h[7]=o,h[2]=i,h[5]=s,h[8]=u,this},e.setFromRowMajorData=function(t,e,i,r,n,s,a,o,u){var h=this.elements;return h[0]=t,h[3]=e,h[6]=i,h[1]=r,h[4]=n,h[7]=s,h[2]=a,h[5]=o,h[8]=u,this},e.setFromColumnVectors=function(t,e,i){return this.set(t.x,t.y,t.z,e.x,e.y,e.z,i.x,i.y,i.z)},e.setFromMatrix4=function(t){var e=t.elements;return this.set(e[0],e[1],e[2],e[4],e[5],e[6],e[8],e[9],e[10])},e.setFromArray=function(t,e){void 0===e&&(e=0);for(var i=0;i<9;i++)this.elements[i]=t[e+i];return this},e.setFromQuaternion=function(t){var e=t.x,i=t.y,r=t.z,n=t.w,s=e+e,a=i+i,o=r+r,u=e*s,h=e*a,c=e*o,l=i*a,f=i*o,d=r*o,p=n*s,m=n*a,v=n*o,y=this.elements;return y[0]=1-(l+d),y[1]=h+v,y[2]=c-m,y[3]=h-v,y[4]=1-(u+d),y[5]=f+p,y[6]=c+m,y[7]=f-p,y[8]=1-(u+l),this},e.setZero=function(){for(var t=0;t<9;t++)this.elements[t]=0;return this},e.identity=function(){return this.set(1,0,0,0,1,0,0,0,1)},e.clone=function(){var e=this.elements;return new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},e.copyFrom=function(t){return this.elements=[].concat(t.elements),this},e.getColumnVector=function(t,e){return e.set(this.elements[3*t],this.elements[3*t+1],this.elements[3*t+2])},e.scale=function(t,e){var i=this.elements;return i[0]*=t,i[3]*=t,i[6]*=t,i[1]*=e,i[4]*=e,i[7]*=e,this},e.rotate=function(t){var e=Math.cos(t),i=Math.sin(t),r=this.elements,n=r[0],s=r[3],a=r[6],o=r[1],u=r[4],h=r[7];return r[0]=e*n+i*o,r[3]=e*s+i*u,r[6]=e*a+i*h,r[1]=-i*n+e*o,r[4]=-i*s+e*u,r[7]=-i*a+e*h,this},e.translate=function(t,e){var i=this.elements;return i[0]+=t*i[2],i[3]+=t*i[5],i[6]+=t*i[8],i[1]+=e*i[2],i[4]+=e*i[5],i[7]+=e*i[8],this},e.multiply=function(t){if("number"==typeof t){for(var e=0;e<9;e++)this.elements[e]*=t;return this}return this.multiplyMatrices(this,t)},e.premultiply=function(t){return this.multiplyMatrices(t,this)},e.multiplyMatrices=function(t,e){var i=t.elements,r=e.elements,n=this.elements,s=i[0],a=i[3],o=i[6],u=i[1],h=i[4],c=i[7],l=i[2],f=i[5],d=i[8],p=r[0],m=r[3],v=r[6],y=r[1],g=r[4],x=r[7],b=r[2],T=r[5],E=r[8];return n[0]=s*p+a*y+o*b,n[3]=s*m+a*g+o*T,n[6]=s*v+a*x+o*E,n[1]=u*p+h*y+c*b,n[4]=u*m+h*g+c*T,n[7]=u*v+h*x+c*E,n[2]=l*p+f*y+d*b,n[5]=l*m+f*g+d*T,n[8]=l*v+f*x+d*E,this},e.determinant=function(){var t=this.elements,e=t[0],i=t[3],r=t[6],n=t[1],s=t[4],a=t[7],o=t[2],u=t[5],h=t[8];return e*(s*h-u*a)+n*(u*r-i*h)+o*(i*a-s*r)},e.invert=function(){var t=this.elements,e=t[0],i=t[3],r=t[6],n=t[1],s=t[4],a=t[7],o=t[2],u=t[5],h=t[8],c=h*s-u*a,l=u*r-h*i,f=a*i-s*r,d=e*c+n*l+o*f;if(0===d)return this.set(0,0,0,0,0,0,0,0,0);var p=1/d;return t[0]=c*p,t[1]=(o*a-h*n)*p,t[2]=(u*n-o*s)*p,t[3]=l*p,t[4]=(h*e-o*r)*p,t[5]=(o*i-u*e)*p,t[6]=f*p,t[7]=(n*r-a*e)*p,t[8]=(s*e-n*i)*p,this},e.transpose=function(){var t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this},e.transformPoint=function(t,e){var i=t.x,r=t.y,n=t.z,s=this.elements,a=null!=e?e:t;return a.x=s[0]*i+s[3]*r+s[6]*n,a.y=s[1]*i+s[4]*r+s[7]*n,a.z=s[2]*i+s[5]*r+s[8]*n,a},e.transformNormal=function(t,e){return this.transformPoint(t,e).normalize()},e.equals=function(t){for(var e=this.elements,i=t.elements,r=0;r<9;r++)if(!We(e[r],i[r]))return!1;return!0},e.toArray=function(){return[].concat(this.elements)},e.fill=function(t,e){void 0===e&&(e=0);var i=this.elements;t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8]},t.fromIdentity=function(){return new t(1,0,0,0,1,0,0,0,1)},t.fromColumnVectors=function(e,i,r){return(new t).setFromColumnVectors(e,i,r)},t.fromMatrix4=function(e){return(new t).setFromMatrix4(e)},t.fromArray=function(e,i){return void 0===i&&(i=0),(new t).setFromArray(e,i)},t.fromQuaternion=function(e){return(new t).setFromQuaternion(e)},t.fromRowMajorData=function(e,i,r,n,s,a,o,u,h){return new t(e,n,o,i,s,u,r,a,h)},t}(),Mr=function(){function t(t,e){void 0===t&&(t=Qe.ZERO),void 0===e&&(e=Qe.X),this.origin=new Qe,this.direction=new Qe,this.origin.copyFrom(t),this.direction.copyFrom(e).normalize()}var e=t.prototype;return e.set=function(t,e){return this.origin.copyFrom(t),this.direction.copyFrom(e).normalize(),this},e.clone=function(){return new t(this.origin,this.direction)},e.copyFrom=function(t){return this.set(t.origin,t.direction)},e.recast=function(e){return this.origin.copyFrom(this.at(e,t.tempVec0)),this},e.at=function(t,e){var i=e||new Qe;return i.copyFrom(this.origin),i.addScaledVector(this.direction,t)},e.equals=function(t){return this.origin.equals(t.origin)&&this.direction.equals(t.direction)},e.applyMatrix=function(t){return this.origin.applyProjectionMatrix(t),this.direction.applyNormalMatrix(t),this},e.intersectBox=function(t,e){var i,r,n,s,a,o,u=this.origin,h=u.x,c=u.y,l=u.z,f=this.direction,d=f.x,p=f.y,m=f.z,v=t.min,y=v.x,g=v.y,x=v.z,b=t.max,T=b.x,E=b.y,_=b.z,w=1/d,A=1/p,C=1/m;if(w>=0?(i=(y-h)*w,r=(T-h)*w):(i=(T-h)*w,r=(y-h)*w),A>=0?(n=(g-c)*A,s=(E-c)*A):(n=(E-c)*A,s=(g-c)*A),!(i>s||n>r||((n>i||i!=i)&&(i=n),(s<r||r!=r)&&(r=s),(n>i||i!=i)&&(i=n),(s<r||r!=r)&&(r=s),C>=0?(a=(x-l)*C,o=(_-l)*C):(a=(_-l)*C,o=(x-l)*C),i>o||a>r||((a>i||i!=i)&&(i=a),(o<r||r!=r)&&(r=o),r<0))))return i>=0?this.at(i,e):this.at(r,e)},e.intersectPlane=function(t,e){var i=t.normal,r=t.distance,n=i.dot(this.direction);if(0===n)return 0===i.dot(this.origin)+r?(e||new Qe).copyFrom(this.origin):void 0;var s=-(this.origin.dot(i)+r)/n;return s>=0?this.at(s,e):void 0},e.intersectSphere=function(e,i){var r=e.center,n=t.tempVec0.subtractVectors(r,this.origin),s=n.dot(this.direction),a=n.dot(n)-s*s,o=e.radius*e.radius;if(!(a>o)){var u=Math.sqrt(o-a),h=s-u,c=s+u;if(!(c<0))return h>=0?this.at(h,i):this.at(c,i)}},e.intersectTriangle=function(e,i,r){var n,s=e.p0,a=e.p1,o=e.p2,u=t.tempVec0.subtractVectors(a,s),h=t.tempVec1.subtractVectors(o,s),c=t.tempVec2.subtractVectors(this.origin,s),l=t.tempVec3.crossVectors(u,h),f=this.direction.dot(l);if(f>0){if(r)return;n=1}else{if(!(f<0))return;n=-1,f=-f}h.crossVectors(c,h);var d=n*this.direction.dot(h);if(!(d<0)){u.cross(c);var p=n*this.direction.dot(u);if(!(p<0||d+p>f)){var m=-n*c.dot(l);if(!(m<0))return this.at(m/f,i)}}},t}();Mr.tempVec0=new Qe,Mr.tempVec1=new Qe,Mr.tempVec2=new Qe,Mr.tempVec3=new Qe;var Ir,Pr,Lr=function(){function t(t,e){void 0===t&&(t=new Qe(1/0,1/0,1/0)),void 0===e&&(e=new Qe(-1/0,-1/0,-1/0)),this.min=t.clone(),this.max=e.clone()}var e=t.prototype;return e.set=function(t,e){return this.min.copyFrom(t),this.max.copyFrom(e),this},e.setFromArray=function(t){for(var e=Number(1/0),i=Number(1/0),r=Number(1/0),n=-1/0,s=-1/0,a=-1/0,o=0,u=t.length;o<u;o+=3){var h=t[o],c=t[o+1],l=t[o+2];h<e&&(e=h),c<i&&(i=c),l<r&&(r=l),h>n&&(n=h),c>s&&(s=c),l>a&&(a=l)}return this.min.set(e,i,r),this.max.set(n,s,a),this},e.setFromPoints=function(t){this.makeEmpty();for(var e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this},e.setFromCenterAndSize=function(t,e){var i=e.clone().multiply(.5);return this.min.copyFrom(t).subtract(i),this.max.copyFrom(t).add(i),this},e.setFromObject=function(t){return this.makeEmpty(),this.expandByObject(t)},e.clone=function(){return(new t).copyFrom(this)},e.copyFrom=function(t){return this.min.copyFrom(t.min),this.max.copyFrom(t.max),this},e.makeEmpty=function(){return this.min.x=this.min.y=this.min.z=Number(1/0),this.max.x=this.max.y=this.max.z=-1/0,this},e.isEmpty=function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},e.getCenter=function(t){return void 0===t&&(t=new Qe),this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiply(.5)},e.getSize=function(t){return void 0===t&&(t=new Qe),this.isEmpty()?t.set(0,0,0):t.subtractVectors(this.max,this.min)},e.expandByPoint=function(t){return this.min.min(t),this.max.max(t),this},e.expandByVector=function(t){return this.min.subtract(t),this.max.add(t),this},e.expandByScalar=function(t){return this.min.add(-t),this.max.add(t),this},e.expandByBox=function(t){return this.min.min(t.min),this.max.max(t.max),this},e.expandByObject=function(e){e.updateWorldMatrix(!1,!1);var i=e.geometry;if(void 0!==i){null===i.boundingBox&&i.computeBoundingBox();var r=new t;r.copyFrom(i.boundingBox),r.applyMatrix4(e.matrixWorld),this.union(r)}for(var n=e.children,s=0,a=n.length;s<a;s++)this.expandByObject(n[s]);return this},e.containsPoint=function(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)},e.containsBox=function(t){return this.min.x<=t.min.x&&this.max.x>=t.max.x&&this.min.y<=t.min.y&&this.max.y>=t.max.y&&this.min.z<=t.min.z&&this.max.z>=t.max.z},e.getParameter=function(t,e){return void 0===e&&(e=new Qe),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},e.intersectsBox=function(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)},e.intersectsSphere=function(t){var e=new Qe;return this.clampPoint(t.center,e),e.distanceSquared(t.center)<=t.radius*t.radius},e.clampPoint=function(t,e){return void 0===e&&(e=new Qe),e.copyFrom(t).clamp(this.min,this.max)},e.distanceToPoint=function(t){return t.clone().clamp(this.min,this.max).subtract(t).length()},e.intersect=function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},e.union=function(t){return this.min.min(t.min),this.max.max(t.max),this},e.applyMatrix4=function(t,e){if(void 0===e&&(e=new Qe),this.isEmpty())return this;var i=this.getOBBPoints(t,e);return this.setFromPoints(i),this},e.getOBBPoints=function(t,e){if(void 0===e&&(e=new Qe),this.isEmpty())return[];var i=[];return i[0]=new Qe(this.min.x,this.min.y,this.min.z),i[1]=new Qe(this.min.x,this.min.y,this.max.z),i[2]=new Qe(this.min.x,this.max.y,this.min.z),i[3]=new Qe(this.min.x,this.max.y,this.max.z),i[4]=new Qe(this.max.x,this.min.y,this.min.z),i[5]=new Qe(this.max.x,this.min.y,this.max.z),i[6]=new Qe(this.max.x,this.max.y,this.min.z),i[7]=new Qe(this.max.x,this.max.y,this.max.z),i.forEach((function(i){i.subtract(e),i.applyMatrix(t),i.add(e)})),i},e.getBoundingSphere=function(t){this.getCenter(t.center);var e=new Qe;return t.radius=.5*this.getSize(e).length(),t},e.translate=function(t){return this.min.add(t),this.max.add(t),this},e.equals=function(t){return t.min.equals(this.min)&&t.max.equals(this.max)},t}(),Fr=function(){function t(t,e){void 0===t&&(t=Qe.ZERO),void 0===e&&(e=-1),this.center=t.clone(),this.radius=e}var e=t.prototype;return e.set=function(t,e){return this.center.copyFrom(t),this.radius=e,this},e.setFromPoints=function(t,e){var i=this.center;if(void 0!==e){i.copyFrom(e);for(var r=0,n=0;n<t.length;n++)r=Math.max(r,i.distanceSquared(t[n]));this.radius=Math.sqrt(r)}else{var s=(new Lr).setFromPoints(t);s.getCenter(i),this.radius=s.getSize().length()/2}return this},e.copyFrom=function(t){return this.center.copyFrom(t.center),this.radius=t.radius,this},e.isEmpty=function(){return this.radius<0},e.makeEmpty=function(){return this.center.set(0,0,0),this.radius=-1,this},e.containsPoint=function(t){return t.distanceSquared(this.center)<=this.radius*this.radius},e.distanceToPoint=function(t){return t.distance(this.center)-this.radius},e.intersectsSphere=function(t){var e=this.radius+t.radius;return t.center.distanceSquared(this.center)<=e*e},e.intersectsBox=function(t){return t.intersectsSphere(this)},e.clampPoint=function(t,e){var i=this.center.distanceSquared(t);return void 0===e&&(e=new Qe),e.copyFrom(t),i>this.radius*this.radius&&(e.subtract(this.center).normalize(),e.multiply(this.radius).add(this.center)),e},e.getBoundingBox=function(t){return void 0===t&&(t=new Lr),this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)},e.applyMatrix4=function(t){var e=t.elements,i=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],n=e[8]*e[8]+e[9]*e[9]+e[10]*e[10],s=Math.sqrt(Math.max(i,r,n));return this.center.applyMatrix(t),this.radius=this.radius*s,this},e.translate=function(t){return this.center.add(t),this},e.expandByPoint=function(t){var e=(new Qe).subtractVectors(t,this.center),i=e.lengthSquared();if(i>this.radius*this.radius){var r=Math.sqrt(i),n=.5*(r-this.radius);this.center.add(e.multiply(n/r)),this.radius+=n}return this},e.union=function(t){var e=new Qe,i=new Qe;return i.subtractVectors(t.center,this.center).normalize().multiply(t.radius),this.expandByPoint(e.copyFrom(t.center).add(i)),this.expandByPoint(e.copyFrom(t.center).subtract(i)),this},e.intersect=function(t){var e=(new Qe).subtractVectors(this.center,t.center),i=e.length();return i>this.radius+t.radius?this.makeEmpty():(this.center=this.center.add(e.normalize().multiply(i/2)),this.radius=this.radius+t.radius-i,this)},e.equals=function(t){return t.center.equals(this.center)&&t.radius===this.radius},e.clone=function(){return(new t).copyFrom(this)},t}(),Vr=Object.freeze({__proto__:null,get EulerOrder(){return br},Euler:Or,Quaternion:ri,Vector2:Ke,Vector3:Qe,Vector4:Je,Matrix3:Rr,Matrix4:ni,Ray:Mr,PI2:je,DEG2RAD:Xe,RAD2DEG:He,NumberEpsilon:Ye,isZero:function(t){return isNaN(t)||Math.abs(t)<Ye},isEqual:We,damp:function(t,e,i,r){return Ze(t,e,1-Math.exp(-i*r))},lerp:Ze,degToRad:function(t){return t*Xe},radToDeg:function(t){return t*He},clamp:qe,Color:ii,Box3:Lr,Sphere:Fr}),Nr=1,Dr=function(t){function e(e,i){var r;if((r=t.call(this,e)||this).destroyed=!1,r.visible=!0,i){var n=i.material,s=i.geometry,a=i.name,o=void 0===a?"<unnamed>":a,u=i.priority,h=void 0===u?0:u,c=i.worldMatrix,l=void 0===c?ni.fromIdentity():c;r.id="Mesh"+Nr++,r.name=o,r.geometry=s,r.material=n,r.priority=h,r.worldMatrix=l}else r.id="Mesh"+Nr++,r.name="<unnamed>",r.worldMatrix=ni.fromIdentity(),r._priority=0;return r}Qt(e,t);var i=e.prototype;return i.setVisible=function(t){this.visible=t},i.getVisible=function(){return this.visible},i.render=function(t){this.isDestroyed||this.getVisible()&&(t.renderingData.currentFrame.globalUniforms&&t.setGlobalMatrix("effects_ObjectToWorld",this.worldMatrix),t.drawGeometry(this.geometry,this.material))},i.firstGeometry=function(){return this.geometry},i.setMaterial=function(t,e){e!==pt.keep&&this.material.dispose(e),this.material=t},i.restore=function(){},i.dispose=function(t){if(!this.destroyed){(null==t?void 0:t.geometries)!==pt.keep&&this.geometry.dispose();var e=null==t?void 0:t.material;e!==pt.keep&&this.material.dispose(e),this.destroyed=!0,void 0!==this.engine&&(this.engine.removeMesh(this),this.engine=void 0)}},Pe(e,[{key:"isDestroyed",get:function(){return this.destroyed}}]),e}(Ge),kr=0,zr=1e3,Ur=3e3;!function(t){t[t.none=0]="none",t[t.color=1]="color",t[t.stencil_8_opaque=2]="stencil_8_opaque",t[t.depth_16_opaque=3]="depth_16_opaque",t[t.depth_stencil_opaque=4]="depth_stencil_opaque",t[t.depth_16_texture=5]="depth_16_texture",t[t.depth_24_stencil_8_texture=6]="depth_24_stencil_8_texture"}(Ir||(Ir={})),function(t){t[t.store=0]="store",t[t.clear=2]="clear"}(Pr||(Pr={}));var Br,Gr=function(){function t(t,e){if(this.destroyed=!1,e){var i=e.texture,r=e.size;if(A(i,Yi))this.texture=i,this.externalTexture=!0;else if(i){var n=i.wrapT,s=i.wrapS,a=i.minFilter,o=i.magFilter,u=i.internalFormat,h=i.format,c=void 0===h?fi.RGBA:h,l=i.type,f=void 0===l?fi.UNSIGNED_BYTE:l;this.externalTexture=!1,this.textureOptions={size:r,format:c,type:f,internalFormat:u||c,wrapT:n,wrapS:s,minFilter:a,magFilter:o,name:e.name},this.texture=Yi.create(t,_i({},this.textureOptions,{sourceType:ci.framebuffer,data:{width:r[0],height:r[1]}}))}}}return t.prototype.dispose=function(){this.destroyed||(this.texture.dispose(),this.destroyed=!0)},Pe(t,[{key:"isDestroyed",get:function(){return this.destroyed}},{key:"storageType",get:function(){return 1}},{key:"size",get:function(){var t=this.texture;return t?[t.getWidth(),t.getHeight()]:[0,0]}},{key:"width",get:function(){return this.texture.getWidth()||0}},{key:"height",get:function(){return this.texture.getHeight()||0}}]),t}();!function(t){t[t.force=0]="force",t[t.keep=1]="keep",t[t.keepExternal=2]="keepExternal",t[t.destroy=0]="destroy"}(Br||(Br={}));var jr=1,Xr=function(){function t(t,e){this.attachments=[],this.destroyed=!1,this.initialized=!1;var i=e.name,r=void 0===i?"RenderPass_"+jr++:i,n=e.clearAction,s=e.semantics,a=e.depthStencilAttachment,o=e.storeAction,u=e.priority,h=void 0===u?0:u,c=e.meshOrder,l=void 0===c?F.ascending:c,f=e.meshes,d=void 0===f?[]:f,p=e.delegate,m=void 0===p?{}:p;this.name=r,this.renderer=t,this.priority=h,this.meshOrder=l,this.meshes=rt(d.slice(),this.meshOrder),this.depthStencilType=(null==a?void 0:a.storageType)||0,this.clearAction=_i({},n),this.storeAction=_i({colorAction:0,depthAction:0,stencilAction:0},o),this.semantics=new wr(s),this.options=e,this.delegate=m,this.setViewportOptions(e)}var e=t.prototype;return e.addMesh=function(t){nt(this.meshes,t,this.meshOrder)},e.removeMesh=function(t){k(this.meshes,t)},e.setMeshes=function(t){var e;return this.meshes.length=0,(e=this.meshes).splice.apply(e,[].concat([0,0],t)),rt(this.meshes,this.meshOrder),this.meshes},e.getInitAttachments=function(){return this.attachments.length>0?this.attachments:this.options.attachments},e.configure=function(t){if(this.framebuffer)t.setFramebuffer(this.framebuffer);else{var e=this.getViewport(),i=e[0],r=e[1],n=e[2],s=e[3];t.setViewport(i,r,n,s)}},e.execute=function(t){t.clear(this.clearAction),t.renderMeshes(this.meshes),t.clear(this.storeAction)},e.frameCleanup=function(t){},e.resetColorAttachments=function(t){var e=this;if(t.length||this.resetAttachments({attachments:[]}),this.attachments.length){var i=t.map((function(t){return t.updateSource({sourceType:ci.framebuffer}),new Gr(e.renderer.engine,{texture:t})}));this.attachments.forEach((function(t){return!t.externalTexture&&t.dispose()})),this.attachments=i,this.framebuffer&&(this.framebuffer.bind(),this.framebuffer.resetColorTextures(t.map((function(t){return t}))))}else this.resetAttachments({attachments:t.map((function(t){return{texture:t}}))})},e.resetAttachments=function(t){this.options=t,this.setViewportOptions(t),this.renderer&&this._resetAttachments()},e.setViewportOptions=function(t){if(t.viewport){if(this.isCustomViewport=!0,this.viewportScale=1,this.customViewport=t.viewport.slice(0,4),this.framebuffer){var e=this.customViewport;this.framebuffer.isCustomViewport=!1,this.framebuffer.resize(e[0],e[1],e[2],e[3])}}else this.isCustomViewport=!1,this.viewportScale=t.viewportScale||1,this.framebuffer&&(this.framebuffer.isCustomViewport=!0,this.framebuffer.viewportScale=this.viewportScale)},e._resetAttachments=function(){var t,e,i=this,r=this.renderer,n=this.options;this.attachments.length&&(this.attachments.forEach((function(t){return!t.externalTexture&&t.dispose()})),this.attachments.length=0,null==(e=this.framebuffer)||e.dispose({depthStencilAttachment:2}),this.framebuffer=null);var s=this.viewportScale,a=this.isCustomViewport?this.customViewport:[0,0,r.getWidth()*s,r.getHeight()*s],o=[a[2],a[3]],u=this.name;if(null==(t=n.attachments)?void 0:t.length){var h=n.attachments.map((function(t,e){var r;return new Gr(i.renderer.engine,_i({size:o,name:(null==(r=t.texture)?void 0:r.name)||u+"##color_"+e},t))}));this.attachments=h;var c=Mn.create({storeAction:this.storeAction,name:u,viewport:a,viewportScale:this.viewportScale,isCustomViewport:this.isCustomViewport,attachments:h.map((function(t){return t.texture})),depthStencilAttachment:n.depthStencilAttachment||{storageType:0}},r);c.bind(),c.unbind(),this.framebuffer=c}else this.attachments.length=0},e.getViewport=function(){var t,e=(null==(t=this.framebuffer)?void 0:t.viewport)||this.customViewport;if(e)return e;var i=this.renderer,r=this.viewportScale;return i?[0,0,i.getWidth()*r,i.getHeight()*r]:[0,0,0,0]},e.getDepthAttachment=function(){var t=this.framebuffer;if(t){var e=t.getDepthTexture(),i=e?this.getDepthTexture(e,t.externalStorage):void 0;return{storageType:t.depthStencilStorageType,storage:t.depthStorage,texture:i}}},e.getStencilAttachment=function(){var t=this.framebuffer;if(t){var e=t.getStencilTexture(),i=e?this.getDepthTexture(e,t.externalStorage):void 0;return{storageType:t.depthStencilStorageType,storage:t.stencilStorage,texture:i}}},e.getDepthTexture=function(t,e){if(!this.depthTexture){var i,r=null==(i=this.options.depthStencilAttachment)?void 0:i.texture,n=t===r?r:t;return e||(this.depthTexture=n),n}return this.depthTexture},e.getStencilTexture=function(t,e){if(!this.stencilTexture){var i,r=null==(i=this.options.depthStencilAttachment)?void 0:i.texture,n=t===r?r:t;return e||(this.stencilTexture=n),n}return this.stencilTexture},e.initialize=function(t){return this.initialized||(this._resetAttachments(),this.initialized=!0),this},e.dispose=function(t){if(!this.destroyed){var e=(null==t?void 0:t.meshes)||void 0;e!==pt.keep&&this.meshes.forEach((function(t){t.dispose(e)})),this.meshes.length=0;var i=(null==t?void 0:t.colorAttachment)?t.colorAttachment:0;this.attachments.forEach((function(t){t.externalTexture&&2===i||1===i||t.dispose()})),this.attachments.length=0,(null==t?void 0:t.semantics)!==pt.keep&&this.semantics.dispose(),this.destroyed=!0;var r,n,s=(null==t?void 0:t.depthStencilAttachment)?t.depthStencilAttachment:0,a=this.framebuffer;if(a)if(a.dispose({depthStencilAttachment:s}),!(a.externalStorage&&2===s||1===s))null==(r=this.stencilTexture)||r.dispose(),null==(n=this.depthTexture)||n.dispose();this.options=this.renderer=null,this.initialize=_t}},Pe(t,[{key:"isDestroyed",get:function(){return this.destroyed}},{key:"viewport",get:function(){return this.getViewport()}},{key:"stencilAttachment",get:function(){return this.getStencilAttachment()}},{key:"depthAttachment",get:function(){return this.getDepthAttachment()}}]),t}(),Hr="vec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;float alpha=ret.a;if(mode==1.){ret.rgb*=alpha;}else if(mode==2.){ret.rgb*=alpha;ret.a=dot(ret.rgb,vec3(0.33333333));}else if(mode==3.){alpha=color.r*alpha;ret=vec4(vc.rgb*alpha,alpha);}return ret;}",Yr="#version 100\nprecision highp float;vec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;float alpha=ret.a;if(mode==1.){ret.rgb*=alpha;}else if(mode==2.){ret.rgb*=alpha;ret.a=dot(ret.rgb,vec3(0.33333333));}else if(mode==3.){alpha=color.r*alpha;ret=vec4(vc.rgb*alpha,alpha);}return ret;}varying vec4 vColor;varying vec4 vTexCoord;varying highp vec2 vParams;uniform vec3 uFrameColor;void main(){gl_FragColor=vec4(uFrameColor.xyz,1.0);}",Wr="float calculateMovement(float t,vec2 p1,vec2 p2,vec2 p3,vec2 p4){float movement=0.0;float h=(t-p1.x)*0.05;for(int i=0;i<=20;i++){float t=float(i)*h;float nt=binarySearchT(t,p1.x,p2.x,p3.x,p4.x);float y=cubicBezier(nt,p1.y,p2.y,p3.y,p4.y);float weight=(i==0||i==20)? 1.0 :(mod(float(i),2.)!=0.)? 4.0 : 2.0;movement+=weight*y;}movement*=h/3.;return movement;}float integrateFromBezierCurveFrames(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i+=2){vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);if(i==0&&time<k0.x){return ret;}vec2 p1=vec2(k0.x,k0.y);vec2 p2=vec2(k0.z,k0.w);vec2 p3=vec2(k1.z,k1.w);vec2 p4=vec2(k1.x,k1.y);if(time>=k1.x){ret+=calculateMovement(k1.x,p1,p2,p3,p4);}if(time>=k0.x&&time<k1.x){return ret+calculateMovement(time,p1,p2,p3,p4);}}return ret;}float integrateByTimeLineSeg(float t,vec2 p0,vec2 p1){float t0=p0.x;float t1=p1.x;float y0=p0.y;float y1=p1.y;vec4 tSqr=vec4(t,t,t0,t0);tSqr=tSqr*tSqr;vec4 a=vec4(2.*t,3.,-t0,3.)*tSqr;float t1y0=t1*y0;vec4 b=vec4(y0-y1,t0*y1-t1y0,2.*y0+y1,t1y0);float r=dot(a,b);return r/(t0-t1)*0.16666667;}float integrateLineSeg(float time,vec2 p0,vec2 p1){float h=time-p0.x;float y0=p0.y;return(y0+y0+(p1.y-y0)*h/(p1.x-p0.x))*h/2.;}float integrateFromLineSeg(float time,float frameStart,float frameCount){if(time==0.){return 0.;}int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i++){if(i>count){return ret;}vec4 ks=lookup_curve(i+start);vec2 k0=ks.xy;vec2 k1=ks.zw;if(time>k0.x&&time<=k1.x){return ret+integrateLineSeg(time,k0,k1);}ret+=integrateLineSeg(k1.x,k0,k1);vec2 k2=lookup_curve(i+start+1).xy;if(time>k1.x&&time<=k2.x){return ret+integrateLineSeg(time,k1,k2);}ret+=integrateLineSeg(k2.x,k1,k2);}return ret;}float integrateByTimeFromLineSeg(float time,float frameStart,float frameCount){if(time==0.){return 0.;}int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i++){if(i>count){return ret;}vec4 ks=lookup_curve(i+start);vec2 k0=ks.xy;vec2 k1=ks.zw;if(time>k0.x&&time<=k1.x){return ret+integrateByTimeLineSeg(time,k0,k1);}ret+=integrateByTimeLineSeg(k1.x,k0,k1);vec2 k2=lookup_curve(i+start+1).xy;if(time>k1.x&&time<=k2.x){return ret+integrateByTimeLineSeg(time,k1,k2);}ret+=integrateByTimeLineSeg(k2.x,k1,k2);}return ret;}float getIntegrateFromTime0(float t1,vec4 value){float type=value.x;if(type==0.){return value.y*t1;}if(type==1.){vec2 p0=vec2(0.,value.y);vec2 p1=vec2(value.w,value.z);return integrateLineSeg(t1,p0,p1);}if(type==3.){return integrateFromLineSeg(t1,value.y,value.z);}if(type==4.){return mix(value.y,value.z,aSeed)*t1;}if(type==5.){return integrateFromBezierCurveFrames(t1,value.z,value.w);}return 0.;}float getIntegrateByTimeFromTime(float t0,float t1,vec4 value){float type=value.x;if(type==0.){return value.y*(t1*t1-t0*t0)/2.;}else if(type==1.){vec2 p0=vec2(0.,value.y);vec2 p1=vec2(value.w,value.z);return integrateByTimeLineSeg(t1,p0,p1)-integrateByTimeLineSeg(t0,p0,p1);}if(type==3.){return integrateByTimeFromLineSeg(t1,value.y,value.z)-integrateByTimeFromLineSeg(t0,value.y,value.z);}if(type==4.){return mix(value.y,value.z,aSeed)*(t1*t1-t0*t0)/2.;}if(type==5.){return integrateFromBezierCurveFrames(t1,value.z,value.w)-integrateFromBezierCurveFrames(t0,value.z,value.w);}return 0.;}",Zr="precision highp float;attribute vec2 aUV;attribute vec3 aPos;varying vec2 vTexCoord;varying vec3 vParams;varying vec4 vColor;uniform vec2 _Size;uniform vec3 _Scale;uniform vec4 _Color;uniform vec4 _TexParams;uniform vec4 _TexOffset;uniform mat4 effects_MatrixVP;uniform mat4 effects_ObjectToWorld;uniform mat4 effects_MatrixV;\n#ifdef ENV_EDITOR\nuniform vec4 uEditorTransform;\n#endif\nvoid main(){vec4 texParams=_TexParams;vTexCoord=vec2(aUV.xy*_TexOffset.zw+_TexOffset.xy);vColor=_Color;vParams=vec3(texParams.w,texParams.y,texParams.x);if(texParams.z==1.0){vec4 pos=vec4(aPos.xy*_Size,aPos.z,1.0);gl_Position=effects_MatrixVP*effects_ObjectToWorld*pos;}else{mat4 view=effects_MatrixV;vec3 camRight=vec3(view[0][0],view[1][0],view[2][0]);vec3 camUp=vec3(view[0][1],view[1][1],view[2][1]);vec3 worldPosition=vec3(effects_ObjectToWorld*vec4(0.0,0.0,0.0,1.0));vec3 vertexPosition=worldPosition+camRight*aPos.x*_Size.x*_Scale.x+camUp*aPos.y*_Size.y*_Scale.y;gl_Position=effects_MatrixVP*vec4(vertexPosition,1.0);}\n#ifdef ENV_EDITOR\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#endif\n}",qr="precision highp float;varying vec4 vColor;varying vec2 vTexCoord;varying vec3 vParams;uniform sampler2D _MainTex;vec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;float alpha=ret.a;if(mode==1.){ret.rgb*=alpha;}else if(mode==2.){ret.rgb*=alpha;ret.a=dot(ret.rgb,vec3(0.33333333));}else if(mode==3.){alpha=color.r*alpha;ret=vec4(vc.rgb*alpha,alpha);}return ret;}void main(){vec4 color=vec4(0.);\n#ifdef TRANSPARENT_VIDEO\nfloat halfX=vTexCoord.x*0.5;vec2 uv_rgb=vec2(halfX,vTexCoord.y);vec2 uv_alpha=vec2(halfX+0.5,vTexCoord.y);vec3 rgb=texture2D(_MainTex,uv_rgb).rgb;float alpha=max(texture2D(_MainTex,uv_alpha).r,1e-5);vec4 texColor=vec4(rgb/alpha,alpha);\n#else\nvec4 texColor=texture2D(_MainTex,vTexCoord.xy);\n#endif\ncolor=blendColor(texColor,vColor,floor(0.5+vParams.y));\n#ifdef ALPHA_CLIP\nif(color.a<0.04){discard;}\n#endif\ncolor.a=clamp(color.a,0.0,1.0);gl_FragColor=color;}",Kr="#version 100\nprecision mediump float;vec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;float alpha=ret.a;if(mode==1.){ret.rgb*=alpha;}else if(mode==2.){ret.rgb*=alpha;ret.a=dot(ret.rgb,vec3(0.33333333));}else if(mode==3.){alpha=color.r*alpha;ret=vec4(vc.rgb*alpha,alpha);}return ret;}\n#define PATICLE_SHADER 1\nvarying float vLife;varying vec2 vTexCoord;varying vec4 vColor;uniform vec3 emissionColor;uniform float emissionIntensity;uniform sampler2D uMaskTex;uniform vec4 uColorParams;uniform vec2 uTexOffset;\n#ifdef COLOR_OVER_LIFETIME\nuniform sampler2D uColorOverLifetime;\n#endif\n#ifdef USE_SPRITE\nvarying vec4 vTexCoordBlend;\n#endif\nvarying float vSeed;\n#ifdef PREVIEW_BORDER\nuniform vec4 uPreviewColor;\n#endif\n#ifdef USE_SPRITE\nvec4 getTextureColor(sampler2D tex,vec2 texCoord){if(vTexCoordBlend.w>0.){return mix(texture2D(tex,texCoord),texture2D(tex,vTexCoordBlend.xy+texCoord),vTexCoordBlend.z);}return texture2D(tex,texCoord);}\n#else\n#define getTextureColor texture2D\n#endif\n#ifndef WEBGL2\n#define round(a) floor(0.5+a)\n#endif\n#ifdef PREVIEW_BORDER\nvoid main(){gl_FragColor=uPreviewColor;}\n#else\nvoid main(){vec4 color=vec4(1.0);vec4 tempColor=vColor;vec2 texOffset=uTexOffset;if(vLife<0.){discard;}if(uColorParams.x>0.0){color=getTextureColor(uMaskTex,vTexCoord);}\n#ifdef COLOR_OVER_LIFETIME\n#ifndef ENABLE_VERTEX_TEXTURE\ntempColor*=texture2D(uColorOverLifetime,vec2(vLife,0.));\n#endif\n#endif\ncolor=blendColor(color,tempColor,round(uColorParams.y));if(color.a<=0.01&&uColorParams.w>0.){float _at=texture2D(uMaskTex,vTexCoord+texOffset).a+texture2D(uMaskTex,vTexCoord+texOffset*-1.).a;if(_at<=0.02){discard;}}vec3 emission=emissionColor*pow(2.0,emissionIntensity);color=vec4(pow(pow(color.rgb,vec3(2.2))+emission,vec3(1.0/2.2)),color.a);gl_FragColor=color;}\n#endif\n",Qr="#version 100\nprecision mediump float;\n#define SHADER_VERTEX 1\n#define PATICLE_SHADER 1\n#ifdef SHADER_VERTEX\n#define CURVE_VALUE_TEXTURE uVCurveValueTexture\n#define CURVE_VALUE_ARRAY uVCurveValues\n#define CURVE_VALUE_COUNT VERT_CURVE_VALUE_COUNT\n#define FRAG_CURVE_VALUE_COUNT 0\n#else\n#define CURVE_VALUE_TEXTURE uFCurveValueTexture\n#define CURVE_VALUE_ARRAY uFCurveValues\n#define CURVE_VALUE_COUNT FRAG_CURVE_VALUE_COUNT\n#define VERT_CURVE_VALUE_COUNT 0\n#endif\n#if CURVE_VALUE_COUNT > 0\n#if LOOKUP_TEXTURE_CURVE\nuniform sampler2D CURVE_VALUE_TEXTURE;const float uCurveCount=1./float(CURVE_VALUE_COUNT);\n#define lookup_curve(i) texture2D(CURVE_VALUE_TEXTURE,vec2(float(i) * uCurveCount,0.))\n#else\nuniform vec4 CURVE_VALUE_ARRAY[CURVE_VALUE_COUNT];\n#define lookup_curve(i) CURVE_VALUE_ARRAY[i]\n#endif\n#else\n#define lookup_curve(i) vec4(0.)\n#endif\n#ifdef WEBGL2\n#define ITR_END (count + 1)\n#else\n#define ITR_END MAX_C\n#endif\n#define NONE_CONST_INDEX 1\n#ifdef SHADER_VERTEX\nattribute float aSeed;varying float vSeed;\n#endif\n#ifdef SHADER_VERTEX\n#define MAX_C VERT_MAX_KEY_FRAME_COUNT\n#else\n#define MAX_C FRAG_MAX_KEY_FRAME_COUNT\n#endif\nmat4 cubicBezierMatrix=mat4(1.0,-3.0,3.0,-1.0,0.0,3.0,-6.0,3.0,0.0,0.0,3.0,-3.0,0.0,0.0,0.0,1.0);float cubicBezier(float t,float y1,float y2,float y3,float y4){vec4 tVec=vec4(1.0,t,t*t,t*t*t);vec4 yVec=vec4(y1,y2,y3,y4);vec4 result=tVec*cubicBezierMatrix*yVec;return result.x+result.y+result.z+result.w;}float binarySearchT(float x,float x1,float x2,float x3,float x4){float left=0.0;float right=1.0;float mid=0.0;float computedX;for(int i=0;i<8;i++){mid=(left+right)*0.5;computedX=cubicBezier(mid,x1,x2,x3,x4);if(abs(computedX-x)<0.0001){break;}else if(computedX>x){right=mid;}else{left=mid;}}return mid;}float valueFromBezierCurveFrames(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);for(int i=0;i<ITR_END;i+=2){if(i>=count){break;}vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);if(i==0&&time<k0.x){return k0.y;}if(i==int(frameCount-2.)&&time>=k1.x){return k1.y;}if(time>=k0.x&&time<=k1.x){float t=(time-k0.x)/(k1.x-k0.x);float nt=binarySearchT(time,k0.x,k0.z,k1.z,k1.x);return cubicBezier(nt,k0.y,k0.w,k1.w,k1.y);}}}float evaluteLineSeg(float t,vec2 p0,vec2 p1){return p0.y+(p1.y-p0.y)*(t-p0.x)/(p1.x-p0.x);}float valueFromLineSegs(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);int end=start+count;for(int i=0;i<ITR_END;i++){if(i>count){return lookup_curve(i).w;}vec4 seg=lookup_curve(i+start);vec2 p0=seg.xy;vec2 p1=seg.zw;if(time>=p0.x&&time<=p1.x){return evaluteLineSeg(time,p0,p1);}vec2 p2=lookup_curve(i+start+1).xy;if(time>p1.x&&time<=p2.x){return evaluteLineSeg(time,p1,p2);}}return lookup_curve(0).y;}float getValueFromTime(float time,vec4 value){float type=value.x;if(type==0.){return value.y;}if(type==1.){return mix(value.y,value.z,time/value.w);}if(type==3.){return valueFromLineSegs(time,value.y,value.z);}if(type==4.){return mix(value.y,value.z,aSeed);}if(type==5.){return valueFromBezierCurveFrames(time,value.z,value.w);}return 0.;}float calculateMovement(float t,vec2 p1,vec2 p2,vec2 p3,vec2 p4){float movement=0.0;float h=(t-p1.x)*0.05;for(int i=0;i<=20;i++){float t=float(i)*h;float nt=binarySearchT(t,p1.x,p2.x,p3.x,p4.x);float y=cubicBezier(nt,p1.y,p2.y,p3.y,p4.y);float weight=(i==0||i==20)? 1.0 :(mod(float(i),2.)!=0.)? 4.0 : 2.0;movement+=weight*y;}movement*=h/3.;return movement;}float integrateFromBezierCurveFrames(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i+=2){vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);if(i==0&&time<k0.x){return ret;}vec2 p1=vec2(k0.x,k0.y);vec2 p2=vec2(k0.z,k0.w);vec2 p3=vec2(k1.z,k1.w);vec2 p4=vec2(k1.x,k1.y);if(time>=k1.x){ret+=calculateMovement(k1.x,p1,p2,p3,p4);}if(time>=k0.x&&time<k1.x){return ret+calculateMovement(time,p1,p2,p3,p4);}}return ret;}float integrateByTimeLineSeg(float t,vec2 p0,vec2 p1){float t0=p0.x;float t1=p1.x;float y0=p0.y;float y1=p1.y;vec4 tSqr=vec4(t,t,t0,t0);tSqr=tSqr*tSqr;vec4 a=vec4(2.*t,3.,-t0,3.)*tSqr;float t1y0=t1*y0;vec4 b=vec4(y0-y1,t0*y1-t1y0,2.*y0+y1,t1y0);float r=dot(a,b);return r/(t0-t1)*0.16666667;}float integrateLineSeg(float time,vec2 p0,vec2 p1){float h=time-p0.x;float y0=p0.y;return(y0+y0+(p1.y-y0)*h/(p1.x-p0.x))*h/2.;}float integrateFromLineSeg(float time,float frameStart,float frameCount){if(time==0.){return 0.;}int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i++){if(i>count){return ret;}vec4 ks=lookup_curve(i+start);vec2 k0=ks.xy;vec2 k1=ks.zw;if(time>k0.x&&time<=k1.x){return ret+integrateLineSeg(time,k0,k1);}ret+=integrateLineSeg(k1.x,k0,k1);vec2 k2=lookup_curve(i+start+1).xy;if(time>k1.x&&time<=k2.x){return ret+integrateLineSeg(time,k1,k2);}ret+=integrateLineSeg(k2.x,k1,k2);}return ret;}float integrateByTimeFromLineSeg(float time,float frameStart,float frameCount){if(time==0.){return 0.;}int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i++){if(i>count){return ret;}vec4 ks=lookup_curve(i+start);vec2 k0=ks.xy;vec2 k1=ks.zw;if(time>k0.x&&time<=k1.x){return ret+integrateByTimeLineSeg(time,k0,k1);}ret+=integrateByTimeLineSeg(k1.x,k0,k1);vec2 k2=lookup_curve(i+start+1).xy;if(time>k1.x&&time<=k2.x){return ret+integrateByTimeLineSeg(time,k1,k2);}ret+=integrateByTimeLineSeg(k2.x,k1,k2);}return ret;}float getIntegrateFromTime0(float t1,vec4 value){float type=value.x;if(type==0.){return value.y*t1;}if(type==1.){vec2 p0=vec2(0.,value.y);vec2 p1=vec2(value.w,value.z);return integrateLineSeg(t1,p0,p1);}if(type==3.){return integrateFromLineSeg(t1,value.y,value.z);}if(type==4.){return mix(value.y,value.z,aSeed)*t1;}if(type==5.){return integrateFromBezierCurveFrames(t1,value.z,value.w);}return 0.;}float getIntegrateByTimeFromTime(float t0,float t1,vec4 value){float type=value.x;if(type==0.){return value.y*(t1*t1-t0*t0)/2.;}else if(type==1.){vec2 p0=vec2(0.,value.y);vec2 p1=vec2(value.w,value.z);return integrateByTimeLineSeg(t1,p0,p1)-integrateByTimeLineSeg(t0,p0,p1);}if(type==3.){return integrateByTimeFromLineSeg(t1,value.y,value.z)-integrateByTimeFromLineSeg(t0,value.y,value.z);}if(type==4.){return mix(value.y,value.z,aSeed)*(t1*t1-t0*t0)/2.;}if(type==5.){return integrateFromBezierCurveFrames(t1,value.z,value.w)-integrateFromBezierCurveFrames(t0,value.z,value.w);}return 0.;}const float d2r=3.141592653589793/180.;attribute vec3 aPos;attribute vec4 aOffset;attribute vec4 aColor;attribute vec3 aDirX;attribute vec3 aDirY;attribute vec3 aTranslation;attribute vec3 aRotation0;attribute vec3 aRotation1;attribute vec3 aRotation2;attribute vec3 aLinearMove;\n#ifdef USE_SPRITE\nattribute vec3 aSprite;uniform vec4 uSprite;struct UVDetail{vec2 uv0;vec3 uv1;};UVDetail getSpriteUV(vec2 uv,float lifeTime);varying vec4 vTexCoordBlend;\n#endif\n#ifdef FINAL_TARGET\nuniform vec3 uFinalTarget;uniform vec4 uForceCurve;\n#endif\nuniform mat4 effects_ObjectToWorld;uniform mat4 effects_MatrixV;uniform mat4 effects_MatrixVP;uniform vec4 uParams;uniform vec4 uOpacityOverLifetimeValue;\n#ifdef COLOR_OVER_LIFETIME\nuniform sampler2D uColorOverLifetime;\n#endif\nuniform vec4 uOrbXByLifetimeValue;uniform vec4 uOrbYByLifetimeValue;uniform vec4 uOrbZByLifetimeValue;uniform vec3 uOrbCenter;uniform vec4 uSizeByLifetimeValue;\n#ifdef SIZE_Y_BY_LIFE\nuniform vec4 uSizeYByLifetimeValue;\n#endif\nvarying float vLife;varying vec4 vColor;varying vec2 vTexCoord;\n#ifdef ENV_EDITOR\nuniform vec4 uEditorTransform;\n#endif\nvec3 calOrbitalMov(float _life,float _dur){vec3 orb=vec3(0.0);\n#ifdef AS_ORBITAL_MOVEMENT\n#define FUNC(a) getValueFromTime(_life,a)\n#else\n#define FUNC(a) getIntegrateFromTime0(_life,a) * _dur\n#endif\n#if ORB_VEL_X\norb.x=FUNC(uOrbXByLifetimeValue);\n#endif\n#if ORB_VEL_Y\norb.y=FUNC(uOrbYByLifetimeValue);\n#endif\n#if ORB_VEL_Z\norb.z=FUNC(uOrbZByLifetimeValue);\n#endif\n#undef FUNC\nreturn orb;}mat3 mat3FromRotation(vec3 rotation){vec3 sinR=sin(rotation*d2r);vec3 cosR=cos(rotation*d2r);return mat3(cosR.z,-sinR.z,0.,sinR.z,cosR.z,0.,0.,0.,1.)*mat3(cosR.y,0.,sinR.y,0.,1.,0.,-sinR.y,0,cosR.y)*mat3(1.,0.,0.,0,cosR.x,-sinR.x,0.,sinR.x,cosR.x);}\n#ifdef USE_SPRITE\nUVDetail getSpriteUV(vec2 uv,float lifeTime){float t=fract(clamp((lifeTime-aSprite.x)/aSprite.y,0.0,1.)*aSprite.z);float frame=uSprite.z*t;float frameIndex=max(ceil(frame)-1.,0.);float row=floor((frameIndex+0.1)/uSprite.x);float col=frameIndex-row*uSprite.x;vec2 retUV=(vec2(col,row)+uv)/uSprite.xy;UVDetail ret;if(uSprite.w>0.){float blend=frame-frameIndex;float frameIndex1=min(ceil(frame),uSprite.z-1.);float row1=floor((frameIndex1+0.1)/uSprite.x);float col1=frameIndex1-row1*uSprite.x;vec2 coord=(vec2(col1,row1)+uv)/uSprite.xy-retUV;ret.uv1=vec3(coord.x,1.-coord.y,blend);}ret.uv0=vec2(retUV.x,1.-retUV.y);return ret;}\n#endif\nvoid main(){float time=uParams.x-aOffset.z;float dur=aOffset.w;if(time<0.||time>dur){gl_Position=vec4(-3.,-3.,-3.,1.);}else{float life=clamp(time/dur,0.0,1.0);vLife=life;\n#ifdef USE_SPRITE\nUVDetail uvD=getSpriteUV(aOffset.xy,time);vTexCoord=uvD.uv0;vTexCoordBlend=vec4(uvD.uv1,uSprite.w);\n#else\nvTexCoord=aOffset.xy;\n#endif\nvColor=aColor;\n#ifdef COLOR_OVER_LIFETIME\n#ifdef ENABLE_VERTEX_TEXTURE\nvColor*=texture2D(uColorOverLifetime,vec2(life,0.));\n#endif\n#endif\nvColor.a*=clamp(getValueFromTime(life,uOpacityOverLifetimeValue),0.,1.);vec3 size=vec3(vec2(getValueFromTime(life,uSizeByLifetimeValue)),1.0);\n#ifdef SIZE_Y_BY_LIFE\nsize.y=getValueFromTime(life,uSizeYByLifetimeValue);\n#endif\nmat3 aRotation=mat3(aRotation0,aRotation1,aRotation2);vec3 point=aRotation*(aDirX*size.x+aDirY*size.y);vec3 _pos=aPos+aTranslation;\n#if ORB_VEL_X + ORB_VEL_Y + ORB_VEL_Z\n_pos=mat3FromRotation(calOrbitalMov(life,dur))*(_pos-uOrbCenter);_pos+=uOrbCenter;\n#endif\n_pos.xyz+=aLinearMove;\n#ifdef FINAL_TARGET\nfloat force=getValueFromTime(life,uForceCurve);vec4 pos=vec4(mix(_pos,uFinalTarget,force),1.);\n#else\nvec4 pos=vec4(_pos,1.0);\n#endif\n#if RENDER_MODE == 1\npos.xyz+=point;pos=effects_ObjectToWorld*pos;\n#elif RENDER_MODE == 3\npos=effects_ObjectToWorld*pos;pos.xyz+=effects_MatrixV[0].xyz*point.x+effects_MatrixV[2].xyz*point.y;\n#elif RENDER_MODE == 2\npos=effects_ObjectToWorld*pos;pos.xy+=point.xy;\n#elif RENDER_MODE == 0\npos=effects_ObjectToWorld*pos;pos.xyz+=effects_MatrixV[0].xyz*point.x+effects_MatrixV[1].xyz*point.y;\n#endif\ngl_Position=effects_MatrixVP*pos;vSeed=aSeed;gl_PointSize=6.0;\n#ifdef ENV_EDITOR\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#endif\n}}",Jr="#version 100\nprecision mediump float;\n#define SHADER_VERTEX 1\n#ifdef SHADER_VERTEX\n#define CURVE_VALUE_TEXTURE uVCurveValueTexture\n#define CURVE_VALUE_ARRAY uVCurveValues\n#define CURVE_VALUE_COUNT VERT_CURVE_VALUE_COUNT\n#define FRAG_CURVE_VALUE_COUNT 0\n#else\n#define CURVE_VALUE_TEXTURE uFCurveValueTexture\n#define CURVE_VALUE_ARRAY uFCurveValues\n#define CURVE_VALUE_COUNT FRAG_CURVE_VALUE_COUNT\n#define VERT_CURVE_VALUE_COUNT 0\n#endif\n#if CURVE_VALUE_COUNT > 0\n#if LOOKUP_TEXTURE_CURVE\nuniform sampler2D CURVE_VALUE_TEXTURE;const float uCurveCount=1./float(CURVE_VALUE_COUNT);\n#define lookup_curve(i) texture2D(CURVE_VALUE_TEXTURE,vec2(float(i) * uCurveCount,0.))\n#else\nuniform vec4 CURVE_VALUE_ARRAY[CURVE_VALUE_COUNT];\n#define lookup_curve(i) CURVE_VALUE_ARRAY[i]\n#endif\n#else\n#define lookup_curve(i) vec4(0.)\n#endif\n#ifdef WEBGL2\n#define ITR_END (count + 1)\n#else\n#define ITR_END MAX_C\n#endif\n#define NONE_CONST_INDEX 1\n#ifdef SHADER_VERTEX\nattribute float aSeed;varying float vSeed;\n#endif\n#ifdef SHADER_VERTEX\n#define MAX_C VERT_MAX_KEY_FRAME_COUNT\n#else\n#define MAX_C FRAG_MAX_KEY_FRAME_COUNT\n#endif\nmat4 cubicBezierMatrix=mat4(1.0,-3.0,3.0,-1.0,0.0,3.0,-6.0,3.0,0.0,0.0,3.0,-3.0,0.0,0.0,0.0,1.0);float cubicBezier(float t,float y1,float y2,float y3,float y4){vec4 tVec=vec4(1.0,t,t*t,t*t*t);vec4 yVec=vec4(y1,y2,y3,y4);vec4 result=tVec*cubicBezierMatrix*yVec;return result.x+result.y+result.z+result.w;}float binarySearchT(float x,float x1,float x2,float x3,float x4){float left=0.0;float right=1.0;float mid=0.0;float computedX;for(int i=0;i<8;i++){mid=(left+right)*0.5;computedX=cubicBezier(mid,x1,x2,x3,x4);if(abs(computedX-x)<0.0001){break;}else if(computedX>x){right=mid;}else{left=mid;}}return mid;}float valueFromBezierCurveFrames(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);for(int i=0;i<ITR_END;i+=2){if(i>=count){break;}vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);if(i==0&&time<k0.x){return k0.y;}if(i==int(frameCount-2.)&&time>=k1.x){return k1.y;}if(time>=k0.x&&time<=k1.x){float t=(time-k0.x)/(k1.x-k0.x);float nt=binarySearchT(time,k0.x,k0.z,k1.z,k1.x);return cubicBezier(nt,k0.y,k0.w,k1.w,k1.y);}}}float evaluteLineSeg(float t,vec2 p0,vec2 p1){return p0.y+(p1.y-p0.y)*(t-p0.x)/(p1.x-p0.x);}float valueFromLineSegs(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);int end=start+count;for(int i=0;i<ITR_END;i++){if(i>count){return lookup_curve(i).w;}vec4 seg=lookup_curve(i+start);vec2 p0=seg.xy;vec2 p1=seg.zw;if(time>=p0.x&&time<=p1.x){return evaluteLineSeg(time,p0,p1);}vec2 p2=lookup_curve(i+start+1).xy;if(time>p1.x&&time<=p2.x){return evaluteLineSeg(time,p1,p2);}}return lookup_curve(0).y;}float getValueFromTime(float time,vec4 value){float type=value.x;if(type==0.){return value.y;}if(type==1.){return mix(value.y,value.z,time/value.w);}if(type==3.){return valueFromLineSegs(time,value.y,value.z);}if(type==4.){return mix(value.y,value.z,aSeed);}if(type==5.){return valueFromBezierCurveFrames(time,value.z,value.w);}return 0.;}attribute vec4 aPos;attribute vec3 aDir;attribute vec3 aInfo;attribute vec4 aColor;attribute float aTime;\n#ifdef ATTR_TRAIL_START\nattribute float aTrailStart;\n#else\nuniform float uTrailStart[64];attribute float aTrailStartIndex;\n#endif\nuniform mat4 effects_MatrixInvV;uniform mat4 effects_ObjectToWorld;uniform mat4 effects_MatrixVP;uniform vec4 uTextureMap;uniform float uTime;uniform vec4 uParams;uniform vec4 uColorParams;uniform vec4 uOpacityOverLifetimeValue;uniform vec4 uWidthOverTrail;\n#ifdef COLOR_OVER_TRAIL\nuniform sampler2D uColorOverTrail;\n#endif\n#ifdef COLOR_OVER_LIFETIME\nuniform sampler2D uColorOverLifetime;\n#endif\nvarying float vLife;varying vec2 vTexCoord;varying vec4 vColor;\n#ifdef ENV_EDITOR\nuniform vec4 uEditorTransform;\n#endif\nvoid main(){vec4 _pa=effects_MatrixVP*vec4(aPos.xyz,1.);vec4 _pb=effects_MatrixVP*vec4(aPos.xyz+aDir,1.);vec2 dir=normalize(_pb.xy/_pb.w-_pa.xy/_pa.w);vec2 screen_xy=vec2(-dir.y,dir.x);vec4 pos=effects_ObjectToWorld*vec4(aPos.xyz,1.);\n#ifdef ATTR_TRAIL_START\nfloat ts=aTrailStart;\n#else\nfloat ts=uTrailStart[int(aTrailStartIndex)];\n#endif\nfloat trail=(ts-aInfo.y)/uParams.y;float width=aPos.w*getValueFromTime(trail,uWidthOverTrail)/max(abs(screen_xy.x),abs(screen_xy.y));pos.xyz+=(effects_MatrixInvV[0].xyz*screen_xy.x+effects_MatrixInvV[1].xyz*screen_xy.y)*width;float time=min((uTime-aTime)/aInfo.x,1.0);gl_Position=effects_MatrixVP*pos;vColor=aColor;\n#ifdef COLOR_OVER_LIFETIME\n#ifdef ENABLE_VERTEX_TEXTURE\nvColor*=texture2D(uColorOverLifetime,vec2(time,0.));\n#endif\n#endif\n#ifdef COLOR_OVER_TRAIL\nvColor*=texture2D(uColorOverTrail,vec2(trail,0.));\n#endif\nvColor.a*=clamp(getValueFromTime(time,uOpacityOverLifetimeValue),0.,1.);vLife=time;vTexCoord=uTextureMap.xy+vec2(trail,aInfo.z)*uTextureMap.zw;vSeed=aSeed;\n#ifdef ENV_EDITOR\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#endif\n}",$r="#ifdef SHADER_VERTEX\n#define CURVE_VALUE_TEXTURE uVCurveValueTexture\n#define CURVE_VALUE_ARRAY uVCurveValues\n#define CURVE_VALUE_COUNT VERT_CURVE_VALUE_COUNT\n#define FRAG_CURVE_VALUE_COUNT 0\n#else\n#define CURVE_VALUE_TEXTURE uFCurveValueTexture\n#define CURVE_VALUE_ARRAY uFCurveValues\n#define CURVE_VALUE_COUNT FRAG_CURVE_VALUE_COUNT\n#define VERT_CURVE_VALUE_COUNT 0\n#endif\n#if CURVE_VALUE_COUNT > 0\n#if LOOKUP_TEXTURE_CURVE\nuniform sampler2D CURVE_VALUE_TEXTURE;const float uCurveCount=1./float(CURVE_VALUE_COUNT);\n#define lookup_curve(i) texture2D(CURVE_VALUE_TEXTURE,vec2(float(i) * uCurveCount,0.))\n#else\nuniform vec4 CURVE_VALUE_ARRAY[CURVE_VALUE_COUNT];\n#define lookup_curve(i) CURVE_VALUE_ARRAY[i]\n#endif\n#else\n#define lookup_curve(i) vec4(0.)\n#endif\n#ifdef WEBGL2\n#define ITR_END (count + 1)\n#else\n#define ITR_END MAX_C\n#endif\n#define NONE_CONST_INDEX 1\n#ifdef SHADER_VERTEX\nattribute float aSeed;varying float vSeed;\n#endif\n#ifdef SHADER_VERTEX\n#define MAX_C VERT_MAX_KEY_FRAME_COUNT\n#else\n#define MAX_C FRAG_MAX_KEY_FRAME_COUNT\n#endif\nmat4 cubicBezierMatrix=mat4(1.0,-3.0,3.0,-1.0,0.0,3.0,-6.0,3.0,0.0,0.0,3.0,-3.0,0.0,0.0,0.0,1.0);float cubicBezier(float t,float y1,float y2,float y3,float y4){vec4 tVec=vec4(1.0,t,t*t,t*t*t);vec4 yVec=vec4(y1,y2,y3,y4);vec4 result=tVec*cubicBezierMatrix*yVec;return result.x+result.y+result.z+result.w;}float binarySearchT(float x,float x1,float x2,float x3,float x4){float left=0.0;float right=1.0;float mid=0.0;float computedX;for(int i=0;i<8;i++){mid=(left+right)*0.5;computedX=cubicBezier(mid,x1,x2,x3,x4);if(abs(computedX-x)<0.0001){break;}else if(computedX>x){right=mid;}else{left=mid;}}return mid;}float valueFromBezierCurveFrames(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);for(int i=0;i<ITR_END;i+=2){if(i>=count){break;}vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);if(i==0&&time<k0.x){return k0.y;}if(i==int(frameCount-2.)&&time>=k1.x){return k1.y;}if(time>=k0.x&&time<=k1.x){float t=(time-k0.x)/(k1.x-k0.x);float nt=binarySearchT(time,k0.x,k0.z,k1.z,k1.x);return cubicBezier(nt,k0.y,k0.w,k1.w,k1.y);}}}float evaluteLineSeg(float t,vec2 p0,vec2 p1){return p0.y+(p1.y-p0.y)*(t-p0.x)/(p1.x-p0.x);}float valueFromLineSegs(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);int end=start+count;for(int i=0;i<ITR_END;i++){if(i>count){return lookup_curve(i).w;}vec4 seg=lookup_curve(i+start);vec2 p0=seg.xy;vec2 p1=seg.zw;if(time>=p0.x&&time<=p1.x){return evaluteLineSeg(time,p0,p1);}vec2 p2=lookup_curve(i+start+1).xy;if(time>p1.x&&time<=p2.x){return evaluteLineSeg(time,p1,p2);}}return lookup_curve(0).y;}float getValueFromTime(float time,vec4 value){float type=value.x;if(type==0.){return value.y;}if(type==1.){return mix(value.y,value.z,time/value.w);}if(type==3.){return valueFromLineSegs(time,value.y,value.z);}if(type==4.){return mix(value.y,value.z,aSeed);}if(type==5.){return valueFromBezierCurveFrames(time,value.z,value.w);}return 0.;}",tn="#ifdef SHADER_VERTEX\n#define CURVE_VALUE_TEXTURE uVCurveValueTexture\n#define CURVE_VALUE_ARRAY uVCurveValues\n#define CURVE_VALUE_COUNT VERT_CURVE_VALUE_COUNT\n#define FRAG_CURVE_VALUE_COUNT 0\n#else\n#define CURVE_VALUE_TEXTURE uFCurveValueTexture\n#define CURVE_VALUE_ARRAY uFCurveValues\n#define CURVE_VALUE_COUNT FRAG_CURVE_VALUE_COUNT\n#define VERT_CURVE_VALUE_COUNT 0\n#endif\n#if CURVE_VALUE_COUNT > 0\n#if LOOKUP_TEXTURE_CURVE\nuniform sampler2D CURVE_VALUE_TEXTURE;const float uCurveCount=1./float(CURVE_VALUE_COUNT);\n#define lookup_curve(i) texture2D(CURVE_VALUE_TEXTURE,vec2(float(i) * uCurveCount,0.))\n#else\nuniform vec4 CURVE_VALUE_ARRAY[CURVE_VALUE_COUNT];\n#define lookup_curve(i) CURVE_VALUE_ARRAY[i]\n#endif\n#else\n#define lookup_curve(i) vec4(0.)\n#endif\n#ifdef WEBGL2\n#define ITR_END (count + 1)\n#else\n#define ITR_END MAX_C\n#endif\n",en="precision highp float;attribute vec2 aPos;varying vec2 uv;void main(){gl_Position=vec4(aPos,0.,1.0);uv=(aPos+vec2(1.0))/2.;}",rn="precision highp float;\n#define HALF_MAX 60000.0\n#define ACEScc_MIDGRAY 0.4135884\nvarying vec2 uv;uniform sampler2D _GaussianTex;uniform sampler2D _SceneTex;uniform float _BloomIntensity;uniform float _Brightness;uniform float _Saturation;uniform float _Contrast;uniform bool _UseBloom;uniform bool _UseToneMapping;uniform vec3 _VignetteColor;uniform vec2 _VignetteCenter;uniform float _VignetteIntensity;uniform float _VignetteSmoothness;uniform float _VignetteRoundness;mat3 LinearToACES=mat3(0.59719,0.07600,0.02840,0.35458,0.90834,0.13383,0.04823,0.01566,0.83777);mat3 ACESToLinear=mat3(1.60475,-0.10208,-0.00327,-0.53108,1.10813,-0.07276,-0.07367,-0.00605,1.07602);float log10(float x){return log(x)/log(10.0);}vec3 log10(vec3 v){return vec3(log10(v.x),log10(v.y),log10(v.z));}vec3 LinearToLogC(vec3 x){return 0.244161*log10(5.555556*x+0.047996)+0.386036;}vec3 LogCToLinear(vec3 x){return(pow(vec3(10.0),(x-0.386036)/0.244161)-0.047996)/5.555556;}vec3 rrt_and_odt_fit(vec3 col){vec3 a=col*(col+0.0245786)-0.000090537;vec3 b=col*(0.983729*col+0.4329510)+0.238081;return a/b;}vec3 ACESToneMapping(vec3 col){vec3 aces=LinearToACES*col;aces=rrt_and_odt_fit(aces);col=ACESToLinear*aces;return col;}vec3 LinearToSrgb(vec3 c){return mix(1.055*pow(c,vec3(1./2.4))-0.055,12.92*c,step(c,vec3(0.0031308)));}vec3 GammaCorrection(vec3 c){return pow(c,vec3(1.0/2.2));}vec3 ApplyVignette(vec3 inputColor,vec2 uv,vec2 center,float intensity,float roundness,float smoothness,vec3 color){vec2 dist=abs(uv-center)*intensity;dist.x*=roundness;float vfactor=pow(clamp((1.0-dot(dist,dist)),0.0,1.0),smoothness);return inputColor*mix(color,vec3(1.0),vfactor);}void main(){vec4 hdrColor=texture2D(_SceneTex,uv);hdrColor.rgb=pow(hdrColor.rgb,vec3(2.2));vec3 finalColor=hdrColor.rgb;if(_UseBloom){vec4 bloomColor=texture2D(_GaussianTex,uv);bloomColor.rgb*=_BloomIntensity;finalColor+=bloomColor.rgb;}if(_VignetteIntensity>0.0){finalColor=ApplyVignette(finalColor,uv,_VignetteCenter,_VignetteIntensity,_VignetteRoundness,_VignetteSmoothness,_VignetteColor);}finalColor=finalColor*_Brightness;vec3 colorLog=LinearToLogC(finalColor);colorLog=(colorLog-ACEScc_MIDGRAY)*_Contrast+ACEScc_MIDGRAY;finalColor=LogCToLinear(colorLog);finalColor=max(finalColor,0.0);float luminance=0.2125*finalColor.r+0.7154*finalColor.g+0.0721*finalColor.b;vec3 luminanceColor=vec3(luminance,luminance,luminance);finalColor=(finalColor-luminanceColor)*_Saturation+luminanceColor;finalColor=max(finalColor,0.0);if(_UseToneMapping){finalColor=max(vec3(0.0),ACESToneMapping(finalColor));}float alpha=min(hdrColor.a,1.0);gl_FragColor=vec4(clamp(GammaCorrection(finalColor),0.0,1.0),alpha);}",nn="precision highp float;varying vec2 uv;uniform sampler2D _MainTex;uniform vec2 _TextureSize;float GaussWeight2D(float x,float y,float sigma){float PI=3.14159265358;float E=2.71828182846;float sigma_2=pow(sigma,2.0);float a=-(x*x+y*y)/(2.0*sigma_2);return pow(E,a)/(2.0*PI*sigma_2);}vec3 GaussNxN(sampler2D tex,vec2 uv,vec2 stride,float sigma){vec3 color=vec3(0.,0.,0.);const int r=5/2;float weight=0.0;for(int i=-r;i<=r;i++){for(int j=-r;j<=r;j++){float w=GaussWeight2D(float(i),float(j),sigma);vec2 coord=uv+vec2(i,j)*stride;color+=texture2D(tex,coord).rgb*w;weight+=w;}}color/=weight;return color;}void main(){vec4 mainColor=texture2D(_MainTex,uv);vec3 color=mainColor.rgb;color=GaussNxN(_MainTex,uv,1.0/_TextureSize,1.0);gl_FragColor=vec4(color,1.0);}",sn="precision highp float;varying vec2 uv;uniform sampler2D _MainTex;uniform vec2 _TextureSize;vec3 GaussH(sampler2D tex,vec2 uv){vec3 color=vec3(0.0);float offsets[9];offsets[0]=-4.0;offsets[1]=-3.0;offsets[2]=-2.0;offsets[3]=-1.0;offsets[4]=0.0;offsets[5]=1.0;offsets[6]=2.0;offsets[7]=3.0;offsets[8]=4.0;float weights[9];weights[0]=0.01621622;weights[1]=0.05405405;weights[2]=0.12162162;weights[3]=0.19459459;weights[4]=0.22702703;weights[5]=0.19459459;weights[6]=0.12162162;weights[7]=0.05405405;weights[8]=0.01621622;for(int i=0;i<9;i++){vec2 offset=vec2(offsets[i]*2.0*(1.0/_TextureSize.x),0);color+=texture2D(tex,uv+offset).rgb*weights[i];}return color;}void main(){vec3 color=GaussH(_MainTex,uv);gl_FragColor=vec4(color,1.0);}",an="precision highp float;varying vec2 uv;uniform sampler2D _MainTex;uniform vec2 _TextureSize;vec3 GaussV(sampler2D tex,vec2 uv){vec3 color=vec3(0.0);float offsets[5];offsets[0]=-3.23076923;offsets[1]=-1.38461538;offsets[2]=0.0;offsets[3]=1.38461538;offsets[4]=3.23076923;float weights[5];weights[0]=0.07027027;weights[1]=0.31621622;weights[2]=0.22702703;weights[3]=0.31621622;weights[4]=0.07027027;for(int i=0;i<5;i++){vec2 offset=vec2(0,offsets[i]*(1.0/_TextureSize.y));color+=texture2D(tex,uv+offset).rgb*weights[i];}return color;}void main(){vec3 color=GaussV(_MainTex,uv);gl_FragColor=vec4(color,1.0);}",on="precision highp float;varying vec2 uv;uniform sampler2D _MainTex;uniform sampler2D _GaussianDownTex;uniform vec2 _GaussianDownTextureSize;float GaussWeight2D(float x,float y,float sigma){float PI=3.14159265358;float E=2.71828182846;float sigma_2=pow(sigma,2.0);float a=-(x*x+y*y)/(2.0*sigma_2);return pow(E,a)/(2.0*PI*sigma_2);}vec3 GaussNxN(sampler2D tex,vec2 uv,vec2 stride,float sigma){vec3 color=vec3(0.,0.,0.);const int r=1;float weight=0.0;for(int i=-r;i<=r;i++){for(int j=-r;j<=r;j++){float w=GaussWeight2D(float(i),float(j),sigma);vec2 coord=uv+vec2(i,j)*stride;color+=texture2D(tex,coord).rgb*w;weight+=w;}}color/=weight;return color;}void main(){vec3 lowResColor=GaussNxN(_MainTex,uv,0.5/_GaussianDownTextureSize,1.0);vec3 highResColor=GaussNxN(_GaussianDownTex,uv,1.0/_GaussianDownTextureSize,1.0);vec3 color=mix(highResColor,lowResColor,0.7);gl_FragColor=vec4(color,1.0);}",un="precision highp float;varying vec2 uv;uniform sampler2D _MainTex;uniform float _Threshold;void main(){vec4 mainTex=texture2D(_MainTex,uv);mainTex.rgb=pow(mainTex.rgb,vec3(2.2));float brightness=max(mainTex.r,max(mainTex.g,mainTex.b));float w=max(0.0,brightness-_Threshold)/max(brightness,0.00001);mainTex.rgb*=w;mainTex.rgb*=mainTex.a;gl_FragColor=vec4(mainTex.rgb,1.0);}",hn={},cn=function(){function t(){}return t.registerInclude=function(t,e){hn[t]&&mt.warn('The "'+t+'" shader include already exist.'),hn[t]=e},t.unRegisterInclude=function(t){delete hn[t]},t.unRegisterAllIncludes=function(){Object.keys(hn).forEach((function(e){t.unRegisterInclude(e)}))},t.genFinalShaderCode=function(e){var i=e.level,r=e.shaderType,n=e.shader,s=e.macros,a=e.removeVersion,o=t.genMacroString(i,s),u=t.genShaderVersion(i),h=t.parseIncludes(n),c=t.isVersion300(h);return h=t.removeWebGLVersion(h),2!==i||c||(h=t.convertTo300(h,r===oi.fragment)),a?o+h:u+o+h},t.convertTo300=function(e,i){if(e=(e=(e=e.replace(/\bvarying\b/g,i?"in":"out")).replace(/\btexture(2D|Cube)\b/g,"texture")).replace(/#extension.+(GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g,""),i){if(e=(e=(e=e.replace(/\btexture(2D|Cube)LodEXT\b/g,"textureLod")).replace(/\btexture(2D|Cube)GradEXT\b/g,"textureGrad")).replace(/\bgl_FragDepthEXT\b/g,"gl_FragDepth"),!t.has300Output(e))if(/\bgl_FragData\[.+?\]/g.test(e)){var r=(e=e.replace(/\bgl_FragColor\b/g,"gl_FragData[0]")).match(/\bgl_FragData\[.+?\]/g);r&&(e=t.replaceMRTShader(e,r))}else e=(e=e.replace(/void\s+?main\s*\(/g,"out vec4 glFragColor;\nvoid main(")).replace(/\bgl_FragColor\b/g,"glFragColor")}else e=e.replace(/\battribute\b/g,"in");return e},t.parseIncludes=function(t,e){var i;for(void 0===e&&(e=/#include <(.+)>/gm);null!==(i=e.exec(t));){var r=i[1],n=hn[r];if(void 0===n)throw new Error("Can't find include shader name "+r);t=t.replace(i[0],n)}return t},t.genMacroString=function(t,e,i){void 0===i&&(i=!0);var r=[],n="WEBGL"+t;return r.push("#ifndef "+n),r.push("#define "+n),r.push("#endif"),i&&r.push("#define GE_RUNTIME"),e&&e.length&&e.forEach((function(t){var e=t[0],i=t[1];!0===i?r.push("#define "+e):Number.isFinite(i)&&r.push("#define "+e+" "+i)})),r.length?r.join("\n")+"\n":""},t.genShaderVersion=function(t){return 1===t?"#version 100\n":"#version 300 es\n"},t.isVersion300=function(t){var e=t.match(/#version\s+\b\d{3}\b\s*(es)?/);return(e?e[0]:"").includes("300")},t.removeWebGLVersion=function(t){var e=t.match(/#version\s+\b\d{3}\b\s*(es)?/);return e?t.replace(e[0],""):t},t.has300Output=function(t){return/\bout\s+(?:\w+\s+)?(?:vec4)\s+(?:\w+)\s*;/.test(t)},t.replaceMRTShader=function(t,e){for(var i=new Set,r="",n=0;n<e.length;n++){var s=e[n].match(/\bgl_FragData\[(.+?)\]/);s&&i.add(s[1])}return i.forEach((function(t){r+="layout(location="+t+") out vec4 fragOutColor"+t+";\n"})),r+="void main(",t=(t=t.replace(/\bgl_FragData\[(.+?)\]/g,"fragOutColor$1")).replace(/void\s+?main\s*\(/g,r)},t}(),ln=function(t){function e(e,i){var r,n=(r=t.call(this,e,i)||this).renderer.engine,s=Cr.create(n,{mode:fi.TRIANGLE_STRIP,attributes:{aPos:{type:fi.FLOAT,size:2,data:new Float32Array([-1,1,-1,-1,1,1,1,-1])}},drawCount:4}),a=cr.create(n,{shader:{vertex:en,fragment:un,glslVersion:ur.GLSL1}});return a.blending=!1,a.depthTest=!1,a.culling=!1,r.screenMesh=Dr.create(n,{geometry:s,material:a,priority:0}),r.priority=5e3,r}Qt(e,t);var i=e.prototype;return i.configure=function(t){this.mainTexture=t.getFramebuffer().getColorTextures()[0],this.sceneTextureHandle.texture=this.mainTexture,t.setFramebuffer(this.framebuffer)},i.execute=function(t){var e,i,r;t.clear({colorAction:Pr.clear,depthAction:Pr.clear,stencilAction:Pr.clear}),this.screenMesh.material.setTexture("_MainTex",this.mainTexture);var n=null!=(r=null==(i=t.renderingData.currentFrame.globalVolume)||null==(e=i.bloom)?void 0:e.threshold)?r:1;this.screenMesh.material.setFloat("_Threshold",n),t.renderMeshes([this.screenMesh])},e}(Xr),fn=function(t){function e(e,i,r){var n;(n=t.call(this,e,r)||this).type=i;var s=n.renderer.engine,a="PostProcess",o=Cr.create(s,{name:a,mode:fi.TRIANGLE_STRIP,attributes:{aPos:{type:fi.FLOAT,size:2,data:new Float32Array([-1,1,-1,-1,1,1,1,-1])}},drawCount:4}),u={vertex:en,fragment:"H"==i?sn:an,glslVersion:ur.GLSL1},h=cr.create(s,{name:a,shader:u});return h.blending=!1,h.depthTest=!1,h.culling=!1,n.screenMesh=Dr.create(s,{name:a,geometry:o,material:h,priority:0}),n.priority=5e3,n}Qt(e,t);var i=e.prototype;return i.configure=function(t){this.mainTexture=t.getFramebuffer().getColorTextures()[0],t.setFramebuffer(this.framebuffer)},i.execute=function(t){t.clear({colorAction:Pr.clear,depthAction:Pr.clear,stencilAction:Pr.clear}),this.screenMesh.material.setTexture("_MainTex",this.mainTexture),this.screenMesh.material.setVector2("_TextureSize",gn(this.mainTexture)),t.renderMeshes([this.screenMesh]),"V"===this.type&&(this.gaussianResult.texture=t.getFramebuffer().getColorTextures()[0])},e}(Xr),dn=function(t){function e(e,i){var r,n="PostProcess",s=(r=t.call(this,e,i)||this).renderer.engine,a=Cr.create(s,{name:n,mode:fi.TRIANGLE_STRIP,attributes:{aPos:{type:fi.FLOAT,size:2,data:new Float32Array([-1,1,-1,-1,1,1,1,-1])}},drawCount:4}),o={vertex:en,fragment:on},u=cr.create(s,{name:n,shader:o});return u.blending=!1,u.depthTest=!1,u.culling=!1,r.screenMesh=Dr.create(s,{name:n,geometry:a,material:u,priority:0}),r.priority=5e3,r}Qt(e,t);var i=e.prototype;return i.configure=function(t){this.mainTexture=t.getFramebuffer().getColorTextures()[0],t.setFramebuffer(this.framebuffer)},i.execute=function(t){t.clear({colorAction:Pr.clear,depthAction:Pr.clear,stencilAction:Pr.clear}),this.screenMesh.material.setTexture("_MainTex",this.mainTexture),this.screenMesh.material.setTexture("_GaussianDownTex",this.gaussianDownSampleResult.texture),this.screenMesh.material.setVector2("_GaussianDownTextureSize",gn(this.gaussianDownSampleResult.texture)),t.renderMeshes([this.screenMesh])},e}(Xr),pn=function(t){function e(e,i){var r,n="PostProcess",s=(r=t.call(this,e,{})||this).renderer.engine;r.sceneTextureHandle=i||new Gr(s);var a=Cr.create(s,{name:n,mode:fi.TRIANGLE_STRIP,attributes:{aPos:{type:fi.FLOAT,size:2,data:new Float32Array([-1,1,-1,-1,1,1,1,-1])}},drawCount:4}),o=cr.create(s,{name:n,shader:{vertex:en,fragment:rn,glslVersion:ur.GLSL1}});return o.blending=!1,o.depthTest=!1,o.culling=!1,r.screenMesh=Dr.create(s,{name:n,geometry:a,material:o,priority:0}),r.priority=5e3,r}Qt(e,t);var i=e.prototype;return i.configure=function(t){this.mainTexture=t.getFramebuffer().getColorTextures()[0],this.sceneTextureHandle.texture||(this.sceneTextureHandle.texture=this.mainTexture),t.setFramebuffer(null)},i.execute=function(t){t.clear({colorAction:Pr.clear,depthAction:Pr.clear,stencilAction:Pr.clear});var e=t.renderingData.currentFrame.globalVolume,i=_i({threshold:0,intensity:0,active:!1},null==e?void 0:e.bloom),r=_i({intensity:0,smoothness:0,roundness:0,active:!1},null==e?void 0:e.vignette),n=_i({brightness:0,saturation:0,contrast:0,active:!1},null==e?void 0:e.colorAdjustments),s=_i({active:!1},null==e?void 0:e.tonemapping);this.screenMesh.material.setTexture("_SceneTex",this.sceneTextureHandle.texture),this.screenMesh.material.setFloat("_Brightness",Math.pow(2,n.brightness)),this.screenMesh.material.setFloat("_Saturation",.01*n.saturation+1),this.screenMesh.material.setFloat("_Contrast",.01*n.contrast+1),this.screenMesh.material.setInt("_UseBloom",Number(i.active)),i.active&&(this.screenMesh.material.setTexture("_GaussianTex",this.mainTexture),this.screenMesh.material.setFloat("_BloomIntensity",i.intensity)),r.intensity>0&&(this.screenMesh.material.setFloat("_VignetteIntensity",r.intensity),this.screenMesh.material.setFloat("_VignetteSmoothness",r.smoothness),this.screenMesh.material.setFloat("_VignetteRoundness",r.roundness),this.screenMesh.material.setVector2("_VignetteCenter",new Ke(.5,.5)),this.screenMesh.material.setVector3("_VignetteColor",new Qe(0,0,0))),this.screenMesh.material.setInt("_UseToneMapping",Number(s.active)),t.renderMeshes([this.screenMesh])},e}(Xr),mn="_effects_default_",vn=1,yn=function(){function t(t){var e;this.renderQueue=[],this.destroyed=!1,this.renderPassInfoMap=new WeakMap;var i=t.camera,r=t.keepColorBuffer,n=t.renderer,s=t.editorTransform,a=void 0===s?[1,1,0,0]:s,o=t.globalVolume,u=t.postProcessingEnabled,h=void 0!==u&&u,c=t.clearAction,l=void 0===c?{colorAction:hi.whatever,stencilAction:hi.clear,depthAction:hi.whatever}:c,f=n.engine;o&&(this.globalVolume=o),this.globalUniforms=new wn;var d,p=[],m={};if(this.renderer=n,h){if(!this.renderer.engine.gpuCapability.detail.halfFloatTexture)throw new Error("Half float texture is not supported.");var v=fi.HALF_FLOAT;p=[{texture:{format:fi.RGBA,type:v,magFilter:fi.LINEAR,minFilter:fi.LINEAR}}],d={storageType:Ir.depth_stencil_opaque},m={colorAction:hi.clear,stencilAction:hi.clear,depthAction:hi.clear}}this.drawObjectPass=new Xr(n,{name:mn,priority:zr,meshOrder:F.ascending,depthStencilAttachment:d,attachments:p,clearAction:m});var y=[this.drawObjectPass];if(this.setRenderPasses(y),h){var g=new Gr(f),x=[0,0,this.renderer.getWidth()/2,this.renderer.getHeight()/2],b=new Array(7),T=fi.HALF_FLOAT,E=new ln(n,{name:"BloomThresholdPass",attachments:[{texture:{format:fi.RGBA,type:T,minFilter:fi.LINEAR,magFilter:fi.LINEAR}}]});E.sceneTextureHandle=g,this.addRenderPass(E);for(var _=0;_<7;_++){b[_]=new Gr(f);var w=new fn(n,"H",{name:"GaussianDownPassH"+_,viewport:x,attachments:[{texture:{format:fi.RGBA,type:T,minFilter:fi.LINEAR,magFilter:fi.LINEAR}}]}),A=new fn(n,"V",{name:"GaussianDownPassV"+_,viewport:x,attachments:[{texture:{format:fi.RGBA,type:T,minFilter:fi.LINEAR,magFilter:fi.LINEAR}}]});A.gaussianResult=b[_],this.addRenderPass(w),this.addRenderPass(A),x[2]/=2,x[3]/=2}x[2]*=4,x[3]*=4;for(var C=0;C<6;C++){var S=new dn(n,{name:"GaussianUpPass"+C,viewport:x,attachments:[{texture:{format:fi.RGBA,type:T,minFilter:fi.LINEAR,magFilter:fi.LINEAR}}]});S.gaussianDownSampleResult=b[5-C],this.addRenderPass(S),x[2]*=2,x[3]*=2}var O=new pn(n,g);this.addRenderPass(O)}this.semantics=new wr(t.semantics),this.clearAction=l,this.name="RenderFrame"+vn++;var R=y[0];this.emptyTexture=qi(f),this.transparentTexture=Ki(f),this.camera=i,this.keepColorBuffer=r,this.renderPassInfoMap.set(R,{listStart:0,listEnd:0,renderPass:R,intermedia:!1}),this.editorTransform=Je.fromArray(a),t.clearAction||this.resetClearActions(),this.passTextureCache=new _r(f);var M=f.gpuCapability,I=M.detail,P=gr(M.level,I.readableDepthStencilTextures&&I.writableFragDepth);null==(e=this.renderer.getShaderLibrary())||e.addShader(P)}var e=t.prototype;return e.addMeshToDefaultRenderPass=function(t){this.drawObjectPass.addMesh(t)},e.removeMeshFromDefaultRenderPass=function(t){this.drawObjectPass.removeMesh(t)},e.dispose=function(t){(null==t?void 0:t.semantics)!==pt.keep&&this.semantics.dispose();var e,i,r=(null==t?void 0:t.passes)?t.passes:void 0;(r!==pt.keep&&this._renderPasses.forEach((function(t){t.dispose(r)})),this.passTextureCache.dispose(),this._renderPasses.length=0,this.emptyTexture.dispose(),this.transparentTexture.dispose(),this.resource)&&(this.resource.color_a.dispose(),this.resource.color_b.dispose(),null==(i=this.resource.depthStencil)||null==(e=i.texture)||e.dispose(),this.resource.finalCopyRP.dispose(),this.resource.resRP.dispose(),this.resource=null);this.destroyed=!0},e.resetRenderPassDefaultAttachment=function(t,e){for(var i,r=this.resource,n=r.color_a,s=r.color_b,a=e;a<t.length;a++){var o,u,h=t[a],c=null==(o=h.attachments[0])?void 0:o.texture;if(c&&i===c){var l=c===n?s:n;h.resetColorAttachments([l])}(c=null==(u=h.attachments[0])?void 0:u.texture)&&(i=c)}},e.findMeshRenderPassIndex=function(t){var e=-1;return this.renderPasses.every((function(i,r){return!i.name.startsWith(mn)||!i.meshes.includes(t)||(e=r,!1)})),e},e.addToRenderPass=function(t,e){var i=this.renderPassInfoMap.get(t),r=e.priority;i&&(0===t.meshes.length?i.listStart=i.listEnd=r:r<i.listStart?i.listStart=r:r>i.listEnd&&(i.listEnd=r),t.addMesh(e))},e.getRPAttachments=function(t,e){if(1===(null==t?void 0:t.length)){var i,r=t[0],n=r.texture,s=r.persistent,a=n.format,o=null!=(i=null==e?void 0:e.getInitAttachments())?i:[];if(a===fi.RGBA&&!s){var u=this.resource.color_a;return 0===o.length?[{texture:u}]:[{texture:o[0].texture===u?this.resource.color_b:u}]}}return t},e.resetClearActions=function(){var t=this.renderPasses.length>1?hi.clear:hi.whatever;this.clearAction.stencilAction=t,this.clearAction.depthAction=t,this.clearAction.colorAction=t,this.keepColorBuffer&&(this.clearAction.colorAction=hi.whatever)},e.setRenderPasses=function(t){var e=this;void 0!==this.renderer&&t.forEach((function(t){return t.initialize(e.renderer)})),this._renderPasses=t.slice()},e.addRenderPass=function(t){void 0!==this.renderer&&t.initialize(this.renderer),this._renderPasses.push(t)},e.createResource=function(){var t=this.renderer.engine;if(!this.resource){var e,i=t.gpuCapability,r=i.detail,n=i.level,s=this.renderer.getWidth(),a=this.renderer.getHeight(),o=2===n?fi.LINEAR:fi.NEAREST,u=Yi.create(t,{sourceType:ci.framebuffer,format:fi.RGBA,name:"frame_a",minFilter:o,magFilter:o}),h=Yi.create(t,{sourceType:ci.framebuffer,format:fi.RGBA,data:{width:s,height:a},minFilter:o,magFilter:o,name:"frame_b"}),c=r.readableDepthStencilTextures&&r.writableFragDepth?Ir.depth_24_stencil_8_texture:Ir.depth_stencil_opaque,l=new Xr(this.renderer,{depthStencilAttachment:{storageType:c},attachments:[{texture:u}]}).initialize(this.renderer),f=new _n(this.renderer,{name:"effects-final-copy",priority:1600,clearAction:{depthAction:hi.clear,stencilAction:hi.clear,colorAction:hi.clear},meshOrder:F.ascending,meshes:[this.createCopyMesh({blend:!0,depthTexture:null==(e=l.getDepthAttachment())?void 0:e.texture})]});this.resource={color_a:l.attachments[0].texture,color_b:h,finalCopyRP:f,depthStencil:l.depthAttachment,resRP:l}}},e.createCopyMesh=function(t){var e,i=pr,r=this.renderer.engine,n=Cr.create(r,{name:i,mode:fi.TRIANGLE_STRIP,attributes:{aPos:{type:fi.FLOAT,size:2,data:new Float32Array([-1,1,-1,-1,1,1,1,-1])}},drawCount:4}),s=gr(r.gpuCapability.level,!!(null==t?void 0:t.depthTexture));null==(e=this.renderer.getShaderLibrary())||e.addShader(s);var a=cr.create(r,{uniformValues:{uDepth:null==t?void 0:t.depthTexture},name:i,shader:s});return a.blending=!1,a.depthTest=!1,a.culling=!1,(null==t?void 0:t.blend)&&(a.blending=!0,a.blendFunction=[fi.SRC_ALPHA,fi.ONE_MINUS_SRC_ALPHA,fi.SRC_ALPHA,fi.ONE_MINUS_SRC_ALPHA]),Dr.create(r,{name:i,geometry:n,material:a,priority:0})},e.removeRenderPass=function(t){k(this._renderPasses,t)},Pe(t,[{key:"renderPasses",get:function(){return this._renderPasses.slice()}},{key:"isDestroyed",get:function(){return this.destroyed}}]),t}();function gn(t){return t?new Ke(t.getWidth(),t.getHeight()):new Ke}function xn(t,e){var i=t.indexOf(e);return t[i-1]}var bn,Tn,En,_n=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.configure=function(t){var e=t.getFramebuffer();e&&(this.prePassTexture=e.getColorTextures()[0]),t.setFramebuffer(null)},i.execute=function(t){t.clear(this.clearAction),this.meshes[0].material.setTexture("uFilterSource",this.prePassTexture),this.meshes[0].material.setVector2("uFilterSourceSize",gn(this.prePassTexture)),t.renderMeshes(this.meshes),this.storeAction&&t.clear(this.storeAction)},e}(Xr),wn=function(){this.floats={},this.ints={},this.vector3s={},this.vector4s={},this.matrices={},this.samplers=[],this.uniforms=[]},An=function(){function t(t){this.size=[0,0],this.multiSample=1,this.destroyed=!1;var e=t.storageType,i=t.format,r=t.attachment;this.storageType=e,this.format=i,this.attachment=r}return Pe(t,[{key:"isDestroyed",get:function(){return this.destroyed}}]),t}(),Cn="function"==typeof o,Sn=function(){function t(t){this.setupCapability(t)}var e=t.prototype;return e.setupCapability=function(t){var e,i=Cn&&A(t,o)?2:1,r=2===i,n=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),s=t.getExtension("WEBGL_depth_texture"),a=!!t.getExtension("OES_texture_half_float_linear"),u=!!t.getExtension("OES_texture_float_linear");this.level=i,this.type=r?"webgl2":"webgl",this.vaoExt=t.getExtension("OES_vertex_array_object"),this.glAsyncCompileExt=t.getExtension("KHR_parallel_shader_compile"),this.UNSIGNED_INT_24_8=t.UNSIGNED_INT_24_8,this.drawBufferExtension=t.getExtension("WEBGL_draw_buffers"),s&&(this.UNSIGNED_INT_24_8=s.UNSIGNED_INT_24_8_WEBGL),r&&!a&&(a=On(t,t.HALF_FLOAT)),r&&!u&&(u=On(t,t.FLOAT)),this.internalFormatDepth16=r?t.DEPTH_COMPONENT16:t.DEPTH_COMPONENT,this.internalFormatDepth24_stencil8=r?t.DEPTH24_STENCIL8:t.DEPTH_STENCIL;var h=r||t.getExtension("OES_texture_float")?t.FLOAT:0,c=r?o.HALF_FLOAT:(null==(e=t.getExtension("OES_texture_half_float"))?void 0:e.HALF_FLOAT_OES)||0,l={floatTexture:h,halfFloatTexture:c,maxSample:r?t.getParameter(t.MAX_SAMPLES):1,maxVertexUniforms:t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),maxVertexTextures:t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxFragmentUniforms:t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),maxFragmentTextures:t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),floatColorAttachment:r?!!t.getExtension("EXT_color_buffer_float"):h>0&&!!t.getExtension("WEBGL_color_buffer_float"),halfFloatColorAttachment:r?!!t.getExtension("EXT_color_buffer_float"):c>0&&!!t.getExtension("EXT_color_buffer_half_float"),maxTextureSize:t.getParameter(t.MAX_TEXTURE_SIZE),maxShaderTexCount:t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS),compressedTexture:Rn(t),halfFloatLinear:a,floatLinear:u,maxTextureAnisotropy:n?t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0,shaderTextureLod:r||!!t.getExtension("EXT_shader_texture_lod"),instanceDraw:r||!!t.getExtension("ANGLE_instanced_arrays"),drawBuffers:r||!!this.drawBufferExtension,asyncShaderCompile:!!this.glAsyncCompileExt,intIndexElementBuffer:!!t.getExtension("OES_element_index_uint"),standardDerivatives:r||!!t.getExtension("OES_standard_derivatives"),readableDepthStencilTextures:r||!!s,writableFragDepth:r||!!t.getExtension("EXT_frag_depth")};this.detail=l,n&&(this.textureMaxAnisotropyExt=n.TEXTURE_MAX_ANISOTROPY_EXT)},e.framebufferTexture2D=function(t,e,i,r,n){var s=this.drawBufferExtension;if(1===this.level&&!s&&i>0)throw new Error("Draw multiple color buffers not available.");var a=s?s["COLOR_ATTACHMENT"+i+"_WEBGL"]:t["COLOR_ATTACHMENT"+i];a?t.framebufferTexture2D(e,a,r,n,0):console.error("Invalid color attachment index: "+i+".")},e.drawBuffers=function(t,e){var i=this.drawBufferExtension;if(1!==this.level||i){var r=e.map((function(e,r){return e?i?i["COLOR_ATTACHMENT"+r+"_WEBGL"]:t["COLOR_ATTACHMENT"+r]:t.NONE}));i?i.drawBuffersWEBGL(r):t.drawBuffers(r)}else if(e.length>1)throw new Error("Draw buffers not available.")},e.setTextureAnisotropic=function(t,e,i){var r=this.detail.maxTextureAnisotropy;r&&t.texParameterf(e,this.textureMaxAnisotropyExt,Math.min(r,i||4))},t}();function On(t,e){var i=t.createTexture(),r=!1;return t.getError(),t.bindTexture(t.TEXTURE_2D,i),t.texImage2D(t.TEXTURE_2D,0,t.R16F,1,1,0,t.RED,e,null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.getError()||(r=!0),t.deleteTexture(i),r}function Rn(t){return t.getExtension("WEBGL_compressed_texture_astc")?2:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc")?1:0}!function(t){t[t.NONE=0]="NONE",t[t.PVRTC=1]="PVRTC",t[t.ASTC=2]="ASTC"}(bn||(bn={})),function(t){t[t.Nearest=0]="Nearest",t[t.Linear=1]="Linear"}(Tn||(Tn={})),function(t){t[t.RGBA32=0]="RGBA32",t[t.RGBAHalf=1]="RGBAHalf"}(En||(En={}));var Mn=function(){function t(){}var e=t.prototype;return e.resize=function(t,e,i,r){},e.resetColorTextures=function(t){},e.unbind=function(){},e.bind=function(){},e.getDepthTexture=function(){},e.getStencilTexture=function(){},e.getColorTextures=function(){return[]},e.dispose=function(t){},Pe(t,[{key:"stencilStorage",get:function(){}},{key:"depthStorage",get:function(){}}]),t}(),In=function(){function t(){}var e=t.prototype;return e.setGlobalFloat=function(t,e){},e.setGlobalInt=function(t,e){},e.setGlobalVector4=function(t,e){},e.setGlobalVector3=function(t,e){},e.setGlobalMatrix=function(t,e){},e.getFramebuffer=function(){return null},e.setFramebuffer=function(t){},e.setViewport=function(t,e,i,r){},e.resize=function(t,e){},e.clear=function(t){},e.getWidth=function(){return 0},e.getHeight=function(){return 0},e.addLostHandler=function(t){},e.addRestoreHandler=function(t){},e.lost=function(t){},e.restore=function(){},e.getShaderLibrary=function(){},e.renderRenderFrame=function(t){},e.renderMeshes=function(t){},e.drawGeometry=function(t,e,i){},e.getTemporaryRT=function(t,e,i,r,n,s){return null},e.dispose=function(t){},t}(),Pn=function(){function t(t){var e=this;Object.keys(t).forEach((function(i){e[i]=t[i]}))}return t.prototype.generate=function(t){var e=Ln(this.arc,this.arcMode,t)*Xe,i=Math.cos(e)*this.radius,r=Math.sin(e)*this.radius,n=new Qe(i,r,0),s=Math.tan(this.angle*Xe),a=n.clone().multiply(s);return a.z+=1,{position:n.multiply(Et(0,1)),direction:a.normalize()}},t}();function Ln(t,e,i){if(e===re.RANDOM)t=Et(0,t);else if(e===re.UNIDIRECTIONAL_CYCLE){var r=i.index%(i.total+1);t=t/i.total*r}else if(e===re.BIDIRECTIONAL_CYCLE){var n=i.index/(i.total+1),s=n-Math.floor(n);t*=Math.floor(n)%2?1-s:s}else e===re.UNIFORM_BURST&&(t=t*i.burstIndex/i.burstCount);return t}var Fn,Vn=function(){function t(t){var e=this;Object.keys(t).forEach((function(i){e[i]=t[i]}))}return t.prototype.generate=function(t){var e=Ln(this.arc,this.arcMode,t)*Xe,i=new Qe(Math.cos(e),Math.sin(e),0),r=this.radius;return{direction:i,position:i.clone().multiply(r)}},t}(),Nn=function(){function t(t){this._d=(t.width||1)/2,this._h=(t.height||1)/2}return t.prototype.generate=function(t){var e=Et(-this._d,this._d),i=Et(-this._h,this._h);return{direction:new Qe(0,0,1),position:new Qe(e,i,0)}},t}(),Dn=function(){function t(t){this._d=(t.width||1)/2,this._h=(t.height||1)/2,this.arcMode=t.arcMode,this.arc=t.arc}return t.prototype.generate=function(t){var e=Ln(this.arc,this.arcMode,t)*Xe,i=new Qe(Math.cos(e),Math.sin(e),0),r=this._d,n=this._h,s=Math.atan2(n,r),a=Math.tan(e),o=new Qe;return e<s?o.set(r,r*a,0):e>=s&&e<Math.PI-s?o.set(n/a,n,0):e<Math.PI+s?o.set(-r,-r*a,0):e<2*Math.PI-s?o.set(-n/a,-n,0):o.set(r,r*a,0),{direction:i,position:o}},t}(),kn=function(){function t(t){this._d=t.width||1,this.arcMode=t.arcMode}return t.prototype.generate=function(t){var e=this.arcMode===re.UNIFORM_BURST?t.burstIndex%t.burstCount/(t.burstCount-1):Et(0,1);return{direction:new Qe(0,1,0),position:new Qe(this._d*(e-.5),0,0)}},t}(),zn=new ni,Un=function(){function t(t){var e=this;Object.keys(t).forEach((function(i){e[i]=t[i]}))}return t.prototype.generate=function(t){var e=this.donutRadius,i=this.radius-e,r=Et(0,2*Math.PI),n=Ln(this.arc,this.arcMode,t)*Xe,s=zn.setFromRotationZ(n),a=new Qe(Math.cos(r),Math.sin(r),0),o=new Qe(i+Math.cos(r)*e,0,Math.sin(r)*e);return{direction:s.transformNormal(a),position:s.transformPoint(o)}},t}(),Bn=new ni,Gn=function(){function t(t){var e=this;Object.keys(t).forEach((function(i){e[i]=t[i]}))}var e=t.prototype;return e.getHorizontalAngle=function(){return Et(-90,90)},e.generate=function(t){var e=Ln(this.arc,this.arcMode,t)*Xe,i=this.getHorizontalAngle()*Xe,r=this.radius,n=new Qe(Math.cos(i),0,Math.sin(i)),s=Bn.setFromRotationZ(e).transformNormal(n);return{position:s.clone().multiply(r),direction:s}},t}(),jn=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.getHorizontalAngle=function(){return Et(0,90)},e}(Gn),Xn=function(){function t(t){var e=t.detail||{anchors:[.5,.5],block:[0,0]};this.anchors=new Float32Array(e.anchors),this.width=t.width||1,this.height=t.height||1,this.block=e.block,this.arcMode=t.arcMode,this.random=qe(t.random||0,0,1)}return t.prototype.generate=function(t){var e=this.anchors,i=e.length/2-1,r=Math.floor(Ln(i,this.arcMode,t)),n=(e[2*r]+this.block[0]*this.random*Math.random())%1-.5,s=(e[2*r+1]+this.block[1]*this.random*Math.random())%1-.5,a=new Qe(n,s,0);return{position:new Qe(n*this.width,s*this.height,0),direction:a.normalize()}},t}(),Hn=function(){function t(){}return t.prototype.generate=function(){return{position:new Qe,direction:new Qe}},t}(),Yn=((Fn={})[Ut.NONE]=Hn,Fn[Ut.CONE]=Pn,Fn[Ut.SPHERE]=Gn,Fn[Ut.HEMISPHERE]=jn,Fn[Ut.CIRCLE]=Vn,Fn[Ut.DONUT]=Un,Fn[Ut.RECTANGLE]=Nn,Fn[Ut.EDGE]=kn,Fn[Ut.RECTANGLE_EDGE]=Dn,Fn[Ut.TEXTURE]=Xn,Fn);function Wn(t){if(!t)return new Hn;var e=_i({radius:1,arc:360,angle:0,arcMode:re.RANDOM},t),i=t.type,r=Yn[i];if(!r)throw new Error("Invalid shape: "+i+".");var n=new r(e);if(i!==Ut.NONE){var s=t.alignSpeedDirection,a=t.upDirection,o=void 0===a?[0,0,1]:a;n.alignSpeedDirection=s,n.upDirection=Qe.fromArray(o).normalize()}return n}function Zn(t,e,i,r,n){var s,a;if(n===function(t,e,i,r){for(var n=0,s=e,a=i-r;s<i;s+=r)n+=(t[a]-t[s])*(t[s+1]+t[a+1]),a=s;return n}(t,e,i,r)>0)for(s=e;s<i;s+=r)a=fs(s,t[s],t[s+1],a);else for(s=i-r;s>=e;s-=r)a=fs(s,t[s],t[s+1],a);return a&&as(a,a.next)&&(ds(a),a=a.next),a}function qn(t,e){if(!t)return t;e||(e=t);var i,r=t;do{if(i=!1,r.steiner||!as(r,r.next)&&0!==ss(r.prev,r,r.next))r=r.next;else{if(ds(r),(r=e=r.prev)===r.next)break;i=!0}}while(i||r!==e);return e}function Kn(t){var e=t.prev,i=t,r=t.next;if(ss(e,i,r)>=0)return!1;for(var n=t.next.next;n!==t.prev;){if(rs(e.x,e.y,i.x,i.y,r.x,r.y,n.x,n.y)&&ss(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function Qn(t,e,i,r){var n=t.prev,s=t,a=t.next;if(ss(n,s,a)>=0)return!1;for(var o=n.x<s.x?n.x<a.x?n.x:a.x:s.x<a.x?s.x:a.x,u=n.y<s.y?n.y<a.y?n.y:a.y:s.y<a.y?s.y:a.y,h=n.x>s.x?n.x>a.x?n.x:a.x:s.x>a.x?s.x:a.x,c=n.y>s.y?n.y>a.y?n.y:a.y:s.y>a.y?s.y:a.y,l=es(o,u,e,i,r),f=es(h,c,e,i,r),d=t.prevZ,p=t.nextZ;d&&d.z>=l&&p&&p.z<=f;){if(d!==t.prev&&d!==t.next&&rs(n.x,n.y,s.x,s.y,a.x,a.y,d.x,d.y)&&ss(d.prev,d,d.next)>=0)return!1;if(d=d.prevZ,p!==t.prev&&p!==t.next&&rs(n.x,n.y,s.x,s.y,a.x,a.y,p.x,p.y)&&ss(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;d&&d.z>=l;){if(d!==t.prev&&d!==t.next&&rs(n.x,n.y,s.x,s.y,a.x,a.y,d.x,d.y)&&ss(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;p&&p.z<=f;){if(p!==t.prev&&p!==t.next&&rs(n.x,n.y,s.x,s.y,a.x,a.y,p.x,p.y)&&ss(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function Jn(t,e){return t.x-e.x}function $n(t,e){if(e=function(t,e){var i,r=e,n=t.x,s=t.y,a=-1/0;do{if(s<=r.y&&s>=r.next.y&&r.next.y!==r.y){var o=r.x+(s-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(o<=n&&o>a){if(a=o,o===n){if(s===r.y)return r;if(s===r.next.y)return r.next}i=r.x<r.next.x?r:r.next}}r=r.next}while(r!==e);if(!i)return null;if(n===a)return i;var u,h=i,c=i.x,l=i.y,f=1/0;r=i;do{n>=r.x&&r.x>=c&&n!==r.x&&rs(s<l?n:a,s,c,l,s<l?a:n,s,r.x,r.y)&&(u=Math.abs(s-r.y)/(n-r.x),cs(r,t)&&(u<f||u===f&&(r.x>i.x||r.x===i.x&&ts(i,r)))&&(i=r,f=u)),r=r.next}while(r!==h);return i}(t,e),e){var i=ls(e,t);qn(e,e.next),qn(i,i.next)}}function ts(t,e){return ss(t.prev,t,e.prev)<0&&ss(e.next,t,t.next)<0}function es(t,e,i,r,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*n)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*n)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function is(t){var e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function rs(t,e,i,r,n,s,a,o){return(n-a)*(e-o)-(t-a)*(s-o)>=0&&(t-a)*(r-o)-(i-a)*(e-o)>=0&&(i-a)*(s-o)-(n-a)*(r-o)>=0}function ns(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&&os(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(cs(t,e)&&cs(e,t)&&function(t,e){var i=t,r=!1,n=(t.x+e.x)/2,s=(t.y+e.y)/2;do{i.y>s!=i.next.y>s&&i.next.y!==i.y&&n<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==t);return r}(t,e)&&(ss(t.prev,t,e.prev)||ss(t,e.prev,e))||as(t,e)&&ss(t.prev,t,t.next)>0&&ss(e.prev,e,e.next)>0)}function ss(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function as(t,e){return t.x===e.x&&t.y===e.y}function os(t,e,i,r){var n=hs(ss(t,e,i)),s=hs(ss(t,e,r)),a=hs(ss(i,r,t)),o=hs(ss(i,r,e));return n!==s&&a!==o||(!(0!==n||!us(t,i,e))||(!(0!==s||!us(t,r,e))||(!(0!==a||!us(i,t,r))||!(0!==o||!us(i,e,r)))))}function us(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function hs(t){return t>0?1:t<0?-1:0}function cs(t,e){return ss(t.prev,t,t.next)<0?ss(t,e,t.next)>=0&&ss(t,t.prev,e)>=0:ss(t,e,t.prev)<0||ss(t,t.next,e)<0}function ls(t,e){var i=new ps(t.i,t.x,t.y),r=new ps(e.i,e.x,e.y),n=t.next,s=e.prev;return t.next=e,e.prev=t,i.next=n,n.prev=i,r.next=i,i.prev=r,s.next=r,r.prev=s,r}function fs(t,e,i,r){var n=new ps(t,e,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function ds(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 ps(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}var ms=0;function vs(t,e,i,r){i=i||2,ms=r||0;var n,s,a,o,u,h,c,l=e&&e.length,f=l?e[0]*i:t.length,d=Zn(t,0,f,i,!0),p=[];if(!d||d.next===d.prev)return p;if(l&&(d=function(t,e,i,r){var n,s,a,o=[];for(n=0,s=e.length;n<s;n++)(a=Zn(t,e[n]*r,n<s-1?e[n+1]*r:t.length,r,!1))===a.next&&(a.steiner=!0),o.push(is(a));for(o.sort(Jn),n=0;n<o.length;n++)$n(o[n],i),i=qn(i,i.next);return i}(t,e,d,i)),t.length>80*i){n=a=t[0],s=o=t[1];for(var m=i;m<f;m+=i)(u=t[m])<n&&(n=u),(h=t[m+1])<s&&(s=h),u>a&&(a=u),h>o&&(o=h);c=0!==(c=Math.max(a-n,o-s))?1/c:0}return ys(d,p,i,n,s,c),p}function ys(t,e,i,r,n,s,a){if(t){!a&&s&&function(t,e,i,r){var n=t;do{null===n.z&&(n.z=es(n.x,n.y,e,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,function(t){var e,i,r,n,s,a,o,u,h=1;do{for(i=t,t=null,s=null,a=0;i;){for(a++,r=i,o=0,e=0;e<h&&(o++,r=r.nextZ);e++);for(u=h;o>0||u>0&&r;)0!==o&&(0===u||!r||i.z<=r.z)?(n=i,i=i.nextZ,o--):(n=r,r=r.nextZ,u--),s?s.nextZ=n:t=n,n.prevZ=s,s=n;i=r}s.nextZ=null,h*=2}while(a>1)}(n)}(t,r,n,s);for(var o,u,h=t;t.prev!==t.next;)if(o=t.prev,u=t.next,s?Qn(t,r,n,s):Kn(t))e.push(o.i/i+ms),e.push(t.i/i+ms),e.push(u.i/i+ms),ds(t),t=u.next,h=u.next;else if((t=u)===h){a?1===a?ys(t=gs(qn(t),e,i),e,i,r,n,s,2):2===a&&xs(t,e,i,r,n,s):ys(qn(t),e,i,r,n,s,1);break}}}function gs(t,e,i){var r=t;do{var n=r.prev,s=r.next.next;!as(n,s)&&os(n,r,r.next,s)&&cs(n,s)&&cs(s,n)&&(e.push(n.i/i+ms),e.push(r.i/i+ms),e.push(s.i/i+ms),ds(r),ds(r.next),r=t=s),r=r.next}while(r!==t);return qn(r)}function xs(t,e,i,r,n,s){var a=t;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&ns(a,o)){var u=ls(a,o);return a=qn(a,a.next),u=qn(u,u.next),ys(a,e,i,r,n,s),void ys(u,e,i,r,n,s)}o=o.next}a=a.next}while(a!==t)}var bs=6,Ts="PRE_COLOR_0",Es="PRE_COLOR_SIZE_0",_s="PRE_MAIN_COLOR_0",ws="PRE_MAIN_COLOR_SIZE_0",As="editor",Cs={"Item duration can't be less than 0":"https://www.galacean.com/effects/user/gasrv4ka5sacrwpg#AOnQS","ValueType: 21/22 is not supported":"https://www.galacean.com/effects/user/gasrv4ka5sacrwpg#smO1b"},Ss=2;function Os(t,e){for(var i=t.s,r=t.p,n=i[1],s=r[1],a=0,o=0;o<n.length;o++){a+=n[o].length-1}var u,h=new Float32Array(a*bs),c=e.indexBase,l=void 0===c?0:c,f=e.uvTransform,d=0,p=0,m=0,v=1,y=1;f&&(p=f[0],m=f[1],u=f[4],v=u?f[3]:f[2],y=u?f[2]:f[3]);for(var g=[0,0],x=0===u?0:-Math.PI/2,b=0;b<n.length;b++)for(var T=n[b],E=s[b],_=s[b+1]||s[0],w=T,A=[0,0],C=0;C<w.length-1;C++){Is(A,w[C],E,_,E[4],E[5],_[2],_[3]),O(A[0],A[1])}var S=vs(Array.from(h),null,bs,l);return{aPoint:h,index:new Uint16Array(S)};function O(t,e){h[d++]=t/2,h[d++]=e/2,f?(g[0]=t,g[1]=e,Ms(g,g,x),h[d++]=p+(g[0]+1)/2*v,h[d++]=m+(g[1]+1)/2*y):(h[d++]=(t+1)/2,h[d++]=(e+1)/2),d+=Ss}}function Rs(t,e){for(var i=[],r=function(t){var e=[];return"gs"in t?t.gs.forEach((function(t){e.push({p:[$t.SHAPE_POINTS,t.p],s:[$t.SHAPE_SPLITS,t.s]})})):"g"in t?e.push({p:[$t.SHAPE_POINTS,t.g.p],s:[$t.SHAPE_SPLITS,t.g.s]}):e.push(t),e}(t),n=0,s=0,a=0,o=0;o<r.length;o++){var u=Os(r[o],{indexBase:n,uvTransform:e});n+=u.aPoint.length/5,i.push(u),s+=u.aPoint.length,a+=u.index.length}if(1===i.length)return i[0];for(var h=new Float32Array(s),c=new Uint16Array(a),l=0,f=0,d=0;l<i[l];l++){var p=i[l];h.set(p.aPoint,f),f+=p.aPoint.length,c.set(p.index,d),d+=p.index.length}return{aPoint:h,index:c}}function Ms(t,e,i){var r=Math.cos(i),n=Math.sin(i),s=e[0],a=e[1];return t[0]=r*s+n*a,t[1]=-n*s+r*a,t}function Is(t,e,i,r,n,s,a,o){var u=1-e,h=u*u*u,c=3*e*u*u,l=3*e*e*u,f=e*e*e;return t[0]=h*i[0]+c*n+l*a+f*r[0],t[1]=h*i[1]+c*s+l*o+f*r[1],t}var Ps=[[0,0,1,1,0]],Ls=function(t){function e(e){var i;(i=t.call(this,e)||this).visible=!0,i.splits=Ps,i.meshCollider=new ro,i._color=new ii(1,1,1,1),i.getHitTestParams=function(t){var e=ni.fromScale(i.transform.size.x,i.transform.size.y,1).premultiply(i.transform.getWorldMatrix()),r=i.interaction;if(t||r){i.meshCollider.setGeometry(i.geometry,e);var n,s=i.meshCollider.getBoundingBoxData();if(s)return{behavior:(null==(n=i.interaction)?void 0:n.behavior)||0,type:s.type,triangles:s.area,backfaceCulling:i.renderer.side===kt.FRONT}}},i.renderer={renderMode:Ht.MESH,blending:Dt.ALPHA,texture:i.engine.emptyTexture,occlusion:!1,transparentOcclusion:!1,side:kt.DOUBLE,mask:0},i.defaultGeometry=Cr.create(i.engine,{attributes:{aPos:{type:fi.FLOAT,size:3,data:new Float32Array([-.5,.5,0,-.5,-.5,0,.5,.5,0,.5,-.5,0])},aUV:{size:2,offset:0,releasable:!0,type:fi.FLOAT,data:new Float32Array([0,1,0,0,1,1,1,0])}},indices:{data:new Uint16Array([0,1,2,2,1,3]),releasable:!0},mode:fi.TRIANGLES,drawCount:6}),i.geometry=i.defaultGeometry;var r=cr.create(i.engine,{shader:{fragment:qr,vertex:Zr,shared:!0}});return i.material=r,i.material.setColor("_Color",new ii(1,1,1,1)),i.maskManager=new lr(e),i}Qt(e,t);var i=e.prototype;return i.setVisible=function(t){this.visible=t},i.getVisible=function(){return this.visible},i.setColor=function(t){A(t,ii)?this._color.copyFrom(t):this._color.setFromArray(t),this.material.setColor("_Color",this._color)},i.setTexture=function(t){var e=this;return E((function(){var i;return O(this,(function(r){switch(r.label){case 0:return"string"!=typeof t?[3,2]:[4,Yi.fromImage(t,e.item.engine)];case 1:return i=r.sent(),[3,3];case 2:i=t,r.label=3;case 3:return e.renderer.texture=i,e.material.setTexture("_MainTex",i),[2]}}))}))()},i.render=function(t){this.getVisible()&&(this.maskManager.drawStencilMask(t),this.draw(t))},i.drawStencilMask=function(t){if(this.isActiveAndEnabled){var e=this.material.colorMask;this.material.colorMask=!1,this.draw(t),this.material.colorMask=e}},i.onStart=function(){this.item.getHitTestParams=this.getHitTestParams},i.getBoundingBox=function(){var t=this.transform.getWorldMatrix();return this.meshCollider.setGeometry(this.geometry,t),this.meshCollider.getBoundingBox()},i.getItemGeometryData=function(t){var e=this.splits,i=this.textureSheetAnimation,r=this.defaultGeometry;if(t.shape){for(var n=t.shape,s=n.index,a=void 0===s?[]:s,o=n.aPoint,u=void 0===o?[]:o,h=new Float32Array(u),c=[],l=[],f=0;f<h.length;f+=6)h[f]*=1,h[f+1]*=1,l.push(u[f+2],u[f+3]),c.push(h[f],h[f+1],0);return r.setAttributeData("aPos",new Float32Array(c)),{index:a,aUV:l}}var d=[-.5,.5,-.5,-.5,.5,.5,.5,-.5],p=[],m=[],v=[];if(1===e.length){var y=i?[0,0,1,1,e[0][4]]:e[0],g=y[4]?[0,0,1,0,0,1,1,1]:[0,1,0,0,1,1,1,0],x=y[0],b=y[1],T=y[4]?y[3]:y[2],E=y[4]?y[2]:y[3];p.push(g[0]*T+x,g[1]*E+b,g[2]*T+x,g[3]*E+b,g[4]*T+x,g[5]*E+b,g[6]*T+x,g[7]*E+b),v.push(d[0],d[1],0,d[2],d[3],0,d[4],d[5],0,d[6],d[7],0),m.push(0,1,2,2,1,3)}else for(var _=0;_<2;_++)for(var w=0;w<2;w++){var A=4*(2*w+_),C=i?[0,0,1,1,e[0][4]]:e[2*w+_],S=C[4]?[0,0,1,0,0,1,1,1]:[0,1,0,0,1,1,1,0],O=((_+_+1)/2-1)/2,R=((w+w+1)/2-1)/2,M=C[0],I=C[1],P=C[4]?C[3]:C[2],L=C[4]?C[2]:C[3],F=[d[0]/2+O,d[1]/2+R,d[2]/2+O,d[3]/2+R,d[4]/2+O,d[5]/2+R,d[6]/2+O,d[7]/2+R];p.push(S[0]*P+M,S[1]*L+I,S[2]*P+M,S[3]*L+I,S[4]*P+M,S[5]*L+I,S[6]*P+M,S[7]*L+I),v.push(1*F[0],1*F[1],0,1*F[2],1*F[3],0,1*F[4],1*F[5],0,1*F[6],1*F[7],0),m.push(A,1+A,2+A,2+A,1+A,3+A)}return r.setAttributeData("aPos",new Float32Array(v)),{index:m,aUV:p}},i.configureDefaultGeometry=function(t){var e=this.getItemGeometryData(t),i=e.index,r=e.aUV,n=this.defaultGeometry;return n.setIndexData(new Uint16Array(i)),n.setAttributeData("aUV",new Float32Array(r)),n.setDrawCount(i.length),n},i.configureMaterial=function(t){var e=t.side,i=t.occlusion,r=t.blending,n=t.mask,s=t.texture,a=this.maskManager.maskMode,o=this.material;o.blending=!0,o.depthTest=!0,o.depthMask=i,o.stencilRef=void 0!==n?[n,n]:void 0,bi(o,r),Ei(o,a),Ti(o,e),o.shader.shaderData.properties='_MainTex("_MainTex",2D) = "white" {}',o.setVector4("_TexOffset",new Je(0,0,1,1)),o.setTexture("_MainTex",s);var u=xi(r),h=new Je;return h.x=t.occlusion?+t.transparentOcclusion:1,h.y=u,h.z=t.renderMode,h.w=a,o.setVector4("_TexParams",h),0===h.x||this.maskManager.alphaMaskEnabled?o.enableMacro("ALPHA_CLIP"):o.disableMacro("ALPHA_CLIP"),o},i.draw=function(t){t.renderingData.currentFrame.globalUniforms&&t.setGlobalMatrix("effects_ObjectToWorld",this.transform.getWorldMatrix());for(var e=0;e<this.materials.length;e++){var i=this.materials[e];i.setVector2("_Size",this.transform.size),this.renderer.renderMode!==Ht.BILLBOARD&&this.renderer.renderMode!==Ht.VERTICAL_BILLBOARD&&this.renderer.renderMode!==Ht.HORIZONTAL_BILLBOARD||i.setVector3("_Scale",this.transform.scale),t.drawGeometry(this.geometry,i,e)}},i.fromData=function(e){t.prototype.fromData.call(this,e);var i,r=e,n=null!=(i=r.renderer)?i:{},s=r.splits,a=r.textureSheetAnimation,o=r.mask;o&&this.maskManager.getMaskMode(o);var u,h,c,l=n.shape,f=s&&!a?s[0]:void 0,d=void 0;if(null==l||"aPoint"in l&&"index"in l||(d=Rs(l,f)),this.splits=s||Ps,this.textureSheetAnimation=a,this.renderer={renderMode:null!=(u=n.renderMode)?u:Ht.MESH,blending:null!=(h=n.blending)?h:Dt.ALPHA,texture:n.texture?this.engine.findObject(n.texture):this.engine.emptyTexture,occlusion:!!n.occlusion,transparentOcclusion:!!n.transparentOcclusion||this.maskManager.maskMode===ui.MASK,side:null!=(c=n.side)?c:kt.DOUBLE,mask:this.maskManager.getRefValue(),shape:d},this.configureMaterial(this.renderer),r.geometry){var p=this.engine.findObject(r.geometry),m=r.splits&&!r.textureSheetAnimation?r.splits[0]:Ps[0],v=m[0],y=m[1],g=Boolean(m[4]),x=g?m[3]:m[2],b=g?m[2]:m[3],T=g?-Math.PI/2:0,E=p.getAttributeData("aUV"),_=p.getAttributeData("aPos"),A=p.getIndexData(),C=[0,0];if(E&&_&&A){for(var S=E.length/2,O=0;O<S;O++){var R=3*O,M=2*O,I=_[R],P=_[R+1];C[0]=I,C[1]=P,Ms(C,C,T),E[M]=(C[0]+.5)*x+v,E[M+1]=(C[1]+.5)*b+y}this.geometry.setAttributeData("aPos",_.slice()),this.geometry.setAttributeData("aUV",E.slice()),this.geometry.setIndexData(A.slice()),this.geometry.setDrawCount(A.length)}this.geometry.subMeshes.length=0;for(var L,F=w(p.subMeshes);!(L=F()).done;){var V=L.value;this.geometry.subMeshes.push({offset:V.offset,indexCount:V.indexCount,vertexCount:V.vertexCount})}}else this.geometry=this.defaultGeometry,this.configureDefaultGeometry(this.renderer)},Pe(e,[{key:"color",get:function(){return this._color},set:function(t){this._color=t,this.material.setColor("_Color",this._color)}}]),e}(Ge),Fs=function(t){function e(e){var i;(i=t.call(this,e)||this).hasStroke=!1,i.hasFill=!1,i.shapeDirty=!0,i.graphicsPath=new Dh,i.vert="\nprecision highp float;\n\nattribute vec3 aPos;//x y\n\nuniform mat4 effects_MatrixVP;\nuniform mat4 effects_MatrixInvV;\nuniform mat4 effects_ObjectToWorld;\n\nvoid main() {\n vec4 pos = vec4(aPos.xyz, 1.0);\n gl_Position = effects_MatrixVP * effects_ObjectToWorld * pos;\n}\n",i.frag="\nprecision highp float;\n\nuniform vec4 _Color;\n\nvoid main() {\n vec4 color = _Color;\n color.rgb *= color.a;\n gl_FragColor = color;\n}\n",i.geometry.subMeshes.push({offset:0,indexCount:0,vertexCount:0},{offset:0,indexCount:0,vertexCount:0});var r={shader:{vertex:i.vert,fragment:i.frag,glslVersion:ur.GLSL1}},n=cr.create(e,r),s=cr.create(e,r);return n.color=new ii(1,1,1,1),n.depthMask=!1,n.depthTest=!0,n.blending=!0,i.material=n,s.color=new ii(.25,.25,.25,1),s.depthMask=!1,s.depthTest=!0,s.blending=!0,i.materials[1]=s,i.strokeAttributes={width:1,alignment:.5,cap:xe.Butt,join:be.Miter,miterLimit:10,color:new ii(1,1,1,1)},i.fillAttribute={color:new ii(1,1,1,1)},i.shapeAttribute={type:ge.Custom,points:[],easingIns:[],easingOuts:[],shapes:[]},i}Qt(e,t);var i=e.prototype;return i.onStart=function(){this.item.getHitTestParams=this.getHitTestParams},i.onUpdate=function(t){this.material.color=this.fillAttribute.color,this.materials[1].color=this.strokeAttributes.color,this.shapeDirty&&(this.buildPath(this.shapeAttribute),this.buildGeometryFromPath(this.graphicsPath.shapePath),this.shapeDirty=!1)},i.buildGeometryFromPath=function(t){var e=t.shapePrimitives,i=[],r=[];if(this.hasFill)for(var n,s=w(e);!(n=s()).done;){var a=n.value.shape,o=[],u=r.length,h=i.length/2;a.build(o),a.triangulate(o,i,h,r,u)}var c=r.length;if(this.hasStroke)for(var l,f=w(e);!(l=f()).done;){var d=l.value.shape,p=[],m=i.length/2,v=this.strokeAttributes,y=!0;this.shapeAttribute.type===ge.Custom&&(y=d.closePath),d.build(p),Th(p,v,!1,y,i,2,m,r)}var g=r.length-c,x=i.length/2,b=this.geometry.getAttributeData("aPos"),T=this.geometry.getAttributeData("aUV"),E=this.geometry.getIndexData();(!b||b.length<3*x)&&(b=new Float32Array(3*x)),(!T||T.length<2*x)&&(T=new Float32Array(2*x)),(!E||E.length<r.length)&&(E=new Uint16Array(r.length));for(var _=0;_<x;_++){var A=3*_,C=2*_,S=2*_;b[A]=i[C],b[A+1]=i[C+1],b[A+2]=0,T[S]=b[A],T[S+1]=b[A+1]}E.set(r),this.geometry.setAttributeData("aPos",b),this.geometry.setAttributeData("aUV",T),this.geometry.setIndexData(E),this.geometry.setDrawCount(r.length);var O=this.geometry.subMeshes[0],R=this.geometry.subMeshes[1];O.indexCount=c,R.offset=2*c,R.indexCount=g},i.buildPath=function(t){switch(this.graphicsPath.clear(),t.type){case ge.Custom:for(var e,i=this.shapeAttribute,r=i.points,n=i.easingIns,s=i.easingOuts,a=w(i.shapes);!(e=a()).done;){var o=e.value,u=o.indexes,h=r[u[0].point];this.graphicsPath.moveTo(h.x,h.y);for(var c=1;c<u.length;c++){var l=u[c],f=u[c-1],d=r[l.point],p=r[f.point],m=s[f.easingOut],v=n[l.easingIn];this.graphicsPath.bezierCurveTo(m.x+p.x,m.y+p.y,v.x+d.x,v.y+d.y,d.x,d.y,1)}if(o.close){var y=u[0],g=u[u.length-1],x=r[y.point],b=r[g.point],T=s[g.easingOut],E=n[y.easingIn];this.graphicsPath.bezierCurveTo(T.x+b.x,T.y+b.y,E.x+x.x,E.y+x.y,x.x,x.y,1),this.graphicsPath.closePath()}}break;case ge.Ellipse:var _=t;this.graphicsPath.ellipse(0,0,_.xRadius,_.yRadius);break;case ge.Rectangle:var A=t;this.graphicsPath.rect(-A.width/2,-A.height/2,A.width,A.height,A.roundness);break;case ge.Star:var C=t;this.graphicsPath.polyStar(C.pointCount,C.outerRadius,C.innerRadius,C.outerRoundness,C.innerRoundness,Ph.Star);break;case ge.Polygon:var S=t;this.graphicsPath.polyStar(S.pointCount,S.radius,S.radius,S.roundness,S.roundness,Ph.Polygon)}},i.fromData=function(e){t.prototype.fromData.call(this,e),this.shapeDirty=!0;var i=e.stroke;i&&(this.hasStroke=!0,this.strokeAttributes.width=i.width,this.strokeAttributes.color.copyFrom(i.color),this.strokeAttributes.cap=i.cap,this.strokeAttributes.join=i.join);var r=e.fill;switch(r&&(this.hasFill=!0,this.fillAttribute.color.copyFrom(r.color)),e.type){case ge.Custom:for(var n,s=e,a={type:ge.Custom,points:[],easingIns:[],easingOuts:[],shapes:[],fill:s.fill},o=w(s.points);!(n=o()).done;){var u=n.value;a.points.push(new Ke(u.x,u.y))}for(var h,c=w(s.easingIns);!(h=c()).done;){var l=h.value;a.easingIns.push(new Ke(l.x,l.y))}for(var f,d=w(s.easingOuts);!(f=d()).done;){var p=f.value;a.easingOuts.push(new Ke(p.x,p.y))}a.shapes=s.shapes,this.shapeAttribute=a;break;case ge.Ellipse:var m=e,v={type:ge.Ellipse,xRadius:m.xRadius,yRadius:m.yRadius,fill:m.fill};this.shapeAttribute=v;break;case ge.Rectangle:var y=e,g={type:ge.Rectangle,width:y.width,height:y.height,roundness:y.roundness,fill:y.fill};this.shapeAttribute=g;break;case ge.Star:var x=e,b={type:ge.Star,pointCount:x.pointCount,innerRadius:x.innerRadius,outerRadius:x.outerRadius,innerRoundness:x.innerRoundness,outerRoundness:x.outerRoundness,fill:x.fill};this.shapeAttribute=b;break;case ge.Polygon:var T=e,E={type:ge.Polygon,pointCount:T.pointCount,radius:T.radius,roundness:T.roundness,fill:T.fill};this.shapeAttribute=E}e.mask&&this.maskManager.getMaskMode(e.mask);var _=this.maskManager.getRefValue();this.material.stencilRef=void 0!==_?[_,_]:void 0,Ei(this.material,this.maskManager.maskMode)},Pe(e,[{key:"shape",get:function(){return this.shapeDirty=!0,this.shapeAttribute}}]),e}(Ls);Fs=S([Ne("ShapeComponent")],Fs);var Vs,Ns=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).loop=!1,e.amountOfMotion=1,e.animationLength=2,e.mode=1,e.startPositionX=0,e.startPositionY=0,e.startPositionZ=0,e.endPositionX=0,e.endPositionY=0,e.endPositionZ=0,e.amplitudeX=0,e.amplitudeY=0,e.amplitudeZ=0,e.phaseX=0,e.phaseY=0,e.phaseZ=0,e}Qt(e,t);var i=e.prototype;return i.onStart=function(){this.effectComponent=this.item.getComponent(ti)},i.onUpdate=function(t){this.updateFake3D()},i.updateFake3D=function(){if(this.effectComponent){var t=this.item.time%this.animationLength/this.animationLength,e=0,i=0,r=0;switch(this.mode){case 0:var n=Math.PI;e=Math.sin(2*n*(t+this.phaseX))*this.amplitudeX,i=Math.sin(2*n*(t+this.phaseY))*this.amplitudeY,r=Math.sin(2*n*(t+this.phaseZ))*this.amplitudeZ;break;case 1:var s=t;this.loop&&(s>.5&&(s=1-s),s*=2),e=this.startPositionX*(1-s)+s*this.endPositionX,i=this.startPositionY*(1-s)+s*this.endPositionY,r=this.startPositionZ*(1-s)+s*this.endPositionZ}var a=this.effectComponent.material;a.setFloat("_PosX",e*this.amountOfMotion),a.setFloat("_PosY",i*this.amountOfMotion),a.setFloat("_PosZ",r*this.amountOfMotion)}},e}(Ue);S([De()],Ns.prototype,"loop",void 0),S([De()],Ns.prototype,"amountOfMotion",void 0),S([De()],Ns.prototype,"animationLength",void 0),S([De()],Ns.prototype,"mode",void 0),S([De()],Ns.prototype,"startPositionX",void 0),S([De()],Ns.prototype,"startPositionY",void 0),S([De()],Ns.prototype,"startPositionZ",void 0),S([De()],Ns.prototype,"endPositionX",void 0),S([De()],Ns.prototype,"endPositionY",void 0),S([De()],Ns.prototype,"endPositionZ",void 0),S([De()],Ns.prototype,"amplitudeX",void 0),S([De()],Ns.prototype,"amplitudeY",void 0),S([De()],Ns.prototype,"amplitudeZ",void 0),S([De()],Ns.prototype,"phaseX",void 0),S([De()],Ns.prototype,"phaseY",void 0),S([De()],Ns.prototype,"phaseZ",void 0),Ns=S([Ne("Fake3DComponent")],Ns),function(t){t[t.Circular=0]="Circular",t[t.Linear=1]="Linear"}(Vs||(Vs={}));var Ds=function(t){function e(e,i){var r;return r=t.call(this,e)||this,i&&r.fromData(i),r}Qt(e,t);var i=e.prototype;return i.onUpdate=function(){if(this.item.composition&&this.item.transform.getValid()){var t=this.item.composition.camera;t.near=this.options.near,t.far=this.options.far,t.fov=this.options.fov,t.clipMode=this.options.clipMode,t.transform.parentTransform=this.transform.parentTransform,t.position=this.transform.position,t.setQuat(this.transform.getQuaternion().clone().conjugate())}},i.fromData=function(e){t.prototype.fromData.call(this,e),this.options=e.options},e}(Ue);Ds=S([Ne(_e.CameraController)],Ds);var ks,zs=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e}(qt);!function(t){t[t.triangle=1]="triangle",t[t.box=2]="box",t[t.sphere=3]="sphere",t[t.custom=4]="custom"}(ks||(ks={}));var Us="click",Bs="touchstart",Gs="touchmove",js="touchend",Xs=function(){function t(t,e){void 0===e&&(e=!1),this.target=t,this.allowPropagation=e,this.enabled=!0,this.handlers={},this.nativeHandlers={}}var e=t.prototype;return e.bindListeners=function(){var t,e,i,r,n,s=this;n=function(t){return t};var a,o="mousedown",u="mousemove",h="mouseup",c=function(t,e,i,n,a){void 0===n&&(n=0),void 0===a&&(a=0);var o=0,u=0,h=d.now();if(!s.target)return mt.warn("Trigger TouchEvent after EventSystem is disposed."),{x:e,y:i,vx:0,vy:u,dx:n,dy:a,ts:h,width:0,height:0,origin:t};var c=s.target,l=c.width,f=c.height;if(r){var p=h-r.ts;o=(n-r.dx)/p||0,u=(a-r.dy)/p||0,r={dx:n,dy:a,ts:h}}return{x:e,y:i,vx:o,vy:u,dx:n,dy:a,ts:h,width:l,height:f,origin:t}};Q()&&(n=function(t){var e=t.touches,i=t.changedTouches;return e[0]||i[0]},o="touchstart",u="touchmove",h="touchend"),this.nativeHandlers=((a={})[o]=function(a){if(s.enabled){var o=n(a),u=Hs(o);t=u.x,e=u.y,r=i={clientX:o.clientX,clientY:o.clientY,ts:d.now(),x:t,y:e},s.dispatchEvent(Bs,c(a,t,e))}},a[u]=function(r){if(i&&s.enabled){var a=Hs(n(r));t=a.x,e=a.y,s.dispatchEvent(Gs,c(r,t,e,t-i.x,e-i.y))}},a[h]=function(r){if(i&&s.enabled){!s.allowPropagation&&r.cancelable&&(r.preventDefault(),r.stopPropagation());var a=n(r),o=Hs(a),u=Math.abs(i.clientX-a.clientX)+Math.abs(i.clientY-a.clientY);t=o.x,e=o.y,u<4&&s.dispatchEvent(Us,c(r,t,e)),s.dispatchEvent(js,c(r,t,e,t-i.x,e-i.y))}i=0},a),Object.keys(this.nativeHandlers).forEach((function(t){var e;null==(e=s.target)||e.addEventListener(String(t),s.nativeHandlers[t])}))},e.dispatchEvent=function(t,e){var i=this.handlers[t];null==i||i.forEach((function(t){return t(e)}))},e.addEventListener=function(t,e){var i=this.handlers[t];return i||(i=this.handlers[t]=[]),D(i,e),function(){k(i,e)}},e.removeEventListener=function(t,e){var i=this.handlers[t];i&&k(i,e)},e.dispose=function(){var t=this;this.target&&(this.handlers={},Object.keys(this.nativeHandlers).forEach((function(e){var i;null==(i=t.target)||i.removeEventListener(String(e),t.nativeHandlers[e])})),this.nativeHandlers={},this.target=null)},t}();function Hs(t){var e=t.target,i=t.clientX,r=t.clientY,n=e.getBoundingClientRect(),s=n.left,a=n.top;return{x:(i-s)/n.width*2-1,y:1-(r-a)/n.height*2}}var Ys,Ws,Zs=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e}(qt),qs=(Ys=new Float32Array(1),Ws=new Int32Array(Ys.buffer),function(t){Ys[0]=t;var e=Ws[0],i=e>>16&32768,r=e>>12&2047,n=e>>23&255;return n<103?i:n>142?(i|=31744,i|=(255==n?0:1)&&8388607&e):n<113?i|=((r|=2048)>>114-n)+(r>>113-n&1):(i|=n-112<<10|r>>1,i+=1&r)}),Ks=function(){function t(t){if(Number.isInteger(t))this.data=new Uint16Array(t);else if(t&&"object"==typeof t&&Number.isInteger(t.length))for(var e=this.data=new Uint16Array(t.length),i=0;i<e.length;i++)e[i]=qs(t[i])}return t.prototype.set=function(t,e){for(var i=0;i<t.length;i++)this.data[i+e]=qs(t[i])},t}();function Qs(t,e){for(var i=[-.5,.5,-.5,-.5,.5,.5,.5,-.5],r=0;r<8;r+=2)i[r]+=t,i[r+1]+=e;return i}var Js,$s=new Or,ta=new ni;function ea(t,e,i,r,n,s,a){var o=t,u=r/n,h=r,c=e.speedOverLifetime;c&&(h=c.getIntegrateValue(0,r,n));var l=e.gravityModifier?e.gravityModifier.getIntegrateByTime(0,r):0;o.copyFrom(s),o.addScaledVector(a,h),o.addScaledVector(i,l);var f=e.linearVelOverLifetime||{},d=e.orbitalVelOverLifetime||{};if(d.enabled){var p=new Qe;d.center&&p.setFromArray(d.center);var m=o.clone().subtract(p),v=d.asRotation,y=["x","y","z"].map((function(t){var e=d[t];return e?v?e.getValue(u):e.getIntegrateValue(0,r,n):0}));$s.setFromArray(y).negate(),ta.setFromEuler($s);var g=ta.transformPoint(m);o.addVectors(p,g)}if(f.enabled){var x=f.asMovement,b=f.x,T=f.y,E=f.z;if(b){var _=x?b.getValue(u):b.getIntegrateValue(0,r,n);o.x=o.x+_}if(T){var w=x?T.getValue(u):T.getIntegrateValue(0,r,n);o.y=o.y+w}if(E){var A=x?E.getValue(u):E.getIntegrateValue(0,r,n);o.z=o.z+A}}return o}function ia(t){return Array.isArray(t)?[t[0],t[1],t[2]]:[0,0,0]}function ra(t,e){for(var i=0,r=t.length;i<r;i++)t[i]=e;return t}function na(t,e,i){if(e&&i)for(var r=0,n=e.length;r<n;r++)t[r]=e[r]*i[r];else if(e){if(t!==e)for(var s=0;s<e.length;s++)t[s]=e[s]}else if(i&&t!==i)for(var a=0;a<i.length;a++)t[a]=i[a];return t}var sa=((Js={})[Yt.PARTICLE_ORIGIN_CENTER]=[0,0],Js[Yt.PARTICLE_ORIGIN_CENTER_BOTTOM]=[0,-.5],Js[Yt.PARTICLE_ORIGIN_CENTER_TOP]=[0,.5],Js[Yt.PARTICLE_ORIGIN_LEFT_TOP]=[-.5,.5],Js[Yt.PARTICLE_ORIGIN_LEFT_CENTER]=[-.5,0],Js[Yt.PARTICLE_ORIGIN_LEFT_BOTTOM]=[-.5,-.5],Js[Yt.PARTICLE_ORIGIN_RIGHT_CENTER]=[.5,0],Js[Yt.PARTICLE_ORIGIN_RIGHT_BOTTOM]=[.5,-.5],Js[Yt.PARTICLE_ORIGIN_RIGHT_TOP]=[.5,.5],Js);function aa(t){return Math.pow(2,Math.round(Math.log(t)/Math.LN2))}function oa(t,e,i){var r=i.position,n=new Qe(t,e,0),s=new Qe;return i.getInverseViewProjectionMatrix().projectPoint(n,s),s.subtract(r),new Mr(r,s)}function ua(t,e,i){var r=t.x,n=t.y,s=t.z,a=new Qe(r-e,n+i,s),o=new Qe(r-e,n-i,s),u=new Qe(r+e,n-i,s),h=new Qe(r+e,n+i,s);return[{p0:a,p1:o,p2:u},{p0:a.clone(),p1:u.clone(),p2:h}]}function ha(t,e,i){return void 0===i&&(i=1e-6),Math.abs(t-e)<i}function ca(t,e){void 0===e&&(e=2);var i=Math.pow(10,e);return Math.floor(t*i)/i}var la={pointIndexCache:{xIndex:0,yIndex:0},getPointInCurve:function(t){t[0];var e=t[1],i=this.getPointIndexInCurve(t,this.pointIndexCache),r=i.xIndex,n=i.yIndex,s=e[r],a=e[n];return new Ke(s,a)},getPointIndexInCurve:function(t,e){var i=t[0],r=t[2],n=i===te.LINE||i===te.EASE_OUT?0:i===te.EASE_IN||i===te.EASE||i===te.HOLD&&r===te.EASE_IN?2:0;return e?(e.xIndex=n,e.yIndex=n+1,e):{xIndex:n,yIndex:n+1}},isLeftSideEase:function(t){var e=t[0];t[1];var i=t[2];return!(e!==te.HOLD||!this.isKeyframeTypeLeftSideEase(i))||this.isKeyframeTypeLeftSideEase(e)},isRightSideEase:function(t){var e=t[0];t[1];var i=t[2];return!(e!==te.HOLD||!this.isKeyframeTypeRightSideEase(i))||this.isKeyframeTypeRightSideEase(e)},isKeyframeTypeLeftSideEase:function(t){return[te.EASE,te.EASE_IN,te.AUTO].includes(t)},isKeyframeTypeRightSideEase:function(t){return[te.EASE,te.EASE_OUT,te.AUTO].includes(t)},isHoldInKeyframe:function(t){var e=t[0];t[1];var i=t[2];return e===te.HOLD&&[te.HOLD,te.LINE_OUT,te.EASE_OUT].includes(i)},isHoldOutKeyframe:function(t){var e=t[0];t[1];var i=t[2];return e===te.HOLD&&[te.HOLD,te.LINE,te.EASE_IN].includes(i)}},fa=function(t,e){this.points=t,this.totalLength=e},da={},pa={},ma=.1;function va(t,e){return 1-3*e+3*t}function ya(t,e){return 3*e-6*t}function ga(t){return 3*t}function xa(t,e,i){return((va(e,i)*t+ya(e,i))*t+ga(e))*t}function ba(t,e,i){return 3*va(e,i)*t*t+2*ya(e,i)*t+ga(e)}var Ta=function(){function t(t,e,i,r){this.p1=t,this.p2=e,this.p3=i,this.p4=r,this.catching={lastPoint:0,lastAddedLength:0};var n=function(t,e,i,r){var n=ca(e.x-t.x,3)+"_"+ca(e.y-t.y,3)+"_"+ca(e.z-t.z,3)+"&"+ca(i.x-t.x,3)+"_"+ca(i.y-t.y,3)+"_"+ca(i.z-t.z,3)+"&"+ca(r.x-t.x,3)+"_"+ca(r.y-t.y,3)+"_"+ca(r.z-t.z,3);if(pa[n])return{data:pa[n],interval:t};for(var s=[],a=null,o=0,u=0,h=0;h<300;h+=1){var c=new Qe,l=h/299;u=0,c.x=3*Math.pow(1-l,2)*l*(i.x-t.x)+3*(1-l)*Math.pow(l,2)*(r.x-t.x)+Math.pow(l,3)*(e.x-t.x),c.y=3*Math.pow(1-l,2)*l*(i.y-t.y)+3*(1-l)*Math.pow(l,2)*(r.y-t.y)+Math.pow(l,3)*(e.y-t.y),c.z=3*Math.pow(1-l,2)*l*(i.z-t.z)+3*(1-l)*Math.pow(l,2)*(r.z-t.z)+Math.pow(l,3)*(e.z-t.z),null!==a&&(u+=Math.pow(c.x-a.x,2),u+=Math.pow(c.y-a.y,2),u+=Math.pow(c.z-a.z,2)),a=c,o+=u=Math.sqrt(u),s[h]={partialLength:u,point:c}}var f=new fa(s,o);return pa[n]=f,{data:f,interval:new Qe(t.x,t.y,t.z)}}(t,e,i,r),s=n.data,a=n.interval;this.lengthData=s,this.interval=a,this.totalLength=s.totalLength}return t.prototype.getPointInPercent=function(t){var e=this.lengthData;if(0===t)return e.points[0].point.clone().add(this.interval);if(ha(1-t,0))return e.points[299].point.clone().add(this.interval);if(ha(e.totalLength,0))return this.p1.clone();var i=new Qe,r=ca(e.totalLength*t,4),n=this.catching.lastAddedLength,s=this.catching.lastPoint;if(ha(n,r))return e.points[s].point.clone().add(this.interval);var a=!0,o=1;for(r<n&&(o=-1);a;){if(r>=n){if(299===s){i.x=e.points[s].point.x,i.y=e.points[s].point.y,i.z=e.points[s].point.z;break}if(r<n+e.points[s+1].partialLength){var u=(r-n)/e.points[s+1].partialLength;i.x=e.points[s].point.x+(e.points[s+1].point.x-e.points[s].point.x)*u,i.y=e.points[s].point.y+(e.points[s+1].point.y-e.points[s].point.y)*u,i.z=e.points[s].point.z+(e.points[s+1].point.z-e.points[s].point.z)*u;break}}o>0&&s<299?(s+=o,n+=ca(e.points[s].partialLength,5)):o<0&&s>0?(n-=ca(e.points[s].partialLength,5),s+=o):a=!1}return this.catching.lastPoint=s,this.catching.lastAddedLength=n,i.add(this.interval),i},t}(),Ea=function(){function t(t,e,i,r){this.p1=t,this.p2=e,this.p3=i,this.p4=r,this.temp=new ri,this.totalLength=0}return t.prototype.getPointInPercent=function(t){return 0===t?this.temp.copyFrom(this.p1):ha(1-t,0)?this.temp.copyFrom(this.p2):(Aa.slerpFlat(this.temp,this.p1,this.p2,t),this.temp)},t}(),_a=function(){function t(t,e,i,r){this.mX1=t,this.mY1=e,this.mX2=i,this.mY2=r,this.precomputed=!1,this.mSampleValues=new Array(11)}var e=t.prototype;return e.precompute=function(){this.precomputed=!0,this.mX1===this.mY1&&this.mX2===this.mY2||this.calcSampleValues()},e.getValue=function(t){return this.mX1===this.mY1&&this.mX2===this.mY2?t:isNaN(this.mY1)||isNaN(this.mY2)?0:0===t||1===t?t:(this.precomputed||this.precompute(),xa(this.getTForX(t),this.mY1,this.mY2))},e.calcSampleValues=function(){for(var t=0;t<11;++t)this.mSampleValues[t]=xa(t*ma,this.mX1,this.mX2)},e.getTForX=function(t){for(var e=this.mSampleValues,i=0,r=1;10!==r&&e[r]<=t;++r)i+=ma;var n=i+(t-e[--r])/(e[r+1]-e[r])*ma,s=ba(n,this.mX1,this.mX2);return s>=.001?function(t,e,i,r){for(var n=0;n<4;++n){var s=ba(e,i,r);if(0===s)return e;e-=(xa(e,i,r)-t)/s}return e}(t,n,this.mX1,this.mX2):0===s?n:function(t,e,i,r,n){var s,a,o=0;do{(s=xa(a=e+(i-e)/2,r,n)-t)>0?i=a:e=a}while(Math.abs(s)>1e-7&&++o<10);return a}(t,i,i+ma,this.mX1,this.mX2)},t}();function wa(t,e){var i=function(t,e,i){var r=t[1],n=la.isHoldOutKeyframe(t),s=la.isHoldInKeyframe(e),a=!s&&la.isRightSideEase(t),o=!n&&la.isLeftSideEase(e);if(a&&!o&&!s){var u=new Ke(r[r.length-4],r[r.length-3]),h=new Ke(r[r.length-2],r[r.length-1]),c=la.getPointInCurve(e),l=new Ke(c.x,c.y);return{type:"ease",p0:u,p1:h,p2:new Ke(l.x-(l.x-u.x)/10,l.y),p3:l}}if(!a&&o&&!n){var f=e[1],d=la.getPointInCurve(t),p=new Ke(d.x,d.y),m=new Ke(f[0],f[1]),v=new Ke(f[2],f[3]);return{type:"ease",p0:p,p1:new Ke(p.x+(v.x-p.x)/10,p.y),p2:m,p3:v}}if(a&&o){var y=e[1];return{type:"ease",p0:new Ke(r[r.length-4],r[r.length-3]),p1:new Ke(r[r.length-2],r[r.length-1]),p2:new Ke(y[0],y[1]),p3:new Ke(y[2],y[3])}}var g=la.getPointInCurve(t),x=la.getPointInCurve(e);n?x.y=g.y:s&&(g.y=x.y);return i?{type:"ease",p0:g,p1:new Ke((x.x-g.x)/3+g.x,(x.y-g.y)/3+g.y),p2:new Ke((x.x-g.x)/3*2+g.x,(x.y-g.y)/3*2+g.y),p3:x,isHold:n||s,leftHoldLine:n,rightHoldLine:s}:{type:"line",p0:g,p1:x,isHold:n||s,leftHoldLine:n,rightHoldLine:s}}(t,e,!0),r=i.p0,n=i.p1,s=i.p2,a=i.p3;ot(s),ot(a);var o,u,h=a.x-r.x,c=a.y-r.y,l=ca((n.x-r.x)/h,5),f=ca((s.x-r.x)/h,5);ha(c,0)?o=u=NaN:(o=ca((n.y-r.y)/c,5),u=ca((s.y-r.y)/c,5)),l<0&&(console.error("Invalid bezier points, x1 < 0",r,n,s,a),l=0),f<0&&(console.error("Invalid bezier points, x2 < 0",r,n,s,a),f=0),l>1&&(console.error("Invalid bezier points, x1 >= 1",r,n,s,a),l=1),f>1&&(console.error("Invalid bezier points, x2 >= 1",r,n,s,a),f=1);var d,p=("bez_"+l+"_"+o+"_"+f+"_"+u).replace(/\./g,"p");return da[p]?d=da[p]:(d=new _a(l,o,f,u),da[p]=d),{points:[r,n,s,a],timeInterval:h,valueInterval:c,curve:d}}var Aa=function(){function t(){}return t.slerpFlat=function(t,e,i,r){var n=e.x,s=e.y,a=e.z,o=e.w,u=i.x,h=i.y,c=i.z,l=i.w;if(0===r)return t.x=n,t.y=s,t.z=a,void(t.w=o);if(1===r)return t.x=u,t.y=h,t.z=c,void(t.w=l);if(o!==l||n!==u||s!==h||a!==c){var f=1-r,d=n*u+s*h+a*c+o*l,p=d>=0?1:-1,m=1-d*d;if(m>Number.EPSILON){var v=Math.sqrt(m),y=Math.atan2(v,d*p);f=Math.sin(f*y)/v,r=Math.sin(r*y)/v}var g=r*p;if(n=n*f+u*g,s=s*f+h*g,a=a*f+c*g,o=o*f+l*g,f===1-r){var x=1/Math.sqrt(n*n+s*s+a*a+o*o);n*=x,s*=x,a*=x,o*=x}}t.x=n,t.y=s,t.z=a,t.w=o},t}(),Ca="not_implement",Sa=function(){function t(t){this.onCreate(t)}var e=t.prototype;return e.onCreate=function(t){throw new Error(Ca)},e.getIntegrateValue=function(t,e,i){throw new Error(Ca)},e.getIntegrateByTime=function(t,e){throw new Error(Ca)},e.getValue=function(t){throw new Error(Ca)},e.getMaxTime=function(){throw new Error(Ca)},e.toUniform=function(t){throw new Error(Ca)},e.map=function(t){throw new Error(Ca)},e.scaleXCoord=function(t){return this},e.toData=function(){throw new Error(Ca)},t.getAllData=function(t,e){for(var i=new(e?Ks:Float32Array)(4*t.index),r=0,n=0,s=t.curves;r<s.length;r++){var a=s[r].toData();i.set(a,n),n+=a.length}return e?i.data:i},t}(),Oa=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.onCreate=function(t){this.value=t},i.getIntegrateValue=function(t,e,i){return this.value*(e-t)},i.getIntegrateByTime=function(t,e){return.5*this.value*(e*e-t*t)},i.getValue=function(t){return this.value},i.toUniform=function(){return new Float32Array([0,this.value,0,0])},i.map=function(t){var e=this.value;return this.value=t(e),this},i.getMaxTime=function(){return 0},e}(Sa),Ra=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.onCreate=function(t){this.items=t},i.getValue=function(t){var e=this.items;return e[Math.floor(Math.random()*e.length)]},i.map=function(t){return this.items=this.items.map(t),this},e}(Sa),Ma=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.onCreate=function(t){this.min=t[0],this.max=t[1]},i.getValue=function(t,e){var i=null!=e?e:Math.random();return this.min+i*(this.max-this.min)},i.getIntegrateValue=function(t,e,i){var r=null!=i?i:1;return(this.min+r*(this.max-this.min))*(e-t)},i.toUniform=function(){return new Float32Array([4,this.min,this.max,0])},i.map=function(t){return this.min=t(this.min),this.max=t(this.max),this},e}(Sa),Ia=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.onCreate=function(t){this.min=t[0],this.max=t[1]},i.getValue=function(t){for(var e=this.min,i=this.max,r=[],n=0;n<e.length;n++){var s=Math.random();r[n]=e[n]*(1-s)+i[n]*s}return r},i.map=function(t){return this.min=this.min.map(t),this.max=this.max.map(t),this},e}(Sa),Pa=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.onCreate=function(t){this.min=t[0],this.max=t[1],this.xCoord=1},i.getValue=function(t){return t/=this.xCoord,this.min*(1-t)+this.max*t},i.toUniform=function(){return new Float32Array([1,this.min,this.max,this.xCoord])},i.getIntegrateValue=function(t,e,i){void 0===i&&(i=1);var r=this.min,n=this.max,s=this.xCoord*i;return((r+e/s*(n-r)+r)*e-(r+t/s*(n-r)+r)*t)/2},i.getIntegrateByTime=function(t,e){return Ua(e,0,this.xCoord,this.min,this.max)-Ua(t,0,this.xCoord,this.min,this.max)},i.map=function(t){return this.min=t(this.min),this.max=t(this.max),this},i.scaleXCoord=function(t){return this.xCoord=t,this},e}(Sa),La=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.onCreate=function(t){this.stops=j(t)},i.getStops=function(){return this.stops},i.getValue=function(t){for(var e=this.stops,i=e.length-1,r=0;r<i;r++){var n=e[r],s=e[r+1];if(n.stop<=t&&s.stop>t){var a=(t-n.stop)/(s.stop-n.stop);return X(n.color,s.color,a,!0)}}return e[i].color.slice()},e}(Sa),Fa=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.onCreate=function(t){this.keys=t.map((function(t){return t.slice?t.slice(0,2):[t.time,t.value]})).sort((function(t,e){return t[0]-e[0]}));var e=this.keys[this.keys.length-1];e[0]<1&&this.keys.push([1,e[1]]);var i=this.keys[0];i[0]>0&&this.keys.unshift([0,i[1]]),this.isLineSeg=!0},i.getValue=function(t){var e=this.keys;if(t<e[0][0])return e[0][1];for(var i=e.length-1,r=0;r<i;r++){var n=e[r],s=e[r+1],a=n[0],o=s[0];if(t>=a&&t<=o){var u=(t-a)/(o-a),h=n[1];return h+u*(s[1]-h)}}return e[i][1]},i.getIntegrateValue=function(t,e,i){return void 0===i&&(i=1),(this.integrate(e,!1)-this.integrate(t,!1))*i},i.getIntegrateByTime=function(t,e){return this.integrate(e,!0)-this.integrate(t,!0)},i.integrate=function(t,e){var i=this.keys;if(t<=i[0][0])return 0;for(var r=0,n=i.length-1,s=e?Ua:za,a=0;a<n;a++){var o=i[a],u=i[a+1],h=o[0],c=u[0];if(t>h&&t<=c)return r+s(t,h,c,o[1],u[1]);r+=s(c,h,c,o[1],u[1])}return r},i.toData=function(){for(var t=this.keys,e=new Float32Array(4*Math.ceil(t.length/2)),i=0,r=0;i<t.length;i++,r+=2)e.set(t[i],r);return e.set(t[t.length-1],e.length-2),e},i.toUniform=function(t){var e=t.index,i=this.keys,r=Math.ceil(i.length/2);return t.lineSegCount+=r,t.curves.push(this),t.index+=r,t.max=Math.max(t.max,r),new Float32Array([3,e,r,0])},i.map=function(t){return this.keys.forEach((function(e){return e[1]=t(e[1])})),this},i.scaleXCoord=function(t){return this.keys.forEach((function(e){return e[0]=t*e[0]})),this},e}(Sa),Va=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.onCreate=function(t){var e=t;this.curveMap={},this.keys=[];for(var i=0;i<e.length-1;i++){var r=wa(e[i],e[i+1]),n=r.points,s=r.curve,a=r.timeInterval,o=r.valueInterval,u=n[0],h=n[n.length-1];this.keys.push([].concat(u.toArray(),n[1].toArray())),this.keys.push([].concat(h.toArray(),n[2].toArray())),this.curveMap[u.x+"&"+h.x]={points:n,timeInterval:a,valueInterval:o,curve:s,timeStart:Number(u.x),timeEnd:Number(h.x)}}this.startKeyframe=e[0],this.endKeyframe=e[e.length-1],this.keyTimeData=Object.keys(this.curveMap)},i.getValue=function(t){var e=0,i=this.keyTimeData,r=this.curveMap[i[0]].timeStart,n=this.curveMap[i[i.length-1]].timeEnd;if(t<=r)return la.getPointIndexInCurve(this.startKeyframe,la.pointIndexCache),this.startKeyframe[1][la.pointIndexCache.yIndex];if(t>=n)return la.getPointIndexInCurve(this.endKeyframe,la.pointIndexCache),this.endKeyframe[1][la.pointIndexCache.yIndex];for(var s=0;s<i.length;s++){var a=this.curveMap[i[s]].timeStart,o=this.curveMap[i[s]].timeEnd;if(t>=Number(a)&&t<Number(o)){e=this.getCurveValue(i[s],t);break}}return e},i.getIntegrateValue=function(t,e,i){void 0===i&&(i=1);var r=(e-t)/i,n=0,s=Object.keys(this.curveMap);if(r<=this.curveMap[s[0]].timeStart)return 0;for(var a=0;a<s.length;a++){var o=this.curveMap[s[a]].timeStart,u=this.curveMap[s[a]].timeEnd;if(r>=Number(u)&&(n+=i*this.getCurveIntegrateValue(s[a],Number(u))),r>=Number(o)&&r<Number(u)){n+=i*this.getCurveIntegrateValue(s[a],r);break}}return n},i.getIntegrateByTime=function(t,e){return this.getIntegrateValue(0,e)-this.getIntegrateValue(0,t)},i.getCurveIntegrateValue=function(t,e){for(var i=this.curveMap[t],r=i.points[0],n=i.timeInterval,s=i.valueInterval,a=0,o=(e-r.x)/20,u=0;u<=20;u++){var h=u*o/n,c=r.y+s*i.curve.getValue(h);a+=0===u||20===u?c:u%2==1?4*c:2*c}return a*=o/3},i.getCurveValue=function(t,e){var i=this.curveMap[t],r=i.points[0],n=i.timeInterval,s=i.valueInterval,a=(e-r.x)/n,o=i.curve.getValue(a);return r.y+s*o},i.toUniform=function(t){var e=t.index,i=this.keys.length;return t.curves.push(this),t.index=e+i,t.max=Math.max(t.max,i),t.curveCount+=i,new Float32Array([5,e+1/i,e,i])},i.toData=function(){for(var t=this.keys,e=new Float32Array(4*t.length),i=0,r=0;i<t.length;i++,r+=4)e.set(t[i],r);return e},i.getMaxTime=function(){var t=this.keyTimeData;return this.curveMap[t[t.length-1]].timeEnd},e}(Sa),Na=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.onCreate=function(t){this.keys=t[0],this.values=t[1]},i.getValue=function(t){for(var e=this.keys,i=this.values,r=0;r<e.length-1;r++){var n=e[r],s=e[r+1];if(n[0]<=t&&s[0]>=t){var a=s[1]-n[1],o=void 0;if(0===a)o=(t-n[0])/(s[0]-n[0]);else o=(Ba(t,n,s)-n[1])/a;return this.calculateVec(r,o)}}return t<=e[0][0]?i[0].slice():i[i.length-1].slice()},i.calculateVec=function(t,e){for(var i=this.values[t],r=this.values[t+1],n=[0,0,0],s=0;s<i.length;s++)n[s]=i[s]*(1-e)+r[s]*e;return n},e}(Sa),Da=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.onCreate=function(t){var e=t[0],i=t[1],r=t[2];if(this.curveSegments={},r.length){for(var n=0;n<e.length-1;n++){var s=e[n],a=e[n+1],o=new Qe(i[n][0],i[n][1],i[n][2]),u=new Qe(i[n+1][0],i[n+1][1],i[n+1][2]),h=new Qe(r[2*n][0],r[2*n][1],r[2*n][2]),c=new Qe(r[2*n+1][0],r[2*n+1][1],r[2*n+1][2]),l=wa(s,a),f=l.points,d=l.curve,p=l.timeInterval,m=l.valueInterval,v=f[0],y=f[f.length-1],g=new Ta(o,u,h,c);this.curveSegments[v.x+"&"+y.x]={points:f,timeInterval:p,valueInterval:m,easingCurve:d,pathCurve:g,timeStart:Number(v.x),timeEnd:Number(y.x)}}this.keyTimeData=Object.keys(this.curveSegments)}},i.getValue=function(t){var e=ca(t,5),i=0,r=new Qe,n=this.keyTimeData;if(!n.length)return r;var s=this.curveSegments[n[0]].timeStart,a=this.curveSegments[n[n.length-1]].timeEnd;if(e<=s)return r=this.curveSegments[n[0]].pathCurve.getPointInPercent(0);if(e>=a)return r=this.curveSegments[n[n.length-1]].pathCurve.getPointInPercent(1);for(var o=0;o<n.length;o++){var u=this.curveSegments[n[o]].timeStart,h=this.curveSegments[n[o]].timeEnd;if(e>=Number(u)&&e<Number(h)){var c=this.curveSegments[n[o]].pathCurve;i=this.getPercValue(n[o],e),r=c.getPointInPercent(i)}}return r},i.getPercValue=function(t,e){var i=this.curveSegments[t],r=i.points[0],n=i.timeInterval,s=ca((e-r.x)/n,4);return qe(i.easingCurve.getValue(s),0,1)},i.getMaxTime=function(){var t=this.keyTimeData;return this.curveSegments[t[t.length-1]].timeEnd},e}(Sa),ka=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.onCreate=function(t){var e=t[0],i=t[1],r=t[2];if(this.curveSegments={},r.length)for(var n=0;n<e.length-1;n++){var s=e[n],a=e[n+1],o=ri.fromArray(i[n]),u=ri.fromArray(i[n+1]),h=ri.fromArray(r[2*n]),c=ri.fromArray(r[2*n+1]),l=wa(s,a),f=l.points,d=l.curve,p=l.timeInterval,m=l.valueInterval,v=f[0],y=f[f.length-1],g=new Ea(o,u,h,c);this.curveSegments[v.x+"&"+y.x]={points:f,timeInterval:p,valueInterval:m,easingCurve:d,pathCurve:g}}},i.getValue=function(t){var e=0,i=ca(t,5),r=Object.keys(this.curveSegments),n=Number(r[0].split("&")[0]),s=Number(r[r.length-1].split("&")[1]);if(i<=n)return this.curveSegments[r[0]].pathCurve.getPointInPercent(0);if(i>=s)return this.curveSegments[r[r.length-1]].pathCurve.getPointInPercent(1);for(var a=0;a<r.length;a++){var o=r[a].split("&"),u=o[0],h=o[1];if(i>=Number(u)&&i<Number(h)){var c=this.curveSegments[r[a]].pathCurve;return e=this.getPercValue(r[a],i),c.getPointInPercent(e)}}return this.curveSegments[r[0]].pathCurve.getPointInPercent(0)},i.getPercValue=function(t,e){var i=this.curveSegments[t],r=i.points[0],n=i.timeInterval,s=ca((e-r.x)/n,4);return qe(i.easingCurve.getValue(s),0,1)},i.getMaxTime=function(){var t=Object.keys(this.curveSegments);return Number(t[t.length-1].split("&")[1])},e}(Sa);function za(t,e,i,r,n){var s=t-e;return(r+r+(n-r)*s/(i-e))*s/2}function Ua(t,e,i,r,n){var s=t*t,a=e*e;return(2*(s*t)*(r-n)+3*s*(e*n-i*r)-a*e*(2*r+n)+3*a*i*r)/(6*(e-i))}function Ba(t,e,i){var r=i[0]-e[0],n=e[3]*r,s=i[2]*r,a=(t-e[0])/r,o=a*a,u=o*a,h=u-2*o+a,c=u-o,l=-2*u+3*o;return(2*u-3*o+1)*e[1]+h*n+c*s+l*i[1]}function Ga(t,e){if(e){var i=e[0],r=e[1];if(i===$t.CURVE){t.curves.push(r);var n=r.length;r[0][0]>0&&n++,r[r.length-1][0]<1&&n++,t.index+=n,t.max=Math.max(t.max,n),t.curveCount+=n}else if(i===$t.LINE){var s=r.length;if(2===s&&0===r[0][0]&&1===r[1][0])return;r[0][0]>0&&s++,r[r.length-1][0]<1&&s++;var a=Math.ceil(s/2);t.lineSegCount+=a,t.curves.push(r),t.index+=a,t.max=Math.max(t.max,a)}else if(i===$t.BEZIER_CURVE){var o=r.length-1;t.index+=2*o,t.curves.push(r),t.max=Math.max(t.max,2*o),t.curveCount+=2*o}}}function ja(){return{curves:[],index:0,max:0,lineSegCount:0,curveCount:0}}function Xa(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Xa=function(){return!!t})()}function Ha(t,e,i){return Ha=Xa()?Reflect.construct:function(t,e,i){var r=[null];r.push.apply(r,e);var n=new(Function.bind.apply(t,r));return i&&Kt(n,i.prototype),n},Ha.apply(null,arguments)}var Ya,Wa=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).value=new Je,e}Qt(e,t);var i=e.prototype;return i.onCreate=function(t){this.xCurve=Ka(t[0]),this.yCurve=Ka(t[1]),this.zCurve=Ka(t[2]),this.wCurve=Ka(t[3])},i.getValue=function(t){var e=this.xCurve.getValue(t),i=this.yCurve.getValue(t),r=this.zCurve.getValue(t),n=this.wCurve.getValue(t);return this.value.set(e,i,r,n),this.value},e}(Sa),Za=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).value=new Ke,e}Qt(e,t);var i=e.prototype;return i.onCreate=function(t){this.xCurve=Ka(t[0]),this.yCurve=Ka(t[1])},i.getValue=function(t){var e=this.xCurve.getValue(t),i=this.yCurve.getValue(t);return this.value.set(e,i),this.value},e}(Sa),qa=((Ya={})[$t.RANDOM]=function(t){return A(t[0],Array)?new Ia(t):new Ma(t)},Ya[$t.CONSTANT]=function(t){return new Oa(t)},Ya[$t.CONSTANT_VEC2]=function(t){return new Oa(t)},Ya[$t.CONSTANT_VEC3]=function(t){return new Oa(t)},Ya[$t.CONSTANT_VEC4]=function(t){return new Oa(t)},Ya[$t.RGBA_COLOR]=function(t){return new Oa(t)},Ya[$t.COLORS]=function(t){return new Ra(t.map((function(t){return B(t,!1)})))},Ya[$t.LINE]=function(t){return 2===t.length&&0===t[0][0]&&1===t[1][0]?new Pa([t[0][1],t[1][1]]):new Fa(t)},Ya[$t.GRADIENT_COLOR]=function(t){return new La(t)},Ya[$t.LINEAR_PATH]=function(t){return new Na(t)},Ya[$t.BEZIER_CURVE]=function(t){return 1===t.length?new Oa(t[0][1][1]):new Va(t)},Ya[$t.BEZIER_CURVE_PATH]=function(t){return 1===t[0].length?new Oa(Ha(Qe,[].concat(t[1][0]))):new Da(t)},Ya[$t.BEZIER_CURVE_QUAT]=function(t){return 1===t[0].length?new Oa(Ha(ri,[].concat(t[1][0]))):new ka(t)},Ya[$t.COLOR_CURVE]=function(t){return new Qa(t)},Ya[$t.VECTOR4_CURVE]=function(t){return new Wa(t)},Ya[$t.VECTOR2_CURVE]=function(t){return new Za(t)},Ya);function Ka(t){if(!t||!isNaN(+t))return new Oa(t||0);if(A(t,Sa))return t;if(xt(qa[t[0]]))return qa[t[0]](t[1]);throw new Error("ValueType: "+t[0]+" is not supported, see "+Cs["ValueType: 21/22 is not supported"]+".")}var Qa=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).value=new ii,e}Qt(e,t);var i=e.prototype;return i.onCreate=function(t){this.rCurve=Ka(t[0]),this.gCurve=Ka(t[1]),this.bCurve=Ka(t[2]),this.aCurve=Ka(t[3])},i.getValue=function(t){var e=this.rCurve.getValue(t),i=this.gCurve.getValue(t),r=this.bCurve.getValue(t),n=this.aCurve.getValue(t);return this.value.set(e,i,r,n),this.value},e}(Sa),Ja=1,$a=function(){function t(t,e,i,r){this.transform=i,this.engine=r,this.color=t.options.previewColor;var n=this.createMaterial(e),s=this.createGeometry();this.mesh=this.createMesh(s,n),this.updateMesh()}var e=t.prototype;return e.updateMesh=function(){var t=this.mesh.material,e=t.getVector2("uSize").clone(),i=t.getVector4("uPos").clone(),r=new Qe,n=new ri,s=this.transform.scale.clone();this.transform.assignWorldTRS(r,n,s),e.x=s.x,e.y=s.y,i.x=r.x,i.y=r.y,i.z=r.z,t.setVector2("uSize",e),t.setVector4("uPos",i),t.setQuaternion("uQuat",n)},e.createMaterial=function(t){var e,i=[["ENV_EDITOR",(null==(e=this.engine.renderer)?void 0:e.env)===As]],r=Ka(this.color).getValue(0),n={shader:{vertex:"\nprecision highp float;\n\nattribute vec2 aPoint;\nuniform vec4 uPos;\nuniform vec2 uSize;\nuniform vec4 uQuat;\nuniform vec4 uColor;\nuniform mat4 effects_ObjectToWorld;\nuniform mat4 effects_MatrixInvV;\nuniform mat4 effects_MatrixVP;\nvarying vec4 vColor;\n#ifdef ENV_EDITOR\n uniform vec4 uEditorTransform;\n#endif\n\nvec3 rotateByQuat(vec3 a, vec4 quat){\n vec3 qvec = quat.xyz;\n vec3 uv = cross(qvec, a);\n vec3 uuv = cross(qvec, uv) * 2.;\n return a +(uv * 2. * quat.w + uuv);\n}\n\nvoid main() {\n vec4 _pos = uPos;\n vec3 point = rotateByQuat(vec3(aPoint.xy * uSize, 0.),uQuat);\n vec4 pos = vec4(_pos.xyz, 1.0);\n pos = effects_ObjectToWorld * pos;\n pos.xyz += effects_MatrixInvV[0].xyz * point.x+ effects_MatrixInvV[1].xyz * point.y;\n gl_Position = effects_MatrixVP * pos;\n vColor = uColor;\n #ifdef ENV_EDITOR\n gl_Position = vec4(gl_Position.xy * uEditorTransform.xy + uEditorTransform.zw * gl_Position.w, gl_Position.zw);\n #endif\n}\n",fragment:"\nprecision highp float;\n\n#define fragColor gl_FragColor\n\nvarying vec4 vColor;\nvoid main() {\n gl_FragColor = vColor*vColor.a;\n}\n",glslVersion:ur.GLSL1,cacheId:t.cachePrefix+"_effects_interact",macros:i},uniformSemantics:{effects_MatrixVP:"VIEWPROJECTION",effects_MatrixInvV:"VIEWINVERSE",effects_ObjectToWorld:"MODEL",uEditorTransform:"EDITOR_TRANSFORM"}},s=cr.create(this.engine,n);return s.blending=!0,s.depthTest=!1,s.setVector4("uPos",new Je(0,0,0,0)),s.setVector2("uSize",new Ke(1,1)),s.setVector4("uColor",new Je(r[0]/255,r[1]/255,r[2]/255,r[3])),s.setQuaternion("uQuat",new ri(0,0,0,0)),s},e.createGeometry=function(){var t=new Uint8Array([0,1,1,2,2,3,3,0]);return Cr.create(this.engine,{attributes:{aPoint:{size:2,offset:0,stride:2*Float32Array.BYTES_PER_ELEMENT,data:new Float32Array([-.5,.5,.5,.5,.5,-.5,-.5,-.5])}},drawCount:t.length,indices:{data:t},mode:fi.LINES,maxVertex:4})},e.createMesh=function(t,e){return Dr.create(this.engine,{name:"Interact_preview"+Ja++,priority:0,worldMatrix:ni.fromIdentity(),geometry:t,material:e})},t}(),to=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).downgrade=.95,e.dragRatio=[1,1],e.dragRange={dxRange:[0,0],dyRange:[0,0]},e.duringPlay=!1,e._interactive=!0,e.lastTime=-1,e.getHitTestParams=function(t){if(e.clickable){var i=e.item.props.content.options.behavior,r=e.getBoundingBox();return r?{type:r.type,triangles:r.area,behavior:i}:void 0}},e}Qt(e,t);var i=e.prototype;return i.getDragRangeX=function(){return this.dragRange.dxRange},i.setDragRangeX=function(t,e){this.dragRange.dxRange=[t,e]},i.getDragRangeY=function(){return this.dragRange.dyRange},i.setDragRangeY=function(t,e){this.dragRange.dyRange=[t,e]},i.onStart=function(){var t=this.item.props.content.options,e=this.item.engine.renderer.env,i=this.item.composition,r=this.interactData.options,n=r.type,s=r.showPreview;if(n===Gt.CLICK&&(this.clickable=!0,s&&e===As)){var a=null==i?void 0:i.getRendererOptions();void 0!==a&&(this.previewContent=new $a(this.item.props.content,a,this.transform,this.engine))}t.type===Gt.DRAG&&(e!==As||t.enableInEditor)&&(null==i?void 0:i.event)&&this.beginDragTarget(t,i.event),this.previewContent&&(this.previewContent.mesh.item=this.item,this.materials=this.previewContent.mesh.materials),this.item.getHitTestParams=this.getHitTestParams},i.onDisable=function(){t.prototype.onDisable.call(this),this.item&&this.item.composition&&(this.duringPlay&&!this.item.transform.getValid()&&(this.item.composition.removeInteractiveItem(this.item,this.item.props.content.options.type),this.duringPlay=!1),this.clickable=!1,this.endDragTarget())},i.onEnable=function(){t.prototype.onEnable.call(this);var e=this.interactData.options.type,i=this.item.engine.renderer.env;if(e===Gt.CLICK)this.clickable=!0;else if(e===Gt.DRAG){var r,n=this.interactData.options,s=n.enableInEditor;if(i!==As||s)(null==(r=this.item.composition)?void 0:r.event)&&this.beginDragTarget(n,this.item.composition.event)}},i.onUpdate=function(t){var e;if(this.duringPlay=!0,this.lastTime<=this.item.time){if(this.item.time>=0&&this.lastTime<0){var i,r=this.item.props.content.options;null==(i=this.item.composition)||i.addInteractiveItem(this.item,r.type)}}else if(this.item.time>=0){var n,s=this.item.props.content.options;null==(n=this.item.composition)||n.addInteractiveItem(this.item,s.type)}this.lastTime=this.item.time,null==(e=this.previewContent)||e.updateMesh(),this.dragEvent&&this.bouncingArg&&(this.bouncingArg.vx*=this.downgrade,this.bouncingArg.vy*=this.downgrade,this.bouncingArg.dy+=this.bouncingArg.vy,this.bouncingArg.dx+=this.bouncingArg.vx,eo(this.bouncingArg)?(this.dragEvent=null,this.bouncingArg=null):this.handleDragMove(this.dragEvent,this.bouncingArg))},i.render=function(t){this.previewContent&&this.previewContent.mesh.render(t)},i.onDestroy=function(){var t;null==(t=this.previewContent)||t.mesh.dispose()},i.endDragTarget=function(){},i.handleDragMove=function(t,e){if((null==t?void 0:t.cameraParam)&&this.canInteract()&&this.item.composition){var i,r,n=t.cameraParam,s=n.position,a=n.fov,o=e.dy,u=e.dx*e.width/e.height,h=s[2],c=Math.tan(a*Math.PI/180/2)*Math.abs(h),l=o*c,f=u*c,d=this.dragRange,p=d.dxRange,m=d.dyRange,v=s[0]-this.dragRatio[0]*f,y=s[1]-this.dragRatio[1]*l,g=p[0],x=p[1],b=m[0],T=m[1];if(v=qe(v,g,x),y=qe(y,b,T),v!==g&&v!==x&&g!==x)null==(i=e.origin)||i.preventDefault();if(y!==b&&y!==T&&b!==T)null==(r=e.origin)||r.preventDefault();this.item.composition.camera.position=new Qe(v,y,h)}},i.beginDragTarget=function(t,i){var r=this;if("camera"===t.target){var n,s={touchstart:function(t){var e;if(r.canInteract()){r.dragEvent=null,r.bouncingArg=null;var i=null==(e=r.item.composition)?void 0:e.camera;n={x:t.x,y:t.y,cameraParam:{position:(null==i?void 0:i.position.toArray())||[0,0,8],fov:(null==i?void 0:i.fov)||60}}}},touchmove:function(t){r.handleDragMove(n,t),r.bouncingArg=t},touchend:function(t){if(r.canInteract()){var e=r.bouncingArg;if(!eo(e,3)&&e){e.vx*=5,e.vy*=5,r.dragEvent=_i({},n)}n=null}}};Object.keys(s).forEach((function(t){i.addEventListener(t,s[t])})),s.touchmove({dx:0,dy:0,width:1,height:1}),this.item.getComponent(e).endDragTarget=function(){Object.keys(s).forEach((function(t){i.removeEventListener(t,s[t])}))}}},i.getBoundingBox=function(){var t=this.transform.getWorldMatrix(),e=ua(Qe.ZERO,.5*this.transform.size.x,.5*this.transform.size.y);return e.forEach((function(e){t.transformPoint(e.p0),t.transformPoint(e.p1),t.transformPoint(e.p2)})),{type:ks.triangle,area:e}},i.fromData=function(e){if(t.prototype.fromData.call(this,e),this.interactData=e,e.options.type===Gt.DRAG){var i=e.options;i.dxRange&&(this.dragRange.dxRange=i.dxRange),i.dyRange&&(this.dragRange.dyRange=i.dyRange)}},i.canInteract=function(){var t;return Boolean(null==(t=this.item.composition)?void 0:t.interactive)&&this._interactive},Pe(e,[{key:"interactive",get:function(){return this._interactive},set:function(t){this._interactive=t,t||(this.bouncingArg=null)}}]),e}(Ge);function eo(t,e){var i=1e-5*(e||1);return t&&Math.abs(t.vx||0)<i&&Math.abs(t.vy||0)<i}to=S([Ne(_e.InteractComponent)],to);var io,ro=function(){function t(){this.triangles=[],this.worldMatrix=new ni,this.assemblyTriangles=function(t,e,i,r,n){for(var s=i;s<r;s+=3){var a=3*e[s],o=3*e[s+1],u=3*e[s+2],h={x:t[a],y:t[a+1],z:t[a+2]},c={x:t[o],y:t[o+1],z:t[o+2]},l={x:t[u],y:t[u+1],z:t[u+2]};n.push({p0:h,p1:c,p2:l})}}}var e=t.prototype;return e.getBoundingBoxData=function(){return this.applyWorldMatrix(this.boundingBoxData.area),this.boundingBoxData},e.getBoundingBox=function(){for(var t,e=-Number.MAX_VALUE,i=-Number.MAX_VALUE,r=Number.MAX_VALUE,n=Number.MAX_VALUE,s=w(this.boundingBoxData.area);!(t=s()).done;){var a=t.value;e=Math.max(a.p0.x,a.p1.x,a.p2.x,e),i=Math.max(a.p0.y,a.p1.y,a.p2.y,i),r=Math.min(a.p0.x,a.p1.x,a.p2.x,r),n=Math.min(a.p0.y,a.p1.y,a.p2.y,n)}var o=[],u=new Qe(r,i,0),h=new Qe(e,i,0),c=new Qe(e,n,0),l=new Qe(r,n,0);return o.push({p0:u,p1:h,p2:c}),o.push({p0:u,p1:c,p2:l}),this.applyWorldMatrix(o),{type:ks.triangle,area:o}},e.setGeometry=function(t,e){this.triangles=this.geometryToTriangles(t);for(var i,r=[],n=w(this.triangles);!(i=n()).done;){var s=i.value;r.push({p0:s.p0,p1:s.p1,p2:s.p2})}e&&this.worldMatrix.copyFrom(e),this.boundingBoxData={type:ks.triangle,area:r}},e.geometryToTriangles=function(t){var e=t.getIndexData(),i=t.getAttributeData("aPos"),r=[];if(!e||!i)return r;if(0===t.subMeshes.length)this.assemblyTriangles(i,e,0,e.length,r);else for(var n,s=w(t.subMeshes);!(n=s()).done;){var a=n.value;if(void 0!==a.indexCount){var o=e.BYTES_PER_ELEMENT,u=a.offset/o,h=u+a.indexCount;this.assemblyTriangles(i,e,u,h,r)}}return r},e.applyWorldMatrix=function(t){var e=this;return t.forEach((function(t){t.p0=e.worldMatrix.transformPoint(t.p0,new Qe),t.p1=e.worldMatrix.transformPoint(t.p1,new Qe),t.p2=e.worldMatrix.transformPoint(t.p2,new Qe)})),t},t}(),no=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).name="sprite",e}return Qt(e,t),e}(qt),so=function(){function t(){this.playableOutputs=[],this.playables=[]}var e=t.prototype;return e.evaluate=function(t){for(var e,i=w(this.playableOutputs);!(e=i()).done;){e.value.context.deltaTime=t}for(var r,n=w(this.playableOutputs);!(r=n()).done;){var s=r.value;this.prepareFrameWithRoot(s)}for(var a,o=w(this.playableOutputs);!(a=o()).done;){var u=a.value;this.processFrameWithRoot(u)}},e.addOutput=function(t){this.playableOutputs.push(t)},e.addPlayable=function(t){this.playables.push(t)},e.processFrameWithRoot=function(t){t.sourcePlayable.processFrame(t.context),t.processFrame()},e.prepareFrameWithRoot=function(t){t.prepareFrame(),t.sourcePlayable.prepareFrame(t.context)},e.updatePlayableTime=function(t,e){0===t.getPlayState()&&t.setTime(t.getTime()+e)},t}(),ao=function(){function t(t,e){this.onPlayablePlayFlag=!0,this.onPlayablePauseFlag=!1,this.duration=0,this.destroyed=!1,this.playState=0,this.time=0,t.addPlayable(this)}var e=t.prototype;return e.play=function(){switch(this.playState){case 0:break;case 1:this.playState=0,this.onPlayablePlayFlag=!0,this.onPlayablePauseFlag=!1}},e.pause=function(){if(0===this.playState)this.playState=1,this.onPlayablePauseFlag=!0,this.onPlayablePlayFlag=!1},e.setTime=function(t){this.time=t},e.getTime=function(){return this.time},e.setDuration=function(t){this.duration=t},e.getDuration=function(){return this.duration},e.getPlayState=function(){return this.playState},e.prepareFrame=function(t){},e.processFrame=function(t){},e.onPlayableDestroy=function(){},e.dispose=function(){this.destroyed||(this.onPlayableDestroy(),this.destroyed=!0)},t}(),oo=function(){function t(){this.context={deltaTime:0,output:this}}var e=t.prototype;return e.setSourcePlayable=function(t){this.sourcePlayable=t},e.setUserData=function(t){this.userData=t},e.getUserData=function(){return this.userData},e.prepareFrame=function(){},e.processFrame=function(){},t}(),uo=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e}(ze);function ho(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}!function(t){t[t.Playing=0]="Playing",t[t.Paused=1]="Paused"}(io||(io={}));var co=new ri,lo=1,fo=function(){function t(t,e){void 0===t&&(t={}),this.taggedProperties={},this.position=new Qe(0,0,0),this.quat=new ri(0,0,0,1),this.rotation=new Or(0,0,0),this.scale=new Qe(1,1,1),this.anchor=new Qe(0,0,0),this.size=new Ke(1,1),this.children=[],this.worldMatrix=ni.fromIdentity(),this.localMatrix=ni.fromIdentity(),this.valid=!0,this.dirtyFlags={localData:!1,localMatrix:!1,worldMatrix:!1,parentMatrix:!1},this.worldTRSCache={position:new Qe(0,0,0),quat:new ri(0,0,0,1),scale:new Qe(1,1,1)},this.name="transform_"+lo++,t&&this.setTransform(t),e&&(this.parentTransform=e),void 0!==t.valid&&this.setValid(t.valid)}var e=t.prototype;return e.setPosition=function(t,e,i){this.position.x===t&&this.position.y===e&&this.position.z===i||(this.position.x=t,this.position.y=e,this.position.z=i,this.dirtyFlags.localData=!0,this.dispatchValueChange())},e.translate=function(t,e,i){0===t&&0===e&&0===i||(this.position.x+=t,this.position.y+=e,this.position.z+=i,this.dirtyFlags.localData=!0,this.dispatchValueChange())},e.setRotation=function(t,e,i){this.rotation.x===t&&this.rotation.y===e&&this.rotation.z===i||(this.rotation.x=t,this.rotation.y=e,this.rotation.z=i,this.quat.setFromEuler(this.rotation),this.quat.conjugate(),this.dirtyFlags.localData=!0,this.dispatchValueChange())},e.setQuaternion=function(t,e,i,r){this.quat.x===t&&this.quat.y===e&&this.quat.z===i&&this.quat.w===r||(this.quat.x=t,this.quat.y=e,this.quat.z=i,this.quat.w=r,this.rotation.setFromQuaternion(this.quat),this.dirtyFlags.localData=!0,this.dispatchValueChange())},e.setScale=function(t,e,i){this.scale.x===t&&this.scale.y===e&&this.scale.z===i||(this.scale.x=t,this.scale.y=e,this.scale.z=i,this.dirtyFlags.localData=!0,this.dispatchValueChange())},e.setSize=function(t,e){this.size.x===t&&this.size.y===e||(this.size.x=t,this.size.y=e,this.dirtyFlags.localData=!0,this.dispatchValueChange())},e.rotateByQuat=function(t){this.quat.multiply(t),this.rotation.setFromQuaternion(this.quat),this.dirtyFlags.localData=!0,this.dispatchValueChange()},e.scaleBy=function(t,e,i){this.scale.x*=t,this.scale.y*=e,this.scale.z*=i,this.dirtyFlags.localData=!0,this.dispatchValueChange()},e.setAnchor=function(t,e){this.anchor.x===t&&this.anchor.y===e||(this.anchor.x=t,this.anchor.y=e,this.dirtyFlags.localData=!0,this.dispatchValueChange())},e.setTransform=function(t,e){var i=t.position,r=t.rotation,n=t.scale,s=t.size,a=t.quat,o=t.name,u=t.anchor;if(o&&(this.name=o),i&&(A(i,Qe)?this.setPosition(i.x,i.y,i.z):this.setPosition(i[0],i[1],i[2])),a)A(a,ri)?this.setQuaternion(a.x,a.y,a.z,a.w):this.setQuaternion(a[0],a[1],a[2],a[3]);else if(r){var h=e?-1:1;A(r,Or)?this.setRotation(r.x*h,r.y*h,r.z*h):this.setRotation(r[0]*h,r[1]*h,r[2]*h)}n&&(A(n,Qe)?this.setScale(n.x,n.y,n.z):this.setScale(n[0],n[1],n[2])),s&&this.setSize(s.x,s.y),u&&(A(u,Ke)?this.setAnchor(u.x,u.y):this.setAnchor(u[0],u[1]))},e.addChild=function(t){D(this.children,t)},e.removeChild=function(t){k(this.children,t)},e.getRotation=function(){return t.getRotation(this.quat,new Or)},e.getQuaternion=function(){return this.quat},e.updateLocalMatrix=function(){this.valid?(this.dirtyFlags.localData&&(this.localMatrix.compose(this.position,this.quat,this.scale,this.anchor),this.dirtyFlags.localMatrix=!0),this.dirtyFlags.localData=!1):this.localMatrix.isIdentity()||(this.localMatrix.identity(),this.dirtyFlags.localMatrix=!0)},e.getMatrix=function(){return this.updateLocalMatrix(),this.localMatrix},e.getParentMatrix=function(){return this.parent&&(this.parentMatrix=this.parent.getWorldMatrix(),this.dirtyFlags.parentMatrix=this.dirtyFlags.parentMatrix||this.parent.dirtyFlags.localMatrix||this.parent.dirtyFlags.worldMatrix),this.parentMatrix},e.getWorldMatrix=function(){var t=this.getMatrix(),e=this.getParentMatrix();return(this.dirtyFlags.localMatrix||this.dirtyFlags.parentMatrix)&&(e?this.worldMatrix.multiplyMatrices(e,t):this.worldMatrix.copyFrom(t),this.dirtyFlags.worldMatrix=!0,this.dirtyFlags.localMatrix=!1,this.dirtyFlags.parentMatrix=!1),this.worldMatrix},e.getWorldScale=function(){var t=this.worldTRSCache;this.dirtyFlags.worldMatrix&&(this.getWorldMatrix().decompose(t.position,t.quat,t.scale),this.dirtyFlags.worldMatrix=!1);return this.worldTRSCache.scale.clone()},e.getWorldPosition=function(){return this.updateTRSCache(),this.worldTRSCache.position.clone()},e.getWorldRotation=function(){return this.updateTRSCache(),t.getRotation(this.worldTRSCache.quat,new Or)},e.assignWorldTRS=function(t,e,i){this.updateTRSCache(),t&&t.copyFrom(this.worldTRSCache.position),e&&e.copyFrom(this.worldTRSCache.quat),i&&i.copyFrom(this.worldTRSCache.scale)},e.cloneFromMatrix=function(t,e){t.decompose(this.position,this.quat,this.scale),this.rotation.setFromQuaternion(this.quat.clone().conjugate()),e&&e.copyFrom(this.scale),this.dirtyFlags.localData=!0,this.dispatchValueChange()},e.setValid=function(t){this.valid!==t&&(this.valid=t,t?this.dirtyFlags.localData=!0:(this.localMatrix.identity(),this.dirtyFlags.localMatrix=!0),this.dispatchValueChange())},e.getValid=function(){return this.valid},e.toData=function(){var t=this.taggedProperties;return t.position=this.position.clone(),t.eulerHint={x:this.rotation.x,y:this.rotation.y,z:this.rotation.z},t.scale=this.scale.clone(),t},e.fromData=function(t){var e={position:(new Qe).copyFrom(t.position),rotation:new Or(t.eulerHint.x,t.eulerHint.y,t.eulerHint.z),scale:(new Qe).copyFrom(t.scale)};this.setTransform(e)},e.dispose=function(){},e.updateTRSCache=function(){var t=this.getWorldMatrix();if(this.dirtyFlags.worldMatrix){var e=this.worldTRSCache;t.decompose(e.position,e.quat,e.scale),this.dirtyFlags.worldMatrix=!1}},e.dispatchValueChange=function(){this.children.forEach((function(t){t.parentMatrixDirty=!0}))},t.getRotation=function(t,e){var i=co.copyFrom(t);return i.conjugate(),e.setFromQuaternion(i)},Pe(t,[{key:"parentTransform",get:function(){return this.parent},set:function(t){t&&this.parent!==t&&this!==t&&(this.parent&&this.parent.removeChild(this),t.addChild(this),this.parent=t,this.parentMatrixDirty=!0)}},{key:"parentMatrixDirty",get:function(){return this.dirtyFlags.parentMatrix},set:function(t){this.dirtyFlags.parentMatrix!==t&&(this.dirtyFlags.parentMatrix=t,this.dispatchValueChange())}}]),t}(),po=new Qe(1,1,1),mo=function(){function t(t,e){void 0===e&&(e={}),this.name=t,this.transform=new fo,this.viewportMatrix=ni.fromIdentity(),this.viewMatrix=ni.fromIdentity(),this.projectionMatrix=ni.fromIdentity(),this.viewProjectionMatrix=ni.fromIdentity(),this.inverseViewMatrix=ni.fromIdentity(),this.dirty=!0;var i=e.near,r=void 0===i?.1:i,n=e.far,s=void 0===n?20:n,a=e.fov,o=void 0===a?60:a,u=e.aspect,h=void 0===u?1:u,c=e.clipMode,l=void 0===c?Jt.portrait:c,f=e.position,d=void 0===f?[0,0,8]:f,p=e.rotation,m=void 0===p?[0,0,0]:p,v=new Or(m[0],m[1],m[2]),y=(new ri).setFromEuler(v);this.options={near:r,far:s,fov:o,aspect:h,clipMode:l},this.transform.setPosition(d[0],d[1],d[2]),this.transform.setQuaternion(y.x,y.y,y.z,y.w),this.dirty=!0,this.updateMatrix()}var e=t.prototype;return e.setTransform=function(t){this.transform.parentTransform=t.parentTransform,this.transform.cloneFromMatrix(t.getMatrix()),this.dirty=!0},e.setViewportMatrix=function(t){this.viewportMatrix=t.clone(),this.dirty=!0},e.getViewportMatrix=function(){return this.viewportMatrix},e.getViewMatrix=function(){return this.updateMatrix(),this.viewMatrix.clone()},e.getInverseViewMatrix=function(){return this.updateMatrix(),this.inverseViewMatrix.clone()},e.getProjectionMatrix=function(){return this.updateMatrix(),this.projectionMatrix.clone()},e.getInverseProjectionMatrix=function(){var t;return this.updateMatrix(),null==(t=this.inverseProjectionMatrix)?void 0:t.clone()},e.getViewProjectionMatrix=function(){return this.updateMatrix(),this.viewProjectionMatrix.clone()},e.getInverseViewProjectionMatrix=function(){return this.updateMatrix(),this.inverseViewProjectionMatrix||(this.inverseViewProjectionMatrix=this.viewProjectionMatrix.clone(),this.inverseViewProjectionMatrix.invert()),this.inverseViewProjectionMatrix.clone()},e.getModelViewProjection=function(t,e){return t.multiplyMatrices(this.viewProjectionMatrix,e)},e.getInverseVPRatio=function(t){var e=new Qe(this.position.x,this.position.y,t),i=this.getViewProjectionMatrix(),r=this.getInverseViewProjectionMatrix();if(!this.viewportMatrix.isIdentity()){var n=this.viewportMatrix.clone();r.premultiply(n),i.multiply(n.invert())}var s=i.projectPoint(e).z,a=r.projectPoint(new Qe(1,1,s)),o=a.x,u=a.y,h=r.projectPoint(new Qe(-1,-1,s)),c=h.x,l=h.y;return new Qe((o-c)/2,(u-l)/2,0)},e.setQuat=function(t){this.transform.getQuaternion().equals(t)||(this.transform.setQuaternion(t.x,t.y,t.z,t.w),this.dirty=!0)},e.getQuat=function(){return this.transform.quat.clone()},e.getOptions=function(){return _i({},this.options,{position:this.position.clone(),rotation:this.rotation.clone()})},e.copy=function(t){var e=t.near,i=t.far,r=t.fov,n=t.clipMode,s=t.aspect,a=t.position,o=t.rotation;this.near=e,this.far=i,this.fov=r,this.clipMode=n,this.aspect=s,this.position=a,this.rotation=o,this.updateMatrix()},e.updateMatrix=function(){if(this.dirty){var t,e=this.options,i=e.fov,r=e.aspect,n=e.near,s=e.far,a=e.clipMode;this.projectionMatrix.perspective(i*Xe,r,n,s,a===Jt.portrait),this.projectionMatrix.premultiply(this.viewportMatrix),this.inverseViewMatrix.compose(this.position,this.getQuat(),po),this.inverseViewMatrix.premultiply(null!=(t=this.transform.getParentMatrix())?t:ni.IDENTITY),this.viewMatrix.copyFrom(this.inverseViewMatrix).invert(),this.viewProjectionMatrix.multiplyMatrices(this.projectionMatrix,this.viewMatrix),this.inverseViewProjectionMatrix=null,this.dirty=!1}},Pe(t,[{key:"near",get:function(){return this.options.near},set:function(t){this.options.near!==t&&(this.options.near=t,this.dirty=!0)}},{key:"far",get:function(){return this.options.far},set:function(t){this.options.far!==t&&(this.options.far=t,this.dirty=!0)}},{key:"fov",get:function(){return this.options.fov},set:function(t){this.options.fov!==t&&(this.options.fov=t,this.dirty=!0)}},{key:"aspect",get:function(){return this.options.aspect},set:function(t){this.options.aspect!==t&&(this.options.aspect=t,this.dirty=!0)}},{key:"clipMode",get:function(){return this.options.clipMode},set:function(t){void 0!==t&&this.options.clipMode!==t&&(this.options.clipMode=t,this.dirty=!0)}},{key:"position",get:function(){return this.transform.position.clone()},set:function(t){this.transform.position.equals(t)||(this.transform.setPosition(t.x,t.y,t.z),this.dirty=!0)}},{key:"worldPosition",get:function(){return this.transform.getWorldPosition()}},{key:"rotation",get:function(){return this.transform.rotation.clone()},set:function(t){this.transform.rotation.equals(t)||(this.transform.setRotation(t.x,t.y,t.z),this.dirty=!0)}}]),t}(),vo=function(){function t(t){var e=t.time,i=t.interval,r=t.count,n=t.cycles,s=t.probability;this.time=+e||0,this.interval=+i||1,this.count=A(r,Sa)?r:Ka(r),this.cycles=+n||1/0,this.probability=isNaN(s)?1:+s,this.reset()}var e=t.prototype;return e.getGeneratorOptions=function(t,e){if(t-this.time-this.now>this.interval*this.index&&this.internalCycles>0)return this.internalCycles--,this.index++,Math.random()<=this.probability?{index:this.index,total:1/this.interval,count:this.count.getValue(e),cycleIndex:this.cycles-this.internalCycles-1}:null},e.reset=function(){this.internalCycles=this.cycles,this.index=0,this.now=0},e.clone=function(){return new t({time:this.time,interval:this.interval,count:this.count,cycles:this.cycles,probability:this.probability})},t}(),yo=function(t){this.content=t},go=function(){function t(t){this.sort=t,this.length=0}var e=t.prototype;return e.findNodeByContent=function(t){var e=this.first;if(e)do{if(t(e.content))return e}while(e=e.next)},e.insertNode=function(t,e){var i=t.next;t.next=e,e.pre=t,e.next=i,i&&(i.pre=e)},e.shiftNode=function(t){var e=new yo(t);if(this.length++,1===this.length)return this.first=this.last=e;for(var i=this.first;i;){if(!(this.sort(i.content,e.content)<=0))return i.pre?this.insertNode(i.pre,e):(this.first=e,e.next=i,i.pre=e),e;if(!i.next)return this.insertNode(i,e),this.last=e;i=i.next}},e.pushNode=function(t){var e=new yo(t);if(this.length++,1===this.length)return this.last=this.first=e;for(var i=this.last;i;){if(!(this.sort(e.content,i.content)<=0))return this.insertNode(i,e),i===this.last&&(this.last=e),e;if(this.first===i)return i.pre=e,e.next=i,this.first=e;i=i.pre}},e.removeNode=function(t){var e=this.first;if(this.length--,e===t){var i=this.first=e.next;i&&(i.pre=null)}else if((e=this.last)===t){var r=this.last=e.pre;r&&(r.next=null)}else if(t){var n=t.pre,s=t.next;n.next=s,s&&(s.pre=n)}t.pre=null,t.next=null},e.forEach=function(t,e){var i=this.first,r=0;if(i)do{t.call(e||this,i.content,r++)}while(i=i.next)},e.forEachReverse=function(t,e){var i=this.last,r=this.length-1;if(i)do{t.call(e||this,i.content,r--)}while(i=i.pre)},e.getNodeByIndex=function(t){var e=0,i=this.first;if(!i||t>=this.length||t<0)return null;for(;e<t;)i=i.next,e++;return i},t}(),xo="runtime_env",bo="lookup_texture",To="offscreen_canvas",Eo="post_process_settings",_o={};function wo(t){return _o[t]}function Ao(t,e){return _o[t]=e}var Co=new Qe,So=new Qe,Oo=function(){function t(t,e){this.pointStart=[];var i,r=e.colorOverLifetime,n=e.colorOverTrail,s=e.maxTrailCount,a=e.opacityOverLifetime,o=void 0===a?Ka(1):a,u=e.widthOverTrail,h=e.name,c=e.occlusion,l=e.blending,f=e.maskMode,d=e.mask,p=e.textureMap,m=void 0===p?[0,0,1,1]:p,v=e.texture,y=e.transparentOcclusion,g=e.minimumVertexDistance,x=e.lifetime,b=e.matrix,T=t.gpuCapability,E=T.detail,_=T.level,w=Math.max(e.pointCountPerTrail,2),C={curves:[],index:0,max:0,lineSegCount:0,curveCount:0},S=E.maxVertexTextures>0,O=(null!=(i=t.renderer)?i:{}).env,R={},M=[["ENABLE_VERTEX_TEXTURE",S],["LOOKUP_TEXTURE_CURVE",0],["ENV_EDITOR",O===As]],I=s>64,P=0;r&&(M.push(["COLOR_OVER_LIFETIME",!0]),P|=1,R.uColorOverLifetime=Yi.createWithData(t,it(r))),n&&(M.push(["COLOR_OVER_TRAIL",!0]),P|=4,R.uColorOverTrail=Yi.createWithData(t,it(n))),I?(M.push(["ATTR_TRAIL_START",1]),P|=8):R.uTrailStart=new Float32Array(s),R.uOpacityOverLifetimeValue=o.toUniform(C);var L=u.toUniform(C);M.push(["VERT_CURVE_VALUE_COUNT",C.index],["VERT_MAX_KEY_FRAME_COUNT",C.max]),R.uVCurveValues=Sa.getAllData(C);var F={shader:{vertex:Jr,fragment:Kr,macros:M,glslVersion:1===_?ur.GLSL1:ur.GLSL3,shared:!0,name:"trail#"+h,cacheId:"-t:+"+P+"+"+C.index+"+"+C.max},uniformSemantics:{effects_MatrixVP:"VIEWPROJECTION",effects_MatrixInvV:"VIEWINVERSE",effects_ObjectToWorld:"MODEL",uEditorTransform:"EDITOR_TRANSFORM"}},V=w*s*2,N=(w-1)*s,D=Float32Array.BYTES_PER_ELEMENT,k=12*D,z={attributes:{aColor:{size:4,stride:k,data:new Float32Array(12*V)},aSeed:{size:1,stride:k,offset:4*D,dataSource:"aColor"},aInfo:{size:3,stride:k,offset:5*D,dataSource:"aColor"},aPos:{size:4,stride:k,offset:8*D,dataSource:"aColor"},aTime:{size:1,data:new Float32Array(V)},aDir:{size:3,data:new Float32Array(3*V)}},indices:{data:new Uint16Array(6*V)},drawCount:6*N,name:"trail#"+h,bufferUsage:fi.DYNAMIC_DRAW};if(I)z.attributes.aTrailStart={size:1,data:new Float32Array(V)};else{var U=new Float32Array(V);z.attributes.aTrailStartIndex={size:1,data:U};for(var B=0;B<s;B++)for(var G=2*w,j=B*G,X=0;X<G;X++)U[j+X]=B}var H=xi(l),Y=cr.create(t,F);Y.blending=!0,Y.depthMask=c,Y.depthTest=!0,Y.stencilRef=d?[d,d]:void 0,Ei(Y,f),bi(Y,l);var W=this.mesh=Dr.create(t,{name:"MTrail_"+h,material:Y,geometry:Cr.create(t,z)}),Z=null!=v?v:Yi.createWithData(t);Object.keys(R).map((function(t){var e=R[t];if(A(e,Yi))Y.setTexture(t,e);else if("uTrailStart"===t)Y.setFloats("uTrailStart",e);else if("uVCurveValues"===t){for(var i=[],r=0;r<e.length;r+=4){var n=new Je(e[r],e[r+1],e[r+2],e[r+3]);i.push(n)}Y.setVector4Array(t,i)}else Y.setVector4(t,Je.fromArray(e))})),Y.setFloat("uTime",0),Y.setVector4("uWidthOverTrail",Je.fromArray(L)),Y.setVector2("uTexOffset",new Ke(0,0)),Y.setVector4("uTextureMap",Je.fromArray(m)),Y.setVector4("uParams",new Je(0,w-1,0,0)),Y.setTexture("uMaskTex",Z),Y.setVector4("uColorParams",new Je(v?1:0,+H,0,+(c&&!y))),this.maxTrailCount=s,this.pointCountPerTrail=w,this.checkVertexDistance=g>0,this.minimumVertexDistance=Math.pow(g||.001,2),this.useAttributeTrailStart=I,this.lifetime=x,b&&(this.mesh.worldMatrix=b),this.geometry=W.firstGeometry(),this.trailCursors=new Uint16Array(s)}var e=t.prototype;return e.addPoint=function(t,e,i){i=i||{};var r=this.trailCursors[t],n=this.pointCountPerTrail,s=this.geometry,a=n-1,o=r%n,u=(r-1)%n,h=(r-2)%n,c=this.getTrailPosition(t,u,Co);if(!(c&&this.checkVertexDistance&&(null==c?void 0:c.distanceSquared(e))<this.minimumVertexDistance)){var l=t*n+o,f=Po(c,e),d=i.time||this.time,p=[Math.random(),i.lifetime||this.lifetime,r],m=i.size||1,v=6*l,y=new Float32Array(6);y.set(f,0),y.set(f,3),s.setAttributeSubData("aDir",v,y),s.setAttributeSubData("aTime",2*l,new Float32Array([d,d]));var g=i.color||[1,1,1,1],x=new Float32Array(24),b=e.toArray();if(x.set(g,0),x.set(p,4),x[7]=0,x.set(b,8),x[11]=.5*m,x.set(g,12),x.set(p,16),x[19]=1,x.set(b,20),x[23]=-.5*m,s.setAttributeSubData("aColor",24*l,x),u>=0){var T=this.getTrailPosition(t,h,So),E=new Float32Array(Po(T,c,e)),_=6*(t*n+u);s.setAttributeSubData("aDir",_,E),s.setAttributeSubData("aDir",_+3,E);var w=t*n*2,A=new Uint16Array([2*u+w,2*u+1+w,2*o+w,2*o+w,2*u+1+w,2*o+1+w]),C=6*(t*a+(r-1)%a);s.setIndexSubData(C,A)}r=++this.trailCursors[t];var S=this.mesh.material,O=S.getVector4("uParams"),R=p[2];if(this.useAttributeTrailStart){for(var M=2*n,I=new Float32Array(M),P=0;P<M;P++)I[P]=R;s.setAttributeSubData("aTrailStart",t*I.length,I)}else{var L=S.getFloats("uTrailStart");null!=L&&(L[t]=R,S.setFloats("uTrailStart",L))}O&&(O.y=Math.max(O.y,r-1)-Math.max(0,r-n),S.setVector4("uParams",O))}},e.getTrailPosition=function(t,e,i){var r=this.pointCountPerTrail;if(e>=0&&e<r){var n=24*(t*r+e)+8,s=this.geometry.getAttributeData("aColor");return ot(s),i.x=s[n],i.y=s[1+n],i.z=s[2+n],i}},e.clearAllTrails=function(){var t=this.geometry.getIndexData();ot(t),this.trailCursors=new Uint16Array(this.trailCursors.length),this.geometry.setIndexData(new Uint16Array(t.length))},e.minusTime=function(t){var e=this.geometry.getAttributeData("aTime");ot(e);for(var i=0;i<e.length;i++)e[i]-=t;this.geometry.setAttributeData("aTime",e),this.time-=t},e.clearTrail=function(t){if(0!==this.trailCursors[t]){var e=6*(this.pointCountPerTrail-1),i=this.geometry.getIndexData();ot(i),i.set(new Uint16Array(e),t*e),this.geometry.setIndexData(i),this.trailCursors[t]=0}},e.getPointStartPos=function(t){return this.pointStart[t]},e.setPointStartPos=function(t,e){this.pointStart[t]=e},e.onUpdate=function(t){},Pe(t,[{key:"time",get:function(){return this.mesh.material.getFloat("uTime")||0},set:function(t){this.mesh.material.setFloat("uTime",null!=t?t:0)}}]),t}(),Ro=new Qe,Mo=new Qe,Io=new Qe;function Po(t,e,i){var r=Ro;return t||i?(t?i?(Mo.subtractVectors(e,t).normalize(),Mo.subtractVectors(i,e),Io.copyFrom(Mo).normalize(),r.addVectors(Mo,Io)):r.subtractVectors(e,t):r.subtractVectors(i,e),r.normalize().toArray()):[0,0,0]}var Lo=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).lastTime=0,e}Qt(e,t);var i=e.prototype;return i.start=function(t){var e=t.output.getUserData();!this.particleSystem&&A(e,Wu)&&(this.particleSystem=e.getComponent(Go),this.particleSystem&&(this.particleSystem.name=e.name,this.particleSystem.startEmit(),this.particleSystem.initEmitterTransform()))},i.processFrame=function(t){this.time>=0&&this.start(t);var e=this.particleSystem;if(e){var i=t.deltaTime;this.time>=0&&this.time<e.item.duration&&e.isEnded()&&e.reset(),Math.abs(this.time-this.lastTime)<.001&&(i=0),e.update(i)}this.lastTime=this.time},e}(ao),Fo=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.createPlayable=function(t){return new Lo(t)},e}(uo),Vo={uSprite:"vec4",uParams:"vec4",uAcceleration:"vec4",uGravityModifierValue:"vec4",uOpacityOverLifetimeValue:"vec4",uRXByLifeTimeValue:"vec4",uRYByLifeTimeValue:"vec4",uRZByLifeTimeValue:"vec4",uLinearXByLifetimeValue:"vec4",uLinearYByLifetimeValue:"vec4",uLinearZByLifetimeValue:"vec4",uSpeedLifetimeValue:"vec4",uOrbXByLifetimeValue:"vec4",uOrbYByLifetimeValue:"vec4",uOrbZByLifetimeValue:"vec4",uSizeByLifetimeValue:"vec4",uSizeYByLifetimeValue:"vec4",uColorParams:"vec4",uFSprite:"vec4",uPreviewColor:"vec4",uVCurveValues:"vec4Array",uFCurveValues:"vec4",uFinalTarget:"vec3",uForceCurve:"vec4",uOrbCenter:"vec3",uTexOffset:"vec2",uPeriodValue:"vec4",uMovementValue:"vec4",uStrengthValue:"vec4",uWaveParams:"vec4"},No=function(){function t(t,e){var i;this.particleCount=0,this.cachedRotationVector3=new Qe,this.cachedRotationMatrix=new Rr,this.cachedLinearMove=new Qe,this.tempMatrix3=new Rr,this.VERT_MAX_KEY_FRAME_COUNT=0;var r,n,s=(null!=(i=t.renderer)?i:{}).env,a=e.speedOverLifetime,o=e.colorOverLifetime,u=e.linearVelOverLifetime,h=e.orbitalVelOverLifetime,c=e.sizeOverLifetime,l=e.rotationOverLifetime,f=e.sprite,d=e.gravityModifier,p=e.maxCount,m=e.textureFlip,v=e.useSprite,y=e.name,g=e.gravity,x=e.forceTarget,b=e.side,T=e.occlusion,E=e.anchor,_=e.blending,w=e.maskMode,C=e.mask,S=e.transparentOcclusion,O=e.meshSlots,R=e.renderMode,M=void 0===R?0:R,I=e.diffuse,P=void 0===I?Yi.createWithData(t):I,L=t.gpuCapability.detail,F=L.halfFloatTexture,V=L.maxVertexUniforms,N=[["RENDER_MODE",+M],["ENV_EDITOR",s===As]],D=t.gpuCapability.level,k={curves:[],index:0,max:0,lineSegCount:0,curveCount:0},z={curves:[],index:0,max:0,lineSegCount:0,curveCount:0},U=V>0,B={},G=0,j=0;(this.useSprite=v,U&&N.push(["ENABLE_VERTEX_TEXTURE",!0]),a&&(N.push(["SPEED_OVER_LIFETIME",!0]),j|=2,B.uSpeedLifetimeValue=a.toUniform(k)),(null==f?void 0:f.animate)&&(N.push(["USE_SPRITE",!0]),j|=4,B.uFSprite=B.uSprite=new Float32Array([f.col,f.row,f.total,f.blend?1:0]),this.useSprite=!0),(null==o?void 0:o.color)&&(N.push(["COLOR_OVER_LIFETIME",!0]),j|=16,B.uColorOverLifetime=A(o.color,Yi)?o.color:Yi.createWithData(t,it(o.color))),(null==o?void 0:o.opacity)?B.uOpacityOverLifetimeValue=o.opacity.toUniform(k):B.uOpacityOverLifetimeValue=Ka(1).toUniform(k),["x","y","z"].forEach((function(t,e){var i=0,n=0;(null==u?void 0:u[t])&&(B["uLinear"+t.toUpperCase()+"ByLifetimeValue"]=u[t].toUniform(k),i=1,j|=1<<7+e,u.enabled=!0),N.push(["LINEAR_VEL_"+t.toUpperCase(),i]),(null==h?void 0:h[t])&&(B["uOrb"+t.toUpperCase()+"ByLifetimeValue"]=h[t].toUniform(k),n=1,j|=1<<10+e,r=!0,h.enabled=!0),N.push(["ORB_VEL_"+t.toUpperCase(),n])})),(null==u?void 0:u.asMovement)&&(N.push(["AS_LINEAR_MOVEMENT",!0]),j|=32),r&&((null==h?void 0:h.asRotation)&&(N.push(["AS_ORBITAL_MOVEMENT",!0]),j|=64),B.uOrbCenter=new Float32Array((null==h?void 0:h.center)||[0,0,0])),B.uSizeByLifetimeValue=null==c?void 0:c.x.toUniform(k),null==c?void 0:c.separateAxes)&&(N.push(["SIZE_Y_BY_LIFE",1]),j|=16384,B.uSizeYByLifetimeValue=null==c||null==(n=c.y)?void 0:n.toUniform(k));(null==l?void 0:l.z)&&(B.uRZByLifeTimeValue=l.z.toUniform(k),j|=32768,N.push(["ROT_Z_LIFETIME",1])),(null==l?void 0:l.x)&&(B.uRXByLifeTimeValue=l.x.toUniform(k),j|=65536,N.push(["ROT_X_LIFETIME",1])),(null==l?void 0:l.y)&&(B.uRYByLifeTimeValue=l.y.toUniform(k),j|=1<<17,N.push(["ROT_Y_LIFETIME",1])),(null==l?void 0:l.asRotation)&&(N.push(["ROT_LIFETIME_AS_MOVEMENT",1]),j|=1<<18),B.uGravityModifierValue=d.toUniform(k),x&&(N.push(["FINAL_TARGET",!0]),j|=1<<19,B.uFinalTarget=new Float32Array(x.target||[0,0,0]),B.uForceCurve=x.curve.toUniform(k)),F&&z.max?(j|=1<<20,B.uFCurveValueTexture=Wi(t,Sa.getAllData(z,!0),z.index,1)):B.uFCurveValues=Sa.getAllData(z);var X=k.max+k.curves.length-32>V;if(2===D&&(k.max=-1,k.index=O?O[0]:ko(k.index),z.index>0&&(z.max=-1,z.index=O?O[1]:ko(z.index))),X&&F&&U){var H=Wi(t,Sa.getAllData(k,!0),k.index,1);B.uVCurveValueTexture=H,G=1}else B.uVCurveValues=Sa.getAllData(k);var Y=["-p:",M,j,k.index,k.max,z.index,z.max].join("+");N.push(["VERT_CURVE_VALUE_COUNT",k.index],["FRAG_CURVE_VALUE_COUNT",z.index],["VERT_MAX_KEY_FRAME_COUNT",k.max],["FRAG_MAX_KEY_FRAME_COUNT",z.max]),this.VERT_MAX_KEY_FRAME_COUNT=k.max;var W={shader:{fragment:Kr,vertex:"#define LOOKUP_TEXTURE_CURVE "+G+"\n"+Qr,glslVersion:1===D?ur.GLSL1:ur.GLSL3,shared:!0,cacheId:Y,macros:N,name:"particle#"+y},uniformSemantics:{effects_MatrixV:"VIEW",effects_MatrixVP:"VIEWPROJECTION",uEditorTransform:"EDITOR_TRANSFORM",effects_ObjectToWorld:"MODEL"}},Z=xi(_);B.uTexOffset=new Float32Array(P?[1/P.getWidth(),1/P.getHeight()]:[0,0]),B.uMaskTex=P,B.uColorParams=new Float32Array([P?1:0,+Z,0,+(!!T&&!S)]),B.uParams=[0,0,0,0],B.uAcceleration=[(null==g?void 0:g[0])||0,(null==g?void 0:g[1])||0,(null==g?void 0:g[2])||0,0];var q=cr.create(t,W);q.blending=!0,q.depthTest=!0,q.depthMask=!!T,q.stencilRef=C?[C,C]:void 0,Ei(q,w),bi(q,_),Ti(q,b),Object.keys(B).map((function(t){var e=B[t];if(A(e,Yi))q.setTexture(t,e);else{var i=[];switch(Vo[t]){case"vec4":q.setVector4(t,Je.fromArray(e));break;case"vec3":q.setVector3(t,Qe.fromArray(e));break;case"vec2":q.setVector2(t,Ke.fromArray(e));break;case"vec4Array":for(var r=0;r<e.length;r+=4){var n=new Je(e[r],e[r+1],e[r+2],e[r+3]);i.push(n)}q.setVector4Array(t,i),i.length=0;break;default:console.warn("Uniform "+t+"'s type not in typeMap.")}}})),q.setVector3("emissionColor",new Qe(0,0,0)),q.setFloat("emissionIntensity",0);var K=Cr.create(t,function(t,e,i){var r=Float32Array.BYTES_PER_ELEMENT,n=12*r,s={aPos:{size:3,offset:0,stride:n,data:new Float32Array(0)},aVel:{size:3,offset:3*r,stride:n,dataSource:"aPos"},aDirX:{size:3,offset:6*r,stride:n,dataSource:"aPos"},aDirY:{size:3,offset:9*r,stride:n,dataSource:"aPos"},aRot:{size:3,offset:0,stride:8*r,data:new Float32Array(0)},aSeed:{size:1,offset:3*r,stride:8*r,dataSource:"aRot"},aColor:{size:4,offset:4*r,stride:8*r,dataSource:"aRot"},aOffset:{size:4,stride:4*r,data:new Float32Array(0)},aTranslation:{size:3,data:new Float32Array(0)},aLinearMove:{size:3,data:new Float32Array(0)},aRotation0:{size:3,offset:0,stride:9*r,data:new Float32Array(0)},aRotation1:{size:3,offset:3*r,stride:9*r,dataSource:"aRotation0"},aRotation2:{size:3,offset:6*r,stride:9*r,dataSource:"aRotation0"}};e&&(s.aSprite={size:3,stride:3*r,data:new Float32Array(0)});return{attributes:s,indices:{data:new Uint16Array(0)},name:i,maxVertex:t}}(4*p,this.useSprite,"particle#"+y)),Q=Dr.create(t,{name:"MParticle_"+y,material:q,geometry:K});this.anchor=E,this.mesh=Q,this.geometry=Q.firstGeometry(),this.forceTarget=x,this.sizeOverLifetime=c,this.speedOverLifetime=a,this.linearVelOverLifetime=u,this.orbitalVelOverLifetime=h,this.orbitalVelOverLifetime=h,this.gravityModifier=d,this.rotationOverLifetime=l,this.maxCount=p,this.textureOffsets=m?[0,0,1,0,0,1,1,1]:[0,1,0,0,1,1,1,0],this.time=0}var e=t.prototype;return e.getPointColor=function(t){var e=this.geometry.getAttributeData("aRot"),i=32*t+4;return ot(e),[e[i],e[i+1],e[i+2],e[i+3]]},e.clearPoints=function(){this.resetGeometryData(this.geometry),this.particleCount=0,this.geometry.setDrawCount(0),this.maxParticleBufferCount=0},e.resetGeometryData=function(t){for(var e=t.getAttributeNames(),i=t.getIndexData(),r=0;r<e.length;r++){var n=e[r],s=t.getAttributeData(n);s&&t.setAttributeData(n,new s.constructor(0))}t.setIndexData(new i.constructor(0))},e.onUpdate=function(t){var e=this.geometry.getAttributeData("aPos"),i=Math.ceil(e.length/12);this.applyTranslation(i,t),this.applyRotation(i,t),this.applyLinearMove(i,t)},e.minusTime=function(t){for(var e=this.geometry.getAttributeData("aOffset"),i=0;i<e.length;i+=4)e[i+2]-=t;this.geometry.setAttributeData("aOffset",e),this.time-=t},e.removePoint=function(t){t<this.particleCount&&this.geometry.setAttributeSubData("aOffset",16*t,new Float32Array(16))},e.setPoint=function(t,e){var i=this.maxCount;if(t<i){var r=t+1,n=4*r,s=this.geometry,a=r>this.maxParticleBufferCount,o=1;this.particleCount>300?o=(this.particleCount+100)/this.particleCount:this.particleCount>100?o=1.4:this.particleCount>0&&(o=2);var u={aPos:new Float32Array(48),aRot:new Float32Array(32),aOffset:new Float32Array(16),aTranslation:new Float32Array(12),aLinearMove:new Float32Array(12),aRotation0:new Float32Array(36)},h=this.useSprite;h&&(u.aSprite=new Float32Array(12));var c=new Qe,l=new ri,f=new Qe(1,1,1);e.transform.assignWorldTRS(c,l,f);var d,p=fo.getRotation(l,new Or),m=c.toArray(),v=p.toArray(),y=this.textureOffsets,g=[0,0,e.delay,e.lifetime],x=[0,0,1,1],b=e.vel,T=e.color,E=[-.5,.5,-.5,-.5,.5,.5,.5,-.5],_=Math.random();h&&(d=e.sprite);for(var w=0;w<4;w++){var A=2*w,C=3*w,S=4*w,O=12*w,R=8*w;u.aPos.set(m,O),b.fill(u.aPos,O+3),u.aRot.set(v,R),u.aRot[R+3]=_,u.aRot.set(T,R+4),h&&u.aSprite.set(d,C);var M=e.uv||x;if(M){var I=h?1-y[A+1]:y[A+1];g[0]=M[0]+y[A]*M[2],g[1]=M[1]+I*M[3]}u.aOffset.set(g,S);for(var P=w+w,L=(E[P]-this.anchor.x)*f.x,F=(E[P+1]-this.anchor.y)*f.y,V=0;V<3;V++)u.aPos[O+6+V]=e.dirX.getElement(V)*L,u.aPos[O+9+V]=e.dirY.getElement(V)*F}var N=new Uint16Array([0,1,2,2,1,3].map((function(e){return e+4*t})));if(a){var D=U(s.getIndexData(),6*r,6*i,o);D.set(N,6*t),s.setIndexData(D),this.maxParticleBufferCount=D.length/6}else s.setIndexSubData(6*t,N);Object.keys(u).forEach((function(e){var r=u[e],h=s.getAttributeStride(e)/Float32Array.BYTES_PER_ELEMENT;if(a){var c=s.getAttributeData(e);ot(c);var l=U(c,n*h,4*i*h,o);l.set(r,r.length*t),s.setAttributeData(e,l)}else s.setAttributeSubData(e,r.length*t,r)})),this.particleCount=Math.max(r,this.particleCount),s.setDrawCount(6*this.particleCount)}},e.applyTranslation=function(t,e){var i=this.time,r=this.geometry.getAttributeData("aTranslation"),n=this.geometry.getAttributeData("aVel"),s=this.geometry.getAttributeData("aOffset");r.length<3*t&&(r=this.expandArray(r,3*t));for(var a=0,o=0,u=0,h=this.mesh.material.getVector4("uAcceleration"),c=this.mesh.material.getVector4("uGravityModifierValue"),l=0;l<t;l+=4){var f=12*l+3;a=n[f],o=n[f+1],u=n[f+2];var d=i-s[4*l+2],p=s[4*l+3];if(h&&c){var m=this.gravityModifier.getIntegrateValue(0,d,p),v=h.x*m,y=h.y*m,g=h.z*m;if(this.speedOverLifetime){var x=this.speedOverLifetime.getValue(d/p);a=a*x+v,o=o*x+y,u=u*x+g}else a+=v,o+=y,u+=g}var b=3*l;if(s[4*l+2]<i){var T=a*(e/1e3),E=o*(e/1e3),_=u*(e/1e3);r[b]+=T,r[b+1]+=E,r[b+2]+=_,r[b+3]+=T,r[b+4]+=E,r[b+5]+=_,r[b+6]+=T,r[b+7]+=E,r[b+8]+=_,r[b+9]+=T,r[b+10]+=E,r[b+11]+=_}}this.geometry.setAttributeData("aTranslation",r)},e.applyRotation=function(t,e){var i=this.geometry.getAttributeData("aRotation0"),r=this.geometry.getAttributeData("aOffset"),n=this.geometry.getAttributeData("aRot"),s=this.geometry.getAttributeData("aSeed"),a=this.time,o=this.cachedRotationMatrix;i.length<9*t&&(i=this.expandArray(i,9*t));for(var u=0;u<t;u+=4){var h=qe((a-r[4*u+2])/r[4*u+3],0,1),c=8*u,l=this.cachedRotationVector3.set(n[c],n[c+1],n[c+2]),f=s[8*u+3],d=l;this.rotationOverLifetime?(this.rotationOverLifetime.x&&(A(this.rotationOverLifetime.x,Ma)?d.x+=this.rotationOverLifetime.x.getValue(h,f):d.x+=this.rotationOverLifetime.x.getValue(h)),this.rotationOverLifetime.y&&(A(this.rotationOverLifetime.y,Ma)?d.y+=this.rotationOverLifetime.y.getValue(h,f):d.y+=this.rotationOverLifetime.y.getValue(h)),this.rotationOverLifetime.z&&(A(this.rotationOverLifetime.z,Ma)?d.z+=this.rotationOverLifetime.z.getValue(h,f):d.z+=this.rotationOverLifetime.z.getValue(h))):o.setZero(),0===d.dot(d)&&o.identity();var p=Math.PI/180,m=d.x*p,v=d.y*p,y=d.z*p,g=Math.sin(m),x=Math.sin(v),b=Math.sin(y),T=Math.cos(m),E=Math.cos(v),_=Math.cos(y);o.set(_,-b,0,b,_,0,0,0,1),o.multiply(this.tempMatrix3.set(E,0,x,0,1,0,-x,0,E)),o.multiply(this.tempMatrix3.set(1,0,0,0,T,-g,0,g,T));var w=9*u,C=o.elements;i.set(C,w),u+4<=t&&(i.set(C,w+9),i.set(C,w+18),i.set(C,w+27))}this.geometry.setAttributeData("aRotation0",i)},e.applyLinearMove=function(t,e){var i=this.geometry.getAttributeData("aLinearMove"),r=this.geometry.getAttributeData("aOffset"),n=this.geometry.getAttributeData("aSeed"),s=this.time;i.length<3*t&&(i=this.expandArray(i,3*t));var a=this.cachedLinearMove;if(this.linearVelOverLifetime&&this.linearVelOverLifetime.enabled)for(var o=0;o<t;o+=4){var u=s-r[4*o+2],h=r[4*o+3],c=u/h,l=n[8*o+3];a.setZero(),this.linearVelOverLifetime.asMovement?(this.linearVelOverLifetime.x&&(A(this.linearVelOverLifetime.x,Ma)?a.x=this.linearVelOverLifetime.x.getValue(c,l):a.x=this.linearVelOverLifetime.x.getValue(c)),this.linearVelOverLifetime.y&&(A(this.linearVelOverLifetime.y,Ma)?a.y=this.linearVelOverLifetime.y.getValue(c,l):a.y=this.linearVelOverLifetime.y.getValue(c)),this.linearVelOverLifetime.z&&(A(this.linearVelOverLifetime.z,Ma)?a.z=this.linearVelOverLifetime.z.getValue(c,l):a.z=this.linearVelOverLifetime.z.getValue(c))):(this.linearVelOverLifetime.x&&(A(this.linearVelOverLifetime.x,Ma)?a.x=this.linearVelOverLifetime.x.getIntegrateValue(0,u,l):a.x=this.linearVelOverLifetime.x.getIntegrateValue(0,u,h)),this.linearVelOverLifetime.y&&(A(this.linearVelOverLifetime.y,Ma)?a.y=this.linearVelOverLifetime.y.getIntegrateValue(0,u,l):a.y=this.linearVelOverLifetime.y.getIntegrateValue(0,u,h)),this.linearVelOverLifetime.z&&(A(this.linearVelOverLifetime.z,Ma)?a.z=this.linearVelOverLifetime.z.getIntegrateValue(0,u,l):a.z=this.linearVelOverLifetime.z.getIntegrateValue(0,u,h)));var f=3*o;i[f]=a.x,i[f+1]=a.y,i[f+2]=a.z,i[f+3]=a.x,i[f+4]=a.y,i[f+5]=a.z,i[f+6]=a.x,i[f+7]=a.y,i[f+8]=a.z,i[f+9]=a.x,i[f+10]=a.y,i[f+11]=a.z}this.geometry.setAttributeData("aLinearMove",i)},e.expandArray=function(t,e){var i=new Float32Array(e);return i.set(t),i},t}(),Do=[10,32,64,160];function ko(t){for(var e=0;e<Do.length;e++){var i=Do[e];if(i>t)return i}return t||Do[0]}function zo(t,e,i){var r;void 0===i&&(i="");var n,s=t.content,a=+((null==(r=s.renderer)?void 0:r.renderMode)||0),o=[["RENDER_MODE",a],["ENV_EDITOR",i===As]],u=e.level,h=e.detail,c={curves:[],index:0,max:0,lineSegCount:0,curveCount:0},l={curves:[],index:0,max:0,lineSegCount:0,curveCount:0},f=h.maxVertexUniforms>0,d=(null!=(n=s.positionOverLifetime)?n:{}).speedOverLifetime,p=0,m=0;f&&o.push(["ENABLE_VERTEX_TEXTURE",!0]),d&&(o.push(["SPEED_OVER_LIFETIME",!0]),m|=2,Ga(c,d));var v=s.textureSheetAnimation;v&&v.animate&&(o.push(["USE_SPRITE",!0]),m|=4);var y=s.colorOverLifetime;y&&y.color&&(o.push(["COLOR_OVER_LIFETIME",!0]),m|=16);var g=y&&y.opacity;g&&Ga(c,g);var x,b=s.positionOverLifetime;if(["x","y","z"].forEach((function(t,e){var i=0,r="linear"+t.toUpperCase(),n="orbital"+t.toUpperCase();(null==b?void 0:b[r])&&(Ga(c,b[r]),i=1,m|=1<<7+e),o.push(["LINEAR_VEL_"+t.toUpperCase(),i]);var s=0;(null==b?void 0:b[n])&&(Ga(c,b[n]),s=1,m|=1<<10+e,x=!0),o.push(["ORB_VEL_"+t.toUpperCase(),s])})),(null==b?void 0:b.asMovement)&&(o.push(["AS_LINEAR_MOVEMENT",!0]),m|=32),x&&(null==b?void 0:b.asRotation)&&(o.push(["AS_ORBITAL_MOVEMENT",!0]),m|=64),s.sizeOverLifetime){var T=s.sizeOverLifetime;T.separateAxes?(Ga(c,T.x),o.push(["SIZE_Y_BY_LIFE",1]),m|=16384,Ga(c,T.y)):Ga(c,T.size)}if(s.rotationOverLifetime){var E=s.rotationOverLifetime;E.z&&(Ga(c,null==E?void 0:E.z),m|=32768,o.push(["ROT_Z_LIFETIME",1])),E.separateAxes&&(E.x&&(Ga(c,E.x),m|=65536,o.push(["ROT_X_LIFETIME",1])),E.y&&(Ga(c,E.y),m|=1<<17,o.push(["ROT_Y_LIFETIME",1]))),(null==E?void 0:E.asRotation)&&(o.push(["ROT_LIFETIME_AS_MOVEMENT",1]),m|=1<<18)}Ga(c,null==b?void 0:b.gravityOverLifetime),(null==b?void 0:b.forceTarget)&&(o.push(["FINAL_TARGET",!0]),m|=1<<19,Ga(c,b.forceCurve));var _=h.halfFloatTexture;_&&l.max&&(m|=1<<20);var w=h.maxVertexUniforms,A=c.max+c.curves.length-32>w;wo(bo)&&(A=!0),2===u&&(c.max=-1,l.index>0&&(l.max=-1)),A&&_&&f&&(p=1);var C=["-p:",a,m,c.index,c.max,l.index,l.max].join("+"),S={fragment:Kr,vertex:"#define LOOKUP_TEXTURE_CURVE "+p+"\n"+Qr,shared:!0,cacheId:C,macros:o,name:"particle#"+t.name};return o.push(["VERT_CURVE_VALUE_COUNT",c.index],["FRAG_CURVE_VALUE_COUNT",l.index],["VERT_MAX_KEY_FRAME_COUNT",c.max],["FRAG_MAX_KEY_FRAME_COUNT",l.max]),{shader:S,vertex:c.index,fragment:l.index}}function Uo(t,e,i){var r,n=null==(r=t.cacheId)?void 0:r.split("+");if(n[3]=e,n[5]=i,t.cacheId=n.join("+"),t.macros)for(var s=0;s<t.macros.length;s++){var a=t.macros[s];if("VERT_CURVE_VALUE_COUNT"===a[0])a[1]=e;else if("FRAG_CURVE_VALUE_COUNT"===a[0]){a[1]=i;break}}}var Bo=function(t){function e(e,i,r){var n;(n=t.call(this,e)||this).name="ParticleSystemRenderer",i&&(n.particleMesh=new No(e,i)),r&&(n.trailMesh=new Oo(e,r));var s=[n.particleMesh.mesh];return n.materials.push(n.particleMesh.mesh.material),n.trailMesh&&(s.push(n.trailMesh.mesh),n.materials.push(n.trailMesh.mesh.material)),n.meshes=s,n}Qt(e,t);var i=e.prototype;return i.onStart=function(){this._priority=this.item.renderOrder,this.particleMesh.gravityModifier.scaleXCoord(this.item.duration);for(var t,e=w(this.meshes);!(t=e()).done;){t.value.onStart()}},i.onUpdate=function(t){var e,i=this.particleMesh.time,r=null!=(e=this.particleMesh.mesh.material.getVector4("uParams"))?e:new Je;this.particleMesh.mesh.material.setVector4("uParams",r.set(i,this.item.duration,0,0))},i.render=function(t){this.maskManager.drawStencilMask(t);for(var e,i=w(this.meshes);!(e=i()).done;){e.value.render(t)}},i.reset=function(){var t;this.particleMesh.clearPoints(),null==(t=this.trailMesh)||t.clearAllTrails()},i.updateTime=function(t,e){this.particleMesh.time=t,this.particleMesh.onUpdate(e),this.trailMesh&&(this.trailMesh.time=t,this.trailMesh.onUpdate(e))},i.minusTimeForLoop=function(t){var e;this.particleMesh.minusTime(t),null==(e=this.trailMesh)||e.minusTime(t)},i.updateWorldMatrix=function(t){this.particleMesh.mesh.worldMatrix=t,this.trailMesh&&(this.trailMesh.mesh.worldMatrix=t)},i.setVisible=function(t){var e;this.particleMesh.mesh.setVisible(t),null==(e=this.trailMesh)||e.mesh.setVisible(t)},i.getTextures=function(){var t=[],e=this.particleMesh.mesh.material.textures;if(Object.keys(e).forEach((function(i){t.push(e[i])})),this.trailMesh){var i=this.trailMesh.mesh.material.textures;Object.keys(i).forEach((function(e){t.push(i[e])}))}return t},i.setParticlePoint=function(t,e){this.particleMesh.setPoint(t,e)},i.removeParticlePoint=function(t){this.particleMesh.removePoint(t)},i.getParticlePointColor=function(t){return this.particleMesh.getPointColor(t)},i.hasTrail=function(){return void 0!==this.trailMesh},i.clearTrail=function(t){var e;null==(e=this.trailMesh)||e.clearTrail(t)},i.addTrailPoint=function(t,e,i){var r;null==(r=this.trailMesh)||r.addPoint(t,e,i)},i.setTrailStartPosition=function(t,e){var i;null==(i=this.trailMesh)||i.setPointStartPos(t,e)},i.getTrailStartPosition=function(t){return this.trailMesh.getPointStartPos(t)},e}(Ge),Go=function(t){function e(e,i){var r;return(r=t.call(this,e)||this).destroyed=!1,r.getHitTestParams=function(t){var e=r.interaction;if(t||e)return{type:ks.custom,collect:function(t){return r.raycast({radius:(null==e?void 0:e.radius)||.4,multiple:!!(null==e?void 0:e.multiple),removeParticle:(null==e?void 0:e.behavior)===ie.removeParticle,ray:t})}}},r.maskManager=new lr(e),i&&r.fromData(i),r}Qt(e,t);var i=e.prototype;return i.isFrozen=function(){return this.frozen},i.isEnded=function(){return this.ended},i.initEmitterTransform=function(){var t,e=this.item.transform.position.clone(),i=this.item.transform.rotation.clone(),r=this.props.emitterTransform&&this.props.emitterTransform.path;r&&(r[0]===$t.CONSTANT_VEC3?e.add(r[1]):t=Ka(r)),this.basicTransform={position:e,rotation:i,path:t};var n=e.clone();if(t&&n.add(t.getValue(0)),this.transform.setPosition(n.x,n.y,n.z),this.options.particleFollowParent){var s=this.transform.getWorldMatrix();this.renderer.updateWorldMatrix(s)}},i.updateEmitterTransform=function(t){var e=this.basicTransform,i=e.path,r=e.position.clone();if(i){var n=this.item.duration;r.add(i.getValue(t/n))}if(this.transform.setPosition(r.x,r.y,r.z),this.options.particleFollowParent){var s=this.transform.getWorldMatrix();this.renderer.updateWorldMatrix(s)}},i.addParticle=function(t,e){var i,r=this.particleLink,n=[t.delay+t.lifetime,0,t.delay,t];if(r.length<e)i=n[1]=r.length;else{var s=r.first;r.removeNode(s),i=n[1]=s.content[1]}r.pushNode(n),this.renderer.setParticlePoint(i,t),this.clearPointTrail(i),this.transform.parentTransform&&this.renderer.setTrailStartPosition(i,this.transform.parentTransform.position.clone())},i.setVisible=function(t){this.renderer.setVisible(t)},i.setOpacity=function(t){var e,i=this.renderer.particleMesh.mesh.material,r=this.renderer.particleMesh.mesh.geometry,n=(null==(e=i.getVector4("uOpacityOverLifetimeValue"))?void 0:e.toArray())||[1,1,1,1];i.setVector4("uOpacityOverLifetimeValue",new Je(n[0],n[1],n[2],t));for(var s=r.getAttributeData("aColor")||[],a=0;a<s.length;a+=32)s[8*a+7]=t},i.setColor=function(t,e,i,r){var n,s=this.renderer.particleMesh.mesh.material,a=this.renderer.particleMesh.mesh.geometry,o=(null==(n=s.getVector4("uOpacityOverLifetimeValue"))?void 0:n.toArray())||[1,1,1,1];s.setVector4("uOpacityOverLifetimeValue",new Je(o[0],o[1],o[2],r));for(var u=a.getAttributeData("aColor")||[],h=0;h<u.length;h+=32)u[8*h+4]=t,u[8*h+5]=e,u[8*h+6]=i,u[8*h+7]=r},i.setParentTransform=function(t){},i.getTextures=function(){return this.renderer.getTextures()},i.startEmit=function(){this.started&&!this.ended||(this.reset(),this.started=!0,this.ended=!1)},i.stop=function(){this.ended=!0,this.started=!1},i.reset=function(){this.renderer.reset(),this.lastUpdate=0,this.loopStartTime=0,this.lastEmitTime=-1/this.emission.rateOverTime.getValue(0),this.generatedCount=0,this.particleLink=new go((function(t,e){return t[0]-e[0]})),this.emission.bursts.forEach((function(t){return t.reset()})),this.frozen=!1,this.ended=!1,this.destroyed=!1},i.update=function(t){var e=this;if(this.started&&!this.frozen){var i=this.lastUpdate+t/1e3,r=this.options,n=this.loopStartTime,s=this.emission;this.lastUpdate=i,this.upDirectionWorld=null,this.renderer.updateTime(i,t);var a=this.particleLink,o=(i-n)/this.item.duration,u=this.timePassed,h=!1,c=function(){e.trails&&!h&&(h=!0,a.forEach((function(t){var i=t[0],r=t[1],n=t[2],s=t[3];i<u?e.clearPointTrail(r):u>n&&e.updatePointTrail(r,o,s,n)})))};if(this.ended){if(this.item.endBehavior!==ee.restart&&ee.destroy===this.item.endBehavior){var l=a.last;l&&l.content[0]<this.lastUpdate&&(this.destroyed=!0)}}else{var f=this.item.duration,d=this.lifetime;if(u<f){var p=1/s.rateOverTime.getValue(d),m=Math.floor((u-this.lastEmitTime)/p),v=m,y=p/m,g=i,x=r.maxCount;this.updateEmitterTransform(u);for(var b=function(){var t=a.first;return e.emissionStopped||a.length===x&&t&&t.content[0]-n>u},T=0;T<v&&T<x&&!b();T++){var E=this.createPoint(d);E.delay+=g+T*y,this.addParticle(E,x),this.lastEmitTime=u}for(var _=s.bursts,w=(null==_?void 0:_.length)-1,A=0;w>=0&&A<x&&!b();w--){var C=_[w],S=!C.disabled&&C.getGeneratorOptions(u,d);if(S){var O=s.burstOffsets[w],R=O&&O[S.cycleIndex]||[0,0,0];C.once&&this.removeBurst(w);for(var M=0;M<S.count&&A<x;M++){var I;if(b())break;var P=this.initPoint(this.shape.generate({total:S.total,index:S.index,burstIndex:M,burstCount:S.count}));P.delay+=g,A++,(I=P.transform).translate.apply(I,[].concat(R)),this.addParticle(P,x)}}}}else if(this.item.endBehavior===ee.restart)c(),this.loopStartTime=i-f,this.lastEmitTime-=f,this.lastUpdate-=f,s.bursts.forEach((function(t){return t.reset()})),this.particleLink.forEach((function(t){t[0]-=f,t[2]-=f,t[3].delay-=f})),this.renderer.minusTimeForLoop(f);else{this.ended=!0,this.item.endBehavior===ee.freeze&&(this.frozen=!0)}}c()}},i.drawStencilMask=function(t){if(this.isActiveAndEnabled){for(var e=[],i=0;i<this.renderer.meshes.length;i++){var r=this.renderer.meshes[i].material;e.push(r.colorMask),r.colorMask=!1}for(var n,s=w(this.renderer.meshes);!(n=s()).done;){n.value.render(t)}for(var a=0;a<this.renderer.meshes.length;a++){this.renderer.meshes[a].material.colorMask=e[a]}}},i.onDestroy=function(){this.item&&this.item.composition&&this.meshes.forEach((function(t){return t.dispose({material:{textures:pt.keep}})}))},i.getParticleBoxes=function(){var t=this.particleLink,e=this.renderer,i=[],r=this.particleCount,n=0;if(!t||!e)return i;for(var s=t.last,a=!1;!a;){var o=s.content[0],u=s.content[3];if(o>this.timePassed){var h=this.getPointPosition(u);i.push({center:h,size:u.transform.scale}),s.pre?s=s.pre:a=!0}++n>r&&(a=!0)}return i},i.raycast=function(t){var e=this.particleLink,i=this.renderer;if(e&&i){var r=e.last,n=[],s=new Qe,a=!1;if(r&&r.content)do{var o=r.content,u=o[0],h=o[1];o[2];var c=o[3];if(u>this.timePassed){var l=this.getPointPosition(c),f=t.ray,d=!1;f&&(d=!!f.intersectSphere({center:l,radius:t.radius},s)),d&&(t.removeParticle&&(i.removeParticlePoint(h),this.clearPointTrail(h),r.content=[0]),n.push(l),t.multiple||(a=!0))}}while((r=r.pre)&&!a);return n}},i.clearPointTrail=function(t){this.trails&&this.trails.dieWithParticles&&this.renderer.clearTrail(t)},i.updatePointTrail=function(t,e,i,r){var n=this.renderer;if(n.hasTrail()){var s=this.trails,a=this.getPointPosition(i),o=s.inheritParticleColor?n.getParticlePointColor(t):[1,1,1,1],u=i.transform.getWorldScale().toArray(),h=1,c=s.lifetime.getValue(e);if(s.sizeAffectsWidth&&(h*=u[0]),s.sizeAffectsLifetime&&(c*=u[0]),s.parentAffectsPosition&&this.transform.parentTransform){a.add(this.transform.parentTransform.position);var l=n.getTrailStartPosition(t);l&&a.subtract(l)}n.addTrailPoint(t,a,{color:o,lifetime:c,size:h,time:r})}},i.getPointPositionByIndex=function(t){var e=this.particleLink.getNodeByIndex(t);return e?this.getPointPosition(e.content[3]):(console.error("Get point error."),null)},i.getPointPosition=function(t){var e=t.transform,i=t.vel,r=t.lifetime,n=t.delay,s=t.gravity,a=void 0===s?[]:s,o=this.options.forceTarget,u=this.lastUpdate-n,h=new Qe,c=Qe.fromArray(a);e.assignWorldTRS(h);var l=ea(new Qe,this.options,c,u,r,h,i);if(o){var f=o.target||[0,0,0],d=o.curve.getValue(u/r),p=1-d;l.x=l.x*p+f[0]*d,l.y=l.y*p+f[1]*d,l.z=l.z*p+f[2]*d}return l},i.initPoint=function(t){var e=this.options,i=this.lifetime,r=this.shape,n=e.startSpeed.getValue(i),s=e.particleFollowParent?ni.IDENTITY:this.transform.getWorldMatrix(),a=t.position,o=s.transformPoint(a,new Qe),u=new fo({position:o,valid:!0}),h=t.direction;if(h=s.transformNormal(h,jo).normalize(),e.startTurbulence&&e.turbulence){for(var c=0;c<3;c++)Zo.setElement(c,e.turbulence[c].getValue(i));qo.setFromVector3(Zo.negate()),Qo.setFromEuler(qo).transformNormal(h).normalize()}var l,f=Yo,d=Wo;r.alignSpeedDirection?(d.copyFrom(h),this.upDirectionWorld||(r.upDirection?this.upDirectionWorld=r.upDirection.clone():this.upDirectionWorld=Qe.Z.clone(),s.transformNormal(this.upDirectionWorld)),f.crossVectors(d,this.upDirectionWorld).normalize(),f.isZero()&&f.set(1,0,0)):(f.set(1,0,0),d.set(0,1,0));var p=this.textureSheetAnimation;p&&p.animate&&((l=Ko)[0]=p.animationDelay.getValue(i),l[1]=p.animationDuration.getValue(i),l[2]=p.cycles.getValue(i));var m=Ho;e.start3DRotation?m.set(e.startRotationX.getValue(i),e.startRotationY.getValue(i),e.startRotationZ.getValue(i)):e.startRotation?m.set(0,0,e.startRotation.getValue(i)):m.set(0,0,0),u.setRotation(m.x,m.y,m.z);var v=e.startColor.getValue(i);3===v.length&&(v[3]=1);var y=Xo;if(e.start3DSize)y.x=e.startSizeX.getValue(i),y.y=e.startSizeY.getValue(i);else{var g=e.startSize.getValue(i),x=e.sizeAspect.getValue(i);y.x=g,y.y=0===x?0:g/x}var b=h.clone();if(b.multiply(n),!e.particleFollowParent){var T=new Qe;this.transform.assignWorldTRS(void 0,void 0,T),y.x*=T.x,y.y*=T.y}return u.setScale(y.x,y.y,1),{size:y,vel:b,color:v,delay:e.startDelay.getValue(i),lifetime:e.startLifetime.getValue(i),uv:$o(this.uvs,!0),gravity:e.gravity,sprite:l,dirY:d,dirX:f,transform:u}},i.addBurst=function(t,e){var i=!1;if(this.emission.bursts.includes(t)||(this.emission.bursts.push(t),i=!0),i&&A(e,Array)){var r=this.emission.bursts.indexOf(t);return this.emission.burstOffsets[r]=e,r}return-1},i.removeBurst=function(t){t<this.emission.bursts.length&&(this.emission.burstOffsets[t]=null,this.emission.bursts.splice(t,1))},i.createPoint=function(t){var e={total:this.emission.rateOverTime.getValue(t),index:this.generatedCount,burstIndex:0,burstCount:0};return this.generatedCount++,this.initPoint(this.shape.generate(e))},i.stopParticleEmission=function(){this.emissionStopped=!0},i.resumeParticleEmission=function(){this.emissionStopped=!1},i.getBoundingBox=function(){var t=this.getParticleBoxes();return{type:ks.sphere,area:t}},i.fromData=function(e){t.prototype.fromData.call(this,e);var i=e;this.props=i,this.destroyed=!1;var r,n,s,a,o,u=i.options,h=i.positionOverLifetime,c=void 0===h?{}:h,l=i.shape,f=null==c?void 0:c.gravityOverLifetime,d=ia(null==c?void 0:c.gravity),p=i.textureSheetAnimation,m=p?{animationDelay:Ka(p.animationDelay||0),animationDuration:Ka(p.animationDuration||1),cycles:Ka(p.cycles||1),animate:p.animate,col:p.col,row:p.row,total:p.total||p.col*p.row}:void 0,v=!!(l&&l.turbulenceX||(null==l?void 0:l.turbulenceY)||(null==l?void 0:l.turbulenceZ));v&&(r=[Ka(null!=(n=l.turbulenceX)?n:0),Ka(null!=(s=l.turbulenceY)?s:0),Ka(null!=(a=l.turbulenceZ)?a:0)]);this.name="ParticleSystem",this.shape=Wn(l),this.emission={rateOverTime:Ka(i.emission.rateOverTime),burstOffsets:Jo(null!=(o=i.emission.burstOffsets)?o:[]),bursts:(i.emission.bursts||[]).map((function(t){return new vo(t)}))},this.textureSheetAnimation=m;var y,g,x=i.renderer||{},b=i.rotationOverLifetime;b&&((y={}).asRotation=!!b.asRotation,y.z=b.z?Ka(b.z):Ka(0),b.separateAxes&&(y.x=b.x&&Ka(b.x),y.y=b.y&&Ka(b.y))),(null==c?void 0:c.forceTarget)&&(g={target:c.target||[0,0,0],curve:Ka(c.forceCurve||[$t.LINE,[[0,0],[1,1]]])});var T={x:c.linearX&&Ka(c.linearX||0),y:c.linearY&&Ka(c.linearY||0),z:c.linearZ&&Ka(c.linearZ||0),asMovement:c.asMovement},E={x:c.orbitalX&&Ka(c.orbitalX),y:c.orbitalY&&Ka(c.orbitalY),z:c.orbitalZ&&Ka(c.orbitalZ),center:c.orbCenter,asRotation:c.asRotation},_=i.sizeOverLifetime||{},w=i.colorOverLifetime,C=(null==_?void 0:_.separateAxes)?{separateAxes:!0,x:Ka(_.x),y:Ka(_.y)}:{separateAxes:!1,x:Ka(("size"in _?_.size:_.x)||1)};x.anchor=x.anchor||[0,0];var S,O=Ke.fromArray(x.anchor);this.options={particleFollowParent:!!u.particleFollowParent,startLifetime:Ka(u.startLifetime),startDelay:Ka(u.startDelay||0),startSpeed:Ka(c.startSpeed||0),startColor:Ka(u.startColor),looping:!1,maxCount:null!=(S=u.maxCount)?S:0,gravityModifier:Ka(f||0),gravity:d,start3DSize:!!u.start3DSize,startTurbulence:v,turbulence:r,speedOverLifetime:c.speedOverLifetime&&Ka(c.speedOverLifetime),linearVelOverLifetime:T,orbitalVelOverLifetime:E,forceTarget:g},u.startRotationZ&&(this.options.startRotation=Ka(u.startRotationZ||0)),(u.startRotationX||u.startRotationY)&&(this.options.start3DRotation=!0,this.options.startRotationX=Ka(u.startRotationX||0),this.options.startRotationY=Ka(u.startRotationY||0),this.options.startRotationZ=Ka(u.startRotationZ||0)),u.start3DSize?(this.options.startSizeX=Ka(u.startSizeX),this.options.startSizeY=Ka(u.startSizeY)):(this.options.startSize=Ka(u.startSize),this.options.sizeAspect=Ka(u.sizeAspect||1));var R=this.getMaskOptions(i),M={meshSlots:u.meshSlots,name:this.name,matrix:ni.IDENTITY,shaderCachePrefix:"",renderMode:x.renderMode||Ht.BILLBOARD,side:x.side||kt.DOUBLE,gravity:d,blending:x.blending||Dt.ALPHA,rotationOverLifetime:y,gravityModifier:this.options.gravityModifier,linearVelOverLifetime:this.options.linearVelOverLifetime,orbitalVelOverLifetime:this.options.orbitalVelOverLifetime,speedOverLifetime:this.options.speedOverLifetime,sprite:m,occlusion:!!x.occlusion,transparentOcclusion:!!x.transparentOcclusion,maxCount:u.maxCount,mask:R.maskRef,maskMode:R.maskMode,forceTarget:g,diffuse:x.texture?this.engine.findObject(x.texture):void 0,sizeOverLifetime:C,anchor:O};if(w){var I=w.color,P=w.opacity;M.colorOverLifetime={},P&&(M.colorOverLifetime.opacity=Ka(w.opacity)),I&&(I[0]===$t.GRADIENT_COLOR?M.colorOverLifetime.color=w.color[1]:I[0]===$t.RGBA_COLOR?M.colorOverLifetime.color=Yi.createWithData(this.engine,{data:new Uint8Array(I[1]),width:1,height:1}):A(I,Yi)&&(M.colorOverLifetime.color=I))}var L,F=[],V=[0,0,1,1];if(i.splits){var N=i.splits[0];V=(L=N[4])?[N[0],N[1],N[3],N[2]]:[N[0],N[1],N[2],N[3]]}if(m&&!m.animate)for(var D=L?m.row:m.col,k=L?m.col:m.row,z=m.total||D*k,U=0,B=0;B<D;B++)for(var G=0;G<k&&U<z;G++,U++)F.push([B*V[2]/D+V[0],G*V[3]/k+V[1],V[2]/D,V[3]/k]);else F.push(V);this.uvs=F,M.textureFlip=L;var j,X=i.trails;X&&(this.trails={lifetime:Ka(X.lifetime),dieWithParticles:!1!==X.dieWithParticles,sizeAffectsWidth:!!X.sizeAffectsWidth,sizeAffectsLifetime:!!X.sizeAffectsLifetime,inheritParticleColor:!!X.inheritParticleColor,parentAffectsPosition:!!X.parentAffectsPosition},R=this.getMaskOptions(X),j={name:"Trail",matrix:ni.IDENTITY,minimumVertexDistance:X.minimumVertexDistance||.02,maxTrailCount:u.maxCount,pointCountPerTrail:Math.round(X.maxPointPerTrail)||32,blending:X.blending,texture:X.texture?this.engine.findObject(X.texture):void 0,opacityOverLifetime:Ka(X.opacityOverLifetime||1),widthOverTrail:Ka(X.widthOverTrail||1),shaderCachePrefix:"",lifetime:this.trails.lifetime,occlusion:!!X.occlusion,transparentOcclusion:!!X.transparentOcclusion,textureMap:X.textureMap,mask:R.maskRef,maskMode:R.maskMode},X.colorOverLifetime&&X.colorOverLifetime[0]===$t.GRADIENT_COLOR&&(j.colorOverLifetime=X.colorOverLifetime[1]),X.colorOverTrail&&X.colorOverTrail[0]===$t.GRADIENT_COLOR&&(j.colorOverTrail=X.colorOverTrail[1])),this.renderer=new Bo(this.engine,M,j),this.renderer.item=this.item,this.renderer.maskManager=this.maskManager,this.meshes=this.renderer.meshes;var H,Y=i.interaction;Y&&(this.interaction={multiple:Y.multiple,radius:null!=(H=Y.radius)?H:.4,behavior:Y.behavior});this.item.getHitTestParams=this.getHitTestParams,this.item._content=this},i.getMaskOptions=function(t){var e=ui.NONE,i=0;return t.mask&&(e=this.maskManager.getMaskMode(t.mask),i=this.maskManager.getRefValue()),{maskMode:e,maskRef:i}},Pe(e,[{key:"timePassed",get:function(){return this.lastUpdate-this.loopStartTime}},{key:"lifetime",get:function(){return this.timePassed/this.item.duration}},{key:"particleCount",get:function(){return this.particleLink.length}},{key:"maxParticles",get:function(){return this.options.maxCount},set:function(t){var e;this.options.maxCount=t,(null==(e=this.renderer)?void 0:e.particleMesh)&&(this.renderer.particleMesh.maxCount=t)}}]),e}(Ue);Go=S([Ne(_e.ParticleSystem)],Go);var jo=new Qe,Xo=new Ke,Ho=new Or,Yo=new Qe,Wo=new Qe,Zo=new Qe,qo=new Or,Ko=[0,0,0],Qo=new ni;function Jo(t){var e={};return Array.isArray(t)&&t.forEach((function(t){var i=A(t,Array),r=i?t[0]:t.index,n=e[r];n||(n=e[r]=[]),i?n.push(t.slice(1,4)):n.push([+t.x,+t.y,+t.z])})),e}function $o(t,e){var i=Math.floor(Math.random()*t.length),r=t[i];return e||t.splice(i,1),r}var tu,eu=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).clipPlayables=[],e.clipWeights=[],e}Qt(e,t);var i=e.prototype;return i.processFrame=function(t){for(var e,i=w(this.clipPlayables);!(e=i()).done;){e.value.processFrame(t)}this.evaluate(t)},i.setClipWeight=function(t,e){if(A(t,ao)){for(var i=0;i<this.clipPlayables.length;i++)if(this.clipPlayables[i]===t)return void(this.clipWeights[i]=e)}else this.clipWeights.length<t+1&&(this.clipWeights.length=t+1),this.clipWeights[t]=e},i.getClipWeight=function(t){return this.clipWeights[t]},i.getClipPlayable=function(t){return this.clipPlayables[t]},i.evaluate=function(t){},e}(ao),iu=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.evaluate=function(t){var e=t.output.getUserData();if(A(e,Wu)){for(var i=e,r=!1,n=0;n<this.clipPlayables.length;n++)if(this.getClipWeight(n)>0){r=!0;break}r?(i.transform.setValid(!0),i.setActive(!0)):(i.transform.setValid(!1),i.setActive(!1))}},e}(eu),ru=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.processFrame=function(t){this.value=this.curve.getValue(this.time/this.getDuration())},e}(ao),nu=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).propertyName="",e}return Qt(e,t),e.prototype.evaluate=function(t){var e=t.output.getUserData();if(e){var i=!1;if(this.propertyValue=e[this.propertyName],void 0!==this.propertyValue&&null!==this.propertyValue){this.resetPropertyValue();for(var r=0;r<this.clipPlayables.length;r++){var n=this.getClipWeight(r);if(n>0){var s=this.getClipPlayable(r);if(!A(s,ru)){console.error("PropertyTrack added non-PropertyPlayableAsset");continue}var a=s.value;this.addWeightedValue(a,n),i=!0}}i&&(e[this.propertyName]=this.propertyValue)}}},e}(eu),su=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.resetPropertyValue=function(){this.propertyValue.setZero()},i.addWeightedValue=function(t,e){var i=this.propertyValue;i.r+=t.r*e,i.g+=t.g*e,i.b+=t.b*e,i.a+=t.a*e},e}(nu),au=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.resetPropertyValue=function(){this.propertyValue=0},i.addWeightedValue=function(t,e){this.propertyValue+=t*e},e}(nu),ou=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.evaluate=function(t){},e}(eu),uu=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.evaluate=function(t){},e}(eu),hu=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.processFrame=function(t){var e=t.output.getUserData();A(e,zu)&&(e.time=this.getTime())},e}(ao),cu=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.evaluate=function(t){var e=t.output.getUserData();if(A(e,zu)){for(var i=e,r=!1,n=0;n<this.clipPlayables.length;n++)if(this.getClipWeight(n)>0){r=!0;break}r?i.item.setActive(!0):i.item.setActive(!1)}},e}(eu),lu=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.evaluate=function(t){},e}(eu),fu=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.resetPropertyValue=function(){this.propertyValue.x=0,this.propertyValue.y=0,this.propertyValue.z=0,this.propertyValue.w=0},i.addWeightedValue=function(t,e){var i=this.propertyValue;i.x+=t.x*e,i.y+=t.y*e,i.z+=t.z*e,i.w+=t.w*e},e}(nu),du=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.resetPropertyValue=function(){this.propertyValue.x=0,this.propertyValue.y=0},i.addWeightedValue=function(t,e){var i=this.propertyValue;i.x+=t.x*e,i.y+=t.y*e},e}(nu),pu=function(){function t(){this.start=0,this.duration=0}return t.prototype.toLocalTime=function(t){var e=t-this.start,i=this.duration;return e-i>0&&(this.endBehavior===ee.restart?e%=i:this.endBehavior===ee.freeze&&(e=Math.min(i,e))),e},t}(),mu=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).trackType=0,e.clipSeed=0,e.clips=[],e.children=[],e}Qt(e,t);var i=e.prototype;return i.updateAnimatedObject=function(){this.parent&&(this.boundObject=this.parent.boundObject)},i.createTrackMixer=function(t){return new eu(t)},i.createOutput=function(){return new oo},i.createPlayableGraph=function(t,e){return this.createMixerPlayableGraph(t,e)},i.createMixerPlayableGraph=function(t,e){for(var i,r=[],n=w(this.clips);!(i=n()).done;){var s=i.value;r.push(s)}return this.compileClips(t,r,e)},i.compileClips=function(t,e,i){for(var r,n=this.createTrackMixer(t),s=w(e);!(r=s()).done;){var a=r.value,o=this.createClipPlayable(t,a);o.setDuration(a.duration);var u=new vu(a,o,n,this);i.push(u),n.clipPlayables.push(o),n.setClipWeight(o,0)}return n},i.createPlayable=function(t){return new ao(t)},i.getChildTracks=function(){return this.children},i.addChild=function(t){this.children.push(t),t.parent=this},i.createClip=function(t,e){var i=new pu;return i.asset=new t(this.engine),i.name=e||"TimelineClip"+i.id,this.addClip(i),i},i.getClips=function(){return this.clips},i.findClip=function(t){for(var e,i=w(this.clips);!(e=i()).done;){var r=e.value;if(r.name===t)return r}},i.addClip=function(t){t.id=(this.clipSeed++).toString(),this.clips.push(t)},i.createClipPlayable=function(t,e){return e.asset.createPlayable(t)},i.fromData=function(e){t.prototype.fromData.call(this,e);for(var i,r=w(this.children);!(i=r()).done;){i.value.parent=this}},e}(uo);S([De(pu)],mu.prototype,"clips",void 0),S([De()],mu.prototype,"children",void 0),mu=S([Ne(_e.TrackAsset)],mu),function(t){t[t.MasterTrack=0]="MasterTrack",t[t.ObjectTrack=1]="ObjectTrack"}(tu||(tu={}));var vu=function(){function t(t,e,i,r){this.clip=t,this.playable=e,this.parentMixer=i,this.track=r,A(this.track.boundObject,Wu)&&(this.particleSystem=this.track.boundObject.getComponent(Go))}return t.prototype.evaluateAt=function(t){var e=this.clip,i=1,r=!1,n=!1,s=this.track.boundObject;t>=e.start+e.duration&&e.endBehavior===ee.destroy?A(s,Wu)&&Wu.isParticle(s)&&this.particleSystem&&!this.particleSystem.destroyed?i=1:(i=0,r=!0):t-this.clip.start>=0?(i=1,n=!0):t<e.start&&(i=0),n&&this.playable.getPlayState()!==io.Playing&&this.playable.play(),this.parentMixer.setClipWeight(this.playable,i);var a=e.toLocalTime(t);this.playable.setTime(a),r&&this.playable.getPlayState()===io.Playing&&this.playable.pause()},Pe(t,[{key:"enable",set:function(t){t?this.playable.play():(this.parentMixer.setClipWeight(this.playable,0),this.playable.pause())}}]),t}(),yu=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.createTrackMixer=function(t){return new iu(t)},e}(mu);yu=S([Ne(_e.ActivationTrack)],yu);var gu=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).propertyNames=[],e.path="",e}Qt(e,t);var i=e.prototype;return i.updateAnimatedObject=function(){for(var t=this.propertyNames,e=this.parent.boundObject,i=0;i<t.length-1;i++){var r=e[t[i]];void 0===r&&console.error("The "+t[i]+" property of "+e+" was not found"),e=r}this.boundObject=e},i.fromData=function(e){t.prototype.fromData.call(this,e);var i=this.path.split(".");this.propertyNames=i},e}(mu);S([De()],gu.prototype,"path",void 0);var xu=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.createTrackMixer=function(t){var e=new au(t),i=this.propertyNames;if(i.length>0){var r=i[i.length-1];e.propertyName=r}return e},i.updateAnimatedObject=function(){for(var t=this.propertyNames,e=this.parent.boundObject,i=0;i<t.length-1;i++){var r=e[t[i]];void 0===r&&console.error("The "+t[i]+" property of "+e+" was not found"),e=r}this.boundObject=e},e}(gu);xu=S([Ne(_e.FloatPropertyTrack)],xu);var bu=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.createTrackMixer=function(t){return new uu(t)},e}(mu);bu=S([Ne(_e.SpriteColorTrack)],bu);var Tu=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.updateAnimatedObject=function(){if(!this.parent||!A(this.parent.boundObject,Wu))throw new Error("SubCompositionTrack needs to be set under the VFXItem track.");this.boundObject=this.parent.boundObject.getComponent(zu)},i.createTrackMixer=function(t){return new cu(t)},e}(mu);Tu=S([Ne(_e.SubCompositionTrack)],Tu);var Eu=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.createTrackMixer=function(t){return new lu(t)},e}(mu);Eu=S([Ne(_e.TransformTrack)],Eu);var _u=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.updateAnimatedObject=function(){A(this.parent.boundObject,Ge)&&(this.parent.boundObject,this.boundObject=this.parent.boundObject.materials[this.index])},e}(mu);S([De()],_u.prototype,"index",void 0),_u=S([Ne("MaterialTrack")],_u);var wu=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.createTrackMixer=function(t){return new ou(t)},e}(mu),Au=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.createTrackMixer=function(t){var e=new fu(t),i=this.propertyNames;if(i.length>0){var r=i[i.length-1];e.propertyName=r}return e},e}(gu);Au=S([Ne(_e.Vector4PropertyTrack)],Au);var Cu=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.createTrackMixer=function(t){var e=new du(t),i=this.propertyNames;if(i.length>0){var r=i[i.length-1];e.propertyName=r}return e},e}(gu);Cu=S([Ne("Vector2PropertyTrack")],Cu);var Su=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.createTrackMixer=function(t){var e=new su(t),i=this.propertyNames;if(i.length>0){var r=i[i.length-1];e.propertyName=r}return e},e}(gu);Su=S([Ne(_e.ColorPropertyTrack)],Su);var Ou=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.createPlayable=function(t){var e=new ru(t);return e.curve=Ka(this.curveData),e.value=e.curve.getValue(0),e},e}(uo);S([De()],Ou.prototype,"curveData",void 0),Ou=S([Ne(_e.ColorPropertyPlayableAsset)],Ou);var Ru=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.createPlayable=function(t){var e=new ru(t);return e.curve=Ka(this.curveData),e.value=e.curve.getValue(0),e},e}(uo);S([De()],Ru.prototype,"curveData",void 0),Ru=S([Ne(_e.FloatPropertyPlayableAsset)],Ru);var Mu=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.createPlayable=function(t){return new hu(t)},e}(uo);Mu=S([Ne(_e.SubCompositionPlayableAsset)],Mu);var Iu=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.updateAnimatedObject=function(){},i.create=function(t){if(A(this.boundObject,Wu)){var e=this.boundObject;if(e.getComponent(Go)){var i=t.createTrack(wu,this,"ParticleTrack");i.boundObject=this.boundObject;var r=i.createClip(Fo);r.start=e.start,r.duration=e.duration,r.endBehavior=e.endBehavior}}},e}(mu);Iu=S([Ne(_e.ObjectBindingTrack)],Iu);var Pu=function(){function t(t,e,i){this.children=[],this.trackAsset=t,this.mixer=e,this.output=i}return t.prototype.addChild=function(t){this.children.push(t)},t}(),Lu=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).tracks=[],e.cacheFlattenedTracks=null,e}Qt(e,t);var i=e.prototype;return i.createPlayable=function(t){for(var e,i=new Fu(t),r=w(this.tracks);!(e=r()).done;){var n=e.value;A(n,Iu)&&n.create(this)}return this.sortTracks(this.tracks),i.compileTracks(t,this.flattenedTracks),i},i.createTrack=function(t,e,i){var r=new t(this.engine);return r.name=i||t.name,e.addChild(r),this.invalidate(),r},i.invalidate=function(){this.cacheFlattenedTracks=null},i.addSubTracksRecursive=function(t,e){for(var i,r=w(t.getChildTracks());!(i=r()).done;){var n=i.value;e.push(n)}for(var s,a=w(t.getChildTracks());!(s=a()).done;){var o=s.value;this.addSubTracksRecursive(o,e)}},i.sortTracks=function(t){for(var e=[],i=0;i<t.length;i++)e.push(new Vu(t[i],i));e.sort(Nu),t.length=0;for(var r,n=w(e);!(r=n()).done;){var s=r.value;t.push(s.track)}},i.fromData=function(t){},Pe(e,[{key:"flattenedTracks",get:function(){if(!this.cacheFlattenedTracks){this.cacheFlattenedTracks=[];for(var t,e=w(this.tracks);!(t=e()).done;){var i=t.value;this.cacheFlattenedTracks.push(i),this.addSubTracksRecursive(i,this.cacheFlattenedTracks)}}return this.cacheFlattenedTracks}}]),e}(uo);S([De()],Lu.prototype,"tracks",void 0),Lu=S([Ne(_e.TimelineAsset)],Lu);var Fu=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).clips=[],e.masterTrackInstances=[],e}Qt(e,t);var i=e.prototype;return i.prepareFrame=function(t){},i.evaluate=function(){for(var t,e=this.getTime(),i=w(this.clips);!(t=i()).done;){t.value.evaluateAt(e)}},i.compileTracks=function(t,e){for(var i,r=e,n={},s=w(r);!(i=s()).done;){var a=i.value,o=a.createPlayableGraph(t,this.clips),u=a.createOutput();u.setUserData(a.boundObject),t.addOutput(u),u.setSourcePlayable(o);var h=new Pu(a,o,u);n[a.getInstanceId()]=h,a.parent||this.masterTrackInstances.push(h)}for(var c,l=w(r);!(c=l()).done;)for(var f,d=c.value,p=n[d.getInstanceId()],m=w(d.getChildTracks());!(f=m()).done;){var v=n[f.value.getInstanceId()];p.addChild(v)}},e}(ao),Vu=function(t,e){this.track=t,this.originalIndex=e};function Nu(t,e){var i=t.track.boundObject,r=e.track.boundObject;return A(i,Wu)&&A(r,Wu)?Wu.isAncestor(i,r)?-1:Wu.isAncestor(r,i)?1:t.originalIndex-e.originalIndex:t.originalIndex-e.originalIndex}var Du=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.createPlayable=function(t){var e=new ru(t);return e.curve=Ka(this.curveData),e.value=e.curve.getValue(0),e},e}(uo);S([De()],Du.prototype,"curveData",void 0),Du=S([Ne(_e.Vector4PropertyPlayableAsset)],Du);var ku=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.createPlayable=function(t){var e=new ru(t);return e.curve=Ka(this.curveData),e.value=e.curve.getValue(0),e},e}(uo);S([De()],ku.prototype,"curveData",void 0),ku=S([Ne(_e.Vector2PropertyPlayableAsset)],ku);var zu=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).time=0,e.startTime=0,e.items=[],e.state=io.Playing,e.reusable=!1,e.sceneBindings=[],e.graph=new so,e}Qt(e,t);var i=e.prototype;return i.onStart=function(){var t;this.timelineAsset||(this.timelineAsset=new Lu(this.engine)),this.resolveBindings(),this.timelinePlayable=this.timelineAsset.createPlayable(this.graph),this.item.endBehavior!==ee.destroy&&this.setReusable(!0),null==(t=this.item.composition)||t.refContent.push(this.item)},i.setReusable=function(t){for(var i,r=w(this.timelineAsset.tracks);!(i=r()).done;){var n=i.value.boundObject;if(A(n,Wu)){var s=n.getComponent(e);s&&s.setReusable(t)}}},i.getReusable=function(){return this.reusable},i.pause=function(){this.state=io.Paused},i.resume=function(){this.state=io.Playing},i.onUpdate=function(t){if(this.state!==io.Paused){var e=this.time;this.timelinePlayable.setTime(e),this.resolveBindings(),this.timelinePlayable.evaluate(),this.graph.evaluate(t)}},i.onEnable=function(){for(var t,e=w(this.items);!(t=e()).done;){t.value.setActive(!0)}},i.onDisable=function(){for(var t,e=w(this.items);!(t=e()).done;){t.value.setActive(!1)}},i.onDestroy=function(){this.item.composition&&this.items&&(this.items.forEach((function(t){return t.dispose()})),this.items.length=0)},i.hitTest=function(t,e,i,r,n,s){for(var a,o=function(s){var o=a.items[s];if(o.isActive&&o.transform.getValid()&&!Wu.isComposition(o)&&!c(o)){var l=o.getHitTestParams(n);if(l){var f=!1,d=new Qe;if(l.type===ks.triangle)for(var p=l.triangles,m=l.backfaceCulling,v=0;v<p.length;v++){var y=p[v];if(t.intersectTriangle(y,d,m)){f=!0,u.push(d);break}}else if(l.type===ks.box){var g=l.center,x=l.size,b=g.clone().addScaledVector(x,.5),T=g.clone().addScaledVector(x,-.5);t.intersectBox({min:b,max:T},d)&&(f=!0,u.push(d))}else if(l.type===ks.sphere){var E=l.center,_=l.radius;t.intersectSphere({center:E,radius:_},d)&&(f=!0,u.push(d))}else if(l.type===ks.custom){var w=l.collect(t,new Ke(e,i));w&&w.length>0&&(w.forEach((function(t){u.push(t)})),f=!0)}if(f){var A={compContent:a.item,id:o.id,name:o.name,position:u[u.length-1],parentId:o.parentId,hitPositions:u,behavior:l.behavior};if(o.emit("click",A),r.push(A),h(A))return{v:r}}}}},u=[],h=(null==s?void 0:s.stop)||vt,c=(null==s?void 0:s.skip)||vt,l=(null==s?void 0:s.maxCount)||this.items.length,f=0;f<this.items.length&&r.length<l;f++){var d=(a=this,o(f));if("object"===C(d))return d.v}return r},i.setChildrenRenderOrder=function(t){for(var i,r=w(this.items);!(i=r()).done;){var n=i.value;n.renderOrder=t++;var s=n.getComponent(e);s&&(t=s.setChildrenRenderOrder(t))}return t},i.fromData=function(e){t.prototype.fromData.call(this,e);var i,r=e;this.startTime=null!=(i=r.startTime)?i:0},i.resolveBindings=function(){for(var t,e=w(this.sceneBindings);!(t=e()).done;){var i=t.value;i.key.boundObject=i.value}for(var r,n=w(this.timelineAsset.tracks);!(r=n()).done;){var s=r.value;this.updateTrackAnimatedObject(s)}},i.updateTrackAnimatedObject=function(t){for(var e,i=w(t.getChildTracks());!(e=i()).done;){var r=e.value;r.updateAnimatedObject(),this.updateTrackAnimatedObject(r)}},e}(Ue);S([De()],zu.prototype,"items",void 0),S([De()],zu.prototype,"sceneBindings",void 0),S([De()],zu.prototype,"timelineAsset",void 0),zu=S([Ne("CompositionComponent")],zu);var Uu,Bu=function(){var t=this,e=this;this.listeners={},this.off=function(e,i){t.listeners[e]&&(t.listeners[e]=t.listeners[e].filter((function(t){return t.listener!==i})))},this.on=function(e,i,r){return t.listeners[e]=t.listeners[e]||[],t.listeners[e].push({listener:i,options:r}),function(){return t.off(e,i)}},this.once=function(e,i){t.on(e,i,{once:!0})},this.emit=function(t){for(var i=arguments.length,r=new Array(i>1?i-1:0),n=1;n<i;n++)r[n-1]=arguments[n];var s;null==(s=e.listeners[t])||s.forEach((function(i){var n=i.listener,s=i.options;n.apply(void 0,[].concat(r)),(null==s?void 0:s.once)&&e.off(t,n)}))},this.getListeners=function(e){var i;return(null==(i=t.listeners[e])?void 0:i.map((function(t){return t.listener})))||[]}},Gu=function(){function t(){this.update=new Xu,this.lateUpdate=new Hu}var e=t.prototype;return e.addComponent=function(t){t.onUpdate!==Ue.prototype.onUpdate&&this.update.addComponent(t),t.onLateUpdate!==Ue.prototype.onLateUpdate&&this.lateUpdate.addComponent(t)},e.removeComponent=function(t){t.onUpdate!==Ue.prototype.onUpdate&&this.update.removeComponent(t),t.onLateUpdate!==Ue.prototype.onLateUpdate&&this.lateUpdate.removeComponent(t)},e.clear=function(){this.update.clear(),this.lateUpdate.clear()},t}(),ju=function(){function t(){this.components=[],this.ticks=[]}var e=t.prototype;return e.tick=function(t){this.tickComponents(this.components,t);for(var e=0;e<this.ticks.length;e++)this.ticks[e](t)},e.tickComponents=function(t,e){},e.addComponent=function(t){this.components.includes(t)||this.components.push(t)},e.removeComponent=function(t){var e=this.components.indexOf(t);e>-1&&this.components.splice(e,1)},e.addTick=function(t,e){var i=t.bind(e);this.ticks.includes(i)||this.ticks.push(i)},e.clear=function(){this.components=[]},t}(),Xu=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.tickComponents=function(t,e){for(var i,r=w(t);!(i=r()).done;){i.value.onUpdate(e)}},e}(ju),Hu=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.tickComponents=function(t,e){for(var i,r=w(t);!(i=r()).done;){i.value.onLateUpdate(e)}},e}(ju),Yu=function(t){function e(i,r){var n,s;(n=t.call(this)||this).sceneTicking=new Gu,n.speed=1,n.isEnded=!1,n.loaderData={},n.refContent=[],n.postProcessingEnabled=!1,n.assigned=!1,n.destroyed=!1,n.postLoaders=[],n.paused=!1,n.isEndCalled=!1,n._textures=[];var a,o=i.reusable,u=void 0!==o&&o,h=i.speed,c=void 0===h?1:h,l=i.baseRenderOrder,f=void 0===l?0:l,d=i.renderer,p=i.event,m=i.width,v=i.height,y=i.handleItemMessage;n.renderer=d,n._textures=r.textures,n.postProcessingEnabled=null!=(a=null==(s=r.jsonScene.renderSettings)?void 0:s.postProcessingEnabled)&&a,n.getEngine().renderLevel=r.renderLevel,u&&(n.keepResource=!0,r.consumed=!0);for(var g,x=r.jsonScene.compositions[0],b=w(r.jsonScene.compositions);!(g=b()).done;){var T=g.value;T.id===r.jsonScene.compositionId&&(x=T)}ot(x),n.rootItem=new Wu(n.getEngine()),n.rootItem.name="rootItem",n.rootItem.duration=x.duration,n.rootItem.endBehavior=x.endBehavior,n.rootItem.composition=ho(n);for(var E,_,A,C=w(x.components);!(E=C()).done;){var S=E.value,O=n.getEngine().findObject(S);n.rootItem.components.push(O),O.item=n.rootItem}return n.rootComposition=n.rootItem.getComponent(zu),n.width=m,n.height=v,n.renderOrder=f,n.id=x.id,n.renderer=d,n.event=p,n.statistic={loadStart:null!=(_=r.startTime)?_:0,loadTime:null!=(A=r.totalTime)?A:0,compileTime:0,firstFrameTime:0},n.reusable=u,n.speed=c,n.name=x.name,n.pluginSystem=r.pluginSystem,n.pluginSystem.initializeComposition(ho(n),r),n.camera=new mo(n.name,_i({},null==x?void 0:x.camera,{aspect:m/v})),n.url=r.url,n.assigned=!0,n.interactive=!0,n.handleItemMessage=y,n.createRenderFrame(),n.rendererOptions=null,e.buildItemTree(n.rootItem),n.rootComposition.setChildrenRenderOrder(0),n.pluginSystem.resetComposition(ho(n),n.renderFrame),n}Qt(e,t);var i=e.prototype;return i.getDuration=function(){return this.rootItem.duration},i.restart=function(){this.reset(),this.forwardTime(this.startTime)},i.setIndex=function(t){this.renderOrder=t},i.getIndex=function(){return this.renderOrder},i.setSpeed=function(t){this.speed=t},i.setVisible=function(t){this.rootItem.setVisible(t)},i.getSpeed=function(){return this.speed},i.play=function(){this.isEnded&&this.reusable&&this.restart(),this.rootComposition.isStartCalled?this.gotoAndPlay(this.time-this.startTime):this.gotoAndPlay(0)},i.pause=function(){this.paused=!0},i.getPaused=function(){return this.paused},i.resume=function(){this.paused=!1},i.gotoAndPlay=function(t){this.setTime(t),this.resume()},i.gotoAndStop=function(t){this.setTime(t),this.pause()},i.createRenderFrame=function(){this.renderFrame=new yn({camera:this.camera,renderer:this.renderer,keepColorBuffer:this.keepColorBuffer,globalVolume:this.globalVolume,postProcessingEnabled:this.postProcessingEnabled}),this.renderFrame.cachedTextures=this.textures},i.setTime=function(t){var e=this.speed,i=this.getPaused();i&&this.resume(),this.setSpeed(1),this.forwardTime(t+this.startTime),this.setSpeed(e),i&&this.pause(),this.emit("goto",{time:t})},i.addItem=function(t){this.items.push(t),t.setParent(this.rootItem)},i.forwardTime=function(t){for(var e=1e3*t-1e3*this.time,i=e<0,r=Math.abs(e),n=i?-15:15;r>15;r-=15)this.update(n);this.update(i?-r:r)},i.reset=function(){this.rendererOptions=null,this.isEnded=!1,this.isEndCalled=!1,this.rootComposition.time=0,this.pluginSystem.resetComposition(this,this.renderFrame)},i.prepareRender=function(){var t=this,e=this.renderFrame;this.postLoaders.length=0,this.pluginSystem.plugins.forEach((function(i){i.prepareRenderFrame(t,e)&&t.postLoaders.push(i)})),this.postLoaders.forEach((function(i){return i.postProcessFrame(t,e)}))},i.update=function(t){if(this.assigned&&!this.getPaused()){this.rootItem.isDuringPlay||(this.callAwake(this.rootItem),this.rootItem.beginPlay());var e=this.time;this.updateCompositionTime(t*this.speed/1e3);var i=1e3*(this.time-e);this.updatePluginLoaders(i),this.sceneTicking.update.tick(i),this.sceneTicking.lateUpdate.tick(i),this.updateCamera(),this.prepareRender(),this.isEnded&&!this.isEndCalled&&(this.isEndCalled=!0,this.emit("end",{composition:this})),this.shouldDispose()&&this.dispose()}},i.shouldDispose=function(){return this.isEnded&&this.rootItem.endBehavior===ee.destroy&&!this.reusable},i.callAwake=function(t){for(var e,i=w(t.components);!(e=i()).done;){var r=e.value;r.isAwakeCalled||(r.onAwake(),r.isAwakeCalled=!0)}for(var n,s=w(t.children);!(n=s()).done;){var a=n.value;this.callAwake(a)}},i.updateCamera=function(){this.camera.updateMatrix()},i.updatePluginLoaders=function(t){var e=this;this.pluginSystem.plugins.forEach((function(i){return i.onCompositionUpdate(e,t)}))},i.updateCompositionTime=function(t){if(this.rootComposition.state!==io.Paused&&this.rootComposition.isActiveAndEnabled){var e=this.time+t-this.startTime;t<0&&e<0&&(e=0);var i=this.rootItem.duration,r=this.rootItem.endBehavior,n=!1;if(e-i>.001)switch(n=!0,r){case ee.restart:e%=i,this.restart();break;case ee.freeze:e=Math.min(i,e);case ee.forward:case ee.destroy:}this.rootComposition.time=e+this.startTime,this.isEnded!==n&&(n?this.isEnded=!0:(this.isEnded=!1,this.isEndCalled=!1))}},i.getItemByName=function(t){return this.rootItem.find(t)},i.getHitTestRay=function(t,e){var i=this.renderFrame.editorTransform,r=i.x,n=i.y;return oa((t-i.z)/r,(e-i.w)/n,this.camera)},i.getEngine=function(){var t;return null==(t=this.renderer)?void 0:t.engine},i.hitTest=function(t,e,i,r){if(this.isDestroyed||!this.interactive)return[];var n=[],s=this.getHitTestRay(t,e);return this.refContent.forEach((function(a){var o;null==(o=a.getComponent(zu))||o.hitTest(s,t,e,n,i,r)})),n},i.addInteractiveItem=function(t,e){if(e===Gt.MESSAGE)return this.handleItemMessage({name:t.name,phrase:2,id:t.id,compositionId:this.id}),t.emit("message",{name:t.name,phrase:2,id:t.id}),t.id},i.removeInteractiveItem=function(t,e){e===Gt.MESSAGE&&(this.handleItemMessage({name:t.name,phrase:1,id:t.id,compositionId:this.id}),t.emit("message",{name:t.name,phrase:1,id:t.id}))},i.destroyItem=function(t){var e=this;t.type==Xt.composition?t.endBehavior!==ee.freeze&&t.getComponent(zu).items.forEach((function(t){return e.pluginSystem.plugins.forEach((function(i){return i.onCompositionItemRemoved(e,t)}))})):(k(this.items,t),this.pluginSystem.plugins.forEach((function(i){return i.onCompositionItemRemoved(e,t)})))},i.lost=function(t){this.videoState=this.textures.map((function(t){if("video"in t.source)return t.source.video.pause(),t.source.video.currentTime})),this.textures.map((function(t){return t.dispose()})),this.dispose()},i.dispose=function(){var t,e,i=this;if(!this.destroyed){this.destroyed=!0;var r={},n=this.textures;n&&this.keepResource&&n.forEach((function(t){(null==t?void 0:t.dispose)&&(r[t.id]=t.dispose,t.dispose=vt)})),this.rootItem.dispose(),this.renderFrame.dispose(),null==(t=this.rendererOptions)||t.emptyTexture.dispose(),null==(e=this.pluginSystem)||e.destroyComposition(this),this.update=function(){mt.error("Update disposed composition: "+i.name+".")},this.dispose=vt,n&&this.keepResource&&n.forEach((function(t){t.dispose=r[t.id],t.dispose()})),this.renderer.env!==As&&this.renderer.clear({stencilAction:hi.clear,clearStencil:0,depthAction:hi.clear,clearDepth:1,colorAction:hi.clear,clearColor:[0,0,0,0]})}},i.setEditorTransform=function(t,e,i){this.renderFrame.editorTransform.set(t,t,e,i)},i.translateByPixel=function(t,e){this.renderer?this.rootItem.translateByPixel(t,e):console.warn("Renderer not assigned. Operation aborted.")},i.setPositionByPixel=function(t,e){this.renderer?this.rootItem.setPositionByPixel(t,e):console.warn("Renderer not assigned. Operation aborted.")},i.translate=function(t,e,i){this.rootItem.translate(t,e,i)},i.setPosition=function(t,e,i){this.rootItem.setPosition(t,e,i)},i.rotate=function(t,e,i){this.rootItem.rotate(t,e,i)},i.setRotation=function(t,e,i){this.rootItem.setRotation(t,e,i)},i.scale=function(t,e,i){this.rootItem.scale(t,e,i)},i.setScale=function(t,e,i){this.rootItem.setScale(t,e,i)},i.offloadTexture=function(){this.textureOffloaded||(this.textures.forEach((function(t){return t&&t.offloadData()})),this.textureOffloaded=!0)},i.getRendererOptions=function(){return this.rendererOptions||(this.rendererOptions={emptyTexture:this.renderFrame.emptyTexture,cachePrefix:"-"}),this.rendererOptions},i.reloadTexture=function(){var t=this;return E((function(){return O(this,(function(e){switch(e.label){case 0:return t.textureOffloaded?[4,Promise.all(t.textures.map((function(t){return null==t?void 0:t.reloadData()})))]:[3,2];case 1:e.sent(),t.textureOffloaded=!1,e.label=2;case 2:return[2]}}))}))()},e.buildItemTree=function(t){for(var e,i=new Map,r=t.getComponent(zu).items,n=w(r);!(e=n()).done;){var s=e.value;i.set(s.id,s)}for(var a,o=w(r);!(a=o()).done;){var u=a.value;if(void 0===u.parentId)u.setParent(t);else{var h=i.get(u.parentId);if(!h)throw new Error("The element references a non-existent element, please check the data.");u.setParent(h)}}},Pe(e,[{key:"transform",get:function(){return this.rootItem.transform}},{key:"textures",get:function(){return this._textures}},{key:"items",get:function(){return this.rootComposition.items}},{key:"startTime",get:function(){return this.rootComposition.startTime}},{key:"time",get:function(){return this.rootComposition.time}},{key:"isDestroyed",get:function(){return this.destroyed}},{key:"viewportMatrix",get:function(){return this.camera.getViewportMatrix()},set:function(t){this.camera.setViewportMatrix(t)}}]),e}(Bu),Wu=function(t){function e(e,i){var r;return(r=t.call(this,e)||this).children=[],r.transform=new fo,r.time=-1,r.duration=0,r.start=0,r.endBehavior=ee.forward,r.type=Xt.base,r.components=[],r.isDuringPlay=!1,r.active=!0,r.visible=!0,r.speed=1,r.listIndex=0,r.isEnabled=!1,r.eventProcessor=new Bu,r.name="VFXItem",r.transform.name=r.name,r.transform.engine=e,i&&r.fromData(i),r}Qt(e,t);var i=e.prototype;return i.on=function(t,e,i){this.eventProcessor.on(t,e,i)},i.off=function(t,e){this.eventProcessor.off(t,e)},i.once=function(t,e){this.eventProcessor.once(t,e)},i.emit=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;r<e;r++)i[r-1]=arguments[r];var n;(n=this.eventProcessor).emit.apply(n,[].concat([t],i))},i.getListeners=function(t){return this.eventProcessor.getListeners(t)},i.setSpeed=function(t){this.speed=t},i.getSpeed=function(){return this.speed},i.addComponent=function(t){var e=new t(this.engine);return this.components.push(e),e.setVFXItem(this),e},i.getComponent=function(t){for(var e,i,r=w(this.components);!(i=r()).done;){var n=i.value;if(A(n,t)){e=n;break}}return e},i.getComponents=function(t){for(var e,i=[],r=w(this.components);!(e=r()).done;){var n=e.value;A(n,t)&&i.push(n)}return i},i.setParent=function(t){(t!==this||t)&&(this.parent&&k(this.parent.children,this),this.parent=t,this.transform.parentTransform=t.transform,t.children.push(this),!this.composition&&t.composition&&(this.composition=t.composition),!this.isDuringPlay&&t.isDuringPlay&&this.beginPlay())},i.setColor=function(t,e,i,r){},i.setOpacity=function(t){},i.setActive=function(t){this.active!==t&&(this.active=!!t,this.onActiveChanged())},i.setVisible=function(t){for(var e,i=w(this.components);!(e=i()).done;){e.value.enabled=t}this.visible=t},i.getVisible=function(){return this.visible},i.getWorldTransform=function(t){var e=null!=t?t:new fo({valid:!0});return e.cloneFromMatrix(this.transform.getWorldMatrix()),e},i.translate=function(t,e,i){this.transform.translate(t,e,i)},i.rotate=function(t,e,i){var r=new Or(t,e,i),n=ri.fromEuler(r);n.conjugate(),this.transform.rotateByQuat(n)},i.scale=function(t,e,i){this.transform.scaleBy(t,e,i)},i.setPositionByPixel=function(t,e){if(this.composition){var i=this.transform.getWorldPosition().z,r=this.composition.camera.getInverseVPRatio(i),n=r.x,s=r.y,a=this.composition.renderer.getWidth()/2,o=this.composition.renderer.getHeight()/2;this.transform.setPosition((2*t/a-1)*n,(1-2*e/o)*s,i)}},i.setPosition=function(t,e,i){this.transform.setPosition(t,e,i)},i.setRotation=function(t,e,i){this.transform.setRotation(t,e,i)},i.setScale=function(t,e,i){this.transform.setScale(t,e,i)},i.getBoundingBox=function(){},i.getHitTestParams=function(t){},i.getCurrentPosition=function(){var t=new Qe;return this.transform.assignWorldTRS(t),t},i.find=function(t){var e;if(this.name===t)return this;var i=[];(e=i).push.apply(e,[].concat(this.children));for(var r=0;r<i.length;){var n,s=i[r];if(r++,s.name===t)return s;(n=i).push.apply(n,[].concat(s.children))}},i.duplicate=function(){var t=new Map;this.gatherPreviousObjectID(t),this.resetGUID();var e=this.engine.findObject({id:this.defination.id});return e.resetGUID(),this.resetGUID(t),this.composition&&e.setParent(this.composition.rootItem),e},i.beginPlay=function(){this.isDuringPlay=!0,this.composition&&this.active&&!this.isEnabled&&this.onEnable();for(var t,e=w(this.children);!(t=e()).done;){var i=t.value;i.isDuringPlay||i.beginPlay()}},i.onActiveChanged=function(){this.isEnabled?this.onDisable():this.onEnable()},i.onEnable=function(){this.isEnabled=!0;for(var t,e=w(this.components);!(t=e()).done;){var i=t.value;i.enabled&&!i.isStartCalled&&(i.onStart(),i.isStartCalled=!0)}for(var r,n=w(this.components);!(r=n()).done;){var s=r.value;s.enabled&&!s.isEnableCalled&&s.enable()}},i.onDisable=function(){this.isEnabled=!1;for(var t,e=w(this.components);!(t=e()).done;){var i=t.value;i.enabled&&i.isEnableCalled&&i.disable()}},i.fromData=function(i){t.prototype.fromData.call(this,i);var r=i.id,n=i.name,s=i.delay,a=i.parentId,o=i.endBehavior,u=i.transform,h=i.duration,c=void 0===h?0:h;this.props=i,this.type=i.type,this.id=r.toString(),this.name=n,this.start=s||this.start;var l={};if(u){var f;if(l.position=(new Qe).copyFrom(u.position),u.quat)l.quat=new ri(u.quat.x,u.quat.y,u.quat.z,u.quat.w);else l.rotation=(new Or).copyFrom(null!=(f=u.eulerHint)?f:u.rotation);l.scale=(new Qe).copyFrom(u.scale),u.size&&(l.size=(new Ke).copyFrom(u.size)),u.anchor&&(l.anchor=(new Ke).copyFrom(u.anchor)),this.transform.setTransform(l)}if(this.transform.name=this.name,this.transform.engine=this.engine,this.parentId=a,this.duration=c,this.endBehavior=o,i.content||(i.content={options:{}}),c<0)throw new Error("Item duration can't be less than 0, see "+Cs["Item duration can't be less than 0"]+".");if(i.components){this.components.length=0;for(var d,p=w(i.components);!(d=p()).done;){var m=d.value,v=this.engine.findObject(m);this.components.push(v),A(v,Go)&&(this.components.includes(v.renderer)||this.components.push(v.renderer))}}e.isComposition(this)&&this.instantiatePreComposition()},i.toData=function(){var t,e;(this.defination.id=this.guid,this.defination.transform=this.transform.toData(),this.defination.dataType=_e.VFXItemData,"rootItem"!==(null==(t=this.parent)?void 0:t.name))&&(this.defination.parentId=null==(e=this.parent)?void 0:e.guid);if(!this.defination.components){this.defination.components=[];for(var i,r=w(this.components);!(i=r()).done;){var n=i.value;A(n,ti)&&this.defination.components.push(n)}}this.defination.content={}},i.translateByPixel=function(t,e){if(this.composition){var i=this.composition.renderer.canvas.getBoundingClientRect(),r=i.width,n=i.height,s=this.transform.getWorldPosition().z,a=this.composition.camera.getInverseVPRatio(s),o=a.x,u=a.y;this.transform.translate(2*t*o/r,-2*e*u/n,0)}},i.dispose=function(){if(this.resetChildrenParent(),this.composition){this.composition.destroyItem(this);for(var t,e=w(this.components.slice());!(t=e()).done;){t.value.dispose()}this.components=[],this._content=void 0,this._composition=null,this.transform.setValid(!1)}},i.resetChildrenParent=function(){for(var t,e=w(this.children);!(t=e()).done;){var i=t.value;this.parent&&i.setParent(this.parent)}var r;this.parent&&k(null==(r=this.parent)?void 0:r.children,this)},i.instantiatePreComposition=function(){var t=this.props.content.options.refId,e=this.engine.findEffectsObjectData(t);if(!e)throw new Error("Referenced precomposition with Id: "+t+" does not exist.");for(var i,r=w(e.components);!(i=r()).done;){var n=i.value,s=this.engine.findObject(n);if(s.item=this,this.components.push(s),s.setInstanceId(wt()),A(s,zu))for(var a,o=w(s.items);!(a=o()).done;){var u=a.value;u.setInstanceId(wt());for(var h,c=w(u.components);!(h=c()).done;){h.value.setInstanceId(wt())}}}Yu.buildItemTree(this)},i.resetGUID=function(t){var e,i=null!=(e=null==t?void 0:t.get(this))?e:wt();this.setInstanceId(i);for(var r,n=w(this.components);!(r=n()).done;){var s,a=r.value,o=null!=(s=null==t?void 0:t.get(a))?s:wt();a.setInstanceId(o)}for(var u,h=w(this.children);!(u=h()).done;){u.value.resetGUID(t)}},i.gatherPreviousObjectID=function(t){t.set(this,this.getInstanceId());for(var e,i=w(this.components);!(e=i()).done;){var r=e.value;t.set(r,r.getInstanceId())}for(var n,s=w(this.children);!(n=s()).done;){n.value.gatherPreviousObjectID(t)}},e.isComposition=function(t){return t.type===Xt.composition},e.isSprite=function(t){return t.type===Xt.sprite},e.isParticle=function(t){return t.type===Xt.particle},e.isNull=function(t){return t.type===Xt.null},e.isTree=function(t){return t.type===Xt.tree},e.isCamera=function(t){return t.type===Xt.camera},e.isAncestor=function(t,e){for(var i=e.parent;i;){if(i===t)return!0;i=i.parent}return!1},Pe(e,[{key:"content",get:function(){return this._content}},{key:"composition",get:function(){return this._composition},set:function(t){this._composition=t;for(var e,i=w(this.children);!(e=i()).done;){var r=e.value;r.composition||(r.composition=t)}}},{key:"compositionReusable",get:function(){var t,e;return null!=(e=null==(t=this.composition)?void 0:t.reusable)&&e}},{key:"renderOrder",get:function(){return this.listIndex},set:function(t){if(this.listIndex!==t){this.listIndex=t;for(var e,i=w(this.components);!(e=i()).done;){var r=e.value;A(r,Ge)&&(r.priority=t)}}}},{key:"isActive",get:function(){return this.active}},{key:"isVisible",get:function(){return this.visible}}]),e}(ze);Wu=S([Ne(_e.VFXItemData)],Wu),function(t){t.is=function(t,e){return t.type===e},t.isComposition=function(t){return t.type===Xt.composition},t.isParticle=function(t){return t.type===Xt.particle},t.isNull=function(t){return t.type===Xt.null}}(Uu||(Uu={}));var Zu=[1,1,1,1],qu=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).renderColor=[1,1,1,1],e}Qt(e,t);var i=e.prototype;return i.processFrame=function(t){var e=t.output.getUserData();if(A(e,Wu)){if(this.activeComponent||(this.activeComponent=this.getActiveComponent(e)),!this.activeMaterial){var i,r;this.activeMaterial=null==(i=this.activeComponent)?void 0:i.material;var n=null==(r=this.activeMaterial)?void 0:r.getColor("_Color");n&&(this.startColor=n.toArray())}var s,a,o,u=ra(Zu,1),h=this.time/e.duration,c=this.opacityOverLifetime,l=this.colorOverLifetime;if(l&&(u=G(l,h,!0),s=!0),c&&(u[3]*=c.getValue(h),s=!0),s)na(this.renderColor,u,this.startColor),null==(o=this.activeMaterial)||null==(a=o.getColor("_Color"))||a.setFromArray(this.renderColor)}},i.create=function(t){this.clipData=t;var e,i=t.colorOverLifetime;i&&(this.opacityOverLifetime=Ka(null!=(e=i.opacity)?e:1),i.color&&i.color[0]===$t.GRADIENT_COLOR&&(this.colorOverLifetime=j(i.color[1])));return this},i.getActiveComponent=function(t){return t.getComponent(Ls)},e}(ao),Ku=0,Qu=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.createPlayable=function(t){var e=new qu(t);return e.create(this.data),e},i.fromData=function(t){this.data=t},e}(uo);Qu=S([Ne(_e.SpriteColorPlayableAsset)],Qu);var Ju=function(t){function e(e,i){var r;return(r=t.call(this,e)||this).frameAnimationLoop=!1,r.name="MSprite"+Ku++,i&&r.fromData(i),r}Qt(e,t);var i=e.prototype;return i.onUpdate=function(t){var e=this,i=this.item.time,r=this.item.duration;i>r&&this.frameAnimationLoop&&(i%=r);var n=Math.min(Math.max(i/r,0),1),s=this.textureSheetAnimation,a=this.renderer.texture.source.video;if(a&&(0===i?a.pause():a.play().catch((function(t){e.engine.renderErrors.add(t)})),this.renderer.texture.uploadCurrentVideoFrame()),s){var o,u,h,c,l,f=s.total||s.row*s.col,d=0,p=0,m=1,v=1;if(this.splits){var y=this.splits[0];u=y[4],d=y[0],p=y[1],u?(m=y[3],v=y[2]):(m=y[2],v=y[3])}if(u?(h=1/s.row*m,c=1/s.col*v):(h=1/s.col*m,c=1/s.row*v),s.animate){var g=Math.round(n*(f-1)),x=Math.floor(g/s.col),b=g-x*s.col;l=u?[h*x,c*(s.col-b)]:[h*b,c*(1+x)]}else l=[0,c];null==(o=this.material.getVector4("_TexOffset"))||o.setFromArray([d+l[0],v+p-l[1],h,c])}},i.onDestroy=function(){var t=this.renderer.texture.source;t.sourceType===ci.video&&(null==t?void 0:t.video)&&(t.video.pause(),t.video.src="",t.video.load())},i.fromData=function(e){t.prototype.fromData.call(this,e);var i=e.interaction,r=e.options;this.interaction=i;var n=r.startColor||[1,1,1,1];this.material.setColor("_Color",(new ii).setFromArray(n))},e}(Ls);Ju=S([Ne(_e.SpriteComponent)],Ju);var $u=8;function th(t){return t.maxVertexUniforms>=256?$u=32:t.maxVertexUniforms>=128?$u=16:void 0}function eh(t){$u=t}var ih=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e}(qt),rh=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e}(qt),nh=function(){function t(t){this.curveValues={},this.playable=t}var e=t.prototype;return e.setCurveValue=function(t,e,i){return this.findCurveValue(t,e)?this.curveValues[t+e].value=i:this.curveValues[t+e]={componentType:t,propertyName:e,value:i},this.curveValues[t+e]},e.findCurveValue=function(t,e){return this.curveValues[t+e]},t}(),sh=function(t){function e(e){var i;return(i=t.call(this,e)||this).animationStream=new nh(ho(i)),i}return Qt(e,t),e}(ao),ah=new Or,oh=new Qe(1,1,1),uh=new Qe,hh=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.start=function(){var t=this.boundObject,e=t.transform.scale;this.originalTransform={position:t.transform.position.clone(),rotation:t.transform.getRotation().clone(),scale:new Qe(e.x,e.y,e.x)};var i,r=this.data.positionOverLifetime,n=this.data.rotationOverLifetime,s=this.data.sizeOverLifetime;if(r&&0!==Object.keys(r).length){this.positionOverLifetime=r,r.path&&(this.originalTransform.path=Ka(r.path));var a=r.linearX||r.linearY||r.linearZ;a&&(this.linearVelOverLifetime={x:r.linearX&&Ka(r.linearX),y:r.linearY&&Ka(r.linearY),z:r.linearZ&&Ka(r.linearZ),asMovement:r.asMovement,enabled:!!a});var o=r.orbitalX||r.orbitalY||r.orbitalZ;o&&(this.orbitalVelOverLifetime={x:r.orbitalX&&Ka(r.orbitalX),y:r.orbitalY&&Ka(r.orbitalY),z:r.orbitalZ&&Ka(r.orbitalZ),center:ia(r.orbCenter),asRotation:r.asRotation,enabled:!!o}),this.speedOverLifetime=r.speedOverLifetime&&Ka(r.speedOverLifetime)}if(s&&(s.separateAxes?(this.sizeSeparateAxes=!0,this.sizeXOverLifetime=Ka(s.x||1),this.sizeYOverLifetime=Ka(s.y||1),this.sizeZOverLifetime=Ka(s.z||1)):this.sizeXOverLifetime=Ka(s.size||1)),n&&(this.rotationOverLifetime={asRotation:n.asRotation,separateAxes:n.separateAxes,z:Ka(n.z||0)},n.separateAxes)){var u=this.rotationOverLifetime;u.x=Ka(n.x||0),u.y=Ka(n.y||0)}this.gravity=Qe.fromArray((null==r?void 0:r.gravity)||[]),this.gravityModifier=Ka(null!=(i=null==r?void 0:r.gravityOverLifetime)?i:0),this.direction=(null==r?void 0:r.direction)?Qe.fromArray(r.direction).normalize():new Qe,this.startSpeed=(null==r?void 0:r.startSpeed)||0,this.velocity=this.direction.clone(),this.velocity.multiply(this.startSpeed)},i.processFrame=function(t){if(!this.boundObject){var e=t.output.getUserData();A(e,Wu)&&(this.boundObject=e,this.start())}this.boundObject&&this.boundObject.composition&&this.sampleAnimation()},i.sampleAnimation=function(){var t=this,e=this.boundObject,i=e.duration,r=this.time/i;if(r=r<0?0:r>1?1:r,this.sizeXOverLifetime){oh.x=this.sizeXOverLifetime.getValue(r),this.sizeSeparateAxes?(oh.y=this.sizeYOverLifetime.getValue(r),oh.z=this.sizeZOverLifetime.getValue(r)):oh.z=oh.y=oh.x;var n=this.originalTransform.scale;e.transform.setScale(oh.x*n.x,oh.y*n.y,oh.z*n.z)}if(this.rotationOverLifetime){var s=function(e){return t.rotationOverLifetime.asRotation?e.getValue(r):e.getIntegrateValue(0,r,i)},a=s(this.rotationOverLifetime.z),o=this.rotationOverLifetime.separateAxes;ah.x=o?s(this.rotationOverLifetime.x):0,ah.y=o?s(this.rotationOverLifetime.y):0,ah.z=a;var u=ah.addEulers(this.originalTransform.rotation,ah);e.transform.setRotation(u.x,u.y,u.z)}if(this.positionOverLifetime){var h=uh;ea(h,this,this.gravity,this.time,i,this.originalTransform.position,this.velocity),this.originalTransform.path&&h.add(this.originalTransform.path.getValue(r)),e.transform.setPosition(h.x,h.y,h.z)}},e}(sh),ch=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.createPlayable=function(t){var e=new hh(t);return e.data=this.transformAnimationData,e},i.fromData=function(t){this.transformAnimationData=t},e}(uo);ch=S([Ne(_e.TransformPlayableAsset)],ch);var lh=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.processFrame=function(t){var e=t.output.getUserData();A(e,Wu)&&(e.time=this.time)},e}(ao),fh=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.createPlayable=function(t){return new lh(t)},e}(uo);fh=S([Ne(_e.ActivationPlayableAsset)],fh);var dh=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).duration=0,e.positionCurves=[],e.rotationCurves=[],e.scaleCurves=[],e.floatCurves=[],e}Qt(e,t);var i=e.prototype;return i.sampleAnimation=function(t,e){var i=e/t.duration;i=i<0?0:i>1?1:i;for(var r,n=w(this.positionCurves);!(r=n()).done;){var s=r.value,a=s.keyFrames.getValue(i),o=this.findTarget(t,s.path);null==o||o.transform.setPosition(a.x,a.y,a.z)}for(var u,h=w(this.rotationCurves);!(u=h()).done;){var c=u.value,l=c.keyFrames.getValue(i),f=this.findTarget(t,c.path);null==f||f.transform.setQuaternion(l.x,l.y,l.z,l.w)}for(var d,p=w(this.scaleCurves);!(d=p()).done;){var m=d.value,v=m.keyFrames.getValue(i),y=this.findTarget(t,m.path);null==y||y.transform.setScale(v.x,v.y,v.z)}},i.fromData=function(t){this.positionCurves.length=0,this.scaleCurves.length=0,this.floatCurves.length=0;for(var e,i=w(t.positionCurves);!(e=i()).done;){var r=e.value,n={path:r.path,keyFrames:Ka(r.keyFrames)};this.duration=Math.max(this.duration,n.keyFrames.getMaxTime()),this.positionCurves.push(n)}for(var s,a=w(t.rotationCurves);!(s=a()).done;){var o=s.value,u={path:o.path,keyFrames:Ka(o.keyFrames)};this.duration=Math.max(this.duration,u.keyFrames.getMaxTime()),this.rotationCurves.push(u)}for(var h,c=w(t.scaleCurves);!(h=c()).done;){var l=h.value,f={path:l.path,keyFrames:Ka(l.keyFrames)};this.duration=Math.max(this.duration,f.keyFrames.getMaxTime()),this.scaleCurves.push(f)}for(var d,p=w(t.floatCurves);!(d=p()).done;){var m=d.value,v={path:m.path,keyFrames:Ka(m.keyFrames),property:m.property,className:m.className};this.duration=Math.max(this.duration,v.keyFrames.getMaxTime()),this.floatCurves.push(v)}},i.findTarget=function(t,e){for(var i,r=t,n=w(e);!(i=n()).done;){for(var s,a=i.value,o=!1,u=w(r.children);!(s=u()).done;){var h=s.value;if(h.name===a){r=h,o=!0;break}}if(!o)return}return r},e}(ze);dh=S([Ne(_e.AnimationClip)],dh);var ph=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.processFrame=function(t){var e=t.output.getUserData();A(e,Wu)&&e.composition&&this.clip.sampleAnimation(e,this.time)},e}(ao),mh=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.x=0,this.y=0,this.x=t,this.y=e}var e=t.prototype;return e.clone=function(){return new t(this.x,this.y)},e.copyFrom=function(t){return this.set(t.x,t.y),this},e.copyTo=function(t){return t.set(this.x,this.y),t},e.equals=function(t){return t.x===this.x&&t.y===this.y},e.set=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.x=t,this.y=e,this},Pe(t,null,[{key:"shared",get:function(){return vh.x=0,vh.y=0,vh}}]),t}(),vh=new mh,yh=1e-4,gh=1e-4;function xh(t,e,i,r,n,s,a,o){var u,h;a?(u=r,h=-i):(u=-r,h=i);var c=t-i*n+u,l=e-r*n+h,f=t+i*s+u,d=e+r*s+h;return o.push(c,l),o.push(f,d),2}function bh(t,e,i,r,n,s,a,o){var u=i-t,h=r-e,c=Math.atan2(u,h),l=Math.atan2(n-t,s-e);o&&c<l?c+=2*Math.PI:!o&&c>l&&(l+=2*Math.PI);var f=c,d=l-c,p=Math.abs(d),m=Math.sqrt(u*u+h*h),v=1+(15*p*Math.sqrt(m)/Math.PI>>0),y=d/v;if(f+=y,o){a.push(t,e),a.push(i,r);for(var g=1,x=f;g<v;g++,x+=y)a.push(t,e),a.push(t+Math.sin(x)*m,e+Math.cos(x)*m);a.push(t,e),a.push(n,s)}else{a.push(i,r),a.push(t,e);for(var b=1,T=f;b<v;b++,T+=y)a.push(t+Math.sin(T)*m,e+Math.cos(T)*m),a.push(t,e);a.push(n,s),a.push(t,e)}return 2*v}function Th(t,e,i,r,n,s,a,o,u){var h=yh;if(0!==t.length){var c=e,l=c.alignment;if(.5!==e.alignment){var f=function(t){var e=t.length;if(e<6)return 1;for(var i=0,r=0,n=t[e-2],s=t[e-1];r<e;r+=2){var a=t[r],o=t[r+1];i+=(a-n)*(o+s),n=a,s=o}return i<0?-1:1}(t);i&&(f*=-1),l=(l-.5)*f+.5}var d=new mh(t[0],t[1]),p=new mh(t[t.length-2],t[t.length-1]),m=r,v=Math.abs(d.x-p.x)<h&&Math.abs(d.y-p.y)<h;if(m){t=t.slice(),v&&(t.pop(),t.pop(),p.set(t[t.length-2],t[t.length-1]));var y=.5*(d.x+p.x),g=.5*(p.y+d.y);t.unshift(y,g),t.push(y,g)}var x=n,b=t.length/2,T=t.length,E=x.length/2,_=c.width/2,w=_*_,A=c.miterLimit*c.miterLimit,C=t[0],S=t[1],O=t[2],R=t[3],M=0,I=0,P=-(S-R),L=C-O,F=0,V=0,N=Math.sqrt(P*P+L*L)+Ye;P/=N,L/=N,P*=_,L*=_;var D=2*(1-l),k=2*l;m||(c.cap===xe.Round?T+=bh(C-P*(D-k)*.5,S-L*(D-k)*.5,C-P*D,S-L*D,C+P*k,S+L*k,x,!0)+2:c.cap===xe.Square&&(T+=xh(C,S,P,L,D,k,!0,x))),x.push(C-P*D,S-L*D),x.push(C+P*k,S+L*k);for(var z=1;z<b-1;++z){C=t[2*(z-1)],S=t[2*(z-1)+1],O=t[2*z],R=t[2*z+1],M=t[2*(z+1)],I=t[2*(z+1)+1],P=-(S-R),L=C-O,P/=N=Math.sqrt(P*P+L*L)+Ye,L/=N,P*=_,L*=_,F=-(R-I),V=O-M,F/=N=Math.sqrt(F*F+V*V)+Ye,V/=N,F*=_,V*=_;var U=O-C,B=S-R,G=O-M,j=I-R,X=U*G+B*j,H=B*G-j*U,Y=H<0;if(Math.abs(H)<.001*Math.abs(X))x.push(O-P*D,R-L*D),x.push(O+P*k,R+L*k),X>=0&&(c.join===be.Round?T+=bh(O,R,O-P*D,R-L*D,O-F*D,R-V*D,x,!1)+4:T+=2,x.push(O-F*k,R-V*k),x.push(O+F*D,R+V*D));else{var W=(-P+C)*(-L+R)-(-P+O)*(-L+S),Z=(-F+M)*(-V+R)-(-F+O)*(-V+I),q=(U*Z-G*W)/H,K=(j*W-B*Z)/H,Q=(q-O)*(q-O)+(K-R)*(K-R),J=O+(q-O)*D,$=R+(K-R)*D,tt=O-(q-O)*k,et=R-(K-R)*k,it=Y?D:k;Q<=Math.min(U*U+B*B,G*G+j*j)+it*it*w?c.join===be.Bevel||Q/w>A?(Y?(x.push(J,$),x.push(O+P*k,R+L*k),x.push(J,$),x.push(O+F*k,R+V*k)):(x.push(O-P*D,R-L*D),x.push(tt,et),x.push(O-F*D,R-V*D),x.push(tt,et)),T+=2):c.join===be.Round?Y?(x.push(J,$),x.push(O+P*k,R+L*k),T+=bh(O,R,O+P*k,R+L*k,O+F*k,R+V*k,x,!0)+4,x.push(J,$),x.push(O+F*k,R+V*k)):(x.push(O-P*D,R-L*D),x.push(tt,et),T+=bh(O,R,O-P*D,R-L*D,O-F*D,R-V*D,x,!1)+4,x.push(O-F*D,R-V*D),x.push(tt,et)):(x.push(J,$),x.push(tt,et)):(x.push(O-P*D,R-L*D),x.push(O+P*k,R+L*k),c.join===be.Round?T+=Y?bh(O,R,O+P*k,R+L*k,O+F*k,R+V*k,x,!0)+2:bh(O,R,O-P*D,R-L*D,O-F*D,R-V*D,x,!1)+2:c.join===be.Miter&&Q/w<=A&&(Y?(x.push(tt,et),x.push(tt,et)):(x.push(J,$),x.push(J,$)),T+=2),x.push(O-F*D,R-V*D),x.push(O+F*k,R+V*k),T+=2)}}C=t[2*(b-2)],S=t[2*(b-2)+1],O=t[2*(b-1)],P=-(S-(R=t[2*(b-1)+1])),L=C-O,P/=N=Math.sqrt(P*P+L*L)+Ye,L/=N,P*=_,L*=_,x.push(O-P*D,R-L*D),x.push(O+P*k,R+L*k),m||(c.cap===xe.Round?T+=bh(O-P*(D-k)*.5,R-L*(D-k)*.5,O-P*D,R-L*D,O+P*k,R+L*k,x,!1)+2:c.cap===xe.Square&&(T+=xh(O,R,P,L,D,k,!1,x)));for(var rt=gh*gh,nt=E;nt<T+E-2;++nt)C=x[2*nt],S=x[2*nt+1],O=x[2*(nt+1)],R=x[2*(nt+1)+1],M=x[2*(nt+2)],I=x[2*(nt+2)+1],Math.abs(C*(R-I)+O*(I-S)+M*(S-R))<rt||o.push(nt,nt+1,nt+2)}}var Eh=function(){},_h="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},wh={exports:{}};!function(t){var e;function i(t,e){return t.b===e.b&&t.a===e.a}function r(t,e){return t.b<e.b||t.b===e.b&&t.a<=e.a}function n(t,e,i){var r=e.b-t.b,n=i.b-e.b;return 0<r+n?r<n?e.a-t.a+r/(r+n)*(t.a-i.a):e.a-i.a+n/(r+n)*(i.a-t.a):0}function s(t,e,i){var r=e.b-t.b,n=i.b-e.b;return 0<r+n?(e.a-i.a)*r+(e.a-t.a)*n:0}function a(t,e){return t.a<e.a||t.a===e.a&&t.b<=e.b}function o(t,e,i){var r=e.a-t.a,n=i.a-e.a;return 0<r+n?r<n?e.b-t.b+r/(r+n)*(t.b-i.b):e.b-i.b+n/(r+n)*(i.b-t.b):0}function u(t,e,i){var r=e.a-t.a,n=i.a-e.a;return 0<r+n?(e.b-i.b)*r+(e.b-t.b)*n:0}function h(t){return r(t.b.a,t.a)}function c(t){return r(t.a,t.b.a)}function l(t,e,i,r){return(t=0>t?0:t)<=(i=0>i?0:i)?0===i?(e+r)/2:e+t/(t+i)*(r-e):r+i/(t+i)*(e-r)}function f(t){var e=y(t.b);return x(e,t.c),x(e.b,t.c),b(e,t.a),e}function d(t,e){var i=!1,r=!1;t!==e&&(e.a!==t.a&&(r=!0,E(e.a,t.a)),e.d!==t.d&&(i=!0,_(e.d,t.d)),g(e,t),r||(x(e,t.a),t.a.c=t),i||(b(e,t.d),t.d.a=t))}function p(t){var e=t.b,i=!1;t.d!==t.b.d&&(i=!0,_(t.d,t.b.d)),t.c===t?E(t.a,null):(t.b.d.a=$(t),t.a.c=t.c,g(t,$(t)),i||b(t,t.d)),e.c===e?(E(e.a,null),_(e.d,null)):(t.d.a=$(e),e.a.c=e.c,g(e,$(e))),T(t)}function m(t){var e=y(t),i=e.b;return g(e,t.e),e.a=t.b.a,x(i,e.a),e.d=i.d=t.d,e=e.b,g(t.b,$(t.b)),g(t.b,e),t.b.a=e.a,e.b.a.c=e.b,e.b.d=t.b.d,e.f=t.f,e.b.f=t.b.f,e}function v(t,e){var i=!1,r=y(t),n=r.b;return e.d!==t.d&&(i=!0,_(e.d,t.d)),g(r,t.e),g(n,e),r.a=t.b.a,n.a=e.a,r.d=n.d=t.d,t.d.a=n,i||b(r,t.d),r}function y(t){var e=new J,i=new J,r=t.b.h;return i.h=r,r.b.h=e,e.h=t,t.b.h=i,e.b=i,e.c=e,e.e=i,i.b=e,i.c=i,i.e=e}function g(t,e){var i=t.c,r=e.c;i.b.e=e,r.b.e=t,t.c=r,e.c=i}function x(t,e){var i=e.f,r=new et(e,i);i.e=r,e.f=r,i=r.c=t;do{i.a=r,i=i.c}while(i!==t)}function b(t,e){var i=e.d,r=new Q(e,i);i.b=r,e.d=r,r.a=t,r.c=e.c,i=t;do{i.d=r,i=i.e}while(i!==t)}function T(t){var e=t.h;t=t.b.h,e.b.h=t,t.b.h=e}function E(t,e){var i=t.c,r=i;do{r.a=e,r=r.c}while(r!==i);i=t.f,(r=t.e).f=i,i.e=r}function _(t,e){var i=t.a,r=i;do{r.d=e,r=r.e}while(r!==i);i=t.d,(r=t.b).d=i,i.b=r}function w(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e}var A=4e150;function C(t,e){t.f+=e.f,t.b.f+=e.b.f}function S(t,e,i){return t=t.a,e=e.a,i=i.a,e.b.a===t?i.b.a===t?r(e.a,i.a)?0>=s(i.b.a,e.a,i.a):0<=s(e.b.a,i.a,e.a):0>=s(i.b.a,t,i.a):i.b.a===t?0<=s(e.b.a,t,e.a):(e=n(e.b.a,t,e.a))>=(t=n(i.b.a,t,i.a))}function O(t){t.a.i=null;var e=t.e;e.a.c=e.c,e.c.a=e.a,t.e=null}function R(t,e){p(t.a),t.c=!1,t.a=e,e.i=t}function M(t){var e=t.a.a;do{t=dt(t)}while(t.a.a===e);return t.c&&(R(t,e=v(ft(t).a.b,t.a.e)),t=dt(t)),t}function I(t,e,i){var r=new lt;return r.a=i,r.e=H(t.f,e.e,r),i.i=r}function P(t,e){switch(t.s){case 100130:return 0!=(1&e);case 100131:return 0!==e;case 100132:return 0<e;case 100133:return 0>e;case 100134:return 2<=e||-2>=e}return!1}function L(t){var e=t.a,i=e.d;i.c=t.d,i.a=e,O(t)}function F(t,e,i){for(t=e,e=e.a;t!==i;){t.c=!1;var r=ft(t),n=r.a;if(n.a!==e.a){if(!r.c){L(t);break}R(r,n=v(e.c.b,n.b))}e.c!==n&&(d($(n),n),d(e,n)),L(t),e=r.a,t=r}return e}function V(t,e,i,r,n,s){var a=!0;do{I(t,e,i.b),i=i.c}while(i!==r);for(null===n&&(n=ft(e).a.b.c);(i=(r=ft(e)).a.b).a===n.a;)i.c!==n&&(d($(i),i),d($(n),i)),r.f=e.f-i.f,r.d=P(t,r.f),e.b=!0,!a&&z(t,e)&&(C(i,n),O(e),p(n)),a=!1,e=r,n=i;e.b=!0,s&&B(t,e)}function N(t,e,i,r,n){var s=[e.g[0],e.g[1],e.g[2]];e.d=null,e.d=t.o&&t.o(s,i,r,t.c)||null,null===e.d&&(n?t.n||(K(t,100156),t.n=!0):e.d=i[0])}function D(t,e,i){var r=[null,null,null,null];r[0]=e.a.d,r[1]=i.a.d,N(t,e.a,r,[.5,.5,0,0],!1),d(e,i)}function k(t,e,i,r,n){var s=Math.abs(e.b-t.b)+Math.abs(e.a-t.a),a=Math.abs(i.b-t.b)+Math.abs(i.a-t.a),o=n+1;r[n]=.5*a/(s+a),r[o]=.5*s/(s+a),t.g[0]+=r[n]*e.g[0]+r[o]*i.g[0],t.g[1]+=r[n]*e.g[1]+r[o]*i.g[1],t.g[2]+=r[n]*e.g[2]+r[o]*i.g[2]}function z(t,e){var n=ft(e),a=e.a,o=n.a;if(r(a.a,o.a)){if(0<s(o.b.a,a.a,o.a))return!1;if(i(a.a,o.a)){if(a.a!==o.a){n=t.e;var u=a.a.h;if(0<=u){var h=(n=n.b).d,c=n.e,l=n.c,f=l[u];h[f]=h[n.a],l[h[f]]=f,f<=--n.a&&(1>=f||r(c[h[f>>1]],c[h[f]])?ht(n,f):ct(n,f)),c[u]=null,l[u]=n.b,n.b=u}else for(n.c[-(u+1)]=null;0<n.a&&null===n.c[n.d[n.a-1]];)--n.a;D(t,$(o),a)}}else m(o.b),d(a,$(o)),e.b=n.b=!0}else{if(0>s(a.b.a,o.a,a.a))return!1;dt(e).b=e.b=!0,m(a.b),d($(o),a)}return!0}function U(t,e){var h=ft(e),c=e.a,f=h.a,p=c.a,v=f.a,y=c.b.a,g=f.b.a,x=new et;if(s(y,t.a,p),s(g,t.a,v),p===v||Math.min(p.a,y.a)>Math.max(v.a,g.a))return!1;if(r(p,v)){if(0<s(g,p,v))return!1}else if(0>s(y,v,p))return!1;var b,T,E=y,_=p,w=g,A=v;if(r(E,_)||(b=E,E=_,_=b),r(w,A)||(b=w,w=A,A=b),r(E,w)||(b=E,E=w,w=b,b=_,_=A,A=b),r(w,_)?r(_,A)?(0>(b=n(E,w,_))+(T=n(w,_,A))&&(b=-b,T=-T),x.b=l(b,w.b,T,_.b)):(0>(b=s(E,w,_))+(T=-s(E,A,_))&&(b=-b,T=-T),x.b=l(b,w.b,T,A.b)):x.b=(w.b+_.b)/2,a(E,_)||(b=E,E=_,_=b),a(w,A)||(b=w,w=A,A=b),a(E,w)||(b=E,E=w,w=b,b=_,_=A,A=b),a(w,_)?a(_,A)?(0>(b=o(E,w,_))+(T=o(w,_,A))&&(b=-b,T=-T),x.a=l(b,w.a,T,_.a)):(0>(b=u(E,w,_))+(T=-u(E,A,_))&&(b=-b,T=-T),x.a=l(b,w.a,T,A.a)):x.a=(w.a+_.a)/2,r(x,t.a)&&(x.b=t.a.b,x.a=t.a.a),E=r(p,v)?p:v,r(E,x)&&(x.b=E.b,x.a=E.a),i(x,p)||i(x,v))return z(t,e),!1;if(!i(y,t.a)&&0<=s(y,t.a,x)||!i(g,t.a)&&0>=s(g,t.a,x)){if(g===t.a)return m(c.b),d(f.b,c),c=ft(e=M(e)).a,F(t,ft(e),h),V(t,e,$(c),c,c,!0),!0;if(y===t.a){m(f.b),d(c.e,$(f)),v=(p=h=e).a.b.a;do{p=dt(p)}while(p.a.b.a===v);return p=ft(e=p).a.b.c,h.a=$(f),V(t,e,(f=F(t,h,null)).c,c.b.c,p,!0),!0}return 0<=s(y,t.a,x)&&(dt(e).b=e.b=!0,m(c.b),c.a.b=t.a.b,c.a.a=t.a.a),0>=s(g,t.a,x)&&(e.b=h.b=!0,m(f.b),f.a.b=t.a.b,f.a.a=t.a.a),!1}return m(c.b),m(f.b),d($(f),c),c.a.b=x.b,c.a.a=x.a,c.a.h=rt(t.e,c.a),c=c.a,f=[0,0,0,0],x=[p.d,y.d,v.d,g.d],c.g[0]=c.g[1]=c.g[2]=0,k(c,p,y,f,0),k(c,v,g,f,2),N(t,c,x,f,!0),dt(e).b=e.b=h.b=!0,!1}function B(t,e){for(var i=ft(e);;){for(;i.b;)e=i,i=ft(i);if(!e.b&&(i=e,null===(e=dt(e))||!e.b))break;e.b=!1;var n,a=e.a,o=i.a;if(n=a.b.a!==o.b.a)t:{var u=ft(n=e),h=n.a,c=u.a,l=void 0;if(r(h.b.a,c.b.a)){if(0>s(h.b.a,c.b.a,h.a)){n=!1;break t}dt(n).b=n.b=!0,l=m(h),d(c.b,l),l.d.c=n.d}else{if(0<s(c.b.a,h.b.a,c.a)){n=!1;break t}n.b=u.b=!0,l=m(c),d(h.e,c.b),l.b.d.c=n.d}n=!0}if(n&&(i.c?(O(i),p(o),o=(i=ft(e)).a):e.c&&(O(e),p(a),a=(e=dt(i)).a)),a.a!==o.a)if(a.b.a===o.b.a||e.c||i.c||a.b.a!==t.a&&o.b.a!==t.a)z(t,e);else if(U(t,e))break;a.a===o.a&&a.b.a===o.b.a&&(C(o,a),O(e),p(a),e=dt(i))}}function G(t,e){t.a=e;for(var n=e.c;null===n.i;)if((n=n.c)===e.c){n=t;var a=e;(h=new lt).a=a.c.b;var o=(l=n.f).a;do{o=o.a}while(null!==o.b&&!l.c(l.b,h,o.b));var u=ft(l=o.b),h=l.a;o=u.a;if(0===s(h.b.a,a,h.a))i((h=l.a).a,a)||i(h.b.a,a)||(m(h.b),l.c&&(p(h.c),l.c=!1),d(a.c,h),G(n,a));else{var c=r(o.b.a,h.b.a)?l:u;u=void 0;l.d||c.c?(u=c===l?v(a.c.b,h.e):v(o.b.c.b,a.c).b,c.c?R(c,u):(h=n,(l=I(n,l,u)).f=dt(l).f+l.a.f,l.d=P(h,l.f)),G(n,a)):V(n,l,a.c,a.c,null,!0)}return}if(l=(h=ft(n=M(n.i))).a,(h=F(t,h,null)).c===l){h=(l=h).c,o=ft(n),u=n.a,c=o.a;var l,f=!1;u.b.a!==c.b.a&&U(t,n),i(u.a,t.a)&&(d($(h),u),h=ft(n=M(n)).a,F(t,ft(n),o),f=!0),i(c.a,t.a)&&(d(l,$(c)),l=F(t,o,null),f=!0),f?V(t,n,l.c,h,h,!0):(a=r(c.a,u.a)?$(c):u,V(t,n,a=v(l.c.b,a),a.c,a.c,!1),a.b.i.c=!0,B(t,n))}else V(t,n,h.c,l,l,!0)}function j(t,e){var i=new lt,r=f(t.b);r.a.b=A,r.a.a=e,r.b.a.b=-A,r.b.a.a=e,t.a=r.b.a,i.a=r,i.f=0,i.d=!1,i.c=!1,i.h=!0,i.b=!1,r=H(r=t.f,r.a,i),i.e=r}function X(t){this.a=new Y,this.b=t,this.c=S}function H(t,e,i){do{e=e.c}while(null!==e.b&&!t.c(t.b,e.b,i));return t=new Y(i,e.a,e),e.a.c=t,e.a=t}function Y(t,e,i){this.b=t||null,this.a=e||this,this.c=i||this}function W(){this.d=Z,this.p=this.b=this.q=null,this.j=[0,0,0],this.s=100130,this.n=!1,this.o=this.a=this.e=this.f=null,this.m=!1,this.c=this.r=this.i=this.k=this.l=this.h=null}var Z=0;function q(t,e){if(t.d!==e)for(;t.d!==e;)if(t.d<e)switch(t.d){case Z:K(t,100151),t.u(null);break;case 1:K(t,100152),t.t()}else switch(t.d){case 2:K(t,100154),t.v();break;case 1:K(t,100153),t.w()}}function K(t,e){t.p&&t.p(e,t.c)}function Q(t,e){this.b=t||this,this.d=e||this,this.a=null,this.c=!1}function J(){this.h=this,this.i=this.d=this.a=this.e=this.c=this.b=null,this.f=0}function $(t){return t.b.e}function tt(){this.c=new et,this.a=new Q,this.b=new J,this.d=new J,this.b.b=this.d,this.d.b=this.b}function et(t,e){this.e=t||this,this.f=e||this,this.d=this.c=null,this.g=[0,0,0],this.h=this.a=this.b=0}function it(){this.c=[],this.d=null,this.a=0,this.e=!1,this.b=new st}function rt(t,e){if(t.e){var i,r=t.b,n=++r.a;return 2*n>r.f&&(r.f*=2,r.c=at(r.c,r.f+1)),0===r.b?i=n:(i=r.b,r.b=r.c[r.b]),r.e[i]=e,r.c[i]=n,r.d[n]=i,r.h&&ct(r,n),i}return r=t.a++,t.c[r]=e,-(r+1)}function nt(t){if(0===t.a)return ut(t.b);var e=t.c[t.d[t.a-1]];if(0!==t.b.a&&r(ot(t.b),e))return ut(t.b);do{--t.a}while(0<t.a&&null===t.c[t.d[t.a-1]]);return e}function st(){this.d=at([0],33),this.e=[null,null],this.c=[0,0],this.a=0,this.f=32,this.b=0,this.h=!1,this.d[1]=1}function at(t,e){for(var i=Array(e),r=0;r<t.length;r++)i[r]=t[r];for(;r<e;r++)i[r]=0;return i}function ot(t){return t.e[t.d[1]]}function ut(t){var e=t.d,i=t.e,r=t.c,n=e[1],s=i[n];return 0<t.a&&(e[1]=e[t.a],r[e[1]]=1,i[n]=null,r[n]=t.b,t.b=n,0<--t.a&&ht(t,1)),s}function ht(t,e){for(var i=t.d,n=t.e,s=t.c,a=e,o=i[a];;){var u=a<<1;u<t.a&&r(n[i[u+1]],n[i[u]])&&(u+=1);var h=i[u];if(u>t.a||r(n[o],n[h])){i[a]=o,s[o]=a;break}i[a]=h,s[h]=a,a=u}}function ct(t,e){for(var i=t.d,n=t.e,s=t.c,a=e,o=i[a];;){var u=a>>1,h=i[u];if(0===u||r(n[h],n[o])){i[a]=o,s[o]=a;break}i[a]=h,s[h]=a,a=u}}function lt(){this.e=this.a=null,this.f=0,this.c=this.b=this.h=this.d=!1}function ft(t){return t.e.c.b}function dt(t){return t.e.a.b}(e=W.prototype).x=function(){q(this,Z)},e.B=function(t,e){switch(t){case 100142:return;case 100140:switch(e){case 100130:case 100131:case 100132:case 100133:case 100134:return void(this.s=e)}break;case 100141:return void(this.m=!!e);default:return void K(this,100900)}K(this,100901)},e.y=function(t){switch(t){case 100142:return 0;case 100140:return this.s;case 100141:return this.m;default:K(this,100900)}return!1},e.A=function(t,e,i){this.j[0]=t,this.j[1]=e,this.j[2]=i},e.z=function(t,e){var i=e||null;switch(t){case 100100:case 100106:this.h=i;break;case 100104:case 100110:this.l=i;break;case 100101:case 100107:this.k=i;break;case 100102:case 100108:this.i=i;break;case 100103:case 100109:this.p=i;break;case 100105:case 100111:this.o=i;break;case 100112:this.r=i;break;default:K(this,100900)}},e.C=function(t,e){var i=!1,r=[0,0,0];q(this,2);for(var n=0;3>n;++n){var s=t[n];-1e150>s&&(s=-1e150,i=!0),1e150<s&&(s=1e150,i=!0),r[n]=s}i&&K(this,100155),null===(i=this.q)?d(i=f(this.b),i.b):(m(i),i=i.e),i.a.d=e,i.a.g[0]=r[0],i.a.g[1]=r[1],i.a.g[2]=r[2],i.f=1,i.b.f=-1,this.q=i},e.u=function(t){q(this,Z),this.d=1,this.b=new tt,this.c=t},e.t=function(){q(this,1),this.d=2,this.q=null},e.v=function(){q(this,2),this.d=1},e.w=function(){q(this,1),this.d=Z;var t=!1,e=[l=this.j[0],n=this.j[1],o=this.j[2]];if(0===l&&0===n&&0===o){for(var n=[-2e150,-2e150,-2e150],a=[2e150,2e150,2e150],o=[],u=[],l=(t=this.b.c).e;l!==t;l=l.e)for(var f=0;3>f;++f){var d=l.g[f];d<a[f]&&(a[f]=d,u[f]=l),d>n[f]&&(n[f]=d,o[f]=l)}if(l=0,n[1]-a[1]>n[0]-a[0]&&(l=1),n[2]-a[2]>n[l]-a[l]&&(l=2),a[l]>=n[l])e[0]=0,e[1]=0,e[2]=1;else{for(n=0,a=u[l],o=o[l],u=[0,0,0],a=[a.g[0]-o.g[0],a.g[1]-o.g[1],a.g[2]-o.g[2]],f=[0,0,0],l=t.e;l!==t;l=l.e)f[0]=l.g[0]-o.g[0],f[1]=l.g[1]-o.g[1],f[2]=l.g[2]-o.g[2],u[0]=a[1]*f[2]-a[2]*f[1],u[1]=a[2]*f[0]-a[0]*f[2],u[2]=a[0]*f[1]-a[1]*f[0],(d=u[0]*u[0]+u[1]*u[1]+u[2]*u[2])>n&&(n=d,e[0]=u[0],e[1]=u[1],e[2]=u[2]);0>=n&&(e[0]=e[1]=e[2]=0,e[w(a)]=1)}t=!0}for(u=w(e),l=this.b.c,n=(u+1)%3,o=(u+2)%3,u=0<e[u]?1:-1,e=l.e;e!==l;e=e.e)e.b=e.g[n],e.a=u*e.g[o];if(t){for(e=0,l=(t=this.b.a).b;l!==t;l=l.b)if(!(0>=(n=l.a).f))do{e+=(n.a.b-n.b.a.b)*(n.a.a+n.b.a.a),n=n.e}while(n!==l.a);if(0>e)for(t=(e=this.b.c).e;t!==e;t=t.e)t.a=-t.a}for(this.n=!1,l=(e=this.b.b).h;l!==e;l=t)t=l.h,n=l.e,i(l.a,l.b.a)&&l.e.e!==l&&(D(this,n,l),p(l),n=(l=n).e),n.e===l&&(n!==l&&(n!==t&&n!==t.b||(t=t.h),p(n)),l!==t&&l!==t.b||(t=t.h),p(l));for(this.e=e=new it,l=(t=this.b.c).e;l!==t;l=l.e)l.h=rt(e,l);for(function(t){t.d=[];for(var e=0;e<t.a;e++)t.d[e]=e;t.d.sort(function(t){return function(e,i){return r(t[e],t[i])?1:-1}}(t.c)),t.e=!0,function(t){for(var e=t.a;1<=e;--e)ht(t,e);t.h=!0}(t.b)}(e),this.f=new X(this),j(this,-A),j(this,A);null!==(e=nt(this.e));){for(;;){t:if(l=this.e,0===l.a)t=ot(l.b);else if(t=l.c[l.d[l.a-1]],0!==l.b.a&&(l=ot(l.b),r(l,t))){t=l;break t}if(null===t||!i(t,e))break;t=nt(this.e),D(this,e.c,t.c)}G(this,e)}for(this.a=this.f.a.a.b.a.a,e=0;null!==(t=this.f.a.a.b);)t.h||++e,O(t);for(this.f=null,(e=this.e).b=null,e.d=null,this.e=e.c=null,l=(e=this.b).a.b;l!==e.a;l=t)t=l.b,(l=l.a).e.e===l&&(C(l.c,l),p(l));if(!this.n){if(e=this.b,this.m)for(l=e.b.h;l!==e.b;l=t)t=l.h,l.b.d.c!==l.d.c?l.f=l.d.c?1:-1:p(l);else for(l=e.a.b;l!==e.a;l=t)if(t=l.b,l.c){for(l=l.a;r(l.b.a,l.a);l=l.c.b);for(;r(l.a,l.b.a);l=l.e);for(n=l.c.b,o=void 0;l.e!==n;)if(r(l.b.a,n.a)){for(;n.e!==l&&(h(n.e)||0>=s(n.a,n.b.a,n.e.b.a));)n=(o=v(n.e,n)).b;n=n.c.b}else{for(;n.e!==l&&(c(l.c.b)||0<=s(l.b.a,l.a,l.c.b.a));)l=(o=v(l,l.c.b)).b;l=l.e}for(;n.e.e!==l;)n=(o=v(n.e,n)).b}if(this.h||this.i||this.k||this.l)if(this.m){for(t=(e=this.b).a.b;t!==e.a;t=t.b)if(t.c){this.h&&this.h(2,this.c),l=t.a;do{this.k&&this.k(l.a.d,this.c),l=l.e}while(l!==t.a);this.i&&this.i(this.c)}}else{for(e=this.b,t=!!this.l,l=!1,n=-1,o=e.a.d;o!==e.a;o=o.d)if(o.c){l||(this.h&&this.h(4,this.c),l=!0),u=o.a;do{t&&(n!==(a=u.b.d.c?0:1)&&(n=a,this.l&&this.l(!!n,this.c))),this.k&&this.k(u.a.d,this.c),u=u.e}while(u!==o.a)}l&&this.i&&this.i(this.c)}if(this.r){for(l=(e=this.b).a.b;l!==e.a;l=t)if(t=l.b,!l.c){o=(n=l.a).e,u=void 0;do{o=(u=o).e,u.d=null,null===u.b.d&&(u.c===u?E(u.a,null):(u.a.c=u.c,g(u,$(u))),(a=u.b).c===a?E(a.a,null):(a.a.c=a.c,g(a,$(a))),T(u))}while(u!==n);n=l.d,(l=l.b).d=n,n.b=l}return this.r(this.b),void(this.c=this.b=null)}}this.b=this.c=null},_h.libtess={GluTesselator:W,windingRule:{GLU_TESS_WINDING_ODD:100130,GLU_TESS_WINDING_NONZERO:100131,GLU_TESS_WINDING_POSITIVE:100132,GLU_TESS_WINDING_NEGATIVE:100133,GLU_TESS_WINDING_ABS_GEQ_TWO:100134},primitiveType:{GL_LINE_LOOP:2,GL_TRIANGLES:4,GL_TRIANGLE_STRIP:5,GL_TRIANGLE_FAN:6},errorType:{GLU_TESS_MISSING_BEGIN_POLYGON:100151,GLU_TESS_MISSING_END_POLYGON:100153,GLU_TESS_MISSING_BEGIN_CONTOUR:100152,GLU_TESS_MISSING_END_CONTOUR:100154,GLU_TESS_COORD_TOO_LARGE:100155,GLU_TESS_NEED_COMBINE_CALLBACK:100156},gluEnum:{GLU_TESS_MESH:100112,GLU_TESS_TOLERANCE:100142,GLU_TESS_WINDING_RULE:100140,GLU_TESS_BOUNDARY_ONLY:100141,GLU_INVALID_ENUM:100900,GLU_INVALID_VALUE:100901,GLU_TESS_BEGIN:100100,GLU_TESS_VERTEX:100101,GLU_TESS_END:100102,GLU_TESS_ERROR:100103,GLU_TESS_EDGE_FLAG:100104,GLU_TESS_COMBINE:100105,GLU_TESS_BEGIN_DATA:100106,GLU_TESS_VERTEX_DATA:100107,GLU_TESS_END_DATA:100108,GLU_TESS_ERROR_DATA:100109,GLU_TESS_EDGE_FLAG_DATA:100110,GLU_TESS_COMBINE_DATA:100111}},W.prototype.gluDeleteTess=W.prototype.x,W.prototype.gluTessProperty=W.prototype.B,W.prototype.gluGetTessProperty=W.prototype.y,W.prototype.gluTessNormal=W.prototype.A,W.prototype.gluTessCallback=W.prototype.z,W.prototype.gluTessVertex=W.prototype.C,W.prototype.gluTessBeginPolygon=W.prototype.u,W.prototype.gluTessBeginContour=W.prototype.t,W.prototype.gluTessEndContour=W.prototype.v,W.prototype.gluTessEndPolygon=W.prototype.w,t.exports=_h.libtess}(wh);var Ah=function(){var t=new wh.exports.GluTesselator;return t.gluTessCallback(wh.exports.gluEnum.GLU_TESS_VERTEX_DATA,(function(t,e){e[e.length]=t[0],e[e.length]=t[1]})),t.gluTessCallback(wh.exports.gluEnum.GLU_TESS_BEGIN,(function(t){t!==wh.exports.primitiveType.GL_TRIANGLES&&console.info("expected TRIANGLES but got type: "+t)})),t.gluTessCallback(wh.exports.gluEnum.GLU_TESS_ERROR,(function(t){console.error("error callback, error number: "+t)})),t.gluTessCallback(wh.exports.gluEnum.GLU_TESS_COMBINE,(function(t,e,i){return[t[0],t[1],t[2]]})),t.gluTessCallback(wh.exports.gluEnum.GLU_TESS_EDGE_FLAG,(function(t){})),t}();function Ch(t){Ah.gluTessNormal(0,0,1);var e=[];Ah.gluTessBeginPolygon(e);for(var i=0;i<t.length;i++){Ah.gluTessBeginContour();for(var r=t[i],n=0;n<r.length;n+=2){var s=[r[n],r[n+1],0];Ah.gluTessVertex(s,s)}Ah.gluTessEndContour()}return Ah.gluTessEndPolygon(),e}var Sh=function(t){function e(){for(var e=arguments.length,i=new Array(e),r=0;r<e;r++)i[r]=arguments[r];var n;(n=t.call(this)||this).points=[],n.closePath=!1;var s=Array.isArray(i[0])?i[0]:i;if("number"!=typeof s[0]){for(var a=[],o=0,u=s.length;o<u;o++)a.push(s[o].x,s[o].y);s=a}return n.points=s,n.closePath=!0,n}Qt(e,t);var i=e.prototype;return i.clone=function(){var t=new e(this.points.slice());return t.closePath=this.closePath,t},i.contains=function(t,e){for(var i=!1,r=this.points.length/2,n=0,s=r-1;n<r;s=n++){var a=this.points[2*n],o=this.points[2*n+1],u=this.points[2*s],h=this.points[2*s+1];o>e!=h>e&&t<(e-o)/(h-o)*(u-a)+a&&(i=!i)}return i},i.copyFrom=function(t){return this.points=t.points.slice(),this.closePath=t.closePath,this},i.copyTo=function(t){return t.copyFrom(this),t},i.getX=function(){return this.points[this.points.length-2]},i.getY=function(){return this.points[this.points.length-1]},i.build=function(t){for(var e=0;e<this.points.length;e++)t[e]=this.points[e]},i.triangulate=function(t,e,i,r,n){var s=Ch([t]),a=e.length/2;0===s.length&&this.getLineEndPointsTriangle(t,s);for(var o=0;o<s.length;o++)e[2*i+o]=s[o];for(var u=s.length/2,h=0;h<u;h++)r[n+h]=a+h},i.getLineEndPointsTriangle=function(t,e){if(!t||t.length<2||t.length%2!=0)throw new Error("Invalid points array");if(2!==t.length){var i=t[2]-t[0],r=t[3]-t[1],n=t[0],s=t[1],a=t[0],o=t[1];if(Math.abs(i)>=Math.abs(r))for(var u=0;u<t.length;u+=2){var h=t[u],c=t[u+1];h<n&&(n=h,s=c),h>a&&(a=h,o=c)}else for(var l=0;l<t.length;l+=2){var f=t[l],d=t[l+1];d<s&&(n=f,s=d),d>o&&(a=f,o=d)}e.push(n,s,a,o,a,o)}else e.push(t[0],t[1],t[0],t[1],t[0],t[1])},Pe(e,[{key:"lastX",get:function(){return this.points[this.points.length-2]}},{key:"lastY",get:function(){return this.points[this.points.length-1]}}]),e}(Eh),Oh=8,Rh=1.1920929e-7;function Mh(t,e,i,r,n,s,a,o,u,h){var c=(1-Math.min(.99,Math.max(0,null!=h?h:.5)))/5;return function(t,e,i,r,n,s,a,o,u,h){Ih(t,e,i,r,n,s,a,o,u,h,0),u.push(a,o)}(e,i,r,n,s,a,o,u,t,c*=c),t}function Ih(t,e,i,r,n,s,a,o,u,h,c){if(!(c>Oh)){var l=(t+i)/2,f=(e+r)/2,d=(i+n)/2,p=(r+s)/2,m=(n+a)/2,v=(s+o)/2,y=(l+d)/2,g=(f+p)/2,x=(d+m)/2,b=(p+v)/2,T=(y+x)/2,E=(g+b)/2;if(c>0){var _=a-t,w=o-e,A=Math.abs((i-a)*w-(r-o)*_),C=Math.abs((n-a)*w-(s-o)*_);if(A>Rh&&C>Rh){if((A+C)*(A+C)<=h*(_*_+w*w))return void u.push(T,E)}else if(A>Rh){if(A*A<=h*(_*_+w*w))return void u.push(T,E)}else if(C>Rh){if(C*C<=h*(_*_+w*w))return void u.push(T,E)}else if((_=T-(t+a)/2)*_+(w=E-(e+o)/2)*w<=h)return void u.push(T,E)}Ih(t,e,l,f,y,g,T,E,u,h,c+1),Ih(T,E,x,b,m,v,a,o,u,h,c+1)}}var Ph,Lh=function(t){function e(e,i,r,n){var s;return void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=0),(s=t.call(this)||this).type="ellipse",s.x=e,s.y=i,s.halfWidth=r,s.halfHeight=n,s}Qt(e,t);var i=e.prototype;return i.clone=function(){return new e(this.x,this.y,this.halfWidth,this.halfHeight)},i.contains=function(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;var i=(t-this.x)/this.halfWidth,r=(e-this.y)/this.halfHeight;return(i*=i)+(r*=r)<=1},i.strokeContains=function(t,e,i){var r=this.halfWidth,n=this.halfHeight;if(r<=0||n<=0)return!1;var s=i/2,a=r-s,o=n-s,u=r+s,h=n+s,c=t-this.x,l=e-this.y;return c*c/(a*a)+l*l/(o*o)>1&&c*c/(u*u)+l*l/(h*h)<=1},i.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.halfWidth=t.halfWidth,this.halfHeight=t.halfHeight,this},i.copyTo=function(t){return t.copyFrom(this),t},i.getX=function(){return this.x},i.getY=function(){return this.y},i.build=function(t){var e=this.x,i=this.y,r=this.halfWidth,n=this.halfHeight;if(!(r>=0&&n>=0))return t;var s=Math.ceil(5*Math.sqrt(r+n)),a=8*s+0+0;if(0===a)return t;if(0===s)return t[0]=t[6]=e+0,t[1]=t[3]=i+0,t[2]=t[4]=e-0,t[5]=t[7]=i-0,t;var o=0,u=4*s+0+2,h=u,c=a,l=0+r,f=0,d=e+l,p=e-l,m=i+f;t[o++]=d,t[o++]=m,t[--u]=m,t[--u]=p;for(var v=1;v<s;v++){var y=Math.PI/2*(v/s),g=0+Math.cos(y)*r,x=0+Math.sin(y)*n,b=e+g,T=e-g,E=i+x,_=i-x;t[o++]=b,t[o++]=E,t[--u]=E,t[--u]=T,t[h++]=T,t[h++]=_,t[--c]=_,t[--c]=b}d=e+(l=0),p=e-l,m=i+(f=0+n);var w=i-f;return t[o++]=d,t[o++]=m,t[--c]=w,t[--c]=d,t},i.triangulate=function(t,e,i,r,n){if(0!==t.length){for(var s=0,a=0,o=0;o<t.length;o+=2)s+=t[o],a+=t[o+1];s/=t.length/2,a/=t.length/2;var u=i;e[2*u]=s,e[2*u+1]=a;for(var h=u++,c=0;c<t.length;c+=2)e[2*u]=t[c],e[2*u+1]=t[c+1],c>0&&(r[n++]=u,r[n++]=h,r[n++]=u-1),u++;r[n++]=h+1,r[n++]=h,r[n++]=u-1}},e}(Eh);!function(t){t[t.Star=0]="Star",t[t.Polygon=1]="Polygon"}(Ph||(Ph={}));var Fh=function(t){function e(e,i,r,n,s,a){var o;return void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=0),void 0===s&&(s=0),void 0===a&&(a=0),(o=t.call(this)||this).pointCount=e,o.outerRadius=i,o.innerRadius=r,o.outerRoundness=n,o.innerRoundness=s,o.starType=a,o.v=[],o.in=[],o.out=[],o}Qt(e,t);var i=e.prototype;return i.clone=function(){return new e(this.pointCount,this.outerRadius,this.innerRadius,this.outerRoundness,this.innerRoundness,this.starType)},i.copyFrom=function(t){this.pointCount=t.pointCount,this.outerRadius=t.outerRadius,this.innerRadius=t.innerRadius,this.outerRoundness=t.outerRoundness,this.innerRoundness=t.innerRoundness,this.starType=t.starType},i.copyTo=function(t){t.copyFrom(this)},i.build=function(t){switch(this.starType){case 0:this.buildStarPath();break;case 1:this.buildPolygonPath()}for(var e=0;e<this.v.length-2;e+=2)Mh(t,this.v[e],this.v[e+1],this.out[e],this.out[e+1],this.in[e+2],this.in[e+3],this.v[e+2],this.v[e+3],1);var i=this.v.length-1;Mh(t,this.v[i-1],this.v[i],this.out[i-1],this.out[i],this.in[0],this.in[1],this.v[0],this.v[1],1)},i.triangulate=function(t,e,i,r,n){for(var s=Ch([t]),a=e.length/2,o=0;o<s.length;o++)e[2*i+o]=s[o];for(var u=s.length/2,h=0;h<u;h++)r[n+h]=a+h},i.buildStarPath=function(){this.v=[],this.in=[],this.out=[];var t,e,i,r,n=2*Math.floor(this.pointCount),s=2*Math.PI/n,a=!0,o=this.outerRadius,u=this.innerRadius,h=this.outerRoundness/100,c=this.innerRoundness/100,l=2*Math.PI*o/(2*n),f=2*Math.PI*u/(2*n),d=-Math.PI/2;for(t=0;t<n;t++){i=a?h:c,r=a?l:f;var p=(e=a?o:u)*Math.cos(d),m=e*Math.sin(d),v=0===p&&0===m?0:m/Math.sqrt(p*p+m*m),y=0===p&&0===m?0:-p/Math.sqrt(p*p+m*m),g=2*t;this.v[g]=p,this.v[g+1]=m,this.in[g]=p+v*r*i*1,this.in[g+1]=m+y*r*i*1,this.out[g]=p-v*r*i*1,this.out[g+1]=m-y*r*i*1,a=!a,d+=1*s}},i.buildPolygonPath=function(){this.v=[],this.in=[],this.out=[];var t,e=Math.floor(this.pointCount),i=2*Math.PI/e,r=this.outerRadius,n=this.outerRoundness/100,s=2*Math.PI*r/(4*e),a=.5*-Math.PI;for(t=0;t<e;t++){var o=r*Math.cos(a),u=r*Math.sin(a),h=0===o&&0===u?0:u/Math.sqrt(o*o+u*u),c=0===o&&0===u?0:-o/Math.sqrt(o*o+u*u),l=2*t;this.v[l]=o,this.v[l+1]=u,this.in[l]=o+h*s*n*1,this.in[l+1]=u+c*s*n*1,this.out[l]=o-h*s*n*1,this.out[l+1]=u-c*s*n*1,a+=1*i}},e}(Eh),Vh=function(t){function e(e,i,r,n,s){var a;return void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=0),void 0===s&&(s=20),(a=t.call(this)||this).x=e,a.y=i,a.width=r,a.height=n,a.roundness=s,a}Qt(e,t);var i=e.prototype;return i.getBounds=function(t){return(t=t||new e).x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t},i.clone=function(){return new e(this.x,this.y,this.width,this.height,this.roundness)},i.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this.roundness=t.roundness,this},i.copyTo=function(t){return t.copyFrom(this),t},i.build=function(t){var e,i=this.width/2,r=this.height/2,n=this.x+i,s=this.y+r,a=e=Math.max(0,Math.min(this.roundness/100,1)*Math.min(i,r)),o=i-a,u=r-e;if(a>=0&&e>=0&&o>=0&&u>=0){var h=5*Math.ceil(2.3*Math.sqrt(a+e)),c=8*h+(o?4:0)+(u?4:0);if(0!==c){if(0===h)return t[0]=t[6]=n+o,t[1]=t[3]=s+u,t[2]=t[4]=n-o,void(t[5]=t[7]=s-u);var l=0,f=4*h+(o?2:0)+2,d=f,p=c,m=o+a,v=u,y=n+m,g=n-m,x=s+v;if(t[l++]=y,t[l++]=x,t[--f]=x,t[--f]=g,u){var b=s-v;t[d++]=g,t[d++]=b,t[--p]=b,t[--p]=y}for(var T=1;T<h;T++){var E=Math.PI/2*(T/h),_=o+Math.cos(E)*a,w=u+Math.sin(E)*e,A=n+_,C=n-_,S=s+w,O=s-w;t[l++]=A,t[l++]=S,t[--f]=S,t[--f]=C,t[d++]=C,t[d++]=O,t[--p]=O,t[--p]=A}y=n+(m=o),g=n-m,x=s+(v=u+e);var R=s-v;t[l++]=y,t[l++]=x,t[--p]=R,t[--p]=y,o&&(t[l++]=g,t[l++]=x,t[--p]=R,t[--p]=g)}}},i.triangulate=function(t,e,i,r,n){if(0!==t.length){for(var s=0,a=0,o=0;o<t.length;o+=2)s+=t[o],a+=t[o+1];s/=t.length/2,a/=t.length/2;var u=i;e[2*u]=s,e[2*u+1]=a;for(var h=u++,c=0;c<t.length;c+=2)e[2*u]=t[c],e[2*u+1]=t[c+1],c>0&&(r[n++]=u,r[n++]=h,r[n++]=u-1),u++;r[n++]=h+1,r[n++]=h,r[n++]=u-1}},e}(Eh),Nh=function(){function t(t){this.graphicsPath=t,this.currentPoly=null,this.shapePrimitives=[]}var e=t.prototype;return e.buildPath=function(){this.currentPoly=null,this.shapePrimitives.length=0;for(var t,e=w(this.graphicsPath.instructions);!(t=e()).done;){var i=t.value,r=i.action,n=i.data;switch(r){case"bezierCurveTo":this.bezierCurveTo(n[0],n[1],n[2],n[3],n[4],n[5],n[6]);break;case"moveTo":this.moveTo(n[0],n[1]);break;case"ellipse":this.ellipse(n[0],n[1],n[2],n[3],n[4]);break;case"polyStar":this.polyStar(n[0],n[1],n[2],n[3],n[4],n[5],n[6]);break;case"rect":this.rect(n[0],n[1],n[2],n[3],n[4]);break;case"closePath":this.closePath()}}this.endPoly()},e.bezierCurveTo=function(t,e,i,r,n,s,a){this.ensurePoly();var o=this.currentPoly;return Mh(o.points,o.lastX,o.lastY,t,e,i,r,n,s,a),this},e.moveTo=function(t,e){return this.startPoly(t,e),this},e.closePath=function(){return this.endPoly(!0),this},e.ellipse=function(t,e,i,r,n){return this.drawShape(new Lh(t,e,i,r),n),this},e.polyStar=function(t,e,i,r,n,s,a){return this.drawShape(new Fh(t,e,i,r,n,s),a),this},e.rect=function(t,e,i,r,n,s){return this.drawShape(new Vh(t,e,i,r,n),s),this},e.drawShape=function(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this},e.startPoly=function(t,e){var i=this.currentPoly;return i&&this.endPoly(),(i=new Sh).points.push(t,e),this.currentPoly=i,this},e.endPoly=function(t){void 0===t&&(t=!1);var e=this.currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this.currentPoly=null,this},e.ensurePoly=function(t){this.currentPoly||(this.currentPoly=new Sh,this.currentPoly.points.push(0,0))},t}(),Dh=function(){function t(){this.instructions=[],this.dirty=!1}var e=t.prototype;return e.bezierCurveTo=function(t,e,i,r,n,s,a){return this.instructions.push({action:"bezierCurveTo",data:[t,e,i,r,n,s,a]}),this.dirty=!0,this},e.moveTo=function(t,e){return this.instructions.push({action:"moveTo",data:[t,e]}),this.dirty=!0,this},e.closePath=function(){return this.instructions.push({action:"closePath",data:[]}),this.dirty=!0,this},e.ellipse=function(t,e,i,r,n){return this.instructions.push({action:"ellipse",data:[t,e,i,r,n]}),this.dirty=!0,this},e.rect=function(t,e,i,r,n,s){return this.instructions.push({action:"rect",data:[t,e,i,r,n,s]}),this.dirty=!0,this},e.polyStar=function(t,e,i,r,n,s,a){return this.instructions.push({action:"polyStar",data:[t,e,i,r,n,s,a]}),this.dirty=!0,this},e.clear=function(){return this.instructions.length=0,this.dirty=!0,this},Pe(t,[{key:"shapePath",get:function(){return this._shapePath||(this._shapePath=new Nh(this)),this.dirty&&(this.dirty=!1,this._shapePath.buildPath()),this._shapePath}}]),t}();function kh(t,e){return!e||"object"!==C(e)&&"function"!=typeof e?ho(t):e}var zh=new(function(){function t(){this.elements=[]}var e=t.prototype;return e.dispose=function(){this.elements.forEach((function(t){return t.remove()})),this.elements.length=0},e.getCanvas=function(){if(0!==this.elements.length){var t=this.elements.shift();return ot(t),t}if(wo(To))return r._createOffscreenCanvas(10,10);var e=i.createElement("canvas");return e.getContext("2d",{willReadFrequently:!0}),e},e.saveCanvas=function(t){t.width=1,t.height=1,this.elements.length<3?D(this.elements,t):t.remove()},t}()),Uh=function(){function t(t){this.width=0,this.height=0;var e=t.textHeight,i=void 0===e?100:e,r=t.textWidth,n=void 0===r?100:r,s=t.textOverflow,a=void 0===s?ce.clip:s,o=t.textBaseline,u=void 0===o?le.top:o,h=t.textAlign,c=void 0===h?fe.left:h,l=t.text,f=void 0===l?" ":l,d=t.letterSpace,p=void 0===d?0:d,m=t.autoWidth,v=void 0!==m&&m,y=t.fontSize,g=t.lineHeight,x=void 0===g?y:g,b=y+p;this.autoWidth=v,this.maxTextWidth=f.length*b,this.width=n,this.height=i,this.letterSpace=p,this.overflow=a,this.textBaseline=u,this.textAlign=c,this.lineHeight=x}var e=t.prototype;return e.getOffsetY=function(t,e,i,r){var n=t.outlineWidth,s=t.fontScale,a=(i-r)/3,o=r+n*s,u=i*(e-1),h=0;switch(this.textBaseline){case le.top:h=o+a;break;case le.middle:h=(this.height*s-u+o)/2;break;case le.bottom:h=this.height*s-u-a}return h},e.getOffsetX=function(t,e){var i=0;switch(this.textAlign){case fe.left:i=t.outlineWidth*t.fontScale;break;case fe.middle:i=(this.width*t.fontScale-e)/2;break;case fe.right:i=this.width*t.fontScale-e}return i},e.setSize=function(t,e){this.width=t,this.height=e},t}(),Bh=function(t){this.isUnderline=!1,this.underlineHeight=1,this.isOutlined=!1,this.outlineWidth=0,this.hasShadow=!1,this.fontDesc="",this.fontScale=2,this.fontOffset=0;var e,i,r,n,s,a,o=t.textColor,u=void 0===o?[1,1,1,1]:o,h=t.fontSize,c=void 0===h?40:h,l=t.outline,f=t.shadow,d=t.fontWeight,p=void 0===d?"normal":d,m=t.fontStyle,v=void 0===m?"normal":m,y=t.fontFamily,g=void 0===y?"sans-serif":y;(this.textColor=u,this.textWeight=p,this.fontStyle=v,this.fontFamily=g,this.fontSize=c,l)&&(this.isOutlined=!0,this.outlineColor=null!=(e=l.outlineColor)?e:[1,1,1,1],this.outlineWidth=null!=(i=l.outlineWidth)?i:1,this.fontOffset+=this.outlineWidth);f&&(this.hasShadow=!0,this.shadowBlur=null!=(r=f.shadowBlur)?r:2,this.shadowColor=null!=(n=f.shadowColor)?n:[0,0,0,1],this.shadowOffsetX=null!=(s=f.shadowOffsetX)?s:0,this.shadowOffsetY=null!=(a=f.shadowOffsetY)?a:0);this.fontStyle!==pe.normal&&(this.fontOffset+=this.fontSize*Math.tan(.20943951))},Gh=["serif","sans-serif","monospace","courier"],jh=0,Xh=function(t){function e(e,i){var r;if((r=t.call(this,e)||this).isDirty=!0,r.lineCount=0,r.maxLineWidth=0,r.SCALE_FACTOR=.1,r.ALPHA_FIX_VALUE=1/255,r.name="MText"+jh++,i&&r.fromData(i),r.canvas=zh.getCanvas(),zh.saveCanvas(r.canvas),r.context=r.canvas.getContext("2d",{willReadFrequently:!0}),!i)return kh(r);var n=i.options;return r.updateWithOptions(n),r.updateTexture(),r}Qt(e,t);var i=e.prototype;return i.onUpdate=function(e){t.prototype.onUpdate.call(this,e),this.updateTexture()},i.fromData=function(e){t.prototype.fromData.call(this,e);var i=e.interaction,r=e.options;this.interaction=i,this.updateWithOptions(r),this.renderText(r),this.material.setColor("_Color",new ii(1,1,1,1))},i.updateWithOptions=function(t){},i.updateTexture=function(t){},e}(Ls);Xh=S([Ne(_e.TextComponent)],Xh);var Hh=function(){function t(){}var e=t.prototype;return e.renderText=function(t){this.updateTexture()},e.updateWithOptions=function(t){this.textStyle=new Bh(t),this.textLayout=new Uh(t),this.text=t.text.toString(),this.lineCount=this.getLineCount(t.text,!0)},e.getLineCount=function(t,e){for(var i=this.context,r=this.textLayout,n=r.letterSpace,s=r.overflow,a=e?this.textStyle.fontSize/10:1/this.textStyle.fontScale,o=this.textLayout.width+this.textStyle.fontOffset,u=1,h=0,c=0;c<t.length;c++){var l,f,d=t[c],p=(null!=(f=null==i||null==(l=i.measureText(d))?void 0:l.width)?f:0)*a;h+=n,s===ce.display?"\n"===d?(u++,h=0):(h+=p,this.maxLineWidth=Math.max(this.maxLineWidth,h)):((h+p>o&&c>0||"\n"===d)&&(u++,this.maxLineWidth=Math.max(this.maxLineWidth,h),h=0),"\n"!==d&&(h+=p))}return u},e.setFontSize=function(t){if(this.textStyle.fontSize!==t){var e=this.textStyle.fontSize-t;this.textLayout.lineHeight+=e,this.textStyle.fontSize=t,this.isDirty=!0}},e.setFontWeight=function(t){this.textStyle.textWeight!==t&&(this.textStyle.textWeight=t,this.isDirty=!0)},e.setFontStyle=function(t){this.textStyle.fontStyle!==t&&(this.textStyle.fontStyle=t,this.isDirty=!0)},e.setText=function(t){this.text!==t&&(this.text=t.toString(),this.lineCount=this.getLineCount(t,!1),this.isDirty=!0)},e.setTextAlign=function(t){this.textLayout.textAlign!==t&&(this.textLayout.textAlign=t,this.isDirty=!0)},e.setTextBaseline=function(t){this.textLayout.textBaseline!==t&&(this.textLayout.textBaseline=t,this.isDirty=!0)},e.setTextColor=function(t){this.textStyle.textColor!==t&&(this.textStyle.textColor=t,this.isDirty=!0)},e.setFontFamily=function(t){this.textStyle.fontFamily!==t||ht(t)?(this.textStyle.fontFamily=t,this.isDirty=!0):console.warn("The font is either the current font or an risky font family.")},e.setOutlineColor=function(t){this.textStyle.outlineColor!==t&&(this.textStyle.outlineColor=t,this.isDirty=!0)},e.setOutlineWidth=function(t){this.textStyle.outlineWidth!==t&&(this.textStyle.outlineWidth=t,this.isDirty=!0)},e.setShadowBlur=function(t){this.textStyle.shadowBlur!==t&&(this.textStyle.shadowBlur=t,this.isDirty=!0)},e.setOverflow=function(t){this.textLayout.overflow=t,this.isDirty=!0},e.setShadowColor=function(t){this.textStyle.shadowColor!==t&&(this.textStyle.shadowColor=t,this.isDirty=!0)},e.setShadowOffsetX=function(t){this.textStyle.shadowOffsetX!==t&&(this.textStyle.shadowOffsetX=t,this.isDirty=!0)},e.setShadowOffsetY=function(t){this.textStyle.shadowOffsetY!==t&&(this.textStyle.shadowOffsetY=t,this.isDirty=!0)},e.setFontScale=function(t){this.textStyle.fontScale!==t&&(this.textStyle.fontScale=t,this.isDirty=!0)},e.setAutoWidth=function(t){this.textLayout.autoWidth!==t&&(this.textLayout.autoWidth=t,this.isDirty=!0)},e.updateTexture=function(t){if(void 0===t&&(t=!0),this.isDirty&&this.context&&this.canvas){var e=this.context,i=this.textStyle,r=this.textLayout,n=i.fontScale,s=(r.width+i.fontOffset)*n,a=r.lineHeight*this.lineCount,o=i.fontSize*n,u=r.lineHeight*n;i.fontDesc=this.getFontDesc(o),this.char=(this.text||"").split(""),this.canvas.width=s,r.autoWidth?(this.canvas.height=a*n,this.item.transform.size.set(1,a/r.height)):this.canvas.height=r.height*n;var h=this.canvas.height;e.fillStyle="rgba(255, 255, 255, 0.0039)",t||(e.translate(0,h),e.scale(1,-1)),this.maxLineWidth>s&&r.overflow===ce.display?e.font=this.getFontDesc(o*s/this.maxLineWidth):e.font=i.fontDesc,e.clearRect(0,0,s,h),i.hasShadow&&this.setupShadow(),i.isOutlined&&this.setupOutline(),e.fillStyle="rgba("+i.textColor[0]+", "+i.textColor[1]+", "+i.textColor[2]+", "+i.textColor[3]+")";for(var c=[],l=0,f=r.getOffsetY(i,this.lineCount,u,o),d=[],p=[],m=0;m<this.char.length;m++){var v=this.char[m],y=e.measureText(v);((l+=r.letterSpace*n)+y.width>s&&m>0||"\n"===v)&&(c.push({y:f,width:l,chars:d,charOffsetX:p}),l=0,f+=u,d=[],p=[]),"\n"!==v&&(d.push(v),p.push(l),l+=y.width)}c.push({y:f,width:l,chars:d,charOffsetX:p}),c.forEach((function(t){var n=r.getOffsetX(i,t.width);t.chars.forEach((function(r,s){i.isOutlined&&e.strokeText(r,n+t.charOffsetX[s],t.y),e.fillText(r,n+t.charOffsetX[s],t.y)}))})),i.hasShadow&&(e.shadowColor="transparent");var g=e.getImageData(0,0,this.canvas.width,this.canvas.height),x=Yi.createWithData(this.engine,{data:new Uint8Array(g.data),width:g.width,height:g.height},{flipY:t,magFilter:fi.LINEAR,minFilter:fi.LINEAR,wrapS:fi.CLAMP_TO_EDGE,wrapT:fi.CLAMP_TO_EDGE});this.renderer.texture=x,this.material.setTexture("_MainTex",x),this.isDirty=!1}},e.getFontDesc=function(t){var e=this.textStyle,i=e.fontSize,r=e.fontScale,n=e.fontFamily,s=e.textWeight,a=e.fontStyle,o=(t||i*r).toString()+"px ";return Gh.includes(n)?o+=n:o+='"'+n+'"',s!==de.normal&&(o=s+" "+o),a!==pe.normal&&(o=a+" "+o),o},e.setupOutline=function(){var t=this.context,e=this.textStyle,i=e.outlineColor,r=e.outlineWidth,n=i[0],s=i[1],a=i[2],o=i[3];t&&(t.strokeStyle="rgba("+255*n+", "+255*s+", "+255*a+", "+o+")",t.lineWidth=2*r)},e.setupShadow=function(){var t=this.context,e=this.textStyle,i=e.outlineColor,r=e.shadowBlur,n=e.shadowOffsetX,s=e.shadowOffsetY,a=i[0],o=i[1],u=i[2],h=i[3];t&&(t.shadowColor="rgba("+255*a+", "+255*o+", "+255*u+", "+h+")",t.shadowBlur=r,t.shadowOffsetX=n,t.shadowOffsetY=-s)},t}();Ct(Xh,[Hh]);var Yh=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e}(qt),Wh=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e}(ze),Zh=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e}(ze);S([De()],Zh.prototype,"buffer",void 0),Zh=S([Ne(_e.BinaryAsset)],Zh);var qh=function(){function t(){}return t.serialize=function(e,i){e.toData(),i||(i={});var r=ke(e);if(r)for(var n,s=w(Object.keys(r));!(n=s()).done;){var a=n.value,o=e[a];"number"==typeof o||"string"==typeof o||"boolean"==typeof o||t.checkTypedArray(o)?i[a]=o:gt(o)?(i[a]||(i[a]=[]),t.serializeArrayProperty(o,i[a],0)):ze.is(o)?i[a]={id:o.getInstanceId()}:bt(o)&&(i[a]||(i[a]={}),t.serializeObjectProperty(o,i[a],0))}for(var u,h=w(Object.keys(e.defination));!(u=h()).done;){var c=u.value,l=e.defination[c];"number"==typeof l||"string"==typeof l||"boolean"==typeof l||t.checkTypedArray(l)?i[c]=l:gt(l)?(i[c]||(i[c]=[]),t.serializeArrayProperty(l,i[c],0)):ze.is(l)?i[c]={id:l.getInstanceId()}:bt(l)&&(i[c]||(i[c]={}),t.serializeObjectProperty(l,i[c],0))}return i},t.deserialize=function(e,i){i.defination=e;var r=ke(i),n=i.engine;if(r)for(var s,a=w(Object.keys(r));!(s=a()).done;){var o=s.value,u=e[o];if(void 0!==u){var h=r[o].type;i[o]=t.deserializeProperty(u,n,0,h)}}i.fromData(i.defination)},t.checkTypedArray=function(t){return A(t,Int8Array)||A(t,Uint8Array)||A(t,Uint8ClampedArray)||A(t,Int16Array)||A(t,Uint16Array)||A(t,Int32Array)||A(t,Uint32Array)||A(t,Float32Array)||A(t,Float64Array)||A(t,ArrayBuffer)},t.checkDataPath=function(t){return!!(bt(t)&&1===Object.keys(t).length&&"id"in t&&yt(t.id)&&32===t.id.length)},t.checkGLTFNode=function(t){return bt(t)&&void 0!==t.nodeIndex&&void 0!==t.isJoint},t.checkImageSource=function(t){return Tt(t)||A(t,c)},t.deserializeProperty=function(e,i,r,n,s){if(void 0===s&&(s=!0),!(r>14)){if(gt(e)){for(var a,o=[],u=w(e);!(a=u()).done;){var h=a.value;o.push(t.deserializeProperty(h,i,r+1,n,s))}return o}if(t.checkDataPath(e)){var c=i.findObject(e);return s?c:e}if(bt(e)&&e.constructor===Object){var l;l=n?new n:{};for(var f,d=w(Object.keys(e));!(f=d()).done;){var p=f.value;l[p]=t.deserializeProperty(e[p],i,r+1,void 0,s)}return l}return e}console.error("The nested object layers of the serialized data exceed the maximum limit.")},t.serializeObjectProperty=function(e,i,r){if(r>14)console.error("The nested object layers of the serialized data exceed the maximum limit.");else{i||(i={});for(var n,s=w(Object.keys(e));!(n=s()).done;){var a=n.value,o=e[a];"number"==typeof o||"string"==typeof o||"boolean"==typeof o||t.checkTypedArray(e)?i[a]=o:gt(o)?(i[a]||(i[a]=[]),t.serializeArrayProperty(o,i[a],r+1)):ze.is(o)?i[a]={id:o.getInstanceId()}:bt(o)&&(i[a]||(i[a]={}),t.serializeObjectProperty(o,i[a],r+1))}}},t.serializeArrayProperty=function(e,i,r){if(r>14)console.error("The nested object layers of the serialized data exceed the maximum limit.");else{i||(i=[]);for(var n=0;n<e.length;n++){var s=e[n];"number"==typeof s||"string"==typeof s||"boolean"==typeof s||t.checkTypedArray(e)?i[n]=s:gt(s)?(i[n]||(i[n]=[]),t.serializeArrayProperty(s,i[n],r+1)):ze.is(s)?i[n]={id:s.getInstanceId()}:bt(s)&&(i[n]||(i[n]={}),t.serializeObjectProperty(s,i[n],r+1))}}},t}(),Kh=function(){function t(t){this.engine=t}var e=t.prototype;return e.loadGUID=function(e){if(!e)return null;var i,r=e.id,n=this.findData(r);if(n){switch(n.dataType){case _e.Material:i=cr.create(this.engine);break;case _e.Geometry:i=Cr.create(this.engine);break;case _e.Texture:i=Yi.create(this.engine);break;default:var s=t.getClass(n.dataType);s&&(i=new s(this.engine))}if(i)return i.setInstanceId(n.id),this.engine.addInstance(i),qh.deserialize(n,i),i;console.error("Constructor for DataType: "+n.dataType+" not found.")}else console.error("Object data with uuid: "+r+" not found.")},e.findData=function(t){return this.engine.jsonSceneData[t]},t.getClass=function(t){return Ve[t]},t}(),Qh=function(){function t(){}return t.prototype.loadGUID=function(t){return E((function(){return O(this,(function(t){return[2,void 0]}))}))()},t}();function Jh(t,e){if(!t.includes(e))return t.push(e),!0}function $h(t){if(Number.isFinite(t))return[$t.CONSTANT,t];if(t){var e=t[0],i=t[1];if(Array.isArray(e))return;if("static"===e||e===$t.CONSTANT)return[$t.CONSTANT,t[1]];if("lines"===e)return[$t.LINE,t[1]];if(e===$t.LINE){var r=i.map((function(t){return[te.LINE,t]}));return[$t.BEZIER_CURVE,r]}return"curve"===e||e===$t.CURVE?[$t.BEZIER_CURVE,bc(i)]:t}}function tc(t,e){return Array.isArray(t)&&"random"===t[0]?[$t.CONSTANT,t[1][e]]:$h(t)}function ec(t){return t&&"color"===t[0]?sc(t[1],!0):[1,1,1,1]}function ic(t,e){if(t)return"colors"===t[0]?[$t.COLORS,t[1].map((function(t){return sc(t,e)}))]:"gradient"===t[0]?nc(t[1],e):"color"===t[0]?[$t.RGBA_COLOR,sc(t[1],e)]:t}function rc(t){return t&&"random"===t[0]?[$t.RANDOM,t[1]]:$h(t)}function nc(t,e){if(t){var i=[];return Object.getOwnPropertyNames(t).forEach((function(r){var n=function(t){var e=/^(-)?([\d+.]+)%$/.exec(t);if(e)return+e[2]/100*(e[1]?-1:1);return+t}(r),s=sc(t[r],e);i.push([n,s[0],s[1],s[2],s[3]])})),i=i.sort((function(t,e){return t[0]-e[0]})),[$t.GRADIENT_COLOR,i]}}function sc(t,e){var i;if("string"==typeof t){t=t.replace(/[\s\t\r\n]/g,"");var r=/rgba?\(([.\d]+),([.\d]+),([.\d]+),?([.\d]+)?\)/.exec(t);if(r){var n=+r[4];i=[+r[1],+r[2],+r[3],isNaN(n)?255:Math.round(255*n)]}else/^#[a-f\d]{3}$/i.test(t)?i=[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16),255]:(r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t))&&(i=[parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16),255])}else A(t,Array)&&(i=[t[0],t[1],t[2],isNaN(t[3])?255:Math.round(255*t[3])]);return e&&(i=ac(i)),i}function ac(t){if(Array.isArray(t))return t.map((function(t){return Number.isFinite(t/255)?Number((t/255).toFixed(6)):0}))}function oc(t,e){return Array.isArray(t)?t[0]===$t.GRADIENT_COLOR?t:("gradient"===t[0]||"color"===t[0])&&nc(t[1],e):nc(t,e)}function uc(t){if(t){if(3===t.length)return[$t.CONSTANT_VEC3,t];var e=t[0];if("path"===e||"bezier"===e||e===$t.BEZIER_PATH||e===$t.LINEAR_PATH){var i=t[1],r=i[0],n=i[1],s=i[2],a=bc(r);if(!s){s=[];for(var o=0;o<n.length;o++){var u=n[o].slice();0===o?s.push(u):o<n.length-1?(s.push(u),s.push(u)):s.push(u)}}return[$t.BEZIER_CURVE_PATH,[a,n,s]]}return t}}function hc(t){for(var e,i=w(Object.keys(t));!(e=i()).done;){var r=e.value;t[r]=Number(t[r])}return t}function cc(t){for(var e,i=w(Object.keys(t));!(e=i()).done;){var r=e.value;void 0===t[r]&&delete t[r]}return t}var lc,fc=Math.cos,dc=Math.sin,pc=Math.PI/180,mc=180/Math.PI;function vc(t,e){return t?[t[0]-.5,.5-t[1]]:e?gc[e]:[0,0]}var yc,gc=((lc={})[Yt.PARTICLE_ORIGIN_CENTER]=[0,0],lc[Yt.PARTICLE_ORIGIN_CENTER_BOTTOM]=[0,-.5],lc[Yt.PARTICLE_ORIGIN_CENTER_TOP]=[0,.5],lc[Yt.PARTICLE_ORIGIN_LEFT_TOP]=[-.5,.5],lc[Yt.PARTICLE_ORIGIN_LEFT_CENTER]=[-.5,0],lc[Yt.PARTICLE_ORIGIN_LEFT_BOTTOM]=[-.5,-.5],lc[Yt.PARTICLE_ORIGIN_RIGHT_CENTER]=[.5,0],lc[Yt.PARTICLE_ORIGIN_RIGHT_BOTTOM]=[.5,-.5],lc[Yt.PARTICLE_ORIGIN_RIGHT_TOP]=[.5,.5],lc);function xc(t,e,i,r){var n=i[0],s=i[1],a=r[0],o=a-n;return[[n+(a-n)/3,s+(t*=o)/3],[a-(a-n)/3,r[1]-(e*=o)/3]]}function bc(t){for(var e=-1e6,i=1e6,r=0;r<t.length;r++)e=Math.max(e,t[r][1]),i=Math.min(i,t[r][1]);for(var n=[[t[0][0],t[0][1]]],s=0;s<t.length-1;s++){var a=t[s][3]*(e-i),o=t[s+1][2]*(e-i),u=[t[s][0],t[s][1]],h=[t[s+1][0],t[s+1][1]];if(u[0]!=h[0]){var c=xc(a,o,u,h),l=c[0],f=c[1];n[n.length-1].push(l[0]),n[n.length-1].push(l[1]),n.push([f[0],f[1],h[0],h[1]])}else n[n.length-1].push(h[0]),n[n.length-1].push(h[1])}return n.map((function(t,e){return 0===e?[te.EASE_OUT,t]:e===n.length-1?[te.EASE_IN,t]:[te.EASE,t]}))}function Tc(t){return t.compositions.forEach((function(t){t.items.forEach((function(t){t.type===Xt.null&&t.endBehavior===ee.destroy&&(t.endBehavior=ee.freeze)}))})),t.version=Vt["2_1"],t}var Ec=new Map,_c=new Map;function wc(t){for(var e,i=w(t.components);!(e=i()).done;){var r=e.value;if(r.dataType===_e.ShapeComponent){var n=r;if(n.type===ge.Custom){var s,a=n;(null==(s=a.shapes)?void 0:s.length)>0&&a.shapes[0].fill&&(a.fill=a.shapes[0].fill);for(var o,u=new Array(a.easingIns.length),h=new Array(a.easingOuts.length).fill(!1),c=w(a.shapes);!(o=c()).done;)for(var l,f=w(o.value.indexes);!(l=f()).done;){var d=l.value,p=a.points[d.point],m=a.easingIns[d.easingIn],v=a.easingOuts[d.easingOut];u[d.easingIn]||(m.x-=p.x,m.y-=p.y,u[d.easingIn]=!0),h[d.easingOut]||(v.x-=p.x,v.y-=p.y,h[d.easingOut]=!0)}}}}return t}function Ac(t){Ec.clear(),_c.clear();for(var e,i=t.compositions,r=t.items,n=w(t.components);!(e=n()).done;){var s=e.value;Ec.set(s.id,s)}for(var a,o=w(r);!(a=o()).done;){var u=a.value;_c.set(u.id,u)}for(var h,c=w(i);!(h=c()).done;){Sc(h.value)}return t}function Cc(t){var e;null==(e=t.plugins)||e.forEach((function(e,i){"richtext"===e&&(t.plugins[i]="rich-text")}));for(var i,r=w(t.items);!(i=r()).done;){var n=i.value;if(n.type===Xt.sprite){var s=Ec.get(n.components[0].id);if(s){var a=s.renderer.shape,o=void 0;o=Number.isInteger(a)?t.shapes[a]:a,s.renderer.shape=o}}}for(var u,h=t.compositionId,c={},l=w(t.compositions);!(u=l()).done;){var f=u.value,d=wt();c[f.id]=d,f.id===h&&(t.compositionId=d),f.id=d;var p={id:wt(),dataType:"CompositionComponent",items:f.items,timelineAsset:f.timelineAsset,sceneBindings:f.sceneBindings,startTime:f.startTime};f.timelineAsset=void 0,f.sceneBindings=void 0,f.startTime=void 0,f.components=[{id:p.id}],t.components.push(p)}for(var m,v=w(t.items);!(m=v()).done;){var y=m.value;if(y.content){var g=y.content.options;g&&void 0!==g.refId&&(g.refId=c[g.refId])}}return t}function Sc(t){for(var e,i=w(t.items);!(e=i()).done;){var r=e.value,n=_c.get(r.id);if(!n)return;if(n.type===Xt.sprite||n.type===Xt.particle||n.type===Xt.spine||n.type===Xt.text||n.type===Xt.richtext||n.type===Xt.video||n.type===Xt.shape){var s=Ec.get(n.components[0].id);s&&Oc(s)}}}function Oc(t){var e=t.renderer,i=null==e?void 0:e.maskMode;i&&i!==ui.NONE&&(i===ui.MASK?(t.mask={isMask:!0},yc=t.id):i!==zt.OBSCURED&&i!==zt.REVERSE_OBSCURED||(t.mask={inverted:i===zt.REVERSE_OBSCURED,reference:{id:yc}}))}function Rc(t){for(var e,i,r,n=function(){var t=u.value;t.endBehavior!==ve&&t.endBehavior!==me||(t.endBehavior=ee.freeze),t.items=t.items.filter((function(t){return"8"!==t.type})),t.items.forEach((function(t){t.type===Xt.particle&&(t.content.filter&&delete t.content.filter)}));for(var e,i=w(t.items);!(e=i()).done;){var r=e.value;h[r.id]=wt(),r.oldId=r.id,r.id=h[r.id],c[r.id]=r}t.items.forEach((function(e,i){if(e.parentId)if(e.parentId.includes("^")){var r=e.parentId.split("^")[0],n=e.parentId.split("^")[1];e.parentId=h[r]+"^"+n}else e.parentId=h[e.parentId];s.items.push(e),t.items[i]={id:e.id}}));var n=_i({},t,{timelineAsset:{id:""},sceneBindings:[]});s.compositions.push(n),function(t,e,i){for(var r,n=[],s=[],a=[],o={tracks:[],id:wt(),dataType:"TimelineAsset"},u=w(t.items);!(r=u()).done;){var h=e[r.value.id],c=[],l={id:wt(),dataType:"ActivationPlayableAsset"};a.push(l);var f={id:wt(),dataType:"ActivationTrack",children:[],clips:[{start:h.delay,duration:h.duration,endBehavior:h.endBehavior,asset:{id:l.id}}]};if(c.push({id:f.id}),s.push(f),h.type!==Xt.particle){var d={id:wt(),dataType:"TransformPlayableAsset",sizeOverLifetime:h.content.sizeOverLifetime,rotationOverLifetime:h.content.rotationOverLifetime,positionOverLifetime:h.content.positionOverLifetime};a.push(d);var p={id:wt(),dataType:"TransformTrack",children:[],clips:[{start:h.delay,duration:h.duration,endBehavior:h.endBehavior,asset:{id:d.id}}]};c.push({id:p.id}),s.push(p)}if(h.type===Xt.sprite||h.type===Xt.text){var m={id:wt(),dataType:"SpriteColorPlayableAsset",colorOverLifetime:h.content.colorOverLifetime};a.push(m);var v={id:wt(),dataType:"SpriteColorTrack",children:[],clips:[{start:h.delay,duration:h.duration,endBehavior:h.endBehavior,asset:{id:m.id}}]};c.push({id:v.id}),s.push(v)}if(h.type===Xt.composition){var y={id:wt(),dataType:"SubCompositionPlayableAsset"};a.push(y);var g={id:wt(),dataType:"SubCompositionTrack",children:[],clips:[{start:h.delay,duration:h.duration,endBehavior:h.endBehavior,asset:{id:y.id}}]};c.push({id:g.id}),s.push(g)}var x={id:wt(),dataType:"ObjectBindingTrack",children:c,clips:[]};s.push(x),o.tracks.push({id:x.id}),n.push({key:{id:x.id},value:{id:h.id}})}for(var b,T=[],E=w(s);!(b=E()).done;){var _=b.value;T.push({id:_.id})}t.timelineAsset={id:o.id},t.sceneBindings=n,i.miscs.push(o);for(var A,C=w(s);!(A=C()).done;){var S=A.value;i.miscs.push(S)}for(var O,R=w(a);!(O=R()).done;){var M=O.value;i.miscs.push(M)}}(n,c,s)},s=_i({},t,{items:[],compositions:[],components:[],materials:[],shaders:[],geometries:[],animations:[],miscs:[]}),a=w(s.images);!(i=a()).done;){i.value.id=wt()}if(null!=(e=s).textures||(e.textures=[]),s.textures.forEach((function(t){var e;t.id=wt(),t.dataType=_e.Texture,t.source={id:null==(e=s.images[t.source])?void 0:e.id}})),s.textures.length<s.images.length)for(var o=s.textures.length;o<s.images.length;o++)s.textures.push({id:wt(),dataType:_e.Texture,source:{id:s.images[o].id},flipY:!0});t.bins&&(r=t.bins,s.bins=r.map((function(t){return{url:t.url,dataType:"BinaryAsset",id:wt()}})));for(var u,h={},c={},l=w(t.compositions);!(u=l()).done;)n();for(var f,d=w(s.items);!(f=d()).done;){var p=f.value;if(p.content){if(p.content.renderer&&void 0!==p.content.renderer.texture){var m=p.content.renderer.texture;p.content.renderer.texture={id:s.textures[m].id}}if(p.content.trails&&void 0!==p.content.trails.texture){var v=p.content.trails.texture;p.content.trails.texture={id:s.textures[v].id}}}if(p.transform){var y,g,x,b=[].concat(null!=(y=p.transform.position)?y:[0,0,0]),T=[].concat(null!=(g=p.transform.rotation)?g:[0,0,0]),E=[].concat(null!=(x=p.transform.scale)?x:[1,1,1]);if(Object.assign(p,{transform:{position:{x:b[0],y:b[1],z:b[2]},eulerHint:{x:T[0],y:T[1],z:T[2]},scale:{x:E[0],y:E[1],z:E[0]}}}),p.type===Xt.sprite&&(p.transform.size={x:E[0],y:E[1]},p.transform.scale={x:1,y:1,z:1}),p.type===Xt.sprite){var _=p.content;_.renderer||(_.renderer={});var A,C,S,O,R=_.renderer,M=vc(R.anchor,R.particleOrigin),I=p.transform.size;if(!R.anchor&&void 0!==R.particleOrigin)p.transform.position.x+=-M[0]*(null!=(A=null==I?void 0:I.x)?A:1),p.transform.position.y+=-M[1]*(null!=(C=null==I?void 0:I.y)?C:1);p.transform.anchor={x:M[0]*(null!=(S=null==I?void 0:I.x)?S:1),y:M[1]*(null!=(O=null==I?void 0:I.y)?O:1)}}}if(p.type===Xt.particle){var P=p.content;P.renderer||(P.renderer={});var L=P.renderer;P.renderer.anchor=vc(L.anchor,L.particleOrigin)}if(p.type===Xt.camera&&p.content.positionOverLifetime&&0!==Object.keys(p.content.positionOverLifetime).length&&(p.content.positionOverLifetime.asMovement=!0),void 0!==p.pn){var F=p.pn,V=t.plugins,N=void 0===V?[]:V;void 0!==F&&Number.isInteger(F)&&(p.pluginName=N[F])}switch("editor-gizmo"===p.pluginName&&(p.type="editor-gizmo"),"orientation-transformer"===p.pluginName&&(p.type="orientation-transformer"),p.content.options.target&&"editor-gizmo"===p.pluginName&&(p.content.options.target=h[p.content.options.target]),p.type===Xt.spine&&t.spines&&0!==t.spines.length&&Ic(t.spines[p.content.options.spine],p.content,s),p.type!==Xt.sprite&&p.type!==Xt.particle&&p.type!==Xt.mesh&&p.type!==Xt.skybox&&p.type!==Xt.light&&"camera"!==p.type&&p.type!==Xt.tree&&p.type!==Xt.interact&&p.type!==Xt.camera&&p.type!==Xt.text&&p.type!==Xt.spine&&"editor-gizmo"!==p.type&&"orientation-transformer"!==p.type||(p.components=[],s.components.push(p.content),p.content.id=wt(),p.content.item={id:p.id},p.dataType=_e.VFXItemData,p.components.push({id:p.content.id})),p.type!==Xt.null&&p.type!==Xt.composition||(p.components=[],p.dataType=_e.VFXItemData),p.type){case Xt.sprite:p.content.dataType=_e.SpriteComponent;break;case Xt.particle:p.content.dataType=_e.ParticleSystem;break;case Xt.mesh:p.content.dataType=_e.MeshComponent;break;case Xt.skybox:p.content.dataType=_e.SkyboxComponent;break;case Xt.light:p.content.dataType=_e.LightComponent;break;case"camera":p.content.dataType=_e.CameraComponent;break;case"editor-gizmo":p.content.dataType="GizmoComponent";break;case"orientation-transformer":p.content.dataType="OrientationComponent";break;case Xt.tree:p.content.dataType=_e.TreeComponent;break;case Xt.interact:p.content.dataType=_e.InteractComponent;break;case Xt.camera:p.content.dataType=_e.CameraController;break;case Xt.text:p.content.dataType=_e.TextComponent;break;case Xt.spine:p.content.dataType=_e.SpineComponent}}return s.version=Vt["3_0"],s}function Mc(t){if(t)for(var e,i=w(Object.keys(t));!(e=i()).done;){var r=e.value,n=t[r],s=Array.isArray(n);s&&2===n.length&&Array.isArray(n[1])?t[r]="path"===r?uc(n):$h(n):s||"object"!=typeof n||Mc(n)}}function Ic(t,e,i){e.resource={atlas:{bins:{id:i.bins[t.atlas[1][0]].id},source:t.atlas[1].slice(1)},skeleton:{bins:{id:i.bins[t.skeleton[1][0]].id},source:t.skeleton[1].slice(1)},skeletonType:t.skeletonType,images:t.images.map((function(t){return{id:i.textures[t].id}}))}}function Pc(t,e){var i,r=t.options,n=t.velocityOverLifetime||{},s={path:uc(null==(i=t.transform)?void 0:i.path),gravity:r.gravity,gravityOverLifetime:$h(r.gravityModifier),direction:r.direction,startSpeed:r.startSpeed,asMovement:n.asMovement,linearX:$h(n.linearX),linearY:$h(n.linearY),linearZ:$h(n.linearZ),asRotation:n.asRotation,orbCenter:n.orbCenter,orbitalX:$h(n.orbitalX),orbitalY:$h(n.orbitalY),orbitalZ:$h(n.orbitalZ),speedOverLifetime:$h(n.speedOverLifetime)};cc(s);var a={options:{startColor:ec(r.startColor)},positionOverLifetime:s};r.startSize&&(e.scale=[r.startSize,r.startSize/(r.sizeAspect||1),1]),r.startRotation&&(e.rotation?e.rotation[2]+=r.startRotation:e.rotation=[0,0,r.startRotation]);var o=t.rotationOverLifetime;if(o){var u=a.rotationOverLifetime={separateAxes:o.separateAxes,asRotation:o.asRotation};u.separateAxes?(u.x=$h(o.x),u.y=$h(o.y),u.z=$h(o.z)):u.z=$h(o.angularVelocity)}var h=t.colorOverLifetime;if(h){var c=a.colorOverLifetime={opacity:$h(h.opacity)};h.color&&(c.color=oc(h.color))}var l=t.sizeOverLifetime;return l&&(a.sizeOverLifetime={separateAxes:l.separateAxes,size:$h(l.size),x:$h(l.x),y:$h(l.y),z:$h(l.z)}),a}var Lc="2.5.0-alpha.5",Fc=/^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/,Vc=/^(\d+)\.(\d+)$/,Nc=!1;function Dc(t){if(!t||"object"!=typeof t)throw new Error("Invalid input: Expected a JSON object.");var e,i;(function(t){var e=t.playerVersion||{},i=e.web,r=void 0===i?"":i;if(r){var n,s,a=null!=(n=Fc.exec(r))?n:[],o=null!=(s=Fc.exec(Lc))?s:[],u=a[1],h=a[2],c=o[1],l=o[2];return Number(c)<Number(u)||Number(c)===Number(u)&&Number(l)<Number(h)}return!1})(t)&&console.warn("The JSON need higher than "+(null==(e=t.playerVersion)?void 0:e.web)+" runtime version(current: "+Lc+"). Some features may not work as expected.");if(function(t){var e,i=null==(e=t.version)?void 0:e.split(".");!i||Number(i[0])>2||2===Number(i[0])&&Number(i[1])>=2||t.compositions.forEach((function(t){t.items.forEach((function(t){t.type!==Xt.mesh&&t.type!==Xt.light||(t.endBehavior=1===t.endBehavior?ee.destroy:t.endBehavior)}))}))}(t),Fc.test(t.version))return Nc="0"===(null==(i=/^(\d+)/.exec(t.version))?void 0:i[0]),Cc(Ac(wc(Rc(Tc(function(t){var e;kc=Vt["1_0"];var i=t.plugins||[];(null==(e=t.bins)?void 0:e.length)&&(kc=Vt["1_3"]);var r,n=(t.requires||[]).slice(),s=t.images.map((function(e,i){return zc(e,i,t.imageTags||[])})),a=t.textures||s.map((function(t,e){return{source:e,flipY:!0}})),o={plugins:i,shapes:t.shapes||[],type:"ge",version:kc,playerVersion:null!=(r=t.playerVersion)?r:{web:"",native:""},compositionId:t.compositionId+"",compositions:t.compositions.map((function(t){return Uc(t,{plugins:i,requires:n})})),images:s,imgUsage:t._imgs,binUsage:t.binUsage,spines:t.spines,requires:t.requires,textures:a,bins:(t.bins||[]).slice()};t._textures&&(o._textures=t._textures);return o}(t))))));Nc=!1;var r=Vc.exec(t.version)||[],n=Number(r[1]),s=Number(r[2]);if(n)return(n<2||2===n&&s<4)&&(t=function(t){return t.compositions.map((function(t){for(var e,i=w(t.items);!(e=i()).done;)Mc(e.value.content)})),t}(t)),n<3&&(t=Rc(Tc(t))),r=Vc.exec(t.version)||[],n=Number(r[1]),s=Number(r[2]),n<4&&(s<2&&(t=wc(t)),s<3&&(t=Ac(t)),s<4&&(t=Cc(t))),t;throw new Error("Invalid JSON version: "+t.version+".")}var kc=Vt["1_0"];function zc(t,e,i){var r=i[e];if("string"==typeof t)return{id:wt(),renderLevel:r,url:t};if(t.template)return{id:wt(),url:t.url,template:t.template,webp:t.webp,renderLevel:r};if(t.compressed)return{id:wt(),url:t.url,compressed:{astc:t.compressed.android,pvrtc:t.compressed.iOS},webp:t.webp,renderLevel:r};if(t.url)return{id:wt(),url:t.url,webp:t.webp,renderLevel:r};if(t&&t.sourceType)return t;throw new Error("Invalid image type.")}function Uc(t,e){var i;void 0===e&&(e={});var r={id:t.id+"",camera:_i({clipMode:ye},t.camera),duration:t.duration,endBehavior:t.endBehavior,items:t.items.map((function(t){return Xc(t,e)})),name:t.name},n=t.startTime||t.st;n&&(r.startTime=n);var s=null==(i=t.meta)?void 0:i.previewSize;return s&&s[0]===s[1]&&0===s[0]&&(s=void 0),s&&(r.previewSize=s),r}var Bc,Gc=[0,0,0,1],jc=.5;function Xc(t,e){var i;void 0===e&&(e={});var r,n,s,a,o,u,h=Xt.base,c=t.endBehavior,l=NaN;if(t.content?(h=t.type||Xt.plugin,u=t.pn,o=t.pluginName,s=t.content,n=t.content,isNaN(u)&&!o&&(o=s.options.type),t.duration&&(l=t.duration),r=t.transform||y(n.transform)):t.particle?(h=Xt.particle,r=y((n=t.particle).transform,Nc,!0),s=function(t){var e=t.options,i=t.transform,r={type:Ut.NONE};if(t.shape){var n,s=null==(n=t.shape.shape)?void 0:n.replace(/([A-Z])/g,"_$1").toUpperCase().replace(/^_/,"");if(r=_i({},t.shape,{type:Ut[s]}),t.shape.upDirection){var a=t.shape.upDirection,o=a[0],u=a[1],h=a[2];0===o&&0===u&&0===h&&delete r.upDirection}}e.startTurbulence&&(r.turbulenceX=rc(e.turbulenceX),r.turbulenceY=rc(e.turbulenceY),r.turbulenceZ=rc(e.turbulenceZ));var c=t.emission;c.bursts&&c.bursts.length>0&&(c.bursts=c.bursts.map((function(t){return hc(t)}))),c.burstOffsets&&c.burstOffsets.length>0&&(c.burstOffsets=c.burstOffsets.map((function(t){return hc(t)}))),c.rateOverTime&&(c.rateOverTime=rc(c.rateOverTime));var l={renderer:t.renderer,shape:r,splits:t.splits,emission:c,options:{startLifetime:rc(e.startLifetime),start3DSize:!!e.start3DSize,startSize:rc(e.startSize),startSizeX:rc(e.startSizeX),startSizeY:rc(e.startSizeY),sizeAspect:rc(e.sizeAspect),maxCount:e.maxCount,startDelay:rc(e.startDelay),startColor:ic(e.startColor,!0),startRotationZ:rc(e.startRotation||e.startRotationZ),particleFollowParent:e.particleFollowParent}};e.start3DRotation&&(l.options.startRotationX=rc(e.startRotationX),l.options.startRotationY=rc(e.startRotationY)),i&&i.path&&(l.emitterTransform={path:uc(i.path)});var f=t.sizeOverLifetime;f&&(f.separateAxes?l.sizeOverLifetime={separateAxes:!0,x:rc(f.x),y:rc(f.y)}:l.sizeOverLifetime={size:rc(f.size)});var d=t.velocityOverLifetime||{},p=d.speedOverLifetime;p=p?$h(p):void 0,l.positionOverLifetime={gravity:e.gravity,gravityOverLifetime:$h(e.gravityModifier),startSpeed:rc(e.startSpeed),speedOverLifetime:p,asMovement:d.asMovement,linearX:rc(d.linearX),linearY:rc(d.linearY),linearZ:rc(d.linearZ),asRotation:d.asRotation,orbCenter:d.orbCenter,orbitalX:rc(d.orbitalX),orbitalY:rc(d.orbitalY),orbitalZ:rc(d.orbitalZ),forceTarget:d.forceTarget,target:d.target,forceCurve:$h(d.forceCurve)},cc(l.positionOverLifetime);var m=t.rotationOverLifetime;m&&(l.rotationOverLifetime={separateAxes:m.separateAxes,asRotation:m.asRotation,z:rc(m.separateAxes?m.z:m.angularVelocity)},m.separateAxes&&(l.rotationOverLifetime.y=$h(m.y),l.rotationOverLifetime.x=$h(m.x)));var v=t.colorOverLifetime;if(v){var y=l.colorOverLifetime={opacity:$h(v.opacity)};v.color&&(y.color=oc(v.color))}var g=t.textureSheetAnimation;g&&(l.textureSheetAnimation={row:g.row,col:g.col,total:g.total,animate:g.animate,cycles:$h(g.cycles),animationDelay:tc(g.animationDelay,0),animationDuration:tc(g.animationDuration,0)});var x=t.trails;x&&(l.trails={lifetime:rc(x.lifetime),dieWithParticles:x.dieWithParticles,maxPointPerTrail:x.maxPointPerTrail,minimumVertexDistance:x.minimumVertexDistance,widthOverTrail:$h(x.widthOverTrail),colorOverTrail:x.colorOverTrail&&oc(x.colorOverTrail,!1),blending:x.blending,colorOverLifetime:x.colorOverLifetime&&oc(x.colorOverLifetime,!1),inheritParticleColor:x.inheritParticleColor,occlusion:x.occlusion,transparentOcclusion:x.transparentOcclusion,orderOffset:x.orderOffset,sizeAffectsLifetime:x.sizeAffectsLifetime,sizeAffectsWidth:x.sizeAffectsWidth,texture:x.texture,parentAffectsPosition:x.parentAffectsPosition,opacityOverLifetime:rc(x.opacityOverLifetime)}),l.trails&&cc(l.trails);var b=t.interaction;return b&&(l.interaction={behavior:b.behavior,radius:b.radius,multiple:b.multiple}),l}(n)):t.sprite?(h=Xt.sprite,s=function(t,e){var i=Pc(t,e),r=t.textureSheetAnimation;return r&&(i.textureSheetAnimation={row:r.row,col:r.col,total:r.total||void 0,animate:r.animate}),i.renderer=t.renderer,t.splits&&(i.splits=t.splits),t.interaction&&(i.interaction=t.interaction),i}(n=t.sprite,r=y(n.transform,!1,!0))):t.cal?(h=Xt.null,s=Pc(n=t.cal,r=y(n.transform,!1,!0))):t.ui?(h=Xt.interact,r=y((n=t.ui).transform),s=function(t){var e,i=t.options;switch(i.type){case"click":e={type:Gt.CLICK,showPreview:i.showPreview,previewColor:i.previewColor&&ec(i.previewColor),behavior:i.behavior||jt.NOTIFY};break;case"drag":e={type:Gt.DRAG,enableInEditor:!!i.enableInEditor,dxRange:i.dxRange,dyRange:i.dyRange,target:i.target};break;case"message":e={type:Gt.MESSAGE}}return{options:e}}(n),r.scale=[n.options.width||1,n.options.height||1,1]):t.model&&(n=t.model,1===t.model.options.type&&(h=Xt.camera,r=y(n.transform),s=function(t){var e,i=t.options,r={options:{fov:i.fov,far:i.far,near:i.near,clipMode:i.clipMode}},n=t.velocityOverLifetime;if(n||(null==(e=t.transform)?void 0:e.path)){var s,a={path:uc(null==(s=t.transform)?void 0:s.path),linearX:$h(null==n?void 0:n.translateX),linearY:$h(null==n?void 0:n.translateY),linearZ:$h(null==n?void 0:n.translateZ)};cc(a),r.positionOverLifetime=a}var o=t.rotationOverLifetime;if(o){var u={separateAxes:o.separateAxes,x:$h(null==o?void 0:o.rotateX),y:$h(null==o?void 0:o.rotateY),z:o.separateAxes?$h(null==o?void 0:o.rotateZ):$h(o.rotation)};cc(u),r.rotationOverLifetime=u}return r}(n))),null==(i=s.renderer)?void 0:i.anchor){var f=new Float32Array(s.renderer.anchor);f[0]==jc&&f[1]==jc?delete s.renderer.anchor:e.requires&&Jh(e.requires,"anchor")}if(n){var d,p,m=null==(d=n.options)?void 0:d.looping;if(m)c=Array.isArray(m)?m[1]?ee.restart:ee.destroy:ee.restart;else c=c||(null==n||null==(p=n.options)?void 0:p.endBehavior)||ee.destroy;n.options.renderLevel&&(a=n.options.renderLevel),isNaN(l)&&(l=n.options.duration)}var v={type:h,name:t.name,delay:t.delay,duration:l,id:t.id+"",transform:r,endBehavior:c,renderLevel:a,content:s};return o?e.plugins?(Jh(e.plugins,o),v.pn=e.plugins.indexOf(o)):v.pluginName=o:Number.isInteger(u)&&(v.pn=u),t.parentId&&(v.parentId=t.parentId+""),v;function y(t,e,i){if(t){var r={},n=t.rotation;if(n&&(r.rotation=e?[-n[0],-n[1],-n[2]]:[n[0],n[1],n[2]],i)){var s=(a=Gc,o=r.rotation[0],u=r.rotation[1],h=r.rotation[2],c=fc(o*pc/2),l=fc(u*pc/2),f=fc(h*pc/2),d=dc(o*pc/2),p=dc(u*pc/2),m=dc(h*pc/2),a[0]=d*l*f+c*p*m,a[1]=c*p*f-d*l*m,a[2]=c*l*m+d*p*f,a[3]=c*l*f-d*p*m,a);r.rotation=function(t,e){var i,r,n,s=e[0],a=e[1],o=e[2],u=e[3],h=s+s,c=a+a,l=o+o,f=s*h,d=a*h,p=a*c,m=o*l,v=u*l,y=1-p-m,g=d-v,x=d+v,b=1-f-m,T=o*h-u*c,E=o*c+u*h,_=1-f-p;return t[1]=Math.asin((r=-1,(i=-T)>(n=1)?n:i<r?r:i))*mc,Math.abs(T)<.9999999?(t[0]=Math.atan2(E,_)*mc,t[2]=Math.atan2(x,y)*mc):(t[0]=0,t[2]=Math.atan2(-g,b)*mc),t}([],s)}return t.position&&(r.position=t.position),Array.isArray(t.scale)&&(r.scale=[t.scale[0]||1,t.scale[1]||1,t.scale[2]||1]),r}var a,o,u,h,c,l,f,d,p,m;return{}}}var Hc,Yc=((Bc={})[Nt.S]=[Nt.S,Nt.BPlus,Nt.APlus],Bc[Nt.A]=[Nt.A,Nt.BPlus,Nt.APlus],Bc[Nt.B]=[Nt.B,Nt.BPlus],Bc);function Wc(t,e){if(!t||!e)return!0;var i=Yc[e];return!!i&&i.includes(t)}function Zc(t,e){var i,r,n=null!=(r=null==t?void 0:t.background)?r:{},s=n.name,a=n.url;return s&&(e&&e[s]?i=e[s]:a&&(i=a)),i}function qc(t,e,i){return Kc.apply(this,arguments)}function Kc(){return(Kc=E((function(t,e,i){var r,n;return O(this,(function(s){switch(s.label){case 0:return"string"!=typeof t?[3,2]:[4,Ii(t)];case 1:return r=s.sent(),[3,3];case 2:r=t,s.label=3;case 3:if(!r)throw new Error("Image not provided.");if(!e)return[2,r];if(n=Zc(e,i)){if(yt(n)&&n!==r.src)return[2,Ii(n)];if(A(n,c))return[2,n]}return[2,r]}}))}))).apply(this,arguments)}!function(t){t.isJSONObject=function(t){return bt(t)&&"jsonScene"in t},t.isURL=function(t){return bt(t)&&"url"in t},t.isWithOptions=function(t){return bt(t)&&"options"in t}}(Hc||(Hc={}));var Qc=1,Jc=function(){function t(t,e){void 0===t&&(t={}),void 0===e&&(e=new wi),this.options=t,this.downloader=e,this.assets={},this.sourceFrom={},this.id=Qc++,this.timers=[],this.updateOptions(t)}var e=t.prototype;return e.updateOptions=function(t){void 0===t&&(t={}),this.options=t,t.pluginData||(t.pluginData={});var e=t.timeout,i=void 0===e?10:e;this.timeout=i},e.loadScene=function(t,e,i){var n=this;return E((function(){var s,a,o,u,h,c,f,p,m,y,g,x,b;return O(this,(function(T){return a=yt(t)?t:n.id,o=d.now(),u=[],h=null==e?void 0:e.engine.gpuCapability,f=null!=(c=null==h?void 0:h.detail.compressedTexture)?c:bn.NONE,p={},y=!1,g=new Promise((function(t,e){m=r.setTimeout((function(){y=!0,n.removeTimer(m);var t=d.now()-o;e(new Error("Load time out: totalTime: "+t.toFixed(4)+"ms "+u.join(" ")+", url: "+a+"."))}),1e3*n.timeout),n.timers.push(m)})),x=E((function(t,e){var i,r,n,s;return O(this,(function(a){switch(a.label){case 0:if(y)return[3,4];i=d.now(),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,e()];case 2:return r=a.sent(),n=d.now()-i,u.push("["+t+": "+n.toFixed(2)+"]"),p[t]=n,[2,r];case 3:throw s=a.sent(),new Error("Load error in "+t+", "+s+".");case 4:throw new Error("Load canceled.")}}))})),b=E((function(){var e,h,c,y,g,b,T,E,_,w,A,C,S,R;return O(this,(function(O){switch(O.label){case 0:return yt(t)?(h=new l(t,v.href).href,n.baseUrl=h,[4,x("loadJSON",(function(){return n.loadJSON(h)}))]):[3,2];case 1:return s=O.sent(),[3,3];case 2:s=t,n.baseUrl=v.href,O.label=3;case 3:return Hc.isJSONObject(s)?(e=_i({},s),[3,9]):[3,4];case 4:return[4,x("processJSON",(function(){return n.processJSON(s)}))];case 5:return c=O.sent(),y=c.jsonScene,g=c.pluginSystem,b=y.bins,T=void 0===b?[]:b,E=y.images,_=y.fonts,[4,Promise.all([x("processBins",(function(){return n.processBins(T)})),x("processImages",(function(){return n.processImages(E,f)})),x("plugin:processAssets",(function(){return n.processPluginAssets(y,g,i)})),x("processFontURL",(function(){return n.processFontURL(_)}))])];case 6:return w=O.sent(),A=w[0],C=w[1],[4,x("processTextures",(function(){return n.processTextures(C,A,y)}))];case 7:return S=O.sent(),e={timeInfos:p,url:t,renderLevel:n.options.renderLevel,storage:{},pluginSystem:g,jsonScene:y,bins:A,textureOptions:S,textures:[],images:C,assets:n.assets},[4,x("plugin:prepareResource",(function(){return g.loadResources(e,n.options)}))];case 8:O.sent(),O.label=9;case 9:return R=d.now()-o,mt.info("Load asset: totalTime: "+R.toFixed(4)+"ms "+u.join(" ")+", url: "+a+"."),r.clearTimeout(m),n.removeTimer(m),e.totalTime=R,e.startTime=o,e.timeInfos=p,[2,e]}}))})),[2,Promise.race([g,b()])]}))}))()},e.getAssets=function(){return this.assets},e.processJSON=function(t){var e=this;return E((function(){var i,r,n;return O(this,(function(s){switch(s.label){case 0:return i=Dc(t),r=i.plugins,[4,(n=new Pt(void 0===r?[]:r)).processRawJSON(i,e.options)];case 1:return s.sent(),[2,{jsonScene:i,pluginSystem:n}]}}))}))()},e.processBins=function(t){var e=this;return E((function(){var i,r,n;return O(this,(function(s){return i=e.options.renderLevel,r=e.baseUrl,n=t.map((function(n){if(A(n,ArrayBuffer))return n;if(Wc(n.renderLevel,i))return e.loadBins(new l(n.url,r).href);throw new Error("Invalid bins source: "+JSON.stringify(t)+".")})),[2,Promise.all(n)]}))}))()},e.processFontURL=function(e){var r=this;return E((function(){var n;return O(this,(function(s){return e?(n=e.map(E((function(e){var n,s,a;return O(this,(function(o){switch(o.label){case 0:if(!e.fontURL||t.fontCache.has(e.fontFamily))return[3,4];ht(e.fontFamily)||console.warn("Risky font family: "+e.fontFamily+"."),o.label=1;case 1:return o.trys.push([1,3,,4]),n=new l(e.fontURL,r.baseUrl).href,[4,(a=new FontFace(null!=(s=e.fontFamily)?s:"","url("+n+")")).load()];case 2:return o.sent(),i.fonts.add(a),t.fontCache.add(e.fontFamily),[3,4];case 3:return o.sent(),mt.warn("Invalid font family or font source: "+JSON.stringify(e.fontURL)+"."),[3,4];case 4:return[2]}}))}))),[2,Promise.all(n)]):[2]}))}))()},e.processImages=function(t,e){void 0===e&&(e=0);var i=this;return E((function(){var r,n,s,a,o,u,h,f;return O(this,(function(d){switch(d.label){case 0:return r=i.options,n=r.useCompressedTexture,s=r.variables,a=r.disableWebP,o=r.disableAVIF,u=i.baseUrl,h=t.map(E((function(t,r){var h,f,d,v,y,g,x,b,T,E,_,w,C,S,R,M,I,P,L,F,V;return O(this,(function(r){switch(r.label){case 0:if(h=t.url,f=t.webp,d=t.avif,v=new l(h,u).href,y=!a&&f?new l(f,u).href:void 0,g=!o&&d?new l(d,u).href:void 0,x=t.id,!("template"in t))return[3,8];if(b=t.template,!(T=b.background))return[3,7];E=Zc(b,s),_=T.type===Te.video,w=T&&_?Di:Ii,r.label=1;case 1:return r.trys.push([1,6,,7]),[4,zi(E,w)];case 2:return A(C=r.sent(),m)?(i.sourceFrom[x]={url:C.src,type:ci.video},[2,C]):[3,3];case 3:return T&&Array.isArray(E)&&s&&(s[T.name]=C.src),i.sourceFrom[x]={url:C.src,type:ci.image},[4,qc(C,b,s)];case 4:return[2,r.sent()];case 5:return[3,7];case 6:throw S=r.sent(),new Error("Failed to load. Check the template or if the URL is "+(_?"video":"image")+" type, URL: "+E+", Error: "+(S.message||S)+".");case 7:return[3,9];case 8:if("compressed"in t&&n&&e){if(R=t.compressed,e===bn.ASTC?M=R.astc:e===bn.PVRTC&&(M=R.pvrtc),M)return I=new l(M,u).href,i.sourceFrom[x]={url:I,type:ci.compressed},[2,i.loadBins(I)]}else if(A(t,c)||A(t,p)||A(t,m)||A(t,Yi))return[2,t];r.label=9;case 9:return g?[4,Ri(v,g)]:[3,11];case 10:return V=r.sent(),[3,13];case 11:return[4,Si(v,y)];case 12:V=r.sent(),r.label=13;case 13:return L=(P=V).url,F=P.image,i.sourceFrom[x]={url:L,type:ci.image},[2,F]}}))}))),[4,Promise.all(h)];case 1:return f=d.sent(),i.assignImagesToAssets(t,f),[2,f]}}))}))()},e.processPluginAssets=function(t,e,i){var r=this;return E((function(){var n,s,a,o,u;return O(this,(function(h){switch(h.label){case 0:return[4,e.processAssets(t,i)];case 1:for(n=h.sent(),s=n.reduce((function(t,e){return t.assets=t.assets.concat(e.assets),t.loadedAssets=t.loadedAssets.concat(e.loadedAssets),t}),{assets:[],loadedAssets:[]}),a=s.assets,o=s.loadedAssets,u=0;u<a.length;u++)r.assets[a[u].id]=o[u];return[2]}}))}))()},e.processTextures=function(t,e,i){var r=this;return E((function(){var n,s,a;return O(this,(function(o){return s=null!=(n=i.textures)?n:t.map((function(t,e){return{source:e}})),a=s.map(E((function(t,n){var s,a,o,u,h,l;return O(this,(function(f){switch(f.label){case 0:if(A(t,Yi))return[2,t];if(!("mipmaps"in t))return[3,4];f.label=1;case 1:return f.trys.push([1,3,,4]),[4,Bi(t,e,r.assets,i.bins)];case 2:return[2,f.sent()];case 3:throw s=f.sent(),new Error("Load texture "+n+" fails, error message: "+s+".");case 4:return a=t.source,o=t.id,h="",bt(a)?(u=r.assets[a.id],h=a.id,[3,7]):[3,5];case 5:return"string"!=typeof a?[3,7]:[4,Ii(At(a))];case 6:u=f.sent(),f.label=7;case 7:if(u)return l=function(t,e,i){var r={id:i,dataType:_e.Texture};if(A(t,Yi))return _i({},t.source,r);if(A(t,c)||Tt(t))return _i({image:t,sourceType:ci.image,sourceFrom:e,keepImageSource:!0,minFilter:fi.LINEAR,magFilter:fi.LINEAR},r);if(A(t,m))return _i({sourceType:ci.video,video:t,minFilter:fi.LINEAR,magFilter:fi.LINEAR},r);if(A(t,ArrayBuffer))return _i({},Ji(t),{sourceFrom:e},r);if("width"in t&&"height"in t&&"data"in t)return _i({sourceType:ci.data,data:t,wrapS:fi.CLAMP_TO_EDGE,wrapT:fi.CLAMP_TO_EDGE,minFilter:fi.NEAREST,magFilter:fi.NEAREST},r);throw new Error("Invalid texture options.")}(u,r.sourceFrom[h],o),[2,l.sourceType===ci.compressed?l:_i({},l,t)];throw new Error("Invalid texture source: "+a+".")}}))}))),[2,Promise.all(a)]}))}))()},e.loadJSON=function(t){var e=this;return E((function(){return O(this,(function(i){return[2,new Promise((function(i,r){e.downloader.downloadJSON(t,i,(function(e,i){r("Couldn't load JSON "+JSON.stringify(t)+": status "+e+", "+i)}))}))]}))}))()},e.loadBins=function(t){var e=this;return E((function(){return O(this,(function(i){return[2,new Promise((function(i,r){e.downloader.downloadBinary(t,i,(function(e,i){r("Couldn't load bins "+JSON.stringify(t)+": status "+e+", "+i)}))}))]}))}))()},e.assignImagesToAssets=function(t,e){for(var i=0;i<t.length;i++)this.assets[t[i].id]=e[i]},e.removeTimer=function(t){var e=this.timers.indexOf(t);-1!==e&&this.timers.splice(e,1)},e.dispose=function(){this.timers.length&&this.timers.map((function(t){return r.clearTimeout(t)})),this.assets={},this.sourceFrom={},this.timers=[]},t}();Jc.fontCache=new Set;var $c,tl=function(){function t(t){this.engine=t,this.builtinObjects=[],this.builtinObjects.push(qi(t))}var e=t.prototype;return e.assembleSceneLoadOptions=function(t,e){void 0===e&&(e={});var i=t;return Hc.isURL(t)&&(Hc.isJSONObject(t)||(i=t.url),Hc.isWithOptions(t)&&(e=_i({},e,t.options))),{source:i,options:e}},e.updateTextVariables=function(t,e){var i=this;void 0===e&&(e={}),t.jsonScene.items.forEach((function(t){if(t.type===Xt.text||t.type===Xt.richtext){var r=e[t.name];if(!r)return;t.components.forEach((function(t){var e=t.id,n=i.engine.findEffectsObjectData(e);(null==n?void 0:n.dataType)!==_e.TextComponent&&(null==n?void 0:n.dataType)!==_e.RichTextComponent||(n.options.text=r)}))}}))},e.initializeTexture=function(t){for(var e=0;e<t.textureOptions.length;e++)t.textures[e]=this.engine.findObject({id:t.textureOptions[e].id}),t.textures[e].initialize()},e.prepareAssets=function(t,e){this.engine.clearResources();for(var i,r=w(Object.keys(e));!(i=r()).done;){var n=i.value,s=e[n],a=new Wh(this.engine);a.data=s,a.setInstanceId(n)}this.engine.addPackageDatas(t);for(var o,u=w(this.builtinObjects);!(o=u()).done;){var h=o.value;this.engine.addInstance(h)}},e.createShaderVariant=function(){for(var t,e=w(Object.keys(this.engine.objectInstance));!(t=e()).done;){var i=t.value,r=this.engine.objectInstance[i];A(r,cr)&&r.createShaderVariant()}},e.destroyBuiltinObjects=function(){for(var t,e=w(this.builtinObjects);!(t=e()).done;){t.value.dispose()}this.builtinObjects.length=0},e.dispose=function(){this.destroyBuiltinObjects()},t}(),el=new Int32Array(2),il=new Float32Array(el.buffer),rl=new Float64Array(el.buffer),nl=1===new Uint16Array(new Uint8Array([1,0]).buffer)[0];!function(t){t[t.UTF8_BYTES=1]="UTF8_BYTES",t[t.UTF16_STRING=2]="UTF16_STRING"}($c||($c={}));var sl=function(){function t(t){this.bytes_=t,this.position_=0,this.text_decoder_=new y}var e=t.prototype;return e.clear=function(){this.position_=0},e.bytes=function(){return this.bytes_},e.position=function(){return this.position_},e.setPosition=function(t){this.position_=t},e.capacity=function(){return this.bytes_.length},e.readInt8=function(t){return this.readUint8(t)<<24>>24},e.readUint8=function(t){return this.bytes_[t]},e.readInt16=function(t){return this.readUint16(t)<<16>>16},e.readUint16=function(t){return this.bytes_[t]|this.bytes_[t+1]<<8},e.readInt32=function(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24},e.readUint32=function(t){return this.readInt32(t)>>>0},e.readInt64=function(t){return BigInt.asIntN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))},e.readUint64=function(t){return BigInt.asUintN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))},e.readFloat32=function(t){return el[0]=this.readInt32(t),il[0]},e.readFloat64=function(t){return el[nl?0:1]=this.readInt32(t),el[nl?1:0]=this.readInt32(t+4),rl[0]},e.writeInt8=function(t,e){this.bytes_[t]=e},e.writeUint8=function(t,e){this.bytes_[t]=e},e.writeInt16=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8},e.writeUint16=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8},e.writeInt32=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24},e.writeUint32=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24},e.writeInt64=function(t,e){this.writeInt32(t,Number(BigInt.asIntN(32,e))),this.writeInt32(t+4,Number(BigInt.asIntN(32,e>>BigInt(32))))},e.writeUint64=function(t,e){this.writeUint32(t,Number(BigInt.asUintN(32,e))),this.writeUint32(t+4,Number(BigInt.asUintN(32,e>>BigInt(32))))},e.writeFloat32=function(t,e){il[0]=e,this.writeInt32(t,el[0])},e.writeFloat64=function(t,e){rl[0]=e,this.writeInt32(t,el[nl?0:1]),this.writeInt32(t+4,el[nl?1:0])},e.getBufferIdentifier=function(){if(this.bytes_.length<this.position_+4+4)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");for(var t="",e=0;e<4;e++)t+=String.fromCharCode(this.readInt8(this.position_+4+e));return t},e.__offset=function(t,e){var i=t-this.readInt32(t);return e<this.readInt16(i)?this.readInt16(i+e):0},e.__union=function(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t},e.__string=function(t,e){t+=this.readInt32(t);var i=this.readInt32(t);t+=4;var r=this.bytes_.subarray(t,t+i);return e===$c.UTF8_BYTES?r:this.text_decoder_.decode(r)},e.__union_with_string=function(t,e){return"string"==typeof t?this.__string(e):this.__union(t,e)},e.__indirect=function(t){return t+this.readInt32(t)},e.__vector=function(t){return t+this.readInt32(t)+4},e.__vector_len=function(t){return this.readInt32(t+this.readInt32(t))},e.__has_identifier=function(t){if(4!=t.length)throw new Error("FlatBuffers: file identifier must be length 4");for(var e=0;e<4;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+4+e))return!1;return!0},e.createScalarList=function(t,e){for(var i=[],r=0;r<e;++r){var n=t(r);null!==n&&i.push(n)}return i},e.createObjList=function(t,e){for(var i=[],r=0;r<e;++r){var n=t(r);null!==n&&i.push(n.unpack())}return i},t.allocate=function(e){return new t(new Uint8Array(e))},t}(),al=function(){function t(t){var e;this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null,this.text_encoder=new TextEncoder,e=t||1024,this.bb=sl.allocate(e),this.space=e}var e=t.prototype;return e.clear=function(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null},e.forceDefaults=function(t){this.force_defaults=t},e.dataBuffer=function(){return this.bb},e.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},e.prep=function(e,i){e>this.minalign&&(this.minalign=e);for(var r=1+~(this.bb.capacity()-this.space+i)&e-1;this.space<r+e+i;){var n=this.bb.capacity();this.bb=t.growByteBuffer(this.bb),this.space+=this.bb.capacity()-n}this.pad(r)},e.pad=function(t){for(var e=0;e<t;e++)this.bb.writeInt8(--this.space,0)},e.writeInt8=function(t){this.bb.writeInt8(this.space-=1,t)},e.writeInt16=function(t){this.bb.writeInt16(this.space-=2,t)},e.writeInt32=function(t){this.bb.writeInt32(this.space-=4,t)},e.writeInt64=function(t){this.bb.writeInt64(this.space-=8,t)},e.writeFloat32=function(t){this.bb.writeFloat32(this.space-=4,t)},e.writeFloat64=function(t){this.bb.writeFloat64(this.space-=8,t)},e.addInt8=function(t){this.prep(1,0),this.writeInt8(t)},e.addInt16=function(t){this.prep(2,0),this.writeInt16(t)},e.addInt32=function(t){this.prep(4,0),this.writeInt32(t)},e.addInt64=function(t){this.prep(8,0),this.writeInt64(t)},e.addFloat32=function(t){this.prep(4,0),this.writeFloat32(t)},e.addFloat64=function(t){this.prep(8,0),this.writeFloat64(t)},e.addFieldInt8=function(t,e,i){(this.force_defaults||e!=i)&&(this.addInt8(e),this.slot(t))},e.addFieldInt16=function(t,e,i){(this.force_defaults||e!=i)&&(this.addInt16(e),this.slot(t))},e.addFieldInt32=function(t,e,i){(this.force_defaults||e!=i)&&(this.addInt32(e),this.slot(t))},e.addFieldInt64=function(t,e,i){(this.force_defaults||e!==i)&&(this.addInt64(e),this.slot(t))},e.addFieldFloat32=function(t,e,i){(this.force_defaults||e!=i)&&(this.addFloat32(e),this.slot(t))},e.addFieldFloat64=function(t,e,i){(this.force_defaults||e!=i)&&(this.addFloat64(e),this.slot(t))},e.addFieldOffset=function(t,e,i){(this.force_defaults||e!=i)&&(this.addOffset(e),this.slot(t))},e.addFieldStruct=function(t,e,i){e!=i&&(this.nested(e),this.slot(t))},e.nested=function(t){if(t!=this.offset())throw new TypeError("FlatBuffers: struct must be serialized inline.")},e.notNested=function(){if(this.isNested)throw new TypeError("FlatBuffers: object serialization must not be nested.")},e.slot=function(t){null!==this.vtable&&(this.vtable[t]=this.offset())},e.offset=function(){return this.bb.capacity()-this.space},e.addOffset=function(t){this.prep(4,0),this.writeInt32(this.offset()-t+4)},e.startObject=function(t){this.notNested(),null==this.vtable&&(this.vtable=[]),this.vtable_in_use=t;for(var e=0;e<t;e++)this.vtable[e]=0;this.isNested=!0,this.object_start=this.offset()},e.endObject=function(){if(null==this.vtable||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);for(var t=this.offset(),e=this.vtable_in_use-1;e>=0&&0==this.vtable[e];e--);for(var i=e+1;e>=0;e--)this.addInt16(0!=this.vtable[e]?t-this.vtable[e]:0);this.addInt16(t-this.object_start);var r=2*(i+2);this.addInt16(r);var n=0,s=this.space;t:for(e=0;e<this.vtables.length;e++){var a=this.bb.capacity()-this.vtables[e];if(r==this.bb.readInt16(a)){for(var o=2;o<r;o+=2)if(this.bb.readInt16(s+o)!=this.bb.readInt16(a+o))continue t;n=this.vtables[e];break}}return n?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,n-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t},e.finish=function(t,e,i){var r=i?4:0;if(e){var n=e;if(this.prep(this.minalign,8+r),4!=n.length)throw new TypeError("FlatBuffers: file identifier must be length 4");for(var s=3;s>=0;s--)this.writeInt8(n.charCodeAt(s))}this.prep(this.minalign,4+r),this.addOffset(t),r&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},e.finishSizePrefixed=function(t,e){this.finish(t,e,!0)},e.requiredField=function(t,e){var i=this.bb.capacity()-t,r=i-this.bb.readInt32(i);if(!(e<this.bb.readInt16(r)&&0!=this.bb.readInt16(r+e)))throw new TypeError("FlatBuffers: field "+e+" must be set")},e.startVector=function(t,e,i){this.notNested(),this.vector_num_elems=e,this.prep(4,t*e),this.prep(i,t*e)},e.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},e.createSharedString=function(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);var e=this.createString(t);return this.string_maps.set(t,e),e},e.createString=function(t){return null==t?0:(e=A(t,Uint8Array)?t:this.text_encoder.encode(t),this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length),this.bb.bytes().set(e,this.space),this.endVector());var e},e.createByteVector=function(t){return null==t?0:(this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length),this.bb.bytes().set(t,this.space),this.endVector())},e.createObjectOffset=function(t){return null===t?0:"string"==typeof t?this.createString(t):t.pack(this)},e.createObjectOffsetList=function(t){for(var e=[],i=0;i<t.length;++i){var r=t[i];if(null===r)throw new TypeError("FlatBuffers: Argument for createObjectOffsetList cannot contain null.");e.push(this.createObjectOffset(r))}return e},e.createStructOffsetList=function(t,e){return e(this,t.length),this.createObjectOffsetList(t.slice().reverse()),this.endVector()},t.growByteBuffer=function(t){var e=t.capacity();if(3221225472&e)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");var i=e<<1,r=sl.allocate(i);return r.setPosition(i-e),r.bytes().set(t.bytes(),i-e),r},t}(),ol=function(){function t(){this.bb=null,this.bb_pos=0}var e=t.prototype;return e.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.dataType=function(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null},e.data=function(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0},e.dataLength=function(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0},e.dataArray=function(){var t=this.bb.__offset(this.bb_pos,6);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null},e.unpack=function(){return new ul(this.dataType(),this.bb.createScalarList(this.data.bind(this),this.dataLength()))},e.unpackTo=function(t){t.dataType=this.dataType(),t.data=this.bb.createScalarList(this.data.bind(this),this.dataLength())},t.getRootAsFBEffectsObjectData=function(e,i){return(i||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsFBEffectsObjectData=function(e,i){return e.setPosition(e.position()+4),(i||new t).__init(e.readInt32(e.position())+e.position(),e)},t.startFBEffectsObjectData=function(t){t.startObject(2)},t.addDataType=function(t,e){t.addFieldOffset(0,e,0)},t.addData=function(t,e){t.addFieldOffset(1,e,0)},t.createDataVector=function(t,e){t.startVector(1,e.length,1);for(var i=e.length-1;i>=0;i--)t.addInt8(e[i]);return t.endVector()},t.startDataVector=function(t,e){t.startVector(1,e,1)},t.endFBEffectsObjectData=function(t){return t.endObject()},t.createFBEffectsObjectData=function(e,i,r){return t.startFBEffectsObjectData(e),t.addDataType(e,i),t.addData(e,r),t.endFBEffectsObjectData(e)},t}(),ul=function(){function t(t,e){void 0===t&&(t=null),void 0===e&&(e=[]),this.dataType=t,this.data=e}return t.prototype.pack=function(t){var e=null!==this.dataType?t.createString(this.dataType):0,i=ol.createDataVector(t,this.data);return ol.createFBEffectsObjectData(t,e,i)},t}(),hl=function(){function t(){this.bb=null,this.bb_pos=0}var e=t.prototype;return e.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.exportObjects=function(t,e){var i=this.bb.__offset(this.bb_pos,4);return i?(e||new ol).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+4*t),this.bb):null},e.exportObjectsLength=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0},e.unpack=function(){return new cl(this.bb.createObjList(this.exportObjects.bind(this),this.exportObjectsLength()))},e.unpackTo=function(t){t.exportObjects=this.bb.createObjList(this.exportObjects.bind(this),this.exportObjectsLength())},t.getRootAsFBEffectsPackageData=function(e,i){return(i||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsFBEffectsPackageData=function(e,i){return e.setPosition(e.position()+4),(i||new t).__init(e.readInt32(e.position())+e.position(),e)},t.startFBEffectsPackageData=function(t){t.startObject(1)},t.addExportObjects=function(t,e){t.addFieldOffset(0,e,0)},t.createExportObjectsVector=function(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()},t.startExportObjectsVector=function(t,e){t.startVector(4,e,4)},t.endFBEffectsPackageData=function(t){return t.endObject()},t.finishFBEffectsPackageDataBuffer=function(t,e){t.finish(e)},t.finishSizePrefixedFBEffectsPackageDataBuffer=function(t,e){t.finish(e,void 0,!0)},t.createFBEffectsPackageData=function(e,i){return t.startFBEffectsPackageData(e),t.addExportObjects(e,i),t.endFBEffectsPackageData(e)},t}(),cl=function(){function t(t){void 0===t&&(t=[]),this.exportObjects=t}return t.prototype.pack=function(t){var e=hl.createExportObjectsVector(t,t.createObjectOffsetList(this.exportObjects));return hl.createFBEffectsPackageData(t,e)},t}(),ll=function(){function t(){this.bb=null,this.bb_pos=0}var e=t.prototype;return e.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.offset=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0},e.indexCount=function(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0},e.vertexCount=function(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt32(this.bb_pos+t):0},e.unpack=function(){return new fl(this.offset(),this.indexCount(),this.vertexCount())},e.unpackTo=function(t){t.offset=this.offset(),t.indexCount=this.indexCount(),t.vertexCount=this.vertexCount()},t.getRootAsFBSubMesh=function(e,i){return(i||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsFBSubMesh=function(e,i){return e.setPosition(e.position()+4),(i||new t).__init(e.readInt32(e.position())+e.position(),e)},t.startFBSubMesh=function(t){t.startObject(3)},t.addOffset=function(t,e){t.addFieldInt32(0,e,0)},t.addIndexCount=function(t,e){t.addFieldInt32(1,e,0)},t.addVertexCount=function(t,e){t.addFieldInt32(2,e,0)},t.endFBSubMesh=function(t){return t.endObject()},t.createFBSubMesh=function(e,i,r,n){return t.startFBSubMesh(e),t.addOffset(e,i),t.addIndexCount(e,r),t.addVertexCount(e,n),t.endFBSubMesh(e)},t}(),fl=function(){function t(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this.offset=t,this.indexCount=e,this.vertexCount=i}return t.prototype.pack=function(t){return ll.createFBSubMesh(t,this.offset,this.indexCount,this.vertexCount)},t}(),dl=function(){function t(){this.bb=null,this.bb_pos=0}var e=t.prototype;return e.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.semantic=function(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null},e.offset=function(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0},e.format=function(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt32(this.bb_pos+t):0},e.dimension=function(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt32(this.bb_pos+t):0},e.normalize=function(){var t=this.bb.__offset(this.bb_pos,12);return!!t&&!!this.bb.readInt8(this.bb_pos+t)},e.unpack=function(){return new pl(this.semantic(),this.offset(),this.format(),this.dimension(),this.normalize())},e.unpackTo=function(t){t.semantic=this.semantic(),t.offset=this.offset(),t.format=this.format(),t.dimension=this.dimension(),t.normalize=this.normalize()},t.getRootAsFBVertexChannel=function(e,i){return(i||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsFBVertexChannel=function(e,i){return e.setPosition(e.position()+4),(i||new t).__init(e.readInt32(e.position())+e.position(),e)},t.startFBVertexChannel=function(t){t.startObject(5)},t.addSemantic=function(t,e){t.addFieldOffset(0,e,0)},t.addOffset=function(t,e){t.addFieldInt32(1,e,0)},t.addFormat=function(t,e){t.addFieldInt32(2,e,0)},t.addDimension=function(t,e){t.addFieldInt32(3,e,0)},t.addNormalize=function(t,e){t.addFieldInt8(4,+e,0)},t.endFBVertexChannel=function(t){return t.endObject()},t.createFBVertexChannel=function(e,i,r,n,s,a){return t.startFBVertexChannel(e),t.addSemantic(e,i),t.addOffset(e,r),t.addFormat(e,n),t.addDimension(e,s),t.addNormalize(e,a),t.endFBVertexChannel(e)},t}(),pl=function(){function t(t,e,i,r,n){void 0===t&&(t=null),void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=!1),this.semantic=t,this.offset=e,this.format=i,this.dimension=r,this.normalize=n}return t.prototype.pack=function(t){var e=null!==this.semantic?t.createString(this.semantic):0;return dl.createFBVertexChannel(t,e,this.offset,this.format,this.dimension,this.normalize)},t}(),ml=function(){function t(){this.bb=null,this.bb_pos=0}var e=t.prototype;return e.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.vertexCount=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0},e.channels=function(t,e){var i=this.bb.__offset(this.bb_pos,6);return i?(e||new dl).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+4*t),this.bb):null},e.channelsLength=function(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0},e.unpack=function(){return new vl(this.vertexCount(),this.bb.createObjList(this.channels.bind(this),this.channelsLength()))},e.unpackTo=function(t){t.vertexCount=this.vertexCount(),t.channels=this.bb.createObjList(this.channels.bind(this),this.channelsLength())},t.getRootAsFBVertexData=function(e,i){return(i||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsFBVertexData=function(e,i){return e.setPosition(e.position()+4),(i||new t).__init(e.readInt32(e.position())+e.position(),e)},t.startFBVertexData=function(t){t.startObject(2)},t.addVertexCount=function(t,e){t.addFieldInt32(0,e,0)},t.addChannels=function(t,e){t.addFieldOffset(1,e,0)},t.createChannelsVector=function(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()},t.startChannelsVector=function(t,e){t.startVector(4,e,4)},t.endFBVertexData=function(t){return t.endObject()},t.createFBVertexData=function(e,i,r){return t.startFBVertexData(e),t.addVertexCount(e,i),t.addChannels(e,r),t.endFBVertexData(e)},t}(),vl=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=[]),this.vertexCount=t,this.channels=e}return t.prototype.pack=function(t){var e=ml.createChannelsVector(t,t.createObjectOffsetList(this.channels));return ml.createFBVertexData(t,this.vertexCount,e)},t}(),yl=function(){function t(){this.bb=null,this.bb_pos=0}var e=t.prototype;return e.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.id=function(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null},e.name=function(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null},e.vertexData=function(t){var e=this.bb.__offset(this.bb_pos,8);return e?(t||new ml).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null},e.indexFormat=function(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt32(this.bb_pos+t):0},e.indexOffset=function(){var t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readInt32(this.bb_pos+t):0},e.subMeshes=function(t,e){var i=this.bb.__offset(this.bb_pos,14);return i?(e||new ll).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+4*t),this.bb):null},e.subMeshesLength=function(){var t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0},e.mode=function(){var t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readInt32(this.bb_pos+t):0},e.buffer=function(t){var e=this.bb.__offset(this.bb_pos,18);return e?this.bb.__string(this.bb_pos+e,t):null},e.binaryData=function(t){var e=this.bb.__offset(this.bb_pos,20);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0},e.binaryDataLength=function(){var t=this.bb.__offset(this.bb_pos,20);return t?this.bb.__vector_len(this.bb_pos+t):0},e.binaryDataArray=function(){var t=this.bb.__offset(this.bb_pos,20);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null},e.boneNames=function(t,e){var i=this.bb.__offset(this.bb_pos,22);return i?this.bb.__string(this.bb.__vector(this.bb_pos+i)+4*t,e):null},e.boneNamesLength=function(){var t=this.bb.__offset(this.bb_pos,22);return t?this.bb.__vector_len(this.bb_pos+t):0},e.rootBoneName=function(t){var e=this.bb.__offset(this.bb_pos,24);return e?this.bb.__string(this.bb_pos+e,t):null},e.inverseBindMatrices=function(t){var e=this.bb.__offset(this.bb_pos,26);return e?this.bb.readFloat32(this.bb.__vector(this.bb_pos+e)+4*t):0},e.inverseBindMatricesLength=function(){var t=this.bb.__offset(this.bb_pos,26);return t?this.bb.__vector_len(this.bb_pos+t):0},e.inverseBindMatricesArray=function(){var t=this.bb.__offset(this.bb_pos,26);return t?new Float32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null},e.unpack=function(){return new gl(this.id(),this.name(),null!==this.vertexData()?this.vertexData().unpack():null,this.indexFormat(),this.indexOffset(),this.bb.createObjList(this.subMeshes.bind(this),this.subMeshesLength()),this.mode(),this.buffer(),this.bb.createScalarList(this.binaryData.bind(this),this.binaryDataLength()),this.bb.createScalarList(this.boneNames.bind(this),this.boneNamesLength()),this.rootBoneName(),this.bb.createScalarList(this.inverseBindMatrices.bind(this),this.inverseBindMatricesLength()))},e.unpackTo=function(t){t.id=this.id(),t.name=this.name(),t.vertexData=null!==this.vertexData()?this.vertexData().unpack():null,t.indexFormat=this.indexFormat(),t.indexOffset=this.indexOffset(),t.subMeshes=this.bb.createObjList(this.subMeshes.bind(this),this.subMeshesLength()),t.mode=this.mode(),t.buffer=this.buffer(),t.binaryData=this.bb.createScalarList(this.binaryData.bind(this),this.binaryDataLength()),t.boneNames=this.bb.createScalarList(this.boneNames.bind(this),this.boneNamesLength()),t.rootBoneName=this.rootBoneName(),t.inverseBindMatrices=this.bb.createScalarList(this.inverseBindMatrices.bind(this),this.inverseBindMatricesLength())},t.getRootAsFBGeometryData=function(e,i){return(i||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsFBGeometryData=function(e,i){return e.setPosition(e.position()+4),(i||new t).__init(e.readInt32(e.position())+e.position(),e)},t.startFBGeometryData=function(t){t.startObject(12)},t.addId=function(t,e){t.addFieldOffset(0,e,0)},t.addName=function(t,e){t.addFieldOffset(1,e,0)},t.addVertexData=function(t,e){t.addFieldOffset(2,e,0)},t.addIndexFormat=function(t,e){t.addFieldInt32(3,e,0)},t.addIndexOffset=function(t,e){t.addFieldInt32(4,e,0)},t.addSubMeshes=function(t,e){t.addFieldOffset(5,e,0)},t.createSubMeshesVector=function(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()},t.startSubMeshesVector=function(t,e){t.startVector(4,e,4)},t.addMode=function(t,e){t.addFieldInt32(6,e,0)},t.addBuffer=function(t,e){t.addFieldOffset(7,e,0)},t.addBinaryData=function(t,e){t.addFieldOffset(8,e,0)},t.createBinaryDataVector=function(t,e){t.startVector(1,e.length,1);for(var i=e.length-1;i>=0;i--)t.addInt8(e[i]);return t.endVector()},t.startBinaryDataVector=function(t,e){t.startVector(1,e,1)},t.addBoneNames=function(t,e){t.addFieldOffset(9,e,0)},t.createBoneNamesVector=function(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()},t.startBoneNamesVector=function(t,e){t.startVector(4,e,4)},t.addRootBoneName=function(t,e){t.addFieldOffset(10,e,0)},t.addInverseBindMatrices=function(t,e){t.addFieldOffset(11,e,0)},t.createInverseBindMatricesVector=function(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addFloat32(e[i]);return t.endVector()},t.startInverseBindMatricesVector=function(t,e){t.startVector(4,e,4)},t.endFBGeometryData=function(t){return t.endObject()},t}(),gl=function(){function t(t,e,i,r,n,s,a,o,u,h,c,l){void 0===t&&(t=null),void 0===e&&(e=null),void 0===i&&(i=null),void 0===r&&(r=0),void 0===n&&(n=0),void 0===s&&(s=[]),void 0===a&&(a=0),void 0===o&&(o=null),void 0===u&&(u=[]),void 0===h&&(h=[]),void 0===c&&(c=null),void 0===l&&(l=[]),this.id=t,this.name=e,this.vertexData=i,this.indexFormat=r,this.indexOffset=n,this.subMeshes=s,this.mode=a,this.buffer=o,this.binaryData=u,this.boneNames=h,this.rootBoneName=c,this.inverseBindMatrices=l}return t.prototype.pack=function(t){var e=null!==this.id?t.createString(this.id):0,i=null!==this.name?t.createString(this.name):0,r=null!==this.vertexData?this.vertexData.pack(t):0,n=yl.createSubMeshesVector(t,t.createObjectOffsetList(this.subMeshes)),s=null!==this.buffer?t.createString(this.buffer):0,a=yl.createBinaryDataVector(t,this.binaryData),o=yl.createBoneNamesVector(t,t.createObjectOffsetList(this.boneNames)),u=null!==this.rootBoneName?t.createString(this.rootBoneName):0,h=yl.createInverseBindMatricesVector(t,this.inverseBindMatrices);return yl.startFBGeometryData(t),yl.addId(t,e),yl.addName(t,i),yl.addVertexData(t,r),yl.addIndexFormat(t,this.indexFormat),yl.addIndexOffset(t,this.indexOffset),yl.addSubMeshes(t,n),yl.addMode(t,this.mode),yl.addBuffer(t,s),yl.addBinaryData(t,a),yl.addBoneNames(t,o),yl.addRootBoneName(t,u),yl.addInverseBindMatrices(t,h),yl.endFBGeometryData(t)},t}(),xl=function(){function t(){this.exportObjectDatas=[]}var e=t.prototype;return e.addData=function(t){this.exportObjectDatas.push(t)},e.serializeToBinary=function(){for(var t,e=new al(1),i=new cl,r=[],n=w(this.exportObjectDatas);!(t=n()).done;){var s=t.value,a=void 0;s.dataType===_e.Geometry&&(a=new ul("Geometry",this.geometryDataToBinary(s))),a&&r.push(a)}return i.exportObjects=r,hl.finishFBEffectsPackageDataBuffer(e,i.pack(e)),e.asUint8Array()},e.deserializeFromBinary=function(t){for(var e=new sl(t),i=hl.getRootAsFBEffectsPackageData(e),r=0;r<i.exportObjectsLength();r++){var n=i.exportObjects(r);if(n){var s=n.dataArray(),a=n.dataType();if(s){var o=void 0;a===_e.Geometry&&(o=this.binaryToGeometryData(s)),o&&this.exportObjectDatas.push(o)}}}},e.geometryDataToBinary=function(t){var e=new al(1),i=new gl,r=t.indexFormat,n=t.indexOffset,s=t.mode,a=t.id,o=t.vertexData,u=t.boneNames,h=void 0===u?[]:u,c=t.rootBoneName,l=void 0===c?"":c,f=t.inverseBindMatrices,d=void 0===f?[]:f,p=t.binaryData,m=void 0===p?[]:p;i.indexFormat=r,i.indexOffset=n,i.mode=s,i.id=a,i.boneNames=h,i.rootBoneName=l,i.inverseBindMatrices=d,i.binaryData=m;var v=new vl;v.vertexCount=o.vertexCount,v.channels=[];for(var y,g=w(o.channels);!(y=g()).done;){var x=y.value,b=x.semantic,T=x.offset,E=x.format,_=x.dimension,A=x.normalize,C=new pl(b,T,E,_,A);v.channels.push(C)}i.vertexData=v;for(var S,O=[],R=w(t.subMeshes);!(S=R()).done;){var M=S.value,I=M.offset,P=M.indexCount,L=M.vertexCount,F=new fl(I,P,L);O.push(F)}return i.subMeshes=O,hl.finishFBEffectsPackageDataBuffer(e,i.pack(e)),e.asUint8Array()},e.binaryToGeometryData=function(t){var e=new sl(t),i=yl.getRootAsFBGeometryData(e),r={vertexCount:0,channels:[]},n=i.vertexData();if(n){r.vertexCount=n.vertexCount();for(var s=0;s<n.channelsLength();s++){var a=n.channels(s);if(a){var o,u={semantic:null!=(o=a.semantic())?o:"",offset:a.offset(),format:a.format(),dimension:a.dimension(),normalize:a.normalize()};r.channels.push(u)}}}for(var h=[],c=0;c<i.subMeshesLength();c++){var l=i.subMeshes(c);if(l){var f={offset:l.offset(),vertexCount:l.vertexCount(),indexCount:l.indexCount()};h.push(f)}}for(var d=[],p=0;p<i.boneNamesLength();p++){var m=i.boneNames(p);d.push(m)}var v,y,g,x,b=i.inverseBindMatricesArray();return{vertexData:r,indexFormat:i.indexFormat(),indexOffset:i.indexOffset(),subMeshes:h,mode:i.mode(),buffer:null!=(v=i.buffer())?v:"",boneNames:d,rootBoneName:null!=(y=i.rootBoneName())?y:"",inverseBindMatrices:b?Array.from(b):void 0,binaryData:null!=(g=i.binaryDataArray())?g:void 0,id:null!=(x=i.id())?x:"",dataType:_e.Geometry}},t}(),bl=function(){function t(){this.renderErrors=new Set,this.destroyed=!1,this.textures=[],this.materials=[],this.geometries=[],this.meshes=[],this.renderPasses=[],this.jsonSceneData={},this.objectInstance={},this.assetLoader=new Kh(this),this.emptyTexture=qi(this),this.transparentTexture=Ki(this)}var e=t.prototype;return e.clearResources=function(){this.jsonSceneData={},this.objectInstance={}},e.addEffectsObjectData=function(t){this.jsonSceneData[t.id]=t},e.findEffectsObjectData=function(t){return this.jsonSceneData[t]},e.addInstance=function(t){this.objectInstance[t.getInstanceId()]=t},e.findObject=function(t){return bt(t)&&t.constructor===Object?this.objectInstance[t.id]?this.objectInstance[t.id]:this.assetLoader.loadGUID(t):t},e.removeInstance=function(t){delete this.objectInstance[t]},e.addPackageDatas=function(t){for(var e,i=t.jsonScene,r=t.textureOptions,n=void 0===r?[]:r,s=i.items,a=void 0===s?[]:s,o=i.materials,u=void 0===o?[]:o,h=i.shaders,c=void 0===h?[]:h,l=i.geometries,f=void 0===l?[]:l,d=i.components,p=void 0===d?[]:d,m=i.animations,v=void 0===m?[]:m,y=i.bins,g=void 0===y?[]:y,x=i.miscs,b=void 0===x?[]:x,T=w(i.compositions);!(e=T()).done;){var E=e.value;this.addEffectsObjectData(E)}for(var _,A=w(a);!(_=A()).done;){var C=_.value;Wc(C.renderLevel,t.renderLevel)||(C.components=[],C.type=Xt.null),this.addEffectsObjectData(C)}for(var S,O=w(u);!(S=O()).done;){var R=S.value;this.addEffectsObjectData(R)}for(var M,I=w(c);!(M=I()).done;){var P=M.value;this.addEffectsObjectData(P)}for(var L,F=w(f);!(L=F()).done;){var V=L.value;this.addEffectsObjectData(V)}for(var N,D=w(p);!(N=D()).done;){var k=N.value;this.addEffectsObjectData(k)}for(var z,U=w(v);!(z=U()).done;){var B=z.value;this.addEffectsObjectData(B)}for(var G,j=w(b);!(G=j()).done;){var X=G.value;this.addEffectsObjectData(X)}for(var H=0;H<g.length;H++){var Y=g[H],W=t.bins[H];if(Y.dataType===_e.BinaryAsset)Y.buffer=W,Y.id&&this.addEffectsObjectData(Y);else{var Z=new xl;Z.deserializeFromBinary(new Uint8Array(W));for(var q,K=w(Z.exportObjectDatas);!(q=K()).done;){var Q=q.value;this.addEffectsObjectData(Q)}}}for(var J,$=w(n);!(J=$()).done;){var tt=J.value;this.addEffectsObjectData(tt)}},e.createVFXItems=function(t){var e=this;return E((function(){var i,r,n,s,a;return O(this,(function(o){for(i=t.jsonScene,r=w(i.items);!(n=r()).done;)s=n.value,"ECS"!==(a=s.type)&&"camera"!==a&&a!==Xt.sprite&&a!==Xt.particle&&a!==Xt.mesh&&a!==Xt.skybox&&a!==Xt.light&&a!==Xt.tree&&a!==Xt.interact&&a!==Xt.camera||e.database&&e.assetLoader.loadGUID(s);return[2]}))}))()},e.addTexture=function(t){this.destroyed||D(this.textures,t)},e.removeTexture=function(t){this.destroyed||k(this.textures,t)},e.addMaterial=function(t){this.destroyed||D(this.materials,t)},e.removeMaterial=function(t){this.destroyed||k(this.materials,t)},e.addGeometry=function(t){this.destroyed||D(this.geometries,t)},e.removeGeometry=function(t){this.destroyed||k(this.geometries,t)},e.addMesh=function(t){this.destroyed||D(this.meshes,t)},e.removeMesh=function(t){this.destroyed||k(this.meshes,t)},e.addRenderPass=function(t){this.destroyed||D(this.renderPasses,t)},e.removeRenderPass=function(t){this.destroyed||k(this.renderPasses,t)},e.getShaderLibrary=function(){return this.renderer.getShaderLibrary()},e.dispose=function(){if(!this.destroyed){this.destroyed=!0;var t=[];this.renderPasses.length>0&&t.push("Pass "+this.renderPasses.length),this.meshes.length>0&&t.push("Mesh "+this.meshes.length),this.geometries.length>0&&t.push("Geom "+this.geometries.length),this.textures.length>0&&t.push("Tex "+this.textures.length),t.length>0&&mt.warn("Release GPU memory: "+t.join(", ")+"."),this.renderPasses.forEach((function(t){return t.dispose()})),this.meshes.forEach((function(t){return t.dispose()})),this.geometries.forEach((function(t){return t.dispose()})),this.materials.forEach((function(t){return t.dispose()})),this.textures.forEach((function(t){return t.dispose()})),this.textures=[],this.materials=[],this.geometries=[],this.meshes=[],this.renderPasses=[],this.renderer=null}},Pe(t,[{key:"isDestroyed",get:function(){return this.destroyed}}]),t}(),Tl=60,El=function(){function t(t){void 0===t&&(t=60),this.paused=!0,this.lastTime=0,this.dt=0,this.setFPS(t),this.tickers=[]}var e=t.prototype;return e.getFPS=function(){return this.targetFPS},e.setFPS=function(t){this.targetFPS=qe(t,1,120),this.interval=Math.floor(1e3/t)-2},e.getPaused=function(){return this.paused},e.start=function(){var t=this;if(this.paused=!1,this.dt=0,!this.intervalId){this.lastTime=d.now();var e=x||function(t){return r.setTimeout(t,16.7)},i=function(){t.intervalId=e(i),t.paused||t.tick()};i()}},e.stop=function(){(g||r.clearTimeout)(this.intervalId),this.intervalId=0,this.lastTime=0,this.paused=!0,this.dt=0,this.tickers=[]},e.pause=function(){this.paused=!0,this.dt=0},e.resume=function(){this.paused=!1,this.dt=0},e.tick=function(){if(!this.paused){var t=d.now();if(this.dt=t-this.lastTime,this.dt>=this.interval){this.lastTime=t,this.resetTickers&&(this.tickers=this.tickers.filter((function(t){return t})),this.resetTickers=!1);for(var e=0,i=this.tickers.length;e<i;e++){var r=this.tickers[e];r(this.dt)}}}},e.add=function(t){if("function"!=typeof t)throw new Error("The tick object must implement the tick method.");this.tickers.push(t)},Pe(t,[{key:"deltaTime",get:function(){return this.dt}}]),t}();Mt("camera",zs,Wu),Mt("text",Yh,Wu),Mt("sprite",no,Wu),Mt("particle",ih,Wu),Mt("cal",rh,Wu),Mt("interact",Zs,Wu);var _l;mt.info("Core version: 2.5.0-alpha.5.");var wl,Al=((_l={})[fi.RGBA]=34842,_l[fi.RGB]=34843,_l[fi.ALPHA]=33325,_l[fi.RED]=33325,_l[fi.LUMINANCE_ALPHA]=33327,_l[fi.LUMINANCE]=33325,_l),Cl=((wl={})[fi.RGBA]=34836,wl[fi.RGB]=34837,wl[fi.ALPHA]=33326,wl[fi.RED]=33326,wl[fi.LUMINANCE_ALPHA]=33328,wl[fi.LUMINANCE]=33326,wl),Sl=function(t){function e(e,i){var r;return(r=t.call(this,e)||this).initialized=!1,i&&r.fromData(i),r}Qt(e,t);var i=e.prototype;return i.bind=function(t){this.pipelineContext.bindTexture(this.target,this.textureBuffer,t)},i.initialize=function(){if(!this.initialized){var t=this.engine;t.addTexture(this),this.pipelineContext=t.getGLPipelineContext();var e=this.pipelineContext.gl,i=this.source,r=i.target,n=void 0===r?e.TEXTURE_2D:r,s=i.name;this.textureBuffer=e.createTexture(),Pl(this.textureBuffer,s),this.target=n,this.update(this.source),this.release(),this.initialized=!0}},i.clone=function(){var t=new e(this.engine,this.source);return t.sourceFrom=this.sourceFrom,t.sourceType=this.sourceType,t.width=this.width,t.height=this.height,t},i.release=function(){switch(this.source.sourceType){case ci.image:delete this.source.image,delete this.source.cube;break;case ci.data:delete this.source.data;break;case ci.compressed:case ci.mipmaps:delete this.source.mipmaps}},i.update=function(t){var e=this;if(!this.pipelineContext||!this.textureBuffer)return this.width=0,void(this.height=0);var i,r,n=this.target,s=this.source,a=this.pipelineContext.gl,o=this.engine.gpuCapability.detail,u=s.sourceType,h=s.data,c=s.cube,l=s.image,f=s.video,d=s.mipmaps,p=s.mipmaps,m=t.data,v=t.cube,y=t.generateMipmap,g=t.mipmaps,x=s.format,b=s.type,T=s.internalFormat,E=0,_=0;if(this.bind(u===ci.video),b===fi.HALF_FLOAT?((b=o.halfFloatTexture)||mt.error("Half float texture is not support."),pi(a)&&T===x&&(x===fi.LUMINANCE&&(x=fi.RED),T=Al[x]),o.halfFloatLinear||(s.minFilter=s.magFilter=a.NEAREST,mt.warn("Half float linear not support, change to NEAREST."))):b===a.FLOAT&&((b=o.floatTexture)||mt.error("Float texture is not support."),pi(a)&&T===x&&(x===fi.LUMINANCE&&(x=fi.RED),T=Cl[x]),o.floatLinear||(s.minFilter=a.NEAREST,s.magFilter=a.NEAREST,mt.warn("Float linear not support, change to NEAREST."))),void 0===s.premultiplyAlpha&&(s.premultiplyAlpha=!1),a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),void 0===s.flipY&&(s.flipY=!1),a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,s.flipY),u===ci.framebuffer)m&&(E=null!=(i=m.width)?i:0,_=null!=(r=m.height)?r:0,E&&_&&(this.width!==E||this.height!==_)&&a.texImage2D(n,0,T,E,_,0,x,b,null));else if(u===ci.data){var w;if(n===a.TEXTURE_CUBE_MAP)v.forEach((function(t,i){var r=e.texImage2DData(a,a.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,T,x,b,t),n=r[0],s=r[1];E=Math.max(n,E),_=Math.max(s,_)}));else w=this.texImage2DData(a,n,0,T,x,b,h),E=w[0],_=w[1]}else if(u===ci.image||u===ci.video){if(n===a.TEXTURE_CUBE_MAP)c.forEach((function(t,i){var r=e.texImage2D(a,a.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,T,x,b,t),n=r[0],s=r[1];E=Math.max(n,E),_=Math.max(s,_)}));else if(n===a.TEXTURE_2D){var A,C=null!=l?l:f;A=this.texImage2D(a,n,0,T,x,b,C),E=A[0],_=A[1]}y&&(Ol(E)&&Ol(_)||pi(a))&&a.generateMipmap(n)}else if(u===ci.mipmaps){var S;n===a.TEXTURE_2D?d.forEach((function(t,i){var r;(S="data"in t?e.texImage2DData(a,n,i,T,x,b,t):e.texImage2D(a,n,i,T,x,b,t),0===i)&&(E=(r=S)[0],_=r[1])})):n===a.TEXTURE_CUBE_MAP&&p.forEach((function(t,i){t.forEach((function(t,r){var n;(S="data"in t?e.texImage2DData(a,a.TEXTURE_CUBE_MAP_POSITIVE_X+r,i,T,x,b,t):e.texImage2D(a,a.TEXTURE_CUBE_MAP_POSITIVE_X+r,i,T,x,b,t),0===i)&&(E=(n=S)[0],_=n[1])}))}))}else u===ci.compressed&&g&&0!==g.length&&(E=g[0].width,_=g[0].height,g.forEach((function(t,e){a.compressedTexImage2D(n,e,T,t.width,t.height,0,t.data)})));this.width=E,this.height=_,this.setTextureFilters(a,n,s)},i.setTextureFilters=function(t,e,i){var r=i.anisotropic,n=void 0===r?4:r,s=i.wrapS,a=void 0===s?t.CLAMP_TO_EDGE:s,o=i.wrapT,u=void 0===o?t.CLAMP_TO_EDGE:o,h=this.engine.gpuCapability;this.target===t.TEXTURE_2D&&h.setTextureAnisotropic(t,this.target,n);var c=pi(t)||Ol(this.width)&&Ol(this.height),l=i.magFilter?i.magFilter:t.NEAREST,f=i.minFilter?i.minFilter:t.NEAREST;c||f!==t.LINEAR_MIPMAP_LINEAR&&f!==t.LINEAR_MIPMAP_NEAREST&&f!==t.NEAREST_MIPMAP_LINEAR&&f!==t.NEAREST_MIPMAP_NEAREST||(f=t.LINEAR),t.texParameteri(e,t.TEXTURE_MIN_FILTER,f),t.texParameteri(e,t.TEXTURE_MAG_FILTER,l),t.texParameteri(e,t.TEXTURE_WRAP_S,c?a:t.CLAMP_TO_EDGE),t.texParameteri(e,t.TEXTURE_WRAP_T,c?u:t.CLAMP_TO_EDGE)},i.fromData=function(e){t.prototype.fromData.call(this,e);var i=e,r=this.assembleOptions(i),n=r.sourceType,s=r.sourceFrom,a=r.name,o=void 0===a?"":a;this.source=r,this.sourceType=n,this.sourceFrom=s,this.name=o,this.guid=e.id},i.texImage2D=function(t,e,i,r,n,s,a){var o,u=this,h=this.source,c=h.sourceType,l=h.minFilter,f=h.magFilter,d=h.wrapS,p=h.wrapT,m=null!=(o=this.engine.gpuCapability.detail.maxTextureSize)?o:2048,v=a;if(c!==ci.video){var y=l!==t.NEAREST||f!==t.NEAREST||d!==t.CLAMP_TO_EDGE||p!==t.CLAMP_TO_EDGE;(y=y||a.width>m||a.height>m)&&setTimeout((function(){v=u.resizeImage(a)}))}t.texImage2D(e,i,r,n,s,v);var g=[v.width,v.height];return c===ci.video?[a.videoWidth,a.videoHeight]:g},i.texImage2DData=function(t,e,i,r,n,s,a){var o=a.data,u=a.width,h=a.height,c=n===t.UNSIGNED_BYTE?new Uint8Array(o.buffer,o.byteOffset,o.byteLength/o.BYTES_PER_ELEMENT):o;return t.texImage2D(e,i,r,u,h,0,n,s,c),[u,h]},i.resizeImage=function(t,e,i){var r,n=null!=(r=this.engine.gpuCapability.detail.maxTextureSize)?r:2048;if(pi(this.pipelineContext.gl)&&t.width<n&&t.height<n)return t;var s=function(t,e,i,r){var n=t.width,s=t.height,a=Math.min(e,i||aa(n)),o=Math.min(e,r||aa(s));if(o!==s||a!==n){var u=zh.getCanvas(),h=u.getContext("2d");return u.width=a,u.height=o,null==h||h.drawImage(t,0,0,n,s,0,0,a,o),mt.warn("Image resize from "+n+"x"+s+" to "+a+"x"+o+"."),u}}(t,n,e,i);return s||t},i.reloadData=function(){var t=this;return E((function(){return O(this,(function(e){switch(e.label){case 0:return t.offloaded?[4,er().reload(t)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))()},i.offloadData=function(){if(this.initialized&&er().canOffloadTexture(this.source.sourceFrom)){var t=this.target,e=this.pipelineContext.gl;if(e&&this.textureBuffer){var i=new Uint8Array([255]);if(this.bind(),t===e.TEXTURE_2D)e.texImage2D(t,0,e.LUMINANCE,1,1,0,e.LUMINANCE,e.UNSIGNED_BYTE,i);else if(t===e.TEXTURE_CUBE_MAP)for(var r=[e.TEXTURE_CUBE_MAP_NEGATIVE_X,e.TEXTURE_CUBE_MAP_NEGATIVE_Y,e.TEXTURE_CUBE_MAP_NEGATIVE_Z,e.TEXTURE_CUBE_MAP_POSITIVE_X,e.TEXTURE_CUBE_MAP_POSITIVE_Y,e.TEXTURE_CUBE_MAP_POSITIVE_Z],n=0;n<r.length;n++)e.texImage2D(r[n],0,e.LUMINANCE,1,1,0,e.LUMINANCE,e.UNSIGNED_BYTE,i);e.generateMipmap(t),this.width=1,this.height=1}this.offloaded=!0}},i.uploadCurrentVideoFrame=function(){var t=this;return E((function(){return O(this,(function(e){return t.source.sourceType===ci.video&&t.source.video&&t.initialized?(t.update({video:t.source.video}),[2,!0]):[2,!1]}))}))()},i.updateSource=function(t){this.source=this.assembleOptions(_i({},this.source,t)),this.sourceType=this.source.sourceType,this.sourceFrom=this.source.sourceFrom,this.update(this.source)},i.restore=function(){},i.dispose=function(){this.pipelineContext&&this.textureBuffer&&this.pipelineContext.gl.deleteTexture(this.textureBuffer),this.width=0,this.height=0,this.textureBuffer=null,this.destroyed=!0,this.update=function(){mt.error("This texture has been destroyed.")},this.initialize=_t,void 0!==this.engine&&this.engine.removeTexture(this)},e}(Yi);function Ol(t){return 0==(t&t-1)&&0!==t}var Rl=function(){function t(t,e){this.ready=!1,this.disposed=!1,this.gl=t.getGLPipelineContext().gl,this.vaoExt=t.gpuCapability.vaoExt,this.vao=this.createVertexArray(e)}var e=t.prototype;return e.bind=function(){this.bindVertexArray(this.vao)},e.unbind=function(){this.bindVertexArray(null)},e.createVertexArray=function(t){var e=null;return pi(this.gl)&&(e=this.gl.createVertexArray()),!e&&this.vaoExt&&(e=this.vaoExt.createVertexArrayOES()),Pl(e,t),e},e.bindVertexArray=function(t){var e;pi(this.gl)?this.gl.bindVertexArray(t):null==(e=this.vaoExt)||e.bindVertexArrayOES(t)},e.dispose=function(){var t;pi(this.gl)?this.gl.deleteVertexArray(this.vao):null==(t=this.vaoExt)||t.deleteVertexArrayOES(this.vao)},t}(),Ml=1,Il=function(){function t(t){this.engine=t,this.textures=[],this.renderbuffers=[],this.framebuffers=[],this.destroyed=!1;var e={width:1,height:1,data:new Uint8Array([255])},i=t.getGLPipelineContext(),r=i.gl;this.gl=r,this.pipelineContext=i,this.emptyTexture2D=new Sl(t,{data:e,sourceType:ci.data,format:r.LUMINANCE,internalFormat:r.LUMINANCE,type:r.UNSIGNED_BYTE}),this.emptyTexture2D.initialize(),this.emptyTextureCube=new Sl(t,{target:r.TEXTURE_CUBE_MAP,cube:[e,e,e,e,e,e],sourceType:ci.data,format:r.LUMINANCE,internalFormat:r.LUMINANCE,type:r.UNSIGNED_BYTE}),this.emptyTextureCube.initialize(),this.name="GLGPURenderer"+Ml,Ml++}var e=t.prototype;return e.copy2=function(t,e){var i=this.gl;if(i){this.sourceFbo||(this.sourceFbo=i.createFramebuffer()),this.targetFbo||(this.targetFbo=i.createFramebuffer());var r=this.pipelineContext;r.bindFramebuffer(i.FRAMEBUFFER,this.sourceFbo),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,t.textureBuffer,0),r.bindFramebuffer(i.FRAMEBUFFER,this.targetFbo),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e.textureBuffer,0),r.bindFramebuffer(i.READ_FRAMEBUFFER,this.sourceFbo),r.bindFramebuffer(i.DRAW_FRAMEBUFFER,this.targetFbo);var n=t.getWidth()===t.getHeight()&&e.getWidth()==e.getHeight()?i.NEAREST:i.LINEAR;i.blitFramebuffer(0,0,t.getWidth(),t.getHeight(),0,0,e.getWidth(),e.getHeight(),i.COLOR_BUFFER_BIT,n),r.bindFramebuffer(i.FRAMEBUFFER,null),r.bindFramebuffer(i.READ_FRAMEBUFFER,null),r.bindFramebuffer(i.DRAW_FRAMEBUFFER,null)}},e.resetColorAttachments=function(t,e){t.bind(),t.resetColorTextures(e)},e.createGLRenderbuffer=function(t){var e=this.gl.createRenderbuffer();return e&&D(this.renderbuffers,t),e},e.resize=function(t,e){var i=this.gl;(i&&i.drawingBufferWidth!==t||i.drawingBufferHeight!==e)&&(i.canvas.width=t,i.canvas.height=e,i.viewport(0,0,t,e),this.framebuffers.forEach((function(i){var r=i.viewport;i.isCustomViewport||i.resize(r[0],r[1],t*i.viewportScale,e*i.viewportScale)})))},e.drawGeometry=function(t,e,i){if(this.gl){var r=t,n=e.shaderVariant.program;if(n){var s=n.setupAttributes(r),a=this.gl,o=r.indicesBuffer,u=r.drawStart,h=r.drawCount,c=r.mode,l=r.subMeshes;if(l&&l.length){var f,d=l[i];if(h<0)return;if(u=d.offset,o)h=null!=(f=d.indexCount)?f:0;else h=d.vertexCount}o?a.drawElements(c,h,o.type,null!=u?u:0):a.drawArrays(c,u,h),null==s||s.unbind()}}else console.warn("GLGPURenderer has not bound a gl object, unable to render geometry.")},e.createGLFramebuffer=function(t,e){var i=this.gl.createFramebuffer();if(!i)throw new Error("Failed to create WebGL framebuffer. gl isContextLost="+this.gl.isContextLost());return D(this.framebuffers,t),Pl(i,e,e),i},e.createVAO=function(t){return new Rl(this.engine,t)},e.deleteGLTexture=function(t){t.textureBuffer&&!this.destroyed&&(this.gl.deleteTexture(t.textureBuffer),k(this.textures,t),delete t.textureBuffer)},e.deleteGPUBuffer=function(t){t&&!this.destroyed&&(this.gl.deleteBuffer(t.glBuffer),delete t.glBuffer)},e.deleteGLFramebuffer=function(t){t&&!this.destroyed&&(this.gl.deleteFramebuffer(t.fbo),k(this.framebuffers,t),delete t.fbo)},e.deleteGLRenderbuffer=function(t){t&&!this.destroyed&&(this.gl.deleteRenderbuffer(t.buffer),k(this.renderbuffers,t),delete t.buffer)},e.deleteResource=function(){var t=this,e=this.gl;e&&(e.deleteFramebuffer(this.sourceFbo),e.deleteFramebuffer(this.targetFbo),this.emptyTexture2D.dispose(),this.emptyTextureCube.dispose(),this.framebuffers.forEach((function(e){return t.deleteGLFramebuffer(e)})),this.framebuffers.length=0,this.renderbuffers.forEach((function(e){return t.deleteGLRenderbuffer(e)})),this.renderbuffers.length=0,this.textures.forEach((function(e){return t.deleteGLTexture(e)})),this.textures.length=0)},e.lost=function(t){mt.error("WebGL context lost, destroying glRenderer by default to prevent memory leaks. Event target: "+t.target+"."),this.deleteResource()},e.dispose=function(){this.deleteResource(),this.emptyTexture2D=this.emptyTextureCube=this.pipelineContext=this.gpu=this.gl=null,this.destroyed=!0},Pe(t,[{key:"height",get:function(){var t;return null==(t=this.gl)?void 0:t.drawingBufferHeight}},{key:"width",get:function(){var t;return null==(t=this.gl)?void 0:t.drawingBufferWidth}},{key:"canvas",get:function(){return this.gl.canvas}},{key:"isDestroyed",get:function(){return this.destroyed}}]),t}();function Pl(t,e,i){void 0!==e&&null!==t&&(t.__SPECTOR_Metadata={name:e},t.__SPECTOR_Object_TAG?(t.__SPECTOR_Object_TAG.displayText=e,i&&(t.__SPECTOR_Object_TAG.id=i)):t.__SPECTOR_Object_TAG={displayText:e,id:""})}var Ll,Fl,Vl=function(){function t(t,e){this.pipelineContext=t,this.byteLength=0,this.destroyed=!1;var i=e.name,r=e.data,n=e.elementCount,s=e.target,a=void 0===s?fi.ARRAY_BUFFER:s,o=e.type,u=void 0===o?fi.FLOAT:o,h=e.usage,c=void 0===h?fi.STATIC_DRAW:h,l=function(t){var e,i;return null!=(i=null==(e=Nl[t])?void 0:e.BYTES_PER_ELEMENT)?i:0}(u);this.target=a,this.type=u,this.usage=c,this.glBuffer=this.createGLBuffer(i),this.bytesPerElement=l,r?this.bufferData(r):n&&this.bufferData(l*n)}var e=t.prototype;return e.createGLBuffer=function(t){var e=this.pipelineContext.gl.createBuffer();return Pl(e,t),e},e.bind=function(){this.pipelineContext.gl.bindBuffer(this.target,this.glBuffer)},e.bufferData=function(t){var e="number"==typeof t?t:t.byteLength;if(this.pipelineContext){this.byteLength=e;var i=this.pipelineContext.gl,r=this.target;i.bindBuffer(r,this.glBuffer),0===e?i.bufferData(r,1,this.usage):(i.bufferData(r,e,this.usage),"number"!=typeof t&&i.bufferSubData(r,0,t))}else this.byteLength=0},e.bufferSubData=function(t,e){if(this.pipelineContext){var i=this.pipelineContext.gl,r=this.target,n=t*this.bytesPerElement,s=n+e.byteLength;i.bindBuffer(r,this.glBuffer),s>this.byteLength&&(this.byteLength=s,i.bufferData(r,s,this.usage)),i.bufferSubData(r,n,e)}else this.byteLength=0},e.dispose=function(){this.pipelineContext.gl.deleteBuffer(this.glBuffer),this.glBuffer=null,this.destroyed=!0},e.readSubData=function(t,e){return!!pi(this.pipelineContext.gl)&&(this.pipelineContext.gl.getBufferSubData(this.target,t*this.bytesPerElement,e),!0)},Pe(t,[{key:"elementCount",get:function(){return this.byteLength/this.bytesPerElement}},{key:"isDestroyed",get:function(){return this.destroyed}}]),t}(),Nl=((Ll={})[fi.INT]=Int32Array,Ll[fi.FLOAT]=Float32Array,Ll[fi.SHORT]=Int16Array,Ll[fi.BYTE]=Int8Array,Ll[fi.UNSIGNED_BYTE]=Uint8Array,Ll[fi.UNSIGNED_INT]=Uint32Array,Ll[fi.UNSIGNED_SHORT]=Uint16Array,Ll);var Dl=((Fl={})[Uint8Array.BYTES_PER_ELEMENT]=fi.UNSIGNED_BYTE,Fl[Uint16Array.BYTES_PER_ELEMENT]=fi.UNSIGNED_SHORT,Fl[Uint32Array.BYTES_PER_ELEMENT]=fi.UNSIGNED_INT,Fl),kl=1,zl=function(t){function e(e,i){var r;return(r=t.call(this,e)||this).drawCount=0,r.buffers={},r.vaos={},r.skin={},r.initialized=!1,r.indicesReleasable=!1,r.attributesName=[],r.destroyed=!1,i&&r.processProps(i),r}Qt(e,t);var i=e.prototype;return i.getOptions=function(){return _i({},this.options)},i.initialize=function(){var t=this;if(!this.initialized){var e=this.engine;ot(e),e.addGeometry(this);var i=this.engine.getGLPipelineContext();Object.keys(this.bufferProps).forEach((function(e){t.buffers[e]=new Vl(i,t.bufferProps[e])})),this.indices&&(this.indicesBuffer=this.createIndicesBuffer(i,this.indices)),this.initialized=!0,this.flush(),this.options=void 0}},i.getAttributeBuffer=function(t){if(this.initialized){var e=this.attributes[t].dataSource;return this.buffers[e]}},i.setAttributeData=function(t,e){if(null!=this.bufferProps){var i=this.getAttributeBufferOption(t),r=this.attributes[t].dataSource;if(i){var n=i.usage,s=i.target;this.bufferProps[r]={data:e,usage:n,target:s,elementCount:e.length},this.dirtyFlags[r].discard=!0,this.dirtyFlags[r].dirty=!0}}},i.getAttributeData=function(t){if(null!=this.bufferProps){var e=this.getAttributeBufferOption(t);return e?e.data:void 0}},i.setAttributeSubData=function(t,e,i){if(null!=this.bufferProps){var r=this.getAttributeBufferOption(t);if(r&&null!=r.data){var n=e,s=e+i.length;if(r.data.length<s){var a=new i.constructor(s);a.set(r.data),r.data=a,this.dirtyFlags[t].discard=!0}else if(!this.dirtyFlags[t].discard){var o=this.dirtyFlags[t];void 0!==o.start&&(o.start=Math.min(o.start,n)),void 0!==o.end&&(o.end=Math.max(o.end,s-1))}r.data.set(i,n),this.dirtyFlags[t].dirty=!0}}},i.getIndexData=function(){return this.indices},i.setIndexData=function(t){(A(t,Uint8Array)||A(t,Uint16Array)||A(t,Uint32Array))&&(this.indices=t,this.dirtyFlags.index.discard=!0,this.dirtyFlags.index.dirty=!0)},i.setIndexSubData=function(t,e){if(this.indices){var i,r=t,n=t+e.length;if(this.indices.length<n){var s=new e.constructor(n);s.set(this.indices),this.indices=s,this.dirtyFlags.index.discard=!0}else if(!this.dirtyFlags.index.discard){var a=this.dirtyFlags.index;void 0!==a.start&&(a.start=Math.min(a.start,r)),void 0!==a.end&&(a.end=Math.max(a.end,n-1))}null==(i=this.indices)||i.set(e,r),this.dirtyFlags.index.dirty=!0}},i.getAttributeStride=function(t){var e=this.attributes[t],i=e.stride,r=e.size,n=e.type;return i||r*Ar[n]},i.getAttributeNames=function(){return this.attributesName},i.setDrawStart=function(t){this.drawStart=t},i.getDrawStart=function(){return this.drawStart},i.setDrawCount=function(t){this.drawCount=t},i.getDrawCount=function(){return this.drawCount},i.getSkinProps=function(){return this.skin},i.getAttributeBufferOption=function(t){var e=this.attributes[t];return e?this.bufferProps[e.dataSource]:void 0},i.createIndicesBuffer=function(t,e){var i=Dl[e.BYTES_PER_ELEMENT],r={data:e,target:fi.ELEMENT_ARRAY_BUFFER,type:i,name:this.name+"##index"};return new Vl(t,r)},i.flush=function(){var t=this;if(this.initialized){var e=this.attributes,i=this.bufferProps,r=this.indices;Object.keys(this.dirtyFlags).forEach((function(n){var s,a,o=t.dirtyFlags[n];if("index"==n)s=t.indicesBuffer,a=r;else{var u=e[n].dataSource;s=t.buffers[u],a=i[u].data}if((o.dirty||o.discard)&&s&&a){if(o.discard)s.bufferData(a);else if(void 0!==o.start&&void 0!==o.end){var h=o.start*a.BYTES_PER_ELEMENT+a.byteOffset,c=o.end-o.start+1,l=new a.constructor(a.buffer,h,c);s.bufferSubData(o.start,l)}o.start=Number.POSITIVE_INFINITY,o.end=0,o.dirty=o.discard=!1}})),Object.keys(this.attributesReleasable).forEach((function(r){var n=t.attributesReleasable[r],s=e[r].dataSource;i[s]&&n&&(i[s].data=void 0)})),this.indicesReleasable}},i.processProps=function(t){var e=t,i=e.drawStart,r=void 0===i?0:i,n=e.drawCount,s=e.mode,a=e.indices,o=e.name,u=void 0===o?"effectsGeometry:"+kl++:o,h=e.bufferUsage,c=void 0===h?fi.STATIC_DRAW:h;this.name=u;var l={},f=[],d={},p={},m={},v=c;this.drawStart=r,void 0!==n&&(this.drawCount=n),this.mode=isNaN(s)?fi.TRIANGLES:s,Object.keys(e.attributes).forEach((function(t){var i=e.attributes[t],r=i.size,n=i.stride,s=i.offset,a=i.normalize,o=i.type,u=void 0===o?fi.FLOAT:o,h=i.releasable,c=i.data;if(!u||"dataSource"in i||c||(c=Sr(u)),c){var y=A(c,Float32Array)?fi.FLOAT:fi.INT;l[t]={data:c,usage:v,target:fi.ARRAY_BUFFER,name:t},d[t]={size:r,stride:n,offset:s,type:null!=u?u:y,normalize:!!a,dataSource:t},m[t]=null!=h&&h,p[t]={dirty:!0,discard:!0,start:Number.POSITIVE_INFINITY,end:0}}else{var g=i.dataSource;g&&(d[t]={size:r,stride:n,offset:s,type:u,dataSource:g,normalize:!!a})}f.push(t)})),p.index={dirty:!0,discard:!0,start:Number.POSITIVE_INFINITY,end:0},this.indices=null==a?void 0:a.data,this.indicesReleasable=!0===(null==a?void 0:a.releasable),this.bufferProps=l,this.attributes=d,this.attributesName=f,this.attributesReleasable=m,this.dirtyFlags=p,this.options=e,this.initialized=!1},i.fromData=function(e){var i,r=this;if(t.prototype.fromData.call(this,e),this.subMeshes=e.subMeshes,e.buffer?i=new Uint8Array(function(t){for(var e=s(t),i=new Uint8Array(e.length),r=0;r<e.length;r++)i[r]=e.charCodeAt(r);var n=i.buffer;return n}(e.buffer)):e.binaryData&&(i=e.binaryData),i){var n=e.vertexData.vertexCount;if(this.hasSemantic(e)){var a={mode:fi.TRIANGLES,attributes:{}};if(e.vertexData.channels.forEach((function(t){var e,s=null!=(e=Ul[t.semantic])?e:t.semantic,o=r.createVertexTypedArray(t,i,n);a.attributes[s]={type:vi(t.format),size:t.dimension,data:o,normalize:t.normalize}})),e.indexFormat!==Ce.None){var o=this.createIndexTypedArray(e.indexFormat,i,e.indexOffset);a.indices={data:o},a.drawCount=o.length}else a.drawCount=n;this.processProps(a)}else{var u=e.vertexData.channels[0],h=e.vertexData.channels[1],c=e.vertexData.channels[2],l=this.createVertexTypedArray(u,i,n),f=this.createVertexTypedArray(h,i,n),d=this.createVertexTypedArray(c,i,n),p=this.createIndexTypedArray(e.indexFormat,i,e.indexOffset),m={mode:fi.TRIANGLES,attributes:{aPos:{type:vi(u.format),size:3,data:l,normalize:u.normalize},aUV:{type:vi(h.format),size:2,data:f,normalize:h.normalize},aNormal:{type:vi(c.format),size:3,data:d,normalize:c.normalize}}};m.indices={data:p},m.drawCount=p.length,this.processProps(m)}this.skin={boneNames:e.boneNames,rootBoneName:e.rootBoneName,inverseBindMatrices:e.inverseBindMatrices}}},i.dispose=function(){var t,e=this;(this.drawStart=0,this.drawCount=NaN,this.bufferProps={},this.indices=void 0,this.attributes={},this.attributesName=[],this.options=void 0,this.initialized)&&(Object.keys(this.buffers).forEach((function(t){e.buffers[t].dispose()})),this.buffers={},null==(t=this.indicesBuffer)||t.dispose(),Object.keys(this.vaos).forEach((function(t){var i;null==(i=e.vaos[t])||i.dispose(),e.vaos[t]=void 0})),this.indicesBuffer=void 0,void 0!==this.engine&&(this.engine.removeGeometry(this),this.engine=void 0));this.destroyed=!0},i.createVertexTypedArray=function(t,e,i){var r=e.buffer;switch(t.format){case Ae.Float32:return new Float32Array(r,e.byteOffset+t.offset,t.dimension*i);case Ae.Int16:return new Int16Array(r,e.byteOffset+t.offset,t.dimension*i);case Ae.Int8:return new Int8Array(r,e.byteOffset+t.offset,t.dimension*i);case Ae.UInt16:return new Uint16Array(r,e.byteOffset+t.offset,t.dimension*i);case Ae.UInt8:return new Uint8Array(r,e.byteOffset+t.offset,t.dimension*i);default:return console.error("Invalid vertex format type: "+t.format+"."),new Float32Array(r,e.byteOffset+t.offset,t.dimension*i)}},i.createIndexTypedArray=function(t,e,i){var r=e.buffer;switch(t){case Ce.UInt16:return new Uint16Array(r,e.byteOffset+i);case Ce.UInt32:return new Uint32Array(r,e.byteOffset+i);default:return console.error("Invalid index format type: "+t+"."),new Uint32Array(r,e.byteOffset+i)}},i.hasSemantic=function(t){var e=!1;return t.vertexData.channels.forEach((function(t){t.semantic&&t.semantic.length>0&&(e=!0)})),e},Pe(e,[{key:"isDestroyed",get:function(){return this.destroyed}},{key:"isInitialized",get:function(){return this.initialized}}]),e}(Cr),Ul={POSITION:"aPos",TEXCOORD0:"aUV",TEXCOORD_0:"aUV",TEXCOORD1:"aUV2",NORMAL:"aNormal",TANGENT:"aTangent",COLOR:"aColor",JOINTS:"aJoints",JOINTS_0:"aJoints",WEIGHTS:"aWeights",WEIGHTS_0:"aWeights",POSITION_BS0:"aTargetPosition0",POSITION_BS1:"aTargetPosition1",POSITION_BS2:"aTargetPosition2",POSITION_BS3:"aTargetPosition3",POSITION_BS4:"aTargetPosition4",POSITION_BS5:"aTargetPosition5",POSITION_BS6:"aTargetPosition6",POSITION_BS7:"aTargetPosition7",NORMAL_BS0:"aTargetNormal0",NORMAL_BS1:"aTargetNormal1",NORMAL_BS2:"aTargetNormal2",NORMAL_BS3:"aTargetNormal3",TANGENT_BS0:"aTargetTangent0",TANGENT_BS1:"aTargetTangent1",TANGENT_BS2:"aTargetTangent2",TANGENT_BS3:"aTargetTangent3"};var Bl,Gl,jl=function(){function t(){this.reset()}var e=t.prototype;return e.setBlendColor=function(t){var e=t[0],i=t[1],r=t[2],n=t[3];this.blendColor[0]===e&&this.blendColor[1]===i&&this.blendColor[2]===r&&this.blendColor[3]===n||(this.blendColor[0]=e,this.blendColor[1]=i,this.blendColor[2]=r,this.blendColor[3]=n)},e.setBlending=function(t){this.blending!==t&&(this.blending=t)},e.setBlendFunctionParameters=function(t){var e=t[0],i=t[1],r=t[2],n=t[3];this.blendFunctionParameters[0]===e&&this.blendFunctionParameters[1]===i&&this.blendFunctionParameters[2]===r&&this.blendFunctionParameters[3]===n||(this.blendFunctionParameters[0]=e,this.blendFunctionParameters[1]=i,this.blendFunctionParameters[2]=r,this.blendFunctionParameters[3]=n)},e.setBlendEquationParameters=function(t){var e=t[0],i=t[1];this.blendEquationParameters[0]===e&&this.blendEquationParameters[1]===i||(this.blendEquationParameters[0]=e,this.blendEquationParameters[1]=i)},e.setDepthTest=function(t){this.depthTest!==t&&(this.depthTest=t)},e.setDepthMask=function(t){this.depthMask!==t&&(this.depthMask=t)},e.setDepthRange=function(t){this.depthRange[0]===t[0]&&this.depthRange[1]===t[1]||(this.depthRange[0]=t[0],this.depthRange[1]=t[1])},e.setDepthFunc=function(t){this.depthFunc!==t&&(this.depthFunc=t)},e.setPolygonOffsetFill=function(t){this.polygonOffsetFill!==t&&(this.polygonOffsetFill=t)},e.setPolygonOffset=function(t){this.polygonOffset[0]===t[0]&&this.polygonOffset[1]===t[1]||(this.polygonOffset[0]=t[0],this.polygonOffset[1]=t[1])},e.setSampleAlphaToCoverage=function(t){this.sampleAlphaToCoverage!==t&&(this.sampleAlphaToCoverage=t)},e.setColorMask=function(t){this.colorMask[0]=t,this.colorMask[1]=t,this.colorMask[2]=t,this.colorMask[3]=t},e.setStencilTest=function(t){this.stencilTest!==t&&(this.stencilTest=t)},e.setStencilMask=function(t){this.stencilMask[0]===t[0]&&this.stencilMask[1]===t[1]||(this.stencilMask[0]=t[0],this.stencilMask[1]=t[1])},e.setStencilRef=function(t){this.stencilRef[0]===t[0]&&this.stencilRef[1]===t[1]||(this.stencilRef[0]=t[0],this.stencilRef[1]=t[1])},e.setStencilFunc=function(t){this.stencilFunc[0]===t[0]&&this.stencilFunc[1]===t[1]||(this.stencilFunc[0]=t[0],this.stencilFunc[1]=t[1])},e.setStencilOpFail=function(t){this.stencilOpFail[0]===t[0]&&this.stencilOpFail[1]===t[1]||(this.stencilOpFail[0]=t[0],this.stencilOpFail[1]=t[1])},e.setStencilOpZFail=function(t){this.stencilOpZFail[0]===t[0]&&this.stencilOpZFail[1]===t[1]||(this.stencilOpZFail[0]=t[0],this.stencilOpZFail[1]=t[1])},e.setStencilOpZPass=function(t){this.stencilOpZPass[0]===t[0]&&this.stencilOpZPass[1]===t[1]||(this.stencilOpZPass[0]=t[0],this.stencilOpZPass[1]=t[1])},e.setCulling=function(t){this.culling!==t&&(this.culling=t)},e.setFrontFace=function(t){this.frontFace!==t&&(this.frontFace=t)},e.setCullFace=function(t){this.cullFace!==t&&(this.cullFace=t)},e.reset=function(){this.blending=!1,this.blendColor=[0,0,0,0],this.blendFunctionParameters=[fi.ONE,fi.ONE_MINUS_SRC_ALPHA,fi.ONE,fi.ONE_MINUS_SRC_ALPHA],this.blendEquationParameters=[fi.FUNC_ADD,fi.FUNC_ADD],this.depthTest=!0,this.depthMask=!0,this.depthRange=[0,1],this.depthFunc=fi.LESS,this.polygonOffset=[0,0],this.polygonOffsetFill=!1,this.sampleAlphaToCoverage=!1,this.colorMask=[!0,!0,!0,!0],this.stencilTest=!1,this.stencilMask=[255,255],this.stencilRef=[0,0],this.stencilFunc=[fi.ALWAYS,fi.ALWAYS],this.stencilOpFail=[fi.KEEP,fi.KEEP],this.stencilOpZFail=[fi.KEEP,fi.KEEP],this.stencilOpZPass=[fi.KEEP,fi.KEEP],this.culling=!1,this.frontFace=fi.CCW,this.cullFace=fi.FRONT},e.apply=function(t){if(t.toggle(fi.SAMPLE_ALPHA_TO_COVERAGE,this.sampleAlphaToCoverage),t.toggle(fi.BLEND,this.blending),t.toggle(fi.DEPTH_TEST,this.depthTest),t.toggle(fi.STENCIL_TEST,this.stencilTest),t.toggle(fi.CULL_FACE,this.culling),t.toggle(fi.POLYGON_OFFSET_FILL,this.polygonOffsetFill),this.stencilTest&&(t.stencilMaskSeparate(fi.BACK,this.stencilMask[1]),t.stencilMaskSeparate(fi.FRONT,this.stencilMask[0]),t.stencilFuncSeparate(fi.BACK,this.stencilFunc[0],this.stencilRef[0],this.stencilMask[0]),t.stencilFuncSeparate(fi.FRONT,this.stencilFunc[1],this.stencilRef[1],this.stencilMask[1]),t.stencilOpSeparate(fi.BACK,this.stencilOpFail[0],this.stencilOpZFail[0],this.stencilOpZPass[0]),t.stencilOpSeparate(fi.FRONT,this.stencilOpFail[1],this.stencilOpZFail[1],this.stencilOpZPass[1])),this.blending){var e=this,i=e.blendColor,r=e.blendEquationParameters,n=e.blendFunctionParameters;t.blendColor(i[0],i[1],i[2],i[3]),t.blendEquationSeparate(r[0],r[1]),t.blendFuncSeparate(n[0],n[1],n[2],n[3])}t.colorMask(this.colorMask[0],this.colorMask[1],this.colorMask[2],this.colorMask[3]),this.depthTest&&(t.depthMask(this.depthMask),t.depthFunc(this.depthFunc),t.depthRange(this.depthRange[0],this.depthRange[1])),this.culling&&(t.cullFace(this.cullFace),t.frontFace(this.frontFace)),this.polygonOffsetFill&&t.polygonOffset(this.polygonOffset[0],this.polygonOffset[1])},t}(),Xl=Je,Hl=ni,Yl=function(t){function e(e,i){var r;return(r=t.call(this,e,i)||this).floats={},r.ints={},r.vector2s={},r.vector3s={},r.vector4s={},r.colors={},r.quaternions={},r.matrices={},r.matrice3s={},r.textures={},r.floatArrays={},r.vector4Arrays={},r.matrixArrays={},r.samplers=[],r.uniforms=[],r.uniformDirty=!0,r.macrosDirty=!0,r.glMaterialState=new jl,i&&(r.shader=new dr(e),r.shader.shaderData=_i({},i.shader,{id:wt(),dataType:_e.Shader})),r}Qt(e,t);var i=e.prototype;return i.enableMacro=function(t,e){this.isMacroEnabled(t)&&this.enabledMacros[t]===e||(this.enabledMacros[t]=null==e||e,this.macrosDirty=!0)},i.disableMacro=function(t){this.isMacroEnabled(t)&&(delete this.enabledMacros[t],this.macrosDirty=!0)},i.isMacroEnabled=function(t){return void 0!==this.enabledMacros[t]},i.initialize=function(){var t=this,e=this.engine;this.createShaderVariant(),this.shaderVariant.initialize(),this.initialized||(e.addMaterial(this),Object.keys(this.textures).forEach((function(e){var i=t.textures[e];xt(i.initialize)?i.initialize():mt.error("Failed to initialize texture: "+JSON.stringify(i)+". Ensure the texture conforms to the expected format.")})),this.initialized=!0)},i.createShaderVariant=function(){(this.shaderDirty||this.macrosDirty)&&(this.shaderVariant=this.shader.createVariant(this.enabledMacros),this.macrosDirty=!1,this.shaderDirty=!1,this.uniformDirty=!0)},i.setupStates=function(t){this.glMaterialState.apply(t)},i.use=function(t,e){var i=t.engine.getGLPipelineContext(),r=this.shaderVariant;if(r.program){var n;if(r.program.bind(),this.setupStates(i),e){for(var s,a=w(e.uniforms);!(s=a()).done;)n=s.value,this.checkUniform(n);for(var o,u=w(e.samplers);!(o=u()).done;)n=o.value,this.samplers.includes(n)||(this.samplers.push(n),this.uniformDirty=!0)}if(this.uniformDirty&&(r.fillShaderInformation(this.uniforms,this.samplers),this.uniformDirty=!1),e){for(n in e.floats)r.setFloat(n,e.floats[n]);for(n in e.ints)r.setInt(n,e.ints[n]);for(n in e.vector4s)r.setVector4(n,e.vector4s[n]);for(n in e.vector3s)r.setVector3(n,e.vector3s[n]);for(n in e.matrices)r.setMatrix(n,e.matrices[n])}for(n in this.textures)this.textures[n].textureBuffer||this.textures[n].initialize();for(n in this.floats)r.setFloat(n,this.floats[n]);for(n in this.ints)r.setInt(n,this.ints[n]);for(n in this.floatArrays)r.setFloats(n,this.floatArrays[n]);for(n in this.textures)r.setTexture(n,this.textures[n]);for(n in this.vector2s)r.setVector2(n,this.vector2s[n]);for(n in this.vector3s)r.setVector3(n,this.vector3s[n]);for(n in this.vector4s)r.setVector4(n,this.vector4s[n]);for(n in this.colors)r.setColor(n,this.colors[n]);for(n in this.quaternions)r.setQuaternion(n,this.quaternions[n]);for(n in this.matrices)r.setMatrix(n,this.matrices[n]);for(n in this.matrice3s)r.setMatrix3(n,this.matrice3s[n]);for(n in this.vector4Arrays)r.setVector4Array(n,this.vector4Arrays[n]);for(n in this.matrixArrays)r.setMatrixArray(n,this.matrixArrays[n])}else{var h;null==(h=this.engine)||h.renderErrors.add(new Error("Shader program is not initialized."))}},i.getFloat=function(t){return this.floats[t]},i.setFloat=function(t,e){this.checkUniform(t),this.floats[t]=e},i.getInt=function(t){return this.ints[t]},i.setInt=function(t,e){this.checkUniform(t),this.ints[t]=e},i.getFloats=function(t){return this.floatArrays[t]},i.setFloats=function(t,e){this.checkUniform(t),this.floatArrays[t]=e},i.getVector2=function(t){return this.vector2s[t]},i.setVector2=function(t,e){this.checkUniform(t),this.vector2s[t]=e},i.getVector3=function(t){return this.vector3s[t]},i.setVector3=function(t,e){this.checkUniform(t),this.vector3s[t]=e},i.getVector4=function(t){return this.vector4s[t]},i.setVector4=function(t,e){this.checkUniform(t),this.vector4s[t]=e},i.getColor=function(t){return this.colors[t]},i.setColor=function(t,e){this.checkUniform(t),this.colors[t]=e},i.getQuaternion=function(t){return this.quaternions[t]},i.setQuaternion=function(t,e){this.checkUniform(t),this.quaternions[t]=e},i.getMatrix=function(t){return this.matrices[t]},i.setMatrix=function(t,e){this.checkUniform(t),this.matrices[t]=e},i.setMatrix3=function(t,e){this.checkUniform(t),this.matrice3s[t]=e},i.getVector4Array=function(t){return this.vector4Arrays[t]},i.setVector4Array=function(t,e){this.checkUniform(t),this.vector4Arrays[t]=[];for(var i,r=w(e);!(i=r()).done;){var n=i.value;this.vector4Arrays[t].push(n.x,n.y,n.z,n.w)}},i.getMatrixArray=function(t){return this.matrixArrays[t]},i.setMatrixArray=function(t,e){this.checkUniform(t),this.matrixArrays[t]=[];for(var i,r=w(e);!(i=r()).done;)for(var n=i.value,s=0;s<16;s++)this.matrixArrays[t].push(n.elements[s])},i.setMatrixNumberArray=function(t,e){this.checkUniform(t),this.matrixArrays[t]=e},i.getTexture=function(t){return this.textures[t]},i.setTexture=function(t,e){this.samplers.includes(t)||(this.samplers.push(t),this.uniformDirty=!0),this.textures[t]=e},i.hasUniform=function(t){return this.uniforms.includes(t)||this.samplers.includes(t)},i.clone=function(t){var i=t||this.props,r=this.engine;ot(r);var n=new e(r,i);return n.glMaterialState=Object.assign(new jl,n.glMaterialState),n.floats=this.floats,n.ints=this.ints,n.vector2s=this.vector2s,n.vector3s=this.vector3s,n.vector4s=this.vector4s,n.colors=this.colors,n.quaternions=this.quaternions,n.matrices=this.matrices,n.textures=this.textures,n.floatArrays=this.floatArrays,n.vector4Arrays=this.vector4Arrays,n.matrixArrays=this.matrixArrays,n.samplers=this.samplers,n.uniforms=this.uniforms,n.uniformDirty=!0,n},i.fromData=function(e){t.prototype.fromData.call(this,e),this.uniforms=[],this.samplers=[],this.textures={},this.floats={},this.ints={},this.floatArrays={},this.vector4s={};var i=_i({},e);void 0!==e.stringTags.RenderType&&(this.blending=e.stringTags.RenderType===Wt.Transparent),void 0!==e.floats.ZTest&&(this.depthTest=0!==e.floats.ZTest),void 0!==e.floats.ZWrite&&(this.depthMask=0!==e.floats.ZWrite);var r,n,s=e.stringTags.RenderFace;for(r in s===Zt.Front?(this.culling=!0,this.cullFace=fi.BACK):s===Zt.Back?(this.culling=!0,this.cullFace=fi.FRONT):this.culling=!1,i.floats)this.setFloat(r,i.floats[r]);for(r in i.ints)this.setInt(r,i.ints[r]);for(r in i.vector4s){var a=i.vector4s[r];this.setVector4(r,new Je(a.x,a.y,a.z,a.w))}for(r in i.colors){var o=i.colors[r];this.setColor(r,new ii(o.r,o.g,o.b,o.a))}for(r in i.textures){var u=i.textures[r],h=this.engine.findObject(u.texture);this.setTexture(r,h);var c=u.offset,l=u.scale;c&&l&&this.setVector4(r+"_ST",new Xl(l.x,l.y,c.x,c.y))}if(e.shader){var f=this.engine.findObject(e.shader);f&&(this.shader=f,this.shaderSource=f.shaderData)}this.stringTags=null!=(n=e.stringTags)?n:{},this.initialized=!1},i.toData=function(){var t=this.defination;for(var e in this.shader&&(t.shader=this.shader),t.floats={},t.ints={},t.vector4s={},t.colors={},t.textures={},t.dataType=_e.Material,t.stringTags=this.stringTags,this.floats)t.floats[e]=this.floats[e];for(var i in this.ints)t.ints[i]=this.ints[i];for(var r in this.vector4s)t.vector4s[r]=this.vector4s[r];for(var n in this.colors)t.colors[n]=this.colors[n];for(var s in this.textures){t.textures[s]||(t.textures[s]={texture:this.textures[s]});var a=t.textures[s],o=this.getVector4(s+"_ST");o&&(a.scale={x:o.x,y:o.y},a.offset={x:o.z,y:o.w},delete t.vector4s[s+"_ST"])}return t},i.cloneUniforms=function(t){var e,i=t;for(e in i.floats)this.setFloat(e,i.floats[e]);for(e in i.ints)this.setInt(e,i.ints[e]);for(e in i.floatArrays)this.setFloats(e,i.floatArrays[e]);for(e in i.textures)this.setTexture(e,i.textures[e]);for(e in i.vector2s)this.setVector2(e,i.vector2s[e]);for(e in i.vector3s)this.setVector3(e,i.vector3s[e]);for(e in i.vector4s)this.setVector4(e,i.vector4s[e]);for(e in i.colors)this.setColor(e,i.colors[e]);for(e in i.quaternions)this.setQuaternion(e,i.quaternions[e]);for(e in i.matrices)this.setMatrix(e,i.matrices[e]);for(e in i.vector4Arrays){for(var r=[],n=0;n<i.vector4Arrays[e].length;n+=4)r.push(new Xl(i.vector4Arrays[e][n],i.vector4Arrays[e][n+1],i.vector4Arrays[e][n+2],i.vector4Arrays[e][n+3]));this.setVector4Array(e,r)}for(e in i.matrixArrays){for(var s=[],a=0;a<i.matrixArrays[e].length;a+=16){for(var o=Hl.fromIdentity(),u=0;u<16;u++)o.elements[u]=i.matrixArrays[e][a+u];s.push(o)}this.setMatrixArray(e,s)}},i.checkUniform=function(t){this.uniforms.includes(t)||(this.uniforms.push(t),this.uniformDirty=!0)},i.dispose=function(t){var e,i=this;this.destroyed||(null==(e=this.shaderVariant)||e.dispose(),(null==t?void 0:t.textures)!==pt.keep&&Object.keys(this.textures).forEach((function(t){var e=i.textures[t];e!==i.engine.emptyTexture&&e.dispose()})),this.shaderSource=null,this.uniformSemantics={},this.floats={},this.ints={},this.vector2s={},this.vector3s={},this.vector4s={},this.quaternions={},this.matrices={},this.matrice3s={},this.textures={},this.floatArrays={},this.vector4Arrays={},this.matrixArrays={},this.samplers=[],this.uniforms=[],this.initialize=_t,this.destroyed=!0,void 0!==this.engine&&this.engine.removeMaterial(this))},Pe(e,[{key:"blending",get:function(){return this.glMaterialState.blending},set:function(t){void 0!==t&&this.glMaterialState.setBlending(t)}},{key:"blendColor",get:function(){return this.glMaterialState.blendColor},set:function(t){t&&this.glMaterialState.setBlendColor(t)}},{key:"blendFunction",get:function(){return this.glMaterialState.blendFunctionParameters},set:function(t){t&&this.glMaterialState.setBlendFunctionParameters(t)}},{key:"blendEquation",get:function(){return this.glMaterialState.blendEquationParameters},set:function(t){t&&this.glMaterialState.setBlendEquationParameters(t)}},{key:"depthTest",get:function(){return this.glMaterialState.depthTest},set:function(t){void 0!==t&&this.glMaterialState.setDepthTest(t)}},{key:"depthMask",get:function(){return this.glMaterialState.depthMask},set:function(t){void 0!==t&&this.glMaterialState.setDepthMask(t)}},{key:"depthRange",get:function(){return this.glMaterialState.depthRange},set:function(t){t&&this.glMaterialState.setDepthRange(t)}},{key:"depthFunc",get:function(){return this.glMaterialState.depthFunc},set:function(t){void 0!==t&&this.glMaterialState.setDepthFunc(t)}},{key:"polygonOffsetFill",get:function(){return this.glMaterialState.polygonOffsetFill},set:function(t){void 0!==t&&this.glMaterialState.setPolygonOffsetFill(t)}},{key:"polygonOffset",get:function(){return this.glMaterialState.polygonOffset},set:function(t){t&&this.glMaterialState.setPolygonOffset(t)}},{key:"sampleAlphaToCoverage",get:function(){return this.glMaterialState.sampleAlphaToCoverage},set:function(t){void 0!==t&&this.glMaterialState.setSampleAlphaToCoverage(t)}},{key:"colorMask",get:function(){return this.glMaterialState.colorMask[0]},set:function(t){this.glMaterialState.setColorMask(t)}},{key:"stencilTest",get:function(){return this.glMaterialState.stencilTest},set:function(t){void 0!==t&&this.glMaterialState.setStencilTest(t)}},{key:"stencilMask",get:function(){return this.glMaterialState.stencilMask},set:function(t){t&&this.glMaterialState.setStencilMask(t)}},{key:"stencilRef",get:function(){return this.glMaterialState.stencilRef},set:function(t){t&&this.glMaterialState.setStencilRef(t)}},{key:"stencilFunc",get:function(){return this.glMaterialState.stencilFunc},set:function(t){t&&this.glMaterialState.setStencilFunc(t)}},{key:"stencilOpFail",get:function(){return this.glMaterialState.stencilOpFail},set:function(t){t&&this.glMaterialState.setStencilOpFail(t)}},{key:"stencilOpZFail",get:function(){return this.glMaterialState.stencilOpZFail},set:function(t){t&&this.glMaterialState.setStencilOpZFail(t)}},{key:"stencilOpZPass",get:function(){return this.glMaterialState.stencilOpZPass},set:function(t){t&&this.glMaterialState.setStencilOpZPass(t)}},{key:"culling",get:function(){return this.glMaterialState.culling},set:function(t){void 0!==t&&this.glMaterialState.setCulling(t)}},{key:"frontFace",get:function(){return this.glMaterialState.frontFace},set:function(t){void 0!==t&&this.glMaterialState.setFrontFace(t)}},{key:"cullFace",get:function(){return this.glMaterialState.cullFace},set:function(t){void 0!==t&&this.glMaterialState.setCullFace(t)}},{key:"isDestroyed",get:function(){return this.destroyed}}]),e}(cr),Wl=function(){function t(t){if(this.renderer=t,1===t.engine.gpuCapability.level){this.copyRenderPass=this.createCopyRenderPass().initialize(t);var e=this.copyRenderPass.meshes[0].material.shaderSource;t.pipelineContext.shaderLibrary.addShader(e)}}var e=t.prototype;return e.resetColorAttachments=function(t,e){this.renderer&&t.resetColorAttachments(e)},e.copyTexture=function(t,e){this.renderer&&(t.initialize(),e.initialize(),e.updateSource({sourceType:ci.framebuffer,data:{width:e.getWidth()||t.getWidth(),height:e.getHeight()||t.getHeight()}}),2===this.renderer.engine.gpuCapability.level?this.copy2(t,e):this.copy1(t,e))},e.copy2=function(t,e){var i=this.renderer.getFramebuffer();this.renderer.glRenderer.copy2(t,e),this.renderer.setFramebuffer(i)},e.copy1=function(t,e){var i=this.copyRenderPass;if(i){var r=this.renderer;if(r){var n=i.framebuffer;n.viewport[2]=e.getWidth()||t.getWidth(),n.viewport[3]=e.getHeight()||t.getHeight(),r.glRenderer.resetColorAttachments(n,[e]),i.meshes[0].material.setTexture("uTex",t),r.renderRenderPass(i)}}},e.createCopyRenderPass=function(){var t="mri-copy-mesh",e={texture:{format:fi.RGBA}},i=this.renderer.engine,r=new zl(i,{name:t,mode:fi.TRIANGLE_STRIP,attributes:{aPos:{type:fi.FLOAT,size:2,data:new Float32Array([-1,1,-1,-1,1,1,1,-1])}},drawCount:4}),n=i.gpuCapability.level,s=new Yl(i,{name:t,shader:{cacheId:"$mri-internal-copy",name:t,vertex:"\nprecision highp float;\nattribute vec2 aPos;\nvarying vec2 vTex;\nvoid main(){\n gl_Position = vec4(aPos,0.,1.0);\n vTex = (aPos + vec2(1.))/2.;\n}",fragment:"\nprecision highp float;\nvarying vec2 vTex;\nuniform sampler2D uTex;\nvoid main(){\n gl_FragColor = texture2D(uTex,vTex);\n}",glslVersion:2===n?ur.GLSL3:ur.GLSL1}});s.blending=!1,s.depthTest=!1,s.culling=!1;var a=new Dr(i,{name:t,geometry:r,material:s,priority:0});return new Zl(this.renderer,{name:"mri-copy-rp",clearAction:{colorAction:hi.whatever},attachments:[e],meshes:[a]})},e.dispose=function(){var t;this.renderer&&(null==(t=this.copyRenderPass)||t.dispose(),this.renderer=void 0)},t}(),Zl=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.configure=function(t){this.currentFramebuffer=t.getFramebuffer(),t.setFramebuffer(this.framebuffer)},i.execute=function(t){this.clearAction&&t.clear(this.clearAction),t.renderMeshes(this.meshes),this.storeAction&&t.clear(this.storeAction),t.setFramebuffer(this.currentFramebuffer)},e}(Xr),ql=function(){function t(t,e,i){var r=this;void 0===e&&(e="webgl"),void 0===i&&(i={}),this.canvas=t,this.glType=e,this.restoreHandlers=[],this.lostHandlers=[],ot(t),this.gl=si(t,e,i),this.contextLostListener=function(t){for(var e,i,n=w(r.lostHandlers);!(i=n()).done;){i.value.lost(t)}null==(e=r.canvas)||e.removeEventListener("webglcontextlost",r.contextLostListener)},this.contextRestoredListener=function(t){for(var e,i,n=w(r.restoreHandlers);!(i=n()).done;){i.value.restore()}null==(e=r.canvas)||e.addEventListener("webglcontextlost",r.contextLostListener)},t.addEventListener("webglcontextlost",this.contextLostListener),t.addEventListener("webglcontextrestored",this.contextRestoredListener)}var e=t.prototype;return e.dispose=function(){this.canvas&&(this.canvas.removeEventListener("webglcontextlost",this.contextLostListener),this.canvas.removeEventListener("webglcontextrestored",this.contextRestoredListener)),this.gl=null,this.canvas=null},e.addLostHandler=function(t){this.lostHandlers.push(t)},e.removeLostHandler=function(t){var e=this.lostHandlers.indexOf(t);e>-1&&this.lostHandlers.splice(e,1)},e.addRestoreHandler=function(t){this.restoreHandlers.push(t)},e.removeRestoreHandler=function(t){var e=this.restoreHandlers.indexOf(t);e>-1&&this.restoreHandlers.splice(e,1)},t}(),Kl=function(t){function e(e){var i;return(i=t.call(this)||this).gpuCapability=new Sn(e),i}Qt(e,t);var i=e.prototype;return i.dispose=function(){this.isDestroyed||t.prototype.dispose.call(this)},i.getGLRenderer=function(){return this.renderer},i.getGLRendererInternal=function(){return this.getGLRenderer().glRenderer},i.getGLPipelineContext=function(){return this.getGLRenderer().pipelineContext},e}(bl),Ql=function(t){function e(e,i){var r;return(r=t.call(this,e)||this).initialized=!1,void 0!==i&&r.initialize(i),r}Qt(e,t);var i=e.prototype;return i.initialize=function(t){this.initialized||(this.initialized=!0,this.renderer=t,this.buffer=t.createGLRenderbuffer(this))},i.setSize=function(t,e){if(this.initialized){if(this.renderer&&(t!==this.size[0]||e!==this.size[1])){var i=this.renderer,r=i.gl;i.pipelineContext.bindRenderbuffer(r.RENDERBUFFER,this.buffer),t&&e?r.renderbufferStorage(r.RENDERBUFFER,this.format,this.size[0]=t,this.size[1]=e):mt.error("Invalid render buffer size: "+t+"x"+e+".")}}else mt.error("Can't set size for uninitialized render buffer.")},i.dispose=function(){this.renderer&&(this.renderer.deleteGLRenderbuffer(this),this.renderer=null,this.buffer=null),this.destroyed=!0,this.initialize=_t},e}(An),Jl=1,$l=function(t){function e(e,i){var r;(r=t.call(this)||this).attachmentTextures=[];var n,s=e.depthStencilAttachment,a=e.viewport,o=e.isCustomViewport,u=e.storeAction,h=e.viewportScale,c=void 0===h?1:h,l=e.name,f=void 0===l?"GLFramebuffer"+Jl++:l;return r.renderer=i,r.engine=i.engine,r.depthStencilStorageType=null!=(n=null==s?void 0:s.storageType)?n:Ir.none,r.viewport=a,r.isCustomViewport=!!o,r.viewportScale=c,r.name=f,r.storeAction=u,r.updateProps(e),r}Qt(e,t);var i=e.prototype;return i.getDepthTexture=function(){return this.depthTexture},i.getStencilTexture=function(){return this.stencilTexture},i.getColorTextures=function(){return this.colorTextures},i.updateAttachmentTextures=function(){var t=this;this.attachmentTextures.length=0,this.colorTextures.forEach((function(e){e.initialize(),D(t.attachmentTextures,e.textureBuffer)})),this.stencilTexture&&D(this.attachmentTextures,this.stencilTexture.textureBuffer),this.depthTexture&&D(this.attachmentTextures,this.depthTexture.textureBuffer)},i.updateProps=function(t){var e,i,r=this.renderer,n=this.engine.gpuCapability,s=null!=(i=t.depthStencilAttachment)?i:{storageType:Ir.none},a=t.attachments.length>0,o=!0;if(this.externalStorage=!1,t.attachments.length>1&&!n.detail.drawBuffers)throw new Error("Multiple color attachments not support.");var u=null==(e=t.depthStencilAttachment)?void 0:e.texture,h=n.detail.readableDepthStencilTextures,c=s.storageType,l=s.storage;if(this.colorTextures=t.attachments.slice(),!a&&c!==Ir.none)throw new Error("Use depth stencil attachment without color attachments.");switch(a&&(this.fbo=r.glRenderer.createGLFramebuffer(this,this.name)),c){case Ir.depth_stencil_opaque:if(l){if(!A(l,Ql))throw new Error("Invalid depth stencil attachment storage.");this.depthStencilRenderbuffer=l,this.externalStorage=!0}else this.depthStencilRenderbuffer=new Ql({format:fi.DEPTH_STENCIL,attachment:fi.DEPTH_STENCIL_ATTACHMENT,storageType:c},r.glRenderer);o=!1;break;case Ir.depth_16_opaque:if(l){if(!A(l,Ql))throw new Error("Invalid depth attachment storage.");this.depthStencilRenderbuffer=l,this.externalStorage=!0}else this.depthStencilRenderbuffer=new Ql({attachment:fi.DEPTH_ATTACHMENT,format:fi.DEPTH_COMPONENT16,storageType:c},r.glRenderer);break;case Ir.stencil_8_opaque:if(l){if(!A(l,Ql))throw new Error("Invalid stencil attachment storage.");this.depthStencilRenderbuffer=l,this.externalStorage=!0}else this.depthStencilRenderbuffer=new Ql({attachment:fi.STENCIL_ATTACHMENT,format:fi.STENCIL_INDEX8,storageType:c},r.glRenderer);break;case Ir.depth_16_texture:if(!h)throw new Error("Depth texture is not support in framebuffer.");this.depthTexture=null!=u?u:new Sl(this.engine,{sourceType:ci.framebuffer,format:fi.DEPTH_COMPONENT,internalFormat:n.internalFormatDepth16,type:fi.UNSIGNED_SHORT,name:this.name+"##depthTex"}),this.depthTexture.initialize();break;case Ir.depth_24_stencil_8_texture:if(!h)throw new Error("Depth stencil texture is not support in framebuffer.");this.depthTexture=this.stencilTexture=null!=u?u:new Sl(this.engine,{sourceType:ci.framebuffer,format:fi.DEPTH_STENCIL,internalFormat:n.internalFormatDepth24_stencil8,type:n.UNSIGNED_INT_24_8,name:this.name+"##dpthStclTex"}),this.depthTexture.initialize(),o=!0}this.storeInvalidAttachments=this.getStoreAttachments(this.storeAction,o),this.updateAttachmentTextures()},i.getStoreAttachments=function(t,e){var i=this.renderer.glRenderer.gl,r=this.colorTextures.length;if(t&&pi(i)&&r>0){var n=[];if(t.depthAction===Pr.clear&&this.depthStorage&&D(n,e?i.DEPTH_ATTACHMENT:i.DEPTH_STENCIL_ATTACHMENT),t.stencilAction===Pr.clear&&this.stencilStorage&&D(n,e?i.STENCIL_ATTACHMENT:i.DEPTH_STENCIL_ATTACHMENT),t.colorAction===Pr.clear)for(var s=0;s<r;s++)D(n,i["COLOR_ATTACHMENT"+s]);return n}},i.unbind=function(){var t=this.storeInvalidAttachments;if(null==t?void 0:t.length){var e=this.renderer.glRenderer.gl;pi(e)&&e.invalidateFramebuffer(e.FRAMEBUFFER,t)}this.renderer.pipelineContext.bindSystemFramebuffer()},i.bind=function(){var t=this;if(this.fbo){var e=this.renderer.glRenderer.gl,i=this.renderer.pipelineContext,r=this.viewport,n=r[0],s=r[1],a=r[2],o=r[3];i.bindFramebuffer(e.FRAMEBUFFER,this.fbo),i.viewport(n,s,a,o);var u=this.renderer.glRenderer.emptyTexture2D.textureBuffer;Object.keys(i.textureUnitDict).forEach((function(e){var r=i.textureUnitDict[e];r&&r!==u&&t.attachmentTextures.includes(r)&&(i.activeTexture(+e),t.renderer.glRenderer.emptyTexture2D.bind())}));for(var h=0;h<4;h++)i.activeTexture(e.TEXTURE0+h),this.renderer.glRenderer.emptyTexture2D.bind();if(!this.ready){var c=this,l=c.depthStencilRenderbuffer,f=c.depthTexture,d=c.stencilTexture;if(i.activeTexture(e.TEXTURE0),l)l.setSize(a,o),e.framebufferRenderbuffer(e.FRAMEBUFFER,l.attachment,e.RENDERBUFFER,l.buffer);else if(f){f.source.data={width:a,height:o},f.update({data:{width:a,height:o,data:new Uint16Array(0)}});var p=f&&d?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.framebufferTexture2D(e.FRAMEBUFFER,p,e.TEXTURE_2D,f.textureBuffer,0)}this.resetColorTextures(this.colorTextures);var m=e.checkFramebufferStatus(e.FRAMEBUFFER);if(m!==e.FRAMEBUFFER_COMPLETE)throw new Error("Framebuffer failed. gl status="+m+", gl error="+e.getError()+", gl isContextLost="+e.isContextLost()+".");this.ready=!0}}},i.resetColorTextures=function(t){var e=t,i=this.renderer.glRenderer.gl,r=this.engine.gpuCapability,n=this.viewport,s=[];if(e){for(var a,o=w(e);!(a=o()).done;){a.value.initialize()}this.colorTextures=e.slice()}this.renderer.pipelineContext.activeTexture(i.TEXTURE0),this.colorTextures.forEach((function(t,e){var a={width:n[2],height:n[3],data:new Uint8Array(0)};t.update({data:a}),r.framebufferTexture2D(i,i.FRAMEBUFFER,e,i.TEXTURE_2D,t.textureBuffer),s.push(!0)})),r.drawBuffers(i,s),this.updateAttachmentTextures()},i.resize=function(t,e,i,r){var n=this.viewport,s=n[0],a=n[1],o=n[2],u=n[3];s===t&&a===e&&o===i&&u===r||(this.viewport=[t,e,i,r],this.ready=!1,this.bind())},i.dispose=function(t){if(this.renderer){this.renderer.glRenderer.deleteGLFramebuffer(this),delete this.fbo;var e,i,r=(null==t?void 0:t.depthStencilAttachment)?t.depthStencilAttachment:Br.force;if(r===Br.force||r===Br.keepExternal&&!this.externalStorage)null==(e=this.depthStencilRenderbuffer)||e.dispose(),null==(i=this.depthTexture)||i.dispose();this.renderer=this.stencilRenderbuffer=this.depthStencilRenderbuffer=null}},Pe(e,[{key:"stencilStorage",get:function(){if(this.depthStencilStorageType!==Ir.depth_16_opaque)return this.depthStencilRenderbuffer}},{key:"depthStorage",get:function(){if(this.depthStencilStorageType!==Ir.stencil_8_opaque)return this.depthStencilRenderbuffer}}]),e}(Mn),tf=((Bl={})[fi.FLOAT]=1,Bl[fi.INT]=1,Bl[fi.UNSIGNED_INT]=1,Bl[fi.SHORT]=1,Bl[fi.BOOL]=1,Bl[fi.UNSIGNED_SHORT]=1,Bl[fi.FLOAT_VEC2]=2,Bl[fi.FLOAT_VEC3]=3,Bl[fi.FLOAT_VEC4]=4,Bl[fi.FLOAT_MAT2]=4,Bl[fi.FLOAT_MAT3]=9,Bl[fi.FLOAT_MAT4]=16,Bl[fi.FLOAT_MAT2x3]=6,Bl[fi.FLOAT_MAT2x4]=8,Bl[fi.FLOAT_MAT4x3]=12,Bl[fi.FLOAT_MAT4x2]=8,Bl[fi.FLOAT_MAT3x4]=12,Bl[fi.FLOAT_MAT3x2]=6,Bl[fi.INT_VEC2]=2,Bl[fi.INT_VEC3]=3,Bl[fi.INT_VEC4]=4,Bl[fi.UNSIGNED_INT_VEC2]=2,Bl[fi.UNSIGNED_INT_VEC3]=3,Bl[fi.UNSIGNED_INT_VEC4]=4,Bl[fi.BOOL_VEC2]=2,Bl[fi.BOOL_VEC3]=3,Bl[fi.BOOL_VEC4]=4,Bl),ef=af(Float32Array),rf=af(Int32Array),nf=af(Uint8Array);function sf(t){return function(e,i,r,n){var s={start:i[1],dirty:!0};if(i[2]>1){var a=e;if(a.length){for(var o=n[1]||a.length,u=i[4]/t.BYTES_PER_ELEMENT,h=s.buffer=new t(o*u),c=n[0]||0,l=0;l<o;l++)h[l*u]=a[l+c];s.start+=c*u}}else s.buffer=new t([e]);return s}}function af(t){return function(e,i,r,n){for(var s=i[8],a=i[2],o=i[5],u=1===a?s:i[4],h=o?u/o:1,c=u/t.BYTES_PER_ELEMENT/h,l=s/t.BYTES_PER_ELEMENT/c,f=tf[i[0]],d=f/h,p=(n[0]||0)*f,m=n[1]?h*n[1]:l,v=new t(c*m),y={start:i[1]+u*(n[0]||0),dirty:!0,buffer:v},g=0,x=0,b=p;g<m;g++){for(var T=0;T<d;T++)v[x+T]=e[b+T];x+=c,b+=d}return y}}function of(t,e){for(var i=function(i){var s=t.getActiveUniformBlockName(e,i);ot(s);var a={index:t.getUniformBlockIndex(e,s),usedByVertexShader:t.getActiveUniformBlockParameter(e,i,t.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER),usedByFragmentShader:t.getActiveUniformBlockParameter(e,i,t.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER),size:t.getActiveUniformBlockParameter(e,i,t.UNIFORM_BLOCK_DATA_SIZE),uniformIndices:t.getActiveUniformBlockParameter(e,i,t.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES),used:!1,uniforms:{},name:s,id:""};a.used=a.usedByVertexShader||a.usedByFragmentShader,r[i]=a;for(var o=a.uniformIndices,u=[],h=0;h<o.length;h++){var c=t.getActiveUniform(e,o[h]).name.replace("[0]","");a.uniforms[c]=[0,0,0,0,0,0,0,h,0],u[h]=c,n.push(c)}[t.UNIFORM_TYPE,t.UNIFORM_OFFSET,t.UNIFORM_SIZE,t.UNIFORM_BLOCK_INDEX,t.UNIFORM_ARRAY_STRIDE,t.UNIFORM_MATRIX_STRIDE,t.UNIFORM_IS_ROW_MAJOR].forEach((function(i,r){t.getActiveUniforms(e,o,i).forEach((function(t,e){var i=u[e];a.uniforms[i][r]=+t}))}));for(var l=0;l<u.length;l++){var f=a.uniforms[u[l]],d=a.uniforms[u[l+1]],p=d?d[1]:a.size;f[8]=p-f[1]}a.id=function(t){var e=t.name,i=t.size,r=t.uniforms,n=t.uniformIndices,s=Object.keys(r).map((function(t){return t+"["+r[t].join(":")+"]"})).join("+");return uf(e+"+",i+"+",n.length+"+",s)}(a)+""},r=[],n=[],s=t.getProgramParameter(e,t.ACTIVE_UNIFORM_BLOCKS),a=0;a<s;++a)i(a);return{blockSpecs:r,blockUniformNames:n}}function uf(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];for(var r=0,n=0;n<arguments.length;n++)for(var s=e[n],a=0;a<s.length;a++)r=Math.imul(31,r)+s.charCodeAt(a)|0;return r}(Gl={})[fi.FLOAT]=sf(Float32Array),Gl[fi.INT]=sf(Int32Array),Gl[fi.UNSIGNED_INT]=sf(Uint32Array),Gl[fi.SHORT]=sf(Int16Array),Gl[fi.BOOL]=sf(Uint8Array),Gl[fi.UNSIGNED_SHORT]=sf(Uint16Array),Gl[fi.FLOAT_VEC2]=ef,Gl[fi.FLOAT_VEC3]=ef,Gl[fi.FLOAT_VEC4]=ef,Gl[fi.FLOAT_MAT2]=ef,Gl[fi.FLOAT_MAT3]=ef,Gl[fi.FLOAT_MAT4]=ef,Gl[fi.FLOAT_MAT2x3]=ef,Gl[fi.FLOAT_MAT2x4]=ef,Gl[fi.FLOAT_MAT4x3]=ef,Gl[fi.FLOAT_MAT4x2]=ef,Gl[fi.FLOAT_MAT3x4]=ef,Gl[fi.FLOAT_MAT3x2]=ef,Gl[fi.INT_VEC2]=rf,Gl[fi.INT_VEC3]=rf,Gl[fi.INT_VEC4]=rf,Gl[fi.UNSIGNED_INT_VEC2]=rf,Gl[fi.UNSIGNED_INT_VEC3]=rf,Gl[fi.UNSIGNED_INT_VEC4]=rf,Gl[fi.BOOL_VEC2]=nf,Gl[fi.BOOL_VEC3]=nf,Gl[fi.BOOL_VEC4]=nf;var hf=function(){function t(t,e,i){var r=this;this.engine=t,this.program=e,this.id=i,this.uniformBlockMap={},this.pipelineContext=t.getGLPipelineContext();var n=this.pipelineContext.gl;(this.pipelineContext.useProgram(e),this.attribInfoMap=this.createAttribMap(),pi(n))&&of(n,e).blockSpecs.forEach((function(t){return r.uniformBlockMap[t.name]=t}));this.pipelineContext.useProgram(null)}var e=t.prototype;return e.bind=function(){this.pipelineContext.useProgram(this.program)},e.setupAttributes=function(t){var e,i,r=this,n=this.id,s=this.pipelineContext.gl;return t.vaos[n]?i=t.vaos[n]:((i=new Rl(this.engine,t.name+"-"+n))||console.error("Failed to create VAO object."),t.vaos[n]=i),i&&i.vao&&(i.bind(),i.ready)||(Object.keys(this.attribInfoMap).forEach((function(e){var i=r.attribInfoMap[e],n=t.attributes[e];if(n){var a=t.buffers[n.dataSource];if(!a)throw new Error("Failed to find a buffer named '"+(n.dataSource||e)+"'. Please ensure the buffer is correctly initialized and bound.");a.bind(),s.enableVertexAttribArray(i.loc),s.vertexAttribPointer(i.loc,n.size,n.type,n.normalize,n.stride||0,n.offset||0)}})),null==(e=t.indicesBuffer)||e.bind(),i&&(i.ready=!0)),i},e.createAttribMap=function(){for(var t=this.pipelineContext.gl,e=this.program,i={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES),n=0;n<r;n++){var s=t.getActiveAttrib(e,n);if(s){var a=s.name,o=s.type,u=s.size,h=t.getAttribLocation(e,a);i[a]={type:o,name:a,size:u,loc:h}}}return i},e.dispose=function(){this.pipelineContext&&(this.pipelineContext.gl.deleteProgram(this.program),this.pipelineContext=null)},t}(),cf=function(t){function e(e,i){var r;return(r=t.call(this,e,i)||this).initialized=!1,r.uniformLocations={},r.samplerChannels={},r}Qt(e,t);var i=e.prototype;return i.initialize=function(){this.initialized||this.engine.getGLPipelineContext().shaderLibrary.compileShader(this)},i.setFloat=function(t,e){this.pipelineContext.setFloat(this.uniformLocations[t],e)},i.setInt=function(t,e){this.pipelineContext.setInt(this.uniformLocations[t],e)},i.setFloats=function(t,e){this.pipelineContext.setFloats(this.uniformLocations[t],e)},i.setTexture=function(t,e){this.pipelineContext.setTexture(this.uniformLocations[t],this.samplerChannels[t],e)},i.setVector2=function(t,e){this.pipelineContext.setVector2(this.uniformLocations[t],e)},i.setVector3=function(t,e){this.pipelineContext.setVector3(this.uniformLocations[t],e)},i.setVector4=function(t,e){this.pipelineContext.setVector4(this.uniformLocations[t],e)},i.setColor=function(t,e){this.pipelineContext.setColor(this.uniformLocations[t],e)},i.setQuaternion=function(t,e){this.pipelineContext.setQuaternion(this.uniformLocations[t],e)},i.setMatrix=function(t,e){this.pipelineContext.setMatrix(this.uniformLocations[t],e)},i.setMatrix3=function(t,e){this.pipelineContext.setMatrix3(this.uniformLocations[t],e)},i.setVector4Array=function(t,e){this.pipelineContext.setVector4Array(this.uniformLocations[t],e)},i.setMatrixArray=function(t,e){this.pipelineContext.setMatrixArray(this.uniformLocations[t],e)},i.fillShaderInformation=function(t,e){var i=e.slice();t=t.concat(i);for(var r,n=this.pipelineContext.getUniforms(this.program.program,t),s=0;s<t.length;s++)this.uniformLocations[t[s]]=n[s];for(r=0;r<i.length;r++){null==this.uniformLocations[i[r]]&&(i.splice(r,1),r--)}for(r=0;r<i.length;r++){var a=i[r];this.samplerChannels[a]=r}},i.toData=function(){var t=this.defination;t.dataType=_e.Shader,t.id=this.guid,t.vertex=this.source.vertex,t.fragment=this.source.fragment},i.dispose=function(){var t;this.compileResult&&this.compileResult.shared||null==(t=this.program)||t.dispose()},e}(fr),lf=0,ff=function(){function t(t,e){this.engine=t,this.pipelineContext=e,this.shaderResults={},this.programMap={},this.glVertShaderMap=new Map,this.glFragShaderMap=new Map,this.shaderAllDone=!1,this.cachedShaders={},this.glAsyncCompileExt=t.gpuCapability.glAsyncCompileExt}var e=t.prototype;return e.compileAllShaders=function(t){var e=this;if(this.shaderAllDone)t&&t([]);else{for(var i,r=[],n=w(Object.keys(this.cachedShaders));!(i=n()).done;){var s=i.value;this.cachedShaders[s].initialized||r.push(s)}t?r.length?Promise.all(r.map((function(t){return new Promise((function(i){return e.compileShader(e.cachedShaders[t],i)}))}))).then(t).catch((function(){return 0})):t([]):r.map((function(t){return e.compileShader(e.cachedShaders[t])})),this.shaderAllDone=!0}},e.addShader=function(t,e){var i,r,n=[];t.macros&&(i=n).push.apply(i,[].concat(t.macros));e&&(r=n).push.apply(r,[].concat(e));var s=_i({},t,{vertex:cn.genFinalShaderCode({level:this.engine.gpuCapability.level,shaderType:oi.vertex,shader:t.vertex,macros:n}),fragment:cn.genFinalShaderCode({level:this.engine.gpuCapability.level,shaderType:oi.fragment,shader:t.fragment,macros:n})}),a=this.computeShaderCacheId(s);if(this.cachedShaders[a])return a;this.shaderAllDone=!1;var o=!1;return(s.shared||s.cacheId)&&(o=!0),this.cachedShaders[a]=new cf(this.engine,_i({},s,{vertex:s.vertex,fragment:s.fragment,name:s.name||a,shared:o})),this.cachedShaders[a].id=a,a},e.createShader=function(t,e){var i=this.addShader(t,e);return this.cachedShaders[i]},e.compileShader=function(t,e){var i=this,r=t.source,n=r.shared,s=r.vertex,a=r.fragment,o=r.name,u=t.source.cacheId,h=!1;(n||u)&&(h=!0);var c=this.pipelineContext.gl,l={shared:h,status:or.compiling},f=this.createProgram(c,s,a,l),p=this.glAsyncCompileExt,m=d.now(),v=function(e){l.status=or.success,l.compileTime=d.now()-m,t.program=e,t.initialized=!0,t.pipelineContext=i.pipelineContext,void 0!==i.programMap[t.id]&&console.warn("Find duplicated shader id: "+t.id+"."),i.programMap[t.id]=e},y=function(){if(i.engine.isDestroyed)return console.warn("The player is destroyed during the loadScene process. Please check the timing of calling loadScene and dispose. A common situation is that when calling loadScene, await is not added. This will cause dispose to be called before loadScene is completed."),null==e?void 0:e(l);if(t.initialized)return null==e?void 0:e(l);var r=(!e||!p||p&&1==c.getProgramParameter(l.program,p.COMPLETION_STATUS_KHR))&&f();if(r){if(l.status!==or.fail){Pl(r,o);var n=new hf(i.engine,r,t.id);if(c.validateProgram(r),c.getProgramParameter(r,c.VALIDATE_STATUS))v(n);else{var u=c.getProgramInfoLog(r);(null==u?void 0:u.includes("the same texture"))||(null==u?void 0:u.includes("Two textures of different types use the same sampler"))?v(n):(l.status=or.fail,l.error=u,console.error("compileProgramError: "+u,"\nvertex:\n",s,"\nfragment:\n",a),c.deleteProgram(r))}}null==e||e(l)}else e&&x(y)};t.compileResult=l,y()},e.computeShaderCacheId=function(t){var e=t.vertex,i=void 0===e?"":e,r=t.fragment,n=void 0===r?"":r,s=t.shared,a=t.cacheId;return s||a?a||"shared_"+uf(i,n):"instanced_"+lf++},e.createProgram=function(t,e,i,r){var n=t.createProgram(),s=this.createGLShader(t,t.VERTEX_SHADER,e),a=this.createGLShader(t,t.FRAGMENT_SHADER,i);return n&&s&&a?(t.attachShader(n,s),t.attachShader(n,a),t.linkProgram(n),r.program=n,r.status=or.compiling,function(){if(r.program=void 0,!t.getProgramParameter(n,t.LINK_STATUS)){var o=t.getProgramInfoLog(n);console.error("Failed to link program: "+o+".");var u=df(t,s,"vertex",e),h=df(t,a,"fragment",i);return r.status=or.fail,u&&(r.error=u.error,r.status=u.status),h&&(r.error=h.error,r.status=h.status),n}return n}):(r.status=or.fail,function(){return null})},e.createGLShader=function(t,e,i){var r=e===t.VERTEX_SHADER?this.glVertShaderMap:this.glFragShaderMap,n=uf(null!=i?i:""),s=r.get(n);if(s)return s;var a=t.createShader(e);return a&&(t.shaderSource(a,i),t.compileShader(a),r.set(n,a)),a},e.deleteShader=function(t){var e=this.programMap[t];void 0!==e&&(e.dispose(),delete this.programMap[t]),void 0!==this.shaderResults[t]&&delete this.shaderResults[t]},e.restore=function(){},e.dispose=function(){var t=this;if(Object.keys(this.programMap).forEach((function(e){t.programMap[e].dispose()})),this.programMap={},this.pipelineContext){var e=this.pipelineContext.gl;this.glFragShaderMap.forEach((function(t){e.deleteShader(t)})),this.glVertShaderMap.forEach((function(t){e.deleteShader(t)})),this.glVertShaderMap=new Map,this.glFragShaderMap=new Map}},t}();function df(t,e,i,r){if(!t.getShaderParameter(e,t.COMPILE_STATUS)){var n=t.getShaderInfoLog(e);return console.error("compile "+i+" error: "+n,(null!=r?r:"").split("\n").map((function(t,e){return e+1+" "+t})).join("\n")),{error:n,status:or.fail}}}var pf=function(){function t(t,e){this.engine=t,this.gl=e,this.gl=e,this.shaderLibrary=new ff(t,this),this.maxTextureCount=this.gl.TEXTURE0+this.gl.getParameter(this.gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS)-1,this.reset()}var e=t.prototype;return e.dispose=function(){this.shaderLibrary.dispose(),this.reset()},e.reset=function(){this.glCapabilityCache={},this.activeTextureIndex=fi.TEXTURE0,this.textureUnitDict={},this.currentFramebuffer={},this.pixelStorei={},this.currentRenderbuffer={}},e.toggle=function(t,e){e?this.enable(t):this.disable(t)},e.enable=function(t){!0!==this.glCapabilityCache[t]&&(this.glCapabilityCache[t]=!0,this.gl.enable(t))},e.disable=function(t){!1!==this.glCapabilityCache[t]&&(this.glCapabilityCache[t]=!1,this.gl.disable(t))},e.bindFramebuffer=function(t,e){this.currentFramebuffer[t]!==e&&(this.currentFramebuffer[t]=e,this.gl.bindFramebuffer(t,e))},e.bindRenderbuffer=function(t,e){this.currentRenderbuffer[t]!==e&&(this.currentRenderbuffer[t]=e,this.gl.bindRenderbuffer(t,e))},e.bindSystemFramebuffer=function(){this.bindFramebuffer(this.gl.FRAMEBUFFER,null)},e.useProgram=function(t){this.set1("useProgram",t)},e.clear=function(t){this.gl.clear(t)},e.clearDepth=function(t){this.set1("clearDepth",t)},e.depthFunc=function(t){this.set1("depthFunc",t)},e.depthMask=function(t){this.set1("depthMask",t)},e.polygonOffset=function(t,e){this.set2("polygonOffset",t,e)},e.depthRange=function(t,e){this.set2("depthRange",t,e)},e.clearStencil=function(t){this.set1("clearStencil",t)},e.stencilMask=function(t){this.stencilMaskSeparate(this.gl.FRONT,t),this.stencilMaskSeparate(this.gl.BACK,t)},e.stencilFunc=function(t,e,i){this.stencilFuncSeparate(this.gl.FRONT,t,e,i),this.stencilFuncSeparate(this.gl.BACK,t,e,i)},e.stencilFuncSeparate=function(t,e,i,r){this.set4("stencilFuncSeparate",t,e,i,r)},e.stencilMaskSeparate=function(t,e){this.set2("stencilMaskSeparate",t,e)},e.stencilOp=function(t,e,i){this.stencilOpSeparate(this.gl.FRONT,t,e,i),this.stencilOpSeparate(this.gl.BACK,t,e,i)},e.stencilOpSeparate=function(t,e,i,r){this.set4("stencilOpSeparate",t,e,i,r)},e.cullFace=function(t){this.set1("cullFace",t)},e.frontFace=function(t){this.set1("frontFace",t)},e.clearColor=function(t,e,i,r){this.set4("clearColor",t,e,i,r)},e.colorMask=function(t,e,i,r){this.set4("colorMask",t,e,i,r)},e.blendColor=function(t,e,i,r){this.set4("blendColor",t,e,i,r)},e.blendFunc=function(t,e){this.blendFuncSeparate(t,e,t,e)},e.blendFuncSeparate=function(t,e,i,r){this.set4("blendFuncSeparate",t,e,i,r)},e.blendEquation=function(t){this.set1("blendEquation",t)},e.blendEquationSeparate=function(t,e){this.set2("blendEquationSeparate",t,e)},e.setPixelStorei=function(t,e){this.pixelStorei[t]!==e&&(this.pixelStorei[t]=e,this.gl.pixelStorei(t,e))},e.viewport=function(t,e,i,r){this.set4("viewport",t,e,i,r)},e.activeTexture=function(t){t=Math.min(t,this.maxTextureCount),this.activeTextureIndex!==t&&(this.activeTextureIndex=t,this.gl.activeTexture(t))},e.bindTexture=function(t,e,i){(this.currentTextureBinding!==e||i)&&(this.gl.bindTexture(t,e),this.currentTextureBinding=e),this.textureUnitDict[this.activeTextureIndex]=e},e.set1=function(t,e){this.glCapabilityCache[t]!==e&&(this.glCapabilityCache[t]=e,this.gl[t](e))},e.set2=function(t,e,i){var r=this.glCapabilityCache[t];r||(r=this.glCapabilityCache[t]={x:NaN,y:NaN}),r.x===e&&r.y===i||this.gl[t](r.x=e,r.y=i)},e.set3=function(t,e,i,r){var n=this.glCapabilityCache[t];n||(n=this.glCapabilityCache[t]={x:NaN,y:NaN,z:NaN}),n.x===e&&n.y===i&&n.z===r||this.gl[t](n.x=e,n.y=i,n.z=r)},e.set4=function(t,e,i,r,n){var s=this.glCapabilityCache[t];s||(s=this.glCapabilityCache[t]={x:NaN,y:NaN,z:NaN,w:NaN}),s.x===e&&s.y===i&&s.z===r&&s.w===n||this.gl[t](s.x=e,s.y=i,s.z=r,s.w=n)},e.get=function(t){return this.glCapabilityCache[t]},e.setFloat=function(t,e){t&&this.gl.uniform1f(t,e)},e.setInt=function(t,e){t&&this.gl.uniform1i(t,e)},e.setFloats=function(t,e){t&&this.gl.uniform1fv(t,e)},e.setVector2=function(t,e){this.setFloat2(t,e.x,e.y)},e.setVector3=function(t,e){this.setFloat3(t,e.x,e.y,e.z)},e.setVector4=function(t,e){this.setFloat4(t,e.x,e.y,e.z,e.w)},e.setColor=function(t,e){this.setFloat4(t,e.r,e.g,e.b,e.a)},e.setQuaternion=function(t,e){this.setFloat4(t,e.x,e.y,e.z,e.w)},e.setVector4Array=function(t,e){t&&e.length%4==0&&this.gl.uniform4fv(t,e)},e.setMatrix=function(t,e){t&&this.gl.uniformMatrix4fv(t,!1,e.elements)},e.setMatrix3=function(t,e){t&&this.gl.uniformMatrix3fv(t,!1,e.elements)},e.setMatrixArray=function(t,e){t&&e.length%16==0&&this.gl.uniformMatrix4fv(t,!1,e)},e.setTexture=function(t,e,i){if(t){this.gl.activeTexture(this.gl.TEXTURE0+e);var r=i.target;this.gl.bindTexture(r,i.textureBuffer),this.gl.uniform1i(t,e)}},e.getUniforms=function(t,e){for(var i=[],r=0;r<e.length;r++)i.push(this.gl.getUniformLocation(t,e[r]));return i},e.setFloat4=function(t,e,i,r,n){t&&this.gl.uniform4f(t,e,i,r,n)},e.setFloat3=function(t,e,i,r){t&&this.gl.uniform3f(t,e,i,r)},e.setFloat2=function(t,e,i){t&&this.gl.uniform2f(t,e,i)},t}(),mf=function(t){function e(e,i,r){var n;(n=t.call(this)||this).canvas=e,n.temporaryRTs={};var s=_i({preserveDrawingBuffer:void 0,alpha:!0,stencil:!0,antialias:!0,depth:!0,premultipliedAlpha:!0},r);n.context=new ql(e,i,s);var a=n.context.gl;return ot(a),n.engine=new Kl(a),n.engine.renderer=ho(n),n.pipelineContext=new pf(n.engine,a),n.glRenderer=new Il(n.engine),n.extension=new Wl(ho(n)),n.renderingData={currentFrame:{}},n.framebuffer=new $l({storeAction:{},viewport:[0,0,n.width,n.height],attachments:[new Sl(n.engine,{sourceType:ci.framebuffer,data:{width:n.width,height:n.height}})],depthStencilAttachment:{storageType:Ir.none}},ho(n)),n}Qt(e,t);var i=e.prototype;return i.renderRenderFrame=function(t){var e,i=t;i.resource&&i.resource.color_b.initialize(),i.emptyTexture.initialize(),i.transparentTexture.initialize();var r=i._renderPasses;if(this.isDestroyed)console.error("Renderer is destroyed, target: GLRenderer.");else{null==(e=i.renderer.getShaderLibrary())||e.compileAllShaders(),this.setFramebuffer(null),this.clear(i.clearAction);var n=i.camera;this.renderingData.currentFrame=i,this.renderingData.currentCamera=n,this.setGlobalMatrix("effects_MatrixInvV",n.getInverseViewMatrix()),this.setGlobalMatrix("effects_MatrixV",n.getViewMatrix()),this.setGlobalMatrix("effects_MatrixVP",n.getViewProjectionMatrix()),this.setGlobalMatrix("_MatrixP",n.getProjectionMatrix()),this.setGlobalVector3("effects_WorldSpaceCameraPos",n.position),rt(r);for(var s,a=w(r);!(s=a()).done;){var o=s.value,u=o.delegate;null==u.willBeginRenderPass||u.willBeginRenderPass.call(u,o,this.renderingData),this.renderRenderPass(o),null==u.didEndRenderPass||u.didEndRenderPass.call(u,o,this.renderingData)}for(var h,c=w(r);!(h=c()).done;){h.value.frameCleanup(this)}}},i.renderRenderPass=function(t){this.renderingData.currentPass=t,t.initialize(this),t.configure(this),t.execute(this)},i.renderMeshes=function(t){for(var e,i=this.renderingData.currentPass.delegate,r=w(t);!(e=r()).done;){var n=e.value;null==i.willRenderMesh||i.willRenderMesh.call(i,n,this.renderingData),n.render(this),null==i.didRenderMesh||i.didRenderMesh.call(i,n,this.renderingData)}},i.setGlobalFloat=function(t,e){this.checkGlobalUniform(t),this.renderingData.currentFrame.globalUniforms.floats[t]=e},i.setGlobalVector4=function(t,e){this.checkGlobalUniform(t),this.renderingData.currentFrame.globalUniforms.vector4s[t]=e},i.getGlobalVector4=function(t){return this.renderingData.currentFrame.globalUniforms.vector4s[t]},i.setGlobalInt=function(t,e){this.checkGlobalUniform(t),this.renderingData.currentFrame.globalUniforms.ints[t]=e},i.setGlobalMatrix=function(t,e){this.checkGlobalUniform(t),this.renderingData.currentFrame.globalUniforms.matrices[t]=e},i.setGlobalVector3=function(t,e){this.checkGlobalUniform(t),this.renderingData.currentFrame.globalUniforms.vector3s[t]=e},i.drawGeometry=function(t,e,i){if(void 0===i&&(i=0),t&&e){e.initialize(),t.initialize(),t.flush();var r=this.renderingData;r.currentFrame.editorTransform&&e.setVector4("uEditorTransform",r.currentFrame.editorTransform);try{e.use(this,r.currentFrame.globalUniforms)}catch(t){return void console.error(t)}this.glRenderer.drawGeometry(t,e,i)}},i.setFramebuffer=function(t){t?(this.framebuffer=t,this.framebuffer.bind(),this.setViewport(t.viewport[0],t.viewport[1],t.viewport[2],t.viewport[3])):(this.pipelineContext.bindSystemFramebuffer(),this.setViewport(0,0,this.getWidth(),this.getHeight()))},i.getFramebuffer=function(){return this.framebuffer},i.getTemporaryRT=function(t,e,i,r,n,s){if(this.temporaryRTs[t])return this.temporaryRTs[t];var a,o,u=Ir.none;n===Tn.Linear?a=fi.LINEAR:n===Tn.Nearest&&(a=fi.NEAREST),s===En.RGBA32?o=fi.UNSIGNED_BYTE:s===En.RGBAHalf&&(o=fi.HALF_FLOAT),0===r?u=Ir.none:16===r?u=Ir.depth_16_opaque:24===r&&(u=Ir.depth_24_stencil_8_texture);var h=new Sl(this.engine,{sourceType:ci.framebuffer,minFilter:a,magFilter:a,internalFormat:fi.RGBA,format:fi.RGBA,type:o}),c=new $l({name:t,storeAction:{},viewport:[0,0,e,i],viewportScale:1,isCustomViewport:!0,attachments:[h],depthStencilAttachment:{storageType:u}},this);return this.temporaryRTs[t]=c,c},i.setViewport=function(t,e,i,r){this.pipelineContext.viewport(t,e,i,r)},i.clear=function(t){var e=this.pipelineContext,i=0;if(t.colorAction===hi.clear){var r=t.clearColor;r&&e.clearColor(r[0],r[1],r[2],r[3]),e.colorMask(!0,!0,!0,!0),i=fi.COLOR_BUFFER_BIT}if(t.stencilAction===hi.clear&&(e.stencilMask(255),e.clearStencil(t.clearStencil||0),i|=fi.STENCIL_BUFFER_BIT),t.depthAction===hi.clear){var n=t.clearDepth;e.depthMask(!0),e.clearDepth(Number.isFinite(n)?n:1),i|=fi.DEPTH_BUFFER_BIT}i&&e.clear(i)},i.addLostHandler=function(t){this.context.addLostHandler(t)},i.addRestoreHandler=function(t){this.context.addRestoreHandler(t)},i.getShaderLibrary=function(){return this.pipelineContext.shaderLibrary},i.getWidth=function(){return this.width},i.getHeight=function(){return this.height},i.dispose=function(){var t;this.context.dispose(),this.extension.dispose(),this.pipelineContext.dispose(),null==(t=this.glRenderer)||t.dispose(),this.canvas=null,this.engine.dispose()},i.lost=function(t){t.preventDefault(),this.pipelineContext.dispose(),this.extension.dispose(),this.glRenderer.lost(t)},i.restore=function(){var t=this.context.gl;if(!t)throw new Error("Can not restore automatically because losing gl context.");this.engine.gpuCapability=new Sn(t),this.engine.renderer=this,this.pipelineContext=new pf(this.engine,t),this.glRenderer=new Il(this.engine),this.extension=new Wl(this)},i.resize=function(t,e){var i=this.glRenderer;i&&(this.width===t&&this.height===e||i.resize(t,e))},i.checkGlobalUniform=function(t){var e=this.renderingData.currentFrame.globalUniforms;e.uniforms.includes(t)||e.uniforms.push(t)},Pe(e,[{key:"isDestroyed",get:function(){var t=this.glRenderer;return!t||t.isDestroyed}},{key:"height",get:function(){var t,e;return null!=(e=null==(t=this.glRenderer)?void 0:t.height)?e:0}},{key:"width",get:function(){var t,e;return null!=(e=null==(t=this.glRenderer)?void 0:t.width)?e:0}}]),e}(In),vf="https://www.galacean.com/effects/user/gasrv4ka5sacrwpg#MvjnY",yf="https://www.galacean.com/effects/user/gasrv4ka5sacrwpg#ulfNT",gf="https://www.galacean.com/effects/user/gasrv4ka5sacrwpg#lLlSW",xf="https://www.galacean.com/effects/user/gasrv4ka5sacrwpg#WZaWg",bf="https://www.galacean.com/effects/user/gasrv4ka5sacrwpg#YSWQr",Tf="https://www.galacean.com/effects/user/gasrv4ka5sacrwpg#IzodZ",Ef="https://www.galacean.com/effects/user/gasrv4ka5sacrwpg#X0ulg";var _f=new Map;function wf(t){return _f.has(t)}function Af(t){return _f.get(t)}function Cf(){return Array.from(_f.values())}var Sf=!1,Of=1,Rf=function(t){function e(e){var s;(s=t.call(this)||this).compositions=[],s.displayScale=1,s.resumePending=!1,s.disposed=!1,s.assetManagers=[],s.speed=1,s.baseCompositionIndex=0,s.lost=function(t){var e;null==(e=s.ticker)||e.pause(),s.compositions.forEach((function(e){return e.lost(t)})),s.renderer.lost(t),s.handleEmitEvent("webglcontextlost",t),If(ho(s),!1)};var a=ho(s);s.restore=E((function(){var t;return O(this,(function(e){switch(e.label){case 0:return a.renderer.restore(),[4,Promise.all(a.compositions.map(E((function(t){var e,i,r,n,s,o,u,h,c,l,f,d;return O(this,(function(p){switch(p.label){case 0:return e=t.time,i=t.url,r=t.speed,n=t.keepResource,s=t.reusable,o=t.renderOrder,u=t.transform,h=t.videoState,[4,a.loadScene(i)];case 1:(c=p.sent()).speed=r,c.reusable=s,c.keepResource=n,c.renderOrder=o,c.transform.setPosition(u.position.x,u.position.y,u.position.z),c.transform.setRotation(u.rotation.x,u.rotation.y,u.rotation.z),c.transform.setScale(u.scale.x,u.scale.y,u.scale.z),l=0,p.label=2;case 2:return l<h.length?h[l]?((f=c.textures[l].source.video).currentTime=null!=(d=h[l])?d:0,[4,f.play()]):[3,4]:[3,5];case 3:p.sent(),p.label=4;case 4:return l++,[3,2];case 5:return c.isEnded=!1,c.gotoAndPlay(e),[2,c]}}))}))))];case 1:return a.compositions=e.sent(),a.emit("webglcontextrestored"),null==(t=a.ticker)||t.resume(),W()&&a.canvas&&(a.canvas.style.display="none",r.setTimeout((function(){a.canvas.style.display=""}),0)),[2]}}))})),s.handleResume=function(){s.emit("update",{player:ho(s),playing:!0})},s.handleClick=function(t){var e=t.x,i=t.y,r=[];s.compositions.forEach((function(t){for(var n,a=w(t.hitTest(e,i));!(n=a()).done;){var o=n.value;r.push(_i({},o,{player:ho(s),composition:t}))}}));for(var n=0;n<r.length;n++){var a=r[n],o=a.behavior||jt.NOTIFY;o===jt.NOTIFY?(s.emit("click",_i({},a,{compositionId:a.composition.id,compositionName:a.composition.name})),a.composition.emit("click",_i({},a,{compositionId:a.composition.id,compositionName:a.composition.name}))):o===jt.RESUME_PLAYER&&s.resume()}};var o=e.container,u=e.canvas,h=e.fps,c=e.name,l=e.pixelRatio,f=e.manualRender,d=e.reportGPUTime,p=e.renderFramework,m=e.notifyTouch,v=e.onError,y=e.interactive,g=void 0!==y&&y,x=e.renderOptions,b=void 0===x?{}:x,T=e.env,_=void 0===T?"":T,A=b.willCaptureImage,C=b.premultipliedAlpha;if(s.onError=v,Sf||"debug-disable"===p)return kh(s);var S,R=(S=/iPhone OS (\d+)_(\d+)/.exec(n.userAgent))&&("13"===S[1]||"16"===S[1]&&"5"===S[2])?"webgl":"webgl2";p&&(R="webgl"===p?"webgl":"webgl2"),s.reportGPUTime=d,s.pixelRatio=Number.isFinite(l)?l:Y(),s.offscreenMode=!0,s.env=_,s.name=c||""+Of++;try{if(li.length)throw new Error("Errors before player create: "+li.map((function(t,e){return"\n "+(e+1)+": "+t}))+".",{cause:"webgliniterror"});u?s.canvas=u:(Pf(o),s.canvas=i.createElement("canvas"),o.appendChild(s.canvas)),s.container=s.canvas.parentElement,s.renderer=In.create(s.canvas,R,{preserveDrawingBuffer:A,premultipliedAlpha:C}),s.renderer.env=_,s.renderer.addLostHandler({lost:s.lost}),s.renderer.addRestoreHandler({restore:s.restore}),s.gpuCapability=s.renderer.engine.gpuCapability,s.assetService=new tl(s.renderer.engine),f||(s.ticker=new El(h),s.ticker.add(s.tick.bind(ho(s)))),s.event=new Xs(s.canvas,!!m),s.event.bindListeners(),s.event.addEventListener(Us,s.handleClick),s.interactive=g,s.resize(),th(s.gpuCapability.detail)}catch(t){s.handleThrowError(t)}return _f.forEach((function(t){t.gpuCapability.type!==s.gpuCapability.type&&mt.warn("Create player with different WebGL version: old="+t.gpuCapability.type+", new="+s.gpuCapability.type+".\nsee "+Ef+".")})),_f.set(s.canvas,ho(s)),function(){for(var t,e=[],i=w(_f.values());!(t=i()).done;){var r=t.value;r.paused||e.push(r)}e.length>1&&mt.error("Current running player count: "+e.length+", see "+Tf+".",e)}(),If(ho(s),!0),s}Qt(e,t);var s=e.prototype;return s.setSpeed=function(t){isNaN(t)||(this.speed=t)},s.getSpeed=function(){return this.speed},s.getCompositionByName=function(t){return this.compositions.find((function(e){return e.name===t}))},s.getCompositions=function(){return this.compositions.sort((function(t,e){return t.getIndex()-e.getIndex()}))},s.getAssetManager=function(){return this.assetManagers},s.loadScene=function(t,e){var i=this;return E((function(){var r,n,s,a,o,u,h,c,l,f,p,m,v,y,g,x,b,T,_,A;return O(this,(function(C){switch(C.label){case 0:return ot(i.renderer,"Renderer is not exist, maybe the Player has been disabled or in gl 'debug-disable' mode."),a=d.now(),o=[],u=[],c=null==(h=null==e?void 0:e.autoplay)||h,l=null==(n=i.renderer.engine.gpuCapability)||null==(r=n.detail)?void 0:r.asyncShaderCompile,f=i.baseCompositionIndex,gt(t)?(p=o).push.apply(p,[].concat(t)):o.push(t),i.baseCompositionIndex+=o.length,c&&(i.autoPlaying=!0),m=[],[4,Promise.all(o.map(E((function(t,r){var n,s,a,o,h,l,d,p;return O(this,(function(v){switch(v.label){case 0:return n=i.assetService.assembleSceneLoadOptions(t,_i({autoplay:c},e)),s=n.source,a=n.options,h=null!=(o=null==a?void 0:a.autoplay)?o:c,l=new Jc(a),i.assetManagers.push(l),[4,l.loadScene(s,i.renderer,{env:i.env})];case 1:return d=v.sent(),i.disposed?(u.length=0,[2]):(i.assetService.prepareAssets(d,d.assets),i.assetService.updateTextVariables(d,l.options.variables),i.assetService.initializeTexture(d),d.pluginSystem.precompile(d.jsonScene.compositions,i.renderer),(p=i.createComposition(d,a)).setIndex(f+r),u[r]=p,m[r]=h,[2])}}))}))))];case 1:return C.sent(),v=d.now(),[4,new Promise((function(t){var e;null==(e=i.renderer.getShaderLibrary())||e.compileAllShaders((function(){return t(null)}))}))];case 2:for(C.sent(),y=d.now()-v,g=0;g<u.length;g++)m[g]?u[g].play():u[g].pause();for(null==(s=i.ticker)||s.start(),x=u.map((function(t){return t.name})),b=d.now()-a,T=w(u);!(_=T()).done;)(A=_.value).statistic.compileTime=y,A.statistic.firstFrameTime=b;return mt.info("First frame ["+x+"]: "+b.toFixed(4)+"ms."),mt.info("Shader "+(l?"async":"sync")+" compile ["+x+"]: "+y.toFixed(4)+"ms."),[2,gt(t)?u:u[0]]}}))}))()},s.createComposition=function(t,e){var i=this;void 0===e&&(e={});var r=this.renderer,n=new Yu(_i({},e,{renderer:r,width:r.getWidth(),height:r.getHeight(),event:this.event,handleItemMessage:function(t){i.emit("message",t)}}),t);return this.ticker&&e.renderLevel===Nt.B&&this.ticker.setFPS(Math.min(this.ticker.getFPS(),30)),this.env!==As&&this.assetService.createShaderVariant(),this.compositions.push(n),n},s.play=function(){var t;this.offscreenMode&&(this.resize(),this.offscreenMode=!1),this.autoPlaying=!0,this.compositions.map((function(t){t.play()})),null==(t=this.ticker)||t.start()},s.gotoAndPlay=function(t){this.offscreenMode&&(this.resize(),this.offscreenMode=!1),this.autoPlaying=!0,this.compositions.map((function(e){e.gotoAndPlay(t)})),this.ticker?this.ticker.start():this.doTick(0,!0)},s.gotoAndStop=function(t){var e;this.offscreenMode&&(this.resize(),this.offscreenMode=!1),this.autoPlaying=!1,this.compositions.map((function(e){e.gotoAndStop(t)})),this.ticker&&!(null==(e=this.ticker)?void 0:e.getPaused())||this.doTick(0,!0),this.emit("update",{player:this,playing:!1})},s.playSequence=function(t){for(var e,i=function(e){t[e].on("end",(function(){t[e+1].play()}))},r=0;r<t.length-1;r++)i(r);t[0].play(),null==(e=this.ticker)||e.start()},s.pause=function(t){var e;this.paused||(null==(e=this.ticker)||e.pause(),this.emit("pause"),this.emit("update",{player:this,playing:!1}),t&&t.offloadTexture&&this.offloadTexture())},s.resume=function(){var t=this;return E((function(){var e;return O(this,(function(i){switch(i.label){case 0:return t.resumePending?[2]:t.paused?(t.resumePending=!0,[4,Promise.all(t.compositions.map((function(t){return t.reloadTexture()})))]):[3,2];case 1:i.sent(),t.resumePending=!1,t.handleResume(),i.label=2;case 2:return null==(e=t.ticker)||e.resume(),[2]}}))}))()},s.tick=function(t){this.doTick(t,this.forceRenderNextFrame),this.forceRenderNextFrame=!1},s.doTick=function(t,e){var i,r=this,n=this.renderer.engine.renderErrors;n.size>0&&(this.handleEmitEvent("rendererror",n.values().next().value),null==(i=this.ticker)||i.pause());t=Math.min(t,33)*this.speed;var s=this.compositions,a=!1;s.sort((function(t,e){return t.getIndex()-e.getIndex()}));for(var o,u=[],h=0;h<s.length;h++){var c=s[h];c.textureOffloaded?(a=!0,mt.error("Composition "+c.name+" texture offloaded, skip render."),u.push(c)):(!c.isDestroyed&&c.renderer&&c.update(t),c.isDestroyed||u.push(c))}if(this.compositions=u,this.baseCompositionIndex=this.compositions.length,a)return this.handleEmitEvent("rendererror",new Error("Play when texture offloaded.")),null==(o=this.ticker)?void 0:o.pause();if(!this.paused||e){var l=this.gpuCapability.level,f=this.renderer.context.gl,d=2===l&&this.reportGPUTime?ai(f):void 0;if(null==d||d.begin(),this.compositions.length||this.compositions.length<s.length||e){this.renderer.setFramebuffer(null),this.renderer.clear({stencilAction:hi.clear,clearStencil:0,depthAction:hi.clear,clearDepth:1,colorAction:hi.clear,clearColor:[0,0,0,0]});for(var p=0;p<s.length;p++)!s[p].renderFrame.isDestroyed&&this.renderer.renderRenderFrame(s[p].renderFrame)}null==d||d.end(),null==d||d.getTime().then((function(t){return null==r.reportGPUTime?void 0:r.reportGPUTime.call(r,null!=t?t:0)})).catch,this.autoPlaying&&this.emit("update",{player:this,playing:!0})}},s.resizeToAspect=function(t,e){void 0===e&&(e=1),t!==this.displayAspect&&(this.displayAspect=t),e!==this.displayScale&&(this.displayScale=e),this.resize()},s.resize=function(){var t,e,r,n,s=this.canvas.parentElement;if(s){var a=this.getTargetSize(s);t=a[0],e=a[1],r=a[2],n=a[3]}else t=r=this.canvas.width,e=n=this.canvas.height;var o=t/e;if(t&&e){var u,h=i.documentElement.clientWidth;r>2*h&&mt.error("DPI overflowed, width "+r+" is more than 2x document width "+h+", see "+yf+".");var c=this.env?this.gpuCapability.detail.maxTextureSize:2048;(r>c||n>c)&&(mt.error("Container size overflowed "+r+"x"+n+", see "+vf+"."),o>1?(r=Math.round(c),n=Math.round(c/o)):(n=Math.round(c),r=Math.round(c*o))),this.renderer.resize(r,n),this.canvas.style.width=t+"px",this.canvas.style.height=e+"px",mt.info("Resize player "+this.name+" ["+r+","+n+","+t+","+e+"]."),null==(u=this.compositions)||u.forEach((function(t){t.camera.aspect=o}))}},s.clearCanvas=function(t){t?this.renderer.clear({stencilAction:hi.clear,clearStencil:0,depthAction:hi.clear,clearDepth:1,colorAction:hi.clear,clearColor:[0,0,0,0]}):this.forceRenderNextFrame=!0},s.destroyCurrentCompositions=function(){this.compositions.forEach((function(t){return t.dispose()})),this.compositions.length=0,this.baseCompositionIndex=0},s.dispose=function(t){var e;if(mt.info("Call player destroyed: "+this.name+"."),!this.disposed){_f.delete(this.canvas),this.pause(),null==(e=this.ticker)||e.stop(),this.assetManagers.forEach((function(t){return t.dispose()})),this.compositions.forEach((function(t){return t.dispose()})),this.compositions.length=0,this.renderer&&(this.renderer.context.removeLostHandler({lost:this.lost}),this.renderer.context.removeRestoreHandler({restore:this.restore}),this.renderer.dispose(!t)),this.event&&this.event.dispose(),this.assetService.dispose(),If(this,!1),A(this.canvas,p)&&!t&&this.renderer.context&&(zh.dispose(),this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.canvas.remove());var i="Never use destroyed player: "+this.name+" again, see "+bf+".",r=function(){return function(t){throw new Error(t)}(i)},n=function(){return t=i,Promise.reject(t);var t};this.tick=r,this.resize=r,this.loadScene=n,this.play=n,this.gotoAndPlay=n,this.gotoAndStop=n,this.playSequence=r,this.destroyCurrentCompositions=r,this.resume=n,this.disposed=!0}},s.offloadTexture=function(){this.compositions.forEach((function(t){return t.offloadTexture()}))},s.getTargetSize=function(t){Pf(t);var e,i,n=this.displayAspect,s=null==r.getComputedStyle?void 0:r.getComputedStyle.call(r,t),a=0,o=0;(s?(a=parseInt(s.width,10),o=parseInt(s.height,10)):(a=t.clientWidth,o=t.clientHeight),n)?a/o>n?e=(i=o*this.displayScale)*n:i=(e=a*this.displayScale)/n:(e=a,i=o);var u=this.pixelRatio,h=e,c=i;if(e=Math.round(e*u),(i=Math.round(i*u))<1||i<1){if(!this.offscreenMode)throw new Error("Invalid container size "+e+"x"+i+", see "+gf+".");e=i=h=c=1}return[h,c,e,i]},s.handleThrowError=function(t){if(!this.onError)throw t;this.onError(t)},s.handleEmitEvent=function(t,e){this.onError?A(e,b)?this.onError(new Error(e.type,{cause:t}),e):A(e,Error)?this.onError(new Error(e.message,{cause:t}),e):this.onError(new Error("Unknown error.",{cause:t}),e):(console.warn("["+t+"] event is deprecated, please use 'onError' instead."),this.emit(t,e))},Pe(e,[{key:"compositionCount",get:function(){return this.compositions.length}},{key:"hasPlayable",get:function(){return this.compositions.length>0}},{key:"paused",get:function(){var t;return null==(t=this.ticker)?void 0:t.getPaused()}},{key:"interactive",get:function(){return this.event.enabled},set:function(t){this.event.enabled=t}}]),e}(Bu);function Mf(t){Sf=!!t}function If(t,e){Object.keys(St).forEach((function(i){var r=St[i],n=e?r.onPlayerCreated:r.onPlayerDestroy;null==n||n(t)}))}function Pf(t){if(null==t)throw new Error("Container is not an HTMLElement, see "+xf+".")}S([function(t,e,i){var r=i.value;return i.value=E((function(){var e,i,n,s,a=arguments;return O(this,(function(o){switch(o.label){case 0:for(e=a.length,i=new Array(e),n=0;n<e;n++)i[n]=a[n];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,r.apply(this,i)];case 2:return[2,o.sent()];case 3:return s=o.sent(),t.handleThrowError.call(this,s),[3,4];case 4:return[2]}}))})),i}],Rf.prototype,"loadScene",null),Yi.create=function(t,e){return new Sl(t,e)},Yi.createWithData=function(t,e,i){void 0===e&&(e=et("#fff")),void 0===i&&(i={});var r=i.type,n=void 0===r?fi.UNSIGNED_BYTE:r,s=i.format,a=void 0===s?fi.RGBA:s,o=i.internalFormat,u=i.wrapS,h=void 0===u?fi.MIRRORED_REPEAT:u,c=i.wrapT,l=void 0===c?fi.MIRRORED_REPEAT:c,f=i.minFilter,d=void 0===f?fi.NEAREST:f,p=i.magFilter,m=void 0===p?fi.NEAREST:p,v=i.flipY,y=void 0!==v&&v;return new Sl(t,{data:e,type:n,sourceType:ci.data,format:a,internalFormat:o||a,wrapS:h,wrapT:l,minFilter:d,magFilter:m,flipY:y})},cr.create=function(t,e){return new Yl(t,e)},Cr.create=function(t,e){return new zl(t,e)},Dr.create=function(t,e){return new Dr(t,e)},An.create=function(t){return new Ql(t)},Mn.create=function(t,e){return new $l(t,e)},In.create=function(t,e,i){return new mf(t,e,i)},bl.create=function(t){return new Kl(t)};var Lf="2.5.0-alpha.5";mt.info("Player version: "+Lf+".");export{qt as AbstractPlugin,lh as ActivationPlayable,fh as ActivationPlayableAsset,yu as ActivationTrack,dh as AnimationClip,ph as AnimationClipPlayable,Wh as Asset,Kh as AssetLoader,Jc as AssetManager,tl as AssetService,Ar as BYTES_TYPE_MAP,Ls as BaseRenderComponent,Be as Behaviour,Va as BezierCurve,Da as BezierCurvePath,ka as BezierCurveQuat,Zh as BinaryAsset,bn as COMPRESSED_TEXTURE,yr as COPY_FRAGMENT_SHADER,mr as COPY_MESH_SHADER_ID,vr as COPY_VERTEX_SHADER,rh as CalculateLoader,mo as Camera,Ds as CameraController,zs as CameraVFXItemLoader,Qa as ColorCurve,Ou as ColorPropertyPlayableAsset,Su as ColorPropertyTrack,Ue as Component,Yu as Composition,zu as CompositionComponent,Gh as DEFAULT_FONTS,Tl as DEFAULT_FPS,Qh as Database,lt as Deferred,pt as DestroyOptions,wi as Downloader,pr as EFFECTS_COPY_MESH_NAME,Us as EVENT_TYPE_CLICK,js as EVENT_TYPE_TOUCH_END,Gs as EVENT_TYPE_TOUCH_MOVE,Bs as EVENT_TYPE_TOUCH_START,ti as EffectComponent,ze as EffectsObject,xl as EffectsPackage,Lh as Ellipse,bl as Engine,Bu as EventEmitter,Xs as EventSystem,Vs as Fake3DAnimationMode,Ns as Fake3DComponent,Tn as FilterMode,Ks as Float16ArrayWrapper,Ru as FloatPropertyPlayableAsset,xu as FloatPropertyTrack,Mn as Framebuffer,Kl as GLEngine,zl as GLGeometry,mf as GLRenderer,ur as GLSLVersion,Sn as GPUCapability,Cr as Geometry,wn as GlobalUniforms,La as GradientValue,Dh as GraphicsPath,Cs as HELP_LINK,ks as HitTestType,to as InteractComponent,Zs as InteractLoader,$a as InteractMesh,Uu as Item,Qi as KTXTexture,Fa as LineSegments,Pa as LinearValue,ui as MaskMode,lr as MaskProcessor,cr as Material,nr as MaterialDataBlock,rr as MaterialRenderType,_u as MaterialTrack,Dr as Mesh,ro as MeshCollider,Iu as ObjectBindingTrack,F as OrderType,As as PLAYER_OPTIONS_ENV_EDITOR,Eo as POST_PROCESS_SETTINGS,Lo as ParticleBehaviourPlayable,Fo as ParticleBehaviourPlayableAsset,ih as ParticleLoader,No as ParticleMesh,Go as ParticleSystem,Bo as ParticleSystemRenderer,wu as ParticleTrack,_r as PassTextureCache,Na as PathSegments,Rf as Player,Pt as PluginSystem,Fh as PolyStar,Sh as Polygon,ei as PostProcessVolume,gu as PropertyTrack,mn as RENDER_PASS_NAME_PREFIX,bo as RENDER_PREFER_LOOKUP_TEXTURE,xo as RUNTIME_ENV,Ra as RandomSetValue,Ma as RandomValue,Ia as RandomVectorValue,yn as RenderFrame,Xr as RenderPass,Ir as RenderPassAttachmentStorageType,Br as RenderPassDestroyAttachmentType,zr as RenderPassPriorityNormal,Ur as RenderPassPriorityPostprocess,kr as RenderPassPriorityPrepare,Gr as RenderTargetHandle,En as RenderTextureFormat,An as Renderbuffer,In as Renderer,Ge as RendererComponent,vu as RuntimeClip,_s as SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0,ws as SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0,Ts as SEMANTIC_PRE_COLOR_ATTACHMENT_0,Es as SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0,bs as SPRITE_VERTEX_STRIDE,Hc as Scene,wr as SemanticMap,qh as SerializationHelper,dr as Shader,or as ShaderCompileResultStatus,cn as ShaderFactory,oi as ShaderType,fr as ShaderVariant,Fs as ShapeComponent,Nh as ShapePath,Qu as SpriteColorPlayableAsset,bu as SpriteColorTrack,Ju as SpriteComponent,no as SpriteLoader,Ph as StarType,Oa as StaticValue,Mu as SubCompositionPlayableAsset,Tu as SubCompositionTrack,To as TEMPLATE_USE_OFFSCREEN_CANVAS,Xh as TextComponent,Hh as TextComponentBase,Uh as TextLayout,Yh as TextLoader,Bh as TextStyle,Yi as Texture,tr as TextureFactory,hi as TextureLoadAction,ci as TextureSourceType,Pr as TextureStoreAction,El as Ticker,Lu as TimelineAsset,pu as TimelineClip,Fu as TimelinePlayable,mu as TrackAsset,Vu as TrackSortWrapper,tu as TrackType,fo as Transform,hh as TransformAnimationPlayable,ch as TransformPlayableAsset,Eu as TransformTrack,Wu as VFXItem,Sa as ValueGetter,Za as Vector2Curve,ku as Vector2PropertyPlayableAsset,Cu as Vector2PropertyTrack,Wa as Vector4Curve,Du as Vector4PropertyPlayableAsset,Au as Vector4PropertyTrack,nt as addByOrder,D as addItem,z as addItemWithOrder,Ct as applyMixins,ot as assertExist,ut as asserts,At as base64ToFile,Hr as blend,Th as buildLine,ea as calculateTranslation,zh as canvasPool,yh as closePointEps,rn as colorGradingFrag,j as colorStopsFromGradient,B as colorToArr,qc as combineImageTemplate,gr as createCopyShader,si as createGLContext,ja as createKeyFrameMeta,Wn as createShape,Ka as createValueGetter,gh as curveEps,ha as decimalEqual,Ot as defaultPlugins,Bi as deserializeMipmapTexture,Mf as disableAllPlayer,vs as earcut,Ne as effectsClass,Ve as effectsClassStore,U as enlargeBuffer,$h as ensureFixedNumber,ia as ensureVec3,xn as findPreviousRenderPass,nn as gaussianDownFrag,sn as gaussianDownHFrag,an as gaussianDownVFrag,on as gaussianUpFrag,Sr as generateEmptyTypedArray,wt as generateGUID,Wi as generateHalfFloatTexture,Ki as generateTransparentTexture,qi as generateWhiteTexture,Cf as getActivePlayers,Zc as getBackgroundImage,G as getColorFromGradientStops,wo as getConfig,er as getDefaultTextureFactory,Rs as getGeometryByShape,Os as getGeometryTriangles,Ji as getKTXTextureOptions,Ga as getKeyFrameMetaByRawValue,ke as getMergedStore,zo as getParticleMeshShader,Y as getPixelRatio,Af as getPlayerByCanvas,xi as getPreMultiAlpha,Uc as getStandardComposition,zc as getStandardImage,Xc as getStandardItem,Dc as getStandardJSON,gn as getTextureSize,fi as glContext,yi as glType2VertexFormatType,ai as gpuTimer,et as imageDataFromColor,it as imageDataFromGradient,li as initErrors,di as initGLContext,Wr as integrate,X as interpolateColor,$ as isAlipayMiniApp,q as isAndroid,gt as isArray,Tt as isCanvas,wf as isCanvasUsedByPlayer,xt as isFunction,W as isIOS,Z as isIOSByUA,J as isMiniProgram,bt as isObject,K as isOpenHarmony,Q as isSimulatorCellPhone,yt as isString,sr as isUniformStruct,ar as isUniformStructArray,ht as isValidFontFamily,pi as isWebGL2,tt as isWechatMiniApp,qr as itemFrag,Yr as itemFrameFrag,Zr as itemVert,Ri as loadAVIFOptional,Li as loadBinary,Vi as loadBlob,Ii as loadImage,zi as loadMedia,Di as loadVideo,Si as loadWebPOptional,mt as logger,Vr as math,$u as maxSpriteMeshItemCount,Uo as modifyMaxKeyframeShader,aa as nearestPowerOfTwo,vt as noop,ac as normalizeColor,ca as numberToFix,H as parsePercent,Kr as particleFrag,sa as particleOriginTranslateMap,Vo as particleUniformTypeMap,Qr as particleVert,Wc as passRenderLevel,St as pluginLoaderMap,Et as randomInRange,Mt as registerPlugin,k as removeItem,Ms as rotateVec2,en as screenMeshVert,De as serialize,bi as setBlendMode,Ao as setConfig,ir as setDefaultTextureFactory,Ei as setMaskMode,eh as setMaxSpriteMeshItemCount,oa as setRayFromCamera,Ti as setSideMode,th as setSpriteMeshMaxItemCountByGPU,rt as sortByOrder,Me as spec,un as thresholdFrag,_t as throwDestroyedError,Jr as trailVert,Qs as translatePoint,ua as trianglesFromRect,It as unregisterPlugin,gi as valIfUndefined,$r as value,tn as valueDefine,ra as vecFill,na as vecMulCombine,Lf as version,vi as vertexFormatType2GLType};
|
|
1
|
+
import{crypto as t,screen as e,document as i,window as r,navigator as n,atob as s,Blob as a,WebGL2RenderingContext as o,WebGLRenderingContext as u,XMLHttpRequest as h,HTMLImageElement as c,URL as l,Image as f,performance as d,HTMLCanvasElement as p,HTMLVideoElement as m,location as v,TextDecoder as y,cancelAnimationFrame as g,requestAnimationFrame as x,Event as b}from"@galacean/appx-adapter/alipay";function T(t,e,i,r,n,s,a){try{var o=t[s](a),u=o.value}catch(t){return void i(t)}o.done?e(u):Promise.resolve(u).then(r,n)}function E(t){return function(){var e=this,i=arguments;return new Promise((function(r,n){var s=t.apply(e,i);function a(t){T(s,r,n,a,o,"next",t)}function o(t){T(s,r,n,a,o,"throw",t)}a(void 0)}))}}function _(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,r=new Array(e);i<e;i++)r[i]=t[i];return r}function w(t,e){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(i)return(i=i.call(t)).next.bind(i);if(Array.isArray(t)||(i=function(t,e){if(t){if("string"==typeof t)return _(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(i):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?_(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){i&&(t=i);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}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 A(t,e){return null!=e&&"undefined"!=typeof Symbol&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](t):A(t,e)}function C(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t}function S(t,e,i,r){var n,s=arguments.length,a=s<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,r);else for(var o=t.length-1;o>=0;o--)(n=t[o])&&(a=(s<3?n(a):s>3?n(e,i,a):n(e,i))||a);return s>3&&a&&Object.defineProperty(e,i,a),a}function O(t,e){var i,r,n,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=o(0),a.throw=o(1),a.return=o(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function o(o){return function(u){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;a&&(a=0,o[0]&&(s=0)),s;)try{if(i=1,r&&(n=2&o[0]?r.return:o[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,o[1])).done)return n;switch(r=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{i=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}}var R;"function"==typeof SuppressedError&&SuppressedError;var M=new Uint8Array(16);function I(){if(!R&&!(R=void 0!==t&&t.getRandomValues&&t.getRandomValues.bind(t)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return R(M)}for(var P=[],L=0;L<256;++L)P.push((L+256).toString(16).slice(1));var F,V={randomUUID:void 0!==t&&t.randomUUID&&t.randomUUID.bind(t)};function N(t,e,i){if(V.randomUUID&&!e&&!t)return V.randomUUID();var r=(t=t||{}).random||(t.rng||I)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){i=i||0;for(var n=0;n<16;++n)e[i+n]=r[n];return e}return function(t,e){return void 0===e&&(e=0),P[t[e+0]]+P[t[e+1]]+P[t[e+2]]+P[t[e+3]]+"-"+P[t[e+4]]+P[t[e+5]]+"-"+P[t[e+6]]+P[t[e+7]]+"-"+P[t[e+8]]+P[t[e+9]]+"-"+P[t[e+10]]+P[t[e+11]]+P[t[e+12]]+P[t[e+13]]+P[t[e+14]]+P[t[e+15]]}(r)}function D(t,e){return t.includes(e)||t.push(e),t}function k(t,e){var i=t.indexOf(e);return i>-1&&t.splice(i,1),t}function z(t,e,i,r){if(void 0===r&&(r=!1),!t.includes(e)&&(t.push(e),1!==t.length)){var n=t.length-1;if(n){var s=t[n];if(r)for(;t[n-1][i]<s[i]&&(t[n]=t[n-1],0!=--n););else for(;t[n-1][i]>s[i]&&(t[n]=t[n-1],0!=--n););t[n]=s}}}function U(t,e,i,r){if(void 0===r&&(r=1),t.buffer.byteLength<t.BYTES_PER_ELEMENT*e){var n=Math.ceil(e*r);Number.isNaN(i)||(n=Math.min(n,i));var s=new ArrayBuffer(t.BYTES_PER_ELEMENT*n),a=new t.constructor(s);return a.set(t),a}return t}function B(t,e){var i=[0,0,0,0];if(yt(t)){t=t.replace(/[\s\t\r\n]/g,"");var r=/rgba?\(([.\d]+),([.\d]+),([.\d]+),?([.\d]+)?\)/.exec(t);if(r){var n=+r[4];i=[+r[1],+r[2],+r[3],isNaN(n)?255:255*n]}else/^#[a-f\d]{3}$/i.test(t)?i=[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16),255]:(r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t))&&(i=[parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16),255])}else A(t,Array)&&(i=[t[0],t[1],t[2],isNaN(t[3])?255:t[3]]);if(e)for(var s=0;s<4;s++)i[s]/=255;return i}function G(t,e,i){if(t.length){for(var r,n=1;n<=t.length-1;n++){var s=t[n-1],a=t[n];if(s.stop<=e&&e<=a.stop){r=X(s.color,a.color,(e-s.stop)/(a.stop-s.stop));break}}return r||(r=t[t.length-1].color),i?r.map((function(t){return t/255})):r}return[0,0,0,0]}function j(t){var e=[];if(A(t,Array)?t.forEach((function(t){var i=t[0],r=t[1],n=t[2],s=t[3],a=t[4];e.push({stop:H(i),color:[r,n,s,a]})})):Object.keys(t).forEach((function(i){var r=B(t[i]);e.push({stop:H(i),color:r})})),(e=e.sort((function(t,e){return t.stop-e.stop}))).length){0!==e[0].stop&&e.unshift({stop:0,color:e[0].color.slice()});var i=e[e.length-1];1!==i.stop&&e.push({stop:1,color:i.color.slice()})}return e}function X(t,e,i,r){var n=[],s=1-i;if(r)for(var a=0;a<4;a++)n[a]=t[a]*s+e[a]*i;else{for(var o=0;o<3;o++)n[o]=Math.round(Math.sqrt(t[o]*t[o]*s+e[o]*e[o]*i));n[3]=Math.round(t[3]*s+e[3]*i)}return n}function H(t){var e=/^(-)?([\d+.]+)%$/.exec(t);return e?+e[2]/100*(e[1]?-1:1):+t}function Y(){if("object"==typeof e&&"object"==typeof i){var t=Math.max(i.documentElement.clientWidth,r.innerWidth||0),n=e.width/t;return Math.min(2*n,2)}return 1}function W(){return!!n.platform&&/iPad|iPhone|iPod/.test(n.platform)}function Z(){var t=n.userAgent.toLowerCase().match(/cpu (iphone )?os (.*?) like mac os/);return t?parseInt(t[2],10):0}function q(){return/\b[Aa]ndroid\b/.test(n.userAgent)}function K(){return/\bOpenHarmony\b/.test(n.userAgent)}function Q(){return q()||K()||/\b(iPad|iPhone|iPod)\b/.test(n.userAgent)}function J(){return $()||tt()}function $(){var t;return"undefined"!=typeof my&&"web"===(null==(t=my)?void 0:t.renderTarget)}function tt(){return"miniprogram"===r.__wxjs_environment}function et(t){yt(t)&&(t=B(t));for(var e=t,i={width:1,height:1,data:new Uint8Array(4)},r=i.data,n=0;n<4;n++)r[n]=e[n];return i}function it(t){var e=128,i={width:e,height:1,data:new Uint8Array(512)},r=i.data,n=j(t);if(n.length){r.set(n[0].color,0);for(var s=1;s<127;s++){for(var a=s/e,o=void 0,u=void 0,h=0;h<n.length&&(o=n[h],u=n[h+1],!(o.stop<=a&&u.stop>a));h++);var c=X(o.color,u.color,(a-o.stop)/(u.stop-o.stop));r.set(c,4*s)}r.set(n[n.length-1].color,508)}return i}function rt(t,e){void 0===e&&(e=2);var i=t.length;if(i<=1||1===e)return t;if(i<=30){for(var r=1;r<i;r++)st(t,r,e);return t}return at(t,e)}function nt(t,e,i){return void 0===i&&(i=2),t.includes(e)?t:(t.push(e),1===t.length||1!==i&&st(t,t.length-1,i),t)}function st(t,e,i){var r=t[e];if(2!==i)for(;e>=1&&t[e-1].priority<r.priority&&(t[e]=t[e-1],0!=--e););else for(;e>=1&&t[e-1].priority>r.priority&&(t[e]=t[e-1],0!=--e););t[e]=r}function at(t,e,i,r){if(void 0===i&&(i=0),void 0===r&&(r=t.length-1),i>=r)return t;for(var n,s=t[i],a=i,o=r;a<o;){if(2===e){for(;t[o].priority>s.priority&&o>=a;)o--;for(;t[a].priority<=s.priority&&a<o;)a++}else{for(;t[o].priority<s.priority&&o>=a;)o--;for(;t[a].priority>=s.priority&&a<o;)a++}var u;u=[t[o],t[a]],t[a]=u[0],t[o]=u[1]}return n=[t[a],t[i]],t[i]=n[0],t[a]=n[1],at(t,e,i,a-1),at(t,e,o+1,r),t}function ot(t,e){if(void 0===e&&(e="item doesn't exist"),null==t)throw new Error(e)}function ut(t,e){if(void 0===e&&(e="asserts failed"),!t)throw new Error(e)}function ht(t){return/^[^\d.][\w-]*$/.test(t)}!function(t){t[t.none=1]="none",t[t.ascending=2]="ascending",t[t.descending=3]="descending"}(F||(F={}));var ct,lt=function(){var t=this;this.promise=new Promise((function(e,i){t.resolve=e,t.reject=i}))},ft="[Galacean Effects]";function dt(t){return["%c"+ft,"color: #AA0100",""+t]}var pt,mt={error:function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;r<e;r++)i[r-1]=arguments[r];var n;(n=console).error.apply(n,[].concat(dt(t),[i])),null==ct||ct("error",t,i)},info:function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;r<e;r++)i[r-1]=arguments[r];var n;(n=console).debug.apply(n,[].concat(dt(t))),null==ct||ct("info",t,i)},warn:function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;r<e;r++)i[r-1]=arguments[r];var n;(n=console).warn.apply(n,[].concat(dt(t))),null==ct||ct("warn",t,i)},register:function(t){t&&xt(t)&&(ct=t)}};function vt(){}function yt(t){return"string"==typeof t}!function(t){t[t.destroy=0]="destroy",t[t.keep=1]="keep",t[t.force=0]="force"}(pt||(pt={}));var gt=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function xt(t){return"[object Function]"===Object.prototype.toString.call(t)}function bt(t){return"[object Object]"===Object.prototype.toString.call(t)}function Tt(t){var e;return"object"==typeof t&&null!==t&&"CANVAS"===(null==(e=t.tagName)?void 0:e.toUpperCase())}function Et(t,e){return t+Math.random()*(e-t)}function _t(){throw new Error("Destroyed item cannot be used again.")}function wt(){return N().replace(/-/g,"")}function At(t,e,i){void 0===e&&(e="base64File"),void 0===i&&(i="");for(var r=t.split(",")[1]||t,n=s(r),o=[],u=0;u<n.length;u+=512){for(var h=n.slice(u,u+512),c=new Array(h.length),l=0;l<h.length;l++)c[l]=h.charCodeAt(l);var f=new Uint8Array(c);o.push(f)}var d=new a(o,{type:i});return new File([d],e,{type:i})}function Ct(t,e){e.forEach((function(e){Object.getOwnPropertyNames(e.prototype).forEach((function(i){var r=Object.getOwnPropertyDescriptor(e.prototype,i);if(!r)throw new Error("Cannot find property descriptor of class "+e);Object.defineProperty(t.prototype,i,r)}))}))}var St={},Ot=[],Rt={};function Mt(t,e,i){Rt[t]&&mt.error("Duplicate registration for plugin "+t+"."),Rt[t]=i,St[t]=e,D(Ot,t)}function It(t){delete Rt[t],delete St[t],k(Ot,t)}var Pt=function(){function t(t){var e={},i=[];Ot.forEach((function(t){var r=St[t];i.includes(r)||(i.push(r),e[t]=r)}));for(var r,n=w(t);!(r=n()).done;){var s=r.value;if(!St[s])throw new Error("The plugin '"+s+"' not found."+Ft(s))}this.plugins=Object.keys(e).map((function(t){var e=new(0,St[t]);return e.name=t,e})).sort((function(t,e){return t.order-e.order}))}var e=t.prototype;return e.initializeComposition=function(t,e){this.plugins.forEach((function(i){return i.onCompositionConstructed(t,e)}))},e.destroyComposition=function(t){this.plugins.forEach((function(e){return e.onCompositionDestroyed(t)}))},e.resetComposition=function(t,e){this.plugins.forEach((function(i){return i.onCompositionReset(t,e)}))},e.processRawJSON=function(t,e){var i=this;return E((function(){return O(this,(function(r){return[2,i.callStatic("processRawJSON",t,e)]}))}))()},e.processAssets=function(t,e){var i=this;return E((function(){return O(this,(function(r){return[2,i.callStatic("processAssets",t,e)]}))}))()},e.precompile=function(t,e){for(var i,r=w(this.plugins);!(i=r()).done;){i.value.precompile(t,e)}},e.loadResources=function(t,e){var i=this;return E((function(){return O(this,(function(r){return[2,i.callStatic("prepareResource",t,e)]}))}))()},e.callStatic=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;r<e;r++)i[r-1]=arguments[r];var n=this;return E((function(){var e,r,s,a,o,u,h;return O(this,(function(c){for(e=[],r=n.plugins,s=0;s<r.length;s++)a=r[s],o=St[a.name],t in o&&e.push(Promise.resolve(null==(h=o[t])?void 0:(u=h).call.apply(u,[].concat([o],i))));return[2,Promise.all(e)]}))}))()},t}(),Lt={"alipay-downgrade":"@galacean/effects-plugin-alipay-downgrade",downgrade:"@galacean/effects-plugin-downgrade","editor-gizmo":"@galacean/effects-plugin-editor-gizmo",model:"@galacean/effects-plugin-model",video:"@galacean/effects-plugin-multimedia",audio:"@galacean/effects-plugin-multimedia","orientation-transformer":"@galacean/effects-plugin-orientation-transformer","rich-text":"@galacean/effects-plugin-rich-text",spine:"@galacean/effects-plugin-spine"};function Ft(t){var e=Lt[t];return e?"\n请按如下命令进行操作(Please follow the commands below to proceed):\n1、使用 npm 安装插件(Install Plugin):npm i "+e+"@latest --save\n2、导入插件(Import Plugin):import '"+e+"'":""}var Vt,Nt,Dt,kt,zt,Ut,Bt,Gt,jt,Xt,Ht,Yt,Wt,Zt,qt=function(){function t(){this.order=100,this.name=""}var e=t.prototype;return e.precompile=function(t,e){},e.onCompositionConstructed=function(t,e){},e.onCompositionItemLifeBegin=function(t,e){},e.onCompositionItemLifeEnd=function(t,e){},e.onCompositionItemRemoved=function(t,e){},e.onCompositionReset=function(t,e){},e.onCompositionWillReset=function(t,e){},e.onCompositionDestroyed=function(t){},e.onCompositionUpdate=function(t,e){},e.prepareRenderFrame=function(t,e){return!1},e.postProcessFrame=function(t,e){},t}();function Kt(t,e){return Kt=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},Kt(t,e)}function Qt(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Kt(t,e)}!function(t){t["1_0"]="1.0",t["1_1"]="1.1",t["1_2"]="1.2",t["1_3"]="1.3",t["1_5"]="1.5",t["1_8"]="1.8",t["2_0"]="2.0",t["2_1"]="2.1",t["2_2"]="2.2",t["2_3"]="2.3",t["2_4"]="2.4",t["3_0"]="3.0",t["3_1"]="3.1",t["3_2"]="3.2",t["3_3"]="3.3",t.LATEST="3.3"}(Vt||(Vt={})),function(t){t.S="S",t.APlus="A+",t.A="A",t.BPlus="B+",t.B="B"}(Nt||(Nt={})),function(t){t[t.ALPHA=0]="ALPHA",t[t.ADD=1]="ADD",t[t.MULTIPLY=2]="MULTIPLY",t[t.BRIGHTNESS=3]="BRIGHTNESS",t[t.SUBTRACTION=4]="SUBTRACTION",t[t.STRONG_LIGHT=5]="STRONG_LIGHT",t[t.WEAK_LIGHT=6]="WEAK_LIGHT",t[t.SUPERPOSITION=7]="SUPERPOSITION"}(Dt||(Dt={})),function(t){t[t.DOUBLE=1032]="DOUBLE",t[t.FRONT=1028]="FRONT",t[t.BACK=1029]="BACK"}(kt||(kt={})),function(t){t[t.OBSCURED=2]="OBSCURED",t[t.REVERSE_OBSCURED=3]="REVERSE_OBSCURED"}(zt||(zt={})),function(t){t[t.NONE=0]="NONE",t[t.SPHERE=1]="SPHERE",t[t.CONE=2]="CONE",t[t.HEMISPHERE=3]="HEMISPHERE",t[t.CIRCLE=4]="CIRCLE",t[t.DONUT=5]="DONUT",t[t.RECTANGLE=6]="RECTANGLE",t[t.RECTANGLE_EDGE=7]="RECTANGLE_EDGE",t[t.EDGE=8]="EDGE",t[t.TEXTURE=9]="TEXTURE"}(Ut||(Ut={})),function(t){t[t.GYROSCOPE=0]="GYROSCOPE",t[t.SPINE=1]="SPINE"}(Bt||(Bt={})),function(t){t[t.CLICK=0]="CLICK",t[t.MESSAGE=1]="MESSAGE",t[t.DRAG=2]="DRAG"}(Gt||(Gt={})),function(t){t[t.NONE=0]="NONE",t[t.NOTIFY=1]="NOTIFY",t[t.RESUME_PLAYER=2]="RESUME_PLAYER",t[t.REMOVE=3]="REMOVE",t[t.PAUSE=4]="PAUSE"}(jt||(jt={})),function(t){t.base="0",t.sprite="1",t.particle="2",t.null="3",t.interact="4",t.plugin="5",t.camera="6",t.composition="7",t.spine="spine",t.mesh="mesh",t.tree="tree",t.text="text",t.light="light",t.skybox="skybox",t.effect="effect",t.shape="shape",t.postProcessVolume="postProcessVolume",t.node="node",t.video="video",t.audio="audio",t.richtext="richtext"}(Xt||(Xt={})),function(t){t[t.BILLBOARD=0]="BILLBOARD",t[t.MESH=1]="MESH",t[t.VERTICAL_BILLBOARD=2]="VERTICAL_BILLBOARD",t[t.HORIZONTAL_BILLBOARD=3]="HORIZONTAL_BILLBOARD"}(Ht||(Ht={})),function(t){t[t.PARTICLE_ORIGIN_CENTER=0]="PARTICLE_ORIGIN_CENTER",t[t.PARTICLE_ORIGIN_LEFT_TOP=1]="PARTICLE_ORIGIN_LEFT_TOP",t[t.PARTICLE_ORIGIN_LEFT_CENTER=2]="PARTICLE_ORIGIN_LEFT_CENTER",t[t.PARTICLE_ORIGIN_LEFT_BOTTOM=3]="PARTICLE_ORIGIN_LEFT_BOTTOM",t[t.PARTICLE_ORIGIN_CENTER_TOP=4]="PARTICLE_ORIGIN_CENTER_TOP",t[t.PARTICLE_ORIGIN_CENTER_BOTTOM=5]="PARTICLE_ORIGIN_CENTER_BOTTOM",t[t.PARTICLE_ORIGIN_RIGHT_TOP=6]="PARTICLE_ORIGIN_RIGHT_TOP",t[t.PARTICLE_ORIGIN_RIGHT_CENTER=7]="PARTICLE_ORIGIN_RIGHT_CENTER",t[t.PARTICLE_ORIGIN_RIGHT_BOTTOM=8]="PARTICLE_ORIGIN_RIGHT_BOTTOM"}(Yt||(Yt={})),function(t){t.Opaque="Opaque",t.Transparent="Transparent"}(Wt||(Wt={})),function(t){t.Both="Both",t.Back="Back",t.Front="Front"}(Zt||(Zt={}));var Jt,$t,te,ee,ie,re,ne,se,ae,oe,ue,he,ce,le,fe,de,pe,me=1,ve=3,ye=0;!function(t){t[t.portrait=1]="portrait",t[t.landscape=0]="landscape"}(Jt||(Jt={})),function(t){t[t.CONSTANT=0]="CONSTANT",t[t.CONSTANT_VEC2=1]="CONSTANT_VEC2",t[t.CONSTANT_VEC3=2]="CONSTANT_VEC3",t[t.CONSTANT_VEC4=3]="CONSTANT_VEC4",t[t.RANDOM=4]="RANDOM",t[t.LINE=5]="LINE",t[t.CURVE=6]="CURVE",t[t.BEZIER_PATH=7]="BEZIER_PATH",t[t.RGBA_COLOR=8]="RGBA_COLOR",t[t.GRADIENT_COLOR=9]="GRADIENT_COLOR",t[t.SHAPE_POINTS=10]="SHAPE_POINTS",t[t.SHAPE_SPLITS=11]="SHAPE_SPLITS",t[t.LINEAR_PATH=12]="LINEAR_PATH",t[t.COLORS=13]="COLORS",t[t.BINARY=20]="BINARY",t[t.BEZIER_CURVE=21]="BEZIER_CURVE",t[t.BEZIER_CURVE_PATH=22]="BEZIER_CURVE_PATH",t[t.BEZIER_CURVE_QUAT=23]="BEZIER_CURVE_QUAT",t[t.COLOR_CURVE=24]="COLOR_CURVE",t[t.VECTOR4_CURVE=25]="VECTOR4_CURVE",t[t.VECTOR2_CURVE=26]="VECTOR2_CURVE"}($t||($t={})),function(t){t[t.AUTO=0]="AUTO",t[t.EASE=1]="EASE",t[t.EASE_IN=2]="EASE_IN",t[t.EASE_OUT=3]="EASE_OUT",t[t.LINE=4]="LINE",t[t.HOLD=5]="HOLD",t[t.LINE_OUT=6]="LINE_OUT"}(te||(te={})),function(t){t[t.destroy=0]="destroy",t[t.restart=5]="restart",t[t.forward=2]="forward",t[t.freeze=4]="freeze"}(ee||(ee={})),function(t){t[t.none=0]="none",t[t.removeParticle=1]="removeParticle"}(ie||(ie={})),function(t){t[t.RANDOM=0]="RANDOM",t[t.UNIDIRECTIONAL_CYCLE=1]="UNIDIRECTIONAL_CYCLE",t[t.BIDIRECTIONAL_CYCLE=2]="BIDIRECTIONAL_CYCLE",t[t.UNIFORM_BURST=3]="UNIFORM_BURST"}(re||(re={})),function(t){t.point="point",t.spot="spot",t.directional="directional",t.ambient="ambient"}(ne||(ne={})),function(t){t[t.box=2]="box",t[t.sphere=3]="sphere"}(se||(se={})),function(t){t.orthographic="orthographic",t.perspective="perspective"}(ae||(ae={})),function(t){t.unlit="unlit",t.pbr="pbr",t.hair="hair"}(oe||(oe={})),function(t){t[t.opaque=100]="opaque",t[t.masked=101]="masked",t[t.translucent=102]="translucent",t[t.additive=103]="additive"}(ue||(ue={})),function(t){t.none="none",t.uv="uv",t.normal="normal",t.basecolor="basecolor",t.alpha="alpha",t.metallic="metallic",t.roughness="roughness",t.ao="ao",t.emissive="emissive",t.diffuse="diffuse"}(he||(he={})),function(t){t[t.display=0]="display",t[t.clip=1]="clip",t[t.ellipsis=2]="ellipsis"}(ce||(ce={})),function(t){t[t.top=0]="top",t[t.middle=1]="middle",t[t.bottom=2]="bottom"}(le||(le={})),function(t){t[t.left=0]="left",t[t.middle=1]="middle",t[t.right=2]="right"}(fe||(fe={})),function(t){t.normal="normal",t.bold="bold",t.lighter="lighter"}(de||(de={})),function(t){t.normal="normal",t.italic="italic",t.oblique="oblique"}(pe||(pe={}));var ge,xe,be,Te,Ee,_e,we,Ae,Ce,Se,Oe={WhiteTexture:"whitetexture00000000000000000000",TransparentTexture:"transparenttexture00000000000000000000",PBRShader:"pbr00000000000000000000000000000",UnlitShader:"unlit000000000000000000000000000"};!function(t){t[t.Custom=0]="Custom",t[t.Rectangle=1]="Rectangle",t[t.Ellipse=2]="Ellipse",t[t.Polygon=3]="Polygon",t[t.Star=4]="Star"}(ge||(ge={})),function(t){t[t.Butt=0]="Butt",t[t.Round=1]="Round",t[t.Square=2]="Square"}(xe||(xe={})),function(t){t[t.Round=0]="Round",t[t.Bevel=1]="Bevel",t[t.Miter=2]="Miter"}(be||(be={})),function(t){t.video="video",t.image="image"}(Te||(Te={})),function(t){t.video="video",t.audio="audio"}(Ee||(Ee={})),function(t){t.VFXItemData="VFXItemData",t.Material="Material",t.Shader="Shader",t.Geometry="Geometry",t.Texture="Texture",t.Image="Image",t.AnimationClip="AnimationClip",t.BinaryAsset="BinaryAsset",t.TrackAsset="TrackAsset",t.TimelineAsset="TimelineAsset",t.ObjectBindingTrack="ObjectBindingTrack",t.TransformTrack="TransformTrack",t.SpriteColorTrack="SpriteColorTrack",t.ActivationTrack="ActivationTrack",t.SubCompositionTrack="SubCompositionTrack",t.FloatPropertyTrack="FloatPropertyTrack",t.ColorPropertyTrack="ColorPropertyTrack",t.Vector2PropertyTrack="Vector2PropertyTrack",t.Vector4PropertyTrack="Vector4PropertyTrack",t.TransformPlayableAsset="TransformPlayableAsset",t.SpriteColorPlayableAsset="SpriteColorPlayableAsset",t.ActivationPlayableAsset="ActivationPlayableAsset",t.SubCompositionPlayableAsset="SubCompositionPlayableAsset",t.FloatPropertyPlayableAsset="FloatPropertyPlayableAsset",t.ColorPropertyPlayableAsset="ColorPropertyPlayableAsset",t.Vector2PropertyPlayableAsset="Vector2PropertyPlayableAsset",t.Vector4PropertyPlayableAsset="Vector4PropertyPlayableAsset",t.MeshComponent="MeshComponent",t.SkyboxComponent="SkyboxComponent",t.LightComponent="LightComponent",t.CameraComponent="CameraComponent",t.ModelPluginComponent="ModelPluginComponent",t.TreeComponent="TreeComponent",t.AnimationComponent="AnimationComponent",t.SpineComponent="SpineComponent",t.VideoComponent="VideoComponent",t.AudioComponent="AudioComponent",t.RichTextComponent="RichTextComponent",t.OrientationComponent="OrientationComponent",t.ShapeComponent="ShapeComponent",t.SpriteComponent="SpriteComponent",t.ParticleSystem="ParticleSystem",t.InteractComponent="InteractComponent",t.CameraController="CameraController",t.PostProcessVolume="PostProcessVolume",t.EffectComponent="EffectComponent",t.TextComponent="TextComponent",t.TimelineClip="TimelineClip"}(_e||(_e={})),function(t){t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN"}(we||(we={})),function(t){t[t.Float16=0]="Float16",t[t.Float32=1]="Float32",t[t.Int8=2]="Int8",t[t.Int16=3]="Int16",t[t.Int32=4]="Int32",t[t.UInt8=5]="UInt8",t[t.UInt16=6]="UInt16",t[t.UInt32=7]="UInt32"}(Ae||(Ae={})),function(t){t[t.None=-1]="None",t[t.UInt8=0]="UInt8",t[t.UInt16=1]="UInt16",t[t.UInt32=2]="UInt32"}(Ce||(Ce={})),function(t){t.Position="POSITION",t.Uv="TEXCOORD0",t.Uv2="TEXCOORD1",t.Normal="NORMAL",t.Tangent="TANGENT",t.Color="COLOR",t.Joints="JOINTS",t.Weights="WEIGHTS",t.PositionBS0="POSITION_BS0",t.PositionBS1="POSITION_BS1",t.PositionBS2="POSITION_BS2",t.PositionBS3="POSITION_BS3",t.PositionBS4="POSITION_BS4",t.PositionBS5="POSITION_BS5",t.PositionBS6="POSITION_BS6",t.PositionBS7="POSITION_BS7",t.NormalBS0="NORMAL_BS0",t.NormalBS1="NORMAL_BS1",t.NormalBS2="NORMAL_BS2",t.NormalBS3="NORMAL_BS3",t.TangentBS0="TANGENT_BS0",t.TangentBS1="TANGENT_BS1",t.TangentBS2="TANGENT_BS2",t.TangentBS3="TANGENT_BS3"}(Se||(Se={}));var Re=Vt.LATEST,Me=Object.freeze({__proto__:null,LATEST_VERSION:Re,get RenderLevel(){return Nt},get BlendingMode(){return Dt},get SideMode(){return kt},get ObscuredMode(){return zt},get ParticleEmitterShapeType(){return Ut},get PluginType(){return Bt},get InteractType(){return Gt},get InteractBehavior(){return jt},get ItemType(){return Xt},get RenderMode(){return Ht},get ParticleOrigin(){return Yt},get RenderType(){return Wt},get RenderFace(){return Zt},get CameraClipMode(){return Jt},END_BEHAVIOR_DESTROY:0,END_BEHAVIOR_PAUSE:me,END_BEHAVIOR_FORWARD:2,END_BEHAVIOR_PAUSE_AND_DESTROY:ve,END_BEHAVIOR_FREEZE:4,END_BEHAVIOR_RESTART:5,END_BEHAVIOR_DESTROY_CHILDREN:6,CAMERA_CLIP_MODE_VERTICAL:1,CAMERA_CLIP_MODE_NORMAL:ye,MESSAGE_ITEM_PHRASE_BEGIN:2,MESSAGE_ITEM_PHRASE_END:1,get ValueType(){return $t},get BezierKeyframeType(){return te},get JSONSceneVersion(){return Vt},get EndBehavior(){return ee},get ParticleInteractionBehavior(){return ie},get ShapeArcMode(){return re},get LightType(){return ne},get ModelBoundingType(){return se},get CameraType(){return ae},get MaterialType(){return oe},get MaterialBlending(){return ue},get RenderMode3D(){return he},get TextOverflow(){return ce},get TextBaseline(){return le},get TextAlignment(){return fe},get TextWeight(){return de},get FontStyle(){return pe},BuiltinObjectGUID:Oe,get ShapePrimitiveType(){return ge},get LineCap(){return xe},get LineJoin(){return be},get BackgroundType(){return Te},get MultimediaType(){return Ee},get DataType(){return _e},get GeometryType(){return we},get VertexFormatType(){return Ae},get IndexFormatType(){return Ce},get VertexBufferSemantic(){return Se}});function Ie(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function Pe(t,e,i){return e&&Ie(t.prototype,e),i&&Ie(t,i),t}var Le=new Map,Fe=new Map,Ve={};function Ne(t){return function(e,i){Ve[t]&&console.warn("Class "+t+" is already registered."),Ve[t]=e}}function De(t,e){return function(t,e){return function(i,r){var n=function(t){var e=t.constructor;Le.get(e)||Le.set(e,{});return Le.get(e)}(i);n&&(n[r]||(n[r]={type:t,sourceName:e}))}}(t,e)}function ke(t){var e=t.constructor;if(Fe.get(e))return Fe.get(e);var i={};Fe.set(e,i);for(var r=t,n=e;n;){var s=Le.get(n);for(var a in s)i[a]=s[a];var o=Object.getPrototypeOf(r);if((n=Object.getPrototypeOf(o).constructor)===Object)break;r=o}return i}var ze=function(){function t(t){this.engine=t,this.guid=wt(),this.defination={},this.engine.addInstance(this)}var e=t.prototype;return e.getInstanceId=function(){return this.guid},e.setInstanceId=function(t){this.engine.removeInstance(this.guid),this.guid=t,this.engine.addInstance(this)},e.toData=function(){},e.fromData=function(t){},e.dispose=function(){},t.is=function(e){return A(e,t)&&"guid"in e},t}(),Ue=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).isAwakeCalled=!1,e.isStartCalled=!1,e.isEnableCalled=!1,e._enabled=!0,e}Qt(e,t);var i=e.prototype;return i.onAwake=function(){},i.onEnable=function(){},i.onDisable=function(){},i.onStart=function(){},i.onUpdate=function(t){},i.onLateUpdate=function(t){},i.onDestroy=function(){},i.enable=function(){this.item.composition&&(this.item.composition.sceneTicking.addComponent(this),this.isEnableCalled=!0),this.onEnable()},i.disable=function(){this.onDisable(),this.item.composition&&(this.isEnableCalled=!1,this.item.composition.sceneTicking.removeComponent(this))},i.setVFXItem=function(t){this.item=t,t.isDuringPlay&&(this.isAwakeCalled||(this.onAwake(),this.isAwakeCalled=!0),t.isActive&&this.enabled&&(this.start(),this.enable()))},i.fromData=function(e){t.prototype.fromData.call(this,e)},i.dispose=function(){this.isEnableCalled&&this.disable(),this.isAwakeCalled&&(this.isAwakeCalled=!1,this.onDestroy()),this.item&&k(this.item.components,this)},i.start=function(){this.isStartCalled||(this.isStartCalled=!0,this.onStart())},Pe(e,[{key:"transform",get:function(){return this.item.transform}},{key:"isActiveAndEnabled",get:function(){return this.item.isActive&&this.enabled}},{key:"enabled",get:function(){return this._enabled},set:function(t){this.enabled!==t&&(this._enabled=t,t?this.isActiveAndEnabled&&(this.enable(),this.isStartCalled||(this.onStart(),this.isStartCalled=!0)):this.isEnableCalled&&this.disable())}}]),e}(ze);S([De()],Ue.prototype,"item",void 0),S([De()],Ue.prototype,"_enabled",void 0);var Be=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.setVFXItem=function(e){t.prototype.setVFXItem.call(this,e)},i.dispose=function(){t.prototype.dispose.call(this)},e}(Ue),Ge=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).materials=[],e._priority=0,e}Qt(e,t);var i=e.prototype;return i.render=function(t){},i.onEnable=function(){var t;null==(t=this.item.composition)||t.renderFrame.addMeshToDefaultRenderPass(this)},i.onDisable=function(){var t;null==(t=this.item.composition)||t.renderFrame.removeMeshFromDefaultRenderPass(this)},Pe(e,[{key:"priority",get:function(){return this._priority},set:function(t){this._priority=t}},{key:"material",get:function(){return this.materials[0]},set:function(t){0===this.materials.length?this.materials.push(t):this.materials[0]=t}}]),e}(Ue);S([De()],Ge.prototype,"materials",void 0),S([De()],Ge.prototype,"_priority",void 0);var je=2*Math.PI,Xe=Math.PI/180,He=180/Math.PI,Ye=1e-6;function We(t,e){return Math.abs(t-e)<Ye||t===1/0&&e===1/0||t===-1/0&&e===-1/0}var Ze=function(t,e,i){return(1-i)*t+i*e};function qe(t,e,i){var r=isNaN(e)?-1/0:e,n=isNaN(i)?1/0:i,s=Math.min(r,n),a=Math.max(r,n);return Math.min(Math.max(t,s),a)}var Ke=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.x=t,this.y=e}var e=t.prototype;return e.set=function(t,e){return this.x=t,this.y=e,this},e.setZero=function(){return this.x=0,this.y=0,this},e.setFromNumber=function(t){return this.x=t,this.y=t,this},e.setFromArray=function(t,e){var i,r;return void 0===e&&(e=0),this.x=null!=(i=t[e])?i:0,this.y=null!=(r=t[e+1])?r:0,this},e.copyFrom=function(t){return this.x=t.x,this.y=t.y,this},e.clone=function(){return new t(this.x,this.y)},e.setElement=function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:console.error("index is out of range: "+t)}return this},e.getElement=function(t){switch(t){case 0:return this.x;case 1:return this.y;default:console.error("index is out of range: "+t)}return 0},e.add=function(t){return"number"==typeof t?(this.x+=t,this.y+=t):A(t,Array)?(this.x+=t[0],this.y+=t[1]):(this.x+=t.x,this.y+=t.y),this},e.addVectors=function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},e.subtract=function(t){return"number"==typeof t?(this.x-=t,this.y-=t):A(t,Array)?(this.x-=t[0],this.y-=t[1]):(this.x-=t.x,this.y-=t.y),this},e.subtractVectors=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},e.multiply=function(t){return"number"==typeof t?(this.x*=t,this.y*=t):A(t,Array)?(this.x*=t[0],this.y*=t[1]):(this.x*=t.x,this.y*=t.y),this},e.multiplyVectors=function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this},e.divide=function(t){return"number"==typeof t?(this.x/=t,this.y/=t):A(t,Array)?(this.x/=t[0],this.y/=t[1]):(this.x/=t.x,this.y/=t.y),this},e.scale=function(t){return this.x*=t,this.y*=t,this},e.sum=function(){return this.x+this.y},e.min=function(t){return"number"==typeof t?(this.x=Math.min(this.x,t),this.y=Math.min(this.y,t)):(this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y)),this},e.max=function(t){return"number"==typeof t?(this.x=Math.max(this.x,t),this.y=Math.max(this.y,t)):(this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y)),this},e.clamp=function(t,e){return this.max(t).min(e)},e.floor=function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},e.ceil=function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},e.round=function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},e.abs=function(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this},e.negate=function(){return this.x=-this.x,this.y=-this.y,this},e.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},e.lengthSquared=function(){return this.x*this.x+this.y*this.y},e.normalize=function(){return this.divide(this.length()||1)},e.setLength=function(t){return this.normalize().multiply(t)},e.lerp=function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},e.lerpVectors=function(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this},e.dot=function(t){return this.x*t.x+this.y*t.y},e.cross=function(t){return this.x*t.y-this.y*t.x},e.distance=function(t){var e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)},e.distanceSquared=function(t){var e=this.x-t.x,i=this.y-t.y;return e*e+i*i},e.equals=function(t){return this.x===t.x&&this.y===t.y},e.isZero=function(){var t=Ye,e=this.x,i=this.y;return Math.abs(e)<=t&&Math.abs(i)<=t},e.toArray=function(){return[this.x,this.y]},e.fill=function(t,e){void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y},e.random=function(){return this.x=Math.random(),this.y=Math.random(),this},t.fromNumber=function(e){return(new t).setFromNumber(e)},t.fromArray=function(e,i){return void 0===i&&(i=0),(new t).setFromArray(e,i)},t}();Ke.ONE=new Ke(1,1),Ke.ZERO=new Ke(0,0);var Qe=function(){function t(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this.x=t,this.y=e,this.z=i}var e=t.prototype;return e.set=function(t,e,i){return this.x=t,this.y=e,this.z=i,this},e.setZero=function(){return this.x=0,this.y=0,this.z=0,this},e.setFromNumber=function(t){return this.x=t,this.y=t,this.z=t,this},e.setFromArray=function(t,e){var i,r,n;return void 0===e&&(e=0),this.x=null!=(i=t[e])?i:0,this.y=null!=(r=t[e+1])?r:0,this.z=null!=(n=t[e+2])?n:0,this},e.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},e.clone=function(){return new t(this.x,this.y,this.z)},e.setElement=function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:console.error("index is out of range: "+t)}return this},e.getElement=function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:console.error("index is out of range: "+t)}return 0},e.add=function(t){return"number"==typeof t?(this.x+=t,this.y+=t,this.z+=t):A(t,Array)?(this.x+=t[0],this.y+=t[1],this.z+=t[2]):(this.x+=t.x,this.y+=t.y,this.z+=t.z),this},e.addVectors=function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},e.addScaledVector=function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},e.subtract=function(t){return"number"==typeof t?(this.x-=t,this.y-=t,this.z-=t):A(t,Array)?(this.x-=t[0],this.y-=t[1],this.z-=t[2]):(this.x-=t.x,this.y-=t.y,this.z-=t.z),this},e.subtractVectors=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},e.multiply=function(t){return"number"==typeof t?(this.x*=t,this.y*=t,this.z*=t):A(t,Array)?(this.x*=t[0],this.y*=t[1],this.z*=t[2]):(this.x*=t.x,this.y*=t.y,this.z*=t.z),this},e.multiplyVectors=function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},e.divide=function(t){return"number"==typeof t?(this.x/=t,this.y/=t,this.z/=t):A(t,Array)?(this.x/=t[0],this.y/=t[1],this.z/=t[2]):(this.x/=t.x,this.y/=t.y,this.z/=t.z),this},e.scale=function(t){return this.x*=t,this.y*=t,this.z*=t,this},e.sum=function(){return this.x+this.y+this.z},e.min=function(t){return"number"==typeof t?(this.x=Math.min(this.x,t),this.y=Math.min(this.y,t),this.z=Math.min(this.z,t)):(this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z)),this},e.max=function(t){return"number"==typeof t?(this.x=Math.max(this.x,t),this.y=Math.max(this.y,t),this.z=Math.max(this.z,t)):(this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z)),this},e.clamp=function(t,e){return this.max(t).min(e)},e.floor=function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},e.ceil=function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},e.round=function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},e.abs=function(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this.z=Math.abs(this.z),this},e.negate=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},e.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},e.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z},e.normalize=function(){return this.divide(this.length()||1)},e.setLength=function(t){return this.normalize().multiply(t)},e.lerp=function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},e.lerpVectors=function(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this},e.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z},e.cross=function(t){return this.crossVectors(this,t)},e.crossVectors=function(t,e){var i=t.x,r=t.y,n=t.z,s=e.x,a=e.y,o=e.z;return this.x=r*o-n*a,this.y=n*s-i*o,this.z=i*a-r*s,this},e.reflect=function(t){return this.subtract(t.clone().multiply(2*this.dot(t)))},e.distance=function(t){return Math.sqrt(this.distanceSquared(t))},e.distanceSquared=function(t){var e=this.x-t.x,i=this.y-t.y,r=this.z-t.z;return e*e+i*i+r*r},e.equals=function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},e.isZero=function(){var t=Ye,e=this,i=e.x,r=e.y,n=e.z;return Math.abs(i)<=t&&Math.abs(r)<=t&&Math.abs(n)<=t},e.toArray=function(){return[this.x,this.y,this.z]},e.toVector2=function(){return new Ke(this.x,this.y)},e.fill=function(t,e){void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z},e.random=function(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this},e.applyEuler=function(t,e){return t.rotateVector3(this,e)},e.applyQuaternion=function(t,e){return t.rotateVector3(this,e)},e.applyMatrix=function(t,e){return t.transformPoint(this,e)},e.applyNormalMatrix=function(t,e){return t.transformNormal(this,e)},e.applyProjectionMatrix=function(t,e){return t.projectPoint(this,e)},t.fromNumber=function(e){return(new t).setFromNumber(e)},t.fromArray=function(e,i){return void 0===i&&(i=0),(new t).setFromArray(e,i)},t}();Qe.X=new Qe(1,0,0),Qe.Y=new Qe(0,1,0),Qe.Z=new Qe(0,0,1),Qe.ONE=new Qe(1,1,1),Qe.ZERO=new Qe(0,0,0);var Je=function(){function t(t,e,i,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=0),this.x=t,this.y=e,this.z=i,this.w=r}var e=t.prototype;return e.set=function(t,e,i,r){return this.x=t,this.y=e,this.z=i,this.w=r,this},e.setZero=function(){return this.x=0,this.y=0,this.z=0,this.w=0,this},e.setFromNumber=function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},e.setFromArray=function(t,e){var i,r,n,s;return void 0===e&&(e=0),this.x=null!=(i=t[e])?i:0,this.y=null!=(r=t[e+1])?r:0,this.z=null!=(n=t[e+2])?n:0,this.w=null!=(s=t[e+3])?s:0,this},e.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},e.clone=function(){return new t(this.x,this.y,this.z,this.w)},e.setElement=function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:console.error("index is out of range: "+t)}return this},e.getElement=function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:console.error("index is out of range: "+t)}return 0},e.add=function(t){return"number"==typeof t?(this.x+=t,this.y+=t,this.z+=t,this.w+=t):A(t,Array)?(this.x+=t[0],this.y+=t[1],this.z+=t[2],this.w+=t[3]):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w),this},e.addVectors=function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this},e.addScaledVector=function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this},e.subtract=function(t){return"number"==typeof t?(this.x-=t,this.y-=t,this.z-=t,this.w-=t):A(t,Array)?(this.x-=t[0],this.y-=t[1],this.z-=t[2],this.w-=t[3]):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w),this},e.subtractVectors=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},e.multiply=function(t){return"number"==typeof t?(this.x*=t,this.y*=t,this.z*=t,this.w*=t):A(t,Array)?(this.x*=t[0],this.y*=t[1],this.z*=t[2],this.w*=t[3]):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w),this},e.multiplyVectors=function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this.w=t.w*e.w,this},e.divide=function(t){return"number"==typeof t?(this.x/=t,this.y/=t,this.z/=t,this.w/=t):A(t,Array)?(this.x/=t[0],this.y/=t[1],this.z/=t[2],this.w/=t[3]):(this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w),this},e.scale=function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},e.sum=function(){return this.x+this.y+this.z+this.w},e.min=function(t){return"number"==typeof t?(this.x=Math.min(this.x,t),this.y=Math.min(this.y,t),this.z=Math.min(this.z,t),this.w=Math.min(this.w,t)):(this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w)),this},e.max=function(t){return"number"==typeof t?(this.x=Math.max(this.x,t),this.y=Math.max(this.y,t),this.z=Math.max(this.z,t),this.w=Math.max(this.w,t)):(this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w)),this},e.clamp=function(t,e){return this.max(t).min(e)},e.floor=function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},e.ceil=function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},e.round=function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},e.abs=function(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this.z=Math.abs(this.z),this.w=Math.abs(this.w),this},e.negate=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},e.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},e.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},e.normalize=function(){return this.divide(this.length()||1)},e.setLength=function(t){return this.normalize().multiply(t)},e.lerp=function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this},e.lerpVectors=function(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this.w=t.w+(e.w-t.w)*i,this},e.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},e.equals=function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},e.isZero=function(){var t=Ye,e=this,i=e.x,r=e.y,n=e.z,s=e.w;return Math.abs(i)<=t&&Math.abs(r)<=t&&Math.abs(n)<=t&&Math.abs(s)<=t},e.toArray=function(){return[this.x,this.y,this.z,this.w]},e.toVector3=function(){return new Qe(this.x,this.y,this.z)},e.fill=function(t,e){void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w},e.random=function(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this},e.applyMatrix=function(t,e){return t.transformVector4(this,e)},t.fromNumber=function(e){return(new t).setFromNumber(e)},t.fromArray=function(e,i){return void 0===i&&(i=0),(new t).setFromArray(e,i)},t}();Je.ONE=new Je(1,1,1,1),Je.ZERO=new Je(0,0,0,0);var $e=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).meshCollider=new ro,e.getHitTestParams=function(t){var i=e.transform.getWorldMatrix();e.meshCollider.setGeometry(e.geometry,i);var r=e.meshCollider.getBoundingBoxData();if(r)return{type:r.type,triangles:r.area}},e}Qt(e,t);var i=e.prototype;return i.render=function(t){t.renderingData.currentFrame.globalUniforms&&t.setGlobalMatrix("effects_ObjectToWorld",this.transform.getWorldMatrix());for(var e=0;e<this.materials.length;e++)t.drawGeometry(this.geometry,this.materials[e],e)},i.getBoundingBox=function(){var t=this.transform.getWorldMatrix();return this.meshCollider.setGeometry(this.geometry,t),this.meshCollider.getBoundingBox()},e}(Ge);S([De()],$e.prototype,"geometry",void 0);var ti=function(t){function e(e){var i;return(i=t.call(this,e)||this).name="EffectComponent",i}Qt(e,t);var i=e.prototype;return i.onStart=function(){this.item.getHitTestParams=this.getHitTestParams},i.onUpdate=function(t){var e,i=this.item.time,r=null!=(e=this.material.getVector4("_Time"))?e:new Je;this.material.setVector4("_Time",r.set(i/20,i,2*i,3*i))},i.fromData=function(e){t.prototype.fromData.call(this,e),this.material=this.materials[0]},e}($e);ti=S([Ne(_e.EffectComponent)],ti);var ei=function(t){function e(e){var i;return(i=t.call(this,e)||this).bloom={threshold:0,intensity:0,active:!1},i.vignette={intensity:0,smoothness:0,roundness:0,active:!1},i.tonemapping={active:!1},i.colorAdjustments={brightness:0,saturation:0,contrast:0,active:!1},i}return Qt(e,t),e.prototype.onStart=function(){var t=this.item.composition;t&&(t.renderFrame.globalVolume=this)},e}(Ue);S([De()],ei.prototype,"bloom",void 0),S([De()],ei.prototype,"vignette",void 0),S([De()],ei.prototype,"tonemapping",void 0),S([De()],ei.prototype,"colorAdjustments",void 0),ei=S([Ne(_e.PostProcessVolume)],ei);var ii=function(){function t(t,e,i,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=0),this.r=t,this.g=e,this.b=i,this.a=r}var e=t.prototype;return e.set=function(t,e,i,r){return this.r=t,this.g=e,this.b=i,this.a=r,this},e.setZero=function(){return this.r=0,this.g=0,this.b=0,this.a=0,this},e.setFromNumber=function(t){return this.r=t,this.g=t,this.b=t,this.a=t,this},e.setFromVector4=function(t){return this.r=t.x,this.g=t.y,this.b=t.z,this.a=t.w,this},e.setFromArray=function(t,e){var i,r,n,s;return void 0===e&&(e=0),this.r=null!=(i=t[e])?i:0,this.g=null!=(r=t[e+1])?r:0,this.b=null!=(n=t[e+2])?n:0,this.a=null!=(s=t[e+3])?s:0,this},e.setFromHSV=function(t,e,i,r){void 0===r&&(r=1);var n=i*e,s=t/60,a=n*(1-Math.abs(s%2-1)),o=0,u=0,h=0;s>=0&&s<=1?(o=n,u=a):s>=1&&s<=2?(o=a,u=n):s>=2&&s<=3?(u=n,h=a):s>=3&&s<=4?(u=a,h=n):s>=4&&s<=5?(o=a,h=n):s>=5&&s<=6&&(o=n,h=a);var c=i-n;return this.set(o+c,u+c,h+c,r)},e.setFromHexString=function(t){if("#"!==t.substring(0,1)||9!==t.length&&7!==t.length)return this;var e=parseInt(t.substring(1,3),16)/255,i=parseInt(t.substring(3,5),16)/255,r=parseInt(t.substring(5,7),16)/255,n=9===t.length?parseInt(t.substring(7,9),16)/255:1;return this.set(e,i,r,n)},e.copyFrom=function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this},e.clone=function(){return new t(this.r,this.g,this.b,this.a)},e.setElement=function(t,e){switch(t){case 0:this.r=e;break;case 1:this.g=e;break;case 2:this.b=e;break;case 3:this.a=e;break;default:console.error("index is out of range: "+t)}return this},e.getElement=function(t){switch(t){case 0:return this.r;case 1:return this.g;case 2:return this.b;case 3:return this.a;default:console.error("index is out of range: "+t)}return 0},e.add=function(t){return"number"==typeof t?(this.r+=t,this.g+=t,this.b+=t,this.a+=t):A(t,Array)?(this.r+=t[0],this.g+=t[1],this.b+=t[2],this.a+=t[3]):(this.r+=t.r,this.g+=t.g,this.b+=t.b,this.a+=t.a),this},e.subtract=function(t){return"number"==typeof t?(this.r-=t,this.g-=t,this.b-=t,this.a-=t):A(t,Array)?(this.r-=t[0],this.g-=t[1],this.b-=t[2],this.a-=t[3]):(this.r-=t.r,this.g-=t.g,this.b-=t.b,this.a-=t.a),this},e.multiply=function(t){return"number"==typeof t?(this.r*=t,this.g*=t,this.b*=t,this.a*=t):A(t,Array)?(this.r*=t[0],this.g*=t[1],this.b*=t[2],this.a*=t[3]):(this.r*=t.r,this.g*=t.g,this.b*=t.b,this.a*=t.a),this},e.divide=function(t){return"number"==typeof t?(this.r/=t,this.g/=t,this.b/=t,this.a/=t):A(t,Array)?(this.r/=t[0],this.g/=t[1],this.b/=t[2],this.a/=t[3]):(this.r/=t.r,this.g/=t.g,this.b/=t.b,this.a/=t.a),this},e.scale=function(t){return this.r*=t,this.g*=t,this.b*=t,this.a*=t,this},e.min=function(t){return"number"==typeof t?(this.r=Math.min(this.r,t),this.g=Math.min(this.g,t),this.b=Math.min(this.b,t),this.a=Math.min(this.a,t)):(this.r=Math.min(this.r,t.r),this.g=Math.min(this.g,t.g),this.b=Math.min(this.b,t.b),this.a=Math.min(this.a,t.a)),this},e.max=function(t){return"number"==typeof t?(this.r=Math.max(this.r,t),this.g=Math.max(this.g,t),this.b=Math.max(this.b,t),this.a=Math.max(this.a,t)):(this.r=Math.max(this.r,t.r),this.g=Math.max(this.g,t.g),this.b=Math.max(this.b,t.b),this.a=Math.max(this.a,t.a)),this},e.clamp=function(t,e){return this.max(t).min(e)},e.lerp=function(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this.a+=(t.a-this.a)*e,this},e.luminance=function(){return.3*this.r+.59*this.g+.11*this.b},e.equals=function(t){return t.r===this.r&&t.g===this.g&&t.b===this.b&&t.a===this.a},e.toLinear=function(){return this.r=t.gammaToLinear(this.r),this.g=t.gammaToLinear(this.g),this.b=t.gammaToLinear(this.b),this},e.toGamma=function(){return this.r=t.linearToGamma(this.r),this.g=t.linearToGamma(this.g),this.b=t.linearToGamma(this.b),this},e.toArray=function(){return[this.r,this.g,this.b,this.a]},e.toVector4=function(){return new Je(this.r,this.g,this.b,this.a)},e.toHSV=function(){var e=this,i=e.r,r=e.g,n=e.b,s=e.a,a=Math.max(i,r,n),o=Math.min(i,r,n),u=a-o,h=0,c=0;return 0!==a&&(c=u/a),a!=o&&(a==i?(h=(r-n)/u,r<n&&(h+=6)):a==r?h=(n-i)/u+2:a==n&&(h=(i-r)/u+4),h*=60),new t(h,c,a,s)},e.toHexString=function(e){void 0===e&&(e=!0);var i=t.ToHex(Math.round(255*this.r)),r=t.ToHex(Math.round(255*this.g)),n=t.ToHex(Math.round(255*this.b)),s=t.ToHex(Math.round(255*this.a));return e?"#"+i+r+n+s:"#"+i+r+n},e.fill=function(t,e){void 0===e&&(e=0),t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t[e+3]=this.a},t.fromNumber=function(e){return(new t).setFromNumber(e)},t.fromArray=function(e,i){return void 0===i&&(i=0),(new t).setFromArray(e,i)},t.fromHexString=function(e){return(new t).setFromHexString(e)},t.fromHSV=function(e,i,r,n){return void 0===n&&(n=1),(new t).setFromHSV(e,i,r,n)},t.gammaToLinear=function(t){return t<=0?0:t<=.04045?t/12.92:t<1?Math.pow((t+.055)/1.055,2.4):Math.pow(t,2.4)},t.linearToGamma=function(t){return t<=0?0:t<.0031308?12.92*t:t<1?1.055*Math.pow(t,.41666)-.055:Math.pow(t,.41666)},t.ToHex=function(t){var e=t.toString(16);return t<=15?("0"+e).toUpperCase():e.toUpperCase()},t}();ii.BLACK=new ii(0,0,0,1),ii.BLUE=new ii(0,0,1,1),ii.CLEAR=new ii(0,0,0,0),ii.CYAN=new ii(0,1,1,1),ii.GRAY=new ii(.5,.5,.5,1),ii.GREEN=new ii(0,1,0,1),ii.MAGENTA=new ii(1,0,1,1),ii.RED=new ii(1,0,0,1),ii.WHITE=new ii(1,1,1,1),ii.YELLOW=new ii(1,.92,.016,1);var ri=function(){function t(t,e,i,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=1),this.x=t,this.y=e,this.z=i,this.w=r}var e=t.prototype;return e.set=function(t,e,i,r){return this.x=t,this.y=e,this.z=i,this.w=r,this},e.setFromEuler=function(t){return t.toQuaternion(this),this},e.setFromAxisAngle=function(e,i){var r=i/2,n=Math.sin(r),s=t.tempVec0;return s.copyFrom(e).normalize(),this.x=s.x*n,this.y=s.y*n,this.z=s.z*n,this.w=Math.cos(r),this},e.setFromVector4=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},e.setFromArray=function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this},e.setFromRotationMatrix=function(t){var e=t.elements,i=e[0],r=e[4],n=e[8],s=e[1],a=e[5],o=e[9],u=e[2],h=e[6],c=e[10],l=i+a+c;if(l>0){var f=.5/Math.sqrt(l+1);this.w=.25/f,this.x=(h-o)*f,this.y=(n-u)*f,this.z=(s-r)*f}else if(i>a&&i>c){var d=2*Math.sqrt(1+i-a-c);this.w=(h-o)/d,this.x=.25*d,this.y=(r+s)/d,this.z=(n+u)/d,this.negate()}else if(a>c){var p=2*Math.sqrt(1+a-i-c);this.w=(n-u)/p,this.x=(r+s)/p,this.y=.25*p,this.z=(o+h)/p,this.negate()}else{var m=2*Math.sqrt(1+c-i-a);this.w=(s-r)/m,this.x=(n+u)/m,this.y=(o+h)/m,this.z=.25*m,this.negate()}return this},e.setFromUnitVectors=function(t,e){var i=t.dot(e)+1;return i<Number.EPSILON?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this.x=-t.y,this.y=t.x,this.z=0,this.w=i):(this.x=0,this.y=-t.z,this.z=t.y,this.w=i)):(this.x=t.y*e.z-t.z*e.y,this.y=t.z*e.x-t.x*e.z,this.z=t.x*e.y-t.y*e.x,this.w=i),this.normalize()},e.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},e.clone=function(){return new t(this.x,this.y,this.z,this.w)},e.angleTo=function(t){return 2*Math.acos(Math.abs(qe(this.dot(t),-1,1)))},e.rotateTowards=function(t,e){var i=this.angleTo(t);if(0===i)return this;var r=Math.min(1,e/i);return this.slerp(t,r),this},e.identity=function(){return this.set(0,0,0,1)},e.invert=function(){return this.conjugate()},e.negate=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},e.conjugate=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},e.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},e.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},e.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},e.normalize=function(){var t=this.length();return 0===t?(this.x=0,this.y=0,this.z=0,this.w=1):(t=1/t,this.x=this.x*t,this.y=this.y*t,this.z=this.z*t,this.w=this.w*t),this},e.multiply=function(t){return this.multiplyQuaternions(this,t)},e.premultiply=function(t){return this.multiplyQuaternions(t,this)},e.multiplyQuaternions=function(t,e){var i=t.x,r=t.y,n=t.z,s=t.w,a=e.x,o=e.y,u=e.z,h=e.w;return this.x=i*h+s*a+r*u-n*o,this.y=r*h+s*o+n*a-i*u,this.z=n*h+s*u+i*o-r*a,this.w=s*h-i*a-r*o-n*u,this},e.slerp=function(t,e){if(0===e)return this;if(1===e)return this.copyFrom(t);var i=this,r=i.x,n=i.y,s=i.z,a=i.w,o=a*t.w+r*t.x+n*t.y+s*t.z;if(o<0?(this.w=-t.w,this.x=-t.x,this.y=-t.y,this.z=-t.z,o=-o):this.copyFrom(t),o>=1)return this.w=a,this.x=r,this.y=n,this.z=s,this;var u=1-o*o;if(u<=Number.EPSILON){var h=1-e;return this.w=h*a+e*this.w,this.x=h*r+e*this.x,this.y=h*n+e*this.y,this.z=h*s+e*this.z,this.normalize(),this}var c=Math.sqrt(u),l=Math.atan2(c,o),f=Math.sin((1-e)*l)/c,d=Math.sin(e*l)/c;return this.w=a*f+this.w*d,this.x=r*f+this.x*d,this.y=n*f+this.y*d,this.z=s*f+this.z*d,this},e.slerpQuaternions=function(t,e,i){this.copyFrom(t).slerp(e,i)},e.rotateVector3=function(t,e){var i=this,r=i.x,n=i.y,s=i.z,a=i.w,o=t.x,u=t.y,h=t.z,c=a*o+n*h-s*u,l=a*u+s*o-r*h,f=a*h+r*u-n*o,d=-r*o-n*u-s*h,p=null!=e?e:t;return p.x=c*a+d*-r+l*-s-f*-n,p.y=l*a+d*-n+f*-r-c*-s,p.z=f*a+d*-s+c*-n-l*-r,p},e.equals=function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},e.toArray=function(){return[this.x,this.y,this.z,this.w]},e.toVector4=function(t){return t.set(this.x,this.y,this.z,this.w)},e.toEuler=function(t){return t.setFromQuaternion(this)},e.toMatrix4=function(t){return t.compose(Qe.ZERO,this,Qe.ONE)},t.fromEuler=function(e){return(new t).setFromEuler(e)},t.fromAxisAngle=function(e,i){return(new t).setFromAxisAngle(e,i)},t.fromVector4=function(e){return(new t).setFromVector4(e)},t.fromArray=function(e,i){return void 0===i&&(i=0),(new t).setFromArray(e,i)},t.fromRotationMatrix=function(e){return(new t).setFromRotationMatrix(e)},t.fromUnitVectors=function(e,i){return(new t).setFromUnitVectors(e,i)},t}();ri.tempVec0=new Qe;var ni=function(){function t(t,e,i,r,n,s,a,o,u,h,c,l,f,d,p,m){void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=0),void 0===s&&(s=1),void 0===a&&(a=0),void 0===o&&(o=0),void 0===u&&(u=0),void 0===h&&(h=0),void 0===c&&(c=1),void 0===l&&(l=0),void 0===f&&(f=0),void 0===d&&(d=0),void 0===p&&(p=0),void 0===m&&(m=1),this.elements=[t,e,i,r,n,s,a,o,u,h,c,l,f,d,p,m]}var e=t.prototype;return e.set=function(t,e,i,r,n,s,a,o,u,h,c,l,f,d,p,m){var v=this.elements;return v[0]=t,v[1]=e,v[2]=i,v[3]=r,v[4]=n,v[5]=s,v[6]=a,v[7]=o,v[8]=u,v[9]=h,v[10]=c,v[11]=l,v[12]=f,v[13]=d,v[14]=p,v[15]=m,this},e.setFromRowMajorData=function(t,e,i,r,n,s,a,o,u,h,c,l,f,d,p,m){var v=this.elements;return v[0]=t,v[4]=e,v[8]=i,v[12]=r,v[1]=n,v[5]=s,v[9]=a,v[13]=o,v[2]=u,v[6]=h,v[10]=c,v[14]=l,v[3]=f,v[7]=d,v[11]=p,v[15]=m,this},e.setFromColumnVectors=function(t,e,i,r){return this.set(t.x,t.y,t.z,t.w,e.x,e.y,e.z,e.w,i.x,i.y,i.z,i.w,r.x,r.y,r.z,r.w)},e.setFromMatrix3=function(t){var e=t.elements;return this.set(e[0],e[1],e[2],0,e[3],e[4],e[5],0,e[6],e[7],e[8],0,0,0,0,1),this},e.setFromArray=function(t,e){void 0===e&&(e=0);for(var i=0;i<16;i++)this.elements[i]=t[e+i];return this},e.setFromScale=function(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1)},e.setFromTranslation=function(t,e,i){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,t,e,i,1)},e.setFromRotationX=function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,i,0,0,-i,e,0,0,0,0,1)},e.setFromRotationY=function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(e,0,-i,0,0,1,0,0,i,0,e,0,0,0,0,1)},e.setFromRotationZ=function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(e,i,0,0,-i,e,0,0,0,0,1,0,0,0,0,1)},e.setFromRotationAxis=function(e,i){var r=t.tempVec0;r.copyFrom(e).normalize();var n=Math.cos(i),s=Math.sin(i),a=1-n,o=r.x,u=r.y,h=r.z,c=a*o,l=a*u;return this.set(c*o+n,c*u+s*h,c*h-s*u,0,c*u-s*h,l*u+n,l*h+s*o,0,c*h+s*u,l*h-s*o,a*h*h+n,0,0,0,0,1)},e.setFromEuler=function(t){return t.toMatrix4(this),this},e.setFromQuaternion=function(t){return this.compose(Qe.ZERO,t,Qe.ONE)},e.setFromShear=function(t,e,i){return this.set(1,t,t,0,e,1,e,0,i,i,1,0,0,0,0,1)},e.setFromBasis=function(t,e,i){return this.set(t.x,t.y,t.z,0,e.x,e.y,e.z,0,i.x,i.y,i.z,0,0,0,0,1)},e.setZero=function(){for(var t=0;t<16;t++)this.elements[t]=0;return this},e.identity=function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},e.isIdentity=function(){var t=this.elements;return 1===t[0]&&0===t[4]&&0===t[8]&&0===t[12]&&0===t[1]&&1===t[5]&&0===t[9]&&0===t[13]&&0===t[2]&&0===t[6]&&1===t[10]&&0===t[14]&&0===t[3]&&0===t[7]&&0===t[11]&&1===t[15]},e.clone=function(){var e=this.elements;return new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])},e.copyFrom=function(t){return this.elements=[].concat(t.elements),this},e.getColumnVector=function(t,e){return e.set(this.elements[4*t],this.elements[4*t+1],this.elements[4*t+2],this.elements[4*t+3])},e.lookAt=function(e,i,r){var n=t.tempVec0,s=t.tempVec1,a=t.tempVec2;a.subtractVectors(e,i),a.normalize(),n.crossVectors(r,a),n.normalize(),s.crossVectors(a,n);var o=this.elements;return o[0]=n.x,o[1]=s.x,o[2]=a.x,o[3]=0,o[4]=n.y,o[5]=s.y,o[6]=a.y,o[7]=0,o[8]=n.z,o[9]=s.z,o[10]=a.z,o[11]=0,o[12]=-n.dot(e),o[13]=-s.dot(e),o[14]=-a.dot(e),o[15]=1,this},e.addScaledMatrix=function(t,e){for(var i=this.elements,r=t.elements,n=0;n<16;n++)i[n]+=r[n]*e;return this},e.multiply=function(t){if("number"==typeof t){for(var e=0;e<16;e++)this.elements[e]*=t;return this}return this.multiplyMatrices(this,t)},e.premultiply=function(t){return this.multiplyMatrices(t,this)},e.multiplyMatrices=function(t,e){var i=t.elements,r=e.elements,n=this.elements,s=i[0],a=i[4],o=i[8],u=i[12],h=i[1],c=i[5],l=i[9],f=i[13],d=i[2],p=i[6],m=i[10],v=i[14],y=i[3],g=i[7],x=i[11],b=i[15],T=r[0],E=r[4],_=r[8],w=r[12],A=r[1],C=r[5],S=r[9],O=r[13],R=r[2],M=r[6],I=r[10],P=r[14],L=r[3],F=r[7],V=r[11],N=r[15];return n[0]=s*T+a*A+o*R+u*L,n[4]=s*E+a*C+o*M+u*F,n[8]=s*_+a*S+o*I+u*V,n[12]=s*w+a*O+o*P+u*N,n[1]=h*T+c*A+l*R+f*L,n[5]=h*E+c*C+l*M+f*F,n[9]=h*_+c*S+l*I+f*V,n[13]=h*w+c*O+l*P+f*N,n[2]=d*T+p*A+m*R+v*L,n[6]=d*E+p*C+m*M+v*F,n[10]=d*_+p*S+m*I+v*V,n[14]=d*w+p*O+m*P+v*N,n[3]=y*T+g*A+x*R+b*L,n[7]=y*E+g*C+x*M+b*F,n[11]=y*_+g*S+x*I+b*V,n[15]=y*w+g*O+x*P+b*N,this},e.multiplyScalar=function(t){var e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this},e.determinant=function(){var t=this.elements,e=t[0],i=t[4],r=t[8],n=t[12],s=t[1],a=t[5],o=t[9],u=t[13],h=t[2],c=t[6],l=t[10],f=t[14];return t[3]*(+n*o*c-r*u*c-n*a*l+i*u*l+r*a*f-i*o*f)+t[7]*(+e*o*f-e*u*l+n*s*l-r*s*f+r*u*h-n*o*h)+t[11]*(+e*u*c-e*a*f-n*s*c+i*s*f+n*a*h-i*u*h)+t[15]*(-r*a*h-e*o*c+e*a*l+r*s*c-i*s*l+i*o*h)},e.transpose=function(){var t,e=this.elements;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this},e.invert=function(){var t=this.elements,e=t[0],i=t[1],r=t[2],n=t[3],s=t[4],a=t[5],o=t[6],u=t[7],h=t[8],c=t[9],l=t[10],f=t[11],d=t[12],p=t[13],m=t[14],v=t[15],y=c*m*u-p*l*u+p*o*f-a*m*f-c*o*v+a*l*v,g=d*l*u-h*m*u-d*o*f+s*m*f+h*o*v-s*l*v,x=h*p*u-d*c*u+d*a*f-s*p*f-h*a*v+s*c*v,b=d*c*o-h*p*o-d*a*l+s*p*l+h*a*m-s*c*m,T=e*y+i*g+r*x+n*b;if(0===T)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);var E=1/T;return t[0]=y*E,t[1]=(p*l*n-c*m*n-p*r*f+i*m*f+c*r*v-i*l*v)*E,t[2]=(a*m*n-p*o*n+p*r*u-i*m*u-a*r*v+i*o*v)*E,t[3]=(c*o*n-a*l*n-c*r*u+i*l*u+a*r*f-i*o*f)*E,t[4]=g*E,t[5]=(h*m*n-d*l*n+d*r*f-e*m*f-h*r*v+e*l*v)*E,t[6]=(d*o*n-s*m*n-d*r*u+e*m*u+s*r*v-e*o*v)*E,t[7]=(s*l*n-h*o*n+h*r*u-e*l*u-s*r*f+e*o*f)*E,t[8]=x*E,t[9]=(d*c*n-h*p*n-d*i*f+e*p*f+h*i*v-e*c*v)*E,t[10]=(s*p*n-d*a*n+d*i*u-e*p*u-s*i*v+e*a*v)*E,t[11]=(h*a*n-s*c*n-h*i*u+e*c*u+s*i*f-e*a*f)*E,t[12]=b*E,t[13]=(h*p*r-d*c*r+d*i*l-e*p*l-h*i*m+e*c*m)*E,t[14]=(d*a*r-s*p*r-d*i*o+e*p*o+s*i*m-e*a*m)*E,t[15]=(s*c*r-h*a*r+h*i*o-e*c*o-s*i*l+e*a*l)*E,this},e.extractBasis=function(t,e,i){var r=this.elements;return t.set(r[0],r[1],r[2]),e.set(r[4],r[5],r[6]),i.set(r[8],r[9],r[10]),this},e.compose=function(t,e,i,r){void 0===r&&(r=Qe.ZERO);var n=this.elements,s=e.x,a=e.y,o=e.z,u=e.w,h=-r.x,c=-r.y,l=-r.z,f=s+s,d=a+a,p=o+o,m=s*f,v=s*d,y=s*p,g=a*d,x=a*p,b=o*p,T=u*f,E=u*d,_=u*p,w=i.x,A=i.y,C=i.z;return n[0]=(1-(g+b))*w,n[1]=(v+_)*w,n[2]=(y-E)*w,n[3]=0,n[4]=(v-_)*A,n[5]=(1-(m+b))*A,n[6]=(x+T)*A,n[7]=0,n[8]=(y+E)*C,n[9]=(x-T)*C,n[10]=(1-(m+g))*C,n[11]=0,n[12]=h*n[0]+c*n[4]+l*n[8]-h+t.x,n[13]=h*n[1]+c*n[5]+l*n[9]-c+t.y,n[14]=h*n[2]+c*n[6]+l*n[10]-l+t.z,this},e.decompose=function(e,i,r){var n=t.tempVec0,s=this.elements,a=n.set(s[0],s[1],s[2]).length(),o=n.set(s[4],s[5],s[6]).length(),u=n.set(s[8],s[9],s[10]).length();this.determinant()<0&&(a=-a),e.x=s[12],e.y=s[13],e.z=s[14];var h=t.tempMat0;h.copyFrom(this);var c=1/a,l=1/o,f=1/u;return h.elements[0]*=c,h.elements[1]*=c,h.elements[2]*=c,h.elements[4]*=l,h.elements[5]*=l,h.elements[6]*=l,h.elements[8]*=f,h.elements[9]*=f,h.elements[10]*=f,i.setFromRotationMatrix(h),r.x=a,r.y=o,r.z=u,this},e.getTranslation=function(t){var e=this.elements;return t.set(e[12],e[13],e[14])},e.getScale=function(t){var e=this.elements;return t.set(Math.hypot(e[0],e[1],e[2]),Math.hypot(e[4],e[5],e[6]),Math.hypot(e[8],e[9],e[10]))},e.getTransform=function(){var t=new Qe,e=new ri,i=new Qe;return this.decompose(t,e,i),{translation:t,rotation:e,scale:i}},e.orthographic=function(t,e,i,r,n,s){var a=1/(e-t),o=1/(i-r),u=1/(s-n),h=-(e+t)*a,c=-(i+r)*o,l=-(s+n)*u;a*=2,o*=2,u*=-2;var f=this.elements;return f[0]=a,f[1]=0,f[2]=0,f[3]=0,f[4]=0,f[5]=o,f[6]=0,f[7]=0,f[8]=0,f[9]=0,f[10]=u,f[11]=0,f[12]=h,f[13]=c,f[14]=l,f[15]=1,this},e.perspective=function(t,e,i,r,n){var s=1/Math.tan(.5*t),a=1/(i-r),o=this.elements;return o[0]=n?s:s/e,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=n?s*e:s,o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=(r+i)*a,o[11]=-1,o[12]=0,o[13]=0,o[14]=2*r*i*a,o[15]=0,null!==r&&r!==1/0||(o[10]=-1,o[14]=-2*i),this},e.projectPoint=function(t,e){var i=t.x,r=t.y,n=t.z,s=this.elements,a=null!=e?e:t;a.x=s[0]*i+s[4]*r+s[8]*n+s[12],a.y=s[1]*i+s[5]*r+s[9]*n+s[13],a.z=s[2]*i+s[6]*r+s[10]*n+s[14];var o=s[3]*i+s[7]*r+s[11]*n+s[15];return a.multiply(1/o)},e.transformPoint=function(t,e){var i=t.x,r=t.y,n=t.z,s=this.elements,a=null!=e?e:t;return a.x=s[0]*i+s[4]*r+s[8]*n+s[12],a.y=s[1]*i+s[5]*r+s[9]*n+s[13],a.z=s[2]*i+s[6]*r+s[10]*n+s[14],a},e.transformNormal=function(t,e){var i=t.x,r=t.y,n=t.z,s=this.elements,a=null!=e?e:t;return a.x=s[0]*i+s[4]*r+s[8]*n,a.y=s[1]*i+s[5]*r+s[9]*n,a.z=s[2]*i+s[6]*r+s[10]*n,a.normalize()},e.transformVector4=function(t,e){var i=t.x,r=t.y,n=t.z,s=t.w,a=this.elements,o=null!=e?e:t;return o.x=a[0]*i+a[4]*r+a[8]*n+a[12]*s,o.y=a[1]*i+a[5]*r+a[9]*n+a[13]*s,o.z=a[2]*i+a[6]*r+a[10]*n+a[14]*s,o.w=a[3]*i+a[7]*r+a[11]*n+a[15]*s,o},e.equals=function(t){for(var e=this.elements,i=t.elements,r=0;r<16;r++)if(!We(e[r],i[r]))return!1;return!0},e.toArray=function(){return[].concat(this.elements)},e.fill=function(t,e){void 0===e&&(e=0);var i=this.elements;t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15]},t.fromIdentity=function(){return new t(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},t.fromLookAt=function(e,i,r){return(new t).lookAt(e,i,r)},t.fromPerspective=function(e,i,r,n,s){return(new t).perspective(e,i,r,n,s)},t.fromColumnVectors=function(e,i,r,n){return(new t).setFromColumnVectors(e,i,r,n)},t.fromMatrix3=function(e){return(new t).setFromMatrix3(e)},t.fromArray=function(e,i){return void 0===i&&(i=0),(new t).setFromArray(e,i)},t.fromScale=function(e,i,r){return(new t).setFromScale(e,i,r)},t.fromTranslation=function(e,i,r){return(new t).setFromTranslation(e,i,r)},t.fromRotationX=function(e){return(new t).setFromRotationX(e)},t.fromRotationY=function(e){return(new t).setFromRotationY(e)},t.fromRotationZ=function(e){return(new t).setFromRotationZ(e)},t.fromRotationAxis=function(e,i){return(new t).setFromRotationAxis(e,i)},t.fromEuler=function(e){return(new t).setFromEuler(e)},t.fromQuaternion=function(e){return(new t).setFromQuaternion(e)},t.fromShear=function(e,i,r){return(new t).setFromShear(e,i,r)},t.fromBasis=function(e,i,r){return(new t).setFromBasis(e,i,r)},t.fromRowMajorData=function(e,i,r,n,s,a,o,u,h,c,l,f,d,p,m,v){return new t(e,s,h,d,i,a,c,p,r,o,l,m,n,u,f,v)},t}();function si(t,e,i){var r;if(void 0===e&&(e="webgl"),"webgl2"===e&&((r=t.getContext("webgl2",i))||console.debug("WebGL2 context retrieval failed, falling back to WebGL context.")),r&&"webgl"!==e||(r=t.getContext("webgl",i)),!r)throw new Error("This browser does not support WebGL or the WebGL version is incorrect. Please check your WebGL version.");return r}function ai(t){var e=t.getExtension("EXT_disjoint_timer_query_webgl2");if(e){var i=t.createQuery(),n=E((function(){return O(this,(function(s){return[2,new Promise((function(s,a){if(i){var o=t.getQueryParameter(i,t.QUERY_RESULT_AVAILABLE),u=t.getParameter(e.GPU_DISJOINT_EXT);if(o&&!u){var h=t.getQueryParameter(i,t.QUERY_RESULT);s(h/1e3/1e3)}(o||u)&&(t.deleteQuery(i),i=null),null!==o&&i&&r.setTimeout((function(){n().then(s).catch}),1)}}))]}))}));if(!i)return;return{begin:function(){i&&t.beginQuery(e.TIME_ELAPSED_EXT,i)},end:function(){t.endQuery(e.TIME_ELAPSED_EXT)},getTime:n}}}ni.IDENTITY=new ni(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),ni.ZERO=new ni(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),ni.tempVec0=new Qe,ni.tempVec1=new Qe,ni.tempVec2=new Qe,ni.tempMat0=new ni;var oi,ui,hi,ci,li=[],fi={};function di(){"function"==typeof o?mi(o):void 0!==u?(mi(u),mi(u.prototype)):li.push("iOS16 lockdown mode, WebGL Constants not in global"),li.length||"HALF_FLOAT"in fi||(fi.HALF_FLOAT=5131)}function pi(t){return void 0!==o&&"WebGL2RenderingContext"===t.constructor.name}function mi(t){for(var e in t)/^[A-Z_]/.test(e)&&(fi[e]=t[e])}function vi(t){switch(t){case Ae.Float32:return u.FLOAT;case Ae.Int16:return u.SHORT;case Ae.Int8:return u.BYTE;case Ae.UInt16:return u.UNSIGNED_SHORT;case Ae.UInt8:return u.UNSIGNED_BYTE;default:return u.FLOAT}}function yi(t){switch(t){case u.FLOAT:return Ae.Float32;case u.SHORT:return Ae.Int16;case u.BYTE:return Ae.Int8;case u.UNSIGNED_SHORT:return Ae.UInt16;case u.UNSIGNED_BYTE:return Ae.UInt8;default:return Ae.Float32}}function gi(t,e){return null==t?e:t}function xi(t){switch(t){case Dt.ALPHA:case Dt.ADD:case Dt.SUBTRACTION:case Dt.STRONG_LIGHT:case Dt.WEAK_LIGHT:return 1;case Dt.SUPERPOSITION:return 2;case Dt.BRIGHTNESS:return 3;case Dt.MULTIPLY:return 0;default:return 1}}function bi(t,e){switch(e){case void 0:case Dt.ALPHA:t.blendFunction=[fi.ONE,fi.ONE_MINUS_SRC_ALPHA,fi.ONE,fi.ONE_MINUS_SRC_ALPHA];break;case Dt.ADD:t.blendFunction=[fi.ONE,fi.ONE,fi.ONE,fi.ONE];break;case Dt.SUBTRACTION:t.blendFunction=[fi.ONE,fi.ONE,fi.ZERO,fi.ONE],t.blendEquation=[fi.FUNC_REVERSE_SUBTRACT,fi.FUNC_REVERSE_SUBTRACT];break;case Dt.SUPERPOSITION:t.blendFunction=[fi.ONE,fi.ONE,fi.ONE,fi.ONE];break;case Dt.MULTIPLY:t.blendFunction=[fi.DST_COLOR,fi.ONE_MINUS_SRC_ALPHA,fi.DST_COLOR,fi.ONE_MINUS_SRC_ALPHA];break;case Dt.BRIGHTNESS:t.blendFunction=[fi.ONE,fi.ONE_MINUS_SRC_ALPHA,fi.ONE,fi.ONE_MINUS_SRC_ALPHA];break;case Dt.STRONG_LIGHT:t.blendFunction=[fi.DST_COLOR,fi.DST_ALPHA,fi.ZERO,fi.ONE];break;case Dt.WEAK_LIGHT:t.blendFunction=[fi.DST_COLOR,fi.ZERO,fi.ZERO,fi.ONE];break;default:console.warn("BlendMode "+e+" not in specification, please set blend params separately.")}}function Ti(t,e){e===kt.DOUBLE?t.culling=!1:(t.culling=!0,t.frontFace=fi.CW,t.cullFace=e===kt.BACK?fi.BACK:fi.FRONT)}function Ei(t,e){switch(e){case void 0:t.stencilTest=!1;break;case ui.MASK:t.stencilTest=!0,t.stencilFunc=[fi.ALWAYS,fi.ALWAYS],t.stencilOpZPass=[fi.REPLACE,fi.REPLACE];break;case ui.OBSCURED:t.stencilTest=!0,t.stencilFunc=[fi.EQUAL,fi.EQUAL];break;case ui.REVERSE_OBSCURED:t.stencilTest=!0,t.stencilFunc=[fi.NOTEQUAL,fi.NOTEQUAL];break;case ui.NONE:t.stencilTest=!1;break;default:console.warn("MaskMode "+e+" not in specification, please set stencil params seperately.")}}function _i(){return _i=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},_i.apply(this,arguments)}li.length||di(),function(t){t[t.vertex=0]="vertex",t[t.fragment=1]="fragment"}(oi||(oi={})),function(t){t[t.NONE=0]="NONE",t[t.MASK=1]="MASK",t[t.OBSCURED=2]="OBSCURED",t[t.REVERSE_OBSCURED=3]="REVERSE_OBSCURED"}(ui||(ui={})),function(t){t[t.whatever=0]="whatever",t[t.clear=2]="clear"}(hi||(hi={})),function(t){t[t.none=0]="none",t[t.data=1]="data",t[t.image=2]="image",t[t.compressed=3]="compressed",t[t.video=4]="video",t[t.canvas=5]="canvas",t[t.framebuffer=6]="framebuffer",t[t.mipmaps=7]="mipmaps"}(ci||(ci={}));var wi=function(){function t(){this.callbacks={}}var e=t.prototype;return e.downloadJSON=function(t,e,i){this.download(t,"json",e,i)},e.downloadBinary=function(t,e,i){this.download(t,"arraybuffer",e,i)},e.downloadBlob=function(t,e,i){this.download(t,"blob",e,i)},e.download=function(t,e,i,r){var n=this;if(void 0===e&&(e="json"),!this.start(t,i,r)){var s=new h,a=function(){n.finish(t,s.status,s.response)};s.responseType=e,s.addEventListener("load",(function(){200==s.status?n.finish(t,200,s.response):a()})),s.addEventListener("error",a),s.open("GET",t,!0),s.send()}},e.start=function(t,e,i){var r=this.callbacks[t];try{if(r)return!0;this.callbacks[t]=r=[]}finally{r.push(e,i)}},e.finish=function(t,e,i){var r=this.callbacks[t];delete this.callbacks[t];for(var n=200==e?[i]:[e,i],s=n.length-1,a=r.length;s<a;s+=2)r[s].apply(null,n)},t}(),Ai=!1,Ci=!1;function Si(t,e){return Oi.apply(this,arguments)}function Oi(){return(Oi=E((function(t,e){return O(this,(function(i){switch(i.label){case 0:return!Ai&&e?[3,2]:[4,Ii(t)];case 1:return[2,{image:i.sent(),url:t}];case 2:return i.trys.push([2,4,,6]),[4,Ii(e)];case 3:return[2,{image:i.sent(),url:e}];case 4:return i.sent(),Ai=!0,[4,Ii(t)];case 5:return[2,{image:i.sent(),url:t}];case 6:return[2]}}))}))).apply(this,arguments)}function Ri(t,e){return Mi.apply(this,arguments)}function Mi(){return(Mi=E((function(t,e){return O(this,(function(i){switch(i.label){case 0:return!Ci&&e?[3,2]:[4,Ii(t)];case 1:return[2,{image:i.sent(),url:t}];case 2:return i.trys.push([2,4,,6]),[4,Ii(e)];case 3:return[2,{image:i.sent(),url:e}];case 4:return i.sent(),Ci=!0,[4,Ii(t)];case 5:return[2,{image:i.sent(),url:t}];case 6:return[2]}}))}))).apply(this,arguments)}function Ii(t){return Pi.apply(this,arguments)}function Pi(){return(Pi=E((function(t){var e,i;return O(this,(function(r){if(e="",A(t,c)){if(t.complete)return[2,t];e=t.src}else A(t,a)?(e=l.createObjectURL(t),i=!0):"string"==typeof t&&(e=t);if(!e)throw new Error("Invalid url type: "+JSON.stringify(t)+".");return[2,new Promise((function(t,r){var n=new f;/^data:/.test(e)||(n.crossOrigin="*"),n.onload=function(){return n.onload=null,i&&l.revokeObjectURL(e),t(n)},n.onerror=function(t){return n.onerror=null,i&&l.revokeObjectURL(e),r("Load image fail: "+e+", reason: "+JSON.stringify(t))},n.src=e}))]}))}))).apply(this,arguments)}function Li(t){return Fi.apply(this,arguments)}function Fi(){return(Fi=E((function(t){return O(this,(function(e){return[2,new Promise((function(e,i){(new wi).downloadBinary(t,e,(function(e,r){i("Couldn't load bins "+t+": status "+e+", "+r)}))}))]}))}))).apply(this,arguments)}function Vi(t){return Ni.apply(this,arguments)}function Ni(){return(Ni=E((function(t){return O(this,(function(e){return[2,new Promise((function(e,i){(new wi).downloadBlob(t,e,(function(e,r){i("Couldn't load blob "+t+": status "+e+", "+r)}))}))]}))}))).apply(this,arguments)}function Di(t){return ki.apply(this,arguments)}function ki(){return(ki=E((function(t){var e;return O(this,(function(r){return e=i.createElement("video"),"string"==typeof t?e.src=t:e.srcObject=t,e.crossOrigin="anonymous",e.muted=!0,q()&&e.setAttribute("renderer","standard"),e.setAttribute("playsinline","playsinline"),[2,new Promise((function(t,i){var r=e.play();r?r.then((function(){return t(e)})):e.addEventListener("loadeddata",(function i(){t(e),e.removeEventListener("loadeddata",i)}),!0),e.addEventListener("error",(function(t){i("Load video fail.")}))}))]}))}))).apply(this,arguments)}function zi(t,e){return Ui.apply(this,arguments)}function Ui(){return(Ui=E((function(t,e){return O(this,(function(i){switch(i.label){case 0:if(!Array.isArray(t))return[3,5];i.label=1;case 1:return i.trys.push([1,3,,5]),[4,e(t[0])];case 2:return[2,i.sent()];case 3:return i.sent(),[4,e(t[1])];case 4:return[2,i.sent()];case 5:return[2,e(t)]}}))}))).apply(this,arguments)}function Bi(t,e,i){return Gi.apply(this,arguments)}function Gi(){return(Gi=E((function(t,e,i,r){var n,s,a,o,u,h,c,l,f;return O(this,(function(d){switch(d.label){case 0:return void 0===r&&(r=[]),34067!==t.target?[3,2]:(n=t.mipmaps,s=t.target,a=n.map((function(t){return Promise.all(t.map((function(t){return t.id?i[t.id]:ji(t,e)})))})),[4,Promise.all(a)]);case 1:return o=d.sent(),[2,_i({keepImageSource:!1},t,{mipmaps:o,sourceFrom:{target:s,type:ci.mipmaps}})];case 2:return u=t.mipmaps,h=t.target,c=u.map((function(t){return ji(t,e)})),[4,Promise.all(c)];case 3:return l=d.sent(),f=r[u[0][1][0]].url,[2,_i({keepImageSource:!1},t,{mipmaps:l,sourceType:ci.mipmaps,sourceFrom:{target:h,bin:f,type:ci.mipmaps,mipmaps:u.map((function(t){return[t[1][1],t[1][2]]}))}})];case 4:return[2]}}))}))).apply(this,arguments)}function ji(t,e){return Xi.apply(this,arguments)}function Xi(){return Xi=E((function(t,e){var i,r,n,s,o;return O(this,(function(u){if(i=t[1],r=i[0],n=i[1],s=i[2],!(o=e[r]))throw new Error("Invalid bin pointer: "+JSON.stringify(t)+".");return[2,Ii(new a([new Uint8Array(o,n,s)]))]}))})),Xi.apply(this,arguments)}var Hi=1,Yi=function(t){function e(e){var i;return(i=t.call(this,e)||this).destroyed=!1,i.id="Tex"+Hi++,i}Qt(e,t);var i=e.prototype;return i.getWidth=function(){return this.width||0},i.getHeight=function(){return this.height||0},i.uploadCurrentVideoFrame=function(){},i.offloadData=function(){},i.reloadData=function(){},i.initialize=function(){},i.assembleOptions=function(t){var e=t.target,i=void 0===e?fi.TEXTURE_2D:e,r=t.format,n=void 0===r?fi.RGBA:r;return t.sourceType||(t.sourceType="image"in t?ci.image:"data"in t?ci.data:"video"in t?ci.video:0),_i({minFilter:fi.NEAREST,magFilter:fi.NEAREST,wrapS:fi.CLAMP_TO_EDGE,wrapT:fi.CLAMP_TO_EDGE,target:i,format:fi.RGBA,internalFormat:n,type:fi.UNSIGNED_BYTE},t)},e.fromImage=function(t,i,r){return E((function(){var n,s;return O(this,(function(a){switch(a.label){case 0:return[4,Ii(t)];case 1:return n=a.sent(),(s=e.create(i,_i({sourceType:ci.image,image:n,target:fi.TEXTURE_2D,id:wt(),flipY:!0},r))).initialize(),[2,s]}}))}))()},e.fromVideo=function(t,i,r){return E((function(){var n,s;return O(this,(function(a){switch(a.label){case 0:return[4,Di(t)];case 1:return n=a.sent(),(s=e.create(i,_i({sourceType:ci.video,video:n,id:wt(),flipY:!0},r))).initialize(),[2,s]}}))}))()},Pe(e,[{key:"isDestroyed",get:function(){return this.destroyed}}]),e}(ze);function Wi(t,e,i,r){var n,s,a=e.length/i/r;return s=n=4===a||0===a?fi.RGBA:3===a?fi.RGB:2===a?fi.LUMINANCE_ALPHA:fi.LUMINANCE,Yi.createWithData(t,{data:e,width:i,height:r},{type:fi.HALF_FLOAT,format:n,internalFormat:s,wrapS:fi.CLAMP_TO_EDGE,wrapT:fi.CLAMP_TO_EDGE})}var Zi={type:fi.UNSIGNED_BYTE,format:fi.RGBA,internalFormat:fi.RGBA,wrapS:fi.MIRRORED_REPEAT,wrapT:fi.MIRRORED_REPEAT,minFilter:fi.NEAREST,magFilter:fi.NEAREST};function qi(t){return Yi.create(t,_i({id:Oe.WhiteTexture,data:{width:1,height:1,data:new Uint8Array([255,255,255,255])},sourceType:ci.data},Zi))}function Ki(t){return Yi.create(t,_i({id:Oe.TransparentTexture,data:{width:1,height:1,data:new Uint8Array([0,0,0,0])},sourceType:ci.data},Zi))}var Qi=function(){function t(t,e,i){void 0===i&&(i=0),this.arrayBuffer=t,this.baseOffset=i;var r=new Uint8Array(this.arrayBuffer,this.baseOffset,12);if(171!==r[0]||75!==r[1]||84!==r[2]||88!==r[3]||32!==r[4]||49!==r[5]||49!==r[6]||187!==r[7]||13!==r[8]||10!==r[9]||26!==r[10]||10!==r[11])throw new Error("Texture missing KTX identifier.");var n=Uint32Array.BYTES_PER_ELEMENT,s=new DataView(this.arrayBuffer,this.baseOffset+12,13*n),a=67305985===s.getUint32(0,!0);this.glType=s.getUint32(1*n,a),this.glTypeSize=s.getUint32(2*n,a),this.glFormat=s.getUint32(3*n,a),this.glInternalFormat=s.getUint32(4*n,a),this.glBaseInternalFormat=s.getUint32(5*n,a),this.pixelWidth=s.getUint32(6*n,a),this.pixelHeight=s.getUint32(7*n,a),this.pixelDepth=s.getUint32(8*n,a),this.numberOfArrayElements=s.getUint32(9*n,a),this.numberOfFaces=s.getUint32(10*n,a),this.numberOfMipmapLevels=s.getUint32(11*n,a),this.bytesOfKeyValueData=s.getUint32(12*n,a),this.numberOfMipmapLevels=Math.max(1,this.numberOfMipmapLevels),0!==this.pixelHeight&&0===this.pixelDepth?0===this.numberOfArrayElements?this.numberOfFaces===e?0===this.glType?this.loadType=0:this.loadType=2:mt.warn("Number of faces expected "+e+", but found "+this.numberOfFaces+"."):mt.warn("Texture arrays not currently supported."):mt.warn("Only 2D textures currently supported.")}return t.prototype.mipmaps=function(t){for(var e=[],i=64+this.bytesOfKeyValueData,r=this.pixelWidth,n=this.pixelHeight,s=t?this.numberOfMipmapLevels:1,a=0;a<s;a++){for(var o=new Int32Array(this.arrayBuffer,this.baseOffset+i,1)[0],u=0;u<this.numberOfFaces;u++){var h=new Uint8Array(this.arrayBuffer,this.baseOffset+i+4,o);e.push({data:h,width:r,height:n}),i+=o+4,i+=3-(o+3)%4}r=Math.max(1,.5*r),n=Math.max(1,.5*n)}return e},t}();function Ji(t){var e=new Qi(t,1),i=e.numberOfMipmapLevels,r=e.pixelWidth,n=e.pixelHeight,s=e.glType,a=e.numberOfFaces,o=e.glInternalFormat,u=e.glFormat,h=i>=Math.floor(Math.log2(Math.max(r,n))+1);return{sourceType:ci.compressed,type:s,target:6===a?fi.TEXTURE_CUBE_MAP:fi.TEXTURE_2D,internalFormat:o,format:u,mipmaps:e.mipmaps(h)}}var $i,tr=function(){function t(){this.reloadPending={}}var e=t.prototype;return e.reload=function(t){var e=this;return E((function(){var i,r;return O(this,(function(n){switch(n.label){case 0:return i=t.id,e.reloadPending[i]?[2]:t.sourceFrom?(e.reloadPending[i]=!0,[4,e.loadSource(t.sourceFrom)]):[3,2];case 1:return r=n.sent(),t.updateSource(r),e.reloadPending[i]=!1,[3,3];case 2:throw new Error("No source from.");case 3:return[2]}}))}))()},e.canOffloadTexture=function(t){if(t){var e=t.type;if(e===ci.compressed||e===ci.image){var i=t.target,r=t.map,n=t.url;return i===fi.TEXTURE_CUBE_MAP?"object"==typeof r&&!!r:yt(n)&&n.length>0}if(e===ci.mipmaps){var s=t.bin,a=t.mipmaps,o=t.target,u=t.maps,h=t.urls;return s?a.length>0:o===fi.TEXTURE_CUBE_MAP?u.every((function(t){return"object"==typeof t&&t})):h.every((function(t){return yt(t)&&t.length>0}))}}return!1},e.loadSource=function(t,e){var i=this;return E((function(){var r,n,s,a,o,u,h,c,l,f,d,p,m,v,y,g,x;return O(this,(function(b){switch(b.label){case 0:return r=t.type,n=t.target,s=t.map,a=t.url,o=t.bin,u=t.mipmaps,h=t.urls,c=t.maps,n!==fi.TEXTURE_CUBE_MAP||r===ci.mipmaps?[3,2]:[4,i.loadCubeMap(s)];case 1:return l=b.sent(),[2,_i({},e,{cube:l,target:fi.TEXTURE_CUBE_MAP,sourceType:ci.image,sourceFrom:{type:ci.image,map:_i({},s),target:fi.TEXTURE_CUBE_MAP}})];case 2:return r!==ci.image?[3,4]:[4,Ii(a)];case 3:return f=b.sent(),[2,_i({},e,{image:f,sourceType:ci.image,sourceFrom:{type:r,url:a,target:fi.TEXTURE_2D}})];case 4:return r!==ci.video?[3,6]:[4,Di(a)];case 5:return d=b.sent(),[2,_i({},e,{video:d,sourceType:ci.video})];case 6:return r!==ci.compressed?[3,8]:[4,Li(a)];case 7:return[2,_i({},Ji(b.sent()),e,{sourceFrom:{url:a,type:ci.compressed}})];case 8:return r!==ci.mipmaps?[3,17]:o?[4,Li(o)]:[3,13];case 9:return p=b.sent(),m=null!=n?n:fi.TEXTURE_2D,v=m===fi.TEXTURE_2D?u.slice():u.map((function(t){return t.slice()})),n!==fi.TEXTURE_CUBE_MAP?[3,11]:[4,Promise.all(u.map((function(t){return i.loadMipmapImages(t,p)})))];case 10:return y=b.sent(),[3,12];case 11:y=i.loadMipmapImages(u,p),b.label=12;case 12:return[2,_i({},e,{mipmaps:y,target:m,sourceType:ci.mipmaps,sourceFrom:{bin:o,mipmaps:v,target:m,type:ci.mipmaps}})];case 13:return n!==fi.TEXTURE_2D&&n?[3,15]:[4,Promise.all(h.map((function(t){return Ii(t)})))];case 14:return g=b.sent(),[2,_i({},e,{mipmaps:g,target:fi.TEXTURE_2D,sourceType:ci.mipmaps,sourceFrom:{type:r,urls:h.slice(),target:fi.TEXTURE_2D}})];case 15:return n!==fi.TEXTURE_CUBE_MAP?[3,17]:[4,Promise.all(c.map((function(t){return i.loadCubeMap(t)})))];case 16:return x=b.sent(),[2,_i({},e,{mipmaps:x,target:fi.TEXTURE_CUBE_MAP,sourceType:ci.mipmaps,sourceFrom:{type:r,maps:c.map((function(t){return _i({},t)})),target:fi.TEXTURE_CUBE_MAP}})];case 17:throw new Error("Invalid resource type: "+r+".")}}))}))()},e.loadMipmapImages=function(t,e){return E((function(){return O(this,(function(i){return[2,Promise.all(t.map((function(t){return Ii(new a([new Uint8Array(e,t[0],t[1])]))})))]}))}))()},e.loadCubeMap=function(t){return E((function(){return O(this,(function(e){return[2,Promise.all(t.map((function(t){return Ii(t)})))]}))}))()},t}();function er(){return $i||($i=new tr),$i}function ir(t){$i=t}var rr,nr=function(){function t(t){this.destroyed=!1;var e=t.name,i=void 0===e?"defaultDataBlock":e;this.name=i}var e=t.prototype;return e.setUniformValues=function(t){var e=this;Object.keys(t).forEach((function(i){e.setUniformValue(i,t[i])}))},e.invalidAllFlags=function(){},e.updateUniformSubData=function(t,e,i){},t}();function sr(t){return"object"==typeof t&&t&&void 0===t.length&&A(t,Yi)}function ar(t){return t&&void 0!==t.length&&sr(t[0])}!function(t){t[t.normal=0]="normal",t[t.transformFeedback=1]="transformFeedback"}(rr||(rr={}));var or,ur,hr=1,cr=function(t){function e(e,i){var r;if((r=t.call(this,e)||this).stringTags={},r.enabledMacros={},r.destroyed=!1,r.initialized=!1,r.shaderDirty=!0,i){var n=i.name,s=void 0===n?"Material"+hr++:n,a=i.renderType,o=void 0===a?0:a,u=i.shader,h=i.uniformSemantics;r.name=s,r.renderType=o,r.shaderSource=u,r.props=i,r.uniformSemantics=_i({},h)}else r.name="Material"+hr++,r.renderType=0;return r}Qt(e,t);var i=e.prototype;return i.initialize=function(){},i.createShaderVariant=function(){},i.use=function(t,e){},Pe(e,[{key:"shader",get:function(){return this._shader},set:function(t){this._shader!==t&&(this._shader=t,this.shaderDirty=!0)}},{key:"mainTexture",get:function(){return this.getTexture("_MainTex")},set:function(t){this.setTexture("_MainTex",t)}},{key:"color",get:function(){return this.getColor("_Color")},set:function(t){this.setColor("_Color",t)}},{key:"blending",set:function(t){}},{key:"blendFunction",set:function(t){}},{key:"blendEquation",set:function(t){}},{key:"depthTest",set:function(t){}},{key:"depthMask",set:function(t){}},{key:"stencilTest",set:function(t){}},{key:"stencilRef",set:function(t){}},{key:"stencilFunc",set:function(t){}},{key:"stencilOpZPass",set:function(t){}},{key:"culling",set:function(t){}},{key:"frontFace",set:function(t){}},{key:"cullFace",set:function(t){}},{key:"blendColor",set:function(t){}},{key:"depthRange",set:function(t){}},{key:"depthFunc",set:function(t){}},{key:"polygonOffsetFill",set:function(t){}},{key:"polygonOffset",set:function(t){}},{key:"sampleAlphaToCoverage",set:function(t){}},{key:"stencilMask",set:function(t){}},{key:"stencilOpFail",set:function(t){}},{key:"stencilOpZFail",set:function(t){}}]),e}(ze),lr=function(){function t(t){this.engine=t,this.alphaMaskEnabled=!1,this.maskMode=ui.NONE,this.maskable=null,this.stencilClearAction={stencilAction:hi.clear}}var e=t.prototype;return e.getRefValue=function(){return 1},e.getMaskMode=function(t){var e=t.isMask,i=void 0!==e&&e,r=t.inverted,n=void 0!==r&&r,s=t.reference,a=t.alphaMaskEnabled,o=void 0!==a&&a;return this.alphaMaskEnabled=o,i?this.maskMode=ui.MASK:(this.maskMode=n?ui.REVERSE_OBSCURED:ui.OBSCURED,s&&(this.maskable=this.engine.findObject(s))),this.maskMode},e.drawStencilMask=function(t){this.maskable&&(t.clear(this.stencilClearAction),this.maskable.drawStencilMask(t))},t}();!function(t){t[t.noShader=0]="noShader",t[t.success=1]="success",t[t.fail=2]="fail",t[t.compiling=3]="compiling"}(or||(or={})),function(t){t.GLSL1="100",t.GLSL3="300 es"}(ur||(ur={}));var fr=function(t){function e(e,i){var r;return(r=t.call(this,e)||this).source=i,r}return Qt(e,t),e}(ze),dr=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.createVariant=function(t){var e=[];if(t)for(var i,r=w(Object.keys(t));!(i=r()).done;){var n=i.value;e.push([n,t[n]])}var s=this.engine.getShaderLibrary().createShader(this.shaderData,e);return s.shader=this,s},i.fromData=function(e){t.prototype.fromData.call(this,e),this.shaderData=e},e}(ze);dr=S([Ne(_e.Shader)],dr);var pr="effects-internal-copy",mr="effects-internal-copy-mesh",vr="\nprecision highp float;\nattribute vec2 aPos;\nvarying vec2 vTex;\nvoid main(){\n gl_Position = vec4(aPos,0.,1.0);\n vTex = (aPos + vec2(1.0))/2.;\n}",yr="precision mediump float;\nvarying vec2 vTex;\n\n#ifdef DEPTH_TEXTURE\nuniform sampler2D uDepth;\n#extension GL_EXT_frag_depth : enable\n#endif\nvoid main(){\n #ifdef DEPTH_TEXTURE\n gl_FragDepthEXT = texture2D(uDepth,vTex).r;\n #endif\n}\n";function gr(t,e){return{name:pr,vertex:vr,fragment:yr,glslVersion:2===t?ur.GLSL3:ur.GLSL1,macros:[["DEPTH_TEXTURE",!!e]],cacheId:mr+ +e}}var xr,br,Tr={format:fi.RGBA,type:fi.UNSIGNED_BYTE,minFilter:fi.LINEAR,magFilter:fi.LINEAR,wrapS:fi.CLAMP_TO_EDGE,wrapT:fi.CLAMP_TO_EDGE},Er=Symbol("dispose"),_r=function(){function t(t){this.textureCache={},this.textureRef={},this.engine=t}var e=t.prototype;return e.requestColorAttachmentTexture=function(t){var e=this,i=t.width,r=t.height,n=t.name,s={sourceType:ci.framebuffer,data:{width:i,height:r},name:n},a=[n];Object.getOwnPropertyNames(Tr).forEach((function(e){var i,r=null!=(i=t[e])?i:Tr[e];s[e]=r,a.push(e,r)}));var o=a.join(":"),u=this.textureCache[o];if(u)this.textureRef[o]++;else{var h=this.engine;ot(h),u=Yi.create(h,s),this.textureCache[o]=u,this.textureRef[o]=1,u[Er]=u.dispose,u.dispose=function(){return e.removeTexture(o)}}return u},e.removeTexture=function(t){var e=this.textureRef[t];if(e<=1){e<0&&console.error("Ref count < 0.");var i=this.textureCache[t];i&&(i[Er](),i.dispose=i[Er]),delete this.textureCache[t],delete this.textureRef[t]}else this.textureRef[t]=e-1},e.dispose=function(){var t=this;Object.keys(this.textureCache).forEach((function(e){var i=t.textureCache[e];i[Er](),i.dispose=i[Er]})),this.textureCache={},this.textureRef={},this.engine=void 0},t}(),wr=function(){function t(t){void 0===t&&(t={}),this.semantics=_i({},t)}var e=t.prototype;return e.toObject=function(){return _i({},this.semantics)},e.setSemantic=function(t,e){void 0===e?delete this.semantics[t]:this.semantics[t]=e},e.getSemanticValue=function(t,e){var i=this.semantics[t];return xt(i)?i(e):i},e.hasSemanticValue=function(t){return t in this.semantics},e.dispose=function(){var t=this;Object.keys(this.semantics).forEach((function(e){delete t.semantics[e]}))},t}(),Ar=((xr={})[fi.FLOAT]=Float32Array.BYTES_PER_ELEMENT,xr[fi.INT]=Int32Array.BYTES_PER_ELEMENT,xr[fi.SHORT]=Int16Array.BYTES_PER_ELEMENT,xr[fi.BYTE]=Int8Array.BYTES_PER_ELEMENT,xr),Cr=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).name="",e.subMeshes=[],e}Qt(e,t);var i=e.prototype;return i.initialize=function(){},i.flush=function(){},e}(ze);function Sr(t){return t===fi.INT?new Int32Array(0):t===fi.SHORT?new Int16Array(0):new Float32Array(0)}!function(t){t[t.XYZ=0]="XYZ",t[t.XZY=1]="XZY",t[t.YXZ=2]="YXZ",t[t.YZX=3]="YZX",t[t.ZXY=4]="ZXY",t[t.ZYX=5]="ZYX"}(br||(br={}));var Or=function(){function t(e,i,r,n){void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=t.DEFAULT_ORDER),this.x=e,this.y=i,this.z=r,this.order=n}var e=t.prototype;return e.set=function(t,e,i,r){return void 0===r&&(r=this.order),this.x=t,this.y=e,this.z=i,this.order=r,this},e.setZero=function(t){return void 0===t&&(t=this.order),this.set(0,0,0,t)},e.setFromRotationMatrix4=function(t,e){void 0===e&&(e=this.order);var i=t.elements,r=i[0],n=i[4],s=i[8],a=i[1],o=i[5],u=i[9],h=i[2],c=i[6],l=i[10];switch(e){case br.XYZ:this.y=Math.asin(qe(s,-1,1)),Math.abs(s)<.9999999?(this.x=Math.atan2(-u,l),this.z=Math.atan2(-n,r)):(this.x=Math.atan2(c,o),this.z=0);break;case br.YXZ:this.x=Math.asin(-qe(u,-1,1)),Math.abs(u)<.9999999?(this.y=Math.atan2(s,l),this.z=Math.atan2(a,o)):(this.y=Math.atan2(-h,r),this.z=0);break;case br.ZXY:this.x=Math.asin(qe(c,-1,1)),Math.abs(c)<.9999999?(this.y=Math.atan2(-h,l),this.z=Math.atan2(-n,o)):(this.y=0,this.z=Math.atan2(a,r));break;case br.ZYX:this.y=Math.asin(-qe(h,-1,1)),Math.abs(h)<.9999999?(this.x=Math.atan2(c,l),this.z=Math.atan2(a,r)):(this.x=0,this.z=Math.atan2(-n,o));break;case br.YZX:this.z=Math.asin(qe(a,-1,1)),Math.abs(a)<.9999999?(this.x=Math.atan2(-u,o),this.y=Math.atan2(-h,r)):(this.x=0,this.y=Math.atan2(s,l));break;case br.XZY:this.z=Math.asin(-qe(n,-1,1)),Math.abs(n)<.9999999?(this.x=Math.atan2(c,o),this.y=Math.atan2(s,r)):(this.x=Math.atan2(-u,l),this.y=0);break;default:console.error("setFromRotationMatrix: unknown order: "+e)}return this.x*=He,this.y*=He,this.z*=He,this.order=e,this},e.setFromQuaternion=function(e,i){void 0===i&&(i=this.order);var r=t.tempMat0;return r.setFromQuaternion(e),this.setFromRotationMatrix4(r,i)},e.setFromVector3=function(t,e){return void 0===e&&(e=this.order),this.set(t.x,t.y,t.z,e)},e.setFromArray=function(t,e,i){var r,n,s,a;return void 0===e&&(e=0),void 0===i&&(i=this.order),this.x=null!=(r=t[e])?r:0,this.y=null!=(n=t[e+1])?n:0,this.z=null!=(s=t[e+2])?s:0,this.order=null!=(a=t[e+3])?a:i,this},e.clone=function(){return new t(this.x,this.y,this.z,this.order)},e.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.order=t.order,this},e.add=function(t){return this.order!=t.order?(console.error("add euler with different order"),this):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},e.addEulers=function(t,e){return t.order!=e.order?(console.error("add euler with different order"),this):(this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.order=t.order,this)},e.negate=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},e.reorder=function(t){var e=new ri;return e.setFromEuler(this),this.setFromQuaternion(e,t)},e.rotateVector3=function(e,i){return t.tempQuat0.setFromEuler(this).rotateVector3(e,i)},e.equals=function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.order===this.order},e.toVector3=function(t){return t.set(this.x,this.y,this.z)},e.toArray=function(){return[this.x,this.y,this.z]},e.toQuaternion=function(t){var e=this,i=e.x,r=e.y,n=e.z,s=e.order,a=Math.cos(i*Xe*.5),o=Math.cos(r*Xe*.5),u=Math.cos(n*Xe*.5),h=Math.sin(i*Xe*.5),c=Math.sin(r*Xe*.5),l=Math.sin(n*Xe*.5);switch(s){case br.XYZ:t.set(h*o*u+a*c*l,a*c*u-h*o*l,a*o*l+h*c*u,a*o*u-h*c*l);break;case br.YXZ:t.set(h*o*u+a*c*l,a*c*u-h*o*l,a*o*l-h*c*u,a*o*u+h*c*l);break;case br.ZXY:t.set(h*o*u-a*c*l,a*c*u+h*o*l,a*o*l+h*c*u,a*o*u-h*c*l);break;case br.ZYX:t.set(h*o*u-a*c*l,a*c*u+h*o*l,a*o*l-h*c*u,a*o*u+h*c*l);break;case br.YZX:t.set(h*o*u+a*c*l,a*c*u+h*o*l,a*o*l-h*c*u,a*o*u-h*c*l);break;case br.XZY:t.set(h*o*u-a*c*l,a*c*u-h*o*l,a*o*l+h*c*u,a*o*u+h*c*l);break;default:console.error("unknown euler order: "+s)}return t},e.toMatrix4=function(t){var e=t.elements,i=this,r=i.x,n=i.y,s=i.z,a=i.order,o=Math.cos(r*Xe),u=Math.sin(r*Xe),h=Math.cos(n*Xe),c=Math.sin(n*Xe),l=Math.cos(s*Xe),f=Math.sin(s*Xe);if(a===br.XYZ){var d=o*l,p=o*f,m=u*l,v=u*f;e[0]=h*l,e[4]=-h*f,e[8]=c,e[1]=p+m*c,e[5]=d-v*c,e[9]=-u*h,e[2]=v-d*c,e[6]=m+p*c,e[10]=o*h}else if(a===br.YXZ){var y=h*l,g=h*f,x=c*l,b=c*f;e[0]=y+b*u,e[4]=x*u-g,e[8]=o*c,e[1]=o*f,e[5]=o*l,e[9]=-u,e[2]=g*u-x,e[6]=b+y*u,e[10]=o*h}else if(a===br.ZXY){var T=h*l,E=h*f,_=c*l,w=c*f;e[0]=T-w*u,e[4]=-o*f,e[8]=_+E*u,e[1]=E+_*u,e[5]=o*l,e[9]=w-T*u,e[2]=-o*c,e[6]=u,e[10]=o*h}else if(a===br.ZYX){var A=o*l,C=o*f,S=u*l,O=u*f;e[0]=h*l,e[4]=S*c-C,e[8]=A*c+O,e[1]=h*f,e[5]=O*c+A,e[9]=C*c-S,e[2]=-c,e[6]=u*h,e[10]=o*h}else if(a===br.YZX){var R=o*h,M=o*c,I=u*h,P=u*c;e[0]=h*l,e[4]=P-R*f,e[8]=I*f+M,e[1]=f,e[5]=o*l,e[9]=-u*l,e[2]=-c*l,e[6]=M*f+I,e[10]=R-P*f}else if(a===br.XZY){var L=o*h,F=o*c,V=u*h,N=u*c;e[0]=h*l,e[4]=-f,e[8]=c*l,e[1]=L*f+N,e[5]=o*l,e[9]=F*f-V,e[2]=V*f-F,e[6]=u*l,e[10]=N*f+L}else console.error("toMatrix4: Invalid order "+a);return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,t},t.fromRotationMatrix4=function(e,i){return void 0===i&&(i=t.DEFAULT_ORDER),(new t).setFromRotationMatrix4(e,i)},t.fromQuaternion=function(e,i){return void 0===i&&(i=t.DEFAULT_ORDER),(new t).setFromQuaternion(e,i)},t.fromVector3=function(e,i){return void 0===i&&(i=t.DEFAULT_ORDER),(new t).setFromVector3(e,i)},t.fromArray=function(e,i,r){return void 0===i&&(i=0),void 0===r&&(r=t.DEFAULT_ORDER),(new t).setFromArray(e,i,r)},t}();Or.DEFAULT_ORDER=br.ZYX,Or.tempQuat0=new ri,Or.tempMat0=new ni;var Rr=function(){function t(t,e,i,r,n,s,a,o,u){void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=1),void 0===s&&(s=0),void 0===a&&(a=0),void 0===o&&(o=0),void 0===u&&(u=1),this.elements=[t,e,i,r,n,s,a,o,u]}var e=t.prototype;return e.set=function(t,e,i,r,n,s,a,o,u){var h=this.elements;return h[0]=t,h[3]=r,h[6]=a,h[1]=e,h[4]=n,h[7]=o,h[2]=i,h[5]=s,h[8]=u,this},e.setFromRowMajorData=function(t,e,i,r,n,s,a,o,u){var h=this.elements;return h[0]=t,h[3]=e,h[6]=i,h[1]=r,h[4]=n,h[7]=s,h[2]=a,h[5]=o,h[8]=u,this},e.setFromColumnVectors=function(t,e,i){return this.set(t.x,t.y,t.z,e.x,e.y,e.z,i.x,i.y,i.z)},e.setFromMatrix4=function(t){var e=t.elements;return this.set(e[0],e[1],e[2],e[4],e[5],e[6],e[8],e[9],e[10])},e.setFromArray=function(t,e){void 0===e&&(e=0);for(var i=0;i<9;i++)this.elements[i]=t[e+i];return this},e.setFromQuaternion=function(t){var e=t.x,i=t.y,r=t.z,n=t.w,s=e+e,a=i+i,o=r+r,u=e*s,h=e*a,c=e*o,l=i*a,f=i*o,d=r*o,p=n*s,m=n*a,v=n*o,y=this.elements;return y[0]=1-(l+d),y[1]=h+v,y[2]=c-m,y[3]=h-v,y[4]=1-(u+d),y[5]=f+p,y[6]=c+m,y[7]=f-p,y[8]=1-(u+l),this},e.setZero=function(){for(var t=0;t<9;t++)this.elements[t]=0;return this},e.identity=function(){return this.set(1,0,0,0,1,0,0,0,1)},e.clone=function(){var e=this.elements;return new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},e.copyFrom=function(t){return this.elements=[].concat(t.elements),this},e.getColumnVector=function(t,e){return e.set(this.elements[3*t],this.elements[3*t+1],this.elements[3*t+2])},e.scale=function(t,e){var i=this.elements;return i[0]*=t,i[3]*=t,i[6]*=t,i[1]*=e,i[4]*=e,i[7]*=e,this},e.rotate=function(t){var e=Math.cos(t),i=Math.sin(t),r=this.elements,n=r[0],s=r[3],a=r[6],o=r[1],u=r[4],h=r[7];return r[0]=e*n+i*o,r[3]=e*s+i*u,r[6]=e*a+i*h,r[1]=-i*n+e*o,r[4]=-i*s+e*u,r[7]=-i*a+e*h,this},e.translate=function(t,e){var i=this.elements;return i[0]+=t*i[2],i[3]+=t*i[5],i[6]+=t*i[8],i[1]+=e*i[2],i[4]+=e*i[5],i[7]+=e*i[8],this},e.multiply=function(t){if("number"==typeof t){for(var e=0;e<9;e++)this.elements[e]*=t;return this}return this.multiplyMatrices(this,t)},e.premultiply=function(t){return this.multiplyMatrices(t,this)},e.multiplyMatrices=function(t,e){var i=t.elements,r=e.elements,n=this.elements,s=i[0],a=i[3],o=i[6],u=i[1],h=i[4],c=i[7],l=i[2],f=i[5],d=i[8],p=r[0],m=r[3],v=r[6],y=r[1],g=r[4],x=r[7],b=r[2],T=r[5],E=r[8];return n[0]=s*p+a*y+o*b,n[3]=s*m+a*g+o*T,n[6]=s*v+a*x+o*E,n[1]=u*p+h*y+c*b,n[4]=u*m+h*g+c*T,n[7]=u*v+h*x+c*E,n[2]=l*p+f*y+d*b,n[5]=l*m+f*g+d*T,n[8]=l*v+f*x+d*E,this},e.determinant=function(){var t=this.elements,e=t[0],i=t[3],r=t[6],n=t[1],s=t[4],a=t[7],o=t[2],u=t[5],h=t[8];return e*(s*h-u*a)+n*(u*r-i*h)+o*(i*a-s*r)},e.invert=function(){var t=this.elements,e=t[0],i=t[3],r=t[6],n=t[1],s=t[4],a=t[7],o=t[2],u=t[5],h=t[8],c=h*s-u*a,l=u*r-h*i,f=a*i-s*r,d=e*c+n*l+o*f;if(0===d)return this.set(0,0,0,0,0,0,0,0,0);var p=1/d;return t[0]=c*p,t[1]=(o*a-h*n)*p,t[2]=(u*n-o*s)*p,t[3]=l*p,t[4]=(h*e-o*r)*p,t[5]=(o*i-u*e)*p,t[6]=f*p,t[7]=(n*r-a*e)*p,t[8]=(s*e-n*i)*p,this},e.transpose=function(){var t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this},e.transformPoint=function(t,e){var i=t.x,r=t.y,n=t.z,s=this.elements,a=null!=e?e:t;return a.x=s[0]*i+s[3]*r+s[6]*n,a.y=s[1]*i+s[4]*r+s[7]*n,a.z=s[2]*i+s[5]*r+s[8]*n,a},e.transformNormal=function(t,e){return this.transformPoint(t,e).normalize()},e.equals=function(t){for(var e=this.elements,i=t.elements,r=0;r<9;r++)if(!We(e[r],i[r]))return!1;return!0},e.toArray=function(){return[].concat(this.elements)},e.fill=function(t,e){void 0===e&&(e=0);var i=this.elements;t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8]},t.fromIdentity=function(){return new t(1,0,0,0,1,0,0,0,1)},t.fromColumnVectors=function(e,i,r){return(new t).setFromColumnVectors(e,i,r)},t.fromMatrix4=function(e){return(new t).setFromMatrix4(e)},t.fromArray=function(e,i){return void 0===i&&(i=0),(new t).setFromArray(e,i)},t.fromQuaternion=function(e){return(new t).setFromQuaternion(e)},t.fromRowMajorData=function(e,i,r,n,s,a,o,u,h){return new t(e,n,o,i,s,u,r,a,h)},t}(),Mr=function(){function t(t,e){void 0===t&&(t=Qe.ZERO),void 0===e&&(e=Qe.X),this.origin=new Qe,this.direction=new Qe,this.origin.copyFrom(t),this.direction.copyFrom(e).normalize()}var e=t.prototype;return e.set=function(t,e){return this.origin.copyFrom(t),this.direction.copyFrom(e).normalize(),this},e.clone=function(){return new t(this.origin,this.direction)},e.copyFrom=function(t){return this.set(t.origin,t.direction)},e.recast=function(e){return this.origin.copyFrom(this.at(e,t.tempVec0)),this},e.at=function(t,e){var i=e||new Qe;return i.copyFrom(this.origin),i.addScaledVector(this.direction,t)},e.equals=function(t){return this.origin.equals(t.origin)&&this.direction.equals(t.direction)},e.applyMatrix=function(t){return this.origin.applyProjectionMatrix(t),this.direction.applyNormalMatrix(t),this},e.intersectBox=function(t,e){var i,r,n,s,a,o,u=this.origin,h=u.x,c=u.y,l=u.z,f=this.direction,d=f.x,p=f.y,m=f.z,v=t.min,y=v.x,g=v.y,x=v.z,b=t.max,T=b.x,E=b.y,_=b.z,w=1/d,A=1/p,C=1/m;if(w>=0?(i=(y-h)*w,r=(T-h)*w):(i=(T-h)*w,r=(y-h)*w),A>=0?(n=(g-c)*A,s=(E-c)*A):(n=(E-c)*A,s=(g-c)*A),!(i>s||n>r||((n>i||i!=i)&&(i=n),(s<r||r!=r)&&(r=s),(n>i||i!=i)&&(i=n),(s<r||r!=r)&&(r=s),C>=0?(a=(x-l)*C,o=(_-l)*C):(a=(_-l)*C,o=(x-l)*C),i>o||a>r||((a>i||i!=i)&&(i=a),(o<r||r!=r)&&(r=o),r<0))))return i>=0?this.at(i,e):this.at(r,e)},e.intersectPlane=function(t,e){var i=t.normal,r=t.distance,n=i.dot(this.direction);if(0===n)return 0===i.dot(this.origin)+r?(e||new Qe).copyFrom(this.origin):void 0;var s=-(this.origin.dot(i)+r)/n;return s>=0?this.at(s,e):void 0},e.intersectSphere=function(e,i){var r=e.center,n=t.tempVec0.subtractVectors(r,this.origin),s=n.dot(this.direction),a=n.dot(n)-s*s,o=e.radius*e.radius;if(!(a>o)){var u=Math.sqrt(o-a),h=s-u,c=s+u;if(!(c<0))return h>=0?this.at(h,i):this.at(c,i)}},e.intersectTriangle=function(e,i,r){var n,s=e.p0,a=e.p1,o=e.p2,u=t.tempVec0.subtractVectors(a,s),h=t.tempVec1.subtractVectors(o,s),c=t.tempVec2.subtractVectors(this.origin,s),l=t.tempVec3.crossVectors(u,h),f=this.direction.dot(l);if(f>0){if(r)return;n=1}else{if(!(f<0))return;n=-1,f=-f}h.crossVectors(c,h);var d=n*this.direction.dot(h);if(!(d<0)){u.cross(c);var p=n*this.direction.dot(u);if(!(p<0||d+p>f)){var m=-n*c.dot(l);if(!(m<0))return this.at(m/f,i)}}},t}();Mr.tempVec0=new Qe,Mr.tempVec1=new Qe,Mr.tempVec2=new Qe,Mr.tempVec3=new Qe;var Ir,Pr,Lr=function(){function t(t,e){void 0===t&&(t=new Qe(1/0,1/0,1/0)),void 0===e&&(e=new Qe(-1/0,-1/0,-1/0)),this.min=t.clone(),this.max=e.clone()}var e=t.prototype;return e.set=function(t,e){return this.min.copyFrom(t),this.max.copyFrom(e),this},e.setFromArray=function(t){for(var e=Number(1/0),i=Number(1/0),r=Number(1/0),n=-1/0,s=-1/0,a=-1/0,o=0,u=t.length;o<u;o+=3){var h=t[o],c=t[o+1],l=t[o+2];h<e&&(e=h),c<i&&(i=c),l<r&&(r=l),h>n&&(n=h),c>s&&(s=c),l>a&&(a=l)}return this.min.set(e,i,r),this.max.set(n,s,a),this},e.setFromPoints=function(t){this.makeEmpty();for(var e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this},e.setFromCenterAndSize=function(t,e){var i=e.clone().multiply(.5);return this.min.copyFrom(t).subtract(i),this.max.copyFrom(t).add(i),this},e.setFromObject=function(t){return this.makeEmpty(),this.expandByObject(t)},e.clone=function(){return(new t).copyFrom(this)},e.copyFrom=function(t){return this.min.copyFrom(t.min),this.max.copyFrom(t.max),this},e.makeEmpty=function(){return this.min.x=this.min.y=this.min.z=Number(1/0),this.max.x=this.max.y=this.max.z=-1/0,this},e.isEmpty=function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},e.getCenter=function(t){return void 0===t&&(t=new Qe),this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiply(.5)},e.getSize=function(t){return void 0===t&&(t=new Qe),this.isEmpty()?t.set(0,0,0):t.subtractVectors(this.max,this.min)},e.expandByPoint=function(t){return this.min.min(t),this.max.max(t),this},e.expandByVector=function(t){return this.min.subtract(t),this.max.add(t),this},e.expandByScalar=function(t){return this.min.add(-t),this.max.add(t),this},e.expandByBox=function(t){return this.min.min(t.min),this.max.max(t.max),this},e.expandByObject=function(e){e.updateWorldMatrix(!1,!1);var i=e.geometry;if(void 0!==i){null===i.boundingBox&&i.computeBoundingBox();var r=new t;r.copyFrom(i.boundingBox),r.applyMatrix4(e.matrixWorld),this.union(r)}for(var n=e.children,s=0,a=n.length;s<a;s++)this.expandByObject(n[s]);return this},e.containsPoint=function(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)},e.containsBox=function(t){return this.min.x<=t.min.x&&this.max.x>=t.max.x&&this.min.y<=t.min.y&&this.max.y>=t.max.y&&this.min.z<=t.min.z&&this.max.z>=t.max.z},e.getParameter=function(t,e){return void 0===e&&(e=new Qe),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},e.intersectsBox=function(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)},e.intersectsSphere=function(t){var e=new Qe;return this.clampPoint(t.center,e),e.distanceSquared(t.center)<=t.radius*t.radius},e.clampPoint=function(t,e){return void 0===e&&(e=new Qe),e.copyFrom(t).clamp(this.min,this.max)},e.distanceToPoint=function(t){return t.clone().clamp(this.min,this.max).subtract(t).length()},e.intersect=function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},e.union=function(t){return this.min.min(t.min),this.max.max(t.max),this},e.applyMatrix4=function(t,e){if(void 0===e&&(e=new Qe),this.isEmpty())return this;var i=this.getOBBPoints(t,e);return this.setFromPoints(i),this},e.getOBBPoints=function(t,e){if(void 0===e&&(e=new Qe),this.isEmpty())return[];var i=[];return i[0]=new Qe(this.min.x,this.min.y,this.min.z),i[1]=new Qe(this.min.x,this.min.y,this.max.z),i[2]=new Qe(this.min.x,this.max.y,this.min.z),i[3]=new Qe(this.min.x,this.max.y,this.max.z),i[4]=new Qe(this.max.x,this.min.y,this.min.z),i[5]=new Qe(this.max.x,this.min.y,this.max.z),i[6]=new Qe(this.max.x,this.max.y,this.min.z),i[7]=new Qe(this.max.x,this.max.y,this.max.z),i.forEach((function(i){i.subtract(e),i.applyMatrix(t),i.add(e)})),i},e.getBoundingSphere=function(t){this.getCenter(t.center);var e=new Qe;return t.radius=.5*this.getSize(e).length(),t},e.translate=function(t){return this.min.add(t),this.max.add(t),this},e.equals=function(t){return t.min.equals(this.min)&&t.max.equals(this.max)},t}(),Fr=function(){function t(t,e){void 0===t&&(t=Qe.ZERO),void 0===e&&(e=-1),this.center=t.clone(),this.radius=e}var e=t.prototype;return e.set=function(t,e){return this.center.copyFrom(t),this.radius=e,this},e.setFromPoints=function(t,e){var i=this.center;if(void 0!==e){i.copyFrom(e);for(var r=0,n=0;n<t.length;n++)r=Math.max(r,i.distanceSquared(t[n]));this.radius=Math.sqrt(r)}else{var s=(new Lr).setFromPoints(t);s.getCenter(i),this.radius=s.getSize().length()/2}return this},e.copyFrom=function(t){return this.center.copyFrom(t.center),this.radius=t.radius,this},e.isEmpty=function(){return this.radius<0},e.makeEmpty=function(){return this.center.set(0,0,0),this.radius=-1,this},e.containsPoint=function(t){return t.distanceSquared(this.center)<=this.radius*this.radius},e.distanceToPoint=function(t){return t.distance(this.center)-this.radius},e.intersectsSphere=function(t){var e=this.radius+t.radius;return t.center.distanceSquared(this.center)<=e*e},e.intersectsBox=function(t){return t.intersectsSphere(this)},e.clampPoint=function(t,e){var i=this.center.distanceSquared(t);return void 0===e&&(e=new Qe),e.copyFrom(t),i>this.radius*this.radius&&(e.subtract(this.center).normalize(),e.multiply(this.radius).add(this.center)),e},e.getBoundingBox=function(t){return void 0===t&&(t=new Lr),this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)},e.applyMatrix4=function(t){var e=t.elements,i=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],n=e[8]*e[8]+e[9]*e[9]+e[10]*e[10],s=Math.sqrt(Math.max(i,r,n));return this.center.applyMatrix(t),this.radius=this.radius*s,this},e.translate=function(t){return this.center.add(t),this},e.expandByPoint=function(t){var e=(new Qe).subtractVectors(t,this.center),i=e.lengthSquared();if(i>this.radius*this.radius){var r=Math.sqrt(i),n=.5*(r-this.radius);this.center.add(e.multiply(n/r)),this.radius+=n}return this},e.union=function(t){var e=new Qe,i=new Qe;return i.subtractVectors(t.center,this.center).normalize().multiply(t.radius),this.expandByPoint(e.copyFrom(t.center).add(i)),this.expandByPoint(e.copyFrom(t.center).subtract(i)),this},e.intersect=function(t){var e=(new Qe).subtractVectors(this.center,t.center),i=e.length();return i>this.radius+t.radius?this.makeEmpty():(this.center=this.center.add(e.normalize().multiply(i/2)),this.radius=this.radius+t.radius-i,this)},e.equals=function(t){return t.center.equals(this.center)&&t.radius===this.radius},e.clone=function(){return(new t).copyFrom(this)},t}(),Vr=Object.freeze({__proto__:null,get EulerOrder(){return br},Euler:Or,Quaternion:ri,Vector2:Ke,Vector3:Qe,Vector4:Je,Matrix3:Rr,Matrix4:ni,Ray:Mr,PI2:je,DEG2RAD:Xe,RAD2DEG:He,NumberEpsilon:Ye,isZero:function(t){return isNaN(t)||Math.abs(t)<Ye},isEqual:We,damp:function(t,e,i,r){return Ze(t,e,1-Math.exp(-i*r))},lerp:Ze,degToRad:function(t){return t*Xe},radToDeg:function(t){return t*He},clamp:qe,Color:ii,Box3:Lr,Sphere:Fr}),Nr=1,Dr=function(t){function e(e,i){var r;if((r=t.call(this,e)||this).destroyed=!1,r.visible=!0,i){var n=i.material,s=i.geometry,a=i.name,o=void 0===a?"<unnamed>":a,u=i.priority,h=void 0===u?0:u,c=i.worldMatrix,l=void 0===c?ni.fromIdentity():c;r.id="Mesh"+Nr++,r.name=o,r.geometry=s,r.material=n,r.priority=h,r.worldMatrix=l}else r.id="Mesh"+Nr++,r.name="<unnamed>",r.worldMatrix=ni.fromIdentity(),r._priority=0;return r}Qt(e,t);var i=e.prototype;return i.setVisible=function(t){this.visible=t},i.getVisible=function(){return this.visible},i.render=function(t){this.isDestroyed||this.getVisible()&&(t.renderingData.currentFrame.globalUniforms&&t.setGlobalMatrix("effects_ObjectToWorld",this.worldMatrix),t.drawGeometry(this.geometry,this.material))},i.firstGeometry=function(){return this.geometry},i.setMaterial=function(t,e){e!==pt.keep&&this.material.dispose(e),this.material=t},i.restore=function(){},i.dispose=function(t){if(!this.destroyed){(null==t?void 0:t.geometries)!==pt.keep&&this.geometry.dispose();var e=null==t?void 0:t.material;e!==pt.keep&&this.material.dispose(e),this.destroyed=!0,void 0!==this.engine&&(this.engine.removeMesh(this),this.engine=void 0)}},Pe(e,[{key:"isDestroyed",get:function(){return this.destroyed}}]),e}(Ge),kr=0,zr=1e3,Ur=3e3;!function(t){t[t.none=0]="none",t[t.color=1]="color",t[t.stencil_8_opaque=2]="stencil_8_opaque",t[t.depth_16_opaque=3]="depth_16_opaque",t[t.depth_stencil_opaque=4]="depth_stencil_opaque",t[t.depth_16_texture=5]="depth_16_texture",t[t.depth_24_stencil_8_texture=6]="depth_24_stencil_8_texture"}(Ir||(Ir={})),function(t){t[t.store=0]="store",t[t.clear=2]="clear"}(Pr||(Pr={}));var Br,Gr=function(){function t(t,e){if(this.destroyed=!1,e){var i=e.texture,r=e.size;if(A(i,Yi))this.texture=i,this.externalTexture=!0;else if(i){var n=i.wrapT,s=i.wrapS,a=i.minFilter,o=i.magFilter,u=i.internalFormat,h=i.format,c=void 0===h?fi.RGBA:h,l=i.type,f=void 0===l?fi.UNSIGNED_BYTE:l;this.externalTexture=!1,this.textureOptions={size:r,format:c,type:f,internalFormat:u||c,wrapT:n,wrapS:s,minFilter:a,magFilter:o,name:e.name},this.texture=Yi.create(t,_i({},this.textureOptions,{sourceType:ci.framebuffer,data:{width:r[0],height:r[1]}}))}}}return t.prototype.dispose=function(){this.destroyed||(this.texture.dispose(),this.destroyed=!0)},Pe(t,[{key:"isDestroyed",get:function(){return this.destroyed}},{key:"storageType",get:function(){return 1}},{key:"size",get:function(){var t=this.texture;return t?[t.getWidth(),t.getHeight()]:[0,0]}},{key:"width",get:function(){return this.texture.getWidth()||0}},{key:"height",get:function(){return this.texture.getHeight()||0}}]),t}();!function(t){t[t.force=0]="force",t[t.keep=1]="keep",t[t.keepExternal=2]="keepExternal",t[t.destroy=0]="destroy"}(Br||(Br={}));var jr=1,Xr=function(){function t(t,e){this.attachments=[],this.destroyed=!1,this.initialized=!1;var i=e.name,r=void 0===i?"RenderPass_"+jr++:i,n=e.clearAction,s=e.semantics,a=e.depthStencilAttachment,o=e.storeAction,u=e.priority,h=void 0===u?0:u,c=e.meshOrder,l=void 0===c?F.ascending:c,f=e.meshes,d=void 0===f?[]:f,p=e.delegate,m=void 0===p?{}:p;this.name=r,this.renderer=t,this.priority=h,this.meshOrder=l,this.meshes=rt(d.slice(),this.meshOrder),this.depthStencilType=(null==a?void 0:a.storageType)||0,this.clearAction=_i({},n),this.storeAction=_i({colorAction:0,depthAction:0,stencilAction:0},o),this.semantics=new wr(s),this.options=e,this.delegate=m,this.setViewportOptions(e)}var e=t.prototype;return e.addMesh=function(t){nt(this.meshes,t,this.meshOrder)},e.removeMesh=function(t){k(this.meshes,t)},e.setMeshes=function(t){var e;return this.meshes.length=0,(e=this.meshes).splice.apply(e,[].concat([0,0],t)),rt(this.meshes,this.meshOrder),this.meshes},e.getInitAttachments=function(){return this.attachments.length>0?this.attachments:this.options.attachments},e.configure=function(t){if(this.framebuffer)t.setFramebuffer(this.framebuffer);else{var e=this.getViewport(),i=e[0],r=e[1],n=e[2],s=e[3];t.setViewport(i,r,n,s)}},e.execute=function(t){t.clear(this.clearAction),t.renderMeshes(this.meshes),t.clear(this.storeAction)},e.frameCleanup=function(t){},e.resetColorAttachments=function(t){var e=this;if(t.length||this.resetAttachments({attachments:[]}),this.attachments.length){var i=t.map((function(t){return t.updateSource({sourceType:ci.framebuffer}),new Gr(e.renderer.engine,{texture:t})}));this.attachments.forEach((function(t){return!t.externalTexture&&t.dispose()})),this.attachments=i,this.framebuffer&&(this.framebuffer.bind(),this.framebuffer.resetColorTextures(t.map((function(t){return t}))))}else this.resetAttachments({attachments:t.map((function(t){return{texture:t}}))})},e.resetAttachments=function(t){this.options=t,this.setViewportOptions(t),this.renderer&&this._resetAttachments()},e.setViewportOptions=function(t){if(t.viewport){if(this.isCustomViewport=!0,this.viewportScale=1,this.customViewport=t.viewport.slice(0,4),this.framebuffer){var e=this.customViewport;this.framebuffer.isCustomViewport=!1,this.framebuffer.resize(e[0],e[1],e[2],e[3])}}else this.isCustomViewport=!1,this.viewportScale=t.viewportScale||1,this.framebuffer&&(this.framebuffer.isCustomViewport=!0,this.framebuffer.viewportScale=this.viewportScale)},e._resetAttachments=function(){var t,e,i=this,r=this.renderer,n=this.options;this.attachments.length&&(this.attachments.forEach((function(t){return!t.externalTexture&&t.dispose()})),this.attachments.length=0,null==(e=this.framebuffer)||e.dispose({depthStencilAttachment:2}),this.framebuffer=null);var s=this.viewportScale,a=this.isCustomViewport?this.customViewport:[0,0,r.getWidth()*s,r.getHeight()*s],o=[a[2],a[3]],u=this.name;if(null==(t=n.attachments)?void 0:t.length){var h=n.attachments.map((function(t,e){var r;return new Gr(i.renderer.engine,_i({size:o,name:(null==(r=t.texture)?void 0:r.name)||u+"##color_"+e},t))}));this.attachments=h;var c=Mn.create({storeAction:this.storeAction,name:u,viewport:a,viewportScale:this.viewportScale,isCustomViewport:this.isCustomViewport,attachments:h.map((function(t){return t.texture})),depthStencilAttachment:n.depthStencilAttachment||{storageType:0}},r);c.bind(),c.unbind(),this.framebuffer=c}else this.attachments.length=0},e.getViewport=function(){var t,e=(null==(t=this.framebuffer)?void 0:t.viewport)||this.customViewport;if(e)return e;var i=this.renderer,r=this.viewportScale;return i?[0,0,i.getWidth()*r,i.getHeight()*r]:[0,0,0,0]},e.getDepthAttachment=function(){var t=this.framebuffer;if(t){var e=t.getDepthTexture(),i=e?this.getDepthTexture(e,t.externalStorage):void 0;return{storageType:t.depthStencilStorageType,storage:t.depthStorage,texture:i}}},e.getStencilAttachment=function(){var t=this.framebuffer;if(t){var e=t.getStencilTexture(),i=e?this.getDepthTexture(e,t.externalStorage):void 0;return{storageType:t.depthStencilStorageType,storage:t.stencilStorage,texture:i}}},e.getDepthTexture=function(t,e){if(!this.depthTexture){var i,r=null==(i=this.options.depthStencilAttachment)?void 0:i.texture,n=t===r?r:t;return e||(this.depthTexture=n),n}return this.depthTexture},e.getStencilTexture=function(t,e){if(!this.stencilTexture){var i,r=null==(i=this.options.depthStencilAttachment)?void 0:i.texture,n=t===r?r:t;return e||(this.stencilTexture=n),n}return this.stencilTexture},e.initialize=function(t){return this.initialized||(this._resetAttachments(),this.initialized=!0),this},e.dispose=function(t){if(!this.destroyed){var e=(null==t?void 0:t.meshes)||void 0;e!==pt.keep&&this.meshes.forEach((function(t){t.dispose(e)})),this.meshes.length=0;var i=(null==t?void 0:t.colorAttachment)?t.colorAttachment:0;this.attachments.forEach((function(t){t.externalTexture&&2===i||1===i||t.dispose()})),this.attachments.length=0,(null==t?void 0:t.semantics)!==pt.keep&&this.semantics.dispose(),this.destroyed=!0;var r,n,s=(null==t?void 0:t.depthStencilAttachment)?t.depthStencilAttachment:0,a=this.framebuffer;if(a)if(a.dispose({depthStencilAttachment:s}),!(a.externalStorage&&2===s||1===s))null==(r=this.stencilTexture)||r.dispose(),null==(n=this.depthTexture)||n.dispose();this.options=this.renderer=null,this.initialize=_t}},Pe(t,[{key:"isDestroyed",get:function(){return this.destroyed}},{key:"viewport",get:function(){return this.getViewport()}},{key:"stencilAttachment",get:function(){return this.getStencilAttachment()}},{key:"depthAttachment",get:function(){return this.getDepthAttachment()}}]),t}(),Hr="vec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;float alpha=ret.a;if(mode==1.){ret.rgb*=alpha;}else if(mode==2.){ret.rgb*=alpha;ret.a=dot(ret.rgb,vec3(0.33333333));}else if(mode==3.){alpha=color.r*alpha;ret=vec4(vc.rgb*alpha,alpha);}return ret;}",Yr="#version 100\nprecision highp float;vec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;float alpha=ret.a;if(mode==1.){ret.rgb*=alpha;}else if(mode==2.){ret.rgb*=alpha;ret.a=dot(ret.rgb,vec3(0.33333333));}else if(mode==3.){alpha=color.r*alpha;ret=vec4(vc.rgb*alpha,alpha);}return ret;}varying vec4 vColor;varying vec4 vTexCoord;varying highp vec2 vParams;uniform vec3 uFrameColor;void main(){gl_FragColor=vec4(uFrameColor.xyz,1.0);}",Wr="float calculateMovement(float t,vec2 p1,vec2 p2,vec2 p3,vec2 p4){float movement=0.0;float h=(t-p1.x)*0.05;for(int i=0;i<=20;i++){float t=float(i)*h;float nt=binarySearchT(t,p1.x,p2.x,p3.x,p4.x);float y=cubicBezier(nt,p1.y,p2.y,p3.y,p4.y);float weight=(i==0||i==20)? 1.0 :(mod(float(i),2.)!=0.)? 4.0 : 2.0;movement+=weight*y;}movement*=h/3.;return movement;}float integrateFromBezierCurveFrames(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i+=2){vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);if(i==0&&time<k0.x){return ret;}vec2 p1=vec2(k0.x,k0.y);vec2 p2=vec2(k0.z,k0.w);vec2 p3=vec2(k1.z,k1.w);vec2 p4=vec2(k1.x,k1.y);if(time>=k1.x){ret+=calculateMovement(k1.x,p1,p2,p3,p4);}if(time>=k0.x&&time<k1.x){return ret+calculateMovement(time,p1,p2,p3,p4);}}return ret;}float integrateByTimeLineSeg(float t,vec2 p0,vec2 p1){float t0=p0.x;float t1=p1.x;float y0=p0.y;float y1=p1.y;vec4 tSqr=vec4(t,t,t0,t0);tSqr=tSqr*tSqr;vec4 a=vec4(2.*t,3.,-t0,3.)*tSqr;float t1y0=t1*y0;vec4 b=vec4(y0-y1,t0*y1-t1y0,2.*y0+y1,t1y0);float r=dot(a,b);return r/(t0-t1)*0.16666667;}float integrateLineSeg(float time,vec2 p0,vec2 p1){float h=time-p0.x;float y0=p0.y;return(y0+y0+(p1.y-y0)*h/(p1.x-p0.x))*h/2.;}float integrateFromLineSeg(float time,float frameStart,float frameCount){if(time==0.){return 0.;}int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i++){if(i>count){return ret;}vec4 ks=lookup_curve(i+start);vec2 k0=ks.xy;vec2 k1=ks.zw;if(time>k0.x&&time<=k1.x){return ret+integrateLineSeg(time,k0,k1);}ret+=integrateLineSeg(k1.x,k0,k1);vec2 k2=lookup_curve(i+start+1).xy;if(time>k1.x&&time<=k2.x){return ret+integrateLineSeg(time,k1,k2);}ret+=integrateLineSeg(k2.x,k1,k2);}return ret;}float integrateByTimeFromLineSeg(float time,float frameStart,float frameCount){if(time==0.){return 0.;}int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i++){if(i>count){return ret;}vec4 ks=lookup_curve(i+start);vec2 k0=ks.xy;vec2 k1=ks.zw;if(time>k0.x&&time<=k1.x){return ret+integrateByTimeLineSeg(time,k0,k1);}ret+=integrateByTimeLineSeg(k1.x,k0,k1);vec2 k2=lookup_curve(i+start+1).xy;if(time>k1.x&&time<=k2.x){return ret+integrateByTimeLineSeg(time,k1,k2);}ret+=integrateByTimeLineSeg(k2.x,k1,k2);}return ret;}float getIntegrateFromTime0(float t1,vec4 value){float type=value.x;if(type==0.){return value.y*t1;}if(type==1.){vec2 p0=vec2(0.,value.y);vec2 p1=vec2(value.w,value.z);return integrateLineSeg(t1,p0,p1);}if(type==3.){return integrateFromLineSeg(t1,value.y,value.z);}if(type==4.){return mix(value.y,value.z,aSeed)*t1;}if(type==5.){return integrateFromBezierCurveFrames(t1,value.z,value.w);}return 0.;}float getIntegrateByTimeFromTime(float t0,float t1,vec4 value){float type=value.x;if(type==0.){return value.y*(t1*t1-t0*t0)/2.;}else if(type==1.){vec2 p0=vec2(0.,value.y);vec2 p1=vec2(value.w,value.z);return integrateByTimeLineSeg(t1,p0,p1)-integrateByTimeLineSeg(t0,p0,p1);}if(type==3.){return integrateByTimeFromLineSeg(t1,value.y,value.z)-integrateByTimeFromLineSeg(t0,value.y,value.z);}if(type==4.){return mix(value.y,value.z,aSeed)*(t1*t1-t0*t0)/2.;}if(type==5.){return integrateFromBezierCurveFrames(t1,value.z,value.w)-integrateFromBezierCurveFrames(t0,value.z,value.w);}return 0.;}",Zr="precision highp float;attribute vec2 aUV;attribute vec3 aPos;varying vec2 vTexCoord;varying vec3 vParams;varying vec4 vColor;uniform vec2 _Size;uniform vec3 _Scale;uniform vec4 _Color;uniform vec4 _TexParams;uniform vec4 _TexOffset;uniform mat4 effects_MatrixVP;uniform mat4 effects_ObjectToWorld;uniform mat4 effects_MatrixV;\n#ifdef ENV_EDITOR\nuniform vec4 uEditorTransform;\n#endif\nvoid main(){vec4 texParams=_TexParams;vTexCoord=vec2(aUV.xy*_TexOffset.zw+_TexOffset.xy);vColor=_Color;vParams=vec3(texParams.w,texParams.y,texParams.x);if(texParams.z==1.0){vec4 pos=vec4(aPos.xy*_Size,aPos.z,1.0);gl_Position=effects_MatrixVP*effects_ObjectToWorld*pos;}else{mat4 view=effects_MatrixV;vec3 camRight=vec3(view[0][0],view[1][0],view[2][0]);vec3 camUp=vec3(view[0][1],view[1][1],view[2][1]);vec3 worldPosition=vec3(effects_ObjectToWorld*vec4(0.0,0.0,0.0,1.0));vec3 vertexPosition=worldPosition+camRight*aPos.x*_Size.x*_Scale.x+camUp*aPos.y*_Size.y*_Scale.y;gl_Position=effects_MatrixVP*vec4(vertexPosition,1.0);}\n#ifdef ENV_EDITOR\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#endif\n}",qr="precision highp float;varying vec4 vColor;varying vec2 vTexCoord;varying vec3 vParams;uniform sampler2D _MainTex;vec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;float alpha=ret.a;if(mode==1.){ret.rgb*=alpha;}else if(mode==2.){ret.rgb*=alpha;ret.a=dot(ret.rgb,vec3(0.33333333));}else if(mode==3.){alpha=color.r*alpha;ret=vec4(vc.rgb*alpha,alpha);}return ret;}void main(){vec4 color=vec4(0.);\n#ifdef TRANSPARENT_VIDEO\nfloat halfX=vTexCoord.x*0.5;vec2 uv_rgb=vec2(halfX,vTexCoord.y);vec2 uv_alpha=vec2(halfX+0.5,vTexCoord.y);vec3 rgb=texture2D(_MainTex,uv_rgb).rgb;float alpha=max(texture2D(_MainTex,uv_alpha).r,1e-5);vec4 texColor=vec4(rgb/alpha,alpha);\n#else\nvec4 texColor=texture2D(_MainTex,vTexCoord.xy);\n#endif\ncolor=blendColor(texColor,vColor,floor(0.5+vParams.y));\n#ifdef ALPHA_CLIP\nif(color.a<0.04){discard;}\n#endif\ncolor.a=clamp(color.a,0.0,1.0);gl_FragColor=color;}",Kr="#version 100\nprecision mediump float;vec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;float alpha=ret.a;if(mode==1.){ret.rgb*=alpha;}else if(mode==2.){ret.rgb*=alpha;ret.a=dot(ret.rgb,vec3(0.33333333));}else if(mode==3.){alpha=color.r*alpha;ret=vec4(vc.rgb*alpha,alpha);}return ret;}\n#define PATICLE_SHADER 1\nvarying float vLife;varying vec2 vTexCoord;varying vec4 vColor;uniform vec3 emissionColor;uniform float emissionIntensity;uniform sampler2D uMaskTex;uniform vec4 uColorParams;uniform vec2 uTexOffset;\n#ifdef COLOR_OVER_LIFETIME\nuniform sampler2D uColorOverLifetime;\n#endif\n#ifdef USE_SPRITE\nvarying vec4 vTexCoordBlend;\n#endif\nvarying float vSeed;\n#ifdef PREVIEW_BORDER\nuniform vec4 uPreviewColor;\n#endif\n#ifdef USE_SPRITE\nvec4 getTextureColor(sampler2D tex,vec2 texCoord){if(vTexCoordBlend.w>0.){return mix(texture2D(tex,texCoord),texture2D(tex,vTexCoordBlend.xy+texCoord),vTexCoordBlend.z);}return texture2D(tex,texCoord);}\n#else\n#define getTextureColor texture2D\n#endif\n#ifndef WEBGL2\n#define round(a) floor(0.5+a)\n#endif\n#ifdef PREVIEW_BORDER\nvoid main(){gl_FragColor=uPreviewColor;}\n#else\nvoid main(){vec4 color=vec4(1.0);vec4 tempColor=vColor;vec2 texOffset=uTexOffset;if(vLife<0.){discard;}if(uColorParams.x>0.0){color=getTextureColor(uMaskTex,vTexCoord);}\n#ifdef COLOR_OVER_LIFETIME\n#ifndef ENABLE_VERTEX_TEXTURE\ntempColor*=texture2D(uColorOverLifetime,vec2(vLife,0.));\n#endif\n#endif\ncolor=blendColor(color,tempColor,round(uColorParams.y));if(color.a<=0.01&&uColorParams.w>0.){float _at=texture2D(uMaskTex,vTexCoord+texOffset).a+texture2D(uMaskTex,vTexCoord+texOffset*-1.).a;if(_at<=0.02){discard;}}vec3 emission=emissionColor*pow(2.0,emissionIntensity);color=vec4(pow(pow(color.rgb,vec3(2.2))+emission,vec3(1.0/2.2)),color.a);gl_FragColor=color;}\n#endif\n",Qr="#version 100\nprecision mediump float;\n#define SHADER_VERTEX 1\n#define PATICLE_SHADER 1\n#ifdef SHADER_VERTEX\n#define CURVE_VALUE_TEXTURE uVCurveValueTexture\n#define CURVE_VALUE_ARRAY uVCurveValues\n#define CURVE_VALUE_COUNT VERT_CURVE_VALUE_COUNT\n#define FRAG_CURVE_VALUE_COUNT 0\n#else\n#define CURVE_VALUE_TEXTURE uFCurveValueTexture\n#define CURVE_VALUE_ARRAY uFCurveValues\n#define CURVE_VALUE_COUNT FRAG_CURVE_VALUE_COUNT\n#define VERT_CURVE_VALUE_COUNT 0\n#endif\n#if CURVE_VALUE_COUNT > 0\n#if LOOKUP_TEXTURE_CURVE\nuniform sampler2D CURVE_VALUE_TEXTURE;const float uCurveCount=1./float(CURVE_VALUE_COUNT);\n#define lookup_curve(i) texture2D(CURVE_VALUE_TEXTURE,vec2(float(i) * uCurveCount,0.))\n#else\nuniform vec4 CURVE_VALUE_ARRAY[CURVE_VALUE_COUNT];\n#define lookup_curve(i) CURVE_VALUE_ARRAY[i]\n#endif\n#else\n#define lookup_curve(i) vec4(0.)\n#endif\n#ifdef WEBGL2\n#define ITR_END (count + 1)\n#else\n#define ITR_END MAX_C\n#endif\n#define NONE_CONST_INDEX 1\n#ifdef SHADER_VERTEX\nattribute float aSeed;varying float vSeed;\n#endif\n#ifdef SHADER_VERTEX\n#define MAX_C VERT_MAX_KEY_FRAME_COUNT\n#else\n#define MAX_C FRAG_MAX_KEY_FRAME_COUNT\n#endif\nmat4 cubicBezierMatrix=mat4(1.0,-3.0,3.0,-1.0,0.0,3.0,-6.0,3.0,0.0,0.0,3.0,-3.0,0.0,0.0,0.0,1.0);float cubicBezier(float t,float y1,float y2,float y3,float y4){vec4 tVec=vec4(1.0,t,t*t,t*t*t);vec4 yVec=vec4(y1,y2,y3,y4);vec4 result=tVec*cubicBezierMatrix*yVec;return result.x+result.y+result.z+result.w;}float binarySearchT(float x,float x1,float x2,float x3,float x4){float left=0.0;float right=1.0;float mid=0.0;float computedX;for(int i=0;i<8;i++){mid=(left+right)*0.5;computedX=cubicBezier(mid,x1,x2,x3,x4);if(abs(computedX-x)<0.0001){break;}else if(computedX>x){right=mid;}else{left=mid;}}return mid;}float valueFromBezierCurveFrames(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);for(int i=0;i<ITR_END;i+=2){if(i>=count){break;}vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);if(i==0&&time<k0.x){return k0.y;}if(i==int(frameCount-2.)&&time>=k1.x){return k1.y;}if(time>=k0.x&&time<=k1.x){float t=(time-k0.x)/(k1.x-k0.x);float nt=binarySearchT(time,k0.x,k0.z,k1.z,k1.x);return cubicBezier(nt,k0.y,k0.w,k1.w,k1.y);}}}float evaluteLineSeg(float t,vec2 p0,vec2 p1){return p0.y+(p1.y-p0.y)*(t-p0.x)/(p1.x-p0.x);}float valueFromLineSegs(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);int end=start+count;for(int i=0;i<ITR_END;i++){if(i>count){return lookup_curve(i).w;}vec4 seg=lookup_curve(i+start);vec2 p0=seg.xy;vec2 p1=seg.zw;if(time>=p0.x&&time<=p1.x){return evaluteLineSeg(time,p0,p1);}vec2 p2=lookup_curve(i+start+1).xy;if(time>p1.x&&time<=p2.x){return evaluteLineSeg(time,p1,p2);}}return lookup_curve(0).y;}float getValueFromTime(float time,vec4 value){float type=value.x;if(type==0.){return value.y;}if(type==1.){return mix(value.y,value.z,time/value.w);}if(type==3.){return valueFromLineSegs(time,value.y,value.z);}if(type==4.){return mix(value.y,value.z,aSeed);}if(type==5.){return valueFromBezierCurveFrames(time,value.z,value.w);}return 0.;}float calculateMovement(float t,vec2 p1,vec2 p2,vec2 p3,vec2 p4){float movement=0.0;float h=(t-p1.x)*0.05;for(int i=0;i<=20;i++){float t=float(i)*h;float nt=binarySearchT(t,p1.x,p2.x,p3.x,p4.x);float y=cubicBezier(nt,p1.y,p2.y,p3.y,p4.y);float weight=(i==0||i==20)? 1.0 :(mod(float(i),2.)!=0.)? 4.0 : 2.0;movement+=weight*y;}movement*=h/3.;return movement;}float integrateFromBezierCurveFrames(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i+=2){vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);if(i==0&&time<k0.x){return ret;}vec2 p1=vec2(k0.x,k0.y);vec2 p2=vec2(k0.z,k0.w);vec2 p3=vec2(k1.z,k1.w);vec2 p4=vec2(k1.x,k1.y);if(time>=k1.x){ret+=calculateMovement(k1.x,p1,p2,p3,p4);}if(time>=k0.x&&time<k1.x){return ret+calculateMovement(time,p1,p2,p3,p4);}}return ret;}float integrateByTimeLineSeg(float t,vec2 p0,vec2 p1){float t0=p0.x;float t1=p1.x;float y0=p0.y;float y1=p1.y;vec4 tSqr=vec4(t,t,t0,t0);tSqr=tSqr*tSqr;vec4 a=vec4(2.*t,3.,-t0,3.)*tSqr;float t1y0=t1*y0;vec4 b=vec4(y0-y1,t0*y1-t1y0,2.*y0+y1,t1y0);float r=dot(a,b);return r/(t0-t1)*0.16666667;}float integrateLineSeg(float time,vec2 p0,vec2 p1){float h=time-p0.x;float y0=p0.y;return(y0+y0+(p1.y-y0)*h/(p1.x-p0.x))*h/2.;}float integrateFromLineSeg(float time,float frameStart,float frameCount){if(time==0.){return 0.;}int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i++){if(i>count){return ret;}vec4 ks=lookup_curve(i+start);vec2 k0=ks.xy;vec2 k1=ks.zw;if(time>k0.x&&time<=k1.x){return ret+integrateLineSeg(time,k0,k1);}ret+=integrateLineSeg(k1.x,k0,k1);vec2 k2=lookup_curve(i+start+1).xy;if(time>k1.x&&time<=k2.x){return ret+integrateLineSeg(time,k1,k2);}ret+=integrateLineSeg(k2.x,k1,k2);}return ret;}float integrateByTimeFromLineSeg(float time,float frameStart,float frameCount){if(time==0.){return 0.;}int start=int(frameStart);int count=int(frameCount-1.);float ret=0.;for(int i=0;i<ITR_END;i++){if(i>count){return ret;}vec4 ks=lookup_curve(i+start);vec2 k0=ks.xy;vec2 k1=ks.zw;if(time>k0.x&&time<=k1.x){return ret+integrateByTimeLineSeg(time,k0,k1);}ret+=integrateByTimeLineSeg(k1.x,k0,k1);vec2 k2=lookup_curve(i+start+1).xy;if(time>k1.x&&time<=k2.x){return ret+integrateByTimeLineSeg(time,k1,k2);}ret+=integrateByTimeLineSeg(k2.x,k1,k2);}return ret;}float getIntegrateFromTime0(float t1,vec4 value){float type=value.x;if(type==0.){return value.y*t1;}if(type==1.){vec2 p0=vec2(0.,value.y);vec2 p1=vec2(value.w,value.z);return integrateLineSeg(t1,p0,p1);}if(type==3.){return integrateFromLineSeg(t1,value.y,value.z);}if(type==4.){return mix(value.y,value.z,aSeed)*t1;}if(type==5.){return integrateFromBezierCurveFrames(t1,value.z,value.w);}return 0.;}float getIntegrateByTimeFromTime(float t0,float t1,vec4 value){float type=value.x;if(type==0.){return value.y*(t1*t1-t0*t0)/2.;}else if(type==1.){vec2 p0=vec2(0.,value.y);vec2 p1=vec2(value.w,value.z);return integrateByTimeLineSeg(t1,p0,p1)-integrateByTimeLineSeg(t0,p0,p1);}if(type==3.){return integrateByTimeFromLineSeg(t1,value.y,value.z)-integrateByTimeFromLineSeg(t0,value.y,value.z);}if(type==4.){return mix(value.y,value.z,aSeed)*(t1*t1-t0*t0)/2.;}if(type==5.){return integrateFromBezierCurveFrames(t1,value.z,value.w)-integrateFromBezierCurveFrames(t0,value.z,value.w);}return 0.;}const float d2r=3.141592653589793/180.;attribute vec3 aPos;attribute vec4 aOffset;attribute vec4 aColor;attribute vec3 aDirX;attribute vec3 aDirY;attribute vec3 aTranslation;attribute vec3 aRotation0;attribute vec3 aRotation1;attribute vec3 aRotation2;attribute vec3 aLinearMove;\n#ifdef USE_SPRITE\nattribute vec3 aSprite;uniform vec4 uSprite;struct UVDetail{vec2 uv0;vec3 uv1;};UVDetail getSpriteUV(vec2 uv,float lifeTime);varying vec4 vTexCoordBlend;\n#endif\n#ifdef FINAL_TARGET\nuniform vec3 uFinalTarget;uniform vec4 uForceCurve;\n#endif\nuniform mat4 effects_ObjectToWorld;uniform mat4 effects_MatrixV;uniform mat4 effects_MatrixVP;uniform vec4 uParams;uniform vec4 uOpacityOverLifetimeValue;\n#ifdef COLOR_OVER_LIFETIME\nuniform sampler2D uColorOverLifetime;\n#endif\nuniform vec4 uOrbXByLifetimeValue;uniform vec4 uOrbYByLifetimeValue;uniform vec4 uOrbZByLifetimeValue;uniform vec3 uOrbCenter;uniform vec4 uSizeByLifetimeValue;\n#ifdef SIZE_Y_BY_LIFE\nuniform vec4 uSizeYByLifetimeValue;\n#endif\nvarying float vLife;varying vec4 vColor;varying vec2 vTexCoord;\n#ifdef ENV_EDITOR\nuniform vec4 uEditorTransform;\n#endif\nvec3 calOrbitalMov(float _life,float _dur){vec3 orb=vec3(0.0);\n#ifdef AS_ORBITAL_MOVEMENT\n#define FUNC(a) getValueFromTime(_life,a)\n#else\n#define FUNC(a) getIntegrateFromTime0(_life,a) * _dur\n#endif\n#if ORB_VEL_X\norb.x=FUNC(uOrbXByLifetimeValue);\n#endif\n#if ORB_VEL_Y\norb.y=FUNC(uOrbYByLifetimeValue);\n#endif\n#if ORB_VEL_Z\norb.z=FUNC(uOrbZByLifetimeValue);\n#endif\n#undef FUNC\nreturn orb;}mat3 mat3FromRotation(vec3 rotation){vec3 sinR=sin(rotation*d2r);vec3 cosR=cos(rotation*d2r);return mat3(cosR.z,-sinR.z,0.,sinR.z,cosR.z,0.,0.,0.,1.)*mat3(cosR.y,0.,sinR.y,0.,1.,0.,-sinR.y,0,cosR.y)*mat3(1.,0.,0.,0,cosR.x,-sinR.x,0.,sinR.x,cosR.x);}\n#ifdef USE_SPRITE\nUVDetail getSpriteUV(vec2 uv,float lifeTime){float t=fract(clamp((lifeTime-aSprite.x)/aSprite.y,0.0,1.)*aSprite.z);float frame=uSprite.z*t;float frameIndex=max(ceil(frame)-1.,0.);float row=floor((frameIndex+0.1)/uSprite.x);float col=frameIndex-row*uSprite.x;vec2 retUV=(vec2(col,row)+uv)/uSprite.xy;UVDetail ret;if(uSprite.w>0.){float blend=frame-frameIndex;float frameIndex1=min(ceil(frame),uSprite.z-1.);float row1=floor((frameIndex1+0.1)/uSprite.x);float col1=frameIndex1-row1*uSprite.x;vec2 coord=(vec2(col1,row1)+uv)/uSprite.xy-retUV;ret.uv1=vec3(coord.x,1.-coord.y,blend);}ret.uv0=vec2(retUV.x,1.-retUV.y);return ret;}\n#endif\nvoid main(){float time=uParams.x-aOffset.z;float dur=aOffset.w;if(time<0.||time>dur){gl_Position=vec4(-3.,-3.,-3.,1.);}else{float life=clamp(time/dur,0.0,1.0);vLife=life;\n#ifdef USE_SPRITE\nUVDetail uvD=getSpriteUV(aOffset.xy,time);vTexCoord=uvD.uv0;vTexCoordBlend=vec4(uvD.uv1,uSprite.w);\n#else\nvTexCoord=aOffset.xy;\n#endif\nvColor=aColor;\n#ifdef COLOR_OVER_LIFETIME\n#ifdef ENABLE_VERTEX_TEXTURE\nvColor*=texture2D(uColorOverLifetime,vec2(life,0.));\n#endif\n#endif\nvColor.a*=clamp(getValueFromTime(life,uOpacityOverLifetimeValue),0.,1.);vec3 size=vec3(vec2(getValueFromTime(life,uSizeByLifetimeValue)),1.0);\n#ifdef SIZE_Y_BY_LIFE\nsize.y=getValueFromTime(life,uSizeYByLifetimeValue);\n#endif\nmat3 aRotation=mat3(aRotation0,aRotation1,aRotation2);vec3 point=aRotation*(aDirX*size.x+aDirY*size.y);vec3 _pos=aPos+aTranslation;\n#if ORB_VEL_X + ORB_VEL_Y + ORB_VEL_Z\n_pos=mat3FromRotation(calOrbitalMov(life,dur))*(_pos-uOrbCenter);_pos+=uOrbCenter;\n#endif\n_pos.xyz+=aLinearMove;\n#ifdef FINAL_TARGET\nfloat force=getValueFromTime(life,uForceCurve);vec4 pos=vec4(mix(_pos,uFinalTarget,force),1.);\n#else\nvec4 pos=vec4(_pos,1.0);\n#endif\n#if RENDER_MODE == 1\npos.xyz+=point;pos=effects_ObjectToWorld*pos;\n#elif RENDER_MODE == 3\npos=effects_ObjectToWorld*pos;pos.xyz+=effects_MatrixV[0].xyz*point.x+effects_MatrixV[2].xyz*point.y;\n#elif RENDER_MODE == 2\npos=effects_ObjectToWorld*pos;pos.xy+=point.xy;\n#elif RENDER_MODE == 0\npos=effects_ObjectToWorld*pos;pos.xyz+=effects_MatrixV[0].xyz*point.x+effects_MatrixV[1].xyz*point.y;\n#endif\ngl_Position=effects_MatrixVP*pos;vSeed=aSeed;gl_PointSize=6.0;\n#ifdef ENV_EDITOR\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#endif\n}}",Jr="#version 100\nprecision mediump float;\n#define SHADER_VERTEX 1\n#ifdef SHADER_VERTEX\n#define CURVE_VALUE_TEXTURE uVCurveValueTexture\n#define CURVE_VALUE_ARRAY uVCurveValues\n#define CURVE_VALUE_COUNT VERT_CURVE_VALUE_COUNT\n#define FRAG_CURVE_VALUE_COUNT 0\n#else\n#define CURVE_VALUE_TEXTURE uFCurveValueTexture\n#define CURVE_VALUE_ARRAY uFCurveValues\n#define CURVE_VALUE_COUNT FRAG_CURVE_VALUE_COUNT\n#define VERT_CURVE_VALUE_COUNT 0\n#endif\n#if CURVE_VALUE_COUNT > 0\n#if LOOKUP_TEXTURE_CURVE\nuniform sampler2D CURVE_VALUE_TEXTURE;const float uCurveCount=1./float(CURVE_VALUE_COUNT);\n#define lookup_curve(i) texture2D(CURVE_VALUE_TEXTURE,vec2(float(i) * uCurveCount,0.))\n#else\nuniform vec4 CURVE_VALUE_ARRAY[CURVE_VALUE_COUNT];\n#define lookup_curve(i) CURVE_VALUE_ARRAY[i]\n#endif\n#else\n#define lookup_curve(i) vec4(0.)\n#endif\n#ifdef WEBGL2\n#define ITR_END (count + 1)\n#else\n#define ITR_END MAX_C\n#endif\n#define NONE_CONST_INDEX 1\n#ifdef SHADER_VERTEX\nattribute float aSeed;varying float vSeed;\n#endif\n#ifdef SHADER_VERTEX\n#define MAX_C VERT_MAX_KEY_FRAME_COUNT\n#else\n#define MAX_C FRAG_MAX_KEY_FRAME_COUNT\n#endif\nmat4 cubicBezierMatrix=mat4(1.0,-3.0,3.0,-1.0,0.0,3.0,-6.0,3.0,0.0,0.0,3.0,-3.0,0.0,0.0,0.0,1.0);float cubicBezier(float t,float y1,float y2,float y3,float y4){vec4 tVec=vec4(1.0,t,t*t,t*t*t);vec4 yVec=vec4(y1,y2,y3,y4);vec4 result=tVec*cubicBezierMatrix*yVec;return result.x+result.y+result.z+result.w;}float binarySearchT(float x,float x1,float x2,float x3,float x4){float left=0.0;float right=1.0;float mid=0.0;float computedX;for(int i=0;i<8;i++){mid=(left+right)*0.5;computedX=cubicBezier(mid,x1,x2,x3,x4);if(abs(computedX-x)<0.0001){break;}else if(computedX>x){right=mid;}else{left=mid;}}return mid;}float valueFromBezierCurveFrames(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);for(int i=0;i<ITR_END;i+=2){if(i>=count){break;}vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);if(i==0&&time<k0.x){return k0.y;}if(i==int(frameCount-2.)&&time>=k1.x){return k1.y;}if(time>=k0.x&&time<=k1.x){float t=(time-k0.x)/(k1.x-k0.x);float nt=binarySearchT(time,k0.x,k0.z,k1.z,k1.x);return cubicBezier(nt,k0.y,k0.w,k1.w,k1.y);}}}float evaluteLineSeg(float t,vec2 p0,vec2 p1){return p0.y+(p1.y-p0.y)*(t-p0.x)/(p1.x-p0.x);}float valueFromLineSegs(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);int end=start+count;for(int i=0;i<ITR_END;i++){if(i>count){return lookup_curve(i).w;}vec4 seg=lookup_curve(i+start);vec2 p0=seg.xy;vec2 p1=seg.zw;if(time>=p0.x&&time<=p1.x){return evaluteLineSeg(time,p0,p1);}vec2 p2=lookup_curve(i+start+1).xy;if(time>p1.x&&time<=p2.x){return evaluteLineSeg(time,p1,p2);}}return lookup_curve(0).y;}float getValueFromTime(float time,vec4 value){float type=value.x;if(type==0.){return value.y;}if(type==1.){return mix(value.y,value.z,time/value.w);}if(type==3.){return valueFromLineSegs(time,value.y,value.z);}if(type==4.){return mix(value.y,value.z,aSeed);}if(type==5.){return valueFromBezierCurveFrames(time,value.z,value.w);}return 0.;}attribute vec4 aPos;attribute vec3 aDir;attribute vec3 aInfo;attribute vec4 aColor;attribute float aTime;\n#ifdef ATTR_TRAIL_START\nattribute float aTrailStart;\n#else\nuniform float uTrailStart[64];attribute float aTrailStartIndex;\n#endif\nuniform mat4 effects_MatrixInvV;uniform mat4 effects_ObjectToWorld;uniform mat4 effects_MatrixVP;uniform vec4 uTextureMap;uniform float uTime;uniform vec4 uParams;uniform vec4 uColorParams;uniform vec4 uOpacityOverLifetimeValue;uniform vec4 uWidthOverTrail;\n#ifdef COLOR_OVER_TRAIL\nuniform sampler2D uColorOverTrail;\n#endif\n#ifdef COLOR_OVER_LIFETIME\nuniform sampler2D uColorOverLifetime;\n#endif\nvarying float vLife;varying vec2 vTexCoord;varying vec4 vColor;\n#ifdef ENV_EDITOR\nuniform vec4 uEditorTransform;\n#endif\nvoid main(){vec4 _pa=effects_MatrixVP*vec4(aPos.xyz,1.);vec4 _pb=effects_MatrixVP*vec4(aPos.xyz+aDir,1.);vec2 dir=normalize(_pb.xy/_pb.w-_pa.xy/_pa.w);vec2 screen_xy=vec2(-dir.y,dir.x);vec4 pos=effects_ObjectToWorld*vec4(aPos.xyz,1.);\n#ifdef ATTR_TRAIL_START\nfloat ts=aTrailStart;\n#else\nfloat ts=uTrailStart[int(aTrailStartIndex)];\n#endif\nfloat trail=(ts-aInfo.y)/uParams.y;float width=aPos.w*getValueFromTime(trail,uWidthOverTrail)/max(abs(screen_xy.x),abs(screen_xy.y));pos.xyz+=(effects_MatrixInvV[0].xyz*screen_xy.x+effects_MatrixInvV[1].xyz*screen_xy.y)*width;float time=min((uTime-aTime)/aInfo.x,1.0);gl_Position=effects_MatrixVP*pos;vColor=aColor;\n#ifdef COLOR_OVER_LIFETIME\n#ifdef ENABLE_VERTEX_TEXTURE\nvColor*=texture2D(uColorOverLifetime,vec2(time,0.));\n#endif\n#endif\n#ifdef COLOR_OVER_TRAIL\nvColor*=texture2D(uColorOverTrail,vec2(trail,0.));\n#endif\nvColor.a*=clamp(getValueFromTime(time,uOpacityOverLifetimeValue),0.,1.);vLife=time;vTexCoord=uTextureMap.xy+vec2(trail,aInfo.z)*uTextureMap.zw;vSeed=aSeed;\n#ifdef ENV_EDITOR\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#endif\n}",$r="#ifdef SHADER_VERTEX\n#define CURVE_VALUE_TEXTURE uVCurveValueTexture\n#define CURVE_VALUE_ARRAY uVCurveValues\n#define CURVE_VALUE_COUNT VERT_CURVE_VALUE_COUNT\n#define FRAG_CURVE_VALUE_COUNT 0\n#else\n#define CURVE_VALUE_TEXTURE uFCurveValueTexture\n#define CURVE_VALUE_ARRAY uFCurveValues\n#define CURVE_VALUE_COUNT FRAG_CURVE_VALUE_COUNT\n#define VERT_CURVE_VALUE_COUNT 0\n#endif\n#if CURVE_VALUE_COUNT > 0\n#if LOOKUP_TEXTURE_CURVE\nuniform sampler2D CURVE_VALUE_TEXTURE;const float uCurveCount=1./float(CURVE_VALUE_COUNT);\n#define lookup_curve(i) texture2D(CURVE_VALUE_TEXTURE,vec2(float(i) * uCurveCount,0.))\n#else\nuniform vec4 CURVE_VALUE_ARRAY[CURVE_VALUE_COUNT];\n#define lookup_curve(i) CURVE_VALUE_ARRAY[i]\n#endif\n#else\n#define lookup_curve(i) vec4(0.)\n#endif\n#ifdef WEBGL2\n#define ITR_END (count + 1)\n#else\n#define ITR_END MAX_C\n#endif\n#define NONE_CONST_INDEX 1\n#ifdef SHADER_VERTEX\nattribute float aSeed;varying float vSeed;\n#endif\n#ifdef SHADER_VERTEX\n#define MAX_C VERT_MAX_KEY_FRAME_COUNT\n#else\n#define MAX_C FRAG_MAX_KEY_FRAME_COUNT\n#endif\nmat4 cubicBezierMatrix=mat4(1.0,-3.0,3.0,-1.0,0.0,3.0,-6.0,3.0,0.0,0.0,3.0,-3.0,0.0,0.0,0.0,1.0);float cubicBezier(float t,float y1,float y2,float y3,float y4){vec4 tVec=vec4(1.0,t,t*t,t*t*t);vec4 yVec=vec4(y1,y2,y3,y4);vec4 result=tVec*cubicBezierMatrix*yVec;return result.x+result.y+result.z+result.w;}float binarySearchT(float x,float x1,float x2,float x3,float x4){float left=0.0;float right=1.0;float mid=0.0;float computedX;for(int i=0;i<8;i++){mid=(left+right)*0.5;computedX=cubicBezier(mid,x1,x2,x3,x4);if(abs(computedX-x)<0.0001){break;}else if(computedX>x){right=mid;}else{left=mid;}}return mid;}float valueFromBezierCurveFrames(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);for(int i=0;i<ITR_END;i+=2){if(i>=count){break;}vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);if(i==0&&time<k0.x){return k0.y;}if(i==int(frameCount-2.)&&time>=k1.x){return k1.y;}if(time>=k0.x&&time<=k1.x){float t=(time-k0.x)/(k1.x-k0.x);float nt=binarySearchT(time,k0.x,k0.z,k1.z,k1.x);return cubicBezier(nt,k0.y,k0.w,k1.w,k1.y);}}}float evaluteLineSeg(float t,vec2 p0,vec2 p1){return p0.y+(p1.y-p0.y)*(t-p0.x)/(p1.x-p0.x);}float valueFromLineSegs(float time,float frameStart,float frameCount){int start=int(frameStart);int count=int(frameCount-1.);int end=start+count;for(int i=0;i<ITR_END;i++){if(i>count){return lookup_curve(i).w;}vec4 seg=lookup_curve(i+start);vec2 p0=seg.xy;vec2 p1=seg.zw;if(time>=p0.x&&time<=p1.x){return evaluteLineSeg(time,p0,p1);}vec2 p2=lookup_curve(i+start+1).xy;if(time>p1.x&&time<=p2.x){return evaluteLineSeg(time,p1,p2);}}return lookup_curve(0).y;}float getValueFromTime(float time,vec4 value){float type=value.x;if(type==0.){return value.y;}if(type==1.){return mix(value.y,value.z,time/value.w);}if(type==3.){return valueFromLineSegs(time,value.y,value.z);}if(type==4.){return mix(value.y,value.z,aSeed);}if(type==5.){return valueFromBezierCurveFrames(time,value.z,value.w);}return 0.;}",tn="#ifdef SHADER_VERTEX\n#define CURVE_VALUE_TEXTURE uVCurveValueTexture\n#define CURVE_VALUE_ARRAY uVCurveValues\n#define CURVE_VALUE_COUNT VERT_CURVE_VALUE_COUNT\n#define FRAG_CURVE_VALUE_COUNT 0\n#else\n#define CURVE_VALUE_TEXTURE uFCurveValueTexture\n#define CURVE_VALUE_ARRAY uFCurveValues\n#define CURVE_VALUE_COUNT FRAG_CURVE_VALUE_COUNT\n#define VERT_CURVE_VALUE_COUNT 0\n#endif\n#if CURVE_VALUE_COUNT > 0\n#if LOOKUP_TEXTURE_CURVE\nuniform sampler2D CURVE_VALUE_TEXTURE;const float uCurveCount=1./float(CURVE_VALUE_COUNT);\n#define lookup_curve(i) texture2D(CURVE_VALUE_TEXTURE,vec2(float(i) * uCurveCount,0.))\n#else\nuniform vec4 CURVE_VALUE_ARRAY[CURVE_VALUE_COUNT];\n#define lookup_curve(i) CURVE_VALUE_ARRAY[i]\n#endif\n#else\n#define lookup_curve(i) vec4(0.)\n#endif\n#ifdef WEBGL2\n#define ITR_END (count + 1)\n#else\n#define ITR_END MAX_C\n#endif\n",en="precision highp float;attribute vec2 aPos;varying vec2 uv;void main(){gl_Position=vec4(aPos,0.,1.0);uv=(aPos+vec2(1.0))/2.;}",rn="precision highp float;\n#define HALF_MAX 60000.0\n#define ACEScc_MIDGRAY 0.4135884\nvarying vec2 uv;uniform sampler2D _GaussianTex;uniform sampler2D _SceneTex;uniform float _BloomIntensity;uniform float _Brightness;uniform float _Saturation;uniform float _Contrast;uniform bool _UseBloom;uniform bool _UseToneMapping;uniform vec3 _VignetteColor;uniform vec2 _VignetteCenter;uniform float _VignetteIntensity;uniform float _VignetteSmoothness;uniform float _VignetteRoundness;mat3 LinearToACES=mat3(0.59719,0.07600,0.02840,0.35458,0.90834,0.13383,0.04823,0.01566,0.83777);mat3 ACESToLinear=mat3(1.60475,-0.10208,-0.00327,-0.53108,1.10813,-0.07276,-0.07367,-0.00605,1.07602);float log10(float x){return log(x)/log(10.0);}vec3 log10(vec3 v){return vec3(log10(v.x),log10(v.y),log10(v.z));}vec3 LinearToLogC(vec3 x){return 0.244161*log10(5.555556*x+0.047996)+0.386036;}vec3 LogCToLinear(vec3 x){return(pow(vec3(10.0),(x-0.386036)/0.244161)-0.047996)/5.555556;}vec3 rrt_and_odt_fit(vec3 col){vec3 a=col*(col+0.0245786)-0.000090537;vec3 b=col*(0.983729*col+0.4329510)+0.238081;return a/b;}vec3 ACESToneMapping(vec3 col){vec3 aces=LinearToACES*col;aces=rrt_and_odt_fit(aces);col=ACESToLinear*aces;return col;}vec3 LinearToSrgb(vec3 c){return mix(1.055*pow(c,vec3(1./2.4))-0.055,12.92*c,step(c,vec3(0.0031308)));}vec3 GammaCorrection(vec3 c){return pow(c,vec3(1.0/2.2));}vec3 ApplyVignette(vec3 inputColor,vec2 uv,vec2 center,float intensity,float roundness,float smoothness,vec3 color){vec2 dist=abs(uv-center)*intensity;dist.x*=roundness;float vfactor=pow(clamp((1.0-dot(dist,dist)),0.0,1.0),smoothness);return inputColor*mix(color,vec3(1.0),vfactor);}void main(){vec4 hdrColor=texture2D(_SceneTex,uv);hdrColor.rgb=pow(hdrColor.rgb,vec3(2.2));vec3 finalColor=hdrColor.rgb;if(_UseBloom){vec4 bloomColor=texture2D(_GaussianTex,uv);bloomColor.rgb*=_BloomIntensity;finalColor+=bloomColor.rgb;}if(_VignetteIntensity>0.0){finalColor=ApplyVignette(finalColor,uv,_VignetteCenter,_VignetteIntensity,_VignetteRoundness,_VignetteSmoothness,_VignetteColor);}finalColor=finalColor*_Brightness;vec3 colorLog=LinearToLogC(finalColor);colorLog=(colorLog-ACEScc_MIDGRAY)*_Contrast+ACEScc_MIDGRAY;finalColor=LogCToLinear(colorLog);finalColor=max(finalColor,0.0);float luminance=0.2125*finalColor.r+0.7154*finalColor.g+0.0721*finalColor.b;vec3 luminanceColor=vec3(luminance,luminance,luminance);finalColor=(finalColor-luminanceColor)*_Saturation+luminanceColor;finalColor=max(finalColor,0.0);if(_UseToneMapping){finalColor=max(vec3(0.0),ACESToneMapping(finalColor));}float alpha=min(hdrColor.a,1.0);gl_FragColor=vec4(clamp(GammaCorrection(finalColor),0.0,1.0),alpha);}",nn="precision highp float;varying vec2 uv;uniform sampler2D _MainTex;uniform vec2 _TextureSize;float GaussWeight2D(float x,float y,float sigma){float PI=3.14159265358;float E=2.71828182846;float sigma_2=pow(sigma,2.0);float a=-(x*x+y*y)/(2.0*sigma_2);return pow(E,a)/(2.0*PI*sigma_2);}vec3 GaussNxN(sampler2D tex,vec2 uv,vec2 stride,float sigma){vec3 color=vec3(0.,0.,0.);const int r=5/2;float weight=0.0;for(int i=-r;i<=r;i++){for(int j=-r;j<=r;j++){float w=GaussWeight2D(float(i),float(j),sigma);vec2 coord=uv+vec2(i,j)*stride;color+=texture2D(tex,coord).rgb*w;weight+=w;}}color/=weight;return color;}void main(){vec4 mainColor=texture2D(_MainTex,uv);vec3 color=mainColor.rgb;color=GaussNxN(_MainTex,uv,1.0/_TextureSize,1.0);gl_FragColor=vec4(color,1.0);}",sn="precision highp float;varying vec2 uv;uniform sampler2D _MainTex;uniform vec2 _TextureSize;vec3 GaussH(sampler2D tex,vec2 uv){vec3 color=vec3(0.0);float offsets[9];offsets[0]=-4.0;offsets[1]=-3.0;offsets[2]=-2.0;offsets[3]=-1.0;offsets[4]=0.0;offsets[5]=1.0;offsets[6]=2.0;offsets[7]=3.0;offsets[8]=4.0;float weights[9];weights[0]=0.01621622;weights[1]=0.05405405;weights[2]=0.12162162;weights[3]=0.19459459;weights[4]=0.22702703;weights[5]=0.19459459;weights[6]=0.12162162;weights[7]=0.05405405;weights[8]=0.01621622;for(int i=0;i<9;i++){vec2 offset=vec2(offsets[i]*2.0*(1.0/_TextureSize.x),0);color+=texture2D(tex,uv+offset).rgb*weights[i];}return color;}void main(){vec3 color=GaussH(_MainTex,uv);gl_FragColor=vec4(color,1.0);}",an="precision highp float;varying vec2 uv;uniform sampler2D _MainTex;uniform vec2 _TextureSize;vec3 GaussV(sampler2D tex,vec2 uv){vec3 color=vec3(0.0);float offsets[5];offsets[0]=-3.23076923;offsets[1]=-1.38461538;offsets[2]=0.0;offsets[3]=1.38461538;offsets[4]=3.23076923;float weights[5];weights[0]=0.07027027;weights[1]=0.31621622;weights[2]=0.22702703;weights[3]=0.31621622;weights[4]=0.07027027;for(int i=0;i<5;i++){vec2 offset=vec2(0,offsets[i]*(1.0/_TextureSize.y));color+=texture2D(tex,uv+offset).rgb*weights[i];}return color;}void main(){vec3 color=GaussV(_MainTex,uv);gl_FragColor=vec4(color,1.0);}",on="precision highp float;varying vec2 uv;uniform sampler2D _MainTex;uniform sampler2D _GaussianDownTex;uniform vec2 _GaussianDownTextureSize;float GaussWeight2D(float x,float y,float sigma){float PI=3.14159265358;float E=2.71828182846;float sigma_2=pow(sigma,2.0);float a=-(x*x+y*y)/(2.0*sigma_2);return pow(E,a)/(2.0*PI*sigma_2);}vec3 GaussNxN(sampler2D tex,vec2 uv,vec2 stride,float sigma){vec3 color=vec3(0.,0.,0.);const int r=1;float weight=0.0;for(int i=-r;i<=r;i++){for(int j=-r;j<=r;j++){float w=GaussWeight2D(float(i),float(j),sigma);vec2 coord=uv+vec2(i,j)*stride;color+=texture2D(tex,coord).rgb*w;weight+=w;}}color/=weight;return color;}void main(){vec3 lowResColor=GaussNxN(_MainTex,uv,0.5/_GaussianDownTextureSize,1.0);vec3 highResColor=GaussNxN(_GaussianDownTex,uv,1.0/_GaussianDownTextureSize,1.0);vec3 color=mix(highResColor,lowResColor,0.7);gl_FragColor=vec4(color,1.0);}",un="precision highp float;varying vec2 uv;uniform sampler2D _MainTex;uniform float _Threshold;void main(){vec4 mainTex=texture2D(_MainTex,uv);mainTex.rgb=pow(mainTex.rgb,vec3(2.2));float brightness=max(mainTex.r,max(mainTex.g,mainTex.b));float w=max(0.0,brightness-_Threshold)/max(brightness,0.00001);mainTex.rgb*=w;mainTex.rgb*=mainTex.a;gl_FragColor=vec4(mainTex.rgb,1.0);}",hn={},cn=function(){function t(){}return t.registerInclude=function(t,e){hn[t]&&mt.warn('The "'+t+'" shader include already exist.'),hn[t]=e},t.unRegisterInclude=function(t){delete hn[t]},t.unRegisterAllIncludes=function(){Object.keys(hn).forEach((function(e){t.unRegisterInclude(e)}))},t.genFinalShaderCode=function(e){var i=e.level,r=e.shaderType,n=e.shader,s=e.macros,a=e.removeVersion,o=t.genMacroString(i,s),u=t.genShaderVersion(i),h=t.parseIncludes(n),c=t.isVersion300(h);return h=t.removeWebGLVersion(h),2!==i||c||(h=t.convertTo300(h,r===oi.fragment)),a?o+h:u+o+h},t.convertTo300=function(e,i){if(e=(e=(e=e.replace(/\bvarying\b/g,i?"in":"out")).replace(/\btexture(2D|Cube)\b/g,"texture")).replace(/#extension.+(GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g,""),i){if(e=(e=(e=e.replace(/\btexture(2D|Cube)LodEXT\b/g,"textureLod")).replace(/\btexture(2D|Cube)GradEXT\b/g,"textureGrad")).replace(/\bgl_FragDepthEXT\b/g,"gl_FragDepth"),!t.has300Output(e))if(/\bgl_FragData\[.+?\]/g.test(e)){var r=(e=e.replace(/\bgl_FragColor\b/g,"gl_FragData[0]")).match(/\bgl_FragData\[.+?\]/g);r&&(e=t.replaceMRTShader(e,r))}else e=(e=e.replace(/void\s+?main\s*\(/g,"out vec4 glFragColor;\nvoid main(")).replace(/\bgl_FragColor\b/g,"glFragColor")}else e=e.replace(/\battribute\b/g,"in");return e},t.parseIncludes=function(t,e){var i;for(void 0===e&&(e=/#include <(.+)>/gm);null!==(i=e.exec(t));){var r=i[1],n=hn[r];if(void 0===n)throw new Error("Can't find include shader name "+r);t=t.replace(i[0],n)}return t},t.genMacroString=function(t,e,i){void 0===i&&(i=!0);var r=[],n="WEBGL"+t;return r.push("#ifndef "+n),r.push("#define "+n),r.push("#endif"),i&&r.push("#define GE_RUNTIME"),e&&e.length&&e.forEach((function(t){var e=t[0],i=t[1];!0===i?r.push("#define "+e):Number.isFinite(i)&&r.push("#define "+e+" "+i)})),r.length?r.join("\n")+"\n":""},t.genShaderVersion=function(t){return 1===t?"#version 100\n":"#version 300 es\n"},t.isVersion300=function(t){var e=t.match(/#version\s+\b\d{3}\b\s*(es)?/);return(e?e[0]:"").includes("300")},t.removeWebGLVersion=function(t){var e=t.match(/#version\s+\b\d{3}\b\s*(es)?/);return e?t.replace(e[0],""):t},t.has300Output=function(t){return/\bout\s+(?:\w+\s+)?(?:vec4)\s+(?:\w+)\s*;/.test(t)},t.replaceMRTShader=function(t,e){for(var i=new Set,r="",n=0;n<e.length;n++){var s=e[n].match(/\bgl_FragData\[(.+?)\]/);s&&i.add(s[1])}return i.forEach((function(t){r+="layout(location="+t+") out vec4 fragOutColor"+t+";\n"})),r+="void main(",t=(t=t.replace(/\bgl_FragData\[(.+?)\]/g,"fragOutColor$1")).replace(/void\s+?main\s*\(/g,r)},t}(),ln=function(t){function e(e,i){var r,n=(r=t.call(this,e,i)||this).renderer.engine,s=Cr.create(n,{mode:fi.TRIANGLE_STRIP,attributes:{aPos:{type:fi.FLOAT,size:2,data:new Float32Array([-1,1,-1,-1,1,1,1,-1])}},drawCount:4}),a=cr.create(n,{shader:{vertex:en,fragment:un,glslVersion:ur.GLSL1}});return a.blending=!1,a.depthTest=!1,a.culling=!1,r.screenMesh=Dr.create(n,{geometry:s,material:a,priority:0}),r.priority=5e3,r}Qt(e,t);var i=e.prototype;return i.configure=function(t){this.mainTexture=t.getFramebuffer().getColorTextures()[0],this.sceneTextureHandle.texture=this.mainTexture,t.setFramebuffer(this.framebuffer)},i.execute=function(t){var e,i,r;t.clear({colorAction:Pr.clear,depthAction:Pr.clear,stencilAction:Pr.clear}),this.screenMesh.material.setTexture("_MainTex",this.mainTexture);var n=null!=(r=null==(i=t.renderingData.currentFrame.globalVolume)||null==(e=i.bloom)?void 0:e.threshold)?r:1;this.screenMesh.material.setFloat("_Threshold",n),t.renderMeshes([this.screenMesh])},e}(Xr),fn=function(t){function e(e,i,r){var n;(n=t.call(this,e,r)||this).type=i;var s=n.renderer.engine,a="PostProcess",o=Cr.create(s,{name:a,mode:fi.TRIANGLE_STRIP,attributes:{aPos:{type:fi.FLOAT,size:2,data:new Float32Array([-1,1,-1,-1,1,1,1,-1])}},drawCount:4}),u={vertex:en,fragment:"H"==i?sn:an,glslVersion:ur.GLSL1},h=cr.create(s,{name:a,shader:u});return h.blending=!1,h.depthTest=!1,h.culling=!1,n.screenMesh=Dr.create(s,{name:a,geometry:o,material:h,priority:0}),n.priority=5e3,n}Qt(e,t);var i=e.prototype;return i.configure=function(t){this.mainTexture=t.getFramebuffer().getColorTextures()[0],t.setFramebuffer(this.framebuffer)},i.execute=function(t){t.clear({colorAction:Pr.clear,depthAction:Pr.clear,stencilAction:Pr.clear}),this.screenMesh.material.setTexture("_MainTex",this.mainTexture),this.screenMesh.material.setVector2("_TextureSize",gn(this.mainTexture)),t.renderMeshes([this.screenMesh]),"V"===this.type&&(this.gaussianResult.texture=t.getFramebuffer().getColorTextures()[0])},e}(Xr),dn=function(t){function e(e,i){var r,n="PostProcess",s=(r=t.call(this,e,i)||this).renderer.engine,a=Cr.create(s,{name:n,mode:fi.TRIANGLE_STRIP,attributes:{aPos:{type:fi.FLOAT,size:2,data:new Float32Array([-1,1,-1,-1,1,1,1,-1])}},drawCount:4}),o={vertex:en,fragment:on},u=cr.create(s,{name:n,shader:o});return u.blending=!1,u.depthTest=!1,u.culling=!1,r.screenMesh=Dr.create(s,{name:n,geometry:a,material:u,priority:0}),r.priority=5e3,r}Qt(e,t);var i=e.prototype;return i.configure=function(t){this.mainTexture=t.getFramebuffer().getColorTextures()[0],t.setFramebuffer(this.framebuffer)},i.execute=function(t){t.clear({colorAction:Pr.clear,depthAction:Pr.clear,stencilAction:Pr.clear}),this.screenMesh.material.setTexture("_MainTex",this.mainTexture),this.screenMesh.material.setTexture("_GaussianDownTex",this.gaussianDownSampleResult.texture),this.screenMesh.material.setVector2("_GaussianDownTextureSize",gn(this.gaussianDownSampleResult.texture)),t.renderMeshes([this.screenMesh])},e}(Xr),pn=function(t){function e(e,i){var r,n="PostProcess",s=(r=t.call(this,e,{})||this).renderer.engine;r.sceneTextureHandle=i||new Gr(s);var a=Cr.create(s,{name:n,mode:fi.TRIANGLE_STRIP,attributes:{aPos:{type:fi.FLOAT,size:2,data:new Float32Array([-1,1,-1,-1,1,1,1,-1])}},drawCount:4}),o=cr.create(s,{name:n,shader:{vertex:en,fragment:rn,glslVersion:ur.GLSL1}});return o.blending=!1,o.depthTest=!1,o.culling=!1,r.screenMesh=Dr.create(s,{name:n,geometry:a,material:o,priority:0}),r.priority=5e3,r}Qt(e,t);var i=e.prototype;return i.configure=function(t){this.mainTexture=t.getFramebuffer().getColorTextures()[0],this.sceneTextureHandle.texture||(this.sceneTextureHandle.texture=this.mainTexture),t.setFramebuffer(null)},i.execute=function(t){t.clear({colorAction:Pr.clear,depthAction:Pr.clear,stencilAction:Pr.clear});var e=t.renderingData.currentFrame.globalVolume,i=_i({threshold:0,intensity:0,active:!1},null==e?void 0:e.bloom),r=_i({intensity:0,smoothness:0,roundness:0,active:!1},null==e?void 0:e.vignette),n=_i({brightness:0,saturation:0,contrast:0,active:!1},null==e?void 0:e.colorAdjustments),s=_i({active:!1},null==e?void 0:e.tonemapping);this.screenMesh.material.setTexture("_SceneTex",this.sceneTextureHandle.texture),this.screenMesh.material.setFloat("_Brightness",Math.pow(2,n.brightness)),this.screenMesh.material.setFloat("_Saturation",.01*n.saturation+1),this.screenMesh.material.setFloat("_Contrast",.01*n.contrast+1),this.screenMesh.material.setInt("_UseBloom",Number(i.active)),i.active&&(this.screenMesh.material.setTexture("_GaussianTex",this.mainTexture),this.screenMesh.material.setFloat("_BloomIntensity",i.intensity)),r.intensity>0&&(this.screenMesh.material.setFloat("_VignetteIntensity",r.intensity),this.screenMesh.material.setFloat("_VignetteSmoothness",r.smoothness),this.screenMesh.material.setFloat("_VignetteRoundness",r.roundness),this.screenMesh.material.setVector2("_VignetteCenter",new Ke(.5,.5)),this.screenMesh.material.setVector3("_VignetteColor",new Qe(0,0,0))),this.screenMesh.material.setInt("_UseToneMapping",Number(s.active)),t.renderMeshes([this.screenMesh])},e}(Xr),mn="_effects_default_",vn=1,yn=function(){function t(t){var e;this.renderQueue=[],this.destroyed=!1,this.renderPassInfoMap=new WeakMap;var i=t.camera,r=t.keepColorBuffer,n=t.renderer,s=t.editorTransform,a=void 0===s?[1,1,0,0]:s,o=t.globalVolume,u=t.postProcessingEnabled,h=void 0!==u&&u,c=t.clearAction,l=void 0===c?{colorAction:hi.whatever,stencilAction:hi.clear,depthAction:hi.whatever}:c,f=n.engine;o&&(this.globalVolume=o),this.globalUniforms=new wn;var d,p=[],m={};if(this.renderer=n,h){if(!this.renderer.engine.gpuCapability.detail.halfFloatTexture)throw new Error("Half float texture is not supported.");var v=fi.HALF_FLOAT;p=[{texture:{format:fi.RGBA,type:v,magFilter:fi.LINEAR,minFilter:fi.LINEAR}}],d={storageType:Ir.depth_stencil_opaque},m={colorAction:hi.clear,stencilAction:hi.clear,depthAction:hi.clear}}this.drawObjectPass=new Xr(n,{name:mn,priority:zr,meshOrder:F.ascending,depthStencilAttachment:d,attachments:p,clearAction:m});var y=[this.drawObjectPass];if(this.setRenderPasses(y),h){var g=new Gr(f),x=[0,0,this.renderer.getWidth()/2,this.renderer.getHeight()/2],b=new Array(7),T=fi.HALF_FLOAT,E=new ln(n,{name:"BloomThresholdPass",attachments:[{texture:{format:fi.RGBA,type:T,minFilter:fi.LINEAR,magFilter:fi.LINEAR}}]});E.sceneTextureHandle=g,this.addRenderPass(E);for(var _=0;_<7;_++){b[_]=new Gr(f);var w=new fn(n,"H",{name:"GaussianDownPassH"+_,viewport:x,attachments:[{texture:{format:fi.RGBA,type:T,minFilter:fi.LINEAR,magFilter:fi.LINEAR}}]}),A=new fn(n,"V",{name:"GaussianDownPassV"+_,viewport:x,attachments:[{texture:{format:fi.RGBA,type:T,minFilter:fi.LINEAR,magFilter:fi.LINEAR}}]});A.gaussianResult=b[_],this.addRenderPass(w),this.addRenderPass(A),x[2]/=2,x[3]/=2}x[2]*=4,x[3]*=4;for(var C=0;C<6;C++){var S=new dn(n,{name:"GaussianUpPass"+C,viewport:x,attachments:[{texture:{format:fi.RGBA,type:T,minFilter:fi.LINEAR,magFilter:fi.LINEAR}}]});S.gaussianDownSampleResult=b[5-C],this.addRenderPass(S),x[2]*=2,x[3]*=2}var O=new pn(n,g);this.addRenderPass(O)}this.semantics=new wr(t.semantics),this.clearAction=l,this.name="RenderFrame"+vn++;var R=y[0];this.emptyTexture=qi(f),this.transparentTexture=Ki(f),this.camera=i,this.keepColorBuffer=r,this.renderPassInfoMap.set(R,{listStart:0,listEnd:0,renderPass:R,intermedia:!1}),this.editorTransform=Je.fromArray(a),t.clearAction||this.resetClearActions(),this.passTextureCache=new _r(f);var M=f.gpuCapability,I=M.detail,P=gr(M.level,I.readableDepthStencilTextures&&I.writableFragDepth);null==(e=this.renderer.getShaderLibrary())||e.addShader(P)}var e=t.prototype;return e.addMeshToDefaultRenderPass=function(t){this.drawObjectPass.addMesh(t)},e.removeMeshFromDefaultRenderPass=function(t){this.drawObjectPass.removeMesh(t)},e.dispose=function(t){(null==t?void 0:t.semantics)!==pt.keep&&this.semantics.dispose();var e,i,r=(null==t?void 0:t.passes)?t.passes:void 0;(r!==pt.keep&&this._renderPasses.forEach((function(t){t.dispose(r)})),this.passTextureCache.dispose(),this._renderPasses.length=0,this.emptyTexture.dispose(),this.transparentTexture.dispose(),this.resource)&&(this.resource.color_a.dispose(),this.resource.color_b.dispose(),null==(i=this.resource.depthStencil)||null==(e=i.texture)||e.dispose(),this.resource.finalCopyRP.dispose(),this.resource.resRP.dispose(),this.resource=null);this.destroyed=!0},e.resetRenderPassDefaultAttachment=function(t,e){for(var i,r=this.resource,n=r.color_a,s=r.color_b,a=e;a<t.length;a++){var o,u,h=t[a],c=null==(o=h.attachments[0])?void 0:o.texture;if(c&&i===c){var l=c===n?s:n;h.resetColorAttachments([l])}(c=null==(u=h.attachments[0])?void 0:u.texture)&&(i=c)}},e.findMeshRenderPassIndex=function(t){var e=-1;return this.renderPasses.every((function(i,r){return!i.name.startsWith(mn)||!i.meshes.includes(t)||(e=r,!1)})),e},e.addToRenderPass=function(t,e){var i=this.renderPassInfoMap.get(t),r=e.priority;i&&(0===t.meshes.length?i.listStart=i.listEnd=r:r<i.listStart?i.listStart=r:r>i.listEnd&&(i.listEnd=r),t.addMesh(e))},e.getRPAttachments=function(t,e){if(1===(null==t?void 0:t.length)){var i,r=t[0],n=r.texture,s=r.persistent,a=n.format,o=null!=(i=null==e?void 0:e.getInitAttachments())?i:[];if(a===fi.RGBA&&!s){var u=this.resource.color_a;return 0===o.length?[{texture:u}]:[{texture:o[0].texture===u?this.resource.color_b:u}]}}return t},e.resetClearActions=function(){var t=this.renderPasses.length>1?hi.clear:hi.whatever;this.clearAction.stencilAction=t,this.clearAction.depthAction=t,this.clearAction.colorAction=t,this.keepColorBuffer&&(this.clearAction.colorAction=hi.whatever)},e.setRenderPasses=function(t){var e=this;void 0!==this.renderer&&t.forEach((function(t){return t.initialize(e.renderer)})),this._renderPasses=t.slice()},e.addRenderPass=function(t){void 0!==this.renderer&&t.initialize(this.renderer),this._renderPasses.push(t)},e.createResource=function(){var t=this.renderer.engine;if(!this.resource){var e,i=t.gpuCapability,r=i.detail,n=i.level,s=this.renderer.getWidth(),a=this.renderer.getHeight(),o=2===n?fi.LINEAR:fi.NEAREST,u=Yi.create(t,{sourceType:ci.framebuffer,format:fi.RGBA,name:"frame_a",minFilter:o,magFilter:o}),h=Yi.create(t,{sourceType:ci.framebuffer,format:fi.RGBA,data:{width:s,height:a},minFilter:o,magFilter:o,name:"frame_b"}),c=r.readableDepthStencilTextures&&r.writableFragDepth?Ir.depth_24_stencil_8_texture:Ir.depth_stencil_opaque,l=new Xr(this.renderer,{depthStencilAttachment:{storageType:c},attachments:[{texture:u}]}).initialize(this.renderer),f=new _n(this.renderer,{name:"effects-final-copy",priority:1600,clearAction:{depthAction:hi.clear,stencilAction:hi.clear,colorAction:hi.clear},meshOrder:F.ascending,meshes:[this.createCopyMesh({blend:!0,depthTexture:null==(e=l.getDepthAttachment())?void 0:e.texture})]});this.resource={color_a:l.attachments[0].texture,color_b:h,finalCopyRP:f,depthStencil:l.depthAttachment,resRP:l}}},e.createCopyMesh=function(t){var e,i=pr,r=this.renderer.engine,n=Cr.create(r,{name:i,mode:fi.TRIANGLE_STRIP,attributes:{aPos:{type:fi.FLOAT,size:2,data:new Float32Array([-1,1,-1,-1,1,1,1,-1])}},drawCount:4}),s=gr(r.gpuCapability.level,!!(null==t?void 0:t.depthTexture));null==(e=this.renderer.getShaderLibrary())||e.addShader(s);var a=cr.create(r,{uniformValues:{uDepth:null==t?void 0:t.depthTexture},name:i,shader:s});return a.blending=!1,a.depthTest=!1,a.culling=!1,(null==t?void 0:t.blend)&&(a.blending=!0,a.blendFunction=[fi.SRC_ALPHA,fi.ONE_MINUS_SRC_ALPHA,fi.SRC_ALPHA,fi.ONE_MINUS_SRC_ALPHA]),Dr.create(r,{name:i,geometry:n,material:a,priority:0})},e.removeRenderPass=function(t){k(this._renderPasses,t)},Pe(t,[{key:"renderPasses",get:function(){return this._renderPasses.slice()}},{key:"isDestroyed",get:function(){return this.destroyed}}]),t}();function gn(t){return t?new Ke(t.getWidth(),t.getHeight()):new Ke}function xn(t,e){var i=t.indexOf(e);return t[i-1]}var bn,Tn,En,_n=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.configure=function(t){var e=t.getFramebuffer();e&&(this.prePassTexture=e.getColorTextures()[0]),t.setFramebuffer(null)},i.execute=function(t){t.clear(this.clearAction),this.meshes[0].material.setTexture("uFilterSource",this.prePassTexture),this.meshes[0].material.setVector2("uFilterSourceSize",gn(this.prePassTexture)),t.renderMeshes(this.meshes),this.storeAction&&t.clear(this.storeAction)},e}(Xr),wn=function(){this.floats={},this.ints={},this.vector3s={},this.vector4s={},this.matrices={},this.samplers=[],this.uniforms=[]},An=function(){function t(t){this.size=[0,0],this.multiSample=1,this.destroyed=!1;var e=t.storageType,i=t.format,r=t.attachment;this.storageType=e,this.format=i,this.attachment=r}return Pe(t,[{key:"isDestroyed",get:function(){return this.destroyed}}]),t}(),Cn="function"==typeof o,Sn=function(){function t(t){this.setupCapability(t)}var e=t.prototype;return e.setupCapability=function(t){var e,i=Cn&&A(t,o)?2:1,r=2===i,n=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),s=t.getExtension("WEBGL_depth_texture"),a=!!t.getExtension("OES_texture_half_float_linear"),u=!!t.getExtension("OES_texture_float_linear");this.level=i,this.type=r?"webgl2":"webgl",this.vaoExt=t.getExtension("OES_vertex_array_object"),this.glAsyncCompileExt=t.getExtension("KHR_parallel_shader_compile"),this.UNSIGNED_INT_24_8=t.UNSIGNED_INT_24_8,this.drawBufferExtension=t.getExtension("WEBGL_draw_buffers"),s&&(this.UNSIGNED_INT_24_8=s.UNSIGNED_INT_24_8_WEBGL),r&&!a&&(a=On(t,t.HALF_FLOAT)),r&&!u&&(u=On(t,t.FLOAT)),this.internalFormatDepth16=r?t.DEPTH_COMPONENT16:t.DEPTH_COMPONENT,this.internalFormatDepth24_stencil8=r?t.DEPTH24_STENCIL8:t.DEPTH_STENCIL;var h=r||t.getExtension("OES_texture_float")?t.FLOAT:0,c=r?o.HALF_FLOAT:(null==(e=t.getExtension("OES_texture_half_float"))?void 0:e.HALF_FLOAT_OES)||0,l={floatTexture:h,halfFloatTexture:c,maxSample:r?t.getParameter(t.MAX_SAMPLES):1,maxVertexUniforms:t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),maxVertexTextures:t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxFragmentUniforms:t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),maxFragmentTextures:t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),floatColorAttachment:r?!!t.getExtension("EXT_color_buffer_float"):h>0&&!!t.getExtension("WEBGL_color_buffer_float"),halfFloatColorAttachment:r?!!t.getExtension("EXT_color_buffer_float"):c>0&&!!t.getExtension("EXT_color_buffer_half_float"),maxTextureSize:t.getParameter(t.MAX_TEXTURE_SIZE),maxShaderTexCount:t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS),compressedTexture:Rn(t),halfFloatLinear:a,floatLinear:u,maxTextureAnisotropy:n?t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0,shaderTextureLod:r||!!t.getExtension("EXT_shader_texture_lod"),instanceDraw:r||!!t.getExtension("ANGLE_instanced_arrays"),drawBuffers:r||!!this.drawBufferExtension,asyncShaderCompile:!!this.glAsyncCompileExt,intIndexElementBuffer:!!t.getExtension("OES_element_index_uint"),standardDerivatives:r||!!t.getExtension("OES_standard_derivatives"),readableDepthStencilTextures:r||!!s,writableFragDepth:r||!!t.getExtension("EXT_frag_depth")};this.detail=l,n&&(this.textureMaxAnisotropyExt=n.TEXTURE_MAX_ANISOTROPY_EXT)},e.framebufferTexture2D=function(t,e,i,r,n){var s=this.drawBufferExtension;if(1===this.level&&!s&&i>0)throw new Error("Draw multiple color buffers not available.");var a=s?s["COLOR_ATTACHMENT"+i+"_WEBGL"]:t["COLOR_ATTACHMENT"+i];a?t.framebufferTexture2D(e,a,r,n,0):console.error("Invalid color attachment index: "+i+".")},e.drawBuffers=function(t,e){var i=this.drawBufferExtension;if(1!==this.level||i){var r=e.map((function(e,r){return e?i?i["COLOR_ATTACHMENT"+r+"_WEBGL"]:t["COLOR_ATTACHMENT"+r]:t.NONE}));i?i.drawBuffersWEBGL(r):t.drawBuffers(r)}else if(e.length>1)throw new Error("Draw buffers not available.")},e.setTextureAnisotropic=function(t,e,i){var r=this.detail.maxTextureAnisotropy;r&&t.texParameterf(e,this.textureMaxAnisotropyExt,Math.min(r,i||4))},t}();function On(t,e){var i=t.createTexture(),r=!1;return t.getError(),t.bindTexture(t.TEXTURE_2D,i),t.texImage2D(t.TEXTURE_2D,0,t.R16F,1,1,0,t.RED,e,null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.getError()||(r=!0),t.deleteTexture(i),r}function Rn(t){return t.getExtension("WEBGL_compressed_texture_astc")?2:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc")?1:0}!function(t){t[t.NONE=0]="NONE",t[t.PVRTC=1]="PVRTC",t[t.ASTC=2]="ASTC"}(bn||(bn={})),function(t){t[t.Nearest=0]="Nearest",t[t.Linear=1]="Linear"}(Tn||(Tn={})),function(t){t[t.RGBA32=0]="RGBA32",t[t.RGBAHalf=1]="RGBAHalf"}(En||(En={}));var Mn=function(){function t(){}var e=t.prototype;return e.resize=function(t,e,i,r){},e.resetColorTextures=function(t){},e.unbind=function(){},e.bind=function(){},e.getDepthTexture=function(){},e.getStencilTexture=function(){},e.getColorTextures=function(){return[]},e.dispose=function(t){},Pe(t,[{key:"stencilStorage",get:function(){}},{key:"depthStorage",get:function(){}}]),t}(),In=function(){function t(){}var e=t.prototype;return e.setGlobalFloat=function(t,e){},e.setGlobalInt=function(t,e){},e.setGlobalVector4=function(t,e){},e.setGlobalVector3=function(t,e){},e.setGlobalMatrix=function(t,e){},e.getFramebuffer=function(){return null},e.setFramebuffer=function(t){},e.setViewport=function(t,e,i,r){},e.resize=function(t,e){},e.clear=function(t){},e.getWidth=function(){return 0},e.getHeight=function(){return 0},e.addLostHandler=function(t){},e.addRestoreHandler=function(t){},e.lost=function(t){},e.restore=function(){},e.getShaderLibrary=function(){},e.renderRenderFrame=function(t){},e.renderMeshes=function(t){},e.drawGeometry=function(t,e,i){},e.getTemporaryRT=function(t,e,i,r,n,s){return null},e.dispose=function(t){},t}(),Pn=function(){function t(t){var e=this;Object.keys(t).forEach((function(i){e[i]=t[i]}))}return t.prototype.generate=function(t){var e=Ln(this.arc,this.arcMode,t)*Xe,i=Math.cos(e)*this.radius,r=Math.sin(e)*this.radius,n=new Qe(i,r,0),s=Math.tan(this.angle*Xe),a=n.clone().multiply(s);return a.z+=1,{position:n.multiply(Et(0,1)),direction:a.normalize()}},t}();function Ln(t,e,i){if(e===re.RANDOM)t=Et(0,t);else if(e===re.UNIDIRECTIONAL_CYCLE){var r=i.index%(i.total+1);t=t/i.total*r}else if(e===re.BIDIRECTIONAL_CYCLE){var n=i.index/(i.total+1),s=n-Math.floor(n);t*=Math.floor(n)%2?1-s:s}else e===re.UNIFORM_BURST&&(t=t*i.burstIndex/i.burstCount);return t}var Fn,Vn=function(){function t(t){var e=this;Object.keys(t).forEach((function(i){e[i]=t[i]}))}return t.prototype.generate=function(t){var e=Ln(this.arc,this.arcMode,t)*Xe,i=new Qe(Math.cos(e),Math.sin(e),0),r=this.radius;return{direction:i,position:i.clone().multiply(r)}},t}(),Nn=function(){function t(t){this._d=(t.width||1)/2,this._h=(t.height||1)/2}return t.prototype.generate=function(t){var e=Et(-this._d,this._d),i=Et(-this._h,this._h);return{direction:new Qe(0,0,1),position:new Qe(e,i,0)}},t}(),Dn=function(){function t(t){this._d=(t.width||1)/2,this._h=(t.height||1)/2,this.arcMode=t.arcMode,this.arc=t.arc}return t.prototype.generate=function(t){var e=Ln(this.arc,this.arcMode,t)*Xe,i=new Qe(Math.cos(e),Math.sin(e),0),r=this._d,n=this._h,s=Math.atan2(n,r),a=Math.tan(e),o=new Qe;return e<s?o.set(r,r*a,0):e>=s&&e<Math.PI-s?o.set(n/a,n,0):e<Math.PI+s?o.set(-r,-r*a,0):e<2*Math.PI-s?o.set(-n/a,-n,0):o.set(r,r*a,0),{direction:i,position:o}},t}(),kn=function(){function t(t){this._d=t.width||1,this.arcMode=t.arcMode}return t.prototype.generate=function(t){var e=this.arcMode===re.UNIFORM_BURST?t.burstIndex%t.burstCount/(t.burstCount-1):Et(0,1);return{direction:new Qe(0,1,0),position:new Qe(this._d*(e-.5),0,0)}},t}(),zn=new ni,Un=function(){function t(t){var e=this;Object.keys(t).forEach((function(i){e[i]=t[i]}))}return t.prototype.generate=function(t){var e=this.donutRadius,i=this.radius-e,r=Et(0,2*Math.PI),n=Ln(this.arc,this.arcMode,t)*Xe,s=zn.setFromRotationZ(n),a=new Qe(Math.cos(r),Math.sin(r),0),o=new Qe(i+Math.cos(r)*e,0,Math.sin(r)*e);return{direction:s.transformNormal(a),position:s.transformPoint(o)}},t}(),Bn=new ni,Gn=function(){function t(t){var e=this;Object.keys(t).forEach((function(i){e[i]=t[i]}))}var e=t.prototype;return e.getHorizontalAngle=function(){return Et(-90,90)},e.generate=function(t){var e=Ln(this.arc,this.arcMode,t)*Xe,i=this.getHorizontalAngle()*Xe,r=this.radius,n=new Qe(Math.cos(i),0,Math.sin(i)),s=Bn.setFromRotationZ(e).transformNormal(n);return{position:s.clone().multiply(r),direction:s}},t}(),jn=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.getHorizontalAngle=function(){return Et(0,90)},e}(Gn),Xn=function(){function t(t){var e=t.detail||{anchors:[.5,.5],block:[0,0]};this.anchors=new Float32Array(e.anchors),this.width=t.width||1,this.height=t.height||1,this.block=e.block,this.arcMode=t.arcMode,this.random=qe(t.random||0,0,1)}return t.prototype.generate=function(t){var e=this.anchors,i=e.length/2-1,r=Math.floor(Ln(i,this.arcMode,t)),n=(e[2*r]+this.block[0]*this.random*Math.random())%1-.5,s=(e[2*r+1]+this.block[1]*this.random*Math.random())%1-.5,a=new Qe(n,s,0);return{position:new Qe(n*this.width,s*this.height,0),direction:a.normalize()}},t}(),Hn=function(){function t(){}return t.prototype.generate=function(){return{position:new Qe,direction:new Qe}},t}(),Yn=((Fn={})[Ut.NONE]=Hn,Fn[Ut.CONE]=Pn,Fn[Ut.SPHERE]=Gn,Fn[Ut.HEMISPHERE]=jn,Fn[Ut.CIRCLE]=Vn,Fn[Ut.DONUT]=Un,Fn[Ut.RECTANGLE]=Nn,Fn[Ut.EDGE]=kn,Fn[Ut.RECTANGLE_EDGE]=Dn,Fn[Ut.TEXTURE]=Xn,Fn);function Wn(t){if(!t)return new Hn;var e=_i({radius:1,arc:360,angle:0,arcMode:re.RANDOM},t),i=t.type,r=Yn[i];if(!r)throw new Error("Invalid shape: "+i+".");var n=new r(e);if(i!==Ut.NONE){var s=t.alignSpeedDirection,a=t.upDirection,o=void 0===a?[0,0,1]:a;n.alignSpeedDirection=s,n.upDirection=Qe.fromArray(o).normalize()}return n}function Zn(t,e,i,r,n){var s,a;if(n===function(t,e,i,r){for(var n=0,s=e,a=i-r;s<i;s+=r)n+=(t[a]-t[s])*(t[s+1]+t[a+1]),a=s;return n}(t,e,i,r)>0)for(s=e;s<i;s+=r)a=fs(s,t[s],t[s+1],a);else for(s=i-r;s>=e;s-=r)a=fs(s,t[s],t[s+1],a);return a&&as(a,a.next)&&(ds(a),a=a.next),a}function qn(t,e){if(!t)return t;e||(e=t);var i,r=t;do{if(i=!1,r.steiner||!as(r,r.next)&&0!==ss(r.prev,r,r.next))r=r.next;else{if(ds(r),(r=e=r.prev)===r.next)break;i=!0}}while(i||r!==e);return e}function Kn(t){var e=t.prev,i=t,r=t.next;if(ss(e,i,r)>=0)return!1;for(var n=t.next.next;n!==t.prev;){if(rs(e.x,e.y,i.x,i.y,r.x,r.y,n.x,n.y)&&ss(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function Qn(t,e,i,r){var n=t.prev,s=t,a=t.next;if(ss(n,s,a)>=0)return!1;for(var o=n.x<s.x?n.x<a.x?n.x:a.x:s.x<a.x?s.x:a.x,u=n.y<s.y?n.y<a.y?n.y:a.y:s.y<a.y?s.y:a.y,h=n.x>s.x?n.x>a.x?n.x:a.x:s.x>a.x?s.x:a.x,c=n.y>s.y?n.y>a.y?n.y:a.y:s.y>a.y?s.y:a.y,l=es(o,u,e,i,r),f=es(h,c,e,i,r),d=t.prevZ,p=t.nextZ;d&&d.z>=l&&p&&p.z<=f;){if(d!==t.prev&&d!==t.next&&rs(n.x,n.y,s.x,s.y,a.x,a.y,d.x,d.y)&&ss(d.prev,d,d.next)>=0)return!1;if(d=d.prevZ,p!==t.prev&&p!==t.next&&rs(n.x,n.y,s.x,s.y,a.x,a.y,p.x,p.y)&&ss(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;d&&d.z>=l;){if(d!==t.prev&&d!==t.next&&rs(n.x,n.y,s.x,s.y,a.x,a.y,d.x,d.y)&&ss(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;p&&p.z<=f;){if(p!==t.prev&&p!==t.next&&rs(n.x,n.y,s.x,s.y,a.x,a.y,p.x,p.y)&&ss(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function Jn(t,e){return t.x-e.x}function $n(t,e){if(e=function(t,e){var i,r=e,n=t.x,s=t.y,a=-1/0;do{if(s<=r.y&&s>=r.next.y&&r.next.y!==r.y){var o=r.x+(s-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(o<=n&&o>a){if(a=o,o===n){if(s===r.y)return r;if(s===r.next.y)return r.next}i=r.x<r.next.x?r:r.next}}r=r.next}while(r!==e);if(!i)return null;if(n===a)return i;var u,h=i,c=i.x,l=i.y,f=1/0;r=i;do{n>=r.x&&r.x>=c&&n!==r.x&&rs(s<l?n:a,s,c,l,s<l?a:n,s,r.x,r.y)&&(u=Math.abs(s-r.y)/(n-r.x),cs(r,t)&&(u<f||u===f&&(r.x>i.x||r.x===i.x&&ts(i,r)))&&(i=r,f=u)),r=r.next}while(r!==h);return i}(t,e),e){var i=ls(e,t);qn(e,e.next),qn(i,i.next)}}function ts(t,e){return ss(t.prev,t,e.prev)<0&&ss(e.next,t,t.next)<0}function es(t,e,i,r,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*n)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*n)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function is(t){var e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function rs(t,e,i,r,n,s,a,o){return(n-a)*(e-o)-(t-a)*(s-o)>=0&&(t-a)*(r-o)-(i-a)*(e-o)>=0&&(i-a)*(s-o)-(n-a)*(r-o)>=0}function ns(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&&os(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(cs(t,e)&&cs(e,t)&&function(t,e){var i=t,r=!1,n=(t.x+e.x)/2,s=(t.y+e.y)/2;do{i.y>s!=i.next.y>s&&i.next.y!==i.y&&n<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==t);return r}(t,e)&&(ss(t.prev,t,e.prev)||ss(t,e.prev,e))||as(t,e)&&ss(t.prev,t,t.next)>0&&ss(e.prev,e,e.next)>0)}function ss(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function as(t,e){return t.x===e.x&&t.y===e.y}function os(t,e,i,r){var n=hs(ss(t,e,i)),s=hs(ss(t,e,r)),a=hs(ss(i,r,t)),o=hs(ss(i,r,e));return n!==s&&a!==o||(!(0!==n||!us(t,i,e))||(!(0!==s||!us(t,r,e))||(!(0!==a||!us(i,t,r))||!(0!==o||!us(i,e,r)))))}function us(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function hs(t){return t>0?1:t<0?-1:0}function cs(t,e){return ss(t.prev,t,t.next)<0?ss(t,e,t.next)>=0&&ss(t,t.prev,e)>=0:ss(t,e,t.prev)<0||ss(t,t.next,e)<0}function ls(t,e){var i=new ps(t.i,t.x,t.y),r=new ps(e.i,e.x,e.y),n=t.next,s=e.prev;return t.next=e,e.prev=t,i.next=n,n.prev=i,r.next=i,i.prev=r,s.next=r,r.prev=s,r}function fs(t,e,i,r){var n=new ps(t,e,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function ds(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 ps(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}var ms=0;function vs(t,e,i,r){i=i||2,ms=r||0;var n,s,a,o,u,h,c,l=e&&e.length,f=l?e[0]*i:t.length,d=Zn(t,0,f,i,!0),p=[];if(!d||d.next===d.prev)return p;if(l&&(d=function(t,e,i,r){var n,s,a,o=[];for(n=0,s=e.length;n<s;n++)(a=Zn(t,e[n]*r,n<s-1?e[n+1]*r:t.length,r,!1))===a.next&&(a.steiner=!0),o.push(is(a));for(o.sort(Jn),n=0;n<o.length;n++)$n(o[n],i),i=qn(i,i.next);return i}(t,e,d,i)),t.length>80*i){n=a=t[0],s=o=t[1];for(var m=i;m<f;m+=i)(u=t[m])<n&&(n=u),(h=t[m+1])<s&&(s=h),u>a&&(a=u),h>o&&(o=h);c=0!==(c=Math.max(a-n,o-s))?1/c:0}return ys(d,p,i,n,s,c),p}function ys(t,e,i,r,n,s,a){if(t){!a&&s&&function(t,e,i,r){var n=t;do{null===n.z&&(n.z=es(n.x,n.y,e,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,function(t){var e,i,r,n,s,a,o,u,h=1;do{for(i=t,t=null,s=null,a=0;i;){for(a++,r=i,o=0,e=0;e<h&&(o++,r=r.nextZ);e++);for(u=h;o>0||u>0&&r;)0!==o&&(0===u||!r||i.z<=r.z)?(n=i,i=i.nextZ,o--):(n=r,r=r.nextZ,u--),s?s.nextZ=n:t=n,n.prevZ=s,s=n;i=r}s.nextZ=null,h*=2}while(a>1)}(n)}(t,r,n,s);for(var o,u,h=t;t.prev!==t.next;)if(o=t.prev,u=t.next,s?Qn(t,r,n,s):Kn(t))e.push(o.i/i+ms),e.push(t.i/i+ms),e.push(u.i/i+ms),ds(t),t=u.next,h=u.next;else if((t=u)===h){a?1===a?ys(t=gs(qn(t),e,i),e,i,r,n,s,2):2===a&&xs(t,e,i,r,n,s):ys(qn(t),e,i,r,n,s,1);break}}}function gs(t,e,i){var r=t;do{var n=r.prev,s=r.next.next;!as(n,s)&&os(n,r,r.next,s)&&cs(n,s)&&cs(s,n)&&(e.push(n.i/i+ms),e.push(r.i/i+ms),e.push(s.i/i+ms),ds(r),ds(r.next),r=t=s),r=r.next}while(r!==t);return qn(r)}function xs(t,e,i,r,n,s){var a=t;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&ns(a,o)){var u=ls(a,o);return a=qn(a,a.next),u=qn(u,u.next),ys(a,e,i,r,n,s),void ys(u,e,i,r,n,s)}o=o.next}a=a.next}while(a!==t)}var bs=6,Ts="PRE_COLOR_0",Es="PRE_COLOR_SIZE_0",_s="PRE_MAIN_COLOR_0",ws="PRE_MAIN_COLOR_SIZE_0",As="editor",Cs={"Item duration can't be less than 0":"https://www.galacean.com/effects/user/gasrv4ka5sacrwpg#AOnQS","ValueType: 21/22 is not supported":"https://www.galacean.com/effects/user/gasrv4ka5sacrwpg#smO1b"},Ss=2;function Os(t,e){for(var i=t.s,r=t.p,n=i[1],s=r[1],a=0,o=0;o<n.length;o++){a+=n[o].length-1}var u,h=new Float32Array(a*bs),c=e.indexBase,l=void 0===c?0:c,f=e.uvTransform,d=0,p=0,m=0,v=1,y=1;f&&(p=f[0],m=f[1],u=f[4],v=u?f[3]:f[2],y=u?f[2]:f[3]);for(var g=[0,0],x=0===u?0:-Math.PI/2,b=0;b<n.length;b++)for(var T=n[b],E=s[b],_=s[b+1]||s[0],w=T,A=[0,0],C=0;C<w.length-1;C++){Is(A,w[C],E,_,E[4],E[5],_[2],_[3]),O(A[0],A[1])}var S=vs(Array.from(h),null,bs,l);return{aPoint:h,index:new Uint16Array(S)};function O(t,e){h[d++]=t/2,h[d++]=e/2,f?(g[0]=t,g[1]=e,Ms(g,g,x),h[d++]=p+(g[0]+1)/2*v,h[d++]=m+(g[1]+1)/2*y):(h[d++]=(t+1)/2,h[d++]=(e+1)/2),d+=Ss}}function Rs(t,e){for(var i=[],r=function(t){var e=[];return"gs"in t?t.gs.forEach((function(t){e.push({p:[$t.SHAPE_POINTS,t.p],s:[$t.SHAPE_SPLITS,t.s]})})):"g"in t?e.push({p:[$t.SHAPE_POINTS,t.g.p],s:[$t.SHAPE_SPLITS,t.g.s]}):e.push(t),e}(t),n=0,s=0,a=0,o=0;o<r.length;o++){var u=Os(r[o],{indexBase:n,uvTransform:e});n+=u.aPoint.length/5,i.push(u),s+=u.aPoint.length,a+=u.index.length}if(1===i.length)return i[0];for(var h=new Float32Array(s),c=new Uint16Array(a),l=0,f=0,d=0;l<i[l];l++){var p=i[l];h.set(p.aPoint,f),f+=p.aPoint.length,c.set(p.index,d),d+=p.index.length}return{aPoint:h,index:c}}function Ms(t,e,i){var r=Math.cos(i),n=Math.sin(i),s=e[0],a=e[1];return t[0]=r*s+n*a,t[1]=-n*s+r*a,t}function Is(t,e,i,r,n,s,a,o){var u=1-e,h=u*u*u,c=3*e*u*u,l=3*e*e*u,f=e*e*e;return t[0]=h*i[0]+c*n+l*a+f*r[0],t[1]=h*i[1]+c*s+l*o+f*r[1],t}var Ps=[[0,0,1,1,0]],Ls=function(t){function e(e){var i;(i=t.call(this,e)||this).visible=!0,i.splits=Ps,i.meshCollider=new ro,i._color=new ii(1,1,1,1),i.getHitTestParams=function(t){var e=ni.fromScale(i.transform.size.x,i.transform.size.y,1).premultiply(i.transform.getWorldMatrix()),r=i.interaction;if(t||r){i.meshCollider.setGeometry(i.geometry,e);var n,s=i.meshCollider.getBoundingBoxData();if(s)return{behavior:(null==(n=i.interaction)?void 0:n.behavior)||0,type:s.type,triangles:s.area,backfaceCulling:i.renderer.side===kt.FRONT}}},i.renderer={renderMode:Ht.MESH,blending:Dt.ALPHA,texture:i.engine.emptyTexture,occlusion:!1,transparentOcclusion:!1,side:kt.DOUBLE,mask:0},i.defaultGeometry=Cr.create(i.engine,{attributes:{aPos:{type:fi.FLOAT,size:3,data:new Float32Array([-.5,.5,0,-.5,-.5,0,.5,.5,0,.5,-.5,0])},aUV:{size:2,offset:0,releasable:!0,type:fi.FLOAT,data:new Float32Array([0,1,0,0,1,1,1,0])}},indices:{data:new Uint16Array([0,1,2,2,1,3]),releasable:!0},mode:fi.TRIANGLES,drawCount:6}),i.geometry=i.defaultGeometry;var r=cr.create(i.engine,{shader:{fragment:qr,vertex:Zr,shared:!0}});return i.material=r,i.material.setColor("_Color",new ii(1,1,1,1)),i.maskManager=new lr(e),i}Qt(e,t);var i=e.prototype;return i.setVisible=function(t){this.visible=t},i.getVisible=function(){return this.visible},i.setColor=function(t){A(t,ii)?this._color.copyFrom(t):this._color.setFromArray(t),this.material.setColor("_Color",this._color)},i.setTexture=function(t){var e=this;return E((function(){var i;return O(this,(function(r){switch(r.label){case 0:return"string"!=typeof t?[3,2]:[4,Yi.fromImage(t,e.item.engine)];case 1:return i=r.sent(),[3,3];case 2:i=t,r.label=3;case 3:return e.renderer.texture=i,e.material.setTexture("_MainTex",i),[2]}}))}))()},i.render=function(t){this.getVisible()&&(this.maskManager.drawStencilMask(t),this.draw(t))},i.drawStencilMask=function(t){if(this.isActiveAndEnabled){var e=this.material.colorMask;this.material.colorMask=!1,this.draw(t),this.material.colorMask=e}},i.onStart=function(){this.item.getHitTestParams=this.getHitTestParams},i.getBoundingBox=function(){var t=this.transform.getWorldMatrix();return this.meshCollider.setGeometry(this.geometry,t),this.meshCollider.getBoundingBox()},i.getItemGeometryData=function(t){var e=this.splits,i=this.textureSheetAnimation,r=this.defaultGeometry;if(t.shape){for(var n=t.shape,s=n.index,a=void 0===s?[]:s,o=n.aPoint,u=void 0===o?[]:o,h=new Float32Array(u),c=[],l=[],f=0;f<h.length;f+=6)h[f]*=1,h[f+1]*=1,l.push(u[f+2],u[f+3]),c.push(h[f],h[f+1],0);return r.setAttributeData("aPos",new Float32Array(c)),{index:a,aUV:l}}var d=[-.5,.5,-.5,-.5,.5,.5,.5,-.5],p=[],m=[],v=[];if(1===e.length){var y=i?[0,0,1,1,e[0][4]]:e[0],g=y[4]?[0,0,1,0,0,1,1,1]:[0,1,0,0,1,1,1,0],x=y[0],b=y[1],T=y[4]?y[3]:y[2],E=y[4]?y[2]:y[3];p.push(g[0]*T+x,g[1]*E+b,g[2]*T+x,g[3]*E+b,g[4]*T+x,g[5]*E+b,g[6]*T+x,g[7]*E+b),v.push(d[0],d[1],0,d[2],d[3],0,d[4],d[5],0,d[6],d[7],0),m.push(0,1,2,2,1,3)}else for(var _=0;_<2;_++)for(var w=0;w<2;w++){var A=4*(2*w+_),C=i?[0,0,1,1,e[0][4]]:e[2*w+_],S=C[4]?[0,0,1,0,0,1,1,1]:[0,1,0,0,1,1,1,0],O=((_+_+1)/2-1)/2,R=((w+w+1)/2-1)/2,M=C[0],I=C[1],P=C[4]?C[3]:C[2],L=C[4]?C[2]:C[3],F=[d[0]/2+O,d[1]/2+R,d[2]/2+O,d[3]/2+R,d[4]/2+O,d[5]/2+R,d[6]/2+O,d[7]/2+R];p.push(S[0]*P+M,S[1]*L+I,S[2]*P+M,S[3]*L+I,S[4]*P+M,S[5]*L+I,S[6]*P+M,S[7]*L+I),v.push(1*F[0],1*F[1],0,1*F[2],1*F[3],0,1*F[4],1*F[5],0,1*F[6],1*F[7],0),m.push(A,1+A,2+A,2+A,1+A,3+A)}return r.setAttributeData("aPos",new Float32Array(v)),{index:m,aUV:p}},i.configureDefaultGeometry=function(t){var e=this.getItemGeometryData(t),i=e.index,r=e.aUV,n=this.defaultGeometry;return n.setIndexData(new Uint16Array(i)),n.setAttributeData("aUV",new Float32Array(r)),n.setDrawCount(i.length),n},i.configureMaterial=function(t){var e=t.side,i=t.occlusion,r=t.blending,n=t.mask,s=t.texture,a=this.maskManager.maskMode,o=this.material;o.blending=!0,o.depthTest=!0,o.depthMask=i,o.stencilRef=void 0!==n?[n,n]:void 0,bi(o,r),Ei(o,a),Ti(o,e),o.shader.shaderData.properties='_MainTex("_MainTex",2D) = "white" {}',o.setVector4("_TexOffset",new Je(0,0,1,1)),o.setTexture("_MainTex",s);var u=xi(r),h=new Je;return h.x=t.occlusion?+t.transparentOcclusion:1,h.y=u,h.z=t.renderMode,h.w=a,o.setVector4("_TexParams",h),0===h.x||this.maskManager.alphaMaskEnabled?o.enableMacro("ALPHA_CLIP"):o.disableMacro("ALPHA_CLIP"),o},i.draw=function(t){t.renderingData.currentFrame.globalUniforms&&t.setGlobalMatrix("effects_ObjectToWorld",this.transform.getWorldMatrix());for(var e=0;e<this.materials.length;e++){var i=this.materials[e];i.setVector2("_Size",this.transform.size),this.renderer.renderMode!==Ht.BILLBOARD&&this.renderer.renderMode!==Ht.VERTICAL_BILLBOARD&&this.renderer.renderMode!==Ht.HORIZONTAL_BILLBOARD||i.setVector3("_Scale",this.transform.scale),t.drawGeometry(this.geometry,i,e)}},i.fromData=function(e){t.prototype.fromData.call(this,e);var i,r=e,n=null!=(i=r.renderer)?i:{},s=r.splits,a=r.textureSheetAnimation,o=r.mask;o&&this.maskManager.getMaskMode(o);var u,h,c,l=n.shape,f=s&&!a?s[0]:void 0,d=void 0;if(null==l||"aPoint"in l&&"index"in l||(d=Rs(l,f)),this.splits=s||Ps,this.textureSheetAnimation=a,this.renderer={renderMode:null!=(u=n.renderMode)?u:Ht.MESH,blending:null!=(h=n.blending)?h:Dt.ALPHA,texture:n.texture?this.engine.findObject(n.texture):this.engine.emptyTexture,occlusion:!!n.occlusion,transparentOcclusion:!!n.transparentOcclusion||this.maskManager.maskMode===ui.MASK,side:null!=(c=n.side)?c:kt.DOUBLE,mask:this.maskManager.getRefValue(),shape:d},this.configureMaterial(this.renderer),r.geometry){var p=this.engine.findObject(r.geometry),m=r.splits&&!r.textureSheetAnimation?r.splits[0]:Ps[0],v=m[0],y=m[1],g=Boolean(m[4]),x=g?m[3]:m[2],b=g?m[2]:m[3],T=g?-Math.PI/2:0,E=p.getAttributeData("aUV"),_=p.getAttributeData("aPos"),A=p.getIndexData(),C=[0,0];if(E&&_&&A){for(var S=E.length/2,O=0;O<S;O++){var R=3*O,M=2*O,I=_[R],P=_[R+1];C[0]=I,C[1]=P,Ms(C,C,T),E[M]=(C[0]+.5)*x+v,E[M+1]=(C[1]+.5)*b+y}this.geometry.setAttributeData("aPos",_.slice()),this.geometry.setAttributeData("aUV",E.slice()),this.geometry.setIndexData(A.slice()),this.geometry.setDrawCount(A.length)}this.geometry.subMeshes.length=0;for(var L,F=w(p.subMeshes);!(L=F()).done;){var V=L.value;this.geometry.subMeshes.push({offset:V.offset,indexCount:V.indexCount,vertexCount:V.vertexCount})}}else this.geometry=this.defaultGeometry,this.configureDefaultGeometry(this.renderer)},Pe(e,[{key:"color",get:function(){return this._color},set:function(t){this._color=t,this.material.setColor("_Color",this._color)}}]),e}(Ge),Fs=function(t){function e(e){var i;(i=t.call(this,e)||this).hasStroke=!1,i.hasFill=!1,i.shapeDirty=!0,i.graphicsPath=new Dh,i.vert="\nprecision highp float;\n\nattribute vec3 aPos;//x y\n\nuniform mat4 effects_MatrixVP;\nuniform mat4 effects_MatrixInvV;\nuniform mat4 effects_ObjectToWorld;\n\nvoid main() {\n vec4 pos = vec4(aPos.xyz, 1.0);\n gl_Position = effects_MatrixVP * effects_ObjectToWorld * pos;\n}\n",i.frag="\nprecision highp float;\n\nuniform vec4 _Color;\n\nvoid main() {\n vec4 color = _Color;\n color.rgb *= color.a;\n gl_FragColor = color;\n}\n",i.geometry.subMeshes.push({offset:0,indexCount:0,vertexCount:0},{offset:0,indexCount:0,vertexCount:0});var r={shader:{vertex:i.vert,fragment:i.frag,glslVersion:ur.GLSL1}},n=cr.create(e,r),s=cr.create(e,r);return n.color=new ii(1,1,1,1),n.depthMask=!1,n.depthTest=!0,n.blending=!0,i.material=n,s.color=new ii(.25,.25,.25,1),s.depthMask=!1,s.depthTest=!0,s.blending=!0,i.materials[1]=s,i.strokeAttributes={width:1,alignment:.5,cap:xe.Butt,join:be.Miter,miterLimit:10,color:new ii(1,1,1,1)},i.fillAttribute={color:new ii(1,1,1,1)},i.shapeAttribute={type:ge.Custom,points:[],easingIns:[],easingOuts:[],shapes:[]},i}Qt(e,t);var i=e.prototype;return i.onStart=function(){this.item.getHitTestParams=this.getHitTestParams},i.onUpdate=function(t){this.material.color=this.fillAttribute.color,this.materials[1].color=this.strokeAttributes.color,this.shapeDirty&&(this.buildPath(this.shapeAttribute),this.buildGeometryFromPath(this.graphicsPath.shapePath),this.shapeDirty=!1)},i.buildGeometryFromPath=function(t){var e=t.shapePrimitives,i=[],r=[];if(this.hasFill)for(var n,s=w(e);!(n=s()).done;){var a=n.value.shape,o=[],u=r.length,h=i.length/2;a.build(o),a.triangulate(o,i,h,r,u)}var c=r.length;if(this.hasStroke)for(var l,f=w(e);!(l=f()).done;){var d=l.value.shape,p=[],m=i.length/2,v=this.strokeAttributes,y=!0;this.shapeAttribute.type===ge.Custom&&(y=d.closePath),d.build(p),Th(p,v,!1,y,i,2,m,r)}var g=r.length-c,x=i.length/2,b=this.geometry.getAttributeData("aPos"),T=this.geometry.getAttributeData("aUV"),E=this.geometry.getIndexData();(!b||b.length<3*x)&&(b=new Float32Array(3*x)),(!T||T.length<2*x)&&(T=new Float32Array(2*x)),(!E||E.length<r.length)&&(E=new Uint16Array(r.length));for(var _=0;_<x;_++){var A=3*_,C=2*_,S=2*_;b[A]=i[C],b[A+1]=i[C+1],b[A+2]=0,T[S]=b[A],T[S+1]=b[A+1]}E.set(r),this.geometry.setAttributeData("aPos",b),this.geometry.setAttributeData("aUV",T),this.geometry.setIndexData(E),this.geometry.setDrawCount(r.length);var O=this.geometry.subMeshes[0],R=this.geometry.subMeshes[1];O.indexCount=c,R.offset=2*c,R.indexCount=g},i.buildPath=function(t){switch(this.graphicsPath.clear(),t.type){case ge.Custom:for(var e,i=this.shapeAttribute,r=i.points,n=i.easingIns,s=i.easingOuts,a=w(i.shapes);!(e=a()).done;){var o=e.value,u=o.indexes,h=r[u[0].point];this.graphicsPath.moveTo(h.x,h.y);for(var c=1;c<u.length;c++){var l=u[c],f=u[c-1],d=r[l.point],p=r[f.point],m=s[f.easingOut],v=n[l.easingIn];this.graphicsPath.bezierCurveTo(m.x+p.x,m.y+p.y,v.x+d.x,v.y+d.y,d.x,d.y,1)}if(o.close){var y=u[0],g=u[u.length-1],x=r[y.point],b=r[g.point],T=s[g.easingOut],E=n[y.easingIn];this.graphicsPath.bezierCurveTo(T.x+b.x,T.y+b.y,E.x+x.x,E.y+x.y,x.x,x.y,1),this.graphicsPath.closePath()}}break;case ge.Ellipse:var _=t;this.graphicsPath.ellipse(0,0,_.xRadius,_.yRadius);break;case ge.Rectangle:var A=t;this.graphicsPath.rect(-A.width/2,-A.height/2,A.width,A.height,A.roundness);break;case ge.Star:var C=t;this.graphicsPath.polyStar(C.pointCount,C.outerRadius,C.innerRadius,C.outerRoundness,C.innerRoundness,Ph.Star);break;case ge.Polygon:var S=t;this.graphicsPath.polyStar(S.pointCount,S.radius,S.radius,S.roundness,S.roundness,Ph.Polygon)}},i.fromData=function(e){t.prototype.fromData.call(this,e),this.shapeDirty=!0;var i=e.stroke;i&&(this.hasStroke=!0,this.strokeAttributes.width=i.width,this.strokeAttributes.color.copyFrom(i.color),this.strokeAttributes.cap=i.cap,this.strokeAttributes.join=i.join);var r=e.fill;switch(r&&(this.hasFill=!0,this.fillAttribute.color.copyFrom(r.color)),e.type){case ge.Custom:for(var n,s=e,a={type:ge.Custom,points:[],easingIns:[],easingOuts:[],shapes:[],fill:s.fill},o=w(s.points);!(n=o()).done;){var u=n.value;a.points.push(new Ke(u.x,u.y))}for(var h,c=w(s.easingIns);!(h=c()).done;){var l=h.value;a.easingIns.push(new Ke(l.x,l.y))}for(var f,d=w(s.easingOuts);!(f=d()).done;){var p=f.value;a.easingOuts.push(new Ke(p.x,p.y))}a.shapes=s.shapes,this.shapeAttribute=a;break;case ge.Ellipse:var m=e,v={type:ge.Ellipse,xRadius:m.xRadius,yRadius:m.yRadius,fill:m.fill};this.shapeAttribute=v;break;case ge.Rectangle:var y=e,g={type:ge.Rectangle,width:y.width,height:y.height,roundness:y.roundness,fill:y.fill};this.shapeAttribute=g;break;case ge.Star:var x=e,b={type:ge.Star,pointCount:x.pointCount,innerRadius:x.innerRadius,outerRadius:x.outerRadius,innerRoundness:x.innerRoundness,outerRoundness:x.outerRoundness,fill:x.fill};this.shapeAttribute=b;break;case ge.Polygon:var T=e,E={type:ge.Polygon,pointCount:T.pointCount,radius:T.radius,roundness:T.roundness,fill:T.fill};this.shapeAttribute=E}e.mask&&this.maskManager.getMaskMode(e.mask);var _=this.maskManager.getRefValue();this.material.stencilRef=void 0!==_?[_,_]:void 0,Ei(this.material,this.maskManager.maskMode)},Pe(e,[{key:"shape",get:function(){return this.shapeDirty=!0,this.shapeAttribute}}]),e}(Ls);Fs=S([Ne("ShapeComponent")],Fs);var Vs,Ns=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).loop=!1,e.amountOfMotion=1,e.animationLength=2,e.mode=1,e.startPositionX=0,e.startPositionY=0,e.startPositionZ=0,e.endPositionX=0,e.endPositionY=0,e.endPositionZ=0,e.amplitudeX=0,e.amplitudeY=0,e.amplitudeZ=0,e.phaseX=0,e.phaseY=0,e.phaseZ=0,e}Qt(e,t);var i=e.prototype;return i.onStart=function(){this.effectComponent=this.item.getComponent(ti)},i.onUpdate=function(t){this.updateFake3D()},i.updateFake3D=function(){if(this.effectComponent){var t=this.item.time%this.animationLength/this.animationLength,e=0,i=0,r=0;switch(this.mode){case 0:var n=Math.PI;e=Math.sin(2*n*(t+this.phaseX))*this.amplitudeX,i=Math.sin(2*n*(t+this.phaseY))*this.amplitudeY,r=Math.sin(2*n*(t+this.phaseZ))*this.amplitudeZ;break;case 1:var s=t;this.loop&&(s>.5&&(s=1-s),s*=2),e=this.startPositionX*(1-s)+s*this.endPositionX,i=this.startPositionY*(1-s)+s*this.endPositionY,r=this.startPositionZ*(1-s)+s*this.endPositionZ}var a=this.effectComponent.material;a.setFloat("_PosX",e*this.amountOfMotion),a.setFloat("_PosY",i*this.amountOfMotion),a.setFloat("_PosZ",r*this.amountOfMotion)}},e}(Ue);S([De()],Ns.prototype,"loop",void 0),S([De()],Ns.prototype,"amountOfMotion",void 0),S([De()],Ns.prototype,"animationLength",void 0),S([De()],Ns.prototype,"mode",void 0),S([De()],Ns.prototype,"startPositionX",void 0),S([De()],Ns.prototype,"startPositionY",void 0),S([De()],Ns.prototype,"startPositionZ",void 0),S([De()],Ns.prototype,"endPositionX",void 0),S([De()],Ns.prototype,"endPositionY",void 0),S([De()],Ns.prototype,"endPositionZ",void 0),S([De()],Ns.prototype,"amplitudeX",void 0),S([De()],Ns.prototype,"amplitudeY",void 0),S([De()],Ns.prototype,"amplitudeZ",void 0),S([De()],Ns.prototype,"phaseX",void 0),S([De()],Ns.prototype,"phaseY",void 0),S([De()],Ns.prototype,"phaseZ",void 0),Ns=S([Ne("Fake3DComponent")],Ns),function(t){t[t.Circular=0]="Circular",t[t.Linear=1]="Linear"}(Vs||(Vs={}));var Ds=function(t){function e(e,i){var r;return r=t.call(this,e)||this,i&&r.fromData(i),r}Qt(e,t);var i=e.prototype;return i.onUpdate=function(){if(this.item.composition&&this.item.transform.getValid()){var t=this.item.composition.camera;t.near=this.options.near,t.far=this.options.far,t.fov=this.options.fov,t.clipMode=this.options.clipMode,t.transform.parentTransform=this.transform.parentTransform,t.position=this.transform.position,t.setQuat(this.transform.getQuaternion().clone().conjugate())}},i.fromData=function(e){t.prototype.fromData.call(this,e),this.options=e.options},e}(Ue);Ds=S([Ne(_e.CameraController)],Ds);var ks,zs=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e}(qt);!function(t){t[t.triangle=1]="triangle",t[t.box=2]="box",t[t.sphere=3]="sphere",t[t.custom=4]="custom"}(ks||(ks={}));var Us="click",Bs="touchstart",Gs="touchmove",js="touchend",Xs=function(){function t(t,e){void 0===e&&(e=!1),this.target=t,this.allowPropagation=e,this.enabled=!0,this.handlers={},this.nativeHandlers={}}var e=t.prototype;return e.bindListeners=function(){var t,e,i,r,n,s=this;n=function(t){return t};var a,o="mousedown",u="mousemove",h="mouseup",c=function(t,e,i,n,a){void 0===n&&(n=0),void 0===a&&(a=0);var o=0,u=0,h=d.now();if(!s.target)return mt.warn("Trigger TouchEvent after EventSystem is disposed."),{x:e,y:i,vx:0,vy:u,dx:n,dy:a,ts:h,width:0,height:0,origin:t};var c=s.target,l=c.width,f=c.height;if(r){var p=h-r.ts;o=(n-r.dx)/p||0,u=(a-r.dy)/p||0,r={dx:n,dy:a,ts:h}}return{x:e,y:i,vx:o,vy:u,dx:n,dy:a,ts:h,width:l,height:f,origin:t}};Q()&&(n=function(t){var e=t.touches,i=t.changedTouches;return e[0]||i[0]},o="touchstart",u="touchmove",h="touchend"),this.nativeHandlers=((a={})[o]=function(a){if(s.enabled){var o=n(a),u=Hs(o);t=u.x,e=u.y,r=i={clientX:o.clientX,clientY:o.clientY,ts:d.now(),x:t,y:e},s.dispatchEvent(Bs,c(a,t,e))}},a[u]=function(r){if(i&&s.enabled){var a=Hs(n(r));t=a.x,e=a.y,s.dispatchEvent(Gs,c(r,t,e,t-i.x,e-i.y))}},a[h]=function(r){if(i&&s.enabled){!s.allowPropagation&&r.cancelable&&(r.preventDefault(),r.stopPropagation());var a=n(r),o=Hs(a),u=Math.abs(i.clientX-a.clientX)+Math.abs(i.clientY-a.clientY);t=o.x,e=o.y,u<4&&s.dispatchEvent(Us,c(r,t,e)),s.dispatchEvent(js,c(r,t,e,t-i.x,e-i.y))}i=0},a),Object.keys(this.nativeHandlers).forEach((function(t){var e;null==(e=s.target)||e.addEventListener(String(t),s.nativeHandlers[t])}))},e.dispatchEvent=function(t,e){var i=this.handlers[t];null==i||i.forEach((function(t){return t(e)}))},e.addEventListener=function(t,e){var i=this.handlers[t];return i||(i=this.handlers[t]=[]),D(i,e),function(){k(i,e)}},e.removeEventListener=function(t,e){var i=this.handlers[t];i&&k(i,e)},e.dispose=function(){var t=this;this.target&&(this.handlers={},Object.keys(this.nativeHandlers).forEach((function(e){var i;null==(i=t.target)||i.removeEventListener(String(e),t.nativeHandlers[e])})),this.nativeHandlers={},this.target=null)},t}();function Hs(t){var e=t.target,i=t.clientX,r=t.clientY,n=e.getBoundingClientRect(),s=n.left,a=n.top;return{x:(i-s)/n.width*2-1,y:1-(r-a)/n.height*2}}var Ys,Ws,Zs=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e}(qt),qs=(Ys=new Float32Array(1),Ws=new Int32Array(Ys.buffer),function(t){Ys[0]=t;var e=Ws[0],i=e>>16&32768,r=e>>12&2047,n=e>>23&255;return n<103?i:n>142?(i|=31744,i|=(255==n?0:1)&&8388607&e):n<113?i|=((r|=2048)>>114-n)+(r>>113-n&1):(i|=n-112<<10|r>>1,i+=1&r)}),Ks=function(){function t(t){if(Number.isInteger(t))this.data=new Uint16Array(t);else if(t&&"object"==typeof t&&Number.isInteger(t.length))for(var e=this.data=new Uint16Array(t.length),i=0;i<e.length;i++)e[i]=qs(t[i])}return t.prototype.set=function(t,e){for(var i=0;i<t.length;i++)this.data[i+e]=qs(t[i])},t}();function Qs(t,e){for(var i=[-.5,.5,-.5,-.5,.5,.5,.5,-.5],r=0;r<8;r+=2)i[r]+=t,i[r+1]+=e;return i}var Js,$s=new Or,ta=new ni;function ea(t,e,i,r,n,s,a){var o=t,u=r/n,h=r,c=e.speedOverLifetime;c&&(h=c.getIntegrateValue(0,r,n));var l=e.gravityModifier?e.gravityModifier.getIntegrateByTime(0,r):0;o.copyFrom(s),o.addScaledVector(a,h),o.addScaledVector(i,l);var f=e.linearVelOverLifetime||{},d=e.orbitalVelOverLifetime||{};if(d.enabled){var p=new Qe;d.center&&p.setFromArray(d.center);var m=o.clone().subtract(p),v=d.asRotation,y=["x","y","z"].map((function(t){var e=d[t];return e?v?e.getValue(u):e.getIntegrateValue(0,r,n):0}));$s.setFromArray(y).negate(),ta.setFromEuler($s);var g=ta.transformPoint(m);o.addVectors(p,g)}if(f.enabled){var x=f.asMovement,b=f.x,T=f.y,E=f.z;if(b){var _=x?b.getValue(u):b.getIntegrateValue(0,r,n);o.x=o.x+_}if(T){var w=x?T.getValue(u):T.getIntegrateValue(0,r,n);o.y=o.y+w}if(E){var A=x?E.getValue(u):E.getIntegrateValue(0,r,n);o.z=o.z+A}}return o}function ia(t){return Array.isArray(t)?[t[0],t[1],t[2]]:[0,0,0]}function ra(t,e){for(var i=0,r=t.length;i<r;i++)t[i]=e;return t}function na(t,e,i){if(e&&i)for(var r=0,n=e.length;r<n;r++)t[r]=e[r]*i[r];else if(e){if(t!==e)for(var s=0;s<e.length;s++)t[s]=e[s]}else if(i&&t!==i)for(var a=0;a<i.length;a++)t[a]=i[a];return t}var sa=((Js={})[Yt.PARTICLE_ORIGIN_CENTER]=[0,0],Js[Yt.PARTICLE_ORIGIN_CENTER_BOTTOM]=[0,-.5],Js[Yt.PARTICLE_ORIGIN_CENTER_TOP]=[0,.5],Js[Yt.PARTICLE_ORIGIN_LEFT_TOP]=[-.5,.5],Js[Yt.PARTICLE_ORIGIN_LEFT_CENTER]=[-.5,0],Js[Yt.PARTICLE_ORIGIN_LEFT_BOTTOM]=[-.5,-.5],Js[Yt.PARTICLE_ORIGIN_RIGHT_CENTER]=[.5,0],Js[Yt.PARTICLE_ORIGIN_RIGHT_BOTTOM]=[.5,-.5],Js[Yt.PARTICLE_ORIGIN_RIGHT_TOP]=[.5,.5],Js);function aa(t){return Math.pow(2,Math.round(Math.log(t)/Math.LN2))}function oa(t,e,i){var r=i.position,n=new Qe(t,e,0),s=new Qe;return i.getInverseViewProjectionMatrix().projectPoint(n,s),s.subtract(r),new Mr(r,s)}function ua(t,e,i){var r=t.x,n=t.y,s=t.z,a=new Qe(r-e,n+i,s),o=new Qe(r-e,n-i,s),u=new Qe(r+e,n-i,s),h=new Qe(r+e,n+i,s);return[{p0:a,p1:o,p2:u},{p0:a.clone(),p1:u.clone(),p2:h}]}function ha(t,e,i){return void 0===i&&(i=1e-6),Math.abs(t-e)<i}function ca(t,e){void 0===e&&(e=2);var i=Math.pow(10,e);return Math.floor(t*i)/i}var la={pointIndexCache:{xIndex:0,yIndex:0},getPointInCurve:function(t){t[0];var e=t[1],i=this.getPointIndexInCurve(t,this.pointIndexCache),r=i.xIndex,n=i.yIndex,s=e[r],a=e[n];return new Ke(s,a)},getPointIndexInCurve:function(t,e){var i=t[0],r=t[2],n=i===te.LINE||i===te.EASE_OUT?0:i===te.EASE_IN||i===te.EASE||i===te.HOLD&&r===te.EASE_IN?2:0;return e?(e.xIndex=n,e.yIndex=n+1,e):{xIndex:n,yIndex:n+1}},isLeftSideEase:function(t){var e=t[0];t[1];var i=t[2];return!(e!==te.HOLD||!this.isKeyframeTypeLeftSideEase(i))||this.isKeyframeTypeLeftSideEase(e)},isRightSideEase:function(t){var e=t[0];t[1];var i=t[2];return!(e!==te.HOLD||!this.isKeyframeTypeRightSideEase(i))||this.isKeyframeTypeRightSideEase(e)},isKeyframeTypeLeftSideEase:function(t){return[te.EASE,te.EASE_IN,te.AUTO].includes(t)},isKeyframeTypeRightSideEase:function(t){return[te.EASE,te.EASE_OUT,te.AUTO].includes(t)},isHoldInKeyframe:function(t){var e=t[0];t[1];var i=t[2];return e===te.HOLD&&[te.HOLD,te.LINE_OUT,te.EASE_OUT].includes(i)},isHoldOutKeyframe:function(t){var e=t[0];t[1];var i=t[2];return e===te.HOLD&&[te.HOLD,te.LINE,te.EASE_IN].includes(i)}},fa=function(t,e){this.points=t,this.totalLength=e},da={},pa={},ma=.1;function va(t,e){return 1-3*e+3*t}function ya(t,e){return 3*e-6*t}function ga(t){return 3*t}function xa(t,e,i){return((va(e,i)*t+ya(e,i))*t+ga(e))*t}function ba(t,e,i){return 3*va(e,i)*t*t+2*ya(e,i)*t+ga(e)}var Ta=function(){function t(t,e,i,r){this.p1=t,this.p2=e,this.p3=i,this.p4=r,this.catching={lastPoint:0,lastAddedLength:0};var n=function(t,e,i,r){var n=ca(e.x-t.x,3)+"_"+ca(e.y-t.y,3)+"_"+ca(e.z-t.z,3)+"&"+ca(i.x-t.x,3)+"_"+ca(i.y-t.y,3)+"_"+ca(i.z-t.z,3)+"&"+ca(r.x-t.x,3)+"_"+ca(r.y-t.y,3)+"_"+ca(r.z-t.z,3);if(pa[n])return{data:pa[n],interval:t};for(var s=[],a=null,o=0,u=0,h=0;h<300;h+=1){var c=new Qe,l=h/299;u=0,c.x=3*Math.pow(1-l,2)*l*(i.x-t.x)+3*(1-l)*Math.pow(l,2)*(r.x-t.x)+Math.pow(l,3)*(e.x-t.x),c.y=3*Math.pow(1-l,2)*l*(i.y-t.y)+3*(1-l)*Math.pow(l,2)*(r.y-t.y)+Math.pow(l,3)*(e.y-t.y),c.z=3*Math.pow(1-l,2)*l*(i.z-t.z)+3*(1-l)*Math.pow(l,2)*(r.z-t.z)+Math.pow(l,3)*(e.z-t.z),null!==a&&(u+=Math.pow(c.x-a.x,2),u+=Math.pow(c.y-a.y,2),u+=Math.pow(c.z-a.z,2)),a=c,o+=u=Math.sqrt(u),s[h]={partialLength:u,point:c}}var f=new fa(s,o);return pa[n]=f,{data:f,interval:new Qe(t.x,t.y,t.z)}}(t,e,i,r),s=n.data,a=n.interval;this.lengthData=s,this.interval=a,this.totalLength=s.totalLength}return t.prototype.getPointInPercent=function(t){var e=this.lengthData;if(0===t)return e.points[0].point.clone().add(this.interval);if(ha(1-t,0))return e.points[299].point.clone().add(this.interval);if(ha(e.totalLength,0))return this.p1.clone();var i=new Qe,r=ca(e.totalLength*t,4),n=this.catching.lastAddedLength,s=this.catching.lastPoint;if(ha(n,r))return e.points[s].point.clone().add(this.interval);var a=!0,o=1;for(r<n&&(o=-1);a;){if(r>=n){if(299===s){i.x=e.points[s].point.x,i.y=e.points[s].point.y,i.z=e.points[s].point.z;break}if(r<n+e.points[s+1].partialLength){var u=(r-n)/e.points[s+1].partialLength;i.x=e.points[s].point.x+(e.points[s+1].point.x-e.points[s].point.x)*u,i.y=e.points[s].point.y+(e.points[s+1].point.y-e.points[s].point.y)*u,i.z=e.points[s].point.z+(e.points[s+1].point.z-e.points[s].point.z)*u;break}}o>0&&s<299?(s+=o,n+=ca(e.points[s].partialLength,5)):o<0&&s>0?(n-=ca(e.points[s].partialLength,5),s+=o):a=!1}return this.catching.lastPoint=s,this.catching.lastAddedLength=n,i.add(this.interval),i},t}(),Ea=function(){function t(t,e,i,r){this.p1=t,this.p2=e,this.p3=i,this.p4=r,this.temp=new ri,this.totalLength=0}return t.prototype.getPointInPercent=function(t){return 0===t?this.temp.copyFrom(this.p1):ha(1-t,0)?this.temp.copyFrom(this.p2):(Aa.slerpFlat(this.temp,this.p1,this.p2,t),this.temp)},t}(),_a=function(){function t(t,e,i,r){this.mX1=t,this.mY1=e,this.mX2=i,this.mY2=r,this.precomputed=!1,this.mSampleValues=new Array(11)}var e=t.prototype;return e.precompute=function(){this.precomputed=!0,this.mX1===this.mY1&&this.mX2===this.mY2||this.calcSampleValues()},e.getValue=function(t){return this.mX1===this.mY1&&this.mX2===this.mY2?t:isNaN(this.mY1)||isNaN(this.mY2)?0:0===t||1===t?t:(this.precomputed||this.precompute(),xa(this.getTForX(t),this.mY1,this.mY2))},e.calcSampleValues=function(){for(var t=0;t<11;++t)this.mSampleValues[t]=xa(t*ma,this.mX1,this.mX2)},e.getTForX=function(t){for(var e=this.mSampleValues,i=0,r=1;10!==r&&e[r]<=t;++r)i+=ma;var n=i+(t-e[--r])/(e[r+1]-e[r])*ma,s=ba(n,this.mX1,this.mX2);return s>=.001?function(t,e,i,r){for(var n=0;n<4;++n){var s=ba(e,i,r);if(0===s)return e;e-=(xa(e,i,r)-t)/s}return e}(t,n,this.mX1,this.mX2):0===s?n:function(t,e,i,r,n){var s,a,o=0;do{(s=xa(a=e+(i-e)/2,r,n)-t)>0?i=a:e=a}while(Math.abs(s)>1e-7&&++o<10);return a}(t,i,i+ma,this.mX1,this.mX2)},t}();function wa(t,e){var i=function(t,e,i){var r=t[1],n=la.isHoldOutKeyframe(t),s=la.isHoldInKeyframe(e),a=!s&&la.isRightSideEase(t),o=!n&&la.isLeftSideEase(e);if(a&&!o&&!s){var u=new Ke(r[r.length-4],r[r.length-3]),h=new Ke(r[r.length-2],r[r.length-1]),c=la.getPointInCurve(e),l=new Ke(c.x,c.y);return{type:"ease",p0:u,p1:h,p2:new Ke(l.x-(l.x-u.x)/10,l.y),p3:l}}if(!a&&o&&!n){var f=e[1],d=la.getPointInCurve(t),p=new Ke(d.x,d.y),m=new Ke(f[0],f[1]),v=new Ke(f[2],f[3]);return{type:"ease",p0:p,p1:new Ke(p.x+(v.x-p.x)/10,p.y),p2:m,p3:v}}if(a&&o){var y=e[1];return{type:"ease",p0:new Ke(r[r.length-4],r[r.length-3]),p1:new Ke(r[r.length-2],r[r.length-1]),p2:new Ke(y[0],y[1]),p3:new Ke(y[2],y[3])}}var g=la.getPointInCurve(t),x=la.getPointInCurve(e);n?x.y=g.y:s&&(g.y=x.y);return i?{type:"ease",p0:g,p1:new Ke((x.x-g.x)/3+g.x,(x.y-g.y)/3+g.y),p2:new Ke((x.x-g.x)/3*2+g.x,(x.y-g.y)/3*2+g.y),p3:x,isHold:n||s,leftHoldLine:n,rightHoldLine:s}:{type:"line",p0:g,p1:x,isHold:n||s,leftHoldLine:n,rightHoldLine:s}}(t,e,!0),r=i.p0,n=i.p1,s=i.p2,a=i.p3;ot(s),ot(a);var o,u,h=a.x-r.x,c=a.y-r.y,l=ca((n.x-r.x)/h,5),f=ca((s.x-r.x)/h,5);ha(c,0)?o=u=NaN:(o=ca((n.y-r.y)/c,5),u=ca((s.y-r.y)/c,5)),l<0&&(console.error("Invalid bezier points, x1 < 0",r,n,s,a),l=0),f<0&&(console.error("Invalid bezier points, x2 < 0",r,n,s,a),f=0),l>1&&(console.error("Invalid bezier points, x1 >= 1",r,n,s,a),l=1),f>1&&(console.error("Invalid bezier points, x2 >= 1",r,n,s,a),f=1);var d,p=("bez_"+l+"_"+o+"_"+f+"_"+u).replace(/\./g,"p");return da[p]?d=da[p]:(d=new _a(l,o,f,u),da[p]=d),{points:[r,n,s,a],timeInterval:h,valueInterval:c,curve:d}}var Aa=function(){function t(){}return t.slerpFlat=function(t,e,i,r){var n=e.x,s=e.y,a=e.z,o=e.w,u=i.x,h=i.y,c=i.z,l=i.w;if(0===r)return t.x=n,t.y=s,t.z=a,void(t.w=o);if(1===r)return t.x=u,t.y=h,t.z=c,void(t.w=l);if(o!==l||n!==u||s!==h||a!==c){var f=1-r,d=n*u+s*h+a*c+o*l,p=d>=0?1:-1,m=1-d*d;if(m>Number.EPSILON){var v=Math.sqrt(m),y=Math.atan2(v,d*p);f=Math.sin(f*y)/v,r=Math.sin(r*y)/v}var g=r*p;if(n=n*f+u*g,s=s*f+h*g,a=a*f+c*g,o=o*f+l*g,f===1-r){var x=1/Math.sqrt(n*n+s*s+a*a+o*o);n*=x,s*=x,a*=x,o*=x}}t.x=n,t.y=s,t.z=a,t.w=o},t}(),Ca="not_implement",Sa=function(){function t(t){this.onCreate(t)}var e=t.prototype;return e.onCreate=function(t){throw new Error(Ca)},e.getIntegrateValue=function(t,e,i){throw new Error(Ca)},e.getIntegrateByTime=function(t,e){throw new Error(Ca)},e.getValue=function(t){throw new Error(Ca)},e.getMaxTime=function(){throw new Error(Ca)},e.toUniform=function(t){throw new Error(Ca)},e.map=function(t){throw new Error(Ca)},e.scaleXCoord=function(t){return this},e.toData=function(){throw new Error(Ca)},t.getAllData=function(t,e){for(var i=new(e?Ks:Float32Array)(4*t.index),r=0,n=0,s=t.curves;r<s.length;r++){var a=s[r].toData();i.set(a,n),n+=a.length}return e?i.data:i},t}(),Oa=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.onCreate=function(t){this.value=t},i.getIntegrateValue=function(t,e,i){return this.value*(e-t)},i.getIntegrateByTime=function(t,e){return.5*this.value*(e*e-t*t)},i.getValue=function(t){return this.value},i.toUniform=function(){return new Float32Array([0,this.value,0,0])},i.map=function(t){var e=this.value;return this.value=t(e),this},i.getMaxTime=function(){return 0},e}(Sa),Ra=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.onCreate=function(t){this.items=t},i.getValue=function(t){var e=this.items;return e[Math.floor(Math.random()*e.length)]},i.map=function(t){return this.items=this.items.map(t),this},e}(Sa),Ma=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.onCreate=function(t){this.min=t[0],this.max=t[1]},i.getValue=function(t,e){var i=null!=e?e:Math.random();return this.min+i*(this.max-this.min)},i.getIntegrateValue=function(t,e,i){var r=null!=i?i:1;return(this.min+r*(this.max-this.min))*(e-t)},i.toUniform=function(){return new Float32Array([4,this.min,this.max,0])},i.map=function(t){return this.min=t(this.min),this.max=t(this.max),this},e}(Sa),Ia=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.onCreate=function(t){this.min=t[0],this.max=t[1]},i.getValue=function(t){for(var e=this.min,i=this.max,r=[],n=0;n<e.length;n++){var s=Math.random();r[n]=e[n]*(1-s)+i[n]*s}return r},i.map=function(t){return this.min=this.min.map(t),this.max=this.max.map(t),this},e}(Sa),Pa=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.onCreate=function(t){this.min=t[0],this.max=t[1],this.xCoord=1},i.getValue=function(t){return t/=this.xCoord,this.min*(1-t)+this.max*t},i.toUniform=function(){return new Float32Array([1,this.min,this.max,this.xCoord])},i.getIntegrateValue=function(t,e,i){void 0===i&&(i=1);var r=this.min,n=this.max,s=this.xCoord*i;return((r+e/s*(n-r)+r)*e-(r+t/s*(n-r)+r)*t)/2},i.getIntegrateByTime=function(t,e){return Ua(e,0,this.xCoord,this.min,this.max)-Ua(t,0,this.xCoord,this.min,this.max)},i.map=function(t){return this.min=t(this.min),this.max=t(this.max),this},i.scaleXCoord=function(t){return this.xCoord=t,this},e}(Sa),La=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.onCreate=function(t){this.stops=j(t)},i.getStops=function(){return this.stops},i.getValue=function(t){for(var e=this.stops,i=e.length-1,r=0;r<i;r++){var n=e[r],s=e[r+1];if(n.stop<=t&&s.stop>t){var a=(t-n.stop)/(s.stop-n.stop);return X(n.color,s.color,a,!0)}}return e[i].color.slice()},e}(Sa),Fa=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.onCreate=function(t){this.keys=t.map((function(t){return t.slice?t.slice(0,2):[t.time,t.value]})).sort((function(t,e){return t[0]-e[0]}));var e=this.keys[this.keys.length-1];e[0]<1&&this.keys.push([1,e[1]]);var i=this.keys[0];i[0]>0&&this.keys.unshift([0,i[1]]),this.isLineSeg=!0},i.getValue=function(t){var e=this.keys;if(t<e[0][0])return e[0][1];for(var i=e.length-1,r=0;r<i;r++){var n=e[r],s=e[r+1],a=n[0],o=s[0];if(t>=a&&t<=o){var u=(t-a)/(o-a),h=n[1];return h+u*(s[1]-h)}}return e[i][1]},i.getIntegrateValue=function(t,e,i){return void 0===i&&(i=1),(this.integrate(e,!1)-this.integrate(t,!1))*i},i.getIntegrateByTime=function(t,e){return this.integrate(e,!0)-this.integrate(t,!0)},i.integrate=function(t,e){var i=this.keys;if(t<=i[0][0])return 0;for(var r=0,n=i.length-1,s=e?Ua:za,a=0;a<n;a++){var o=i[a],u=i[a+1],h=o[0],c=u[0];if(t>h&&t<=c)return r+s(t,h,c,o[1],u[1]);r+=s(c,h,c,o[1],u[1])}return r},i.toData=function(){for(var t=this.keys,e=new Float32Array(4*Math.ceil(t.length/2)),i=0,r=0;i<t.length;i++,r+=2)e.set(t[i],r);return e.set(t[t.length-1],e.length-2),e},i.toUniform=function(t){var e=t.index,i=this.keys,r=Math.ceil(i.length/2);return t.lineSegCount+=r,t.curves.push(this),t.index+=r,t.max=Math.max(t.max,r),new Float32Array([3,e,r,0])},i.map=function(t){return this.keys.forEach((function(e){return e[1]=t(e[1])})),this},i.scaleXCoord=function(t){return this.keys.forEach((function(e){return e[0]=t*e[0]})),this},e}(Sa),Va=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.onCreate=function(t){var e=t;this.curveMap={},this.keys=[];for(var i=0;i<e.length-1;i++){var r=wa(e[i],e[i+1]),n=r.points,s=r.curve,a=r.timeInterval,o=r.valueInterval,u=n[0],h=n[n.length-1];this.keys.push([].concat(u.toArray(),n[1].toArray())),this.keys.push([].concat(h.toArray(),n[2].toArray())),this.curveMap[u.x+"&"+h.x]={points:n,timeInterval:a,valueInterval:o,curve:s,timeStart:Number(u.x),timeEnd:Number(h.x)}}this.startKeyframe=e[0],this.endKeyframe=e[e.length-1],this.keyTimeData=Object.keys(this.curveMap)},i.getValue=function(t){var e=0,i=this.keyTimeData,r=this.curveMap[i[0]].timeStart,n=this.curveMap[i[i.length-1]].timeEnd;if(t<=r)return la.getPointIndexInCurve(this.startKeyframe,la.pointIndexCache),this.startKeyframe[1][la.pointIndexCache.yIndex];if(t>=n)return la.getPointIndexInCurve(this.endKeyframe,la.pointIndexCache),this.endKeyframe[1][la.pointIndexCache.yIndex];for(var s=0;s<i.length;s++){var a=this.curveMap[i[s]].timeStart,o=this.curveMap[i[s]].timeEnd;if(t>=Number(a)&&t<Number(o)){e=this.getCurveValue(i[s],t);break}}return e},i.getIntegrateValue=function(t,e,i){void 0===i&&(i=1);var r=(e-t)/i,n=0,s=Object.keys(this.curveMap);if(r<=this.curveMap[s[0]].timeStart)return 0;for(var a=0;a<s.length;a++){var o=this.curveMap[s[a]].timeStart,u=this.curveMap[s[a]].timeEnd;if(r>=Number(u)&&(n+=i*this.getCurveIntegrateValue(s[a],Number(u))),r>=Number(o)&&r<Number(u)){n+=i*this.getCurveIntegrateValue(s[a],r);break}}return n},i.getIntegrateByTime=function(t,e){return this.getIntegrateValue(0,e)-this.getIntegrateValue(0,t)},i.getCurveIntegrateValue=function(t,e){for(var i=this.curveMap[t],r=i.points[0],n=i.timeInterval,s=i.valueInterval,a=0,o=(e-r.x)/20,u=0;u<=20;u++){var h=u*o/n,c=r.y+s*i.curve.getValue(h);a+=0===u||20===u?c:u%2==1?4*c:2*c}return a*=o/3},i.getCurveValue=function(t,e){var i=this.curveMap[t],r=i.points[0],n=i.timeInterval,s=i.valueInterval,a=(e-r.x)/n,o=i.curve.getValue(a);return r.y+s*o},i.toUniform=function(t){var e=t.index,i=this.keys.length;return t.curves.push(this),t.index=e+i,t.max=Math.max(t.max,i),t.curveCount+=i,new Float32Array([5,e+1/i,e,i])},i.toData=function(){for(var t=this.keys,e=new Float32Array(4*t.length),i=0,r=0;i<t.length;i++,r+=4)e.set(t[i],r);return e},i.getMaxTime=function(){var t=this.keyTimeData;return this.curveMap[t[t.length-1]].timeEnd},e}(Sa),Na=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.onCreate=function(t){this.keys=t[0],this.values=t[1]},i.getValue=function(t){for(var e=this.keys,i=this.values,r=0;r<e.length-1;r++){var n=e[r],s=e[r+1];if(n[0]<=t&&s[0]>=t){var a=s[1]-n[1],o=void 0;if(0===a)o=(t-n[0])/(s[0]-n[0]);else o=(Ba(t,n,s)-n[1])/a;return this.calculateVec(r,o)}}return t<=e[0][0]?i[0].slice():i[i.length-1].slice()},i.calculateVec=function(t,e){for(var i=this.values[t],r=this.values[t+1],n=[0,0,0],s=0;s<i.length;s++)n[s]=i[s]*(1-e)+r[s]*e;return n},e}(Sa),Da=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.onCreate=function(t){var e=t[0],i=t[1],r=t[2];if(this.curveSegments={},r.length){for(var n=0;n<e.length-1;n++){var s=e[n],a=e[n+1],o=new Qe(i[n][0],i[n][1],i[n][2]),u=new Qe(i[n+1][0],i[n+1][1],i[n+1][2]),h=new Qe(r[2*n][0],r[2*n][1],r[2*n][2]),c=new Qe(r[2*n+1][0],r[2*n+1][1],r[2*n+1][2]),l=wa(s,a),f=l.points,d=l.curve,p=l.timeInterval,m=l.valueInterval,v=f[0],y=f[f.length-1],g=new Ta(o,u,h,c);this.curveSegments[v.x+"&"+y.x]={points:f,timeInterval:p,valueInterval:m,easingCurve:d,pathCurve:g,timeStart:Number(v.x),timeEnd:Number(y.x)}}this.keyTimeData=Object.keys(this.curveSegments)}},i.getValue=function(t){var e=ca(t,5),i=0,r=new Qe,n=this.keyTimeData;if(!n.length)return r;var s=this.curveSegments[n[0]].timeStart,a=this.curveSegments[n[n.length-1]].timeEnd;if(e<=s)return r=this.curveSegments[n[0]].pathCurve.getPointInPercent(0);if(e>=a)return r=this.curveSegments[n[n.length-1]].pathCurve.getPointInPercent(1);for(var o=0;o<n.length;o++){var u=this.curveSegments[n[o]].timeStart,h=this.curveSegments[n[o]].timeEnd;if(e>=Number(u)&&e<Number(h)){var c=this.curveSegments[n[o]].pathCurve;i=this.getPercValue(n[o],e),r=c.getPointInPercent(i)}}return r},i.getPercValue=function(t,e){var i=this.curveSegments[t],r=i.points[0],n=i.timeInterval,s=ca((e-r.x)/n,4);return qe(i.easingCurve.getValue(s),0,1)},i.getMaxTime=function(){var t=this.keyTimeData;return this.curveSegments[t[t.length-1]].timeEnd},e}(Sa),ka=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.onCreate=function(t){var e=t[0],i=t[1],r=t[2];if(this.curveSegments={},r.length)for(var n=0;n<e.length-1;n++){var s=e[n],a=e[n+1],o=ri.fromArray(i[n]),u=ri.fromArray(i[n+1]),h=ri.fromArray(r[2*n]),c=ri.fromArray(r[2*n+1]),l=wa(s,a),f=l.points,d=l.curve,p=l.timeInterval,m=l.valueInterval,v=f[0],y=f[f.length-1],g=new Ea(o,u,h,c);this.curveSegments[v.x+"&"+y.x]={points:f,timeInterval:p,valueInterval:m,easingCurve:d,pathCurve:g}}},i.getValue=function(t){var e=0,i=ca(t,5),r=Object.keys(this.curveSegments),n=Number(r[0].split("&")[0]),s=Number(r[r.length-1].split("&")[1]);if(i<=n)return this.curveSegments[r[0]].pathCurve.getPointInPercent(0);if(i>=s)return this.curveSegments[r[r.length-1]].pathCurve.getPointInPercent(1);for(var a=0;a<r.length;a++){var o=r[a].split("&"),u=o[0],h=o[1];if(i>=Number(u)&&i<Number(h)){var c=this.curveSegments[r[a]].pathCurve;return e=this.getPercValue(r[a],i),c.getPointInPercent(e)}}return this.curveSegments[r[0]].pathCurve.getPointInPercent(0)},i.getPercValue=function(t,e){var i=this.curveSegments[t],r=i.points[0],n=i.timeInterval,s=ca((e-r.x)/n,4);return qe(i.easingCurve.getValue(s),0,1)},i.getMaxTime=function(){var t=Object.keys(this.curveSegments);return Number(t[t.length-1].split("&")[1])},e}(Sa);function za(t,e,i,r,n){var s=t-e;return(r+r+(n-r)*s/(i-e))*s/2}function Ua(t,e,i,r,n){var s=t*t,a=e*e;return(2*(s*t)*(r-n)+3*s*(e*n-i*r)-a*e*(2*r+n)+3*a*i*r)/(6*(e-i))}function Ba(t,e,i){var r=i[0]-e[0],n=e[3]*r,s=i[2]*r,a=(t-e[0])/r,o=a*a,u=o*a,h=u-2*o+a,c=u-o,l=-2*u+3*o;return(2*u-3*o+1)*e[1]+h*n+c*s+l*i[1]}function Ga(t,e){if(e){var i=e[0],r=e[1];if(i===$t.CURVE){t.curves.push(r);var n=r.length;r[0][0]>0&&n++,r[r.length-1][0]<1&&n++,t.index+=n,t.max=Math.max(t.max,n),t.curveCount+=n}else if(i===$t.LINE){var s=r.length;if(2===s&&0===r[0][0]&&1===r[1][0])return;r[0][0]>0&&s++,r[r.length-1][0]<1&&s++;var a=Math.ceil(s/2);t.lineSegCount+=a,t.curves.push(r),t.index+=a,t.max=Math.max(t.max,a)}else if(i===$t.BEZIER_CURVE){var o=r.length-1;t.index+=2*o,t.curves.push(r),t.max=Math.max(t.max,2*o),t.curveCount+=2*o}}}function ja(){return{curves:[],index:0,max:0,lineSegCount:0,curveCount:0}}function Xa(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Xa=function(){return!!t})()}function Ha(t,e,i){return Ha=Xa()?Reflect.construct:function(t,e,i){var r=[null];r.push.apply(r,e);var n=new(Function.bind.apply(t,r));return i&&Kt(n,i.prototype),n},Ha.apply(null,arguments)}var Ya,Wa=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).value=new Je,e}Qt(e,t);var i=e.prototype;return i.onCreate=function(t){this.xCurve=Ka(t[0]),this.yCurve=Ka(t[1]),this.zCurve=Ka(t[2]),this.wCurve=Ka(t[3])},i.getValue=function(t){var e=this.xCurve.getValue(t),i=this.yCurve.getValue(t),r=this.zCurve.getValue(t),n=this.wCurve.getValue(t);return this.value.set(e,i,r,n),this.value},e}(Sa),Za=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).value=new Ke,e}Qt(e,t);var i=e.prototype;return i.onCreate=function(t){this.xCurve=Ka(t[0]),this.yCurve=Ka(t[1])},i.getValue=function(t){var e=this.xCurve.getValue(t),i=this.yCurve.getValue(t);return this.value.set(e,i),this.value},e}(Sa),qa=((Ya={})[$t.RANDOM]=function(t){return A(t[0],Array)?new Ia(t):new Ma(t)},Ya[$t.CONSTANT]=function(t){return new Oa(t)},Ya[$t.CONSTANT_VEC2]=function(t){return new Oa(t)},Ya[$t.CONSTANT_VEC3]=function(t){return new Oa(t)},Ya[$t.CONSTANT_VEC4]=function(t){return new Oa(t)},Ya[$t.RGBA_COLOR]=function(t){return new Oa(t)},Ya[$t.COLORS]=function(t){return new Ra(t.map((function(t){return B(t,!1)})))},Ya[$t.LINE]=function(t){return 2===t.length&&0===t[0][0]&&1===t[1][0]?new Pa([t[0][1],t[1][1]]):new Fa(t)},Ya[$t.GRADIENT_COLOR]=function(t){return new La(t)},Ya[$t.LINEAR_PATH]=function(t){return new Na(t)},Ya[$t.BEZIER_CURVE]=function(t){return 1===t.length?new Oa(t[0][1][1]):new Va(t)},Ya[$t.BEZIER_CURVE_PATH]=function(t){return 1===t[0].length?new Oa(Ha(Qe,[].concat(t[1][0]))):new Da(t)},Ya[$t.BEZIER_CURVE_QUAT]=function(t){return 1===t[0].length?new Oa(Ha(ri,[].concat(t[1][0]))):new ka(t)},Ya[$t.COLOR_CURVE]=function(t){return new Qa(t)},Ya[$t.VECTOR4_CURVE]=function(t){return new Wa(t)},Ya[$t.VECTOR2_CURVE]=function(t){return new Za(t)},Ya);function Ka(t){if(!t||!isNaN(+t))return new Oa(t||0);if(A(t,Sa))return t;if(xt(qa[t[0]]))return qa[t[0]](t[1]);throw new Error("ValueType: "+t[0]+" is not supported, see "+Cs["ValueType: 21/22 is not supported"]+".")}var Qa=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).value=new ii,e}Qt(e,t);var i=e.prototype;return i.onCreate=function(t){this.rCurve=Ka(t[0]),this.gCurve=Ka(t[1]),this.bCurve=Ka(t[2]),this.aCurve=Ka(t[3])},i.getValue=function(t){var e=this.rCurve.getValue(t),i=this.gCurve.getValue(t),r=this.bCurve.getValue(t),n=this.aCurve.getValue(t);return this.value.set(e,i,r,n),this.value},e}(Sa),Ja=1,$a=function(){function t(t,e,i,r){this.transform=i,this.engine=r,this.color=t.options.previewColor;var n=this.createMaterial(e),s=this.createGeometry();this.mesh=this.createMesh(s,n),this.updateMesh()}var e=t.prototype;return e.updateMesh=function(){var t=this.mesh.material,e=t.getVector2("uSize").clone(),i=t.getVector4("uPos").clone(),r=new Qe,n=new ri,s=this.transform.scale.clone();this.transform.assignWorldTRS(r,n,s),e.x=s.x,e.y=s.y,i.x=r.x,i.y=r.y,i.z=r.z,t.setVector2("uSize",e),t.setVector4("uPos",i),t.setQuaternion("uQuat",n)},e.createMaterial=function(t){var e,i=[["ENV_EDITOR",(null==(e=this.engine.renderer)?void 0:e.env)===As]],r=Ka(this.color).getValue(0),n={shader:{vertex:"\nprecision highp float;\n\nattribute vec2 aPoint;\nuniform vec4 uPos;\nuniform vec2 uSize;\nuniform vec4 uQuat;\nuniform vec4 uColor;\nuniform mat4 effects_ObjectToWorld;\nuniform mat4 effects_MatrixInvV;\nuniform mat4 effects_MatrixVP;\nvarying vec4 vColor;\n#ifdef ENV_EDITOR\n uniform vec4 uEditorTransform;\n#endif\n\nvec3 rotateByQuat(vec3 a, vec4 quat){\n vec3 qvec = quat.xyz;\n vec3 uv = cross(qvec, a);\n vec3 uuv = cross(qvec, uv) * 2.;\n return a +(uv * 2. * quat.w + uuv);\n}\n\nvoid main() {\n vec4 _pos = uPos;\n vec3 point = rotateByQuat(vec3(aPoint.xy * uSize, 0.),uQuat);\n vec4 pos = vec4(_pos.xyz, 1.0);\n pos = effects_ObjectToWorld * pos;\n pos.xyz += effects_MatrixInvV[0].xyz * point.x+ effects_MatrixInvV[1].xyz * point.y;\n gl_Position = effects_MatrixVP * pos;\n vColor = uColor;\n #ifdef ENV_EDITOR\n gl_Position = vec4(gl_Position.xy * uEditorTransform.xy + uEditorTransform.zw * gl_Position.w, gl_Position.zw);\n #endif\n}\n",fragment:"\nprecision highp float;\n\n#define fragColor gl_FragColor\n\nvarying vec4 vColor;\nvoid main() {\n gl_FragColor = vColor*vColor.a;\n}\n",glslVersion:ur.GLSL1,cacheId:t.cachePrefix+"_effects_interact",macros:i},uniformSemantics:{effects_MatrixVP:"VIEWPROJECTION",effects_MatrixInvV:"VIEWINVERSE",effects_ObjectToWorld:"MODEL",uEditorTransform:"EDITOR_TRANSFORM"}},s=cr.create(this.engine,n);return s.blending=!0,s.depthTest=!1,s.setVector4("uPos",new Je(0,0,0,0)),s.setVector2("uSize",new Ke(1,1)),s.setVector4("uColor",new Je(r[0]/255,r[1]/255,r[2]/255,r[3])),s.setQuaternion("uQuat",new ri(0,0,0,0)),s},e.createGeometry=function(){var t=new Uint8Array([0,1,1,2,2,3,3,0]);return Cr.create(this.engine,{attributes:{aPoint:{size:2,offset:0,stride:2*Float32Array.BYTES_PER_ELEMENT,data:new Float32Array([-.5,.5,.5,.5,.5,-.5,-.5,-.5])}},drawCount:t.length,indices:{data:t},mode:fi.LINES,maxVertex:4})},e.createMesh=function(t,e){return Dr.create(this.engine,{name:"Interact_preview"+Ja++,priority:0,worldMatrix:ni.fromIdentity(),geometry:t,material:e})},t}(),to=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).downgrade=.95,e.dragRatio=[1,1],e.dragRange={dxRange:[0,0],dyRange:[0,0]},e.duringPlay=!1,e._interactive=!0,e.lastTime=-1,e.getHitTestParams=function(t){if(e.clickable){var i=e.item.props.content.options.behavior,r=e.getBoundingBox();return r?{type:r.type,triangles:r.area,behavior:i}:void 0}},e}Qt(e,t);var i=e.prototype;return i.getDragRangeX=function(){return this.dragRange.dxRange},i.setDragRangeX=function(t,e){this.dragRange.dxRange=[t,e]},i.getDragRangeY=function(){return this.dragRange.dyRange},i.setDragRangeY=function(t,e){this.dragRange.dyRange=[t,e]},i.onStart=function(){var t=this.item.props.content.options,e=this.item.engine.renderer.env,i=this.item.composition,r=this.interactData.options,n=r.type,s=r.showPreview;if(n===Gt.CLICK&&(this.clickable=!0,s&&e===As)){var a=null==i?void 0:i.getRendererOptions();void 0!==a&&(this.previewContent=new $a(this.item.props.content,a,this.transform,this.engine))}t.type===Gt.DRAG&&(e!==As||t.enableInEditor)&&(null==i?void 0:i.event)&&this.beginDragTarget(t,i.event),this.previewContent&&(this.previewContent.mesh.item=this.item,this.materials=this.previewContent.mesh.materials),this.item.getHitTestParams=this.getHitTestParams},i.onDisable=function(){t.prototype.onDisable.call(this),this.item&&this.item.composition&&(this.duringPlay&&!this.item.transform.getValid()&&(this.item.composition.removeInteractiveItem(this.item,this.item.props.content.options.type),this.duringPlay=!1),this.clickable=!1,this.endDragTarget())},i.onEnable=function(){t.prototype.onEnable.call(this);var e=this.interactData.options.type,i=this.item.engine.renderer.env;if(e===Gt.CLICK)this.clickable=!0;else if(e===Gt.DRAG){var r,n=this.interactData.options,s=n.enableInEditor;if(i!==As||s)(null==(r=this.item.composition)?void 0:r.event)&&this.beginDragTarget(n,this.item.composition.event)}},i.onUpdate=function(t){var e;if(this.duringPlay=!0,this.lastTime<=this.item.time){if(this.item.time>=0&&this.lastTime<0){var i,r=this.item.props.content.options;null==(i=this.item.composition)||i.addInteractiveItem(this.item,r.type)}}else if(this.item.time>=0){var n,s=this.item.props.content.options;null==(n=this.item.composition)||n.addInteractiveItem(this.item,s.type)}this.lastTime=this.item.time,null==(e=this.previewContent)||e.updateMesh(),this.dragEvent&&this.bouncingArg&&(this.bouncingArg.vx*=this.downgrade,this.bouncingArg.vy*=this.downgrade,this.bouncingArg.dy+=this.bouncingArg.vy,this.bouncingArg.dx+=this.bouncingArg.vx,eo(this.bouncingArg)?(this.dragEvent=null,this.bouncingArg=null):this.handleDragMove(this.dragEvent,this.bouncingArg))},i.render=function(t){this.previewContent&&this.previewContent.mesh.render(t)},i.onDestroy=function(){var t;null==(t=this.previewContent)||t.mesh.dispose()},i.endDragTarget=function(){},i.handleDragMove=function(t,e){if((null==t?void 0:t.cameraParam)&&this.canInteract()&&this.item.composition){var i,r,n=t.cameraParam,s=n.position,a=n.fov,o=e.dy,u=e.dx*e.width/e.height,h=s[2],c=Math.tan(a*Math.PI/180/2)*Math.abs(h),l=o*c,f=u*c,d=this.dragRange,p=d.dxRange,m=d.dyRange,v=s[0]-this.dragRatio[0]*f,y=s[1]-this.dragRatio[1]*l,g=p[0],x=p[1],b=m[0],T=m[1];if(v=qe(v,g,x),y=qe(y,b,T),v!==g&&v!==x&&g!==x)null==(i=e.origin)||i.preventDefault();if(y!==b&&y!==T&&b!==T)null==(r=e.origin)||r.preventDefault();this.item.composition.camera.position=new Qe(v,y,h)}},i.beginDragTarget=function(t,i){var r=this;if("camera"===t.target){var n,s={touchstart:function(t){var e;if(r.canInteract()){r.dragEvent=null,r.bouncingArg=null;var i=null==(e=r.item.composition)?void 0:e.camera;n={x:t.x,y:t.y,cameraParam:{position:(null==i?void 0:i.position.toArray())||[0,0,8],fov:(null==i?void 0:i.fov)||60}}}},touchmove:function(t){r.handleDragMove(n,t),r.bouncingArg=t},touchend:function(t){if(r.canInteract()){var e=r.bouncingArg;if(!eo(e,3)&&e){e.vx*=5,e.vy*=5,r.dragEvent=_i({},n)}n=null}}};Object.keys(s).forEach((function(t){i.addEventListener(t,s[t])})),s.touchmove({dx:0,dy:0,width:1,height:1}),this.item.getComponent(e).endDragTarget=function(){Object.keys(s).forEach((function(t){i.removeEventListener(t,s[t])}))}}},i.getBoundingBox=function(){var t=this.transform.getWorldMatrix(),e=ua(Qe.ZERO,.5*this.transform.size.x,.5*this.transform.size.y);return e.forEach((function(e){t.transformPoint(e.p0),t.transformPoint(e.p1),t.transformPoint(e.p2)})),{type:ks.triangle,area:e}},i.fromData=function(e){if(t.prototype.fromData.call(this,e),this.interactData=e,e.options.type===Gt.DRAG){var i=e.options;i.dxRange&&(this.dragRange.dxRange=i.dxRange),i.dyRange&&(this.dragRange.dyRange=i.dyRange)}},i.canInteract=function(){var t;return Boolean(null==(t=this.item.composition)?void 0:t.interactive)&&this._interactive},Pe(e,[{key:"interactive",get:function(){return this._interactive},set:function(t){this._interactive=t,t||(this.bouncingArg=null)}}]),e}(Ge);function eo(t,e){var i=1e-5*(e||1);return t&&Math.abs(t.vx||0)<i&&Math.abs(t.vy||0)<i}to=S([Ne(_e.InteractComponent)],to);var io,ro=function(){function t(){this.triangles=[],this.worldMatrix=new ni,this.assemblyTriangles=function(t,e,i,r,n){for(var s=i;s<r;s+=3){var a=3*e[s],o=3*e[s+1],u=3*e[s+2],h={x:t[a],y:t[a+1],z:t[a+2]},c={x:t[o],y:t[o+1],z:t[o+2]},l={x:t[u],y:t[u+1],z:t[u+2]};n.push({p0:h,p1:c,p2:l})}}}var e=t.prototype;return e.getBoundingBoxData=function(){return this.applyWorldMatrix(this.boundingBoxData.area),this.boundingBoxData},e.getBoundingBox=function(){for(var t,e=-Number.MAX_VALUE,i=-Number.MAX_VALUE,r=Number.MAX_VALUE,n=Number.MAX_VALUE,s=w(this.boundingBoxData.area);!(t=s()).done;){var a=t.value;e=Math.max(a.p0.x,a.p1.x,a.p2.x,e),i=Math.max(a.p0.y,a.p1.y,a.p2.y,i),r=Math.min(a.p0.x,a.p1.x,a.p2.x,r),n=Math.min(a.p0.y,a.p1.y,a.p2.y,n)}var o=[],u=new Qe(r,i,0),h=new Qe(e,i,0),c=new Qe(e,n,0),l=new Qe(r,n,0);return o.push({p0:u,p1:h,p2:c}),o.push({p0:u,p1:c,p2:l}),this.applyWorldMatrix(o),{type:ks.triangle,area:o}},e.setGeometry=function(t,e){this.triangles=this.geometryToTriangles(t);for(var i,r=[],n=w(this.triangles);!(i=n()).done;){var s=i.value;r.push({p0:s.p0,p1:s.p1,p2:s.p2})}e&&this.worldMatrix.copyFrom(e),this.boundingBoxData={type:ks.triangle,area:r}},e.geometryToTriangles=function(t){var e=t.getIndexData(),i=t.getAttributeData("aPos"),r=[];if(!e||!i)return r;if(0===t.subMeshes.length)this.assemblyTriangles(i,e,0,e.length,r);else for(var n,s=w(t.subMeshes);!(n=s()).done;){var a=n.value;if(void 0!==a.indexCount){var o=e.BYTES_PER_ELEMENT,u=a.offset/o,h=u+a.indexCount;this.assemblyTriangles(i,e,u,h,r)}}return r},e.applyWorldMatrix=function(t){var e=this;return t.forEach((function(t){t.p0=e.worldMatrix.transformPoint(t.p0,new Qe),t.p1=e.worldMatrix.transformPoint(t.p1,new Qe),t.p2=e.worldMatrix.transformPoint(t.p2,new Qe)})),t},t}(),no=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).name="sprite",e}return Qt(e,t),e}(qt),so=function(){function t(){this.playableOutputs=[],this.playables=[]}var e=t.prototype;return e.evaluate=function(t){for(var e,i=w(this.playableOutputs);!(e=i()).done;){e.value.context.deltaTime=t}for(var r,n=w(this.playableOutputs);!(r=n()).done;){var s=r.value;this.prepareFrameWithRoot(s)}for(var a,o=w(this.playableOutputs);!(a=o()).done;){var u=a.value;this.processFrameWithRoot(u)}},e.addOutput=function(t){this.playableOutputs.push(t)},e.addPlayable=function(t){this.playables.push(t)},e.processFrameWithRoot=function(t){t.sourcePlayable.processFrame(t.context),t.processFrame()},e.prepareFrameWithRoot=function(t){t.prepareFrame(),t.sourcePlayable.prepareFrame(t.context)},e.updatePlayableTime=function(t,e){0===t.getPlayState()&&t.setTime(t.getTime()+e)},t}(),ao=function(){function t(t,e){this.onPlayablePlayFlag=!0,this.onPlayablePauseFlag=!1,this.duration=0,this.destroyed=!1,this.playState=0,this.time=0,t.addPlayable(this)}var e=t.prototype;return e.play=function(){switch(this.playState){case 0:break;case 1:this.playState=0,this.onPlayablePlayFlag=!0,this.onPlayablePauseFlag=!1}},e.pause=function(){if(0===this.playState)this.playState=1,this.onPlayablePauseFlag=!0,this.onPlayablePlayFlag=!1},e.setTime=function(t){this.time=t},e.getTime=function(){return this.time},e.setDuration=function(t){this.duration=t},e.getDuration=function(){return this.duration},e.getPlayState=function(){return this.playState},e.prepareFrame=function(t){},e.processFrame=function(t){},e.onPlayableDestroy=function(){},e.dispose=function(){this.destroyed||(this.onPlayableDestroy(),this.destroyed=!0)},t}(),oo=function(){function t(){this.context={deltaTime:0,output:this}}var e=t.prototype;return e.setSourcePlayable=function(t){this.sourcePlayable=t},e.setUserData=function(t){this.userData=t},e.getUserData=function(){return this.userData},e.prepareFrame=function(){},e.processFrame=function(){},t}(),uo=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e}(ze);function ho(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}!function(t){t[t.Playing=0]="Playing",t[t.Paused=1]="Paused"}(io||(io={}));var co=new ri,lo=1,fo=function(){function t(t,e){void 0===t&&(t={}),this.taggedProperties={},this.position=new Qe(0,0,0),this.quat=new ri(0,0,0,1),this.rotation=new Or(0,0,0),this.scale=new Qe(1,1,1),this.anchor=new Qe(0,0,0),this.size=new Ke(1,1),this.children=[],this.worldMatrix=ni.fromIdentity(),this.localMatrix=ni.fromIdentity(),this.valid=!0,this.dirtyFlags={localData:!1,localMatrix:!1,worldMatrix:!1,parentMatrix:!1},this.worldTRSCache={position:new Qe(0,0,0),quat:new ri(0,0,0,1),scale:new Qe(1,1,1)},this.name="transform_"+lo++,t&&this.setTransform(t),e&&(this.parentTransform=e),void 0!==t.valid&&this.setValid(t.valid)}var e=t.prototype;return e.setPosition=function(t,e,i){this.position.x===t&&this.position.y===e&&this.position.z===i||(this.position.x=t,this.position.y=e,this.position.z=i,this.dirtyFlags.localData=!0,this.dispatchValueChange())},e.translate=function(t,e,i){0===t&&0===e&&0===i||(this.position.x+=t,this.position.y+=e,this.position.z+=i,this.dirtyFlags.localData=!0,this.dispatchValueChange())},e.setRotation=function(t,e,i){this.rotation.x===t&&this.rotation.y===e&&this.rotation.z===i||(this.rotation.x=t,this.rotation.y=e,this.rotation.z=i,this.quat.setFromEuler(this.rotation),this.quat.conjugate(),this.dirtyFlags.localData=!0,this.dispatchValueChange())},e.setQuaternion=function(t,e,i,r){this.quat.x===t&&this.quat.y===e&&this.quat.z===i&&this.quat.w===r||(this.quat.x=t,this.quat.y=e,this.quat.z=i,this.quat.w=r,this.rotation.setFromQuaternion(this.quat),this.dirtyFlags.localData=!0,this.dispatchValueChange())},e.setScale=function(t,e,i){this.scale.x===t&&this.scale.y===e&&this.scale.z===i||(this.scale.x=t,this.scale.y=e,this.scale.z=i,this.dirtyFlags.localData=!0,this.dispatchValueChange())},e.setSize=function(t,e){this.size.x===t&&this.size.y===e||(this.size.x=t,this.size.y=e,this.dirtyFlags.localData=!0,this.dispatchValueChange())},e.rotateByQuat=function(t){this.quat.multiply(t),this.rotation.setFromQuaternion(this.quat),this.dirtyFlags.localData=!0,this.dispatchValueChange()},e.scaleBy=function(t,e,i){this.scale.x*=t,this.scale.y*=e,this.scale.z*=i,this.dirtyFlags.localData=!0,this.dispatchValueChange()},e.setAnchor=function(t,e){this.anchor.x===t&&this.anchor.y===e||(this.anchor.x=t,this.anchor.y=e,this.dirtyFlags.localData=!0,this.dispatchValueChange())},e.setTransform=function(t,e){var i=t.position,r=t.rotation,n=t.scale,s=t.size,a=t.quat,o=t.name,u=t.anchor;if(o&&(this.name=o),i&&(A(i,Qe)?this.setPosition(i.x,i.y,i.z):this.setPosition(i[0],i[1],i[2])),a)A(a,ri)?this.setQuaternion(a.x,a.y,a.z,a.w):this.setQuaternion(a[0],a[1],a[2],a[3]);else if(r){var h=e?-1:1;A(r,Or)?this.setRotation(r.x*h,r.y*h,r.z*h):this.setRotation(r[0]*h,r[1]*h,r[2]*h)}n&&(A(n,Qe)?this.setScale(n.x,n.y,n.z):this.setScale(n[0],n[1],n[2])),s&&this.setSize(s.x,s.y),u&&(A(u,Ke)?this.setAnchor(u.x,u.y):this.setAnchor(u[0],u[1]))},e.addChild=function(t){D(this.children,t)},e.removeChild=function(t){k(this.children,t)},e.getRotation=function(){return t.getRotation(this.quat,new Or)},e.getQuaternion=function(){return this.quat},e.updateLocalMatrix=function(){this.valid?(this.dirtyFlags.localData&&(this.localMatrix.compose(this.position,this.quat,this.scale,this.anchor),this.dirtyFlags.localMatrix=!0),this.dirtyFlags.localData=!1):this.localMatrix.isIdentity()||(this.localMatrix.identity(),this.dirtyFlags.localMatrix=!0)},e.getMatrix=function(){return this.updateLocalMatrix(),this.localMatrix},e.getParentMatrix=function(){return this.parent&&(this.parentMatrix=this.parent.getWorldMatrix(),this.dirtyFlags.parentMatrix=this.dirtyFlags.parentMatrix||this.parent.dirtyFlags.localMatrix||this.parent.dirtyFlags.worldMatrix),this.parentMatrix},e.getWorldMatrix=function(){var t=this.getMatrix(),e=this.getParentMatrix();return(this.dirtyFlags.localMatrix||this.dirtyFlags.parentMatrix)&&(e?this.worldMatrix.multiplyMatrices(e,t):this.worldMatrix.copyFrom(t),this.dirtyFlags.worldMatrix=!0,this.dirtyFlags.localMatrix=!1,this.dirtyFlags.parentMatrix=!1),this.worldMatrix},e.getWorldScale=function(){var t=this.worldTRSCache;this.dirtyFlags.worldMatrix&&(this.getWorldMatrix().decompose(t.position,t.quat,t.scale),this.dirtyFlags.worldMatrix=!1);return this.worldTRSCache.scale.clone()},e.getWorldPosition=function(){return this.updateTRSCache(),this.worldTRSCache.position.clone()},e.getWorldRotation=function(){return this.updateTRSCache(),t.getRotation(this.worldTRSCache.quat,new Or)},e.assignWorldTRS=function(t,e,i){this.updateTRSCache(),t&&t.copyFrom(this.worldTRSCache.position),e&&e.copyFrom(this.worldTRSCache.quat),i&&i.copyFrom(this.worldTRSCache.scale)},e.cloneFromMatrix=function(t,e){t.decompose(this.position,this.quat,this.scale),this.rotation.setFromQuaternion(this.quat.clone().conjugate()),e&&e.copyFrom(this.scale),this.dirtyFlags.localData=!0,this.dispatchValueChange()},e.setValid=function(t){this.valid!==t&&(this.valid=t,t?this.dirtyFlags.localData=!0:(this.localMatrix.identity(),this.dirtyFlags.localMatrix=!0),this.dispatchValueChange())},e.getValid=function(){return this.valid},e.toData=function(){var t=this.taggedProperties;return t.position=this.position.clone(),t.eulerHint={x:this.rotation.x,y:this.rotation.y,z:this.rotation.z},t.scale=this.scale.clone(),t},e.fromData=function(t){var e={position:(new Qe).copyFrom(t.position),rotation:new Or(t.eulerHint.x,t.eulerHint.y,t.eulerHint.z),scale:(new Qe).copyFrom(t.scale)};this.setTransform(e)},e.dispose=function(){},e.updateTRSCache=function(){var t=this.getWorldMatrix();if(this.dirtyFlags.worldMatrix){var e=this.worldTRSCache;t.decompose(e.position,e.quat,e.scale),this.dirtyFlags.worldMatrix=!1}},e.dispatchValueChange=function(){this.children.forEach((function(t){t.parentMatrixDirty=!0}))},t.getRotation=function(t,e){var i=co.copyFrom(t);return i.conjugate(),e.setFromQuaternion(i)},Pe(t,[{key:"parentTransform",get:function(){return this.parent},set:function(t){t&&this.parent!==t&&this!==t&&(this.parent&&this.parent.removeChild(this),t.addChild(this),this.parent=t,this.parentMatrixDirty=!0)}},{key:"parentMatrixDirty",get:function(){return this.dirtyFlags.parentMatrix},set:function(t){this.dirtyFlags.parentMatrix!==t&&(this.dirtyFlags.parentMatrix=t,this.dispatchValueChange())}}]),t}(),po=new Qe(1,1,1),mo=function(){function t(t,e){void 0===e&&(e={}),this.name=t,this.transform=new fo,this.viewportMatrix=ni.fromIdentity(),this.viewMatrix=ni.fromIdentity(),this.projectionMatrix=ni.fromIdentity(),this.viewProjectionMatrix=ni.fromIdentity(),this.inverseViewMatrix=ni.fromIdentity(),this.dirty=!0;var i=e.near,r=void 0===i?.1:i,n=e.far,s=void 0===n?20:n,a=e.fov,o=void 0===a?60:a,u=e.aspect,h=void 0===u?1:u,c=e.clipMode,l=void 0===c?Jt.portrait:c,f=e.position,d=void 0===f?[0,0,8]:f,p=e.rotation,m=void 0===p?[0,0,0]:p,v=new Or(m[0],m[1],m[2]),y=(new ri).setFromEuler(v);this.options={near:r,far:s,fov:o,aspect:h,clipMode:l},this.transform.setPosition(d[0],d[1],d[2]),this.transform.setQuaternion(y.x,y.y,y.z,y.w),this.dirty=!0,this.updateMatrix()}var e=t.prototype;return e.setTransform=function(t){this.transform.parentTransform=t.parentTransform,this.transform.cloneFromMatrix(t.getMatrix()),this.dirty=!0},e.setViewportMatrix=function(t){this.viewportMatrix=t.clone(),this.dirty=!0},e.getViewportMatrix=function(){return this.viewportMatrix},e.getViewMatrix=function(){return this.updateMatrix(),this.viewMatrix.clone()},e.getInverseViewMatrix=function(){return this.updateMatrix(),this.inverseViewMatrix.clone()},e.getProjectionMatrix=function(){return this.updateMatrix(),this.projectionMatrix.clone()},e.getInverseProjectionMatrix=function(){var t;return this.updateMatrix(),null==(t=this.inverseProjectionMatrix)?void 0:t.clone()},e.getViewProjectionMatrix=function(){return this.updateMatrix(),this.viewProjectionMatrix.clone()},e.getInverseViewProjectionMatrix=function(){return this.updateMatrix(),this.inverseViewProjectionMatrix||(this.inverseViewProjectionMatrix=this.viewProjectionMatrix.clone(),this.inverseViewProjectionMatrix.invert()),this.inverseViewProjectionMatrix.clone()},e.getModelViewProjection=function(t,e){return t.multiplyMatrices(this.viewProjectionMatrix,e)},e.getInverseVPRatio=function(t){var e=new Qe(this.position.x,this.position.y,t),i=this.getViewProjectionMatrix(),r=this.getInverseViewProjectionMatrix();if(!this.viewportMatrix.isIdentity()){var n=this.viewportMatrix.clone();r.premultiply(n),i.multiply(n.invert())}var s=i.projectPoint(e).z,a=r.projectPoint(new Qe(1,1,s)),o=a.x,u=a.y,h=r.projectPoint(new Qe(-1,-1,s)),c=h.x,l=h.y;return new Qe((o-c)/2,(u-l)/2,0)},e.setQuat=function(t){this.transform.getQuaternion().equals(t)||(this.transform.setQuaternion(t.x,t.y,t.z,t.w),this.dirty=!0)},e.getQuat=function(){return this.transform.quat.clone()},e.getOptions=function(){return _i({},this.options,{position:this.position.clone(),rotation:this.rotation.clone()})},e.copy=function(t){var e=t.near,i=t.far,r=t.fov,n=t.clipMode,s=t.aspect,a=t.position,o=t.rotation;this.near=e,this.far=i,this.fov=r,this.clipMode=n,this.aspect=s,this.position=a,this.rotation=o,this.updateMatrix()},e.updateMatrix=function(){if(this.dirty){var t,e=this.options,i=e.fov,r=e.aspect,n=e.near,s=e.far,a=e.clipMode;this.projectionMatrix.perspective(i*Xe,r,n,s,a===Jt.portrait),this.projectionMatrix.premultiply(this.viewportMatrix),this.inverseViewMatrix.compose(this.position,this.getQuat(),po),this.inverseViewMatrix.premultiply(null!=(t=this.transform.getParentMatrix())?t:ni.IDENTITY),this.viewMatrix.copyFrom(this.inverseViewMatrix).invert(),this.viewProjectionMatrix.multiplyMatrices(this.projectionMatrix,this.viewMatrix),this.inverseViewProjectionMatrix=null,this.dirty=!1}},Pe(t,[{key:"near",get:function(){return this.options.near},set:function(t){this.options.near!==t&&(this.options.near=t,this.dirty=!0)}},{key:"far",get:function(){return this.options.far},set:function(t){this.options.far!==t&&(this.options.far=t,this.dirty=!0)}},{key:"fov",get:function(){return this.options.fov},set:function(t){this.options.fov!==t&&(this.options.fov=t,this.dirty=!0)}},{key:"aspect",get:function(){return this.options.aspect},set:function(t){this.options.aspect!==t&&(this.options.aspect=t,this.dirty=!0)}},{key:"clipMode",get:function(){return this.options.clipMode},set:function(t){void 0!==t&&this.options.clipMode!==t&&(this.options.clipMode=t,this.dirty=!0)}},{key:"position",get:function(){return this.transform.position.clone()},set:function(t){this.transform.position.equals(t)||(this.transform.setPosition(t.x,t.y,t.z),this.dirty=!0)}},{key:"worldPosition",get:function(){return this.transform.getWorldPosition()}},{key:"rotation",get:function(){return this.transform.rotation.clone()},set:function(t){this.transform.rotation.equals(t)||(this.transform.setRotation(t.x,t.y,t.z),this.dirty=!0)}}]),t}(),vo=function(){function t(t){var e=t.time,i=t.interval,r=t.count,n=t.cycles,s=t.probability;this.time=+e||0,this.interval=+i||1,this.count=A(r,Sa)?r:Ka(r),this.cycles=+n||1/0,this.probability=isNaN(s)?1:+s,this.reset()}var e=t.prototype;return e.getGeneratorOptions=function(t,e){if(t-this.time-this.now>this.interval*this.index&&this.internalCycles>0)return this.internalCycles--,this.index++,Math.random()<=this.probability?{index:this.index,total:1/this.interval,count:this.count.getValue(e),cycleIndex:this.cycles-this.internalCycles-1}:null},e.reset=function(){this.internalCycles=this.cycles,this.index=0,this.now=0},e.clone=function(){return new t({time:this.time,interval:this.interval,count:this.count,cycles:this.cycles,probability:this.probability})},t}(),yo=function(t){this.content=t},go=function(){function t(t){this.sort=t,this.length=0}var e=t.prototype;return e.findNodeByContent=function(t){var e=this.first;if(e)do{if(t(e.content))return e}while(e=e.next)},e.insertNode=function(t,e){var i=t.next;t.next=e,e.pre=t,e.next=i,i&&(i.pre=e)},e.shiftNode=function(t){var e=new yo(t);if(this.length++,1===this.length)return this.first=this.last=e;for(var i=this.first;i;){if(!(this.sort(i.content,e.content)<=0))return i.pre?this.insertNode(i.pre,e):(this.first=e,e.next=i,i.pre=e),e;if(!i.next)return this.insertNode(i,e),this.last=e;i=i.next}},e.pushNode=function(t){var e=new yo(t);if(this.length++,1===this.length)return this.last=this.first=e;for(var i=this.last;i;){if(!(this.sort(e.content,i.content)<=0))return this.insertNode(i,e),i===this.last&&(this.last=e),e;if(this.first===i)return i.pre=e,e.next=i,this.first=e;i=i.pre}},e.removeNode=function(t){var e=this.first;if(this.length--,e===t){var i=this.first=e.next;i&&(i.pre=null)}else if((e=this.last)===t){var r=this.last=e.pre;r&&(r.next=null)}else if(t){var n=t.pre,s=t.next;n.next=s,s&&(s.pre=n)}t.pre=null,t.next=null},e.forEach=function(t,e){var i=this.first,r=0;if(i)do{t.call(e||this,i.content,r++)}while(i=i.next)},e.forEachReverse=function(t,e){var i=this.last,r=this.length-1;if(i)do{t.call(e||this,i.content,r--)}while(i=i.pre)},e.getNodeByIndex=function(t){var e=0,i=this.first;if(!i||t>=this.length||t<0)return null;for(;e<t;)i=i.next,e++;return i},t}(),xo="runtime_env",bo="lookup_texture",To="offscreen_canvas",Eo="post_process_settings",_o={};function wo(t){return _o[t]}function Ao(t,e){return _o[t]=e}var Co=new Qe,So=new Qe,Oo=function(){function t(t,e){this.pointStart=[];var i,r=e.colorOverLifetime,n=e.colorOverTrail,s=e.maxTrailCount,a=e.opacityOverLifetime,o=void 0===a?Ka(1):a,u=e.widthOverTrail,h=e.name,c=e.occlusion,l=e.blending,f=e.maskMode,d=e.mask,p=e.textureMap,m=void 0===p?[0,0,1,1]:p,v=e.texture,y=e.transparentOcclusion,g=e.minimumVertexDistance,x=e.lifetime,b=e.matrix,T=t.gpuCapability,E=T.detail,_=T.level,w=Math.max(e.pointCountPerTrail,2),C={curves:[],index:0,max:0,lineSegCount:0,curveCount:0},S=E.maxVertexTextures>0,O=(null!=(i=t.renderer)?i:{}).env,R={},M=[["ENABLE_VERTEX_TEXTURE",S],["LOOKUP_TEXTURE_CURVE",0],["ENV_EDITOR",O===As]],I=s>64,P=0;r&&(M.push(["COLOR_OVER_LIFETIME",!0]),P|=1,R.uColorOverLifetime=Yi.createWithData(t,it(r))),n&&(M.push(["COLOR_OVER_TRAIL",!0]),P|=4,R.uColorOverTrail=Yi.createWithData(t,it(n))),I?(M.push(["ATTR_TRAIL_START",1]),P|=8):R.uTrailStart=new Float32Array(s),R.uOpacityOverLifetimeValue=o.toUniform(C);var L=u.toUniform(C);M.push(["VERT_CURVE_VALUE_COUNT",C.index],["VERT_MAX_KEY_FRAME_COUNT",C.max]),R.uVCurveValues=Sa.getAllData(C);var F={shader:{vertex:Jr,fragment:Kr,macros:M,glslVersion:1===_?ur.GLSL1:ur.GLSL3,shared:!0,name:"trail#"+h,cacheId:"-t:+"+P+"+"+C.index+"+"+C.max},uniformSemantics:{effects_MatrixVP:"VIEWPROJECTION",effects_MatrixInvV:"VIEWINVERSE",effects_ObjectToWorld:"MODEL",uEditorTransform:"EDITOR_TRANSFORM"}},V=w*s*2,N=(w-1)*s,D=Float32Array.BYTES_PER_ELEMENT,k=12*D,z={attributes:{aColor:{size:4,stride:k,data:new Float32Array(12*V)},aSeed:{size:1,stride:k,offset:4*D,dataSource:"aColor"},aInfo:{size:3,stride:k,offset:5*D,dataSource:"aColor"},aPos:{size:4,stride:k,offset:8*D,dataSource:"aColor"},aTime:{size:1,data:new Float32Array(V)},aDir:{size:3,data:new Float32Array(3*V)}},indices:{data:new Uint16Array(6*V)},drawCount:6*N,name:"trail#"+h,bufferUsage:fi.DYNAMIC_DRAW};if(I)z.attributes.aTrailStart={size:1,data:new Float32Array(V)};else{var U=new Float32Array(V);z.attributes.aTrailStartIndex={size:1,data:U};for(var B=0;B<s;B++)for(var G=2*w,j=B*G,X=0;X<G;X++)U[j+X]=B}var H=xi(l),Y=cr.create(t,F);Y.blending=!0,Y.depthMask=c,Y.depthTest=!0,Y.stencilRef=d?[d,d]:void 0,Ei(Y,f),bi(Y,l);var W=this.mesh=Dr.create(t,{name:"MTrail_"+h,material:Y,geometry:Cr.create(t,z)}),Z=null!=v?v:Yi.createWithData(t);Object.keys(R).map((function(t){var e=R[t];if(A(e,Yi))Y.setTexture(t,e);else if("uTrailStart"===t)Y.setFloats("uTrailStart",e);else if("uVCurveValues"===t){for(var i=[],r=0;r<e.length;r+=4){var n=new Je(e[r],e[r+1],e[r+2],e[r+3]);i.push(n)}Y.setVector4Array(t,i)}else Y.setVector4(t,Je.fromArray(e))})),Y.setFloat("uTime",0),Y.setVector4("uWidthOverTrail",Je.fromArray(L)),Y.setVector2("uTexOffset",new Ke(0,0)),Y.setVector4("uTextureMap",Je.fromArray(m)),Y.setVector4("uParams",new Je(0,w-1,0,0)),Y.setTexture("uMaskTex",Z),Y.setVector4("uColorParams",new Je(v?1:0,+H,0,+(c&&!y))),this.maxTrailCount=s,this.pointCountPerTrail=w,this.checkVertexDistance=g>0,this.minimumVertexDistance=Math.pow(g||.001,2),this.useAttributeTrailStart=I,this.lifetime=x,b&&(this.mesh.worldMatrix=b),this.geometry=W.firstGeometry(),this.trailCursors=new Uint16Array(s)}var e=t.prototype;return e.addPoint=function(t,e,i){i=i||{};var r=this.trailCursors[t],n=this.pointCountPerTrail,s=this.geometry,a=n-1,o=r%n,u=(r-1)%n,h=(r-2)%n,c=this.getTrailPosition(t,u,Co);if(!(c&&this.checkVertexDistance&&(null==c?void 0:c.distanceSquared(e))<this.minimumVertexDistance)){var l=t*n+o,f=Po(c,e),d=i.time||this.time,p=[Math.random(),i.lifetime||this.lifetime,r],m=i.size||1,v=6*l,y=new Float32Array(6);y.set(f,0),y.set(f,3),s.setAttributeSubData("aDir",v,y),s.setAttributeSubData("aTime",2*l,new Float32Array([d,d]));var g=i.color||[1,1,1,1],x=new Float32Array(24),b=e.toArray();if(x.set(g,0),x.set(p,4),x[7]=0,x.set(b,8),x[11]=.5*m,x.set(g,12),x.set(p,16),x[19]=1,x.set(b,20),x[23]=-.5*m,s.setAttributeSubData("aColor",24*l,x),u>=0){var T=this.getTrailPosition(t,h,So),E=new Float32Array(Po(T,c,e)),_=6*(t*n+u);s.setAttributeSubData("aDir",_,E),s.setAttributeSubData("aDir",_+3,E);var w=t*n*2,A=new Uint16Array([2*u+w,2*u+1+w,2*o+w,2*o+w,2*u+1+w,2*o+1+w]),C=6*(t*a+(r-1)%a);s.setIndexSubData(C,A)}r=++this.trailCursors[t];var S=this.mesh.material,O=S.getVector4("uParams"),R=p[2];if(this.useAttributeTrailStart){for(var M=2*n,I=new Float32Array(M),P=0;P<M;P++)I[P]=R;s.setAttributeSubData("aTrailStart",t*I.length,I)}else{var L=S.getFloats("uTrailStart");null!=L&&(L[t]=R,S.setFloats("uTrailStart",L))}O&&(O.y=Math.max(O.y,r-1)-Math.max(0,r-n),S.setVector4("uParams",O))}},e.getTrailPosition=function(t,e,i){var r=this.pointCountPerTrail;if(e>=0&&e<r){var n=24*(t*r+e)+8,s=this.geometry.getAttributeData("aColor");return ot(s),i.x=s[n],i.y=s[1+n],i.z=s[2+n],i}},e.clearAllTrails=function(){var t=this.geometry.getIndexData();ot(t),this.trailCursors=new Uint16Array(this.trailCursors.length),this.geometry.setIndexData(new Uint16Array(t.length))},e.minusTime=function(t){var e=this.geometry.getAttributeData("aTime");ot(e);for(var i=0;i<e.length;i++)e[i]-=t;this.geometry.setAttributeData("aTime",e),this.time-=t},e.clearTrail=function(t){if(0!==this.trailCursors[t]){var e=6*(this.pointCountPerTrail-1),i=this.geometry.getIndexData();ot(i),i.set(new Uint16Array(e),t*e),this.geometry.setIndexData(i),this.trailCursors[t]=0}},e.getPointStartPos=function(t){return this.pointStart[t]},e.setPointStartPos=function(t,e){this.pointStart[t]=e},e.onUpdate=function(t){},Pe(t,[{key:"time",get:function(){return this.mesh.material.getFloat("uTime")||0},set:function(t){this.mesh.material.setFloat("uTime",null!=t?t:0)}}]),t}(),Ro=new Qe,Mo=new Qe,Io=new Qe;function Po(t,e,i){var r=Ro;return t||i?(t?i?(Mo.subtractVectors(e,t).normalize(),Mo.subtractVectors(i,e),Io.copyFrom(Mo).normalize(),r.addVectors(Mo,Io)):r.subtractVectors(e,t):r.subtractVectors(i,e),r.normalize().toArray()):[0,0,0]}var Lo=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).lastTime=0,e}Qt(e,t);var i=e.prototype;return i.start=function(t){var e=t.output.getUserData();!this.particleSystem&&A(e,Wu)&&(this.particleSystem=e.getComponent(Go),this.particleSystem&&(this.particleSystem.name=e.name,this.particleSystem.startEmit(),this.particleSystem.initEmitterTransform()))},i.processFrame=function(t){this.time>=0&&this.start(t);var e=this.particleSystem;if(e){var i=t.deltaTime;this.time>=0&&this.time<e.item.duration&&e.isEnded()&&e.reset(),Math.abs(this.time-this.lastTime)<.001&&(i=0),e.update(i)}this.lastTime=this.time},e}(ao),Fo=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.createPlayable=function(t){return new Lo(t)},e}(uo),Vo={uSprite:"vec4",uParams:"vec4",uAcceleration:"vec4",uGravityModifierValue:"vec4",uOpacityOverLifetimeValue:"vec4",uRXByLifeTimeValue:"vec4",uRYByLifeTimeValue:"vec4",uRZByLifeTimeValue:"vec4",uLinearXByLifetimeValue:"vec4",uLinearYByLifetimeValue:"vec4",uLinearZByLifetimeValue:"vec4",uSpeedLifetimeValue:"vec4",uOrbXByLifetimeValue:"vec4",uOrbYByLifetimeValue:"vec4",uOrbZByLifetimeValue:"vec4",uSizeByLifetimeValue:"vec4",uSizeYByLifetimeValue:"vec4",uColorParams:"vec4",uFSprite:"vec4",uPreviewColor:"vec4",uVCurveValues:"vec4Array",uFCurveValues:"vec4",uFinalTarget:"vec3",uForceCurve:"vec4",uOrbCenter:"vec3",uTexOffset:"vec2",uPeriodValue:"vec4",uMovementValue:"vec4",uStrengthValue:"vec4",uWaveParams:"vec4"},No=function(){function t(t,e){var i;this.particleCount=0,this.cachedRotationVector3=new Qe,this.cachedRotationMatrix=new Rr,this.cachedLinearMove=new Qe,this.tempMatrix3=new Rr,this.VERT_MAX_KEY_FRAME_COUNT=0;var r,n,s=(null!=(i=t.renderer)?i:{}).env,a=e.speedOverLifetime,o=e.colorOverLifetime,u=e.linearVelOverLifetime,h=e.orbitalVelOverLifetime,c=e.sizeOverLifetime,l=e.rotationOverLifetime,f=e.sprite,d=e.gravityModifier,p=e.maxCount,m=e.textureFlip,v=e.useSprite,y=e.name,g=e.gravity,x=e.forceTarget,b=e.side,T=e.occlusion,E=e.anchor,_=e.blending,w=e.maskMode,C=e.mask,S=e.transparentOcclusion,O=e.meshSlots,R=e.renderMode,M=void 0===R?0:R,I=e.diffuse,P=void 0===I?Yi.createWithData(t):I,L=t.gpuCapability.detail,F=L.halfFloatTexture,V=L.maxVertexUniforms,N=[["RENDER_MODE",+M],["ENV_EDITOR",s===As]],D=t.gpuCapability.level,k={curves:[],index:0,max:0,lineSegCount:0,curveCount:0},z={curves:[],index:0,max:0,lineSegCount:0,curveCount:0},U=V>0,B={},G=0,j=0;(this.useSprite=v,U&&N.push(["ENABLE_VERTEX_TEXTURE",!0]),a&&(N.push(["SPEED_OVER_LIFETIME",!0]),j|=2,B.uSpeedLifetimeValue=a.toUniform(k)),(null==f?void 0:f.animate)&&(N.push(["USE_SPRITE",!0]),j|=4,B.uFSprite=B.uSprite=new Float32Array([f.col,f.row,f.total,f.blend?1:0]),this.useSprite=!0),(null==o?void 0:o.color)&&(N.push(["COLOR_OVER_LIFETIME",!0]),j|=16,B.uColorOverLifetime=A(o.color,Yi)?o.color:Yi.createWithData(t,it(o.color))),(null==o?void 0:o.opacity)?B.uOpacityOverLifetimeValue=o.opacity.toUniform(k):B.uOpacityOverLifetimeValue=Ka(1).toUniform(k),["x","y","z"].forEach((function(t,e){var i=0,n=0;(null==u?void 0:u[t])&&(B["uLinear"+t.toUpperCase()+"ByLifetimeValue"]=u[t].toUniform(k),i=1,j|=1<<7+e,u.enabled=!0),N.push(["LINEAR_VEL_"+t.toUpperCase(),i]),(null==h?void 0:h[t])&&(B["uOrb"+t.toUpperCase()+"ByLifetimeValue"]=h[t].toUniform(k),n=1,j|=1<<10+e,r=!0,h.enabled=!0),N.push(["ORB_VEL_"+t.toUpperCase(),n])})),(null==u?void 0:u.asMovement)&&(N.push(["AS_LINEAR_MOVEMENT",!0]),j|=32),r&&((null==h?void 0:h.asRotation)&&(N.push(["AS_ORBITAL_MOVEMENT",!0]),j|=64),B.uOrbCenter=new Float32Array((null==h?void 0:h.center)||[0,0,0])),B.uSizeByLifetimeValue=null==c?void 0:c.x.toUniform(k),null==c?void 0:c.separateAxes)&&(N.push(["SIZE_Y_BY_LIFE",1]),j|=16384,B.uSizeYByLifetimeValue=null==c||null==(n=c.y)?void 0:n.toUniform(k));(null==l?void 0:l.z)&&(B.uRZByLifeTimeValue=l.z.toUniform(k),j|=32768,N.push(["ROT_Z_LIFETIME",1])),(null==l?void 0:l.x)&&(B.uRXByLifeTimeValue=l.x.toUniform(k),j|=65536,N.push(["ROT_X_LIFETIME",1])),(null==l?void 0:l.y)&&(B.uRYByLifeTimeValue=l.y.toUniform(k),j|=1<<17,N.push(["ROT_Y_LIFETIME",1])),(null==l?void 0:l.asRotation)&&(N.push(["ROT_LIFETIME_AS_MOVEMENT",1]),j|=1<<18),B.uGravityModifierValue=d.toUniform(k),x&&(N.push(["FINAL_TARGET",!0]),j|=1<<19,B.uFinalTarget=new Float32Array(x.target||[0,0,0]),B.uForceCurve=x.curve.toUniform(k)),F&&z.max?(j|=1<<20,B.uFCurveValueTexture=Wi(t,Sa.getAllData(z,!0),z.index,1)):B.uFCurveValues=Sa.getAllData(z);var X=k.max+k.curves.length-32>V;if(2===D&&(k.max=-1,k.index=O?O[0]:ko(k.index),z.index>0&&(z.max=-1,z.index=O?O[1]:ko(z.index))),X&&F&&U){var H=Wi(t,Sa.getAllData(k,!0),k.index,1);B.uVCurveValueTexture=H,G=1}else B.uVCurveValues=Sa.getAllData(k);var Y=["-p:",M,j,k.index,k.max,z.index,z.max].join("+");N.push(["VERT_CURVE_VALUE_COUNT",k.index],["FRAG_CURVE_VALUE_COUNT",z.index],["VERT_MAX_KEY_FRAME_COUNT",k.max],["FRAG_MAX_KEY_FRAME_COUNT",z.max]),this.VERT_MAX_KEY_FRAME_COUNT=k.max;var W={shader:{fragment:Kr,vertex:"#define LOOKUP_TEXTURE_CURVE "+G+"\n"+Qr,glslVersion:1===D?ur.GLSL1:ur.GLSL3,shared:!0,cacheId:Y,macros:N,name:"particle#"+y},uniformSemantics:{effects_MatrixV:"VIEW",effects_MatrixVP:"VIEWPROJECTION",uEditorTransform:"EDITOR_TRANSFORM",effects_ObjectToWorld:"MODEL"}},Z=xi(_);B.uTexOffset=new Float32Array(P?[1/P.getWidth(),1/P.getHeight()]:[0,0]),B.uMaskTex=P,B.uColorParams=new Float32Array([P?1:0,+Z,0,+(!!T&&!S)]),B.uParams=[0,0,0,0],B.uAcceleration=[(null==g?void 0:g[0])||0,(null==g?void 0:g[1])||0,(null==g?void 0:g[2])||0,0];var q=cr.create(t,W);q.blending=!0,q.depthTest=!0,q.depthMask=!!T,q.stencilRef=C?[C,C]:void 0,Ei(q,w),bi(q,_),Ti(q,b),Object.keys(B).map((function(t){var e=B[t];if(A(e,Yi))q.setTexture(t,e);else{var i=[];switch(Vo[t]){case"vec4":q.setVector4(t,Je.fromArray(e));break;case"vec3":q.setVector3(t,Qe.fromArray(e));break;case"vec2":q.setVector2(t,Ke.fromArray(e));break;case"vec4Array":for(var r=0;r<e.length;r+=4){var n=new Je(e[r],e[r+1],e[r+2],e[r+3]);i.push(n)}q.setVector4Array(t,i),i.length=0;break;default:console.warn("Uniform "+t+"'s type not in typeMap.")}}})),q.setVector3("emissionColor",new Qe(0,0,0)),q.setFloat("emissionIntensity",0);var K=Cr.create(t,function(t,e,i){var r=Float32Array.BYTES_PER_ELEMENT,n=12*r,s={aPos:{size:3,offset:0,stride:n,data:new Float32Array(0)},aVel:{size:3,offset:3*r,stride:n,dataSource:"aPos"},aDirX:{size:3,offset:6*r,stride:n,dataSource:"aPos"},aDirY:{size:3,offset:9*r,stride:n,dataSource:"aPos"},aRot:{size:3,offset:0,stride:8*r,data:new Float32Array(0)},aSeed:{size:1,offset:3*r,stride:8*r,dataSource:"aRot"},aColor:{size:4,offset:4*r,stride:8*r,dataSource:"aRot"},aOffset:{size:4,stride:4*r,data:new Float32Array(0)},aTranslation:{size:3,data:new Float32Array(0)},aLinearMove:{size:3,data:new Float32Array(0)},aRotation0:{size:3,offset:0,stride:9*r,data:new Float32Array(0)},aRotation1:{size:3,offset:3*r,stride:9*r,dataSource:"aRotation0"},aRotation2:{size:3,offset:6*r,stride:9*r,dataSource:"aRotation0"}};e&&(s.aSprite={size:3,stride:3*r,data:new Float32Array(0)});return{attributes:s,indices:{data:new Uint16Array(0)},name:i,maxVertex:t}}(4*p,this.useSprite,"particle#"+y)),Q=Dr.create(t,{name:"MParticle_"+y,material:q,geometry:K});this.anchor=E,this.mesh=Q,this.geometry=Q.firstGeometry(),this.forceTarget=x,this.sizeOverLifetime=c,this.speedOverLifetime=a,this.linearVelOverLifetime=u,this.orbitalVelOverLifetime=h,this.orbitalVelOverLifetime=h,this.gravityModifier=d,this.rotationOverLifetime=l,this.maxCount=p,this.textureOffsets=m?[0,0,1,0,0,1,1,1]:[0,1,0,0,1,1,1,0],this.time=0}var e=t.prototype;return e.getPointColor=function(t){var e=this.geometry.getAttributeData("aRot"),i=32*t+4;return ot(e),[e[i],e[i+1],e[i+2],e[i+3]]},e.clearPoints=function(){this.resetGeometryData(this.geometry),this.particleCount=0,this.geometry.setDrawCount(0),this.maxParticleBufferCount=0},e.resetGeometryData=function(t){for(var e=t.getAttributeNames(),i=t.getIndexData(),r=0;r<e.length;r++){var n=e[r],s=t.getAttributeData(n);s&&t.setAttributeData(n,new s.constructor(0))}t.setIndexData(new i.constructor(0))},e.onUpdate=function(t){var e=this.geometry.getAttributeData("aPos"),i=Math.ceil(e.length/12);this.applyTranslation(i,t),this.applyRotation(i,t),this.applyLinearMove(i,t)},e.minusTime=function(t){for(var e=this.geometry.getAttributeData("aOffset"),i=0;i<e.length;i+=4)e[i+2]-=t;this.geometry.setAttributeData("aOffset",e),this.time-=t},e.removePoint=function(t){t<this.particleCount&&this.geometry.setAttributeSubData("aOffset",16*t,new Float32Array(16))},e.setPoint=function(t,e){var i=this.maxCount;if(t<i){var r=t+1,n=4*r,s=this.geometry,a=r>this.maxParticleBufferCount,o=1;this.particleCount>300?o=(this.particleCount+100)/this.particleCount:this.particleCount>100?o=1.4:this.particleCount>0&&(o=2);var u={aPos:new Float32Array(48),aRot:new Float32Array(32),aOffset:new Float32Array(16),aTranslation:new Float32Array(12),aLinearMove:new Float32Array(12),aRotation0:new Float32Array(36)},h=this.useSprite;h&&(u.aSprite=new Float32Array(12));var c=new Qe,l=new ri,f=new Qe(1,1,1);e.transform.assignWorldTRS(c,l,f);var d,p=fo.getRotation(l,new Or),m=c.toArray(),v=p.toArray(),y=this.textureOffsets,g=[0,0,e.delay,e.lifetime],x=[0,0,1,1],b=e.vel,T=e.color,E=[-.5,.5,-.5,-.5,.5,.5,.5,-.5],_=Math.random();h&&(d=e.sprite);for(var w=0;w<4;w++){var A=2*w,C=3*w,S=4*w,O=12*w,R=8*w;u.aPos.set(m,O),b.fill(u.aPos,O+3),u.aRot.set(v,R),u.aRot[R+3]=_,u.aRot.set(T,R+4),h&&u.aSprite.set(d,C);var M=e.uv||x;if(M){var I=h?1-y[A+1]:y[A+1];g[0]=M[0]+y[A]*M[2],g[1]=M[1]+I*M[3]}u.aOffset.set(g,S);for(var P=w+w,L=(E[P]-this.anchor.x)*f.x,F=(E[P+1]-this.anchor.y)*f.y,V=0;V<3;V++)u.aPos[O+6+V]=e.dirX.getElement(V)*L,u.aPos[O+9+V]=e.dirY.getElement(V)*F}var N=new Uint16Array([0,1,2,2,1,3].map((function(e){return e+4*t})));if(a){var D=U(s.getIndexData(),6*r,6*i,o);D.set(N,6*t),s.setIndexData(D),this.maxParticleBufferCount=D.length/6}else s.setIndexSubData(6*t,N);Object.keys(u).forEach((function(e){var r=u[e],h=s.getAttributeStride(e)/Float32Array.BYTES_PER_ELEMENT;if(a){var c=s.getAttributeData(e);ot(c);var l=U(c,n*h,4*i*h,o);l.set(r,r.length*t),s.setAttributeData(e,l)}else s.setAttributeSubData(e,r.length*t,r)})),this.particleCount=Math.max(r,this.particleCount),s.setDrawCount(6*this.particleCount)}},e.applyTranslation=function(t,e){var i=this.time,r=this.geometry.getAttributeData("aTranslation"),n=this.geometry.getAttributeData("aVel"),s=this.geometry.getAttributeData("aOffset");r.length<3*t&&(r=this.expandArray(r,3*t));for(var a=0,o=0,u=0,h=this.mesh.material.getVector4("uAcceleration"),c=this.mesh.material.getVector4("uGravityModifierValue"),l=0;l<t;l+=4){var f=12*l+3;a=n[f],o=n[f+1],u=n[f+2];var d=i-s[4*l+2],p=s[4*l+3];if(h&&c){var m=this.gravityModifier.getIntegrateValue(0,d,p),v=h.x*m,y=h.y*m,g=h.z*m;if(this.speedOverLifetime){var x=this.speedOverLifetime.getValue(d/p);a=a*x+v,o=o*x+y,u=u*x+g}else a+=v,o+=y,u+=g}var b=3*l;if(s[4*l+2]<i){var T=a*(e/1e3),E=o*(e/1e3),_=u*(e/1e3);r[b]+=T,r[b+1]+=E,r[b+2]+=_,r[b+3]+=T,r[b+4]+=E,r[b+5]+=_,r[b+6]+=T,r[b+7]+=E,r[b+8]+=_,r[b+9]+=T,r[b+10]+=E,r[b+11]+=_}}this.geometry.setAttributeData("aTranslation",r)},e.applyRotation=function(t,e){var i=this.geometry.getAttributeData("aRotation0"),r=this.geometry.getAttributeData("aOffset"),n=this.geometry.getAttributeData("aRot"),s=this.geometry.getAttributeData("aSeed"),a=this.time,o=this.cachedRotationMatrix;i.length<9*t&&(i=this.expandArray(i,9*t));for(var u=0;u<t;u+=4){var h=qe((a-r[4*u+2])/r[4*u+3],0,1),c=8*u,l=this.cachedRotationVector3.set(n[c],n[c+1],n[c+2]),f=s[8*u+3],d=l;this.rotationOverLifetime?(this.rotationOverLifetime.x&&(A(this.rotationOverLifetime.x,Ma)?d.x+=this.rotationOverLifetime.x.getValue(h,f):d.x+=this.rotationOverLifetime.x.getValue(h)),this.rotationOverLifetime.y&&(A(this.rotationOverLifetime.y,Ma)?d.y+=this.rotationOverLifetime.y.getValue(h,f):d.y+=this.rotationOverLifetime.y.getValue(h)),this.rotationOverLifetime.z&&(A(this.rotationOverLifetime.z,Ma)?d.z+=this.rotationOverLifetime.z.getValue(h,f):d.z+=this.rotationOverLifetime.z.getValue(h))):o.setZero(),0===d.dot(d)&&o.identity();var p=Math.PI/180,m=d.x*p,v=d.y*p,y=d.z*p,g=Math.sin(m),x=Math.sin(v),b=Math.sin(y),T=Math.cos(m),E=Math.cos(v),_=Math.cos(y);o.set(_,-b,0,b,_,0,0,0,1),o.multiply(this.tempMatrix3.set(E,0,x,0,1,0,-x,0,E)),o.multiply(this.tempMatrix3.set(1,0,0,0,T,-g,0,g,T));var w=9*u,C=o.elements;i.set(C,w),u+4<=t&&(i.set(C,w+9),i.set(C,w+18),i.set(C,w+27))}this.geometry.setAttributeData("aRotation0",i)},e.applyLinearMove=function(t,e){var i=this.geometry.getAttributeData("aLinearMove"),r=this.geometry.getAttributeData("aOffset"),n=this.geometry.getAttributeData("aSeed"),s=this.time;i.length<3*t&&(i=this.expandArray(i,3*t));var a=this.cachedLinearMove;if(this.linearVelOverLifetime&&this.linearVelOverLifetime.enabled)for(var o=0;o<t;o+=4){var u=s-r[4*o+2],h=r[4*o+3],c=u/h,l=n[8*o+3];a.setZero(),this.linearVelOverLifetime.asMovement?(this.linearVelOverLifetime.x&&(A(this.linearVelOverLifetime.x,Ma)?a.x=this.linearVelOverLifetime.x.getValue(c,l):a.x=this.linearVelOverLifetime.x.getValue(c)),this.linearVelOverLifetime.y&&(A(this.linearVelOverLifetime.y,Ma)?a.y=this.linearVelOverLifetime.y.getValue(c,l):a.y=this.linearVelOverLifetime.y.getValue(c)),this.linearVelOverLifetime.z&&(A(this.linearVelOverLifetime.z,Ma)?a.z=this.linearVelOverLifetime.z.getValue(c,l):a.z=this.linearVelOverLifetime.z.getValue(c))):(this.linearVelOverLifetime.x&&(A(this.linearVelOverLifetime.x,Ma)?a.x=this.linearVelOverLifetime.x.getIntegrateValue(0,u,l):a.x=this.linearVelOverLifetime.x.getIntegrateValue(0,u,h)),this.linearVelOverLifetime.y&&(A(this.linearVelOverLifetime.y,Ma)?a.y=this.linearVelOverLifetime.y.getIntegrateValue(0,u,l):a.y=this.linearVelOverLifetime.y.getIntegrateValue(0,u,h)),this.linearVelOverLifetime.z&&(A(this.linearVelOverLifetime.z,Ma)?a.z=this.linearVelOverLifetime.z.getIntegrateValue(0,u,l):a.z=this.linearVelOverLifetime.z.getIntegrateValue(0,u,h)));var f=3*o;i[f]=a.x,i[f+1]=a.y,i[f+2]=a.z,i[f+3]=a.x,i[f+4]=a.y,i[f+5]=a.z,i[f+6]=a.x,i[f+7]=a.y,i[f+8]=a.z,i[f+9]=a.x,i[f+10]=a.y,i[f+11]=a.z}this.geometry.setAttributeData("aLinearMove",i)},e.expandArray=function(t,e){var i=new Float32Array(e);return i.set(t),i},t}(),Do=[10,32,64,160];function ko(t){for(var e=0;e<Do.length;e++){var i=Do[e];if(i>t)return i}return t||Do[0]}function zo(t,e,i){var r;void 0===i&&(i="");var n,s=t.content,a=+((null==(r=s.renderer)?void 0:r.renderMode)||0),o=[["RENDER_MODE",a],["ENV_EDITOR",i===As]],u=e.level,h=e.detail,c={curves:[],index:0,max:0,lineSegCount:0,curveCount:0},l={curves:[],index:0,max:0,lineSegCount:0,curveCount:0},f=h.maxVertexUniforms>0,d=(null!=(n=s.positionOverLifetime)?n:{}).speedOverLifetime,p=0,m=0;f&&o.push(["ENABLE_VERTEX_TEXTURE",!0]),d&&(o.push(["SPEED_OVER_LIFETIME",!0]),m|=2,Ga(c,d));var v=s.textureSheetAnimation;v&&v.animate&&(o.push(["USE_SPRITE",!0]),m|=4);var y=s.colorOverLifetime;y&&y.color&&(o.push(["COLOR_OVER_LIFETIME",!0]),m|=16);var g=y&&y.opacity;g&&Ga(c,g);var x,b=s.positionOverLifetime;if(["x","y","z"].forEach((function(t,e){var i=0,r="linear"+t.toUpperCase(),n="orbital"+t.toUpperCase();(null==b?void 0:b[r])&&(Ga(c,b[r]),i=1,m|=1<<7+e),o.push(["LINEAR_VEL_"+t.toUpperCase(),i]);var s=0;(null==b?void 0:b[n])&&(Ga(c,b[n]),s=1,m|=1<<10+e,x=!0),o.push(["ORB_VEL_"+t.toUpperCase(),s])})),(null==b?void 0:b.asMovement)&&(o.push(["AS_LINEAR_MOVEMENT",!0]),m|=32),x&&(null==b?void 0:b.asRotation)&&(o.push(["AS_ORBITAL_MOVEMENT",!0]),m|=64),s.sizeOverLifetime){var T=s.sizeOverLifetime;T.separateAxes?(Ga(c,T.x),o.push(["SIZE_Y_BY_LIFE",1]),m|=16384,Ga(c,T.y)):Ga(c,T.size)}if(s.rotationOverLifetime){var E=s.rotationOverLifetime;E.z&&(Ga(c,null==E?void 0:E.z),m|=32768,o.push(["ROT_Z_LIFETIME",1])),E.separateAxes&&(E.x&&(Ga(c,E.x),m|=65536,o.push(["ROT_X_LIFETIME",1])),E.y&&(Ga(c,E.y),m|=1<<17,o.push(["ROT_Y_LIFETIME",1]))),(null==E?void 0:E.asRotation)&&(o.push(["ROT_LIFETIME_AS_MOVEMENT",1]),m|=1<<18)}Ga(c,null==b?void 0:b.gravityOverLifetime),(null==b?void 0:b.forceTarget)&&(o.push(["FINAL_TARGET",!0]),m|=1<<19,Ga(c,b.forceCurve));var _=h.halfFloatTexture;_&&l.max&&(m|=1<<20);var w=h.maxVertexUniforms,A=c.max+c.curves.length-32>w;wo(bo)&&(A=!0),2===u&&(c.max=-1,l.index>0&&(l.max=-1)),A&&_&&f&&(p=1);var C=["-p:",a,m,c.index,c.max,l.index,l.max].join("+"),S={fragment:Kr,vertex:"#define LOOKUP_TEXTURE_CURVE "+p+"\n"+Qr,shared:!0,cacheId:C,macros:o,name:"particle#"+t.name};return o.push(["VERT_CURVE_VALUE_COUNT",c.index],["FRAG_CURVE_VALUE_COUNT",l.index],["VERT_MAX_KEY_FRAME_COUNT",c.max],["FRAG_MAX_KEY_FRAME_COUNT",l.max]),{shader:S,vertex:c.index,fragment:l.index}}function Uo(t,e,i){var r,n=null==(r=t.cacheId)?void 0:r.split("+");if(n[3]=e,n[5]=i,t.cacheId=n.join("+"),t.macros)for(var s=0;s<t.macros.length;s++){var a=t.macros[s];if("VERT_CURVE_VALUE_COUNT"===a[0])a[1]=e;else if("FRAG_CURVE_VALUE_COUNT"===a[0]){a[1]=i;break}}}var Bo=function(t){function e(e,i,r){var n;(n=t.call(this,e)||this).name="ParticleSystemRenderer",i&&(n.particleMesh=new No(e,i)),r&&(n.trailMesh=new Oo(e,r));var s=[n.particleMesh.mesh];return n.materials.push(n.particleMesh.mesh.material),n.trailMesh&&(s.push(n.trailMesh.mesh),n.materials.push(n.trailMesh.mesh.material)),n.meshes=s,n}Qt(e,t);var i=e.prototype;return i.onStart=function(){this._priority=this.item.renderOrder,this.particleMesh.gravityModifier.scaleXCoord(this.item.duration);for(var t,e=w(this.meshes);!(t=e()).done;){t.value.onStart()}},i.onUpdate=function(t){var e,i=this.particleMesh.time,r=null!=(e=this.particleMesh.mesh.material.getVector4("uParams"))?e:new Je;this.particleMesh.mesh.material.setVector4("uParams",r.set(i,this.item.duration,0,0))},i.render=function(t){this.maskManager.drawStencilMask(t);for(var e,i=w(this.meshes);!(e=i()).done;){e.value.render(t)}},i.reset=function(){var t;this.particleMesh.clearPoints(),null==(t=this.trailMesh)||t.clearAllTrails()},i.updateTime=function(t,e){this.particleMesh.time=t,this.particleMesh.onUpdate(e),this.trailMesh&&(this.trailMesh.time=t,this.trailMesh.onUpdate(e))},i.minusTimeForLoop=function(t){var e;this.particleMesh.minusTime(t),null==(e=this.trailMesh)||e.minusTime(t)},i.updateWorldMatrix=function(t){this.particleMesh.mesh.worldMatrix=t,this.trailMesh&&(this.trailMesh.mesh.worldMatrix=t)},i.setVisible=function(t){var e;this.particleMesh.mesh.setVisible(t),null==(e=this.trailMesh)||e.mesh.setVisible(t)},i.getTextures=function(){var t=[],e=this.particleMesh.mesh.material.textures;if(Object.keys(e).forEach((function(i){t.push(e[i])})),this.trailMesh){var i=this.trailMesh.mesh.material.textures;Object.keys(i).forEach((function(e){t.push(i[e])}))}return t},i.setParticlePoint=function(t,e){this.particleMesh.setPoint(t,e)},i.removeParticlePoint=function(t){this.particleMesh.removePoint(t)},i.getParticlePointColor=function(t){return this.particleMesh.getPointColor(t)},i.hasTrail=function(){return void 0!==this.trailMesh},i.clearTrail=function(t){var e;null==(e=this.trailMesh)||e.clearTrail(t)},i.addTrailPoint=function(t,e,i){var r;null==(r=this.trailMesh)||r.addPoint(t,e,i)},i.setTrailStartPosition=function(t,e){var i;null==(i=this.trailMesh)||i.setPointStartPos(t,e)},i.getTrailStartPosition=function(t){return this.trailMesh.getPointStartPos(t)},e}(Ge),Go=function(t){function e(e,i){var r;return(r=t.call(this,e)||this).destroyed=!1,r.getHitTestParams=function(t){var e=r.interaction;if(t||e)return{type:ks.custom,collect:function(t){return r.raycast({radius:(null==e?void 0:e.radius)||.4,multiple:!!(null==e?void 0:e.multiple),removeParticle:(null==e?void 0:e.behavior)===ie.removeParticle,ray:t})}}},r.maskManager=new lr(e),i&&r.fromData(i),r}Qt(e,t);var i=e.prototype;return i.isFrozen=function(){return this.frozen},i.isEnded=function(){return this.ended},i.initEmitterTransform=function(){var t,e=this.item.transform.position.clone(),i=this.item.transform.rotation.clone(),r=this.props.emitterTransform&&this.props.emitterTransform.path;r&&(r[0]===$t.CONSTANT_VEC3?e.add(r[1]):t=Ka(r)),this.basicTransform={position:e,rotation:i,path:t};var n=e.clone();if(t&&n.add(t.getValue(0)),this.transform.setPosition(n.x,n.y,n.z),this.options.particleFollowParent){var s=this.transform.getWorldMatrix();this.renderer.updateWorldMatrix(s)}},i.updateEmitterTransform=function(t){var e=this.basicTransform,i=e.path,r=e.position.clone();if(i){var n=this.item.duration;r.add(i.getValue(t/n))}if(this.transform.setPosition(r.x,r.y,r.z),this.options.particleFollowParent){var s=this.transform.getWorldMatrix();this.renderer.updateWorldMatrix(s)}},i.addParticle=function(t,e){var i,r=this.particleLink,n=[t.delay+t.lifetime,0,t.delay,t];if(r.length<e)i=n[1]=r.length;else{var s=r.first;r.removeNode(s),i=n[1]=s.content[1]}r.pushNode(n),this.renderer.setParticlePoint(i,t),this.clearPointTrail(i),this.transform.parentTransform&&this.renderer.setTrailStartPosition(i,this.transform.parentTransform.position.clone())},i.setVisible=function(t){this.renderer.setVisible(t)},i.setOpacity=function(t){var e,i=this.renderer.particleMesh.mesh.material,r=this.renderer.particleMesh.mesh.geometry,n=(null==(e=i.getVector4("uOpacityOverLifetimeValue"))?void 0:e.toArray())||[1,1,1,1];i.setVector4("uOpacityOverLifetimeValue",new Je(n[0],n[1],n[2],t));for(var s=r.getAttributeData("aColor")||[],a=0;a<s.length;a+=32)s[8*a+7]=t},i.setColor=function(t,e,i,r){var n,s=this.renderer.particleMesh.mesh.material,a=this.renderer.particleMesh.mesh.geometry,o=(null==(n=s.getVector4("uOpacityOverLifetimeValue"))?void 0:n.toArray())||[1,1,1,1];s.setVector4("uOpacityOverLifetimeValue",new Je(o[0],o[1],o[2],r));for(var u=a.getAttributeData("aColor")||[],h=0;h<u.length;h+=32)u[8*h+4]=t,u[8*h+5]=e,u[8*h+6]=i,u[8*h+7]=r},i.setParentTransform=function(t){},i.getTextures=function(){return this.renderer.getTextures()},i.startEmit=function(){this.started&&!this.ended||(this.reset(),this.started=!0,this.ended=!1)},i.stop=function(){this.ended=!0,this.started=!1},i.reset=function(){this.renderer.reset(),this.lastUpdate=0,this.loopStartTime=0,this.lastEmitTime=-1/this.emission.rateOverTime.getValue(0),this.generatedCount=0,this.particleLink=new go((function(t,e){return t[0]-e[0]})),this.emission.bursts.forEach((function(t){return t.reset()})),this.frozen=!1,this.ended=!1,this.destroyed=!1},i.update=function(t){var e=this;if(this.started&&!this.frozen){var i=this.lastUpdate+t/1e3,r=this.options,n=this.loopStartTime,s=this.emission;this.lastUpdate=i,this.upDirectionWorld=null,this.renderer.updateTime(i,t);var a=this.particleLink,o=(i-n)/this.item.duration,u=this.timePassed,h=!1,c=function(){e.trails&&!h&&(h=!0,a.forEach((function(t){var i=t[0],r=t[1],n=t[2],s=t[3];i<u?e.clearPointTrail(r):u>n&&e.updatePointTrail(r,o,s,n)})))};if(this.ended){if(this.item.endBehavior!==ee.restart&&ee.destroy===this.item.endBehavior){var l=a.last;l&&l.content[0]<this.lastUpdate&&(this.destroyed=!0)}}else{var f=this.item.duration,d=this.lifetime;if(u<f){var p=1/s.rateOverTime.getValue(d),m=Math.floor((u-this.lastEmitTime)/p),v=m,y=p/m,g=i,x=r.maxCount;this.updateEmitterTransform(u);for(var b=function(){var t=a.first;return e.emissionStopped||a.length===x&&t&&t.content[0]-n>u},T=0;T<v&&T<x&&!b();T++){var E=this.createPoint(d);E.delay+=g+T*y,this.addParticle(E,x),this.lastEmitTime=u}for(var _=s.bursts,w=(null==_?void 0:_.length)-1,A=0;w>=0&&A<x&&!b();w--){var C=_[w],S=!C.disabled&&C.getGeneratorOptions(u,d);if(S){var O=s.burstOffsets[w],R=O&&O[S.cycleIndex]||[0,0,0];C.once&&this.removeBurst(w);for(var M=0;M<S.count&&A<x;M++){var I;if(b())break;var P=this.initPoint(this.shape.generate({total:S.total,index:S.index,burstIndex:M,burstCount:S.count}));P.delay+=g,A++,(I=P.transform).translate.apply(I,[].concat(R)),this.addParticle(P,x)}}}}else if(this.item.endBehavior===ee.restart)c(),this.loopStartTime=i-f,this.lastEmitTime-=f,this.lastUpdate-=f,s.bursts.forEach((function(t){return t.reset()})),this.particleLink.forEach((function(t){t[0]-=f,t[2]-=f,t[3].delay-=f})),this.renderer.minusTimeForLoop(f);else{this.ended=!0,this.item.endBehavior===ee.freeze&&(this.frozen=!0)}}c()}},i.drawStencilMask=function(t){if(this.isActiveAndEnabled){for(var e=[],i=0;i<this.renderer.meshes.length;i++){var r=this.renderer.meshes[i].material;e.push(r.colorMask),r.colorMask=!1}for(var n,s=w(this.renderer.meshes);!(n=s()).done;){n.value.render(t)}for(var a=0;a<this.renderer.meshes.length;a++){this.renderer.meshes[a].material.colorMask=e[a]}}},i.onDestroy=function(){this.item&&this.item.composition&&this.meshes.forEach((function(t){return t.dispose({material:{textures:pt.keep}})}))},i.getParticleBoxes=function(){var t=this.particleLink,e=this.renderer,i=[],r=this.particleCount,n=0;if(!t||!e)return i;for(var s=t.last,a=!1;!a;){var o=s.content[0],u=s.content[3];if(o>this.timePassed){var h=this.getPointPosition(u);i.push({center:h,size:u.transform.scale}),s.pre?s=s.pre:a=!0}++n>r&&(a=!0)}return i},i.raycast=function(t){var e=this.particleLink,i=this.renderer;if(e&&i){var r=e.last,n=[],s=new Qe,a=!1;if(r&&r.content)do{var o=r.content,u=o[0],h=o[1];o[2];var c=o[3];if(u>this.timePassed){var l=this.getPointPosition(c),f=t.ray,d=!1;f&&(d=!!f.intersectSphere({center:l,radius:t.radius},s)),d&&(t.removeParticle&&(i.removeParticlePoint(h),this.clearPointTrail(h),r.content=[0]),n.push(l),t.multiple||(a=!0))}}while((r=r.pre)&&!a);return n}},i.clearPointTrail=function(t){this.trails&&this.trails.dieWithParticles&&this.renderer.clearTrail(t)},i.updatePointTrail=function(t,e,i,r){var n=this.renderer;if(n.hasTrail()){var s=this.trails,a=this.getPointPosition(i),o=s.inheritParticleColor?n.getParticlePointColor(t):[1,1,1,1],u=i.transform.getWorldScale().toArray(),h=1,c=s.lifetime.getValue(e);if(s.sizeAffectsWidth&&(h*=u[0]),s.sizeAffectsLifetime&&(c*=u[0]),s.parentAffectsPosition&&this.transform.parentTransform){a.add(this.transform.parentTransform.position);var l=n.getTrailStartPosition(t);l&&a.subtract(l)}n.addTrailPoint(t,a,{color:o,lifetime:c,size:h,time:r})}},i.getPointPositionByIndex=function(t){var e=this.particleLink.getNodeByIndex(t);return e?this.getPointPosition(e.content[3]):(console.error("Get point error."),null)},i.getPointPosition=function(t){var e=t.transform,i=t.vel,r=t.lifetime,n=t.delay,s=t.gravity,a=void 0===s?[]:s,o=this.options.forceTarget,u=this.lastUpdate-n,h=new Qe,c=Qe.fromArray(a);e.assignWorldTRS(h);var l=ea(new Qe,this.options,c,u,r,h,i);if(o){var f=o.target||[0,0,0],d=o.curve.getValue(u/r),p=1-d;l.x=l.x*p+f[0]*d,l.y=l.y*p+f[1]*d,l.z=l.z*p+f[2]*d}return l},i.initPoint=function(t){var e=this.options,i=this.lifetime,r=this.shape,n=e.startSpeed.getValue(i),s=e.particleFollowParent?ni.IDENTITY:this.transform.getWorldMatrix(),a=t.position,o=s.transformPoint(a,new Qe),u=new fo({position:o,valid:!0}),h=t.direction;if(h=s.transformNormal(h,jo).normalize(),e.startTurbulence&&e.turbulence){for(var c=0;c<3;c++)Zo.setElement(c,e.turbulence[c].getValue(i));qo.setFromVector3(Zo.negate()),Qo.setFromEuler(qo).transformNormal(h).normalize()}var l,f=Yo,d=Wo;r.alignSpeedDirection?(d.copyFrom(h),this.upDirectionWorld||(r.upDirection?this.upDirectionWorld=r.upDirection.clone():this.upDirectionWorld=Qe.Z.clone(),s.transformNormal(this.upDirectionWorld)),f.crossVectors(d,this.upDirectionWorld).normalize(),f.isZero()&&f.set(1,0,0)):(f.set(1,0,0),d.set(0,1,0));var p=this.textureSheetAnimation;p&&p.animate&&((l=Ko)[0]=p.animationDelay.getValue(i),l[1]=p.animationDuration.getValue(i),l[2]=p.cycles.getValue(i));var m=Ho;e.start3DRotation?m.set(e.startRotationX.getValue(i),e.startRotationY.getValue(i),e.startRotationZ.getValue(i)):e.startRotation?m.set(0,0,e.startRotation.getValue(i)):m.set(0,0,0),u.setRotation(m.x,m.y,m.z);var v=e.startColor.getValue(i);3===v.length&&(v[3]=1);var y=Xo;if(e.start3DSize)y.x=e.startSizeX.getValue(i),y.y=e.startSizeY.getValue(i);else{var g=e.startSize.getValue(i),x=e.sizeAspect.getValue(i);y.x=g,y.y=0===x?0:g/x}var b=h.clone();if(b.multiply(n),!e.particleFollowParent){var T=new Qe;this.transform.assignWorldTRS(void 0,void 0,T),y.x*=T.x,y.y*=T.y}return u.setScale(y.x,y.y,1),{size:y,vel:b,color:v,delay:e.startDelay.getValue(i),lifetime:e.startLifetime.getValue(i),uv:$o(this.uvs,!0),gravity:e.gravity,sprite:l,dirY:d,dirX:f,transform:u}},i.addBurst=function(t,e){var i=!1;if(this.emission.bursts.includes(t)||(this.emission.bursts.push(t),i=!0),i&&A(e,Array)){var r=this.emission.bursts.indexOf(t);return this.emission.burstOffsets[r]=e,r}return-1},i.removeBurst=function(t){t<this.emission.bursts.length&&(this.emission.burstOffsets[t]=null,this.emission.bursts.splice(t,1))},i.createPoint=function(t){var e={total:this.emission.rateOverTime.getValue(t),index:this.generatedCount,burstIndex:0,burstCount:0};return this.generatedCount++,this.initPoint(this.shape.generate(e))},i.stopParticleEmission=function(){this.emissionStopped=!0},i.resumeParticleEmission=function(){this.emissionStopped=!1},i.getBoundingBox=function(){var t=this.getParticleBoxes();return{type:ks.sphere,area:t}},i.fromData=function(e){t.prototype.fromData.call(this,e);var i=e;this.props=i,this.destroyed=!1;var r,n,s,a,o,u=i.options,h=i.positionOverLifetime,c=void 0===h?{}:h,l=i.shape,f=null==c?void 0:c.gravityOverLifetime,d=ia(null==c?void 0:c.gravity),p=i.textureSheetAnimation,m=p?{animationDelay:Ka(p.animationDelay||0),animationDuration:Ka(p.animationDuration||1),cycles:Ka(p.cycles||1),animate:p.animate,col:p.col,row:p.row,total:p.total||p.col*p.row}:void 0,v=!!(l&&l.turbulenceX||(null==l?void 0:l.turbulenceY)||(null==l?void 0:l.turbulenceZ));v&&(r=[Ka(null!=(n=l.turbulenceX)?n:0),Ka(null!=(s=l.turbulenceY)?s:0),Ka(null!=(a=l.turbulenceZ)?a:0)]);this.name="ParticleSystem",this.shape=Wn(l),this.emission={rateOverTime:Ka(i.emission.rateOverTime),burstOffsets:Jo(null!=(o=i.emission.burstOffsets)?o:[]),bursts:(i.emission.bursts||[]).map((function(t){return new vo(t)}))},this.textureSheetAnimation=m;var y,g,x=i.renderer||{},b=i.rotationOverLifetime;b&&((y={}).asRotation=!!b.asRotation,y.z=b.z?Ka(b.z):Ka(0),b.separateAxes&&(y.x=b.x&&Ka(b.x),y.y=b.y&&Ka(b.y))),(null==c?void 0:c.forceTarget)&&(g={target:c.target||[0,0,0],curve:Ka(c.forceCurve||[$t.LINE,[[0,0],[1,1]]])});var T={x:c.linearX&&Ka(c.linearX||0),y:c.linearY&&Ka(c.linearY||0),z:c.linearZ&&Ka(c.linearZ||0),asMovement:c.asMovement},E={x:c.orbitalX&&Ka(c.orbitalX),y:c.orbitalY&&Ka(c.orbitalY),z:c.orbitalZ&&Ka(c.orbitalZ),center:c.orbCenter,asRotation:c.asRotation},_=i.sizeOverLifetime||{},w=i.colorOverLifetime,C=(null==_?void 0:_.separateAxes)?{separateAxes:!0,x:Ka(_.x),y:Ka(_.y)}:{separateAxes:!1,x:Ka(("size"in _?_.size:_.x)||1)};x.anchor=x.anchor||[0,0];var S,O=Ke.fromArray(x.anchor);this.options={particleFollowParent:!!u.particleFollowParent,startLifetime:Ka(u.startLifetime),startDelay:Ka(u.startDelay||0),startSpeed:Ka(c.startSpeed||0),startColor:Ka(u.startColor),looping:!1,maxCount:null!=(S=u.maxCount)?S:0,gravityModifier:Ka(f||0),gravity:d,start3DSize:!!u.start3DSize,startTurbulence:v,turbulence:r,speedOverLifetime:c.speedOverLifetime&&Ka(c.speedOverLifetime),linearVelOverLifetime:T,orbitalVelOverLifetime:E,forceTarget:g},u.startRotationZ&&(this.options.startRotation=Ka(u.startRotationZ||0)),(u.startRotationX||u.startRotationY)&&(this.options.start3DRotation=!0,this.options.startRotationX=Ka(u.startRotationX||0),this.options.startRotationY=Ka(u.startRotationY||0),this.options.startRotationZ=Ka(u.startRotationZ||0)),u.start3DSize?(this.options.startSizeX=Ka(u.startSizeX),this.options.startSizeY=Ka(u.startSizeY)):(this.options.startSize=Ka(u.startSize),this.options.sizeAspect=Ka(u.sizeAspect||1));var R=this.getMaskOptions(i),M={meshSlots:u.meshSlots,name:this.name,matrix:ni.IDENTITY,shaderCachePrefix:"",renderMode:x.renderMode||Ht.BILLBOARD,side:x.side||kt.DOUBLE,gravity:d,blending:x.blending||Dt.ALPHA,rotationOverLifetime:y,gravityModifier:this.options.gravityModifier,linearVelOverLifetime:this.options.linearVelOverLifetime,orbitalVelOverLifetime:this.options.orbitalVelOverLifetime,speedOverLifetime:this.options.speedOverLifetime,sprite:m,occlusion:!!x.occlusion,transparentOcclusion:!!x.transparentOcclusion,maxCount:u.maxCount,mask:R.maskRef,maskMode:R.maskMode,forceTarget:g,diffuse:x.texture?this.engine.findObject(x.texture):void 0,sizeOverLifetime:C,anchor:O};if(w){var I=w.color,P=w.opacity;M.colorOverLifetime={},P&&(M.colorOverLifetime.opacity=Ka(w.opacity)),I&&(I[0]===$t.GRADIENT_COLOR?M.colorOverLifetime.color=w.color[1]:I[0]===$t.RGBA_COLOR?M.colorOverLifetime.color=Yi.createWithData(this.engine,{data:new Uint8Array(I[1]),width:1,height:1}):A(I,Yi)&&(M.colorOverLifetime.color=I))}var L,F=[],V=[0,0,1,1];if(i.splits){var N=i.splits[0];V=(L=N[4])?[N[0],N[1],N[3],N[2]]:[N[0],N[1],N[2],N[3]]}if(m&&!m.animate)for(var D=L?m.row:m.col,k=L?m.col:m.row,z=m.total||D*k,U=0,B=0;B<D;B++)for(var G=0;G<k&&U<z;G++,U++)F.push([B*V[2]/D+V[0],G*V[3]/k+V[1],V[2]/D,V[3]/k]);else F.push(V);this.uvs=F,M.textureFlip=L;var j,X=i.trails;X&&(this.trails={lifetime:Ka(X.lifetime),dieWithParticles:!1!==X.dieWithParticles,sizeAffectsWidth:!!X.sizeAffectsWidth,sizeAffectsLifetime:!!X.sizeAffectsLifetime,inheritParticleColor:!!X.inheritParticleColor,parentAffectsPosition:!!X.parentAffectsPosition},R=this.getMaskOptions(X),j={name:"Trail",matrix:ni.IDENTITY,minimumVertexDistance:X.minimumVertexDistance||.02,maxTrailCount:u.maxCount,pointCountPerTrail:Math.round(X.maxPointPerTrail)||32,blending:X.blending,texture:X.texture?this.engine.findObject(X.texture):void 0,opacityOverLifetime:Ka(X.opacityOverLifetime||1),widthOverTrail:Ka(X.widthOverTrail||1),shaderCachePrefix:"",lifetime:this.trails.lifetime,occlusion:!!X.occlusion,transparentOcclusion:!!X.transparentOcclusion,textureMap:X.textureMap,mask:R.maskRef,maskMode:R.maskMode},X.colorOverLifetime&&X.colorOverLifetime[0]===$t.GRADIENT_COLOR&&(j.colorOverLifetime=X.colorOverLifetime[1]),X.colorOverTrail&&X.colorOverTrail[0]===$t.GRADIENT_COLOR&&(j.colorOverTrail=X.colorOverTrail[1])),this.renderer=new Bo(this.engine,M,j),this.renderer.item=this.item,this.renderer.maskManager=this.maskManager,this.meshes=this.renderer.meshes;var H,Y=i.interaction;Y&&(this.interaction={multiple:Y.multiple,radius:null!=(H=Y.radius)?H:.4,behavior:Y.behavior});this.item.getHitTestParams=this.getHitTestParams,this.item._content=this},i.getMaskOptions=function(t){var e=ui.NONE,i=0;return t.mask&&(e=this.maskManager.getMaskMode(t.mask),i=this.maskManager.getRefValue()),{maskMode:e,maskRef:i}},Pe(e,[{key:"timePassed",get:function(){return this.lastUpdate-this.loopStartTime}},{key:"lifetime",get:function(){return this.timePassed/this.item.duration}},{key:"particleCount",get:function(){return this.particleLink.length}},{key:"maxParticles",get:function(){return this.options.maxCount},set:function(t){var e;this.options.maxCount=t,(null==(e=this.renderer)?void 0:e.particleMesh)&&(this.renderer.particleMesh.maxCount=t)}}]),e}(Ue);Go=S([Ne(_e.ParticleSystem)],Go);var jo=new Qe,Xo=new Ke,Ho=new Or,Yo=new Qe,Wo=new Qe,Zo=new Qe,qo=new Or,Ko=[0,0,0],Qo=new ni;function Jo(t){var e={};return Array.isArray(t)&&t.forEach((function(t){var i=A(t,Array),r=i?t[0]:t.index,n=e[r];n||(n=e[r]=[]),i?n.push(t.slice(1,4)):n.push([+t.x,+t.y,+t.z])})),e}function $o(t,e){var i=Math.floor(Math.random()*t.length),r=t[i];return e||t.splice(i,1),r}var tu,eu=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).clipPlayables=[],e.clipWeights=[],e}Qt(e,t);var i=e.prototype;return i.processFrame=function(t){for(var e,i=w(this.clipPlayables);!(e=i()).done;){e.value.processFrame(t)}this.evaluate(t)},i.setClipWeight=function(t,e){if(A(t,ao)){for(var i=0;i<this.clipPlayables.length;i++)if(this.clipPlayables[i]===t)return void(this.clipWeights[i]=e)}else this.clipWeights.length<t+1&&(this.clipWeights.length=t+1),this.clipWeights[t]=e},i.getClipWeight=function(t){return this.clipWeights[t]},i.getClipPlayable=function(t){return this.clipPlayables[t]},i.evaluate=function(t){},e}(ao),iu=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.evaluate=function(t){var e=t.output.getUserData();if(A(e,Wu)){for(var i=e,r=!1,n=0;n<this.clipPlayables.length;n++)if(this.getClipWeight(n)>0){r=!0;break}r?(i.transform.setValid(!0),i.setActive(!0)):(i.transform.setValid(!1),i.setActive(!1))}},e}(eu),ru=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.processFrame=function(t){this.value=this.curve.getValue(this.time/this.getDuration())},e}(ao),nu=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).propertyName="",e}return Qt(e,t),e.prototype.evaluate=function(t){var e=t.output.getUserData();if(e){var i=!1;if(this.propertyValue=e[this.propertyName],void 0!==this.propertyValue&&null!==this.propertyValue){this.resetPropertyValue();for(var r=0;r<this.clipPlayables.length;r++){var n=this.getClipWeight(r);if(n>0){var s=this.getClipPlayable(r);if(!A(s,ru)){console.error("PropertyTrack added non-PropertyPlayableAsset");continue}var a=s.value;this.addWeightedValue(a,n),i=!0}}i&&(e[this.propertyName]=this.propertyValue)}}},e}(eu),su=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.resetPropertyValue=function(){this.propertyValue.setZero()},i.addWeightedValue=function(t,e){var i=this.propertyValue;i.r+=t.r*e,i.g+=t.g*e,i.b+=t.b*e,i.a+=t.a*e},e}(nu),au=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.resetPropertyValue=function(){this.propertyValue=0},i.addWeightedValue=function(t,e){this.propertyValue+=t*e},e}(nu),ou=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.evaluate=function(t){},e}(eu),uu=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.evaluate=function(t){},e}(eu),hu=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.processFrame=function(t){var e=t.output.getUserData();A(e,zu)&&(e.time=this.getTime())},e}(ao),cu=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.evaluate=function(t){var e=t.output.getUserData();if(A(e,zu)){for(var i=e,r=!1,n=0;n<this.clipPlayables.length;n++)if(this.getClipWeight(n)>0){r=!0;break}r?i.item.setActive(!0):i.item.setActive(!1)}},e}(eu),lu=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.evaluate=function(t){},e}(eu),fu=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.resetPropertyValue=function(){this.propertyValue.x=0,this.propertyValue.y=0,this.propertyValue.z=0,this.propertyValue.w=0},i.addWeightedValue=function(t,e){var i=this.propertyValue;i.x+=t.x*e,i.y+=t.y*e,i.z+=t.z*e,i.w+=t.w*e},e}(nu),du=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.resetPropertyValue=function(){this.propertyValue.x=0,this.propertyValue.y=0},i.addWeightedValue=function(t,e){var i=this.propertyValue;i.x+=t.x*e,i.y+=t.y*e},e}(nu),pu=function(){function t(){this.start=0,this.duration=0}return t.prototype.toLocalTime=function(t){var e=t-this.start,i=this.duration;return e-i>0&&(this.endBehavior===ee.restart?e%=i:this.endBehavior===ee.freeze&&(e=Math.min(i,e))),e},t}(),mu=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).trackType=0,e.clipSeed=0,e.clips=[],e.children=[],e}Qt(e,t);var i=e.prototype;return i.updateAnimatedObject=function(){this.parent&&(this.boundObject=this.parent.boundObject)},i.createTrackMixer=function(t){return new eu(t)},i.createOutput=function(){return new oo},i.createPlayableGraph=function(t,e){return this.createMixerPlayableGraph(t,e)},i.createMixerPlayableGraph=function(t,e){for(var i,r=[],n=w(this.clips);!(i=n()).done;){var s=i.value;r.push(s)}return this.compileClips(t,r,e)},i.compileClips=function(t,e,i){for(var r,n=this.createTrackMixer(t),s=w(e);!(r=s()).done;){var a=r.value,o=this.createClipPlayable(t,a);o.setDuration(a.duration);var u=new vu(a,o,n,this);i.push(u),n.clipPlayables.push(o),n.setClipWeight(o,0)}return n},i.createPlayable=function(t){return new ao(t)},i.getChildTracks=function(){return this.children},i.addChild=function(t){this.children.push(t),t.parent=this},i.createClip=function(t,e){var i=new pu;return i.asset=new t(this.engine),i.name=e||"TimelineClip"+i.id,this.addClip(i),i},i.getClips=function(){return this.clips},i.findClip=function(t){for(var e,i=w(this.clips);!(e=i()).done;){var r=e.value;if(r.name===t)return r}},i.addClip=function(t){t.id=(this.clipSeed++).toString(),this.clips.push(t)},i.createClipPlayable=function(t,e){return e.asset.createPlayable(t)},i.fromData=function(e){t.prototype.fromData.call(this,e);for(var i,r=w(this.children);!(i=r()).done;){i.value.parent=this}},e}(uo);S([De(pu)],mu.prototype,"clips",void 0),S([De()],mu.prototype,"children",void 0),mu=S([Ne(_e.TrackAsset)],mu),function(t){t[t.MasterTrack=0]="MasterTrack",t[t.ObjectTrack=1]="ObjectTrack"}(tu||(tu={}));var vu=function(){function t(t,e,i,r){this.clip=t,this.playable=e,this.parentMixer=i,this.track=r,A(this.track.boundObject,Wu)&&(this.particleSystem=this.track.boundObject.getComponent(Go))}return t.prototype.evaluateAt=function(t){var e=this.clip,i=1,r=!1,n=!1,s=this.track.boundObject;t>=e.start+e.duration&&e.endBehavior===ee.destroy?A(s,Wu)&&Wu.isParticle(s)&&this.particleSystem&&!this.particleSystem.destroyed?i=1:(i=0,r=!0):t-this.clip.start>=0?(i=1,n=!0):t<e.start&&(i=0),n&&this.playable.getPlayState()!==io.Playing&&this.playable.play(),this.parentMixer.setClipWeight(this.playable,i);var a=e.toLocalTime(t);this.playable.setTime(a),r&&this.playable.getPlayState()===io.Playing&&this.playable.pause()},Pe(t,[{key:"enable",set:function(t){t?this.playable.play():(this.parentMixer.setClipWeight(this.playable,0),this.playable.pause())}}]),t}(),yu=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.createTrackMixer=function(t){return new iu(t)},e}(mu);yu=S([Ne(_e.ActivationTrack)],yu);var gu=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).propertyNames=[],e.path="",e}Qt(e,t);var i=e.prototype;return i.updateAnimatedObject=function(){for(var t=this.propertyNames,e=this.parent.boundObject,i=0;i<t.length-1;i++){var r=e[t[i]];void 0===r&&console.error("The "+t[i]+" property of "+e+" was not found"),e=r}this.boundObject=e},i.fromData=function(e){t.prototype.fromData.call(this,e);var i=this.path.split(".");this.propertyNames=i},e}(mu);S([De()],gu.prototype,"path",void 0);var xu=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.createTrackMixer=function(t){var e=new au(t),i=this.propertyNames;if(i.length>0){var r=i[i.length-1];e.propertyName=r}return e},i.updateAnimatedObject=function(){for(var t=this.propertyNames,e=this.parent.boundObject,i=0;i<t.length-1;i++){var r=e[t[i]];void 0===r&&console.error("The "+t[i]+" property of "+e+" was not found"),e=r}this.boundObject=e},e}(gu);xu=S([Ne(_e.FloatPropertyTrack)],xu);var bu=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.createTrackMixer=function(t){return new uu(t)},e}(mu);bu=S([Ne(_e.SpriteColorTrack)],bu);var Tu=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.updateAnimatedObject=function(){if(!this.parent||!A(this.parent.boundObject,Wu))throw new Error("SubCompositionTrack needs to be set under the VFXItem track.");this.boundObject=this.parent.boundObject.getComponent(zu)},i.createTrackMixer=function(t){return new cu(t)},e}(mu);Tu=S([Ne(_e.SubCompositionTrack)],Tu);var Eu=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.createTrackMixer=function(t){return new lu(t)},e}(mu);Eu=S([Ne(_e.TransformTrack)],Eu);var _u=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.updateAnimatedObject=function(){A(this.parent.boundObject,Ge)&&(this.parent.boundObject,this.boundObject=this.parent.boundObject.materials[this.index])},e}(mu);S([De()],_u.prototype,"index",void 0),_u=S([Ne("MaterialTrack")],_u);var wu=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.createTrackMixer=function(t){return new ou(t)},e}(mu),Au=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.createTrackMixer=function(t){var e=new fu(t),i=this.propertyNames;if(i.length>0){var r=i[i.length-1];e.propertyName=r}return e},e}(gu);Au=S([Ne(_e.Vector4PropertyTrack)],Au);var Cu=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.createTrackMixer=function(t){var e=new du(t),i=this.propertyNames;if(i.length>0){var r=i[i.length-1];e.propertyName=r}return e},e}(gu);Cu=S([Ne("Vector2PropertyTrack")],Cu);var Su=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.createTrackMixer=function(t){var e=new su(t),i=this.propertyNames;if(i.length>0){var r=i[i.length-1];e.propertyName=r}return e},e}(gu);Su=S([Ne(_e.ColorPropertyTrack)],Su);var Ou=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.createPlayable=function(t){var e=new ru(t);return e.curve=Ka(this.curveData),e.value=e.curve.getValue(0),e},e}(uo);S([De()],Ou.prototype,"curveData",void 0),Ou=S([Ne(_e.ColorPropertyPlayableAsset)],Ou);var Ru=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.createPlayable=function(t){var e=new ru(t);return e.curve=Ka(this.curveData),e.value=e.curve.getValue(0),e},e}(uo);S([De()],Ru.prototype,"curveData",void 0),Ru=S([Ne(_e.FloatPropertyPlayableAsset)],Ru);var Mu=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.createPlayable=function(t){return new hu(t)},e}(uo);Mu=S([Ne(_e.SubCompositionPlayableAsset)],Mu);var Iu=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.updateAnimatedObject=function(){},i.create=function(t){if(A(this.boundObject,Wu)){var e=this.boundObject;if(e.getComponent(Go)){var i=t.createTrack(wu,this,"ParticleTrack");i.boundObject=this.boundObject;var r=i.createClip(Fo);r.start=e.start,r.duration=e.duration,r.endBehavior=e.endBehavior}}},e}(mu);Iu=S([Ne(_e.ObjectBindingTrack)],Iu);var Pu=function(){function t(t,e,i){this.children=[],this.trackAsset=t,this.mixer=e,this.output=i}return t.prototype.addChild=function(t){this.children.push(t)},t}(),Lu=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).tracks=[],e.cacheFlattenedTracks=null,e}Qt(e,t);var i=e.prototype;return i.createPlayable=function(t){for(var e,i=new Fu(t),r=w(this.tracks);!(e=r()).done;){var n=e.value;A(n,Iu)&&n.create(this)}return this.sortTracks(this.tracks),i.compileTracks(t,this.flattenedTracks),i},i.createTrack=function(t,e,i){var r=new t(this.engine);return r.name=i||t.name,e.addChild(r),this.invalidate(),r},i.invalidate=function(){this.cacheFlattenedTracks=null},i.addSubTracksRecursive=function(t,e){for(var i,r=w(t.getChildTracks());!(i=r()).done;){var n=i.value;e.push(n)}for(var s,a=w(t.getChildTracks());!(s=a()).done;){var o=s.value;this.addSubTracksRecursive(o,e)}},i.sortTracks=function(t){for(var e=[],i=0;i<t.length;i++)e.push(new Vu(t[i],i));e.sort(Nu),t.length=0;for(var r,n=w(e);!(r=n()).done;){var s=r.value;t.push(s.track)}},i.fromData=function(t){},Pe(e,[{key:"flattenedTracks",get:function(){if(!this.cacheFlattenedTracks){this.cacheFlattenedTracks=[];for(var t,e=w(this.tracks);!(t=e()).done;){var i=t.value;this.cacheFlattenedTracks.push(i),this.addSubTracksRecursive(i,this.cacheFlattenedTracks)}}return this.cacheFlattenedTracks}}]),e}(uo);S([De()],Lu.prototype,"tracks",void 0),Lu=S([Ne(_e.TimelineAsset)],Lu);var Fu=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).clips=[],e.masterTrackInstances=[],e}Qt(e,t);var i=e.prototype;return i.prepareFrame=function(t){},i.evaluate=function(){for(var t,e=this.getTime(),i=w(this.clips);!(t=i()).done;){t.value.evaluateAt(e)}},i.compileTracks=function(t,e){for(var i,r=e,n={},s=w(r);!(i=s()).done;){var a=i.value,o=a.createPlayableGraph(t,this.clips),u=a.createOutput();u.setUserData(a.boundObject),t.addOutput(u),u.setSourcePlayable(o);var h=new Pu(a,o,u);n[a.getInstanceId()]=h,a.parent||this.masterTrackInstances.push(h)}for(var c,l=w(r);!(c=l()).done;)for(var f,d=c.value,p=n[d.getInstanceId()],m=w(d.getChildTracks());!(f=m()).done;){var v=n[f.value.getInstanceId()];p.addChild(v)}},e}(ao),Vu=function(t,e){this.track=t,this.originalIndex=e};function Nu(t,e){var i=t.track.boundObject,r=e.track.boundObject;return A(i,Wu)&&A(r,Wu)?Wu.isAncestor(i,r)?-1:Wu.isAncestor(r,i)?1:t.originalIndex-e.originalIndex:t.originalIndex-e.originalIndex}var Du=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.createPlayable=function(t){var e=new ru(t);return e.curve=Ka(this.curveData),e.value=e.curve.getValue(0),e},e}(uo);S([De()],Du.prototype,"curveData",void 0),Du=S([Ne(_e.Vector4PropertyPlayableAsset)],Du);var ku=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.createPlayable=function(t){var e=new ru(t);return e.curve=Ka(this.curveData),e.value=e.curve.getValue(0),e},e}(uo);S([De()],ku.prototype,"curveData",void 0),ku=S([Ne(_e.Vector2PropertyPlayableAsset)],ku);var zu=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).time=0,e.startTime=0,e.items=[],e.state=io.Playing,e.reusable=!1,e.sceneBindings=[],e.graph=new so,e}Qt(e,t);var i=e.prototype;return i.onStart=function(){var t;this.timelineAsset||(this.timelineAsset=new Lu(this.engine)),this.resolveBindings(),this.timelinePlayable=this.timelineAsset.createPlayable(this.graph),this.item.endBehavior!==ee.destroy&&this.setReusable(!0),null==(t=this.item.composition)||t.refContent.push(this.item)},i.setReusable=function(t){for(var i,r=w(this.timelineAsset.tracks);!(i=r()).done;){var n=i.value.boundObject;if(A(n,Wu)){var s=n.getComponent(e);s&&s.setReusable(t)}}},i.getReusable=function(){return this.reusable},i.pause=function(){this.state=io.Paused},i.resume=function(){this.state=io.Playing},i.onUpdate=function(t){if(this.state!==io.Paused){var e=this.time;this.timelinePlayable.setTime(e),this.resolveBindings(),this.timelinePlayable.evaluate(),this.graph.evaluate(t)}},i.onEnable=function(){for(var t,e=w(this.items);!(t=e()).done;){t.value.setActive(!0)}},i.onDisable=function(){for(var t,e=w(this.items);!(t=e()).done;){t.value.setActive(!1)}},i.onDestroy=function(){this.item.composition&&this.items&&(this.items.forEach((function(t){return t.dispose()})),this.items.length=0)},i.hitTest=function(t,e,i,r,n,s){for(var a,o=function(s){var o=a.items[s];if(o.isActive&&o.transform.getValid()&&!Wu.isComposition(o)&&!c(o)){var l=o.getHitTestParams(n);if(l){var f=!1,d=new Qe;if(l.type===ks.triangle)for(var p=l.triangles,m=l.backfaceCulling,v=0;v<p.length;v++){var y=p[v];if(t.intersectTriangle(y,d,m)){f=!0,u.push(d);break}}else if(l.type===ks.box){var g=l.center,x=l.size,b=g.clone().addScaledVector(x,.5),T=g.clone().addScaledVector(x,-.5);t.intersectBox({min:b,max:T},d)&&(f=!0,u.push(d))}else if(l.type===ks.sphere){var E=l.center,_=l.radius;t.intersectSphere({center:E,radius:_},d)&&(f=!0,u.push(d))}else if(l.type===ks.custom){var w=l.collect(t,new Ke(e,i));w&&w.length>0&&(w.forEach((function(t){u.push(t)})),f=!0)}if(f){var A={compContent:a.item,id:o.id,name:o.name,position:u[u.length-1],parentId:o.parentId,hitPositions:u,behavior:l.behavior};if(o.emit("click",A),r.push(A),h(A))return{v:r}}}}},u=[],h=(null==s?void 0:s.stop)||vt,c=(null==s?void 0:s.skip)||vt,l=(null==s?void 0:s.maxCount)||this.items.length,f=0;f<this.items.length&&r.length<l;f++){var d=(a=this,o(f));if("object"===C(d))return d.v}return r},i.setChildrenRenderOrder=function(t){for(var i,r=w(this.items);!(i=r()).done;){var n=i.value;n.renderOrder=t++;var s=n.getComponent(e);s&&(t=s.setChildrenRenderOrder(t))}return t},i.fromData=function(e){t.prototype.fromData.call(this,e);var i,r=e;this.startTime=null!=(i=r.startTime)?i:0},i.resolveBindings=function(){for(var t,e=w(this.sceneBindings);!(t=e()).done;){var i=t.value;i.key.boundObject=i.value}for(var r,n=w(this.timelineAsset.tracks);!(r=n()).done;){var s=r.value;this.updateTrackAnimatedObject(s)}},i.updateTrackAnimatedObject=function(t){for(var e,i=w(t.getChildTracks());!(e=i()).done;){var r=e.value;r.updateAnimatedObject(),this.updateTrackAnimatedObject(r)}},e}(Ue);S([De()],zu.prototype,"items",void 0),S([De()],zu.prototype,"sceneBindings",void 0),S([De()],zu.prototype,"timelineAsset",void 0),zu=S([Ne("CompositionComponent")],zu);var Uu,Bu=function(){var t=this,e=this;this.listeners={},this.off=function(e,i){t.listeners[e]&&(t.listeners[e]=t.listeners[e].filter((function(t){return t.listener!==i})))},this.on=function(e,i,r){return t.listeners[e]=t.listeners[e]||[],t.listeners[e].push({listener:i,options:r}),function(){return t.off(e,i)}},this.once=function(e,i){t.on(e,i,{once:!0})},this.emit=function(t){for(var i=arguments.length,r=new Array(i>1?i-1:0),n=1;n<i;n++)r[n-1]=arguments[n];var s;null==(s=e.listeners[t])||s.forEach((function(i){var n=i.listener,s=i.options;n.apply(void 0,[].concat(r)),(null==s?void 0:s.once)&&e.off(t,n)}))},this.getListeners=function(e){var i;return(null==(i=t.listeners[e])?void 0:i.map((function(t){return t.listener})))||[]}},Gu=function(){function t(){this.update=new Xu,this.lateUpdate=new Hu}var e=t.prototype;return e.addComponent=function(t){t.onUpdate!==Ue.prototype.onUpdate&&this.update.addComponent(t),t.onLateUpdate!==Ue.prototype.onLateUpdate&&this.lateUpdate.addComponent(t)},e.removeComponent=function(t){t.onUpdate!==Ue.prototype.onUpdate&&this.update.removeComponent(t),t.onLateUpdate!==Ue.prototype.onLateUpdate&&this.lateUpdate.removeComponent(t)},e.clear=function(){this.update.clear(),this.lateUpdate.clear()},t}(),ju=function(){function t(){this.components=[],this.ticks=[]}var e=t.prototype;return e.tick=function(t){this.tickComponents(this.components,t);for(var e=0;e<this.ticks.length;e++)this.ticks[e](t)},e.tickComponents=function(t,e){},e.addComponent=function(t){this.components.includes(t)||this.components.push(t)},e.removeComponent=function(t){var e=this.components.indexOf(t);e>-1&&this.components.splice(e,1)},e.addTick=function(t,e){var i=t.bind(e);this.ticks.includes(i)||this.ticks.push(i)},e.clear=function(){this.components=[]},t}(),Xu=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.tickComponents=function(t,e){for(var i,r=w(t);!(i=r()).done;){i.value.onUpdate(e)}},e}(ju),Hu=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.tickComponents=function(t,e){for(var i,r=w(t);!(i=r()).done;){i.value.onLateUpdate(e)}},e}(ju),Yu=function(t){function e(i,r){var n,s;(n=t.call(this)||this).sceneTicking=new Gu,n.speed=1,n.isEnded=!1,n.loaderData={},n.refContent=[],n.postProcessingEnabled=!1,n.assigned=!1,n.destroyed=!1,n.postLoaders=[],n.paused=!1,n.isEndCalled=!1,n._textures=[];var a,o=i.reusable,u=void 0!==o&&o,h=i.speed,c=void 0===h?1:h,l=i.baseRenderOrder,f=void 0===l?0:l,d=i.renderer,p=i.event,m=i.width,v=i.height,y=i.handleItemMessage;n.renderer=d,n._textures=r.textures,n.postProcessingEnabled=null!=(a=null==(s=r.jsonScene.renderSettings)?void 0:s.postProcessingEnabled)&&a,n.getEngine().renderLevel=r.renderLevel,u&&(n.keepResource=!0,r.consumed=!0);for(var g,x=r.jsonScene.compositions[0],b=w(r.jsonScene.compositions);!(g=b()).done;){var T=g.value;T.id===r.jsonScene.compositionId&&(x=T)}ot(x),n.rootItem=new Wu(n.getEngine()),n.rootItem.name="rootItem",n.rootItem.duration=x.duration,n.rootItem.endBehavior=x.endBehavior,n.rootItem.composition=ho(n);for(var E,_,A,C=w(x.components);!(E=C()).done;){var S=E.value,O=n.getEngine().findObject(S);n.rootItem.components.push(O),O.item=n.rootItem}return n.rootComposition=n.rootItem.getComponent(zu),n.width=m,n.height=v,n.renderOrder=f,n.id=x.id,n.renderer=d,n.event=p,n.statistic={loadStart:null!=(_=r.startTime)?_:0,loadTime:null!=(A=r.totalTime)?A:0,compileTime:0,firstFrameTime:0},n.reusable=u,n.speed=c,n.name=x.name,n.pluginSystem=r.pluginSystem,n.pluginSystem.initializeComposition(ho(n),r),n.camera=new mo(n.name,_i({},null==x?void 0:x.camera,{aspect:m/v})),n.url=r.url,n.assigned=!0,n.interactive=!0,n.handleItemMessage=y,n.createRenderFrame(),n.rendererOptions=null,e.buildItemTree(n.rootItem),n.rootComposition.setChildrenRenderOrder(0),n.pluginSystem.resetComposition(ho(n),n.renderFrame),n}Qt(e,t);var i=e.prototype;return i.getDuration=function(){return this.rootItem.duration},i.restart=function(){this.reset(),this.forwardTime(this.startTime)},i.setIndex=function(t){this.renderOrder=t},i.getIndex=function(){return this.renderOrder},i.setSpeed=function(t){this.speed=t},i.setVisible=function(t){this.rootItem.setVisible(t)},i.getSpeed=function(){return this.speed},i.play=function(){this.isEnded&&this.reusable&&this.restart(),this.rootComposition.isStartCalled?this.gotoAndPlay(this.time-this.startTime):this.gotoAndPlay(0)},i.pause=function(){this.paused=!0},i.getPaused=function(){return this.paused},i.resume=function(){this.paused=!1},i.gotoAndPlay=function(t){this.setTime(t),this.resume()},i.gotoAndStop=function(t){this.setTime(t),this.pause()},i.createRenderFrame=function(){this.renderFrame=new yn({camera:this.camera,renderer:this.renderer,keepColorBuffer:this.keepColorBuffer,globalVolume:this.globalVolume,postProcessingEnabled:this.postProcessingEnabled}),this.renderFrame.cachedTextures=this.textures},i.setTime=function(t){var e=this.speed,i=this.getPaused();i&&this.resume(),this.setSpeed(1),this.forwardTime(t+this.startTime),this.setSpeed(e),i&&this.pause(),this.emit("goto",{time:t})},i.addItem=function(t){this.items.push(t),t.setParent(this.rootItem)},i.forwardTime=function(t){for(var e=1e3*t-1e3*this.time,i=e<0,r=Math.abs(e),n=i?-15:15;r>15;r-=15)this.update(n);this.update(i?-r:r)},i.reset=function(){this.rendererOptions=null,this.isEnded=!1,this.isEndCalled=!1,this.rootComposition.time=0,this.pluginSystem.resetComposition(this,this.renderFrame)},i.prepareRender=function(){var t=this,e=this.renderFrame;this.postLoaders.length=0,this.pluginSystem.plugins.forEach((function(i){i.prepareRenderFrame(t,e)&&t.postLoaders.push(i)})),this.postLoaders.forEach((function(i){return i.postProcessFrame(t,e)}))},i.update=function(t){if(this.assigned&&!this.getPaused()){this.rootItem.isDuringPlay||(this.callAwake(this.rootItem),this.rootItem.beginPlay());var e=this.time;this.updateCompositionTime(t*this.speed/1e3);var i=1e3*(this.time-e);this.updatePluginLoaders(i),this.sceneTicking.update.tick(i),this.sceneTicking.lateUpdate.tick(i),this.updateCamera(),this.prepareRender(),this.isEnded&&!this.isEndCalled&&(this.isEndCalled=!0,this.emit("end",{composition:this})),this.shouldDispose()&&this.dispose()}},i.shouldDispose=function(){return this.isEnded&&this.rootItem.endBehavior===ee.destroy&&!this.reusable},i.callAwake=function(t){for(var e,i=w(t.components);!(e=i()).done;){var r=e.value;r.isAwakeCalled||(r.onAwake(),r.isAwakeCalled=!0)}for(var n,s=w(t.children);!(n=s()).done;){var a=n.value;this.callAwake(a)}},i.updateCamera=function(){this.camera.updateMatrix()},i.updatePluginLoaders=function(t){var e=this;this.pluginSystem.plugins.forEach((function(i){return i.onCompositionUpdate(e,t)}))},i.updateCompositionTime=function(t){if(this.rootComposition.state!==io.Paused&&this.rootComposition.isActiveAndEnabled){var e=this.time+t-this.startTime;t<0&&e<0&&(e=0);var i=this.rootItem.duration,r=this.rootItem.endBehavior,n=!1;if(e-i>.001)switch(n=!0,r){case ee.restart:e%=i,this.restart();break;case ee.freeze:e=Math.min(i,e);case ee.forward:case ee.destroy:}this.rootComposition.time=e+this.startTime,this.isEnded!==n&&(n?this.isEnded=!0:(this.isEnded=!1,this.isEndCalled=!1))}},i.getItemByName=function(t){return this.rootItem.find(t)},i.getHitTestRay=function(t,e){var i=this.renderFrame.editorTransform,r=i.x,n=i.y;return oa((t-i.z)/r,(e-i.w)/n,this.camera)},i.getEngine=function(){var t;return null==(t=this.renderer)?void 0:t.engine},i.hitTest=function(t,e,i,r){if(this.isDestroyed||!this.interactive)return[];var n=[],s=this.getHitTestRay(t,e);return this.refContent.forEach((function(a){var o;null==(o=a.getComponent(zu))||o.hitTest(s,t,e,n,i,r)})),n},i.addInteractiveItem=function(t,e){if(e===Gt.MESSAGE)return this.handleItemMessage({name:t.name,phrase:2,id:t.id,compositionId:this.id}),t.emit("message",{name:t.name,phrase:2,id:t.id}),t.id},i.removeInteractiveItem=function(t,e){e===Gt.MESSAGE&&(this.handleItemMessage({name:t.name,phrase:1,id:t.id,compositionId:this.id}),t.emit("message",{name:t.name,phrase:1,id:t.id}))},i.destroyItem=function(t){var e=this;t.type==Xt.composition?t.endBehavior!==ee.freeze&&t.getComponent(zu).items.forEach((function(t){return e.pluginSystem.plugins.forEach((function(i){return i.onCompositionItemRemoved(e,t)}))})):(k(this.items,t),this.pluginSystem.plugins.forEach((function(i){return i.onCompositionItemRemoved(e,t)})))},i.lost=function(t){this.videoState=this.textures.map((function(t){if("video"in t.source)return t.source.video.pause(),t.source.video.currentTime})),this.textures.map((function(t){return t.dispose()})),this.dispose()},i.dispose=function(){var t,e,i=this;if(!this.destroyed){this.destroyed=!0;var r={},n=this.textures;n&&this.keepResource&&n.forEach((function(t){(null==t?void 0:t.dispose)&&(r[t.id]=t.dispose,t.dispose=vt)})),this.rootItem.dispose(),this.renderFrame.dispose(),null==(t=this.rendererOptions)||t.emptyTexture.dispose(),null==(e=this.pluginSystem)||e.destroyComposition(this),this.update=function(){mt.error("Update disposed composition: "+i.name+".")},this.dispose=vt,n&&this.keepResource&&n.forEach((function(t){t.dispose=r[t.id],t.dispose()})),this.renderer.env!==As&&this.renderer.clear({stencilAction:hi.clear,clearStencil:0,depthAction:hi.clear,clearDepth:1,colorAction:hi.clear,clearColor:[0,0,0,0]})}},i.setEditorTransform=function(t,e,i){this.renderFrame.editorTransform.set(t,t,e,i)},i.translateByPixel=function(t,e){this.renderer?this.rootItem.translateByPixel(t,e):console.warn("Renderer not assigned. Operation aborted.")},i.setPositionByPixel=function(t,e){this.renderer?this.rootItem.setPositionByPixel(t,e):console.warn("Renderer not assigned. Operation aborted.")},i.translate=function(t,e,i){this.rootItem.translate(t,e,i)},i.setPosition=function(t,e,i){this.rootItem.setPosition(t,e,i)},i.rotate=function(t,e,i){this.rootItem.rotate(t,e,i)},i.setRotation=function(t,e,i){this.rootItem.setRotation(t,e,i)},i.scale=function(t,e,i){this.rootItem.scale(t,e,i)},i.setScale=function(t,e,i){this.rootItem.setScale(t,e,i)},i.offloadTexture=function(){this.textureOffloaded||(this.textures.forEach((function(t){return t&&t.offloadData()})),this.textureOffloaded=!0)},i.getRendererOptions=function(){return this.rendererOptions||(this.rendererOptions={emptyTexture:this.renderFrame.emptyTexture,cachePrefix:"-"}),this.rendererOptions},i.reloadTexture=function(){var t=this;return E((function(){return O(this,(function(e){switch(e.label){case 0:return t.textureOffloaded?[4,Promise.all(t.textures.map((function(t){return null==t?void 0:t.reloadData()})))]:[3,2];case 1:e.sent(),t.textureOffloaded=!1,e.label=2;case 2:return[2]}}))}))()},e.buildItemTree=function(t){for(var e,i=new Map,r=t.getComponent(zu).items,n=w(r);!(e=n()).done;){var s=e.value;i.set(s.id,s)}for(var a,o=w(r);!(a=o()).done;){var u=a.value;if(void 0===u.parentId)u.setParent(t);else{var h=i.get(u.parentId);if(!h)throw new Error("The element references a non-existent element, please check the data.");u.setParent(h)}}},Pe(e,[{key:"transform",get:function(){return this.rootItem.transform}},{key:"textures",get:function(){return this._textures}},{key:"items",get:function(){return this.rootComposition.items}},{key:"startTime",get:function(){return this.rootComposition.startTime}},{key:"time",get:function(){return this.rootComposition.time}},{key:"isDestroyed",get:function(){return this.destroyed}},{key:"viewportMatrix",get:function(){return this.camera.getViewportMatrix()},set:function(t){this.camera.setViewportMatrix(t)}}]),e}(Bu),Wu=function(t){function e(e,i){var r;return(r=t.call(this,e)||this).children=[],r.transform=new fo,r.time=-1,r.duration=0,r.start=0,r.endBehavior=ee.forward,r.type=Xt.base,r.components=[],r.isDuringPlay=!1,r.active=!0,r.visible=!0,r.speed=1,r.listIndex=0,r.isEnabled=!1,r.eventProcessor=new Bu,r.name="VFXItem",r.transform.name=r.name,r.transform.engine=e,i&&r.fromData(i),r}Qt(e,t);var i=e.prototype;return i.on=function(t,e,i){this.eventProcessor.on(t,e,i)},i.off=function(t,e){this.eventProcessor.off(t,e)},i.once=function(t,e){this.eventProcessor.once(t,e)},i.emit=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;r<e;r++)i[r-1]=arguments[r];var n;(n=this.eventProcessor).emit.apply(n,[].concat([t],i))},i.getListeners=function(t){return this.eventProcessor.getListeners(t)},i.setSpeed=function(t){this.speed=t},i.getSpeed=function(){return this.speed},i.addComponent=function(t){var e=new t(this.engine);return this.components.push(e),e.setVFXItem(this),e},i.getComponent=function(t){for(var e,i,r=w(this.components);!(i=r()).done;){var n=i.value;if(A(n,t)){e=n;break}}return e},i.getComponents=function(t){for(var e,i=[],r=w(this.components);!(e=r()).done;){var n=e.value;A(n,t)&&i.push(n)}return i},i.setParent=function(t){(t!==this||t)&&(this.parent&&k(this.parent.children,this),this.parent=t,this.transform.parentTransform=t.transform,t.children.push(this),!this.composition&&t.composition&&(this.composition=t.composition),!this.isDuringPlay&&t.isDuringPlay&&this.beginPlay())},i.setColor=function(t,e,i,r){},i.setOpacity=function(t){},i.setActive=function(t){this.active!==t&&(this.active=!!t,this.onActiveChanged())},i.setVisible=function(t){for(var e,i=w(this.components);!(e=i()).done;){e.value.enabled=t}this.visible=t},i.getVisible=function(){return this.visible},i.getWorldTransform=function(t){var e=null!=t?t:new fo({valid:!0});return e.cloneFromMatrix(this.transform.getWorldMatrix()),e},i.translate=function(t,e,i){this.transform.translate(t,e,i)},i.rotate=function(t,e,i){var r=new Or(t,e,i),n=ri.fromEuler(r);n.conjugate(),this.transform.rotateByQuat(n)},i.scale=function(t,e,i){this.transform.scaleBy(t,e,i)},i.setPositionByPixel=function(t,e){if(this.composition){var i=this.transform.getWorldPosition().z,r=this.composition.camera.getInverseVPRatio(i),n=r.x,s=r.y,a=this.composition.renderer.getWidth()/2,o=this.composition.renderer.getHeight()/2;this.transform.setPosition((2*t/a-1)*n,(1-2*e/o)*s,i)}},i.setPosition=function(t,e,i){this.transform.setPosition(t,e,i)},i.setRotation=function(t,e,i){this.transform.setRotation(t,e,i)},i.setScale=function(t,e,i){this.transform.setScale(t,e,i)},i.getBoundingBox=function(){},i.getHitTestParams=function(t){},i.getCurrentPosition=function(){var t=new Qe;return this.transform.assignWorldTRS(t),t},i.find=function(t){var e;if(this.name===t)return this;var i=[];(e=i).push.apply(e,[].concat(this.children));for(var r=0;r<i.length;){var n,s=i[r];if(r++,s.name===t)return s;(n=i).push.apply(n,[].concat(s.children))}},i.duplicate=function(){var t=new Map;this.gatherPreviousObjectID(t),this.resetGUID();var e=this.engine.findObject({id:this.defination.id});return e.resetGUID(),this.resetGUID(t),this.composition&&e.setParent(this.composition.rootItem),e},i.beginPlay=function(){this.isDuringPlay=!0,this.composition&&this.active&&!this.isEnabled&&this.onEnable();for(var t,e=w(this.children);!(t=e()).done;){var i=t.value;i.isDuringPlay||i.beginPlay()}},i.onActiveChanged=function(){this.isEnabled?this.onDisable():this.onEnable()},i.onEnable=function(){this.isEnabled=!0;for(var t,e=w(this.components);!(t=e()).done;){var i=t.value;i.enabled&&!i.isStartCalled&&(i.onStart(),i.isStartCalled=!0)}for(var r,n=w(this.components);!(r=n()).done;){var s=r.value;s.enabled&&!s.isEnableCalled&&s.enable()}},i.onDisable=function(){this.isEnabled=!1;for(var t,e=w(this.components);!(t=e()).done;){var i=t.value;i.enabled&&i.isEnableCalled&&i.disable()}},i.fromData=function(i){t.prototype.fromData.call(this,i);var r=i.id,n=i.name,s=i.delay,a=i.parentId,o=i.endBehavior,u=i.transform,h=i.duration,c=void 0===h?0:h;this.props=i,this.type=i.type,this.id=r.toString(),this.name=n,this.start=s||this.start;var l={};if(u){var f;if(l.position=(new Qe).copyFrom(u.position),u.quat)l.quat=new ri(u.quat.x,u.quat.y,u.quat.z,u.quat.w);else l.rotation=(new Or).copyFrom(null!=(f=u.eulerHint)?f:u.rotation);l.scale=(new Qe).copyFrom(u.scale),u.size&&(l.size=(new Ke).copyFrom(u.size)),u.anchor&&(l.anchor=(new Ke).copyFrom(u.anchor)),this.transform.setTransform(l)}if(this.transform.name=this.name,this.transform.engine=this.engine,this.parentId=a,this.duration=c,this.endBehavior=o,i.content||(i.content={options:{}}),c<0)throw new Error("Item duration can't be less than 0, see "+Cs["Item duration can't be less than 0"]+".");if(i.components){this.components.length=0;for(var d,p=w(i.components);!(d=p()).done;){var m=d.value,v=this.engine.findObject(m);this.components.push(v),A(v,Go)&&(this.components.includes(v.renderer)||this.components.push(v.renderer))}}e.isComposition(this)&&this.instantiatePreComposition()},i.toData=function(){var t,e;(this.defination.id=this.guid,this.defination.transform=this.transform.toData(),this.defination.dataType=_e.VFXItemData,"rootItem"!==(null==(t=this.parent)?void 0:t.name))&&(this.defination.parentId=null==(e=this.parent)?void 0:e.guid);if(!this.defination.components){this.defination.components=[];for(var i,r=w(this.components);!(i=r()).done;){var n=i.value;A(n,ti)&&this.defination.components.push(n)}}this.defination.content={}},i.translateByPixel=function(t,e){if(this.composition){var i=this.composition.renderer.canvas.getBoundingClientRect(),r=i.width,n=i.height,s=this.transform.getWorldPosition().z,a=this.composition.camera.getInverseVPRatio(s),o=a.x,u=a.y;this.transform.translate(2*t*o/r,-2*e*u/n,0)}},i.dispose=function(){if(this.resetChildrenParent(),this.composition){this.composition.destroyItem(this);for(var t,e=w(this.components.slice());!(t=e()).done;){t.value.dispose()}this.components=[],this._content=void 0,this._composition=null,this.transform.setValid(!1)}},i.resetChildrenParent=function(){for(var t,e=w(this.children);!(t=e()).done;){var i=t.value;this.parent&&i.setParent(this.parent)}var r;this.parent&&k(null==(r=this.parent)?void 0:r.children,this)},i.instantiatePreComposition=function(){var t=this.props.content.options.refId,e=this.engine.findEffectsObjectData(t);if(!e)throw new Error("Referenced precomposition with Id: "+t+" does not exist.");for(var i,r=w(e.components);!(i=r()).done;){var n=i.value,s=this.engine.findObject(n);if(s.item=this,this.components.push(s),s.setInstanceId(wt()),A(s,zu))for(var a,o=w(s.items);!(a=o()).done;){var u=a.value;u.setInstanceId(wt());for(var h,c=w(u.components);!(h=c()).done;){h.value.setInstanceId(wt())}}}Yu.buildItemTree(this)},i.resetGUID=function(t){var e,i=null!=(e=null==t?void 0:t.get(this))?e:wt();this.setInstanceId(i);for(var r,n=w(this.components);!(r=n()).done;){var s,a=r.value,o=null!=(s=null==t?void 0:t.get(a))?s:wt();a.setInstanceId(o)}for(var u,h=w(this.children);!(u=h()).done;){u.value.resetGUID(t)}},i.gatherPreviousObjectID=function(t){t.set(this,this.getInstanceId());for(var e,i=w(this.components);!(e=i()).done;){var r=e.value;t.set(r,r.getInstanceId())}for(var n,s=w(this.children);!(n=s()).done;){n.value.gatherPreviousObjectID(t)}},e.isComposition=function(t){return t.type===Xt.composition},e.isSprite=function(t){return t.type===Xt.sprite},e.isParticle=function(t){return t.type===Xt.particle},e.isNull=function(t){return t.type===Xt.null},e.isTree=function(t){return t.type===Xt.tree},e.isCamera=function(t){return t.type===Xt.camera},e.isAncestor=function(t,e){for(var i=e.parent;i;){if(i===t)return!0;i=i.parent}return!1},Pe(e,[{key:"content",get:function(){return this._content}},{key:"composition",get:function(){return this._composition},set:function(t){this._composition=t;for(var e,i=w(this.children);!(e=i()).done;){var r=e.value;r.composition||(r.composition=t)}}},{key:"compositionReusable",get:function(){var t,e;return null!=(e=null==(t=this.composition)?void 0:t.reusable)&&e}},{key:"renderOrder",get:function(){return this.listIndex},set:function(t){if(this.listIndex!==t){this.listIndex=t;for(var e,i=w(this.components);!(e=i()).done;){var r=e.value;A(r,Ge)&&(r.priority=t)}}}},{key:"isActive",get:function(){return this.active}},{key:"isVisible",get:function(){return this.visible}}]),e}(ze);Wu=S([Ne(_e.VFXItemData)],Wu),function(t){t.is=function(t,e){return t.type===e},t.isComposition=function(t){return t.type===Xt.composition},t.isParticle=function(t){return t.type===Xt.particle},t.isNull=function(t){return t.type===Xt.null}}(Uu||(Uu={}));var Zu=[1,1,1,1],qu=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).renderColor=[1,1,1,1],e}Qt(e,t);var i=e.prototype;return i.processFrame=function(t){var e=t.output.getUserData();if(A(e,Wu)){if(this.activeComponent||(this.activeComponent=this.getActiveComponent(e)),!this.activeMaterial){var i,r;this.activeMaterial=null==(i=this.activeComponent)?void 0:i.material;var n=null==(r=this.activeMaterial)?void 0:r.getColor("_Color");n&&(this.startColor=n.toArray())}var s,a,o,u=ra(Zu,1),h=this.time/e.duration,c=this.opacityOverLifetime,l=this.colorOverLifetime;if(l&&(u=G(l,h,!0),s=!0),c&&(u[3]*=c.getValue(h),s=!0),s)na(this.renderColor,u,this.startColor),null==(o=this.activeMaterial)||null==(a=o.getColor("_Color"))||a.setFromArray(this.renderColor)}},i.create=function(t){this.clipData=t;var e,i=t.colorOverLifetime;i&&(this.opacityOverLifetime=Ka(null!=(e=i.opacity)?e:1),i.color&&i.color[0]===$t.GRADIENT_COLOR&&(this.colorOverLifetime=j(i.color[1])));return this},i.getActiveComponent=function(t){return t.getComponent(Ls)},e}(ao),Ku=0,Qu=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.createPlayable=function(t){var e=new qu(t);return e.create(this.data),e},i.fromData=function(t){this.data=t},e}(uo);Qu=S([Ne(_e.SpriteColorPlayableAsset)],Qu);var Ju=function(t){function e(e,i){var r;return(r=t.call(this,e)||this).frameAnimationLoop=!1,r.name="MSprite"+Ku++,i&&r.fromData(i),r}Qt(e,t);var i=e.prototype;return i.onUpdate=function(t){var e=this,i=this.item.time,r=this.item.duration;i>r&&this.frameAnimationLoop&&(i%=r);var n=Math.min(Math.max(i/r,0),1),s=this.textureSheetAnimation,a=this.renderer.texture.source.video;if(a&&(0===i?a.pause():a.play().catch((function(t){e.engine.renderErrors.add(t)})),this.renderer.texture.uploadCurrentVideoFrame()),s){var o,u,h,c,l,f=s.total||s.row*s.col,d=0,p=0,m=1,v=1;if(this.splits){var y=this.splits[0];u=y[4],d=y[0],p=y[1],u?(m=y[3],v=y[2]):(m=y[2],v=y[3])}if(u?(h=1/s.row*m,c=1/s.col*v):(h=1/s.col*m,c=1/s.row*v),s.animate){var g=Math.round(n*(f-1)),x=Math.floor(g/s.col),b=g-x*s.col;l=u?[h*x,c*(s.col-b)]:[h*b,c*(1+x)]}else l=[0,c];null==(o=this.material.getVector4("_TexOffset"))||o.setFromArray([d+l[0],v+p-l[1],h,c])}},i.onDestroy=function(){var t=this.renderer.texture.source;t.sourceType===ci.video&&(null==t?void 0:t.video)&&(t.video.pause(),t.video.src="",t.video.load())},i.fromData=function(e){t.prototype.fromData.call(this,e);var i=e.interaction,r=e.options;this.interaction=i;var n=r.startColor||[1,1,1,1];this.material.setColor("_Color",(new ii).setFromArray(n))},e}(Ls);Ju=S([Ne(_e.SpriteComponent)],Ju);var $u=8;function th(t){return t.maxVertexUniforms>=256?$u=32:t.maxVertexUniforms>=128?$u=16:void 0}function eh(t){$u=t}var ih=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e}(qt),rh=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e}(qt),nh=function(){function t(t){this.curveValues={},this.playable=t}var e=t.prototype;return e.setCurveValue=function(t,e,i){return this.findCurveValue(t,e)?this.curveValues[t+e].value=i:this.curveValues[t+e]={componentType:t,propertyName:e,value:i},this.curveValues[t+e]},e.findCurveValue=function(t,e){return this.curveValues[t+e]},t}(),sh=function(t){function e(e){var i;return(i=t.call(this,e)||this).animationStream=new nh(ho(i)),i}return Qt(e,t),e}(ao),ah=new Or,oh=new Qe(1,1,1),uh=new Qe,hh=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.start=function(){var t=this.boundObject,e=t.transform.scale;this.originalTransform={position:t.transform.position.clone(),rotation:t.transform.getRotation().clone(),scale:new Qe(e.x,e.y,e.x)};var i,r=this.data.positionOverLifetime,n=this.data.rotationOverLifetime,s=this.data.sizeOverLifetime;if(r&&0!==Object.keys(r).length){this.positionOverLifetime=r,r.path&&(this.originalTransform.path=Ka(r.path));var a=r.linearX||r.linearY||r.linearZ;a&&(this.linearVelOverLifetime={x:r.linearX&&Ka(r.linearX),y:r.linearY&&Ka(r.linearY),z:r.linearZ&&Ka(r.linearZ),asMovement:r.asMovement,enabled:!!a});var o=r.orbitalX||r.orbitalY||r.orbitalZ;o&&(this.orbitalVelOverLifetime={x:r.orbitalX&&Ka(r.orbitalX),y:r.orbitalY&&Ka(r.orbitalY),z:r.orbitalZ&&Ka(r.orbitalZ),center:ia(r.orbCenter),asRotation:r.asRotation,enabled:!!o}),this.speedOverLifetime=r.speedOverLifetime&&Ka(r.speedOverLifetime)}if(s&&(s.separateAxes?(this.sizeSeparateAxes=!0,this.sizeXOverLifetime=Ka(s.x||1),this.sizeYOverLifetime=Ka(s.y||1),this.sizeZOverLifetime=Ka(s.z||1)):this.sizeXOverLifetime=Ka(s.size||1)),n&&(this.rotationOverLifetime={asRotation:n.asRotation,separateAxes:n.separateAxes,z:Ka(n.z||0)},n.separateAxes)){var u=this.rotationOverLifetime;u.x=Ka(n.x||0),u.y=Ka(n.y||0)}this.gravity=Qe.fromArray((null==r?void 0:r.gravity)||[]),this.gravityModifier=Ka(null!=(i=null==r?void 0:r.gravityOverLifetime)?i:0),this.direction=(null==r?void 0:r.direction)?Qe.fromArray(r.direction).normalize():new Qe,this.startSpeed=(null==r?void 0:r.startSpeed)||0,this.velocity=this.direction.clone(),this.velocity.multiply(this.startSpeed)},i.processFrame=function(t){if(!this.boundObject){var e=t.output.getUserData();A(e,Wu)&&(this.boundObject=e,this.start())}this.boundObject&&this.boundObject.composition&&this.sampleAnimation()},i.sampleAnimation=function(){var t=this,e=this.boundObject,i=e.duration,r=this.time/i;if(r=r<0?0:r>1?1:r,this.sizeXOverLifetime){oh.x=this.sizeXOverLifetime.getValue(r),this.sizeSeparateAxes?(oh.y=this.sizeYOverLifetime.getValue(r),oh.z=this.sizeZOverLifetime.getValue(r)):oh.z=oh.y=oh.x;var n=this.originalTransform.scale;e.transform.setScale(oh.x*n.x,oh.y*n.y,oh.z*n.z)}if(this.rotationOverLifetime){var s=function(e){return t.rotationOverLifetime.asRotation?e.getValue(r):e.getIntegrateValue(0,r,i)},a=s(this.rotationOverLifetime.z),o=this.rotationOverLifetime.separateAxes;ah.x=o?s(this.rotationOverLifetime.x):0,ah.y=o?s(this.rotationOverLifetime.y):0,ah.z=a;var u=ah.addEulers(this.originalTransform.rotation,ah);e.transform.setRotation(u.x,u.y,u.z)}if(this.positionOverLifetime){var h=uh;ea(h,this,this.gravity,this.time,i,this.originalTransform.position,this.velocity),this.originalTransform.path&&h.add(this.originalTransform.path.getValue(r)),e.transform.setPosition(h.x,h.y,h.z)}},e}(sh),ch=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.createPlayable=function(t){var e=new hh(t);return e.data=this.transformAnimationData,e},i.fromData=function(t){this.transformAnimationData=t},e}(uo);ch=S([Ne(_e.TransformPlayableAsset)],ch);var lh=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.processFrame=function(t){var e=t.output.getUserData();A(e,Wu)&&(e.time=this.time)},e}(ao),fh=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.createPlayable=function(t){return new lh(t)},e}(uo);fh=S([Ne(_e.ActivationPlayableAsset)],fh);var dh=function(t){function e(){var e;return(e=t.apply(this,arguments)||this).duration=0,e.positionCurves=[],e.rotationCurves=[],e.scaleCurves=[],e.floatCurves=[],e}Qt(e,t);var i=e.prototype;return i.sampleAnimation=function(t,e){var i=e/t.duration;i=i<0?0:i>1?1:i;for(var r,n=w(this.positionCurves);!(r=n()).done;){var s=r.value,a=s.keyFrames.getValue(i),o=this.findTarget(t,s.path);null==o||o.transform.setPosition(a.x,a.y,a.z)}for(var u,h=w(this.rotationCurves);!(u=h()).done;){var c=u.value,l=c.keyFrames.getValue(i),f=this.findTarget(t,c.path);null==f||f.transform.setQuaternion(l.x,l.y,l.z,l.w)}for(var d,p=w(this.scaleCurves);!(d=p()).done;){var m=d.value,v=m.keyFrames.getValue(i),y=this.findTarget(t,m.path);null==y||y.transform.setScale(v.x,v.y,v.z)}},i.fromData=function(t){this.positionCurves.length=0,this.scaleCurves.length=0,this.floatCurves.length=0;for(var e,i=w(t.positionCurves);!(e=i()).done;){var r=e.value,n={path:r.path,keyFrames:Ka(r.keyFrames)};this.duration=Math.max(this.duration,n.keyFrames.getMaxTime()),this.positionCurves.push(n)}for(var s,a=w(t.rotationCurves);!(s=a()).done;){var o=s.value,u={path:o.path,keyFrames:Ka(o.keyFrames)};this.duration=Math.max(this.duration,u.keyFrames.getMaxTime()),this.rotationCurves.push(u)}for(var h,c=w(t.scaleCurves);!(h=c()).done;){var l=h.value,f={path:l.path,keyFrames:Ka(l.keyFrames)};this.duration=Math.max(this.duration,f.keyFrames.getMaxTime()),this.scaleCurves.push(f)}for(var d,p=w(t.floatCurves);!(d=p()).done;){var m=d.value,v={path:m.path,keyFrames:Ka(m.keyFrames),property:m.property,className:m.className};this.duration=Math.max(this.duration,v.keyFrames.getMaxTime()),this.floatCurves.push(v)}},i.findTarget=function(t,e){for(var i,r=t,n=w(e);!(i=n()).done;){for(var s,a=i.value,o=!1,u=w(r.children);!(s=u()).done;){var h=s.value;if(h.name===a){r=h,o=!0;break}}if(!o)return}return r},e}(ze);dh=S([Ne(_e.AnimationClip)],dh);var ph=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e.prototype.processFrame=function(t){var e=t.output.getUserData();A(e,Wu)&&e.composition&&this.clip.sampleAnimation(e,this.time)},e}(ao),mh=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.x=0,this.y=0,this.x=t,this.y=e}var e=t.prototype;return e.clone=function(){return new t(this.x,this.y)},e.copyFrom=function(t){return this.set(t.x,t.y),this},e.copyTo=function(t){return t.set(this.x,this.y),t},e.equals=function(t){return t.x===this.x&&t.y===this.y},e.set=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.x=t,this.y=e,this},Pe(t,null,[{key:"shared",get:function(){return vh.x=0,vh.y=0,vh}}]),t}(),vh=new mh,yh=1e-4,gh=1e-4;function xh(t,e,i,r,n,s,a,o){var u,h;a?(u=r,h=-i):(u=-r,h=i);var c=t-i*n+u,l=e-r*n+h,f=t+i*s+u,d=e+r*s+h;return o.push(c,l),o.push(f,d),2}function bh(t,e,i,r,n,s,a,o){var u=i-t,h=r-e,c=Math.atan2(u,h),l=Math.atan2(n-t,s-e);o&&c<l?c+=2*Math.PI:!o&&c>l&&(l+=2*Math.PI);var f=c,d=l-c,p=Math.abs(d),m=Math.sqrt(u*u+h*h),v=1+(15*p*Math.sqrt(m)/Math.PI>>0),y=d/v;if(f+=y,o){a.push(t,e),a.push(i,r);for(var g=1,x=f;g<v;g++,x+=y)a.push(t,e),a.push(t+Math.sin(x)*m,e+Math.cos(x)*m);a.push(t,e),a.push(n,s)}else{a.push(i,r),a.push(t,e);for(var b=1,T=f;b<v;b++,T+=y)a.push(t+Math.sin(T)*m,e+Math.cos(T)*m),a.push(t,e);a.push(n,s),a.push(t,e)}return 2*v}function Th(t,e,i,r,n,s,a,o,u){var h=yh;if(0!==t.length){var c=e,l=c.alignment;if(.5!==e.alignment){var f=function(t){var e=t.length;if(e<6)return 1;for(var i=0,r=0,n=t[e-2],s=t[e-1];r<e;r+=2){var a=t[r],o=t[r+1];i+=(a-n)*(o+s),n=a,s=o}return i<0?-1:1}(t);i&&(f*=-1),l=(l-.5)*f+.5}var d=new mh(t[0],t[1]),p=new mh(t[t.length-2],t[t.length-1]),m=r,v=Math.abs(d.x-p.x)<h&&Math.abs(d.y-p.y)<h;if(m){t=t.slice(),v&&(t.pop(),t.pop(),p.set(t[t.length-2],t[t.length-1]));var y=.5*(d.x+p.x),g=.5*(p.y+d.y);t.unshift(y,g),t.push(y,g)}var x=n,b=t.length/2,T=t.length,E=x.length/2,_=c.width/2,w=_*_,A=c.miterLimit*c.miterLimit,C=t[0],S=t[1],O=t[2],R=t[3],M=0,I=0,P=-(S-R),L=C-O,F=0,V=0,N=Math.sqrt(P*P+L*L)+Ye;P/=N,L/=N,P*=_,L*=_;var D=2*(1-l),k=2*l;m||(c.cap===xe.Round?T+=bh(C-P*(D-k)*.5,S-L*(D-k)*.5,C-P*D,S-L*D,C+P*k,S+L*k,x,!0)+2:c.cap===xe.Square&&(T+=xh(C,S,P,L,D,k,!0,x))),x.push(C-P*D,S-L*D),x.push(C+P*k,S+L*k);for(var z=1;z<b-1;++z){C=t[2*(z-1)],S=t[2*(z-1)+1],O=t[2*z],R=t[2*z+1],M=t[2*(z+1)],I=t[2*(z+1)+1],P=-(S-R),L=C-O,P/=N=Math.sqrt(P*P+L*L)+Ye,L/=N,P*=_,L*=_,F=-(R-I),V=O-M,F/=N=Math.sqrt(F*F+V*V)+Ye,V/=N,F*=_,V*=_;var U=O-C,B=S-R,G=O-M,j=I-R,X=U*G+B*j,H=B*G-j*U,Y=H<0;if(Math.abs(H)<.001*Math.abs(X))x.push(O-P*D,R-L*D),x.push(O+P*k,R+L*k),X>=0&&(c.join===be.Round?T+=bh(O,R,O-P*D,R-L*D,O-F*D,R-V*D,x,!1)+4:T+=2,x.push(O-F*k,R-V*k),x.push(O+F*D,R+V*D));else{var W=(-P+C)*(-L+R)-(-P+O)*(-L+S),Z=(-F+M)*(-V+R)-(-F+O)*(-V+I),q=(U*Z-G*W)/H,K=(j*W-B*Z)/H,Q=(q-O)*(q-O)+(K-R)*(K-R),J=O+(q-O)*D,$=R+(K-R)*D,tt=O-(q-O)*k,et=R-(K-R)*k,it=Y?D:k;Q<=Math.min(U*U+B*B,G*G+j*j)+it*it*w?c.join===be.Bevel||Q/w>A?(Y?(x.push(J,$),x.push(O+P*k,R+L*k),x.push(J,$),x.push(O+F*k,R+V*k)):(x.push(O-P*D,R-L*D),x.push(tt,et),x.push(O-F*D,R-V*D),x.push(tt,et)),T+=2):c.join===be.Round?Y?(x.push(J,$),x.push(O+P*k,R+L*k),T+=bh(O,R,O+P*k,R+L*k,O+F*k,R+V*k,x,!0)+4,x.push(J,$),x.push(O+F*k,R+V*k)):(x.push(O-P*D,R-L*D),x.push(tt,et),T+=bh(O,R,O-P*D,R-L*D,O-F*D,R-V*D,x,!1)+4,x.push(O-F*D,R-V*D),x.push(tt,et)):(x.push(J,$),x.push(tt,et)):(x.push(O-P*D,R-L*D),x.push(O+P*k,R+L*k),c.join===be.Round?T+=Y?bh(O,R,O+P*k,R+L*k,O+F*k,R+V*k,x,!0)+2:bh(O,R,O-P*D,R-L*D,O-F*D,R-V*D,x,!1)+2:c.join===be.Miter&&Q/w<=A&&(Y?(x.push(tt,et),x.push(tt,et)):(x.push(J,$),x.push(J,$)),T+=2),x.push(O-F*D,R-V*D),x.push(O+F*k,R+V*k),T+=2)}}C=t[2*(b-2)],S=t[2*(b-2)+1],O=t[2*(b-1)],P=-(S-(R=t[2*(b-1)+1])),L=C-O,P/=N=Math.sqrt(P*P+L*L)+Ye,L/=N,P*=_,L*=_,x.push(O-P*D,R-L*D),x.push(O+P*k,R+L*k),m||(c.cap===xe.Round?T+=bh(O-P*(D-k)*.5,R-L*(D-k)*.5,O-P*D,R-L*D,O+P*k,R+L*k,x,!1)+2:c.cap===xe.Square&&(T+=xh(O,R,P,L,D,k,!1,x)));for(var rt=gh*gh,nt=E;nt<T+E-2;++nt)C=x[2*nt],S=x[2*nt+1],O=x[2*(nt+1)],R=x[2*(nt+1)+1],M=x[2*(nt+2)],I=x[2*(nt+2)+1],Math.abs(C*(R-I)+O*(I-S)+M*(S-R))<rt||o.push(nt,nt+1,nt+2)}}var Eh=function(){},_h="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},wh={exports:{}};!function(t){var e;function i(t,e){return t.b===e.b&&t.a===e.a}function r(t,e){return t.b<e.b||t.b===e.b&&t.a<=e.a}function n(t,e,i){var r=e.b-t.b,n=i.b-e.b;return 0<r+n?r<n?e.a-t.a+r/(r+n)*(t.a-i.a):e.a-i.a+n/(r+n)*(i.a-t.a):0}function s(t,e,i){var r=e.b-t.b,n=i.b-e.b;return 0<r+n?(e.a-i.a)*r+(e.a-t.a)*n:0}function a(t,e){return t.a<e.a||t.a===e.a&&t.b<=e.b}function o(t,e,i){var r=e.a-t.a,n=i.a-e.a;return 0<r+n?r<n?e.b-t.b+r/(r+n)*(t.b-i.b):e.b-i.b+n/(r+n)*(i.b-t.b):0}function u(t,e,i){var r=e.a-t.a,n=i.a-e.a;return 0<r+n?(e.b-i.b)*r+(e.b-t.b)*n:0}function h(t){return r(t.b.a,t.a)}function c(t){return r(t.a,t.b.a)}function l(t,e,i,r){return(t=0>t?0:t)<=(i=0>i?0:i)?0===i?(e+r)/2:e+t/(t+i)*(r-e):r+i/(t+i)*(e-r)}function f(t){var e=y(t.b);return x(e,t.c),x(e.b,t.c),b(e,t.a),e}function d(t,e){var i=!1,r=!1;t!==e&&(e.a!==t.a&&(r=!0,E(e.a,t.a)),e.d!==t.d&&(i=!0,_(e.d,t.d)),g(e,t),r||(x(e,t.a),t.a.c=t),i||(b(e,t.d),t.d.a=t))}function p(t){var e=t.b,i=!1;t.d!==t.b.d&&(i=!0,_(t.d,t.b.d)),t.c===t?E(t.a,null):(t.b.d.a=$(t),t.a.c=t.c,g(t,$(t)),i||b(t,t.d)),e.c===e?(E(e.a,null),_(e.d,null)):(t.d.a=$(e),e.a.c=e.c,g(e,$(e))),T(t)}function m(t){var e=y(t),i=e.b;return g(e,t.e),e.a=t.b.a,x(i,e.a),e.d=i.d=t.d,e=e.b,g(t.b,$(t.b)),g(t.b,e),t.b.a=e.a,e.b.a.c=e.b,e.b.d=t.b.d,e.f=t.f,e.b.f=t.b.f,e}function v(t,e){var i=!1,r=y(t),n=r.b;return e.d!==t.d&&(i=!0,_(e.d,t.d)),g(r,t.e),g(n,e),r.a=t.b.a,n.a=e.a,r.d=n.d=t.d,t.d.a=n,i||b(r,t.d),r}function y(t){var e=new J,i=new J,r=t.b.h;return i.h=r,r.b.h=e,e.h=t,t.b.h=i,e.b=i,e.c=e,e.e=i,i.b=e,i.c=i,i.e=e}function g(t,e){var i=t.c,r=e.c;i.b.e=e,r.b.e=t,t.c=r,e.c=i}function x(t,e){var i=e.f,r=new et(e,i);i.e=r,e.f=r,i=r.c=t;do{i.a=r,i=i.c}while(i!==t)}function b(t,e){var i=e.d,r=new Q(e,i);i.b=r,e.d=r,r.a=t,r.c=e.c,i=t;do{i.d=r,i=i.e}while(i!==t)}function T(t){var e=t.h;t=t.b.h,e.b.h=t,t.b.h=e}function E(t,e){var i=t.c,r=i;do{r.a=e,r=r.c}while(r!==i);i=t.f,(r=t.e).f=i,i.e=r}function _(t,e){var i=t.a,r=i;do{r.d=e,r=r.e}while(r!==i);i=t.d,(r=t.b).d=i,i.b=r}function w(t){var e=0;return Math.abs(t[1])>Math.abs(t[0])&&(e=1),Math.abs(t[2])>Math.abs(t[e])&&(e=2),e}var A=4e150;function C(t,e){t.f+=e.f,t.b.f+=e.b.f}function S(t,e,i){return t=t.a,e=e.a,i=i.a,e.b.a===t?i.b.a===t?r(e.a,i.a)?0>=s(i.b.a,e.a,i.a):0<=s(e.b.a,i.a,e.a):0>=s(i.b.a,t,i.a):i.b.a===t?0<=s(e.b.a,t,e.a):(e=n(e.b.a,t,e.a))>=(t=n(i.b.a,t,i.a))}function O(t){t.a.i=null;var e=t.e;e.a.c=e.c,e.c.a=e.a,t.e=null}function R(t,e){p(t.a),t.c=!1,t.a=e,e.i=t}function M(t){var e=t.a.a;do{t=dt(t)}while(t.a.a===e);return t.c&&(R(t,e=v(ft(t).a.b,t.a.e)),t=dt(t)),t}function I(t,e,i){var r=new lt;return r.a=i,r.e=H(t.f,e.e,r),i.i=r}function P(t,e){switch(t.s){case 100130:return 0!=(1&e);case 100131:return 0!==e;case 100132:return 0<e;case 100133:return 0>e;case 100134:return 2<=e||-2>=e}return!1}function L(t){var e=t.a,i=e.d;i.c=t.d,i.a=e,O(t)}function F(t,e,i){for(t=e,e=e.a;t!==i;){t.c=!1;var r=ft(t),n=r.a;if(n.a!==e.a){if(!r.c){L(t);break}R(r,n=v(e.c.b,n.b))}e.c!==n&&(d($(n),n),d(e,n)),L(t),e=r.a,t=r}return e}function V(t,e,i,r,n,s){var a=!0;do{I(t,e,i.b),i=i.c}while(i!==r);for(null===n&&(n=ft(e).a.b.c);(i=(r=ft(e)).a.b).a===n.a;)i.c!==n&&(d($(i),i),d($(n),i)),r.f=e.f-i.f,r.d=P(t,r.f),e.b=!0,!a&&z(t,e)&&(C(i,n),O(e),p(n)),a=!1,e=r,n=i;e.b=!0,s&&B(t,e)}function N(t,e,i,r,n){var s=[e.g[0],e.g[1],e.g[2]];e.d=null,e.d=t.o&&t.o(s,i,r,t.c)||null,null===e.d&&(n?t.n||(K(t,100156),t.n=!0):e.d=i[0])}function D(t,e,i){var r=[null,null,null,null];r[0]=e.a.d,r[1]=i.a.d,N(t,e.a,r,[.5,.5,0,0],!1),d(e,i)}function k(t,e,i,r,n){var s=Math.abs(e.b-t.b)+Math.abs(e.a-t.a),a=Math.abs(i.b-t.b)+Math.abs(i.a-t.a),o=n+1;r[n]=.5*a/(s+a),r[o]=.5*s/(s+a),t.g[0]+=r[n]*e.g[0]+r[o]*i.g[0],t.g[1]+=r[n]*e.g[1]+r[o]*i.g[1],t.g[2]+=r[n]*e.g[2]+r[o]*i.g[2]}function z(t,e){var n=ft(e),a=e.a,o=n.a;if(r(a.a,o.a)){if(0<s(o.b.a,a.a,o.a))return!1;if(i(a.a,o.a)){if(a.a!==o.a){n=t.e;var u=a.a.h;if(0<=u){var h=(n=n.b).d,c=n.e,l=n.c,f=l[u];h[f]=h[n.a],l[h[f]]=f,f<=--n.a&&(1>=f||r(c[h[f>>1]],c[h[f]])?ht(n,f):ct(n,f)),c[u]=null,l[u]=n.b,n.b=u}else for(n.c[-(u+1)]=null;0<n.a&&null===n.c[n.d[n.a-1]];)--n.a;D(t,$(o),a)}}else m(o.b),d(a,$(o)),e.b=n.b=!0}else{if(0>s(a.b.a,o.a,a.a))return!1;dt(e).b=e.b=!0,m(a.b),d($(o),a)}return!0}function U(t,e){var h=ft(e),c=e.a,f=h.a,p=c.a,v=f.a,y=c.b.a,g=f.b.a,x=new et;if(s(y,t.a,p),s(g,t.a,v),p===v||Math.min(p.a,y.a)>Math.max(v.a,g.a))return!1;if(r(p,v)){if(0<s(g,p,v))return!1}else if(0>s(y,v,p))return!1;var b,T,E=y,_=p,w=g,A=v;if(r(E,_)||(b=E,E=_,_=b),r(w,A)||(b=w,w=A,A=b),r(E,w)||(b=E,E=w,w=b,b=_,_=A,A=b),r(w,_)?r(_,A)?(0>(b=n(E,w,_))+(T=n(w,_,A))&&(b=-b,T=-T),x.b=l(b,w.b,T,_.b)):(0>(b=s(E,w,_))+(T=-s(E,A,_))&&(b=-b,T=-T),x.b=l(b,w.b,T,A.b)):x.b=(w.b+_.b)/2,a(E,_)||(b=E,E=_,_=b),a(w,A)||(b=w,w=A,A=b),a(E,w)||(b=E,E=w,w=b,b=_,_=A,A=b),a(w,_)?a(_,A)?(0>(b=o(E,w,_))+(T=o(w,_,A))&&(b=-b,T=-T),x.a=l(b,w.a,T,_.a)):(0>(b=u(E,w,_))+(T=-u(E,A,_))&&(b=-b,T=-T),x.a=l(b,w.a,T,A.a)):x.a=(w.a+_.a)/2,r(x,t.a)&&(x.b=t.a.b,x.a=t.a.a),E=r(p,v)?p:v,r(E,x)&&(x.b=E.b,x.a=E.a),i(x,p)||i(x,v))return z(t,e),!1;if(!i(y,t.a)&&0<=s(y,t.a,x)||!i(g,t.a)&&0>=s(g,t.a,x)){if(g===t.a)return m(c.b),d(f.b,c),c=ft(e=M(e)).a,F(t,ft(e),h),V(t,e,$(c),c,c,!0),!0;if(y===t.a){m(f.b),d(c.e,$(f)),v=(p=h=e).a.b.a;do{p=dt(p)}while(p.a.b.a===v);return p=ft(e=p).a.b.c,h.a=$(f),V(t,e,(f=F(t,h,null)).c,c.b.c,p,!0),!0}return 0<=s(y,t.a,x)&&(dt(e).b=e.b=!0,m(c.b),c.a.b=t.a.b,c.a.a=t.a.a),0>=s(g,t.a,x)&&(e.b=h.b=!0,m(f.b),f.a.b=t.a.b,f.a.a=t.a.a),!1}return m(c.b),m(f.b),d($(f),c),c.a.b=x.b,c.a.a=x.a,c.a.h=rt(t.e,c.a),c=c.a,f=[0,0,0,0],x=[p.d,y.d,v.d,g.d],c.g[0]=c.g[1]=c.g[2]=0,k(c,p,y,f,0),k(c,v,g,f,2),N(t,c,x,f,!0),dt(e).b=e.b=h.b=!0,!1}function B(t,e){for(var i=ft(e);;){for(;i.b;)e=i,i=ft(i);if(!e.b&&(i=e,null===(e=dt(e))||!e.b))break;e.b=!1;var n,a=e.a,o=i.a;if(n=a.b.a!==o.b.a)t:{var u=ft(n=e),h=n.a,c=u.a,l=void 0;if(r(h.b.a,c.b.a)){if(0>s(h.b.a,c.b.a,h.a)){n=!1;break t}dt(n).b=n.b=!0,l=m(h),d(c.b,l),l.d.c=n.d}else{if(0<s(c.b.a,h.b.a,c.a)){n=!1;break t}n.b=u.b=!0,l=m(c),d(h.e,c.b),l.b.d.c=n.d}n=!0}if(n&&(i.c?(O(i),p(o),o=(i=ft(e)).a):e.c&&(O(e),p(a),a=(e=dt(i)).a)),a.a!==o.a)if(a.b.a===o.b.a||e.c||i.c||a.b.a!==t.a&&o.b.a!==t.a)z(t,e);else if(U(t,e))break;a.a===o.a&&a.b.a===o.b.a&&(C(o,a),O(e),p(a),e=dt(i))}}function G(t,e){t.a=e;for(var n=e.c;null===n.i;)if((n=n.c)===e.c){n=t;var a=e;(h=new lt).a=a.c.b;var o=(l=n.f).a;do{o=o.a}while(null!==o.b&&!l.c(l.b,h,o.b));var u=ft(l=o.b),h=l.a;o=u.a;if(0===s(h.b.a,a,h.a))i((h=l.a).a,a)||i(h.b.a,a)||(m(h.b),l.c&&(p(h.c),l.c=!1),d(a.c,h),G(n,a));else{var c=r(o.b.a,h.b.a)?l:u;u=void 0;l.d||c.c?(u=c===l?v(a.c.b,h.e):v(o.b.c.b,a.c).b,c.c?R(c,u):(h=n,(l=I(n,l,u)).f=dt(l).f+l.a.f,l.d=P(h,l.f)),G(n,a)):V(n,l,a.c,a.c,null,!0)}return}if(l=(h=ft(n=M(n.i))).a,(h=F(t,h,null)).c===l){h=(l=h).c,o=ft(n),u=n.a,c=o.a;var l,f=!1;u.b.a!==c.b.a&&U(t,n),i(u.a,t.a)&&(d($(h),u),h=ft(n=M(n)).a,F(t,ft(n),o),f=!0),i(c.a,t.a)&&(d(l,$(c)),l=F(t,o,null),f=!0),f?V(t,n,l.c,h,h,!0):(a=r(c.a,u.a)?$(c):u,V(t,n,a=v(l.c.b,a),a.c,a.c,!1),a.b.i.c=!0,B(t,n))}else V(t,n,h.c,l,l,!0)}function j(t,e){var i=new lt,r=f(t.b);r.a.b=A,r.a.a=e,r.b.a.b=-A,r.b.a.a=e,t.a=r.b.a,i.a=r,i.f=0,i.d=!1,i.c=!1,i.h=!0,i.b=!1,r=H(r=t.f,r.a,i),i.e=r}function X(t){this.a=new Y,this.b=t,this.c=S}function H(t,e,i){do{e=e.c}while(null!==e.b&&!t.c(t.b,e.b,i));return t=new Y(i,e.a,e),e.a.c=t,e.a=t}function Y(t,e,i){this.b=t||null,this.a=e||this,this.c=i||this}function W(){this.d=Z,this.p=this.b=this.q=null,this.j=[0,0,0],this.s=100130,this.n=!1,this.o=this.a=this.e=this.f=null,this.m=!1,this.c=this.r=this.i=this.k=this.l=this.h=null}var Z=0;function q(t,e){if(t.d!==e)for(;t.d!==e;)if(t.d<e)switch(t.d){case Z:K(t,100151),t.u(null);break;case 1:K(t,100152),t.t()}else switch(t.d){case 2:K(t,100154),t.v();break;case 1:K(t,100153),t.w()}}function K(t,e){t.p&&t.p(e,t.c)}function Q(t,e){this.b=t||this,this.d=e||this,this.a=null,this.c=!1}function J(){this.h=this,this.i=this.d=this.a=this.e=this.c=this.b=null,this.f=0}function $(t){return t.b.e}function tt(){this.c=new et,this.a=new Q,this.b=new J,this.d=new J,this.b.b=this.d,this.d.b=this.b}function et(t,e){this.e=t||this,this.f=e||this,this.d=this.c=null,this.g=[0,0,0],this.h=this.a=this.b=0}function it(){this.c=[],this.d=null,this.a=0,this.e=!1,this.b=new st}function rt(t,e){if(t.e){var i,r=t.b,n=++r.a;return 2*n>r.f&&(r.f*=2,r.c=at(r.c,r.f+1)),0===r.b?i=n:(i=r.b,r.b=r.c[r.b]),r.e[i]=e,r.c[i]=n,r.d[n]=i,r.h&&ct(r,n),i}return r=t.a++,t.c[r]=e,-(r+1)}function nt(t){if(0===t.a)return ut(t.b);var e=t.c[t.d[t.a-1]];if(0!==t.b.a&&r(ot(t.b),e))return ut(t.b);do{--t.a}while(0<t.a&&null===t.c[t.d[t.a-1]]);return e}function st(){this.d=at([0],33),this.e=[null,null],this.c=[0,0],this.a=0,this.f=32,this.b=0,this.h=!1,this.d[1]=1}function at(t,e){for(var i=Array(e),r=0;r<t.length;r++)i[r]=t[r];for(;r<e;r++)i[r]=0;return i}function ot(t){return t.e[t.d[1]]}function ut(t){var e=t.d,i=t.e,r=t.c,n=e[1],s=i[n];return 0<t.a&&(e[1]=e[t.a],r[e[1]]=1,i[n]=null,r[n]=t.b,t.b=n,0<--t.a&&ht(t,1)),s}function ht(t,e){for(var i=t.d,n=t.e,s=t.c,a=e,o=i[a];;){var u=a<<1;u<t.a&&r(n[i[u+1]],n[i[u]])&&(u+=1);var h=i[u];if(u>t.a||r(n[o],n[h])){i[a]=o,s[o]=a;break}i[a]=h,s[h]=a,a=u}}function ct(t,e){for(var i=t.d,n=t.e,s=t.c,a=e,o=i[a];;){var u=a>>1,h=i[u];if(0===u||r(n[h],n[o])){i[a]=o,s[o]=a;break}i[a]=h,s[h]=a,a=u}}function lt(){this.e=this.a=null,this.f=0,this.c=this.b=this.h=this.d=!1}function ft(t){return t.e.c.b}function dt(t){return t.e.a.b}(e=W.prototype).x=function(){q(this,Z)},e.B=function(t,e){switch(t){case 100142:return;case 100140:switch(e){case 100130:case 100131:case 100132:case 100133:case 100134:return void(this.s=e)}break;case 100141:return void(this.m=!!e);default:return void K(this,100900)}K(this,100901)},e.y=function(t){switch(t){case 100142:return 0;case 100140:return this.s;case 100141:return this.m;default:K(this,100900)}return!1},e.A=function(t,e,i){this.j[0]=t,this.j[1]=e,this.j[2]=i},e.z=function(t,e){var i=e||null;switch(t){case 100100:case 100106:this.h=i;break;case 100104:case 100110:this.l=i;break;case 100101:case 100107:this.k=i;break;case 100102:case 100108:this.i=i;break;case 100103:case 100109:this.p=i;break;case 100105:case 100111:this.o=i;break;case 100112:this.r=i;break;default:K(this,100900)}},e.C=function(t,e){var i=!1,r=[0,0,0];q(this,2);for(var n=0;3>n;++n){var s=t[n];-1e150>s&&(s=-1e150,i=!0),1e150<s&&(s=1e150,i=!0),r[n]=s}i&&K(this,100155),null===(i=this.q)?d(i=f(this.b),i.b):(m(i),i=i.e),i.a.d=e,i.a.g[0]=r[0],i.a.g[1]=r[1],i.a.g[2]=r[2],i.f=1,i.b.f=-1,this.q=i},e.u=function(t){q(this,Z),this.d=1,this.b=new tt,this.c=t},e.t=function(){q(this,1),this.d=2,this.q=null},e.v=function(){q(this,2),this.d=1},e.w=function(){q(this,1),this.d=Z;var t=!1,e=[l=this.j[0],n=this.j[1],o=this.j[2]];if(0===l&&0===n&&0===o){for(var n=[-2e150,-2e150,-2e150],a=[2e150,2e150,2e150],o=[],u=[],l=(t=this.b.c).e;l!==t;l=l.e)for(var f=0;3>f;++f){var d=l.g[f];d<a[f]&&(a[f]=d,u[f]=l),d>n[f]&&(n[f]=d,o[f]=l)}if(l=0,n[1]-a[1]>n[0]-a[0]&&(l=1),n[2]-a[2]>n[l]-a[l]&&(l=2),a[l]>=n[l])e[0]=0,e[1]=0,e[2]=1;else{for(n=0,a=u[l],o=o[l],u=[0,0,0],a=[a.g[0]-o.g[0],a.g[1]-o.g[1],a.g[2]-o.g[2]],f=[0,0,0],l=t.e;l!==t;l=l.e)f[0]=l.g[0]-o.g[0],f[1]=l.g[1]-o.g[1],f[2]=l.g[2]-o.g[2],u[0]=a[1]*f[2]-a[2]*f[1],u[1]=a[2]*f[0]-a[0]*f[2],u[2]=a[0]*f[1]-a[1]*f[0],(d=u[0]*u[0]+u[1]*u[1]+u[2]*u[2])>n&&(n=d,e[0]=u[0],e[1]=u[1],e[2]=u[2]);0>=n&&(e[0]=e[1]=e[2]=0,e[w(a)]=1)}t=!0}for(u=w(e),l=this.b.c,n=(u+1)%3,o=(u+2)%3,u=0<e[u]?1:-1,e=l.e;e!==l;e=e.e)e.b=e.g[n],e.a=u*e.g[o];if(t){for(e=0,l=(t=this.b.a).b;l!==t;l=l.b)if(!(0>=(n=l.a).f))do{e+=(n.a.b-n.b.a.b)*(n.a.a+n.b.a.a),n=n.e}while(n!==l.a);if(0>e)for(t=(e=this.b.c).e;t!==e;t=t.e)t.a=-t.a}for(this.n=!1,l=(e=this.b.b).h;l!==e;l=t)t=l.h,n=l.e,i(l.a,l.b.a)&&l.e.e!==l&&(D(this,n,l),p(l),n=(l=n).e),n.e===l&&(n!==l&&(n!==t&&n!==t.b||(t=t.h),p(n)),l!==t&&l!==t.b||(t=t.h),p(l));for(this.e=e=new it,l=(t=this.b.c).e;l!==t;l=l.e)l.h=rt(e,l);for(function(t){t.d=[];for(var e=0;e<t.a;e++)t.d[e]=e;t.d.sort(function(t){return function(e,i){return r(t[e],t[i])?1:-1}}(t.c)),t.e=!0,function(t){for(var e=t.a;1<=e;--e)ht(t,e);t.h=!0}(t.b)}(e),this.f=new X(this),j(this,-A),j(this,A);null!==(e=nt(this.e));){for(;;){t:if(l=this.e,0===l.a)t=ot(l.b);else if(t=l.c[l.d[l.a-1]],0!==l.b.a&&(l=ot(l.b),r(l,t))){t=l;break t}if(null===t||!i(t,e))break;t=nt(this.e),D(this,e.c,t.c)}G(this,e)}for(this.a=this.f.a.a.b.a.a,e=0;null!==(t=this.f.a.a.b);)t.h||++e,O(t);for(this.f=null,(e=this.e).b=null,e.d=null,this.e=e.c=null,l=(e=this.b).a.b;l!==e.a;l=t)t=l.b,(l=l.a).e.e===l&&(C(l.c,l),p(l));if(!this.n){if(e=this.b,this.m)for(l=e.b.h;l!==e.b;l=t)t=l.h,l.b.d.c!==l.d.c?l.f=l.d.c?1:-1:p(l);else for(l=e.a.b;l!==e.a;l=t)if(t=l.b,l.c){for(l=l.a;r(l.b.a,l.a);l=l.c.b);for(;r(l.a,l.b.a);l=l.e);for(n=l.c.b,o=void 0;l.e!==n;)if(r(l.b.a,n.a)){for(;n.e!==l&&(h(n.e)||0>=s(n.a,n.b.a,n.e.b.a));)n=(o=v(n.e,n)).b;n=n.c.b}else{for(;n.e!==l&&(c(l.c.b)||0<=s(l.b.a,l.a,l.c.b.a));)l=(o=v(l,l.c.b)).b;l=l.e}for(;n.e.e!==l;)n=(o=v(n.e,n)).b}if(this.h||this.i||this.k||this.l)if(this.m){for(t=(e=this.b).a.b;t!==e.a;t=t.b)if(t.c){this.h&&this.h(2,this.c),l=t.a;do{this.k&&this.k(l.a.d,this.c),l=l.e}while(l!==t.a);this.i&&this.i(this.c)}}else{for(e=this.b,t=!!this.l,l=!1,n=-1,o=e.a.d;o!==e.a;o=o.d)if(o.c){l||(this.h&&this.h(4,this.c),l=!0),u=o.a;do{t&&(n!==(a=u.b.d.c?0:1)&&(n=a,this.l&&this.l(!!n,this.c))),this.k&&this.k(u.a.d,this.c),u=u.e}while(u!==o.a)}l&&this.i&&this.i(this.c)}if(this.r){for(l=(e=this.b).a.b;l!==e.a;l=t)if(t=l.b,!l.c){o=(n=l.a).e,u=void 0;do{o=(u=o).e,u.d=null,null===u.b.d&&(u.c===u?E(u.a,null):(u.a.c=u.c,g(u,$(u))),(a=u.b).c===a?E(a.a,null):(a.a.c=a.c,g(a,$(a))),T(u))}while(u!==n);n=l.d,(l=l.b).d=n,n.b=l}return this.r(this.b),void(this.c=this.b=null)}}this.b=this.c=null},_h.libtess={GluTesselator:W,windingRule:{GLU_TESS_WINDING_ODD:100130,GLU_TESS_WINDING_NONZERO:100131,GLU_TESS_WINDING_POSITIVE:100132,GLU_TESS_WINDING_NEGATIVE:100133,GLU_TESS_WINDING_ABS_GEQ_TWO:100134},primitiveType:{GL_LINE_LOOP:2,GL_TRIANGLES:4,GL_TRIANGLE_STRIP:5,GL_TRIANGLE_FAN:6},errorType:{GLU_TESS_MISSING_BEGIN_POLYGON:100151,GLU_TESS_MISSING_END_POLYGON:100153,GLU_TESS_MISSING_BEGIN_CONTOUR:100152,GLU_TESS_MISSING_END_CONTOUR:100154,GLU_TESS_COORD_TOO_LARGE:100155,GLU_TESS_NEED_COMBINE_CALLBACK:100156},gluEnum:{GLU_TESS_MESH:100112,GLU_TESS_TOLERANCE:100142,GLU_TESS_WINDING_RULE:100140,GLU_TESS_BOUNDARY_ONLY:100141,GLU_INVALID_ENUM:100900,GLU_INVALID_VALUE:100901,GLU_TESS_BEGIN:100100,GLU_TESS_VERTEX:100101,GLU_TESS_END:100102,GLU_TESS_ERROR:100103,GLU_TESS_EDGE_FLAG:100104,GLU_TESS_COMBINE:100105,GLU_TESS_BEGIN_DATA:100106,GLU_TESS_VERTEX_DATA:100107,GLU_TESS_END_DATA:100108,GLU_TESS_ERROR_DATA:100109,GLU_TESS_EDGE_FLAG_DATA:100110,GLU_TESS_COMBINE_DATA:100111}},W.prototype.gluDeleteTess=W.prototype.x,W.prototype.gluTessProperty=W.prototype.B,W.prototype.gluGetTessProperty=W.prototype.y,W.prototype.gluTessNormal=W.prototype.A,W.prototype.gluTessCallback=W.prototype.z,W.prototype.gluTessVertex=W.prototype.C,W.prototype.gluTessBeginPolygon=W.prototype.u,W.prototype.gluTessBeginContour=W.prototype.t,W.prototype.gluTessEndContour=W.prototype.v,W.prototype.gluTessEndPolygon=W.prototype.w,t.exports=_h.libtess}(wh);var Ah=function(){var t=new wh.exports.GluTesselator;return t.gluTessCallback(wh.exports.gluEnum.GLU_TESS_VERTEX_DATA,(function(t,e){e[e.length]=t[0],e[e.length]=t[1]})),t.gluTessCallback(wh.exports.gluEnum.GLU_TESS_BEGIN,(function(t){t!==wh.exports.primitiveType.GL_TRIANGLES&&console.info("expected TRIANGLES but got type: "+t)})),t.gluTessCallback(wh.exports.gluEnum.GLU_TESS_ERROR,(function(t){console.error("error callback, error number: "+t)})),t.gluTessCallback(wh.exports.gluEnum.GLU_TESS_COMBINE,(function(t,e,i){return[t[0],t[1],t[2]]})),t.gluTessCallback(wh.exports.gluEnum.GLU_TESS_EDGE_FLAG,(function(t){})),t}();function Ch(t){Ah.gluTessNormal(0,0,1);var e=[];Ah.gluTessBeginPolygon(e);for(var i=0;i<t.length;i++){Ah.gluTessBeginContour();for(var r=t[i],n=0;n<r.length;n+=2){var s=[r[n],r[n+1],0];Ah.gluTessVertex(s,s)}Ah.gluTessEndContour()}return Ah.gluTessEndPolygon(),e}var Sh=function(t){function e(){for(var e=arguments.length,i=new Array(e),r=0;r<e;r++)i[r]=arguments[r];var n;(n=t.call(this)||this).points=[],n.closePath=!1;var s=Array.isArray(i[0])?i[0]:i;if("number"!=typeof s[0]){for(var a=[],o=0,u=s.length;o<u;o++)a.push(s[o].x,s[o].y);s=a}return n.points=s,n.closePath=!0,n}Qt(e,t);var i=e.prototype;return i.clone=function(){var t=new e(this.points.slice());return t.closePath=this.closePath,t},i.contains=function(t,e){for(var i=!1,r=this.points.length/2,n=0,s=r-1;n<r;s=n++){var a=this.points[2*n],o=this.points[2*n+1],u=this.points[2*s],h=this.points[2*s+1];o>e!=h>e&&t<(e-o)/(h-o)*(u-a)+a&&(i=!i)}return i},i.copyFrom=function(t){return this.points=t.points.slice(),this.closePath=t.closePath,this},i.copyTo=function(t){return t.copyFrom(this),t},i.getX=function(){return this.points[this.points.length-2]},i.getY=function(){return this.points[this.points.length-1]},i.build=function(t){for(var e=0;e<this.points.length;e++)t[e]=this.points[e]},i.triangulate=function(t,e,i,r,n){var s=Ch([t]),a=e.length/2;0===s.length&&this.getLineEndPointsTriangle(t,s);for(var o=0;o<s.length;o++)e[2*i+o]=s[o];for(var u=s.length/2,h=0;h<u;h++)r[n+h]=a+h},i.getLineEndPointsTriangle=function(t,e){if(!t||t.length<2||t.length%2!=0)throw new Error("Invalid points array");if(2!==t.length){var i=t[2]-t[0],r=t[3]-t[1],n=t[0],s=t[1],a=t[0],o=t[1];if(Math.abs(i)>=Math.abs(r))for(var u=0;u<t.length;u+=2){var h=t[u],c=t[u+1];h<n&&(n=h,s=c),h>a&&(a=h,o=c)}else for(var l=0;l<t.length;l+=2){var f=t[l],d=t[l+1];d<s&&(n=f,s=d),d>o&&(a=f,o=d)}e.push(n,s,a,o,a,o)}else e.push(t[0],t[1],t[0],t[1],t[0],t[1])},Pe(e,[{key:"lastX",get:function(){return this.points[this.points.length-2]}},{key:"lastY",get:function(){return this.points[this.points.length-1]}}]),e}(Eh),Oh=8,Rh=1.1920929e-7;function Mh(t,e,i,r,n,s,a,o,u,h){var c=(1-Math.min(.99,Math.max(0,null!=h?h:.5)))/5;return function(t,e,i,r,n,s,a,o,u,h){Ih(t,e,i,r,n,s,a,o,u,h,0),u.push(a,o)}(e,i,r,n,s,a,o,u,t,c*=c),t}function Ih(t,e,i,r,n,s,a,o,u,h,c){if(!(c>Oh)){var l=(t+i)/2,f=(e+r)/2,d=(i+n)/2,p=(r+s)/2,m=(n+a)/2,v=(s+o)/2,y=(l+d)/2,g=(f+p)/2,x=(d+m)/2,b=(p+v)/2,T=(y+x)/2,E=(g+b)/2;if(c>0){var _=a-t,w=o-e,A=Math.abs((i-a)*w-(r-o)*_),C=Math.abs((n-a)*w-(s-o)*_);if(A>Rh&&C>Rh){if((A+C)*(A+C)<=h*(_*_+w*w))return void u.push(T,E)}else if(A>Rh){if(A*A<=h*(_*_+w*w))return void u.push(T,E)}else if(C>Rh){if(C*C<=h*(_*_+w*w))return void u.push(T,E)}else if((_=T-(t+a)/2)*_+(w=E-(e+o)/2)*w<=h)return void u.push(T,E)}Ih(t,e,l,f,y,g,T,E,u,h,c+1),Ih(T,E,x,b,m,v,a,o,u,h,c+1)}}var Ph,Lh=function(t){function e(e,i,r,n){var s;return void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=0),(s=t.call(this)||this).type="ellipse",s.x=e,s.y=i,s.halfWidth=r,s.halfHeight=n,s}Qt(e,t);var i=e.prototype;return i.clone=function(){return new e(this.x,this.y,this.halfWidth,this.halfHeight)},i.contains=function(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;var i=(t-this.x)/this.halfWidth,r=(e-this.y)/this.halfHeight;return(i*=i)+(r*=r)<=1},i.strokeContains=function(t,e,i){var r=this.halfWidth,n=this.halfHeight;if(r<=0||n<=0)return!1;var s=i/2,a=r-s,o=n-s,u=r+s,h=n+s,c=t-this.x,l=e-this.y;return c*c/(a*a)+l*l/(o*o)>1&&c*c/(u*u)+l*l/(h*h)<=1},i.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.halfWidth=t.halfWidth,this.halfHeight=t.halfHeight,this},i.copyTo=function(t){return t.copyFrom(this),t},i.getX=function(){return this.x},i.getY=function(){return this.y},i.build=function(t){var e=this.x,i=this.y,r=this.halfWidth,n=this.halfHeight;if(!(r>=0&&n>=0))return t;var s=Math.ceil(5*Math.sqrt(r+n)),a=8*s+0+0;if(0===a)return t;if(0===s)return t[0]=t[6]=e+0,t[1]=t[3]=i+0,t[2]=t[4]=e-0,t[5]=t[7]=i-0,t;var o=0,u=4*s+0+2,h=u,c=a,l=0+r,f=0,d=e+l,p=e-l,m=i+f;t[o++]=d,t[o++]=m,t[--u]=m,t[--u]=p;for(var v=1;v<s;v++){var y=Math.PI/2*(v/s),g=0+Math.cos(y)*r,x=0+Math.sin(y)*n,b=e+g,T=e-g,E=i+x,_=i-x;t[o++]=b,t[o++]=E,t[--u]=E,t[--u]=T,t[h++]=T,t[h++]=_,t[--c]=_,t[--c]=b}d=e+(l=0),p=e-l,m=i+(f=0+n);var w=i-f;return t[o++]=d,t[o++]=m,t[--c]=w,t[--c]=d,t},i.triangulate=function(t,e,i,r,n){if(0!==t.length){for(var s=0,a=0,o=0;o<t.length;o+=2)s+=t[o],a+=t[o+1];s/=t.length/2,a/=t.length/2;var u=i;e[2*u]=s,e[2*u+1]=a;for(var h=u++,c=0;c<t.length;c+=2)e[2*u]=t[c],e[2*u+1]=t[c+1],c>0&&(r[n++]=u,r[n++]=h,r[n++]=u-1),u++;r[n++]=h+1,r[n++]=h,r[n++]=u-1}},e}(Eh);!function(t){t[t.Star=0]="Star",t[t.Polygon=1]="Polygon"}(Ph||(Ph={}));var Fh=function(t){function e(e,i,r,n,s,a){var o;return void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=0),void 0===s&&(s=0),void 0===a&&(a=0),(o=t.call(this)||this).pointCount=e,o.outerRadius=i,o.innerRadius=r,o.outerRoundness=n,o.innerRoundness=s,o.starType=a,o.v=[],o.in=[],o.out=[],o}Qt(e,t);var i=e.prototype;return i.clone=function(){return new e(this.pointCount,this.outerRadius,this.innerRadius,this.outerRoundness,this.innerRoundness,this.starType)},i.copyFrom=function(t){this.pointCount=t.pointCount,this.outerRadius=t.outerRadius,this.innerRadius=t.innerRadius,this.outerRoundness=t.outerRoundness,this.innerRoundness=t.innerRoundness,this.starType=t.starType},i.copyTo=function(t){t.copyFrom(this)},i.build=function(t){switch(this.starType){case 0:this.buildStarPath();break;case 1:this.buildPolygonPath()}for(var e=0;e<this.v.length-2;e+=2)Mh(t,this.v[e],this.v[e+1],this.out[e],this.out[e+1],this.in[e+2],this.in[e+3],this.v[e+2],this.v[e+3],1);var i=this.v.length-1;Mh(t,this.v[i-1],this.v[i],this.out[i-1],this.out[i],this.in[0],this.in[1],this.v[0],this.v[1],1)},i.triangulate=function(t,e,i,r,n){for(var s=Ch([t]),a=e.length/2,o=0;o<s.length;o++)e[2*i+o]=s[o];for(var u=s.length/2,h=0;h<u;h++)r[n+h]=a+h},i.buildStarPath=function(){this.v=[],this.in=[],this.out=[];var t,e,i,r,n=2*Math.floor(this.pointCount),s=2*Math.PI/n,a=!0,o=this.outerRadius,u=this.innerRadius,h=this.outerRoundness/100,c=this.innerRoundness/100,l=2*Math.PI*o/(2*n),f=2*Math.PI*u/(2*n),d=-Math.PI/2;for(t=0;t<n;t++){i=a?h:c,r=a?l:f;var p=(e=a?o:u)*Math.cos(d),m=e*Math.sin(d),v=0===p&&0===m?0:m/Math.sqrt(p*p+m*m),y=0===p&&0===m?0:-p/Math.sqrt(p*p+m*m),g=2*t;this.v[g]=p,this.v[g+1]=m,this.in[g]=p+v*r*i*1,this.in[g+1]=m+y*r*i*1,this.out[g]=p-v*r*i*1,this.out[g+1]=m-y*r*i*1,a=!a,d+=1*s}},i.buildPolygonPath=function(){this.v=[],this.in=[],this.out=[];var t,e=Math.floor(this.pointCount),i=2*Math.PI/e,r=this.outerRadius,n=this.outerRoundness/100,s=2*Math.PI*r/(4*e),a=.5*-Math.PI;for(t=0;t<e;t++){var o=r*Math.cos(a),u=r*Math.sin(a),h=0===o&&0===u?0:u/Math.sqrt(o*o+u*u),c=0===o&&0===u?0:-o/Math.sqrt(o*o+u*u),l=2*t;this.v[l]=o,this.v[l+1]=u,this.in[l]=o+h*s*n*1,this.in[l+1]=u+c*s*n*1,this.out[l]=o-h*s*n*1,this.out[l+1]=u-c*s*n*1,a+=1*i}},e}(Eh),Vh=function(t){function e(e,i,r,n,s){var a;return void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=0),void 0===s&&(s=20),(a=t.call(this)||this).x=e,a.y=i,a.width=r,a.height=n,a.roundness=s,a}Qt(e,t);var i=e.prototype;return i.getBounds=function(t){return(t=t||new e).x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t},i.clone=function(){return new e(this.x,this.y,this.width,this.height,this.roundness)},i.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this.roundness=t.roundness,this},i.copyTo=function(t){return t.copyFrom(this),t},i.build=function(t){var e,i=this.width/2,r=this.height/2,n=this.x+i,s=this.y+r,a=e=Math.max(0,Math.min(this.roundness/100,1)*Math.min(i,r)),o=i-a,u=r-e;if(a>=0&&e>=0&&o>=0&&u>=0){var h=5*Math.ceil(2.3*Math.sqrt(a+e)),c=8*h+(o?4:0)+(u?4:0);if(0!==c){if(0===h)return t[0]=t[6]=n+o,t[1]=t[3]=s+u,t[2]=t[4]=n-o,void(t[5]=t[7]=s-u);var l=0,f=4*h+(o?2:0)+2,d=f,p=c,m=o+a,v=u,y=n+m,g=n-m,x=s+v;if(t[l++]=y,t[l++]=x,t[--f]=x,t[--f]=g,u){var b=s-v;t[d++]=g,t[d++]=b,t[--p]=b,t[--p]=y}for(var T=1;T<h;T++){var E=Math.PI/2*(T/h),_=o+Math.cos(E)*a,w=u+Math.sin(E)*e,A=n+_,C=n-_,S=s+w,O=s-w;t[l++]=A,t[l++]=S,t[--f]=S,t[--f]=C,t[d++]=C,t[d++]=O,t[--p]=O,t[--p]=A}y=n+(m=o),g=n-m,x=s+(v=u+e);var R=s-v;t[l++]=y,t[l++]=x,t[--p]=R,t[--p]=y,o&&(t[l++]=g,t[l++]=x,t[--p]=R,t[--p]=g)}}},i.triangulate=function(t,e,i,r,n){if(0!==t.length){for(var s=0,a=0,o=0;o<t.length;o+=2)s+=t[o],a+=t[o+1];s/=t.length/2,a/=t.length/2;var u=i;e[2*u]=s,e[2*u+1]=a;for(var h=u++,c=0;c<t.length;c+=2)e[2*u]=t[c],e[2*u+1]=t[c+1],c>0&&(r[n++]=u,r[n++]=h,r[n++]=u-1),u++;r[n++]=h+1,r[n++]=h,r[n++]=u-1}},e}(Eh),Nh=function(){function t(t){this.graphicsPath=t,this.currentPoly=null,this.shapePrimitives=[]}var e=t.prototype;return e.buildPath=function(){this.currentPoly=null,this.shapePrimitives.length=0;for(var t,e=w(this.graphicsPath.instructions);!(t=e()).done;){var i=t.value,r=i.action,n=i.data;switch(r){case"bezierCurveTo":this.bezierCurveTo(n[0],n[1],n[2],n[3],n[4],n[5],n[6]);break;case"moveTo":this.moveTo(n[0],n[1]);break;case"ellipse":this.ellipse(n[0],n[1],n[2],n[3],n[4]);break;case"polyStar":this.polyStar(n[0],n[1],n[2],n[3],n[4],n[5],n[6]);break;case"rect":this.rect(n[0],n[1],n[2],n[3],n[4]);break;case"closePath":this.closePath()}}this.endPoly()},e.bezierCurveTo=function(t,e,i,r,n,s,a){this.ensurePoly();var o=this.currentPoly;return Mh(o.points,o.lastX,o.lastY,t,e,i,r,n,s,a),this},e.moveTo=function(t,e){return this.startPoly(t,e),this},e.closePath=function(){return this.endPoly(!0),this},e.ellipse=function(t,e,i,r,n){return this.drawShape(new Lh(t,e,i,r),n),this},e.polyStar=function(t,e,i,r,n,s,a){return this.drawShape(new Fh(t,e,i,r,n,s),a),this},e.rect=function(t,e,i,r,n,s){return this.drawShape(new Vh(t,e,i,r,n),s),this},e.drawShape=function(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this},e.startPoly=function(t,e){var i=this.currentPoly;return i&&this.endPoly(),(i=new Sh).points.push(t,e),this.currentPoly=i,this},e.endPoly=function(t){void 0===t&&(t=!1);var e=this.currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this.currentPoly=null,this},e.ensurePoly=function(t){this.currentPoly||(this.currentPoly=new Sh,this.currentPoly.points.push(0,0))},t}(),Dh=function(){function t(){this.instructions=[],this.dirty=!1}var e=t.prototype;return e.bezierCurveTo=function(t,e,i,r,n,s,a){return this.instructions.push({action:"bezierCurveTo",data:[t,e,i,r,n,s,a]}),this.dirty=!0,this},e.moveTo=function(t,e){return this.instructions.push({action:"moveTo",data:[t,e]}),this.dirty=!0,this},e.closePath=function(){return this.instructions.push({action:"closePath",data:[]}),this.dirty=!0,this},e.ellipse=function(t,e,i,r,n){return this.instructions.push({action:"ellipse",data:[t,e,i,r,n]}),this.dirty=!0,this},e.rect=function(t,e,i,r,n,s){return this.instructions.push({action:"rect",data:[t,e,i,r,n,s]}),this.dirty=!0,this},e.polyStar=function(t,e,i,r,n,s,a){return this.instructions.push({action:"polyStar",data:[t,e,i,r,n,s,a]}),this.dirty=!0,this},e.clear=function(){return this.instructions.length=0,this.dirty=!0,this},Pe(t,[{key:"shapePath",get:function(){return this._shapePath||(this._shapePath=new Nh(this)),this.dirty&&(this.dirty=!1,this._shapePath.buildPath()),this._shapePath}}]),t}();function kh(t,e){return!e||"object"!==C(e)&&"function"!=typeof e?ho(t):e}var zh=new(function(){function t(){this.elements=[]}var e=t.prototype;return e.dispose=function(){this.elements.forEach((function(t){return t.remove()})),this.elements.length=0},e.getCanvas=function(){if(0!==this.elements.length){var t=this.elements.shift();return ot(t),t}if(wo(To))return r._createOffscreenCanvas(10,10);var e=i.createElement("canvas");return e.getContext("2d",{willReadFrequently:!0}),e},e.saveCanvas=function(t){t.width=1,t.height=1,this.elements.length<3?D(this.elements,t):t.remove()},t}()),Uh=function(){function t(t){this.width=0,this.height=0;var e=t.textHeight,i=void 0===e?100:e,r=t.textWidth,n=void 0===r?100:r,s=t.textOverflow,a=void 0===s?ce.clip:s,o=t.textBaseline,u=void 0===o?le.top:o,h=t.textAlign,c=void 0===h?fe.left:h,l=t.text,f=void 0===l?" ":l,d=t.letterSpace,p=void 0===d?0:d,m=t.autoWidth,v=void 0!==m&&m,y=t.fontSize,g=t.lineHeight,x=void 0===g?y:g,b=y+p;this.autoWidth=v,this.maxTextWidth=f.length*b,this.width=n,this.height=i,this.letterSpace=p,this.overflow=a,this.textBaseline=u,this.textAlign=c,this.lineHeight=x}var e=t.prototype;return e.getOffsetY=function(t,e,i,r){var n=t.outlineWidth,s=t.fontScale,a=(i-r)/3,o=r+n*s,u=i*(e-1),h=0;switch(this.textBaseline){case le.top:h=o+a;break;case le.middle:h=(this.height*s-u+o)/2;break;case le.bottom:h=this.height*s-u-a}return h},e.getOffsetX=function(t,e){var i=0;switch(this.textAlign){case fe.left:i=t.outlineWidth*t.fontScale;break;case fe.middle:i=(this.width*t.fontScale-e)/2;break;case fe.right:i=this.width*t.fontScale-e}return i},e.setSize=function(t,e){this.width=t,this.height=e},t}(),Bh=function(t){this.isUnderline=!1,this.underlineHeight=1,this.isOutlined=!1,this.outlineWidth=0,this.hasShadow=!1,this.fontDesc="",this.fontScale=2,this.fontOffset=0;var e,i,r,n,s,a,o=t.textColor,u=void 0===o?[1,1,1,1]:o,h=t.fontSize,c=void 0===h?40:h,l=t.outline,f=t.shadow,d=t.fontWeight,p=void 0===d?"normal":d,m=t.fontStyle,v=void 0===m?"normal":m,y=t.fontFamily,g=void 0===y?"sans-serif":y;(this.textColor=u,this.textWeight=p,this.fontStyle=v,this.fontFamily=g,this.fontSize=c,l)&&(this.isOutlined=!0,this.outlineColor=null!=(e=l.outlineColor)?e:[1,1,1,1],this.outlineWidth=null!=(i=l.outlineWidth)?i:1,this.fontOffset+=this.outlineWidth);f&&(this.hasShadow=!0,this.shadowBlur=null!=(r=f.shadowBlur)?r:2,this.shadowColor=null!=(n=f.shadowColor)?n:[0,0,0,1],this.shadowOffsetX=null!=(s=f.shadowOffsetX)?s:0,this.shadowOffsetY=null!=(a=f.shadowOffsetY)?a:0);this.fontStyle!==pe.normal&&(this.fontOffset+=this.fontSize*Math.tan(.20943951))},Gh=["serif","sans-serif","monospace","courier"],jh=0,Xh=function(t){function e(e,i){var r;if((r=t.call(this,e)||this).isDirty=!0,r.lineCount=0,r.maxLineWidth=0,r.SCALE_FACTOR=.1,r.ALPHA_FIX_VALUE=1/255,r.name="MText"+jh++,i&&r.fromData(i),r.canvas=zh.getCanvas(),zh.saveCanvas(r.canvas),r.context=r.canvas.getContext("2d",{willReadFrequently:!0}),!i)return kh(r);var n=i.options;return r.updateWithOptions(n),r.updateTexture(),r}Qt(e,t);var i=e.prototype;return i.onUpdate=function(e){t.prototype.onUpdate.call(this,e),this.updateTexture()},i.fromData=function(e){t.prototype.fromData.call(this,e);var i=e.interaction,r=e.options;this.interaction=i,this.updateWithOptions(r),this.renderText(r),this.material.setColor("_Color",new ii(1,1,1,1))},i.updateWithOptions=function(t){},i.updateTexture=function(t){},e}(Ls);Xh=S([Ne(_e.TextComponent)],Xh);var Hh=function(){function t(){}var e=t.prototype;return e.renderText=function(t){this.updateTexture()},e.updateWithOptions=function(t){this.textStyle=new Bh(t),this.textLayout=new Uh(t),this.text=t.text.toString(),this.lineCount=this.getLineCount(t.text,!0)},e.getLineCount=function(t,e){for(var i=this.context,r=this.textLayout,n=r.letterSpace,s=r.overflow,a=e?this.textStyle.fontSize/10:1/this.textStyle.fontScale,o=this.textLayout.width+this.textStyle.fontOffset,u=1,h=0,c=0;c<t.length;c++){var l,f,d=t[c],p=(null!=(f=null==i||null==(l=i.measureText(d))?void 0:l.width)?f:0)*a;h+=n,s===ce.display?"\n"===d?(u++,h=0):(h+=p,this.maxLineWidth=Math.max(this.maxLineWidth,h)):((h+p>o&&c>0||"\n"===d)&&(u++,this.maxLineWidth=Math.max(this.maxLineWidth,h),h=0),"\n"!==d&&(h+=p))}return u},e.setFontSize=function(t){if(this.textStyle.fontSize!==t){var e=this.textStyle.fontSize-t;this.textLayout.lineHeight+=e,this.textStyle.fontSize=t,this.isDirty=!0}},e.setFontWeight=function(t){this.textStyle.textWeight!==t&&(this.textStyle.textWeight=t,this.isDirty=!0)},e.setFontStyle=function(t){this.textStyle.fontStyle!==t&&(this.textStyle.fontStyle=t,this.isDirty=!0)},e.setText=function(t){this.text!==t&&(this.text=t.toString(),this.lineCount=this.getLineCount(t,!1),this.isDirty=!0)},e.setTextAlign=function(t){this.textLayout.textAlign!==t&&(this.textLayout.textAlign=t,this.isDirty=!0)},e.setTextBaseline=function(t){this.textLayout.textBaseline!==t&&(this.textLayout.textBaseline=t,this.isDirty=!0)},e.setTextColor=function(t){this.textStyle.textColor!==t&&(this.textStyle.textColor=t,this.isDirty=!0)},e.setFontFamily=function(t){this.textStyle.fontFamily!==t||ht(t)?(this.textStyle.fontFamily=t,this.isDirty=!0):console.warn("The font is either the current font or an risky font family.")},e.setOutlineColor=function(t){this.textStyle.outlineColor!==t&&(this.textStyle.outlineColor=t,this.isDirty=!0)},e.setOutlineWidth=function(t){this.textStyle.outlineWidth!==t&&(this.textStyle.outlineWidth=t,this.isDirty=!0)},e.setShadowBlur=function(t){this.textStyle.shadowBlur!==t&&(this.textStyle.shadowBlur=t,this.isDirty=!0)},e.setOverflow=function(t){this.textLayout.overflow=t,this.isDirty=!0},e.setShadowColor=function(t){this.textStyle.shadowColor!==t&&(this.textStyle.shadowColor=t,this.isDirty=!0)},e.setShadowOffsetX=function(t){this.textStyle.shadowOffsetX!==t&&(this.textStyle.shadowOffsetX=t,this.isDirty=!0)},e.setShadowOffsetY=function(t){this.textStyle.shadowOffsetY!==t&&(this.textStyle.shadowOffsetY=t,this.isDirty=!0)},e.setFontScale=function(t){this.textStyle.fontScale!==t&&(this.textStyle.fontScale=t,this.isDirty=!0)},e.setAutoWidth=function(t){this.textLayout.autoWidth!==t&&(this.textLayout.autoWidth=t,this.isDirty=!0)},e.updateTexture=function(t){if(void 0===t&&(t=!0),this.isDirty&&this.context&&this.canvas){var e=this.context,i=this.textStyle,r=this.textLayout,n=i.fontScale,s=(r.width+i.fontOffset)*n,a=r.lineHeight*this.lineCount,o=i.fontSize*n,u=r.lineHeight*n;i.fontDesc=this.getFontDesc(o),this.char=(this.text||"").split(""),this.canvas.width=s,r.autoWidth?(this.canvas.height=a*n,this.item.transform.size.set(1,a/r.height)):this.canvas.height=r.height*n;var h=this.canvas.height;e.fillStyle="rgba(255, 255, 255, 0.0039)",t||(e.translate(0,h),e.scale(1,-1)),this.maxLineWidth>s&&r.overflow===ce.display?e.font=this.getFontDesc(o*s/this.maxLineWidth):e.font=i.fontDesc,e.clearRect(0,0,s,h),i.hasShadow&&this.setupShadow(),i.isOutlined&&this.setupOutline(),e.fillStyle="rgba("+i.textColor[0]+", "+i.textColor[1]+", "+i.textColor[2]+", "+i.textColor[3]+")";for(var c=[],l=0,f=r.getOffsetY(i,this.lineCount,u,o),d=[],p=[],m=0;m<this.char.length;m++){var v=this.char[m],y=e.measureText(v);((l+=r.letterSpace*n)+y.width>s&&m>0||"\n"===v)&&(c.push({y:f,width:l,chars:d,charOffsetX:p}),l=0,f+=u,d=[],p=[]),"\n"!==v&&(d.push(v),p.push(l),l+=y.width)}c.push({y:f,width:l,chars:d,charOffsetX:p}),c.forEach((function(t){var n=r.getOffsetX(i,t.width);t.chars.forEach((function(r,s){i.isOutlined&&e.strokeText(r,n+t.charOffsetX[s],t.y),e.fillText(r,n+t.charOffsetX[s],t.y)}))})),i.hasShadow&&(e.shadowColor="transparent");var g=e.getImageData(0,0,this.canvas.width,this.canvas.height),x=Yi.createWithData(this.engine,{data:new Uint8Array(g.data),width:g.width,height:g.height},{flipY:t,magFilter:fi.LINEAR,minFilter:fi.LINEAR,wrapS:fi.CLAMP_TO_EDGE,wrapT:fi.CLAMP_TO_EDGE});this.renderer.texture=x,this.material.setTexture("_MainTex",x),this.isDirty=!1}},e.getFontDesc=function(t){var e=this.textStyle,i=e.fontSize,r=e.fontScale,n=e.fontFamily,s=e.textWeight,a=e.fontStyle,o=(t||i*r).toString()+"px ";return Gh.includes(n)?o+=n:o+='"'+n+'"',s!==de.normal&&(o=s+" "+o),a!==pe.normal&&(o=a+" "+o),o},e.setupOutline=function(){var t=this.context,e=this.textStyle,i=e.outlineColor,r=e.outlineWidth,n=i[0],s=i[1],a=i[2],o=i[3];t&&(t.strokeStyle="rgba("+255*n+", "+255*s+", "+255*a+", "+o+")",t.lineWidth=2*r)},e.setupShadow=function(){var t=this.context,e=this.textStyle,i=e.outlineColor,r=e.shadowBlur,n=e.shadowOffsetX,s=e.shadowOffsetY,a=i[0],o=i[1],u=i[2],h=i[3];t&&(t.shadowColor="rgba("+255*a+", "+255*o+", "+255*u+", "+h+")",t.shadowBlur=r,t.shadowOffsetX=n,t.shadowOffsetY=-s)},t}();Ct(Xh,[Hh]);var Yh=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e}(qt),Wh=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e}(ze),Zh=function(t){function e(){return t.apply(this,arguments)}return Qt(e,t),e}(ze);S([De()],Zh.prototype,"buffer",void 0),Zh=S([Ne(_e.BinaryAsset)],Zh);var qh=function(){function t(){}return t.serialize=function(e,i){e.toData(),i||(i={});var r=ke(e);if(r)for(var n,s=w(Object.keys(r));!(n=s()).done;){var a=n.value,o=e[a];"number"==typeof o||"string"==typeof o||"boolean"==typeof o||t.checkTypedArray(o)?i[a]=o:gt(o)?(i[a]||(i[a]=[]),t.serializeArrayProperty(o,i[a],0)):ze.is(o)?i[a]={id:o.getInstanceId()}:bt(o)&&(i[a]||(i[a]={}),t.serializeObjectProperty(o,i[a],0))}for(var u,h=w(Object.keys(e.defination));!(u=h()).done;){var c=u.value,l=e.defination[c];"number"==typeof l||"string"==typeof l||"boolean"==typeof l||t.checkTypedArray(l)?i[c]=l:gt(l)?(i[c]||(i[c]=[]),t.serializeArrayProperty(l,i[c],0)):ze.is(l)?i[c]={id:l.getInstanceId()}:bt(l)&&(i[c]||(i[c]={}),t.serializeObjectProperty(l,i[c],0))}return i},t.deserialize=function(e,i){i.defination=e;var r=ke(i),n=i.engine;if(r)for(var s,a=w(Object.keys(r));!(s=a()).done;){var o=s.value,u=e[o];if(void 0!==u){var h=r[o].type;i[o]=t.deserializeProperty(u,n,0,h)}}i.fromData(i.defination)},t.checkTypedArray=function(t){return A(t,Int8Array)||A(t,Uint8Array)||A(t,Uint8ClampedArray)||A(t,Int16Array)||A(t,Uint16Array)||A(t,Int32Array)||A(t,Uint32Array)||A(t,Float32Array)||A(t,Float64Array)||A(t,ArrayBuffer)},t.checkDataPath=function(t){return!!(bt(t)&&1===Object.keys(t).length&&"id"in t&&yt(t.id)&&32===t.id.length)},t.checkGLTFNode=function(t){return bt(t)&&void 0!==t.nodeIndex&&void 0!==t.isJoint},t.checkImageSource=function(t){return Tt(t)||A(t,c)},t.deserializeProperty=function(e,i,r,n,s){if(void 0===s&&(s=!0),!(r>14)){if(gt(e)){for(var a,o=[],u=w(e);!(a=u()).done;){var h=a.value;o.push(t.deserializeProperty(h,i,r+1,n,s))}return o}if(t.checkDataPath(e)){var c=i.findObject(e);return s?c:e}if(bt(e)&&e.constructor===Object){var l;l=n?new n:{};for(var f,d=w(Object.keys(e));!(f=d()).done;){var p=f.value;l[p]=t.deserializeProperty(e[p],i,r+1,void 0,s)}return l}return e}console.error("The nested object layers of the serialized data exceed the maximum limit.")},t.serializeObjectProperty=function(e,i,r){if(r>14)console.error("The nested object layers of the serialized data exceed the maximum limit.");else{i||(i={});for(var n,s=w(Object.keys(e));!(n=s()).done;){var a=n.value,o=e[a];"number"==typeof o||"string"==typeof o||"boolean"==typeof o||t.checkTypedArray(e)?i[a]=o:gt(o)?(i[a]||(i[a]=[]),t.serializeArrayProperty(o,i[a],r+1)):ze.is(o)?i[a]={id:o.getInstanceId()}:bt(o)&&(i[a]||(i[a]={}),t.serializeObjectProperty(o,i[a],r+1))}}},t.serializeArrayProperty=function(e,i,r){if(r>14)console.error("The nested object layers of the serialized data exceed the maximum limit.");else{i||(i=[]);for(var n=0;n<e.length;n++){var s=e[n];"number"==typeof s||"string"==typeof s||"boolean"==typeof s||t.checkTypedArray(e)?i[n]=s:gt(s)?(i[n]||(i[n]=[]),t.serializeArrayProperty(s,i[n],r+1)):ze.is(s)?i[n]={id:s.getInstanceId()}:bt(s)&&(i[n]||(i[n]={}),t.serializeObjectProperty(s,i[n],r+1))}}},t}(),Kh=function(){function t(t){this.engine=t}var e=t.prototype;return e.loadGUID=function(e){if(!e)return null;var i,r=e.id,n=this.findData(r);if(n){switch(n.dataType){case _e.Material:i=cr.create(this.engine);break;case _e.Geometry:i=Cr.create(this.engine);break;case _e.Texture:i=Yi.create(this.engine);break;default:var s=t.getClass(n.dataType);s&&(i=new s(this.engine))}if(i)return i.setInstanceId(n.id),this.engine.addInstance(i),qh.deserialize(n,i),i;console.error("Constructor for DataType: "+n.dataType+" not found.")}else console.error("Object data with uuid: "+r+" not found.")},e.findData=function(t){return this.engine.jsonSceneData[t]},t.getClass=function(t){return Ve[t]},t}(),Qh=function(){function t(){}return t.prototype.loadGUID=function(t){return E((function(){return O(this,(function(t){return[2,void 0]}))}))()},t}();function Jh(t,e){if(!t.includes(e))return t.push(e),!0}function $h(t){if(Number.isFinite(t))return[$t.CONSTANT,t];if(t){var e=t[0],i=t[1];if(Array.isArray(e))return;if("static"===e||e===$t.CONSTANT)return[$t.CONSTANT,t[1]];if("lines"===e)return[$t.LINE,t[1]];if(e===$t.LINE){var r=i.map((function(t){return[te.LINE,t]}));return[$t.BEZIER_CURVE,r]}return"curve"===e||e===$t.CURVE?[$t.BEZIER_CURVE,bc(i)]:t}}function tc(t,e){return Array.isArray(t)&&"random"===t[0]?[$t.CONSTANT,t[1][e]]:$h(t)}function ec(t){return t&&"color"===t[0]?sc(t[1],!0):[1,1,1,1]}function ic(t,e){if(t)return"colors"===t[0]?[$t.COLORS,t[1].map((function(t){return sc(t,e)}))]:"gradient"===t[0]?nc(t[1],e):"color"===t[0]?[$t.RGBA_COLOR,sc(t[1],e)]:t}function rc(t){return t&&"random"===t[0]?[$t.RANDOM,t[1]]:$h(t)}function nc(t,e){if(t){var i=[];return Object.getOwnPropertyNames(t).forEach((function(r){var n=function(t){var e=/^(-)?([\d+.]+)%$/.exec(t);if(e)return+e[2]/100*(e[1]?-1:1);return+t}(r),s=sc(t[r],e);i.push([n,s[0],s[1],s[2],s[3]])})),i=i.sort((function(t,e){return t[0]-e[0]})),[$t.GRADIENT_COLOR,i]}}function sc(t,e){var i;if("string"==typeof t){t=t.replace(/[\s\t\r\n]/g,"");var r=/rgba?\(([.\d]+),([.\d]+),([.\d]+),?([.\d]+)?\)/.exec(t);if(r){var n=+r[4];i=[+r[1],+r[2],+r[3],isNaN(n)?255:Math.round(255*n)]}else/^#[a-f\d]{3}$/i.test(t)?i=[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16),255]:(r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t))&&(i=[parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16),255])}else A(t,Array)&&(i=[t[0],t[1],t[2],isNaN(t[3])?255:Math.round(255*t[3])]);return e&&(i=ac(i)),i}function ac(t){if(Array.isArray(t))return t.map((function(t){return Number.isFinite(t/255)?Number((t/255).toFixed(6)):0}))}function oc(t,e){return Array.isArray(t)?t[0]===$t.GRADIENT_COLOR?t:("gradient"===t[0]||"color"===t[0])&&nc(t[1],e):nc(t,e)}function uc(t){if(t){if(3===t.length)return[$t.CONSTANT_VEC3,t];var e=t[0];if("path"===e||"bezier"===e||e===$t.BEZIER_PATH||e===$t.LINEAR_PATH){var i=t[1],r=i[0],n=i[1],s=i[2],a=bc(r);if(!s){s=[];for(var o=0;o<n.length;o++){var u=n[o].slice();0===o?s.push(u):o<n.length-1?(s.push(u),s.push(u)):s.push(u)}}return[$t.BEZIER_CURVE_PATH,[a,n,s]]}return t}}function hc(t){for(var e,i=w(Object.keys(t));!(e=i()).done;){var r=e.value;t[r]=Number(t[r])}return t}function cc(t){for(var e,i=w(Object.keys(t));!(e=i()).done;){var r=e.value;void 0===t[r]&&delete t[r]}return t}var lc,fc=Math.cos,dc=Math.sin,pc=Math.PI/180,mc=180/Math.PI;function vc(t,e){return t?[t[0]-.5,.5-t[1]]:e?gc[e]:[0,0]}var yc,gc=((lc={})[Yt.PARTICLE_ORIGIN_CENTER]=[0,0],lc[Yt.PARTICLE_ORIGIN_CENTER_BOTTOM]=[0,-.5],lc[Yt.PARTICLE_ORIGIN_CENTER_TOP]=[0,.5],lc[Yt.PARTICLE_ORIGIN_LEFT_TOP]=[-.5,.5],lc[Yt.PARTICLE_ORIGIN_LEFT_CENTER]=[-.5,0],lc[Yt.PARTICLE_ORIGIN_LEFT_BOTTOM]=[-.5,-.5],lc[Yt.PARTICLE_ORIGIN_RIGHT_CENTER]=[.5,0],lc[Yt.PARTICLE_ORIGIN_RIGHT_BOTTOM]=[.5,-.5],lc[Yt.PARTICLE_ORIGIN_RIGHT_TOP]=[.5,.5],lc);function xc(t,e,i,r){var n=i[0],s=i[1],a=r[0],o=a-n;return[[n+(a-n)/3,s+(t*=o)/3],[a-(a-n)/3,r[1]-(e*=o)/3]]}function bc(t){for(var e=-1e6,i=1e6,r=0;r<t.length;r++)e=Math.max(e,t[r][1]),i=Math.min(i,t[r][1]);for(var n=[[t[0][0],t[0][1]]],s=0;s<t.length-1;s++){var a=t[s][3]*(e-i),o=t[s+1][2]*(e-i),u=[t[s][0],t[s][1]],h=[t[s+1][0],t[s+1][1]];if(u[0]!=h[0]){var c=xc(a,o,u,h),l=c[0],f=c[1];n[n.length-1].push(l[0]),n[n.length-1].push(l[1]),n.push([f[0],f[1],h[0],h[1]])}else n[n.length-1].push(h[0]),n[n.length-1].push(h[1])}return n.map((function(t,e){return 0===e?[te.EASE_OUT,t]:e===n.length-1?[te.EASE_IN,t]:[te.EASE,t]}))}function Tc(t){return t.compositions.forEach((function(t){t.items.forEach((function(t){t.type===Xt.null&&t.endBehavior===ee.destroy&&(t.endBehavior=ee.freeze)}))})),t.version=Vt["2_1"],t}var Ec=new Map,_c=new Map;function wc(t){for(var e,i=w(t.components);!(e=i()).done;){var r=e.value;if(r.dataType===_e.ShapeComponent){var n=r;if(n.type===ge.Custom){var s,a=n;(null==(s=a.shapes)?void 0:s.length)>0&&a.shapes[0].fill&&(a.fill=a.shapes[0].fill);for(var o,u=new Array(a.easingIns.length),h=new Array(a.easingOuts.length).fill(!1),c=w(a.shapes);!(o=c()).done;)for(var l,f=w(o.value.indexes);!(l=f()).done;){var d=l.value,p=a.points[d.point],m=a.easingIns[d.easingIn],v=a.easingOuts[d.easingOut];u[d.easingIn]||(m.x-=p.x,m.y-=p.y,u[d.easingIn]=!0),h[d.easingOut]||(v.x-=p.x,v.y-=p.y,h[d.easingOut]=!0)}}}}return t}function Ac(t){Ec.clear(),_c.clear();for(var e,i=t.compositions,r=t.items,n=w(t.components);!(e=n()).done;){var s=e.value;Ec.set(s.id,s)}for(var a,o=w(r);!(a=o()).done;){var u=a.value;_c.set(u.id,u)}for(var h,c=w(i);!(h=c()).done;){Sc(h.value)}return t}function Cc(t){var e;null==(e=t.plugins)||e.forEach((function(e,i){"richtext"===e&&(t.plugins[i]="rich-text")}));for(var i,r=w(t.items);!(i=r()).done;){var n=i.value;if(n.type===Xt.sprite){var s=Ec.get(n.components[0].id);if(s){var a=s.renderer.shape,o=void 0;o=Number.isInteger(a)?t.shapes[a]:a,s.renderer.shape=o}}}for(var u,h=t.compositionId,c={},l=w(t.compositions);!(u=l()).done;){var f=u.value,d=wt();c[f.id]=d,f.id===h&&(t.compositionId=d),f.id=d;var p={id:wt(),dataType:"CompositionComponent",items:f.items,timelineAsset:f.timelineAsset,sceneBindings:f.sceneBindings,startTime:f.startTime};f.timelineAsset=void 0,f.sceneBindings=void 0,f.startTime=void 0,f.components=[{id:p.id}],t.components.push(p)}for(var m,v=w(t.items);!(m=v()).done;){var y=m.value;if(y.content){var g=y.content.options;g&&void 0!==g.refId&&(g.refId=c[g.refId])}}return t}function Sc(t){for(var e,i=w(t.items);!(e=i()).done;){var r=e.value,n=_c.get(r.id);if(!n)return;if(n.type===Xt.sprite||n.type===Xt.particle||n.type===Xt.spine||n.type===Xt.text||n.type===Xt.richtext||n.type===Xt.video||n.type===Xt.shape){var s=Ec.get(n.components[0].id);s&&Oc(s)}}}function Oc(t){var e=t.renderer,i=null==e?void 0:e.maskMode;i&&i!==ui.NONE&&(i===ui.MASK?(t.mask={isMask:!0},yc=t.id):i!==zt.OBSCURED&&i!==zt.REVERSE_OBSCURED||(t.mask={inverted:i===zt.REVERSE_OBSCURED,reference:{id:yc}}))}function Rc(t){for(var e,i,r,n=function(){var t=u.value;t.endBehavior!==ve&&t.endBehavior!==me||(t.endBehavior=ee.freeze),t.items=t.items.filter((function(t){return"8"!==t.type})),t.items.forEach((function(t){t.type===Xt.particle&&(t.content.filter&&delete t.content.filter)}));for(var e,i=w(t.items);!(e=i()).done;){var r=e.value;h[r.id]=wt(),r.oldId=r.id,r.id=h[r.id],c[r.id]=r}t.items.forEach((function(e,i){if(e.parentId)if(e.parentId.includes("^")){var r=e.parentId.split("^")[0],n=e.parentId.split("^")[1];e.parentId=h[r]+"^"+n}else e.parentId=h[e.parentId];s.items.push(e),t.items[i]={id:e.id}}));var n=_i({},t,{timelineAsset:{id:""},sceneBindings:[]});s.compositions.push(n),function(t,e,i){for(var r,n=[],s=[],a=[],o={tracks:[],id:wt(),dataType:"TimelineAsset"},u=w(t.items);!(r=u()).done;){var h=e[r.value.id],c=[],l={id:wt(),dataType:"ActivationPlayableAsset"};a.push(l);var f={id:wt(),dataType:"ActivationTrack",children:[],clips:[{start:h.delay,duration:h.duration,endBehavior:h.endBehavior,asset:{id:l.id}}]};if(c.push({id:f.id}),s.push(f),h.type!==Xt.particle){var d={id:wt(),dataType:"TransformPlayableAsset",sizeOverLifetime:h.content.sizeOverLifetime,rotationOverLifetime:h.content.rotationOverLifetime,positionOverLifetime:h.content.positionOverLifetime};a.push(d);var p={id:wt(),dataType:"TransformTrack",children:[],clips:[{start:h.delay,duration:h.duration,endBehavior:h.endBehavior,asset:{id:d.id}}]};c.push({id:p.id}),s.push(p)}if(h.type===Xt.sprite||h.type===Xt.text){var m={id:wt(),dataType:"SpriteColorPlayableAsset",colorOverLifetime:h.content.colorOverLifetime};a.push(m);var v={id:wt(),dataType:"SpriteColorTrack",children:[],clips:[{start:h.delay,duration:h.duration,endBehavior:h.endBehavior,asset:{id:m.id}}]};c.push({id:v.id}),s.push(v)}if(h.type===Xt.composition){var y={id:wt(),dataType:"SubCompositionPlayableAsset"};a.push(y);var g={id:wt(),dataType:"SubCompositionTrack",children:[],clips:[{start:h.delay,duration:h.duration,endBehavior:h.endBehavior,asset:{id:y.id}}]};c.push({id:g.id}),s.push(g)}var x={id:wt(),dataType:"ObjectBindingTrack",children:c,clips:[]};s.push(x),o.tracks.push({id:x.id}),n.push({key:{id:x.id},value:{id:h.id}})}for(var b,T=[],E=w(s);!(b=E()).done;){var _=b.value;T.push({id:_.id})}t.timelineAsset={id:o.id},t.sceneBindings=n,i.miscs.push(o);for(var A,C=w(s);!(A=C()).done;){var S=A.value;i.miscs.push(S)}for(var O,R=w(a);!(O=R()).done;){var M=O.value;i.miscs.push(M)}}(n,c,s)},s=_i({},t,{items:[],compositions:[],components:[],materials:[],shaders:[],geometries:[],animations:[],miscs:[]}),a=w(s.images);!(i=a()).done;){i.value.id=wt()}if(null!=(e=s).textures||(e.textures=[]),s.textures.forEach((function(t){var e;t.id=wt(),t.dataType=_e.Texture,t.source={id:null==(e=s.images[t.source])?void 0:e.id}})),s.textures.length<s.images.length)for(var o=s.textures.length;o<s.images.length;o++)s.textures.push({id:wt(),dataType:_e.Texture,source:{id:s.images[o].id},flipY:!0});t.bins&&(r=t.bins,s.bins=r.map((function(t){return{url:t.url,dataType:"BinaryAsset",id:wt()}})));for(var u,h={},c={},l=w(t.compositions);!(u=l()).done;)n();for(var f,d=w(s.items);!(f=d()).done;){var p=f.value;if(p.content){if(p.content.renderer&&void 0!==p.content.renderer.texture){var m=p.content.renderer.texture;p.content.renderer.texture={id:s.textures[m].id}}if(p.content.trails&&void 0!==p.content.trails.texture){var v=p.content.trails.texture;p.content.trails.texture={id:s.textures[v].id}}}if(p.transform){var y,g,x,b=[].concat(null!=(y=p.transform.position)?y:[0,0,0]),T=[].concat(null!=(g=p.transform.rotation)?g:[0,0,0]),E=[].concat(null!=(x=p.transform.scale)?x:[1,1,1]);if(Object.assign(p,{transform:{position:{x:b[0],y:b[1],z:b[2]},eulerHint:{x:T[0],y:T[1],z:T[2]},scale:{x:E[0],y:E[1],z:E[0]}}}),p.type===Xt.sprite&&(p.transform.size={x:E[0],y:E[1]},p.transform.scale={x:1,y:1,z:1}),p.type===Xt.sprite){var _=p.content;_.renderer||(_.renderer={});var A,C,S,O,R=_.renderer,M=vc(R.anchor,R.particleOrigin),I=p.transform.size;if(!R.anchor&&void 0!==R.particleOrigin)p.transform.position.x+=-M[0]*(null!=(A=null==I?void 0:I.x)?A:1),p.transform.position.y+=-M[1]*(null!=(C=null==I?void 0:I.y)?C:1);p.transform.anchor={x:M[0]*(null!=(S=null==I?void 0:I.x)?S:1),y:M[1]*(null!=(O=null==I?void 0:I.y)?O:1)}}}if(p.type===Xt.particle){var P=p.content;P.renderer||(P.renderer={});var L=P.renderer;P.renderer.anchor=vc(L.anchor,L.particleOrigin)}if(p.type===Xt.camera&&p.content.positionOverLifetime&&0!==Object.keys(p.content.positionOverLifetime).length&&(p.content.positionOverLifetime.asMovement=!0),void 0!==p.pn){var F=p.pn,V=t.plugins,N=void 0===V?[]:V;void 0!==F&&Number.isInteger(F)&&(p.pluginName=N[F])}switch("editor-gizmo"===p.pluginName&&(p.type="editor-gizmo"),"orientation-transformer"===p.pluginName&&(p.type="orientation-transformer"),p.content.options.target&&"editor-gizmo"===p.pluginName&&(p.content.options.target=h[p.content.options.target]),p.type===Xt.spine&&t.spines&&0!==t.spines.length&&Ic(t.spines[p.content.options.spine],p.content,s),p.type!==Xt.sprite&&p.type!==Xt.particle&&p.type!==Xt.mesh&&p.type!==Xt.skybox&&p.type!==Xt.light&&"camera"!==p.type&&p.type!==Xt.tree&&p.type!==Xt.interact&&p.type!==Xt.camera&&p.type!==Xt.text&&p.type!==Xt.spine&&"editor-gizmo"!==p.type&&"orientation-transformer"!==p.type||(p.components=[],s.components.push(p.content),p.content.id=wt(),p.content.item={id:p.id},p.dataType=_e.VFXItemData,p.components.push({id:p.content.id})),p.type!==Xt.null&&p.type!==Xt.composition||(p.components=[],p.dataType=_e.VFXItemData),p.type){case Xt.sprite:p.content.dataType=_e.SpriteComponent;break;case Xt.particle:p.content.dataType=_e.ParticleSystem;break;case Xt.mesh:p.content.dataType=_e.MeshComponent;break;case Xt.skybox:p.content.dataType=_e.SkyboxComponent;break;case Xt.light:p.content.dataType=_e.LightComponent;break;case"camera":p.content.dataType=_e.CameraComponent;break;case"editor-gizmo":p.content.dataType="GizmoComponent";break;case"orientation-transformer":p.content.dataType="OrientationComponent";break;case Xt.tree:p.content.dataType=_e.TreeComponent;break;case Xt.interact:p.content.dataType=_e.InteractComponent;break;case Xt.camera:p.content.dataType=_e.CameraController;break;case Xt.text:p.content.dataType=_e.TextComponent;break;case Xt.spine:p.content.dataType=_e.SpineComponent}}return s.version=Vt["3_0"],s}function Mc(t){if(t)for(var e,i=w(Object.keys(t));!(e=i()).done;){var r=e.value,n=t[r],s=Array.isArray(n);s&&2===n.length&&Array.isArray(n[1])?t[r]="path"===r?uc(n):$h(n):s||"object"!=typeof n||Mc(n)}}function Ic(t,e,i){e.resource={atlas:{bins:{id:i.bins[t.atlas[1][0]].id},source:t.atlas[1].slice(1)},skeleton:{bins:{id:i.bins[t.skeleton[1][0]].id},source:t.skeleton[1].slice(1)},skeletonType:t.skeletonType,images:t.images.map((function(t){return{id:i.textures[t].id}}))}}function Pc(t,e){var i,r=t.options,n=t.velocityOverLifetime||{},s={path:uc(null==(i=t.transform)?void 0:i.path),gravity:r.gravity,gravityOverLifetime:$h(r.gravityModifier),direction:r.direction,startSpeed:r.startSpeed,asMovement:n.asMovement,linearX:$h(n.linearX),linearY:$h(n.linearY),linearZ:$h(n.linearZ),asRotation:n.asRotation,orbCenter:n.orbCenter,orbitalX:$h(n.orbitalX),orbitalY:$h(n.orbitalY),orbitalZ:$h(n.orbitalZ),speedOverLifetime:$h(n.speedOverLifetime)};cc(s);var a={options:{startColor:ec(r.startColor)},positionOverLifetime:s};r.startSize&&(e.scale=[r.startSize,r.startSize/(r.sizeAspect||1),1]),r.startRotation&&(e.rotation?e.rotation[2]+=r.startRotation:e.rotation=[0,0,r.startRotation]);var o=t.rotationOverLifetime;if(o){var u=a.rotationOverLifetime={separateAxes:o.separateAxes,asRotation:o.asRotation};u.separateAxes?(u.x=$h(o.x),u.y=$h(o.y),u.z=$h(o.z)):u.z=$h(o.angularVelocity)}var h=t.colorOverLifetime;if(h){var c=a.colorOverLifetime={opacity:$h(h.opacity)};h.color&&(c.color=oc(h.color))}var l=t.sizeOverLifetime;return l&&(a.sizeOverLifetime={separateAxes:l.separateAxes,size:$h(l.size),x:$h(l.x),y:$h(l.y),z:$h(l.z)}),a}var Lc="2.5.0-alpha.6",Fc=/^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/,Vc=/^(\d+)\.(\d+)$/,Nc=!1;function Dc(t){if(!t||"object"!=typeof t)throw new Error("Invalid input: Expected a JSON object.");var e,i;(function(t){var e=t.playerVersion||{},i=e.web,r=void 0===i?"":i;if(r){var n,s,a=null!=(n=Fc.exec(r))?n:[],o=null!=(s=Fc.exec(Lc))?s:[],u=a[1],h=a[2],c=o[1],l=o[2];return Number(c)<Number(u)||Number(c)===Number(u)&&Number(l)<Number(h)}return!1})(t)&&console.warn("The JSON need higher than "+(null==(e=t.playerVersion)?void 0:e.web)+" runtime version(current: "+Lc+"). Some features may not work as expected.");if(function(t){var e,i=null==(e=t.version)?void 0:e.split(".");!i||Number(i[0])>2||2===Number(i[0])&&Number(i[1])>=2||t.compositions.forEach((function(t){t.items.forEach((function(t){t.type!==Xt.mesh&&t.type!==Xt.light||(t.endBehavior=1===t.endBehavior?ee.destroy:t.endBehavior)}))}))}(t),Fc.test(t.version))return Nc="0"===(null==(i=/^(\d+)/.exec(t.version))?void 0:i[0]),Cc(Ac(wc(Rc(Tc(function(t){var e;kc=Vt["1_0"];var i=t.plugins||[];(null==(e=t.bins)?void 0:e.length)&&(kc=Vt["1_3"]);var r,n=(t.requires||[]).slice(),s=t.images.map((function(e,i){return zc(e,i,t.imageTags||[])})),a=t.textures||s.map((function(t,e){return{source:e,flipY:!0}})),o={plugins:i,shapes:t.shapes||[],type:"ge",version:kc,playerVersion:null!=(r=t.playerVersion)?r:{web:"",native:""},compositionId:t.compositionId+"",compositions:t.compositions.map((function(t){return Uc(t,{plugins:i,requires:n})})),images:s,imgUsage:t._imgs,binUsage:t.binUsage,spines:t.spines,requires:t.requires,textures:a,bins:(t.bins||[]).slice()};t._textures&&(o._textures=t._textures);return o}(t))))));Nc=!1;var r=Vc.exec(t.version)||[],n=Number(r[1]),s=Number(r[2]);if(n)return(n<2||2===n&&s<4)&&(t=function(t){return t.compositions.map((function(t){for(var e,i=w(t.items);!(e=i()).done;)Mc(e.value.content)})),t}(t)),n<3&&(t=Rc(Tc(t))),r=Vc.exec(t.version)||[],n=Number(r[1]),s=Number(r[2]),n<4&&(s<2&&(t=wc(t)),s<3&&(t=Ac(t)),s<4&&(t=Cc(t))),t;throw new Error("Invalid JSON version: "+t.version+".")}var kc=Vt["1_0"];function zc(t,e,i){var r=i[e];if("string"==typeof t)return{id:wt(),renderLevel:r,url:t};if(t.template)return{id:wt(),url:t.url,template:t.template,webp:t.webp,renderLevel:r};if(t.compressed)return{id:wt(),url:t.url,compressed:{astc:t.compressed.android,pvrtc:t.compressed.iOS},webp:t.webp,renderLevel:r};if(t.url)return{id:wt(),url:t.url,webp:t.webp,renderLevel:r};if(t&&t.sourceType)return t;throw new Error("Invalid image type.")}function Uc(t,e){var i;void 0===e&&(e={});var r={id:t.id+"",camera:_i({clipMode:ye},t.camera),duration:t.duration,endBehavior:t.endBehavior,items:t.items.map((function(t){return Xc(t,e)})),name:t.name},n=t.startTime||t.st;n&&(r.startTime=n);var s=null==(i=t.meta)?void 0:i.previewSize;return s&&s[0]===s[1]&&0===s[0]&&(s=void 0),s&&(r.previewSize=s),r}var Bc,Gc=[0,0,0,1],jc=.5;function Xc(t,e){var i;void 0===e&&(e={});var r,n,s,a,o,u,h=Xt.base,c=t.endBehavior,l=NaN;if(t.content?(h=t.type||Xt.plugin,u=t.pn,o=t.pluginName,s=t.content,n=t.content,isNaN(u)&&!o&&(o=s.options.type),t.duration&&(l=t.duration),r=t.transform||y(n.transform)):t.particle?(h=Xt.particle,r=y((n=t.particle).transform,Nc,!0),s=function(t){var e=t.options,i=t.transform,r={type:Ut.NONE};if(t.shape){var n,s=null==(n=t.shape.shape)?void 0:n.replace(/([A-Z])/g,"_$1").toUpperCase().replace(/^_/,"");if(r=_i({},t.shape,{type:Ut[s]}),t.shape.upDirection){var a=t.shape.upDirection,o=a[0],u=a[1],h=a[2];0===o&&0===u&&0===h&&delete r.upDirection}}e.startTurbulence&&(r.turbulenceX=rc(e.turbulenceX),r.turbulenceY=rc(e.turbulenceY),r.turbulenceZ=rc(e.turbulenceZ));var c=t.emission;c.bursts&&c.bursts.length>0&&(c.bursts=c.bursts.map((function(t){return hc(t)}))),c.burstOffsets&&c.burstOffsets.length>0&&(c.burstOffsets=c.burstOffsets.map((function(t){return hc(t)}))),c.rateOverTime&&(c.rateOverTime=rc(c.rateOverTime));var l={renderer:t.renderer,shape:r,splits:t.splits,emission:c,options:{startLifetime:rc(e.startLifetime),start3DSize:!!e.start3DSize,startSize:rc(e.startSize),startSizeX:rc(e.startSizeX),startSizeY:rc(e.startSizeY),sizeAspect:rc(e.sizeAspect),maxCount:e.maxCount,startDelay:rc(e.startDelay),startColor:ic(e.startColor,!0),startRotationZ:rc(e.startRotation||e.startRotationZ),particleFollowParent:e.particleFollowParent}};e.start3DRotation&&(l.options.startRotationX=rc(e.startRotationX),l.options.startRotationY=rc(e.startRotationY)),i&&i.path&&(l.emitterTransform={path:uc(i.path)});var f=t.sizeOverLifetime;f&&(f.separateAxes?l.sizeOverLifetime={separateAxes:!0,x:rc(f.x),y:rc(f.y)}:l.sizeOverLifetime={size:rc(f.size)});var d=t.velocityOverLifetime||{},p=d.speedOverLifetime;p=p?$h(p):void 0,l.positionOverLifetime={gravity:e.gravity,gravityOverLifetime:$h(e.gravityModifier),startSpeed:rc(e.startSpeed),speedOverLifetime:p,asMovement:d.asMovement,linearX:rc(d.linearX),linearY:rc(d.linearY),linearZ:rc(d.linearZ),asRotation:d.asRotation,orbCenter:d.orbCenter,orbitalX:rc(d.orbitalX),orbitalY:rc(d.orbitalY),orbitalZ:rc(d.orbitalZ),forceTarget:d.forceTarget,target:d.target,forceCurve:$h(d.forceCurve)},cc(l.positionOverLifetime);var m=t.rotationOverLifetime;m&&(l.rotationOverLifetime={separateAxes:m.separateAxes,asRotation:m.asRotation,z:rc(m.separateAxes?m.z:m.angularVelocity)},m.separateAxes&&(l.rotationOverLifetime.y=$h(m.y),l.rotationOverLifetime.x=$h(m.x)));var v=t.colorOverLifetime;if(v){var y=l.colorOverLifetime={opacity:$h(v.opacity)};v.color&&(y.color=oc(v.color))}var g=t.textureSheetAnimation;g&&(l.textureSheetAnimation={row:g.row,col:g.col,total:g.total,animate:g.animate,cycles:$h(g.cycles),animationDelay:tc(g.animationDelay,0),animationDuration:tc(g.animationDuration,0)});var x=t.trails;x&&(l.trails={lifetime:rc(x.lifetime),dieWithParticles:x.dieWithParticles,maxPointPerTrail:x.maxPointPerTrail,minimumVertexDistance:x.minimumVertexDistance,widthOverTrail:$h(x.widthOverTrail),colorOverTrail:x.colorOverTrail&&oc(x.colorOverTrail,!1),blending:x.blending,colorOverLifetime:x.colorOverLifetime&&oc(x.colorOverLifetime,!1),inheritParticleColor:x.inheritParticleColor,occlusion:x.occlusion,transparentOcclusion:x.transparentOcclusion,orderOffset:x.orderOffset,sizeAffectsLifetime:x.sizeAffectsLifetime,sizeAffectsWidth:x.sizeAffectsWidth,texture:x.texture,parentAffectsPosition:x.parentAffectsPosition,opacityOverLifetime:rc(x.opacityOverLifetime)}),l.trails&&cc(l.trails);var b=t.interaction;return b&&(l.interaction={behavior:b.behavior,radius:b.radius,multiple:b.multiple}),l}(n)):t.sprite?(h=Xt.sprite,s=function(t,e){var i=Pc(t,e),r=t.textureSheetAnimation;return r&&(i.textureSheetAnimation={row:r.row,col:r.col,total:r.total||void 0,animate:r.animate}),i.renderer=t.renderer,t.splits&&(i.splits=t.splits),t.interaction&&(i.interaction=t.interaction),i}(n=t.sprite,r=y(n.transform,!1,!0))):t.cal?(h=Xt.null,s=Pc(n=t.cal,r=y(n.transform,!1,!0))):t.ui?(h=Xt.interact,r=y((n=t.ui).transform),s=function(t){var e,i=t.options;switch(i.type){case"click":e={type:Gt.CLICK,showPreview:i.showPreview,previewColor:i.previewColor&&ec(i.previewColor),behavior:i.behavior||jt.NOTIFY};break;case"drag":e={type:Gt.DRAG,enableInEditor:!!i.enableInEditor,dxRange:i.dxRange,dyRange:i.dyRange,target:i.target};break;case"message":e={type:Gt.MESSAGE}}return{options:e}}(n),r.scale=[n.options.width||1,n.options.height||1,1]):t.model&&(n=t.model,1===t.model.options.type&&(h=Xt.camera,r=y(n.transform),s=function(t){var e,i=t.options,r={options:{fov:i.fov,far:i.far,near:i.near,clipMode:i.clipMode}},n=t.velocityOverLifetime;if(n||(null==(e=t.transform)?void 0:e.path)){var s,a={path:uc(null==(s=t.transform)?void 0:s.path),linearX:$h(null==n?void 0:n.translateX),linearY:$h(null==n?void 0:n.translateY),linearZ:$h(null==n?void 0:n.translateZ)};cc(a),r.positionOverLifetime=a}var o=t.rotationOverLifetime;if(o){var u={separateAxes:o.separateAxes,x:$h(null==o?void 0:o.rotateX),y:$h(null==o?void 0:o.rotateY),z:o.separateAxes?$h(null==o?void 0:o.rotateZ):$h(o.rotation)};cc(u),r.rotationOverLifetime=u}return r}(n))),null==(i=s.renderer)?void 0:i.anchor){var f=new Float32Array(s.renderer.anchor);f[0]==jc&&f[1]==jc?delete s.renderer.anchor:e.requires&&Jh(e.requires,"anchor")}if(n){var d,p,m=null==(d=n.options)?void 0:d.looping;if(m)c=Array.isArray(m)?m[1]?ee.restart:ee.destroy:ee.restart;else c=c||(null==n||null==(p=n.options)?void 0:p.endBehavior)||ee.destroy;n.options.renderLevel&&(a=n.options.renderLevel),isNaN(l)&&(l=n.options.duration)}var v={type:h,name:t.name,delay:t.delay,duration:l,id:t.id+"",transform:r,endBehavior:c,renderLevel:a,content:s};return o?e.plugins?(Jh(e.plugins,o),v.pn=e.plugins.indexOf(o)):v.pluginName=o:Number.isInteger(u)&&(v.pn=u),t.parentId&&(v.parentId=t.parentId+""),v;function y(t,e,i){if(t){var r={},n=t.rotation;if(n&&(r.rotation=e?[-n[0],-n[1],-n[2]]:[n[0],n[1],n[2]],i)){var s=(a=Gc,o=r.rotation[0],u=r.rotation[1],h=r.rotation[2],c=fc(o*pc/2),l=fc(u*pc/2),f=fc(h*pc/2),d=dc(o*pc/2),p=dc(u*pc/2),m=dc(h*pc/2),a[0]=d*l*f+c*p*m,a[1]=c*p*f-d*l*m,a[2]=c*l*m+d*p*f,a[3]=c*l*f-d*p*m,a);r.rotation=function(t,e){var i,r,n,s=e[0],a=e[1],o=e[2],u=e[3],h=s+s,c=a+a,l=o+o,f=s*h,d=a*h,p=a*c,m=o*l,v=u*l,y=1-p-m,g=d-v,x=d+v,b=1-f-m,T=o*h-u*c,E=o*c+u*h,_=1-f-p;return t[1]=Math.asin((r=-1,(i=-T)>(n=1)?n:i<r?r:i))*mc,Math.abs(T)<.9999999?(t[0]=Math.atan2(E,_)*mc,t[2]=Math.atan2(x,y)*mc):(t[0]=0,t[2]=Math.atan2(-g,b)*mc),t}([],s)}return t.position&&(r.position=t.position),Array.isArray(t.scale)&&(r.scale=[t.scale[0]||1,t.scale[1]||1,t.scale[2]||1]),r}var a,o,u,h,c,l,f,d,p,m;return{}}}var Hc,Yc=((Bc={})[Nt.S]=[Nt.S,Nt.BPlus,Nt.APlus],Bc[Nt.A]=[Nt.A,Nt.BPlus,Nt.APlus],Bc[Nt.B]=[Nt.B,Nt.BPlus],Bc);function Wc(t,e){if(!t||!e)return!0;var i=Yc[e];return!!i&&i.includes(t)}function Zc(t,e){var i,r,n=null!=(r=null==t?void 0:t.background)?r:{},s=n.name,a=n.url;return s&&(e&&e[s]?i=e[s]:a&&(i=a)),i}function qc(t,e,i){return Kc.apply(this,arguments)}function Kc(){return(Kc=E((function(t,e,i){var r,n;return O(this,(function(s){switch(s.label){case 0:return"string"!=typeof t?[3,2]:[4,Ii(t)];case 1:return r=s.sent(),[3,3];case 2:r=t,s.label=3;case 3:if(!r)throw new Error("Image not provided.");if(!e)return[2,r];if(n=Zc(e,i)){if(yt(n)&&n!==r.src)return[2,Ii(n)];if(A(n,c))return[2,n]}return[2,r]}}))}))).apply(this,arguments)}!function(t){t.isJSONObject=function(t){return bt(t)&&"jsonScene"in t},t.isURL=function(t){return bt(t)&&"url"in t},t.isWithOptions=function(t){return bt(t)&&"options"in t}}(Hc||(Hc={}));var Qc=1,Jc=function(){function t(t,e){void 0===t&&(t={}),void 0===e&&(e=new wi),this.options=t,this.downloader=e,this.assets={},this.sourceFrom={},this.id=Qc++,this.timers=[],this.updateOptions(t)}var e=t.prototype;return e.updateOptions=function(t){void 0===t&&(t={}),this.options=t,t.pluginData||(t.pluginData={});var e=t.timeout,i=void 0===e?10:e;this.timeout=i},e.loadScene=function(t,e,i){var n=this;return E((function(){var s,a,o,u,h,c,f,p,m,y,g,x,b;return O(this,(function(T){return a=yt(t)?t:n.id,o=d.now(),u=[],h=null==e?void 0:e.engine.gpuCapability,f=null!=(c=null==h?void 0:h.detail.compressedTexture)?c:bn.NONE,p={},y=!1,g=new Promise((function(t,e){m=r.setTimeout((function(){y=!0,n.removeTimer(m);var t=d.now()-o;e(new Error("Load time out: totalTime: "+t.toFixed(4)+"ms "+u.join(" ")+", url: "+a+"."))}),1e3*n.timeout),n.timers.push(m)})),x=E((function(t,e){var i,r,n,s;return O(this,(function(a){switch(a.label){case 0:if(y)return[3,4];i=d.now(),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,e()];case 2:return r=a.sent(),n=d.now()-i,u.push("["+t+": "+n.toFixed(2)+"]"),p[t]=n,[2,r];case 3:throw s=a.sent(),new Error("Load error in "+t+", "+s+".");case 4:throw new Error("Load canceled.")}}))})),b=E((function(){var e,h,c,y,g,b,T,E,_,w,A,C,S,R;return O(this,(function(O){switch(O.label){case 0:return yt(t)?(h=new l(t,v.href).href,n.baseUrl=h,[4,x("loadJSON",(function(){return n.loadJSON(h)}))]):[3,2];case 1:return s=O.sent(),[3,3];case 2:s=t,n.baseUrl=v.href,O.label=3;case 3:return Hc.isJSONObject(s)?(e=_i({},s),[3,9]):[3,4];case 4:return[4,x("processJSON",(function(){return n.processJSON(s)}))];case 5:return c=O.sent(),y=c.jsonScene,g=c.pluginSystem,b=y.bins,T=void 0===b?[]:b,E=y.images,_=y.fonts,[4,Promise.all([x("processBins",(function(){return n.processBins(T)})),x("processImages",(function(){return n.processImages(E,f)})),x("plugin:processAssets",(function(){return n.processPluginAssets(y,g,i)})),x("processFontURL",(function(){return n.processFontURL(_)}))])];case 6:return w=O.sent(),A=w[0],C=w[1],[4,x("processTextures",(function(){return n.processTextures(C,A,y)}))];case 7:return S=O.sent(),e={timeInfos:p,url:t,renderLevel:n.options.renderLevel,storage:{},pluginSystem:g,jsonScene:y,bins:A,textureOptions:S,textures:[],images:C,assets:n.assets},[4,x("plugin:prepareResource",(function(){return g.loadResources(e,n.options)}))];case 8:O.sent(),O.label=9;case 9:return R=d.now()-o,mt.info("Load asset: totalTime: "+R.toFixed(4)+"ms "+u.join(" ")+", url: "+a+"."),r.clearTimeout(m),n.removeTimer(m),e.totalTime=R,e.startTime=o,e.timeInfos=p,[2,e]}}))})),[2,Promise.race([g,b()])]}))}))()},e.getAssets=function(){return this.assets},e.processJSON=function(t){var e=this;return E((function(){var i,r,n;return O(this,(function(s){switch(s.label){case 0:return i=Dc(t),r=i.plugins,[4,(n=new Pt(void 0===r?[]:r)).processRawJSON(i,e.options)];case 1:return s.sent(),[2,{jsonScene:i,pluginSystem:n}]}}))}))()},e.processBins=function(t){var e=this;return E((function(){var i,r,n;return O(this,(function(s){return i=e.options.renderLevel,r=e.baseUrl,n=t.map((function(n){if(A(n,ArrayBuffer))return n;if(Wc(n.renderLevel,i))return e.loadBins(new l(n.url,r).href);throw new Error("Invalid bins source: "+JSON.stringify(t)+".")})),[2,Promise.all(n)]}))}))()},e.processFontURL=function(e){var r=this;return E((function(){var n;return O(this,(function(s){return e?(n=e.map(E((function(e){var n,s,a;return O(this,(function(o){switch(o.label){case 0:if(!e.fontURL||t.fontCache.has(e.fontFamily))return[3,4];ht(e.fontFamily)||console.warn("Risky font family: "+e.fontFamily+"."),o.label=1;case 1:return o.trys.push([1,3,,4]),n=new l(e.fontURL,r.baseUrl).href,[4,(a=new FontFace(null!=(s=e.fontFamily)?s:"","url("+n+")")).load()];case 2:return o.sent(),i.fonts.add(a),t.fontCache.add(e.fontFamily),[3,4];case 3:return o.sent(),mt.warn("Invalid font family or font source: "+JSON.stringify(e.fontURL)+"."),[3,4];case 4:return[2]}}))}))),[2,Promise.all(n)]):[2]}))}))()},e.processImages=function(t,e){void 0===e&&(e=0);var i=this;return E((function(){var r,n,s,a,o,u,h,f;return O(this,(function(d){switch(d.label){case 0:return r=i.options,n=r.useCompressedTexture,s=r.variables,a=r.disableWebP,o=r.disableAVIF,u=i.baseUrl,h=t.map(E((function(t,r){var h,f,d,v,y,g,x,b,T,E,_,w,C,S,R,M,I,P,L,F,V;return O(this,(function(r){switch(r.label){case 0:if(h=t.url,f=t.webp,d=t.avif,v=new l(h,u).href,y=!a&&f?new l(f,u).href:void 0,g=!o&&d?new l(d,u).href:void 0,x=t.id,!("template"in t))return[3,8];if(b=t.template,!(T=b.background))return[3,7];E=Zc(b,s),_=T.type===Te.video,w=T&&_?Di:Ii,r.label=1;case 1:return r.trys.push([1,6,,7]),[4,zi(E,w)];case 2:return A(C=r.sent(),m)?(i.sourceFrom[x]={url:C.src,type:ci.video},[2,C]):[3,3];case 3:return T&&Array.isArray(E)&&s&&(s[T.name]=C.src),i.sourceFrom[x]={url:C.src,type:ci.image},[4,qc(C,b,s)];case 4:return[2,r.sent()];case 5:return[3,7];case 6:throw S=r.sent(),new Error("Failed to load. Check the template or if the URL is "+(_?"video":"image")+" type, URL: "+E+", Error: "+(S.message||S)+".");case 7:return[3,9];case 8:if("compressed"in t&&n&&e){if(R=t.compressed,e===bn.ASTC?M=R.astc:e===bn.PVRTC&&(M=R.pvrtc),M)return I=new l(M,u).href,i.sourceFrom[x]={url:I,type:ci.compressed},[2,i.loadBins(I)]}else if(A(t,c)||A(t,p)||A(t,m)||A(t,Yi))return[2,t];r.label=9;case 9:return g?[4,Ri(v,g)]:[3,11];case 10:return V=r.sent(),[3,13];case 11:return[4,Si(v,y)];case 12:V=r.sent(),r.label=13;case 13:return L=(P=V).url,F=P.image,i.sourceFrom[x]={url:L,type:ci.image},[2,F]}}))}))),[4,Promise.all(h)];case 1:return f=d.sent(),i.assignImagesToAssets(t,f),[2,f]}}))}))()},e.processPluginAssets=function(t,e,i){var r=this;return E((function(){var n,s,a,o,u;return O(this,(function(h){switch(h.label){case 0:return[4,e.processAssets(t,i)];case 1:for(n=h.sent(),s=n.reduce((function(t,e){return t.assets=t.assets.concat(e.assets),t.loadedAssets=t.loadedAssets.concat(e.loadedAssets),t}),{assets:[],loadedAssets:[]}),a=s.assets,o=s.loadedAssets,u=0;u<a.length;u++)r.assets[a[u].id]=o[u];return[2]}}))}))()},e.processTextures=function(t,e,i){var r=this;return E((function(){var n,s,a;return O(this,(function(o){return s=null!=(n=i.textures)?n:t.map((function(t,e){return{source:e}})),a=s.map(E((function(t,n){var s,a,o,u,h,l;return O(this,(function(f){switch(f.label){case 0:if(A(t,Yi))return[2,t];if(!("mipmaps"in t))return[3,4];f.label=1;case 1:return f.trys.push([1,3,,4]),[4,Bi(t,e,r.assets,i.bins)];case 2:return[2,f.sent()];case 3:throw s=f.sent(),new Error("Load texture "+n+" fails, error message: "+s+".");case 4:return a=t.source,o=t.id,h="",bt(a)?(u=r.assets[a.id],h=a.id,[3,7]):[3,5];case 5:return"string"!=typeof a?[3,7]:[4,Ii(At(a))];case 6:u=f.sent(),f.label=7;case 7:if(u)return l=function(t,e,i){var r={id:i,dataType:_e.Texture};if(A(t,Yi))return _i({},t.source,r);if(A(t,c)||Tt(t))return _i({image:t,sourceType:ci.image,sourceFrom:e,keepImageSource:!0,minFilter:fi.LINEAR,magFilter:fi.LINEAR},r);if(A(t,m))return _i({sourceType:ci.video,video:t,minFilter:fi.LINEAR,magFilter:fi.LINEAR},r);if(A(t,ArrayBuffer))return _i({},Ji(t),{sourceFrom:e},r);if("width"in t&&"height"in t&&"data"in t)return _i({sourceType:ci.data,data:t,wrapS:fi.CLAMP_TO_EDGE,wrapT:fi.CLAMP_TO_EDGE,minFilter:fi.NEAREST,magFilter:fi.NEAREST},r);throw new Error("Invalid texture options.")}(u,r.sourceFrom[h],o),[2,l.sourceType===ci.compressed?l:_i({},l,t)];throw new Error("Invalid texture source: "+a+".")}}))}))),[2,Promise.all(a)]}))}))()},e.loadJSON=function(t){var e=this;return E((function(){return O(this,(function(i){return[2,new Promise((function(i,r){e.downloader.downloadJSON(t,i,(function(e,i){r("Couldn't load JSON "+JSON.stringify(t)+": status "+e+", "+i)}))}))]}))}))()},e.loadBins=function(t){var e=this;return E((function(){return O(this,(function(i){return[2,new Promise((function(i,r){e.downloader.downloadBinary(t,i,(function(e,i){r("Couldn't load bins "+JSON.stringify(t)+": status "+e+", "+i)}))}))]}))}))()},e.assignImagesToAssets=function(t,e){for(var i=0;i<t.length;i++)this.assets[t[i].id]=e[i]},e.removeTimer=function(t){var e=this.timers.indexOf(t);-1!==e&&this.timers.splice(e,1)},e.dispose=function(){this.timers.length&&this.timers.map((function(t){return r.clearTimeout(t)})),this.assets={},this.sourceFrom={},this.timers=[]},t}();Jc.fontCache=new Set;var $c,tl=function(){function t(t){this.engine=t,this.builtinObjects=[],this.builtinObjects.push(qi(t))}var e=t.prototype;return e.assembleSceneLoadOptions=function(t,e){void 0===e&&(e={});var i=t;return Hc.isURL(t)&&(Hc.isJSONObject(t)||(i=t.url),Hc.isWithOptions(t)&&(e=_i({},e,t.options))),{source:i,options:e}},e.updateTextVariables=function(t,e){var i=this;void 0===e&&(e={}),t.jsonScene.items.forEach((function(t){if(t.type===Xt.text||t.type===Xt.richtext){var r=e[t.name];if(!r)return;t.components.forEach((function(t){var e=t.id,n=i.engine.findEffectsObjectData(e);(null==n?void 0:n.dataType)!==_e.TextComponent&&(null==n?void 0:n.dataType)!==_e.RichTextComponent||(n.options.text=r)}))}}))},e.initializeTexture=function(t){for(var e=0;e<t.textureOptions.length;e++)t.textures[e]=this.engine.findObject({id:t.textureOptions[e].id}),t.textures[e].initialize()},e.prepareAssets=function(t,e){this.engine.clearResources();for(var i,r=w(Object.keys(e));!(i=r()).done;){var n=i.value,s=e[n],a=new Wh(this.engine);a.data=s,a.setInstanceId(n)}this.engine.addPackageDatas(t);for(var o,u=w(this.builtinObjects);!(o=u()).done;){var h=o.value;this.engine.addInstance(h)}},e.createShaderVariant=function(){for(var t,e=w(Object.keys(this.engine.objectInstance));!(t=e()).done;){var i=t.value,r=this.engine.objectInstance[i];A(r,cr)&&r.createShaderVariant()}},e.destroyBuiltinObjects=function(){for(var t,e=w(this.builtinObjects);!(t=e()).done;){t.value.dispose()}this.builtinObjects.length=0},e.dispose=function(){this.destroyBuiltinObjects()},t}(),el=new Int32Array(2),il=new Float32Array(el.buffer),rl=new Float64Array(el.buffer),nl=1===new Uint16Array(new Uint8Array([1,0]).buffer)[0];!function(t){t[t.UTF8_BYTES=1]="UTF8_BYTES",t[t.UTF16_STRING=2]="UTF16_STRING"}($c||($c={}));var sl=function(){function t(t){this.bytes_=t,this.position_=0,this.text_decoder_=new y}var e=t.prototype;return e.clear=function(){this.position_=0},e.bytes=function(){return this.bytes_},e.position=function(){return this.position_},e.setPosition=function(t){this.position_=t},e.capacity=function(){return this.bytes_.length},e.readInt8=function(t){return this.readUint8(t)<<24>>24},e.readUint8=function(t){return this.bytes_[t]},e.readInt16=function(t){return this.readUint16(t)<<16>>16},e.readUint16=function(t){return this.bytes_[t]|this.bytes_[t+1]<<8},e.readInt32=function(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24},e.readUint32=function(t){return this.readInt32(t)>>>0},e.readInt64=function(t){return BigInt.asIntN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))},e.readUint64=function(t){return BigInt.asUintN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))},e.readFloat32=function(t){return el[0]=this.readInt32(t),il[0]},e.readFloat64=function(t){return el[nl?0:1]=this.readInt32(t),el[nl?1:0]=this.readInt32(t+4),rl[0]},e.writeInt8=function(t,e){this.bytes_[t]=e},e.writeUint8=function(t,e){this.bytes_[t]=e},e.writeInt16=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8},e.writeUint16=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8},e.writeInt32=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24},e.writeUint32=function(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24},e.writeInt64=function(t,e){this.writeInt32(t,Number(BigInt.asIntN(32,e))),this.writeInt32(t+4,Number(BigInt.asIntN(32,e>>BigInt(32))))},e.writeUint64=function(t,e){this.writeUint32(t,Number(BigInt.asUintN(32,e))),this.writeUint32(t+4,Number(BigInt.asUintN(32,e>>BigInt(32))))},e.writeFloat32=function(t,e){il[0]=e,this.writeInt32(t,el[0])},e.writeFloat64=function(t,e){rl[0]=e,this.writeInt32(t,el[nl?0:1]),this.writeInt32(t+4,el[nl?1:0])},e.getBufferIdentifier=function(){if(this.bytes_.length<this.position_+4+4)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");for(var t="",e=0;e<4;e++)t+=String.fromCharCode(this.readInt8(this.position_+4+e));return t},e.__offset=function(t,e){var i=t-this.readInt32(t);return e<this.readInt16(i)?this.readInt16(i+e):0},e.__union=function(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t},e.__string=function(t,e){t+=this.readInt32(t);var i=this.readInt32(t);t+=4;var r=this.bytes_.subarray(t,t+i);return e===$c.UTF8_BYTES?r:this.text_decoder_.decode(r)},e.__union_with_string=function(t,e){return"string"==typeof t?this.__string(e):this.__union(t,e)},e.__indirect=function(t){return t+this.readInt32(t)},e.__vector=function(t){return t+this.readInt32(t)+4},e.__vector_len=function(t){return this.readInt32(t+this.readInt32(t))},e.__has_identifier=function(t){if(4!=t.length)throw new Error("FlatBuffers: file identifier must be length 4");for(var e=0;e<4;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+4+e))return!1;return!0},e.createScalarList=function(t,e){for(var i=[],r=0;r<e;++r){var n=t(r);null!==n&&i.push(n)}return i},e.createObjList=function(t,e){for(var i=[],r=0;r<e;++r){var n=t(r);null!==n&&i.push(n.unpack())}return i},t.allocate=function(e){return new t(new Uint8Array(e))},t}(),al=function(){function t(t){var e;this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null,this.text_encoder=new TextEncoder,e=t||1024,this.bb=sl.allocate(e),this.space=e}var e=t.prototype;return e.clear=function(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null},e.forceDefaults=function(t){this.force_defaults=t},e.dataBuffer=function(){return this.bb},e.asUint8Array=function(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())},e.prep=function(e,i){e>this.minalign&&(this.minalign=e);for(var r=1+~(this.bb.capacity()-this.space+i)&e-1;this.space<r+e+i;){var n=this.bb.capacity();this.bb=t.growByteBuffer(this.bb),this.space+=this.bb.capacity()-n}this.pad(r)},e.pad=function(t){for(var e=0;e<t;e++)this.bb.writeInt8(--this.space,0)},e.writeInt8=function(t){this.bb.writeInt8(this.space-=1,t)},e.writeInt16=function(t){this.bb.writeInt16(this.space-=2,t)},e.writeInt32=function(t){this.bb.writeInt32(this.space-=4,t)},e.writeInt64=function(t){this.bb.writeInt64(this.space-=8,t)},e.writeFloat32=function(t){this.bb.writeFloat32(this.space-=4,t)},e.writeFloat64=function(t){this.bb.writeFloat64(this.space-=8,t)},e.addInt8=function(t){this.prep(1,0),this.writeInt8(t)},e.addInt16=function(t){this.prep(2,0),this.writeInt16(t)},e.addInt32=function(t){this.prep(4,0),this.writeInt32(t)},e.addInt64=function(t){this.prep(8,0),this.writeInt64(t)},e.addFloat32=function(t){this.prep(4,0),this.writeFloat32(t)},e.addFloat64=function(t){this.prep(8,0),this.writeFloat64(t)},e.addFieldInt8=function(t,e,i){(this.force_defaults||e!=i)&&(this.addInt8(e),this.slot(t))},e.addFieldInt16=function(t,e,i){(this.force_defaults||e!=i)&&(this.addInt16(e),this.slot(t))},e.addFieldInt32=function(t,e,i){(this.force_defaults||e!=i)&&(this.addInt32(e),this.slot(t))},e.addFieldInt64=function(t,e,i){(this.force_defaults||e!==i)&&(this.addInt64(e),this.slot(t))},e.addFieldFloat32=function(t,e,i){(this.force_defaults||e!=i)&&(this.addFloat32(e),this.slot(t))},e.addFieldFloat64=function(t,e,i){(this.force_defaults||e!=i)&&(this.addFloat64(e),this.slot(t))},e.addFieldOffset=function(t,e,i){(this.force_defaults||e!=i)&&(this.addOffset(e),this.slot(t))},e.addFieldStruct=function(t,e,i){e!=i&&(this.nested(e),this.slot(t))},e.nested=function(t){if(t!=this.offset())throw new TypeError("FlatBuffers: struct must be serialized inline.")},e.notNested=function(){if(this.isNested)throw new TypeError("FlatBuffers: object serialization must not be nested.")},e.slot=function(t){null!==this.vtable&&(this.vtable[t]=this.offset())},e.offset=function(){return this.bb.capacity()-this.space},e.addOffset=function(t){this.prep(4,0),this.writeInt32(this.offset()-t+4)},e.startObject=function(t){this.notNested(),null==this.vtable&&(this.vtable=[]),this.vtable_in_use=t;for(var e=0;e<t;e++)this.vtable[e]=0;this.isNested=!0,this.object_start=this.offset()},e.endObject=function(){if(null==this.vtable||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);for(var t=this.offset(),e=this.vtable_in_use-1;e>=0&&0==this.vtable[e];e--);for(var i=e+1;e>=0;e--)this.addInt16(0!=this.vtable[e]?t-this.vtable[e]:0);this.addInt16(t-this.object_start);var r=2*(i+2);this.addInt16(r);var n=0,s=this.space;t:for(e=0;e<this.vtables.length;e++){var a=this.bb.capacity()-this.vtables[e];if(r==this.bb.readInt16(a)){for(var o=2;o<r;o+=2)if(this.bb.readInt16(s+o)!=this.bb.readInt16(a+o))continue t;n=this.vtables[e];break}}return n?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,n-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t},e.finish=function(t,e,i){var r=i?4:0;if(e){var n=e;if(this.prep(this.minalign,8+r),4!=n.length)throw new TypeError("FlatBuffers: file identifier must be length 4");for(var s=3;s>=0;s--)this.writeInt8(n.charCodeAt(s))}this.prep(this.minalign,4+r),this.addOffset(t),r&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)},e.finishSizePrefixed=function(t,e){this.finish(t,e,!0)},e.requiredField=function(t,e){var i=this.bb.capacity()-t,r=i-this.bb.readInt32(i);if(!(e<this.bb.readInt16(r)&&0!=this.bb.readInt16(r+e)))throw new TypeError("FlatBuffers: field "+e+" must be set")},e.startVector=function(t,e,i){this.notNested(),this.vector_num_elems=e,this.prep(4,t*e),this.prep(i,t*e)},e.endVector=function(){return this.writeInt32(this.vector_num_elems),this.offset()},e.createSharedString=function(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);var e=this.createString(t);return this.string_maps.set(t,e),e},e.createString=function(t){return null==t?0:(e=A(t,Uint8Array)?t:this.text_encoder.encode(t),this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length),this.bb.bytes().set(e,this.space),this.endVector());var e},e.createByteVector=function(t){return null==t?0:(this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length),this.bb.bytes().set(t,this.space),this.endVector())},e.createObjectOffset=function(t){return null===t?0:"string"==typeof t?this.createString(t):t.pack(this)},e.createObjectOffsetList=function(t){for(var e=[],i=0;i<t.length;++i){var r=t[i];if(null===r)throw new TypeError("FlatBuffers: Argument for createObjectOffsetList cannot contain null.");e.push(this.createObjectOffset(r))}return e},e.createStructOffsetList=function(t,e){return e(this,t.length),this.createObjectOffsetList(t.slice().reverse()),this.endVector()},t.growByteBuffer=function(t){var e=t.capacity();if(3221225472&e)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");var i=e<<1,r=sl.allocate(i);return r.setPosition(i-e),r.bytes().set(t.bytes(),i-e),r},t}(),ol=function(){function t(){this.bb=null,this.bb_pos=0}var e=t.prototype;return e.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.dataType=function(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null},e.data=function(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0},e.dataLength=function(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0},e.dataArray=function(){var t=this.bb.__offset(this.bb_pos,6);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null},e.unpack=function(){return new ul(this.dataType(),this.bb.createScalarList(this.data.bind(this),this.dataLength()))},e.unpackTo=function(t){t.dataType=this.dataType(),t.data=this.bb.createScalarList(this.data.bind(this),this.dataLength())},t.getRootAsFBEffectsObjectData=function(e,i){return(i||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsFBEffectsObjectData=function(e,i){return e.setPosition(e.position()+4),(i||new t).__init(e.readInt32(e.position())+e.position(),e)},t.startFBEffectsObjectData=function(t){t.startObject(2)},t.addDataType=function(t,e){t.addFieldOffset(0,e,0)},t.addData=function(t,e){t.addFieldOffset(1,e,0)},t.createDataVector=function(t,e){t.startVector(1,e.length,1);for(var i=e.length-1;i>=0;i--)t.addInt8(e[i]);return t.endVector()},t.startDataVector=function(t,e){t.startVector(1,e,1)},t.endFBEffectsObjectData=function(t){return t.endObject()},t.createFBEffectsObjectData=function(e,i,r){return t.startFBEffectsObjectData(e),t.addDataType(e,i),t.addData(e,r),t.endFBEffectsObjectData(e)},t}(),ul=function(){function t(t,e){void 0===t&&(t=null),void 0===e&&(e=[]),this.dataType=t,this.data=e}return t.prototype.pack=function(t){var e=null!==this.dataType?t.createString(this.dataType):0,i=ol.createDataVector(t,this.data);return ol.createFBEffectsObjectData(t,e,i)},t}(),hl=function(){function t(){this.bb=null,this.bb_pos=0}var e=t.prototype;return e.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.exportObjects=function(t,e){var i=this.bb.__offset(this.bb_pos,4);return i?(e||new ol).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+4*t),this.bb):null},e.exportObjectsLength=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0},e.unpack=function(){return new cl(this.bb.createObjList(this.exportObjects.bind(this),this.exportObjectsLength()))},e.unpackTo=function(t){t.exportObjects=this.bb.createObjList(this.exportObjects.bind(this),this.exportObjectsLength())},t.getRootAsFBEffectsPackageData=function(e,i){return(i||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsFBEffectsPackageData=function(e,i){return e.setPosition(e.position()+4),(i||new t).__init(e.readInt32(e.position())+e.position(),e)},t.startFBEffectsPackageData=function(t){t.startObject(1)},t.addExportObjects=function(t,e){t.addFieldOffset(0,e,0)},t.createExportObjectsVector=function(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()},t.startExportObjectsVector=function(t,e){t.startVector(4,e,4)},t.endFBEffectsPackageData=function(t){return t.endObject()},t.finishFBEffectsPackageDataBuffer=function(t,e){t.finish(e)},t.finishSizePrefixedFBEffectsPackageDataBuffer=function(t,e){t.finish(e,void 0,!0)},t.createFBEffectsPackageData=function(e,i){return t.startFBEffectsPackageData(e),t.addExportObjects(e,i),t.endFBEffectsPackageData(e)},t}(),cl=function(){function t(t){void 0===t&&(t=[]),this.exportObjects=t}return t.prototype.pack=function(t){var e=hl.createExportObjectsVector(t,t.createObjectOffsetList(this.exportObjects));return hl.createFBEffectsPackageData(t,e)},t}(),ll=function(){function t(){this.bb=null,this.bb_pos=0}var e=t.prototype;return e.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.offset=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0},e.indexCount=function(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0},e.vertexCount=function(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt32(this.bb_pos+t):0},e.unpack=function(){return new fl(this.offset(),this.indexCount(),this.vertexCount())},e.unpackTo=function(t){t.offset=this.offset(),t.indexCount=this.indexCount(),t.vertexCount=this.vertexCount()},t.getRootAsFBSubMesh=function(e,i){return(i||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsFBSubMesh=function(e,i){return e.setPosition(e.position()+4),(i||new t).__init(e.readInt32(e.position())+e.position(),e)},t.startFBSubMesh=function(t){t.startObject(3)},t.addOffset=function(t,e){t.addFieldInt32(0,e,0)},t.addIndexCount=function(t,e){t.addFieldInt32(1,e,0)},t.addVertexCount=function(t,e){t.addFieldInt32(2,e,0)},t.endFBSubMesh=function(t){return t.endObject()},t.createFBSubMesh=function(e,i,r,n){return t.startFBSubMesh(e),t.addOffset(e,i),t.addIndexCount(e,r),t.addVertexCount(e,n),t.endFBSubMesh(e)},t}(),fl=function(){function t(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),this.offset=t,this.indexCount=e,this.vertexCount=i}return t.prototype.pack=function(t){return ll.createFBSubMesh(t,this.offset,this.indexCount,this.vertexCount)},t}(),dl=function(){function t(){this.bb=null,this.bb_pos=0}var e=t.prototype;return e.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.semantic=function(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null},e.offset=function(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0},e.format=function(){var t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt32(this.bb_pos+t):0},e.dimension=function(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt32(this.bb_pos+t):0},e.normalize=function(){var t=this.bb.__offset(this.bb_pos,12);return!!t&&!!this.bb.readInt8(this.bb_pos+t)},e.unpack=function(){return new pl(this.semantic(),this.offset(),this.format(),this.dimension(),this.normalize())},e.unpackTo=function(t){t.semantic=this.semantic(),t.offset=this.offset(),t.format=this.format(),t.dimension=this.dimension(),t.normalize=this.normalize()},t.getRootAsFBVertexChannel=function(e,i){return(i||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsFBVertexChannel=function(e,i){return e.setPosition(e.position()+4),(i||new t).__init(e.readInt32(e.position())+e.position(),e)},t.startFBVertexChannel=function(t){t.startObject(5)},t.addSemantic=function(t,e){t.addFieldOffset(0,e,0)},t.addOffset=function(t,e){t.addFieldInt32(1,e,0)},t.addFormat=function(t,e){t.addFieldInt32(2,e,0)},t.addDimension=function(t,e){t.addFieldInt32(3,e,0)},t.addNormalize=function(t,e){t.addFieldInt8(4,+e,0)},t.endFBVertexChannel=function(t){return t.endObject()},t.createFBVertexChannel=function(e,i,r,n,s,a){return t.startFBVertexChannel(e),t.addSemantic(e,i),t.addOffset(e,r),t.addFormat(e,n),t.addDimension(e,s),t.addNormalize(e,a),t.endFBVertexChannel(e)},t}(),pl=function(){function t(t,e,i,r,n){void 0===t&&(t=null),void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=!1),this.semantic=t,this.offset=e,this.format=i,this.dimension=r,this.normalize=n}return t.prototype.pack=function(t){var e=null!==this.semantic?t.createString(this.semantic):0;return dl.createFBVertexChannel(t,e,this.offset,this.format,this.dimension,this.normalize)},t}(),ml=function(){function t(){this.bb=null,this.bb_pos=0}var e=t.prototype;return e.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.vertexCount=function(){var t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0},e.channels=function(t,e){var i=this.bb.__offset(this.bb_pos,6);return i?(e||new dl).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+4*t),this.bb):null},e.channelsLength=function(){var t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0},e.unpack=function(){return new vl(this.vertexCount(),this.bb.createObjList(this.channels.bind(this),this.channelsLength()))},e.unpackTo=function(t){t.vertexCount=this.vertexCount(),t.channels=this.bb.createObjList(this.channels.bind(this),this.channelsLength())},t.getRootAsFBVertexData=function(e,i){return(i||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsFBVertexData=function(e,i){return e.setPosition(e.position()+4),(i||new t).__init(e.readInt32(e.position())+e.position(),e)},t.startFBVertexData=function(t){t.startObject(2)},t.addVertexCount=function(t,e){t.addFieldInt32(0,e,0)},t.addChannels=function(t,e){t.addFieldOffset(1,e,0)},t.createChannelsVector=function(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()},t.startChannelsVector=function(t,e){t.startVector(4,e,4)},t.endFBVertexData=function(t){return t.endObject()},t.createFBVertexData=function(e,i,r){return t.startFBVertexData(e),t.addVertexCount(e,i),t.addChannels(e,r),t.endFBVertexData(e)},t}(),vl=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=[]),this.vertexCount=t,this.channels=e}return t.prototype.pack=function(t){var e=ml.createChannelsVector(t,t.createObjectOffsetList(this.channels));return ml.createFBVertexData(t,this.vertexCount,e)},t}(),yl=function(){function t(){this.bb=null,this.bb_pos=0}var e=t.prototype;return e.__init=function(t,e){return this.bb_pos=t,this.bb=e,this},e.id=function(t){var e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null},e.name=function(t){var e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null},e.vertexData=function(t){var e=this.bb.__offset(this.bb_pos,8);return e?(t||new ml).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null},e.indexFormat=function(){var t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt32(this.bb_pos+t):0},e.indexOffset=function(){var t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readInt32(this.bb_pos+t):0},e.subMeshes=function(t,e){var i=this.bb.__offset(this.bb_pos,14);return i?(e||new ll).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+4*t),this.bb):null},e.subMeshesLength=function(){var t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0},e.mode=function(){var t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readInt32(this.bb_pos+t):0},e.buffer=function(t){var e=this.bb.__offset(this.bb_pos,18);return e?this.bb.__string(this.bb_pos+e,t):null},e.binaryData=function(t){var e=this.bb.__offset(this.bb_pos,20);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0},e.binaryDataLength=function(){var t=this.bb.__offset(this.bb_pos,20);return t?this.bb.__vector_len(this.bb_pos+t):0},e.binaryDataArray=function(){var t=this.bb.__offset(this.bb_pos,20);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null},e.boneNames=function(t,e){var i=this.bb.__offset(this.bb_pos,22);return i?this.bb.__string(this.bb.__vector(this.bb_pos+i)+4*t,e):null},e.boneNamesLength=function(){var t=this.bb.__offset(this.bb_pos,22);return t?this.bb.__vector_len(this.bb_pos+t):0},e.rootBoneName=function(t){var e=this.bb.__offset(this.bb_pos,24);return e?this.bb.__string(this.bb_pos+e,t):null},e.inverseBindMatrices=function(t){var e=this.bb.__offset(this.bb_pos,26);return e?this.bb.readFloat32(this.bb.__vector(this.bb_pos+e)+4*t):0},e.inverseBindMatricesLength=function(){var t=this.bb.__offset(this.bb_pos,26);return t?this.bb.__vector_len(this.bb_pos+t):0},e.inverseBindMatricesArray=function(){var t=this.bb.__offset(this.bb_pos,26);return t?new Float32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null},e.unpack=function(){return new gl(this.id(),this.name(),null!==this.vertexData()?this.vertexData().unpack():null,this.indexFormat(),this.indexOffset(),this.bb.createObjList(this.subMeshes.bind(this),this.subMeshesLength()),this.mode(),this.buffer(),this.bb.createScalarList(this.binaryData.bind(this),this.binaryDataLength()),this.bb.createScalarList(this.boneNames.bind(this),this.boneNamesLength()),this.rootBoneName(),this.bb.createScalarList(this.inverseBindMatrices.bind(this),this.inverseBindMatricesLength()))},e.unpackTo=function(t){t.id=this.id(),t.name=this.name(),t.vertexData=null!==this.vertexData()?this.vertexData().unpack():null,t.indexFormat=this.indexFormat(),t.indexOffset=this.indexOffset(),t.subMeshes=this.bb.createObjList(this.subMeshes.bind(this),this.subMeshesLength()),t.mode=this.mode(),t.buffer=this.buffer(),t.binaryData=this.bb.createScalarList(this.binaryData.bind(this),this.binaryDataLength()),t.boneNames=this.bb.createScalarList(this.boneNames.bind(this),this.boneNamesLength()),t.rootBoneName=this.rootBoneName(),t.inverseBindMatrices=this.bb.createScalarList(this.inverseBindMatrices.bind(this),this.inverseBindMatricesLength())},t.getRootAsFBGeometryData=function(e,i){return(i||new t).__init(e.readInt32(e.position())+e.position(),e)},t.getSizePrefixedRootAsFBGeometryData=function(e,i){return e.setPosition(e.position()+4),(i||new t).__init(e.readInt32(e.position())+e.position(),e)},t.startFBGeometryData=function(t){t.startObject(12)},t.addId=function(t,e){t.addFieldOffset(0,e,0)},t.addName=function(t,e){t.addFieldOffset(1,e,0)},t.addVertexData=function(t,e){t.addFieldOffset(2,e,0)},t.addIndexFormat=function(t,e){t.addFieldInt32(3,e,0)},t.addIndexOffset=function(t,e){t.addFieldInt32(4,e,0)},t.addSubMeshes=function(t,e){t.addFieldOffset(5,e,0)},t.createSubMeshesVector=function(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()},t.startSubMeshesVector=function(t,e){t.startVector(4,e,4)},t.addMode=function(t,e){t.addFieldInt32(6,e,0)},t.addBuffer=function(t,e){t.addFieldOffset(7,e,0)},t.addBinaryData=function(t,e){t.addFieldOffset(8,e,0)},t.createBinaryDataVector=function(t,e){t.startVector(1,e.length,1);for(var i=e.length-1;i>=0;i--)t.addInt8(e[i]);return t.endVector()},t.startBinaryDataVector=function(t,e){t.startVector(1,e,1)},t.addBoneNames=function(t,e){t.addFieldOffset(9,e,0)},t.createBoneNamesVector=function(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()},t.startBoneNamesVector=function(t,e){t.startVector(4,e,4)},t.addRootBoneName=function(t,e){t.addFieldOffset(10,e,0)},t.addInverseBindMatrices=function(t,e){t.addFieldOffset(11,e,0)},t.createInverseBindMatricesVector=function(t,e){t.startVector(4,e.length,4);for(var i=e.length-1;i>=0;i--)t.addFloat32(e[i]);return t.endVector()},t.startInverseBindMatricesVector=function(t,e){t.startVector(4,e,4)},t.endFBGeometryData=function(t){return t.endObject()},t}(),gl=function(){function t(t,e,i,r,n,s,a,o,u,h,c,l){void 0===t&&(t=null),void 0===e&&(e=null),void 0===i&&(i=null),void 0===r&&(r=0),void 0===n&&(n=0),void 0===s&&(s=[]),void 0===a&&(a=0),void 0===o&&(o=null),void 0===u&&(u=[]),void 0===h&&(h=[]),void 0===c&&(c=null),void 0===l&&(l=[]),this.id=t,this.name=e,this.vertexData=i,this.indexFormat=r,this.indexOffset=n,this.subMeshes=s,this.mode=a,this.buffer=o,this.binaryData=u,this.boneNames=h,this.rootBoneName=c,this.inverseBindMatrices=l}return t.prototype.pack=function(t){var e=null!==this.id?t.createString(this.id):0,i=null!==this.name?t.createString(this.name):0,r=null!==this.vertexData?this.vertexData.pack(t):0,n=yl.createSubMeshesVector(t,t.createObjectOffsetList(this.subMeshes)),s=null!==this.buffer?t.createString(this.buffer):0,a=yl.createBinaryDataVector(t,this.binaryData),o=yl.createBoneNamesVector(t,t.createObjectOffsetList(this.boneNames)),u=null!==this.rootBoneName?t.createString(this.rootBoneName):0,h=yl.createInverseBindMatricesVector(t,this.inverseBindMatrices);return yl.startFBGeometryData(t),yl.addId(t,e),yl.addName(t,i),yl.addVertexData(t,r),yl.addIndexFormat(t,this.indexFormat),yl.addIndexOffset(t,this.indexOffset),yl.addSubMeshes(t,n),yl.addMode(t,this.mode),yl.addBuffer(t,s),yl.addBinaryData(t,a),yl.addBoneNames(t,o),yl.addRootBoneName(t,u),yl.addInverseBindMatrices(t,h),yl.endFBGeometryData(t)},t}(),xl=function(){function t(){this.exportObjectDatas=[]}var e=t.prototype;return e.addData=function(t){this.exportObjectDatas.push(t)},e.serializeToBinary=function(){for(var t,e=new al(1),i=new cl,r=[],n=w(this.exportObjectDatas);!(t=n()).done;){var s=t.value,a=void 0;s.dataType===_e.Geometry&&(a=new ul("Geometry",this.geometryDataToBinary(s))),a&&r.push(a)}return i.exportObjects=r,hl.finishFBEffectsPackageDataBuffer(e,i.pack(e)),e.asUint8Array()},e.deserializeFromBinary=function(t){for(var e=new sl(t),i=hl.getRootAsFBEffectsPackageData(e),r=0;r<i.exportObjectsLength();r++){var n=i.exportObjects(r);if(n){var s=n.dataArray(),a=n.dataType();if(s){var o=void 0;a===_e.Geometry&&(o=this.binaryToGeometryData(s)),o&&this.exportObjectDatas.push(o)}}}},e.geometryDataToBinary=function(t){var e=new al(1),i=new gl,r=t.indexFormat,n=t.indexOffset,s=t.mode,a=t.id,o=t.vertexData,u=t.boneNames,h=void 0===u?[]:u,c=t.rootBoneName,l=void 0===c?"":c,f=t.inverseBindMatrices,d=void 0===f?[]:f,p=t.binaryData,m=void 0===p?[]:p;i.indexFormat=r,i.indexOffset=n,i.mode=s,i.id=a,i.boneNames=h,i.rootBoneName=l,i.inverseBindMatrices=d,i.binaryData=m;var v=new vl;v.vertexCount=o.vertexCount,v.channels=[];for(var y,g=w(o.channels);!(y=g()).done;){var x=y.value,b=x.semantic,T=x.offset,E=x.format,_=x.dimension,A=x.normalize,C=new pl(b,T,E,_,A);v.channels.push(C)}i.vertexData=v;for(var S,O=[],R=w(t.subMeshes);!(S=R()).done;){var M=S.value,I=M.offset,P=M.indexCount,L=M.vertexCount,F=new fl(I,P,L);O.push(F)}return i.subMeshes=O,hl.finishFBEffectsPackageDataBuffer(e,i.pack(e)),e.asUint8Array()},e.binaryToGeometryData=function(t){var e=new sl(t),i=yl.getRootAsFBGeometryData(e),r={vertexCount:0,channels:[]},n=i.vertexData();if(n){r.vertexCount=n.vertexCount();for(var s=0;s<n.channelsLength();s++){var a=n.channels(s);if(a){var o,u={semantic:null!=(o=a.semantic())?o:"",offset:a.offset(),format:a.format(),dimension:a.dimension(),normalize:a.normalize()};r.channels.push(u)}}}for(var h=[],c=0;c<i.subMeshesLength();c++){var l=i.subMeshes(c);if(l){var f={offset:l.offset(),vertexCount:l.vertexCount(),indexCount:l.indexCount()};h.push(f)}}for(var d=[],p=0;p<i.boneNamesLength();p++){var m=i.boneNames(p);d.push(m)}var v,y,g,x,b=i.inverseBindMatricesArray();return{vertexData:r,indexFormat:i.indexFormat(),indexOffset:i.indexOffset(),subMeshes:h,mode:i.mode(),buffer:null!=(v=i.buffer())?v:"",boneNames:d,rootBoneName:null!=(y=i.rootBoneName())?y:"",inverseBindMatrices:b?Array.from(b):void 0,binaryData:null!=(g=i.binaryDataArray())?g:void 0,id:null!=(x=i.id())?x:"",dataType:_e.Geometry}},t}(),bl=function(){function t(){this.renderErrors=new Set,this.destroyed=!1,this.textures=[],this.materials=[],this.geometries=[],this.meshes=[],this.renderPasses=[],this.jsonSceneData={},this.objectInstance={},this.assetLoader=new Kh(this),this.emptyTexture=qi(this),this.transparentTexture=Ki(this)}var e=t.prototype;return e.clearResources=function(){this.jsonSceneData={},this.objectInstance={}},e.addEffectsObjectData=function(t){this.jsonSceneData[t.id]=t},e.findEffectsObjectData=function(t){return this.jsonSceneData[t]},e.addInstance=function(t){this.objectInstance[t.getInstanceId()]=t},e.findObject=function(t){return bt(t)&&t.constructor===Object?this.objectInstance[t.id]?this.objectInstance[t.id]:this.assetLoader.loadGUID(t):t},e.removeInstance=function(t){delete this.objectInstance[t]},e.addPackageDatas=function(t){for(var e,i=t.jsonScene,r=t.textureOptions,n=void 0===r?[]:r,s=i.items,a=void 0===s?[]:s,o=i.materials,u=void 0===o?[]:o,h=i.shaders,c=void 0===h?[]:h,l=i.geometries,f=void 0===l?[]:l,d=i.components,p=void 0===d?[]:d,m=i.animations,v=void 0===m?[]:m,y=i.bins,g=void 0===y?[]:y,x=i.miscs,b=void 0===x?[]:x,T=w(i.compositions);!(e=T()).done;){var E=e.value;this.addEffectsObjectData(E)}for(var _,A=w(a);!(_=A()).done;){var C=_.value;Wc(C.renderLevel,t.renderLevel)||(C.components=[],C.type=Xt.null),this.addEffectsObjectData(C)}for(var S,O=w(u);!(S=O()).done;){var R=S.value;this.addEffectsObjectData(R)}for(var M,I=w(c);!(M=I()).done;){var P=M.value;this.addEffectsObjectData(P)}for(var L,F=w(f);!(L=F()).done;){var V=L.value;this.addEffectsObjectData(V)}for(var N,D=w(p);!(N=D()).done;){var k=N.value;this.addEffectsObjectData(k)}for(var z,U=w(v);!(z=U()).done;){var B=z.value;this.addEffectsObjectData(B)}for(var G,j=w(b);!(G=j()).done;){var X=G.value;this.addEffectsObjectData(X)}for(var H=0;H<g.length;H++){var Y=g[H],W=t.bins[H];if(Y.dataType===_e.BinaryAsset)Y.buffer=W,Y.id&&this.addEffectsObjectData(Y);else{var Z=new xl;Z.deserializeFromBinary(new Uint8Array(W));for(var q,K=w(Z.exportObjectDatas);!(q=K()).done;){var Q=q.value;this.addEffectsObjectData(Q)}}}for(var J,$=w(n);!(J=$()).done;){var tt=J.value;this.addEffectsObjectData(tt)}},e.createVFXItems=function(t){var e=this;return E((function(){var i,r,n,s,a;return O(this,(function(o){for(i=t.jsonScene,r=w(i.items);!(n=r()).done;)s=n.value,"ECS"!==(a=s.type)&&"camera"!==a&&a!==Xt.sprite&&a!==Xt.particle&&a!==Xt.mesh&&a!==Xt.skybox&&a!==Xt.light&&a!==Xt.tree&&a!==Xt.interact&&a!==Xt.camera||e.database&&e.assetLoader.loadGUID(s);return[2]}))}))()},e.addTexture=function(t){this.destroyed||D(this.textures,t)},e.removeTexture=function(t){this.destroyed||k(this.textures,t)},e.addMaterial=function(t){this.destroyed||D(this.materials,t)},e.removeMaterial=function(t){this.destroyed||k(this.materials,t)},e.addGeometry=function(t){this.destroyed||D(this.geometries,t)},e.removeGeometry=function(t){this.destroyed||k(this.geometries,t)},e.addMesh=function(t){this.destroyed||D(this.meshes,t)},e.removeMesh=function(t){this.destroyed||k(this.meshes,t)},e.addRenderPass=function(t){this.destroyed||D(this.renderPasses,t)},e.removeRenderPass=function(t){this.destroyed||k(this.renderPasses,t)},e.getShaderLibrary=function(){return this.renderer.getShaderLibrary()},e.dispose=function(){if(!this.destroyed){this.destroyed=!0;var t=[];this.renderPasses.length>0&&t.push("Pass "+this.renderPasses.length),this.meshes.length>0&&t.push("Mesh "+this.meshes.length),this.geometries.length>0&&t.push("Geom "+this.geometries.length),this.textures.length>0&&t.push("Tex "+this.textures.length),t.length>0&&mt.warn("Release GPU memory: "+t.join(", ")+"."),this.renderPasses.forEach((function(t){return t.dispose()})),this.meshes.forEach((function(t){return t.dispose()})),this.geometries.forEach((function(t){return t.dispose()})),this.materials.forEach((function(t){return t.dispose()})),this.textures.forEach((function(t){return t.dispose()})),this.textures=[],this.materials=[],this.geometries=[],this.meshes=[],this.renderPasses=[],this.renderer=null}},Pe(t,[{key:"isDestroyed",get:function(){return this.destroyed}}]),t}(),Tl=60,El=function(){function t(t){void 0===t&&(t=60),this.paused=!0,this.lastTime=0,this.dt=0,this.setFPS(t),this.tickers=[]}var e=t.prototype;return e.getFPS=function(){return this.targetFPS},e.setFPS=function(t){this.targetFPS=qe(t,1,120),this.interval=Math.floor(1e3/t)-2},e.getPaused=function(){return this.paused},e.start=function(){var t=this;if(this.paused=!1,this.dt=0,!this.intervalId){this.lastTime=d.now();var e=x||function(t){return r.setTimeout(t,16.7)},i=function(){t.intervalId=e(i),t.paused||t.tick()};i()}},e.stop=function(){(g||r.clearTimeout)(this.intervalId),this.intervalId=0,this.lastTime=0,this.paused=!0,this.dt=0,this.tickers=[]},e.pause=function(){this.paused=!0,this.dt=0},e.resume=function(){this.paused=!1,this.dt=0},e.tick=function(){if(!this.paused){var t=d.now();if(this.dt=t-this.lastTime,this.dt>=this.interval){this.lastTime=t,this.resetTickers&&(this.tickers=this.tickers.filter((function(t){return t})),this.resetTickers=!1);for(var e=0,i=this.tickers.length;e<i;e++){var r=this.tickers[e];r(this.dt)}}}},e.add=function(t){if("function"!=typeof t)throw new Error("The tick object must implement the tick method.");this.tickers.push(t)},Pe(t,[{key:"deltaTime",get:function(){return this.dt}}]),t}();Mt("camera",zs,Wu),Mt("text",Yh,Wu),Mt("sprite",no,Wu),Mt("particle",ih,Wu),Mt("cal",rh,Wu),Mt("interact",Zs,Wu);var _l;mt.info("Core version: 2.5.0-alpha.6.");var wl,Al=((_l={})[fi.RGBA]=34842,_l[fi.RGB]=34843,_l[fi.ALPHA]=33325,_l[fi.RED]=33325,_l[fi.LUMINANCE_ALPHA]=33327,_l[fi.LUMINANCE]=33325,_l),Cl=((wl={})[fi.RGBA]=34836,wl[fi.RGB]=34837,wl[fi.ALPHA]=33326,wl[fi.RED]=33326,wl[fi.LUMINANCE_ALPHA]=33328,wl[fi.LUMINANCE]=33326,wl),Sl=function(t){function e(e,i){var r;return(r=t.call(this,e)||this).initialized=!1,i&&r.fromData(i),r}Qt(e,t);var i=e.prototype;return i.bind=function(t){this.pipelineContext.bindTexture(this.target,this.textureBuffer,t)},i.initialize=function(){if(!this.initialized){var t=this.engine;t.addTexture(this),this.pipelineContext=t.getGLPipelineContext();var e=this.pipelineContext.gl,i=this.source,r=i.target,n=void 0===r?e.TEXTURE_2D:r,s=i.name;this.textureBuffer=e.createTexture(),Pl(this.textureBuffer,s),this.target=n,this.update(this.source),this.release(),this.initialized=!0}},i.clone=function(){var t=new e(this.engine,this.source);return t.sourceFrom=this.sourceFrom,t.sourceType=this.sourceType,t.width=this.width,t.height=this.height,t},i.release=function(){switch(this.source.sourceType){case ci.image:delete this.source.image,delete this.source.cube;break;case ci.data:delete this.source.data;break;case ci.compressed:case ci.mipmaps:delete this.source.mipmaps}},i.update=function(t){var e=this;if(!this.pipelineContext||!this.textureBuffer)return this.width=0,void(this.height=0);var i,r,n=this.target,s=this.source,a=this.pipelineContext.gl,o=this.engine.gpuCapability.detail,u=s.sourceType,h=s.data,c=s.cube,l=s.image,f=s.video,d=s.mipmaps,p=s.mipmaps,m=t.data,v=t.cube,y=t.generateMipmap,g=t.mipmaps,x=s.format,b=s.type,T=s.internalFormat,E=0,_=0;if(this.bind(u===ci.video),b===fi.HALF_FLOAT?((b=o.halfFloatTexture)||mt.error("Half float texture is not support."),pi(a)&&T===x&&(x===fi.LUMINANCE&&(x=fi.RED),T=Al[x]),o.halfFloatLinear||(s.minFilter=s.magFilter=a.NEAREST,mt.warn("Half float linear not support, change to NEAREST."))):b===a.FLOAT&&((b=o.floatTexture)||mt.error("Float texture is not support."),pi(a)&&T===x&&(x===fi.LUMINANCE&&(x=fi.RED),T=Cl[x]),o.floatLinear||(s.minFilter=a.NEAREST,s.magFilter=a.NEAREST,mt.warn("Float linear not support, change to NEAREST."))),void 0===s.premultiplyAlpha&&(s.premultiplyAlpha=!1),a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),void 0===s.flipY&&(s.flipY=!1),a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,s.flipY),u===ci.framebuffer)m&&(E=null!=(i=m.width)?i:0,_=null!=(r=m.height)?r:0,E&&_&&(this.width!==E||this.height!==_)&&a.texImage2D(n,0,T,E,_,0,x,b,null));else if(u===ci.data){var w;if(n===a.TEXTURE_CUBE_MAP)v.forEach((function(t,i){var r=e.texImage2DData(a,a.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,T,x,b,t),n=r[0],s=r[1];E=Math.max(n,E),_=Math.max(s,_)}));else w=this.texImage2DData(a,n,0,T,x,b,h),E=w[0],_=w[1]}else if(u===ci.image||u===ci.video){if(n===a.TEXTURE_CUBE_MAP)c.forEach((function(t,i){var r=e.texImage2D(a,a.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,T,x,b,t),n=r[0],s=r[1];E=Math.max(n,E),_=Math.max(s,_)}));else if(n===a.TEXTURE_2D){var A,C=null!=l?l:f;A=this.texImage2D(a,n,0,T,x,b,C),E=A[0],_=A[1]}y&&(Ol(E)&&Ol(_)||pi(a))&&a.generateMipmap(n)}else if(u===ci.mipmaps){var S;n===a.TEXTURE_2D?d.forEach((function(t,i){var r;(S="data"in t?e.texImage2DData(a,n,i,T,x,b,t):e.texImage2D(a,n,i,T,x,b,t),0===i)&&(E=(r=S)[0],_=r[1])})):n===a.TEXTURE_CUBE_MAP&&p.forEach((function(t,i){t.forEach((function(t,r){var n;(S="data"in t?e.texImage2DData(a,a.TEXTURE_CUBE_MAP_POSITIVE_X+r,i,T,x,b,t):e.texImage2D(a,a.TEXTURE_CUBE_MAP_POSITIVE_X+r,i,T,x,b,t),0===i)&&(E=(n=S)[0],_=n[1])}))}))}else u===ci.compressed&&g&&0!==g.length&&(E=g[0].width,_=g[0].height,g.forEach((function(t,e){a.compressedTexImage2D(n,e,T,t.width,t.height,0,t.data)})));this.width=E,this.height=_,this.setTextureFilters(a,n,s)},i.setTextureFilters=function(t,e,i){var r=i.anisotropic,n=void 0===r?4:r,s=i.wrapS,a=void 0===s?t.CLAMP_TO_EDGE:s,o=i.wrapT,u=void 0===o?t.CLAMP_TO_EDGE:o,h=this.engine.gpuCapability;this.target===t.TEXTURE_2D&&h.setTextureAnisotropic(t,this.target,n);var c=pi(t)||Ol(this.width)&&Ol(this.height),l=i.magFilter?i.magFilter:t.NEAREST,f=i.minFilter?i.minFilter:t.NEAREST;c||f!==t.LINEAR_MIPMAP_LINEAR&&f!==t.LINEAR_MIPMAP_NEAREST&&f!==t.NEAREST_MIPMAP_LINEAR&&f!==t.NEAREST_MIPMAP_NEAREST||(f=t.LINEAR),t.texParameteri(e,t.TEXTURE_MIN_FILTER,f),t.texParameteri(e,t.TEXTURE_MAG_FILTER,l),t.texParameteri(e,t.TEXTURE_WRAP_S,c?a:t.CLAMP_TO_EDGE),t.texParameteri(e,t.TEXTURE_WRAP_T,c?u:t.CLAMP_TO_EDGE)},i.fromData=function(e){t.prototype.fromData.call(this,e);var i=e,r=this.assembleOptions(i),n=r.sourceType,s=r.sourceFrom,a=r.name,o=void 0===a?"":a;this.source=r,this.sourceType=n,this.sourceFrom=s,this.name=o,this.guid=e.id},i.texImage2D=function(t,e,i,r,n,s,a){var o,u=this,h=this.source,c=h.sourceType,l=h.minFilter,f=h.magFilter,d=h.wrapS,p=h.wrapT,m=null!=(o=this.engine.gpuCapability.detail.maxTextureSize)?o:2048,v=a;if(c!==ci.video){var y=l!==t.NEAREST||f!==t.NEAREST||d!==t.CLAMP_TO_EDGE||p!==t.CLAMP_TO_EDGE;(y=y||a.width>m||a.height>m)&&setTimeout((function(){v=u.resizeImage(a)}))}t.texImage2D(e,i,r,n,s,v);var g=[v.width,v.height];return c===ci.video?[a.videoWidth,a.videoHeight]:g},i.texImage2DData=function(t,e,i,r,n,s,a){var o=a.data,u=a.width,h=a.height,c=n===t.UNSIGNED_BYTE?new Uint8Array(o.buffer,o.byteOffset,o.byteLength/o.BYTES_PER_ELEMENT):o;return t.texImage2D(e,i,r,u,h,0,n,s,c),[u,h]},i.resizeImage=function(t,e,i){var r,n=null!=(r=this.engine.gpuCapability.detail.maxTextureSize)?r:2048;if(pi(this.pipelineContext.gl)&&t.width<n&&t.height<n)return t;var s=function(t,e,i,r){var n=t.width,s=t.height,a=Math.min(e,i||aa(n)),o=Math.min(e,r||aa(s));if(o!==s||a!==n){var u=zh.getCanvas(),h=u.getContext("2d");return u.width=a,u.height=o,null==h||h.drawImage(t,0,0,n,s,0,0,a,o),mt.warn("Image resize from "+n+"x"+s+" to "+a+"x"+o+"."),u}}(t,n,e,i);return s||t},i.reloadData=function(){var t=this;return E((function(){return O(this,(function(e){switch(e.label){case 0:return t.offloaded?[4,er().reload(t)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))()},i.offloadData=function(){if(this.initialized&&er().canOffloadTexture(this.source.sourceFrom)){var t=this.target,e=this.pipelineContext.gl;if(e&&this.textureBuffer){var i=new Uint8Array([255]);if(this.bind(),t===e.TEXTURE_2D)e.texImage2D(t,0,e.LUMINANCE,1,1,0,e.LUMINANCE,e.UNSIGNED_BYTE,i);else if(t===e.TEXTURE_CUBE_MAP)for(var r=[e.TEXTURE_CUBE_MAP_NEGATIVE_X,e.TEXTURE_CUBE_MAP_NEGATIVE_Y,e.TEXTURE_CUBE_MAP_NEGATIVE_Z,e.TEXTURE_CUBE_MAP_POSITIVE_X,e.TEXTURE_CUBE_MAP_POSITIVE_Y,e.TEXTURE_CUBE_MAP_POSITIVE_Z],n=0;n<r.length;n++)e.texImage2D(r[n],0,e.LUMINANCE,1,1,0,e.LUMINANCE,e.UNSIGNED_BYTE,i);e.generateMipmap(t),this.width=1,this.height=1}this.offloaded=!0}},i.uploadCurrentVideoFrame=function(){var t=this;return E((function(){return O(this,(function(e){return t.source.sourceType===ci.video&&t.source.video&&t.initialized?(t.update({video:t.source.video}),[2,!0]):[2,!1]}))}))()},i.updateSource=function(t){this.source=this.assembleOptions(_i({},this.source,t)),this.sourceType=this.source.sourceType,this.sourceFrom=this.source.sourceFrom,this.update(this.source)},i.restore=function(){},i.dispose=function(){this.pipelineContext&&this.textureBuffer&&this.pipelineContext.gl.deleteTexture(this.textureBuffer),this.width=0,this.height=0,this.textureBuffer=null,this.destroyed=!0,this.update=function(){mt.error("This texture has been destroyed.")},this.initialize=_t,void 0!==this.engine&&this.engine.removeTexture(this)},e}(Yi);function Ol(t){return 0==(t&t-1)&&0!==t}var Rl=function(){function t(t,e){this.ready=!1,this.disposed=!1,this.gl=t.getGLPipelineContext().gl,this.vaoExt=t.gpuCapability.vaoExt,this.vao=this.createVertexArray(e)}var e=t.prototype;return e.bind=function(){this.bindVertexArray(this.vao)},e.unbind=function(){this.bindVertexArray(null)},e.createVertexArray=function(t){var e=null;return pi(this.gl)&&(e=this.gl.createVertexArray()),!e&&this.vaoExt&&(e=this.vaoExt.createVertexArrayOES()),Pl(e,t),e},e.bindVertexArray=function(t){var e;pi(this.gl)?this.gl.bindVertexArray(t):null==(e=this.vaoExt)||e.bindVertexArrayOES(t)},e.dispose=function(){var t;pi(this.gl)?this.gl.deleteVertexArray(this.vao):null==(t=this.vaoExt)||t.deleteVertexArrayOES(this.vao)},t}(),Ml=1,Il=function(){function t(t){this.engine=t,this.textures=[],this.renderbuffers=[],this.framebuffers=[],this.destroyed=!1;var e={width:1,height:1,data:new Uint8Array([255])},i=t.getGLPipelineContext(),r=i.gl;this.gl=r,this.pipelineContext=i,this.emptyTexture2D=new Sl(t,{data:e,sourceType:ci.data,format:r.LUMINANCE,internalFormat:r.LUMINANCE,type:r.UNSIGNED_BYTE}),this.emptyTexture2D.initialize(),this.emptyTextureCube=new Sl(t,{target:r.TEXTURE_CUBE_MAP,cube:[e,e,e,e,e,e],sourceType:ci.data,format:r.LUMINANCE,internalFormat:r.LUMINANCE,type:r.UNSIGNED_BYTE}),this.emptyTextureCube.initialize(),this.name="GLGPURenderer"+Ml,Ml++}var e=t.prototype;return e.copy2=function(t,e){var i=this.gl;if(i){this.sourceFbo||(this.sourceFbo=i.createFramebuffer()),this.targetFbo||(this.targetFbo=i.createFramebuffer());var r=this.pipelineContext;r.bindFramebuffer(i.FRAMEBUFFER,this.sourceFbo),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,t.textureBuffer,0),r.bindFramebuffer(i.FRAMEBUFFER,this.targetFbo),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e.textureBuffer,0),r.bindFramebuffer(i.READ_FRAMEBUFFER,this.sourceFbo),r.bindFramebuffer(i.DRAW_FRAMEBUFFER,this.targetFbo);var n=t.getWidth()===t.getHeight()&&e.getWidth()==e.getHeight()?i.NEAREST:i.LINEAR;i.blitFramebuffer(0,0,t.getWidth(),t.getHeight(),0,0,e.getWidth(),e.getHeight(),i.COLOR_BUFFER_BIT,n),r.bindFramebuffer(i.FRAMEBUFFER,null),r.bindFramebuffer(i.READ_FRAMEBUFFER,null),r.bindFramebuffer(i.DRAW_FRAMEBUFFER,null)}},e.resetColorAttachments=function(t,e){t.bind(),t.resetColorTextures(e)},e.createGLRenderbuffer=function(t){var e=this.gl.createRenderbuffer();return e&&D(this.renderbuffers,t),e},e.resize=function(t,e){var i=this.gl;(i&&i.drawingBufferWidth!==t||i.drawingBufferHeight!==e)&&(i.canvas.width=t,i.canvas.height=e,i.viewport(0,0,t,e),this.framebuffers.forEach((function(i){var r=i.viewport;i.isCustomViewport||i.resize(r[0],r[1],t*i.viewportScale,e*i.viewportScale)})))},e.drawGeometry=function(t,e,i){if(this.gl){var r=t,n=e.shaderVariant.program;if(n){var s=n.setupAttributes(r),a=this.gl,o=r.indicesBuffer,u=r.drawStart,h=r.drawCount,c=r.mode,l=r.subMeshes;if(l&&l.length){var f,d=l[i];if(h<0)return;if(u=d.offset,o)h=null!=(f=d.indexCount)?f:0;else h=d.vertexCount}o?a.drawElements(c,h,o.type,null!=u?u:0):a.drawArrays(c,u,h),null==s||s.unbind()}}else console.warn("GLGPURenderer has not bound a gl object, unable to render geometry.")},e.createGLFramebuffer=function(t,e){var i=this.gl.createFramebuffer();if(!i)throw new Error("Failed to create WebGL framebuffer. gl isContextLost="+this.gl.isContextLost());return D(this.framebuffers,t),Pl(i,e,e),i},e.createVAO=function(t){return new Rl(this.engine,t)},e.deleteGLTexture=function(t){t.textureBuffer&&!this.destroyed&&(this.gl.deleteTexture(t.textureBuffer),k(this.textures,t),delete t.textureBuffer)},e.deleteGPUBuffer=function(t){t&&!this.destroyed&&(this.gl.deleteBuffer(t.glBuffer),delete t.glBuffer)},e.deleteGLFramebuffer=function(t){t&&!this.destroyed&&(this.gl.deleteFramebuffer(t.fbo),k(this.framebuffers,t),delete t.fbo)},e.deleteGLRenderbuffer=function(t){t&&!this.destroyed&&(this.gl.deleteRenderbuffer(t.buffer),k(this.renderbuffers,t),delete t.buffer)},e.deleteResource=function(){var t=this,e=this.gl;e&&(e.deleteFramebuffer(this.sourceFbo),e.deleteFramebuffer(this.targetFbo),this.emptyTexture2D.dispose(),this.emptyTextureCube.dispose(),this.framebuffers.forEach((function(e){return t.deleteGLFramebuffer(e)})),this.framebuffers.length=0,this.renderbuffers.forEach((function(e){return t.deleteGLRenderbuffer(e)})),this.renderbuffers.length=0,this.textures.forEach((function(e){return t.deleteGLTexture(e)})),this.textures.length=0)},e.lost=function(t){mt.error("WebGL context lost, destroying glRenderer by default to prevent memory leaks. Event target: "+t.target+"."),this.deleteResource()},e.dispose=function(){this.deleteResource(),this.emptyTexture2D=this.emptyTextureCube=this.pipelineContext=this.gpu=this.gl=null,this.destroyed=!0},Pe(t,[{key:"height",get:function(){var t;return null==(t=this.gl)?void 0:t.drawingBufferHeight}},{key:"width",get:function(){var t;return null==(t=this.gl)?void 0:t.drawingBufferWidth}},{key:"canvas",get:function(){return this.gl.canvas}},{key:"isDestroyed",get:function(){return this.destroyed}}]),t}();function Pl(t,e,i){void 0!==e&&null!==t&&(t.__SPECTOR_Metadata={name:e},t.__SPECTOR_Object_TAG?(t.__SPECTOR_Object_TAG.displayText=e,i&&(t.__SPECTOR_Object_TAG.id=i)):t.__SPECTOR_Object_TAG={displayText:e,id:""})}var Ll,Fl,Vl=function(){function t(t,e){this.pipelineContext=t,this.byteLength=0,this.destroyed=!1;var i=e.name,r=e.data,n=e.elementCount,s=e.target,a=void 0===s?fi.ARRAY_BUFFER:s,o=e.type,u=void 0===o?fi.FLOAT:o,h=e.usage,c=void 0===h?fi.STATIC_DRAW:h,l=function(t){var e,i;return null!=(i=null==(e=Nl[t])?void 0:e.BYTES_PER_ELEMENT)?i:0}(u);this.target=a,this.type=u,this.usage=c,this.glBuffer=this.createGLBuffer(i),this.bytesPerElement=l,r?this.bufferData(r):n&&this.bufferData(l*n)}var e=t.prototype;return e.createGLBuffer=function(t){var e=this.pipelineContext.gl.createBuffer();return Pl(e,t),e},e.bind=function(){this.pipelineContext.gl.bindBuffer(this.target,this.glBuffer)},e.bufferData=function(t){var e="number"==typeof t?t:t.byteLength;if(this.pipelineContext){this.byteLength=e;var i=this.pipelineContext.gl,r=this.target;i.bindBuffer(r,this.glBuffer),0===e?i.bufferData(r,1,this.usage):(i.bufferData(r,e,this.usage),"number"!=typeof t&&i.bufferSubData(r,0,t))}else this.byteLength=0},e.bufferSubData=function(t,e){if(this.pipelineContext){var i=this.pipelineContext.gl,r=this.target,n=t*this.bytesPerElement,s=n+e.byteLength;i.bindBuffer(r,this.glBuffer),s>this.byteLength&&(this.byteLength=s,i.bufferData(r,s,this.usage)),i.bufferSubData(r,n,e)}else this.byteLength=0},e.dispose=function(){this.pipelineContext.gl.deleteBuffer(this.glBuffer),this.glBuffer=null,this.destroyed=!0},e.readSubData=function(t,e){return!!pi(this.pipelineContext.gl)&&(this.pipelineContext.gl.getBufferSubData(this.target,t*this.bytesPerElement,e),!0)},Pe(t,[{key:"elementCount",get:function(){return this.byteLength/this.bytesPerElement}},{key:"isDestroyed",get:function(){return this.destroyed}}]),t}(),Nl=((Ll={})[fi.INT]=Int32Array,Ll[fi.FLOAT]=Float32Array,Ll[fi.SHORT]=Int16Array,Ll[fi.BYTE]=Int8Array,Ll[fi.UNSIGNED_BYTE]=Uint8Array,Ll[fi.UNSIGNED_INT]=Uint32Array,Ll[fi.UNSIGNED_SHORT]=Uint16Array,Ll);var Dl=((Fl={})[Uint8Array.BYTES_PER_ELEMENT]=fi.UNSIGNED_BYTE,Fl[Uint16Array.BYTES_PER_ELEMENT]=fi.UNSIGNED_SHORT,Fl[Uint32Array.BYTES_PER_ELEMENT]=fi.UNSIGNED_INT,Fl),kl=1,zl=function(t){function e(e,i){var r;return(r=t.call(this,e)||this).drawCount=0,r.buffers={},r.vaos={},r.skin={},r.initialized=!1,r.indicesReleasable=!1,r.attributesName=[],r.destroyed=!1,i&&r.processProps(i),r}Qt(e,t);var i=e.prototype;return i.getOptions=function(){return _i({},this.options)},i.initialize=function(){var t=this;if(!this.initialized){var e=this.engine;ot(e),e.addGeometry(this);var i=this.engine.getGLPipelineContext();Object.keys(this.bufferProps).forEach((function(e){t.buffers[e]=new Vl(i,t.bufferProps[e])})),this.indices&&(this.indicesBuffer=this.createIndicesBuffer(i,this.indices)),this.initialized=!0,this.flush(),this.options=void 0}},i.getAttributeBuffer=function(t){if(this.initialized){var e=this.attributes[t].dataSource;return this.buffers[e]}},i.setAttributeData=function(t,e){if(null!=this.bufferProps){var i=this.getAttributeBufferOption(t),r=this.attributes[t].dataSource;if(i){var n=i.usage,s=i.target;this.bufferProps[r]={data:e,usage:n,target:s,elementCount:e.length},this.dirtyFlags[r].discard=!0,this.dirtyFlags[r].dirty=!0}}},i.getAttributeData=function(t){if(null!=this.bufferProps){var e=this.getAttributeBufferOption(t);return e?e.data:void 0}},i.setAttributeSubData=function(t,e,i){if(null!=this.bufferProps){var r=this.getAttributeBufferOption(t);if(r&&null!=r.data){var n=e,s=e+i.length;if(r.data.length<s){var a=new i.constructor(s);a.set(r.data),r.data=a,this.dirtyFlags[t].discard=!0}else if(!this.dirtyFlags[t].discard){var o=this.dirtyFlags[t];void 0!==o.start&&(o.start=Math.min(o.start,n)),void 0!==o.end&&(o.end=Math.max(o.end,s-1))}r.data.set(i,n),this.dirtyFlags[t].dirty=!0}}},i.getIndexData=function(){return this.indices},i.setIndexData=function(t){(A(t,Uint8Array)||A(t,Uint16Array)||A(t,Uint32Array))&&(this.indices=t,this.dirtyFlags.index.discard=!0,this.dirtyFlags.index.dirty=!0)},i.setIndexSubData=function(t,e){if(this.indices){var i,r=t,n=t+e.length;if(this.indices.length<n){var s=new e.constructor(n);s.set(this.indices),this.indices=s,this.dirtyFlags.index.discard=!0}else if(!this.dirtyFlags.index.discard){var a=this.dirtyFlags.index;void 0!==a.start&&(a.start=Math.min(a.start,r)),void 0!==a.end&&(a.end=Math.max(a.end,n-1))}null==(i=this.indices)||i.set(e,r),this.dirtyFlags.index.dirty=!0}},i.getAttributeStride=function(t){var e=this.attributes[t],i=e.stride,r=e.size,n=e.type;return i||r*Ar[n]},i.getAttributeNames=function(){return this.attributesName},i.setDrawStart=function(t){this.drawStart=t},i.getDrawStart=function(){return this.drawStart},i.setDrawCount=function(t){this.drawCount=t},i.getDrawCount=function(){return this.drawCount},i.getSkinProps=function(){return this.skin},i.getAttributeBufferOption=function(t){var e=this.attributes[t];return e?this.bufferProps[e.dataSource]:void 0},i.createIndicesBuffer=function(t,e){var i=Dl[e.BYTES_PER_ELEMENT],r={data:e,target:fi.ELEMENT_ARRAY_BUFFER,type:i,name:this.name+"##index"};return new Vl(t,r)},i.flush=function(){var t=this;if(this.initialized){var e=this.attributes,i=this.bufferProps,r=this.indices;Object.keys(this.dirtyFlags).forEach((function(n){var s,a,o=t.dirtyFlags[n];if("index"==n)s=t.indicesBuffer,a=r;else{var u=e[n].dataSource;s=t.buffers[u],a=i[u].data}if((o.dirty||o.discard)&&s&&a){if(o.discard)s.bufferData(a);else if(void 0!==o.start&&void 0!==o.end){var h=o.start*a.BYTES_PER_ELEMENT+a.byteOffset,c=o.end-o.start+1,l=new a.constructor(a.buffer,h,c);s.bufferSubData(o.start,l)}o.start=Number.POSITIVE_INFINITY,o.end=0,o.dirty=o.discard=!1}})),Object.keys(this.attributesReleasable).forEach((function(r){var n=t.attributesReleasable[r],s=e[r].dataSource;i[s]&&n&&(i[s].data=void 0)})),this.indicesReleasable}},i.processProps=function(t){var e=t,i=e.drawStart,r=void 0===i?0:i,n=e.drawCount,s=e.mode,a=e.indices,o=e.name,u=void 0===o?"effectsGeometry:"+kl++:o,h=e.bufferUsage,c=void 0===h?fi.STATIC_DRAW:h;this.name=u;var l={},f=[],d={},p={},m={},v=c;this.drawStart=r,void 0!==n&&(this.drawCount=n),this.mode=isNaN(s)?fi.TRIANGLES:s,Object.keys(e.attributes).forEach((function(t){var i=e.attributes[t],r=i.size,n=i.stride,s=i.offset,a=i.normalize,o=i.type,u=void 0===o?fi.FLOAT:o,h=i.releasable,c=i.data;if(!u||"dataSource"in i||c||(c=Sr(u)),c){var y=A(c,Float32Array)?fi.FLOAT:fi.INT;l[t]={data:c,usage:v,target:fi.ARRAY_BUFFER,name:t},d[t]={size:r,stride:n,offset:s,type:null!=u?u:y,normalize:!!a,dataSource:t},m[t]=null!=h&&h,p[t]={dirty:!0,discard:!0,start:Number.POSITIVE_INFINITY,end:0}}else{var g=i.dataSource;g&&(d[t]={size:r,stride:n,offset:s,type:u,dataSource:g,normalize:!!a})}f.push(t)})),p.index={dirty:!0,discard:!0,start:Number.POSITIVE_INFINITY,end:0},this.indices=null==a?void 0:a.data,this.indicesReleasable=!0===(null==a?void 0:a.releasable),this.bufferProps=l,this.attributes=d,this.attributesName=f,this.attributesReleasable=m,this.dirtyFlags=p,this.options=e,this.initialized=!1},i.fromData=function(e){var i,r=this;if(t.prototype.fromData.call(this,e),this.subMeshes=e.subMeshes,e.buffer?i=new Uint8Array(function(t){for(var e=s(t),i=new Uint8Array(e.length),r=0;r<e.length;r++)i[r]=e.charCodeAt(r);var n=i.buffer;return n}(e.buffer)):e.binaryData&&(i=e.binaryData),i){var n=e.vertexData.vertexCount;if(this.hasSemantic(e)){var a={mode:fi.TRIANGLES,attributes:{}};if(e.vertexData.channels.forEach((function(t){var e,s=null!=(e=Ul[t.semantic])?e:t.semantic,o=r.createVertexTypedArray(t,i,n);a.attributes[s]={type:vi(t.format),size:t.dimension,data:o,normalize:t.normalize}})),e.indexFormat!==Ce.None){var o=this.createIndexTypedArray(e.indexFormat,i,e.indexOffset);a.indices={data:o},a.drawCount=o.length}else a.drawCount=n;this.processProps(a)}else{var u=e.vertexData.channels[0],h=e.vertexData.channels[1],c=e.vertexData.channels[2],l=this.createVertexTypedArray(u,i,n),f=this.createVertexTypedArray(h,i,n),d=this.createVertexTypedArray(c,i,n),p=this.createIndexTypedArray(e.indexFormat,i,e.indexOffset),m={mode:fi.TRIANGLES,attributes:{aPos:{type:vi(u.format),size:3,data:l,normalize:u.normalize},aUV:{type:vi(h.format),size:2,data:f,normalize:h.normalize},aNormal:{type:vi(c.format),size:3,data:d,normalize:c.normalize}}};m.indices={data:p},m.drawCount=p.length,this.processProps(m)}this.skin={boneNames:e.boneNames,rootBoneName:e.rootBoneName,inverseBindMatrices:e.inverseBindMatrices}}},i.dispose=function(){var t,e=this;(this.drawStart=0,this.drawCount=NaN,this.bufferProps={},this.indices=void 0,this.attributes={},this.attributesName=[],this.options=void 0,this.initialized)&&(Object.keys(this.buffers).forEach((function(t){e.buffers[t].dispose()})),this.buffers={},null==(t=this.indicesBuffer)||t.dispose(),Object.keys(this.vaos).forEach((function(t){var i;null==(i=e.vaos[t])||i.dispose(),e.vaos[t]=void 0})),this.indicesBuffer=void 0,void 0!==this.engine&&(this.engine.removeGeometry(this),this.engine=void 0));this.destroyed=!0},i.createVertexTypedArray=function(t,e,i){var r=e.buffer;switch(t.format){case Ae.Float32:return new Float32Array(r,e.byteOffset+t.offset,t.dimension*i);case Ae.Int16:return new Int16Array(r,e.byteOffset+t.offset,t.dimension*i);case Ae.Int8:return new Int8Array(r,e.byteOffset+t.offset,t.dimension*i);case Ae.UInt16:return new Uint16Array(r,e.byteOffset+t.offset,t.dimension*i);case Ae.UInt8:return new Uint8Array(r,e.byteOffset+t.offset,t.dimension*i);default:return console.error("Invalid vertex format type: "+t.format+"."),new Float32Array(r,e.byteOffset+t.offset,t.dimension*i)}},i.createIndexTypedArray=function(t,e,i){var r=e.buffer;switch(t){case Ce.UInt16:return new Uint16Array(r,e.byteOffset+i);case Ce.UInt32:return new Uint32Array(r,e.byteOffset+i);default:return console.error("Invalid index format type: "+t+"."),new Uint32Array(r,e.byteOffset+i)}},i.hasSemantic=function(t){var e=!1;return t.vertexData.channels.forEach((function(t){t.semantic&&t.semantic.length>0&&(e=!0)})),e},Pe(e,[{key:"isDestroyed",get:function(){return this.destroyed}},{key:"isInitialized",get:function(){return this.initialized}}]),e}(Cr),Ul={POSITION:"aPos",TEXCOORD0:"aUV",TEXCOORD_0:"aUV",TEXCOORD1:"aUV2",NORMAL:"aNormal",TANGENT:"aTangent",COLOR:"aColor",JOINTS:"aJoints",JOINTS_0:"aJoints",WEIGHTS:"aWeights",WEIGHTS_0:"aWeights",POSITION_BS0:"aTargetPosition0",POSITION_BS1:"aTargetPosition1",POSITION_BS2:"aTargetPosition2",POSITION_BS3:"aTargetPosition3",POSITION_BS4:"aTargetPosition4",POSITION_BS5:"aTargetPosition5",POSITION_BS6:"aTargetPosition6",POSITION_BS7:"aTargetPosition7",NORMAL_BS0:"aTargetNormal0",NORMAL_BS1:"aTargetNormal1",NORMAL_BS2:"aTargetNormal2",NORMAL_BS3:"aTargetNormal3",TANGENT_BS0:"aTargetTangent0",TANGENT_BS1:"aTargetTangent1",TANGENT_BS2:"aTargetTangent2",TANGENT_BS3:"aTargetTangent3"};var Bl,Gl,jl=function(){function t(){this.reset()}var e=t.prototype;return e.setBlendColor=function(t){var e=t[0],i=t[1],r=t[2],n=t[3];this.blendColor[0]===e&&this.blendColor[1]===i&&this.blendColor[2]===r&&this.blendColor[3]===n||(this.blendColor[0]=e,this.blendColor[1]=i,this.blendColor[2]=r,this.blendColor[3]=n)},e.setBlending=function(t){this.blending!==t&&(this.blending=t)},e.setBlendFunctionParameters=function(t){var e=t[0],i=t[1],r=t[2],n=t[3];this.blendFunctionParameters[0]===e&&this.blendFunctionParameters[1]===i&&this.blendFunctionParameters[2]===r&&this.blendFunctionParameters[3]===n||(this.blendFunctionParameters[0]=e,this.blendFunctionParameters[1]=i,this.blendFunctionParameters[2]=r,this.blendFunctionParameters[3]=n)},e.setBlendEquationParameters=function(t){var e=t[0],i=t[1];this.blendEquationParameters[0]===e&&this.blendEquationParameters[1]===i||(this.blendEquationParameters[0]=e,this.blendEquationParameters[1]=i)},e.setDepthTest=function(t){this.depthTest!==t&&(this.depthTest=t)},e.setDepthMask=function(t){this.depthMask!==t&&(this.depthMask=t)},e.setDepthRange=function(t){this.depthRange[0]===t[0]&&this.depthRange[1]===t[1]||(this.depthRange[0]=t[0],this.depthRange[1]=t[1])},e.setDepthFunc=function(t){this.depthFunc!==t&&(this.depthFunc=t)},e.setPolygonOffsetFill=function(t){this.polygonOffsetFill!==t&&(this.polygonOffsetFill=t)},e.setPolygonOffset=function(t){this.polygonOffset[0]===t[0]&&this.polygonOffset[1]===t[1]||(this.polygonOffset[0]=t[0],this.polygonOffset[1]=t[1])},e.setSampleAlphaToCoverage=function(t){this.sampleAlphaToCoverage!==t&&(this.sampleAlphaToCoverage=t)},e.setColorMask=function(t){this.colorMask[0]=t,this.colorMask[1]=t,this.colorMask[2]=t,this.colorMask[3]=t},e.setStencilTest=function(t){this.stencilTest!==t&&(this.stencilTest=t)},e.setStencilMask=function(t){this.stencilMask[0]===t[0]&&this.stencilMask[1]===t[1]||(this.stencilMask[0]=t[0],this.stencilMask[1]=t[1])},e.setStencilRef=function(t){this.stencilRef[0]===t[0]&&this.stencilRef[1]===t[1]||(this.stencilRef[0]=t[0],this.stencilRef[1]=t[1])},e.setStencilFunc=function(t){this.stencilFunc[0]===t[0]&&this.stencilFunc[1]===t[1]||(this.stencilFunc[0]=t[0],this.stencilFunc[1]=t[1])},e.setStencilOpFail=function(t){this.stencilOpFail[0]===t[0]&&this.stencilOpFail[1]===t[1]||(this.stencilOpFail[0]=t[0],this.stencilOpFail[1]=t[1])},e.setStencilOpZFail=function(t){this.stencilOpZFail[0]===t[0]&&this.stencilOpZFail[1]===t[1]||(this.stencilOpZFail[0]=t[0],this.stencilOpZFail[1]=t[1])},e.setStencilOpZPass=function(t){this.stencilOpZPass[0]===t[0]&&this.stencilOpZPass[1]===t[1]||(this.stencilOpZPass[0]=t[0],this.stencilOpZPass[1]=t[1])},e.setCulling=function(t){this.culling!==t&&(this.culling=t)},e.setFrontFace=function(t){this.frontFace!==t&&(this.frontFace=t)},e.setCullFace=function(t){this.cullFace!==t&&(this.cullFace=t)},e.reset=function(){this.blending=!1,this.blendColor=[0,0,0,0],this.blendFunctionParameters=[fi.ONE,fi.ONE_MINUS_SRC_ALPHA,fi.ONE,fi.ONE_MINUS_SRC_ALPHA],this.blendEquationParameters=[fi.FUNC_ADD,fi.FUNC_ADD],this.depthTest=!0,this.depthMask=!0,this.depthRange=[0,1],this.depthFunc=fi.LESS,this.polygonOffset=[0,0],this.polygonOffsetFill=!1,this.sampleAlphaToCoverage=!1,this.colorMask=[!0,!0,!0,!0],this.stencilTest=!1,this.stencilMask=[255,255],this.stencilRef=[0,0],this.stencilFunc=[fi.ALWAYS,fi.ALWAYS],this.stencilOpFail=[fi.KEEP,fi.KEEP],this.stencilOpZFail=[fi.KEEP,fi.KEEP],this.stencilOpZPass=[fi.KEEP,fi.KEEP],this.culling=!1,this.frontFace=fi.CCW,this.cullFace=fi.FRONT},e.apply=function(t){if(t.toggle(fi.SAMPLE_ALPHA_TO_COVERAGE,this.sampleAlphaToCoverage),t.toggle(fi.BLEND,this.blending),t.toggle(fi.DEPTH_TEST,this.depthTest),t.toggle(fi.STENCIL_TEST,this.stencilTest),t.toggle(fi.CULL_FACE,this.culling),t.toggle(fi.POLYGON_OFFSET_FILL,this.polygonOffsetFill),this.stencilTest&&(t.stencilMaskSeparate(fi.BACK,this.stencilMask[1]),t.stencilMaskSeparate(fi.FRONT,this.stencilMask[0]),t.stencilFuncSeparate(fi.BACK,this.stencilFunc[0],this.stencilRef[0],this.stencilMask[0]),t.stencilFuncSeparate(fi.FRONT,this.stencilFunc[1],this.stencilRef[1],this.stencilMask[1]),t.stencilOpSeparate(fi.BACK,this.stencilOpFail[0],this.stencilOpZFail[0],this.stencilOpZPass[0]),t.stencilOpSeparate(fi.FRONT,this.stencilOpFail[1],this.stencilOpZFail[1],this.stencilOpZPass[1])),this.blending){var e=this,i=e.blendColor,r=e.blendEquationParameters,n=e.blendFunctionParameters;t.blendColor(i[0],i[1],i[2],i[3]),t.blendEquationSeparate(r[0],r[1]),t.blendFuncSeparate(n[0],n[1],n[2],n[3])}t.colorMask(this.colorMask[0],this.colorMask[1],this.colorMask[2],this.colorMask[3]),this.depthTest&&(t.depthMask(this.depthMask),t.depthFunc(this.depthFunc),t.depthRange(this.depthRange[0],this.depthRange[1])),this.culling&&(t.cullFace(this.cullFace),t.frontFace(this.frontFace)),this.polygonOffsetFill&&t.polygonOffset(this.polygonOffset[0],this.polygonOffset[1])},t}(),Xl=Je,Hl=ni,Yl=function(t){function e(e,i){var r;return(r=t.call(this,e,i)||this).floats={},r.ints={},r.vector2s={},r.vector3s={},r.vector4s={},r.colors={},r.quaternions={},r.matrices={},r.matrice3s={},r.textures={},r.floatArrays={},r.vector4Arrays={},r.matrixArrays={},r.samplers=[],r.uniforms=[],r.uniformDirty=!0,r.macrosDirty=!0,r.glMaterialState=new jl,i&&(r.shader=new dr(e),r.shader.shaderData=_i({},i.shader,{id:wt(),dataType:_e.Shader})),r}Qt(e,t);var i=e.prototype;return i.enableMacro=function(t,e){this.isMacroEnabled(t)&&this.enabledMacros[t]===e||(this.enabledMacros[t]=null==e||e,this.macrosDirty=!0)},i.disableMacro=function(t){this.isMacroEnabled(t)&&(delete this.enabledMacros[t],this.macrosDirty=!0)},i.isMacroEnabled=function(t){return void 0!==this.enabledMacros[t]},i.initialize=function(){var t=this,e=this.engine;this.createShaderVariant(),this.shaderVariant.initialize(),this.initialized||(e.addMaterial(this),Object.keys(this.textures).forEach((function(e){var i=t.textures[e];xt(i.initialize)?i.initialize():mt.error("Failed to initialize texture: "+JSON.stringify(i)+". Ensure the texture conforms to the expected format.")})),this.initialized=!0)},i.createShaderVariant=function(){(this.shaderDirty||this.macrosDirty)&&(this.shaderVariant=this.shader.createVariant(this.enabledMacros),this.macrosDirty=!1,this.shaderDirty=!1,this.uniformDirty=!0)},i.setupStates=function(t){this.glMaterialState.apply(t)},i.use=function(t,e){var i=t.engine.getGLPipelineContext(),r=this.shaderVariant;if(r.program){var n;if(r.program.bind(),this.setupStates(i),e){for(var s,a=w(e.uniforms);!(s=a()).done;)n=s.value,this.checkUniform(n);for(var o,u=w(e.samplers);!(o=u()).done;)n=o.value,this.samplers.includes(n)||(this.samplers.push(n),this.uniformDirty=!0)}if(this.uniformDirty&&(r.fillShaderInformation(this.uniforms,this.samplers),this.uniformDirty=!1),e){for(n in e.floats)r.setFloat(n,e.floats[n]);for(n in e.ints)r.setInt(n,e.ints[n]);for(n in e.vector4s)r.setVector4(n,e.vector4s[n]);for(n in e.vector3s)r.setVector3(n,e.vector3s[n]);for(n in e.matrices)r.setMatrix(n,e.matrices[n])}for(n in this.textures)this.textures[n].textureBuffer||this.textures[n].initialize();for(n in this.floats)r.setFloat(n,this.floats[n]);for(n in this.ints)r.setInt(n,this.ints[n]);for(n in this.floatArrays)r.setFloats(n,this.floatArrays[n]);for(n in this.textures)r.setTexture(n,this.textures[n]);for(n in this.vector2s)r.setVector2(n,this.vector2s[n]);for(n in this.vector3s)r.setVector3(n,this.vector3s[n]);for(n in this.vector4s)r.setVector4(n,this.vector4s[n]);for(n in this.colors)r.setColor(n,this.colors[n]);for(n in this.quaternions)r.setQuaternion(n,this.quaternions[n]);for(n in this.matrices)r.setMatrix(n,this.matrices[n]);for(n in this.matrice3s)r.setMatrix3(n,this.matrice3s[n]);for(n in this.vector4Arrays)r.setVector4Array(n,this.vector4Arrays[n]);for(n in this.matrixArrays)r.setMatrixArray(n,this.matrixArrays[n])}else{var h;null==(h=this.engine)||h.renderErrors.add(new Error("Shader program is not initialized."))}},i.getFloat=function(t){return this.floats[t]},i.setFloat=function(t,e){this.checkUniform(t),this.floats[t]=e},i.getInt=function(t){return this.ints[t]},i.setInt=function(t,e){this.checkUniform(t),this.ints[t]=e},i.getFloats=function(t){return this.floatArrays[t]},i.setFloats=function(t,e){this.checkUniform(t),this.floatArrays[t]=e},i.getVector2=function(t){return this.vector2s[t]},i.setVector2=function(t,e){this.checkUniform(t),this.vector2s[t]=e},i.getVector3=function(t){return this.vector3s[t]},i.setVector3=function(t,e){this.checkUniform(t),this.vector3s[t]=e},i.getVector4=function(t){return this.vector4s[t]},i.setVector4=function(t,e){this.checkUniform(t),this.vector4s[t]=e},i.getColor=function(t){return this.colors[t]},i.setColor=function(t,e){this.checkUniform(t),this.colors[t]=e},i.getQuaternion=function(t){return this.quaternions[t]},i.setQuaternion=function(t,e){this.checkUniform(t),this.quaternions[t]=e},i.getMatrix=function(t){return this.matrices[t]},i.setMatrix=function(t,e){this.checkUniform(t),this.matrices[t]=e},i.setMatrix3=function(t,e){this.checkUniform(t),this.matrice3s[t]=e},i.getVector4Array=function(t){return this.vector4Arrays[t]},i.setVector4Array=function(t,e){this.checkUniform(t),this.vector4Arrays[t]=[];for(var i,r=w(e);!(i=r()).done;){var n=i.value;this.vector4Arrays[t].push(n.x,n.y,n.z,n.w)}},i.getMatrixArray=function(t){return this.matrixArrays[t]},i.setMatrixArray=function(t,e){this.checkUniform(t),this.matrixArrays[t]=[];for(var i,r=w(e);!(i=r()).done;)for(var n=i.value,s=0;s<16;s++)this.matrixArrays[t].push(n.elements[s])},i.setMatrixNumberArray=function(t,e){this.checkUniform(t),this.matrixArrays[t]=e},i.getTexture=function(t){return this.textures[t]},i.setTexture=function(t,e){this.samplers.includes(t)||(this.samplers.push(t),this.uniformDirty=!0),this.textures[t]=e},i.hasUniform=function(t){return this.uniforms.includes(t)||this.samplers.includes(t)},i.clone=function(t){var i=t||this.props,r=this.engine;ot(r);var n=new e(r,i);return n.glMaterialState=Object.assign(new jl,n.glMaterialState),n.floats=this.floats,n.ints=this.ints,n.vector2s=this.vector2s,n.vector3s=this.vector3s,n.vector4s=this.vector4s,n.colors=this.colors,n.quaternions=this.quaternions,n.matrices=this.matrices,n.textures=this.textures,n.floatArrays=this.floatArrays,n.vector4Arrays=this.vector4Arrays,n.matrixArrays=this.matrixArrays,n.samplers=this.samplers,n.uniforms=this.uniforms,n.uniformDirty=!0,n},i.fromData=function(e){t.prototype.fromData.call(this,e),this.uniforms=[],this.samplers=[],this.textures={},this.floats={},this.ints={},this.floatArrays={},this.vector4s={};var i=_i({},e);void 0!==e.stringTags.RenderType&&(this.blending=e.stringTags.RenderType===Wt.Transparent),void 0!==e.floats.ZTest&&(this.depthTest=0!==e.floats.ZTest),void 0!==e.floats.ZWrite&&(this.depthMask=0!==e.floats.ZWrite);var r,n,s=e.stringTags.RenderFace;for(r in s===Zt.Front?(this.culling=!0,this.cullFace=fi.BACK):s===Zt.Back?(this.culling=!0,this.cullFace=fi.FRONT):this.culling=!1,i.floats)this.setFloat(r,i.floats[r]);for(r in i.ints)this.setInt(r,i.ints[r]);for(r in i.vector4s){var a=i.vector4s[r];this.setVector4(r,new Je(a.x,a.y,a.z,a.w))}for(r in i.colors){var o=i.colors[r];this.setColor(r,new ii(o.r,o.g,o.b,o.a))}for(r in i.textures){var u=i.textures[r],h=this.engine.findObject(u.texture);this.setTexture(r,h);var c=u.offset,l=u.scale;c&&l&&this.setVector4(r+"_ST",new Xl(l.x,l.y,c.x,c.y))}if(e.shader){var f=this.engine.findObject(e.shader);f&&(this.shader=f,this.shaderSource=f.shaderData)}this.stringTags=null!=(n=e.stringTags)?n:{},this.initialized=!1},i.toData=function(){var t=this.defination;for(var e in this.shader&&(t.shader=this.shader),t.floats={},t.ints={},t.vector4s={},t.colors={},t.textures={},t.dataType=_e.Material,t.stringTags=this.stringTags,this.floats)t.floats[e]=this.floats[e];for(var i in this.ints)t.ints[i]=this.ints[i];for(var r in this.vector4s)t.vector4s[r]=this.vector4s[r];for(var n in this.colors)t.colors[n]=this.colors[n];for(var s in this.textures){t.textures[s]||(t.textures[s]={texture:this.textures[s]});var a=t.textures[s],o=this.getVector4(s+"_ST");o&&(a.scale={x:o.x,y:o.y},a.offset={x:o.z,y:o.w},delete t.vector4s[s+"_ST"])}return t},i.cloneUniforms=function(t){var e,i=t;for(e in i.floats)this.setFloat(e,i.floats[e]);for(e in i.ints)this.setInt(e,i.ints[e]);for(e in i.floatArrays)this.setFloats(e,i.floatArrays[e]);for(e in i.textures)this.setTexture(e,i.textures[e]);for(e in i.vector2s)this.setVector2(e,i.vector2s[e]);for(e in i.vector3s)this.setVector3(e,i.vector3s[e]);for(e in i.vector4s)this.setVector4(e,i.vector4s[e]);for(e in i.colors)this.setColor(e,i.colors[e]);for(e in i.quaternions)this.setQuaternion(e,i.quaternions[e]);for(e in i.matrices)this.setMatrix(e,i.matrices[e]);for(e in i.vector4Arrays){for(var r=[],n=0;n<i.vector4Arrays[e].length;n+=4)r.push(new Xl(i.vector4Arrays[e][n],i.vector4Arrays[e][n+1],i.vector4Arrays[e][n+2],i.vector4Arrays[e][n+3]));this.setVector4Array(e,r)}for(e in i.matrixArrays){for(var s=[],a=0;a<i.matrixArrays[e].length;a+=16){for(var o=Hl.fromIdentity(),u=0;u<16;u++)o.elements[u]=i.matrixArrays[e][a+u];s.push(o)}this.setMatrixArray(e,s)}},i.checkUniform=function(t){this.uniforms.includes(t)||(this.uniforms.push(t),this.uniformDirty=!0)},i.dispose=function(t){var e,i=this;this.destroyed||(null==(e=this.shaderVariant)||e.dispose(),(null==t?void 0:t.textures)!==pt.keep&&Object.keys(this.textures).forEach((function(t){var e=i.textures[t];e!==i.engine.emptyTexture&&e.dispose()})),this.shaderSource=null,this.uniformSemantics={},this.floats={},this.ints={},this.vector2s={},this.vector3s={},this.vector4s={},this.quaternions={},this.matrices={},this.matrice3s={},this.textures={},this.floatArrays={},this.vector4Arrays={},this.matrixArrays={},this.samplers=[],this.uniforms=[],this.initialize=_t,this.destroyed=!0,void 0!==this.engine&&this.engine.removeMaterial(this))},Pe(e,[{key:"blending",get:function(){return this.glMaterialState.blending},set:function(t){void 0!==t&&this.glMaterialState.setBlending(t)}},{key:"blendColor",get:function(){return this.glMaterialState.blendColor},set:function(t){t&&this.glMaterialState.setBlendColor(t)}},{key:"blendFunction",get:function(){return this.glMaterialState.blendFunctionParameters},set:function(t){t&&this.glMaterialState.setBlendFunctionParameters(t)}},{key:"blendEquation",get:function(){return this.glMaterialState.blendEquationParameters},set:function(t){t&&this.glMaterialState.setBlendEquationParameters(t)}},{key:"depthTest",get:function(){return this.glMaterialState.depthTest},set:function(t){void 0!==t&&this.glMaterialState.setDepthTest(t)}},{key:"depthMask",get:function(){return this.glMaterialState.depthMask},set:function(t){void 0!==t&&this.glMaterialState.setDepthMask(t)}},{key:"depthRange",get:function(){return this.glMaterialState.depthRange},set:function(t){t&&this.glMaterialState.setDepthRange(t)}},{key:"depthFunc",get:function(){return this.glMaterialState.depthFunc},set:function(t){void 0!==t&&this.glMaterialState.setDepthFunc(t)}},{key:"polygonOffsetFill",get:function(){return this.glMaterialState.polygonOffsetFill},set:function(t){void 0!==t&&this.glMaterialState.setPolygonOffsetFill(t)}},{key:"polygonOffset",get:function(){return this.glMaterialState.polygonOffset},set:function(t){t&&this.glMaterialState.setPolygonOffset(t)}},{key:"sampleAlphaToCoverage",get:function(){return this.glMaterialState.sampleAlphaToCoverage},set:function(t){void 0!==t&&this.glMaterialState.setSampleAlphaToCoverage(t)}},{key:"colorMask",get:function(){return this.glMaterialState.colorMask[0]},set:function(t){this.glMaterialState.setColorMask(t)}},{key:"stencilTest",get:function(){return this.glMaterialState.stencilTest},set:function(t){void 0!==t&&this.glMaterialState.setStencilTest(t)}},{key:"stencilMask",get:function(){return this.glMaterialState.stencilMask},set:function(t){t&&this.glMaterialState.setStencilMask(t)}},{key:"stencilRef",get:function(){return this.glMaterialState.stencilRef},set:function(t){t&&this.glMaterialState.setStencilRef(t)}},{key:"stencilFunc",get:function(){return this.glMaterialState.stencilFunc},set:function(t){t&&this.glMaterialState.setStencilFunc(t)}},{key:"stencilOpFail",get:function(){return this.glMaterialState.stencilOpFail},set:function(t){t&&this.glMaterialState.setStencilOpFail(t)}},{key:"stencilOpZFail",get:function(){return this.glMaterialState.stencilOpZFail},set:function(t){t&&this.glMaterialState.setStencilOpZFail(t)}},{key:"stencilOpZPass",get:function(){return this.glMaterialState.stencilOpZPass},set:function(t){t&&this.glMaterialState.setStencilOpZPass(t)}},{key:"culling",get:function(){return this.glMaterialState.culling},set:function(t){void 0!==t&&this.glMaterialState.setCulling(t)}},{key:"frontFace",get:function(){return this.glMaterialState.frontFace},set:function(t){void 0!==t&&this.glMaterialState.setFrontFace(t)}},{key:"cullFace",get:function(){return this.glMaterialState.cullFace},set:function(t){void 0!==t&&this.glMaterialState.setCullFace(t)}},{key:"isDestroyed",get:function(){return this.destroyed}}]),e}(cr),Wl=function(){function t(t){if(this.renderer=t,1===t.engine.gpuCapability.level){this.copyRenderPass=this.createCopyRenderPass().initialize(t);var e=this.copyRenderPass.meshes[0].material.shaderSource;t.pipelineContext.shaderLibrary.addShader(e)}}var e=t.prototype;return e.resetColorAttachments=function(t,e){this.renderer&&t.resetColorAttachments(e)},e.copyTexture=function(t,e){this.renderer&&(t.initialize(),e.initialize(),e.updateSource({sourceType:ci.framebuffer,data:{width:e.getWidth()||t.getWidth(),height:e.getHeight()||t.getHeight()}}),2===this.renderer.engine.gpuCapability.level?this.copy2(t,e):this.copy1(t,e))},e.copy2=function(t,e){var i=this.renderer.getFramebuffer();this.renderer.glRenderer.copy2(t,e),this.renderer.setFramebuffer(i)},e.copy1=function(t,e){var i=this.copyRenderPass;if(i){var r=this.renderer;if(r){var n=i.framebuffer;n.viewport[2]=e.getWidth()||t.getWidth(),n.viewport[3]=e.getHeight()||t.getHeight(),r.glRenderer.resetColorAttachments(n,[e]),i.meshes[0].material.setTexture("uTex",t),r.renderRenderPass(i)}}},e.createCopyRenderPass=function(){var t="mri-copy-mesh",e={texture:{format:fi.RGBA}},i=this.renderer.engine,r=new zl(i,{name:t,mode:fi.TRIANGLE_STRIP,attributes:{aPos:{type:fi.FLOAT,size:2,data:new Float32Array([-1,1,-1,-1,1,1,1,-1])}},drawCount:4}),n=i.gpuCapability.level,s=new Yl(i,{name:t,shader:{cacheId:"$mri-internal-copy",name:t,vertex:"\nprecision highp float;\nattribute vec2 aPos;\nvarying vec2 vTex;\nvoid main(){\n gl_Position = vec4(aPos,0.,1.0);\n vTex = (aPos + vec2(1.))/2.;\n}",fragment:"\nprecision highp float;\nvarying vec2 vTex;\nuniform sampler2D uTex;\nvoid main(){\n gl_FragColor = texture2D(uTex,vTex);\n}",glslVersion:2===n?ur.GLSL3:ur.GLSL1}});s.blending=!1,s.depthTest=!1,s.culling=!1;var a=new Dr(i,{name:t,geometry:r,material:s,priority:0});return new Zl(this.renderer,{name:"mri-copy-rp",clearAction:{colorAction:hi.whatever},attachments:[e],meshes:[a]})},e.dispose=function(){var t;this.renderer&&(null==(t=this.copyRenderPass)||t.dispose(),this.renderer=void 0)},t}(),Zl=function(t){function e(){return t.apply(this,arguments)}Qt(e,t);var i=e.prototype;return i.configure=function(t){this.currentFramebuffer=t.getFramebuffer(),t.setFramebuffer(this.framebuffer)},i.execute=function(t){this.clearAction&&t.clear(this.clearAction),t.renderMeshes(this.meshes),this.storeAction&&t.clear(this.storeAction),t.setFramebuffer(this.currentFramebuffer)},e}(Xr),ql=function(){function t(t,e,i){var r=this;void 0===e&&(e="webgl"),void 0===i&&(i={}),this.canvas=t,this.glType=e,this.restoreHandlers=[],this.lostHandlers=[],ot(t),this.gl=si(t,e,i),this.contextLostListener=function(t){for(var e,i,n=w(r.lostHandlers);!(i=n()).done;){i.value.lost(t)}null==(e=r.canvas)||e.removeEventListener("webglcontextlost",r.contextLostListener)},this.contextRestoredListener=function(t){for(var e,i,n=w(r.restoreHandlers);!(i=n()).done;){i.value.restore()}null==(e=r.canvas)||e.addEventListener("webglcontextlost",r.contextLostListener)},t.addEventListener("webglcontextlost",this.contextLostListener),t.addEventListener("webglcontextrestored",this.contextRestoredListener)}var e=t.prototype;return e.dispose=function(){this.canvas&&(this.canvas.removeEventListener("webglcontextlost",this.contextLostListener),this.canvas.removeEventListener("webglcontextrestored",this.contextRestoredListener)),this.gl=null,this.canvas=null},e.addLostHandler=function(t){this.lostHandlers.push(t)},e.removeLostHandler=function(t){var e=this.lostHandlers.indexOf(t);e>-1&&this.lostHandlers.splice(e,1)},e.addRestoreHandler=function(t){this.restoreHandlers.push(t)},e.removeRestoreHandler=function(t){var e=this.restoreHandlers.indexOf(t);e>-1&&this.restoreHandlers.splice(e,1)},t}(),Kl=function(t){function e(e){var i;return(i=t.call(this)||this).gpuCapability=new Sn(e),i}Qt(e,t);var i=e.prototype;return i.dispose=function(){this.isDestroyed||t.prototype.dispose.call(this)},i.getGLRenderer=function(){return this.renderer},i.getGLRendererInternal=function(){return this.getGLRenderer().glRenderer},i.getGLPipelineContext=function(){return this.getGLRenderer().pipelineContext},e}(bl),Ql=function(t){function e(e,i){var r;return(r=t.call(this,e)||this).initialized=!1,void 0!==i&&r.initialize(i),r}Qt(e,t);var i=e.prototype;return i.initialize=function(t){this.initialized||(this.initialized=!0,this.renderer=t,this.buffer=t.createGLRenderbuffer(this))},i.setSize=function(t,e){if(this.initialized){if(this.renderer&&(t!==this.size[0]||e!==this.size[1])){var i=this.renderer,r=i.gl;i.pipelineContext.bindRenderbuffer(r.RENDERBUFFER,this.buffer),t&&e?r.renderbufferStorage(r.RENDERBUFFER,this.format,this.size[0]=t,this.size[1]=e):mt.error("Invalid render buffer size: "+t+"x"+e+".")}}else mt.error("Can't set size for uninitialized render buffer.")},i.dispose=function(){this.renderer&&(this.renderer.deleteGLRenderbuffer(this),this.renderer=null,this.buffer=null),this.destroyed=!0,this.initialize=_t},e}(An),Jl=1,$l=function(t){function e(e,i){var r;(r=t.call(this)||this).attachmentTextures=[];var n,s=e.depthStencilAttachment,a=e.viewport,o=e.isCustomViewport,u=e.storeAction,h=e.viewportScale,c=void 0===h?1:h,l=e.name,f=void 0===l?"GLFramebuffer"+Jl++:l;return r.renderer=i,r.engine=i.engine,r.depthStencilStorageType=null!=(n=null==s?void 0:s.storageType)?n:Ir.none,r.viewport=a,r.isCustomViewport=!!o,r.viewportScale=c,r.name=f,r.storeAction=u,r.updateProps(e),r}Qt(e,t);var i=e.prototype;return i.getDepthTexture=function(){return this.depthTexture},i.getStencilTexture=function(){return this.stencilTexture},i.getColorTextures=function(){return this.colorTextures},i.updateAttachmentTextures=function(){var t=this;this.attachmentTextures.length=0,this.colorTextures.forEach((function(e){e.initialize(),D(t.attachmentTextures,e.textureBuffer)})),this.stencilTexture&&D(this.attachmentTextures,this.stencilTexture.textureBuffer),this.depthTexture&&D(this.attachmentTextures,this.depthTexture.textureBuffer)},i.updateProps=function(t){var e,i,r=this.renderer,n=this.engine.gpuCapability,s=null!=(i=t.depthStencilAttachment)?i:{storageType:Ir.none},a=t.attachments.length>0,o=!0;if(this.externalStorage=!1,t.attachments.length>1&&!n.detail.drawBuffers)throw new Error("Multiple color attachments not support.");var u=null==(e=t.depthStencilAttachment)?void 0:e.texture,h=n.detail.readableDepthStencilTextures,c=s.storageType,l=s.storage;if(this.colorTextures=t.attachments.slice(),!a&&c!==Ir.none)throw new Error("Use depth stencil attachment without color attachments.");switch(a&&(this.fbo=r.glRenderer.createGLFramebuffer(this,this.name)),c){case Ir.depth_stencil_opaque:if(l){if(!A(l,Ql))throw new Error("Invalid depth stencil attachment storage.");this.depthStencilRenderbuffer=l,this.externalStorage=!0}else this.depthStencilRenderbuffer=new Ql({format:fi.DEPTH_STENCIL,attachment:fi.DEPTH_STENCIL_ATTACHMENT,storageType:c},r.glRenderer);o=!1;break;case Ir.depth_16_opaque:if(l){if(!A(l,Ql))throw new Error("Invalid depth attachment storage.");this.depthStencilRenderbuffer=l,this.externalStorage=!0}else this.depthStencilRenderbuffer=new Ql({attachment:fi.DEPTH_ATTACHMENT,format:fi.DEPTH_COMPONENT16,storageType:c},r.glRenderer);break;case Ir.stencil_8_opaque:if(l){if(!A(l,Ql))throw new Error("Invalid stencil attachment storage.");this.depthStencilRenderbuffer=l,this.externalStorage=!0}else this.depthStencilRenderbuffer=new Ql({attachment:fi.STENCIL_ATTACHMENT,format:fi.STENCIL_INDEX8,storageType:c},r.glRenderer);break;case Ir.depth_16_texture:if(!h)throw new Error("Depth texture is not support in framebuffer.");this.depthTexture=null!=u?u:new Sl(this.engine,{sourceType:ci.framebuffer,format:fi.DEPTH_COMPONENT,internalFormat:n.internalFormatDepth16,type:fi.UNSIGNED_SHORT,name:this.name+"##depthTex"}),this.depthTexture.initialize();break;case Ir.depth_24_stencil_8_texture:if(!h)throw new Error("Depth stencil texture is not support in framebuffer.");this.depthTexture=this.stencilTexture=null!=u?u:new Sl(this.engine,{sourceType:ci.framebuffer,format:fi.DEPTH_STENCIL,internalFormat:n.internalFormatDepth24_stencil8,type:n.UNSIGNED_INT_24_8,name:this.name+"##dpthStclTex"}),this.depthTexture.initialize(),o=!0}this.storeInvalidAttachments=this.getStoreAttachments(this.storeAction,o),this.updateAttachmentTextures()},i.getStoreAttachments=function(t,e){var i=this.renderer.glRenderer.gl,r=this.colorTextures.length;if(t&&pi(i)&&r>0){var n=[];if(t.depthAction===Pr.clear&&this.depthStorage&&D(n,e?i.DEPTH_ATTACHMENT:i.DEPTH_STENCIL_ATTACHMENT),t.stencilAction===Pr.clear&&this.stencilStorage&&D(n,e?i.STENCIL_ATTACHMENT:i.DEPTH_STENCIL_ATTACHMENT),t.colorAction===Pr.clear)for(var s=0;s<r;s++)D(n,i["COLOR_ATTACHMENT"+s]);return n}},i.unbind=function(){var t=this.storeInvalidAttachments;if(null==t?void 0:t.length){var e=this.renderer.glRenderer.gl;pi(e)&&e.invalidateFramebuffer(e.FRAMEBUFFER,t)}this.renderer.pipelineContext.bindSystemFramebuffer()},i.bind=function(){var t=this;if(this.fbo){var e=this.renderer.glRenderer.gl,i=this.renderer.pipelineContext,r=this.viewport,n=r[0],s=r[1],a=r[2],o=r[3];i.bindFramebuffer(e.FRAMEBUFFER,this.fbo),i.viewport(n,s,a,o);var u=this.renderer.glRenderer.emptyTexture2D.textureBuffer;Object.keys(i.textureUnitDict).forEach((function(e){var r=i.textureUnitDict[e];r&&r!==u&&t.attachmentTextures.includes(r)&&(i.activeTexture(+e),t.renderer.glRenderer.emptyTexture2D.bind())}));for(var h=0;h<4;h++)i.activeTexture(e.TEXTURE0+h),this.renderer.glRenderer.emptyTexture2D.bind();if(!this.ready){var c=this,l=c.depthStencilRenderbuffer,f=c.depthTexture,d=c.stencilTexture;if(i.activeTexture(e.TEXTURE0),l)l.setSize(a,o),e.framebufferRenderbuffer(e.FRAMEBUFFER,l.attachment,e.RENDERBUFFER,l.buffer);else if(f){f.source.data={width:a,height:o},f.update({data:{width:a,height:o,data:new Uint16Array(0)}});var p=f&&d?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.framebufferTexture2D(e.FRAMEBUFFER,p,e.TEXTURE_2D,f.textureBuffer,0)}this.resetColorTextures(this.colorTextures);var m=e.checkFramebufferStatus(e.FRAMEBUFFER);if(m!==e.FRAMEBUFFER_COMPLETE)throw new Error("Framebuffer failed. gl status="+m+", gl error="+e.getError()+", gl isContextLost="+e.isContextLost()+".");this.ready=!0}}},i.resetColorTextures=function(t){var e=t,i=this.renderer.glRenderer.gl,r=this.engine.gpuCapability,n=this.viewport,s=[];if(e){for(var a,o=w(e);!(a=o()).done;){a.value.initialize()}this.colorTextures=e.slice()}this.renderer.pipelineContext.activeTexture(i.TEXTURE0),this.colorTextures.forEach((function(t,e){var a={width:n[2],height:n[3],data:new Uint8Array(0)};t.update({data:a}),r.framebufferTexture2D(i,i.FRAMEBUFFER,e,i.TEXTURE_2D,t.textureBuffer),s.push(!0)})),r.drawBuffers(i,s),this.updateAttachmentTextures()},i.resize=function(t,e,i,r){var n=this.viewport,s=n[0],a=n[1],o=n[2],u=n[3];s===t&&a===e&&o===i&&u===r||(this.viewport=[t,e,i,r],this.ready=!1,this.bind())},i.dispose=function(t){if(this.renderer){this.renderer.glRenderer.deleteGLFramebuffer(this),delete this.fbo;var e,i,r=(null==t?void 0:t.depthStencilAttachment)?t.depthStencilAttachment:Br.force;if(r===Br.force||r===Br.keepExternal&&!this.externalStorage)null==(e=this.depthStencilRenderbuffer)||e.dispose(),null==(i=this.depthTexture)||i.dispose();this.renderer=this.stencilRenderbuffer=this.depthStencilRenderbuffer=null}},Pe(e,[{key:"stencilStorage",get:function(){if(this.depthStencilStorageType!==Ir.depth_16_opaque)return this.depthStencilRenderbuffer}},{key:"depthStorage",get:function(){if(this.depthStencilStorageType!==Ir.stencil_8_opaque)return this.depthStencilRenderbuffer}}]),e}(Mn),tf=((Bl={})[fi.FLOAT]=1,Bl[fi.INT]=1,Bl[fi.UNSIGNED_INT]=1,Bl[fi.SHORT]=1,Bl[fi.BOOL]=1,Bl[fi.UNSIGNED_SHORT]=1,Bl[fi.FLOAT_VEC2]=2,Bl[fi.FLOAT_VEC3]=3,Bl[fi.FLOAT_VEC4]=4,Bl[fi.FLOAT_MAT2]=4,Bl[fi.FLOAT_MAT3]=9,Bl[fi.FLOAT_MAT4]=16,Bl[fi.FLOAT_MAT2x3]=6,Bl[fi.FLOAT_MAT2x4]=8,Bl[fi.FLOAT_MAT4x3]=12,Bl[fi.FLOAT_MAT4x2]=8,Bl[fi.FLOAT_MAT3x4]=12,Bl[fi.FLOAT_MAT3x2]=6,Bl[fi.INT_VEC2]=2,Bl[fi.INT_VEC3]=3,Bl[fi.INT_VEC4]=4,Bl[fi.UNSIGNED_INT_VEC2]=2,Bl[fi.UNSIGNED_INT_VEC3]=3,Bl[fi.UNSIGNED_INT_VEC4]=4,Bl[fi.BOOL_VEC2]=2,Bl[fi.BOOL_VEC3]=3,Bl[fi.BOOL_VEC4]=4,Bl),ef=af(Float32Array),rf=af(Int32Array),nf=af(Uint8Array);function sf(t){return function(e,i,r,n){var s={start:i[1],dirty:!0};if(i[2]>1){var a=e;if(a.length){for(var o=n[1]||a.length,u=i[4]/t.BYTES_PER_ELEMENT,h=s.buffer=new t(o*u),c=n[0]||0,l=0;l<o;l++)h[l*u]=a[l+c];s.start+=c*u}}else s.buffer=new t([e]);return s}}function af(t){return function(e,i,r,n){for(var s=i[8],a=i[2],o=i[5],u=1===a?s:i[4],h=o?u/o:1,c=u/t.BYTES_PER_ELEMENT/h,l=s/t.BYTES_PER_ELEMENT/c,f=tf[i[0]],d=f/h,p=(n[0]||0)*f,m=n[1]?h*n[1]:l,v=new t(c*m),y={start:i[1]+u*(n[0]||0),dirty:!0,buffer:v},g=0,x=0,b=p;g<m;g++){for(var T=0;T<d;T++)v[x+T]=e[b+T];x+=c,b+=d}return y}}function of(t,e){for(var i=function(i){var s=t.getActiveUniformBlockName(e,i);ot(s);var a={index:t.getUniformBlockIndex(e,s),usedByVertexShader:t.getActiveUniformBlockParameter(e,i,t.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER),usedByFragmentShader:t.getActiveUniformBlockParameter(e,i,t.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER),size:t.getActiveUniformBlockParameter(e,i,t.UNIFORM_BLOCK_DATA_SIZE),uniformIndices:t.getActiveUniformBlockParameter(e,i,t.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES),used:!1,uniforms:{},name:s,id:""};a.used=a.usedByVertexShader||a.usedByFragmentShader,r[i]=a;for(var o=a.uniformIndices,u=[],h=0;h<o.length;h++){var c=t.getActiveUniform(e,o[h]).name.replace("[0]","");a.uniforms[c]=[0,0,0,0,0,0,0,h,0],u[h]=c,n.push(c)}[t.UNIFORM_TYPE,t.UNIFORM_OFFSET,t.UNIFORM_SIZE,t.UNIFORM_BLOCK_INDEX,t.UNIFORM_ARRAY_STRIDE,t.UNIFORM_MATRIX_STRIDE,t.UNIFORM_IS_ROW_MAJOR].forEach((function(i,r){t.getActiveUniforms(e,o,i).forEach((function(t,e){var i=u[e];a.uniforms[i][r]=+t}))}));for(var l=0;l<u.length;l++){var f=a.uniforms[u[l]],d=a.uniforms[u[l+1]],p=d?d[1]:a.size;f[8]=p-f[1]}a.id=function(t){var e=t.name,i=t.size,r=t.uniforms,n=t.uniformIndices,s=Object.keys(r).map((function(t){return t+"["+r[t].join(":")+"]"})).join("+");return uf(e+"+",i+"+",n.length+"+",s)}(a)+""},r=[],n=[],s=t.getProgramParameter(e,t.ACTIVE_UNIFORM_BLOCKS),a=0;a<s;++a)i(a);return{blockSpecs:r,blockUniformNames:n}}function uf(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];for(var r=0,n=0;n<arguments.length;n++)for(var s=e[n],a=0;a<s.length;a++)r=Math.imul(31,r)+s.charCodeAt(a)|0;return r}(Gl={})[fi.FLOAT]=sf(Float32Array),Gl[fi.INT]=sf(Int32Array),Gl[fi.UNSIGNED_INT]=sf(Uint32Array),Gl[fi.SHORT]=sf(Int16Array),Gl[fi.BOOL]=sf(Uint8Array),Gl[fi.UNSIGNED_SHORT]=sf(Uint16Array),Gl[fi.FLOAT_VEC2]=ef,Gl[fi.FLOAT_VEC3]=ef,Gl[fi.FLOAT_VEC4]=ef,Gl[fi.FLOAT_MAT2]=ef,Gl[fi.FLOAT_MAT3]=ef,Gl[fi.FLOAT_MAT4]=ef,Gl[fi.FLOAT_MAT2x3]=ef,Gl[fi.FLOAT_MAT2x4]=ef,Gl[fi.FLOAT_MAT4x3]=ef,Gl[fi.FLOAT_MAT4x2]=ef,Gl[fi.FLOAT_MAT3x4]=ef,Gl[fi.FLOAT_MAT3x2]=ef,Gl[fi.INT_VEC2]=rf,Gl[fi.INT_VEC3]=rf,Gl[fi.INT_VEC4]=rf,Gl[fi.UNSIGNED_INT_VEC2]=rf,Gl[fi.UNSIGNED_INT_VEC3]=rf,Gl[fi.UNSIGNED_INT_VEC4]=rf,Gl[fi.BOOL_VEC2]=nf,Gl[fi.BOOL_VEC3]=nf,Gl[fi.BOOL_VEC4]=nf;var hf=function(){function t(t,e,i){var r=this;this.engine=t,this.program=e,this.id=i,this.uniformBlockMap={},this.pipelineContext=t.getGLPipelineContext();var n=this.pipelineContext.gl;(this.pipelineContext.useProgram(e),this.attribInfoMap=this.createAttribMap(),pi(n))&&of(n,e).blockSpecs.forEach((function(t){return r.uniformBlockMap[t.name]=t}));this.pipelineContext.useProgram(null)}var e=t.prototype;return e.bind=function(){this.pipelineContext.useProgram(this.program)},e.setupAttributes=function(t){var e,i,r=this,n=this.id,s=this.pipelineContext.gl;return t.vaos[n]?i=t.vaos[n]:((i=new Rl(this.engine,t.name+"-"+n))||console.error("Failed to create VAO object."),t.vaos[n]=i),i&&i.vao&&(i.bind(),i.ready)||(Object.keys(this.attribInfoMap).forEach((function(e){var i=r.attribInfoMap[e],n=t.attributes[e];if(n){var a=t.buffers[n.dataSource];if(!a)throw new Error("Failed to find a buffer named '"+(n.dataSource||e)+"'. Please ensure the buffer is correctly initialized and bound.");a.bind(),s.enableVertexAttribArray(i.loc),s.vertexAttribPointer(i.loc,n.size,n.type,n.normalize,n.stride||0,n.offset||0)}})),null==(e=t.indicesBuffer)||e.bind(),i&&(i.ready=!0)),i},e.createAttribMap=function(){for(var t=this.pipelineContext.gl,e=this.program,i={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES),n=0;n<r;n++){var s=t.getActiveAttrib(e,n);if(s){var a=s.name,o=s.type,u=s.size,h=t.getAttribLocation(e,a);i[a]={type:o,name:a,size:u,loc:h}}}return i},e.dispose=function(){this.pipelineContext&&(this.pipelineContext.gl.deleteProgram(this.program),this.pipelineContext=null)},t}(),cf=function(t){function e(e,i){var r;return(r=t.call(this,e,i)||this).initialized=!1,r.uniformLocations={},r.samplerChannels={},r}Qt(e,t);var i=e.prototype;return i.initialize=function(){this.initialized||this.engine.getGLPipelineContext().shaderLibrary.compileShader(this)},i.setFloat=function(t,e){this.pipelineContext.setFloat(this.uniformLocations[t],e)},i.setInt=function(t,e){this.pipelineContext.setInt(this.uniformLocations[t],e)},i.setFloats=function(t,e){this.pipelineContext.setFloats(this.uniformLocations[t],e)},i.setTexture=function(t,e){this.pipelineContext.setTexture(this.uniformLocations[t],this.samplerChannels[t],e)},i.setVector2=function(t,e){this.pipelineContext.setVector2(this.uniformLocations[t],e)},i.setVector3=function(t,e){this.pipelineContext.setVector3(this.uniformLocations[t],e)},i.setVector4=function(t,e){this.pipelineContext.setVector4(this.uniformLocations[t],e)},i.setColor=function(t,e){this.pipelineContext.setColor(this.uniformLocations[t],e)},i.setQuaternion=function(t,e){this.pipelineContext.setQuaternion(this.uniformLocations[t],e)},i.setMatrix=function(t,e){this.pipelineContext.setMatrix(this.uniformLocations[t],e)},i.setMatrix3=function(t,e){this.pipelineContext.setMatrix3(this.uniformLocations[t],e)},i.setVector4Array=function(t,e){this.pipelineContext.setVector4Array(this.uniformLocations[t],e)},i.setMatrixArray=function(t,e){this.pipelineContext.setMatrixArray(this.uniformLocations[t],e)},i.fillShaderInformation=function(t,e){var i=e.slice();t=t.concat(i);for(var r,n=this.pipelineContext.getUniforms(this.program.program,t),s=0;s<t.length;s++)this.uniformLocations[t[s]]=n[s];for(r=0;r<i.length;r++){null==this.uniformLocations[i[r]]&&(i.splice(r,1),r--)}for(r=0;r<i.length;r++){var a=i[r];this.samplerChannels[a]=r}},i.toData=function(){var t=this.defination;t.dataType=_e.Shader,t.id=this.guid,t.vertex=this.source.vertex,t.fragment=this.source.fragment},i.dispose=function(){var t;this.compileResult&&this.compileResult.shared||null==(t=this.program)||t.dispose()},e}(fr),lf=0,ff=function(){function t(t,e){this.engine=t,this.pipelineContext=e,this.shaderResults={},this.programMap={},this.glVertShaderMap=new Map,this.glFragShaderMap=new Map,this.shaderAllDone=!1,this.cachedShaders={},this.glAsyncCompileExt=t.gpuCapability.glAsyncCompileExt}var e=t.prototype;return e.compileAllShaders=function(t){var e=this;if(this.shaderAllDone)t&&t([]);else{for(var i,r=[],n=w(Object.keys(this.cachedShaders));!(i=n()).done;){var s=i.value;this.cachedShaders[s].initialized||r.push(s)}t?r.length?Promise.all(r.map((function(t){return new Promise((function(i){return e.compileShader(e.cachedShaders[t],i)}))}))).then(t).catch((function(){return 0})):t([]):r.map((function(t){return e.compileShader(e.cachedShaders[t])})),this.shaderAllDone=!0}},e.addShader=function(t,e){var i,r,n=[];t.macros&&(i=n).push.apply(i,[].concat(t.macros));e&&(r=n).push.apply(r,[].concat(e));var s=_i({},t,{vertex:cn.genFinalShaderCode({level:this.engine.gpuCapability.level,shaderType:oi.vertex,shader:t.vertex,macros:n}),fragment:cn.genFinalShaderCode({level:this.engine.gpuCapability.level,shaderType:oi.fragment,shader:t.fragment,macros:n})}),a=this.computeShaderCacheId(s);if(this.cachedShaders[a])return a;this.shaderAllDone=!1;var o=!1;return(s.shared||s.cacheId)&&(o=!0),this.cachedShaders[a]=new cf(this.engine,_i({},s,{vertex:s.vertex,fragment:s.fragment,name:s.name||a,shared:o})),this.cachedShaders[a].id=a,a},e.createShader=function(t,e){var i=this.addShader(t,e);return this.cachedShaders[i]},e.compileShader=function(t,e){var i=this,r=t.source,n=r.shared,s=r.vertex,a=r.fragment,o=r.name,u=t.source.cacheId,h=!1;(n||u)&&(h=!0);var c=this.pipelineContext.gl,l={shared:h,status:or.compiling},f=this.createProgram(c,s,a,l),p=this.glAsyncCompileExt,m=d.now(),v=function(e){l.status=or.success,l.compileTime=d.now()-m,t.program=e,t.initialized=!0,t.pipelineContext=i.pipelineContext,void 0!==i.programMap[t.id]&&console.warn("Find duplicated shader id: "+t.id+"."),i.programMap[t.id]=e},y=function(){if(i.engine.isDestroyed)return console.warn("The player is destroyed during the loadScene process. Please check the timing of calling loadScene and dispose. A common situation is that when calling loadScene, await is not added. This will cause dispose to be called before loadScene is completed."),null==e?void 0:e(l);if(t.initialized)return null==e?void 0:e(l);var r=(!e||!p||p&&1==c.getProgramParameter(l.program,p.COMPLETION_STATUS_KHR))&&f();if(r){if(l.status!==or.fail){Pl(r,o);var n=new hf(i.engine,r,t.id);if(c.validateProgram(r),c.getProgramParameter(r,c.VALIDATE_STATUS))v(n);else{var u=c.getProgramInfoLog(r);(null==u?void 0:u.includes("the same texture"))||(null==u?void 0:u.includes("Two textures of different types use the same sampler"))?v(n):(l.status=or.fail,l.error=u,console.error("compileProgramError: "+u,"\nvertex:\n",s,"\nfragment:\n",a),c.deleteProgram(r))}}null==e||e(l)}else e&&x(y)};t.compileResult=l,y()},e.computeShaderCacheId=function(t){var e=t.vertex,i=void 0===e?"":e,r=t.fragment,n=void 0===r?"":r,s=t.shared,a=t.cacheId;return s||a?a||"shared_"+uf(i,n):"instanced_"+lf++},e.createProgram=function(t,e,i,r){var n=t.createProgram(),s=this.createGLShader(t,t.VERTEX_SHADER,e),a=this.createGLShader(t,t.FRAGMENT_SHADER,i);return n&&s&&a?(t.attachShader(n,s),t.attachShader(n,a),t.linkProgram(n),r.program=n,r.status=or.compiling,function(){if(r.program=void 0,!t.getProgramParameter(n,t.LINK_STATUS)){var o=t.getProgramInfoLog(n);console.error("Failed to link program: "+o+".");var u=df(t,s,"vertex",e),h=df(t,a,"fragment",i);return r.status=or.fail,u&&(r.error=u.error,r.status=u.status),h&&(r.error=h.error,r.status=h.status),n}return n}):(r.status=or.fail,function(){return null})},e.createGLShader=function(t,e,i){var r=e===t.VERTEX_SHADER?this.glVertShaderMap:this.glFragShaderMap,n=uf(null!=i?i:""),s=r.get(n);if(s)return s;var a=t.createShader(e);return a&&(t.shaderSource(a,i),t.compileShader(a),r.set(n,a)),a},e.deleteShader=function(t){var e=this.programMap[t];void 0!==e&&(e.dispose(),delete this.programMap[t]),void 0!==this.shaderResults[t]&&delete this.shaderResults[t]},e.restore=function(){},e.dispose=function(){var t=this;if(Object.keys(this.programMap).forEach((function(e){t.programMap[e].dispose()})),this.programMap={},this.pipelineContext){var e=this.pipelineContext.gl;this.glFragShaderMap.forEach((function(t){e.deleteShader(t)})),this.glVertShaderMap.forEach((function(t){e.deleteShader(t)})),this.glVertShaderMap=new Map,this.glFragShaderMap=new Map}},t}();function df(t,e,i,r){if(!t.getShaderParameter(e,t.COMPILE_STATUS)){var n=t.getShaderInfoLog(e);return console.error("compile "+i+" error: "+n,(null!=r?r:"").split("\n").map((function(t,e){return e+1+" "+t})).join("\n")),{error:n,status:or.fail}}}var pf=function(){function t(t,e){this.engine=t,this.gl=e,this.gl=e,this.shaderLibrary=new ff(t,this),this.maxTextureCount=this.gl.TEXTURE0+this.gl.getParameter(this.gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS)-1,this.reset()}var e=t.prototype;return e.dispose=function(){this.shaderLibrary.dispose(),this.reset()},e.reset=function(){this.glCapabilityCache={},this.activeTextureIndex=fi.TEXTURE0,this.textureUnitDict={},this.currentFramebuffer={},this.pixelStorei={},this.currentRenderbuffer={}},e.toggle=function(t,e){e?this.enable(t):this.disable(t)},e.enable=function(t){!0!==this.glCapabilityCache[t]&&(this.glCapabilityCache[t]=!0,this.gl.enable(t))},e.disable=function(t){!1!==this.glCapabilityCache[t]&&(this.glCapabilityCache[t]=!1,this.gl.disable(t))},e.bindFramebuffer=function(t,e){this.currentFramebuffer[t]!==e&&(this.currentFramebuffer[t]=e,this.gl.bindFramebuffer(t,e))},e.bindRenderbuffer=function(t,e){this.currentRenderbuffer[t]!==e&&(this.currentRenderbuffer[t]=e,this.gl.bindRenderbuffer(t,e))},e.bindSystemFramebuffer=function(){this.bindFramebuffer(this.gl.FRAMEBUFFER,null)},e.useProgram=function(t){this.set1("useProgram",t)},e.clear=function(t){this.gl.clear(t)},e.clearDepth=function(t){this.set1("clearDepth",t)},e.depthFunc=function(t){this.set1("depthFunc",t)},e.depthMask=function(t){this.set1("depthMask",t)},e.polygonOffset=function(t,e){this.set2("polygonOffset",t,e)},e.depthRange=function(t,e){this.set2("depthRange",t,e)},e.clearStencil=function(t){this.set1("clearStencil",t)},e.stencilMask=function(t){this.stencilMaskSeparate(this.gl.FRONT,t),this.stencilMaskSeparate(this.gl.BACK,t)},e.stencilFunc=function(t,e,i){this.stencilFuncSeparate(this.gl.FRONT,t,e,i),this.stencilFuncSeparate(this.gl.BACK,t,e,i)},e.stencilFuncSeparate=function(t,e,i,r){this.set4("stencilFuncSeparate",t,e,i,r)},e.stencilMaskSeparate=function(t,e){this.set2("stencilMaskSeparate",t,e)},e.stencilOp=function(t,e,i){this.stencilOpSeparate(this.gl.FRONT,t,e,i),this.stencilOpSeparate(this.gl.BACK,t,e,i)},e.stencilOpSeparate=function(t,e,i,r){this.set4("stencilOpSeparate",t,e,i,r)},e.cullFace=function(t){this.set1("cullFace",t)},e.frontFace=function(t){this.set1("frontFace",t)},e.clearColor=function(t,e,i,r){this.set4("clearColor",t,e,i,r)},e.colorMask=function(t,e,i,r){this.set4("colorMask",t,e,i,r)},e.blendColor=function(t,e,i,r){this.set4("blendColor",t,e,i,r)},e.blendFunc=function(t,e){this.blendFuncSeparate(t,e,t,e)},e.blendFuncSeparate=function(t,e,i,r){this.set4("blendFuncSeparate",t,e,i,r)},e.blendEquation=function(t){this.set1("blendEquation",t)},e.blendEquationSeparate=function(t,e){this.set2("blendEquationSeparate",t,e)},e.setPixelStorei=function(t,e){this.pixelStorei[t]!==e&&(this.pixelStorei[t]=e,this.gl.pixelStorei(t,e))},e.viewport=function(t,e,i,r){this.set4("viewport",t,e,i,r)},e.activeTexture=function(t){t=Math.min(t,this.maxTextureCount),this.activeTextureIndex!==t&&(this.activeTextureIndex=t,this.gl.activeTexture(t))},e.bindTexture=function(t,e,i){(this.currentTextureBinding!==e||i)&&(this.gl.bindTexture(t,e),this.currentTextureBinding=e),this.textureUnitDict[this.activeTextureIndex]=e},e.set1=function(t,e){this.glCapabilityCache[t]!==e&&(this.glCapabilityCache[t]=e,this.gl[t](e))},e.set2=function(t,e,i){var r=this.glCapabilityCache[t];r||(r=this.glCapabilityCache[t]={x:NaN,y:NaN}),r.x===e&&r.y===i||this.gl[t](r.x=e,r.y=i)},e.set3=function(t,e,i,r){var n=this.glCapabilityCache[t];n||(n=this.glCapabilityCache[t]={x:NaN,y:NaN,z:NaN}),n.x===e&&n.y===i&&n.z===r||this.gl[t](n.x=e,n.y=i,n.z=r)},e.set4=function(t,e,i,r,n){var s=this.glCapabilityCache[t];s||(s=this.glCapabilityCache[t]={x:NaN,y:NaN,z:NaN,w:NaN}),s.x===e&&s.y===i&&s.z===r&&s.w===n||this.gl[t](s.x=e,s.y=i,s.z=r,s.w=n)},e.get=function(t){return this.glCapabilityCache[t]},e.setFloat=function(t,e){t&&this.gl.uniform1f(t,e)},e.setInt=function(t,e){t&&this.gl.uniform1i(t,e)},e.setFloats=function(t,e){t&&this.gl.uniform1fv(t,e)},e.setVector2=function(t,e){this.setFloat2(t,e.x,e.y)},e.setVector3=function(t,e){this.setFloat3(t,e.x,e.y,e.z)},e.setVector4=function(t,e){this.setFloat4(t,e.x,e.y,e.z,e.w)},e.setColor=function(t,e){this.setFloat4(t,e.r,e.g,e.b,e.a)},e.setQuaternion=function(t,e){this.setFloat4(t,e.x,e.y,e.z,e.w)},e.setVector4Array=function(t,e){t&&e.length%4==0&&this.gl.uniform4fv(t,e)},e.setMatrix=function(t,e){t&&this.gl.uniformMatrix4fv(t,!1,e.elements)},e.setMatrix3=function(t,e){t&&this.gl.uniformMatrix3fv(t,!1,e.elements)},e.setMatrixArray=function(t,e){t&&e.length%16==0&&this.gl.uniformMatrix4fv(t,!1,e)},e.setTexture=function(t,e,i){if(t){this.gl.activeTexture(this.gl.TEXTURE0+e);var r=i.target;this.gl.bindTexture(r,i.textureBuffer),this.gl.uniform1i(t,e)}},e.getUniforms=function(t,e){for(var i=[],r=0;r<e.length;r++)i.push(this.gl.getUniformLocation(t,e[r]));return i},e.setFloat4=function(t,e,i,r,n){t&&this.gl.uniform4f(t,e,i,r,n)},e.setFloat3=function(t,e,i,r){t&&this.gl.uniform3f(t,e,i,r)},e.setFloat2=function(t,e,i){t&&this.gl.uniform2f(t,e,i)},t}(),mf=function(t){function e(e,i,r){var n;(n=t.call(this)||this).canvas=e,n.temporaryRTs={};var s=_i({preserveDrawingBuffer:void 0,alpha:!0,stencil:!0,antialias:!0,depth:!0,premultipliedAlpha:!0},r);n.context=new ql(e,i,s);var a=n.context.gl;return ot(a),n.engine=new Kl(a),n.engine.renderer=ho(n),n.pipelineContext=new pf(n.engine,a),n.glRenderer=new Il(n.engine),n.extension=new Wl(ho(n)),n.renderingData={currentFrame:{}},n.framebuffer=new $l({storeAction:{},viewport:[0,0,n.width,n.height],attachments:[new Sl(n.engine,{sourceType:ci.framebuffer,data:{width:n.width,height:n.height}})],depthStencilAttachment:{storageType:Ir.none}},ho(n)),n}Qt(e,t);var i=e.prototype;return i.renderRenderFrame=function(t){var e,i=t;i.resource&&i.resource.color_b.initialize(),i.emptyTexture.initialize(),i.transparentTexture.initialize();var r=i._renderPasses;if(this.isDestroyed)console.error("Renderer is destroyed, target: GLRenderer.");else{null==(e=i.renderer.getShaderLibrary())||e.compileAllShaders(),this.setFramebuffer(null),this.clear(i.clearAction);var n=i.camera;this.renderingData.currentFrame=i,this.renderingData.currentCamera=n,this.setGlobalMatrix("effects_MatrixInvV",n.getInverseViewMatrix()),this.setGlobalMatrix("effects_MatrixV",n.getViewMatrix()),this.setGlobalMatrix("effects_MatrixVP",n.getViewProjectionMatrix()),this.setGlobalMatrix("_MatrixP",n.getProjectionMatrix()),this.setGlobalVector3("effects_WorldSpaceCameraPos",n.position),rt(r);for(var s,a=w(r);!(s=a()).done;){var o=s.value,u=o.delegate;null==u.willBeginRenderPass||u.willBeginRenderPass.call(u,o,this.renderingData),this.renderRenderPass(o),null==u.didEndRenderPass||u.didEndRenderPass.call(u,o,this.renderingData)}for(var h,c=w(r);!(h=c()).done;){h.value.frameCleanup(this)}}},i.renderRenderPass=function(t){this.renderingData.currentPass=t,t.initialize(this),t.configure(this),t.execute(this)},i.renderMeshes=function(t){for(var e,i=this.renderingData.currentPass.delegate,r=w(t);!(e=r()).done;){var n=e.value;null==i.willRenderMesh||i.willRenderMesh.call(i,n,this.renderingData),n.render(this),null==i.didRenderMesh||i.didRenderMesh.call(i,n,this.renderingData)}},i.setGlobalFloat=function(t,e){this.checkGlobalUniform(t),this.renderingData.currentFrame.globalUniforms.floats[t]=e},i.setGlobalVector4=function(t,e){this.checkGlobalUniform(t),this.renderingData.currentFrame.globalUniforms.vector4s[t]=e},i.getGlobalVector4=function(t){return this.renderingData.currentFrame.globalUniforms.vector4s[t]},i.setGlobalInt=function(t,e){this.checkGlobalUniform(t),this.renderingData.currentFrame.globalUniforms.ints[t]=e},i.setGlobalMatrix=function(t,e){this.checkGlobalUniform(t),this.renderingData.currentFrame.globalUniforms.matrices[t]=e},i.setGlobalVector3=function(t,e){this.checkGlobalUniform(t),this.renderingData.currentFrame.globalUniforms.vector3s[t]=e},i.drawGeometry=function(t,e,i){if(void 0===i&&(i=0),t&&e){e.initialize(),t.initialize(),t.flush();var r=this.renderingData;r.currentFrame.editorTransform&&e.setVector4("uEditorTransform",r.currentFrame.editorTransform);try{e.use(this,r.currentFrame.globalUniforms)}catch(t){return void console.error(t)}this.glRenderer.drawGeometry(t,e,i)}},i.setFramebuffer=function(t){t?(this.framebuffer=t,this.framebuffer.bind(),this.setViewport(t.viewport[0],t.viewport[1],t.viewport[2],t.viewport[3])):(this.pipelineContext.bindSystemFramebuffer(),this.setViewport(0,0,this.getWidth(),this.getHeight()))},i.getFramebuffer=function(){return this.framebuffer},i.getTemporaryRT=function(t,e,i,r,n,s){if(this.temporaryRTs[t])return this.temporaryRTs[t];var a,o,u=Ir.none;n===Tn.Linear?a=fi.LINEAR:n===Tn.Nearest&&(a=fi.NEAREST),s===En.RGBA32?o=fi.UNSIGNED_BYTE:s===En.RGBAHalf&&(o=fi.HALF_FLOAT),0===r?u=Ir.none:16===r?u=Ir.depth_16_opaque:24===r&&(u=Ir.depth_24_stencil_8_texture);var h=new Sl(this.engine,{sourceType:ci.framebuffer,minFilter:a,magFilter:a,internalFormat:fi.RGBA,format:fi.RGBA,type:o}),c=new $l({name:t,storeAction:{},viewport:[0,0,e,i],viewportScale:1,isCustomViewport:!0,attachments:[h],depthStencilAttachment:{storageType:u}},this);return this.temporaryRTs[t]=c,c},i.setViewport=function(t,e,i,r){this.pipelineContext.viewport(t,e,i,r)},i.clear=function(t){var e=this.pipelineContext,i=0;if(t.colorAction===hi.clear){var r=t.clearColor;r&&e.clearColor(r[0],r[1],r[2],r[3]),e.colorMask(!0,!0,!0,!0),i=fi.COLOR_BUFFER_BIT}if(t.stencilAction===hi.clear&&(e.stencilMask(255),e.clearStencil(t.clearStencil||0),i|=fi.STENCIL_BUFFER_BIT),t.depthAction===hi.clear){var n=t.clearDepth;e.depthMask(!0),e.clearDepth(Number.isFinite(n)?n:1),i|=fi.DEPTH_BUFFER_BIT}i&&e.clear(i)},i.addLostHandler=function(t){this.context.addLostHandler(t)},i.addRestoreHandler=function(t){this.context.addRestoreHandler(t)},i.getShaderLibrary=function(){return this.pipelineContext.shaderLibrary},i.getWidth=function(){return this.width},i.getHeight=function(){return this.height},i.dispose=function(){var t;this.context.dispose(),this.extension.dispose(),this.pipelineContext.dispose(),null==(t=this.glRenderer)||t.dispose(),this.canvas=null,this.engine.dispose()},i.lost=function(t){t.preventDefault(),this.pipelineContext.dispose(),this.extension.dispose(),this.glRenderer.lost(t)},i.restore=function(){var t=this.context.gl;if(!t)throw new Error("Can not restore automatically because losing gl context.");this.engine.gpuCapability=new Sn(t),this.engine.renderer=this,this.pipelineContext=new pf(this.engine,t),this.glRenderer=new Il(this.engine),this.extension=new Wl(this)},i.resize=function(t,e){var i=this.glRenderer;i&&(this.width===t&&this.height===e||i.resize(t,e))},i.checkGlobalUniform=function(t){var e=this.renderingData.currentFrame.globalUniforms;e.uniforms.includes(t)||e.uniforms.push(t)},Pe(e,[{key:"isDestroyed",get:function(){var t=this.glRenderer;return!t||t.isDestroyed}},{key:"height",get:function(){var t,e;return null!=(e=null==(t=this.glRenderer)?void 0:t.height)?e:0}},{key:"width",get:function(){var t,e;return null!=(e=null==(t=this.glRenderer)?void 0:t.width)?e:0}}]),e}(In),vf="https://www.galacean.com/effects/user/gasrv4ka5sacrwpg#MvjnY",yf="https://www.galacean.com/effects/user/gasrv4ka5sacrwpg#ulfNT",gf="https://www.galacean.com/effects/user/gasrv4ka5sacrwpg#lLlSW",xf="https://www.galacean.com/effects/user/gasrv4ka5sacrwpg#WZaWg",bf="https://www.galacean.com/effects/user/gasrv4ka5sacrwpg#YSWQr",Tf="https://www.galacean.com/effects/user/gasrv4ka5sacrwpg#IzodZ",Ef="https://www.galacean.com/effects/user/gasrv4ka5sacrwpg#X0ulg";var _f=new Map;function wf(t){return _f.has(t)}function Af(t){return _f.get(t)}function Cf(){return Array.from(_f.values())}var Sf=!1,Of=1,Rf=function(t){function e(e){var s;(s=t.call(this)||this).compositions=[],s.displayScale=1,s.resumePending=!1,s.disposed=!1,s.assetManagers=[],s.speed=1,s.baseCompositionIndex=0,s.lost=function(t){var e;null==(e=s.ticker)||e.pause(),s.compositions.forEach((function(e){return e.lost(t)})),s.renderer.lost(t),s.handleEmitEvent("webglcontextlost",t),If(ho(s),!1)};var a=ho(s);s.restore=E((function(){var t;return O(this,(function(e){switch(e.label){case 0:return a.renderer.restore(),[4,Promise.all(a.compositions.map(E((function(t){var e,i,r,n,s,o,u,h,c,l,f,d;return O(this,(function(p){switch(p.label){case 0:return e=t.time,i=t.url,r=t.speed,n=t.keepResource,s=t.reusable,o=t.renderOrder,u=t.transform,h=t.videoState,[4,a.loadScene(i)];case 1:(c=p.sent()).speed=r,c.reusable=s,c.keepResource=n,c.renderOrder=o,c.transform.setPosition(u.position.x,u.position.y,u.position.z),c.transform.setRotation(u.rotation.x,u.rotation.y,u.rotation.z),c.transform.setScale(u.scale.x,u.scale.y,u.scale.z),l=0,p.label=2;case 2:return l<h.length?h[l]?((f=c.textures[l].source.video).currentTime=null!=(d=h[l])?d:0,[4,f.play()]):[3,4]:[3,5];case 3:p.sent(),p.label=4;case 4:return l++,[3,2];case 5:return c.isEnded=!1,c.gotoAndPlay(e),[2,c]}}))}))))];case 1:return a.compositions=e.sent(),a.emit("webglcontextrestored"),null==(t=a.ticker)||t.resume(),W()&&a.canvas&&(a.canvas.style.display="none",r.setTimeout((function(){a.canvas.style.display=""}),0)),[2]}}))})),s.handleResume=function(){s.emit("update",{player:ho(s),playing:!0})},s.handleClick=function(t){var e=t.x,i=t.y,r=[];s.compositions.forEach((function(t){for(var n,a=w(t.hitTest(e,i));!(n=a()).done;){var o=n.value;r.push(_i({},o,{player:ho(s),composition:t}))}}));for(var n=0;n<r.length;n++){var a=r[n],o=a.behavior||jt.NOTIFY;o===jt.NOTIFY?(s.emit("click",_i({},a,{compositionId:a.composition.id,compositionName:a.composition.name})),a.composition.emit("click",_i({},a,{compositionId:a.composition.id,compositionName:a.composition.name}))):o===jt.RESUME_PLAYER&&s.resume()}};var o=e.container,u=e.canvas,h=e.fps,c=e.name,l=e.pixelRatio,f=e.manualRender,d=e.reportGPUTime,p=e.renderFramework,m=e.notifyTouch,v=e.onError,y=e.interactive,g=void 0!==y&&y,x=e.renderOptions,b=void 0===x?{}:x,T=e.env,_=void 0===T?"":T,A=b.willCaptureImage,C=b.premultipliedAlpha;if(s.onError=v,Sf||"debug-disable"===p)return kh(s);var S,R=(S=/iPhone OS (\d+)_(\d+)/.exec(n.userAgent))&&("13"===S[1]||"16"===S[1]&&"5"===S[2])?"webgl":"webgl2";p&&(R="webgl"===p?"webgl":"webgl2"),s.reportGPUTime=d,s.pixelRatio=Number.isFinite(l)?l:Y(),s.offscreenMode=!0,s.env=_,s.name=c||""+Of++;try{if(li.length)throw new Error("Errors before player create: "+li.map((function(t,e){return"\n "+(e+1)+": "+t}))+".",{cause:"webgliniterror"});u?s.canvas=u:(Pf(o),s.canvas=i.createElement("canvas"),o.appendChild(s.canvas)),s.container=s.canvas.parentElement,s.renderer=In.create(s.canvas,R,{preserveDrawingBuffer:A,premultipliedAlpha:C}),s.renderer.env=_,s.renderer.addLostHandler({lost:s.lost}),s.renderer.addRestoreHandler({restore:s.restore}),s.gpuCapability=s.renderer.engine.gpuCapability,s.assetService=new tl(s.renderer.engine),f||(s.ticker=new El(h),s.ticker.add(s.tick.bind(ho(s)))),s.event=new Xs(s.canvas,!!m),s.event.bindListeners(),s.event.addEventListener(Us,s.handleClick),s.interactive=g,s.resize(),th(s.gpuCapability.detail)}catch(t){s.handleThrowError(t)}return _f.forEach((function(t){t.gpuCapability.type!==s.gpuCapability.type&&mt.warn("Create player with different WebGL version: old="+t.gpuCapability.type+", new="+s.gpuCapability.type+".\nsee "+Ef+".")})),_f.set(s.canvas,ho(s)),function(){for(var t,e=[],i=w(_f.values());!(t=i()).done;){var r=t.value;r.paused||e.push(r)}e.length>1&&mt.error("Current running player count: "+e.length+", see "+Tf+".",e)}(),If(ho(s),!0),s}Qt(e,t);var s=e.prototype;return s.setSpeed=function(t){isNaN(t)||(this.speed=t)},s.getSpeed=function(){return this.speed},s.getCompositionByName=function(t){return this.compositions.find((function(e){return e.name===t}))},s.getCompositions=function(){return this.compositions.sort((function(t,e){return t.getIndex()-e.getIndex()}))},s.getAssetManager=function(){return this.assetManagers},s.loadScene=function(t,e){var i=this;return E((function(){var r,n,s,a,o,u,h,c,l,f,p,m,v,y,g,x,b,T,_,A;return O(this,(function(C){switch(C.label){case 0:return ot(i.renderer,"Renderer is not exist, maybe the Player has been disabled or in gl 'debug-disable' mode."),a=d.now(),o=[],u=[],c=null==(h=null==e?void 0:e.autoplay)||h,l=null==(n=i.renderer.engine.gpuCapability)||null==(r=n.detail)?void 0:r.asyncShaderCompile,f=i.baseCompositionIndex,gt(t)?(p=o).push.apply(p,[].concat(t)):o.push(t),i.baseCompositionIndex+=o.length,c&&(i.autoPlaying=!0),m=[],[4,Promise.all(o.map(E((function(t,r){var n,s,a,o,h,l,d,p;return O(this,(function(v){switch(v.label){case 0:return n=i.assetService.assembleSceneLoadOptions(t,_i({autoplay:c},e)),s=n.source,a=n.options,h=null!=(o=null==a?void 0:a.autoplay)?o:c,l=new Jc(a),i.assetManagers.push(l),[4,l.loadScene(s,i.renderer,{env:i.env})];case 1:return d=v.sent(),i.disposed?(u.length=0,[2]):(i.assetService.prepareAssets(d,d.assets),i.assetService.updateTextVariables(d,l.options.variables),i.assetService.initializeTexture(d),d.pluginSystem.precompile(d.jsonScene.compositions,i.renderer),(p=i.createComposition(d,a)).setIndex(f+r),u[r]=p,m[r]=h,[2])}}))}))))];case 1:return C.sent(),v=d.now(),[4,new Promise((function(t){var e;null==(e=i.renderer.getShaderLibrary())||e.compileAllShaders((function(){return t(null)}))}))];case 2:for(C.sent(),y=d.now()-v,g=0;g<u.length;g++)m[g]?u[g].play():u[g].pause();for(null==(s=i.ticker)||s.start(),x=u.map((function(t){return t.name})),b=d.now()-a,T=w(u);!(_=T()).done;)(A=_.value).statistic.compileTime=y,A.statistic.firstFrameTime=b;return mt.info("First frame ["+x+"]: "+b.toFixed(4)+"ms."),mt.info("Shader "+(l?"async":"sync")+" compile ["+x+"]: "+y.toFixed(4)+"ms."),[2,gt(t)?u:u[0]]}}))}))()},s.createComposition=function(t,e){var i=this;void 0===e&&(e={});var r=this.renderer,n=new Yu(_i({},e,{renderer:r,width:r.getWidth(),height:r.getHeight(),event:this.event,handleItemMessage:function(t){i.emit("message",t)}}),t);return this.ticker&&e.renderLevel===Nt.B&&this.ticker.setFPS(Math.min(this.ticker.getFPS(),30)),this.env!==As&&this.assetService.createShaderVariant(),this.compositions.push(n),n},s.play=function(){var t;this.offscreenMode&&(this.resize(),this.offscreenMode=!1),this.autoPlaying=!0,this.compositions.map((function(t){t.play()})),null==(t=this.ticker)||t.start()},s.gotoAndPlay=function(t){this.offscreenMode&&(this.resize(),this.offscreenMode=!1),this.autoPlaying=!0,this.compositions.map((function(e){e.gotoAndPlay(t)})),this.ticker?this.ticker.start():this.doTick(0,!0)},s.gotoAndStop=function(t){var e;this.offscreenMode&&(this.resize(),this.offscreenMode=!1),this.autoPlaying=!1,this.compositions.map((function(e){e.gotoAndStop(t)})),this.ticker&&!(null==(e=this.ticker)?void 0:e.getPaused())||this.doTick(0,!0),this.emit("update",{player:this,playing:!1})},s.playSequence=function(t){for(var e,i=function(e){t[e].on("end",(function(){t[e+1].play()}))},r=0;r<t.length-1;r++)i(r);t[0].play(),null==(e=this.ticker)||e.start()},s.pause=function(t){var e;this.paused||(null==(e=this.ticker)||e.pause(),this.emit("pause"),this.emit("update",{player:this,playing:!1}),t&&t.offloadTexture&&this.offloadTexture())},s.resume=function(){var t=this;return E((function(){var e;return O(this,(function(i){switch(i.label){case 0:return t.resumePending?[2]:t.paused?(t.resumePending=!0,[4,Promise.all(t.compositions.map((function(t){return t.reloadTexture()})))]):[3,2];case 1:i.sent(),t.resumePending=!1,t.handleResume(),i.label=2;case 2:return null==(e=t.ticker)||e.resume(),[2]}}))}))()},s.tick=function(t){this.doTick(t,this.forceRenderNextFrame),this.forceRenderNextFrame=!1},s.doTick=function(t,e){var i,r=this,n=this.renderer.engine.renderErrors;n.size>0&&(this.handleEmitEvent("rendererror",n.values().next().value),null==(i=this.ticker)||i.pause());t=Math.min(t,33)*this.speed;var s=this.compositions,a=!1;s.sort((function(t,e){return t.getIndex()-e.getIndex()}));for(var o,u=[],h=0;h<s.length;h++){var c=s[h];c.textureOffloaded?(a=!0,mt.error("Composition "+c.name+" texture offloaded, skip render."),u.push(c)):(!c.isDestroyed&&c.renderer&&c.update(t),c.isDestroyed||u.push(c))}if(this.compositions=u,this.baseCompositionIndex=this.compositions.length,a)return this.handleEmitEvent("rendererror",new Error("Play when texture offloaded.")),null==(o=this.ticker)?void 0:o.pause();if(!this.paused||e){var l=this.gpuCapability.level,f=this.renderer.context.gl,d=2===l&&this.reportGPUTime?ai(f):void 0;if(null==d||d.begin(),this.compositions.length||this.compositions.length<s.length||e){this.renderer.setFramebuffer(null),this.renderer.clear({stencilAction:hi.clear,clearStencil:0,depthAction:hi.clear,clearDepth:1,colorAction:hi.clear,clearColor:[0,0,0,0]});for(var p=0;p<s.length;p++)!s[p].renderFrame.isDestroyed&&this.renderer.renderRenderFrame(s[p].renderFrame)}null==d||d.end(),null==d||d.getTime().then((function(t){return null==r.reportGPUTime?void 0:r.reportGPUTime.call(r,null!=t?t:0)})).catch,this.autoPlaying&&this.emit("update",{player:this,playing:!0})}},s.resizeToAspect=function(t,e){void 0===e&&(e=1),t!==this.displayAspect&&(this.displayAspect=t),e!==this.displayScale&&(this.displayScale=e),this.resize()},s.resize=function(){var t,e,r,n,s=this.canvas.parentElement;if(s){var a=this.getTargetSize(s);t=a[0],e=a[1],r=a[2],n=a[3]}else t=r=this.canvas.width,e=n=this.canvas.height;var o=t/e;if(t&&e){var u,h=i.documentElement.clientWidth;r>2*h&&mt.error("DPI overflowed, width "+r+" is more than 2x document width "+h+", see "+yf+".");var c=this.env?this.gpuCapability.detail.maxTextureSize:2048;(r>c||n>c)&&(mt.error("Container size overflowed "+r+"x"+n+", see "+vf+"."),o>1?(r=Math.round(c),n=Math.round(c/o)):(n=Math.round(c),r=Math.round(c*o))),this.renderer.resize(r,n),this.canvas.style.width=t+"px",this.canvas.style.height=e+"px",mt.info("Resize player "+this.name+" ["+r+","+n+","+t+","+e+"]."),null==(u=this.compositions)||u.forEach((function(t){t.camera.aspect=o}))}},s.clearCanvas=function(t){t?this.renderer.clear({stencilAction:hi.clear,clearStencil:0,depthAction:hi.clear,clearDepth:1,colorAction:hi.clear,clearColor:[0,0,0,0]}):this.forceRenderNextFrame=!0},s.destroyCurrentCompositions=function(){this.compositions.forEach((function(t){return t.dispose()})),this.compositions.length=0,this.baseCompositionIndex=0},s.dispose=function(t){var e;if(mt.info("Call player destroyed: "+this.name+"."),!this.disposed){_f.delete(this.canvas),this.pause(),null==(e=this.ticker)||e.stop(),this.assetManagers.forEach((function(t){return t.dispose()})),this.compositions.forEach((function(t){return t.dispose()})),this.compositions.length=0,this.renderer&&(this.renderer.context.removeLostHandler({lost:this.lost}),this.renderer.context.removeRestoreHandler({restore:this.restore}),this.renderer.dispose(!t)),this.event&&this.event.dispose(),this.assetService.dispose(),If(this,!1),A(this.canvas,p)&&!t&&this.renderer.context&&(zh.dispose(),this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.canvas.remove());var i="Never use destroyed player: "+this.name+" again, see "+bf+".",r=function(){return function(t){throw new Error(t)}(i)},n=function(){return t=i,Promise.reject(t);var t};this.tick=r,this.resize=r,this.loadScene=n,this.play=n,this.gotoAndPlay=n,this.gotoAndStop=n,this.playSequence=r,this.destroyCurrentCompositions=r,this.resume=n,this.disposed=!0}},s.offloadTexture=function(){this.compositions.forEach((function(t){return t.offloadTexture()}))},s.getTargetSize=function(t){Pf(t);var e,i,n=this.displayAspect,s=null==r.getComputedStyle?void 0:r.getComputedStyle.call(r,t),a=0,o=0;(s?(a=parseInt(s.width,10),o=parseInt(s.height,10)):(a=t.clientWidth,o=t.clientHeight),n)?a/o>n?e=(i=o*this.displayScale)*n:i=(e=a*this.displayScale)/n:(e=a,i=o);var u=this.pixelRatio,h=e,c=i;if(e=Math.round(e*u),(i=Math.round(i*u))<1||i<1){if(!this.offscreenMode)throw new Error("Invalid container size "+e+"x"+i+", see "+gf+".");e=i=h=c=1}return[h,c,e,i]},s.handleThrowError=function(t){if(!this.onError)throw t;this.onError(t)},s.handleEmitEvent=function(t,e){this.onError?A(e,b)?this.onError(new Error(e.type,{cause:t}),e):A(e,Error)?this.onError(new Error(e.message,{cause:t}),e):this.onError(new Error("Unknown error.",{cause:t}),e):(console.warn("["+t+"] event is deprecated, please use 'onError' instead."),this.emit(t,e))},Pe(e,[{key:"compositionCount",get:function(){return this.compositions.length}},{key:"hasPlayable",get:function(){return this.compositions.length>0}},{key:"paused",get:function(){var t;return null==(t=this.ticker)?void 0:t.getPaused()}},{key:"interactive",get:function(){return this.event.enabled},set:function(t){this.event.enabled=t}}]),e}(Bu);function Mf(t){Sf=!!t}function If(t,e){Object.keys(St).forEach((function(i){var r=St[i],n=e?r.onPlayerCreated:r.onPlayerDestroy;null==n||n(t)}))}function Pf(t){if(null==t)throw new Error("Container is not an HTMLElement, see "+xf+".")}S([function(t,e,i){var r=i.value;return i.value=E((function(){var e,i,n,s,a=arguments;return O(this,(function(o){switch(o.label){case 0:for(e=a.length,i=new Array(e),n=0;n<e;n++)i[n]=a[n];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,r.apply(this,i)];case 2:return[2,o.sent()];case 3:return s=o.sent(),t.handleThrowError.call(this,s),[3,4];case 4:return[2]}}))})),i}],Rf.prototype,"loadScene",null),Yi.create=function(t,e){return new Sl(t,e)},Yi.createWithData=function(t,e,i){void 0===e&&(e=et("#fff")),void 0===i&&(i={});var r=i.type,n=void 0===r?fi.UNSIGNED_BYTE:r,s=i.format,a=void 0===s?fi.RGBA:s,o=i.internalFormat,u=i.wrapS,h=void 0===u?fi.MIRRORED_REPEAT:u,c=i.wrapT,l=void 0===c?fi.MIRRORED_REPEAT:c,f=i.minFilter,d=void 0===f?fi.NEAREST:f,p=i.magFilter,m=void 0===p?fi.NEAREST:p,v=i.flipY,y=void 0!==v&&v;return new Sl(t,{data:e,type:n,sourceType:ci.data,format:a,internalFormat:o||a,wrapS:h,wrapT:l,minFilter:d,magFilter:m,flipY:y})},cr.create=function(t,e){return new Yl(t,e)},Cr.create=function(t,e){return new zl(t,e)},Dr.create=function(t,e){return new Dr(t,e)},An.create=function(t){return new Ql(t)},Mn.create=function(t,e){return new $l(t,e)},In.create=function(t,e,i){return new mf(t,e,i)},bl.create=function(t){return new Kl(t)};var Lf="2.5.0-alpha.6";mt.info("Player version: "+Lf+".");export{qt as AbstractPlugin,lh as ActivationPlayable,fh as ActivationPlayableAsset,yu as ActivationTrack,dh as AnimationClip,ph as AnimationClipPlayable,Wh as Asset,Kh as AssetLoader,Jc as AssetManager,tl as AssetService,Ar as BYTES_TYPE_MAP,Ls as BaseRenderComponent,Be as Behaviour,Va as BezierCurve,Da as BezierCurvePath,ka as BezierCurveQuat,Zh as BinaryAsset,bn as COMPRESSED_TEXTURE,yr as COPY_FRAGMENT_SHADER,mr as COPY_MESH_SHADER_ID,vr as COPY_VERTEX_SHADER,rh as CalculateLoader,mo as Camera,Ds as CameraController,zs as CameraVFXItemLoader,Qa as ColorCurve,Ou as ColorPropertyPlayableAsset,Su as ColorPropertyTrack,Ue as Component,Yu as Composition,zu as CompositionComponent,Gh as DEFAULT_FONTS,Tl as DEFAULT_FPS,Qh as Database,lt as Deferred,pt as DestroyOptions,wi as Downloader,pr as EFFECTS_COPY_MESH_NAME,Us as EVENT_TYPE_CLICK,js as EVENT_TYPE_TOUCH_END,Gs as EVENT_TYPE_TOUCH_MOVE,Bs as EVENT_TYPE_TOUCH_START,ti as EffectComponent,ze as EffectsObject,xl as EffectsPackage,Lh as Ellipse,bl as Engine,Bu as EventEmitter,Xs as EventSystem,Vs as Fake3DAnimationMode,Ns as Fake3DComponent,Tn as FilterMode,Ks as Float16ArrayWrapper,Ru as FloatPropertyPlayableAsset,xu as FloatPropertyTrack,Mn as Framebuffer,Kl as GLEngine,zl as GLGeometry,mf as GLRenderer,ur as GLSLVersion,Sn as GPUCapability,Cr as Geometry,wn as GlobalUniforms,La as GradientValue,Dh as GraphicsPath,Cs as HELP_LINK,ks as HitTestType,to as InteractComponent,Zs as InteractLoader,$a as InteractMesh,Uu as Item,Qi as KTXTexture,Fa as LineSegments,Pa as LinearValue,ui as MaskMode,lr as MaskProcessor,cr as Material,nr as MaterialDataBlock,rr as MaterialRenderType,_u as MaterialTrack,Dr as Mesh,ro as MeshCollider,Iu as ObjectBindingTrack,F as OrderType,As as PLAYER_OPTIONS_ENV_EDITOR,Eo as POST_PROCESS_SETTINGS,Lo as ParticleBehaviourPlayable,Fo as ParticleBehaviourPlayableAsset,ih as ParticleLoader,No as ParticleMesh,Go as ParticleSystem,Bo as ParticleSystemRenderer,wu as ParticleTrack,_r as PassTextureCache,Na as PathSegments,Rf as Player,Pt as PluginSystem,Fh as PolyStar,Sh as Polygon,ei as PostProcessVolume,gu as PropertyTrack,mn as RENDER_PASS_NAME_PREFIX,bo as RENDER_PREFER_LOOKUP_TEXTURE,xo as RUNTIME_ENV,Ra as RandomSetValue,Ma as RandomValue,Ia as RandomVectorValue,yn as RenderFrame,Xr as RenderPass,Ir as RenderPassAttachmentStorageType,Br as RenderPassDestroyAttachmentType,zr as RenderPassPriorityNormal,Ur as RenderPassPriorityPostprocess,kr as RenderPassPriorityPrepare,Gr as RenderTargetHandle,En as RenderTextureFormat,An as Renderbuffer,In as Renderer,Ge as RendererComponent,vu as RuntimeClip,_s as SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0,ws as SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0,Ts as SEMANTIC_PRE_COLOR_ATTACHMENT_0,Es as SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0,bs as SPRITE_VERTEX_STRIDE,Hc as Scene,wr as SemanticMap,qh as SerializationHelper,dr as Shader,or as ShaderCompileResultStatus,cn as ShaderFactory,oi as ShaderType,fr as ShaderVariant,Fs as ShapeComponent,Nh as ShapePath,Qu as SpriteColorPlayableAsset,bu as SpriteColorTrack,Ju as SpriteComponent,no as SpriteLoader,Ph as StarType,Oa as StaticValue,Mu as SubCompositionPlayableAsset,Tu as SubCompositionTrack,To as TEMPLATE_USE_OFFSCREEN_CANVAS,Xh as TextComponent,Hh as TextComponentBase,Uh as TextLayout,Yh as TextLoader,Bh as TextStyle,Yi as Texture,tr as TextureFactory,hi as TextureLoadAction,ci as TextureSourceType,Pr as TextureStoreAction,El as Ticker,Lu as TimelineAsset,pu as TimelineClip,Fu as TimelinePlayable,mu as TrackAsset,Vu as TrackSortWrapper,tu as TrackType,fo as Transform,hh as TransformAnimationPlayable,ch as TransformPlayableAsset,Eu as TransformTrack,Wu as VFXItem,Sa as ValueGetter,Za as Vector2Curve,ku as Vector2PropertyPlayableAsset,Cu as Vector2PropertyTrack,Wa as Vector4Curve,Du as Vector4PropertyPlayableAsset,Au as Vector4PropertyTrack,nt as addByOrder,D as addItem,z as addItemWithOrder,Ct as applyMixins,ot as assertExist,ut as asserts,At as base64ToFile,Hr as blend,Th as buildLine,ea as calculateTranslation,zh as canvasPool,yh as closePointEps,rn as colorGradingFrag,j as colorStopsFromGradient,B as colorToArr,qc as combineImageTemplate,gr as createCopyShader,si as createGLContext,ja as createKeyFrameMeta,Wn as createShape,Ka as createValueGetter,gh as curveEps,ha as decimalEqual,Ot as defaultPlugins,Bi as deserializeMipmapTexture,Mf as disableAllPlayer,vs as earcut,Ne as effectsClass,Ve as effectsClassStore,U as enlargeBuffer,$h as ensureFixedNumber,ia as ensureVec3,xn as findPreviousRenderPass,nn as gaussianDownFrag,sn as gaussianDownHFrag,an as gaussianDownVFrag,on as gaussianUpFrag,Sr as generateEmptyTypedArray,wt as generateGUID,Wi as generateHalfFloatTexture,Ki as generateTransparentTexture,qi as generateWhiteTexture,Cf as getActivePlayers,Zc as getBackgroundImage,G as getColorFromGradientStops,wo as getConfig,er as getDefaultTextureFactory,Rs as getGeometryByShape,Os as getGeometryTriangles,Ji as getKTXTextureOptions,Ga as getKeyFrameMetaByRawValue,ke as getMergedStore,zo as getParticleMeshShader,Y as getPixelRatio,Af as getPlayerByCanvas,xi as getPreMultiAlpha,Uc as getStandardComposition,zc as getStandardImage,Xc as getStandardItem,Dc as getStandardJSON,gn as getTextureSize,fi as glContext,yi as glType2VertexFormatType,ai as gpuTimer,et as imageDataFromColor,it as imageDataFromGradient,li as initErrors,di as initGLContext,Wr as integrate,X as interpolateColor,$ as isAlipayMiniApp,q as isAndroid,gt as isArray,Tt as isCanvas,wf as isCanvasUsedByPlayer,xt as isFunction,W as isIOS,Z as isIOSByUA,J as isMiniProgram,bt as isObject,K as isOpenHarmony,Q as isSimulatorCellPhone,yt as isString,sr as isUniformStruct,ar as isUniformStructArray,ht as isValidFontFamily,pi as isWebGL2,tt as isWechatMiniApp,qr as itemFrag,Yr as itemFrameFrag,Zr as itemVert,Ri as loadAVIFOptional,Li as loadBinary,Vi as loadBlob,Ii as loadImage,zi as loadMedia,Di as loadVideo,Si as loadWebPOptional,mt as logger,Vr as math,$u as maxSpriteMeshItemCount,Uo as modifyMaxKeyframeShader,aa as nearestPowerOfTwo,vt as noop,ac as normalizeColor,ca as numberToFix,H as parsePercent,Kr as particleFrag,sa as particleOriginTranslateMap,Vo as particleUniformTypeMap,Qr as particleVert,Wc as passRenderLevel,St as pluginLoaderMap,Et as randomInRange,Mt as registerPlugin,k as removeItem,Ms as rotateVec2,en as screenMeshVert,De as serialize,bi as setBlendMode,Ao as setConfig,ir as setDefaultTextureFactory,Ei as setMaskMode,eh as setMaxSpriteMeshItemCount,oa as setRayFromCamera,Ti as setSideMode,th as setSpriteMeshMaxItemCountByGPU,rt as sortByOrder,Me as spec,un as thresholdFrag,_t as throwDestroyedError,Jr as trailVert,Qs as translatePoint,ua as trianglesFromRect,It as unregisterPlugin,gi as valIfUndefined,$r as value,tn as valueDefine,ra as vecFill,na as vecMulCombine,Lf as version,vi as vertexFormatType2GLType};
|
|
2
2
|
//# sourceMappingURL=alipay.mjs.map
|